| | |
| | | |
| | | import com.alibaba.excel.EasyExcel; |
| | | import com.alibaba.excel.ExcelWriter; |
| | | import com.alibaba.excel.support.ExcelTypeEnum; |
| | | import com.alibaba.excel.write.metadata.WriteSheet; |
| | | import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.core.domain.entity.User; |
| | | import com.ruoyi.common.enums.ContractType; |
| | | import com.ruoyi.common.enums.StaffSkillLevelType; |
| | | import com.ruoyi.common.exception.base.BaseException; |
| | | import com.ruoyi.common.utils.api.mes.MesApiUtils; |
| | | import com.ruoyi.common.utils.api.mes.model.WorkingHoursRecordSumVO; |
| | | import com.ruoyi.common.utils.api.mes.model.WorkingHoursRecordTotalVO; |
| | | import com.ruoyi.common.utils.excel.EasyExcelUtils; |
| | | import com.ruoyi.common.utils.excel.FullCustomAutoWidthHandler; |
| | | import com.ruoyi.common.utils.excel.HeaderContentRowHeightHandler; |
| | | import com.ruoyi.performance.dto.AuxiliaryAllDto; |
| | | import com.ruoyi.performance.dto.AuxiliaryCorrectionHoursDto; |
| | | import com.ruoyi.performance.dto.AuxiliaryOriginalHoursDto; |
| | | import com.ruoyi.performance.dto.AuxiliaryOriginalHoursLookDto; |
| | | import com.ruoyi.performance.mapper.AuxiliaryCorrectionHoursMapper; |
| | |
| | | import com.ruoyi.performance.pojo.AuxiliaryCorrectionHours; |
| | | import com.ruoyi.performance.service.AuxiliaryOriginalHoursService; |
| | | import com.ruoyi.system.mapper.UserMapper; |
| | | import org.apache.commons.math3.analysis.function.Power; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.poi.ss.usermodel.IndexedColors; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.net.URLEncoder; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.time.LocalDate; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.*; |
| | | import java.util.concurrent.atomic.AtomicInteger; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Slf4j |
| | | @Service |
| | | public class AuxiliaryOriginalHoursServiceImpl implements AuxiliaryOriginalHoursService { |
| | | |
| | |
| | | |
| | | @Resource |
| | | AuxiliaryCorrectionHoursMapper auxiliaryCorrectionHoursMapper; |
| | | |
| | | @Autowired |
| | | private MesApiUtils mesApiUtils; |
| | | |
| | | @Override |
| | | public IPage<AuxiliaryOriginalHoursDto> selectAuxiliaryOriginalHours(Page page, AuxiliaryOriginalHoursLookDto auxiliaryOriginalHoursLookDto) { |
| | |
| | | dto.setAssistBeginDate(beginDate); |
| | | dto.setAssistEndDate(endDate); |
| | | |
| | | |
| | | //查询KJNS和ZTNS域的MES绩效数据 |
| | | Map<String, Object> params = new HashMap<>(); |
| | | params.put("year",date.getYear()); |
| | | params.put("month",date.getMonthValue()); |
| | | List<WorkingHoursRecordTotalVO> hoursRecordSumByNS = new ArrayList<>(); |
| | | List<WorkingHoursRecordTotalVO> hoursRecordSumByKJ = new ArrayList<>(); |
| | | try { |
| | | hoursRecordSumByNS = mesApiUtils.getCheckWorkingHoursRecordSum(ContractType.ZTNS.getValue(), params); |
| | | hoursRecordSumByKJ = mesApiUtils.getCheckWorkingHoursRecordSum(ContractType.KJNS.getValue(), params); |
| | | }catch (Exception e){ |
| | | log.error("工时汇总查询异常:{}",e.getMessage()); |
| | | } |
| | | // 查询产量工时 |
| | | List<AuxiliaryAllDto> auxiliaryAllDtos = auxiliaryOutputWorkingHoursMapper.selectAuxiliaryAllByMonth(dto, userIds); |
| | | |
| | |
| | | BigDecimal total = (auxiliaryAllDto.getYieldHour() != null ? auxiliaryAllDto.getYieldHour() : BigDecimal.ZERO) |
| | | .add(auxiliaryAllDto.getSubsidiaryHour() != null ? auxiliaryAllDto.getSubsidiaryHour() : BigDecimal.ZERO); |
| | | auxiliaryAllDto.setTotalHour(total); |
| | | if(!hoursRecordSumByNS.isEmpty()){ |
| | | WorkingHoursRecordTotalVO totalVOByNS = hoursRecordSumByNS.stream().filter(f -> StringUtils.equals(f.getChecker(), auxiliaryAllDto.getUserName())).findFirst().orElse(null); |
| | | if(ObjectUtils.isNotNull(totalVOByNS)){ |
| | | auxiliaryAllDto.setHandymanWageByNS(totalVOByNS.getHandymanWage()); |
| | | auxiliaryAllDto.setOnsiteInspWageByNS(totalVOByNS.getOnsiteInspWage()); |
| | | auxiliaryAllDto.setOperationPerformanceByNS(totalVOByNS.getOperationPerformance()); |
| | | auxiliaryAllDto.setProductPerformanceByNS(totalVOByNS.getProductPerformance()); |
| | | } |
| | | } |
| | | if(!hoursRecordSumByKJ.isEmpty()){ |
| | | WorkingHoursRecordTotalVO totalVOByKJ = hoursRecordSumByKJ.stream().filter(f -> StringUtils.equals(f.getChecker(), auxiliaryAllDto.getUserName())).findFirst().orElse(null); |
| | | if(ObjectUtils.isNotNull(totalVOByKJ)){ |
| | | auxiliaryAllDto.setHandymanWageByKJ(totalVOByKJ.getHandymanWage()); |
| | | auxiliaryAllDto.setOnsiteInspWageByKJ(totalVOByKJ.getOnsiteInspWage()); |
| | | auxiliaryAllDto.setOperationPerformanceByKJ(totalVOByKJ.getOperationPerformance()); |
| | | auxiliaryAllDto.setProductPerformanceByKJ(totalVOByKJ.getProductPerformance()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | return auxiliaryAllDtos; |
| | | } |
| | | |
| | | @Override |
| | | public void exportWorkHoursTotal(HttpServletResponse response, AuxiliaryOriginalHoursLookDto dto) { |
| | | response.reset(); |
| | | try { |
| | | //1.组装数据 |
| | | AtomicInteger excelIndex = new AtomicInteger(1); |
| | | List<AuxiliaryAllDto> auxiliaryAllDtos = selectAuxiliaryAllByMonth(dto); |
| | | auxiliaryAllDtos.forEach(a->{ |
| | | a.setExcelIndex(excelIndex.getAndIncrement()); |
| | | a.setOperationPerformance(a.getOperationPerformanceByKJ().add(a.getOperationPerformanceByNS()));//工序绩效汇总 |
| | | a.setOnsiteInspWage(a.getOnsiteInspWageByKJ().add(a.getOnsiteInspWageByNS()));//巡检绩效汇总 |
| | | a.setProductPerformance(a.getProductPerformanceByKJ().add(a.getProductPerformanceByNS()));//成品绩效汇总 |
| | | a.setHandymanWage(a.getHandymanWageByKJ().add(a.getHandymanWageByNS()));//杂工工资 |
| | | }); |
| | | //2.导出 |
| | | String fileName = "中天耐丝质量部工时汇总"+ ExcelTypeEnum.XLSX; |
| | | fileName = URLEncoder.encode(fileName, StandardCharsets.UTF_8.toString()); |
| | | response.setContentType("application/vnd.ms-excel"); |
| | | response.setHeader("Cache-Control", "no-cache"); |
| | | response.setHeader("Content-Disposition", "attachment;filename=" + fileName); |
| | | response.setHeader("Access-Control-Expose-Headers", "Content-Disposition"); |
| | | EasyExcel.write(response.getOutputStream()) |
| | | .head(AuxiliaryAllDto.class) |
| | | .registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()) |
| | | .sheet("Sheet 1") |
| | | .doWrite(auxiliaryAllDtos); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | |
| | | private Map<String, AuxiliaryOriginalHoursDto> getData(List<Map<String, Object>> objectMaps, String type) { |
| | | Map<String, AuxiliaryOriginalHoursDto> dtoMap = new HashMap<>(); |
| | | for (Map<String, Object> objectMap : objectMaps) { |