|
@@ -726,7 +726,7 @@ public class BizArchiveInputTempServiceImpl extends ServiceImpl<BizArchiveInputT
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Map<String,List<importCheckModel>> checkInput(List<OrderExcelImportLoopModel> orderList) {
|
|
|
+ public Map<String,List<importCheckModel>> checkInput(List<OrderExcelImportLoopModel> orderList,Long tenantId) {
|
|
|
importCheckModel checkmodel = null;
|
|
|
//结束月小于当前时间
|
|
|
List<importCheckModel> endMonthList = new ArrayList<>();
|
|
@@ -734,46 +734,46 @@ public class BizArchiveInputTempServiceImpl extends ServiceImpl<BizArchiveInputT
|
|
|
List<importCheckModel> startMonthList = new ArrayList<>();
|
|
|
|
|
|
List<importCheckModel> checkModelList = new ArrayList<>();
|
|
|
- for(OrderExcelImportLoopModel model : orderList){
|
|
|
- String companyName = model.getCompanyName();
|
|
|
+ for(OrderExcelImportLoopModel loopModel : orderList){
|
|
|
+ String companyName = loopModel.getCompanyName();
|
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
Long taskId = 0L;
|
|
|
|
|
|
- if ("是".equals(model.getKeepAccount())) {
|
|
|
+ if ("是".equals(loopModel.getKeepAccount())) {
|
|
|
checkmodel = new importCheckModel();
|
|
|
checkmodel.setCompanyName(companyName);
|
|
|
- checkmodel.setContractNo(model.getContractNo());
|
|
|
+ checkmodel.setContractNo(loopModel.getContractNo());
|
|
|
checkmodel.setTaskType("代理记账");
|
|
|
- checkmodel.setStartMonth(model.getKeepAccountStartMonth());
|
|
|
- checkmodel.setEndMonth(model.getKeepAccountEndMonth());
|
|
|
+ checkmodel.setStartMonth(loopModel.getKeepAccountStartMonth());
|
|
|
+ checkmodel.setEndMonth(loopModel.getKeepAccountEndMonth());
|
|
|
checkModelList.add(checkmodel);
|
|
|
}
|
|
|
- if ("是".equals(model.getSocialSecurity())) {
|
|
|
+ if ("是".equals(loopModel.getSocialSecurity())) {
|
|
|
checkmodel = new importCheckModel();
|
|
|
checkmodel.setCompanyName(companyName);
|
|
|
- checkmodel.setContractNo(model.getContractNo());
|
|
|
+ checkmodel.setContractNo(loopModel.getContractNo());
|
|
|
checkmodel.setTaskType("社保");
|
|
|
- checkmodel.setStartMonth(model.getSocialSecurityStartMonth());
|
|
|
- checkmodel.setEndMonth(model.getSocialSecurityEndMonth());
|
|
|
+ checkmodel.setStartMonth(loopModel.getSocialSecurityStartMonth());
|
|
|
+ checkmodel.setEndMonth(loopModel.getSocialSecurityEndMonth());
|
|
|
checkModelList.add(checkmodel);
|
|
|
}
|
|
|
- if ("是".equals(model.getHousingFund())) {
|
|
|
+ if ("是".equals(loopModel.getHousingFund())) {
|
|
|
checkmodel = new importCheckModel();
|
|
|
checkmodel.setCompanyName(companyName);
|
|
|
- checkmodel.setContractNo(model.getContractNo());
|
|
|
+ checkmodel.setContractNo(loopModel.getContractNo());
|
|
|
checkmodel.setTaskType("公积金");
|
|
|
- checkmodel.setStartMonth(model.getHousingFundStartMonth());
|
|
|
- checkmodel.setEndMonth(model.getHousingFundEndMonth());
|
|
|
+ checkmodel.setStartMonth(loopModel.getHousingFundStartMonth());
|
|
|
+ checkmodel.setEndMonth(loopModel.getHousingFundEndMonth());
|
|
|
checkModelList.add(checkmodel);
|
|
|
}
|
|
|
- if ("是".equals(model.getReturnTax())) {
|
|
|
+ if ("是".equals(loopModel.getReturnTax())) {
|
|
|
checkmodel = new importCheckModel();
|
|
|
checkmodel.setCompanyName(companyName);
|
|
|
- checkmodel.setContractNo(model.getContractNo());
|
|
|
+ checkmodel.setContractNo(loopModel.getContractNo());
|
|
|
checkmodel.setTaskType("返税");
|
|
|
- checkmodel.setStartMonth(model.getReturnTaxStartMonth());
|
|
|
- checkmodel.setEndMonth(model.getReturnTaxEndMonth());
|
|
|
+ checkmodel.setStartMonth(loopModel.getReturnTaxStartMonth());
|
|
|
+ checkmodel.setEndMonth(loopModel.getReturnTaxEndMonth());
|
|
|
checkModelList.add(checkmodel);
|
|
|
}
|
|
|
}
|
|
@@ -811,4 +811,197 @@ public class BizArchiveInputTempServiceImpl extends ServiceImpl<BizArchiveInputT
|
|
|
map.put("endMonth",endMonthList);
|
|
|
return map;
|
|
|
}
|
|
|
+ public Map<String,String> checkexcel(List<OrderExcelImportLoopModel> orderList,Long tenantId){
|
|
|
+ successNum = 0;
|
|
|
+ failureNum = 0;
|
|
|
+ successMsg = new StringBuilder();
|
|
|
+ failureMsg = new StringBuilder();
|
|
|
+ List<String> contractNo = orderList.stream().map(m -> m.getContractNo()).collect(Collectors.toList());
|
|
|
+ //合同号不能重复
|
|
|
+ Map<String, Long> nameCountMap = contractNo.stream()
|
|
|
+ .collect(Collectors.groupingBy(name -> name, Collectors.counting()));
|
|
|
+ List<BizCompany> companies = companyService.query().eq("tenant_id", tenantId).list();
|
|
|
+ List<String> contNOs = this.query().eq("service_type", 1).eq("tenant_id", tenantId).list().stream().map(m -> m.getContractNo()).collect(Collectors.toList());
|
|
|
+ List<importCheckModel> checkModelList = new ArrayList<>();
|
|
|
+ for(OrderExcelImportLoopModel loopModel : orderList) {
|
|
|
+ if (loopModel.getDiscountAmount() == null) {
|
|
|
+ loopModel.setDiscountAmount(BigDecimal.ZERO);
|
|
|
+ }
|
|
|
+ BizCompany company = companies.stream().filter(v -> v.getName().equals(loopModel.getCompanyName())).findFirst().orElse(null);
|
|
|
+ if (company == null) {
|
|
|
+ failureNum++;
|
|
|
+// failureMsg.append("<br/>").append(failureNum).append("、客户 ").append(loopModel.getCompanyName()).append(" 不存在");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ SysUser user = userService.selectUserByUserNameAndTenantId(loopModel.getSignerName(), String.valueOf(tenantId));
|
|
|
+// if (user == null) {
|
|
|
+// failureNum++;
|
|
|
+// failureMsg.append("<br/>").append(failureNum).append("、员工 ").append(item.getSignerName()).append(" 不存在");
|
|
|
+// continue;
|
|
|
+// }
|
|
|
+ // 判断下订单总价单价是否和录入相符
|
|
|
+ // 假设 amount - discountAmount != trueAmount 跳过该订单
|
|
|
+ if (loopModel.getAmount() == null) {
|
|
|
+ failureNum++;
|
|
|
+ failureMsg.append("<br/>").append(failureNum).append("、订单 ").append(loopModel.getContractNo()).append(failureNum).append("服务金额不能为空");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (loopModel.getTrueAmount() == null) {
|
|
|
+ failureNum++;
|
|
|
+ failureMsg.append("<br/>").append(failureNum).append("、订单 ").append(loopModel.getContractNo()).append(failureNum).append("实收金额不能为空");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (loopModel.getAmount().subtract(loopModel.getDiscountAmount() == null ? BigDecimal.ZERO : loopModel.getDiscountAmount()).compareTo(loopModel.getTrueAmount()) != 0) {
|
|
|
+ failureNum++;
|
|
|
+ failureMsg.append("<br/>").append(failureNum).append("、订单 ").append(loopModel.getContractNo()).append(" 实际付款金额出错");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (loopModel.getTrueAmount().compareTo(BigDecimal.ZERO) < 0) {
|
|
|
+ failureNum++;
|
|
|
+ failureMsg.append("<br/>").append(failureNum).append("、订单 ").append(loopModel.getContractNo()).append(" 实际付款金额小于0");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ // 假设子表金额不等于订单总金额
|
|
|
+ BigDecimal keepAccount = loopModel.getKeepAccountAmount() == null ? BigDecimal.ZERO : loopModel.getKeepAccountAmount();
|
|
|
+ BigDecimal security = loopModel.getSocialSecurityAmount() == null ? BigDecimal.ZERO : loopModel.getSocialSecurityAmount();
|
|
|
+ BigDecimal housingFund = loopModel.getHousingFundAmount() == null ? BigDecimal.ZERO : loopModel.getHousingFundAmount();
|
|
|
+ BigDecimal returnTax = loopModel.getReturnTaxAmount() == null ? BigDecimal.ZERO : loopModel.getReturnTaxAmount();
|
|
|
+ //优惠
|
|
|
+ BigDecimal keepFreeAccount = loopModel.getKeepAccountFreeAmount() == null ? BigDecimal.ZERO : loopModel.getKeepAccountFreeAmount();
|
|
|
+ BigDecimal securityFree = loopModel.getSocialSecurityFreeAmount() == null ? BigDecimal.ZERO : loopModel.getSocialSecurityFreeAmount();
|
|
|
+ BigDecimal housingFundFree = loopModel.getHousingFundFreeAmount() == null ? BigDecimal.ZERO : loopModel.getHousingFundFreeAmount();
|
|
|
+ BigDecimal returnTaxFree = loopModel.getReturnTaxFreeAmount() == null ? BigDecimal.ZERO : loopModel.getReturnTaxFreeAmount();
|
|
|
+// if (item.getAmount().compareTo(keepAccount.add(security).add(housingFund).add(returnTax)) != 0) {
|
|
|
+ //update 6/12 实收金额 和各项金额比较 ,各项金额填写时应该为 单价*月-优惠金额
|
|
|
+ if (loopModel.getTrueAmount().compareTo(keepAccount.add(security).add(housingFund).add(returnTax)) != 0) {
|
|
|
+ failureNum++;
|
|
|
+ failureMsg.append("<br/>").append(failureNum).append("、订单 ").append(loopModel.getContractNo()).append(" 实收金额不等于实际任务金额的和。");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (loopModel.getDiscountAmount().compareTo(keepFreeAccount.add(securityFree).add(housingFundFree).add(returnTaxFree)) != 0) {
|
|
|
+ failureNum++;
|
|
|
+ failureMsg.append("<br/>").append(failureNum).append("、订单 ").append(loopModel.getContractNo()).append("优惠金额不等于任务优惠金额的和。");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ BigDecimal keepAccountPrice = loopModel.getKeepAccountPrice() == null ? BigDecimal.ZERO : loopModel.getKeepAccountPrice();
|
|
|
+ BigDecimal securityPrice = loopModel.getSocialSecurityPrice() == null ? BigDecimal.ZERO : loopModel.getSocialSecurityPrice();
|
|
|
+ BigDecimal housingFundPrice = loopModel.getHousingFundPrice() == null ? BigDecimal.ZERO : loopModel.getHousingFundPrice();
|
|
|
+ BigDecimal returnTaxPrice = loopModel.getReturnTaxPrice() == null ? BigDecimal.ZERO : loopModel.getReturnTaxPrice();
|
|
|
+ BigDecimal keepAccountMonth = loopModel.getKeepAccountMonth() == null ? BigDecimal.ZERO : BigDecimal.valueOf(loopModel.getKeepAccountMonth());
|
|
|
+ BigDecimal securityMonth = loopModel.getSocialSecurityMonth() == null ? BigDecimal.ZERO : BigDecimal.valueOf(loopModel.getSocialSecurityMonth());
|
|
|
+ BigDecimal housingFundMonth = loopModel.getHousingFundMonth() == null ? BigDecimal.ZERO : BigDecimal.valueOf(loopModel.getHousingFundMonth());
|
|
|
+ BigDecimal returnTaxMonth = loopModel.getReturnTaxMonth() == null ? BigDecimal.ZERO : BigDecimal.valueOf(loopModel.getReturnTaxMonth());
|
|
|
+ if (loopModel.getKeepAccountStartMonth() != null && loopModel.getKeepAccountEndMonth() != null) {
|
|
|
+ Calendar startCalendar = Calendar.getInstance();
|
|
|
+ startCalendar.setTime(loopModel.getKeepAccountStartMonth());
|
|
|
+ Calendar endCalendar = Calendar.getInstance();
|
|
|
+ endCalendar.setTime(loopModel.getKeepAccountEndMonth());
|
|
|
+ // 计算年份和月份的差异
|
|
|
+ int yearDiff = endCalendar.get(Calendar.YEAR) - startCalendar.get(Calendar.YEAR);
|
|
|
+ int monthDiff = endCalendar.get(Calendar.MONTH) - startCalendar.get(Calendar.MONTH);
|
|
|
+ // 总的月份差异
|
|
|
+ int totalMonthsBetween = yearDiff * 12 + monthDiff + 1;
|
|
|
+ BigDecimal keeFreeMonth = loopModel.getKeepAccountFreeMonth() == null ? BigDecimal.ZERO : BigDecimal.valueOf(loopModel.getKeepAccountFreeMonth());
|
|
|
+ if (totalMonthsBetween != keepAccountMonth.add(keeFreeMonth).intValue()) {
|
|
|
+ failureNum++;
|
|
|
+ failureMsg.append("<br/>").append(failureNum).append(company.getName() + "的代理记账服务的服务月数+赠送月数跟结束月-开始月的时间不等,请检查数据");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ if (loopModel.getSocialSecurityStartMonth() != null && loopModel.getSocialSecurityEndMonth() != null) {
|
|
|
+ Calendar startCalendar2 = Calendar.getInstance();
|
|
|
+ startCalendar2.setTime(loopModel.getSocialSecurityStartMonth());
|
|
|
+ Calendar endCalendar2 = Calendar.getInstance();
|
|
|
+ endCalendar2.setTime(loopModel.getSocialSecurityEndMonth());
|
|
|
+ // 计算年份和月份的差异
|
|
|
+ int yearDiff2 = endCalendar2.get(Calendar.YEAR) - startCalendar2.get(Calendar.YEAR);
|
|
|
+ int monthDiff2 = endCalendar2.get(Calendar.MONTH) - startCalendar2.get(Calendar.MONTH);
|
|
|
+ // 总的月份差异
|
|
|
+ int totalMonthsBetween2 = yearDiff2 * 12 + monthDiff2 + 1;
|
|
|
+ BigDecimal socialSecurityMonth = loopModel.getSocialSecurityFreeMonth() == null ? BigDecimal.ZERO : BigDecimal.valueOf(loopModel.getSocialSecurityFreeMonth());
|
|
|
+ if (totalMonthsBetween2 != securityMonth.add(socialSecurityMonth).intValue()) {
|
|
|
+ failureNum++;
|
|
|
+
|
|
|
+ failureMsg.append("<br/>").append(failureNum).append(company.getName() + "的社保代缴服务的服务月数+赠送月数跟结束月-开始月的时间不等,请检查数据");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if (loopModel.getHousingFundStartMonth() != null && loopModel.getHousingFundEndMonth() != null) {
|
|
|
+ Calendar startCalendar3 = Calendar.getInstance();
|
|
|
+ startCalendar3.setTime(loopModel.getHousingFundStartMonth());
|
|
|
+ Calendar endCalendar3 = Calendar.getInstance();
|
|
|
+ endCalendar3.setTime(loopModel.getHousingFundEndMonth());
|
|
|
+ // 计算年份和月份的差异
|
|
|
+ int yearDiff3 = endCalendar3.get(Calendar.YEAR) - startCalendar3.get(Calendar.YEAR);
|
|
|
+ int monthDiff3 = endCalendar3.get(Calendar.MONTH) - startCalendar3.get(Calendar.MONTH);
|
|
|
+ // 总的月份差异
|
|
|
+ int totalMonthsBetween3 = yearDiff3 * 12 + monthDiff3 + 1;
|
|
|
+ BigDecimal housingFundMonths = loopModel.getHousingFundFreeMonth() == null ? BigDecimal.ZERO : BigDecimal.valueOf(loopModel.getHousingFundFreeMonth());
|
|
|
+ if (totalMonthsBetween3 != housingFundMonth.add(housingFundMonths).intValue()) {
|
|
|
+ failureNum++;
|
|
|
+ failureMsg.append("<br/>").append(failureNum).append(company.getName() + "的公积金服务的服务月数+赠送月数跟结束月-开始月的时间不等,请检查数据");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (loopModel.getReturnTaxStartMonth() != null && loopModel.getReturnTaxEndMonth() != null) {
|
|
|
+ Calendar startCalendar4 = Calendar.getInstance();
|
|
|
+ startCalendar4.setTime(loopModel.getReturnTaxStartMonth());
|
|
|
+ Calendar endCalendar4 = Calendar.getInstance();
|
|
|
+ endCalendar4.setTime(loopModel.getReturnTaxEndMonth());
|
|
|
+ // 计算年份和月份的差异
|
|
|
+ int yearDiff4 = endCalendar4.get(Calendar.YEAR) - startCalendar4.get(Calendar.YEAR);
|
|
|
+ int monthDiff4 = endCalendar4.get(Calendar.MONTH) - startCalendar4.get(Calendar.MONTH);
|
|
|
+ // 总的月份差异
|
|
|
+ int totalMonthsBetween4 = yearDiff4 * 12 + monthDiff4 + 1;
|
|
|
+ BigDecimal returnTaxFreeMonth = loopModel.getReturnTaxFreeMonth() == null ? BigDecimal.ZERO : BigDecimal.valueOf(loopModel.getReturnTaxFreeMonth());
|
|
|
+ if (totalMonthsBetween4 != returnTaxMonth.add(returnTaxFreeMonth).intValue()) {
|
|
|
+ failureNum++;
|
|
|
+ failureMsg.append("<br/>").append(failureNum).append(company.getName() + "的返税申报服务的服务月数+赠送月数跟结束月-开始月的时间不等,请检查数据");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (nameCountMap.get(loopModel.getContractNo()) > 1L) {
|
|
|
+ failureNum++;
|
|
|
+ failureMsg.append("<br/>").append(failureNum).append("导入的合同编号 ").append(loopModel.getContractNo()).append("不能重复");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (contNOs.contains(loopModel.getContractNo())) {
|
|
|
+ failureNum++;
|
|
|
+ failureMsg.append("<br/>").append(failureNum).append("合同编号 ").append(loopModel.getContractNo()).append("已存在不能重复导入");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //update 6/12 加单条优惠才为当月总金额
|
|
|
+ if (keepAccount.add(keepFreeAccount).compareTo(keepAccountPrice.multiply(keepAccountMonth)) != 0) {
|
|
|
+ failureNum++;
|
|
|
+ failureMsg.append("<br/>").append(failureNum).append("、订单 ").append(loopModel.getContractNo()).append(" 记账总金额计算值与记账单价不符。");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (security.add(securityFree).compareTo(securityPrice.multiply(securityMonth)) != 0) {
|
|
|
+ failureNum++;
|
|
|
+ failureMsg.append("<br/>").append(failureNum).append("、订单 ").append(loopModel.getContractNo()).append(" 社保总金额计算值与社保单价不符。");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (housingFund.add(housingFundFree).compareTo(housingFundPrice.multiply(housingFundMonth)) != 0) {
|
|
|
+ failureNum++;
|
|
|
+ failureMsg.append("<br/>").append(failureNum).append("、订单 ").append(loopModel.getContractNo()).append(" 公积金总金额计算值与公积金单价不符。");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (returnTax.add(returnTaxFree).compareTo(returnTaxMonth.multiply(returnTaxPrice)) != 0) {
|
|
|
+ failureNum++;
|
|
|
+ failureMsg.append("<br/>").append(failureNum).append("、订单 ").append(loopModel.getContractNo()).append(" 返税总金额计算值与返税单价不符。");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Map<String,String> map = new HashMap<>();
|
|
|
+ map.put("failureNum",String.valueOf(failureNum));
|
|
|
+ map.put("failureMsg",failureMsg.toString());
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
}
|