| | |
| | | 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; |
| | |
| | | iPage.getRecords().forEach(item -> { |
| | | String[] split = item.getSpecificationModel().split("\\*"); |
| | | if(split.length == 2 && isNumeric(split[1]) && isNumeric(split[0])){ |
| | | // 计算损耗 |
| | | // 计算损耗(100000代表 损耗的 100 和 单位转换的1000) |
| | | BigDecimal divide = new BigDecimal(split[0]) |
| | | .multiply(new BigDecimal(split[1])) |
| | | .multiply(item.getFinishedNum()) |
| | | .multiply(losses.get(0).getRate()) |
| | | .divide(new BigDecimal(100), 2, RoundingMode.HALF_UP); |
| | | .divide(new BigDecimal(100000), 2, RoundingMode.HALF_UP); |
| | | item.setLoss(divide.toString()); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | private final ProcurementRecordServiceImpl procurementRecordService; |
| | | |
| | | private final SalesLedgerProductMapper salesLedgerProductMapper; |
| | | |
| | | @Override |
| | | public int productionReport(ProductionReportDto productionReportDto) { |
| | |
| | | .process(salesLedgerWork.getProcess()) |
| | | .schedulingDate(LocalDate.parse(productionReportDto.getSchedulingDate(), DateTimeFormatter.ISO_LOCAL_DATE)); |
| | | salesLedgerProductionAccountingMapper.insert(builder.build()); |
| | | // 查询销售产品单价 |
| | | SalesLedgerProduct salesLedgerProduct = salesLedgerProductMapper.selectById(salesLedgerWork.getSalesLedgerProductId()); |
| | | // 生产报工成功 -> 入库 |
| | | LoginUser loginUser = SecurityUtils.getLoginUser(); |
| | | ProcurementAddDto procurementRecordOutAdd = new ProcurementAddDto(); |
| | |
| | | Details details1 = new Details(); |
| | | details1.setInboundQuantity(productionReportDto.getFinishedNum()); |
| | | details1.setId(Integer.parseInt(salesLedgerWork.getSalesLedgerProductId().toString())); |
| | | details1.setTaxInclusiveUnitPrice(salesLedgerProduct != null ? salesLedgerProduct.getTaxInclusiveUnitPrice() : productionReportDto.getUnitPrice()); |
| | | details1.setTotalPrice(details1.getTaxInclusiveUnitPrice().multiply(details1.getInboundQuantity())); |
| | | details.add(details1); |
| | | procurementRecordOutAdd.setDetails(details); |
| | | procurementRecordService.add(procurementRecordOutAdd); |