项目大屏进度数据统计,修改ai工单逻辑
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
package org.dromara.test;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
@ -7,6 +8,7 @@ import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.contractor.domain.SubConstructionUser;
|
||||
import org.dromara.contractor.service.ISubConstructionUserService;
|
||||
import org.dromara.contractor.service.ISubUserSalaryDetailService;
|
||||
import org.dromara.design.service.IDesTechnicalStandardService;
|
||||
import org.dromara.facility.domain.FacMatrix;
|
||||
import org.dromara.facility.service.IFacMatrixService;
|
||||
@ -20,6 +22,7 @@ import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@ -57,6 +60,9 @@ public class DemoTest {
|
||||
@Resource
|
||||
private ISubConstructionUserService constructionUserService;
|
||||
|
||||
@Resource
|
||||
private ISubUserSalaryDetailService userSalaryDetailService;
|
||||
|
||||
@Test
|
||||
void test() {
|
||||
Boolean result = photovoltaicPanelPartsService
|
||||
@ -120,4 +126,18 @@ public class DemoTest {
|
||||
constructionUserService.update(constructionUserLuw);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSalary() {
|
||||
List<SubConstructionUser> list = constructionUserService.lambdaQuery()
|
||||
.eq(SubConstructionUser::getProjectId, 1897160897167638529L)
|
||||
.list();
|
||||
if (CollUtil.isNotEmpty(list)) {
|
||||
for (SubConstructionUser user : list) {
|
||||
for (int i = 1; i < 7; i++) {
|
||||
userSalaryDetailService.insertByAttendance(user.getSysUserId(), LocalDate.now().minusDays(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,8 +1,6 @@
|
||||
package org.dromara.bigscreen.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.dromara.bigscreen.domain.vo.ProjectImageProgressVo;
|
||||
import org.dromara.bigscreen.domain.vo.ProjectPeopleVo;
|
||||
@ -14,6 +12,9 @@ import org.dromara.common.core.exception.ServiceException;
|
||||
import org.dromara.common.utils.BigDecimalUtil;
|
||||
import org.dromara.contractor.domain.SubConstructionUser;
|
||||
import org.dromara.contractor.service.ISubConstructionUserService;
|
||||
import org.dromara.progress.domain.PgsProgressCategory;
|
||||
import org.dromara.progress.domain.enums.PgsProgressUnitTypeEnum;
|
||||
import org.dromara.progress.service.IPgsProgressCategoryService;
|
||||
import org.dromara.project.domain.BusProject;
|
||||
import org.dromara.project.domain.BusProjectTeam;
|
||||
import org.dromara.project.domain.BusProjectTeamMember;
|
||||
@ -27,6 +28,7 @@ import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@ -62,6 +64,9 @@ public class ProjectBigScreenServiceImpl implements ProjectBigScreenService {
|
||||
@Resource
|
||||
private IBusProjectTeamMemberService projectTeamMemberService;
|
||||
|
||||
@Resource
|
||||
private IPgsProgressCategoryService progressCategoryService;
|
||||
|
||||
/**
|
||||
* 获取项目天气
|
||||
*
|
||||
@ -203,50 +208,87 @@ public class ProjectBigScreenServiceImpl implements ProjectBigScreenService {
|
||||
@Override
|
||||
public ProjectImageProgressVo getProjectImageProgress(Long projectId) {
|
||||
checkProject(projectId);
|
||||
// 生成 0 ~ 100 的随机 double
|
||||
double random = RandomUtil.randomDouble(0, 100);
|
||||
|
||||
// 保留两位小数(四舍五入)
|
||||
double result = NumberUtil.round(random, 2).doubleValue();
|
||||
ProjectImageProgressVo vo = new ProjectImageProgressVo();
|
||||
vo.setAreaPercentage(BigDecimal.valueOf(result));
|
||||
// 生成 0 ~ 100 的随机 double
|
||||
double random1 = RandomUtil.randomDouble(0, 100);
|
||||
|
||||
// 保留两位小数(四舍五入)
|
||||
double result1 = NumberUtil.round(random1, 2).doubleValue();
|
||||
vo.setRoadPercentage(BigDecimal.valueOf(result1));
|
||||
// 生成 0 ~ 100 的随机 double
|
||||
double random2 = RandomUtil.randomDouble(0, 100);
|
||||
|
||||
// 保留两位小数(四舍五入)
|
||||
double result2 = NumberUtil.round(random2, 2).doubleValue();
|
||||
vo.setCollectorLinePercentage(BigDecimal.valueOf(result2));
|
||||
// 生成 0 ~ 100 的随机 double
|
||||
double random3 = RandomUtil.randomDouble(0, 100);
|
||||
|
||||
// 保留两位小数(四舍五入)
|
||||
double result3 = NumberUtil.round(random3, 2).doubleValue();
|
||||
vo.setExportLinePercentage(BigDecimal.valueOf(result3));
|
||||
// 生成 0 ~ 100 的随机 double
|
||||
double random4 = RandomUtil.randomDouble(0, 100);
|
||||
|
||||
// 保留两位小数(四舍五入)
|
||||
double result4 = NumberUtil.round(random4, 2).doubleValue();
|
||||
vo.setSubstationPercentage(BigDecimal.valueOf(result4));
|
||||
// 生成 0 ~ 100 的随机 double
|
||||
double random5 = RandomUtil.randomDouble(0, 100);
|
||||
|
||||
// 保留两位小数(四舍五入)
|
||||
double result5 = NumberUtil.round(random5, 2).doubleValue();
|
||||
vo.setBoxTransformerPercentage(BigDecimal.valueOf(result5));
|
||||
|
||||
// 生成 0 ~ 100 的随机 double
|
||||
double random6 = RandomUtil.randomDouble(0, 100);
|
||||
|
||||
// 保留两位小数(四舍五入)
|
||||
double result6 = NumberUtil.round(random6, 2).doubleValue();
|
||||
vo.setTotalPercentage(BigDecimal.valueOf(result6));
|
||||
// 获取所有子项目列表
|
||||
List<BusProject> subProjectList = projectService.lambdaQuery()
|
||||
.eq(BusProject::getPId, projectId)
|
||||
.list();
|
||||
if (CollUtil.isEmpty(subProjectList)) {
|
||||
return vo;
|
||||
}
|
||||
// 子项目id列表
|
||||
List<Long> subProjectIds = subProjectList.stream().map(BusProject::getId).toList();
|
||||
// 计算集电线路
|
||||
vo.setCollectorLinePercentage(BigDecimal.ZERO);
|
||||
// 计算送出线路
|
||||
vo.setExportLinePercentage(BigDecimal.ZERO);
|
||||
// 计算升压站
|
||||
vo.setSubstationPercentage(BigDecimal.ZERO);
|
||||
// 计算光伏场区
|
||||
vo.setAreaPercentage(BigDecimal.ZERO);
|
||||
// 计算道路
|
||||
vo.setRoadPercentage(BigDecimal.ZERO);
|
||||
// 计算箱变
|
||||
vo.setBoxTransformerPercentage(BigDecimal.ZERO);
|
||||
// 获取集电线路、送出线路、升压站数据
|
||||
List<PgsProgressCategory> progressCategoryList = progressCategoryService.lambdaQuery()
|
||||
.in(PgsProgressCategory::getProjectId, subProjectIds)
|
||||
.in(PgsProgressCategory::getName, "集电线路", "送出线路", "升压站", "光伏场区")
|
||||
.eq(PgsProgressCategory::getParentId, 0L)
|
||||
.list();
|
||||
if (CollUtil.isNotEmpty(progressCategoryList)) {
|
||||
List<Long> categoryIds = progressCategoryList.stream().map(PgsProgressCategory::getId).distinct().toList();
|
||||
List<PgsProgressCategory> leafNodesByTopIds = progressCategoryService.getLeafNodesByTopIds(categoryIds);
|
||||
Map<String, List<PgsProgressCategory>> categoryMap = leafNodesByTopIds.stream()
|
||||
.collect(Collectors.groupingBy(PgsProgressCategory::getName));
|
||||
// 计算集电线路
|
||||
if (categoryMap.containsKey("集电线路")) {
|
||||
List<PgsProgressCategory> categoryList = categoryMap.get("集电线路");
|
||||
vo.setCollectorLinePercentage(getCompletedPercentage(categoryList));
|
||||
}
|
||||
// 计算送出线路
|
||||
if (categoryMap.containsKey("送出线路")) {
|
||||
List<PgsProgressCategory> categoryList = categoryMap.get("送出线路");
|
||||
vo.setExportLinePercentage(getCompletedPercentage(categoryList));
|
||||
}
|
||||
// 计算升压站
|
||||
if (categoryMap.containsKey("升压站")) {
|
||||
List<PgsProgressCategory> categoryList = categoryMap.get("升压站");
|
||||
vo.setSubstationPercentage(getCompletedPercentage(categoryList));
|
||||
}
|
||||
// 计算光伏场区
|
||||
if (categoryMap.containsKey("光伏场区")) {
|
||||
List<PgsProgressCategory> categoryList = categoryMap.get("光伏场区");
|
||||
vo.setAreaPercentage(getCompletedPercentage(categoryList));
|
||||
}
|
||||
}
|
||||
// 计算道路
|
||||
List<PgsProgressCategory> roadCategoryList = progressCategoryService.lambdaQuery()
|
||||
.in(PgsProgressCategory::getProjectId, subProjectIds)
|
||||
.like(PgsProgressCategory::getName, "道路")
|
||||
.ne(PgsProgressCategory::getUnitType, PgsProgressUnitTypeEnum.NULL.getValue())
|
||||
.list();
|
||||
if (CollUtil.isNotEmpty(roadCategoryList)) {
|
||||
vo.setRoadPercentage(getCompletedPercentage(roadCategoryList));
|
||||
}
|
||||
// 计算箱变
|
||||
List<PgsProgressCategory> boxTransformerCategoryList = progressCategoryService.lambdaQuery()
|
||||
.in(PgsProgressCategory::getProjectId, subProjectIds)
|
||||
.like(PgsProgressCategory::getName, "箱变")
|
||||
.ne(PgsProgressCategory::getUnitType, PgsProgressUnitTypeEnum.NULL.getValue())
|
||||
.list();
|
||||
if (CollUtil.isNotEmpty(boxTransformerCategoryList)) {
|
||||
vo.setBoxTransformerPercentage(getCompletedPercentage(boxTransformerCategoryList));
|
||||
}
|
||||
// 计算总进度
|
||||
vo.setTotalPercentage(
|
||||
vo.getCollectorLinePercentage()
|
||||
.add(vo.getExportLinePercentage())
|
||||
.add(vo.getSubstationPercentage())
|
||||
.add(vo.getAreaPercentage())
|
||||
.add(vo.getRoadPercentage())
|
||||
.add(vo.getBoxTransformerPercentage())
|
||||
);
|
||||
return vo;
|
||||
}
|
||||
|
||||
@ -276,4 +318,26 @@ public class ProjectBigScreenServiceImpl implements ProjectBigScreenService {
|
||||
throw new ServiceException("项目不存在", HttpStatus.NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取项目进度百分比
|
||||
*
|
||||
* @param categoryList 项目进度列表
|
||||
* @return 项目进度百分比
|
||||
*/
|
||||
private BigDecimal getCompletedPercentage(List<PgsProgressCategory> categoryList) {
|
||||
BigDecimal completedTotal = BigDecimal.ZERO;
|
||||
BigDecimal allTotal = BigDecimal.ZERO;
|
||||
for (PgsProgressCategory category : categoryList) {
|
||||
BigDecimal completed = category.getCompleted();
|
||||
BigDecimal total = category.getTotal();
|
||||
if (PgsProgressUnitTypeEnum.NUMBER.getValue().equals(category.getUnitType())) {
|
||||
completedTotal = completedTotal.add(completed);
|
||||
} else if (PgsProgressUnitTypeEnum.PERCENTAGE.getValue().equals(category.getUnitType())) {
|
||||
completedTotal = completedTotal.add(completed.divide(BigDecimal.valueOf(100L), 2, RoundingMode.HALF_UP).multiply(total));
|
||||
}
|
||||
allTotal = allTotal.add(total);
|
||||
}
|
||||
return BigDecimalUtil.toPercentage(completedTotal, allTotal);
|
||||
}
|
||||
}
|
||||
|
@ -1,20 +1,24 @@
|
||||
package org.dromara.contractor.controller.app;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
||||
import org.dromara.common.log.annotation.Log;
|
||||
import org.dromara.common.log.enums.BusinessType;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.web.core.BaseController;
|
||||
import org.dromara.contractor.domain.dto.salaryperiod.SubSalaryPeriodCreateReq;
|
||||
import org.dromara.contractor.domain.dto.salaryperiod.SubSalaryPeriodQueryReq;
|
||||
import org.dromara.contractor.domain.vo.salaryperiod.SubSalaryPeriodVo;
|
||||
import org.dromara.contractor.service.ISubSalaryPeriodService;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* 工资结算周期 app 接口
|
||||
*
|
||||
* @author lilemy
|
||||
* @date 2025-09-04 14:13
|
||||
*/
|
||||
@ -26,6 +30,25 @@ public class SubSalaryPeriodAppController extends BaseController {
|
||||
@Resource
|
||||
private ISubSalaryPeriodService salaryPeriodService;
|
||||
|
||||
/**
|
||||
* 查询工资结算周期列表
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<SubSalaryPeriodVo> list(SubSalaryPeriodQueryReq req, PageQuery pageQuery) {
|
||||
return salaryPeriodService.queryPageList(req, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取工资结算周期详细信息
|
||||
*
|
||||
* @param id 主键
|
||||
*/
|
||||
@GetMapping("/{id}")
|
||||
public R<SubSalaryPeriodVo> getInfo(@NotNull(message = "主键不能为空")
|
||||
@PathVariable Long id) {
|
||||
return R.ok(salaryPeriodService.queryById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增工资结算周期
|
||||
*/
|
||||
|
@ -60,6 +60,11 @@ public class SubSalaryPeriod extends BaseEntity {
|
||||
*/
|
||||
private BigDecimal totalWage;
|
||||
|
||||
/**
|
||||
* 总人数
|
||||
*/
|
||||
private Integer totalPeople;
|
||||
|
||||
/**
|
||||
* 状态 0-未开始 1-进行中 2-已完成
|
||||
*/
|
||||
|
@ -4,12 +4,15 @@ import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import lombok.Data;
|
||||
import org.dromara.common.translation.annotation.Translation;
|
||||
import org.dromara.common.translation.constant.TransConstant;
|
||||
import org.dromara.contractor.domain.SubSalaryPeriod;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
/**
|
||||
@ -44,6 +47,11 @@ public class SubSalaryPeriodVo implements Serializable {
|
||||
@ExcelProperty(value = "班组id")
|
||||
private Long teamId;
|
||||
|
||||
/**
|
||||
* 班组名称
|
||||
*/
|
||||
private String teamName;
|
||||
|
||||
/**
|
||||
* 开始日期
|
||||
*/
|
||||
@ -68,6 +76,11 @@ public class SubSalaryPeriodVo implements Serializable {
|
||||
@ExcelProperty(value = "总工资")
|
||||
private BigDecimal totalWage;
|
||||
|
||||
/**
|
||||
* 总人数
|
||||
*/
|
||||
private Integer totalPeople;
|
||||
|
||||
/**
|
||||
* 状态 0-未开始 1-进行中 2-已完成
|
||||
*/
|
||||
@ -80,4 +93,21 @@ public class SubSalaryPeriodVo implements Serializable {
|
||||
@ExcelProperty(value = "备注")
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@ExcelProperty(value = "创建时间")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private Long createBy;
|
||||
|
||||
/**
|
||||
* 创建人名称
|
||||
*/
|
||||
@Translation(type = TransConstant.USER_ID_TO_NICKNAME, mapper = "createBy")
|
||||
private String createByName;
|
||||
|
||||
}
|
||||
|
@ -21,6 +21,8 @@ import org.dromara.contractor.mapper.SubSalaryPeriodMapper;
|
||||
import org.dromara.contractor.service.ISubSalaryPeriodService;
|
||||
import org.dromara.contractor.service.ISubUserSalaryDetailService;
|
||||
import org.dromara.contractor.service.ISubUserSalaryPeriodService;
|
||||
import org.dromara.project.domain.BusProjectTeam;
|
||||
import org.dromara.project.service.IBusProjectTeamService;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@ -28,10 +30,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@ -50,6 +49,9 @@ public class SubSalaryPeriodServiceImpl extends ServiceImpl<SubSalaryPeriodMappe
|
||||
@Resource
|
||||
private ISubUserSalaryPeriodService userSalaryPeriodService;
|
||||
|
||||
@Resource
|
||||
private IBusProjectTeamService projectTeamService;
|
||||
|
||||
/**
|
||||
* 查询工资结算周期
|
||||
*
|
||||
@ -128,6 +130,7 @@ public class SubSalaryPeriodServiceImpl extends ServiceImpl<SubSalaryPeriodMappe
|
||||
.le(SubUserSalaryDetail::getReportDate, endDate)
|
||||
.list();
|
||||
BigDecimal totalWage = BigDecimal.ZERO;
|
||||
int totalPeople = 0;
|
||||
List<SubUserSalaryPeriod> periodList = new ArrayList<>();
|
||||
if (CollUtil.isNotEmpty(detailList)) {
|
||||
Map<Long, List<SubUserSalaryDetail>> userDetailMap = detailList.stream()
|
||||
@ -147,6 +150,7 @@ public class SubSalaryPeriodServiceImpl extends ServiceImpl<SubSalaryPeriodMappe
|
||||
// 汇总
|
||||
totalWage = totalWage.add(total);
|
||||
periodList.add(period);
|
||||
totalPeople++;
|
||||
}
|
||||
}
|
||||
// 封装新增数据
|
||||
@ -157,6 +161,7 @@ public class SubSalaryPeriodServiceImpl extends ServiceImpl<SubSalaryPeriodMappe
|
||||
salaryPeriod.setEndDate(endDate);
|
||||
salaryPeriod.setTotalDays(days);
|
||||
salaryPeriod.setTotalWage(totalWage);
|
||||
salaryPeriod.setTotalPeople(totalPeople);
|
||||
// 新增
|
||||
boolean save = this.save(salaryPeriod);
|
||||
if (!save) {
|
||||
@ -187,6 +192,14 @@ public class SubSalaryPeriodServiceImpl extends ServiceImpl<SubSalaryPeriodMappe
|
||||
return salaryPeriodVo;
|
||||
}
|
||||
BeanUtils.copyProperties(salaryPeriod, salaryPeriodVo);
|
||||
// 获取班组名称
|
||||
Long teamId = salaryPeriod.getTeamId();
|
||||
if (teamId != null) {
|
||||
BusProjectTeam team = projectTeamService.getById(teamId);
|
||||
if (team != null) {
|
||||
salaryPeriodVo.setTeamName(team.getTeamName());
|
||||
}
|
||||
}
|
||||
return salaryPeriodVo;
|
||||
}
|
||||
|
||||
@ -238,9 +251,17 @@ public class SubSalaryPeriodServiceImpl extends ServiceImpl<SubSalaryPeriodMappe
|
||||
if (CollUtil.isEmpty(salaryPeriodList)) {
|
||||
return salaryPeriodVoPage;
|
||||
}
|
||||
// 获取班组
|
||||
Set<Long> teamIdList = salaryPeriodList.stream().map(SubSalaryPeriod::getTeamId).collect(Collectors.toSet());
|
||||
List<BusProjectTeam> teamList = projectTeamService.listByIds(teamIdList);
|
||||
Map<Long, BusProjectTeam> teamMap = teamList.stream().collect(Collectors.toMap(BusProjectTeam::getId, team -> team));
|
||||
List<SubSalaryPeriodVo> salaryPeriodVoList = salaryPeriodList.stream().map(entity -> {
|
||||
SubSalaryPeriodVo salaryPeriodVo = new SubSalaryPeriodVo();
|
||||
BeanUtils.copyProperties(entity, salaryPeriodVo);
|
||||
// 获取班组名称
|
||||
if (teamMap.containsKey(entity.getTeamId())) {
|
||||
salaryPeriodVo.setTeamName(teamMap.get(entity.getTeamId()).getTeamName());
|
||||
}
|
||||
return salaryPeriodVo;
|
||||
}).toList();
|
||||
salaryPeriodVoPage.setRecords(salaryPeriodVoList);
|
||||
|
@ -158,4 +158,20 @@ public interface IPgsProgressCategoryService extends IService<PgsProgressCategor
|
||||
|
||||
|
||||
PgsProgressCategory convertVoToEntity(PgsProgressCategoryVo vo);
|
||||
|
||||
/**
|
||||
* 获取最底层的叶子节点
|
||||
*
|
||||
* @param topId 顶级节点id
|
||||
* @return 最底层的叶子节点
|
||||
*/
|
||||
List<PgsProgressCategory> getLeafNodesByTopId(Long topId);
|
||||
|
||||
/**
|
||||
* 获取最底层的叶子节点(支持多个顶级id)
|
||||
*
|
||||
* @param topIds 顶级节点id集合
|
||||
* @return 最底层的叶子节点
|
||||
*/
|
||||
List<PgsProgressCategory> getLeafNodesByTopIds(List<Long> topIds);
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -1154,4 +1155,68 @@ public class PgsProgressCategoryServiceImpl extends ServiceImpl<PgsProgressCateg
|
||||
return entity;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取最底层的叶子节点
|
||||
*
|
||||
* @param topId 顶级节点id
|
||||
* @return 最底层的叶子节点
|
||||
*/
|
||||
@Override
|
||||
public List<PgsProgressCategory> getLeafNodesByTopId(Long topId) {
|
||||
// 1. 查出所有属于该顶级节点的子孙节点
|
||||
List<PgsProgressCategory> allChildren = this.list(
|
||||
Wrappers.<PgsProgressCategory>lambdaQuery()
|
||||
.like(PgsProgressCategory::getAncestors, "," + topId + ",")
|
||||
);
|
||||
|
||||
if (allChildren.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
// 2. 过滤掉那些还有子节点的,只保留最底层
|
||||
Set<Long> parentIds = allChildren.stream()
|
||||
.map(PgsProgressCategory::getParentId)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
return allChildren.stream()
|
||||
.filter(item -> !parentIds.contains(item.getId())) // 没有被当作别人父id的,就是叶子节点
|
||||
.toList();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取最底层的叶子节点(支持多个顶级id)
|
||||
*
|
||||
* @param topIds 顶级节点id集合
|
||||
* @return 最底层的叶子节点
|
||||
*/
|
||||
@Override
|
||||
public List<PgsProgressCategory> getLeafNodesByTopIds(List<Long> topIds) {
|
||||
if (topIds == null || topIds.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
// 1. 查出所有属于这些顶级节点的子孙节点
|
||||
List<PgsProgressCategory> allChildren = this.list(
|
||||
Wrappers.<PgsProgressCategory>lambdaQuery()
|
||||
.and(wrapper -> {
|
||||
for (Long topId : topIds) {
|
||||
wrapper.or(q -> q.like(PgsProgressCategory::getAncestors, "," + topId + ","));
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
if (allChildren.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
// 2. 过滤掉那些还有子节点的,只保留最底层
|
||||
Set<Long> parentIds = allChildren.stream()
|
||||
.map(PgsProgressCategory::getParentId)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
return allChildren.stream()
|
||||
.filter(item -> !parentIds.contains(item.getId())) // 没有被当作别人父id的,就是叶子节点
|
||||
.toList();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,6 +2,8 @@ package org.dromara.safety.domain.vo.safetyinspection;
|
||||
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import lombok.Data;
|
||||
import org.dromara.common.translation.annotation.Translation;
|
||||
import org.dromara.common.translation.constant.TransConstant;
|
||||
import org.dromara.safety.domain.HseSafetyInspection;
|
||||
|
||||
import java.io.Serial;
|
||||
@ -137,11 +139,23 @@ public class HseSafetyInspectionVo implements Serializable {
|
||||
*/
|
||||
private String checkFile;
|
||||
|
||||
/**
|
||||
* 检查附件url
|
||||
*/
|
||||
@Translation(type = TransConstant.OSS_ID_TO_URL, mapper = "checkFile")
|
||||
private String checkFileUrl;
|
||||
|
||||
/**
|
||||
* 整改附件
|
||||
*/
|
||||
private String rectificationFile;
|
||||
|
||||
/**
|
||||
* 整改附件url
|
||||
*/
|
||||
@Translation(type = TransConstant.OSS_ID_TO_URL, mapper = "rectificationFile")
|
||||
private String rectificationFileUrl;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
|
@ -130,15 +130,21 @@ public class HseRecognizeRecordServiceImpl extends ServiceImpl<HseRecognizeRecor
|
||||
}
|
||||
List<HseViolationRecordCreateDto> violationRecordList = new ArrayList<>();
|
||||
for (HseRecognizeRecord entity : entityList) {
|
||||
HseViolationRecordCreateDto violationRecord = new HseViolationRecordCreateDto();
|
||||
String violationType = entity.getViolationType();
|
||||
if (StringUtils.isNotBlank(violationType)) {
|
||||
List<String> list = StringUtils.splitList(violationType);
|
||||
for (String s : list) {
|
||||
if (entity.getProjectId() != null) {
|
||||
HseViolationRecordCreateDto violationRecord = new HseViolationRecordCreateDto();
|
||||
violationRecord.setProjectId(entity.getProjectId());
|
||||
violationRecord.setRecognizeId(entity.getId());
|
||||
violationRecord.setViolationType(entity.getViolationType());
|
||||
violationRecord.setViolationType(s);
|
||||
violationRecord.setViolationTime(entity.getCreateTime());
|
||||
violationRecordList.add(violationRecord);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (CollUtil.isNotEmpty(violationRecordList)) {
|
||||
violationRecordService.insertByMonitor(violationRecordList);
|
||||
}
|
||||
|
@ -474,9 +474,10 @@ public class HseSafetyInspectionServiceImpl extends ServiceImpl<HseSafetyInspect
|
||||
Long correctorId = safetyInspection.getCorrectorId();
|
||||
// 只有指定用户可以整改
|
||||
Long userId = LoginHelper.getUserId();
|
||||
if (!correctorId.equals(userId)) {
|
||||
// todo 仅测试
|
||||
/* if (!correctorId.equals(userId)) {
|
||||
throw new ServiceException("当前用户不是指定整改人", HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
}*/
|
||||
HseSafetyInspection updateInspection = new HseSafetyInspection();
|
||||
BeanUtils.copyProperties(req, updateInspection);
|
||||
// 填充默认值
|
||||
|
@ -377,9 +377,10 @@ public class HseViolationRecordServiceImpl extends ServiceImpl<HseViolationRecor
|
||||
Long correctorId = violationRecord.getCorrectorId();
|
||||
// 只有指定用户可以整改
|
||||
Long userId = LoginHelper.getUserId();
|
||||
if (!correctorId.equals(userId)) {
|
||||
// todo 仅测试
|
||||
/* if (!correctorId.equals(userId)) {
|
||||
throw new ServiceException("当前用户不是指定整改人", HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
}*/
|
||||
HseViolationRecord updateRecord = new HseViolationRecord();
|
||||
BeanUtils.copyProperties(req, updateRecord);
|
||||
// 填充默认值
|
||||
|
Reference in New Issue
Block a user