| | |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | |
| | | salesLedgerWorkLambdaQueryWrapper.in(SalesLedgerWork::getSalesLedgerProductId, collect) |
| | | .ne(SalesLedgerWork::getStatus, 1); |
| | | List<SalesLedgerWork> salesLedgerWorks = salesLedgerWorkMapper.selectList(salesLedgerWorkLambdaQueryWrapper); |
| | | List<SalesLedgerSchedulingDto> list1 = new ArrayList<>(); |
| | | list.getRecords().forEach(i -> { |
| | | // 获取完成数量 |
| | | i.setSuccessNum(salesLedgerWorks |
| | |
| | | .filter(j -> j.getSalesLedgerProductId().equals(i.getSalesLedgerProductId())) |
| | | .map(SalesLedgerWork::getFinishedNum) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add)); |
| | | // 状态 = 数量和完工数量比较 |
| | | if(i.getSchedulingNum().compareTo(new BigDecimal(0)) == 0){ |
| | | i.setStatus("未完成"); |
| | | } else if(i.getSchedulingNum().compareTo(i.getSuccessNum()) == 0){ |
| | | i.setStatus("已完成"); |
| | | }else{ |
| | | i.setStatus("生产中"); |
| | | } |
| | | |
| | | // 计算生产总量 = 规格 * 数量 / 1000 |
| | | String[] split = i.getSpecificationModel().split("\\*"); |
| | | if(split.length == 2){ |
| | | if(split.length == 2 && isNumeric(split[0]) && isNumeric(split[1])){ |
| | | BigDecimal multiply = new BigDecimal(split[0]) |
| | | .multiply(new BigDecimal(split[1]) |
| | | .multiply(i.getQuantity()).divide(new BigDecimal(1000),2, RoundingMode.CEILING)); |
| | | i.setTotalProduction(multiply); |
| | | } |
| | | |
| | | // 状态 = 数量和完工数量比较 |
| | | if(i.getSchedulingNum().compareTo(new BigDecimal(0)) == 0){ |
| | | i.setStatus("未完成"); |
| | | } else if(i.getQuantity().compareTo(i.getSchedulingNum()) <= 0){ |
| | | i.setStatus("已完成"); |
| | | }else{ |
| | | i.setStatus("生产中"); |
| | | } |
| | | |
| | | }); |
| | | return list; |
| | | } |
| | | |
| | | public static boolean isNumeric(String str) { |
| | | if (str == null || str.isEmpty()) { |
| | | return false; |
| | | } |
| | | // 遍历字符串的每个字符,检查是否为数字 |
| | | for (int i = 0; i < str.length(); i++) { |
| | | if (!Character.isDigit(str.charAt(i))) { |
| | | return false; |
| | | } |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | |
| | | return new BigDecimal(totalNum.get()).multiply(new BigDecimal(100)).divide(lossNum, 2,RoundingMode.HALF_UP); |
| | | } |
| | | |
| | | private LossMapper lossMapper; |
| | | private final LossMapper lossMapper; |
| | | |
| | | |
| | | /** |
| | |
| | | list.getRecords().forEach(i -> { |
| | | // 计算生产总量 = 规格 * 数量 / 1000 |
| | | String[] split = i.getSpecificationModel().split("\\*"); |
| | | if(split.length == 2){ |
| | | if(split.length == 2 && isNumeric(split[0]) && isNumeric(split[1])){ |
| | | BigDecimal multiply = new BigDecimal(split[0]) |
| | | .multiply(new BigDecimal(split[1]) |
| | | .multiply(i.getSuccessNum()).divide(new BigDecimal(1000),2, RoundingMode.CEILING)); |
| | |
| | | .salesLedgerSchedulingId(salesLedgerScheduling.getId()) |
| | | .salesLedgerId(salesLedgerScheduling.getSalesLedgerId()) |
| | | .remark(processSchedulingDto.getRemark()) |
| | | .productionLine(processSchedulingDto.getProductionLine()) |
| | | .type(processSchedulingDto.getType()) |
| | | .loss(processSchedulingDto.getLoss()) |
| | | .receive(processSchedulingDto.getReceive()) |