修改进度计划、施工产值
This commit is contained in:
@ -8,6 +8,7 @@ import org.dromara.facility.domain.FacMatrix;
|
||||
import org.dromara.facility.service.IFacMatrixService;
|
||||
import org.dromara.facility.service.IFacPhotovoltaicPanelPartsService;
|
||||
import org.dromara.progress.service.IPgsProgressCategoryService;
|
||||
import org.dromara.progress.service.IPgsProgressCategoryTemplateService;
|
||||
import org.dromara.project.service.IBusProjectService;
|
||||
import org.dromara.system.service.ISysDeptService;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@ -30,6 +31,9 @@ public class DemoTest {
|
||||
@Resource
|
||||
private IPgsProgressCategoryService progressCategoryService;
|
||||
|
||||
@Resource
|
||||
private IPgsProgressCategoryTemplateService progressCategoryTemplateService;
|
||||
|
||||
@Resource
|
||||
private IFacMatrixService matrixService;
|
||||
|
||||
@ -84,6 +88,12 @@ public class DemoTest {
|
||||
Boolean result = progressCategoryService.insertByTemplate(1906557369562726402L, matrixList, null);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testProject() {
|
||||
// 初始化施工类型模版
|
||||
Boolean init = progressCategoryTemplateService.initTemplateByProject(1958935730389606402L);
|
||||
}
|
||||
|
||||
/* @Test
|
||||
void testDeptProject() {
|
||||
deptService.selectProjectIdById(100L);
|
||||
|
@ -0,0 +1,38 @@
|
||||
package org.dromara.job.cycle;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.progress.service.IPgsProgressPlanDetailService;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
/**
|
||||
* 同步计划详情到施工产值
|
||||
*
|
||||
* @author lilemy
|
||||
* @date 2025-08-26 19:21
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class IncSyncPlanDetail2ConstructionValue {
|
||||
|
||||
@Resource
|
||||
private IPgsProgressPlanDetailService progressPlanDetailService;
|
||||
|
||||
/**
|
||||
* 同步计划详情到施工产值(每天 1 点执行)
|
||||
*/
|
||||
@Scheduled(cron = "0 0 1 * * ?")
|
||||
public void run() {
|
||||
LocalDate yesterday = LocalDate.now().minusDays(1);
|
||||
log.info("执行定时任务:同步 {} 计划详情到施工产值", yesterday);
|
||||
Boolean synced = progressPlanDetailService.syncPlanDetail2ConstructionValue(yesterday, null);
|
||||
if (synced) {
|
||||
log.info("同步计划详情到施工产值成功");
|
||||
} else {
|
||||
log.info("暂无计划详情需要同步");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,16 +1,14 @@
|
||||
package org.dromara.out.domain;
|
||||
|
||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
|
||||
/**
|
||||
* 施工产值对象 out_construction_value
|
||||
|
@ -15,7 +15,7 @@ import org.dromara.common.core.utils.MapstructUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.facility.domain.vo.matrix.FacMatrixVo;
|
||||
import org.dromara.facility.domain.FacMatrix;
|
||||
import org.dromara.facility.service.IFacMatrixService;
|
||||
import org.dromara.out.domain.OutConstructionValue;
|
||||
import org.dromara.out.domain.bo.OutConstructionValueBo;
|
||||
@ -178,11 +178,11 @@ public class OutConstructionValueServiceImpl extends ServiceImpl<OutConstruction
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigDecimal getCompleteValue(Long projectId, String month,String type) {
|
||||
public BigDecimal getCompleteValue(Long projectId, String month, String type) {
|
||||
BigDecimal completeValue;
|
||||
if(type.equals("1")){
|
||||
if (type.equals("1")) {
|
||||
completeValue = baseMapper.getCompleteOwnerValue(projectId, month);
|
||||
}else{
|
||||
} else {
|
||||
completeValue = baseMapper.getCompleteOutValue(projectId, month);
|
||||
}
|
||||
|
||||
@ -202,19 +202,7 @@ public class OutConstructionValueServiceImpl extends ServiceImpl<OutConstruction
|
||||
|
||||
}
|
||||
|
||||
public void getName(OutConstructionValueVo vo){
|
||||
//查询项目
|
||||
BusProjectVo busProjectVo = busProjectService.queryById(vo.getProjectId());
|
||||
vo.setProjectName(busProjectVo.getProjectName());
|
||||
|
||||
//查询方阵以及子项目
|
||||
FacMatrixVo facMatrixVo = facMatrixService.queryById(vo.getMatrixId());
|
||||
vo.setMatrixName(facMatrixVo.getMatrixName());
|
||||
|
||||
BusProjectVo busProjectVo1 = busProjectService.queryById(facMatrixVo.getProjectId());
|
||||
vo.setSubProjectId(busProjectVo1.getId());
|
||||
vo.setSubProjectName(busProjectVo1.getProjectName());
|
||||
|
||||
public void getName(OutConstructionValueVo vo) {
|
||||
//查询分部工程以及分项工程
|
||||
PgsProgressCategoryVo pgsProgressCategoryVo = pgsProgressCategoryService.queryById(vo.getProgressCategoryId());
|
||||
vo.setProgressCategoryName(pgsProgressCategoryVo.getName());
|
||||
@ -222,6 +210,18 @@ public class OutConstructionValueServiceImpl extends ServiceImpl<OutConstruction
|
||||
PgsProgressCategoryVo pgsProgressCategoryVo1 = pgsProgressCategoryService.queryById(pgsProgressCategoryVo.getParentId());
|
||||
vo.setCategoryId(pgsProgressCategoryVo1.getId());
|
||||
vo.setCategoryName(pgsProgressCategoryVo1.getName());
|
||||
//查询项目
|
||||
BusProjectVo busProjectVo = busProjectService.queryById(vo.getProjectId());
|
||||
vo.setProjectName(busProjectVo.getProjectName());
|
||||
|
||||
//查询方阵以及子项目
|
||||
if (vo.getMatrixId() != null) {
|
||||
FacMatrix facMatrix = facMatrixService.getById(vo.getMatrixId());
|
||||
vo.setMatrixName(facMatrix.getMatrixName());
|
||||
}
|
||||
BusProjectVo busProjectVo1 = busProjectService.queryById(pgsProgressCategoryVo.getProjectId());
|
||||
vo.setSubProjectId(busProjectVo1.getId());
|
||||
vo.setSubProjectName(busProjectVo1.getProjectName());
|
||||
}
|
||||
|
||||
|
||||
|
@ -60,4 +60,8 @@ public interface PgsProgressCategoryConstant {
|
||||
PHOTOVOLTAIC_PANEL_SUPPORT_WORK_TYPE
|
||||
);
|
||||
|
||||
/**
|
||||
* 最大层级
|
||||
*/
|
||||
Integer MAX_LEVEL = 3;
|
||||
}
|
||||
|
@ -23,10 +23,7 @@ import org.dromara.progress.domain.dto.progresscategory.PgsProgressCategoryCreat
|
||||
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;
|
||||
import org.dromara.progress.domain.vo.progresscategory.PgsProgressCategoryLastTimeVo;
|
||||
import org.dromara.progress.domain.vo.progresscategory.PgsProgressCategoryProjectVo;
|
||||
import org.dromara.progress.domain.vo.progresscategory.PgsProgressCategoryVo;
|
||||
import org.dromara.progress.domain.vo.progresscategory.*;
|
||||
import org.dromara.progress.service.IPgsProgressCategoryService;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@ -66,14 +63,25 @@ public class PgsProgressCategoryController extends BaseController {
|
||||
return R.ok(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据进度父级查询进度类别列表
|
||||
*/
|
||||
@SaCheckPermission("progress:progressCategory:listByParent")
|
||||
@GetMapping("/listByParent/{parentId}")
|
||||
public R<List<PgsProgressCategoryVo>> listByParent(@NotNull(message = "项目id不能为空")
|
||||
@PathVariable Long parentId) {
|
||||
List<PgsProgressCategoryVo> list = pgsProgressCategoryService.queryListByParent(parentId);
|
||||
return R.ok(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据子项目获取进度类别模版顶级目录列表
|
||||
*/
|
||||
@SaCheckPermission("progress:progressCategory:listTopBySubProjectId")
|
||||
@GetMapping("/listTopBySubProjectId/{subProjectId}")
|
||||
public R<List<PgsProgressCategoryVo>> listTopBySubProjectId(@NotNull(message = "项目id不能为空")
|
||||
@PathVariable Long subProjectId) {
|
||||
List<PgsProgressCategoryVo> list = pgsProgressCategoryService.getTopListByProjectId(subProjectId);
|
||||
public R<List<PgsProgressCategoryTopVo>> listTopBySubProjectId(@NotNull(message = "项目id不能为空")
|
||||
@PathVariable Long subProjectId) {
|
||||
List<PgsProgressCategoryTopVo> list = pgsProgressCategoryService.getTopListByProjectId(subProjectId);
|
||||
return R.ok(list);
|
||||
}
|
||||
|
||||
@ -112,7 +120,7 @@ public class PgsProgressCategoryController extends BaseController {
|
||||
@SaCheckPermission("progress:progressCategory:import")
|
||||
@Log(title = "进度类别导入", businessType = BusinessType.IMPORT)
|
||||
@PostMapping("/import")
|
||||
public R<Void> importData(@RequestParam("file") MultipartFile file) throws Exception {
|
||||
public R<Void> importData(@RequestParam("file") MultipartFile file) {
|
||||
|
||||
// 检查文件是否为空
|
||||
if (file == null || file.isEmpty()) {
|
||||
|
@ -6,8 +6,6 @@ import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.core.validate.AddGroup;
|
||||
import org.dromara.common.core.validate.EditGroup;
|
||||
import org.dromara.common.excel.utils.ExcelUtil;
|
||||
import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
||||
import org.dromara.common.log.annotation.Log;
|
||||
@ -58,13 +56,25 @@ public class PgsProgressCategoryTemplateController extends BaseController {
|
||||
return R.ok(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据进度父级查询进度类别模版列表
|
||||
*/
|
||||
@SaCheckPermission("progress:progressCategoryTemplate:listByParent")
|
||||
@GetMapping("/listByParent/{parentId}")
|
||||
public R<List<PgsProgressCategoryTemplateVo>> listByParent(@NotNull(message = "父级类别主键不能为空")
|
||||
@PathVariable Long parentId) {
|
||||
List<PgsProgressCategoryTemplateVo> list = pgsProgressCategoryTemplateService.queryListByParent(parentId);
|
||||
return R.ok(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取系统顶级进度类别模版列表
|
||||
*/
|
||||
@SaCheckPermission("progress:progressCategoryTemplate:listSystemTop")
|
||||
@GetMapping("/listSystemTop")
|
||||
public R<List<PgsProgressCategoryTemplateVo>> listSystemTop() {
|
||||
return R.ok(pgsProgressCategoryTemplateService.listSystemTop());
|
||||
@GetMapping("/listSystemTop/{projectId}")
|
||||
public R<List<PgsProgressCategoryTemplateVo>> listSystemTop(@NotNull(message = "项目主键不能为空")
|
||||
@PathVariable Long projectId) {
|
||||
return R.ok(pgsProgressCategoryTemplateService.listSystemTop(projectId));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -97,7 +107,7 @@ public class PgsProgressCategoryTemplateController extends BaseController {
|
||||
@Log(title = "进度类别模版", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
public R<Long> add(@Validated(AddGroup.class) @RequestBody PgsProgressCategoryTemplateCreateReq req) {
|
||||
public R<Long> add(@Validated @RequestBody PgsProgressCategoryTemplateCreateReq req) {
|
||||
return R.ok(pgsProgressCategoryTemplateService.insertByBo(req));
|
||||
}
|
||||
|
||||
@ -108,7 +118,7 @@ public class PgsProgressCategoryTemplateController extends BaseController {
|
||||
@Log(title = "进度类别模版", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping()
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody PgsProgressCategoryTemplateUpdateReq req) {
|
||||
public R<Void> edit(@Validated @RequestBody PgsProgressCategoryTemplateUpdateReq req) {
|
||||
return toAjax(pgsProgressCategoryTemplateService.updateByBo(req));
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@ import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.time.LocalDate;
|
||||
|
||||
/**
|
||||
* 进度计划详情对象 pgs_progress_plan_detail
|
||||
@ -48,7 +48,7 @@ public class PgsProgressPlanDetail extends BaseEntity {
|
||||
/**
|
||||
* 计划时间
|
||||
*/
|
||||
private Date date;
|
||||
private LocalDate date;
|
||||
|
||||
/**
|
||||
* 计划数量/百分比
|
||||
|
@ -19,6 +19,11 @@ public class PgsProgressCategoryQueryReq {
|
||||
*/
|
||||
private Long matrixId;
|
||||
|
||||
/**
|
||||
* 父类别id
|
||||
*/
|
||||
private Long parentId;
|
||||
|
||||
/**
|
||||
* 关联结构(1子项目 2方阵)
|
||||
*/
|
||||
|
@ -51,6 +51,12 @@ public class PgsProgressCategoryTemplateCreateReq implements Serializable {
|
||||
*/
|
||||
private String constructionType;
|
||||
|
||||
/**
|
||||
* 关联结构(1子项目 2方阵)
|
||||
*/
|
||||
@NotBlank(message = "关联结构不能为空")
|
||||
private String relevancyStructure;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
|
@ -54,6 +54,11 @@ public class PgsProgressCategoryTemplateUpdateReq implements Serializable {
|
||||
*/
|
||||
private String constructionType;
|
||||
|
||||
/**
|
||||
* 关联结构(1子项目 2方阵)
|
||||
*/
|
||||
private String relevancyStructure;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
|
@ -1,12 +1,11 @@
|
||||
package org.dromara.progress.domain.dto.progressplandetail;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.time.LocalDate;
|
||||
|
||||
/**
|
||||
* @author lilemy
|
||||
@ -20,8 +19,7 @@ public class PgsProgressPlanDetailCreateDto {
|
||||
/**
|
||||
* 计划时间
|
||||
*/
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd")
|
||||
private Date date;
|
||||
private LocalDate date;
|
||||
|
||||
/**
|
||||
* 计划数量/百分比
|
||||
|
@ -0,0 +1,41 @@
|
||||
package org.dromara.progress.domain.vo.progresscategory;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author lilemy
|
||||
* @date 2025-08-26 16:52
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class PgsProgressCategoryMatrixStructureTopVo {
|
||||
|
||||
/**
|
||||
* 关联结构(1子项目 2方阵)
|
||||
*/
|
||||
private String relevancyStructure;
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 类别名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 方阵id
|
||||
*/
|
||||
private Long matrixId;
|
||||
|
||||
/**
|
||||
* 方阵名称
|
||||
*/
|
||||
private String matrixName;
|
||||
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package org.dromara.progress.domain.vo.progresscategory;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author lilemy
|
||||
* @date 2025-08-26 16:49
|
||||
*/
|
||||
@Data
|
||||
public class PgsProgressCategoryTopVo implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = -8638109773596974231L;
|
||||
|
||||
/**
|
||||
* 关联结构(1子项目 2方阵)
|
||||
*/
|
||||
private String relevancyStructure;
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 类别名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 关联方阵结构列表
|
||||
*/
|
||||
private List<PgsProgressCategoryMatrixStructureTopVo> matrixStructureList;
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
package org.dromara.progress.domain.vo.progressplandetail;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
@ -8,7 +7,7 @@ import lombok.NoArgsConstructor;
|
||||
import org.dromara.common.json.handler.BigDecimalToIntegerSerializer;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -28,8 +27,7 @@ public class PgsProgressPlanDetailDateVo {
|
||||
/**
|
||||
* 计划时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
private Date date;
|
||||
private LocalDate date;
|
||||
|
||||
/**
|
||||
* 已完成数量
|
||||
|
@ -2,7 +2,6 @@ package org.dromara.progress.domain.vo.progressplandetail;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import lombok.Data;
|
||||
import org.dromara.progress.domain.PgsProgressPlanDetail;
|
||||
@ -10,7 +9,7 @@ import org.dromara.progress.domain.PgsProgressPlanDetail;
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.time.LocalDate;
|
||||
|
||||
|
||||
/**
|
||||
@ -49,8 +48,7 @@ public class PgsProgressPlanDetailVo implements Serializable {
|
||||
* 计划时间
|
||||
*/
|
||||
@ExcelProperty(value = "计划时间")
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
||||
private Date date;
|
||||
private LocalDate date;
|
||||
|
||||
/**
|
||||
* 计划数量/百分比
|
||||
|
@ -8,10 +8,7 @@ import org.dromara.progress.domain.dto.progresscategory.PgsProgressCategoryCreat
|
||||
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;
|
||||
import org.dromara.progress.domain.vo.progresscategory.PgsProgressCategoryLastTimeVo;
|
||||
import org.dromara.progress.domain.vo.progresscategory.PgsProgressCategoryProjectVo;
|
||||
import org.dromara.progress.domain.vo.progresscategory.PgsProgressCategoryVo;
|
||||
import org.dromara.progress.domain.vo.progresscategory.*;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@ -34,13 +31,21 @@ public interface IPgsProgressCategoryService extends IService<PgsProgressCategor
|
||||
PgsProgressCategoryVo queryById(Long id);
|
||||
|
||||
/**
|
||||
* 查询符合条件的进度类别列表
|
||||
* 查询进度类别
|
||||
*
|
||||
* @param req 查询条件
|
||||
* @return 进度类别列表
|
||||
*/
|
||||
List<PgsProgressCategoryVo> queryList(PgsProgressCategoryQueryReq req);
|
||||
|
||||
/**
|
||||
* 根据进度父级id查询符合条件的进度类别列表
|
||||
*
|
||||
* @param parentId 父级id
|
||||
* @return 进度类别列表
|
||||
*/
|
||||
List<PgsProgressCategoryVo> queryListByParent(Long parentId);
|
||||
|
||||
/**
|
||||
* 查询设施剩余数量
|
||||
*
|
||||
@ -55,7 +60,7 @@ public interface IPgsProgressCategoryService extends IService<PgsProgressCategor
|
||||
* @param subProjectId 子项目id
|
||||
* @return 顶级进度类别模版
|
||||
*/
|
||||
List<PgsProgressCategoryVo> getTopListByProjectId(Long subProjectId);
|
||||
List<PgsProgressCategoryTopVo> getTopListByProjectId(Long subProjectId);
|
||||
|
||||
/**
|
||||
* 新增进度类别
|
||||
@ -146,7 +151,6 @@ public interface IPgsProgressCategoryService extends IService<PgsProgressCategor
|
||||
*/
|
||||
List<PgsProgressCategory> queryListByProjectIds(List<Long> projectIds);
|
||||
|
||||
|
||||
/***
|
||||
* 获取方阵id及对应数量
|
||||
*/
|
||||
|
@ -47,6 +47,14 @@ public interface IPgsProgressCategoryTemplateService extends IService<PgsProgres
|
||||
*/
|
||||
List<PgsProgressCategoryTemplateVo> queryList(PgsProgressCategoryTemplateQueryReq req);
|
||||
|
||||
/**
|
||||
* 根据父级id获取进度类别模版列表
|
||||
*
|
||||
* @param parentId 父级id
|
||||
* @return 类别模版列表
|
||||
*/
|
||||
List<PgsProgressCategoryTemplateVo> queryListByParent(Long parentId);
|
||||
|
||||
/**
|
||||
* 新增进度类别模版
|
||||
*
|
||||
@ -83,9 +91,10 @@ public interface IPgsProgressCategoryTemplateService extends IService<PgsProgres
|
||||
/**
|
||||
* 获取系统顶级进度类别模版
|
||||
*
|
||||
* @param projectId 项目id
|
||||
* @return 系统顶级进度类别模版
|
||||
*/
|
||||
List<PgsProgressCategoryTemplateVo> listSystemTop();
|
||||
List<PgsProgressCategoryTemplateVo> listSystemTop(Long projectId);
|
||||
|
||||
/**
|
||||
* 获取进度类别模版视图对象
|
||||
|
@ -15,6 +15,7 @@ import org.dromara.progress.domain.vo.progressplandetail.PgsProgressPlanDetailNu
|
||||
import org.dromara.progress.domain.vo.progressplandetail.PgsProgressPlanDetailUnFinishVo;
|
||||
import org.dromara.progress.domain.vo.progressplandetail.PgsProgressPlanDetailVo;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -113,4 +114,13 @@ public interface IPgsProgressPlanDetailService extends IService<PgsProgressPlanD
|
||||
*/
|
||||
List<PgsProgressPlanDetail> queryListByProjectIds(List<Long> projectIds);
|
||||
|
||||
/**
|
||||
* 同步计划详情到施工产值
|
||||
*
|
||||
* @param localDate 计划日期
|
||||
* @param projectId 项目id,为空同步所有项目进度计划详情
|
||||
* @return 是否成功
|
||||
*/
|
||||
Boolean syncPlanDetail2ConstructionValue(LocalDate localDate, Long projectId);
|
||||
|
||||
}
|
||||
|
@ -4,9 +4,11 @@ import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.json.JSONArray;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.baomidou.mybatisplus.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.DateUtils;
|
||||
@ -56,6 +58,7 @@ import java.util.stream.Collectors;
|
||||
* @author lilemy
|
||||
* @date 2025-05-26
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class PgsProgressCategoryServiceImpl extends ServiceImpl<PgsProgressCategoryMapper, PgsProgressCategory>
|
||||
implements IPgsProgressCategoryService {
|
||||
@ -121,21 +124,28 @@ public class PgsProgressCategoryServiceImpl extends ServiceImpl<PgsProgressCateg
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询符合条件的进度类别列表
|
||||
* 查询进度类别
|
||||
*
|
||||
* @param req 查询条件
|
||||
* @return 进度类别列表
|
||||
*/
|
||||
@Override
|
||||
public List<PgsProgressCategoryVo> queryList(PgsProgressCategoryQueryReq req) {
|
||||
Long matrixId = req.getMatrixId();
|
||||
if (matrixService.getById(matrixId) == null) {
|
||||
return List.of();
|
||||
}
|
||||
List<PgsProgressCategory> list = this.lambdaQuery()
|
||||
.eq(PgsProgressCategory::getMatrixId, matrixId)
|
||||
.list();
|
||||
return this.getVoList(list);
|
||||
LambdaQueryWrapper<PgsProgressCategory> lqw = this.buildQueryWrapper(req);
|
||||
return this.getVoList(this.list(lqw));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据进度父级id查询符合条件的进度类别列表
|
||||
*
|
||||
* @param parentId 父级id
|
||||
* @return 进度类别列表
|
||||
*/
|
||||
@Override
|
||||
public List<PgsProgressCategoryVo> queryListByParent(Long parentId) {
|
||||
QueryWrapper<PgsProgressCategory> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.apply("FIND_IN_SET({0}, ancestors)", parentId);
|
||||
return this.getVoList(this.list(queryWrapper));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -182,7 +192,7 @@ public class PgsProgressCategoryServiceImpl extends ServiceImpl<PgsProgressCateg
|
||||
* @return 顶级进度类别模版
|
||||
*/
|
||||
@Override
|
||||
public List<PgsProgressCategoryVo> getTopListByProjectId(Long subProjectId) {
|
||||
public List<PgsProgressCategoryTopVo> getTopListByProjectId(Long subProjectId) {
|
||||
List<PgsProgressCategory> list = this.lambdaQuery()
|
||||
.eq(PgsProgressCategory::getProjectId, subProjectId)
|
||||
.eq(PgsProgressCategory::getParentId, PgsProgressCategoryConstant.TOP_PARENT_ID)
|
||||
@ -190,9 +200,43 @@ public class PgsProgressCategoryServiceImpl extends ServiceImpl<PgsProgressCateg
|
||||
if (CollUtil.isEmpty(list)) {
|
||||
return List.of();
|
||||
}
|
||||
return list.stream()
|
||||
.map(this::getVo)
|
||||
.collect(Collectors.toList());
|
||||
List<PgsProgressCategoryTopVo> topList = new ArrayList<>();
|
||||
// 获取关联子项的数据
|
||||
List<PgsProgressCategory> subList = list.stream()
|
||||
.filter(category ->
|
||||
category.getRelevancyStructure().equals(PgsRelevancyStructureEnum.SUB_PROJECT.getValue()))
|
||||
.toList();
|
||||
if (CollUtil.isNotEmpty(subList)) {
|
||||
List<PgsProgressCategoryTopVo> subVoList = subList.stream().map(category -> {
|
||||
PgsProgressCategoryTopVo vo = new PgsProgressCategoryTopVo();
|
||||
BeanUtils.copyProperties(category, vo);
|
||||
return vo;
|
||||
}).toList();
|
||||
topList.addAll(subVoList);
|
||||
}
|
||||
// 获取关联方阵数据
|
||||
List<PgsProgressCategory> matrixList = list.stream()
|
||||
.filter(category ->
|
||||
category.getRelevancyStructure().equals(PgsRelevancyStructureEnum.MATRIX.getValue()))
|
||||
.toList();
|
||||
if (CollUtil.isNotEmpty(matrixList)) {
|
||||
Map<String, List<PgsProgressCategory>> matrixMap = matrixList.stream()
|
||||
.collect(Collectors.groupingBy(PgsProgressCategory::getName));
|
||||
for (Map.Entry<String, List<PgsProgressCategory>> entry : matrixMap.entrySet()) {
|
||||
PgsProgressCategoryTopVo topVo = new PgsProgressCategoryTopVo();
|
||||
topVo.setName(entry.getKey());
|
||||
topVo.setRelevancyStructure(PgsRelevancyStructureEnum.MATRIX.getValue());
|
||||
List<PgsProgressCategory> value = entry.getValue();
|
||||
List<PgsProgressCategoryMatrixStructureTopVo> matrixVoList = value.stream().map(category -> {
|
||||
PgsProgressCategoryMatrixStructureTopVo vo = new PgsProgressCategoryMatrixStructureTopVo();
|
||||
BeanUtils.copyProperties(category, vo);
|
||||
return vo;
|
||||
}).toList();
|
||||
topVo.setMatrixStructureList(matrixVoList);
|
||||
topList.add(topVo);
|
||||
}
|
||||
}
|
||||
return topList;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -220,7 +264,11 @@ public class PgsProgressCategoryServiceImpl extends ServiceImpl<PgsProgressCateg
|
||||
if (parent == null) {
|
||||
throw new ServiceException("父进度类别模版不存在", HttpStatus.NOT_FOUND);
|
||||
}
|
||||
progressCategory.setAncestors(parent.getAncestors() + StringUtils.SEPARATOR + progressCategory.getParentId());
|
||||
String ancestors = parent.getAncestors();
|
||||
if (ancestors.split(StringUtils.SEPARATOR).length > PgsProgressCategoryConstant.MAX_LEVEL) {
|
||||
throw new ServiceException("超过最大层级", HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
progressCategory.setAncestors(ancestors + StringUtils.SEPARATOR + progressCategory.getParentId());
|
||||
}
|
||||
// 计算产值
|
||||
if (ownerPrice != null && total != null && ownerPrice.compareTo(BigDecimal.ZERO) >= 0 && total.compareTo(BigDecimal.ZERO) >= 0) {
|
||||
@ -365,7 +413,11 @@ public class PgsProgressCategoryServiceImpl extends ServiceImpl<PgsProgressCateg
|
||||
if (parent == null) {
|
||||
throw new ServiceException("父进度类别模版不存在", HttpStatus.NOT_FOUND);
|
||||
}
|
||||
progressCategory.setAncestors(parent.getAncestors() + StringUtils.SEPARATOR + progressCategory.getParentId());
|
||||
String ancestors = parent.getAncestors();
|
||||
if (ancestors.split(StringUtils.SEPARATOR).length > PgsProgressCategoryConstant.MAX_LEVEL) {
|
||||
throw new ServiceException("超过最大层级", HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
progressCategory.setAncestors(ancestors + StringUtils.SEPARATOR + progressCategory.getParentId());
|
||||
}
|
||||
// 写入数据库
|
||||
boolean result = this.updateById(progressCategory);
|
||||
@ -470,9 +522,11 @@ public class PgsProgressCategoryServiceImpl extends ServiceImpl<PgsProgressCateg
|
||||
Long projectId = req.getProjectId();
|
||||
Long matrixId = req.getMatrixId();
|
||||
String relevancyStructure = req.getRelevancyStructure();
|
||||
Long parentId = req.getParentId();
|
||||
// 精确查询
|
||||
lqw.eq(ObjectUtils.isNotEmpty(projectId), PgsProgressCategory::getProjectId, projectId);
|
||||
lqw.eq(ObjectUtils.isNotEmpty(matrixId), PgsProgressCategory::getMatrixId, matrixId);
|
||||
lqw.eq(ObjectUtils.isNotEmpty(parentId), PgsProgressCategory::getParentId, parentId);
|
||||
lqw.eq(StringUtils.isNotBlank(relevancyStructure), PgsProgressCategory::getRelevancyStructure, relevancyStructure);
|
||||
return lqw;
|
||||
}
|
||||
@ -504,7 +558,7 @@ public class PgsProgressCategoryServiceImpl extends ServiceImpl<PgsProgressCateg
|
||||
if (progressCategory.getParentId() == 0) {
|
||||
List<PgsProgressCategory> children = parentIdToChildrenMap.getOrDefault(progressCategory.getId(), Collections.emptyList());
|
||||
// 获取父节点状态
|
||||
String pidStatus = getPidStatus(children);
|
||||
String parentStatus = getParentStatus(children);
|
||||
// 累加子节点数据
|
||||
BigDecimal total = children.stream().map(PgsProgressCategory::getTotal).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
BigDecimal completed = BigDecimal.ZERO;
|
||||
@ -526,7 +580,7 @@ public class PgsProgressCategoryServiceImpl extends ServiceImpl<PgsProgressCateg
|
||||
vo.setTotal(total);
|
||||
vo.setCompleted(completed);
|
||||
vo.setPlanTotal(planTotal);
|
||||
vo.setStatus(pidStatus);
|
||||
vo.setStatus(parentStatus);
|
||||
}
|
||||
// 计算百分比
|
||||
BigDecimal total = vo.getTotal();
|
||||
@ -565,6 +619,7 @@ public class PgsProgressCategoryServiceImpl extends ServiceImpl<PgsProgressCateg
|
||||
if (CollUtil.isEmpty(categoryTemplateList)) {
|
||||
throw new ServiceException("对应模板进度类别不存在", HttpStatus.NOT_FOUND);
|
||||
}
|
||||
categoryTemplateList.sort(Comparator.comparing(PgsProgressCategoryTemplate::getAncestors));
|
||||
// 获取百分比设施数据
|
||||
Map<String, List<PgsProgressCategory>> oldPercentageCategoryMap = new HashMap<>();
|
||||
Map<Long, List<PgsProgressPlan>> oldPlanMap = new HashMap<>();
|
||||
@ -606,34 +661,39 @@ public class PgsProgressCategoryServiceImpl extends ServiceImpl<PgsProgressCateg
|
||||
List<PgsProgressPlanDetail> newPlanDetailList = new ArrayList<>();
|
||||
// 获取关联子项目的进度
|
||||
List<PgsProgressCategoryTemplate> subTemplateList = categoryTemplateList.stream()
|
||||
.filter(template -> template.getConstructionType().equals(PgsRelevancyStructureEnum.SUB_PROJECT.getValue()))
|
||||
.filter(template -> template.getRelevancyStructure().equals(PgsRelevancyStructureEnum.SUB_PROJECT.getValue()))
|
||||
.toList();
|
||||
log.info("subTemplateList:{}", subTemplateList);
|
||||
List<PgsProgressCategoryTemplate> matrixTemplateList = categoryTemplateList.stream()
|
||||
.filter(template -> template.getConstructionType().equals(PgsRelevancyStructureEnum.MATRIX.getValue()))
|
||||
.filter(template -> template.getRelevancyStructure().equals(PgsRelevancyStructureEnum.MATRIX.getValue()))
|
||||
.toList();
|
||||
log.info("matrixTemplateList:{}", matrixTemplateList);
|
||||
// 每个 matrixId 对应一套新的 ID 映射
|
||||
for (FacMatrix matrix : matrixList) {
|
||||
// templateId -> newId
|
||||
Map<Long, Long> localIdMap = new HashMap<>();
|
||||
List<PgsProgressCategory> localList = new ArrayList<>();
|
||||
for (PgsProgressCategoryTemplate template : matrixTemplateList) {
|
||||
for (PgsProgressCategoryTemplate matrixTemplate : matrixTemplateList) {
|
||||
Long newId = IdWorker.getId();
|
||||
localIdMap.put(template.getId(), newId);
|
||||
localIdMap.put(matrixTemplate.getId(), newId);
|
||||
PgsProgressCategory newCategory = new PgsProgressCategory();
|
||||
newCategory.setId(newId);
|
||||
newCategory.setName(template.getName());
|
||||
newCategory.setUnitType(template.getUnitType());
|
||||
newCategory.setWorkType(template.getWorkType());
|
||||
newCategory.setName(matrixTemplate.getName());
|
||||
newCategory.setUnitType(matrixTemplate.getUnitType());
|
||||
newCategory.setWorkType(matrixTemplate.getWorkType());
|
||||
newCategory.setProjectId(projectId);
|
||||
newCategory.setMatrixId(matrix.getId());
|
||||
newCategory.setMatrixName(matrix.getMatrixName());
|
||||
newCategory.setRemark(template.getRemark());
|
||||
newCategory.setRelevancyStructure(PgsRelevancyStructureEnum.MATRIX.getValue());
|
||||
newCategory.setRemark(matrixTemplate.getRemark());
|
||||
// 先临时设置旧 pid
|
||||
newCategory.setParentId(template.getParentId());
|
||||
newCategory.setParentId(matrixTemplate.getParentId());
|
||||
// 临时保存旧 ancestors(不转换)
|
||||
newCategory.setAncestors(matrixTemplate.getAncestors());
|
||||
localList.add(newCategory);
|
||||
// 创建百分比设施
|
||||
if (template.getParentId() != 0 && template.getUnitType().equals(PgsProgressUnitTypeEnum.PERCENTAGE.getValue())) {
|
||||
String mapKey = matrix.getMatrixName() + "_" + template.getWorkType();
|
||||
if (matrixTemplate.getParentId() != 0 && matrixTemplate.getUnitType().equals(PgsProgressUnitTypeEnum.PERCENTAGE.getValue())) {
|
||||
String mapKey = matrix.getMatrixName() + "_" + matrixTemplate.getWorkType();
|
||||
// 填充数据
|
||||
if (CollUtil.isNotEmpty(oldPercentageCategoryMap) && oldPercentageCategoryMap.containsKey(mapKey)) {
|
||||
PgsProgressCategory oldPercentageCategory = oldPercentageCategoryMap.get(mapKey).getFirst();
|
||||
@ -669,23 +729,95 @@ public class PgsProgressCategoryServiceImpl extends ServiceImpl<PgsProgressCateg
|
||||
percentageFacility.setProjectId(projectId);
|
||||
percentageFacility.setMatrixId(matrix.getId());
|
||||
percentageFacility.setProgressCategoryId(newId);
|
||||
percentageFacility.setProgressCategoryName(template.getName());
|
||||
percentageFacility.setProgressCategoryName(matrixTemplate.getName());
|
||||
percentageFacilityList.add(percentageFacility);
|
||||
}
|
||||
}
|
||||
// 修正本 matrix 的 pid
|
||||
// === 第 2 轮:修正 parentId 和 ancestors ===
|
||||
for (PgsProgressCategory category : localList) {
|
||||
// 修正本 matrix 的 parentId
|
||||
Long oldPid = category.getParentId();
|
||||
if (oldPid != 0) {
|
||||
category.setParentId(localIdMap.getOrDefault(oldPid, 0L));
|
||||
}
|
||||
String oldAncestors = category.getAncestors();
|
||||
if (StringUtils.isNotBlank(oldAncestors)) {
|
||||
String[] parts = oldAncestors.split(StringUtils.SEPARATOR);
|
||||
List<String> newAncestorsList = new ArrayList<>();
|
||||
for (String part : parts) {
|
||||
if (PgsProgressCategoryConstant.TOP_PARENT_ID.toString().equals(part)) {
|
||||
newAncestorsList.add(PgsProgressCategoryConstant.TOP_PARENT_ID.toString());
|
||||
} else {
|
||||
Long oldId = Long.valueOf(part);
|
||||
Long mappedId = localIdMap.getOrDefault(oldId, null);
|
||||
if (mappedId != null) {
|
||||
newAncestorsList.add(String.valueOf(mappedId));
|
||||
} else {
|
||||
// 如果没映射,说明是别的 matrix 的节点,可以选择跳过或者保留原值
|
||||
// 建议保留原值,避免断链
|
||||
newAncestorsList.add(part);
|
||||
}
|
||||
}
|
||||
}
|
||||
category.setAncestors(String.join(StringUtils.SEPARATOR, newAncestorsList));
|
||||
} else {
|
||||
category.setAncestors(PgsProgressCategoryConstant.TOP_PARENT_ID.toString());
|
||||
}
|
||||
}
|
||||
newList.addAll(localList);
|
||||
}
|
||||
// 新增关联子项目进度的数据
|
||||
for (PgsProgressCategoryTemplate template : subTemplateList) {
|
||||
|
||||
// templateId -> newId
|
||||
Map<Long, Long> subLocalIdMap = new HashMap<>();
|
||||
List<PgsProgressCategory> subLocalList = new ArrayList<>();
|
||||
for (PgsProgressCategoryTemplate subProjectTemplate : subTemplateList) {
|
||||
Long newId = IdWorker.getId();
|
||||
subLocalIdMap.put(subProjectTemplate.getId(), newId);
|
||||
PgsProgressCategory newCategory = new PgsProgressCategory();
|
||||
newCategory.setId(newId);
|
||||
newCategory.setName(subProjectTemplate.getName());
|
||||
newCategory.setUnitType(subProjectTemplate.getUnitType());
|
||||
newCategory.setWorkType(subProjectTemplate.getWorkType());
|
||||
newCategory.setProjectId(projectId);
|
||||
newCategory.setMatrixId(0L);
|
||||
newCategory.setRelevancyStructure(PgsRelevancyStructureEnum.SUB_PROJECT.getValue());
|
||||
newCategory.setRemark(subProjectTemplate.getRemark());
|
||||
// 先临时设置旧 pid
|
||||
newCategory.setParentId(subProjectTemplate.getParentId());
|
||||
newCategory.setAncestors(subProjectTemplate.getAncestors());
|
||||
subLocalList.add(newCategory);
|
||||
}
|
||||
// 修正本 matrix 的 pid
|
||||
for (PgsProgressCategory category : subLocalList) {
|
||||
Long oldPid = category.getParentId();
|
||||
if (oldPid != 0) {
|
||||
category.setParentId(subLocalIdMap.getOrDefault(oldPid, 0L));
|
||||
}
|
||||
String oldAncestors = category.getAncestors();
|
||||
if (StringUtils.isNotBlank(oldAncestors)) {
|
||||
String[] parts = oldAncestors.split(StringUtils.SEPARATOR);
|
||||
List<String> newAncestorsList = new ArrayList<>();
|
||||
for (String part : parts) {
|
||||
if (PgsProgressCategoryConstant.TOP_PARENT_ID.toString().equals(part)) {
|
||||
newAncestorsList.add(PgsProgressCategoryConstant.TOP_PARENT_ID.toString());
|
||||
} else {
|
||||
Long oldId = Long.valueOf(part);
|
||||
Long mappedId = subLocalIdMap.getOrDefault(oldId, null);
|
||||
if (mappedId != null) {
|
||||
newAncestorsList.add(String.valueOf(mappedId));
|
||||
} else {
|
||||
// 如果没映射,说明是别的 matrix 的节点,可以选择跳过或者保留原值
|
||||
// 建议保留原值,避免断链
|
||||
newAncestorsList.add(part);
|
||||
}
|
||||
}
|
||||
}
|
||||
category.setAncestors(String.join(StringUtils.SEPARATOR, newAncestorsList));
|
||||
} else {
|
||||
category.setAncestors(PgsProgressCategoryConstant.TOP_PARENT_ID.toString());
|
||||
}
|
||||
}
|
||||
newList.addAll(subLocalList);
|
||||
// 删除旧进度类别
|
||||
LambdaQueryWrapper<PgsProgressCategory> lqw = new LambdaQueryWrapper<>();
|
||||
lqw.eq(PgsProgressCategory::getProjectId, projectId);
|
||||
@ -959,7 +1091,7 @@ public class PgsProgressCategoryServiceImpl extends ServiceImpl<PgsProgressCateg
|
||||
* @param children 子节点列表
|
||||
* @return 父节点完成状态
|
||||
*/
|
||||
public String getPidStatus(List<PgsProgressCategory> children) {
|
||||
public String getParentStatus(List<PgsProgressCategory> children) {
|
||||
if (CollUtil.isEmpty(children)) {
|
||||
return PgsFinishStatusEnum.UNFINISH.getValue(); // 为空视为未开始
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ 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.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
@ -85,6 +86,19 @@ public class PgsProgressCategoryTemplateServiceImpl extends ServiceImpl<PgsProgr
|
||||
return list.stream().map(this::getVo).toList();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据父级id获取进度类别模版列表
|
||||
*
|
||||
* @param parentId 父级id
|
||||
* @return 类别模版列表
|
||||
*/
|
||||
@Override
|
||||
public List<PgsProgressCategoryTemplateVo> queryListByParent(Long parentId) {
|
||||
QueryWrapper<PgsProgressCategoryTemplate> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.apply("FIND_IN_SET({0}, ancestors)", parentId);
|
||||
return this.list(queryWrapper).stream().map(this::getVo).toList();
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增进度类别模版
|
||||
*
|
||||
@ -98,6 +112,7 @@ public class PgsProgressCategoryTemplateServiceImpl extends ServiceImpl<PgsProgr
|
||||
BeanUtils.copyProperties(req, progressCategoryTemplate);
|
||||
Long projectId = req.getProjectId();
|
||||
String constructionType = req.getConstructionType();
|
||||
String relevancyStructure = req.getRelevancyStructure();
|
||||
if (projectId == 0 && constructionType == null) {
|
||||
throw new ServiceException("请选择项目施工类型", HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
@ -107,13 +122,21 @@ public class PgsProgressCategoryTemplateServiceImpl extends ServiceImpl<PgsProgr
|
||||
// 获取祖级列表
|
||||
if (PgsProgressCategoryConstant.TOP_PARENT_ID.equals(progressCategoryTemplate.getParentId())) {
|
||||
progressCategoryTemplate.setAncestors(PgsProgressCategoryConstant.TOP_PARENT_ID.toString());
|
||||
// 只有顶级节点选择关联项目结构
|
||||
progressCategoryTemplate.setRelevancyStructure(relevancyStructure);
|
||||
} else {
|
||||
Long parentId = req.getParentId();
|
||||
PgsProgressCategoryTemplate parent = this.getById(parentId);
|
||||
if (parent == null) {
|
||||
throw new ServiceException("父进度类别模版不存在", HttpStatus.NOT_FOUND);
|
||||
}
|
||||
progressCategoryTemplate.setAncestors(parent.getAncestors() + StringUtils.SEPARATOR + progressCategoryTemplate.getParentId());
|
||||
String ancestors = parent.getAncestors();
|
||||
if (ancestors.split(StringUtils.SEPARATOR).length > PgsProgressCategoryConstant.MAX_LEVEL) {
|
||||
throw new ServiceException("超过最大层级", HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
progressCategoryTemplate.setAncestors(ancestors + StringUtils.SEPARATOR + progressCategoryTemplate.getParentId());
|
||||
// 子级根据父级关联项目结构进行关联
|
||||
progressCategoryTemplate.setRelevancyStructure(parent.getRelevancyStructure());
|
||||
}
|
||||
// 写入数据库
|
||||
boolean result = this.save(progressCategoryTemplate);
|
||||
@ -150,7 +173,11 @@ public class PgsProgressCategoryTemplateServiceImpl extends ServiceImpl<PgsProgr
|
||||
if (parent == null) {
|
||||
throw new ServiceException("父进度类别模版不存在", HttpStatus.NOT_FOUND);
|
||||
}
|
||||
progressCategoryTemplate.setAncestors(parent.getAncestors() + StringUtils.SEPARATOR + progressCategoryTemplate.getParentId());
|
||||
String ancestors = parent.getAncestors();
|
||||
if (ancestors.split(StringUtils.SEPARATOR).length > PgsProgressCategoryConstant.MAX_LEVEL) {
|
||||
throw new ServiceException("超过最大层级", HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
progressCategoryTemplate.setAncestors(ancestors + StringUtils.SEPARATOR + progressCategoryTemplate.getParentId());
|
||||
}
|
||||
// 写入数据库
|
||||
boolean result = this.updateById(progressCategoryTemplate);
|
||||
@ -239,6 +266,7 @@ public class PgsProgressCategoryTemplateServiceImpl extends ServiceImpl<PgsProgr
|
||||
if (CollUtil.isEmpty(categoryTemplateList)) {
|
||||
throw new ServiceException("对应模板进度类别不存在", HttpStatus.NOT_FOUND);
|
||||
}
|
||||
categoryTemplateList.sort(Comparator.comparing(PgsProgressCategoryTemplate::getAncestors));
|
||||
// templateId -> newId
|
||||
Map<Long, Long> localIdMap = new HashMap<>();
|
||||
List<PgsProgressCategoryTemplate> localList = new ArrayList<>();
|
||||
@ -252,9 +280,28 @@ public class PgsProgressCategoryTemplateServiceImpl extends ServiceImpl<PgsProgr
|
||||
newTemp.setWorkType(temp.getWorkType());
|
||||
newTemp.setProjectId(projectId);
|
||||
newTemp.setConstructionType(temp.getConstructionType());
|
||||
newTemp.setRelevancyStructure(temp.getRelevancyStructure());
|
||||
newTemp.setRemark(temp.getRemark());
|
||||
// 先临时设置旧 pid
|
||||
newTemp.setParentId(temp.getParentId());
|
||||
// ====== 处理 ancestors ======
|
||||
String oldAncestors = temp.getAncestors(); // 比如 "0,1958931191474941953"
|
||||
if (StringUtils.isNotBlank(oldAncestors)) {
|
||||
String[] parts = oldAncestors.split(StringUtils.SEPARATOR);
|
||||
List<String> newAncestorsList = new ArrayList<>();
|
||||
for (String part : parts) {
|
||||
if (PgsProgressCategoryConstant.TOP_PARENT_ID.toString().equals(part)) {
|
||||
newAncestorsList.add(PgsProgressCategoryConstant.TOP_PARENT_ID.toString());
|
||||
} else {
|
||||
Long oldId = Long.valueOf(part);
|
||||
Long mappedId = localIdMap.getOrDefault(oldId, oldId);
|
||||
newAncestorsList.add(String.valueOf(mappedId));
|
||||
}
|
||||
}
|
||||
newTemp.setAncestors(String.join(StringUtils.SEPARATOR, newAncestorsList));
|
||||
} else {
|
||||
newTemp.setAncestors(PgsProgressCategoryConstant.TOP_PARENT_ID.toString());
|
||||
}
|
||||
localList.add(newTemp);
|
||||
}
|
||||
// 修正本 matrix 的 pid
|
||||
@ -275,12 +322,13 @@ public class PgsProgressCategoryTemplateServiceImpl extends ServiceImpl<PgsProgr
|
||||
/**
|
||||
* 获取系统顶级进度类别模版
|
||||
*
|
||||
* @param projectId 项目id
|
||||
* @return 系统顶级进度类别模版
|
||||
*/
|
||||
@Override
|
||||
public List<PgsProgressCategoryTemplateVo> listSystemTop() {
|
||||
public List<PgsProgressCategoryTemplateVo> listSystemTop(Long projectId) {
|
||||
List<PgsProgressCategoryTemplate> list = this.lambdaQuery()
|
||||
.eq(PgsProgressCategoryTemplate::getProjectId, PgsProgressCategoryConstant.TOP_PARENT_ID)
|
||||
.eq(PgsProgressCategoryTemplate::getProjectId, projectId)
|
||||
.eq(PgsProgressCategoryTemplate::getParentId, PgsProgressCategoryConstant.TOP_PARENT_ID)
|
||||
.list();
|
||||
if (CollUtil.isEmpty(list)) {
|
||||
|
@ -20,6 +20,8 @@ import org.dromara.facility.domain.*;
|
||||
import org.dromara.facility.domain.enums.FacFinishStatusEnum;
|
||||
import org.dromara.facility.domain.enums.FacFinishTypeEnum;
|
||||
import org.dromara.facility.service.*;
|
||||
import org.dromara.out.domain.OutConstructionValue;
|
||||
import org.dromara.out.service.IOutConstructionValueService;
|
||||
import org.dromara.progress.constant.PgsProgressCategoryConstant;
|
||||
import org.dromara.progress.domain.PgsProgressCategory;
|
||||
import org.dromara.progress.domain.PgsProgressPlan;
|
||||
@ -48,6 +50,8 @@ import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 进度计划详情Service业务层处理
|
||||
@ -87,6 +91,9 @@ public class PgsProgressPlanDetailServiceImpl extends ServiceImpl<PgsProgressPla
|
||||
@Resource
|
||||
private IFacPhotovoltaicPanelColumnService photovoltaicPanelColumnService;
|
||||
|
||||
@Resource
|
||||
private IOutConstructionValueService constructionValueService;
|
||||
|
||||
/**
|
||||
* 分页查询进度计划详情列表
|
||||
*
|
||||
@ -126,7 +133,7 @@ public class PgsProgressPlanDetailServiceImpl extends ServiceImpl<PgsProgressPla
|
||||
}
|
||||
BigDecimal oldFinishedNumber = progressPlan.getFinishedNumber();
|
||||
// todo 判断完成时间是否大于当前时间
|
||||
Date planDate = progressPlanDetail.getDate();
|
||||
LocalDate planDate = progressPlanDetail.getDate();
|
||||
/* if (planDate.after(new Date())) {
|
||||
throw new ServiceException("完成时间不能大于当前时间", HttpStatus.BAD_REQUEST);
|
||||
}*/
|
||||
@ -754,6 +761,72 @@ public class PgsProgressPlanDetailServiceImpl extends ServiceImpl<PgsProgressPla
|
||||
.list();
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步计划详情到施工产值
|
||||
*
|
||||
* @param localDate 计划日期
|
||||
* @param projectId 项目id,为空同步所有项目进度计划详情
|
||||
* @return 是否成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean syncPlanDetail2ConstructionValue(LocalDate localDate, Long projectId) {
|
||||
// 获取当天的计划详情
|
||||
List<PgsProgressPlanDetail> planDetailList = this.lambdaQuery()
|
||||
.eq(ObjectUtils.isNotEmpty(projectId), PgsProgressPlanDetail::getProjectId, projectId)
|
||||
.eq(PgsProgressPlanDetail::getDate, localDate)
|
||||
.list();
|
||||
if (CollUtil.isEmpty(planDetailList)) {
|
||||
return false;
|
||||
}
|
||||
// 获取进度类别
|
||||
List<Long> categoryIds = planDetailList.stream()
|
||||
.map(PgsProgressPlanDetail::getProgressCategoryId)
|
||||
.distinct()
|
||||
.toList();
|
||||
List<PgsProgressCategory> categoryList = progressCategoryService.lambdaQuery()
|
||||
.in(CollUtil.isNotEmpty(categoryIds), PgsProgressCategory::getId, categoryIds)
|
||||
.list();
|
||||
Map<Long, PgsProgressCategory> categoryMap = categoryList.stream()
|
||||
.collect(
|
||||
Collectors.toMap(PgsProgressCategory::getId,
|
||||
Function.identity(),
|
||||
(v1, v2) -> v1)
|
||||
);
|
||||
List<OutConstructionValue> saveList = new ArrayList<>();
|
||||
for (PgsProgressPlanDetail planDetail : planDetailList) {
|
||||
OutConstructionValue value = new OutConstructionValue();
|
||||
Long progressCategoryId = planDetail.getProgressCategoryId();
|
||||
PgsProgressCategory category = categoryMap.get(progressCategoryId);
|
||||
if (category == null) {
|
||||
continue;
|
||||
}
|
||||
value.setProjectId(planDetail.getProjectId());
|
||||
value.setMatrixId(category.getMatrixId());
|
||||
value.setProgressCategoryId(progressCategoryId);
|
||||
int artificialNum = planDetail.getFinishedNumber().intValue();
|
||||
value.setArtificialNum(artificialNum);
|
||||
int uavNum = planDetail.getAiFill().intValue();
|
||||
value.setUavNum(uavNum);
|
||||
value.setPlanNum(planDetail.getPlanNumber().intValue());
|
||||
value.setReportDate(LocalDate.now());
|
||||
value.setPlanDate(planDetail.getDate());
|
||||
// 计算产值
|
||||
BigDecimal constructionPrice = category.getConstructionPrice();
|
||||
BigDecimal ownerPrice = category.getOwnerPrice();
|
||||
value.setOutValue(constructionPrice.multiply(BigDecimal.valueOf(artificialNum)).add(constructionPrice.multiply(BigDecimal.valueOf(uavNum))));
|
||||
value.setOwnerValue(ownerPrice.multiply(BigDecimal.valueOf(artificialNum)).add(ownerPrice.multiply(BigDecimal.valueOf(uavNum))));
|
||||
saveList.add(value);
|
||||
}
|
||||
// 保存数据
|
||||
if (CollUtil.isNotEmpty(saveList)) {
|
||||
boolean saved = constructionValueService.saveBatch(saveList);
|
||||
if (!saved) {
|
||||
throw new ServiceException("同步计划详情到施工产值失败,数据库异常", HttpStatus.ERROR);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*
|
||||
@ -803,7 +876,7 @@ public class PgsProgressPlanDetailServiceImpl extends ServiceImpl<PgsProgressPla
|
||||
Long projectId,
|
||||
Long progressCategoryId,
|
||||
List<Long> finishedDetailIdList,
|
||||
Date finishDate,
|
||||
LocalDate finishDate,
|
||||
IService<T> service,
|
||||
SFunction<T, Long> getIdFunc,
|
||||
SFunction<T, String> getNameFunc,
|
||||
|
@ -131,8 +131,9 @@ public class PgsProgressPlanServiceImpl extends ServiceImpl<PgsProgressPlanMappe
|
||||
}
|
||||
Long matrixId = progressPlan.getMatrixId();
|
||||
FacMatrix matrix = matrixService.getById(matrixId);
|
||||
if (matrix == null) {
|
||||
throw new ServiceException("对应方阵不存在", HttpStatus.NOT_FOUND);
|
||||
String matrixName = null;
|
||||
if (matrix != null) {
|
||||
matrixName = matrix.getMatrixName();
|
||||
}
|
||||
Long progressCategoryId = progressPlan.getProgressCategoryId();
|
||||
// 校验日期是否合法
|
||||
@ -147,7 +148,7 @@ public class PgsProgressPlanServiceImpl extends ServiceImpl<PgsProgressPlanMappe
|
||||
PgsProgressCategory progressCategory = progressCategoryService.getById(progressCategoryId);
|
||||
this.validPlanNumber(req.getPlanNumber(), progressCategory);
|
||||
progressPlan.setProgressCategoryName(progressCategory.getName());
|
||||
progressPlan.setMatrixName(matrix.getMatrixName());
|
||||
progressPlan.setMatrixName(matrixName);
|
||||
// 操作数据库
|
||||
boolean save = this.save(progressPlan);
|
||||
if (!save) {
|
||||
@ -333,6 +334,9 @@ public class PgsProgressPlanServiceImpl extends ServiceImpl<PgsProgressPlanMappe
|
||||
}
|
||||
String unitTypeMsg = "数量";
|
||||
BigDecimal total = progressCategory.getTotal();
|
||||
if (total == null || total.compareTo(BigDecimal.ZERO) <= 0) {
|
||||
throw new ServiceException("请导入分项工程数量后再添加计划", HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
// 百分比项目需乘以总数
|
||||
if (progressCategory.getUnitType().equals(PgsProgressUnitTypeEnum.PERCENTAGE.getValue())) {
|
||||
planNumber = planNumber.multiply(total).divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP);
|
||||
|
@ -37,6 +37,7 @@ import org.dromara.facility.service.IFacMatrixService;
|
||||
import org.dromara.manager.weathermanager.WeatherConstant;
|
||||
import org.dromara.manager.weathermanager.WeatherManager;
|
||||
import org.dromara.progress.domain.PgsProgressCategory;
|
||||
import org.dromara.progress.domain.enums.PgsRelevancyStructureEnum;
|
||||
import org.dromara.progress.domain.vo.progresscategory.PgsProgressCategoryStructureVo;
|
||||
import org.dromara.progress.service.IPgsProgressCategoryService;
|
||||
import org.dromara.progress.service.IPgsProgressCategoryTemplateService;
|
||||
@ -71,6 +72,7 @@ import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* 项目Service业务层处理
|
||||
@ -953,6 +955,10 @@ public class BusProjectServiceImpl extends ServiceImpl<BusProjectMapper, BusProj
|
||||
List<PgsProgressCategory> progressCategoryList = progressCategoryService.lambdaQuery()
|
||||
.in(PgsProgressCategory::getMatrixId, matrixIds)
|
||||
.list();
|
||||
List<PgsProgressCategory> subProgressCategoryList = progressCategoryService.lambdaQuery()
|
||||
.eq(PgsProgressCategory::getRelevancyStructure, PgsRelevancyStructureEnum.SUB_PROJECT.getValue())
|
||||
.in(PgsProgressCategory::getProjectId, subProjectIds)
|
||||
.list();
|
||||
|
||||
// 构造子项目结构
|
||||
List<BusSubProjectStructureVo> subProjectStructures = subProjects.stream().map(subProject -> {
|
||||
@ -960,6 +966,18 @@ public class BusProjectServiceImpl extends ServiceImpl<BusProjectMapper, BusProj
|
||||
subProjectVo.setId(subProject.getId());
|
||||
subProjectVo.setName(subProject.getProjectName());
|
||||
|
||||
List<PgsProgressCategory> subCategory = subProgressCategoryList.stream()
|
||||
.filter(c -> Objects.equals(c.getProjectId(), subProject.getId()))
|
||||
.toList();
|
||||
|
||||
List<FacMatrixStructureVo> structureVoList = subCategory.stream()
|
||||
.map(category -> {
|
||||
FacMatrixStructureVo matrixVo = new FacMatrixStructureVo();
|
||||
matrixVo.setId(category.getId());
|
||||
matrixVo.setName(category.getName());
|
||||
return matrixVo;
|
||||
}).toList();
|
||||
|
||||
// 找到该子项目下的方阵
|
||||
List<FacMatrix> matrices = matrixMap.getOrDefault(subProject.getId(), new ArrayList<>());
|
||||
List<FacMatrixStructureVo> matrixVos = matrices.stream().map(matrix -> {
|
||||
@ -977,8 +995,11 @@ public class BusProjectServiceImpl extends ServiceImpl<BusProjectMapper, BusProj
|
||||
matrixVo.setChildren(categoryTree);
|
||||
return matrixVo;
|
||||
}).toList();
|
||||
|
||||
subProjectVo.setChildren(matrixVos);
|
||||
List<FacMatrixStructureVo> resultList = Stream.concat(
|
||||
structureVoList.stream(),
|
||||
matrixVos.stream()
|
||||
).toList();
|
||||
subProjectVo.setChildren(resultList);
|
||||
return subProjectVo;
|
||||
}).toList();
|
||||
|
||||
|
Reference in New Issue
Block a user