| | |
| | | import com.ruoyi.production.dto.ProductWorkOrderDto; |
| | | import com.ruoyi.production.mapper.ProductWorkOrderFileMapper; |
| | | import com.ruoyi.production.mapper.ProductWorkOrderMapper; |
| | | import com.ruoyi.production.mapper.ProductionMachineRecordMapper; |
| | | import com.ruoyi.production.pojo.ProductWorkOrder; |
| | | import com.ruoyi.production.pojo.ProductWorkOrderFile; |
| | | import com.ruoyi.production.pojo.ProductionMachineRecord; |
| | | import com.ruoyi.production.service.ProductWorkOrderService; |
| | | import com.ruoyi.project.system.domain.SysUser; |
| | | import com.ruoyi.project.system.mapper.SysUserMapper; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.LinkedHashSet; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | |
| | | @Service |
| | | @Transactional(rollbackFor = Exception.class) |
| | |
| | | private ProductWorkOrderMapper productWorkOrderMapper; |
| | | @Autowired |
| | | private ProductWorkOrderFileMapper productWorkOrderFileMapper; |
| | | @Autowired |
| | | private ProductionMachineRecordMapper productionMachineRecordMapper; |
| | | @Autowired |
| | | private SysUserMapper sysUserMapper; |
| | | |
| | | @Value("${file.temp-dir}") |
| | | private String tempDir; |
| | |
| | | |
| | | @Override |
| | | public ProductWorkOrderDto getProductWorkOrderById(Long id) { |
| | | return productWorkOrderMapper.getProductWorkOrderFlowCard(id); |
| | | ProductWorkOrderDto productWorkOrderDto = productWorkOrderMapper.getProductWorkOrderFlowCard(id); |
| | | // 合并工单排产人员与机台上机操作员,去重后作为报工弹窗默认班组成员 |
| | | Set<Long> userIdSet = new LinkedHashSet<>(); |
| | | if (productWorkOrderDto != null && StrUtil.isNotBlank(productWorkOrderDto.getUserIds())) { |
| | | for (String uid : productWorkOrderDto.getUserIds().split(",")) { |
| | | if (StrUtil.isNotBlank(uid)) { |
| | | userIdSet.add(Long.parseLong(uid.trim())); |
| | | } |
| | | } |
| | | } |
| | | List<ProductionMachineRecord> machineRecords = productionMachineRecordMapper.selectList( |
| | | Wrappers.<ProductionMachineRecord>lambdaQuery() |
| | | .eq(ProductionMachineRecord::getWorkOrderId, id) |
| | | .isNotNull(ProductionMachineRecord::getOperatorId)); |
| | | for (ProductionMachineRecord machineRecord : machineRecords) { |
| | | if (StrUtil.isNotBlank(machineRecord.getOperatorId())) { |
| | | for (String uid : machineRecord.getOperatorId().split(",")) { |
| | | if (StrUtil.isNotBlank(uid)) { |
| | | userIdSet.add(Long.parseLong(uid.trim())); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | List<ProductWorkOrderDto.ReportPerson> reportPersons = new ArrayList<>(); |
| | | for (Long userId : userIdSet) { |
| | | ProductWorkOrderDto.ReportPerson reportPerson = new ProductWorkOrderDto.ReportPerson(); |
| | | reportPerson.setUserId(userId); |
| | | SysUser sysUser = sysUserMapper.selectUserById(userId); |
| | | if (sysUser != null) { |
| | | reportPerson.setUserName(sysUser.getNickName()); |
| | | } |
| | | reportPersons.add(reportPerson); |
| | | } |
| | | if (productWorkOrderDto != null) { |
| | | productWorkOrderDto.setReportPersons(reportPersons); |
| | | } |
| | | return productWorkOrderDto; |
| | | } |
| | | |
| | | @Override |