yb
昨天 88c6a0e35a1edc37872fb11725c229124b037c43
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentMagnificationServiceImpl.java
@@ -4,13 +4,22 @@
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;
@@ -49,10 +58,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 +139,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);