Browse Source

Merge remote-tracking branch 'origin/master'

zhongwei
tyty 1 year ago
parent
commit
764819b75d
  1. 14
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmInfoServiceImpl.java
  2. 15
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/feign/ProjectClient.java
  3. 7
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/services/impl/ObjectServiceImpl.java

14
hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmInfoServiceImpl.java

@ -599,6 +599,17 @@ public class EmInfoServiceImpl extends BaseServiceImpl<EmInfoMapper, EmInfoEntit
.flatMap(path -> Arrays.stream(path.split("/"))).distinct().collect(Collectors.toList()); .flatMap(path -> Arrays.stream(path.split("/"))).distinct().collect(Collectors.toList());
emCodes.addAll(childrenEmCode); emCodes.addAll(childrenEmCode);
} }
return this.getEmInfoTree(deptId,parentCode,emCodes);
}
/**
* 获取设备树巡检对象选择专用
* @param deptId 机构ID
* @param parentCode 父设备编号
* @param emCodes 巡检项目设备编号集合
* @return 获取设备树
*/
private List<JSONObject> getEmInfoTree(Long deptId, String parentCode,List<String> emCodes) {
EmInfoEntity emInfo = this.getOne(Wrappers.<EmInfoEntity>lambdaQuery().eq(EmInfoEntity::getNumber, parentCode)); EmInfoEntity emInfo = this.getOne(Wrappers.<EmInfoEntity>lambdaQuery().eq(EmInfoEntity::getNumber, parentCode));
// 获取parentCode下的子设备集合 // 获取parentCode下的子设备集合
LambdaQueryWrapper<EmInfoEntity> queryWrapper = Wrappers.<EmInfoEntity>lambdaQuery() LambdaQueryWrapper<EmInfoEntity> queryWrapper = Wrappers.<EmInfoEntity>lambdaQuery()
@ -608,13 +619,12 @@ public class EmInfoServiceImpl extends BaseServiceImpl<EmInfoMapper, EmInfoEntit
List<JSONObject> result = emInfoList.stream().map(emInfoEntity -> { List<JSONObject> result = emInfoList.stream().map(emInfoEntity -> {
JSONObject object = JSONObject.parseObject(JSON.toJSONString(emInfoEntity)); JSONObject object = JSONObject.parseObject(JSON.toJSONString(emInfoEntity));
object.put("disabled", emCodes.contains(emInfoEntity.getNumber()) ? false : true); object.put("disabled", emCodes.contains(emInfoEntity.getNumber()) ? false : true);
object.put("children",this.getEmInfoTree(deptId,emInfoEntity.getNumber(),emCodes));
return object; return object;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
return result; return result;
} }
/** /**
* 设备信息缓存(ctptinstalledCapacity监测点位) * 设备信息缓存(ctptinstalledCapacity监测点位)
*/ */

15
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/feign/ProjectClient.java

@ -6,8 +6,10 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.hzinfo.inspect.obj.dto.ContentDTO; import com.hnac.hzinfo.inspect.obj.dto.ContentDTO;
import com.hnac.hzinfo.inspect.obj.dto.ProjectDTO; import com.hnac.hzinfo.inspect.obj.dto.ProjectDTO;
import com.hnac.hzinfo.inspect.obj.entity.ProjectContentEntity;
import com.hnac.hzinfo.inspect.obj.entity.ProjectEntity; import com.hnac.hzinfo.inspect.obj.entity.ProjectEntity;
import com.hnac.hzinfo.inspect.obj.request.ProjectContentRequest; import com.hnac.hzinfo.inspect.obj.request.ProjectContentRequest;
import com.hnac.hzinfo.inspect.obj.services.ProjectContentService;
import com.hnac.hzinfo.inspect.obj.services.ProjectService; import com.hnac.hzinfo.inspect.obj.services.ProjectService;
import com.hnac.hzinfo.inspect.obj.vo.ProjectVO; import com.hnac.hzinfo.inspect.obj.vo.ProjectVO;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
@ -16,11 +18,14 @@ import lombok.extern.slf4j.Slf4j;
import org.springblade.core.boot.ctrl.BladeController; import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.mp.support.Query; import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.Func;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.validation.Valid; import javax.validation.Valid;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
/** /**
* @ClassName ProjectClient * @ClassName ProjectClient
@ -35,6 +40,7 @@ import java.util.List;
public class ProjectClient extends BladeController implements IProjectClient { public class ProjectClient extends BladeController implements IProjectClient {
private final ProjectService projectService; private final ProjectService projectService;
private final ProjectContentService projectContentService;
@Override @Override
@PostMapping(ADD_PROJECT_AND_CONTENT) @PostMapping(ADD_PROJECT_AND_CONTENT)
@ -55,8 +61,13 @@ public class ProjectClient extends BladeController implements IProjectClient {
@GetMapping(GET_EM_CODES_BY_DEPT_ID) @GetMapping(GET_EM_CODES_BY_DEPT_ID)
public R<List<String>> getEmCodesByDeptId(@RequestParam Long deptId) { public R<List<String>> getEmCodesByDeptId(@RequestParam Long deptId) {
QueryWrapper<ProjectEntity> queryWrapper = Wrappers.<ProjectEntity>query().eq("create_dept", deptId); QueryWrapper<ProjectEntity> queryWrapper = Wrappers.<ProjectEntity>query().eq("create_dept", deptId);
queryWrapper.select("distinct em_code emCode");
queryWrapper.ne("em_code","").isNotNull("em_code"); queryWrapper.ne("em_code","").isNotNull("em_code");
return R.data(projectService.listObjs(queryWrapper, String::valueOf)); List<ProjectEntity> projects = projectService.list(queryWrapper);
if(CollectionUtil.isNotEmpty(projects)) {
QueryWrapper<ProjectContentEntity> in = Wrappers.<ProjectContentEntity>query().select("distinct project_id").in("project_id", projects.stream().map(ProjectEntity::getId).collect(Collectors.toList()));
List<Long> projectIds = projectContentService.listObjs(in, Func::toLong);
return R.data(projects.stream().filter(project -> projectIds.contains(project.getId())).map(ProjectEntity::getEmCode).collect(Collectors.toList()));
}
return R.data(projects.stream().map(ProjectEntity::getEmCode).collect(Collectors.toList()));
} }
} }

7
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/services/impl/ObjectServiceImpl.java

@ -276,10 +276,15 @@ public class ObjectServiceImpl extends BaseServiceImpl<InspectObjectMapper, Obje
project.setEmCode(emCode); project.setEmCode(emCode);
project.setStatus(ObjectConstants.ProjectEnableEnum.YES.getEnableType()); project.setStatus(ObjectConstants.ProjectEnableEnum.YES.getEnableType());
ProjectEntity one = projectService.getOne(project); ProjectEntity one = projectService.getOne(project);
// 剔除掉未绑定巡检内容的巡检项目
LambdaQueryWrapper<ProjectContentEntity> projectContentWrapper = Wrappers.<ProjectContentEntity>lambdaQuery().eq(ProjectContentEntity::getProjectId, one.getId());
if(CollectionUtil.isEmpty(projectContentService.list(projectContentWrapper))) {
return null;
}
return TemplateProjectEntity.builder().templateId(template.getId()).projectId(one.getId()).build(); return TemplateProjectEntity.builder().templateId(template.getId()).projectId(one.getId()).build();
}; };
List<TemplateProjectEntity> templateProjectList = Stream.iterate(0,n -> n + 1).limit(emCodeList.size()) List<TemplateProjectEntity> templateProjectList = Stream.iterate(0,n -> n + 1).limit(emCodeList.size())
.flatMap(index -> emInfoClient.getChildrenByEmCode(emCodeList.get(index)).getData().stream()).map(getTemplateProjectByEmCode).collect(Collectors.toList()); .flatMap(index -> emInfoClient.getChildrenByEmCode(emCodeList.get(index)).getData().stream()).map(getTemplateProjectByEmCode).filter(ObjectUtil::isNotEmpty).collect(Collectors.toList());
templateProjectService.saveBatch(templateProjectList); templateProjectService.saveBatch(templateProjectList);
} }
} }

Loading…
Cancel
Save