| | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.approve.utils.StartAndEndDateDto; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.excel.ConfigurableMergeStrategy; |
| | | import com.ruoyi.common.utils.excel.CustomCellStyleHandler; |
| | | import com.ruoyi.lavorissue.dto.StatisticsLaborIssue; |
| | |
| | | import com.ruoyi.project.system.domain.SysDictData; |
| | | import com.ruoyi.project.system.mapper.SysDeptMapper; |
| | | import com.ruoyi.project.system.mapper.SysDictDataMapper; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.poi.ss.util.CellRangeAddress; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.net.URLEncoder; |
| | |
| | | */ |
| | | @Service |
| | | @Slf4j |
| | | @RequiredArgsConstructor |
| | | public class LavorIssueServiceImpl extends ServiceImpl<LavorIssueMapper, LaborIssue> implements LavorIssueService { |
| | | |
| | | @Autowired |
| | | private LavorIssueMapper lavorIssueMapper; |
| | | private final LavorIssueMapper lavorIssueMapper; |
| | | private final SysDictDataMapper sysDictDataMapper; |
| | | private final SysDeptMapper sysDeptMapper; |
| | | |
| | | |
| | | @Override |
| | | public IPage<LaborIssue> listPage(Page page, LaborIssue laborIssue) { |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> statisticsList(LaborIssue laborIssue){ |
| | | public List<Map<String, Object>> statisticsList(LaborIssue laborIssue) { |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
| | | StartAndEndDateDto startAndEndDateDto = getStartAndEndDateDto(laborIssue.getSeason(), laborIssue.getIssueDate()); |
| | | laborIssue.setStartDate(startAndEndDateDto.getStartDate()); |
| | |
| | | return records; |
| | | } |
| | | |
| | | public StartAndEndDateDto getStartAndEndDateDto(Integer season,Date payDate){ |
| | | public StartAndEndDateDto getStartAndEndDateDto(Integer season, Date payDate) { |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
| | | StartAndEndDateDto startAndEndDateDto = new StartAndEndDateDto(); |
| | | Calendar calendar = Calendar.getInstance(); |
| | | int currentYear = calendar.get(Calendar.YEAR); |
| | | startAndEndDateDto.setYear(currentYear); |
| | | if(season != null){ |
| | | switch (season){ |
| | | if (season != null) { |
| | | switch (season) { |
| | | case 1: |
| | | startAndEndDateDto.setStartDate(currentYear + "-01-01"); |
| | | startAndEndDateDto.setEndDate(currentYear + "-03-31"); |
| | |
| | | break; |
| | | } |
| | | } |
| | | if(payDate != null){ |
| | | if (payDate != null) { |
| | | Date lastDayOfMonth = getLastDayOfMonth(payDate); |
| | | Date firstDayOfMonth = getFirstDayOfMonth(payDate); |
| | | startAndEndDateDto.setStartDate(sdf.format(firstDayOfMonth)); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public StatisticsLaborIssue statistics(StatisticsLaborIssue req) throws Exception{ |
| | | public StatisticsLaborIssue statistics(StatisticsLaborIssue req) throws Exception { |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
| | | StatisticsLaborIssue statisticsLaborIssue = new StatisticsLaborIssue(); |
| | | StartAndEndDateDto startAndEndDateDto = getStartAndEndDateDto(req.getSeason(), req.getIssueDate()); |
| | | LambdaQueryWrapper<LaborIssue> laborIssueLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | if(req.getSeason() != null || req.getIssueDate() != null){ |
| | | if (req.getSeason() != null || req.getIssueDate() != null) { |
| | | laborIssueLambdaQueryWrapper.ge(LaborIssue::getIssueDate, startAndEndDateDto.getStartDate()) |
| | | .le(LaborIssue::getIssueDate, startAndEndDateDto.getEndDate()); |
| | | } |
| | | List<LaborIssue> laborIssues = lavorIssueMapper.selectList(laborIssueLambdaQueryWrapper); |
| | | if(!CollectionUtils.isEmpty(laborIssues)){ |
| | | if (!CollectionUtils.isEmpty(laborIssues)) { |
| | | Long sum = laborIssues.stream() |
| | | .filter(laborIssue -> laborIssue.getAdoptedDate() != null) |
| | | .mapToLong(LaborIssue::getNum) |
| | |
| | | return statisticsLaborIssue; |
| | | } |
| | | |
| | | @Autowired |
| | | private SysDictDataMapper sysDictDataMapper; |
| | | |
| | | @Override |
| | | public void exportCopy(HttpServletResponse response, LaborIssue laborIssue) throws UnsupportedEncodingException { |
| | | List<SysDictData> sys_lavor_issue = sysDictDataMapper.selectDictDataByType("sys_lavor_issue"); |
| | | if(CollectionUtils.isEmpty(sys_lavor_issue)){ |
| | | if (CollectionUtils.isEmpty(sys_lavor_issue)) { |
| | | throw new RuntimeException("字典数据为空"); |
| | | } |
| | | StartAndEndDateDto startAndEndDateDto = getStartAndEndDateDto(laborIssue.getSeason(), laborIssue.getIssueDate()); |
| | |
| | | //新建ExcelWriter |
| | | ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream()) |
| | | .registerWriteHandler(new CustomCellStyleHandler()) |
| | | .registerWriteHandler(new ConfigurableMergeStrategy(exportExternalPackingListGetMerge(4,sys_lavor_issue.size(),laborIssueMap.size()))) |
| | | .registerWriteHandler(new ConfigurableMergeStrategy(exportExternalPackingListGetMerge(4, sys_lavor_issue.size(), laborIssueMap.size()))) |
| | | .build(); |
| | | |
| | | List<List<List<String>>> data = completeExternalPackingList(laborIssueMap, sys_lavor_issue,laborIssue); |
| | | List<List<List<String>>> data = completeExternalPackingList(laborIssueMap, sys_lavor_issue, laborIssue); |
| | | |
| | | for (int i = 0; i < data.size(); i++) { |
| | | List<List<String>> list = data.get(i); |
| | |
| | | } |
| | | } |
| | | |
| | | @Autowired |
| | | private SysDeptMapper sysDeptMapper; |
| | | |
| | | |
| | | // 处理外部装箱单数据 |
| | | private List<List<List<String>>> completeExternalPackingList(Map<String, List<LaborIssue>> listMap,List<SysDictData> sys_lavor_issue,LaborIssue obj) { |
| | | // 处理外部装箱单数据 |
| | | private List<List<List<String>>> completeExternalPackingList(Map<String, List<LaborIssue>> listMap, List<SysDictData> sys_lavor_issue, LaborIssue obj) { |
| | | List<List<List<String>>> data = new ArrayList<>(); |
| | | int num = sys_lavor_issue.size(); |
| | | |
| | |
| | | list.add(""); |
| | | list.add("企业管理科"); |
| | | list.add(""); |
| | | list.add("企业管理科" + obj.getYear() + "年" + obj.getStartMonth() + "月-" + obj.getYear() + "年" + obj.getEndMonth() +"月劳保发放计划表"); |
| | | for (int i = 1; i <= num; i++){ |
| | | list.add("企业管理科" + obj.getYear() + "年" + obj.getStartMonth() + "月-" + obj.getYear() + "年" + obj.getEndMonth() + "月劳保发放计划表"); |
| | | for (int i = 1; i <= num; i++) { |
| | | list.add(""); |
| | | } |
| | | item.add(list); |
| | |
| | | list1.add(""); |
| | | list1.add("结束年/月"); |
| | | list1.add(""); |
| | | for (int i = 0; i <= num; i++){ |
| | | for (int i = 0; i <= num; i++) { |
| | | list1.add(""); |
| | | } |
| | | item.add(list1); |
| | |
| | | list2.add(obj.getStartMonth().toString()); |
| | | list2.add(obj.getYear().toString()); |
| | | list2.add(obj.getEndMonth().toString()); |
| | | for (int i = 0; i <= num; i++){ |
| | | for (int i = 0; i <= num; i++) { |
| | | list.add(""); |
| | | } |
| | | item.add(list2); |
| | |
| | | .mapToLong(LaborIssue::getNum) |
| | | .sum() |
| | | + ""); |
| | | if(i.get() == 0){ |
| | | if (i.get() == 0) { |
| | | sumList.add(value.stream().filter(laborIssue -> laborIssue.getDictId().equals(sysDictData.getDictValue())) |
| | | .mapToLong(LaborIssue::getNum) |
| | | .sum() |
| | | + ""); |
| | | }else { |
| | | sumList.set(j,(Long.parseLong(sumList.get(j)) + value.stream().filter(laborIssue -> laborIssue.getDictId().equals(sysDictData.getDictValue())) |
| | | } else { |
| | | sumList.set(j, (Long.parseLong(sumList.get(j)) + value.stream().filter(laborIssue -> laborIssue.getDictId().equals(sysDictData.getDictValue())) |
| | | .mapToLong(LaborIssue::getNum) |
| | | .sum()) |
| | | + ""); |
| | |
| | | list5.add(""); |
| | | list5.add(""); |
| | | list5.add(""); |
| | | for (int h = 0; h < sumList.size(); h++){ |
| | | for (int h = 0; h < sumList.size(); h++) { |
| | | list5.add(sumList.get(h)); |
| | | } |
| | | item.add(list5); |
| | |
| | | * |
| | | * @return |
| | | */ |
| | | private List<CellRangeAddress> exportExternalPackingListGetMerge(Integer rowNum,Integer num,Integer listSize) { |
| | | private List<CellRangeAddress> exportExternalPackingListGetMerge(Integer rowNum, Integer num, Integer listSize) { |
| | | List<CellRangeAddress> mergeRegions = new ArrayList<>(); |
| | | mergeRegions.add(new CellRangeAddress(0, 0, 0, 1)); // 合并A1:Q2 |
| | | mergeRegions.add(new CellRangeAddress(0, 0, 2, 3)); // 合并A4:Q4 |
| | |
| | | |
| | | /** |
| | | * 获取当月第一天 |
| | | * |
| | | * @param date |
| | | * @return |
| | | */ |