Commit c364e077 authored by xixinzhao's avatar xixinzhao

fix(jyjc): 检验结果技术参数修改

parent 2fb30a20
......@@ -39,4 +39,12 @@ public class JyjcInspectionResultParam extends BaseEntity {
@TableField("remark")
private String remark;
/**
* 备注
*/
@TableField("param_type")
private String paramType;
}
......@@ -3,6 +3,8 @@ package com.yeejoin.amos.boot.module.jyjc.biz.service.impl;
import cn.hutool.core.bean.BeanUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSONPObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Sequence;
......@@ -115,7 +117,14 @@ public class JyjcInspectionResultServiceImpl extends BaseService<JyjcInspectionR
public JyjcInspectionResultModel updateJyjcInspectionResult(Map<String, Map<String, Object>> tableModel) {
Map<String, Object> map = tableModel.get(JYJC_SUBMIT_KEY);
JyjcInspectionResultModel model = BeanUtil.mapToBean(map, JyjcInspectionResultModel.class, true);
String inspector = model.getInspector();
if (StringUtil.isNotEmpty(inspector)) {
List jsonArray = JSONArray.parseArray(inspector);
Object inspectors = jsonArray.stream().map(String::valueOf).collect(Collectors.joining(","));
model.setInspector(String.valueOf(inspectors));
}
// 更新结果主表
updateWithModel(model);
......@@ -123,46 +132,49 @@ public class JyjcInspectionResultServiceImpl extends BaseService<JyjcInspectionR
// 更新附件表
List<JyjcInspectionResultAttachment> attachmentList = new ArrayList<>();
LambdaQueryWrapper<JyjcInspectionResultAttachment> fileWrapper = new LambdaQueryWrapper<>();
Map<String, Object> fileMap = new HashMap<>();
map.forEach((k, v) -> {
if (k.contains(JYJC_SUBMIT_FILE_PREFIX) && !ObjectUtils.isEmpty(map.get(k))) {
fileWrapper.or(wrapper ->wrapper.eq(JyjcInspectionResultAttachment::getAttachmentType, k).eq(JyjcInspectionResultAttachment::getResultSeq, model.getSequenceNbr()));
fileMap.put(k, map.get(k));
}
});
fileWrapper.eq(JyjcInspectionResultAttachment::getResultSeq, model.getSequenceNbr());
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());
map.forEach((k, v) -> {
if (k.contains(JYJC_SUBMIT_FILE_PREFIX)) {
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);
}
attachmentList.add(attachment);
});
if (!CollectionUtils.isEmpty(attachmentList)) {
attachmentService.saveOrUpdateBatch(attachmentList);
}
// 更新参数表
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();
resultParam.setResultSeq(model.getSequenceNbr());
resultParam.setParamJson(JSON.toJSONString(model.getResultParamModelMap()));
if (!CollectionUtils.isEmpty(params)) {
JyjcInspectionResultParam jyjcInspectionResultParam = params.get(0);
resultParam.setSequenceNbr(jyjcInspectionResultParam.getSequenceNbr());
LambdaQueryWrapper<JyjcInspectionResultParam> paramWrapper = new LambdaQueryWrapper<>();
paramWrapper.eq(JyjcInspectionResultParam::getResultSeq, model.getSequenceNbr());
List<JyjcInspectionResultParam> params = resultParamService.list(paramWrapper);
List<JyjcInspectionResultParam> paramList = new ArrayList<>();
tableModel.forEach((k, v) -> {
if (!JYJC_SUBMIT_KEY.equals(k) && !ObjectUtils.isEmpty(tableModel.get(k))) {
List<JyjcInspectionResultParam> collect = params.stream().filter(p -> k.equals(p.getParamType())).collect(Collectors.toList());
JyjcInspectionResultParam resultParam = new JyjcInspectionResultParam();
if (!CollectionUtils.isEmpty(collect)) {
resultParam.setSequenceNbr(collect.get(0).getSequenceNbr());
}
resultParam.setResultSeq(model.getSequenceNbr());
resultParam.setParamJson(JSON.toJSONString(tableModel.get(k)));
paramList.add(resultParam);
}
resultParamService.saveOrUpdate(resultParam);
});
if (!CollectionUtils.isEmpty(paramList)){
resultParamService.saveOrUpdateBatch(paramList);
}
//插入操作历史记录
......@@ -211,6 +223,7 @@ public class JyjcInspectionResultServiceImpl extends BaseService<JyjcInspectionR
@Override
public Map<String, Object> queryDetailBySeq(Long sequenceNbr) {
Map<String, Object> map = new HashMap<>();
Map<String, Object> resultMap = new HashMap<>(9);
JyjcInspectionResultModel jyjcInspectionResultModel = this.queryBySeq(sequenceNbr);
if (!ObjectUtils.isEmpty(jyjcInspectionResultModel)) {
......@@ -231,17 +244,18 @@ public class JyjcInspectionResultServiceImpl extends BaseService<JyjcInspectionR
// 获取技术参数
List<JyjcInspectionResultParam> paramList = iJyjcInspectionResultParamService.getParamByResultSeq(sequenceNbr);
Map<String, Object> mapParam = new HashMap<>();
if (!CollectionUtils.isEmpty(paramList)) {
Map<String, Object> finalMap = map;
paramList.forEach(param -> {
if (!ObjectUtils.isEmpty(param.getParamJson())) {
mapParam.putAll(JSON.parseObject(param.getParamJson()));
JSONObject paramObj = JSON.parseObject(String.valueOf(param.getParamJson()));
paramObj.put("equList", finalMap.get("equList"));
paramObj.put("equCategory", finalMap.get("equCategory"));
resultMap.put(param.getParamType(), paramObj);
}
});
map.put("paramJson", mapParam);
}
}
Map<String, Object> resultMap = new HashMap<>();
resultMap.put(JYJC_SUBMIT_KEY, map);
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