[add] 添加定时任务,判断进度计划是否延期,并更新数据 [update] 修改进度计划相关逻辑
This commit is contained in:
@ -8,7 +8,6 @@ import org.dromara.facility.domain.FacMatrix;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
@ -43,22 +42,10 @@ public class FacMatrixVo implements Serializable {
|
||||
@ExcelProperty(value = "方阵名称")
|
||||
private String matrixName;
|
||||
|
||||
/**
|
||||
* 方阵位置
|
||||
*/
|
||||
@ExcelProperty(value = "方阵位置")
|
||||
private String positions;
|
||||
|
||||
/**
|
||||
* 方阵位置
|
||||
*/
|
||||
private List<List<String>> positionList;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@ExcelProperty(value = "备注")
|
||||
private String remark;
|
||||
|
||||
|
||||
}
|
||||
|
@ -73,4 +73,6 @@ public interface IFacPhotovoltaicPanelPartsService {
|
||||
*/
|
||||
Boolean validPartsExistByPhotovoltaicPanel(Long projectId, Collection<String> photovoltaicPanelNames);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -384,6 +384,7 @@ public class FacBoxTransformerServiceImpl extends ServiceImpl<FacBoxTransformerM
|
||||
lqw.eq(ObjectUtils.isNotEmpty(matrixId), FacBoxTransformer::getMatrixId, matrixId);
|
||||
lqw.eq(StringUtils.isNotBlank(status), FacBoxTransformer::getStatus, status);
|
||||
lqw.eq(StringUtils.isNotBlank(finishType), FacBoxTransformer::getFinishType, finishType);
|
||||
lqw.orderByAsc(FacBoxTransformer::getName);
|
||||
return lqw;
|
||||
}
|
||||
|
||||
|
@ -384,6 +384,7 @@ public class FacInverterServiceImpl extends ServiceImpl<FacInverterMapper, FacIn
|
||||
lqw.eq(ObjectUtils.isNotEmpty(matrixId), FacInverter::getMatrixId, matrixId);
|
||||
lqw.eq(StringUtils.isNotBlank(status), FacInverter::getStatus, status);
|
||||
lqw.eq(StringUtils.isNotBlank(finishType), FacInverter::getFinishType, finishType);
|
||||
lqw.orderByAsc(FacInverter::getName);
|
||||
return lqw;
|
||||
}
|
||||
|
||||
|
@ -455,16 +455,6 @@ public class FacMatrixServiceImpl extends ServiceImpl<FacMatrixMapper, FacMatrix
|
||||
return matrixVo;
|
||||
}
|
||||
BeanUtils.copyProperties(matrix, matrixVo);
|
||||
// 将 JSON 字符串转化为 List
|
||||
String positions = matrix.getPositions();
|
||||
if (StringUtils.isNotBlank(positions)) {
|
||||
List<List<String>> positionList = new ArrayList<>();
|
||||
List<String> arr = JSONUtil.toList(positions, String.class);
|
||||
for (String s : arr) {
|
||||
positionList.add(JSONUtil.toList(s, String.class));
|
||||
}
|
||||
matrixVo.setPositionList(positionList);
|
||||
}
|
||||
return matrixVo;
|
||||
}
|
||||
|
||||
@ -486,6 +476,8 @@ public class FacMatrixServiceImpl extends ServiceImpl<FacMatrixMapper, FacMatrix
|
||||
lqw.like(StringUtils.isNotBlank(matrixName), FacMatrix::getMatrixName, matrixName);
|
||||
// 精确查询
|
||||
lqw.eq(ObjectUtils.isNotEmpty(projectId), FacMatrix::getProjectId, projectId);
|
||||
// 排序
|
||||
lqw.orderByAsc(FacMatrix::getMatrixName);
|
||||
return lqw;
|
||||
}
|
||||
|
||||
|
@ -252,6 +252,7 @@ public class FacPhotovoltaicPanelColumnServiceImpl extends ServiceImpl<FacPhotov
|
||||
lqw.eq(ObjectUtils.isNotEmpty(matrixId), FacPhotovoltaicPanelColumn::getMatrixId, matrixId);
|
||||
lqw.eq(StringUtils.isNotBlank(status), FacPhotovoltaicPanelColumn::getStatus, status);
|
||||
lqw.eq(StringUtils.isNotBlank(finishType), FacPhotovoltaicPanelColumn::getFinishType, finishType);
|
||||
lqw.orderByAsc(FacPhotovoltaicPanelColumn::getName);
|
||||
return lqw;
|
||||
}
|
||||
|
||||
|
@ -252,6 +252,7 @@ public class FacPhotovoltaicPanelPointServiceImpl extends ServiceImpl<FacPhotovo
|
||||
lqw.eq(ObjectUtils.isNotEmpty(matrixId), FacPhotovoltaicPanelPoint::getMatrixId, matrixId);
|
||||
lqw.eq(StringUtils.isNotBlank(status), FacPhotovoltaicPanelPoint::getStatus, status);
|
||||
lqw.eq(StringUtils.isNotBlank(finishType), FacPhotovoltaicPanelPoint::getFinishType, finishType);
|
||||
lqw.orderByAsc(FacPhotovoltaicPanelPoint::getName);
|
||||
return lqw;
|
||||
}
|
||||
|
||||
|
@ -533,6 +533,7 @@ public class FacPhotovoltaicPanelServiceImpl extends ServiceImpl<FacPhotovoltaic
|
||||
lqw.eq(ObjectUtils.isNotEmpty(matrixId), FacPhotovoltaicPanel::getMatrixId, matrixId);
|
||||
lqw.eq(StringUtils.isNotBlank(status), FacPhotovoltaicPanel::getStatus, status);
|
||||
lqw.eq(StringUtils.isNotBlank(finishType), FacPhotovoltaicPanel::getFinishType, finishType);
|
||||
lqw.orderByAsc(FacPhotovoltaicPanel::getName);
|
||||
return lqw;
|
||||
}
|
||||
|
||||
|
@ -252,6 +252,7 @@ public class FacPhotovoltaicPanelSupportServiceImpl extends ServiceImpl<FacPhoto
|
||||
lqw.eq(ObjectUtils.isNotEmpty(matrixId), FacPhotovoltaicPanelSupport::getMatrixId, matrixId);
|
||||
lqw.eq(StringUtils.isNotBlank(status), FacPhotovoltaicPanelSupport::getStatus, status);
|
||||
lqw.eq(StringUtils.isNotBlank(finishType), FacPhotovoltaicPanelSupport::getFinishType, finishType);
|
||||
lqw.orderByAsc(FacPhotovoltaicPanelSupport::getName);
|
||||
return lqw;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,30 @@
|
||||
package org.dromara.job.cycle;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.progress.service.IPgsProgressPlanService;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author lcj
|
||||
* @date 2025/5/29 9:38
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class IncSyncValidProgressPlanIsDelay {
|
||||
|
||||
@Resource
|
||||
private IPgsProgressPlanService progressPlanService;
|
||||
|
||||
// 每天凌晨 12 点执行
|
||||
@Scheduled(cron = "0 0 0 * * ?")
|
||||
public void run() {
|
||||
log.info("执行定时任务:判断施工进度是否延期");
|
||||
Boolean result = progressPlanService.validProgressPlanIsDelay();
|
||||
if (result) {
|
||||
log.info("延期施工进度设置成功");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -13,6 +13,8 @@ public interface PgsProgressCategoryConstant {
|
||||
*/
|
||||
Long PUBLIC_PROJECT_ID = 0L;
|
||||
|
||||
String PHOTOVOLTAIC_PANEL_WORK_TYPE = "15";
|
||||
|
||||
/**
|
||||
* 光伏板进度类别名称
|
||||
*/
|
||||
@ -25,6 +27,15 @@ public interface PgsProgressCategoryConstant {
|
||||
"17"
|
||||
);
|
||||
|
||||
/**
|
||||
* 关联光伏板进度类别名称
|
||||
*/
|
||||
List<String> RELEVANCE_PHOTOVOLTAIC_PANEL_WORK_TYPE = List.of(
|
||||
"12",
|
||||
"13",
|
||||
"14"
|
||||
);
|
||||
|
||||
/**
|
||||
* 逆变器进度类别名称
|
||||
*/
|
||||
|
@ -4,6 +4,7 @@ import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.web.core.BaseController;
|
||||
@ -34,6 +35,7 @@ public class PgsProgressPlanDetailController extends BaseController {
|
||||
* 新增进度计划详情(普通设施)
|
||||
*/
|
||||
@SaCheckPermission("progress:progressPlanDetail:insert")
|
||||
@RepeatSubmit()
|
||||
@PostMapping("/insert/detail")
|
||||
public R<Void> insertFinishedDetail(@Validated @RequestBody PgsProgressPlanDetailFinishedCreateReq req) {
|
||||
return toAjax(pgsProgressPlanDetailService.insertFinishedDetail(req));
|
||||
@ -43,6 +45,7 @@ public class PgsProgressPlanDetailController extends BaseController {
|
||||
* 新增进度计划详情(百分比设施)
|
||||
*/
|
||||
@SaCheckPermission("progress:progressPlanDetail:insert")
|
||||
@RepeatSubmit()
|
||||
@PostMapping("/insert/percentage")
|
||||
public R<Void> insertPercentageDetail(@Validated @RequestBody PgsProgressPlanDetailPercentageCreateReq req) {
|
||||
return toAjax(pgsProgressPlanDetailService.insertPercentageDetail(req));
|
||||
@ -78,6 +81,7 @@ public class PgsProgressPlanDetailController extends BaseController {
|
||||
* 删除进度计划详情
|
||||
*/
|
||||
@SaCheckPermission("progress:progressPlanDetail:remove")
|
||||
@RepeatSubmit()
|
||||
@DeleteMapping("/remove/detail")
|
||||
public R<Void> removeDetail(@Validated PgsProgressPlanDetailRemoveReq req) {
|
||||
return toAjax(pgsProgressPlanDetailService.removeDetail(req));
|
||||
|
@ -86,6 +86,11 @@ public class PgsProgressCategory extends BaseEntity {
|
||||
*/
|
||||
private String workType;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 删除时间
|
||||
*/
|
||||
|
@ -52,6 +52,11 @@ public class PgsProgressCategoryTemplate implements Serializable {
|
||||
*/
|
||||
private Long projectId;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
|
@ -34,4 +34,9 @@ public class PgsProgressCategoryCreateReq {
|
||||
*/
|
||||
private String unitType;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
}
|
||||
|
@ -61,4 +61,9 @@ public class PgsProgressCategoryUpdateReq {
|
||||
*/
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
}
|
||||
|
@ -35,4 +35,9 @@ public class PgsProgressCategoryTemplateCreateReq implements Serializable {
|
||||
*/
|
||||
private Long projectId;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
}
|
||||
|
@ -35,4 +35,9 @@ public class PgsProgressCategoryTemplateUpdateReq implements Serializable {
|
||||
*/
|
||||
private String unitType;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
}
|
||||
|
@ -21,11 +21,6 @@ public class PgsProgressPlanDetailFinishedCreateReq implements Serializable {
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 项目id
|
||||
*/
|
||||
private Long projectId;
|
||||
|
||||
/**
|
||||
* 完成详情id列表
|
||||
*/
|
||||
|
@ -0,0 +1,24 @@
|
||||
package org.dromara.progress.domain.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author lcj
|
||||
* @date 2025/5/29 10:46
|
||||
*/
|
||||
@Getter
|
||||
public enum PgsDelayStatusEnum {
|
||||
|
||||
UNDELAY("未延期", "0"),
|
||||
DELAY("已延期", "1");
|
||||
|
||||
private final String text;
|
||||
|
||||
private final String value;
|
||||
|
||||
PgsDelayStatusEnum(String text, String value) {
|
||||
this.text = text;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package org.dromara.progress.domain.vo.progresscategory;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
@ -20,8 +21,12 @@ public class PgsProgressCategoryLastTimeVo implements Serializable {
|
||||
/**
|
||||
* 计划结束时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
private Date endDate;
|
||||
|
||||
/**
|
||||
* 剩余数量
|
||||
*/
|
||||
private BigDecimal leftNum;
|
||||
|
||||
}
|
||||
|
@ -112,4 +112,10 @@ public class PgsProgressCategoryVo implements Serializable {
|
||||
@ExcelDictFormat(readConverterExp = "0=未开始,1=进行中,2=已完成")
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@ExcelProperty(value = "备注")
|
||||
private String remark;
|
||||
|
||||
}
|
||||
|
@ -57,5 +57,10 @@ public class PgsProgressCategoryTemplateVo implements Serializable {
|
||||
@ExcelProperty(value = "项目id")
|
||||
private Long projectId;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@ExcelProperty(value = "备注")
|
||||
private String remark;
|
||||
|
||||
}
|
||||
|
@ -101,4 +101,5 @@ public interface IPgsProgressCategoryService extends IService<PgsProgressCategor
|
||||
* @return 是否创建成功
|
||||
*/
|
||||
Boolean insertByTemplate(Long projectId, List<Long> matrixIds);
|
||||
|
||||
}
|
||||
|
@ -94,4 +94,11 @@ public interface IPgsProgressPlanService extends IService<PgsProgressPlan> {
|
||||
*/
|
||||
void validPlanNumber(Long planNumber, PgsProgressCategory progressCategory);
|
||||
|
||||
/**
|
||||
* 校验计划是否延迟
|
||||
*
|
||||
* @return 是否延迟
|
||||
*/
|
||||
Boolean validProgressPlanIsDelay();
|
||||
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.dromara.common.core.constant.HttpStatus;
|
||||
import org.dromara.common.core.exception.ServiceException;
|
||||
import org.dromara.common.core.utils.DateUtils;
|
||||
import org.dromara.common.core.utils.ObjectUtils;
|
||||
import org.dromara.facility.domain.FacPercentageFacility;
|
||||
import org.dromara.facility.service.IFacPercentageFacilityService;
|
||||
@ -33,6 +34,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -105,8 +107,12 @@ public class PgsProgressCategoryServiceImpl extends ServiceImpl<PgsProgressCateg
|
||||
.orderByDesc(PgsProgressPlan::getEndDate)
|
||||
.last("limit 1")
|
||||
.one();
|
||||
if (progressPlan != null) {
|
||||
LocalDate now = LocalDate.now();
|
||||
Date date = DateUtils.toDate(now);
|
||||
if (progressPlan != null && progressPlan.getEndDate().after(date)) {
|
||||
lastTimeVo.setEndDate(progressPlan.getEndDate());
|
||||
} else {
|
||||
lastTimeVo.setEndDate(date);
|
||||
}
|
||||
return lastTimeVo;
|
||||
}
|
||||
@ -239,7 +245,6 @@ public class PgsProgressCategoryServiceImpl extends ServiceImpl<PgsProgressCateg
|
||||
// 精确查询
|
||||
lqw.in(ObjectUtils.isNotEmpty(projectId), PgsProgressCategory::getProjectId, projectId);
|
||||
lqw.eq(ObjectUtils.isNotEmpty(matrixId), PgsProgressCategory::getMatrixId, matrixId);
|
||||
lqw.orderByAsc(PgsProgressCategory::getWorkType);
|
||||
return lqw;
|
||||
}
|
||||
|
||||
@ -319,6 +324,7 @@ public class PgsProgressCategoryServiceImpl extends ServiceImpl<PgsProgressCateg
|
||||
newCategory.setWorkType(template.getWorkType());
|
||||
newCategory.setProjectId(projectId);
|
||||
newCategory.setMatrixId(matrixId);
|
||||
newCategory.setRemark(template.getRemark());
|
||||
// 先临时设置旧 pid
|
||||
newCategory.setPid(template.getPid());
|
||||
localList.add(newCategory);
|
||||
|
@ -167,6 +167,15 @@ public class PgsProgressCategoryTemplateServiceImpl extends ServiceImpl<PgsProgr
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
List<PgsProgressCategoryTemplate> categoryTemplateList = this.listByIds(ids);
|
||||
if (isValid) {
|
||||
categoryTemplateList.forEach(template->{
|
||||
Long projectId = template.getProjectId();
|
||||
if (projectId != null && projectId == 0) {
|
||||
throw new ServiceException("通用模版,无法删除", HttpStatus.CONFLICT);
|
||||
}
|
||||
});
|
||||
}
|
||||
return this.removeBatchByIds(ids);
|
||||
}
|
||||
|
||||
|
@ -29,6 +29,7 @@ import org.dromara.progress.domain.PgsProgressPlanDetail;
|
||||
import org.dromara.progress.domain.dto.progressplandetail.PgsProgressPlanDetailFinishedCreateReq;
|
||||
import org.dromara.progress.domain.dto.progressplandetail.PgsProgressPlanDetailPercentageCreateReq;
|
||||
import org.dromara.progress.domain.dto.progressplandetail.PgsProgressPlanDetailRemoveReq;
|
||||
import org.dromara.progress.domain.enums.PgsFinishStatusEnum;
|
||||
import org.dromara.progress.domain.vo.progressplandetail.PgsProgressPlanDetailFinishedVo;
|
||||
import org.dromara.progress.domain.vo.progressplandetail.PgsProgressPlanDetailNumVo;
|
||||
import org.dromara.progress.domain.vo.progressplandetail.PgsProgressPlanDetailUnFinishVo;
|
||||
@ -36,7 +37,6 @@ import org.dromara.progress.mapper.PgsProgressPlanDetailMapper;
|
||||
import org.dromara.progress.service.IPgsProgressCategoryService;
|
||||
import org.dromara.progress.service.IPgsProgressPlanDetailService;
|
||||
import org.dromara.progress.service.IPgsProgressPlanService;
|
||||
import org.dromara.project.service.IBusProjectService;
|
||||
import org.dromara.utils.PageConvertUtil;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
@ -45,10 +45,9 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 进度计划详情Service业务层处理
|
||||
@ -76,9 +75,6 @@ public class PgsProgressPlanDetailServiceImpl extends ServiceImpl<PgsProgressPla
|
||||
@Resource
|
||||
private IPgsProgressCategoryService progressCategoryService;
|
||||
|
||||
@Resource
|
||||
private IBusProjectService projectService;
|
||||
|
||||
/**
|
||||
* 插入进度计划详情设施
|
||||
*
|
||||
@ -92,18 +88,13 @@ public class PgsProgressPlanDetailServiceImpl extends ServiceImpl<PgsProgressPla
|
||||
if (CollUtil.isEmpty(finishedDetailIdList)) {
|
||||
return true;
|
||||
}
|
||||
int size = finishedDetailIdList.size();
|
||||
Long id = req.getId();
|
||||
PgsProgressPlanDetail progressPlanDetail = this.getById(id);
|
||||
if (progressPlanDetail == null) {
|
||||
throw new ServiceException("进度计划详情信息不存在", HttpStatus.NOT_FOUND);
|
||||
}
|
||||
Long projectId = req.getProjectId();
|
||||
if (projectId == null || projectService.getById(projectId) == null) {
|
||||
throw new ServiceException("项目信息不存在", HttpStatus.NOT_FOUND);
|
||||
}
|
||||
if (progressPlanDetail.getProjectId().equals(projectId)) {
|
||||
throw new ServiceException("进度计划详情信息不属于当前项目,请重新选择", HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
Long projectId = progressPlanDetail.getProjectId();
|
||||
Long progressCategoryId = progressPlanDetail.getProgressCategoryId();
|
||||
PgsProgressCategory progressCategory = progressCategoryService.getById(progressCategoryId);
|
||||
if (progressCategory == null) {
|
||||
@ -111,8 +102,16 @@ public class PgsProgressPlanDetailServiceImpl extends ServiceImpl<PgsProgressPla
|
||||
}
|
||||
String workType = progressCategory.getWorkType();
|
||||
List<PgsProgressPlanDetailFinishedVo> finishedDetailList = JSONUtil.toList(progressPlanDetail.getFinishedDetail(), PgsProgressPlanDetailFinishedVo.class);
|
||||
Set<Long> idSet = new HashSet<>(finishedDetailIdList);
|
||||
List<String> matchedNames = finishedDetailList.stream()
|
||||
.filter(detail -> idSet.contains(detail.getId()))
|
||||
.map(PgsProgressPlanDetailFinishedVo::getName)
|
||||
.toList();
|
||||
if (CollUtil.isNotEmpty(matchedNames)) {
|
||||
throw new ServiceException("设施:" + String.join(",", matchedNames) + "已完成,请勿重复提交", HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
if (PgsProgressCategoryConstant.PHOTOVOLTAIC_PANEL_PROGRESS_CATEGORY_WORK_TYPE.contains(workType)) {
|
||||
handleFacilityFinish(
|
||||
List<PgsProgressPlanDetailFinishedVo> finishedVoList = handleFacilityFinish(
|
||||
projectId,
|
||||
progressCategoryId,
|
||||
finishedDetailIdList,
|
||||
@ -125,11 +124,39 @@ public class PgsProgressPlanDetailServiceImpl extends ServiceImpl<PgsProgressPla
|
||||
FacPhotovoltaicPanel::getProjectId,
|
||||
FacPhotovoltaicPanel::getProgressCategoryId,
|
||||
FacPhotovoltaicPanel::getId,
|
||||
FacPhotovoltaicPanel::getStatus,
|
||||
finishedDetailList
|
||||
FacPhotovoltaicPanel::getStatus
|
||||
);
|
||||
finishedDetailList.addAll(finishedVoList);
|
||||
// 更新光伏板时,更新关联的钻孔、桩基、支架信息
|
||||
if (PgsProgressCategoryConstant.PHOTOVOLTAIC_PANEL_WORK_TYPE.equals(workType)) {
|
||||
List<FacPhotovoltaicPanel> photovoltaicPanelList = photovoltaicPanelService.lambdaQuery()
|
||||
.eq(FacPhotovoltaicPanel::getProjectId, projectId)
|
||||
.eq(FacPhotovoltaicPanel::getMatrixId, progressCategory.getMatrixId())
|
||||
.in(FacPhotovoltaicPanel::getProgressCategoryId, PgsProgressCategoryConstant.RELEVANCE_PHOTOVOLTAIC_PANEL_WORK_TYPE)
|
||||
.list();
|
||||
Map<Long, List<FacPhotovoltaicPanel>> map = photovoltaicPanelList
|
||||
.stream().collect(Collectors.groupingBy(FacPhotovoltaicPanel::getProgressCategoryId));
|
||||
// 批量更新关联的光伏板信息
|
||||
boolean update = photovoltaicPanelService.lambdaUpdate()
|
||||
.eq(FacPhotovoltaicPanel::getProjectId, projectId)
|
||||
.in(FacPhotovoltaicPanel::getProgressCategoryId, PgsProgressCategoryConstant.RELEVANCE_PHOTOVOLTAIC_PANEL_WORK_TYPE)
|
||||
.eq(FacPhotovoltaicPanel::getMatrixId, progressCategory.getMatrixId())
|
||||
.set(FacPhotovoltaicPanel::getStatus, FacFinishStatusEnum.FINISH.getValue())
|
||||
.set(FacPhotovoltaicPanel::getFinishType, FacFinishTypeEnum.HAND.getValue())
|
||||
.set(FacPhotovoltaicPanel::getFinishDate, progressPlanDetail.getDate())
|
||||
.update();
|
||||
if (!update) {
|
||||
throw new ServiceException("更新设施信息异常", HttpStatus.ERROR);
|
||||
}
|
||||
// todo
|
||||
for (Map.Entry<Long, List<FacPhotovoltaicPanel>> entry : map.entrySet()) {
|
||||
Long key = entry.getKey();
|
||||
List<FacPhotovoltaicPanel> value = entry.getValue();
|
||||
// 封装计划详情
|
||||
}
|
||||
}
|
||||
} else if (PgsProgressCategoryConstant.INVERTER_PROGRESS_CATEGORY_WORK_TYPE.contains(workType)) {
|
||||
handleFacilityFinish(
|
||||
List<PgsProgressPlanDetailFinishedVo> finishedVoList = handleFacilityFinish(
|
||||
projectId,
|
||||
progressCategoryId,
|
||||
finishedDetailIdList,
|
||||
@ -142,11 +169,11 @@ public class PgsProgressPlanDetailServiceImpl extends ServiceImpl<PgsProgressPla
|
||||
FacInverter::getProjectId,
|
||||
FacInverter::getProgressCategoryId,
|
||||
FacInverter::getId,
|
||||
FacInverter::getStatus,
|
||||
finishedDetailList
|
||||
FacInverter::getStatus
|
||||
);
|
||||
finishedDetailList.addAll(finishedVoList);
|
||||
} else if (PgsProgressCategoryConstant.BOX_TRANSFORMER_PROGRESS_CATEGORY_WORK_TYPE.contains(workType)) {
|
||||
handleFacilityFinish(
|
||||
List<PgsProgressPlanDetailFinishedVo> finishedVoList = handleFacilityFinish(
|
||||
projectId,
|
||||
progressCategoryId,
|
||||
finishedDetailIdList,
|
||||
@ -159,29 +186,31 @@ public class PgsProgressPlanDetailServiceImpl extends ServiceImpl<PgsProgressPla
|
||||
FacBoxTransformer::getProjectId,
|
||||
FacBoxTransformer::getProgressCategoryId,
|
||||
FacBoxTransformer::getId,
|
||||
FacBoxTransformer::getStatus,
|
||||
finishedDetailList
|
||||
FacBoxTransformer::getStatus
|
||||
);
|
||||
finishedDetailList.addAll(finishedVoList);
|
||||
}
|
||||
PgsProgressPlanDetail detail = new PgsProgressPlanDetail();
|
||||
detail.setId(id);
|
||||
detail.setFinishedDetail(JSONUtil.toJsonStr(finishedDetailList));
|
||||
detail.setFinishedNumber(progressPlanDetail.getFinishedNumber() + finishedDetailList.size());
|
||||
detail.setFinishedNumber(progressPlanDetail.getFinishedNumber() + size);
|
||||
boolean update = this.updateById(detail);
|
||||
if (!update) {
|
||||
throw new ServiceException("更新进度计划详情异常", HttpStatus.ERROR);
|
||||
}
|
||||
boolean result = progressPlanService.lambdaUpdate()
|
||||
.eq(PgsProgressPlan::getId, progressPlanDetail.getProgressPlanId())
|
||||
.setSql("finished_number = finished_number + " + finishedDetailList.size())
|
||||
.setSql("finished_number = finished_number + " + size)
|
||||
.update();
|
||||
if (!result) {
|
||||
throw new ServiceException("更新进度计划异常", HttpStatus.ERROR);
|
||||
}
|
||||
boolean updateCategory = progressCategoryService.lambdaUpdate()
|
||||
.eq(PgsProgressCategory::getId, progressCategoryId)
|
||||
.setSql("completed = completed + " + finishedDetailList.size())
|
||||
.update();
|
||||
BigDecimal completedTotal = progressCategory.getCompleted().add(new BigDecimal(size));
|
||||
progressCategory.setCompleted(completedTotal);
|
||||
if (completedTotal.compareTo(progressCategory.getTotal()) == 0) {
|
||||
progressCategory.setStatus(PgsFinishStatusEnum.FINISH.getValue());
|
||||
}
|
||||
boolean updateCategory = progressCategoryService.updateById(progressCategory);
|
||||
if (!updateCategory) {
|
||||
throw new ServiceException("更新进度计划类别异常", HttpStatus.ERROR);
|
||||
}
|
||||
@ -197,6 +226,7 @@ public class PgsProgressPlanDetailServiceImpl extends ServiceImpl<PgsProgressPla
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean insertPercentageDetail(PgsProgressPlanDetailPercentageCreateReq req) {
|
||||
// 校验
|
||||
Long finishedNumber = req.getFinishedNumber();
|
||||
if (finishedNumber == null) {
|
||||
throw new ServiceException("完成百分比不能为空", HttpStatus.BAD_REQUEST);
|
||||
@ -217,6 +247,11 @@ public class PgsProgressPlanDetailServiceImpl extends ServiceImpl<PgsProgressPla
|
||||
if (progressPlan == null) {
|
||||
throw new ServiceException("进度计划信息不存在", HttpStatus.NOT_FOUND);
|
||||
}
|
||||
Long progressCategoryId = progressPlanDetail.getProgressCategoryId();
|
||||
PgsProgressCategory progressCategory = progressCategoryService.getById(progressCategoryId);
|
||||
if (progressCategory == null) {
|
||||
throw new ServiceException("进度计划类别信息不存在", HttpStatus.NOT_FOUND);
|
||||
}
|
||||
Long number = progressPlanDetail.getFinishedNumber();
|
||||
Long finishedNumberTotal = progressPlan.getFinishedNumber();
|
||||
if (finishedNumberTotal + finishedNumber > progressPlan.getPlanNumber()) {
|
||||
@ -228,16 +263,18 @@ public class PgsProgressPlanDetailServiceImpl extends ServiceImpl<PgsProgressPla
|
||||
if (!update) {
|
||||
throw new ServiceException("更新进度计划详情异常", HttpStatus.ERROR);
|
||||
}
|
||||
progressPlan.setFinishedNumber(finishedNumberTotal - progressPlan.getFinishedNumber() + finishedNumber);
|
||||
progressPlan.setFinishedNumber(finishedNumberTotal - number + finishedNumber);
|
||||
boolean result = progressPlanService.updateById(progressPlan);
|
||||
if (!result) {
|
||||
throw new ServiceException("更新进度计划异常", HttpStatus.ERROR);
|
||||
}
|
||||
boolean updateCategory = progressCategoryService.lambdaUpdate()
|
||||
.eq(PgsProgressCategory::getId, progressPlan.getProgressCategoryId())
|
||||
.setSql("completed = completed - " + number)
|
||||
.setSql("completed = completed + " + finishedNumber)
|
||||
.update();
|
||||
BigDecimal completed = progressCategory.getCompleted();
|
||||
BigDecimal completedTotal = completed.subtract(new BigDecimal(number)).add(new BigDecimal(finishedNumber));
|
||||
progressCategory.setCompleted(completedTotal);
|
||||
if (completedTotal.compareTo(progressCategory.getTotal()) == 0) {
|
||||
progressCategory.setStatus(PgsFinishStatusEnum.FINISH.getValue());
|
||||
}
|
||||
boolean updateCategory = progressCategoryService.updateById(progressCategory);
|
||||
if (!updateCategory) {
|
||||
throw new ServiceException("更新进度分类异常", HttpStatus.ERROR);
|
||||
}
|
||||
@ -293,7 +330,6 @@ public class PgsProgressPlanDetailServiceImpl extends ServiceImpl<PgsProgressPla
|
||||
vo.setId(entity.getId());
|
||||
vo.setName(entity.getName());
|
||||
vo.setStatus(entity.getStatus());
|
||||
vo.setName(progressCategory.getName());
|
||||
return vo;
|
||||
});
|
||||
return TableDataInfo.build(voPage);
|
||||
@ -309,7 +345,6 @@ public class PgsProgressPlanDetailServiceImpl extends ServiceImpl<PgsProgressPla
|
||||
vo.setId(entity.getId());
|
||||
vo.setName(entity.getName());
|
||||
vo.setStatus(entity.getStatus());
|
||||
vo.setName(progressCategory.getName());
|
||||
return vo;
|
||||
});
|
||||
return TableDataInfo.build(voPage);
|
||||
@ -325,7 +360,6 @@ public class PgsProgressPlanDetailServiceImpl extends ServiceImpl<PgsProgressPla
|
||||
vo.setId(entity.getId());
|
||||
vo.setName(entity.getName());
|
||||
vo.setStatus(entity.getStatus());
|
||||
vo.setName(progressCategory.getName());
|
||||
return vo;
|
||||
});
|
||||
return TableDataInfo.build(voPage);
|
||||
@ -449,6 +483,9 @@ public class PgsProgressPlanDetailServiceImpl extends ServiceImpl<PgsProgressPla
|
||||
if (!updatePlan) {
|
||||
throw new ServiceException("修改进度计划失败,数据库异常", HttpStatus.ERROR);
|
||||
}
|
||||
if (removeTotal > 0 && progressCategory.getTotal().compareTo(progressCategory.getCompleted()) == 0) {
|
||||
progressCategory.setStatus(PgsFinishStatusEnum.INPROGRESS.getValue());
|
||||
}
|
||||
progressCategory.setCompleted(progressCategory.getCompleted().subtract(BigDecimal.valueOf(removeTotal)));
|
||||
boolean updateCategory = progressCategoryService.updateById(progressCategory);
|
||||
if (!updateCategory) {
|
||||
@ -480,7 +517,25 @@ public class PgsProgressPlanDetailServiceImpl extends ServiceImpl<PgsProgressPla
|
||||
return new Page<T>(pageNum, pageSize, fullList.size()).setRecords(pageList);
|
||||
}
|
||||
|
||||
public <T> void handleFacilityFinish(
|
||||
/**
|
||||
* 获取设施封装
|
||||
*
|
||||
* @param projectId 项目ID
|
||||
* @param progressCategoryId 进度类别ID
|
||||
* @param finishedDetailIdList 设施完成ID列表
|
||||
* @param finishDate 设施完成时间
|
||||
* @param service 服务
|
||||
* @param getIdFunc 获取ID方法
|
||||
* @param getNameFunc 获取名称方法
|
||||
* @param getFinishTypeFunc 获取完成类型方法
|
||||
* @param getFinishDateFunc 获取完成时间方法
|
||||
* @param getProjectIdFunc 获取项目ID方法
|
||||
* @param getProgressCategoryIdFunc 获取进度类别ID方法
|
||||
* @param getIdColumnFunc 获取ID列方法
|
||||
* @param getStatusFunc 获取状态方法
|
||||
* @param <T> 设施类型
|
||||
*/
|
||||
public <T> List<PgsProgressPlanDetailFinishedVo> handleFacilityFinish(
|
||||
Long projectId,
|
||||
Long progressCategoryId,
|
||||
List<Long> finishedDetailIdList,
|
||||
@ -493,8 +548,7 @@ public class PgsProgressPlanDetailServiceImpl extends ServiceImpl<PgsProgressPla
|
||||
SFunction<T, Long> getProjectIdFunc,
|
||||
SFunction<T, Long> getProgressCategoryIdFunc,
|
||||
SFunction<T, Long> getIdColumnFunc,
|
||||
SFunction<T, String> getStatusFunc,
|
||||
List<PgsProgressPlanDetailFinishedVo> finishedDetailList
|
||||
SFunction<T, String> getStatusFunc
|
||||
) {
|
||||
List<T> entityList = service.lambdaQuery()
|
||||
.eq(getProjectIdFunc, projectId)
|
||||
@ -515,14 +569,13 @@ public class PgsProgressPlanDetailServiceImpl extends ServiceImpl<PgsProgressPla
|
||||
if (!update) {
|
||||
throw new ServiceException("更新设施信息异常", HttpStatus.ERROR);
|
||||
}
|
||||
List<PgsProgressPlanDetailFinishedVo> list = entityList.stream().map(entity -> {
|
||||
return entityList.stream().map(entity -> {
|
||||
PgsProgressPlanDetailFinishedVo vo = new PgsProgressPlanDetailFinishedVo();
|
||||
vo.setId(getIdFunc.apply(entity));
|
||||
vo.setName(getNameFunc.apply(entity));
|
||||
vo.setFinishType(getFinishTypeFunc.apply(entity));
|
||||
vo.setFinishType(FacFinishTypeEnum.HAND.getValue());
|
||||
return vo;
|
||||
}).toList();
|
||||
finishedDetailList.addAll(list);
|
||||
}
|
||||
|
||||
|
||||
|
@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
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,6 +20,7 @@ import org.dromara.progress.domain.PgsProgressPlanDetail;
|
||||
import org.dromara.progress.domain.dto.progressplan.PgsProgressPlanCreateReq;
|
||||
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.vo.progressplan.PgsProgressPlanVo;
|
||||
import org.dromara.progress.domain.vo.progressplandetail.PgsProgressPlanDetailNumVo;
|
||||
@ -32,6 +34,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
@ -44,6 +47,7 @@ import java.util.stream.Collectors;
|
||||
* @author lcj
|
||||
* @date 2025-05-27
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class PgsProgressPlanServiceImpl extends ServiceImpl<PgsProgressPlanMapper, PgsProgressPlan>
|
||||
implements IPgsProgressPlanService {
|
||||
@ -322,4 +326,55 @@ public class PgsProgressPlanServiceImpl extends ServiceImpl<PgsProgressPlanMappe
|
||||
throw new ServiceException("计划数量不能大于剩余数量", HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验计划是否延迟
|
||||
*
|
||||
* @return 是否延迟
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean validProgressPlanIsDelay() {
|
||||
// 查找延期的施工进度
|
||||
LambdaQueryWrapper<PgsProgressPlan> lqw = new LambdaQueryWrapper<>();
|
||||
lqw.lt(PgsProgressPlan::getEndDate, LocalDate.now());
|
||||
lqw.apply("finished_number < plan_number ");
|
||||
lqw.eq(PgsProgressPlan::getDelayNumber, 0);
|
||||
List<PgsProgressPlan> delayPlanList = this.list(lqw);
|
||||
if (CollUtil.isEmpty(delayPlanList)) {
|
||||
log.info("无新增延期的施工进度");
|
||||
return true;
|
||||
}
|
||||
Map<Long, List<PgsProgressPlan>> delayPlanMap = delayPlanList
|
||||
.stream().collect(Collectors.groupingBy(PgsProgressPlan::getProgressCategoryId));
|
||||
log.warn("延期的施工进度:{}", delayPlanList);
|
||||
List<PgsProgressPlan> progressPlanList = new ArrayList<>();
|
||||
List<Long> categoryIdList = new ArrayList<>();
|
||||
for (Map.Entry<Long, List<PgsProgressPlan>> entry : delayPlanMap.entrySet()) {
|
||||
Long key = entry.getKey();
|
||||
categoryIdList.add(key);
|
||||
List<PgsProgressPlan> value = entry.getValue();
|
||||
// 遍历施工进度,更新延期数量
|
||||
List<PgsProgressPlan> delayList = value.stream().map(progressPlan -> {
|
||||
PgsProgressPlan newProgressPlan = new PgsProgressPlan();
|
||||
newProgressPlan.setId(progressPlan.getId());
|
||||
newProgressPlan.setDelayNumber(progressPlan.getPlanNumber() - progressPlan.getFinishedNumber());
|
||||
return newProgressPlan;
|
||||
}).toList();
|
||||
progressPlanList.addAll(delayList);
|
||||
}
|
||||
// 批量更新
|
||||
boolean result = this.updateBatchById(progressPlanList);
|
||||
if (!result) {
|
||||
throw new ServiceException("更新施工进度失败", HttpStatus.ERROR);
|
||||
}
|
||||
boolean update = progressCategoryService.lambdaUpdate()
|
||||
.in(PgsProgressCategory::getId, categoryIdList)
|
||||
.set(PgsProgressCategory::getIsDelay, PgsDelayStatusEnum.DELAY.getValue())
|
||||
.update();
|
||||
if (!update) {
|
||||
throw new ServiceException("更新进度类别异常", HttpStatus.ERROR);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -477,3 +477,23 @@ values(1905067946597736454, '黑名单删除', 1905067946597736450, '4', '#', '
|
||||
|
||||
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark)
|
||||
values(1905067946597736455, '黑名单导出', 1905067946597736450, '5', '#', '', 1, 0, 'F', '0', '0', 'project:constructionBlacklist:export', '#', 103, 1, sysdate(), null, null, '');
|
||||
|
||||
-- 菜单 SQL
|
||||
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark)
|
||||
values(1927984223038324738, '进度类别模版', '1913133014288699393', '1', 'progressCategoryTemplate', 'progress/progressCategoryTemplate/index', 1, 0, 'C', '0', '0', 'progress:progressCategoryTemplate:list', '#', 103, 1, sysdate(), null, null, '进度类别模版菜单');
|
||||
|
||||
-- 按钮 SQL
|
||||
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark)
|
||||
values(1927984223038324739, '进度类别模版查询', 1927984223038324738, '1', '#', '', 1, 0, 'F', '0', '0', 'progress:progressCategoryTemplate:query', '#', 103, 1, sysdate(), null, null, '');
|
||||
|
||||
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark)
|
||||
values(1927984223038324740, '进度类别模版新增', 1927984223038324738, '2', '#', '', 1, 0, 'F', '0', '0', 'progress:progressCategoryTemplate:add', '#', 103, 1, sysdate(), null, null, '');
|
||||
|
||||
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark)
|
||||
values(1927984223038324741, '进度类别模版修改', 1927984223038324738, '3', '#', '', 1, 0, 'F', '0', '0', 'progress:progressCategoryTemplate:edit', '#', 103, 1, sysdate(), null, null, '');
|
||||
|
||||
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark)
|
||||
values(1927984223038324742, '进度类别模版删除', 1927984223038324738, '4', '#', '', 1, 0, 'F', '0', '0', 'progress:progressCategoryTemplate:remove', '#', 103, 1, sysdate(), null, null, '');
|
||||
|
||||
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark)
|
||||
values(1927984223038324743, '进度类别模版导出', 1927984223038324738, '5', '#', '', 1, 0, 'F', '0', '0', 'progress:progressCategoryTemplate:export', '#', 103, 1, sysdate(), null, null, '');
|
||||
|
Reference in New Issue
Block a user