package org.jeecg.modules.mdc.service.impl; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.jeecg.modules.mdc.entity.MdcEquipmentDaySchedule; import org.jeecg.modules.mdc.mapper.MdcEquipmentDayScheduleMapper; import org.jeecg.modules.mdc.service.IMdcEquipmentDayScheduleService; import org.jeecg.modules.mdc.vo.MdcEquipmentDayScheduleVo; import org.jeecg.modules.system.entity.MdcProduction; import org.jeecg.modules.system.service.IMdcProductionService; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.math.BigDecimal; import java.math.RoundingMode; /** * @Author: Lius * @CreateTime: 2025-02-26 * @Description: s */ @Service public class MdcEquipmentDayScheduleServiceImpl extends ServiceImpl implements IMdcEquipmentDayScheduleService { @Resource private IMdcProductionService mdcProductionService; @Override public IPage pageList(MdcEquipmentDayScheduleVo mdcEquipmentDayScheduleVo, Page page) { IPage mdcEquipmentDayScheduleIPage = this.baseMapper.pageList(mdcEquipmentDayScheduleVo, page); if (mdcEquipmentDayScheduleIPage.getRecords() != null && !mdcEquipmentDayScheduleIPage.getRecords().isEmpty()) { MdcProduction mdcProduction = mdcProductionService.getById(mdcEquipmentDayScheduleVo.getProductionId()); mdcEquipmentDayScheduleIPage.getRecords().forEach(mdcEquipmentDaySchedule -> { mdcEquipmentDaySchedule.setWorkshop(mdcProduction.getProductionName()); BigDecimal batchNum = new BigDecimal(mdcEquipmentDaySchedule.getBatchNum()); BigDecimal qualifiedQty = new BigDecimal(mdcEquipmentDaySchedule.getQualifiedQty()); if (batchNum.compareTo(BigDecimal.ZERO) != 0) { mdcEquipmentDaySchedule.setQualifiedRate(qualifiedQty.multiply(new BigDecimal("100")).divide(batchNum, 2, RoundingMode.HALF_UP)); } if (batchNum.compareTo(qualifiedQty) > 0) { mdcEquipmentDaySchedule.setQualifiedStatus("未完成"); } else { mdcEquipmentDaySchedule.setQualifiedStatus("已完成"); } }); } return mdcEquipmentDayScheduleIPage; } @Override public MdcEquipmentDaySchedule selectLast(String equipmentId) { return this.baseMapper.selectLast(equipmentId); } }