From e929e18f8d04e72a23c24b06b89ab2d7be6f9c84 Mon Sep 17 00:00:00 2001
From: xiangpei <xiangpei@timesnew.cn>
Date: 星期四, 28 十一月 2024 06:04:29 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
business/src/main/java/com/ycl/service/impl/ProjectInfoServiceImpl.java | 113 ++++++++++++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 104 insertions(+), 9 deletions(-)
diff --git a/business/src/main/java/com/ycl/service/impl/ProjectInfoServiceImpl.java b/business/src/main/java/com/ycl/service/impl/ProjectInfoServiceImpl.java
index eeca686..1cddb79 100644
--- a/business/src/main/java/com/ycl/service/impl/ProjectInfoServiceImpl.java
+++ b/business/src/main/java/com/ycl/service/impl/ProjectInfoServiceImpl.java
@@ -1,21 +1,31 @@
package com.ycl.service.impl;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ycl.common.base.Result;
+import com.ycl.common.enums.business.FileTypeEnum;
+import com.ycl.common.utils.SecurityUtils;
+import com.ycl.domain.entity.File;
import com.ycl.domain.entity.ProjectInfo;
import com.ycl.domain.form.ProjectInfoForm;
import com.ycl.domain.query.ProjectInfoQuery;
-import com.ycl.domain.vo.ProjectInfoVO;
+import com.ycl.domain.vo.*;
import com.ycl.framework.utils.PageUtil;
+import com.ycl.mapper.FileMapper;
import com.ycl.mapper.ProjectInfoMapper;
+import com.ycl.service.FileService;
import com.ycl.service.ProjectInfoService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
+import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import java.util.stream.Collectors;
/**
@@ -29,41 +39,74 @@
public class ProjectInfoServiceImpl extends ServiceImpl<ProjectInfoMapper, ProjectInfo> implements ProjectInfoService {
private final ProjectInfoMapper projectInfoMapper;
-
+ private final FileService fileService;
+ private final FileMapper fileMapper;
/**
* 娣诲姞
+ *
* @param form
* @return
*/
@Override
+ @Transactional(rollbackFor = Exception.class)
public Result add(ProjectInfoForm form) {
+ //娣诲姞鍩烘湰淇℃伅
ProjectInfo entity = ProjectInfoForm.getEntityByForm(form, null);
+ Long userId = SecurityUtils.getUserId();
+ entity.setCreateBy(userId);
+ entity.setUpdateBy(userId);
baseMapper.insert(entity);
- return Result.ok("娣诲姞鎴愬姛");
+ //娣诲姞鏂囦欢
+ List<File> fileList = form.getFileList();
+ fileList.forEach(item->{
+ item.setBusId(entity.getId());
+ item.setType(FileTypeEnum.PROJECT_INFO);
+ });
+ fileService.saveBatch(fileList);
+ return Result.ok("娣诲姞鎴愬姛").data(entity.getId());
}
/**
* 淇敼
+ *
* @param form
* @return
*/
@Override
+ @Transactional(rollbackFor = Exception.class)
public Result update(ProjectInfoForm form) {
ProjectInfo entity = baseMapper.selectById(form.getId());
-
// 涓虹┖鎶汭llegalArgumentException锛屽仛鍏ㄥ眬寮傚父澶勭悊
Assert.notNull(entity, "璁板綍涓嶅瓨鍦�");
- BeanUtils.copyProperties(form, entity);
+ ProjectInfoForm.getEntityByForm(form,entity);
+ Long userId = SecurityUtils.getUserId();
+ entity.setUpdateBy(userId);
+
+ List<File> fileList = form.getFileList();
+ fileList.forEach(item->{
+ item.setBusId(entity.getId());
+ item.setType(FileTypeEnum.PROJECT_INFO);
+ });
+ //鍒犻櫎鍘熸湁鏂囦欢
+ QueryWrapper<File> fileQueryWrapper = new QueryWrapper<>();
+ fileQueryWrapper.eq("type",FileTypeEnum.PROJECT_INFO.getType());
+ fileQueryWrapper.eq("bus_id",entity.getId());
+ fileMapper.delete(fileQueryWrapper);
+ //鏇挎崲鎴愮幇鏈�
+ fileService.saveBatch(fileList);
+ //鏇存柊椤圭洰淇℃伅
baseMapper.updateById(entity);
return Result.ok("淇敼鎴愬姛");
}
/**
* 鎵归噺鍒犻櫎
+ *
* @param ids
* @return
*/
@Override
+ //TODO:寰呭畬鍠�
public Result remove(List<String> ids) {
baseMapper.deleteBatchIds(ids);
return Result.ok("鍒犻櫎鎴愬姛");
@@ -71,10 +114,12 @@
/**
* id鍒犻櫎
+ *
* @param id
* @return
*/
@Override
+ //TODO:寰呭畬鍠�
public Result removeById(String id) {
baseMapper.deleteById(id);
return Result.ok("鍒犻櫎鎴愬姛");
@@ -82,30 +127,47 @@
/**
* 鍒嗛〉鏌ヨ
+ *
* @param query
* @return
*/
@Override
public Result page(ProjectInfoQuery query) {
- IPage<ProjectInfoVO> page = PageUtil.getPage(query, ProjectInfoVO.class);
+ IPage<ProjectInfo> page = PageUtil.getPage(query, ProjectInfo.class);
baseMapper.getPage(page, query);
- return Result.ok().data(page.getRecords()).total(page.getTotal());
+ List<ProjectInfo> records = page.getRecords();
+ List<ProjectInfoVO> list = records.stream()
+ .map(entity -> {
+ ProjectInfoVO vo = ProjectInfoVO.getVoByEntity(entity, null);
+ vo.setProjectColorCode("green");
+ return vo;
+ })
+ .collect(Collectors.toList());
+ return Result.ok().data(list).total(page.getTotal());
}
/**
* 鏍规嵁id鏌ユ壘
+ *
* @param id
* @return
*/
@Override
public Result detail(Integer id) {
- ProjectInfoVO vo = baseMapper.getById(id);
- Assert.notNull(vo, "璁板綍涓嶅瓨鍦�");
+ ProjectInfo entity = baseMapper.getById(id);
+ Assert.notNull(entity, "璁板綍涓嶅瓨鍦�");
+ ProjectInfoVO vo = ProjectInfoVO.getVoByEntity(entity, null);
+ QueryWrapper<File> fileQueryWrapper = new QueryWrapper<>();
+ fileQueryWrapper.eq("type",FileTypeEnum.PROJECT_INFO.getType());
+ fileQueryWrapper.eq("bus_id",vo.getId());
+ List<File> files = fileMapper.selectList(fileQueryWrapper);
+ vo.setFileList(files);
return Result.ok().data(vo);
}
/**
* 鍒楄〃
+ *
* @return
*/
@Override
@@ -116,4 +178,37 @@
.collect(Collectors.toList());
return Result.ok().data(vos);
}
+
+ @Override
+ public IndexCountVO getIndexCount(IndexDTO indexDTO) {
+ // {"proPhaseCountVO":[{"type":"鍌ㄥ瑙勫垝闃舵","count":0,"amount":"0.00","text":"鍌�"},
+ // {"type":"椤圭洰鍓嶆湡闃舵","count":0,"amount":"0.00","text":"鏂�"},
+ // {"type":"瀹炴柦闃舵","count":0,"amount":"0.00","text":"寤�"},{"type":"绔e伐鎶曠敤闃舵","count":0,"amount":"0.00","text":"绔�"}],
+ // "impTypeCountVO":[{"type":"涓�鑸」鐩�","count":0,"amount":"0.00","text":"鏅�"},
+ // {"type":"鍘块噸鐐归」鐩�","count":0,"amount":"0.00","text":"鍘�"},{"type":"甯傞噸鐐归」鐩�","count":0,"amount":"0.00","text":"甯�"},
+ // {"type":"鐪侀噸鐐归」鐩�","count":0,"amount":"0.00","text":"鐪�"}]}}
+ IndexCountVO indexCountVO = new IndexCountVO();
+ List<IndexProPhaseCountVO> proPhaseCountVO = new ArrayList<>();
+ proPhaseCountVO.add(new IndexProPhaseCountVO("鍌ㄥ瑙勫垝闃舵", 0, "0.00", "鍌�"));
+ proPhaseCountVO.add(new IndexProPhaseCountVO("椤圭洰鍓嶆湡闃舵", 0, "0.00", "鏂�"));
+ proPhaseCountVO.add(new IndexProPhaseCountVO("瀹炴柦闃舵", 0, "0.00", "寤�"));
+ proPhaseCountVO.add(new IndexProPhaseCountVO("绔e伐鎶曠敤闃舵", 0, "0.00", "绔�"));
+ List<IndexImpTypeCountVO> impTypeCountVO = new ArrayList<>();
+ impTypeCountVO.add(new IndexImpTypeCountVO("涓�鑸」鐩�", 0, "0.00", "鏅�"));
+ impTypeCountVO.add(new IndexImpTypeCountVO("鍘块噸鐐归」鐩�", 0, "0.00", "鍘�"));
+ impTypeCountVO.add(new IndexImpTypeCountVO("甯傞噸鐐归」鐩�", 0, "0.00", "甯�"));
+ impTypeCountVO.add(new IndexImpTypeCountVO("鐪侀噸鐐归」鐩�", 0, "0.00", "鐪�"));
+ indexCountVO.setImpTypeCountVO(impTypeCountVO);
+ indexCountVO.setProPhaseCountVO(proPhaseCountVO);
+
+
+ return indexCountVO;
+ }
+
+ @Override
+ public Map<String, Integer> countExceptionProject(IndexDTO indexDTO) {
+ Map<String, Integer> map = new HashMap<>();
+ map.put("processExceptionProject", 0);
+ return map;
+ }
}
--
Gitblit v1.8.0