|
|
@@ -8,6 +8,8 @@ import jakarta.annotation.Resource;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.sky.core.log.exception.ServiceException;
|
|
|
import org.sky.core.mp.base.BaseServiceImpl;
|
|
|
+import org.sky.core.mp.support.Condition;
|
|
|
+import org.sky.core.mp.support.Query;
|
|
|
import org.sky.core.secure.utils.SecureUtil;
|
|
|
import org.sky.core.tool.utils.BeanUtil;
|
|
|
import org.sky.core.tool.utils.CollectionUtil;
|
|
|
@@ -23,19 +25,16 @@ import org.sky.scientific.pojo.dto.XmTechnicianDto;
|
|
|
import org.sky.scientific.pojo.entity.TechnicianEntity;
|
|
|
import org.sky.scientific.pojo.entity.XmEntity;
|
|
|
import org.sky.scientific.pojo.entity.XmTechnicianEntity;
|
|
|
-import org.sky.scientific.pojo.entity.YsRyrgfyEntity;
|
|
|
import org.sky.scientific.pojo.vo.TechnicianVO;
|
|
|
import org.sky.scientific.pojo.vo.XmTechnicianSummary;
|
|
|
+import org.sky.scientific.pojo.vo.YsRyrgfyVO;
|
|
|
import org.sky.scientific.service.ITechnicianService;
|
|
|
import org.sky.system.cache.DictCache;
|
|
|
import org.sky.system.pojo.enums.DictEnum;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
-import java.util.Date;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Objects;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* 技术人员花名册 服务实现类
|
|
|
@@ -57,13 +56,17 @@ public class TechnicianServiceImpl extends BaseServiceImpl<TechnicianMapper, Tec
|
|
|
@Override
|
|
|
public boolean saveOrUpdateTechnician(TechnicianEntity technician) {
|
|
|
if (StringUtil.isBlank(technician.getYearAndMonth())) {
|
|
|
-// technician.setYearAndMonth(DateUtil.format(DateUtil.now(), DateUtil.PATTERN_YYYYMM));
|
|
|
throw new ServiceException("参数yearAndMonth不能为空");
|
|
|
}
|
|
|
if (StringUtil.isBlank(technician.getNumber()) && StringUtil.isBlank(technician.getIdCard())) {
|
|
|
throw new ServiceException("工号和身份证号码不能同时为空");
|
|
|
}
|
|
|
|
|
|
+ String unicode = baseMapper.getUnicodeByNumberAndIdentityCard(technician.getNumber(), technician.getIdCard());
|
|
|
+ if (unicode == null){
|
|
|
+ unicode = UUID.randomUUID().toString();
|
|
|
+ }
|
|
|
+ technician.setUnicode(unicode);
|
|
|
//根据年月和工号或身份证
|
|
|
LambdaQueryWrapper<TechnicianEntity> wrapper = Wrappers.<TechnicianEntity>lambdaQuery()
|
|
|
.eq(TechnicianEntity::getYearAndMonth, technician.getYearAndMonth())
|
|
|
@@ -161,29 +164,36 @@ public class TechnicianServiceImpl extends BaseServiceImpl<TechnicianMapper, Tec
|
|
|
.eq(XmTechnicianEntity::getYearAndMonth, DateUtil.format(lastDate, DateUtil.PATTERN_YYYYMM));
|
|
|
List<XmTechnicianEntity> lastMonthTechnicianList = xmTechnicianMapper.selectList(wrapper);
|
|
|
//若无数据,则引入预算表的人员人工费用
|
|
|
- List<Long> technicianIds = null;
|
|
|
+ List<String> unicodeList = null;
|
|
|
if (CollectionUtil.isEmpty(lastMonthTechnicianList)) {
|
|
|
- List<YsRyrgfyEntity> ysRyrgfyList = ysRyrgfyMapper.selectList(Wrappers.<YsRyrgfyEntity>lambdaQuery().eq(YsRyrgfyEntity::getXmId, xm.getId()));
|
|
|
- technicianIds = ysRyrgfyList.stream().map(YsRyrgfyEntity::getTechnicianId).toList();
|
|
|
+ Query query = new Query();
|
|
|
+ query.setCurrent(1);
|
|
|
+ query.setSize(Integer.MAX_VALUE);
|
|
|
+
|
|
|
+ YsRyrgfyVO vo = new YsRyrgfyVO();
|
|
|
+ vo.setXmId(xm.getId());
|
|
|
+
|
|
|
+ List<YsRyrgfyVO> ysRyrgfyList = ysRyrgfyMapper.selectYsRyrgfyPage(Condition.getPage(query), vo);
|
|
|
+ unicodeList = ysRyrgfyList.stream().map(YsRyrgfyVO::getUnicode).toList();
|
|
|
} else {
|
|
|
- technicianIds = lastMonthTechnicianList.stream().map(XmTechnicianEntity::getTechnicianId).toList();
|
|
|
+ unicodeList = lastMonthTechnicianList.stream().map(XmTechnicianEntity::getUnicode).toList();
|
|
|
}
|
|
|
- insertXmTechnician(technicianIds, xm.getId(), yearAndMonth);
|
|
|
+ insertXmTechnician(unicodeList, xm.getId(), yearAndMonth);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void insertXmTechnician(List<Long> technicianIdList, Long xmId, String yearAndMonth) {
|
|
|
- for (Long technicianId : technicianIdList) {
|
|
|
+ private void insertXmTechnician(List<String> unicodeList, Long xmId, String yearAndMonth) {
|
|
|
+ for (String unicode : unicodeList) {
|
|
|
XmTechnicianEntity monthlyEntity = new XmTechnicianEntity();
|
|
|
monthlyEntity.setXmId(xmId);
|
|
|
- monthlyEntity.setTechnicianId(technicianId);
|
|
|
+ monthlyEntity.setUnicode(unicode);
|
|
|
monthlyEntity.setYearAndMonth(yearAndMonth);
|
|
|
monthlyEntity.setCreateUser(SecureUtil.getUserId());
|
|
|
monthlyEntity.setUpdateUser(SecureUtil.getUserId());
|
|
|
|
|
|
LambdaQueryWrapper<XmTechnicianEntity> queryWrapper = Wrappers.<XmTechnicianEntity>lambdaQuery().
|
|
|
eq(XmTechnicianEntity::getYearAndMonth, yearAndMonth).
|
|
|
- eq(XmTechnicianEntity::getTechnicianId, technicianId).
|
|
|
+ eq(XmTechnicianEntity::getUnicode, unicode).
|
|
|
eq(XmTechnicianEntity::getXmId, xmId);
|
|
|
if (xmTechnicianMapper.selectCount(queryWrapper) == 0) {
|
|
|
xmTechnicianMapper.insert(monthlyEntity);
|
|
|
@@ -206,7 +216,7 @@ public class TechnicianServiceImpl extends BaseServiceImpl<TechnicianMapper, Tec
|
|
|
entity.setTenantId(SecureUtil.getTenantId());
|
|
|
LambdaQueryWrapper<XmTechnicianEntity> wrapper = Wrappers.<XmTechnicianEntity>lambdaQuery().
|
|
|
eq(XmTechnicianEntity::getYearAndMonth, entity.getYearAndMonth()).
|
|
|
- eq(XmTechnicianEntity::getTechnicianId, entity.getTechnicianId()).
|
|
|
+ eq(XmTechnicianEntity::getUnicode, entity.getUnicode()).
|
|
|
eq(XmTechnicianEntity::getXmId, entity.getXmId());
|
|
|
if (xmTechnicianMapper.selectCount(wrapper) == 0) {
|
|
|
affectNum = xmTechnicianMapper.insert(entity);
|
|
|
@@ -257,7 +267,15 @@ public class TechnicianServiceImpl extends BaseServiceImpl<TechnicianMapper, Tec
|
|
|
|
|
|
@Override
|
|
|
public IPage<XmTechnicianSummary> xiangmucanyanrenyuanhuizongbiao(IPage<XmTechnicianSummary> page, XmTechnicianEntity entity) {
|
|
|
- List<XmTechnicianSummary> summary = xmTechnicianMapper.xmTechnicianSummary(page, entity);
|
|
|
+ if (StringUtil.isAllBlank(entity.getYearAndMonth())) {
|
|
|
+ throw new ServiceException("参数yearAndMonth不能为空");
|
|
|
+ }
|
|
|
+ List<XmTechnicianSummary> summary = null;
|
|
|
+ if (entity.getYearAndMonth().length() == 6) {
|
|
|
+ summary = xmTechnicianMapper.xmTechnicianSummaryByMonthly(page, entity);
|
|
|
+ }else {
|
|
|
+ summary = xmTechnicianMapper.xmTechnicianSummaryByYear(page, entity);
|
|
|
+ }
|
|
|
return page.setRecords(summary);
|
|
|
}
|
|
|
}
|