| | |
| | | |
| | | @Override |
| | | public int productionReportUpdate(ProductionReportDto productionReportDto) { |
| | | SalesLedgerWork salesLedgerWork = salesLedgerWorkMapper.selectById(productionReportDto.getId()); |
| | | if(salesLedgerWork == null) throw new RuntimeException("报工数据不存在"); |
| | | SalesLedgerProductionAccounting salesLedgerProductionAccounting = salesLedgerProductionAccountingMapper.selectById(productionReportDto.getId()); |
| | | if(salesLedgerProductionAccounting == null) throw new RuntimeException("报工数据不存在"); |
| | | SysUser sysUser = sysUserMapper.selectUserById(productionReportDto.getSchedulingUserId()); |
| | | if(sysUser == null) throw new RuntimeException("生产人不存在"); |
| | | salesLedgerProductionAccounting.setFinishedNum(productionReportDto.getFinishedNum()); |
| | | salesLedgerProductionAccounting.setSchedulingUserId(sysUser.getUserId()); |
| | | salesLedgerProductionAccounting.setSchedulingUserName(sysUser.getNickName()); |
| | | salesLedgerProductionAccounting.setSchedulingDate(LocalDate.parse(productionReportDto.getSchedulingDate(), DateTimeFormatter.ISO_LOCAL_DATE)); |
| | | salesLedgerProductionAccountingMapper.updateById(salesLedgerProductionAccounting); |
| | | |
| | | // 更新报工数据 |
| | | SalesLedgerWork salesLedgerWork = salesLedgerWorkMapper.selectById(salesLedgerProductionAccounting.getSalesLedgerWorkId()); |
| | | if(salesLedgerWork == null) throw new RuntimeException("报工数据不存在"); |
| | | salesLedgerWork.setFinishedNum(productionReportDto.getFinishedNum()); |
| | | if(salesLedgerWork.getSchedulingNum().compareTo(salesLedgerWork.getFinishedNum()) <= 0){ |
| | | salesLedgerWork.setStatus(3); |
| | |
| | | salesLedgerWork.setSchedulingUserName(sysUser.getNickName()); |
| | | salesLedgerWork.setSchedulingDate(LocalDate.parse(productionReportDto.getSchedulingDate(), DateTimeFormatter.ISO_LOCAL_DATE)); |
| | | salesLedgerWorkMapper.updateById(salesLedgerWork); |
| | | |
| | | // 更新核算数据 |
| | | LambdaQueryWrapper<SalesLedgerProductionAccounting> salesLedgerProductionAccountingLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | salesLedgerProductionAccountingLambdaQueryWrapper.eq(SalesLedgerProductionAccounting::getSalesLedgerWorkId, salesLedgerWork.getId()) |
| | | .orderByDesc(SalesLedgerProductionAccounting::getCreateTime) |
| | | .last("limit 1"); |
| | | SalesLedgerProductionAccounting salesLedgerProductionAccounting = salesLedgerProductionAccountingMapper.selectOne(salesLedgerProductionAccountingLambdaQueryWrapper); |
| | | if(salesLedgerProductionAccounting != null){ |
| | | salesLedgerProductionAccounting.setFinishedNum(productionReportDto.getFinishedNum()); |
| | | salesLedgerProductionAccounting.setSchedulingUserId(sysUser.getUserId()); |
| | | salesLedgerProductionAccounting.setSchedulingUserName(sysUser.getNickName()); |
| | | salesLedgerProductionAccounting.setSchedulingDate(LocalDate.parse(productionReportDto.getSchedulingDate(), DateTimeFormatter.ISO_LOCAL_DATE)); |
| | | salesLedgerProductionAccountingMapper.updateById(salesLedgerProductionAccounting); |
| | | } |
| | | return 0; |
| | | } |
| | | |