|
@@ -5,6 +5,7 @@ import com.management.platform.entity.*;
|
|
|
import com.management.platform.mapper.*;
|
|
|
import com.management.platform.service.FinanceService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.management.platform.service.UserService;
|
|
|
import com.management.platform.util.ExcelUtil;
|
|
|
import com.management.platform.util.HttpRespMsg;
|
|
|
import com.management.platform.util.MD5Util;
|
|
@@ -52,11 +53,15 @@ public class FinanceServiceImpl extends ServiceImpl<FinanceMapper, Finance> impl
|
|
|
@Resource
|
|
|
private UserMapper userMapper;
|
|
|
@Resource
|
|
|
+ private UserService userService;
|
|
|
+ @Resource
|
|
|
private DepartmentMapper departmentMapper;
|
|
|
@Resource
|
|
|
private FinanceService financeService;
|
|
|
@Resource
|
|
|
private ProjectMapper projectMapper;
|
|
|
+ @Resource
|
|
|
+ private TimeTypeMapper timeTypeMapper;
|
|
|
@Value(value = "${upload.path}")
|
|
|
private String path;
|
|
|
|
|
@@ -103,7 +108,11 @@ public class FinanceServiceImpl extends ServiceImpl<FinanceMapper, Finance> impl
|
|
|
LocalDateTime endDate = LocalDateTime.parse(dateStr,df);
|
|
|
endDate = endDate.plusMonths(1);
|
|
|
|
|
|
+ TimeType timeType = timeTypeMapper.selectById(companyId);
|
|
|
+ BigDecimal monthHours = timeType.getMonthDays().multiply(new BigDecimal(timeType.getAllday()));
|
|
|
|
|
|
+ //需要更新成本的人员数据
|
|
|
+ List<User> updateUserList = new ArrayList<>();
|
|
|
//由于第一行需要指明列对应的标题
|
|
|
int rowNum = sheet.getLastRowNum();
|
|
|
for (int rowIndex = 0; rowIndex <= sheet.getLastRowNum(); rowIndex++) {
|
|
@@ -149,6 +158,7 @@ public class FinanceServiceImpl extends ServiceImpl<FinanceMapper, Finance> impl
|
|
|
|
|
|
Optional<User> first = first = userList.stream().filter(u -> u.getName().equals(name)).findFirst();
|
|
|
if (first.isPresent()) {
|
|
|
+
|
|
|
finance.setUserId(first.get().getId());
|
|
|
BigDecimal total = new BigDecimal(0);
|
|
|
if (salaryCell != null) {
|
|
@@ -215,6 +225,13 @@ public class FinanceServiceImpl extends ServiceImpl<FinanceMapper, Finance> impl
|
|
|
total = total.add(value);
|
|
|
}
|
|
|
finance.setTotalCost(total);
|
|
|
+
|
|
|
+ //设置人员总成本,计算时薪
|
|
|
+ User localUser = new User();
|
|
|
+ localUser.setId(finance.getUserId());
|
|
|
+ localUser.setMonthCost(total);
|
|
|
+ localUser.setCost(total.divide(monthHours, 2, BigDecimal.ROUND_HALF_UP));
|
|
|
+ updateUserList.add(localUser);
|
|
|
} else {
|
|
|
msg.setError("用户["+name+"]不存在,请在组织结构中添加该成员");
|
|
|
return msg;
|
|
@@ -226,6 +243,12 @@ public class FinanceServiceImpl extends ServiceImpl<FinanceMapper, Finance> impl
|
|
|
|
|
|
//批量插入
|
|
|
financeService.saveOrUpdateBatch(financeList);
|
|
|
+ userService.updateBatchById(updateUserList);
|
|
|
+
|
|
|
+ //同步个人的成本为财务上传的成本
|
|
|
+ financeList.stream().forEach(f->{
|
|
|
+
|
|
|
+ });
|
|
|
|
|
|
//检查是否有删除的,需要删除掉
|
|
|
List<Integer> readyForDelete = new ArrayList<>();
|