Browse Source

根据服务目录自动创建 工作内容

ops-management-platform-backend-dev
gjh 3 weeks ago
parent
commit
0ccccdae82
  1. 15
      ruoyi-modules/guoyan-platform/src/main/java/org/dromara/platform/controller/RoutineInspectionInfoController.java
  2. 12
      ruoyi-modules/guoyan-platform/src/main/java/org/dromara/platform/domain/dto/RoutineWorkDto.java
  3. 8
      ruoyi-modules/guoyan-platform/src/main/java/org/dromara/platform/service/IInspectionPlanInfoService.java
  4. 69
      ruoyi-modules/guoyan-platform/src/main/java/org/dromara/platform/service/impl/InspectionPlanInfoServiceImpl.java
  5. 8
      ruoyi-modules/guoyan-platform/src/main/java/org/dromara/platform/service/impl/RoutineInspectionInfoServiceImpl.java

15
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<RoutineInspectionInfoVo> specialList(RoutineInspectionInfoBo bo, PageQuery pageQuery) {
return routineInspectionInfoService.queryPageSpecialList(bo, pageQuery);
}
@SaCheckPermission("platform:routineInspectionInfo:specialList")
@PostMapping("/autoCreatePlans")
public R<Void> autoCreatePlans(@RequestBody RoutineWorkDto routineWorkDto) {
String contractId = routineWorkDto.getContractId();
String categoryId = routineWorkDto.getCategoryId();
List<String> serviceProjectList = routineWorkDto.getServiceProjectList();
inspectionPlanInfoService.autoCreatePlans( contractId, categoryId, serviceProjectList);
return R.ok("根据服务目录创建工作内容 !");
}
}

12
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<String> serviceProjectList;
}

8
ruoyi-modules/guoyan-platform/src/main/java/org/dromara/platform/service/IInspectionPlanInfoService.java

@ -69,6 +69,11 @@ public interface IInspectionPlanInfoService {
*/
Boolean deleteWithValidByIds(Collection<String> ids, Boolean isValid);
/**
* 配置服务目录 根据所选目录创建 后续手动创建工作内容(例行工作+专项工作)
* @param contractId
* @param categoryId
*/
void createPlans(String contractId, String categoryId);
/**
@ -84,4 +89,7 @@ public interface IInspectionPlanInfoService {
* @return
*/
List<AgreementInfo> findLeafNodeInfos(String categoryId);
void autoCreatePlans(String contractId, String categoryId, List<String> serviceProjectList);
}

69
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<String> 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<RoutineInspectionInfo> addList = new ArrayList<>();
// 2.根据合同日期计算天数
long daysBetween = DateUtil.betweenDay(startDate, endDate, false);
List<AgreementInfoVo> agreementInfoVos = agreementInfoMapper.selectVoByIds(serviceProjectList);
List<AgreementInfoVo> routineList = agreementInfoVos.stream()
.filter(item -> "例行操作".equals(item.getDeliverContent()))
.collect(Collectors.toList());
List<AgreementInfoVo> 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("开始新增专项工作!");
}
}
}

8
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<RoutineInspectionInfoVo> queryPageList(RoutineInspectionInfoBo bo, PageQuery pageQuery) {
LambdaQueryWrapper<RoutineInspectionInfo> lqw = buildQueryWrapper(bo);
Page<RoutineInspectionInfoVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
List<RoutineInspectionInfoVo> records = result.getRecords();
//过滤 records中的每一个元素 交付内容不是 "例行操作"的元素 用Stream流
List<RoutineInspectionInfoVo> 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<RoutineInspectionInfo> lqw = buildQueryWrapper(bo);
Page<RoutineInspectionInfoVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
List<RoutineInspectionInfoVo> records = result.getRecords();
//过滤 records中的每一个元素 交付内容不是 "立项操作"的元素 用Stream流
//过滤 records中的每一个元素 交付内容不是 "例行操作"的元素 用Stream流
List<RoutineInspectionInfoVo> filteredRecords = records.stream()
.filter(record -> !"例行操作".equals(record.getDeliverContent()))
.collect(Collectors.toList());

Loading…
Cancel
Save