|
|
@@ -4,19 +4,29 @@ import cn.hutool.core.lang.Assert;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.fasterxml.jackson.core.type.TypeReference;
|
|
|
+import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.ktg.common.core.text.Convert;
|
|
|
+import com.ktg.iscs.domain.IsJobTicketPoints;
|
|
|
import com.ktg.iscs.domain.IsSopPoints;
|
|
|
import com.ktg.iscs.domain.IsWorkarea;
|
|
|
+import com.ktg.iscs.domain.vo.points.PointDetailVO;
|
|
|
import com.ktg.iscs.domain.vo.workarea.PageWorkareaVO;
|
|
|
+import com.ktg.iscs.domain.vo.workarea.PointsMapVO;
|
|
|
import com.ktg.iscs.mapper.IsWorkareaMapper;
|
|
|
+import com.ktg.iscs.service.IIsIsolationPointService;
|
|
|
+import com.ktg.iscs.service.IIsJobTicketPointsService;
|
|
|
import com.ktg.iscs.service.IIsSopPointsService;
|
|
|
import com.ktg.iscs.service.IIsWorkareaService;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.io.IOException;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* 工作区域Service业务层处理
|
|
|
@@ -31,6 +41,10 @@ public class IsWorkareaServiceImpl extends ServiceImpl<IsWorkareaMapper, IsWorka
|
|
|
private IsWorkareaMapper isWorkareaMapper;
|
|
|
@Autowired
|
|
|
private IIsSopPointsService iIsSopPointsService;
|
|
|
+ @Autowired
|
|
|
+ private IIsIsolationPointService iIsIsolationPointService;
|
|
|
+ @Autowired
|
|
|
+ private IIsJobTicketPointsService iIsJobTicketPointsService;
|
|
|
|
|
|
/**
|
|
|
* 查询工作区域
|
|
|
@@ -136,4 +150,80 @@ public class IsWorkareaServiceImpl extends ServiceImpl<IsWorkareaMapper, IsWorka
|
|
|
public Page<PageWorkareaVO> getIsWorkareaPage(Page page, IsWorkarea dto) {
|
|
|
return isWorkareaMapper.getIsWorkareaPage(page, dto);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<PointsMapVO> selectIsWorkareaMapById(Long workareaId, Long sopId, Long ticketId) {
|
|
|
+ // 1.断言校验
|
|
|
+ Assert.notNull(workareaId, "请传入区域id");
|
|
|
+ // 2.查询区域信息
|
|
|
+ IsWorkarea workarea = getById(workareaId);
|
|
|
+ // 3.解析map
|
|
|
+ List<PointsMapVO> points = new ArrayList<>();
|
|
|
+ if (workarea != null) {
|
|
|
+ String map = workarea.getMap();
|
|
|
+ ObjectMapper objectMapper = new ObjectMapper();
|
|
|
+ try {
|
|
|
+ points = objectMapper.readValue(map, new TypeReference<List<PointsMapVO>>(){});
|
|
|
+ // 4.补充点位name,隔离点类型,危险能量类型
|
|
|
+ List<Long> pointIds = points.stream().map(PointsMapVO::getPointId).collect(Collectors.toList());
|
|
|
+ List<PointDetailVO> pointDetailList = iIsIsolationPointService.getPointDetailList(pointIds);
|
|
|
+ // 5.获取sop信息
|
|
|
+ List<IsSopPoints> isSopPoints;
|
|
|
+ if (sopId != null) {
|
|
|
+ isSopPoints = iIsSopPointsService.list(Wrappers.<IsSopPoints>lambdaQuery()
|
|
|
+ .eq(IsSopPoints::getSopId, sopId));
|
|
|
+ } else {
|
|
|
+ isSopPoints = new ArrayList<>();
|
|
|
+ }
|
|
|
+ // 6.获取作业票点位数据
|
|
|
+ List<IsJobTicketPoints> isJobTicketPoints;
|
|
|
+ if (ticketId != null) {
|
|
|
+ isJobTicketPoints = iIsJobTicketPointsService.list(Wrappers.<IsJobTicketPoints>lambdaQuery()
|
|
|
+ .eq(IsJobTicketPoints::getTicketId, ticketId));
|
|
|
+ } else {
|
|
|
+ isJobTicketPoints = new ArrayList<>();
|
|
|
+ }
|
|
|
+ // 6.组装数据
|
|
|
+ points.stream().filter(o -> {
|
|
|
+ // 初始化选中状态
|
|
|
+ o.setState(false);
|
|
|
+ // 如果点位信息有,则填充
|
|
|
+ if (!pointDetailList.isEmpty()) {
|
|
|
+ for (PointDetailVO pointDetailVO : pointDetailList) {
|
|
|
+ if (o.getPointId().equals(pointDetailVO.getPointId())) {
|
|
|
+ o.setPointName(pointDetailVO.getPointName());
|
|
|
+ o.setPointType(pointDetailVO.getPointType());
|
|
|
+ o.setPointTypeName(pointDetailVO.getPointTypeName());
|
|
|
+ o.setPowerType(pointDetailVO.getPowerType());
|
|
|
+ o.setPowerTypeName(pointDetailVO.getPowerTypeName());
|
|
|
+ o.setPointIcon(pointDetailVO.getPointIcon());
|
|
|
+ o.setPointPicture(pointDetailVO.getPointPicture());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // sop如果选中信息有则开始标记
|
|
|
+ if (!isSopPoints.isEmpty()) {
|
|
|
+ for (IsSopPoints isSopPoint : isSopPoints) {
|
|
|
+ if (o.getPointId().equals(isSopPoint.getPointId())) {
|
|
|
+ o.setState(true);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 作业票如果选中信息有则开始标记
|
|
|
+ if (!isJobTicketPoints.isEmpty()) {
|
|
|
+ for (IsJobTicketPoints ticketPoint : isJobTicketPoints) {
|
|
|
+ if (o.getPointId().equals(ticketPoint.getPointId())) {
|
|
|
+ o.setState(true);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ } catch (IOException e) {
|
|
|
+ Assert.isTrue(false, "map数据解析失败!");
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return points;
|
|
|
+ }
|
|
|
}
|