[update] 人员关联、进度计划

This commit is contained in:
lcj
2025-08-08 18:20:51 +08:00
parent baea1dc7ab
commit ad1ca2d429
35 changed files with 1433 additions and 637 deletions

View File

@ -1,15 +0,0 @@
package org.dromara.facility.constant;
/**
* @author lilemy
* @date 2025/5/23 11:29
*/
public interface FacPhotovoltaicPanelPartsConstant {
String POINT = "钻孔";
String COLUMN = "桩基";
String SUPPORT = "支架";
}

View File

@ -11,6 +11,7 @@ import org.dromara.facility.domain.dto.boxtransformer.FacBoxTransformerCreateReq
import org.dromara.facility.domain.dto.boxtransformer.FacBoxTransformerQueryReq;
import org.dromara.facility.domain.dto.boxtransformer.FacBoxTransformerUpdateReq;
import org.dromara.facility.domain.vo.boxtransformer.FacBoxTransformerVo;
import org.dromara.progress.domain.PgsProgressCategory;
import java.util.Collection;
import java.util.List;
@ -64,6 +65,14 @@ public interface IFacBoxTransformerService extends IService<FacBoxTransformer> {
*/
Boolean insertByGeoJson(FacBoxTransformerCreateByGeoJsonReq geoJson);
/**
* 根据类别模板创建箱变数据
*
* @param progressCategory 需新建数据的类别
* @param temp 旧类别列表
*/
void insertByCategoryTemp(PgsProgressCategory progressCategory, List<PgsProgressCategory> temp);
/**
* 修改设施-箱变
*

View File

@ -11,6 +11,7 @@ import org.dromara.facility.domain.dto.inverter.FacInverterCreateReq;
import org.dromara.facility.domain.dto.inverter.FacInverterQueryReq;
import org.dromara.facility.domain.dto.inverter.FacInverterUpdateReq;
import org.dromara.facility.domain.vo.inverter.FacInverterVo;
import org.dromara.progress.domain.PgsProgressCategory;
import java.util.Collection;
import java.util.List;
@ -64,6 +65,14 @@ public interface IFacInverterService extends IService<FacInverter> {
*/
Boolean insertByGeoJson(FacInverterCreateByGeoJsonReq geoJson);
/**
* 根据类别模板创建逆变器数据
*
* @param progressCategory 需新建数据的类别
* @param temp 旧类别列表
*/
void insertByCategoryTemp(PgsProgressCategory progressCategory, List<PgsProgressCategory> temp);
/**
* 修改设施-逆变器
*

View File

@ -12,6 +12,7 @@ import org.dromara.facility.domain.dto.photovoltaicpanelcolumn.FacPhotovoltaicPa
import org.dromara.facility.domain.dto.photovoltaicpanelparts.FacPhotovoltaicPanelPartsQueryReq;
import org.dromara.facility.domain.vo.photovoltaicpanelcolumn.FacPhotovoltaicPanelColumnVo;
import org.dromara.facility.domain.vo.photovoltaicpanelparts.FacPhotovoltaicPanelPartsByPanelNameVo;
import org.dromara.progress.domain.PgsProgressCategory;
import java.util.Collection;
import java.util.List;
@ -57,6 +58,14 @@ public interface IFacPhotovoltaicPanelColumnService extends IService<FacPhotovol
*/
Long insertByBo(FacPhotovoltaicPanelColumnCreateReq req);
/**
* 根据类别模板创建光伏板立柱数据
*
* @param progressCategory 需新建数据的类别
* @param temp 旧类别列表
*/
void insertByCategoryTemp(PgsProgressCategory progressCategory, List<PgsProgressCategory> temp);
/**
* 修改设施-光伏板立柱
*

View File

@ -12,6 +12,7 @@ import org.dromara.facility.domain.dto.photovoltaicpanelpoint.FacPhotovoltaicPan
import org.dromara.facility.domain.dto.photovoltaicpanelpoint.FacPhotovoltaicPanelPointUpdateReq;
import org.dromara.facility.domain.vo.photovoltaicpanelparts.FacPhotovoltaicPanelPartsByPanelNameVo;
import org.dromara.facility.domain.vo.photovoltaicpanelpoint.FacPhotovoltaicPanelPointVo;
import org.dromara.progress.domain.PgsProgressCategory;
import java.util.Collection;
import java.util.List;
@ -57,6 +58,14 @@ public interface IFacPhotovoltaicPanelPointService extends IService<FacPhotovolt
*/
Long insertByBo(FacPhotovoltaicPanelPointCreateReq req);
/**
* 根据类别模板创建光伏板桩点数据
*
* @param progressCategory 需新建数据的类别
* @param temp 旧类别列表
*/
void insertByCategoryTemp(PgsProgressCategory progressCategory, List<PgsProgressCategory> temp);
/**
* 修改设施-光伏板桩点
*

View File

@ -11,6 +11,7 @@ import org.dromara.facility.domain.dto.photovoltaicpanel.FacPhotovoltaicPanelCre
import org.dromara.facility.domain.dto.photovoltaicpanel.FacPhotovoltaicPanelQueryReq;
import org.dromara.facility.domain.dto.photovoltaicpanel.FacPhotovoltaicPanelUpdateReq;
import org.dromara.facility.domain.vo.photovoltaicpanel.FacPhotovoltaicPanelVo;
import org.dromara.progress.domain.PgsProgressCategory;
import java.util.Collection;
import java.util.List;
@ -78,6 +79,14 @@ public interface IFacPhotovoltaicPanelService extends IService<FacPhotovoltaicPa
*/
void deleteBatchInner(List<FacPhotovoltaicPanel> photovoltaicPanelList);
/**
* 根据类别模板创建光伏板数据
*
* @param progressCategory 需新建数据的类别
* @param temp 旧类别列表
*/
void insertByCategoryTemp(PgsProgressCategory progressCategory, List<PgsProgressCategory> temp);
/**
* 修改设施-光伏板
*

View File

@ -12,6 +12,7 @@ import org.dromara.facility.domain.dto.photovoltaicpanelsupport.FacPhotovoltaicP
import org.dromara.facility.domain.dto.photovoltaicpanelsupport.FacPhotovoltaicPanelSupportUpdateReq;
import org.dromara.facility.domain.vo.photovoltaicpanelparts.FacPhotovoltaicPanelPartsByPanelNameVo;
import org.dromara.facility.domain.vo.photovoltaicpanelsupport.FacPhotovoltaicPanelSupportVo;
import org.dromara.progress.domain.PgsProgressCategory;
import java.util.Collection;
import java.util.List;
@ -57,6 +58,14 @@ public interface IFacPhotovoltaicPanelSupportService extends IService<FacPhotovo
*/
Long insertByBo(FacPhotovoltaicPanelSupportCreateReq req);
/**
* 根据类别模板创建光伏板支架数据
*
* @param progressCategory 需新建数据的类别
* @param temp 旧类别列表
*/
void insertByCategoryTemp(PgsProgressCategory progressCategory, List<PgsProgressCategory> temp);
/**
* 修改设施-光伏板支架
*

View File

@ -36,10 +36,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
@ -179,7 +176,9 @@ public class FacBoxTransformerServiceImpl extends ServiceImpl<FacBoxTransformerM
}
// 获取进度类别信息
List<PgsProgressCategory> progressCategoryList = progressCategoryService.lambdaQuery()
.in(PgsProgressCategory::getWorkType, PgsProgressCategoryConstant.BOX_TRANSFORMER_PROGRESS_CATEGORY_WORK_TYPE).list();
.eq(PgsProgressCategory::getProjectId, projectId)
.likeRight(PgsProgressCategory::getWorkType, PgsProgressCategoryConstant.BOX_TRANSFORMER_WORK_TYPE + "_")
.list();
Map<Long, List<PgsProgressCategory>> progressCategoryMap = progressCategoryList
.stream().collect(Collectors.groupingBy(PgsProgressCategory::getMatrixId));
List<FacBoxTransformer> boxTransformerList = new ArrayList<>();
@ -258,6 +257,61 @@ public class FacBoxTransformerServiceImpl extends ServiceImpl<FacBoxTransformerM
return true;
}
/**
* 根据类别模板创建箱变数据
*
* @param progressCategory 需新建数据的类别
* @param temp 旧类别列表
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void insertByCategoryTemp(PgsProgressCategory progressCategory, List<PgsProgressCategory> temp) {
Set<Long> tempIds = temp.stream().map(PgsProgressCategory::getId).collect(Collectors.toSet());
List<FacBoxTransformer> boxTransformers = this.lambdaQuery()
.in(FacBoxTransformer::getProgressCategoryId, tempIds)
.list();
if (CollUtil.isEmpty(boxTransformers)) {
return;
}
Map<Long, List<FacBoxTransformer>> tempMap = boxTransformers.stream()
.collect(Collectors.groupingBy(FacBoxTransformer::getProgressCategoryId));
List<FacBoxTransformer> boxTransformerList = new ArrayList<>();
for (Map.Entry<Long, List<FacBoxTransformer>> entry : tempMap.entrySet()) {
if (CollUtil.isNotEmpty(entry.getValue())) {
boxTransformerList.addAll(entry.getValue());
break;
}
}
if (CollUtil.isEmpty(boxTransformerList)) {
return;
}
List<FacBoxTransformer> newBoxTransformerList = boxTransformerList.stream().map(boxTransformer -> {
FacBoxTransformer newBoxTransformer = new FacBoxTransformer();
newBoxTransformer.setProjectId(progressCategory.getProjectId());
newBoxTransformer.setMatrixId(progressCategory.getMatrixId());
newBoxTransformer.setName(boxTransformer.getName());
newBoxTransformer.setPositions(boxTransformer.getPositions());
newBoxTransformer.setProgressCategoryId(progressCategory.getId());
newBoxTransformer.setProgressCategoryName(progressCategory.getName());
newBoxTransformer.setRemark(boxTransformer.getRemark());
return newBoxTransformer;
}).toList();
boolean saved = this.saveBatch(newBoxTransformerList);
if (!saved) {
throw new ServiceException("新增箱变失败,数据库异常", HttpStatus.ERROR);
}
BigDecimal total = BigDecimal.valueOf(newBoxTransformerList.size());
progressCategory.setTotal(total);
progressCategory.setOutputValue(total.multiply(
Optional.ofNullable(progressCategory.getUnitPrice())
.orElse(BigDecimal.ZERO)
));
boolean result = progressCategoryService.updateById(progressCategory);
if (!result) {
throw new ServiceException("更新进度失败,数据库异常", HttpStatus.ERROR);
}
}
/**
* 修改设施-箱变
*

View File

@ -36,10 +36,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
@ -157,7 +154,7 @@ public class FacInverterServiceImpl extends ServiceImpl<FacInverterMapper, FacIn
if (CollUtil.isEmpty(matrixList)) {
throw new ServiceException("项目下无方阵数据,请先创建方阵信息后再添加逆变器信息", HttpStatus.NOT_FOUND);
}
// 获取箱变信息
// 获取逆变器信息
List<FacInverter> oldInverterList = this.lambdaQuery()
.eq(FacInverter::getProjectId, projectId).list();
Map<String, FacInverter> inverterMap = oldInverterList.stream().collect(Collectors.toMap(
@ -179,14 +176,16 @@ public class FacInverterServiceImpl extends ServiceImpl<FacInverterMapper, FacIn
}
// 获取进度类别信息
List<PgsProgressCategory> progressCategoryList = progressCategoryService.lambdaQuery()
.in(PgsProgressCategory::getWorkType, PgsProgressCategoryConstant.INVERTER_PROGRESS_CATEGORY_WORK_TYPE).list();
.eq(PgsProgressCategory::getProjectId, projectId)
.likeRight(PgsProgressCategory::getWorkType, PgsProgressCategoryConstant.INVERTER_WORK_TYPE + "_")
.list();
Map<Long, List<PgsProgressCategory>> progressCategoryMap = progressCategoryList.stream()
.collect(Collectors.groupingBy(PgsProgressCategory::getMatrixId));
List<FacInverter> inverterList = new ArrayList<>();
for (FacFeatureByPoint locationFeature : locationGeoJson) {
FacGeometryByPoint geometry = locationFeature.getGeometry();
List<Double> coordinates = geometry.getCoordinates();
// 判断箱变在哪个方阵里
// 判断逆变器在哪个方阵里
FacMatrix matrix = matrixService.getMatrixIdByCoordinates(matrixList, coordinates);
if (matrix == null) {
continue;
@ -206,7 +205,7 @@ public class FacInverterServiceImpl extends ServiceImpl<FacInverterMapper, FacIn
inverter.setProjectId(projectId);
inverter.setPositions(JSONUtil.toJsonStr(coordinates));
String mapKey = name + "_" + progressCategory.getId();
// 如果有同名同类别箱变,则获取该箱变完成状态
// 如果有同名同类别逆变器,则获取该逆变器完成状态
if (CollUtil.isNotEmpty(inverterMap) && inverterMap.containsKey(mapKey)) {
FacInverter oldInverter = inverterMap.get(mapKey);
inverter.setFinishType(oldInverter.getFinishType());
@ -258,6 +257,61 @@ public class FacInverterServiceImpl extends ServiceImpl<FacInverterMapper, FacIn
return true;
}
/**
* 根据类别模板插入逆变器
*
* @param progressCategory 需新建数据的类别
* @param temp 旧类别列表
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void insertByCategoryTemp(PgsProgressCategory progressCategory, List<PgsProgressCategory> temp) {
Set<Long> tempIds = temp.stream().map(PgsProgressCategory::getId).collect(Collectors.toSet());
List<FacInverter> inverters = this.lambdaQuery()
.in(FacInverter::getProgressCategoryId, tempIds)
.list();
if (CollUtil.isEmpty(inverters)) {
return;
}
Map<Long, List<FacInverter>> tempMap = inverters.stream()
.collect(Collectors.groupingBy(FacInverter::getProgressCategoryId));
List<FacInverter> inverterList = new ArrayList<>();
for (Map.Entry<Long, List<FacInverter>> entry : tempMap.entrySet()) {
if (CollUtil.isNotEmpty(entry.getValue())) {
inverterList.addAll(entry.getValue());
break;
}
}
if (CollUtil.isEmpty(inverterList)) {
return;
}
List<FacInverter> newInverterList = inverterList.stream().map(inverter -> {
FacInverter newInverter = new FacInverter();
newInverter.setProjectId(progressCategory.getProjectId());
newInverter.setMatrixId(progressCategory.getMatrixId());
newInverter.setName(inverter.getName());
newInverter.setPositions(inverter.getPositions());
newInverter.setProgressCategoryId(progressCategory.getId());
newInverter.setProgressCategoryName(progressCategory.getName());
newInverter.setRemark(inverter.getRemark());
return newInverter;
}).toList();
boolean saved = this.saveBatch(newInverterList);
if (!saved) {
throw new ServiceException("新增逆变器失败,数据库异常", HttpStatus.ERROR);
}
BigDecimal total = BigDecimal.valueOf(newInverterList.size());
progressCategory.setTotal(total);
progressCategory.setOutputValue(total.multiply(
Optional.ofNullable(progressCategory.getUnitPrice())
.orElse(BigDecimal.ZERO)
));
boolean result = progressCategoryService.updateById(progressCategory);
if (!result) {
throw new ServiceException("更新进度失败,数据库异常", HttpStatus.ERROR);
}
}
/**
* 修改设施-逆变器
*

View File

@ -25,15 +25,15 @@ import org.dromara.facility.domain.vo.photovoltaicpanelparts.FacPhotovoltaicPane
import org.dromara.facility.mapper.FacPhotovoltaicPanelColumnMapper;
import org.dromara.facility.service.IFacMatrixService;
import org.dromara.facility.service.IFacPhotovoltaicPanelColumnService;
import org.dromara.progress.domain.PgsProgressCategory;
import org.dromara.progress.service.IPgsProgressCategoryService;
import org.dromara.project.service.IBusProjectService;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
/**
@ -52,6 +52,9 @@ public class FacPhotovoltaicPanelColumnServiceImpl extends ServiceImpl<FacPhotov
@Resource
private IFacMatrixService matrixService;
@Resource
private IPgsProgressCategoryService progressCategoryService;
/**
* 查询设施-光伏板立柱
*
@ -127,6 +130,61 @@ public class FacPhotovoltaicPanelColumnServiceImpl extends ServiceImpl<FacPhotov
return photovoltaicPanelColumn.getId();
}
/**
* 根据类别模板创建光伏板立柱数据
*
* @param progressCategory 需新建数据的类别
* @param temp 旧类别列表
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void insertByCategoryTemp(PgsProgressCategory progressCategory, List<PgsProgressCategory> temp) {
Set<Long> tempIds = temp.stream().map(PgsProgressCategory::getId).collect(Collectors.toSet());
List<FacPhotovoltaicPanelColumn> columns = this.lambdaQuery()
.in(FacPhotovoltaicPanelColumn::getProgressCategoryId, tempIds)
.list();
if (CollUtil.isEmpty(columns)) {
return;
}
Map<Long, List<FacPhotovoltaicPanelColumn>> tempMap = columns.stream()
.collect(Collectors.groupingBy(FacPhotovoltaicPanelColumn::getProgressCategoryId));
List<FacPhotovoltaicPanelColumn> PhotovoltaicPanelColumnList = new ArrayList<>();
for (Map.Entry<Long, List<FacPhotovoltaicPanelColumn>> entry : tempMap.entrySet()) {
if (CollUtil.isNotEmpty(entry.getValue())) {
PhotovoltaicPanelColumnList.addAll(entry.getValue());
break;
}
}
if (CollUtil.isEmpty(PhotovoltaicPanelColumnList)) {
return;
}
List<FacPhotovoltaicPanelColumn> newColumnList = PhotovoltaicPanelColumnList.stream().map(PhotovoltaicPanelColumn -> {
FacPhotovoltaicPanelColumn newColumn = new FacPhotovoltaicPanelColumn();
newColumn.setProjectId(progressCategory.getProjectId());
newColumn.setMatrixId(progressCategory.getMatrixId());
newColumn.setName(PhotovoltaicPanelColumn.getName());
newColumn.setPositions(PhotovoltaicPanelColumn.getPositions());
newColumn.setProgressCategoryId(progressCategory.getId());
newColumn.setProgressCategoryName(progressCategory.getName());
newColumn.setRemark(PhotovoltaicPanelColumn.getRemark());
return newColumn;
}).toList();
boolean saved = this.saveBatch(newColumnList);
if (!saved) {
throw new ServiceException("新增光伏板立柱失败,数据库异常", HttpStatus.ERROR);
}
BigDecimal total = BigDecimal.valueOf(newColumnList.size());
progressCategory.setTotal(total);
progressCategory.setOutputValue(total.multiply(
Optional.ofNullable(progressCategory.getUnitPrice())
.orElse(BigDecimal.ZERO)
));
boolean result = progressCategoryService.updateById(progressCategory);
if (!result) {
throw new ServiceException("更新进度失败,数据库异常", HttpStatus.ERROR);
}
}
/**
* 修改设施-光伏板立柱
*

View File

@ -15,7 +15,6 @@ import org.dromara.common.satoken.utils.LoginHelper;
import org.dromara.common.sse.dto.SseMessageDto;
import org.dromara.common.sse.utils.SseMessageUtils;
import org.dromara.common.utils.JSTUtil;
import org.dromara.facility.constant.FacPhotovoltaicPanelPartsConstant;
import org.dromara.facility.constant.FacRedisKeyConstant;
import org.dromara.facility.domain.FacPhotovoltaicPanel;
import org.dromara.facility.domain.FacPhotovoltaicPanelColumn;
@ -206,19 +205,20 @@ public class FacPhotovoltaicPanelPartsServiceImpl implements IFacPhotovoltaicPan
*/
private void saveBatch(Long projectId, List<FacFeatureByPoint> features, Long userId) {
// 获取进度类别 Map
List<String> progressCategoryNameList = List.of(
FacPhotovoltaicPanelPartsConstant.POINT,
FacPhotovoltaicPanelPartsConstant.COLUMN,
FacPhotovoltaicPanelPartsConstant.SUPPORT
);
List<PgsProgressCategory> progressCategoryList = progressCategoryService.lambdaQuery()
.select(PgsProgressCategory::getId, PgsProgressCategory::getName, PgsProgressCategory::getMatrixId)
.in(PgsProgressCategory::getName, progressCategoryNameList)
.in(PgsProgressCategory::getProjectId, projectId, PgsProgressCategoryConstant.PUBLIC_PROJECT_ID)
.select(PgsProgressCategory::getId, PgsProgressCategory::getName, PgsProgressCategory::getMatrixId, PgsProgressCategory::getWorkType)
.eq(PgsProgressCategory::getProjectId, projectId)
.and(lqw -> lqw
.likeRight(PgsProgressCategory::getWorkType, PgsProgressCategoryConstant.PHOTOVOLTAIC_PANEL_POINT_WORK_TYPE + "_")
.or()
.likeRight(PgsProgressCategory::getWorkType, PgsProgressCategoryConstant.PHOTOVOLTAIC_PANEL_COLUMN_WORK_TYPE + "_")
.or()
.likeRight(PgsProgressCategory::getWorkType, PgsProgressCategoryConstant.PHOTOVOLTAIC_PANEL_SUPPORT_WORK_TYPE + "_")
)
.list();
Map<String, List<PgsProgressCategory>> progressCategoryMap = progressCategoryList.stream()
.collect(Collectors.groupingBy(
progressCategory -> progressCategory.getMatrixId() + "_" + progressCategory.getName()
progressCategory -> progressCategory.getMatrixId() + "_" + progressCategory.getWorkType().split("_")[0]
));
// 查询项目下光伏板
List<FacPhotovoltaicPanel> photovoltaicPanelList = photovoltaicPanelService.lambdaQuery()
@ -299,68 +299,80 @@ public class FacPhotovoltaicPanelPartsServiceImpl implements IFacPhotovoltaicPan
Long matrixId = photovoltaicPanel.getMatrixId();
String jsonStr = JSONUtil.toJsonStr(list);
// 创建 Point
FacPhotovoltaicPanelPoint point = new FacPhotovoltaicPanelPoint();
point.setProjectId(projectId);
point.setMatrixId(matrixId);
point.setName(name);
point.setPositions(jsonStr);
point.setCreateBy(userId);
point.setUpdateBy(userId);
if (oldPointMap.containsKey(name)) {
FacPhotovoltaicPanelPoint oldPoint = oldPointMap.get(name);
point.setFinishType(oldPoint.getFinishType());
point.setFinishDate(oldPoint.getFinishDate());
point.setStatus(oldPoint.getStatus());
}
String pointMapKey = matrixId + "_" + FacPhotovoltaicPanelPartsConstant.POINT;
String pointMapKey = matrixId + "_" + PgsProgressCategoryConstant.PHOTOVOLTAIC_PANEL_POINT_WORK_TYPE;
if (progressCategoryMap.containsKey(pointMapKey)) {
PgsProgressCategory cat = progressCategoryMap.get(pointMapKey).getFirst();
point.setProgressCategoryId(cat.getId());
point.setProgressCategoryName(cat.getName());
List<PgsProgressCategory> categoryList = progressCategoryMap.get(pointMapKey);
if (CollUtil.isNotEmpty(categoryList)) {
for (PgsProgressCategory category : categoryList) {
FacPhotovoltaicPanelPoint point = new FacPhotovoltaicPanelPoint();
point.setProjectId(projectId);
point.setMatrixId(matrixId);
point.setName(name);
point.setPositions(jsonStr);
point.setCreateBy(userId);
point.setUpdateBy(userId);
if (oldPointMap.containsKey(name)) {
FacPhotovoltaicPanelPoint oldPoint = oldPointMap.get(name);
point.setFinishType(oldPoint.getFinishType());
point.setFinishDate(oldPoint.getFinishDate());
point.setStatus(oldPoint.getStatus());
}
point.setProgressCategoryId(category.getId());
point.setProgressCategoryName(category.getName());
pointList.add(point);
}
}
}
pointList.add(point);
// 创建 Column
FacPhotovoltaicPanelColumn column = new FacPhotovoltaicPanelColumn();
column.setProjectId(projectId);
column.setMatrixId(matrixId);
column.setName(name);
column.setPositions(jsonStr);
column.setCreateBy(userId);
column.setUpdateBy(userId);
if (oldColumnMap.containsKey(name)) {
FacPhotovoltaicPanelColumn oldColumn = oldColumnMap.get(name);
column.setFinishType(oldColumn.getFinishType());
column.setFinishDate(oldColumn.getFinishDate());
column.setStatus(oldColumn.getStatus());
}
String columnMapKey = matrixId + "_" + FacPhotovoltaicPanelPartsConstant.COLUMN;
String columnMapKey = matrixId + "_" + PgsProgressCategoryConstant.PHOTOVOLTAIC_PANEL_COLUMN_WORK_TYPE;
if (progressCategoryMap.containsKey(columnMapKey)) {
PgsProgressCategory cat = progressCategoryMap.get(columnMapKey).getFirst();
column.setProgressCategoryId(cat.getId());
column.setProgressCategoryName(cat.getName());
List<PgsProgressCategory> categoryList = progressCategoryMap.get(columnMapKey);
if (CollUtil.isNotEmpty(categoryList)) {
for (PgsProgressCategory category : categoryList) {
FacPhotovoltaicPanelColumn column = new FacPhotovoltaicPanelColumn();
column.setProjectId(projectId);
column.setMatrixId(matrixId);
column.setName(name);
column.setPositions(jsonStr);
column.setCreateBy(userId);
column.setUpdateBy(userId);
if (oldColumnMap.containsKey(name)) {
FacPhotovoltaicPanelColumn oldColumn = oldColumnMap.get(name);
column.setFinishType(oldColumn.getFinishType());
column.setFinishDate(oldColumn.getFinishDate());
column.setStatus(oldColumn.getStatus());
}
column.setProgressCategoryId(category.getId());
column.setProgressCategoryName(category.getName());
columnList.add(column);
}
}
}
columnList.add(column);
// 创建 Support
FacPhotovoltaicPanelSupport support = new FacPhotovoltaicPanelSupport();
support.setProjectId(projectId);
support.setMatrixId(matrixId);
support.setName(name);
support.setPositions(jsonStr);
support.setCreateBy(userId);
support.setUpdateBy(userId);
if (oldSupportMap.containsKey(name)) {
FacPhotovoltaicPanelSupport oldSupport = oldSupportMap.get(name);
support.setFinishType(oldSupport.getFinishType());
support.setFinishDate(oldSupport.getFinishDate());
support.setStatus(oldSupport.getStatus());
}
String supportMapKey = matrixId + "_" + FacPhotovoltaicPanelPartsConstant.SUPPORT;
String supportMapKey = matrixId + "_" + PgsProgressCategoryConstant.PHOTOVOLTAIC_PANEL_SUPPORT_WORK_TYPE;
if (progressCategoryMap.containsKey(supportMapKey)) {
PgsProgressCategory cat = progressCategoryMap.get(supportMapKey).getFirst();
support.setProgressCategoryId(cat.getId());
support.setProgressCategoryName(cat.getName());
List<PgsProgressCategory> categoryList = progressCategoryMap.get(supportMapKey);
if (CollUtil.isNotEmpty(categoryList)) {
for (PgsProgressCategory category : categoryList) {
FacPhotovoltaicPanelSupport support = new FacPhotovoltaicPanelSupport();
support.setProjectId(projectId);
support.setMatrixId(matrixId);
support.setName(name);
support.setPositions(jsonStr);
support.setCreateBy(userId);
support.setUpdateBy(userId);
if (oldSupportMap.containsKey(name)) {
FacPhotovoltaicPanelSupport oldSupport = oldSupportMap.get(name);
support.setFinishType(oldSupport.getFinishType());
support.setFinishDate(oldSupport.getFinishDate());
support.setStatus(oldSupport.getStatus());
}
support.setProgressCategoryId(category.getId());
support.setProgressCategoryName(category.getName());
supportList.add(support);
}
}
}
supportList.add(support);
}
}
});
@ -389,68 +401,94 @@ public class FacPhotovoltaicPanelPartsServiceImpl implements IFacPhotovoltaicPan
int batchSize = 1000;
// 保存所有批次任务
List<CompletableFuture<Void>> deleteFutures = new ArrayList<>();
int deleteSize = oldPointList.size();
for (int i = 0; i < deleteSize; i += batchSize) {
int endIndex = Math.min(i + batchSize, deleteSize);
List<FacPhotovoltaicPanelPoint> batchPointList = oldPointList.subList(i, endIndex);
List<FacPhotovoltaicPanelColumn> batchColumnList = oldColumnList.subList(i, endIndex);
List<FacPhotovoltaicPanelSupport> batchSupportList = oldSupportList.subList(i, endIndex);
// 使用事务处理每批数据
int oldTotalPointSize = oldPointList.size();
int oldTotalColumnSize = oldColumnList.size();
int oldTotalSupportSize = oldSupportList.size();
// 最大批次数根据最长的列表来
int oldTotalSize = Math.max(Math.max(oldTotalPointSize, oldTotalColumnSize), oldTotalSupportSize);
for (int i = 0; i < oldTotalSize; i += batchSize) {
// 分别计算每个列表的 endIndex防止越界
int endPointIndex = Math.min(i + batchSize, oldTotalPointSize);
int endColumnIndex = Math.min(i + batchSize, oldTotalColumnSize);
int endSupportIndex = Math.min(i + batchSize, oldTotalSupportSize);
// 防止 subList 起始下标超出
List<FacPhotovoltaicPanelPoint> batchPointList =
i < oldTotalPointSize ? oldPointList.subList(i, endPointIndex) : Collections.emptyList();
List<FacPhotovoltaicPanelColumn> batchColumnList =
i < oldTotalColumnSize ? oldColumnList.subList(i, endColumnIndex) : Collections.emptyList();
List<FacPhotovoltaicPanelSupport> batchSupportList =
i < oldTotalSupportSize ? oldSupportList.subList(i, endSupportIndex) : Collections.emptyList();
// 获取代理
FacPhotovoltaicPanelPartsServiceImpl photovoltaicPanelPartsService = self;
// 异步处理每批数据,将任务添加到异步任务列表
CompletableFuture<Void> future = CompletableFuture.runAsync(() -> photovoltaicPanelPartsService.batchDeletePartsInner(batchPointList, batchColumnList, batchSupportList), customExecutor);
// 异步处理每批数据
CompletableFuture<Void> future = CompletableFuture.runAsync(
() -> photovoltaicPanelPartsService.batchDeletePartsInner(batchPointList, batchColumnList, batchSupportList),
customExecutor
);
deleteFutures.add(future);
}
// 等待所有批次完成操作
CompletableFuture.allOf(deleteFutures.toArray(new CompletableFuture[0])).join();
// 保存所有批次任务
List<CompletableFuture<Void>> insertFutures = new ArrayList<>();
int totalSize = pointList.size();
int totalPointSize = pointList.size();
int totalColumnSize = columnList.size();
int totalSupportSize = supportList.size();
// 最大批次数 = 三个列表中最长的长度
int totalSize = Math.max(Math.max(totalPointSize, totalColumnSize), totalSupportSize);
for (int i = 0; i < totalSize; i += batchSize) {
int endIndex = Math.min(i + batchSize, totalSize);
List<FacPhotovoltaicPanelPoint> batchPointList = pointList.subList(i, endIndex);
List<FacPhotovoltaicPanelColumn> batchColumnList = columnList.subList(i, endIndex);
List<FacPhotovoltaicPanelSupport> batchSupportList = supportList.subList(i, endIndex);
// 使用事务处理每批数据
// 获取代理
// 分别计算三个列表的 endIndex防止越界
int endPointIndex = Math.min(i + batchSize, totalPointSize);
int endColumnIndex = Math.min(i + batchSize, totalColumnSize);
int endSupportIndex = Math.min(i + batchSize, totalSupportSize);
// 如果起始索引已经超出长度,就给空列表
List<FacPhotovoltaicPanelPoint> batchPointList =
i < totalPointSize ? pointList.subList(i, endPointIndex) : Collections.emptyList();
List<FacPhotovoltaicPanelColumn> batchColumnList =
i < totalColumnSize ? columnList.subList(i, endColumnIndex) : Collections.emptyList();
List<FacPhotovoltaicPanelSupport> batchSupportList =
i < totalSupportSize ? supportList.subList(i, endSupportIndex) : Collections.emptyList();
FacPhotovoltaicPanelPartsServiceImpl photovoltaicPanelPartsService = self;
// 异步处理每批数据,将任务添加到异步任务列表
CompletableFuture<Void> future = CompletableFuture.runAsync(() -> photovoltaicPanelPartsService.batchInsertPartsInner(batchPointList, batchColumnList, batchSupportList), customExecutor);
CompletableFuture<Void> future = CompletableFuture.runAsync(
() -> photovoltaicPanelPartsService.batchInsertPartsInner(batchPointList, batchColumnList, batchSupportList),
customExecutor
);
insertFutures.add(future);
}
// 等待所有批次完成操作
CompletableFuture.allOf(insertFutures.toArray(new CompletableFuture[0])).join();
// 关闭线程池
customExecutor.shutdown();
// 更新数量
Map<Long, List<FacPhotovoltaicPanelPoint>> pointCountMap = pointList
.stream().collect(Collectors.groupingBy(FacPhotovoltaicPanelPoint::getProgressCategoryId));
Map<Long, List<FacPhotovoltaicPanelColumn>> columnCountMap = columnList
.stream().collect(Collectors.groupingBy(FacPhotovoltaicPanelColumn::getProgressCategoryId));
Map<Long, List<FacPhotovoltaicPanelSupport>> supportCountMap = supportList
.stream().collect(Collectors.groupingBy(FacPhotovoltaicPanelSupport::getProgressCategoryId));
for (PgsProgressCategory progressCategory : progressCategoryList) {
Long progressCategoryId = progressCategory.getId();
BigDecimal unitPrice = progressCategory.getUnitPrice();
int total = 0;
if (pointCountMap.containsKey(progressCategoryId)) {
total = pointCountMap.get(progressCategoryId).size();
} else if (columnCountMap.containsKey(progressCategoryId)) {
total = columnCountMap.get(progressCategoryId).size();
} else if (supportCountMap.containsKey(progressCategoryId)) {
total = supportCountMap.get(progressCategoryId).size();
if (CollUtil.isNotEmpty(progressCategoryList)) {
// 更新数量
Map<Long, List<FacPhotovoltaicPanelPoint>> pointCountMap = pointList
.stream().collect(Collectors.groupingBy(FacPhotovoltaicPanelPoint::getProgressCategoryId));
Map<Long, List<FacPhotovoltaicPanelColumn>> columnCountMap = columnList
.stream().collect(Collectors.groupingBy(FacPhotovoltaicPanelColumn::getProgressCategoryId));
Map<Long, List<FacPhotovoltaicPanelSupport>> supportCountMap = supportList
.stream().collect(Collectors.groupingBy(FacPhotovoltaicPanelSupport::getProgressCategoryId));
for (PgsProgressCategory progressCategory : progressCategoryList) {
Long progressCategoryId = progressCategory.getId();
BigDecimal unitPrice = progressCategory.getUnitPrice();
int total = 0;
if (pointCountMap.containsKey(progressCategoryId)) {
total = pointCountMap.get(progressCategoryId).size();
} else if (columnCountMap.containsKey(progressCategoryId)) {
total = columnCountMap.get(progressCategoryId).size();
} else if (supportCountMap.containsKey(progressCategoryId)) {
total = supportCountMap.get(progressCategoryId).size();
}
progressCategory.setTotal(BigDecimal.valueOf(total));
// 如果单价不为 0 则计算产值
if (unitPrice != null && unitPrice.compareTo(BigDecimal.ZERO) != 0) {
progressCategory.setOutputValue(unitPrice.multiply(BigDecimal.valueOf(total)));
}
}
progressCategory.setTotal(BigDecimal.valueOf(total));
// 如果单价不为 0 则计算产值
if (unitPrice.compareTo(BigDecimal.ZERO) != 0) {
progressCategory.setOutputValue(unitPrice.multiply(BigDecimal.valueOf(total)));
boolean result = progressCategoryService.updateBatchById(progressCategoryList);
if (!result) {
throw new ServiceException("更新进度类别失败,数据库异常", HttpStatus.ERROR);
}
}
boolean result = progressCategoryService.updateBatchById(progressCategoryList);
if (!result) {
throw new ServiceException("更新进度类别失败,数据库异常", HttpStatus.ERROR);
}
}
/**

View File

@ -25,15 +25,15 @@ import org.dromara.facility.domain.vo.photovoltaicpanelpoint.FacPhotovoltaicPane
import org.dromara.facility.mapper.FacPhotovoltaicPanelPointMapper;
import org.dromara.facility.service.IFacMatrixService;
import org.dromara.facility.service.IFacPhotovoltaicPanelPointService;
import org.dromara.progress.domain.PgsProgressCategory;
import org.dromara.progress.service.IPgsProgressCategoryService;
import org.dromara.project.service.IBusProjectService;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
/**
@ -52,6 +52,9 @@ public class FacPhotovoltaicPanelPointServiceImpl extends ServiceImpl<FacPhotovo
@Resource
private IFacMatrixService matrixService;
@Resource
private IPgsProgressCategoryService progressCategoryService;
/**
* 查询设施-光伏板桩点
*
@ -127,6 +130,61 @@ public class FacPhotovoltaicPanelPointServiceImpl extends ServiceImpl<FacPhotovo
return photovoltaicPanelPoint.getId();
}
/**
* 根据类别模板创建光伏板桩点数据
*
* @param progressCategory 需新建数据的类别
* @param temp 旧类别列表
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void insertByCategoryTemp(PgsProgressCategory progressCategory, List<PgsProgressCategory> temp) {
Set<Long> tempIds = temp.stream().map(PgsProgressCategory::getId).collect(Collectors.toSet());
List<FacPhotovoltaicPanelPoint> points = this.lambdaQuery()
.in(FacPhotovoltaicPanelPoint::getProgressCategoryId, tempIds)
.list();
if (CollUtil.isEmpty(points)) {
return;
}
Map<Long, List<FacPhotovoltaicPanelPoint>> tempMap = points.stream()
.collect(Collectors.groupingBy(FacPhotovoltaicPanelPoint::getProgressCategoryId));
List<FacPhotovoltaicPanelPoint> PhotovoltaicPanelPointList = new ArrayList<>();
for (Map.Entry<Long, List<FacPhotovoltaicPanelPoint>> entry : tempMap.entrySet()) {
if (CollUtil.isNotEmpty(entry.getValue())) {
PhotovoltaicPanelPointList.addAll(entry.getValue());
break;
}
}
if (CollUtil.isEmpty(PhotovoltaicPanelPointList)) {
return;
}
List<FacPhotovoltaicPanelPoint> newPointList = PhotovoltaicPanelPointList.stream().map(PhotovoltaicPanelPoint -> {
FacPhotovoltaicPanelPoint newPoint = new FacPhotovoltaicPanelPoint();
newPoint.setProjectId(progressCategory.getProjectId());
newPoint.setMatrixId(progressCategory.getMatrixId());
newPoint.setName(PhotovoltaicPanelPoint.getName());
newPoint.setPositions(PhotovoltaicPanelPoint.getPositions());
newPoint.setProgressCategoryId(progressCategory.getId());
newPoint.setProgressCategoryName(progressCategory.getName());
newPoint.setRemark(PhotovoltaicPanelPoint.getRemark());
return newPoint;
}).toList();
boolean saved = this.saveBatch(newPointList);
if (!saved) {
throw new ServiceException("新增光伏板桩点失败,数据库异常", HttpStatus.ERROR);
}
BigDecimal total = BigDecimal.valueOf(newPointList.size());
progressCategory.setTotal(total);
progressCategory.setOutputValue(total.multiply(
Optional.ofNullable(progressCategory.getUnitPrice())
.orElse(BigDecimal.ZERO)
));
boolean result = progressCategoryService.updateById(progressCategory);
if (!result) {
throw new ServiceException("更新进度失败,数据库异常", HttpStatus.ERROR);
}
}
/**
* 修改设施-光伏板桩点
*

View File

@ -253,7 +253,9 @@ public class FacPhotovoltaicPanelServiceImpl extends ServiceImpl<FacPhotovoltaic
));
// 获取进度类别信息
List<PgsProgressCategory> progressCategoryList = progressCategoryService.lambdaQuery()
.in(PgsProgressCategory::getWorkType, PgsProgressCategoryConstant.PHOTOVOLTAIC_PANEL_PROGRESS_CATEGORY_WORK_TYPE).list();
.eq(PgsProgressCategory::getProjectId, projectId)
.likeRight(PgsProgressCategory::getWorkType, PgsProgressCategoryConstant.PHOTOVOLTAIC_PANEL_WORK_TYPE + "_")
.list();
Map<Long, List<PgsProgressCategory>> progressCategoryMap = progressCategoryList.stream()
.collect(Collectors.groupingBy(PgsProgressCategory::getMatrixId));
List<FacPhotovoltaicPanel> allPanels = new ArrayList<>();
@ -460,6 +462,61 @@ public class FacPhotovoltaicPanelServiceImpl extends ServiceImpl<FacPhotovoltaic
}
}
/**
* 根据类别模板插入光伏板
*
* @param progressCategory 需新建数据的类别
* @param temp 旧类别列表
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void insertByCategoryTemp(PgsProgressCategory progressCategory, List<PgsProgressCategory> temp) {
Set<Long> tempIds = temp.stream().map(PgsProgressCategory::getId).collect(Collectors.toSet());
List<FacPhotovoltaicPanel> panels = this.lambdaQuery()
.in(FacPhotovoltaicPanel::getProgressCategoryId, tempIds)
.list();
if (CollUtil.isEmpty(panels)) {
return;
}
Map<Long, List<FacPhotovoltaicPanel>> tempMap = panels.stream()
.collect(Collectors.groupingBy(FacPhotovoltaicPanel::getProgressCategoryId));
List<FacPhotovoltaicPanel> photovoltaicPanelList = new ArrayList<>();
for (Map.Entry<Long, List<FacPhotovoltaicPanel>> entry : tempMap.entrySet()) {
if (CollUtil.isNotEmpty(entry.getValue())) {
photovoltaicPanelList.addAll(entry.getValue());
break;
}
}
if (CollUtil.isEmpty(photovoltaicPanelList)) {
return;
}
List<FacPhotovoltaicPanel> newPanelList = photovoltaicPanelList.stream().map(photovoltaicPanel -> {
FacPhotovoltaicPanel newPanel = new FacPhotovoltaicPanel();
newPanel.setProjectId(progressCategory.getProjectId());
newPanel.setMatrixId(progressCategory.getMatrixId());
newPanel.setName(photovoltaicPanel.getName());
newPanel.setPositions(photovoltaicPanel.getPositions());
newPanel.setProgressCategoryId(progressCategory.getId());
newPanel.setProgressCategoryName(progressCategory.getName());
newPanel.setRemark(photovoltaicPanel.getRemark());
return newPanel;
}).toList();
boolean saved = this.saveBatch(newPanelList);
if (!saved) {
throw new ServiceException("新增光伏板失败,数据库异常", HttpStatus.ERROR);
}
BigDecimal total = BigDecimal.valueOf(newPanelList.size());
progressCategory.setTotal(total);
progressCategory.setOutputValue(total.multiply(
Optional.ofNullable(progressCategory.getUnitPrice())
.orElse(BigDecimal.ZERO)
));
boolean result = progressCategoryService.updateById(progressCategory);
if (!result) {
throw new ServiceException("更新进度失败,数据库异常", HttpStatus.ERROR);
}
}
/**
* 修改设施-光伏板
*

View File

@ -25,15 +25,15 @@ import org.dromara.facility.domain.vo.photovoltaicpanelsupport.FacPhotovoltaicPa
import org.dromara.facility.mapper.FacPhotovoltaicPanelSupportMapper;
import org.dromara.facility.service.IFacMatrixService;
import org.dromara.facility.service.IFacPhotovoltaicPanelSupportService;
import org.dromara.progress.domain.PgsProgressCategory;
import org.dromara.progress.service.IPgsProgressCategoryService;
import org.dromara.project.service.IBusProjectService;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
/**
@ -52,6 +52,9 @@ public class FacPhotovoltaicPanelSupportServiceImpl extends ServiceImpl<FacPhoto
@Resource
private IFacMatrixService matrixService;
@Resource
private IPgsProgressCategoryService progressCategoryService;
/**
* 查询设施-光伏板支架
*
@ -127,6 +130,61 @@ public class FacPhotovoltaicPanelSupportServiceImpl extends ServiceImpl<FacPhoto
return photovoltaicPanelSupport.getId();
}
/**
* 根据类别模板创建光伏板支架数据
*
* @param progressCategory 需新建数据的类别
* @param temp 旧类别列表
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void insertByCategoryTemp(PgsProgressCategory progressCategory, List<PgsProgressCategory> temp) {
Set<Long> tempIds = temp.stream().map(PgsProgressCategory::getId).collect(Collectors.toSet());
List<FacPhotovoltaicPanelSupport> supports = this.lambdaQuery()
.in(FacPhotovoltaicPanelSupport::getProgressCategoryId, tempIds)
.list();
if (CollUtil.isEmpty(supports)) {
return;
}
Map<Long, List<FacPhotovoltaicPanelSupport>> tempMap = supports.stream()
.collect(Collectors.groupingBy(FacPhotovoltaicPanelSupport::getProgressCategoryId));
List<FacPhotovoltaicPanelSupport> PhotovoltaicPanelSupportList = new ArrayList<>();
for (Map.Entry<Long, List<FacPhotovoltaicPanelSupport>> entry : tempMap.entrySet()) {
if (CollUtil.isNotEmpty(entry.getValue())) {
PhotovoltaicPanelSupportList.addAll(entry.getValue());
break;
}
}
if (CollUtil.isEmpty(PhotovoltaicPanelSupportList)) {
return;
}
List<FacPhotovoltaicPanelSupport> newSupportList = PhotovoltaicPanelSupportList.stream().map(PhotovoltaicPanelSupport -> {
FacPhotovoltaicPanelSupport newSupport = new FacPhotovoltaicPanelSupport();
newSupport.setProjectId(progressCategory.getProjectId());
newSupport.setMatrixId(progressCategory.getMatrixId());
newSupport.setName(PhotovoltaicPanelSupport.getName());
newSupport.setPositions(PhotovoltaicPanelSupport.getPositions());
newSupport.setProgressCategoryId(progressCategory.getId());
newSupport.setProgressCategoryName(progressCategory.getName());
newSupport.setRemark(PhotovoltaicPanelSupport.getRemark());
return newSupport;
}).toList();
boolean saved = this.saveBatch(newSupportList);
if (!saved) {
throw new ServiceException("新增光伏板支架失败,数据库异常", HttpStatus.ERROR);
}
BigDecimal total = BigDecimal.valueOf(newSupportList.size());
progressCategory.setTotal(total);
progressCategory.setOutputValue(total.multiply(
Optional.ofNullable(progressCategory.getUnitPrice())
.orElse(BigDecimal.ZERO)
));
boolean result = progressCategoryService.updateById(progressCategory);
if (!result) {
throw new ServiceException("更新进度失败,数据库异常", HttpStatus.ERROR);
}
}
/**
* 修改设施-光伏板支架
*

View File

@ -18,62 +18,46 @@ public interface PgsProgressCategoryConstant {
*/
Long PUBLIC_PROJECT_ID = 0L;
/**
* 光伏板进度类别
*/
String PHOTOVOLTAIC_PANEL_WORK_TYPE = "1";
/**
* 逆变器进度类别
*/
String INVERTER_WORK_TYPE = "2";
/**
* 箱变进度类别
*/
String BOX_TRANSFORMER_WORK_TYPE = "3";
/**
* 光伏板钻孔进度类别
*/
String PHOTOVOLTAIC_PANEL_POINT_WORK_TYPE = "12";
String PHOTOVOLTAIC_PANEL_POINT_WORK_TYPE = "4";
/**
* 光伏板桩基进度类别
*/
String PHOTOVOLTAIC_PANEL_COLUMN_WORK_TYPE = "13";
String PHOTOVOLTAIC_PANEL_COLUMN_WORK_TYPE = "5";
/**
* 光伏板支架进度类别
*/
String PHOTOVOLTAIC_PANEL_SUPPORT_WORK_TYPE = "14";
String PHOTOVOLTAIC_PANEL_SUPPORT_WORK_TYPE = "6";
/**
* 光伏板进度类别名称
* 进度工作类别列表
*/
List<String> PHOTOVOLTAIC_PANEL_PROGRESS_CATEGORY_WORK_TYPE = List.of(
"15",
"16",
"17"
);
/**
* 关联光伏板进度类别名称
*/
List<String> RELEVANCE_PHOTOVOLTAIC_PANEL_WORK_TYPE = List.of(
"12",
"13",
"14"
);
/**
* 逆变器进度类别名称
*/
List<String> INVERTER_PROGRESS_CATEGORY_WORK_TYPE = List.of(
"2",
"3",
"4",
"18",
"19",
"20",
"21"
);
/**
* 箱变进度类别名称
*/
List<String> BOX_TRANSFORMER_PROGRESS_CATEGORY_WORK_TYPE = List.of(
"23",
"24",
"25",
"26",
"27",
"28"
List<String> WORK_TYPE_LIST = List.of(
PHOTOVOLTAIC_PANEL_WORK_TYPE,
INVERTER_WORK_TYPE,
BOX_TRANSFORMER_WORK_TYPE,
PHOTOVOLTAIC_PANEL_POINT_WORK_TYPE,
PHOTOVOLTAIC_PANEL_COLUMN_WORK_TYPE,
PHOTOVOLTAIC_PANEL_SUPPORT_WORK_TYPE
);
}

View File

@ -12,6 +12,7 @@ import org.dromara.common.log.annotation.Log;
import org.dromara.common.log.enums.BusinessType;
import org.dromara.common.web.core.BaseController;
import org.dromara.progress.domain.dto.progresscategory.PgsProgressCategoryCreatePriceReq;
import org.dromara.progress.domain.dto.progresscategory.PgsProgressCategoryCreateReq;
import org.dromara.progress.domain.dto.progresscategory.PgsProgressCategoryQueryReq;
import org.dromara.progress.domain.dto.progresscategory.PgsProgressCategoryUpdateReq;
import org.dromara.progress.domain.vo.progresscategory.PgsProgressCategoryCoordinateVo;
@ -118,6 +119,17 @@ public class PgsProgressCategoryController extends BaseController {
return toAjax(pgsProgressCategoryService.insertPrice(req));
}
/**
* 新增进度类别
*/
@SaCheckPermission("progress:progressCategory:add")
@Log(title = "进度类别", businessType = BusinessType.INSERT)
@RepeatSubmit()
@PostMapping()
public R<Void> insert(@Validated @RequestBody PgsProgressCategoryCreateReq req) {
return toAjax(pgsProgressCategoryService.insertByReq(req));
}
/**
* 修改进度类别
*/

View File

@ -52,6 +52,11 @@ public class PgsProgressCategoryTemplate implements Serializable {
*/
private Long projectId;
/**
* 施工类型
*/
private String constructionType;
/**
* 备注
*/

View File

@ -0,0 +1,71 @@
package org.dromara.progress.domain.dto.progresscategory;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* @author lilemy
* @date 2025-08-07 19:35
*/
@Data
public class PgsProgressCategoryCreateReq implements Serializable {
@Serial
private static final long serialVersionUID = 6264724604334298318L;
/**
* 父类别id
*/
@NotNull(message = "父类别id不能为空")
private Long parentId;
/**
* 方阵id
*/
@NotNull(message = "方阵id不能为空")
private Long matrixId;
/**
* 类别名称
*/
@NotBlank(message = "类别名称不能为空")
private String name;
/**
* 计量方式0无 1数量 2百分比
*/
@NotBlank(message = "计量方式不能为空")
private String unitType;
/**
* 计量单位
*/
@NotBlank(message = "计量单位不能为空")
private String unit;
/**
* 综合单价
*/
@NotNull(message = "综合单价不能为空")
private BigDecimal unitPrice;
/**
* 总数量
*/
private BigDecimal total;
/**
* 工作类型
*/
private String workType;
/**
* 备注
*/
private String remark;
}

View File

@ -1,5 +1,6 @@
package org.dromara.progress.domain.dto.progresscategory;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import java.math.BigDecimal;
@ -14,6 +15,7 @@ public class PgsProgressCategoryUpdateReq {
/**
* 主键id
*/
@NotNull(message = "id不能为空")
private Long id;
/**
@ -21,11 +23,6 @@ public class PgsProgressCategoryUpdateReq {
*/
private Long parentId;
/**
* 项目id
*/
private Long projectId;
/**
* 类别名称
*/
@ -41,26 +38,6 @@ public class PgsProgressCategoryUpdateReq {
*/
private BigDecimal total;
/**
* 已完成数量/百分比
*/
private BigDecimal completed;
/**
* 计划总数量/百分比
*/
private BigDecimal planTotal;
/**
* 是否超期0否 1是
*/
private String isDelay;
/**
* 完成状态0未开始 1进行中 2已完成
*/
private String status;
/**
* 备注
*/

View File

@ -1,5 +1,7 @@
package org.dromara.progress.domain.dto.progresscategorytemplate;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import java.io.Serial;
@ -18,23 +20,37 @@ public class PgsProgressCategoryTemplateCreateReq implements Serializable {
/**
* 父类别id
*/
@NotNull(message = "父类别id不能为空")
private Long parentId;
/**
* 类别名称
*/
@NotBlank(message = "类别名称不能为空")
private String name;
/**
* 计量方式0无 1数量 2百分比
*/
@NotBlank(message = "计量方式不能为空")
private String unitType;
/**
* 工作类型
*/
private String workType;
/**
* 项目id0表示共用
*/
@NotNull(message = "项目id不能为空")
private Long projectId;
/**
* 施工类型
*/
private String constructionType;
/**
* 备注
*/

View File

@ -34,4 +34,9 @@ public class PgsProgressCategoryTemplateQueryReq implements Serializable {
*/
private Long projectId;
/**
* 施工类型
*/
private String constructionType;
}

View File

@ -1,5 +1,6 @@
package org.dromara.progress.domain.dto.progresscategorytemplate;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import java.io.Serial;
@ -18,13 +19,21 @@ public class PgsProgressCategoryTemplateUpdateReq implements Serializable {
/**
* 主键id
*/
@NotNull(message = "主键id不能为空")
private Long id;
/**
* 父类别id
*/
@NotNull(message = "父类别id不能为空")
private Long parentId;
/**
* 项目id
*/
@NotNull(message = "项目id不能为空")
private Long projectId;
/**
* 类别名称
*/
@ -35,6 +44,16 @@ public class PgsProgressCategoryTemplateUpdateReq implements Serializable {
*/
private String unitType;
/**
* 工作类型
*/
private String workType;
/**
* 施工类型
*/
private String constructionType;
/**
* 备注
*/

View File

@ -136,4 +136,9 @@ public class PgsProgressCategoryVo implements Serializable {
@ExcelProperty(value = "产值金额")
private BigDecimal outputValue;
/**
* 工作类型
*/
private String workType;
}

View File

@ -1,11 +1,7 @@
package org.dromara.progress.domain.vo.progresscategorytemplate;
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.excel.annotation.ExcelDictFormat;
import org.dromara.common.excel.convert.ExcelDictConvert;
import org.dromara.progress.domain.PgsProgressCategoryTemplate;
import java.io.Serial;
@ -19,7 +15,6 @@ import java.io.Serializable;
* @date 2025-05-22
*/
@Data
@ExcelIgnoreUnannotated
@AutoMapper(target = PgsProgressCategoryTemplate.class)
public class PgsProgressCategoryTemplateVo implements Serializable {
@ -29,38 +24,41 @@ public class PgsProgressCategoryTemplateVo implements Serializable {
/**
* 主键id
*/
@ExcelProperty(value = "主键id")
private Long id;
/**
* 父类别id
*/
@ExcelProperty(value = "父类别id")
private Long parentId;
/**
* 类别名称
*/
@ExcelProperty(value = "类别名称")
private String name;
/**
* 计量方式0无 1数量 2百分比
*/
@ExcelProperty(value = "计量方式", converter = ExcelDictConvert.class)
@ExcelDictFormat(readConverterExp = "1=数量,2=百分比")
private String unitType;
/**
* 工作类型
*/
private String workType;
/**
* 项目id0表示共用
*/
@ExcelProperty(value = "项目id")
private Long projectId;
/**
* 施工类型
*/
private String constructionType;
/**
* 备注
*/
@ExcelProperty(value = "备注")
private String remark;
}

View File

@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
import org.dromara.facility.domain.FacMatrix;
import org.dromara.progress.domain.PgsProgressCategory;
import org.dromara.progress.domain.dto.progresscategory.PgsProgressCategoryCreatePriceReq;
import org.dromara.progress.domain.dto.progresscategory.PgsProgressCategoryCreateReq;
import org.dromara.progress.domain.dto.progresscategory.PgsProgressCategoryQueryReq;
import org.dromara.progress.domain.dto.progresscategory.PgsProgressCategoryUpdateReq;
import org.dromara.progress.domain.vo.progresscategory.PgsProgressCategoryCoordinateVo;
@ -47,6 +48,14 @@ public interface IPgsProgressCategoryService extends IService<PgsProgressCategor
*/
PgsProgressCategoryLastTimeVo queryLastTimeById(Long id);
/**
* 新增进度类别
*
* @param req 进度类别
* @return 是否新增成功
*/
Boolean insertByReq(PgsProgressCategoryCreateReq req);
/**
* 新增分项工程单价
*

View File

@ -72,6 +72,14 @@ public interface IPgsProgressCategoryTemplateService extends IService<PgsProgres
*/
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
/**
* 根据项目初始化进度类别模版
*
* @param projectId 项目id
* @return 是否初始化成功
*/
Boolean initTemplateByProject(Long projectId);
/**
* 获取进度类别模版视图对象
*

View File

@ -22,6 +22,7 @@ import org.dromara.progress.domain.PgsProgressCategoryTemplate;
import org.dromara.progress.domain.PgsProgressPlan;
import org.dromara.progress.domain.PgsProgressPlanDetail;
import org.dromara.progress.domain.dto.progresscategory.PgsProgressCategoryCreatePriceReq;
import org.dromara.progress.domain.dto.progresscategory.PgsProgressCategoryCreateReq;
import org.dromara.progress.domain.dto.progresscategory.PgsProgressCategoryQueryReq;
import org.dromara.progress.domain.dto.progresscategory.PgsProgressCategoryUpdateReq;
import org.dromara.progress.domain.enums.PgsCoordinateTypeEnum;
@ -91,6 +92,18 @@ public class PgsProgressCategoryServiceImpl extends ServiceImpl<PgsProgressCateg
@Resource
private IFacMatrixService matrixService;
@Lazy
@Resource
private IFacPhotovoltaicPanelPointService photovoltaicPanelPointService;
@Lazy
@Resource
private IFacPhotovoltaicPanelColumnService photovoltaicPanelColumnService;
@Lazy
@Resource
private IFacPhotovoltaicPanelSupportService photovoltaicPanelSupportService;
/**
* 查询进度类别
*
@ -159,6 +172,68 @@ public class PgsProgressCategoryServiceImpl extends ServiceImpl<PgsProgressCateg
return lastTimeVo;
}
/**
* 新增进度类别
*
* @param req 进度类别
* @return 是否新增成功
*/
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean insertByReq(PgsProgressCategoryCreateReq req) {
BigDecimal unitPrice = req.getUnitPrice();
BigDecimal total = req.getTotal();
String workType = req.getWorkType();
PgsProgressCategory progressCategory = new PgsProgressCategory();
BeanUtils.copyProperties(req, progressCategory);
validEntityBeforeSave(progressCategory);
// 计算产值
if (unitPrice != null && total != null && unitPrice.compareTo(BigDecimal.ZERO) >= 0 && total.compareTo(BigDecimal.ZERO) >= 0) {
progressCategory.setOutputValue(unitPrice.multiply(total));
}
if (StringUtils.isNotBlank(workType) && PgsProgressCategoryConstant.WORK_TYPE_LIST.contains(workType)) {
List<PgsProgressCategory> progressCategoryList = this.lambdaQuery()
.eq(PgsProgressCategory::getMatrixId, req.getMatrixId())
.likeRight(PgsProgressCategory::getWorkType, workType + "_")
.list();
// 获取当前关联数据类别的最大数
int maxNum = progressCategoryList.stream()
.map(PgsProgressCategory::getWorkType)
.mapToInt(s -> Integer.parseInt(s.substring(s.indexOf('_') + 1)))
.max()
.orElse(0);
progressCategory.setWorkType(workType + "_" + (maxNum + 1));
// 保存新添加的进度类别
boolean save = this.save(progressCategory);
if (!save) {
throw new ServiceException("新增分项工程信息异常", HttpStatus.ERROR);
}
if (CollUtil.isNotEmpty(progressCategoryList)) {
// 根据模版创建数据
switch (workType) {
case PgsProgressCategoryConstant.PHOTOVOLTAIC_PANEL_WORK_TYPE ->
photovoltaicPanelService.insertByCategoryTemp(progressCategory, progressCategoryList);
case PgsProgressCategoryConstant.INVERTER_WORK_TYPE ->
inverterService.insertByCategoryTemp(progressCategory, progressCategoryList);
case PgsProgressCategoryConstant.BOX_TRANSFORMER_WORK_TYPE ->
boxTransformerService.insertByCategoryTemp(progressCategory, progressCategoryList);
case PgsProgressCategoryConstant.PHOTOVOLTAIC_PANEL_POINT_WORK_TYPE ->
photovoltaicPanelPointService.insertByCategoryTemp(progressCategory, progressCategoryList);
case PgsProgressCategoryConstant.PHOTOVOLTAIC_PANEL_COLUMN_WORK_TYPE ->
photovoltaicPanelColumnService.insertByCategoryTemp(progressCategory, progressCategoryList);
case PgsProgressCategoryConstant.PHOTOVOLTAIC_PANEL_SUPPORT_WORK_TYPE ->
photovoltaicPanelSupportService.insertByCategoryTemp(progressCategory, progressCategoryList);
}
}
} else {
boolean save = this.save(progressCategory);
if (!save) {
throw new ServiceException("新增分项工程信息异常", HttpStatus.ERROR);
}
}
return true;
}
/**
* 新增分项工程单价
*
@ -178,10 +253,19 @@ public class PgsProgressCategoryServiceImpl extends ServiceImpl<PgsProgressCateg
if (progressCategory.getUnitType().equals(PgsProgressUnitTypeEnum.PERCENTAGE.getValue())) {
progressCategory.setTotal(req.getTotal());
outputValue = req.getTotal().multiply(unitPrice);
} else if (progressCategory.getUnitType().equals(PgsProgressUnitTypeEnum.NUMBER.getValue()) && progressCategory.getWorkType() != null) {
BigDecimal total = progressCategory.getTotal();
if (total == null || total.compareTo(BigDecimal.ZERO) <= 0) {
throw new ServiceException("请导入分项工程数量后再添加单价", HttpStatus.BAD_REQUEST);
}
outputValue = total.multiply(unitPrice);
} else if (progressCategory.getUnitType().equals(PgsProgressUnitTypeEnum.NUMBER.getValue())) {
BigDecimal total = progressCategory.getTotal();
if (total.compareTo(BigDecimal.ZERO) <= 0) {
throw new ServiceException("请导入分项工程数量后再添加单价", HttpStatus.BAD_REQUEST);
if (total == null || total.compareTo(BigDecimal.ZERO) <= 0) {
total = req.getTotal();
}
if (total == null || total.compareTo(BigDecimal.ZERO) <= 0) {
throw new ServiceException("请输入分项工程数量", HttpStatus.BAD_REQUEST);
}
outputValue = total.multiply(unitPrice);
}
@ -222,28 +306,25 @@ public class PgsProgressCategoryServiceImpl extends ServiceImpl<PgsProgressCateg
* 保存前的数据校验
*/
private void validEntityBeforeSave(PgsProgressCategory entity) {
// TODO 做一些数据校验,如唯一约束
Long projectId = entity.getProjectId();
Long matrixId = entity.getMatrixId();
Long parentId = entity.getParentId();
if (projectId != null && projectId != 0) {
if (projectService.getById(projectId) == null) {
throw new ServiceException("对应项目不存在", HttpStatus.NOT_FOUND);
if (matrixId != null && matrixId != 0) {
FacMatrix matrix = matrixService.getById(matrixId);
if (matrix == null) {
throw new ServiceException("对应方阵不存在", HttpStatus.NOT_FOUND);
}
entity.setProjectId(matrix.getProjectId());
}
if (parentId != null && parentId != 0) {
if (this.getById(parentId) == null) {
throw new ServiceException("对应进度类别不存在", HttpStatus.NOT_FOUND);
throw new ServiceException("对应进度类别不存在", HttpStatus.NOT_FOUND);
}
}
// 名称唯一性校验
LambdaQueryWrapper<PgsProgressCategory> lqw = new LambdaQueryWrapper<>();
lqw.eq(PgsProgressCategory::getName, entity.getName());
if (projectId != null && projectId != 0) {
lqw.eq(PgsProgressCategory::getProjectId, entity.getProjectId());
}
if (parentId != null && parentId != 0) {
lqw.eq(PgsProgressCategory::getParentId, entity.getParentId());
}
lqw.eq(PgsProgressCategory::getMatrixId, entity.getMatrixId());
lqw.eq(PgsProgressCategory::getParentId, entity.getParentId());
if (entity.getId() != null) {
// 排除自身
lqw.ne(PgsProgressCategory::getId, entity.getId());
@ -263,6 +344,7 @@ public class PgsProgressCategoryServiceImpl extends ServiceImpl<PgsProgressCateg
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
// todo 添加校验
return this.removeBatchByIds(ids);
}
@ -280,6 +362,10 @@ public class PgsProgressCategoryServiceImpl extends ServiceImpl<PgsProgressCateg
// 对象转封装类
PgsProgressCategoryVo progressCategoryVo = new PgsProgressCategoryVo();
BeanUtils.copyProperties(progressCategory, progressCategoryVo);
String workType = progressCategory.getWorkType();
if (StringUtils.isNotBlank(workType)) {
progressCategoryVo.setWorkType(workType.split("_")[0]);
}
return progressCategoryVo;
}
@ -322,6 +408,10 @@ public class PgsProgressCategoryServiceImpl extends ServiceImpl<PgsProgressCateg
return progressCategoryList.stream().map(progressCategory -> {
PgsProgressCategoryVo vo = new PgsProgressCategoryVo();
BeanUtils.copyProperties(progressCategory, vo);
String workType = progressCategory.getWorkType();
if (StringUtils.isNotBlank(workType)) {
vo.setWorkType(workType.split("_")[0]);
}
// 如果是父节点,计算其子节点的总和
if (progressCategory.getParentId() == 0) {
List<PgsProgressCategory> children = parentIdToChildrenMap.getOrDefault(progressCategory.getId(), Collections.emptyList());
@ -381,7 +471,7 @@ public class PgsProgressCategoryServiceImpl extends ServiceImpl<PgsProgressCateg
public Boolean insertByTemplate(Long projectId, List<FacMatrix> matrixList, List<FacMatrix> oldMatrixList) {
// 获取模板进度类别
List<PgsProgressCategoryTemplate> categoryTemplateList = pgsProgressCategoryTemplateService.lambdaQuery()
.in(PgsProgressCategoryTemplate::getProjectId, projectId, PgsProgressCategoryConstant.PUBLIC_PROJECT_ID)
.eq(PgsProgressCategoryTemplate::getProjectId, projectId)
.list();
// 遍历模板进度类别,复制数据
if (CollUtil.isEmpty(categoryTemplateList)) {
@ -563,62 +653,68 @@ public class PgsProgressCategoryServiceImpl extends ServiceImpl<PgsProgressCateg
String workType = progressCategory.getWorkType();
List<PgsProgressCategoryFacilityVo> facilityList;
PgsProgressCategoryCoordinateVo coordinateVo = new PgsProgressCategoryCoordinateVo();
if (PgsProgressCategoryConstant.PHOTOVOLTAIC_PANEL_PROGRESS_CATEGORY_WORK_TYPE.contains(workType)) {
List<FacPhotovoltaicPanel> list = photovoltaicPanelService.lambdaQuery()
.eq(FacPhotovoltaicPanel::getProjectId, progressCategory.getProjectId())
.eq(FacPhotovoltaicPanel::getMatrixId, progressCategory.getMatrixId())
.eq(FacPhotovoltaicPanel::getProgressCategoryId, progressCategory.getId())
.list();
facilityList = list.stream().map(fac -> {
JSONArray jsonArray = JSONUtil.parseArray(fac.getPositions());
int depth = JsonDimensionUtil.getJsonArrayDepth(jsonArray);
return new PgsProgressCategoryFacilityVo(
fac.getId(),
fac.getName(),
jsonArray,
PgsCoordinateTypeEnum.getTextByValue(depth),
fac.getStatus(),
fac.getFinishDate()
);
}).toList();
} else if (PgsProgressCategoryConstant.INVERTER_PROGRESS_CATEGORY_WORK_TYPE.contains(workType)) {
List<FacInverter> list = inverterService.lambdaQuery()
.eq(FacInverter::getProjectId, progressCategory.getProjectId())
.eq(FacInverter::getMatrixId, progressCategory.getMatrixId())
.eq(FacInverter::getProgressCategoryId, progressCategory.getId())
.list();
facilityList = list.stream().map(fac -> {
JSONArray jsonArray = JSONUtil.parseArray(fac.getPositions());
int depth = JsonDimensionUtil.getJsonArrayDepth(jsonArray);
return new PgsProgressCategoryFacilityVo(
fac.getId(),
fac.getName(),
jsonArray,
PgsCoordinateTypeEnum.getTextByValue(depth),
fac.getStatus(),
fac.getFinishDate()
);
}).toList();
} else if (PgsProgressCategoryConstant.BOX_TRANSFORMER_PROGRESS_CATEGORY_WORK_TYPE.contains(workType)) {
List<FacBoxTransformer> list = boxTransformerService.lambdaQuery()
.eq(FacBoxTransformer::getProjectId, progressCategory.getProjectId())
.eq(FacBoxTransformer::getMatrixId, progressCategory.getMatrixId())
.eq(FacBoxTransformer::getProgressCategoryId, progressCategory.getId())
.list();
facilityList = list.stream().map(fac -> {
JSONArray jsonArray = JSONUtil.parseArray(fac.getPositions());
int depth = JsonDimensionUtil.getJsonArrayDepth(jsonArray);
return new PgsProgressCategoryFacilityVo(
fac.getId(),
fac.getName(),
jsonArray,
PgsCoordinateTypeEnum.getTextByValue(depth),
fac.getStatus(),
fac.getFinishDate()
);
}).toList();
} else {
return coordinateVo;
String type = workType.split("_")[0];
switch (type) {
case PgsProgressCategoryConstant.PHOTOVOLTAIC_PANEL_WORK_TYPE -> {
List<FacPhotovoltaicPanel> list = photovoltaicPanelService.lambdaQuery()
.eq(FacPhotovoltaicPanel::getProjectId, progressCategory.getProjectId())
.eq(FacPhotovoltaicPanel::getMatrixId, progressCategory.getMatrixId())
.eq(FacPhotovoltaicPanel::getProgressCategoryId, progressCategory.getId())
.list();
facilityList = list.stream().map(fac -> {
JSONArray jsonArray = JSONUtil.parseArray(fac.getPositions());
int depth = JsonDimensionUtil.getJsonArrayDepth(jsonArray);
return new PgsProgressCategoryFacilityVo(
fac.getId(),
fac.getName(),
jsonArray,
PgsCoordinateTypeEnum.getTextByValue(depth),
fac.getStatus(),
fac.getFinishDate()
);
}).toList();
}
case PgsProgressCategoryConstant.INVERTER_WORK_TYPE -> {
List<FacInverter> list = inverterService.lambdaQuery()
.eq(FacInverter::getProjectId, progressCategory.getProjectId())
.eq(FacInverter::getMatrixId, progressCategory.getMatrixId())
.eq(FacInverter::getProgressCategoryId, progressCategory.getId())
.list();
facilityList = list.stream().map(fac -> {
JSONArray jsonArray = JSONUtil.parseArray(fac.getPositions());
int depth = JsonDimensionUtil.getJsonArrayDepth(jsonArray);
return new PgsProgressCategoryFacilityVo(
fac.getId(),
fac.getName(),
jsonArray,
PgsCoordinateTypeEnum.getTextByValue(depth),
fac.getStatus(),
fac.getFinishDate()
);
}).toList();
}
case PgsProgressCategoryConstant.BOX_TRANSFORMER_WORK_TYPE -> {
List<FacBoxTransformer> list = boxTransformerService.lambdaQuery()
.eq(FacBoxTransformer::getProjectId, progressCategory.getProjectId())
.eq(FacBoxTransformer::getMatrixId, progressCategory.getMatrixId())
.eq(FacBoxTransformer::getProgressCategoryId, progressCategory.getId())
.list();
facilityList = list.stream().map(fac -> {
JSONArray jsonArray = JSONUtil.parseArray(fac.getPositions());
int depth = JsonDimensionUtil.getJsonArrayDepth(jsonArray);
return new PgsProgressCategoryFacilityVo(
fac.getId(),
fac.getName(),
jsonArray,
PgsCoordinateTypeEnum.getTextByValue(depth),
fac.getStatus(),
fac.getFinishDate()
);
}).toList();
}
case null, default -> {
return coordinateVo;
}
}
List<PgsProgressPlanDetailDateVo> detailList = progressPlanDetailService.lambdaQuery()
.select(PgsProgressPlanDetail::getId,

View File

@ -2,9 +2,12 @@ package org.dromara.progress.service.impl;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.dromara.common.core.constant.HttpStatus;
import org.dromara.common.core.exception.ServiceException;
import org.dromara.common.core.utils.ObjectUtils;
@ -19,12 +22,13 @@ import org.dromara.progress.domain.dto.progresscategorytemplate.PgsProgressCateg
import org.dromara.progress.domain.vo.progresscategorytemplate.PgsProgressCategoryTemplateVo;
import org.dromara.progress.mapper.PgsProgressCategoryTemplateMapper;
import org.dromara.progress.service.IPgsProgressCategoryTemplateService;
import org.dromara.project.domain.BusProject;
import org.dromara.project.service.IBusProjectService;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Collection;
import java.util.List;
import java.util.*;
/**
* 进度类别模版Service业务层处理
@ -32,10 +36,14 @@ import java.util.List;
* @author lilemy
* @date 2025-05-22
*/
@Slf4j
@Service
public class PgsProgressCategoryTemplateServiceImpl extends ServiceImpl<PgsProgressCategoryTemplateMapper, PgsProgressCategoryTemplate>
implements IPgsProgressCategoryTemplateService {
@Resource
private IBusProjectService projectService;
/**
* 查询进度类别模版
*
@ -87,8 +95,14 @@ public class PgsProgressCategoryTemplateServiceImpl extends ServiceImpl<PgsProgr
// 将实体类和 DTO 进行转换
PgsProgressCategoryTemplate progressCategoryTemplate = new PgsProgressCategoryTemplate();
BeanUtils.copyProperties(req, progressCategoryTemplate);
Long projectId = req.getProjectId();
String constructionType = req.getConstructionType();
if (projectId == 0 && constructionType == null) {
throw new ServiceException("请选择项目施工类型", HttpStatus.BAD_REQUEST);
}
// 数据校验
validEntityBeforeSave(progressCategoryTemplate);
progressCategoryTemplate.setWorkType(this.getTempWorkType(progressCategoryTemplate));
// 写入数据库
boolean result = this.save(progressCategoryTemplate);
if (!result) {
@ -114,6 +128,7 @@ public class PgsProgressCategoryTemplateServiceImpl extends ServiceImpl<PgsProgr
}
// 数据校验
validEntityBeforeSave(progressCategoryTemplate);
progressCategoryTemplate.setWorkType(this.getTempWorkType(progressCategoryTemplate));
// 写入数据库
boolean result = this.updateById(progressCategoryTemplate);
if (!result) {
@ -128,26 +143,26 @@ public class PgsProgressCategoryTemplateServiceImpl extends ServiceImpl<PgsProgr
private void validEntityBeforeSave(PgsProgressCategoryTemplate entity) {
// TODO 做一些数据校验,如唯一约束
Long projectId = entity.getProjectId();
Long pid = entity.getParentId();
if (projectId != null && projectId != 0) {
if (this.getById(projectId) == null) {
Long parentId = entity.getParentId();
if (projectId != 0) {
BusProject project = projectService.getById(projectId);
if (project == null) {
throw new ServiceException("对应项目不存在", HttpStatus.NOT_FOUND);
}
if (entity.getConstructionType() == null) {
entity.setConstructionType(project.getProjectType());
}
}
if (pid != null && pid != 0) {
if (this.getById(pid) == null) {
if (parentId != 0) {
if (this.getById(parentId) == null) {
throw new ServiceException("对应进度类别模版不存在", HttpStatus.NOT_FOUND);
}
}
// 名称唯一性校验
LambdaQueryWrapper<PgsProgressCategoryTemplate> lqw = new LambdaQueryWrapper<>();
lqw.eq(PgsProgressCategoryTemplate::getName, entity.getName());
if (projectId != null && projectId != 0) {
lqw.eq(PgsProgressCategoryTemplate::getProjectId, entity.getProjectId());
}
if (pid != null && pid != 0) {
lqw.eq(PgsProgressCategoryTemplate::getParentId, entity.getParentId());
}
lqw.eq(PgsProgressCategoryTemplate::getProjectId, entity.getProjectId());
lqw.eq(PgsProgressCategoryTemplate::getParentId, entity.getParentId());
if (entity.getId() != null) {
// 排除自身
lqw.ne(PgsProgressCategoryTemplate::getId, entity.getId());
@ -179,6 +194,61 @@ public class PgsProgressCategoryTemplateServiceImpl extends ServiceImpl<PgsProgr
return this.removeBatchByIds(ids);
}
/**
* 根据项目初始化进度类别模版
*
* @param projectId 项目id
* @return 是否初始化成功
*/
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean initTemplateByProject(Long projectId) {
BusProject project = projectService.getById(projectId);
if (project == null) {
throw new ServiceException("项目不存在", HttpStatus.NOT_FOUND);
}
// 获取模板进度类别
List<PgsProgressCategoryTemplate> categoryTemplateList = this.lambdaQuery()
.eq(PgsProgressCategoryTemplate::getProjectId, PgsProgressCategoryConstant.PUBLIC_PROJECT_ID)
.eq(PgsProgressCategoryTemplate::getConstructionType, project.getProjectType())
.list();
// 遍历模板进度类别,复制数据
if (CollUtil.isEmpty(categoryTemplateList)) {
throw new ServiceException("对应模板进度类别不存在", HttpStatus.NOT_FOUND);
}
// templateId -> newId
Map<Long, Long> localIdMap = new HashMap<>();
List<PgsProgressCategoryTemplate> localList = new ArrayList<>();
for (PgsProgressCategoryTemplate temp : categoryTemplateList) {
Long newId = IdWorker.getId();
localIdMap.put(temp.getId(), newId);
PgsProgressCategoryTemplate newTemp = new PgsProgressCategoryTemplate();
newTemp.setId(newId);
newTemp.setName(temp.getName());
newTemp.setUnitType(temp.getUnitType());
newTemp.setWorkType(temp.getWorkType());
newTemp.setProjectId(projectId);
newTemp.setConstructionType(temp.getConstructionType());
newTemp.setRemark(temp.getRemark());
// 先临时设置旧 pid
newTemp.setParentId(temp.getParentId());
localList.add(newTemp);
}
// 修正本 matrix 的 pid
for (PgsProgressCategoryTemplate template : localList) {
Long oldPid = template.getParentId();
if (oldPid != 0) {
template.setParentId(localIdMap.getOrDefault(oldPid, 0L));
}
}
// 批量保存新进度类别模版
boolean save = this.saveBatch(localList);
if (!save) {
throw new ServiceException("创建进度类别模版失败", HttpStatus.ERROR);
}
return true;
}
/**
* 获取进度类别模版视图对象
*
@ -193,6 +263,10 @@ public class PgsProgressCategoryTemplateServiceImpl extends ServiceImpl<PgsProgr
// 对象转封装类
PgsProgressCategoryTemplateVo progressCategoryTemplateVo = new PgsProgressCategoryTemplateVo();
BeanUtils.copyProperties(progressCategoryTemplate, progressCategoryTemplateVo);
String workType = progressCategoryTemplate.getWorkType();
if (StringUtils.isNotBlank(workType)) {
progressCategoryTemplateVo.setWorkType(workType.split("_")[0]);
}
return progressCategoryTemplateVo;
}
@ -239,9 +313,38 @@ public class PgsProgressCategoryTemplateServiceImpl extends ServiceImpl<PgsProgr
// 对象转封装类
PgsProgressCategoryTemplateVo progressCategoryTemplateVo = new PgsProgressCategoryTemplateVo();
BeanUtils.copyProperties(progressCategoryTemplate, progressCategoryTemplateVo);
String workType = progressCategoryTemplate.getWorkType();
if (StringUtils.isNotBlank(workType)) {
progressCategoryTemplateVo.setWorkType(workType.split("_")[0]);
}
return progressCategoryTemplateVo;
}).toList();
progressCategoryTemplateVoPage.setRecords(progressCategoryTemplateVoList);
return progressCategoryTemplateVoPage;
}
/**
* 获取项目进度类别模板关联数据
*
* @param newTemplate 新进度类型模版
* @return 关联数据字符串例如1_2 2_4 3_5
*/
private String getTempWorkType(PgsProgressCategoryTemplate newTemplate) {
String workType = newTemplate.getWorkType();
if (StringUtils.isNotBlank(workType) && PgsProgressCategoryConstant.WORK_TYPE_LIST.contains(workType)) {
List<PgsProgressCategoryTemplate> progressCategoryList = this.lambdaQuery()
.eq(PgsProgressCategoryTemplate::getProjectId, newTemplate.getProjectId())
.likeRight(PgsProgressCategoryTemplate::getWorkType, workType + "_")
.list();
// 获取当前关联数据类别的最大数
int maxNum = progressCategoryList.stream()
.map(PgsProgressCategoryTemplate::getWorkType)
.mapToInt(s -> Integer.parseInt(s.substring(s.indexOf('_') + 1)))
.max()
.orElse(0);
return workType + "_" + (maxNum + 1);
} else {
return null;
}
}
}

View File

@ -137,6 +137,7 @@ public class PgsProgressPlanDetailServiceImpl extends ServiceImpl<PgsProgressPla
throw new ServiceException("进度计划类别信息不存在", HttpStatus.NOT_FOUND);
}
String workType = progressCategory.getWorkType();
String type = workType.split("_")[0];
List<PgsProgressPlanDetailFinishedVo> finishedDetailList = JSONUtil.toList(progressPlanDetail.getFinishedDetail(), PgsProgressPlanDetailFinishedVo.class);
Set<Long> idSet = new HashSet<>(finishedDetailIdList);
List<String> matchedNames = finishedDetailList.stream()
@ -146,110 +147,116 @@ public class PgsProgressPlanDetailServiceImpl extends ServiceImpl<PgsProgressPla
if (CollUtil.isNotEmpty(matchedNames)) {
throw new ServiceException("设施:" + String.join(",", matchedNames) + "已完成,请勿重复提交", HttpStatus.BAD_REQUEST);
}
if (PgsProgressCategoryConstant.PHOTOVOLTAIC_PANEL_PROGRESS_CATEGORY_WORK_TYPE.contains(workType)) {
List<PgsProgressPlanDetailFinishedVo> finishedVoList = handleFacilityFinish(
projectId,
progressCategoryId,
finishedDetailIdList,
planDate,
photovoltaicPanelService,
FacPhotovoltaicPanel::getId,
FacPhotovoltaicPanel::getName,
FacPhotovoltaicPanel::getFinishType,
FacPhotovoltaicPanel::getFinishDate,
FacPhotovoltaicPanel::getProjectId,
FacPhotovoltaicPanel::getProgressCategoryId,
FacPhotovoltaicPanel::getId,
FacPhotovoltaicPanel::getStatus
);
finishedDetailList.addAll(finishedVoList);
} else if (PgsProgressCategoryConstant.INVERTER_PROGRESS_CATEGORY_WORK_TYPE.contains(workType)) {
List<PgsProgressPlanDetailFinishedVo> finishedVoList = handleFacilityFinish(
projectId,
progressCategoryId,
finishedDetailIdList,
planDate,
inverterService,
FacInverter::getId,
FacInverter::getName,
FacInverter::getFinishType,
FacInverter::getFinishDate,
FacInverter::getProjectId,
FacInverter::getProgressCategoryId,
FacInverter::getId,
FacInverter::getStatus
);
finishedDetailList.addAll(finishedVoList);
} else if (PgsProgressCategoryConstant.BOX_TRANSFORMER_PROGRESS_CATEGORY_WORK_TYPE.contains(workType)) {
List<PgsProgressPlanDetailFinishedVo> finishedVoList = handleFacilityFinish(
projectId,
progressCategoryId,
finishedDetailIdList,
planDate,
boxTransformerService,
FacBoxTransformer::getId,
FacBoxTransformer::getName,
FacBoxTransformer::getFinishType,
FacBoxTransformer::getFinishDate,
FacBoxTransformer::getProjectId,
FacBoxTransformer::getProgressCategoryId,
FacBoxTransformer::getId,
FacBoxTransformer::getStatus
);
finishedDetailList.addAll(finishedVoList);
} else if (PgsProgressCategoryConstant.PHOTOVOLTAIC_PANEL_POINT_WORK_TYPE.contains(workType)) {
List<PgsProgressPlanDetailFinishedVo> finishedVoList = handleFacilityFinish(
projectId,
progressCategoryId,
finishedDetailIdList,
planDate,
photovoltaicPanelPointService,
FacPhotovoltaicPanelPoint::getId,
FacPhotovoltaicPanelPoint::getName,
FacPhotovoltaicPanelPoint::getFinishType,
FacPhotovoltaicPanelPoint::getFinishDate,
FacPhotovoltaicPanelPoint::getProjectId,
FacPhotovoltaicPanelPoint::getProgressCategoryId,
FacPhotovoltaicPanelPoint::getId,
FacPhotovoltaicPanelPoint::getStatus
);
finishedDetailList.addAll(finishedVoList);
} else if (PgsProgressCategoryConstant.PHOTOVOLTAIC_PANEL_COLUMN_WORK_TYPE.contains(workType)) {
List<PgsProgressPlanDetailFinishedVo> finishedVoList = handleFacilityFinish(
projectId,
progressCategoryId,
finishedDetailIdList,
planDate,
photovoltaicPanelColumnService,
FacPhotovoltaicPanelColumn::getId,
FacPhotovoltaicPanelColumn::getName,
FacPhotovoltaicPanelColumn::getFinishType,
FacPhotovoltaicPanelColumn::getFinishDate,
FacPhotovoltaicPanelColumn::getProjectId,
FacPhotovoltaicPanelColumn::getProgressCategoryId,
FacPhotovoltaicPanelColumn::getId,
FacPhotovoltaicPanelColumn::getStatus
);
finishedDetailList.addAll(finishedVoList);
} else if (PgsProgressCategoryConstant.PHOTOVOLTAIC_PANEL_SUPPORT_WORK_TYPE.contains(workType)) {
List<PgsProgressPlanDetailFinishedVo> finishedVoList = handleFacilityFinish(
projectId,
progressCategoryId,
finishedDetailIdList,
planDate,
photovoltaicPanelSupportService,
FacPhotovoltaicPanelSupport::getId,
FacPhotovoltaicPanelSupport::getName,
FacPhotovoltaicPanelSupport::getFinishType,
FacPhotovoltaicPanelSupport::getFinishDate,
FacPhotovoltaicPanelSupport::getProjectId,
FacPhotovoltaicPanelSupport::getProgressCategoryId,
FacPhotovoltaicPanelSupport::getId,
FacPhotovoltaicPanelSupport::getStatus
);
finishedDetailList.addAll(finishedVoList);
} else {
throw new ServiceException("未定义的进度计划类别", HttpStatus.BAD_REQUEST);
switch (type) {
case PgsProgressCategoryConstant.PHOTOVOLTAIC_PANEL_WORK_TYPE -> {
List<PgsProgressPlanDetailFinishedVo> finishedVoList = handleFacilityFinish(
projectId,
progressCategoryId,
finishedDetailIdList,
planDate,
photovoltaicPanelService,
FacPhotovoltaicPanel::getId,
FacPhotovoltaicPanel::getName,
FacPhotovoltaicPanel::getFinishType,
FacPhotovoltaicPanel::getFinishDate,
FacPhotovoltaicPanel::getProjectId,
FacPhotovoltaicPanel::getProgressCategoryId,
FacPhotovoltaicPanel::getId,
FacPhotovoltaicPanel::getStatus
);
finishedDetailList.addAll(finishedVoList);
}
case PgsProgressCategoryConstant.INVERTER_WORK_TYPE -> {
List<PgsProgressPlanDetailFinishedVo> finishedVoList = handleFacilityFinish(
projectId,
progressCategoryId,
finishedDetailIdList,
planDate,
inverterService,
FacInverter::getId,
FacInverter::getName,
FacInverter::getFinishType,
FacInverter::getFinishDate,
FacInverter::getProjectId,
FacInverter::getProgressCategoryId,
FacInverter::getId,
FacInverter::getStatus
);
finishedDetailList.addAll(finishedVoList);
}
case PgsProgressCategoryConstant.BOX_TRANSFORMER_WORK_TYPE -> {
List<PgsProgressPlanDetailFinishedVo> finishedVoList = handleFacilityFinish(
projectId,
progressCategoryId,
finishedDetailIdList,
planDate,
boxTransformerService,
FacBoxTransformer::getId,
FacBoxTransformer::getName,
FacBoxTransformer::getFinishType,
FacBoxTransformer::getFinishDate,
FacBoxTransformer::getProjectId,
FacBoxTransformer::getProgressCategoryId,
FacBoxTransformer::getId,
FacBoxTransformer::getStatus
);
finishedDetailList.addAll(finishedVoList);
}
case PgsProgressCategoryConstant.PHOTOVOLTAIC_PANEL_POINT_WORK_TYPE -> {
List<PgsProgressPlanDetailFinishedVo> finishedVoList = handleFacilityFinish(
projectId,
progressCategoryId,
finishedDetailIdList,
planDate,
photovoltaicPanelPointService,
FacPhotovoltaicPanelPoint::getId,
FacPhotovoltaicPanelPoint::getName,
FacPhotovoltaicPanelPoint::getFinishType,
FacPhotovoltaicPanelPoint::getFinishDate,
FacPhotovoltaicPanelPoint::getProjectId,
FacPhotovoltaicPanelPoint::getProgressCategoryId,
FacPhotovoltaicPanelPoint::getId,
FacPhotovoltaicPanelPoint::getStatus
);
finishedDetailList.addAll(finishedVoList);
}
case PgsProgressCategoryConstant.PHOTOVOLTAIC_PANEL_COLUMN_WORK_TYPE -> {
List<PgsProgressPlanDetailFinishedVo> finishedVoList = handleFacilityFinish(
projectId,
progressCategoryId,
finishedDetailIdList,
planDate,
photovoltaicPanelColumnService,
FacPhotovoltaicPanelColumn::getId,
FacPhotovoltaicPanelColumn::getName,
FacPhotovoltaicPanelColumn::getFinishType,
FacPhotovoltaicPanelColumn::getFinishDate,
FacPhotovoltaicPanelColumn::getProjectId,
FacPhotovoltaicPanelColumn::getProgressCategoryId,
FacPhotovoltaicPanelColumn::getId,
FacPhotovoltaicPanelColumn::getStatus
);
finishedDetailList.addAll(finishedVoList);
}
case PgsProgressCategoryConstant.PHOTOVOLTAIC_PANEL_SUPPORT_WORK_TYPE -> {
List<PgsProgressPlanDetailFinishedVo> finishedVoList = handleFacilityFinish(
projectId,
progressCategoryId,
finishedDetailIdList,
planDate,
photovoltaicPanelSupportService,
FacPhotovoltaicPanelSupport::getId,
FacPhotovoltaicPanelSupport::getName,
FacPhotovoltaicPanelSupport::getFinishType,
FacPhotovoltaicPanelSupport::getFinishDate,
FacPhotovoltaicPanelSupport::getProjectId,
FacPhotovoltaicPanelSupport::getProgressCategoryId,
FacPhotovoltaicPanelSupport::getId,
FacPhotovoltaicPanelSupport::getStatus
);
finishedDetailList.addAll(finishedVoList);
}
case null, default -> throw new ServiceException("未定义的进度计划类别", HttpStatus.BAD_REQUEST);
}
PgsProgressPlanDetail detail = new PgsProgressPlanDetail();
detail.setId(id);
@ -392,98 +399,105 @@ public class PgsProgressPlanDetailServiceImpl extends ServiceImpl<PgsProgressPla
throw new ServiceException("进度计划类别信息不存在", HttpStatus.NOT_FOUND);
}
String workType = progressCategory.getWorkType();
if (PgsProgressCategoryConstant.PHOTOVOLTAIC_PANEL_PROGRESS_CATEGORY_WORK_TYPE.contains(workType)) {
LambdaQueryWrapper<FacPhotovoltaicPanel> lqw = new LambdaQueryWrapper<>();
lqw.select(FacPhotovoltaicPanel::getId, FacPhotovoltaicPanel::getName, FacPhotovoltaicPanel::getStatus);
lqw.eq(FacPhotovoltaicPanel::getProjectId, progressPlanDetail.getProjectId());
lqw.eq(FacPhotovoltaicPanel::getProgressCategoryId, progressCategoryId);
lqw.in(FacPhotovoltaicPanel::getStatus, FacFinishStatusEnum.UNFINISH.getValue(), FacFinishStatusEnum.INPROGRESS.getValue());
Page<FacPhotovoltaicPanel> page = photovoltaicPanelService.page(pageQuery.build(), lqw);
Page<PgsProgressPlanDetailUnFinishVo> voPage = PageConvertUtil.convert(page, entity -> {
PgsProgressPlanDetailUnFinishVo vo = new PgsProgressPlanDetailUnFinishVo();
vo.setId(entity.getId());
vo.setName(entity.getName());
vo.setStatus(entity.getStatus());
return vo;
});
return TableDataInfo.build(voPage);
} else if (PgsProgressCategoryConstant.INVERTER_PROGRESS_CATEGORY_WORK_TYPE.contains(workType)) {
LambdaQueryWrapper<FacInverter> lqw = new LambdaQueryWrapper<>();
lqw.select(FacInverter::getId, FacInverter::getName, FacInverter::getStatus);
lqw.eq(FacInverter::getProjectId, progressPlanDetail.getProjectId());
lqw.eq(FacInverter::getProgressCategoryId, progressCategoryId);
lqw.in(FacInverter::getStatus, FacFinishStatusEnum.UNFINISH.getValue(), FacFinishStatusEnum.INPROGRESS.getValue());
Page<FacInverter> page = inverterService.page(pageQuery.build(), lqw);
Page<PgsProgressPlanDetailUnFinishVo> voPage = PageConvertUtil.convert(page, entity -> {
PgsProgressPlanDetailUnFinishVo vo = new PgsProgressPlanDetailUnFinishVo();
vo.setId(entity.getId());
vo.setName(entity.getName());
vo.setStatus(entity.getStatus());
return vo;
});
return TableDataInfo.build(voPage);
} else if (PgsProgressCategoryConstant.BOX_TRANSFORMER_PROGRESS_CATEGORY_WORK_TYPE.contains(workType)) {
LambdaQueryWrapper<FacBoxTransformer> lqw = new LambdaQueryWrapper<>();
lqw.select(FacBoxTransformer::getId, FacBoxTransformer::getName, FacBoxTransformer::getStatus);
lqw.eq(FacBoxTransformer::getProjectId, progressPlanDetail.getProjectId());
lqw.eq(FacBoxTransformer::getProgressCategoryId, progressCategoryId);
lqw.in(FacBoxTransformer::getStatus, FacFinishStatusEnum.UNFINISH.getValue(), FacFinishStatusEnum.INPROGRESS.getValue());
Page<FacBoxTransformer> page = boxTransformerService.page(pageQuery.build(), lqw);
Page<PgsProgressPlanDetailUnFinishVo> voPage = PageConvertUtil.convert(page, entity -> {
PgsProgressPlanDetailUnFinishVo vo = new PgsProgressPlanDetailUnFinishVo();
vo.setId(entity.getId());
vo.setName(entity.getName());
vo.setStatus(entity.getStatus());
return vo;
});
return TableDataInfo.build(voPage);
} else if (PgsProgressCategoryConstant.PHOTOVOLTAIC_PANEL_POINT_WORK_TYPE.contains(workType)) {
LambdaQueryWrapper<FacPhotovoltaicPanelPoint> lqw = new LambdaQueryWrapper<>();
lqw.select(FacPhotovoltaicPanelPoint::getId, FacPhotovoltaicPanelPoint::getName, FacPhotovoltaicPanelPoint::getStatus);
lqw.eq(FacPhotovoltaicPanelPoint::getProjectId, progressPlanDetail.getProjectId());
lqw.eq(FacPhotovoltaicPanelPoint::getProgressCategoryId, progressCategoryId);
lqw.in(FacPhotovoltaicPanelPoint::getStatus, FacFinishStatusEnum.UNFINISH.getValue(), FacFinishStatusEnum.INPROGRESS.getValue());
Page<FacPhotovoltaicPanelPoint> page = photovoltaicPanelPointService.page(pageQuery.build(), lqw);
Page<PgsProgressPlanDetailUnFinishVo> voPage = PageConvertUtil.convert(page, entity -> {
PgsProgressPlanDetailUnFinishVo vo = new PgsProgressPlanDetailUnFinishVo();
vo.setId(entity.getId());
vo.setName(entity.getName());
vo.setStatus(entity.getStatus());
return vo;
});
return TableDataInfo.build(voPage);
} else if (PgsProgressCategoryConstant.PHOTOVOLTAIC_PANEL_COLUMN_WORK_TYPE.contains(workType)) {
LambdaQueryWrapper<FacPhotovoltaicPanelColumn> lqw = new LambdaQueryWrapper<>();
lqw.select(FacPhotovoltaicPanelColumn::getId, FacPhotovoltaicPanelColumn::getName, FacPhotovoltaicPanelColumn::getStatus);
lqw.eq(FacPhotovoltaicPanelColumn::getProjectId, progressPlanDetail.getProjectId());
lqw.eq(FacPhotovoltaicPanelColumn::getProgressCategoryId, progressCategoryId);
lqw.in(FacPhotovoltaicPanelColumn::getStatus, FacFinishStatusEnum.UNFINISH.getValue(), FacFinishStatusEnum.INPROGRESS.getValue());
Page<FacPhotovoltaicPanelColumn> page = photovoltaicPanelColumnService.page(pageQuery.build(), lqw);
Page<PgsProgressPlanDetailUnFinishVo> voPage = PageConvertUtil.convert(page, entity -> {
PgsProgressPlanDetailUnFinishVo vo = new PgsProgressPlanDetailUnFinishVo();
vo.setId(entity.getId());
vo.setName(entity.getName());
vo.setStatus(entity.getStatus());
return vo;
});
return TableDataInfo.build(voPage);
} else if (PgsProgressCategoryConstant.PHOTOVOLTAIC_PANEL_SUPPORT_WORK_TYPE.contains(workType)) {
LambdaQueryWrapper<FacPhotovoltaicPanelSupport> lqw = new LambdaQueryWrapper<>();
lqw.select(FacPhotovoltaicPanelSupport::getId, FacPhotovoltaicPanelSupport::getName, FacPhotovoltaicPanelSupport::getStatus);
lqw.eq(FacPhotovoltaicPanelSupport::getProjectId, progressPlanDetail.getProjectId());
lqw.eq(FacPhotovoltaicPanelSupport::getProgressCategoryId, progressCategoryId);
lqw.in(FacPhotovoltaicPanelSupport::getStatus, FacFinishStatusEnum.UNFINISH.getValue(), FacFinishStatusEnum.INPROGRESS.getValue());
Page<FacPhotovoltaicPanelSupport> page = photovoltaicPanelSupportService.page(pageQuery.build(), lqw);
Page<PgsProgressPlanDetailUnFinishVo> voPage = PageConvertUtil.convert(page, entity -> {
PgsProgressPlanDetailUnFinishVo vo = new PgsProgressPlanDetailUnFinishVo();
vo.setId(entity.getId());
vo.setName(entity.getName());
vo.setStatus(entity.getStatus());
return vo;
});
return TableDataInfo.build(voPage);
} else {
throw new ServiceException("未定义的进度计划类别", HttpStatus.BAD_REQUEST);
String type = workType.split("_")[0];
switch (type) {
case PgsProgressCategoryConstant.PHOTOVOLTAIC_PANEL_WORK_TYPE -> {
LambdaQueryWrapper<FacPhotovoltaicPanel> lqw = new LambdaQueryWrapper<>();
lqw.select(FacPhotovoltaicPanel::getId, FacPhotovoltaicPanel::getName, FacPhotovoltaicPanel::getStatus);
lqw.eq(FacPhotovoltaicPanel::getProjectId, progressPlanDetail.getProjectId());
lqw.eq(FacPhotovoltaicPanel::getProgressCategoryId, progressCategoryId);
lqw.in(FacPhotovoltaicPanel::getStatus, FacFinishStatusEnum.UNFINISH.getValue(), FacFinishStatusEnum.INPROGRESS.getValue());
Page<FacPhotovoltaicPanel> page = photovoltaicPanelService.page(pageQuery.build(), lqw);
Page<PgsProgressPlanDetailUnFinishVo> voPage = PageConvertUtil.convert(page, entity -> {
PgsProgressPlanDetailUnFinishVo vo = new PgsProgressPlanDetailUnFinishVo();
vo.setId(entity.getId());
vo.setName(entity.getName());
vo.setStatus(entity.getStatus());
return vo;
});
return TableDataInfo.build(voPage);
}
case PgsProgressCategoryConstant.INVERTER_WORK_TYPE -> {
LambdaQueryWrapper<FacInverter> lqw = new LambdaQueryWrapper<>();
lqw.select(FacInverter::getId, FacInverter::getName, FacInverter::getStatus);
lqw.eq(FacInverter::getProjectId, progressPlanDetail.getProjectId());
lqw.eq(FacInverter::getProgressCategoryId, progressCategoryId);
lqw.in(FacInverter::getStatus, FacFinishStatusEnum.UNFINISH.getValue(), FacFinishStatusEnum.INPROGRESS.getValue());
Page<FacInverter> page = inverterService.page(pageQuery.build(), lqw);
Page<PgsProgressPlanDetailUnFinishVo> voPage = PageConvertUtil.convert(page, entity -> {
PgsProgressPlanDetailUnFinishVo vo = new PgsProgressPlanDetailUnFinishVo();
vo.setId(entity.getId());
vo.setName(entity.getName());
vo.setStatus(entity.getStatus());
return vo;
});
return TableDataInfo.build(voPage);
}
case PgsProgressCategoryConstant.BOX_TRANSFORMER_WORK_TYPE -> {
LambdaQueryWrapper<FacBoxTransformer> lqw = new LambdaQueryWrapper<>();
lqw.select(FacBoxTransformer::getId, FacBoxTransformer::getName, FacBoxTransformer::getStatus);
lqw.eq(FacBoxTransformer::getProjectId, progressPlanDetail.getProjectId());
lqw.eq(FacBoxTransformer::getProgressCategoryId, progressCategoryId);
lqw.in(FacBoxTransformer::getStatus, FacFinishStatusEnum.UNFINISH.getValue(), FacFinishStatusEnum.INPROGRESS.getValue());
Page<FacBoxTransformer> page = boxTransformerService.page(pageQuery.build(), lqw);
Page<PgsProgressPlanDetailUnFinishVo> voPage = PageConvertUtil.convert(page, entity -> {
PgsProgressPlanDetailUnFinishVo vo = new PgsProgressPlanDetailUnFinishVo();
vo.setId(entity.getId());
vo.setName(entity.getName());
vo.setStatus(entity.getStatus());
return vo;
});
return TableDataInfo.build(voPage);
}
case PgsProgressCategoryConstant.PHOTOVOLTAIC_PANEL_POINT_WORK_TYPE -> {
LambdaQueryWrapper<FacPhotovoltaicPanelPoint> lqw = new LambdaQueryWrapper<>();
lqw.select(FacPhotovoltaicPanelPoint::getId, FacPhotovoltaicPanelPoint::getName, FacPhotovoltaicPanelPoint::getStatus);
lqw.eq(FacPhotovoltaicPanelPoint::getProjectId, progressPlanDetail.getProjectId());
lqw.eq(FacPhotovoltaicPanelPoint::getProgressCategoryId, progressCategoryId);
lqw.in(FacPhotovoltaicPanelPoint::getStatus, FacFinishStatusEnum.UNFINISH.getValue(), FacFinishStatusEnum.INPROGRESS.getValue());
Page<FacPhotovoltaicPanelPoint> page = photovoltaicPanelPointService.page(pageQuery.build(), lqw);
Page<PgsProgressPlanDetailUnFinishVo> voPage = PageConvertUtil.convert(page, entity -> {
PgsProgressPlanDetailUnFinishVo vo = new PgsProgressPlanDetailUnFinishVo();
vo.setId(entity.getId());
vo.setName(entity.getName());
vo.setStatus(entity.getStatus());
return vo;
});
return TableDataInfo.build(voPage);
}
case PgsProgressCategoryConstant.PHOTOVOLTAIC_PANEL_COLUMN_WORK_TYPE -> {
LambdaQueryWrapper<FacPhotovoltaicPanelColumn> lqw = new LambdaQueryWrapper<>();
lqw.select(FacPhotovoltaicPanelColumn::getId, FacPhotovoltaicPanelColumn::getName, FacPhotovoltaicPanelColumn::getStatus);
lqw.eq(FacPhotovoltaicPanelColumn::getProjectId, progressPlanDetail.getProjectId());
lqw.eq(FacPhotovoltaicPanelColumn::getProgressCategoryId, progressCategoryId);
lqw.in(FacPhotovoltaicPanelColumn::getStatus, FacFinishStatusEnum.UNFINISH.getValue(), FacFinishStatusEnum.INPROGRESS.getValue());
Page<FacPhotovoltaicPanelColumn> page = photovoltaicPanelColumnService.page(pageQuery.build(), lqw);
Page<PgsProgressPlanDetailUnFinishVo> voPage = PageConvertUtil.convert(page, entity -> {
PgsProgressPlanDetailUnFinishVo vo = new PgsProgressPlanDetailUnFinishVo();
vo.setId(entity.getId());
vo.setName(entity.getName());
vo.setStatus(entity.getStatus());
return vo;
});
return TableDataInfo.build(voPage);
}
case PgsProgressCategoryConstant.PHOTOVOLTAIC_PANEL_SUPPORT_WORK_TYPE -> {
LambdaQueryWrapper<FacPhotovoltaicPanelSupport> lqw = new LambdaQueryWrapper<>();
lqw.select(FacPhotovoltaicPanelSupport::getId, FacPhotovoltaicPanelSupport::getName, FacPhotovoltaicPanelSupport::getStatus);
lqw.eq(FacPhotovoltaicPanelSupport::getProjectId, progressPlanDetail.getProjectId());
lqw.eq(FacPhotovoltaicPanelSupport::getProgressCategoryId, progressCategoryId);
lqw.in(FacPhotovoltaicPanelSupport::getStatus, FacFinishStatusEnum.UNFINISH.getValue(), FacFinishStatusEnum.INPROGRESS.getValue());
Page<FacPhotovoltaicPanelSupport> page = photovoltaicPanelSupportService.page(pageQuery.build(), lqw);
Page<PgsProgressPlanDetailUnFinishVo> voPage = PageConvertUtil.convert(page, entity -> {
PgsProgressPlanDetailUnFinishVo vo = new PgsProgressPlanDetailUnFinishVo();
vo.setId(entity.getId());
vo.setName(entity.getName());
vo.setStatus(entity.getStatus());
return vo;
});
return TableDataInfo.build(voPage);
}
case null, default -> throw new ServiceException("未定义的进度计划类别", HttpStatus.BAD_REQUEST);
}
}
@ -525,104 +539,111 @@ public class PgsProgressPlanDetailServiceImpl extends ServiceImpl<PgsProgressPla
List<PgsProgressPlanDetailFinishedVo> finishedVoList = JSONUtil.toList(finishedDetail, PgsProgressPlanDetailFinishedVo.class);
PgsProgressCategory progressCategory = progressCategoryService.getById(progressPlanDetail.getProgressCategoryId());
String workType = progressCategory.getWorkType();
if (PgsProgressCategoryConstant.PHOTOVOLTAIC_PANEL_PROGRESS_CATEGORY_WORK_TYPE.contains(workType)) {
List<FacPhotovoltaicPanel> list = photovoltaicPanelService.lambdaQuery()
.in(FacPhotovoltaicPanel::getId, detailIdList)
.list();
if (CollUtil.isEmpty(list) || list.size() != removeTotal) {
throw new ServiceException("设施数据丢失", HttpStatus.NOT_FOUND);
String type = workType.split("_")[0];
switch (type) {
case PgsProgressCategoryConstant.PHOTOVOLTAIC_PANEL_WORK_TYPE -> {
List<FacPhotovoltaicPanel> list = photovoltaicPanelService.lambdaQuery()
.in(FacPhotovoltaicPanel::getId, detailIdList)
.list();
if (CollUtil.isEmpty(list) || list.size() != removeTotal) {
throw new ServiceException("设施数据丢失", HttpStatus.NOT_FOUND);
}
LambdaUpdateWrapper<FacPhotovoltaicPanel> lqw = new LambdaUpdateWrapper<>();
lqw.in(FacPhotovoltaicPanel::getId, detailIdList);
lqw.set(FacPhotovoltaicPanel::getStatus, FacFinishStatusEnum.UNFINISH.getValue());
lqw.set(FacPhotovoltaicPanel::getFinishType, null);
lqw.set(FacPhotovoltaicPanel::getFinishDate, null);
boolean update = photovoltaicPanelService.update(lqw);
if (!update) {
throw new ServiceException("修改设施数据失败,数据库异常", HttpStatus.ERROR);
}
}
LambdaUpdateWrapper<FacPhotovoltaicPanel> lqw = new LambdaUpdateWrapper<>();
lqw.in(FacPhotovoltaicPanel::getId, detailIdList);
lqw.set(FacPhotovoltaicPanel::getStatus, FacFinishStatusEnum.UNFINISH.getValue());
lqw.set(FacPhotovoltaicPanel::getFinishType, null);
lqw.set(FacPhotovoltaicPanel::getFinishDate, null);
boolean update = photovoltaicPanelService.update(lqw);
if (!update) {
throw new ServiceException("修改设施数据失败,数据库异常", HttpStatus.ERROR);
case PgsProgressCategoryConstant.INVERTER_WORK_TYPE -> {
List<FacInverter> list = inverterService.lambdaQuery()
.in(FacInverter::getId, detailIdList)
.list();
if (CollUtil.isEmpty(list) || list.size() != removeTotal) {
throw new ServiceException("设施数据丢失", HttpStatus.NOT_FOUND);
}
LambdaUpdateWrapper<FacInverter> lqw = new LambdaUpdateWrapper<>();
lqw.in(FacInverter::getId, detailIdList);
lqw.set(FacInverter::getStatus, FacFinishStatusEnum.UNFINISH.getValue());
lqw.set(FacInverter::getFinishType, null);
lqw.set(FacInverter::getFinishDate, null);
boolean update = inverterService.update(lqw);
if (!update) {
throw new ServiceException("修改设施数据失败,数据库异常", HttpStatus.ERROR);
}
}
} else if (PgsProgressCategoryConstant.INVERTER_PROGRESS_CATEGORY_WORK_TYPE.contains(workType)) {
List<FacInverter> list = inverterService.lambdaQuery()
.in(FacInverter::getId, detailIdList)
.list();
if (CollUtil.isEmpty(list) || list.size() != removeTotal) {
throw new ServiceException("设施数据丢失", HttpStatus.NOT_FOUND);
case PgsProgressCategoryConstant.BOX_TRANSFORMER_WORK_TYPE -> {
List<FacBoxTransformer> list = boxTransformerService.lambdaQuery()
.in(FacBoxTransformer::getId, detailIdList)
.list();
if (CollUtil.isEmpty(list) || list.size() != removeTotal) {
throw new ServiceException("设施数据丢失", HttpStatus.NOT_FOUND);
}
LambdaUpdateWrapper<FacBoxTransformer> lqw = new LambdaUpdateWrapper<>();
lqw.in(FacBoxTransformer::getId, detailIdList);
lqw.set(FacBoxTransformer::getStatus, FacFinishStatusEnum.UNFINISH.getValue());
lqw.set(FacBoxTransformer::getFinishType, null);
lqw.set(FacBoxTransformer::getFinishDate, null);
boolean update = boxTransformerService.update(lqw);
if (!update) {
throw new ServiceException("修改设施数据失败,数据库异常", HttpStatus.ERROR);
}
}
LambdaUpdateWrapper<FacInverter> lqw = new LambdaUpdateWrapper<>();
lqw.in(FacInverter::getId, detailIdList);
lqw.set(FacInverter::getStatus, FacFinishStatusEnum.UNFINISH.getValue());
lqw.set(FacInverter::getFinishType, null);
lqw.set(FacInverter::getFinishDate, null);
boolean update = inverterService.update(lqw);
if (!update) {
throw new ServiceException("修改设施数据失败,数据库异常", HttpStatus.ERROR);
case PgsProgressCategoryConstant.PHOTOVOLTAIC_PANEL_POINT_WORK_TYPE -> {
List<FacPhotovoltaicPanelPoint> list = photovoltaicPanelPointService.lambdaQuery()
.in(FacPhotovoltaicPanelPoint::getId, detailIdList)
.list();
if (CollUtil.isEmpty(list) || list.size() != removeTotal) {
throw new ServiceException("设施数据丢失", HttpStatus.NOT_FOUND);
}
LambdaUpdateWrapper<FacPhotovoltaicPanelPoint> lqw = new LambdaUpdateWrapper<>();
lqw.in(FacPhotovoltaicPanelPoint::getId, detailIdList);
lqw.set(FacPhotovoltaicPanelPoint::getStatus, FacFinishStatusEnum.UNFINISH.getValue());
lqw.set(FacPhotovoltaicPanelPoint::getFinishType, null);
lqw.set(FacPhotovoltaicPanelPoint::getFinishDate, null);
boolean update = photovoltaicPanelPointService.update(lqw);
if (!update) {
throw new ServiceException("修改设施数据失败,数据库异常", HttpStatus.ERROR);
}
}
} else if (PgsProgressCategoryConstant.BOX_TRANSFORMER_PROGRESS_CATEGORY_WORK_TYPE.contains(workType)) {
List<FacBoxTransformer> list = boxTransformerService.lambdaQuery()
.in(FacBoxTransformer::getId, detailIdList)
.list();
if (CollUtil.isEmpty(list) || list.size() != removeTotal) {
throw new ServiceException("设施数据丢失", HttpStatus.NOT_FOUND);
case PgsProgressCategoryConstant.PHOTOVOLTAIC_PANEL_COLUMN_WORK_TYPE -> {
List<FacPhotovoltaicPanelColumn> list = photovoltaicPanelColumnService.lambdaQuery()
.in(FacPhotovoltaicPanelColumn::getId, detailIdList)
.list();
if (CollUtil.isEmpty(list) || list.size() != removeTotal) {
throw new ServiceException("设施数据丢失", HttpStatus.NOT_FOUND);
}
LambdaUpdateWrapper<FacPhotovoltaicPanelColumn> lqw = new LambdaUpdateWrapper<>();
lqw.in(FacPhotovoltaicPanelColumn::getId, detailIdList);
lqw.set(FacPhotovoltaicPanelColumn::getStatus, FacFinishStatusEnum.UNFINISH.getValue());
lqw.set(FacPhotovoltaicPanelColumn::getFinishType, null);
lqw.set(FacPhotovoltaicPanelColumn::getFinishDate, null);
boolean update = photovoltaicPanelColumnService.update(lqw);
if (!update) {
throw new ServiceException("修改设施数据失败,数据库异常", HttpStatus.ERROR);
}
}
LambdaUpdateWrapper<FacBoxTransformer> lqw = new LambdaUpdateWrapper<>();
lqw.in(FacBoxTransformer::getId, detailIdList);
lqw.set(FacBoxTransformer::getStatus, FacFinishStatusEnum.UNFINISH.getValue());
lqw.set(FacBoxTransformer::getFinishType, null);
lqw.set(FacBoxTransformer::getFinishDate, null);
boolean update = boxTransformerService.update(lqw);
if (!update) {
throw new ServiceException("修改设施数据失败,数据库异常", HttpStatus.ERROR);
case PgsProgressCategoryConstant.PHOTOVOLTAIC_PANEL_SUPPORT_WORK_TYPE -> {
List<FacPhotovoltaicPanelSupport> list = photovoltaicPanelSupportService.lambdaQuery()
.in(FacPhotovoltaicPanelSupport::getId, detailIdList)
.list();
if (CollUtil.isEmpty(list) || list.size() != removeTotal) {
throw new ServiceException("设施数据丢失", HttpStatus.NOT_FOUND);
}
LambdaUpdateWrapper<FacPhotovoltaicPanelSupport> lqw = new LambdaUpdateWrapper<>();
lqw.in(FacPhotovoltaicPanelSupport::getId, detailIdList);
lqw.set(FacPhotovoltaicPanelSupport::getStatus, FacFinishStatusEnum.UNFINISH.getValue());
lqw.set(FacPhotovoltaicPanelSupport::getFinishType, null);
lqw.set(FacPhotovoltaicPanelSupport::getFinishDate, null);
boolean update = photovoltaicPanelSupportService.update(lqw);
if (!update) {
throw new ServiceException("修改设施数据失败,数据库异常", HttpStatus.ERROR);
}
}
} else if (PgsProgressCategoryConstant.PHOTOVOLTAIC_PANEL_POINT_WORK_TYPE.contains(workType)) {
List<FacPhotovoltaicPanelPoint> list = photovoltaicPanelPointService.lambdaQuery()
.in(FacPhotovoltaicPanelPoint::getId, detailIdList)
.list();
if (CollUtil.isEmpty(list) || list.size() != removeTotal) {
throw new ServiceException("设施数据丢失", HttpStatus.NOT_FOUND);
}
LambdaUpdateWrapper<FacPhotovoltaicPanelPoint> lqw = new LambdaUpdateWrapper<>();
lqw.in(FacPhotovoltaicPanelPoint::getId, detailIdList);
lqw.set(FacPhotovoltaicPanelPoint::getStatus, FacFinishStatusEnum.UNFINISH.getValue());
lqw.set(FacPhotovoltaicPanelPoint::getFinishType, null);
lqw.set(FacPhotovoltaicPanelPoint::getFinishDate, null);
boolean update = photovoltaicPanelPointService.update(lqw);
if (!update) {
throw new ServiceException("修改设施数据失败,数据库异常", HttpStatus.ERROR);
}
} else if (PgsProgressCategoryConstant.PHOTOVOLTAIC_PANEL_COLUMN_WORK_TYPE.contains(workType)) {
List<FacPhotovoltaicPanelColumn> list = photovoltaicPanelColumnService.lambdaQuery()
.in(FacPhotovoltaicPanelColumn::getId, detailIdList)
.list();
if (CollUtil.isEmpty(list) || list.size() != removeTotal) {
throw new ServiceException("设施数据丢失", HttpStatus.NOT_FOUND);
}
LambdaUpdateWrapper<FacPhotovoltaicPanelColumn> lqw = new LambdaUpdateWrapper<>();
lqw.in(FacPhotovoltaicPanelColumn::getId, detailIdList);
lqw.set(FacPhotovoltaicPanelColumn::getStatus, FacFinishStatusEnum.UNFINISH.getValue());
lqw.set(FacPhotovoltaicPanelColumn::getFinishType, null);
lqw.set(FacPhotovoltaicPanelColumn::getFinishDate, null);
boolean update = photovoltaicPanelColumnService.update(lqw);
if (!update) {
throw new ServiceException("修改设施数据失败,数据库异常", HttpStatus.ERROR);
}
} else if (PgsProgressCategoryConstant.PHOTOVOLTAIC_PANEL_SUPPORT_WORK_TYPE.contains(workType)) {
List<FacPhotovoltaicPanelSupport> list = photovoltaicPanelSupportService.lambdaQuery()
.in(FacPhotovoltaicPanelSupport::getId, detailIdList)
.list();
if (CollUtil.isEmpty(list) || list.size() != removeTotal) {
throw new ServiceException("设施数据丢失", HttpStatus.NOT_FOUND);
}
LambdaUpdateWrapper<FacPhotovoltaicPanelSupport> lqw = new LambdaUpdateWrapper<>();
lqw.in(FacPhotovoltaicPanelSupport::getId, detailIdList);
lqw.set(FacPhotovoltaicPanelSupport::getStatus, FacFinishStatusEnum.UNFINISH.getValue());
lqw.set(FacPhotovoltaicPanelSupport::getFinishType, null);
lqw.set(FacPhotovoltaicPanelSupport::getFinishDate, null);
boolean update = photovoltaicPanelSupportService.update(lqw);
if (!update) {
throw new ServiceException("修改设施数据失败,数据库异常", HttpStatus.ERROR);
}
} else {
throw new ServiceException("未定义的进度计划类别", HttpStatus.BAD_REQUEST);
case null, default -> throw new ServiceException("未定义的进度计划类别", HttpStatus.BAD_REQUEST);
}
AtomicInteger finishType2Count = new AtomicInteger(0);
// 过滤出不需要删除的,生成新列表

View File

@ -22,6 +22,7 @@ import org.dromara.progress.domain.dto.progressplan.PgsProgressPlanQueryReq;
import org.dromara.progress.domain.dto.progressplandetail.PgsProgressPlanDetailCreateDto;
import org.dromara.progress.domain.enums.PgsDelayStatusEnum;
import org.dromara.progress.domain.enums.PgsFinishStatusEnum;
import org.dromara.progress.domain.enums.PgsProgressUnitTypeEnum;
import org.dromara.progress.domain.vo.progressplan.PgsProgressPlanVo;
import org.dromara.progress.domain.vo.progressplandetail.PgsProgressPlanDetailNumVo;
import org.dromara.progress.mapper.PgsProgressPlanMapper;
@ -329,20 +330,30 @@ public class PgsProgressPlanServiceImpl extends ServiceImpl<PgsProgressPlanMappe
if (progressCategory == null) {
throw new ServiceException("进度类别不存在", HttpStatus.NOT_FOUND);
}
if (planNumber.compareTo(BigDecimal.ZERO) <= 0) {
throw new ServiceException("计划数量不能小于等于0", HttpStatus.BAD_REQUEST);
}
String unitTypeMsg = "数量";
BigDecimal total = progressCategory.getTotal();
// 百分比项目需乘以总数
if (progressCategory.getUnitType().equals(PgsProgressUnitTypeEnum.PERCENTAGE.getValue())) {
planNumber = planNumber.multiply(total);
unitTypeMsg = "百分比";
}
if (planNumber.compareTo(BigDecimal.ZERO) <= 0) {
throw new ServiceException("计划" + unitTypeMsg + "不能小于等于0", HttpStatus.BAD_REQUEST);
}
BigDecimal completed = progressCategory.getCompleted();
BigDecimal planTotal = total.subtract(completed);
if (planNumber.compareTo(planTotal) > 0) {
throw new ServiceException("计划数量不能大于剩余数量", HttpStatus.BAD_REQUEST);
throw new ServiceException("计划" + unitTypeMsg + "不能大于剩余" + unitTypeMsg, HttpStatus.BAD_REQUEST);
}
// 如果计划数量大于未完成和计划的数量,则计划数量不合法
BigDecimal planAndFinishedNumberNumber = this.getCurrentPlanAndFinishedNumber(progressCategory);
BigDecimal leftNumber = progressCategory.getTotal().subtract(planAndFinishedNumberNumber);
// 百分比项目需乘以总数
if (progressCategory.getUnitType().equals(PgsProgressUnitTypeEnum.PERCENTAGE.getValue())) {
planAndFinishedNumberNumber = planAndFinishedNumberNumber.multiply(total);
}
BigDecimal leftNumber = total.subtract(planAndFinishedNumberNumber);
if (planNumber.compareTo(leftNumber) > 0) {
throw new ServiceException("计划数量不能大于当前完成数量和计划数量总和", HttpStatus.BAD_REQUEST);
throw new ServiceException("计划" + unitTypeMsg + "不能大于当前完成" + unitTypeMsg + "和计划" + unitTypeMsg + "总和", HttpStatus.BAD_REQUEST);
}
}

View File

@ -11,6 +11,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.dromara.common.constant.DesignMapFileConstant;
import org.dromara.common.core.constant.HttpStatus;
import org.dromara.common.core.exception.ServiceException;
import org.dromara.common.core.utils.ObjectUtils;
@ -20,7 +21,7 @@ import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.common.satoken.utils.LoginHelper;
import org.dromara.common.sse.dto.SseMessageDto;
import org.dromara.common.sse.utils.SseMessageUtils;
import org.dromara.common.constant.DesignMapFileConstant;
import org.dromara.common.utils.Dxf2JsonUtil;
import org.dromara.project.domain.BusProject;
import org.dromara.project.domain.BusProjectFile;
import org.dromara.project.domain.dto.projectfile.BusProjectFileQueryReq;
@ -30,7 +31,6 @@ import org.dromara.project.domain.vo.projectfile.BusProjectFileVo;
import org.dromara.project.mapper.BusProjectFileMapper;
import org.dromara.project.service.IBusProjectFileService;
import org.dromara.project.service.IBusProjectService;
import org.dromara.common.utils.Dxf2JsonUtil;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
@ -197,12 +197,13 @@ public class BusProjectFileServiceImpl extends ServiceImpl<BusProjectFileMapper,
throw new ServiceException("文件格式不正确只能解析json文件", HttpStatus.BAD_REQUEST);
}
JSONObject jsonObject;
String property = System.getProperty("user.dir");
Path path = Paths.get(property, filePath);
try {
String property = System.getProperty("user.dir");
Path path = Paths.get(property, filePath);
String jsonStr = Files.readString(path, StandardCharsets.UTF_8);
jsonObject = JSONUtil.parseObj(jsonStr);
} catch (IOException e) {
log.error("项目文件读取失败:读取路径{}", path);
throw new ServiceException("文件读取失败", HttpStatus.ERROR);
}
return jsonObject;

View File

@ -2,7 +2,6 @@ package org.dromara.project.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.PhoneUtil;
@ -11,7 +10,6 @@ import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
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.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@ -37,6 +35,7 @@ import org.dromara.facility.domain.vo.matrix.FacMatrixBySubProjectVo;
import org.dromara.facility.service.IFacMatrixService;
import org.dromara.manager.weathermanager.WeatherConstant;
import org.dromara.manager.weathermanager.WeatherManager;
import org.dromara.progress.service.IPgsProgressCategoryTemplateService;
import org.dromara.project.constant.BusProjectConstant;
import org.dromara.project.domain.BusProject;
import org.dromara.project.domain.BusProjectFile;
@ -60,7 +59,6 @@ import org.dromara.system.domain.enums.SysDeptTypeEnum;
import org.dromara.system.mapper.SysDeptMapper;
import org.dromara.workflow.service.IFlwDefinitionService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
@ -129,9 +127,13 @@ public class BusProjectServiceImpl extends ServiceImpl<BusProjectMapper, BusProj
@Resource
private IBusProjectService self;
@Autowired
@Resource
private IBusProjectPunchrangeService busProjectPunchrangeService;
@Lazy
@Resource
private IPgsProgressCategoryTemplateService progressCategoryTemplateService;
private final Cache<String, String> WEATHER_CACHE =
Caffeine.newBuilder().initialCapacity(1024)
.maximumSize(10000L)
@ -397,6 +399,7 @@ public class BusProjectServiceImpl extends ServiceImpl<BusProjectMapper, BusProj
BusProject subProject = new BusProject();
subProject.setPId(pId);
subProject.setProjectName(projectName);
subProject.setProjectType(project.getProjectType());
boolean save = this.save(subProject);
if (!save) {
throw new ServiceException("新增子项目失败,数据库异常", HttpStatus.ERROR);
@ -414,6 +417,11 @@ public class BusProjectServiceImpl extends ServiceImpl<BusProjectMapper, BusProj
if (!saveRelevancy) {
throw new ServiceException("新增用户与项目关联失败,数据库异常", HttpStatus.ERROR);
}
// 初始化施工类型模版
Boolean init = progressCategoryTemplateService.initTemplateByProject(subProjectId);
if (!init) {
throw new ServiceException("初始化项目施工类型模版失败,数据库异常", HttpStatus.ERROR);
}
return subProjectId;
}
@ -486,7 +494,7 @@ public class BusProjectServiceImpl extends ServiceImpl<BusProjectMapper, BusProj
}
}
// 操作数据库
if (this.updateById(project)){
if (this.updateById(project)) {
if (!req.getPunchrangeList().isEmpty()) {
//删除所有旧的范围
busProjectPunchrangeService.remove(Wrappers.lambdaQuery(BusProjectPunchrange.class).eq(BusProjectPunchrange::getProjectId, project.getId()));

View File

@ -2,7 +2,6 @@ package org.dromara.project.service.impl;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@ -20,14 +19,17 @@ import org.dromara.contractor.service.ISubConstructionUserService;
import org.dromara.project.domain.BusConstructionUserExit;
import org.dromara.project.domain.BusProjectTeam;
import org.dromara.project.domain.BusProjectTeamMember;
import org.dromara.project.domain.enums.BusProjectTeamMemberPostEnum;
import org.dromara.project.domain.dto.projectteammember.BusProjectTeamMemberCreateReq;
import org.dromara.project.domain.dto.projectteammember.BusProjectTeamMemberExitReq;
import org.dromara.project.domain.dto.projectteammember.BusProjectTeamMemberQueryReq;
import org.dromara.project.domain.dto.projectteammember.BusProjectTeamMemberUpdateReq;
import org.dromara.project.domain.enums.BusProjectTeamMemberPostEnum;
import org.dromara.project.domain.vo.projectteammember.BusProjectTeamMemberVo;
import org.dromara.project.mapper.BusProjectTeamMemberMapper;
import org.dromara.project.service.*;
import org.dromara.system.domain.SysUser;
import org.dromara.system.domain.vo.SysUserVo;
import org.dromara.system.service.ISysUserService;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -35,7 +37,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Objects;
import java.util.stream.Collectors;
/**
@ -51,6 +53,9 @@ public class BusProjectTeamMemberServiceImpl extends ServiceImpl<BusProjectTeamM
@Resource
private ISubConstructionUserService constructionUserService;
@Resource
private ISysUserService userService;
@Resource
private IBusProjectTeamService projectTeamService;
@ -125,11 +130,13 @@ public class BusProjectTeamMemberServiceImpl extends ServiceImpl<BusProjectTeamM
if (projectTeam == null) {
throw new ServiceException("对应班组不存在", HttpStatus.NOT_FOUND);
}
Long memberId = projectTeamMember.getMemberId();
SubConstructionUser constructionUser = constructionUserService.getBySysUserId(memberId);
// 判断用户是否已经被拉黑
constructionBlacklistService.validUserInBlacklist(projectTeamMember.getMemberId(), projectTeamMember.getProjectId());
constructionBlacklistService.validUserInBlacklist(constructionUser.getId(), projectTeamMember.getProjectId());
// 判断对应的用户与项目关联是否存在
BusProjectTeamMember teamMember = this.getOne(new LambdaQueryWrapper<BusProjectTeamMember>()
.eq(BusProjectTeamMember::getMemberId, projectTeamMember.getMemberId())
.eq(BusProjectTeamMember::getMemberId, memberId)
.eq(BusProjectTeamMember::getProjectId, projectTeamMember.getProjectId()));
if (teamMember != null) {
throw new ServiceException("当前用户已入场", HttpStatus.BAD_REQUEST);
@ -141,7 +148,7 @@ public class BusProjectTeamMemberServiceImpl extends ServiceImpl<BusProjectTeamM
}
// 同步修改用户表的team_id字段并添加入场时间
LambdaUpdateWrapper<SubConstructionUser> constructionUserLuw = Wrappers.lambdaUpdate(SubConstructionUser.class)
.eq(SubConstructionUser::getId, projectTeamMember.getMemberId())
.eq(SubConstructionUser::getId, constructionUser.getId())
.set(SubConstructionUser::getTeamId, projectTeamMember.getTeamId())
.set(SubConstructionUser::getTeamName, projectTeam.getTeamName())
.set(SubConstructionUser::getEntryDate, new Date())
@ -175,10 +182,12 @@ public class BusProjectTeamMemberServiceImpl extends ServiceImpl<BusProjectTeamM
if (oldProjectTeamMember == null) {
throw new ServiceException("修改项目班组下的成员,数据不存在", HttpStatus.NOT_FOUND);
}
Long memberId = projectTeamMember.getMemberId();
SubConstructionUser constructionUser = constructionUserService.getBySysUserId(memberId);
// 如果修改了班组信息,同步修改用户表的字段
if (!oldProjectTeamMember.getTeamId().equals(teamId)) {
LambdaUpdateWrapper<SubConstructionUser> constructionUserLuw = Wrappers.lambdaUpdate(SubConstructionUser.class)
.eq(SubConstructionUser::getId, projectTeamMember.getMemberId())
.eq(SubConstructionUser::getId, constructionUser.getId())
.set(SubConstructionUser::getTeamId, projectTeamMember.getTeamId())
.set(SubConstructionUser::getTeamName, projectTeam.getTeamName());
constructionUserService.update(constructionUserLuw);
@ -210,7 +219,7 @@ public class BusProjectTeamMemberServiceImpl extends ServiceImpl<BusProjectTeamM
if (projectService.getById(projectId) == null) {
throw new ServiceException("对应项目不存在", HttpStatus.NOT_FOUND);
}
if (constructionUserService.getById(memberId) == null) {
if (userService.selectUserById(memberId) == null) {
throw new ServiceException("对应人员不存在", HttpStatus.NOT_FOUND);
}
}
@ -241,7 +250,8 @@ public class BusProjectTeamMemberServiceImpl extends ServiceImpl<BusProjectTeamM
throw new ServiceException("删除项目班组下的成员失败,数据库异常", HttpStatus.ERROR);
}
// 将文件信息保存到数据库
SubConstructionUser constructionUser = constructionUserService.getById(projectTeamMember.getMemberId());
Long memberId = projectTeamMember.getMemberId();
SubConstructionUser constructionUser = constructionUserService.getBySysUserId(memberId);
BusConstructionUserExit constructionUserExit = new BusConstructionUserExit();
constructionUserExit.setProjectId(constructionUser.getProjectId());
constructionUserExit.setUserId(constructionUser.getId());
@ -254,7 +264,7 @@ public class BusProjectTeamMemberServiceImpl extends ServiceImpl<BusProjectTeamM
constructionUserExitService.save(constructionUserExit);
// 同步修改用户表的team_id字段
LambdaUpdateWrapper<SubConstructionUser> constructionUserLuw = Wrappers.lambdaUpdate(SubConstructionUser.class)
.eq(SubConstructionUser::getId, projectTeamMember.getMemberId())
.eq(SubConstructionUser::getId, constructionUser.getId())
.set(SubConstructionUser::getTeamId, null)
.set(SubConstructionUser::getLeaveDate, new Date());
constructionUserService.update(constructionUserLuw);
@ -277,8 +287,8 @@ public class BusProjectTeamMemberServiceImpl extends ServiceImpl<BusProjectTeamM
BeanUtils.copyProperties(projectTeamMember, projectTeamMemberVo);
// 关联获取施工人员信息
Long memberId = projectTeamMember.getMemberId();
SubConstructionUser constructionUser = constructionUserService.getById(memberId);
projectTeamMemberVo.setMemberName(constructionUser.getUserName());
SysUserVo userVo = userService.selectUserById(memberId);
projectTeamMemberVo.setMemberName(userVo.getNickName());
return projectTeamMemberVo;
}
@ -304,11 +314,12 @@ public class BusProjectTeamMemberServiceImpl extends ServiceImpl<BusProjectTeamM
String remark = req.getRemark();
// 联表查询
if (StringUtils.isNotBlank(memberName)) {
QueryWrapper<SubConstructionUser> constructionUserQueryWrapper = new QueryWrapper<>();
constructionUserQueryWrapper.select("id");
constructionUserQueryWrapper.like("user_name", memberName);
List<Long> constructionUserIdList = constructionUserService.listObjs(constructionUserQueryWrapper, obj -> (Long) obj);
lqw.in(BusProjectTeamMember::getMemberId, constructionUserIdList);
LambdaQueryWrapper<SysUser> sysUserLqw = new LambdaQueryWrapper<>();
sysUserLqw.select(SysUser::getUserId);
sysUserLqw.like(SysUser::getNickName, memberName);
List<SysUserVo> userVos = userService.selectUserListByNikeName(memberName);
List<Long> userIds = userVos.stream().map(SysUserVo::getUserId).distinct().filter(Objects::nonNull).toList();
lqw.in(BusProjectTeamMember::getMemberId, userIds);
}
// 模糊查询
lqw.like(StringUtils.isNotBlank(remark), BusProjectTeamMember::getRemark, remark);
@ -338,18 +349,18 @@ public class BusProjectTeamMemberServiceImpl extends ServiceImpl<BusProjectTeamM
return projectTeamMemberVoPage;
}
// 关联查询施工人员信息
Set<Long> teamMemberIdSet = projectTeamMemberList.stream().map(BusProjectTeamMember::getMemberId)
.collect(Collectors.toSet());
Map<Long, List<SubConstructionUser>> contractorIdContractorList = constructionUserService.listByIds(teamMemberIdSet).stream()
.collect(Collectors.groupingBy(SubConstructionUser::getId));
List<Long> teamMemberIds = projectTeamMemberList.stream().map(BusProjectTeamMember::getMemberId)
.distinct().toList();
List<SysUserVo> userVos = userService.selectUserByIds(teamMemberIds, null);
Map<Long, SysUserVo> userVoMap = userVos.stream().collect(Collectors.toMap(SysUserVo::getUserId, userVo -> userVo));
// 填充信息
List<BusProjectTeamMemberVo> projectTeamMemberVoList = projectTeamMemberList.stream().map(projectTeamMember -> {
BusProjectTeamMemberVo projectTeamMemberVo = new BusProjectTeamMemberVo();
BeanUtils.copyProperties(projectTeamMember, projectTeamMemberVo);
Long memberId = projectTeamMember.getMemberId();
String memberName = null;
if (contractorIdContractorList.containsKey(memberId)) {
memberName = contractorIdContractorList.get(memberId).get(0).getUserName();
if (userVoMap.containsKey(memberId)) {
memberName = userVoMap.get(memberId).getNickName();
}
projectTeamMemberVo.setMemberName(memberName);
return projectTeamMemberVo;

View File

@ -91,6 +91,14 @@ public interface ISysUserService {
*/
String selectUserPostGroup(Long userId);
/**
* 根据用户昵称获取用户列表
*
* @param nickName 用户昵称
* @return 用户列表
*/
List<SysUserVo> selectUserListByNikeName(String nickName);
/**
* 校验用户名称是否唯一
*

View File

@ -251,6 +251,18 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
return StreamUtils.join(list, SysPostVo::getPostName);
}
/**
* 根据用户昵称获取用户列表
*
* @param nickName 用户昵称
* @return 用户列表
*/
@Override
public List<SysUserVo> selectUserListByNikeName(String nickName) {
return baseMapper.selectUserList(new LambdaQueryWrapper<SysUser>()
.like(StringUtils.isNotBlank(nickName), SysUser::getNickName, nickName));
}
/**
* 校验用户名称是否唯一
*