|
|
@@ -6,6 +6,7 @@ import cn.hutool.core.util.StrUtil;
|
|
|
import com.alibaba.excel.EasyExcel;
|
|
|
import com.alibaba.excel.support.ExcelTypeEnum;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
|
|
import com.xjrsoft.common.model.result.RT;
|
|
|
import com.xjrsoft.common.mybatis.SqlRunnerAdapter;
|
|
|
@@ -26,7 +27,6 @@ import com.xjrsoft.module.organization.service.IUserDeptRelationService;
|
|
|
import com.xjrsoft.module.organization.service.IUserService;
|
|
|
import com.xjrsoft.module.organization.vo.UserPageVo;
|
|
|
import com.xjrsoft.module.teacher.entity.BaseTeacher;
|
|
|
-import com.xjrsoft.module.teacher.entity.WfTeacherleave;
|
|
|
import com.xjrsoft.module.teacher.service.IWfTeacherleaveService;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
@@ -41,7 +41,6 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
import javax.validation.Valid;
|
|
|
import java.io.ByteArrayOutputStream;
|
|
|
import java.text.DecimalFormat;
|
|
|
-import java.time.LocalDateTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
@@ -82,47 +81,11 @@ public class LedgerStatisticsController {
|
|
|
userIdList.addAll(userList.stream().map(UserDeptRelation::getUserId).collect(Collectors.toList()));
|
|
|
}
|
|
|
|
|
|
- LocalDateTime startTime = null;
|
|
|
- LocalDateTime endTime = null;
|
|
|
- if(dto.getStartDate() != null && dto.getEndDate() != null){
|
|
|
- startTime = dto.getStartDate().atTime(0,0,0);
|
|
|
- endTime = dto.getEndDate().atTime(23,59,59);
|
|
|
- }
|
|
|
- Map<String, List<WfTeacherleave>> userLeaveMap = teacherleaveService.getUserLeaveList(startTime, endTime, userIdList);
|
|
|
-
|
|
|
- List<String> userIds = new ArrayList<>(userLeaveMap.keySet());
|
|
|
- if(userIds.isEmpty()){
|
|
|
- return RT.ok(new PageOutput<>());
|
|
|
- }
|
|
|
-
|
|
|
- IPage<LedgerStatisticsLeaveVo> userPage = userService.selectJoinListPage(ConventPage.getPage(dto), LedgerStatisticsLeaveVo.class,
|
|
|
- new MPJLambdaWrapper<User>()
|
|
|
- .disableSubLogicDel()
|
|
|
- .select(User::getId)
|
|
|
- .select(User.class, x -> VoToColumnUtil.fieldsToColumns(UserPageVo.class).contains(x.getProperty()))
|
|
|
- .select(" (SELECT GROUP_CONCAT(t1.name) FROM xjr_department t1" +
|
|
|
- " INNER JOIN xjr_user_dept_relation t2 ON t1.id = t2.dept_id" +
|
|
|
- " WHERE t1.delete_mark = 0 AND t2.user_id = t.id) as dept_name")
|
|
|
- .innerJoin(BaseTeacher.class, BaseTeacher::getUserId, User::getId)
|
|
|
- .like(StrUtil.isNotEmpty(dto.getName()), User::getName, dto.getName())
|
|
|
- .like(StrUtil.isNotEmpty(dto.getUserName()), User::getUserName, dto.getUserName())
|
|
|
- .in(User::getId, userIds)
|
|
|
- .orderByAsc(User::getId)
|
|
|
- );
|
|
|
-
|
|
|
- for (LedgerStatisticsLeaveVo record : userPage.getRecords()) {
|
|
|
- List<WfTeacherleave> wfTeacherleaves = userLeaveMap.get(record.getId().toString());
|
|
|
- if(wfTeacherleaves == null || wfTeacherleaves.isEmpty()){
|
|
|
- continue;
|
|
|
- }
|
|
|
- double value = wfTeacherleaves.stream().mapToDouble(WfTeacherleave::getLeaveDays).sum();
|
|
|
- boolean isInteger = (value % 1) == 0;
|
|
|
- DecimalFormat df = new DecimalFormat(isInteger ? "0" : "#.##");
|
|
|
- String formattedValue = df.format(value);
|
|
|
- record.setLeaveDays(formattedValue);
|
|
|
+ if(!userIdList.isEmpty()){
|
|
|
+ dto.setUserIds(userIdList);
|
|
|
}
|
|
|
-
|
|
|
- PageOutput<LedgerStatisticsLeaveVo> pageOutput = ConventPage.getPageOutput(userPage, LedgerStatisticsLeaveVo.class);
|
|
|
+ Page<LedgerStatisticsLeaveVo> page = teacherleaveService.getStatisticsPage(new Page<>(dto.getLimit(), dto.getSize()), dto);
|
|
|
+ PageOutput<LedgerStatisticsLeaveVo> pageOutput = ConventPage.getPageOutput(page, LedgerStatisticsLeaveVo.class);
|
|
|
return RT.ok(pageOutput);
|
|
|
}
|
|
|
|
|
|
@@ -143,50 +106,13 @@ public class LedgerStatisticsController {
|
|
|
userIdList.addAll(userList.stream().map(UserDeptRelation::getUserId).collect(Collectors.toList()));
|
|
|
}
|
|
|
|
|
|
- LocalDateTime startTime = null;
|
|
|
- LocalDateTime endTime = null;
|
|
|
- if(dto.getStartDate() != null && dto.getEndDate() != null){
|
|
|
- startTime = dto.getStartDate().atTime(0,0,0);
|
|
|
- endTime = dto.getEndDate().atTime(23,59,59);
|
|
|
- }
|
|
|
- Map<String, List<WfTeacherleave>> userLeaveMap = teacherleaveService.getUserLeaveList(startTime, endTime, userIdList);
|
|
|
-
|
|
|
- List<String> userIds = new ArrayList<>(userLeaveMap.keySet());
|
|
|
- if(userIds.isEmpty()){
|
|
|
- List<LedgerStatisticsLeaveExcelVo> list = new ArrayList<>();
|
|
|
- ByteArrayOutputStream bot = new ByteArrayOutputStream();
|
|
|
- EasyExcel.write(bot, LedgerStatisticsLeaveExcelVo.class).automaticMergeHead(false).excelType(ExcelTypeEnum.XLSX).sheet().doWrite(list);
|
|
|
-
|
|
|
- return RT.fileStream(bot.toByteArray(), "teacher-leave" + ExcelTypeEnum.XLSX.getValue());
|
|
|
+ if(!userIdList.isEmpty()){
|
|
|
+ dto.setUserIds(userIdList);
|
|
|
}
|
|
|
-
|
|
|
- List<LedgerStatisticsLeaveVo> list = userService.selectJoinList(LedgerStatisticsLeaveVo.class,
|
|
|
- new MPJLambdaWrapper<User>()
|
|
|
- .disableSubLogicDel()
|
|
|
- .select(User::getId)
|
|
|
- .select(User.class, x -> VoToColumnUtil.fieldsToColumns(UserPageVo.class).contains(x.getProperty()))
|
|
|
- .select(" (SELECT GROUP_CONCAT(t1.name) FROM xjr_department t1" +
|
|
|
- " INNER JOIN xjr_user_dept_relation t2 ON t1.id = t2.dept_id" +
|
|
|
- " WHERE t1.delete_mark = 0 AND t2.user_id = t.id) as dept_name")
|
|
|
- .innerJoin(BaseTeacher.class, BaseTeacher::getUserId, User::getId)
|
|
|
- .like(StrUtil.isNotEmpty(dto.getName()), User::getName, dto.getName())
|
|
|
- .like(StrUtil.isNotEmpty(dto.getUserName()), User::getUserName, dto.getUserName())
|
|
|
- .in(User::getId, userIds)
|
|
|
- .orderByAsc(User::getId)
|
|
|
- );
|
|
|
+ List<LedgerStatisticsLeaveVo> list = teacherleaveService.getStatisticsList(dto);
|
|
|
List<LedgerStatisticsLeaveExcelVo> dataList = new ArrayList<>();
|
|
|
-
|
|
|
int sortCode = 1;
|
|
|
for (LedgerStatisticsLeaveVo record : list) {
|
|
|
- List<WfTeacherleave> wfTeacherleaves = userLeaveMap.get(record.getId().toString());
|
|
|
- if(wfTeacherleaves == null || wfTeacherleaves.isEmpty()){
|
|
|
- continue;
|
|
|
- }
|
|
|
- double value = wfTeacherleaves.stream().mapToDouble(WfTeacherleave::getLeaveDays).sum();
|
|
|
- boolean isInteger = (value % 1) == 0;
|
|
|
- DecimalFormat df = new DecimalFormat(isInteger ? "0" : "#.##");
|
|
|
- String formattedValue = df.format(value);
|
|
|
- record.setLeaveDays(formattedValue);
|
|
|
record.setSortCode(sortCode);
|
|
|
LedgerStatisticsLeaveExcelVo bean = BeanUtil.toBean(record, LedgerStatisticsLeaveExcelVo.class);
|
|
|
dataList.add(bean);
|