Browse Source

000000000

zhoulisky 7 months ago
parent
commit
4f19dbac4e

+ 33 - 14
kd-service/kd-scientific/src/main/java/org/sky/scientific/service/impl/AttendanceServiceImpl.java

@@ -369,30 +369,49 @@ public class AttendanceServiceImpl extends BaseServiceImpl<AttendanceMapper, Att
 		List<XmTechnicianEntity> list = xmTechnicianMapper.selectList(Wrappers.<XmTechnicianEntity>lambdaQuery().eq(XmTechnicianEntity::getYearAndMonth, yearAndMonth));
 
 		if(Func.isEmpty(list)){
-			throw new ServiceException("本月没有研发人员");
+			throw new ServiceException("本月无参研人员");
 		}
+		List<String> unicodeList = list.stream().map(XmTechnicianEntity::getUnicode).distinct().toList();
 
+		List<AttendanceEntity> attendanceList = this.baseMapper.selectByYearAndMonth(yearAndMonth);
+		List<String> existsUnicodeList = attendanceList.stream().map(AttendanceEntity::getUnicode).distinct().toList();
+
+		List<String> insertUnicodeList = unicodeList.stream().filter(item -> !existsUnicodeList.contains(item)).toList();
+		if(Func.isEmpty(insertUnicodeList)){
+			throw new ServiceException("本月参研人员已全部引用");
+		}
 		List<AttendanceEntity> insertList = new ArrayList<>();
-		for (XmTechnicianEntity xmTechnician : list) {
+		for (String unicode : insertUnicodeList) {
 			AttendanceEntity attendance = new AttendanceEntity();
-			attendance.setUnicode(xmTechnician.getUnicode());
+			attendance.setUnicode(unicode);
 			attendance.setWorkDate(yearAndMonth + "01");
 			attendance.setWorkHours(0.0);
 			attendance.setTenantId(SecureUtil.getTenantId());
 			insertList.add(attendance);
 		}
+		return this.saveBatch(insertList);
+//		if(Func.isEmpty(existsUnicodeList)){
+//			return this.saveBatch(insertList);
+//		}else {
+////			List<AttendanceEntity> deduplicationList = insertList.stream().filter(item -> !existsUnicodeList.contains(item.getUnicode())).toList();
+//			List<String> insertUnicodeList = unicodeList.stream().filter(item -> !existsUnicodeList.contains(item)).toList();
+//			if(Func.isEmpty(insertUnicodeList)){
+//				throw new ServiceException("本月参研人员已全部引用");
+//			}
+//			return this.saveBatch(deduplicationList);
+//		}
+//		List<AttendanceEntity> insertList = new ArrayList<>();
+//		for (XmTechnicianEntity xmTechnician : list) {
+//			AttendanceEntity attendance = new AttendanceEntity();
+//			attendance.setUnicode(xmTechnician.getUnicode());
+//			attendance.setWorkDate(yearAndMonth + "01");
+//			attendance.setWorkHours(0.0);
+//			attendance.setTenantId(SecureUtil.getTenantId());
+//			insertList.add(attendance);
+//		}
+
+
 
-		List<AttendanceEntity> attendanceList = this.baseMapper.selectByYearAndMonth(yearAndMonth);
-		List<String> existsUnicodeList = attendanceList.stream().map(AttendanceEntity::getUnicode).distinct().toList();
-		if(Func.isEmpty(existsUnicodeList)){
- 			return this.saveBatch(insertList);
-		}else {
-			List<AttendanceEntity> deduplicationList = insertList.stream().filter(item -> !existsUnicodeList.contains(item.getUnicode())).toList();
-			if(Func.isEmpty(deduplicationList)){
-				throw new ServiceException("本月研发人员已全部引用");
-			}
-			return this.saveBatch(deduplicationList);
-		}
  	}
 
 	@Override

+ 12 - 6
kd-service/kd-scientific/src/main/java/org/sky/scientific/service/impl/XmServiceImpl.java

@@ -86,14 +86,20 @@ public class XmServiceImpl extends BaseServiceImpl<XmMapper, XmEntity> implement
 
 		this.judgeXmmcAvailable(xm.getXmmc());
 
+//		if(XmStatusEnum.暂存.getCode() == xm.getStatus()){
+//
+//		}
+
 		//检查项目名称是否重复(xm);
 		LambdaQueryWrapper<XmEntity> queryWrapper = Wrappers.<XmEntity>lambdaQuery().eq(XmEntity::getXmmc, xm.getXmmc());
-		if (baseMapper.selectCount(queryWrapper) > 0) {
+		Long xmIdByXmmc = baseMapper.getXmIdByXmmcOrXmbh(null, xm.getXmmc(), null);
+		if (xmIdByXmmc!=null && !xmIdByXmmc.equals(xm.getId())) {
 			throw new ServiceException("研发项目名称已存在");
 		}
 
-		queryWrapper = Wrappers.<XmEntity>lambdaQuery().eq(XmEntity::getXmbh, xm.getXmbh());
-		if (baseMapper.selectCount(queryWrapper) > 0) {
+//		queryWrapper = Wrappers.<XmEntity>lambdaQuery().eq(XmEntity::getXmbh, xm.getXmbh());
+		Long xmIdByXmbh = baseMapper.getXmIdByXmmcOrXmbh(null, null, xm.getXmbh());
+		if (xmIdByXmbh!=null && !xmIdByXmbh.equals(xm.getId())) {
 			throw new ServiceException("研发项目编号已存在");
 		}
 
@@ -107,7 +113,7 @@ public class XmServiceImpl extends BaseServiceImpl<XmMapper, XmEntity> implement
 			}
 		}
 
-		return this.save(xm) ? xm.getId() : null;
+		return this.saveOrUpdate(xm) ? xm.getId() : null;
 	}
 
 	@Override
@@ -152,7 +158,7 @@ public class XmServiceImpl extends BaseServiceImpl<XmMapper, XmEntity> implement
 	@Override
 	public boolean updateXm(XmUpdateDto dto) {
 		XmVO dbXm = baseMapper.selectByXmId(dto.getXmId());
-		if(XmStatusEnum.暂存.getCode() != dbXm.getStatus()){
+		if (XmStatusEnum.暂存.getCode() != dbXm.getStatus()) {
 			throw new ServiceException("只有项目状态为暂存时才能修改项目信息");
 		}
 		return baseMapper.updateXm(dto);
@@ -215,7 +221,7 @@ public class XmServiceImpl extends BaseServiceImpl<XmMapper, XmEntity> implement
 
 	@SneakyThrows
 	@Override
- 	public void exportSummary(OutputStream os, XmDTO dto) {
+	public void exportSummary(OutputStream os, XmDTO dto) {
 		try {
 			InputStream templateFileName = this.getClass().getClassLoader().getResourceAsStream("export-template/研发项目管理/研发项目汇总表.xls");