|
@@ -2,19 +2,102 @@ package com.rongwei.zhsw.system.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.rongwe.zhsw.system.domain.SwInspectionTaskPointDo;
|
|
|
+import com.rongwei.rwcommon.base.R;
|
|
|
import com.rongwei.zhsw.system.dao.SwInspectionTaskPointDao;
|
|
|
import com.rongwei.zhsw.system.service.SwInspectionTaskPointService;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
-* @author libai
|
|
|
-* @description 针对表【sw_inspection_task_point(巡检任务-检查点)】的数据库操作Service实现
|
|
|
-* @createDate 2025-04-18 09:02:00
|
|
|
-*/
|
|
|
+ * @author libai
|
|
|
+ * @description 针对表【sw_inspection_task_point(巡检任务-检查点)】的数据库操作Service实现
|
|
|
+ * @createDate 2025-04-18 09:02:00
|
|
|
+ */
|
|
|
@Service
|
|
|
public class SwInspectionTaskPointServiceImpl extends ServiceImpl<SwInspectionTaskPointDao, SwInspectionTaskPointDo>
|
|
|
- implements SwInspectionTaskPointService {
|
|
|
+ implements SwInspectionTaskPointService {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public R updateInspectionTask(Map<String, Object> taskPointInfo) {
|
|
|
+ if (taskPointInfo == null || !taskPointInfo.containsKey("id")) {
|
|
|
+ return R.error("参数错误:缺少必要的id字段");
|
|
|
+ }
|
|
|
+
|
|
|
+ String id = (String) taskPointInfo.get("id");
|
|
|
+
|
|
|
+ // 根据id查询检查点信息
|
|
|
+ SwInspectionTaskPointDo pointDo = this.getById(id);
|
|
|
+ if (pointDo == null) {
|
|
|
+ return R.error("找不到对应的检查点记录");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 更新巡检结果
|
|
|
+ if (taskPointInfo.containsKey("status")) {
|
|
|
+ Integer status = (Integer) taskPointInfo.get("status");
|
|
|
+ pointDo.setInspectionresult(String.valueOf(status));
|
|
|
+ }
|
|
|
+
|
|
|
+ // 更新异常描述(如果有)
|
|
|
+ if (taskPointInfo.containsKey("ycription") && StringUtils.isNotBlank((String) taskPointInfo.get("ycription"))) {
|
|
|
+ pointDo.setExceptiondescription((String) taskPointInfo.get("ycription"));
|
|
|
+ }
|
|
|
+
|
|
|
+ // 处理照片
|
|
|
+ if (taskPointInfo.containsKey("photos") && taskPointInfo.get("photos") != null) {
|
|
|
+ List<String> photos = (List<String>) taskPointInfo.get("photos");
|
|
|
+ if (!photos.isEmpty()) {
|
|
|
+ String photoStr = processPhotos(photos);
|
|
|
+ pointDo.setPhotograph(photoStr);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 更新数据
|
|
|
+ this.updateById(pointDo);
|
|
|
+ return R.ok("提交成功",pointDo.getPhotograph());
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 处理照片数据,格式化为存储格式
|
|
|
+ *
|
|
|
+ * @param photos 照片URL列表
|
|
|
+ * @return 格式化后的照片字符串
|
|
|
+ */
|
|
|
+ private String processPhotos(List<String> photos) {
|
|
|
+ if (photos == null || photos.isEmpty()) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ return photos.stream()
|
|
|
+ .map(this::formatPhotoPath)
|
|
|
+ .collect(Collectors.joining("^_^"));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 格式化单个照片路径
|
|
|
+ *
|
|
|
+ * @param photoPath 照片路径
|
|
|
+ * @return 格式化后的照片信息
|
|
|
+ */
|
|
|
+ private String formatPhotoPath(String photoPath) {
|
|
|
+ if (StringUtils.isBlank(photoPath)) {
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取照片名称(最后一个斜杠后的部分)
|
|
|
+ String fileName = photoPath.substring(photoPath.lastIndexOf("/") + 1);
|
|
|
+
|
|
|
+ // 获取文件ID(文件名去掉后缀)
|
|
|
+ String fileId = fileName;
|
|
|
+ if (fileName.contains(".")) {
|
|
|
+ fileId = fileName.substring(0, fileName.lastIndexOf("."));
|
|
|
+ }
|
|
|
|
|
|
+ // 格式:fileName-;-fileId
|
|
|
+ return fileName + "-;-" + fileId;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|