Commit f04beb18 authored by tangwei's avatar tangwei

修改接口

parent 9d792553
......@@ -6,9 +6,14 @@ import javax.servlet.http.HttpServletResponse;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.patrol.business.dao.repository.IPointClassifyDao;
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.JcsFeignClient;
import com.yeejoin.amos.patrol.business.vo.PointInputItemNewVo;
import com.yeejoin.amos.patrol.dao.entity.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -56,8 +61,6 @@ import com.yeejoin.amos.patrol.core.common.response.PointResponse;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import com.yeejoin.amos.patrol.dao.entity.Point;
import com.yeejoin.amos.patrol.dao.entity.PointClassify;
import com.yeejoin.amos.patrol.feign.RemoteSecurityService;
import io.swagger.annotations.Api;
......@@ -90,6 +93,15 @@ public class PointController extends AbstractBaseController {
@Autowired
private JcsFeignClient jcsFeignClient;
@Autowired
private IPointClassifyDao iPointClassifyDao;
@Autowired
private IPointInputItemDao iPointInputItemDao;
@Autowired
private IRoutePointDao iRoutePointDao;
@Autowired
private IRoutePointItemDao iRoutePointItemDao;
/**
*
......@@ -128,6 +140,7 @@ public class PointController extends AbstractBaseController {
public CommonResponse addPointXcdx(@ApiParam(value = "新增巡查对象", required = true) @RequestBody PointInputItemNewVo pointClassify){
try {
List<RoutePoint> routePointList = iRoutePointDao.queryByPointId(pointClassify.getPointId());
AgencyUserModel user = getUserInfo();
PointClassify newPointClassify = new PointClassify();
newPointClassify.setEquipmentId(pointClassify.getEquipmentId());
......@@ -160,6 +173,29 @@ public class PointController extends AbstractBaseController {
newPointClassify.setCode(pointClassify.getCode());
iPointService.addPointClassifyByPointId(newPointClassify);
List<PointInputItemVo> customInputList = pointClassify.getEquipIputDetailData();//巡检项
for (PointInputItemVo pItemVo : customInputList) {
PointInputItem pointInputItem = new PointInputItem();
pointInputItem.setPointId(pointClassify.getPointId());
pointInputItem.setInputItemId(pItemVo.getId());
pointInputItem.setClassifyIds(Long.valueOf(newPointClassify.getId()).toString());
pointInputItem.setId(0);
pointInputItem.setOrderNo(pItemVo.getpOrderNo());
PointInputItem pointInputItemResult = iPointInputItemDao.save(pointInputItem);
//更新巡检路线
if(routePointList.size()>0){
Long classifyId=newPointClassify.getId();
for (RoutePoint routePoint :routePointList) {
RoutePointItem routePointItem = new RoutePointItem();
routePointItem.setPointClassifyId(classifyId);
routePointItem.setPointInputItemId(pointInputItemResult.getId());
routePointItem.setRoutePointId(routePoint.getId());
iRoutePointItemDao.save(routePointItem);
}
}
}
return CommonResponseUtil.success();
} catch (Exception e) {
e.printStackTrace();
......@@ -175,6 +211,7 @@ public class PointController extends AbstractBaseController {
try {
AgencyUserModel user = getUserInfo();
List<RoutePoint> routePointList = iRoutePointDao.queryByPointId(pointClassifys.get(0).getPointId());
for (PointInputItemNewVo pointClassify : pointClassifys) {
PointClassify newPointClassify = new PointClassify();
newPointClassify.setEquipmentId(pointClassify.getEquipmentId());
......@@ -193,6 +230,34 @@ public class PointController extends AbstractBaseController {
newPointClassify.setCode(pointClassify.getCode());
newPointClassify.setBuildingName(pointClassify.getBuildingName());
iPointService.addPointClassifyByPointId(newPointClassify);
List<PointInputItemVo> customInputList = pointClassify.getEquipIputDetailData();//巡检项
for (PointInputItemVo pItemVo : customInputList) {
PointInputItem pointInputItem = new PointInputItem();
pointInputItem.setPointId(pointClassify.getPointId());
pointInputItem.setInputItemId(pItemVo.getId());
pointInputItem.setClassifyIds(Long.valueOf(newPointClassify.getId()).toString());
pointInputItem.setId(0);
pointInputItem.setOrderNo(pItemVo.getpOrderNo());
PointInputItem pointInputItemResult = iPointInputItemDao.save(pointInputItem);
//更新巡检路线
if(routePointList.size()>0){
Long classifyId=newPointClassify.getId();
for (RoutePoint routePoint :routePointList) {
RoutePointItem routePointItem = new RoutePointItem();
routePointItem.setPointClassifyId(classifyId);
routePointItem.setPointInputItemId(pointInputItemResult.getId());
routePointItem.setRoutePointId(routePoint.getId());
iRoutePointItemDao.save(routePointItem);
}
}
}
}
return CommonResponseUtil.success();
......@@ -204,6 +269,43 @@ public class PointController extends AbstractBaseController {
}
//删除巡查对象
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "删除巡查对象", notes = "删除巡查对象")
@GetMapping(value = "/queryPointByIdNew", produces = "application/json;charset=UTF-8")
public CommonResponse deletPointClassify(@ApiParam(value = "巡查对象id", required = true) @RequestParam Long id) {
try {
//如果点下只有一个对象,并且点已经关联线路就不能删除
PointClassify pointClassify=iPointClassifyDao.getOne(id);
List<PointClassify> list=iPointClassifyDao.getPointClassifyByPointId(pointClassify.getPointId());
List<RoutePointItem> listp=iRoutePointItemDao.getRoutePointItemByPointId(pointClassify.getPointId());
if(list.size()==1&&listp!=null&&listp.size()>0){
return CommonResponseUtil.failure("巡查点已绑定路线,最少保留一个巡查对象!");
}
//删除对象
iPointClassifyDao.deleteById(id);
//删除检查项
iPointInputItemDao.deleteClassifyId(id);
//删除巡检路线和项的关系表
iRoutePointItemDao.delRoutePointItemByPointClassifyId(id);
return CommonResponseUtil.success();
} catch (Exception e) {
log.error(e.getMessage(), e);
return CommonResponseUtil.failure("查询巡检点失败");
}
}
/**
* 获取当前登录人,单位下建筑树
*
......@@ -471,7 +573,7 @@ public class PointController extends AbstractBaseController {
/**
* 查询巡检点信息
*
* @param point
* @param
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
......@@ -506,7 +608,7 @@ public class PointController extends AbstractBaseController {
/**
* 查询巡检点信息
*
* @param point
* @param
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
......
......@@ -21,6 +21,11 @@ public interface IRoutePointItemDao extends BaseDao<RoutePointItem, Long> {
void delRoutePointItemByItemId(List<Long> pItemIds);
@Modifying
@Transactional
@Query(value = "DELETE FROM p_route_point_item WHERE point_classify_id = ?1", nativeQuery = true)
void delRoutePointItemByPointClassifyId(Long pItemIds);
@Modifying
@Query(value = "SELECT prpi.* FROM p_route_point_item prpi LEFT JOIN p_route_point prp ON prp.id = prpi.route_point_id WHERE prp.point_id = ?1 AND prpi.point_classify_id in (?2)", nativeQuery = true)
List<RoutePointItem> getRoutePointItemByPointIdAndClassifyIds(Long pointId,List<Long> classifyIds);
......@@ -40,4 +45,12 @@ public interface IRoutePointItemDao extends BaseDao<RoutePointItem, Long> {
@Modifying
@Query(value = "SELECT * from p_route_point_item WHERE route_point_id = ?1 AND point_classify_id =?2", nativeQuery = true)
List<RoutePointItem> getRoutePointItemList(Long pointId,Long pointClassifyId);
@Modifying
@Query(value = "SELECT prpi.* FROM p_route_point_item prpi LEFT JOIN p_route_point prp ON prp.id = prpi.route_point_id WHERE prp.point_id = ?1", nativeQuery = true)
List<RoutePointItem> getRoutePointItemByPointId(Long pointId);
}
......@@ -694,6 +694,7 @@ public class PointServiceImpl implements IPointService {
BeanUtils.copyProperties(newpointParam.getPoint(), newPoint);
newPoint.setLastUpdateTime(new Date());
iPointDao.save(newPoint);
List<PointClassify> oldPointClassifyList = queryPointClassify(pointId);// 新的点分类的补集,即需要删除的分类
List<PointInputItemNewVo> newPointClassifyList = newpointParam.getInputItemVoInfo();// 新的点分类的补集,即需要删除的分类
// List<Long> oldClassIdList=oldPointClassifyList.stream().map(PointClassify::getId).distinct().collect(Collectors.toList());
......@@ -731,23 +732,7 @@ public class PointServiceImpl implements IPointService {
iRoutePointItemDao.delRoutePointItemByItemId(pItemIds);// 删除p_route_point_item中使用到该项的行
}
// 删除点的旧分类
// 删除点分类时更新p_point_inputitem里面分类id
// List<PointClassify> newPointClassifyList = newpointParam.getPointClassifyList();
// List<PointClassify> oldPointClassifyList = queryPointClassify(pointId);// 新的点分类的补集,即需要删除的分类
// newPointClassifyList.forEach(item -> {
// Iterator<PointClassify> iter2 = oldPointClassifyList.iterator();
// while (iter2.hasNext()) {
// PointClassify pClassify = iter2.next();
// if (item.getId() == pClassify.getId()) {
// iter2.remove();
// }
// }
// });
// for (PointClassify classify : oldPointClassifyList) {
// iPointClassifyDao.deleteById(classify.getId());
// }
//
// 删除点的旧图片信息
List<PointPhoto> oldPointPhotoList = queryPointPhoto(pointId);
iPointPhotoDao.deleteAll(oldPointPhotoList);
......
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