| | |
| | | import me.zhengjie.modules.capitalFlow.repository.CapitalFlowExpendRepository; |
| | | import me.zhengjie.modules.capitalFlow.repository.CapitalFlowIncomeRepository; |
| | | import me.zhengjie.modules.quartz.service.impl.CapitalServiceImpl; |
| | | import me.zhengjie.modules.system.service.dto.SysCompanyDto; |
| | | import me.zhengjie.modules.system.service.impl.SysCompanyServiceImpl; |
| | | import me.zhengjie.utils.*; |
| | | import lombok.RequiredArgsConstructor; |
| | | import me.zhengjie.modules.capitalFlow.repository.CapitalFlowRepository; |
| | |
| | | */ |
| | | @Override |
| | | public void generate(CapitalFlow resources) { |
| | | // 日历类 |
| | | Calendar cal = Calendar.getInstance(); |
| | | cal.add(Calendar.MONTH, -1); |
| | | if(resources.getFlowYearMonth().compareTo(cal.getTime()) > 0){ |
| | | throw new BadRequestException("只能更新上个月的流水记录"); |
| | | } |
| | | // // 日历类 |
| | | // Calendar cal = Calendar.getInstance(); |
| | | // cal.add(Calendar.MONTH, -1); |
| | | // if(resources.getFlowYearMonth().compareTo(cal.getTime()) > 0){ |
| | | // throw new BadRequestException("只能更新上个月的流水记录"); |
| | | // } |
| | | // 格式化日期 |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
| | | // 目标年月 |
| | |
| | | CapitalAccountCompanyDto capitalAccountCompanyDto = capitalAccountCompanyService.findById(resources.getAccountCompanyId()); |
| | | return capitalAccountCompanyDto.getAccountName(); |
| | | } |
| | | |
| | | /** |
| | | * 关联月度资金公司流账户 |
| | | * @return |
| | | */ |
| | | public CapitalFlowDto relevanceCapitalFlow(Long accountCompanyId) { |
| | | // 当前系统时间 |
| | | Calendar calendar = Calendar.getInstance(); |
| | | // 资金流水检索类 |
| | | CapitalFlowQueryCriteria criteria = new CapitalFlowQueryCriteria(); |
| | | criteria.setAccountCompanyId(accountCompanyId); |
| | | criteria.setFlowYearMonth(DateUtil.getYearMonth(calendar)); |
| | | // 查询资金流水 |
| | | List<CapitalFlowDto> capitalFlowDtoList = capitalFlowMapper.toDto(capitalFlowRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));; |
| | | // 判断资金流水 |
| | | if (capitalFlowDtoList.size() == 0) { |
| | | throw new BadRequestException("没有找到对应的月度资金公司流账户!"); |
| | | } else if (capitalFlowDtoList.size() > 1) { |
| | | throw new BadRequestException("找到多条对应的月度资金公司流账户!"); |
| | | } |
| | | return capitalFlowDtoList.get(0); |
| | | } |
| | | } |