|
@@ -17,6 +17,10 @@ import org.jeecg.common.util.oConvertUtils;
|
|
|
import org.jeecg.modules.billet.billetHotsend.entity.BilletHotsendDetailsVo;
|
|
|
import org.jeecg.modules.billet.billetHotsendChangeShift.service.IBilletHotsendChangeShiftService;
|
|
|
import org.jeecg.modules.billet.operateLog.service.IOperateLogService;
|
|
|
+import org.jeecg.modules.billet.rollClubOne.entity.RollClubOneDetails;
|
|
|
+import org.jeecg.modules.billet.rollClubOne.service.IRollClubOneDetailsService;
|
|
|
+import org.jeecg.modules.billet.rollHeight.entity.RollHeightDetails;
|
|
|
+import org.jeecg.modules.billet.rollHeight.service.IRollHeightDetailsService;
|
|
|
import org.jeecg.modules.billet.storageBill.entity.BilletHotsendDetails;
|
|
|
import org.jeecg.modules.billet.storageBill.entity.StorageBill;
|
|
|
import org.jeecg.modules.billet.storageBill.service.IStorageBillService;
|
|
@@ -31,7 +35,9 @@ import org.springframework.web.servlet.ModelAndView;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.lang.reflect.Field;
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @Description: 钢坯装运单
|
|
@@ -56,6 +62,12 @@ public class StorageBillController extends JeecgController<StorageBill, IStorage
|
|
|
@Autowired
|
|
|
private IStorageCarLogService storageCarLogService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IRollClubOneDetailsService rollClubOneDetailsService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IRollHeightDetailsService rollHeightDetailsService;
|
|
|
+
|
|
|
@Autowired
|
|
|
private IBilletHotsendChangeShiftService billetHotsendChangeShiftService;
|
|
|
|
|
@@ -143,6 +155,47 @@ public class StorageBillController extends JeecgController<StorageBill, IStorage
|
|
|
}
|
|
|
// 封装分组后的结果到新的 IPage 对象
|
|
|
IPage<StorageBill> groupedPage = new Page<>(pageNo, pageSize, groupedMap.size());
|
|
|
+ for (StorageBill bill : groupedMap.values()){
|
|
|
+ List<String> storageBillIds = Arrays.stream(bill.getId().split(",")).collect(Collectors.toList());
|
|
|
+ String totalBlankOutputStr = "";
|
|
|
+ // 根据装运单ID查询对应的明细,统计总的出坯量
|
|
|
+ if ("棒一".equals(bill.getDestination()) && oConvertUtils.listIsNotEmpty(storageBillIds)){
|
|
|
+ LambdaQueryWrapper<RollClubOneDetails> queryWrapper1 = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper1.eq(RollClubOneDetails::getHeatNo, bill.getHeatNo());
|
|
|
+ queryWrapper1.in(RollClubOneDetails::getStorageBillId, storageBillIds);
|
|
|
+ List<RollClubOneDetails> rollClubOneDetailsList = rollClubOneDetailsService.list(queryWrapper1);
|
|
|
+ // 使用 Stream API 统计 blankOutput 字段的总和
|
|
|
+ OptionalDouble totalBlankOutputOptional = rollClubOneDetailsList != null ?
|
|
|
+ OptionalDouble.of(rollClubOneDetailsList.stream()
|
|
|
+ .mapToDouble(details -> details.getBlankOutput() != null ? details.getBlankOutput() : 0)
|
|
|
+ .sum()) : OptionalDouble.empty();
|
|
|
+ // 将总和转换为字符串
|
|
|
+ totalBlankOutputStr = totalBlankOutputOptional.isPresent() ?
|
|
|
+ String.valueOf(totalBlankOutputOptional.getAsDouble()) : "0";
|
|
|
+
|
|
|
+ }else if ("高线".equals(bill.getDestination()) && oConvertUtils.listIsNotEmpty(storageBillIds)){
|
|
|
+ LambdaQueryWrapper<RollHeightDetails> queryWrapper2 = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper2.eq(RollHeightDetails::getHeatNo, bill.getHeatNo());
|
|
|
+ queryWrapper2.in(RollHeightDetails::getStorageBillId, storageBillIds);
|
|
|
+ List<RollHeightDetails> rollHeightDetailsList = rollHeightDetailsService.list(queryWrapper2);
|
|
|
+ // 使用 Stream API 统计 blankOutput 字段的总和
|
|
|
+ OptionalDouble totalBlankOutputOptional = rollHeightDetailsList != null ?
|
|
|
+ OptionalDouble.of(rollHeightDetailsList.stream()
|
|
|
+ .mapToDouble(details -> details.getBlankOutput() != null ? details.getBlankOutput() : 0)
|
|
|
+ .sum()) : OptionalDouble.empty();
|
|
|
+ // 将总和转换为字符串,保留两位小时,四舍五入原则
|
|
|
+ if (totalBlankOutputOptional.isPresent()) {
|
|
|
+ // 使用 BigDecimal 进行精确计算和格式化
|
|
|
+ BigDecimal total = BigDecimal.valueOf(totalBlankOutputOptional.getAsDouble());
|
|
|
+ // 保留两位小数
|
|
|
+ total = total.setScale(3, BigDecimal.ROUND_HALF_UP);
|
|
|
+ totalBlankOutputStr = total.toString();
|
|
|
+ } else {
|
|
|
+ totalBlankOutputStr = "0";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ bill.setRemarks(totalBlankOutputStr);
|
|
|
+ }
|
|
|
groupedPage.setRecords(new ArrayList<>(groupedMap.values()));
|
|
|
return Result.OK(groupedPage);
|
|
|
}
|