package com.engine.salary.service.impl; import com.api.browser.bean.SearchConditionGroup; import com.api.browser.bean.SearchConditionItem; import com.api.browser.util.ConditionFactory; import com.cloudstore.eccom.pc.table.WeaTableColumn; import com.cloudstore.eccom.pc.table.WeaTableOperate; import com.cloudstore.eccom.pc.table.WeaTableOperates; 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.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.param.InsuranceAccountBatchParam; import com.engine.salary.entity.siaccount.param.InsuranceAccountDetailParam; import com.engine.salary.entity.siaccount.param.Permission; import com.engine.salary.entity.siaccount.po.InsuranceAccountBatchPO; import com.engine.salary.entity.siaccount.po.InsuranceAccountDetailPO; import com.engine.salary.enums.siaccount.BillStatusEnum; import com.engine.salary.enums.siaccount.PaymentStatusEnum; import com.engine.salary.mapper.datacollection.EmployMapper; import com.engine.salary.mapper.siaccount.InsuranceAccountDetailMapper; 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.db.MapperProxyFactory; import com.engine.salary.util.page.PageInfo; 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(); 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()); 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) { ConditionFactory conditionFactory = new ConditionFactory(user); //条件组 List addGroups = new ArrayList<>(); List conditionItems = new ArrayList<>(); // // WeaForm weaForm = new WeaForm(); // WeaFormItem weaFormItem = new WeaFormItem(WeaFormItemType.DATEPICKER); // weaFormItem.setRequired(true); // String minDate = SalaryDateUtil.getYearMonth(-1, 0); // String maxDate = SalaryDateUtil.getYearMonth(0, 6); // weaFormItem.getOtherParams().put("minDate", minDate); // weaFormItem.getOtherParams().put("maxDate", maxDate); // List billMonthList = siAccountService.listByTimeRange(minDate, maxDate, tenantKey); // if (CollectionUtils.isEmpty(billMonthList)) { // weaFormItem.getOtherParams().put("disabledData", Collections.emptyList()); // } else { // weaFormItem.getOtherParams().put("disabledData", billMonthList.stream().map(InsuranceAccountBatchPO::getBillMonth).collect(Collectors.toList())); // } // weaFormItem.getOtherParams().put("type", "month"); // weaFormItem.getOtherParams().put("format", "YYYY-MM"); // weaFormItem.getOtherParams().put("showFormat", "YYYY-MM"); // weaForm.getItems().put("billMonth", weaFormItem); // // // // // WeaFormItem remarksItem = new WeaFormItem(WeaFormItemType.TEXTAREA); // remarksItem.setMaxLength("60"); // weaForm.getItems().put("remarks", remarksItem); // List one = new ArrayList<>(); // one.add(new WeaFormLayout("billMonth", SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 92146, "账单月份"), new String[]{"billMonth"})); // List two = new ArrayList<>(); // two.add(new WeaFormLayout("remarks", SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 84961, "备注"), new String[]{"remarks"})); // weaForm.getLayout().add(one); // weaForm.getLayout().add(two); // Map data = new HashMap<>(); // data.put("billMonth", SalaryDateUtil.getYearMonth(0, 0)); // weaForm.setData(data); return null; } }