|
@@ -9,16 +9,13 @@ import cn.ezhizao.project.business.housingFund.mapper.BizHousingFundConfirmDetai
|
|
|
import cn.ezhizao.project.business.housingFund.mapper.BizHousingFundConfirmDetailMapper;
|
|
|
import cn.ezhizao.project.business.housingFund.mapper.BizHousingFundConfirmMapper;
|
|
|
import cn.ezhizao.project.business.housingFund.service.IBizHousingFundConfirmService;
|
|
|
-import cn.ezhizao.project.business.salary.domain.BizFinancialSalary;
|
|
|
-import cn.ezhizao.project.business.salary.domain.BizFinancialSalaryDetail;
|
|
|
-import cn.ezhizao.project.business.salary.domain.BizFinancialSalaryDetailEmployee;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
-import java.math.BigDecimal;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @author 周晓
|
|
@@ -51,8 +48,7 @@ public class BizHousingFundConfirmServiceImpl extends ServiceImpl<BizHousingFund
|
|
|
return financialHousingFundConfirmDao.getTotal(conditions);
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public String importSalary(List<BizHousingFundConfirmDetailEmployee> detailList, String year, String month, Long tenantId) {
|
|
|
+ public String importHousingFundCon(List<BizHousingFundConfirmDetailEmployee> detailList, String year, String month, Long tenantId) {
|
|
|
if (StringUtils.isNull(detailList) || detailList.size() == 0) {
|
|
|
throw new ServiceException("导入数据不能为空!");
|
|
|
}
|
|
@@ -60,48 +56,62 @@ public class BizHousingFundConfirmServiceImpl extends ServiceImpl<BizHousingFund
|
|
|
int failureNum = 0;
|
|
|
StringBuilder successMsg = new StringBuilder();
|
|
|
StringBuilder failureMsg = new StringBuilder();
|
|
|
- //获取信息
|
|
|
- for(BizHousingFundConfirmDetailEmployee l : detailList){
|
|
|
- BizHousingFundConfirm housingFundConfirm=new BizHousingFundConfirm();
|
|
|
- housingFundConfirm.setCompanyName(l.getCompanyName());
|
|
|
+ // 根据 客户名称 字段将元素分组
|
|
|
+ Map<String, List<BizHousingFundConfirmDetailEmployee>> groupedByName = detailList.stream()
|
|
|
+ .collect(Collectors.groupingBy(BizHousingFundConfirmDetailEmployee::getCompanyName));
|
|
|
+ int number = 0;
|
|
|
+
|
|
|
+ // 循环遍历每个分组
|
|
|
+ for (Map.Entry<String, List<BizHousingFundConfirmDetailEmployee>> entry : groupedByName.entrySet()) {
|
|
|
+ String name = entry.getKey();
|
|
|
+
|
|
|
+ List<BizHousingFundConfirmDetailEmployee> employees = entry.getValue();
|
|
|
+ BizHousingFundConfirmDetailEmployee detai = employees.get(number++);
|
|
|
+
|
|
|
+ BizHousingFundConfirm housingFundConfirm = new BizHousingFundConfirm();
|
|
|
+ housingFundConfirm.setCompanyName(detai.getCompanyName());
|
|
|
housingFundConfirm.setTenantId(tenantId);
|
|
|
- List <BizHousingFundConfirm> list= getListByBean(housingFundConfirm);
|
|
|
+ List<BizHousingFundConfirm> list = getListByBean(housingFundConfirm);
|
|
|
+
|
|
|
//是否存在该客户
|
|
|
- if(list.size() == 0){
|
|
|
+ if (list.size() == 0) {
|
|
|
failureNum++;
|
|
|
- failureMsg.append("<br/>").append(failureNum).append("、客户 ").append(l.getCompanyName()).append(" 不存在");
|
|
|
+ failureMsg.append("<br/>").append(failureNum).append("、客户 ").append(detai.getCompanyName()).append(" 不存在");
|
|
|
continue;
|
|
|
}
|
|
|
- if(list.size() > 1){
|
|
|
+ if (list.size() > 1) {
|
|
|
failureNum++;
|
|
|
- failureMsg.append("<br/>").append(failureNum).append("、客户 ").append(l.getCompanyName()).append("请输入详细客户名称");
|
|
|
+ failureMsg.append("<br/>").append(failureNum).append("、客户 ").append(detai.getCompanyName()).append("请输入详细客户名称");
|
|
|
continue;
|
|
|
}
|
|
|
- housingFundConfirm=list.get(0);
|
|
|
+
|
|
|
+ housingFundConfirm = list.get(0);
|
|
|
//获取明细
|
|
|
- BizHousingFundConfirmDetail detail=new BizHousingFundConfirmDetail();
|
|
|
+ BizHousingFundConfirmDetail detail = new BizHousingFundConfirmDetail();
|
|
|
detail.setHousingFundConfirmId(housingFundConfirm.getId());
|
|
|
detail.setMonth(month);
|
|
|
detail.setYear(year);
|
|
|
- List<BizHousingFundConfirmDetail> confirmDetailList=housingFundConfirmDetailDao.getList(detail);
|
|
|
- if(confirmDetailList.size()>0){
|
|
|
+ List<BizHousingFundConfirmDetail> confirmDetailList = housingFundConfirmDetailDao.getList(detail);
|
|
|
+ if (confirmDetailList.size() > 0) {
|
|
|
failureNum++;
|
|
|
- failureMsg.append("<br/>").append(failureNum).append("、客户 ").append(l.getCompanyName()).append(year+"年"+month+"月").append("公积金已有数据");
|
|
|
+ failureMsg.append("<br/>").append(failureNum).append("、客户 ").append(detai.getCompanyName()).append(year + "年" + month + "月").append("公积金已有数据");
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
//设置状态为待确认
|
|
|
detail.setStatus(1);
|
|
|
detail.setCompanyId(housingFundConfirm.getCompanyId());
|
|
|
- //新增工资明细
|
|
|
+ //新增公积金明细
|
|
|
housingFundConfirmDetailDao.insert(detail);
|
|
|
|
|
|
- l.setHousingFundConfirmId(housingFundConfirm.getId());
|
|
|
- l.setHousingFundConfirmDetailId(detail.getId());
|
|
|
- //新增人员明细
|
|
|
- housingFundConfirmDetailEmployeeDao.insert(l);
|
|
|
- successNum++;
|
|
|
- successMsg.append("<br/>").append(successNum).append("、公积金 ").append(l.getCompanyName()).append(" 导入成功");
|
|
|
+ for (BizHousingFundConfirmDetailEmployee l : employees) {
|
|
|
+ l.setHousingFundConfirmId(housingFundConfirm.getId());
|
|
|
+ l.setHousingFundConfirmDetailId(detail.getId());
|
|
|
+ //新增人员明细
|
|
|
+ housingFundConfirmDetailEmployeeDao.insert(l);
|
|
|
+ successNum++;
|
|
|
+ successMsg.append("<br/>").append(successNum).append("、公积金 ").append(l.getCompanyName()).append(" 导入成功");
|
|
|
+ }
|
|
|
}
|
|
|
if (failureNum > 0) {
|
|
|
failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
|
|
@@ -109,7 +119,7 @@ public class BizHousingFundConfirmServiceImpl extends ServiceImpl<BizHousingFund
|
|
|
} else {
|
|
|
successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
|
|
|
}
|
|
|
+
|
|
|
return successMsg.toString();
|
|
|
}
|
|
|
-
|
|
|
}
|