|
|
@@ -11,14 +11,16 @@ import com.tuoheng.admin.enums.SectionEnum; |
|
|
|
import com.tuoheng.admin.enums.StructureEnum; |
|
|
|
import com.tuoheng.admin.mapper.*; |
|
|
|
import com.tuoheng.admin.query.StructureQuery; |
|
|
|
import com.tuoheng.admin.service.structure.IStructureService; |
|
|
|
import com.tuoheng.admin.utils.CurrentUserUtil; |
|
|
|
import com.tuoheng.admin.vo.StructureInfoVo; |
|
|
|
import com.tuoheng.common.core.common.BaseServiceImpl; |
|
|
|
import com.tuoheng.common.core.config.common.CommonConfig; |
|
|
|
import com.tuoheng.common.core.enums.ServiceExceptionEnum; |
|
|
|
import com.tuoheng.common.core.exception.ServiceException; |
|
|
|
import com.tuoheng.common.core.utils.*; |
|
|
|
import com.tuoheng.common.core.utils.CommonUtils; |
|
|
|
import com.tuoheng.common.core.utils.DateUtils; |
|
|
|
import com.tuoheng.common.core.utils.JsonResult; |
|
|
|
import com.tuoheng.common.core.utils.StringUtils; |
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
@@ -53,43 +55,42 @@ public class StructureServiceImpl extends BaseServiceImpl<StructureMapper, Struc |
|
|
|
@Autowired |
|
|
|
private SectionDeptMapper sectionDeptMapper; |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public JsonResult queryPage(StructureQuery query) { |
|
|
|
if(null==(query.getPage()) && null == query.getLimit()){ |
|
|
|
if (null == (query.getPage()) && null == query.getLimit()) { |
|
|
|
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); |
|
|
|
} |
|
|
|
//获取登录信息 |
|
|
|
User user = CurrentUserUtil.getUserInfo(); |
|
|
|
if(ObjectUtil.isNull(user)){ |
|
|
|
if (ObjectUtil.isNull(user)) { |
|
|
|
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); |
|
|
|
} |
|
|
|
//租户id |
|
|
|
String tenantId = user.getTenantId(); |
|
|
|
query.setTenantId(tenantId); |
|
|
|
|
|
|
|
//获取用户角色 |
|
|
|
Integer roleId = user.getRoleId(); |
|
|
|
IPage<Structure> page = new Page<>(query.getPage(),query.getLimit()); |
|
|
|
IPage<Structure> page = new Page<>(query.getPage(), query.getLimit()); |
|
|
|
IPage<StructureInfoVo> pageData = null; |
|
|
|
//如果是超级管理员,查看所有构造物 |
|
|
|
if(RoleEnum.SUPER_ADMIN.getCode() == roleId){ |
|
|
|
//query.setTenantId(tenantId); |
|
|
|
if (RoleEnum.SUPER_ADMIN.getCode() == roleId) { |
|
|
|
//数据分页 |
|
|
|
pageData = structureMapper.queryPage(page,query); |
|
|
|
pageData = structureMapper.queryPage(page, query); |
|
|
|
List<StructureInfoVo> list = pageData.getRecords().stream().map((item) -> { |
|
|
|
StructureInfoVo structureInfoVo = new StructureInfoVo(); |
|
|
|
BeanUtils.copyProperties(item, structureInfoVo); |
|
|
|
//获取构造物图片,对图片进行处理 |
|
|
|
if(StringUtils.isNotEmpty(item.getImageUrl())){ |
|
|
|
if (StringUtils.isNotEmpty(item.getImageUrl())) { |
|
|
|
String[] imageUrls = item.getImageUrl().split(","); |
|
|
|
if(StringUtils.isNotEmpty(imageUrls)){ |
|
|
|
if (StringUtils.isNotEmpty(imageUrls)) { |
|
|
|
for (int i = 0; i < imageUrls.length; i++) { |
|
|
|
if(StringUtils.isNotEmpty(imageUrls[i])){ |
|
|
|
imageUrls[i]= CommonConfig.imageURL+imageUrls[i]; |
|
|
|
if (StringUtils.isNotEmpty(imageUrls[i])) { |
|
|
|
imageUrls[i] = CommonConfig.imageURL + imageUrls[i]; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
structureInfoVo.setImageUrl(StringUtils.join(imageUrls,",")); |
|
|
|
structureInfoVo.setImageUrl(StringUtils.join(imageUrls, ",")); |
|
|
|
} |
|
|
|
// if (StringUtils.isNotEmpty(item.getImageUrl())) { |
|
|
|
// String imageUrl = getMultipleUrl(item.getImageUrl()); |
|
|
@@ -101,22 +102,22 @@ public class StructureServiceImpl extends BaseServiceImpl<StructureMapper, Struc |
|
|
|
|
|
|
|
} |
|
|
|
//如果是部门管理员或普通用户,查询本部门及子部门包含的路段及路段对应的构造物 |
|
|
|
if(RoleEnum.ADMIN.getCode() == roleId || RoleEnum.ORDINARY_USER.getCode() == roleId){ |
|
|
|
if (RoleEnum.ADMIN.getCode() == roleId || RoleEnum.ORDINARY_USER.getCode() == roleId) { |
|
|
|
String deptId = user.getDeptId(); |
|
|
|
if (StringUtils.isEmpty(deptId)){ |
|
|
|
return JsonResult.error(StructureEnum.DEPT_IS_NOT_EXIST.getCode(),StructureEnum.DEPT_IS_NOT_EXIST.getMsg()); |
|
|
|
if (StringUtils.isEmpty(deptId)) { |
|
|
|
return JsonResult.error(StructureEnum.DEPT_IS_NOT_EXIST.getCode(), StructureEnum.DEPT_IS_NOT_EXIST.getMsg()); |
|
|
|
} |
|
|
|
//获取当前登录用户对应的部门及子部门 |
|
|
|
List<String> deptList = deptMapper.selectAllChildListById(deptId); |
|
|
|
if(StringUtils.isEmpty(deptList) && deptList.size()<=0){ |
|
|
|
return JsonResult.error(SectionEnum.DEPT_ID_IS_NULL.getCode(),SectionEnum.DEPT_ID_IS_NULL.getMsg()); |
|
|
|
if (StringUtils.isEmpty(deptList) && deptList.size() <= 0) { |
|
|
|
return JsonResult.error(SectionEnum.DEPT_ID_IS_NULL.getCode(), SectionEnum.DEPT_ID_IS_NULL.getMsg()); |
|
|
|
} |
|
|
|
//根据部门列表查对应的部门路段数据列表 |
|
|
|
List<SectionDept> sectionDeptList = sectionDeptMapper.selectList(Wrappers.<SectionDept>lambdaQuery() |
|
|
|
.eq(SectionDept::getTenantId, tenantId) |
|
|
|
.in(SectionDept::getDeptId, deptList)); |
|
|
|
if(StringUtils.isEmpty(sectionDeptList) && sectionDeptList.size()<=0){ |
|
|
|
return JsonResult.error(SectionEnum.DEPT_SECTION_IS_NOT_EXIST.getCode(),SectionEnum.DEPT_SECTION_IS_NOT_EXIST.getMsg()); |
|
|
|
if (StringUtils.isEmpty(sectionDeptList) && sectionDeptList.size() <= 0) { |
|
|
|
return JsonResult.error(SectionEnum.DEPT_SECTION_IS_NOT_EXIST.getCode(), SectionEnum.DEPT_SECTION_IS_NOT_EXIST.getMsg()); |
|
|
|
} |
|
|
|
//查询对应的路段列表 |
|
|
|
List<String> sectionIdList = sectionDeptList.stream().map(t -> t.getSectionId()).distinct().collect(Collectors.toList()); |
|
|
@@ -127,20 +128,20 @@ public class StructureServiceImpl extends BaseServiceImpl<StructureMapper, Struc |
|
|
|
//根据路段id查询对应的构造物列表 |
|
|
|
for (String sectionId : sectionIdList) { |
|
|
|
query.setSectionId(sectionId); |
|
|
|
pageData = structureMapper.queryPageBySectionId(page,query); |
|
|
|
pageData = structureMapper.queryPageBySectionId(page, query); |
|
|
|
List<StructureInfoVo> records = pageData.getRecords(); |
|
|
|
for (StructureInfoVo record : records) { |
|
|
|
//获取构造物图片,对图片进行处理 |
|
|
|
if(StringUtils.isNotEmpty(record.getImageUrl())){ |
|
|
|
if (StringUtils.isNotEmpty(record.getImageUrl())) { |
|
|
|
String[] imageUrls = record.getImageUrl().split(","); |
|
|
|
if(StringUtils.isNotEmpty(imageUrls)){ |
|
|
|
if (StringUtils.isNotEmpty(imageUrls)) { |
|
|
|
for (int i = 0; i < imageUrls.length; i++) { |
|
|
|
if(StringUtils.isNotEmpty(imageUrls[i])){ |
|
|
|
imageUrls[i]= CommonConfig.imageURL+imageUrls[i]; |
|
|
|
if (StringUtils.isNotEmpty(imageUrls[i])) { |
|
|
|
imageUrls[i] = CommonConfig.imageURL + imageUrls[i]; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
record.setImageUrl(StringUtils.join(imageUrls,",")); |
|
|
|
record.setImageUrl(StringUtils.join(imageUrls, ",")); |
|
|
|
} |
|
|
|
list.add(record); |
|
|
|
} |
|
|
@@ -165,23 +166,23 @@ public class StructureServiceImpl extends BaseServiceImpl<StructureMapper, Struc |
|
|
|
public JsonResult editInfo(Structure entity) { |
|
|
|
//获取登录信息 |
|
|
|
String userId = CurrentUserUtil.getUserId(); |
|
|
|
if(StringUtils.isEmpty(userId)){ |
|
|
|
JsonResult.error(StructureEnum.USER_ID_IS_NULL.getCode(),StructureEnum.USER_ID_IS_NULL.getMsg()); |
|
|
|
if (StringUtils.isEmpty(userId)) { |
|
|
|
JsonResult.error(StructureEnum.USER_ID_IS_NULL.getCode(), StructureEnum.USER_ID_IS_NULL.getMsg()); |
|
|
|
} |
|
|
|
|
|
|
|
//校验 |
|
|
|
if(StringUtils.isEmpty(entity.getRoadId()) && StringUtils.isEmpty(entity.getSectionId())){ |
|
|
|
if (StringUtils.isEmpty(entity.getRoadId()) && StringUtils.isEmpty(entity.getSectionId())) { |
|
|
|
return JsonResult.error("公路和路段为空"); |
|
|
|
} |
|
|
|
//获取租户id |
|
|
|
String tenantId = CurrentUserUtil.getTenantId(); |
|
|
|
//查询用户信息 |
|
|
|
if(StringUtils.isEmpty(entity.getId())){ |
|
|
|
if (StringUtils.isEmpty(entity.getId())) { |
|
|
|
//新增 |
|
|
|
entity.setCreateTime(DateUtils.now()); |
|
|
|
entity.setCreateUser(userId); |
|
|
|
entity.setTenantId(tenantId); |
|
|
|
}else { |
|
|
|
} else { |
|
|
|
//更新 |
|
|
|
entity.setUpdateTime(DateUtils.now()); |
|
|
|
entity.setUpdateUser(userId); |
|
|
@@ -194,50 +195,51 @@ public class StructureServiceImpl extends BaseServiceImpl<StructureMapper, Struc |
|
|
|
|
|
|
|
/** |
|
|
|
* 当前登录人对应的公路所属的构造物 |
|
|
|
* |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public JsonResult getSectionInfo() { |
|
|
|
//获取登录信息 |
|
|
|
String tenantId = CurrentUserUtil.getTenantId(); |
|
|
|
if(StringUtils.isEmpty(tenantId)){ |
|
|
|
JsonResult.error(StructureEnum.TENANT_ID_IS_NULL.getCode(),StructureEnum.TENANT_ID_IS_NULL.getMsg()); |
|
|
|
if (StringUtils.isEmpty(tenantId)) { |
|
|
|
JsonResult.error(StructureEnum.TENANT_ID_IS_NULL.getCode(), StructureEnum.TENANT_ID_IS_NULL.getMsg()); |
|
|
|
} |
|
|
|
List<Structure> structures = structureMapper.selectList(Wrappers.<Structure>lambdaQuery().eq(Structure::getMark, 1) |
|
|
|
.eq(Structure::getTenantId, tenantId)); |
|
|
|
if(null == structures){ |
|
|
|
if (null == structures) { |
|
|
|
return JsonResult.error(); |
|
|
|
} |
|
|
|
List<StructureInfoVo> list = new ArrayList<>(); |
|
|
|
for (Structure structure : structures) { |
|
|
|
StructureInfoVo structureInfoVo = new StructureInfoVo(); |
|
|
|
BeanUtils.copyProperties(structure,structureInfoVo); |
|
|
|
BeanUtils.copyProperties(structure, structureInfoVo); |
|
|
|
//设置图片 |
|
|
|
if(StringUtils.isNotEmpty(structure.getImageUrl())){ |
|
|
|
if (StringUtils.isNotEmpty(structure.getImageUrl())) { |
|
|
|
String[] imageUrls = structure.getImageUrl().split(","); |
|
|
|
if(StringUtils.isNotEmpty(imageUrls)){ |
|
|
|
if (StringUtils.isNotEmpty(imageUrls)) { |
|
|
|
for (int i = 0; i < imageUrls.length; i++) { |
|
|
|
if(StringUtils.isNotEmpty(imageUrls[i])){ |
|
|
|
imageUrls[i]=CommonConfig.imageURL+imageUrls[i]; |
|
|
|
if (StringUtils.isNotEmpty(imageUrls[i])) { |
|
|
|
imageUrls[i] = CommonConfig.imageURL + imageUrls[i]; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
structureInfoVo.setImageUrl(StringUtils.join(imageUrls,",")); |
|
|
|
structureInfoVo.setImageUrl(StringUtils.join(imageUrls, ",")); |
|
|
|
} |
|
|
|
//根据公路id获取公路code |
|
|
|
if(StringUtils.isEmpty(structure.getRoadId())){ |
|
|
|
if (StringUtils.isEmpty(structure.getRoadId())) { |
|
|
|
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); |
|
|
|
} |
|
|
|
RoadInformation roadInformation = roadInformationMapper.selectById(structure.getRoadId()); |
|
|
|
if(ObjectUtil.isNotNull(roadInformation)){ |
|
|
|
if (ObjectUtil.isNotNull(roadInformation)) { |
|
|
|
structureInfoVo.setCode(roadInformation.getCode()); |
|
|
|
} |
|
|
|
//根据路段id获取路段范围 |
|
|
|
if(StringUtils.isEmpty(structure.getSectionId())){ |
|
|
|
if (StringUtils.isEmpty(structure.getSectionId())) { |
|
|
|
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); |
|
|
|
} |
|
|
|
Section section = sectionMapper.selectById(structure.getSectionId()); |
|
|
|
if(ObjectUtil.isNotNull(section)){ |
|
|
|
if (ObjectUtil.isNotNull(section)) { |
|
|
|
structureInfoVo.setSectionRange(section.getSectionRange()); |
|
|
|
} |
|
|
|
list.add(structureInfoVo); |