|
@@ -3,26 +3,26 @@ package com.jeeplus.test.reimbursementsys.service.impl;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.google.common.collect.Lists;
|
|
|
+import com.jeeplus.sys.service.OfficeService;
|
|
|
+import com.jeeplus.sys.service.UserService;
|
|
|
+import com.jeeplus.sys.service.dto.OfficeDTO;
|
|
|
import com.jeeplus.sys.service.dto.UserDTO;
|
|
|
import com.jeeplus.sys.utils.DictUtils;
|
|
|
import com.jeeplus.sys.utils.StringUtils;
|
|
|
import com.jeeplus.sys.utils.UserUtils;
|
|
|
-import com.jeeplus.test.reimbursementsys.domain.dto.ReimbursementAddressDTO;
|
|
|
-import com.jeeplus.test.reimbursementsys.domain.dto.ReimbursementBusinessDTO;
|
|
|
-import com.jeeplus.test.reimbursementsys.domain.dto.ReimbursementBusinessReturnDTO;
|
|
|
-import com.jeeplus.test.reimbursementsys.domain.dto.ReimbursementUserDTO;
|
|
|
+import com.jeeplus.test.reimbursementsys.domain.dto.*;
|
|
|
import com.jeeplus.test.reimbursementsys.mapper.ReimbursementBusinessMapper;
|
|
|
import com.jeeplus.test.reimbursementsys.mapper.ReimbursementUserMapper;
|
|
|
import com.jeeplus.test.reimbursementsys.service.ReimbursementUserService;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.math.BigDecimal;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.time.LocalDate;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* @author li-peike
|
|
@@ -32,6 +32,7 @@ import java.util.Map;
|
|
|
* @createTime 2022年05月06日 10:38:00
|
|
|
*/
|
|
|
@Service
|
|
|
+@Transactional(readOnly = true)
|
|
|
public class ReimbursementUserServiceImpl implements ReimbursementUserService {
|
|
|
|
|
|
@Resource
|
|
@@ -40,6 +41,12 @@ public class ReimbursementUserServiceImpl implements ReimbursementUserService {
|
|
|
@Resource
|
|
|
private ReimbursementBusinessMapper businessMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private OfficeService officeService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private UserService userService;
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
public ReimbursementUserDTO queryById(String id) {
|
|
@@ -65,6 +72,7 @@ public class ReimbursementUserServiceImpl implements ReimbursementUserService {
|
|
|
* @param reimbursementUser
|
|
|
*/
|
|
|
@Override
|
|
|
+ @Transactional(readOnly = false)
|
|
|
public Map<String,Object> save(ReimbursementUserDTO reimbursementUser) {
|
|
|
Map<String,Object> map = new HashMap<>();
|
|
|
|
|
@@ -122,11 +130,13 @@ public class ReimbursementUserServiceImpl implements ReimbursementUserService {
|
|
|
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional(readOnly = false)
|
|
|
public void update(ReimbursementUserDTO reimbursementUser) {
|
|
|
mapper.update(reimbursementUser);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional(readOnly = false)
|
|
|
public Map<String,Object> delete(List<String> idList) {
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
if(idList.size()>0) {
|
|
@@ -161,6 +171,7 @@ public class ReimbursementUserServiceImpl implements ReimbursementUserService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional(readOnly = false)
|
|
|
public Map<String,Object> deleteWuHan(List<String> idList) {
|
|
|
Map<String,Object> map = new HashMap<>();
|
|
|
List<String> userName = Lists.newArrayList();
|
|
@@ -308,6 +319,7 @@ public class ReimbursementUserServiceImpl implements ReimbursementUserService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional(readOnly = false)
|
|
|
public Map<String, Object> saveList(List<ReimbursementUserDTO> reimbursementUserList) {
|
|
|
|
|
|
List<ReimbursementUserDTO> saveList = Lists.newArrayList();
|
|
@@ -378,6 +390,92 @@ public class ReimbursementUserServiceImpl implements ReimbursementUserService {
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ @Transactional(readOnly = false)
|
|
|
+ public Map<String, Object> initialize(String officeName) {
|
|
|
+ Map<String,Object> map = new HashMap<>();
|
|
|
+ //根据部门名称 查询所属部门
|
|
|
+ List<OfficeDTO> officeListByOfficeName = officeService.getOfficeAllByOfficeName(officeName);
|
|
|
+ //如果不存在该部门,则进行抛出
|
|
|
+ if(officeListByOfficeName.size() == 0){
|
|
|
+ map.put("success", false);
|
|
|
+ map.put("message", "未查询到部门信息。");
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+ //查询部门下所有有效人员信息
|
|
|
+ List<String> officeIds = Lists.newArrayList();
|
|
|
+ for (OfficeDTO office : officeListByOfficeName) {
|
|
|
+ officeIds.add(office.getId());
|
|
|
+ }
|
|
|
+ List<UserDTO> officeUserList = userService.getUserByOfficeIds(officeIds);
|
|
|
+ //根据部门人员查询数据库中已存在的人员信息
|
|
|
+ if(officeUserList.size()>0){
|
|
|
+ List<String> userIdList = Lists.newArrayList();
|
|
|
+ for (UserDTO user : officeUserList) {
|
|
|
+ userIdList.add(user.getId());
|
|
|
+ }
|
|
|
+ //获取当前年份
|
|
|
+ Calendar date = Calendar.getInstance();
|
|
|
+ String year = String.valueOf(date.get(Calendar.YEAR));
|
|
|
+
|
|
|
+ //根据人员id集合和年份查询已存在的人员信息
|
|
|
+ List<ReimbursementUserDTO> existReimbursementUserList = mapper.getExistReimbursementUserList(userIdList, year);
|
|
|
+
|
|
|
+ //排除已存在的人员信息
|
|
|
+ for (ReimbursementUserDTO existReimbursementUser: existReimbursementUserList) {
|
|
|
+ Iterator iterator = officeUserList.iterator();
|
|
|
+ while (iterator.hasNext()) {
|
|
|
+ UserDTO data = (UserDTO) iterator.next();
|
|
|
+ if (existReimbursementUser.getUserId().equals(data.getId())){
|
|
|
+ iterator.remove();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(officeUserList.size()>0){
|
|
|
+ //获取日报销额度
|
|
|
+ String reimbursementQuotaDay = DictUtils.getDictLabel("1", "reimbursement_quota_day", null);
|
|
|
+ //获取当年度的总天数
|
|
|
+ int yearDay = LocalDate.now().lengthOfYear();
|
|
|
+ //获取年度休假天数
|
|
|
+ String holidayDay = DictUtils.getDictLabel("1", "reimbursement_holiday_day", null);
|
|
|
+ Integer reimbursementAllDay = yearDay;
|
|
|
+ if(StringUtils.isNotBlank(holidayDay)){
|
|
|
+ int i = Integer.parseInt(holidayDay);
|
|
|
+ reimbursementAllDay = yearDay - Integer.parseInt(holidayDay);
|
|
|
+ }
|
|
|
+ //日报销额度
|
|
|
+ BigDecimal reimbursementQuotaDayB = new BigDecimal(reimbursementQuotaDay);
|
|
|
+ //年可报销天数
|
|
|
+ BigDecimal reimbursementAllDayB = new BigDecimal(reimbursementAllDay);
|
|
|
+ //计算并赋值年报销额度
|
|
|
+ BigDecimal reimbursementQuotaB = reimbursementQuotaDayB.multiply(reimbursementAllDayB);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ List<ReimbursementUserDTO> userInfoList = Lists.newArrayList();
|
|
|
+
|
|
|
+ //将不存在数据库中的人员信息进行批量添加
|
|
|
+ for (UserDTO user : officeUserList) {
|
|
|
+ ReimbursementUserDTO userInfo = new ReimbursementUserDTO();
|
|
|
+ userInfo.setYear(year);
|
|
|
+ userInfo.setUserId(user.getId());
|
|
|
+ userInfo.setReimbursementQuotaDay(reimbursementQuotaDay);
|
|
|
+ userInfo.setReimbursementAllDay(reimbursementAllDay);
|
|
|
+ userInfo.setReimbursementQuota(reimbursementQuotaB.toString());
|
|
|
+ userInfo.preInsert();
|
|
|
+ userInfoList.add(userInfo);
|
|
|
+ }
|
|
|
+ mapper.saveList(userInfoList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ map.put("success", true);
|
|
|
+ map.put("message", "人员初始化成功");
|
|
|
+
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 文件数据分组
|