|
@@ -0,0 +1,287 @@
|
|
|
+package com.bizmatics.service.impl;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.bizmatics.common.core.bean.CommonPage;
|
|
|
+import com.bizmatics.common.mvc.base.AbstractCrudService;
|
|
|
+import com.bizmatics.model.*;
|
|
|
+import com.bizmatics.model.system.SysUser;
|
|
|
+import com.bizmatics.model.vo.*;
|
|
|
+import com.bizmatics.persistence.mapper.PatrolInspectionSchemeMapper;
|
|
|
+import com.bizmatics.service.*;
|
|
|
+import com.bizmatics.service.util.SecurityUtils;
|
|
|
+import com.bizmatics.service.vo.CommonIcoVO;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * <p>
|
|
|
+ * 巡检管理-巡检计划
|
|
|
+ * </p>
|
|
|
+ *
|
|
|
+ * @author ya
|
|
|
+ * @since 2021-10-18
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class PatrolInspectionSchemeServiceImpl extends AbstractCrudService<PatrolInspectionSchemeMapper, PatrolInspectionScheme> implements PatrolInspectionSchemeService {
|
|
|
+ @Autowired
|
|
|
+ private PatrolInspectionRouteService patrolInspectionRouteService;
|
|
|
+ @Autowired
|
|
|
+ private PatrolRouteContentService patrolRouteContentService;
|
|
|
+ @Autowired
|
|
|
+ private PatrolInspectionTeamService patrolInspectionTeamService;
|
|
|
+ @Autowired
|
|
|
+ private PatrolTeamInspectionService patrolTeamInspectionService;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void patrolInspectionSchemeAdd(PatrolInspectionSchemeVo patrolInspectionSchemeVo) {
|
|
|
+ SysUser user = SecurityUtils.getLoginUser().getUser();
|
|
|
+ PatrolInspectionScheme patrolInspectionScheme = new PatrolInspectionScheme();
|
|
|
+ patrolInspectionScheme.setInspectionSchemeName(patrolInspectionSchemeVo.getInspectionSchemeName());
|
|
|
+ patrolInspectionScheme.setInspectionTeamId(patrolInspectionSchemeVo.getInspectionTeamId());
|
|
|
+ patrolInspectionScheme.setInspectionMode(patrolInspectionSchemeVo.getInspectionMode());
|
|
|
+ patrolInspectionScheme.setSchemeStartDate(patrolInspectionSchemeVo.getSchemeStartDate());
|
|
|
+ patrolInspectionScheme.setSchemeEndDate(patrolInspectionSchemeVo.getSchemeEndDate());
|
|
|
+ patrolInspectionScheme.setInspectionCycleNumber(patrolInspectionSchemeVo.getInspectionCycleNumber());
|
|
|
+ patrolInspectionScheme.setInspectionCycleType(patrolInspectionSchemeVo.getInspectionCycleType());
|
|
|
+ patrolInspectionScheme.setExecutionTime(patrolInspectionSchemeVo.getExecutionTime());
|
|
|
+ patrolInspectionScheme.setEncounterWeekend(patrolInspectionSchemeVo.getEncounterWeekend());
|
|
|
+ patrolInspectionScheme.setWorkOrderTime(patrolInspectionSchemeVo.getWorkOrderTime());
|
|
|
+ patrolInspectionScheme.setWorkOrderDeadline(patrolInspectionSchemeVo.getWorkOrderDeadline());
|
|
|
+ patrolInspectionScheme.setStatus(patrolInspectionSchemeVo.getStatus());
|
|
|
+ patrolInspectionScheme.setCreator(user.getUserName());
|
|
|
+ patrolInspectionScheme.setCreateTime(new Date());
|
|
|
+ patrolInspectionScheme.setExecutions(0);
|
|
|
+ this.save(patrolInspectionScheme);
|
|
|
+ Integer inspectionSchemeId = patrolInspectionScheme.getId();
|
|
|
+ PatrolInspectionRoute patrolInspectionRoute = new PatrolInspectionRoute();
|
|
|
+
|
|
|
+ patrolInspectionRoute.setInspectionRouteName(patrolInspectionSchemeVo.getPatrolInspectionRouteVo().getInspectionRouteName());
|
|
|
+ patrolInspectionRoute.setInspectionSchemeId(inspectionSchemeId);
|
|
|
+ patrolInspectionRoute.setSiteId(patrolInspectionSchemeVo.getPatrolInspectionRouteVo().getSiteId());
|
|
|
+ patrolInspectionRoute.setCreator(user.getUserName());
|
|
|
+ patrolInspectionRoute.setCreateTime(new Date());
|
|
|
+ patrolInspectionRoute.setStatus(1);
|
|
|
+ patrolInspectionRouteService.save(patrolInspectionRoute);
|
|
|
+ Integer inspectionRouteId = patrolInspectionRoute.getId();
|
|
|
+ if (patrolInspectionSchemeVo.getPatrolInspectionRouteVo().getPatrolRouteContentVo().size() > 0) {
|
|
|
+ for (int j = 0; j < patrolInspectionSchemeVo.getPatrolInspectionRouteVo().getPatrolRouteContentVo().size(); j++) {
|
|
|
+ PatrolRouteContent patrolRouteContent = new PatrolRouteContent();
|
|
|
+ patrolRouteContent.setInspectionContentId(patrolInspectionSchemeVo.getPatrolInspectionRouteVo().getPatrolRouteContentVo().get(j).getInspectionContentId());
|
|
|
+ patrolRouteContent.setInspectionRouteId(inspectionRouteId);
|
|
|
+ patrolRouteContent.setCreator(user.getUserName());
|
|
|
+ patrolRouteContent.setCreateTime(new Date());
|
|
|
+ patrolRouteContent.setStatus(1);
|
|
|
+ patrolRouteContentService.save(patrolRouteContent);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void patrolInspectionSchemeUpdate(PatrolInspectionSchemeVo patrolInspectionSchemeVo) {
|
|
|
+ SysUser user = SecurityUtils.getLoginUser().getUser();
|
|
|
+ PatrolInspectionScheme patrolInspectionScheme = new PatrolInspectionScheme();
|
|
|
+ patrolInspectionScheme.setInspectionSchemeName(patrolInspectionSchemeVo.getInspectionSchemeName());
|
|
|
+ patrolInspectionScheme.setInspectionTeamId(patrolInspectionSchemeVo.getInspectionTeamId());
|
|
|
+ patrolInspectionScheme.setInspectionMode(patrolInspectionSchemeVo.getInspectionMode());
|
|
|
+ patrolInspectionScheme.setSchemeStartDate(patrolInspectionSchemeVo.getSchemeStartDate());
|
|
|
+ patrolInspectionScheme.setSchemeEndDate(patrolInspectionSchemeVo.getSchemeEndDate());
|
|
|
+ patrolInspectionScheme.setInspectionCycleNumber(patrolInspectionSchemeVo.getInspectionCycleNumber());
|
|
|
+ patrolInspectionScheme.setInspectionCycleType(patrolInspectionSchemeVo.getInspectionCycleType());
|
|
|
+ patrolInspectionScheme.setExecutionTime(patrolInspectionSchemeVo.getExecutionTime());
|
|
|
+ patrolInspectionScheme.setEncounterWeekend(patrolInspectionSchemeVo.getEncounterWeekend());
|
|
|
+ patrolInspectionScheme.setWorkOrderTime(patrolInspectionSchemeVo.getWorkOrderTime());
|
|
|
+ patrolInspectionScheme.setWorkOrderDeadline(patrolInspectionSchemeVo.getWorkOrderDeadline());
|
|
|
+ patrolInspectionScheme.setStatus(patrolInspectionSchemeVo.getStatus());
|
|
|
+ patrolInspectionScheme.setId(patrolInspectionSchemeVo.getId());
|
|
|
+ this.updateById(patrolInspectionScheme);
|
|
|
+ Integer inspectionSchemeId = patrolInspectionScheme.getId();
|
|
|
+ //注销旧数据
|
|
|
+ LambdaQueryWrapper<PatrolInspectionRoute> queryWrapper = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper.eq(PatrolInspectionRoute::getInspectionSchemeId, inspectionSchemeId);
|
|
|
+ List<PatrolInspectionRoute> patrolInspectionRouteList = patrolInspectionRouteService.list(queryWrapper);
|
|
|
+ if (patrolInspectionRouteList.size() > 0) {
|
|
|
+ List<Object> inspectionRouteIdList = new ArrayList<>();
|
|
|
+ for (int i = 0; i < patrolInspectionRouteList.size(); i++) {
|
|
|
+ PatrolInspectionRoute patrolInspectionRoute = new PatrolInspectionRoute();
|
|
|
+ patrolInspectionRoute.setStatus(0);
|
|
|
+ patrolInspectionRoute.setId(patrolInspectionRouteList.get(i).getId());
|
|
|
+ patrolInspectionRouteService.updateById(patrolInspectionRoute);
|
|
|
+ inspectionRouteIdList.add(patrolInspectionRouteList.get(i).getId());
|
|
|
+ }
|
|
|
+ LambdaQueryWrapper<PatrolRouteContent> queryWrapperone = Wrappers.lambdaQuery();
|
|
|
+ queryWrapperone.in(PatrolRouteContent::getInspectionRouteId, inspectionRouteIdList);
|
|
|
+ List<PatrolRouteContent> patrolRouteContentList = patrolRouteContentService.list(queryWrapperone);
|
|
|
+ if (patrolRouteContentList.size() > 0) {
|
|
|
+ for (int i = 0; i < patrolRouteContentList.size(); i++) {
|
|
|
+ PatrolRouteContent patrolRouteContent = new PatrolRouteContent();
|
|
|
+ patrolRouteContent.setStatus(0);
|
|
|
+ patrolRouteContent.setId(patrolRouteContentList.get(i).getId());
|
|
|
+ patrolRouteContentService.updateById(patrolRouteContent);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //重新添加新数据
|
|
|
+ PatrolInspectionRoute patrolInspectionRoute = new PatrolInspectionRoute();
|
|
|
+ patrolInspectionRoute.setInspectionRouteName(patrolInspectionSchemeVo.getPatrolInspectionRouteVo().getInspectionRouteName());
|
|
|
+ patrolInspectionRoute.setInspectionSchemeId(inspectionSchemeId);
|
|
|
+ patrolInspectionRoute.setSiteId(patrolInspectionSchemeVo.getPatrolInspectionRouteVo().getSiteId());
|
|
|
+ patrolInspectionRoute.setCreator(user.getUserName());
|
|
|
+ patrolInspectionRoute.setCreateTime(new Date());
|
|
|
+ patrolInspectionRoute.setStatus(1);
|
|
|
+ patrolInspectionRouteService.save(patrolInspectionRoute);
|
|
|
+ Integer inspectionRouteId = patrolInspectionRoute.getId();
|
|
|
+ if (patrolInspectionSchemeVo.getPatrolInspectionRouteVo().getPatrolRouteContentVo().size() > 0) {
|
|
|
+ for (int j = 0; j < patrolInspectionSchemeVo.getPatrolInspectionRouteVo().getPatrolRouteContentVo().size(); j++) {
|
|
|
+ PatrolRouteContent patrolRouteContent = new PatrolRouteContent();
|
|
|
+ patrolRouteContent.setInspectionContentId(patrolInspectionSchemeVo.getPatrolInspectionRouteVo().getPatrolRouteContentVo().get(j).getInspectionContentId());
|
|
|
+ patrolRouteContent.setInspectionRouteId(inspectionRouteId);
|
|
|
+ patrolRouteContent.setCreator(user.getUserName());
|
|
|
+ patrolRouteContent.setCreateTime(new Date());
|
|
|
+ patrolRouteContent.setStatus(1);
|
|
|
+ patrolRouteContentService.save(patrolRouteContent);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void patrolInspectionSchemeDel(Integer id) {
|
|
|
+ PatrolInspectionScheme patrolInspectionScheme = new PatrolInspectionScheme();
|
|
|
+ patrolInspectionScheme.setStatus(0);
|
|
|
+ patrolInspectionScheme.setId(id);
|
|
|
+ this.updateById(patrolInspectionScheme);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public CommonPage<PatrolInspectionScheme> patrolInspectionSchemeList(String inspectionSchemeName, Integer status, Integer size, Integer current) {
|
|
|
+ IPage<PatrolInspectionScheme> page = new Page<PatrolInspectionScheme>(size, current);
|
|
|
+ LambdaQueryWrapper<PatrolInspectionScheme> queryWrapper = Wrappers.lambdaQuery();
|
|
|
+ if (!inspectionSchemeName.equals("") && !inspectionSchemeName.equals(null)) {
|
|
|
+ queryWrapper.like(PatrolInspectionScheme::getInspectionSchemeName, inspectionSchemeName);
|
|
|
+ }
|
|
|
+ if (status != 0) {
|
|
|
+ queryWrapper.eq(PatrolInspectionScheme::getStatus, status);
|
|
|
+ }
|
|
|
+ page = this.page(page, queryWrapper);
|
|
|
+ this.ToCommonPage(page);
|
|
|
+ return new CommonPage<>(page.getRecords(), page.getTotal(), page.getCurrent(), page.getSize());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<PatrolInspectionSchemeOneVo> PatrolInspectionScheme(Integer id) {
|
|
|
+// PatrolInspectionSchemeVo patrolInspectionSchemeVo = new PatrolInspectionSchemeVo();
|
|
|
+ PatrolInspectionRouteVo patrolInspectionRouteVo = new PatrolInspectionRouteVo();
|
|
|
+ PatrolInspectionTeamVo patrolInspectionTeamVo = new PatrolInspectionTeamVo();
|
|
|
+ LambdaQueryWrapper<PatrolInspectionScheme> queryWrapper = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper.eq(PatrolInspectionScheme::getId, id);
|
|
|
+ List<PatrolInspectionScheme> patrolInspectionSchemeList = this.list(queryWrapper);
|
|
|
+
|
|
|
+ //线路查询
|
|
|
+ LambdaQueryWrapper<PatrolInspectionRoute> queryWrapperOne = Wrappers.lambdaQuery();
|
|
|
+ queryWrapperOne.eq(PatrolInspectionRoute::getInspectionSchemeId, id).eq(PatrolInspectionRoute::getStatus, 1);
|
|
|
+ List<PatrolInspectionRoute> patrolInspectionRouteList = patrolInspectionRouteService.list(queryWrapperOne);
|
|
|
+ if (patrolInspectionRouteList.size() > 0) {
|
|
|
+// for (int i = 0; i < patrolInspectionRouteList.size(); i++) {
|
|
|
+ List<PatrolRouteContentVo> patrolRouteContentList = baseMapper.patrolRouteContent(patrolInspectionRouteList.get(0).getId());
|
|
|
+ Integer inspectionSchemeId = patrolInspectionRouteList.get(0).getInspectionSchemeId();
|
|
|
+
|
|
|
+ patrolInspectionRouteVo.setInspectionSchemeId(inspectionSchemeId);
|
|
|
+ patrolInspectionRouteVo.setInspectionRouteName(patrolInspectionRouteList.get(0).getInspectionRouteName());
|
|
|
+ patrolInspectionRouteVo.setCreator(patrolInspectionRouteList.get(0).getCreator());
|
|
|
+ patrolInspectionRouteVo.setCreateTime(patrolInspectionRouteList.get(0).getCreateTime());
|
|
|
+ patrolInspectionRouteVo.setId(patrolInspectionRouteList.get(0).getId());
|
|
|
+ patrolInspectionRouteVo.setStatus(patrolInspectionRouteList.get(0).getStatus());
|
|
|
+ patrolInspectionRouteVo.setPatrolRouteContentVo(patrolRouteContentList);
|
|
|
+// }
|
|
|
+ }
|
|
|
+
|
|
|
+ //团队查询
|
|
|
+ LambdaQueryWrapper<PatrolInspectionTeam> queryWrapperTwo = Wrappers.lambdaQuery();
|
|
|
+ queryWrapperTwo.eq(PatrolInspectionTeam::getId, patrolInspectionSchemeList.get(0).getInspectionTeamId()).eq(PatrolInspectionTeam::getStatus, 1);
|
|
|
+ List<PatrolInspectionTeam> patrolInspectionTeamList = patrolInspectionTeamService.list(queryWrapperTwo);
|
|
|
+ if (patrolInspectionTeamList.size() > 0) {
|
|
|
+// for (int i = 0; i < patrolInspectionTeamList.size(); i++) {
|
|
|
+ List<PatrolInspectors> patrolInspectorsList = baseMapper.patrolInspectorsList(patrolInspectionTeamList.get(0).getId());
|
|
|
+ patrolInspectionTeamVo.setId(patrolInspectionTeamList.get(0).getId());
|
|
|
+ patrolInspectionTeamVo.setTeamName(patrolInspectionTeamList.get(0).getTeamName());
|
|
|
+ patrolInspectionTeamVo.setInspectorsId(patrolInspectionTeamList.get(0).getInspectorsId());
|
|
|
+ patrolInspectionTeamVo.setUserId(patrolInspectionTeamList.get(0).getUserId());
|
|
|
+ patrolInspectionTeamVo.setTeamType(patrolInspectionTeamList.get(0).getTeamType());
|
|
|
+ patrolInspectionTeamVo.setReservedField(patrolInspectionTeamList.get(0).getReservedField());
|
|
|
+ patrolInspectionTeamVo.setCreator(patrolInspectionTeamList.get(0).getCreator());
|
|
|
+ patrolInspectionTeamVo.setCreateTime(patrolInspectionTeamList.get(0).getCreateTime());
|
|
|
+ patrolInspectionTeamVo.setStatus(patrolInspectionTeamList.get(0).getStatus());
|
|
|
+ patrolInspectionTeamVo.setPatrolInspectors(patrolInspectorsList);
|
|
|
+// }
|
|
|
+ }
|
|
|
+
|
|
|
+ List<PatrolInspectionSchemeOneVo> list = new ArrayList<>();
|
|
|
+ list.add(PatrolInspectionSchemeOneVo.builder()
|
|
|
+ .inspectionSchemeName(patrolInspectionSchemeList.get(0).getInspectionSchemeName())
|
|
|
+ .inspectionMode(patrolInspectionSchemeList.get(0).getInspectionMode())
|
|
|
+ .inspectionTeamId(patrolInspectionSchemeList.get(0).getInspectionTeamId())
|
|
|
+ .schemeEndDate(patrolInspectionSchemeList.get(0).getSchemeEndDate())
|
|
|
+ .schemeStartDate(patrolInspectionSchemeList.get(0).getSchemeStartDate())
|
|
|
+ .inspectionCycleNumber(patrolInspectionSchemeList.get(0).getInspectionCycleNumber())
|
|
|
+ .inspectionCycleType(patrolInspectionSchemeList.get(0).getInspectionCycleType())
|
|
|
+ .executionTime(patrolInspectionSchemeList.get(0).getExecutionTime())
|
|
|
+ .encounterWeekend(patrolInspectionSchemeList.get(0).getEncounterWeekend())
|
|
|
+ .workOrderTime(patrolInspectionSchemeList.get(0).getWorkOrderTime())
|
|
|
+ .workOrderDeadline(patrolInspectionSchemeList.get(0).getWorkOrderDeadline())
|
|
|
+ .status(patrolInspectionSchemeList.get(0).getStatus())
|
|
|
+ .creator(patrolInspectionSchemeList.get(0).getCreator())
|
|
|
+ .createTime(patrolInspectionSchemeList.get(0).getCreateTime())
|
|
|
+ .executions(patrolInspectionSchemeList.get(0).getExecutions())
|
|
|
+ .id(patrolInspectionSchemeList.get(0).getId())
|
|
|
+ .patrolInspectionTeamVo(patrolInspectionTeamVo)
|
|
|
+ .patrolInspectionRouteVo(patrolInspectionRouteVo)
|
|
|
+ .build()
|
|
|
+ );
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<PatrolCheckEntryVo> checkItemList(Integer inspectionContentId) {
|
|
|
+ List<PatrolCheckEntryVo> list = baseMapper.checkItemList(inspectionContentId);
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<PatrolInspectionContent> patrolInspectionContentDroplist(Integer siteId) {
|
|
|
+ List<PatrolInspectionContent> list = baseMapper.patrolInspectionContentDroplist(siteId);
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void patrolInspectionRouteDel(Integer id) {
|
|
|
+ PatrolInspectionRoute patrolInspectionRoute = new PatrolInspectionRoute();
|
|
|
+ patrolInspectionRoute.setId(id);
|
|
|
+ patrolInspectionRoute.setStatus(0);
|
|
|
+ patrolInspectionRouteService.updateById(patrolInspectionRoute);
|
|
|
+ LambdaQueryWrapper<PatrolRouteContent> queryWrapperOne = Wrappers.lambdaQuery();
|
|
|
+ queryWrapperOne.eq(PatrolRouteContent::getInspectionRouteId, id).eq(PatrolRouteContent::getStatus, 1);
|
|
|
+ List<PatrolRouteContent> patrolRouteContentList = patrolRouteContentService.list(queryWrapperOne);
|
|
|
+ if (patrolRouteContentList.size() > 0) {
|
|
|
+ for (int i = 0; i < patrolRouteContentList.size(); i++) {
|
|
|
+ PatrolRouteContent patrolRouteContent = new PatrolRouteContent();
|
|
|
+ patrolRouteContent.setStatus(0);
|
|
|
+ patrolRouteContent.setId(patrolRouteContentList.get(i).getId());
|
|
|
+ patrolRouteContentService.updateById(patrolRouteContent);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<PatrolInspectionSchemeListVo> patrolInspectionSchemeCalendar(Integer id) {
|
|
|
+ List<PatrolInspectionSchemeListVo> list = baseMapper.patrolInspectionSchemeList(id);
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|