From 0ccccdae82743b1cc5974bbeb42e5d3b32a6e23a Mon Sep 17 00:00:00 2001 From: gjh <1421wake> Date: Wed, 16 Apr 2025 15:22:01 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=B9=E6=8D=AE=E6=9C=8D=E5=8A=A1=E7=9B=AE?= =?UTF-8?q?=E5=BD=95=E8=87=AA=E5=8A=A8=E5=88=9B=E5=BB=BA=20=E5=B7=A5?= =?UTF-8?q?=E4=BD=9C=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../RoutineInspectionInfoController.java | 15 ++++ .../platform/domain/dto/RoutineWorkDto.java | 12 ++++ .../service/IInspectionPlanInfoService.java | 8 +++ .../impl/InspectionPlanInfoServiceImpl.java | 69 +++++++++++++++++++ .../RoutineInspectionInfoServiceImpl.java | 8 ++- 5 files changed, 111 insertions(+), 1 deletion(-) create mode 100644 ruoyi-modules/guoyan-platform/src/main/java/org/dromara/platform/domain/dto/RoutineWorkDto.java diff --git a/ruoyi-modules/guoyan-platform/src/main/java/org/dromara/platform/controller/RoutineInspectionInfoController.java b/ruoyi-modules/guoyan-platform/src/main/java/org/dromara/platform/controller/RoutineInspectionInfoController.java index dcc1578..69660d7 100644 --- a/ruoyi-modules/guoyan-platform/src/main/java/org/dromara/platform/controller/RoutineInspectionInfoController.java +++ b/ruoyi-modules/guoyan-platform/src/main/java/org/dromara/platform/controller/RoutineInspectionInfoController.java @@ -2,6 +2,7 @@ package org.dromara.platform.controller; import java.util.List; +import jakarta.annotation.Resource; import lombok.RequiredArgsConstructor; import jakarta.servlet.http.HttpServletResponse; import jakarta.validation.constraints.*; @@ -10,6 +11,8 @@ import org.apache.ibatis.annotations.Param; import org.dromara.platform.domain.InspectionPlanInfo; import org.dromara.platform.domain.RoutineInspectionInfo; import org.dromara.platform.domain.dto.RoutineInspectionDto; +import org.dromara.platform.domain.dto.RoutineWorkDto; +import org.dromara.platform.service.IInspectionPlanInfoService; import org.springframework.web.bind.annotation.*; import org.springframework.validation.annotation.Validated; import org.dromara.common.idempotent.annotation.RepeatSubmit; @@ -39,6 +42,8 @@ import org.dromara.common.mybatis.core.page.TableDataInfo; public class RoutineInspectionInfoController extends BaseController { private final IRoutineInspectionInfoService routineInspectionInfoService; + @Resource + private IInspectionPlanInfoService inspectionPlanInfoService; /** * 查询日常巡检-计划列表 @@ -137,5 +142,15 @@ public class RoutineInspectionInfoController extends BaseController { public TableDataInfo specialList(RoutineInspectionInfoBo bo, PageQuery pageQuery) { return routineInspectionInfoService.queryPageSpecialList(bo, pageQuery); } + + @SaCheckPermission("platform:routineInspectionInfo:specialList") + @PostMapping("/autoCreatePlans") + public R autoCreatePlans(@RequestBody RoutineWorkDto routineWorkDto) { + String contractId = routineWorkDto.getContractId(); + String categoryId = routineWorkDto.getCategoryId(); + List serviceProjectList = routineWorkDto.getServiceProjectList(); + inspectionPlanInfoService.autoCreatePlans( contractId, categoryId, serviceProjectList); + return R.ok("根据服务目录创建工作内容 !"); + } } diff --git a/ruoyi-modules/guoyan-platform/src/main/java/org/dromara/platform/domain/dto/RoutineWorkDto.java b/ruoyi-modules/guoyan-platform/src/main/java/org/dromara/platform/domain/dto/RoutineWorkDto.java new file mode 100644 index 0000000..f909e59 --- /dev/null +++ b/ruoyi-modules/guoyan-platform/src/main/java/org/dromara/platform/domain/dto/RoutineWorkDto.java @@ -0,0 +1,12 @@ +package org.dromara.platform.domain.dto; + +import lombok.Data; + +import java.util.List; + +@Data +public class RoutineWorkDto { + private String contractId; + private String categoryId; + private List serviceProjectList; +} diff --git a/ruoyi-modules/guoyan-platform/src/main/java/org/dromara/platform/service/IInspectionPlanInfoService.java b/ruoyi-modules/guoyan-platform/src/main/java/org/dromara/platform/service/IInspectionPlanInfoService.java index 91f5a6a..1bc549f 100644 --- a/ruoyi-modules/guoyan-platform/src/main/java/org/dromara/platform/service/IInspectionPlanInfoService.java +++ b/ruoyi-modules/guoyan-platform/src/main/java/org/dromara/platform/service/IInspectionPlanInfoService.java @@ -69,6 +69,11 @@ public interface IInspectionPlanInfoService { */ Boolean deleteWithValidByIds(Collection ids, Boolean isValid); + /** + * 配置服务目录 根据所选目录创建 后续手动创建工作内容(例行工作+专项工作) + * @param contractId + * @param categoryId + */ void createPlans(String contractId, String categoryId); /** @@ -84,4 +89,7 @@ public interface IInspectionPlanInfoService { * @return */ List findLeafNodeInfos(String categoryId); + + + void autoCreatePlans(String contractId, String categoryId, List serviceProjectList); } diff --git a/ruoyi-modules/guoyan-platform/src/main/java/org/dromara/platform/service/impl/InspectionPlanInfoServiceImpl.java b/ruoyi-modules/guoyan-platform/src/main/java/org/dromara/platform/service/impl/InspectionPlanInfoServiceImpl.java index bb0e126..530b7a4 100644 --- a/ruoyi-modules/guoyan-platform/src/main/java/org/dromara/platform/service/impl/InspectionPlanInfoServiceImpl.java +++ b/ruoyi-modules/guoyan-platform/src/main/java/org/dromara/platform/service/impl/InspectionPlanInfoServiceImpl.java @@ -1,6 +1,7 @@ package org.dromara.platform.service.impl; import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.date.DateUtil; import jakarta.annotation.Resource; import lombok.extern.slf4j.Slf4j; import org.dromara.common.core.utils.MapstructUtils; @@ -13,12 +14,15 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; import lombok.RequiredArgsConstructor; import org.dromara.platform.domain.AgreementInfo; import org.dromara.platform.domain.ContractInfo; +import org.dromara.platform.domain.RoutineInspectionInfo; +import org.dromara.platform.domain.bo.RoutineInspectionInfoBo; import org.dromara.platform.domain.dto.AgreementInfoDto; import org.dromara.platform.domain.vo.AgreementInfoVo; import org.dromara.platform.domain.vo.ContractInfoVo; import org.dromara.platform.domain.vo.ioCompanySelectVo; import org.dromara.platform.mapper.AgreementInfoMapper; import org.dromara.platform.mapper.ContractInfoMapper; +import org.dromara.platform.mapper.RoutineInspectionInfoMapper; import org.dromara.platform.service.IAgreementInfoService; import org.dromara.platform.service.IContractInfoService; import org.dromara.platform.service.IServiceCatalogCategoryService; @@ -59,6 +63,9 @@ public class InspectionPlanInfoServiceImpl implements IInspectionPlanInfoService @Resource private AgreementInfoMapper agreementInfoMapper; + + @Resource + private RoutineInspectionInfoMapper routineInspectionInfoMapper; /** * 查询巡检计划 * @@ -245,4 +252,66 @@ public class InspectionPlanInfoServiceImpl implements IInspectionPlanInfoService } return agreementInfos; } + + @Override + public void autoCreatePlans(String contractId, String categoryId, List serviceProjectList) { + ContractInfoVo contractInfoVo = contractInfoService.queryById(contractId); + // 1.从合同信息中到获取到通用数据 + String contractName = contractInfoVo.getContractName(); + String projectName = contractInfoVo.getProjectName(); + Date startDate = contractInfoVo.getStartDate(); + Date endDate = contractInfoVo.getEndDate(); + String partyB = contractInfoVo.getPartyB(); + List addList = new ArrayList<>(); + // 2.根据合同日期计算天数 + long daysBetween = DateUtil.betweenDay(startDate, endDate, false); + + List agreementInfoVos = agreementInfoMapper.selectVoByIds(serviceProjectList); + List routineList = agreementInfoVos.stream() + .filter(item -> "例行操作".equals(item.getDeliverContent())) + .collect(Collectors.toList()); + + List specialList = agreementInfoVos.stream() + .filter(item -> !"例行操作".equals(item.getDeliverContent())) + .collect(Collectors.toList()); + + // 交付内容属于例行操作的则自动创建任务到 例行工作列表 + for (AgreementInfoVo agreementInfoVo : routineList) { + // 还有一层循环去处理要生成多少条例行工作 + for (long i = 0; i < daysBetween; i++) { + RoutineInspectionInfo routineInspectionInfo = new RoutineInspectionInfo(); + routineInspectionInfo.setProjectName(projectName); + routineInspectionInfo.setContractName(contractName); + routineInspectionInfo.setServiceProject(agreementInfoVo.getServiceProject()); + routineInspectionInfo.setDescription(agreementInfoVo.getServiceContent()); + routineInspectionInfo.setDeliverContent(agreementInfoVo.getDeliverContent()); + routineInspectionInfo.setCode(agreementInfoVo.getCode()); + routineInspectionInfo.setScheduleStartDate(DateUtil.offsetDay(startDate, (int) i)); + routineInspectionInfo.setScheduleEndDate(DateUtil.offsetDay(startDate, (int) i)); + routineInspectionInfo.setIoCompany(partyB); + routineInspectionInfo.setStatus(1L); + addList.add(routineInspectionInfo); + } + } + routineInspectionInfoMapper.insert(addList); + log.info("自动创建例行工作成功"); + + // 交付内容属于专项的则自动创建任务到 全部工作列表,再让用户手动创建计划 + for (AgreementInfoVo agreementInfo : specialList) { + InspectionPlanInfo inspectionPlanInfo = new InspectionPlanInfo(); + inspectionPlanInfo.setProjectName(projectName); + inspectionPlanInfo.setContractName(contractName); + inspectionPlanInfo.setStartDate(startDate); + inspectionPlanInfo.setEndDate(endDate); + inspectionPlanInfo.setDescription(agreementInfo.getServiceContent()); + inspectionPlanInfo.setFrequency(agreementInfo.getFrequency()); + inspectionPlanInfo.setServiceProject(agreementInfo.getServiceProject()); + inspectionPlanInfo.setIoCompany(partyB); + inspectionPlanInfo.setDeliverContent(agreementInfo.getDeliverContent()); + inspectionPlanInfo.setStatus(0L); + baseMapper.insert(inspectionPlanInfo); + log.info("开始新增专项工作!"); + } + + } } diff --git a/ruoyi-modules/guoyan-platform/src/main/java/org/dromara/platform/service/impl/RoutineInspectionInfoServiceImpl.java b/ruoyi-modules/guoyan-platform/src/main/java/org/dromara/platform/service/impl/RoutineInspectionInfoServiceImpl.java index d1ed8e1..a9d48a1 100644 --- a/ruoyi-modules/guoyan-platform/src/main/java/org/dromara/platform/service/impl/RoutineInspectionInfoServiceImpl.java +++ b/ruoyi-modules/guoyan-platform/src/main/java/org/dromara/platform/service/impl/RoutineInspectionInfoServiceImpl.java @@ -58,6 +58,12 @@ public class RoutineInspectionInfoServiceImpl implements IRoutineInspectionInfoS public TableDataInfo queryPageList(RoutineInspectionInfoBo bo, PageQuery pageQuery) { LambdaQueryWrapper lqw = buildQueryWrapper(bo); Page result = baseMapper.selectVoPage(pageQuery.build(), lqw); + List records = result.getRecords(); + //过滤 records中的每一个元素 交付内容不是 "例行操作"的元素 用Stream流 + List filteredRecords = records.stream() + .filter(record -> "例行操作".equals(record.getDeliverContent())) + .collect(Collectors.toList()); + result.setRecords(filteredRecords); return TableDataInfo.build(result); } @@ -171,7 +177,7 @@ public class RoutineInspectionInfoServiceImpl implements IRoutineInspectionInfoS LambdaQueryWrapper lqw = buildQueryWrapper(bo); Page result = baseMapper.selectVoPage(pageQuery.build(), lqw); List records = result.getRecords(); - //过滤 records中的每一个元素 交付内容不是 "立项操作"的元素 用Stream流 + //过滤 records中的每一个元素 交付内容不是 "例行操作"的元素 用Stream流 List filteredRecords = records.stream() .filter(record -> !"例行操作".equals(record.getDeliverContent())) .collect(Collectors.toList());