Commit 084e4e59 authored by xixinzhao's avatar xixinzhao

检验结果提交bug修复

parent 07a7fe18
...@@ -67,9 +67,9 @@ import java.text.ParseException; ...@@ -67,9 +67,9 @@ import java.text.ParseException;
@Service @Service
public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationNoticeDto,JgInstallationNotice,JgInstallationNoticeMapper> implements IJgInstallationNoticeService { public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationNoticeDto,JgInstallationNotice,JgInstallationNoticeMapper> implements IJgInstallationNoticeService {
public static final String SUBMIT_TYPE_FLOW = "1"; private static final String SUBMIT_TYPE_FLOW = "1";
public static final String PROCESS_DEFINITION_KEY = "installationNotification"; private static final String PROCESS_DEFINITION_KEY = "installationNotification";
public static final String TABLE_PAGE_ID = "1734141426742095873"; private static final String TABLE_PAGE_ID = "1734141426742095873";
//西安行政区划code //西安行政区划code
......
...@@ -3,6 +3,7 @@ package com.yeejoin.amos.boot.module.jyjc.biz.service.impl; ...@@ -3,6 +3,7 @@ package com.yeejoin.amos.boot.module.jyjc.biz.service.impl;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Sequence; import com.baomidou.mybatisplus.core.toolkit.Sequence;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
...@@ -30,6 +31,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -30,6 +31,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.Resource; import org.springframework.core.io.Resource;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.core.foundation.context.RequestContext; import org.typroject.tyboot.core.foundation.context.RequestContext;
...@@ -48,6 +50,9 @@ import java.util.stream.Collectors; ...@@ -48,6 +50,9 @@ import java.util.stream.Collectors;
@Service @Service
public class JyjcInspectionResultServiceImpl extends BaseService<JyjcInspectionResultModel, JyjcInspectionResult, JyjcInspectionResultMapper> implements IJyjcInspectionResultService { public class JyjcInspectionResultServiceImpl extends BaseService<JyjcInspectionResultModel, JyjcInspectionResult, JyjcInspectionResultMapper> implements IJyjcInspectionResultService {
private static final String JYJC_SUBMIT_FILE_PREFIX = "JYJC_";
private static final String JYJC_SUBMIT_KEY = "inspectResult";
@Autowired @Autowired
private IJyjcInspectionResultAttachmentService iJyjcInspectionResultAttachmentService; private IJyjcInspectionResultAttachmentService iJyjcInspectionResultAttachmentService;
...@@ -106,32 +111,61 @@ public class JyjcInspectionResultServiceImpl extends BaseService<JyjcInspectionR ...@@ -106,32 +111,61 @@ public class JyjcInspectionResultServiceImpl extends BaseService<JyjcInspectionR
} }
@Transactional(rollbackFor = Exception.class)
public JyjcInspectionResultModel updateJyjcInspectionResult(Map<String, Map<String, Object>> tableModel) { public JyjcInspectionResultModel updateJyjcInspectionResult(Map<String, Map<String, Object>> tableModel) {
Map<String, Object> map = tableModel.get("inspectResult"); Map<String, Object> map = tableModel.get(JYJC_SUBMIT_KEY);
JyjcInspectionResultModel model = BeanUtil.mapToBean(map, JyjcInspectionResultModel.class, true); JyjcInspectionResultModel model = BeanUtil.mapToBean(map, JyjcInspectionResultModel.class, true);
// 更新结果主表
updateWithModel(model); updateWithModel(model);
// 更新附件表
List<JyjcInspectionResultAttachment> attachmentList = new ArrayList<>(); List<JyjcInspectionResultAttachment> attachmentList = new ArrayList<>();
LambdaQueryWrapper<JyjcInspectionResultAttachment> fileWrapper = new LambdaQueryWrapper<>();
Map<String, Object> fileMap = new HashMap<>();
map.forEach((k, v) -> { map.forEach((k, v) -> {
if (k.contains("JYJC_") && !ObjectUtils.isEmpty(map.get(k))) { if (k.contains(JYJC_SUBMIT_FILE_PREFIX) && !ObjectUtils.isEmpty(map.get(k))) {
JyjcInspectionResultAttachment attachment = new JyjcInspectionResultAttachment(); fileWrapper.eq(JyjcInspectionResultAttachment::getAttachmentType, k);
attachment.setResultSeq(model.getSequenceNbr()); fileWrapper.eq(JyjcInspectionResultAttachment::getResultSeq, model.getSequenceNbr());
attachment.setAttachmentUrl(JSON.toJSONString(map.get(k))); fileMap.put(k, map.get(k));
attachment.setAttachmentType(k); }
attachmentList.add(attachment); });
List<JyjcInspectionResultAttachment> fileList = attachmentService.list(fileWrapper);
fileMap.forEach((k, v) -> {
JyjcInspectionResultAttachment attachment = new JyjcInspectionResultAttachment();
attachment.setResultSeq(model.getSequenceNbr());
attachment.setAttachmentUrl(JSON.toJSONString(map.get(k)));
attachment.setAttachmentType(k);
// 新增时需要判断之前有就更新
if (!CollectionUtils.isEmpty(fileList)) {
List<JyjcInspectionResultAttachment> collect = fileList.stream().filter(obj -> k.equals(obj.getAttachmentType())).collect(Collectors.toList());
if (!CollectionUtils.isEmpty(collect)) {
JyjcInspectionResultAttachment jyjcInspectionResultAttachment = collect.get(0);
attachment.setSequenceNbr(jyjcInspectionResultAttachment.getSequenceNbr());
}
} }
attachmentList.add(attachment);
}); });
if (!CollectionUtils.isEmpty(attachmentList)) { if (!CollectionUtils.isEmpty(attachmentList)) {
attachmentService.saveBatch(attachmentList); attachmentService.saveOrUpdateBatch(attachmentList);
} }
if (!CollectionUtils.isEmpty(model.getResultParamModelMap())) { // 更新参数表
if (!CollectionUtils.isEmpty(model.getResultParamModelMap())){
LambdaQueryWrapper<JyjcInspectionResultParam> paramWrapper = new LambdaQueryWrapper<>();
paramWrapper.eq(JyjcInspectionResultParam::getResultSeq, model.getSequenceNbr());
List<JyjcInspectionResultParam> params = resultParamService.list(paramWrapper);
JyjcInspectionResultParam resultParam = new JyjcInspectionResultParam(); JyjcInspectionResultParam resultParam = new JyjcInspectionResultParam();
resultParam.setResultSeq(model.getSequenceNbr()); resultParam.setResultSeq(model.getSequenceNbr());
resultParam.setParamJson(JSON.toJSONString(model.getResultParamModelMap())); resultParam.setParamJson(JSON.toJSONString(model.getResultParamModelMap()));
resultParamService.save(resultParam); if (!CollectionUtils.isEmpty(params)) {
JyjcInspectionResultParam jyjcInspectionResultParam = params.get(0);
resultParam.setSequenceNbr(jyjcInspectionResultParam.getSequenceNbr());
}
resultParamService.saveOrUpdate(resultParam);
} }
//插入操作历史记录 //插入操作历史记录
InspectionDetectionInfo info = new InspectionDetectionInfo(); InspectionDetectionInfo info = new InspectionDetectionInfo();
QueryWrapper<InspectionDetectionInfo> wrapper = new QueryWrapper<>(); QueryWrapper<InspectionDetectionInfo> wrapper = new QueryWrapper<>();
...@@ -209,7 +243,7 @@ public class JyjcInspectionResultServiceImpl extends BaseService<JyjcInspectionR ...@@ -209,7 +243,7 @@ public class JyjcInspectionResultServiceImpl extends BaseService<JyjcInspectionR
} }
} }
Map<String, Object> resultMap = new HashMap<>(); Map<String, Object> resultMap = new HashMap<>();
resultMap.put("inspectResult", map); resultMap.put(JYJC_SUBMIT_KEY, map);
return resultMap; return resultMap;
} }
......
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