¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.eam.controller; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | import java.io.IOException; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.net.URLDecoder; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.jeecg.common.api.vo.Result; |
| | | import org.jeecg.common.system.query.QueryGenerator; |
| | | import org.jeecg.common.util.DateUtils; |
| | | import org.jeecg.common.util.oConvertUtils; |
| | | import org.jeecg.modules.eam.entity.Mtbf; |
| | | import org.jeecg.modules.eam.service.IMtbfService; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import org.jeecgframework.poi.excel.ExcelImportUtil; |
| | | import org.jeecgframework.poi.excel.def.NormalExcelConstants; |
| | | import org.jeecgframework.poi.excel.entity.ExportParams; |
| | | import org.jeecgframework.poi.excel.entity.ImportParams; |
| | | import org.jeecgframework.poi.excel.view.JeecgEntityExcelView; |
| | | import org.jeecg.common.system.base.controller.JeecgController; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | import org.springframework.web.multipart.MultipartHttpServletRequest; |
| | | import org.springframework.web.servlet.ModelAndView; |
| | | import com.alibaba.fastjson.JSON; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.jeecg.common.aspect.annotation.AutoLog; |
| | | |
| | | /** |
| | | * @Description: mom_eam_mtbf |
| | | * @Author: jeecg-boot |
| | | * @Date: 2025-06-12 |
| | | * @Version: V1.0 |
| | | */ |
| | | @Api(tags="mom_eam_mtbf") |
| | | @RestController |
| | | @RequestMapping("/eam/mtbf") |
| | | @Slf4j |
| | | public class MtbfController extends JeecgController<Mtbf, IMtbfService> { |
| | | @Autowired |
| | | private IMtbfService mtbfService; |
| | | |
| | | /** |
| | | * å页å表æ¥è¯¢ |
| | | * |
| | | * @param mtbf |
| | | * @param pageNo |
| | | * @param pageSize |
| | | * @param req |
| | | * @return |
| | | */ |
| | | //@AutoLog(value = "mom_eam_mtbf-å页å表æ¥è¯¢") |
| | | @ApiOperation(value="mom_eam_mtbf-å页å表æ¥è¯¢", notes="mom_eam_mtbf-å页å表æ¥è¯¢") |
| | | @GetMapping(value = "/list") |
| | | public Result<IPage<Mtbf>> queryPageList(Mtbf mtbf, |
| | | @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, |
| | | @RequestParam(name="pageSize", defaultValue="10") Integer pageSize, |
| | | HttpServletRequest req) { |
| | | QueryWrapper<Mtbf> queryWrapper = QueryGenerator.initQueryWrapper(mtbf, req.getParameterMap()); |
| | | Page<Mtbf> page = new Page<Mtbf>(pageNo, pageSize); |
| | | IPage<Mtbf> pageList = mtbfService.page(page, queryWrapper); |
| | | return Result.OK(pageList); |
| | | } |
| | | |
| | | |
| | | @GetMapping("/getMTBF") |
| | | public Result<?> getMTBF(@RequestParam("pageNo") Integer pageNo, |
| | | @RequestParam("pageSize") Integer pageSize, |
| | | @RequestParam Map<String, Object> params) { |
| | | String faultStartTime = (String)params.get("faultStartTime"); |
| | | String faultEndTime = (String)params.get("faultEndTime"); |
| | | if(org.apache.commons.lang3.StringUtils.isBlank(faultStartTime) && StringUtils.isBlank(faultEndTime)){ |
| | | Date dayAfter = DateUtils.getDayAfter(new Date(), -6); |
| | | SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); |
| | | dateFormat.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));// 设置å京æ¶åº |
| | | params.put("faultStartTime",dateFormat.format(dayAfter)); |
| | | |
| | | String currentDateStr = DateUtils.getCurrentDateStr(); |
| | | params.put("faultEndTime",currentDateStr); |
| | | } |
| | | IPage<Map<String, Object>> mtbf = mtbfService.getMTBF(pageNo, pageSize, params); |
| | | return Result.ok(mtbf); |
| | | } |
| | | |
| | | /** |
| | | * æ·»å |
| | | * |
| | | * @param mtbf |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "mom_eam_mtbf-æ·»å ") |
| | | @ApiOperation(value="mom_eam_mtbf-æ·»å ", notes="mom_eam_mtbf-æ·»å ") |
| | | //@RequiresPermissions("org.jeecg.modules.mdc:mom_eam_mtbf:add") |
| | | @PostMapping(value = "/add") |
| | | public Result<String> add(@RequestBody Mtbf mtbf) { |
| | | mtbfService.save(mtbf); |
| | | return Result.OK("æ·»å æåï¼"); |
| | | } |
| | | |
| | | /** |
| | | * ç¼è¾ |
| | | * |
| | | * @param mtbf |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "mom_eam_mtbf-ç¼è¾") |
| | | @ApiOperation(value="mom_eam_mtbf-ç¼è¾", notes="mom_eam_mtbf-ç¼è¾") |
| | | //@RequiresPermissions("org.jeecg.modules.mdc:mom_eam_mtbf:edit") |
| | | @RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST}) |
| | | public Result<String> edit(@RequestBody Mtbf mtbf) { |
| | | mtbfService.updateById(mtbf); |
| | | return Result.OK("ç¼è¾æå!"); |
| | | } |
| | | |
| | | /** |
| | | * éè¿idå é¤ |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "mom_eam_mtbf-éè¿idå é¤") |
| | | @ApiOperation(value="mom_eam_mtbf-éè¿idå é¤", notes="mom_eam_mtbf-éè¿idå é¤") |
| | | //@RequiresPermissions("org.jeecg.modules.mdc:mom_eam_mtbf:delete") |
| | | @DeleteMapping(value = "/delete") |
| | | public Result<String> delete(@RequestParam(name="id",required=true) String id) { |
| | | mtbfService.removeById(id); |
| | | return Result.OK("å 餿å!"); |
| | | } |
| | | |
| | | /** |
| | | * æ¹éå é¤ |
| | | * |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "mom_eam_mtbf-æ¹éå é¤") |
| | | @ApiOperation(value="mom_eam_mtbf-æ¹éå é¤", notes="mom_eam_mtbf-æ¹éå é¤") |
| | | //@RequiresPermissions("org.jeecg.modules.mdc:mom_eam_mtbf:deleteBatch") |
| | | @DeleteMapping(value = "/deleteBatch") |
| | | public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) { |
| | | this.mtbfService.removeByIds(Arrays.asList(ids.split(","))); |
| | | return Result.OK("æ¹éå 餿å!"); |
| | | } |
| | | |
| | | /** |
| | | * éè¿idæ¥è¯¢ |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | //@AutoLog(value = "mom_eam_mtbf-éè¿idæ¥è¯¢") |
| | | @ApiOperation(value="mom_eam_mtbf-éè¿idæ¥è¯¢", notes="mom_eam_mtbf-éè¿idæ¥è¯¢") |
| | | @GetMapping(value = "/queryById") |
| | | public Result<Mtbf> queryById(@RequestParam(name="id",required=true) String id) { |
| | | Mtbf mtbf = mtbfService.getById(id); |
| | | if(mtbf==null) { |
| | | return Result.error("æªæ¾å°å¯¹åºæ°æ®"); |
| | | } |
| | | return Result.OK(mtbf); |
| | | } |
| | | |
| | | /** |
| | | * 导åºexcel |
| | | * |
| | | * @param request |
| | | * @param mtbf |
| | | */ |
| | | //@RequiresPermissions("org.jeecg.modules.mdc:mom_eam_mtbf:exportXls") |
| | | @RequestMapping(value = "/exportXls") |
| | | public ModelAndView exportXls(HttpServletRequest request, Mtbf mtbf) { |
| | | return super.exportXls(request, mtbf, Mtbf.class, "mom_eam_mtbf"); |
| | | } |
| | | |
| | | /** |
| | | * éè¿excel导å
¥æ°æ® |
| | | * |
| | | * @param request |
| | | * @param response |
| | | * @return |
| | | */ |
| | | //@RequiresPermissions("mom_eam_mtbf:importExcel") |
| | | @RequestMapping(value = "/importExcel", method = RequestMethod.POST) |
| | | public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) { |
| | | return super.importExcel(request, response, Mtbf.class); |
| | | } |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.eam.controller; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | import java.io.IOException; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.net.URLDecoder; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import org.jeecg.common.api.vo.Result; |
| | | import org.jeecg.common.system.query.QueryGenerator; |
| | | import org.jeecg.common.util.oConvertUtils; |
| | | import org.jeecg.modules.eam.entity.MtbfLog; |
| | | import org.jeecg.modules.eam.service.IMtbfLogService; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import org.jeecgframework.poi.excel.ExcelImportUtil; |
| | | import org.jeecgframework.poi.excel.def.NormalExcelConstants; |
| | | import org.jeecgframework.poi.excel.entity.ExportParams; |
| | | import org.jeecgframework.poi.excel.entity.ImportParams; |
| | | import org.jeecgframework.poi.excel.view.JeecgEntityExcelView; |
| | | import org.jeecg.common.system.base.controller.JeecgController; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | import org.springframework.web.multipart.MultipartHttpServletRequest; |
| | | import org.springframework.web.servlet.ModelAndView; |
| | | import com.alibaba.fastjson.JSON; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.jeecg.common.aspect.annotation.AutoLog; |
| | | |
| | | /** |
| | | * @Description: mom_eam_mtbf_log |
| | | * @Author: jeecg-boot |
| | | * @Date: 2025-06-17 |
| | | * @Version: V1.0 |
| | | */ |
| | | @Api(tags="mom_eam_mtbf_log") |
| | | @RestController |
| | | @RequestMapping("/eam/mtbfLog") |
| | | @Slf4j |
| | | public class MtbfLogController extends JeecgController<MtbfLog, IMtbfLogService> { |
| | | @Autowired |
| | | private IMtbfLogService mtbfLogService; |
| | | |
| | | /** |
| | | * å页å表æ¥è¯¢ |
| | | * |
| | | * @param mtbfLog |
| | | * @param pageNo |
| | | * @param pageSize |
| | | * @param req |
| | | * @return |
| | | */ |
| | | //@AutoLog(value = "mom_eam_mtbf_log-å页å表æ¥è¯¢") |
| | | @ApiOperation(value="mom_eam_mtbf_log-å页å表æ¥è¯¢", notes="mom_eam_mtbf_log-å页å表æ¥è¯¢") |
| | | @GetMapping(value = "/list") |
| | | public Result<IPage<MtbfLog>> queryPageList(MtbfLog mtbfLog, |
| | | @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, |
| | | @RequestParam(name="pageSize", defaultValue="10") Integer pageSize, |
| | | HttpServletRequest req) { |
| | | QueryWrapper<MtbfLog> queryWrapper = QueryGenerator.initQueryWrapper(mtbfLog, req.getParameterMap()); |
| | | Page<MtbfLog> page = new Page<MtbfLog>(pageNo, pageSize); |
| | | IPage<MtbfLog> pageList = mtbfLogService.page(page, queryWrapper); |
| | | return Result.OK(pageList); |
| | | } |
| | | |
| | | /** |
| | | * æ·»å |
| | | * |
| | | * @param mtbfLog |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "mom_eam_mtbf_log-æ·»å ") |
| | | @ApiOperation(value="mom_eam_mtbf_log-æ·»å ", notes="mom_eam_mtbf_log-æ·»å ") |
| | | //@RequiresPermissions("org.jeecg.modules.mdc:mom_eam_mtbf_log:add") |
| | | @PostMapping(value = "/add") |
| | | public Result<String> add(@RequestBody MtbfLog mtbfLog) { |
| | | mtbfLogService.save(mtbfLog); |
| | | return Result.OK("æ·»å æåï¼"); |
| | | } |
| | | |
| | | /** |
| | | * ç¼è¾ |
| | | * |
| | | * @param mtbfLog |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "mom_eam_mtbf_log-ç¼è¾") |
| | | @ApiOperation(value="mom_eam_mtbf_log-ç¼è¾", notes="mom_eam_mtbf_log-ç¼è¾") |
| | | //@RequiresPermissions("org.jeecg.modules.mdc:mom_eam_mtbf_log:edit") |
| | | @RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST}) |
| | | public Result<String> edit(@RequestBody MtbfLog mtbfLog) { |
| | | mtbfLogService.updateById(mtbfLog); |
| | | return Result.OK("ç¼è¾æå!"); |
| | | } |
| | | |
| | | /** |
| | | * éè¿idå é¤ |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "mom_eam_mtbf_log-éè¿idå é¤") |
| | | @ApiOperation(value="mom_eam_mtbf_log-éè¿idå é¤", notes="mom_eam_mtbf_log-éè¿idå é¤") |
| | | //@RequiresPermissions("org.jeecg.modules.mdc:mom_eam_mtbf_log:delete") |
| | | @DeleteMapping(value = "/delete") |
| | | public Result<String> delete(@RequestParam(name="id",required=true) String id) { |
| | | mtbfLogService.removeById(id); |
| | | return Result.OK("å 餿å!"); |
| | | } |
| | | |
| | | /** |
| | | * æ¹éå é¤ |
| | | * |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "mom_eam_mtbf_log-æ¹éå é¤") |
| | | @ApiOperation(value="mom_eam_mtbf_log-æ¹éå é¤", notes="mom_eam_mtbf_log-æ¹éå é¤") |
| | | //@RequiresPermissions("org.jeecg.modules.mdc:mom_eam_mtbf_log:deleteBatch") |
| | | @DeleteMapping(value = "/deleteBatch") |
| | | public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) { |
| | | this.mtbfLogService.removeByIds(Arrays.asList(ids.split(","))); |
| | | return Result.OK("æ¹éå 餿å!"); |
| | | } |
| | | |
| | | /** |
| | | * éè¿idæ¥è¯¢ |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | //@AutoLog(value = "mom_eam_mtbf_log-éè¿idæ¥è¯¢") |
| | | @ApiOperation(value="mom_eam_mtbf_log-éè¿idæ¥è¯¢", notes="mom_eam_mtbf_log-éè¿idæ¥è¯¢") |
| | | @GetMapping(value = "/queryById") |
| | | public Result<MtbfLog> queryById(@RequestParam(name="id",required=true) String id) { |
| | | MtbfLog mtbfLog = mtbfLogService.getById(id); |
| | | if(mtbfLog==null) { |
| | | return Result.error("æªæ¾å°å¯¹åºæ°æ®"); |
| | | } |
| | | return Result.OK(mtbfLog); |
| | | } |
| | | |
| | | /** |
| | | * 导åºexcel |
| | | * |
| | | * @param request |
| | | * @param mtbfLog |
| | | */ |
| | | //@RequiresPermissions("org.jeecg.modules.mdc:mom_eam_mtbf_log:exportXls") |
| | | @RequestMapping(value = "/exportXls") |
| | | public ModelAndView exportXls(HttpServletRequest request, MtbfLog mtbfLog) { |
| | | return super.exportXls(request, mtbfLog, MtbfLog.class, "mom_eam_mtbf_log"); |
| | | } |
| | | |
| | | /** |
| | | * éè¿excel导å
¥æ°æ® |
| | | * |
| | | * @param request |
| | | * @param response |
| | | * @return |
| | | */ |
| | | //@RequiresPermissions("mom_eam_mtbf_log:importExcel") |
| | | @RequestMapping(value = "/importExcel", method = RequestMethod.POST) |
| | | public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) { |
| | | return super.importExcel(request, response, MtbfLog.class); |
| | | } |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.eam.entity; |
| | | |
| | | import java.io.Serializable; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.util.Date; |
| | | import java.math.BigDecimal; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.*; |
| | | import lombok.Data; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | 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.EqualsAndHashCode; |
| | | import lombok.experimental.Accessors; |
| | | |
| | | /** |
| | | * @Description: mom_eam_mtbf |
| | | * @Author: jeecg-boot |
| | | * @Date: 2025-06-12 |
| | | * @Version: V1.0 |
| | | */ |
| | | @Data |
| | | @TableName("mom_eam_mtbf") |
| | | @Accessors(chain = true) |
| | | @EqualsAndHashCode(callSuper = false) |
| | | @ApiModel(value="mom_eam_mtbf对象", description="mom_eam_mtbf") |
| | | public class Mtbf implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /**id*/ |
| | | @TableId(type = IdType.ASSIGN_ID) |
| | | @ApiModelProperty(value = "id") |
| | | private java.lang.String id; |
| | | /**æ
éæ¶é´*/ |
| | | @Excel(name = "ç»è®¡æ¶é´", width = 15, format = "yyyy-MM-dd") |
| | | @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd") |
| | | @DateTimeFormat(pattern="yyyy-MM-dd") |
| | | @ApiModelProperty(value = "ç»è®¡æ¶é´") |
| | | private java.util.Date faultData; |
| | | |
| | | @ApiModelProperty(value = "å建æ¶é´") |
| | | @Excel(name = "å建æ¶é´", width = 20, format = "yyyy-MM-dd HH:mm:ss") |
| | | @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private java.util.Date createTime; |
| | | |
| | | /**æ
éæ¥ä¿®åç¼å·*/ |
| | | @Excel(name = "æ
éæ¥ä¿®åç¼å·", width = 15) |
| | | @ApiModelProperty(value = "æ
éæ¥ä¿®åç¼å·") |
| | | private java.lang.String reportRepairNum; |
| | | /**设å¤id*/ |
| | | @Excel(name = "设å¤id", width = 15) |
| | | @ApiModelProperty(value = "设å¤id") |
| | | private java.lang.String equipmentId; |
| | | /**æ»å¯å©ç¨æ¶é´*/ |
| | | @Excel(name = "æ»å¯å©ç¨æ¶é´", width = 15) |
| | | @ApiModelProperty(value = "æ»å¯å©ç¨æ¶é´") |
| | | private java.math.BigDecimal totalAvailableTime; |
| | | /**æ
éæ¶é¿*/ |
| | | @Excel(name = "æ
éæ¶é¿", width = 15) |
| | | @ApiModelProperty(value = "æ
éæ¶é¿") |
| | | private java.math.BigDecimal faultTime; |
| | | /**ç»´ä¿®æ¶é¿*/ |
| | | @Excel(name = "ç»´ä¿®æ¶é¿", width = 15) |
| | | @ApiModelProperty(value = "ç»´ä¿®æ¶é¿") |
| | | private java.math.BigDecimal repairTime; |
| | | /**æ æ
éæ¶é¿*/ |
| | | @Excel(name = "æ æ
éæ¶é¿", width = 15) |
| | | @ApiModelProperty(value = "æ æ
éæ¶é¿") |
| | | private java.math.BigDecimal noFaultTime; |
| | | |
| | | @TableField(exist = false) |
| | | private String faultNumber; |
| | | @TableField(exist = false) |
| | | private String mtbf; |
| | | @TableField(exist = false) |
| | | private String mttr; |
| | | @TableField(exist = false) |
| | | private String serviceabilityRate;//å®å¥½ç |
| | | @TableField(exist = false) |
| | | private String startRate;//æ
éç |
| | | |
| | | /**ç¶æ 1æ¥ä¿® 2ç»´ä¿® 4 宿 */ |
| | | @TableField(exist = false) |
| | | private String Status; |
| | | |
| | | /**æ
éå¼å§æ¶é´*/ |
| | | @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @TableField(exist = false) |
| | | private Date faultStartTime; |
| | | |
| | | /**ç»´ä¿®å¼å§æ¶é´*/ |
| | | @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @TableField(exist = false) |
| | | private Date repairStartTime; |
| | | |
| | | /**ç»´ä¿®å®ææ¶é´*/ |
| | | @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @TableField(exist = false) |
| | | private Date repairEndTime; |
| | | |
| | | @TableField(exist = false) |
| | | private String equipmentNum; |
| | | @TableField(exist = false) |
| | | private String equipmentName; |
| | | @TableField(exist = false) |
| | | private String equipmentModel; |
| | | @TableField(exist = false) |
| | | private String workCenterName; |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.eam.entity; |
| | | |
| | | import java.io.Serializable; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.util.Date; |
| | | import java.math.BigDecimal; |
| | | 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.fasterxml.jackson.annotation.JsonFormat; |
| | | 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.EqualsAndHashCode; |
| | | import lombok.experimental.Accessors; |
| | | |
| | | /** |
| | | * @Description: mom_eam_mtbf_log |
| | | * @Author: jeecg-boot |
| | | * @Date: 2025-06-17 |
| | | * @Version: V1.0 |
| | | */ |
| | | @Data |
| | | @TableName("mom_eam_mtbf_log") |
| | | @Accessors(chain = true) |
| | | @EqualsAndHashCode(callSuper = false) |
| | | @ApiModel(value="mom_eam_mtbf_log对象", description="mom_eam_mtbf_log") |
| | | public class MtbfLog implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /**id*/ |
| | | @TableId(type = IdType.ASSIGN_ID) |
| | | @ApiModelProperty(value = "id") |
| | | private java.lang.String id; |
| | | /**æ¥ä¿®å*/ |
| | | @Excel(name = "æ¥ä¿®å", width = 15) |
| | | @ApiModelProperty(value = "æ¥ä¿®å") |
| | | private java.lang.String reportRepairNum; |
| | | /**设å¤id*/ |
| | | @Excel(name = "设å¤id", width = 15) |
| | | @ApiModelProperty(value = "设å¤id") |
| | | private java.lang.String equipmentId; |
| | | /**ä¿ä¿®æ¶é´*/ |
| | | @Excel(name = "ä¿ä¿®æ¶é´", width = 15, format = "yyyy-MM-dd") |
| | | @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd") |
| | | @DateTimeFormat(pattern="yyyy-MM-dd") |
| | | @ApiModelProperty(value = "ä¿ä¿®æ¶é´") |
| | | private java.util.Date reportTime; |
| | | /**ç»´ä¿®æ¥åæ¶é´*/ |
| | | @Excel(name = "ç»´ä¿®æ¥åæ¶é´", width = 15, format = "yyyy-MM-dd") |
| | | @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd") |
| | | @DateTimeFormat(pattern="yyyy-MM-dd") |
| | | @ApiModelProperty(value = "ç»´ä¿®æ¥åæ¶é´") |
| | | private java.util.Date repairStartTime; |
| | | /**ç»´ä¿®å®ææ¶é´*/ |
| | | @Excel(name = "ç»´ä¿®å®ææ¶é´", width = 15, format = "yyyy-MM-dd") |
| | | @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd") |
| | | @DateTimeFormat(pattern="yyyy-MM-dd") |
| | | @ApiModelProperty(value = "ç»´ä¿®å®ææ¶é´") |
| | | private java.util.Date repairFinishTime; |
| | | /**å建æ¶é´*/ |
| | | @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd") |
| | | @DateTimeFormat(pattern="yyyy-MM-dd") |
| | | @ApiModelProperty(value = "å建æ¶é´") |
| | | private java.util.Date createTime; |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.eam.mapper; |
| | | |
| | | import java.util.List; |
| | | |
| | | import org.apache.ibatis.annotations.Param; |
| | | import org.jeecg.modules.eam.entity.MtbfLog; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | |
| | | /** |
| | | * @Description: mom_eam_mtbf_log |
| | | * @Author: jeecg-boot |
| | | * @Date: 2025-06-17 |
| | | * @Version: V1.0 |
| | | */ |
| | | public interface MtbfLogMapper extends BaseMapper<MtbfLog> { |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.eam.mapper; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import org.jeecg.modules.eam.entity.Mtbf; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import org.jeecg.modules.eam.model.MaintenanceCycleVo; |
| | | import org.jeecg.modules.eam.vo.MtbfVo; |
| | | |
| | | /** |
| | | * @Description: mom_eam_mtbf |
| | | * @Author: jeecg-boot |
| | | * @Date: 2025-06-12 |
| | | * @Version: V1.0 |
| | | */ |
| | | public interface MtbfMapper extends BaseMapper<Mtbf> { |
| | | |
| | | List<MtbfVo> getReportRepairTimeList(@Param("yesterday")String yesterday); |
| | | |
| | | IPage<Map<String, Object>> getMTBF(IPage<Map> pageData, @Param("params") Map<String,Object> params); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="org.jeecg.modules.eam.mapper.MtbfLogMapper"> |
| | | |
| | | </mapper> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="org.jeecg.modules.eam.mapper.MtbfMapper"> |
| | | |
| | | |
| | | <select id="getMTBF" parameterType="Map" resultType="Map"> |
| | | select |
| | | isnull(qqq.equipmentId,ttt.id) as equipmentId, |
| | | isnull(qqq.equipmentNum,ttt.num) as equipmentNum, |
| | | isnull(qqq.equipmentName,ttt.name) as equipmentName, |
| | | isnull(qqq.equipmentModel,ttt.model) as equipmentModel, |
| | | isnull(qqq.workCenterName,ttt1.name) as workCenterName, |
| | | isnull(qqq.faultNumber,0) as faultNumber, |
| | | isnull(qqq.totalAvailableTime,(datediff( HOUR, #{params.faultStartTime}, #{params.faultEndTime} ) + 24)) as totalAvailableTime, |
| | | isnull(qqq.faultTime,0) as faultTime, |
| | | isnull(qqq.repairTime,0) as repairTime, |
| | | isnull(qqq.noFaultTime,(datediff( HOUR, #{params.faultStartTime}, #{params.faultEndTime} ) + 24)) as noFaultTime, |
| | | isnull(qqq.mtbf,0) as mtbf, |
| | | isnull(qqq.mttr,0) as mttr, |
| | | isnull(qqq.serviceabilityRate,STR( ( 1 * 100 ), 10, 2 ) + '%') as serviceabilityRate, |
| | | isnull(qqq.startRate,STR( ( 0 * 100 ), 10, 2 ) + '%') as startRate |
| | | from mom_eam_equipment ttt |
| | | left join mom_base_area ttt1 ON ttt.work_center_id = ttt1.id |
| | | left join ( |
| | | SELECT |
| | | tt.equipmentId, |
| | | tt.equipmentNum, |
| | | tt.equipmentName, |
| | | tt.equipmentModel, |
| | | tt.workCenterName, |
| | | COUNT ( tt.equipmentId ) AS faultNumber, |
| | | SUM ( totalAvailableTime ) AS totalAvailableTime, |
| | | SUM ( faultTime ) AS faultTime, |
| | | SUM ( repairTime ) AS repairTime, |
| | | SUM ( noFaultTime ) AS noFaultTime, |
| | | SUM ( noFaultTime ) / COUNT ( tt.equipmentId ) AS mtbf, |
| | | SUM ( repairTime ) / COUNT ( tt.equipmentId ) AS mttr, |
| | | STR((SUM ( noFaultTime ) / SUM ( totalAvailableTime ) * 100), 10, 2) + '%' AS serviceabilityRate, |
| | | STR((SUM ( faultTime ) / SUM ( totalAvailableTime ) * 100), 10, 2)+ '%' AS startRate |
| | | FROM |
| | | ( |
| | | SELECT |
| | | t1.report_repair_num AS reportRepairNum, |
| | | t1.equipment_id AS equipmentId, |
| | | t2.num AS equipmentNum, |
| | | t2.name AS equipmentName, |
| | | t2.model AS equipmentModel, |
| | | t3.name AS workCenterName, |
| | | SUM ( t1.total_available_time ) AS totalAvailableTime, |
| | | SUM ( t1.fault_time ) AS faultTime, |
| | | SUM ( t1.repair_time ) AS repairTime, |
| | | SUM ( t1.no_fault_time ) AS noFaultTime |
| | | FROM |
| | | mom_eam_mtbf t1 |
| | | LEFT JOIN mom_eam_equipment t2 ON t1.equipment_id = t2.id |
| | | LEFT JOIN mom_base_area t3 ON t2.work_center_id = t3.id |
| | | where 1=1 |
| | | <if test="params.equipmentNum != null and params.equipmentNum != ''"> |
| | | and t2.num like concat('%',#{params.equipmentNum},'%') |
| | | </if> |
| | | <if test="params.workCenterId != null and params.workCenterId != ''"> |
| | | and t3.id = #{params.workCenterId} |
| | | </if> |
| | | <if test="params.equipmentImportanceId != null and params.equipmentImportanceId != ''"> |
| | | and t2.equipment_importance_id = #{params.equipmentImportanceId} |
| | | </if> |
| | | <if test="params.specificEquipment != null and params.specificEquipment != ''"> |
| | | and t2.specific_equipment = #{params.specificEquipment} |
| | | </if> |
| | | AND SUBSTRING ( CONVERT ( VARCHAR ( 10 ), t1.fault_data, 120 ), 1, 10 ) >= #{params.faultStartTime} |
| | | AND SUBSTRING ( CONVERT ( VARCHAR ( 10 ), t1.fault_data, 120 ), 1, 10 ) <= #{params.faultEndTime} |
| | | GROUP BY |
| | | t1.report_repair_num, |
| | | t1.equipment_id, |
| | | t2.num, |
| | | t2.name, |
| | | t2.model, |
| | | t3.name |
| | | ) tt |
| | | GROUP BY |
| | | tt.equipmentId, |
| | | tt.equipmentNum, |
| | | tt.equipmentName, |
| | | tt.equipmentModel, |
| | | tt.workCenterName) qqq on ttt.id = qqq.equipmentId |
| | | where 1= 1 and ttt.work_center_id is not null |
| | | <if test="params.equipmentNum != null and params.equipmentNum != ''"> |
| | | and ttt.num like concat('%',#{params.equipmentNum},'%') |
| | | </if> |
| | | <if test="params.workCenterId != null and params.workCenterId != ''"> |
| | | and ttt1.id = #{params.workCenterId} |
| | | </if> |
| | | <if test="params.equipmentImportanceId != null and params.equipmentImportanceId != ''"> |
| | | and ttt.equipment_importance_id = #{params.equipmentImportanceId} |
| | | </if> |
| | | <if test="params.specificEquipment != null and params.specificEquipment != ''"> |
| | | and ttt.specific_equipment = #{params.specificEquipment} |
| | | </if> |
| | | </select> |
| | | |
| | | |
| | | <select id="getReportRepairTimeList" resultType="org.jeecg.modules.eam.vo.MtbfVo"> |
| | | SELECT |
| | | t1.num AS reportRepairNum, |
| | | t1.status, |
| | | t1.equipment_id AS equipmentId, |
| | | t1.fault_time AS faultStartTime, |
| | | t2.create_time AS repairStartTime, |
| | | t2.actual_end_time AS repairEndTime |
| | | FROM |
| | | mom_eam_equipment_report_repair t1 |
| | | LEFT JOIN mom_eam_repair_order t2 ON t2.report_repair_id = t1.id |
| | | WHERE t1.status IN ( '1', '2', '4' ) |
| | | AND ( SUBSTRING ( CONVERT ( VARCHAR ( 10 ), t2.actual_end_time, 120 ), 1, 10 ) = #{yesterday} OR t1.status != '4' ) |
| | | </select> |
| | | </mapper> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.eam.service; |
| | | |
| | | import org.jeecg.modules.eam.entity.MtbfLog; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | |
| | | /** |
| | | * @Description: mom_eam_mtbf_log |
| | | * @Author: jeecg-boot |
| | | * @Date: 2025-06-17 |
| | | * @Version: V1.0 |
| | | */ |
| | | public interface IMtbfLogService extends IService<MtbfLog> { |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.eam.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import org.jeecg.modules.eam.entity.EquipmentMaintenancePlanDetail; |
| | | import org.jeecg.modules.eam.entity.Mtbf; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import org.jeecg.modules.eam.vo.MtbfVo; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @Description: mom_eam_mtbf |
| | | * @Author: jeecg-boot |
| | | * @Date: 2025-06-12 |
| | | * @Version: V1.0 |
| | | */ |
| | | public interface IMtbfService extends IService<Mtbf> { |
| | | |
| | | List<MtbfVo> getReportRepairTimeList(String yesterday); |
| | | |
| | | IPage<Map<String, Object>> getMTBF(Integer pageNo, Integer pageSize, Map<String, Object> params); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.eam.service.impl; |
| | | |
| | | import org.jeecg.modules.eam.entity.MtbfLog; |
| | | import org.jeecg.modules.eam.mapper.MtbfLogMapper; |
| | | import org.jeecg.modules.eam.service.IMtbfLogService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | |
| | | /** |
| | | * @Description: mom_eam_mtbf_log |
| | | * @Author: jeecg-boot |
| | | * @Date: 2025-06-17 |
| | | * @Version: V1.0 |
| | | */ |
| | | @Service |
| | | public class MtbfLogServiceImpl extends ServiceImpl<MtbfLogMapper, MtbfLog> implements IMtbfLogService { |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.eam.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ctc.wstx.util.DataUtil; |
| | | import org.jeecg.common.util.DateUtils; |
| | | import org.jeecg.modules.eam.entity.Mtbf; |
| | | import org.jeecg.modules.eam.entity.MtbfLog; |
| | | import org.jeecg.modules.eam.mapper.MtbfMapper; |
| | | import org.jeecg.modules.eam.service.IMtbfLogService; |
| | | import org.jeecg.modules.eam.service.IMtbfService; |
| | | import org.jeecg.modules.eam.vo.MtbfVo; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.time.Duration; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.ZoneId; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @Description: mom_eam_mtbf |
| | | * @Author: jeecg-boot |
| | | * @Date: 2025-06-12 |
| | | * @Version: V1.0 |
| | | */ |
| | | @Service |
| | | public class MtbfServiceImpl extends ServiceImpl<MtbfMapper, Mtbf> implements IMtbfService { |
| | | |
| | | @Autowired |
| | | @Lazy |
| | | private IMtbfLogService mtbfLogService; |
| | | |
| | | @Override |
| | | public IPage<Map<String, Object>> getMTBF(Integer pageNo, Integer pageSize, Map<String, Object> params) { |
| | | IPage<Map> pageData = new Page<Map>(pageNo, pageSize); |
| | | return super.getBaseMapper().getMTBF(pageData, params) ; |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public List<MtbfVo> getReportRepairTimeList(String yesterday) { |
| | | List<MtbfVo> reportRepairTimeList = this.baseMapper.getReportRepairTimeList(yesterday); |
| | | for (MtbfVo mtbf : reportRepairTimeList) { |
| | | List<MtbfLog> list = mtbfLogService.lambdaQuery().eq(MtbfLog::getReportRepairNum, mtbf.getReportRepairNum()).list(); |
| | | if(list.size()>0){ |
| | | MtbfLog mtbfLog = list.get(0); |
| | | mtbfLog.setReportRepairNum(mtbf.getReportRepairNum()); |
| | | mtbfLog.setEquipmentId(mtbf.getEquipmentId()); |
| | | mtbfLog.setReportTime(mtbf.getFaultStartTime()); |
| | | mtbfLog.setRepairStartTime(mtbf.getRepairStartTime()); |
| | | mtbfLog.setRepairFinishTime(mtbf.getRepairEndTime()); |
| | | mtbfLogService.updateById(mtbfLog); |
| | | }else{ |
| | | MtbfLog mtbfLog = new MtbfLog(); |
| | | mtbfLog.setReportRepairNum(mtbf.getReportRepairNum()); |
| | | mtbfLog.setEquipmentId(mtbf.getEquipmentId()); |
| | | mtbfLog.setReportTime(mtbf.getFaultStartTime()); |
| | | mtbfLog.setRepairStartTime(mtbf.getRepairStartTime()); |
| | | mtbfLog.setRepairFinishTime(mtbf.getRepairEndTime()); |
| | | mtbfLog.setCreateTime(new Date()); |
| | | mtbfLogService.save(mtbfLog); |
| | | } |
| | | Date faultStartTime = mtbf.getFaultStartTime();//æ
éå¼å§æ¶é´ |
| | | Date yesterdayData = DateUtils.getDayAfter(new Date(), -1);//æ¨å¤©æ¥æ |
| | | //æ
éæ¶é´æ¯ä¸æ¯æ¨å¤©åçç |
| | | boolean f = isSameDate(faultStartTime, yesterdayData); |
| | | //è®¡ç®æ
éæ¶é¿ |
| | | Date todayMidnightAsDate = getTodayMidnightAsDate();//仿¥åæ¨ |
| | | |
| | | String status = mtbf.getStatus(); |
| | | Mtbf mtbf1 = new Mtbf(); |
| | | mtbf1.setReportRepairNum(mtbf.getReportRepairNum()); |
| | | mtbf1.setEquipmentId(mtbf.getEquipmentId()); |
| | | mtbf1.setFaultData(new Date()); |
| | | mtbf1.setCreateTime(new Date()); |
| | | mtbf1.setTotalAvailableTime(new BigDecimal(24)); |
| | | if("1".equals(status)){//ç¶æ1ï¼æ¥ä¿® |
| | | //æ
éæ¥ä¿®æ¶é´æ¯æ¨å¤© æ
éæ¶é´ = 24 - æ
éå¼å§æ¶é´ |
| | | if(f){ |
| | | //仿¥åæ¨ - æ¨æ¥æ
éåçæ¶é´ = æ
éæ¶é´ |
| | | double faultTime = getPreciseHoursDifference(faultStartTime, todayMidnightAsDate); |
| | | // double faultTime = getHoursFromYesterdayMidnightToDate(faultStartTime); |
| | | mtbf1.setFaultTime(new BigDecimal(faultTime).setScale(2, RoundingMode.HALF_UP)); |
| | | mtbf1.setNoFaultTime((new BigDecimal(24).subtract(new BigDecimal(faultTime))).setScale(2, RoundingMode.HALF_UP)); |
| | | }else{ |
| | | //æ
éæ¥ä¿®æ¶é´ä¸æ¯æ¨å¤© æ
éæ¶é´ = 24 |
| | | //double faultTime = 24; |
| | | mtbf1.setFaultTime(new BigDecimal(24)); |
| | | mtbf1.setNoFaultTime(new BigDecimal(0)); |
| | | } |
| | | mtbf1.setRepairTime(new BigDecimal(0)); |
| | | this.save(mtbf1); |
| | | }else if("2".equals(status)){//ç¶æ2ï¼ç»´ä¿® |
| | | Date repairStartTime = mtbf.getRepairStartTime(); |
| | | //ç»´ä¿®æ¶é´æ¯ä¸æ¯æ¨å¤©åçç |
| | | boolean rr = isSameDate(repairStartTime, yesterdayData); |
| | | //æ
éæ¥ä¿®æ¶é´æ¯æ¨å¤© æ
éæ¶é´ = 24 - æ
éå¼å§æ¶é´ |
| | | if(f){ |
| | | double faultTime = getPreciseHoursDifference(faultStartTime,todayMidnightAsDate); |
| | | mtbf1.setFaultTime(new BigDecimal(faultTime).setScale(2, RoundingMode.HALF_UP)); |
| | | mtbf1.setNoFaultTime((new BigDecimal(24).subtract(new BigDecimal(faultTime))).setScale(2, RoundingMode.HALF_UP)); |
| | | if(repairStartTime == null){ |
| | | mtbf1.setRepairTime(new BigDecimal(0)); |
| | | }else if(rr){ |
| | | double repairTime = getPreciseHoursDifference(repairStartTime, todayMidnightAsDate); |
| | | mtbf1.setRepairTime(new BigDecimal(repairTime).setScale(2, RoundingMode.HALF_UP)); |
| | | |
| | | } |
| | | //ä¸åå¨ç»´ä¿®æ¶é´æ¯å½å¤©çï¼å ä¸ºå®æ¶ä»»å¡æ¯ä»å¤©æ§è¡ï¼ç®æ¨å¤©çç»æ |
| | | // else{ |
| | | // mtbf1.setRepairTime(new BigDecimal(24)); |
| | | // } |
| | | |
| | | }else{ |
| | | //æ
éæ¥ä¿®æ¶é´ä¸æ¯æ¨å¤© æ
éæ¶é´ = 24 |
| | | mtbf1.setFaultTime(new BigDecimal(24)); |
| | | mtbf1.setNoFaultTime(new BigDecimal(0)); |
| | | if(rr){ |
| | | // double repairTime = getPreciseHoursDifference(todayMidnightAsDate, repairStartTime); |
| | | double repairTime = getHoursFromYesterdayMidnightToDate(repairStartTime); |
| | | mtbf1.setRepairTime(new BigDecimal(repairTime).setScale(2, RoundingMode.HALF_UP)); |
| | | }else{ |
| | | mtbf1.setRepairTime(new BigDecimal(24)); |
| | | } |
| | | } |
| | | // mtbf1.setNoFaultTime(new BigDecimal(0)); |
| | | this.save(mtbf1); |
| | | }else{//ç¶æ4ï¼ä¿®å® |
| | | Date repairStartTime = mtbf.getRepairStartTime(); |
| | | Date repairEndTime = mtbf.getRepairEndTime(); |
| | | if(f){ |
| | | double faultTime = getPreciseHoursDifference(faultStartTime,repairEndTime); |
| | | double repairTime = getPreciseHoursDifference(repairStartTime,repairEndTime); |
| | | mtbf1.setFaultTime(new BigDecimal(faultTime).setScale(2, RoundingMode.HALF_UP)); |
| | | mtbf1.setRepairTime(new BigDecimal(repairTime).setScale(2, RoundingMode.HALF_UP)); |
| | | mtbf1.setNoFaultTime((new BigDecimal(24).subtract(new BigDecimal(faultTime))).setScale(2, RoundingMode.HALF_UP)); |
| | | }else{ |
| | | double repairTime = getHoursFromYesterdayMidnightToDate(repairEndTime); |
| | | mtbf1.setFaultTime(new BigDecimal(repairTime).setScale(2, RoundingMode.HALF_UP)); |
| | | mtbf1.setRepairTime(new BigDecimal(repairTime).setScale(2, RoundingMode.HALF_UP)); |
| | | mtbf1.setNoFaultTime((new BigDecimal(24).subtract(new BigDecimal(repairTime))).setScale(2, RoundingMode.HALF_UP)); |
| | | } |
| | | this.save(mtbf1); |
| | | } |
| | | } |
| | | return reportRepairTimeList; |
| | | } |
| | | |
| | | // æ¹æ³1ï¼è®¡ç®æ¨å¤©åæ¨å°æå®Dateçç²¾ç¡®å°æ¶æ°ï¼å
æ¬å°æ°é¨åï¼ |
| | | public static double getHoursFromYesterdayMidnightToDate(Date targetDate) { |
| | | if (targetDate == null) { |
| | | return 0.0; |
| | | } |
| | | |
| | | // è·åæ¨å¤©åæ¨çæ¶é´å¹¶è½¬æ¢ä¸ºDate |
| | | LocalDateTime yesterdayMidnight = LocalDate.now().minusDays(1).atStartOfDay(); |
| | | Date yesterdayMidnightDate = Date.from( |
| | | yesterdayMidnight.atZone(ZoneId.systemDefault()).toInstant() |
| | | ); |
| | | |
| | | // è®¡ç®æ¯«ç§å·® |
| | | long diffInMillis = targetDate.getTime() - yesterdayMidnightDate.getTime(); |
| | | |
| | | // 转æ¢ä¸ºå°æ¶ï¼å
æ¬å°æ°é¨åï¼ |
| | | return diffInMillis / (1000.0 * 60 * 60); |
| | | } |
| | | |
| | | |
| | | // 计ç®å
å«å°æ°é¨åçå°æ¶å·® |
| | | public static double getPreciseHoursDifference(Date startDate, Date endDate) { |
| | | long diffInMillis = endDate.getTime() - startDate.getTime(); |
| | | return (double) diffInMillis / (1000 * 60 * 60); |
| | | } |
| | | |
| | | // è·åä»å¤©åæ¨çDate对象 |
| | | public static Date getTodayMidnightAsDate() { |
| | | LocalDateTime midnight = LocalDate.now().atStartOfDay(); |
| | | return Date.from(midnight.atZone(ZoneId.systemDefault()).toInstant()); |
| | | } |
| | | |
| | | public static boolean isSameDate(Date date1, Date date2) { |
| | | // å°Date转æ¢ä¸ºLocalDateï¼åªå
å«å¹´ææ¥ï¼ |
| | | LocalDate localDate1 = date1.toInstant() |
| | | .atZone(ZoneId.systemDefault()) |
| | | .toLocalDate(); |
| | | |
| | | LocalDate localDate2 = date2.toInstant() |
| | | .atZone(ZoneId.systemDefault()) |
| | | .toLocalDate(); |
| | | |
| | | // ç´æ¥æ¯è¾ä¸¤ä¸ªLocalDate对象 |
| | | return localDate1.isEqual(localDate2); |
| | | } |
| | | } |