Commit 967bffd0 authored by chenzhao's avatar chenzhao

增加接口 修改代码

parent e600893c
......@@ -9,6 +9,7 @@ import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.patrol.business.feign.JcsFeignClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -124,18 +125,13 @@ public class RouteController extends AbstractBaseController {
route.setDeptName(bizOrgName);
}
if(route.getBoss()!=null){
//查询jcs
ResponseModel<Object> companyInfo = jcsFeignClient.getCompanyInfo(route.getBoss());
Object obj = companyInfo.getResult();
FeignClientResult result = jcsFeignClient.selectById(route.getBoss());
Object obj = result.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) {
......@@ -690,4 +686,23 @@ public class RouteController extends AbstractBaseController {
}
}
/**
* 修改保存巡检路线
* @return IDs
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "巡检路线关联巡检点", notes = "巡检路线关联巡检点")
@PutMapping(value = "/relevancyPoint", produces = "application/json;charset=UTF-8")
public CommonResponse relevancyPoint(@ApiParam(value = "巡检路线", required = true) @RequestBody Route route) {
try {
return CommonResponseUtil.success(routeService.relevancyPoint(route));
} catch (Exception e) {
log.error(e.getMessage(), e);
return CommonResponseUtil.failure("巡检路线更新失败");
}
}
}
......@@ -267,6 +267,72 @@ public class RouteServiceImpl implements IRouteService {
}
@Override
@Transactional
public Route relevancyPoint(Route route) {
List<RoutePoint> routePoints = route.getRoutePointList();
Long routeId = route.getId();
String orgCode = route.getOrgCode();
String CreatorId = route.getCreatorId();
// 以下删除顺序不可更改
// 删除旧的项
routePointItemMapper.delRoutePointItemByRouteId(routeId);
// 删除旧的点
iRoutePointDao.delRoutePointByRouteId(routeId);
// 保存新的点
if (routePoints != null && !routePoints.isEmpty()) {
List<RoutePoint> points = new ArrayList<>();
List<RoutePointItem> items = new ArrayList<>();
List<Long> pointIds = new ArrayList<>();
routePoints.forEach(rp -> {
rp.setOrgCode(orgCode);
rp.setRouteId(routeId);
rp.setCreatorId(CreatorId);
points.add(rp);
pointIds.add(rp.getPointId());
});
List<RoutePoint> savedPoints = iRoutePointDao.saveAll(points);
List<Map<String, Object>> pointRefItem = pointMapper.getPointRefItem(pointIds);
if (!savedPoints.isEmpty()) {
savedPoints.forEach(rp -> {
String excludeItems = rp.getExcludeItems();
Set<Long> excludeItemIdSet = new HashSet<>();
if (excludeItems != null && !excludeItems.isEmpty()) {
String[] itemIds = excludeItems.split(",");
for (String itemId : itemIds) {
try {
excludeItemIdSet.add(Long.valueOf(itemId));
} catch (Exception e) {
}
}
}
final int[] orderNum = {1};
pointRefItem.forEach(ref -> {
Long pointId = rp.getPointId();
if(pointId.equals(ref.get("pointId"))){
if(!excludeItemIdSet.contains(ref.get("itemId"))) {
RoutePointItem item = new RoutePointItem();
item.setPointInputItemId((Long) ref.get("id"));
item.setRoutePointId(rp.getId());
item.setPointClassifyId(Long.valueOf(ref.get("classifyId").toString()));
item.setOrderNo(orderNum[0]++);
item.setPointId(pointId);
item.setIsDelete(false);
items.add(item);
}
}
});
});
if(!items.isEmpty()) {
iRoutePointItemDao.saveAll(items);
}
}
}
return route;
}
@Override
@Transactional(rollbackFor = {YeeException.class, Exception.class})
public void migrateRoutePoint(Long sourceRouteId, Long[] pointIds, Long targetRouteId) {
List<RoutePoint> routePointList = iRoutePointDao.queryRoutePoint(sourceRouteId, pointIds);
......
......@@ -45,6 +45,7 @@ public interface IRouteService {
Route updateRoute(Route route);
Route updateRouteNew(Route route);
Route relevancyPoint(Route route);
/**
* 迁移路线巡检点
*
......
......@@ -258,7 +258,7 @@
and a.catalog_id in <foreach collection="catalogIds" item="catalogId" index="index" open="(" separator="," close=")" >#{catalogId}</foreach>
</if>
<if test="bizOrgCode!=null and bizOrgCode!=''">
and a.biz_org_codeLIKE CONCAT (#{bizOrgCode} ,'%')
and a.biz_org_code LIKE CONCAT (#{bizOrgCode} ,'%')
</if>
<choose>
<when test="level == '-0' ">and a.level is null</when>
......@@ -293,7 +293,7 @@
and a.catalog_id in <foreach collection="catalogIds" item="catalogId" index="index" open="(" separator="," close=")" >#{catalogId}</foreach>
</if>
<if test="bizOrgCode!=null and bizOrgCode!=''">
and a.biz_org_codeLIKE CONCAT (#{bizOrgCode} ,'%')
and a.biz_org_code LIKE CONCAT (#{bizOrgCode},'%')
</if>
<choose>
<when test="level == '-0' ">and a.level is null</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