diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/facility/domain/enums/FacFinishTypeEnum.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/facility/domain/enums/FacFinishTypeEnum.java new file mode 100644 index 00000000..cbea64e4 --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/facility/domain/enums/FacFinishTypeEnum.java @@ -0,0 +1,24 @@ +package org.dromara.facility.domain.enums; + +import lombok.Getter; + +/** + * @author lcj + * @date 2025/5/28 10:17 + */ +@Getter +public enum FacFinishTypeEnum { + + HAND("手动填报", "1"), + AI("AI填报", "2"); + + private final String text; + + private final String value; + + FacFinishTypeEnum(String text, String value) { + this.text = text; + this.value = value; + } + +} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/facility/service/impl/FacBoxTransformerServiceImpl.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/facility/service/impl/FacBoxTransformerServiceImpl.java index fe1934d6..2517ec3e 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/facility/service/impl/FacBoxTransformerServiceImpl.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/facility/service/impl/FacBoxTransformerServiceImpl.java @@ -30,7 +30,7 @@ import org.dromara.progress.constant.PgsProgressCategoryConstant; import org.dromara.progress.domain.PgsProgressCategory; import org.dromara.progress.service.IPgsProgressCategoryService; import org.dromara.project.service.IBusProjectService; -import org.dromara.utils.JSTUtils; +import org.dromara.utils.JSTUtil; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -191,7 +191,7 @@ public class FacBoxTransformerServiceImpl extends ServiceImpl> coordinatesList = JSTUtils.getTwoDimensionalCoordinates(geometry); + List> coordinatesList = JSTUtil.getTwoDimensionalCoordinates(geometry); // 获取方阵名称 - String nameStr = JSTUtils.findNearestPointText(coordinatesList, nameFeatures); + String nameStr = JSTUtil.findNearestPointText(coordinatesList, nameFeatures); String name = nameStr.split(" ")[0]; if (name == null) { continue; @@ -528,7 +528,7 @@ public class FacMatrixServiceImpl extends ServiceImpl> pointInPlaneList = JSTUtils.getPointInPlaneList(positionList, pointPositionList); + List> pointInPlaneList = JSTUtil.getPointInPlaneList(positionList, pointPositionList); // 删除点在面内的点 pointPositionList.removeAll(pointInPlaneList); // 判断点在面内的点是否为空 diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/facility/service/impl/FacPhotovoltaicPanelServiceImpl.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/facility/service/impl/FacPhotovoltaicPanelServiceImpl.java index 4c8f0760..f3f91d18 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/facility/service/impl/FacPhotovoltaicPanelServiceImpl.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/facility/service/impl/FacPhotovoltaicPanelServiceImpl.java @@ -32,7 +32,7 @@ import org.dromara.progress.constant.PgsProgressCategoryConstant; import org.dromara.progress.domain.PgsProgressCategory; import org.dromara.progress.service.IPgsProgressCategoryService; import org.dromara.project.service.IBusProjectService; -import org.dromara.utils.JSTUtils; +import org.dromara.utils.JSTUtil; import org.springframework.aop.framework.AopContext; import org.springframework.beans.BeanUtils; import org.springframework.context.annotation.Lazy; @@ -216,7 +216,7 @@ public class FacPhotovoltaicPanelServiceImpl extends ServiceImpl getLastTimeInfo(@NotNull(message = "主键不能为空") + @PathVariable Long id) { + return R.ok(pgsProgressCategoryService.queryLastTimeById(id)); + } + /** * 新增进度类别 */ diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/controller/PgsProgressPlanController.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/controller/PgsProgressPlanController.java index f818abe9..658eeb6f 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/controller/PgsProgressPlanController.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/controller/PgsProgressPlanController.java @@ -83,13 +83,13 @@ public class PgsProgressPlanController extends BaseController { /** * 删除进度计划 * - * @param ids 主键串 + * @param id 主键 */ @SaCheckPermission("progress:progressPlan:remove") @Log(title = "进度计划", businessType = BusinessType.DELETE) - @DeleteMapping("/{ids}") + @DeleteMapping("/{id}") public R remove(@NotEmpty(message = "主键不能为空") - @PathVariable Long[] ids) { - return toAjax(pgsProgressPlanService.deleteWithValidByIds(List.of(ids), true)); + @PathVariable Long id) { + return toAjax(pgsProgressPlanService.deleteById(id)); } } diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/controller/PgsProgressPlanDetailController.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/controller/PgsProgressPlanDetailController.java index 6d03d95b..842d7e00 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/controller/PgsProgressPlanDetailController.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/controller/PgsProgressPlanDetailController.java @@ -2,27 +2,20 @@ package org.dromara.progress.controller; import cn.dev33.satoken.annotation.SaCheckPermission; import jakarta.annotation.Resource; -import jakarta.servlet.http.HttpServletResponse; import jakarta.validation.constraints.NotNull; import org.dromara.common.core.domain.R; -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; -import org.dromara.common.log.enums.BusinessType; import org.dromara.common.mybatis.core.page.PageQuery; import org.dromara.common.mybatis.core.page.TableDataInfo; import org.dromara.common.web.core.BaseController; -import org.dromara.progress.domain.dto.progressplandetail.PgsProgressPlanDetailQueryReq; -import org.dromara.progress.domain.dto.progressplandetail.PgsProgressPlanDetailUpdateReq; -import org.dromara.progress.domain.vo.progressplandetail.PgsProgressPlanDetailFacilityVo; -import org.dromara.progress.domain.vo.progressplandetail.PgsProgressPlanDetailVo; +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.vo.progressplandetail.PgsProgressPlanDetailFinishedVo; +import org.dromara.progress.domain.vo.progressplandetail.PgsProgressPlanDetailUnFinishVo; import org.dromara.progress.service.IPgsProgressPlanDetailService; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; -import java.util.List; - /** * 进度计划详情 * @@ -38,59 +31,56 @@ public class PgsProgressPlanDetailController extends BaseController { private IPgsProgressPlanDetailService pgsProgressPlanDetailService; /** - * 查询进度计划详情列表 + * 新增进度计划详情(普通设施) */ - @SaCheckPermission("progress:progressPlanDetail:list") - @GetMapping("/list") - public TableDataInfo list(PgsProgressPlanDetailQueryReq req, PageQuery pageQuery) { - return pgsProgressPlanDetailService.queryPageList(req, pageQuery); + @SaCheckPermission("progress:progressPlanDetail:insert") + @PostMapping("/insert/detail") + public R insertFinishedDetail(@Validated @RequestBody PgsProgressPlanDetailFinishedCreateReq req) { + return toAjax(pgsProgressPlanDetailService.insertFinishedDetail(req)); } /** - * 导出进度计划详情列表 + * 新增进度计划详情(百分比设施) */ - @SaCheckPermission("progress:progressPlanDetail:export") - @Log(title = "进度计划详情", businessType = BusinessType.EXPORT) - @PostMapping("/export") - public void export(PgsProgressPlanDetailQueryReq req, HttpServletResponse response) { - List list = pgsProgressPlanDetailService.queryList(req); - ExcelUtil.exportExcel(list, "进度计划详情", PgsProgressPlanDetailVo.class, response); + @SaCheckPermission("progress:progressPlanDetail:insert") + @PostMapping("/insert/percentage") + public R insertPercentageDetail(@Validated @RequestBody PgsProgressPlanDetailPercentageCreateReq req) { + return toAjax(pgsProgressPlanDetailService.insertPercentageDetail(req)); } /** - * 获取进度计划详情详细信息 + * 获取进度计划详情已完成设施详细信息 * * @param id 主键 */ @SaCheckPermission("progress:progressPlanDetail:query") - @GetMapping("/{id}") - public R getInfo(@NotNull(message = "主键不能为空") - @PathVariable Long id) { - return R.ok(pgsProgressPlanDetailService.queryById(id)); + @GetMapping("/detail/finished/{id}") + public TableDataInfo getFinishedDetail(@NotNull(message = "主键不能为空") + @PathVariable Long id, + PageQuery pageQuery) { + return pgsProgressPlanDetailService.queryFinishedById(id, pageQuery); } /** - * 获取进度计划详情详细信息 + * 获取进度计划详情未完成设施详细信息 * * @param id 主键 */ @SaCheckPermission("progress:progressPlanDetail:query") - @GetMapping("/detail/{id}") - public R> getDetail(@NotNull(message = "主键不能为空") - @PathVariable Long id, - PageQuery pageQuery) { - return R.ok(pgsProgressPlanDetailService.queryFacilityById(id, pageQuery)); + @GetMapping("/detail/unFinish/{id}") + public TableDataInfo getUnFinishDetail(@NotNull(message = "主键不能为空") + @PathVariable Long id, + PageQuery pageQuery) { + return pgsProgressPlanDetailService.queryUnFinishById(id, pageQuery); } /** - * 修改进度计划详情 + * 删除进度计划详情 */ - @SaCheckPermission("progress:progressPlanDetail:edit") - @Log(title = "进度计划详情", businessType = BusinessType.UPDATE) - @RepeatSubmit() - @PutMapping() - public R edit(@Validated(EditGroup.class) @RequestBody PgsProgressPlanDetailUpdateReq req) { - return toAjax(pgsProgressPlanDetailService.updateByBo(req)); + @SaCheckPermission("progress:progressPlanDetail:remove") + @DeleteMapping("/remove/detail") + public R removeDetail(@Validated PgsProgressPlanDetailRemoveReq req) { + return toAjax(pgsProgressPlanDetailService.removeDetail(req)); } } diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/domain/PgsProgressPlan.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/domain/PgsProgressPlan.java index 1bb8232d..8f3773d8 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/domain/PgsProgressPlan.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/domain/PgsProgressPlan.java @@ -75,6 +75,11 @@ public class PgsProgressPlan extends BaseEntity { */ private Long finishedNumber; + /** + * 延期数量/百分比 + */ + private Long delayNumber; + /** * 删除时间 */ diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/domain/PgsProgressPlanDetail.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/domain/PgsProgressPlanDetail.java index 8c7ad6d1..84714727 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/domain/PgsProgressPlanDetail.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/domain/PgsProgressPlanDetail.java @@ -40,6 +40,11 @@ public class PgsProgressPlanDetail extends BaseEntity { */ private Long progressPlanId; + /** + * 进度类型id + */ + private Long progressCategoryId; + /** * 计划时间 */ @@ -55,6 +60,11 @@ public class PgsProgressPlanDetail extends BaseEntity { */ private Long finishedNumber; + /** + * 完成详情 + */ + private String finishedDetail; + /** * AI填入数量 */ diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/domain/dto/progressplandetail/PgsProgressPlanDetailFinishedCreateReq.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/domain/dto/progressplandetail/PgsProgressPlanDetailFinishedCreateReq.java new file mode 100644 index 00000000..bc4bfc39 --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/domain/dto/progressplandetail/PgsProgressPlanDetailFinishedCreateReq.java @@ -0,0 +1,34 @@ +package org.dromara.progress.domain.dto.progressplandetail; + +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; +import java.util.List; + +/** + * @author lcj + * @date 2025/5/28 9:36 + */ +@Data +public class PgsProgressPlanDetailFinishedCreateReq implements Serializable { + + @Serial + private static final long serialVersionUID = -5685368912659847672L; + + /** + * 主键id + */ + private Long id; + + /** + * 项目id + */ + private Long projectId; + + /** + * 完成详情id列表 + */ + private List finishedDetailIdList; + +} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/domain/dto/progressplandetail/PgsProgressPlanDetailPercentageCreateReq.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/domain/dto/progressplandetail/PgsProgressPlanDetailPercentageCreateReq.java new file mode 100644 index 00000000..9738c79b --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/domain/dto/progressplandetail/PgsProgressPlanDetailPercentageCreateReq.java @@ -0,0 +1,28 @@ +package org.dromara.progress.domain.dto.progressplandetail; + +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; + +/** + * @author lcj + * @date 2025/5/28 16:06 + */ +@Data +public class PgsProgressPlanDetailPercentageCreateReq implements Serializable { + + @Serial + private static final long serialVersionUID = -2987044313320050949L; + + /** + * 主键id + */ + private Long id; + + /** + * 完成数量 + */ + private Long finishedNumber; + +} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/domain/dto/progressplandetail/PgsProgressPlanDetailQueryReq.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/domain/dto/progressplandetail/PgsProgressPlanDetailQueryReq.java deleted file mode 100644 index 7dba19ec..00000000 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/domain/dto/progressplandetail/PgsProgressPlanDetailQueryReq.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.dromara.progress.domain.dto.progressplandetail; - -import lombok.Data; - -import java.io.Serial; -import java.io.Serializable; -import java.util.Date; - -/** - * @author lcj - * @date 2025/5/27 10:58 - */ -@Data -public class PgsProgressPlanDetailQueryReq implements Serializable { - - @Serial - private static final long serialVersionUID = -1135087412952022463L; - - /** - * 项目id - */ - private Long projectId; - - /** - * 进度计划id - */ - private Long progressPlanId; - - /** - * 计划时间 - */ - private Date date; - -} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/domain/dto/progressplandetail/PgsProgressPlanDetailRemoveReq.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/domain/dto/progressplandetail/PgsProgressPlanDetailRemoveReq.java new file mode 100644 index 00000000..17b928d0 --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/domain/dto/progressplandetail/PgsProgressPlanDetailRemoveReq.java @@ -0,0 +1,29 @@ +package org.dromara.progress.domain.dto.progressplandetail; + +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; +import java.util.List; + +/** + * @author lcj + * @date 2025/5/28 16:34 + */ +@Data +public class PgsProgressPlanDetailRemoveReq implements Serializable { + + @Serial + private static final long serialVersionUID = 2345733680238879534L; + + /** + * 主键id + */ + private Long id; + + /** + * 详情id列表 + */ + private List detailIdList; + +} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/domain/dto/progressplandetail/PgsProgressPlanDetailUpdateReq.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/domain/dto/progressplandetail/PgsProgressPlanDetailUpdateReq.java deleted file mode 100644 index 3630c8af..00000000 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/domain/dto/progressplandetail/PgsProgressPlanDetailUpdateReq.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.dromara.progress.domain.dto.progressplandetail; - -import lombok.Data; - -import java.io.Serial; -import java.io.Serializable; - -/** - * @author lcj - * @date 2025/5/27 10:58 - */ -@Data -public class PgsProgressPlanDetailUpdateReq implements Serializable { - - @Serial - private static final long serialVersionUID = -3397212461695330079L; - -} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/domain/enums/PgsFinishStatusEnum.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/domain/enums/PgsFinishStatusEnum.java new file mode 100644 index 00000000..cdc44281 --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/domain/enums/PgsFinishStatusEnum.java @@ -0,0 +1,25 @@ +package org.dromara.progress.domain.enums; + +import lombok.Getter; + +/** + * @author lcj + * @date 2025/5/28 18:49 + */ +@Getter +public enum PgsFinishStatusEnum { + + UNFINISH("未开始", "0"), + INPROGRESS("进行中", "1"), + FINISH("已完成", "2"); + + private final String text; + + private final String value; + + PgsFinishStatusEnum(String text, String value) { + this.text = text; + this.value = value; + } + +} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/domain/vo/progresscategory/PgsProgressCategoryLastTimeVo.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/domain/vo/progresscategory/PgsProgressCategoryLastTimeVo.java new file mode 100644 index 00000000..965428a5 --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/domain/vo/progresscategory/PgsProgressCategoryLastTimeVo.java @@ -0,0 +1,27 @@ +package org.dromara.progress.domain.vo.progresscategory; + +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +/** + * @author lcj + * @date 2025/5/28 11:36 + */ +@Data +public class PgsProgressCategoryLastTimeVo implements Serializable { + + @Serial + private static final long serialVersionUID = -3509755254504905644L; + + /** + * 计划结束时间 + */ + private Date endDate; + + private BigDecimal leftNum; + +} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/domain/vo/progresscategory/PgsProgressCategoryVo.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/domain/vo/progresscategory/PgsProgressCategoryVo.java index 7934118c..0f67262a 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/domain/vo/progresscategory/PgsProgressCategoryVo.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/domain/vo/progresscategory/PgsProgressCategoryVo.java @@ -89,12 +89,14 @@ public class PgsProgressCategoryVo implements Serializable { /** * 已完成数量百分比 */ - private String completedPercentage; + @JsonSerialize(using = BigDecimalToIntegerSerializer.class) + private BigDecimal completedPercentage; /** * 计划中数量百分比 */ - private String planTotalPercentage; + @JsonSerialize(using = BigDecimalToIntegerSerializer.class) + private BigDecimal planTotalPercentage; /** * 是否超期(0否 1是) diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/domain/vo/progressplan/PgsProgressPlanVo.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/domain/vo/progressplan/PgsProgressPlanVo.java index 9f8c54be..1b4dde02 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/domain/vo/progressplan/PgsProgressPlanVo.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/domain/vo/progressplan/PgsProgressPlanVo.java @@ -2,6 +2,7 @@ package org.dromara.progress.domain.vo.progressplan; 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.PgsProgressPlan; @@ -48,12 +49,14 @@ public class PgsProgressPlanVo implements Serializable { /** * 计划开始时间 */ + @JsonFormat(pattern = "yyyy-MM-dd") @ExcelProperty(value = "计划开始时间") private Date startDate; /** * 计划结束时间 */ + @JsonFormat(pattern = "yyyy-MM-dd") @ExcelProperty(value = "计划结束时间") private Date endDate; @@ -69,6 +72,17 @@ public class PgsProgressPlanVo implements Serializable { @ExcelProperty(value = "完成数量/百分比") private Long finishedNumber; + /** + * 延期数量/百分比 + */ + @ExcelProperty(value = "延迟数量/百分比") + private Long delayNumber; + + /** + * AI自动填入 + */ + private Long aiFill; + /** * 进度计划详情 */ diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/domain/vo/progressplandetail/PgsProgressPlanDetailFinishedVo.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/domain/vo/progressplandetail/PgsProgressPlanDetailFinishedVo.java new file mode 100644 index 00000000..e46af92c --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/domain/vo/progressplandetail/PgsProgressPlanDetailFinishedVo.java @@ -0,0 +1,31 @@ +package org.dromara.progress.domain.vo.progressplandetail; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author lcj + * @date 2025/5/28 10:20 + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class PgsProgressPlanDetailFinishedVo { + + /** + * 设施id + */ + private Long id; + + /** + * 设施名称 + */ + private String name; + + /** + * 设施完成类型 + */ + private String finishType; + +} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/domain/vo/progressplandetail/PgsProgressPlanDetailNumVo.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/domain/vo/progressplandetail/PgsProgressPlanDetailNumVo.java index 0d5eabcb..1ddbb60f 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/domain/vo/progressplandetail/PgsProgressPlanDetailNumVo.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/domain/vo/progressplandetail/PgsProgressPlanDetailNumVo.java @@ -1,5 +1,6 @@ package org.dromara.progress.domain.vo.progressplandetail; +import com.fasterxml.jackson.annotation.JsonFormat; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; @@ -23,6 +24,7 @@ public class PgsProgressPlanDetailNumVo { /** * 计划时间 */ + @JsonFormat(pattern = "yyyy-MM-dd") private Date date; /** diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/domain/vo/progressplandetail/PgsProgressPlanDetailFacilityVo.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/domain/vo/progressplandetail/PgsProgressPlanDetailUnFinishVo.java similarity index 59% rename from xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/domain/vo/progressplandetail/PgsProgressPlanDetailFacilityVo.java rename to xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/domain/vo/progressplandetail/PgsProgressPlanDetailUnFinishVo.java index 50c04a87..a5dc2e21 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/domain/vo/progressplandetail/PgsProgressPlanDetailFacilityVo.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/domain/vo/progressplandetail/PgsProgressPlanDetailUnFinishVo.java @@ -7,13 +7,13 @@ import java.io.Serializable; /** * @author lcj - * @date 2025/5/27 16:08 + * @date 2025/5/28 11:01 */ @Data -public class PgsProgressPlanDetailFacilityVo implements Serializable { +public class PgsProgressPlanDetailUnFinishVo implements Serializable { @Serial - private static final long serialVersionUID = -4292009770864819304L; + private static final long serialVersionUID = 2970680763220471140L; /** * 设施id @@ -26,8 +26,8 @@ public class PgsProgressPlanDetailFacilityVo implements Serializable { private String name; /** - * 设施完成类型 + * 设施状态 */ - private String finishType; + private String status; } diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/service/IPgsProgressCategoryService.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/service/IPgsProgressCategoryService.java index fe307c1b..d31efb94 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/service/IPgsProgressCategoryService.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/service/IPgsProgressCategoryService.java @@ -6,6 +6,7 @@ import org.dromara.progress.domain.PgsProgressCategory; 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.PgsProgressCategoryLastTimeVo; import org.dromara.progress.domain.vo.progresscategory.PgsProgressCategoryVo; import java.util.Collection; @@ -35,6 +36,14 @@ public interface IPgsProgressCategoryService extends IService queryList(PgsProgressCategoryQueryReq req); + /** + * 查询设施剩余数量 + * + * @param id 主键 + * @return 设施剩余数量 + */ + PgsProgressCategoryLastTimeVo queryLastTimeById(Long id); + /** * 新增进度类别 * diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/service/IPgsProgressPlanDetailService.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/service/IPgsProgressPlanDetailService.java index 2a47e19a..dabc05cc 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/service/IPgsProgressPlanDetailService.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/service/IPgsProgressPlanDetailService.java @@ -1,16 +1,15 @@ package org.dromara.progress.service; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; import org.dromara.common.mybatis.core.page.PageQuery; import org.dromara.common.mybatis.core.page.TableDataInfo; import org.dromara.progress.domain.PgsProgressPlanDetail; -import org.dromara.progress.domain.dto.progressplandetail.PgsProgressPlanDetailQueryReq; -import org.dromara.progress.domain.dto.progressplandetail.PgsProgressPlanDetailUpdateReq; -import org.dromara.progress.domain.vo.progressplandetail.PgsProgressPlanDetailFacilityVo; +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.vo.progressplandetail.PgsProgressPlanDetailFinishedVo; import org.dromara.progress.domain.vo.progressplandetail.PgsProgressPlanDetailNumVo; -import org.dromara.progress.domain.vo.progressplandetail.PgsProgressPlanDetailVo; +import org.dromara.progress.domain.vo.progressplandetail.PgsProgressPlanDetailUnFinishVo; import java.util.List; @@ -23,54 +22,38 @@ import java.util.List; public interface IPgsProgressPlanDetailService extends IService { /** - * 查询进度计划详情 + * 插入进度计划详情设施 * - * @param id 主键 - * @return 进度计划详情 + * @param req 插入进度计划详情设施参数 + * @return 是否插入成功 */ - PgsProgressPlanDetailVo queryById(Long id); + Boolean insertFinishedDetail(PgsProgressPlanDetailFinishedCreateReq req); /** - * 分页查询进度计划详情列表 + * 插入进度计划详情设施 * - * @param req 查询条件 - * @param pageQuery 分页参数 - * @return 进度计划详情分页列表 + * @param req 插入进度计划详情设施参数 + * @return 是否插入成功 */ - TableDataInfo queryPageList(PgsProgressPlanDetailQueryReq req, PageQuery pageQuery); + Boolean insertPercentageDetail(PgsProgressPlanDetailPercentageCreateReq req); /** - * 查询符合条件的进度计划详情列表 - * - * @param req 查询条件 - * @return 进度计划详情列表 - */ - List queryList(PgsProgressPlanDetailQueryReq req); - - /** - * 分页查询进度计划详情设施列表 + * 分页查询进度计划详情已完成设施列表 * * @param id 主键 * @param pageQuery 分页参数 * @return 进度计划详情设施分页列表 */ - TableDataInfo queryFacilityById(Long id, PageQuery pageQuery); + TableDataInfo queryFinishedById(Long id, PageQuery pageQuery); /** - * 修改进度计划详情 + * 分页查询进度计划详情未完成设施列表 * - * @param req 进度计划详情 - * @return 是否修改成功 + * @param id 主键 + * @param pageQuery 分页参数 + * @return 进度计划详情设施分页列表 */ - Boolean updateByBo(PgsProgressPlanDetailUpdateReq req); - - /** - * 获取进度计划详情视图对象 - * - * @param progressPlanDetail 进度计划详情对象 - * @return 进度计划详情视图对象 - */ - PgsProgressPlanDetailVo getVo(PgsProgressPlanDetail progressPlanDetail); + TableDataInfo queryUnFinishById(Long id, PageQuery pageQuery); /** * 获取进度计划详情视图对象列表 @@ -81,19 +64,11 @@ public interface IPgsProgressPlanDetailService extends IService getNumVoList(List progressPlanDetailList); /** - * 获取进度计划详情查询条件封装 + * 删除进度计划详情 * - * @param req 查询条件 - * @return 查询条件封装 + * @param req 删除进度计划详情参数 + * @return 是否删除成功 */ - LambdaQueryWrapper buildQueryWrapper(PgsProgressPlanDetailQueryReq req); - - /** - * 获取进度计划详情分页对象视图 - * - * @param progressPlanDetailPage 进度计划详情分页对象 - * @return 进度计划详情分页对象视图 - */ - Page getVoPage(Page progressPlanDetailPage); + Boolean removeDetail(PgsProgressPlanDetailRemoveReq req); } diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/service/IPgsProgressPlanService.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/service/IPgsProgressPlanService.java index 9b298412..c59ff503 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/service/IPgsProgressPlanService.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/service/IPgsProgressPlanService.java @@ -5,12 +5,12 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; import org.dromara.common.mybatis.core.page.PageQuery; import org.dromara.common.mybatis.core.page.TableDataInfo; +import org.dromara.progress.domain.PgsProgressCategory; import org.dromara.progress.domain.PgsProgressPlan; import org.dromara.progress.domain.dto.progressplan.PgsProgressPlanCreateReq; import org.dromara.progress.domain.dto.progressplan.PgsProgressPlanQueryReq; import org.dromara.progress.domain.vo.progressplan.PgsProgressPlanVo; -import java.util.Collection; import java.util.List; /** @@ -55,13 +55,12 @@ public interface IPgsProgressPlanService extends IService { Long insertByBo(PgsProgressPlanCreateReq req); /** - * 校验并批量删除进度计划信息 + * 删除进度计划信息 * - * @param ids 待删除的主键集合 - * @param isValid 是否进行有效性校验 + * @param id 待删除的主键 * @return 是否删除成功 */ - Boolean deleteWithValidByIds(Collection ids, Boolean isValid); + Boolean deleteById(Long id); /** * 获取进度计划视图对象 @@ -90,9 +89,9 @@ public interface IPgsProgressPlanService extends IService { /** * 校验计划数量是否合法 * - * @param planNumber 计划数量 - * @param progressCategoryId 进度类别id + * @param planNumber 计划数量 + * @param progressCategory 进度类别 */ - void validPlanNumber(Long planNumber, Long progressCategoryId); + void validPlanNumber(Long planNumber, PgsProgressCategory progressCategory); } diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/service/impl/PgsProgressCategoryServiceImpl.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/service/impl/PgsProgressCategoryServiceImpl.java index 3b2861e6..c2225810 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/service/impl/PgsProgressCategoryServiceImpl.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/service/impl/PgsProgressCategoryServiceImpl.java @@ -14,16 +14,21 @@ import org.dromara.facility.service.IFacPercentageFacilityService; import org.dromara.progress.constant.PgsProgressCategoryConstant; import org.dromara.progress.domain.PgsProgressCategory; import org.dromara.progress.domain.PgsProgressCategoryTemplate; +import org.dromara.progress.domain.PgsProgressPlan; 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.PgsFinishStatusEnum; import org.dromara.progress.domain.enums.PgsProgressUnitTypeEnum; +import org.dromara.progress.domain.vo.progresscategory.PgsProgressCategoryLastTimeVo; import org.dromara.progress.domain.vo.progresscategory.PgsProgressCategoryVo; import org.dromara.progress.mapper.PgsProgressCategoryMapper; import org.dromara.progress.service.IPgsProgressCategoryService; import org.dromara.progress.service.IPgsProgressCategoryTemplateService; +import org.dromara.progress.service.IPgsProgressPlanService; import org.dromara.utils.BigDecimalUtil; import org.springframework.beans.BeanUtils; +import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -47,6 +52,10 @@ public class PgsProgressCategoryServiceImpl extends ServiceImpl children = parentIdToChildrenMap.getOrDefault(progressCategory.getId(), Collections.emptyList()); + // 获取父节点状态 + String pidStatus = getPidStatus(children); // 累加子节点数据 BigDecimal total = children.stream().map(PgsProgressCategory::getTotal).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add); BigDecimal completed = children.stream().map(PgsProgressCategory::getCompleted).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add); @@ -236,6 +275,7 @@ public class PgsProgressCategoryServiceImpl extends ServiceImpl children) { + if (CollUtil.isEmpty(children)) { + return PgsFinishStatusEnum.UNFINISH.getValue(); // 为空视为未开始 + } + boolean allFinished = true; + boolean hasInProgress = false; + for (PgsProgressCategory category : children) { + String status = category.getStatus(); + if (!PgsFinishStatusEnum.FINISH.getValue().equals(status)) { + allFinished = false; + if (PgsFinishStatusEnum.INPROGRESS.getValue().equals(status)) { + hasInProgress = true; + } + } + } + if (allFinished) { + return PgsFinishStatusEnum.FINISH.getValue(); // 全部完成 + } else if (hasInProgress) { + return PgsFinishStatusEnum.INPROGRESS.getValue(); // 有进行中 + } else { + return PgsFinishStatusEnum.UNFINISH.getValue(); // 全部未开始 + } + } + } diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/service/impl/PgsProgressPlanDetailServiceImpl.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/service/impl/PgsProgressPlanDetailServiceImpl.java index 7d245327..6728f19c 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/service/impl/PgsProgressPlanDetailServiceImpl.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/service/impl/PgsProgressPlanDetailServiceImpl.java @@ -1,18 +1,24 @@ package org.dromara.progress.service.impl; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.json.JSONUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import com.baomidou.mybatisplus.core.toolkit.support.SFunction; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.IService; 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.ObjectUtils; import org.dromara.common.mybatis.core.page.PageQuery; import org.dromara.common.mybatis.core.page.TableDataInfo; import org.dromara.facility.domain.FacBoxTransformer; import org.dromara.facility.domain.FacInverter; import org.dromara.facility.domain.FacPhotovoltaicPanel; import org.dromara.facility.domain.enums.FacFinishStatusEnum; +import org.dromara.facility.domain.enums.FacFinishTypeEnum; import org.dromara.facility.service.IFacBoxTransformerService; import org.dromara.facility.service.IFacInverterService; import org.dromara.facility.service.IFacPhotovoltaicPanelService; @@ -20,21 +26,29 @@ import org.dromara.progress.constant.PgsProgressCategoryConstant; import org.dromara.progress.domain.PgsProgressCategory; import org.dromara.progress.domain.PgsProgressPlan; import org.dromara.progress.domain.PgsProgressPlanDetail; -import org.dromara.progress.domain.dto.progressplandetail.PgsProgressPlanDetailQueryReq; -import org.dromara.progress.domain.dto.progressplandetail.PgsProgressPlanDetailUpdateReq; -import org.dromara.progress.domain.vo.progressplandetail.PgsProgressPlanDetailFacilityVo; +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.vo.progressplandetail.PgsProgressPlanDetailFinishedVo; import org.dromara.progress.domain.vo.progressplandetail.PgsProgressPlanDetailNumVo; -import org.dromara.progress.domain.vo.progressplandetail.PgsProgressPlanDetailVo; +import org.dromara.progress.domain.vo.progressplandetail.PgsProgressPlanDetailUnFinishVo; 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; import org.springframework.stereotype.Service; +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.concurrent.atomic.AtomicInteger; /** * 进度计划详情Service业务层处理 @@ -62,44 +76,172 @@ public class PgsProgressPlanDetailServiceImpl extends ServiceImpl finishedDetailIdList = req.getFinishedDetailIdList(); + if (CollUtil.isEmpty(finishedDetailIdList)) { + return true; + } + Long id = req.getId(); PgsProgressPlanDetail progressPlanDetail = this.getById(id); if (progressPlanDetail == null) { throw new ServiceException("进度计划详情信息不存在", HttpStatus.NOT_FOUND); } - return this.getVo(progressPlanDetail); + 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 progressCategoryId = progressPlanDetail.getProgressCategoryId(); + PgsProgressCategory progressCategory = progressCategoryService.getById(progressCategoryId); + if (progressCategory == null) { + throw new ServiceException("进度计划类别信息不存在", HttpStatus.NOT_FOUND); + } + String workType = progressCategory.getWorkType(); + List finishedDetailList = JSONUtil.toList(progressPlanDetail.getFinishedDetail(), PgsProgressPlanDetailFinishedVo.class); + if (PgsProgressCategoryConstant.PHOTOVOLTAIC_PANEL_PROGRESS_CATEGORY_WORK_TYPE.contains(workType)) { + handleFacilityFinish( + projectId, + progressCategoryId, + finishedDetailIdList, + progressPlanDetail.getDate(), + photovoltaicPanelService, + FacPhotovoltaicPanel::getId, + FacPhotovoltaicPanel::getName, + FacPhotovoltaicPanel::getFinishType, + FacPhotovoltaicPanel::getFinishDate, + FacPhotovoltaicPanel::getProjectId, + FacPhotovoltaicPanel::getProgressCategoryId, + FacPhotovoltaicPanel::getId, + FacPhotovoltaicPanel::getStatus, + finishedDetailList + ); + } else if (PgsProgressCategoryConstant.INVERTER_PROGRESS_CATEGORY_WORK_TYPE.contains(workType)) { + handleFacilityFinish( + projectId, + progressCategoryId, + finishedDetailIdList, + progressPlanDetail.getDate(), + inverterService, + FacInverter::getId, + FacInverter::getName, + FacInverter::getFinishType, + FacInverter::getFinishDate, + FacInverter::getProjectId, + FacInverter::getProgressCategoryId, + FacInverter::getId, + FacInverter::getStatus, + finishedDetailList + ); + } else if (PgsProgressCategoryConstant.BOX_TRANSFORMER_PROGRESS_CATEGORY_WORK_TYPE.contains(workType)) { + handleFacilityFinish( + projectId, + progressCategoryId, + finishedDetailIdList, + progressPlanDetail.getDate(), + boxTransformerService, + FacBoxTransformer::getId, + FacBoxTransformer::getName, + FacBoxTransformer::getFinishType, + FacBoxTransformer::getFinishDate, + FacBoxTransformer::getProjectId, + FacBoxTransformer::getProgressCategoryId, + FacBoxTransformer::getId, + FacBoxTransformer::getStatus, + finishedDetailList + ); + } + PgsProgressPlanDetail detail = new PgsProgressPlanDetail(); + detail.setId(id); + detail.setFinishedDetail(JSONUtil.toJsonStr(finishedDetailList)); + detail.setFinishedNumber(progressPlanDetail.getFinishedNumber() + finishedDetailList.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()) + .update(); + if (!result) { + throw new ServiceException("更新进度计划异常", HttpStatus.ERROR); + } + boolean updateCategory = progressCategoryService.lambdaUpdate() + .eq(PgsProgressCategory::getId, progressCategoryId) + .setSql("completed = completed + " + finishedDetailList.size()) + .update(); + if (!updateCategory) { + throw new ServiceException("更新进度计划类别异常", HttpStatus.ERROR); + } + return true; } /** - * 分页查询进度计划详情列表 + * 插入进度计划详情设施 * - * @param req 查询条件 - * @param pageQuery 分页参数 - * @return 进度计划详情分页列表 + * @param req 插入进度计划详情设施参数 + * @return 是否插入成功 */ @Override - public TableDataInfo queryPageList(PgsProgressPlanDetailQueryReq req, PageQuery pageQuery) { - Page result = this.page(pageQuery.build(), this.buildQueryWrapper(req)); - return TableDataInfo.build(this.getVoPage(result)); - } - - /** - * 查询符合条件的进度计划详情列表 - * - * @param req 查询条件 - * @return 进度计划详情列表 - */ - @Override - public List queryList(PgsProgressPlanDetailQueryReq req) { - List list = this.list(this.buildQueryWrapper(req)); - return list.stream().map(this::getVo).toList(); + @Transactional(rollbackFor = Exception.class) + public Boolean insertPercentageDetail(PgsProgressPlanDetailPercentageCreateReq req) { + Long finishedNumber = req.getFinishedNumber(); + if (finishedNumber == null) { + throw new ServiceException("完成百分比不能为空", HttpStatus.BAD_REQUEST); + } + if (finishedNumber < 0) { + throw new ServiceException("完成百分比不能小于0", HttpStatus.BAD_REQUEST); + } + if (finishedNumber > 100) { + throw new ServiceException("完成百分比不能大于100", HttpStatus.BAD_REQUEST); + } + Long id = req.getId(); + PgsProgressPlanDetail progressPlanDetail = this.getById(id); + if (progressPlanDetail == null) { + throw new ServiceException("进度计划详情信息不存在", HttpStatus.NOT_FOUND); + } + Long progressPlanId = progressPlanDetail.getProgressPlanId(); + PgsProgressPlan progressPlan = progressPlanService.getById(progressPlanId); + if (progressPlan == null) { + throw new ServiceException("进度计划信息不存在", HttpStatus.NOT_FOUND); + } + Long number = progressPlanDetail.getFinishedNumber(); + Long finishedNumberTotal = progressPlan.getFinishedNumber(); + if (finishedNumberTotal + finishedNumber > progressPlan.getPlanNumber()) { + throw new ServiceException("完成百分比不能大于计划进度", HttpStatus.BAD_REQUEST); + } + progressPlanDetail.setFinishedNumber(finishedNumber); + // 更新 + boolean update = this.updateById(progressPlanDetail); + if (!update) { + throw new ServiceException("更新进度计划详情异常", HttpStatus.ERROR); + } + progressPlan.setFinishedNumber(finishedNumberTotal - progressPlan.getFinishedNumber() + 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(); + if (!updateCategory) { + throw new ServiceException("更新进度分类异常", HttpStatus.ERROR); + } + return true; } /** @@ -110,108 +252,86 @@ public class PgsProgressPlanDetailServiceImpl extends ServiceImpl queryFacilityById(Long id, PageQuery pageQuery) { + public TableDataInfo queryFinishedById(Long id, PageQuery pageQuery) { PgsProgressPlanDetail progressPlanDetail = this.getById(id); if (progressPlanDetail == null) { throw new ServiceException("进度计划详情信息不存在", HttpStatus.NOT_FOUND); } - PgsProgressPlan progressPlan = progressPlanService.getById(progressPlanDetail.getProgressPlanId()); - if (progressPlan == null) { - throw new ServiceException("进度计划信息不存在", HttpStatus.NOT_FOUND); + String finishedDetail = progressPlanDetail.getFinishedDetail(); + List list = JSONUtil.toList(finishedDetail, PgsProgressPlanDetailFinishedVo.class); + return TableDataInfo.build(this.paginateList(list, pageQuery)); + } + + /** + * 分页查询进度计划详情未完成设施列表 + * + * @param id 主键 + * @param pageQuery 分页参数 + * @return 进度计划详情设施分页列表 + */ + @Override + public TableDataInfo queryUnFinishById(Long id, PageQuery pageQuery) { + PgsProgressPlanDetail progressPlanDetail = this.getById(id); + if (progressPlanDetail == null) { + throw new ServiceException("进度计划详情信息不存在", HttpStatus.NOT_FOUND); } - Long progressCategoryId = progressPlan.getProgressCategoryId(); - Long projectId = progressPlan.getProjectId(); - Long matrixId = progressPlan.getMatrixId(); + Long progressCategoryId = progressPlanDetail.getProgressCategoryId(); PgsProgressCategory progressCategory = progressCategoryService.getById(progressCategoryId); if (progressCategory == null) { throw new ServiceException("进度计划类别信息不存在", HttpStatus.NOT_FOUND); } String workType = progressCategory.getWorkType(); - Page resultPage = pageQuery.build(); if (PgsProgressCategoryConstant.PHOTOVOLTAIC_PANEL_PROGRESS_CATEGORY_WORK_TYPE.contains(workType)) { LambdaQueryWrapper lqw = new LambdaQueryWrapper<>(); - lqw.eq(FacPhotovoltaicPanel::getProjectId, projectId); - lqw.eq(FacPhotovoltaicPanel::getMatrixId, matrixId); + lqw.select(FacPhotovoltaicPanel::getId, FacPhotovoltaicPanel::getName, FacPhotovoltaicPanel::getStatus); + lqw.eq(FacPhotovoltaicPanel::getProjectId, progressPlanDetail.getProjectId()); lqw.eq(FacPhotovoltaicPanel::getProgressCategoryId, progressCategoryId); - lqw.eq(FacPhotovoltaicPanel::getFinishDate, progressPlanDetail.getDate()); - lqw.eq(FacPhotovoltaicPanel::getFinishType, FacFinishStatusEnum.FINISH.getValue()); - Page result = photovoltaicPanelService.page(pageQuery.build(), lqw); - List records = result.getRecords(); - List facilityVoList = records.stream().map(photovoltaicPanel -> { - PgsProgressPlanDetailFacilityVo facilityVo = new PgsProgressPlanDetailFacilityVo(); - facilityVo.setId(photovoltaicPanel.getId()); - facilityVo.setName(photovoltaicPanel.getName()); - facilityVo.setFinishType(photovoltaicPanel.getFinishType()); - return facilityVo; - }).toList(); - resultPage.setRecords(facilityVoList); + lqw.in(FacPhotovoltaicPanel::getStatus, FacFinishStatusEnum.UNFINISH.getValue(), FacFinishStatusEnum.INPROGRESS.getValue()); + Page page = photovoltaicPanelService.page(pageQuery.build(), lqw); + Page voPage = PageConvertUtil.convert(page, entity -> { + PgsProgressPlanDetailUnFinishVo vo = new PgsProgressPlanDetailUnFinishVo(); + vo.setId(entity.getId()); + vo.setName(entity.getName()); + vo.setStatus(entity.getStatus()); + vo.setName(progressCategory.getName()); + return vo; + }); + return TableDataInfo.build(voPage); } else if (PgsProgressCategoryConstant.INVERTER_PROGRESS_CATEGORY_WORK_TYPE.contains(workType)) { LambdaQueryWrapper lqw = new LambdaQueryWrapper<>(); - lqw.eq(FacInverter::getProjectId, projectId); - lqw.eq(FacInverter::getMatrixId, matrixId); + lqw.select(FacInverter::getId, FacInverter::getName, FacInverter::getStatus); + lqw.eq(FacInverter::getProjectId, progressPlanDetail.getProjectId()); lqw.eq(FacInverter::getProgressCategoryId, progressCategoryId); - lqw.eq(FacInverter::getFinishDate, progressPlanDetail.getDate()); - lqw.eq(FacInverter::getFinishType, FacFinishStatusEnum.FINISH.getValue()); - Page result = inverterService.page(pageQuery.build(), lqw); - List records = result.getRecords(); - List facilityVoList = records.stream().map(inverter -> { - PgsProgressPlanDetailFacilityVo facilityVo = new PgsProgressPlanDetailFacilityVo(); - facilityVo.setId(inverter.getId()); - facilityVo.setName(inverter.getName()); - facilityVo.setFinishType(inverter.getFinishType()); - return facilityVo; - }).toList(); - resultPage.setRecords(facilityVoList); + lqw.in(FacInverter::getStatus, FacFinishStatusEnum.UNFINISH.getValue(), FacFinishStatusEnum.INPROGRESS.getValue()); + Page page = inverterService.page(pageQuery.build(), lqw); + Page voPage = PageConvertUtil.convert(page, entity -> { + PgsProgressPlanDetailUnFinishVo vo = new PgsProgressPlanDetailUnFinishVo(); + vo.setId(entity.getId()); + vo.setName(entity.getName()); + vo.setStatus(entity.getStatus()); + vo.setName(progressCategory.getName()); + return vo; + }); + return TableDataInfo.build(voPage); } else if (PgsProgressCategoryConstant.BOX_TRANSFORMER_PROGRESS_CATEGORY_WORK_TYPE.contains(workType)) { LambdaQueryWrapper lqw = new LambdaQueryWrapper<>(); - lqw.eq(FacBoxTransformer::getProjectId, projectId); - lqw.eq(FacBoxTransformer::getMatrixId, matrixId); + lqw.select(FacBoxTransformer::getId, FacBoxTransformer::getName, FacBoxTransformer::getStatus); + lqw.eq(FacBoxTransformer::getProjectId, progressPlanDetail.getProjectId()); lqw.eq(FacBoxTransformer::getProgressCategoryId, progressCategoryId); - lqw.eq(FacBoxTransformer::getFinishDate, progressPlanDetail.getDate()); - lqw.eq(FacBoxTransformer::getFinishType, FacFinishStatusEnum.FINISH.getValue()); - Page result = boxTransformerService.page(pageQuery.build(), lqw); - List records = result.getRecords(); - List facilityVoList = records.stream().map(boxTransformer -> { - PgsProgressPlanDetailFacilityVo facilityVo = new PgsProgressPlanDetailFacilityVo(); - facilityVo.setId(boxTransformer.getId()); - facilityVo.setName(boxTransformer.getName()); - facilityVo.setFinishType(boxTransformer.getFinishType()); - return facilityVo; - }).toList(); - resultPage.setRecords(facilityVoList); + lqw.in(FacBoxTransformer::getStatus, FacFinishStatusEnum.UNFINISH.getValue(), FacFinishStatusEnum.INPROGRESS.getValue()); + Page page = boxTransformerService.page(pageQuery.build(), lqw); + Page voPage = PageConvertUtil.convert(page, entity -> { + PgsProgressPlanDetailUnFinishVo vo = new PgsProgressPlanDetailUnFinishVo(); + vo.setId(entity.getId()); + vo.setName(entity.getName()); + vo.setStatus(entity.getStatus()); + vo.setName(progressCategory.getName()); + return vo; + }); + return TableDataInfo.build(voPage); } else { - throw new ServiceException("未知进度计划类别工作类型", HttpStatus.BAD_REQUEST); + throw new ServiceException("未定义的进度计划类别", HttpStatus.BAD_REQUEST); } - return TableDataInfo.build(resultPage); - } - - /** - * 修改进度计划详情 - * - * @param req 进度计划详情 - * @return 是否修改成功 - */ - @Override - public Boolean updateByBo(PgsProgressPlanDetailUpdateReq req) { - return null; - } - - /** - * 保存前的数据校验 - */ - private void validEntityBeforeSave(PgsProgressPlanDetail entity) { - //TODO 做一些数据校验,如唯一约束 - } - - /** - * 获取进度计划详情视图对象 - * - * @param progressPlanDetail 进度计划详情对象 - * @return 进度计划详情视图对象 - */ - @Override - public PgsProgressPlanDetailVo getVo(PgsProgressPlanDetail progressPlanDetail) { - return null; } /** @@ -230,34 +350,180 @@ public class PgsProgressPlanDetailServiceImpl extends ServiceImpl buildQueryWrapper(PgsProgressPlanDetailQueryReq req) { - LambdaQueryWrapper lqw = new LambdaQueryWrapper<>(); - if (req == null) { - return lqw; + @Transactional(rollbackFor = Exception.class) + public Boolean removeDetail(PgsProgressPlanDetailRemoveReq req) { + Long id = req.getId(); + List detailIdList = req.getDetailIdList(); + if (CollUtil.isEmpty(detailIdList)) { + return true; } - Long projectId = req.getProjectId(); - Long progressPlanId = req.getProgressPlanId(); - Date date = req.getDate(); - lqw.eq(ObjectUtils.isNotEmpty(projectId), PgsProgressPlanDetail::getProjectId, projectId); - lqw.eq(ObjectUtils.isNotEmpty(progressPlanId), PgsProgressPlanDetail::getProgressPlanId, progressPlanId); - lqw.eq(ObjectUtils.isNotEmpty(date), PgsProgressPlanDetail::getDate, date); - return lqw; + PgsProgressPlanDetail progressPlanDetail = this.getById(id); + if (progressPlanDetail == null) { + throw new ServiceException("进度计划详情数据不存在", HttpStatus.NOT_FOUND); + } + String finishedDetail = progressPlanDetail.getFinishedDetail(); + int removeTotal = detailIdList.size(); + List 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 list = photovoltaicPanelService.lambdaQuery() + .in(FacPhotovoltaicPanel::getId, detailIdList) + .list(); + if (CollUtil.isEmpty(list) || list.size() != removeTotal) { + throw new ServiceException("设施数据丢失", HttpStatus.NOT_FOUND); + } + LambdaUpdateWrapper 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); + } + } else if (PgsProgressCategoryConstant.INVERTER_PROGRESS_CATEGORY_WORK_TYPE.contains(workType)) { + List list = inverterService.lambdaQuery() + .in(FacInverter::getId, detailIdList) + .list(); + if (CollUtil.isEmpty(list) || list.size() != removeTotal) { + throw new ServiceException("设施数据丢失", HttpStatus.NOT_FOUND); + } + LambdaUpdateWrapper 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.BOX_TRANSFORMER_PROGRESS_CATEGORY_WORK_TYPE.contains(workType)) { + List list = boxTransformerService.lambdaQuery() + .in(FacBoxTransformer::getId, detailIdList) + .list(); + if (CollUtil.isEmpty(list) || list.size() != removeTotal) { + throw new ServiceException("设施数据丢失", HttpStatus.NOT_FOUND); + } + LambdaUpdateWrapper 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); + } + } else { + throw new ServiceException("未定义的进度计划类别", HttpStatus.BAD_REQUEST); + } + AtomicInteger finishType2Count = new AtomicInteger(0); + // 过滤出不需要删除的,生成新列表 + List newList = finishedVoList.stream() + .filter(vo -> { + boolean toRemove = detailIdList.contains(vo.getId()); + if (toRemove && FacFinishTypeEnum.AI.getValue().equals(vo.getFinishType())) { + finishType2Count.incrementAndGet(); + } + return !toRemove; + }) + .toList(); + progressPlanDetail.setFinishedDetail(JSONUtil.toJsonStr(newList)); + progressPlanDetail.setFinishedNumber((long) newList.size()); + long aiFill = progressPlanDetail.getAiFill() - (long) finishType2Count.get(); + progressPlanDetail.setAiFill(Math.max(aiFill, 0L)); + boolean updatePlanDetail = this.updateById(progressPlanDetail); + if (!updatePlanDetail) { + throw new ServiceException("修改进度计划详情失败,数据库异常", HttpStatus.ERROR); + } + boolean updatePlan = progressPlanService.lambdaUpdate() + .eq(PgsProgressPlan::getId, progressPlanDetail.getProgressPlanId()) + .setSql("finished_number = finished_number - " + removeTotal) + .update(); + if (!updatePlan) { + throw new ServiceException("修改进度计划失败,数据库异常", HttpStatus.ERROR); + } + progressCategory.setCompleted(progressCategory.getCompleted().subtract(BigDecimal.valueOf(removeTotal))); + boolean updateCategory = progressCategoryService.updateById(progressCategory); + if (!updateCategory) { + throw new ServiceException("修改进度类别失败,数据库异常", HttpStatus.ERROR); + } + return true; } /** - * 获取进度计划详情分页对象视图 + * 分页 * - * @param progressPlanDetailPage 进度计划详情分页对象 - * @return 进度计划详情分页对象视图 + * @param fullList 列表 + * @param pageQuery 分页参数 + * @return 分页列表 */ - @Override - public Page getVoPage(Page progressPlanDetailPage) { - return null; + public Page paginateList(List fullList, PageQuery pageQuery) { + int pageNum = ObjectUtil.defaultIfNull(pageQuery.getPageNum(), PageQuery.DEFAULT_PAGE_NUM); + int pageSize = ObjectUtil.defaultIfNull(pageQuery.getPageSize(), PageQuery.DEFAULT_PAGE_SIZE); + // 保底 + if (pageNum < 1) pageNum = 1; + if (pageSize < 1) pageSize = PageQuery.DEFAULT_PAGE_SIZE; + int fromIndex = (pageNum - 1) * pageSize; + int toIndex = Math.min(fromIndex + pageSize, fullList.size()); + // 防止越界 + if (fromIndex > fullList.size()) { + return new Page(pageNum, pageSize, fullList.size()).setRecords(Collections.emptyList()); + } + List pageList = fullList.subList(fromIndex, toIndex); + return new Page(pageNum, pageSize, fullList.size()).setRecords(pageList); } + + public void handleFacilityFinish( + Long projectId, + Long progressCategoryId, + List finishedDetailIdList, + Date finishDate, + IService service, + SFunction getIdFunc, + SFunction getNameFunc, + SFunction getFinishTypeFunc, + SFunction getFinishDateFunc, + SFunction getProjectIdFunc, + SFunction getProgressCategoryIdFunc, + SFunction getIdColumnFunc, + SFunction getStatusFunc, + List finishedDetailList + ) { + List entityList = service.lambdaQuery() + .eq(getProjectIdFunc, projectId) + .eq(getProgressCategoryIdFunc, progressCategoryId) + .in(getIdColumnFunc, finishedDetailIdList) + .list(); + if (entityList.size() != finishedDetailIdList.size()) { + throw new ServiceException("上传设施信息异常", HttpStatus.BAD_REQUEST); + } + boolean update = service.lambdaUpdate() + .eq(getProjectIdFunc, projectId) + .eq(getProgressCategoryIdFunc, progressCategoryId) + .in(getIdColumnFunc, finishedDetailIdList) + .set(getStatusFunc, FacFinishStatusEnum.FINISH.getValue()) + .set(getFinishTypeFunc, FacFinishTypeEnum.HAND.getValue()) + .set(getFinishDateFunc, finishDate) + .update(); + if (!update) { + throw new ServiceException("更新设施信息异常", HttpStatus.ERROR); + } + List list = entityList.stream().map(entity -> { + PgsProgressPlanDetailFinishedVo vo = new PgsProgressPlanDetailFinishedVo(); + vo.setId(getIdFunc.apply(entity)); + vo.setName(getNameFunc.apply(entity)); + vo.setFinishType(getFinishTypeFunc.apply(entity)); + return vo; + }).toList(); + finishedDetailList.addAll(list); + } + + } diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/service/impl/PgsProgressPlanServiceImpl.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/service/impl/PgsProgressPlanServiceImpl.java index 3a8ad396..18ec093b 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/service/impl/PgsProgressPlanServiceImpl.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/service/impl/PgsProgressPlanServiceImpl.java @@ -19,6 +19,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.PgsFinishStatusEnum; import org.dromara.progress.domain.vo.progressplan.PgsProgressPlanVo; import org.dromara.progress.domain.vo.progressplandetail.PgsProgressPlanDetailNumVo; import org.dromara.progress.mapper.PgsProgressPlanMapper; @@ -31,7 +32,10 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.math.BigDecimal; -import java.util.*; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Map; import java.util.stream.Collectors; /** @@ -109,6 +113,12 @@ public class PgsProgressPlanServiceImpl extends ServiceImpl ids, Boolean isValid) { + public Boolean deleteById(Long id) { Long userId = LoginHelper.getUserId(); - List progressPlanList = this.listByIds(ids); - if (isValid) { - //TODO 做一些业务上的校验,判断是否需要校验 - List projectId = progressPlanList.stream().map(PgsProgressPlan::getProjectId).toList(); - projectService.validAuth(projectId, userId); + PgsProgressPlan progressPlan = this.getById(id); + if (progressPlan == null) { + throw new ServiceException("进度计划信息不存在", HttpStatus.NOT_FOUND); } - return this.removeBatchByIds(ids); + Long projectId = progressPlan.getProjectId(); + projectService.validAuth(projectId, userId); + if (progressPlan.getPlanNumber() != null && progressPlan.getPlanNumber() != 0) { + throw new ServiceException("已存在完成的设施,无法删除", HttpStatus.CONFLICT); + } + // 删除数据 + boolean result = this.removeById(id); + if (!result) { + throw new ServiceException("删除进度计划失败,数据库异常", HttpStatus.ERROR); + } + // 关联删除分类中记录的计划值 + boolean update = progressCategoryService.lambdaUpdate() + .eq(PgsProgressCategory::getId, progressPlan.getProgressCategoryId()) + .setSql("plan_total = plan_total - " + progressPlan.getPlanNumber()) + .update(); + if (!update) { + throw new ServiceException("更新进度分类计划总数量失败,数据库操作失败", HttpStatus.ERROR); + } + // 关联删除计划详情数据 + LambdaQueryWrapper lqw = new LambdaQueryWrapper<>(); + lqw.eq(PgsProgressPlanDetail::getProgressPlanId, id); + boolean remove = progressPlanDetailService.remove(lqw); + if (!remove) { + throw new ServiceException("删除进度计划详情失败,数据库异常", HttpStatus.ERROR); + } + return true; } /** @@ -268,10 +289,15 @@ public class PgsProgressPlanServiceImpl extends ServiceImpl numDetailList = new ArrayList<>(); + long aiFill = 0L; if (detailMap.containsKey(id)) { numDetailList = progressPlanDetailService.getNumVoList(detailMap.get(id)); + for (PgsProgressPlanDetailNumVo vo : numDetailList) { + aiFill += vo.getAiFill() != null ? vo.getAiFill() : 0L; + } } progressPlanVo.setDetailList(numDetailList); + progressPlanVo.setAiFill(aiFill); return progressPlanVo; }).toList(); progressPlanVoPage.setRecords(progressPlanVoList); @@ -281,12 +307,11 @@ public class PgsProgressPlanServiceImpl extends ServiceImpl { try { // 构造命令行参数 - Dxf2JsonUtils.dxf2json(exePath, inputDXFPath, outputJSONPath, sourceEPSG, targetEPSG); + Dxf2JsonUtil.dxf2json(exePath, inputDXFPath, outputJSONPath, sourceEPSG, targetEPSG); String jsonFilePath = bashPath + File.separator + uuid + "." + DesignMapFileConstant.JSONFileSuffix; String jsonFileName = FileUtil.getPrefix(fileName) + "." + DesignMapFileConstant.JSONFileSuffix; // 修改数据库信息 diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/quality/service/impl/QltQualityConstructionLogServiceImpl.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/quality/service/impl/QltQualityConstructionLogServiceImpl.java index 7abeac97..c5a80252 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/quality/service/impl/QltQualityConstructionLogServiceImpl.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/quality/service/impl/QltQualityConstructionLogServiceImpl.java @@ -35,7 +35,7 @@ import org.dromara.system.domain.vo.SysOssVo; import org.dromara.system.domain.vo.SysUserVo; import org.dromara.system.service.ISysOssService; import org.dromara.system.service.ISysUserService; -import org.dromara.utils.DocumentUtils; +import org.dromara.utils.DocumentUtil; import org.springframework.beans.BeanUtils; import org.springframework.http.MediaType; import org.springframework.stereotype.Service; @@ -378,7 +378,7 @@ public class QltQualityConstructionLogServiceImpl extends ServiceImpl 转换为 Page + * + * @param source 原始分页数据 + * @param mapper 实体 -> VO 的转换函数 + * @return Page + */ + public static Page convert(Page source, Function mapper) { + Page target = new Page<>(source.getCurrent(), source.getSize(), source.getTotal()); + if (CollUtil.isEmpty(source.getRecords())) { + target.setRecords(Collections.emptyList()); + } else { + List voList = source.getRecords().stream().map(mapper).toList(); + target.setRecords(voList); + } + return target; + } + +} diff --git a/xinnengyuan/script/sql/xinnengyuan.sql b/xinnengyuan/script/sql/xinnengyuan.sql index 0d54aa46..7084c03a 100644 --- a/xinnengyuan/script/sql/xinnengyuan.sql +++ b/xinnengyuan/script/sql/xinnengyuan.sql @@ -1045,20 +1045,23 @@ CREATE TABLE `pgs_progress_plan` DROP TABLE IF EXISTS `pgs_progress_plan_detail`; CREATE TABLE `pgs_progress_plan_detail` ( - `id` bigint not null auto_increment comment '主键id', - `project_id` bigint not null comment '项目id', - `progress_plan_id` bigint not null comment '进度计划id', - `date` date null comment '计划时间', - `plan_number` decimal(10) null comment '计划数量/百分比', - `finished_number` decimal(10) null comment '完成数量/百分比', - `ai_fill` decimal(10) null comment 'AI填入数量', - `create_by` varchar(64) null comment '创建者', - `update_by` varchar(64) null comment '更新者', - `create_time` datetime default CURRENT_TIMESTAMP null comment '创建时间', - `update_time` datetime default CURRENT_TIMESTAMP null on update CURRENT_TIMESTAMP comment '更新时间', - `deleted_at` datetime null comment '删除时间', - `is_delete` tinyint(4) default 0 not null comment '是否删除(0正常 1删除)', + `id` bigint not null auto_increment comment '主键id', + `project_id` bigint not null comment '项目id', + `progress_plan_id` bigint not null comment '进度计划id', + `progress_category_id` bigint null comment '进度类型id', + `date` date null comment '计划时间', + `plan_number` decimal(10) null comment '计划数量/百分比', + `finished_number` decimal(10) null comment '完成数量/百分比', + `ai_fill` decimal(10) null comment 'AI填入数量', + `finished_detail` text null comment '完成设施详情', + `create_by` varchar(64) null comment '创建者', + `update_by` varchar(64) null comment '更新者', + `create_time` datetime default CURRENT_TIMESTAMP null comment '创建时间', + `update_time` datetime default CURRENT_TIMESTAMP null on update CURRENT_TIMESTAMP comment '更新时间', + `deleted_at` datetime null comment '删除时间', + `is_delete` tinyint(4) default 0 not null comment '是否删除(0正常 1删除)', PRIMARY KEY (`id`) USING BTREE, INDEX `idx_project_id` (`project_id` ASC) USING BTREE comment '项目id', - INDEX `idx_progress_plan_id` (`progress_plan_id` ASC) USING BTREE comment '进度计划id' + INDEX `idx_progress_plan_id` (`progress_plan_id` ASC) USING BTREE comment '进度计划id', + INDEX `idx_date` (`date` ASC) USING BTREE comment '计划时间' ) comment ='进度计划详情' COLLATE = utf8mb4_unicode_ci;