|
|
|
@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSON; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
|
import org.jeecg.common.exception.JeecgBootException; |
|
|
|
|
import org.jeecg.modules.demo.accessories.entity.ZyAccessories; |
|
|
|
@ -77,6 +78,7 @@ import java.util.stream.Collectors; |
|
|
|
|
* @Version: V1.0 |
|
|
|
|
*/ |
|
|
|
|
@Service |
|
|
|
|
@Slf4j |
|
|
|
|
public class ZyPlanProcessServiceImpl extends ServiceImpl<ZyPlanProcessMapper, ZyPlanProcess> implements IZyPlanProcessService { |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
@ -260,7 +262,7 @@ public class ZyPlanProcessServiceImpl extends ServiceImpl<ZyPlanProcessMapper, Z |
|
|
|
|
public void createMaterialBill(ZyPlanProcess zyPlanProcess) { |
|
|
|
|
ZyProductPlan zyProductPlan = iZyProductPlanService.getById(zyPlanProcess.getPlanId()); |
|
|
|
|
if (ObjectUtils.isEmpty(zyProductPlan)) { |
|
|
|
|
throw new JeecgBootException("生产计划不存在!"); |
|
|
|
|
throw new JeecgBootException(zyPlanProcess.getPlanId() + ":生产计划不存在!"); |
|
|
|
|
} |
|
|
|
|
List<ZyPlanProcess> planProcessList = this.list(new LambdaQueryWrapper<ZyPlanProcess>().eq(ZyPlanProcess::getPlanId, zyPlanProcess.getPlanId())); |
|
|
|
|
if (ObjectUtils.isEmpty(planProcessList)) return; |
|
|
|
@ -304,33 +306,36 @@ public class ZyPlanProcessServiceImpl extends ServiceImpl<ZyPlanProcessMapper, Z |
|
|
|
|
/** |
|
|
|
|
* @param zyPlanProcess 生产计划工序 |
|
|
|
|
* @param stationList 车间工位 |
|
|
|
|
* @param zyProcessMachineList 工序设备列表 |
|
|
|
|
* @param zyProcessMachineList 工序设备列表(一个工序对应多个工序设备) |
|
|
|
|
*/ |
|
|
|
|
void diffMachine(ZyPlanProcess zyPlanProcess, List<Station> stationList, List<ZyProcessMachine> zyProcessMachineList) { |
|
|
|
|
if (!ObjectUtils.isEmpty(zyProcessMachineList)) { |
|
|
|
|
if (!ObjectUtils.isEmpty(stationList) && !ObjectUtils.isEmpty(zyProcessMachineList)) { |
|
|
|
|
//工序设备类型列表
|
|
|
|
|
List<String> zyDevicetype_codes = zyProcessMachineList.stream().map(ZyProcessMachine::getCode).collect(Collectors.toList()); |
|
|
|
|
Optional.ofNullable(stationList).orElse(new ArrayList<>()).forEach(e -> { |
|
|
|
|
List<StationMachine> stationMachineList = iStationMachineService.list(new LambdaQueryWrapper<StationMachine>().eq(StationMachine::getStationId, e.getId())); |
|
|
|
|
//工位设备ids
|
|
|
|
|
List<String> stationMachineIds = Optional.ofNullable(stationMachineList).orElse(new ArrayList<>()).stream().map(StationMachine::getMachineId).collect(Collectors.toList()); |
|
|
|
|
List<ZyDevice> zyDeviceList = iZyDeviceService.list(new LambdaQueryWrapper<ZyDevice>().in(ZyDevice::getId, stationMachineIds)); |
|
|
|
|
List<String> zyDevice_typeCodes = Optional.ofNullable(zyDeviceList).orElse(new ArrayList<>()).stream().map(ZyDevice::getTypeCode).collect(Collectors.toList()); |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 工位设备包含工序设备即匹配成功 |
|
|
|
|
*/ |
|
|
|
|
if (zyDevice_typeCodes.containsAll(zyDevicetype_codes)) { |
|
|
|
|
String collect = zyProcessMachineList.stream().map(ZyProcessMachine::getMachineId).collect(Collectors.joining(",")); |
|
|
|
|
zyPlanProcess.setMachineIds(collect); |
|
|
|
|
zyPlanProcess.setMachineNames(iStationMachineService.convertByMachineIds(stationMachineIds)); |
|
|
|
|
zyPlanProcess.setStationId(e.getId()); |
|
|
|
|
zyPlanProcess.setStationName(e.getStationName()); |
|
|
|
|
zyPlanProcess.setStationNum(e.getStationNum()); |
|
|
|
|
this.updateById(zyPlanProcess); |
|
|
|
|
return; |
|
|
|
|
for (int j = 0; j < stationList.size(); j++) { |
|
|
|
|
Station station = stationList.get(j); |
|
|
|
|
List<StationMachine> stationMachineList = iStationMachineService.list(new LambdaQueryWrapper<StationMachine>().eq(StationMachine::getStationId, station.getId())); |
|
|
|
|
if (!ObjectUtils.isEmpty(stationMachineList)) { |
|
|
|
|
//工位设备ids
|
|
|
|
|
List<String> stationMachineIds = Optional.ofNullable(stationMachineList).orElse(new ArrayList<>()).stream().map(StationMachine::getMachineId).collect(Collectors.toList()); |
|
|
|
|
List<ZyDevice> zyDeviceList = iZyDeviceService.list(new LambdaQueryWrapper<ZyDevice>().in(ZyDevice::getId, stationMachineIds)); |
|
|
|
|
List<String> zyDevice_typeCodes = Optional.ofNullable(zyDeviceList).orElse(new ArrayList<>()).stream().map(ZyDevice::getTypeCode).collect(Collectors.toList()); |
|
|
|
|
/** |
|
|
|
|
* 工位设备包含工序设备即匹配成功 |
|
|
|
|
*/ |
|
|
|
|
if (zyDevice_typeCodes.containsAll(zyDevicetype_codes)) { |
|
|
|
|
String collect = zyProcessMachineList.stream().map(ZyProcessMachine::getMachineId).collect(Collectors.joining(",")); |
|
|
|
|
zyPlanProcess.setMachineIds(collect); |
|
|
|
|
zyPlanProcess.setMachineNames(iStationMachineService.convertByMachineIds(stationMachineIds)); |
|
|
|
|
zyPlanProcess.setStationId(station.getId()); |
|
|
|
|
zyPlanProcess.setStationName(station.getStationName()); |
|
|
|
|
zyPlanProcess.setStationNum(station.getStationNum()); |
|
|
|
|
this.updateById(zyPlanProcess); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -467,7 +472,11 @@ public class ZyPlanProcessServiceImpl extends ServiceImpl<ZyPlanProcessMapper, Z |
|
|
|
|
ZyPlanProcessAccessories en = new ZyPlanProcessAccessories(); |
|
|
|
|
en.setPlanProcessId(e.getId()); |
|
|
|
|
en.setPlanId(e.getPlanId()); |
|
|
|
|
en.setAmount(new BigDecimal(obj.getAmount())); |
|
|
|
|
if (!ObjectUtils.isEmpty(obj.getAmount())) { |
|
|
|
|
en.setAmount(new BigDecimal(obj.getAmount())); |
|
|
|
|
} else { |
|
|
|
|
en.setAmount(new BigDecimal(0)); |
|
|
|
|
} |
|
|
|
|
en.setAccessoriesId(obj.getAccessoriesId()); |
|
|
|
|
ZyAccessories zyAccessories = iZyAccessoriesService.getById(obj.getAccessoriesId()); |
|
|
|
|
en.setAccessoriesName(StringUtils.isNotBlank(zyAccessories.getContents()) ? zyAccessories.getContents() : ""); |
|
|
|
@ -492,7 +501,11 @@ public class ZyPlanProcessServiceImpl extends ServiceImpl<ZyPlanProcessMapper, Z |
|
|
|
|
en.setPlanProcessId(e.getId()); |
|
|
|
|
en.setPlanId(e.getPlanId()); |
|
|
|
|
en.setFabricId(obj.getFabricId()); |
|
|
|
|
en.setAmount(new BigDecimal(obj.getAmount())); |
|
|
|
|
if (!ObjectUtils.isEmpty(obj.getAmount())) { |
|
|
|
|
en.setAmount(new BigDecimal(obj.getAmount())); |
|
|
|
|
} else { |
|
|
|
|
en.setAmount(new BigDecimal(0)); |
|
|
|
|
} |
|
|
|
|
ZyFabric zyFabric = iZyFabricService.getById(obj.getFabricId()); |
|
|
|
|
en.setFabricName(StringUtils.isNotBlank(zyFabric.getName()) ? zyFabric.getName() : ""); |
|
|
|
|
list.add(en); |
|
|
|
@ -590,6 +603,8 @@ public class ZyPlanProcessServiceImpl extends ServiceImpl<ZyPlanProcessMapper, Z |
|
|
|
|
.stream().map(ZyPlanProcess::getId).collect(Collectors.toList()); |
|
|
|
|
|
|
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
|
if (ObjectUtils.isEmpty(ids)) return result; |
|
|
|
|
|
|
|
|
|
List<ZyPlanFabric> fabricList = iZyPlanFabricService.list(new LambdaQueryWrapper<ZyPlanFabric>() |
|
|
|
|
.eq(ZyPlanFabric::getPlanId, zyPlanProcess.getPlanId())); |
|
|
|
|
result.put("fabricList", fabricList); |
|
|
|
|