Commit c346f25b authored by chenzhao's avatar chenzhao

增加重复校验功能

parent 169358a5
...@@ -11,6 +11,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; ...@@ -11,6 +11,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils; import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.patrol.business.dao.mapper.InputItemMapper; import com.yeejoin.amos.patrol.business.dao.mapper.InputItemMapper;
import com.yeejoin.amos.patrol.business.feign.JcsFeignClient; import com.yeejoin.amos.patrol.business.feign.JcsFeignClient;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -554,6 +555,9 @@ public class InputItemController extends AbstractBaseController { ...@@ -554,6 +555,9 @@ public class InputItemController extends AbstractBaseController {
if (param.getEquipmentType() == null && param.getCustomType() == null&&param.getFacilitiesType() == null&&param.getKeyPartsType() == null){ if (param.getEquipmentType() == null && param.getCustomType() == null&&param.getFacilitiesType() == null&&param.getKeyPartsType() == null){
throw new BadRequest("适用类型至少需选择一项"); throw new BadRequest("适用类型至少需选择一项");
} }
if (CollectionUtils.isNotEmpty(inputItemDao.findByItemName(param.getName()))) {
throw new BadRequest("该名称已存在,请重新输入");
}
//如果为1则为否,顺应机场逻辑 //如果为1则为否,顺应机场逻辑
param.setCustomType("1".equals(param.getCustomType()) ? null : param.getCustomType()); param.setCustomType("1".equals(param.getCustomType()) ? null : param.getCustomType());
param.setKeyPartsType("1".equals(param.getKeyPartsType()) ? null : param.getKeyPartsType()); param.setKeyPartsType("1".equals(param.getKeyPartsType()) ? null : param.getKeyPartsType());
......
...@@ -7,10 +7,7 @@ import javax.servlet.http.HttpServletResponse; ...@@ -7,10 +7,7 @@ import javax.servlet.http.HttpServletResponse;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yeejoin.amos.component.feign.model.FeignClientResult; import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.patrol.business.dao.mapper.PointMapper; import com.yeejoin.amos.patrol.business.dao.mapper.PointMapper;
import com.yeejoin.amos.patrol.business.dao.repository.IPointClassifyDao; import com.yeejoin.amos.patrol.business.dao.repository.*;
import com.yeejoin.amos.patrol.business.dao.repository.IPointInputItemDao;
import com.yeejoin.amos.patrol.business.dao.repository.IRoutePointDao;
import com.yeejoin.amos.patrol.business.dao.repository.IRoutePointItemDao;
import com.yeejoin.amos.patrol.business.feign.EquipFeign; import com.yeejoin.amos.patrol.business.feign.EquipFeign;
import com.yeejoin.amos.patrol.business.feign.JcsFeignClient; import com.yeejoin.amos.patrol.business.feign.JcsFeignClient;
import com.yeejoin.amos.patrol.business.vo.*; import com.yeejoin.amos.patrol.business.vo.*;
...@@ -64,6 +61,7 @@ import com.yeejoin.amos.patrol.feign.RemoteSecurityService; ...@@ -64,6 +61,7 @@ import com.yeejoin.amos.patrol.feign.RemoteSecurityService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseModel; import org.typroject.tyboot.core.restful.utils.ResponseModel;
@RestController @RestController
...@@ -78,6 +76,8 @@ public class PointController extends AbstractBaseController { ...@@ -78,6 +76,8 @@ public class PointController extends AbstractBaseController {
@Autowired @Autowired
private PointMapper pointMapper; private PointMapper pointMapper;
@Autowired
private IPointDao iPointDao;
@Autowired @Autowired
private ICatalogTreeService catalogTreeService; private ICatalogTreeService catalogTreeService;
...@@ -1502,6 +1502,20 @@ public class PointController extends AbstractBaseController { ...@@ -1502,6 +1502,20 @@ public class PointController extends AbstractBaseController {
if (ObjectUtils.isEmpty(pointNewVo.getChargePersonId())) { if (ObjectUtils.isEmpty(pointNewVo.getChargePersonId())) {
return CommonResponseUtil.failure("责任人不能为空"); return CommonResponseUtil.failure("责任人不能为空");
} }
if (!ObjectUtils.isEmpty(pointNewVo.getName())) {
List<Point> list = iPointDao.findByName(pointNewVo.getName());
if (CollectionUtils.isNotEmpty(list)) {
throw new BadRequest("该名称巡检点已存在");
}
}
if (!ObjectUtils.isEmpty(pointNewVo.getName())) {
List<Point> list = iPointDao.findByNo(pointNewVo.getPointNo());
if (CollectionUtils.isNotEmpty(list)) {
throw new BadRequest("该编号已存在");
}
}
try { try {
Point point = new Point(); Point point = new Point();
BeanUtils.copyProperties(pointNewVo,point); BeanUtils.copyProperties(pointNewVo,point);
......
...@@ -9,10 +9,13 @@ import java.util.Map; ...@@ -9,10 +9,13 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yeejoin.amos.component.feign.model.FeignClientResult; import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.patrol.business.dao.mapper.RoutePointItemMapper; import com.yeejoin.amos.patrol.business.dao.mapper.RoutePointItemMapper;
import com.yeejoin.amos.patrol.business.dao.repository.IRoutePointDao; import com.yeejoin.amos.patrol.business.dao.repository.IRoutePointDao;
import com.yeejoin.amos.patrol.business.feign.JcsFeignClient; import com.yeejoin.amos.patrol.business.feign.JcsFeignClient;
import com.yeejoin.amos.patrol.business.service.impl.RouteServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -54,6 +57,7 @@ import com.yeejoin.amos.patrol.feign.RemoteSecurityService; ...@@ -54,6 +57,7 @@ import com.yeejoin.amos.patrol.feign.RemoteSecurityService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseModel; import org.typroject.tyboot.core.restful.utils.ResponseModel;
import javax.annotation.Resource; import javax.annotation.Resource;
...@@ -80,6 +84,8 @@ public class RouteController extends AbstractBaseController { ...@@ -80,6 +84,8 @@ public class RouteController extends AbstractBaseController {
private RoutePointItemMapper routePointItemMapper; private RoutePointItemMapper routePointItemMapper;
@Autowired @Autowired
private IRoutePointDao iRoutePointDao; private IRoutePointDao iRoutePointDao;
@Autowired
private RouteServiceImpl routeServiceImpl;
/** /**
* *
* 新增接口 * 新增接口
...@@ -167,6 +173,15 @@ public class RouteController extends AbstractBaseController { ...@@ -167,6 +173,15 @@ public class RouteController extends AbstractBaseController {
String loginOrgCode = getOrgCode(reginParams); String loginOrgCode = getOrgCode(reginParams);
route.setOrgCode(loginOrgCode); route.setOrgCode(loginOrgCode);
if(!StringUtils.isEmpty(route.getName())){
LambdaQueryWrapper<Route> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(Route::getName,route.getName());
List<Route> list = routeServiceImpl.list(wrapper);
if (!ObjectUtils.isEmpty(list) || list.size()>0){
throw new BadRequest("该名称路线已存在");
}
}
if(route.getDeptId()!=null){ if(route.getDeptId()!=null){
//查询jcs //查询jcs
ResponseModel<Object> companyInfo = jcsFeignClient.getCompanyInfo(route.getDeptId()); ResponseModel<Object> companyInfo = jcsFeignClient.getCompanyInfo(route.getDeptId());
......
...@@ -17,7 +17,7 @@ import com.yeejoin.amos.patrol.dao.entity.PointInputItem; ...@@ -17,7 +17,7 @@ import com.yeejoin.amos.patrol.dao.entity.PointInputItem;
import com.yeejoin.amos.patrol.dao.entity.Route; import com.yeejoin.amos.patrol.dao.entity.Route;
import com.yeejoin.amos.patrol.dao.entity.RoutePointItem; import com.yeejoin.amos.patrol.dao.entity.RoutePointItem;
public interface RouteMapper extends BaseMapper { public interface RouteMapper extends BaseMapper, com.baomidou.mybatisplus.core.mapper.BaseMapper<Route> {
/** /**
* 根据路线id与点id,获取路线上点的项 * 根据路线id与点id,获取路线上点的项
......
...@@ -33,4 +33,11 @@ public interface IInputItemDao extends BaseDao<InputItem, Long> { ...@@ -33,4 +33,11 @@ public interface IInputItemDao extends BaseDao<InputItem, Long> {
@Query(value = "delete * from p_input_item where is not null and is_delete =0", nativeQuery = true) @Query(value = "delete * from p_input_item where is not null and is_delete =0", nativeQuery = true)
void deleteAllByEquipmentNameIsNotNull(); void deleteAllByEquipmentNameIsNotNull();
@Query(value = "select * from p_input_item where item_no = ?1 and is_delete =0", nativeQuery = true)
List<InputItem> findByItemNo(String itemNo);
@Query(value = "select * from p_input_item where name = ?1 and is_delete =0", nativeQuery = true)
List<InputItem> findByItemName(String name);
} }
...@@ -27,4 +27,10 @@ public interface IPointDao extends BaseDao<Point, Long> { ...@@ -27,4 +27,10 @@ public interface IPointDao extends BaseDao<Point, Long> {
Optional<Point> findById(Long id); Optional<Point> findById(Long id);
@Query(value = "select * from p_point where point_no = (?1) and is_delete =0", nativeQuery = true)
List<Point> findByNo(String pointNo);
@Query(value = "select * from p_point where name = (?1) and is_delete =0", nativeQuery = true)
List<Point> findByName(String name);
} }
package com.yeejoin.amos.patrol.business.service.impl; package com.yeejoin.amos.patrol.business.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.base.Joiner; import com.google.common.base.Joiner;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
...@@ -67,7 +68,7 @@ import java.util.Set; ...@@ -67,7 +68,7 @@ import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Service("routeService") @Service("routeService")
public class RouteServiceImpl implements IRouteService { public class RouteServiceImpl extends ServiceImpl<RouteMapper, Route> implements IRouteService {
@Autowired @Autowired
private IRouteDao iRouteDao; private IRouteDao iRouteDao;
......
...@@ -5,6 +5,7 @@ import java.util.LinkedHashMap; ...@@ -5,6 +5,7 @@ import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yeejoin.amos.patrol.business.param.LoginUserParam; import com.yeejoin.amos.patrol.business.param.LoginUserParam;
import com.yeejoin.amos.patrol.business.param.SynRouteParam; import com.yeejoin.amos.patrol.business.param.SynRouteParam;
import com.yeejoin.amos.patrol.business.util.DaoCriteria; import com.yeejoin.amos.patrol.business.util.DaoCriteria;
...@@ -22,7 +23,7 @@ import com.yeejoin.amos.patrol.dao.entity.Point; ...@@ -22,7 +23,7 @@ import com.yeejoin.amos.patrol.dao.entity.Point;
import com.yeejoin.amos.patrol.dao.entity.Route; import com.yeejoin.amos.patrol.dao.entity.Route;
import com.yeejoin.amos.patrol.dao.entity.RoutePoint; import com.yeejoin.amos.patrol.dao.entity.RoutePoint;
public interface IRouteService { public interface IRouteService extends IService<Route> {
/** /**
* 添加巡检路线 * 添加巡检路线
......
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