|
@@ -979,65 +979,74 @@ public class BizDayworkController extends BaseController {
|
|
|
@GetMapping(value = "/showDaywork")
|
|
|
@Log(title = "报工", businessType = BusinessType.SELECT)
|
|
|
public AjaxResult getDayworkByCarrierId(BizDayworkItem bizDayworkItem) {
|
|
|
- // 判断该批次是否已被领取
|
|
|
- // 获取该批次最后一条的状态
|
|
|
- List<BizDayworkCarrier> bizDayworkCarriers = bizDayworkCarrierService.query().eq("carrier_id", bizDayworkItem.getCarrierId()).eq("is_changed", 0).list();
|
|
|
- if (bizDayworkCarriers.isEmpty()) {
|
|
|
- throw new RuntimeException("该载具未绑定任何批次!");
|
|
|
- }
|
|
|
+ try {
|
|
|
+ // 根据箱号,获取箱子
|
|
|
+ BizCarrier bizCarrier = bizCarrierService.query().eq("carrier_code", bizDayworkItem.getCarrierCode()).one();
|
|
|
+ if (bizCarrier == null) {
|
|
|
+ return error("该箱号不存在");
|
|
|
+ }
|
|
|
+ // 判断该批次是否已被领取
|
|
|
+ // 获取该批次最后一条的状态
|
|
|
+ List<BizDayworkCarrier> bizDayworkCarriers = bizDayworkCarrierService.query().eq("carrier_id", bizCarrier.getId()).eq("is_changed", 0).list();
|
|
|
+ if (bizDayworkCarriers.isEmpty()) {
|
|
|
+ throw new RuntimeException("该载具未绑定任何批次!");
|
|
|
+ }
|
|
|
|
|
|
- List<BizDaywork> bizDayworks = bizDayworkService.query().in("id", bizDayworkCarriers.isEmpty()
|
|
|
- ?
|
|
|
- Collections.singletonList(0L)
|
|
|
- :
|
|
|
- bizDayworkCarriers.stream()
|
|
|
- .map(BizDayworkCarrier::getDayworkId)
|
|
|
- .collect(Collectors.toList())
|
|
|
- )
|
|
|
- .list();
|
|
|
+ List<BizDaywork> bizDayworks = bizDayworkService.query().in("id", bizDayworkCarriers.isEmpty()
|
|
|
+ ?
|
|
|
+ Collections.singletonList(0L)
|
|
|
+ :
|
|
|
+ bizDayworkCarriers.stream()
|
|
|
+ .map(BizDayworkCarrier::getDayworkId)
|
|
|
+ .collect(Collectors.toList())
|
|
|
+ )
|
|
|
+ .list();
|
|
|
|
|
|
- List<BizDayworkItem> allBizDayworkItem = bizDayworkItemService.query().in("daywork_id", bizDayworks.isEmpty() ? Collections.singletonList(0L) : bizDayworks.stream().map(BizDaywork::getId).collect(Collectors.toList())).orderByDesc("create_time").list();
|
|
|
- bizDayworks.forEach(l -> l.setDayworkItemList(allBizDayworkItem.stream().filter(v -> v.getDayworkId().equals(l.getId())).collect(Collectors.toList())));
|
|
|
- List<BizDayworkItem> turnoverItems = new ArrayList<>();
|
|
|
- for (BizDaywork bizDaywork : bizDayworks) {
|
|
|
- if (bizDaywork.getDayworkItemList().get(0).getStatus().equals("4")
|
|
|
- || bizDaywork.getDayworkItemList().get(0).getStatus().equals("5")
|
|
|
- || bizDaywork.getDayworkItemList().get(0).getStatus().equals("7")) {
|
|
|
- turnoverItems.add(bizDaywork.getDayworkItemList().get(0));
|
|
|
+ List<BizDayworkItem> allBizDayworkItem = bizDayworkItemService.query().in("daywork_id", bizDayworks.isEmpty() ? Collections.singletonList(0L) : bizDayworks.stream().map(BizDaywork::getId).collect(Collectors.toList())).orderByDesc("create_time").list();
|
|
|
+ bizDayworks.forEach(l -> l.setDayworkItemList(allBizDayworkItem.stream().filter(v -> v.getDayworkId().equals(l.getId())).collect(Collectors.toList())));
|
|
|
+ List<BizDayworkItem> turnoverItems = new ArrayList<>();
|
|
|
+ for (BizDaywork bizDaywork : bizDayworks) {
|
|
|
+ if (bizDaywork.getDayworkItemList().get(0).getStatus().equals("4")
|
|
|
+ || bizDaywork.getDayworkItemList().get(0).getStatus().equals("5")
|
|
|
+ || bizDaywork.getDayworkItemList().get(0).getStatus().equals("7")) {
|
|
|
+ turnoverItems.add(bizDaywork.getDayworkItemList().get(0));
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- if (!turnoverItems.isEmpty()) {
|
|
|
- BizDayworkItem conditions = new BizDayworkItem();
|
|
|
- conditions.setIds(turnoverItems.stream().map(BizDayworkItem::getId).collect(Collectors.toList()));
|
|
|
- List<BizDayworkItem> items = bizDayworkItemService.getList(conditions);
|
|
|
- //拿到生产计划id
|
|
|
- List<Long> productionPlanDetailIds = items.stream().map(BizDayworkItem::getProductionPlanDetailId).collect(Collectors.toList());
|
|
|
- List<BizProductionPlanDetail> bizProductionPlanDetails = bizProductionPlanDetailService.query().in("id", productionPlanDetailIds.isEmpty() ? Collections.singletonList(0L) : productionPlanDetailIds).list();
|
|
|
- //查找批次id
|
|
|
- List<Long> bizLotIds = bizDayworks.stream()
|
|
|
- .filter(v -> v.getIsWasteRecycling() == 1 || v.getIsAmend() == 1)
|
|
|
- .map(BizDaywork::getLotId).collect(Collectors.toList());
|
|
|
- List<BizLotTechnologicalProcess> bizLotTechnologicalProcesses = bizLotTechnologicalProcessService.query().eq("is_stop", 0).in("lot_id", bizLotIds.isEmpty() ? Collections.singletonList(0L) : bizLotIds).list();
|
|
|
- List<Long> LotTechnologicalProcessesIds = bizLotTechnologicalProcesses.stream().map(BizLotTechnologicalProcess::getId).collect(Collectors.toList());
|
|
|
- List<BizLotTechnologicalProcessDetail> bizLotTechnologicalProcessDetails = bizLotTechnologicalProcessDetailService.query().in("lot_technological_process_id", LotTechnologicalProcessesIds.isEmpty() ? Collections.singletonList(0L) : LotTechnologicalProcessesIds).list();
|
|
|
- for (BizDayworkItem item : items) {
|
|
|
- //添加产品描述
|
|
|
- item.setProductDescription(bizProductionPlanDetails.stream().filter(v -> v.getId().equals(item.getProductionPlanDetailId())).collect(Collectors.toList()).get(0).getProductDescription());
|
|
|
- //如果不是正常批次,则工艺重新取
|
|
|
- if (bizLotIds.contains(item.getLotId())) {
|
|
|
- List<BizLotTechnologicalProcessDetail> processDetail = bizLotTechnologicalProcessDetails.stream().filter(v -> v.getLotId().equals(item.getLotId())).collect(Collectors.toList());
|
|
|
- BizLotTechnologicalProcessDetail process = processDetail.stream().filter(v -> v.getProcessStepNumber().equals(item.getProcessStepNumber())).findFirst().orElse(null);
|
|
|
- BizTechnologicalProcessDetail technologicalProcessDetail = new BizTechnologicalProcessDetail();
|
|
|
- technologicalProcessDetail.setProcessAlias(process.getProcessAlias());
|
|
|
- technologicalProcessDetail.setProcessCode(process.getProcessCode());
|
|
|
- technologicalProcessDetail.setProductDescription(process.getProductDescription());
|
|
|
- technologicalProcessDetail.setProcessStepNumber(process.getProcessStepNumber());
|
|
|
- item.setTechnologicalProcessDetail(technologicalProcessDetail);
|
|
|
+ if (!turnoverItems.isEmpty()) {
|
|
|
+ BizDayworkItem conditions = new BizDayworkItem();
|
|
|
+ conditions.setIds(turnoverItems.stream().map(BizDayworkItem::getId).collect(Collectors.toList()));
|
|
|
+ List<BizDayworkItem> items = bizDayworkItemService.getList(conditions);
|
|
|
+ //拿到生产计划id
|
|
|
+ List<Long> productionPlanDetailIds = items.stream().map(BizDayworkItem::getProductionPlanDetailId).collect(Collectors.toList());
|
|
|
+ List<BizProductionPlanDetail> bizProductionPlanDetails = bizProductionPlanDetailService.query().in("id", productionPlanDetailIds.isEmpty() ? Collections.singletonList(0L) : productionPlanDetailIds).list();
|
|
|
+ //查找批次id
|
|
|
+ List<Long> bizLotIds = bizDayworks.stream()
|
|
|
+ .filter(v -> v.getIsWasteRecycling() == 1 || v.getIsAmend() == 1)
|
|
|
+ .map(BizDaywork::getLotId).collect(Collectors.toList());
|
|
|
+ List<BizLotTechnologicalProcess> bizLotTechnologicalProcesses = bizLotTechnologicalProcessService.query().eq("is_stop", 0).in("lot_id", bizLotIds.isEmpty() ? Collections.singletonList(0L) : bizLotIds).list();
|
|
|
+ List<Long> LotTechnologicalProcessesIds = bizLotTechnologicalProcesses.stream().map(BizLotTechnologicalProcess::getId).collect(Collectors.toList());
|
|
|
+ List<BizLotTechnologicalProcessDetail> bizLotTechnologicalProcessDetails = bizLotTechnologicalProcessDetailService.query().in("lot_technological_process_id", LotTechnologicalProcessesIds.isEmpty() ? Collections.singletonList(0L) : LotTechnologicalProcessesIds).list();
|
|
|
+ for (BizDayworkItem item : items) {
|
|
|
+ //添加产品描述
|
|
|
+ item.setProductDescription(bizProductionPlanDetails.stream().filter(v -> v.getId().equals(item.getProductionPlanDetailId())).collect(Collectors.toList()).get(0).getProductDescription());
|
|
|
+ //如果不是正常批次,则工艺重新取
|
|
|
+ if (bizLotIds.contains(item.getLotId())) {
|
|
|
+ List<BizLotTechnologicalProcessDetail> processDetail = bizLotTechnologicalProcessDetails.stream().filter(v -> v.getLotId().equals(item.getLotId())).collect(Collectors.toList());
|
|
|
+ BizLotTechnologicalProcessDetail process = processDetail.stream().filter(v -> v.getProcessStepNumber().equals(item.getProcessStepNumber())).findFirst().orElse(null);
|
|
|
+ BizTechnologicalProcessDetail technologicalProcessDetail = new BizTechnologicalProcessDetail();
|
|
|
+ technologicalProcessDetail.setProcessAlias(process.getProcessAlias());
|
|
|
+ technologicalProcessDetail.setProcessCode(process.getProcessCode());
|
|
|
+ technologicalProcessDetail.setProductDescription(process.getProductDescription());
|
|
|
+ technologicalProcessDetail.setProcessStepNumber(process.getProcessStepNumber());
|
|
|
+ item.setTechnologicalProcessDetail(technologicalProcessDetail);
|
|
|
+ }
|
|
|
}
|
|
|
+ return success(items);
|
|
|
+ } else {
|
|
|
+ return success(turnoverItems);
|
|
|
}
|
|
|
- return success(items);
|
|
|
- } else {
|
|
|
- return success(turnoverItems);
|
|
|
+ } catch (Exception e) {
|
|
|
+ return error("箱子数据有误");
|
|
|
}
|
|
|
}
|
|
|
|