From 7ac98a63354350f520eb1df1a6333a0122125e25 Mon Sep 17 00:00:00 2001 From: yb <1113799@qq.com> Date: 星期三, 10 九月 2025 09:35:27 +0800 Subject: [PATCH] 倍率统计服务bug调整 --- lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentMagnificationServiceImpl.java | 61 ++++++++++++++++++++++++++++-- 1 files changed, 56 insertions(+), 5 deletions(-) diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentMagnificationServiceImpl.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentMagnificationServiceImpl.java index 9237246..9b873b5 100644 --- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentMagnificationServiceImpl.java +++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentMagnificationServiceImpl.java @@ -4,17 +4,27 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.apache.commons.lang3.StringUtils; -import org.jeecg.modules.mdc.entity.*; +import org.apache.shiro.SecurityUtils; +import org.jeecg.common.system.vo.LoginUser; +import org.jeecg.modules.mdc.dto.MdcEquipmentMagnificationDto; +import org.jeecg.modules.mdc.entity.Equipment; +import org.jeecg.modules.mdc.entity.MdcDriveTypeParamConfig; +import org.jeecg.modules.mdc.entity.MdcEquipmentMagnification; +import org.jeecg.modules.mdc.entity.MdcEquipmentRunningSection; import org.jeecg.modules.mdc.mapper.MdcEquipmentMagnificationMapper; import org.jeecg.modules.mdc.service.*; import org.jeecg.modules.mdc.util.DateUtils; -import org.jeecg.modules.mdc.vo.MdcDeviceCalendarVo; import org.jeecg.modules.mdc.vo.MdcEquipmentMagnificationVo; +import org.jeecgframework.poi.excel.def.NormalExcelConstants; +import org.jeecgframework.poi.excel.entity.ExportParams; +import org.jeecgframework.poi.excel.view.JeecgEntityExcelView; import org.springframework.stereotype.Service; +import org.springframework.web.servlet.ModelAndView; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import java.math.BigDecimal; +import java.math.RoundingMode; import java.util.*; @Service @@ -49,10 +59,10 @@ if (mdcMagnification == null) { start = DateUtils.plusTime(DateUtils.getNow(), -5); } else { + start = DateUtils.toDate(mdcMagnification.getTheDate(),DateUtils.STR_DATE ); if (now.toString().equals(start.toString())) { continue; } - start = DateUtils.toDate(mdcMagnification.getTheDate(),DateUtils.STR_DATE ); } List<String> dates = DateUtils.getDatesStringList(start,now); List<MdcDriveTypeParamConfig> list = new ArrayList<>(); @@ -130,6 +140,47 @@ return this.baseMapper.pageList(pageData, magnificationVo); } + @Override + public ModelAndView exportXls(String userId, MdcEquipmentMagnificationVo magnificationVo) { + List<String> equipmentIds = new ArrayList<>(); + if (StringUtils.isNotEmpty(magnificationVo.getParentId()) && StringUtils.isEmpty(magnificationVo.getEquipmentId())) { + if ("2".equals(magnificationVo.getTypeTree())) { + // 閮ㄩ棬灞傜骇 + equipmentIds = mdcEquipmentService.getEquipmentIdsByDepart(userId, magnificationVo.getParentId()); + } else { + // 浜х嚎灞傜骇 + equipmentIds = mdcEquipmentService.getEquipmentIdsProduction(userId, magnificationVo.getParentId()); + } + } else if (StringUtils.isNotEmpty(magnificationVo.getEquipmentId())) { + // 鍗曞彴璁惧淇℃伅 + magnificationVo.setEquipmentIdList(Collections.singletonList(magnificationVo.getEquipmentId())); + } else { + // 鏌ヨ鐢ㄦ埛鎷ユ湁鐨勬墍鏈夎澶囦俊鎭� + if ("2".equals(magnificationVo.getTypeTree())) { + //閮ㄩ棬灞傜骇 + equipmentIds = mdcEquipmentService.getEquipmentIdsByDepart(userId, null); + } else { + //浜х嚎灞傜骇 + equipmentIds = mdcEquipmentService.getEquipmentIdsProduction(userId, null); + } + } + if (magnificationVo.getEquipmentIdList() == null || magnificationVo.getEquipmentIdList().isEmpty()) { + magnificationVo.setEquipmentIdList(equipmentIds); + } + if (magnificationVo.getEquipmentIdList() == null || magnificationVo.getEquipmentIdList().isEmpty()) { + return null; + } + List<MdcEquipmentMagnificationDto> magnificationDtos = super.baseMapper.list(magnificationVo); + ModelAndView mv = new ModelAndView(new JeecgEntityExcelView()); + // 瀵煎嚭鏂囦欢鍚嶇О + mv.addObject(NormalExcelConstants.FILE_NAME, "鍊嶇巼鎶ヨ〃"); + mv.addObject(NormalExcelConstants.CLASS, MdcEquipmentMagnificationDto.class); + LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); + mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("鍊嶇巼鎶ヨ〃", "瀵煎嚭浜�:" + user.getRealname(), "鍊嶇巼鎶ヨ〃")); + mv.addObject(NormalExcelConstants.DATA_LIST, magnificationDtos); + return mv; + } + private MdcEquipmentMagnification selectMagnification(String equipmentId,String date,String drivetype,List<MdcDriveTypeParamConfig> list) { Date startTime = DateUtils.plusTime(DateUtils.getShortDate(date), 0); Date endTime = DateUtils.plusTime(DateUtils.getShortDate(date), 1); @@ -173,14 +224,14 @@ info.setSpindlebeilvValue(bigDecimal); info.setSpindlebeilvNumber(numberSizeList); if (bigDecimal.compareTo(BigDecimal.ZERO) >0 && new BigDecimal(numberSizeList).compareTo(BigDecimal.ZERO) > 0) { - info.setSpindlebeilv(bigDecimal.divide(new BigDecimal(numberSizeList))); + info.setSpindlebeilv(bigDecimal.divide(new BigDecimal(numberSizeList),4, RoundingMode.HALF_UP)); } } if (config.getChineseName().equals(feedbeilv)) { info.setFeedbeilvValue(bigDecimal); info.setFeedbeilvNumber(numberSizeList); if (bigDecimal.compareTo(BigDecimal.ZERO) >0 && new BigDecimal(numberSizeList).compareTo(BigDecimal.ZERO) > 0) { - info.setFeedbeilv(bigDecimal.divide(new BigDecimal(numberSizeList))); + info.setFeedbeilv(bigDecimal.divide(new BigDecimal(numberSizeList),4, RoundingMode.HALF_UP)); } } } -- Gitblit v1.9.3