From f20611265f7d34fd4fbcdfdaff6cb9cccd0b25fc Mon Sep 17 00:00:00 2001
From: shenyijian <1178253012@qq.com>
Date: Fri, 21 Jun 2024 11:53:21 +0800
Subject: [PATCH] 湖北水库:施工:项目查询过滤无效修复、根据角色查询用户

---
 skjcmanager/skjcmanager-service/skjcmanager-sm/src/main/java/cn/gistack/sm/sg/service/impl/SgGxServiceImpl.java |   35 ++++++++++++++++++++++++++++-------
 1 files changed, 28 insertions(+), 7 deletions(-)

diff --git a/skjcmanager/skjcmanager-service/skjcmanager-sm/src/main/java/cn/gistack/sm/sg/service/impl/SgGxServiceImpl.java b/skjcmanager/skjcmanager-service/skjcmanager-sm/src/main/java/cn/gistack/sm/sg/service/impl/SgGxServiceImpl.java
index 12ff1f6..2e267eb 100644
--- a/skjcmanager/skjcmanager-service/skjcmanager-sm/src/main/java/cn/gistack/sm/sg/service/impl/SgGxServiceImpl.java
+++ b/skjcmanager/skjcmanager-service/skjcmanager-sm/src/main/java/cn/gistack/sm/sg/service/impl/SgGxServiceImpl.java
@@ -2,13 +2,16 @@
 
 import cn.gistack.sm.sg.DO.SgGxDO;
 import cn.gistack.sm.sg.DO.SgGxStepDO;
+import cn.gistack.sm.sg.DO.SgReportUserDO;
 import cn.gistack.sm.sg.DTO.ProjectSearchDTO;
 import cn.gistack.sm.sg.VO.SgGxVO;
 import cn.gistack.sm.sg.mapper.SgGxMapper;
+import cn.gistack.sm.sg.mapper.SgProgressReportMapper;
 import cn.gistack.sm.sg.service.SgGxService;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springblade.core.log.exception.ServiceException;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -28,16 +31,30 @@
 public class SgGxServiceImpl extends ServiceImpl<SgGxMapper, SgGxDO> implements SgGxService {
 	@Autowired
 	private SgGxMapper sgGxMapper;
+
+	@Autowired
+	private SgProgressReportMapper sgProgressReportMapper;
 	@Override
 	public IPage<SgGxVO> queryPageList(IPage<SgGxVO> page, ProjectSearchDTO searchDTO) {
-		List<SgGxVO> list = sgGxMapper.queryPageList(searchDTO);
+		List<SgGxVO> list = sgGxMapper.queryPageList(page,searchDTO);
 		if (CollectionUtils.isNotEmpty(list)){
 			List<Long> ids = list.stream().map(SgGxDO::getId).collect(Collectors.toList());
+			List<Long> userIds = list.stream().map(SgGxDO::getCreateUser).collect(Collectors.toList());
+			List<Map<String,Object>> users = sgProgressReportMapper.getUserByIds(userIds);
 			List<SgGxStepDO> stepDOS = sgGxMapper.queryStepByIds(ids);
 			if (CollectionUtils.isNotEmpty(stepDOS)){
 				Map<Long, List<SgGxStepDO>> map = stepDOS.stream().collect(Collectors.groupingBy(SgGxStepDO::getGxInfoId));
 				for (SgGxVO sgGxDO : list) {
-					sgGxDO.setStepDOList(map.get(sgGxDO.getId()));
+					for (Map<String, Object> user : users) {
+						if (user.get("ID").equals(sgGxDO.getCreateUser())){
+							sgGxDO.setCreateUserName(user.get("REAL_NAME").toString());
+						}
+					}
+					List<SgGxStepDO> sgGxStepDOS = map.get(sgGxDO.getId());
+					if (CollectionUtils.isNotEmpty(sgGxStepDOS)){
+						sgGxDO.setStepDOList(sgGxStepDOS);
+						sgGxDO.setGxStepCount(sgGxStepDOS.size());
+					}
 				}
 			}
 		}
@@ -46,24 +63,28 @@
 
 	@Override
 	public void add(SgGxDO sgGxDO) {
+		sgGxDO.setCreateUpdateTime();
 		if (sgGxMapper.selectByGxType(sgGxDO.getGxType())!= null){
-			throw  new RuntimeException("工序类型已存在");
+			throw  new ServiceException("工序类型已存在");
 		}
 		this.save(sgGxDO);
 	}
 
 	@Override
 	public void update(SgGxDO sgGxDO) {
-		if (sgGxMapper.selectByGxType(sgGxDO.getGxType())!= null){
-			throw  new RuntimeException("工序类型已存在");
+		sgGxDO.setCreateUpdateTime();
+		SgGxDO one = sgGxMapper.selectByGxType(sgGxDO.getGxType());
+		if (one != null && one.getId()!= sgGxDO.getId()  ){
+			throw  new ServiceException("工序类型已存在");
 		}
 		this.updateById(sgGxDO);
 	}
 
 	@Override
 	public SgGxVO detail(Long id) {
-		SgGxVO byId = (SgGxVO) this.getById(id);
-		byId.setStepDOList(sgGxMapper.queryStepByIds(List.of(id)));
+		SgGxVO byId = sgGxMapper.getById(id);
+		List<SgGxStepDO> stepDOS = sgGxMapper.queryStepByIds(List.of(id));
+		byId.setStepDOList(stepDOS);
 		return byId;
 	}
 }

--
Gitblit v1.9.3