|
@@ -62,19 +62,26 @@ public class FinanceImportServiceImpl extends ServiceImpl<FinanceImportMapper, F
|
|
|
private UserService userService;
|
|
|
@Resource
|
|
|
private ReportService reportService;
|
|
|
+ @Resource
|
|
|
+ private FinanceFixedcolnameMapper financeFixedcolnameMapper;
|
|
|
|
|
|
|
|
|
@Override
|
|
|
@Transactional
|
|
|
- public HttpRespMsg submitImport(Integer companyId, String yearMonth, Boolean syncUserCost, Boolean syncHistoryReport, MultipartFile multipartFile, HttpServletRequest request) {
|
|
|
+ public HttpRespMsg submitImport(Integer companyId, String yearMonth, Boolean syncUserCost, Boolean syncHistoryReport,
|
|
|
+ MultipartFile multipartFile, Boolean isVerification,HttpServletRequest request) {
|
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
|
User user = userMapper.selectById(request.getHeader("TOKEN"));
|
|
|
//检查当月是否已经存在审核通过的
|
|
|
- FinanceImport oldItem = financeImportMapper.selectOne(new QueryWrapper<FinanceImport>().eq("company_id", companyId).eq("ymonth", yearMonth).orderByDesc("indate").last("limit 1"));
|
|
|
+ FinanceImport oldItem = financeImportMapper.selectOne(new QueryWrapper<FinanceImport>().eq("company_id", companyId).eq("ymonth", yearMonth).eq("is_verification", isVerification).orderByDesc("indate").last("limit 1"));
|
|
|
if (oldItem != null) {
|
|
|
if (oldItem.getState() == 1) {
|
|
|
//msg.setError(yearMonth+"月薪资已审核通过,无法上传。");
|
|
|
- msg.setError(MessageUtils.message("salary.uploadErrorByAdopt"));
|
|
|
+ if (oldItem.getIsVerification()) {
|
|
|
+ msg.setError(yearMonth + "核销数据已审核通过,无法上传。");
|
|
|
+ } else {
|
|
|
+ msg.setError(yearMonth + MessageUtils.message("salary.uploadErrorByAdopt"));
|
|
|
+ }
|
|
|
return msg;
|
|
|
} else {
|
|
|
if (oldItem.getState() == 0) {
|
|
@@ -159,7 +166,7 @@ public class FinanceImportServiceImpl extends ServiceImpl<FinanceImportMapper, F
|
|
|
}
|
|
|
|
|
|
//如果有必要,更新该月份的日报相关的成本
|
|
|
- if (syncHistoryReport) {
|
|
|
+ if (syncHistoryReport && !isVerification) {
|
|
|
List<Report> reportList = reportMapper.selectSimpleTime(companyId, startStr, endStr);
|
|
|
if (reportList.size() > 0) {
|
|
|
for (Report r : reportList) {
|
|
@@ -226,6 +233,7 @@ public class FinanceImportServiceImpl extends ServiceImpl<FinanceImportMapper, F
|
|
|
log.setYmonth(yearMonth);
|
|
|
log.setRecoverMonthcost(syncUserCost?1:0);
|
|
|
log.setRecoverReport(syncHistoryReport?1:0);
|
|
|
+ log.setIsVerification(isVerification);
|
|
|
financeImportMapper.insert(log);
|
|
|
} catch (IOException e) {
|
|
|
e.printStackTrace();
|
|
@@ -289,14 +297,7 @@ public class FinanceImportServiceImpl extends ServiceImpl<FinanceImportMapper, F
|
|
|
List<Finance> financeList = new ArrayList<Finance>();
|
|
|
List<Finance> oldFinanceList = financeMapper.selectList(new QueryWrapper<Finance>().eq("company_id", companyId).eq("ymonth", yearMonth));
|
|
|
//获取月成本列表
|
|
|
- DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
- String dateStr = yearMonth+"-01 00:00:00";
|
|
|
- LocalDateTime startDate = LocalDateTime.parse(dateStr,df);
|
|
|
- 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<>();
|
|
@@ -308,9 +309,16 @@ public class FinanceImportServiceImpl extends ServiceImpl<FinanceImportMapper, F
|
|
|
if (financeImport.getRecoverMonthcost()==1 || financeImport.getRecoverReport()==1) {
|
|
|
userTimeList = reportMapper.getUserWorkingTimeByRange(companyId, startStr, endStr);
|
|
|
}
|
|
|
-
|
|
|
+// List<FinanceFixedcolname> fixedcolnameList = financeFixedcolnameMapper.selectList(new QueryWrapper<FinanceFixedcolname>().eq("company_id", companyId));
|
|
|
List<FinanceTblcuscol> cusColList = financeTblcuscolMapper.selectList(new QueryWrapper<FinanceTblcuscol>().eq("company_id", companyId));
|
|
|
FinanceFixedcolname financeConfig = financeFixedcolnameService.getFixed(companyId);
|
|
|
+ int verCusColIndex = 0;
|
|
|
+ for (int i = 0; i < cusColList.size(); i++) {
|
|
|
+ if ("奖金核销".equals(cusColList.get(i).getFieldName())) {
|
|
|
+ verCusColIndex = i ;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
if (cusColList.size() > 0) {
|
|
|
financeConfig.setField1(cusColList.get(0).getFieldName());
|
|
|
financeConfig.setField1Calculate(cusColList.get(0).getNeedCalculate());
|
|
@@ -353,6 +361,7 @@ public class FinanceImportServiceImpl extends ServiceImpl<FinanceImportMapper, F
|
|
|
if ((name.equals("姓名") || name.equals("name")) && 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;
|
|
@@ -389,109 +398,174 @@ public class FinanceImportServiceImpl extends ServiceImpl<FinanceImportMapper, F
|
|
|
Optional<Finance> matchItem = oldFinanceList.stream().filter(o -> o.getName().equals(finance.getName())).findFirst();
|
|
|
if (matchItem.isPresent()) {
|
|
|
finance.setId(matchItem.get().getId());
|
|
|
+ finance.setTotalCost(matchItem.get().getTotalCost());
|
|
|
+ } else {
|
|
|
+ throw new Exception("当前月份该员工:"+name+"尚无月薪记录,无法核销");
|
|
|
}
|
|
|
+ if (oldItem.getIsVerification()) {
|
|
|
+ finance.setMonthCost(null);
|
|
|
+ BigDecimal value = null;
|
|
|
+ BigDecimal oldValue = null;
|
|
|
+ //奖金核销导入,只更新核销部分
|
|
|
+ if (verCusColIndex == 0 && field1 != null) {
|
|
|
+ field1.setCellType(CellType.STRING);
|
|
|
+ String item = field1.getStringCellValue();
|
|
|
+ value = !StringUtil.isEmpty(item) ? new BigDecimal(item.trim().replaceAll("\\u00a0", "")) : BigDecimal.valueOf(0);
|
|
|
+ finance.setCustomField1(value);
|
|
|
+ oldValue = matchItem.get().getCustomField1();
|
|
|
+ }
|
|
|
+ else if (verCusColIndex == 1 && field2 != null) {
|
|
|
+ field2.setCellType(CellType.STRING);
|
|
|
+ String item = field2.getStringCellValue();
|
|
|
+ value = !StringUtil.isEmpty(item) ? new BigDecimal(item.trim().replaceAll("\\u00a0", "")) : BigDecimal.valueOf(0);
|
|
|
+ finance.setCustomField2(value);
|
|
|
+ oldValue = matchItem.get().getCustomField2();
|
|
|
+ }
|
|
|
+ else if (verCusColIndex == 2 && field3 != null) {
|
|
|
+ field3.setCellType(CellType.STRING);
|
|
|
+ String item = field3.getStringCellValue();
|
|
|
+ value = !StringUtil.isEmpty(item)? new BigDecimal(item.trim().replaceAll("\\u00a0", "")) : BigDecimal.valueOf(0);
|
|
|
+ finance.setCustomField3(value);
|
|
|
+ oldValue = matchItem.get().getCustomField3();
|
|
|
+ }
|
|
|
+ else if (verCusColIndex == 3 && field4 != null) {
|
|
|
+ field4.setCellType(CellType.STRING);
|
|
|
+ String item = field4.getStringCellValue();
|
|
|
+ value = !StringUtil.isEmpty(item)? new BigDecimal(item.trim().replaceAll("\\u00a0", "")) : BigDecimal.valueOf(0);
|
|
|
+ finance.setCustomField4(value);
|
|
|
+ oldValue = matchItem.get().getCustomField4();
|
|
|
+ }
|
|
|
+ else if (verCusColIndex == 4 && field5 != null) {
|
|
|
+ field5.setCellType(CellType.STRING);
|
|
|
+ String item = field5.getStringCellValue();
|
|
|
+ value = !StringUtil.isEmpty(item)? new BigDecimal(item.trim().replaceAll("\\u00a0", "")) : BigDecimal.valueOf(0);
|
|
|
+ finance.setCustomField5(value);
|
|
|
+ oldValue = matchItem.get().getCustomField5();
|
|
|
+ }
|
|
|
+ else if (verCusColIndex == 5 && field6 != null) {
|
|
|
+ field6.setCellType(CellType.STRING);
|
|
|
+ String item = field6.getStringCellValue();
|
|
|
+ value = !StringUtil.isEmpty(item)? new BigDecimal(item.trim().replaceAll("\\u00a0", "")) : BigDecimal.valueOf(0);
|
|
|
+ finance.setCustomField6(value);
|
|
|
+ oldValue = matchItem.get().getCustomField6();
|
|
|
+ }
|
|
|
+ else if (verCusColIndex == 6 && field7 != null) {
|
|
|
+ field7.setCellType(CellType.STRING);
|
|
|
+ String item = field7.getStringCellValue();
|
|
|
+ value = !StringUtil.isEmpty(item)? new BigDecimal(item.trim().replaceAll("\\u00a0", "")) : BigDecimal.valueOf(0);
|
|
|
+ finance.setCustomField7(value);
|
|
|
+ oldValue = matchItem.get().getCustomField7();
|
|
|
+ }
|
|
|
+ //更新total,扣除掉奖金(先回退掉之前扣除的)
|
|
|
+ BigDecimal bg = finance.getTotalCost();
|
|
|
+ if (oldValue != null) {
|
|
|
+ bg = bg.subtract(oldValue);
|
|
|
+ }
|
|
|
+ finance.setTotalCost(bg.add(value));
|
|
|
+ total = finance.getTotalCost();
|
|
|
+ } else {
|
|
|
+ //常规月薪导入
|
|
|
+ if (bonusCell != null) {
|
|
|
+ bonusCell.setCellType(CellType.STRING);
|
|
|
+ String bonusString = bonusCell.getStringCellValue();
|
|
|
+ BigDecimal bonus = !StringUtil.isEmpty(bonusString) ? new BigDecimal(bonusString.trim().replaceAll("\\u00a0", "")) : BigDecimal.valueOf(0);
|
|
|
+ finance.setBonus(bonus);
|
|
|
+ if (financeConfig.getBonusCalculate()==1) total = total.add(bonus);
|
|
|
+ }
|
|
|
+ if (allowanceCell != null) {
|
|
|
+ allowanceCell.setCellType(CellType.STRING);
|
|
|
+ String item = allowanceCell.getStringCellValue();
|
|
|
+ BigDecimal value = !StringUtil.isEmpty(item) ? new BigDecimal(item.trim().replaceAll("\\u00a0", "")) : BigDecimal.valueOf(0);
|
|
|
+ finance.setAllowance(value);
|
|
|
+ if (financeConfig.getAllowanceCalculate()==1) total = total.add(value);
|
|
|
+ }
|
|
|
+ if (inJobCell != null) {
|
|
|
+ inJobCell.setCellType(CellType.STRING);
|
|
|
+ String item = inJobCell.getStringCellValue();
|
|
|
+ BigDecimal value = !StringUtil.isEmpty(item) ? new BigDecimal(item.trim().replaceAll("\\u00a0", "")) : BigDecimal.valueOf(0);
|
|
|
+ finance.setInsuranceLosejob(value);
|
|
|
+ if (financeConfig.getInsuranceLosejobCalculate()==1) total = total.add(value);
|
|
|
+ }
|
|
|
+ if (inMedicalCell != null) {
|
|
|
+ inMedicalCell.setCellType(CellType.STRING);
|
|
|
+ String item = inMedicalCell.getStringCellValue();
|
|
|
+ BigDecimal value = !StringUtil.isEmpty(item) ? new BigDecimal(item.trim().replaceAll("\\u00a0", "")) : BigDecimal.valueOf(0);
|
|
|
+ finance.setInsuranceMedical(value);
|
|
|
+ if (financeConfig.getInsuranceMedicalCalculate()==1) total = total.add(value);
|
|
|
+ }
|
|
|
+ if (inOldCell != null) {
|
|
|
+ inOldCell.setCellType(CellType.STRING);
|
|
|
+ String item = inOldCell.getStringCellValue();
|
|
|
+ BigDecimal value = !StringUtil.isEmpty(item) ? new BigDecimal(item.trim().replaceAll("\\u00a0", "")) : BigDecimal.valueOf(0);
|
|
|
+ finance.setInsuranceOld(value);
|
|
|
+ if (financeConfig.getInsuranceOldCalculate()==1) total = total.add(value);
|
|
|
+ }
|
|
|
+ if (injuryCell != null) {
|
|
|
+ injuryCell.setCellType(CellType.STRING);
|
|
|
+ String item = injuryCell.getStringCellValue();
|
|
|
+ BigDecimal value = !StringUtil.isEmpty(item) ? new BigDecimal(item.trim().replaceAll("\\u00a0", "")) : BigDecimal.valueOf(0);
|
|
|
+ finance.setInsuranceInjury(value);
|
|
|
+ if (financeConfig.getInsuranceInjuryCalculate()==1) total = total.add(value);
|
|
|
+ }
|
|
|
+ if (houseFundCell != null) {
|
|
|
+ houseFundCell.setCellType(CellType.STRING);
|
|
|
+ String item = houseFundCell.getStringCellValue();
|
|
|
+ BigDecimal value = !StringUtil.isEmpty(item) ? new BigDecimal(item.trim().replaceAll("\\u00a0", "")) : BigDecimal.valueOf(0);
|
|
|
+ finance.setHouseFund(value);
|
|
|
+ if (financeConfig.getHouseFundCalculate()==1) total = total.add(value);
|
|
|
+ }
|
|
|
|
|
|
- if (bonusCell != null) {
|
|
|
- bonusCell.setCellType(CellType.STRING);
|
|
|
- String bonusString = bonusCell.getStringCellValue();
|
|
|
- BigDecimal bonus = !StringUtil.isEmpty(bonusString) ? new BigDecimal(bonusString.trim().replaceAll("\\u00a0", "")) : BigDecimal.valueOf(0);
|
|
|
- finance.setBonus(bonus);
|
|
|
- if (financeConfig.getBonusCalculate()==1) total = total.add(bonus);
|
|
|
- }
|
|
|
- if (allowanceCell != null) {
|
|
|
- allowanceCell.setCellType(CellType.STRING);
|
|
|
- String item = allowanceCell.getStringCellValue();
|
|
|
- BigDecimal value = !StringUtil.isEmpty(item) ? new BigDecimal(item.trim().replaceAll("\\u00a0", "")) : BigDecimal.valueOf(0);
|
|
|
- finance.setAllowance(value);
|
|
|
- if (financeConfig.getAllowanceCalculate()==1) total = total.add(value);
|
|
|
- }
|
|
|
- if (inJobCell != null) {
|
|
|
- inJobCell.setCellType(CellType.STRING);
|
|
|
- String item = inJobCell.getStringCellValue();
|
|
|
- BigDecimal value = !StringUtil.isEmpty(item) ? new BigDecimal(item.trim().replaceAll("\\u00a0", "")) : BigDecimal.valueOf(0);
|
|
|
- finance.setInsuranceLosejob(value);
|
|
|
- if (financeConfig.getInsuranceLosejobCalculate()==1) total = total.add(value);
|
|
|
- }
|
|
|
- if (inMedicalCell != null) {
|
|
|
- inMedicalCell.setCellType(CellType.STRING);
|
|
|
- String item = inMedicalCell.getStringCellValue();
|
|
|
- BigDecimal value = !StringUtil.isEmpty(item) ? new BigDecimal(item.trim().replaceAll("\\u00a0", "")) : BigDecimal.valueOf(0);
|
|
|
- finance.setInsuranceMedical(value);
|
|
|
- if (financeConfig.getInsuranceMedicalCalculate()==1) total = total.add(value);
|
|
|
- }
|
|
|
- if (inOldCell != null) {
|
|
|
- inOldCell.setCellType(CellType.STRING);
|
|
|
- String item = inOldCell.getStringCellValue();
|
|
|
- BigDecimal value = !StringUtil.isEmpty(item) ? new BigDecimal(item.trim().replaceAll("\\u00a0", "")) : BigDecimal.valueOf(0);
|
|
|
- finance.setInsuranceOld(value);
|
|
|
- if (financeConfig.getInsuranceOldCalculate()==1) total = total.add(value);
|
|
|
- }
|
|
|
- if (injuryCell != null) {
|
|
|
- injuryCell.setCellType(CellType.STRING);
|
|
|
- String item = injuryCell.getStringCellValue();
|
|
|
- BigDecimal value = !StringUtil.isEmpty(item) ? new BigDecimal(item.trim().replaceAll("\\u00a0", "")) : BigDecimal.valueOf(0);
|
|
|
- finance.setInsuranceInjury(value);
|
|
|
- if (financeConfig.getInsuranceInjuryCalculate()==1) total = total.add(value);
|
|
|
- }
|
|
|
- if (houseFundCell != null) {
|
|
|
- houseFundCell.setCellType(CellType.STRING);
|
|
|
- String item = houseFundCell.getStringCellValue();
|
|
|
- BigDecimal value = !StringUtil.isEmpty(item) ? new BigDecimal(item.trim().replaceAll("\\u00a0", "")) : BigDecimal.valueOf(0);
|
|
|
- finance.setHouseFund(value);
|
|
|
- if (financeConfig.getHouseFundCalculate()==1) total = total.add(value);
|
|
|
- }
|
|
|
-
|
|
|
- if (field1 != null) {
|
|
|
- field1.setCellType(CellType.STRING);
|
|
|
- String item = field1.getStringCellValue();
|
|
|
- BigDecimal value = !StringUtil.isEmpty(item) ? new BigDecimal(item.trim().replaceAll("\\u00a0", "")) : BigDecimal.valueOf(0);
|
|
|
- finance.setCustomField1(value);
|
|
|
- if (financeConfig.getField1Calculate() != null && financeConfig.getField1Calculate()==1) total = total.add(value);
|
|
|
- }
|
|
|
- if (field2 != null) {
|
|
|
- field2.setCellType(CellType.STRING);
|
|
|
- String item = field2.getStringCellValue();
|
|
|
- BigDecimal value = !StringUtil.isEmpty(item) ? new BigDecimal(item.trim().replaceAll("\\u00a0", "")) : BigDecimal.valueOf(0);
|
|
|
- finance.setCustomField2(value);
|
|
|
- if (financeConfig.getField2Calculate() != null && financeConfig.getField2Calculate()==1) total = total.add(value);
|
|
|
- }
|
|
|
- if (field3 != null) {
|
|
|
- field3.setCellType(CellType.STRING);
|
|
|
- String item = field3.getStringCellValue();
|
|
|
- BigDecimal value = !StringUtil.isEmpty(item)? new BigDecimal(item.trim().replaceAll("\\u00a0", "")) : BigDecimal.valueOf(0);
|
|
|
- finance.setCustomField3(value);
|
|
|
- if (financeConfig.getField3Calculate() != null && financeConfig.getField3Calculate()==1) total = total.add(value);
|
|
|
- }
|
|
|
- if (field4 != null) {
|
|
|
- field4.setCellType(CellType.STRING);
|
|
|
- String item = field4.getStringCellValue();
|
|
|
- BigDecimal value = !StringUtil.isEmpty(item)? new BigDecimal(item.trim().replaceAll("\\u00a0", "")) : BigDecimal.valueOf(0);
|
|
|
- finance.setCustomField4(value);
|
|
|
- if (financeConfig.getField4Calculate() != null && financeConfig.getField4Calculate()==1) total = total.add(value);
|
|
|
- }
|
|
|
- if (field5 != null) {
|
|
|
- field5.setCellType(CellType.STRING);
|
|
|
- String item = field5.getStringCellValue();
|
|
|
- BigDecimal value = !StringUtil.isEmpty(item)? new BigDecimal(item.trim().replaceAll("\\u00a0", "")) : BigDecimal.valueOf(0);
|
|
|
- finance.setCustomField5(value);
|
|
|
- if (financeConfig.getField5Calculate() != null && financeConfig.getField5Calculate()==1) total = total.add(value);
|
|
|
- }
|
|
|
- if (field6 != null) {
|
|
|
- field6.setCellType(CellType.STRING);
|
|
|
- String item = field6.getStringCellValue();
|
|
|
- BigDecimal value = !StringUtil.isEmpty(item)? new BigDecimal(item.trim().replaceAll("\\u00a0", "")) : BigDecimal.valueOf(0);
|
|
|
- finance.setCustomField6(value);
|
|
|
- if (financeConfig.getField6Calculate() != null && financeConfig.getField6Calculate()==1) total = total.add(value);
|
|
|
- }
|
|
|
- if (field7 != null) {
|
|
|
- field7.setCellType(CellType.STRING);
|
|
|
- String item = field7.getStringCellValue();
|
|
|
- BigDecimal value = !StringUtil.isEmpty(item)? new BigDecimal(item.trim().replaceAll("\\u00a0", "")) : BigDecimal.valueOf(0);
|
|
|
- finance.setCustomField7(value);
|
|
|
- if (financeConfig.getField7Calculate() != null && financeConfig.getField7Calculate()==1) total = total.add(value);
|
|
|
+ if (field1 != null) {
|
|
|
+ field1.setCellType(CellType.STRING);
|
|
|
+ String item = field1.getStringCellValue();
|
|
|
+ BigDecimal value = !StringUtil.isEmpty(item) ? new BigDecimal(item.trim().replaceAll("\\u00a0", "")) : BigDecimal.valueOf(0);
|
|
|
+ finance.setCustomField1(value);
|
|
|
+ if (financeConfig.getField1Calculate() != null && financeConfig.getField1Calculate()==1) total = total.add(value);
|
|
|
+ }
|
|
|
+ if (field2 != null) {
|
|
|
+ field2.setCellType(CellType.STRING);
|
|
|
+ String item = field2.getStringCellValue();
|
|
|
+ BigDecimal value = !StringUtil.isEmpty(item) ? new BigDecimal(item.trim().replaceAll("\\u00a0", "")) : BigDecimal.valueOf(0);
|
|
|
+ finance.setCustomField2(value);
|
|
|
+ if (financeConfig.getField2Calculate() != null && financeConfig.getField2Calculate()==1) total = total.add(value);
|
|
|
+ }
|
|
|
+ if (field3 != null) {
|
|
|
+ field3.setCellType(CellType.STRING);
|
|
|
+ String item = field3.getStringCellValue();
|
|
|
+ BigDecimal value = !StringUtil.isEmpty(item)? new BigDecimal(item.trim().replaceAll("\\u00a0", "")) : BigDecimal.valueOf(0);
|
|
|
+ finance.setCustomField3(value);
|
|
|
+ if (financeConfig.getField3Calculate() != null && financeConfig.getField3Calculate()==1) total = total.add(value);
|
|
|
+ }
|
|
|
+ if (field4 != null) {
|
|
|
+ field4.setCellType(CellType.STRING);
|
|
|
+ String item = field4.getStringCellValue();
|
|
|
+ BigDecimal value = !StringUtil.isEmpty(item)? new BigDecimal(item.trim().replaceAll("\\u00a0", "")) : BigDecimal.valueOf(0);
|
|
|
+ finance.setCustomField4(value);
|
|
|
+ if (financeConfig.getField4Calculate() != null && financeConfig.getField4Calculate()==1) total = total.add(value);
|
|
|
+ }
|
|
|
+ if (field5 != null) {
|
|
|
+ field5.setCellType(CellType.STRING);
|
|
|
+ String item = field5.getStringCellValue();
|
|
|
+ BigDecimal value = !StringUtil.isEmpty(item)? new BigDecimal(item.trim().replaceAll("\\u00a0", "")) : BigDecimal.valueOf(0);
|
|
|
+ finance.setCustomField5(value);
|
|
|
+ if (financeConfig.getField5Calculate() != null && financeConfig.getField5Calculate()==1) total = total.add(value);
|
|
|
+ }
|
|
|
+ if (field6 != null) {
|
|
|
+ field6.setCellType(CellType.STRING);
|
|
|
+ String item = field6.getStringCellValue();
|
|
|
+ BigDecimal value = !StringUtil.isEmpty(item)? new BigDecimal(item.trim().replaceAll("\\u00a0", "")) : BigDecimal.valueOf(0);
|
|
|
+ finance.setCustomField6(value);
|
|
|
+ if (financeConfig.getField6Calculate() != null && financeConfig.getField6Calculate()==1) total = total.add(value);
|
|
|
+ }
|
|
|
+ if (field7 != null) {
|
|
|
+ field7.setCellType(CellType.STRING);
|
|
|
+ String item = field7.getStringCellValue();
|
|
|
+ BigDecimal value = !StringUtil.isEmpty(item)? new BigDecimal(item.trim().replaceAll("\\u00a0", "")) : BigDecimal.valueOf(0);
|
|
|
+ finance.setCustomField7(value);
|
|
|
+ if (financeConfig.getField7Calculate() != null && financeConfig.getField7Calculate()==1) total = total.add(value);
|
|
|
+ }
|
|
|
+ finance.setTotalCost(total);
|
|
|
}
|
|
|
- finance.setTotalCost(total);
|
|
|
-
|
|
|
//如果需要更新员工成本
|
|
|
if (financeImport.getRecoverMonthcost()==1 || financeImport.getRecoverReport()==1) {
|
|
|
//设置人员总成本,计算时薪
|
|
@@ -506,9 +580,9 @@ public class FinanceImportServiceImpl extends ServiceImpl<FinanceImportMapper, F
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
updateUserList.add(localUser);
|
|
|
}
|
|
|
+
|
|
|
} else {
|
|
|
//msg.setError("用户["+name+"]不存在,请在组织结构中添加该成员");
|
|
|
msg.setError(MessageUtils.message("group.userNull",name));
|
|
@@ -516,7 +590,6 @@ public class FinanceImportServiceImpl extends ServiceImpl<FinanceImportMapper, F
|
|
|
}
|
|
|
finance.setYmonth(yearMonth);
|
|
|
financeList.add(finance);
|
|
|
-
|
|
|
}
|
|
|
if (financeList.size() == 0) {
|
|
|
//msg.setError("请填写数据再上传");
|
|
@@ -539,38 +612,52 @@ public class FinanceImportServiceImpl extends ServiceImpl<FinanceImportMapper, F
|
|
|
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 (!oldItem.getIsVerification()) {
|
|
|
+ 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 (readyForDelete.size() > 0) {
|
|
|
- financeService.removeByIds(readyForDelete);
|
|
|
}
|
|
|
+
|
|
|
//如果有必要,更新该月份的日报相关的成本
|
|
|
if (financeImport.getRecoverReport()==1) {
|
|
|
List<Report> reportList = reportMapper.selectSimpleTime(companyId, startStr, endStr);
|
|
|
if (reportList.size() > 0) {
|
|
|
- for (Report r : reportList) {
|
|
|
+ for (int i=0;i<reportList.size(); i++) {
|
|
|
+ Report r = reportList.get(i);
|
|
|
Optional<User> first = updateUserList.stream().filter(u -> u.getId().equals(r.getCreatorId())).findFirst();
|
|
|
- if (!first.isPresent()) {
|
|
|
- String notFillUser = userMapper.selectById(r.getCreatorId()).getName();
|
|
|
- System.out.println("缺少[" + notFillUser + "]的薪资成本, 请修改数据重新上传");
|
|
|
- //throw new UserNotFoundException("缺少[" + notFillUser + "]的薪资成本, 请修改数据重新上传");
|
|
|
- throw new UserNotFoundException(MessageUtils.message("salary.lackAndUpAgain",notFillUser));
|
|
|
+ if (first.isPresent()) {
|
|
|
+ BigDecimal hourCost = first.get().getCost();
|
|
|
+ r.setCost(hourCost.multiply(new BigDecimal(r.getWorkingTime())));
|
|
|
+ r.setCreatorId(null);
|
|
|
+ r.setWorkingTime(null);
|
|
|
+ } else {
|
|
|
+ if (oldItem.getIsVerification()) {
|
|
|
+ //该日报的人员本次没有核销的奖金,无需处理
|
|
|
+ reportList.remove(i);
|
|
|
+ i--;
|
|
|
+ } else {
|
|
|
+ //缺少薪资成本
|
|
|
+ String notFillUser = userMapper.selectById(r.getCreatorId()).getName();
|
|
|
+ System.out.println("缺少[" + notFillUser + "]的薪资成本, 请修改数据重新上传");
|
|
|
+ //throw new UserNotFoundException("缺少[" + notFillUser + "]的薪资成本, 请修改数据重新上传");
|
|
|
+ throw new UserNotFoundException(MessageUtils.message("salary.lackAndUpAgain",notFillUser));
|
|
|
+ }
|
|
|
}
|
|
|
- BigDecimal hourCost = first.get().getCost();
|
|
|
- r.setCost(hourCost.multiply(new BigDecimal(r.getWorkingTime())));
|
|
|
- r.setCreatorId(null);
|
|
|
- r.setWorkingTime(null);
|
|
|
}
|
|
|
//批量更新日报的成本
|
|
|
- reportService.updateBatchById(reportList);
|
|
|
+ if (reportList.size() > 0) {
|
|
|
+ reportService.updateBatchById(reportList);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|