Commit a7850ad4 authored by H2T's avatar H2T

修改巡检线路点的巡检项接口修改

parent bd038335
...@@ -744,11 +744,12 @@ public class RouteController extends AbstractBaseController { ...@@ -744,11 +744,12 @@ public class RouteController extends AbstractBaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "修改巡检线路点的巡检项新", notes = "修改巡检线路点的巡检项新") @ApiOperation(value = "修改巡检线路点的巡检项新", notes = "修改巡检线路点的巡检项新")
@PostMapping(value = "/updateRoutePointInputItemNew", produces = "application/json;charset=UTF-8") @PostMapping(value = "/updateRoutePointInputItemNew", produces = "application/json;charset=UTF-8")
public CommonResponse updateRoutePointInputItemNew(@ApiParam(value = "巡检路线id", required = true) @RequestParam Long routeId, public CommonResponse updateRoutePointInputItemNew(@ApiParam(value = "巡检路线id", required = true) @RequestParam(value = "routeId") Long routeId,
@ApiParam(value = "巡检点id", required = true) @RequestParam Long pointId, @ApiParam(value = "巡检点id", required = true) @RequestParam(value = "pointId") Long pointId,
@ApiParam(value = "巡检点分类id", required = true) @RequestParam(value = "classifyId") Long classifyId,
@ApiParam(value = "巡检点巡检项id", required = true) @RequestParam List<Long> inputItemIds) { @ApiParam(value = "巡检点巡检项id", required = true) @RequestParam List<Long> inputItemIds) {
try { try {
routeService.updateRoutePointInputItemNew(routeId, pointId, inputItemIds); routeService.updateRoutePointInputItemNew(routeId, pointId,classifyId, inputItemIds);
return CommonResponseUtil.success(); return CommonResponseUtil.success();
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
......
...@@ -56,4 +56,9 @@ public interface IPointInputItemDao extends BaseDao<PointInputItem, Long> { ...@@ -56,4 +56,9 @@ public interface IPointInputItemDao extends BaseDao<PointInputItem, Long> {
@Query(value = "SELECT count(*) FROM p_point_inputitem WHERE input_item_id IN(?1) ", nativeQuery = true) @Query(value = "SELECT count(*) FROM p_point_inputitem WHERE input_item_id IN(?1) ", nativeQuery = true)
int selectByITemId(String inputItemIds); int selectByITemId(String inputItemIds);
@Modifying
@Transactional
@Query(value = "SELECT * FROM p_point_inputitem WHERE point_id = ?1 and classify_ids =?2", nativeQuery = true)
List<PointInputItem> getPointInputItemByPointIdAndClassifyId(Long pointId,Long classifyId);
} }
...@@ -31,6 +31,8 @@ import org.springframework.transaction.annotation.Transactional; ...@@ -31,6 +31,8 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@Service("routeService") @Service("routeService")
public class RouteServiceImpl extends ServiceImpl<RouteMapper, Route> implements IRouteService { public class RouteServiceImpl extends ServiceImpl<RouteMapper, Route> implements IRouteService {
...@@ -539,18 +541,27 @@ public class RouteServiceImpl extends ServiceImpl<RouteMapper, Route> implement ...@@ -539,18 +541,27 @@ public class RouteServiceImpl extends ServiceImpl<RouteMapper, Route> implement
iRoutePointItemDao.saveAll(routePointList); iRoutePointItemDao.saveAll(routePointList);
} }
@Override
@Transactional @Transactional
public void updateRoutePointInputItemNew(Long routeId, Long pointId, List<Long> inputItemIds) { public void updateRoutePointInputItemNew(Long routeId, Long pointId,Long classifyId, List<Long> inputItemIds) {
Long[] pointIds = {pointId}; Long[] pointIds = {pointId};
List<RoutePoint> oldRoutePointList = iRoutePointDao.queryRoutePoint(routeId, pointIds); List<RoutePoint> oldRoutePointList = iRoutePointDao.queryRoutePoint(routeId, pointIds);
if(oldRoutePointList!=null&&oldRoutePointList.size()>0){ if (oldRoutePointList != null && oldRoutePointList.size() > 0) {
RoutePoint RoutePoint=oldRoutePointList.get(0);
if(inputItemIds!=null){ RoutePoint RoutePoint = oldRoutePointList.get(0);
String excludeItem = StringUtils.join(inputItemIds.toArray(), ","); List<Long> split = Arrays.asList(RoutePoint.getExcludeItems().split(",")).stream().map(Long::parseLong).collect(Collectors.toList());
RoutePoint.setExcludeItems(excludeItem);
}else{ Set<Long> allPointInputItemIdSet = iPointInputItemDao.getPointInputItemByPointIdAndClassifyId(pointId, classifyId)
RoutePoint.setExcludeItems(null); .stream().map(PointInputItem::getId)
} .collect(Collectors.toSet());
List<Long> otherClassify = new ArrayList<>();
split.forEach(x -> {
if (!allPointInputItemIdSet.contains(x)) {
otherClassify.add(x);
}
});
List<Long> lastList = Stream.concat(otherClassify.stream(), inputItemIds.stream()).distinct().collect(Collectors.toList());
RoutePoint.setExcludeItems(StringUtils.join(lastList.toArray(), ","));
iRoutePointDao.saveAndFlush(RoutePoint); iRoutePointDao.saveAndFlush(RoutePoint);
} }
} }
......
...@@ -132,7 +132,7 @@ public interface IRouteService extends IService<Route> { ...@@ -132,7 +132,7 @@ public interface IRouteService extends IService<Route> {
*/ */
void updateRoutePointInputItem(Long routeId, Long pointId, Long[] inputItemIds); void updateRoutePointInputItem(Long routeId, Long pointId, Long[] inputItemIds);
void updateRoutePointInputItemNew(Long routeId, Long pointId, List<Long> inputItemIds); void updateRoutePointInputItemNew(Long routeId, Long pointId, Long classifyId,List<Long> inputItemIds);
/** /**
* 列出巡检点的巡检项及其分类 * 列出巡检点的巡检项及其分类
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment