|
|
@@ -1,15 +1,11 @@
|
|
|
|
|
|
package org.sky.scientific.service.impl;
|
|
|
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import jakarta.annotation.Resource;
|
|
|
-import jakarta.validation.constraints.Email;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.apache.ibatis.executor.BatchResult;
|
|
|
-import org.glassfish.jaxb.core.v2.TODO;
|
|
|
import org.sky.core.log.exception.ServiceException;
|
|
|
import org.sky.core.mp.base.BaseServiceImpl;
|
|
|
import org.sky.core.secure.utils.AuthUtil;
|
|
|
@@ -20,7 +16,9 @@ import org.sky.scientific.mapper.TechnicianMapper;
|
|
|
import org.sky.scientific.mapper.XmTechnicianMonthlyMapper;
|
|
|
import org.sky.scientific.mapper.YsRyrgfyMapper;
|
|
|
import org.sky.scientific.pojo.dto.TechnicianDTO;
|
|
|
+import org.sky.scientific.pojo.dto.XmTechnicianMonthlyDto;
|
|
|
import org.sky.scientific.pojo.entity.TechnicianEntity;
|
|
|
+import org.sky.scientific.pojo.entity.XmEntity;
|
|
|
import org.sky.scientific.pojo.entity.XmTechnicianMonthlyEntity;
|
|
|
import org.sky.scientific.pojo.entity.YsRyrgfyEntity;
|
|
|
import org.sky.scientific.pojo.vo.TechnicianVO;
|
|
|
@@ -31,8 +29,9 @@ import org.sky.system.pojo.enums.DictEnum;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
-import java.util.*;
|
|
|
-import java.util.stream.Collectors;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Objects;
|
|
|
|
|
|
/**
|
|
|
* 技术人员花名册 服务实现类
|
|
|
@@ -70,12 +69,12 @@ public class TechnicianServiceImpl extends BaseServiceImpl<TechnicianMapper, Tec
|
|
|
//查询快照表是否存在,存在则覆盖,不存在则新增
|
|
|
// TODO 新增基础信息成功后,technician.getTechnicianId()是否为空
|
|
|
TechnicianEntity technicianSnapshot = baseMapper.selectByTechnicianIdAndYearAndMonth(technicianId, technician.getYearAndMonth());
|
|
|
- if(technicianSnapshot == null){
|
|
|
+ if (technicianSnapshot == null) {
|
|
|
//新增
|
|
|
- affectNum = baseMapper.saveTechnicianSnapshot(technicianId,technician);
|
|
|
- }else {
|
|
|
+ affectNum = baseMapper.saveTechnicianSnapshot(technicianId, technician);
|
|
|
+ } else {
|
|
|
//覆盖
|
|
|
- affectNum = baseMapper.updateTechnicianSnapshot(technicianId,technician);
|
|
|
+ affectNum = baseMapper.updateTechnicianSnapshot(technicianId, technician);
|
|
|
}
|
|
|
return affectNum == 1;
|
|
|
}
|
|
|
@@ -87,15 +86,15 @@ public class TechnicianServiceImpl extends BaseServiceImpl<TechnicianMapper, Tec
|
|
|
|
|
|
@Override
|
|
|
public IPage<TechnicianVO> selectTechnicianPage(IPage<TechnicianVO> page, TechnicianDTO technician) {
|
|
|
- if(StringUtil.isBlank(technician.getYearAndMonth())){
|
|
|
+ if (StringUtil.isBlank(technician.getYearAndMonth())) {
|
|
|
throw new ServiceException("参数yearAndMonth不能为空");
|
|
|
}
|
|
|
List<TechnicianVO> voList = null;
|
|
|
- if(technician.getYearAndMonth().length() == 4){
|
|
|
+ if (technician.getYearAndMonth().length() == 4) {
|
|
|
voList = baseMapper.selectByYear(technician);
|
|
|
- }else if(technician.getYearAndMonth().length() == 6){
|
|
|
+ } else if (technician.getYearAndMonth().length() == 6) {
|
|
|
voList = baseMapper.selectTechnicianPage(page, technician);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
throw new ServiceException("参数yearAndMonth只能是YYYY或YYYYmm格式");
|
|
|
}
|
|
|
return page.setRecords(voList);
|
|
|
@@ -129,7 +128,7 @@ public class TechnicianServiceImpl extends BaseServiceImpl<TechnicianMapper, Tec
|
|
|
//得到上个月的年月
|
|
|
String lastDate = DateUtil.format(DateUtil.minusMonths(DateUtil.parse(technician.getYearAndMonth(), DateUtil.PATTERN_YYYYMM), 1), DateUtil.PATTERN_YYYYMM);
|
|
|
List<TechnicianEntity> lastMonthList = this.baseMapper.selectByYearAndMonth(lastDate);
|
|
|
- if(CollectionUtil.isEmpty(lastMonthList)){
|
|
|
+ if (CollectionUtil.isEmpty(lastMonthList)) {
|
|
|
throw new ServiceException("上个月人员名单为空");
|
|
|
}
|
|
|
//与本月数据对比,去重后保存至数据库
|
|
|
@@ -152,33 +151,35 @@ public class TechnicianServiceImpl extends BaseServiceImpl<TechnicianMapper, Tec
|
|
|
|
|
|
@Transactional
|
|
|
@Override
|
|
|
- public void zhijieyinyongyusuanbiaomingdan(XmTechnicianMonthlyEntity entity) {
|
|
|
- //先根据xmId查询项目预算中的人员名单
|
|
|
- List<YsRyrgfyEntity> ysRyrgfyEntityList = ysRyrgfyMapper.selectList(Wrappers.<YsRyrgfyEntity>lambdaQuery().eq(YsRyrgfyEntity::getXmId, entity.getXmId()));
|
|
|
- if(CollectionUtil.isEmpty(ysRyrgfyEntityList)){
|
|
|
- throw new ServiceException("该项目没有填写人员人工费用预算");
|
|
|
- }
|
|
|
- List<Long> technicianIdList = ysRyrgfyEntityList.stream().map(YsRyrgfyEntity::getTechnicianId).toList();
|
|
|
- for (Long technicianId : technicianIdList) {
|
|
|
- XmTechnicianMonthlyEntity monthlyEntity = new XmTechnicianMonthlyEntity();
|
|
|
- monthlyEntity.setXmId(entity.getXmId());
|
|
|
- monthlyEntity.setTechnicianId(technicianId);
|
|
|
- monthlyEntity.setYearAndMonth(entity.getYearAndMonth());
|
|
|
- monthlyEntity.setCreateUser(SecureUtil.getUserId());
|
|
|
- monthlyEntity.setUpdateUser(SecureUtil.getUserId());
|
|
|
-
|
|
|
- LambdaQueryWrapper<XmTechnicianMonthlyEntity> wrapper = Wrappers.<XmTechnicianMonthlyEntity>lambdaQuery().
|
|
|
- eq(XmTechnicianMonthlyEntity::getYearAndMonth, entity.getYearAndMonth()).
|
|
|
- eq(XmTechnicianMonthlyEntity::getTechnicianId, technicianId).
|
|
|
- eq(XmTechnicianMonthlyEntity::getXmId, entity.getXmId());
|
|
|
- if(xmTechnicianMonthlyMapper.selectCount(wrapper) == 0) {
|
|
|
- xmTechnicianMonthlyMapper.insert(monthlyEntity);
|
|
|
+ public void zhijieyinyongyusuanbiaomingdan(XmTechnicianMonthlyDto dto) {
|
|
|
+ //遍历xmIdList,根据xmId查询项目预算中的人员名单
|
|
|
+ for (XmEntity xm : dto.getXmList()) {
|
|
|
+ List<YsRyrgfyEntity> ysRyrgfyList = ysRyrgfyMapper.selectList(Wrappers.<YsRyrgfyEntity>lambdaQuery().eq(YsRyrgfyEntity::getXmId, xm.getId()));
|
|
|
+ if (CollectionUtil.isEmpty(ysRyrgfyList)) {
|
|
|
+ throw new ServiceException("项目[" + xm.getXmmc() + "]没有填写人员人工费用预算");
|
|
|
+ }
|
|
|
+ List<Long> technicianIdList = ysRyrgfyList.stream().map(YsRyrgfyEntity::getTechnicianId).toList();
|
|
|
+ for (Long technicianId : technicianIdList) {
|
|
|
+ XmTechnicianMonthlyEntity monthlyEntity = new XmTechnicianMonthlyEntity();
|
|
|
+ monthlyEntity.setXmId(xm.getId());
|
|
|
+ monthlyEntity.setTechnicianId(technicianId);
|
|
|
+ monthlyEntity.setYearAndMonth(dto.getYearAndMonth());
|
|
|
+ monthlyEntity.setCreateUser(SecureUtil.getUserId());
|
|
|
+ monthlyEntity.setUpdateUser(SecureUtil.getUserId());
|
|
|
+
|
|
|
+ LambdaQueryWrapper<XmTechnicianMonthlyEntity> wrapper = Wrappers.<XmTechnicianMonthlyEntity>lambdaQuery().
|
|
|
+ eq(XmTechnicianMonthlyEntity::getYearAndMonth, dto.getYearAndMonth()).
|
|
|
+ eq(XmTechnicianMonthlyEntity::getTechnicianId, technicianId).
|
|
|
+ eq(XmTechnicianMonthlyEntity::getXmId, xm.getId());
|
|
|
+ if (xmTechnicianMonthlyMapper.selectCount(wrapper) == 0) {
|
|
|
+ xmTechnicianMonthlyMapper.insert(monthlyEntity);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public IPage<XmTechnicianMonthlyEntity> meiyueshijicanyuanrenyuanmingdan(XmTechnicianMonthlyEntity entity, IPage<Object> page) {
|
|
|
+ public IPage<XmTechnicianMonthlyEntity> meiyueshijicanyuanrenyuanmingdan(XmTechnicianMonthlyDto entity, IPage<Object> page) {
|
|
|
return xmTechnicianMonthlyMapper.meiyueshijicanyuanrenyuanmingdan(page, entity);
|
|
|
}
|
|
|
|
|
|
@@ -193,17 +194,17 @@ public class TechnicianServiceImpl extends BaseServiceImpl<TechnicianMapper, Tec
|
|
|
eq(XmTechnicianMonthlyEntity::getYearAndMonth, entity.getYearAndMonth()).
|
|
|
eq(XmTechnicianMonthlyEntity::getTechnicianId, entity.getTechnicianId()).
|
|
|
eq(XmTechnicianMonthlyEntity::getXmId, entity.getXmId());
|
|
|
- if(xmTechnicianMonthlyMapper.selectCount(wrapper) == 0) {
|
|
|
+ if (xmTechnicianMonthlyMapper.selectCount(wrapper) == 0) {
|
|
|
affectNum = xmTechnicianMonthlyMapper.insert(entity);
|
|
|
- }else{
|
|
|
- throw new ServiceException("科技人员已是项目在["+entity.getYearAndMonth()+"]的参研人员,请勿重复新增");
|
|
|
+ } else {
|
|
|
+ throw new ServiceException("科技人员已是项目在[" + entity.getYearAndMonth() + "]的参研人员,请勿重复新增");
|
|
|
}
|
|
|
return affectNum == 1;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public boolean physicalDeleteXmTechnicianMonthlyByIds(List<Long> ids) {
|
|
|
- if(CollectionUtil.isEmpty(ids)){
|
|
|
+ if (CollectionUtil.isEmpty(ids)) {
|
|
|
throw new ServiceException("参数不能为空");
|
|
|
}
|
|
|
return xmTechnicianMonthlyMapper.physicalDeleteXmTechnicianMonthlyByIds(ids) == ids.size();
|
|
|
@@ -215,24 +216,24 @@ public class TechnicianServiceImpl extends BaseServiceImpl<TechnicianMapper, Tec
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public IPage<TechnicianEntity> selectTechnicianPageByDateInterval(IPage<TechnicianEntity> page, HashMap<String,String> param) {
|
|
|
- if(!param.containsKey("startDate") || !param.containsKey("endDate")){
|
|
|
+ public IPage<TechnicianEntity> selectTechnicianPageByDateInterval(IPage<TechnicianEntity> page, HashMap<String, String> param) {
|
|
|
+ if (!param.containsKey("startDate") || !param.containsKey("endDate")) {
|
|
|
throw new ServiceException("startDate或者endDate为空");
|
|
|
}
|
|
|
String startDate = param.get("startDate");
|
|
|
String endDate = param.get("endDate");
|
|
|
- if(startDate.contains("-")){
|
|
|
+ if (startDate.contains("-")) {
|
|
|
startDate = startDate.replace("-", "");
|
|
|
}
|
|
|
- if(endDate.contains("-")){
|
|
|
+ if (endDate.contains("-")) {
|
|
|
endDate = endDate.replace("-", "");
|
|
|
}
|
|
|
|
|
|
- if(startDate.length() == 8){
|
|
|
- startDate = startDate.substring(0,6);
|
|
|
+ if (startDate.length() == 8) {
|
|
|
+ startDate = startDate.substring(0, 6);
|
|
|
}
|
|
|
- if(endDate.length() == 8){
|
|
|
- endDate = endDate.substring(0,6);
|
|
|
+ if (endDate.length() == 8) {
|
|
|
+ endDate = endDate.substring(0, 6);
|
|
|
}
|
|
|
param.put("startDate", startDate);
|
|
|
param.put("endDate", endDate);
|