| | |
| | | package com.qianwen.smartman.modules.coproduction.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.google.common.collect.Lists; |
| | | import java.lang.invoke.SerializedLambda; |
| | | import java.time.LocalDate; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | |
| | | import java.util.Map; |
| | | import java.util.function.Function; |
| | | import java.util.stream.Collectors; |
| | | import com.qianwen.smartman.common.cache.RegionCache; |
| | | import com.qianwen.smartman.common.constant.CommonConstant; |
| | | import com.qianwen.smartman.common.constant.ExcelConstant; |
| | | import com.qianwen.smartman.common.utils.Lambda; |
| | | import com.qianwen.smartman.common.utils.MessageUtils; |
| | | import com.qianwen.smartman.common.utils.TimeUtils; |
| | | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.google.common.collect.Lists; |
| | | import com.qianwen.core.excel.util.ExcelUtil; |
| | | import com.qianwen.core.log.exception.ServiceException; |
| | | import com.qianwen.core.mp.base.BaseServiceImpl; |
| | |
| | | import com.qianwen.core.oss.model.BladeFile; |
| | | import com.qianwen.core.tool.utils.DateUtil; |
| | | import com.qianwen.core.tool.utils.Func; |
| | | import com.qianwen.smartman.common.constant.CommonConstant; |
| | | import com.qianwen.smartman.common.constant.ExcelConstant; |
| | | import com.qianwen.smartman.common.utils.Lambda; |
| | | import com.qianwen.smartman.common.utils.MessageUtils; |
| | | import com.qianwen.smartman.common.utils.TimeUtils; |
| | | import com.qianwen.smartman.modules.coproduction.convert.OrderReportRecordConvert; |
| | | import com.qianwen.smartman.modules.coproduction.convert.ReportConvert; |
| | | import com.qianwen.smartman.modules.coproduction.dto.JuxtapositionReportDTO; |
| | |
| | | import com.qianwen.smartman.modules.coproduction.vo.OrderReportRecordResVO; |
| | | import com.qianwen.smartman.modules.coproduction.vo.OrderReportRecordSearchVO; |
| | | import com.qianwen.smartman.modules.resource.builder.oss.OssBuilder; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | @Service |
| | | /* loaded from: blade-api.jar:BOOT-INF/classes/org/springblade/modules/coproduction/service/impl/OrderReportRecordServiceImpl.class */ |
| | |
| | | return orderReportRecord; |
| | | } |
| | | |
| | | @Override // org.springblade.modules.coproduction.service.IOrderReportRecordService |
| | | @Override |
| | | @Transactional(rollbackFor = {Exception.class}) |
| | | public Boolean updateRecord(OrderProcessReportWorkDTO workDTO, OrderReportRecord orderReportRecord, OrderProcess orderProcess) { |
| | | int qualifyNum = workDTO.getQualifyNum().intValue() + ((orderReportRecord.getQualifyNum() == null) ? 0 : orderReportRecord.getQualifyNum().intValue()); |
| | | int scrappedNum = workDTO.getScrappedNum().intValue() + ((orderReportRecord.getScrappedNum() == null) ? 0 : orderReportRecord.getScrappedNum().intValue()); |
| | | Integer whetherParallel = orderProcess.getWhetherParallel(); |
| | | //Integer whetherParallel = orderProcess.getWhetherParallel(); |
| | | if (Func.isEmpty(orderReportRecord.getMainSequenceId()) && qualifyNum == 0 && scrappedNum == 0) |
| | | throw new ServiceException(MessageUtils.message("production.report.fail.is.not.parallel.qualifyNum.and.scrappedNum.is.not.zero", new Object[0])); |
| | | return Boolean.valueOf(update(Wrappers.<OrderReportRecord>lambdaUpdate() |
| | |
| | | .set(OrderReportRecord::getRemark, workDTO.getRemark()))); |
| | | } |
| | | |
| | | @Override // org.springblade.modules.coproduction.service.IOrderReportRecordService |
| | | @Override |
| | | @Transactional(rollbackFor = {Exception.class}) |
| | | public OrderReportRecord buildReportRecord(OrderProcessReportWorkDTO reportWorkDTO, OrderReportRecord orderReportRecord) { |
| | | orderReportRecord.setQualifyNum(Integer.valueOf(reportWorkDTO.getQualifyNum().intValue() + orderReportRecord.getQualifyNum().intValue())).setScrappedNum(Integer.valueOf(reportWorkDTO.getScrappedNum().intValue() + orderReportRecord.getScrappedNum().intValue())).setWorkshopUserId(Long.valueOf(Func.toLong(reportWorkDTO.getWorkshopUserId()))).setWorkshopUserName(reportWorkDTO.getWorkshopUserName()).setWorkshopUserCode(reportWorkDTO.getWorkshopUserCode()).setQualityUserId(Long.valueOf(Func.toLong(reportWorkDTO.getQualityUserId()))).setQualityUserName(reportWorkDTO.getQualityUserName()).setQualityUserCode(reportWorkDTO.getQualityUserCode()).setRemark(reportWorkDTO.getRemark()).setRecordStatus(CoProductionEnum.RecordStatus.YES.getCode()).setQualityTime(DateUtil.now()).setWorkshopTime(DateUtil.now()); |
| | | return orderReportRecord; |
| | | } |
| | | |
| | | @Override // org.springblade.modules.coproduction.service.IOrderReportRecordService |
| | | @Override |
| | | public OrderReportRecord getLatestRecord(Long planId, Long orderId, Long orderProcessId) { |
| | | List<OrderReportRecord> list = list(Wrappers.<OrderReportRecord>lambdaQuery() |
| | | .eq(Func.isNotEmpty(planId), OrderReportRecord::getPlanId, planId) |
| | |
| | | return orderProcessReportWorkDTO; |
| | | } |
| | | |
| | | @Override // org.springblade.modules.coproduction.service.IOrderReportRecordService |
| | | @Override |
| | | public IPage<OrderReportRecordResVO> pageQuery(OrderReportRecordSearchVO vo) { |
| | | Query query = vo.getQuery(); |
| | | Long productId = vo.getProductId(); |
| | |
| | | String startTime = Func.notNull(startDate) ? TimeUtils.getStartTime(startDate) : ""; |
| | | LocalDate endDate = vo.getEndDate(); |
| | | String endTime = Func.notNull(endDate) ? TimeUtils.getEndTime(endDate) : ""; |
| | | IPage<OrderReportRecordResVO> page = ((OrderReportRecordMapper) this.baseMapper).pageQuery(Condition.getPage(query), getWrapper(orderId, productId, reportEmployeeIds, workEmployeeIds, startTime, endTime)); |
| | | IPage<OrderReportRecordResVO> page = this.baseMapper.pageQuery(Condition.getPage(query), getWrapper(orderId, productId, reportEmployeeIds, workEmployeeIds, startTime, endTime)); |
| | | List<OrderReportRecordResVO> records = page.getRecords(); |
| | | if (Func.isEmpty(records)) { |
| | | return new Page(); |
| | | return new Page<>(); |
| | | } |
| | | List<Long> recordIds = (List) records.stream().map((v0) -> { |
| | | List<Long> recordIds = records.stream().map((v0) -> { |
| | | return v0.getId(); |
| | | }).collect(Collectors.toList()); |
| | | List<OrderReportRecord> recordList = list(Lambda.in((v0) -> { |
| | | return v0.getOpenSequenceId(); |
| | | }, recordIds)); |
| | | if (Func.isEmpty(recordList)) { |
| | | page.setRecords((List) records.stream().peek(r -> { |
| | | page.setRecords(records.stream().peek(r -> { |
| | | if (Func.notNull(r.getStartTime()) && Func.notNull(r.getEndTime())) { |
| | | r.setReportTime(Long.valueOf(DateUtil.between(r.getStartTime(), r.getEndTime()).getSeconds())); |
| | | } |
| | | }).collect(Collectors.toList())); |
| | | return page; |
| | | } |
| | | Map<Long, List<OrderReportRecord>> recordMap = (Map) recordList.stream().collect(Collectors.groupingBy((v0) -> { |
| | | Map<Long, List<OrderReportRecord>> recordMap = recordList.stream().collect(Collectors.groupingBy((v0) -> { |
| | | return v0.getOpenSequenceId(); |
| | | })); |
| | | List<OrderReportRecordResVO> vos = completeData(records, recordMap); |
| | |
| | | if (Func.isEmpty(records)) { |
| | | return exportRecord(Lists.newArrayList()); |
| | | } |
| | | List<Long> recordIds = (List) records.stream().map((v0) -> { |
| | | List<Long> recordIds = records.stream().map((v0) -> { |
| | | return v0.getId(); |
| | | }).collect(Collectors.toList()); |
| | | List<OrderReportRecord> recordList = list(Lambda.in((v0) -> { |
| | |
| | | return exportHasChildRecord(records, recordList); |
| | | } |
| | | |
| | | @Override // org.springblade.modules.coproduction.service.IOrderReportRecordService |
| | | @Override |
| | | public List<OrderChildRecordVO> queryChildRecord(String mainRecordId) { |
| | | List<OrderReportRecord> records = list(Lambda.eq((v0) -> { |
| | | return v0.getOpenSequenceId(); |
| | | }, mainRecordId)); |
| | | List<Long> opIds = (List) records.stream().map((v0) -> { |
| | | List<OrderReportRecord> records = list(Lambda.eq(OrderReportRecord::getOpenSequenceId, mainRecordId)); |
| | | List<Long> opIds = records.stream().map((v0) -> { |
| | | return v0.getProcessId(); |
| | | }).collect(Collectors.toList()); |
| | | List<OrderProcess> orderProcessList = this.orderProcessService.listByIds(opIds); |
| | | Map<Long, OrderProcess> map = (Map) orderProcessList.stream().collect(Collectors.toMap((v0) -> { |
| | | Map<Long, OrderProcess> map = orderProcessList.stream().collect(Collectors.toMap((v0) -> { |
| | | return v0.getId(); |
| | | }, v -> { |
| | | return v; |
| | | })); |
| | | return (List) records.stream().map(c -> { |
| | | return records.stream().map(c -> { |
| | | return convertVO(c, map); |
| | | }).collect(Collectors.toList()); |
| | | } |
| | |
| | | } |
| | | |
| | | private BladeFile exportNoChildRecord(List<OrderReportRecordResVO> records) { |
| | | List<OrderReportRecordExport> result = (List) records.stream().map(OrderReportRecordServiceImpl::getExport).collect(Collectors.toList()); |
| | | List<OrderReportRecordExport> result = records.stream().map(OrderReportRecordServiceImpl::getExport).collect(Collectors.toList()); |
| | | return exportRecord(result); |
| | | } |
| | | |
| | | private BladeFile exportHasChildRecord(List<OrderReportRecordResVO> records, List<OrderReportRecord> recordList) { |
| | | Map<Long, List<OrderReportRecord>> recordMap = (Map) recordList.stream().collect(Collectors.groupingBy((v0) -> { |
| | | Map<Long, List<OrderReportRecord>> recordMap = recordList.stream().collect(Collectors.groupingBy((v0) -> { |
| | | return v0.getOpenSequenceId(); |
| | | })); |
| | | List<OrderReportRecordExport> result = Lists.newArrayList(); |
| | | List<OrderProcess> orderProcessList = this.orderProcessService.list(); |
| | | Map<Long, OrderProcess> orderProcessMap = (Map) orderProcessList.stream().collect(Collectors.toMap((v0) -> { |
| | | Map<Long, OrderProcess> orderProcessMap = orderProcessList.stream().collect(Collectors.toMap((v0) -> { |
| | | return v0.getId(); |
| | | }, v -> { |
| | | return v; |
| | | })); |
| | | records.forEach(rd -> { |
| | | OrderReportRecordExport convert = getExport(rd); |
| | | List<OrderReportRecord> childRecords = (List) recordMap.get(rd.getId()); |
| | | List<OrderReportRecord> childRecords = recordMap.get(rd.getId()); |
| | | if (Func.isNotEmpty(childRecords)) { |
| | | String workstationNames = (String) childRecords.stream().map((v0) -> { |
| | | return v0.getWorkstationName(); |
| | |
| | | QueryWrapper<T> wrapper = Wrappers.<T>query().eq(Func.notNull(productId), "bp.product_id", productId).eq(Func.notNull(orderId), "borr.order_id", orderId).in(Func.isNotEmpty(reportEmployeeIds), "borr.workshop_user_id", reportEmployeeIds).in(Func.isNotEmpty(workEmployeeIds), "borr.producer_user_id", workEmployeeIds); |
| | | if (Func.isNotBlank(startTime) && Func.isNotBlank(endTime)) { |
| | | wrapper.nested(nt -> { |
| | | QueryWrapper queryWrapper = (QueryWrapper) ((QueryWrapper) ((QueryWrapper) nt.between("borr.start_time", startTime, endTime)).or()).between("borr.workshop_time", startTime, endTime); |
| | | nt.between("borr.start_time", startTime, endTime).or().between("borr.workshop_time", startTime, endTime); |
| | | }); |
| | | } else if (Func.isNotBlank(startTime)) { |
| | | wrapper.nested(nt2 -> { |
| | | QueryWrapper queryWrapper = (QueryWrapper) ((QueryWrapper) ((QueryWrapper) nt2.gt("borr.start_time", startTime)).or()).gt("borr.start_time", startTime); |
| | | nt2.gt("borr.start_time", startTime).or().gt("borr.start_time", startTime); |
| | | }); |
| | | } else if (Func.isNotBlank(endTime)) { |
| | | wrapper.nested(nt3 -> { |
| | | QueryWrapper queryWrapper = (QueryWrapper) ((QueryWrapper) ((QueryWrapper) nt3.le("borr.workshop_time", endTime)).or()).le("borr.workshop_time", endTime); |
| | | nt3.le("borr.workshop_time", endTime).or().le("borr.workshop_time", endTime); |
| | | }); |
| | | } |
| | | if (Func.isNotBlank(wrapper.getSqlSegment())) { |
| | |
| | | } |
| | | |
| | | private List<OrderReportRecordResVO> completeData(List<OrderReportRecordResVO> records, Map<Long, List<OrderReportRecord>> recordMap) { |
| | | return (List) records.stream().peek(r -> { |
| | | return records.stream().peek(r -> { |
| | | if (Func.notNull(r.getStartTime()) && Func.notNull(r.getEndTime())) { |
| | | r.setReportTime(Long.valueOf(DateUtil.between(r.getStartTime(), r.getEndTime()).getSeconds())); |
| | | } |
| | | List<OrderReportRecord> childRecords = (List) recordMap.get(r.getId()); |
| | | List<OrderReportRecord> childRecords = recordMap.get(r.getId()); |
| | | if (Func.isNotEmpty(childRecords)) { |
| | | String workstationIds = (String) childRecords.stream().map(c -> { |
| | | Long workstationId = c.getWorkstationId(); |
| | |
| | | }).collect(Collectors.joining(",")); |
| | | Long workstationId = r.getWorkstationId(); |
| | | r.setWorkstationIds(workstationId == null ? workstationIds : String.join(",", String.valueOf(workstationId), workstationIds)); |
| | | String workstationNames = (String) childRecords.stream().map((v0) -> { |
| | | String workstationNames = childRecords.stream().map((v0) -> { |
| | | return v0.getWorkstationName(); |
| | | }).filter((v0) -> { |
| | | return Func.notNull(v0); |
| | |
| | | if (Func.isEmpty(reportWorkDTOList)) { |
| | | throw new ServiceException(MessageUtils.message("production.report.fail.data.empty", new Object[0])); |
| | | } |
| | | List<String> recordIds = (List) reportWorkDTOList.stream().map((v0) -> { |
| | | List<String> recordIds = reportWorkDTOList.stream().map((v0) -> { |
| | | return v0.getRecordId(); |
| | | }).collect(Collectors.toList()); |
| | | Map<Long, OrderReportRecord> recordMap = getRecordMap(recordIds); |
| | |
| | | throw new ServiceException(MessageUtils.message("production.report.fail.data.empty", new Object[0])); |
| | | } |
| | | this.orderProcessService.parallelProcessAround(ReportConvert.INSTANCE.convertParallel(reportWorkDTOList), Boolean.TRUE); |
| | | List<String> recordIds = (List) reportWorkDTOList.stream().map((v0) -> { |
| | | List<String> recordIds = reportWorkDTOList.stream().map((v0) -> { |
| | | return v0.getRecordId(); |
| | | }).distinct().collect(Collectors.toList()); |
| | | Map<Long, OrderReportRecord> recordMap = getRecordMap(recordIds); |