lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/MdcEquipmentMagnificationController.java
@@ -10,15 +10,16 @@ import org.jeecg.common.system.base.controller.JeecgController; import org.jeecg.common.system.vo.LoginUser; import org.jeecg.modules.mdc.entity.MdcEquipmentMagnification; import org.jeecg.modules.mdc.entity.MdcProcessQuantity; import org.jeecg.modules.mdc.service.IMdcEquipmentMagnificationService; import org.jeecg.modules.mdc.vo.MdcEquipmentMagnificationVo; import org.jeecg.modules.mdc.vo.MdcProcessQuantityVo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; 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; @Slf4j @Api(tags = "åçç»è®¡") @@ -48,4 +49,19 @@ IPage<MdcEquipmentMagnification> pageList = service.pageList(userId,magnificationVo,pageNo, pageSize, req); return Result.OK(pageList); } /** * 导åºexcel * * @param request * @param magnificationVo */ @RequestMapping(value = "/exportXls") public ModelAndView exportXls(HttpServletRequest request, MdcEquipmentMagnificationVo magnificationVo) { LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); String userId = user.getId(); return service.exportXls(userId, magnificationVo); } } lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/dto/MdcEquipmentMagnificationDto.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,27 @@ package org.jeecg.modules.mdc.dto; import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import org.jeecgframework.poi.excel.annotation.Excel; import java.math.BigDecimal; @Data public class MdcEquipmentMagnificationDto { @Excel(name = "设å¤ç¼å·", width = 15) private String equipmentId; // 主轴åçå¹³åå¼ @Excel(name = "主轴åçå¹³åå¼", width = 15) private BigDecimal spindlebeilv = new BigDecimal(0); //è¿ç»åçå¹³åå¼ @Excel(name = "è¿ç»åçå¹³åå¼", width = 15) private BigDecimal feedbeilv = new BigDecimal(0); //æææ¥æ @ApiModelProperty(value = "æ¥æ") @Excel(name = "æ¥æ", width = 15, format = "yyyy-MM-dd") @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd") private String theDate; } lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentMagnificationMapper.java
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Select; import org.jeecg.modules.mdc.dto.MdcEquipmentMagnificationDto; import org.jeecg.modules.mdc.entity.MdcEquipmentMagnification; import org.jeecg.modules.mdc.vo.MdcEquipmentMagnificationVo; @@ -24,4 +25,7 @@ IPage<MdcEquipmentMagnification> pageList(IPage<MdcEquipmentMagnification> pageData, @Param("magnificationVo") MdcEquipmentMagnificationVo magnificationVo); List<MdcEquipmentMagnificationDto> list(@Param("magnificationVo") MdcEquipmentMagnificationVo magnificationVo); } lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentMagnificationMapper.xml
@@ -30,4 +30,29 @@ ORDER BY t1.the_date ASC </select> <!--å页å表æ¥è¯¢--> <select id="list" resultType="org.jeecg.modules.mdc.dto.MdcEquipmentMagnificationDto"> SELECT * FROM mdc_equipment_magnification t1 WHERE 1=1 <if test="magnificationVo.equipmentId != null and magnificationVo.equipmentId != ''"> AND t1.equipment_id = #{ magnificationVo.equipmentId } </if> <if test="magnificationVo.startTime != null and magnificationVo.startTime != ''"> AND t1.the_date >= #{ magnificationVo.startTime } </if> <if test="magnificationVo.endTime != null and magnificationVo.endTime != ''"> AND t1.the_date <= #{ magnificationVo.endTime } </if> <if test="magnificationVo.equipmentIdList != null and magnificationVo.equipmentIdList.size() > 0 "> AND t1.equipment_id IN <foreach collection="magnificationVo.equipmentIdList" item="id" index="index" open="(" close=")" separator=","> #{ id } </foreach> </if> ORDER BY t1.the_date ASC </select> </mapper> lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentMagnificationService.java
@@ -3,9 +3,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; import org.jeecg.modules.mdc.entity.MdcEquipmentMagnification; import org.jeecg.modules.mdc.vo.MdcDeviceCalendarQueryVo; import org.jeecg.modules.mdc.vo.MdcDeviceCalendarVo; import org.jeecg.modules.mdc.vo.MdcEquipmentMagnificationVo; import org.springframework.web.servlet.ModelAndView; import javax.servlet.http.HttpServletRequest; @@ -17,4 +16,14 @@ IPage<MdcEquipmentMagnification> pageList(String userId, MdcEquipmentMagnificationVo magnificationVo, Integer pageNo, Integer pageSize, HttpServletRequest req); /** * å¯¼åº * * @param userId * @param magnificationVo * @return */ ModelAndView exportXls(String userId, MdcEquipmentMagnificationVo magnificationVo); } lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentMagnificationServiceImpl.java
@@ -4,13 +4,20 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.apache.commons.lang3.StringUtils; 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.*; 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; @@ -130,6 +137,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, MdcDownTime.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);