| | |
| | | package com.ruoyi.production.service.impl; |
| | | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | |
| | | List<String> deviceNames = productProcessList.stream().map(ProductProcess::getDeviceName).collect(Collectors.toList()); |
| | | List<DeviceLedger> deviceLedgerList = deviceLedgerMapper.selectList(Wrappers.<DeviceLedger>lambdaQuery().in(DeviceLedger::getDeviceName, deviceNames)); |
| | | if(CollectionUtils.isEmpty(deviceLedgerList)){ |
| | | throw new RuntimeException("工序机台不能为空"); |
| | | throw new RuntimeException("未能查询到该机台信息,请检查机台名称是否正确"); |
| | | } |
| | | Map<String, DeviceLedger> deviceNameMap = deviceLedgerList.stream().collect(Collectors.toMap(DeviceLedger::getDeviceName, deviceLedger -> deviceLedger)); |
| | | productProcessList.forEach(productProcess -> { |
| | | DeviceLedger deviceLedger = deviceNameMap.get(productProcess.getDeviceName()); |
| | | productProcess.setDeviceLeaderId(deviceLedger.getId()); |
| | | this.save(productProcess); |
| | | if(StrUtil.isEmpty(productProcess.getNo())){ |
| | | String no = "GX" + String.format("%08d", productProcess.getId()); |
| | | productProcess.setNo(no); |
| | | productProcessMapper.updateById(productProcess); |
| | | } |
| | | |
| | | }); |
| | | |
| | | return AjaxResult.success(true); |