weaver-hrm-salary/src/com/engine/salary/service/impl/SIAccountServiceImpl.java

330 lines
15 KiB
Java
Raw Normal View History

2022-04-11 19:07:35 +08:00
package com.engine.salary.service.impl;
2022-04-12 19:29:19 +08:00
import com.api.browser.bean.SearchConditionGroup;
import com.api.browser.bean.SearchConditionItem;
import com.cloudstore.eccom.pc.table.WeaTableColumn;
2022-04-11 19:07:35 +08:00
import com.cloudstore.eccom.result.WeaResultMsg;
2022-04-12 10:24:21 +08:00
import com.engine.common.util.ServiceUtil;
2022-04-11 19:07:35 +08:00
import com.engine.core.impl.Service;
import com.engine.salary.biz.SIAccountBiz;
import com.engine.salary.component.SalaryWeaTable;
2022-04-12 19:29:19 +08:00
import com.engine.salary.constant.SalaryDefaultTenantConstant;
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
import com.engine.salary.entity.salaryarchive.dto.SalaryArchiveListDTO;
2022-04-11 19:07:35 +08:00
import com.engine.salary.entity.siaccount.bo.InsuranceAccountBO;
import com.engine.salary.entity.siaccount.dto.InsuranceAccountBatchListDTO;
2022-04-15 13:17:25 +08:00
import com.engine.salary.entity.siaccount.param.*;
2022-04-11 19:07:35 +08:00
import com.engine.salary.entity.siaccount.po.InsuranceAccountBatchPO;
2022-04-12 10:24:21 +08:00
import com.engine.salary.entity.siaccount.po.InsuranceAccountDetailPO;
2022-04-15 13:17:25 +08:00
import com.engine.salary.entity.siaccount.po.InsuranceAccountInspectPO;
2022-04-12 19:29:19 +08:00
import com.engine.salary.enums.siaccount.BillStatusEnum;
2022-04-15 13:17:25 +08:00
import com.engine.salary.enums.siaccount.InspectStatusEnum;
2022-04-12 19:29:19 +08:00
import com.engine.salary.enums.siaccount.PaymentStatusEnum;
import com.engine.salary.mapper.datacollection.EmployMapper;
2022-04-14 11:54:16 +08:00
import com.engine.salary.mapper.siaccount.InsuranceAccountBatchMapper;
2022-04-12 19:29:19 +08:00
import com.engine.salary.mapper.siaccount.InsuranceAccountDetailMapper;
2022-04-15 13:17:25 +08:00
import com.engine.salary.mapper.siaccount.InsuranceAccountInspectMapper;
2022-04-12 19:29:19 +08:00
import com.engine.salary.service.ColumnBuildService;
2022-04-12 10:24:21 +08:00
import com.engine.salary.service.RecordsBuildService;
2022-04-11 19:07:35 +08:00
import com.engine.salary.service.SIAccountService;
import java.util.*;
2022-04-12 19:29:19 +08:00
import java.util.stream.Collectors;
2022-04-11 19:07:35 +08:00
2022-04-12 19:29:19 +08:00
import com.engine.salary.util.SalaryDateUtil;
2022-04-14 11:54:16 +08:00
import com.engine.salary.util.SalaryFormItemUtil;
2022-04-12 19:29:19 +08:00
import com.engine.salary.util.db.MapperProxyFactory;
2022-04-11 19:07:35 +08:00
import com.engine.salary.util.page.PageInfo;
2022-04-14 11:54:16 +08:00
import com.engine.salary.util.valid.ValidUtil;
2022-04-12 19:29:19 +08:00
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
2022-04-12 10:24:21 +08:00
import weaver.hrm.User;
2022-04-11 19:07:35 +08:00
/**
* @Author weaver_cl
* @Description: TODO
* @Date 2022/4/11
* @Version V1.0
**/
public class SIAccountServiceImpl extends Service implements SIAccountService {
private SIAccountBiz siAccountBiz = new SIAccountBiz();
2022-04-12 10:24:21 +08:00
public RecordsBuildService getService(User user) {
return ServiceUtil.getService(RecordsBuildServiceImpl.class,user);
}
2022-04-12 19:29:19 +08:00
public ColumnBuildService getColumnBuildService(User user) {
return ServiceUtil.getService(ColumnBuildServiceImpl.class,user);
}
2022-04-11 19:07:35 +08:00
@Override
public Map<String, Object> listPage(InsuranceAccountBatchParam queryParam) {
Long employeeId = (long)user.getUID();
Map<String,Object> datas = new HashMap<>();
//福利台账列表
PageInfo<InsuranceAccountBatchPO> pageInfo = siAccountBiz.listPage(queryParam,employeeId);
Collection<InsuranceAccountBatchPO> insuranceAccountBatchPOS = pageInfo.getList();
List<InsuranceAccountBatchListDTO> insuranceAccountBatchListDTOS = InsuranceAccountBO.buildAccountBatchDTOList(insuranceAccountBatchPOS);
PageInfo<InsuranceAccountBatchListDTO> pageInfos = new PageInfo<>(insuranceAccountBatchListDTOS,InsuranceAccountBatchListDTO.class);
pageInfos.setTotal(insuranceAccountBatchListDTOS.size());
pageInfos.setPageNum(queryParam.getCurrent());
pageInfos.setPageSize(queryParam.getPageSize());
2022-04-12 19:29:19 +08:00
List<Map<Integer,List<Permission>>> operatesPermission = new ArrayList<>();
2022-04-11 19:07:35 +08:00
SalaryWeaTable<InsuranceAccountBatchListDTO> table = new SalaryWeaTable<>(user, InsuranceAccountBatchListDTO.class);
//table.getColumns().get(0).setFixed("left");
2022-04-12 19:29:19 +08:00
// for (int i = 0; i < insuranceAccountBatchListDTOS.size(); i++) {
// InsuranceAccountBatchListDTO insuranceAccountBatchListDTO = insuranceAccountBatchListDTOS.get(i);
// if (Objects.equals(insuranceAccountBatchListDTO.getBillStatus(), BillStatusEnum.ARCHIVED.getDefaultLabel())) {
// table.getOperates().getOperate().get(i).getIndex();
//
// resultTable.getOperatesPermission().get(i).get(0).setVisible(false);
// resultTable.getOperatesPermission().get(i).get(1).setVisible(false);
// resultTable.getOperatesPermission().get(i).get(2).setVisible(false);
// resultTable.getOperatesPermission().get(i).get(3).setVisible(false);
// resultTable.getOperates().get(4).setOuter(true);
// }
// if (Objects.equals(insuranceAccountBatchListDTO.getBillStatus(), BillStatusEnum.NOT_ARCHIVED.getDefaultLabel())) {
// resultTable.getOperatesPermission().get(i).get(4).setVisible(false);
// List<InsuranceAccountInspectPO> insuranceAccountInspectPOS = siAccountInspectService.listByBillMonth(insuranceAccountBatchListDTO.getBillMonth(), tenantKey);
// if (CollectionUtils.isEmpty(insuranceAccountInspectPOS)) {
// resultTable.getOperatesPermission().get(i).get(2).setVisible(false);
// }
// }
// }
2022-04-11 19:07:35 +08:00
WeaResultMsg result = new WeaResultMsg(false);
result.putAll(table.makeDataResult());
result.success();
datas.put("pageInfo", pageInfos);
2022-04-12 19:29:19 +08:00
datas.put("operatesPermission",operatesPermission);
2022-04-11 19:07:35 +08:00
//datas.put("dataKey",result.getResultMap());
return datas;
// WeaTable<InsuranceAccountBatchListDTO> resultTable = FormatManager.<InsuranceAccountBatchListDTO>getInstance()
// .genTable(InsuranceAccountBatchListDTO.class, insuranceAccountBatchListDTOPage);
//
// resultTable.getOperates().forEach(e -> {
// if (e.getIndex() == 0) {
// e.setOuter(true);
// }
// });
2022-04-12 19:29:19 +08:00
2022-04-11 19:07:35 +08:00
// resultTable.setModule("hrmsalary");
// resultTable.getColumns().get(0).setFixed("left");
// return WeaResult.success(resultTable);
}
@Override
2022-04-12 10:24:21 +08:00
public Map<String, Object> listCommonPage(InsuranceAccountDetailParam queryParam) {
2022-04-11 19:07:35 +08:00
Long employeeId = (long)user.getUID();
Map<String,Object> datas = new HashMap<>();
2022-04-12 10:24:21 +08:00
//正常缴纳列表
PageInfo<InsuranceAccountDetailPO> pageInfo = siAccountBiz.listCommonPage(queryParam);
List<InsuranceAccountDetailPO> insuranceAccountDetailPOS = pageInfo.getList();
//数据组装
List<Map<String, Object>> records = getService(user).buildCommonRecords(insuranceAccountDetailPOS, employeeId);
2022-04-12 19:29:19 +08:00
PageInfo<Map<String, Object>> pageInfos = new PageInfo<Map<String, Object>>(records);
pageInfos.setTotal(records.size());
pageInfos.setPageNum(queryParam.getCurrent());
pageInfos.setPageSize(queryParam.getPageSize());
//动态列组装
List<WeaTableColumn> weaTableColumn = getColumnBuildService(user).buildCommonColumnsWithStyle(insuranceAccountDetailPOS, employeeId, SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY, false);
SalaryWeaTable<InsuranceAccountDetailPO> table = new SalaryWeaTable<>(user, SalaryArchiveListDTO.class);
table.setColumns(weaTableColumn);
WeaResultMsg result = new WeaResultMsg(false);
result.putAll(table.makeDataResult());
result.success();
datas.put("pageInfo", pageInfos);
datas.put("dataKey",result.getResultMap());
return datas;
}
@Override
public Map<String, Object> listCommonPageByName(InsuranceAccountDetailParam queryParam) {
//增加查询参数userName
if (StringUtils.isNotBlank(queryParam.getUserName())) {
List<DataCollectionEmployee> employeeIdsByUserName = MapperProxyFactory.getProxy(EmployMapper.class).getEmployeeIdsByUserName(queryParam.getUserName());
List<Long> employeeIds = employeeIdsByUserName.stream().map(DataCollectionEmployee::getEmployeeId).collect(Collectors.toList());
queryParam.setEmployeeIds(employeeIds);
}
return listCommonPage(queryParam);
}
@Override
public Map<String, Object> listSupplementaryPage(InsuranceAccountDetailParam queryParam) {
Long employeeId = (long)user.getUID();
Map<String,Object> datas = new HashMap<>();
//正常缴纳列表
queryParam.setPaymentStatus(PaymentStatusEnum.REPAIR.getValue());
List<InsuranceAccountDetailPO> list = MapperProxyFactory.getProxy(InsuranceAccountDetailMapper.class).list(queryParam);
PageInfo<InsuranceAccountDetailPO> pageInfo = new PageInfo<>(list,InsuranceAccountDetailPO.class);
List<InsuranceAccountDetailPO> insuranceAccountDetailPOS = pageInfo.getList();
//数据组装
List<Map<String, Object>> records = getService(user).buildCommonRecords(insuranceAccountDetailPOS, employeeId);
PageInfo<Map<String, Object>> pageInfos = new PageInfo<Map<String, Object>>(records);
pageInfos.setTotal(records.size());
pageInfos.setPageNum(queryParam.getCurrent());
pageInfos.setPageSize(queryParam.getPageSize());
2022-04-12 10:24:21 +08:00
2022-04-12 19:29:19 +08:00
//动态列组装
List<WeaTableColumn> weaTableColumn = getColumnBuildService(user).buildCommonColumnsWithStyle(insuranceAccountDetailPOS, employeeId, SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY, false);
2022-04-12 10:24:21 +08:00
2022-04-12 19:29:19 +08:00
SalaryWeaTable<InsuranceAccountDetailPO> table = new SalaryWeaTable<>(user, SalaryArchiveListDTO.class);
table.setColumns(weaTableColumn);
WeaResultMsg result = new WeaResultMsg(false);
result.putAll(table.makeDataResult());
result.success();
datas.put("pageInfo", pageInfos);
datas.put("dataKey",result.getResultMap());
2022-04-12 10:24:21 +08:00
return datas;
2022-04-11 19:07:35 +08:00
}
2022-04-12 10:24:21 +08:00
2022-04-12 19:29:19 +08:00
@Override
public Map<String, Object> supplementaryByNameList(InsuranceAccountDetailParam queryParam) {
//增加查询参数userName
if (StringUtils.isNotBlank(queryParam.getUserName())) {
List<DataCollectionEmployee> employeeIdsByUserName = MapperProxyFactory.getProxy(EmployMapper.class).getEmployeeIdsByUserName(queryParam.getUserName());
List<Long> employeeIds = employeeIdsByUserName.stream().map(DataCollectionEmployee::getEmployeeId).collect(Collectors.toList());
queryParam.setEmployeeIds(employeeIds);
}
return listSupplementaryPage(queryParam);
}
@Override
public Map<String, Object> getForm(Map<String, Object> params) {
2022-04-14 11:54:16 +08:00
Map<String, Object> apidatas = new HashMap<>();
2022-04-12 19:29:19 +08:00
//条件组
List<SearchConditionGroup> addGroups = new ArrayList<>();
List<SearchConditionItem> conditionItems = new ArrayList<>();
2022-04-14 11:54:16 +08:00
SearchConditionItem datePickerItem = SalaryFormItemUtil.datePickerItem(user, 2, 16, true, 1, "账单月份", "billMonth");
String minDate = SalaryDateUtil.getYearMonth(-1, 0);
String maxDate = SalaryDateUtil.getYearMonth(0, 6);
datePickerItem.getOtherParams().put("minDate",minDate);
datePickerItem.getOtherParams().put("maxDate",maxDate);
InsuranceAccountBatchParam queryParam = InsuranceAccountBatchParam.builder().startTime(minDate).endTime(maxDate).build();
List<InsuranceAccountBatchPO> billMonthList = MapperProxyFactory.getProxy(InsuranceAccountBatchMapper.class).list(queryParam);
if (CollectionUtils.isEmpty(billMonthList)) {
datePickerItem.getOtherParams().put("disabledData", Collections.emptyList());
} else {
datePickerItem.getOtherParams().put("disabledData", billMonthList.stream().map(InsuranceAccountBatchPO::getBillMonth).collect(Collectors.toList()));
}
datePickerItem.getOtherParams().put("type", "month");
datePickerItem.getOtherParams().put("format", "YYYY-MM");
datePickerItem.getOtherParams().put("showFormat", "YYYY-MM");
conditionItems.add(datePickerItem);
2022-04-12 19:29:19 +08:00
2022-04-14 11:54:16 +08:00
SearchConditionItem textareaItem = SalaryFormItemUtil.textareaItem(user, 2, 16, true, 1, 60, "备注", "remarks");
conditionItems.add(textareaItem);
addGroups.add(new SearchConditionGroup("常用条件",true,conditionItems));
apidatas.put("billMonth", SalaryDateUtil.getYearMonth(0, 0));
apidatas.put("condition",addGroups);
return apidatas;
}
@Override
2022-04-15 13:17:25 +08:00
public void save(AccountParam param) {
2022-04-14 11:54:16 +08:00
Long employeeId = (long)user.getUID();
2022-04-15 13:17:25 +08:00
String lastName = user.getLastname();
2022-04-14 11:54:16 +08:00
ValidUtil.doValidator(param);
2022-04-15 13:17:25 +08:00
siAccountBiz.save(true,param,employeeId,lastName);
}
@Override
public void commonAccount(SaveCommonAccountParam param) {
Long employeeId = (long)user.getUID();
ValidUtil.doValidator(param);
siAccountBiz.saveCommonAccount(param,employeeId);
}
@Override
public void delete(AccountParam accountParam) {
Long employeeId = (long)user.getUID();
siAccountBiz.delete(accountParam,employeeId);
}
@Override
public void saveCommonAccount(SaveCommonAccountParam accountParam) {
Long employeeId = (long)user.getUID();
siAccountBiz.saveCommonAccount(accountParam,employeeId);
}
@Override
public void saveSupplementaryAccount(SaveSupplementaryAccountParam saveSupplementaryAccountParam) {
Long employeeId = (long)user.getUID();
siAccountBiz.saveSupplementaryAccount(saveSupplementaryAccountParam,employeeId);
}
@Override
public void deleteCommonAccount(SaveCommonAccountParam param) {
Long employeeId = (long)user.getUID();
siAccountBiz.deleteCommonAccount(param,employeeId);
}
@Override
public void deleteSummplementaryAccount(List<SupplementAccountBaseParam> supplementAccountBaseParams) {
Long employeeId = (long)user.getUID();
siAccountBiz.deleteSupplementaryAccount(supplementAccountBaseParams,employeeId);
}
@Override
public void file(AccountParam accountParam) {
Long employeeId = (long)user.getUID();
String billMonth = accountParam.getBillMonth();
siAccountBiz.file(billMonth,employeeId);
}
@Override
public void unconfirmed(Collection<Long> ids) {
List<InsuranceAccountInspectPO> insuranceAccountInspectPOS = MapperProxyFactory.getProxy(InsuranceAccountInspectMapper.class).getByInspectStatusAndIds(InspectStatusEnum.COMFORED.getValue(),ids);
if (CollectionUtils.isNotEmpty(insuranceAccountInspectPOS)) {
MapperProxyFactory.getProxy(InsuranceAccountDetailMapper.class).batchUnConfirmedInspectDetails(insuranceAccountInspectPOS.stream().map(InsuranceAccountInspectPO::getId).collect(Collectors.toList()));
}
}
@Override
public Map<String, Boolean> buttonCheck(String billMonth) {
Map<String, Boolean> result = new HashMap<>();
List<InsuranceAccountInspectPO> list = MapperProxyFactory.getProxy(InsuranceAccountInspectMapper.class).getByInspectStatusAndBillMonth(InspectStatusEnum.IGNORE.getValue(),billMonth);
if (CollectionUtils.isEmpty(list)) {
result.put("displayFlag", false);
return result;
}
result.put("displayFlag", true);
return result;
2022-04-12 19:29:19 +08:00
}
2022-04-12 10:24:21 +08:00
2022-04-11 19:07:35 +08:00
}