|
|
@@ -1,25 +1,24 @@
|
|
|
|
|
|
package org.sky.scientific.service.impl;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import jakarta.annotation.Resource;
|
|
|
-import org.sky.core.log.exception.ServiceException;
|
|
|
+import org.sky.core.mp.base.BaseServiceImpl;
|
|
|
import org.sky.core.secure.utils.AuthUtil;
|
|
|
import org.sky.core.tool.utils.DateUtil;
|
|
|
import org.sky.core.tool.utils.StringUtil;
|
|
|
+import org.sky.scientific.excel.SalaryExcel;
|
|
|
+import org.sky.scientific.mapper.SalaryMapper;
|
|
|
import org.sky.scientific.mapper.TechnicianMapper;
|
|
|
import org.sky.scientific.pojo.entity.SalaryEntity;
|
|
|
-import org.sky.scientific.pojo.entity.TechnicianEntity;
|
|
|
import org.sky.scientific.pojo.vo.SalaryVO;
|
|
|
-import org.sky.scientific.excel.SalaryExcel;
|
|
|
-import org.sky.scientific.mapper.SalaryMapper;
|
|
|
import org.sky.scientific.service.ISalaryService;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
|
-import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
-import org.sky.core.mp.base.BaseServiceImpl;
|
|
|
+
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
|
@@ -39,7 +38,7 @@ public class SalaryServiceImpl extends BaseServiceImpl<SalaryMapper, SalaryEntit
|
|
|
List<SalaryVO> voList = baseMapper.selectSalaryPage(page, salary);
|
|
|
//如果数据空,则查询该年度整体是否有数据
|
|
|
// if (voList.isEmpty()) {
|
|
|
-// LambdaQueryWrapper<SalaryEntity> wrapper = Wrappers.<SalaryEntity>query().lambda()
|
|
|
+// LambdaQueryWrapper<SalaryEntity> wrapper = Wrappers.<SalaryEntity>query ().lambda()
|
|
|
// .eq(SalaryEntity::getYearAndMonth, salary.getYearAndMonth())
|
|
|
// .eq(SalaryEntity::getTenantId, AuthUtil.getTenantId())
|
|
|
// .eq(SalaryEntity::getIsDeleted, 0);
|
|
|
@@ -66,41 +65,69 @@ public class SalaryServiceImpl extends BaseServiceImpl<SalaryMapper, SalaryEntit
|
|
|
|
|
|
Integer affectNum = 0;
|
|
|
if (StringUtil.isBlank(salary.getYearAndMonth())) {
|
|
|
- salary.setYearAndMonth(DateUtil.format(DateUtil.now(), "yyyy"));
|
|
|
- }
|
|
|
- //从技术人员花名册中根据年份和人员信息,查询人员是否存在
|
|
|
- TechnicianEntity technician = new TechnicianEntity();
|
|
|
- technician.setYearAndMonth(salary.getYearAndMonth());
|
|
|
- technician.setNumber(salary.getNumber());
|
|
|
- technician.setIdentityCard(salary.getIdentityCard());
|
|
|
- technician.setTenantId(AuthUtil.getTenantId());
|
|
|
- Integer countWithTechnician = technicianMapper.countByDateAndNumberOrIdentityCard(technician);
|
|
|
- //不存在则抛出异常
|
|
|
- if(countWithTechnician == 0){
|
|
|
- throw new ServiceException("[" + salary.getYearAndMonth() + "]年度内无人员[" + salary.getName() + "、" + salary.getNumber() + "、" + salary.getIdentityCard() + "]");
|
|
|
- }else {
|
|
|
- //存在则根据年份和人员信息查询工资是否存在
|
|
|
- LambdaQueryWrapper<SalaryEntity> wrapper = Wrappers.<SalaryEntity>query().lambda()
|
|
|
- .eq(SalaryEntity::getYearAndMonth, salary.getYearAndMonth())
|
|
|
- .eq(SalaryEntity::getNumber, salary.getNumber())
|
|
|
- .eq(SalaryEntity::getIdentityCard, salary.getIdentityCard())
|
|
|
- .eq(SalaryEntity::getTenantId, AuthUtil.getTenantId())
|
|
|
- .eq(SalaryEntity::getIsDeleted, 0);
|
|
|
- //存在则覆盖
|
|
|
- if (baseMapper.selectCount(wrapper) > 0) {
|
|
|
- LambdaUpdateWrapper<SalaryEntity> updateWrapper = Wrappers.<SalaryEntity>update().lambda()
|
|
|
- .eq(SalaryEntity::getYearAndMonth, salary.getYearAndMonth())
|
|
|
- .eq(SalaryEntity::getNumber, salary.getNumber())
|
|
|
- .eq(SalaryEntity::getIdentityCard, salary.getIdentityCard())
|
|
|
- .eq(SalaryEntity::getTenantId, AuthUtil.getTenantId())
|
|
|
- .eq(SalaryEntity::getIsDeleted, 0);
|
|
|
- affectNum = baseMapper.update(salary, updateWrapper);
|
|
|
- }else {
|
|
|
- //不存在则新增
|
|
|
- affectNum = baseMapper.insert(salary);
|
|
|
- }
|
|
|
+ salary.setYearAndMonth(DateUtil.format(DateUtil.now(), DateUtil.PATTERN_YYYY));
|
|
|
}
|
|
|
+// //从技术人员花名册中根据年份和人员信息,查询人员是否存在
|
|
|
+// TechnicianEntity technician = new TechnicianEntity();
|
|
|
+// technician.setYearAndMonth(salary.getYearAndMonth());
|
|
|
+// technician.setNumber(salary.getNumber());
|
|
|
+// technician.setIdentityCard(salary.getIdentityCard());
|
|
|
+// technician.setTenantId(AuthUtil.getTenantId());
|
|
|
+// Integer countWithTechnician = technicianMapper.selectPrimaryByDateAndNumberOrIdentityCard(technician);
|
|
|
+// //不存在则抛出异常
|
|
|
+// if(countWithTechnician == 0){
|
|
|
+// throw new ServiceException("[" + salary.getYearAndMonth() + "]年度内无人员[" + salary.getName() + "、" + salary.getNumber() + "、" + salary.getIdentityCard() + "]");
|
|
|
+// }else {
|
|
|
+// //存在则根据年份和人员信息查询工资是否存在
|
|
|
+// LambdaQueryWrapper<SalaryEntity> wrapper = Wrappers.<SalaryEntity>query().lambda()
|
|
|
+// .eq(SalaryEntity::getYearAndMonth, salary.getYearAndMonth())
|
|
|
+// .eq(SalaryEntity::getNumber, salary.getNumber())
|
|
|
+// .eq(SalaryEntity::getIdentityCard, salary.getIdentityCard())
|
|
|
+// .eq(SalaryEntity::getTenantId, AuthUtil.getTenantId())
|
|
|
+// .eq(SalaryEntity::getIsDeleted, 0);
|
|
|
+// //存在则覆盖
|
|
|
+// if (baseMapper.selectCount(wrapper) > 0) {
|
|
|
+// LambdaUpdateWrapper<SalaryEntity> updateWrapper = Wrappers.<SalaryEntity>update().lambda()
|
|
|
+// .eq(SalaryEntity::getYearAndMonth, salary.getYearAndMonth())
|
|
|
+// .eq(SalaryEntity::getNumber, salary.getNumber())
|
|
|
+// .eq(SalaryEntity::getIdentityCard, salary.getIdentityCard())
|
|
|
+// .eq(SalaryEntity::getTenantId, AuthUtil.getTenantId())
|
|
|
+// .eq(SalaryEntity::getIsDeleted, 0);
|
|
|
+// affectNum = baseMapper.update(salary, updateWrapper);
|
|
|
+// }else {
|
|
|
+// //不存在则新增
|
|
|
+// affectNum = baseMapper.insert(salary);
|
|
|
+// }
|
|
|
+// }
|
|
|
return affectNum > 0;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public boolean updateSalary(SalaryEntity salary) {
|
|
|
+ boolean result = false;
|
|
|
+ //根据number、identityId、yearAndMonth查询工资数据,
|
|
|
+ LambdaQueryWrapper<SalaryEntity> queryWrapper = Wrappers.<SalaryEntity>lambdaQuery()
|
|
|
+ .eq(SalaryEntity::getNumber, salary.getNumber())
|
|
|
+ .eq(SalaryEntity::getIdentityCard, salary.getIdentityCard())
|
|
|
+ .eq(SalaryEntity::getYearAndMonth, salary.getYearAndMonth())
|
|
|
+ .eq(SalaryEntity::getTenantId, AuthUtil.getTenantId());
|
|
|
+ if (baseMapper.selectCount(queryWrapper) == 1) {
|
|
|
+ //存在,则修改
|
|
|
+ result = baseMapper.updateSalary(salary) == 1;
|
|
|
+ } else {
|
|
|
+ //不存在,则新增
|
|
|
+ result = this.save(salary);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean deleteSalary(List<SalaryEntity> salaryList) {
|
|
|
+ Integer affectNum = 0;
|
|
|
+ //根据number、identityId、yearAndMonth删除工资数据
|
|
|
+ for (SalaryEntity salary : salaryList) {
|
|
|
+ affectNum += baseMapper.deleteSalary(salary);
|
|
|
+ }
|
|
|
+ return affectNum == salaryList.size();
|
|
|
+ }
|
|
|
}
|