| | |
| | | package com.ruoyi.production.service.impl; |
| | | |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.util.IdUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.basic.service.CustomerFollowUpFileService; |
| | | import com.ruoyi.dto.SimplePersonDto; |
| | | import com.ruoyi.production.dto.ProcessContentDto; |
| | | import com.ruoyi.production.dto.ProcessRouteAnticlockwiseDto; |
| | | import com.ruoyi.production.dto.SaveProductionPrintOrderDto; |
| | | import com.ruoyi.production.dto.*; |
| | | import com.ruoyi.production.mapper.ProductOrderMapper; |
| | | import com.ruoyi.production.mapper.ProductionPrintOrderMapper; |
| | | import com.ruoyi.production.pojo.ProductOrder; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | |
| | | private final ProductOrderMapper productOrderMapper; |
| | | private final ProcessRouteServiceImpl processRouteService; |
| | | |
| | | private final CustomerFollowUpFileService customerFollowUpFileService; |
| | | @Override |
| | | @Transactional |
| | | public void save(SaveProductionPrintOrderDto dto) { |
| | |
| | | processContentDto.setId(IdUtil.simpleUUID()); |
| | | } |
| | | }); |
| | | MaterialInfoDto materialInfoDtoFirst = dto.getMaterialInfo().get(0); |
| | | // 调用工序方增 函数 |
| | | List<ProcessRouteAnticlockwiseDto> processRouteAnticlockwiseDtos = processContentDtoList.stream().map(it -> { |
| | | ProcessRouteAnticlockwiseDto pdto = new ProcessRouteAnticlockwiseDto(); |
| | | pdto.setProcessId(it.getProcessId()); |
| | | pdto.setProcessRouteName(it.getProcessContent()); |
| | | pdto.setProcessRouteName(it.getProcessName()); |
| | | pdto.setProcessRouteOpenNum(it.getOpenCount()); |
| | | pdto.setProcessRouteNum(it.getProcessPositive()); |
| | | pdto.setProcessRouteAddNum(it.getProcessPositive()); |
| | | // pdto.setProcessRouteRequire(); 工艺要求 |
| | | pdto.setProductModelId(dto.getProductModelId()); |
| | | pdto.setUserIds(it.getReportWorkerList().stream().map(SimplePersonDto::getUserName).collect(Collectors.joining(","))); |
| | | pdto.setProductModelId(Long.valueOf(materialInfoDtoFirst.getProductModelId())); |
| | | pdto.setUserIds(it.getReportWorkerList().stream().map(SimplePersonDto::getUserId).map(String::valueOf).collect(Collectors.joining(","))); |
| | | pdto.setUserNames(it.getReportWorkerList().stream().map(SimplePersonDto::getUserName).collect(Collectors.joining(","))); |
| | | pdto.setDeviceId(it.getDeviceId()); |
| | | pdto.setUuid(it.getId()); |
| | | return pdto; |
| | | }).collect(Collectors.toList()); |
| | | |
| | | processRouteService.processRouteAnticlockwise(processRouteAnticlockwiseDtos,dto.getProductModelId(),dto.getProductOrderId()); |
| | | // 生成备注 备注由全部工序名称来 组成 |
| | | String remark = processContentDtoList.stream().map(ProcessContentDto::getProcessContent).collect(Collectors.joining("、")); |
| | | String remark = processContentDtoList.stream().map(ProcessContentDto::getProcessName).collect(Collectors.joining("、")); |
| | | ProductOrder productOrder = new ProductOrder(); |
| | | productOrder.setId(dto.getProductOrderId()); |
| | | productOrder.setRemark(remark); |
| | | productOrderMapper.updateById(productOrder); |
| | | int i = dto.getId() == null ? productionPrintOrderMapper.insert(productionPrintOrder) : productionPrintOrderMapper.updateById(productionPrintOrder); |
| | | } |
| | | |
| | | @Override |
| | | public ProductionPrintOrderDto getByProductWordId(Long id) { |
| | | LambdaQueryWrapper<ProductionPrintOrder> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(ProductionPrintOrder::getProductOrderId, id); |
| | | queryWrapper.orderByDesc(ProductionPrintOrder::getCreateTime); |
| | | queryWrapper.last("limit 1"); |
| | | ProductionPrintOrder productionPrintOrder = productionPrintOrderMapper.selectOne(queryWrapper); |
| | | ProductionPrintOrderDto productionPrintOrderDto = BeanUtil.copyProperties(productionPrintOrder, ProductionPrintOrderDto.class); |
| | | |
| | | // 获取附件信息 |
| | | productionPrintOrderDto.setCuttingFileVo(customerFollowUpFileService.getSimpleFileVoById(productionPrintOrderDto.getCuttingFileId())); |
| | | |
| | | return productionPrintOrderDto; |
| | | } |
| | | |
| | | @Override |
| | | public List<ProductionPrintOrder> getListByOrders(List<Long> orderIds) { |
| | | if(CollUtil.isEmpty(orderIds)){ |
| | | return new ArrayList<>(); |
| | | } |
| | | LambdaQueryWrapper<ProductionPrintOrder> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.in(ProductionPrintOrder::getProductOrderId, orderIds); |
| | | List<ProductionPrintOrder> productionPrintOrders = productionPrintOrderMapper.selectList(queryWrapper); |
| | | // 去除重复的orderIds的记录只保留id最大的一个 |
| | | return productionPrintOrders.stream().collect(Collectors.collectingAndThen( |
| | | Collectors.toMap( |
| | | ProductionPrintOrder::getProductOrderId, |
| | | productionPrintOrder -> productionPrintOrder, |
| | | (existing, replacement) -> existing.getId() > replacement.getId() ? existing : replacement |
| | | ), |
| | | map -> new ArrayList<>(map.values()) |
| | | )); |
| | | } |
| | | } |
| | | |
| | | |