| | |
| | | */ |
| | | package me.zhengjie.modules.capitalFlow.service.impl; |
| | | |
| | | import me.zhengjie.exception.BadRequestException; |
| | | import me.zhengjie.modules.capitalFlow.domain.CapitalFlow; |
| | | import me.zhengjie.modules.capitalFlow.domain.CapitalFlowExpend; |
| | | import me.zhengjie.modules.capitalFlow.domain.CapitalFlowIncome; |
| | | 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 org.springframework.data.domain.Page; |
| | | import org.springframework.data.domain.Pageable; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.io.IOException; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.ArrayList; |
| | | import java.util.LinkedHashMap; |
| | | import java.util.function.Function; |
| | | |
| | | /** |
| | |
| | | * @date 2023-02-13 |
| | | **/ |
| | | @Service |
| | | @Transactional |
| | | @RequiredArgsConstructor |
| | | public class CapitalFlowServiceImpl implements CapitalFlowService { |
| | | |
| | |
| | | private final SysCompanyServiceImpl sysCompanyServiceImpl; |
| | | private final CapitalFlowExpendRepository capitalFlowExpendRepository; |
| | | private final CapitalFlowIncomeRepository capitalFlowIncomeRepository; |
| | | private final CapitalServiceImpl capitalService; |
| | | |
| | | @Override |
| | | public Map<String,Object> queryAll(CapitalFlowQueryCriteria criteria, Pageable pageable){ |
| | |
| | | @Override |
| | | public void deleteAll(Long[] ids) { |
| | | for (Long id : ids) { |
| | | // 查询流水支出表 |
| | | List<CapitalFlowExpend> capitalFlowExpends = capitalFlowExpendRepository.findByFlowId(id); |
| | | for(int i = 0; i < capitalFlowExpends.size(); i++){ |
| | | capitalFlowExpendRepository.deleteByFlowId(capitalFlowExpends.get(i).getFlowId()); |
| | | } |
| | | // 查询流水收入表 |
| | | List<CapitalFlowIncome> capitalFlowIncomes = capitalFlowIncomeRepository.findByFlowId(id); |
| | | for(int i = 0; i < capitalFlowIncomes.size(); i++){ |
| | | capitalFlowIncomeRepository.deleteByFlowId(capitalFlowIncomes.get(i).getFlowId()); |
| | | } |
| | | capitalFlowRepository.deleteById(id); |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | /** |
| | | * 流水生成 |
| | | * @param resources / |
| | | */ |
| | | @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("只能更新上个月的流水记录"); |
| | | } |
| | | // 格式化日期 |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
| | | // 目标年月 |
| | | String targetYearMonth = sdf.format(resources.getFlowYearMonth().getTime()); |
| | | capitalService.getCapitalInfo(resources.getCompanyId(), targetYearMonth); |
| | | } |
| | | |
| | | /** |
| | | * 公司名称 |
| | | * @param resources |
| | | * @return |