| | |
| | | import com.ruoyi.production.service.SalesLedgerSchedulingService; |
| | | import com.ruoyi.project.system.domain.SysUser; |
| | | import com.ruoyi.project.system.mapper.SysUserMapper; |
| | | import com.ruoyi.sales.mapper.LossMapper; |
| | | import com.ruoyi.sales.mapper.SalesLedgerProductMapper; |
| | | import com.ruoyi.sales.pojo.Loss; |
| | | import com.ruoyi.sales.pojo.SalesLedgerProduct; |
| | | 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; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.time.LocalDate; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.ArrayList; |
| | |
| | | }else{ |
| | | i.setStatus("生产中"); |
| | | } |
| | | // 计算生产总量 = 规格 * 数量 / 1000 |
| | | String[] split = i.getSpecificationModel().split("\\*"); |
| | | 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); |
| | | } |
| | | |
| | | }); |
| | | 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 |
| | |
| | | totalNum.addAndGet(productionNum.intValue()); |
| | | } |
| | | }); |
| | | return new BigDecimal(totalNum.get()); |
| | | // 需要 / 损耗率 |
| | | Loss loss = lossMapper.selectOne(new LambdaQueryWrapper<Loss>().last("limit 1")); |
| | | BigDecimal lossNum = loss == null ? new BigDecimal(6) : loss.getRate(); //没有损耗率则默认为6 |
| | | |
| | | return new BigDecimal(totalNum.get()).multiply(new BigDecimal(100)).divide(lossNum, 2,RoundingMode.HALF_UP); |
| | | } |
| | | |
| | | private final LossMapper lossMapper; |
| | | |
| | | |
| | | /** |
| | |
| | | // salesLedgerWorkLambdaQueryWrapper.in(SalesLedgerWork::getSalesLedgerSchedulingId, collect) |
| | | // .ne(SalesLedgerWork::getStatus, 1); |
| | | // List<SalesLedgerWork> salesLedgerWorks = salesLedgerWorkMapper.selectList(salesLedgerWorkLambdaQueryWrapper); |
| | | // list.getRecords().forEach(i -> { |
| | | // // 获取完成数量 |
| | | // i.setSuccessNum(salesLedgerWorks |
| | | // .stream() |
| | | // .filter(j -> j.getSalesLedgerSchedulingId().equals(i.getId())) |
| | | // .map(SalesLedgerWork::getFinishedNum) |
| | | // .reduce(BigDecimal.ZERO, BigDecimal::add)); |
| | | // }); |
| | | list.getRecords().forEach(i -> { |
| | | // 计算生产总量 = 规格 * 数量 / 1000 |
| | | String[] split = i.getSpecificationModel().split("\\*"); |
| | | 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)); |
| | | i.setTotalProduction(multiply); |
| | | } |
| | | }); |
| | | return list; |
| | | } |
| | | |