|
|
@ -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("开始新增专项工作!"); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|