update
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package org.jeecg.modules.database.controller;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
@@ -9,17 +10,25 @@ import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.aspect.annotation.AutoLog;
|
||||
import org.jeecg.common.system.base.controller.JeecgController;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
import org.jeecg.common.system.util.JwtUtil;
|
||||
import org.jeecg.common.util.ReflectHelper;
|
||||
import org.jeecg.common.system.vo.LoginUser;
|
||||
import org.jeecg.common.util.*;
|
||||
import org.jeecg.modules.database.constant.ExperimentStatus;
|
||||
import org.jeecg.modules.database.dto.ExperimentExportDTO;
|
||||
import org.jeecg.modules.database.dto.ExperimentExportDetailDTO;
|
||||
import org.jeecg.modules.database.entity.*;
|
||||
import org.jeecg.modules.database.service.*;
|
||||
import org.jeecg.modules.system.entity.SysUser;
|
||||
import org.jeecg.modules.system.service.ISysUserService;
|
||||
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
||||
import org.jeecgframework.poi.excel.entity.ExportParams;
|
||||
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
@@ -270,15 +279,15 @@ public class ExperimentController extends JeecgController<Experiment, IExperimen
|
||||
|
||||
List<ExperimentAnnealProcess> experimentAnnealProcess = experimentAnnealProcessService.getByExperimentId(old.getId());
|
||||
if (CollUtil.isNotEmpty(experimentAnnealProcess)) {
|
||||
experimentAnnealProcess.forEach(v -> experimentAnnealProcessService.copy(v.getId(),copied.getId()));
|
||||
experimentAnnealProcess.forEach(v -> experimentAnnealProcessService.copy(v.getId(), copied.getId()));
|
||||
}
|
||||
List<ExperimentRadiationProcess> experimentRadiationProcess = experimentRadiationProcessService.getByExperimentId(old.getId());
|
||||
if (CollUtil.isNotEmpty(experimentRadiationProcess)) {
|
||||
experimentRadiationProcess.forEach(v -> experimentRadiationProcessService.copy(v.getId(),copied.getId()));
|
||||
experimentRadiationProcess.forEach(v -> experimentRadiationProcessService.copy(v.getId(), copied.getId()));
|
||||
}
|
||||
List<ExperimentTestProcess> experimentTestProcess = experimentTestProcessService.getByExperimentId(old.getId());
|
||||
if (CollUtil.isNotEmpty(experimentTestProcess)) {
|
||||
experimentTestProcess.forEach(v -> experimentTestProcessService.copy(v.getId(),copied.getId()));
|
||||
experimentTestProcess.forEach(v -> experimentTestProcessService.copy(v.getId(), copied.getId()));
|
||||
}
|
||||
return Result.OK("复制成功!");
|
||||
}
|
||||
@@ -373,7 +382,82 @@ public class ExperimentController extends JeecgController<Experiment, IExperimen
|
||||
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, Experiment experiment) {
|
||||
return super.exportXls(request, experiment, Experiment.class, "试验管理");
|
||||
//return super.exportXls(request, experiment, Experiment.class, "试验管理");
|
||||
String title = "试验管理";
|
||||
QueryWrapper<Experiment> queryWrapper = QueryGenerator.initQueryWrapper(experiment, request.getParameterMap());
|
||||
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
|
||||
// 过滤选中数据
|
||||
String selections = request.getParameter("selections");
|
||||
if (oConvertUtils.isNotEmpty(selections)) {
|
||||
List<String> selectionList = Arrays.asList(selections.split(","));
|
||||
queryWrapper.in("id", selectionList);
|
||||
}
|
||||
// Step.2 获取导出数据
|
||||
queryWrapper.orderBy(true, true, "index_no");
|
||||
List<Experiment> exportList = experimentService.list(queryWrapper);
|
||||
for (Experiment ex : exportList) {
|
||||
experimentService.fetchExperimentDetail(ex);
|
||||
}
|
||||
List<ExperimentExportDTO> resultList = new ArrayList<>();
|
||||
for (Experiment ex : exportList) {
|
||||
ExperimentExportDTO dto = new ExperimentExportDTO();
|
||||
dto.setId(ex.getId());
|
||||
dto.setIndexNo(ex.getIndexNo());
|
||||
dto.setExperimentNo(ex.getExperimentNo());
|
||||
dto.setName(ex.getName());
|
||||
dto.setClientName(ex.getClientName());
|
||||
dto.setType(ex.getType());
|
||||
dto.setStartDate(ex.getStartDate());
|
||||
dto.setEndDate(ex.getEndDate());
|
||||
String equipmentStr = ex.getDeviationEquipmentList().stream().map(v -> v.getEquipmentNo()).filter(
|
||||
v -> StringUtils.isNotBlank(v))
|
||||
.collect(Collectors.joining("\n"));
|
||||
dto.setEquipment(equipmentStr);
|
||||
dto.setSupervisorName(ex.getSupervisorName());
|
||||
dto.setReportCount(ex.getExperimentReportList().size() + "");
|
||||
List<ExperimentRating> experimentRatingList = ex.getExperimentRatingList();
|
||||
String rateStr = experimentRatingList.stream().map(v -> v.getRateUserName() + ":" + v.getTotalScore()).collect(
|
||||
Collectors.joining("\n"));
|
||||
dto.setRateUserAndScore(rateStr);
|
||||
List<ExperimentRadiationProcess> experimentRadiationProcess = experimentRadiationProcessService.getByExperimentId(ex.getId());
|
||||
List<ExperimentExportDetailDTO> detailList = new ArrayList<>();
|
||||
//List<ExperimentIrradiationBoard> irradiationBoardList = ex.getIrradiationBoardList();
|
||||
if (CollUtil.isNotEmpty(experimentRadiationProcess)) {
|
||||
experimentRadiationProcess.forEach(v -> {
|
||||
List<ExperimentSampleInfo> sampleInfoList = v.getSampleInfoList();
|
||||
if (CollUtil.isNotEmpty(sampleInfoList)) {
|
||||
sampleInfoList.forEach(sample -> {
|
||||
ExperimentExportDetailDTO detail = new ExperimentExportDetailDTO();
|
||||
detail.setRadiateType(v.getRadiationSource());
|
||||
detail.setSampleModel(sample.getSampleModel());
|
||||
detail.setSampleType(sample.getSampleType());
|
||||
detail.setMeasurementRate("");
|
||||
detail.setTotalMeasurementRate("");
|
||||
detail.setSourceArea("");
|
||||
detailList.add(detail);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
dto.setDetailList(detailList);
|
||||
resultList.add(dto);
|
||||
|
||||
}
|
||||
// Step.3 AutoPoi 导出Excel
|
||||
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
|
||||
//此处设置的filename无效 ,前端会重更新设置一下
|
||||
mv.addObject(NormalExcelConstants.FILE_NAME, title);
|
||||
mv.addObject(NormalExcelConstants.CLASS, ExperimentExportDTO.class);
|
||||
//update-begin--Author:liusq Date:20210126 for:图片导出报错,ImageBasePath未设置--------------------
|
||||
ExportParams exportParams = new ExportParams(title + "报表", "导出人:" + Optional.ofNullable(sysUser).map(v -> v.getRealname())
|
||||
.orElse("") + ",导出日期:" + DateUtils.formatDate(new Date()), title);
|
||||
//exportParams.setImageBasePath(jeecgBaseConfig.getPath().getUpload());
|
||||
//update-end--Author:liusq Date:20210126 for:图片导出报错,ImageBasePath未设置----------------------
|
||||
mv.addObject(NormalExcelConstants.PARAMS, exportParams);
|
||||
mv.addObject(NormalExcelConstants.DATA_LIST, resultList);
|
||||
return mv;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -61,7 +61,7 @@ public class ExperimentRatingController extends JeecgController<ExperimentRating
|
||||
QueryWrapper<ExperimentRating> queryWrapper = QueryGenerator.initQueryWrapper(experimentRating, req.getParameterMap());
|
||||
Page<ExperimentRating> page = new Page<ExperimentRating>(pageNo, pageSize);
|
||||
IPage<ExperimentRating> pageList = experimentRatingService.page(page, queryWrapper);
|
||||
pageList.getRecords().forEach(v -> experimentRatingService.fetchExperimentDetail(v));
|
||||
pageList.getRecords().forEach(v -> experimentService.fetchExperimentRateDetail(v));
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
@@ -188,7 +188,7 @@ public class ExperimentRatingController extends JeecgController<ExperimentRating
|
||||
if (experimentRating == null) {
|
||||
return Result.error("未找到对应数据");
|
||||
}
|
||||
experimentRatingService.fetchExperimentDetail(experimentRating);
|
||||
experimentService.fetchExperimentRateDetail(experimentRating);
|
||||
return Result.OK(experimentRating);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@ package org.jeecg.modules.database.dto;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.jeecg.modules.database.entity.*;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import org.jeecgframework.poi.excel.annotation.ExcelCollection;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
@@ -25,27 +25,30 @@ public class ExperimentExportDTO implements Serializable {
|
||||
* 主键
|
||||
*/
|
||||
private String id;
|
||||
@Excel(name = "序号", width = 15)
|
||||
@Excel(name = "序号", width = 15, needMerge = true)
|
||||
private Integer indexNo;
|
||||
@Excel(name = "试验编号", width = 15)
|
||||
@Excel(name = "试验编号", width = 15, needMerge = true)
|
||||
private String experimentNo;
|
||||
@Excel(name = "名称", width = 15)
|
||||
@Excel(name = "名称", width = 15, needMerge = true)
|
||||
private String name;
|
||||
@Excel(name = "委托方名称", width = 15)
|
||||
@Excel(name = "委托方名称", width = 15, needMerge = true)
|
||||
private String clientName;
|
||||
@Excel(name = "试验类型", width = 15, replace = {"科研试验_1", "外协试验_2"})
|
||||
@Excel(name = "试验类型", width = 15, needMerge = true, replace = {"科研试验_1", "外协试验_2"})
|
||||
private String type;
|
||||
@Excel(name = "试验开始日期", width = 15)
|
||||
@Excel(name = "试验开始日期", width = 15, needMerge = true)
|
||||
private String startDate;
|
||||
@Excel(name = "实验结束日期", width = 15)
|
||||
@Excel(name = "实验结束日期", width = 15, needMerge = true)
|
||||
private String endDate;
|
||||
@Excel(name = "使用设备", width = 15)
|
||||
@Excel(name = "使用设备", width = 15, needMerge = true)
|
||||
private String equipment;
|
||||
@Excel(name = "试验负责人", width = 15)
|
||||
@Excel(name = "试验负责人", width = 15, needMerge = true)
|
||||
private String supervisorName;
|
||||
@Excel(name = "已出报告份数", width = 15)
|
||||
@Excel(name = "已出报告份数", width = 15, needMerge = true)
|
||||
private String reportCount;
|
||||
@Excel(name = "试验员及评分", width = 15)
|
||||
@Excel(name = "试验员及评分", width = 15, needMerge = true)
|
||||
private String rateUserAndScore;
|
||||
|
||||
@ExcelCollection(name = "试验实施")
|
||||
private List<ExperimentExportDetailDTO> detailList;
|
||||
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ public class ExperimentExportDetailDTO implements Serializable {
|
||||
*
|
||||
*/
|
||||
@Excel(name = "辐射源类型", width = 15)
|
||||
private Integer radiateType;
|
||||
private String radiateType;
|
||||
@Excel(name = "样品型号", width = 15)
|
||||
private String sampleModel;
|
||||
@Excel(name = "样品类型", width = 15)
|
||||
|
||||
@@ -128,16 +128,16 @@ public class Experiment implements Serializable {
|
||||
* 试验负责人
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String supervisorName;
|
||||
private String supervisorName;
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
@Excel(name = "状态", width = 15)
|
||||
@Schema(description = "状态")
|
||||
private String status;
|
||||
private String status;
|
||||
|
||||
@TableField(exist = false)
|
||||
private List<String> statusList;
|
||||
private List<String> statusList;
|
||||
/**
|
||||
* 样品信息
|
||||
*/
|
||||
@@ -198,6 +198,10 @@ public class Experiment implements Serializable {
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private List<ExperimentUser> experimentUserList;
|
||||
@TableField(exist = false)
|
||||
private List<ExperimentReport> experimentReportList;
|
||||
@TableField(exist = false)
|
||||
private List<ExperimentRating> experimentRatingList;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String sampleType;
|
||||
|
||||
@@ -111,6 +111,8 @@ public class ExperimentRating implements Serializable {
|
||||
@TableField(exist = false)
|
||||
private String experimentNo;
|
||||
@TableField(exist = false)
|
||||
private String rateUserName;
|
||||
@TableField(exist = false)
|
||||
@Schema(description = "评分人列表")
|
||||
private List<ExperimentRatingUserDTO> rateUserList;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ package org.jeecg.modules.database.service;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.jeecg.modules.database.entity.ExperimentRating;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 试验评分
|
||||
* @Author: jeecg-boot
|
||||
@@ -11,5 +13,5 @@ import org.jeecg.modules.database.entity.ExperimentRating;
|
||||
*/
|
||||
public interface IExperimentRatingService extends IService<ExperimentRating> {
|
||||
|
||||
void fetchExperimentDetail(ExperimentRating experimentRating);
|
||||
List<ExperimentRating> getByExperimentId(String experimentId);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.jeecg.modules.database.entity.Experiment;
|
||||
import org.jeecg.modules.database.entity.ExperimentRating;
|
||||
import org.jeecg.modules.system.entity.SysUser;
|
||||
|
||||
/**
|
||||
@@ -29,4 +30,7 @@ public interface IExperimentService extends IService<Experiment> {
|
||||
Long sumLhs();
|
||||
|
||||
Long sumXhy();
|
||||
|
||||
void fetchExperimentRateDetail(ExperimentRating experimentRating);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
package org.jeecg.modules.database.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.jeecg.modules.database.entity.Experiment;
|
||||
import org.jeecg.modules.database.entity.ExperimentRating;
|
||||
import org.jeecg.modules.database.mapper.ExperimentRatingMapper;
|
||||
import org.jeecg.modules.database.service.IExperimentRatingService;
|
||||
import org.jeecg.modules.database.service.IExperimentService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 试验评分
|
||||
@@ -20,19 +18,9 @@ import java.util.Objects;
|
||||
@Service
|
||||
public class ExperimentRatingServiceImpl extends ServiceImpl<ExperimentRatingMapper, ExperimentRating> implements IExperimentRatingService {
|
||||
|
||||
@Autowired
|
||||
private IExperimentService experimentService;
|
||||
|
||||
@Override
|
||||
public void fetchExperimentDetail(ExperimentRating experimentRating) {
|
||||
if (Objects.isNull(experimentRating)) {
|
||||
return;
|
||||
}
|
||||
Experiment experiment = experimentService.getById(experimentRating.getExperimentId());
|
||||
if (Objects.isNull(experiment)) {
|
||||
return;
|
||||
}
|
||||
experimentRating.setExperimentName(experiment.getName());
|
||||
experimentRating.setExperimentNo(experiment.getExperimentNo());
|
||||
public List<ExperimentRating> getByExperimentId(String experimentId) {
|
||||
List<ExperimentRating> list = list(new LambdaQueryWrapper<ExperimentRating>().eq(ExperimentRating::getExperimentId, experimentId));
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,6 +43,10 @@ public class ExperimentServiceImpl extends ServiceImpl<ExperimentMapper, Experim
|
||||
|
||||
@Autowired
|
||||
private IExperimentSequenceService experimentSequenceService;
|
||||
@Autowired
|
||||
private IExperimentReportService experimentReportService;
|
||||
@Autowired
|
||||
private IExperimentRatingService experimentRatingService;
|
||||
|
||||
@Autowired
|
||||
private IExperimentFileService experimentFileService;
|
||||
@@ -76,35 +80,60 @@ public class ExperimentServiceImpl extends ServiceImpl<ExperimentMapper, Experim
|
||||
experimentUser.setUserName(sysUser.getRealname());
|
||||
}
|
||||
});
|
||||
experiment.setExperimentUserList(userList);
|
||||
experiment.setExperimentUser(userList.stream().map(ExperimentUser::getUserId).collect(Collectors.joining(",")));
|
||||
} else {
|
||||
experiment.setExperimentUserList(new ArrayList<>());
|
||||
}
|
||||
experiment.setExperimentUserList(userList);
|
||||
experiment.setExperimentUser(userList.stream().map(ExperimentUser::getUserId).collect(Collectors.joining(",")));
|
||||
|
||||
List<ExperimentSampleInfo> sampleInfoList = experimentSampleInfoService.getByExperimentId(experiment.getId());
|
||||
if (CollUtil.isNotEmpty(sampleInfoList)) {
|
||||
experiment.setSampleInfoList(sampleInfoList);
|
||||
} else {
|
||||
experiment.setSampleInfoList(new ArrayList<>());
|
||||
}
|
||||
|
||||
List<ExperimentDeviationCondition> deviationConditionList = experimentDeviationConditionService.getByExperimentId(
|
||||
experiment.getId());
|
||||
if (CollUtil.isNotEmpty(deviationConditionList)) {
|
||||
experiment.setDeviationConditionList(deviationConditionList);
|
||||
} else {
|
||||
experiment.setDeviationConditionList(new ArrayList<>());
|
||||
}
|
||||
|
||||
List<ExperimentDeviationEquipment> deviationEquipmentList = experimentDeviationEquipmentService.getByExperimentId(
|
||||
experiment.getId());
|
||||
if (CollUtil.isNotEmpty(deviationEquipmentList)) {
|
||||
experiment.setDeviationEquipmentList(deviationEquipmentList);
|
||||
} else {
|
||||
experiment.setDeviationEquipmentList(new ArrayList<>());
|
||||
}
|
||||
|
||||
List<ExperimentIrradiationBoard> irradiationBoardList = experimentIrradiationBoardService.getByExperimentId(experiment.getId());
|
||||
if (CollUtil.isNotEmpty(irradiationBoardList)) {
|
||||
experiment.setIrradiationBoardList(irradiationBoardList);
|
||||
} else {
|
||||
experiment.setIrradiationBoardList(new ArrayList<>());
|
||||
}
|
||||
|
||||
List<ExperimentFile> experimentFileList = experimentFileService.getByExperimentId(experiment.getId());
|
||||
if (CollUtil.isNotEmpty(experimentFileList)) {
|
||||
experiment.setFileList(experimentFileList);
|
||||
} else {
|
||||
experiment.setFileList(new ArrayList<>());
|
||||
}
|
||||
List<ExperimentReport> reportList = experimentReportService.getByExperimentId(experiment.getId());
|
||||
if (CollUtil.isNotEmpty(reportList)) {
|
||||
experiment.setExperimentReportList(reportList);
|
||||
} else {
|
||||
experiment.setExperimentReportList(new ArrayList<>());
|
||||
}
|
||||
List<ExperimentRating> ratingList = experimentRatingService.getByExperimentId(experiment.getId());
|
||||
if (CollUtil.isNotEmpty(ratingList)) {
|
||||
ratingList.forEach(this::fetchExperimentRateDetail);
|
||||
experiment.setExperimentRatingList(ratingList);
|
||||
} else {
|
||||
experiment.setExperimentRatingList(new ArrayList<>());
|
||||
}
|
||||
//List<ExperimentAnnealProcess> experimentAnnealProcessList = experimentAnnealProcessService.getByExperimentId(experiment.getId());
|
||||
//List<ExperimentRadiationProcess> radiationProcessList = experimentRadiationProcessService.getByExperimentId(experiment.getId());
|
||||
@@ -290,4 +319,23 @@ public class ExperimentServiceImpl extends ServiceImpl<ExperimentMapper, Experim
|
||||
public Long sumXhy() {
|
||||
return Optional.ofNullable(baseMapper.sumXhy()).orElse(0L);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fetchExperimentRateDetail(ExperimentRating experimentRating) {
|
||||
if (Objects.isNull(experimentRating)) {
|
||||
return;
|
||||
}
|
||||
Experiment experiment = this.getById(experimentRating.getExperimentId());
|
||||
if (Objects.isNull(experiment)) {
|
||||
return;
|
||||
}
|
||||
|
||||
SysUser sysUser = userService.getById(experimentRating.getRateUserId());
|
||||
if (Objects.nonNull(sysUser)) {
|
||||
experimentRating.setRateUserName(sysUser.getRealname());
|
||||
}
|
||||
experimentRating.setExperimentName(experiment.getName());
|
||||
experimentRating.setExperimentNo(experiment.getExperimentNo());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user