项目级大屏接口、人员任命导入导出接口
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
package org.dromara.bigscreen.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.dromara.bigscreen.domain.dto.WeatherQueryReq;
|
||||
import org.dromara.bigscreen.domain.vo.*;
|
||||
@ -10,6 +11,7 @@ import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.core.utils.DateUtils;
|
||||
import org.dromara.common.utils.BigDecimalUtil;
|
||||
import org.dromara.manager.weathermanager.vo.WeatherVo;
|
||||
import org.dromara.project.domain.BusAttendance;
|
||||
import org.dromara.project.domain.BusProject;
|
||||
import org.dromara.project.domain.BusUserProjectRelevancy;
|
||||
import org.dromara.project.service.IBusAttendanceService;
|
||||
@ -27,9 +29,10 @@ import java.math.RoundingMode;
|
||||
import java.text.DecimalFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 企业级大屏
|
||||
@ -138,19 +141,19 @@ public class EnterpriseBigScreenController {
|
||||
.map(BusUserProjectRelevancy::getUserId)
|
||||
.distinct().count());
|
||||
|
||||
// peopleCountVo.setManagersCount(list.stream().filter(item -> "2".equals(item.getUserType()))
|
||||
// .map(BusUserProjectRelevancy::getUserId)
|
||||
// .distinct().count());
|
||||
peopleCountVo.setManagersCount(69L);
|
||||
peopleCountVo.setManagersCount(list.stream().filter(item -> "2".equals(item.getUserType()))
|
||||
.map(BusUserProjectRelevancy::getUserId)
|
||||
.distinct().count());
|
||||
// peopleCountVo.setManagersCount(69L);
|
||||
|
||||
// peopleCountVo.setSubcontractorsCount(list.stream().filter(item -> "3".equals(item.getUserType()))
|
||||
// .map(BusUserProjectRelevancy::getUserId)
|
||||
// .distinct().count());
|
||||
peopleCountVo.setSubcontractorsCount(list.stream().filter(item -> "3".equals(item.getUserType()))
|
||||
.map(BusUserProjectRelevancy::getUserId)
|
||||
.distinct().count());
|
||||
|
||||
peopleCountVo.setManagersCount(9L);
|
||||
// peopleCountVo.setManagersCount(9L);
|
||||
|
||||
Integer projectUserCount = projectBigScreenMapper.getUserCount();
|
||||
peopleCountVo.setConstructionPersonnelCount(Long.valueOf(projectUserCount));
|
||||
// Integer projectUserCount = projectBigScreenMapper.getUserCount();
|
||||
// peopleCountVo.setConstructionPersonnelCount(Long.valueOf(projectUserCount));
|
||||
return R.ok(peopleCountVo);
|
||||
}
|
||||
|
||||
@ -162,15 +165,14 @@ public class EnterpriseBigScreenController {
|
||||
@GetMapping("/allAttendanceCount")
|
||||
public R<TodayAttendanceCountVo> getAllAttendanceCount() {
|
||||
TodayAttendanceCountVo todayAttendanceCountVo = new TodayAttendanceCountVo();
|
||||
List<BusProject> projectList = projectService.listByIds(List.of(1897160897167638529L, 1897161054676336641L));
|
||||
Integer countUser = 0;
|
||||
Integer countAttendance = 0;
|
||||
for (BusProject project : projectList) {
|
||||
Long projectId = project.getGoId();
|
||||
countUser = countUser + projectBigScreenMapper.getProjectUserCount(projectId);
|
||||
countAttendance = countAttendance + projectBigScreenMapper.getAttendanceCount(projectId, DateUtils.getDate());
|
||||
}
|
||||
/*
|
||||
// List<BusProject> projectList = projectService.listByIds(List.of(1897160897167638529L, 1897161054676336641L));
|
||||
// Integer countUser = 0;
|
||||
// Integer countAttendance = 0;
|
||||
// for (BusProject project : projectList) {
|
||||
// Long projectId = project.getGoId();
|
||||
// countUser = countUser + projectBigScreenMapper.getProjectUserCount(projectId);
|
||||
// countAttendance = countAttendance + projectBigScreenMapper.getAttendanceCount(projectId, DateUtils.getDate());
|
||||
// }
|
||||
List<BusAttendance> list = attendanceService.list(Wrappers.<BusAttendance>lambdaQuery()
|
||||
.eq(BusAttendance::getClockDate, LocalDate.now())
|
||||
.in(BusAttendance::getClockStatus, Arrays.asList("1", "2", "3"))
|
||||
@ -182,17 +184,16 @@ public class EnterpriseBigScreenController {
|
||||
// 查询总人数
|
||||
List<BusUserProjectRelevancy> relevancyList = userProjectRelevancyService.list();
|
||||
long totalUserCount = relevancyList.stream().map(BusUserProjectRelevancy::getUserId).distinct().count();
|
||||
*/
|
||||
|
||||
// 计算考勤率(保留一位小数)
|
||||
if (countUser > 0) {
|
||||
BigDecimal rate = new BigDecimal(countAttendance * 100)
|
||||
.divide(new BigDecimal(countUser), 1, RoundingMode.HALF_UP);
|
||||
if (totalUserCount > 0) {
|
||||
BigDecimal rate = new BigDecimal(attendanceCount * 100)
|
||||
.divide(new BigDecimal(totalUserCount), 1, RoundingMode.HALF_UP);
|
||||
todayAttendanceCountVo.setAttendanceRate(rate.doubleValue());
|
||||
} else {
|
||||
todayAttendanceCountVo.setAttendanceRate(0.0);
|
||||
}
|
||||
todayAttendanceCountVo.setAttendanceCount(Long.valueOf(countAttendance));
|
||||
todayAttendanceCountVo.setAttendanceCount(attendanceCount);
|
||||
return R.ok(todayAttendanceCountVo);
|
||||
}
|
||||
|
||||
@ -203,19 +204,19 @@ public class EnterpriseBigScreenController {
|
||||
@GetMapping("/projectAttendanceCount")
|
||||
public R<List<ProjectAttendanceCountVo>> getProjectAttendanceCount() {
|
||||
|
||||
List<BusProject> projectList = projectService.listByIds(List.of(1897160897167638529L, 1897161054676336641L));
|
||||
return R.ok(projectList.stream().map(busProject -> {
|
||||
ProjectAttendanceCountVo vo = new ProjectAttendanceCountVo();
|
||||
vo.setProjectId(busProject.getId());
|
||||
vo.setProjectName(busProject.getProjectName());
|
||||
Long projectId = busProject.getGoId();
|
||||
Integer projectUserCount = projectBigScreenMapper.getProjectUserCount(projectId);
|
||||
Integer attendanceCount = projectBigScreenMapper.getAttendanceCount(projectId, DateUtils.getDate());
|
||||
vo.setAttendanceCount(Long.valueOf(attendanceCount));
|
||||
vo.setAttendanceRate(BigDecimalUtil.toPercentage(BigDecimal.valueOf(attendanceCount), BigDecimal.valueOf(projectUserCount)).doubleValue());
|
||||
return vo;
|
||||
}).toList());
|
||||
/*ArrayList<ProjectAttendanceCountVo> projectAttendanceCountVos = new ArrayList<>();
|
||||
// List<BusProject> projectList = projectService.listByIds(List.of(1897160897167638529L, 1897161054676336641L));
|
||||
// return R.ok(projectList.stream().map(busProject -> {
|
||||
// ProjectAttendanceCountVo vo = new ProjectAttendanceCountVo();
|
||||
// vo.setProjectId(busProject.getId());
|
||||
// vo.setProjectName(busProject.getProjectName());
|
||||
// Long projectId = busProject.getGoId();
|
||||
// Integer projectUserCount = projectBigScreenMapper.getProjectUserCount(projectId);
|
||||
// Integer attendanceCount = projectBigScreenMapper.getAttendanceCount(projectId, DateUtils.getDate());
|
||||
// vo.setAttendanceCount(Long.valueOf(attendanceCount));
|
||||
// vo.setAttendanceRate(BigDecimalUtil.toPercentage(BigDecimal.valueOf(attendanceCount), BigDecimal.valueOf(projectUserCount)).doubleValue());
|
||||
// return vo;
|
||||
// }).toList());
|
||||
ArrayList<ProjectAttendanceCountVo> projectAttendanceCountVos = new ArrayList<>();
|
||||
|
||||
List<BusAttendance> list = attendanceService.list(Wrappers.<BusAttendance>lambdaQuery()
|
||||
.eq(BusAttendance::getClockDate, LocalDate.now())
|
||||
@ -257,7 +258,7 @@ public class EnterpriseBigScreenController {
|
||||
projectAttendanceCountVos.add(projectAttendanceCountVo);
|
||||
}
|
||||
|
||||
return R.ok(projectAttendanceCountVos);*/
|
||||
return R.ok(projectAttendanceCountVos);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -188,52 +188,52 @@ public class ProjectBigScreenController {
|
||||
@GetMapping("/people/{projectId}")
|
||||
public R<ProjectPeopleVo> getProjectPeople(@NotNull(message = "主键不能为空")
|
||||
@PathVariable Long projectId) {
|
||||
BusProject project = projectService.getById(projectId);
|
||||
projectId = project.getGoId();
|
||||
Integer projectUserCount = projectBigScreenMapper.getProjectUserCount(projectId);
|
||||
ProjectPeopleVo vo = new ProjectPeopleVo();
|
||||
vo.setPeopleCount(BigDecimal.valueOf(projectUserCount));
|
||||
Integer attendanceCount = projectBigScreenMapper.getAttendanceCount(projectId, DateUtils.getDate());
|
||||
vo.setAttendanceCount(BigDecimal.valueOf(attendanceCount));
|
||||
vo.setAttendanceRate(BigDecimalUtil.toPercentage(BigDecimal.valueOf(attendanceCount), BigDecimal.valueOf(projectUserCount)));
|
||||
List<BusConstructionUser> projectUserList = projectBigScreenMapper.getProjectUserList(projectId);
|
||||
List<BusProjectTeamByGo> teamList = projectBigScreenMapper.getTeamList(projectId);
|
||||
|
||||
List<ProjectTeamAttendanceVo> teamAttendanceList = new ArrayList<>();
|
||||
String punchRange = project.getPunchRange();
|
||||
String punchTime = "";
|
||||
if (punchRange != null) {
|
||||
String start = punchRange.split(",")[0];
|
||||
punchTime = LocalDate.now() + " " + start;
|
||||
}
|
||||
if (projectUserList != null && teamList != null) {
|
||||
projectUserList = projectUserList.stream().filter(user -> user.getTeamId() != null).toList();
|
||||
Map<Long, List<BusConstructionUser>> userMap = projectUserList.stream()
|
||||
.collect(Collectors.groupingBy(BusConstructionUser::getTeamId));
|
||||
for (BusProjectTeamByGo team : teamList) {
|
||||
ProjectTeamAttendanceVo vo1 = new ProjectTeamAttendanceVo();
|
||||
vo1.setId(team.getId());
|
||||
vo1.setTeamName(team.getName());
|
||||
vo1.setAttendanceTime(punchTime);
|
||||
vo1.setAttendanceNumber(BigDecimal.ZERO);
|
||||
List<BusConstructionUser> userList = userMap.get(team.getId());
|
||||
if (CollUtil.isNotEmpty(userList)) {
|
||||
List<String> list = userList.stream().map(BusConstructionUser::getOpenid).distinct().toList();
|
||||
Integer aCount = projectBigScreenMapper.getAttendanceCountByOpenIds(list, LocalDate.now());
|
||||
vo1.setAttendanceNumber(BigDecimal.valueOf(aCount));
|
||||
}
|
||||
vo1.setAllNumber(BigDecimal.valueOf(userMap.getOrDefault(team.getId(), List.of()).size()));
|
||||
if (vo1.getAttendanceNumber() != null && vo1.getAllNumber() != null && vo1.getAllNumber().compareTo(BigDecimal.ZERO) != 0) {
|
||||
vo1.setAttendanceRate(BigDecimalUtil.toPercentage(vo1.getAttendanceNumber(), vo1.getAllNumber()));
|
||||
} else {
|
||||
vo1.setAttendanceRate(BigDecimal.ZERO);
|
||||
}
|
||||
teamAttendanceList.add(vo1);
|
||||
}
|
||||
}
|
||||
vo.setTeamAttendanceList(teamAttendanceList);
|
||||
return R.ok(vo);
|
||||
// return R.ok(projectBigScreenService.getProjectPeople(projectId));
|
||||
// BusProject project = projectService.getById(projectId);
|
||||
// projectId = project.getGoId();
|
||||
// Integer projectUserCount = projectBigScreenMapper.getProjectUserCount(projectId);
|
||||
// ProjectPeopleVo vo = new ProjectPeopleVo();
|
||||
// vo.setPeopleCount(BigDecimal.valueOf(projectUserCount));
|
||||
// Integer attendanceCount = projectBigScreenMapper.getAttendanceCount(projectId, DateUtils.getDate());
|
||||
// vo.setAttendanceCount(BigDecimal.valueOf(attendanceCount));
|
||||
// vo.setAttendanceRate(BigDecimalUtil.toPercentage(BigDecimal.valueOf(attendanceCount), BigDecimal.valueOf(projectUserCount)));
|
||||
// List<BusConstructionUser> projectUserList = projectBigScreenMapper.getProjectUserList(projectId);
|
||||
// List<BusProjectTeamByGo> teamList = projectBigScreenMapper.getTeamList(projectId);
|
||||
//
|
||||
// List<ProjectTeamAttendanceVo> teamAttendanceList = new ArrayList<>();
|
||||
// String punchRange = project.getPunchRange();
|
||||
// String punchTime = "";
|
||||
// if (punchRange != null) {
|
||||
// String start = punchRange.split(",")[0];
|
||||
// punchTime = LocalDate.now() + " " + start;
|
||||
// }
|
||||
// if (projectUserList != null && teamList != null) {
|
||||
// projectUserList = projectUserList.stream().filter(user -> user.getTeamId() != null).toList();
|
||||
// Map<Long, List<BusConstructionUser>> userMap = projectUserList.stream()
|
||||
// .collect(Collectors.groupingBy(BusConstructionUser::getTeamId));
|
||||
// for (BusProjectTeamByGo team : teamList) {
|
||||
// ProjectTeamAttendanceVo vo1 = new ProjectTeamAttendanceVo();
|
||||
// vo1.setId(team.getId());
|
||||
// vo1.setTeamName(team.getName());
|
||||
// vo1.setAttendanceTime(punchTime);
|
||||
// vo1.setAttendanceNumber(BigDecimal.ZERO);
|
||||
// List<BusConstructionUser> userList = userMap.get(team.getId());
|
||||
// if (CollUtil.isNotEmpty(userList)) {
|
||||
// List<String> list = userList.stream().map(BusConstructionUser::getOpenid).distinct().toList();
|
||||
// Integer aCount = projectBigScreenMapper.getAttendanceCountByOpenIds(list, LocalDate.now());
|
||||
// vo1.setAttendanceNumber(BigDecimal.valueOf(aCount));
|
||||
// }
|
||||
// vo1.setAllNumber(BigDecimal.valueOf(userMap.getOrDefault(team.getId(), List.of()).size()));
|
||||
// if (vo1.getAttendanceNumber() != null && vo1.getAllNumber() != null && vo1.getAllNumber().compareTo(BigDecimal.ZERO) != 0) {
|
||||
// vo1.setAttendanceRate(BigDecimalUtil.toPercentage(vo1.getAttendanceNumber(), vo1.getAllNumber()));
|
||||
// } else {
|
||||
// vo1.setAttendanceRate(BigDecimal.ZERO);
|
||||
// }
|
||||
// teamAttendanceList.add(vo1);
|
||||
// }
|
||||
// }
|
||||
// vo.setTeamAttendanceList(teamAttendanceList);
|
||||
// return R.ok(vo);
|
||||
return R.ok(projectBigScreenService.getProjectPeople(projectId));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -253,18 +253,18 @@ public class ProjectBigScreenController {
|
||||
@GetMapping("/generalize/{projectId}")
|
||||
public R<String> getProjectGeneralize(@NotNull(message = "主键不能为空")
|
||||
@PathVariable Long projectId) {
|
||||
BusProject project = projectService.getById(projectId);
|
||||
if (project != null) {
|
||||
Long goId = project.getGoId();
|
||||
if (goId != null) {
|
||||
List<SysProjectIntroduce> sysProjectIntroduces = projectBigScreenMapper.selectByProjectId(goId);
|
||||
if (CollUtil.isNotEmpty(sysProjectIntroduces)) {
|
||||
return R.ok(sysProjectIntroduces.getFirst().getRichText());
|
||||
}
|
||||
}
|
||||
}
|
||||
// return R.ok(projectBigScreenService.getProjectGeneralize(projectId));
|
||||
return R.ok();
|
||||
// BusProject project = projectService.getById(projectId);
|
||||
// if (project != null) {
|
||||
// Long goId = project.getGoId();
|
||||
// if (goId != null) {
|
||||
// List<SysProjectIntroduce> sysProjectIntroduces = projectBigScreenMapper.selectByProjectId(goId);
|
||||
// if (CollUtil.isNotEmpty(sysProjectIntroduces)) {
|
||||
// return R.ok(sysProjectIntroduces.getFirst().getRichText());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
return R.ok(projectBigScreenService.getProjectGeneralize(projectId));
|
||||
// return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -354,6 +354,35 @@ public class ProjectBigScreenController {
|
||||
projectBigScreenService.setList(bo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询地图项目分类
|
||||
*/
|
||||
// @SaCheckPermission("project:bigScreen:getProjectMapList")
|
||||
@GetMapping("/getProjectMapList")
|
||||
public R<Map<String,Map<String,Map<String,String>>>> getProjectMapList() {
|
||||
return R.ok(projectService.getProjectMapList());
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 查询项目地域分散图
|
||||
*/
|
||||
// @SaCheckPermission("project:bigScreen:getProjectMapList")
|
||||
@GetMapping("/getProjectDiYv")
|
||||
public R<Map<String,Long>> getProjectDiYv() {
|
||||
return R.ok(projectService.getProjectDiYv());
|
||||
}
|
||||
|
||||
/**
|
||||
* 计划和实际容量对比
|
||||
*/
|
||||
// @SaCheckPermission("project:bigScreen:getProjectMapList")
|
||||
@GetMapping("/getProjectCapacity")
|
||||
public R<Map<String,Map<String,String>>> getProjectCapacity() {
|
||||
return R.ok(projectService.getProjectCapacity());
|
||||
}
|
||||
|
||||
|
||||
// public List<Map<String, Object>> setSxt() {
|
||||
// List<Map<String, Object>> sxtChildrenMap = new ArrayList<>();
|
||||
|
||||
@ -35,4 +35,13 @@ public class EnterpriseKeyIndexVo implements Serializable {
|
||||
* 风电项目总容量
|
||||
*/
|
||||
private BigDecimal windElectricityTotalCapacity;
|
||||
|
||||
/**
|
||||
* 业绩数量
|
||||
*/
|
||||
private Long performanceCount;
|
||||
/**
|
||||
* 典型业绩
|
||||
*/
|
||||
private Long typicalPerformance;
|
||||
}
|
||||
|
||||
@ -19,41 +19,41 @@ public interface ProjectBigScreenMapper {
|
||||
|
||||
@Select("select * from bus_corporate_events limit 10")
|
||||
List<BusCorporateEvents> getBusCorporateEvents();
|
||||
|
||||
@Select("select * from sys_project_introduce where project_id = #{projectId}")
|
||||
List<SysProjectIntroduce> selectByProjectId(@Param("projectId") Long projectId);
|
||||
|
||||
@Select("select count(*) from bus_construction_user where project_id = #{projectId} && deleted_at is NULL")
|
||||
Integer getProjectUserCount(@Param("projectId") Long projectId);
|
||||
|
||||
@Select("select count(*) from bus_construction_user where project_id in (60,59) && deleted_at is NULL")
|
||||
Integer getUserCount();
|
||||
|
||||
@Select("select count(*) from bus_attendance where project_id = #{projectId} && printing_date = #{printingDate} && commuter = '1'")
|
||||
Integer getAttendanceCount(@Param("projectId") Long projectId,
|
||||
@Param("printingDate") String printingDate);
|
||||
|
||||
@Select("SELECT * FROM sys_project_team WHERE project_id = #{projectId} && deleted_at is NULL")
|
||||
List<BusProjectTeamByGo> getTeamList(@Param("projectId") Long projectId);
|
||||
|
||||
@Select("SELECT * FROM bus_construction_user WHERE project_id = #{projectId} && deleted_at is NULL")
|
||||
List<BusConstructionUser> getProjectUserList(@Param("projectId") Long projectId);
|
||||
|
||||
@Select({
|
||||
"<script>",
|
||||
"SELECT count(*) ",
|
||||
"FROM bus_attendance ",
|
||||
"WHERE openid IN ",
|
||||
"<foreach collection='openIds' item='id' open='(' separator=',' close=')'>",
|
||||
" #{id}",
|
||||
"</foreach>",
|
||||
"AND printing_date = #{printingDate} ",
|
||||
"AND commuter = '1'",
|
||||
"</script>"
|
||||
})
|
||||
Integer getAttendanceCountByOpenIds(@Param("openIds") List<String> openIds,
|
||||
@Param("printingDate") LocalDate printingDate);
|
||||
|
||||
@Select("SELECT * FROM bus_tour WHERE project_id = #{projectId} AND deleted_at IS NULL LIMIT 10")
|
||||
List<BusTour> selectTourByProjectId(@Param("projectId") Long projectId);
|
||||
//
|
||||
// @Select("select * from sys_project_introduce where project_id = #{projectId}")
|
||||
// List<SysProjectIntroduce> selectByProjectId(@Param("projectId") Long projectId);
|
||||
//
|
||||
// @Select("select count(*) from bus_construction_user where project_id = #{projectId} && deleted_at is NULL")
|
||||
// Integer getProjectUserCount(@Param("projectId") Long projectId);
|
||||
//
|
||||
// @Select("select count(*) from bus_construction_user where project_id in (60,59) && deleted_at is NULL")
|
||||
// Integer getUserCount();
|
||||
//
|
||||
// @Select("select count(*) from bus_attendance where project_id = #{projectId} && printing_date = #{printingDate} && commuter = '1'")
|
||||
// Integer getAttendanceCount(@Param("projectId") Long projectId,
|
||||
// @Param("printingDate") String printingDate);
|
||||
//
|
||||
// @Select("SELECT * FROM sys_project_team WHERE project_id = #{projectId} && deleted_at is NULL")
|
||||
// List<BusProjectTeamByGo> getTeamList(@Param("projectId") Long projectId);
|
||||
//
|
||||
// @Select("SELECT * FROM bus_construction_user WHERE project_id = #{projectId} && deleted_at is NULL")
|
||||
// List<BusConstructionUser> getProjectUserList(@Param("projectId") Long projectId);
|
||||
//
|
||||
// @Select({
|
||||
// "<script>",
|
||||
// "SELECT count(*) ",
|
||||
// "FROM bus_attendance ",
|
||||
// "WHERE openid IN ",
|
||||
// "<foreach collection='openIds' item='id' open='(' separator=',' close=')'>",
|
||||
// " #{id}",
|
||||
// "</foreach>",
|
||||
// "AND printing_date = #{printingDate} ",
|
||||
// "AND commuter = '1'",
|
||||
// "</script>"
|
||||
// })
|
||||
// Integer getAttendanceCountByOpenIds(@Param("openIds") List<String> openIds,
|
||||
// @Param("printingDate") LocalDate printingDate);
|
||||
//
|
||||
// @Select("SELECT * FROM bus_tour WHERE project_id = #{projectId} AND deleted_at IS NULL LIMIT 10")
|
||||
// List<BusTour> selectTourByProjectId(@Param("projectId") Long projectId);
|
||||
}
|
||||
|
||||
@ -124,6 +124,8 @@ public class EnterpriseBigScreenServiceImpl implements EnterpriseBigScreenServic
|
||||
vo.setWindElectricityCount(windElectricityCount);
|
||||
vo.setPhotovoltaicTotalCapacity(photovoltaicTotalCapacity);
|
||||
vo.setWindElectricityTotalCapacity(windElectricityTotalCapacity);
|
||||
vo.setPerformanceCount(52L);
|
||||
vo.setTypicalPerformance(22L);
|
||||
return vo;
|
||||
}
|
||||
|
||||
|
||||
@ -1,12 +1,32 @@
|
||||
package org.dromara.design.controller;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.rmi.ServerException;
|
||||
import java.time.LocalDate;
|
||||
import java.time.ZoneId;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.constraints.*;
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
import org.apache.poi.ss.usermodel.CellType;
|
||||
import org.apache.poi.ss.usermodel.DateUtil;
|
||||
import org.apache.poi.ss.usermodel.Row;
|
||||
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
//import org.dromara.design.domain.DesUserExcelData;
|
||||
import org.dromara.design.domain.DesUserExcelData;
|
||||
import org.dromara.design.domain.dto.ExcelData;
|
||||
import org.dromara.design.domain.dto.desUser.DesUserBatchDto;
|
||||
import org.dromara.design.domain.dto.volumecatalog.DesVolumeCatalogCreateReq;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
||||
@ -22,6 +42,7 @@ import org.dromara.design.domain.vo.DesUserVo;
|
||||
import org.dromara.design.domain.bo.DesUserBo;
|
||||
import org.dromara.design.service.IDesUserService;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
/**
|
||||
* 设计人员
|
||||
@ -57,6 +78,51 @@ public class DesUserController extends BaseController {
|
||||
ExcelUtil.exportExcel(list, "设计人员", DesUserVo.class, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 收资清单模板导出
|
||||
*/
|
||||
@SaCheckPermission("design:user:exportExcel")
|
||||
@Log(title = "收资清单", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/exportExcel")
|
||||
public void exportExcelByProjectId(@RequestParam("deptId") Long deptId, HttpServletResponse response){
|
||||
desUserService.exportExcelByProjectId(deptId, response);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 导入卷册目录
|
||||
*/
|
||||
@SaCheckPermission("design:user:importData")
|
||||
@Log(title = "导入卷册目录", businessType = BusinessType.IMPORT)
|
||||
@PostMapping("/importData")
|
||||
public R<Void> importData(@RequestParam("file") MultipartFile file,Long projectId) throws IOException {
|
||||
if (projectId == null) {
|
||||
return R.fail("项目ID不能为空");
|
||||
}
|
||||
List<DesUserExcelData> dataList = readExcel(file);
|
||||
if (CollectionUtils.isEmpty(dataList)) {
|
||||
throw new ServerException("导入数据为空");
|
||||
}
|
||||
Collections.reverse(dataList);
|
||||
List<DesUserBo> desUserBos = new ArrayList<>();
|
||||
for (DesUserExcelData desUserBo : dataList) {
|
||||
DesUserBo userBo = new DesUserBo();
|
||||
userBo.setProjectId(projectId);
|
||||
userBo.setUserId(desUserBo.getUserId());
|
||||
userBo.setUserName(desUserBo.getUser());
|
||||
userBo.setUserType(desUserBo.getUserTypeId());
|
||||
if (!"1".equals(desUserBo.getUserTypeId())) {
|
||||
userBo.setUserMajor(desUserBo.getUserMajorId());
|
||||
}
|
||||
desUserBos.add(userBo);
|
||||
}
|
||||
DesUserBatchDto dto = new DesUserBatchDto();
|
||||
dto.setProjectId(projectId);
|
||||
dto.setList(desUserBos);
|
||||
desUserService.batchAddOrUpdate(dto);
|
||||
return toAjax(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取设计人员详细信息
|
||||
*
|
||||
@ -114,5 +180,131 @@ public class DesUserController extends BaseController {
|
||||
return toAjax(desUserService.batchAddOrUpdate(dto));
|
||||
}
|
||||
|
||||
public static List<DesUserExcelData> readExcel(MultipartFile file) throws IOException {
|
||||
List<DesUserExcelData> dataList = new ArrayList<>();
|
||||
|
||||
try (InputStream inputStream = file.getInputStream();
|
||||
XSSFWorkbook workbook = new XSSFWorkbook(inputStream)) {
|
||||
|
||||
XSSFSheet sheet = workbook.getSheetAt(0);
|
||||
|
||||
// 从第二行(index=1)开始读取数据,跳过表头
|
||||
for (int rowIndex = 1; rowIndex <= sheet.getLastRowNum(); rowIndex++) {
|
||||
Row row = sheet.getRow(rowIndex);
|
||||
if (hasValidData(row)) {
|
||||
String userMajor = getCellValue(row.getCell(0));
|
||||
String userMajorId = getCellValue(row.getCell(1));
|
||||
String user = getCellValue(row.getCell(2));
|
||||
Long userId = Long.valueOf(getCellValue(row.getCell(3)));
|
||||
String userType = getCellValue(row.getCell(4));
|
||||
String userTypeId = getCellValue(row.getCell(5));
|
||||
if (!"1".equals(userMajorId)) {
|
||||
if (user == null || user.isEmpty()){
|
||||
throw new ServerException("设计人员不能为空");
|
||||
}
|
||||
if (userType == null || userType.isEmpty()){
|
||||
throw new ServerException("人员类型不能为空");
|
||||
}
|
||||
}
|
||||
DesUserExcelData excelData = new DesUserExcelData(
|
||||
userMajor,userMajorId,user, userId, userType,
|
||||
userTypeId
|
||||
);
|
||||
dataList.add(excelData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return dataList;
|
||||
}
|
||||
private static boolean hasValidData(Row row) {
|
||||
// 遍历行中的所有单元格
|
||||
for (int cellIndex = 0; cellIndex < row.getLastCellNum(); cellIndex++) {
|
||||
Cell cell = row.getCell(cellIndex, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
|
||||
String cellValue = getCellValue(cell).trim();
|
||||
|
||||
// 只要有一个单元格有非空值,就认为是有效行
|
||||
if (!cellValue.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static String getCellValue(Cell cell) {
|
||||
if (cell == null) {
|
||||
return "";
|
||||
}
|
||||
// 使用CellType枚举判断单元格类型(POI 4.0+版本推荐方式)
|
||||
CellType cellType = cell.getCellType();
|
||||
// 对于公式单元格,获取其计算结果的类型
|
||||
if (cellType == CellType.FORMULA) {
|
||||
cellType = cell.getCachedFormulaResultType();
|
||||
}
|
||||
|
||||
switch (cellType) {
|
||||
case STRING:
|
||||
return cell.getStringCellValue().trim();
|
||||
case NUMERIC:
|
||||
if (DateUtil.isCellDateFormatted(cell)) {
|
||||
Date date = cell.getDateCellValue();
|
||||
return date.toString();
|
||||
} else {
|
||||
// 处理数字类型,避免科学计数法
|
||||
return String.valueOf((long) cell.getNumericCellValue());
|
||||
}
|
||||
case BOOLEAN:
|
||||
return String.valueOf(cell.getBooleanCellValue());
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
private static LocalDate getLocalDateValue(Cell cell) {
|
||||
if (cell == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
CellType cellType = cell.getCellType();
|
||||
if (cellType == CellType.FORMULA) {
|
||||
cellType = cell.getCachedFormulaResultType();
|
||||
}
|
||||
|
||||
try {
|
||||
if (cellType == CellType.NUMERIC) {
|
||||
if (DateUtil.isCellDateFormatted(cell)) {
|
||||
Date date = cell.getDateCellValue();
|
||||
return date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
|
||||
} else {
|
||||
// 如果是数字但不是日期,就尝试转为 LocalDate (例如 20250730)
|
||||
double numericValue = cell.getNumericCellValue();
|
||||
String text = String.valueOf((long) numericValue);
|
||||
return LocalDate.parse(text);
|
||||
}
|
||||
} else if (cellType == CellType.STRING) {
|
||||
String text = cell.getStringCellValue().trim();
|
||||
if (text.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
// 尝试解析不同格式
|
||||
try {
|
||||
return LocalDate.parse(text); // 默认 ISO 格式 yyyy-MM-dd
|
||||
} catch (Exception e) {
|
||||
// 如果 Excel 是 yyyy/MM/dd 或 yyyy.MM.dd,可以额外处理
|
||||
try {
|
||||
return LocalDate.parse(text, java.time.format.DateTimeFormatter.ofPattern("yyyy/MM/dd"));
|
||||
} catch (Exception ignored) {}
|
||||
try {
|
||||
return LocalDate.parse(text, java.time.format.DateTimeFormatter.ofPattern("yyyy.MM.dd"));
|
||||
} catch (Exception ignored) {}
|
||||
return null; // 不识别的格式就返回 null
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,30 @@
|
||||
package org.dromara.design.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
/**
|
||||
* @Author 铁憨憨
|
||||
* @Date 2025/8/12 22:53
|
||||
* @Version 1.0
|
||||
*/
|
||||
@Data
|
||||
public class DesUserExcelData {
|
||||
private String userMajor;
|
||||
private String userMajorId;
|
||||
private String user;
|
||||
private Long userId;
|
||||
private String userType;
|
||||
private String userTypeId;
|
||||
|
||||
// 构造函数
|
||||
public DesUserExcelData(String userMajor, String userMajorId, String user, Long userId, String userType, String userTypeId) {
|
||||
this.userMajor = userMajor;
|
||||
this.userMajorId = userMajorId;
|
||||
this.user = user;
|
||||
this.userId = userId;
|
||||
this.userType = userType;
|
||||
this.userTypeId = userTypeId;
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,6 @@
|
||||
package org.dromara.design.service;
|
||||
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import org.dromara.design.domain.dto.desUser.DesUserBatchDto;
|
||||
import org.dromara.design.domain.vo.DesUserVo;
|
||||
@ -96,4 +97,6 @@ public interface IDesUserService extends IService<DesUser>{
|
||||
Map<String, String> getUserList(DesUserBo desUserBo);
|
||||
|
||||
Long getCount(String principal, String specialty, Long projectId);
|
||||
|
||||
void exportExcelByProjectId(Long deptId, HttpServletResponse response);
|
||||
}
|
||||
|
||||
@ -1,6 +1,11 @@
|
||||
package org.dromara.design.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.apache.poi.ss.util.CellRangeAddressList;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.dromara.common.core.exception.ServiceException;
|
||||
import org.dromara.common.core.utils.MapstructUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
@ -10,8 +15,11 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.design.domain.dto.desUser.DesUserBatchDto;
|
||||
import org.dromara.system.domain.bo.SysUserBo;
|
||||
import org.dromara.system.domain.vo.SysDictDataVo;
|
||||
import org.dromara.system.domain.vo.SysUserVo;
|
||||
import org.dromara.system.service.ISysDictDataService;
|
||||
import org.dromara.system.service.ISysUserService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.dromara.design.domain.bo.DesUserBo;
|
||||
import org.dromara.design.domain.vo.DesUserVo;
|
||||
@ -19,6 +27,9 @@ import org.dromara.design.domain.DesUser;
|
||||
import org.dromara.design.mapper.DesUserMapper;
|
||||
import org.dromara.design.service.IDesUserService;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -36,6 +47,8 @@ public class DesUserServiceImpl extends ServiceImpl<DesUserMapper, DesUser> impl
|
||||
|
||||
private final ISysDictDataService sysDictDataService;
|
||||
|
||||
private final ISysUserService sysUserService;
|
||||
|
||||
/**
|
||||
* 查询设计人员
|
||||
*
|
||||
@ -186,4 +199,242 @@ public class DesUserServiceImpl extends ServiceImpl<DesUserMapper, DesUser> impl
|
||||
.eq(DesUser::getUserId, Long.valueOf(principal))
|
||||
.eq(DesUser::getUserMajor, specialty));
|
||||
}
|
||||
|
||||
public Map<String, String> getSysUserList(SysUserBo sysUserBo) {
|
||||
List<SysUserVo> sysUserVos = sysUserService.selectUserListByDeptByType(sysUserBo);
|
||||
Map<String, String> map = new HashMap<>();
|
||||
for (SysUserVo sysUserVo : sysUserVos) {
|
||||
map.put(sysUserVo.getUserId().toString(), sysUserVo.getNickName());
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exportExcelByProjectId(Long deptId, HttpServletResponse response) {
|
||||
SysUserBo sysUserBo = new SysUserBo();
|
||||
sysUserBo.setDeptId(deptId);
|
||||
sysUserBo.setUserType("sys_user");
|
||||
List<SysDictDataVo> list = sysDictDataService.selectByDictType("des_user_major");
|
||||
List<SysDictDataVo> typeList = sysDictDataService.selectByDictType("des_user_type");
|
||||
Map<String, String> uniqueMajors = list.stream().filter(Objects::nonNull).collect(Collectors
|
||||
.toMap(SysDictDataVo::getDictValue, SysDictDataVo::getDictLabel, (existing, existing1) -> existing));
|
||||
if (uniqueMajors.isEmpty()) {
|
||||
throw new ServiceException("请完成专业配置!!");
|
||||
}
|
||||
Map<String, String> userTypeMap = typeList.stream().filter(Objects::nonNull).collect(Collectors
|
||||
.toMap(SysDictDataVo::getDictValue, SysDictDataVo::getDictLabel, (existing, existing1) -> existing));
|
||||
if (userTypeMap.isEmpty()) {
|
||||
throw new ServiceException("请联系管理员设置设计人员类型!!");
|
||||
}
|
||||
Map<String, String> userList = getSysUserList(sysUserBo);
|
||||
if (userList == null || userList.isEmpty()) {
|
||||
throw new ServiceException("找不到人员!");
|
||||
}
|
||||
|
||||
Workbook workbook = new XSSFWorkbook();
|
||||
// 创建主 Sheet 和隐藏 Sheet
|
||||
Sheet mainSheet = workbook.createSheet("设计人员配置模板");
|
||||
Sheet dataSheet = workbook.createSheet("DropdownData");
|
||||
workbook.setSheetHidden(workbook.getSheetIndex(dataSheet), true);
|
||||
|
||||
// 3. 创建单元格样式
|
||||
|
||||
CellStyle editableStyle = createEditableCellStyle(workbook); // 可编辑单元格样式
|
||||
CellStyle protectedStyle = createProtectedCellStyle(workbook); // 受保护单元格样式(ID列用
|
||||
|
||||
//填充隐藏数据Sheet
|
||||
int rowIndex = 0;
|
||||
|
||||
// 填充专业和专业ID(A列和B列)
|
||||
for (Map.Entry<String, String> entry : uniqueMajors.entrySet()) {
|
||||
Row row = dataSheet.createRow(rowIndex++);
|
||||
row.createCell(0).setCellValue(entry.getValue()); // A列:专业ID
|
||||
row.createCell(1).setCellValue(entry.getKey()); // B列:专业名称
|
||||
}
|
||||
|
||||
// 重置行索引,填充人员和人员ID(C列和D列)
|
||||
rowIndex = 0;
|
||||
for (Map.Entry<String, String> entry : userList.entrySet()) {
|
||||
Row row = dataSheet.getRow(rowIndex);
|
||||
if (row == null) {
|
||||
row = dataSheet.createRow(rowIndex);
|
||||
}
|
||||
row.createCell(2).setCellValue(entry.getValue()); // C列:人员ID
|
||||
row.createCell(3).setCellValue(entry.getKey()); // D列:人员名称
|
||||
rowIndex++;
|
||||
}
|
||||
rowIndex = 0;
|
||||
// 填充专业和专业ID(A列和B列)
|
||||
for (Map.Entry<String, String> entry : userTypeMap.entrySet()) {
|
||||
Row row = dataSheet.getRow(rowIndex);
|
||||
if (row == null) {
|
||||
row = dataSheet.createRow(rowIndex);
|
||||
}
|
||||
row.createCell(4).setCellValue(entry.getValue()); // A列:专业ID
|
||||
row.createCell(5).setCellValue(entry.getKey()); // B列:专业名称
|
||||
rowIndex++;
|
||||
}
|
||||
|
||||
// 主 Sheet 设置表头
|
||||
Row sheetRow = mainSheet.createRow(0);
|
||||
String[] headers = {"专业", "专业编码",
|
||||
"设计人员", "设计人员编码", "人员类型", "人员人员编码"};
|
||||
for (int i = 0; i < headers.length; i++) {
|
||||
Cell cell = sheetRow.createCell(i);
|
||||
cell.setCellValue(headers[i]);
|
||||
}
|
||||
|
||||
// 6. 设置专业下拉列表(第二列)
|
||||
setMajorDropdown(mainSheet, uniqueMajors.size());
|
||||
|
||||
// 8. 设置人员下拉列表(第四列)
|
||||
setPersonDropdown(mainSheet, userList.size());
|
||||
|
||||
setTypeDropdown(mainSheet, typeList.size());
|
||||
|
||||
|
||||
String formulaTemplate = "IFERROR(INDEX(DropdownData!$B$1:$B$" + uniqueMajors.size() + ", MATCH(A{rowNum}, DropdownData!$A$1:$A$" + uniqueMajors.size() + ", 0)),\"\")";
|
||||
|
||||
String formulaTemplate1 = "IFERROR(INDEX(DropdownData!$D$1:$D$" + userList.size() + ", MATCH(C{rowNum}, DropdownData!$C$1:$C$" + userList.size() + ", 0)),\"\")";
|
||||
String formulaTemplate2 = "IFERROR(INDEX(DropdownData!$F$1:$F$" + userTypeMap.size() + ", MATCH(E{rowNum}, DropdownData!$E$1:$E$" + userTypeMap.size() + ", 0)),\"\")";
|
||||
|
||||
|
||||
for (int i = 1; i <= 100; i++) { // 从第2行到101行
|
||||
Row row = mainSheet.createRow(i);
|
||||
int currentRowNum = i + 1; // Excel行号从1开始
|
||||
String formula = formulaTemplate.replace("{rowNum}", String.valueOf(currentRowNum));
|
||||
|
||||
Cell cell = row.createCell(0);
|
||||
cell.setCellStyle(editableStyle); //专业不锁定
|
||||
|
||||
Cell idCell = row.createCell(1);
|
||||
idCell.setCellFormula(formula);
|
||||
idCell.setCellStyle(protectedStyle); // 应用隐藏公式样式
|
||||
|
||||
String formula1 = formulaTemplate1.replace("{rowNum}", String.valueOf(currentRowNum));
|
||||
|
||||
Cell cell2 = row.createCell(2);
|
||||
cell2.setCellStyle(editableStyle);
|
||||
|
||||
Cell idCell2 = row.createCell(3);
|
||||
idCell2.setCellFormula(formula1);
|
||||
idCell2.setCellStyle(protectedStyle);
|
||||
|
||||
String formula2 = formulaTemplate2.replace("{rowNum}", String.valueOf(currentRowNum));
|
||||
|
||||
Cell cell3 = row.createCell(4);
|
||||
cell3.setCellStyle(editableStyle);
|
||||
|
||||
Cell idCell3 = row.createCell(5);
|
||||
idCell3.setCellFormula(formula2);
|
||||
idCell3.setCellStyle(protectedStyle);
|
||||
|
||||
}
|
||||
|
||||
|
||||
// 保护工作表,仅允许编辑未锁定的单元格
|
||||
mainSheet.protectSheet("123456"); // 空密码
|
||||
|
||||
// 核心:锁定表头(第1行)和前1列(包含ID列)
|
||||
mainSheet.createFreezePane(0, 1, 0, 1);
|
||||
|
||||
|
||||
// 调整列宽
|
||||
mainSheet.setColumnWidth(0, 20 * 200);
|
||||
mainSheet.setColumnWidth(1, 20 * 300);
|
||||
mainSheet.setColumnWidth(2, 20 * 200);
|
||||
mainSheet.setColumnWidth(3, 20 * 300);
|
||||
mainSheet.setColumnWidth(4, 20 * 200);
|
||||
mainSheet.setColumnWidth(5, 20 * 300);
|
||||
// 2. 设置响应头
|
||||
// 设置响应头,指定Excel格式和下载文件名
|
||||
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
||||
response.setCharacterEncoding("utf-8");
|
||||
response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode("设计人员配置模板.xlsx", StandardCharsets.UTF_8));
|
||||
// 直接写入响应输出流
|
||||
try {
|
||||
workbook.write(response.getOutputStream());
|
||||
workbook.close();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建可编辑单元格样式
|
||||
*/
|
||||
private CellStyle createEditableCellStyle(Workbook workbook) {
|
||||
CellStyle style = workbook.createCellStyle();
|
||||
style.setLocked(false); // 关键:允许编辑
|
||||
return style;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建受保护单元格样式(用于ID列)
|
||||
*/
|
||||
private CellStyle createProtectedCellStyle(Workbook workbook) {
|
||||
CellStyle style = workbook.createCellStyle();
|
||||
DataFormat dataFormat = workbook.createDataFormat();
|
||||
short formatIndex = dataFormat.getFormat("0"); // 匹配“自定义→0”格式
|
||||
style.setDataFormat(formatIndex);
|
||||
style.setHidden(true); // 隐藏公式
|
||||
style.setLocked(true);
|
||||
return style;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置专业下拉列表(第二列,索引1)
|
||||
*/
|
||||
private void setMajorDropdown(Sheet mainSheet, int majorCount) {
|
||||
DataValidationHelper helper = mainSheet.getDataValidationHelper();
|
||||
|
||||
// 专业数据范围:数据Sheet的A列(从第1行到专业数量行)
|
||||
String majorRange = "DropdownData!$A$1:$A$" + majorCount;
|
||||
|
||||
DataValidationConstraint constraint = helper.createFormulaListConstraint(majorRange);
|
||||
// 作用范围:第2行到100行,第二列
|
||||
CellRangeAddressList addressList = new CellRangeAddressList(1, 100, 0, 0);
|
||||
|
||||
DataValidation validation = helper.createValidation(constraint, addressList);
|
||||
validation.setShowErrorBox(true);
|
||||
mainSheet.addValidationData(validation);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置人员下拉列表(第四列,索引3)
|
||||
*/
|
||||
private void setPersonDropdown(Sheet mainSheet, int personCount) {
|
||||
DataValidationHelper helper = mainSheet.getDataValidationHelper();
|
||||
|
||||
// 人员数据范围:数据Sheet的C列(从第1行到人员数量行)
|
||||
String personRange = "DropdownData!$C$1:$C$" + personCount;
|
||||
|
||||
DataValidationConstraint constraint = helper.createFormulaListConstraint(personRange);
|
||||
// 作用范围:第2行到100行,第四列
|
||||
CellRangeAddressList addressList = new CellRangeAddressList(1, 100, 2, 2);
|
||||
|
||||
DataValidation validation = helper.createValidation(constraint, addressList);
|
||||
validation.setShowErrorBox(true);
|
||||
mainSheet.addValidationData(validation);
|
||||
|
||||
}
|
||||
/**
|
||||
* 设置人员下拉列表(第四列,索引3)
|
||||
*/
|
||||
private void setTypeDropdown(Sheet mainSheet, int personCount) {
|
||||
DataValidationHelper helper = mainSheet.getDataValidationHelper();
|
||||
|
||||
// 人员数据范围:数据Sheet的C列(从第1行到人员数量行)
|
||||
String personRange = "DropdownData!$E$1:$E$" + personCount;
|
||||
|
||||
DataValidationConstraint constraint = helper.createFormulaListConstraint(personRange);
|
||||
// 作用范围:第2行到100行,第四列
|
||||
CellRangeAddressList addressList = new CellRangeAddressList(1, 100, 4, 4);
|
||||
|
||||
DataValidation validation = helper.createValidation(constraint, addressList);
|
||||
validation.setShowErrorBox(true);
|
||||
mainSheet.addValidationData(validation);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -438,11 +438,11 @@ public class DesVolumeCatalogServiceImpl extends ServiceImpl<DesVolumeCatalogMap
|
||||
desUserBo.setProjectId(projectId);
|
||||
Map<String, String> uniqueMajors = desUserService.getUserMajor(desUserBo);
|
||||
if (uniqueMajors == null || uniqueMajors.isEmpty()) {
|
||||
throw new ServiceException("请完成专业配置!!",502);
|
||||
throw new ServiceException("请完成专业配置!!");
|
||||
}
|
||||
Map<String, String> userList = desUserService.getUserList(desUserBo);
|
||||
if (userList == null || userList.isEmpty()) {
|
||||
throw new ServiceException("请完成人员任命!",502);
|
||||
throw new ServiceException("请完成人员任命!");
|
||||
}
|
||||
|
||||
Workbook workbook = new XSSFWorkbook();
|
||||
|
||||
@ -161,4 +161,9 @@ public class BusProject extends BaseEntity {
|
||||
*/
|
||||
private Long goId;
|
||||
|
||||
/**
|
||||
* 省份
|
||||
*/
|
||||
private String province;
|
||||
|
||||
}
|
||||
|
||||
@ -124,4 +124,9 @@ public class BusProjectCreateReq implements Serializable {
|
||||
* 显示隐藏(0显示 1隐藏)
|
||||
*/
|
||||
private String showHidden;
|
||||
|
||||
/**
|
||||
* 省份
|
||||
*/
|
||||
private String province;
|
||||
}
|
||||
|
||||
@ -201,4 +201,11 @@ public class BusProjectVo implements Serializable {
|
||||
*/
|
||||
private Long goId;
|
||||
|
||||
/**
|
||||
* 省份
|
||||
*/
|
||||
private String province;
|
||||
|
||||
private Long count;
|
||||
|
||||
}
|
||||
|
||||
@ -4,6 +4,9 @@ import org.dromara.project.domain.BusProject;
|
||||
import org.dromara.project.domain.vo.project.BusProjectVo;
|
||||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 项目Mapper接口
|
||||
*
|
||||
@ -12,4 +15,6 @@ import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
*/
|
||||
public interface BusProjectMapper extends BaseMapperPlus<BusProject, BusProjectVo> {
|
||||
|
||||
List<BusProjectVo> getProjectDiYv();
|
||||
|
||||
}
|
||||
|
||||
@ -218,4 +218,23 @@ public interface IBusProjectService extends IService<BusProject> {
|
||||
BusProjectVo selectById(Long projectId);
|
||||
|
||||
List<BusProjectVo> selectProjectVoList();
|
||||
|
||||
/**
|
||||
*查询地图项目分类
|
||||
* @return
|
||||
*/
|
||||
Map<String, Map<String, Map<String, String>>> getProjectMapList();
|
||||
|
||||
/**
|
||||
* 查询项目地域分散图
|
||||
* @return
|
||||
*/
|
||||
Map<String, Long> getProjectDiYv();
|
||||
|
||||
/**
|
||||
* 计划和实际容量对比
|
||||
* @return
|
||||
*/
|
||||
Map<String, Map<String, String>> getProjectCapacity();
|
||||
|
||||
}
|
||||
|
||||
@ -51,6 +51,8 @@ import org.dromara.project.mapper.BusProjectMapper;
|
||||
import org.dromara.project.service.*;
|
||||
import org.dromara.quality.service.IQltKnowledgeDocumentService;
|
||||
import org.dromara.safety.service.IHseKnowledgeDocumentService;
|
||||
import org.dromara.system.domain.vo.SysDictDataVo;
|
||||
import org.dromara.system.service.ISysDictDataService;
|
||||
import org.dromara.workflow.service.IFlwDefinitionService;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
@ -136,6 +138,9 @@ public class BusProjectServiceImpl extends ServiceImpl<BusProjectMapper, BusProj
|
||||
@Resource
|
||||
private IBusProjectTeamService projectTeamService;
|
||||
|
||||
@Resource
|
||||
private ISysDictDataService dictDataService;
|
||||
|
||||
private final Cache<String, String> WEATHER_CACHE =
|
||||
Caffeine.newBuilder().initialCapacity(1024)
|
||||
.maximumSize(10000L)
|
||||
@ -1113,6 +1118,68 @@ public class BusProjectServiceImpl extends ServiceImpl<BusProjectMapper, BusProj
|
||||
return baseMapper.selectVoList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Map<String, Map<String, String>>> getProjectMapList() {
|
||||
//获取项目类型列表
|
||||
List<SysDictDataVo> projectTypes = dictDataService.selectByDictType("project_type");
|
||||
if (projectTypes == null || projectTypes.isEmpty()) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
//获取项目列表
|
||||
List<BusProjectVo> projectVos = baseMapper.selectVoList(new LambdaQueryWrapper<BusProject>().eq(BusProject::getPId,0).eq(BusProject::getIsDelete,0));
|
||||
if (projectVos == null || projectVos.isEmpty()) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
Map<String, Map<String, Map<String, String>>> map = new HashMap<>();
|
||||
for (SysDictDataVo projectType : projectTypes) {
|
||||
Map<String, Map<String, String>> map1 = new HashMap<>();
|
||||
//获取迭代器
|
||||
Iterator<BusProjectVo> iterator = projectVos.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
//指向下一个元素
|
||||
BusProjectVo project = iterator.next();
|
||||
if (projectType.getDictValue().equals(project.getProjectType())) {
|
||||
Map<String, String> map2 = new HashMap<>();
|
||||
map2.put("lng",project.getLng());
|
||||
map2.put("lat",project.getLat());
|
||||
map2.put("projectId",project.getId().toString());
|
||||
map1.put(project.getProjectName(),map2);
|
||||
//当满足条件时删除该元素
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
map.put(projectType.getDictLabel(),map1);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Long> getProjectDiYv() {
|
||||
List<BusProjectVo> projectVos = baseMapper.getProjectDiYv();
|
||||
Map<String, Long> map = new HashMap<>();
|
||||
for (BusProjectVo vo : projectVos) {
|
||||
map.put(StringUtils.isNotBlank(vo.getProvince())?vo.getProvince():"未知地区",vo.getCount());
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Map<String, String>> getProjectCapacity() {
|
||||
//获取项目列表
|
||||
List<BusProjectVo> projectVos = baseMapper.selectVoList(new LambdaQueryWrapper<BusProject>().eq(BusProject::getPId,0).eq(BusProject::getIsDelete,0));
|
||||
if (projectVos == null || projectVos.isEmpty()) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
Map<String, Map<String, String>> map = new HashMap<>();
|
||||
for (BusProjectVo project : projectVos) {
|
||||
Map<String, String> map2 = new HashMap<>();
|
||||
map2.put("actual",project.getActual());
|
||||
map2.put("plan",project.getPlan());
|
||||
map.put(project.getProjectName(),map2);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造分项工程树
|
||||
*/
|
||||
|
||||
@ -123,5 +123,14 @@ public interface SysUserMapper extends BaseMapperPlus<SysUser, SysUserVo> {
|
||||
List<Long> thisAlldepIds(@Param("depId") Long deptId);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 查询用户列表
|
||||
* @param sysUserWrapper
|
||||
* @return
|
||||
*/
|
||||
@DataPermission({
|
||||
@DataColumn(key = "deptName", value = "u.dept_id"),
|
||||
@DataColumn(key = "userName", value = "u.user_id")
|
||||
})
|
||||
List<SysUserVo> selectVoListByDept(@Param(Constants.WRAPPER) Wrapper<SysUser> sysUserWrapper);
|
||||
}
|
||||
|
||||
@ -73,5 +73,5 @@ public interface ISysDictDataService {
|
||||
*/
|
||||
boolean checkDictDataUnique(SysDictDataBo dict);
|
||||
|
||||
List<SysDictDataVo> selectByDictType(String desUserMajor);
|
||||
List<SysDictDataVo> selectByDictType(String dictType);
|
||||
}
|
||||
|
||||
@ -264,4 +264,6 @@ public interface ISysUserService {
|
||||
Long save(SysUser sysUser);
|
||||
|
||||
Boolean updateAppUserType(Long userId,String appUserType);
|
||||
|
||||
List<SysUserVo> selectUserListByDeptByType(SysUserBo sysUserBo);
|
||||
}
|
||||
|
||||
@ -155,8 +155,8 @@ public class SysDictDataServiceImpl implements ISysDictDataService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysDictDataVo> selectByDictType(String desUserMajor) {
|
||||
return baseMapper.selectVoList(new LambdaQueryWrapper<SysDictData>().eq(SysDictData::getDictType, desUserMajor));
|
||||
public List<SysDictDataVo> selectByDictType(String dictType) {
|
||||
return baseMapper.selectVoList(new LambdaQueryWrapper<SysDictData>().eq(SysDictData::getDictType, dictType));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -837,6 +837,11 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
||||
.eq(SysUser::getUserId, userId)) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysUserVo> selectUserListByDeptByType(SysUserBo sysUserBo) {
|
||||
return baseMapper.selectVoListByDept(this.buildQueryWrapper(sysUserBo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过用户ID查询用户账户
|
||||
*
|
||||
|
||||
@ -4,4 +4,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.dromara.project.mapper.BusProjectMapper">
|
||||
|
||||
<select id="getProjectDiYv" resultType="org.dromara.project.domain.vo.project.BusProjectVo">
|
||||
SELECT
|
||||
province,
|
||||
COUNT(*) AS count
|
||||
FROM
|
||||
bus_project
|
||||
GROUP BY
|
||||
province
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@ -109,6 +109,18 @@
|
||||
WHERE is_show = '1'
|
||||
ORDER BY level, order_num;
|
||||
</select>
|
||||
<select id="selectVoListByDept" resultType="org.dromara.system.domain.vo.SysUserVo">
|
||||
select
|
||||
<if test="ew.getSqlSelect != null">
|
||||
${ew.getSqlSelect}
|
||||
</if>
|
||||
<if test="ew.getSqlSelect == null">
|
||||
u.user_id, u.dept_id, u.nick_name, u.user_name, u.email, u.avatar, u.phonenumber, u.sex,
|
||||
u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark,u.app_user_type
|
||||
</if>
|
||||
from sys_user u
|
||||
${ew.getCustomSqlSegment}
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user