|
@@ -191,15 +191,25 @@ public class FinanceServiceImpl extends ServiceImpl<FinanceMapper, Finance> impl
|
|
|
if (ExcelUtil.isRowEmpty(row)) {
|
|
|
continue;
|
|
|
}
|
|
|
- //姓名 工资 奖金 津贴 养老保险 医疗保险 失业保险 (新增工伤保险) 住房公积金 其他; 可能有自定义的项
|
|
|
- Cell nameCell = row.getCell(0);
|
|
|
- Cell salaryCell = row.getCell(1);
|
|
|
- Cell bonusCell = row.getCell(2);
|
|
|
- Cell allowanceCell = row.getCell(3);
|
|
|
- Cell inOldCell = row.getCell(4);
|
|
|
- Cell inMedicalCell = row.getCell(5);
|
|
|
- Cell inJobCell = row.getCell(6);
|
|
|
- Cell injuryCell = row.getCell(7);
|
|
|
+ //(工号-可配置) 姓名 工资 奖金 津贴 养老保险 医疗保险 失业保险 (新增工伤保险) 住房公积金 其他; 可能有自定义的项
|
|
|
+
|
|
|
+ Cell jobNumberCell = null;
|
|
|
+ int nameStartIndex = 0;
|
|
|
+ //是否配置了工号模式的模板
|
|
|
+ boolean includeJobNumber = (timeType.getFinanceJobnumEnabled() == 1);
|
|
|
+ if (includeJobNumber) {
|
|
|
+ jobNumberCell = row.getCell(0);
|
|
|
+ jobNumberCell.setCellType(CellType.STRING);
|
|
|
+ nameStartIndex = 1;
|
|
|
+ }
|
|
|
+ Cell nameCell = row.getCell(nameStartIndex + 0);
|
|
|
+ Cell salaryCell = row.getCell(nameStartIndex + 1);
|
|
|
+ Cell bonusCell = row.getCell(nameStartIndex + 2);
|
|
|
+ Cell allowanceCell = row.getCell(nameStartIndex + 3);
|
|
|
+ Cell inOldCell = row.getCell(nameStartIndex + 4);
|
|
|
+ Cell inMedicalCell = row.getCell(nameStartIndex + 5);
|
|
|
+ Cell inJobCell = row.getCell(nameStartIndex + 6);
|
|
|
+ Cell injuryCell = row.getCell(nameStartIndex + 7);
|
|
|
|
|
|
nameCell.setCellType(CellType.STRING);
|
|
|
|
|
@@ -208,10 +218,10 @@ public class FinanceServiceImpl extends ServiceImpl<FinanceMapper, Finance> impl
|
|
|
if (name.equals("姓名") && rowIndex == 0) {
|
|
|
continue;
|
|
|
}
|
|
|
- Cell houseFundCell = row.getCell(8);
|
|
|
- Cell field1 = cusColList.size() > 0?row.getCell(9):null;
|
|
|
- Cell field2 = cusColList.size() > 1?row.getCell(10):null;
|
|
|
- Cell field3 = cusColList.size() > 2?row.getCell(11):null;
|
|
|
+ Cell houseFundCell = row.getCell(nameStartIndex + 8);
|
|
|
+ Cell field1 = cusColList.size() > 0?row.getCell(nameStartIndex + 9):null;
|
|
|
+ Cell field2 = cusColList.size() > 1?row.getCell(nameStartIndex + 10):null;
|
|
|
+ Cell field3 = cusColList.size() > 2?row.getCell(nameStartIndex + 11):null;
|
|
|
|
|
|
if (field1 != null)field1.setCellType(CellType.STRING);
|
|
|
if (field2 != null)field2.setCellType(CellType.STRING);
|
|
@@ -219,8 +229,13 @@ public class FinanceServiceImpl extends ServiceImpl<FinanceMapper, Finance> impl
|
|
|
|
|
|
finance.setCompanyId(companyId);
|
|
|
finance.setName(name);
|
|
|
+ if (includeJobNumber) {
|
|
|
+ finance.setJobNumber(jobNumberCell.getStringCellValue());
|
|
|
+ }
|
|
|
|
|
|
- Optional<User> first = userList.stream().filter(u -> u.getName().equals(name)).findFirst();
|
|
|
+ Optional<User> first = userList.stream().filter(u -> includeJobNumber?
|
|
|
+ u.getJobNumber() != null && u.getJobNumber().equals(finance.getJobNumber())
|
|
|
+ :u.getName().equals(name)).findFirst();
|
|
|
if (first.isPresent()) {
|
|
|
finance.setUserId(first.get().getId());
|
|
|
BigDecimal total = new BigDecimal(0);
|
|
@@ -232,8 +247,8 @@ public class FinanceServiceImpl extends ServiceImpl<FinanceMapper, Finance> impl
|
|
|
if (financeConfig.getMonthCostCalculate()==1) total = total.add(value);
|
|
|
}
|
|
|
|
|
|
- //按姓名做匹配
|
|
|
- Optional<Finance> matchItem = oldFinanceList.stream().filter(o -> o.getName().equals(finance.getName())).findFirst();
|
|
|
+ //按UserId做匹配
|
|
|
+ Optional<Finance> matchItem = oldFinanceList.stream().filter(o -> o.getUserId().equals(finance.getUserId())).findFirst();
|
|
|
if (matchItem.isPresent()) {
|
|
|
finance.setId(matchItem.get().getId());
|
|
|
}
|
|
@@ -329,7 +344,11 @@ public class FinanceServiceImpl extends ServiceImpl<FinanceMapper, Finance> impl
|
|
|
updateUserList.add(localUser);
|
|
|
}
|
|
|
} else {
|
|
|
- msg.setError("用户["+name+"]不存在,请在组织结构中添加该成员");
|
|
|
+ if (includeJobNumber) {
|
|
|
+ msg.setError("用户["+name+","+finance.getJobNumber()+"]不存在,请在组织结构中添加该成员");
|
|
|
+ } else {
|
|
|
+ msg.setError("用户["+name+"]不存在,请在组织结构中添加该成员");
|
|
|
+ }
|
|
|
return msg;
|
|
|
}
|
|
|
finance.setYmonth(yearMonth);
|
|
@@ -351,25 +370,11 @@ public class FinanceServiceImpl extends ServiceImpl<FinanceMapper, Finance> impl
|
|
|
User user1 = new User();
|
|
|
user1.setId(upU.getId());
|
|
|
user1.setMonthCost(upU.getMonthCost());
|
|
|
- user1.setCost(upU.getMonthCost().divide(db,2, BigDecimal.ROUND_HALF_UP));
|
|
|
+ user1.setCost(upU.getMonthCost().divide(db,4, BigDecimal.ROUND_HALF_UP));
|
|
|
dbUpUserList.add(user1);
|
|
|
}
|
|
|
userService.updateBatchById(dbUpUserList);
|
|
|
}
|
|
|
- //修改成每次上传都新增更新,不删除。 前端界面增加删除功能。
|
|
|
-// List<Integer> readyForDelete = new ArrayList<>();
|
|
|
-// oldFinanceList.forEach(old->{
|
|
|
-// boolean exists = false;
|
|
|
-// if (financeList.stream().filter(f->f.getName().equals(old.getName())).findAny().isPresent()) {
|
|
|
-// exists = true;
|
|
|
-// }
|
|
|
-// if (!exists) {
|
|
|
-// readyForDelete.add(old.getId());
|
|
|
-// }
|
|
|
-// });
|
|
|
-// if (readyForDelete.size() > 0) {
|
|
|
-// financeService.removeByIds(readyForDelete);
|
|
|
-// }
|
|
|
//如果有必要,更新该月份的日报相关的成本
|
|
|
if (syncHistoryReport) {
|
|
|
List<Report> reportList = reportMapper.selectSimpleTime(companyId, startStr, endStr);
|
|
@@ -394,7 +399,6 @@ public class FinanceServiceImpl extends ServiceImpl<FinanceMapper, Finance> impl
|
|
|
|
|
|
//保存导入记录
|
|
|
String originName = fileName;
|
|
|
- System.out.println("fileName=="+originName);
|
|
|
String[] names = originName.split("\\.");
|
|
|
String destFileName = names[0] + "_"+System.currentTimeMillis()+"."+names[1];
|
|
|
String financeFolder = "finance";
|
|
@@ -431,7 +435,6 @@ public class FinanceServiceImpl extends ServiceImpl<FinanceMapper, Finance> impl
|
|
|
} catch (IOException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
-// file.deleteOnExit();//程序退出时删除临时文件
|
|
|
System.out.println(file.delete());
|
|
|
}
|
|
|
return msg;
|