|
|
@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.ktg.common.core.text.Convert;
|
|
|
import com.ktg.common.utils.bean.BeanUtils;
|
|
|
+import com.ktg.iscs.domain.IsJobTicketPoints;
|
|
|
import com.ktg.iscs.domain.IsSop;
|
|
|
import com.ktg.iscs.domain.IsSopPoints;
|
|
|
import com.ktg.iscs.domain.IsSopUser;
|
|
|
@@ -65,6 +66,13 @@ public class IsSopServiceImpl extends ServiceImpl<IsSopMapper, IsSop> implements
|
|
|
List<Long> pointIds = isSopPoints.stream().map(IsSopPoints::getPointId).collect(Collectors.toList());
|
|
|
// List<IsIsolationPoint> isIsolationPoints = iIsIsolationPointService.listByIds(pointIds);
|
|
|
List<PointDetailVO> pointDetailVOList = iIsIsolationPointService.getPointDetailList(pointIds);
|
|
|
+ for (PointDetailVO pointDetailVO : pointDetailVOList) {
|
|
|
+ for (IsSopPoints isSopPoint : isSopPoints) {
|
|
|
+ if (pointDetailVO.getPointId().equals(isSopPoint.getPointId())) {
|
|
|
+ pointDetailVO.setPrePointId(isSopPoint.getPrePointId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
// 3.1组合返回数据
|
|
|
sopDetailVO.setPointDetailVOList(pointDetailVOList);
|
|
|
}
|
|
|
@@ -98,25 +106,23 @@ public class IsSopServiceImpl extends ServiceImpl<IsSopMapper, IsSop> implements
|
|
|
@Override
|
|
|
public Boolean insertIsSop(AddSopDTO dto) {
|
|
|
// 断言校验
|
|
|
- Assert.notNull(dto.getWorkshopId(), "所属车间不可为空!");
|
|
|
Assert.isTrue(StringUtils.isNotBlank(dto.getSopName()), "SOP名称不可为空!");
|
|
|
Assert.isTrue(StringUtils.isNotBlank(dto.getSopCode()), "SOP编号名称不可为空!");
|
|
|
List<IsSop> list = list(Wrappers.<IsSop>lambdaQuery().eq(IsSop::getSopCode, dto.getSopCode()));
|
|
|
Assert.isTrue(list.isEmpty(), "该SOP编号已被使用!");
|
|
|
// 1.判断隔离点必选
|
|
|
- Assert.isTrue(StringUtils.isNotBlank(dto.getPointIds()), "隔离点id不可为空!");
|
|
|
+ Assert.isFalse(dto.getPointsList().isEmpty(), "隔离点id不可为空!");
|
|
|
// 2.开始新增sop数据
|
|
|
IsSop isSop = BeanUtils.toBean(dto, IsSop.class);
|
|
|
save(isSop);
|
|
|
// 3.新增车间、区域、隔离点和sop的关联关系
|
|
|
// TODO 批量新增
|
|
|
- Long[] pointIds = Convert.toLongArray(dto.getPointIds());
|
|
|
- for (Long pointId : pointIds) {
|
|
|
+ for (IsJobTicketPoints isJobTicketPoints : dto.getPointsList()) {
|
|
|
IsSopPoints isSopPoints = new IsSopPoints();
|
|
|
isSopPoints.setSopId(isSop.getSopId());
|
|
|
- isSopPoints.setWorkshopId(dto.getWorkshopId());
|
|
|
isSopPoints.setWorkareaId(dto.getWorkareaId());
|
|
|
- isSopPoints.setPointId(pointId);
|
|
|
+ isSopPoints.setPointId(isJobTicketPoints.getPointId());
|
|
|
+ isSopPoints.setPrePointId(isJobTicketPoints.getPrePointId());
|
|
|
iIsSopPointsService.save(isSopPoints);
|
|
|
}
|
|
|
// 4.新增人员信息到模板
|
|
|
@@ -144,7 +150,6 @@ public class IsSopServiceImpl extends ServiceImpl<IsSopMapper, IsSop> implements
|
|
|
public Boolean updateIsSop(AddSopDTO dto) {
|
|
|
// 断言校验
|
|
|
Assert.notNull(dto.getSopId(), "sopId不可为空!");
|
|
|
- Assert.notNull(dto.getWorkshopId(), "所属车间不可为空!");
|
|
|
Assert.isTrue(StringUtils.isNotBlank(dto.getSopName()), "SOP名称不可为空!");
|
|
|
Assert.isTrue(StringUtils.isNotBlank(dto.getSopCode()), "SOP编号名称不可为空!");
|
|
|
List<IsSop> list = list(Wrappers.<IsSop>lambdaQuery()
|
|
|
@@ -152,27 +157,24 @@ public class IsSopServiceImpl extends ServiceImpl<IsSopMapper, IsSop> implements
|
|
|
.ne(IsSop::getSopId, dto.getSopId()));
|
|
|
Assert.isTrue(list.isEmpty(), "该SOP编号已被使用!");
|
|
|
// 1.判断隔离点必选
|
|
|
- Assert.isTrue(StringUtils.isNotBlank(dto.getPointIds()), "隔离点id不可为空!");
|
|
|
+ Assert.isFalse(dto.getPointsList().isEmpty(), "隔离点id不可为空!");
|
|
|
// 1.1检查区域有没有变,区域变了的话隔离点肯定变了,因为隔离点是从区域数据中解析的
|
|
|
IsSop sop = getById(dto.getSopId());
|
|
|
// 2.开始检查隔离点有没有变更
|
|
|
- Long[] pointIds = Convert.toLongArray(dto.getPointIds());
|
|
|
+ List<Long> poindList = dto.getPointsList().stream().map(IsJobTicketPoints::getPointId).collect(Collectors.toList());
|
|
|
List<IsSopPoints> isSopPoints = iIsSopPointsService.list(Wrappers.<IsSopPoints>lambdaQuery()
|
|
|
- .eq(IsSopPoints::getSopId, dto.getSopId()));
|
|
|
+ .eq(IsSopPoints::getSopId, dto.getSopId())
|
|
|
+ .in(IsSopPoints::getPointId, poindList));
|
|
|
// 2.1如果查出来变更了,开始执行删除,重新增加一轮 / 区域变更则点位必然改变,也需要删除
|
|
|
- if (pointIds.length != isSopPoints.size() || !sop.getWorkareaId().equals(dto.getWorkareaId())) {
|
|
|
- Set<Long> recordIds = isSopPoints.stream().map(IsSopPoints::getRecordId).collect(Collectors.toSet());
|
|
|
- if (!recordIds.isEmpty()) {
|
|
|
- String rids = StringUtils.join(recordIds.toArray(), ",");
|
|
|
- iIsSopPointsService.deleteIsSopPointsByRecordIds(rids);
|
|
|
- }
|
|
|
+ if (dto.getPointsList().size() != isSopPoints.size() || !sop.getWorkareaId().equals(dto.getWorkareaId())) {
|
|
|
+ iIsSopPointsService.remove(Wrappers.<IsSopPoints>lambdaQuery().eq(IsSopPoints::getSopId, dto.getSopId()));
|
|
|
// TODO 批量新增
|
|
|
- for (Long pointId : pointIds) {
|
|
|
+ for (IsJobTicketPoints isJobTicketPoints : dto.getPointsList()) {
|
|
|
IsSopPoints newSopPoints = new IsSopPoints();
|
|
|
newSopPoints.setSopId(dto.getSopId());
|
|
|
- newSopPoints.setWorkshopId(dto.getWorkshopId());
|
|
|
newSopPoints.setWorkareaId(dto.getWorkareaId());
|
|
|
- newSopPoints.setPointId(pointId);
|
|
|
+ newSopPoints.setPointId(isJobTicketPoints.getPointId());
|
|
|
+ newSopPoints.setPrePointId(isJobTicketPoints.getPrePointId());
|
|
|
iIsSopPointsService.save(newSopPoints);
|
|
|
}
|
|
|
}
|