package com.engine.salary.service.impl; import com.api.browser.bean.SearchConditionGroup; import com.api.browser.bean.SearchConditionItem; import com.cloudstore.eccom.pc.table.*; import com.cloudstore.eccom.result.WeaResultMsg; import com.engine.common.util.ServiceUtil; import com.engine.core.impl.Service; import com.engine.salary.biz.SIAccountBiz; import com.engine.salary.biz.SIArchivesBiz; import com.engine.salary.component.SalaryWeaTable; import com.engine.salary.constant.SalaryDefaultTenantConstant; import com.engine.salary.entity.datacollection.DataCollectionEmployee; import com.engine.salary.entity.salaryarchive.dto.SalaryArchiveListDTO; import com.engine.salary.entity.siaccount.bo.InsuranceAccountBO; import com.engine.salary.entity.siaccount.dto.InsuranceAccountBatchListDTO; import com.engine.salary.entity.siaccount.dto.InsuranceAccountTabDTO; import com.engine.salary.entity.siaccount.param.*; import com.engine.salary.entity.siaccount.po.InsuranceAccountBatchPO; import com.engine.salary.entity.siaccount.po.InsuranceAccountDetailPO; import com.engine.salary.entity.siaccount.po.InsuranceAccountInspectPO; import com.engine.salary.entity.siarchives.po.InsuranceArchivesEmployeePO; import com.engine.salary.enums.UserStatusEnum; import com.engine.salary.enums.siaccount.BillStatusEnum; import com.engine.salary.enums.siaccount.InspectStatusEnum; import com.engine.salary.enums.siaccount.PaymentStatusEnum; import com.engine.salary.mapper.datacollection.EmployMapper; import com.engine.salary.mapper.siaccount.InsuranceAccountBatchMapper; import com.engine.salary.mapper.siaccount.InsuranceAccountDetailMapper; import com.engine.salary.mapper.siaccount.InsuranceAccountInspectMapper; import com.engine.salary.service.ColumnBuildService; import com.engine.salary.service.RecordsBuildService; import com.engine.salary.service.SIAccountService; import java.util.*; import java.util.stream.Collectors; import com.engine.salary.util.SalaryDateUtil; import com.engine.salary.util.SalaryFormItemUtil; import com.engine.salary.util.SalaryI18nUtil; import com.engine.salary.util.db.MapperProxyFactory; import com.engine.salary.util.page.PageInfo; import com.engine.salary.util.valid.ValidUtil; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import weaver.hrm.User; /** * @Author weaver_cl * @Description: TODO * @Date 2022/4/11 * @Version V1.0 **/ public class SIAccountServiceImpl extends Service implements SIAccountService { private SIAccountBiz siAccountBiz = new SIAccountBiz(); private SIArchivesBiz siArchivesBiz = new SIArchivesBiz(); public RecordsBuildService getService(User user) { return ServiceUtil.getService(RecordsBuildServiceImpl.class,user); } public ColumnBuildService getColumnBuildService(User user) { return ServiceUtil.getService(ColumnBuildServiceImpl.class,user); } @Override public Map listPage(InsuranceAccountBatchParam queryParam) { Long employeeId = (long)user.getUID(); Map datas = new HashMap<>(); //福利台账列表 PageInfo pageInfo = siAccountBiz.listPage(queryParam,employeeId); Collection insuranceAccountBatchPOS = pageInfo.getList(); List insuranceAccountBatchListDTOS = InsuranceAccountBO.buildAccountBatchDTOList(insuranceAccountBatchPOS); PageInfo pageInfos = new PageInfo<>(insuranceAccountBatchListDTOS,InsuranceAccountBatchListDTO.class); pageInfos.setTotal(insuranceAccountBatchListDTOS.size()); pageInfos.setPageNum(queryParam.getCurrent()); pageInfos.setPageSize(queryParam.getPageSize()); List>> operatesPermission = new ArrayList<>(); SalaryWeaTable table = new SalaryWeaTable<>(user, InsuranceAccountBatchListDTO.class); //table.getColumns().get(0).setFixed("left"); // 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 insuranceAccountInspectPOS = siAccountInspectService.listByBillMonth(insuranceAccountBatchListDTO.getBillMonth(), tenantKey); // if (CollectionUtils.isEmpty(insuranceAccountInspectPOS)) { // resultTable.getOperatesPermission().get(i).get(2).setVisible(false); // } // } // } WeaResultMsg result = new WeaResultMsg(false); result.putAll(table.makeDataResult()); result.success(); datas.put("pageInfo", pageInfos); datas.put("operatesPermission",operatesPermission); //datas.put("dataKey",result.getResultMap()); return datas; // WeaTable resultTable = FormatManager.getInstance() // .genTable(InsuranceAccountBatchListDTO.class, insuranceAccountBatchListDTOPage); // // resultTable.getOperates().forEach(e -> { // if (e.getIndex() == 0) { // e.setOuter(true); // } // }); // resultTable.setModule("hrmsalary"); // resultTable.getColumns().get(0).setFixed("left"); // return WeaResult.success(resultTable); } @Override public Map listCommonPage(InsuranceAccountDetailParam queryParam) { Long employeeId = (long)user.getUID(); Map datas = new HashMap<>(); //正常缴纳列表 PageInfo pageInfo = siAccountBiz.listCommonPage(queryParam); List insuranceAccountDetailPOS = pageInfo.getList(); //数据组装 List> records = getService(user).buildCommonRecords(insuranceAccountDetailPOS, employeeId); PageInfo> pageInfos = new PageInfo<>(records); pageInfos.setTotal(records.size()); pageInfos.setPageNum(queryParam.getCurrent()); pageInfos.setPageSize(queryParam.getPageSize()); //动态列组装 List weaTableColumn = getColumnBuildService(user).buildCommonColumnsWithStyle(insuranceAccountDetailPOS, employeeId, SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY, false); SalaryWeaTable 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 listCommonPageByName(InsuranceAccountDetailParam queryParam) { //增加查询参数userName if (StringUtils.isNotBlank(queryParam.getUserName())) { List employeeIdsByUserName = MapperProxyFactory.getProxy(EmployMapper.class).getEmployeeIdsByUserName(queryParam.getUserName()); List employeeIds = employeeIdsByUserName.stream().map(DataCollectionEmployee::getEmployeeId).collect(Collectors.toList()); queryParam.setEmployeeIds(employeeIds); } return listCommonPage(queryParam); } @Override public Map listSupplementaryPage(InsuranceAccountDetailParam queryParam) { Long employeeId = (long)user.getUID(); Map datas = new HashMap<>(); //补缴缴纳列表 queryParam.setPaymentStatus(PaymentStatusEnum.REPAIR.getValue()); //PageUtil.start(queryParam.getCurrent(), queryParam.getPageSize()); List list = MapperProxyFactory.getProxy(InsuranceAccountDetailMapper.class).list(queryParam); PageInfo pageInfo = new PageInfo<>(list,InsuranceAccountDetailPO.class); List insuranceAccountDetailPOS = pageInfo.getList(); //数据组装 List> records = getService(user).buildCommonRecords(insuranceAccountDetailPOS, employeeId); PageInfo> pageInfos = new PageInfo>(records); pageInfos.setTotal(records.size()); pageInfos.setPageNum(queryParam.getCurrent()); pageInfos.setPageSize(queryParam.getPageSize()); //动态列组装 List weaTableColumn = getColumnBuildService(user).buildCommonColumnsWithStyle(insuranceAccountDetailPOS, employeeId, SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY, false); SalaryWeaTable 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 supplementaryByNameList(InsuranceAccountDetailParam queryParam) { //增加查询参数userName if (StringUtils.isNotBlank(queryParam.getUserName())) { List employeeIdsByUserName = MapperProxyFactory.getProxy(EmployMapper.class).getEmployeeIdsByUserName(queryParam.getUserName()); List employeeIds = employeeIdsByUserName.stream().map(DataCollectionEmployee::getEmployeeId).collect(Collectors.toList()); queryParam.setEmployeeIds(employeeIds); } return listSupplementaryPage(queryParam); } @Override public Map getForm(Map params) { Map apidatas = new HashMap<>(); //条件组 List addGroups = new ArrayList<>(); List conditionItems = new ArrayList<>(); 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 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); 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 public void save(AccountParam param) { Long employeeId = (long)user.getUID(); String lastName = user.getLastname(); ValidUtil.doValidator(param); 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 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 ids) { List 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 buttonCheck(String billMonth) { Map result = new HashMap<>(); List 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; } @Override public void ignore(Collection ids) { List insuranceAccountInspectPOS = MapperProxyFactory.getProxy(InsuranceAccountInspectMapper.class).getByInspectStatusAndIds(InspectStatusEnum.IGNORE.getValue(),ids); if (CollectionUtils.isNotEmpty(insuranceAccountInspectPOS)) { MapperProxyFactory.getProxy(InsuranceAccountDetailMapper.class).batchIgnoreInspectDetails(insuranceAccountInspectPOS.stream().map(InsuranceAccountInspectPO::getId).collect(Collectors.toList())); } } @Override public InsuranceAccountTabDTO tabList(String billMonth) { InsuranceAccountTabDTO insuranceAccountTabDTO = InsuranceAccountTabDTO.builder().build(); InsuranceAccountBatchPO insuranceAccountBatchPO = MapperProxyFactory.getProxy(InsuranceAccountBatchMapper.class).getByBillMonth(billMonth); boolean isShow = false; if (insuranceAccountBatchPO == null || insuranceAccountBatchPO.getBillStatus() == BillStatusEnum.NOT_ARCHIVED.getValue()) { isShow = true; } if (insuranceAccountBatchPO != null) { insuranceAccountTabDTO.setRemarks(insuranceAccountBatchPO.getRemarks()); } List> tabList = new ArrayList<>(); Map common = new HashMap<>(); common.put("id", "1"); common.put("content", SalaryI18nUtil.getI18nLabel( 92265, "正常缴纳")); tabList.add(common); if (isShow) { Map change = new HashMap<>(); change.put("id", "2"); change.put("content", SalaryI18nUtil.getI18nLabel( 100509, "异动清单")); tabList.add(change); } Map repair = new HashMap<>(); repair.put("id", "3"); repair.put("content", SalaryI18nUtil.getI18nLabel(92267, "补缴")); tabList.add(repair); Map overView = new HashMap<>(); overView.put("id", "4"); overView.put("content", SalaryI18nUtil.getI18nLabel( 99927, "总览")); tabList.add(overView); insuranceAccountTabDTO.setTabList(tabList); insuranceAccountTabDTO.setShow(isShow); insuranceAccountTabDTO.setBillMonth(billMonth); return insuranceAccountTabDTO; } @Override public Map changeList(InsuranceAccountDetailParam param) { Map datas = new HashMap<>(); Long employeeId = (long)user.getUID(); List insuranceArchivesEmployeePOS = MapperProxyFactory.getProxy(InsuranceAccountDetailMapper.class).changeList(param.getUserName(), param.getCurrent(), param.getPageSize()); List> records = siArchivesBiz.buildTableData(insuranceArchivesEmployeePOS); PageInfo> pageInfos = new PageInfo<>(records); pageInfos.setTotal(records.size()); pageInfos.setPageNum(param.getCurrent()); pageInfos.setPageSize(param.getPageSize()); List weaTableColumns = siArchivesBiz.buildWeaTableColumns(insuranceArchivesEmployeePOS, employeeId); WeaTable table = new WeaTable(); table.setPageUID(UUID.randomUUID().toString()); table.setColumns(weaTableColumns); table.setTableType(WeaTableType.CHECKBOX); WeaTableOperates weaTableOperates = new WeaTableOperates(); WeaTableOperate weaTableOperate = new WeaTableOperate(); weaTableOperate.setIndex("0"); weaTableOperate.setText("移除"); WeaTableOperate weaTableOperate1 = new WeaTableOperate(); weaTableOperate1.setIndex("1"); weaTableOperate1.setText("添加"); table.setOperates(weaTableOperates); List> permissions = new ArrayList<>(); for (int i = 0; i < records.size(); i++) { List permission = new ArrayList<>(); if (UserStatusEnum.DEPARTURE.getDescription().equals(records.get(i).get("status"))) { permission.add(new Permission(true, false)); permission.add(new Permission(false, false)); permissions.add(permission); } if (UserStatusEnum.DEPARTURE.getDescription().equals(records.get(i).get("status"))) { permission.add(new Permission(false, false)); permission.add(new Permission(true, false)); permissions.add(permission); } } WeaResultMsg result = new WeaResultMsg(false); result.putAll(table.makeDataResult()); result.success(); datas.put("permissions",permissions); datas.put("pageInfo", pageInfos); datas.put("dataKey",result.getResultMap()); return datas; } @Override public void accountInspect(InspectAccountParam param) { Long employeeId = (long)user.getUID(); ValidUtil.doValidator(param); siAccountBiz.accountInspect(param.getIds(),param.getBillMonth(),employeeId); } @Override public Map getInspectTable(InsuranceAccountDetailParam param) { Map datas = new HashMap<>(); List insuranceAccountInspectPOS = MapperProxyFactory.getProxy(InsuranceAccountInspectMapper.class).getByBillMonth(param.getBillMonth()); List> records = getService(user).buildInspectRecords(insuranceAccountInspectPOS); PageInfo> pageInfos = new PageInfo<>(records); pageInfos.setTotal(records.size()); pageInfos.setPageNum(param.getCurrent()); pageInfos.setPageSize(param.getPageSize()); List weaTableColumns = getColumnBuildService(user).buildInspectColumns(insuranceAccountInspectPOS); WeaTable table = new WeaTable(); table.setPageUID(UUID.randomUUID().toString()); table.setColumns(weaTableColumns); table.setTableType(WeaTableType.CHECKBOX); WeaTableOperates weaTableOperates = new WeaTableOperates(); WeaTableOperate weaTableOperate = new WeaTableOperate(); weaTableOperate.setIndex("0"); weaTableOperate.setText("忽略"); WeaTableOperate weaTableOperate1 = new WeaTableOperate(); weaTableOperate1.setIndex("1"); weaTableOperate1.setText("重置"); table.setOperates(weaTableOperates); List> permissions = new ArrayList<>(); for (int i = 0; i < records.size(); i++) { List permission = new ArrayList<>(); Permission permissionCheckBox = new Permission(); if (InspectStatusEnum.IGNORE.getValue() == records.get(i).get("inspectStatus")) { permissionCheckBox.setVisible(true); permissionCheckBox.setDisabled(false); permission.add(new Permission(true, false)); permission.add(new Permission(false, true)); permissions.add(permission); } if (InspectStatusEnum.COMFORED.getValue() == records.get(i).get("inspectStatus")) { permissionCheckBox.setVisible(true); permissionCheckBox.setDisabled(true); permission.add(new Permission(false, true)); permission.add(new Permission(true, false)); permissions.add(permission); } } WeaResultMsg result = new WeaResultMsg(false); result.putAll(table.makeDataResult()); result.success(); datas.put("permissions",permissions); datas.put("pageInfo", pageInfos); datas.put("dataKey",result.getResultMap()); return datas; } }