return structureService.deleteByIds(ids); | return structureService.deleteByIds(ids); | ||||
} | } | ||||
/** | |||||
* 根据经纬度获取构造物信息 | |||||
* @return | |||||
*/ | |||||
@GetMapping("/getSectionInfo") | |||||
public JsonResult getSectionInfo(){ | |||||
return structureService.getSectionInfo(); | |||||
} | |||||
} | } |
JsonResult getListInfo(StructureQuery query); | JsonResult getListInfo(StructureQuery query); | ||||
JsonResult editInfo(Structure entity); | JsonResult editInfo(Structure entity); | ||||
JsonResult getSectionInfo(); | |||||
} | } |
package com.tuoheng.admin.service.impl; | package com.tuoheng.admin.service.impl; | ||||
import cn.hutool.core.util.ObjectUtil; | |||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | ||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; | |||||
import com.baomidou.mybatisplus.core.metadata.IPage; | import com.baomidou.mybatisplus.core.metadata.IPage; | ||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | import com.baomidou.mybatisplus.core.toolkit.Wrappers; | ||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | ||||
import com.tuoheng.admin.config.CommonConfig; | import com.tuoheng.admin.config.CommonConfig; | ||||
import com.tuoheng.admin.entity.RoadInformation; | |||||
import com.tuoheng.admin.entity.Section; | |||||
import com.tuoheng.admin.entity.Structure; | import com.tuoheng.admin.entity.Structure; | ||||
import com.tuoheng.admin.entity.User; | |||||
import com.tuoheng.admin.mapper.RoadInformationMapper; | import com.tuoheng.admin.mapper.RoadInformationMapper; | ||||
import com.tuoheng.admin.mapper.SectionMapper; | import com.tuoheng.admin.mapper.SectionMapper; | ||||
import com.tuoheng.admin.mapper.StructureMapper; | import com.tuoheng.admin.mapper.StructureMapper; | ||||
import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
import java.util.ArrayList; | |||||
import java.util.Arrays; | import java.util.Arrays; | ||||
import java.util.List; | import java.util.List; | ||||
import java.util.stream.Collectors; | import java.util.stream.Collectors; | ||||
List<StructureInfoVo> list = pageData.getRecords().stream().map((item) -> { | List<StructureInfoVo> list = pageData.getRecords().stream().map((item) -> { | ||||
StructureInfoVo structureInfoVo = new StructureInfoVo(); | StructureInfoVo structureInfoVo = new StructureInfoVo(); | ||||
BeanUtils.copyProperties(item, structureInfoVo); | BeanUtils.copyProperties(item, structureInfoVo); | ||||
//获取构造物土图片,对图片进行处理 | |||||
//获取构造物图片,对图片进行处理 | |||||
if(StringUtils.isNotEmpty(item.getImageUrl())){ | if(StringUtils.isNotEmpty(item.getImageUrl())){ | ||||
String[] imageUrls = item.getImageUrl().split(","); | String[] imageUrls = item.getImageUrl().split(","); | ||||
if(StringUtils.isNotEmpty(imageUrls)){ | if(StringUtils.isNotEmpty(imageUrls)){ | ||||
return JsonResult.success(); | return JsonResult.success(); | ||||
} | } | ||||
@Override | |||||
public JsonResult getSectionInfo() { | |||||
//获取登录信息 | |||||
// String username = SecurityUserUtils.username(); | |||||
// User user = userMapper.selectOne(Wrappers.<User>lambdaQuery() | |||||
// .eq(User::getUsername, username).eq(User::getMark, 1)); | |||||
// if(null==user){ | |||||
// return JsonResult.error(); | |||||
// } | |||||
// String tenantId = user.getTenantId(); | |||||
String tenantId = "0"; | |||||
List<Structure> structures = structureMapper.selectList(Wrappers.<Structure>lambdaQuery().eq(Structure::getMark, 1) | |||||
.eq(Structure::getTenantId, tenantId)); | |||||
if(null == structures){ | |||||
return JsonResult.error(); | |||||
} | |||||
List<StructureInfoVo> list = new ArrayList<>(); | |||||
for (Structure structure : structures) { | |||||
StructureInfoVo structureInfoVo = new StructureInfoVo(); | |||||
BeanUtils.copyProperties(structure,structureInfoVo); | |||||
//设置图片 | |||||
if(StringUtils.isNotEmpty(structure.getImageUrl())){ | |||||
String[] imageUrls = structure.getImageUrl().split(","); | |||||
if(StringUtils.isNotEmpty(imageUrls)){ | |||||
for (int i = 0; i < imageUrls.length; i++) { | |||||
if(StringUtils.isNotEmpty(imageUrls[i])){ | |||||
imageUrls[i]=CommonConfig.imageURL+imageUrls[i]; | |||||
} | |||||
} | |||||
} | |||||
structureInfoVo.setImageUrl(StringUtils.join(imageUrls,",")); | |||||
} | |||||
//根据公路id获取公路code | |||||
if(StringUtils.isEmpty(structure.getRoadId())){ | |||||
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | |||||
} | |||||
RoadInformation roadInformation = roadInformationMapper.selectById(structure.getRoadId()); | |||||
if(ObjectUtil.isNotNull(roadInformation)){ | |||||
structureInfoVo.setCode(roadInformation.getCode()); | |||||
} | |||||
//根据路段id获取路段范围 | |||||
if(StringUtils.isEmpty(structure.getSectionId())){ | |||||
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | |||||
} | |||||
Section section = sectionMapper.selectById(structure.getSectionId()); | |||||
if(ObjectUtil.isNotNull(section)){ | |||||
structureInfoVo.setSectionRange(section.getSectionRange()); | |||||
} | |||||
list.add(structureInfoVo); | |||||
} | |||||
return JsonResult.success(list); | |||||
} | |||||
/** | /** | ||||
* 多个url进行转换,用,号隔开 | * 多个url进行转换,用,号隔开 |
} | } | ||||
/** | |||||
*查看问题及结果 | |||||
* @param id | |||||
* @return | |||||
*/ | |||||
@GetMapping("/seeQuestion/{id}") | |||||
public JsonResult seeQuestion(@PathVariable("id") String id){ | |||||
return iInspectionFileService.seeQuestion(id); | |||||
} | |||||
} | } |
package com.tuoheng.miniprogram.controller; | |||||
import com.tuoheng.common.core.utils.JsonResult; | |||||
import com.tuoheng.miniprogram.entity.InspectionFileHandle; | |||||
import com.tuoheng.miniprogram.entity.dto.UploadResultDto; | |||||
import com.tuoheng.miniprogram.service.IInspectionFileHandleService; | |||||
import org.springframework.beans.factory.annotation.Autowired; | |||||
import org.springframework.web.bind.annotation.*; | |||||
/** | |||||
* 巡检问题处理结果 前端控制器 | |||||
* | |||||
* @Author ChengWang | |||||
* @Date 2022/11/25 | |||||
*/ | |||||
@RestController | |||||
@RequestMapping("/inspectionFileHandle") | |||||
public class InspectionFileHandleController { | |||||
@Autowired | |||||
private IInspectionFileHandleService iInspectionFileHandleService; | |||||
/** | |||||
* 上传处理结果 | |||||
* @param dto | |||||
* @return | |||||
*/ | |||||
@PostMapping("/uploadResult") | |||||
public JsonResult uploadResult(@RequestBody UploadResultDto dto){ | |||||
return iInspectionFileHandleService.uploadResult(dto); | |||||
} | |||||
} |
package com.tuoheng.miniprogram.dao; | |||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |||||
import com.tuoheng.miniprogram.entity.InspectionFileHandle; | |||||
/** | |||||
* @Author ChengWang | |||||
* @Date 2022/11/25 | |||||
*/ | |||||
public interface InspectionFileHandleMapper extends BaseMapper<InspectionFileHandle> { | |||||
} |
import com.baomidou.mybatisplus.core.mapper.BaseMapper; | import com.baomidou.mybatisplus.core.mapper.BaseMapper; | ||||
import com.tuoheng.miniprogram.entity.InspectionFile; | import com.tuoheng.miniprogram.entity.InspectionFile; | ||||
import com.tuoheng.miniprogram.vo.SeeQuestionVo; | |||||
import org.apache.ibatis.annotations.Param; | |||||
/** | /** | ||||
* @Author ChengWang | * @Author ChengWang | ||||
public interface InspectionFileMapper extends BaseMapper<InspectionFile> { | public interface InspectionFileMapper extends BaseMapper<InspectionFile> { | ||||
SeeQuestionVo selectByInspectionId(@Param("id") String id); | |||||
} | } |
package com.tuoheng.miniprogram.entity.dto; | |||||
import lombok.Data; | |||||
/** | |||||
* @Author ChengWang | |||||
* @Date 2022/11/25 | |||||
*/ | |||||
@Data | |||||
public class UploadResultDto { | |||||
/** | |||||
* 问题id | |||||
*/ | |||||
private String id; | |||||
/** | |||||
* 租户id | |||||
*/ | |||||
private String tenantId; | |||||
/** | |||||
* 处理结果的图片,多张用,隔开 | |||||
*/ | |||||
private String handlerImage; | |||||
/** | |||||
* 处理结果 | |||||
*/ | |||||
private String handlerResult; | |||||
} |
package com.tuoheng.miniprogram.service; | |||||
import com.tuoheng.common.core.utils.JsonResult; | |||||
import com.tuoheng.miniprogram.entity.dto.UploadResultDto; | |||||
/** | |||||
* @Author ChengWang | |||||
* @Date 2022/11/25 | |||||
*/ | |||||
public interface IInspectionFileHandleService { | |||||
JsonResult uploadResult(UploadResultDto dto); | |||||
} |
JsonResult confirm(InspectionFile entity); | JsonResult confirm(InspectionFile entity); | ||||
JsonResult ignore(InspectionFile entity); | JsonResult ignore(InspectionFile entity); | ||||
JsonResult seeQuestion(String id); | |||||
} | } |
package com.tuoheng.miniprogram.service.impl; | |||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |||||
import com.tuoheng.common.core.utils.DateUtils; | |||||
import com.tuoheng.common.core.utils.JsonResult; | |||||
import com.tuoheng.common.core.utils.StringUtils; | |||||
import com.tuoheng.miniprogram.dao.InspectionFileHandleMapper; | |||||
import com.tuoheng.miniprogram.dao.InspectionFileMapper; | |||||
import com.tuoheng.miniprogram.entity.InspectionFileHandle; | |||||
import com.tuoheng.miniprogram.entity.dto.UploadResultDto; | |||||
import com.tuoheng.miniprogram.service.IInspectionFileHandleService; | |||||
import lombok.extern.slf4j.Slf4j; | |||||
import org.springframework.beans.factory.annotation.Autowired; | |||||
import org.springframework.stereotype.Service; | |||||
/** | |||||
* @Author ChengWang | |||||
* @Date 2022/11/25 | |||||
*/ | |||||
@Service | |||||
@Slf4j | |||||
public class InspectionFileHandleServiceImpl implements IInspectionFileHandleService { | |||||
@Autowired | |||||
private InspectionFileMapper inspectionFileMapper; | |||||
@Autowired | |||||
private InspectionFileHandleMapper inspectionFileHandleMapper; | |||||
/** | |||||
* 上传结果 | |||||
* @param dto | |||||
* @return | |||||
*/ | |||||
@Override | |||||
public JsonResult uploadResult(UploadResultDto dto) { | |||||
if(StringUtils.isEmpty(dto.getId())) { | |||||
return JsonResult.error("问题id为空"); | |||||
} | |||||
if(StringUtils.isEmpty(dto.getTenantId())){ | |||||
return JsonResult.error("租户id不存在"); | |||||
} | |||||
InspectionFileHandle inspectionFileHandle = new InspectionFileHandle(); | |||||
inspectionFileHandle.setInspectionFileId(dto.getId()); | |||||
inspectionFileHandle.setTenantId(dto.getTenantId()); | |||||
inspectionFileHandle.setHandlerImage(dto.getHandlerImage()); | |||||
inspectionFileHandle.setHandlerResult(dto.getHandlerResult()); | |||||
inspectionFileHandle.setHandlerUser("cw"); | |||||
inspectionFileHandle.setCreateUser("cw"); | |||||
inspectionFileHandle.setCreateTime(DateUtils.now()); | |||||
inspectionFileHandle.setMark(1); | |||||
int count = inspectionFileHandleMapper.insert(inspectionFileHandle); | |||||
if(count<=0){ | |||||
return JsonResult.error(); | |||||
} | |||||
return JsonResult.success(); | |||||
} | |||||
} |
import com.tuoheng.common.core.config.common.CommonConfig; | import com.tuoheng.common.core.config.common.CommonConfig; | ||||
import com.tuoheng.common.core.enums.ServiceExceptionEnum; | import com.tuoheng.common.core.enums.ServiceExceptionEnum; | ||||
import com.tuoheng.common.core.exception.ServiceException; | import com.tuoheng.common.core.exception.ServiceException; | ||||
import com.tuoheng.common.core.utils.CommonUtils; | |||||
import com.tuoheng.common.core.utils.JsonResult; | import com.tuoheng.common.core.utils.JsonResult; | ||||
import com.tuoheng.common.core.utils.SecurityUserUtils; | import com.tuoheng.common.core.utils.SecurityUserUtils; | ||||
import com.tuoheng.common.core.utils.StringUtils; | import com.tuoheng.common.core.utils.StringUtils; | ||||
import com.tuoheng.miniprogram.entity.query.InspectionFileQuery; | import com.tuoheng.miniprogram.entity.query.InspectionFileQuery; | ||||
import com.tuoheng.miniprogram.service.IInspectionFileService; | import com.tuoheng.miniprogram.service.IInspectionFileService; | ||||
import com.tuoheng.miniprogram.vo.InspectionFileInfoVo; | import com.tuoheng.miniprogram.vo.InspectionFileInfoVo; | ||||
import com.tuoheng.miniprogram.vo.SeeQuestionVo; | |||||
import lombok.extern.slf4j.Slf4j; | import lombok.extern.slf4j.Slf4j; | ||||
import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
import java.util.Arrays; | |||||
import java.util.List; | |||||
import java.util.stream.Collectors; | |||||
/** | /** | ||||
* @Author ChengWang | * @Author ChengWang | ||||
return JsonResult.success("忽略问题成功"); | return JsonResult.success("忽略问题成功"); | ||||
} | } | ||||
/** | |||||
* 查看 | |||||
* @param id | |||||
* @return | |||||
*/ | |||||
@Override | |||||
public JsonResult seeQuestion(String id) { | |||||
//校验 | |||||
if(StringUtils.isEmpty(id)){ | |||||
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | |||||
} | |||||
SeeQuestionVo vo = inspectionFileMapper.selectByInspectionId(id); | |||||
if(ObjectUtil.isNull(vo)){ | |||||
return JsonResult.error("未查询出对应的问题及处理结果"); | |||||
} | |||||
//对属性处理 | |||||
if(StringUtils.isNotEmpty(vo.getFileOriginal())){ | |||||
vo.setFileOriginal(CommonConfig.imageURL+vo.getFileOriginal()); | |||||
} | |||||
if(StringUtils.isNotEmpty(vo.getFileImage())){ | |||||
vo.setFileImage(CommonConfig.imageURL+vo.getFileImage()); | |||||
} | |||||
if(StringUtils.isNotEmpty(vo.getFileThumbnail())){ | |||||
vo.setFileThumbnail(CommonConfig.imageURL+vo.getFileThumbnail()); | |||||
} | |||||
//对多张处理结果图进行处理用,隔开 | |||||
if(StringUtils.isNotEmpty(vo.getHandlerImage())){ | |||||
String getHandlerImage = getMultipleUrl(vo.getHandlerImage()); | |||||
vo.setHandlerImage(getHandlerImage); | |||||
} | |||||
return JsonResult.success(vo); | |||||
} | |||||
/** | |||||
* 多个url进行转换,用,号隔开 | |||||
* | |||||
* @param url | |||||
* @return | |||||
*/ | |||||
private String getMultipleUrl(String url) { | |||||
List<String> collect = Arrays.asList(url.split(",")).stream().map( | |||||
s -> CommonUtils.getImageURL(s)).collect(Collectors.toList()); | |||||
//返回 | |||||
return org.apache.commons.lang3.StringUtils.join(collect, ","); | |||||
} | |||||
private IPage<InspectionFileInfoVo> getInspectionFileInfoVoIPage(Inspection inspection, IPage<InspectionFile> result) { | private IPage<InspectionFileInfoVo> getInspectionFileInfoVoIPage(Inspection inspection, IPage<InspectionFile> result) { | ||||
//数据转换 | //数据转换 | ||||
return result.convert(t -> { | return result.convert(t -> { |
package com.tuoheng.miniprogram.vo; | |||||
import lombok.Data; | |||||
/** | |||||
* @Author ChengWang | |||||
* @Date 2022/11/28 | |||||
*/ | |||||
@Data | |||||
public class SeeQuestionVo { | |||||
/** | |||||
* 问题类型id | |||||
*/ | |||||
private String questionId; | |||||
/** | |||||
* 问题名称 | |||||
*/ | |||||
private String questionName; | |||||
/** | |||||
*缩略图(问题图片) | |||||
*/ | |||||
private String fileThumbnail; | |||||
/** | |||||
*原图 | |||||
*/ | |||||
private String fileOriginal; | |||||
/** | |||||
* 标记图 | |||||
*/ | |||||
private String fileImage; | |||||
/** | |||||
* 处理结果照片 | |||||
*/ | |||||
private String handlerImage; | |||||
/** | |||||
* 处理结果 | |||||
*/ | |||||
private String handlerResult; | |||||
/** | |||||
* 处理时间 | |||||
*/ | |||||
private String handlerTime; | |||||
/** | |||||
* 处理人员 | |||||
*/ | |||||
private String handlerUser; | |||||
} |
<?xml version="1.0" encoding="UTF-8" ?> | |||||
<!DOCTYPE mapper | |||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | |||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |||||
<mapper namespace="com.tuoheng.miniprogram.dao.InspectionFileHandleMapper"> | |||||
</mapper> |
<mapper namespace="com.tuoheng.miniprogram.dao.InspectionFileMapper"> | <mapper namespace="com.tuoheng.miniprogram.dao.InspectionFileMapper"> | ||||
<select id="selectByInspectionId" resultType="com.tuoheng.miniprogram.vo.SeeQuestionVo"> | |||||
select | |||||
tf.question_id as questionId, | |||||
tf.question_name as questionName, | |||||
tf.file_thumbnail as fileThumbnail, | |||||
tf.file_original as fileOriginal, | |||||
tf.file_image as fileImage, | |||||
tfh.handler_image as handlerImage, | |||||
tfh.handler_result as handlerResult, | |||||
tfh.handler_time as handlerTime, | |||||
tfh.handler_user as handlerUser | |||||
from | |||||
th_inspection_file as tf | |||||
left join th_inspection_file_handle AS tfh on tf.id = tfh.inspection_file_id | |||||
where tf.mark =1 and tfh.mark=1 | |||||
and tf.id=#{id} | |||||
</select> | |||||
</mapper> | </mapper> |