Commit 1e5c3162 authored by tangwei's avatar tangwei

新增接口

parent af878b99
......@@ -133,6 +133,19 @@ public class PointController extends AbstractBaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "新*查询巡检点列表", notes = "新*查询巡检点列表")
@GetMapping(value = "/routeListNew", produces = "application/json;charset=UTF-8")
public CommonResponse queryPointListByRouteIdNew(
@ApiParam(value = "线路ID") @RequestParam(value = "routeId") Long routeId) {
Page<Map<String, Object>> pag =new PageImpl<Map<String, Object>>(iPointService.queryPointListByRouteId(routeId));
return CommonResponseUtil.success();
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "新增巡查对象", notes = "新增巡查对象")
......
......@@ -9,10 +9,12 @@ import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import com.yeejoin.amos.patrol.business.feign.JcsFeignClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.expression.spel.ast.NullLiteral;
import org.springframework.scheduling.annotation.Async;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.DeleteMapping;
......@@ -49,6 +51,7 @@ import com.yeejoin.amos.patrol.feign.RemoteSecurityService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
@RestController
@RequestMapping(value = "/api/route")
......@@ -64,6 +67,156 @@ public class RouteController extends AbstractBaseController {
private AsyncTask asyncTask;
@Autowired
private RemoteSecurityService remoteSecurityService;
@Autowired
private JcsFeignClient jcsFeignClient;
/**
*
* 新增接口
* **/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "查询巡检路线信息", notes = "查询巡检路线信息")
@PostMapping(value = "/listNew", produces = "application/json;charset=UTF-8")
public CommonResponse listRouteNew(
@ApiParam(value = "查询条件", required = false) @RequestBody(required = false) RoutePageParam queryRequests,
@ApiParam(value = "分页参数", required = true, defaultValue = "pageNumber=0&pageSize=10") CommonPageable commonPageable) {
try {
ReginParams reginParams = getSelectedOrgInfo();
//获取所在公司code
String bizOrgCode=reginParams.getPersonIdentity().getCompanyBizOrgCode();
queryRequests.setBizOrgCode(bizOrgCode);
Page<HashMap<String, Object>> routeList = routeService.getRouteInfo(null,null,null,queryRequests);
return CommonResponseUtil.success(routeList);
} catch (Exception e) {
log.error(e.getMessage(), e);
return CommonResponseUtil.failure("查询巡检路线信息失败");
}
}
/**
* 修改保存巡检路线
* @return IDs
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "新*保存巡检路线", notes = "新*保存巡检路线")
@PutMapping(value = "/saveUpdateNew", produces = "application/json;charset=UTF-8")
public CommonResponse saveRouteNew(@ApiParam(value = "巡检路线", required = true) @RequestBody Route route) {
try {
ReginParams reginParams = getSelectedOrgInfo();
route.setBizOrgCode(reginParams.getPersonIdentity().getBizOrgCode());
route.setBizOrgName(reginParams.getPersonIdentity().getCompanyName());
if(route.getDeptId()!=null){
//查询jcs
ResponseModel<Object> companyInfo = jcsFeignClient.getCompanyInfo(route.getDeptId());
Object obj = companyInfo.getResult();
String bizOrgName = ((Map<String, Object>) obj).get("bizOrgName").toString();
route.setDeptName(bizOrgName);
}
if(route.getBoss()!=null){
//查询jcs
ResponseModel<Object> companyInfo = jcsFeignClient.getCompanyInfo(route.getBoss());
Object obj = companyInfo.getResult();
String bizOrgName = ((Map<String, Object>) obj).get("bizOrgName").toString();
String amosOrgId = ((Map<String, Object>) obj).get("amosOrgId").toString();
route.setBoss(amosOrgId);
route.setBossName(bizOrgName);
}
route.setCreatorId(getUserId());
return CommonResponseUtil.success(routeService.addRouteNew(route));
} catch (Exception e) {
log.error(e.getMessage(), e);
return CommonResponseUtil.failure("巡检路线新增失败");
}
}
/**
* 根据ID查询巡检路线信息
*
* @param point
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "查询巡检路线信息", notes = "查询巡检路线信息")
@GetMapping(value = "/queryRouteByIdNew", produces = "application/json;charset=UTF-8")
public CommonResponse queryRouteByIdNew(
@ApiParam(value = "巡检路线id", required = true) @RequestParam(name = "id") long id) {
try {
Route route = routeService.queryRouteById(id);
return CommonResponseUtil.success(route);
} catch (Exception e) {
log.error(e.getMessage(), e);
return CommonResponseUtil.failure("查询巡检路线失败");
}
}
/**
* 删除巡检路线
*
* @param routeIds
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "删除巡检路线", notes = "删除巡检路线")
@DeleteMapping(value = "/deleteRouteNew", produces = "application/json;charset=UTF-8")
public CommonResponse deleteRouteNew(@ApiParam(value = "巡检路线ID", required = false) @RequestParam List<Long> routeIds) {
try {
//校验1:线路上有点时返回删除失败
Map<Long, String> idNameMap = new HashMap<>();
for (long id : routeIds) {
int routePointCount = routeService.countRoutePoint(id);
if (routePointCount > 0) {
Route route = routeService.queryRouteById(id);
idNameMap.put(id, route.getName());
}
}
if (idNameMap.size() > 0) {
return CommonResponseUtil.failure(idNameMap, "删除路线失败:路线上已设置巡检点");
}
//校验2:计划在使用,删除失败
idNameMap.clear();
for (long id : routeIds) {
int routePointCount = routeService.countRoutePoint(id);
if (routePointCount > 0) {
List<Plan> planList = routeService.queryPlanByRouteId(id);
if(planList != null && planList.size() >0){
idNameMap.put(id, planList.get(0).getName());
}
}
}
if (idNameMap.size() > 0) {
return CommonResponseUtil.failure(idNameMap, "删除路线失败:计划在使用");
}
routeService.delRouteById(routeIds.toArray(new Long[0]));
return CommonResponseUtil.success();
} catch (Exception e) {
log.error(e.getMessage(), e);
return CommonResponseUtil.failure("删除巡检路线失败");
}
}
/**
* 增加巡检路线
*
......
......@@ -34,6 +34,13 @@ public interface IRoutePointDao extends BaseDao<RoutePoint, Long> {
@Query(value = "select * from p_route_point WHERE route_id = ?1 and point_id in (?2)", nativeQuery = true)
List<RoutePoint> queryRoutePoint(Long routeId, Long[] pointIds);
@Modifying
@Transactional
@Query(value = "select * from p_route_point WHERE route_id = ?1 ", nativeQuery = true)
List<RoutePoint> queryRoutePointList(Long routeId);
@Modifying
@Query(value = "select point_id from p_route_point WHERE route_id = ?1", nativeQuery = true)
List<Long> findAllByRouteId(Long routeId);
......
......@@ -64,5 +64,6 @@ public interface JcsFeignClient {
@GetMapping(value = "/org-usr/getCompanyInfo")
ResponseModel<Object> getCompanyInfo(@RequestParam(value = "companyId") String companyId);
}
......@@ -2,6 +2,8 @@ package com.yeejoin.amos.patrol.business.param;
import com.yeejoin.amos.patrol.core.common.request.CommonPageable;
import javax.persistence.Column;
public class RoutePageParam extends CommonPageable{
/**
......@@ -27,7 +29,7 @@ public class RoutePageParam extends CommonPageable{
/**
* 责任部门
*/
private String deptName;
// private String deptName;
private Long deptId;
......@@ -50,7 +52,42 @@ public class RoutePageParam extends CommonPageable{
* 人员编号
*/
private String userId;
private String bossName;
//所属单位code
private String bizOrgCode;
//所属单位名称
private String bizOrgName;
//责任部门名称
private String deptName;
public String getBossName() {
return bossName;
}
public void setBossName(String bossName) {
this.bossName = bossName;
}
public String getBizOrgCode() {
return bizOrgCode;
}
public void setBizOrgCode(String bizOrgCode) {
this.bizOrgCode = bizOrgCode;
}
public String getBizOrgName() {
return bizOrgName;
}
public void setBizOrgName(String bizOrgName) {
this.bizOrgName = bizOrgName;
}
public Long getId() {
return id;
}
......
......@@ -138,6 +138,13 @@ public class RouteServiceImpl implements IRouteService {
}
@Override
public Route addRouteNew(Route route) {
return iRouteDao.saveAndFlush(route);
}
@Override
@Transactional
public void delRouteById(Long[] ids) {
//0.删除路线
......
......@@ -29,7 +29,9 @@ public interface IRouteService {
* @param route
*/
Route addRoute(Route route);
Route addRouteNew(Route route);
/**
* 删除路线
* @param routeIds
......
......@@ -89,6 +89,8 @@
<if test="name!=null">AND r.`name` LIKE CONCAT('%', #{name}, '%')</if>
<if test="remark!=null">AND r.remark LIKE CONCAT('%', #{remark}, '%')</if>
<if test="orgCode!=null">AND r.org_Code = #{orgCode}</if>
<if test="bizOrgCode!=null">AND r.biz_org_code = #{bizOrgCode}</if>
<!-- <if test="deptId!=null">AND r.dept_id = #{deptId}</if> -->
<choose>
<when test="deptId > 0 " > AND r.dept_id = #{deptId}</when>
......@@ -104,8 +106,8 @@
r.boss,
r.tel,
r.remark,
r.dept_id,
r.user_id
r.dept_name,
r.boss_name
FROM
`p_route` r
WHERE
......@@ -113,6 +115,7 @@
<if test="name!=null">AND r.`name` LIKE CONCAT('%', #{name}, '%')</if>
<if test="remark!=null">AND r.remark LIKE CONCAT('%', #{remark}, '%')</if>
<if test="orgCode!=null">AND r.org_Code = #{orgCode}</if>
<if test="bizOrgCode!=null">AND r.biz_org_code = #{bizOrgCode}</if>
<choose>
<when test="deptId > 0 " > AND r.dept_id = #{deptId}</when>
<when test="deptId == -1 " > AND r.dept_id in(0,-1)</when>
......
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