项目-标准评估
This commit is contained in:
+193
-35
@@ -1,11 +1,19 @@
|
||||
package com.jero.modules.projectLibrary.controller;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.io.OutputStream;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.poi.excel.ExcelUtil;
|
||||
import cn.hutool.poi.excel.ExcelWriter;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.jero.common.api.vo.Result;
|
||||
import com.jero.modules.laws.enterprise.entity.EnterpriseStandard;
|
||||
import com.jero.modules.laws.enterprise.service.EnterpriseStandardService;
|
||||
import com.jero.common.exception.JeroBootException;
|
||||
import com.jero.common.system.query.QueryGenerator;
|
||||
import com.jero.common.util.MessageUtils;
|
||||
import com.jero.modules.laws.standard.entity.LawsDomesticStandard;
|
||||
import com.jero.modules.laws.standard.entity.LawsOverseasStandard;
|
||||
import com.jero.modules.laws.standard.service.ILawsDomesticStandardService;
|
||||
@@ -13,9 +21,10 @@ import com.jero.modules.laws.standard.service.ILawsOverseasStandardService;
|
||||
import com.jero.modules.projectLibrary.entity.LawsAssess;
|
||||
import com.jero.modules.projectLibrary.service.ILawsAssessService;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.jero.modules.projectLibrary.vo.LawsAssessAddVo;
|
||||
import com.sun.deploy.net.URLEncoder;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import com.jero.common.system.base.controller.JeroController;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -40,13 +49,12 @@ import org.apache.poi.ss.formula.functions.T;
|
||||
public class LawsAssessController extends JeroController<LawsAssess, ILawsAssessService> {
|
||||
@Autowired
|
||||
private ILawsAssessService lawsAssessService;
|
||||
|
||||
@Autowired
|
||||
private ILawsDomesticStandardService lawsDomesticStandardService; //国内标准
|
||||
@Autowired
|
||||
private ILawsOverseasStandardService lawsOverseasStandardService; //海外标准
|
||||
@Autowired
|
||||
private EnterpriseStandardService enterpriseStandardService; //企业标准
|
||||
//国内标准
|
||||
@Autowired
|
||||
private ILawsDomesticStandardService lawsDomesticStandardService;
|
||||
//海外标准
|
||||
@Autowired
|
||||
private ILawsOverseasStandardService lawsOverseasStandardService;
|
||||
|
||||
/**
|
||||
* 分页列表查询
|
||||
@@ -62,7 +70,6 @@ public class LawsAssessController extends JeroController<LawsAssess, ILawsAssess
|
||||
this.assignment(pageList.getRecords());
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
private void assignment(List<LawsAssess> records) {
|
||||
for (LawsAssess assess : records) {
|
||||
String standardId = assess.getStandardId();
|
||||
@@ -70,32 +77,130 @@ public class LawsAssessController extends JeroController<LawsAssess, ILawsAssess
|
||||
if ("1".equals(source)){
|
||||
//查询国内标准数据,赋值给collection
|
||||
LawsDomesticStandard standard = lawsDomesticStandardService.queryById(standardId);
|
||||
BeanUtils.copyProperties(standard, assess);
|
||||
assess.setStandardEnglishName(standard.getStandardEnglishName());
|
||||
assess.setStandardState(standard.getStandardState());
|
||||
assess.setApplicableVehicle(standard.getApplicableVehicle());
|
||||
assess.setOnTheProductionDate(standard.getOnTheProductionDate());
|
||||
assess.setNewModelImplementationDate(standard.getNewModelImplementationDate());
|
||||
assess.setEvaluationResults("这里要用额外方法查询");
|
||||
assess.setResponsibleDepartment(standard.getResponsibleDepartment());
|
||||
}
|
||||
if ("2".equals(source)){
|
||||
//查询海外标准数据,赋值给collection
|
||||
LawsOverseasStandard standard = lawsOverseasStandardService.queryById(standardId);
|
||||
BeanUtils.copyProperties(standard, assess);
|
||||
}
|
||||
if ("3".equals(source)){
|
||||
//查询企业标准数据,赋值给collection
|
||||
EnterpriseStandard standard = enterpriseStandardService.getById(standardId);
|
||||
BeanUtils.copyProperties(standard, assess);
|
||||
assess.setStandardEnglishName(standard.getStandardEnglishName());
|
||||
assess.setStandardState(standard.getStandardState());
|
||||
assess.setApplicableVehicle(standard.getApplicableVehicle());
|
||||
assess.setOnTheProductionDate(standard.getOnTheProductionDate());
|
||||
assess.setNewModelImplementationDate(standard.getNewModelImplementationDate());
|
||||
assess.setEvaluationResults("这里要用额外方法查询");
|
||||
assess.setResponsibleDepartment(standard.getResponsibleDepartment());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
* 调取
|
||||
*/
|
||||
@AutoLog(value = "项目-标准评估-添加")
|
||||
@ApiOperation(value="项目-标准评估-添加", notes="项目-标准评估-添加")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<T> add(@Validated @RequestBody LawsAssess lawsAssess) {
|
||||
lawsAssessService.add(lawsAssess);
|
||||
@AutoLog(value = "项目-标准评估-调取")
|
||||
@ApiOperation(value="项目-标准评估-调取", notes="项目-标准评估-调取")
|
||||
@PostMapping(value = "/retrieval")
|
||||
public Result<T> retrieval(@Validated @RequestBody LawsAssessAddVo lawsAssessAddVo) {
|
||||
String domesticStandardId = lawsAssessAddVo.getDomesticStandardId();
|
||||
String overseasStandardId = lawsAssessAddVo.getOverseasStandardId();
|
||||
if (StringUtils.isNotBlank(domesticStandardId) && StringUtils.isNotBlank(overseasStandardId)){
|
||||
return Result.error("请至少选择一个标准进行调取!");
|
||||
}
|
||||
//查询当前项目已绑定的标准,为了不造成重复绑定
|
||||
List<LawsAssess> assessArrayList = lawsAssessService.getAllByProjectId(lawsAssessAddVo.getProjectId());
|
||||
List<String> collect = assessArrayList.stream().map(LawsAssess::getStandardId).distinct().collect(Collectors.toList());
|
||||
Date now = new Date();
|
||||
List<LawsAssess> lawsAssesses = new ArrayList<>();
|
||||
if (StringUtils.isNotBlank(domesticStandardId)){
|
||||
List<String> asList = Arrays.asList(domesticStandardId.split(","));
|
||||
for (String id : asList) {
|
||||
if (collect.contains(id)){
|
||||
continue;
|
||||
}
|
||||
LawsAssess lawsAssess = new LawsAssess();
|
||||
lawsAssess.setSource("1");
|
||||
lawsAssess.setProjectId(lawsAssessAddVo.getProjectId());
|
||||
lawsAssess.setStandardId(id);
|
||||
LawsDomesticStandard standard = lawsDomesticStandardService.queryById(id);
|
||||
lawsAssess.setStandardNumber(standard.getStandardNumber());
|
||||
lawsAssess.setStandardName(standard.getStandardName());
|
||||
lawsAssess.setProcessStatus("1");
|
||||
lawsAssess.setCreateTime(now);
|
||||
lawsAssess.setUpdateTime(now);
|
||||
lawsAssesses.add(lawsAssess);
|
||||
}
|
||||
}
|
||||
if (StringUtils.isNotBlank(overseasStandardId)){
|
||||
List<String> asList = Arrays.asList(overseasStandardId.split(","));
|
||||
for (String id : asList) {
|
||||
if (collect.contains(id)){
|
||||
continue;
|
||||
}
|
||||
LawsAssess lawsAssess = new LawsAssess();
|
||||
lawsAssess.setSource("2");
|
||||
lawsAssess.setProjectId(lawsAssessAddVo.getProjectId());
|
||||
lawsAssess.setStandardId(id);
|
||||
LawsOverseasStandard standard = lawsOverseasStandardService.queryById(id);
|
||||
lawsAssess.setStandardNumber(standard.getStandardNumber());
|
||||
lawsAssess.setStandardName(standard.getStandardName());
|
||||
lawsAssess.setProcessStatus("1");
|
||||
lawsAssess.setCreateTime(now);
|
||||
lawsAssess.setUpdateTime(now);
|
||||
lawsAssesses.add(lawsAssess);
|
||||
}
|
||||
}
|
||||
if (lawsAssesses.isEmpty()){
|
||||
return Result.error("调取标准全部存在,请重新选择标准!");
|
||||
}
|
||||
lawsAssessService.saveBatch(lawsAssesses);
|
||||
return Result.OK("操作成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 复制
|
||||
*/
|
||||
@AutoLog(value = "项目-标准评估-复制")
|
||||
@ApiOperation(value="项目-标准评估-复制", notes="项目-标准评估-复制")
|
||||
@PostMapping(value = "/copy")
|
||||
public Result<T> copy(@Validated @RequestBody LawsAssessAddVo lawsAssessAddVo) {
|
||||
String copyProjectId = lawsAssessAddVo.getCopyProjectId();
|
||||
if (StringUtils.isBlank(copyProjectId)){
|
||||
return Result.error("请至少选择一个项目进行复制!");
|
||||
}
|
||||
Date now = new Date();
|
||||
List<LawsAssess> lawsAssesses = new ArrayList<>();
|
||||
List<LawsAssess> assessArrayList = lawsAssessService.getAllByProjectId(lawsAssessAddVo.getProjectId());
|
||||
List<String> collect = assessArrayList.stream().map(LawsAssess::getStandardId).distinct().collect(Collectors.toList());
|
||||
List<LawsAssess> copyAssessArrayList = lawsAssessService.getAllByProjectId(copyProjectId);
|
||||
for (LawsAssess lawsAssess : copyAssessArrayList) {
|
||||
String standardId = lawsAssess.getStandardId();
|
||||
if (collect.contains(standardId)){
|
||||
continue;
|
||||
}
|
||||
LawsAssess assess = new LawsAssess();
|
||||
assess.setSource(lawsAssess.getSource());
|
||||
assess.setProjectId(lawsAssessAddVo.getProjectId());
|
||||
assess.setStandardId(standardId);
|
||||
assess.setStandardNumber(lawsAssess.getStandardNumber());
|
||||
assess.setStandardName(lawsAssess.getStandardName());
|
||||
assess.setProcessStatus("1");
|
||||
assess.setCreateTime(now);
|
||||
assess.setUpdateTime(now);
|
||||
lawsAssesses.add(assess);
|
||||
}
|
||||
if (lawsAssesses.isEmpty()){
|
||||
return Result.error("复制项目标准全部存在,请重新选择项目!");
|
||||
}
|
||||
lawsAssessService.saveBatch(lawsAssesses);
|
||||
return Result.OK("操作成功!");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
*/
|
||||
@@ -110,14 +215,67 @@ public class LawsAssessController extends JeroController<LawsAssess, ILawsAssess
|
||||
return Result.OK("删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出excel
|
||||
*/
|
||||
@AutoLog(value = "项目-标准评估-导出excel")
|
||||
@ApiOperation(value="项目-标准评估-导出excel", notes="项目-标准评估-导出excel")
|
||||
@GetMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, LawsAssess lawsAssess) {
|
||||
return super.exportXls(request, lawsAssess, LawsAssess.class, "项目-标准评估");
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出excel
|
||||
*/
|
||||
@AutoLog(value = "项目-标准评估-导出excel")
|
||||
@ApiOperation(value="项目-标准评估-导出excel", notes="项目-标准评估-导出excel")
|
||||
@GetMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, LawsAssess lawsAssess, HttpServletResponse response) {
|
||||
String outFileName = MessageUtils.getLanguage().equals("EN") ? "Internal Work Group Personnel Table" + System.currentTimeMillis() + ".xlsx" : "项目-标准评估" + System.currentTimeMillis() + ".xlsx";
|
||||
String ENCODING = "UTF-8";
|
||||
ExcelWriter writer = ExcelUtil.getWriter(true);
|
||||
|
||||
// 通过工具类创建writer并且进行别名
|
||||
assembleWriter(writer);
|
||||
|
||||
//获取数据
|
||||
List<LawsAssess> dos = null;
|
||||
String selections = request.getParameter("selections");
|
||||
if (StringUtils.isNotBlank(selections)){
|
||||
dos = lawsAssessService.listByIds(Arrays.asList(selections.split(",")));
|
||||
}else {
|
||||
QueryWrapper<LawsAssess> queryWrapper = QueryGenerator.initQueryWrapper(lawsAssess, request.getParameterMap());
|
||||
dos = lawsAssessService.list(queryWrapper);
|
||||
}
|
||||
if (dos.isEmpty()){
|
||||
throw new JeroBootException("请选择数据导出!");
|
||||
}
|
||||
this.assignment(dos);
|
||||
|
||||
//导出表头只保留别名中的字段
|
||||
writer.setOnlyAlias(true);
|
||||
//表格高度
|
||||
writer.setDefaultRowHeight(18);
|
||||
//表格宽度
|
||||
writer.setColumnWidth(-1, 20);
|
||||
//放入数据
|
||||
writer.write(dos, true);
|
||||
try {
|
||||
// 获取我们的输出流
|
||||
final OutputStream output = response.getOutputStream();
|
||||
response.setContentType("application/vnd.ms-excel;charset=utf-8");
|
||||
response.setHeader("Content-Disposition", "attachment;filename=" + outFileName + ";filename*=utf-8"
|
||||
+ URLEncoder.encode(outFileName, ENCODING));
|
||||
writer.flush(output, true);
|
||||
writer.close();
|
||||
// 这里可以自行关闭资源或者写一个关闭资源的工具类
|
||||
IoUtil.close(output);
|
||||
} catch (Exception e) {
|
||||
log.error("导出失败:", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
private void assembleWriter(ExcelWriter writer) {
|
||||
writer.addHeaderAlias("standardNumber", "标准号");
|
||||
writer.addHeaderAlias("standardName", "标准名称");
|
||||
writer.addHeaderAlias("standardState", "标准状态");
|
||||
writer.addHeaderAlias("applicableVehicle", "适用车型");
|
||||
writer.addHeaderAlias("onTheProductionDate", "在产车实施日期");
|
||||
writer.addHeaderAlias("newModelImplementationDate", "新车型实施日期");
|
||||
writer.addHeaderAlias("processStatus", "流程状态");
|
||||
writer.addHeaderAlias("evaluationResults", "评估结果");
|
||||
writer.addHeaderAlias("responsibleDepartment", "责任部门");
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -155,10 +155,10 @@ public class LawsProjectLibraryController extends JeroController<LawsProjectLibr
|
||||
QueryWrapper<LawsProjectLibrary> queryWrapper = QueryGenerator.initQueryWrapper(lawsProjectLibrary, request.getParameterMap());
|
||||
dos = lawsProjectLibraryService.list(queryWrapper);
|
||||
}
|
||||
this.translate(dos);
|
||||
if (dos.isEmpty()){
|
||||
throw new JeroBootException("请选择数据导出!");
|
||||
}
|
||||
this.translate(dos);
|
||||
|
||||
//导出表头只保留别名中的字段
|
||||
writer.setOnlyAlias(true);
|
||||
|
||||
@@ -58,10 +58,14 @@ public class LawsAssess implements Serializable {
|
||||
private String source;
|
||||
|
||||
/**标准编号*/
|
||||
@NotBlank(message = "standardNum not null")
|
||||
@Excel(name = "标准编号", width = 15)
|
||||
@ApiModelProperty(value = "标准编号")
|
||||
private String standardNum;
|
||||
private String standardNumber;
|
||||
|
||||
/**标准名称*/
|
||||
@Excel(name = "标准名称", width = 15)
|
||||
@ApiModelProperty(value = "标准名称")
|
||||
private String standardName;
|
||||
|
||||
/**流程状态(1-未评估、2-评估中、3-已评估)*/
|
||||
@Dict(dicCode = "process_status")
|
||||
@@ -94,9 +98,6 @@ public class LawsAssess implements Serializable {
|
||||
@ApiModelProperty(value = "所属部门")
|
||||
private String orgCode;
|
||||
|
||||
@TableField(exist = false)
|
||||
@ApiModelProperty(value = "标准名称")
|
||||
private String standardName;
|
||||
|
||||
@TableField(exist = false)
|
||||
@ApiModelProperty(value = "英文名称")
|
||||
|
||||
+2
@@ -73,4 +73,6 @@ public interface ILawsAssessService extends IService<LawsAssess> {
|
||||
* @return
|
||||
*/
|
||||
LawsAssess queryById(String id);
|
||||
|
||||
List<LawsAssess> getAllByProjectId(String projectId);
|
||||
}
|
||||
|
||||
+14
@@ -1,12 +1,16 @@
|
||||
package com.jero.modules.projectLibrary.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.jero.modules.projectLibrary.entity.LawsAssess;
|
||||
import com.jero.modules.projectLibrary.mapper.LawsAssessMapper;
|
||||
import com.jero.modules.projectLibrary.service.ILawsAssessService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import com.jero.common.exception.JeroBootException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Date;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
@@ -115,4 +119,14 @@ public class LawsAssessServiceImpl extends ServiceImpl<LawsAssessMapper, LawsAss
|
||||
public LawsAssess queryById(String id) {
|
||||
return getById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LawsAssess> getAllByProjectId(String projectId) {
|
||||
if (StringUtils.isBlank(projectId)){
|
||||
return new ArrayList<>();
|
||||
}
|
||||
LambdaQueryWrapper<LawsAssess> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(LawsAssess::getProjectId, projectId);
|
||||
return list(wrapper);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.jero.modules.projectLibrary.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
/**
|
||||
* 项目-标准评估 调取、复制接口当作入参对象使用
|
||||
*/
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@ApiModel(value="lawsAssessAddVo对象", description="项目-标准评估-调取、复制")
|
||||
public class LawsAssessAddVo {
|
||||
|
||||
/**项目ID*/
|
||||
@NotBlank(message = "projectId not null")
|
||||
@ApiModelProperty(value = "所在项目ID")
|
||||
private String projectId;
|
||||
|
||||
/**项目ID*/
|
||||
@ApiModelProperty(value = "所选复制项目ID")
|
||||
private String copyProjectId;
|
||||
|
||||
/**标准ID*/
|
||||
@ApiModelProperty(value = "国内标准ID")
|
||||
private String domesticStandardId;
|
||||
|
||||
/**标准编号*/
|
||||
@ApiModelProperty(value = "国内标准编号")
|
||||
private String domesticStandardNumber;
|
||||
|
||||
/**标准ID*/
|
||||
@ApiModelProperty(value = "海外标准ID")
|
||||
private String overseasStandardId;
|
||||
|
||||
/**标准编号*/
|
||||
@ApiModelProperty(value = "海外标准编号")
|
||||
private String overseasStandardNumber;
|
||||
}
|
||||
Reference in New Issue
Block a user