|
|
@@ -0,0 +1,228 @@
|
|
|
+package cn.iocoder.yudao.module.rd.controller.admin.coretechnology;
|
|
|
+
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
+import cn.hutool.core.util.ObjUtil;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
+import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
|
|
+import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
|
|
+import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|
|
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
+import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
|
+import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
|
|
+import cn.iocoder.yudao.module.rd.controller.admin.attachment.vo.AttachmentPageReqVO;
|
|
|
+import cn.iocoder.yudao.module.rd.controller.admin.coretechnology.vo.CoreTechnologyPageReqVO;
|
|
|
+import cn.iocoder.yudao.module.rd.controller.admin.coretechnology.vo.CoreTechnologyRespVO;
|
|
|
+import cn.iocoder.yudao.module.rd.controller.admin.coretechnology.vo.CoreTechnologySaveReqVO;
|
|
|
+import cn.iocoder.yudao.module.rd.controller.admin.coretechnologydetail.vo.CoreTechnologyDetailPageReqVO;
|
|
|
+import cn.iocoder.yudao.module.rd.dal.dataobject.attachment.AttachmentDO;
|
|
|
+import cn.iocoder.yudao.module.rd.dal.dataobject.coretechnology.CoreTechnologyDO;
|
|
|
+import cn.iocoder.yudao.module.rd.dal.dataobject.coretechnologydetail.CoreTechnologyDetailDO;
|
|
|
+import cn.iocoder.yudao.module.rd.enums.AttachmentCategoryEnum;
|
|
|
+import cn.iocoder.yudao.module.rd.service.attachment.AttachmentService;
|
|
|
+import cn.iocoder.yudao.module.rd.service.coretechnology.CoreTechnologyService;
|
|
|
+import cn.iocoder.yudao.module.rd.service.coretechnologydetail.CoreTechnologyDetailService;
|
|
|
+import cn.iocoder.yudao.module.rd.utils.DictDataUtils;
|
|
|
+import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictDataDO;
|
|
|
+import cn.iocoder.yudao.module.system.service.dict.DictDataService;
|
|
|
+import io.swagger.v3.oas.annotations.Operation;
|
|
|
+import io.swagger.v3.oas.annotations.Parameter;
|
|
|
+import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
+import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import javax.validation.Valid;
|
|
|
+import java.io.IOException;
|
|
|
+import java.util.Collections;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
|
|
|
+import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
|
+
|
|
|
+@Tag(name = "管理后台 - 核心技术")
|
|
|
+@RestController
|
|
|
+@RequestMapping("/rd/core-technology")
|
|
|
+@Validated
|
|
|
+public class CoreTechnologyController {
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private CoreTechnologyService coreTechnologyService;
|
|
|
+ @Resource
|
|
|
+ private DictDataService dictDataService;
|
|
|
+ @Resource
|
|
|
+ private DictDataUtils dictDataUtils;
|
|
|
+ @Resource
|
|
|
+ private AttachmentService attachmentService;
|
|
|
+ @Resource
|
|
|
+ private CoreTechnologyDetailService coreTechnologyDetailService;
|
|
|
+
|
|
|
+ @PostMapping("/create")
|
|
|
+ @Operation(summary = "创建核心技术")
|
|
|
+ @PreAuthorize("@ss.hasPermission('rd:core-technology:create')")
|
|
|
+ public CommonResult<Long> createCoreTechnology(@Valid @RequestBody CoreTechnologySaveReqVO createReqVO) {
|
|
|
+ return success(coreTechnologyService.createCoreTechnology(createReqVO));
|
|
|
+ }
|
|
|
+
|
|
|
+ @PutMapping("/update")
|
|
|
+ @Operation(summary = "更新核心技术")
|
|
|
+ @PreAuthorize("@ss.hasPermission('rd:core-technology:update')")
|
|
|
+ public CommonResult<Boolean> updateCoreTechnology(@Valid @RequestBody CoreTechnologySaveReqVO updateReqVO) {
|
|
|
+ coreTechnologyService.updateCoreTechnology(updateReqVO);
|
|
|
+ return success(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @DeleteMapping("/delete")
|
|
|
+ @Operation(summary = "删除核心技术")
|
|
|
+ @Parameter(name = "id", description = "编号", required = true)
|
|
|
+ @PreAuthorize("@ss.hasPermission('rd:core-technology:delete')")
|
|
|
+ public CommonResult<Boolean> deleteCoreTechnology(@RequestParam("id") Long id) {
|
|
|
+ coreTechnologyService.deleteCoreTechnology(id);
|
|
|
+ return success(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/get")
|
|
|
+ @Operation(summary = "获得核心技术")
|
|
|
+ @Parameter(name = "id", description = "编号", required = true, example = "1024")
|
|
|
+ @PreAuthorize("@ss.hasPermission('rd:core-technology:query')")
|
|
|
+ public CommonResult<CoreTechnologyRespVO> getCoreTechnology(@RequestParam("id") Long id) {
|
|
|
+ CoreTechnologyDO coreTechnology = coreTechnologyService.getCoreTechnology(id);
|
|
|
+ return success(buildCoreTechnology(coreTechnology));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询核心技术 技术详情
|
|
|
+ * @param technology
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private CoreTechnologyRespVO buildCoreTechnology(CoreTechnologyDO technology) {
|
|
|
+ // 如果 technology 为空 返回空对象
|
|
|
+ if (ObjUtil.isEmpty(technology)) {
|
|
|
+ return new CoreTechnologyRespVO();
|
|
|
+ }
|
|
|
+ CoreTechnologyRespVO technologyVO = BeanUtils.toBean(technology, CoreTechnologyRespVO.class);
|
|
|
+ // 查询 核心技术-状态 字典数据
|
|
|
+ Map<String, String> techStatusesPair = dictDataUtils.getDictData("rd_core_technology_status");
|
|
|
+ // 查询 核心技术-级别 字典数据
|
|
|
+ Map<String, String> techLevelPair = dictDataUtils.getDictData("rd_core_technology_level");
|
|
|
+ // 查询 核心技术-类型 字典数据
|
|
|
+ Map<String, String> techTypesPair = dictDataUtils.getDictData("rd_core_technology_type");
|
|
|
+
|
|
|
+ // 核心技术-状态
|
|
|
+ String status = technologyVO.getTechnologyStatus();
|
|
|
+ if (StrUtil.isNotBlank(status) && techStatusesPair.containsKey(status)) {
|
|
|
+ technologyVO.setTechnologyStatusLabel(techStatusesPair.get(status));
|
|
|
+ }
|
|
|
+
|
|
|
+ // 核心技术-级别
|
|
|
+ String level = technologyVO.getTechnologyLevel();
|
|
|
+ if (StrUtil.isNotBlank(level) && techLevelPair.containsKey(level)) {
|
|
|
+ technologyVO.setTechnologyLevelLabel(techLevelPair.get(level));
|
|
|
+ }
|
|
|
+
|
|
|
+ // 核心技术-类型
|
|
|
+ String type = technologyVO.getTechnologyType();
|
|
|
+ if (StrUtil.isNotBlank(type) && techTypesPair.containsKey(type)) {
|
|
|
+ technologyVO.setTechnologyTypeLabel(techTypesPair.get(type));
|
|
|
+ }
|
|
|
+ // 查询核心技术 进度明细 按照进度日期降序排列
|
|
|
+ CoreTechnologyDetailPageReqVO detailReqVO = new CoreTechnologyDetailPageReqVO();
|
|
|
+ detailReqVO.setTechnologyId(technology.getId());
|
|
|
+ List<CoreTechnologyDetailDO> technologyDetails = coreTechnologyDetailService.getCoreTechnologyDetails(detailReqVO);
|
|
|
+ if (CollUtil.isNotEmpty(technologyDetails)) {
|
|
|
+ technologyVO.setDetails(technologyDetails);
|
|
|
+ }
|
|
|
+ // 查询当前核心技术 附件列表
|
|
|
+ AttachmentPageReqVO reqVO = new AttachmentPageReqVO();
|
|
|
+ reqVO.setBizId(technology.getId());
|
|
|
+ reqVO.setCategory(AttachmentCategoryEnum.CORE_TECHNOLOGY.getCode());
|
|
|
+ List<AttachmentDO> attachments = attachmentService.getIotAttachments(reqVO);
|
|
|
+ if (CollUtil.isNotEmpty(attachments)) {
|
|
|
+ technologyVO.setAttachments(attachments);
|
|
|
+ }
|
|
|
+ return technologyVO;
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/page")
|
|
|
+ @Operation(summary = "获得核心技术分页")
|
|
|
+ @PreAuthorize("@ss.hasPermission('rd:core-technology:query')")
|
|
|
+ public CommonResult<PageResult<CoreTechnologyRespVO>> getCoreTechnologyPage(@Valid CoreTechnologyPageReqVO pageReqVO) {
|
|
|
+ PageResult<CoreTechnologyDO> pageResult = coreTechnologyService.getCoreTechnologyPage(pageReqVO);
|
|
|
+ return success(new PageResult<>(buildCoreTechnologyList(pageResult.getList()), pageResult.getTotal()));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 设置日报的关联信息 部门(施工队伍) 项目 任务 带班干部 日报填报人
|
|
|
+ * @param technologies
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private List<CoreTechnologyRespVO> buildCoreTechnologyList(List<CoreTechnologyDO> technologies) {
|
|
|
+ if (CollUtil.isEmpty(technologies)) {
|
|
|
+ return Collections.emptyList();
|
|
|
+ }
|
|
|
+ // 查询数据字典值列表
|
|
|
+ // 核心技术-状态 key字典键值 value字典标签
|
|
|
+ Map<String, String> techStatusesPair = new HashMap<>();
|
|
|
+ // 核心技术-级别 key字典键值 value字典标签
|
|
|
+ Map<String, String> techLevelPair = new HashMap<>();
|
|
|
+ // 核心技术-类型 key字典键值 value字典标签
|
|
|
+ Map<String, String> techTypesPair = new HashMap<>();
|
|
|
+
|
|
|
+ // 查询 核心技术-状态 字典数据
|
|
|
+ List<DictDataDO> techStatuses = dictDataService.getDictDataListByDictType("rd_core_technology_status");
|
|
|
+ // 查询 核心技术-级别 字典数据
|
|
|
+ List<DictDataDO> techLevel = dictDataService.getDictDataListByDictType("rd_core_technology_level");
|
|
|
+ // 查询 核心技术-类型 字典数据
|
|
|
+ List<DictDataDO> techTypes = dictDataService.getDictDataListByDictType("rd_core_technology_type");
|
|
|
+ if (CollUtil.isNotEmpty(techStatuses)) {
|
|
|
+ techStatuses.forEach(tech -> {
|
|
|
+ techStatusesPair.put(tech.getValue(), tech.getLabel());
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (CollUtil.isNotEmpty(techLevel)) {
|
|
|
+ techLevel.forEach(tech -> {
|
|
|
+ techLevelPair.put(tech.getValue(), tech.getLabel());
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (CollUtil.isNotEmpty(techTypes)) {
|
|
|
+ techTypes.forEach(tech -> {
|
|
|
+ techTypesPair.put(tech.getValue(), tech.getLabel());
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ return BeanUtils.toBean(technologies, CoreTechnologyRespVO.class, (techVO) -> {
|
|
|
+ if (StrUtil.isNotBlank(techVO.getTechnologyStatus())) {
|
|
|
+ if (techStatusesPair.containsKey(techVO.getTechnologyStatus())) {
|
|
|
+ techVO.setTechnologyStatusLabel(techStatusesPair.get(techVO.getTechnologyStatus()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (StrUtil.isNotBlank(techVO.getTechnologyLevel())) {
|
|
|
+ if (techLevelPair.containsKey(techVO.getTechnologyLevel())) {
|
|
|
+ techVO.setTechnologyLevelLabel(techLevelPair.get(techVO.getTechnologyLevel()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (StrUtil.isNotBlank(techVO.getTechnologyType())) {
|
|
|
+ if (techTypesPair.containsKey(techVO.getTechnologyType())) {
|
|
|
+ techVO.setTechnologyTypeLabel(techTypesPair.get(techVO.getTechnologyType()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/export-excel")
|
|
|
+ @Operation(summary = "导出核心技术 Excel")
|
|
|
+ @PreAuthorize("@ss.hasPermission('rd:core-technology:export')")
|
|
|
+ @ApiAccessLog(operateType = EXPORT)
|
|
|
+ public void exportCoreTechnologyExcel(@Valid CoreTechnologyPageReqVO pageReqVO,
|
|
|
+ HttpServletResponse response) throws IOException {
|
|
|
+ pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
|
|
+ List<CoreTechnologyDO> list = coreTechnologyService.getCoreTechnologyPage(pageReqVO).getList();
|
|
|
+ // 导出 Excel
|
|
|
+ ExcelUtils.write(response, "核心技术.xls", "数据", CoreTechnologyRespVO.class,
|
|
|
+ BeanUtils.toBean(list, CoreTechnologyRespVO.class));
|
|
|
+ }
|
|
|
+
|
|
|
+}
|