From 52d8907479e58ff70e91aa3889a68ebbb8d9384e Mon Sep 17 00:00:00 2001 From: zhaopeng Date: Mon, 2 Feb 2026 18:39:07 +0800 Subject: [PATCH] =?UTF-8?q?Revert=20"feat:=20=E9=87=8D=E6=96=B0=E6=8F=90?= =?UTF-8?q?=E4=BA=A4de=E4=BF=AE=E6=94=B9"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit c2a46f48d4000d02a7610a6da47af07b77d0680a. --- src/com/api/salary/listener/InitListener.java | 53 + .../salary/web/AddUpDeductionController.java | 9 + .../salary/web/AddUpSituationController.java | 8 + .../api/salary/web/AttendQuoteController.java | 8 + src/com/api/salary/web/AuthController.java | 8 + src/com/api/salary/web/ExtEmpController.java | 8 + .../api/salary/web/MaintainerController.java | 9 + .../salary/web/MySalaryShowSetController.java | 13 + .../salary/web/OtherDeductionController.java | 8 + src/com/api/salary/web/ProcessController.java | 8 + src/com/api/salary/web/PushController.java | 8 + .../api/salary/web/SIAccountController.java | 13 + .../web/SIArchiveActionAPIController.java | 14 + .../api/salary/web/SIArchivesController.java | 13 + .../api/salary/web/SICategoryController.java | 13 + .../api/salary/web/SIExportController.java | 13 + .../api/salary/web/SIReportController.java | 16 + .../api/salary/web/SISchemeController.java | 13 + .../api/salary/web/SalaryAcctController.java | 8 + .../web/SalaryArchiveActionAPIController.java | 10 + .../salary/web/SalaryArchiveController.java | 8 + .../api/salary/web/SalaryBillController.java | 7 + .../salary/web/SalaryCommonController.java | 7 + .../api/salary/web/SalaryFieldController.java | 7 + .../salary/web/SalaryFormulaController.java | 7 + .../api/salary/web/SalaryItemController.java | 7 + .../salary/web/SalaryProgressController.java | 7 + .../salary/web/SalarySendRangeController.java | 8 + .../api/salary/web/SalarySobController.java | 15 + .../SalaryStatisticsDimensionController.java | 9 + .../SalaryStatisticsEchartsController.java | 8 + .../SalaryStatisticsEmployeeController.java | 8 + .../web/SalaryStatisticsItemController.java | 9 + .../web/SalaryStatisticsPushController.java | 8 + .../web/SalaryStatisticsReportController.java | 9 + .../web/SalarySystemConfigController.java | 8 + .../web/SpecialAddDeductionController.java | 8 + .../api/salary/web/TaxAgentController.java | 7 + .../salary/web/TaxDeclarationController.java | 7 + src/com/api/salary/web/TaxRateController.java | 7 + .../salary/web/VariableArchiveController.java | 8 + .../salary/web/VariableItemController.java | 8 + .../action/BatEditSalaryExcelAction.java | 112 + .../action/CheckBatEditSalaryExcelAction.java | 111 + .../action/CheckEditSIArchiveAction.java | 153 + .../salary/action/CheckEditSalaryAction.java | 147 + .../salary/action/CheckInitSalaryAction.java | 208 + .../CheckStayAddToPaySIArchiveAction.java | 161 + .../CheckStayDelToStopSIArchiveAction.java | 160 + .../salary/action/CheckStopSalaryAction.java | 177 + .../action/CopyToPaySIArchiveAction.java | 170 + .../salary/action/EditSIArchiveAction.java | 152 + .../salary/action/EditSalaryAction.java | 147 + .../action/EditToPaySIArchiveAction.java | 198 + .../action/EditToStopSIArchiveAction.java | 201 + .../action/FileSalaryAcctRecordAction.java | 83 + .../salary/action/InitSalaryAction.java | 216 + .../engine/salary/action/RehireAction.java | 261 + .../action/SalaryAcctFileByIdAction.java | 64 + .../salary/action/SendSalaryAction.java | 136 + .../action/StayAddToPaySIArchiveAction.java | 171 + .../action/StayDelToStopSIArchiveAction.java | 196 + .../salary/action/StopSalaryAction.java | 203 + .../action/UpdateSISchemeDetailAction.java | 272 + .../updateSalaryApprovalStatusAction.java | 78 + src/com/engine/salary/annotation/Auth.java | 29 + .../engine/salary/annotation/AuthField.java | 22 + src/com/engine/salary/annotation/AuthOpt.java | 20 + src/com/engine/salary/annotation/Encrypt.java | 20 + src/com/engine/salary/annotation/I18n.java | 20 + .../salary/annotation/SalaryFormulaVar.java | 27 + .../engine/salary/annotation/SalaryTable.java | 69 + .../salary/annotation/SalaryTableColumn.java | 34 + .../salary/annotation/SalaryTableOperate.java | 27 + .../engine/salary/annotation/TableTitle.java | 13 + .../engine/salary/biz/AddUpDeductionBiz.java | 171 + .../engine/salary/biz/AddUpSituationBiz.java | 191 + src/com/engine/salary/biz/AttendQuoteBiz.java | 66 + .../engine/salary/biz/AttendQuoteDataBiz.java | 67 + .../salary/biz/AttendQuoteDataValueBiz.java | 93 + .../salary/biz/AttendQuoteFieldBiz.java | 108 + .../biz/AttendQuoteFieldSettingBiz.java | 46 + src/com/engine/salary/biz/EmployBiz.java | 247 + .../engine/salary/biz/OtherDeductionBiz.java | 226 + src/com/engine/salary/biz/SIAccountBiz.java | 2683 ++++++ src/com/engine/salary/biz/SIArchivesBiz.java | 2653 ++++++ src/com/engine/salary/biz/SICategoryBiz.java | 184 + src/com/engine/salary/biz/SISchemeBiz.java | 497 ++ .../engine/salary/biz/SalaryArchiveBiz.java | 66 + .../salary/biz/SalaryArchiveDimissionBiz.java | 42 + .../salary/biz/SalaryArchiveItemBiz.java | 251 + .../salary/biz/SalaryArchiveTaxAgentBiz.java | 93 + src/com/engine/salary/biz/SalaryItemBiz.java | 157 + src/com/engine/salary/biz/SalarySendBiz.java | 121 + .../engine/salary/biz/SalarySendInfoBiz.java | 148 + .../salary/biz/SalarySendRangeObjBiz.java | 83 + .../salary/biz/SalarySobAdjustRuleBiz.java | 50 + src/com/engine/salary/biz/SalarySobBiz.java | 86 + .../salary/biz/SalarySobCheckRuleBiz.java | 109 + .../salary/biz/SalarySobDefaultItemBiz.java | 22 + .../biz/SalarySobDefaultItemGroupBiz.java | 23 + .../salary/biz/SalarySobEmpFieldBiz.java | 88 + .../engine/salary/biz/SalarySobItemBiz.java | 134 + .../salary/biz/SalarySobItemGroupBiz.java | 94 + .../salary/biz/SalarySobItemHideBiz.java | 66 + .../engine/salary/biz/SalarySobRangeBiz.java | 84 + .../engine/salary/biz/SalaryTemplateBiz.java | 143 + .../salary/biz/SpecialAddDeductionBiz.java | 223 + src/com/engine/salary/biz/SubCompanyBiz.java | 48 + .../engine/salary/biz/SysSalaryItemBiz.java | 51 + src/com/engine/salary/biz/TaxAgentBiz.java | 43 + src/com/engine/salary/biz/TaxRateBiz.java | 323 + .../engine/salary/biz/TaxRateDetailBiz.java | 48 + .../engine/salary/cache/SalaryCacheKey.java | 76 + .../engine/salary/cache/SalaryModuleKey.java | 16 + .../salary/cmd/TaxRate/TaxRateDeleteCmd.java | 45 + .../salary/cmd/TaxRate/TaxRateGetFormCmd.java | 37 + .../salary/cmd/TaxRate/TaxRateListCmd.java | 106 + .../salary/cmd/TaxRate/TaxRateSaveCmd.java | 36 + .../salary/cmd/TaxRate/TaxRateUpdateCmd.java | 33 + .../cmd/siarchives/SIArchivesTipsCmd.java | 47 + .../cmd/sicategory/SICategoryGetFormCmd.java | 86 + .../cmd/sicategory/SICategoryInsertCmd.java | 39 + .../cmd/sicategory/SICategoryListCmd.java | 53 + .../cmd/sicategory/SICategoryUpdateCmd.java | 39 + .../SICategoryUpdateStatusByIdCmd.java | 40 + .../salary/cmd/sischeme/SISchemeCopyCmd.java | 40 + .../cmd/sischeme/SISchemeDeleteCmd.java | 74 + .../cmd/sischeme/SISchemeGetFormCmd.java | 48 + .../cmd/sischeme/SISchemeInsertCmd.java | 40 + .../salary/cmd/sischeme/SISchemeListCmd.java | 61 + .../cmd/sischeme/SISchemeUpdateCmd.java | 40 + .../engine/salary/common/BaseQueryParam.java | 33 + .../engine/salary/common/LocalDateRange.java | 36 + .../engine/salary/common/SalaryContext.java | 38 + src/com/engine/salary/component/Page.java | 170 + src/com/engine/salary/component/PageInfo.java | 380 + .../salary/component/PageInterceptor.java | 176 + .../engine/salary/component/ReflectUtil.java | 174 + .../salary/component/SalaryWeaTable.java | 116 + .../salary/component/WeaFormOption.java | 75 + .../salary/component/WeaTableColumnGroup.java | 68 + .../salary/config/SalaryElogConfig.java | 325 + .../salary/config/SalaryPermissionConfig.java | 194 + .../salary/constant/HrmSalaryPayrollConf.java | 15 + .../constant/SalaryArchiveConstant.java | 36 + .../salary/constant/SalaryAuthConstant.java | 18 + .../salary/constant/SalaryBillConstant.java | 30 + .../constant/SalaryDefaultTenantConstant.java | 14 + .../constant/SalaryFormulaFieldConstant.java | 30 + .../salary/constant/SalaryItemConstant.java | 44 + .../constant/SalaryItemDataTypeConstant.java | 21 + ...aryTemplateSalaryItemSetGroupConstant.java | 25 + .../SalrayCheckSecondAuthConstant.java | 46 + .../constant/TaxAgentPermissionConstant.java | 24 + .../TaxDeclarationDataIndexConstant.java | 278 + .../constant/TaxRateDataIndexConstant.java | 56 + src/com/engine/salary/constant/des.json | 1552 ++++ .../engine/salary/encrypt/AESEncryptUtil.java | 149 + .../engine/salary/encrypt/EncryptSetting.java | 16 + .../engine/salary/encrypt/EncryptUtil.java | 167 + .../engine/salary/encrypt/TestEncrypt.java | 18 + .../entity/agency/bo/PaymentAgencyBO.java | 57 + .../agency/dto/PaymentAgencyFormDTO.java | 58 + .../agency/dto/PaymentAgencyListDTO.java | 55 + .../entity/agency/po/PaymentAgencyPO.java | 56 + .../salary/entity/auth/dto/AuthDataDTO.java | 38 + .../salary/entity/auth/dto/AuthLimitDTO.java | 18 + .../salary/entity/auth/dto/AuthMemberDTO.java | 26 + .../salary/entity/auth/dto/AuthOptDTO.java | 77 + .../salary/entity/auth/dto/AuthRoleDTO.java | 53 + .../entity/auth/dto/AuthRoleDataDTO.java | 32 + .../entity/auth/dto/AuthRoleEmpDTO.java | 32 + .../salary/entity/auth/dto/AuthTreeDTO.java | 62 + .../engine/salary/entity/auth/dto/EmpOpt.java | 19 + .../engine/salary/entity/auth/dto/Opt.java | 15 + .../salary/entity/auth/dto/PermissionDTO.java | 5 + .../salary/entity/auth/dto/RoleLimit.java | 19 + .../salary/entity/auth/dto/SobOptAuth.java | 19 + .../salary/entity/auth/dto/TaxEmpOptAuth.java | 19 + .../salary/entity/auth/dto/TaxOptAuth.java | 19 + .../entity/auth/param/AuthDataQueryParam.java | 20 + .../entity/auth/param/AuthDataSaveParam.java | 41 + .../auth/param/AuthMemberQueryParam.java | 20 + .../auth/param/AuthMemberSaveParam.java | 29 + .../entity/auth/param/AuthOptSaveParam.java | 26 + .../auth/param/AuthRoleListQueryParam.java | 59 + .../entity/auth/param/AuthRoleSaveParam.java | 44 + .../entity/auth/param/AuthSyncParam.java | 17 + .../entity/auth/param/AuthTreeQueryParam.java | 28 + .../salary/entity/auth/po/AuthDataPO.java | 92 + .../salary/entity/auth/po/AuthMemberPO.java | 71 + .../salary/entity/auth/po/AuthOptPO.java | 75 + .../salary/entity/auth/po/AuthResourcePO.java | 83 + .../salary/entity/auth/po/AuthRoleDataPO.java | 69 + .../salary/entity/auth/po/AuthRoleEmpPO.java | 61 + .../salary/entity/auth/po/AuthRolePO.java | 69 + .../salary/entity/auth/vo/Permission.java | 40 + .../salary/entity/config/SalaryConfig.java | 49 + .../entity/datacollection/AddUpDeduction.java | 139 + .../entity/datacollection/AddUpSituation.java | 239 + .../DataCollectionEmployee.java | 140 + .../datacollection/bo/AttendQuoteDataBO.java | 71 + .../datacollection/bo/AttendQuoteFieldBO.java | 106 + .../datacollection/bo/DataCollectionBO.java | 52 + .../datacollection/bo/VariableArchiveBO.java | 281 + .../bo/VariableArchiveExcelBO.java | 314 + .../datacollection/dto/AddUpDeductionDTO.java | 170 + .../dto/AddUpDeductionRecordDTO.java | 131 + .../datacollection/dto/AddUpSituationDTO.java | 222 + .../dto/AddUpSituationRecordDTO.java | 177 + .../dto/AttendQuoteDataBaseDTO.java | 61 + .../dto/AttendQuoteDataDTO.java | 29 + .../dto/AttendQuoteDataValueDTO.java | 27 + .../dto/AttendQuoteFieldFormDTO.java | 40 + .../dto/AttendQuoteFieldListDTO.java | 63 + .../AttendQuoteFieldSettingFieldListDTO.java | 33 + .../dto/AttendQuoteFieldSettingListDTO.java | 32 + .../dto/AttendQuoteListDTO.java | 84 + .../dto/OtherDeductionListDTO.java | 128 + .../dto/OtherDeductionRecordDTO.java | 101 + .../dto/SpecialAddDeductionListDTO.java | 140 + .../dto/SpecialAddDeductionRecordDTO.java | 103 + .../dto/VariableArchiveItemDTO.java | 33 + .../dto/VariableArchiveListDTO.java | 104 + .../dto/VariableItemListDTO.java | 37 + .../param/AddDeductionAutoAddParam.java | 24 + .../param/AddUpDeductionImportParam.java | 31 + .../param/AddUpDeductionQueryParam.java | 73 + .../AddUpDeductionRecordDeleteParam.java | 29 + .../param/AddUpDeductionRecordParam.java | 67 + .../param/AddUpSituationDeleteParam.java | 29 + .../param/AddUpSituationImportParam.java | 29 + .../param/AddUpSituationParam.java | 101 + .../param/AddUpSituationQueryParam.java | 68 + .../param/AttendModuleSettingFieldParam.java | 27 + .../param/AttendQuoteCheckOperationParam.java | 35 + .../param/AttendQuoteDataEditParam.java | 32 + .../AttendQuoteDataExportTemplateParam.java | 29 + .../param/AttendQuoteDataImportParam.java | 36 + .../param/AttendQuoteDataQueryParam.java | 48 + .../param/AttendQuoteDataSaveParam.java | 28 + .../param/AttendQuoteDataSyncParam.java | 52 + .../param/AttendQuoteFieldQueryParam.java | 62 + .../param/AttendQuoteFieldSaveParam.java | 52 + .../AttendQuoteFieldSettingQueryParam.java | 29 + .../AttendQuoteFieldSettingRecoverParam.java | 28 + .../AttendQuoteFieldSettingSaveParam.java | 28 + .../param/AttendQuoteQueryParam.java | 34 + .../param/OtherDeductionExtendLastParam.java | 21 + .../param/OtherDeductionImportParam.java | 31 + .../param/OtherDeductionParam.java | 63 + .../param/OtherDeductionQueryParam.java | 65 + .../QuerySalaryCycleAndAttendCycleParam.java | 25 + .../param/SpecialAddDeductionImportParam.java | 28 + .../param/SpecialAddDeductionParam.java | 80 + .../param/SpecialAddDeductionQueryParam.java | 60 + .../SpecialAddDeductionRecordDeleteParam.java | 25 + .../VariableArchiveImportHandleParam.java | 104 + .../param/VariableArchiveQueryParam.java | 52 + .../param/VariableArchiveSaveParam.java | 38 + .../param/VariableItemQueryParam.java | 31 + .../param/VariableItemSaveParam.java | 41 + .../datacollection/po/AttendQuoteDataPO.java | 64 + .../po/AttendQuoteDataValuePO.java | 68 + .../datacollection/po/AttendQuoteFieldPO.java | 93 + .../po/AttendQuoteFieldSettingPO.java | 56 + .../datacollection/po/AttendQuotePO.java | 112 + .../datacollection/po/OtherDeductionPO.java | 123 + .../po/SpecialAddDeductionPO.java | 121 + .../po/VariableArchiveItemPO.java | 78 + .../datacollection/po/VariableArchivePO.java | 51 + .../datacollection/po/VariableItemPO.java | 58 + .../salary/entity/extemp/dto/ExtEmpDTO.java | 57 + .../extemp/param/ExtEmpImportParam.java | 22 + .../entity/extemp/param/ExtEmpQueryParam.java | 27 + .../entity/extemp/param/ExtEmpSaveParam.java | 101 + .../salary/entity/extemp/po/ExtEmpPO.java | 192 + .../engine/salary/entity/hrm/DeptInfo.java | 35 + .../engine/salary/entity/hrm/HrmStatus.java | 16 + .../engine/salary/entity/hrm/JobCallInfo.java | 32 + .../salary/entity/hrm/PositionInfo.java | 32 + .../salary/entity/hrm/SubCompanyInfo.java | 30 + .../entity/hrm/dto/EmployeeInfoExpandDTO.java | 53 + .../salary/entity/hrm/dto/FieldSetting.java | 35 + .../salary/entity/hrm/dto/HrmInfoDTO.java | 26 + .../entity/hrm/param/HrmQueryParam.java | 30 + .../entity/hrm/po/ExpandFieldSettingsPO.java | 74 + .../salary/entity/hrm/po/HrmSnapshotPO.java | 434 + .../process/dto/SalaryAdjustmentDTO.java | 18 + .../salary/entity/progress/ProgressDTO.java | 66 + .../salary/entity/push/dto/PushRecordDTO.java | 116 + .../entity/push/dto/PushRecordDetailDTO.java | 94 + .../entity/push/dto/PushSettingDTO.java | 61 + .../entity/push/dto/PushSettingItemDTO.java | 65 + .../entity/push/param/CreatePushParam.java | 29 + .../salary/entity/push/param/PushParam.java | 20 + .../push/param/PushSettingItemQueryParam.java | 22 + .../push/param/PushSettingItemSaveParam.java | 71 + .../push/param/PushSettingQueryParam.java | 28 + .../push/param/PushSettingSaveParam.java | 59 + .../param/RecordDetailListQueryParam.java | 22 + .../push/param/RecordListQueryParam.java | 17 + .../entity/push/param/WithdrawParam.java | 20 + .../entity/push/param/WithdrawPushParam.java | 29 + .../entity/push/po/PushRecordDetailPO.java | 96 + .../salary/entity/push/po/PushRecordPO.java | 123 + .../entity/push/po/PushSettingItemPO.java | 103 + .../salary/entity/push/po/PushSettingPO.java | 93 + .../report/bo/SalaryAcctResultReportBO.java | 100 + .../report/po/SalaryAcctResultReportPO.java | 98 + .../entity/salaryBill/bo/SalaryBillBO.java | 964 +++ .../salaryBill/bo/SalaryBillItemNameBO.java | 30 + .../salaryBill/bo/SalarySendRangeBO.java | 186 + .../salaryBill/bo/SalaryTemplateBO.java | 192 + .../salaryBill/dto/MySalaryShowSetDTO.java | 40 + .../salaryBill/dto/SalaryBaseSetFormDTO.java | 38 + .../dto/SalaryBillAckFeedbackDTO.java | 46 + .../salaryBill/dto/SalaryBillItemNameDTO.java | 30 + .../salaryBill/dto/SalaryBillSendDTO.java | 99 + .../dto/SalaryBillWatermarkDTO.java | 37 + .../dto/SalaryMySalaryBillListDTO.java | 40 + .../salaryBill/dto/SalarySendBaseInfoDTO.java | 54 + .../salaryBill/dto/SalarySendCheckDTO.java | 28 + .../dto/SalarySendDetailListDTO.java | 58 + .../salaryBill/dto/SalarySendInfoListDTO.java | 82 + .../salaryBill/dto/SalarySendListDTO.java | 154 + .../dto/SalarySendRangeListDTO.java | 36 + .../salaryBill/dto/SalarySendRangeObjDTO.java | 44 + .../salaryBill/dto/SalarySendUserInfoDTO.java | 38 + .../dto/SalaryTemplateBaseFormDTO.java | 27 + .../dto/SalaryTemplateBaseSetDTO.java | 106 + .../salaryBill/dto/SalaryTemplateListDTO.java | 72 + .../dto/SalaryTemplateReplenishFormDTO.java | 33 + .../salaryBill/dto/SalaryTemplateSMSDTO.java | 23 + .../dto/SalaryTemplateSMSSetDTO.java | 26 + .../dto/SalaryTemplateSalaryItemListDTO.java | 40 + .../SalaryTemplateSalaryItemSetListDTO.java | 31 + .../dto/SalaryTemplateShowFormDTO.java | 38 + .../dto/SalaryTemplateShowSetDTO.java | 58 + .../dto/salaryBillViewingLimitSetting.java | 38 + .../param/ReplenishFormQueryParam.java | 22 + .../salaryBill/param/SMSCodeCheckParam.java | 32 + .../salaryBill/param/SMSCodeSendParam.java | 28 + .../param/SalaryBaseSetSaveParam.java | 62 + .../param/SalaryBillGetTokenParam.java | 26 + .../param/SalaryBillItemDetailQueryParam.java | 36 + .../param/SalaryBillItemNameSaveParam.java | 46 + .../param/SalaryBillQueryParam.java | 38 + .../SalaryBillSalaryGroupQueryParam.java | 31 + .../param/SalaryBillSalaryItemQueryParam.java | 26 + .../param/SalaryExportPdfParam.java | 26 + .../salaryBill/param/SalaryPreviewParam.java | 32 + .../param/SalarySendDetailListQueryParam.java | 79 + .../param/SalarySendDetailQueryParam.java | 81 + .../param/SalarySendGrantParam.java | 45 + .../param/SalarySendInfoQueryParam.java | 94 + .../param/SalarySendQueryParam.java | 39 + .../param/SalarySendRangeQueryParam.java | 30 + .../param/SalarySendRangeSaveParam.java | 122 + .../param/SalarySendWithdrawParam.java | 33 + .../param/SalaryTemplateCopyParam.java | 36 + .../param/SalaryTemplateDefaultUseParam.java | 27 + .../param/SalaryTemplateQueryParam.java | 28 + .../param/SalaryTemplateSaveParam.java | 180 + .../salaryBill/po/SalaryBillItemNamePO.java | 71 + .../salaryBill/po/SalaryBillWatermarkPO.java | 69 + .../salaryBill/po/SalarySendInfoPO.java | 124 + .../entity/salaryBill/po/SalarySendPO.java | 107 + .../salaryBill/po/SalarySendRangeObj.java | 71 + .../salaryBill/po/SalarySendRangePO.java | 57 + .../salaryBill/po/SalaryTemplatePO.java | 244 + .../salaryacct/bo/CalculateFormulaVarBO.java | 648 ++ .../salaryacct/bo/ExpressFormulaBO.java | 116 + .../salaryacct/bo/SalaryAcctCalculateBO.java | 140 + .../bo/SalaryAcctCalculatePriorityBO.java | 248 + .../salaryacct/bo/SalaryAcctCheckBO.java | 81 + .../salaryacct/bo/SalaryAcctConfig.java | 84 + .../bo/SalaryAcctConsolidatedTaxBO.java | 105 + .../salaryacct/bo/SalaryAcctEmployeeBO.java | 171 + .../salaryacct/bo/SalaryAcctFormulaBO.java | 140 + .../salaryacct/bo/SalaryAcctRecordBO.java | 181 + .../salaryacct/bo/SalaryAcctResultBO.java | 904 +++ .../bo/SalaryAcctResultListContext.java | 52 + .../salaryacct/bo/SalaryAcctResultLogBO.java | 40 + .../salaryacct/bo/SalaryCalcContext.java | 46 + .../bo/SalaryCalcEmployeeContext.java | 41 + .../salaryacct/bo/SalaryCalcFormula.java | 53 + .../bo/SalaryCalcFormulaContext.java | 105 + .../salaryacct/bo/SalaryCalcResult.java | 34 + .../entity/salaryacct/bo/SalaryCheckBO.java | 228 + .../salaryacct/bo/SalaryCheckResultBO.java | 93 + .../dto/ConsolidatedTaxDetailDTO.java | 27 + .../dto/SalaryAccEmployeeListDTO.java | 69 + .../dto/SalaryAcctEmpSearchConditionDTO.java | 60 + .../dto/SalaryAcctEmployeeCountDTO.java | 23 + .../dto/SalaryAcctEmployeeInfoDTO.java | 36 + .../dto/SalaryAcctImportFieldDTO.java | 73 + .../salaryacct/dto/SalaryAcctRateDTO.java | 41 + .../dto/SalaryAcctRecordFormDTO.java | 39 + .../dto/SalaryAcctRecordListDTO.java | 74 + .../dto/SalaryAcctResultDetailDTO.java | 97 + .../dto/SalaryAcctResultListColumnDTO.java | 32 + .../SalaryAcctResultSearchConditionDTO.java | 72 + .../dto/SalaryAcctResultTemplateDTO.java | 44 + .../dto/SalaryCheckResultListDTO.java | 66 + .../dto/SalaryCheckResultRecordCountDTO.java | 21 + .../dto/SalaryCheckResultRecordListDTO.java | 62 + .../dto/SalaryComparisonResultListDTO.java | 32 + .../param/SalaryAcctCalculateParam.java | 30 + .../param/SalaryAcctCheckParam.java | 34 + .../SalaryAcctEmpCheckTaxAgentParam.java | 19 + .../SalaryAcctEmpRefreshTaxAgentParam.java | 19 + .../param/SalaryAcctEmployeeAddParam.java | 25 + .../param/SalaryAcctEmployeeDeleteParam.java | 26 + .../SalaryAcctEmployeeListQueryParam.java | 61 + .../param/SalaryAcctEmployeeQueryParam.java | 74 + .../param/SalaryAcctEmployeeSaveParam.java | 30 + .../param/SalaryAcctImportParam.java | 36 + .../param/SalaryAcctImportTemplateParam.java | 31 + .../param/SalaryAcctRecordQueryParam.java | 42 + .../param/SalaryAcctRecordReAccountParam.java | 19 + .../param/SalaryAcctRecordSaveParam.java | 39 + .../SalaryAcctResultBatchUpdateParam.java | 37 + .../param/SalaryAcctResultLockParam.java | 34 + .../param/SalaryAcctResultLogQueryParam.java | 73 + .../param/SalaryAcctResultQueryParam.java | 85 + .../param/SalaryAcctResultSaveParam.java | 49 + .../SalaryAcctResultTemplateSaveParam.java | 48 + ...SalaryAcctResultUpdateLockStatusParam.java | 39 + .../param/SalaryCheckResultExportParam.java | 31 + .../param/SalaryCheckResultQueryParam.java | 27 + .../SalaryCheckResultRecordQueryParam.java | 27 + .../SalaryComparisonResultExportParam.java | 20 + .../SalaryComparisonResultQueryParam.java | 23 + .../salaryacct/po/ExcelAcctResultPO.java | 95 + .../salaryacct/po/SalaryAcctEmployeePO.java | 181 + .../salaryacct/po/SalaryAcctRecordPO.java | 160 + .../salaryacct/po/SalaryAcctResultLogPO.java | 75 + .../salaryacct/po/SalaryAcctResultPO.java | 121 + .../salaryacct/po/SalaryAcctResultTempPO.java | 105 + .../po/SalaryAcctResultTemplatePO.java | 61 + .../salaryacct/po/SalaryAcctSobConfigPO.java | 100 + .../po/SalaryCheckResultDetailTempPO.java | 85 + .../salaryacct/po/SalaryCheckResultPO.java | 73 + .../po/SalaryCheckResultRecordPO.java | 83 + .../salaryarchive/bo/SalaryArchiveBO.java | 329 + .../bo/SalaryArchiveExcelBO.java | 911 +++ .../salaryarchive/bo/SalaryArchiveItemBO.java | 462 ++ .../entity/salaryarchive/bo/TaxAgentBO.java | 70 + .../config/ArchiveFieldConfig.java | 24 + .../dto/DimissionSetFormDTO.java | 36 + .../dto/SalaryArchiveBaseInfoFormDTO.java | 91 + .../dto/SalaryArchiveDataDTO.java | 29 + .../dto/SalaryArchiveFormDTO.java | 43 + .../dto/SalaryArchiveInitImportDTO.java | 37 + .../dto/SalaryArchiveInitImportSameDTO.java | 38 + .../dto/SalaryArchiveItemBaseDTO.java | 56 + .../dto/SalaryArchiveItemDataDTO.java | 32 + .../dto/SalaryArchiveItemDataListDTO.java | 45 + .../dto/SalaryArchiveItemFormDTO.java | 36 + .../dto/SalaryArchiveListDTO.java | 130 + .../dto/SalaryArchiveTaxAgentDataDTO.java | 34 + .../dto/SalaryArchiveTaxAgentFormDTO.java | 27 + .../dto/SalaryItemAdjustRecordListDTO.java | 92 + .../dto/SalaryItemAdjustValidDTO.java | 33 + .../SingleSalaryItemAdjustRecordListDTO.java | 71 + .../SingleTaxAgentAdjustRecordListDTO.java | 76 + .../dto/TaxAgentAdjustRecordListDTO.java | 96 + .../salaryarchive/dto/TaxAgentFormDTO.java | 38 + .../salaryarchive/dto/TaxAgentListDTO.java | 45 + .../SalaryArchiveDimissionSaveParam.java | 25 + .../param/SalaryArchiveImportActionParam.java | 50 + .../param/SalaryArchiveImportHandleParam.java | 180 + .../SalaryArchiveItemDetailSaveParam.java | 28 + .../param/SalaryArchiveItemQueryParam.java | 33 + .../param/SalaryArchiveItemSaveParam.java | 87 + .../param/SalaryArchiveQueryParam.java | 121 + .../param/SalaryArchiveSaveParam.java | 32 + .../param/SalaryArchiveSetPaySaveParam.java | 46 + .../param/SalaryArchiveStopParam.java | 39 + .../SalaryArchiveTaxAgentQueryParam.java | 27 + .../param/SalaryArchiveTaxAgentSaveParam.java | 57 + .../param/SalaryItemAdjustBeforeParam.java | 35 + .../SalaryItemAdjustRecordQueryParam.java | 70 + ...ingleSalaryItemAdjustRecordQueryParam.java | 50 + .../SingleTaxAgentAdjustRecordQueryParam.java | 54 + .../param/TaxAgentAdjustRecordQueryParam.java | 66 + .../param/TaxAgentQueryParam.java | 30 + .../param/TaxAgentSaveParam.java | 38 + .../po/SalaryArchiveDimissionPO.java | 59 + .../po/SalaryArchiveEmployeePO.java | 31 + .../salaryarchive/po/SalaryArchiveItemPO.java | 125 + .../salaryarchive/po/SalaryArchivePO.java | 144 + .../po/SalaryArchiveTaxAgentPO.java | 99 + .../entity/salaryformula/ExpressFormula.java | 97 + .../salaryformula/bo/SalaryFormulaBO.java | 55 + .../salaryformula/config/FormluaConfig.java | 27 + .../salaryformula/dto/ExpressFormulaDTO.java | 69 + .../dto/SalaryFormulaEmployeeDTO.java | 112 + .../dto/SalaryFormulaTaxRateDTO.java | 71 + .../param/SalaryFormulaDetailQueryParam.java | 26 + .../param/SalaryFormulaFieldQueryParam.java | 29 + .../param/SalaryFormulaMockParam.java | 25 + .../param/SalaryFormulaSaveParam.java | 71 + .../entity/salaryformula/po/FormulaPO.java | 120 + .../entity/salaryformula/po/FormulaVar.java | 100 + .../entity/salaryitem/bo/SalaryItemBO.java | 302 + .../entity/salaryitem/bo/SysSalaryItemBO.java | 161 + .../salaryitem/config/FormulaConfig.java | 92 + .../salaryitem/config/FormulaVarConfig.java | 74 + .../config/SalaryItemAllConfig.java | 23 + .../salaryitem/config/SalaryItemConfig.java | 179 + .../config/SalaryItemExcelConfig.java | 114 + .../salaryitem/dto/SalaryFieldListDTO.java | 87 + .../salaryitem/dto/SalaryItemFormDTO.java | 104 + .../salaryitem/dto/SalaryItemListDTO.java | 113 + .../dto/SalaryItemSearchConditionDTO.java | 98 + .../salaryitem/dto/SalaryItemSobListDTO.java | 123 + .../salaryitem/dto/SysSalaryItemListDTO.java | 62 + .../dto/SysSalaryItemSearchConditionDTO.java | 65 + .../SalaryItemDownloadTemplateParam.java | 24 + .../param/SalaryItemExportParam.java | 27 + .../param/SalaryItemImportParam.java | 26 + .../salaryitem/param/SalaryItemSaveParam.java | 115 + .../param/SalaryItemSearchParam.java | 104 + .../salaryitem/param/SyncSalaryItemParam.java | 30 + .../param/SysSalaryItemSearchParam.java | 46 + .../entity/salaryitem/po/SalaryItemPO.java | 259 + .../entity/salaryitem/po/SysSalaryItemPO.java | 135 + .../entity/salarysob/bo/SalaryApprovalBO.java | 91 + .../salarysob/bo/SalarySobAdjustRuleBO.java | 98 + .../entity/salarysob/bo/SalarySobBO.java | 124 + .../salarysob/bo/SalarySobBackItemBO.java | 70 + .../salarysob/bo/SalarySobCheckRuleBO.java | 94 + .../entity/salarysob/bo/SalarySobCycleBO.java | 109 + .../salarysob/bo/SalarySobDuplicateBO.java | 340 + .../bo/SalarySobItemAggregateBO.java | 268 + .../entity/salarysob/bo/SalarySobItemBO.java | 189 + .../salarysob/bo/SalarySobItemSaveBO.java | 133 + .../entity/salarysob/bo/SalarySobRangeBO.java | 172 + .../salarysob/bo/SalarySobRangeSaveBO.java | 141 + .../salarysob/config/SalarySobConfig.java | 38 + .../salarysob/dto/SalaryApprovalDTO.java | 78 + .../salarysob/dto/SalaryItemBaseDTO.java | 26 + .../dto/SalarySobAdjustRuleListDTO.java | 48 + .../dto/SalarySobBackItemAggregateDTO.java | 72 + .../salarysob/dto/SalarySobBackItemDTO.java | 64 + .../dto/SalarySobBackItemFormDTO.java | 52 + .../salarysob/dto/SalarySobBasicFormDTO.java | 124 + .../dto/SalarySobCheckRuleFormDTO.java | 53 + .../dto/SalarySobCheckRuleListDTO.java | 53 + .../salarysob/dto/SalarySobCycleDTO.java | 68 + .../salarysob/dto/SalarySobEmpFieldDTO.java | 44 + .../dto/SalarySobItemAggregateDTO.java | 45 + .../salarysob/dto/SalarySobItemDTO.java | 118 + .../salarysob/dto/SalarySobItemFormDTO.java | 89 + .../salarysob/dto/SalarySobItemGroupDTO.java | 47 + .../dto/SalarySobItemGroupFormDTO.java | 39 + .../dto/SalarySobItemIncomeCategoryDTO.java | 33 + .../salarysob/dto/SalarySobListDTO.java | 73 + .../dto/SalarySobRangeImportListDTO.java | 69 + .../salarysob/dto/SalarySobRangeListDTO.java | 59 + .../param/ApprovalRequestSaveParam.java | 27 + .../param/SalaryApprovalQueryParam.java | 24 + .../SalarySobAdjustRuleItemQueryParam.java | 33 + .../param/SalarySobAdjustRuleQueryParam.java | 25 + .../param/SalarySobAdjustRuleSaveParam.java | 58 + .../param/SalarySobBackItemSaveParam.java | 47 + .../param/SalarySobBasicSaveParam.java | 100 + .../param/SalarySobCheckRuleQueryParam.java | 28 + .../param/SalarySobCheckRuleSaveParam.java | 40 + .../param/SalarySobDisableParam.java | 25 + .../param/SalarySobDuplicateParam.java | 33 + .../param/SalarySobItemSaveParam.java | 123 + .../param/SalarySobListQueryParam.java | 24 + .../salarysob/param/SalarySobQueryParam.java | 31 + .../param/SalarySobRangeEmpQueryParam.java | 32 + .../param/SalarySobRangeExtSaveParam.java | 42 + .../param/SalarySobRangeImportParam.java | 25 + .../param/SalarySobRangeQueryParam.java | 29 + .../param/SalarySobRangeSaveParam.java | 75 + .../param/UpdateCheckRuleFormulaParam.java | 30 + .../salarysob/po/SalaryApprovalRulePO.java | 70 + .../salarysob/po/SalarySobAdjustRulePO.java | 114 + .../salarysob/po/SalarySobBackItemPO.java | 197 + .../salarysob/po/SalarySobCheckRulePO.java | 77 + .../po/SalarySobDefaultBackItemPO.java | 67 + .../po/SalarySobDefaultEmpFieldPO.java | 72 + .../po/SalarySobDefaultItemGroupPO.java | 79 + .../salarysob/po/SalarySobDefaultItemPO.java | 94 + .../salarysob/po/SalarySobEmpFieldPO.java | 125 + .../salarysob/po/SalarySobExtRangePO.java | 65 + .../salarysob/po/SalarySobItemGroupPO.java | 133 + .../salarysob/po/SalarySobItemHidePO.java | 71 + .../entity/salarysob/po/SalarySobItemPO.java | 211 + .../entity/salarysob/po/SalarySobPO.java | 188 + .../entity/salarysob/po/SalarySobRangePO.java | 111 + .../entity/salarysob/po/SobTaxLinkPO.java | 74 + .../salary/entity/salarysql/ExpressSQL.java | 65 + .../salary/entity/salarysql/po/SQLPO.java | 64 + .../salary/entity/salarysql/po/SQLVar.java | 67 + .../setting/dto/PageListSettingDTO.java | 18 + .../setting/dto/PageListTemplateDTO.java | 74 + .../dto/PageListTemplateDetailDTO.java | 19 + .../setting/param/DownloadTemplateParam.java | 24 + .../param/PageListColumnsQueryParam.java | 21 + .../param/PageListSettingQueryParam.java | 23 + .../param/PageListSettingResetParam.java | 22 + .../param/PageListSettingSaveParam.java | 37 + .../param/PageListTemplateChangeParam.java | 31 + .../param/PageListTemplateDeleteParam.java | 18 + .../param/PageListTemplateQueryParam.java | 28 + .../param/PageListTemplateSaveParam.java | 48 + .../salary/entity/setting/po/PageLinkPO.java | 70 + .../entity/setting/po/PageListSettingPO.java | 75 + .../entity/setting/po/PageListTemplatePO.java | 109 + .../siaccount/bo/InsuranceAccountBO.java | 102 + .../bo/InsuranceComparisonResultBO.java | 470 ++ .../dto/InsuranceAccountBatchListDTO.java | 120 + .../siaccount/dto/InsuranceAccountTabDTO.java | 44 + .../dto/InsuranceAccountViewListDTO.java | 52 + .../InsuranceAcctDetailImportFieldDTO.java | 27 + .../dto/InsuranceComparisonResultListDTO.java | 29 + .../dto/InsuranceCompensationDTO.java | 97 + .../siaccount/dto/SIAccountUtilDTO.java | 36 + .../entity/siaccount/param/AccountParam.java | 48 + .../param/BalanceAccountBaseParam.java | 64 + .../siaccount/param/CompensationParam.java | 48 + .../siaccount/param/DSTenantKeyThreadVar.java | 15 + .../param/EditAccountDetailParam.java | 32 + .../param/ExcelInsuranceImportParam.java | 30 + .../siaccount/param/InspectAccountParam.java | 32 + .../param/InsuranceAccountBatchParam.java | 32 + .../param/InsuranceAccountDetailParam.java | 51 + ...nsuranceAcctDetailImportTemplateParam.java | 29 + .../param/InsuranceAcctImportParam.java | 27 + .../InsuranceComparisonResultQueryParam.java | 20 + .../entity/siaccount/param/Permission.java | 39 + .../param/QueryAccountDetailParam.java | 25 + .../siaccount/param/RecessionParam.java | 47 + .../param/SaveCommonAccountParam.java | 40 + .../param/SaveSupplementaryAccountParam.java | 98 + .../param/SupplementAccountBaseParam.java | 101 + .../siaccount/po/ExcelInsuranceDetailPO.java | 277 + .../siaccount/po/InsuranceAccountBatchPO.java | 149 + .../po/InsuranceAccountDetailPO.java | 341 + .../po/InsuranceAccountDetailTempPO.java | 289 + .../po/InsuranceAccountInspectPO.java | 82 + .../po/InsuranceCompensationConfigPO.java | 80 + .../siaccount/po/InsuranceCompensationPO.java | 124 + .../siarchives/bo/InsuranceArchivesBO.java | 85 + .../bo/InsuranceArchivesBaseInfoBO.java | 134 + .../dto/InsuranceArchivesBaseDTO.java | 54 + .../dto/InsuranceArchivesBaseHistoryDTO.java | 104 + .../dto/InsuranceArchivesFundSchemeDTO.java | 70 + .../dto/InsuranceArchivesOtherSchemeDTO.java | 62 + .../dto/InsuranceArchivesSocialSchemeDTO.java | 65 + .../param/InsuranceArchivesFundSaveParam.java | 59 + .../param/InsuranceArchivesListParam.java | 123 + .../InsuranceArchivesOtherSaveParam.java | 53 + .../param/InsuranceArchivesSaveParam.java | 33 + .../InsuranceArchivesSocialSaveParam.java | 56 + .../param/SIArchiveBaseHistoryListParam.java | 28 + .../param/SIArchiveImportActionParam.java | 39 + .../param/SIArchiveImportParam.java | 56 + .../po/InsuranceArchivesAccountPO.java | 27 + .../po/InsuranceArchivesBaseHistoryPO.java | 82 + .../po/InsuranceArchivesBaseInfoPO.java | 117 + .../po/InsuranceArchivesEmployeePO.java | 90 + .../po/InsuranceArchivesFundSchemePO.java | 141 + .../po/InsuranceArchivesOtherSchemePO.java | 128 + .../po/InsuranceArchivesSocialSchemePO.java | 135 + .../entity/sicategory/bo/ICategoryBO.java | 40 + .../sicategory/bo/InsuranceCategoryBO.java | 102 + .../entity/sicategory/dto/ICategoryDTO.java | 53 + .../sicategory/dto/ICategoryFormDTO.java | 48 + .../sicategory/dto/ICategoryListDTO.java | 58 + .../param/ICategoryListQueryParam.java | 8 + .../sicategory/param/UpdateStatusParam.java | 29 + .../entity/sicategory/po/ICategoryPO.java | 76 + .../siexport/param/InsuranceExportParam.java | 48 + .../entity/siexport/po/AccountExportPO.java | 33 + .../siexport/po/ExcelAccountExportPO.java | 61 + .../entity/sischeme/bo/InsuranceSchemeBO.java | 94 + .../sischeme/dto/InsuranceSchemeDTO.java | 67 + .../dto/InsuranceSchemeDetailDTO.java | 111 + .../sischeme/dto/InsuranceSchemeListDTO.java | 63 + .../InsuranceSchemeDetailUpdateParam.java | 61 + .../sischeme/param/InsuranceSchemeParam.java | 46 + .../param/InsuranceSchemeReqParam.java | 54 + .../sischeme/param/SISchemaImportParam.java | 30 + .../sischeme/po/InsuranceSchemeDetailPO.java | 156 + .../entity/sischeme/po/InsuranceSchemePO.java | 113 + .../sischeme/vo/InsuranceSchemeFormVO.java | 29 + .../entity/sischeme/vo/SISchemeTableVO.java | 84 + .../salary/entity/taxagent/bo/TaxAgentBO.java | 437 + .../taxagent/config/TaxAgentConfig.java | 28 + ...AdjustRecordForFormSearchConditionDTO.java | 99 + .../dto/TaxAgentAdjustRecordListDTO.java | 136 + ...axAgentAdjustRecordSearchConditionDTO.java | 139 + .../taxagent/dto/TaxAgentBaseFormDTO.java | 30 + .../taxagent/dto/TaxAgentEmployeeDTO.java | 37 + .../dto/TaxAgentEmployeeOptionDTO.java | 25 + .../dto/TaxAgentEmployeeTaxAgentDTO.java | 29 + .../entity/taxagent/dto/TaxAgentFormDTO.java | 37 + .../entity/taxagent/dto/TaxAgentListDTO.java | 42 + .../dto/TaxAgentManageRangeEmployeeDTO.java | 47 + .../TaxAgentManageRangeEmployeeListDTO.java | 80 + .../dto/TaxAgentManageRangeFormDTO.java | 37 + .../dto/TaxAgentManageRangeListDTO.java | 64 + .../dto/TaxAgentSubAdminBaseFormDTO.java | 33 + .../taxagent/dto/TaxAgentSubAdminListDTO.java | 40 + .../param/TaxAgentAdjustRecordQueryParam.java | 65 + .../param/TaxAgentAdminChangeCheckParam.java | 30 + .../taxagent/param/TaxAgentEmpSaveParam.java | 30 + .../taxagent/param/TaxAgentImportParam.java | 24 + .../TaxAgentManageRangeEmpQueryParam.java | 32 + .../TaxAgentManageRangeExtSaveParam.java | 36 + .../param/TaxAgentManageRangeQueryParam.java | 22 + .../param/TaxAgentManageRangeSaveParam.java | 71 + .../taxagent/param/TaxAgentQueryParam.java | 29 + .../TaxAgentRangeDownloadTemplateParam.java | 22 + .../param/TaxAgentRangeExtQueryParam.java | 29 + .../param/TaxAgentRangeQueryParam.java | 25 + .../param/TaxAgentRangeSaveParam.java | 25 + .../taxagent/param/TaxAgentSaveBaseParam.java | 22 + .../taxagent/param/TaxAgentSaveParam.java | 46 + .../param/TaxAgentSubAdminBaseFormParam.java | 30 + .../param/TaxAgentSubAdminBaseSaveParam.java | 33 + .../param/TaxAgentSubAdminEmpSaveParam.java | 33 + .../param/TaxAgentSubAdminQueryParam.java | 27 + .../TaxAgentSubAdminRangeQueryParam.java | 24 + .../param/TaxAgentSubAdminRangeSaveParam.java | 22 + .../entity/taxagent/po/TaxAgentAdminPO.java | 70 + .../entity/taxagent/po/TaxAgentBasePO.java | 79 + .../taxagent/po/TaxAgentEmpChangePO.java | 96 + .../entity/taxagent/po/TaxAgentEmpPO.java | 81 + .../taxagent/po/TaxAgentEmployeePO.java | 40 + .../taxagent/po/TaxAgentExtRangePO.java | 69 + .../taxagent/po/TaxAgentManageRangePO.java | 115 + .../salary/entity/taxagent/po/TaxAgentPO.java | 116 + .../taxagent/po/TaxAgentSubAdminEmpPO.java | 78 + .../taxagent/po/TaxAgentSubAdminPO.java | 74 + .../taxdeclaration/bo/TaxDeclarationBO.java | 744 ++ .../bo/TaxDeclarationDetailBO.java | 181 + .../bo/TaxDeclarationDetailListColumn.java | 870 ++ .../dto/TaxDeclarationAnnualListDTO.java | 100 + .../dto/TaxDeclarationDetailListDTO.java | 275 + .../dto/TaxDeclarationEmployeeDTO.java | 21 + .../dto/TaxDeclarationFormDTO.java | 33 + .../dto/TaxDeclarationInfoDTO.java | 34 + .../dto/TaxDeclarationLaborListDTO.java | 121 + .../dto/TaxDeclarationListDTO.java | 70 + .../TaxDeclarationDetailListQueryParam.java | 29 + .../param/TaxDeclarationListQueryParam.java | 31 + .../param/TaxDeclarationSaveParam.java | 53 + .../po/TaxDeclarationDetailPO.java | 90 + .../taxdeclaration/po/TaxDeclarationPO.java | 96 + .../salary/entity/taxrate/SysTaxRateBase.java | 58 + .../entity/taxrate/SysTaxRateDetailPO.java | 109 + .../salary/entity/taxrate/TaxAgent.java | 73 + .../salary/entity/taxrate/TaxRateBase.java | 58 + .../salary/entity/taxrate/TaxRateDetail.java | 84 + .../salary/entity/taxrate/bo/TaxRateBO.java | 136 + .../entity/taxrate/bo/TaxRateDetailBO.java | 93 + .../taxrate/param/TaxAgentQueryParam.java | 25 + .../taxrate/param/TaxRateBaseSaveParam.java | 28 + .../taxrate/param/TaxRateDetailSaveParam.java | 49 + .../taxrate/param/TaxRateSaveParam.java | 32 + .../entity/taxrate/vo/TaxAgentTableVO.java | 51 + .../taxrate/vo/TaxDeclarationListVO.java | 78 + .../entity/taxrate/vo/TaxRateFormVo.java | 31 + .../entity/taxrate/vo/TaxRateTableVO.java | 60 + .../engine/salary/enums/AccountTypeEnum.java | 68 + src/com/engine/salary/enums/BaseEnum.java | 20 + .../engine/salary/enums/OperateTypeEnum.java | 50 + .../salary/enums/SalaryCycleTypeEnum.java | 56 + .../salary/enums/SalaryDataSourceEnum.java | 75 + .../salary/enums/SalaryItemCategoryEnum.java | 58 + .../salary/enums/SalaryItemTypeEnum.java | 81 + .../salary/enums/SalaryJobFlagEnum.java | 31 + .../engine/salary/enums/SalaryOnOffEnum.java | 62 + .../salary/enums/SalaryRoundingModeEnum.java | 81 + .../salary/enums/SalarySobStatusEnum.java | 47 + .../salary/enums/SalarySystemTypeEnum.java | 54 + .../salary/enums/SalaryValueTypeEnum.java | 79 + .../engine/salary/enums/UserStatusEnum.java | 115 + .../salary/enums/auth/AuthCheckTypeEnum.java | 59 + .../salary/enums/auth/AuthFilterTypeEnum.java | 59 + .../salary/enums/auth/DataLinkEnum.java | 79 + .../salary/enums/auth/DataTargetTypeEnum.java | 176 + .../enums/auth/LoginPersonTargetTypeEnum.java | 123 + .../enums/auth/MemberTargetTypeEnum.java | 121 + .../enums/auth/ResourceTargetTypeEnum.java | 75 + .../salary/enums/common/FilterEnum.java | 132 + .../salary/enums/common/SharedTypeEnum.java | 48 + .../AttendQuoteFieldSourceTypeEnum.java | 63 + .../AttendQuoteFieldTypeEnum.java | 50 + .../AttendQuoteSourceTypeEnum.java | 50 + .../DataCollectionEmployeeTypeEnum.java | 53 + .../datacollection/UseEmployeeTypeEnum.java | 54 + .../salary/enums/push/PushItemFieldEnum.java | 125 + .../push/PushRecordDetailStatusEnum.java | 71 + .../enums/push/PushRecordStatusEnum.java | 74 + .../salary/enums/push/PushRecordTypeEnum.java | 68 + .../salaryaccounting/EmployeeTypeEnum.java | 40 + .../salaryaccounting/LockStatusEnum.java | 46 + .../SalaryAcctRecordStatusEnum.java | 57 + .../SalaryAcctResultDataSourceEnum.java | 56 + .../salaryarchive/ArchiveStatusEnum.java | 42 + ...dividualTaxWithholdingAgentStatusEnum.java | 48 + .../SalaryArchiveAddTypeEnum.java | 43 + .../SalaryArchiveAdjustRecordTypeEnum.java | 26 + .../SalaryArchiveAdjustWayEnum.java | 25 + ...alaryArchiveDimissionTimeIntervalEnum.java | 41 + .../SalaryArchiveFieldTypeEnum.java | 58 + .../SalaryArchiveImportTypeEnum.java | 51 + .../SalaryArchiveItemAdjustReasonEnum.java | 88 + .../SalaryArchiveListTypeEnum.java | 53 + .../SalaryArchiveStatusEnum.java | 46 + ...SalaryArchiveTaxAgentAdjustReasonEnum.java | 68 + .../salarybill/BillConfimStatusEnum.java | 71 + .../enums/salarybill/BillReadStatusEnum.java | 70 + .../enums/salarybill/MessageChannelEnum.java | 73 + .../enums/salarybill/MonthTypeEnum.java | 82 + .../salarybill/SalarySendStatusEnum.java | 65 + .../SalaryTemplateReplenishRuleEnum.java | 38 + ...SalaryTemplateTextContentPositionEnum.java | 30 + .../salarybill/SalaryTemplateVarEnum.java | 32 + .../SalaryTemplateWatermarkTypeEnum.java | 33 + .../salarybill/SalaryTemplateWhetherEnum.java | 45 + .../FormulaVarFieldTypeEnum.java | 31 + .../salaryformula/ReferenceTypeEnum.java | 32 + .../enums/salaryformula/ReturnTypeEnum.java | 31 + .../SalaryFormulaReferenceEnum.java | 68 + .../salaryformula/SalarySQLReferenceEnum.java | 57 + .../enums/salaryformula/ValidateTypeEnum.java | 31 + .../enums/salaryitem/SalaryDataTypeEnum.java | 79 + .../SalaryAutoSendCycleTypeEnum.java | 54 + .../salarysend/SalarySendGrantTypeEnum.java | 50 + .../SalarySendRangeTargetTypeEnum.java | 48 + .../salarysend/SalarySendRangeTypeEnum.java | 53 + .../enums/salarysob/IncomeCategoryEnum.java | 62 + .../salarysob/SalaryEmployeeStatusEnum.java | 160 + .../SalarySobAdjustRuleTypeEnum.java | 58 + .../enums/salarysob/TargetTypeEnum.java | 76 + .../setting/PageListSettingPageEnum.java | 39 + .../enums/siaccount/BillStatusEnum.java | 39 + .../enums/siaccount/EmployeeStatusEnum.java | 59 + .../enums/siaccount/InspectStatusEnum.java | 39 + .../enums/siaccount/PaymentStatusEnum.java | 43 + .../enums/siaccount/ProjectTypeEnum.java | 41 + .../enums/siaccount/ResourceFromEnum.java | 42 + .../salary/enums/sicategory/DataTypeEnum.java | 31 + .../enums/sicategory/DeleteTypeEnum.java | 31 + .../enums/sicategory/IncludeTypeEnum.java | 28 + .../enums/sicategory/IsPaymentEnum.java | 29 + .../salary/enums/sicategory/IsUseEnum.java | 30 + .../enums/sicategory/NonPaymentEnum.java | 31 + .../enums/sicategory/PaymentScopeEnum.java | 46 + .../enums/sicategory/PaymentTypeEnum.java | 38 + .../enums/sicategory/RententionRuleEnum.java | 56 + .../enums/sicategory/SharedTypeEnum.java | 37 + .../enums/sicategory/UndertakerEnum.java | 39 + .../enums/sicategory/WelfareTypeEnum.java | 53 + .../taxagent/TaxAgentEmpChangeModuleEnum.java | 32 + .../taxagent/TaxAgentEmpChangeTypeEnum.java | 32 + .../enums/taxagent/TaxAgentRangeTypeEnum.java | 49 + .../enums/taxagent/TaxAgentRoleTypeEnum.java | 31 + .../salary/exception/ExceptionUtil.java | 17 + .../exception/SalaryRunTimeException.java | 15 + .../formlua/constant/FormluaConstant.java | 1558 ++++ .../salary/formlua/core/QLExpressContext.java | 18 + .../engine/salary/formlua/core/QlExpress.java | 279 + .../salary/formlua/core/QlExpressTest.java | 33 + .../formlua/core/exception/ErrorType.java | 70 + .../core/exception/ExcelRunTimeException.java | 24 + .../formlua/entity/parameter/DataType.java | 279 + .../entity/parameter/DateAndString.java | 5 + .../formlua/entity/parameter/ExcelFunc.java | 138 + .../formlua/entity/parameter/ExcelFuncs.java | 467 ++ .../entity/parameter/FormulaContext.java | 35 + .../entity/parameter/FuncDescUtil.java | 133 + .../formlua/entity/parameter/FuncNames.java | 20 + .../formlua/entity/parameter/IllegalList.java | 19 + .../entity/parameter/ParamContext.java | 30 + .../entity/parameter/ParamFactory.java | 127 + .../formlua/entity/parameter/ParamType.java | 15 + .../formlua/entity/parameter/ReturnType.java | 13 + .../entity/parameter/ThreadLocalData.java | 59 + .../formlua/entity/standard/AggFunc.java | 8 + .../entity/standard/ExcelModuleFixField.java | 34 + .../formlua/entity/standard/ExcelPage.java | 56 + .../formlua/entity/standard/ExcelResult.java | 175 + .../entity/standard/FormulaCategory.java | 58 + .../entity/standard/FormulaDataSource.java | 37 + .../entity/standard/FormulaFilterData.java | 299 + .../standard/FormulaModuleCategory.java | 34 + .../entity/standard/execute/ExclDataType.java | 8 + .../entity/standard/execute/ExclFixField.java | 67 + .../entity/standard/execute/FixFieldType.java | 11 + .../formlua/func/compare/CommonOper.java | 71 + .../formlua/func/compare/Compareutils.java | 310 + .../formlua/func/compare/EqOperator.java | 239 + .../func/compare/GreaterEqOperator.java | 104 + .../formlua/func/compare/GreaterOperator.java | 101 + .../formlua/func/compare/InOperator.java | 97 + .../formlua/func/compare/LessEqOperator.java | 103 + .../formlua/func/compare/LessOperator.java | 104 + .../formlua/func/compare/NotEqueOperator.java | 102 + .../formlua/func/compare/OperatorInTest.java | 38 + .../formlua/func/compare/WOperatorAdd.java | 60 + .../formlua/func/compare/WOperatorDiv.java | 66 + .../formlua/func/compare/WOperatorMulti.java | 55 + .../formlua/func/compare/WOperatorReduce.java | 59 + .../formlua/func/date/DateTimeService.java | 99 + .../func/date/DateTimeServiceImpl.java | 1364 ++++ .../formlua/func/finance/FinanceService.java | 15 + .../func/finance/FinanceServiceImpl.java | 118 + .../formlua/func/find/FindFuncsService.java | 31 + .../func/find/FindFuncsServiceImpl.java | 188 + .../salary/formlua/func/logic/IfOperator.java | 96 + .../formlua/func/logic/LogicService.java | 26 + .../formlua/func/logic/LogicServiceImpl.java | 496 ++ .../salary/formlua/func/logic/LogicUtils.java | 109 + .../formlua/func/math/MathFuncsService.java | 79 + .../func/math/MathFuncsServiceImpl.java | 465 ++ .../formlua/func/string/ExtractType.java | 7 + .../func/string/StringFormulaService.java | 186 + .../func/string/StringFormulaServiceImpl.java | 811 ++ .../salary/formlua/util/CompareUtil.java | 24 + .../engine/salary/formlua/util/DateUtil.java | 211 + .../engine/salary/formlua/util/ErrorUtil.java | 33 + .../salary/formlua/util/ExcelParamUtil.java | 1125 +++ .../salary/formlua/util/ExcelResult.java | 36 + .../formlua/util/ExcelStandardUtil.java | 492 ++ .../formlua/util/ExpressRegularUtil.java | 234 + .../salary/formlua/util/IgnoreFilter.java | 21 + .../formlua/util/IgnoreParamFilter.java | 766 ++ .../salary/formlua/util/NativePlace.java | 7162 +++++++++++++++++ .../salary/formlua/util/RegularUtil.java | 241 + .../engine/salary/formlua/util/SortUtil.java | 49 + .../formlua/util/standard/ExcelDataType.java | 8 + .../salary/handle/LongListTypeHandler.java | 49 + .../salary/handle/SalaryListTypeHandler.java | 49 + .../maintainer/MaintainerController.java | 111 + .../datacollection/AddUpSituationManager.java | 68 + .../salaryacct/SalaryAcctManager.java | 387 + .../salaryacct/SalaryAcctSupplementParam.java | 54 + .../maintainer/salaryacct/SupAcctThread.java | 42 + .../salaryarchive/SalaryArchiveManager.java | 64 + .../salary/mapper/InsuranceExportMapper.java | 22 + .../salary/mapper/InsuranceExportMapper.xml | 321 + src/com/engine/salary/mapper/SQLMapper.java | 20 + src/com/engine/salary/mapper/SQLMapper.xml | 12 + .../salary/mapper/SysTaxRateBaseMapper.java | 75 + .../salary/mapper/SysTaxRateBaseMapper.xml | 333 + .../salary/mapper/SysTaxRateDetailMapper.java | 19 + .../salary/mapper/SysTaxRateDetailMapper.xml | 55 + .../salary/mapper/TaxRateBaseMapper.java | 80 + .../salary/mapper/TaxRateBaseMapper.xml | 277 + .../salary/mapper/TaxRateDetailMapper.java | 75 + .../salary/mapper/TaxRateDetailMapper.xml | 471 ++ .../archive/SalaryArchiveDimissionMapper.java | 64 + .../archive/SalaryArchiveDimissionMapper.xml | 241 + .../archive/SalaryArchiveItemMapper.java | 102 + .../archive/SalaryArchiveItemMapper.xml | 1219 +++ .../mapper/archive/SalaryArchiveMapper.java | 146 + .../mapper/archive/SalaryArchiveMapper.xml | 883 ++ .../archive/SalaryArchiveTaxAgentMapper.java | 98 + .../archive/SalaryArchiveTaxAgentMapper.xml | 844 ++ .../salary/mapper/auth/AuthDataMapper.java | 79 + .../salary/mapper/auth/AuthDataMapper.xml | 276 + .../engine/salary/mapper/auth/AuthMapper.java | 27 + .../engine/salary/mapper/auth/AuthMapper.xml | 168 + .../salary/mapper/auth/AuthMemberMapper.java | 78 + .../salary/mapper/auth/AuthMemberMapper.xml | 241 + .../salary/mapper/auth/AuthOptMapper.java | 79 + .../salary/mapper/auth/AuthOptMapper.xml | 230 + .../mapper/auth/AuthResourceMapper.java | 78 + .../salary/mapper/auth/AuthResourceMapper.xml | 243 + .../mapper/auth/AuthRoleDataMapper.java | 87 + .../salary/mapper/auth/AuthRoleDataMapper.xml | 311 + .../salary/mapper/auth/AuthRoleEmpMapper.java | 87 + .../salary/mapper/auth/AuthRoleEmpMapper.xml | 318 + .../salary/mapper/auth/AuthRoleMapper.java | 76 + .../salary/mapper/auth/AuthRoleMapper.xml | 296 + .../datacollection/AddUpDeductionMapper.java | 81 + .../datacollection/AddUpDeductionMapper.xml | 676 ++ .../datacollection/AddUpSituationMapper.java | 68 + .../datacollection/AddUpSituationMapper.xml | 788 ++ .../datacollection/AttendQuoteDataMapper.java | 85 + .../datacollection/AttendQuoteDataMapper.xml | 399 + .../AttendQuoteDataValueMapper.java | 76 + .../AttendQuoteDataValueMapper.xml | 403 + .../AttendQuoteFieldMapper.java | 113 + .../datacollection/AttendQuoteFieldMapper.xml | 493 ++ .../datacollection/AttendQuoteMapper.java | 83 + .../datacollection/AttendQuoteMapper.xml | 319 + .../AttendQuoteSyncSetMapper.java | 67 + .../AttendQuoteSyncSetMapper.xml | 249 + .../mapper/datacollection/EmployMapper.java | 184 + .../mapper/datacollection/EmployMapper.xml | 665 ++ .../datacollection/OtherDeductionMapper.java | 52 + .../datacollection/OtherDeductionMapper.xml | 483 ++ .../SpecialAddDeductionMapper.java | 37 + .../SpecialAddDeductionMapper.xml | 755 ++ .../VariableArchiveItemMapper.java | 89 + .../VariableArchiveItemMapper.xml | 365 + .../datacollection/VariableArchiveMapper.java | 81 + .../datacollection/VariableArchiveMapper.xml | 412 + .../datacollection/VariableItemMapper.java | 68 + .../datacollection/VariableItemMapper.xml | 210 + .../mapper/extemp/ExternalEmployeeMapper.java | 92 + .../mapper/extemp/ExternalEmployeeMapper.xml | 720 ++ .../salary/mapper/formula/FormulaMapper.java | 65 + .../salary/mapper/formula/FormulaMapper.xml | 309 + .../mapper/formula/FormulaVarMapper.java | 53 + .../mapper/formula/FormulaVarMapper.xml | 245 + .../mapper/hrm/ExpandFieldSettingsMapper.java | 73 + .../mapper/hrm/ExpandFieldSettingsMapper.xml | 259 + .../salary/mapper/hrm/HrmSnapshotMapper.java | 87 + .../salary/mapper/hrm/HrmSnapshotMapper.xml | 1201 +++ .../mapper/push/PushRecordDetailMapper.java | 76 + .../mapper/push/PushRecordDetailMapper.xml | 316 + .../salary/mapper/push/PushRecordMapper.java | 75 + .../salary/mapper/push/PushRecordMapper.xml | 335 + .../mapper/push/PushSettingItemMapper.java | 72 + .../mapper/push/PushSettingItemMapper.xml | 284 + .../salary/mapper/push/PushSettingMapper.java | 73 + .../salary/mapper/push/PushSettingMapper.xml | 268 + .../report/SalaryAcctResultReportMapper.java | 55 + .../report/SalaryAcctResultReportMapper.xml | 425 + .../SalaryStatisticsDimensionMapper.java | 66 + .../SalaryStatisticsDimensionMapper.xml | 303 + .../SalaryStatisticsEChartsSettingMapper.java | 72 + .../SalaryStatisticsEChartsSettingMapper.xml | 321 + .../report/SalaryStatisticsItemMapper.java | 73 + .../report/SalaryStatisticsItemMapper.xml | 401 + .../report/SalaryStatisticsPushMapper.java | 83 + .../report/SalaryStatisticsPushMapper.xml | 358 + .../report/SalaryStatisticsReportMapper.java | 71 + .../report/SalaryStatisticsReportMapper.xml | 476 ++ .../salaryStatisticsPushDetailMapper.java | 81 + .../salaryStatisticsPushDetailMapper.xml | 319 + .../salaryacct/ExcelAcctResultMapper.java | 56 + .../salaryacct/ExcelAcctResultMapper.xml | 222 + .../salaryacct/SalaryAcctEmployeeMapper.java | 129 + .../salaryacct/SalaryAcctEmployeeMapper.xml | 1250 +++ .../salaryacct/SalaryAcctRecordMapper.java | 84 + .../salaryacct/SalaryAcctRecordMapper.xml | 463 ++ .../salaryacct/SalaryAcctResultLogMapper.java | 81 + .../salaryacct/SalaryAcctResultLogMapper.xml | 306 + .../salaryacct/SalaryAcctResultMapper.java | 137 + .../salaryacct/SalaryAcctResultMapper.xml | 621 ++ .../SalaryAcctResultTempMapper.java | 54 + .../salaryacct/SalaryAcctResultTempMapper.xml | 198 + .../SalaryAcctResultTemplateMapper.java | 66 + .../SalaryAcctResultTemplateMapper.xml | 242 + .../salaryacct/SalaryAcctSobConfigMapper.java | 80 + .../salaryacct/SalaryAcctSobConfigMapper.xml | 316 + .../salarybill/SalaryBillItemNameMapper.java | 102 + .../salarybill/SalaryBillItemNameMapper.xml | 344 + .../salarybill/SalaryBillWatermarkMapper.java | 73 + .../salarybill/SalaryBillWatermarkMapper.xml | 215 + .../salarybill/SalarySendInfoMapper.java | 117 + .../salarybill/SalarySendInfoMapper.xml | 843 ++ .../mapper/salarybill/SalarySendMapper.java | 70 + .../mapper/salarybill/SalarySendMapper.xml | 371 + .../salarybill/SalarySendRangeMapper.java | 34 + .../salarybill/SalarySendRangeMapper.xml | 358 + .../salarybill/SalarySendRangeObjMapper.java | 35 + .../salarybill/SalarySendRangeObjMapper.xml | 363 + .../salarybill/SalaryTemplateMapper.java | 76 + .../salarybill/SalaryTemplateMapper.xml | 1017 +++ .../mapper/salaryitem/SalaryItemMapper.java | 78 + .../mapper/salaryitem/SalaryItemMapper.xml | 655 ++ .../salaryitem/SysSalaryItemMapper.java | 73 + .../mapper/salaryitem/SysSalaryItemMapper.xml | 828 ++ .../salarysob/SalaryApprovalRuleMapper.java | 72 + .../salarysob/SalaryApprovalRuleMapper.xml | 222 + .../salarysob/SalarySobAdjustRuleMapper.java | 82 + .../salarysob/SalarySobAdjustRuleMapper.xml | 400 + .../salarysob/SalarySobBackItemMapper.java | 88 + .../salarysob/SalarySobBackItemMapper.xml | 393 + .../salarysob/SalarySobCheckRuleMapper.java | 91 + .../salarysob/SalarySobCheckRuleMapper.xml | 420 + .../SalarySobDefaultEmpFieldMapper.java | 67 + .../SalarySobDefaultEmpFieldMapper.xml | 294 + .../SalarySobDefaultItemGroupMapper.java | 64 + .../SalarySobDefaultItemGroupMapper.xml | 304 + .../salarysob/SalarySobDefaultItemMapper.java | 66 + .../salarysob/SalarySobDefaultItemMapper.xml | 340 + .../salarysob/SalarySobEmpFieldMapper.java | 95 + .../salarysob/SalarySobEmpFieldMapper.xml | 406 + .../salarysob/SalarySobExtRangeMapper.java | 69 + .../salarysob/SalarySobExtRangeMapper.xml | 250 + .../salarysob/SalarySobItemGroupMapper.java | 89 + .../salarysob/SalarySobItemGroupMapper.xml | 322 + .../salarysob/SalarySobItemHideMapper.java | 32 + .../salarysob/SalarySobItemHideMapper.xml | 75 + .../mapper/salarysob/SalarySobItemMapper.java | 100 + .../mapper/salarysob/SalarySobItemMapper.xml | 372 + .../mapper/salarysob/SalarySobMapper.java | 61 + .../mapper/salarysob/SalarySobMapper.xml | 541 ++ .../salarysob/SalarySobRangeMapper.java | 93 + .../mapper/salarysob/SalarySobRangeMapper.xml | 480 ++ .../mapper/salarysob/SobTaxLinkMapper.java | 76 + .../mapper/salarysob/SobTaxLinkMapper.xml | 226 + .../salary/mapper/setting/PageLinkMapper.java | 73 + .../salary/mapper/setting/PageLinkMapper.xml | 224 + .../mapper/setting/PageListSettingMapper.java | 78 + .../mapper/setting/PageListSettingMapper.xml | 242 + .../setting/PageListTemplateMapper.java | 73 + .../mapper/setting/PageListTemplateMapper.xml | 279 + .../siaccount/ExcelInsuranceDetailMapper.java | 43 + .../siaccount/ExcelInsuranceDetailMapper.xml | 593 ++ .../InsuranceAccountBatchMapper.java | 70 + .../siaccount/InsuranceAccountBatchMapper.xml | 301 + .../InsuranceAccountDetailMapper.java | 203 + .../InsuranceAccountDetailMapper.xml | 1624 ++++ .../InsuranceAccountInspectMapper.java | 44 + .../InsuranceAccountInspectMapper.xml | 163 + .../InsuranceCompensationConfigMapper.java | 19 + .../InsuranceCompensationConfigMapper.xml | 170 + .../InsuranceCompensationMapper.java | 29 + .../siaccount/InsuranceCompensationMapper.xml | 281 + .../siaccount/SIAccountDetailMapper.java | 17 + .../siaccount/SIAccountDetailMapper.xml | 116 + .../siaccount/SIAccountDetailTempMapper.java | 47 + .../siaccount/SIAccountDetailTempMapper.xml | 376 + .../mapper/siaccount/SIAccountUtilMapper.java | 37 + .../mapper/siaccount/SIAccountUtilMapper.xml | 90 + .../mapper/siarchives/FundSchemeMapper.java | 111 + .../mapper/siarchives/FundSchemeMapper.xml | 423 + .../InsuranceBaseAdjustHistoryMapper.java | 30 + .../InsuranceBaseAdjustHistoryMapper.xml | 243 + .../siarchives/InsuranceBaseInfoMapper.java | 139 + .../siarchives/InsuranceBaseInfoMapper.xml | 417 + .../mapper/siarchives/OtherSchemeMapper.java | 110 + .../mapper/siarchives/OtherSchemeMapper.xml | 406 + .../mapper/siarchives/SocialSchemeMapper.java | 141 + .../mapper/siarchives/SocialSchemeMapper.xml | 1063 +++ .../mapper/sicategory/ICategoryMapper.java | 106 + .../mapper/sicategory/ICategoryMapper.xml | 223 + .../sischeme/InsuranceSchemeDetailMapper.java | 82 + .../sischeme/InsuranceSchemeDetailMapper.xml | 360 + .../sischeme/InsuranceSchemeMapper.java | 71 + .../mapper/sischeme/InsuranceSchemeMapper.xml | 231 + .../mapper/sys/SalarySysConfMapper.java | 79 + .../salary/mapper/sys/SalarySysConfMapper.xml | 253 + .../mapper/taxagent/TaxAgentAdminMapper.java | 67 + .../mapper/taxagent/TaxAgentAdminMapper.xml | 209 + .../mapper/taxagent/TaxAgentBaseMapper.java | 68 + .../mapper/taxagent/TaxAgentBaseMapper.xml | 180 + .../taxagent/TaxAgentEmpChangeMapper.java | 76 + .../taxagent/TaxAgentEmpChangeMapper.xml | 374 + .../mapper/taxagent/TaxAgentEmpMapper.java | 78 + .../mapper/taxagent/TaxAgentEmpMapper.xml | 331 + .../taxagent/TaxAgentExtRangeMapper.java | 69 + .../taxagent/TaxAgentExtRangeMapper.xml | 253 + .../taxagent/TaxAgentManageRangeMapper.java | 74 + .../taxagent/TaxAgentManageRangeMapper.xml | 344 + .../mapper/taxagent/TaxAgentMapper.java | 75 + .../salary/mapper/taxagent/TaxAgentMapper.xml | 281 + .../TaxDeclarationDetailMapper.java | 73 + .../TaxDeclarationDetailMapper.xml | 198 + .../taxdeclaration/TaxDeclarationMapper.java | 44 + .../taxdeclaration/TaxDeclarationMapper.xml | 150 + .../salaryArchive/SalaryArchiveActionAPI.java | 127 + .../salaryArchive/SalaryArchiveInfo.java | 44 + .../SalaryArchiveProcessQueryParam.java | 44 + .../siArchives/SIArchiveActionAPI.java | 64 + .../remote/attend/cmd/GetKQReportCmd.java | 603 ++ .../remote/attend/cmd/GetSearchListCmd.java | 371 + .../remote/attend/entity/Attend4Salary.java | 34 + .../service/RemoteAttend4SalaryService.java | 35 + .../impl/RemoteAttend4SalaryServiceImpl.java | 252 + .../salary/remote/mode/cmd/GetModeList.java | 139 + .../common/constant/DbCrudConstant.java | 10 + .../common/constant/SalaryConstant.java | 12 + .../common/constant/SalaryReportModule.java | 6 + .../SalaryStatisticsDimensionConstant.java | 139 + .../entity/bo/SalaryStatisticsEmployeeBO.java | 62 + .../entity/bo/SalaryStatisticsReportBO.java | 1294 +++ .../entity/dto/SalaryReportCacheInfo.java | 34 + .../dto/SalaryStatisticsDimensionFormDTO.java | 29 + .../dto/SalaryStatisticsDimensionListDTO.java | 48 + .../dto/SalaryStatisticsEchartsDTO.java | 52 + ...laryStatisticsEmployeeDetailResultDTO.java | 38 + .../dto/SalaryStatisticsEmployeeListDTO.java | 54 + .../dto/SalaryStatisticsItemFormDTO.java | 30 + .../dto/SalaryStatisticsItemRuleDTO.java | 42 + .../SalaryStatisticsItemStringRuleDTO.java | 23 + .../dto/SalaryStatisticsPushDetail.java | 25 + .../SalaryStatisticsPushDetailFormDTO.java | 36 + .../SalaryStatisticsPushDetailTableDTO.java | 48 + .../dto/SalaryStatisticsPushTableDTO.java | 42 + .../dto/SalaryStatisticsReportDataDTO.java | 54 + .../dto/SalaryStatisticsReportFormDTO.java | 32 + .../entity/dto/SubEmployeeTableDTO.java | 36 + .../report/entity/dto/SubTableChartsDTO.java | 47 + .../report/entity/dto/TaxAgentViewDTO.java | 24 + .../report/entity/param/ExportColumn.java | 20 + .../entity/param/ExportCommonParam.java | 33 + .../param/SalaryAcctEmployeeQueryParam.java | 34 + .../param/SalaryEmployeeQueryParam.java | 39 + ...ryStatisticsDataPerspectiveQueryParam.java | 87 + .../SalaryStatisticsDimensionQueryParam.java | 26 + .../SalaryStatisticsDimensionSaveParam.java | 132 + ...aryStatisticsEmployeeDetailQueryParam.java | 44 + .../SalaryStatisticsEmployeeQueryParam.java | 38 + ...aryStatisticsEmployeeSalaryQueryParam.java | 56 + .../SalaryStatisticsItemGetFormParam.java | 26 + .../param/SalaryStatisticsItemSaveParam.java | 69 + .../SalaryStatisticsPushDetailParam.java | 26 + .../param/SalaryStatisticsPushParam.java | 64 + .../SalaryStatisticsReportDataQueryParam.java | 115 + .../SalaryStatisticsReportQueryParam.java | 26 + .../SalaryStatisticsReportSaveParam.java | 48 + ...aryStatisticsSearchConditionSaveParam.java | 87 + .../entity/param/SubTableDataQueryParam.java | 66 + .../entity/param/SubTableItemParam.java | 33 + .../report/entity/param/SubTableParam.java | 25 + .../param/SubTableSearchConditionParam.java | 59 + .../entity/param/TaxAgentQueryParam.java | 30 + .../po/SalaryStatisticsDimensionPO.java | 95 + .../po/SalaryStatisticsEChartsSettingPO.java | 83 + .../entity/po/SalaryStatisticsItemPO.java | 209 + .../po/SalaryStatisticsPushDetailPO.java | 68 + .../entity/po/SalaryStatisticsPushPO.java | 71 + .../entity/po/SalaryStatisticsReportPO.java | 132 + .../report/entity/po/SubTableItemPO.java | 74 + .../salary/report/enums/DataTypeEnum.java | 25 + .../salary/report/enums/DimensionEnum.java | 44 + .../salary/report/enums/EmployeeTypeEnum.java | 52 + .../report/enums/ExtEmployeeTypeEnum.java | 18 + .../report/enums/IncomeCategoryEnum.java | 88 + .../salary/report/enums/OperateTypeEnum.java | 28 + .../salary/report/enums/PaymentScopeEnum.java | 28 + .../report/enums/PaymentStatusEnum.java | 35 + .../report/enums/SalaryDataTypeEnum.java | 55 + .../SalaryStatisticsDimensionTypeEnum.java | 50 + .../SalaryStatisticsItemStringRuleEnum.java | 52 + .../report/enums/SalarySystemTypeEnum.java | 57 + .../salary/report/enums/TableTypeEnum.java | 18 + .../enums/TaxAgentPermissionConstant.java | 22 + .../report/enums/TaxAgentRoleTypeEnum.java | 34 + .../salary/report/enums/UnitTypeEnum.java | 45 + .../report/enums/WeaBrowserTypeEnum.java | 37 + .../SalaryStatisticsDimensionService.java | 91 + .../SalaryStatisticsEchartsService.java | 37 + .../SalaryStatisticsEmployeeService.java | 60 + .../service/SalaryStatisticsItemService.java | 62 + .../SalaryStatisticsPushDetailService.java | 85 + .../service/SalaryStatisticsPushService.java | 86 + .../SalaryStatisticsReportService.java | 116 + .../report/service/SubTableExportService.java | 7 + .../SalaryStatisticsDimensionServiceImpl.java | 268 + .../SalaryStatisticsEchartsServiceImpl.java | 104 + .../SalaryStatisticsEmployeeServiceImpl.java | 385 + .../impl/SalaryStatisticsItemServiceImpl.java | 207 + ...SalaryStatisticsPushDetailServiceImpl.java | 107 + .../impl/SalaryStatisticsPushServiceImpl.java | 771 ++ .../SalaryStatisticsReportServiceImpl.java | 2220 +++++ .../impl/SubTableExportServiceImpl.java | 182 + .../salary/report/util/ReportDataUtil.java | 33 + .../salary/report/util/ReportEnumUtil.java | 31 + .../salary/report/util/ReportTimeUtil.java | 169 + .../SalaryStatisticsDimensionController.java | 136 + .../SalaryStatisticsEchartsController.java | 78 + .../SalaryStatisticsEmployeeController.java | 137 + .../web/SalaryStatisticsItemController.java | 107 + .../web/SalaryStatisticsPushController.java | 143 + .../web/SalaryStatisticsReportController.java | 226 + .../SalaryStatisticsDimensionWrapper.java | 240 + .../SalaryStatisticsEchartsWrapper.java | 51 + .../SalaryStatisticsEmployeeWrapper.java | 364 + .../wrapper/SalaryStatisticsItemWrapper.java | 300 + .../SalaryStatisticsReportWrapper.java | 675 ++ .../salary/service/AddUpDeductionService.java | 151 + .../salary/service/AddUpSituationService.java | 115 + .../service/AttendQuoteDataService.java | 95 + .../service/AttendQuoteFieldService.java | 111 + .../AttendQuoteFieldSettingService.java | 60 + .../salary/service/AttendQuoteService.java | 42 + .../engine/salary/service/AttendService.java | 12 + .../salary/service/ColumnBuildService.java | 36 + .../engine/salary/service/ExtEmpService.java | 60 + .../salary/service/FormulaRunService.java | 14 + .../service/MySalaryShowSetService.java | 19 + .../salary/service/OtherDeductionService.java | 117 + .../salary/service/ProgressService.java | 86 + .../engine/salary/service/PushService.java | 75 + .../salary/service/RecordsBuildService.java | 22 + .../salary/service/RemoteExcelService.java | 31 + .../service/SIAComparisonResultService.java | 30 + .../salary/service/SIAccountService.java | 328 + .../salary/service/SIArchivesService.java | 165 + .../salary/service/SIBalanceService.java | 20 + .../salary/service/SICategoryService.java | 74 + .../salary/service/SICompensationService.java | 36 + .../salary/service/SIExportService.java | 34 + .../salary/service/SIImportService.java | 20 + .../salary/service/SIRecessionService.java | 17 + .../salary/service/SIRepairService.java | 16 + .../salary/service/SIReportService.java | 11 + .../salary/service/SISchemeService.java | 86 + .../service/SalaryAcctCalculateService.java | 25 + .../service/SalaryAcctEmployeeService.java | 273 + .../service/SalaryAcctExcelService.java | 164 + .../service/SalaryAcctRecordService.java | 213 + .../service/SalaryAcctReportService.java | 42 + .../service/SalaryAcctResultLogService.java | 72 + .../service/SalaryAcctResultService.java | 234 + .../service/SalaryAcctResultTempService.java | 39 + .../SalaryAcctResultTemplateService.java | 79 + .../service/SalaryAcctSobConfigService.java | 86 + .../service/SalaryApprovalRuleService.java | 117 + .../service/SalaryArchiveExcelService.java | 50 + .../service/SalaryArchiveItemService.java | 176 + .../salary/service/SalaryArchiveService.java | 259 + .../service/SalaryArchiveTaxAgentService.java | 84 + .../service/SalaryBillBaseSetService.java | 66 + .../service/SalaryBillItemNameService.java | 100 + .../salary/service/SalaryBillService.java | 96 + .../service/SalaryBillWatermarkService.java | 64 + .../salary/service/SalaryCacheService.java | 69 + .../SalaryCheckResultDetailService.java | 80 + .../service/SalaryCheckResultService.java | 106 + .../SalaryComparisonResultService.java | 72 + .../salary/service/SalaryEmployeeService.java | 197 + .../salary/service/SalaryFormulaService.java | 68 + .../salary/service/SalaryItemService.java | 173 + .../salary/service/SalarySQLService.java | 42 + .../service/SalarySendRangeObjService.java | 42 + .../service/SalarySendRangeService.java | 25 + .../salary/service/SalarySendService.java | 229 + .../service/SalarySobAdjustRuleService.java | 47 + .../service/SalarySobBackItemService.java | 72 + .../service/SalarySobCheckRuleService.java | 106 + .../SalarySobDefaultEmpFieldService.java | 18 + .../service/SalarySobDefaultItemService.java | 24 + .../service/SalarySobEmpFieldService.java | 41 + .../service/SalarySobExtRangeService.java | 54 + .../service/SalarySobItemGroupService.java | 49 + .../service/SalarySobItemHideService.java | 27 + .../salary/service/SalarySobItemService.java | 131 + .../salary/service/SalarySobRangeService.java | 110 + .../salary/service/SalarySobService.java | 158 + .../salary/service/SalaryTemplateService.java | 134 + .../engine/salary/service/SettingService.java | 67 + .../service/SpecialAddDeductionService.java | 108 + .../salary/service/SysSalaryItemService.java | 62 + .../salary/service/TaxAgentAdminService.java | 63 + .../salary/service/TaxAgentBaseService.java | 42 + .../service/TaxAgentEmpChangeService.java | 39 + .../salary/service/TaxAgentEmpService.java | 49 + .../salary/service/TaxAgentExcelService.java | 30 + .../service/TaxAgentManageRangeService.java | 91 + .../salary/service/TaxAgentService.java | 276 + .../service/TaxAgentSubAdminEmpService.java | 49 + .../service/TaxAgentSubAdminService.java | 82 + .../service/TaxDeclarationDetailService.java | 87 + .../service/TaxDeclarationExcelService.java | 21 + .../salary/service/TaxDeclarationService.java | 53 + .../salary/service/TaxRateBaseService.java | 28 + .../salary/service/TaxRateDetailService.java | 43 + .../service/VariableArchiveItemService.java | 36 + .../service/VariableArchiveService.java | 75 + .../salary/service/VariableItemService.java | 66 + .../salary/service/auth/AuthDataService.java | 50 + .../service/auth/AuthDataServiceImpl.java | 163 + .../service/auth/AuthMemberService.java | 49 + .../service/auth/AuthMemberServiceImpl.java | 204 + .../salary/service/auth/AuthOptService.java | 36 + .../service/auth/AuthOptServiceImpl.java | 98 + .../salary/service/auth/AuthRoleService.java | 40 + .../service/auth/AuthRoleServiceImpl.java | 250 + .../salary/service/auth/AuthService.java | 69 + .../salary/service/auth/AuthServiceImpl.java | 362 + .../impl/AddUpDeductionServiceImpl.java | 1166 +++ .../impl/AddUpSituationServiceImpl.java | 1156 +++ .../impl/AttendQuoteDataServiceImpl.java | 1044 +++ .../impl/AttendQuoteFieldServiceImpl.java | 356 + .../AttendQuoteFieldSettingServiceImpl.java | 282 + .../service/impl/AttendQuoteServiceImpl.java | 157 + .../service/impl/ColumnBuildServiceImpl.java | 567 ++ .../service/impl/ExtEmpServiceImpl.java | 638 ++ .../service/impl/FormulaRunServiceImpl.java | 242 + .../impl/MySalaryShowSetServiceImpl.java | 44 + .../impl/OtherDeductionServiceImpl.java | 1009 +++ .../service/impl/ProgressServiceImpl.java | 145 + .../salary/service/impl/PushServiceImpl.java | 564 ++ .../service/impl/RecordsBuildServiceImpl.java | 421 + .../service/impl/RemoteExcelServiceImpl.java | 493 ++ .../impl/SIAComparisonResultServiceImpl.java | 337 + .../service/impl/SIAccountServiceImpl.java | 6992 ++++++++++++++++ .../service/impl/SIArchivesServiceImpl.java | 4082 ++++++++++ .../service/impl/SIBalanceServiceImpl.java | 563 ++ .../service/impl/SICategoryServiceImpl.java | 485 ++ .../impl/SICompensationServiceImpl.java | 724 ++ .../service/impl/SIExportServiceImpl.java | 924 +++ .../service/impl/SIImportServiceImpl.java | 379 + .../service/impl/SIRecessionServiceImpl.java | 439 + .../service/impl/SIRepairServiceImpl.java | 627 ++ .../service/impl/SIReportServiceImpl.java | 34 + .../service/impl/SISchemeServiceImpl.java | 2933 +++++++ .../impl/SalaryAcctCalcServiceImpl.java | 648 ++ .../impl/SalaryAcctCalculateServiceImpl.java | 392 + .../impl/SalaryAcctEmployeeServiceImpl.java | 873 ++ .../impl/SalaryAcctExcelServiceImpl.java | 1689 ++++ .../impl/SalaryAcctRecordServiceImpl.java | 825 ++ .../impl/SalaryAcctReportServiceImpl.java | 93 + .../impl/SalaryAcctResultLogServiceImpl.java | 70 + .../impl/SalaryAcctResultServiceImpl.java | 1286 +++ .../impl/SalaryAcctResultTempServiceImpl.java | 52 + .../SalaryAcctResultTemplateServiceImpl.java | 72 + .../impl/SalaryAcctSobConfigServiceImpl.java | 200 + .../impl/SalaryApprovalRuleServiceImpl.java | 248 + .../impl/SalaryArchiveExcelServiceImpl.java | 870 ++ .../impl/SalaryArchiveItemServiceImpl.java | 821 ++ .../impl/SalaryArchiveServiceImpl.java | 1403 ++++ .../SalaryArchiveTaxAgentServiceImpl.java | 259 + .../impl/SalaryBillBaseSetServiceImpl.java | 201 + .../impl/SalaryBillItemNameServiceImpl.java | 182 + .../service/impl/SalaryBillServiceImpl.java | 1185 +++ .../impl/SalaryBillWatermarkServiceImpl.java | 57 + .../service/impl/SalaryCacheServiceImpl.java | 51 + .../SalaryComparisonResultServiceImpl.java | 284 + .../impl/SalaryEmployeeServiceImpl.java | 684 ++ .../impl/SalaryFormulaServiceImpl.java | 450 ++ .../service/impl/SalaryItemServiceImpl.java | 866 ++ .../impl/SalarySendRangeObjServiceImpl.java | 106 + .../impl/SalarySendRangeServiceImpl.java | 193 + .../service/impl/SalarySendServiceImpl.java | 2008 +++++ .../impl/SalarySobAdjustRuleServiceImpl.java | 100 + .../impl/SalarySobBackItemServiceImpl.java | 154 + .../impl/SalarySobCheckRuleServiceImpl.java | 199 + .../SalarySobDefaultEmpFieldServiceImpl.java | 26 + .../impl/SalarySobDefaultItemServiceImpl.java | 29 + .../impl/SalarySobEmpFieldServiceImpl.java | 42 + .../impl/SalarySobExtRangeServiceImpl.java | 129 + .../impl/SalarySobItemGroupServiceImpl.java | 109 + .../impl/SalarySobItemHideServiceImpl.java | 28 + .../impl/SalarySobItemServiceImpl.java | 617 ++ .../impl/SalarySobRangeServiceImpl.java | 548 ++ .../service/impl/SalarySobServiceImpl.java | 1014 +++ .../impl/SalaryTemplateServiceImpl.java | 517 ++ .../service/impl/SettingServiceImpl.java | 487 ++ .../impl/SpecialAddDeductionServiceImpl.java | 702 ++ .../impl/SysSalaryItemServiceImpl.java | 122 + .../impl/TaxAgentAdminServiceImpl.java | 88 + .../service/impl/TaxAgentBaseServiceImpl.java | 152 + .../impl/TaxAgentEmpChangeServiceImpl.java | 55 + .../service/impl/TaxAgentEmpServiceImpl.java | 267 + .../impl/TaxAgentExcelServiceImpl.java | 95 + .../impl/TaxAgentManageRangeServiceImpl.java | 1094 +++ .../service/impl/TaxAgentServiceImpl.java | 868 ++ .../impl/TaxDeclarationDetailServiceImpl.java | 257 + .../impl/TaxDeclarationExcelServiceImpl.java | 192 + .../impl/TaxDeclarationServiceImpl.java | 399 + .../service/impl/TaxRateBaseServiceImpl.java | 78 + .../impl/TaxRateDetailServiceImpl.java | 67 + .../impl/VariableArchiveItemServiceImpl.java | 87 + .../impl/VariableArchiveServiceImpl.java | 633 ++ .../service/impl/VariableItemServiceImpl.java | 246 + .../engine/salary/sys/config/SysConfig.java | 23 + .../sys/constant/SalarySysConstant.java | 234 + .../sys/entity/param/AppSettingSaveParam.java | 56 + .../param/MatchEmployeeModeSaveParam.java | 25 + .../sys/entity/param/OrderRuleParam.java | 30 + .../entity/param/SalarySysConfQueryParam.java | 29 + .../sys/entity/param/UploadConfigParam.java | 25 + .../salary/sys/entity/po/SalarySysConfPO.java | 91 + .../salary/sys/entity/vo/AppSettingVO.java | 88 + .../salary/sys/entity/vo/OrderRuleVO.java | 22 + .../sys/entity/vo/UploadConfigResponse.java | 30 + .../salary/sys/enums/AscOrDescEnum.java | 55 + .../sys/enums/MatchEmployeeModeEnum.java | 53 + src/com/engine/salary/sys/enums/OpenEnum.java | 55 + .../salary/sys/enums/OrderRuleEnum.java | 60 + .../sys/enums/PayrollCheckTypeEnum.java | 55 + .../sys/enums/SalaryAcctEmployeeRuleEnum.java | 52 + .../salary/sys/enums/ShotTimeTypeEnum.java | 57 + .../sys/enums/TaxDeclarationFunctionEnum.java | 55 + .../sys/service/SalarySysConfService.java | 148 + .../impl/SalarySysConfServiceImpl.java | 1285 +++ .../AutoAddAllSpecialAddDeductionJob.java | 37 + .../timer/AutoConfirmSalaryBillCronJob.java | 72 + .../salary/timer/AutoSendSalaryJob.java | 101 + .../salary/timer/AutoSiAccountAndFileJob.java | 106 + .../salary/timer/AutoSyncAttendQuoteJob.java | 82 + .../timer/AutoSyncEmpArchiveStartDateJob.java | 182 + .../AutoSyncResignationEmpArchiveJob.java | 124 + .../engine/salary/timer/HrmSnapshotJob.java | 54 + .../timer/SyncTaxAgentEmp2SobEmpJob.java | 79 + .../salary/timer/SyncTaxAgentEmpJob.java | 56 + .../transmethod/EncryptTransMethod.java | 7 + .../transmethod/ICategoryTransMethod.java | 38 + .../transmethod/SISchemeTransMethod.java | 17 + .../transmethod/TaxRateTransMethod.java | 45 + .../salary/transmethod/TransMethod.java | 141 + src/com/engine/salary/util/DataUtil.java | 26 + src/com/engine/salary/util/EnumUtil.java | 357 + src/com/engine/salary/util/FileUtils.java | 88 + src/com/engine/salary/util/JsonUtil.java | 97 + .../engine/salary/util/ResponseResult.java | 184 + src/com/engine/salary/util/SalaryAssert.java | 163 + .../engine/salary/util/SalaryDateUtil.java | 609 ++ .../engine/salary/util/SalaryEntityUtil.java | 376 + .../engine/salary/util/SalaryEnumUtil.java | 111 + .../salary/util/SalaryFormItemUtil.java | 236 + .../engine/salary/util/SalaryI18nUtil.java | 125 + .../engine/salary/util/SalaryLoggerUtil.java | 98 + src/com/engine/salary/util/SalarySobUtil.java | 57 + .../salary/util/SalaryThreadPoolUtil.java | 80 + .../engine/salary/util/SalaryTokenUtil.java | 258 + src/com/engine/salary/util/aes/AESUtils.java | 198 + .../salary/util/db/DBOperateAdapter.java | 5 + src/com/engine/salary/util/db/DBType.java | 41 + .../engine/salary/util/db/IdGenerator.java | 51 + .../salary/util/db/MapperProxyFactory.java | 79 + .../engine/salary/util/excel/BooleanEnum.java | 41 + .../salary/util/excel/ExcelComment.java | 111 + .../salary/util/excel/ExcelFillUtils.java | 204 + .../util/excel/ExcelParseException.java | 36 + .../salary/util/excel/ExcelParseHelper.java | 397 + .../salary/util/excel/ExcelPreviewDTO.java | 18 + .../salary/util/excel/ExcelProperty.java | 15 + .../salary/util/excel/ExcelSupport.java | 189 + .../engine/salary/util/excel/ExcelUtil.java | 497 ++ .../salary/util/excel/ExcelUtilPlus.java | 897 +++ .../util/excel/ImportExcelResponse.java | 27 + src/com/engine/salary/util/page/Column.java | 23 + .../engine/salary/util/page/DataSource.java | 9 + src/com/engine/salary/util/page/PageInfo.java | 66 + .../salary/util/page/SalaryPageUtil.java | 109 + src/com/engine/salary/util/pdf/HtmlToPdf.java | 78 + .../salary/util/report/SalaryReportUtil.java | 34 + src/com/engine/salary/util/valid/Compare.java | 40 + .../engine/salary/util/valid/DataCheck.java | 60 + src/com/engine/salary/util/valid/Modify.java | 15 + .../salary/util/valid/ModifyTypeEnum.java | 13 + .../salary/util/valid/RuntimeTypeEnum.java | 5 + .../salary/util/valid/ValidTypeEnum.java | 13 + .../engine/salary/util/valid/ValidUtil.java | 308 + .../salary/util/valid/ValueTypeEnum.java | 13 + .../engine/salary/util/xml/XStreamUtil.java | 68 + .../salary/web/AddUpDeductionController.java | 382 + .../salary/web/AddUpSituationController.java | 361 + .../salary/web/AttendQuoteController.java | 444 + src/com/engine/salary/web/AuthController.java | 218 + .../engine/salary/web/ExtEmpController.java | 133 + .../salary/web/MySalaryShowSetController.java | 45 + .../salary/web/OtherDeductionController.java | 359 + .../engine/salary/web/ProcessController.java | 48 + src/com/engine/salary/web/PushController.java | 134 + .../salary/web/SIAccountController.java | 1191 +++ .../salary/web/SIArchivesController.java | 268 + .../salary/web/SICategoryController.java | 163 + .../engine/salary/web/SIExportController.java | 367 + .../engine/salary/web/SIReportController.java | 68 + .../engine/salary/web/SISchemeController.java | 385 + .../salary/web/SalaryAcctController.java | 931 +++ .../salary/web/SalaryArchiveController.java | 1035 +++ .../salary/web/SalaryBillController.java | 820 ++ .../salary/web/SalaryCommonController.java | 207 + .../salary/web/SalaryFieldController.java | 102 + .../salary/web/SalaryFormulaController.java | 104 + .../salary/web/SalaryItemController.java | 312 + .../salary/web/SalaryProgressController.java | 52 + .../salary/web/SalarySendRangeController.java | 58 + .../salary/web/SalarySobController.java | 678 ++ .../web/SalarySystemConfigController.java | 376 + .../web/SpecialAddDeductionController.java | 338 + .../engine/salary/web/TaxAgentController.java | 520 ++ .../salary/web/TaxDeclarationController.java | 142 + .../engine/salary/web/TaxRateController.java | 92 + .../salary/web/VariableArchiveController.java | 259 + .../salary/web/VariableItemController.java | 324 + .../salary/wrapper/AddUpDeductionWrapper.java | 173 + .../salary/wrapper/AddUpSituationWrapper.java | 172 + .../wrapper/AttendQuoteDataWrapper.java | 182 + .../AttendQuoteFieldSettingWrapper.java | 68 + .../wrapper/AttendQuoteFieldWrapper.java | 147 + .../salary/wrapper/AttendQuoteWrapper.java | 159 + .../engine/salary/wrapper/AuthWrapper.java | 187 + .../engine/salary/wrapper/ExtEmpWrapper.java | 66 + .../wrapper/MySalaryShowSetWrapper.java | 32 + .../salary/wrapper/OtherDeductionWrapper.java | 270 + .../engine/salary/wrapper/ProcessWrapper.java | 39 + .../engine/salary/wrapper/PushWrapper.java | 100 + .../engine/salary/wrapper/RoleWrapper.java | 24 + .../wrapper/SIAComparisonResultWrapper.java | 55 + .../salary/wrapper/SIAccountWrapper.java | 168 + .../salary/wrapper/SICategoryWrapper.java | 112 + .../salary/wrapper/SIExportWrapper.java | 44 + .../salary/wrapper/SIImportWrapper.java | 28 + .../salary/wrapper/SIReportWrapper.java | 69 + .../salary/wrapper/SISchemeWrapper.java | 28 + .../wrapper/SalaryAcctEmployeeWrapper.java | 198 + .../wrapper/SalaryAcctExcelWrapper.java | 152 + .../wrapper/SalaryAcctRecordWrapper.java | 383 + .../wrapper/SalaryAcctResultWrapper.java | 314 + .../salary/wrapper/SalaryApprovalWrapper.java | 168 + .../wrapper/SalaryArchiveItemWrapper.java | 486 ++ .../wrapper/SalaryArchiveTaxAgentWrapper.java | 267 + .../salary/wrapper/SalaryArchiveWrapper.java | 646 ++ .../wrapper/SalaryBillBaseSetWrapper.java | 91 + .../salary/wrapper/SalaryCommonWrapper.java | 81 + .../SalaryComparisonResultWrapper.java | 83 + .../salary/wrapper/SalaryFieldWrapper.java | 250 + .../salary/wrapper/SalaryFormulaWrapper.java | 175 + .../salary/wrapper/SalaryItemWrapper.java | 328 + .../wrapper/SalarySendRangeWrapper.java | 36 + .../salary/wrapper/SalarySendWrapper.java | 741 ++ .../wrapper/SalarySobAdjustRuleWrapper.java | 96 + .../wrapper/SalarySobBackItemWrapper.java | 135 + .../wrapper/SalarySobCheckRuleWrapper.java | 124 + .../salary/wrapper/SalarySobItemWrapper.java | 180 + .../salary/wrapper/SalarySobRangeWrapper.java | 192 + .../salary/wrapper/SalarySobWrapper.java | 299 + .../wrapper/SalarySystemConfigWrapper.java | 301 + .../salary/wrapper/SalaryTemplateWrapper.java | 468 ++ .../wrapper/SpecialAddDeductionWrapper.java | 204 + .../salary/wrapper/SysSalaryItemWrapper.java | 116 + .../salary/wrapper/TaxAgentBaseWrapper.java | 44 + .../wrapper/TaxAgentSubAdminWrapper.java | 178 + .../salary/wrapper/TaxAgentWrapper.java | 508 ++ .../wrapper/TaxDeclarationDetailWrapper.java | 65 + .../salary/wrapper/TaxDeclarationWrapper.java | 161 + .../wrapper/VariableArchiveWrapper.java | 130 + .../salary/wrapper/VariableItemWrapper.java | 75 + .../proxy/SalaryAcctRecordWrapperProxy.java | 53 + .../proxy/SalaryAcctResultWrapperProxy.java | 23 + .../proxy/SalaryArchiveItemWrapperProxy.java | 67 + .../wrapper/proxy/SalarySendWrapperProxy.java | 34 + 1639 files changed, 251807 insertions(+) create mode 100644 src/com/api/salary/listener/InitListener.java create mode 100644 src/com/api/salary/web/AddUpDeductionController.java create mode 100644 src/com/api/salary/web/AddUpSituationController.java create mode 100644 src/com/api/salary/web/AttendQuoteController.java create mode 100644 src/com/api/salary/web/AuthController.java create mode 100644 src/com/api/salary/web/ExtEmpController.java create mode 100644 src/com/api/salary/web/MaintainerController.java create mode 100644 src/com/api/salary/web/MySalaryShowSetController.java create mode 100644 src/com/api/salary/web/OtherDeductionController.java create mode 100644 src/com/api/salary/web/ProcessController.java create mode 100644 src/com/api/salary/web/PushController.java create mode 100644 src/com/api/salary/web/SIAccountController.java create mode 100644 src/com/api/salary/web/SIArchiveActionAPIController.java create mode 100644 src/com/api/salary/web/SIArchivesController.java create mode 100644 src/com/api/salary/web/SICategoryController.java create mode 100644 src/com/api/salary/web/SIExportController.java create mode 100644 src/com/api/salary/web/SIReportController.java create mode 100644 src/com/api/salary/web/SISchemeController.java create mode 100644 src/com/api/salary/web/SalaryAcctController.java create mode 100644 src/com/api/salary/web/SalaryArchiveActionAPIController.java create mode 100644 src/com/api/salary/web/SalaryArchiveController.java create mode 100644 src/com/api/salary/web/SalaryBillController.java create mode 100644 src/com/api/salary/web/SalaryCommonController.java create mode 100644 src/com/api/salary/web/SalaryFieldController.java create mode 100644 src/com/api/salary/web/SalaryFormulaController.java create mode 100644 src/com/api/salary/web/SalaryItemController.java create mode 100644 src/com/api/salary/web/SalaryProgressController.java create mode 100644 src/com/api/salary/web/SalarySendRangeController.java create mode 100644 src/com/api/salary/web/SalarySobController.java create mode 100644 src/com/api/salary/web/SalaryStatisticsDimensionController.java create mode 100644 src/com/api/salary/web/SalaryStatisticsEchartsController.java create mode 100644 src/com/api/salary/web/SalaryStatisticsEmployeeController.java create mode 100644 src/com/api/salary/web/SalaryStatisticsItemController.java create mode 100644 src/com/api/salary/web/SalaryStatisticsPushController.java create mode 100644 src/com/api/salary/web/SalaryStatisticsReportController.java create mode 100644 src/com/api/salary/web/SalarySystemConfigController.java create mode 100644 src/com/api/salary/web/SpecialAddDeductionController.java create mode 100644 src/com/api/salary/web/TaxAgentController.java create mode 100644 src/com/api/salary/web/TaxDeclarationController.java create mode 100644 src/com/api/salary/web/TaxRateController.java create mode 100644 src/com/api/salary/web/VariableArchiveController.java create mode 100644 src/com/api/salary/web/VariableItemController.java create mode 100644 src/com/engine/salary/action/BatEditSalaryExcelAction.java create mode 100644 src/com/engine/salary/action/CheckBatEditSalaryExcelAction.java create mode 100644 src/com/engine/salary/action/CheckEditSIArchiveAction.java create mode 100644 src/com/engine/salary/action/CheckEditSalaryAction.java create mode 100644 src/com/engine/salary/action/CheckInitSalaryAction.java create mode 100644 src/com/engine/salary/action/CheckStayAddToPaySIArchiveAction.java create mode 100644 src/com/engine/salary/action/CheckStayDelToStopSIArchiveAction.java create mode 100644 src/com/engine/salary/action/CheckStopSalaryAction.java create mode 100644 src/com/engine/salary/action/CopyToPaySIArchiveAction.java create mode 100644 src/com/engine/salary/action/EditSIArchiveAction.java create mode 100644 src/com/engine/salary/action/EditSalaryAction.java create mode 100644 src/com/engine/salary/action/EditToPaySIArchiveAction.java create mode 100644 src/com/engine/salary/action/EditToStopSIArchiveAction.java create mode 100644 src/com/engine/salary/action/FileSalaryAcctRecordAction.java create mode 100644 src/com/engine/salary/action/InitSalaryAction.java create mode 100644 src/com/engine/salary/action/RehireAction.java create mode 100644 src/com/engine/salary/action/SalaryAcctFileByIdAction.java create mode 100644 src/com/engine/salary/action/SendSalaryAction.java create mode 100644 src/com/engine/salary/action/StayAddToPaySIArchiveAction.java create mode 100644 src/com/engine/salary/action/StayDelToStopSIArchiveAction.java create mode 100644 src/com/engine/salary/action/StopSalaryAction.java create mode 100644 src/com/engine/salary/action/UpdateSISchemeDetailAction.java create mode 100644 src/com/engine/salary/action/updateSalaryApprovalStatusAction.java create mode 100644 src/com/engine/salary/annotation/Auth.java create mode 100644 src/com/engine/salary/annotation/AuthField.java create mode 100644 src/com/engine/salary/annotation/AuthOpt.java create mode 100644 src/com/engine/salary/annotation/Encrypt.java create mode 100644 src/com/engine/salary/annotation/I18n.java create mode 100644 src/com/engine/salary/annotation/SalaryFormulaVar.java create mode 100644 src/com/engine/salary/annotation/SalaryTable.java create mode 100644 src/com/engine/salary/annotation/SalaryTableColumn.java create mode 100644 src/com/engine/salary/annotation/SalaryTableOperate.java create mode 100644 src/com/engine/salary/annotation/TableTitle.java create mode 100644 src/com/engine/salary/biz/AddUpDeductionBiz.java create mode 100644 src/com/engine/salary/biz/AddUpSituationBiz.java create mode 100644 src/com/engine/salary/biz/AttendQuoteBiz.java create mode 100644 src/com/engine/salary/biz/AttendQuoteDataBiz.java create mode 100644 src/com/engine/salary/biz/AttendQuoteDataValueBiz.java create mode 100644 src/com/engine/salary/biz/AttendQuoteFieldBiz.java create mode 100644 src/com/engine/salary/biz/AttendQuoteFieldSettingBiz.java create mode 100644 src/com/engine/salary/biz/EmployBiz.java create mode 100644 src/com/engine/salary/biz/OtherDeductionBiz.java create mode 100644 src/com/engine/salary/biz/SIAccountBiz.java create mode 100644 src/com/engine/salary/biz/SIArchivesBiz.java create mode 100644 src/com/engine/salary/biz/SICategoryBiz.java create mode 100644 src/com/engine/salary/biz/SISchemeBiz.java create mode 100644 src/com/engine/salary/biz/SalaryArchiveBiz.java create mode 100644 src/com/engine/salary/biz/SalaryArchiveDimissionBiz.java create mode 100644 src/com/engine/salary/biz/SalaryArchiveItemBiz.java create mode 100644 src/com/engine/salary/biz/SalaryArchiveTaxAgentBiz.java create mode 100644 src/com/engine/salary/biz/SalaryItemBiz.java create mode 100644 src/com/engine/salary/biz/SalarySendBiz.java create mode 100644 src/com/engine/salary/biz/SalarySendInfoBiz.java create mode 100644 src/com/engine/salary/biz/SalarySendRangeObjBiz.java create mode 100644 src/com/engine/salary/biz/SalarySobAdjustRuleBiz.java create mode 100644 src/com/engine/salary/biz/SalarySobBiz.java create mode 100644 src/com/engine/salary/biz/SalarySobCheckRuleBiz.java create mode 100644 src/com/engine/salary/biz/SalarySobDefaultItemBiz.java create mode 100644 src/com/engine/salary/biz/SalarySobDefaultItemGroupBiz.java create mode 100644 src/com/engine/salary/biz/SalarySobEmpFieldBiz.java create mode 100644 src/com/engine/salary/biz/SalarySobItemBiz.java create mode 100644 src/com/engine/salary/biz/SalarySobItemGroupBiz.java create mode 100644 src/com/engine/salary/biz/SalarySobItemHideBiz.java create mode 100644 src/com/engine/salary/biz/SalarySobRangeBiz.java create mode 100644 src/com/engine/salary/biz/SalaryTemplateBiz.java create mode 100644 src/com/engine/salary/biz/SpecialAddDeductionBiz.java create mode 100644 src/com/engine/salary/biz/SubCompanyBiz.java create mode 100644 src/com/engine/salary/biz/SysSalaryItemBiz.java create mode 100644 src/com/engine/salary/biz/TaxAgentBiz.java create mode 100644 src/com/engine/salary/biz/TaxRateBiz.java create mode 100644 src/com/engine/salary/biz/TaxRateDetailBiz.java create mode 100644 src/com/engine/salary/cache/SalaryCacheKey.java create mode 100644 src/com/engine/salary/cache/SalaryModuleKey.java create mode 100644 src/com/engine/salary/cmd/TaxRate/TaxRateDeleteCmd.java create mode 100644 src/com/engine/salary/cmd/TaxRate/TaxRateGetFormCmd.java create mode 100644 src/com/engine/salary/cmd/TaxRate/TaxRateListCmd.java create mode 100644 src/com/engine/salary/cmd/TaxRate/TaxRateSaveCmd.java create mode 100644 src/com/engine/salary/cmd/TaxRate/TaxRateUpdateCmd.java create mode 100644 src/com/engine/salary/cmd/siarchives/SIArchivesTipsCmd.java create mode 100644 src/com/engine/salary/cmd/sicategory/SICategoryGetFormCmd.java create mode 100644 src/com/engine/salary/cmd/sicategory/SICategoryInsertCmd.java create mode 100644 src/com/engine/salary/cmd/sicategory/SICategoryListCmd.java create mode 100644 src/com/engine/salary/cmd/sicategory/SICategoryUpdateCmd.java create mode 100644 src/com/engine/salary/cmd/sicategory/SICategoryUpdateStatusByIdCmd.java create mode 100644 src/com/engine/salary/cmd/sischeme/SISchemeCopyCmd.java create mode 100644 src/com/engine/salary/cmd/sischeme/SISchemeDeleteCmd.java create mode 100644 src/com/engine/salary/cmd/sischeme/SISchemeGetFormCmd.java create mode 100644 src/com/engine/salary/cmd/sischeme/SISchemeInsertCmd.java create mode 100644 src/com/engine/salary/cmd/sischeme/SISchemeListCmd.java create mode 100644 src/com/engine/salary/cmd/sischeme/SISchemeUpdateCmd.java create mode 100644 src/com/engine/salary/common/BaseQueryParam.java create mode 100644 src/com/engine/salary/common/LocalDateRange.java create mode 100644 src/com/engine/salary/common/SalaryContext.java create mode 100644 src/com/engine/salary/component/Page.java create mode 100644 src/com/engine/salary/component/PageInfo.java create mode 100644 src/com/engine/salary/component/PageInterceptor.java create mode 100644 src/com/engine/salary/component/ReflectUtil.java create mode 100644 src/com/engine/salary/component/SalaryWeaTable.java create mode 100644 src/com/engine/salary/component/WeaFormOption.java create mode 100644 src/com/engine/salary/component/WeaTableColumnGroup.java create mode 100644 src/com/engine/salary/config/SalaryElogConfig.java create mode 100644 src/com/engine/salary/config/SalaryPermissionConfig.java create mode 100644 src/com/engine/salary/constant/HrmSalaryPayrollConf.java create mode 100644 src/com/engine/salary/constant/SalaryArchiveConstant.java create mode 100644 src/com/engine/salary/constant/SalaryAuthConstant.java create mode 100644 src/com/engine/salary/constant/SalaryBillConstant.java create mode 100644 src/com/engine/salary/constant/SalaryDefaultTenantConstant.java create mode 100644 src/com/engine/salary/constant/SalaryFormulaFieldConstant.java create mode 100644 src/com/engine/salary/constant/SalaryItemConstant.java create mode 100644 src/com/engine/salary/constant/SalaryItemDataTypeConstant.java create mode 100644 src/com/engine/salary/constant/SalaryTemplateSalaryItemSetGroupConstant.java create mode 100644 src/com/engine/salary/constant/SalrayCheckSecondAuthConstant.java create mode 100644 src/com/engine/salary/constant/TaxAgentPermissionConstant.java create mode 100644 src/com/engine/salary/constant/TaxDeclarationDataIndexConstant.java create mode 100644 src/com/engine/salary/constant/TaxRateDataIndexConstant.java create mode 100644 src/com/engine/salary/constant/des.json create mode 100644 src/com/engine/salary/encrypt/AESEncryptUtil.java create mode 100644 src/com/engine/salary/encrypt/EncryptSetting.java create mode 100644 src/com/engine/salary/encrypt/EncryptUtil.java create mode 100644 src/com/engine/salary/encrypt/TestEncrypt.java create mode 100644 src/com/engine/salary/entity/agency/bo/PaymentAgencyBO.java create mode 100644 src/com/engine/salary/entity/agency/dto/PaymentAgencyFormDTO.java create mode 100644 src/com/engine/salary/entity/agency/dto/PaymentAgencyListDTO.java create mode 100644 src/com/engine/salary/entity/agency/po/PaymentAgencyPO.java create mode 100644 src/com/engine/salary/entity/auth/dto/AuthDataDTO.java create mode 100644 src/com/engine/salary/entity/auth/dto/AuthLimitDTO.java create mode 100644 src/com/engine/salary/entity/auth/dto/AuthMemberDTO.java create mode 100644 src/com/engine/salary/entity/auth/dto/AuthOptDTO.java create mode 100644 src/com/engine/salary/entity/auth/dto/AuthRoleDTO.java create mode 100644 src/com/engine/salary/entity/auth/dto/AuthRoleDataDTO.java create mode 100644 src/com/engine/salary/entity/auth/dto/AuthRoleEmpDTO.java create mode 100644 src/com/engine/salary/entity/auth/dto/AuthTreeDTO.java create mode 100644 src/com/engine/salary/entity/auth/dto/EmpOpt.java create mode 100644 src/com/engine/salary/entity/auth/dto/Opt.java create mode 100644 src/com/engine/salary/entity/auth/dto/PermissionDTO.java create mode 100644 src/com/engine/salary/entity/auth/dto/RoleLimit.java create mode 100644 src/com/engine/salary/entity/auth/dto/SobOptAuth.java create mode 100644 src/com/engine/salary/entity/auth/dto/TaxEmpOptAuth.java create mode 100644 src/com/engine/salary/entity/auth/dto/TaxOptAuth.java create mode 100644 src/com/engine/salary/entity/auth/param/AuthDataQueryParam.java create mode 100644 src/com/engine/salary/entity/auth/param/AuthDataSaveParam.java create mode 100644 src/com/engine/salary/entity/auth/param/AuthMemberQueryParam.java create mode 100644 src/com/engine/salary/entity/auth/param/AuthMemberSaveParam.java create mode 100644 src/com/engine/salary/entity/auth/param/AuthOptSaveParam.java create mode 100644 src/com/engine/salary/entity/auth/param/AuthRoleListQueryParam.java create mode 100644 src/com/engine/salary/entity/auth/param/AuthRoleSaveParam.java create mode 100644 src/com/engine/salary/entity/auth/param/AuthSyncParam.java create mode 100644 src/com/engine/salary/entity/auth/param/AuthTreeQueryParam.java create mode 100644 src/com/engine/salary/entity/auth/po/AuthDataPO.java create mode 100644 src/com/engine/salary/entity/auth/po/AuthMemberPO.java create mode 100644 src/com/engine/salary/entity/auth/po/AuthOptPO.java create mode 100644 src/com/engine/salary/entity/auth/po/AuthResourcePO.java create mode 100644 src/com/engine/salary/entity/auth/po/AuthRoleDataPO.java create mode 100644 src/com/engine/salary/entity/auth/po/AuthRoleEmpPO.java create mode 100644 src/com/engine/salary/entity/auth/po/AuthRolePO.java create mode 100644 src/com/engine/salary/entity/auth/vo/Permission.java create mode 100644 src/com/engine/salary/entity/config/SalaryConfig.java create mode 100644 src/com/engine/salary/entity/datacollection/AddUpDeduction.java create mode 100644 src/com/engine/salary/entity/datacollection/AddUpSituation.java create mode 100644 src/com/engine/salary/entity/datacollection/DataCollectionEmployee.java create mode 100644 src/com/engine/salary/entity/datacollection/bo/AttendQuoteDataBO.java create mode 100644 src/com/engine/salary/entity/datacollection/bo/AttendQuoteFieldBO.java create mode 100644 src/com/engine/salary/entity/datacollection/bo/DataCollectionBO.java create mode 100644 src/com/engine/salary/entity/datacollection/bo/VariableArchiveBO.java create mode 100644 src/com/engine/salary/entity/datacollection/bo/VariableArchiveExcelBO.java create mode 100644 src/com/engine/salary/entity/datacollection/dto/AddUpDeductionDTO.java create mode 100644 src/com/engine/salary/entity/datacollection/dto/AddUpDeductionRecordDTO.java create mode 100644 src/com/engine/salary/entity/datacollection/dto/AddUpSituationDTO.java create mode 100644 src/com/engine/salary/entity/datacollection/dto/AddUpSituationRecordDTO.java create mode 100644 src/com/engine/salary/entity/datacollection/dto/AttendQuoteDataBaseDTO.java create mode 100644 src/com/engine/salary/entity/datacollection/dto/AttendQuoteDataDTO.java create mode 100644 src/com/engine/salary/entity/datacollection/dto/AttendQuoteDataValueDTO.java create mode 100644 src/com/engine/salary/entity/datacollection/dto/AttendQuoteFieldFormDTO.java create mode 100644 src/com/engine/salary/entity/datacollection/dto/AttendQuoteFieldListDTO.java create mode 100644 src/com/engine/salary/entity/datacollection/dto/AttendQuoteFieldSettingFieldListDTO.java create mode 100644 src/com/engine/salary/entity/datacollection/dto/AttendQuoteFieldSettingListDTO.java create mode 100644 src/com/engine/salary/entity/datacollection/dto/AttendQuoteListDTO.java create mode 100644 src/com/engine/salary/entity/datacollection/dto/OtherDeductionListDTO.java create mode 100644 src/com/engine/salary/entity/datacollection/dto/OtherDeductionRecordDTO.java create mode 100644 src/com/engine/salary/entity/datacollection/dto/SpecialAddDeductionListDTO.java create mode 100644 src/com/engine/salary/entity/datacollection/dto/SpecialAddDeductionRecordDTO.java create mode 100644 src/com/engine/salary/entity/datacollection/dto/VariableArchiveItemDTO.java create mode 100644 src/com/engine/salary/entity/datacollection/dto/VariableArchiveListDTO.java create mode 100644 src/com/engine/salary/entity/datacollection/dto/VariableItemListDTO.java create mode 100644 src/com/engine/salary/entity/datacollection/param/AddDeductionAutoAddParam.java create mode 100644 src/com/engine/salary/entity/datacollection/param/AddUpDeductionImportParam.java create mode 100644 src/com/engine/salary/entity/datacollection/param/AddUpDeductionQueryParam.java create mode 100644 src/com/engine/salary/entity/datacollection/param/AddUpDeductionRecordDeleteParam.java create mode 100644 src/com/engine/salary/entity/datacollection/param/AddUpDeductionRecordParam.java create mode 100644 src/com/engine/salary/entity/datacollection/param/AddUpSituationDeleteParam.java create mode 100644 src/com/engine/salary/entity/datacollection/param/AddUpSituationImportParam.java create mode 100644 src/com/engine/salary/entity/datacollection/param/AddUpSituationParam.java create mode 100644 src/com/engine/salary/entity/datacollection/param/AddUpSituationQueryParam.java create mode 100644 src/com/engine/salary/entity/datacollection/param/AttendModuleSettingFieldParam.java create mode 100644 src/com/engine/salary/entity/datacollection/param/AttendQuoteCheckOperationParam.java create mode 100644 src/com/engine/salary/entity/datacollection/param/AttendQuoteDataEditParam.java create mode 100644 src/com/engine/salary/entity/datacollection/param/AttendQuoteDataExportTemplateParam.java create mode 100644 src/com/engine/salary/entity/datacollection/param/AttendQuoteDataImportParam.java create mode 100644 src/com/engine/salary/entity/datacollection/param/AttendQuoteDataQueryParam.java create mode 100644 src/com/engine/salary/entity/datacollection/param/AttendQuoteDataSaveParam.java create mode 100644 src/com/engine/salary/entity/datacollection/param/AttendQuoteDataSyncParam.java create mode 100644 src/com/engine/salary/entity/datacollection/param/AttendQuoteFieldQueryParam.java create mode 100644 src/com/engine/salary/entity/datacollection/param/AttendQuoteFieldSaveParam.java create mode 100644 src/com/engine/salary/entity/datacollection/param/AttendQuoteFieldSettingQueryParam.java create mode 100644 src/com/engine/salary/entity/datacollection/param/AttendQuoteFieldSettingRecoverParam.java create mode 100644 src/com/engine/salary/entity/datacollection/param/AttendQuoteFieldSettingSaveParam.java create mode 100644 src/com/engine/salary/entity/datacollection/param/AttendQuoteQueryParam.java create mode 100644 src/com/engine/salary/entity/datacollection/param/OtherDeductionExtendLastParam.java create mode 100644 src/com/engine/salary/entity/datacollection/param/OtherDeductionImportParam.java create mode 100644 src/com/engine/salary/entity/datacollection/param/OtherDeductionParam.java create mode 100644 src/com/engine/salary/entity/datacollection/param/OtherDeductionQueryParam.java create mode 100644 src/com/engine/salary/entity/datacollection/param/QuerySalaryCycleAndAttendCycleParam.java create mode 100644 src/com/engine/salary/entity/datacollection/param/SpecialAddDeductionImportParam.java create mode 100644 src/com/engine/salary/entity/datacollection/param/SpecialAddDeductionParam.java create mode 100644 src/com/engine/salary/entity/datacollection/param/SpecialAddDeductionQueryParam.java create mode 100644 src/com/engine/salary/entity/datacollection/param/SpecialAddDeductionRecordDeleteParam.java create mode 100644 src/com/engine/salary/entity/datacollection/param/VariableArchiveImportHandleParam.java create mode 100644 src/com/engine/salary/entity/datacollection/param/VariableArchiveQueryParam.java create mode 100644 src/com/engine/salary/entity/datacollection/param/VariableArchiveSaveParam.java create mode 100644 src/com/engine/salary/entity/datacollection/param/VariableItemQueryParam.java create mode 100644 src/com/engine/salary/entity/datacollection/param/VariableItemSaveParam.java create mode 100644 src/com/engine/salary/entity/datacollection/po/AttendQuoteDataPO.java create mode 100644 src/com/engine/salary/entity/datacollection/po/AttendQuoteDataValuePO.java create mode 100644 src/com/engine/salary/entity/datacollection/po/AttendQuoteFieldPO.java create mode 100644 src/com/engine/salary/entity/datacollection/po/AttendQuoteFieldSettingPO.java create mode 100644 src/com/engine/salary/entity/datacollection/po/AttendQuotePO.java create mode 100644 src/com/engine/salary/entity/datacollection/po/OtherDeductionPO.java create mode 100644 src/com/engine/salary/entity/datacollection/po/SpecialAddDeductionPO.java create mode 100644 src/com/engine/salary/entity/datacollection/po/VariableArchiveItemPO.java create mode 100644 src/com/engine/salary/entity/datacollection/po/VariableArchivePO.java create mode 100644 src/com/engine/salary/entity/datacollection/po/VariableItemPO.java create mode 100644 src/com/engine/salary/entity/extemp/dto/ExtEmpDTO.java create mode 100644 src/com/engine/salary/entity/extemp/param/ExtEmpImportParam.java create mode 100644 src/com/engine/salary/entity/extemp/param/ExtEmpQueryParam.java create mode 100644 src/com/engine/salary/entity/extemp/param/ExtEmpSaveParam.java create mode 100644 src/com/engine/salary/entity/extemp/po/ExtEmpPO.java create mode 100644 src/com/engine/salary/entity/hrm/DeptInfo.java create mode 100644 src/com/engine/salary/entity/hrm/HrmStatus.java create mode 100644 src/com/engine/salary/entity/hrm/JobCallInfo.java create mode 100644 src/com/engine/salary/entity/hrm/PositionInfo.java create mode 100644 src/com/engine/salary/entity/hrm/SubCompanyInfo.java create mode 100644 src/com/engine/salary/entity/hrm/dto/EmployeeInfoExpandDTO.java create mode 100644 src/com/engine/salary/entity/hrm/dto/FieldSetting.java create mode 100644 src/com/engine/salary/entity/hrm/dto/HrmInfoDTO.java create mode 100644 src/com/engine/salary/entity/hrm/param/HrmQueryParam.java create mode 100644 src/com/engine/salary/entity/hrm/po/ExpandFieldSettingsPO.java create mode 100644 src/com/engine/salary/entity/hrm/po/HrmSnapshotPO.java create mode 100644 src/com/engine/salary/entity/process/dto/SalaryAdjustmentDTO.java create mode 100644 src/com/engine/salary/entity/progress/ProgressDTO.java create mode 100644 src/com/engine/salary/entity/push/dto/PushRecordDTO.java create mode 100644 src/com/engine/salary/entity/push/dto/PushRecordDetailDTO.java create mode 100644 src/com/engine/salary/entity/push/dto/PushSettingDTO.java create mode 100644 src/com/engine/salary/entity/push/dto/PushSettingItemDTO.java create mode 100644 src/com/engine/salary/entity/push/param/CreatePushParam.java create mode 100644 src/com/engine/salary/entity/push/param/PushParam.java create mode 100644 src/com/engine/salary/entity/push/param/PushSettingItemQueryParam.java create mode 100644 src/com/engine/salary/entity/push/param/PushSettingItemSaveParam.java create mode 100644 src/com/engine/salary/entity/push/param/PushSettingQueryParam.java create mode 100644 src/com/engine/salary/entity/push/param/PushSettingSaveParam.java create mode 100644 src/com/engine/salary/entity/push/param/RecordDetailListQueryParam.java create mode 100644 src/com/engine/salary/entity/push/param/RecordListQueryParam.java create mode 100644 src/com/engine/salary/entity/push/param/WithdrawParam.java create mode 100644 src/com/engine/salary/entity/push/param/WithdrawPushParam.java create mode 100644 src/com/engine/salary/entity/push/po/PushRecordDetailPO.java create mode 100644 src/com/engine/salary/entity/push/po/PushRecordPO.java create mode 100644 src/com/engine/salary/entity/push/po/PushSettingItemPO.java create mode 100644 src/com/engine/salary/entity/push/po/PushSettingPO.java create mode 100644 src/com/engine/salary/entity/report/bo/SalaryAcctResultReportBO.java create mode 100644 src/com/engine/salary/entity/report/po/SalaryAcctResultReportPO.java create mode 100644 src/com/engine/salary/entity/salaryBill/bo/SalaryBillBO.java create mode 100644 src/com/engine/salary/entity/salaryBill/bo/SalaryBillItemNameBO.java create mode 100644 src/com/engine/salary/entity/salaryBill/bo/SalarySendRangeBO.java create mode 100644 src/com/engine/salary/entity/salaryBill/bo/SalaryTemplateBO.java create mode 100644 src/com/engine/salary/entity/salaryBill/dto/MySalaryShowSetDTO.java create mode 100644 src/com/engine/salary/entity/salaryBill/dto/SalaryBaseSetFormDTO.java create mode 100644 src/com/engine/salary/entity/salaryBill/dto/SalaryBillAckFeedbackDTO.java create mode 100644 src/com/engine/salary/entity/salaryBill/dto/SalaryBillItemNameDTO.java create mode 100644 src/com/engine/salary/entity/salaryBill/dto/SalaryBillSendDTO.java create mode 100644 src/com/engine/salary/entity/salaryBill/dto/SalaryBillWatermarkDTO.java create mode 100644 src/com/engine/salary/entity/salaryBill/dto/SalaryMySalaryBillListDTO.java create mode 100644 src/com/engine/salary/entity/salaryBill/dto/SalarySendBaseInfoDTO.java create mode 100644 src/com/engine/salary/entity/salaryBill/dto/SalarySendCheckDTO.java create mode 100644 src/com/engine/salary/entity/salaryBill/dto/SalarySendDetailListDTO.java create mode 100644 src/com/engine/salary/entity/salaryBill/dto/SalarySendInfoListDTO.java create mode 100644 src/com/engine/salary/entity/salaryBill/dto/SalarySendListDTO.java create mode 100644 src/com/engine/salary/entity/salaryBill/dto/SalarySendRangeListDTO.java create mode 100644 src/com/engine/salary/entity/salaryBill/dto/SalarySendRangeObjDTO.java create mode 100644 src/com/engine/salary/entity/salaryBill/dto/SalarySendUserInfoDTO.java create mode 100644 src/com/engine/salary/entity/salaryBill/dto/SalaryTemplateBaseFormDTO.java create mode 100644 src/com/engine/salary/entity/salaryBill/dto/SalaryTemplateBaseSetDTO.java create mode 100644 src/com/engine/salary/entity/salaryBill/dto/SalaryTemplateListDTO.java create mode 100644 src/com/engine/salary/entity/salaryBill/dto/SalaryTemplateReplenishFormDTO.java create mode 100644 src/com/engine/salary/entity/salaryBill/dto/SalaryTemplateSMSDTO.java create mode 100644 src/com/engine/salary/entity/salaryBill/dto/SalaryTemplateSMSSetDTO.java create mode 100644 src/com/engine/salary/entity/salaryBill/dto/SalaryTemplateSalaryItemListDTO.java create mode 100644 src/com/engine/salary/entity/salaryBill/dto/SalaryTemplateSalaryItemSetListDTO.java create mode 100644 src/com/engine/salary/entity/salaryBill/dto/SalaryTemplateShowFormDTO.java create mode 100644 src/com/engine/salary/entity/salaryBill/dto/SalaryTemplateShowSetDTO.java create mode 100644 src/com/engine/salary/entity/salaryBill/dto/salaryBillViewingLimitSetting.java create mode 100644 src/com/engine/salary/entity/salaryBill/param/ReplenishFormQueryParam.java create mode 100644 src/com/engine/salary/entity/salaryBill/param/SMSCodeCheckParam.java create mode 100644 src/com/engine/salary/entity/salaryBill/param/SMSCodeSendParam.java create mode 100644 src/com/engine/salary/entity/salaryBill/param/SalaryBaseSetSaveParam.java create mode 100644 src/com/engine/salary/entity/salaryBill/param/SalaryBillGetTokenParam.java create mode 100644 src/com/engine/salary/entity/salaryBill/param/SalaryBillItemDetailQueryParam.java create mode 100644 src/com/engine/salary/entity/salaryBill/param/SalaryBillItemNameSaveParam.java create mode 100644 src/com/engine/salary/entity/salaryBill/param/SalaryBillQueryParam.java create mode 100644 src/com/engine/salary/entity/salaryBill/param/SalaryBillSalaryGroupQueryParam.java create mode 100644 src/com/engine/salary/entity/salaryBill/param/SalaryBillSalaryItemQueryParam.java create mode 100644 src/com/engine/salary/entity/salaryBill/param/SalaryExportPdfParam.java create mode 100644 src/com/engine/salary/entity/salaryBill/param/SalaryPreviewParam.java create mode 100644 src/com/engine/salary/entity/salaryBill/param/SalarySendDetailListQueryParam.java create mode 100644 src/com/engine/salary/entity/salaryBill/param/SalarySendDetailQueryParam.java create mode 100644 src/com/engine/salary/entity/salaryBill/param/SalarySendGrantParam.java create mode 100644 src/com/engine/salary/entity/salaryBill/param/SalarySendInfoQueryParam.java create mode 100644 src/com/engine/salary/entity/salaryBill/param/SalarySendQueryParam.java create mode 100644 src/com/engine/salary/entity/salaryBill/param/SalarySendRangeQueryParam.java create mode 100644 src/com/engine/salary/entity/salaryBill/param/SalarySendRangeSaveParam.java create mode 100644 src/com/engine/salary/entity/salaryBill/param/SalarySendWithdrawParam.java create mode 100644 src/com/engine/salary/entity/salaryBill/param/SalaryTemplateCopyParam.java create mode 100644 src/com/engine/salary/entity/salaryBill/param/SalaryTemplateDefaultUseParam.java create mode 100644 src/com/engine/salary/entity/salaryBill/param/SalaryTemplateQueryParam.java create mode 100644 src/com/engine/salary/entity/salaryBill/param/SalaryTemplateSaveParam.java create mode 100644 src/com/engine/salary/entity/salaryBill/po/SalaryBillItemNamePO.java create mode 100644 src/com/engine/salary/entity/salaryBill/po/SalaryBillWatermarkPO.java create mode 100644 src/com/engine/salary/entity/salaryBill/po/SalarySendInfoPO.java create mode 100644 src/com/engine/salary/entity/salaryBill/po/SalarySendPO.java create mode 100644 src/com/engine/salary/entity/salaryBill/po/SalarySendRangeObj.java create mode 100644 src/com/engine/salary/entity/salaryBill/po/SalarySendRangePO.java create mode 100644 src/com/engine/salary/entity/salaryBill/po/SalaryTemplatePO.java create mode 100644 src/com/engine/salary/entity/salaryacct/bo/CalculateFormulaVarBO.java create mode 100644 src/com/engine/salary/entity/salaryacct/bo/ExpressFormulaBO.java create mode 100644 src/com/engine/salary/entity/salaryacct/bo/SalaryAcctCalculateBO.java create mode 100644 src/com/engine/salary/entity/salaryacct/bo/SalaryAcctCalculatePriorityBO.java create mode 100644 src/com/engine/salary/entity/salaryacct/bo/SalaryAcctCheckBO.java create mode 100644 src/com/engine/salary/entity/salaryacct/bo/SalaryAcctConfig.java create mode 100644 src/com/engine/salary/entity/salaryacct/bo/SalaryAcctConsolidatedTaxBO.java create mode 100644 src/com/engine/salary/entity/salaryacct/bo/SalaryAcctEmployeeBO.java create mode 100644 src/com/engine/salary/entity/salaryacct/bo/SalaryAcctFormulaBO.java create mode 100644 src/com/engine/salary/entity/salaryacct/bo/SalaryAcctRecordBO.java create mode 100644 src/com/engine/salary/entity/salaryacct/bo/SalaryAcctResultBO.java create mode 100644 src/com/engine/salary/entity/salaryacct/bo/SalaryAcctResultListContext.java create mode 100644 src/com/engine/salary/entity/salaryacct/bo/SalaryAcctResultLogBO.java create mode 100644 src/com/engine/salary/entity/salaryacct/bo/SalaryCalcContext.java create mode 100644 src/com/engine/salary/entity/salaryacct/bo/SalaryCalcEmployeeContext.java create mode 100644 src/com/engine/salary/entity/salaryacct/bo/SalaryCalcFormula.java create mode 100644 src/com/engine/salary/entity/salaryacct/bo/SalaryCalcFormulaContext.java create mode 100644 src/com/engine/salary/entity/salaryacct/bo/SalaryCalcResult.java create mode 100644 src/com/engine/salary/entity/salaryacct/bo/SalaryCheckBO.java create mode 100644 src/com/engine/salary/entity/salaryacct/bo/SalaryCheckResultBO.java create mode 100644 src/com/engine/salary/entity/salaryacct/dto/ConsolidatedTaxDetailDTO.java create mode 100644 src/com/engine/salary/entity/salaryacct/dto/SalaryAccEmployeeListDTO.java create mode 100644 src/com/engine/salary/entity/salaryacct/dto/SalaryAcctEmpSearchConditionDTO.java create mode 100644 src/com/engine/salary/entity/salaryacct/dto/SalaryAcctEmployeeCountDTO.java create mode 100644 src/com/engine/salary/entity/salaryacct/dto/SalaryAcctEmployeeInfoDTO.java create mode 100644 src/com/engine/salary/entity/salaryacct/dto/SalaryAcctImportFieldDTO.java create mode 100644 src/com/engine/salary/entity/salaryacct/dto/SalaryAcctRateDTO.java create mode 100644 src/com/engine/salary/entity/salaryacct/dto/SalaryAcctRecordFormDTO.java create mode 100644 src/com/engine/salary/entity/salaryacct/dto/SalaryAcctRecordListDTO.java create mode 100644 src/com/engine/salary/entity/salaryacct/dto/SalaryAcctResultDetailDTO.java create mode 100644 src/com/engine/salary/entity/salaryacct/dto/SalaryAcctResultListColumnDTO.java create mode 100644 src/com/engine/salary/entity/salaryacct/dto/SalaryAcctResultSearchConditionDTO.java create mode 100644 src/com/engine/salary/entity/salaryacct/dto/SalaryAcctResultTemplateDTO.java create mode 100644 src/com/engine/salary/entity/salaryacct/dto/SalaryCheckResultListDTO.java create mode 100644 src/com/engine/salary/entity/salaryacct/dto/SalaryCheckResultRecordCountDTO.java create mode 100644 src/com/engine/salary/entity/salaryacct/dto/SalaryCheckResultRecordListDTO.java create mode 100644 src/com/engine/salary/entity/salaryacct/dto/SalaryComparisonResultListDTO.java create mode 100644 src/com/engine/salary/entity/salaryacct/param/SalaryAcctCalculateParam.java create mode 100644 src/com/engine/salary/entity/salaryacct/param/SalaryAcctCheckParam.java create mode 100644 src/com/engine/salary/entity/salaryacct/param/SalaryAcctEmpCheckTaxAgentParam.java create mode 100644 src/com/engine/salary/entity/salaryacct/param/SalaryAcctEmpRefreshTaxAgentParam.java create mode 100644 src/com/engine/salary/entity/salaryacct/param/SalaryAcctEmployeeAddParam.java create mode 100644 src/com/engine/salary/entity/salaryacct/param/SalaryAcctEmployeeDeleteParam.java create mode 100644 src/com/engine/salary/entity/salaryacct/param/SalaryAcctEmployeeListQueryParam.java create mode 100644 src/com/engine/salary/entity/salaryacct/param/SalaryAcctEmployeeQueryParam.java create mode 100644 src/com/engine/salary/entity/salaryacct/param/SalaryAcctEmployeeSaveParam.java create mode 100644 src/com/engine/salary/entity/salaryacct/param/SalaryAcctImportParam.java create mode 100644 src/com/engine/salary/entity/salaryacct/param/SalaryAcctImportTemplateParam.java create mode 100644 src/com/engine/salary/entity/salaryacct/param/SalaryAcctRecordQueryParam.java create mode 100644 src/com/engine/salary/entity/salaryacct/param/SalaryAcctRecordReAccountParam.java create mode 100644 src/com/engine/salary/entity/salaryacct/param/SalaryAcctRecordSaveParam.java create mode 100644 src/com/engine/salary/entity/salaryacct/param/SalaryAcctResultBatchUpdateParam.java create mode 100644 src/com/engine/salary/entity/salaryacct/param/SalaryAcctResultLockParam.java create mode 100644 src/com/engine/salary/entity/salaryacct/param/SalaryAcctResultLogQueryParam.java create mode 100644 src/com/engine/salary/entity/salaryacct/param/SalaryAcctResultQueryParam.java create mode 100644 src/com/engine/salary/entity/salaryacct/param/SalaryAcctResultSaveParam.java create mode 100644 src/com/engine/salary/entity/salaryacct/param/SalaryAcctResultTemplateSaveParam.java create mode 100644 src/com/engine/salary/entity/salaryacct/param/SalaryAcctResultUpdateLockStatusParam.java create mode 100644 src/com/engine/salary/entity/salaryacct/param/SalaryCheckResultExportParam.java create mode 100644 src/com/engine/salary/entity/salaryacct/param/SalaryCheckResultQueryParam.java create mode 100644 src/com/engine/salary/entity/salaryacct/param/SalaryCheckResultRecordQueryParam.java create mode 100644 src/com/engine/salary/entity/salaryacct/param/SalaryComparisonResultExportParam.java create mode 100644 src/com/engine/salary/entity/salaryacct/param/SalaryComparisonResultQueryParam.java create mode 100644 src/com/engine/salary/entity/salaryacct/po/ExcelAcctResultPO.java create mode 100644 src/com/engine/salary/entity/salaryacct/po/SalaryAcctEmployeePO.java create mode 100644 src/com/engine/salary/entity/salaryacct/po/SalaryAcctRecordPO.java create mode 100644 src/com/engine/salary/entity/salaryacct/po/SalaryAcctResultLogPO.java create mode 100644 src/com/engine/salary/entity/salaryacct/po/SalaryAcctResultPO.java create mode 100644 src/com/engine/salary/entity/salaryacct/po/SalaryAcctResultTempPO.java create mode 100644 src/com/engine/salary/entity/salaryacct/po/SalaryAcctResultTemplatePO.java create mode 100644 src/com/engine/salary/entity/salaryacct/po/SalaryAcctSobConfigPO.java create mode 100644 src/com/engine/salary/entity/salaryacct/po/SalaryCheckResultDetailTempPO.java create mode 100644 src/com/engine/salary/entity/salaryacct/po/SalaryCheckResultPO.java create mode 100644 src/com/engine/salary/entity/salaryacct/po/SalaryCheckResultRecordPO.java create mode 100644 src/com/engine/salary/entity/salaryarchive/bo/SalaryArchiveBO.java create mode 100644 src/com/engine/salary/entity/salaryarchive/bo/SalaryArchiveExcelBO.java create mode 100644 src/com/engine/salary/entity/salaryarchive/bo/SalaryArchiveItemBO.java create mode 100644 src/com/engine/salary/entity/salaryarchive/bo/TaxAgentBO.java create mode 100644 src/com/engine/salary/entity/salaryarchive/config/ArchiveFieldConfig.java create mode 100644 src/com/engine/salary/entity/salaryarchive/dto/DimissionSetFormDTO.java create mode 100644 src/com/engine/salary/entity/salaryarchive/dto/SalaryArchiveBaseInfoFormDTO.java create mode 100644 src/com/engine/salary/entity/salaryarchive/dto/SalaryArchiveDataDTO.java create mode 100644 src/com/engine/salary/entity/salaryarchive/dto/SalaryArchiveFormDTO.java create mode 100644 src/com/engine/salary/entity/salaryarchive/dto/SalaryArchiveInitImportDTO.java create mode 100644 src/com/engine/salary/entity/salaryarchive/dto/SalaryArchiveInitImportSameDTO.java create mode 100644 src/com/engine/salary/entity/salaryarchive/dto/SalaryArchiveItemBaseDTO.java create mode 100644 src/com/engine/salary/entity/salaryarchive/dto/SalaryArchiveItemDataDTO.java create mode 100644 src/com/engine/salary/entity/salaryarchive/dto/SalaryArchiveItemDataListDTO.java create mode 100644 src/com/engine/salary/entity/salaryarchive/dto/SalaryArchiveItemFormDTO.java create mode 100644 src/com/engine/salary/entity/salaryarchive/dto/SalaryArchiveListDTO.java create mode 100644 src/com/engine/salary/entity/salaryarchive/dto/SalaryArchiveTaxAgentDataDTO.java create mode 100644 src/com/engine/salary/entity/salaryarchive/dto/SalaryArchiveTaxAgentFormDTO.java create mode 100644 src/com/engine/salary/entity/salaryarchive/dto/SalaryItemAdjustRecordListDTO.java create mode 100644 src/com/engine/salary/entity/salaryarchive/dto/SalaryItemAdjustValidDTO.java create mode 100644 src/com/engine/salary/entity/salaryarchive/dto/SingleSalaryItemAdjustRecordListDTO.java create mode 100644 src/com/engine/salary/entity/salaryarchive/dto/SingleTaxAgentAdjustRecordListDTO.java create mode 100644 src/com/engine/salary/entity/salaryarchive/dto/TaxAgentAdjustRecordListDTO.java create mode 100644 src/com/engine/salary/entity/salaryarchive/dto/TaxAgentFormDTO.java create mode 100644 src/com/engine/salary/entity/salaryarchive/dto/TaxAgentListDTO.java create mode 100644 src/com/engine/salary/entity/salaryarchive/param/SalaryArchiveDimissionSaveParam.java create mode 100644 src/com/engine/salary/entity/salaryarchive/param/SalaryArchiveImportActionParam.java create mode 100644 src/com/engine/salary/entity/salaryarchive/param/SalaryArchiveImportHandleParam.java create mode 100644 src/com/engine/salary/entity/salaryarchive/param/SalaryArchiveItemDetailSaveParam.java create mode 100644 src/com/engine/salary/entity/salaryarchive/param/SalaryArchiveItemQueryParam.java create mode 100644 src/com/engine/salary/entity/salaryarchive/param/SalaryArchiveItemSaveParam.java create mode 100644 src/com/engine/salary/entity/salaryarchive/param/SalaryArchiveQueryParam.java create mode 100644 src/com/engine/salary/entity/salaryarchive/param/SalaryArchiveSaveParam.java create mode 100644 src/com/engine/salary/entity/salaryarchive/param/SalaryArchiveSetPaySaveParam.java create mode 100644 src/com/engine/salary/entity/salaryarchive/param/SalaryArchiveStopParam.java create mode 100644 src/com/engine/salary/entity/salaryarchive/param/SalaryArchiveTaxAgentQueryParam.java create mode 100644 src/com/engine/salary/entity/salaryarchive/param/SalaryArchiveTaxAgentSaveParam.java create mode 100644 src/com/engine/salary/entity/salaryarchive/param/SalaryItemAdjustBeforeParam.java create mode 100644 src/com/engine/salary/entity/salaryarchive/param/SalaryItemAdjustRecordQueryParam.java create mode 100644 src/com/engine/salary/entity/salaryarchive/param/SingleSalaryItemAdjustRecordQueryParam.java create mode 100644 src/com/engine/salary/entity/salaryarchive/param/SingleTaxAgentAdjustRecordQueryParam.java create mode 100644 src/com/engine/salary/entity/salaryarchive/param/TaxAgentAdjustRecordQueryParam.java create mode 100644 src/com/engine/salary/entity/salaryarchive/param/TaxAgentQueryParam.java create mode 100644 src/com/engine/salary/entity/salaryarchive/param/TaxAgentSaveParam.java create mode 100644 src/com/engine/salary/entity/salaryarchive/po/SalaryArchiveDimissionPO.java create mode 100644 src/com/engine/salary/entity/salaryarchive/po/SalaryArchiveEmployeePO.java create mode 100644 src/com/engine/salary/entity/salaryarchive/po/SalaryArchiveItemPO.java create mode 100644 src/com/engine/salary/entity/salaryarchive/po/SalaryArchivePO.java create mode 100644 src/com/engine/salary/entity/salaryarchive/po/SalaryArchiveTaxAgentPO.java create mode 100644 src/com/engine/salary/entity/salaryformula/ExpressFormula.java create mode 100644 src/com/engine/salary/entity/salaryformula/bo/SalaryFormulaBO.java create mode 100644 src/com/engine/salary/entity/salaryformula/config/FormluaConfig.java create mode 100644 src/com/engine/salary/entity/salaryformula/dto/ExpressFormulaDTO.java create mode 100644 src/com/engine/salary/entity/salaryformula/dto/SalaryFormulaEmployeeDTO.java create mode 100644 src/com/engine/salary/entity/salaryformula/dto/SalaryFormulaTaxRateDTO.java create mode 100644 src/com/engine/salary/entity/salaryformula/param/SalaryFormulaDetailQueryParam.java create mode 100644 src/com/engine/salary/entity/salaryformula/param/SalaryFormulaFieldQueryParam.java create mode 100644 src/com/engine/salary/entity/salaryformula/param/SalaryFormulaMockParam.java create mode 100644 src/com/engine/salary/entity/salaryformula/param/SalaryFormulaSaveParam.java create mode 100644 src/com/engine/salary/entity/salaryformula/po/FormulaPO.java create mode 100644 src/com/engine/salary/entity/salaryformula/po/FormulaVar.java create mode 100644 src/com/engine/salary/entity/salaryitem/bo/SalaryItemBO.java create mode 100644 src/com/engine/salary/entity/salaryitem/bo/SysSalaryItemBO.java create mode 100644 src/com/engine/salary/entity/salaryitem/config/FormulaConfig.java create mode 100644 src/com/engine/salary/entity/salaryitem/config/FormulaVarConfig.java create mode 100644 src/com/engine/salary/entity/salaryitem/config/SalaryItemAllConfig.java create mode 100644 src/com/engine/salary/entity/salaryitem/config/SalaryItemConfig.java create mode 100644 src/com/engine/salary/entity/salaryitem/config/SalaryItemExcelConfig.java create mode 100644 src/com/engine/salary/entity/salaryitem/dto/SalaryFieldListDTO.java create mode 100644 src/com/engine/salary/entity/salaryitem/dto/SalaryItemFormDTO.java create mode 100644 src/com/engine/salary/entity/salaryitem/dto/SalaryItemListDTO.java create mode 100644 src/com/engine/salary/entity/salaryitem/dto/SalaryItemSearchConditionDTO.java create mode 100644 src/com/engine/salary/entity/salaryitem/dto/SalaryItemSobListDTO.java create mode 100644 src/com/engine/salary/entity/salaryitem/dto/SysSalaryItemListDTO.java create mode 100644 src/com/engine/salary/entity/salaryitem/dto/SysSalaryItemSearchConditionDTO.java create mode 100644 src/com/engine/salary/entity/salaryitem/param/SalaryItemDownloadTemplateParam.java create mode 100644 src/com/engine/salary/entity/salaryitem/param/SalaryItemExportParam.java create mode 100644 src/com/engine/salary/entity/salaryitem/param/SalaryItemImportParam.java create mode 100644 src/com/engine/salary/entity/salaryitem/param/SalaryItemSaveParam.java create mode 100644 src/com/engine/salary/entity/salaryitem/param/SalaryItemSearchParam.java create mode 100644 src/com/engine/salary/entity/salaryitem/param/SyncSalaryItemParam.java create mode 100644 src/com/engine/salary/entity/salaryitem/param/SysSalaryItemSearchParam.java create mode 100644 src/com/engine/salary/entity/salaryitem/po/SalaryItemPO.java create mode 100644 src/com/engine/salary/entity/salaryitem/po/SysSalaryItemPO.java create mode 100644 src/com/engine/salary/entity/salarysob/bo/SalaryApprovalBO.java create mode 100644 src/com/engine/salary/entity/salarysob/bo/SalarySobAdjustRuleBO.java create mode 100644 src/com/engine/salary/entity/salarysob/bo/SalarySobBO.java create mode 100644 src/com/engine/salary/entity/salarysob/bo/SalarySobBackItemBO.java create mode 100644 src/com/engine/salary/entity/salarysob/bo/SalarySobCheckRuleBO.java create mode 100644 src/com/engine/salary/entity/salarysob/bo/SalarySobCycleBO.java create mode 100644 src/com/engine/salary/entity/salarysob/bo/SalarySobDuplicateBO.java create mode 100644 src/com/engine/salary/entity/salarysob/bo/SalarySobItemAggregateBO.java create mode 100644 src/com/engine/salary/entity/salarysob/bo/SalarySobItemBO.java create mode 100644 src/com/engine/salary/entity/salarysob/bo/SalarySobItemSaveBO.java create mode 100644 src/com/engine/salary/entity/salarysob/bo/SalarySobRangeBO.java create mode 100644 src/com/engine/salary/entity/salarysob/bo/SalarySobRangeSaveBO.java create mode 100644 src/com/engine/salary/entity/salarysob/config/SalarySobConfig.java create mode 100644 src/com/engine/salary/entity/salarysob/dto/SalaryApprovalDTO.java create mode 100644 src/com/engine/salary/entity/salarysob/dto/SalaryItemBaseDTO.java create mode 100644 src/com/engine/salary/entity/salarysob/dto/SalarySobAdjustRuleListDTO.java create mode 100644 src/com/engine/salary/entity/salarysob/dto/SalarySobBackItemAggregateDTO.java create mode 100644 src/com/engine/salary/entity/salarysob/dto/SalarySobBackItemDTO.java create mode 100644 src/com/engine/salary/entity/salarysob/dto/SalarySobBackItemFormDTO.java create mode 100644 src/com/engine/salary/entity/salarysob/dto/SalarySobBasicFormDTO.java create mode 100644 src/com/engine/salary/entity/salarysob/dto/SalarySobCheckRuleFormDTO.java create mode 100644 src/com/engine/salary/entity/salarysob/dto/SalarySobCheckRuleListDTO.java create mode 100644 src/com/engine/salary/entity/salarysob/dto/SalarySobCycleDTO.java create mode 100644 src/com/engine/salary/entity/salarysob/dto/SalarySobEmpFieldDTO.java create mode 100644 src/com/engine/salary/entity/salarysob/dto/SalarySobItemAggregateDTO.java create mode 100644 src/com/engine/salary/entity/salarysob/dto/SalarySobItemDTO.java create mode 100644 src/com/engine/salary/entity/salarysob/dto/SalarySobItemFormDTO.java create mode 100644 src/com/engine/salary/entity/salarysob/dto/SalarySobItemGroupDTO.java create mode 100644 src/com/engine/salary/entity/salarysob/dto/SalarySobItemGroupFormDTO.java create mode 100644 src/com/engine/salary/entity/salarysob/dto/SalarySobItemIncomeCategoryDTO.java create mode 100644 src/com/engine/salary/entity/salarysob/dto/SalarySobListDTO.java create mode 100644 src/com/engine/salary/entity/salarysob/dto/SalarySobRangeImportListDTO.java create mode 100644 src/com/engine/salary/entity/salarysob/dto/SalarySobRangeListDTO.java create mode 100644 src/com/engine/salary/entity/salarysob/param/ApprovalRequestSaveParam.java create mode 100644 src/com/engine/salary/entity/salarysob/param/SalaryApprovalQueryParam.java create mode 100644 src/com/engine/salary/entity/salarysob/param/SalarySobAdjustRuleItemQueryParam.java create mode 100644 src/com/engine/salary/entity/salarysob/param/SalarySobAdjustRuleQueryParam.java create mode 100644 src/com/engine/salary/entity/salarysob/param/SalarySobAdjustRuleSaveParam.java create mode 100644 src/com/engine/salary/entity/salarysob/param/SalarySobBackItemSaveParam.java create mode 100644 src/com/engine/salary/entity/salarysob/param/SalarySobBasicSaveParam.java create mode 100644 src/com/engine/salary/entity/salarysob/param/SalarySobCheckRuleQueryParam.java create mode 100644 src/com/engine/salary/entity/salarysob/param/SalarySobCheckRuleSaveParam.java create mode 100644 src/com/engine/salary/entity/salarysob/param/SalarySobDisableParam.java create mode 100644 src/com/engine/salary/entity/salarysob/param/SalarySobDuplicateParam.java create mode 100644 src/com/engine/salary/entity/salarysob/param/SalarySobItemSaveParam.java create mode 100644 src/com/engine/salary/entity/salarysob/param/SalarySobListQueryParam.java create mode 100644 src/com/engine/salary/entity/salarysob/param/SalarySobQueryParam.java create mode 100644 src/com/engine/salary/entity/salarysob/param/SalarySobRangeEmpQueryParam.java create mode 100644 src/com/engine/salary/entity/salarysob/param/SalarySobRangeExtSaveParam.java create mode 100644 src/com/engine/salary/entity/salarysob/param/SalarySobRangeImportParam.java create mode 100644 src/com/engine/salary/entity/salarysob/param/SalarySobRangeQueryParam.java create mode 100644 src/com/engine/salary/entity/salarysob/param/SalarySobRangeSaveParam.java create mode 100644 src/com/engine/salary/entity/salarysob/param/UpdateCheckRuleFormulaParam.java create mode 100644 src/com/engine/salary/entity/salarysob/po/SalaryApprovalRulePO.java create mode 100644 src/com/engine/salary/entity/salarysob/po/SalarySobAdjustRulePO.java create mode 100644 src/com/engine/salary/entity/salarysob/po/SalarySobBackItemPO.java create mode 100644 src/com/engine/salary/entity/salarysob/po/SalarySobCheckRulePO.java create mode 100644 src/com/engine/salary/entity/salarysob/po/SalarySobDefaultBackItemPO.java create mode 100644 src/com/engine/salary/entity/salarysob/po/SalarySobDefaultEmpFieldPO.java create mode 100644 src/com/engine/salary/entity/salarysob/po/SalarySobDefaultItemGroupPO.java create mode 100644 src/com/engine/salary/entity/salarysob/po/SalarySobDefaultItemPO.java create mode 100644 src/com/engine/salary/entity/salarysob/po/SalarySobEmpFieldPO.java create mode 100644 src/com/engine/salary/entity/salarysob/po/SalarySobExtRangePO.java create mode 100644 src/com/engine/salary/entity/salarysob/po/SalarySobItemGroupPO.java create mode 100644 src/com/engine/salary/entity/salarysob/po/SalarySobItemHidePO.java create mode 100644 src/com/engine/salary/entity/salarysob/po/SalarySobItemPO.java create mode 100644 src/com/engine/salary/entity/salarysob/po/SalarySobPO.java create mode 100644 src/com/engine/salary/entity/salarysob/po/SalarySobRangePO.java create mode 100644 src/com/engine/salary/entity/salarysob/po/SobTaxLinkPO.java create mode 100644 src/com/engine/salary/entity/salarysql/ExpressSQL.java create mode 100644 src/com/engine/salary/entity/salarysql/po/SQLPO.java create mode 100644 src/com/engine/salary/entity/salarysql/po/SQLVar.java create mode 100644 src/com/engine/salary/entity/setting/dto/PageListSettingDTO.java create mode 100644 src/com/engine/salary/entity/setting/dto/PageListTemplateDTO.java create mode 100644 src/com/engine/salary/entity/setting/dto/PageListTemplateDetailDTO.java create mode 100644 src/com/engine/salary/entity/setting/param/DownloadTemplateParam.java create mode 100644 src/com/engine/salary/entity/setting/param/PageListColumnsQueryParam.java create mode 100644 src/com/engine/salary/entity/setting/param/PageListSettingQueryParam.java create mode 100644 src/com/engine/salary/entity/setting/param/PageListSettingResetParam.java create mode 100644 src/com/engine/salary/entity/setting/param/PageListSettingSaveParam.java create mode 100644 src/com/engine/salary/entity/setting/param/PageListTemplateChangeParam.java create mode 100644 src/com/engine/salary/entity/setting/param/PageListTemplateDeleteParam.java create mode 100644 src/com/engine/salary/entity/setting/param/PageListTemplateQueryParam.java create mode 100644 src/com/engine/salary/entity/setting/param/PageListTemplateSaveParam.java create mode 100644 src/com/engine/salary/entity/setting/po/PageLinkPO.java create mode 100644 src/com/engine/salary/entity/setting/po/PageListSettingPO.java create mode 100644 src/com/engine/salary/entity/setting/po/PageListTemplatePO.java create mode 100644 src/com/engine/salary/entity/siaccount/bo/InsuranceAccountBO.java create mode 100644 src/com/engine/salary/entity/siaccount/bo/InsuranceComparisonResultBO.java create mode 100644 src/com/engine/salary/entity/siaccount/dto/InsuranceAccountBatchListDTO.java create mode 100644 src/com/engine/salary/entity/siaccount/dto/InsuranceAccountTabDTO.java create mode 100644 src/com/engine/salary/entity/siaccount/dto/InsuranceAccountViewListDTO.java create mode 100644 src/com/engine/salary/entity/siaccount/dto/InsuranceAcctDetailImportFieldDTO.java create mode 100644 src/com/engine/salary/entity/siaccount/dto/InsuranceComparisonResultListDTO.java create mode 100644 src/com/engine/salary/entity/siaccount/dto/InsuranceCompensationDTO.java create mode 100644 src/com/engine/salary/entity/siaccount/dto/SIAccountUtilDTO.java create mode 100644 src/com/engine/salary/entity/siaccount/param/AccountParam.java create mode 100644 src/com/engine/salary/entity/siaccount/param/BalanceAccountBaseParam.java create mode 100644 src/com/engine/salary/entity/siaccount/param/CompensationParam.java create mode 100644 src/com/engine/salary/entity/siaccount/param/DSTenantKeyThreadVar.java create mode 100644 src/com/engine/salary/entity/siaccount/param/EditAccountDetailParam.java create mode 100644 src/com/engine/salary/entity/siaccount/param/ExcelInsuranceImportParam.java create mode 100644 src/com/engine/salary/entity/siaccount/param/InspectAccountParam.java create mode 100644 src/com/engine/salary/entity/siaccount/param/InsuranceAccountBatchParam.java create mode 100644 src/com/engine/salary/entity/siaccount/param/InsuranceAccountDetailParam.java create mode 100644 src/com/engine/salary/entity/siaccount/param/InsuranceAcctDetailImportTemplateParam.java create mode 100644 src/com/engine/salary/entity/siaccount/param/InsuranceAcctImportParam.java create mode 100644 src/com/engine/salary/entity/siaccount/param/InsuranceComparisonResultQueryParam.java create mode 100644 src/com/engine/salary/entity/siaccount/param/Permission.java create mode 100644 src/com/engine/salary/entity/siaccount/param/QueryAccountDetailParam.java create mode 100644 src/com/engine/salary/entity/siaccount/param/RecessionParam.java create mode 100644 src/com/engine/salary/entity/siaccount/param/SaveCommonAccountParam.java create mode 100644 src/com/engine/salary/entity/siaccount/param/SaveSupplementaryAccountParam.java create mode 100644 src/com/engine/salary/entity/siaccount/param/SupplementAccountBaseParam.java create mode 100644 src/com/engine/salary/entity/siaccount/po/ExcelInsuranceDetailPO.java create mode 100644 src/com/engine/salary/entity/siaccount/po/InsuranceAccountBatchPO.java create mode 100644 src/com/engine/salary/entity/siaccount/po/InsuranceAccountDetailPO.java create mode 100644 src/com/engine/salary/entity/siaccount/po/InsuranceAccountDetailTempPO.java create mode 100644 src/com/engine/salary/entity/siaccount/po/InsuranceAccountInspectPO.java create mode 100644 src/com/engine/salary/entity/siaccount/po/InsuranceCompensationConfigPO.java create mode 100644 src/com/engine/salary/entity/siaccount/po/InsuranceCompensationPO.java create mode 100644 src/com/engine/salary/entity/siarchives/bo/InsuranceArchivesBO.java create mode 100644 src/com/engine/salary/entity/siarchives/bo/InsuranceArchivesBaseInfoBO.java create mode 100644 src/com/engine/salary/entity/siarchives/dto/InsuranceArchivesBaseDTO.java create mode 100644 src/com/engine/salary/entity/siarchives/dto/InsuranceArchivesBaseHistoryDTO.java create mode 100644 src/com/engine/salary/entity/siarchives/dto/InsuranceArchivesFundSchemeDTO.java create mode 100644 src/com/engine/salary/entity/siarchives/dto/InsuranceArchivesOtherSchemeDTO.java create mode 100644 src/com/engine/salary/entity/siarchives/dto/InsuranceArchivesSocialSchemeDTO.java create mode 100644 src/com/engine/salary/entity/siarchives/param/InsuranceArchivesFundSaveParam.java create mode 100644 src/com/engine/salary/entity/siarchives/param/InsuranceArchivesListParam.java create mode 100644 src/com/engine/salary/entity/siarchives/param/InsuranceArchivesOtherSaveParam.java create mode 100644 src/com/engine/salary/entity/siarchives/param/InsuranceArchivesSaveParam.java create mode 100644 src/com/engine/salary/entity/siarchives/param/InsuranceArchivesSocialSaveParam.java create mode 100644 src/com/engine/salary/entity/siarchives/param/SIArchiveBaseHistoryListParam.java create mode 100644 src/com/engine/salary/entity/siarchives/param/SIArchiveImportActionParam.java create mode 100644 src/com/engine/salary/entity/siarchives/param/SIArchiveImportParam.java create mode 100644 src/com/engine/salary/entity/siarchives/po/InsuranceArchivesAccountPO.java create mode 100644 src/com/engine/salary/entity/siarchives/po/InsuranceArchivesBaseHistoryPO.java create mode 100644 src/com/engine/salary/entity/siarchives/po/InsuranceArchivesBaseInfoPO.java create mode 100644 src/com/engine/salary/entity/siarchives/po/InsuranceArchivesEmployeePO.java create mode 100644 src/com/engine/salary/entity/siarchives/po/InsuranceArchivesFundSchemePO.java create mode 100644 src/com/engine/salary/entity/siarchives/po/InsuranceArchivesOtherSchemePO.java create mode 100644 src/com/engine/salary/entity/siarchives/po/InsuranceArchivesSocialSchemePO.java create mode 100644 src/com/engine/salary/entity/sicategory/bo/ICategoryBO.java create mode 100644 src/com/engine/salary/entity/sicategory/bo/InsuranceCategoryBO.java create mode 100644 src/com/engine/salary/entity/sicategory/dto/ICategoryDTO.java create mode 100644 src/com/engine/salary/entity/sicategory/dto/ICategoryFormDTO.java create mode 100644 src/com/engine/salary/entity/sicategory/dto/ICategoryListDTO.java create mode 100644 src/com/engine/salary/entity/sicategory/param/ICategoryListQueryParam.java create mode 100644 src/com/engine/salary/entity/sicategory/param/UpdateStatusParam.java create mode 100644 src/com/engine/salary/entity/sicategory/po/ICategoryPO.java create mode 100644 src/com/engine/salary/entity/siexport/param/InsuranceExportParam.java create mode 100644 src/com/engine/salary/entity/siexport/po/AccountExportPO.java create mode 100644 src/com/engine/salary/entity/siexport/po/ExcelAccountExportPO.java create mode 100644 src/com/engine/salary/entity/sischeme/bo/InsuranceSchemeBO.java create mode 100644 src/com/engine/salary/entity/sischeme/dto/InsuranceSchemeDTO.java create mode 100644 src/com/engine/salary/entity/sischeme/dto/InsuranceSchemeDetailDTO.java create mode 100644 src/com/engine/salary/entity/sischeme/dto/InsuranceSchemeListDTO.java create mode 100644 src/com/engine/salary/entity/sischeme/param/InsuranceSchemeDetailUpdateParam.java create mode 100644 src/com/engine/salary/entity/sischeme/param/InsuranceSchemeParam.java create mode 100644 src/com/engine/salary/entity/sischeme/param/InsuranceSchemeReqParam.java create mode 100644 src/com/engine/salary/entity/sischeme/param/SISchemaImportParam.java create mode 100644 src/com/engine/salary/entity/sischeme/po/InsuranceSchemeDetailPO.java create mode 100644 src/com/engine/salary/entity/sischeme/po/InsuranceSchemePO.java create mode 100644 src/com/engine/salary/entity/sischeme/vo/InsuranceSchemeFormVO.java create mode 100644 src/com/engine/salary/entity/sischeme/vo/SISchemeTableVO.java create mode 100644 src/com/engine/salary/entity/taxagent/bo/TaxAgentBO.java create mode 100644 src/com/engine/salary/entity/taxagent/config/TaxAgentConfig.java create mode 100644 src/com/engine/salary/entity/taxagent/dto/TaxAgentAdjustRecordForFormSearchConditionDTO.java create mode 100644 src/com/engine/salary/entity/taxagent/dto/TaxAgentAdjustRecordListDTO.java create mode 100644 src/com/engine/salary/entity/taxagent/dto/TaxAgentAdjustRecordSearchConditionDTO.java create mode 100644 src/com/engine/salary/entity/taxagent/dto/TaxAgentBaseFormDTO.java create mode 100644 src/com/engine/salary/entity/taxagent/dto/TaxAgentEmployeeDTO.java create mode 100644 src/com/engine/salary/entity/taxagent/dto/TaxAgentEmployeeOptionDTO.java create mode 100644 src/com/engine/salary/entity/taxagent/dto/TaxAgentEmployeeTaxAgentDTO.java create mode 100644 src/com/engine/salary/entity/taxagent/dto/TaxAgentFormDTO.java create mode 100644 src/com/engine/salary/entity/taxagent/dto/TaxAgentListDTO.java create mode 100644 src/com/engine/salary/entity/taxagent/dto/TaxAgentManageRangeEmployeeDTO.java create mode 100644 src/com/engine/salary/entity/taxagent/dto/TaxAgentManageRangeEmployeeListDTO.java create mode 100644 src/com/engine/salary/entity/taxagent/dto/TaxAgentManageRangeFormDTO.java create mode 100644 src/com/engine/salary/entity/taxagent/dto/TaxAgentManageRangeListDTO.java create mode 100644 src/com/engine/salary/entity/taxagent/dto/TaxAgentSubAdminBaseFormDTO.java create mode 100644 src/com/engine/salary/entity/taxagent/dto/TaxAgentSubAdminListDTO.java create mode 100644 src/com/engine/salary/entity/taxagent/param/TaxAgentAdjustRecordQueryParam.java create mode 100644 src/com/engine/salary/entity/taxagent/param/TaxAgentAdminChangeCheckParam.java create mode 100644 src/com/engine/salary/entity/taxagent/param/TaxAgentEmpSaveParam.java create mode 100644 src/com/engine/salary/entity/taxagent/param/TaxAgentImportParam.java create mode 100644 src/com/engine/salary/entity/taxagent/param/TaxAgentManageRangeEmpQueryParam.java create mode 100644 src/com/engine/salary/entity/taxagent/param/TaxAgentManageRangeExtSaveParam.java create mode 100644 src/com/engine/salary/entity/taxagent/param/TaxAgentManageRangeQueryParam.java create mode 100644 src/com/engine/salary/entity/taxagent/param/TaxAgentManageRangeSaveParam.java create mode 100644 src/com/engine/salary/entity/taxagent/param/TaxAgentQueryParam.java create mode 100644 src/com/engine/salary/entity/taxagent/param/TaxAgentRangeDownloadTemplateParam.java create mode 100644 src/com/engine/salary/entity/taxagent/param/TaxAgentRangeExtQueryParam.java create mode 100644 src/com/engine/salary/entity/taxagent/param/TaxAgentRangeQueryParam.java create mode 100644 src/com/engine/salary/entity/taxagent/param/TaxAgentRangeSaveParam.java create mode 100644 src/com/engine/salary/entity/taxagent/param/TaxAgentSaveBaseParam.java create mode 100644 src/com/engine/salary/entity/taxagent/param/TaxAgentSaveParam.java create mode 100644 src/com/engine/salary/entity/taxagent/param/TaxAgentSubAdminBaseFormParam.java create mode 100644 src/com/engine/salary/entity/taxagent/param/TaxAgentSubAdminBaseSaveParam.java create mode 100644 src/com/engine/salary/entity/taxagent/param/TaxAgentSubAdminEmpSaveParam.java create mode 100644 src/com/engine/salary/entity/taxagent/param/TaxAgentSubAdminQueryParam.java create mode 100644 src/com/engine/salary/entity/taxagent/param/TaxAgentSubAdminRangeQueryParam.java create mode 100644 src/com/engine/salary/entity/taxagent/param/TaxAgentSubAdminRangeSaveParam.java create mode 100644 src/com/engine/salary/entity/taxagent/po/TaxAgentAdminPO.java create mode 100644 src/com/engine/salary/entity/taxagent/po/TaxAgentBasePO.java create mode 100644 src/com/engine/salary/entity/taxagent/po/TaxAgentEmpChangePO.java create mode 100644 src/com/engine/salary/entity/taxagent/po/TaxAgentEmpPO.java create mode 100644 src/com/engine/salary/entity/taxagent/po/TaxAgentEmployeePO.java create mode 100644 src/com/engine/salary/entity/taxagent/po/TaxAgentExtRangePO.java create mode 100644 src/com/engine/salary/entity/taxagent/po/TaxAgentManageRangePO.java create mode 100644 src/com/engine/salary/entity/taxagent/po/TaxAgentPO.java create mode 100644 src/com/engine/salary/entity/taxagent/po/TaxAgentSubAdminEmpPO.java create mode 100644 src/com/engine/salary/entity/taxagent/po/TaxAgentSubAdminPO.java create mode 100644 src/com/engine/salary/entity/taxdeclaration/bo/TaxDeclarationBO.java create mode 100644 src/com/engine/salary/entity/taxdeclaration/bo/TaxDeclarationDetailBO.java create mode 100644 src/com/engine/salary/entity/taxdeclaration/bo/TaxDeclarationDetailListColumn.java create mode 100644 src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationAnnualListDTO.java create mode 100644 src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationDetailListDTO.java create mode 100644 src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationEmployeeDTO.java create mode 100644 src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationFormDTO.java create mode 100644 src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationInfoDTO.java create mode 100644 src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationLaborListDTO.java create mode 100644 src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationListDTO.java create mode 100644 src/com/engine/salary/entity/taxdeclaration/param/TaxDeclarationDetailListQueryParam.java create mode 100644 src/com/engine/salary/entity/taxdeclaration/param/TaxDeclarationListQueryParam.java create mode 100644 src/com/engine/salary/entity/taxdeclaration/param/TaxDeclarationSaveParam.java create mode 100644 src/com/engine/salary/entity/taxdeclaration/po/TaxDeclarationDetailPO.java create mode 100644 src/com/engine/salary/entity/taxdeclaration/po/TaxDeclarationPO.java create mode 100644 src/com/engine/salary/entity/taxrate/SysTaxRateBase.java create mode 100644 src/com/engine/salary/entity/taxrate/SysTaxRateDetailPO.java create mode 100644 src/com/engine/salary/entity/taxrate/TaxAgent.java create mode 100644 src/com/engine/salary/entity/taxrate/TaxRateBase.java create mode 100644 src/com/engine/salary/entity/taxrate/TaxRateDetail.java create mode 100644 src/com/engine/salary/entity/taxrate/bo/TaxRateBO.java create mode 100644 src/com/engine/salary/entity/taxrate/bo/TaxRateDetailBO.java create mode 100644 src/com/engine/salary/entity/taxrate/param/TaxAgentQueryParam.java create mode 100644 src/com/engine/salary/entity/taxrate/param/TaxRateBaseSaveParam.java create mode 100644 src/com/engine/salary/entity/taxrate/param/TaxRateDetailSaveParam.java create mode 100644 src/com/engine/salary/entity/taxrate/param/TaxRateSaveParam.java create mode 100644 src/com/engine/salary/entity/taxrate/vo/TaxAgentTableVO.java create mode 100644 src/com/engine/salary/entity/taxrate/vo/TaxDeclarationListVO.java create mode 100644 src/com/engine/salary/entity/taxrate/vo/TaxRateFormVo.java create mode 100644 src/com/engine/salary/entity/taxrate/vo/TaxRateTableVO.java create mode 100644 src/com/engine/salary/enums/AccountTypeEnum.java create mode 100644 src/com/engine/salary/enums/BaseEnum.java create mode 100644 src/com/engine/salary/enums/OperateTypeEnum.java create mode 100644 src/com/engine/salary/enums/SalaryCycleTypeEnum.java create mode 100644 src/com/engine/salary/enums/SalaryDataSourceEnum.java create mode 100644 src/com/engine/salary/enums/SalaryItemCategoryEnum.java create mode 100644 src/com/engine/salary/enums/SalaryItemTypeEnum.java create mode 100644 src/com/engine/salary/enums/SalaryJobFlagEnum.java create mode 100644 src/com/engine/salary/enums/SalaryOnOffEnum.java create mode 100644 src/com/engine/salary/enums/SalaryRoundingModeEnum.java create mode 100644 src/com/engine/salary/enums/SalarySobStatusEnum.java create mode 100644 src/com/engine/salary/enums/SalarySystemTypeEnum.java create mode 100644 src/com/engine/salary/enums/SalaryValueTypeEnum.java create mode 100644 src/com/engine/salary/enums/UserStatusEnum.java create mode 100644 src/com/engine/salary/enums/auth/AuthCheckTypeEnum.java create mode 100644 src/com/engine/salary/enums/auth/AuthFilterTypeEnum.java create mode 100644 src/com/engine/salary/enums/auth/DataLinkEnum.java create mode 100644 src/com/engine/salary/enums/auth/DataTargetTypeEnum.java create mode 100644 src/com/engine/salary/enums/auth/LoginPersonTargetTypeEnum.java create mode 100644 src/com/engine/salary/enums/auth/MemberTargetTypeEnum.java create mode 100644 src/com/engine/salary/enums/auth/ResourceTargetTypeEnum.java create mode 100644 src/com/engine/salary/enums/common/FilterEnum.java create mode 100644 src/com/engine/salary/enums/common/SharedTypeEnum.java create mode 100644 src/com/engine/salary/enums/datacollection/AttendQuoteFieldSourceTypeEnum.java create mode 100644 src/com/engine/salary/enums/datacollection/AttendQuoteFieldTypeEnum.java create mode 100644 src/com/engine/salary/enums/datacollection/AttendQuoteSourceTypeEnum.java create mode 100644 src/com/engine/salary/enums/datacollection/DataCollectionEmployeeTypeEnum.java create mode 100644 src/com/engine/salary/enums/datacollection/UseEmployeeTypeEnum.java create mode 100644 src/com/engine/salary/enums/push/PushItemFieldEnum.java create mode 100644 src/com/engine/salary/enums/push/PushRecordDetailStatusEnum.java create mode 100644 src/com/engine/salary/enums/push/PushRecordStatusEnum.java create mode 100644 src/com/engine/salary/enums/push/PushRecordTypeEnum.java create mode 100644 src/com/engine/salary/enums/salaryaccounting/EmployeeTypeEnum.java create mode 100644 src/com/engine/salary/enums/salaryaccounting/LockStatusEnum.java create mode 100644 src/com/engine/salary/enums/salaryaccounting/SalaryAcctRecordStatusEnum.java create mode 100644 src/com/engine/salary/enums/salaryaccounting/SalaryAcctResultDataSourceEnum.java create mode 100644 src/com/engine/salary/enums/salaryarchive/ArchiveStatusEnum.java create mode 100644 src/com/engine/salary/enums/salaryarchive/IndividualTaxWithholdingAgentStatusEnum.java create mode 100644 src/com/engine/salary/enums/salaryarchive/SalaryArchiveAddTypeEnum.java create mode 100644 src/com/engine/salary/enums/salaryarchive/SalaryArchiveAdjustRecordTypeEnum.java create mode 100644 src/com/engine/salary/enums/salaryarchive/SalaryArchiveAdjustWayEnum.java create mode 100644 src/com/engine/salary/enums/salaryarchive/SalaryArchiveDimissionTimeIntervalEnum.java create mode 100644 src/com/engine/salary/enums/salaryarchive/SalaryArchiveFieldTypeEnum.java create mode 100644 src/com/engine/salary/enums/salaryarchive/SalaryArchiveImportTypeEnum.java create mode 100644 src/com/engine/salary/enums/salaryarchive/SalaryArchiveItemAdjustReasonEnum.java create mode 100644 src/com/engine/salary/enums/salaryarchive/SalaryArchiveListTypeEnum.java create mode 100644 src/com/engine/salary/enums/salaryarchive/SalaryArchiveStatusEnum.java create mode 100644 src/com/engine/salary/enums/salaryarchive/SalaryArchiveTaxAgentAdjustReasonEnum.java create mode 100644 src/com/engine/salary/enums/salarybill/BillConfimStatusEnum.java create mode 100644 src/com/engine/salary/enums/salarybill/BillReadStatusEnum.java create mode 100644 src/com/engine/salary/enums/salarybill/MessageChannelEnum.java create mode 100644 src/com/engine/salary/enums/salarybill/MonthTypeEnum.java create mode 100644 src/com/engine/salary/enums/salarybill/SalarySendStatusEnum.java create mode 100644 src/com/engine/salary/enums/salarybill/SalaryTemplateReplenishRuleEnum.java create mode 100644 src/com/engine/salary/enums/salarybill/SalaryTemplateTextContentPositionEnum.java create mode 100644 src/com/engine/salary/enums/salarybill/SalaryTemplateVarEnum.java create mode 100644 src/com/engine/salary/enums/salarybill/SalaryTemplateWatermarkTypeEnum.java create mode 100644 src/com/engine/salary/enums/salarybill/SalaryTemplateWhetherEnum.java create mode 100644 src/com/engine/salary/enums/salaryformula/FormulaVarFieldTypeEnum.java create mode 100644 src/com/engine/salary/enums/salaryformula/ReferenceTypeEnum.java create mode 100644 src/com/engine/salary/enums/salaryformula/ReturnTypeEnum.java create mode 100644 src/com/engine/salary/enums/salaryformula/SalaryFormulaReferenceEnum.java create mode 100644 src/com/engine/salary/enums/salaryformula/SalarySQLReferenceEnum.java create mode 100644 src/com/engine/salary/enums/salaryformula/ValidateTypeEnum.java create mode 100644 src/com/engine/salary/enums/salaryitem/SalaryDataTypeEnum.java create mode 100644 src/com/engine/salary/enums/salarysend/SalaryAutoSendCycleTypeEnum.java create mode 100644 src/com/engine/salary/enums/salarysend/SalarySendGrantTypeEnum.java create mode 100644 src/com/engine/salary/enums/salarysend/SalarySendRangeTargetTypeEnum.java create mode 100644 src/com/engine/salary/enums/salarysend/SalarySendRangeTypeEnum.java create mode 100644 src/com/engine/salary/enums/salarysob/IncomeCategoryEnum.java create mode 100644 src/com/engine/salary/enums/salarysob/SalaryEmployeeStatusEnum.java create mode 100644 src/com/engine/salary/enums/salarysob/SalarySobAdjustRuleTypeEnum.java create mode 100644 src/com/engine/salary/enums/salarysob/TargetTypeEnum.java create mode 100644 src/com/engine/salary/enums/setting/PageListSettingPageEnum.java create mode 100644 src/com/engine/salary/enums/siaccount/BillStatusEnum.java create mode 100644 src/com/engine/salary/enums/siaccount/EmployeeStatusEnum.java create mode 100644 src/com/engine/salary/enums/siaccount/InspectStatusEnum.java create mode 100644 src/com/engine/salary/enums/siaccount/PaymentStatusEnum.java create mode 100644 src/com/engine/salary/enums/siaccount/ProjectTypeEnum.java create mode 100644 src/com/engine/salary/enums/siaccount/ResourceFromEnum.java create mode 100644 src/com/engine/salary/enums/sicategory/DataTypeEnum.java create mode 100644 src/com/engine/salary/enums/sicategory/DeleteTypeEnum.java create mode 100644 src/com/engine/salary/enums/sicategory/IncludeTypeEnum.java create mode 100644 src/com/engine/salary/enums/sicategory/IsPaymentEnum.java create mode 100644 src/com/engine/salary/enums/sicategory/IsUseEnum.java create mode 100644 src/com/engine/salary/enums/sicategory/NonPaymentEnum.java create mode 100644 src/com/engine/salary/enums/sicategory/PaymentScopeEnum.java create mode 100644 src/com/engine/salary/enums/sicategory/PaymentTypeEnum.java create mode 100644 src/com/engine/salary/enums/sicategory/RententionRuleEnum.java create mode 100644 src/com/engine/salary/enums/sicategory/SharedTypeEnum.java create mode 100644 src/com/engine/salary/enums/sicategory/UndertakerEnum.java create mode 100644 src/com/engine/salary/enums/sicategory/WelfareTypeEnum.java create mode 100644 src/com/engine/salary/enums/taxagent/TaxAgentEmpChangeModuleEnum.java create mode 100644 src/com/engine/salary/enums/taxagent/TaxAgentEmpChangeTypeEnum.java create mode 100644 src/com/engine/salary/enums/taxagent/TaxAgentRangeTypeEnum.java create mode 100644 src/com/engine/salary/enums/taxagent/TaxAgentRoleTypeEnum.java create mode 100644 src/com/engine/salary/exception/ExceptionUtil.java create mode 100644 src/com/engine/salary/exception/SalaryRunTimeException.java create mode 100644 src/com/engine/salary/formlua/constant/FormluaConstant.java create mode 100644 src/com/engine/salary/formlua/core/QLExpressContext.java create mode 100644 src/com/engine/salary/formlua/core/QlExpress.java create mode 100644 src/com/engine/salary/formlua/core/QlExpressTest.java create mode 100644 src/com/engine/salary/formlua/core/exception/ErrorType.java create mode 100644 src/com/engine/salary/formlua/core/exception/ExcelRunTimeException.java create mode 100644 src/com/engine/salary/formlua/entity/parameter/DataType.java create mode 100644 src/com/engine/salary/formlua/entity/parameter/DateAndString.java create mode 100644 src/com/engine/salary/formlua/entity/parameter/ExcelFunc.java create mode 100644 src/com/engine/salary/formlua/entity/parameter/ExcelFuncs.java create mode 100644 src/com/engine/salary/formlua/entity/parameter/FormulaContext.java create mode 100644 src/com/engine/salary/formlua/entity/parameter/FuncDescUtil.java create mode 100644 src/com/engine/salary/formlua/entity/parameter/FuncNames.java create mode 100644 src/com/engine/salary/formlua/entity/parameter/IllegalList.java create mode 100644 src/com/engine/salary/formlua/entity/parameter/ParamContext.java create mode 100644 src/com/engine/salary/formlua/entity/parameter/ParamFactory.java create mode 100644 src/com/engine/salary/formlua/entity/parameter/ParamType.java create mode 100644 src/com/engine/salary/formlua/entity/parameter/ReturnType.java create mode 100644 src/com/engine/salary/formlua/entity/parameter/ThreadLocalData.java create mode 100644 src/com/engine/salary/formlua/entity/standard/AggFunc.java create mode 100644 src/com/engine/salary/formlua/entity/standard/ExcelModuleFixField.java create mode 100644 src/com/engine/salary/formlua/entity/standard/ExcelPage.java create mode 100644 src/com/engine/salary/formlua/entity/standard/ExcelResult.java create mode 100644 src/com/engine/salary/formlua/entity/standard/FormulaCategory.java create mode 100644 src/com/engine/salary/formlua/entity/standard/FormulaDataSource.java create mode 100644 src/com/engine/salary/formlua/entity/standard/FormulaFilterData.java create mode 100644 src/com/engine/salary/formlua/entity/standard/FormulaModuleCategory.java create mode 100644 src/com/engine/salary/formlua/entity/standard/execute/ExclDataType.java create mode 100644 src/com/engine/salary/formlua/entity/standard/execute/ExclFixField.java create mode 100644 src/com/engine/salary/formlua/entity/standard/execute/FixFieldType.java create mode 100644 src/com/engine/salary/formlua/func/compare/CommonOper.java create mode 100644 src/com/engine/salary/formlua/func/compare/Compareutils.java create mode 100644 src/com/engine/salary/formlua/func/compare/EqOperator.java create mode 100644 src/com/engine/salary/formlua/func/compare/GreaterEqOperator.java create mode 100644 src/com/engine/salary/formlua/func/compare/GreaterOperator.java create mode 100644 src/com/engine/salary/formlua/func/compare/InOperator.java create mode 100644 src/com/engine/salary/formlua/func/compare/LessEqOperator.java create mode 100644 src/com/engine/salary/formlua/func/compare/LessOperator.java create mode 100644 src/com/engine/salary/formlua/func/compare/NotEqueOperator.java create mode 100644 src/com/engine/salary/formlua/func/compare/OperatorInTest.java create mode 100644 src/com/engine/salary/formlua/func/compare/WOperatorAdd.java create mode 100644 src/com/engine/salary/formlua/func/compare/WOperatorDiv.java create mode 100644 src/com/engine/salary/formlua/func/compare/WOperatorMulti.java create mode 100644 src/com/engine/salary/formlua/func/compare/WOperatorReduce.java create mode 100644 src/com/engine/salary/formlua/func/date/DateTimeService.java create mode 100644 src/com/engine/salary/formlua/func/date/DateTimeServiceImpl.java create mode 100644 src/com/engine/salary/formlua/func/finance/FinanceService.java create mode 100644 src/com/engine/salary/formlua/func/finance/FinanceServiceImpl.java create mode 100644 src/com/engine/salary/formlua/func/find/FindFuncsService.java create mode 100644 src/com/engine/salary/formlua/func/find/FindFuncsServiceImpl.java create mode 100644 src/com/engine/salary/formlua/func/logic/IfOperator.java create mode 100644 src/com/engine/salary/formlua/func/logic/LogicService.java create mode 100644 src/com/engine/salary/formlua/func/logic/LogicServiceImpl.java create mode 100644 src/com/engine/salary/formlua/func/logic/LogicUtils.java create mode 100644 src/com/engine/salary/formlua/func/math/MathFuncsService.java create mode 100644 src/com/engine/salary/formlua/func/math/MathFuncsServiceImpl.java create mode 100644 src/com/engine/salary/formlua/func/string/ExtractType.java create mode 100644 src/com/engine/salary/formlua/func/string/StringFormulaService.java create mode 100644 src/com/engine/salary/formlua/func/string/StringFormulaServiceImpl.java create mode 100644 src/com/engine/salary/formlua/util/CompareUtil.java create mode 100644 src/com/engine/salary/formlua/util/DateUtil.java create mode 100644 src/com/engine/salary/formlua/util/ErrorUtil.java create mode 100644 src/com/engine/salary/formlua/util/ExcelParamUtil.java create mode 100644 src/com/engine/salary/formlua/util/ExcelResult.java create mode 100644 src/com/engine/salary/formlua/util/ExcelStandardUtil.java create mode 100644 src/com/engine/salary/formlua/util/ExpressRegularUtil.java create mode 100644 src/com/engine/salary/formlua/util/IgnoreFilter.java create mode 100644 src/com/engine/salary/formlua/util/IgnoreParamFilter.java create mode 100644 src/com/engine/salary/formlua/util/NativePlace.java create mode 100644 src/com/engine/salary/formlua/util/RegularUtil.java create mode 100644 src/com/engine/salary/formlua/util/SortUtil.java create mode 100644 src/com/engine/salary/formlua/util/standard/ExcelDataType.java create mode 100644 src/com/engine/salary/handle/LongListTypeHandler.java create mode 100644 src/com/engine/salary/handle/SalaryListTypeHandler.java create mode 100644 src/com/engine/salary/maintainer/MaintainerController.java create mode 100644 src/com/engine/salary/maintainer/datacollection/AddUpSituationManager.java create mode 100644 src/com/engine/salary/maintainer/salaryacct/SalaryAcctManager.java create mode 100644 src/com/engine/salary/maintainer/salaryacct/SalaryAcctSupplementParam.java create mode 100644 src/com/engine/salary/maintainer/salaryacct/SupAcctThread.java create mode 100644 src/com/engine/salary/maintainer/salaryarchive/SalaryArchiveManager.java create mode 100644 src/com/engine/salary/mapper/InsuranceExportMapper.java create mode 100644 src/com/engine/salary/mapper/InsuranceExportMapper.xml create mode 100644 src/com/engine/salary/mapper/SQLMapper.java create mode 100644 src/com/engine/salary/mapper/SQLMapper.xml create mode 100644 src/com/engine/salary/mapper/SysTaxRateBaseMapper.java create mode 100644 src/com/engine/salary/mapper/SysTaxRateBaseMapper.xml create mode 100644 src/com/engine/salary/mapper/SysTaxRateDetailMapper.java create mode 100644 src/com/engine/salary/mapper/SysTaxRateDetailMapper.xml create mode 100644 src/com/engine/salary/mapper/TaxRateBaseMapper.java create mode 100644 src/com/engine/salary/mapper/TaxRateBaseMapper.xml create mode 100644 src/com/engine/salary/mapper/TaxRateDetailMapper.java create mode 100644 src/com/engine/salary/mapper/TaxRateDetailMapper.xml create mode 100644 src/com/engine/salary/mapper/archive/SalaryArchiveDimissionMapper.java create mode 100644 src/com/engine/salary/mapper/archive/SalaryArchiveDimissionMapper.xml create mode 100644 src/com/engine/salary/mapper/archive/SalaryArchiveItemMapper.java create mode 100644 src/com/engine/salary/mapper/archive/SalaryArchiveItemMapper.xml create mode 100644 src/com/engine/salary/mapper/archive/SalaryArchiveMapper.java create mode 100644 src/com/engine/salary/mapper/archive/SalaryArchiveMapper.xml create mode 100644 src/com/engine/salary/mapper/archive/SalaryArchiveTaxAgentMapper.java create mode 100644 src/com/engine/salary/mapper/archive/SalaryArchiveTaxAgentMapper.xml create mode 100644 src/com/engine/salary/mapper/auth/AuthDataMapper.java create mode 100644 src/com/engine/salary/mapper/auth/AuthDataMapper.xml create mode 100644 src/com/engine/salary/mapper/auth/AuthMapper.java create mode 100644 src/com/engine/salary/mapper/auth/AuthMapper.xml create mode 100644 src/com/engine/salary/mapper/auth/AuthMemberMapper.java create mode 100644 src/com/engine/salary/mapper/auth/AuthMemberMapper.xml create mode 100644 src/com/engine/salary/mapper/auth/AuthOptMapper.java create mode 100644 src/com/engine/salary/mapper/auth/AuthOptMapper.xml create mode 100644 src/com/engine/salary/mapper/auth/AuthResourceMapper.java create mode 100644 src/com/engine/salary/mapper/auth/AuthResourceMapper.xml create mode 100644 src/com/engine/salary/mapper/auth/AuthRoleDataMapper.java create mode 100644 src/com/engine/salary/mapper/auth/AuthRoleDataMapper.xml create mode 100644 src/com/engine/salary/mapper/auth/AuthRoleEmpMapper.java create mode 100644 src/com/engine/salary/mapper/auth/AuthRoleEmpMapper.xml create mode 100644 src/com/engine/salary/mapper/auth/AuthRoleMapper.java create mode 100644 src/com/engine/salary/mapper/auth/AuthRoleMapper.xml create mode 100644 src/com/engine/salary/mapper/datacollection/AddUpDeductionMapper.java create mode 100644 src/com/engine/salary/mapper/datacollection/AddUpDeductionMapper.xml create mode 100644 src/com/engine/salary/mapper/datacollection/AddUpSituationMapper.java create mode 100644 src/com/engine/salary/mapper/datacollection/AddUpSituationMapper.xml create mode 100644 src/com/engine/salary/mapper/datacollection/AttendQuoteDataMapper.java create mode 100644 src/com/engine/salary/mapper/datacollection/AttendQuoteDataMapper.xml create mode 100644 src/com/engine/salary/mapper/datacollection/AttendQuoteDataValueMapper.java create mode 100644 src/com/engine/salary/mapper/datacollection/AttendQuoteDataValueMapper.xml create mode 100644 src/com/engine/salary/mapper/datacollection/AttendQuoteFieldMapper.java create mode 100644 src/com/engine/salary/mapper/datacollection/AttendQuoteFieldMapper.xml create mode 100644 src/com/engine/salary/mapper/datacollection/AttendQuoteMapper.java create mode 100644 src/com/engine/salary/mapper/datacollection/AttendQuoteMapper.xml create mode 100644 src/com/engine/salary/mapper/datacollection/AttendQuoteSyncSetMapper.java create mode 100644 src/com/engine/salary/mapper/datacollection/AttendQuoteSyncSetMapper.xml create mode 100644 src/com/engine/salary/mapper/datacollection/EmployMapper.java create mode 100644 src/com/engine/salary/mapper/datacollection/EmployMapper.xml create mode 100644 src/com/engine/salary/mapper/datacollection/OtherDeductionMapper.java create mode 100644 src/com/engine/salary/mapper/datacollection/OtherDeductionMapper.xml create mode 100644 src/com/engine/salary/mapper/datacollection/SpecialAddDeductionMapper.java create mode 100644 src/com/engine/salary/mapper/datacollection/SpecialAddDeductionMapper.xml create mode 100644 src/com/engine/salary/mapper/datacollection/VariableArchiveItemMapper.java create mode 100644 src/com/engine/salary/mapper/datacollection/VariableArchiveItemMapper.xml create mode 100644 src/com/engine/salary/mapper/datacollection/VariableArchiveMapper.java create mode 100644 src/com/engine/salary/mapper/datacollection/VariableArchiveMapper.xml create mode 100644 src/com/engine/salary/mapper/datacollection/VariableItemMapper.java create mode 100644 src/com/engine/salary/mapper/datacollection/VariableItemMapper.xml create mode 100644 src/com/engine/salary/mapper/extemp/ExternalEmployeeMapper.java create mode 100644 src/com/engine/salary/mapper/extemp/ExternalEmployeeMapper.xml create mode 100644 src/com/engine/salary/mapper/formula/FormulaMapper.java create mode 100644 src/com/engine/salary/mapper/formula/FormulaMapper.xml create mode 100644 src/com/engine/salary/mapper/formula/FormulaVarMapper.java create mode 100644 src/com/engine/salary/mapper/formula/FormulaVarMapper.xml create mode 100644 src/com/engine/salary/mapper/hrm/ExpandFieldSettingsMapper.java create mode 100644 src/com/engine/salary/mapper/hrm/ExpandFieldSettingsMapper.xml create mode 100644 src/com/engine/salary/mapper/hrm/HrmSnapshotMapper.java create mode 100644 src/com/engine/salary/mapper/hrm/HrmSnapshotMapper.xml create mode 100644 src/com/engine/salary/mapper/push/PushRecordDetailMapper.java create mode 100644 src/com/engine/salary/mapper/push/PushRecordDetailMapper.xml create mode 100644 src/com/engine/salary/mapper/push/PushRecordMapper.java create mode 100644 src/com/engine/salary/mapper/push/PushRecordMapper.xml create mode 100644 src/com/engine/salary/mapper/push/PushSettingItemMapper.java create mode 100644 src/com/engine/salary/mapper/push/PushSettingItemMapper.xml create mode 100644 src/com/engine/salary/mapper/push/PushSettingMapper.java create mode 100644 src/com/engine/salary/mapper/push/PushSettingMapper.xml create mode 100644 src/com/engine/salary/mapper/report/SalaryAcctResultReportMapper.java create mode 100644 src/com/engine/salary/mapper/report/SalaryAcctResultReportMapper.xml create mode 100644 src/com/engine/salary/mapper/report/SalaryStatisticsDimensionMapper.java create mode 100644 src/com/engine/salary/mapper/report/SalaryStatisticsDimensionMapper.xml create mode 100644 src/com/engine/salary/mapper/report/SalaryStatisticsEChartsSettingMapper.java create mode 100644 src/com/engine/salary/mapper/report/SalaryStatisticsEChartsSettingMapper.xml create mode 100644 src/com/engine/salary/mapper/report/SalaryStatisticsItemMapper.java create mode 100644 src/com/engine/salary/mapper/report/SalaryStatisticsItemMapper.xml create mode 100644 src/com/engine/salary/mapper/report/SalaryStatisticsPushMapper.java create mode 100644 src/com/engine/salary/mapper/report/SalaryStatisticsPushMapper.xml create mode 100644 src/com/engine/salary/mapper/report/SalaryStatisticsReportMapper.java create mode 100644 src/com/engine/salary/mapper/report/SalaryStatisticsReportMapper.xml create mode 100644 src/com/engine/salary/mapper/report/salaryStatisticsPushDetailMapper.java create mode 100644 src/com/engine/salary/mapper/report/salaryStatisticsPushDetailMapper.xml create mode 100644 src/com/engine/salary/mapper/salaryacct/ExcelAcctResultMapper.java create mode 100644 src/com/engine/salary/mapper/salaryacct/ExcelAcctResultMapper.xml create mode 100644 src/com/engine/salary/mapper/salaryacct/SalaryAcctEmployeeMapper.java create mode 100644 src/com/engine/salary/mapper/salaryacct/SalaryAcctEmployeeMapper.xml create mode 100644 src/com/engine/salary/mapper/salaryacct/SalaryAcctRecordMapper.java create mode 100644 src/com/engine/salary/mapper/salaryacct/SalaryAcctRecordMapper.xml create mode 100644 src/com/engine/salary/mapper/salaryacct/SalaryAcctResultLogMapper.java create mode 100644 src/com/engine/salary/mapper/salaryacct/SalaryAcctResultLogMapper.xml create mode 100644 src/com/engine/salary/mapper/salaryacct/SalaryAcctResultMapper.java create mode 100644 src/com/engine/salary/mapper/salaryacct/SalaryAcctResultMapper.xml create mode 100644 src/com/engine/salary/mapper/salaryacct/SalaryAcctResultTempMapper.java create mode 100644 src/com/engine/salary/mapper/salaryacct/SalaryAcctResultTempMapper.xml create mode 100644 src/com/engine/salary/mapper/salaryacct/SalaryAcctResultTemplateMapper.java create mode 100644 src/com/engine/salary/mapper/salaryacct/SalaryAcctResultTemplateMapper.xml create mode 100644 src/com/engine/salary/mapper/salaryacct/SalaryAcctSobConfigMapper.java create mode 100644 src/com/engine/salary/mapper/salaryacct/SalaryAcctSobConfigMapper.xml create mode 100644 src/com/engine/salary/mapper/salarybill/SalaryBillItemNameMapper.java create mode 100644 src/com/engine/salary/mapper/salarybill/SalaryBillItemNameMapper.xml create mode 100644 src/com/engine/salary/mapper/salarybill/SalaryBillWatermarkMapper.java create mode 100644 src/com/engine/salary/mapper/salarybill/SalaryBillWatermarkMapper.xml create mode 100644 src/com/engine/salary/mapper/salarybill/SalarySendInfoMapper.java create mode 100644 src/com/engine/salary/mapper/salarybill/SalarySendInfoMapper.xml create mode 100644 src/com/engine/salary/mapper/salarybill/SalarySendMapper.java create mode 100644 src/com/engine/salary/mapper/salarybill/SalarySendMapper.xml create mode 100644 src/com/engine/salary/mapper/salarybill/SalarySendRangeMapper.java create mode 100644 src/com/engine/salary/mapper/salarybill/SalarySendRangeMapper.xml create mode 100644 src/com/engine/salary/mapper/salarybill/SalarySendRangeObjMapper.java create mode 100644 src/com/engine/salary/mapper/salarybill/SalarySendRangeObjMapper.xml create mode 100644 src/com/engine/salary/mapper/salarybill/SalaryTemplateMapper.java create mode 100644 src/com/engine/salary/mapper/salarybill/SalaryTemplateMapper.xml create mode 100644 src/com/engine/salary/mapper/salaryitem/SalaryItemMapper.java create mode 100644 src/com/engine/salary/mapper/salaryitem/SalaryItemMapper.xml create mode 100644 src/com/engine/salary/mapper/salaryitem/SysSalaryItemMapper.java create mode 100644 src/com/engine/salary/mapper/salaryitem/SysSalaryItemMapper.xml create mode 100644 src/com/engine/salary/mapper/salarysob/SalaryApprovalRuleMapper.java create mode 100644 src/com/engine/salary/mapper/salarysob/SalaryApprovalRuleMapper.xml create mode 100644 src/com/engine/salary/mapper/salarysob/SalarySobAdjustRuleMapper.java create mode 100644 src/com/engine/salary/mapper/salarysob/SalarySobAdjustRuleMapper.xml create mode 100644 src/com/engine/salary/mapper/salarysob/SalarySobBackItemMapper.java create mode 100644 src/com/engine/salary/mapper/salarysob/SalarySobBackItemMapper.xml create mode 100644 src/com/engine/salary/mapper/salarysob/SalarySobCheckRuleMapper.java create mode 100644 src/com/engine/salary/mapper/salarysob/SalarySobCheckRuleMapper.xml create mode 100644 src/com/engine/salary/mapper/salarysob/SalarySobDefaultEmpFieldMapper.java create mode 100644 src/com/engine/salary/mapper/salarysob/SalarySobDefaultEmpFieldMapper.xml create mode 100644 src/com/engine/salary/mapper/salarysob/SalarySobDefaultItemGroupMapper.java create mode 100644 src/com/engine/salary/mapper/salarysob/SalarySobDefaultItemGroupMapper.xml create mode 100644 src/com/engine/salary/mapper/salarysob/SalarySobDefaultItemMapper.java create mode 100644 src/com/engine/salary/mapper/salarysob/SalarySobDefaultItemMapper.xml create mode 100644 src/com/engine/salary/mapper/salarysob/SalarySobEmpFieldMapper.java create mode 100644 src/com/engine/salary/mapper/salarysob/SalarySobEmpFieldMapper.xml create mode 100644 src/com/engine/salary/mapper/salarysob/SalarySobExtRangeMapper.java create mode 100644 src/com/engine/salary/mapper/salarysob/SalarySobExtRangeMapper.xml create mode 100644 src/com/engine/salary/mapper/salarysob/SalarySobItemGroupMapper.java create mode 100644 src/com/engine/salary/mapper/salarysob/SalarySobItemGroupMapper.xml create mode 100644 src/com/engine/salary/mapper/salarysob/SalarySobItemHideMapper.java create mode 100644 src/com/engine/salary/mapper/salarysob/SalarySobItemHideMapper.xml create mode 100644 src/com/engine/salary/mapper/salarysob/SalarySobItemMapper.java create mode 100644 src/com/engine/salary/mapper/salarysob/SalarySobItemMapper.xml create mode 100644 src/com/engine/salary/mapper/salarysob/SalarySobMapper.java create mode 100644 src/com/engine/salary/mapper/salarysob/SalarySobMapper.xml create mode 100644 src/com/engine/salary/mapper/salarysob/SalarySobRangeMapper.java create mode 100644 src/com/engine/salary/mapper/salarysob/SalarySobRangeMapper.xml create mode 100644 src/com/engine/salary/mapper/salarysob/SobTaxLinkMapper.java create mode 100644 src/com/engine/salary/mapper/salarysob/SobTaxLinkMapper.xml create mode 100644 src/com/engine/salary/mapper/setting/PageLinkMapper.java create mode 100644 src/com/engine/salary/mapper/setting/PageLinkMapper.xml create mode 100644 src/com/engine/salary/mapper/setting/PageListSettingMapper.java create mode 100644 src/com/engine/salary/mapper/setting/PageListSettingMapper.xml create mode 100644 src/com/engine/salary/mapper/setting/PageListTemplateMapper.java create mode 100644 src/com/engine/salary/mapper/setting/PageListTemplateMapper.xml create mode 100644 src/com/engine/salary/mapper/siaccount/ExcelInsuranceDetailMapper.java create mode 100644 src/com/engine/salary/mapper/siaccount/ExcelInsuranceDetailMapper.xml create mode 100644 src/com/engine/salary/mapper/siaccount/InsuranceAccountBatchMapper.java create mode 100644 src/com/engine/salary/mapper/siaccount/InsuranceAccountBatchMapper.xml create mode 100644 src/com/engine/salary/mapper/siaccount/InsuranceAccountDetailMapper.java create mode 100644 src/com/engine/salary/mapper/siaccount/InsuranceAccountDetailMapper.xml create mode 100644 src/com/engine/salary/mapper/siaccount/InsuranceAccountInspectMapper.java create mode 100644 src/com/engine/salary/mapper/siaccount/InsuranceAccountInspectMapper.xml create mode 100644 src/com/engine/salary/mapper/siaccount/InsuranceCompensationConfigMapper.java create mode 100644 src/com/engine/salary/mapper/siaccount/InsuranceCompensationConfigMapper.xml create mode 100644 src/com/engine/salary/mapper/siaccount/InsuranceCompensationMapper.java create mode 100644 src/com/engine/salary/mapper/siaccount/InsuranceCompensationMapper.xml create mode 100644 src/com/engine/salary/mapper/siaccount/SIAccountDetailMapper.java create mode 100644 src/com/engine/salary/mapper/siaccount/SIAccountDetailMapper.xml create mode 100644 src/com/engine/salary/mapper/siaccount/SIAccountDetailTempMapper.java create mode 100644 src/com/engine/salary/mapper/siaccount/SIAccountDetailTempMapper.xml create mode 100644 src/com/engine/salary/mapper/siaccount/SIAccountUtilMapper.java create mode 100644 src/com/engine/salary/mapper/siaccount/SIAccountUtilMapper.xml create mode 100644 src/com/engine/salary/mapper/siarchives/FundSchemeMapper.java create mode 100644 src/com/engine/salary/mapper/siarchives/FundSchemeMapper.xml create mode 100644 src/com/engine/salary/mapper/siarchives/InsuranceBaseAdjustHistoryMapper.java create mode 100644 src/com/engine/salary/mapper/siarchives/InsuranceBaseAdjustHistoryMapper.xml create mode 100644 src/com/engine/salary/mapper/siarchives/InsuranceBaseInfoMapper.java create mode 100644 src/com/engine/salary/mapper/siarchives/InsuranceBaseInfoMapper.xml create mode 100644 src/com/engine/salary/mapper/siarchives/OtherSchemeMapper.java create mode 100644 src/com/engine/salary/mapper/siarchives/OtherSchemeMapper.xml create mode 100644 src/com/engine/salary/mapper/siarchives/SocialSchemeMapper.java create mode 100644 src/com/engine/salary/mapper/siarchives/SocialSchemeMapper.xml create mode 100644 src/com/engine/salary/mapper/sicategory/ICategoryMapper.java create mode 100644 src/com/engine/salary/mapper/sicategory/ICategoryMapper.xml create mode 100644 src/com/engine/salary/mapper/sischeme/InsuranceSchemeDetailMapper.java create mode 100644 src/com/engine/salary/mapper/sischeme/InsuranceSchemeDetailMapper.xml create mode 100644 src/com/engine/salary/mapper/sischeme/InsuranceSchemeMapper.java create mode 100644 src/com/engine/salary/mapper/sischeme/InsuranceSchemeMapper.xml create mode 100644 src/com/engine/salary/mapper/sys/SalarySysConfMapper.java create mode 100644 src/com/engine/salary/mapper/sys/SalarySysConfMapper.xml create mode 100644 src/com/engine/salary/mapper/taxagent/TaxAgentAdminMapper.java create mode 100644 src/com/engine/salary/mapper/taxagent/TaxAgentAdminMapper.xml create mode 100644 src/com/engine/salary/mapper/taxagent/TaxAgentBaseMapper.java create mode 100644 src/com/engine/salary/mapper/taxagent/TaxAgentBaseMapper.xml create mode 100644 src/com/engine/salary/mapper/taxagent/TaxAgentEmpChangeMapper.java create mode 100644 src/com/engine/salary/mapper/taxagent/TaxAgentEmpChangeMapper.xml create mode 100644 src/com/engine/salary/mapper/taxagent/TaxAgentEmpMapper.java create mode 100644 src/com/engine/salary/mapper/taxagent/TaxAgentEmpMapper.xml create mode 100644 src/com/engine/salary/mapper/taxagent/TaxAgentExtRangeMapper.java create mode 100644 src/com/engine/salary/mapper/taxagent/TaxAgentExtRangeMapper.xml create mode 100644 src/com/engine/salary/mapper/taxagent/TaxAgentManageRangeMapper.java create mode 100644 src/com/engine/salary/mapper/taxagent/TaxAgentManageRangeMapper.xml create mode 100644 src/com/engine/salary/mapper/taxagent/TaxAgentMapper.java create mode 100644 src/com/engine/salary/mapper/taxagent/TaxAgentMapper.xml create mode 100644 src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationDetailMapper.java create mode 100644 src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationDetailMapper.xml create mode 100644 src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationMapper.java create mode 100644 src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationMapper.xml create mode 100644 src/com/engine/salary/process/salaryArchive/SalaryArchiveActionAPI.java create mode 100644 src/com/engine/salary/process/salaryArchive/SalaryArchiveInfo.java create mode 100644 src/com/engine/salary/process/salaryArchive/SalaryArchiveProcessQueryParam.java create mode 100644 src/com/engine/salary/process/siArchives/SIArchiveActionAPI.java create mode 100644 src/com/engine/salary/remote/attend/cmd/GetKQReportCmd.java create mode 100644 src/com/engine/salary/remote/attend/cmd/GetSearchListCmd.java create mode 100644 src/com/engine/salary/remote/attend/entity/Attend4Salary.java create mode 100644 src/com/engine/salary/remote/attend/service/RemoteAttend4SalaryService.java create mode 100644 src/com/engine/salary/remote/attend/service/impl/RemoteAttend4SalaryServiceImpl.java create mode 100644 src/com/engine/salary/remote/mode/cmd/GetModeList.java create mode 100644 src/com/engine/salary/report/common/constant/DbCrudConstant.java create mode 100644 src/com/engine/salary/report/common/constant/SalaryConstant.java create mode 100644 src/com/engine/salary/report/common/constant/SalaryReportModule.java create mode 100644 src/com/engine/salary/report/common/constant/SalaryStatisticsDimensionConstant.java create mode 100644 src/com/engine/salary/report/entity/bo/SalaryStatisticsEmployeeBO.java create mode 100644 src/com/engine/salary/report/entity/bo/SalaryStatisticsReportBO.java create mode 100644 src/com/engine/salary/report/entity/dto/SalaryReportCacheInfo.java create mode 100644 src/com/engine/salary/report/entity/dto/SalaryStatisticsDimensionFormDTO.java create mode 100644 src/com/engine/salary/report/entity/dto/SalaryStatisticsDimensionListDTO.java create mode 100644 src/com/engine/salary/report/entity/dto/SalaryStatisticsEchartsDTO.java create mode 100644 src/com/engine/salary/report/entity/dto/SalaryStatisticsEmployeeDetailResultDTO.java create mode 100644 src/com/engine/salary/report/entity/dto/SalaryStatisticsEmployeeListDTO.java create mode 100644 src/com/engine/salary/report/entity/dto/SalaryStatisticsItemFormDTO.java create mode 100644 src/com/engine/salary/report/entity/dto/SalaryStatisticsItemRuleDTO.java create mode 100644 src/com/engine/salary/report/entity/dto/SalaryStatisticsItemStringRuleDTO.java create mode 100644 src/com/engine/salary/report/entity/dto/SalaryStatisticsPushDetail.java create mode 100644 src/com/engine/salary/report/entity/dto/SalaryStatisticsPushDetailFormDTO.java create mode 100644 src/com/engine/salary/report/entity/dto/SalaryStatisticsPushDetailTableDTO.java create mode 100644 src/com/engine/salary/report/entity/dto/SalaryStatisticsPushTableDTO.java create mode 100644 src/com/engine/salary/report/entity/dto/SalaryStatisticsReportDataDTO.java create mode 100644 src/com/engine/salary/report/entity/dto/SalaryStatisticsReportFormDTO.java create mode 100644 src/com/engine/salary/report/entity/dto/SubEmployeeTableDTO.java create mode 100644 src/com/engine/salary/report/entity/dto/SubTableChartsDTO.java create mode 100644 src/com/engine/salary/report/entity/dto/TaxAgentViewDTO.java create mode 100644 src/com/engine/salary/report/entity/param/ExportColumn.java create mode 100644 src/com/engine/salary/report/entity/param/ExportCommonParam.java create mode 100644 src/com/engine/salary/report/entity/param/SalaryAcctEmployeeQueryParam.java create mode 100644 src/com/engine/salary/report/entity/param/SalaryEmployeeQueryParam.java create mode 100644 src/com/engine/salary/report/entity/param/SalaryStatisticsDataPerspectiveQueryParam.java create mode 100644 src/com/engine/salary/report/entity/param/SalaryStatisticsDimensionQueryParam.java create mode 100644 src/com/engine/salary/report/entity/param/SalaryStatisticsDimensionSaveParam.java create mode 100644 src/com/engine/salary/report/entity/param/SalaryStatisticsEmployeeDetailQueryParam.java create mode 100644 src/com/engine/salary/report/entity/param/SalaryStatisticsEmployeeQueryParam.java create mode 100644 src/com/engine/salary/report/entity/param/SalaryStatisticsEmployeeSalaryQueryParam.java create mode 100644 src/com/engine/salary/report/entity/param/SalaryStatisticsItemGetFormParam.java create mode 100644 src/com/engine/salary/report/entity/param/SalaryStatisticsItemSaveParam.java create mode 100644 src/com/engine/salary/report/entity/param/SalaryStatisticsPushDetailParam.java create mode 100644 src/com/engine/salary/report/entity/param/SalaryStatisticsPushParam.java create mode 100644 src/com/engine/salary/report/entity/param/SalaryStatisticsReportDataQueryParam.java create mode 100644 src/com/engine/salary/report/entity/param/SalaryStatisticsReportQueryParam.java create mode 100644 src/com/engine/salary/report/entity/param/SalaryStatisticsReportSaveParam.java create mode 100644 src/com/engine/salary/report/entity/param/SalaryStatisticsSearchConditionSaveParam.java create mode 100644 src/com/engine/salary/report/entity/param/SubTableDataQueryParam.java create mode 100644 src/com/engine/salary/report/entity/param/SubTableItemParam.java create mode 100644 src/com/engine/salary/report/entity/param/SubTableParam.java create mode 100644 src/com/engine/salary/report/entity/param/SubTableSearchConditionParam.java create mode 100644 src/com/engine/salary/report/entity/param/TaxAgentQueryParam.java create mode 100644 src/com/engine/salary/report/entity/po/SalaryStatisticsDimensionPO.java create mode 100644 src/com/engine/salary/report/entity/po/SalaryStatisticsEChartsSettingPO.java create mode 100644 src/com/engine/salary/report/entity/po/SalaryStatisticsItemPO.java create mode 100644 src/com/engine/salary/report/entity/po/SalaryStatisticsPushDetailPO.java create mode 100644 src/com/engine/salary/report/entity/po/SalaryStatisticsPushPO.java create mode 100644 src/com/engine/salary/report/entity/po/SalaryStatisticsReportPO.java create mode 100644 src/com/engine/salary/report/entity/po/SubTableItemPO.java create mode 100644 src/com/engine/salary/report/enums/DataTypeEnum.java create mode 100644 src/com/engine/salary/report/enums/DimensionEnum.java create mode 100644 src/com/engine/salary/report/enums/EmployeeTypeEnum.java create mode 100644 src/com/engine/salary/report/enums/ExtEmployeeTypeEnum.java create mode 100644 src/com/engine/salary/report/enums/IncomeCategoryEnum.java create mode 100644 src/com/engine/salary/report/enums/OperateTypeEnum.java create mode 100644 src/com/engine/salary/report/enums/PaymentScopeEnum.java create mode 100644 src/com/engine/salary/report/enums/PaymentStatusEnum.java create mode 100644 src/com/engine/salary/report/enums/SalaryDataTypeEnum.java create mode 100644 src/com/engine/salary/report/enums/SalaryStatisticsDimensionTypeEnum.java create mode 100644 src/com/engine/salary/report/enums/SalaryStatisticsItemStringRuleEnum.java create mode 100644 src/com/engine/salary/report/enums/SalarySystemTypeEnum.java create mode 100644 src/com/engine/salary/report/enums/TableTypeEnum.java create mode 100644 src/com/engine/salary/report/enums/TaxAgentPermissionConstant.java create mode 100644 src/com/engine/salary/report/enums/TaxAgentRoleTypeEnum.java create mode 100644 src/com/engine/salary/report/enums/UnitTypeEnum.java create mode 100644 src/com/engine/salary/report/enums/WeaBrowserTypeEnum.java create mode 100644 src/com/engine/salary/report/service/SalaryStatisticsDimensionService.java create mode 100644 src/com/engine/salary/report/service/SalaryStatisticsEchartsService.java create mode 100644 src/com/engine/salary/report/service/SalaryStatisticsEmployeeService.java create mode 100644 src/com/engine/salary/report/service/SalaryStatisticsItemService.java create mode 100644 src/com/engine/salary/report/service/SalaryStatisticsPushDetailService.java create mode 100644 src/com/engine/salary/report/service/SalaryStatisticsPushService.java create mode 100644 src/com/engine/salary/report/service/SalaryStatisticsReportService.java create mode 100644 src/com/engine/salary/report/service/SubTableExportService.java create mode 100644 src/com/engine/salary/report/service/impl/SalaryStatisticsDimensionServiceImpl.java create mode 100644 src/com/engine/salary/report/service/impl/SalaryStatisticsEchartsServiceImpl.java create mode 100644 src/com/engine/salary/report/service/impl/SalaryStatisticsEmployeeServiceImpl.java create mode 100644 src/com/engine/salary/report/service/impl/SalaryStatisticsItemServiceImpl.java create mode 100644 src/com/engine/salary/report/service/impl/SalaryStatisticsPushDetailServiceImpl.java create mode 100644 src/com/engine/salary/report/service/impl/SalaryStatisticsPushServiceImpl.java create mode 100644 src/com/engine/salary/report/service/impl/SalaryStatisticsReportServiceImpl.java create mode 100644 src/com/engine/salary/report/service/impl/SubTableExportServiceImpl.java create mode 100644 src/com/engine/salary/report/util/ReportDataUtil.java create mode 100644 src/com/engine/salary/report/util/ReportEnumUtil.java create mode 100644 src/com/engine/salary/report/util/ReportTimeUtil.java create mode 100644 src/com/engine/salary/report/web/SalaryStatisticsDimensionController.java create mode 100644 src/com/engine/salary/report/web/SalaryStatisticsEchartsController.java create mode 100644 src/com/engine/salary/report/web/SalaryStatisticsEmployeeController.java create mode 100644 src/com/engine/salary/report/web/SalaryStatisticsItemController.java create mode 100644 src/com/engine/salary/report/web/SalaryStatisticsPushController.java create mode 100644 src/com/engine/salary/report/web/SalaryStatisticsReportController.java create mode 100644 src/com/engine/salary/report/wrapper/SalaryStatisticsDimensionWrapper.java create mode 100644 src/com/engine/salary/report/wrapper/SalaryStatisticsEchartsWrapper.java create mode 100644 src/com/engine/salary/report/wrapper/SalaryStatisticsEmployeeWrapper.java create mode 100644 src/com/engine/salary/report/wrapper/SalaryStatisticsItemWrapper.java create mode 100644 src/com/engine/salary/report/wrapper/SalaryStatisticsReportWrapper.java create mode 100644 src/com/engine/salary/service/AddUpDeductionService.java create mode 100644 src/com/engine/salary/service/AddUpSituationService.java create mode 100644 src/com/engine/salary/service/AttendQuoteDataService.java create mode 100644 src/com/engine/salary/service/AttendQuoteFieldService.java create mode 100644 src/com/engine/salary/service/AttendQuoteFieldSettingService.java create mode 100644 src/com/engine/salary/service/AttendQuoteService.java create mode 100644 src/com/engine/salary/service/AttendService.java create mode 100644 src/com/engine/salary/service/ColumnBuildService.java create mode 100644 src/com/engine/salary/service/ExtEmpService.java create mode 100644 src/com/engine/salary/service/FormulaRunService.java create mode 100644 src/com/engine/salary/service/MySalaryShowSetService.java create mode 100644 src/com/engine/salary/service/OtherDeductionService.java create mode 100644 src/com/engine/salary/service/ProgressService.java create mode 100644 src/com/engine/salary/service/PushService.java create mode 100644 src/com/engine/salary/service/RecordsBuildService.java create mode 100644 src/com/engine/salary/service/RemoteExcelService.java create mode 100644 src/com/engine/salary/service/SIAComparisonResultService.java create mode 100644 src/com/engine/salary/service/SIAccountService.java create mode 100644 src/com/engine/salary/service/SIArchivesService.java create mode 100644 src/com/engine/salary/service/SIBalanceService.java create mode 100644 src/com/engine/salary/service/SICategoryService.java create mode 100644 src/com/engine/salary/service/SICompensationService.java create mode 100644 src/com/engine/salary/service/SIExportService.java create mode 100644 src/com/engine/salary/service/SIImportService.java create mode 100644 src/com/engine/salary/service/SIRecessionService.java create mode 100644 src/com/engine/salary/service/SIRepairService.java create mode 100644 src/com/engine/salary/service/SIReportService.java create mode 100644 src/com/engine/salary/service/SISchemeService.java create mode 100644 src/com/engine/salary/service/SalaryAcctCalculateService.java create mode 100644 src/com/engine/salary/service/SalaryAcctEmployeeService.java create mode 100644 src/com/engine/salary/service/SalaryAcctExcelService.java create mode 100644 src/com/engine/salary/service/SalaryAcctRecordService.java create mode 100644 src/com/engine/salary/service/SalaryAcctReportService.java create mode 100644 src/com/engine/salary/service/SalaryAcctResultLogService.java create mode 100644 src/com/engine/salary/service/SalaryAcctResultService.java create mode 100644 src/com/engine/salary/service/SalaryAcctResultTempService.java create mode 100644 src/com/engine/salary/service/SalaryAcctResultTemplateService.java create mode 100644 src/com/engine/salary/service/SalaryAcctSobConfigService.java create mode 100644 src/com/engine/salary/service/SalaryApprovalRuleService.java create mode 100644 src/com/engine/salary/service/SalaryArchiveExcelService.java create mode 100644 src/com/engine/salary/service/SalaryArchiveItemService.java create mode 100644 src/com/engine/salary/service/SalaryArchiveService.java create mode 100644 src/com/engine/salary/service/SalaryArchiveTaxAgentService.java create mode 100644 src/com/engine/salary/service/SalaryBillBaseSetService.java create mode 100644 src/com/engine/salary/service/SalaryBillItemNameService.java create mode 100644 src/com/engine/salary/service/SalaryBillService.java create mode 100644 src/com/engine/salary/service/SalaryBillWatermarkService.java create mode 100644 src/com/engine/salary/service/SalaryCacheService.java create mode 100644 src/com/engine/salary/service/SalaryCheckResultDetailService.java create mode 100644 src/com/engine/salary/service/SalaryCheckResultService.java create mode 100644 src/com/engine/salary/service/SalaryComparisonResultService.java create mode 100644 src/com/engine/salary/service/SalaryEmployeeService.java create mode 100644 src/com/engine/salary/service/SalaryFormulaService.java create mode 100644 src/com/engine/salary/service/SalaryItemService.java create mode 100644 src/com/engine/salary/service/SalarySQLService.java create mode 100644 src/com/engine/salary/service/SalarySendRangeObjService.java create mode 100644 src/com/engine/salary/service/SalarySendRangeService.java create mode 100644 src/com/engine/salary/service/SalarySendService.java create mode 100644 src/com/engine/salary/service/SalarySobAdjustRuleService.java create mode 100644 src/com/engine/salary/service/SalarySobBackItemService.java create mode 100644 src/com/engine/salary/service/SalarySobCheckRuleService.java create mode 100644 src/com/engine/salary/service/SalarySobDefaultEmpFieldService.java create mode 100644 src/com/engine/salary/service/SalarySobDefaultItemService.java create mode 100644 src/com/engine/salary/service/SalarySobEmpFieldService.java create mode 100644 src/com/engine/salary/service/SalarySobExtRangeService.java create mode 100644 src/com/engine/salary/service/SalarySobItemGroupService.java create mode 100644 src/com/engine/salary/service/SalarySobItemHideService.java create mode 100644 src/com/engine/salary/service/SalarySobItemService.java create mode 100644 src/com/engine/salary/service/SalarySobRangeService.java create mode 100644 src/com/engine/salary/service/SalarySobService.java create mode 100644 src/com/engine/salary/service/SalaryTemplateService.java create mode 100644 src/com/engine/salary/service/SettingService.java create mode 100644 src/com/engine/salary/service/SpecialAddDeductionService.java create mode 100644 src/com/engine/salary/service/SysSalaryItemService.java create mode 100644 src/com/engine/salary/service/TaxAgentAdminService.java create mode 100644 src/com/engine/salary/service/TaxAgentBaseService.java create mode 100644 src/com/engine/salary/service/TaxAgentEmpChangeService.java create mode 100644 src/com/engine/salary/service/TaxAgentEmpService.java create mode 100644 src/com/engine/salary/service/TaxAgentExcelService.java create mode 100644 src/com/engine/salary/service/TaxAgentManageRangeService.java create mode 100644 src/com/engine/salary/service/TaxAgentService.java create mode 100644 src/com/engine/salary/service/TaxAgentSubAdminEmpService.java create mode 100644 src/com/engine/salary/service/TaxAgentSubAdminService.java create mode 100644 src/com/engine/salary/service/TaxDeclarationDetailService.java create mode 100644 src/com/engine/salary/service/TaxDeclarationExcelService.java create mode 100644 src/com/engine/salary/service/TaxDeclarationService.java create mode 100644 src/com/engine/salary/service/TaxRateBaseService.java create mode 100644 src/com/engine/salary/service/TaxRateDetailService.java create mode 100644 src/com/engine/salary/service/VariableArchiveItemService.java create mode 100644 src/com/engine/salary/service/VariableArchiveService.java create mode 100644 src/com/engine/salary/service/VariableItemService.java create mode 100644 src/com/engine/salary/service/auth/AuthDataService.java create mode 100644 src/com/engine/salary/service/auth/AuthDataServiceImpl.java create mode 100644 src/com/engine/salary/service/auth/AuthMemberService.java create mode 100644 src/com/engine/salary/service/auth/AuthMemberServiceImpl.java create mode 100644 src/com/engine/salary/service/auth/AuthOptService.java create mode 100644 src/com/engine/salary/service/auth/AuthOptServiceImpl.java create mode 100644 src/com/engine/salary/service/auth/AuthRoleService.java create mode 100644 src/com/engine/salary/service/auth/AuthRoleServiceImpl.java create mode 100644 src/com/engine/salary/service/auth/AuthService.java create mode 100644 src/com/engine/salary/service/auth/AuthServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/AddUpDeductionServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/AddUpSituationServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/AttendQuoteDataServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/AttendQuoteFieldServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/AttendQuoteFieldSettingServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/AttendQuoteServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/ColumnBuildServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/ExtEmpServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/FormulaRunServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/MySalaryShowSetServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/OtherDeductionServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/ProgressServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/PushServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/RecordsBuildServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/RemoteExcelServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/SIAComparisonResultServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/SIAccountServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/SIArchivesServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/SIBalanceServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/SICategoryServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/SICompensationServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/SIExportServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/SIImportServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/SIRecessionServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/SIRepairServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/SIReportServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/SISchemeServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/SalaryAcctCalcServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/SalaryAcctCalculateServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/SalaryAcctEmployeeServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/SalaryAcctExcelServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/SalaryAcctRecordServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/SalaryAcctReportServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/SalaryAcctResultLogServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/SalaryAcctResultServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/SalaryAcctResultTempServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/SalaryAcctResultTemplateServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/SalaryAcctSobConfigServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/SalaryApprovalRuleServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/SalaryArchiveExcelServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/SalaryArchiveItemServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/SalaryArchiveServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/SalaryArchiveTaxAgentServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/SalaryBillBaseSetServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/SalaryBillItemNameServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/SalaryBillServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/SalaryBillWatermarkServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/SalaryCacheServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/SalaryComparisonResultServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/SalaryEmployeeServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/SalaryFormulaServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/SalaryItemServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/SalarySendRangeObjServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/SalarySendRangeServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/SalarySendServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/SalarySobAdjustRuleServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/SalarySobBackItemServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/SalarySobCheckRuleServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/SalarySobDefaultEmpFieldServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/SalarySobDefaultItemServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/SalarySobEmpFieldServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/SalarySobExtRangeServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/SalarySobItemGroupServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/SalarySobItemHideServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/SalarySobItemServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/SalarySobRangeServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/SalarySobServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/SalaryTemplateServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/SettingServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/SpecialAddDeductionServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/SysSalaryItemServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/TaxAgentAdminServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/TaxAgentBaseServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/TaxAgentEmpChangeServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/TaxAgentEmpServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/TaxAgentExcelServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/TaxAgentManageRangeServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/TaxAgentServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/TaxDeclarationDetailServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/TaxDeclarationExcelServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/TaxDeclarationServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/TaxRateBaseServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/TaxRateDetailServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/VariableArchiveItemServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/VariableArchiveServiceImpl.java create mode 100644 src/com/engine/salary/service/impl/VariableItemServiceImpl.java create mode 100644 src/com/engine/salary/sys/config/SysConfig.java create mode 100644 src/com/engine/salary/sys/constant/SalarySysConstant.java create mode 100644 src/com/engine/salary/sys/entity/param/AppSettingSaveParam.java create mode 100644 src/com/engine/salary/sys/entity/param/MatchEmployeeModeSaveParam.java create mode 100644 src/com/engine/salary/sys/entity/param/OrderRuleParam.java create mode 100644 src/com/engine/salary/sys/entity/param/SalarySysConfQueryParam.java create mode 100644 src/com/engine/salary/sys/entity/param/UploadConfigParam.java create mode 100644 src/com/engine/salary/sys/entity/po/SalarySysConfPO.java create mode 100644 src/com/engine/salary/sys/entity/vo/AppSettingVO.java create mode 100644 src/com/engine/salary/sys/entity/vo/OrderRuleVO.java create mode 100644 src/com/engine/salary/sys/entity/vo/UploadConfigResponse.java create mode 100644 src/com/engine/salary/sys/enums/AscOrDescEnum.java create mode 100644 src/com/engine/salary/sys/enums/MatchEmployeeModeEnum.java create mode 100644 src/com/engine/salary/sys/enums/OpenEnum.java create mode 100644 src/com/engine/salary/sys/enums/OrderRuleEnum.java create mode 100644 src/com/engine/salary/sys/enums/PayrollCheckTypeEnum.java create mode 100644 src/com/engine/salary/sys/enums/SalaryAcctEmployeeRuleEnum.java create mode 100644 src/com/engine/salary/sys/enums/ShotTimeTypeEnum.java create mode 100644 src/com/engine/salary/sys/enums/TaxDeclarationFunctionEnum.java create mode 100644 src/com/engine/salary/sys/service/SalarySysConfService.java create mode 100644 src/com/engine/salary/sys/service/impl/SalarySysConfServiceImpl.java create mode 100644 src/com/engine/salary/timer/AutoAddAllSpecialAddDeductionJob.java create mode 100644 src/com/engine/salary/timer/AutoConfirmSalaryBillCronJob.java create mode 100644 src/com/engine/salary/timer/AutoSendSalaryJob.java create mode 100644 src/com/engine/salary/timer/AutoSiAccountAndFileJob.java create mode 100644 src/com/engine/salary/timer/AutoSyncAttendQuoteJob.java create mode 100644 src/com/engine/salary/timer/AutoSyncEmpArchiveStartDateJob.java create mode 100644 src/com/engine/salary/timer/AutoSyncResignationEmpArchiveJob.java create mode 100644 src/com/engine/salary/timer/HrmSnapshotJob.java create mode 100644 src/com/engine/salary/timer/SyncTaxAgentEmp2SobEmpJob.java create mode 100644 src/com/engine/salary/timer/SyncTaxAgentEmpJob.java create mode 100644 src/com/engine/salary/transmethod/EncryptTransMethod.java create mode 100644 src/com/engine/salary/transmethod/ICategoryTransMethod.java create mode 100644 src/com/engine/salary/transmethod/SISchemeTransMethod.java create mode 100644 src/com/engine/salary/transmethod/TaxRateTransMethod.java create mode 100644 src/com/engine/salary/transmethod/TransMethod.java create mode 100644 src/com/engine/salary/util/DataUtil.java create mode 100644 src/com/engine/salary/util/EnumUtil.java create mode 100644 src/com/engine/salary/util/FileUtils.java create mode 100644 src/com/engine/salary/util/JsonUtil.java create mode 100644 src/com/engine/salary/util/ResponseResult.java create mode 100644 src/com/engine/salary/util/SalaryAssert.java create mode 100644 src/com/engine/salary/util/SalaryDateUtil.java create mode 100644 src/com/engine/salary/util/SalaryEntityUtil.java create mode 100644 src/com/engine/salary/util/SalaryEnumUtil.java create mode 100644 src/com/engine/salary/util/SalaryFormItemUtil.java create mode 100644 src/com/engine/salary/util/SalaryI18nUtil.java create mode 100644 src/com/engine/salary/util/SalaryLoggerUtil.java create mode 100644 src/com/engine/salary/util/SalarySobUtil.java create mode 100644 src/com/engine/salary/util/SalaryThreadPoolUtil.java create mode 100644 src/com/engine/salary/util/SalaryTokenUtil.java create mode 100644 src/com/engine/salary/util/aes/AESUtils.java create mode 100644 src/com/engine/salary/util/db/DBOperateAdapter.java create mode 100644 src/com/engine/salary/util/db/DBType.java create mode 100644 src/com/engine/salary/util/db/IdGenerator.java create mode 100644 src/com/engine/salary/util/db/MapperProxyFactory.java create mode 100644 src/com/engine/salary/util/excel/BooleanEnum.java create mode 100644 src/com/engine/salary/util/excel/ExcelComment.java create mode 100644 src/com/engine/salary/util/excel/ExcelFillUtils.java create mode 100644 src/com/engine/salary/util/excel/ExcelParseException.java create mode 100644 src/com/engine/salary/util/excel/ExcelParseHelper.java create mode 100644 src/com/engine/salary/util/excel/ExcelPreviewDTO.java create mode 100644 src/com/engine/salary/util/excel/ExcelProperty.java create mode 100644 src/com/engine/salary/util/excel/ExcelSupport.java create mode 100644 src/com/engine/salary/util/excel/ExcelUtil.java create mode 100644 src/com/engine/salary/util/excel/ExcelUtilPlus.java create mode 100644 src/com/engine/salary/util/excel/ImportExcelResponse.java create mode 100644 src/com/engine/salary/util/page/Column.java create mode 100644 src/com/engine/salary/util/page/DataSource.java create mode 100644 src/com/engine/salary/util/page/PageInfo.java create mode 100644 src/com/engine/salary/util/page/SalaryPageUtil.java create mode 100644 src/com/engine/salary/util/pdf/HtmlToPdf.java create mode 100644 src/com/engine/salary/util/report/SalaryReportUtil.java create mode 100644 src/com/engine/salary/util/valid/Compare.java create mode 100644 src/com/engine/salary/util/valid/DataCheck.java create mode 100644 src/com/engine/salary/util/valid/Modify.java create mode 100644 src/com/engine/salary/util/valid/ModifyTypeEnum.java create mode 100644 src/com/engine/salary/util/valid/RuntimeTypeEnum.java create mode 100644 src/com/engine/salary/util/valid/ValidTypeEnum.java create mode 100644 src/com/engine/salary/util/valid/ValidUtil.java create mode 100644 src/com/engine/salary/util/valid/ValueTypeEnum.java create mode 100644 src/com/engine/salary/util/xml/XStreamUtil.java create mode 100644 src/com/engine/salary/web/AddUpDeductionController.java create mode 100644 src/com/engine/salary/web/AddUpSituationController.java create mode 100644 src/com/engine/salary/web/AttendQuoteController.java create mode 100644 src/com/engine/salary/web/AuthController.java create mode 100644 src/com/engine/salary/web/ExtEmpController.java create mode 100644 src/com/engine/salary/web/MySalaryShowSetController.java create mode 100644 src/com/engine/salary/web/OtherDeductionController.java create mode 100644 src/com/engine/salary/web/ProcessController.java create mode 100644 src/com/engine/salary/web/PushController.java create mode 100644 src/com/engine/salary/web/SIAccountController.java create mode 100644 src/com/engine/salary/web/SIArchivesController.java create mode 100644 src/com/engine/salary/web/SICategoryController.java create mode 100644 src/com/engine/salary/web/SIExportController.java create mode 100644 src/com/engine/salary/web/SIReportController.java create mode 100644 src/com/engine/salary/web/SISchemeController.java create mode 100644 src/com/engine/salary/web/SalaryAcctController.java create mode 100644 src/com/engine/salary/web/SalaryArchiveController.java create mode 100644 src/com/engine/salary/web/SalaryBillController.java create mode 100644 src/com/engine/salary/web/SalaryCommonController.java create mode 100644 src/com/engine/salary/web/SalaryFieldController.java create mode 100644 src/com/engine/salary/web/SalaryFormulaController.java create mode 100644 src/com/engine/salary/web/SalaryItemController.java create mode 100644 src/com/engine/salary/web/SalaryProgressController.java create mode 100644 src/com/engine/salary/web/SalarySendRangeController.java create mode 100644 src/com/engine/salary/web/SalarySobController.java create mode 100644 src/com/engine/salary/web/SalarySystemConfigController.java create mode 100644 src/com/engine/salary/web/SpecialAddDeductionController.java create mode 100644 src/com/engine/salary/web/TaxAgentController.java create mode 100644 src/com/engine/salary/web/TaxDeclarationController.java create mode 100644 src/com/engine/salary/web/TaxRateController.java create mode 100644 src/com/engine/salary/web/VariableArchiveController.java create mode 100644 src/com/engine/salary/web/VariableItemController.java create mode 100644 src/com/engine/salary/wrapper/AddUpDeductionWrapper.java create mode 100644 src/com/engine/salary/wrapper/AddUpSituationWrapper.java create mode 100644 src/com/engine/salary/wrapper/AttendQuoteDataWrapper.java create mode 100644 src/com/engine/salary/wrapper/AttendQuoteFieldSettingWrapper.java create mode 100644 src/com/engine/salary/wrapper/AttendQuoteFieldWrapper.java create mode 100644 src/com/engine/salary/wrapper/AttendQuoteWrapper.java create mode 100644 src/com/engine/salary/wrapper/AuthWrapper.java create mode 100644 src/com/engine/salary/wrapper/ExtEmpWrapper.java create mode 100644 src/com/engine/salary/wrapper/MySalaryShowSetWrapper.java create mode 100644 src/com/engine/salary/wrapper/OtherDeductionWrapper.java create mode 100644 src/com/engine/salary/wrapper/ProcessWrapper.java create mode 100644 src/com/engine/salary/wrapper/PushWrapper.java create mode 100644 src/com/engine/salary/wrapper/RoleWrapper.java create mode 100644 src/com/engine/salary/wrapper/SIAComparisonResultWrapper.java create mode 100644 src/com/engine/salary/wrapper/SIAccountWrapper.java create mode 100644 src/com/engine/salary/wrapper/SICategoryWrapper.java create mode 100644 src/com/engine/salary/wrapper/SIExportWrapper.java create mode 100644 src/com/engine/salary/wrapper/SIImportWrapper.java create mode 100644 src/com/engine/salary/wrapper/SIReportWrapper.java create mode 100644 src/com/engine/salary/wrapper/SISchemeWrapper.java create mode 100644 src/com/engine/salary/wrapper/SalaryAcctEmployeeWrapper.java create mode 100644 src/com/engine/salary/wrapper/SalaryAcctExcelWrapper.java create mode 100644 src/com/engine/salary/wrapper/SalaryAcctRecordWrapper.java create mode 100644 src/com/engine/salary/wrapper/SalaryAcctResultWrapper.java create mode 100644 src/com/engine/salary/wrapper/SalaryApprovalWrapper.java create mode 100644 src/com/engine/salary/wrapper/SalaryArchiveItemWrapper.java create mode 100644 src/com/engine/salary/wrapper/SalaryArchiveTaxAgentWrapper.java create mode 100644 src/com/engine/salary/wrapper/SalaryArchiveWrapper.java create mode 100644 src/com/engine/salary/wrapper/SalaryBillBaseSetWrapper.java create mode 100644 src/com/engine/salary/wrapper/SalaryCommonWrapper.java create mode 100644 src/com/engine/salary/wrapper/SalaryComparisonResultWrapper.java create mode 100644 src/com/engine/salary/wrapper/SalaryFieldWrapper.java create mode 100644 src/com/engine/salary/wrapper/SalaryFormulaWrapper.java create mode 100644 src/com/engine/salary/wrapper/SalaryItemWrapper.java create mode 100644 src/com/engine/salary/wrapper/SalarySendRangeWrapper.java create mode 100644 src/com/engine/salary/wrapper/SalarySendWrapper.java create mode 100644 src/com/engine/salary/wrapper/SalarySobAdjustRuleWrapper.java create mode 100644 src/com/engine/salary/wrapper/SalarySobBackItemWrapper.java create mode 100644 src/com/engine/salary/wrapper/SalarySobCheckRuleWrapper.java create mode 100644 src/com/engine/salary/wrapper/SalarySobItemWrapper.java create mode 100644 src/com/engine/salary/wrapper/SalarySobRangeWrapper.java create mode 100644 src/com/engine/salary/wrapper/SalarySobWrapper.java create mode 100644 src/com/engine/salary/wrapper/SalarySystemConfigWrapper.java create mode 100644 src/com/engine/salary/wrapper/SalaryTemplateWrapper.java create mode 100644 src/com/engine/salary/wrapper/SpecialAddDeductionWrapper.java create mode 100644 src/com/engine/salary/wrapper/SysSalaryItemWrapper.java create mode 100644 src/com/engine/salary/wrapper/TaxAgentBaseWrapper.java create mode 100644 src/com/engine/salary/wrapper/TaxAgentSubAdminWrapper.java create mode 100644 src/com/engine/salary/wrapper/TaxAgentWrapper.java create mode 100644 src/com/engine/salary/wrapper/TaxDeclarationDetailWrapper.java create mode 100644 src/com/engine/salary/wrapper/TaxDeclarationWrapper.java create mode 100644 src/com/engine/salary/wrapper/VariableArchiveWrapper.java create mode 100644 src/com/engine/salary/wrapper/VariableItemWrapper.java create mode 100644 src/com/engine/salary/wrapper/proxy/SalaryAcctRecordWrapperProxy.java create mode 100644 src/com/engine/salary/wrapper/proxy/SalaryAcctResultWrapperProxy.java create mode 100644 src/com/engine/salary/wrapper/proxy/SalaryArchiveItemWrapperProxy.java create mode 100644 src/com/engine/salary/wrapper/proxy/SalarySendWrapperProxy.java diff --git a/src/com/api/salary/listener/InitListener.java b/src/com/api/salary/listener/InitListener.java new file mode 100644 index 000000000..18fb3cb4f --- /dev/null +++ b/src/com/api/salary/listener/InitListener.java @@ -0,0 +1,53 @@ +package com.api.salary.listener; + +import com.sun.jersey.api.model.AbstractResourceModelContext; +import com.sun.jersey.api.model.AbstractResourceModelListener; +import com.weaver.upgrade.FunctionUpgradeUtil; +import org.apache.commons.lang3.StringUtils; +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.system.License; + +import javax.ws.rs.ext.Provider; + +@Provider +public class InitListener implements AbstractResourceModelListener { + @Override + public void onLoaded(AbstractResourceModelContext abstractResourceModelContext) { + int menuid = 100118; + BaseBean bb = new BaseBean(); + String cId = new License().getCId(); + String defaultCloseNonStandard149 = bb.getPropValue("hrmSalary", "defaultCloseNonStandard149"); + if (StringUtils.isNotBlank(cId) && "true".equals(defaultCloseNonStandard149)) { + if (cId.length() > 7) { + cId = cId.substring(cId.length() - 7); + } + int cid = Integer.parseInt(cId); + if (!hasMenuInfo(cid, "left", menuid)) { + bb.writeLog("149新薪酬管理 添加默认菜单控制"); + insertMenuInfo(cid, "left", menuid); + } + } + } + + private void insertMenuInfo(int cid, String type, int id) { + RecordSet rs = new RecordSet(); + BaseBean bb = new BaseBean(); + bb.writeLog("FunctionUpgradeUtil.getMenuId(cid,id):" + FunctionUpgradeUtil.getMenuId(cid, id)); + String sql = "INSERT INTO menucontrollist (type,menuid,isopen) VALUES('" + type + "','" + FunctionUpgradeUtil.getMenuId(cid, id) + "','" + FunctionUpgradeUtil.getMenuStatus(id, -1, cid) + "')"; + rs.execute(sql); + } + + private boolean hasMenuInfo(int cid, String type, int id) { + RecordSet rs = new RecordSet(); + String sql = "select count(1) as count from menucontrollist where type = ? and menuid = ?"; + rs.executeQuery(sql, type, FunctionUpgradeUtil.getMenuId(cid, id)); + if (rs.next()) { + int count = rs.getInt("count"); + if (count > 0) { + return true; + } + } + return false; + } +} diff --git a/src/com/api/salary/web/AddUpDeductionController.java b/src/com/api/salary/web/AddUpDeductionController.java new file mode 100644 index 000000000..d9af2aa3e --- /dev/null +++ b/src/com/api/salary/web/AddUpDeductionController.java @@ -0,0 +1,9 @@ +package com.api.salary.web; + + +import javax.ws.rs.Path; + +@Path("/bs/hrmsalary/addUpDeduction") +public class AddUpDeductionController extends com.engine.salary.web.AddUpDeductionController{ + +} diff --git a/src/com/api/salary/web/AddUpSituationController.java b/src/com/api/salary/web/AddUpSituationController.java new file mode 100644 index 000000000..b579ad253 --- /dev/null +++ b/src/com/api/salary/web/AddUpSituationController.java @@ -0,0 +1,8 @@ +package com.api.salary.web; + +import javax.ws.rs.Path; + +@Path("/bs/hrmsalary/addUpSituation") +public class AddUpSituationController extends com.engine.salary.web.AddUpSituationController{ + +} diff --git a/src/com/api/salary/web/AttendQuoteController.java b/src/com/api/salary/web/AttendQuoteController.java new file mode 100644 index 000000000..b91be1744 --- /dev/null +++ b/src/com/api/salary/web/AttendQuoteController.java @@ -0,0 +1,8 @@ +package com.api.salary.web; + +import javax.ws.rs.Path; + +@Path("/bs/hrmsalary/attendQuote") +public class AttendQuoteController extends com.engine.salary.web.AttendQuoteController{ + +} diff --git a/src/com/api/salary/web/AuthController.java b/src/com/api/salary/web/AuthController.java new file mode 100644 index 000000000..3a2c0374c --- /dev/null +++ b/src/com/api/salary/web/AuthController.java @@ -0,0 +1,8 @@ +package com.api.salary.web; + +import javax.ws.rs.Path; + +@Path("/bs/hrmsalary/auth") +public class AuthController extends com.engine.salary.web.AuthController { + +} diff --git a/src/com/api/salary/web/ExtEmpController.java b/src/com/api/salary/web/ExtEmpController.java new file mode 100644 index 000000000..9b349b2ef --- /dev/null +++ b/src/com/api/salary/web/ExtEmpController.java @@ -0,0 +1,8 @@ +package com.api.salary.web; + +import javax.ws.rs.Path; + +@Path("/bs/hrmsalary/extEmp") +public class ExtEmpController extends com.engine.salary.web.ExtEmpController{ + +} diff --git a/src/com/api/salary/web/MaintainerController.java b/src/com/api/salary/web/MaintainerController.java new file mode 100644 index 000000000..f43fe0a46 --- /dev/null +++ b/src/com/api/salary/web/MaintainerController.java @@ -0,0 +1,9 @@ +package com.api.salary.web; + + +import javax.ws.rs.Path; + +@Path("/bs/hrmsalary/maintainer") +public class MaintainerController extends com.engine.salary.maintainer.MaintainerController{ + +} diff --git a/src/com/api/salary/web/MySalaryShowSetController.java b/src/com/api/salary/web/MySalaryShowSetController.java new file mode 100644 index 000000000..0be912245 --- /dev/null +++ b/src/com/api/salary/web/MySalaryShowSetController.java @@ -0,0 +1,13 @@ +package com.api.salary.web; + +import javax.ws.rs.Path; + +/** + * @Description: 我的薪资福利显示设置 + * @Author: wangxiangzhong + * @Date: 2021-12-08 14:44 + */ +@Path("/bs/hrmsalary/mySalaryShowSet") +public class MySalaryShowSetController extends com.engine.salary.web.MySalaryShowSetController { + +} diff --git a/src/com/api/salary/web/OtherDeductionController.java b/src/com/api/salary/web/OtherDeductionController.java new file mode 100644 index 000000000..8684ef641 --- /dev/null +++ b/src/com/api/salary/web/OtherDeductionController.java @@ -0,0 +1,8 @@ +package com.api.salary.web; + +import javax.ws.rs.Path; + +@Path("/bs/hrmsalary/otherDeduction") +public class OtherDeductionController extends com.engine.salary.web.OtherDeductionController { + +} diff --git a/src/com/api/salary/web/ProcessController.java b/src/com/api/salary/web/ProcessController.java new file mode 100644 index 000000000..60fcf484f --- /dev/null +++ b/src/com/api/salary/web/ProcessController.java @@ -0,0 +1,8 @@ +package com.api.salary.web; + +import javax.ws.rs.Path; + +@Path("/bs/hrmsalary/process") +public class ProcessController extends com.engine.salary.web.ProcessController{ + +} diff --git a/src/com/api/salary/web/PushController.java b/src/com/api/salary/web/PushController.java new file mode 100644 index 000000000..854a3b9b7 --- /dev/null +++ b/src/com/api/salary/web/PushController.java @@ -0,0 +1,8 @@ +package com.api.salary.web; + +import javax.ws.rs.Path; + +@Path("/bs/hrmsalary/push") +public class PushController extends com.engine.salary.web.PushController{ + +} diff --git a/src/com/api/salary/web/SIAccountController.java b/src/com/api/salary/web/SIAccountController.java new file mode 100644 index 000000000..8f15448b9 --- /dev/null +++ b/src/com/api/salary/web/SIAccountController.java @@ -0,0 +1,13 @@ +package com.api.salary.web; + +import javax.ws.rs.Path; + +/** + * @Author weaver_cl + * @Description: + * @Date 2022/4/11 + * @Version V1.0 + **/ +@Path("/bs/hrmsalary/siaccount") +public class SIAccountController extends com.engine.salary.web.SIAccountController { +} diff --git a/src/com/api/salary/web/SIArchiveActionAPIController.java b/src/com/api/salary/web/SIArchiveActionAPIController.java new file mode 100644 index 000000000..c130f6a8b --- /dev/null +++ b/src/com/api/salary/web/SIArchiveActionAPIController.java @@ -0,0 +1,14 @@ +package com.api.salary.web; + +import com.engine.salary.process.siArchives.SIArchiveActionAPI; + +import javax.ws.rs.Path; + +/** + * @Author: sy + * @Description: + * @Date: 2022/11/11 + **/ +@Path("/bs/hrmsalary/siArchiveAction") +public class SIArchiveActionAPIController extends SIArchiveActionAPI { +} diff --git a/src/com/api/salary/web/SIArchivesController.java b/src/com/api/salary/web/SIArchivesController.java new file mode 100644 index 000000000..bf3aa3fcd --- /dev/null +++ b/src/com/api/salary/web/SIArchivesController.java @@ -0,0 +1,13 @@ +package com.api.salary.web; + +import javax.ws.rs.Path; + +/** + * @Author weaver_cl + * @Description: TODO + * @Date 2022/3/11 + * @Version V1.0 + **/ +@Path("/bs/hrmsalary/archives") +public class SIArchivesController extends com.engine.salary.web.SIArchivesController { +} diff --git a/src/com/api/salary/web/SICategoryController.java b/src/com/api/salary/web/SICategoryController.java new file mode 100644 index 000000000..b41f73627 --- /dev/null +++ b/src/com/api/salary/web/SICategoryController.java @@ -0,0 +1,13 @@ +package com.api.salary.web; + +import javax.ws.rs.Path; + +/** + * @Author weaver_cl + * @Description: TODO + * @Date 2022/3/9 + * @Version V1.0 + **/ +@Path("/bs/hrmsalary/sicategory") +public class SICategoryController extends com.engine.salary.web.SICategoryController { +} diff --git a/src/com/api/salary/web/SIExportController.java b/src/com/api/salary/web/SIExportController.java new file mode 100644 index 000000000..b9ece4fb3 --- /dev/null +++ b/src/com/api/salary/web/SIExportController.java @@ -0,0 +1,13 @@ +package com.api.salary.web; + +import javax.ws.rs.Path; + +/** + * @Author weaver_cl + * @Description: + * @Date 2022/4/20 + * @Version V1.0 + **/ +@Path("/bs/hrmsalary/welfare") +public class SIExportController extends com.engine.salary.web.SIExportController { +} diff --git a/src/com/api/salary/web/SIReportController.java b/src/com/api/salary/web/SIReportController.java new file mode 100644 index 000000000..f61cc4af1 --- /dev/null +++ b/src/com/api/salary/web/SIReportController.java @@ -0,0 +1,16 @@ +package com.api.salary.web; + +import javax.ws.rs.Path; + +/** + * 福利报表 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Path("/bs/hrmsalary/report") +public class SIReportController extends com.engine.salary.web.SIReportController { + +} diff --git a/src/com/api/salary/web/SISchemeController.java b/src/com/api/salary/web/SISchemeController.java new file mode 100644 index 000000000..6d12c2d05 --- /dev/null +++ b/src/com/api/salary/web/SISchemeController.java @@ -0,0 +1,13 @@ +package com.api.salary.web; + +import javax.ws.rs.Path; + +/** + * @Author weaver_cl + * @Description: TODO + * @Date 2022/3/7 + * @Version V1.0 + **/ +@Path("/bs/hrmsalary/scheme") +public class SISchemeController extends com.engine.salary.web.SISchemeController { +} diff --git a/src/com/api/salary/web/SalaryAcctController.java b/src/com/api/salary/web/SalaryAcctController.java new file mode 100644 index 000000000..7d8be0bcf --- /dev/null +++ b/src/com/api/salary/web/SalaryAcctController.java @@ -0,0 +1,8 @@ +package com.api.salary.web; + +import javax.ws.rs.Path; + +@Path("/bs/hrmsalary/salaryacct") +public class SalaryAcctController extends com.engine.salary.web.SalaryAcctController { + +} diff --git a/src/com/api/salary/web/SalaryArchiveActionAPIController.java b/src/com/api/salary/web/SalaryArchiveActionAPIController.java new file mode 100644 index 000000000..039cf4e67 --- /dev/null +++ b/src/com/api/salary/web/SalaryArchiveActionAPIController.java @@ -0,0 +1,10 @@ +package com.api.salary.web; + + +import com.engine.salary.process.salaryArchive.SalaryArchiveActionAPI; + +import javax.ws.rs.Path; + +@Path("/bs/hrmsalary/salaryArchiveAction") +public class SalaryArchiveActionAPIController extends SalaryArchiveActionAPI { +} diff --git a/src/com/api/salary/web/SalaryArchiveController.java b/src/com/api/salary/web/SalaryArchiveController.java new file mode 100644 index 000000000..acb190965 --- /dev/null +++ b/src/com/api/salary/web/SalaryArchiveController.java @@ -0,0 +1,8 @@ +package com.api.salary.web; + +import javax.ws.rs.Path; + +@Path("/bs/hrmsalary/salaryArchive") +public class SalaryArchiveController extends com.engine.salary.web.SalaryArchiveController{ + +} diff --git a/src/com/api/salary/web/SalaryBillController.java b/src/com/api/salary/web/SalaryBillController.java new file mode 100644 index 000000000..c423f5f02 --- /dev/null +++ b/src/com/api/salary/web/SalaryBillController.java @@ -0,0 +1,7 @@ +package com.api.salary.web; + +import javax.ws.rs.Path; + +@Path("/bs/hrmsalary/salaryBill") +public class SalaryBillController extends com.engine.salary.web.SalaryBillController{ +} diff --git a/src/com/api/salary/web/SalaryCommonController.java b/src/com/api/salary/web/SalaryCommonController.java new file mode 100644 index 000000000..cf3de7b33 --- /dev/null +++ b/src/com/api/salary/web/SalaryCommonController.java @@ -0,0 +1,7 @@ +package com.api.salary.web; + +import javax.ws.rs.Path; + +@Path("/bs/hrmsalary/common") +public class SalaryCommonController extends com.engine.salary.web.SalaryCommonController{ +} diff --git a/src/com/api/salary/web/SalaryFieldController.java b/src/com/api/salary/web/SalaryFieldController.java new file mode 100644 index 000000000..4b576c1d3 --- /dev/null +++ b/src/com/api/salary/web/SalaryFieldController.java @@ -0,0 +1,7 @@ +package com.api.salary.web; + +import javax.ws.rs.Path; + +@Path("/bs/hrmsalary/salaryField") +public class SalaryFieldController extends com.engine.salary.web.SalaryFieldController{ +} diff --git a/src/com/api/salary/web/SalaryFormulaController.java b/src/com/api/salary/web/SalaryFormulaController.java new file mode 100644 index 000000000..d2e501bf9 --- /dev/null +++ b/src/com/api/salary/web/SalaryFormulaController.java @@ -0,0 +1,7 @@ +package com.api.salary.web; + +import javax.ws.rs.Path; + +@Path("/bs/hrmsalary/formula") +public class SalaryFormulaController extends com.engine.salary.web.SalaryFormulaController { +} diff --git a/src/com/api/salary/web/SalaryItemController.java b/src/com/api/salary/web/SalaryItemController.java new file mode 100644 index 000000000..04bb234d6 --- /dev/null +++ b/src/com/api/salary/web/SalaryItemController.java @@ -0,0 +1,7 @@ +package com.api.salary.web; + +import javax.ws.rs.Path; + +@Path("/bs/hrmsalary/salaryitem") +public class SalaryItemController extends com.engine.salary.web.SalaryItemController{ +} diff --git a/src/com/api/salary/web/SalaryProgressController.java b/src/com/api/salary/web/SalaryProgressController.java new file mode 100644 index 000000000..c342de99a --- /dev/null +++ b/src/com/api/salary/web/SalaryProgressController.java @@ -0,0 +1,7 @@ +package com.api.salary.web; + +import javax.ws.rs.Path; + +@Path("/bs/hrmsalary/progress") +public class SalaryProgressController extends com.engine.salary.web.SalaryProgressController{ +} diff --git a/src/com/api/salary/web/SalarySendRangeController.java b/src/com/api/salary/web/SalarySendRangeController.java new file mode 100644 index 000000000..f55f91346 --- /dev/null +++ b/src/com/api/salary/web/SalarySendRangeController.java @@ -0,0 +1,8 @@ +package com.api.salary.web; + +import javax.ws.rs.Path; + +@Path("/bs/hrmsalary/salaryBill/send/range/") +public class SalarySendRangeController extends com.engine.salary.web.SalarySendRangeController{ + +} diff --git a/src/com/api/salary/web/SalarySobController.java b/src/com/api/salary/web/SalarySobController.java new file mode 100644 index 000000000..716d3a195 --- /dev/null +++ b/src/com/api/salary/web/SalarySobController.java @@ -0,0 +1,15 @@ +package com.api.salary.web; + +import javax.ws.rs.Path; + +/** + * 薪资账套 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Path("/bs/hrmsalary/salarysob") +public class SalarySobController extends com.engine.salary.web.SalarySobController { +} diff --git a/src/com/api/salary/web/SalaryStatisticsDimensionController.java b/src/com/api/salary/web/SalaryStatisticsDimensionController.java new file mode 100644 index 000000000..6f088d983 --- /dev/null +++ b/src/com/api/salary/web/SalaryStatisticsDimensionController.java @@ -0,0 +1,9 @@ +package com.api.salary.web; + + +import javax.ws.rs.Path; + +@Path("/bs/hrmsalary/report/statistics/dimension") +public class SalaryStatisticsDimensionController extends com.engine.salary.report.web.SalaryStatisticsDimensionController{ + +} diff --git a/src/com/api/salary/web/SalaryStatisticsEchartsController.java b/src/com/api/salary/web/SalaryStatisticsEchartsController.java new file mode 100644 index 000000000..991c25382 --- /dev/null +++ b/src/com/api/salary/web/SalaryStatisticsEchartsController.java @@ -0,0 +1,8 @@ +package com.api.salary.web; + +import javax.ws.rs.Path; + +@Path("/bs/hrmsalary/report/statistics/echarts") +public class SalaryStatisticsEchartsController extends com.engine.salary.report.web.SalaryStatisticsEchartsController{ + +} diff --git a/src/com/api/salary/web/SalaryStatisticsEmployeeController.java b/src/com/api/salary/web/SalaryStatisticsEmployeeController.java new file mode 100644 index 000000000..92902b46f --- /dev/null +++ b/src/com/api/salary/web/SalaryStatisticsEmployeeController.java @@ -0,0 +1,8 @@ +package com.api.salary.web; + +import javax.ws.rs.Path; + +@Path("/bs/hrmsalary/report/statistics/employee") +public class SalaryStatisticsEmployeeController extends com.engine.salary.report.web.SalaryStatisticsEmployeeController{ + +} diff --git a/src/com/api/salary/web/SalaryStatisticsItemController.java b/src/com/api/salary/web/SalaryStatisticsItemController.java new file mode 100644 index 000000000..5b72826aa --- /dev/null +++ b/src/com/api/salary/web/SalaryStatisticsItemController.java @@ -0,0 +1,9 @@ +package com.api.salary.web; + + +import javax.ws.rs.Path; + +@Path("/bs/hrmsalary/report/statistics/item") +public class SalaryStatisticsItemController extends com.engine.salary.report.web.SalaryStatisticsItemController{ + +} diff --git a/src/com/api/salary/web/SalaryStatisticsPushController.java b/src/com/api/salary/web/SalaryStatisticsPushController.java new file mode 100644 index 000000000..75b370b37 --- /dev/null +++ b/src/com/api/salary/web/SalaryStatisticsPushController.java @@ -0,0 +1,8 @@ +package com.api.salary.web; + + +import javax.ws.rs.Path; + +@Path("/bs/salaryreport/salary/statistics/push") +public class SalaryStatisticsPushController extends com.engine.salary.report.web.SalaryStatisticsPushController{ +} diff --git a/src/com/api/salary/web/SalaryStatisticsReportController.java b/src/com/api/salary/web/SalaryStatisticsReportController.java new file mode 100644 index 000000000..70a08f7f9 --- /dev/null +++ b/src/com/api/salary/web/SalaryStatisticsReportController.java @@ -0,0 +1,9 @@ +package com.api.salary.web; + + +import javax.ws.rs.Path; + +@Path("/bs/hrmsalary/report/statistics/report") +public class SalaryStatisticsReportController extends com.engine.salary.report.web.SalaryStatisticsReportController{ + +} diff --git a/src/com/api/salary/web/SalarySystemConfigController.java b/src/com/api/salary/web/SalarySystemConfigController.java new file mode 100644 index 000000000..429e42154 --- /dev/null +++ b/src/com/api/salary/web/SalarySystemConfigController.java @@ -0,0 +1,8 @@ +package com.api.salary.web; + +import javax.ws.rs.Path; + +@Path("/bs/hrmsalary/sys") +public class SalarySystemConfigController extends com.engine.salary.web.SalarySystemConfigController{ + +} diff --git a/src/com/api/salary/web/SpecialAddDeductionController.java b/src/com/api/salary/web/SpecialAddDeductionController.java new file mode 100644 index 000000000..61afb7017 --- /dev/null +++ b/src/com/api/salary/web/SpecialAddDeductionController.java @@ -0,0 +1,8 @@ +package com.api.salary.web; + +import javax.ws.rs.Path; + +@Path("/bs/hrmsalary/specialAddDeduction") +public class SpecialAddDeductionController extends com.engine.salary.web.SpecialAddDeductionController { + +} diff --git a/src/com/api/salary/web/TaxAgentController.java b/src/com/api/salary/web/TaxAgentController.java new file mode 100644 index 000000000..2e699c1e8 --- /dev/null +++ b/src/com/api/salary/web/TaxAgentController.java @@ -0,0 +1,7 @@ +package com.api.salary.web; + +import javax.ws.rs.Path; + +@Path("/bs/hrmsalary/taxAgent") +public class TaxAgentController extends com.engine.salary.web.TaxAgentController{ +} diff --git a/src/com/api/salary/web/TaxDeclarationController.java b/src/com/api/salary/web/TaxDeclarationController.java new file mode 100644 index 000000000..352bc706f --- /dev/null +++ b/src/com/api/salary/web/TaxDeclarationController.java @@ -0,0 +1,7 @@ +package com.api.salary.web; + +import javax.ws.rs.Path; + +@Path("/bs/hrmsalary/taxdeclaration") +public class TaxDeclarationController extends com.engine.salary.web.TaxDeclarationController{ +} diff --git a/src/com/api/salary/web/TaxRateController.java b/src/com/api/salary/web/TaxRateController.java new file mode 100644 index 000000000..9cb45a9be --- /dev/null +++ b/src/com/api/salary/web/TaxRateController.java @@ -0,0 +1,7 @@ +package com.api.salary.web; + +import javax.ws.rs.Path; + +@Path("/bs/hrmsalary/taxrate") +public class TaxRateController extends com.engine.salary.web.TaxRateController{ +} diff --git a/src/com/api/salary/web/VariableArchiveController.java b/src/com/api/salary/web/VariableArchiveController.java new file mode 100644 index 000000000..ccf82cd89 --- /dev/null +++ b/src/com/api/salary/web/VariableArchiveController.java @@ -0,0 +1,8 @@ +package com.api.salary.web; + +import javax.ws.rs.Path; + +@Path("/bs/hrmsalary/variableSalary") +public class VariableArchiveController extends com.engine.salary.web.VariableArchiveController { + +} diff --git a/src/com/api/salary/web/VariableItemController.java b/src/com/api/salary/web/VariableItemController.java new file mode 100644 index 000000000..6c3063aea --- /dev/null +++ b/src/com/api/salary/web/VariableItemController.java @@ -0,0 +1,8 @@ +package com.api.salary.web; + +import javax.ws.rs.Path; + +@Path("/bs/hrmsalary/variableSalaryItem") +public class VariableItemController extends com.engine.salary.web.VariableItemController { + +} diff --git a/src/com/engine/salary/action/BatEditSalaryExcelAction.java b/src/com/engine/salary/action/BatEditSalaryExcelAction.java new file mode 100644 index 000000000..adc1f7160 --- /dev/null +++ b/src/com/engine/salary/action/BatEditSalaryExcelAction.java @@ -0,0 +1,112 @@ +package com.engine.salary.action; + +import com.engine.common.util.ServiceUtil; +import com.engine.salary.entity.salaryarchive.param.SalaryArchiveImportHandleParam; +import com.engine.salary.enums.salaryarchive.SalaryArchiveImportTypeEnum; +import com.engine.salary.enums.salaryarchive.SalaryArchiveListTypeEnum; +import com.engine.salary.service.SalaryArchiveExcelService; +import com.engine.salary.service.impl.SalaryArchiveExcelServiceImpl; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.Property; +import weaver.soa.workflow.request.RequestInfo; + +import java.util.Arrays; +import java.util.Map; +import java.util.stream.Collectors; + +@Slf4j +public class BatEditSalaryExcelAction implements Action { + + private SalaryArchiveExcelService getSalaryArchiveExcelService(User user) { + return ServiceUtil.getService(SalaryArchiveExcelServiceImpl.class, user); + } + + private String batSalaryExcelField; + + public String getBatSalaryExcelField() { + return batSalaryExcelField; + } + + public void setBatSalaryExcelField(String batSalaryExcelField) { + this.batSalaryExcelField = batSalaryExcelField; + } + + private String operatorField; + + public String getOperatorField() { + return operatorField; + } + + public void setOperatorField(String operatorField) { + this.operatorField = operatorField; + } + + // 是否执行action的字段, 0代表不执行,其余代表执行 + private String enableField; + + public String getEnableField() { + return enableField; + } + + public void setEnableField(String enableField) { + this.enableField = enableField; + } + + @Override + public String execute(RequestInfo requestInfo) { + try { + + Property[] properties = requestInfo.getMainTableInfo().getProperty(); + Map fieldMap = Arrays.stream(properties).collect(Collectors.toMap(Property::getName, + property -> Util.null2String(property.getValue()))); + + String enable = fieldMap.get(enableField); + if (StringUtils.isNotBlank(enable) && enable.equals("0")) { + // 不执行action + return SUCCESS; + } + String docId = fieldMap.get(batSalaryExcelField); + + RecordSet rs = new RecordSet(); + String queryImageId = "select imagefileid from docimagefile where docid = ?"; + rs.executeQuery(queryImageId, docId); + String imagefileid = null; + if (rs.next()) { + imagefileid = rs.getString("imagefileid"); + } + + SalaryArchiveImportHandleParam param = SalaryArchiveImportHandleParam.builder().imageId(imagefileid) + .listType(SalaryArchiveListTypeEnum.FIXED.getValue()) + .importType(SalaryArchiveImportTypeEnum.SALARYITEMADJUST.getValue()) + .onlyCheck(false) + .isProcess(true) + .build(); + + //操作人 + String uid = fieldMap.getOrDefault(operatorField, "1"); + Map map = getSalaryArchiveExcelService(new User(Integer.parseInt(uid))).batchImportEbatch(param); + + int errorCount = (int) map.get("errorCount"); + if (errorCount > 0) { + log.error("批量调薪存在异常 requestId:{} map:{}",requestInfo.getRequestid(), map); +// List> excelComments = (List>) map.get("errorNotice"); +// StringBuilder message = new StringBuilder(); +// for (Map comments : excelComments) { +// message.append(comments.get("message")).append("/n"); +// } +// requestInfo.getRequestManager().setMessage(message.toString()); +// return FAILURE_AND_CONTINUE; + } + } catch (Exception e) { + log.error("批量调薪异常", e); + requestInfo.getRequestManager().setMessage(e.getMessage()); + return FAILURE_AND_CONTINUE; + } + return SUCCESS; + } +} diff --git a/src/com/engine/salary/action/CheckBatEditSalaryExcelAction.java b/src/com/engine/salary/action/CheckBatEditSalaryExcelAction.java new file mode 100644 index 000000000..0378e8b62 --- /dev/null +++ b/src/com/engine/salary/action/CheckBatEditSalaryExcelAction.java @@ -0,0 +1,111 @@ +package com.engine.salary.action; + +import com.engine.common.util.ServiceUtil; +import com.engine.salary.entity.salaryarchive.param.SalaryArchiveImportHandleParam; +import com.engine.salary.enums.salaryarchive.SalaryArchiveImportTypeEnum; +import com.engine.salary.enums.salaryarchive.SalaryArchiveListTypeEnum; +import com.engine.salary.service.SalaryArchiveExcelService; +import com.engine.salary.service.impl.SalaryArchiveExcelServiceImpl; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.Property; +import weaver.soa.workflow.request.RequestInfo; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +@Slf4j +public class CheckBatEditSalaryExcelAction implements Action { + + private SalaryArchiveExcelService getSalaryArchiveExcelService(User user) { + return ServiceUtil.getService(SalaryArchiveExcelServiceImpl.class, user); + } + + private String batSalaryExcelField; + + public String getBatSalaryExcelField() { + return batSalaryExcelField; + } + + public void setBatSalaryExcelField(String batSalaryExcelField) { + this.batSalaryExcelField = batSalaryExcelField; + } + + private String operatorField; + + public String getOperatorField() { + return operatorField; + } + + public void setOperatorField(String operatorField) { + this.operatorField = operatorField; + } + + // 是否执行action的字段, 0代表不执行,其余代表执行 + private String enableField; + + public String getEnableField() { + return enableField; + } + + public void setEnableField(String enableField) { + this.enableField = enableField; + } + + @Override + public String execute(RequestInfo requestInfo) { + try { + Property[] properties = requestInfo.getMainTableInfo().getProperty(); + Map fieldMap = Arrays.stream(properties).collect(Collectors.toMap(Property::getName, + property -> Util.null2String(property.getValue()))); + + String enable = fieldMap.get(enableField); + if (StringUtils.isNotBlank(enable) && enable.equals("0")) { + // 不执行action + return SUCCESS; + } + String docId = fieldMap.get(batSalaryExcelField); + + RecordSet rs = new RecordSet(); + String queryImageId = "select imagefileid from docimagefile where docid = ?"; + rs.executeQuery(queryImageId, docId); + String imagefileid = null; + if (rs.next()) { + imagefileid = rs.getString("imagefileid"); + } + + SalaryArchiveImportHandleParam param = SalaryArchiveImportHandleParam.builder().imageId(imagefileid) + .listType(SalaryArchiveListTypeEnum.FIXED.getValue()) + .importType(SalaryArchiveImportTypeEnum.SALARYITEMADJUST.getValue()) + .onlyCheck(true) + .isProcess(true) + .build(); + + //操作人 + String uid = fieldMap.getOrDefault(operatorField, "1"); + Map map = getSalaryArchiveExcelService(new User(Integer.parseInt(uid))).batchImportEbatch(param); + int errorCount = (int) map.get("errorCount"); + if (errorCount > 0) { + log.error("批量调薪检查存在异常 requestId:{} map:{}", requestInfo.getRequestid(), map); + List> excelComments = (List>) map.get("errorNotice"); + StringBuilder message = new StringBuilder("excel中"); + for (Map comments : excelComments) { + message.append(comments.get("message")).append("\n"); + } + requestInfo.getRequestManager().setMessage(message.toString()); + return FAILURE_AND_CONTINUE; + } + } catch (Exception e) { + log.error("批量调薪检查异常", e); + requestInfo.getRequestManager().setMessage(e.getMessage()); + return FAILURE_AND_CONTINUE; + } + return SUCCESS; + } +} diff --git a/src/com/engine/salary/action/CheckEditSIArchiveAction.java b/src/com/engine/salary/action/CheckEditSIArchiveAction.java new file mode 100644 index 000000000..2a0bbccb7 --- /dev/null +++ b/src/com/engine/salary/action/CheckEditSIArchiveAction.java @@ -0,0 +1,153 @@ +package com.engine.salary.action; + +import com.engine.common.util.ServiceUtil; +import com.engine.salary.entity.siarchives.param.SIArchiveImportParam; +import com.engine.salary.service.SISchemeService; +import com.engine.salary.service.impl.SISchemeServiceImpl; +import com.engine.salary.util.SalaryEntityUtil; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.Property; +import weaver.soa.workflow.request.RequestInfo; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * @Author: sy + * @Description: 编辑福利档案的前置校验 + * @Date: 2023/8/21 + **/ +@Slf4j +public class CheckEditSIArchiveAction implements Action { + + private SISchemeService getSISchemeService(User user) { + return ServiceUtil.getService(SISchemeServiceImpl.class,user); + } + private String tableName; + + + public String getTableName() { + return tableName; + } + + public void setTableName(String tableName) { + this.tableName = tableName; + } + + // 是否执行action的字段, 0代表不执行,其余代表执行 + private String enableField; + + public String getEnableField() { + return enableField; + } + + public void setEnableField(String enableField) { + this.enableField = enableField; + } + + @Override + public String execute(RequestInfo requestInfo) { + try { + Property[] properties = requestInfo.getMainTableInfo().getProperty(); + Map fieldMap = Arrays.stream(properties).collect(Collectors.toMap(Property::getName, + property -> Util.null2String(property.getValue()))); + + String enable = fieldMap.get(enableField); + if (StringUtils.isNotBlank(enable) && enable.equals("0")) { + // 不执行action + return SUCCESS; + } + RecordSet rs = new RecordSet(); + + String queryImageId = "select salaryname,processfield from " + tableName + " where workflowid = ?"; + rs.executeQuery(queryImageId, requestInfo.getWorkflowid()); + + List list = new ArrayList<>(); + while (rs.next()) { + String processField = rs.getString("processfield"); + String salaryName = rs.getString("salaryname"); + String value = fieldMap.get(processField); + list.add(new CheckEditSIArchiveAction.SalaryField(processField, salaryName, value)); + } + List> importData = new ArrayList<>(); + importData.add(SalaryEntityUtil.convert2Map(list, CheckEditSIArchiveAction.SalaryField::getSalaryName, CheckEditSIArchiveAction.SalaryField::getValue)); + //福利执行状态 + String runStatus = list.stream().filter(f -> f.salaryName.equals("档案状态")).findFirst().map(CheckEditSIArchiveAction.SalaryField::getValue).orElse("1"); + + SIArchiveImportParam build = SIArchiveImportParam.builder() + .importDatas(importData) + .runStatus(runStatus) + .build(); + + //操作人 + String uid = list.stream().filter(f -> f.salaryName.equals("操作人")).findFirst().map(CheckEditSIArchiveAction.SalaryField::getValue).orElse("1"); + Map map = getSISchemeService(new User(Integer.parseInt(uid))).checkSIArchiveAdd(build); + + List errorNotice = (List) map.get("errorData"); + if (CollectionUtils.isNotEmpty(errorNotice)) { + log.error("福利档案编辑内容检查存在异常 requestId:{} ,参数:{}, map:{}", requestInfo.getRequestid(), build, map); + List> excelComments = (List>) map.get("errorData"); + StringBuilder message = new StringBuilder(""); + for (Map comments : excelComments) { + message.append(comments.get("message")).append("\n"); + } + requestInfo.getRequestManager().setMessage(message.toString()); + return FAILURE_AND_CONTINUE; + } + } catch (Exception e) { + log.error("福利档案编辑内容检查异常", e); + requestInfo.getRequestManager().setMessage(e.getMessage()); + return FAILURE_AND_CONTINUE; + } + return SUCCESS; + } + + + class SalaryField { + + private String processField; + + private String salaryName; + + private String value; + + public String getProcessField() { + return processField; + } + + public void setProcessField(String processField) { + this.processField = processField; + } + + public String getSalaryName() { + return salaryName; + } + + public void setSalaryName(String salaryName) { + this.salaryName = salaryName; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public SalaryField(String processField, String salaryName, String value) { + this.processField = processField; + this.salaryName = salaryName; + this.value = value; + } + } +} diff --git a/src/com/engine/salary/action/CheckEditSalaryAction.java b/src/com/engine/salary/action/CheckEditSalaryAction.java new file mode 100644 index 000000000..f8c2dcb75 --- /dev/null +++ b/src/com/engine/salary/action/CheckEditSalaryAction.java @@ -0,0 +1,147 @@ +package com.engine.salary.action; + +import com.engine.common.util.ServiceUtil; +import com.engine.salary.entity.salaryarchive.param.SalaryArchiveImportActionParam; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.wrapper.SalaryArchiveWrapper; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.Property; +import weaver.soa.workflow.request.RequestInfo; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +@Slf4j +public class CheckEditSalaryAction implements Action { + + + private SalaryArchiveWrapper getSalaryArchiveWrapper(User user) { + return ServiceUtil.getService(SalaryArchiveWrapper.class, user); + } + + private String tableName; + + + public String getTableName() { + return tableName; + } + + public void setTableName(String tableName) { + this.tableName = tableName; + } + + // 是否执行action的字段, 0代表不执行,其余代表执行 + private String enableField; + + public String getEnableField() { + return enableField; + } + + public void setEnableField(String enableField) { + this.enableField = enableField; + } + + @Override + public String execute(RequestInfo requestInfo) { + try { + + Property[] properties = requestInfo.getMainTableInfo().getProperty(); + Map fieldMap = Arrays.stream(properties).collect(Collectors.toMap(Property::getName, + property -> Util.null2String(property.getValue()))); + + String enable = fieldMap.get(enableField); + if (StringUtils.isNotBlank(enable) && enable.equals("0")) { + // 不执行action + return SUCCESS; + } + RecordSet rs = new RecordSet(); + + String queryImageId = "select salaryname,processfield from " + tableName + " where workflowid = ?"; + rs.executeQuery(queryImageId, requestInfo.getWorkflowid()); + + List list = new ArrayList<>(); + while (rs.next()) { + String processField = rs.getString("processfield"); + String salaryName = rs.getString("salaryname"); + String value = fieldMap.get(processField); + list.add(new SalaryField(processField, salaryName, value)); + } + List> importData = new ArrayList<>(); + importData.add(SalaryEntityUtil.convert2Map(list, SalaryField::getSalaryName, SalaryField::getValue)); + + SalaryArchiveImportActionParam build = SalaryArchiveImportActionParam.builder() + .importDatas(importData) + .build(); + + //操作人 + String uid = list.stream().filter(f -> f.salaryName.equals("操作人")).findFirst().map(SalaryField::getValue).orElse("1"); + Map map = getSalaryArchiveWrapper(new User(Integer.parseInt(uid))).checkAdjustmentSalaryArchive(build); + + List errorNotice = (List) map.get("errorNotice"); + if (CollectionUtils.isNotEmpty(errorNotice)) { + log.error("调薪检查存在异常 requestId:{} ,参数:{}, map:{}", requestInfo.getRequestid(), build, map); + List> excelComments = (List>) map.get("errorNotice"); + StringBuilder message = new StringBuilder(""); + for (Map comments : excelComments) { + message.append(comments.get("message")).append("\n"); + } + requestInfo.getRequestManager().setMessage(message.toString()); + return FAILURE_AND_CONTINUE; + } + } catch (Exception e) { + log.error("调薪检查异常", e); + requestInfo.getRequestManager().setMessage(e.getMessage()); + return FAILURE_AND_CONTINUE; + } + return SUCCESS; + } + + + class SalaryField { + + private String processField; + + private String salaryName; + + private String value; + + public String getProcessField() { + return processField; + } + + public void setProcessField(String processField) { + this.processField = processField; + } + + public String getSalaryName() { + return salaryName; + } + + public void setSalaryName(String salaryName) { + this.salaryName = salaryName; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public SalaryField(String processField, String salaryName, String value) { + this.processField = processField; + this.salaryName = salaryName; + this.value = value; + } + } +} diff --git a/src/com/engine/salary/action/CheckInitSalaryAction.java b/src/com/engine/salary/action/CheckInitSalaryAction.java new file mode 100644 index 000000000..157ecab8a --- /dev/null +++ b/src/com/engine/salary/action/CheckInitSalaryAction.java @@ -0,0 +1,208 @@ +package com.engine.salary.action; + +import com.engine.common.util.ServiceUtil; +import com.engine.salary.entity.salaryarchive.param.SalaryArchiveImportActionParam; +import com.engine.salary.entity.salaryarchive.po.SalaryArchivePO; +import com.engine.salary.entity.taxagent.param.TaxAgentQueryParam; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import com.engine.salary.enums.salaryarchive.SalaryArchiveStatusEnum; +import com.engine.salary.mapper.archive.SalaryArchiveMapper; +import com.engine.salary.service.SalaryArchiveService; +import com.engine.salary.service.TaxAgentService; +import com.engine.salary.service.impl.SalaryArchiveServiceImpl; +import com.engine.salary.service.impl.TaxAgentServiceImpl; +import com.engine.salary.util.SalaryDateUtil; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.db.MapperProxyFactory; +import com.engine.salary.wrapper.SalaryArchiveWrapper; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.math.NumberUtils; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.Property; +import weaver.soa.workflow.request.RequestInfo; + +import java.util.*; +import java.util.stream.Collectors; + +@Slf4j +public class CheckInitSalaryAction implements Action { + + + private SalaryArchiveWrapper getSalaryArchiveWrapper(User user) { + return ServiceUtil.getService(SalaryArchiveWrapper.class, user); + } + + private TaxAgentService getTaxAgentService(User user) { + return ServiceUtil.getService(TaxAgentServiceImpl.class, user); + } + + private SalaryArchiveService getSalaryArchiveService(User user) { + return ServiceUtil.getService(SalaryArchiveServiceImpl.class, user); + } + + private SalaryArchiveMapper getSalaryArchiveMapper() { + return MapperProxyFactory.getProxy(SalaryArchiveMapper.class); + } + + private String tableName; + + + public String getTableName() { + return tableName; + } + + public void setTableName(String tableName) { + this.tableName = tableName; + } + + // 是否执行action的字段, 0代表不执行,其余代表执行 + private String enableField; + + public String getEnableField() { + return enableField; + } + + public void setEnableField(String enableField) { + this.enableField = enableField; + } + + @Override + public String execute(RequestInfo requestInfo) { + try { + + Property[] properties = requestInfo.getMainTableInfo().getProperty(); + Map fieldMap = Arrays.stream(properties).collect(Collectors.toMap(Property::getName, + property -> Util.null2String(property.getValue()))); + + String enable = fieldMap.get(enableField); + if (StringUtils.isNotBlank(enable) && enable.equals("0")) { + // 不执行action + return SUCCESS; + } + + RecordSet rs = new RecordSet(); + + String queryImageId = "select salaryname,processfield from " + tableName + " where workflowid = ?"; + rs.executeQuery(queryImageId, requestInfo.getWorkflowid()); + + List list = new ArrayList<>(); + while (rs.next()) { + String processField = rs.getString("processfield"); + String salaryName = rs.getString("salaryname"); + String value = fieldMap.get(processField); + list.add(new SalaryField(processField, salaryName, value)); + } + Map importDataMap = SalaryEntityUtil.convert2Map(list, SalaryField::getSalaryName, SalaryField::getValue); + + return doSalaryArchiveInit(requestInfo, importDataMap); + } catch (Exception e) { + log.error("定薪检查异常", e); + requestInfo.getRequestManager().setMessage(e.getMessage()); + return FAILURE_AND_CONTINUE; + } + } + + public String doSalaryArchiveInit(RequestInfo requestInfo, Map importDataMap) { + User user = new User(); + user.setLoginid("sysadmin"); + user.setUid(1); + List> importData = new ArrayList<>(); + if(!importDataMap.containsKey("生效日期")){ + importDataMap.put("生效日期", SalaryDateUtil.getFormatDate(new Date())); + } + if(!importDataMap.containsKey("最后发薪日期")){ + importDataMap.put("最后发薪日期", ""); + } + importData.add(importDataMap); + + // 首先判断是否已经存在薪资档案,且薪资档案状态为待定薪 + String taxAgentName = importDataMap.getOrDefault("个税扣缴义务人", "").toString(); + String empIdStr = importDataMap.getOrDefault("员工id", "").toString(); + if (StringUtils.isBlank(taxAgentName)) { + requestInfo.getRequestManager().setMessage("个税扣缴义务人不能为空"); + return FAILURE_AND_CONTINUE; + } + // 获取义务人信息 + List taxAgentPOS = getTaxAgentService(user).list(TaxAgentQueryParam.builder().name(taxAgentName).build()); + if (CollectionUtils.isEmpty(taxAgentPOS)) { + requestInfo.getRequestManager().setMessage("个税扣缴义务人不存在"); + return FAILURE_AND_CONTINUE; + } + Long taxAgentId = taxAgentPOS.get(0).getId(); + // 获取员工id + if (NumberUtils.isCreatable(empIdStr)) { + List salaryArchivePOList = getSalaryArchiveService(user).listSome(SalaryArchivePO.builder().taxAgentId(taxAgentId).employeeId(Long.valueOf(empIdStr)).build()); + if (CollectionUtils.isNotEmpty(salaryArchivePOList) && !salaryArchivePOList.get(0).getRunStatus().equals(SalaryArchiveStatusEnum.PENDING.getValue())) { + // 存在薪资档案,且薪资档案状态不是待定薪,修改状态为待定薪 + salaryArchivePOList.get(0).setRunStatus(SalaryArchiveStatusEnum.PENDING.getValue()); + salaryArchivePOList.get(0).setPayEndDate(null); + getSalaryArchiveMapper().update(salaryArchivePOList.get(0)); + } + } + + SalaryArchiveImportActionParam build = SalaryArchiveImportActionParam.builder() + .importDatas(importData) + .build(); + + //操作人 + Map map = getSalaryArchiveWrapper(user).checkSalaryArchiveInit(build); + + List errorNotice = (List) map.get("errorNotice"); + if (CollectionUtils.isNotEmpty(errorNotice)) { + log.error("定薪检查存在异常 requestId:{} ,参数:{}, map:{}", requestInfo.getRequestid(), build, map); + List> excelComments = (List>) map.get("errorNotice"); + StringBuilder message = new StringBuilder(""); + for (Map comments : excelComments) { + message.append(comments.get("message")).append("\n"); + } + requestInfo.getRequestManager().setMessage(message.toString()); + return FAILURE_AND_CONTINUE; + } + return SUCCESS; + } + + + class SalaryField { + + private String processField; + + private String salaryName; + + private String value; + + public String getProcessField() { + return processField; + } + + public void setProcessField(String processField) { + this.processField = processField; + } + + public String getSalaryName() { + return salaryName; + } + + public void setSalaryName(String salaryName) { + this.salaryName = salaryName; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public SalaryField(String processField, String salaryName, String value) { + this.processField = processField; + this.salaryName = salaryName; + this.value = value; + } + } +} diff --git a/src/com/engine/salary/action/CheckStayAddToPaySIArchiveAction.java b/src/com/engine/salary/action/CheckStayAddToPaySIArchiveAction.java new file mode 100644 index 000000000..6adfa8299 --- /dev/null +++ b/src/com/engine/salary/action/CheckStayAddToPaySIArchiveAction.java @@ -0,0 +1,161 @@ +package com.engine.salary.action; + +import com.engine.salary.entity.siarchives.po.InsuranceArchivesBaseInfoPO; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import com.engine.salary.enums.siaccount.EmployeeStatusEnum; +import com.engine.salary.mapper.siarchives.InsuranceBaseInfoMapper; +import com.engine.salary.mapper.taxagent.TaxAgentMapper; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.db.MapperProxyFactory; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.Property; +import weaver.soa.workflow.request.RequestInfo; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * @Author: sy + * @Description: 福利档案增员action的前置校验 + * @Date: 2023/8/22 + **/ +@Slf4j +public class CheckStayAddToPaySIArchiveAction implements Action { + + private InsuranceBaseInfoMapper getInsuranceBaseInfoMapper() { + return MapperProxyFactory.getProxy(InsuranceBaseInfoMapper.class); + } + + private TaxAgentMapper getTaxAgentMapper() { + return MapperProxyFactory.getProxy(TaxAgentMapper.class); + } + + private String tableName; + + + public String getTableName() { + return tableName; + } + + public void setTableName(String tableName) { + this.tableName = tableName; + } + + // 是否执行action的字段, 0代表不执行,其余代表执行 + private String enableField; + + public String getEnableField() { + return enableField; + } + + public void setEnableField(String enableField) { + this.enableField = enableField; + } + + @Override + public String execute(RequestInfo requestInfo) { + try { + + Property[] properties = requestInfo.getMainTableInfo().getProperty(); + Map fieldMap = Arrays.stream(properties).collect(Collectors.toMap(Property::getName, + property -> Util.null2String(property.getValue()))); + + String enable = fieldMap.get(enableField); + if (StringUtils.isNotBlank(enable) && enable.equals("0")) { + // 不执行action + return SUCCESS; + } + + RecordSet rs = new RecordSet(); + + String queryImageId = "select salaryname,processfield from " + tableName + " where workflowid = ?"; + rs.executeQuery(queryImageId, requestInfo.getWorkflowid()); + + List list = new ArrayList<>(); + while (rs.next()) { + String processField = rs.getString("processfield"); + String salaryName = rs.getString("salaryname"); + String value = fieldMap.get(processField); + list.add(new CheckStayAddToPaySIArchiveAction.SalaryField(processField, salaryName, value)); + } + // 流程数据 + Map importDataMap = SalaryEntityUtil.convert2Map(list, CheckStayAddToPaySIArchiveAction.SalaryField::getSalaryName, CheckStayAddToPaySIArchiveAction.SalaryField::getValue); + String taxAgentName = importDataMap.getOrDefault("个税扣缴义务人", "").toString(); + List taxAgentPOS = getTaxAgentMapper().listByName(taxAgentName); + if(CollectionUtils.isEmpty(taxAgentPOS)){ + requestInfo.getRequestManager().setMessage("个税扣缴义务人不存在!"); + return FAILURE_AND_CONTINUE; + } + Long taxAgentId = Long.valueOf( taxAgentPOS.get(0).getId() ); + Long employeeId = Long.valueOf(importDataMap.getOrDefault("员工id", "-1").toString()); + + //操作人 + String uid = importDataMap.getOrDefault("操作人","1").toString(); + User user = new User(Integer.parseInt(uid)); + // 获取福利档案 + InsuranceArchivesBaseInfoPO insuranceArchivesBaseInfoPO = getInsuranceBaseInfoMapper().getOneByEmployeeIdAndPayOrg(taxAgentId, employeeId); + if(insuranceArchivesBaseInfoPO == null){ + requestInfo.getRequestManager().setMessage("该个税扣缴义务人下该员工不存在福利档案,请检查后重试!"); + return FAILURE_AND_CONTINUE; + } else if(!insuranceArchivesBaseInfoPO.getRunStatus().equals(EmployeeStatusEnum.STAY_ADD.getValue())){ + requestInfo.getRequestManager().setMessage("该个税扣缴义务人下该员工的福利档案状态不是待增员,无法进行增员操作,请检查后重试!"); + return FAILURE_AND_CONTINUE; + } + + } catch (Exception e) { + log.error("增员校验异常", e); + requestInfo.getRequestManager().setMessage(e.getMessage()); + return FAILURE_AND_CONTINUE; + } + return SUCCESS; + } + + + class SalaryField { + + private String processField; + + private String salaryName; + + private String value; + + public String getProcessField() { + return processField; + } + + public void setProcessField(String processField) { + this.processField = processField; + } + + public String getSalaryName() { + return salaryName; + } + + public void setSalaryName(String salaryName) { + this.salaryName = salaryName; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public SalaryField(String processField, String salaryName, String value) { + this.processField = processField; + this.salaryName = salaryName; + this.value = value; + } + } +} diff --git a/src/com/engine/salary/action/CheckStayDelToStopSIArchiveAction.java b/src/com/engine/salary/action/CheckStayDelToStopSIArchiveAction.java new file mode 100644 index 000000000..ef816fbd8 --- /dev/null +++ b/src/com/engine/salary/action/CheckStayDelToStopSIArchiveAction.java @@ -0,0 +1,160 @@ +package com.engine.salary.action; + +import com.engine.salary.entity.siarchives.po.InsuranceArchivesBaseInfoPO; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import com.engine.salary.enums.siaccount.EmployeeStatusEnum; +import com.engine.salary.mapper.siarchives.InsuranceBaseInfoMapper; +import com.engine.salary.mapper.taxagent.TaxAgentMapper; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.db.MapperProxyFactory; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.Property; +import weaver.soa.workflow.request.RequestInfo; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * @Author: sy + * @Description: 福利档案减员action的前置校验 + * @Date: 2023/8/22 + **/ +@Slf4j +public class CheckStayDelToStopSIArchiveAction implements Action { + + private InsuranceBaseInfoMapper getInsuranceBaseInfoMapper() { + return MapperProxyFactory.getProxy(InsuranceBaseInfoMapper.class); + } + + private TaxAgentMapper getTaxAgentMapper() { + return MapperProxyFactory.getProxy(TaxAgentMapper.class); + } + + private String tableName; + + + public String getTableName() { + return tableName; + } + + public void setTableName(String tableName) { + this.tableName = tableName; + } + + // 是否执行action的字段, 0代表不执行,其余代表执行 + private String enableField; + + public String getEnableField() { + return enableField; + } + + public void setEnableField(String enableField) { + this.enableField = enableField; + } + + @Override + public String execute(RequestInfo requestInfo) { + try { + + Property[] properties = requestInfo.getMainTableInfo().getProperty(); + Map fieldMap = Arrays.stream(properties).collect(Collectors.toMap(Property::getName, + property -> Util.null2String(property.getValue()))); + + String enable = fieldMap.get(enableField); + if (StringUtils.isNotBlank(enable) && enable.equals("0")) { + // 不执行action + return SUCCESS; + } + RecordSet rs = new RecordSet(); + + String queryImageId = "select salaryname,processfield from " + tableName + " where workflowid = ?"; + rs.executeQuery(queryImageId, requestInfo.getWorkflowid()); + + List list = new ArrayList<>(); + while (rs.next()) { + String processField = rs.getString("processfield"); + String salaryName = rs.getString("salaryname"); + String value = fieldMap.get(processField); + list.add(new CheckStayDelToStopSIArchiveAction.SalaryField(processField, salaryName, value)); + } + // 流程数据 + Map importDataMap = SalaryEntityUtil.convert2Map(list, CheckStayDelToStopSIArchiveAction.SalaryField::getSalaryName, CheckStayDelToStopSIArchiveAction.SalaryField::getValue); + String taxAgentName = importDataMap.getOrDefault("个税扣缴义务人", "").toString(); + List taxAgentPOS = getTaxAgentMapper().listByName(taxAgentName); + if(CollectionUtils.isEmpty(taxAgentPOS)){ + requestInfo.getRequestManager().setMessage("个税扣缴义务人不存在!"); + return FAILURE_AND_CONTINUE; + } + Long taxAgentId = Long.valueOf( taxAgentPOS.get(0).getId() ); + Long employeeId = Long.valueOf(importDataMap.getOrDefault("员工id", "-1").toString()); + + //操作人 + String uid = importDataMap.getOrDefault("操作人","1").toString(); + User user = new User(Integer.parseInt(uid)); + // 获取福利档案 + InsuranceArchivesBaseInfoPO insuranceArchivesBaseInfoPO = getInsuranceBaseInfoMapper().getOneByEmployeeIdAndPayOrg(taxAgentId, employeeId); + if(insuranceArchivesBaseInfoPO == null){ + requestInfo.getRequestManager().setMessage("该个税扣缴义务人下该员工不存在福利档案,请检查后重试!"); + return FAILURE_AND_CONTINUE; + } else if(!insuranceArchivesBaseInfoPO.getRunStatus().equals(EmployeeStatusEnum.STAY_DEL.getValue())){ + requestInfo.getRequestManager().setMessage("该个税扣缴义务人下该员工的福利档案状态不是待减员,无法进行减员操作,请检查后重试!"); + return FAILURE_AND_CONTINUE; + } + + } catch (Exception e) { + log.error("减员校验异常", e); + requestInfo.getRequestManager().setMessage(e.getMessage()); + return FAILURE_AND_CONTINUE; + } + return SUCCESS; + } + + + class SalaryField { + + private String processField; + + private String salaryName; + + private String value; + + public String getProcessField() { + return processField; + } + + public void setProcessField(String processField) { + this.processField = processField; + } + + public String getSalaryName() { + return salaryName; + } + + public void setSalaryName(String salaryName) { + this.salaryName = salaryName; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public SalaryField(String processField, String salaryName, String value) { + this.processField = processField; + this.salaryName = salaryName; + this.value = value; + } + } +} diff --git a/src/com/engine/salary/action/CheckStopSalaryAction.java b/src/com/engine/salary/action/CheckStopSalaryAction.java new file mode 100644 index 000000000..6243e6ed5 --- /dev/null +++ b/src/com/engine/salary/action/CheckStopSalaryAction.java @@ -0,0 +1,177 @@ +package com.engine.salary.action; + +import com.engine.common.util.ServiceUtil; +import com.engine.salary.entity.salaryarchive.po.SalaryArchivePO; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import com.engine.salary.mapper.taxagent.TaxAgentMapper; +import com.engine.salary.service.SalaryArchiveService; +import com.engine.salary.service.impl.SalaryArchiveServiceImpl; +import com.engine.salary.util.SalaryDateUtil; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.db.MapperProxyFactory; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.math.NumberUtils; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.Property; +import weaver.soa.workflow.request.RequestInfo; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * @author Harryxzy + * @ClassName stopSalaryAction + * @date 2023/06/15 9:17 + * @description 校验停薪参数 + */ +@Slf4j +public class CheckStopSalaryAction implements Action { + + private SalaryArchiveService getSalaryArchiveService(User user) { + return ServiceUtil.getService(SalaryArchiveServiceImpl.class, user); + } + + private TaxAgentMapper getTaxAgentMapper() { + return MapperProxyFactory.getProxy(TaxAgentMapper.class); + } + + private String tableName; + + + public String getTableName() { + return tableName; + } + + public void setTableName(String tableName) { + this.tableName = tableName; + } + + // 是否执行action的字段, 0代表不执行,其余代表执行 + private String enableField; + + public String getEnableField() { + return enableField; + } + + public void setEnableField(String enableField) { + this.enableField = enableField; + } + + @Override + public String execute(RequestInfo requestInfo) { + try { + + Property[] properties = requestInfo.getMainTableInfo().getProperty(); + Map fieldMap = Arrays.stream(properties).collect(Collectors.toMap(Property::getName, + property -> Util.null2String(property.getValue()))); + + String enable = fieldMap.get(enableField); + if (StringUtils.isNotBlank(enable) && enable.equals("0")) { + // 不执行action + return SUCCESS; + } + RecordSet rs = new RecordSet(); + + String queryImageId = "select salaryname,processfield from " + tableName + " where workflowid = ?"; + rs.executeQuery(queryImageId, requestInfo.getWorkflowid()); + + List list = new ArrayList<>(); + while (rs.next()) { + String processField = rs.getString("processfield"); + String salaryName = rs.getString("salaryname"); + String value = fieldMap.get(processField); + list.add(new CheckStopSalaryAction.SalaryField(processField, salaryName, value)); + } + // 流程数据 + Map importDataMap = SalaryEntityUtil.convert2Map(list, CheckStopSalaryAction.SalaryField::getSalaryName, CheckStopSalaryAction.SalaryField::getValue); + String taxAgentName = importDataMap.getOrDefault("个税扣缴义务人", "").toString(); + List taxAgentPOS = getTaxAgentMapper().listByName(taxAgentName); + if(CollectionUtils.isEmpty(taxAgentPOS)){ + requestInfo.getRequestManager().setMessage("个税扣缴义务人不存在!"); + log.error("停薪检查异常 requestId:{} msg:{}", requestInfo.getRequestid(), taxAgentName + "个税扣缴义务人不存在!"); + return FAILURE_AND_CONTINUE; + } + Long taxAgentId = Long.valueOf( taxAgentPOS.get(0).getId() ); + Long employeeId = Long.valueOf(importDataMap.getOrDefault("员工id", "-1").toString()); + if( importDataMap.get("最后发薪日期") == null || StringUtils.isBlank(importDataMap.get("最后发薪日期").toString())){ + requestInfo.getRequestManager().setMessage("缺少最后发薪日期字段!"); + log.error("停薪检查异常 requestId:{} msg:{}", requestInfo.getRequestid(), "缺少最后发薪日期字段!"); + return FAILURE_AND_CONTINUE; + }else if(SalaryDateUtil.stringToDate(importDataMap.get("最后发薪日期").toString()) == null){ + requestInfo.getRequestManager().setMessage("最后发薪日期格式错误,格式为yyyy-MM-dd"); + log.error("停薪检查异常 requestId:{} msg:{}", requestInfo.getRequestid(), "最后发薪日期格式错误,格式为yyyy-MM-dd" + importDataMap.get("最后发薪日期").toString()); + return FAILURE_AND_CONTINUE; + } + + //操作人 + String uid = importDataMap.getOrDefault("操作人","1").toString(); + User user = new User(Integer.parseInt(uid)); + // 获取薪资档案 + List salaryArchiveList = getSalaryArchiveService(user).listSome(SalaryArchivePO.builder().taxAgentId(taxAgentId).employeeId(employeeId).deleteType(NumberUtils.INTEGER_ZERO).build()); + if(CollectionUtils.isEmpty(salaryArchiveList)){ + requestInfo.getRequestManager().setMessage("该个税扣缴义务人下该员工不存在薪资档案,请检查后重试!"); + log.error("停薪检查异常 requestId:{} msg:{}", requestInfo.getRequestid(), taxAgentId +"_"+ employeeId+"该个税扣缴义务人下该员工不存在薪资档案,请检查后重试!"); + return FAILURE_AND_CONTINUE; + } + if(salaryArchiveList.size() > 1){ + requestInfo.getRequestManager().setMessage("该个税扣缴义务人下该员工存在多条薪资档案记录,请检查后重试!"); + log.error("停薪检查异常 requestId:{} msg:{}", requestInfo.getRequestid(), taxAgentId +"_"+ employeeId+"该个税扣缴义务人下该员工存在多条薪资档案记录,请检查后重试!"); + return FAILURE_AND_CONTINUE; + } + + } catch (Exception e) { + log.error("停薪检查异常", e); + requestInfo.getRequestManager().setMessage(e.getMessage()); + return FAILURE_AND_CONTINUE; + } + return SUCCESS; + } + + + class SalaryField { + + private String processField; + + private String salaryName; + + private String value; + + public String getProcessField() { + return processField; + } + + public void setProcessField(String processField) { + this.processField = processField; + } + + public String getSalaryName() { + return salaryName; + } + + public void setSalaryName(String salaryName) { + this.salaryName = salaryName; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public SalaryField(String processField, String salaryName, String value) { + this.processField = processField; + this.salaryName = salaryName; + this.value = value; + } + } +} diff --git a/src/com/engine/salary/action/CopyToPaySIArchiveAction.java b/src/com/engine/salary/action/CopyToPaySIArchiveAction.java new file mode 100644 index 000000000..8f0421c71 --- /dev/null +++ b/src/com/engine/salary/action/CopyToPaySIArchiveAction.java @@ -0,0 +1,170 @@ +package com.engine.salary.action; + +import cn.hutool.core.util.StrUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import com.engine.salary.mapper.taxagent.TaxAgentMapper; +import com.engine.salary.service.SIArchivesService; +import com.engine.salary.service.impl.SIArchivesServiceImpl; +import com.engine.salary.util.SalaryDateUtil; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.db.MapperProxyFactory; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.Property; +import weaver.soa.workflow.request.RequestInfo; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * @Author: sy + * @Description: 拷贝福利档案并置为在缴 + * @Date: 2024/1/29 + **/ +@Slf4j +public class CopyToPaySIArchiveAction implements Action { + + private TaxAgentMapper getTaxAgentMapper() { + return MapperProxyFactory.getProxy(TaxAgentMapper.class); + } + + private SIArchivesService getSIArchivesService(User user) { + return ServiceUtil.getService(SIArchivesServiceImpl.class,user); + } + + private String tableName; + + public String getTableName() { + return tableName; + } + + public void setTableName(String tableName) { + this.tableName = tableName; + } + + // 是否执行action的字段, 0代表不执行,其余代表执行 + private String enableField; + + public String getEnableField() { + return enableField; + } + + public void setEnableField(String enableField) { + this.enableField = enableField; + } + + @Override + public String execute(RequestInfo requestInfo) { + try { + Property[] properties = requestInfo.getMainTableInfo().getProperty(); + Map fieldMap = Arrays.stream(properties).collect(Collectors.toMap(Property::getName, + property -> Util.null2String(property.getValue()))); + + String enable = fieldMap.get(enableField); + if (StringUtils.isNotBlank(enable) && enable.equals("0")) { + // 不执行action + return SUCCESS; + } + RecordSet rs = new RecordSet(); + + String queryImageId = "select salaryname,processfield from " + tableName + " where workflowid = ?"; + rs.executeQuery(queryImageId, requestInfo.getWorkflowid()); + + List list = new ArrayList<>(); + while (rs.next()) { + String processField = rs.getString("processfield"); + String salaryName = rs.getString("salaryname"); + String value = fieldMap.get(processField); + list.add(new CopyToPaySIArchiveAction.SalaryField(processField, salaryName, value)); + } + List> importData = new ArrayList<>(); + importData.add(SalaryEntityUtil.convert2Map(list, CopyToPaySIArchiveAction.SalaryField::getSalaryName, CopyToPaySIArchiveAction.SalaryField::getValue)); + //操作人 + String uid = list.stream().filter(f -> f.salaryName.equals("操作人")).findFirst().map(CopyToPaySIArchiveAction.SalaryField::getValue).orElse("1"); + //增员 + String toCopyTaxAgentName = importData.get(0).get("待复制个税扣缴义务人").toString(); + String toUpdateTaxAgentName = importData.get(0).get("待更新个税扣缴义务人").toString(); + String payStartYearMonth = importData.get(0).getOrDefault("起始缴纳月", "").toString(); + if (StrUtil.isNotBlank(payStartYearMonth) && !SalaryDateUtil.checkYearMonth(payStartYearMonth)) { + requestInfo.getRequestManager().setMessage("起始缴纳月格式有误,正确格式示例为'2021-01'"); + return FAILURE_AND_CONTINUE; + } + + List toCopyTaxAgentPOS = getTaxAgentMapper().listByName(toCopyTaxAgentName); + List toUpdateTaxAgentPOS = getTaxAgentMapper().listByName(toUpdateTaxAgentName); + if(CollectionUtils.isEmpty(toCopyTaxAgentPOS)){ + requestInfo.getRequestManager().setMessage("待复制个税扣缴义务人不存在!"); + return FAILURE_AND_CONTINUE; + } + if(CollectionUtils.isEmpty(toUpdateTaxAgentPOS)){ + requestInfo.getRequestManager().setMessage("待更新个税扣缴义务人不存在!"); + return FAILURE_AND_CONTINUE; + } + Long toCopyTaxAgentId = toCopyTaxAgentPOS.get(0).getId(); + Long toUpdateTaxAgentId = toUpdateTaxAgentPOS.get(0).getId(); + Long employeeId = Long.valueOf(list.stream().filter(f -> "员工id".equals(f.salaryName)).findFirst().map(CopyToPaySIArchiveAction.SalaryField::getValue).orElse("-1")); + User user = new User(Integer.parseInt(uid)); + user.setLanguage(7); + //拷贝福利档案并置为在缴 + Map resultMap = getSIArchivesService(user).copyToPay(toCopyTaxAgentId, toUpdateTaxAgentId, employeeId, payStartYearMonth); + if (!"success".equals(resultMap.get("type").toString())) { + requestInfo.getRequestManager().setMessage(resultMap.get("msg").toString()); + return FAILURE_AND_CONTINUE; + } + + } catch (Exception e) { + log.error("福利档案复制并置为在缴异常", e); + requestInfo.getRequestManager().setMessage(e.getMessage()); + return FAILURE_AND_CONTINUE; + } + return SUCCESS; + } + + class SalaryField { + + private String processField; + + private String salaryName; + + private String value; + + public String getProcessField() { + return processField; + } + + public void setProcessField(String processField) { + this.processField = processField; + } + + public String getSalaryName() { + return salaryName; + } + + public void setSalaryName(String salaryName) { + this.salaryName = salaryName; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public SalaryField(String processField, String salaryName, String value) { + this.processField = processField; + this.salaryName = salaryName; + this.value = value; + } + } +} diff --git a/src/com/engine/salary/action/EditSIArchiveAction.java b/src/com/engine/salary/action/EditSIArchiveAction.java new file mode 100644 index 000000000..4cb6eb505 --- /dev/null +++ b/src/com/engine/salary/action/EditSIArchiveAction.java @@ -0,0 +1,152 @@ +package com.engine.salary.action; + +import com.engine.common.util.ServiceUtil; +import com.engine.salary.entity.siarchives.param.SIArchiveImportParam; +import com.engine.salary.service.SISchemeService; +import com.engine.salary.service.impl.SISchemeServiceImpl; +import com.engine.salary.util.SalaryEntityUtil; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.Property; +import weaver.soa.workflow.request.RequestInfo; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * @Author: sy + * @Description: 编辑福利档案 + * @Date: 2023/8/21 + **/ +@Slf4j +public class EditSIArchiveAction implements Action { + private SISchemeService getSISchemeService(User user) { + return ServiceUtil.getService(SISchemeServiceImpl.class,user); + } + private String tableName; + + + public String getTableName() { + return tableName; + } + + public void setTableName(String tableName) { + this.tableName = tableName; + } + + // 是否执行action的字段, 0代表不执行,其余代表执行 + private String enableField; + + public String getEnableField() { + return enableField; + } + + public void setEnableField(String enableField) { + this.enableField = enableField; + } + + @Override + public String execute(RequestInfo requestInfo) { + try { + Property[] properties = requestInfo.getMainTableInfo().getProperty(); + Map fieldMap = Arrays.stream(properties).collect(Collectors.toMap(Property::getName, + property -> Util.null2String(property.getValue()))); + + String enable = fieldMap.get(enableField); + if (StringUtils.isNotBlank(enable) && enable.equals("0")) { + // 不执行action + return SUCCESS; + } + RecordSet rs = new RecordSet(); + + String queryImageId = "select salaryname,processfield from " + tableName + " where workflowid = ?"; + rs.executeQuery(queryImageId, requestInfo.getWorkflowid()); + + List list = new ArrayList<>(); + while (rs.next()) { + String processField = rs.getString("processfield"); + String salaryName = rs.getString("salaryname"); + String value = fieldMap.get(processField); + list.add(new EditSIArchiveAction.SalaryField(processField, salaryName, value)); + } + List> importData = new ArrayList<>(); + importData.add(SalaryEntityUtil.convert2Map(list, EditSIArchiveAction.SalaryField::getSalaryName, EditSIArchiveAction.SalaryField::getValue)); + //福利执行状态 + String runStatus = list.stream().filter(f -> f.salaryName.equals("档案状态")).findFirst().map(EditSIArchiveAction.SalaryField::getValue).orElse("1"); + + SIArchiveImportParam build = SIArchiveImportParam.builder() + .importDatas(importData) + .runStatus(runStatus) + .build(); + + //操作人 + String uid = list.stream().filter(f -> f.salaryName.equals("操作人")).findFirst().map(EditSIArchiveAction.SalaryField::getValue).orElse("1"); + Map map = getSISchemeService(new User(Integer.parseInt(uid))).addSIArchive(build); + + List errorNotice = (List) map.get("errorData"); + if (CollectionUtils.isNotEmpty(errorNotice)) { + log.error("福利档案编辑存在异常 requestId:{} ,参数:{}, map:{}", requestInfo.getRequestid(), build, map); + List> excelComments = (List>) map.get("errorData"); + StringBuilder message = new StringBuilder(""); + for (Map comments : excelComments) { + message.append(comments.get("message")).append("\n"); + } + requestInfo.getRequestManager().setMessage(message.toString()); + return FAILURE_AND_CONTINUE; + } + } catch (Exception e) { + log.error("福利档案编辑异常", e); + requestInfo.getRequestManager().setMessage(e.getMessage()); + return FAILURE_AND_CONTINUE; + } + return SUCCESS; + } + + + class SalaryField { + + private String processField; + + private String salaryName; + + private String value; + + public String getProcessField() { + return processField; + } + + public void setProcessField(String processField) { + this.processField = processField; + } + + public String getSalaryName() { + return salaryName; + } + + public void setSalaryName(String salaryName) { + this.salaryName = salaryName; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public SalaryField(String processField, String salaryName, String value) { + this.processField = processField; + this.salaryName = salaryName; + this.value = value; + } + } +} diff --git a/src/com/engine/salary/action/EditSalaryAction.java b/src/com/engine/salary/action/EditSalaryAction.java new file mode 100644 index 000000000..3c8dd5446 --- /dev/null +++ b/src/com/engine/salary/action/EditSalaryAction.java @@ -0,0 +1,147 @@ +package com.engine.salary.action; + +import com.engine.common.util.ServiceUtil; +import com.engine.salary.entity.salaryarchive.param.SalaryArchiveImportActionParam; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.wrapper.SalaryArchiveWrapper; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.Property; +import weaver.soa.workflow.request.RequestInfo; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +@Slf4j +public class EditSalaryAction implements Action { + + + private SalaryArchiveWrapper getSalaryArchiveWrapper(User user) { + return ServiceUtil.getService(SalaryArchiveWrapper.class, user); + } + + private String tableName; + + + public String getTableName() { + return tableName; + } + + public void setTableName(String tableName) { + this.tableName = tableName; + } + + // 是否执行action的字段, 0代表不执行,其余代表执行 + private String enableField; + + public String getEnableField() { + return enableField; + } + + public void setEnableField(String enableField) { + this.enableField = enableField; + } + + @Override + public String execute(RequestInfo requestInfo) { + try { + + Property[] properties = requestInfo.getMainTableInfo().getProperty(); + Map fieldMap = Arrays.stream(properties).collect(Collectors.toMap(Property::getName, + property -> Util.null2String(property.getValue()))); + + String enable = fieldMap.get(enableField); + if (StringUtils.isNotBlank(enable) && enable.equals("0")) { + // 不执行action + return SUCCESS; + } + RecordSet rs = new RecordSet(); + + String queryImageId = "select salaryname,processfield from " + tableName + " where workflowid = ?"; + rs.executeQuery(queryImageId, requestInfo.getWorkflowid()); + + List list = new ArrayList<>(); + while (rs.next()) { + String processField = rs.getString("processfield"); + String salaryName = rs.getString("salaryname"); + String value = fieldMap.get(processField); + list.add(new SalaryField(processField, salaryName, value)); + } + List> importData = new ArrayList<>(); + importData.add(SalaryEntityUtil.convert2Map(list, SalaryField::getSalaryName, SalaryField::getValue)); + + SalaryArchiveImportActionParam build = SalaryArchiveImportActionParam.builder() + .importDatas(importData) + .build(); + + //操作人 + String uid = list.stream().filter(f -> f.salaryName.equals("操作人")).findFirst().map(SalaryField::getValue).orElse("1"); + Map map = getSalaryArchiveWrapper(new User(Integer.parseInt(uid))).adjustmentSalaryArchive(build); + + List errorNotice = (List) map.get("errorNotice"); + if (CollectionUtils.isNotEmpty(errorNotice)) { + log.error("调薪存在异常 requestId:{} map:{}", requestInfo.getRequestid(), map); +// List> excelComments = (List>) map.get("errorNotice"); +// StringBuilder message = new StringBuilder(""); +// for (Map comments : excelComments) { +// message.append(comments.get("message")).append("\n"); +// } +// requestInfo.getRequestManager().setMessage(message.toString()); +// return FAILURE_AND_CONTINUE; + } + } catch (Exception e) { + log.error("调薪异常", e); + requestInfo.getRequestManager().setMessage(e.getMessage()); + return FAILURE_AND_CONTINUE; + } + return SUCCESS; + } + + + class SalaryField { + + private String processField; + + private String salaryName; + + private String value; + + public String getProcessField() { + return processField; + } + + public void setProcessField(String processField) { + this.processField = processField; + } + + public String getSalaryName() { + return salaryName; + } + + public void setSalaryName(String salaryName) { + this.salaryName = salaryName; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public SalaryField(String processField, String salaryName, String value) { + this.processField = processField; + this.salaryName = salaryName; + this.value = value; + } + } +} diff --git a/src/com/engine/salary/action/EditToPaySIArchiveAction.java b/src/com/engine/salary/action/EditToPaySIArchiveAction.java new file mode 100644 index 000000000..31259e94a --- /dev/null +++ b/src/com/engine/salary/action/EditToPaySIArchiveAction.java @@ -0,0 +1,198 @@ +package com.engine.salary.action; + +import com.engine.common.util.ServiceUtil; +import com.engine.salary.entity.siarchives.param.SIArchiveImportParam; +import com.engine.salary.entity.siarchives.po.InsuranceArchivesBaseInfoPO; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import com.engine.salary.enums.siaccount.EmployeeStatusEnum; +import com.engine.salary.mapper.siarchives.InsuranceBaseInfoMapper; +import com.engine.salary.mapper.taxagent.TaxAgentMapper; +import com.engine.salary.service.SIArchivesService; +import com.engine.salary.service.SISchemeService; +import com.engine.salary.service.impl.SIArchivesServiceImpl; +import com.engine.salary.service.impl.SISchemeServiceImpl; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.db.MapperProxyFactory; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.Property; +import weaver.soa.workflow.request.RequestInfo; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * @Author: sy + * @Description: 编辑并增员福利档案 + * @Date: 2023/9/8 + **/ +@Slf4j +public class EditToPaySIArchiveAction implements Action { + private SISchemeService getSISchemeService(User user) { + return ServiceUtil.getService(SISchemeServiceImpl.class,user); + } + + private InsuranceBaseInfoMapper getInsuranceBaseInfoMapper() { + return MapperProxyFactory.getProxy(InsuranceBaseInfoMapper.class); + } + + private SIArchivesService getSIArchivesService(User user) { + return ServiceUtil.getService(SIArchivesServiceImpl.class,user); + } + + private TaxAgentMapper getTaxAgentMapper() { + return MapperProxyFactory.getProxy(TaxAgentMapper.class); + } + + private String tableName; + + + public String getTableName() { + return tableName; + } + + public void setTableName(String tableName) { + this.tableName = tableName; + } + + // 是否执行action的字段, 0代表不执行,其余代表执行 + private String enableField; + + public String getEnableField() { + return enableField; + } + + public void setEnableField(String enableField) { + this.enableField = enableField; + } + + @Override + public String execute(RequestInfo requestInfo) { + try { + Property[] properties = requestInfo.getMainTableInfo().getProperty(); + Map fieldMap = Arrays.stream(properties).collect(Collectors.toMap(Property::getName, + property -> Util.null2String(property.getValue()))); + + String enable = fieldMap.get(enableField); + if (StringUtils.isNotBlank(enable) && enable.equals("0")) { + // 不执行action + return SUCCESS; + } + RecordSet rs = new RecordSet(); + + String queryImageId = "select salaryname,processfield from " + tableName + " where workflowid = ?"; + rs.executeQuery(queryImageId, requestInfo.getWorkflowid()); + + List list = new ArrayList<>(); + while (rs.next()) { + String processField = rs.getString("processfield"); + String salaryName = rs.getString("salaryname"); + String value = fieldMap.get(processField); + list.add(new EditToPaySIArchiveAction.SalaryField(processField, salaryName, value)); + } + List> importData = new ArrayList<>(); + importData.add(SalaryEntityUtil.convert2Map(list, EditToPaySIArchiveAction.SalaryField::getSalaryName, EditToPaySIArchiveAction.SalaryField::getValue)); + //福利执行状态 + String runStatus = EmployeeStatusEnum.STAY_ADD.getValue(); + + SIArchiveImportParam build = SIArchiveImportParam.builder() + .importDatas(importData) + .runStatus(runStatus) + .build(); + + //操作人 + String uid = list.stream().filter(f -> f.salaryName.equals("操作人")).findFirst().map(EditToPaySIArchiveAction.SalaryField::getValue).orElse("1"); + //更新/新建档案数据 + Map map = getSISchemeService(new User(Integer.parseInt(uid))).addSIArchive(build); + + List errorNotice = (List) map.get("errorData"); + if (CollectionUtils.isNotEmpty(errorNotice)) { + log.error("福利档案编辑并增员存在异常 requestId:{} ,参数:{}, map:{}", requestInfo.getRequestid(), build, map); + List> excelComments = (List>) map.get("errorData"); + StringBuilder message = new StringBuilder(""); + for (Map comments : excelComments) { + message.append(comments.get("message")).append("\n"); + } + requestInfo.getRequestManager().setMessage(message.toString()); + return FAILURE_AND_CONTINUE; + } + //增员 + String taxAgentName = importData.get(0).get("个税扣缴义务人").toString(); + List taxAgentPOS = getTaxAgentMapper().listByName(taxAgentName); + if(CollectionUtils.isEmpty(taxAgentPOS)){ + requestInfo.getRequestManager().setMessage("个税扣缴义务人不存在!"); + return FAILURE_AND_CONTINUE; + } + Long taxAgentId = Long.valueOf(taxAgentPOS.get(0).getId()); + Long employeeId = Long.valueOf(list.stream().filter(f -> f.salaryName.equals("员工id")).findFirst().map(EditToPaySIArchiveAction.SalaryField::getValue).orElse("-1")); + User user = new User(Integer.parseInt(uid)); + // 获取福利档案基础信息 + InsuranceArchivesBaseInfoPO insuranceArchivesBaseInfoPO = getInsuranceBaseInfoMapper().getOneByEmployeeIdAndPayOrg(taxAgentId, employeeId); + if(insuranceArchivesBaseInfoPO == null){ + requestInfo.getRequestManager().setMessage("该个税扣缴义务人下该员工不存在福利档案,请检查后重试!"); + return FAILURE_AND_CONTINUE; + } else if(!insuranceArchivesBaseInfoPO.getRunStatus().equals(EmployeeStatusEnum.STAY_ADD.getValue())){ + requestInfo.getRequestManager().setMessage("该个税扣缴义务人下该员工的福利档案状态不是待增员,无法进行增员操作,请检查后重试!"); + return FAILURE_AND_CONTINUE; + } + //增员 + Map resultMap = getSIArchivesService(user).stayAddToPay(Collections.singletonList(insuranceArchivesBaseInfoPO.getId())); + if (resultMap.get("type").toString().equals("fail")) { + requestInfo.getRequestManager().setMessage(resultMap.get("msg").toString()); + return FAILURE_AND_CONTINUE; + } + + + } catch (Exception e) { + log.error("福利档案编辑并增员异常", e); + requestInfo.getRequestManager().setMessage(e.getMessage()); + return FAILURE_AND_CONTINUE; + } + return SUCCESS; + } + + + class SalaryField { + + private String processField; + + private String salaryName; + + private String value; + + public String getProcessField() { + return processField; + } + + public void setProcessField(String processField) { + this.processField = processField; + } + + public String getSalaryName() { + return salaryName; + } + + public void setSalaryName(String salaryName) { + this.salaryName = salaryName; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public SalaryField(String processField, String salaryName, String value) { + this.processField = processField; + this.salaryName = salaryName; + this.value = value; + } + } +} diff --git a/src/com/engine/salary/action/EditToStopSIArchiveAction.java b/src/com/engine/salary/action/EditToStopSIArchiveAction.java new file mode 100644 index 000000000..1f2a612fd --- /dev/null +++ b/src/com/engine/salary/action/EditToStopSIArchiveAction.java @@ -0,0 +1,201 @@ +package com.engine.salary.action; + +import com.engine.common.util.ServiceUtil; +import com.engine.salary.entity.siarchives.param.SIArchiveImportParam; +import com.engine.salary.entity.siarchives.po.InsuranceArchivesBaseInfoPO; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import com.engine.salary.enums.siaccount.EmployeeStatusEnum; +import com.engine.salary.mapper.siarchives.InsuranceBaseInfoMapper; +import com.engine.salary.mapper.taxagent.TaxAgentMapper; +import com.engine.salary.service.SIArchivesService; +import com.engine.salary.service.SISchemeService; +import com.engine.salary.service.impl.SIArchivesServiceImpl; +import com.engine.salary.service.impl.SISchemeServiceImpl; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.db.MapperProxyFactory; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.Property; +import weaver.soa.workflow.request.RequestInfo; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * @Author: sy + * @Description: 编辑并减员福利档案 + * @Date: 2023/9/8 + **/ +@Slf4j +public class EditToStopSIArchiveAction implements Action { + private SISchemeService getSISchemeService(User user) { + return ServiceUtil.getService(SISchemeServiceImpl.class,user); + } + + private InsuranceBaseInfoMapper getInsuranceBaseInfoMapper() { + return MapperProxyFactory.getProxy(InsuranceBaseInfoMapper.class); + } + + private SIArchivesService getSIArchivesService(User user) { + return ServiceUtil.getService(SIArchivesServiceImpl.class,user); + } + + private TaxAgentMapper getTaxAgentMapper() { + return MapperProxyFactory.getProxy(TaxAgentMapper.class); + } + + private String tableName; + + + public String getTableName() { + return tableName; + } + + public void setTableName(String tableName) { + this.tableName = tableName; + } + + // 是否执行action的字段, 0代表不执行,其余代表执行 + private String enableField; + + public String getEnableField() { + return enableField; + } + + public void setEnableField(String enableField) { + this.enableField = enableField; + } + + @Override + public String execute(RequestInfo requestInfo) { + try { + Property[] properties = requestInfo.getMainTableInfo().getProperty(); + Map fieldMap = Arrays.stream(properties).collect(Collectors.toMap(Property::getName, + property -> Util.null2String(property.getValue()))); + + String enable = fieldMap.get(enableField); + if (StringUtils.isNotBlank(enable) && enable.equals("0")) { + // 不执行action + return SUCCESS; + } + RecordSet rs = new RecordSet(); + + String queryImageId = "select salaryname,processfield from " + tableName + " where workflowid = ?"; + rs.executeQuery(queryImageId, requestInfo.getWorkflowid()); + + List list = new ArrayList<>(); + while (rs.next()) { + String processField = rs.getString("processfield"); + String salaryName = rs.getString("salaryname"); + String value = fieldMap.get(processField); + list.add(new EditToStopSIArchiveAction.SalaryField(processField, salaryName, value)); + } + List> importData = new ArrayList<>(); + importData.add(SalaryEntityUtil.convert2Map(list, EditToStopSIArchiveAction.SalaryField::getSalaryName, EditToStopSIArchiveAction.SalaryField::getValue)); + //福利执行状态 + String runStatus = EmployeeStatusEnum.PAYING.getValue(); + + SIArchiveImportParam build = SIArchiveImportParam.builder() + .importDatas(importData) + .runStatus(runStatus) + .build(); + + //操作人 + String uid = list.stream().filter(f -> f.salaryName.equals("操作人")).findFirst().map(EditToStopSIArchiveAction.SalaryField::getValue).orElse("1"); + User user = new User(Integer.parseInt(uid)); + //更新/新建档案数据 + Map map = getSISchemeService(new User(Integer.parseInt(uid))).addSIArchive(build); + + List errorNotice = (List) map.get("errorData"); + if (CollectionUtils.isNotEmpty(errorNotice)) { + log.error("福利档案编辑并减员存在异常 requestId:{} ,参数:{}, map:{}", requestInfo.getRequestid(), build, map); + List> excelComments = (List>) map.get("errorData"); + StringBuilder message = new StringBuilder(""); + for (Map comments : excelComments) { + message.append(comments.get("message")).append("\n"); + } + requestInfo.getRequestManager().setMessage(message.toString()); + return FAILURE_AND_CONTINUE; + } + //刷新福利档案状态 + getSIArchivesService(user).handleStayDelData(Integer.parseInt(uid)); + //减员 + String taxAgentName = importData.get(0).get("个税扣缴义务人").toString(); + List taxAgentPOS = getTaxAgentMapper().listByName(taxAgentName); + if(CollectionUtils.isEmpty(taxAgentPOS)){ + requestInfo.getRequestManager().setMessage("个税扣缴义务人不存在!"); + return FAILURE_AND_CONTINUE; + } + Long taxAgentId = Long.valueOf(taxAgentPOS.get(0).getId()); + Long employeeId = Long.valueOf(list.stream().filter(f -> f.salaryName.equals("员工id")).findFirst().map(EditToStopSIArchiveAction.SalaryField::getValue).orElse("-1")); + + // 获取福利档案 + InsuranceArchivesBaseInfoPO insuranceArchivesBaseInfoPO = getInsuranceBaseInfoMapper().getOneByEmployeeIdAndPayOrg(taxAgentId, employeeId); + if(insuranceArchivesBaseInfoPO == null){ + requestInfo.getRequestManager().setMessage("该个税扣缴义务人下该员工不存在福利档案,请检查后重试!"); + return FAILURE_AND_CONTINUE; + } else if(!insuranceArchivesBaseInfoPO.getRunStatus().equals(EmployeeStatusEnum.STAY_DEL.getValue())){ + requestInfo.getRequestManager().setMessage("该个税扣缴义务人下该员工的福利档案状态不是待减员,无法进行减员操作,请检查后重试!"); + return FAILURE_AND_CONTINUE; + } + //减员 + Map resultMap = getSIArchivesService(user).stayDelToStop(Collections.singletonList(insuranceArchivesBaseInfoPO.getId())); + if (resultMap.get("type").toString().equals("fail")) { + requestInfo.getRequestManager().setMessage(resultMap.get("msg").toString()); + return FAILURE_AND_CONTINUE; + } + + + } catch (Exception e) { + log.error("福利档案编辑并减员异常", e); + requestInfo.getRequestManager().setMessage(e.getMessage()); + return FAILURE_AND_CONTINUE; + } + return SUCCESS; + } + + + class SalaryField { + + private String processField; + + private String salaryName; + + private String value; + + public String getProcessField() { + return processField; + } + + public void setProcessField(String processField) { + this.processField = processField; + } + + public String getSalaryName() { + return salaryName; + } + + public void setSalaryName(String salaryName) { + this.salaryName = salaryName; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public SalaryField(String processField, String salaryName, String value) { + this.processField = processField; + this.salaryName = salaryName; + this.value = value; + } + } +} diff --git a/src/com/engine/salary/action/FileSalaryAcctRecordAction.java b/src/com/engine/salary/action/FileSalaryAcctRecordAction.java new file mode 100644 index 000000000..838c4c494 --- /dev/null +++ b/src/com/engine/salary/action/FileSalaryAcctRecordAction.java @@ -0,0 +1,83 @@ +package com.engine.salary.action; + +import com.engine.common.util.ServiceUtil; +import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO; +import com.engine.salary.mapper.taxagent.TaxAgentMapper; +import com.engine.salary.service.SalaryAcctRecordService; +import com.engine.salary.service.impl.SalaryAcctRecordServiceImpl; +import com.engine.salary.util.db.MapperProxyFactory; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import weaver.general.BaseBean; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.Property; +import weaver.soa.workflow.request.RequestInfo; + +import java.util.Arrays; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * @author Harryxzy + * @ClassName FileSalaryAcctRecordAction + * @date 2023/12/13 9:17 + * @description 薪资核算记录归档action + */ +@Slf4j +public class FileSalaryAcctRecordAction implements Action { + + + private SalaryAcctRecordService getSalaryAcctRecordService(User user) { + return ServiceUtil.getService(SalaryAcctRecordServiceImpl.class, user); + } + + private TaxAgentMapper getTaxAgentMapper() { + return MapperProxyFactory.getProxy(TaxAgentMapper.class); + } + + + private String recordIdFieldName; + + + public String getRecordIdFieldName() { + return recordIdFieldName; + } + + public void setRecordIdFieldName(String recordIdFieldName) { + this.recordIdFieldName = recordIdFieldName; + } + + @Override + public String execute(RequestInfo requestInfo) { + Property[] properties = requestInfo.getMainTableInfo().getProperty(); + Map fieldMap = Arrays.stream(properties).collect(Collectors.toMap(Property::getName, + property -> Util.null2String(property.getValue()))); + String salaryAcctRecordId = fieldMap.get(recordIdFieldName); + if (StringUtils.isBlank(salaryAcctRecordId)) { + requestInfo.getRequestManager().setMessage("薪资核算记录不存在"); + return FAILURE_AND_CONTINUE; + } + User user = new User(); + user.setUid(1); + Long acctRecordId = Long.valueOf(salaryAcctRecordId); + SalaryAcctRecordPO salaryAcctRecordPO = getSalaryAcctRecordService(user).getById(acctRecordId); + if (salaryAcctRecordPO == null) { + requestInfo.getRequestManager().setMessage("薪资核算记录不存在,或已被删除"); + return FAILURE_AND_CONTINUE; + } + if (salaryAcctRecordPO.getStatus() > 1) { + BaseBean baseBean = new BaseBean(); + baseBean.writeLog("核算记录归档action, 该核算记录已经归档:" + salaryAcctRecordPO.getId()); + return SUCCESS; + } + try { + getSalaryAcctRecordService(user).file(acctRecordId); + } catch (Exception e) { + requestInfo.getRequestManager().setMessage(e.getMessage()); + return FAILURE_AND_CONTINUE; + } + return SUCCESS; + } +} diff --git a/src/com/engine/salary/action/InitSalaryAction.java b/src/com/engine/salary/action/InitSalaryAction.java new file mode 100644 index 000000000..af3ab875e --- /dev/null +++ b/src/com/engine/salary/action/InitSalaryAction.java @@ -0,0 +1,216 @@ +package com.engine.salary.action; + +import com.engine.common.util.ServiceUtil; +import com.engine.salary.entity.salaryarchive.param.SalaryArchiveImportActionParam; +import com.engine.salary.entity.salaryarchive.po.SalaryArchivePO; +import com.engine.salary.entity.taxagent.param.TaxAgentQueryParam; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import com.engine.salary.enums.salaryarchive.SalaryArchiveStatusEnum; +import com.engine.salary.mapper.archive.SalaryArchiveMapper; +import com.engine.salary.service.SalaryArchiveService; +import com.engine.salary.service.TaxAgentService; +import com.engine.salary.service.impl.SalaryArchiveServiceImpl; +import com.engine.salary.service.impl.TaxAgentServiceImpl; +import com.engine.salary.util.SalaryDateUtil; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.db.MapperProxyFactory; +import com.engine.salary.wrapper.SalaryArchiveWrapper; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.math.NumberUtils; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.Property; +import weaver.soa.workflow.request.RequestInfo; + +import java.util.*; +import java.util.stream.Collectors; + +@Slf4j +public class InitSalaryAction implements Action { + + + private SalaryArchiveWrapper getSalaryArchiveWrapper(User user) { + return ServiceUtil.getService(SalaryArchiveWrapper.class, user); + } + + private SalaryArchiveService getSalaryArchiveService(User user) { + return ServiceUtil.getService(SalaryArchiveServiceImpl.class, user); + } + + private TaxAgentService getTaxAgentService(User user) { + return ServiceUtil.getService(TaxAgentServiceImpl.class, user); + } + + private SalaryArchiveMapper getSalaryArchiveMapper() { + return MapperProxyFactory.getProxy(SalaryArchiveMapper.class); + } + + private String tableName; + + + private String archiveStatus; + + + public String getTableName() { + return tableName; + } + + public void setTableName(String tableName) { + this.tableName = tableName; + } + + // 是否执行action的字段, 0代表不执行,其余代表执行 + private String enableField; + + public String getEnableField() { + return enableField; + } + + public void setEnableField(String enableField) { + this.enableField = enableField; + } + + @Override + public String execute(RequestInfo requestInfo) { + try { + Property[] properties = requestInfo.getMainTableInfo().getProperty(); + Map fieldMap = Arrays.stream(properties).collect(Collectors.toMap(Property::getName, + property -> Util.null2String(property.getValue()))); + + String enable = fieldMap.get(enableField); + if (StringUtils.isNotBlank(enable) && enable.equals("0")) { + // 不执行action + return SUCCESS; + } + RecordSet rs = new RecordSet(); + + String queryImageId = "select salaryname,processfield from " + tableName + " where workflowid = ?"; + rs.executeQuery(queryImageId, requestInfo.getWorkflowid()); + + List list = new ArrayList<>(); + while (rs.next()) { + String processField = rs.getString("processfield"); + String salaryName = rs.getString("salaryname"); + String value = fieldMap.get(processField); + list.add(new SalaryField(processField, salaryName, value)); + } + + Map importDataMap = SalaryEntityUtil.convert2Map(list, SalaryField::getSalaryName, SalaryField::getValue); + + return doSalaryArchiveInit(requestInfo, importDataMap); + } catch (Exception e) { + log.error("定薪异常", e); + requestInfo.getRequestManager().setMessage(e.getMessage()); + return FAILURE_AND_CONTINUE; + } + } + + public String doSalaryArchiveInit(RequestInfo requestInfo, Map importDataMap) { + User user = new User(); + user.setLoginid("sysadmin"); + user.setUid(1); + List> importData = new ArrayList<>(); + if(!importDataMap.containsKey("生效日期")){ + importDataMap.put("生效日期", SalaryDateUtil.getFormatDate(new Date())); + } + if(!importDataMap.containsKey("最后发薪日期")){ + importDataMap.put("最后发薪日期", ""); + } + importData.add(importDataMap); + + // 首先判断是否已经存在薪资档案,且薪资档案状态为待定薪 + String taxAgentName = importDataMap.getOrDefault("个税扣缴义务人", "").toString(); + String empIdStr = importDataMap.getOrDefault("员工id", "").toString(); + if (StringUtils.isBlank(taxAgentName)) { + requestInfo.getRequestManager().setMessage("个税扣缴义务人不能为空"); + return FAILURE_AND_CONTINUE; + } + // 获取义务人信息 + List taxAgentPOS = getTaxAgentService(user).list(TaxAgentQueryParam.builder().name(taxAgentName).build()); + if (CollectionUtils.isEmpty(taxAgentPOS)) { + requestInfo.getRequestManager().setMessage("个税扣缴义务人不存在"); + return FAILURE_AND_CONTINUE; + } + Long taxAgentId = taxAgentPOS.get(0).getId(); + // 获取员工id + if (NumberUtils.isCreatable(empIdStr)) { + List salaryArchivePOList = getSalaryArchiveService(user).listSome(SalaryArchivePO.builder().taxAgentId(taxAgentId).employeeId(Long.valueOf(empIdStr)).build()); + if (CollectionUtils.isNotEmpty(salaryArchivePOList) && !salaryArchivePOList.get(0).getRunStatus().equals(SalaryArchiveStatusEnum.PENDING.getValue())) { + // 存在薪资档案,且薪资档案状态不是待定薪,修改状态为待定薪 + salaryArchivePOList.get(0).setRunStatus(SalaryArchiveStatusEnum.PENDING.getValue()); + salaryArchivePOList.get(0).setPayEndDate(null); + getSalaryArchiveMapper().update(salaryArchivePOList.get(0)); + } + } + + SalaryArchiveImportActionParam build = SalaryArchiveImportActionParam.builder() + .importDatas(importData) + .build(); + + if (StringUtils.isNotBlank(archiveStatus) && archiveStatus.equals(SalaryArchiveStatusEnum.PENDING.getValue())) { + build.setKeepStatus(true); + } + + //操作人 + String uid = importDataMap.getOrDefault("操作人", "1").toString(); + Map map = getSalaryArchiveWrapper(new User(Integer.parseInt(uid))).importSalaryArchiveInit(build); + + List errorNotice = (List) map.get("errorNotice"); + if (CollectionUtils.isNotEmpty(errorNotice)) { + log.error("定薪存在异常 requestId:{} ,参数:{}, map:{}", requestInfo.getRequestid(), build, map); + List> excelComments = (List>) map.get("errorNotice"); + StringBuilder message = new StringBuilder(""); + for (Map comments : excelComments) { + message.append(comments.get("message")).append("\n"); + } + requestInfo.getRequestManager().setMessage(message.toString()); + return FAILURE_AND_CONTINUE; + } + return SUCCESS; + } + + + + class SalaryField { + + private String processField; + + private String salaryName; + + private String value; + + public String getProcessField() { + return processField; + } + + public void setProcessField(String processField) { + this.processField = processField; + } + + public String getSalaryName() { + return salaryName; + } + + public void setSalaryName(String salaryName) { + this.salaryName = salaryName; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public SalaryField(String processField, String salaryName, String value) { + this.processField = processField; + this.salaryName = salaryName; + this.value = value; + } + } +} diff --git a/src/com/engine/salary/action/RehireAction.java b/src/com/engine/salary/action/RehireAction.java new file mode 100644 index 000000000..f0ac107f3 --- /dev/null +++ b/src/com/engine/salary/action/RehireAction.java @@ -0,0 +1,261 @@ +package com.engine.salary.action; + +import com.engine.common.util.ServiceUtil; +import com.engine.salary.entity.salaryarchive.param.SalaryArchiveImportActionParam; +import com.engine.salary.entity.salaryarchive.po.SalaryArchivePO; +import com.engine.salary.entity.taxagent.param.TaxAgentManageRangeSaveParam; +import com.engine.salary.entity.taxagent.param.TaxAgentQueryParam; +import com.engine.salary.entity.taxagent.param.TaxAgentRangeSaveParam; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import com.engine.salary.enums.salaryarchive.SalaryArchiveStatusEnum; +import com.engine.salary.enums.salarysob.TargetTypeEnum; +import com.engine.salary.mapper.archive.SalaryArchiveMapper; +import com.engine.salary.service.SalaryArchiveService; +import com.engine.salary.service.TaxAgentManageRangeService; +import com.engine.salary.service.TaxAgentService; +import com.engine.salary.service.impl.SalaryArchiveServiceImpl; +import com.engine.salary.service.impl.TaxAgentManageRangeServiceImpl; +import com.engine.salary.service.impl.TaxAgentServiceImpl; +import com.engine.salary.util.SalaryDateUtil; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.db.MapperProxyFactory; +import com.engine.salary.wrapper.SalaryArchiveWrapper; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.Property; +import weaver.soa.workflow.request.RequestInfo; + +import java.util.*; +import java.util.stream.Collectors; + +@Slf4j +public class RehireAction implements Action { + + + private SalaryArchiveWrapper getSalaryArchiveWrapper(User user) { + return ServiceUtil.getService(SalaryArchiveWrapper.class, user); + } + + private SalaryArchiveService getSalaryArchiveService(User user) { + return ServiceUtil.getService(SalaryArchiveServiceImpl.class, user); + } + + private SalaryArchiveMapper getSalaryArchiveMapper() { + return MapperProxyFactory.getProxy(SalaryArchiveMapper.class); + } + + private TaxAgentService getTaxAgentService(User user) { + return ServiceUtil.getService(TaxAgentServiceImpl.class, user); + } + + private TaxAgentManageRangeService getTaxAgentManageRangeService(User user) { + return ServiceUtil.getService(TaxAgentManageRangeServiceImpl.class, user); + } + + + + private String tableName; + + + public String getTableName() { + return tableName; + } + + public void setTableName(String tableName) { + this.tableName = tableName; + } + + // 是否执行action的字段, 0代表不执行,其余代表执行 + private String enableField; + + public String getEnableField() { + return enableField; + } + + public void setEnableField(String enableField) { + this.enableField = enableField; + } + + @Override + public String execute(RequestInfo requestInfo) { + try { + User user = new User(1); + Property[] properties = requestInfo.getMainTableInfo().getProperty(); + Map fieldMap = Arrays.stream(properties).collect(Collectors.toMap(Property::getName, + property -> Util.null2String(property.getValue()))); + + String enable = fieldMap.get(enableField); + if (StringUtils.isNotBlank(enable) && enable.equals("0")) { + // 不执行action + return SUCCESS; + } + + RecordSet rs = new RecordSet(); + + String queryImageId = "select salaryname,processfield from " + tableName + " where workflowid = ?"; + rs.executeQuery(queryImageId, requestInfo.getWorkflowid()); + + List list = new ArrayList<>(); + while (rs.next()) { + String processField = rs.getString("processfield"); + String salaryName = rs.getString("salaryname"); + String value = fieldMap.get(processField); + list.add(new SalaryField(processField, salaryName, value)); + } + Map salaryFieldMap = SalaryEntityUtil.convert2Map(list, SalaryField::getSalaryName, SalaryField::getValue); + String taxAgentName = salaryFieldMap.getOrDefault("个税扣缴义务人", "").toString(); + String empIdStr = salaryFieldMap.getOrDefault("员工id", "").toString(); + if (StringUtils.isBlank(taxAgentName) || StringUtils.isBlank(empIdStr)) { + requestInfo.getRequestManager().setMessage("个税扣缴义务人、或员工id不能为空"); + return FAILURE_AND_CONTINUE; + } + // 获取义务人信息 + List taxAgentPOS = getTaxAgentService(user).list(TaxAgentQueryParam.builder().name(taxAgentName).build()); + if (CollectionUtils.isEmpty(taxAgentPOS)) { + requestInfo.getRequestManager().setMessage("个税扣缴义务人不存在"); + return FAILURE_AND_CONTINUE; + } + // 先获取该个税扣缴义务人下,该员工的薪资档案 + Long taxAgentId = taxAgentPOS.get(0).getId(); + Long employeeId = Long.valueOf(empIdStr); + List salaryArchivePOS = getSalaryArchiveService(user).listSome(SalaryArchivePO.builder().taxAgentId(taxAgentId).employeeId(employeeId).build()); + if (CollectionUtils.isEmpty(salaryArchivePOS) || salaryArchivePOS.get(0).getRunStatus().equals(SalaryArchiveStatusEnum.PENDING.getValue())){ + // 直接走定薪action生成档案 + InitSalaryAction initSalaryAction = new InitSalaryAction(); + return initSalaryAction.doSalaryArchiveInit(requestInfo, salaryFieldMap); + + // requestInfo.getRequestManager().setMessage("该个税扣缴义务人下,该员工不存在薪资档案!"); + // return FAILURE_AND_CONTINUE; + } else if (salaryArchivePOS.get(0).getRunStatus().equals(SalaryArchiveStatusEnum.STOP_FROM_PENDING.getValue())) { + // 先把状态变成待定薪然后走定薪action + salaryArchivePOS.get(0).setRunStatus(SalaryArchiveStatusEnum.PENDING.getValue()); + salaryArchivePOS.get(0).setPayEndDate(null); + getSalaryArchiveMapper().update(salaryArchivePOS.get(0)); + InitSalaryAction initSalaryAction = new InitSalaryAction(); + return initSalaryAction.doSalaryArchiveInit(requestInfo, salaryFieldMap); + + // requestInfo.getRequestManager().setMessage("该个税扣缴义务人下,该员工没有发过薪。需取消停薪后,申请定薪流程!"); + // return FAILURE_AND_CONTINUE; + } else { + if (salaryArchivePOS.get(0).getRunStatus().equals(SalaryArchiveStatusEnum.STOP_FROM_SUSPEND.getValue())) { + // 停薪来自待停薪 1、取消停薪 + getSalaryArchiveWrapper(user).cancelStop(Collections.singletonList(salaryArchivePOS.get(0).getId())); + } + if (salaryArchivePOS.get(0).getRunStatus().equals(SalaryArchiveStatusEnum.STOP_FROM_SUSPEND.getValue()) || + salaryArchivePOS.get(0).getRunStatus().equals(SalaryArchiveStatusEnum.SUSPEND.getValue())) { + // 1、如果不在人员范围内则把他加入义务人的人员范围,2、删除待办 + addTaxAgentRangeIfNotExist(taxAgentId, employeeId, user); + getSalaryArchiveWrapper(user).deleteSuspendTodo(Collections.singletonList(salaryArchivePOS.get(0).getId())); + } + + // 调薪 + List> importData = new ArrayList<>(); + importData.add(SalaryEntityUtil.convert2Map(list, SalaryField::getSalaryName, SalaryField::getValue)); + + SalaryArchiveImportActionParam build = SalaryArchiveImportActionParam.builder() + .importDatas(importData) + .build(); + + //操作人 + String uid = list.stream().filter(f -> f.salaryName.equals("操作人")).findFirst().map(RehireAction.SalaryField::getValue).orElse("1"); + Map map = getSalaryArchiveWrapper(new User(Integer.parseInt(uid))).adjustmentSalaryArchive(build); + + List errorNotice = (List) map.get("errorNotice"); + if (CollectionUtils.isNotEmpty(errorNotice)) { + // 回滚档案状态 + getSalaryArchiveMapper().update(salaryArchivePOS.get(0)); + log.error("调薪存在异常 requestId:{} map:{}", requestInfo.getRequestid(), map); + List> excelComments = (List>) map.get("errorNotice"); + StringBuilder message = new StringBuilder(""); + for (Map comments : excelComments) { + message.append(comments.get("message")).append("\n"); + } + requestInfo.getRequestManager().setMessage(message.toString()); + return FAILURE_AND_CONTINUE; + } + // 如果有起始发薪日期字段,则更新档案的起始发薪日期 + String startPayDate = salaryFieldMap.getOrDefault("起始发薪日期", "").toString(); + if (StringUtils.isNotBlank(startPayDate)) { + Date date = SalaryDateUtil.dateStrToLocalDate(startPayDate); + if (date != null) { + Long salaryArchiveId = salaryArchivePOS.get(0).getId(); + getSalaryArchiveMapper().updatePayStartDateById(salaryArchiveId, date); + } + + } + } + } catch (Exception e) { + log.error("返聘调薪异常", e); + requestInfo.getRequestManager().setMessage(e.getMessage()); + return FAILURE_AND_CONTINUE; + } + return SUCCESS; + } + + + + + private void addTaxAgentRangeIfNotExist(Long taxAgentId, Long employeeId, User user){ + // 获取该义务人下人员范围 + Collection empIds = getTaxAgentService(user).listEmployeeIdsInTaxAgent(taxAgentId); + if (!empIds.contains(employeeId)) { + //将人员添加进个税扣缴义务人中 + TaxAgentManageRangeSaveParam.TaxAgentSubAdminRangeTargetParam taxAgentSubAdminRangeTargetParam = new TaxAgentManageRangeSaveParam.TaxAgentSubAdminRangeTargetParam(); + taxAgentSubAdminRangeTargetParam.setTargetId(employeeId); + taxAgentSubAdminRangeTargetParam.setTargetType(TargetTypeEnum.EMPLOYEE); + + TaxAgentRangeSaveParam taxAgentRangeSaveParam = new TaxAgentRangeSaveParam(); + taxAgentRangeSaveParam.setTaxAgentId(taxAgentId); + taxAgentRangeSaveParam.setIncludeType(1); + taxAgentRangeSaveParam.setEmployeeStatus(Arrays.asList("0", "1", "2", "3", "4", "5", "6")); + taxAgentRangeSaveParam.setTargetParams(Collections.singletonList(taxAgentSubAdminRangeTargetParam)); + taxAgentRangeSaveParam.setSync(true); + getTaxAgentManageRangeService(user).save(taxAgentRangeSaveParam); + } + } + + + class SalaryField { + + private String processField; + + private String salaryName; + + private String value; + + public String getProcessField() { + return processField; + } + + public void setProcessField(String processField) { + this.processField = processField; + } + + public String getSalaryName() { + return salaryName; + } + + public void setSalaryName(String salaryName) { + this.salaryName = salaryName; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public SalaryField(String processField, String salaryName, String value) { + this.processField = processField; + this.salaryName = salaryName; + this.value = value; + } + } +} diff --git a/src/com/engine/salary/action/SalaryAcctFileByIdAction.java b/src/com/engine/salary/action/SalaryAcctFileByIdAction.java new file mode 100644 index 000000000..710233ecb --- /dev/null +++ b/src/com/engine/salary/action/SalaryAcctFileByIdAction.java @@ -0,0 +1,64 @@ +package com.engine.salary.action; + +import com.engine.common.util.ServiceUtil; +import com.engine.salary.service.SalaryAcctRecordService; +import com.engine.salary.service.impl.SalaryAcctRecordServiceImpl; +import com.engine.salary.util.SalaryI18nUtil; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang.StringUtils; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.Property; +import weaver.soa.workflow.request.RequestInfo; + +import java.util.Arrays; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * @Author: sy + * @Description: 通过薪资核算id归档台账记录 + * @Date: 2023/7/18 + **/ +@Slf4j +public class SalaryAcctFileByIdAction implements Action { + private SalaryAcctRecordService getSalaryAcctRecordService(User user) { + return ServiceUtil.getService(SalaryAcctRecordServiceImpl.class, user); + } + + private String acctRecordId; + + public String getAcctRecordId() { + return acctRecordId; + } + + public void setAcctRecordId(String acctRecordId) { + this.acctRecordId = acctRecordId; + } + + @Override + public String execute(RequestInfo requestInfo) { + User user = requestInfo.getRequestManager().getUser(); + + Property[] properties = requestInfo.getMainTableInfo().getProperty(); + Map fieldMap = Arrays.stream(properties).collect(Collectors.toMap(Property::getName, + property -> Util.null2String(property.getValue()))); + + Long salaryAcctId = StringUtils.isNotBlank(fieldMap.get(acctRecordId)) ? Long.parseLong(fieldMap.get(acctRecordId)) : 0L; + + if (!salaryAcctId.equals(0L)) { + try { + getSalaryAcctRecordService(user).file(salaryAcctId); + } catch (Exception e) { + log.error("薪资核算归档异常", e); + requestInfo.getRequestManager().setMessage(e.getMessage()); + return FAILURE_AND_CONTINUE; + } + } else { + requestInfo.getRequestManager().setMessage(SalaryI18nUtil.getI18nLabel(542300, "薪资核算记录不存在或已被删除")); + return FAILURE_AND_CONTINUE; + } + return SUCCESS; + } +} diff --git a/src/com/engine/salary/action/SendSalaryAction.java b/src/com/engine/salary/action/SendSalaryAction.java new file mode 100644 index 000000000..39705e5c2 --- /dev/null +++ b/src/com/engine/salary/action/SendSalaryAction.java @@ -0,0 +1,136 @@ +package com.engine.salary.action; + +import com.engine.common.util.ServiceUtil; +import com.engine.salary.biz.SalarySendInfoBiz; +import com.engine.salary.entity.salaryBill.param.SalarySendGrantParam; +import com.engine.salary.entity.salaryBill.po.SalarySendPO; +import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO; +import com.engine.salary.service.SalaryAcctRecordService; +import com.engine.salary.service.SalaryBillService; +import com.engine.salary.service.SalarySendService; +import com.engine.salary.service.SalaryTemplateService; +import com.engine.salary.service.impl.SalaryAcctRecordServiceImpl; +import com.engine.salary.service.impl.SalaryBillServiceImpl; +import com.engine.salary.service.impl.SalarySendServiceImpl; +import com.engine.salary.service.impl.SalaryTemplateServiceImpl; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.Property; +import weaver.soa.workflow.request.RequestInfo; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * @author Harryxzy + * @ClassName FileSalaryAcctRecordAction + * @date 2023/12/13 9:17 + * @description 工资单发放action + */ +@Slf4j +public class SendSalaryAction implements Action { + + + private SalaryAcctRecordService getSalaryAcctRecordService(User user) { + return ServiceUtil.getService(SalaryAcctRecordServiceImpl.class, user); + } + + private SalarySendService getSalarySendService(User user) { + return ServiceUtil.getService(SalarySendServiceImpl.class, user); + } + + private SalaryTemplateService getSalaryTemplateService(User user) { + return ServiceUtil.getService(SalaryTemplateServiceImpl.class, user); + } + + private SalarySendInfoBiz salarySendInfoMapper = new SalarySendInfoBiz(); + + private SalaryBillService getSalaryBillService(User user) { + return ServiceUtil.getService(SalaryBillServiceImpl.class, user); + } + + + /** + * 发放id(核算记录id,工资单id)流程字段名 + */ + private String idFieldName; + + /** + * 根据什么id(核算记录id,工资单id)发工资单 + */ + private String sendBy; + + // 是否执行action的字段, 0代表不执行,其余代表执行 + private String enableField; + + public String getEnableField() { + return enableField; + } + + public void setEnableField(String enableField) { + this.enableField = enableField; + } + + + @Override + public String execute(RequestInfo requestInfo) { + Property[] properties = requestInfo.getMainTableInfo().getProperty(); + Map fieldMap = Arrays.stream(properties).collect(Collectors.toMap(Property::getName, + property -> Util.null2String(property.getValue()))); + + String enable = fieldMap.get(enableField); + if (StringUtils.isNotBlank(enable) && enable.equals("0")) { + // 不执行action + return SUCCESS; + } + + String idStr = fieldMap.get(idFieldName); + if (StringUtils.isBlank(idStr)) { + requestInfo.getRequestManager().setMessage("核算记录id或工资单id不能为空"); + return FAILURE_AND_CONTINUE; + } + User user = new User(); + user.setUid(1); + Long id = Long.valueOf(idStr); + SalarySendPO salarySendPO; + if(!org.h2.util.StringUtils.isNullOrEmpty(sendBy) && sendBy.equals("salaryAcctRecordId")) { + // 根据核算记录id发 + SalaryAcctRecordPO salaryAcctRecordPO = getSalaryAcctRecordService(user).getById(id); + if (salaryAcctRecordPO == null) { + requestInfo.getRequestManager().setMessage("薪资核算记录不存在,或已被删除"); + return FAILURE_AND_CONTINUE; + } + if (salaryAcctRecordPO.getStatus() == 1) { + requestInfo.getRequestManager().setMessage("核算记录还未归档,请先归档"); + return FAILURE_AND_CONTINUE; + } + // 获取工资单id + List salarySendPOList = getSalarySendService(user).listSome(SalarySendPO.builder().salaryAccountingId(id).sendStatus(0).build()); + salarySendPO = salarySendPOList.get(0); + } else if (!org.h2.util.StringUtils.isNullOrEmpty(sendBy) && sendBy.equals("salarySendId")) { + // 根据工资单发 + salarySendPO = getSalarySendService(user).getById(id); + } else { + requestInfo.getRequestManager().setMessage("请先维护根据什么id发放工资单的sendBy参数"); + return FAILURE_AND_CONTINUE; + } + + if (salarySendPO == null || salarySendPO.getId() == null) { + requestInfo.getRequestManager().setMessage("工资单不存在或已被删除!"); + return FAILURE_AND_CONTINUE; + } + try { + // 全部发放 + getSalaryBillService(user).grant(SalarySendGrantParam.builder().salarySendId(salarySendPO.getId()).build()); + } catch (Exception e) { + requestInfo.getRequestManager().setMessage(e.getMessage()); + return FAILURE_AND_CONTINUE; + } + return SUCCESS; + } +} diff --git a/src/com/engine/salary/action/StayAddToPaySIArchiveAction.java b/src/com/engine/salary/action/StayAddToPaySIArchiveAction.java new file mode 100644 index 000000000..371bdd8ee --- /dev/null +++ b/src/com/engine/salary/action/StayAddToPaySIArchiveAction.java @@ -0,0 +1,171 @@ +package com.engine.salary.action; + +import com.engine.common.util.ServiceUtil; +import com.engine.salary.entity.siarchives.po.InsuranceArchivesBaseInfoPO; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import com.engine.salary.enums.siaccount.EmployeeStatusEnum; +import com.engine.salary.mapper.siarchives.InsuranceBaseInfoMapper; +import com.engine.salary.mapper.taxagent.TaxAgentMapper; +import com.engine.salary.service.SIArchivesService; +import com.engine.salary.service.impl.SIArchivesServiceImpl; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.db.MapperProxyFactory; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.Property; +import weaver.soa.workflow.request.RequestInfo; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * @Author: sy + * @Description: 福利档案增员action + * @Date: 2023/8/22 + **/ +@Slf4j +public class StayAddToPaySIArchiveAction implements Action { + + private InsuranceBaseInfoMapper getInsuranceBaseInfoMapper() { + return MapperProxyFactory.getProxy(InsuranceBaseInfoMapper.class); + } + + private SIArchivesService getSIArchivesService(User user) { + return ServiceUtil.getService(SIArchivesServiceImpl.class,user); + } + + + private TaxAgentMapper getTaxAgentMapper() { + return MapperProxyFactory.getProxy(TaxAgentMapper.class); + } + + private String tableName; + + + public String getTableName() { + return tableName; + } + + public void setTableName(String tableName) { + this.tableName = tableName; + } + + // 是否执行action的字段, 0代表不执行,其余代表执行 + private String enableField; + + public String getEnableField() { + return enableField; + } + + public void setEnableField(String enableField) { + this.enableField = enableField; + } + + @Override + public String execute(RequestInfo requestInfo) { + try { + + Property[] properties = requestInfo.getMainTableInfo().getProperty(); + Map fieldMap = Arrays.stream(properties).collect(Collectors.toMap(Property::getName, + property -> Util.null2String(property.getValue()))); + + String enable = fieldMap.get(enableField); + if (StringUtils.isNotBlank(enable) && enable.equals("0")) { + // 不执行action + return SUCCESS; + } + RecordSet rs = new RecordSet(); + + String queryImageId = "select salaryname,processfield from " + tableName + " where workflowid = ?"; + rs.executeQuery(queryImageId, requestInfo.getWorkflowid()); + + List list = new ArrayList<>(); + while (rs.next()) { + String processField = rs.getString("processfield"); + String salaryName = rs.getString("salaryname"); + String value = fieldMap.get(processField); + list.add(new StayAddToPaySIArchiveAction.SalaryField(processField, salaryName, value)); + } + // 流程数据 + Map importDataMap = SalaryEntityUtil.convert2Map(list, StayAddToPaySIArchiveAction.SalaryField::getSalaryName, StayAddToPaySIArchiveAction.SalaryField::getValue); + String taxAgentName = importDataMap.getOrDefault("个税扣缴义务人", "").toString(); + List taxAgentPOS = getTaxAgentMapper().listByName(taxAgentName); + if(CollectionUtils.isEmpty(taxAgentPOS)){ + requestInfo.getRequestManager().setMessage("个税扣缴义务人不存在!"); + return FAILURE_AND_CONTINUE; + } + Long taxAgentId = Long.valueOf(taxAgentPOS.get(0).getId()); + Long employeeId = Long.valueOf(importDataMap.getOrDefault("员工id", "-1").toString()); + + //操作人 + String uid = importDataMap.getOrDefault("操作人","1").toString(); + User user = new User(Integer.parseInt(uid)); + // 获取福利档案基础信息 + InsuranceArchivesBaseInfoPO insuranceArchivesBaseInfoPO = getInsuranceBaseInfoMapper().getOneByEmployeeIdAndPayOrg(taxAgentId, employeeId); + if(insuranceArchivesBaseInfoPO == null){ + requestInfo.getRequestManager().setMessage("该个税扣缴义务人下该员工不存在福利档案,请检查后重试!"); + return FAILURE_AND_CONTINUE; + } else if(!insuranceArchivesBaseInfoPO.getRunStatus().equals(EmployeeStatusEnum.STAY_ADD.getValue())){ + requestInfo.getRequestManager().setMessage("该个税扣缴义务人下该员工的福利档案状态不是待增员,无法进行增员操作,请检查后重试!"); + return FAILURE_AND_CONTINUE; + } + //增员 + Map resultMap = getSIArchivesService(user).stayAddToPay(Collections.singletonList(insuranceArchivesBaseInfoPO.getId())); + if (resultMap.get("type").toString().equals("fail")) { + requestInfo.getRequestManager().setMessage(resultMap.get("msg").toString()); + return FAILURE_AND_CONTINUE; + } + + } catch (Exception e) { + log.error("增员异常", e); + requestInfo.getRequestManager().setMessage(e.getMessage()); + return FAILURE_AND_CONTINUE; + } + return SUCCESS; + } + + + class SalaryField { + + private String processField; + + private String salaryName; + + private String value; + + public String getProcessField() { + return processField; + } + + public void setProcessField(String processField) { + this.processField = processField; + } + + public String getSalaryName() { + return salaryName; + } + + public void setSalaryName(String salaryName) { + this.salaryName = salaryName; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public SalaryField(String processField, String salaryName, String value) { + this.processField = processField; + this.salaryName = salaryName; + this.value = value; + } + } +} diff --git a/src/com/engine/salary/action/StayDelToStopSIArchiveAction.java b/src/com/engine/salary/action/StayDelToStopSIArchiveAction.java new file mode 100644 index 000000000..b715b9eea --- /dev/null +++ b/src/com/engine/salary/action/StayDelToStopSIArchiveAction.java @@ -0,0 +1,196 @@ +package com.engine.salary.action; + +import cn.hutool.core.util.StrUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.salary.entity.siarchives.po.InsuranceArchivesBaseInfoPO; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import com.engine.salary.enums.siaccount.EmployeeStatusEnum; +import com.engine.salary.mapper.siarchives.InsuranceBaseInfoMapper; +import com.engine.salary.mapper.taxagent.TaxAgentMapper; +import com.engine.salary.service.SIArchivesService; +import com.engine.salary.service.impl.SIArchivesServiceImpl; +import com.engine.salary.util.SalaryDateUtil; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.db.MapperProxyFactory; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.Property; +import weaver.soa.workflow.request.RequestInfo; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * @Author: sy + * @Description: 福利档案减员action + * @Date: 2023/8/22 + **/ +@Slf4j +public class StayDelToStopSIArchiveAction implements Action { + + private InsuranceBaseInfoMapper getInsuranceBaseInfoMapper() { + return MapperProxyFactory.getProxy(InsuranceBaseInfoMapper.class); + } + + private SIArchivesService getSIArchivesService(User user) { + return ServiceUtil.getService(SIArchivesServiceImpl.class,user); + } + + private TaxAgentMapper getTaxAgentMapper() { + return MapperProxyFactory.getProxy(TaxAgentMapper.class); + } + + private String tableName; + + + public String getTableName() { + return tableName; + } + + public void setTableName(String tableName) { + this.tableName = tableName; + } + + // 是否执行action的字段, 0代表不执行,其余代表执行 + private String enableField; + + public String getEnableField() { + return enableField; + } + + public void setEnableField(String enableField) { + this.enableField = enableField; + } + + @Override + public String execute(RequestInfo requestInfo) { + try { + + Property[] properties = requestInfo.getMainTableInfo().getProperty(); + Map fieldMap = Arrays.stream(properties).collect(Collectors.toMap(Property::getName, + property -> Util.null2String(property.getValue()))); + + String enable = fieldMap.get(enableField); + if (StringUtils.isNotBlank(enable) && enable.equals("0")) { + // 不执行action + return SUCCESS; + } + RecordSet rs = new RecordSet(); + + String queryImageId = "select salaryname,processfield from " + tableName + " where workflowid = ?"; + rs.executeQuery(queryImageId, requestInfo.getWorkflowid()); + + List list = new ArrayList<>(); + while (rs.next()) { + String processField = rs.getString("processfield"); + String salaryName = rs.getString("salaryname"); + String value = fieldMap.get(processField); + list.add(new StayDelToStopSIArchiveAction.SalaryField(processField, salaryName, value)); + } + // 流程数据 + Map importDataMap = SalaryEntityUtil.convert2Map(list, StayDelToStopSIArchiveAction.SalaryField::getSalaryName, StayDelToStopSIArchiveAction.SalaryField::getValue); + String taxAgentName = importDataMap.getOrDefault("个税扣缴义务人", "").toString(); + List taxAgentPOS = getTaxAgentMapper().listByName(taxAgentName); + if(CollectionUtils.isEmpty(taxAgentPOS)){ + requestInfo.getRequestManager().setMessage("个税扣缴义务人不存在!"); + return FAILURE_AND_CONTINUE; + } + Long taxAgentId = Long.valueOf( taxAgentPOS.get(0).getId() ); + Long employeeId = Long.valueOf(importDataMap.getOrDefault("员工id", "-1").toString()); + + String payEndYearMonth = importDataMap.getOrDefault("最后缴纳月", "").toString(); + // 如果只有一个“最后缴纳月”, 代表社保、公积金、其他均使用同一个最后缴纳月 + String fundEndYearMonth = importDataMap.getOrDefault("公积金最后缴纳月", "").toString(); + String otherEndYearMonth = importDataMap.getOrDefault("其他福利最后缴纳月", "").toString(); + if (StrUtil.isNotBlank(payEndYearMonth) && !SalaryDateUtil.checkYearMonth(payEndYearMonth)) { + requestInfo.getRequestManager().setMessage("最后缴纳月格式有误,正确格式示例为'2021-01'"); + return FAILURE_AND_CONTINUE; + } + + if (StrUtil.isNotBlank(fundEndYearMonth) && !SalaryDateUtil.checkYearMonth(fundEndYearMonth)) { + requestInfo.getRequestManager().setMessage("公积金最后缴纳月格式有误,正确格式示例为'2021-01'"); + return FAILURE_AND_CONTINUE; + } + + if (StrUtil.isNotBlank(otherEndYearMonth) && !SalaryDateUtil.checkYearMonth(otherEndYearMonth)) { + requestInfo.getRequestManager().setMessage("其他福利最后缴纳月格式有误,正确格式示例为'2021-01'"); + return FAILURE_AND_CONTINUE; + } + + //操作人 + String uid = importDataMap.getOrDefault("操作人","1").toString(); + User user = new User(Integer.parseInt(uid)); + // 获取福利档案 + InsuranceArchivesBaseInfoPO insuranceArchivesBaseInfoPO = getInsuranceBaseInfoMapper().getOneByEmployeeIdAndPayOrg(taxAgentId, employeeId); + if(insuranceArchivesBaseInfoPO == null){ + requestInfo.getRequestManager().setMessage("该个税扣缴义务人下该员工不存在福利档案,请检查后重试!"); + return FAILURE_AND_CONTINUE; + } else if(StrUtil.isBlank(payEndYearMonth) && !insuranceArchivesBaseInfoPO.getRunStatus().equals(EmployeeStatusEnum.STAY_DEL.getValue())){ + requestInfo.getRequestManager().setMessage("该个税扣缴义务人下该员工的福利档案状态不是待减员,无法进行减员操作,请检查后重试!"); + return FAILURE_AND_CONTINUE; + } + //减员 + Map resultMap = new HashMap<>(); + if (StrUtil.isBlank(payEndYearMonth)) { + resultMap = getSIArchivesService(user).stayDelToStop(Collections.singletonList(insuranceArchivesBaseInfoPO.getId())); + } else { + resultMap = getSIArchivesService(user).stopWithoutLimit(Collections.singletonList(insuranceArchivesBaseInfoPO.getId()), payEndYearMonth, fundEndYearMonth, otherEndYearMonth); + } + if (resultMap.get("type").toString().equals("fail")) { + requestInfo.getRequestManager().setMessage(resultMap.get("msg").toString()); + return FAILURE_AND_CONTINUE; + } + + } catch (Exception e) { + log.error("减员异常", e); + requestInfo.getRequestManager().setMessage(e.getMessage()); + return FAILURE_AND_CONTINUE; + } + return SUCCESS; + } + + + class SalaryField { + + private String processField; + + private String salaryName; + + private String value; + + public String getProcessField() { + return processField; + } + + public void setProcessField(String processField) { + this.processField = processField; + } + + public String getSalaryName() { + return salaryName; + } + + public void setSalaryName(String salaryName) { + this.salaryName = salaryName; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public SalaryField(String processField, String salaryName, String value) { + this.processField = processField; + this.salaryName = salaryName; + this.value = value; + } + } +} diff --git a/src/com/engine/salary/action/StopSalaryAction.java b/src/com/engine/salary/action/StopSalaryAction.java new file mode 100644 index 000000000..10d4d765a --- /dev/null +++ b/src/com/engine/salary/action/StopSalaryAction.java @@ -0,0 +1,203 @@ +package com.engine.salary.action; + +import com.engine.common.util.ServiceUtil; +import com.engine.salary.entity.salaryarchive.po.SalaryArchivePO; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import com.engine.salary.enums.salaryarchive.SalaryArchiveStatusEnum; +import com.engine.salary.mapper.archive.SalaryArchiveMapper; +import com.engine.salary.mapper.taxagent.TaxAgentMapper; +import com.engine.salary.service.SalaryArchiveService; +import com.engine.salary.service.impl.SalaryArchiveServiceImpl; +import com.engine.salary.util.SalaryDateUtil; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.db.MapperProxyFactory; +import com.mzlion.core.utils.BeanUtils; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.math.NumberUtils; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.Property; +import weaver.soa.workflow.request.RequestInfo; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * @author Harryxzy + * @ClassName stopSalaryAction + * @date 2023/06/15 9:17 + * @description 停薪处理 + */ +@Slf4j +public class StopSalaryAction implements Action { + + + private SalaryArchiveService getSalaryArchiveService(User user) { + return ServiceUtil.getService(SalaryArchiveServiceImpl.class, user); + } + + private SalaryArchiveMapper getSalaryArchiveMapper() { + return MapperProxyFactory.getProxy(SalaryArchiveMapper.class); + } + + private TaxAgentMapper getTaxAgentMapper() { + return MapperProxyFactory.getProxy(TaxAgentMapper.class); + } + + + private String tableName; + + + public String getTableName() { + return tableName; + } + + public void setTableName(String tableName) { + this.tableName = tableName; + } + + // 是否执行action的字段, 0代表不执行,其余代表执行 + private String enableField; + + public String getEnableField() { + return enableField; + } + + public void setEnableField(String enableField) { + this.enableField = enableField; + } + + @Override + public String execute(RequestInfo requestInfo) { + try { + + Property[] properties = requestInfo.getMainTableInfo().getProperty(); + Map fieldMap = Arrays.stream(properties).collect(Collectors.toMap(Property::getName, + property -> Util.null2String(property.getValue()))); + + String enable = fieldMap.get(enableField); + if (StringUtils.isNotBlank(enable) && enable.equals("0")) { + // 不执行action + return SUCCESS; + } + RecordSet rs = new RecordSet(); + + + String queryImageId = "select salaryname,processfield from " + tableName + " where workflowid = ?"; + rs.executeQuery(queryImageId, requestInfo.getWorkflowid()); + + List list = new ArrayList<>(); + while (rs.next()) { + String processField = rs.getString("processfield"); + String salaryName = rs.getString("salaryname"); + String value = fieldMap.get(processField); + list.add(new StopSalaryAction.SalaryField(processField, salaryName, value)); + } + // 流程数据 + Map importDataMap = SalaryEntityUtil.convert2Map(list, StopSalaryAction.SalaryField::getSalaryName, StopSalaryAction.SalaryField::getValue); + //操作人 + String uid = importDataMap.getOrDefault("操作人","1").toString(); + User user = new User(Integer.parseInt(uid)); + + String taxAgentName = importDataMap.getOrDefault("个税扣缴义务人", "").toString(); + List taxAgentPOS = getTaxAgentMapper().listByName(taxAgentName); + if(CollectionUtils.isEmpty(taxAgentPOS)){ + requestInfo.getRequestManager().setMessage("个税扣缴义务人不存在!"); + log.error("停薪异常 requestId:{} msg:{}", requestInfo.getRequestid(), taxAgentName + "个税扣缴义务人不存在!"); + return FAILURE_AND_CONTINUE; + } + Long taxAgentId = Long.valueOf( taxAgentPOS.get(0).getId() ); + Long employeeId = Long.valueOf(importDataMap.getOrDefault("员工id", "-1").toString()); + if( importDataMap.get("最后发薪日期") == null || StringUtils.isBlank(importDataMap.get("最后发薪日期").toString())){ + requestInfo.getRequestManager().setMessage("缺少最后发薪日期字段!"); + log.error("停薪异常 requestId:{} msg:{}", requestInfo.getRequestid(), "缺少最后发薪日期字段!"); + return FAILURE_AND_CONTINUE; + }else if(SalaryDateUtil.stringToDate(importDataMap.get("最后发薪日期").toString()) == null){ + requestInfo.getRequestManager().setMessage("最后发薪日期格式错误,格式为yyyy-MM-dd"); + log.error("停薪异常 requestId:{} msg:{}", requestInfo.getRequestid(), "最后发薪日期格式错误,格式为yyyy-MM-dd" + importDataMap.get("最后发薪日期").toString()); + return FAILURE_AND_CONTINUE; + } + + // 获取薪资档案 + List salaryArchiveList = getSalaryArchiveService(user).listSome(SalaryArchivePO.builder().taxAgentId(taxAgentId).employeeId(employeeId).deleteType(NumberUtils.INTEGER_ZERO).build()); + if(CollectionUtils.isEmpty(salaryArchiveList)){ + requestInfo.getRequestManager().setMessage("该个税扣缴义务人下该员工不存在薪资档案,请检查后重试!"); + log.error("停薪异常 requestId:{} msg:{}", requestInfo.getRequestid(), taxAgentId +"_"+ employeeId+"该个税扣缴义务人下该员工不存在薪资档案,请检查后重试!"); + return FAILURE_AND_CONTINUE; + } + if(salaryArchiveList.size() > 1){ + requestInfo.getRequestManager().setMessage("该个税扣缴义务人下该员工存在多条薪资档案记录,请检查后重试!"); + log.error("停薪异常 requestId:{} msg:{}", requestInfo.getRequestid(), taxAgentId +"_"+ employeeId+"该个税扣缴义务人下该员工存在多条薪资档案记录,请检查后重试!"); + return FAILURE_AND_CONTINUE; + } + // 设置最后发薪日期 + SalaryArchivePO salaryArchivePO = salaryArchiveList.get(0); + SalaryArchivePO updatePO = new SalaryArchivePO(); + BeanUtils.copyProperties(salaryArchivePO,updatePO); + if(StringUtils.equals(salaryArchivePO.getRunStatus(), SalaryArchiveStatusEnum.FIXED.getValue()) || StringUtils.equals(salaryArchivePO.getRunStatus(), SalaryArchiveStatusEnum.SUSPEND.getValue())){ + // 发薪、待停薪员工设置最后发薪日期 + updatePO.setRunStatus(SalaryArchiveStatusEnum.SUSPEND.getValue()); + updatePO.setPayEndDate(SalaryDateUtil.stringToDate(importDataMap.get("最后发薪日期").toString())); + updatePO.setUpdateTime(new Date()); + getSalaryArchiveMapper().update(updatePO); + // 停薪 + getSalaryArchiveService(user).gotoStop(Collections.singletonList(updatePO.getId())); + }else{ + // 待定薪员工,保存最后发薪日期 + updatePO.setPayEndDate(SalaryDateUtil.stringToDate(importDataMap.get("最后发薪日期").toString())); + updatePO.setUpdateTime(new Date()); + getSalaryArchiveMapper().update(updatePO); + getSalaryArchiveService(user).deletePendingTodo(Collections.singletonList(updatePO.getId())); + } + } catch (Exception e) { + log.error("停薪异常", e); + requestInfo.getRequestManager().setMessage(e.getMessage()); + return FAILURE_AND_CONTINUE; + } + return SUCCESS; + } + + + class SalaryField { + + private String processField; + + private String salaryName; + + private String value; + + public String getProcessField() { + return processField; + } + + public void setProcessField(String processField) { + this.processField = processField; + } + + public String getSalaryName() { + return salaryName; + } + + public void setSalaryName(String salaryName) { + this.salaryName = salaryName; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public SalaryField(String processField, String salaryName, String value) { + this.processField = processField; + this.salaryName = salaryName; + this.value = value; + } + } +} diff --git a/src/com/engine/salary/action/UpdateSISchemeDetailAction.java b/src/com/engine/salary/action/UpdateSISchemeDetailAction.java new file mode 100644 index 000000000..91c93c377 --- /dev/null +++ b/src/com/engine/salary/action/UpdateSISchemeDetailAction.java @@ -0,0 +1,272 @@ +package com.engine.salary.action; + +import com.engine.salary.encrypt.EncryptUtil; +import com.engine.salary.entity.sicategory.po.ICategoryPO; +import com.engine.salary.entity.sischeme.po.InsuranceSchemeDetailPO; +import com.engine.salary.entity.sischeme.po.InsuranceSchemePO; +import com.engine.salary.enums.sicategory.IsUseEnum; +import com.engine.salary.mapper.sicategory.ICategoryMapper; +import com.engine.salary.mapper.sischeme.InsuranceSchemeDetailMapper; +import com.engine.salary.mapper.sischeme.InsuranceSchemeMapper; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.db.MapperProxyFactory; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.*; +import weaver.workflow.request.RequestManager; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * @Author: sy + * @Description: 更新福利方案明细信息action + * @Date: 2023/9/18 + **/ +@Slf4j +public class UpdateSISchemeDetailAction implements Action { + + private EncryptUtil encryptUtil = new EncryptUtil(); + + private InsuranceSchemeMapper getInsuranceSchemeMapper() { + return MapperProxyFactory.getProxy(InsuranceSchemeMapper.class); + } + + private InsuranceSchemeDetailMapper getInsuranceSchemeDetailMapper() { + return MapperProxyFactory.getProxy(InsuranceSchemeDetailMapper.class); + } + + private ICategoryMapper getICategoryMapper() { + return MapperProxyFactory.getProxy(ICategoryMapper.class); + } + + private String tableName; + + + public String getTableName() { + return tableName; + } + + public void setTableName(String tableName) { + this.tableName = tableName; + } + + // 是否执行action的字段, 0代表不执行,其余代表执行 + private String enableField; + + public String getEnableField() { + return enableField; + } + + public void setEnableField(String enableField) { + this.enableField = enableField; + } + + @Override + public String execute(RequestInfo requestInfo) { + try { + RequestManager requestManager = requestInfo.getRequestManager(); + User user = requestManager.getUser(); + + Property[] properties = requestInfo.getMainTableInfo().getProperty(); + Map fieldMap = Arrays.stream(properties).collect(Collectors.toMap(Property::getName, + property -> Util.null2String(property.getValue()))); + String enable = fieldMap.get(enableField); + if (StringUtils.isNotBlank(enable) && enable.equals("0")) { + // 不执行action + return SUCCESS; + } + + DetailTable[] detailTables = requestInfo.getDetailTableInfo().getDetailTable(); + List> detailList = new ArrayList<>(); + if (detailTables.length > 0) { + for(DetailTable dt : detailTables) { + Row[] s = dt.getRow(); + for (Row r : s) { + Cell[] c = r.getCell(); + Map detailMap = Arrays.stream(c).collect(Collectors.toMap(Cell::getName, + property -> Util.null2String(property.getValue()))); + detailList.add(detailMap); + } + + } + } + RecordSet rs = new RecordSet(); + + String queryImageId = "select salaryname,processfield from " + tableName + " where workflowid = ?"; + rs.executeQuery(queryImageId, requestInfo.getWorkflowid()); + + //遍历取出明细表中对应数据 + int detailNo = 0; + List listAll = getICategoryMapper().listAll().stream().filter(f -> f.getIsUse().equals(IsUseEnum.START.getValue())).collect(Collectors.toList()); + List schemeList = getInsuranceSchemeMapper().listAll(); + List updateSchemeDetails = new ArrayList<>(); + for (Map map : detailList) { + detailNo++; + List list = new ArrayList<>(); + while (rs.next()) { + String processField = rs.getString("processfield"); + String salaryName = rs.getString("salaryname"); + String value = map.get(processField); + list.add(new UpdateSISchemeDetailAction.SalaryField(processField, salaryName, value)); + } + rs.beforFirst(); + // 流程数据 + Map importDataMap = SalaryEntityUtil.convert2Map(list, UpdateSISchemeDetailAction.SalaryField::getSalaryName, UpdateSISchemeDetailAction.SalaryField::getValue); + //设置更新对象元素 + String schemeId = importDataMap.getOrDefault("福利方案id", "").toString(); + String schemeName = importDataMap.getOrDefault("福利方案名称", "").toString(); + //查询福利方案 + InsuranceSchemePO targetSchemePO = new InsuranceSchemePO(); + if (StringUtils.isNotBlank(schemeId)) { + targetSchemePO = schemeList.stream().filter(f -> f.getId().equals(Long.valueOf(schemeId))).findFirst().orElse(null); + } else if (StringUtils.isNotBlank(schemeName)) { + targetSchemePO = schemeList.stream().filter(f -> f.getSchemeName().equals(schemeName)).findFirst().orElse(null); + } else { + requestInfo.getRequestManager().setMessage("错误行" + detailNo + ":" + "福利方案id和福利方案名称至少填写一个!"); + return FAILURE_AND_CONTINUE; + } + + if (targetSchemePO == null) { + requestInfo.getRequestManager().setMessage("错误行" + detailNo + ":" + "福利方案id和福利方案名称信息有误,无法匹配到已有福利方案!"); + return FAILURE_AND_CONTINUE; + } + //查询福利方案下的福利项明细 + List insuranceSchemeDetailPOS = getInsuranceSchemeDetailMapper().queryListBySchemeId(targetSchemePO.getId()); + if (insuranceSchemeDetailPOS.size() > 0) { + encryptUtil.decryptList(insuranceSchemeDetailPOS, InsuranceSchemeDetailPO.class); + } else { + requestInfo.getRequestManager().setMessage("错误行" + detailNo + ":" + "该福利方案不存在福利项明细,无法进行修改!"); + return FAILURE_AND_CONTINUE; + } + + String paymentScope = importDataMap.getOrDefault("缴纳对象", "").toString(); + if (StringUtils.isBlank(paymentScope)) { + requestInfo.getRequestManager().setMessage("错误行" + detailNo + ":" + "缴纳对象必填!"); + return FAILURE_AND_CONTINUE; + } + + String insuranceId = importDataMap.getOrDefault("福利项id", "").toString(); + String insuranceName = importDataMap.getOrDefault("福利项名称", "").toString(); + + InsuranceSchemeDetailPO targetSchemeDetailPO = new InsuranceSchemeDetailPO(); + if (StringUtils.isNotBlank(insuranceId)) { + targetSchemeDetailPO = insuranceSchemeDetailPOS.stream() + .filter(f -> f.getInsuranceId().equals(Long.valueOf(insuranceId)) && f.getPaymentScope().equals(Integer.valueOf(paymentScope))) + .findFirst().orElse(null); + } else if (StringUtils.isNotBlank(insuranceName)) { + List targetCategoryPOs = listAll.stream().filter(f -> f.getInsuranceName().equals(insuranceName)).collect(Collectors.toList()); + if (targetCategoryPOs .size() == 1) { + targetSchemeDetailPO = insuranceSchemeDetailPOS.stream() + .filter(f -> f.getInsuranceId().equals(targetCategoryPOs.get(0).getId()) && f.getPaymentScope().equals(Integer.valueOf(paymentScope))) + .findFirst().orElse(null); + } else if (targetCategoryPOs.size() > 1) { + requestInfo.getRequestManager().setMessage("错误行" + detailNo + ":" + "福利项名称匹配到多个福利项!"); + return FAILURE_AND_CONTINUE; + } + + } else { + requestInfo.getRequestManager().setMessage("错误行" + detailNo + ":" + "福利项id和福利项名称至少填写一个!"); + return FAILURE_AND_CONTINUE; + } + + if (targetSchemeDetailPO == null) { + requestInfo.getRequestManager().setMessage("错误行" + detailNo + ":" + "福利项id和福利项名称信息有误,无法匹配到方案已有福利项!"); + return FAILURE_AND_CONTINUE; + } + + String isPayment = importDataMap.getOrDefault("是否缴费", "").toString(); + if (StringUtils.isNotBlank(isPayment)) { + targetSchemeDetailPO.setIsPayment(Integer.valueOf(isPayment)); + } + + String upperLimit = importDataMap.getOrDefault("基数上限", "").toString(); + if (StringUtils.isNotBlank(upperLimit)) { + targetSchemeDetailPO.setUpperLimit(upperLimit); + } + String lowerLimit = importDataMap.getOrDefault("基数下限", "").toString(); + if (StringUtils.isNotBlank(lowerLimit)) { + targetSchemeDetailPO.setLowerLimit(lowerLimit); + } + String paymentProportion = importDataMap.getOrDefault("缴纳比例", "").toString(); + if (StringUtils.isNotBlank(paymentProportion)) { + targetSchemeDetailPO.setPaymentProportion(paymentProportion); + } + String fixedCost = importDataMap.getOrDefault("固定费用", "").toString(); + if (StringUtils.isNotBlank(fixedCost)) { + targetSchemeDetailPO.setFixedCost(fixedCost); + } + String validNum = importDataMap.getOrDefault("有效小数位", "").toString(); + if (StringUtils.isNotBlank(validNum)) { + targetSchemeDetailPO.setValidNum(Integer.valueOf(validNum)); + }else { + targetSchemeDetailPO.setValidNum(2); + } + String rententionRule = importDataMap.getOrDefault("进位规则", "").toString(); + if (StringUtils.isNotBlank(rententionRule)) { + targetSchemeDetailPO.setRententionRule(Integer.valueOf(rententionRule)); + } + targetSchemeDetailPO.setUpdateTime(new Date()); + + updateSchemeDetails.add(targetSchemeDetailPO); + + } + //更新方案明细 + if (updateSchemeDetails.size() > 0) { + encryptUtil.encryptList(updateSchemeDetails, InsuranceSchemeDetailPO.class); + updateSchemeDetails.forEach(getInsuranceSchemeDetailMapper()::updateAll); + } + + + } catch (Exception e) { + log.error("福利方案更新异常", e); + requestInfo.getRequestManager().setMessage(e.getMessage()); + return FAILURE_AND_CONTINUE; + } + return SUCCESS; + } + + + class SalaryField { + + private String processField; + + private String salaryName; + + private String value; + + public String getProcessField() { + return processField; + } + + public void setProcessField(String processField) { + this.processField = processField; + } + + public String getSalaryName() { + return salaryName; + } + + public void setSalaryName(String salaryName) { + this.salaryName = salaryName; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public SalaryField(String processField, String salaryName, String value) { + this.processField = processField; + this.salaryName = salaryName; + this.value = value; + } + } +} diff --git a/src/com/engine/salary/action/updateSalaryApprovalStatusAction.java b/src/com/engine/salary/action/updateSalaryApprovalStatusAction.java new file mode 100644 index 000000000..14e613881 --- /dev/null +++ b/src/com/engine/salary/action/updateSalaryApprovalStatusAction.java @@ -0,0 +1,78 @@ +package com.engine.salary.action; + +import cn.hutool.core.util.NumberUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO; +import com.engine.salary.mapper.salaryacct.SalaryAcctRecordMapper; +import com.engine.salary.service.SalaryAcctRecordService; +import com.engine.salary.service.impl.SalaryAcctRecordServiceImpl; +import com.engine.salary.util.db.MapperProxyFactory; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.Property; +import weaver.soa.workflow.request.RequestInfo; + +import java.util.Arrays; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * @ClassName updateSalaryApprovalStatusAction + * @author Harryxzy + * @date 2024/4/24 15:44 + * @description 跟新薪资核算审批状态 + */ +@Slf4j +public class updateSalaryApprovalStatusAction implements Action { + + private SalaryAcctRecordService getSalaryAcctRecordService(User user) { + return ServiceUtil.getService(SalaryAcctRecordServiceImpl.class, user); + } + + private SalaryAcctRecordMapper getSalaryAcctRecordMapper() { + return MapperProxyFactory.getProxy(SalaryAcctRecordMapper.class); + } + + + // 记录薪资核算记录id的字段 + private String salaryAcctRecordIdField; + + // 修改为对应的状态 + private String status; + + @Override + public String execute(RequestInfo requestInfo) { + try { + if (StringUtils.isEmpty(salaryAcctRecordIdField)) { + requestInfo.getRequestManager().setMessage("薪资核算记录id字段不能为空"); + return FAILURE_AND_CONTINUE; + } + Property[] properties = requestInfo.getMainTableInfo().getProperty(); + Map fieldMap = Arrays.stream(properties).collect(Collectors.toMap(Property::getName, + property -> Util.null2String(property.getValue()))); + String salaryAcctRecordId = fieldMap.get(salaryAcctRecordIdField); + if (!NumberUtil.isNumber(salaryAcctRecordId)) { + requestInfo.getRequestManager().setMessage("核算记录id不为数字"); + return FAILURE_AND_CONTINUE; + } + User user = new User(); + user.setUid(1); + user.setLoginid("sysadmin"); + SalaryAcctRecordPO salaryAcctRecordPO = getSalaryAcctRecordService(user).getById(Long.valueOf(salaryAcctRecordId)); + if (salaryAcctRecordPO == null) { + requestInfo.getRequestManager().setMessage("核算记录不存在或已被删除"); + return FAILURE_AND_CONTINUE; + } + salaryAcctRecordPO.setApprovalStatus(status); + getSalaryAcctRecordMapper().updateIgnoreNull(salaryAcctRecordPO); + } catch (Exception e) { + log.error("审批状态更新失败", e); + requestInfo.getRequestManager().setMessage(e.getMessage()); + return FAILURE_AND_CONTINUE; + } + return SUCCESS; + } +} diff --git a/src/com/engine/salary/annotation/Auth.java b/src/com/engine/salary/annotation/Auth.java new file mode 100644 index 000000000..78cc19097 --- /dev/null +++ b/src/com/engine/salary/annotation/Auth.java @@ -0,0 +1,29 @@ +package com.engine.salary.annotation; + +import com.engine.salary.enums.auth.AuthCheckTypeEnum; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * 权限验证字段 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +public @interface Auth { + String page(); + + AuthCheckTypeEnum checkType() default AuthCheckTypeEnum.TAX_EMP; + + String taxAgentIdField() default "taxAgentId"; + String employeeIdField() default "employeeId"; + String sobIdField() default "salarySobId"; + String optsField() default "opts"; +} diff --git a/src/com/engine/salary/annotation/AuthField.java b/src/com/engine/salary/annotation/AuthField.java new file mode 100644 index 000000000..b51cd44f3 --- /dev/null +++ b/src/com/engine/salary/annotation/AuthField.java @@ -0,0 +1,22 @@ +package com.engine.salary.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * 权限验证字段 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Target(ElementType.FIELD) +@Retention(RetentionPolicy.RUNTIME) +public @interface AuthField { + + String fieldType(); + +} diff --git a/src/com/engine/salary/annotation/AuthOpt.java b/src/com/engine/salary/annotation/AuthOpt.java new file mode 100644 index 000000000..e4ffcb499 --- /dev/null +++ b/src/com/engine/salary/annotation/AuthOpt.java @@ -0,0 +1,20 @@ +package com.engine.salary.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * 权限验证字段 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Target(ElementType.FIELD) +@Retention(RetentionPolicy.RUNTIME) +public @interface AuthOpt { + +} diff --git a/src/com/engine/salary/annotation/Encrypt.java b/src/com/engine/salary/annotation/Encrypt.java new file mode 100644 index 000000000..c61e1de44 --- /dev/null +++ b/src/com/engine/salary/annotation/Encrypt.java @@ -0,0 +1,20 @@ +package com.engine.salary.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * 加密字段,用于标注需加解密的字段 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Target(ElementType.FIELD) +@Retention(RetentionPolicy.RUNTIME) +public @interface Encrypt { + +} diff --git a/src/com/engine/salary/annotation/I18n.java b/src/com/engine/salary/annotation/I18n.java new file mode 100644 index 000000000..ca9b71fd8 --- /dev/null +++ b/src/com/engine/salary/annotation/I18n.java @@ -0,0 +1,20 @@ +package com.engine.salary.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * 国际化标识 + *

Copyright: Copyright (c) 2024

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Target(ElementType.FIELD) +@Retention(RetentionPolicy.RUNTIME) +public @interface I18n { + +} diff --git a/src/com/engine/salary/annotation/SalaryFormulaVar.java b/src/com/engine/salary/annotation/SalaryFormulaVar.java new file mode 100644 index 000000000..2e3077158 --- /dev/null +++ b/src/com/engine/salary/annotation/SalaryFormulaVar.java @@ -0,0 +1,27 @@ +package com.engine.salary.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * 薪资公式计算器-变量 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Target({ElementType.FIELD}) +@Retention(RetentionPolicy.RUNTIME) +public @interface SalaryFormulaVar { + + int labelId(); + + String defaultLabel(); + + String dataType(); + + String fieldId() default ""; +} diff --git a/src/com/engine/salary/annotation/SalaryTable.java b/src/com/engine/salary/annotation/SalaryTable.java new file mode 100644 index 000000000..ef0b19884 --- /dev/null +++ b/src/com/engine/salary/annotation/SalaryTable.java @@ -0,0 +1,69 @@ +package com.engine.salary.annotation; + + +import com.cloudstore.eccom.pc.table.WeaTableType; + +import java.lang.annotation.*; + +/** + * 数据列表 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface SalaryTable { + + String pageId() default ""; + + /** + * 数据库字段,以','分割,例如:"id, name, description" + */ + String fields() default ""; + + /** + * 表名 ,例如:"FROM hrsa_tax_agent" + */ + String fromSql() default ""; + + /** + * 条件 + */ + String where() default ""; + + /** + * 分组 + */ + String groupby() default ""; + + + /** + * 排序 + */ + String orderby() default ""; + + /** + * 主键 + */ + String primarykey() default ""; + + /** + * 去重 + */ + boolean distinct() default false; + + /** + * 操作按钮 + */ + SalaryTableOperate[] operates() default {}; + + /** + * 列表选择框 + */ + WeaTableType tableType() default WeaTableType.NONE; + +} diff --git a/src/com/engine/salary/annotation/SalaryTableColumn.java b/src/com/engine/salary/annotation/SalaryTableColumn.java new file mode 100644 index 000000000..94d93a5cf --- /dev/null +++ b/src/com/engine/salary/annotation/SalaryTableColumn.java @@ -0,0 +1,34 @@ +package com.engine.salary.annotation; + +import java.lang.annotation.*; + +/** + * 数据列表表头 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Target({ElementType.FIELD}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface SalaryTableColumn { + + String text() default ""; + + int labelId() default -1; + + String width() default ""; + + String column() default ""; + + boolean display() default true; + + String orderkey() default ""; + + String transmethod() default ""; + + // 额外参数 + String otherPara() default ""; +} diff --git a/src/com/engine/salary/annotation/SalaryTableOperate.java b/src/com/engine/salary/annotation/SalaryTableOperate.java new file mode 100644 index 000000000..f9f69c16b --- /dev/null +++ b/src/com/engine/salary/annotation/SalaryTableOperate.java @@ -0,0 +1,27 @@ +package com.engine.salary.annotation; + +import java.lang.annotation.*; + +/** + * 列表操作按钮 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Target({ElementType.ANNOTATION_TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface SalaryTableOperate { + + String text() default ""; + + int labelId() default -1; + + String href() default ""; + + String index() default "0"; + + +} diff --git a/src/com/engine/salary/annotation/TableTitle.java b/src/com/engine/salary/annotation/TableTitle.java new file mode 100644 index 000000000..427aa8862 --- /dev/null +++ b/src/com/engine/salary/annotation/TableTitle.java @@ -0,0 +1,13 @@ +package com.engine.salary.annotation; + +import java.lang.annotation.*; + +@Target({ElementType.FIELD}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface TableTitle { + String title(); + String dataIndex(); + String key(); + boolean display() default true; +} diff --git a/src/com/engine/salary/biz/AddUpDeductionBiz.java b/src/com/engine/salary/biz/AddUpDeductionBiz.java new file mode 100644 index 000000000..3e7f8330c --- /dev/null +++ b/src/com/engine/salary/biz/AddUpDeductionBiz.java @@ -0,0 +1,171 @@ +package com.engine.salary.biz; + +import com.engine.salary.encrypt.EncryptUtil; +import com.engine.salary.entity.datacollection.AddUpDeduction; +import com.engine.salary.entity.datacollection.dto.AddUpDeductionDTO; +import com.engine.salary.entity.datacollection.dto.AddUpDeductionRecordDTO; +import com.engine.salary.entity.datacollection.param.AddUpDeductionQueryParam; +import com.engine.salary.mapper.datacollection.AddUpDeductionMapper; +import com.engine.salary.util.SalaryI18nUtil; +import com.google.common.collect.Lists; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.ibatis.session.SqlSession; +import weaver.conn.mybatis.MyBatisFactory; +import weaver.general.BaseBean; + +import java.util.ArrayList; +import java.util.List; + +public class AddUpDeductionBiz extends BaseBean { + + private final EncryptUtil encryptUtil = new EncryptUtil(); + + + /** + * 关联查询查询列表 + * + * @param param + * @return + */ + public List list(AddUpDeductionQueryParam param) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + AddUpDeductionMapper mapper = sqlSession.getMapper(AddUpDeductionMapper.class); + List list = mapper.list(param); + encryptUtil.decryptList(list, AddUpDeductionDTO.class); + SalaryI18nUtil.i18nList(list); + return list; + } finally { + sqlSession.close(); + } + } + + /** + * 条件查询 + * + * @param param + * @return + */ + public List listSome(AddUpDeduction param) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + AddUpDeductionMapper mapper = sqlSession.getMapper(AddUpDeductionMapper.class); + if (CollectionUtils.isNotEmpty(param.getEmployeeIds())) { + List addUpDeductions = new ArrayList<>(); + List> partition = Lists.partition(param.getEmployeeIds(), 500); + partition.forEach(l -> { + param.setEmployeeIds(l); + addUpDeductions.addAll(mapper.listSome(param)); + }); + return encryptUtil.decryptList(addUpDeductions, AddUpDeduction.class); + } else { + List addUpDeductions = mapper.listSome(param); + return encryptUtil.decryptList(addUpDeductions, AddUpDeduction.class); + } + } finally { + sqlSession.close(); + } + } + + + /** + * 根据id获取 + * + * @param id + * @return + */ + public AddUpDeduction getById(Long id) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + AddUpDeductionMapper mapper = sqlSession.getMapper(AddUpDeductionMapper.class); + AddUpDeduction byId = mapper.getById(id); + return encryptUtil.decrypt(byId, AddUpDeduction.class); + } finally { + sqlSession.close(); + } + } + + /** + * 详情列表 + * + * @param param + * @return + */ + public List recordList(AddUpDeductionQueryParam param) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + AddUpDeductionMapper mapper = sqlSession.getMapper(AddUpDeductionMapper.class); + List addUpDeductionRecordStrDTOS = mapper.recordList(param); + encryptUtil.decryptList(addUpDeductionRecordStrDTOS, AddUpDeductionRecordDTO.class); + SalaryI18nUtil.i18nList(addUpDeductionRecordStrDTOS); + return addUpDeductionRecordStrDTOS; + } finally { + sqlSession.close(); + } + } + + /** + * 批量插入 + * + * @param param + * @return + */ + public void batchSave(List param) { + if (CollectionUtils.isEmpty(param)) { + return; + } + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + AddUpDeductionMapper mapper = sqlSession.getMapper(AddUpDeductionMapper.class); + encryptUtil.encryptList(param, AddUpDeduction.class); + List> partition = Lists.partition(param, 100); + partition.forEach(mapper::insertData); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + /** + * 批量插入 + * + * @param param + * @return + */ + public void batchUpdate(List param) { + if (CollectionUtils.isEmpty(param)) { + return; + } + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + AddUpDeductionMapper mapper = sqlSession.getMapper(AddUpDeductionMapper.class); + encryptUtil.encryptList(param, AddUpDeduction.class); + List> partition = Lists.partition(param, 100); + partition.forEach(mapper::updateData); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + + + + + public void batchDeleteByIDS(List ids) { + if (CollectionUtils.isEmpty(ids)) { + return; + } + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + AddUpDeductionMapper mapper = sqlSession.getMapper(AddUpDeductionMapper.class); + List> partition = Lists.partition(ids, 100); + partition.forEach(mapper::deleteData); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + +} diff --git a/src/com/engine/salary/biz/AddUpSituationBiz.java b/src/com/engine/salary/biz/AddUpSituationBiz.java new file mode 100644 index 000000000..41068ef88 --- /dev/null +++ b/src/com/engine/salary/biz/AddUpSituationBiz.java @@ -0,0 +1,191 @@ +package com.engine.salary.biz; + +import com.engine.salary.encrypt.EncryptUtil; +import com.engine.salary.entity.datacollection.AddUpSituation; +import com.engine.salary.entity.datacollection.dto.AddUpSituationRecordDTO; +import com.engine.salary.entity.datacollection.param.AddUpSituationQueryParam; +import com.engine.salary.mapper.datacollection.AddUpSituationMapper; +import com.google.common.collect.Lists; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.ibatis.session.SqlSession; +import weaver.conn.mybatis.MyBatisFactory; +import weaver.general.BaseBean; + +import java.util.*; +import java.util.stream.Collectors; + +public class AddUpSituationBiz extends BaseBean { + + private EncryptUtil encryptUtil = new EncryptUtil(); + + + /** + * 条件查询 + * + * @param param + * @return + */ + public List listSome(AddUpSituation param) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + AddUpSituationMapper mapper = sqlSession.getMapper(AddUpSituationMapper.class); + if (CollectionUtils.isNotEmpty(param.getEmployeeIds())) { + List addUpSituations = new ArrayList<>(); + List> partition = Lists.partition((List) param.getEmployeeIds(), 500); + partition.forEach(l -> { + param.setEmployeeIds(l); + addUpSituations.addAll(mapper.listSome(param)); + }); + return encryptUtil.decryptList(addUpSituations, AddUpSituation.class); + } else { + List addUpSituations = mapper.listSome(param); + return encryptUtil.decryptList(addUpSituations, AddUpSituation.class); + } + } finally { + sqlSession.close(); + } + } + + + /** + * 根据id获取 + * + * @param id + * @return + */ + public AddUpSituation getById(Long id) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + AddUpSituationMapper mapper = sqlSession.getMapper(AddUpSituationMapper.class); + AddUpSituation byId = mapper.getById(id); + return encryptUtil.decrypt(byId, AddUpSituation.class); + } finally { + sqlSession.close(); + } + } + + /** + * 详情列表 + * + * @param param + * @return + */ + public List recordList(AddUpSituationQueryParam param) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + AddUpSituationMapper mapper = sqlSession.getMapper(AddUpSituationMapper.class); + List addUpSituationRecordDTOS = mapper.recordList(param); + return encryptUtil.decryptList(addUpSituationRecordDTOS, AddUpSituationRecordDTO.class); + } finally { + sqlSession.close(); + } + } + + /** + * 批量插入 + * + * @param param + * @return + */ + public void batchSave(List param) { + if (CollectionUtils.isEmpty(param)) { + return; + } + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + AddUpSituationMapper mapper = sqlSession.getMapper(AddUpSituationMapper.class); + encryptUtil.encryptList(param, AddUpSituation.class); + List> partition = Lists.partition(param, 50); + partition.forEach(mapper::insertData); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + /** + * 批量插入 + * + * @param param + * @return + */ + public void batchUpdate(List param) { + if (CollectionUtils.isEmpty(param)) { + return; + } + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + AddUpSituationMapper mapper = sqlSession.getMapper(AddUpSituationMapper.class); + encryptUtil.encryptList(param, AddUpSituation.class); + List> partition = Lists.partition(param, 50); + partition.forEach(mapper::updateData); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + + public void handleImportData(List pos) { + if (CollectionUtils.isEmpty(pos)) { + return; + } + AddUpSituation po = pos.get(0); + // 多条相同人的则以第一条为准,如果逆序排列(用于重复的则以最后一条为准)Collections.reverse(pos); + // 去重(通过记录的唯一条件(申报月份,人员id,个税扣缴义务人id)拼接) + List finalPos = pos.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(f -> f.getEmployeeId() + "-" + f.getTaxAgentId()))), ArrayList::new)); + // 查询已有数据 + List list = listSome(AddUpSituation.builder().taxYearMonth(po.getTaxYearMonth()).build()); + // 待修改的 本地已存在则更新【交集】 + List updateList = list.stream().map(m -> { + Optional optional = finalPos.stream().filter(p -> (p.getEmployeeId() + "-" + p.getTaxAgentId()).equals(m.getEmployeeId() + "-" + m.getTaxAgentId())).findFirst(); + AddUpSituation temp = null; + if (optional.isPresent()) { + temp = optional.get(); + // 换成本地库的id + temp.setId(m.getId()); + } + return temp; + }).filter(Objects::nonNull).collect(Collectors.toList()); + // 待新增的 导入比本地多,则新增【差集(导入 - local)】 + List saveList = finalPos.stream().map(m -> { + Optional optional = list.stream().filter(p -> (p.getEmployeeId() + "-" + p.getTaxAgentId()).equals(m.getEmployeeId() + "-" + m.getTaxAgentId())).findFirst(); + AddUpSituation temp = null; + if (!optional.isPresent()) { + temp = m; + } + return temp; + }).filter(Objects::nonNull).collect(Collectors.toList()); + + // 修改 + if (CollectionUtils.isNotEmpty(updateList)) { + batchUpdate(updateList); + } + // 保存 + if (CollectionUtils.isNotEmpty(saveList)) { + batchSave(saveList); + } + } + + + /** + * @return void + * @description 批量删除数据 + * @author Harryxzy + * @date 2022/10/27 22:39 + */ + public void batchDeleteByIDS(List deleteIds) { + if (CollectionUtils.isEmpty(deleteIds)) { + return; + } + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + AddUpSituationMapper mapper = sqlSession.getMapper(AddUpSituationMapper.class); + List> partition = Lists.partition(deleteIds, 100); + partition.forEach(mapper::deleteData); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } +} diff --git a/src/com/engine/salary/biz/AttendQuoteBiz.java b/src/com/engine/salary/biz/AttendQuoteBiz.java new file mode 100644 index 000000000..f4a2dc2bb --- /dev/null +++ b/src/com/engine/salary/biz/AttendQuoteBiz.java @@ -0,0 +1,66 @@ +package com.engine.salary.biz; + +import com.engine.salary.entity.datacollection.dto.AttendQuoteListDTO; +import com.engine.salary.entity.datacollection.param.AttendQuoteQueryParam; +import com.engine.salary.entity.datacollection.po.AttendQuotePO; +import com.engine.salary.mapper.datacollection.AttendQuoteMapper; +import org.apache.ibatis.session.SqlSession; +import weaver.conn.mybatis.MyBatisFactory; + +import java.util.List; + +public class AttendQuoteBiz { + + public List list(AttendQuoteQueryParam param) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + AttendQuoteMapper mapper = sqlSession.getMapper(AttendQuoteMapper.class); + return mapper.list(param); + } finally { + sqlSession.close(); + } + } + + public void deleteByIds(List unAccountingIds) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + AttendQuoteMapper mapper = sqlSession.getMapper(AttendQuoteMapper.class); + mapper.deleteByIds(unAccountingIds); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + public List listSome(AttendQuotePO param) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + AttendQuoteMapper mapper = sqlSession.getMapper(AttendQuoteMapper.class); + return mapper.listSome(param); + } finally { + sqlSession.close(); + } + } + + public void updateById(AttendQuotePO attendQuote) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + AttendQuoteMapper mapper = sqlSession.getMapper(AttendQuoteMapper.class); + mapper.updateIgnoreNull(attendQuote); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + public void insert(AttendQuotePO attendQuote) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + AttendQuoteMapper mapper = sqlSession.getMapper(AttendQuoteMapper.class); + mapper.insertIgnoreNull(attendQuote); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } +} diff --git a/src/com/engine/salary/biz/AttendQuoteDataBiz.java b/src/com/engine/salary/biz/AttendQuoteDataBiz.java new file mode 100644 index 000000000..f3b456fdf --- /dev/null +++ b/src/com/engine/salary/biz/AttendQuoteDataBiz.java @@ -0,0 +1,67 @@ +package com.engine.salary.biz; + +import com.engine.salary.entity.datacollection.dto.AttendQuoteDataBaseDTO; +import com.engine.salary.entity.datacollection.param.AttendQuoteDataQueryParam; +import com.engine.salary.entity.datacollection.po.AttendQuoteDataPO; +import com.engine.salary.mapper.datacollection.AttendQuoteDataMapper; +import com.engine.salary.util.SalaryI18nUtil; +import com.google.common.collect.Lists; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.ibatis.session.SqlSession; +import weaver.conn.mybatis.MyBatisFactory; + +import java.util.List; + +public class AttendQuoteDataBiz { + + public List list(AttendQuoteDataQueryParam param) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + AttendQuoteDataMapper mapper = sqlSession.getMapper(AttendQuoteDataMapper.class); + List list = mapper.list(param); + return SalaryI18nUtil.i18nList(list); + } finally { + sqlSession.close(); + } + } + + public List listSome(AttendQuoteDataQueryParam param) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + AttendQuoteDataMapper mapper = sqlSession.getMapper(AttendQuoteDataMapper.class); + return mapper.listSome(param); + } finally { + sqlSession.close(); + } + } + + + + public void deleteByAttendQuoteIds(List unAccountingIds) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + AttendQuoteDataMapper mapper = sqlSession.getMapper(AttendQuoteDataMapper.class); + mapper.deleteByAttendQuoteIds(unAccountingIds); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + + } + + public void insertData(List pos) { + if(CollectionUtils.isEmpty(pos)){ + return; + } + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + AttendQuoteDataMapper mapper = sqlSession.getMapper(AttendQuoteDataMapper.class); + List> partition = Lists.partition(pos, 100); + partition.forEach(mapper::insertData); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + +} diff --git a/src/com/engine/salary/biz/AttendQuoteDataValueBiz.java b/src/com/engine/salary/biz/AttendQuoteDataValueBiz.java new file mode 100644 index 000000000..f80b1aa36 --- /dev/null +++ b/src/com/engine/salary/biz/AttendQuoteDataValueBiz.java @@ -0,0 +1,93 @@ +package com.engine.salary.biz; + +import com.engine.salary.entity.datacollection.po.AttendQuoteDataValuePO; +import com.engine.salary.mapper.datacollection.AttendQuoteDataValueMapper; +import com.google.common.collect.Lists; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.ibatis.session.SqlSession; +import weaver.conn.mybatis.MyBatisFactory; + +import java.util.ArrayList; +import java.util.List; + +public class AttendQuoteDataValueBiz { + + /** + * 根据考勤引用字段表的主键id删除 + * + * @param attendQuoteDataIds + */ + public void deleteByAttendQuoteDataIds(List attendQuoteDataIds) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + AttendQuoteDataValueMapper mapper = sqlSession.getMapper(AttendQuoteDataValueMapper.class); + List> partition = Lists.partition(attendQuoteDataIds, 500); + partition.forEach(mapper::deleteByAttendQuoteDataIds); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + + public List listSome(AttendQuoteDataValuePO param) { + List list = new ArrayList<>(); + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + AttendQuoteDataValueMapper mapper = sqlSession.getMapper(AttendQuoteDataValueMapper.class); + + List employeeIds = param.getEmployeeIds(); + if (CollectionUtils.isNotEmpty(employeeIds)) { + List> partition = Lists.partition(employeeIds, 100); + partition.forEach(empIds -> { + param.setEmployeeIds(empIds); + list.addAll(mapper.listSome(param)); + }); + } else { + list.addAll(mapper.listSome(param)); + } + } finally { + sqlSession.close(); + } + return list; + } + + public void insertData(List values) { + if (CollectionUtils.isEmpty(values)) { + return; + } + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + AttendQuoteDataValueMapper mapper = sqlSession.getMapper(AttendQuoteDataValueMapper.class); + List> partition = Lists.partition(values, 100); + partition.forEach(mapper::insertData); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + public void deleteByAttendQuoteIds(List quoteIds) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + AttendQuoteDataValueMapper mapper = sqlSession.getMapper(AttendQuoteDataValueMapper.class); + mapper.deleteByAttendIds(quoteIds); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + public void updateDataValue(AttendQuoteDataValuePO po) { + + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + AttendQuoteDataValueMapper mapper = sqlSession.getMapper(AttendQuoteDataValueMapper.class); + mapper.updateDataValueByFiledIdAndEmployeeId(po); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + + } +} diff --git a/src/com/engine/salary/biz/AttendQuoteFieldBiz.java b/src/com/engine/salary/biz/AttendQuoteFieldBiz.java new file mode 100644 index 000000000..70d7c72fb --- /dev/null +++ b/src/com/engine/salary/biz/AttendQuoteFieldBiz.java @@ -0,0 +1,108 @@ +package com.engine.salary.biz; + +import com.engine.salary.entity.datacollection.dto.AttendQuoteFieldListDTO; +import com.engine.salary.entity.datacollection.param.AttendQuoteFieldQueryParam; +import com.engine.salary.entity.datacollection.po.AttendQuoteFieldPO; +import com.engine.salary.mapper.datacollection.AttendQuoteFieldMapper; +import com.google.common.collect.Lists; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.ibatis.session.SqlSession; +import weaver.conn.mybatis.MyBatisFactory; + +import java.util.Collection; +import java.util.List; + +public class AttendQuoteFieldBiz { + + public List listSome(AttendQuoteFieldPO param) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + AttendQuoteFieldMapper mapper = sqlSession.getMapper(AttendQuoteFieldMapper.class); + return mapper.listSome(param); + } finally { + sqlSession.close(); + } + } + + public void save(AttendQuoteFieldPO po) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + AttendQuoteFieldMapper mapper = sqlSession.getMapper(AttendQuoteFieldMapper.class); + mapper.insertIgnoreNull(po); + + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + public AttendQuoteFieldPO getById(Long id) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + AttendQuoteFieldMapper mapper = sqlSession.getMapper(AttendQuoteFieldMapper.class); + return mapper.getById(id); + } finally { + sqlSession.close(); + } + } + + public void update(AttendQuoteFieldPO po) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + AttendQuoteFieldMapper mapper = sqlSession.getMapper(AttendQuoteFieldMapper.class); + mapper.updateIgnoreNull(po); + + sqlSession.commit(); + } finally { + sqlSession.close(); + } + + } + + public List list(AttendQuoteFieldQueryParam param) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + AttendQuoteFieldMapper mapper = sqlSession.getMapper(AttendQuoteFieldMapper.class); + return mapper.list(param); + } finally { + sqlSession.close(); + } + } + + public void deleteByIds(Collection ids) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + AttendQuoteFieldMapper mapper = sqlSession.getMapper(AttendQuoteFieldMapper.class); + mapper.deleteByIds(ids); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + public void saveBatch(List saves) { + if(CollectionUtils.isEmpty(saves)){ + return; + } + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + AttendQuoteFieldMapper mapper = sqlSession.getMapper(AttendQuoteFieldMapper.class); + List> partition = Lists.partition(saves, 100); + partition.forEach(mapper::saveBatch); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + public void deleteAttendByCode(AttendQuoteFieldQueryParam param) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + AttendQuoteFieldMapper mapper = sqlSession.getMapper(AttendQuoteFieldMapper.class); + mapper.deleteAttendByCode(param); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } +} diff --git a/src/com/engine/salary/biz/AttendQuoteFieldSettingBiz.java b/src/com/engine/salary/biz/AttendQuoteFieldSettingBiz.java new file mode 100644 index 000000000..28266a88b --- /dev/null +++ b/src/com/engine/salary/biz/AttendQuoteFieldSettingBiz.java @@ -0,0 +1,46 @@ +package com.engine.salary.biz; + +import com.engine.salary.entity.datacollection.po.AttendQuoteFieldSettingPO; +import com.engine.salary.enums.datacollection.AttendQuoteSourceTypeEnum; +import com.engine.salary.mapper.datacollection.AttendQuoteSyncSetMapper; +import org.apache.ibatis.session.SqlSession; +import weaver.conn.mybatis.MyBatisFactory; + +import java.util.List; + +public class AttendQuoteFieldSettingBiz { + public List getAttendQuoteFieldSetting(AttendQuoteSourceTypeEnum sourceType) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + AttendQuoteSyncSetMapper mapper = sqlSession.getMapper(AttendQuoteSyncSetMapper.class); + return mapper.listSome(AttendQuoteFieldSettingPO.builder().sourceType(sourceType.getValue()).build()); + } finally { + sqlSession.close(); + } + } + + + public void insert(AttendQuoteFieldSettingPO po) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + AttendQuoteSyncSetMapper mapper = sqlSession.getMapper(AttendQuoteSyncSetMapper.class); + mapper.insertIgnoreNull(po); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + public void updateById(AttendQuoteFieldSettingPO po) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + AttendQuoteSyncSetMapper mapper = sqlSession.getMapper(AttendQuoteSyncSetMapper.class); + mapper.updateIgnoreNull(po); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + +} diff --git a/src/com/engine/salary/biz/EmployBiz.java b/src/com/engine/salary/biz/EmployBiz.java new file mode 100644 index 000000000..6de561546 --- /dev/null +++ b/src/com/engine/salary/biz/EmployBiz.java @@ -0,0 +1,247 @@ +package com.engine.salary.biz; + +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.hrm.DeptInfo; +import com.engine.salary.entity.hrm.PositionInfo; +import com.engine.salary.entity.hrm.SubCompanyInfo; +import com.engine.salary.entity.salarysob.param.SalarySobRangeEmpQueryParam; +import com.engine.salary.mapper.datacollection.EmployMapper; +import com.google.common.collect.Lists; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.ibatis.session.SqlSession; +import weaver.conn.mybatis.MyBatisFactory; +import weaver.general.BaseBean; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +public class EmployBiz extends BaseBean { + + public List listAll(){ + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + EmployMapper mapper = sqlSession.getMapper(EmployMapper.class); + return mapper.listAll(); + } finally { + sqlSession.close(); + } + } + + /** + * 查询人员列表 + * + * @return + */ + public List listEmployee() { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + EmployMapper mapper = sqlSession.getMapper(EmployMapper.class); + return mapper.listEmployee(); + } finally { + sqlSession.close(); + } + } + + public List getEmployeeByIds(List list) { + if (CollectionUtils.isEmpty(list)) { + return new ArrayList<>(); + } + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + List dataList = new ArrayList<>(); + EmployMapper mapper = sqlSession.getMapper(EmployMapper.class); + List> partition = Lists.partition(list, 1000); + for (List longs : partition) { + dataList.addAll(mapper.getEmployeeByIds(longs)); + } + return dataList; + } finally { + sqlSession.close(); + } + } + + public List getEmployeeByIdsIncludeAccountType(List list) { + if (CollectionUtils.isEmpty(list)) { + return new ArrayList<>(); + } + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + List dataList = new ArrayList<>(); + EmployMapper mapper = sqlSession.getMapper(EmployMapper.class); + List> partition = Lists.partition(list, 1000); + for (List longs : partition) { + dataList.addAll(mapper.getEmployeeByIdsIncludeAccountType(longs)); + } + return dataList; + } finally { + sqlSession.close(); + } + } + + public List getEmployeeByIdsAll(List list) { + if (CollectionUtils.isEmpty(list)) { + return new ArrayList<>(); + } + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + List employeeList = new ArrayList<>(); + EmployMapper mapper = sqlSession.getMapper(EmployMapper.class); + List> partition = Lists.partition(list, 1000); + partition.forEach(e->{ + List employeeByIdsAll = mapper.getEmployeeByIdsAll(e); + employeeList.addAll(employeeByIdsAll); + }); + return employeeList; + } finally { + sqlSession.close(); + } + } + + + /** + * 岗位信息 + * + * @param list + * @return + */ + public List listPositionInfo(List list) { + if (CollectionUtils.isEmpty(list)) { + return new ArrayList<>(); + } + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + EmployMapper mapper = sqlSession.getMapper(EmployMapper.class); + return mapper.listPositionInfo(list); + } finally { + sqlSession.close(); + } + } + + public PositionInfo getPositionInfoById(Long positionId) { + if (positionId == null) { + return null; + } + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + EmployMapper mapper = sqlSession.getMapper(EmployMapper.class); + return mapper.getPositionInfoById(positionId); + } finally { + sqlSession.close(); + } + } + + public List listByParams(List includeQueryParams) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + EmployMapper mapper = sqlSession.getMapper(EmployMapper.class); + List emps = new ArrayList<>(); + List> partition = Lists.partition(includeQueryParams, 100); + partition.forEach(list->{ + emps.addAll(mapper.listByParams(list)); + }); + return emps; + } finally { + sqlSession.close(); + } + } + + public List listByVirtualParams(List virtualQueryParams) { + if (CollectionUtils.isEmpty(virtualQueryParams)) { + return Collections.emptyList(); + } + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + EmployMapper mapper = sqlSession.getMapper(EmployMapper.class); + List emps = new ArrayList<>(); + List> partition = Lists.partition(virtualQueryParams, 100); + partition.forEach(list->{ + emps.addAll(mapper.listByVirtualParams(list)); + }); + return emps; + } finally { + sqlSession.close(); + } + } + + public DataCollectionEmployee getEmployeeById(Long employeeId) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + EmployMapper mapper = sqlSession.getMapper(EmployMapper.class); + return mapper.getEmployeeById(employeeId); + } finally { + sqlSession.close(); + } + } + + public List getDeptInfoList(List list) { + if (CollectionUtils.isEmpty(list)) { + return new ArrayList<>(); + } + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + EmployMapper mapper = sqlSession.getMapper(EmployMapper.class); + return mapper.getDeptInfoList(list); + } finally { + sqlSession.close(); + } + } + + public List getSubCompanyInfoList(List list) { + if (CollectionUtils.isEmpty(list)) { + return new ArrayList<>(); + } + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + EmployMapper mapper = sqlSession.getMapper(EmployMapper.class); + return mapper.getSubCompanyInfoList(list); + } finally { + sqlSession.close(); + } + } + + public SubCompanyInfo getSubCompanyInfoById(Long subCompanyId) { + if (subCompanyId == null) { + return null; + } + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + EmployMapper mapper = sqlSession.getMapper(EmployMapper.class); + return mapper.getSubCompanyInfoById(subCompanyId); + } finally { + sqlSession.close(); + } + } + + + public List listAllForReport() { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + EmployMapper mapper = sqlSession.getMapper(EmployMapper.class); + return mapper.listAllForReport(); + } finally { + sqlSession.close(); + } + } + + public List listByDismissDate(String dismissDate) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + EmployMapper mapper = sqlSession.getMapper(EmployMapper.class); + return mapper.listByDismissDate(dismissDate); + } finally { + sqlSession.close(); + } + } + + public DeptInfo getDeptInfoById(Long departmentId) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + EmployMapper mapper = sqlSession.getMapper(EmployMapper.class); + return mapper.getDeptInfoById(departmentId); + } finally { + sqlSession.close(); + } + } + +} diff --git a/src/com/engine/salary/biz/OtherDeductionBiz.java b/src/com/engine/salary/biz/OtherDeductionBiz.java new file mode 100644 index 000000000..175a65c40 --- /dev/null +++ b/src/com/engine/salary/biz/OtherDeductionBiz.java @@ -0,0 +1,226 @@ +package com.engine.salary.biz; + +import com.engine.salary.config.SalaryElogConfig; +import com.engine.hrmelog.entity.dto.LoggerContext; +import com.engine.salary.encrypt.EncryptUtil; +import com.engine.salary.entity.datacollection.dto.OtherDeductionRecordDTO; +import com.engine.salary.entity.datacollection.param.OtherDeductionQueryParam; +import com.engine.salary.entity.datacollection.po.OtherDeductionPO; +import com.engine.salary.enums.OperateTypeEnum; +import com.engine.salary.mapper.datacollection.OtherDeductionMapper; +import com.engine.salary.util.SalaryDateUtil; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.SalaryI18nUtil; +import com.google.common.collect.Lists; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.ibatis.session.SqlSession; +import weaver.conn.mybatis.MyBatisFactory; +import weaver.general.BaseBean; +import weaver.hrm.User; + +import java.util.*; +import java.util.stream.Collectors; + +public class OtherDeductionBiz extends BaseBean { + + private EncryptUtil encryptUtil = new EncryptUtil(); + + /** + * 条件查询 + * + * @param param + * @return + */ + public List listSome(OtherDeductionPO param) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + OtherDeductionMapper mapper = sqlSession.getMapper(OtherDeductionMapper.class); + if (CollectionUtils.isNotEmpty(param.getEmployeeIds())) { + List> partition = Lists.partition(param.getEmployeeIds(), 500); + List otherDeductionPOS = new ArrayList<>(); + partition.forEach(l -> { + param.setEmployeeIds(l); + otherDeductionPOS.addAll(mapper.listSome(param)); + }); + return encryptUtil.decryptList(otherDeductionPOS, OtherDeductionPO.class); + }else { + List otherDeductionPOS = mapper.listSome(param); + return encryptUtil.decryptList(otherDeductionPOS, OtherDeductionPO.class); + } + } finally { + sqlSession.close(); + } + } + + + /** + * 根据id获取 + * + * @param id + * @return + */ + public OtherDeductionPO getById(Long id) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + OtherDeductionMapper mapper = sqlSession.getMapper(OtherDeductionMapper.class); + OtherDeductionPO byId = mapper.getById(id); + return encryptUtil.decrypt(byId, OtherDeductionPO.class); + } finally { + sqlSession.close(); + } + } + + /** + * 详情列表 + * + * @param param + * @return + */ + public List recordList(OtherDeductionQueryParam param) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + OtherDeductionMapper mapper = sqlSession.getMapper(OtherDeductionMapper.class); + List otherDeductionRecordDTOS = mapper.recordList(param); + return encryptUtil.decryptList(otherDeductionRecordDTOS, OtherDeductionRecordDTO.class); + } finally { + sqlSession.close(); + } + } + + /** + * 批量插入 + * + * @param param + * @return + */ + public void batchSave(List param) { + if (CollectionUtils.isEmpty(param)) { + return; + } + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + OtherDeductionMapper mapper = sqlSession.getMapper(OtherDeductionMapper.class); + encryptUtil.encryptList(param, OtherDeductionPO.class); + List> partition = Lists.partition(param, 100); + partition.forEach(mapper::insertData); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + /** + * 批量插入 + * + * @param param + * @return + */ + public void batchUpdate(List param) { + if (CollectionUtils.isEmpty(param)) { + return; + } + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + OtherDeductionMapper mapper = sqlSession.getMapper(OtherDeductionMapper.class); + encryptUtil.encryptList(param, OtherDeductionPO.class); + List> partition = Lists.partition(param, 100); + partition.forEach(mapper::updateData); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + + /** + * 处理导入数据 + * + * @param pos + */ + public void handleImportData(List pos, User user) { + if (CollectionUtils.isEmpty(pos)) { + return; + } + OtherDeductionPO po = pos.get(0); + // 多条相同人的则以第一条为准,如果逆序排列(用于重复的则以最后一条为准)Collections.reverse(pos); + // 去重(通过记录的唯一条件(申报月份,人员id,个税扣缴义务人id)拼接) + List finalPos = pos.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(f -> f.getEmployeeId() + "-" + f.getTaxAgentId()))), ArrayList::new)); + // 查询已有数据 + List list = listSome(OtherDeductionPO.builder().declareMonth(po.getDeclareMonth()).build()); + // 待修改的 本地已存在则更新【交集】 + List updateList = list.stream().map(m -> { + Optional optional = finalPos.stream().filter(p -> (p.getEmployeeId() + "-" + p.getTaxAgentId()).equals(m.getEmployeeId() + "-" + m.getTaxAgentId())).findFirst(); + OtherDeductionPO temp = null; + if (optional.isPresent()) { + temp = optional.get(); + // 换成本地库的id + temp.setId(m.getId()); + } + return temp; + }).filter(Objects::nonNull).collect(Collectors.toList()); + // 待新增的 导入比本地多,则新增【差集(导入 - local)】 + List saveList = finalPos.stream().map(m -> { + Optional optional = list.stream().filter(p -> (p.getEmployeeId() + "-" + p.getTaxAgentId()).equals(m.getEmployeeId() + "-" + m.getTaxAgentId())).findFirst(); + OtherDeductionPO temp = null; + if (!optional.isPresent()) { + temp = m; + } + return temp; + }).filter(Objects::nonNull).collect(Collectors.toList()); + + // 修改 + if (CollectionUtils.isNotEmpty(updateList)) { + batchUpdate(updateList); + } + // 保存 + if (CollectionUtils.isNotEmpty(saveList)) { + batchSave(saveList); + } + + // 记录日志 + // 根据月份、人员id查出保存的数据 + List empIds = saveList.stream().map(OtherDeductionPO::getEmployeeId).collect(Collectors.toList()); + List insertList = listSome(OtherDeductionPO.builder().declareMonth(po.getDeclareMonth()).employeeIds(empIds).build()); + Map insertMap = SalaryEntityUtil.convert2Map(insertList, p -> p.getTaxAgentId() + "-" + SalaryDateUtil.getFormatYearMonth(p.getDeclareMonth()) + "-" + p.getEmployeeId()); + saveList.forEach(save -> { + OtherDeductionPO otherDeductionPO = insertMap.get(save.getTaxAgentId() + "-" + SalaryDateUtil.getFormatYearMonth(save.getDeclareMonth()) + "-" + save.getEmployeeId()); + if (otherDeductionPO != null) { + updateList.add(otherDeductionPO); + } + }); + + if (CollectionUtils.isNotEmpty(updateList)) { + String name = SalaryDateUtil.getFormatYearMonth(po.getDeclareMonth()); + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetName(SalaryI18nUtil.getI18nLabel( 0, "其他免税扣除 ") + name); + loggerContext.setOperateType(OperateTypeEnum.EXCEL_IMPORT.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel( 0, "导入")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel( 0, "其他免税扣除") + name); + loggerContext.setNewValueList(updateList); + SalaryElogConfig.otherDeductionLoggerTemplate.write(loggerContext); + } + } + + + /** + * @return void + * @description 批量删除 + * @author Harryxzy + * @date 2022/10/27 16:07 + */ + public void batchDeleteByIDS(List deleteIds) { + if (CollectionUtils.isEmpty(deleteIds)) { + return; + } + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + OtherDeductionMapper mapper = sqlSession.getMapper(OtherDeductionMapper.class); + List> partition = Lists.partition(deleteIds, 100); + partition.forEach(mapper::deleteData); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } +} diff --git a/src/com/engine/salary/biz/SIAccountBiz.java b/src/com/engine/salary/biz/SIAccountBiz.java new file mode 100644 index 000000000..6cc08b93c --- /dev/null +++ b/src/com/engine/salary/biz/SIAccountBiz.java @@ -0,0 +1,2683 @@ +package com.engine.salary.biz; + +import cn.hutool.core.util.ObjectUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.TypeReference; +import com.api.formmode.mybatis.util.SqlProxyHandle; +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.cache.SalaryCacheKey; +import com.engine.salary.constant.SalaryDefaultTenantConstant; +import com.engine.salary.encrypt.EncryptUtil; +import com.engine.salary.entity.progress.ProgressDTO; +import com.engine.salary.entity.siaccount.dto.InsuranceAccountViewListDTO; +import com.engine.salary.entity.siaccount.dto.SIAccountUtilDTO; +import com.engine.salary.entity.siaccount.param.*; +import com.engine.salary.entity.siaccount.po.*; +import com.engine.salary.entity.siarchives.po.*; +import com.engine.salary.entity.sicategory.po.ICategoryPO; +import com.engine.salary.entity.sischeme.po.InsuranceSchemeDetailPO; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import com.engine.salary.enums.siaccount.*; +import com.engine.salary.enums.sicategory.*; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.mapper.siaccount.*; +import com.engine.salary.mapper.siarchives.FundSchemeMapper; +import com.engine.salary.mapper.siarchives.InsuranceBaseInfoMapper; +import com.engine.salary.mapper.siarchives.OtherSchemeMapper; +import com.engine.salary.mapper.siarchives.SocialSchemeMapper; +import com.engine.salary.mapper.sicategory.ICategoryMapper; +import com.engine.salary.mapper.sischeme.InsuranceSchemeDetailMapper; +import com.engine.salary.mapper.taxagent.TaxAgentMapper; +import com.engine.salary.service.ProgressService; +import com.engine.salary.service.SalaryEmployeeService; +import com.engine.salary.service.TaxAgentService; +import com.engine.salary.service.impl.ProgressServiceImpl; +import com.engine.salary.service.impl.SalaryEmployeeServiceImpl; +import com.engine.salary.service.impl.TaxAgentServiceImpl; +import com.engine.salary.sys.constant.SalarySysConstant; +import com.engine.salary.sys.entity.po.SalarySysConfPO; +import com.engine.salary.sys.entity.vo.OrderRuleVO; +import com.engine.salary.sys.enums.SalaryAcctEmployeeRuleEnum; +import com.engine.salary.sys.service.SalarySysConfService; +import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl; +import com.engine.salary.util.SalaryAssert; +import com.engine.salary.util.SalaryDateUtil; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.db.IdGenerator; +import com.engine.salary.util.db.MapperProxyFactory; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.util.page.SalaryPageUtil; +import com.engine.salary.util.valid.ValidUtil; +import com.google.common.collect.Lists; +import com.wbi.util.StringUtil; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang.math.NumberUtils; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.BeanUtils; +import weaver.hrm.User; + +import java.math.BigDecimal; +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.function.Function; +import java.util.regex.Pattern; +import java.util.stream.Collectors; + +/** + * @Author weaver_cl + * @Description: + * @Date 2022/4/11 + * @Version V1.0 + **/ +@Slf4j +public class SIAccountBiz extends Service { + + private SIArchivesBiz siArchivesBiz = new SIArchivesBiz(); + + + private EncryptUtil encryptUtil = new EncryptUtil(); + + private TaxAgentService getTaxAgentService() { + return ServiceUtil.getService(TaxAgentServiceImpl.class, user); + } + + private SalaryEmployeeService getSalaryEmployeeService() { + return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user); + } + + private InsuranceAccountBatchMapper getInsuranceAccountBatchMapper() { + return SqlProxyHandle.getProxy(InsuranceAccountBatchMapper.class); + } + + + private InsuranceAccountDetailMapper getInsuranceAccountDetailMapper() { + return SqlProxyHandle.getProxy(InsuranceAccountDetailMapper.class); + } + + private SIAccountUtilMapper getSIAccountUtilMapper() { + return MapperProxyFactory.getProxy(SIAccountUtilMapper.class); + } + + private InsuranceAccountInspectMapper getInsuranceAccountInspectMapper() { + return MapperProxyFactory.getProxy(InsuranceAccountInspectMapper.class); + } + + private InsuranceBaseInfoMapper getInsuranceBaseInfoMapper() { + return MapperProxyFactory.getProxy(InsuranceBaseInfoMapper.class); + } + + private SocialSchemeMapper getSocialSchemeMapper() { + return MapperProxyFactory.getProxy(SocialSchemeMapper.class); + } + + private FundSchemeMapper getFundSchemeMapper() { + return MapperProxyFactory.getProxy(FundSchemeMapper.class); + } + + private OtherSchemeMapper getOtherSchemeMapper() { + return MapperProxyFactory.getProxy(OtherSchemeMapper.class); + } + + private SalarySysConfService getSalarySysConfService(User user) { + return ServiceUtil.getService(SalarySysConfServiceImpl.class, user); + } + + private InsuranceCompensationMapper getInsuranceCompensationMapper() { + return MapperProxyFactory.getProxy(InsuranceCompensationMapper.class); + } + + private ProgressService getSalaryAcctProgressService(User user) { + return (ProgressService) ServiceUtil.getService(ProgressServiceImpl.class, user); + } + + private SalaryEmployeeService getSalaryEmployeeService(User user) { + return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user); + } + + + private SIAccountDetailTempMapper getSIAccountDetailTempMapper() { + return MapperProxyFactory.getProxy(SIAccountDetailTempMapper.class); + } + + private InsuranceSchemeDetailMapper getInsuranceSchemeDetailMapper() { + return MapperProxyFactory.getProxy(InsuranceSchemeDetailMapper.class); + } + + private ICategoryMapper getICategoryMapper() { + return MapperProxyFactory.getProxy(ICategoryMapper.class); + } + + private TaxAgentMapper getTaxAgentMapper() { + return MapperProxyFactory.getProxy(TaxAgentMapper.class); + } + + public PageInfo listPage(InsuranceAccountBatchParam queryParam) { + List list = getInsuranceAccountBatchMapper().list(queryParam); + PageInfo page = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), + list, InsuranceAccountBatchPO.class); + encryptUtil.decryptList(page.getList(), InsuranceAccountBatchPO.class); + return page; + } + + public PageInfo listCommonPage(InsuranceAccountDetailParam queryParam) { + queryParam.setPaymentStatus(PaymentStatusEnum.COMMON.getValue()); + +// //过滤出需要核算的人员,即福利档案基础信息表中runStatus为正在缴纳和待减员的人员 +// List baseInfoPOList = getInsuranceBaseInfoMapper().listAll(); +// List canAccountIds = baseInfoPOList.stream() +// .filter(f->f.getPaymentOrganization().toString().equals(queryParam.getPaymentOrganization()) +// && (f.getRunStatus().equals(EmployeeStatusEnum.PAYING.getValue()) || f.getRunStatus().equals(EmployeeStatusEnum.STAY_DEL.getValue()))) +// .map(InsuranceArchivesBaseInfoPO::getEmployeeId) +// .collect(Collectors.toList()); +// queryParam.setEmployeeIds(canAccountIds); + //排序配置 + OrderRuleVO orderRule = getSalarySysConfService(user).orderRule(); + queryParam.setOrderRule(orderRule); + + //系统人员福利台账明细 + List list = getInsuranceAccountDetailMapper().list(queryParam); + //非系统各人员台账明细 + List extList = getInsuranceAccountDetailMapper().extList(queryParam); + list.addAll(extList); + + PageInfo pageInfo = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), + list, InsuranceAccountDetailPO.class); + encryptUtil.decryptList(pageInfo.getList(), InsuranceAccountDetailPO.class); + return pageInfo; + } + + public String save(boolean flag, AccountParam param, Long employeeId, String currentUserName) { + if (flag) { + InsuranceAccountBatchPO insuranceAccountBatchPO = getInsuranceAccountBatchMapper().getByBillMonth(param.getBillMonth(), param.getPaymentOrganization()); + insuranceAccountBatchPO = encryptUtil.decrypt(insuranceAccountBatchPO, InsuranceAccountBatchPO.class); + SalaryAssert.isNull(insuranceAccountBatchPO, SalaryI18nUtil.getI18nLabel(100461, "所属月份存在核算数据")); + + InsuranceAccountBatchPO build = InsuranceAccountBatchPO.builder() + .paymentOrganization(param.getPaymentOrganization()) + .accountant(currentUserName) + .billMonth(param.getBillMonth()) + .billStatus(BillStatusEnum.NOT_ARCHIVED.getValue()) + .remarks(param.getRemarks()) + .creator(employeeId) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .createTime(new Date()) + .updateTime(new Date()) + .deleteType(DeleteTypeEnum.NOT_DELETED.getValue()) + .paymentOrganization(param.getPaymentOrganization()) + .socialPay("0") + .fundPay("0") + .otherPay("0") + .build(); + encryptUtil.encrypt(build, InsuranceAccountBatchPO.class); + getInsuranceAccountBatchMapper().insert(build); +// LoggerContext insuranceSchemeContext = new LoggerContext(); +// insuranceSchemeContext.setTargetId(String.valueOf(build.getId())); +// insuranceSchemeContext.setTargetName(build.getBillMonth()); +// insuranceSchemeContext.setOperateType(OperateTypeEnum.ADD.getValue()); +// insuranceSchemeContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 100462, "新增台账")); +// insuranceSchemeContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 100462, "新增台账")); +// insuranceSchemeContext.setNewValues(build); +// siAccountLoggerTemplate.write(insuranceSchemeContext); + } + try { + account(param, employeeId, SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY, currentUserName); + } catch (Exception e) { + // 回滚 + List list = Lists.newArrayList(getInsuranceAccountBatchMapper().getByBillMonth(param.getBillMonth(), param.getPaymentOrganization())); + list = encryptUtil.decryptList(list, InsuranceAccountBatchPO.class); + if (CollectionUtils.isNotEmpty(list)) { + list.stream().forEach(f -> { + getInsuranceAccountBatchMapper().deleteById(f.getId()); + }); + } + throw new SalaryRunTimeException(e.getMessage()); + } + return employeeId.toString(); + } + + public void account(AccountParam param, Long employeeId, String tenantKey, String currentUserName) { + +// Collection employeeIdsInTaxAgent = getTaxAgentService().listEmployeeIdsInTaxAgent(param.getPaymentOrganization()); + + Long paymentOrganization = param.getPaymentOrganization(); +// List employeeIds = getInsuranceAccountDetailMapper().selectAccountIds(SalaryDateUtil.getMonthBegin(param.getBillMonth()), paymentOrganization); + List employeeIds = getInsuranceAccountDetailMapper().selectEmpByPaymentOrg(paymentOrganization); +// employeeIds = employeeIds.stream().filter(employeeIdsInTaxAgent::contains).collect(Collectors.toList()); + if (CollectionUtils.isEmpty(employeeIds)) { + List list = Lists.newArrayList(getInsuranceAccountDetailMapper().queryNormalListByBillMonth(param.getBillMonth(), paymentOrganization)); + encryptUtil.decryptList(list, InsuranceAccountDetailPO.class); + if (CollectionUtils.isNotEmpty(list)) { + list.stream().forEach(f -> { + getInsuranceAccountDetailMapper().deleteById(f.getId()); + }); + } + } + SalaryAssert.notEmpty(employeeIds, "没有需要核算的人员"); + AccountParam selectParam = new AccountParam(); + selectParam.setBillMonth(param.getBillMonth()); + selectParam.setPaymentOrganization(paymentOrganization); + ExecutorService taskExecutor = Executors.newCachedThreadPool(); + taskExecutor.execute(() -> { + try { + DSTenantKeyThreadVar.tenantKey.set(tenantKey); + accounting(selectParam, employeeId, tenantKey, currentUserName); + } finally { + DSTenantKeyThreadVar.tenantKey.remove(); + } + }); + } + + public void accounting(AccountParam param, Long employeeId, String tenantKey, String currentUserName) { + //薪资核算进度暂未实现 + ProgressDTO salaryAcctProgressDTO = getSalaryAcctProgressService(user).getProgress(SalaryCacheKey.ACCT_PROGRESS + param.getBillMonth()); + if (salaryAcctProgressDTO != null && salaryAcctProgressDTO.isStatus() && salaryAcctProgressDTO.getProgress().compareTo(BigDecimal.ONE) < 0) { + return; + } + + // 初始化进度 + ProgressDTO initProgress = new ProgressDTO() + .setTitle(SalaryI18nUtil.getI18nLabel(97515, "核算中")) + .setTitleLabelId(97515L) + .setTotalQuantity(NumberUtils.INTEGER_ONE) + .setCalculatedQuantity(NumberUtils.INTEGER_ZERO) + .setProgress(BigDecimal.ZERO) + .setStatus(true) + .setMessage(StringUtils.EMPTY); + getSalaryAcctProgressService(user).initProgress(SalaryCacheKey.ACCT_PROGRESS + param.getBillMonth(), initProgress); + + log.info("开始核算,当前操作人为:{}", currentUserName); + doAccounting(param, employeeId, tenantKey, currentUserName); + } + + + public void doAccounting(AccountParam param, Long employeeId, String tenantKey, String currentUserName) { + log.info("核算时间:{}, 核算月份:{}, 个税扣缴义务人:{}, 是否首次核算:{}", new Date(), param.getBillMonth(), param.getPaymentOrganization(), param.isFlag()); + try { + List ids; + List validIds = new ArrayList<>(); + if (CollectionUtils.isEmpty(param.getIds())) { + // 需要分权的情况 +// if(getTaxAgentService().isOpenDevolution()) { + List empIds = getInsuranceAccountDetailMapper().selectEmpByPaymentOrg(param.getPaymentOrganization()); + + // 获取薪资核算人员规则 + SalarySysConfPO salaryAcctEmployeeRule = getSalarySysConfService(user).getOneByCode(SalarySysConstant.SALARY_ACCT_EMPLOYEE_RULE); + List status = new ArrayList<>(); + if(Objects.isNull(salaryAcctEmployeeRule) || StringUtils.equals(salaryAcctEmployeeRule.getConfValue(), SalaryAcctEmployeeRuleEnum.BYPAYENDTIME.getValue()) ){ + // 包含停缴 + status = Arrays.asList(EmployeeStatusEnum.PAYING.getValue(),EmployeeStatusEnum.STAY_DEL.getValue(), + EmployeeStatusEnum.STOP_PAYMENT_FROM_DEL.getValue()); + }else{ + status = Arrays.asList(EmployeeStatusEnum.PAYING.getValue(),EmployeeStatusEnum.STAY_DEL.getValue()); + } + List finalStatus = status; + //过滤出需要核算的人员,即福利档案基础信息表中runStatus为正在缴纳和待减员的人员 + List baseInfoPOList = getInsuranceBaseInfoMapper().listAll(); + List canAccountIds = baseInfoPOList.stream() + .filter(f->f.getPaymentOrganization().equals(param.getPaymentOrganization()) + && (finalStatus.contains(f.getRunStatus()) )) + .map(InsuranceArchivesBaseInfoPO::getEmployeeId) + .collect(Collectors.toList()); + + //20231122逻辑优化,过滤出不在起始缴纳月和最后缴纳月区间的人员 + List empIdsInPayMonthRange = listCanPayEmpIds(param.getPaymentOrganization(), param.getBillMonth()); + empIds = empIds.stream().filter(f->canAccountIds.contains(f) && empIdsInPayMonthRange.contains(f)).collect(Collectors.toList()); + + //过滤不在扣缴义务人下的数据 +// Collection employeeIdsInTaxAgent = getTaxAgentService().listEmployeeIdsInTaxAgent(param.getPaymentOrganization()); +// empIds = empIds.stream().filter(employeeIdsInTaxAgent::contains).collect(Collectors.toList()); + + List socials = siArchivesBiz.getSocialByEmployeeIds(empIds); + //过滤出目标个税扣缴义务人相关信息 + socials = socials.stream().filter(f -> f.getPaymentOrganization().equals(param.getPaymentOrganization())).collect(Collectors.toList()); + List emp1 = socials.stream() + .filter(s -> !(StringUtils.isBlank(s.getSocialEndTime()) && StringUtils.isBlank(s.getSocialStartTime())) && + (StringUtils.isBlank(s.getSocialEndTime()) || (SalaryDateUtil.stringToDate(s.getSocialEndTime() + "-01") != null && !SalaryDateUtil.stringToDate(param.getBillMonth() + "-01").after(SalaryDateUtil.stringToDate(s.getSocialEndTime() + "-01")))) ) + .map(InsuranceArchivesSocialSchemePO::getEmployeeId) + .collect(Collectors.toList()); + + List funds = siArchivesBiz.getFundByEmployeeIds(empIds); + //过滤出目标个税扣缴义务人相关信息 + funds = funds.stream().filter(f -> f.getPaymentOrganization().equals(param.getPaymentOrganization())).collect(Collectors.toList()); + List emp2 = funds.stream() + .filter(s -> !(StringUtils.isBlank(s.getFundStartTime()) && StringUtils.isBlank(s.getFundEndTime())) && + (StringUtils.isBlank(s.getFundEndTime()) || (SalaryDateUtil.stringToDate(s.getFundEndTime() + "-01") != null && !SalaryDateUtil.stringToDate(param.getBillMonth() + "-01").after(SalaryDateUtil.stringToDate(s.getFundEndTime() + "-01"))))) + .map(InsuranceArchivesFundSchemePO::getEmployeeId) + .collect(Collectors.toList()); + + List others = siArchivesBiz.getOtherByEmployeeIds(empIds); + //过滤出目标个税扣缴义务人相关信息 + others = others.stream().filter(f -> f.getPaymentOrganization().equals(param.getPaymentOrganization())).collect(Collectors.toList()); + List emp3 = others.stream() + .filter(s -> !(StringUtils.isBlank(s.getOtherStartTime()) && StringUtils.isBlank(s.getOtherEndTime())) && + (StringUtils.isBlank(s.getOtherEndTime()) || (SalaryDateUtil.stringToDate(s.getOtherEndTime() + "-01") != null && !SalaryDateUtil.stringToDate(param.getBillMonth() + "-01").after(SalaryDateUtil.stringToDate(s.getOtherEndTime() + "-01"))))) + .map(InsuranceArchivesOtherSchemePO::getEmployeeId) + .collect(Collectors.toList()); + validIds.addAll(emp1); + validIds.addAll(emp2); + validIds.addAll(emp3); + + List finalValidIds = validIds.stream().distinct().collect(Collectors.toList()); + ids = empIds.stream().filter(finalValidIds::contains).collect(Collectors.toList()); + +// } else { +// ids = getInsuranceAccountDetailMapper().selectAccountIds(SalaryDateUtil.getMonthBegin(param.getBillMonth()), null); +// } + } else { + ids = param.getIds(); + } + if (CollectionUtils.isEmpty(ids)) { + getSalaryAcctProgressService(user).finish(SalaryCacheKey.ACCT_PROGRESS + param.getBillMonth(), true); +// getSalaryAcctProgressService(user).fail(SalaryCacheKey.ACCT_PROGRESS + param.getBillMonth(), SalaryI18nUtil.getI18nLabel( 100468, "无需要核算的人员")); + return; + } +// SalaryAcctProgressDTO salaryAcctProgressDTO = new SalaryAcctProgressDTO(SalaryI18nUtil.getI18nLabel(97515, "核算中"), 97515L, ids.size(), 0, +// BigDecimal.ZERO, true, "", true); + //salaryAcctProgressService.initProgress(tenantKey + param.getBillMonth(), salaryAcctProgressDTO, employeeId, tenantKey); + + // 初始化进度 + ProgressDTO initProgress = new ProgressDTO() + .setTitle(SalaryI18nUtil.getI18nLabel(97515, "核算中")) + .setTitleLabelId(97515L) + .setTotalQuantity(ids.size()) + .setCalculatedQuantity(NumberUtils.INTEGER_ZERO) + .setProgress(BigDecimal.ZERO) + .setStatus(true) + .setMessage(StringUtils.EMPTY); + getSalaryAcctProgressService(user).initProgress(SalaryCacheKey.ACCT_PROGRESS + param.getBillMonth(), initProgress); + /* List> partition = Lists.partition(ids, 100); + CountDownLatch countDownLatch = new CountDownLatch(partition.size()); + BlockingDeque results = new LinkedBlockingDeque<>(partition.size());*/ + log.info("开始生成福利核算数据,待处理人员数量:{}", ids.size()); + commonAccount(/*countDownLatch, results, */param.getBillMonth(), ids, employeeId, tenantKey, param.getPaymentOrganization()); + log.info("福利核算数据生成完毕,开始数据处理"); + /* for (List batchIds : partition) { + taskExecutor.execute(() -> { + commonAccount(countDownLatch, results, param.getBillMonth(), batchIds, simpleEmployee); + }); + } + countDownLatch.await(); + boolean allSuccess = results.stream().allMatch(Boolean::booleanValue);*/ + /* if (allSuccess) {*/ + handleData(ids, param, employeeId, tenantKey, currentUserName); + log.info("福利核算数据处理完毕!"); + /*}*/ + List> partition = Lists.partition((List) ids, 100); + partition.forEach(part -> { + getSIAccountDetailTempMapper().batchDelByEmpIdsAndMonthAndPayOrg(part, param.getBillMonth(), param.getPaymentOrganization()); + }); + log.info("更新福利核算进度······"); + getSalaryAcctProgressService(user).finish(SalaryCacheKey.ACCT_PROGRESS + param.getBillMonth(), true); + log.info("福利核算进度完成!"); + } catch (Exception e) { + log.error("account run fail", e); + getSalaryAcctProgressService(user).fail(SalaryCacheKey.ACCT_PROGRESS + param.getBillMonth(), SalaryI18nUtil.getI18nLabel(99642, "福利核算出错") + ": " + e.getMessage()); + + List list = Lists.newArrayList(getInsuranceAccountBatchMapper().getByBillMonth(param.getBillMonth(), param.getPaymentOrganization())); + if (CollectionUtils.isNotEmpty(list)) { + list.stream().forEach(f -> { + getInsuranceAccountBatchMapper().deleteById(f.getId()); + }); + } + + //薪资核算进度暂未实现 + //salaryAcctProgressService.del(tenantKey + param.getBillMonth(), employeeId, tenantKey); + //logger.error("welfare account error:{}", e.getMessage(), e); + } + } + + /** + * 根据个税扣缴义务人和账单月,获取三类福利档案中符合缴纳开始结束月区间的人员id + * @param paymentOrganization + * @param billMonth + * @return + */ + public List listCanPayEmpIds(Long paymentOrganization, String billMonth) { + List listCanPayEmpIds = new ArrayList<>(); + //社保档案中可进行缴纳的人员 + List socialCanPayEmpIds = getSocialSchemeMapper().listCanPayEmpIds(paymentOrganization, billMonth, 0); + //公积金档案中可进行缴纳的人员 + List fundCanPayEmpIds = getFundSchemeMapper().listCanPayEmpIds(paymentOrganization, billMonth, 0); + //其他福利档案中可进行缴纳的人员 + List otherCanPayEmpIds = getOtherSchemeMapper().listCanPayEmpIds(paymentOrganization, billMonth, 0); + if (socialCanPayEmpIds != null && socialCanPayEmpIds.size() > 0) { + listCanPayEmpIds.addAll(socialCanPayEmpIds); + } + if (fundCanPayEmpIds != null && fundCanPayEmpIds.size() > 0) { + listCanPayEmpIds.addAll(fundCanPayEmpIds); + } + if (otherCanPayEmpIds != null && otherCanPayEmpIds.size() > 0) { + listCanPayEmpIds.addAll(otherCanPayEmpIds); + } + //去重 + listCanPayEmpIds = listCanPayEmpIds.stream().distinct().collect(Collectors.toList()); + return listCanPayEmpIds; + } + + public void commonAccount(/*CountDownLatch countDownLatch, BlockingDeque results,*/ String billMonth, List ids, Long employeeId, String tenantKey, Long paymentOrganization) { + /* try {*/ + SIArchivesBiz siArchivesBiz = new SIArchivesBiz(); + Map insuranceArchivesAccountPOS = siArchivesBiz.buildBatchAccount(ids, paymentOrganization); + List list = new ArrayList<>(); + int count = 0; + for (Map.Entry entry : insuranceArchivesAccountPOS.entrySet()) { + Long k = entry.getKey(); + InsuranceArchivesAccountPO v = entry.getValue(); + InsuranceAccountDetailPO insuranceAccountDetailPO = new InsuranceAccountDetailPO(); + insuranceAccountDetailPO.setBillMonth(billMonth); + insuranceAccountDetailPO.setBillStatus(BillStatusEnum.NOT_ARCHIVED.getValue()); + insuranceAccountDetailPO.setCreator(employeeId); + insuranceAccountDetailPO.setCreateTime(new Date()); + insuranceAccountDetailPO.setDeleteType(DeleteTypeEnum.NOT_DELETED.getValue()); + insuranceAccountDetailPO.setEmployeeId(k); + insuranceAccountDetailPO.setUpdateTime(new Date()); + insuranceAccountDetailPO.setPaymentStatus(PaymentStatusEnum.COMMON.getValue()); + insuranceAccountDetailPO.setResourceFrom(ResourceFromEnum.SYSTEM.getValue()); + insuranceAccountDetailPO.setTenantKey(tenantKey); + insuranceAccountDetailPO.setPaymentOrganization(paymentOrganization); + + //核算社保 + accountSocial(insuranceAccountDetailPO, v, billMonth, tenantKey); + //核算公积金 + accountFund(insuranceAccountDetailPO, v, billMonth, tenantKey); + //核算其他福利 + accountOther(insuranceAccountDetailPO, v, billMonth, tenantKey); + //计算合计 + account(insuranceAccountDetailPO); + //临时表PO + InsuranceAccountDetailTempPO insuranceAccountDetailTempPO = new InsuranceAccountDetailTempPO(); + BeanUtils.copyProperties(insuranceAccountDetailPO, insuranceAccountDetailTempPO); + list.add(insuranceAccountDetailTempPO); + count++; + + if (count % 50 == 0 || count >= ids.size()) { + //salaryAcctProgressService.getAndAddCalculatedQty(tenantKey + billMonth, count >= ids.size() ? count % 50 : 50); + + if (count >= ids.size()) { + getSalaryAcctProgressService(user).updateProgress(SalaryCacheKey.ACCT_PROGRESS + billMonth, BigDecimal.valueOf(0.99), false); + log.info("更新福利核算进度,当前进度为:{}", getSalaryAcctProgressService(user).getProgress(SalaryCacheKey.ACCT_PROGRESS + billMonth)); + } else { + getSalaryAcctProgressService(user).getAndAddCalculatedQty(SalaryCacheKey.ACCT_PROGRESS + billMonth, count >= ids.size() ? count % 50 : 50); + log.info("更新福利核算进度,当前进度为:{}", getSalaryAcctProgressService(user).getProgress(SalaryCacheKey.ACCT_PROGRESS + billMonth)); + } + + } + + } + + //临时表入库前先对(可能存在的)历史数据进行删除 + List> partition = Lists.partition((List) ids, 100); + partition.forEach(part -> { + getSIAccountDetailTempMapper().batchDelByEmpIdsAndMonthAndPayOrg(part, billMonth, paymentOrganization); + }); + //临时表数据入库 + if (CollectionUtils.isNotEmpty(list)) { + encryptUtil.encryptList(list, InsuranceAccountDetailTempPO.class); + List> lists = splitList(list, 20); + lists.forEach(subList -> { + getSIAccountDetailTempMapper().batchSaveAccountTempDetails(subList); + }); + } + + /* } catch (Exception e) { + logger.error("福利核算失败:{}", e.getMessage(), e); + results.add(false); + } finally { + countDownLatch.countDown(); + }*/ + } + + private List> splitList(List list, int groupSize) { + int length = list.size(); + // 计算可以分成多少组 + int num = (length + groupSize - 1) / groupSize; + List> newList = new ArrayList<>(num); + for (int i = 0; i < num; i++) { + // 开始位置 + int fromIndex = i * groupSize; + // 结束位置 + int toIndex = (i + 1) * groupSize < length ? (i + 1) * groupSize : length; + newList.add(list.subList(fromIndex, toIndex)); + } + return newList; + } + + + private void handleData(List ids, AccountParam param, Long employeeId, String tenantKey, String currentUserName) { + //事务后续处理 + //TransactionStatus status = transactionManager.getTransaction(new DefaultTransactionDefinition()); + String billMonth = param.getBillMonth(); + try { +// List list = getSIAccountDetailTempMapper().getListByEmployeeIdsAndBillMonth(ids, billMonth, param.getPaymentOrganization()); + List list = new ArrayList<>(); + List> partitionDetailTempInfo = Lists.partition((List) ids, 100); + partitionDetailTempInfo.forEach(part -> list.addAll( + getSIAccountDetailTempMapper().getListByEmployeeIdsAndBillMonth(part, billMonth, param.getPaymentOrganization()))); + + encryptUtil.decryptList(list, InsuranceAccountDetailTempPO.class); + Integer paymentStatus = 0; + log.info("核算明细临时表 hrsa_bill_detail_temp待处理数量:{}", list.size()); + List> partitionIds = Lists.partition((List) ids, 100); + log.info("bill_detail入库前删除数据数量:{}", ids.size()); + for (List part : partitionIds) { + getInsuranceAccountDetailMapper().batchDelAccountDetails(part, billMonth, param.getPaymentOrganization(), paymentStatus); + + //删除账单月份+个税扣缴义务人+人员id下的调差数据 + getInsuranceCompensationMapper().deleteByBillMonthPayOrgEmpIds(InsuranceCompensationPO.builder() + .billMonth(billMonth) + .paymentOrganization(param.getPaymentOrganization()) + .employeeIds(part) + .build()); + } + + //生成bill_detail入库数据 + List collect = list.stream().map(item -> { + InsuranceAccountDetailPO insuranceAccountDetailPO = new InsuranceAccountDetailPO(); + BeanUtils.copyProperties(item, insuranceAccountDetailPO); + return insuranceAccountDetailPO; + }).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(collect)) { + log.info("bill_detail入库数据数量:{}", collect.size()); + batchSaveAccountInspectDetail(collect, billMonth, tenantKey); + encryptUtil.encryptList(collect, InsuranceAccountDetailPO.class); + List> lists = splitDetailList(collect, 20); + lists.forEach(subList -> { + getInsuranceAccountDetailMapper().batchSaveAccountDetails(subList); + }); + updateBatchAccount(param, employeeId, tenantKey, currentUserName); + } + //transactionManager.commit(status); + } catch (Exception e) { + log.error("福利核算数据处理失败", e); + getSalaryAcctProgressService(user).fail(SalaryCacheKey.ACCT_PROGRESS + param.getBillMonth(), SalaryI18nUtil.getI18nLabel(99642, "福利核算出错") + ": " + e.getMessage()); + //transactionManager.rollback(status); + throw e; + } + } + + + public InsuranceAccountDetailPO account(InsuranceAccountDetailPO insuranceAccountDetailPO) { + //个人合计 + BigDecimal socialPerson = + StringUtils.isBlank(insuranceAccountDetailPO.getSocialPerSum()) ? new BigDecimal("0") : new BigDecimal(insuranceAccountDetailPO.getSocialPerSum()); + BigDecimal fundPerson = + StringUtils.isBlank(insuranceAccountDetailPO.getFundPerSum()) ? new BigDecimal("0") : new BigDecimal(insuranceAccountDetailPO.getFundPerSum()); + BigDecimal otherPerson = + StringUtils.isBlank(insuranceAccountDetailPO.getOtherPerSum()) ? new BigDecimal("0") : new BigDecimal(insuranceAccountDetailPO.getOtherPerSum()); + BigDecimal perSum = socialPerson.add(fundPerson).add(otherPerson); + insuranceAccountDetailPO.setPerSum(perSum.toPlainString()); + //单位合计 + BigDecimal socialCom = + StringUtils.isBlank(insuranceAccountDetailPO.getSocialComSum()) ? new BigDecimal("0") : new BigDecimal(insuranceAccountDetailPO.getSocialComSum()); + BigDecimal fundCom = StringUtils.isBlank(insuranceAccountDetailPO.getFundComSum()) ? new BigDecimal("0") : new BigDecimal(insuranceAccountDetailPO.getFundComSum()); + BigDecimal otherCom = + StringUtils.isBlank(insuranceAccountDetailPO.getOtherComSum()) ? new BigDecimal("0") : new BigDecimal(insuranceAccountDetailPO.getOtherComSum()); + BigDecimal comSum = socialCom.add(fundCom).add(otherCom); + insuranceAccountDetailPO.setComSum(comSum.toPlainString()); + //社保合计 + insuranceAccountDetailPO.setSocialSum(socialPerson.add(socialCom).toPlainString()); + //公积金合计 + insuranceAccountDetailPO.setFundSum(fundPerson.add(fundCom).toPlainString()); + //其他福利合计 + insuranceAccountDetailPO.setOtherSum(otherPerson.add(otherCom).toPlainString()); + //合计 + insuranceAccountDetailPO.setTotal(perSum.add(comSum).toPlainString()); + return insuranceAccountDetailPO; + } + + public InsuranceAccountDetailPO accountOther(InsuranceAccountDetailPO insuranceAccountDetailPO, InsuranceArchivesAccountPO accountPO, String billMonth, String tenantKey) { + boolean welBaseDiffSign = siArchivesBiz.isDiffWelBase(); + if (accountPO.getOther() != null) { + InsuranceArchivesOtherSchemePO otherPO = accountPO.getOther(); + insuranceAccountDetailPO.setOtherPayOrg(otherPO.getPaymentOrganization()); + insuranceAccountDetailPO.setOtherSchemeId(otherPO.getOtherSchemeId()); + insuranceAccountDetailPO.setOtherPaymentBaseString(otherPO.getOtherPaymentBaseString()); + insuranceAccountDetailPO.setOtherPaymentComBaseString(otherPO.getOtherPaymentComBaseString()); + //判断是否在起始缴纳月和最后缴纳月之间 + Boolean inDataRange = SalaryDateUtil.monthInRange(insuranceAccountDetailPO.getBillMonth(), otherPO.getOtherStartTime(), otherPO.getOtherEndTime()); + if ((Objects.equals(NonPaymentEnum.YES.getValue(), otherPO.getNonPayment()) || otherPO.getNonPayment() == null) && otherPO.getOtherSchemeId() != null && inDataRange) { + List detailPOS = getInsuranceSchemeDetailMapper().queryListBySchemeId(otherPO.getOtherSchemeId()); + encryptUtil.decryptList(detailPOS, InsuranceSchemeDetailPO.class); + //方案中包含的需要缴纳其他的个人福利 + int monthIndex = Integer.parseInt(billMonth.split("-")[1]) - 1; + Map otherPerson = detailPOS.stream() + .filter(item -> Objects.equals(IsPaymentEnum.YES.getValue(), item.getIsPayment()) && Objects.equals(item.getPaymentScope(), PaymentScopeEnum.SCOPE_PERSON.getValue()) + && (item.getPaymentCycle() == null || item.getPaymentCycle() == 0 || (item.getPaymentCycle() == 1 && String.valueOf(item.getCycleSetting().charAt(monthIndex)).equals("1")))) + .collect( + Collectors.toMap(InsuranceSchemeDetailPO::getInsuranceId, Function.identity())); + //档案中包含的基数信息 + HashMap archivesPerson = JSON.parseObject(otherPO.getOtherPaymentBaseString(), new HashMap().getClass()); + //需要核算其他的福利id 个人 + List needArchivesPerson = new ArrayList<>(); + if (archivesPerson != null) { + archivesPerson.forEach((id, value) -> { + if (otherPerson.containsKey(Long.valueOf(id))) { + needArchivesPerson.add(Long.valueOf(id)); + } + }); + } + //避免福利档案的方案未设置基数,导致核算时遗漏这些福利项的核算,遍历下方案相关福利项,并将遗漏的福利项id添加 + if(otherPerson.size() > 0) { + otherPerson.forEach((id, object) -> { + if (!needArchivesPerson.contains(id)) { + needArchivesPerson.add(id); + } + }); + } + //判断核算周期、核算月、福利起始缴纳月的关系 + checkCycleSettingWithStartMonth(otherPerson, billMonth, otherPO.getOtherStartTime()); + + List otherPer = new ArrayList<>(); + Map otherPerJsonMap = new HashMap<>(); + needArchivesPerson.stream().forEach(e -> { + InsuranceSchemeDetailPO po = otherPerson.get(e); + BigDecimal paymentProportion = new BigDecimal(StringUtils.isBlank(po.getPaymentProportion()) ? "0" : po.getPaymentProportion()).divide(new BigDecimal("100")); + BigDecimal paymentNum = new BigDecimal((ObjectUtil.isEmpty(archivesPerson) || StringUtils.isBlank(archivesPerson.get(String.valueOf(e)))) ? "0" : archivesPerson.get(String.valueOf(e))); + BigDecimal fixedCost = StringUtils.isBlank(po.getFixedCost()) ? new BigDecimal("0") : new BigDecimal(po.getFixedCost()); + Integer newScale = po.getValidNum() == null ? 2 : po.getValidNum(); +// BigDecimal result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost)); + BigDecimal result = new BigDecimal("0"); + if (po.getPaymentCycle() != null && po.getPaymentCycle() == 1) { + int monthValue = 1; + for (int i = monthIndex - 1; i >= 0; i--) { + String cycleValue = po.getCycleSetting().charAt(i) + ""; + if (Integer.parseInt(cycleValue) == 1) { + break; + } + monthValue++; + } + if (po.getAccountType() == 1) { + paymentNum = paymentNum.multiply(new BigDecimal(monthValue)); + fixedCost = fixedCost.multiply(new BigDecimal(monthValue)); + result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost)); + } else { + for (int i = 0; i < monthValue; i++) { + result = result.add(SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost))); + } + } + } else { + result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost)); + } + otherPerJsonMap.put(String.valueOf(e), result.toPlainString()); + otherPer.add(result); + }); + insuranceAccountDetailPO.setOtherPerJson(JSON.toJSONString(otherPerJsonMap)); + BigDecimal otherPerSum = new BigDecimal("0"); + for (BigDecimal bigDecimal : otherPer) { + otherPerSum = otherPerSum.add(bigDecimal); + } + insuranceAccountDetailPO.setOtherPerSum(otherPerSum.toPlainString()); + + //方案中包含的需要缴纳公积金的单位福利 + Map otherCom = detailPOS.stream() + .filter( + item -> Objects.equals(IsPaymentEnum.YES.getValue(), item.getIsPayment()) && Objects.equals(item.getPaymentScope(), PaymentScopeEnum.SCOPE_COMPANY.getValue()) + && (item.getPaymentCycle() == null || item.getPaymentCycle() == 0 || (item.getPaymentCycle() == 1 && String.valueOf(item.getCycleSetting().charAt(monthIndex)).equals("1")))) + .collect( + Collectors.toMap(InsuranceSchemeDetailPO::getInsuranceId, Function.identity())); + //档案中包含的基数信息 +// HashMap archivesCom = JSON.parseObject(otherPO.getOtherPaymentBaseString(), new HashMap().getClass()); + HashMap archivesCom = new HashMap<>(); + if (welBaseDiffSign) { + archivesCom = JSON.parseObject(otherPO.getOtherPaymentComBaseString(), new HashMap().getClass()); + } else { + archivesCom = JSON.parseObject(otherPO.getOtherPaymentBaseString(), new HashMap().getClass()); + } + //需要核算其他的福利id 单位 + List needArchivesCom = new ArrayList<>(); + if (archivesCom != null) { + archivesCom.forEach((id, value) -> { + if (otherCom.containsKey(Long.valueOf(id))) { + needArchivesCom.add(Long.valueOf(id)); + } + }); + } + //避免福利档案的方案未设置基数,导致核算时遗漏这些福利项的核算,遍历下方案相关福利项,并将遗漏的福利项id添加 + if(otherCom.size() > 0) { + otherCom.forEach((id, object) -> { + if (!needArchivesCom.contains(id)) { + needArchivesCom.add(id); + } + }); + } + //判断核算周期、核算月、福利起始缴纳月的关系 + checkCycleSettingWithStartMonth(otherCom, billMonth, otherPO.getOtherStartTime()); + + List otherComList = new ArrayList<>(); + Map otherComJsonMap = new HashMap<>(); + HashMap finalArchivesCom = archivesCom; + needArchivesCom.stream().forEach(e -> { + InsuranceSchemeDetailPO po = otherCom.get(e); + BigDecimal paymentProportion = new BigDecimal(StringUtils.isBlank(po.getPaymentProportion()) ? "0" : po.getPaymentProportion()).divide(new BigDecimal("100")); + BigDecimal paymentNum = new BigDecimal((ObjectUtil.isEmpty(finalArchivesCom) || StringUtils.isBlank(finalArchivesCom.get(String.valueOf(e)))) ? "0" : finalArchivesCom.get(String.valueOf(e))); + BigDecimal fixedCost = StringUtils.isBlank(po.getFixedCost()) ? new BigDecimal("0") : new BigDecimal(po.getFixedCost()); + Integer newScale = po.getValidNum() == null ? 2 : po.getValidNum(); +// BigDecimal result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost)); + BigDecimal result = new BigDecimal("0"); + if (Objects.equals(po.getPaymentCycle(), 1)) { + int monthValue = 1; + for (int i = monthIndex - 1; i >= 0; i--) { + String cycleValue = po.getCycleSetting().charAt(i) + ""; + if (Integer.parseInt(cycleValue) == 1) { + break; + } + monthValue++; + } + if (po.getAccountType() == 1) { + paymentNum = paymentNum.multiply(new BigDecimal(monthValue)); + fixedCost = fixedCost.multiply(new BigDecimal(monthValue)); + result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost)); + } else { + for (int i = 0; i < monthValue; i++) { + result = result.add(SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost))); + } + } + } else { + result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost)); + } + otherComJsonMap.put(String.valueOf(e), result.toPlainString()); + otherComList.add(result); + }); + insuranceAccountDetailPO.setOtherComJson(JSON.toJSONString(otherComJsonMap)); + BigDecimal otherComSum = new BigDecimal("0"); + for (BigDecimal bigDecimal : otherComList) { + otherComSum = otherComSum.add(bigDecimal); + } + insuranceAccountDetailPO.setOtherComSum(otherComSum.toPlainString()); + } + } + return insuranceAccountDetailPO; + } + + + public InsuranceAccountDetailPO accountFund(InsuranceAccountDetailPO insuranceAccountDetailPO, InsuranceArchivesAccountPO accountPO, String billMonth, String tenantKey) { + boolean welBaseDiffSign = siArchivesBiz.isDiffWelBase(); + if (accountPO.getFund() != null) { + InsuranceArchivesFundSchemePO fundPO = accountPO.getFund(); + insuranceAccountDetailPO.setFundPayOrg(fundPO.getPaymentOrganization()); + insuranceAccountDetailPO.setFundAccount(fundPO.getFundAccount()); + insuranceAccountDetailPO.setSupplementFundAccount(fundPO.getSupplementFundAccount()); + insuranceAccountDetailPO.setFundSchemeId(fundPO.getFundSchemeId()); + insuranceAccountDetailPO.setFundPaymentBaseString(fundPO.getFundPaymentBaseString()); + insuranceAccountDetailPO.setFundPaymentComBaseString(fundPO.getFundPaymentComBaseString()); + //判断是否在起始缴纳月和最后缴纳月之间 + Boolean inDataRange = SalaryDateUtil.monthInRange(insuranceAccountDetailPO.getBillMonth(), fundPO.getFundStartTime(), fundPO.getFundEndTime()); + if ((NonPaymentEnum.YES.getValue() == fundPO.getNonPayment() || fundPO.getNonPayment() == null) && fundPO.getFundSchemeId() != null && inDataRange) { + List detailPOS = getInsuranceSchemeDetailMapper().queryListBySchemeId(fundPO.getFundSchemeId()); + encryptUtil.decryptList(detailPOS, InsuranceSchemeDetailPO.class); + //方案中包含的需要缴纳社保的个人福利 + int monthIndex = Integer.parseInt(billMonth.split("-")[1]) - 1; + Map fundperson = detailPOS.stream() + .filter(item -> Objects.equals(IsPaymentEnum.YES.getValue(), item.getIsPayment()) && Objects.equals(item.getPaymentScope(), PaymentScopeEnum.SCOPE_PERSON.getValue()) + && (item.getPaymentCycle() == null || item.getPaymentCycle() == 0 || (item.getPaymentCycle() == 1 && String.valueOf(item.getCycleSetting().charAt(monthIndex)).equals("1")))) + .collect( + Collectors.toMap(InsuranceSchemeDetailPO::getInsuranceId, Function.identity())); + //档案中包含的基数信息 + HashMap archivesPerson = JSON.parseObject(fundPO.getFundPaymentBaseString(), new HashMap().getClass()); + //需要核算公积金的福利id 个人 + List needArchivesPerson = new ArrayList<>(); + if (archivesPerson != null) { + archivesPerson.forEach((id, value) -> { + if (fundperson.containsKey(Long.valueOf(id))) { + needArchivesPerson.add(Long.valueOf(id)); + } + }); + } + //避免福利档案的方案未设置基数,导致核算时遗漏这些福利项的核算,遍历下方案相关福利项,并将遗漏的福利项id添加 + if(fundperson.size() > 0) { + fundperson.forEach((id, object) -> { + if (!needArchivesPerson.contains(id)) { + needArchivesPerson.add(id); + } + }); + } + //判断核算周期、核算月、福利起始缴纳月的关系 + checkCycleSettingWithStartMonth(fundperson, billMonth, fundPO.getFundStartTime()); + + List fundPer = new ArrayList<>(); + Map fundPerJsonMap = new HashMap<>(); + needArchivesPerson.stream().forEach(e -> { + InsuranceSchemeDetailPO po = fundperson.get(e); + BigDecimal paymentProportion = new BigDecimal(StringUtils.isBlank(po.getPaymentProportion()) ? "0" : po.getPaymentProportion()).divide(new BigDecimal("100")); + BigDecimal paymentNum = new BigDecimal((ObjectUtil.isEmpty(archivesPerson) || StringUtils.isBlank(archivesPerson.get(String.valueOf(e)))) ? "0" : archivesPerson.get(String.valueOf(e))); + BigDecimal fixedCost = StringUtils.isBlank(po.getFixedCost()) ? new BigDecimal("0") : new BigDecimal(po.getFixedCost()); + Integer newScale = po.getValidNum() == null ? 2 : po.getValidNum(); +// BigDecimal result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost)); + BigDecimal result = new BigDecimal("0"); + if (Objects.equals(po.getPaymentCycle(), 1)) { + int monthValue = 1; + for (int i = monthIndex - 1; i >= 0; i--) { + String cycleValue = po.getCycleSetting().charAt(i) + ""; + if (Integer.parseInt(cycleValue) == 1) { + break; + } + monthValue++; + } + if (po.getAccountType() == 1) { + paymentNum = paymentNum.multiply(new BigDecimal(monthValue)); + fixedCost = fixedCost.multiply(new BigDecimal(monthValue)); + result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost)); + } else { + for (int i = 0; i < monthValue; i++) { + result = result.add(SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost))); + } + } + } else { + result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost)); + } + fundPerJsonMap.put(String.valueOf(e), result.toPlainString()); + fundPer.add(result); + }); + insuranceAccountDetailPO.setFundPerJson(JSON.toJSONString(fundPerJsonMap)); + BigDecimal funPerSum = new BigDecimal("0"); + for (BigDecimal bigDecimal : fundPer) { + funPerSum = funPerSum.add(bigDecimal); + } + insuranceAccountDetailPO.setFundPerSum(funPerSum.toPlainString()); + + //方案中包含的需要缴纳公积金的单位福利 + Map fundCom = detailPOS.stream() + .filter(item -> Objects.equals(IsPaymentEnum.YES.getValue(), item.getIsPayment()) && Objects.equals(item.getPaymentScope(), PaymentScopeEnum.SCOPE_COMPANY.getValue()) + && (item.getPaymentCycle() == null || item.getPaymentCycle() == 0 || (item.getPaymentCycle() == 1 && String.valueOf(item.getCycleSetting().charAt(monthIndex)).equals("1")))) + .collect( + Collectors.toMap(InsuranceSchemeDetailPO::getInsuranceId, Function.identity())); + //档案中包含的基数信息 +// HashMap archivesCom = JSON.parseObject(fundPO.getFundPaymentBaseString(), new HashMap().getClass()); + HashMap archivesCom = new HashMap<>(); + if (welBaseDiffSign) { + archivesCom = JSON.parseObject(fundPO.getFundPaymentComBaseString(), new HashMap().getClass()); + } else { + archivesCom = JSON.parseObject(fundPO.getFundPaymentBaseString(), new HashMap().getClass()); + } + //需要核算公积金的福利id 单位 + List needArchivesCom = new ArrayList<>(); + if (archivesCom != null) { + archivesCom.forEach((id, value) -> { + if (fundCom.containsKey(Long.valueOf(id))) { + needArchivesCom.add(Long.valueOf(id)); + } + }); + } + //避免福利档案的方案未设置基数,导致核算时遗漏这些福利项的核算,遍历下方案相关福利项,并将遗漏的福利项id添加 + if(fundCom.size() > 0) { + fundCom.forEach((id, object) -> { + if (!needArchivesCom.contains(id)) { + needArchivesCom.add(id); + } + }); + } + //判断核算周期、核算月、福利起始缴纳月的关系 + checkCycleSettingWithStartMonth(fundCom, billMonth, fundPO.getFundStartTime()); + + List fundComList = new ArrayList<>(); + Map fundComJsonMap = new HashMap<>(); + HashMap finalArchivesCom = archivesCom; + needArchivesCom.stream().forEach(e -> { + InsuranceSchemeDetailPO po = fundCom.get(e); + BigDecimal paymentProportion = new BigDecimal(StringUtils.isBlank(po.getPaymentProportion()) ? "0" : po.getPaymentProportion()).divide(new BigDecimal("100")); + BigDecimal paymentNum = new BigDecimal((ObjectUtil.isEmpty(finalArchivesCom) || StringUtils.isBlank(finalArchivesCom.get(String.valueOf(e)))) ? "0" : finalArchivesCom.get(String.valueOf(e))); + BigDecimal fixedCost = StringUtils.isBlank(po.getFixedCost()) ? new BigDecimal("0") : new BigDecimal(po.getFixedCost()); + Integer newScale = po.getValidNum() == null ? 2 : po.getValidNum(); +// BigDecimal result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost)); + BigDecimal result = new BigDecimal("0"); + if (Objects.equals(po.getPaymentCycle(), 1)) { + int monthValue = 1; + for (int i = monthIndex - 1; i >= 0; i--) { + String cycleValue = po.getCycleSetting().charAt(i) + ""; + if (Integer.parseInt(cycleValue) == 1) { + break; + } + monthValue++; + } + if (po.getAccountType() == 1) { + paymentNum = paymentNum.multiply(new BigDecimal(monthValue)); + fixedCost = fixedCost.multiply(new BigDecimal(monthValue)); + result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost)); + } else { + for (int i = 0; i < monthValue; i++) { + result = result.add(SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost))); + } + } + } else { + result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost)); + } + fundComJsonMap.put(String.valueOf(e), result.toPlainString()); + fundComList.add(result); + }); + insuranceAccountDetailPO.setFundComJson(JSON.toJSONString(fundComJsonMap)); + BigDecimal fundComSum = new BigDecimal("0"); + for (BigDecimal bigDecimal : fundComList) { + fundComSum = fundComSum.add(bigDecimal); + } + insuranceAccountDetailPO.setFundComSum(fundComSum.toPlainString()); + + } + } + return insuranceAccountDetailPO; + } + + + public InsuranceAccountDetailPO accountSocial(InsuranceAccountDetailPO insuranceAccountDetailPO, InsuranceArchivesAccountPO accountPO, String billMonth, String tenantKey) { + boolean welBaseDiffSign = siArchivesBiz.isDiffWelBase(); + if (accountPO.getSocial() != null) { + InsuranceArchivesSocialSchemePO socialPO = accountPO.getSocial(); + insuranceAccountDetailPO.setSocialPayOrg(socialPO.getPaymentOrganization()); + insuranceAccountDetailPO.setSocialAccount(socialPO.getSocialAccount()); + insuranceAccountDetailPO.setSocialSchemeId(socialPO.getSocialSchemeId()); + insuranceAccountDetailPO.setSocialPaymentBaseString(socialPO.getSocialPaymentBaseString()); + insuranceAccountDetailPO.setSocialPaymentComBaseString(socialPO.getSocialPaymentComBaseString()); + //判断是否在起始缴纳月和最后缴纳月之间 + Boolean inDataRange = SalaryDateUtil.monthInRange(insuranceAccountDetailPO.getBillMonth(), socialPO.getSocialStartTime(), socialPO.getSocialEndTime()); + if ((NonPaymentEnum.YES.getValue().equals(socialPO.getNonPayment()) || socialPO.getNonPayment() == null) && socialPO.getSocialSchemeId() != null && inDataRange) { + List detailPOS = getInsuranceSchemeDetailMapper().queryListBySchemeId(socialPO.getSocialSchemeId()); + encryptUtil.decryptList(detailPOS, InsuranceSchemeDetailPO.class); + //方案中包含的需要缴纳社保的个人福利 + int monthIndex = Integer.parseInt(billMonth.split("-")[1]) - 1; + Map schemeperson = detailPOS.stream() + .filter(item -> + Objects.equals(IsPaymentEnum.YES.getValue(), item.getIsPayment()) && + Objects.equals(item.getPaymentScope(), PaymentScopeEnum.SCOPE_PERSON.getValue()) && + (item.getPaymentCycle() == null || item.getPaymentCycle() == 0 || (item.getPaymentCycle() == 1 && String.valueOf(item.getCycleSetting().charAt(monthIndex)).equals("1"))) + ) + .collect( + Collectors.toMap(InsuranceSchemeDetailPO::getInsuranceId, Function.identity())); + //档案中包含的基数信息 + HashMap archivesPerson = JSON.parseObject(socialPO.getSocialPaymentBaseString(), new HashMap().getClass()); + //需要核算社保的福利id 个人 + List needArchivesPerson = new ArrayList<>(); + if (archivesPerson != null) { + archivesPerson.forEach((id, value) -> { + if (schemeperson.containsKey(Long.valueOf(id))) { + needArchivesPerson.add(Long.valueOf(id)); + } + }); + } + //避免福利档案的方案未设置基数,导致核算时遗漏这些福利项的核算,遍历下方案相关福利项,并将遗漏的福利项id添加 + if(schemeperson.size() > 0) { + schemeperson.forEach((id, object) -> { + if (!needArchivesPerson.contains(id)) { + needArchivesPerson.add(id); + } + }); + } + //判断核算周期、核算月、福利起始缴纳月的关系 + checkCycleSettingWithStartMonth(schemeperson, billMonth, socialPO.getSocialStartTime()); + + List socialPer = new ArrayList<>(); + Map socialPerJsonMap = new HashMap<>(); + needArchivesPerson.forEach(e -> { + InsuranceSchemeDetailPO po = schemeperson.get(e); + BigDecimal paymentProportion = new BigDecimal(StringUtils.isBlank(po.getPaymentProportion()) ? "0" : po.getPaymentProportion()).divide(new BigDecimal("100")); + BigDecimal paymentNum = new BigDecimal((ObjectUtil.isEmpty(archivesPerson) || StringUtils.isBlank(archivesPerson.get(String.valueOf(e)))) ? "0" : archivesPerson.get(String.valueOf(e))); + BigDecimal fixedCost = StringUtils.isBlank(po.getFixedCost()) ? new BigDecimal("0") : new BigDecimal(po.getFixedCost()); + Integer newScale = po.getValidNum() == null ? 2 : po.getValidNum(); +// BigDecimal result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost)); + BigDecimal result = new BigDecimal("0"); + if (Objects.equals(po.getPaymentCycle(), 1)) { + int monthValue = 1; + for (int i = monthIndex - 1; i >= 0; i--) { + String cycleValue = po.getCycleSetting().charAt(i) + ""; + if (Integer.parseInt(cycleValue) == 1) { + break; + } + monthValue++; + } + if (po.getAccountType() == 1) { + paymentNum = paymentNum.multiply(new BigDecimal(monthValue)); + fixedCost = fixedCost.multiply(new BigDecimal(monthValue)); + result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost)); + } else { + for (int i = 0; i < monthValue; i++) { + result = result.add(SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost))); + } + } + } else { + result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost)); + } + socialPerJsonMap.put(String.valueOf(e), result.toPlainString()); + socialPer.add(result); + }); + insuranceAccountDetailPO.setSocialPerJson(JSON.toJSONString(socialPerJsonMap)); + BigDecimal socialPerSum = new BigDecimal("0"); + for (BigDecimal bigDecimal : socialPer) { + socialPerSum = socialPerSum.add(bigDecimal); + } + insuranceAccountDetailPO.setSocialPerSum(socialPerSum.toPlainString()); + + //方案中包含的需要缴纳社保的单位福利 + Map schemeCom = detailPOS.stream() + .filter(item -> Objects.equals(IsPaymentEnum.YES.getValue(), item.getIsPayment()) && Objects.equals(item.getPaymentScope(), PaymentScopeEnum.SCOPE_COMPANY.getValue()) && + (item.getPaymentCycle() == null || item.getPaymentCycle() == 0 || (item.getPaymentCycle() == 1 && String.valueOf(item.getCycleSetting().charAt(monthIndex)).equals("1")))) + .collect( + Collectors.toMap(InsuranceSchemeDetailPO::getInsuranceId, Function.identity())); + //档案中包含的基数信息 +// HashMap archivesCom = JSON.parseObject(socialPO.getSocialPaymentBaseString(), new HashMap().getClass()); + HashMap archivesCom = new HashMap<>(); + if (welBaseDiffSign) { + archivesCom = JSON.parseObject(socialPO.getSocialPaymentComBaseString(), new HashMap().getClass()); + } else { + archivesCom = JSON.parseObject(socialPO.getSocialPaymentBaseString(), new HashMap().getClass()); + } + //需要核算社保的福利id 单位 + List needArchivesCom = new ArrayList<>(); + if (archivesCom != null) { + archivesCom.forEach((id, value) -> { + if (schemeCom.containsKey(Long.valueOf(id))) { + needArchivesCom.add(Long.valueOf(id)); + } + }); + } + //避免福利档案的方案未设置基数,导致核算时遗漏这些福利项的核算,遍历下方案相关福利项,并将遗漏的福利项id添加 + if(schemeCom.size() > 0) { + schemeCom.forEach((id, object) -> { + if (!needArchivesCom.contains(id)) { + needArchivesCom.add(id); + } + }); + } + //判断核算周期、核算月、福利起始缴纳月的关系 + checkCycleSettingWithStartMonth(schemeCom, billMonth, socialPO.getSocialStartTime()); + + List socialCom = new ArrayList<>(); + Map sociaComJsonMap = new HashMap<>(); + HashMap finalArchivesCom = archivesCom; + needArchivesCom.stream().forEach(e -> { + InsuranceSchemeDetailPO po = schemeCom.get(e); + BigDecimal paymentProportion = new BigDecimal(StringUtils.isBlank(po.getPaymentProportion()) ? "0" : po.getPaymentProportion()).divide(new BigDecimal("100")); + BigDecimal paymentNum = new BigDecimal((ObjectUtil.isEmpty(finalArchivesCom) || StringUtils.isBlank(finalArchivesCom.get(String.valueOf(e)))) ? "0" : finalArchivesCom.get(String.valueOf(e))); + BigDecimal fixedCost = StringUtils.isBlank(po.getFixedCost()) ? new BigDecimal("0") : new BigDecimal(po.getFixedCost()); + Integer newScale = po.getValidNum() == null ? 2 : po.getValidNum(); +// BigDecimal result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost)); + BigDecimal result = new BigDecimal("0"); + if (Objects.equals(po.getPaymentCycle(), 1)) { + int monthValue = 1; + for (int i = monthIndex - 1; i >= 0; i--) { + String cycleValue = po.getCycleSetting().charAt(i) + ""; + if (Integer.parseInt(cycleValue) == 1) { + break; + } + monthValue++; + } + if (po.getAccountType() == 1) { + paymentNum = paymentNum.multiply(new BigDecimal(monthValue)); + fixedCost = fixedCost.multiply(new BigDecimal(monthValue)); + result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost)); + } else { + for (int i = 0; i < monthValue; i++) { + result = result.add(SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost))); + } + } + } else { + result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost)); + } + sociaComJsonMap.put(String.valueOf(e), result.toPlainString()); + socialCom.add(result); + + }); + insuranceAccountDetailPO.setSocialComJson(JSON.toJSONString(sociaComJsonMap)); + BigDecimal socialComSum = new BigDecimal("0"); + for (BigDecimal decimal : socialCom) { + socialComSum = socialComSum.add(decimal); + } + insuranceAccountDetailPO.setSocialComSum(socialComSum.toPlainString()); + } + + } + return insuranceAccountDetailPO; + } + + /** + * 对于核算月和福利起始缴纳月处于同年时,要避免根据周期缴纳福利费用时,可能出现的多余费用缴纳情况 + * @param schemeDetail 福利方案明细 + * @param billMonth 核算月 + * @param startMonth 福利起始缴纳月 + * @return + */ + public Map checkCycleSettingWithStartMonth(Map schemeDetail, String billMonth, String startMonth) { + String billYear = billMonth.substring(0,4); + if (StringUtils.isNotBlank(startMonth) && billYear.equals(startMonth.substring(0,4))) { + int startMonthIndex = Integer.parseInt(startMonth.split("-")[1]) - 1; + schemeDetail.forEach((k, v) -> { + if (v.getPaymentCycle() != null && v.getPaymentCycle().equals(1) && startMonthIndex != 0) { + StringBuilder newCycleSetting = new StringBuilder(v.getCycleSetting()); + newCycleSetting.setCharAt(startMonthIndex - 1, '1'); + v.setCycleSetting(newCycleSetting.toString()); + } + }); + + } + return schemeDetail; + } + + public void batchSaveAccountInspectDetail(List list, String billMonth, String tenantKey) { + List insuranceAccountInspectAllPOS = accountInspect(list, true); + batchDelInspectDetail(insuranceAccountInspectAllPOS); + List insuranceAccountInspectPOS = accountInspect(list, false); + if (CollectionUtils.isNotEmpty(insuranceAccountInspectPOS)) { + batchSaveInspectDetail(insuranceAccountInspectPOS); + } + } + + public List accountInspect(List list, boolean isAll) { + List insuranceAccountInspectPOS = new ArrayList<>(); + for (InsuranceAccountDetailPO e : list) { + if (isAll || detailCheck(e.getSocialPerJson()) || detailCheck(e.getSocialComJson()) + || detailCheck(e.getFundPerJson()) || detailCheck(e.getFundComJson()) + || detailCheck(e.getOtherPerJson()) || detailCheck(e.getOtherComJson())) { + InsuranceAccountInspectPO insuranceAccountInspectPO = InsuranceAccountInspectPO.builder().build(); + insuranceAccountInspectPO.setSupplementaryProjects(e.getSupplementaryProjects()); + insuranceAccountInspectPO.setInspectStatus(InspectStatusEnum.IGNORE.getValue()); + insuranceAccountInspectPO.setBillMonth(e.getBillMonth()); + insuranceAccountInspectPO.setCreator(e.getCreator()); + insuranceAccountInspectPO.setCreateTime(new Date()); + insuranceAccountInspectPO.setDeleteType(DeleteTypeEnum.NOT_DELETED.getValue()); + insuranceAccountInspectPO.setEmployeeId(e.getEmployeeId()); + insuranceAccountInspectPO.setPaymentStatus(e.getPaymentStatus()); + insuranceAccountInspectPO.setSupplementaryMonth(e.getSupplementaryMonth()); + insuranceAccountInspectPO.setTenantKey(e.getTenantKey()); + insuranceAccountInspectPO.setUpdateTime(new Date()); + insuranceAccountInspectPOS.add(insuranceAccountInspectPO); + } + } + return insuranceAccountInspectPOS; + } + + + public boolean detailCheck(String baseString) { + if (StringUtils.isEmpty(baseString)) { + return false; + } + Map baseStringMap = JSON.parseObject(baseString, new TypeReference>() { + }); + if (baseStringMap == null || baseStringMap.size() == 0) { + return false; + } + return baseStringMap.values().stream().anyMatch(item -> StringUtils.isEmpty(item) || Pattern.matches("^([0].?[0]*)$", item)); + + } + + public void batchDelInspectDetail(List list) { + List> lists = Lists.partition(list, 100); + lists.forEach(getInsuranceAccountInspectMapper()::batchDelInspectDetails); + + } + + public void batchSaveInspectDetail(List list) { + List> lists = Lists.partition(list, 100); + lists.forEach(getInsuranceAccountInspectMapper()::batchSaveInspectDetails); + } + + + /** + * 跟新台账接口 + * + * @param tenantKey 租户key + */ + public void updateBatchAccount(AccountParam param, Long employeeId, String tenantKey, String currentUserName) { + String billMonth = param.getBillMonth(); + + List insuranceAccountDetailPOS = getInsuranceAccountDetailMapper().selectList(billMonth, param.getPaymentOrganization()); + Map> map = insuranceAccountDetailPOS.stream().filter(item -> item.getEmployeeId() != null) + .collect(Collectors.groupingBy(InsuranceAccountDetailPO::getEmployeeId)); + int socialAccountPerson = 0; + int funcAccountPerson = 0; + int otherAccountPerson = 0; + BigDecimal socialSum = new BigDecimal("0"); + BigDecimal fundSum = new BigDecimal("0"); + BigDecimal otherSum = new BigDecimal("0"); + for (Map.Entry> entry : map.entrySet()) { + List v = entry.getValue(); + BigDecimal socialTemp = new BigDecimal("0"); + BigDecimal fundTemp = new BigDecimal("0"); + BigDecimal otherTemp = new BigDecimal("0"); + encryptUtil.decryptList(v, InsuranceAccountDetailPO.class); + boolean socialPersonFlag = false; + boolean fundPersonFlag = false; + boolean otherPersonFlag = false; + for (InsuranceAccountDetailPO item : v) { + // 判断社保是否为0 + socialPersonFlag = (StringUtils.isBlank(item.getSocialSum()) || SalaryEntityUtil.StringEqZERO(item.getSocialSum())); + BigDecimal socialPerson = socialPersonFlag ? new BigDecimal("0") : new BigDecimal(item.getSocialSum()); + fundPersonFlag = (StringUtils.isBlank(item.getFundSum()) || SalaryEntityUtil.StringEqZERO(item.getFundSum())); + BigDecimal fundPerson = fundPersonFlag ? new BigDecimal("0") : new BigDecimal(item.getFundSum()); + otherPersonFlag = (StringUtils.isBlank(item.getOtherSum()) || SalaryEntityUtil.StringEqZERO(item.getOtherSum())); + BigDecimal otherPerson = otherPersonFlag ? new BigDecimal("0") : new BigDecimal(item.getOtherSum()); + socialTemp = socialTemp.add(socialPerson); + fundTemp = fundTemp.add(fundPerson); + otherTemp = otherTemp.add(otherPerson); + if (!socialPersonFlag && !item.getPaymentStatus().equals(PaymentStatusEnum.BALANCE.getValue())) { + socialAccountPerson += 1; + } + if (!fundPersonFlag && !item.getPaymentStatus().equals(PaymentStatusEnum.BALANCE.getValue())) { + funcAccountPerson += 1; + } + if (!otherPersonFlag && !item.getPaymentStatus().equals(PaymentStatusEnum.BALANCE.getValue())) { + otherAccountPerson += 1; + } + } +// if (!socialPersonFlag) { +// socialSum = socialSum.add(socialTemp); +// } +// if (!fundPersonFlag) { +// fundSum = fundSum.add(fundTemp); +// } +// if (!otherPersonFlag) { +// otherSum = otherSum.add(otherTemp); +// } + + if (!"0".equals(socialTemp.toPlainString())) { + socialSum = socialSum.add(socialTemp); + } + if (!"0".equals(fundTemp.toPlainString())) { + fundSum = fundSum.add(fundTemp); + } + if (!"0".equals(otherTemp.toPlainString())) { + otherSum = otherSum.add(otherTemp); + } + } + InsuranceAccountBatchPO insuranceAccountBatchPO = getInsuranceAccountBatchMapper().getByBillMonth(billMonth, param.getPaymentOrganization()); + encryptUtil.decrypt(insuranceAccountBatchPO, InsuranceAccountBatchPO.class); + + insuranceAccountBatchPO.setAccountant(currentUserName); + insuranceAccountBatchPO.setUpdateTime(new Date()); + insuranceAccountBatchPO.setSocialPay(socialSum.toPlainString()); + insuranceAccountBatchPO.setSocialNum(socialAccountPerson); + insuranceAccountBatchPO.setFundNum(funcAccountPerson); + insuranceAccountBatchPO.setFundPay(fundSum.toPlainString()); + insuranceAccountBatchPO.setOtherNum(otherAccountPerson); + insuranceAccountBatchPO.setOtherPay(otherSum.toPlainString()); + encryptUtil.encrypt(insuranceAccountBatchPO, InsuranceAccountBatchPO.class); + getInsuranceAccountBatchMapper().updateById(insuranceAccountBatchPO); +// LoggerContext insuranceSchemeContext = new LoggerContext(); +// insuranceSchemeContext.setTargetId(String.valueOf(insuranceAccountBatchPO.getId())); +// insuranceSchemeContext.setTargetName(insuranceAccountBatchPO.getBillMonth()); +// insuranceSchemeContext.setOperateType(OperateTypeEnum.UPDATE.getValue()); +// insuranceSchemeContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 100491, "更新台账")); +// insuranceSchemeContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 100491, "更新台账")); +// insuranceSchemeContext.setNewValues(insuranceAccountBatchPO); +// siAccountLoggerTemplate.write(insuranceSchemeContext); + + } + + + public void saveCommonAccount(SaveCommonAccountParam param, Long employeeId, String currentUserName) { + List collect; + SalaryAssert.notEmpty(param.getIncludes(), SalaryI18nUtil.getI18nLabel(100466, "参数为空")); + SalaryAssert.notNull(param.getBillMonth(), SalaryI18nUtil.getI18nLabel(100467, "账单月为空")); + if (CollectionUtils.isNotEmpty(param.getExcludes())) { + collect = param.getIncludes().stream().filter(item -> !param.getExcludes().contains(item)).collect(Collectors.toList()); + } else { + collect = param.getIncludes(); + } + SalaryAssert.notEmpty(collect, SalaryI18nUtil.getI18nLabel(99920, "无核算人员")); + AccountParam accountParam = new AccountParam(); + accountParam.setBillMonth(param.getBillMonth()); + accountParam.setIds(collect); + accounting(accountParam, employeeId, SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY, currentUserName); + } + + public void delete(AccountParam param, Long employeeId) { + InsuranceAccountBatchPO insuranceAccountBatchPO = getInsuranceAccountBatchMapper().getByBillMonth(param.getBillMonth(), param.getPaymentOrganization()); + encryptUtil.decrypt(insuranceAccountBatchPO, InsuranceAccountBatchPO.class); + SalaryAssert.notNull(insuranceAccountBatchPO, SalaryI18nUtil.getI18nLabel(84026, "参数错误")); +// if (insuranceAccountBatchPO.getBillStatus().equals(BillStatusEnum.ARCHIVED.getValue())) { +// int num = checkIfBusinessaccounting(insuranceAccountBatchPO); +// //表示已经被核算过不能重新核算 +// if (num > 0) { +// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "已被薪酬核算给核算过,无法删除!")); +// } +// } + +// if(param.getPaymentOrganization()==null){ +// throw new SalaryRunTimeException("个税扣缴义务人为空"); +// } + getInsuranceAccountBatchMapper().deleteById(insuranceAccountBatchPO.getId()); + getInsuranceAccountDetailMapper().batchDeleteNotFile(param.getBillMonth(), param.getPaymentOrganization()); + + //删除账单月份+个税扣缴义务人下的调差数据 + getInsuranceCompensationMapper().deleteByBillMonthAndPayOrg(param.getBillMonth(), param.getPaymentOrganization()); +// LoggerContext insuranceSchemeContext = new LoggerContext(); +// insuranceSchemeContext.setTargetId(String.valueOf(insuranceAccountBatchPO.getId())); +// insuranceSchemeContext.setTargetName(insuranceAccountBatchPO.getBillMonth()); +// insuranceSchemeContext.setOperateType(OperateTypeEnum.DELETE.getValue()); +// insuranceSchemeContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(tenantkey, employeeId, 100464, "删除台账")); +// insuranceSchemeContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(tenantkey, employeeId, 100464, "删除台账")); +// insuranceSchemeContext.setNewValues(insuranceAccountBatchPO); +// siAccountLoggerTemplate.write(insuranceSchemeContext); + } + + public void saveSupplementaryAccount(SaveSupplementaryAccountParam param, Long employeeId, String currentUserName) { + if (StringUtils.isBlank(param.getBillMonth()) || CollectionUtils.isEmpty(param.getBillMonthList()) || CollectionUtils.isEmpty(param.getProjects()) + || CollectionUtils.isEmpty(param.getIncludes())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(84026, "参数错误")); + } + //需要补缴的月份 + if (param.getBillMonthList().contains(param.getBillMonth())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100481, "当前月走正常缴纳")); + } + //需要补缴的员工id + List employeeIds = param.getIncludes(); + if (CollectionUtils.isNotEmpty(param.getExcludes())) { + employeeIds = employeeIds.stream().filter(item -> !param.getExcludes().contains(item)).collect(Collectors.toList()); + } + //校验补缴人员是否存在福利档案基础信息,并且runStatus处于正在缴纳或者待减员 + List insuranceBaseInfoList = getInsuranceBaseInfoMapper().getSocialByPaymentOrganization(param.getPaymentOrganization()); + List finalEmployeeIds = employeeIds; + List filterList = insuranceBaseInfoList.stream().filter(e -> { + for (Long uId : finalEmployeeIds) { + if (e.getEmployeeId().equals(uId) && (e.getRunStatus().equals(EmployeeStatusEnum.STAY_DEL.getValue()) || e.getRunStatus().equals(EmployeeStatusEnum.PAYING.getValue()))) { + return true; + } + } + return false; + }).collect(Collectors.toList()); + if (filterList.size() != employeeIds.size()) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "补缴人员中存在未设置福利档案人员或相关人员不在福利在缴人员中,不可新建补缴信息!")); + } + //20231122逻辑优化,过滤出不在起始缴纳月和最后缴纳月区间的人员 + List empIdsInPayMonthRange = listCanPayEmpIds(param.getPaymentOrganization(), param.getBillMonth()); + employeeIds = employeeIds.stream().filter(f -> empIdsInPayMonthRange.contains(f)).collect(Collectors.toList()); + + SalaryAssert.notEmpty(employeeIds, SalaryI18nUtil.getI18nLabel(99920, "无核算人员")); + List baseList = new ArrayList<>(); + employeeIds.stream().forEach(id -> { + param.getBillMonthList().stream().forEach(month -> { + SupplementAccountBaseParam supplementAccountBaseParam = SupplementAccountBaseParam.builder() + .supplementaryMonth(month) + .employeeId(id) + .paymentOrganization(param.getPaymentOrganization()) + .projects(param.getProjects()) + .billMonth(param.getBillMonth()) + .supplementType(param.getSupplementType()) + .build(); + if ("2".equals(param.getSupplementType())) { + supplementAccountBaseParam.setSocialPaymentBaseString(param.getSocialPaymentBaseString()); + supplementAccountBaseParam.setFundPaymentBaseString(param.getFundPaymentBaseString()); + supplementAccountBaseParam.setOtherPaymentBaseString(param.getOtherPaymentBaseString()); + } else if("3".equals(param.getSupplementType())) { + supplementAccountBaseParam.setSocialPaymentPerString(param.getSocialPaymentPerString()); + supplementAccountBaseParam.setSocialPaymentComString(param.getSocialPaymentComString()); + supplementAccountBaseParam.setFundPaymentPerString(param.getFundPaymentPerString()); + supplementAccountBaseParam.setFundPaymentComString(param.getFundPaymentComString()); + supplementAccountBaseParam.setOtherPaymentPerString(param.getOtherPaymentPerString()); + supplementAccountBaseParam.setOtherPaymentComString(param.getOtherPaymentComString()); + } + baseList.add(supplementAccountBaseParam); + }); + }); + //核算开始 + accountSupplement(baseList, employeeIds, param.getBillMonth(), employeeId, param.getPaymentOrganization()); + + updateBatchAccount(AccountParam.builder().billMonth(param.getBillMonth()).paymentOrganization(param.getPaymentOrganization()).build(), employeeId, SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY, currentUserName); + } + + /** + * @param baseList 员工id-账单月份-补缴月份(单挑)-补缴项 集合 + * @param employeeIds 需要补缴的员工id + * @return + */ + public String accountSupplement(List baseList, List employeeIds, String billMonth, Long employeeId, Long paymentOrganization) { + //(k,v) k-员工id v-员工对应的福利档案数据 + Map longInsuranceArchivesAccountPOMap = siArchivesBiz.buildBatchAccount(employeeIds, paymentOrganization); + //核算结果集 + List pos = new ArrayList<>(); + baseList.forEach(baseParam -> { + //判断人员id+账单月份+补缴月份在表中的唯一性 + List supplementList = getInsuranceAccountDetailMapper().querySupplementList(baseParam.getBillMonth(), baseParam.getPaymentOrganization(), baseParam.getEmployeeId(), baseParam.getSupplementaryMonth()); + if (supplementList.size() > 0) { + throw new SalaryRunTimeException("当前人员和账单月份已存在该补缴月份的数据!无法再次创建!"); + } + InsuranceAccountDetailPO insuranceAccountDetailPO = accountSingleEmployeeBill(baseParam, longInsuranceArchivesAccountPOMap.get(baseParam.getEmployeeId()), employeeId); + pos.add(insuranceAccountDetailPO); + }); + batchSaveSupplementAccount(pos, billMonth, SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY); + return SalaryI18nUtil.getI18nLabel(100492, "核算完成,数据保存成功"); + } + + + public InsuranceAccountDetailPO accountSingleEmployeeBill(SupplementAccountBaseParam baseParam, InsuranceArchivesAccountPO accountPO, Long employeeId) { + InsuranceAccountDetailPO insuranceAccountDetailPO = new InsuranceAccountDetailPO(); + List projects = baseParam.getProjects(); + insuranceAccountDetailPO.setBillMonth(baseParam.getBillMonth()); + insuranceAccountDetailPO.setBillStatus(BillStatusEnum.NOT_ARCHIVED.getValue()); + insuranceAccountDetailPO.setCreator(employeeId); + insuranceAccountDetailPO.setCreateTime(new Date()); + insuranceAccountDetailPO.setUpdateTime(new Date()); + insuranceAccountDetailPO.setDeleteType(DeleteTypeEnum.NOT_DELETED.getValue()); + insuranceAccountDetailPO.setId(IdGenerator.generate()); + insuranceAccountDetailPO.setEmployeeId(baseParam.getEmployeeId()); + insuranceAccountDetailPO.setPaymentStatus(PaymentStatusEnum.REPAIR.getValue()); + insuranceAccountDetailPO.setSupplementaryMonth(baseParam.getSupplementaryMonth()); + insuranceAccountDetailPO.setPaymentOrganization(baseParam.getPaymentOrganization()); + insuranceAccountDetailPO.setSupplementaryProjects( + String.join(",", + baseParam.getProjects() == null ? new ArrayList<>() : baseParam.getProjects().stream().map(String::valueOf).collect(Collectors.toList()))); + insuranceAccountDetailPO.setTenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY); + insuranceAccountDetailPO.setResourceFrom(ResourceFromEnum.SYSTEM.getValue()); + //缴纳组织=个税扣缴义务人 + insuranceAccountDetailPO.setSocialPayOrg(baseParam.getPaymentOrganization()); + if (projects.contains(ProjectTypeEnum.ALL.getValue())) { + if ("2".equals(baseParam.getSupplementType())) { + if (accountPO.getSocial() != null) { + accountPO.getSocial().setSocialPaymentBaseString(baseParam.getSocialPaymentBaseString()); + } + if (accountPO.getFund() != null) { + accountPO.getFund().setFundPaymentBaseString(baseParam.getFundPaymentBaseString()); + } + if (accountPO.getOther() != null) { + accountPO.getOther().setOtherPaymentBaseString(baseParam.getOtherPaymentBaseString()); + } + accountSocial(insuranceAccountDetailPO, accountPO, baseParam.getSupplementaryMonth()); + accountFund(insuranceAccountDetailPO, accountPO, baseParam.getSupplementaryMonth()); + accountOther(insuranceAccountDetailPO, accountPO, baseParam.getSupplementaryMonth()); + } else if ("3".equals(baseParam.getSupplementType())) { + accountSocialByData(insuranceAccountDetailPO, baseParam); + accountFundByData(insuranceAccountDetailPO, baseParam); + accountOtherByData(insuranceAccountDetailPO, baseParam); + } else { + accountSocial(insuranceAccountDetailPO, accountPO, baseParam.getSupplementaryMonth()); + accountFund(insuranceAccountDetailPO, accountPO, baseParam.getSupplementaryMonth()); + accountOther(insuranceAccountDetailPO, accountPO, baseParam.getSupplementaryMonth()); + } + + return account(insuranceAccountDetailPO); + } + if (projects.contains(ProjectTypeEnum.SOCIAL.getValue())) { + if ("2".equals(baseParam.getSupplementType())) { + if (accountPO.getSocial() != null) { + accountPO.getSocial().setSocialPaymentBaseString(baseParam.getSocialPaymentBaseString()); + } + accountSocial(insuranceAccountDetailPO, accountPO, baseParam.getSupplementaryMonth()); + } else if ("3".equals(baseParam.getSupplementType())) { + accountSocialByData(insuranceAccountDetailPO, baseParam); + } else { + accountSocial(insuranceAccountDetailPO, accountPO, baseParam.getSupplementaryMonth()); + } + + } + if (!projects.contains(ProjectTypeEnum.SOCIAL.getValue())) { + List ids = new ArrayList<>(); + List list = getICategoryMapper().listByDataType(DataTypeEnum.SYSTEM.getValue()); + + if (projects.contains(ProjectTypeEnum.ENDOWMENT_INSURANCE.getValue())) { + ICategoryPO insuranceCategoryPO = list.stream().filter(item -> SalaryI18nUtil.getI18nLabel(93113, "养老保险").equals(item.getInsuranceName())).findFirst() + .get(); + ids.add(insuranceCategoryPO.getId()); + } + if (projects.contains(ProjectTypeEnum.MEDICAL_INSURANCE.getValue())) { + ICategoryPO insuranceCategoryPO = list.stream().filter(item -> SalaryI18nUtil.getI18nLabel(93114, "医疗保险").equals(item.getInsuranceName())).findFirst() + .get(); + ids.add(insuranceCategoryPO.getId()); + } + if ("2".equals(baseParam.getSupplementType())) { + if (accountPO.getSocial() != null) { + accountPO.getSocial().setSocialPaymentBaseString(baseParam.getSocialPaymentBaseString()); + } + accountEndowmentInsurance(insuranceAccountDetailPO, accountPO, ids, baseParam.getSupplementaryMonth()); + } else if ("3".equals(baseParam.getSupplementType())) { + accountEndowmentInsuranceByData(insuranceAccountDetailPO, baseParam, ids); + } else { + accountEndowmentInsurance(insuranceAccountDetailPO, accountPO, ids, baseParam.getSupplementaryMonth()); + } + + } + if (projects.contains(ProjectTypeEnum.FUND.getValue())) { + if ("2".equals(baseParam.getSupplementType())) { + if (accountPO.getFund() != null) { + accountPO.getFund().setFundPaymentBaseString(baseParam.getFundPaymentBaseString()); + } + accountFund(insuranceAccountDetailPO, accountPO, baseParam.getSupplementaryMonth()); + } else if ("3".equals(baseParam.getSupplementType())) { + accountFundByData(insuranceAccountDetailPO, baseParam); + } else { + accountFund(insuranceAccountDetailPO, accountPO, baseParam.getSupplementaryMonth()); + } + } + if (projects.contains(ProjectTypeEnum.OTHER.getValue())) { + + if ("2".equals(baseParam.getSupplementType())) { + if (accountPO.getOther() != null) { + accountPO.getOther().setOtherPaymentBaseString(baseParam.getOtherPaymentBaseString()); + } + accountOther(insuranceAccountDetailPO, accountPO, baseParam.getSupplementaryMonth()); + } else if ("3".equals(baseParam.getSupplementType())) { + accountOtherByData(insuranceAccountDetailPO, baseParam); + } else { + accountOther(insuranceAccountDetailPO, accountPO, baseParam.getSupplementaryMonth()); + } + + } + + return account(insuranceAccountDetailPO); + } + + + public InsuranceAccountDetailPO accountOther(InsuranceAccountDetailPO insuranceAccountDetailPO, InsuranceArchivesAccountPO accountPO, String billMonth) { + boolean welBaseDiffSign = siArchivesBiz.isDiffWelBase(); + if (accountPO.getOther() != null) { + InsuranceArchivesOtherSchemePO otherPO = accountPO.getOther(); + insuranceAccountDetailPO.setOtherPayOrg(otherPO.getPaymentOrganization()); + insuranceAccountDetailPO.setOtherSchemeId(otherPO.getOtherSchemeId()); + insuranceAccountDetailPO.setOtherPaymentBaseString(otherPO.getOtherPaymentBaseString()); + insuranceAccountDetailPO.setOtherPaymentComBaseString(otherPO.getOtherPaymentComBaseString()); + //判断是否在起始缴纳月和最后缴纳月之间 + Boolean inDataRange = SalaryDateUtil.monthInRange(billMonth, otherPO.getOtherStartTime(), otherPO.getOtherEndTime()); + if ((Objects.equals(NonPaymentEnum.YES.getValue(), otherPO.getNonPayment()) || otherPO.getNonPayment() == null) && otherPO.getOtherSchemeId() != null && inDataRange) { + List detailPOS = getInsuranceSchemeDetailMapper().queryListBySchemeId(otherPO.getOtherSchemeId()); + encryptUtil.decryptList(detailPOS, InsuranceSchemeDetailPO.class); + //方案中包含的需要缴纳其他的个人福利 + int monthIndex = Integer.parseInt(billMonth.split("-")[1]) - 1; + Map otherPerson = detailPOS.stream() + .filter(item -> Objects.equals(IsPaymentEnum.YES.getValue(), item.getIsPayment()) && Objects.equals(item.getPaymentScope(), PaymentScopeEnum.SCOPE_PERSON.getValue()) && (item.getPaymentCycle() == null || item.getPaymentCycle() == 0 || (item.getPaymentCycle() == 1 && String.valueOf(item.getCycleSetting().charAt(monthIndex)).equals("1")))) + .collect( + Collectors.toMap(InsuranceSchemeDetailPO::getInsuranceId, Function.identity())); + //档案中包含的基数信息 + HashMap archivesPerson = JSON.parseObject(otherPO.getOtherPaymentBaseString(), new HashMap().getClass()); + //需要核算其他的福利id 个人 + List needArchivesPerson = new ArrayList<>(); + if (archivesPerson != null) { + archivesPerson.forEach((id, value) -> { + if (otherPerson.containsKey(Long.valueOf(id))) { + needArchivesPerson.add(Long.valueOf(id)); + } + }); + } + //判断核算周期、核算月、福利起始缴纳月的关系 + checkCycleSettingWithStartMonth(otherPerson, billMonth, otherPO.getOtherStartTime()); + + List otherPer = new ArrayList<>(); + Map otherPerJsonMap = new HashMap<>(); + needArchivesPerson.stream().forEach(e -> { + InsuranceSchemeDetailPO po = otherPerson.get(e); + BigDecimal paymentProportion = new BigDecimal(StringUtils.isBlank(po.getPaymentProportion()) ? "0" : po.getPaymentProportion()).divide(new BigDecimal("100")); + BigDecimal paymentNum = new BigDecimal((ObjectUtil.isEmpty(archivesPerson) || StringUtils.isBlank(archivesPerson.get(String.valueOf(e)))) ? "0" : archivesPerson.get(String.valueOf(e))); + BigDecimal fixedCost = StringUtils.isBlank(po.getFixedCost()) ? new BigDecimal("0") : new BigDecimal(po.getFixedCost()); + Integer newScale = po.getValidNum() == null ? 2 : po.getValidNum(); +// BigDecimal result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost)); + BigDecimal result = new BigDecimal("0"); + if (po.getPaymentCycle() != null && po.getPaymentCycle() == 1) { + int monthValue = 1; + for (int i = monthIndex - 1; i >= 0; i--) { + String cycleValue = po.getCycleSetting().charAt(i) + ""; + if (Integer.parseInt(cycleValue) == 1) { + break; + } + monthValue++; + } + if (po.getAccountType() == 1) { + paymentNum = paymentNum.multiply(new BigDecimal(monthValue)); + fixedCost = fixedCost.multiply(new BigDecimal(monthValue)); + result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost)); + } else { + for (int i = 0; i < monthValue; i++) { + result = result.add(SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost))); + } + } + } else { + result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost)); + } + + otherPerJsonMap.put(String.valueOf(e), result.toPlainString()); + otherPer.add(result); + }); + insuranceAccountDetailPO.setOtherPerJson(JSON.toJSONString(otherPerJsonMap)); + BigDecimal otherPerSum = new BigDecimal("0"); + for (BigDecimal bigDecimal : otherPer) { + otherPerSum = otherPerSum.add(bigDecimal); + } + insuranceAccountDetailPO.setOtherPerSum(otherPerSum.toPlainString()); + + //方案中包含的需要缴纳公积金的单位福利 + Map otherCom = detailPOS.stream() + .filter( + item -> Objects.equals(IsPaymentEnum.YES.getValue(), item.getIsPayment()) && Objects.equals(item.getPaymentScope(), PaymentScopeEnum.SCOPE_COMPANY.getValue()) && (item.getPaymentCycle() == null || item.getPaymentCycle() == 0 || (item.getPaymentCycle() == 1 && String.valueOf(item.getCycleSetting().charAt(monthIndex)).equals("1")))) + .collect( + Collectors.toMap(InsuranceSchemeDetailPO::getInsuranceId, Function.identity())); + //档案中包含的基数信息 +// HashMap archivesCom = JSON.parseObject(otherPO.getOtherPaymentBaseString(), new HashMap().getClass()); + HashMap archivesCom = new HashMap<>(); + if (welBaseDiffSign) { + archivesCom = JSON.parseObject(otherPO.getOtherPaymentComBaseString(), new HashMap().getClass()); + } else { + archivesCom = JSON.parseObject(otherPO.getOtherPaymentBaseString(), new HashMap().getClass()); + } + //需要核算其他的福利id 单位 + List needArchivesCom = new ArrayList<>(); + if (archivesCom != null) { + archivesCom.forEach((id, value) -> { + if (otherCom.containsKey(Long.valueOf(id))) { + needArchivesCom.add(Long.valueOf(id)); + } + }); + } + //判断核算周期、核算月、福利起始缴纳月的关系 + checkCycleSettingWithStartMonth(otherCom, billMonth, otherPO.getOtherStartTime()); + + List otherComList = new ArrayList<>(); + Map otherComJsonMap = new HashMap<>(); + HashMap finalArchivesCom = archivesCom; + needArchivesCom.stream().forEach(e -> { + InsuranceSchemeDetailPO po = otherCom.get(e); + BigDecimal paymentProportion = new BigDecimal(StringUtils.isBlank(po.getPaymentProportion()) ? "0" : po.getPaymentProportion()).divide(new BigDecimal("100")); + BigDecimal paymentNum = new BigDecimal((ObjectUtil.isEmpty(finalArchivesCom) || StringUtils.isBlank(finalArchivesCom.get(String.valueOf(e)))) ? "0" : finalArchivesCom.get(String.valueOf(e))); + BigDecimal fixedCost = StringUtils.isBlank(po.getFixedCost()) ? new BigDecimal("0") : new BigDecimal(po.getFixedCost()); + Integer newScale = po.getValidNum() == null ? 2 : po.getValidNum(); +// BigDecimal result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost)); + BigDecimal result = new BigDecimal("0"); + if (Objects.equals(po.getPaymentCycle(), 1)) { + int monthValue = 1; + for (int i = monthIndex - 1; i >= 0; i--) { + String cycleValue = po.getCycleSetting().charAt(i) + ""; + if (Integer.parseInt(cycleValue) == 1) { + break; + } + monthValue++; + } + if (po.getAccountType() == 1) { + paymentNum = paymentNum.multiply(new BigDecimal(monthValue)); + fixedCost = fixedCost.multiply(new BigDecimal(monthValue)); + result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost)); + } else { + for (int i = 0; i < monthValue; i++) { + result = result.add(SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost))); + } + } + } else { + result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost)); + } + + otherComJsonMap.put(String.valueOf(e), result.toPlainString()); + otherComList.add(result); + }); + insuranceAccountDetailPO.setOtherComJson(JSON.toJSONString(otherComJsonMap)); + BigDecimal otherComSum = new BigDecimal("0"); + for (BigDecimal bigDecimal : otherComList) { + otherComSum = otherComSum.add(bigDecimal); + } + insuranceAccountDetailPO.setOtherComSum(otherComSum.toPlainString()); + } + } + return insuranceAccountDetailPO; + } + + public InsuranceAccountDetailPO accountFund(InsuranceAccountDetailPO insuranceAccountDetailPO, InsuranceArchivesAccountPO accountPO, String billMonth) { + boolean welBaseDiffSign = siArchivesBiz.isDiffWelBase(); + if (accountPO.getFund() != null) { + InsuranceArchivesFundSchemePO fundPO = accountPO.getFund(); + insuranceAccountDetailPO.setFundPayOrg(fundPO.getPaymentOrganization()); + insuranceAccountDetailPO.setFundAccount(fundPO.getFundAccount()); + insuranceAccountDetailPO.setSupplementFundAccount(fundPO.getSupplementFundAccount()); + insuranceAccountDetailPO.setFundSchemeId(fundPO.getFundSchemeId()); + insuranceAccountDetailPO.setFundPaymentBaseString(fundPO.getFundPaymentBaseString()); + insuranceAccountDetailPO.setFundPaymentComBaseString(fundPO.getFundPaymentComBaseString()); + //判断是否在起始缴纳月和最后缴纳月之间 + Boolean inDataRange = SalaryDateUtil.monthInRange(billMonth, fundPO.getFundStartTime(), fundPO.getFundEndTime()); + if ((Objects.equals(NonPaymentEnum.YES.getValue(), fundPO.getNonPayment()) || fundPO.getNonPayment() == null) && fundPO.getFundSchemeId() != null && inDataRange) { + List detailPOS = getInsuranceSchemeDetailMapper().queryListBySchemeId(fundPO.getFundSchemeId()); + encryptUtil.decryptList(detailPOS, InsuranceSchemeDetailPO.class); + //方案中包含的需要缴纳社保的个人福利 + int monthIndex = Integer.parseInt(billMonth.split("-")[1]) - 1; + Map fundperson = detailPOS.stream() + .filter(item -> Objects.equals(IsPaymentEnum.YES.getValue(), item.getIsPayment()) && Objects.equals(item.getPaymentScope(), PaymentScopeEnum.SCOPE_PERSON.getValue()) && (item.getPaymentCycle() == null || item.getPaymentCycle() == 0 || (item.getPaymentCycle() == 1 && String.valueOf(item.getCycleSetting().charAt(monthIndex)).equals("1")))) + .collect( + Collectors.toMap(InsuranceSchemeDetailPO::getInsuranceId, Function.identity())); + //档案中包含的基数信息 + HashMap archivesPerson = JSON.parseObject(fundPO.getFundPaymentBaseString(), new HashMap().getClass()); + //需要核算公积金的福利id 个人 + List needArchivesPerson = new ArrayList<>(); + if (archivesPerson != null) { + archivesPerson.forEach((id, value) -> { + if (fundperson.containsKey(Long.valueOf(id))) { + needArchivesPerson.add(Long.valueOf(id)); + } + }); + } + //判断核算周期、核算月、福利起始缴纳月的关系 + checkCycleSettingWithStartMonth(fundperson, billMonth, fundPO.getFundStartTime()); + + List fundPer = new ArrayList<>(); + Map fundPerJsonMap = new HashMap<>(); + needArchivesPerson.stream().forEach(e -> { + InsuranceSchemeDetailPO po = fundperson.get(e); + BigDecimal paymentProportion = new BigDecimal(StringUtils.isBlank(po.getPaymentProportion()) ? "0" : po.getPaymentProportion()).divide(new BigDecimal("100")); + BigDecimal paymentNum = new BigDecimal((ObjectUtil.isEmpty(archivesPerson) || StringUtils.isBlank(archivesPerson.get(String.valueOf(e)))) ? "0" : archivesPerson.get(String.valueOf(e))); + BigDecimal fixedCost = StringUtils.isBlank(po.getFixedCost()) ? new BigDecimal("0") : new BigDecimal(po.getFixedCost()); + Integer newScale = po.getValidNum() == null ? 2 : po.getValidNum(); +// BigDecimal result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost)); + BigDecimal result = new BigDecimal("0"); + if (Objects.equals(po.getPaymentCycle(), 1)) { + int monthValue = 1; + for (int i = monthIndex - 1; i >= 0; i--) { + String cycleValue = po.getCycleSetting().charAt(i) + ""; + if (Integer.parseInt(cycleValue) == 1) { + break; + } + monthValue++; + } + if (po.getAccountType() == 1) { + paymentNum = paymentNum.multiply(new BigDecimal(monthValue)); + fixedCost = fixedCost.multiply(new BigDecimal(monthValue)); + result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost)); + } else { + for (int i = 0; i < monthValue; i++) { + result = result.add(SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost))); + } + } + } else { + result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost)); + } + + fundPerJsonMap.put(String.valueOf(e), result.toPlainString()); + fundPer.add(result); + }); + insuranceAccountDetailPO.setFundPerJson(JSON.toJSONString(fundPerJsonMap)); + BigDecimal funPerSum = new BigDecimal("0"); + for (BigDecimal bigDecimal : fundPer) { + funPerSum = funPerSum.add(bigDecimal); + } + insuranceAccountDetailPO.setFundPerSum(funPerSum.toPlainString()); + + //方案中包含的需要缴纳公积金的单位福利 + Map fundCom = detailPOS.stream() + .filter(item -> Objects.equals(IsPaymentEnum.YES.getValue(), item.getIsPayment()) && Objects.equals(item.getPaymentScope(), PaymentScopeEnum.SCOPE_COMPANY.getValue()) && (item.getPaymentCycle() == null || item.getPaymentCycle() == 0 || (item.getPaymentCycle() == 1 && String.valueOf(item.getCycleSetting().charAt(monthIndex)).equals("1")))) + .collect( + Collectors.toMap(InsuranceSchemeDetailPO::getInsuranceId, Function.identity())); + //档案中包含的基数信息 +// HashMap archivesCom = JSON.parseObject(fundPO.getFundPaymentBaseString(), new HashMap().getClass()); + HashMap archivesCom = new HashMap<>(); + if (welBaseDiffSign) { + archivesCom = JSON.parseObject(fundPO.getFundPaymentComBaseString(), new HashMap().getClass()); + } else { + archivesCom = JSON.parseObject(fundPO.getFundPaymentBaseString(), new HashMap().getClass()); + } + //需要核算公积金的福利id 单位 + List needArchivesCom = new ArrayList<>(); + if (archivesCom != null) { + archivesCom.forEach((id, value) -> { + if (fundCom.containsKey(Long.valueOf(id))) { + needArchivesCom.add(Long.valueOf(id)); + } + }); + } + //判断核算周期、核算月、福利起始缴纳月的关系 + checkCycleSettingWithStartMonth(fundCom, billMonth, fundPO.getFundStartTime()); + + List fundComList = new ArrayList<>(); + Map fundComJsonMap = new HashMap<>(); + HashMap finalArchivesCom = archivesCom; + needArchivesCom.stream().forEach(e -> { + InsuranceSchemeDetailPO po = fundCom.get(e); + BigDecimal paymentProportion = new BigDecimal(StringUtils.isBlank(po.getPaymentProportion()) ? "0" : po.getPaymentProportion()).divide(new BigDecimal("100")); + BigDecimal paymentNum = new BigDecimal((ObjectUtil.isEmpty(finalArchivesCom) || StringUtils.isBlank(finalArchivesCom.get(String.valueOf(e)))) ? "0" : finalArchivesCom.get(String.valueOf(e))); + BigDecimal fixedCost = StringUtils.isBlank(po.getFixedCost()) ? new BigDecimal("0") : new BigDecimal(po.getFixedCost()); + Integer newScale = po.getValidNum() == null ? 2 : po.getValidNum(); +// BigDecimal result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost)); + BigDecimal result = new BigDecimal("0"); + if (Objects.equals(po.getPaymentCycle(), 1)) { + int monthValue = 1; + for (int i = monthIndex - 1; i >= 0; i--) { + String cycleValue = po.getCycleSetting().charAt(i) + ""; + if (Integer.parseInt(cycleValue) == 1) { + break; + } + monthValue++; + } + if (po.getAccountType() == 1) { + paymentNum = paymentNum.multiply(new BigDecimal(monthValue)); + fixedCost = fixedCost.multiply(new BigDecimal(monthValue)); + result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost)); + } else { + for (int i = 0; i < monthValue; i++) { + result = result.add(SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost))); + } + } + } else { + result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost)); + } + + fundComJsonMap.put(String.valueOf(e), result.toPlainString()); + fundComList.add(result); + }); + insuranceAccountDetailPO.setFundComJson(JSON.toJSONString(fundComJsonMap)); + BigDecimal fundComSum = new BigDecimal("0"); + for (BigDecimal bigDecimal : fundComList) { + fundComSum = fundComSum.add(bigDecimal); + } + insuranceAccountDetailPO.setFundComSum(fundComSum.toPlainString()); + + } + } + return insuranceAccountDetailPO; + } + + public InsuranceAccountDetailPO accountSocial(InsuranceAccountDetailPO insuranceAccountDetailPO, InsuranceArchivesAccountPO accountPO, String billMonth) { + boolean welBaseDiffSign = siArchivesBiz.isDiffWelBase(); + if (accountPO.getSocial() != null) { + InsuranceArchivesSocialSchemePO socialPO = accountPO.getSocial(); + insuranceAccountDetailPO.setSocialPayOrg(socialPO.getPaymentOrganization()); + insuranceAccountDetailPO.setSocialAccount(socialPO.getSocialAccount()); + insuranceAccountDetailPO.setSocialSchemeId(socialPO.getSocialSchemeId()); + insuranceAccountDetailPO.setSocialPaymentBaseString(socialPO.getSocialPaymentBaseString()); + insuranceAccountDetailPO.setSocialPaymentComBaseString(socialPO.getSocialPaymentComBaseString()); + //判断是否在起始缴纳月和最后缴纳月之间 + Boolean inDataRange = SalaryDateUtil.monthInRange(billMonth, socialPO.getSocialStartTime(), socialPO.getSocialEndTime()); + if ((Objects.equals(NonPaymentEnum.YES.getValue(), socialPO.getNonPayment()) || socialPO.getNonPayment() == null) && socialPO.getSocialSchemeId() != null && inDataRange) { + List detailPOS = getInsuranceSchemeDetailMapper().queryListBySchemeId(socialPO.getSocialSchemeId()); + encryptUtil.decryptList(detailPOS, InsuranceSchemeDetailPO.class); + //方案中包含的需要缴纳社保的个人福利 + int monthIndex = Integer.parseInt(billMonth.split("-")[1]) - 1; + Map schemeperson = detailPOS.stream() + .filter(item -> + Objects.equals(IsPaymentEnum.YES.getValue(), item.getIsPayment()) && + Objects.equals(item.getPaymentScope(), PaymentScopeEnum.SCOPE_PERSON.getValue()) && + (item.getPaymentCycle() == null || item.getPaymentCycle() == 0 || (item.getPaymentCycle() == 1 && String.valueOf(item.getCycleSetting().charAt(monthIndex)).equals("1"))) + ) + .collect( + Collectors.toMap(InsuranceSchemeDetailPO::getInsuranceId, Function.identity())); + //档案中包含的基数信息 + HashMap archivesPerson = JSON.parseObject(socialPO.getSocialPaymentBaseString(), new HashMap().getClass()); + //需要核算社保的福利id 个人 + List needArchivesPerson = new ArrayList<>(); + if (archivesPerson != null) { + archivesPerson.forEach((id, value) -> { + if (schemeperson.containsKey(Long.valueOf(id))) { + needArchivesPerson.add(Long.valueOf(id)); + } + }); + } + //判断核算周期、核算月、福利起始缴纳月的关系 + checkCycleSettingWithStartMonth(schemeperson, billMonth, socialPO.getSocialStartTime()); + + List socialPer = new ArrayList<>(); + Map socialPerJsonMap = new HashMap<>(); + needArchivesPerson.forEach(e -> { + InsuranceSchemeDetailPO po = schemeperson.get(e); + BigDecimal paymentProportion = new BigDecimal(StringUtils.isBlank(po.getPaymentProportion()) ? "0" : po.getPaymentProportion()).divide(new BigDecimal("100")); + BigDecimal paymentNum = new BigDecimal((ObjectUtil.isEmpty(archivesPerson) || StringUtils.isBlank(archivesPerson.get(String.valueOf(e)))) ? "0" : archivesPerson.get(String.valueOf(e))); + BigDecimal fixedCost = StringUtils.isBlank(po.getFixedCost()) ? new BigDecimal("0") : new BigDecimal(po.getFixedCost()); + Integer newScale = po.getValidNum() == null ? 2 : po.getValidNum(); +// BigDecimal result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost)); + BigDecimal result = new BigDecimal("0"); + if (Objects.equals(po.getPaymentCycle(), 1)) { + int monthValue = 1; + for (int i = monthIndex - 1; i >= 0; i--) { + String cycleValue = po.getCycleSetting().charAt(i) + ""; + if (Integer.parseInt(cycleValue) == 1) { + break; + } + monthValue++; + } + if (po.getAccountType() == 1) { + paymentNum = paymentNum.multiply(new BigDecimal(monthValue)); + fixedCost = fixedCost.multiply(new BigDecimal(monthValue)); + result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost)); + } else { + for (int i = 0; i < monthValue; i++) { + result = result.add(SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost))); + } + } + } else { + result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost)); + } + + socialPerJsonMap.put(String.valueOf(e), result.toPlainString()); + socialPer.add(result); + }); + insuranceAccountDetailPO.setSocialPerJson(JSON.toJSONString(socialPerJsonMap)); + BigDecimal socialPerSum = new BigDecimal("0"); + for (BigDecimal bigDecimal : socialPer) { + socialPerSum = socialPerSum.add(bigDecimal); + } + insuranceAccountDetailPO.setSocialPerSum(socialPerSum.toPlainString()); + + //方案中包含的需要缴纳社保的单位福利 + Map schemeCom = detailPOS.stream() + .filter(item -> Objects.equals(IsPaymentEnum.YES.getValue(), item.getIsPayment()) && Objects.equals(item.getPaymentScope(), PaymentScopeEnum.SCOPE_COMPANY.getValue()) && + (item.getPaymentCycle() == null || item.getPaymentCycle() == 0 || (item.getPaymentCycle() == 1 && String.valueOf(item.getCycleSetting().charAt(monthIndex)).equals("1")))) + .collect( + Collectors.toMap(InsuranceSchemeDetailPO::getInsuranceId, Function.identity())); + //档案中包含的基数信息 +// HashMap archivesCom = JSON.parseObject(socialPO.getSocialPaymentBaseString(), new HashMap().getClass()); + HashMap archivesCom = new HashMap<>(); + if (welBaseDiffSign) { + archivesCom = JSON.parseObject(socialPO.getSocialPaymentComBaseString(), new HashMap().getClass()); + } else { + archivesCom = JSON.parseObject(socialPO.getSocialPaymentBaseString(), new HashMap().getClass()); + } + //需要核算社保的福利id 单位 + List needArchivesCom = new ArrayList<>(); + if (archivesCom != null) { + archivesCom.forEach((id, value) -> { + if (schemeCom.containsKey(Long.valueOf(id))) { + needArchivesCom.add(Long.valueOf(id)); + } + }); + } + //判断核算周期、核算月、福利起始缴纳月的关系 + checkCycleSettingWithStartMonth(schemeCom, billMonth, socialPO.getSocialStartTime()); + + List socialCom = new ArrayList<>(); + Map sociaComJsonMap = new HashMap<>(); + HashMap finalArchivesCom = archivesCom; + needArchivesCom.stream().forEach(e -> { + InsuranceSchemeDetailPO po = schemeCom.get(e); + BigDecimal paymentProportion = new BigDecimal(StringUtils.isBlank(po.getPaymentProportion()) ? "0" : po.getPaymentProportion()).divide(new BigDecimal("100")); + BigDecimal paymentNum = new BigDecimal((ObjectUtil.isEmpty(finalArchivesCom) || StringUtils.isBlank(finalArchivesCom.get(String.valueOf(e)))) ? "0" : finalArchivesCom.get(String.valueOf(e))); + BigDecimal fixedCost = StringUtils.isBlank(po.getFixedCost()) ? new BigDecimal("0") : new BigDecimal(po.getFixedCost()); + Integer newScale = po.getValidNum() == null ? 2 : po.getValidNum(); +// BigDecimal result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost)); + BigDecimal result = new BigDecimal("0"); + if (Objects.equals(po.getPaymentCycle(), 1)) { + int monthValue = 1; + for (int i = monthIndex - 1; i >= 0; i--) { + String cycleValue = po.getCycleSetting().charAt(i) + ""; + if (Integer.parseInt(cycleValue) == 1) { + break; + } + monthValue++; + } + if (po.getAccountType() == 1) { + paymentNum = paymentNum.multiply(new BigDecimal(monthValue)); + fixedCost = fixedCost.multiply(new BigDecimal(monthValue)); + result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost)); + } else { + for (int i = 0; i < monthValue; i++) { + result = result.add(SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost))); + } + } + } else { + result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost)); + } + + sociaComJsonMap.put(String.valueOf(e), result.toPlainString()); + socialCom.add(result); + + }); + insuranceAccountDetailPO.setSocialComJson(JSON.toJSONString(sociaComJsonMap)); + BigDecimal socialComSum = new BigDecimal("0"); + for (BigDecimal decimal : socialCom) { + socialComSum = socialComSum.add(decimal); + } + insuranceAccountDetailPO.setSocialComSum(socialComSum.toPlainString()); + } + + } + return insuranceAccountDetailPO; + } + + public InsuranceAccountDetailPO accountEndowmentInsurance(InsuranceAccountDetailPO insuranceAccountDetailPO, InsuranceArchivesAccountPO accountPO, List categoryIds, String billMonth) { + if (accountPO.getSocial() != null) { + InsuranceArchivesSocialSchemePO socialPO = accountPO.getSocial(); + insuranceAccountDetailPO.setSocialPayOrg(socialPO.getPaymentOrganization()); + insuranceAccountDetailPO.setSocialAccount(socialPO.getSocialAccount()); + insuranceAccountDetailPO.setSocialSchemeId(socialPO.getSocialSchemeId()); + insuranceAccountDetailPO.setSocialPaymentBaseString(socialPO.getSocialPaymentBaseString()); + insuranceAccountDetailPO.setSocialPaymentComBaseString(socialPO.getSocialPaymentComBaseString()); + //判断是否在起始缴纳月和最后缴纳月之间 + Boolean inDataRange = SalaryDateUtil.monthInRange(billMonth, socialPO.getSocialStartTime(), socialPO.getSocialEndTime()); + + if ((Objects.equals(NonPaymentEnum.YES.getValue(), socialPO.getNonPayment()) || socialPO.getNonPayment() == null) && socialPO.getSocialSchemeId() != null && inDataRange) { + List detailPOS = getInsuranceSchemeDetailMapper().queryListBySchemeId(socialPO.getSocialSchemeId()); + encryptUtil.decryptList(detailPOS, InsuranceSchemeDetailPO.class); + //方案中包含的需要缴纳社保的个人福利 + int monthIndex = Integer.parseInt(billMonth.split("-")[1]) - 1; + Map schemeperson = detailPOS.stream() + .filter(item -> Objects.equals(IsPaymentEnum.YES.getValue(), item.getIsPayment()) + && Objects.equals(item.getPaymentScope(), PaymentScopeEnum.SCOPE_PERSON.getValue()) + && (item.getPaymentCycle() == null || item.getPaymentCycle() == 0 || (item.getPaymentCycle() == 1 && String.valueOf(item.getCycleSetting().charAt(monthIndex)).equals("1")))) + .collect( + Collectors.toMap(InsuranceSchemeDetailPO::getInsuranceId, Function.identity())); + //档案中包含的基数信息 + HashMap archivesPerson = JSON.parseObject(socialPO.getSocialPaymentBaseString(), new HashMap().getClass()); + //需要核算社保的福利id 个人 + List needArchivesPerson = new ArrayList<>(); + if (archivesPerson != null) { + categoryIds.forEach(item -> { + if (archivesPerson.containsKey(String.valueOf(item)) && schemeperson.containsKey(item)) { + if (StringUtils.isNotBlank(archivesPerson.get(String.valueOf(item)))) { + needArchivesPerson.add(item); + } + + } + }); + } + //判断核算周期、核算月、福利起始缴纳月的关系 + checkCycleSettingWithStartMonth(schemeperson, billMonth, socialPO.getSocialStartTime()); + + List socialPer = new ArrayList<>(); + Map socialPerJsonMap = new HashMap<>(); + needArchivesPerson.forEach(e -> { + InsuranceSchemeDetailPO po = schemeperson.get(e); + BigDecimal paymentProportion = new BigDecimal(po.getPaymentProportion()).divide(new BigDecimal("100")); +// BigDecimal paymentNum = new BigDecimal(archivesPerson.get(String.valueOf(e))); + BigDecimal paymentNum = new BigDecimal((ObjectUtil.isEmpty(archivesPerson) || StringUtils.isBlank(archivesPerson.get(String.valueOf(e)))) ? "0" : archivesPerson.get(String.valueOf(e))); + BigDecimal fixedCost = StringUtils.isBlank(po.getFixedCost()) ? new BigDecimal("0") : new BigDecimal(po.getFixedCost()); + Integer newScale = po.getValidNum() == null ? 2 : po.getValidNum(); +// BigDecimal result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost)); + BigDecimal result = new BigDecimal("0"); + if (Objects.equals(po.getPaymentCycle(), 1)) { + int monthValue = 1; + for (int i = monthIndex - 1; i >= 0; i--) { + String cycleValue = po.getCycleSetting().charAt(i) + ""; + if (Integer.parseInt(cycleValue) == 1) { + break; + } + monthValue++; + } + if (po.getAccountType() == 1) { + paymentNum = paymentNum.multiply(new BigDecimal(monthValue)); + fixedCost = fixedCost.multiply(new BigDecimal(monthValue)); + result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost)); + } else { + for (int i = 0; i < monthValue; i++) { + result = result.add(SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost))); + } + } + } else { + result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost)); + } + socialPerJsonMap.put(String.valueOf(e), result.toPlainString()); + socialPer.add(result); + }); + insuranceAccountDetailPO.setSocialPerJson(JSON.toJSONString(socialPerJsonMap)); + BigDecimal socialPerSum = new BigDecimal("0"); + for (BigDecimal bigDecimal : socialPer) { + socialPerSum = socialPerSum.add(bigDecimal); + } + insuranceAccountDetailPO.setSocialPerSum(socialPerSum.toPlainString()); + + //方案中包含的需要缴纳社保的单位福利 + Map schemeCom = detailPOS.stream() + .filter(item -> Objects.equals(IsPaymentEnum.YES.getValue(), item.getIsPayment()) && Objects.equals(item.getPaymentScope(), PaymentScopeEnum.SCOPE_COMPANY.getValue()) && + (item.getPaymentCycle() == null || item.getPaymentCycle() == 0 || (item.getPaymentCycle() == 1 && String.valueOf(item.getCycleSetting().charAt(monthIndex)).equals("1")))) + .collect( + Collectors.toMap(InsuranceSchemeDetailPO::getInsuranceId, Function.identity())); + //档案中包含的基数信息 + HashMap archivesCom = JSON.parseObject(socialPO.getSocialPaymentBaseString(), new HashMap().getClass()); + //需要核算社保的福利id 单位 + List needArchivesCom = new ArrayList<>(); + if (archivesCom != null) { + categoryIds.forEach(item -> { + if (archivesCom.containsKey(String.valueOf(item)) && schemeCom.containsKey(item)) { + if (StringUtils.isNotBlank(archivesCom.get(String.valueOf(item)))) { + needArchivesCom.add(item); + } + + } + }); + //判断核算周期、核算月、福利起始缴纳月的关系 + checkCycleSettingWithStartMonth(schemeCom, billMonth, socialPO.getSocialStartTime()); + +// archivesCom.forEach((id, value) -> { +// if (schemeCom.containsKey(Long.valueOf(id))) { +// needArchivesCom.add(Long.valueOf(id)); +// } +// }); + } + + List socialCom = new ArrayList<>(); + Map sociaComJsonMap = new HashMap<>(); + needArchivesCom.forEach(e -> { + InsuranceSchemeDetailPO po = schemeCom.get(e); + BigDecimal paymentProportion = new BigDecimal(po.getPaymentProportion()).divide(new BigDecimal("100")); +// BigDecimal paymentNum = SalaryEntityUtil.string2BigDecimalDefault0(archivesCom.get(String.valueOf(e))); + BigDecimal paymentNum = new BigDecimal((ObjectUtil.isEmpty(archivesCom) || StringUtils.isBlank(archivesCom.get(String.valueOf(e)))) ? "0" : archivesCom.get(String.valueOf(e))); + BigDecimal fixedCost = StringUtils.isBlank(po.getFixedCost()) ? new BigDecimal("0") : new BigDecimal(po.getFixedCost()); + Integer newScale = po.getValidNum() == null ? 2 : po.getValidNum(); +// BigDecimal result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost)); + BigDecimal result = new BigDecimal("0"); + if (Objects.equals(po.getPaymentCycle(), 1)) { + int monthValue = 1; + for (int i = monthIndex - 1; i >= 0; i--) { + String cycleValue = po.getCycleSetting().charAt(i) + ""; + if (Integer.parseInt(cycleValue) == 1) { + break; + } + monthValue++; + } + if (po.getAccountType() == 1) { + paymentNum = paymentNum.multiply(new BigDecimal(monthValue)); + fixedCost = fixedCost.multiply(new BigDecimal(monthValue)); + result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost)); + } else { + for (int i = 0; i < monthValue; i++) { + result = result.add(SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost))); + } + } + } else { + result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost)); + } + + sociaComJsonMap.put(String.valueOf(e), result.toPlainString()); + socialCom.add(result); + + }); + insuranceAccountDetailPO.setSocialComJson(JSON.toJSONString(sociaComJsonMap)); + BigDecimal socialComSum = new BigDecimal("0"); + for (BigDecimal decimal : socialCom) { + socialComSum = socialComSum.add(decimal); + } + insuranceAccountDetailPO.setSocialComSum(socialComSum.toPlainString()); + } + } + return insuranceAccountDetailPO; + } + + + private List> splitDetailList(List list, int groupSize) { + int length = list.size(); + // 计算可以分成多少组 + int num = (length + groupSize - 1) / groupSize; + List> newList = new ArrayList<>(num); + for (int i = 0; i < num; i++) { + // 开始位置 + int fromIndex = i * groupSize; + // 结束位置 + int toIndex = (i + 1) * groupSize < length ? (i + 1) * groupSize : length; + newList.add(list.subList(fromIndex, toIndex)); + } + return newList; + } + + public void batchSaveSupplementAccount(List pos, String billMonth, String tenantKey) { + if (CollectionUtils.isEmpty(pos)) { + return; + } + batchSaveAccountInspectDetail(pos, billMonth, tenantKey); + getInsuranceAccountDetailMapper().batchDelSupplementAccountDetails(pos); + encryptUtil.encryptList(pos, InsuranceAccountDetailPO.class); + List> lists = splitDetailList(pos, 20); + lists.forEach(subList -> { + getInsuranceAccountDetailMapper().batchSaveAccountDetails(subList); + }); + //删除日志 +// pos.stream().forEach(item -> { +// LoggerContext insuranceSchemeContext = new LoggerContext(); +// insuranceSchemeContext.setTargetId(String.valueOf(item.getId())); +// insuranceSchemeContext.setTargetName(String.valueOf(item.getEmployeeId())); +// insuranceSchemeContext.setOperateType(OperateTypeEnum.DELETE.getValue()); +// insuranceSchemeContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(100448, "删除核算记录")); +// insuranceSchemeContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(100448, "删除核算记录")); +// insuranceSchemeContext.setNewValues(item); +// siAccountLoggerTemplate.write(insuranceSchemeContext); +// }); + //插入日志 +// pos.stream().forEach(item -> { +// LoggerContext insuranceSchemeContext = new LoggerContext(); +// insuranceSchemeContext.setTargetId(String.valueOf(item.getId())); +// insuranceSchemeContext.setTargetName(String.valueOf(item.getEmployeeId())); +// insuranceSchemeContext.setOperateType(OperateTypeEnum.ADD.getValue()); +// insuranceSchemeContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(100494, "新建核算记录")); +// insuranceSchemeContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(100494, "新建核算记录")); +// insuranceSchemeContext.setNewValues(item); +// siAccountLoggerTemplate.write(insuranceSchemeContext); +// }); + } + + public void deleteCommonAccount(SaveCommonAccountParam param, Long employeeId, String currentUserName) { + ValidUtil.doValidator(param); + SalaryAssert.notEmpty(param.getIncludes(), SalaryI18nUtil.getI18nLabel(84026, "参数错误")); + //根据id批量删除 + if (param.getIds().size() > 0) { + getInsuranceAccountDetailMapper().batchDelAccountDetailsByIds(param.getIds()); + } else { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "请勾选需要删除的数据项!")); + } + //记录日志 +// LoggerContext insuranceSchemeContext = new LoggerContext(); +// insuranceSchemeContext.setTargetId(String.join(",", param.getIncludes().stream().map(item -> String.valueOf(item)).collect(Collectors.toList()))); +// insuranceSchemeContext.setTargetName(param.getBillMonth()); +// insuranceSchemeContext.setOperateType(OperateTypeEnum.ADD.getValue()); +// insuranceSchemeContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 100462, "新增台账")); +// insuranceSchemeContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 100462, "新增台账")); +// insuranceSchemeContext.setNewValues(param); +// siAccountLoggerTemplate.write(insuranceSchemeContext); + updateBatchAccount(AccountParam.builder().billMonth(param.getBillMonth()).paymentOrganization(param.getPaymentOrganization()).build(), employeeId, SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY, currentUserName); + } + + public void deleteSupplementaryAccount(List param, Long employeeId, String currentUserName) { + SalaryAssert.notEmpty(param, SalaryI18nUtil.getI18nLabel(84026, "参数错误")); + boolean valid = param.stream().anyMatch(item -> item.getEmployeeId() == null + || StringUtils.isBlank(item.getSupplementaryMonth()) + || StringUtils.isBlank(item.getBillMonth())); + if (valid) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(84026, "参数错误")); + } + getInsuranceAccountDetailMapper().batchDelSupplementDetailsByIds(param); +// param.stream().forEach(item -> { +// LoggerContext insuranceSchemeContext = new LoggerContext(); +// insuranceSchemeContext.setTargetName(item.getBillMonth()); +// insuranceSchemeContext.setOperateType(OperateTypeEnum.DELETE.getValue()); +// insuranceSchemeContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 100490, "删除补缴核算记录")); +// insuranceSchemeContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 100490, "删除补缴核算记录")); +// insuranceSchemeContext.setNewValues(item); +// siAccountLoggerTemplate.write(insuranceSchemeContext); +// }); + updateBatchAccount(AccountParam.builder().billMonth(param.get(0).getBillMonth()).paymentOrganization(param.get(0).getPaymentOrganization()).build(), employeeId, SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY, currentUserName); + } + + public void file(String billMonth, Long employeeId, Long paymentOrganization) { + // 归档前检查是否有核算异常 +// List insuranceAccountInspectPOS = getInsuranceAccountInspectMapper().getByInspectStatusAndBillMonth(InspectStatusEnum.IGNORE.getValue(),billMonth); + +// SalaryAssert.isEmpty(insuranceAccountInspectPOS, SalaryI18nUtil.getI18nLabel( 100500, "当前核算月存在核算异常数据")); + //开始归档数据 + InsuranceAccountBatchPO insuranceAccountBatchPO = getInsuranceAccountBatchMapper().getByBillStatus(billMonth, BillStatusEnum.NOT_ARCHIVED.getValue(), paymentOrganization); + encryptUtil.decrypt(insuranceAccountBatchPO, InsuranceAccountBatchPO.class); + SalaryAssert.notNull(insuranceAccountBatchPO, SalaryI18nUtil.getI18nLabel(100503, "月份账单不存在")); + SalaryAssert.isFalse(Objects.equals(insuranceAccountBatchPO.getBillStatus(), BillStatusEnum.ARCHIVED.getValue()), SalaryI18nUtil.getI18nLabel(100504, "月份账单已归档")); + insuranceAccountBatchPO.setBillStatus(BillStatusEnum.ARCHIVED.getValue()); + encryptUtil.encrypt(insuranceAccountBatchPO, InsuranceAccountBatchPO.class); + getInsuranceAccountBatchMapper().updateById(insuranceAccountBatchPO); + //日志记录 +// LoggerContext insuranceSchemeContext = new LoggerContext(); +// insuranceSchemeContext.setTargetId(String.valueOf(insuranceAccountBatchPO.getId())); +// insuranceSchemeContext.setTargetName(insuranceAccountBatchPO.getBillMonth()); +// insuranceSchemeContext.setOperateType(OperateTypeEnum.UPDATE.getValue()); +// insuranceSchemeContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 100506, "台账归档")); +// insuranceSchemeContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 100506, "台账归档")); +// insuranceSchemeContext.setNewValues(insuranceAccountBatchPO); +// siAccountLoggerTemplate.write(insuranceSchemeContext); + } + + + public void accountInspect(Collection ids, String billMonth, Long employeeId, String currentUserName, Long paymentOrganization) { + List insuranceAccountInspectPOS = allInspects(ids, billMonth); + SalaryAssert.notEmpty(insuranceAccountInspectPOS, SalaryI18nUtil.getI18nLabel(100515, "无核算数据")); + List commonInspects = insuranceAccountInspectPOS.stream() + .filter(e -> Objects.equals(e.getPaymentStatus(), PaymentStatusEnum.COMMON.getValue())) + .collect(Collectors.toList()); + List supplementInspects = insuranceAccountInspectPOS.stream() + .filter(e -> Objects.equals(e.getPaymentStatus(), PaymentStatusEnum.REPAIR.getValue())) + .collect(Collectors.toList()); + //核算正常缴纳 + if (CollectionUtils.isNotEmpty(commonInspects)) { + SaveCommonAccountParam param = new SaveCommonAccountParam(); + param.setBillMonth(billMonth); + param.setIncludes(commonInspects.stream().map(InsuranceAccountInspectPO::getEmployeeId).collect(Collectors.toList())); + saveCommonAccount(param, employeeId, currentUserName); + } + //核算补缴 + if (CollectionUtils.isNotEmpty(supplementInspects)) { + List baseList = new ArrayList<>(); + supplementInspects.forEach(e -> { + SupplementAccountBaseParam base = new SupplementAccountBaseParam(); + base.setBillMonth(billMonth); + base.setProjects( + e.getSupplementaryProjects() == null ? null : Arrays.stream(e.getSupplementaryProjects().split(",")).map(Integer::valueOf).collect(Collectors.toList())); + base.setEmployeeId(e.getEmployeeId()); + base.setSupplementaryMonth(e.getSupplementaryMonth()); + baseList.add(base); + }); + accountSupplement(baseList, baseList.stream().map(SupplementAccountBaseParam::getEmployeeId).collect(Collectors.toList()), billMonth, employeeId, paymentOrganization); + } + } + + + public List allInspects(Collection ids, String billMonth) { + List list = getInsuranceAccountInspectMapper().getList(billMonth, InspectStatusEnum.IGNORE.getValue(), ids); + + if (CollectionUtils.isNotEmpty(list)) { + return list; + } + return Collections.emptyList(); + } + + + public PageInfo overView(InsuranceAccountDetailParam queryParam) { + +// SalaryPageUtil.start(queryParam.getCurrent(),queryParam.getPageSize()); + List insuranceAccountDetailPOS = getInsuranceAccountDetailMapper().selectList(queryParam.getBillMonth(), StringUtil.isBlank(queryParam.getPaymentOrganization()) ? null : Long.valueOf(queryParam.getPaymentOrganization())); + encryptUtil.decryptList(insuranceAccountDetailPOS, InsuranceAccountDetailPO.class); + + //获取扣缴义务人信息 + List paymentList = getTaxAgentMapper().listAll(); + SalaryAssert.notEmpty(paymentList, SalaryI18nUtil.getI18nLabel(100341, "该租户无扣缴义务人")); + Map paymentMap = paymentList.stream().collect(Collectors.toMap(TaxAgentPO::getId, Function.identity())); + List insuranceAccountViewListDTOS = buildRecords(insuranceAccountDetailPOS, paymentMap); + +// List iCategoryPOS = getICategoryMapper().listAll(); +// Page page = FormatManager.getTablePage(); +// Page insuranceAccountViewListDTOPage = new Page<>(page.getCurrent(), insuranceAccountViewListDTOS.size(), insuranceAccountViewListDTOS.size(), +// page.isSearchCount()); + + PageInfo insuranceAccountViewListDTOPage = new PageInfo<>(insuranceAccountViewListDTOS, InsuranceAccountViewListDTO.class); + insuranceAccountViewListDTOPage.setTotal(insuranceAccountViewListDTOS.size()); + return insuranceAccountViewListDTOPage; + } + + public List buildRecords(List list, Map paymentMap) { + Map result = new HashMap<>(); + //根据组织分组,对社保进行统计 + Map> socialCollect = list.stream().filter(item -> item.getSocialPayOrg() != null) + .collect(Collectors.groupingBy(InsuranceAccountDetailPO::getSocialPayOrg)); + socialCollect.forEach((k, v) -> { + if (result.get(k) == null) { + InsuranceAccountViewListDTO temp = new InsuranceAccountViewListDTO(); + temp.setPayOrg(paymentMap.get(k).getName()); + result.put(k, temp); + } + InsuranceAccountViewListDTO insuranceAccountViewListDTO = result.get(k); + accountSocialView(insuranceAccountViewListDTO, v); + }); + //根据组织分组,对公积金进行统计 + Map> fundCollect = list.stream().filter(item -> item.getSocialPayOrg() != null) + .collect(Collectors.groupingBy(InsuranceAccountDetailPO::getSocialPayOrg)); + fundCollect.forEach((k, v) -> { + if (result.get(k) == null) { + InsuranceAccountViewListDTO temp = new InsuranceAccountViewListDTO(); + temp.setPayOrg(paymentMap.get(k).getName()); + result.put(k, temp); + } + InsuranceAccountViewListDTO insuranceAccountViewListDTO = result.get(k); + accountFundView(insuranceAccountViewListDTO, v); + }); + //根据组织分组,对其他福利进行统计 + Map> otherCollect = list.stream().filter(item -> item.getSocialPayOrg() != null) + .collect(Collectors.groupingBy(InsuranceAccountDetailPO::getSocialPayOrg)); + otherCollect.forEach((k, v) -> { + if (result.get(k) == null) { + InsuranceAccountViewListDTO temp = new InsuranceAccountViewListDTO(); + temp.setPayOrg(paymentMap.get(k).getName()); + result.put(k, temp); + } + InsuranceAccountViewListDTO insuranceAccountViewListDTO = result.get(k); + accountOtherView(insuranceAccountViewListDTO, v); + }); + //对各组织进行金额合计 + List viewDTOS = new ArrayList<>(); + result.forEach((k, v) -> { + BigDecimal socialPaySum = StringUtils.isBlank(v.getSocialPaySum()) ? new BigDecimal("0") : new BigDecimal(v.getSocialPaySum()); + BigDecimal fundPaySum = StringUtils.isBlank(v.getFundPaySum()) ? new BigDecimal("0") : new BigDecimal(v.getFundPaySum()); + BigDecimal otherPaySum = StringUtils.isBlank(v.getOtherPaySum()) ? new BigDecimal("0") : new BigDecimal(v.getOtherPaySum()); + v.setIndex(k); + BigDecimal sum = socialPaySum.add(fundPaySum).add(otherPaySum); + v.setSum(sum.toPlainString()); + viewDTOS.add(v); + }); + //合计 + InsuranceAccountViewListDTO insuranceAccountViewListDTO = new InsuranceAccountViewListDTO(); + int socialNum = 0; + int fundNum = 0; + int otherNum = 0; + BigDecimal socialSum = new BigDecimal("0"); + BigDecimal fundSum = new BigDecimal("0"); + BigDecimal otherSum = new BigDecimal("0"); + BigDecimal sum = new BigDecimal("0"); + for (InsuranceAccountViewListDTO item : viewDTOS) { + if (item.getSocialNum() != null) { + socialNum += item.getSocialNum(); + } + if (item.getFundNum() != null) { + fundNum += item.getFundNum(); + } + if (item.getOtherNum() != null) { + otherNum += item.getOtherNum(); + } + if (StringUtils.isNotBlank(item.getSocialPaySum())) { + socialSum = socialSum.add(new BigDecimal(item.getSocialPaySum())); + } + if (StringUtils.isNotBlank(item.getFundPaySum())) { + fundSum = fundSum.add(new BigDecimal(item.getFundPaySum())); + } + if (StringUtils.isNotBlank(item.getOtherPaySum())) { + otherSum = otherSum.add(new BigDecimal(item.getOtherPaySum())); + } + if (StringUtils.isNotBlank(item.getSum())) { + sum = sum.add(new BigDecimal(item.getSum())); + } + } + insuranceAccountViewListDTO.setSum(sum.toPlainString()); + insuranceAccountViewListDTO.setSocialPaySum(socialSum.toPlainString()); + insuranceAccountViewListDTO.setPayOrg(SalaryI18nUtil.getI18nLabel(93278, "合计")); + insuranceAccountViewListDTO.setFundPaySum(fundSum.toPlainString()); + insuranceAccountViewListDTO.setOtherPaySum(otherSum.toPlainString()); + insuranceAccountViewListDTO.setSocialNum(socialNum); + insuranceAccountViewListDTO.setFundNum(fundNum); + insuranceAccountViewListDTO.setOtherNum(otherNum); + viewDTOS.add(insuranceAccountViewListDTO); + viewDTOS.forEach(e -> { + e.setSocialPaySum(StringUtils.isBlank(e.getSocialPaySum()) ? "0" : e.getSocialPaySum()); + e.setSocialNum(e.getSocialNum() == null ? 0 : e.getSocialNum()); + e.setFundNum(e.getFundNum() == null ? 0 : e.getFundNum()); + e.setFundPaySum(StringUtils.isBlank(e.getFundPaySum()) ? "0" : e.getFundPaySum()); + e.setOtherPaySum(StringUtils.isBlank(e.getOtherPaySum()) ? "0" : e.getOtherPaySum()); + e.setOtherNum(e.getOtherNum() == null ? 0 : e.getOtherNum()); + e.setSum(SalaryEntityUtil.thousandthConvert(e.getSum())); + e.setSocialPaySum(SalaryEntityUtil.thousandthConvert(e.getSocialPaySum())); + e.setOtherPaySum(SalaryEntityUtil.thousandthConvert(e.getOtherPaySum())); + e.setFundPaySum(SalaryEntityUtil.thousandthConvert(e.getFundPaySum())); + }); + return viewDTOS; + } + + public void accountOtherView(InsuranceAccountViewListDTO dto, List pos) { + int otherNum = 0; + BigDecimal otherPaySum = new BigDecimal("0"); + for (InsuranceAccountDetailPO item : pos) { + if (StringUtils.isNotBlank(item.getOtherSum()) && SalaryEntityUtil.string2DoubleDefault0(item.getOtherSum()) != 0.0) { + if (!PaymentStatusEnum.BALANCE.getValue().equals(item.getPaymentStatus())) { + otherNum += 1; + } + otherPaySum = otherPaySum.add(new BigDecimal(item.getOtherSum())); + } + } + dto.setOtherNum(otherNum); + dto.setOtherPaySum(otherPaySum.toPlainString()); + } + + public void accountFundView(InsuranceAccountViewListDTO dto, List pos) { + int fundNum = 0; + BigDecimal fundPaySum = new BigDecimal("0"); + for (InsuranceAccountDetailPO item : pos) { + if (StringUtils.isNotBlank(item.getFundSum()) && SalaryEntityUtil.string2DoubleDefault0(item.getFundSum()) != 0.0) { + if (!PaymentStatusEnum.BALANCE.getValue().equals(item.getPaymentStatus())) { + fundNum += 1; + } + fundPaySum = fundPaySum.add(new BigDecimal(item.getFundSum())); + } + } + dto.setFundNum(fundNum); + dto.setFundPaySum(fundPaySum.toPlainString()); + } + + public void accountSocialView(InsuranceAccountViewListDTO dto, List pos) { + int socialNum = 0; + BigDecimal socialPaySum = new BigDecimal("0"); + for (InsuranceAccountDetailPO item : pos) { + if (StringUtils.isNotBlank(item.getSocialSum()) && SalaryEntityUtil.string2DoubleDefault0(item.getSocialSum()) != 0.0 ) { + if (!PaymentStatusEnum.BALANCE.getValue().equals(item.getPaymentStatus())) { + socialNum += 1; + } + socialPaySum = socialPaySum.add(new BigDecimal(item.getSocialSum())); + } + } + dto.setSocialNum(socialNum); + dto.setSocialPaySum(socialPaySum.toPlainString()); + } + + + /** + * 查询台账id是否已经薪资核算核算过 + * + * @param param + * @return + */ + public int checkIfBusinessaccounting(InsuranceAccountBatchPO param) { + List list = getSIAccountUtilMapper().checkIfBusinessaccounting(param.getId()); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM"); + return (int) list.stream().filter( f -> { + String billMonthBySob = sdf.format(convertSalaryMonthToBillMonth(f.getSalaryMonth(), f.getSocialSecurityCycleType())); + return f.getBillmonth().equals(billMonthBySob.substring(0, 7)); + }).count(); + } + + public Date convertSalaryMonthToBillMonth(Date salaryMonth, Integer socialSecurityCycleType) { + Calendar calendar = Calendar.getInstance(); + calendar.setTime(salaryMonth); + calendar.add(Calendar.MONTH, socialSecurityCycleType - 3); + return calendar.getTime(); + } + /** + * 更新薪资台账 + * + * @param param + * @return + */ + public void updateById(InsuranceAccountBatchPO param) { + getInsuranceAccountBatchMapper().updateById(param); + } + + /** + * 更新福利台账 + */ + public void updateByEmployeeIdAndBillMonth(InsuranceAccountDetailPO insuranceAccountDetailPO) { + getInsuranceAccountDetailMapper().updateByEmployeeIdAndBillMonth(insuranceAccountDetailPO); + } + + public void accountFundByData(InsuranceAccountDetailPO insuranceAccountDetailPO, SupplementAccountBaseParam baseParam) { + //公积金个人 + if (StringUtils.isNotBlank(baseParam.getFundPaymentPerString())) { + List fundPer = new ArrayList<>(); + HashMap fundPerson = JSON.parseObject(baseParam.getFundPaymentPerString(), new HashMap().getClass()); + fundPerson.forEach((k, v) -> { + BigDecimal result = new BigDecimal(v); + fundPer.add(result); + }); + insuranceAccountDetailPO.setFundPerJson(baseParam.getFundPaymentPerString()); + BigDecimal fundPerSum = new BigDecimal("0"); + for (BigDecimal bigDecimal : fundPer) { + fundPerSum = fundPerSum.add(bigDecimal); + } + insuranceAccountDetailPO.setFundPerSum(fundPerSum.toPlainString()); + } + //公积金单位 + if (StringUtils.isNotBlank(baseParam.getFundPaymentComString())) { + List fundCom = new ArrayList<>(); + HashMap fundComMap = JSON.parseObject(baseParam.getFundPaymentComString(), new HashMap().getClass()); + fundComMap.forEach((k, v) -> { + BigDecimal result = new BigDecimal(v); + fundCom.add(result); + }); + insuranceAccountDetailPO.setFundComJson(baseParam.getFundPaymentComString()); + BigDecimal fundComSum = new BigDecimal("0"); + for (BigDecimal bigDecimal : fundCom) { + fundComSum = fundComSum.add(bigDecimal); + } + insuranceAccountDetailPO.setFundComSum(fundComSum.toPlainString()); + } + } + + public void accountOtherByData(InsuranceAccountDetailPO insuranceAccountDetailPO, SupplementAccountBaseParam baseParam) { + //其他福利个人 + if (StringUtils.isNotBlank(baseParam.getOtherPaymentPerString())) { + List otherPer = new ArrayList<>(); + HashMap otherPerMap = JSON.parseObject(baseParam.getOtherPaymentPerString(), new HashMap().getClass()); + otherPerMap.forEach((k, v) -> { + BigDecimal result = new BigDecimal(v); + otherPer.add(result); + }); + insuranceAccountDetailPO.setOtherPerJson(baseParam.getOtherPaymentPerString()); + BigDecimal otherPerSum = new BigDecimal("0"); + for (BigDecimal bigDecimal : otherPer) { + otherPerSum = otherPerSum.add(bigDecimal); + } + insuranceAccountDetailPO.setOtherPerSum(otherPerSum.toPlainString()); + } + //其他福利单位 + if (StringUtils.isNotBlank(baseParam.getOtherPaymentComString())) { + List otherCom = new ArrayList<>(); + HashMap otherComMap = JSON.parseObject(baseParam.getOtherPaymentComString(), new HashMap().getClass()); + otherComMap.forEach((k, v) -> { + BigDecimal result = new BigDecimal(v); + otherCom.add(result); + }); + insuranceAccountDetailPO.setOtherComJson(baseParam.getOtherPaymentComString()); + BigDecimal otherComSum = new BigDecimal("0"); + for (BigDecimal bigDecimal : otherCom) { + otherComSum = otherComSum.add(bigDecimal); + } + insuranceAccountDetailPO.setOtherComSum(otherComSum.toPlainString()); + } + } + + public void accountSocialByData(InsuranceAccountDetailPO insuranceAccountDetailPO, SupplementAccountBaseParam baseParam) { + //社保个人 + if (StringUtils.isNotBlank(baseParam.getSocialPaymentPerString())) { + List socialPer = new ArrayList<>(); + HashMap archivesPerson = JSON.parseObject(baseParam.getSocialPaymentPerString(), new HashMap().getClass()); + archivesPerson.forEach((k, v) -> { + BigDecimal result = new BigDecimal(v); + socialPer.add(result); + }); + insuranceAccountDetailPO.setSocialPerJson(baseParam.getSocialPaymentPerString()); + BigDecimal socialPerSum = new BigDecimal("0"); + for (BigDecimal bigDecimal : socialPer) { + socialPerSum = socialPerSum.add(bigDecimal); + } + insuranceAccountDetailPO.setSocialPerSum(socialPerSum.toPlainString()); + } + //社保单位 + if (StringUtils.isNotBlank(baseParam.getSocialPaymentComString())) { + List socialCom = new ArrayList<>(); + HashMap archivesCom = JSON.parseObject(baseParam.getSocialPaymentComString(), new HashMap().getClass()); + archivesCom.forEach((k, v) -> { + BigDecimal result = new BigDecimal(v); + socialCom.add(result); + }); + insuranceAccountDetailPO.setSocialComJson(baseParam.getSocialPaymentComString()); + BigDecimal socialComSum = new BigDecimal("0"); + for (BigDecimal bigDecimal : socialCom) { + socialComSum = socialComSum.add(bigDecimal); + } + insuranceAccountDetailPO.setSocialComSum(socialComSum.toPlainString()); + } + } + + public void accountEndowmentInsuranceByData(InsuranceAccountDetailPO insuranceAccountDetailPO, SupplementAccountBaseParam baseParam, List ids) { + //社保个人 + if (StringUtils.isNotBlank(baseParam.getSocialPaymentPerString())) { + List socialPer = new ArrayList<>(); + HashMap archivesPerson = JSON.parseObject(baseParam.getSocialPaymentPerString(), new HashMap().getClass()); + HashMap socialPerson = new HashMap<>(); + archivesPerson.forEach((k, v) -> { + if (ids.contains(Long.valueOf(k))) { + socialPerson.put(k, v); + BigDecimal result = new BigDecimal(v); + socialPer.add(result); + } + + }); + insuranceAccountDetailPO.setSocialPerJson(JSON.toJSONString(socialPerson)); + BigDecimal socialPerSum = new BigDecimal("0"); + for (BigDecimal bigDecimal : socialPer) { + socialPerSum = socialPerSum.add(bigDecimal); + } + insuranceAccountDetailPO.setSocialPerSum(socialPerSum.toPlainString()); + } + //社保单位 + if (StringUtils.isNotBlank(baseParam.getSocialPaymentComString())) { + List socialCom = new ArrayList<>(); + HashMap archivesCom = JSON.parseObject(baseParam.getSocialPaymentComString(), new HashMap().getClass()); + HashMap socialComMap = new HashMap<>(); + archivesCom.forEach((k, v) -> { + if (ids.contains(Long.valueOf(k))) { + socialComMap.put(k, v); + BigDecimal result = new BigDecimal(v); + socialCom.add(result); + } + }); + insuranceAccountDetailPO.setSocialComJson(JSON.toJSONString(socialComMap)); + BigDecimal socialComSum = new BigDecimal("0"); + for (BigDecimal bigDecimal : socialCom) { + socialComSum = socialComSum.add(bigDecimal); + } + insuranceAccountDetailPO.setSocialComSum(socialComSum.toPlainString()); + } + } +} diff --git a/src/com/engine/salary/biz/SIArchivesBiz.java b/src/com/engine/salary/biz/SIArchivesBiz.java new file mode 100644 index 000000000..0bf32a63f --- /dev/null +++ b/src/com/engine/salary/biz/SIArchivesBiz.java @@ -0,0 +1,2653 @@ +package com.engine.salary.biz; + +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.TypeReference; +import com.api.browser.bean.SearchConditionGroup; +import com.api.browser.bean.SearchConditionItem; +import com.api.browser.bean.SearchConditionOption; +import com.api.browser.util.ConditionFactory; +import com.api.browser.util.ConditionType; +import com.cloudstore.eccom.pc.table.WeaTable; +import com.cloudstore.eccom.pc.table.WeaTableCheckboxpopedom; +import com.cloudstore.eccom.pc.table.WeaTableColumn; +import com.cloudstore.eccom.result.WeaResultMsg; +import com.engine.common.util.ServiceUtil; +import com.engine.salary.common.SalaryContext; +import com.engine.salary.constant.SalaryDefaultTenantConstant; +import com.engine.salary.encrypt.EncryptUtil; +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.siarchives.bo.InsuranceArchivesBO; +import com.engine.salary.entity.siarchives.dto.*; +import com.engine.salary.entity.siarchives.param.*; +import com.engine.salary.entity.siarchives.po.*; +import com.engine.salary.entity.sicategory.po.ICategoryPO; +import com.engine.salary.entity.sischeme.po.InsuranceSchemeDetailPO; +import com.engine.salary.entity.sischeme.po.InsuranceSchemePO; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import com.engine.salary.enums.UserStatusEnum; +import com.engine.salary.enums.datacollection.DataCollectionEmployeeTypeEnum; +import com.engine.salary.enums.siaccount.EmployeeStatusEnum; +import com.engine.salary.enums.sicategory.*; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.mapper.siarchives.*; +import com.engine.salary.mapper.sicategory.ICategoryMapper; +import com.engine.salary.mapper.sischeme.InsuranceSchemeDetailMapper; +import com.engine.salary.mapper.sischeme.InsuranceSchemeMapper; +import com.engine.salary.mapper.taxagent.TaxAgentMapper; +import com.engine.salary.service.SalaryEmployeeService; +import com.engine.salary.service.impl.SalaryEmployeeServiceImpl; +import com.engine.salary.sys.entity.po.SalarySysConfPO; +import com.engine.salary.sys.enums.OpenEnum; +import com.engine.salary.sys.service.SalarySysConfService; +import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl; +import com.engine.salary.util.SalaryAssert; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.SalaryFormItemUtil; +import com.engine.salary.util.*; +import com.engine.salary.util.db.MapperProxyFactory; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.util.page.SalaryPageUtil; +import com.engine.salary.wrapper.TaxAgentWrapper; +import com.google.common.collect.Lists; +import com.engine.salary.util.db.IdGenerator; +import lombok.Data; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang.StringUtils; +import org.apache.ibatis.session.SqlSession; +import org.springframework.beans.BeanUtils; +import org.springframework.util.StopWatch; +import weaver.conn.mybatis.MyBatisFactory; +import weaver.general.Util; +import weaver.hrm.User; + +import java.math.BigDecimal; +import java.util.*; +import java.util.function.Function; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import java.util.stream.Collectors; + +import static com.engine.salary.sys.constant.SalarySysConstant.WEL_BASE_AUTO_ADJUST; +import static com.engine.salary.sys.constant.SalarySysConstant.WEL_BASE_DIFF_BY_PER_AND_COM; + + +/** + * @Author weaver_cl + * @Description: + * @Date 2022/3/12 + * @Version V1.0 + **/ +@Data +@Slf4j +public class SIArchivesBiz { + + Boolean needAuth; + Collection taxAgentPOS; + + private EncryptUtil encryptUtil = new EncryptUtil(); + + private TaxAgentMapper getTaxAgentMapper() { + return MapperProxyFactory.getProxy(TaxAgentMapper.class); + } + + private InsuranceBaseInfoMapper getInsuranceBaseInfoMapper() { + return MapperProxyFactory.getProxy(InsuranceBaseInfoMapper.class); + } + + private InsuranceSchemeDetailMapper getInsuranceSchemeDetailMapper() { + return MapperProxyFactory.getProxy(InsuranceSchemeDetailMapper.class); + } + + private SocialSchemeMapper getSocialSchemeMapper() { + return MapperProxyFactory.getProxy(SocialSchemeMapper.class); + } + + private FundSchemeMapper getFundSchemeMapper() { + return MapperProxyFactory.getProxy(FundSchemeMapper.class); + } + + private OtherSchemeMapper getOtherSchemeMapper() { + return MapperProxyFactory.getProxy(OtherSchemeMapper.class); + } + + private TaxAgentWrapper getTaxAgentWrapper(User user) { + return ServiceUtil.getService(TaxAgentWrapper.class, user); + } + + private SalaryEmployeeService getSalaryEmployeeService(User user) { + return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user); + } + + private SalarySysConfService getSalarySysConfService(User user) { + return ServiceUtil.getService(SalarySysConfServiceImpl.class, user); + } + + /** + * @param welfareType + * @param employeeId + * @param operateId + * @param user + * @return + */ + public Map getBaseForm(WelfareTypeEnum welfareType, Long employeeId, Long operateId, User user, Long paymentOrganization) { + Map data = new HashMap<>(16); + SalaryAssert.notNull(employeeId, "员工id不可为空"); + List employeeByIds = getSalaryEmployeeService(user).getEmployeeByIdsAll(Collections.singletonList(employeeId)); + SalaryAssert.notEmpty(employeeByIds, "员工信息不存在"); + DataCollectionEmployee item = employeeByIds.get(0); + + + if (welfareType == null) { + //基础信息表单 + InsuranceArchivesBaseDTO insuranceArchivesBaseDTO = InsuranceArchivesBaseDTO.builder().department(item.getDepartmentName()) + .hiredate(item.getCompanystartdate()) + .position(item.getJobtitleName()) + .username(item.getUsername()) + .telephone(item.getMobile()) + .dimissionDate(item.getDismissdate()) + .build(); + +// if (item.getStatus() == UserStatusEnum.unavailable) { +// InsuranceArchivesListParam insuranceArchivesListParam = new InsuranceArchivesListParam(); +// insuranceArchivesListParam.setEmployeeIds(Collections.singletonList(employeeId)); +// List insuranceArchivesEmployeePOS = siArchivesSocialMapper.queryEmployeeList(insuranceArchivesListParam, tenantKey); +// if (CollectionUtils.isNotEmpty(insuranceArchivesEmployeePOS)) { +// insuranceArchivesBaseDTO.setDimissionDate(SalaryDateUtil.getFormatLocalDate(insuranceArchivesEmployeePOS.get(0).getDimissionDate())); +// } +// } + + //WeaForm weaForm = SalaryFormatUtil.getInstance().buildForm(InsuranceArchivesBaseDTO.class, insuranceArchivesBaseDTO); + // weaForm.getGroups().add(new WeaFormGroup("g1", "员工信息")); + // weaForm.getLayout().forEach(items -> items.forEach(e -> e.setGroupId("g1"))); + data.put("data", insuranceArchivesBaseDTO); + return data; + } + + SISchemeBiz siSchemeBiz = new SISchemeBiz(); + List list = siSchemeBiz.listAll(); + // 过滤可见性范围 + list = filterList(list); + List selectItems = new ArrayList<>(); + List addGroups = new ArrayList<>(); + List paymentOptions = paymentOrganizationOptions(); + List underTakeOptions = Arrays.stream(UndertakerEnum.values()).map(e -> new SearchConditionOption(e.getValue().toString(), e.getDefaultLabel())).collect(Collectors.toList()); + + + //返回数据 + switch (welfareType) { + case SOCIAL_SECURITY: + InsuranceArchivesSocialSchemeDTO insuranceArchivesSocialSchemeDTO = buildSocialForm(employeeId, operateId, paymentOrganization); + List socialList = list.stream().filter(e -> Objects.equals(e.getWelfareType(), WelfareTypeEnum.SOCIAL_SECURITY.getValue())).collect(Collectors.toList()); + List socialOptions = new ArrayList<>(); + socialList.forEach(social -> { + socialOptions.add(new SearchConditionOption(Util.null2String(social.getId()), social.getSchemeName())); + }); + SearchConditionItem socialName = SalaryFormItemUtil.selectItem(user, socialOptions, 2, 12, 6, false, "社保方案名称", "socialSchemeId"); + SearchConditionItem organizationName = SalaryFormItemUtil.selectItem(user, paymentOptions, 2, 12, 6, false, "社保缴纳组织", "paymentOrganization"); + SearchConditionItem underTakeName = SalaryFormItemUtil.selectItem(user, underTakeOptions, 2, 12, 6, false, "社保个人实际承担方", "underTake"); + + selectItems.add(socialName); + selectItems.add(organizationName); + selectItems.add(underTakeName); + + addGroups.add(new SearchConditionGroup("社保基础信息", true, selectItems)); + data.put("data", insuranceArchivesSocialSchemeDTO); + data.put("items", addGroups); + break; + case ACCUMULATION_FUND: + InsuranceArchivesFundSchemeDTO insuranceArchivesFundSchemeDTO = buildFundForm(employeeId, operateId, paymentOrganization); + List fundList = list.stream().filter(e -> Objects.equals(e.getWelfareType(), WelfareTypeEnum.ACCUMULATION_FUND.getValue())).collect(Collectors.toList()); + List fundOptions = new ArrayList<>(); + fundList.forEach(social -> { + fundOptions.add(new SearchConditionOption(Util.null2String(social.getId()), social.getSchemeName())); + }); + SearchConditionItem fundName = SalaryFormItemUtil.selectItem(user, fundOptions, 2, 12, 6, false, "公积金方案名称", "fundSchemeId"); + SearchConditionItem organizationFundName = SalaryFormItemUtil.selectItem(user, paymentOptions, 2, 12, 6, false, "公积金缴纳组织", "paymentOrganization"); + SearchConditionItem underTakeFundName = SalaryFormItemUtil.selectItem(user, underTakeOptions, 2, 12, 6, false, "公积金个人实际承担方", "underTake"); + + selectItems.add(fundName); + selectItems.add(organizationFundName); + selectItems.add(underTakeFundName); + addGroups.add(new SearchConditionGroup("公积金基础信息", true, selectItems)); + data.put("data", insuranceArchivesFundSchemeDTO); + data.put("items", addGroups); + break; + case OTHER: + InsuranceArchivesOtherSchemeDTO insuranceArchivesOtherSchemeDTO = buildOtherForm(employeeId, operateId, paymentOrganization); + List otherList = list.stream().filter(e -> Objects.equals(e.getWelfareType(), WelfareTypeEnum.OTHER.getValue())).collect(Collectors.toList()); + List otherOptions = new ArrayList<>(); + otherList.forEach(social -> { + otherOptions.add(new SearchConditionOption(Util.null2String(social.getId()), social.getSchemeName())); + }); + SearchConditionItem otherName = SalaryFormItemUtil.selectItem(user, otherOptions, 2, 12, 6, false, "其它福利名称", "otherSchemeId"); + SearchConditionItem organizationOtherName = SalaryFormItemUtil.selectItem(user, paymentOptions, 2, 12, 6, false, "其它福利缴纳组织", "paymentOrganization"); + SearchConditionItem underTakeOtherName = SalaryFormItemUtil.selectItem(user, underTakeOptions, 2, 12, 6, false, "其它福利个人实际承担方", "underTake"); + + selectItems.add(otherName); + selectItems.add(organizationOtherName); + selectItems.add(underTakeOtherName); + addGroups.add(new SearchConditionGroup("其它福利基础信息", true, selectItems)); + data.put("data", insuranceArchivesOtherSchemeDTO); + data.put("items", addGroups); + break; + default: + } + return data; + } + + /*** + * @description 过滤没有权限访问的 + * @return List + * @author Harryxzy + * @date 2022/9/19 18:32 + */ + List filterList(List list){ + List ids = taxAgentPOS.stream().map(i -> String.valueOf(i.getId())).collect(Collectors.toList()); + List result = list.stream().filter(item -> { + boolean flag = true; + if (item.getSharedType()!= null && item.getSharedType().equals("1")) { + flag = false; + String taxAgentIds = item.getTaxAgentIds(); + if(StringUtils.isNotBlank(taxAgentIds)){ + String splitFlag = ","; + String[] split = taxAgentIds.split(splitFlag); + for (int i = 0; i < split.length; i++) { + if (ids.contains(split[i])) { + flag = true; + } + } + } + } + return flag; + }).collect(Collectors.toList()); + return result; + } + + /** + * 获取详细表单 + * + * @param user + * @param welfareType + * @param employeeId + * @param operateId + * @param schemeId + * @return + */ + public Map getPaymentForm(User user, WelfareTypeEnum welfareType, Long employeeId, long operateId, Long schemeId, Long paymentOrganization) { + Map data = new HashMap<>(16); + //判断是否要区分个人和单位福利基数 + SalarySysConfPO welBaseDiff = getSalarySysConfService(user).getOneByCode(WEL_BASE_DIFF_BY_PER_AND_COM); + boolean welBaseDiffSign = welBaseDiff != null && welBaseDiff.getConfValue().equals(OpenEnum.OPEN.getValue()); + //判断是否要自动调整基数 + SalarySysConfPO welBaseAutoAdjust = getSalarySysConfService(user).getOneByCode(WEL_BASE_AUTO_ADJUST); + boolean welBaseAutoAdjustSign = welBaseAutoAdjust != null && welBaseAutoAdjust.getConfValue().equals(OpenEnum.OPEN.getValue()); + + switch (welfareType) { + case SOCIAL_SECURITY: + data = buildSocialPaymentForm(user, employeeId, schemeId, operateId, welfareType.getValue(), paymentOrganization, welBaseDiffSign, welBaseAutoAdjustSign); + break; + case ACCUMULATION_FUND: + data = buildFundPaymentForm(user, employeeId, schemeId, operateId, welfareType.getValue(), paymentOrganization, welBaseDiffSign, welBaseAutoAdjustSign); + break; + case OTHER: + data = buildOtherPaymentForm(user, employeeId, schemeId, operateId, welfareType.getValue(), paymentOrganization, welBaseDiffSign, welBaseAutoAdjustSign); + break; + default: + } + return data; + } + + /** + * 其他payForm + * + * @param employeeId + * @param schemeId + * @param operateId + * @return + */ + public Map buildOtherPaymentForm(User user, Long employeeId, Long schemeId, long operateId, Integer welfareType, Long paymentOrganization, boolean welBaseDiffSign, boolean welBaseAutoAdjustSign) { + Map dataMap = new HashMap<>(); + InsuranceArchivesOtherSchemeDTO data = buildOtherForm(employeeId, operateId, paymentOrganization); + Map insuranceValueMap = new HashMap<>(); + Map insuranceComValueMap = new HashMap<>(); + if (data != null) { + insuranceValueMap = StrUtil.isNotBlank(data.getOtherPaymentBaseString()) + ? JSONObject.parseObject(data.getOtherPaymentBaseString(), new TypeReference>() {}) : new HashMap<>(); + if (welBaseDiffSign) { + insuranceComValueMap = StrUtil.isNotBlank(data.getOtherPaymentComBaseString()) + ? JSONObject.parseObject(data.getOtherPaymentComBaseString(), new TypeReference>() {}) : new HashMap<>(); + } + } + List addGroups = new ArrayList<>(); + List inputItems = buildPaymentBase(user, schemeId, welfareType, welBaseDiffSign); + //如果查询结果中存在 方案中缺失福利险种的值,设置初始值 + for (SearchConditionItem item : inputItems) { + String insuranceId = item.getDomkey().length > 0 ? item.getDomkey()[0] : null; + if (StrUtil.isNotBlank(insuranceId) && insuranceValueMap.get(insuranceId) == null) { + String basicValue = welBaseAutoAdjustSign ? ("0.000".equals(item.getMin()) ? "0" : item.getMin()) : "0"; + insuranceValueMap.put(insuranceId, basicValue); + } + } + dataMap.put("data", insuranceValueMap); + addGroups.add(new SearchConditionGroup("其它福利缴纳基数", true, inputItems)); + dataMap.put("items", addGroups); + if (welBaseDiffSign) { + List addComGroups = new ArrayList<>(); + List inputComItems = buildPaymentComBase(user, schemeId, welfareType); + addComGroups.add(new SearchConditionGroup("其它福利缴纳基数", true, inputComItems)); + dataMap.put("comItems", addComGroups); + + for (SearchConditionItem item : inputComItems) { + String insuranceId = item.getDomkey().length > 0 ? item.getDomkey()[0] : null; + if (StrUtil.isNotBlank(insuranceId) && insuranceComValueMap.get(insuranceId) == null) { + String basicValue = welBaseAutoAdjustSign ? ("0.000".equals(item.getMin()) ? "0" : item.getMin()) : "0"; + insuranceComValueMap.put(insuranceId, basicValue); + } + } + dataMap.put("comData", insuranceComValueMap); + } + return dataMap; + } + + /** + * 公积金payForm + * + * @param employeeId + * @param schemeId + * @param operateId + * @return + */ + public Map buildFundPaymentForm(User user, Long employeeId, Long schemeId, long operateId, Integer welfareType, Long paymentOrganization, boolean welBaseDiffSign, boolean welBaseAutoAdjustSign) { + + Map dataMap = new HashMap<>(); + InsuranceArchivesFundSchemeDTO data = buildFundForm(employeeId, operateId, paymentOrganization); + Map insuranceValueMap = new HashMap<>(); + Map insuranceComValueMap = new HashMap<>(); + if (data != null) { + insuranceValueMap = StrUtil.isNotBlank(data.getFundPaymentBaseString()) + ? JSONObject.parseObject(data.getFundPaymentBaseString(), new TypeReference>() {}) : new HashMap<>(); + if (welBaseDiffSign) { + insuranceComValueMap = StrUtil.isNotBlank(data.getFundPaymentComBaseString()) + ? JSONObject.parseObject(data.getFundPaymentComBaseString(), new TypeReference>() {}) : new HashMap<>(); + } + } + + List addGroups = new ArrayList<>(); + List inputItems = buildPaymentBase(user, schemeId, welfareType, welBaseDiffSign); + //如果查询结果中存在 方案中缺失福利险种的值,设置初始值 + for (SearchConditionItem item : inputItems) { + String insuranceId = item.getDomkey().length > 0 ? item.getDomkey()[0] : null; + if (StrUtil.isNotBlank(insuranceId) && insuranceValueMap.get(insuranceId) == null) { + String basicValue = welBaseAutoAdjustSign ? ("0.000".equals(item.getMin()) ? "0" : item.getMin()) : "0"; + insuranceValueMap.put(insuranceId, basicValue); + } + } + dataMap.put("data", insuranceValueMap); + addGroups.add(new SearchConditionGroup("公积金缴纳基数", true, inputItems)); + dataMap.put("items", addGroups); + if (welBaseDiffSign) { + List addComGroups = new ArrayList<>(); + List inputComItems = buildPaymentComBase(user, schemeId, welfareType); + addComGroups.add(new SearchConditionGroup("公积金缴纳基数", true, inputComItems)); + dataMap.put("comItems", addComGroups); + + for (SearchConditionItem item : inputComItems) { + String insuranceId = item.getDomkey().length > 0 ? item.getDomkey()[0] : null; + if (StrUtil.isNotBlank(insuranceId) && insuranceComValueMap.get(insuranceId) == null) { + String basicValue = welBaseAutoAdjustSign ? ("0.000".equals(item.getMin()) ? "0" : item.getMin()) : "0"; + insuranceComValueMap.put(insuranceId, basicValue); + } + } + dataMap.put("comData", insuranceComValueMap); + } + return dataMap; + } + + /** + * 社保payForm + * + * @param employeeId + * @param schemeId + * @param operateId + * @return + */ + public Map buildSocialPaymentForm(User user, Long employeeId, Long schemeId, long operateId, Integer welfareType, Long paymentOrganization, boolean welBaseDiffSign, boolean welBaseAutoAdjustSign) { + Map dataMap = new HashMap<>(); + InsuranceArchivesSocialSchemeDTO data = buildSocialForm(employeeId, operateId, paymentOrganization); + Map insuranceValueMap = new HashMap<>(); + Map insuranceComValueMap = new HashMap<>(); + if (data != null) { + insuranceValueMap = StrUtil.isNotBlank(data.getSchemePaymentBaseString()) + ? JSONObject.parseObject(data.getSchemePaymentBaseString(), new TypeReference>() {}) : new HashMap<>(); + if (welBaseDiffSign) { + insuranceComValueMap = StrUtil.isNotBlank(data.getSchemePaymentComBaseString()) + ? JSONObject.parseObject(data.getSchemePaymentComBaseString(), new TypeReference>() {}) : new HashMap<>(); + } + } + + List addGroups = new ArrayList<>(); + List inputItems = buildPaymentBase(user, schemeId, welfareType, welBaseDiffSign); + //如果查询结果中存在 方案中缺失福利险种的值,设置初始值 + for (SearchConditionItem item : inputItems) { + String insuranceId = item.getDomkey().length > 0 ? item.getDomkey()[0] : null; + if (StrUtil.isNotBlank(insuranceId) && insuranceValueMap.get(insuranceId) == null) { + String basicValue = welBaseAutoAdjustSign ? ("0.000".equals(item.getMin()) ? "0" : item.getMin()) : "0"; + insuranceValueMap.put(insuranceId, basicValue); + } + } + dataMap.put("data", insuranceValueMap); + addGroups.add(new SearchConditionGroup("社保缴纳基数", true, inputItems)); + dataMap.put("items", addGroups); + if (welBaseDiffSign) { + List addComGroups = new ArrayList<>(); + List inputComItems = buildPaymentComBase(user, schemeId, welfareType); + addComGroups.add(new SearchConditionGroup("社保缴纳基数", true, inputComItems)); + dataMap.put("comItems", addComGroups); + + for (SearchConditionItem item : inputComItems) { + String insuranceId = item.getDomkey().length > 0 ? item.getDomkey()[0] : null; + if (StrUtil.isNotBlank(insuranceId) && insuranceComValueMap.get(insuranceId) == null) { + String basicValue = welBaseAutoAdjustSign ? ("0.000".equals(item.getMin()) ? "0" : item.getMin()) : "0"; + insuranceComValueMap.put(insuranceId, basicValue); + } + } + dataMap.put("comData", insuranceComValueMap); + } + return dataMap; + + } + + /** + * 构造payment(items) + * + * @param schemeId + * @return + */ + public List buildPaymentBase(User user, Long schemeId, Integer welfareType, boolean welBaseDiffSign) { + List inputItems = new ArrayList<>(); + if (schemeId == null) { + return new ArrayList<>(); + } + List list = queryListByPrimaryIdIsPayment(schemeId, welfareType).stream() + .filter(f -> f.getPaymentScope().equals(PaymentScopeEnum.SCOPE_PERSON.getValue())).collect(Collectors.toList()); + if (!welBaseDiffSign) { + List perInsuranceIdList = list.stream().map(InsuranceSchemeDetailPO::getInsuranceId).collect(Collectors.toList()); + List moreComList = queryListByPrimaryIdIsPayment(schemeId, welfareType).stream() + .filter(f -> f.getPaymentScope().equals(PaymentScopeEnum.SCOPE_COMPANY.getValue()) && !perInsuranceIdList.contains(f.getInsuranceId())).collect(Collectors.toList()); + if (moreComList.size() > 0) { + list.addAll(moreComList); + } + } + + SICategoryBiz siCategoryBiz = new SICategoryBiz(); + list.forEach(insuranceSchemeDetail -> { + ICategoryPO iCategoryPO = siCategoryBiz.getByID(insuranceSchemeDetail.getInsuranceId()); + if (iCategoryPO != null) { +// inputItems.add(SalaryFormItemUtil.inputNumberItem(user, "precision:2", 2, 12, 2, iCategoryPO.getInsuranceName(), String.valueOf(insuranceSchemeDetail.getInsuranceId()))); + inputItems.add(SalaryFormItemUtil.inputNumberItemWithMaxAndMin(user, "precision:2", 2, 12, 2, iCategoryPO.getInsuranceName(), String.valueOf(insuranceSchemeDetail.getInsuranceId()) + , insuranceSchemeDetail.getUpperLimit(), insuranceSchemeDetail.getLowerLimit())); + } + }); + return inputItems; + } + + public List buildPaymentComBase(User user, Long schemeId, Integer welfareType) { + List inputItems = new ArrayList<>(); + if (schemeId == null) { + return new ArrayList<>(); + } + List list = queryListByPrimaryIdIsPayment(schemeId, welfareType).stream() + .filter(f -> f.getPaymentScope().equals(PaymentScopeEnum.SCOPE_COMPANY.getValue())).collect(Collectors.toList()); + SICategoryBiz siCategoryBiz = new SICategoryBiz(); + list.forEach(insuranceSchemeDetail -> { + ICategoryPO iCategoryPO = siCategoryBiz.getByID(insuranceSchemeDetail.getInsuranceId()); + if (iCategoryPO != null) { +// inputItems.add(SalaryFormItemUtil.inputNumberItem(user, "precision:2", 2, 12, 2, iCategoryPO.getInsuranceName(), String.valueOf(insuranceSchemeDetail.getInsuranceId()))); + inputItems.add(SalaryFormItemUtil.inputNumberItemWithMaxAndMin(user, "precision:2", 2, 12, 2, iCategoryPO.getInsuranceName(), String.valueOf(insuranceSchemeDetail.getInsuranceId()) + , insuranceSchemeDetail.getUpperLimit(), insuranceSchemeDetail.getLowerLimit())); + } + }); + return inputItems; + } + + /** + * 获取方案明细 + * + * @param schemeId + * @return + */ + public List queryListByPrimaryIdIsPayment(Long schemeId, Integer welfareType) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + InsuranceSchemeDetailMapper insuranceSchemeDetailMapper = sqlSession.getMapper(InsuranceSchemeDetailMapper.class); + List insuranceSchemeDetailPOS = insuranceSchemeDetailMapper.queryListByPrimaryIdIsPayment(schemeId, IsPaymentEnum.YES.getValue(), welfareType); + encryptUtil.decryptList(insuranceSchemeDetailPOS, InsuranceSchemeDetailPO.class); + return insuranceSchemeDetailPOS; + } finally { + sqlSession.close(); + } + } + + + /** + * 社保缴纳组织 + * + * @return + */ + public List paymentOrganizationOptions() { + Collection list = taxAgentPOS; + if (CollectionUtils.isEmpty(list)) { + return new ArrayList<>(); + } + return list + .stream() + .map(item -> new SearchConditionOption(String.valueOf(item.getId()), item.getName())).collect(Collectors.toList()); + } + + /** + * 其它基础表单 + * + * @param employeeId + * @param operateId + * @return + */ + public InsuranceArchivesOtherSchemeDTO buildOtherForm(Long employeeId, Long operateId, Long paymentOrganization) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + OtherSchemeMapper otherSchemeMapper = sqlSession.getMapper(OtherSchemeMapper.class); +// List otherList = otherSchemeMapper.getOtherByEmployeeId(Collections.singletonList(employeeId)); + List otherList = otherSchemeMapper.getOtherByEmployeeIdAndPayOrg(InsuranceArchivesEmployeePO.builder() + .employeeId(employeeId) + .paymentOrganization(paymentOrganization) + .build()); + encryptUtil.decryptList(otherList, InsuranceArchivesOtherSchemePO.class); + InsuranceArchivesOtherSchemePO insuranceArchivesOtherSchemePO = otherList.size() != 0 ? otherList.get(0) : null; + InsuranceArchivesOtherSchemeDTO data = InsuranceArchivesBO.convertOtherPOtoDTO(insuranceArchivesOtherSchemePO, employeeId); + if (insuranceArchivesOtherSchemePO == null) { + data.setEmployeeId(employeeId); + data.setUnderTake(UndertakerEnum.SCOPE_PERSON.getValue().toString()); + } + return data; + } finally { + sqlSession.close(); + } + + } + + /** + * 公积金基础表单 + * + * @param employeeId + * @param operateId + * @return + */ + public InsuranceArchivesFundSchemeDTO buildFundForm(Long employeeId, Long operateId, Long paymentOrganization) { + + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + FundSchemeMapper fundSchemeMapper = sqlSession.getMapper(FundSchemeMapper.class); +// List fundList = fundSchemeMapper.getFundByEmployeeId(Collections.singletonList(employeeId)); + List fundList = fundSchemeMapper.getFundByEmployeeIdAndPayOrg(InsuranceArchivesEmployeePO.builder() + .employeeId(employeeId) + .paymentOrganization(paymentOrganization) + .build()); + encryptUtil.decryptList(fundList, InsuranceArchivesFundSchemePO.class); + InsuranceArchivesFundSchemePO insuranceArchivesFundSchemePO = fundList.size() != 0 ? fundList.get(0) : null; + InsuranceArchivesFundSchemeDTO data = InsuranceArchivesBO.convertFundPOtoDTO(insuranceArchivesFundSchemePO, employeeId); + if (insuranceArchivesFundSchemePO == null) { + data.setEmployeeId(employeeId); + data.setUnderTake(UndertakerEnum.SCOPE_PERSON.getValue().toString()); + } + return data; + } finally { + sqlSession.close(); + } + + } + + /** + * 社保基础表单 + * + * @param employeeId + * @param operateId + * @return + */ + public InsuranceArchivesSocialSchemeDTO buildSocialForm(Long employeeId, Long operateId, Long paymentOrganization) { + InsuranceArchivesSocialSchemePO insuranceArchivesSocialSchemePO = getSocialByEmployeeId(employeeId, paymentOrganization); + InsuranceArchivesSocialSchemeDTO data = InsuranceArchivesBO.convertSocialPOtoDTO(insuranceArchivesSocialSchemePO, employeeId); + if (insuranceArchivesSocialSchemePO == null) { + data.setEmployeeId(employeeId); + data.setUnderTake(UndertakerEnum.SCOPE_PERSON.getValue().toString()); + } + return data; + } + + + /** + * 获取社保档案表 + * + * @param employeeId + * @return + */ + public InsuranceArchivesSocialSchemePO getSocialByEmployeeId(Long employeeId, Long paymentOrganization) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SocialSchemeMapper socialSchemeMapper = sqlSession.getMapper(SocialSchemeMapper.class); + List socialList = socialSchemeMapper.getSocialByEmployeeIdAndPayOrg(InsuranceArchivesEmployeePO.builder() + .employeeId(employeeId) + .paymentOrganization(paymentOrganization) + .build()); + encryptUtil.decryptList(socialList, InsuranceArchivesSocialSchemePO.class); + return socialList.size() != 0 ? socialList.get(0) : null; + } finally { + sqlSession.close(); + } + } + + public List getSocialByEmployeeIds(List employeeIds) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SocialSchemeMapper socialSchemeMapper = sqlSession.getMapper(SocialSchemeMapper.class); + List> partition = Lists.partition(employeeIds, 1000); + List allList = new ArrayList<>(); + for (List longs : partition) { + List socialList = socialSchemeMapper.getSocialByEmployeeId(longs); + allList.addAll(socialList); + } + return allList; + } finally { + sqlSession.close(); + } + } + + + public List getFundByEmployeeIds(List employeeIds) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + FundSchemeMapper fundSchemeMapper = sqlSession.getMapper(FundSchemeMapper.class); + List> partition = Lists.partition(employeeIds, 1000); + List allList = new ArrayList<>(); + for (List longs : partition) { + List fundList = fundSchemeMapper.getFundByEmployeeId(longs); + allList.addAll(fundList); + } + return allList; + } finally { + sqlSession.close(); + } + } + + public List getOtherByEmployeeIds(List employeeIds) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + OtherSchemeMapper otherSchemeMapper = sqlSession.getMapper(OtherSchemeMapper.class); + List> partition = Lists.partition(employeeIds, 1000); + List allList = new ArrayList<>(); + for (List longs : partition) { + List otherList = otherSchemeMapper.getOtherByEmployeeId(longs); + allList.addAll(otherList); + } + return allList; + } finally { + sqlSession.close(); + } + } + + /** + * 根据人员id和个税扣缴人id获取记录 + */ + public List getSocialByEmployeeIdAndPayOrg(List insuranceArchivesEmployeePOS) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SocialSchemeMapper socialSchemeMapper = sqlSession.getMapper(SocialSchemeMapper.class); + List allList = new ArrayList<>(); + for (InsuranceArchivesEmployeePO po : insuranceArchivesEmployeePOS) { + List socialList = socialSchemeMapper.getSocialByEmployeeIdAndPayOrg(po); + if (socialList.size() > 0) { + allList.add(socialList.get(0)); + } + } + return allList; + } finally { + sqlSession.close(); + } + } + + + public List getFundByEmployeeIdAndPayOrg(List insuranceArchivesEmployeePOS) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + FundSchemeMapper fundSchemeMapper = sqlSession.getMapper(FundSchemeMapper.class); + List allList = new ArrayList<>(); + for (InsuranceArchivesEmployeePO po : insuranceArchivesEmployeePOS) { + List fundList = fundSchemeMapper.getFundByEmployeeIdAndPayOrg(po); + if (fundList.size() > 0) { + allList.add(fundList.get(0)); + } + } + return allList; + } finally { + sqlSession.close(); + } + } + + public List getOtherByEmployeeIdAndPayOrg(List insuranceArchivesEmployeePOS) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + OtherSchemeMapper otherSchemeMapper = sqlSession.getMapper(OtherSchemeMapper.class); + List allList = new ArrayList<>(); + for (InsuranceArchivesEmployeePO po : insuranceArchivesEmployeePOS) { + List otherList = otherSchemeMapper.getOtherByEmployeeIdAndPayOrg(po); + if (otherList.size() > 0) { + allList.add(otherList.get(0)); + } + } + return allList; + } finally { + sqlSession.close(); + } + } + + + /** + * 新增 + * + * @param param + * @param user + */ + public void insert(InsuranceArchivesSaveParam param, User user) { + SalaryAssert.notNull(param.getWelfareType(), "福利类型为空"); + //判断是否要区分个人和单位福利基数 + SalarySysConfPO welBaseDiff = getSalarySysConfService(user).getOneByCode(WEL_BASE_DIFF_BY_PER_AND_COM); + boolean welBaseDiffSign = welBaseDiff != null && welBaseDiff.getConfValue().equals(OpenEnum.OPEN.getValue()); + switch (param.getWelfareType()) { + case SOCIAL_SECURITY: + socialSave(param, user, welBaseDiffSign); + break; + case ACCUMULATION_FUND: + fundSave(param, user, welBaseDiffSign); + break; + case OTHER: + otherSave(param, user, welBaseDiffSign); + break; + default: + throw new SalaryRunTimeException("福利类型不存在"); + } + + } + + /** + * @param paramReq + * @param + */ + public void otherSave(InsuranceArchivesSaveParam paramReq, User user, boolean welBaseDiffSign) { + long employeeId = user.getUID(); + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + OtherSchemeMapper otherSchemeMapper = sqlSession.getMapper(OtherSchemeMapper.class); + + InsuranceArchivesOtherSaveParam param = JSONObject.parseObject(paramReq.getBaseForm(), InsuranceArchivesOtherSaveParam.class); + SalaryAssert.notNull("员工id为空", param, param.getEmployeeId()); + + if (StringUtils.isNotBlank(param.getOtherStartTime()) && !SalaryDateUtil.checkYearMonth(param.getOtherStartTime())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(542532, "其他福利起始缴纳时间格式错误,正确格式为YYYY-MM或者yyyy-MM-dd")); + } + if (StringUtils.isNotBlank(param.getOtherEndTime()) && !SalaryDateUtil.checkYearMonth(param.getOtherEndTime())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(542533, "其他福利最后缴纳时间格式错误,正确格式为YYYY-MM或者yyyy-MM-dd")); + } + + List otherIds = new ArrayList(); + otherIds.add(param.getId()); + List oldOtherInfoList = otherSchemeMapper.getOtherById(otherIds); + + //设置福利档案基数调整记录数据 + InsuranceArchivesBaseHistoryDTO adjustInfo = InsuranceArchivesBaseHistoryDTO.builder() + .adjustAfterSchemeId(param.getOtherSchemeId()) + .adjustAfterBaseJson(paramReq.getPaymentForm()) + .adjustAfterComBaseJson(paramReq.getPaymentComForm()) + .welfareType(paramReq.getWelfareType().getValue()) + .employeeId(param.getEmployeeId()) + .paymentOrganization(param.getPaymentOrganization()) + .build(); + + StringBuilder errorMsg = new StringBuilder(""); + if (oldOtherInfoList.size() == 1) { + InsuranceArchivesOtherSchemePO oldOtherInfo = oldOtherInfoList.get(0); + //设置福利档案基数调整记录数据 + encryptUtil.decrypt(oldOtherInfo, InsuranceArchivesOtherSchemePO.class); + adjustInfo.setAdjustBeforeBaseJson(oldOtherInfo.getOtherPaymentBaseString()); + adjustInfo.setAdjustBeforeSchemeId(oldOtherInfo.getOtherSchemeId()); + adjustInfo.setAdjustBeforeComBaseJson(oldOtherInfo.getOtherPaymentComBaseString()); + //新数据 + InsuranceArchivesOtherSchemePO updateOtherInfo = + InsuranceArchivesOtherSchemePO.builder() + .id(oldOtherInfo.getId()) + .otherSchemeId(param.getOtherSchemeId()) + .otherStartTime(StringUtils.isNotBlank(param.getOtherStartTime()) ? param.getOtherStartTime() : null) + .underTake(param.getUnderTake()) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .welfareType(paramReq.getWelfareType().getValue()) + .otherEndTime(StringUtils.isNotBlank(param.getOtherEndTime()) ? param.getOtherEndTime() : null) + .employeeId(param.getEmployeeId()) + .deleteType(DeleteTypeEnum.NOT_DELETED.getValue()) + .updateTime(new Date()) + .nonPayment(param.getNonPayment()) + .creator(employeeId) + .paymentOrganization(param.getPaymentOrganization()) + .otherPaymentBaseString(paramReq.getPaymentForm()) + .build(); + //校验福利基数是否符合上下限要求, + if (!checkWelBaseLimit(updateOtherInfo.getOtherSchemeId(),updateOtherInfo.getOtherPaymentBaseString(), PaymentScopeEnum.SCOPE_PERSON.getValue(), errorMsg)) { + // throw new SalaryRunTimeException("其他福利明细中的基数更新内容不符合相关基数上下限要求,请检查后重试!"); + throw new SalaryRunTimeException("其他福利个人:" + errorMsg.toString()); + } + //需要拆分个人和公司福利基数时 + if (welBaseDiffSign) { + updateOtherInfo.setOtherPaymentComBaseString(paramReq.getPaymentComForm()); + //校验福利基数是否符合上下限要求 + if (!checkWelBaseLimit(updateOtherInfo.getOtherSchemeId(),updateOtherInfo.getOtherPaymentComBaseString(), PaymentScopeEnum.SCOPE_COMPANY.getValue(), errorMsg)) { + // throw new SalaryRunTimeException("其他福利明细中的基数更新内容不符合相关基数上下限要求,请检查后重试!"); + throw new SalaryRunTimeException("其他福利公司:" + errorMsg.toString()); + } + } + encryptUtil.encrypt(updateOtherInfo, InsuranceArchivesOtherSchemePO.class); + otherSchemeMapper.updateById(updateOtherInfo); + //更新base_info表状态 + InsuranceArchivesBaseInfoPO baseInfoPO = getInsuranceBaseInfoMapper().getOneByEmployeeIdAndPayOrg(param.getPaymentOrganization(), param.getEmployeeId()); + if(baseInfoPO != null && baseInfoPO.getEmployeeType() != null && baseInfoPO.getEmployeeType().equals(DataCollectionEmployeeTypeEnum.EXT_EMPLOYEE.getValue())) { + //对于非系统人员,编辑后状态切换为正在缴纳 + baseInfoPO.setRunStatus(EmployeeStatusEnum.PAYING.getValue()); + } + baseInfoPO.setOtherArchivesId(updateOtherInfo.getId()); + getInsuranceBaseInfoMapper().updateById(baseInfoPO); + sqlSession.commit(); + } else { + otherSchemeMapper.deleteByEmployeeIdAndPayOrg(InsuranceArchivesOtherSchemePO.builder() + .employeeId(param.getEmployeeId()) + .paymentOrganization(param.getPaymentOrganization()) + .build()); + //新建社保档案,并关联主表 + InsuranceArchivesOtherSchemePO insertOtherInfo = InsuranceArchivesOtherSchemePO.builder() + .otherSchemeId(param.getOtherSchemeId()) + .otherStartTime(StringUtils.isNotBlank(param.getOtherStartTime()) ? param.getOtherStartTime() : null) + .underTake(param.getUnderTake()) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .welfareType(paramReq.getWelfareType().getValue()) + .otherEndTime(StringUtils.isNotBlank(param.getOtherEndTime()) ? param.getOtherEndTime() : null) + .employeeId(param.getEmployeeId()) + .deleteType(DeleteTypeEnum.NOT_DELETED.getValue()) + .createTime(new Date()) + .updateTime(new Date()) + .nonPayment(param.getNonPayment()) + .creator(employeeId) + .paymentOrganization(param.getPaymentOrganization()) + .otherPaymentBaseString(paramReq.getPaymentForm()) + .build(); + //校验福利基数是否符合上下限要求, + if (!checkWelBaseLimit(insertOtherInfo.getOtherSchemeId(),insertOtherInfo.getOtherPaymentBaseString(), PaymentScopeEnum.SCOPE_PERSON.getValue(), errorMsg)) { + // throw new SalaryRunTimeException("其他福利明细中的基数更新内容不符合相关基数上下限要求,请检查后重试!"); + throw new SalaryRunTimeException("其他福利个人:" + errorMsg.toString()); + } + //需要拆分个人和公司福利基数时 + if (welBaseDiffSign) { + insertOtherInfo.setOtherPaymentComBaseString(paramReq.getPaymentComForm()); + //校验福利基数是否符合上下限要求 + if (!checkWelBaseLimit(insertOtherInfo.getOtherSchemeId(),insertOtherInfo.getOtherPaymentComBaseString(), PaymentScopeEnum.SCOPE_COMPANY.getValue(), errorMsg)) { + // throw new SalaryRunTimeException("其他福利明细中的基数更新内容不符合相关基数上下限要求,请检查后重试!"); + throw new SalaryRunTimeException("其他福利公司:" + errorMsg.toString()); + } + } + encryptUtil.encrypt(insertOtherInfo, InsuranceArchivesOtherSchemePO.class); + otherSchemeMapper.insert(insertOtherInfo); + sqlSession.commit(); + + InsuranceArchivesBaseInfoPO baseInfoPO = getInsuranceBaseInfoMapper().getOneByEmployeeIdAndPayOrg(param.getPaymentOrganization(), param.getEmployeeId()); + if(baseInfoPO != null) { + List otherInfos = otherSchemeMapper.getOtherByEmployeeIdAndPayOrg(InsuranceArchivesEmployeePO.builder() + .employeeId(param.getEmployeeId()) + .paymentOrganization(param.getPaymentOrganization()) + .build()); + baseInfoPO.setOtherArchivesId(otherInfos.get(0).getId()); + //对于非系统人员,编辑后状态切换为正在缴纳 + if (baseInfoPO.getEmployeeType() != null && baseInfoPO.getEmployeeType().equals(DataCollectionEmployeeTypeEnum.EXT_EMPLOYEE.getValue())) { + baseInfoPO.setRunStatus(EmployeeStatusEnum.PAYING.getValue()); + } + getInsuranceBaseInfoMapper().updateById(baseInfoPO); + } else { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "档案不存在!")); + } + } + + //生成福利档案基数调整记录数据 + List adjustHistoryList = createAdjustInfo(adjustInfo, employeeId); + //福利档案基数调整记录数据入库 + batchInsertAdjustHistory(adjustHistoryList, employeeId); + + } finally { + sqlSession.close(); + } + } + + /** + * @param paramReq + * @param + */ + public void fundSave(InsuranceArchivesSaveParam paramReq, User user, boolean welBaseDiffSign) { + long employeeId = user.getUID(); + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + FundSchemeMapper fundSchemeMapper = sqlSession.getMapper(FundSchemeMapper.class); + InsuranceArchivesFundSaveParam param = JSONObject.parseObject(paramReq.getBaseForm(), InsuranceArchivesFundSaveParam.class); + SalaryAssert.notNull("员工id为空", param, param.getEmployeeId()); + + if (StringUtils.isNotBlank(param.getFundStartTime()) && !SalaryDateUtil.checkYearMonth(param.getFundStartTime())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(542530, "公积金起始缴纳时间格式错误,正确格式为YYYY-MM或者yyyy-MM-dd")); + } + if (StringUtils.isNotBlank(param.getFundEndTime()) && !SalaryDateUtil.checkYearMonth(param.getFundEndTime())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(542531, "公积金最后缴纳时间格式错误,正确格式为YYYY-MM或者yyyy-MM-dd")); + } + + List fundIds = new ArrayList(); + fundIds.add(param.getId()); + List oldFundInfoList = fundSchemeMapper.getFundById(fundIds); + + //设置福利档案基数调整记录数据 + InsuranceArchivesBaseHistoryDTO adjustInfo = InsuranceArchivesBaseHistoryDTO.builder() + .adjustAfterSchemeId(param.getFundSchemeId()) + .adjustAfterBaseJson(paramReq.getPaymentForm()) + .adjustAfterComBaseJson(paramReq.getPaymentComForm()) + .welfareType(paramReq.getWelfareType().getValue()) + .employeeId(param.getEmployeeId()) + .paymentOrganization(param.getPaymentOrganization()) + .build(); + + StringBuilder errorMsg = new StringBuilder(""); + if (oldFundInfoList.size() == 1) { + InsuranceArchivesFundSchemePO oldFundInfo = oldFundInfoList.get(0); + //设置福利档案基数调整记录数据 + encryptUtil.decrypt(oldFundInfo, InsuranceArchivesFundSchemePO.class); + adjustInfo.setAdjustBeforeBaseJson(oldFundInfo.getFundPaymentBaseString()); + adjustInfo.setAdjustBeforeSchemeId(oldFundInfo.getFundSchemeId()); + adjustInfo.setAdjustBeforeComBaseJson(oldFundInfo.getFundPaymentComBaseString()); + //新数据 + InsuranceArchivesFundSchemePO updateFundInfo = InsuranceArchivesFundSchemePO.builder() + .id(oldFundInfo.getId()) + .fundSchemeId(param.getFundSchemeId()) + .fundAccount(param.getFundAccount()) + .fundEndTime(StringUtils.isNotBlank(param.getFundEndTime()) ? param.getFundEndTime() : null) + .fundStartTime(StringUtils.isNotBlank(param.getFundStartTime()) ? param.getFundStartTime() : null) + .fundPaymentBaseString(paramReq.getPaymentForm()) + .supplementFundAccount(param.getSupplementFundAccount()) + .creator(employeeId) + .nonPayment(param.getNonPayment()) + .deleteType(DeleteTypeEnum.NOT_DELETED.getValue()) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .underTake(param.getUnderTake()) + .paymentOrganization(param.getPaymentOrganization()) + .updateTime(new Date()) + .welfareType(paramReq.getWelfareType().getValue()) + .employeeId(param.getEmployeeId()) + .build(); + //校验福利基数是否符合上下限要求, + if (!checkWelBaseLimit(updateFundInfo.getFundSchemeId(),updateFundInfo.getFundPaymentBaseString(), PaymentScopeEnum.SCOPE_PERSON.getValue(), errorMsg)) { + // throw new SalaryRunTimeException("公积金福利明细中的基数更新内容不符合相关基数上下限要求,请检查后重试!"); + throw new SalaryRunTimeException("公积金个人:" + errorMsg.toString()); + } + //需要拆分个人和公司福利基数时 + if (welBaseDiffSign) { + updateFundInfo.setFundPaymentComBaseString(paramReq.getPaymentComForm()); + //校验福利基数是否符合上下限要求 + if (!checkWelBaseLimit(updateFundInfo.getFundSchemeId(),updateFundInfo.getFundPaymentComBaseString(), PaymentScopeEnum.SCOPE_COMPANY.getValue(), errorMsg)) { + // throw new SalaryRunTimeException("公积金福利明细中的基数更新内容不符合相关基数上下限要求,请检查后重试!"); + throw new SalaryRunTimeException("公积金公司:" + errorMsg.toString()); + } + } + encryptUtil.encrypt(updateFundInfo, InsuranceArchivesFundSchemePO.class); + fundSchemeMapper.updateById(updateFundInfo); + //更新base_info表状态 + InsuranceArchivesBaseInfoPO baseInfoPO = getInsuranceBaseInfoMapper().getOneByEmployeeIdAndPayOrg(param.getPaymentOrganization(), param.getEmployeeId()); + if(baseInfoPO != null && baseInfoPO.getEmployeeType() != null && baseInfoPO.getEmployeeType().equals(DataCollectionEmployeeTypeEnum.EXT_EMPLOYEE.getValue())) { + //对于非系统人员,编辑后状态切换为正在缴纳 + baseInfoPO.setRunStatus(EmployeeStatusEnum.PAYING.getValue()); + } + baseInfoPO.setFundArchivesId(updateFundInfo.getId()); + getInsuranceBaseInfoMapper().updateById(baseInfoPO); + sqlSession.commit(); + } else { + fundSchemeMapper.deleteByEmployeeIdAndPayOrg(InsuranceArchivesFundSchemePO.builder() + .employeeId(param.getEmployeeId()) + .paymentOrganization(param.getPaymentOrganization()) + .build()); + //新建社保档案,并关联主表 + InsuranceArchivesFundSchemePO insertFundInfo = InsuranceArchivesFundSchemePO.builder() + .fundSchemeId(param.getFundSchemeId()) + .fundAccount(param.getFundAccount()) + .fundEndTime(StringUtils.isNotBlank(param.getFundEndTime()) ? param.getFundEndTime() : null) + .fundStartTime(StringUtils.isNotBlank(param.getFundStartTime()) ? param.getFundStartTime() : null) + .fundPaymentBaseString(paramReq.getPaymentForm()) + .supplementFundAccount(param.getSupplementFundAccount()) + .creator(employeeId) + .nonPayment(param.getNonPayment()) + .deleteType(DeleteTypeEnum.NOT_DELETED.getValue()) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .underTake(param.getUnderTake()) + .paymentOrganization(param.getPaymentOrganization()) + .createTime(new Date()) + .updateTime(new Date()) + .welfareType(paramReq.getWelfareType().getValue()) + .employeeId(param.getEmployeeId()) + .build(); + //校验福利基数是否符合上下限要求, + if (!checkWelBaseLimit(insertFundInfo.getFundSchemeId(),insertFundInfo.getFundPaymentBaseString(), PaymentScopeEnum.SCOPE_PERSON.getValue(), errorMsg)) { + // throw new SalaryRunTimeException("公积金福利明细中的基数更新内容不符合相关基数上下限要求,请检查后重试!"); + throw new SalaryRunTimeException("公积金个人:" + errorMsg.toString()); + } + //需要拆分个人和公司福利基数时 + if (welBaseDiffSign) { + insertFundInfo.setFundPaymentComBaseString(paramReq.getPaymentComForm()); + //校验福利基数是否符合上下限要求 + if (!checkWelBaseLimit(insertFundInfo.getFundSchemeId(),insertFundInfo.getFundPaymentComBaseString(), PaymentScopeEnum.SCOPE_COMPANY.getValue(), errorMsg)) { + // throw new SalaryRunTimeException("公积金福利明细中的基数更新内容不符合相关基数上下限要求,请检查后重试!"); + throw new SalaryRunTimeException("公积金公司:" + errorMsg.toString()); + } + } + encryptUtil.encrypt(insertFundInfo, InsuranceArchivesFundSchemePO.class); + fundSchemeMapper.insert(insertFundInfo); + sqlSession.commit(); + + InsuranceArchivesBaseInfoPO baseInfoPO = getInsuranceBaseInfoMapper().getOneByEmployeeIdAndPayOrg(param.getPaymentOrganization(), param.getEmployeeId()); + if(baseInfoPO != null) { + List fundInfos = fundSchemeMapper.getFundByEmployeeIdAndPayOrg(InsuranceArchivesEmployeePO.builder() + .employeeId(param.getEmployeeId()) + .paymentOrganization(param.getPaymentOrganization()) + .build()); + baseInfoPO.setFundArchivesId(fundInfos.get(0).getId()); + //对于非系统人员,编辑后状态切换为正在缴纳 + if (baseInfoPO.getEmployeeType() != null && baseInfoPO.getEmployeeType().equals(DataCollectionEmployeeTypeEnum.EXT_EMPLOYEE.getValue())) { + baseInfoPO.setRunStatus(EmployeeStatusEnum.PAYING.getValue()); + } + getInsuranceBaseInfoMapper().updateById(baseInfoPO); + } else { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "档案不存在!")); + } + + } + + //生成福利档案基数调整记录数据 + List adjustHistoryList = createAdjustInfo(adjustInfo, employeeId); + //福利档案基数调整记录数据入库 + batchInsertAdjustHistory(adjustHistoryList, employeeId); + + } finally { + sqlSession.close(); + } + + } + + /** + * @param paramReq + * @param + */ + public void socialSave(InsuranceArchivesSaveParam paramReq, User user, boolean welBaseDiffSign) { + long employeeId = user.getUID(); + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SocialSchemeMapper socialSchemeMapper = sqlSession.getMapper(SocialSchemeMapper.class); + + InsuranceArchivesSocialSaveParam param = JSONObject.parseObject(paramReq.getBaseForm(), InsuranceArchivesSocialSaveParam.class); + SalaryAssert.notNull("员工id为空", param, param.getEmployeeId()); + + if (StringUtils.isNotBlank(param.getSocialStartTime()) && !SalaryDateUtil.checkYearMonth(param.getSocialStartTime())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(542528, "社保起始缴纳时间格式错误,正确格式为YYYY-MM或者yyyy-MM-dd")); + } + if (StringUtils.isNotBlank(param.getSocialEndTime()) && !SalaryDateUtil.checkYearMonth(param.getSocialEndTime())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(542529, "社保最后缴纳时间格式错误,正确格式为YYYY-MM或者yyyy-MM-dd")); + } + +// //删除社保数据 +// socialSchemeMapper.batchDeleteByEmployeeIds(Collections.singletonList(param.getEmployeeId())); + + //查询已有数据 + List socialIds = new ArrayList(); + socialIds.add(param.getId()); + List oldSocialInfoList = socialSchemeMapper.getSocialById(socialIds); + + //设置福利档案基数调整记录数据 + InsuranceArchivesBaseHistoryDTO adjustInfo = InsuranceArchivesBaseHistoryDTO.builder() + .adjustAfterSchemeId(param.getSocialSchemeId()) + .adjustAfterBaseJson(paramReq.getPaymentForm()) + .adjustAfterComBaseJson(paramReq.getPaymentComForm()) + .welfareType(paramReq.getWelfareType().getValue()) + .employeeId(param.getEmployeeId()) + .paymentOrganization(param.getPaymentOrganization()) + .build(); + + StringBuilder errorMsg = new StringBuilder(); + //组装新数据 + if (oldSocialInfoList.size() == 1) { + //老数据 + InsuranceArchivesSocialSchemePO oldSocialInfo = oldSocialInfoList.get(0); + //设置福利档案基数调整记录数据 + encryptUtil.decrypt(oldSocialInfo, InsuranceArchivesSocialSchemePO.class); + adjustInfo.setAdjustBeforeBaseJson(oldSocialInfo.getSocialPaymentBaseString()); + adjustInfo.setAdjustBeforeSchemeId(oldSocialInfo.getSocialSchemeId()); + adjustInfo.setAdjustBeforeComBaseJson(oldSocialInfo.getSocialPaymentComBaseString()); + //新数据 + InsuranceArchivesSocialSchemePO updateSocialInfo = + InsuranceArchivesSocialSchemePO.builder() + .id(oldSocialInfo.getId()) + .welfareType(paramReq.getWelfareType().getValue()) + .deleteType(DeleteTypeEnum.NOT_DELETED.getValue()) + .socialPaymentBaseString(paramReq.getPaymentForm()) + .socialSchemeId(param.getSocialSchemeId()) + .socialEndTime(StringUtils.isNotBlank(param.getSocialEndTime()) ? param.getSocialEndTime() : null) + .socialStartTime(StringUtils.isNotBlank(param.getSocialStartTime()) ? param.getSocialStartTime() : null) + .creator(employeeId) + .nonPayment(param.getNonPayment()) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .employeeId(param.getEmployeeId()) + .updateTime(new Date()) + .underTake(param.getUnderTake()) + .socialAccount(param.getSchemeAccount()) + .paymentOrganization(param.getPaymentOrganization()) + .build(); + //校验福利基数是否符合上下限要求 + if (!checkWelBaseLimit(updateSocialInfo.getSocialSchemeId(),updateSocialInfo.getSocialPaymentBaseString(), PaymentScopeEnum.SCOPE_PERSON.getValue(), errorMsg)) { + // throw new SalaryRunTimeException("社保福利明细中的基数更新内容不符合相关基数上下限要求,请检查后重试!"); + throw new SalaryRunTimeException("社保个人:" + errorMsg.toString()); + } + //需要拆分个人和公司福利基数时 + if (welBaseDiffSign) { + updateSocialInfo.setSocialPaymentComBaseString(paramReq.getPaymentComForm()); + //校验福利基数是否符合上下限要求 + if (!checkWelBaseLimit(updateSocialInfo.getSocialSchemeId(),updateSocialInfo.getSocialPaymentComBaseString(), PaymentScopeEnum.SCOPE_COMPANY.getValue(), errorMsg)) { + // throw new SalaryRunTimeException("社保福利明细中的基数更新内容不符合相关基数上下限要求,请检查后重试!"); + throw new SalaryRunTimeException("社保公司:" + errorMsg.toString()); + } + } + encryptUtil.encrypt(updateSocialInfo, InsuranceArchivesSocialSchemePO.class); + socialSchemeMapper.updateById(updateSocialInfo); + //更新base_info表状态 + InsuranceArchivesBaseInfoPO baseInfoPO = getInsuranceBaseInfoMapper().getOneByEmployeeIdAndPayOrg(param.getPaymentOrganization(), param.getEmployeeId()); + if(baseInfoPO != null && baseInfoPO.getEmployeeType() != null && baseInfoPO.getEmployeeType().equals(DataCollectionEmployeeTypeEnum.EXT_EMPLOYEE.getValue())) { + //对于非系统人员,编辑后状态切换为正在缴纳 + baseInfoPO.setRunStatus(EmployeeStatusEnum.PAYING.getValue()); + } + baseInfoPO.setSocialArchivesId(updateSocialInfo.getId()); + getInsuranceBaseInfoMapper().updateById(baseInfoPO); + sqlSession.commit(); + } else { + socialSchemeMapper.deleteByEmployeeIdAndPayOrg(InsuranceArchivesSocialSchemePO.builder() + .employeeId(param.getEmployeeId()) + .paymentOrganization(param.getPaymentOrganization()) + .build()); + //新建社保档案,并关联主表 + InsuranceArchivesSocialSchemePO insertSocialInfo = + InsuranceArchivesSocialSchemePO.builder() + .welfareType(paramReq.getWelfareType().getValue()) + .deleteType(DeleteTypeEnum.NOT_DELETED.getValue()) + .socialPaymentBaseString(paramReq.getPaymentForm()) + .socialSchemeId(param.getSocialSchemeId()) + .socialEndTime(StringUtils.isNotBlank(param.getSocialEndTime()) ? param.getSocialEndTime() : null) + .socialStartTime(StringUtils.isNotBlank(param.getSocialStartTime()) ? param.getSocialStartTime() : null) + .creator(employeeId) + .nonPayment(param.getNonPayment()) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .employeeId(param.getEmployeeId()) + .createTime(new Date()) + .updateTime(new Date()) + .underTake(param.getUnderTake()) + .socialAccount(param.getSchemeAccount()) + .paymentOrganization(param.getPaymentOrganization()) + .build(); + //校验福利基数是否符合上下限要求 + if (!checkWelBaseLimit(insertSocialInfo.getSocialSchemeId(),insertSocialInfo.getSocialPaymentBaseString(), PaymentScopeEnum.SCOPE_PERSON.getValue(), errorMsg)) { + // throw new SalaryRunTimeException("社保福利明细中的基数更新内容不符合相关基数上下限要求,请检查后重试!"); + throw new SalaryRunTimeException("社保个人:" + errorMsg.toString()); + } + //需要拆分个人和公司福利基数时 + if (welBaseDiffSign) { + insertSocialInfo.setSocialPaymentComBaseString(paramReq.getPaymentComForm()); + //校验福利基数是否符合上下限要求 + if (!checkWelBaseLimit(insertSocialInfo.getSocialSchemeId(),insertSocialInfo.getSocialPaymentComBaseString(), PaymentScopeEnum.SCOPE_COMPANY.getValue(), errorMsg)) { + // throw new SalaryRunTimeException("社保福利明细中的基数更新内容不符合相关基数上下限要求,请检查后重试!"); + throw new SalaryRunTimeException("社保公司:" + errorMsg.toString()); + } + } + encryptUtil.encrypt(insertSocialInfo, InsuranceArchivesSocialSchemePO.class); + socialSchemeMapper.insert(insertSocialInfo); + sqlSession.commit(); + + InsuranceArchivesBaseInfoPO baseInfoPO = getInsuranceBaseInfoMapper().getOneByEmployeeIdAndPayOrg(param.getPaymentOrganization(), param.getEmployeeId()); + if(baseInfoPO != null) { + List socialInfos = socialSchemeMapper.getSocialByEmployeeIdAndPayOrg(InsuranceArchivesEmployeePO.builder() + .employeeId(param.getEmployeeId()) + .paymentOrganization(param.getPaymentOrganization()) + .build()); + baseInfoPO.setSocialArchivesId(socialInfos.get(0).getId()); + //对于非系统人员,编辑后状态切换为正在缴纳 + if (baseInfoPO.getEmployeeType() != null && baseInfoPO.getEmployeeType().equals(DataCollectionEmployeeTypeEnum.EXT_EMPLOYEE.getValue())) { + baseInfoPO.setRunStatus(EmployeeStatusEnum.PAYING.getValue()); + } + getInsuranceBaseInfoMapper().updateById(baseInfoPO); + } else { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "档案不存在!")); + } + + } + + //生成福利档案基数调整记录数据 + List adjustHistoryList = createAdjustInfo(adjustInfo, employeeId); + //福利档案基数调整记录数据入库 + batchInsertAdjustHistory(adjustHistoryList, employeeId); + } finally { + sqlSession.close(); + } + } + + /** + * 校验福利基数是否符合上下限要求 + * @param primaryId + * @param paymentBaseString + * @return + */ + public Boolean checkWelBaseLimit(Long primaryId, String paymentBaseString, Integer paymentScope, StringBuilder errorMsg) { + + if (primaryId ==null || paymentBaseString == null) { + return true; + } + Map paymentBaseJson = JSON.parseObject(paymentBaseString, new HashMap().getClass()); + if (paymentBaseJson == null) { + return true; + } + + for (Map.Entry entry : paymentBaseJson.entrySet()) { + + //判断福利值是否为空/数字 + if (entry.getValue() == null || entry.getValue().length() == 0) { + continue; + } else if (!isNumeric(entry.getValue())) { + errorMsg.append("福利值非数字"); + log.info("福利值非数字!"); + return false; + } + + //根据福利方案id、险种id、缴纳对象、缴费状态查询明细 + List insuranceSchemeDetailPOList = getInsuranceSchemeDetailMapper().getByPI(primaryId, Long.valueOf(entry.getKey())); + log.info("福利方案id: {},, 福利明细项id:{}", primaryId, Long.valueOf(entry.getKey())); + if (insuranceSchemeDetailPOList.size() == 0) { + errorMsg.append("根据福利方案id、险种id、缴纳对象查询明细为null!福利方案id: " + primaryId + ", 福利明细项id:" + Long.valueOf(entry.getKey())); + log.info("根据福利方案id、险种id、缴纳对象查询明细为null!福利方案id: {}, 福利明细项id:{}", primaryId, Long.valueOf(entry.getKey())); + return false; + } + List isPaymentList = insuranceSchemeDetailPOList.stream() + .filter(f -> f.getIsPayment().equals(IsPaymentEnum.YES.getValue()) && f.getPaymentScope().equals(paymentScope)).collect(Collectors.toList()); + if (isPaymentList.size() > 0) { + InsuranceSchemeDetailPO insuranceSchemeDetailPO = isPaymentList.get(0); + + encryptUtil.decrypt(insuranceSchemeDetailPO, InsuranceSchemeDetailPO.class); + String lowerLimit = "0.000".equals(insuranceSchemeDetailPO.getLowerLimit()) ? null : insuranceSchemeDetailPO.getLowerLimit(); + String upperLimit = "0.000".equals(insuranceSchemeDetailPO.getUpperLimit()) ? null : insuranceSchemeDetailPO.getUpperLimit(); + if (lowerLimit != null && lowerLimit.length() > 0 && Double.parseDouble(entry.getValue()) < Double.parseDouble(lowerLimit)) { + //数值低于对应福利明细下限 + errorMsg.append("基数:"+ entry.getKey() + " 数值:" + entry.getValue() +"低于对应福利明细下限:" + lowerLimit); + log.info("社保基数 {} 数值 {} 低于对应福利明细下限 {}!", entry.getKey(), entry.getValue(), lowerLimit); + return false; + } + if (upperLimit != null && upperLimit.length() > 0 && Double.parseDouble(entry.getValue()) > Double.parseDouble(upperLimit)) { + //数值高于对应福利明细上限 + errorMsg.append("基数:"+ entry.getKey() + " 数值:" + entry.getValue() +"高于对应福利明细上限:" + upperLimit); + log.info("社保基数 {} 数值 {} 高于对应福利明细上限 {} !", entry.getKey(), entry.getValue(), upperLimit); + return false; + } + } else { + log.info("福利明细项属于未缴费状态,不对上下限进行约束"); + } + + + } + return true; + } + + + /** + * 校验福利基数是否符合上下限要求,并返回符合要求的数据 + * @param primaryId + * @param paymentBaseString + * @return + */ + public String checkAndBuildWelBaseWithLimit(Long primaryId, String paymentBaseString, Integer paymentScope) { + + if (primaryId ==null || paymentBaseString == null) { + return paymentBaseString; + } + Map paymentBaseJson = JSON.parseObject(paymentBaseString, HashMap.class); + Map newPaymentBaseJson = JSON.parseObject(paymentBaseString, HashMap.class); + if (paymentBaseJson == null) { + return null; + } + + for (Map.Entry entry : paymentBaseJson.entrySet()) { + + //判断福利值是否为空/数字 + if (entry.getValue() == null || entry.getValue().length() == 0) { + continue; + } else if (!isNumeric(entry.getValue())) { + log.info("福利值非数字!"); + newPaymentBaseJson.remove(entry.getKey()); + continue; + } + //根据福利方案id、险种id + List insuranceSchemeDetailPOList = getInsuranceSchemeDetailMapper().getByPI(primaryId, Long.valueOf(entry.getKey())); + log.info("福利方案id: {},, 福利明细项id:{}", primaryId, Long.valueOf(entry.getKey())); + if (insuranceSchemeDetailPOList.size() == 0) { + log.info("根据福利方案id、险种id、缴纳对象查询明细为null!福利方案id: {}, 福利明细项id:{}", primaryId, Long.valueOf(entry.getKey())); + newPaymentBaseJson.remove(entry.getKey()); + continue; + } + List checkList = insuranceSchemeDetailPOList.stream() + .filter(f -> f.getPaymentScope().equals(paymentScope)).collect(Collectors.toList()); + if (checkList.size() > 0) { + InsuranceSchemeDetailPO insuranceSchemeDetailPO = checkList.get(0); + encryptUtil.decrypt(insuranceSchemeDetailPO, InsuranceSchemeDetailPO.class); + String lowerLimit = "0.000".equals(insuranceSchemeDetailPO.getLowerLimit()) ? null : insuranceSchemeDetailPO.getLowerLimit(); + String upperLimit = "0.000".equals(insuranceSchemeDetailPO.getUpperLimit()) ? null : insuranceSchemeDetailPO.getUpperLimit(); + if (lowerLimit != null && lowerLimit.length() > 0 && Double.parseDouble(entry.getValue()) < Double.parseDouble(lowerLimit)) { + //数值低于对应福利明细下限 + log.info("社保基数 {} 数值 {} 低于对应福利明细下限 {}!", entry.getKey(), entry.getValue(), lowerLimit); + newPaymentBaseJson.put(entry.getKey(), lowerLimit); + } + if (upperLimit != null && upperLimit.length() > 0 && Double.parseDouble(entry.getValue()) > Double.parseDouble(upperLimit)) { + //数值高于对应福利明细上限 + log.info("社保基数 {} 数值 {} 高于对应福利明细上限 {} !", entry.getKey(), entry.getValue(), upperLimit); + newPaymentBaseJson.put(entry.getKey(), upperLimit); + } + } + } + return JSON.toJSONString(newPaymentBaseJson); + } + + /** + * 档案列表 + *

+ * 这里是一个含有比较多动态字段的列表,用的是手动拼装的方式 + * + * @param param 高级搜索条件 + * @param operateId 操作员id + * @return table + */ + public Map listPage(InsuranceArchivesListParam param, long operateId) { + Map apidatas = new HashMap<>(16); + InsuranceArchivesListParam request = InsuranceArchivesListParam.builder().build(); + if (param.getHireDate() != null && param.getHireDate().length == 2) { + param.setHiredateStart(param.getHireDate()[0]); + param.setHiredateEnd(param.getHireDate()[1]); + } + if (param.getDimissionDate() != null && param.getDimissionDate().length == 2) { + param.setDimissionDateStart(param.getDimissionDate()[0]); + param.setDimissionDateEnd(param.getDimissionDate()[1]); + } + + if (StringUtils.isNotBlank(param.getDepartmentIdsStr())) { + request.setDepartmentIds(Arrays.stream(param.getDepartmentIdsStr().split(",")).map(BigDecimal::new).collect(Collectors.toList())); + } + + if (StringUtils.isNotBlank(param.getSubcompanyIdsStr())) { + request.setSubcompanyIds(Arrays.stream(param.getSubcompanyIdsStr().split(",")).map(BigDecimal::new).collect(Collectors.toList())); + } + + + if (StringUtils.isNotBlank(param.getPositionsStr())) { + request.setPositions(Arrays.stream(param.getPositionsStr().split(",")).map(BigDecimal::new).collect(Collectors.toList())); + } + + if (StringUtils.isNotBlank(param.getStatusesStr())) { + request.setStatuses(Arrays.stream(param.getStatusesStr().split(",")).map(String::new).collect(Collectors.toList())); + } + + request.setNeedAuth(param.getNeedAuth()); + request.setTaxAgentEmployeeIds(param.getTaxAgentEmployeeIds()); + request.setTaxAgentIds(param.getTaxAgentIds()); + + Integer current = param.getCurrent() == null ? 1 : param.getCurrent(); + Integer pageSize = param.getPageSize() == null ? 10 : param.getPageSize(); + long startNum = (current - 1) * pageSize; + param.setStartNum(startNum); + param.setPageSize(pageSize); +// request.setStatuses(param.getStatuses()); + request.setKeyword(param.getUserName()); + + request.setSiSchemeId(param.getSiSchemeId()); + request.setFundSchemeId(param.getFundSchemeId()); + request.setOtherSchemeId(param.getOtherSchemeId()); + + request.setPageSize(param.getPageSize()); + request.setCurrent(param.getCurrent()); + + request.setJobNum(param.getJobNum()); + + request.setOrderRule(param.getOrderRule()); + + request.setRunStatuses(param.getRunStatuses()); + + request.setTaxAgentId(param.getTaxAgentId()); + + request.setExtWelArchiveList(param.isExtWelArchiveList()); + + apidatas = listPageEmployeePOS(request, operateId); + + return apidatas; + } + + + /** + * 获取员工的基本信息 + *

+ * 此处主要是一个公共接口,有多处引用。我们薪资系统只保存员工id(employeeId), + * 但是页面上需要展示员工的更多信息(姓名,部门,状态。。。), + * 所以这里主要是用于接收联表数据的一个接口 + * + * @param param 高级搜索条件,用于过滤数据 + * @param operateId 操作员id + * @return list + */ + public Map listPageEmployeePOS(InsuranceArchivesListParam param, long operateId) { + //是否分权 + Boolean needAuth = param.getNeedAuth(); + StopWatch sw = new StopWatch(); + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + Map datas = new HashMap<>(16); + try { + SocialSchemeMapper socialSchemeMapper = sqlSession.getMapper(SocialSchemeMapper.class); + List page = new ArrayList<>(); + PageInfo pageInfo = new PageInfo<>(InsuranceArchivesEmployeePO.class); +// //生成福利档案历史基础信息(在福利档案基础信息表为空时) +// createOldInsuranceBaseInfo(operateId); + //获取福利档案列表数据 + if (needAuth) { + Collection taxAgentEmployeeIds = param.getTaxAgentEmployeeIds(); + Collection taxAgentIds = param.getTaxAgentIds(); + log.info("从数据库获取档案列表数据开始"); + sw.start("获取福利档案列表数据"); + if (param.isExtWelArchiveList()) { + page = socialSchemeMapper.queryExtEmployeeList(param); + } else { + page = socialSchemeMapper.queryEmployeeList(param); + } + sw.stop(); + log.info("从数据库获取档案列表数据完成!"); + page = page.stream().filter(f -> +// taxAgentEmployeeIds.contains(f.getEmployeeId())|| + taxAgentIds.contains(f.getPaymentOrganization()) + ).collect(Collectors.toList()); + + // 填充总数和当页数据 + // 分页参数 + pageInfo = SalaryPageUtil.buildPage(param.getCurrent(), param.getPageSize(), InsuranceArchivesEmployeePO.class); + pageInfo.setTotal(page.size()); + pageInfo.setList(SalaryPageUtil.subList(pageInfo.getPageNum(), pageInfo.getPageSize(), page)); + } else { + log.info("从数据库获取档案列表数据开始"); + sw.start("获取档案列表数据"); + if (param.isExtWelArchiveList()) { + page = socialSchemeMapper.queryExtEmployeeList(param); + } else { + page = socialSchemeMapper.queryEmployeeList(param); + } + sw.stop(); + log.info("从数据库获取档案列表数据完成!"); + pageInfo = SalaryPageUtil.buildPage(param.getCurrent(), param.getPageSize(), + page, InsuranceArchivesEmployeePO.class); + } + List> records = null; + log.info("buildTableData方法处理福利档案列表数据开始"); + sw.start("buildTableData方法处理福利档案列表数据"); + if (param.getExportData() != null && param.getExportData()) { + records = buildTableData(pageInfo.getList(), true); + } else { + records = buildTableData(pageInfo.getList(), false); + } + sw.stop(); + log.info("buildTableData方法处理福利档案列表数据完成!"); + + log.info("buildWeaTableColumns方法处理福利档案列表数据开始"); + sw.start("buildWeaTableColumns方法处理福利档案列表数据"); + List columns = buildWeaTableColumns(pageInfo.getList(), operateId); + sw.stop(); + log.info("buildWeaTableColumns方法处理福利档案列表数据完成!"); + WeaTable table = new WeaTable(); + table.setColumns(columns); + //设置check是否可用 + List checkboxpopedomList = new ArrayList<>(); + WeaTableCheckboxpopedom checkboxpopedom = new WeaTableCheckboxpopedom(); + checkboxpopedom.setPopedompara("column:system_type"); + checkboxpopedom.setShowmethod("com.engine.salary.transmethod.TaxRateTransMethod.getCheckBoxPopedom"); + checkboxpopedomList.add(checkboxpopedom); + table.setCheckboxList(checkboxpopedomList); + table.setCheckboxpopedom(null); + + WeaResultMsg result = new WeaResultMsg(false); + result.putAll(table.makeDataResult()); + result.success(); + + datas.put("pageInfo", pageInfo); + datas.put("datas", records); + datas.put("columns", columns); + datas.put("dataKey", result.getResultMap()); + + log.info("各操作计时 {}", sw.prettyPrint()); + return datas; + + } finally { + sqlSession.close(); + } + } + + /** + * @param + * @param operateId + * @return + */ + public List buildWeaTableColumns(List insuranceArchivesEmployeePOS, long operateId) { + + Map> titleMap = buildColumnTitle(insuranceArchivesEmployeePOS, operateId); + List list = new ArrayList<>(); + WeaTableColumn nameColumn = new WeaTableColumn("100px", "姓名", "employeeName"); + nameColumn.setFixed("left"); + list.add(nameColumn); + list.add(new WeaTableColumn("150px", "个税扣缴义务人", "paymentOrganizationName")); + list.add(new WeaTableColumn("150px", "分部", "subcompanyName")); + list.add(new WeaTableColumn("150px", "部门", "departmentName")); + list.add(new WeaTableColumn("150px", "手机号", "mobile")); + list.add(new WeaTableColumn("150px", "员工状态", "status")); + list.add(new WeaTableColumn("150px", "工号", "jobNum")); + + list.add(new WeaTableColumn("150px", "入职日期", "companystartdate")); +// list.add(new WeaTableColumn("150px", "合同到期日期", "dismissdate")); + + list.add(new WeaTableColumn("150px", "社保方案名称", "socialName")); + titleMap.get(WelfareTypeEnum.SOCIAL_SECURITY.getValue()).forEach((k, v) -> list.add(new WeaTableColumn("150px", v, k))); + list.add(new WeaTableColumn("150px", "社保账号", "socialAccount")); + list.add(new WeaTableColumn("150px", "社保起始缴纳月", "socialStartTime")); + list.add(new WeaTableColumn("150px", "社保最后缴纳月", "socialEndTime")); + list.add(new WeaTableColumn("150px", "公积金方案名称", "fundName")); + list.add(new WeaTableColumn("150px", "公积金账号", "fundAccount")); + titleMap.get(WelfareTypeEnum.ACCUMULATION_FUND.getValue()).forEach((k, v) -> list.add(new WeaTableColumn("150px", v, k))); + list.add(new WeaTableColumn("150px", "补充公积金账号", "supplementFundAccount")); + list.add(new WeaTableColumn("150px", "公积金起始缴纳月", "fundStartTime")); + list.add(new WeaTableColumn("150px", "公积金最后缴纳月", "fundEndTime")); + list.add(new WeaTableColumn("150px", "其他福利方案名称", "otherName")); + titleMap.get(WelfareTypeEnum.OTHER.getValue()).forEach((k, v) -> list.add(new WeaTableColumn("150px", v, k))); + list.add(new WeaTableColumn("150px", "其他福利起始缴纳月", "otherStartTime")); + list.add(new WeaTableColumn("150px", "其他福利最后缴纳月", "otherEndTime")); + return list; + } + + /** + * @param insuranceArchivesEmployeePOS + * @param operateId + * @return + */ + public Map> buildColumnTitle(List insuranceArchivesEmployeePOS, long operateId) { + + boolean welBaseDiffSign = isDiffWelBase(); + + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + Map> result = new HashMap<>(); + + insuranceArchivesEmployeePOS = insuranceArchivesEmployeePOS.stream().filter(f -> f.getEmployeeId() != null).collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(InsuranceArchivesEmployeePO::getEmployeeId))), ArrayList::new)); + try { + + SocialSchemeMapper socialSchemeMapper = sqlSession.getMapper(SocialSchemeMapper.class); + FundSchemeMapper fundSchemeMapper = sqlSession.getMapper(FundSchemeMapper.class); + OtherSchemeMapper otherSchemeMapper = sqlSession.getMapper(OtherSchemeMapper.class); + ICategoryMapper iCategoryMapper = sqlSession.getMapper(ICategoryMapper.class); + + Set socialSet = new HashSet<>(); + Set fundSet = new HashSet<>(); + Set otherSet = new HashSet<>(); + + Set socialComSet = new HashSet<>(); + Set fundComSet = new HashSet<>(); + Set otherComSet = new HashSet<>(); + + insuranceArchivesEmployeePOS.forEach(item -> { + List socialList = socialSchemeMapper.getSocialByEmployeeId(Collections.singletonList(item.getEmployeeId())); + encryptUtil.decryptList(socialList, InsuranceArchivesSocialSchemePO.class); + List fundList = fundSchemeMapper.getFundByEmployeeId(Collections.singletonList(item.getEmployeeId())); + encryptUtil.decryptList(fundList, InsuranceArchivesFundSchemePO.class); + List otherList = otherSchemeMapper.getOtherByEmployeeId(Collections.singletonList(item.getEmployeeId())); + encryptUtil.decryptList(otherList, InsuranceArchivesOtherSchemePO.class); + if (socialList.size() > 0) { + for (InsuranceArchivesSocialSchemePO socialSchemePO : socialList) { + + Map socialJson = JSON.parseObject(socialSchemePO.getSocialPaymentBaseString(), new TypeReference>() { + }); + if (socialJson != null) { + socialJson.forEach((k, v) -> socialSet.add(k)); + } + //如果需要区分个人和公司福利基数 + if (welBaseDiffSign) { + Map socialComJson = JSON.parseObject(socialSchemePO.getSocialPaymentComBaseString(), new TypeReference>() { + }); + if (socialComJson != null) { + socialComJson.forEach((k, v) -> socialComSet.add(k)); + } + } + } + + } + if (fundList.size() > 0) { + for (InsuranceArchivesFundSchemePO fundSchemePO : fundList) { + Map fundJson = JSON.parseObject(fundSchemePO.getFundPaymentBaseString(), new TypeReference>() { + }); + if (fundJson != null) { + fundJson.forEach((k, v) -> fundSet.add(k)); + } + //如果需要区分个人和公司福利基数 + if (welBaseDiffSign) { + Map fundComJson = JSON.parseObject(fundSchemePO.getFundPaymentComBaseString(), new TypeReference>() { + }); + if (fundComJson != null) { + fundComJson.forEach((k, v) -> fundComSet.add(k)); + } + } + } + + } + if (otherList.size() > 0) { + for (InsuranceArchivesOtherSchemePO otherSchemePO : otherList) { + Map otherJson = JSON.parseObject(otherSchemePO.getOtherPaymentBaseString(), new TypeReference>() { + }); + if (otherJson != null) { + otherJson.forEach((k, v) -> otherSet.add(k)); + } + //如果需要区分个人和公司福利基数 + if (welBaseDiffSign) { + Map otherComJson = JSON.parseObject(otherSchemePO.getOtherPaymentComBaseString(), new TypeReference>() { + }); + if (otherComJson != null) { + otherComJson.forEach((k, v) -> otherComSet.add(k)); + } + } + } + + } + }); + Map socialMap = new HashMap<>(); + Map socialComMap = new HashMap<>(); + Map socialCollect = new HashMap<>(); + Map customSocial = iCategoryMapper.listByWelfareType(WelfareTypeEnum.SOCIAL_SECURITY.getValue(), null) + .stream().collect(Collectors.toMap(ICategoryPO::getId, Function.identity())); + + Map sysSocial = iCategoryMapper.listByWelfareType(WelfareTypeEnum.SOCIAL_SECURITY.getValue(), DataTypeEnum.SYSTEM.getValue()) + .stream().collect(Collectors.toMap(ICategoryPO::getId, Function.identity())); + + socialCollect.putAll(customSocial); + socialCollect.putAll(sysSocial); + + if (welBaseDiffSign) { + socialSet.forEach(item -> { + if (socialCollect.containsKey(Long.valueOf(item))) { + socialMap.put(item + "per", socialCollect.get(Long.valueOf(item)).getInsuranceName() + SalaryI18nUtil.getI18nLabel(0, "申报基数") + SalaryI18nUtil.getI18nLabel(0,"个人")); + } + }); + socialComSet.forEach(item -> { + if (socialCollect.containsKey(Long.valueOf(item))) { + socialComMap.put(item + "com", socialCollect.get(Long.valueOf(item)).getInsuranceName() + SalaryI18nUtil.getI18nLabel(0, "申报基数") + SalaryI18nUtil.getI18nLabel(0,"单位")); + } + }); + } else { + socialSet.forEach(item -> { + if (socialCollect.containsKey(Long.valueOf(item))) { + socialMap.put(item, socialCollect.get(Long.valueOf(item)).getInsuranceName() + SalaryI18nUtil.getI18nLabel(0, "申报基数")); + } + }); + } + Map fundMap = new HashMap<>(); + Map fundComMap = new HashMap<>(); + Map fundCollect = new HashMap<>(); + Map customFund = iCategoryMapper.listByWelfareType(WelfareTypeEnum.ACCUMULATION_FUND.getValue(), null).stream().collect(Collectors.toMap(ICategoryPO::getId, Function.identity())); + Map sysFund = iCategoryMapper.listByWelfareType(WelfareTypeEnum.ACCUMULATION_FUND.getValue(), DataTypeEnum.SYSTEM.getValue()).stream().collect(Collectors.toMap(ICategoryPO::getId, Function.identity())); + fundCollect.putAll(customFund); + fundCollect.putAll(sysFund); + if (welBaseDiffSign) { + fundSet.forEach(item -> { + if (fundCollect.containsKey(Long.valueOf(item))) { + fundMap.put(item + "per", fundCollect.get(Long.valueOf(item)).getInsuranceName() + SalaryI18nUtil.getI18nLabel(0, "申报基数") + SalaryI18nUtil.getI18nLabel(0,"个人")); + } + }); + fundComSet.forEach(item -> { + if (fundCollect.containsKey(Long.valueOf(item))) { + fundComMap.put(item + "com", fundCollect.get(Long.valueOf(item)).getInsuranceName() + SalaryI18nUtil.getI18nLabel(0, "申报基数") + SalaryI18nUtil.getI18nLabel(0,"单位")); + } + }); + } else { + fundSet.forEach(item -> { + if (fundCollect.containsKey(Long.valueOf(item))) { + fundMap.put(item, fundCollect.get(Long.valueOf(item)).getInsuranceName() + SalaryI18nUtil.getI18nLabel(0, "申报基数")); + } + }); + } + Map otherMap = new HashMap<>(); + Map otherComMap = new HashMap<>(); + Map otherCollect = new HashMap<>(); + Map customOther = iCategoryMapper.listByWelfareType(WelfareTypeEnum.OTHER.getValue(), null).stream().collect(Collectors.toMap(ICategoryPO::getId, Function.identity())); + Map sysOther = iCategoryMapper.listByWelfareType(WelfareTypeEnum.OTHER.getValue(), DataTypeEnum.SYSTEM.getValue()).stream().collect(Collectors.toMap(ICategoryPO::getId, Function.identity())); + otherCollect.putAll(customOther); + otherCollect.putAll(sysOther); + + if (welBaseDiffSign) { + otherSet.forEach(item -> { + if (otherCollect.containsKey(Long.valueOf(item))) { + otherMap.put(item + "per", otherCollect.get(Long.valueOf(item)).getInsuranceName() + SalaryI18nUtil.getI18nLabel(0, "申报基数") + SalaryI18nUtil.getI18nLabel(0,"个人")); + } + }); + otherComSet.forEach(item -> { + if (otherCollect.containsKey(Long.valueOf(item))) { + otherComMap.put(item + "com", otherCollect.get(Long.valueOf(item)).getInsuranceName() + SalaryI18nUtil.getI18nLabel(0, "申报基数") + SalaryI18nUtil.getI18nLabel(0,"单位")); + } + }); + } else { + otherSet.forEach(item -> { + if (otherCollect.containsKey(Long.valueOf(item))) { + otherMap.put(item, otherCollect.get(Long.valueOf(item)).getInsuranceName() + SalaryI18nUtil.getI18nLabel(0, "申报基数")); + } + }); + } + // map根据key排序 + LinkedHashMap socialMapWithAscKey = socialMap.entrySet().stream() + .sorted(Map.Entry.comparingByKey()) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (oldValue, newValue) -> oldValue, + LinkedHashMap::new)); + LinkedHashMap fundMapWithAscKey = fundMap.entrySet().stream() + .sorted(Map.Entry.comparingByKey()) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (oldValue, newValue) -> oldValue, + LinkedHashMap::new)); + LinkedHashMap otherMapWithAscKey = otherMap.entrySet().stream() + .sorted(Map.Entry.comparingByKey()) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (oldValue, newValue) -> oldValue, + LinkedHashMap::new)); + if (welBaseDiffSign) { + LinkedHashMap socialComMapWithAscKey = socialComMap.entrySet().stream() + .sorted(Map.Entry.comparingByKey()) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (oldValue, newValue) -> oldValue, + LinkedHashMap::new)); + LinkedHashMap fundComMapWithAscKey = fundComMap.entrySet().stream() + .sorted(Map.Entry.comparingByKey()) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (oldValue, newValue) -> oldValue, + LinkedHashMap::new)); + LinkedHashMap otherComMapWithAscKey = otherComMap.entrySet().stream() + .sorted(Map.Entry.comparingByKey()) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (oldValue, newValue) -> oldValue, + LinkedHashMap::new)); + socialMapWithAscKey.putAll(socialComMapWithAscKey); + fundMapWithAscKey.putAll(fundComMapWithAscKey); + otherMapWithAscKey.putAll(otherComMapWithAscKey); + } + + result.put(WelfareTypeEnum.SOCIAL_SECURITY.getValue(), socialMapWithAscKey); + result.put(WelfareTypeEnum.ACCUMULATION_FUND.getValue(), fundMapWithAscKey); + result.put(WelfareTypeEnum.OTHER.getValue(), otherMapWithAscKey); + return result; + } finally { + sqlSession.close(); + } + + + } + + + public List> buildTableData(List insuranceArchivesEmployeePOS) { + return buildTableData(insuranceArchivesEmployeePOS, false); + } + + /** + * @param insuranceArchivesEmployeePOS + * @return + */ + public List> buildTableData(List insuranceArchivesEmployeePOS, boolean export) { + + boolean welBaseDiffSign = isDiffWelBase(); + + List taxAgentPOS = getTaxAgentMapper().listAll(); + Map longTaxAgentPOMap = SalaryEntityUtil.convert2Map(taxAgentPOS, TaxAgentPO::getId); + + + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + List> records = new ArrayList<>(); + try { + SocialSchemeMapper socialSchemeMapper = sqlSession.getMapper(SocialSchemeMapper.class); + FundSchemeMapper fundSchemeMapper = sqlSession.getMapper(FundSchemeMapper.class); + OtherSchemeMapper otherSchemeMapper = sqlSession.getMapper(OtherSchemeMapper.class); + InsuranceSchemeMapper insuranceSchemeMapper = sqlSession.getMapper(InsuranceSchemeMapper.class); + +// List employeeIds = insuranceArchivesEmployeePOS.stream().map(InsuranceArchivesEmployeePO::getEmployeeId).collect(Collectors.toList()); + Map socialSchemePOMap = encryptUtil.decryptList(this.getSocialByEmployeeIdAndPayOrg(insuranceArchivesEmployeePOS), InsuranceArchivesSocialSchemePO.class) + .stream().collect(Collectors.toMap(InsuranceArchivesSocialSchemePO::getId, Function.identity())); + + Map fundSchemePOMap = encryptUtil.decryptList(this.getFundByEmployeeIdAndPayOrg(insuranceArchivesEmployeePOS), InsuranceArchivesFundSchemePO.class) + .stream().collect(Collectors.toMap(InsuranceArchivesFundSchemePO::getId, Function.identity())); + List otherByEmployeeList = this.getOtherByEmployeeIdAndPayOrg(insuranceArchivesEmployeePOS); + encryptUtil.decryptList(otherByEmployeeList, InsuranceArchivesOtherSchemePO.class); + Map otherSchemePOMap = otherByEmployeeList + .stream().collect(Collectors.toMap(InsuranceArchivesOtherSchemePO::getId, Function.identity())); + insuranceArchivesEmployeePOS.forEach(item -> { + InsuranceArchivesSocialSchemePO socialItem = socialSchemePOMap.get(item.getSocialId()); + InsuranceArchivesFundSchemePO fundItem = fundSchemePOMap.get(item.getFundId()); + InsuranceArchivesOtherSchemePO otherItem = otherSchemePOMap.get(item.getOtherId()); + Map map = new HashMap<>(); + map.put("employeeName", item.getUserName()); + map.put("paymentOrganizationName", longTaxAgentPOMap.get(item.getPaymentOrganization()) != null ? longTaxAgentPOMap.get(item.getPaymentOrganization()).getName() : ""); + map.put("employeeId", item.getEmployeeId()); + map.put("departmentName", item.getDepartmentName()); + map.put("subcompanyName", item.getSubcompanyName()); + map.put("departmentId", item.getDepartmentId()); + map.put("jobNum", item.getJobNum()); + map.put("companystartdate", item.getCompanystartdate()); + map.put("dismissdate", item.getDimissionDate()); + map.put("mobile", item.getTelephone()); + map.put("siSchemeId", item.getSiSchemeId()); + map.put("fundSchemeId", item.getFundSchemeId()); + map.put("otherSchemeId", item.getOtherSchemeId()); + map.put("status", item.getUserStatus() != null ? UserStatusEnum.getDefaultLabelByValue(item.getUserStatus()) : ""); + map.put("baseInfo", item.getBaseInfoId()); + map.put("paymentOrganization", item.getPaymentOrganization()); + if (socialItem != null) { + map.put("socialName", insuranceSchemeMapper.querySchemeName(socialItem.getSocialSchemeId())); + Map socialJson = JSON.parseObject(socialItem.getSocialPaymentBaseString(), new TypeReference>() { + }); + if (welBaseDiffSign) { + if (socialJson != null) { + //查询该福利方案下开启缴纳的福利项 + List insuranceIdList = payInsuranceIds(socialItem.getSocialSchemeId(), PaymentScopeEnum.SCOPE_PERSON.getValue()); + socialJson.forEach((k, v) -> { + if (insuranceIdList.contains(Long.valueOf(k))) { + map.put(k + "per", v); + } + }); + } + Map socialComJson = JSON.parseObject(socialItem.getSocialPaymentComBaseString(), new TypeReference>() { + }); + if (socialComJson != null) { + //查询该福利方案下开启缴纳的福利项 + List insuranceIdList = payInsuranceIds(socialItem.getSocialSchemeId(),PaymentScopeEnum.SCOPE_COMPANY.getValue()); + socialComJson.forEach((k, v) -> { + if (insuranceIdList.contains(Long.valueOf(k))) { + map.put(k + "com", v); + } + }); + } + } else { + if (socialJson != null) { + //查询该福利方案下开启缴纳的福利项 + List insuranceIdList = payInsuranceIds(socialItem.getSocialSchemeId()); + socialJson.forEach((k, v) -> { + if (insuranceIdList.contains(Long.valueOf(k))) { + map.put(k, v); + } + }); + } + } + + map.put("socialAccount", socialItem.getSocialAccount()); + map.put("socialStartTime", socialItem.getSocialStartTime()); + map.put("socialEndTime", socialItem.getSocialEndTime()); + } + if (fundItem != null) { + map.put("fundName", insuranceSchemeMapper.querySchemeName(fundItem.getFundSchemeId())); + map.put("fundAccount", fundItem.getFundAccount()); + Map fundJson = JSON.parseObject(fundItem.getFundPaymentBaseString(), new TypeReference>() { + }); + if (welBaseDiffSign) { + if (fundJson != null) { + //查询该福利方案下开启缴纳的福利项 + List insuranceIdList = payInsuranceIds(fundItem.getFundSchemeId(),PaymentScopeEnum.SCOPE_PERSON.getValue()); + fundJson.forEach((k, v) -> { + if (insuranceIdList.contains(Long.valueOf(k))) { + map.put(k + "per", v); + } + }); + } + Map fundComJson = JSON.parseObject(fundItem.getFundPaymentComBaseString(), new TypeReference>() { + }); + if (fundComJson != null) { + //查询该福利方案下开启缴纳的福利项 + List insuranceIdList = payInsuranceIds(fundItem.getFundSchemeId(),PaymentScopeEnum.SCOPE_COMPANY.getValue()); + fundComJson.forEach((k, v) -> { + if (insuranceIdList.contains(Long.valueOf(k))) { + map.put(k + "com", v); + } + }); + } + } else { + if (fundJson != null) { + //查询该福利方案下开启缴纳的福利项 + List insuranceIdList = payInsuranceIds(fundItem.getFundSchemeId()); + fundJson.forEach((k, v) -> { + if (insuranceIdList.contains(Long.valueOf(k))) { + map.put(k, v); + } + }); + } + } + + map.put("supplementFundAccount", fundItem.getSupplementFundAccount()); + map.put("fundStartTime", fundItem.getFundStartTime()); + map.put("fundEndTime", fundItem.getFundEndTime()); + + } + if (otherItem != null) { + map.put("otherName", insuranceSchemeMapper.querySchemeName(otherItem.getOtherSchemeId())); + Map otherJson = JSON.parseObject(otherItem.getOtherPaymentBaseString(), new TypeReference>() { + }); + if (welBaseDiffSign) { + if (otherJson != null) { + //查询该福利方案下开启缴纳的福利项 + List insuranceIdList = payInsuranceIds(otherItem.getOtherSchemeId(),PaymentScopeEnum.SCOPE_PERSON.getValue()); + otherJson.forEach((k, v) -> { + if (insuranceIdList.contains(Long.valueOf(k))) { + map.put(k + "per", v); + } + }); + } + Map otherComJson = JSON.parseObject(otherItem.getOtherPaymentComBaseString(), new TypeReference>() { + }); + if (otherComJson != null) { + //查询该福利方案下开启缴纳的福利项 + List insuranceIdList = payInsuranceIds(otherItem.getOtherSchemeId(),PaymentScopeEnum.SCOPE_COMPANY.getValue()); + otherComJson.forEach((k, v) -> { + if (insuranceIdList.contains(Long.valueOf(k))) { + map.put(k + "com", v); + } + }); + } + } else { + if (otherJson != null) { + //查询该福利方案下开启缴纳的福利项 + List insuranceIdList = payInsuranceIds(otherItem.getOtherSchemeId()); + otherJson.forEach((k, v) -> { + if (insuranceIdList.contains(Long.valueOf(k))) { + map.put(k, v); + } + }); + } + } + + map.put("otherStartTime", otherItem.getOtherStartTime()); + map.put("otherEndTime", otherItem.getOtherEndTime()); + } + records.add(map); + }); + return records; + + } finally { + sqlSession.close(); + } + } + + public List payInsuranceIds(Long socialSchemeId) { + //查询该福利方案下开启缴纳的福利项 + List detailPOS = getInsuranceSchemeDetailMapper().queryListBySchemeId(socialSchemeId); + List insuranceIdList = new ArrayList<>(); + if (detailPOS != null && detailPOS.size() > 0) { + //开启缴纳的 + insuranceIdList = detailPOS.stream().filter(f -> f.getIsPayment().equals(IsPaymentEnum.YES.getValue())).map(InsuranceSchemeDetailPO::getInsuranceId).collect(Collectors.toList()); + } + return insuranceIdList; + } + + public List payInsuranceIds(Long socialSchemeId, Integer paymentScope) { + //查询该福利方案下开启缴纳的福利项 + List detailPOS = getInsuranceSchemeDetailMapper().queryListBySchemeId(socialSchemeId); + List insuranceIdList = new ArrayList<>(); + if (detailPOS != null && detailPOS.size() > 0) { + //开启缴纳的 + insuranceIdList = detailPOS.stream().filter(f -> f.getIsPayment().equals(IsPaymentEnum.YES.getValue()) && f.getPaymentScope().equals(paymentScope)) + .map(InsuranceSchemeDetailPO::getInsuranceId).collect(Collectors.toList()); + } + return insuranceIdList; + } + + /** + * 获取信息提示 + */ + public void tips() { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SocialSchemeMapper socialSchemeMapper = sqlSession.getMapper(SocialSchemeMapper.class); + List employeeIds = socialSchemeMapper.tips(); + SalaryAssert.isEmpty(employeeIds, "当前有离职人员档案存在福利缴纳起始月,未维护福利最后缴纳月,请尽快处理"); + + } finally { + sqlSession.close(); + } + } + + /** + * 高级搜索 + * + * @return + */ + public Map getSearchCondition(User user) { + + List userStatusOptions = Arrays.stream(UserStatusEnum.values()).map(e -> new SearchConditionOption(String.valueOf(e.getValue()), e.getDefaultLabel())).collect(Collectors.toList()); + List list = new SISchemeBiz().listAll(); + + List schemeOption = list.stream().filter(item -> Objects.equals(item.getWelfareType(), WelfareTypeEnum.SOCIAL_SECURITY.getValue())) + .collect(Collectors.toList()) + .stream().map(item -> new SearchConditionOption(item.getId().toString(), item.getSchemeName())).collect(Collectors.toList()); + + List fundOption = list.stream().filter(item -> Objects.equals(item.getWelfareType(), WelfareTypeEnum.ACCUMULATION_FUND.getValue())) + .collect(Collectors.toList()) + .stream().map(item -> new SearchConditionOption(item.getId().toString(), item.getSchemeName())).collect(Collectors.toList()); + + List otherOption = list.stream().filter(item -> Objects.equals(item.getWelfareType(), WelfareTypeEnum.OTHER.getValue())) + .collect(Collectors.toList()) + .stream().map(item -> new SearchConditionOption(item.getId().toString(), item.getSchemeName())).collect(Collectors.toList()); + + List> taxAgentList = getTaxAgentWrapper(user).selectListAsAdmin(); + List taxAgentOption = taxAgentList.stream().map(item -> new SearchConditionOption(item.get("id").toString(), item.get("content").toString())).collect(Collectors.toList()); + + + Map apidatas = new HashMap(); + ConditionFactory conditionFactory = new ConditionFactory(user); + + //条件组 + List addGroups = new ArrayList(); + + List conditionItems = new ArrayList(); + + //文本输入框 + SearchConditionItem username = conditionFactory.createCondition(ConditionType.INPUT, 25034, "username"); + username.setInputType("input"); + username.setColSpan(2);//定义一行显示条件数,默认值为2,当值为1时标识该条件单独占一行 + username.setFieldcol(16); //条件输入框所占宽度,默认值18 + username.setLabelcol(8); + username.setViewAttr(2); // 编辑权限 1:只读,2:可编辑, 3:必填 默认2 + username.setLabel("姓名"); //设置文本值 这个将覆盖多语言标签的值 + conditionItems.add(username); + + //文本输入框 + SearchConditionItem jobNum = conditionFactory.createCondition(ConditionType.INPUT, 25034, "jobNum"); + jobNum.setInputType("input"); + jobNum.setColSpan(2);//定义一行显示条件数,默认值为2,当值为1时标识该条件单独占一行 + jobNum.setFieldcol(16); //条件输入框所占宽度,默认值18 + jobNum.setLabelcol(8); + jobNum.setViewAttr(2); // 编辑权限 1:只读,2:可编辑, 3:必填 默认2 + jobNum.setLabel("工号"); //设置文本值 这个将覆盖多语言标签的值 + conditionItems.add(jobNum); + + + SearchConditionItem departmentIds = conditionFactory.createCondition(ConditionType.BROWSER, 502329, "departmentIdsStr", "57"); + departmentIds.setColSpan(2); + departmentIds.setFieldcol(16); + departmentIds.setLabelcol(8); + departmentIds.setLabel("部门"); + conditionItems.add(departmentIds); + + + SearchConditionItem statuses = conditionFactory.createCondition(ConditionType.SELECT, 502327, "statusesStr"); + statuses.setInputType("select"); + statuses.setMultiple(true); + statuses.setOptions(userStatusOptions); + statuses.setColSpan(2); + statuses.setFieldcol(16); + statuses.setLabelcol(8); + statuses.setIsQuickSearch(true); + statuses.setLabel("状态"); + conditionItems.add(statuses); + + + SearchConditionItem positions = conditionFactory.createCondition(ConditionType.BROWSER, 502327, "positionsStr", "278"); + positions.setInputType("browser"); + positions.setColSpan(2); + positions.setFieldcol(16); + positions.setLabelcol(8); + positions.setIsQuickSearch(true); + positions.setLabel("岗位"); + conditionItems.add(positions); + + SearchConditionItem subcompanyIds = conditionFactory.createCondition(ConditionType.BROWSER, 502327, "subcompanyIdsStr", "194"); + subcompanyIds.setInputType("browser"); + subcompanyIds.setColSpan(2); + subcompanyIds.setFieldcol(16); + subcompanyIds.setLabelcol(8); + subcompanyIds.setIsQuickSearch(true); + subcompanyIds.setLabel("分部"); + conditionItems.add(subcompanyIds); + +// SearchConditionItem hireDate = conditionFactory.createCondition(ConditionType.TIMEPICKER,502327,new String[]{"hireDate", "hireDate"}); +// hireDate.setInputType("timepicker"); +// hireDate.setColSpan(2); +// hireDate.setFieldcol(16); +// hireDate.setViewAttr(8); +// hireDate.setFormat("yyyy-MM-dd"); +// hireDate.setLabel("入职日期"); +// conditionItems.add(hireDate); +// +// +// SearchConditionItem dimissionDate = conditionFactory.createCondition(ConditionType.TIMEPICKER,502327,new String[]{"dimissionDate", "dimissionDate"}); +// dimissionDate.setInputType("timepicker"); +// dimissionDate.setColSpan(2); +// dimissionDate.setFieldcol(16); +// dimissionDate.setViewAttr(8); +// dimissionDate.setFormat("yyyy-MM-dd"); +// dimissionDate.setLabel("离职日期"); +// conditionItems.add(dimissionDate); + + + SearchConditionItem siSchemeId = conditionFactory.createCondition(ConditionType.SELECT, 502327, "siSchemeId"); + siSchemeId.setInputType("select"); + siSchemeId.setOptions(schemeOption); + siSchemeId.setColSpan(2); + siSchemeId.setFieldcol(16); + siSchemeId.setLabelcol(8); + siSchemeId.setIsQuickSearch(true); + siSchemeId.setLabel("社保方案"); + conditionItems.add(siSchemeId); + + + SearchConditionItem fundSchemeId = conditionFactory.createCondition(ConditionType.SELECT, 502327, "fundSchemeId"); + fundSchemeId.setInputType("select"); + fundSchemeId.setOptions(fundOption); + fundSchemeId.setColSpan(2); + fundSchemeId.setFieldcol(16); + fundSchemeId.setLabelcol(8); + fundSchemeId.setIsQuickSearch(true); + fundSchemeId.setLabel("公积金方案"); + conditionItems.add(fundSchemeId); + + SearchConditionItem otherSchemeId = conditionFactory.createCondition(ConditionType.SELECT, 502327, "otherSchemeId"); + otherSchemeId.setInputType("select"); + otherSchemeId.setOptions(otherOption); + otherSchemeId.setColSpan(2); + otherSchemeId.setFieldcol(16); + otherSchemeId.setLabelcol(8); + otherSchemeId.setIsQuickSearch(true); + otherSchemeId.setLabel("其它福利方案"); + conditionItems.add(otherSchemeId); + + SearchConditionItem taxAgentId = conditionFactory.createCondition(ConditionType.SELECT, 502327, "taxAgentId"); + taxAgentId.setInputType("select"); + taxAgentId.setOptions(taxAgentOption); + taxAgentId.setColSpan(2); + taxAgentId.setFieldcol(16); + taxAgentId.setLabelcol(8); + taxAgentId.setIsQuickSearch(true); + taxAgentId.setLabel("个税扣缴义务人"); + conditionItems.add(taxAgentId); + + addGroups.add(new SearchConditionGroup("常用条件", true, conditionItems)); + apidatas.put("condition", addGroups); + return apidatas; + } + + /** + * 组装员工的社保,公积金,其他福利数据 + * + * @param ids 员工id集合 + * @return map + */ + public Map buildBatchAccount(List ids, Long paymentOrganization) { + if (CollectionUtils.isEmpty(ids)) { + return new HashMap<>(); + } + //设置获取社保/公积金/其他福利档案方法的入参 + List insuranceArchivesEmployeePOS = new ArrayList<>(); + for (Long employeeId : ids) { + insuranceArchivesEmployeePOS.add(InsuranceArchivesEmployeePO.builder() + .employeeId(employeeId) + .paymentOrganization(paymentOrganization) + .build()); + } + + Map result = new HashMap<>(); + Map socialMap = new HashMap<>(); + Map funMap = new HashMap<>(); + Map otherMap = new HashMap<>(); + List socialPOS = encryptUtil.decryptList(this.getSocialByEmployeeIdAndPayOrg(insuranceArchivesEmployeePOS), InsuranceArchivesSocialSchemePO.class); + if (CollectionUtils.isNotEmpty(socialPOS)) { + socialMap = socialPOS.stream().collect(Collectors.toMap(InsuranceArchivesSocialSchemePO::getEmployeeId, Function.identity())); + } + List fundPOS = encryptUtil.decryptList(this.getFundByEmployeeIdAndPayOrg(insuranceArchivesEmployeePOS), InsuranceArchivesFundSchemePO.class); + if (CollectionUtils.isNotEmpty(fundPOS)) { + funMap = fundPOS.stream().collect(Collectors.toMap(InsuranceArchivesFundSchemePO::getEmployeeId, Function.identity())); + } + List otherPOS = this.getOtherByEmployeeIdAndPayOrg(insuranceArchivesEmployeePOS); + encryptUtil.decryptList(otherPOS, InsuranceArchivesOtherSchemePO.class); + if (CollectionUtils.isNotEmpty(otherPOS)) { + otherMap = otherPOS.stream().collect(Collectors.toMap(InsuranceArchivesOtherSchemePO::getEmployeeId, Function.identity())); + } + for (Long id : ids) { + InsuranceArchivesAccountPO po = new InsuranceArchivesAccountPO(); + po.setSocial(socialMap.get(id)); + po.setFund(funMap.get(id)); + po.setOther(otherMap.get(id)); + result.put(id, po); + } + return result; + } + + + /** + * 判断是否需要生成历史福利档案基本信息 + */ + public Boolean createOldInsuranceBaseInfo(Long creator) { + + + log.info("判断是否需要生成历史数据"); + List nowBaseInfoList = getInsuranceBaseInfoMapper().getInsuranceBaseInfoList(); + if (nowBaseInfoList.size() == 0) { + StopWatch sw = new StopWatch(); + log.info("福利档案基础信息表为空,开始生成历史数据:"); + //处理公积金、其他福利档案中个税扣缴义务人为空的情况 + sw.start("处理公积金、其他福利档案中个税扣缴义务人为空的情况"); + List socialList = getSocialSchemeMapper().listAll(); + List fundList = getFundSchemeMapper().listAll(); + List otherList = getOtherSchemeMapper().listAll(); + + List updateFundList = new ArrayList<>(); + List updateOtherList = new ArrayList<>(); + for (InsuranceArchivesSocialSchemePO socialSchemePO : socialList) { + List toDealFundList = fundList.stream().filter(f -> f.getEmployeeId().equals(socialSchemePO.getEmployeeId()) && f.getPaymentOrganization() == null).collect(Collectors.toList()); + if (toDealFundList.size() > 0) { + InsuranceArchivesFundSchemePO toDealFundPO = toDealFundList.get(0); + toDealFundPO.setPaymentOrganization(socialSchemePO.getPaymentOrganization()); + updateFundList.add(toDealFundPO); + } + + List toDealOtherList = otherList.stream().filter(f -> f.getEmployeeId().equals(socialSchemePO.getEmployeeId()) && f.getPaymentOrganization() == null).collect(Collectors.toList()); + if (toDealOtherList.size() > 0) { + InsuranceArchivesOtherSchemePO toDealOtherPO = toDealOtherList.get(0); + toDealOtherPO.setPaymentOrganization(socialSchemePO.getPaymentOrganization()); + updateOtherList.add(toDealOtherPO); + + } + + } + log.info("重置个税扣缴义务人id的公积金档案数:{}", updateFundList.size()); + log.info("重置个税扣缴义务人id的其他福利档案数:{}", updateOtherList.size()); + //更新公积金和其他福利档案 + updateFundList.forEach(getFundSchemeMapper()::updateById); + updateOtherList.forEach(getOtherSchemeMapper()::updateById); + sw.stop(); + + sw.start("处理待入库的历史福利档案基础信息并入库"); + List addBaseInfoList = new ArrayList<>(); + + List oldBaseInfoList = getInsuranceBaseInfoMapper().getInsuranceBaseInfoListByInsuranceDetail(null); + log.info("获取待生成的历史福利档案基础信息条数:{}", oldBaseInfoList.size()); + //去重 + oldBaseInfoList = oldBaseInfoList.stream() + .collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(f -> f.getPaymentOrganization() + "-" + f.getEmployeeId()))), ArrayList::new)); + log.info("去重后的待生成历史福利档案基础信息条数:{}", oldBaseInfoList.size()); + if (oldBaseInfoList.size() > 0) { + //设置基本信息表字段 + for (InsuranceArchivesBaseInfoPO po : oldBaseInfoList) { + po.setId(IdGenerator.generate()); + po.setCreateTime(new Date()); + po.setDeleteType(0); + po.setCreator(creator); + po.setRunStatus(EmployeeStatusEnum.STAY_ADD.getValue()); + po.setUpdateTime(new Date()); + po.setTenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY); + + addBaseInfoList.add(po); + } + //将历史基本信息入库 + List> partition = Lists.partition(addBaseInfoList, 50); + partition.forEach(getInsuranceBaseInfoMapper()::batchSave); + + sw.stop(); + log.info("各操作计时 {}", sw.prettyPrint()); + return true; + }else { + return false; + } + + + } else { + return false; + } + + } + + /** + * 判断字符串是否为整数或者小数或者负数 + */ + public static boolean isNumeric(String str){ + + Pattern pattern = Pattern.compile("^-?\\d+(\\.\\d+)?$"); + Matcher isNum = pattern.matcher(str); + if (!isNum.matches()) { + return false; + } + return true; + + } + + /** + * 获取没有设置社保、公积金最后缴纳月的档案 + * @param employeeIds + * @return + */ + public List listEndDateIsNull(List employeeIds) { + if (CollectionUtils.isEmpty(employeeIds)) { + return Collections.emptyList(); + } + return getInsuranceBaseInfoMapper().listEndDateIsNull(employeeIds); + } + + public List dealSocialBaseAdjustInfoList(List adjustList, Long creator) { + List adjustHistoryList = new ArrayList<>(); + if (adjustList.size() > 0) { + //遍历待更新的福利档案数据,对每组档案生成基数调整记录(基数单元未变化则忽略) + for (InsuranceArchivesSocialSchemePO po : adjustList) { + List oldBaseInfoList = getSocialSchemeMapper().getSocialByEmployeeIdAndPayOrg(InsuranceArchivesEmployeePO.builder() + .paymentOrganization(po.getPaymentOrganization()).employeeId(po.getEmployeeId()).build()); + + InsuranceArchivesBaseHistoryDTO adjustInfo = InsuranceArchivesBaseHistoryDTO.builder() + .adjustAfterSchemeId(po.getSocialSchemeId()) + .adjustAfterBaseJson(po.getSocialPaymentBaseString()) + .adjustAfterComBaseJson(po.getSocialPaymentComBaseString()) + .welfareType(po.getWelfareType()) + .employeeId(po.getEmployeeId()) + .paymentOrganization(po.getPaymentOrganization()) + .build(); + if (oldBaseInfoList.size() == 1) { + //新增调整记录,变更 + InsuranceArchivesSocialSchemePO oldBaseInfo = oldBaseInfoList.get(0); + encryptUtil.decrypt(oldBaseInfo, InsuranceArchivesSocialSchemePO.class); + adjustInfo.setAdjustBeforeBaseJson(oldBaseInfo.getSocialPaymentBaseString()); + adjustInfo.setAdjustBeforeComBaseJson(oldBaseInfo.getSocialPaymentComBaseString()); + adjustInfo.setAdjustBeforeSchemeId(oldBaseInfo.getSocialSchemeId()); + } else if (oldBaseInfoList.size() > 1) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"社保档案存在冗余数据!")); + } + adjustHistoryList.addAll(createAdjustInfo(adjustInfo, creator)); + } + } + return adjustHistoryList; + + } + public List dealFundBaseAdjustInfoList(List adjustList, Long creator) { + List adjustHistoryList = new ArrayList<>(); + if (adjustList.size() > 0) { + //遍历待更新的福利档案数据,对每组档案生成基数调整记录(基数单元未变化则忽略) + for (InsuranceArchivesFundSchemePO po : adjustList) { + List oldBaseInfoList = getFundSchemeMapper().getFundByEmployeeIdAndPayOrg(InsuranceArchivesEmployeePO.builder() + .paymentOrganization(po.getPaymentOrganization()).employeeId(po.getEmployeeId()).build()); + + InsuranceArchivesBaseHistoryDTO adjustInfo = InsuranceArchivesBaseHistoryDTO.builder() + .adjustAfterSchemeId(po.getFundSchemeId()) + .adjustAfterBaseJson(po.getFundPaymentBaseString()) + .adjustAfterComBaseJson(po.getFundPaymentComBaseString()) + .welfareType(po.getWelfareType()) + .employeeId(po.getEmployeeId()) + .paymentOrganization(po.getPaymentOrganization()) + .build(); + if (oldBaseInfoList.size() == 1) { + //新增调整记录,变更 + InsuranceArchivesFundSchemePO oldBaseInfo = oldBaseInfoList.get(0); + encryptUtil.decrypt(oldBaseInfo, InsuranceArchivesFundSchemePO.class); + adjustInfo.setAdjustBeforeBaseJson(oldBaseInfo.getFundPaymentBaseString()); + adjustInfo.setAdjustBeforeComBaseJson(oldBaseInfo.getFundPaymentComBaseString()); + adjustInfo.setAdjustBeforeSchemeId(oldBaseInfo.getFundSchemeId()); + } else if (oldBaseInfoList.size() > 1) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"公积金档案存在冗余数据!")); + } + adjustHistoryList.addAll(createAdjustInfo(adjustInfo, creator)); + } + } + return adjustHistoryList; + } + public List dealOtherBaseAdjustInfoList(List adjustList, Long creator) { + List adjustHistoryList = new ArrayList<>(); + if (adjustList.size() > 0) { + //遍历待更新的福利档案数据,对每组档案生成基数调整记录(基数单元未变化则忽略) + for (InsuranceArchivesOtherSchemePO po : adjustList) { + List oldBaseInfoList = getOtherSchemeMapper().getOtherByEmployeeIdAndPayOrg(InsuranceArchivesEmployeePO.builder() + .paymentOrganization(po.getPaymentOrganization()).employeeId(po.getEmployeeId()).build()); + + InsuranceArchivesBaseHistoryDTO adjustInfo = InsuranceArchivesBaseHistoryDTO.builder() + .adjustAfterSchemeId(po.getOtherSchemeId()) + .adjustAfterBaseJson(po.getOtherPaymentBaseString()) + .adjustAfterComBaseJson(po.getOtherPaymentComBaseString()) + .welfareType(po.getWelfareType()) + .employeeId(po.getEmployeeId()) + .paymentOrganization(po.getPaymentOrganization()) + .build(); + if (oldBaseInfoList.size() == 1) { + //新增调整记录,变更 + InsuranceArchivesOtherSchemePO oldBaseInfo = oldBaseInfoList.get(0); + encryptUtil.decrypt(oldBaseInfo, InsuranceArchivesOtherSchemePO.class); + adjustInfo.setAdjustBeforeBaseJson(oldBaseInfo.getOtherPaymentBaseString()); + adjustInfo.setAdjustBeforeComBaseJson(oldBaseInfo.getOtherPaymentComBaseString()); + adjustInfo.setAdjustBeforeSchemeId(oldBaseInfo.getOtherSchemeId()); + } else if (oldBaseInfoList.size() > 1) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"其他福利档案存在冗余数据!")); + } + adjustHistoryList.addAll(createAdjustInfo(adjustInfo, creator)); + } + } + return adjustHistoryList; + } + + //生成基数调整记录(基数单元未变化则忽略) + public List createAdjustInfo(InsuranceArchivesBaseHistoryDTO adjustInfo, Long creator) { + Date now = new Date(); + boolean welBaseDiffSign = isDiffWelBase(); + + List toCreateAdjustHistoryList = new ArrayList<>(); + //旧档案不存在基数信息,则直接遍历新的基数数据,生成调整记录;旧档案存在基数信息,则合并新旧基数数据,遍历合并后的技术数据中的key,生成调整记录。 + if(StringUtils.isNotBlank(adjustInfo.getAdjustAfterBaseJson()) && StringUtils.isBlank(adjustInfo.getAdjustBeforeBaseJson())) { + Map adjustAfterBaseMap = JSON.parseObject(adjustInfo.getAdjustAfterBaseJson(), new TypeReference>() { + }); + for (String key : adjustAfterBaseMap.keySet()) { + InsuranceArchivesBaseHistoryPO adjustItem = new InsuranceArchivesBaseHistoryPO(); + BeanUtils.copyProperties(adjustInfo, adjustItem); + adjustItem.setAdjustWelfareItemId(Long.valueOf(key)); + adjustItem.setAdjustAfterBaseValue((String) adjustAfterBaseMap.get(key)); + adjustItem.setOperateTime(now); + adjustItem.setOperator(creator); + adjustItem.setCreator(creator); + adjustItem.setCreateTime(now); + adjustItem.setUpdateTime(now); + adjustItem.setDeleteType(DeleteTypeEnum.NOT_DELETED.getValue()); + adjustItem.setTenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY); + adjustItem.setId(IdGenerator.generate()); + adjustItem.setPaymentScope(welBaseDiffSign ? PaymentScopeEnum.SCOPE_PERSON.getValue().toString() : PaymentScopeEnum.SCOPE_PERSON.getValue().toString() + "," + PaymentScopeEnum.SCOPE_COMPANY.getValue().toString()); + toCreateAdjustHistoryList.add(adjustItem); + } + } else if (StringUtils.isNotBlank(adjustInfo.getAdjustAfterBaseJson()) && StringUtils.isNotBlank(adjustInfo.getAdjustBeforeBaseJson())) { + Map adjustAfterBaseMap = JSON.parseObject(adjustInfo.getAdjustAfterBaseJson(), new TypeReference>() { + }); + Map adjustBeforeBaseMap = JSON.parseObject(adjustInfo.getAdjustBeforeBaseJson(), new TypeReference>() { + }); + Map reDealMap = new HashMap<>(); + if (adjustAfterBaseMap != null) { + reDealMap.putAll(adjustAfterBaseMap); + } + if (adjustBeforeBaseMap != null) { + reDealMap.putAll(adjustBeforeBaseMap); + } + if (reDealMap.size() >0) { + for (String key : reDealMap.keySet()) { + String beforeValue = (String) adjustBeforeBaseMap.get(key); + String afterValue = (String) adjustAfterBaseMap.get(key); + if (SalaryEntityUtil.empty2Zero(beforeValue).compareTo(SalaryEntityUtil.empty2Zero(afterValue)) == 0) { + continue; + } + InsuranceArchivesBaseHistoryPO adjustItem = new InsuranceArchivesBaseHistoryPO(); + BeanUtils.copyProperties(adjustInfo, adjustItem); + adjustItem.setAdjustWelfareItemId(Long.valueOf(key)); + adjustItem.setAdjustBeforeBaseValue(beforeValue); + adjustItem.setAdjustAfterBaseValue(afterValue); + adjustItem.setOperateTime(now); + adjustItem.setOperator(creator); + adjustItem.setCreator(creator); + adjustItem.setCreateTime(now); + adjustItem.setUpdateTime(now); + adjustItem.setDeleteType(DeleteTypeEnum.NOT_DELETED.getValue()); + adjustItem.setTenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY); + adjustItem.setId(IdGenerator.generate()); + adjustItem.setPaymentScope(welBaseDiffSign ? PaymentScopeEnum.SCOPE_PERSON.getValue().toString() : PaymentScopeEnum.SCOPE_PERSON.getValue().toString() + "," + PaymentScopeEnum.SCOPE_COMPANY.getValue().toString()); + + toCreateAdjustHistoryList.add(adjustItem); + } + } + + } + //如果系统应用设置拆分了个人和公司福利基数,则对adjustBeforeComBaseJson,adjustAfterComBaseJson也进行处理 + if (welBaseDiffSign) { + //旧档案不存在基数信息,则直接遍历新的基数数据,生成调整记录;旧档案存在基数信息,则合并新旧基数数据,遍历合并后的技术数据中的key,生成调整记录。 + if(StringUtils.isNotBlank(adjustInfo.getAdjustAfterComBaseJson()) && StringUtils.isBlank(adjustInfo.getAdjustBeforeComBaseJson())) { + Map adjustAfterComBaseMap = JSON.parseObject(adjustInfo.getAdjustAfterComBaseJson(), new TypeReference>() { + }); + for (String key : adjustAfterComBaseMap.keySet()) { + InsuranceArchivesBaseHistoryPO adjustItem = new InsuranceArchivesBaseHistoryPO(); + BeanUtils.copyProperties(adjustInfo, adjustItem); + adjustItem.setAdjustWelfareItemId(Long.valueOf(key)); + adjustItem.setAdjustAfterBaseValue((String) adjustAfterComBaseMap.get(key)); + adjustItem.setOperateTime(now); + adjustItem.setOperator(creator); + adjustItem.setCreator(creator); + adjustItem.setCreateTime(now); + adjustItem.setUpdateTime(now); + adjustItem.setDeleteType(DeleteTypeEnum.NOT_DELETED.getValue()); + adjustItem.setTenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY); + adjustItem.setId(IdGenerator.generate()); + adjustItem.setPaymentScope(PaymentScopeEnum.SCOPE_COMPANY.getValue().toString()); + toCreateAdjustHistoryList.add(adjustItem); + } + } else if (StringUtils.isNotBlank(adjustInfo.getAdjustAfterComBaseJson()) && StringUtils.isNotBlank(adjustInfo.getAdjustBeforeComBaseJson())) { + Map adjustAfterComBaseMap = JSON.parseObject(adjustInfo.getAdjustAfterComBaseJson(), new TypeReference>() { + }); + Map adjustBeforeComBaseMap = JSON.parseObject(adjustInfo.getAdjustBeforeComBaseJson(), new TypeReference>() { + }); + Map reDealMap = new HashMap<>(); + if (adjustAfterComBaseMap != null) { + reDealMap.putAll(adjustAfterComBaseMap); + } + if (adjustBeforeComBaseMap != null) { + reDealMap.putAll(adjustBeforeComBaseMap); + } + if (reDealMap.size() >0) { + for (String key : reDealMap.keySet()) { + String beforeValue = (String) adjustBeforeComBaseMap.get(key); + String afterValue = (String) adjustAfterComBaseMap.get(key); + if (SalaryEntityUtil.empty2Zero(beforeValue).compareTo(SalaryEntityUtil.empty2Zero(afterValue)) == 0) { + continue; + } + InsuranceArchivesBaseHistoryPO adjustItem = new InsuranceArchivesBaseHistoryPO(); + BeanUtils.copyProperties(adjustInfo, adjustItem); + adjustItem.setAdjustWelfareItemId(Long.valueOf(key)); + adjustItem.setAdjustBeforeBaseValue(beforeValue); + adjustItem.setAdjustAfterBaseValue(afterValue); + adjustItem.setOperateTime(now); + adjustItem.setOperator(creator); + adjustItem.setCreator(creator); + adjustItem.setCreateTime(now); + adjustItem.setUpdateTime(now); + adjustItem.setDeleteType(DeleteTypeEnum.NOT_DELETED.getValue()); + adjustItem.setTenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY); + adjustItem.setId(IdGenerator.generate()); + adjustItem.setPaymentScope( PaymentScopeEnum.SCOPE_COMPANY.getValue().toString()); + + toCreateAdjustHistoryList.add(adjustItem); + } + } + + } + } + return toCreateAdjustHistoryList; + } + + /** + * 新增福利档案基数调整记录 + * + */ + public void batchInsertAdjustHistory(List adjustHistoryList, long employeeId) { + + if (CollectionUtils.isEmpty(adjustHistoryList)) { + return; + } + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + InsuranceBaseAdjustHistoryMapper mapper = sqlSession.getMapper(InsuranceBaseAdjustHistoryMapper.class); + List> partition = Lists.partition(adjustHistoryList, 100); + partition.forEach(mapper::batchSave); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + /** + * 获取福利档案基数调整记录 + * + */ + public List getAdjustHistoryList(Long paymentOrganization, Long employeeId) { + + if (paymentOrganization == null && employeeId == null) { + return null; + } + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + InsuranceBaseAdjustHistoryMapper mapper = sqlSession.getMapper(InsuranceBaseAdjustHistoryMapper.class); + List list = mapper.listByEmployeeIdAndPayOrg(paymentOrganization, employeeId); + return list; + } finally { + sqlSession.close(); + } + } + + /** + * 获取福利档案基数调整记录 + * + */ + public List getBaseHistoryByEmployeeIdAndOperator(Long operator, Long employeeId) { + + + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + InsuranceBaseAdjustHistoryMapper mapper = sqlSession.getMapper(InsuranceBaseAdjustHistoryMapper.class); + List empList = mapper.listByEmployeeIdAndOperator(operator, employeeId); + List extEmpList = mapper.listByExtEmpIdAndOperator(operator, employeeId); + if (extEmpList != null) { + empList.addAll(extEmpList); + empList = empList.stream().filter(f -> StringUtils.isNotBlank(f.getEmployeeName())) + .sorted(Comparator.comparing(InsuranceArchivesBaseHistoryDTO::getOperateTime).reversed()).collect(Collectors.toList()); + } + return empList; + } finally { + sqlSession.close(); + } + } + + public List buildAdjustHistoryColumns(long operateId) { + List list = new ArrayList<>(); + WeaTableColumn nameColumn = new WeaTableColumn("100px", "福利项名称", "welfareItemName"); + nameColumn.setFixed("left"); + list.add(nameColumn); + list.add(new WeaTableColumn("150px", "调整前方案", "adjustBeforeSchemeName")); + list.add(new WeaTableColumn("150px", "调整前基数", "adjustBeforeBaseValue")); + list.add(new WeaTableColumn("150px", "调整后方案", "adjustAfterSchemeName")); + list.add(new WeaTableColumn("150px", "调整后基数", "adjustAfterBaseValue")); + list.add(new WeaTableColumn("150px", "操作人", "operatorName")); + list.add(new WeaTableColumn("150px", "操作时间", "operatorTime")); + return list; + } + + public boolean isDiffWelBase() { + User user = (User) SalaryContext.get().getValue("user"); + //判断是否要区分个人和单位福利基数 + SalarySysConfPO welBaseDiff = getSalarySysConfService(user).getOneByCode(WEL_BASE_DIFF_BY_PER_AND_COM); + + return welBaseDiff != null && welBaseDiff.getConfValue().equals(OpenEnum.OPEN.getValue()); + } +} diff --git a/src/com/engine/salary/biz/SICategoryBiz.java b/src/com/engine/salary/biz/SICategoryBiz.java new file mode 100644 index 000000000..dec57358b --- /dev/null +++ b/src/com/engine/salary/biz/SICategoryBiz.java @@ -0,0 +1,184 @@ +package com.engine.salary.biz; + +import com.engine.salary.entity.sicategory.bo.ICategoryBO; +import com.engine.salary.entity.sicategory.dto.ICategoryFormDTO; +import com.engine.salary.entity.sicategory.po.ICategoryPO; +import com.engine.salary.entity.sischeme.po.InsuranceSchemeDetailPO; +import com.engine.salary.enums.sicategory.IsPaymentEnum; +import com.engine.salary.enums.sicategory.WelfareTypeEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.mapper.sicategory.ICategoryMapper; +import com.engine.salary.util.SalaryEnumUtil; +import com.mzlion.core.utils.BeanUtils; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.ibatis.session.SqlSession; +import weaver.conn.mybatis.MyBatisFactory; + +import java.util.Date; +import java.util.List; +import java.util.Objects; + +/** + * @Author weaver_cl + * @Description: + * @Date 2022/3/9 + * @Version V1.0 + **/ +public class SICategoryBiz { + + + /** + * 自定义福利表单 + * id == null ? 新建表单 : 查看已有数据内容表单 + * @param id 自定义福利主键 + * @return 表单 + */ + public ICategoryFormDTO getForm(Long id) { + if (id != null) { + ICategoryPO iCategoryPO = getByID(id); + ICategoryFormDTO iCategoryFormDTO = new ICategoryFormDTO(); + if (Objects.isNull(iCategoryPO)) { + throw new SalaryRunTimeException("数据不存在"); + } + BeanUtils.copyProperties(iCategoryPO,iCategoryFormDTO); + iCategoryFormDTO.setWelfareType(SalaryEnumUtil.enumMatchByValue(iCategoryPO.getWelfareType(), WelfareTypeEnum.values(), WelfareTypeEnum.class)); + iCategoryFormDTO.setPaymentScope(SalaryEnumUtil.stringToEnums(iCategoryPO.getPaymentScope(), ",")); + return iCategoryFormDTO; + } + + return ICategoryFormDTO.builder().welfareType(WelfareTypeEnum.SOCIAL_SECURITY).build(); + } + + + /** + * 根据id获取 + * @param id + * @return + */ + public ICategoryPO getByID(Long id) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + ICategoryMapper iCategoryMapper = sqlSession.getMapper(ICategoryMapper.class); + ICategoryPO iCategoryPO = iCategoryMapper.getById(id); + return iCategoryPO; + + } finally { + sqlSession.close(); + } + } + + /** + * 保存 + * @param iCategoryFormDTO + * @param employeeId DataTypeEnum.SYSTEM.getValue() + */ + public void save(ICategoryFormDTO iCategoryFormDTO, long employeeId) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + ICategoryMapper iCategoryMapper = sqlSession.getMapper(ICategoryMapper.class); + iCategoryFormDTO.setInsuranceName(StringUtils.trim(iCategoryFormDTO.getInsuranceName())); + List iCategoryPOS = listByName(iCategoryFormDTO.getInsuranceName()); + if (CollectionUtils.isNotEmpty(iCategoryPOS)) { + throw new SalaryRunTimeException("福利名称不允许重复"); + } + ICategoryPO iCategoryPO = ICategoryBO.convertToInsuranceCategoryPO(iCategoryFormDTO, employeeId); + iCategoryMapper.insert(iCategoryPO); + + sqlSession.commit(); + + } finally { + sqlSession.close(); + } + + + } + + /** + * 根据名称获取 + * @param insuranceName + * @return + */ + public List listByName(String insuranceName) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + + try{ + ICategoryMapper iCategoryMapper = sqlSession.getMapper(ICategoryMapper.class); + List iCategoryPOS = iCategoryMapper.listByName(insuranceName); + return iCategoryPOS; + + } finally { + sqlSession.close(); + } + } + + /** + * 更新 + * @param iCategoryFormDTO + * @param employeeId + */ + public void update(ICategoryFormDTO iCategoryFormDTO, long employeeId) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try{ + if (iCategoryFormDTO.getId() == null) { + throw new SalaryRunTimeException("id is required"); + } + + ICategoryPO iCategoryPO = getByID(iCategoryFormDTO.getId()); + if (Objects.isNull(iCategoryPO)) { + throw new SalaryRunTimeException("数据不存在"); + } + + List iCategoryPOS = listByName(iCategoryFormDTO.getInsuranceName()); + if (CollectionUtils.isNotEmpty(iCategoryPOS)) { + throw new SalaryRunTimeException("福利名称不允许重复"); + } + + iCategoryPO.setInsuranceName(iCategoryFormDTO.getInsuranceName()); +// iCategoryPO.setWelfareType(iCategoryFormDTO.getWelfareType().getValue()); +// iCategoryPO.setPaymentScope(SalaryEnumUtil.enumArrToString(iCategoryFormDTO.getPaymentScope())); + iCategoryPO.setUpdateTime(new Date()); + ICategoryMapper iCategoryMapper = sqlSession.getMapper(ICategoryMapper.class); + iCategoryMapper.update(iCategoryPO); + + sqlSession.commit(); + } finally { + sqlSession.close(); + } + + } + + /** + * 更新状态 + * @param id + * @param isUse + * @param employeeId + */ + public void updateStatusById(Long id, Integer isUse, long employeeId) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + if(id == null) { + throw new SalaryRunTimeException("id is required"); + } + if (isUse == null) { + throw new SalaryRunTimeException("isUse is required"); + } + List insuranceSchemeDetailPOS = new SISchemeBiz().queryListByInsuranceIdIsPayment(id, IsPaymentEnum.YES.getValue()); + if(CollectionUtils.isNotEmpty(insuranceSchemeDetailPOS) && isUse == 0) { + throw new SalaryRunTimeException("该福利开启缴费,不可删除(或停用)"); + } + ICategoryPO iCategoryPO = getByID(id); + if (Objects.isNull(iCategoryPO)) { + throw new SalaryRunTimeException("数据记录不存在"); + } + iCategoryPO.setIsUse(isUse); + ICategoryMapper iCategoryMapper = sqlSession.getMapper(ICategoryMapper.class); + iCategoryMapper.updateById(iCategoryPO); + + sqlSession.commit(); + }finally { + sqlSession.close(); + } + + } +} diff --git a/src/com/engine/salary/biz/SISchemeBiz.java b/src/com/engine/salary/biz/SISchemeBiz.java new file mode 100644 index 000000000..f4b82614a --- /dev/null +++ b/src/com/engine/salary/biz/SISchemeBiz.java @@ -0,0 +1,497 @@ +package com.engine.salary.biz; + +import com.api.formmode.mybatis.util.SqlProxyHandle; +import com.engine.salary.constant.SalaryDefaultTenantConstant; +import com.engine.salary.encrypt.EncryptUtil; +import com.engine.salary.entity.sicategory.po.ICategoryPO; +import com.engine.salary.entity.sischeme.bo.InsuranceSchemeBO; +import com.engine.salary.entity.sischeme.dto.InsuranceSchemeDTO; +import com.engine.salary.entity.sischeme.dto.InsuranceSchemeDetailDTO; +import com.engine.salary.entity.sischeme.param.InsuranceSchemeReqParam; +import com.engine.salary.entity.sischeme.po.InsuranceSchemeDetailPO; +import com.engine.salary.entity.sischeme.po.InsuranceSchemePO; +import com.engine.salary.entity.sischeme.vo.InsuranceSchemeFormVO; +import com.engine.salary.enums.SalaryRoundingModeEnum; +import com.engine.salary.enums.sicategory.*; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.mapper.siaccount.SIAccountUtilMapper; +import com.engine.salary.mapper.sicategory.ICategoryMapper; +import com.engine.salary.mapper.sischeme.InsuranceSchemeDetailMapper; +import com.engine.salary.mapper.sischeme.InsuranceSchemeMapper; +import com.engine.salary.util.SalaryAssert; +import com.engine.salary.util.SalaryEnumUtil; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.ibatis.session.SqlSession; +import weaver.conn.mybatis.MyBatisFactory; + +import java.math.BigDecimal; +import java.util.*; +import java.util.regex.Pattern; +import java.util.stream.Collectors; + + +/** + * @Author weaver_cl + * @Date 2022/3/7 + * @Version V1.0 + **/ +public class SISchemeBiz { + + private SIAccountUtilMapper getSIAccountUtilMapper() { + return SqlProxyHandle.getProxy(SIAccountUtilMapper.class); + } + + private EncryptUtil encryptUtil = new EncryptUtil(); + + /** + * 获取社保方案 + * + * @param id + * @param welfareTypeEnum + * @return + */ + public InsuranceSchemeFormVO getForm(Long id, WelfareTypeEnum welfareTypeEnum) { + InsuranceSchemeDTO insuranceSchemeDTO = getSchemeFormDTO(welfareTypeEnum, id); + List insuranceSchemeDetailDTOList = getSchemeDetailFormDTO(welfareTypeEnum, id); + return InsuranceSchemeFormVO.builder().schemeBatch(insuranceSchemeDTO).schemeDetailList(insuranceSchemeDetailDTOList).build(); + } + + /** + * 获取方案明细表集合 新建|详情 + * + * @param welfareTypeEnum 福利类型 + * @param id 方案主键id + * @return form + */ + public List getSchemeDetailFormDTO(WelfareTypeEnum welfareTypeEnum, Long id) { + List insuranceCategoryPOS = listByWelfareType(welfareTypeEnum.getValue()); + List insuranceSchemeDetailDTOList = new ArrayList<>(); + insuranceCategoryPOS.forEach(item -> { + PaymentScopeEnum[] paymentScopeEnums = SalaryEnumUtil.stringToEnums(item.getPaymentScope(), ","); + Arrays.stream(paymentScopeEnums).forEach(e -> { + InsuranceSchemeDetailDTO insuranceSchemeDetailDTO = InsuranceSchemeDetailDTO.builder().build(); + InsuranceSchemeDetailPO insuranceSchemeDetailPO = getByPPI(id, e.getValue(), item.getId()); + if (insuranceSchemeDetailPO == null) { + insuranceSchemeDetailDTO = InsuranceSchemeDetailDTO.builder() + .id((long) (Math.random() * 10000)) + .insuranceId(item.getId()) + .insuranceName(item.getInsuranceName()) + .paymentScope(e.getDefaultLabel()) + .rententionRule(String.valueOf(SalaryRoundingModeEnum.ROUNDING.getValue())) + .validNum(2) + .cycleSetting("000000000000") + .paymentCycle("0") + .accountType("0") + .build(); + if (Objects.equals(item.getDataType(), DataTypeEnum.SYSTEM.getValue())) { + insuranceSchemeDetailDTO.setIsPayment(true); + } else { + insuranceSchemeDetailDTO.setIsPayment(false); + } + } else { + //BeanUtils.copyProperties(insuranceSchemeDetailPO, insuranceSchemeDetailDTO); + insuranceSchemeDetailDTO.setEffectiveTime(insuranceSchemeDetailPO.getEffectiveTime()); + insuranceSchemeDetailDTO.setExpirationTime(insuranceSchemeDetailPO.getExpirationTime()); + insuranceSchemeDetailDTO.setId(insuranceSchemeDetailPO.getId()); + insuranceSchemeDetailDTO.setInsuranceId(insuranceSchemeDetailPO.getInsuranceId()); + insuranceSchemeDetailDTO.setPaymentScopeValue(insuranceSchemeDetailPO.getPaymentScope()); + insuranceSchemeDetailDTO.setPrimaryId(insuranceSchemeDetailPO.getPrimaryId()); + insuranceSchemeDetailDTO.setValidNum(insuranceSchemeDetailPO.getValidNum() == null ? 2 : insuranceSchemeDetailPO.getValidNum()); + + if (insuranceSchemeDetailPO.getIsPayment() != null) { + insuranceSchemeDetailDTO.setIsPayment(Objects.equals(insuranceSchemeDetailPO.getIsPayment(), IsPaymentEnum.YES.getValue())); + } + if (insuranceSchemeDetailPO.getPaymentCycle() != null) { + insuranceSchemeDetailDTO.setPaymentCycle(insuranceSchemeDetailPO.getPaymentCycle() + ""); + } else { + insuranceSchemeDetailDTO.setPaymentCycle("0"); + } + if (insuranceSchemeDetailPO.getAccountType() != null) { + insuranceSchemeDetailDTO.setAccountType(insuranceSchemeDetailPO.getAccountType() + ""); + } else { + insuranceSchemeDetailDTO.setAccountType("0"); + } + if (insuranceSchemeDetailPO.getCycleSetting() == null) { + insuranceSchemeDetailDTO.setCycleSetting("000000000000"); + } else { + insuranceSchemeDetailDTO.setCycleSetting(insuranceSchemeDetailPO.getCycleSetting()); + } + if (StringUtils.isNotBlank(insuranceSchemeDetailPO.getUpperLimit())) { + BigDecimal bigDecimal = new BigDecimal(insuranceSchemeDetailPO.getUpperLimit()); + insuranceSchemeDetailDTO.setUpperLimit(numberCheck(bigDecimal.toPlainString()) ? null : bigDecimal); + } + if (StringUtils.isNotBlank(insuranceSchemeDetailPO.getLowerLimit())) { + BigDecimal bigDecimal = new BigDecimal(insuranceSchemeDetailPO.getLowerLimit()); + insuranceSchemeDetailDTO.setLowerLimit(numberCheck(bigDecimal.toPlainString()) ? null : bigDecimal); + } + if (StringUtils.isNotBlank(insuranceSchemeDetailPO.getPaymentProportion())) { + BigDecimal bigDecimal = new BigDecimal(insuranceSchemeDetailPO.getPaymentProportion()); + insuranceSchemeDetailDTO.setPaymentProportion(numberCheck(bigDecimal.toPlainString()) ? null : bigDecimal); + } + if (StringUtils.isNotBlank(insuranceSchemeDetailPO.getFixedCost())) { + BigDecimal bigDecimal = new BigDecimal(insuranceSchemeDetailPO.getFixedCost()); + insuranceSchemeDetailDTO.setFixedCost(numberCheck(bigDecimal.toPlainString()) ? null : bigDecimal); + } + insuranceSchemeDetailDTO.setInsuranceName(item.getInsuranceName()); + insuranceSchemeDetailDTO.setRententionRule(String.valueOf(insuranceSchemeDetailPO.getRententionRule())); + insuranceSchemeDetailDTO.setPaymentScope(e.getDefaultLabel()); + + } + insuranceSchemeDetailDTO.setPaymentScopeValue(e.getValue()); + insuranceSchemeDetailDTOList.add(insuranceSchemeDetailDTO); + }); + }); + return insuranceSchemeDetailDTOList; + } + + /** + * 根据福利类型获取 + * + * @param welfareType + * @return + */ + public List listByWelfareType(Integer welfareType) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + ICategoryMapper iCategoryMapper = sqlSession.getMapper(ICategoryMapper.class); + List insuranceCategoryPOS = iCategoryMapper.listByWelfareType(welfareType, null); + return insuranceCategoryPOS; + } finally { + sqlSession.close(); + } + } + + public boolean numberCheck(String number) { + return Pattern.compile("^0\\.[0]*").matcher(number).matches(); + } + + private InsuranceSchemeDetailPO getByPPI(Long primaryId, Integer paymentScope, Long insuranceId) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + InsuranceSchemeDetailMapper insuranceSchemeDetailMapper = sqlSession.getMapper(InsuranceSchemeDetailMapper.class); + InsuranceSchemeDetailPO insuranceSchemeDetailPO = insuranceSchemeDetailMapper.getByPPI(primaryId, paymentScope, insuranceId); + encryptUtil.decrypt(insuranceSchemeDetailPO, InsuranceSchemeDetailPO.class); + return insuranceSchemeDetailPO; + } finally { + sqlSession.close(); + } + } + + + /** + * 获取方案主表信息 新建|详情 + * + * @param welfareTypeEnum 福利类型 + * @param id 方案主键id + * @return form + */ + private InsuranceSchemeDTO getSchemeFormDTO(WelfareTypeEnum welfareTypeEnum, Long id) { + InsuranceSchemeDTO insuranceSchemeDTO = InsuranceSchemeDTO.builder().paymentType(PaymentTypeEnum.SCHEME_TOWN).welfareType(welfareTypeEnum).build(); + if (id != null) { + InsuranceSchemePO insuranceSchemePO = getById(id); + SalaryAssert.notNull(insuranceSchemePO, "福利方案不存在"); + //BeanUtils.copyProperties(insuranceSchemePO, insuranceSchemeDTO); + insuranceSchemeDTO.setId(insuranceSchemePO.getId()); + insuranceSchemeDTO.setPaymentArea(insuranceSchemePO.getPaymentArea()); + insuranceSchemeDTO.setRemarks(insuranceSchemePO.getRemarks()); + insuranceSchemeDTO.setSchemeName(insuranceSchemePO.getSchemeName()); + insuranceSchemeDTO.setPaymentType(SalaryEnumUtil.enumMatchByValue(insuranceSchemePO.getPaymentType(), PaymentTypeEnum.values(), PaymentTypeEnum.class)); + insuranceSchemeDTO.setWelfareType(welfareTypeEnum); + insuranceSchemeDTO.setSharedType(StringUtils.isBlank(insuranceSchemePO.getSharedType()) ? "0" : insuranceSchemePO.getSharedType()); + insuranceSchemeDTO.setTaxAgentIds(insuranceSchemePO.getTaxAgentIds()); + } + return insuranceSchemeDTO; + } + + /** + * 社保方案基础信息主表 + * + * @param id + * @return + */ + public InsuranceSchemePO getById(Long id) { + + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + InsuranceSchemeMapper insuranceSchemeMapper = sqlSession.getMapper(InsuranceSchemeMapper.class); + InsuranceSchemePO insuranceSchemePO = insuranceSchemeMapper.getById(id); + + return insuranceSchemePO; + } finally { + sqlSession.close(); + } + } + + + /** + * 获取所有方案 + * + * @return + */ + public List listAll(){ + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + InsuranceSchemeMapper insuranceSchemeMapper = sqlSession.getMapper(InsuranceSchemeMapper.class); + List insuranceSchemePOList = insuranceSchemeMapper.listAll(); + return insuranceSchemePOList; + } finally { + sqlSession.close(); + } + } + + + /** + * 社保方案基础信息明细表 + * + * @param primaryId + * @return + */ + public List listByPrimaryId(Long primaryId) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + InsuranceSchemeDetailMapper insuranceSchemeDetailMapper = sqlSession.getMapper(InsuranceSchemeDetailMapper.class); + List insuranceSchemeDetailPOS = insuranceSchemeDetailMapper.queryListBySchemeId(primaryId); + encryptUtil.decryptList(insuranceSchemeDetailPOS, InsuranceSchemeDetailPO.class); +// return decryptSchemeDetailList(insuranceSchemeDetailPOS); + return insuranceSchemeDetailPOS; + } finally { + sqlSession.close(); + } + + } + + /** + * 新增 + * + * @param saveParam + * @param employeeId + */ + public void save(InsuranceSchemeReqParam saveParam, long employeeId) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + + try { + //保存福利项目主表 + InsuranceSchemeMapper insuranceSchemeMapper = sqlSession.getMapper(InsuranceSchemeMapper.class); + saveParam.getInsuranceScheme().setSchemeName(StringUtils.trim(saveParam.getInsuranceScheme().getSchemeName())); + List listResult = insuranceSchemeMapper.listByName(saveParam.getInsuranceScheme().getSchemeName()); + SalaryAssert.isEmpty(listResult, "该福利名称已经存在,福利名称系统全局唯一"); + + InsuranceSchemePO insuranceSchemePO = InsuranceSchemeBO.convert2BatchPO(saveParam.getInsuranceScheme(), employeeId); + if (insuranceSchemePO.getSharedType() == null) { + insuranceSchemePO.setSharedType(SharedTypeEnum.PUBLIC.getValue()); + } else { + if (insuranceSchemePO.getSharedType().equals(SharedTypeEnum.PRIVATE.getValue()) && StringUtils.isBlank(insuranceSchemePO.getTaxAgentIds())) { + throw new SalaryRunTimeException("方案可见性为私有时,未设置可见范围"); + } + } + + + insuranceSchemeMapper.insert(insuranceSchemePO); + + + //保存福利项目明细表 + InsuranceSchemeDetailMapper insuranceSchemeDetailMapper = sqlSession.getMapper(InsuranceSchemeDetailMapper.class); + List insuranceSchemeDetailPOS = InsuranceSchemeBO.convertToInsuranceSchemeDetailPoList(saveParam.getInsuranceSchemeDetailList(), employeeId, insuranceSchemePO.getId()); + encryptUtil.encryptList(insuranceSchemeDetailPOS, InsuranceSchemeDetailPO.class); + insuranceSchemeDetailPOS.forEach(insuranceSchemeDetailMapper::insert); + + sqlSession.commit(); + + } finally { + sqlSession.close(); + } + + + } + + /** + * 更新 + * + * @param updateParam + * @param employeeId + */ + public void update(InsuranceSchemeReqParam updateParam, long employeeId) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + InsuranceSchemeMapper insuranceSchemeMapper = sqlSession.getMapper(InsuranceSchemeMapper.class); + InsuranceSchemeDetailMapper insuranceSchemeDetailMapper = sqlSession.getMapper(InsuranceSchemeDetailMapper.class); + + //查询是否存在福利方案 + InsuranceSchemePO insuranceSchemePO = getById(updateParam.getInsuranceScheme().getId()); + if (Objects.isNull(insuranceSchemePO)) { + throw new SalaryRunTimeException("福利方案不存在"); + } + //去除入参中方案名称的空格 + updateParam.getInsuranceScheme().setSchemeName(StringUtils.trim(updateParam.getInsuranceScheme().getSchemeName())); + //福利方案名称重复 + List insuranceSchemePOList = insuranceSchemeMapper.listByName(updateParam.getInsuranceScheme().getSchemeName()); + if (CollectionUtils.isNotEmpty(insuranceSchemePOList)) { + boolean repeat = insuranceSchemePOList.stream().anyMatch(item -> !Objects.equals(item.getId(), updateParam.getInsuranceScheme().getId())); + SalaryAssert.isTrue(!repeat, "福利方案名称重复"); + } + + if (insuranceSchemePO.getSharedType() == null) { + insuranceSchemePO.setSharedType(SharedTypeEnum.PUBLIC.getValue()); + } else { + if (insuranceSchemePO.getSharedType().equals(SharedTypeEnum.PRIVATE.getValue()) && StringUtils.isBlank(insuranceSchemePO.getTaxAgentIds())) { + throw new SalaryRunTimeException("方案可见性为私有时,未设置可见范围"); + } + } + + //更新福利方案主表 + InsuranceSchemePO insuranceSchemePO1 = InsuranceSchemeBO.buildInsuranceSchemePO(insuranceSchemePO, updateParam.getInsuranceScheme()); + insuranceSchemeMapper.update(insuranceSchemePO1); + + //更新福利方案明细表 先删后插 + insuranceSchemeDetailMapper.batchDeleteByPrimaryIds(Collections.singleton(updateParam.getInsuranceScheme().getId())); + //更新明细表 + List insuranceSchemeDetailPOS = InsuranceSchemeBO.convertToInsuranceSchemeDetailPoList(updateParam.getInsuranceSchemeDetailList(), employeeId, insuranceSchemePO.getId()); + encryptUtil.encryptList(insuranceSchemeDetailPOS, InsuranceSchemeDetailPO.class); + insuranceSchemeDetailPOS.forEach(insuranceSchemeDetailMapper::insert); + + //记录操作日志 + + sqlSession.commit(); + } finally { + sqlSession.close(); + } + + } + + /** + * 复制方案 + * + * @param id + * @param schemeName + * @param employeeId + */ + public void copy(Long id, String schemeName, long employeeId) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + InsuranceSchemeMapper insuranceSchemeMapper = sqlSession.getMapper(InsuranceSchemeMapper.class); + //去除入参中方案名称的空格 + schemeName = StringUtils.trim(schemeName); + + List listResult = insuranceSchemeMapper.listByName(schemeName); + SalaryAssert.isEmpty(listResult, "方案名称重复"); + + InsuranceSchemeDetailMapper insuranceSchemeDetailMapper = sqlSession.getMapper(InsuranceSchemeDetailMapper.class); + if (Objects.isNull(id)) { + throw new SalaryRunTimeException("方案id为空"); + } + + if (Objects.isNull(schemeName)) { + throw new SalaryRunTimeException("复制方案名为空"); + } + + InsuranceSchemePO insuranceSchemePO = getById(id); + if (Objects.isNull(insuranceSchemePO)) { + throw new SalaryRunTimeException("方案不存在"); + } + + if (insuranceSchemePO.getSchemeName().equals(schemeName)) { + throw new SalaryRunTimeException("方案名称重复"); + } + + InsuranceSchemePO batchPO = InsuranceSchemePO.builder() + .creator(employeeId) + .createTime(new Date()) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .schemeName(schemeName) + .paymentArea(insuranceSchemePO.getPaymentArea()) + .updateTime(new Date()) + .deleteType(DeleteTypeEnum.NOT_DELETED.getValue()) + .paymentType(insuranceSchemePO.getPaymentType()) + .remarks(insuranceSchemePO.getRemarks()) + .welfareType(insuranceSchemePO.getWelfareType()) + .isUse(insuranceSchemePO.getIsUse()) + .build(); + insuranceSchemeMapper.insert(batchPO); + + List detailList = insuranceSchemeDetailMapper.queryListBySchemeId(id); + detailList = encryptUtil.decryptList(detailList,InsuranceSchemeDetailPO.class); + if (CollectionUtils.isNotEmpty(detailList)) { + List detailPOS = detailList.stream().map(item -> InsuranceSchemeDetailPO.builder() + .creator(employeeId) + .createTime(new Date()) + .deleteType(DeleteTypeEnum.NOT_DELETED.getValue()) + .effectiveTime(item.getEffectiveTime()) + .expirationTime(item.getExpirationTime()) + .fixedCost(item.getFixedCost()) + .insuranceId(item.getInsuranceId()) + .isPayment(item.getIsPayment()) + .lowerLimit(item.getLowerLimit()) + .paymentScope(item.getPaymentScope()) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .paymentProportion(item.getPaymentProportion()) + .updateTime(new Date()) + .primaryId(batchPO.getId()) + .rententionRule(item.getRententionRule()) + .upperLimit(item.getUpperLimit()) + .validNum(item.getValidNum()==null?2:item.getValidNum()) + .build() + ).collect(Collectors.toList()); + encryptUtil.encryptList(detailPOS, InsuranceSchemeDetailPO.class); + detailPOS.forEach(insuranceSchemeDetailMapper::insert); + } + + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + /** + * 根据险种id和是否缴费查询社保方案明细表 + * + * @param insuranceId 险种id + * @param isPayment 是否缴费 + * @return list + */ + public List queryListByInsuranceIdIsPayment(Long insuranceId, Integer isPayment) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + InsuranceSchemeDetailMapper insuranceSchemeDetailMapper = sqlSession.getMapper(InsuranceSchemeDetailMapper.class); + List insuranceSchemeDetailPOList = insuranceSchemeDetailMapper.queryListByInsuranceIdIsPayment(insuranceId, isPayment); + encryptUtil.decryptList(insuranceSchemeDetailPOList, InsuranceSchemeDetailPO.class); + return insuranceSchemeDetailPOList; + } finally { + sqlSession.close(); + } + + } + + public int checkBeforeDeleteSocialscheme(Map params) { + return getSIAccountUtilMapper().checkBeforeDeleteSocialscheme((Collection) params.get("ids")).get(0).getNum(); + } + + public int checkBeforeDeleteAccumulationfund(Map params) { + return getSIAccountUtilMapper().checkBeforeDeleteAccumulationfund((Collection) params.get("ids")).get(0).getNum(); + } + + public int checkBeforeDeleteOtherscheme(Map params) { + return getSIAccountUtilMapper().checkBeforeDeleteOtherscheme((Collection) params.get("ids")).get(0).getNum(); + } + + public int checkBeforeDeleteBill(Map params, Integer welfareTypeId) { + return getSIAccountUtilMapper().checkBeforeDeleteBill((Collection) params.get("ids"), welfareTypeId).get(0).getNum(); + } + + public void deleteSocialscheme(Map params) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + + InsuranceSchemeDetailMapper insuranceSchemeDetailMapper = sqlSession.getMapper(InsuranceSchemeDetailMapper.class); + InsuranceSchemeMapper insuranceSchemeMapper = sqlSession.getMapper(InsuranceSchemeMapper.class); + + insuranceSchemeMapper.deleteByIds((Collection) params.get("ids")); + insuranceSchemeDetailMapper.deleteByIds((Collection) params.get("ids")); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + +} diff --git a/src/com/engine/salary/biz/SalaryArchiveBiz.java b/src/com/engine/salary/biz/SalaryArchiveBiz.java new file mode 100644 index 000000000..fffb22ac3 --- /dev/null +++ b/src/com/engine/salary/biz/SalaryArchiveBiz.java @@ -0,0 +1,66 @@ +package com.engine.salary.biz; + +import com.engine.salary.entity.salaryarchive.po.SalaryArchivePO; +import com.engine.salary.mapper.archive.SalaryArchiveMapper; +import com.google.common.collect.Lists; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.ibatis.session.SqlSession; +import weaver.conn.mybatis.MyBatisFactory; + +import java.util.List; + +public class SalaryArchiveBiz { + + public SalaryArchivePO getById(Long salaryArchiveId) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalaryArchiveMapper mapper = sqlSession.getMapper(SalaryArchiveMapper.class); + return mapper.getById(salaryArchiveId); + } finally { + sqlSession.close(); + } + } + + + public void batchInsert(List salaryArchiveSaves) { + if (CollectionUtils.isEmpty(salaryArchiveSaves)) { + return; + } + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalaryArchiveMapper mapper = sqlSession.getMapper(SalaryArchiveMapper.class); + List> partition = Lists.partition(salaryArchiveSaves, 100); + partition.forEach(mapper::batchInsert); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + public void batchDeleteHistoryData(SalaryArchivePO build) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalaryArchiveMapper mapper = sqlSession.getMapper(SalaryArchiveMapper.class); + mapper.batchDeleteHistoryData(build); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + + public void batchUpdate(List list) { + if (CollectionUtils.isEmpty(list)) { + return; + } + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalaryArchiveMapper mapper = sqlSession.getMapper(SalaryArchiveMapper.class); + List> partition = Lists.partition(list, 100); + partition.forEach(mapper::batchUpdate); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } +} diff --git a/src/com/engine/salary/biz/SalaryArchiveDimissionBiz.java b/src/com/engine/salary/biz/SalaryArchiveDimissionBiz.java new file mode 100644 index 000000000..3e1a623f5 --- /dev/null +++ b/src/com/engine/salary/biz/SalaryArchiveDimissionBiz.java @@ -0,0 +1,42 @@ +package com.engine.salary.biz; + +import com.engine.salary.entity.salaryarchive.po.SalaryArchiveDimissionPO; +import com.engine.salary.mapper.archive.SalaryArchiveDimissionMapper; +import org.apache.ibatis.session.SqlSession; +import weaver.conn.mybatis.MyBatisFactory; + +import java.util.List; + +public class SalaryArchiveDimissionBiz { + public List dimissionSets() { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalaryArchiveDimissionMapper mapper = sqlSession.getMapper(SalaryArchiveDimissionMapper.class); + return mapper.listAll(); + } finally { + sqlSession.close(); + } + } + + public void updateById(SalaryArchiveDimissionPO po) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalaryArchiveDimissionMapper mapper = sqlSession.getMapper(SalaryArchiveDimissionMapper.class); + mapper.updateIgnoreNull(po); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + public void insert(SalaryArchiveDimissionPO build) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalaryArchiveDimissionMapper mapper = sqlSession.getMapper(SalaryArchiveDimissionMapper.class); + mapper.insertIgnoreNull(build); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } +} diff --git a/src/com/engine/salary/biz/SalaryArchiveItemBiz.java b/src/com/engine/salary/biz/SalaryArchiveItemBiz.java new file mode 100644 index 000000000..527b6b3b2 --- /dev/null +++ b/src/com/engine/salary/biz/SalaryArchiveItemBiz.java @@ -0,0 +1,251 @@ +package com.engine.salary.biz; + +import com.engine.salary.config.SalaryElogConfig; +import com.engine.salary.encrypt.EncryptUtil; +import com.engine.salary.entity.salaryarchive.dto.SalaryItemAdjustRecordListDTO; +import com.engine.salary.entity.salaryarchive.param.SalaryArchiveItemQueryParam; +import com.engine.salary.entity.salaryarchive.param.SalaryItemAdjustRecordQueryParam; +import com.engine.salary.entity.salaryarchive.po.SalaryArchiveItemPO; +import com.engine.salary.mapper.archive.SalaryArchiveItemMapper; +import com.engine.salary.util.SalaryDateUtil; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.SalaryLoggerUtil; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.util.page.SalaryPageUtil; +import com.google.common.collect.Lists; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.ibatis.session.SqlSession; +import weaver.conn.mybatis.MyBatisFactory; +import weaver.hrm.User; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +public class SalaryArchiveItemBiz { + public EncryptUtil encryptUtil = new EncryptUtil(); + + public List getCurrentEffectiveItemList(SalaryArchiveItemQueryParam build) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalaryArchiveItemMapper mapper = sqlSession.getMapper(SalaryArchiveItemMapper.class); + List salaryArchiveItemPOS = mapper.listByParam(build); + return encryptUtil.decryptList(salaryArchiveItemPOS, SalaryArchiveItemPO.class); + } finally { + sqlSession.close(); + } + } + + public List listByParam(SalaryArchiveItemQueryParam build) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalaryArchiveItemMapper mapper = sqlSession.getMapper(SalaryArchiveItemMapper.class); + if (CollectionUtils.isNotEmpty(build.getEmployeeIds())) { + List salaryArchiveItemPOS = new ArrayList<>(); + List> partition = Lists.partition((List) build.getEmployeeIds(), 500); + partition.forEach(l -> { + build.setEmployeeIds(l); + salaryArchiveItemPOS.addAll(mapper.listByParam(build)); + }); + return encryptUtil.decryptList(salaryArchiveItemPOS, SalaryArchiveItemPO.class); + } else { + List salaryArchiveItemPOS = mapper.listByParam(build); + return encryptUtil.decryptList(salaryArchiveItemPOS, SalaryArchiveItemPO.class); + } + } finally { + sqlSession.close(); + } + } + + public SalaryArchiveItemPO getById(Long salaryArchiveItemId) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalaryArchiveItemMapper mapper = sqlSession.getMapper(SalaryArchiveItemMapper.class); + return encryptUtil.decrypt(mapper.getById(salaryArchiveItemId), SalaryArchiveItemPO.class); + } finally { + sqlSession.close(); + } + } + + public List getIneffectiveSalaryItems(SalaryArchiveItemQueryParam build) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalaryArchiveItemMapper mapper = sqlSession.getMapper(SalaryArchiveItemMapper.class); + List ineffectiveSalaryItems = new ArrayList<>(); + if (CollectionUtils.isNotEmpty(build.getSalaryArchivesIds())) { + List salaryArchivesIds = (List) build.getSalaryArchivesIds(); + List> partition = Lists.partition(salaryArchivesIds, 1000); + partition.forEach(list -> { + build.setSalaryArchivesIds(list); + ineffectiveSalaryItems.addAll(mapper.getIneffectiveSalaryItems(build)); + }); + } + return encryptUtil.decryptList(ineffectiveSalaryItems, SalaryArchiveItemPO.class); + } finally { + sqlSession.close(); + } + } + + public List getEffectiveSalaryItems(SalaryArchiveItemQueryParam build) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalaryArchiveItemMapper mapper = sqlSession.getMapper(SalaryArchiveItemMapper.class); + List effectiveSalaryItems = mapper.getEffectiveSalaryItems(build); + return encryptUtil.decryptList(effectiveSalaryItems, SalaryArchiveItemPO.class); + } finally { + sqlSession.close(); + } + } + + public void deleteBatchIds(List effectiveSalaryItemDels) { + + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalaryArchiveItemMapper mapper = sqlSession.getMapper(SalaryArchiveItemMapper.class); + List> partition = Lists.partition(effectiveSalaryItemDels, 999); + partition.forEach(mapper::deleteBatchIds); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + public void batchInsert(List salaryArchiveItemNews, User user) { + if (CollectionUtils.isEmpty(salaryArchiveItemNews)) { + return; + } + + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalaryArchiveItemMapper mapper = sqlSession.getMapper(SalaryArchiveItemMapper.class); + encryptUtil.encryptList(salaryArchiveItemNews, SalaryArchiveItemPO.class); + List> partition = Lists.partition(salaryArchiveItemNews, 100); + partition.forEach(mapper::batchInsert); + sqlSession.commit(); + + // 记录日志 + List archiveIdList = salaryArchiveItemNews.stream().map(SalaryArchiveItemPO::getSalaryArchiveId).distinct().collect(Collectors.toList()); + List itemIdList = salaryArchiveItemNews.stream().map(SalaryArchiveItemPO::getSalaryItemId).distinct().collect(Collectors.toList()); + // 查出保存的id + List savePO = getIneffectiveSalaryItems(SalaryArchiveItemQueryParam.builder().salaryArchivesIds(archiveIdList).salaryItemIds(itemIdList).build()); + Map saveMap = SalaryEntityUtil.convert2Map(savePO, p -> p.getSalaryArchiveId() + p.getSalaryItemId() + SalaryDateUtil.getFormatDate(p.getEffectiveTime())); + String operateName = SalaryI18nUtil.getI18nLabel(0, "新增调薪记录"); + salaryArchiveItemNews.forEach(e -> { + SalaryArchiveItemPO archive = saveMap.getOrDefault(e.getSalaryArchiveId() + e.getSalaryItemId() + SalaryDateUtil.getFormatDate(e.getEffectiveTime()), SalaryArchiveItemPO.builder().build()); + SalaryLoggerUtil.recordAddSingleLog(SalaryElogConfig.salaryArchiveItemAdjustLoggerTemplate, + archive.getId(), + operateName + ":" + archive.getId(), + operateName, + operateName, + archive, + user); + }); + } finally { + sqlSession.close(); + } + } + + public void updateById(SalaryArchiveItemPO salaryArchiveItem) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalaryArchiveItemMapper mapper = sqlSession.getMapper(SalaryArchiveItemMapper.class); + encryptUtil.encrypt(salaryArchiveItem, SalaryArchiveItemPO.class); + mapper.update(salaryArchiveItem); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + + public void updateIgnoreNull(SalaryArchiveItemPO salaryArchiveItem) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalaryArchiveItemMapper mapper = sqlSession.getMapper(SalaryArchiveItemMapper.class); + encryptUtil.encrypt(salaryArchiveItem, SalaryArchiveItemPO.class); + mapper.updateIgnoreNull(salaryArchiveItem); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + + public List salaryItemAdjustRecordList(SalaryItemAdjustRecordQueryParam queryParam, List salaryItemIds) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalaryArchiveItemMapper mapper = sqlSession.getMapper(SalaryArchiveItemMapper.class); + List salaryArchiveIds = queryParam.getSalaryArchiveIds(); + if (CollectionUtils.isEmpty(salaryArchiveIds)) { + List salaryItemAdjustRecordListDTOS = mapper.salaryItemAdjustRecordList(queryParam, salaryItemIds); + return encryptUtil.decryptList(salaryItemAdjustRecordListDTOS, SalaryItemAdjustRecordListDTO.class); + } else { + List salaryItemAdjustRecordListDTOS = new ArrayList<>(); + List> salaryArchiveIdsPartition = Lists.partition(salaryArchiveIds, 500); + salaryArchiveIdsPartition.forEach(l -> { + queryParam.setSalaryArchiveIds(l); + salaryItemAdjustRecordListDTOS.addAll(mapper.salaryItemAdjustRecordList(queryParam, salaryItemIds)); + }); + return encryptUtil.decryptList(salaryItemAdjustRecordListDTOS, SalaryItemAdjustRecordListDTO.class); + } + + } finally { + sqlSession.close(); + } + } + + public void deleteBySalaryArchiveId(List salaryArchiveIds) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalaryArchiveItemMapper mapper = sqlSession.getMapper(SalaryArchiveItemMapper.class); + mapper.deleteBySalaryArchiveId(salaryArchiveIds); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + public PageInfo salaryItemAdjustRecordListPage(SalaryItemAdjustRecordQueryParam queryParam, List salaryItemIds) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalaryArchiveItemMapper mapper = sqlSession.getMapper(SalaryArchiveItemMapper.class); + + List salaryArchiveIds = queryParam.getSalaryArchiveIds(); + if (CollectionUtils.isEmpty(salaryArchiveIds)) { + List salaryItemAdjustRecordListDTOS = mapper.salaryItemAdjustRecordList(queryParam, salaryItemIds); + PageInfo page = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), + salaryItemAdjustRecordListDTOS, + SalaryItemAdjustRecordListDTO.class); + encryptUtil.decryptList(page.getList(), SalaryItemAdjustRecordListDTO.class); + return page; + } else { + List salaryItemAdjustRecordListDTOS = new ArrayList<>(); + List> salaryArchiveIdsPartition = Lists.partition(salaryArchiveIds, 500); + salaryArchiveIdsPartition.forEach(l -> { + queryParam.setSalaryArchiveIds(l); + salaryItemAdjustRecordListDTOS.addAll(mapper.salaryItemAdjustRecordList(queryParam, salaryItemIds)); + }); + PageInfo page = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), + salaryItemAdjustRecordListDTOS, + SalaryItemAdjustRecordListDTO.class); + encryptUtil.decryptList(page.getList(), SalaryItemAdjustRecordListDTO.class); + return page; + } + } finally { + sqlSession.close(); + } + } + + public void batchDeleteHistoryData(SalaryArchiveItemPO build) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalaryArchiveItemMapper mapper = sqlSession.getMapper(SalaryArchiveItemMapper.class); + mapper.batchDeleteHistoryData(build); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } +} diff --git a/src/com/engine/salary/biz/SalaryArchiveTaxAgentBiz.java b/src/com/engine/salary/biz/SalaryArchiveTaxAgentBiz.java new file mode 100644 index 000000000..09c2ea669 --- /dev/null +++ b/src/com/engine/salary/biz/SalaryArchiveTaxAgentBiz.java @@ -0,0 +1,93 @@ +package com.engine.salary.biz; + +import com.engine.salary.entity.salaryarchive.param.SalaryArchiveTaxAgentQueryParam; +import com.engine.salary.entity.salaryarchive.po.SalaryArchiveTaxAgentPO; +import com.engine.salary.mapper.archive.SalaryArchiveTaxAgentMapper; +import com.google.common.collect.Lists; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.ibatis.session.SqlSession; +import weaver.conn.mybatis.MyBatisFactory; + +import java.util.List; + +public class SalaryArchiveTaxAgentBiz { + + public List listByParam(SalaryArchiveTaxAgentQueryParam build) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalaryArchiveTaxAgentMapper mapper = sqlSession.getMapper(SalaryArchiveTaxAgentMapper.class); + return mapper.listByParam(build); + } finally { + sqlSession.close(); + } + } + + public void deleteBySalaryArchiveId(List salaryArchiveIds) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalaryArchiveTaxAgentMapper mapper = sqlSession.getMapper(SalaryArchiveTaxAgentMapper.class); + mapper.deleteBySalaryArchiveId(salaryArchiveIds); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + public List getEffectiveTaxAgentList(SalaryArchiveTaxAgentQueryParam build) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalaryArchiveTaxAgentMapper mapper = sqlSession.getMapper(SalaryArchiveTaxAgentMapper.class); + return mapper.getEffectiveTaxAgentList(build); + } finally { + sqlSession.close(); + } + } + + public List getIneffectiveTaxAgentList(SalaryArchiveTaxAgentQueryParam build) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalaryArchiveTaxAgentMapper mapper = sqlSession.getMapper(SalaryArchiveTaxAgentMapper.class); + return mapper.getIneffectiveTaxAgentList(build); + } finally { + sqlSession.close(); + } + } + + public void deleteBatchIds(List ids) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalaryArchiveTaxAgentMapper mapper = sqlSession.getMapper(SalaryArchiveTaxAgentMapper.class); + mapper.deleteBatchIds(ids); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + public void batchInsert(List salaryArchiveTaxAgentSaves) { + if (CollectionUtils.isEmpty(salaryArchiveTaxAgentSaves)) { + return; + } + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalaryArchiveTaxAgentMapper mapper = sqlSession.getMapper(SalaryArchiveTaxAgentMapper.class); + List> partition = Lists.partition(salaryArchiveTaxAgentSaves, 100); + partition.forEach(mapper::batchInsert); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + + } + + public void batchDeleteHistoryData(SalaryArchiveTaxAgentPO build) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalaryArchiveTaxAgentMapper mapper = sqlSession.getMapper(SalaryArchiveTaxAgentMapper.class); + mapper.batchDeleteHistoryData(build); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } +} diff --git a/src/com/engine/salary/biz/SalaryItemBiz.java b/src/com/engine/salary/biz/SalaryItemBiz.java new file mode 100644 index 000000000..f18611ff2 --- /dev/null +++ b/src/com/engine/salary/biz/SalaryItemBiz.java @@ -0,0 +1,157 @@ +package com.engine.salary.biz; + +import com.engine.salary.entity.salaryitem.param.SalaryItemSearchParam; +import com.engine.salary.entity.salaryitem.po.SalaryItemPO; +import com.engine.salary.enums.SalaryOnOffEnum; +import com.engine.salary.mapper.salaryitem.SalaryItemMapper; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.util.page.SalaryPageUtil; +import com.google.common.collect.Lists; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.ibatis.session.SqlSession; +import weaver.conn.mybatis.MyBatisFactory; + +import java.util.Collection; +import java.util.List; + +public class SalaryItemBiz { + + public SalaryItemPO getById(Long id) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalaryItemMapper mapper = sqlSession.getMapper(SalaryItemMapper.class); + return mapper.getById(id); + } finally { + sqlSession.close(); + } + } + + public List listAll() { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalaryItemMapper mapper = sqlSession.getMapper(SalaryItemMapper.class); + return mapper.listAll(); + } finally { + sqlSession.close(); + } + } + + public List listSome(SalaryItemPO build) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalaryItemMapper mapper = sqlSession.getMapper(SalaryItemMapper.class); + return mapper.listSome(build); + } finally { + sqlSession.close(); + } + } + + public void batchSave(Collection salaryItems) { + if (CollectionUtils.isEmpty(salaryItems)) { + return; + } + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalaryItemMapper mapper = sqlSession.getMapper(SalaryItemMapper.class); + List> partition = Lists.partition((List) salaryItems, 100); + partition.forEach(mapper::batchInsert); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + public void insert(SalaryItemPO salaryItemPO) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalaryItemMapper mapper = sqlSession.getMapper(SalaryItemMapper.class); + mapper.insertIgnoreNull(salaryItemPO); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + public void updateById(SalaryItemPO newSalaryItemPO) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalaryItemMapper mapper = sqlSession.getMapper(SalaryItemMapper.class); + mapper.updateIgnoreNull(newSalaryItemPO); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + public void deleteByIds(Collection ids) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalaryItemMapper mapper = sqlSession.getMapper(SalaryItemMapper.class); + mapper.deleteByIds(ids); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + public PageInfo listPageByParam(SalaryItemSearchParam searchParam) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalaryItemMapper mapper = sqlSession.getMapper(SalaryItemMapper.class); + List salaryItemPOList = mapper.listByParam(searchParam); + return SalaryPageUtil.buildPage(searchParam.getCurrent(), searchParam.getPageSize(), + salaryItemPOList, SalaryItemPO.class); + } finally { + sqlSession.close(); + } + + } + + public List listByParam(SalaryItemSearchParam searchParam) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalaryItemMapper mapper = sqlSession.getMapper(SalaryItemMapper.class); + return mapper.listByParam(searchParam); + } finally { + sqlSession.close(); + } + } + + public List getCanAdjustSalaryItems() { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalaryItemMapper mapper = sqlSession.getMapper(SalaryItemMapper.class); + return mapper.listSome(SalaryItemPO.builder().useInEmployeeSalary(SalaryOnOffEnum.ON.getValue()).build()); + } finally { + sqlSession.close(); + } + + } + + + public void batchUpdateSortedIndex(List list) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalaryItemMapper mapper = sqlSession.getMapper(SalaryItemMapper.class); + List> partition = (List>)Lists.partition(list, 100); + partition.forEach(mapper::batchUpdateSortedIndex); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + + public List listByParamOrderById(SalaryItemSearchParam searchParam) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalaryItemMapper mapper = sqlSession.getMapper(SalaryItemMapper.class); + return mapper.listByParamOrderById(searchParam); + } finally { + sqlSession.close(); + } + } + + + +} diff --git a/src/com/engine/salary/biz/SalarySendBiz.java b/src/com/engine/salary/biz/SalarySendBiz.java new file mode 100644 index 000000000..6af3ae366 --- /dev/null +++ b/src/com/engine/salary/biz/SalarySendBiz.java @@ -0,0 +1,121 @@ +package com.engine.salary.biz; + +import com.engine.salary.entity.salaryBill.dto.SalarySendListDTO; +import com.engine.salary.entity.salaryBill.param.SalarySendQueryParam; +import com.engine.salary.entity.salaryBill.po.SalarySendPO; +import com.engine.salary.mapper.salarybill.SalarySendMapper; +import org.apache.ibatis.session.SqlSession; +import weaver.conn.mybatis.MyBatisFactory; + +import java.util.List; +import java.util.Map; + +public class SalarySendBiz { + /** + * 根据id获取数据 + * @param id + * @return + */ + public SalarySendPO getById(Long id) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySendMapper mapper = sqlSession.getMapper(SalarySendMapper.class); + return mapper.getById(id); + } finally { + sqlSession.close(); + } + } + + + /** + * 更新 + * @param salarySendNew + */ + public void updateById(SalarySendPO salarySendNew) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySendMapper mapper = sqlSession.getMapper(SalarySendMapper.class); + mapper.updateIgnoreNull(salarySendNew); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + /** + * 根据查询条件查询 + * @param condition + */ + public List listSomeWithCondition(Map condition) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySendMapper mapper = sqlSession.getMapper(SalarySendMapper.class); + return mapper.listSomeWithCondition(condition); + } finally { + sqlSession.close(); + } + } + + /** + * 根据现有字段查询 + * @return + */ + public List listSome(SalarySendPO po) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySendMapper mapper = sqlSession.getMapper(SalarySendMapper.class); + return mapper.listSome(po); + } finally { + sqlSession.close(); + } + } + + + /** + * 工资单发放列表(分页) + * @param queryParam + * @return + */ + public List list(SalarySendQueryParam queryParam) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySendMapper mapper = sqlSession.getMapper(SalarySendMapper.class); + return mapper.list(queryParam); + } finally { + sqlSession.close(); + } + } + + public void insert(SalarySendPO salarySend) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySendMapper mapper = sqlSession.getMapper(SalarySendMapper.class); + mapper.insertIgnoreNull(salarySend); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + public void batchHandleSendStatusHistory() { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySendMapper mapper = sqlSession.getMapper(SalarySendMapper.class); + mapper.batchHandleSendStatusHistory(); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + public void batchHandleSalaryAcctTypeHistory() { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySendMapper mapper = sqlSession.getMapper(SalarySendMapper.class); + mapper.batchHandleSalaryAcctTypeHistory(); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } +} diff --git a/src/com/engine/salary/biz/SalarySendInfoBiz.java b/src/com/engine/salary/biz/SalarySendInfoBiz.java new file mode 100644 index 000000000..df1bca38d --- /dev/null +++ b/src/com/engine/salary/biz/SalarySendInfoBiz.java @@ -0,0 +1,148 @@ +package com.engine.salary.biz; + +import com.engine.salary.entity.salaryBill.dto.SalaryMySalaryBillListDTO; +import com.engine.salary.entity.salaryBill.dto.SalarySendDetailListDTO; +import com.engine.salary.entity.salaryBill.dto.SalarySendInfoListDTO; +import com.engine.salary.entity.salaryBill.param.SalaryBillQueryParam; +import com.engine.salary.entity.salaryBill.param.SalarySendDetailQueryParam; +import com.engine.salary.entity.salaryBill.param.SalarySendInfoQueryParam; +import com.engine.salary.entity.salaryBill.po.SalarySendInfoPO; +import com.engine.salary.mapper.salarybill.SalarySendInfoMapper; +import com.engine.salary.util.SalaryI18nUtil; +import com.google.common.collect.Lists; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.session.SqlSession; +import weaver.conn.mybatis.MyBatisFactory; + +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Set; + +public class SalarySendInfoBiz { + /** + * 查询工资单发放信息列表 + */ + public List list(SalarySendInfoQueryParam param) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySendInfoMapper mapper = sqlSession.getMapper(SalarySendInfoMapper.class); + List list = mapper.list(param); + return SalaryI18nUtil.i18nList(list); + } finally { + sqlSession.close(); + } + } + + /** + * 工资单发放 + * + * @param po + * @param salarySendId + * @param statusList + * @param ids + */ + public void updateGrantWithdraw(SalarySendInfoPO po, Long salarySendId, List statusList, Collection ids) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySendInfoMapper mapper = sqlSession.getMapper(SalarySendInfoMapper.class); + mapper.updateGrantWithdraw(po, salarySendId, statusList, ids); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + + /** + * 根据现有字段查询 + * + * @param params + * @return + */ + public List listSome(@Param("param") SalarySendInfoPO params) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySendInfoMapper mapper = sqlSession.getMapper(SalarySendInfoMapper.class); + return mapper.listSome(params); + } finally { + sqlSession.close(); + } + } + + public void updateById(SalarySendInfoPO po) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySendInfoMapper mapper = sqlSession.getMapper(SalarySendInfoMapper.class); + mapper.updateIgnoreNull(po); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + /** + * 工资单发放详情列表 + * + * @param param + * @param otherSalaryAccRecordIds + * @return + */ + public List detailList(@Param("param") SalarySendDetailQueryParam param, + @Param("otherSalaryAccRecordIds") Set otherSalaryAccRecordIds) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySendInfoMapper mapper = sqlSession.getMapper(SalarySendInfoMapper.class); + List detailList = mapper.detailList(param, otherSalaryAccRecordIds); + SalaryI18nUtil.i18nList(detailList); + return detailList; + } finally { + sqlSession.close(); + } + } + + /** + * 我的工资单列表详情 + * + * @param queryParam + * @return + */ + public List mySalaryBillList(SalaryBillQueryParam queryParam) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySendInfoMapper mapper = sqlSession.getMapper(SalarySendInfoMapper.class); + return mapper.mySalaryBillList(queryParam); + } finally { + sqlSession.close(); + } + } + + public void batchInsert(List salarySendInfos) { + if (CollectionUtils.isEmpty(salarySendInfos)) { + return; + } + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySendInfoMapper mapper = sqlSession.getMapper(SalarySendInfoMapper.class); + List> partition = Lists.partition(salarySendInfos, 100); + partition.forEach(mapper::batchInsert); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + public List listSalaryAccRecordIds(SalarySendDetailQueryParam queryParam) { + if (null == queryParam) { + return Collections.emptyList(); + } + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySendInfoMapper mapper = sqlSession.getMapper(SalarySendInfoMapper.class); + return mapper.listSalaryAccRecordIds(queryParam); + } finally { + sqlSession.close(); + } + } +} diff --git a/src/com/engine/salary/biz/SalarySendRangeObjBiz.java b/src/com/engine/salary/biz/SalarySendRangeObjBiz.java new file mode 100644 index 000000000..53633dce6 --- /dev/null +++ b/src/com/engine/salary/biz/SalarySendRangeObjBiz.java @@ -0,0 +1,83 @@ +package com.engine.salary.biz; + +import com.engine.common.util.ServiceUtil; +import com.engine.salary.entity.salaryBill.dto.SalarySendUserInfoDTO; +import com.engine.salary.entity.salaryBill.po.SalarySendRangeObj; +import com.engine.salary.entity.taxagent.dto.TaxAgentEmployeeTaxAgentDTO; +import com.engine.salary.mapper.salarybill.SalarySendRangeObjMapper; +import com.engine.salary.service.TaxAgentService; +import com.engine.salary.service.impl.TaxAgentServiceImpl; +import com.engine.salary.util.db.MapperProxyFactory; +import com.google.common.collect.Lists; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.ibatis.session.SqlSession; +import weaver.conn.mybatis.MyBatisFactory; + +import java.util.*; +import java.util.function.Consumer; +import java.util.function.Function; +import java.util.stream.Collectors; + +import static com.engine.salary.constant.SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY; + +public class SalarySendRangeObjBiz { + private TaxAgentService getTaxAgentService() { + return ServiceUtil.getService(TaxAgentServiceImpl.class); + } + + private SalarySendRangeObjMapper getSalarySendRangeObjMapper() { + return MapperProxyFactory.getProxy(SalarySendRangeObjMapper.class); + } + + public R applyMapper(Function mapper) { + try (SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession()) { + final SalarySendRangeObjMapper salarySendRangeObjMapper = sqlSession.getMapper(SalarySendRangeObjMapper.class); + R apply = mapper.apply(salarySendRangeObjMapper); + sqlSession.commit(); + return apply; + } + } + + public void runMapper(Consumer mapper) { + try (SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession()) { + final SalarySendRangeObjMapper salarySendRangeObjMapper = sqlSession.getMapper(SalarySendRangeObjMapper.class); + mapper.accept(salarySendRangeObjMapper); + sqlSession.commit(); + } + } + + public List getSalarySendUserInfoDTOs(List employees) { + List userDTOs = new ArrayList<>(); + List> partition = Lists.partition(employees, 500); + partition.forEach(l->{ + List userInfos = getSalarySendRangeObjMapper().getUserInfoByEmployeeIds(l); + userDTOs.addAll(userInfos); + }); + + Map userMap = userDTOs.stream() + .collect(Collectors.toMap(SalarySendUserInfoDTO::getResourceId, Function.identity())); + + List employeeIds = userDTOs.stream() + .map(SalarySendUserInfoDTO::getResourceId) + .collect(Collectors.toList()); + Collection employeeAgents + = getTaxAgentService().listAllTaxAgentsAsRange(employeeIds); + for (TaxAgentEmployeeTaxAgentDTO employeeAgent : employeeAgents) { + SalarySendUserInfoDTO info = userMap.get(employeeAgent.getEmployeeId()); + if (info != null) { + if (CollectionUtils.isEmpty(info.getTaxAgentIds())) { + info.setTaxAgentIds(new ArrayList<>()); + } + info.getTaxAgentIds().addAll(Optional.ofNullable(employeeAgent.getTaxAgentIds()).orElse(Collections.emptyList())); + } + } + return userDTOs; + } + + public void replaceAllByRangeId(Long rangeId, List rangeObjs) { + runMapper(mapper -> { + mapper.deleteByRangeIds(Collections.singletonList(rangeId), DEFAULT_TENANT_KEY); + mapper.batchInsert(rangeObjs); + }); + } +} diff --git a/src/com/engine/salary/biz/SalarySobAdjustRuleBiz.java b/src/com/engine/salary/biz/SalarySobAdjustRuleBiz.java new file mode 100644 index 000000000..5e7963abd --- /dev/null +++ b/src/com/engine/salary/biz/SalarySobAdjustRuleBiz.java @@ -0,0 +1,50 @@ +package com.engine.salary.biz; + +import com.engine.salary.entity.salarysob.po.SalarySobAdjustRulePO; +import com.engine.salary.mapper.salarysob.SalarySobAdjustRuleMapper; +import com.google.common.collect.Lists; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.ibatis.session.SqlSession; +import weaver.conn.mybatis.MyBatisFactory; + +import java.util.Collection; +import java.util.List; + +public class SalarySobAdjustRuleBiz { + + public List listBySalarySobId(Long salarySobId) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySobAdjustRuleMapper mapper = sqlSession.getMapper(SalarySobAdjustRuleMapper.class); + return mapper.listSome(SalarySobAdjustRulePO.builder().salarySobId(salarySobId).build()); + } finally { + sqlSession.close(); + } + } + + public void deleteBySalarySobIds(Collection salarySobIds) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySobAdjustRuleMapper mapper = sqlSession.getMapper(SalarySobAdjustRuleMapper.class); + mapper.deleteBySalarySobIds(salarySobIds); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + public void batchInsert(Collection salarySobAdjustRulePOS) { + if (CollectionUtils.isEmpty(salarySobAdjustRulePOS)) { + return; + } + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySobAdjustRuleMapper mapper = sqlSession.getMapper(SalarySobAdjustRuleMapper.class); + List> partition = Lists.partition((List) salarySobAdjustRulePOS, 100); + partition.forEach(mapper::batchInsert); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } +} diff --git a/src/com/engine/salary/biz/SalarySobBiz.java b/src/com/engine/salary/biz/SalarySobBiz.java new file mode 100644 index 000000000..6c89a204d --- /dev/null +++ b/src/com/engine/salary/biz/SalarySobBiz.java @@ -0,0 +1,86 @@ +package com.engine.salary.biz; + +import com.engine.salary.entity.salarysob.po.SalarySobPO; +import com.engine.salary.mapper.salarysob.SalarySobMapper; +import org.apache.ibatis.session.SqlSession; +import weaver.conn.mybatis.MyBatisFactory; + +import java.util.Collection; +import java.util.List; + +public class SalarySobBiz { + public SalarySobPO getById(Long id) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySobMapper mapper = sqlSession.getMapper(SalarySobMapper.class); + return mapper.getById(id); + } finally { + sqlSession.close(); + } + } + + + public List listSome(SalarySobPO build) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySobMapper mapper = sqlSession.getMapper(SalarySobMapper.class); + return mapper.listSome(build); + } finally { + sqlSession.close(); + } + } + + public List listByParam(SalarySobPO build) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySobMapper mapper = sqlSession.getMapper(SalarySobMapper.class); + return mapper.listByParam(build); + } finally { + sqlSession.close(); + } + } + + public void insert(SalarySobPO salarySobPO) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySobMapper mapper = sqlSession.getMapper(SalarySobMapper.class); + mapper.insertIgnoreNull(salarySobPO); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + public void updateById(SalarySobPO newSalarySobPO) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySobMapper mapper = sqlSession.getMapper(SalarySobMapper.class); + mapper.updateIgnoreNull(newSalarySobPO); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + + } + + public void deleteByIds(Collection ids) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySobMapper mapper = sqlSession.getMapper(SalarySobMapper.class); + mapper.deleteByIds(ids); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + public List listByName(SalarySobPO build) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySobMapper mapper = sqlSession.getMapper(SalarySobMapper.class); + return mapper.listByName(build); + } finally { + sqlSession.close(); + } + } +} diff --git a/src/com/engine/salary/biz/SalarySobCheckRuleBiz.java b/src/com/engine/salary/biz/SalarySobCheckRuleBiz.java new file mode 100644 index 000000000..e11c3d37d --- /dev/null +++ b/src/com/engine/salary/biz/SalarySobCheckRuleBiz.java @@ -0,0 +1,109 @@ +package com.engine.salary.biz; + +import com.engine.salary.entity.salarysob.param.SalarySobCheckRuleQueryParam; +import com.engine.salary.entity.salarysob.po.SalarySobCheckRulePO; +import com.engine.salary.mapper.salarysob.SalarySobCheckRuleMapper; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.util.page.SalaryPageUtil; +import com.google.common.collect.Lists; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.ibatis.session.SqlSession; +import weaver.conn.mybatis.MyBatisFactory; + +import java.util.Collection; +import java.util.List; + +public class SalarySobCheckRuleBiz { + + + public SalarySobCheckRulePO getById(Long id) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySobCheckRuleMapper mapper = sqlSession.getMapper(SalarySobCheckRuleMapper.class); + return mapper.getById(id); + } finally { + sqlSession.close(); + } + } + + public List listSome(SalarySobCheckRulePO build) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySobCheckRuleMapper mapper = sqlSession.getMapper(SalarySobCheckRuleMapper.class); + return mapper.listSome(build); + } finally { + sqlSession.close(); + } + } + + public void deleteByIds(Collection ids) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySobCheckRuleMapper mapper = sqlSession.getMapper(SalarySobCheckRuleMapper.class); + mapper.deleteByIds(ids); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + public void updateById(SalarySobCheckRulePO newSalarySobCheckRulePO) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySobCheckRuleMapper mapper = sqlSession.getMapper(SalarySobCheckRuleMapper.class); + mapper.updateIgnoreNull(newSalarySobCheckRulePO); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + public void batchInsert(Collection salarySobCheckRulePOS) { + if(CollectionUtils.isEmpty(salarySobCheckRulePOS)){ + return; + } + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySobCheckRuleMapper mapper = sqlSession.getMapper(SalarySobCheckRuleMapper.class); + List> partition = Lists.partition((List) salarySobCheckRulePOS, 100); + partition.forEach(mapper::batchInsert); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + public void insert(SalarySobCheckRulePO salarySobCheckRulePO) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySobCheckRuleMapper mapper = sqlSession.getMapper(SalarySobCheckRuleMapper.class); + mapper.insertIgnoreNull(salarySobCheckRulePO); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + public void deleteBySalarySobIds(Collection salarySobIds) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySobCheckRuleMapper mapper = sqlSession.getMapper(SalarySobCheckRuleMapper.class); + mapper.deleteBySalarySobIds(salarySobIds); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + public PageInfo listPageByParam(SalarySobCheckRuleQueryParam param) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySobCheckRuleMapper mapper = sqlSession.getMapper(SalarySobCheckRuleMapper.class); + List list = mapper.listByParam(param); + return SalaryPageUtil.buildPage(param.getCurrent(), param.getPageSize(), + list, SalarySobCheckRulePO.class); + } finally { + sqlSession.close(); + } + } +} diff --git a/src/com/engine/salary/biz/SalarySobDefaultItemBiz.java b/src/com/engine/salary/biz/SalarySobDefaultItemBiz.java new file mode 100644 index 000000000..2270bd344 --- /dev/null +++ b/src/com/engine/salary/biz/SalarySobDefaultItemBiz.java @@ -0,0 +1,22 @@ +package com.engine.salary.biz; + +import com.engine.salary.entity.salarysob.po.SalarySobDefaultItemPO; +import com.engine.salary.mapper.salarysob.SalarySobDefaultItemMapper; +import org.apache.ibatis.session.SqlSession; +import weaver.conn.mybatis.MyBatisFactory; + +import java.util.List; + +public class SalarySobDefaultItemBiz { + + + public List listByIncomeCategory(SalarySobDefaultItemPO build) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySobDefaultItemMapper mapper = sqlSession.getMapper(SalarySobDefaultItemMapper.class); + return mapper.listSome(build); + } finally { + sqlSession.close(); + } + } +} diff --git a/src/com/engine/salary/biz/SalarySobDefaultItemGroupBiz.java b/src/com/engine/salary/biz/SalarySobDefaultItemGroupBiz.java new file mode 100644 index 000000000..e9cde90f0 --- /dev/null +++ b/src/com/engine/salary/biz/SalarySobDefaultItemGroupBiz.java @@ -0,0 +1,23 @@ +package com.engine.salary.biz; + +import com.engine.salary.entity.salarysob.po.SalarySobDefaultItemGroupPO; +import com.engine.salary.enums.salarysob.IncomeCategoryEnum; +import com.engine.salary.mapper.salarysob.SalarySobDefaultItemGroupMapper; +import org.apache.ibatis.session.SqlSession; +import weaver.conn.mybatis.MyBatisFactory; + +import java.util.List; + +public class SalarySobDefaultItemGroupBiz { + + public List listByIncomeCategory(IncomeCategoryEnum incomeCategory) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySobDefaultItemGroupMapper mapper = sqlSession.getMapper(SalarySobDefaultItemGroupMapper.class); + return mapper.listSome(SalarySobDefaultItemGroupPO.builder().incomeCategory(incomeCategory.getValue()).build()); + } finally { + sqlSession.close(); + } + } + +} diff --git a/src/com/engine/salary/biz/SalarySobEmpFieldBiz.java b/src/com/engine/salary/biz/SalarySobEmpFieldBiz.java new file mode 100644 index 000000000..5fd662e47 --- /dev/null +++ b/src/com/engine/salary/biz/SalarySobEmpFieldBiz.java @@ -0,0 +1,88 @@ +package com.engine.salary.biz; + +import com.engine.salary.entity.salarysob.po.SalarySobDefaultEmpFieldPO; +import com.engine.salary.entity.salarysob.po.SalarySobEmpFieldPO; +import com.engine.salary.mapper.salarysob.SalarySobDefaultEmpFieldMapper; +import com.engine.salary.mapper.salarysob.SalarySobEmpFieldMapper; +import com.google.common.collect.Lists; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.ibatis.session.SqlSession; +import weaver.conn.mybatis.MyBatisFactory; + +import java.util.Collection; +import java.util.List; + +public class SalarySobEmpFieldBiz { + + + public List listSome(SalarySobEmpFieldPO build) { + + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySobEmpFieldMapper mapper = sqlSession.getMapper(SalarySobEmpFieldMapper.class); + return mapper.listSome(build); + + } finally { + sqlSession.close(); + } + } + + public void batchInsert(Collection salarySobEmpFieldPOS) { + if (CollectionUtils.isEmpty(salarySobEmpFieldPOS)) { + return; + } + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySobEmpFieldMapper mapper = sqlSession.getMapper(SalarySobEmpFieldMapper.class); + List> partition = Lists.partition((List) salarySobEmpFieldPOS, 100); + partition.forEach(mapper::batchInsert); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + public void deleteBySalarySobIds(Collection salarySobIds) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySobEmpFieldMapper mapper = sqlSession.getMapper(SalarySobEmpFieldMapper.class); + mapper.deleteBySalarySobIds(salarySobIds); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + + public void deleteByIds(Collection ids) { + + if (CollectionUtils.isEmpty(ids)) { + return; + } + + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySobEmpFieldMapper mapper = sqlSession.getMapper(SalarySobEmpFieldMapper.class); + mapper.deleteByIds(ids); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + + //---------------------------系统默认员工信息字段----------------------------------- + + public List listDefaultEmpField() { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySobDefaultEmpFieldMapper mapper = sqlSession.getMapper(SalarySobDefaultEmpFieldMapper.class); + return mapper.listAll(); + } finally { + sqlSession.close(); + } + } + + + +} diff --git a/src/com/engine/salary/biz/SalarySobItemBiz.java b/src/com/engine/salary/biz/SalarySobItemBiz.java new file mode 100644 index 000000000..233eae306 --- /dev/null +++ b/src/com/engine/salary/biz/SalarySobItemBiz.java @@ -0,0 +1,134 @@ +package com.engine.salary.biz; + +import com.engine.salary.entity.salarysob.po.SalarySobItemPO; +import com.engine.salary.mapper.salarysob.SalarySobItemMapper; +import com.google.common.collect.Lists; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.ibatis.session.SqlSession; +import weaver.conn.mybatis.MyBatisFactory; + +import java.util.Collection; +import java.util.List; +import java.util.Objects; + +public class SalarySobItemBiz { + + public List listAll() { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySobItemMapper mapper = sqlSession.getMapper(SalarySobItemMapper.class); + return mapper.listAll(); + } finally { + sqlSession.close(); + } + } + + public List listSome(SalarySobItemPO build) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySobItemMapper mapper = sqlSession.getMapper(SalarySobItemMapper.class); + return mapper.listSome(build); + } finally { + sqlSession.close(); + } + } + + + public void batchInsert(Collection salarySobItemPOS) { + if (CollectionUtils.isEmpty(salarySobItemPOS)) { + return; + } + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySobItemMapper mapper = sqlSession.getMapper(SalarySobItemMapper.class); + List> partition = Lists.partition((List) salarySobItemPOS, 100); + partition.forEach(mapper::batchInsert); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + + public void deleteBySalarySobIds(Collection salarySobIds) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySobItemMapper mapper = sqlSession.getMapper(SalarySobItemMapper.class); + mapper.deleteBySalarySobIds(salarySobIds); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + public void deleteItemShowBySalarySobId(Collection salarySobIds) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySobItemMapper mapper = sqlSession.getMapper(SalarySobItemMapper.class); + mapper.deleteItemShowBySalarySobId(salarySobIds); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + + + public List listBySalarySobIdAndGroupId(Long salarySobId, Collection salarySobItemGroupIds) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySobItemMapper mapper = sqlSession.getMapper(SalarySobItemMapper.class); + return mapper.listBySalarySobIdAndGroupId(salarySobId, salarySobItemGroupIds); + } finally { + sqlSession.close(); + } + } + + + public void deleteByIds(List ids) { + + if (CollectionUtils.isEmpty(ids)) { + return; + } + + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySobItemMapper mapper = sqlSession.getMapper(SalarySobItemMapper.class); + mapper.deleteByIds(ids); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + public void deleteByGroupIds(List needDeleteGroupIds) { + if (CollectionUtils.isEmpty(needDeleteGroupIds)) { + return; + } + + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySobItemMapper mapper = sqlSession.getMapper(SalarySobItemMapper.class); + mapper.deleteByGroupIds(needDeleteGroupIds); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + + } + + + public void update(SalarySobItemPO salarySobItemPO) { + if (Objects.isNull(salarySobItemPO)) { + return; + } + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySobItemMapper mapper = sqlSession.getMapper(SalarySobItemMapper.class); + mapper.updateIgnoreNull(salarySobItemPO); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } +} diff --git a/src/com/engine/salary/biz/SalarySobItemGroupBiz.java b/src/com/engine/salary/biz/SalarySobItemGroupBiz.java new file mode 100644 index 000000000..781c60a72 --- /dev/null +++ b/src/com/engine/salary/biz/SalarySobItemGroupBiz.java @@ -0,0 +1,94 @@ +package com.engine.salary.biz; + +import com.engine.salary.entity.salarysob.po.SalarySobItemGroupPO; +import com.engine.salary.mapper.salarysob.SalarySobItemGroupMapper; +import org.apache.commons.collections.CollectionUtils; +import org.apache.ibatis.session.SqlSession; +import weaver.conn.mybatis.MyBatisFactory; + +import java.util.Collection; +import java.util.List; + +public class SalarySobItemGroupBiz { + + public SalarySobItemGroupPO getById(Long id) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySobItemGroupMapper mapper = sqlSession.getMapper(SalarySobItemGroupMapper.class); + return mapper.getById(id); + } finally { + sqlSession.close(); + } + } + + public List listSome(SalarySobItemGroupPO build) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySobItemGroupMapper mapper = sqlSession.getMapper(SalarySobItemGroupMapper.class); + return mapper.listSome(build); + } finally { + sqlSession.close(); + } + } + + public void batchInsert(Collection salarySobItemGroupPOS) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySobItemGroupMapper mapper = sqlSession.getMapper(SalarySobItemGroupMapper.class); + mapper.batchInsert(salarySobItemGroupPOS); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + public void insert(SalarySobItemGroupPO po) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySobItemGroupMapper mapper = sqlSession.getMapper(SalarySobItemGroupMapper.class); + mapper.insertIgnoreNull(po); + } finally { + sqlSession.commit(); + sqlSession.close(); + } + } + + public void deleteBySalarySobIds(Collection salarySobIds) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySobItemGroupMapper mapper = sqlSession.getMapper(SalarySobItemGroupMapper.class); + mapper.deleteBySalarySobIds(salarySobIds); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + + public void deleteByIds(List ids) { + + if (CollectionUtils.isEmpty(ids)) { + return; + } + + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySobItemGroupMapper mapper = sqlSession.getMapper(SalarySobItemGroupMapper.class); + mapper.deleteByIds(ids); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + public void update(SalarySobItemGroupPO po) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySobItemGroupMapper mapper = sqlSession.getMapper(SalarySobItemGroupMapper.class); + mapper.updateIgnoreNull(po); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } +} diff --git a/src/com/engine/salary/biz/SalarySobItemHideBiz.java b/src/com/engine/salary/biz/SalarySobItemHideBiz.java new file mode 100644 index 000000000..5aa0f5a77 --- /dev/null +++ b/src/com/engine/salary/biz/SalarySobItemHideBiz.java @@ -0,0 +1,66 @@ +package com.engine.salary.biz; + +import com.engine.salary.entity.salarysob.po.SalarySobItemHidePO; +import com.engine.salary.mapper.salarysob.SalarySobItemHideMapper; +import org.apache.ibatis.session.SqlSession; +import weaver.conn.mybatis.MyBatisFactory; + +import java.util.Collection; +import java.util.List; + +public class SalarySobItemHideBiz { + + public List listHideItemIds(SalarySobItemHidePO salarySobPO) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySobItemHideMapper mapper = sqlSession.getMapper(SalarySobItemHideMapper.class); + return mapper.listHideItemIds(salarySobPO); + } finally { + sqlSession.close(); + } + } + + public void deleteBySalarySobIds(Collection ids) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySobItemHideMapper mapper = sqlSession.getMapper(SalarySobItemHideMapper.class); + mapper.deleteBySalarySobIds(ids); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + public void update(SalarySobItemHidePO salarySobGroupItemHidePO) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySobItemHideMapper mapper = sqlSession.getMapper(SalarySobItemHideMapper.class); + mapper.update(salarySobGroupItemHidePO); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + + } + + public void updateByItemId(SalarySobItemHidePO salarySobGroupItemHidePO) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySobItemHideMapper mapper = sqlSession.getMapper(SalarySobItemHideMapper.class); + mapper.updateByItemId(salarySobGroupItemHidePO); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + public List listSome(SalarySobItemHidePO po) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySobItemHideMapper mapper = sqlSession.getMapper(SalarySobItemHideMapper.class); + return mapper.listSome(po); + } finally { + sqlSession.close(); + } + } +} diff --git a/src/com/engine/salary/biz/SalarySobRangeBiz.java b/src/com/engine/salary/biz/SalarySobRangeBiz.java new file mode 100644 index 000000000..adfc94c5d --- /dev/null +++ b/src/com/engine/salary/biz/SalarySobRangeBiz.java @@ -0,0 +1,84 @@ +package com.engine.salary.biz; + +import com.engine.salary.entity.salarysob.po.SalarySobRangePO; +import com.engine.salary.mapper.salarysob.SalarySobRangeMapper; +import com.google.common.collect.Lists; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.ibatis.session.SqlSession; +import weaver.conn.mybatis.MyBatisFactory; + +import java.util.Collection; +import java.util.List; + +public class SalarySobRangeBiz { + + + public List listSome(SalarySobRangePO build) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySobRangeMapper mapper = sqlSession.getMapper(SalarySobRangeMapper.class); + return mapper.listSome(build); + } finally { + sqlSession.close(); + } + } + + public void batchInsert(Collection needInsertSalarySobRanges) { + if(CollectionUtils.isEmpty(needInsertSalarySobRanges)){ + return; + } + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySobRangeMapper mapper = sqlSession.getMapper(SalarySobRangeMapper.class); + List> partition = Lists.partition((List) needInsertSalarySobRanges, 100); + partition.forEach(mapper::batchInsert); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + public void updateById(SalarySobRangePO po) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySobRangeMapper mapper = sqlSession.getMapper(SalarySobRangeMapper.class); + mapper.updateIgnoreNull(po); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + public void deleteByIds(Collection ids) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySobRangeMapper mapper = sqlSession.getMapper(SalarySobRangeMapper.class); + mapper.deleteByIds(ids); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + public void deleteBySalarySobIds(Collection salarySobIds) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySobRangeMapper mapper = sqlSession.getMapper(SalarySobRangeMapper.class); + mapper.deleteBySalarySobIds(salarySobIds); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + public void updateEmployeeStatuses(SalarySobRangePO item) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySobRangeMapper mapper = sqlSession.getMapper(SalarySobRangeMapper.class); + mapper.updateEmployeeStatuses(item); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } +} diff --git a/src/com/engine/salary/biz/SalaryTemplateBiz.java b/src/com/engine/salary/biz/SalaryTemplateBiz.java new file mode 100644 index 000000000..53180b0a4 --- /dev/null +++ b/src/com/engine/salary/biz/SalaryTemplateBiz.java @@ -0,0 +1,143 @@ +package com.engine.salary.biz; + +import com.engine.salary.entity.salaryBill.dto.SalaryTemplateListDTO; +import com.engine.salary.entity.salaryBill.param.SalaryTemplateQueryParam; +import com.engine.salary.entity.salaryBill.po.SalaryTemplatePO; +import com.engine.salary.mapper.salarybill.SalaryTemplateMapper; +import org.apache.ibatis.session.SqlSession; +import weaver.conn.mybatis.MyBatisFactory; + +import java.util.Collection; +import java.util.List; + +/** + * 工资单模板 + */ +public class SalaryTemplateBiz { + + /** + * 根据id获取数据 + * @param id + * @return + */ + public SalaryTemplatePO getById(Long id) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalaryTemplateMapper mapper = sqlSession.getMapper(SalaryTemplateMapper.class); + return mapper.getById(id); + } finally { + sqlSession.close(); + } + } + + /** + * 根据id更新 + * @param salaryTemplateNew + */ + public void updateById(SalaryTemplatePO salaryTemplateNew) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalaryTemplateMapper mapper = sqlSession.getMapper(SalaryTemplateMapper.class); + mapper.updateIgnoreNull(salaryTemplateNew); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + /** + * 根据现有字段查询 + * @param po + * @return + */ + public List listSome(SalaryTemplatePO po) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalaryTemplateMapper mapper = sqlSession.getMapper(SalaryTemplateMapper.class); + return mapper.listSome(po); + } finally { + sqlSession.close(); + } + } + + /** + * 新增 + * @param salaryTemplatePO + * @return + */ + public void insert(SalaryTemplatePO salaryTemplatePO) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalaryTemplateMapper mapper = sqlSession.getMapper(SalaryTemplateMapper.class); + mapper.insertIgnoreNull(salaryTemplatePO); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + + /** + * 查询工资单模板列表 + * @param param + * @return + */ + public List list(SalaryTemplateQueryParam param) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalaryTemplateMapper mapper = sqlSession.getMapper(SalaryTemplateMapper.class); + return mapper.list(param); + } finally { + sqlSession.close(); + } + } + + /** + * 批量删除工资单模板 + * @param ids + */ + public void deleteByIds(Collection ids) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalaryTemplateMapper mapper = sqlSession.getMapper(SalaryTemplateMapper.class); + mapper.deleteByIds(ids); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + /** + * 默认模板 + */ + public List listDefaultTemplates(List ids) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalaryTemplateMapper mapper = sqlSession.getMapper(SalaryTemplateMapper.class); + return mapper.listDefaultTemplates(ids); + } finally { + sqlSession.close(); + } + } + + public void updateBySalarySobId(SalaryTemplatePO po) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalaryTemplateMapper mapper = sqlSession.getMapper(SalaryTemplateMapper.class); + mapper.updateUsetypeBySalarySobId(po); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + public List listDTO(SalaryTemplatePO param) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalaryTemplateMapper mapper = sqlSession.getMapper(SalaryTemplateMapper.class); + return mapper.listDTO(param); + } finally { + sqlSession.close(); + } + } +} diff --git a/src/com/engine/salary/biz/SpecialAddDeductionBiz.java b/src/com/engine/salary/biz/SpecialAddDeductionBiz.java new file mode 100644 index 000000000..be57b5c29 --- /dev/null +++ b/src/com/engine/salary/biz/SpecialAddDeductionBiz.java @@ -0,0 +1,223 @@ +package com.engine.salary.biz; + +import com.engine.salary.config.SalaryElogConfig; +import com.engine.hrmelog.entity.dto.LoggerContext; +import com.engine.salary.encrypt.EncryptUtil; +import com.engine.salary.entity.datacollection.dto.SpecialAddDeductionListDTO; +import com.engine.salary.entity.datacollection.dto.SpecialAddDeductionRecordDTO; +import com.engine.salary.entity.datacollection.param.SpecialAddDeductionQueryParam; +import com.engine.salary.entity.datacollection.po.SpecialAddDeductionPO; +import com.engine.salary.enums.OperateTypeEnum; +import com.engine.salary.mapper.datacollection.SpecialAddDeductionMapper; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.db.MapperProxyFactory; +import com.google.common.collect.Lists; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.ibatis.session.SqlSession; +import weaver.conn.mybatis.MyBatisFactory; +import weaver.general.BaseBean; +import weaver.hrm.User; + +import java.util.*; +import java.util.stream.Collectors; + +public class SpecialAddDeductionBiz extends BaseBean { + private EncryptUtil encryptUtil = new EncryptUtil(); + + private SpecialAddDeductionMapper mapper() { + return MapperProxyFactory.getProxy(SpecialAddDeductionMapper.class); + } + + /** + * 根据id获取 + * + * @param id + * @return + */ + public SpecialAddDeductionPO getById(Long id) { + try (SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession()) { + SpecialAddDeductionMapper mapper = sqlSession.getMapper(SpecialAddDeductionMapper.class); + SpecialAddDeductionPO byId = mapper.getById(id); + return encryptUtil.decrypt(byId, SpecialAddDeductionPO.class); + } + } + + public List listDTOByParam(SpecialAddDeductionQueryParam param) { + List specialAddDeductionRecordDTOS = mapper().listDtoByParam(param); + return encryptUtil.decryptList(specialAddDeductionRecordDTOS, SpecialAddDeductionRecordDTO.class); + } + + + public List listByParam(SpecialAddDeductionQueryParam param) { + List specialAddDeductionListDTOS = mapper().listByParam(param); + encryptUtil.decryptList(specialAddDeductionListDTOS, SpecialAddDeductionListDTO.class); + return SalaryI18nUtil.i18nList(specialAddDeductionListDTOS); + } + + public List listByTaxAgentIds(List taxAgentIds) { + try (SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession()) { + SpecialAddDeductionMapper mapper = sqlSession.getMapper(SpecialAddDeductionMapper.class); + List pos = mapper.listByTaxAgentIds(taxAgentIds); + return encryptUtil.decryptList(pos, SpecialAddDeductionPO.class); + } + } + + + /** + * 批量插入 + * + * @param param + * @return + */ + public void batchSave(List param) { + if (CollectionUtils.isEmpty(param)) { + return; + } + try (SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession()) { + SpecialAddDeductionMapper mapper = sqlSession.getMapper(SpecialAddDeductionMapper.class); + encryptUtil.encryptList(param, SpecialAddDeductionPO.class); + List> partition = Lists.partition(param, 100); + partition.forEach(mapper::batchInsert); + sqlSession.commit(); + } + } + + /** + * 批量插入 + * + * @param param + * @return + */ + public void batchUpdate(List param) { + if (CollectionUtils.isEmpty(param)) { + return; + } + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SpecialAddDeductionMapper mapper = sqlSession.getMapper(SpecialAddDeductionMapper.class); + encryptUtil.encryptList(param, SpecialAddDeductionPO.class); + List> partition = Lists.partition(param, 50); + partition.forEach(mapper::updateBatchSelective); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + /** + * 条件查询 + * + * @param param + * @return + */ + public List listSome(SpecialAddDeductionPO param) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SpecialAddDeductionMapper mapper = sqlSession.getMapper(SpecialAddDeductionMapper.class); + List specialAddDeductionPOS = mapper.listSome(param); + return encryptUtil.decryptList(specialAddDeductionPOS, SpecialAddDeductionPO.class); + } finally { + sqlSession.close(); + } + } + + + /** + * 处理导入数据 + * + * @param pos + */ + public void handleImportData(List pos, User user) { + if (CollectionUtils.isEmpty(pos)) { + return; + } + SpecialAddDeductionPO po = pos.get(0); + // 多条相同人的则以第一条为准,如果逆序排列(用于重复的则以最后一条为准)Collections.reverse(pos); + // 去重(通过记录的唯一条件(申报月份,人员id,个税扣缴义务人id)拼接) + List finalPos = pos.stream() + .collect(Collectors.collectingAndThen( + Collectors.toCollection(() -> + new TreeSet<>(Comparator.comparing(f -> f.getEmployeeId() + "-" + f.getTaxAgentId()))), + ArrayList::new) + ); + // 查询已有数据 + List list = listByTaxAgentIds(null); + // 待修改的 本地已存在则更新【交集】 + List updateList = list.stream() + .map(m -> finalPos.stream() + .filter(p -> (p.getEmployeeId() + "-" + p.getTaxAgentId()).equals(m.getEmployeeId() + "-" + m.getTaxAgentId())) + .findFirst() + .map(t -> t.setId(m.getId())) + .orElse(null) + ).filter(Objects::nonNull).collect(Collectors.toList()); + // 待新增的 导入比本地多,则新增【差集(导入 - local)】 + List saveList = finalPos.stream() + .filter(m -> list.stream().noneMatch(p -> (p.getEmployeeId() + "-" + p.getTaxAgentId()).equals(m.getEmployeeId() + "-" + m.getTaxAgentId())) + ).filter(Objects::nonNull).collect(Collectors.toList()); + + // 修改 + if (CollectionUtils.isNotEmpty(updateList)) { + batchUpdate(updateList); + } + // 保存 + if (CollectionUtils.isNotEmpty(saveList)) { + batchSave(saveList); + } + + // 记录操作日志 + // 根据人员id查出保存的数据 + List empIds = saveList.stream().map(SpecialAddDeductionPO::getEmployeeId).collect(Collectors.toList()); + List insertLogList = listSome(SpecialAddDeductionPO.builder().employeeIds(empIds).build()); + Map insertMap = SalaryEntityUtil.convert2Map(insertLogList, p -> p.getTaxAgentId() + "-" + p.getEmployeeId()); + saveList.forEach(save -> { + SpecialAddDeductionPO specialAddDeductionPO = insertMap.get(save.getTaxAgentId() + "-" + save.getEmployeeId()); + if (specialAddDeductionPO != null) { + updateList.add(specialAddDeductionPO); + } + }); + + if (CollectionUtils.isNotEmpty(updateList)) { + LoggerContext loggerContext = new LoggerContext(); + loggerContext.setUser(user); + if(updateList.size() == 1) { + loggerContext.setTargetId(updateList.get(0).getId().toString()); + } + loggerContext.setTargetName(SalaryI18nUtil.getI18nLabel( 0, "专项附加扣除 ")); + loggerContext.setOperateType(OperateTypeEnum.ADD.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "导入")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "导入专项附加扣除 ")); + loggerContext.setNewValueList(updateList); + SalaryElogConfig.specialAddDeductionLoggerTemplate.write(loggerContext); + } + } + + + /** + * @return void + * @description 批量删除 + */ + public void batchDeleteByIds(List deleteIds) { + if (CollectionUtils.isEmpty(deleteIds)) { + return; + } + try (SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession()) { + SpecialAddDeductionMapper mapper = sqlSession.getMapper(SpecialAddDeductionMapper.class); + List> partition = Lists.partition(deleteIds, 100); + partition.forEach(mapper::deleteByIds); + sqlSession.commit(); + } + } + + public List getByEmployeeId(List employeeIds, Long taxAgentId) { + if (CollectionUtils.isEmpty(employeeIds)) { + employeeIds = Collections.emptyList(); + } + return mapper().getByEmployeeIds(employeeIds, taxAgentId) + .stream() + .filter(Objects::nonNull) + .filter(s -> s.getEmployeeId() != null) + .map(item -> encryptUtil.decrypt(item, SpecialAddDeductionPO.class)) + .collect(Collectors.toList()); + } +} diff --git a/src/com/engine/salary/biz/SubCompanyBiz.java b/src/com/engine/salary/biz/SubCompanyBiz.java new file mode 100644 index 000000000..2ca3cbd6d --- /dev/null +++ b/src/com/engine/salary/biz/SubCompanyBiz.java @@ -0,0 +1,48 @@ +package com.engine.salary.biz; + +import com.engine.salary.entity.hrm.SubCompanyInfo; +import org.apache.commons.lang3.StringUtils; +import weaver.conn.RecordSet; + +import java.util.ArrayList; +import java.util.List; + +public class SubCompanyBiz { + + public List list() { + List returnList = new ArrayList<>(); + + RecordSet rs = new RecordSet(); + rs.executeQuery("select id, subcompanyname from HrmsubCompany"); + while (rs.next()) { + returnList.add( + SubCompanyInfo.builder() + .id(Long.valueOf(rs.getString(1))) + .name(rs.getString(2)).build() + ); + } + return returnList; + } + + /** + * 获取所有上级分部 + * + * @param subId + * @param returnList + * @return + */ + public List getSupSubCompanyLists(String subId, List returnList) { + RecordSet rs = new RecordSet(); + rs.executeSql("select supsubcomid from HrmsubCompany where id=" + subId); + while (rs.next()) { + String supsubcomid = rs.getString(1); + if (!StringUtils.equals(supsubcomid, "0")) { + returnList.add(supsubcomid); + getSupSubCompanyLists(supsubcomid, returnList); + } + } + return returnList; + } + + +} diff --git a/src/com/engine/salary/biz/SysSalaryItemBiz.java b/src/com/engine/salary/biz/SysSalaryItemBiz.java new file mode 100644 index 000000000..19ed10802 --- /dev/null +++ b/src/com/engine/salary/biz/SysSalaryItemBiz.java @@ -0,0 +1,51 @@ +package com.engine.salary.biz; + +import com.engine.salary.entity.salaryitem.po.SysSalaryItemPO; +import com.engine.salary.mapper.salaryitem.SysSalaryItemMapper; +import org.apache.ibatis.session.SqlSession; +import weaver.conn.mybatis.MyBatisFactory; + +import java.util.List; + +public class SysSalaryItemBiz { + + public SysSalaryItemPO getById(Long id) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SysSalaryItemMapper mapper = sqlSession.getMapper(SysSalaryItemMapper.class); + return mapper.getById(id); + } finally { + sqlSession.close(); + } + } + + public List listAll() { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SysSalaryItemMapper mapper = sqlSession.getMapper(SysSalaryItemMapper.class); + return mapper.listAll(); + } finally { + sqlSession.close(); + } + } + + public List listSome(SysSalaryItemPO build) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SysSalaryItemMapper mapper = sqlSession.getMapper(SysSalaryItemMapper.class); + return mapper.listSome(build); + } finally { + sqlSession.close(); + } + } + + public SysSalaryItemPO selectOneByName(String name) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SysSalaryItemMapper mapper = sqlSession.getMapper(SysSalaryItemMapper.class); + return mapper.selectOneByName(name); + } finally { + sqlSession.close(); + } + } +} diff --git a/src/com/engine/salary/biz/TaxAgentBiz.java b/src/com/engine/salary/biz/TaxAgentBiz.java new file mode 100644 index 000000000..96ba7fb23 --- /dev/null +++ b/src/com/engine/salary/biz/TaxAgentBiz.java @@ -0,0 +1,43 @@ +package com.engine.salary.biz; + +import com.engine.salary.entity.taxagent.param.TaxAgentQueryParam; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import com.engine.salary.mapper.taxagent.TaxAgentMapper; +import org.apache.ibatis.session.SqlSession; +import weaver.conn.mybatis.MyBatisFactory; + +import java.util.Collection; +import java.util.List; + +public class TaxAgentBiz { + + public List listAll() { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + TaxAgentMapper taxAgentMapper = sqlSession.getMapper(TaxAgentMapper.class); + return taxAgentMapper.listAll(); + } finally { + sqlSession.close(); + } + } + + public List listByIds(Collection taxAgentIds) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + TaxAgentMapper taxAgentMapper = sqlSession.getMapper(TaxAgentMapper.class); + return taxAgentMapper.listBySome(TaxAgentQueryParam.builder().ids(taxAgentIds).build()); + } finally { + sqlSession.close(); + } + } + + public TaxAgentPO getById(Long taxAgentId) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + TaxAgentMapper taxAgentMapper = sqlSession.getMapper(TaxAgentMapper.class); + return taxAgentMapper.getById(taxAgentId); + } finally { + sqlSession.close(); + } + } +} diff --git a/src/com/engine/salary/biz/TaxRateBiz.java b/src/com/engine/salary/biz/TaxRateBiz.java new file mode 100644 index 000000000..0c7a75b60 --- /dev/null +++ b/src/com/engine/salary/biz/TaxRateBiz.java @@ -0,0 +1,323 @@ +package com.engine.salary.biz; + +import com.engine.salary.entity.taxrate.SysTaxRateBase; +import com.engine.salary.entity.taxrate.TaxRateBase; +import com.engine.salary.entity.taxrate.TaxRateDetail; +import com.engine.salary.entity.taxrate.bo.TaxRateBO; +import com.engine.salary.entity.taxrate.param.TaxRateSaveParam; +import com.engine.salary.entity.taxrate.vo.TaxRateFormVo; +import com.engine.salary.enums.SalarySystemTypeEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.mapper.SysTaxRateBaseMapper; +import com.engine.salary.mapper.TaxRateBaseMapper; +import com.engine.salary.mapper.TaxRateDetailMapper; +import com.engine.salary.util.SalaryEntityUtil; +import com.google.common.collect.Lists; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.ibatis.session.SqlSession; +import org.springframework.beans.BeanUtils; +import weaver.conn.mybatis.MyBatisFactory; +import weaver.general.BaseBean; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * 税率操作类 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class TaxRateBiz extends BaseBean { + + + public TaxRateBase getById(Long id) { + + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + TaxRateBaseMapper taxRateBaseMapper = sqlSession.getMapper(TaxRateBaseMapper.class); + SysTaxRateBaseMapper sysTaxRateBaseMapper = sqlSession.getMapper(SysTaxRateBaseMapper.class); + TaxRateBase taxRateBase = taxRateBaseMapper.getById(id); + + // 如果自定义税率表中没有再查询系统默认的税率表 + if (Objects.isNull(taxRateBase)) { + SysTaxRateBase sysTaxRateBase = sysTaxRateBaseMapper.getById(id); + if (sysTaxRateBase == null) { + return null; + } + taxRateBase = new TaxRateBase(); + BeanUtils.copyProperties(sysTaxRateBase, taxRateBase); + } + return taxRateBase; + } finally { + sqlSession.close(); + } + } + + public List listByIds(Collection ids) { + + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + TaxRateBaseMapper taxRateBaseMapper = sqlSession.getMapper(TaxRateBaseMapper.class); + SysTaxRateBaseMapper sysTaxRateBaseMapper = sqlSession.getMapper(SysTaxRateBaseMapper.class); + + if (CollectionUtils.isEmpty(ids)) { + return Collections.emptyList(); + } + List resultList = Lists.newArrayListWithExpectedSize(ids.size()); + // 查询系统默认的税率表 + List sysTaxRateBases = sysTaxRateBaseMapper.selectByIds(ids); + List TaxRateBaseS4Sys = sysTaxRateBases.stream() + .map(sysTaxRateBase -> { + TaxRateBase TaxRateBase = new TaxRateBase(); + BeanUtils.copyProperties(sysTaxRateBase, TaxRateBase); + return TaxRateBase; + }) + .collect(Collectors.toList()); + resultList.addAll(TaxRateBaseS4Sys); + + // 查询自定义税率表 + List taxRateBases = taxRateBaseMapper.selectByIds(ids); + resultList.addAll(taxRateBases); + + return resultList; + + } finally { + sqlSession.close(); + } + } + + + public List listByName(String name) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + TaxRateBaseMapper taxRateBaseMapper = sqlSession.getMapper(TaxRateBaseMapper.class); + SysTaxRateBaseMapper sysTaxRateBaseMapper = sqlSession.getMapper(SysTaxRateBaseMapper.class); + + List resultList = Lists.newArrayList(); + + // 查询系统默认的税率表 + List sysTaxRateBases = sysTaxRateBaseMapper.listBySome(SysTaxRateBase.builder().name(name).build()); + List TaxRateBaseS4Sys = sysTaxRateBases.stream() + .map(sysTaxRateBase -> { + TaxRateBase TaxRateBase = new TaxRateBase(); + BeanUtils.copyProperties(sysTaxRateBase, TaxRateBase); + return TaxRateBase; + }) + .collect(Collectors.toList()); + resultList.addAll(TaxRateBaseS4Sys); + + // 查询自定义税率表 + List TaxRateBaseS = taxRateBaseMapper.listBySome(TaxRateBase.builder().name(name).build()); + resultList.addAll(TaxRateBaseS); + + return resultList; + + } finally { + sqlSession.close(); + } + } + + + public List list() { + List resultList = Lists.newArrayList(); + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SysTaxRateBaseMapper sysTaxRateBaseMapper = sqlSession.getMapper(SysTaxRateBaseMapper.class); + TaxRateBaseMapper taxRateBaseMapper = sqlSession.getMapper(TaxRateBaseMapper.class); + + // 查询系统默认的税率表 + List sysTaxRateBases = sysTaxRateBaseMapper.listAll(); + List TaxRateBaseS4Sys = sysTaxRateBases.stream() + .map(sysTaxRateBase -> { + TaxRateBase TaxRateBase = new TaxRateBase(); + BeanUtils.copyProperties(sysTaxRateBase, TaxRateBase); + return TaxRateBase; + }) + .collect(Collectors.toList()); + resultList.addAll(TaxRateBaseS4Sys); + + // 查询自定义税率表 + List TaxRateBaseS = taxRateBaseMapper.listAll(); + resultList.addAll(TaxRateBaseS); + + } finally { + sqlSession.close(); + } + + return resultList; + } + + public void deleteByIds(Collection ids) { + // 查询待删除的个税税率表主表 + List TaxRateBaseS = listByIds(ids); + if (CollectionUtils.isEmpty(TaxRateBaseS)) { + throw new SalaryRunTimeException("个税税率表不存在"); + } + // 系统默认的个税税率表不允许删除 + boolean containSystem = TaxRateBaseS.stream() + .anyMatch(taxRateBatchPO -> SalarySystemTypeEnum.parseByValue(taxRateBatchPO.getSystemType()) == SalarySystemTypeEnum.SYSTEM); + if (containSystem) { + throw new SalaryRunTimeException("系统默认的税率表不允许删除"); + } + ids = SalaryEntityUtil.properties(TaxRateBaseS, TaxRateBase::getId); + // todo 记录日志 +// TaxRateBaseS.forEach(taxRateBatchPO -> { +// LoggerContext loggerContext = new LoggerContext<>(); +// loggerContext.setTargetId(String.valueOf(taxRateBatchPO.getId())); +// loggerContext.setTargetName(taxRateBatchPO.getName()); +// loggerContext.setOperateType(OperateTypeEnum.DELETE.getValue()); +// loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(98120, "删除个税税率表")); +// loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(98120, "删除个税税率表")); +// loggerContext.setNewValues(taxRateBatchPO); +// taxRateLoggerTemplate.write(loggerContext); +// }); + + + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + TaxRateBaseMapper taxRateBaseMapper = sqlSession.getMapper(TaxRateBaseMapper.class); + TaxRateDetailMapper taxRateDetailMapper = sqlSession.getMapper(TaxRateDetailMapper.class); + // 删除主表 + taxRateBaseMapper.deleteByIds(ids); + // 删除明细表 + taxRateDetailMapper.deleteByBatchIds(ids); + + sqlSession.commit(); + } finally { + sqlSession.close(); + } + + } + + public void save(TaxRateSaveParam saveParam, Long employeeId) { + + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + TaxRateBaseMapper taxRateBaseMapper = sqlSession.getMapper(TaxRateBaseMapper.class); + + // 个税税率表主表名称不允许重复 + List TaxRateBaseS = listByName(saveParam.getTaxRateBatch().getName()); + if (CollectionUtils.isNotEmpty(TaxRateBaseS)) { + throw new SalaryRunTimeException("名称不允许重复"); + } + // 保存个税税率表主表 + TaxRateBase TaxRateBase = TaxRateBO.convert2BatchPO(saveParam.getTaxRateBatch(), employeeId); + taxRateBaseMapper.insertIgnoreNull(TaxRateBase); + // todo 记录日志 +// LoggerContext loggerContext = new LoggerContext<>(); +// loggerContext.setTargetId(String.valueOf(TaxRateBase.getId())); +// loggerContext.setTargetName(TaxRateBase.getName()); +// loggerContext.setOperateType(OperateTypeEnum.ADD.getValue()); +// loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(98107, "新增个税税率表(基础信息)")); +// loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(86124, "基础信息")); +// loggerContext.setNewValues(TaxRateBase); +// taxRateLoggerTemplate.write(loggerContext); + // 保存个税税率表明细表 + List taxRateDetailPOS = TaxRateBO.convert2RecordPO(TaxRateBase.getId(), saveParam.getTaxRateRecords(), employeeId); + new TaxRateDetailBiz().saveBatch(taxRateDetailPOS); + // todo 记录日志 +// LoggerContext detailLoggerContext = new LoggerContext<>(); +// detailLoggerContext.setTargetId(String.valueOf(TaxRateBase.getId())); +// detailLoggerContext.setTargetName(TaxRateBase.getName()); +// detailLoggerContext.setOperateType(OperateTypeEnum.ADD.getValue()); +// detailLoggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(98125, "新增个税税率表(详细设置)")); +// detailLoggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(96687, "详细设置")); +// detailLoggerContext.setNewValueList(taxRateDetailPOS); +// taxRateLoggerTemplate.write(loggerContext); + + + sqlSession.commit(); + + } finally { + sqlSession.close(); + } + + + } + + public void update(TaxRateSaveParam updateParam, Long employeeId) { + + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SysTaxRateBaseMapper sysTaxRateBaseMapper = sqlSession.getMapper(SysTaxRateBaseMapper.class); + TaxRateBaseMapper taxRateBaseMapper = sqlSession.getMapper(TaxRateBaseMapper.class); + TaxRateDetailMapper taxRateDetailMapper = sqlSession.getMapper(TaxRateDetailMapper.class); + + // 查询是否存在指定的个税税率表 + TaxRateBase taxRateBase = getById(updateParam.getTaxRateBatch().getId()); + if (Objects.isNull(taxRateBase)) { + throw new SalaryRunTimeException("个税税率表不存在"); + } + // 个税税率表主表名称不允许重复 + List TaxRateBaseS = listByName(updateParam.getTaxRateBatch().getName()); + boolean nameExist = !CollectionUtils.isEmpty(TaxRateBaseS) && + TaxRateBaseS.stream().anyMatch(e -> !Objects.equals(e.getId(), updateParam.getTaxRateBatch().getId())); + if (nameExist) { + throw new SalaryRunTimeException("名称不允许重复"); + } + // 系统默认的个税税率表不允许编辑 + if (SalarySystemTypeEnum.parseByValue(taxRateBase.getSystemType()) == SalarySystemTypeEnum.SYSTEM) { + throw new SalaryRunTimeException("系统默认的个税税率表不允许编辑"); + } + // 更新个税税率表主表 + TaxRateBase newTaxRateBase = new TaxRateBase(); + BeanUtils.copyProperties(taxRateBase, newTaxRateBase); + newTaxRateBase.setName(updateParam.getTaxRateBatch().getName()); + newTaxRateBase.setDescription(updateParam.getTaxRateBatch().getDescription()); + taxRateBaseMapper.updateIgnoreNull(newTaxRateBase); + // todo 记录日志 +// LoggerContext loggerContext = new LoggerContext<>(); +// loggerContext.setTargetId(String.valueOf(taxRateBase.getId())); +// loggerContext.setTargetName(taxRateBase.getName()); +// loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue()); +// loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(98108, "编辑个税税率表(基础信息)")); +// loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(86124, "基础信息")); +// loggerContext.setOldValues(taxRateBase); +// loggerContext.setNewValues(newTaxRateBase); +// taxRateLoggerTemplate.write(loggerContext); + // 更新个税税率表明细表-先删除后插入 + List taxRateDetailPOS = taxRateDetailMapper.listByBaseId(taxRateBase.getId()); + taxRateDetailMapper.deleteByBatchIds(Collections.singleton(taxRateBase.getId())); + List newTaxRateDetailPOS = TaxRateBO.convert2RecordPO(taxRateBase.getId(), updateParam.getTaxRateRecords(), employeeId); + new TaxRateDetailBiz().saveBatch(newTaxRateDetailPOS); + // todo 记录日志 +// LoggerContext detailLoggerContext = new LoggerContext<>(); +// detailLoggerContext.setTargetId(String.valueOf(taxRateBase.getId())); +// detailLoggerContext.setTargetName(taxRateBase.getName()); +// detailLoggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue()); +// detailLoggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(98128, "新增个税税率表(详细设置)")); +// detailLoggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(96687, "详细设置")); +// detailLoggerContext.setOldValueList(taxRateDetailPOS); +// detailLoggerContext.setNewValueList(newTaxRateDetailPOS); +// taxRateLoggerTemplate.write(loggerContext); + + + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + + /** + * 个税税率表详情 + * + * @param id 主表主键id + * @return + */ + public TaxRateFormVo getForm(Long id) { + if (id != null) { + // 查询个税税率表主表 + TaxRateBase taxRateBasePo = getById(id); + // 查询个税税率表明细表 + List taxRateDetailPOS = new TaxRateDetailBiz().listByBaseId(id); + return TaxRateFormVo.builder().taxRateBatch(taxRateBasePo).taxRateRecords(taxRateDetailPOS).systemType(Optional.ofNullable(taxRateBasePo.getSystemType()).map(SalarySystemTypeEnum::parseByValue).orElse(SalarySystemTypeEnum.CUSTOM)).build(); + } + return TaxRateFormVo.builder().build(); + } + + +} diff --git a/src/com/engine/salary/biz/TaxRateDetailBiz.java b/src/com/engine/salary/biz/TaxRateDetailBiz.java new file mode 100644 index 000000000..b646ad3e3 --- /dev/null +++ b/src/com/engine/salary/biz/TaxRateDetailBiz.java @@ -0,0 +1,48 @@ +package com.engine.salary.biz; + +import com.engine.salary.entity.taxrate.TaxRateDetail; +import com.engine.salary.mapper.TaxRateDetailMapper; +import org.apache.ibatis.session.SqlSession; +import weaver.conn.mybatis.MyBatisFactory; +import weaver.general.BaseBean; + +import java.util.List; + +/** + * 税率明细操作类 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class TaxRateDetailBiz extends BaseBean { + + public void saveBatch(List list) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + TaxRateDetailMapper taxRateDetailMapper = sqlSession.getMapper(TaxRateDetailMapper.class); + + list.forEach(taxRateDetailMapper::insertIgnoreNull); + + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + + public List listByBaseId(Long baseId) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + TaxRateDetailMapper taxRateDetailMapper = sqlSession.getMapper(TaxRateDetailMapper.class); + + return taxRateDetailMapper.listByBaseId(baseId); + + } finally { + sqlSession.close(); + } + } + + +} diff --git a/src/com/engine/salary/cache/SalaryCacheKey.java b/src/com/engine/salary/cache/SalaryCacheKey.java new file mode 100644 index 000000000..4d0d19280 --- /dev/null +++ b/src/com/engine/salary/cache/SalaryCacheKey.java @@ -0,0 +1,76 @@ +package com.engine.salary.cache; + +/** + * 用于定义本服务内部使用的缓存key + */ +public class SalaryCacheKey { + + /** + * 人员范围同步 + */ + public final static String TAX_AGENT_MANAGE_RANGE_SYNC = "TAX_AGENT_MANAGE_RANGE_SYNC"; + + /** + * 核算进度 + */ + public final static String ACCT_PROGRESS = "ACCT_PROGRESS_"; + + /** + * 薪资核算的账套配置 + */ + public final static String ACCT_SOB_CONFIG = "ACCT_SOB_CONFIG"; + + /** + * 考勤进度 + */ + public final static String ATTEND_PROGRESS = "ATTEND_PROGRESS"; + + /** + * 工资单发放进度 + */ + public final static String SALARY_GRANT_PROGRESS = "SALARY_GRANT_PROGRESS"; + + /** + * 工资单撤回进度 + */ + public final static String SALARY_WITHDRAW_PROGRESS = "SALARY_WITHDRAW_PROGRESS"; + + /** + * 短信验证码缓存 + */ + public final static String SALARY_CACHE_SMS_CODE = "SALARY_CACHE_SMS_CODE"; + + /** + * ecology系统的token + */ + public final static String ECOLOGY_TOKEN = "ECOLOGY_TOKEN"; + + /** + * 个税申报表 + */ + public final static String TAX_DECLARATION = "TAX_DECLARATION"; + + /** + * 人员报送 + */ + public final static String EMPLOYEE_DECLARE = "EMPLOYEE_DECLARE"; + + /** + * 自定义业务数据 + */ + public final static String CUSTOM_DATA = "CUSTOM_DATA"; + + /** + * 报表主键 + */ + public final static String SALARY_REPORT_IDS = "SALARY_REPORT_IDS"; + + public final static String SALARY_REPORT_CONDITIONS = "SALARY_REPORT_CONDITIONS_"; + + public final static String SALARY_REPORT_DATA = "SALARY_REPORT_DATA_"; + + + public final static String UPLOAD_SALARY_CONFIG = "UPLOAD_SALARY_CONFIG"; + + +} diff --git a/src/com/engine/salary/cache/SalaryModuleKey.java b/src/com/engine/salary/cache/SalaryModuleKey.java new file mode 100644 index 000000000..9a400744d --- /dev/null +++ b/src/com/engine/salary/cache/SalaryModuleKey.java @@ -0,0 +1,16 @@ +package com.engine.salary.cache; + +/** + * @description: 用于拷贝定义所有的模块key,按照模块名规范表进行定义,便于开发引用。要求变量名和变量值必须完全保持一致 + * @author: xiajun + * @modified By: xiajun + * @date: Created in 12/13/21 11:24 AM + * @version:v1.0 + */ +public class SalaryModuleKey { + + /** + * 薪酬管理模块表示标识 + */ + public final static String HRM_SALARY_MODULE = "HRM_SALARY_MODULE"; +} diff --git a/src/com/engine/salary/cmd/TaxRate/TaxRateDeleteCmd.java b/src/com/engine/salary/cmd/TaxRate/TaxRateDeleteCmd.java new file mode 100644 index 000000000..690885ce2 --- /dev/null +++ b/src/com/engine/salary/cmd/TaxRate/TaxRateDeleteCmd.java @@ -0,0 +1,45 @@ +package com.engine.salary.cmd.TaxRate; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.salary.biz.TaxRateBiz; +import com.engine.salary.exception.SalaryRunTimeException; +import org.apache.commons.collections4.CollectionUtils; +import weaver.hrm.User; + +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; + +public class TaxRateDeleteCmd extends AbstractCommonCommand> { + + public TaxRateDeleteCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + Map apidatas = new HashMap(16); + + + Collection ids = (Collection)params.get("ids"); + if (CollectionUtils.isEmpty(ids)) { + throw new SalaryRunTimeException("参数错误"); + } + TaxRateBiz taxRateBiz = new TaxRateBiz(); + + taxRateBiz.deleteByIds(ids); + + return apidatas; + } + + + +} diff --git a/src/com/engine/salary/cmd/TaxRate/TaxRateGetFormCmd.java b/src/com/engine/salary/cmd/TaxRate/TaxRateGetFormCmd.java new file mode 100644 index 000000000..7a5af8521 --- /dev/null +++ b/src/com/engine/salary/cmd/TaxRate/TaxRateGetFormCmd.java @@ -0,0 +1,37 @@ +package com.engine.salary.cmd.TaxRate; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.salary.biz.TaxRateBiz; +import com.engine.salary.entity.taxrate.vo.TaxRateFormVo; +import weaver.general.Util; +import weaver.hrm.User; + +import java.util.HashMap; +import java.util.Map; + +public class TaxRateGetFormCmd extends AbstractCommonCommand> { + + public TaxRateGetFormCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + Map apidatas = new HashMap(16); + TaxRateBiz taxRateBiz = new TaxRateBiz(); + Long id = Long.valueOf(Util.null2String(params.get("id"))); + TaxRateFormVo form = taxRateBiz.getForm(id); + apidatas.put("form",form); + return apidatas; + } + + +} diff --git a/src/com/engine/salary/cmd/TaxRate/TaxRateListCmd.java b/src/com/engine/salary/cmd/TaxRate/TaxRateListCmd.java new file mode 100644 index 000000000..11c234910 --- /dev/null +++ b/src/com/engine/salary/cmd/TaxRate/TaxRateListCmd.java @@ -0,0 +1,106 @@ +package com.engine.salary.cmd.TaxRate; + +import com.cloudstore.eccom.pc.table.WeaTableCheckboxpopedom; +import com.cloudstore.eccom.pc.table.WeaTableOperate; +import com.cloudstore.eccom.pc.table.WeaTableOperates; +import com.cloudstore.eccom.pc.table.WeaTablePopedom; +import com.cloudstore.eccom.result.WeaResultMsg; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.salary.component.SalaryWeaTable; +import com.engine.salary.entity.taxrate.vo.TaxRateTableVO; +import com.engine.salary.util.db.DBType; +import org.apache.commons.lang3.StringUtils; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class TaxRateListCmd extends AbstractCommonCommand> { + + public TaxRateListCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + + Map apidatas = new HashMap(16); + + String sql = "from (select create_time,creator,delete_type, description, id, name, system_type, tenant_key, update_time from hrsa_sys_tax_rate_base s " + + " where s.delete_type = 0"; + + DBType dbType = DBType.get(new RecordSet().getDBType()); + + //模糊查询 + String name = Util.null2String(params.get("name")); + if (StringUtils.isNotBlank(name)) { + sql += " and s.name " + dbType.like(name); + } + sql += " union all " + + " select create_time,creator,delete_type, description, id, name, system_type, tenant_key, update_time " + + " from hrsa_tax_rate_base b " + + " where b.delete_type = 0 "; + //模糊查询 + if (StringUtils.isNotBlank(name)) { + sql += " and b.name " + dbType.like(name); + } + sql += ") t"; + + SalaryWeaTable table = new SalaryWeaTable(user, TaxRateTableVO.class); + table.setSqlform(sql); + + //设置check是否可用 + List checkboxpopedomList = new ArrayList<>(); + WeaTableCheckboxpopedom checkboxpopedom = new WeaTableCheckboxpopedom(); + checkboxpopedom.setPopedompara("column:system_type"); + checkboxpopedom.setShowmethod("com.engine.salary.transmethod.TaxRateTransMethod.getCheckBoxPopedom"); + checkboxpopedomList.add(checkboxpopedom); + table.setCheckboxList(checkboxpopedomList); + table.setCheckboxpopedom(null); + + List operateList = new ArrayList<>(); + WeaTableOperate editOperate = new WeaTableOperate("编辑", "", "0"); +// editOperate.setOtherpara("column:system_type"); +// editOperate.setIsalwaysshow("com.engine.salary.transmethod.TaxRateTransMethod.getCheckBoxPopedom"); + operateList.add(editOperate); + WeaTableOperate deleteOperate = new WeaTableOperate("删除", "", "1"); +// deleteOperate.setOtherpara("column:system_type"); +// deleteOperate.setIsalwaysshow("com.engine.salary.transmethod.TaxRateTransMethod.getCheckBoxPopedom"); + operateList.add(deleteOperate); + WeaTableOperate logOperate = new WeaTableOperate("操作日志", "", "3"); + operateList.add(logOperate); + + WeaTablePopedom popedom = new WeaTablePopedom(); + popedom.setTransmethod("com.engine.salary.transmethod.TaxRateTransMethod.getOpratePopedomWithType"); + popedom.setOtherpara("column:system_type"); + + + WeaTableOperates weaTableOperates = new WeaTableOperates(); + weaTableOperates.setOperate(operateList); + weaTableOperates.setPopedom(popedom); + table.setOperates(weaTableOperates); + + + + + WeaResultMsg result = new WeaResultMsg(false); + result.putAll(table.makeDataResult()); + result.success(); + apidatas = result.getResultMap(); + return apidatas; + } + + +} diff --git a/src/com/engine/salary/cmd/TaxRate/TaxRateSaveCmd.java b/src/com/engine/salary/cmd/TaxRate/TaxRateSaveCmd.java new file mode 100644 index 000000000..3c4f2f79e --- /dev/null +++ b/src/com/engine/salary/cmd/TaxRate/TaxRateSaveCmd.java @@ -0,0 +1,36 @@ +package com.engine.salary.cmd.TaxRate; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.salary.biz.TaxRateBiz; +import com.engine.salary.entity.taxrate.param.TaxRateSaveParam; +import weaver.hrm.User; + +import java.util.HashMap; +import java.util.Map; + +public class TaxRateSaveCmd extends AbstractCommonCommand> { + + public TaxRateSaveCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + Map apidatas = new HashMap(16); + TaxRateBiz taxRateBiz = new TaxRateBiz(); + TaxRateSaveParam taxRateSaveParam = (TaxRateSaveParam) params.get("taxRateSaveParam"); + taxRateBiz.save(taxRateSaveParam, (long) user.getUID()); + return apidatas; + } + + + +} diff --git a/src/com/engine/salary/cmd/TaxRate/TaxRateUpdateCmd.java b/src/com/engine/salary/cmd/TaxRate/TaxRateUpdateCmd.java new file mode 100644 index 000000000..a742586c6 --- /dev/null +++ b/src/com/engine/salary/cmd/TaxRate/TaxRateUpdateCmd.java @@ -0,0 +1,33 @@ +package com.engine.salary.cmd.TaxRate; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.salary.biz.TaxRateBiz; +import com.engine.salary.entity.taxrate.param.TaxRateSaveParam; +import weaver.hrm.User; + +import java.util.HashMap; +import java.util.Map; + +public class TaxRateUpdateCmd extends AbstractCommonCommand> { + + public TaxRateUpdateCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + Map apidatas = new HashMap(16); + TaxRateBiz taxRateBiz = new TaxRateBiz(); + TaxRateSaveParam taxRateSaveParam = (TaxRateSaveParam) params.get("taxRateSaveParam"); + taxRateBiz.update(taxRateSaveParam, (long) user.getUID()); + return apidatas; + } +} diff --git a/src/com/engine/salary/cmd/siarchives/SIArchivesTipsCmd.java b/src/com/engine/salary/cmd/siarchives/SIArchivesTipsCmd.java new file mode 100644 index 000000000..5d4eea819 --- /dev/null +++ b/src/com/engine/salary/cmd/siarchives/SIArchivesTipsCmd.java @@ -0,0 +1,47 @@ +package com.engine.salary.cmd.siarchives; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.salary.mapper.siarchives.SocialSchemeMapper; +import com.engine.salary.util.SalaryAssert; +import org.apache.ibatis.session.SqlSession; +import weaver.conn.mybatis.MyBatisFactory; +import weaver.hrm.User; + +import java.util.List; +import java.util.Map; + +/** + * @Author weaver_cl + * @Description: + * @Date 2022/3/12 + * @Version V1.0 + **/ +public class SIArchivesTipsCmd extends AbstractCommonCommand> { + + public SIArchivesTipsCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SocialSchemeMapper socialSchemeMapper = sqlSession.getMapper(SocialSchemeMapper.class); + List employeeIds = socialSchemeMapper.tips(); + SalaryAssert.isEmpty(employeeIds, "当前有离职人员档案存在福利缴纳起始月,未维护福利最后缴纳月,请尽快处理"); + + } finally { + sqlSession.close(); + } + return null; + } +} diff --git a/src/com/engine/salary/cmd/sicategory/SICategoryGetFormCmd.java b/src/com/engine/salary/cmd/sicategory/SICategoryGetFormCmd.java new file mode 100644 index 000000000..ebd164bfe --- /dev/null +++ b/src/com/engine/salary/cmd/sicategory/SICategoryGetFormCmd.java @@ -0,0 +1,86 @@ +package com.engine.salary.cmd.sicategory; + +import com.api.browser.bean.SearchConditionItem; +import com.api.browser.bean.SearchConditionOption; +import com.api.browser.util.ConditionFactory; +import com.api.browser.util.ConditionType; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.salary.biz.SICategoryBiz; +import com.engine.salary.entity.sicategory.dto.ICategoryFormDTO; +import weaver.hrm.User; + +import java.util.*; + +/** + * @Author weaver_cl + * @Description: + * @Date 2022/3/9 + * @Version V1.0 + **/ +public class SICategoryGetFormCmd extends AbstractCommonCommand> { + + public SICategoryGetFormCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + Map apidatas = new HashMap<>(16); + SICategoryBiz siCategoryBiz = new SICategoryBiz(); + Long id = (Long) params.get("id"); + ICategoryFormDTO form = siCategoryBiz.getForm(id); + apidatas.put("form",form); + ConditionFactory conditionFactory = new ConditionFactory(user); + Map items = new HashMap<>(); + + SearchConditionItem input = conditionFactory.createCondition(ConditionType.INPUT,502327, "insuranceName"); + input.setColSpan(2);//定义一行显示条件数,默认值为2,当值为1时标识该条件单独占一行 + input.setFieldcol(12); //条件输入框所占宽度,默认值18 + input.setViewAttr(3); // 编辑权限 1:只读,2:可编辑, 3:必填 默认2 + input.setLength(10); // 设置输入长度 + input.setLabel("福利名称"); //设置文本值 这个将覆盖多语言标签的值 + input.setRules("required"); //设置字段填入规则 + + items.put("insuranceName",input); + + SearchConditionItem radio = conditionFactory.createCondition(ConditionType.RADIO,502327,"welfareType"); + List radioOptions = new ArrayList <>(); + radioOptions.add(new SearchConditionOption("SOCIAL_SECURITY","社保",true)); + radioOptions.add(new SearchConditionOption("ACCUMULATION_FUND","公积金")); + radioOptions.add(new SearchConditionOption("OTHER","企业年金及其他福利")); + radio.setColSpan(2); + radio.setFieldcol(12); + radio.setLabelcol(6); + radio.setViewAttr(3); + radio.setIsQuickSearch(false); + radio.setOptions(radioOptions); + radio.setLabel("类型"); + radio.setRules("required"); + items.put("welfareType",radio); + + SearchConditionItem checkbox = conditionFactory.createCondition(ConditionType.CHECKBOX,502327,"paymentScope"); + List checkOptions = new ArrayList <>(); + checkOptions.add(new SearchConditionOption("SCOPE_COMPANY","公司")); + checkOptions.add(new SearchConditionOption("SCOPE_PERSON","个人")); + checkbox.setColSpan(2); + checkbox.setFieldcol(12); + checkbox.setLabelcol(6); + checkbox.setViewAttr(3); + checkbox.setIsQuickSearch(false); + checkbox.setOptions(checkOptions); + checkbox.setLabel("缴纳对象"); + checkbox.setRules("required"); + items.put("paymentScope",checkbox); + + apidatas.put("item",items); + return apidatas; + } +} diff --git a/src/com/engine/salary/cmd/sicategory/SICategoryInsertCmd.java b/src/com/engine/salary/cmd/sicategory/SICategoryInsertCmd.java new file mode 100644 index 000000000..54c796c7a --- /dev/null +++ b/src/com/engine/salary/cmd/sicategory/SICategoryInsertCmd.java @@ -0,0 +1,39 @@ +package com.engine.salary.cmd.sicategory; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.salary.biz.SICategoryBiz; +import com.engine.salary.entity.sicategory.dto.ICategoryFormDTO; +import weaver.hrm.User; + +import java.util.HashMap; +import java.util.Map; + +/** + * @Author weaver_cl + * @Description: + * @Date 2022/3/9 + * @Version V1.0 + **/ +public class SICategoryInsertCmd extends AbstractCommonCommand> { + + public SICategoryInsertCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + Map apidatas = new HashMap<>(16); + SICategoryBiz siCategoryBiz = new SICategoryBiz(); + ICategoryFormDTO iCategoryFormDTO = (ICategoryFormDTO)params.get("iCategoryFormDTO"); + siCategoryBiz.save(iCategoryFormDTO,(long) user.getUID()); + return apidatas; + } +} diff --git a/src/com/engine/salary/cmd/sicategory/SICategoryListCmd.java b/src/com/engine/salary/cmd/sicategory/SICategoryListCmd.java new file mode 100644 index 000000000..deace97a2 --- /dev/null +++ b/src/com/engine/salary/cmd/sicategory/SICategoryListCmd.java @@ -0,0 +1,53 @@ +package com.engine.salary.cmd.sicategory; + +import com.cloudstore.eccom.result.WeaResultMsg; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.salary.component.SalaryWeaTable; +import com.engine.salary.entity.sicategory.dto.ICategoryListDTO; +import weaver.hrm.User; + +import java.util.Map; +import java.util.Objects; + +/** + * @Author weaver_cl + * @Description: + * @Date 2022/3/11 + * @Version V1.0 + **/ +public class SICategoryListCmd extends AbstractCommonCommand> { + + public SICategoryListCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + SalaryWeaTable table = new SalaryWeaTable<>(user,ICategoryListDTO.class); + String sqlWhere = buildSqlWhere(params); + table.setSqlwhere(sqlWhere); + + WeaResultMsg result = new WeaResultMsg(false); + result.putAll(table.makeDataResult()); + result.success(); + return result.getResultMap(); + } + + private String buildSqlWhere(Map params) { + String sqlWhere = "where delete_Type = 0 and data_type != 1"; + Integer welfareType = (Integer)params.get("welfareType"); + + if (Objects.nonNull(welfareType)){ + sqlWhere += " and welfare_type ="+welfareType; + } + return sqlWhere; + } +} diff --git a/src/com/engine/salary/cmd/sicategory/SICategoryUpdateCmd.java b/src/com/engine/salary/cmd/sicategory/SICategoryUpdateCmd.java new file mode 100644 index 000000000..93b92b7c1 --- /dev/null +++ b/src/com/engine/salary/cmd/sicategory/SICategoryUpdateCmd.java @@ -0,0 +1,39 @@ +package com.engine.salary.cmd.sicategory; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.salary.biz.SICategoryBiz; +import com.engine.salary.entity.sicategory.dto.ICategoryFormDTO; +import weaver.hrm.User; + +import java.util.HashMap; +import java.util.Map; + +/** + * @Author weaver_cl + * + * @Date 2022/3/10 + * @Version V1.0 + **/ +public class SICategoryUpdateCmd extends AbstractCommonCommand> { + + public SICategoryUpdateCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + Map apidatas = new HashMap(16); + SICategoryBiz siCategoryBiz = new SICategoryBiz(); + ICategoryFormDTO iCategoryFormDTO = (ICategoryFormDTO) params.get("iCategoryFormDTO"); + siCategoryBiz.update(iCategoryFormDTO, (long) user.getUID()); + return apidatas; + } +} diff --git a/src/com/engine/salary/cmd/sicategory/SICategoryUpdateStatusByIdCmd.java b/src/com/engine/salary/cmd/sicategory/SICategoryUpdateStatusByIdCmd.java new file mode 100644 index 000000000..1e5571a29 --- /dev/null +++ b/src/com/engine/salary/cmd/sicategory/SICategoryUpdateStatusByIdCmd.java @@ -0,0 +1,40 @@ +package com.engine.salary.cmd.sicategory; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.salary.biz.SICategoryBiz; +import com.engine.salary.entity.sicategory.param.UpdateStatusParam; +import weaver.hrm.User; + +import java.util.HashMap; +import java.util.Map; + +/** + * @Author weaver_cl + * + * @Date 2022/3/10 + * @Version V1.0 + **/ +public class SICategoryUpdateStatusByIdCmd extends AbstractCommonCommand>{ + + public SICategoryUpdateStatusByIdCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + Map apidatas = new HashMap(16); + SICategoryBiz siCategoryBiz = new SICategoryBiz(); + Long id = (Long) params.get("id"); + Integer isUse = (Integer) params.get("isUse"); + siCategoryBiz.updateStatusById(id, isUse,(long) user.getUID()); + return apidatas; + } +} diff --git a/src/com/engine/salary/cmd/sischeme/SISchemeCopyCmd.java b/src/com/engine/salary/cmd/sischeme/SISchemeCopyCmd.java new file mode 100644 index 000000000..f00e56950 --- /dev/null +++ b/src/com/engine/salary/cmd/sischeme/SISchemeCopyCmd.java @@ -0,0 +1,40 @@ +package com.engine.salary.cmd.sischeme; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.salary.biz.SISchemeBiz; +import weaver.general.Util; +import weaver.hrm.User; + +import java.util.HashMap; +import java.util.Map; + +/** + * @Author weaver_cl + * + * @Date 2022/3/8 + * @Version V1.0 + **/ +@Deprecated +public class SISchemeCopyCmd extends AbstractCommonCommand> { + + public SISchemeCopyCmd(Map params, User user) { + this.user = user; + this.params = params; + } + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + Map apidatas = new HashMap(16); + SISchemeBiz siSchemeBiz = new SISchemeBiz(); + Long id = (Long) params.get("id"); + String schemeName = Util.null2String(params.get("schemeName")); + siSchemeBiz.copy(id,schemeName,(long) user.getUID()); + return apidatas; + } +} diff --git a/src/com/engine/salary/cmd/sischeme/SISchemeDeleteCmd.java b/src/com/engine/salary/cmd/sischeme/SISchemeDeleteCmd.java new file mode 100644 index 000000000..488989936 --- /dev/null +++ b/src/com/engine/salary/cmd/sischeme/SISchemeDeleteCmd.java @@ -0,0 +1,74 @@ +package com.engine.salary.cmd.sischeme; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.salary.biz.SISchemeBiz; +import com.engine.salary.enums.sicategory.WelfareTypeEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import org.apache.commons.collections4.CollectionUtils; +import weaver.hrm.User; + +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; + +/** + * @Author weaver_cl + * + * @Date 2022/3/8 + * @Version V1.0 + **/ +@Deprecated +public class SISchemeDeleteCmd extends AbstractCommonCommand> { + + public SISchemeDeleteCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + Map apidatas = new HashMap(16); + + + Collection ids = (Collection)params.get("ids"); + if (CollectionUtils.isEmpty(ids)) { + throw new SalaryRunTimeException("参数错误"); + } + SISchemeBiz siSchemeBiz = new SISchemeBiz(); + //fixme 校验带上类型 + int welfareTypeId = (Integer) params.get("welfareTypeId"); + if(WelfareTypeEnum.SOCIAL_SECURITY.getValue() == welfareTypeId){ + int num = siSchemeBiz.checkBeforeDeleteSocialscheme(params); + if (num > 0){ + throw new SalaryRunTimeException("该社保方案已被使用"); + } + } + if(WelfareTypeEnum.ACCUMULATION_FUND.getValue() == welfareTypeId){ + int accumulationfundNum = siSchemeBiz.checkBeforeDeleteAccumulationfund(params); + if (accumulationfundNum > 0){ + throw new SalaryRunTimeException("该公积金方案已被使用"); + } + } + if(WelfareTypeEnum.OTHER.getValue() == welfareTypeId){ + int otherschemeNum = siSchemeBiz.checkBeforeDeleteOtherscheme(params); + if (otherschemeNum > 0){ + throw new SalaryRunTimeException("该其他福利方案已被使用"); + } + } + + int billNum = siSchemeBiz.checkBeforeDeleteBill(params,welfareTypeId); + if (billNum > 0){ + throw new SalaryRunTimeException("该福利方案已被核算"); + } + siSchemeBiz.deleteSocialscheme(params); + + return apidatas; + } +} diff --git a/src/com/engine/salary/cmd/sischeme/SISchemeGetFormCmd.java b/src/com/engine/salary/cmd/sischeme/SISchemeGetFormCmd.java new file mode 100644 index 000000000..eb75b5ef1 --- /dev/null +++ b/src/com/engine/salary/cmd/sischeme/SISchemeGetFormCmd.java @@ -0,0 +1,48 @@ +package com.engine.salary.cmd.sischeme; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.salary.biz.SISchemeBiz; +import com.engine.salary.entity.sischeme.vo.InsuranceSchemeFormVO; +import com.engine.salary.enums.sicategory.WelfareTypeEnum; +import weaver.general.Util; +import weaver.hrm.User; + +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** + * @Author weaver_cl + * + * @Date 2022/3/7 + * @Version V1.0 + **/ +@Deprecated +public class SISchemeGetFormCmd extends AbstractCommonCommand> { + + public SISchemeGetFormCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + Map apidatas = new HashMap<>(16); + SISchemeBiz siSchemeBiz = new SISchemeBiz(); + Long id = null; + if (Objects.nonNull(params.get("id"))) { + id =Long.valueOf(Util.null2String(params.get("id"))); + } + WelfareTypeEnum welfareTypeEnum = (WelfareTypeEnum)params.get("welfareTypeEnum"); + InsuranceSchemeFormVO form = siSchemeBiz.getForm(id, welfareTypeEnum); + apidatas.put("form",form); + return apidatas; + } +} diff --git a/src/com/engine/salary/cmd/sischeme/SISchemeInsertCmd.java b/src/com/engine/salary/cmd/sischeme/SISchemeInsertCmd.java new file mode 100644 index 000000000..b4a554fba --- /dev/null +++ b/src/com/engine/salary/cmd/sischeme/SISchemeInsertCmd.java @@ -0,0 +1,40 @@ +package com.engine.salary.cmd.sischeme; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.salary.biz.SISchemeBiz; +import com.engine.salary.entity.sischeme.param.InsuranceSchemeReqParam; +import weaver.hrm.User; + +import java.util.HashMap; +import java.util.Map; + +/** + * @Author weaver_cl + * + * @Date 2022/3/8 + * @Version V1.0 + **/ +@Deprecated +public class SISchemeInsertCmd extends AbstractCommonCommand> { + + public SISchemeInsertCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + Map apidatas = new HashMap(16); + SISchemeBiz siSchemeBiz = new SISchemeBiz(); + InsuranceSchemeReqParam insuranceSchemeReqParam = (InsuranceSchemeReqParam) params.get("insuranceSchemeReqParam"); + siSchemeBiz.save(insuranceSchemeReqParam, (long) user.getUID()); + return apidatas; + } +} diff --git a/src/com/engine/salary/cmd/sischeme/SISchemeListCmd.java b/src/com/engine/salary/cmd/sischeme/SISchemeListCmd.java new file mode 100644 index 000000000..44153bd57 --- /dev/null +++ b/src/com/engine/salary/cmd/sischeme/SISchemeListCmd.java @@ -0,0 +1,61 @@ +package com.engine.salary.cmd.sischeme; + +import com.cloudstore.eccom.result.WeaResultMsg; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.salary.component.SalaryWeaTable; +import com.engine.salary.entity.sischeme.vo.SISchemeTableVO; +import weaver.hrm.User; + +import java.util.Map; +import java.util.Objects; + +/** + * @Author weaver_cl + * + * @Date 2022/3/10 + * @Version V1.0 + **/ +@Deprecated +public class SISchemeListCmd extends AbstractCommonCommand> { + + public SISchemeListCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + + SalaryWeaTable table = new SalaryWeaTable<>(user,SISchemeTableVO.class); + + String sqlWhere = buildSqlWhere(params); + table.setSqlwhere(sqlWhere); + + WeaResultMsg result = new WeaResultMsg(false); + result.putAll(table.makeDataResult()); + result.success(); + return result.getResultMap(); + + } + + private String buildSqlWhere(Map params) { + + String sqlWhere = "where a.id = b.primary_id and b.insurance_id = c.id and a.delete_Type = 0"; + + Integer welfareType = (Integer)params.get("welfareType"); + + + if (Objects.nonNull(welfareType)){ + sqlWhere += " and a.welfare_type ="+welfareType; + } + + return sqlWhere; + } +} diff --git a/src/com/engine/salary/cmd/sischeme/SISchemeUpdateCmd.java b/src/com/engine/salary/cmd/sischeme/SISchemeUpdateCmd.java new file mode 100644 index 000000000..7910223e4 --- /dev/null +++ b/src/com/engine/salary/cmd/sischeme/SISchemeUpdateCmd.java @@ -0,0 +1,40 @@ +package com.engine.salary.cmd.sischeme; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.salary.biz.SISchemeBiz; +import com.engine.salary.entity.sischeme.param.InsuranceSchemeReqParam; +import weaver.hrm.User; + +import java.util.HashMap; +import java.util.Map; + +/** + * @Author weaver_cl + * + * @Date 2022/3/8 + * @Version V1.0 + **/ +@Deprecated +public class SISchemeUpdateCmd extends AbstractCommonCommand> { + + public SISchemeUpdateCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + Map apidatas = new HashMap(16); + SISchemeBiz siSchemeBiz = new SISchemeBiz(); + InsuranceSchemeReqParam insuranceSchemeReqParam = (InsuranceSchemeReqParam) params.get("insuranceSchemeReqParam"); + siSchemeBiz.update(insuranceSchemeReqParam, (long) user.getUID()); + return apidatas; + } +} diff --git a/src/com/engine/salary/common/BaseQueryParam.java b/src/com/engine/salary/common/BaseQueryParam.java new file mode 100644 index 000000000..703231be8 --- /dev/null +++ b/src/com/engine/salary/common/BaseQueryParam.java @@ -0,0 +1,33 @@ +package com.engine.salary.common; + +import com.engine.salary.enums.auth.AuthFilterTypeEnum; +import com.engine.salary.sys.entity.vo.OrderRuleVO; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class BaseQueryParam { + /** + * 页码 + */ + private Integer current = 1; + + /** + * 分页大小 + */ + private Integer pageSize = 10; + + /** + * 排序规则 + */ + private OrderRuleVO orderRule; + + /** + * 数据过滤级别 + */ + private AuthFilterTypeEnum filterType ; +} diff --git a/src/com/engine/salary/common/LocalDateRange.java b/src/com/engine/salary/common/LocalDateRange.java new file mode 100644 index 000000000..ea820594e --- /dev/null +++ b/src/com/engine/salary/common/LocalDateRange.java @@ -0,0 +1,36 @@ +package com.engine.salary.common; + +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.util.Date; + +/** + * 日期范围 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@Accessors(chain = true) +@NoArgsConstructor +@AllArgsConstructor +public class LocalDateRange { + + //"开始日期 + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") + private Date fromDate; + + //结束日期 + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") + private Date endDate; + + +} diff --git a/src/com/engine/salary/common/SalaryContext.java b/src/com/engine/salary/common/SalaryContext.java new file mode 100644 index 000000000..b83bb88fc --- /dev/null +++ b/src/com/engine/salary/common/SalaryContext.java @@ -0,0 +1,38 @@ +package com.engine.salary.common; + +import java.util.HashMap; +import java.util.Map; + + +/** + * 薪酬上下文 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SalaryContext { + public static ThreadLocal context = new ThreadLocal(); + + private Map map = new HashMap<>(); + + public static SalaryContext get() { + if (null == context.get()) { + context.set(new SalaryContext()); + } + return context.get(); + } + + public void setValue(String key, Object value) { + map.put(key, value); + } + + public Object getValue(String key) { + return map.get(key); + } + + public void removeContext() { + context.remove(); + } +} \ No newline at end of file diff --git a/src/com/engine/salary/component/Page.java b/src/com/engine/salary/component/Page.java new file mode 100644 index 000000000..a23215bfb --- /dev/null +++ b/src/com/engine/salary/component/Page.java @@ -0,0 +1,170 @@ +package com.engine.salary.component; + + +import java.util.ArrayList; +import java.util.List; + +public class Page extends ArrayList { + private static final long serialVersionUID = 1L; + + /** + * 页码,从1开始 + */ + private int pageNum; + /** + * 页面大小 + */ + private int pageSize; + /** + * 起始行 + */ + private int startRow; + /** + * 末行 + */ + private int endRow; + /** + * 总数 + */ + private long total; + /** + * 总页数 + */ + private int pages; + /** + * 包含count查询 + */ + private boolean count = true; + /** + * 分页合理化 + */ + private Boolean reasonable; + /** + * 当设置为true的时候,如果pagesize设置为0(或RowBounds的limit=0),就不执行分页,返回全部结果 + */ + private Boolean pageSizeZero; + + public Page() { + super(); + } + + + /** + * int[] rowBounds + * 0 : offset + * 1 : limit + */ + public Page(int[] rowBounds, boolean count) { + super(0); + if (rowBounds[0] == 0 && rowBounds[1] == Integer.MAX_VALUE) { + pageSizeZero = true; + this.pageSize = 0; + } else { + this.pageSize = rowBounds[1]; + this.pageNum = rowBounds[1] != 0 ? (int) (Math.ceil(((double) rowBounds[0] + rowBounds[1]) / rowBounds[1])) : 0; + } + this.startRow = rowBounds[0]; + this.count = count; + this.endRow = this.startRow + rowBounds[1]; + } + + public List getResult() { + return this; + } + + public int getPages() { + return pages; + } + + + public int getEndRow() { + return endRow; + } + + + public int getPageNum() { + return pageNum; + } + + + public int getPageSize() { + return pageSize; + } + + + public int getStartRow() { + return startRow; + } + + + public long getTotal() { + return total; + } + + public void setTotal(long total) { + this.total = total; + if (total == -1) { + pages = 1; + return; + } + if (pageSize > 0) { + pages = (int) (total / pageSize + ((total % pageSize == 0) ? 0 : 1)); + } else { + pages = 0; + } + //分页合理化,针对不合理的页码自动处理 + if ((reasonable != null && reasonable) && pageNum > pages) { + pageNum = pages; + calculateStartAndEndRow(); + } + } + + public Boolean getReasonable() { + return reasonable; + } + + + public Boolean getPageSizeZero() { + return pageSizeZero; + } + + + /** + * 计算起止行号 + */ + private void calculateStartAndEndRow() { + this.startRow = this.pageNum > 0 ? (this.pageNum - 1) * this.pageSize : 0; + this.endRow = this.startRow + this.pageSize * (this.pageNum > 0 ? 1 : 0); + } + + public boolean isCount() { + return this.count; + } + + + /** + * 转换为PageInfo + * + * @return + */ + public PageInfo toPageInfo() { + PageInfo pageInfo = new PageInfo(this); + return pageInfo; + } + + + @Override + public String toString() { + return "Page{" + + "count=" + count + + ", pageNum=" + pageNum + + ", pageSize=" + pageSize + + ", startRow=" + startRow + + ", endRow=" + endRow + + ", total=" + total + + ", pages=" + pages + + ", reasonable=" + reasonable + + ", pageSizeZero=" + pageSizeZero + + '}'; + } +} \ No newline at end of file diff --git a/src/com/engine/salary/component/PageInfo.java b/src/com/engine/salary/component/PageInfo.java new file mode 100644 index 000000000..6a630a6e4 --- /dev/null +++ b/src/com/engine/salary/component/PageInfo.java @@ -0,0 +1,380 @@ +package com.engine.salary.component; + + +import java.io.Serializable; +import java.util.Collection; +import java.util.List; + +/** + * 对Page 结果进行包装 + * pageHelper的替代 + *

Copyright: Copyright (c) 2024

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class PageInfo implements Serializable { + private static final long serialVersionUID = 1L; + //当前页 + private int pageNum; + //每页的数量 + private int pageSize; + //当前页的数量 + private int size; + + //由于startRow和endRow不常用,这里说个具体的用法 + //可以在页面中"显示startRow到endRow 共size条数据" + + //当前页面第一个元素在数据库中的行号 + private int startRow; + //当前页面最后一个元素在数据库中的行号 + private int endRow; + //总记录数 + private long total; + //总页数 + private int pages; + //结果集 + private List list; + + //前一页 + private int prePage; + //下一页 + private int nextPage; + + //是否为第一页 + private boolean isFirstPage = false; + //是否为最后一页 + private boolean isLastPage = false; + //是否有前一页 + private boolean hasPreviousPage = false; + //是否有下一页 + private boolean hasNextPage = false; + //导航页码数 + private int navigatePages; + //所有导航页号 + private int[] navigatepageNums; + //导航条上的第一页 + private int navigateFirstPage; + //导航条上的最后一页 + private int navigateLastPage; + + public PageInfo() { + } + + /** + * 包装Page对象 + * + * @param list + */ + public PageInfo(List list) { + this(list, 8); + } + + /** + * 包装Page对象 + * + * @param list page结果 + * @param navigatePages 页码数量 + */ + public PageInfo(List list, int navigatePages) { + if (list instanceof Page) { + Page page = (Page) list; + this.pageNum = page.getPageNum(); + this.pageSize = page.getPageSize(); + + this.pages = page.getPages(); + this.list = page; + this.size = page.size(); + this.total = page.getTotal(); + //由于结果是>startRow的,所以实际的需要+1 + if (this.size == 0) { + this.startRow = 0; + this.endRow = 0; + } else { + this.startRow = page.getStartRow() + 1; + //计算实际的endRow(最后一页的时候特殊) + this.endRow = this.startRow - 1 + this.size; + } + } else if (list instanceof Collection) { + this.pageNum = 1; + this.pageSize = list.size(); + + this.pages = 1; + this.list = list; + this.size = list.size(); + this.total = list.size(); + this.startRow = 0; + this.endRow = list.size() > 0 ? list.size() - 1 : 0; + } + if (list instanceof Collection) { + this.navigatePages = navigatePages; + //计算导航页 + calcNavigatepageNums(); + //计算前后页,第一页,最后一页 + calcPage(); + //判断页面边界 + judgePageBoudary(); + } + } + + /** + * 计算导航页 + */ + private void calcNavigatepageNums() { + //当总页数小于或等于导航页码数时 + if (pages <= navigatePages) { + navigatepageNums = new int[pages]; + for (int i = 0; i < pages; i++) { + navigatepageNums[i] = i + 1; + } + } else { //当总页数大于导航页码数时 + navigatepageNums = new int[navigatePages]; + int startNum = pageNum - navigatePages / 2; + int endNum = pageNum + navigatePages / 2; + + if (startNum < 1) { + startNum = 1; + //(最前navigatePages页 + for (int i = 0; i < navigatePages; i++) { + navigatepageNums[i] = startNum++; + } + } else if (endNum > pages) { + endNum = pages; + //最后navigatePages页 + for (int i = navigatePages - 1; i >= 0; i--) { + navigatepageNums[i] = endNum--; + } + } else { + //所有中间页 + for (int i = 0; i < navigatePages; i++) { + navigatepageNums[i] = startNum++; + } + } + } + } + + /** + * 计算前后页,第一页,最后一页 + */ + private void calcPage() { + if (navigatepageNums != null && navigatepageNums.length > 0) { + navigateFirstPage = navigatepageNums[0]; + navigateLastPage = navigatepageNums[navigatepageNums.length - 1]; + if (pageNum > 1) { + prePage = pageNum - 1; + } + if (pageNum < pages) { + nextPage = pageNum + 1; + } + } + } + + /** + * 判定页面边界 + */ + private void judgePageBoudary() { + isFirstPage = pageNum == 1; + isLastPage = pageNum == pages; + hasPreviousPage = pageNum > 1; + hasNextPage = pageNum < pages; + } + + public int getPageNum() { + return pageNum; + } + + public void setPageNum(int pageNum) { + this.pageNum = pageNum; + } + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + public int getSize() { + return size; + } + + public void setSize(int size) { + this.size = size; + } + + public int getStartRow() { + return startRow; + } + + public void setStartRow(int startRow) { + this.startRow = startRow; + } + + public int getEndRow() { + return endRow; + } + + public void setEndRow(int endRow) { + this.endRow = endRow; + } + + public long getTotal() { + return total; + } + + public void setTotal(long total) { + this.total = total; + } + + public int getPages() { + return pages; + } + + public void setPages(int pages) { + this.pages = pages; + } + + public List getList() { + return list; + } + + public void setList(List list) { + this.list = list; + } + + @Deprecated + // firstPage就是1, 此函数获取的是导航条上的第一页, 容易产生歧义 + public int getFirstPage() { + return navigateFirstPage; + } + + @Deprecated + public void setFirstPage(int firstPage) { + this.navigateFirstPage = firstPage; + } + + public int getPrePage() { + return prePage; + } + + public void setPrePage(int prePage) { + this.prePage = prePage; + } + + public int getNextPage() { + return nextPage; + } + + public void setNextPage(int nextPage) { + this.nextPage = nextPage; + } + + @Deprecated + // 请用getPages()来获取最后一页, 此函数获取的是导航条上的最后一页, 容易产生歧义. + public int getLastPage() { + return navigateLastPage; + } + + @Deprecated + public void setLastPage(int lastPage) { + this.navigateLastPage = lastPage; + } + + public boolean isIsFirstPage() { + return isFirstPage; + } + + public void setIsFirstPage(boolean isFirstPage) { + this.isFirstPage = isFirstPage; + } + + public boolean isIsLastPage() { + return isLastPage; + } + + public void setIsLastPage(boolean isLastPage) { + this.isLastPage = isLastPage; + } + + public boolean isHasPreviousPage() { + return hasPreviousPage; + } + + public void setHasPreviousPage(boolean hasPreviousPage) { + this.hasPreviousPage = hasPreviousPage; + } + + public boolean isHasNextPage() { + return hasNextPage; + } + + public void setHasNextPage(boolean hasNextPage) { + this.hasNextPage = hasNextPage; + } + + public int getNavigatePages() { + return navigatePages; + } + + public void setNavigatePages(int navigatePages) { + this.navigatePages = navigatePages; + } + + public int[] getNavigatepageNums() { + return navigatepageNums; + } + + public void setNavigatepageNums(int[] navigatepageNums) { + this.navigatepageNums = navigatepageNums; + } + + public int getNavigateFirstPage() { + return navigateFirstPage; + } + + public int getNavigateLastPage() { + return navigateLastPage; + } + + public void setNavigateFirstPage(int navigateFirstPage) { + this.navigateFirstPage = navigateFirstPage; + } + + public void setNavigateLastPage(int navigateLastPage) { + this.navigateLastPage = navigateLastPage; + } + + @Override + public String toString() { + final StringBuffer sb = new StringBuffer("PageInfo{"); + sb.append("pageNum=").append(pageNum); + sb.append(", pageSize=").append(pageSize); + sb.append(", size=").append(size); + sb.append(", startRow=").append(startRow); + sb.append(", endRow=").append(endRow); + sb.append(", total=").append(total); + sb.append(", pages=").append(pages); + sb.append(", list=").append(list); + sb.append(", prePage=").append(prePage); + sb.append(", nextPage=").append(nextPage); + sb.append(", isFirstPage=").append(isFirstPage); + sb.append(", isLastPage=").append(isLastPage); + sb.append(", hasPreviousPage=").append(hasPreviousPage); + sb.append(", hasNextPage=").append(hasNextPage); + sb.append(", navigatePages=").append(navigatePages); + sb.append(", navigateFirstPage").append(navigateFirstPage); + sb.append(", navigateLastPage").append(navigateLastPage); + sb.append(", navigatepageNums="); + if (navigatepageNums == null) sb.append("null"); + else { + sb.append('['); + for (int i = 0; i < navigatepageNums.length; ++i) + sb.append(i == 0 ? "" : ", ").append(navigatepageNums[i]); + sb.append(']'); + } + sb.append('}'); + return sb.toString(); + } +} diff --git a/src/com/engine/salary/component/PageInterceptor.java b/src/com/engine/salary/component/PageInterceptor.java new file mode 100644 index 000000000..a41d739dd --- /dev/null +++ b/src/com/engine/salary/component/PageInterceptor.java @@ -0,0 +1,176 @@ +package com.engine.salary.component; + + +import org.apache.commons.lang3.StringUtils; +import org.apache.ibatis.binding.MapperMethod; +import org.apache.ibatis.executor.parameter.ParameterHandler; +import org.apache.ibatis.executor.statement.RoutingStatementHandler; +import org.apache.ibatis.executor.statement.StatementHandler; +import org.apache.ibatis.mapping.BoundSql; +import org.apache.ibatis.mapping.MappedStatement; +import org.apache.ibatis.mapping.ParameterMapping; +import org.apache.ibatis.plugin.*; +import org.apache.ibatis.scripting.defaults.DefaultParameterHandler; +import weaver.conn.RecordSet; + +import javax.xml.bind.PropertyException; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.List; +import java.util.Properties; + + +@Intercepts({@Signature(method = "prepare", type = StatementHandler.class, args = {Connection.class,Integer.class})}) +@SuppressWarnings("rawtypes") +public class PageInterceptor implements Interceptor { + private static String databaseType = "";// 数据库类型,不同的数据库有不同的分页方法 + + /** + * 拦截后要执行的方法 + */ + public Object intercept(Invocation invocation) throws Throwable { + + RoutingStatementHandler handler = (RoutingStatementHandler) invocation + .getTarget(); + StatementHandler delegate = (StatementHandler) ReflectUtil.getFieldValue(handler, "delegate"); + BoundSql boundSql = delegate.getBoundSql(); + Object params = boundSql.getParameterObject(); + Page page = null; + if (params instanceof Page) { + page = (Page) params; + } else if (params instanceof MapperMethod.ParamMap) { + MapperMethod.ParamMap paramMap = (MapperMethod.ParamMap) params; + for (Object key : paramMap.keySet()) { + if (paramMap.get(key) instanceof Page) { + page = (Page) paramMap.get(key); + break; + } + } + } + + if (page != null) { + MappedStatement mappedStatement = (MappedStatement) ReflectUtil + .getFieldValue(delegate, "mappedStatement"); + Connection connection = (Connection) invocation.getArgs()[0]; + String sql = boundSql.getSql(); + this.setTotalRecord(page, (MapperMethod.ParamMap) params, + mappedStatement, connection); + String pageSql = this.getPageSql(page, sql); + ReflectUtil.setFieldValue(boundSql, "sql", pageSql); + } + return invocation.proceed(); + } + + /** + * 拦截器对应的封装原始对象的方法 + */ + public Object plugin(Object target) { + return Plugin.wrap(target, this); + } + + public void setProperties(Properties p) { + databaseType = p.getProperty("databaseType"); + if (StringUtils.isEmpty(databaseType)) { + try { + throw new PropertyException("databaseType is not found!"); + } catch (PropertyException e) { + e.printStackTrace(); + } + } + } + + private String getPageSql(Page page, String sql) { + StringBuffer sqlBuffer = new StringBuffer(sql); + RecordSet recordSet = new RecordSet(); + + String dbType = recordSet.getDBType(); + if ("mysql".equalsIgnoreCase(dbType)) { + return getMysqlPageSql(page, sqlBuffer); + } else if ("oracle".equalsIgnoreCase(dbType)) { + return getOraclePageSql(page, sqlBuffer); + } else if ("sqlserver".equalsIgnoreCase(dbType)) { + return getSqlserverPageSql(page, sqlBuffer); + } + return sqlBuffer.toString(); + } + + private String getSqlserverPageSql(Page page, StringBuffer sqlBuffer) { + // 计算第一条记录的位置,Sqlserver中记录的位置是从0开始的。 + int startRowNum = (page.getPageNum() - 1) * page.getPageSize() + 1; + int endRowNum = startRowNum + page.getPageSize(); + String sql = "select appendRowNum.row,* from (select ROW_NUMBER() OVER (order by (select 0)) AS row,* from (" + + sqlBuffer.toString() + + ") as innerTable" + + ")as appendRowNum where appendRowNum.row >= " + + startRowNum + + " AND appendRowNum.row <= " + endRowNum; + return sql; + } + + private String getMysqlPageSql(Page page, StringBuffer sqlBuffer) { + // 计算第一条记录的位置,Mysql中记录的位置是从0开始的。 + int offset = (page.getPageNum() - 1) * page.getPageSize(); + sqlBuffer.append(" limit ").append(offset).append(",").append(page.getPageSize()); + return sqlBuffer.toString(); + } + + private String getOraclePageSql(Page page, StringBuffer sqlBuffer) { + // 计算第一条记录的位置,Oracle分页是通过rownum进行的,而rownum是从1开始的 + int offset = (page.getPageNum() - 1) * page.getPageSize() + 1; + sqlBuffer.insert(0, "select u.*, rownum r from (").append(") u where rownum < ") + .append(offset + page.getPageSize()); + sqlBuffer.insert(0, "select * from (").append(") where r >= ").append(offset); + return sqlBuffer.toString(); + } + + /** + * 给当前的参数对象page设置总记录数 + * + * @param page Mapper映射语句对应的参数对象 + * @param mappedStatement Mapper映射语句 + * @param connection + */ + private void setTotalRecord(Page page, MapperMethod.ParamMap params, + MappedStatement mappedStatement, Connection connection) { + BoundSql boundSql = mappedStatement.getBoundSql(params); + String sql = boundSql.getSql(); + String countSql = this.getCountSql(sql); + List parameterMappings = boundSql.getParameterMappings(); + BoundSql countBoundSql = new BoundSql(mappedStatement.getConfiguration(), countSql, parameterMappings, params); + ParameterHandler parameterHandler = new DefaultParameterHandler( + mappedStatement, params, countBoundSql); + PreparedStatement pstmt = null; + ResultSet rs = null; + try { + pstmt = connection.prepareStatement(countSql); + parameterHandler.setParameters(pstmt); + rs = pstmt.executeQuery(); + if (rs.next()) { + int totalRecord = rs.getInt(1); +// page.setTotalRecord(totalRecord); + } + } catch (SQLException e) { + e.printStackTrace(); + } finally { + try { + if (rs != null) rs.close(); + if (pstmt != null) pstmt.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + } + + /** + * 根据原Sql语句获取对应的查询总记录数的Sql语句 + * + * @param sql + * @return + */ + private String getCountSql(String sql) { + return "select count(*) from (" + sql + ") as countRecord"; + } + +} diff --git a/src/com/engine/salary/component/ReflectUtil.java b/src/com/engine/salary/component/ReflectUtil.java new file mode 100644 index 000000000..75d777b22 --- /dev/null +++ b/src/com/engine/salary/component/ReflectUtil.java @@ -0,0 +1,174 @@ +package com.engine.salary.component; + +import org.apache.commons.beanutils.BeanUtils; +import org.apache.commons.lang3.StringUtils; +import org.springframework.util.Assert; + +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + + +/** + * 利用反射进行操作的一个工具类 + */ +public class ReflectUtil { + /** + * 利用反射获取指定对象的指定属性 + * + * @param obj + * 目标对象 + * @param fieldName + * 目标属性 + * @return 目标属性的值 + */ + public static Object getFieldValue(Object obj, String fieldName) { + Object result = null; + Field field = ReflectUtil.getField(obj, fieldName); + if (field != null) { + field.setAccessible(true); + try { + result = field.get(obj); + } catch (IllegalArgumentException e) { + e.printStackTrace(); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } + } + return result; + } + + /** + * 利用反射获取指定对象里面的指定属性 + * + * @param obj + * 目标对象 + * @param fieldName + * 目标属性 + * @return 目标字段 + */ + private static Field getField(Object obj, String fieldName) { + Field field = null; + for (Class clazz = obj.getClass(); clazz != Object.class; clazz = clazz + .getSuperclass()) { + try { + field = clazz.getDeclaredField(fieldName); + break; + } catch (NoSuchFieldException e) { + // 这里不用做处理,子类没有该字段可能对应的父类有,都没有就返回null。 + } + } + return field; + } + + /** + * 利用反射设置指定对象的指定属性为指定的值 + * + * @param obj + * 目标对象 + * @param fieldName + * 目标属性 + * @param fieldValue + * 目标值 + */ + public static void setFieldValue(Object obj, String fieldName, + String fieldValue) { + Field field = ReflectUtil.getField(obj, fieldName); + if (field != null) { + try { + field.setAccessible(true); + field.set(obj, fieldValue); + } catch (IllegalArgumentException e) { + e.printStackTrace(); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } + } + } + + /** + * 两者属性名一致时,拷贝source里的属性到dest里 + * + * @return void + * @throws IllegalArgumentException + * @throws IllegalAccessException + * @throws InvocationTargetException + */ + @SuppressWarnings("unchecked") + public static void copyPorperties(Object dest, Object source) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException{ + Class srcCla = source.getClass(); + Field[] fsF = srcCla.getDeclaredFields(); + + for (Field s : fsF) + { + String name = s.getName(); + Object srcObj = invokeGetterMethod(source, name); + try + { + BeanUtils.setProperty(dest, name, srcObj); + } + catch (Exception e){ + e.printStackTrace(); + } + + } + } + + /** + * 调用Getter方法. + * @throws InvocationTargetException + * @throws IllegalArgumentException + * @throws IllegalAccessException + */ + public static Object invokeGetterMethod(Object target, String propertyName) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException + { + String getterMethodName = "get" + StringUtils.capitalize(propertyName); + return invokeMethod(target, getterMethodName, new Class[] {}, + new Object[] {}); + } + + /** + * 直接调用对象方法, 无视private/protected修饰符. + * @throws InvocationTargetException + * @throws IllegalArgumentException + * @throws IllegalAccessException + */ + public static Object invokeMethod(final Object object, + final String methodName, final Class[] parameterTypes, + final Object[] parameters) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException{ + Method method = getDeclaredMethod(object, methodName, parameterTypes); + if (method == null) + { + throw new IllegalArgumentException("Could not find method [" + + methodName + "] parameterType " + parameterTypes + + " on target [" + object + "]"); + } + + method.setAccessible(true); + return method.invoke(object, parameters); + } + + /** + * 循环向上转型, 获取对象的DeclaredMethod. + * + * 如向上转型到Object仍无法找到, 返回null. + */ + protected static Method getDeclaredMethod(Object object, String methodName, + Class[] parameterTypes) + { + Assert.notNull(object, "object不能为空"); + + for (Class superClass = object.getClass(); superClass != Object.class; superClass = superClass + .getSuperclass()) + { + try{ + return superClass.getDeclaredMethod(methodName, parameterTypes); + } + catch (NoSuchMethodException e) + {// NOSONAR + // Method不在当前类定义,继续向上转型 + } + } + return null; + } +} diff --git a/src/com/engine/salary/component/SalaryWeaTable.java b/src/com/engine/salary/component/SalaryWeaTable.java new file mode 100644 index 000000000..b4e41a76c --- /dev/null +++ b/src/com/engine/salary/component/SalaryWeaTable.java @@ -0,0 +1,116 @@ +package com.engine.salary.component; + +import com.cloudstore.eccom.constant.WeaBoolAttr; +import com.cloudstore.eccom.pc.table.*; +import com.engine.salary.annotation.SalaryTable; +import com.engine.salary.annotation.SalaryTableColumn; +import com.engine.salary.annotation.SalaryTableOperate; +import org.apache.commons.lang3.StringUtils; +import weaver.general.PageIdConst; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class SalaryWeaTable extends WeaTable { + + public SalaryWeaTable(User user, Class clazz) { + + boolean isAnno = clazz.isAnnotationPresent(SalaryTable.class); + if (isAnno) { + SalaryTable table = (SalaryTable) clazz.getAnnotation(SalaryTable.class); + String pageId = table.pageId(); + super.setPageID(pageId); + String pageUid = pageId + "_" + user.getUID(); + super.setPageUID(pageUid); + String pageSize = PageIdConst.getPageSize(pageId, user.getUID()); + super.setPagesize(pageSize); + String backfields = table.fields(); + super.setBackfields(backfields); + String sql = table.fromSql(); + super.setSqlform(sql); + String where = table.where(); + if (StringUtils.isNotBlank(where)) { + super.setSqlwhere(where); + } + String orderby = table.orderby(); + if (StringUtils.isNotBlank(orderby)) { + super.setSqlorderby(orderby); + } + String groupby = table.groupby(); + if (StringUtils.isNotBlank(groupby)) { + super.setSqlgroupby(groupby); + } + boolean distinct = table.distinct(); + super.setSqlisdistinct(String.valueOf(distinct)); + String primarykey = table.primarykey(); + if (StringUtils.isNotBlank(primarykey)) { + super.setSqlprimarykey(primarykey); + } + SalaryTableOperate[] operates = table.operates(); + if (operates != null && operates.length > 0) { + List operateList = new ArrayList<>(); + Arrays.stream(operates).forEach(o -> { + String text = o.text(); + int labelId = o.labelId(); + String htmlLabelName = SystemEnv.getHtmlLabelName(labelId, user.getLanguage()); + if (StringUtils.isNotBlank(htmlLabelName)) { + text = htmlLabelName; + } + WeaTableOperate weaTableOperate = new WeaTableOperate(text, o.href(), o.index()); + operateList.add(weaTableOperate); + }); + WeaTableOperates weaTableOperates = new WeaTableOperates(); + weaTableOperates.setOperate(operateList); + super.setOperates(weaTableOperates); + } + + WeaTableType weaTableTypeEnum = table.tableType(); + //设置check是否可用 + if (weaTableTypeEnum == WeaTableType.CHECKBOX) { + super.setTableType(weaTableTypeEnum); +// WeaTableCheckboxpopedom checkboxpopedom = new WeaTableCheckboxpopedom(); +// checkboxpopedom.setShowmethod("true"); +// super.setCheckboxpopedom(checkboxpopedom); + } + + } + + Field[] fields = clazz.getDeclaredFields(); + for (Field f : fields) { + boolean isanno = f.isAnnotationPresent(SalaryTableColumn.class); + if (isanno) { + SalaryTableColumn columnAnn = f.getAnnotation(SalaryTableColumn.class); + String text = columnAnn.text(); + int labelId = columnAnn.labelId(); + String htmlLabelName = SystemEnv.getHtmlLabelName(labelId, user.getLanguage()); + if (StringUtils.isNotBlank(htmlLabelName)) { + text = htmlLabelName; + } + String width = columnAnn.width(); + String column = columnAnn.column(); + String orderkey = columnAnn.orderkey(); + boolean display = columnAnn.display(); + WeaTableColumn weaTableColumn = new WeaTableColumn(width, text, column, orderkey); + String transmethod = columnAnn.transmethod(); + + if (StringUtils.isNotBlank(transmethod)) { + weaTableColumn.setTransmethod(transmethod); + } + String otherPara = columnAnn.otherPara(); + if(StringUtils.isNotBlank(otherPara)) { + weaTableColumn.setOtherpara(otherPara); + } + if (!display) { + weaTableColumn.setDisplay(WeaBoolAttr.FALSE); + } + super.getColumns().add(weaTableColumn); + } + } + + + } +} diff --git a/src/com/engine/salary/component/WeaFormOption.java b/src/com/engine/salary/component/WeaFormOption.java new file mode 100644 index 000000000..ba01d7c58 --- /dev/null +++ b/src/com/engine/salary/component/WeaFormOption.java @@ -0,0 +1,75 @@ +package com.engine.salary.component; + +import java.io.Serializable; + +public class WeaFormOption implements Serializable { + private static final long serialVersionUID = -4539753893868901626L; + private String id; + private String content; + private boolean disabled; + + private boolean canEdit; + + private boolean canDelete; + + public WeaFormOption() { + this.disabled = Boolean.FALSE; + } + + public WeaFormOption(String id, String content) { + this.disabled = Boolean.FALSE; + this.canEdit = Boolean.TRUE; + this.canDelete = Boolean.TRUE; + this.id = id; + this.content = content; + } + + public WeaFormOption(String id, String content, boolean canEdit, boolean canDelete) { + this.disabled = Boolean.FALSE; + this.id = id; + this.content = content; + this.canEdit = canEdit; + this.canDelete = canDelete; + } + + public String getId() { + return this.id; + } + + public void setId(String id) { + this.id = id; + } + + public String getContent() { + return this.content; + } + + public void setContent(String content) { + this.content = content; + } + + + public boolean isDisabled() { + return this.disabled; + } + + public void setDisabled(boolean disabled) { + this.disabled = disabled; + } + + public boolean isCanEdit() { + return canEdit; + } + + public void setCanEdit(boolean canEdit) { + this.canEdit = canEdit; + } + + public boolean isCanDelete() { + return canDelete; + } + + public void setCanDelete(boolean canDelete) { + this.canDelete = canDelete; + } +} diff --git a/src/com/engine/salary/component/WeaTableColumnGroup.java b/src/com/engine/salary/component/WeaTableColumnGroup.java new file mode 100644 index 000000000..0dcd305af --- /dev/null +++ b/src/com/engine/salary/component/WeaTableColumnGroup.java @@ -0,0 +1,68 @@ +package com.engine.salary.component; + +import com.cloudstore.eccom.pc.table.WeaTableColumn; +import lombok.Data; + +import java.util.List; + +@Data +public class WeaTableColumnGroup extends WeaTableColumn { + + /** + * 锁定状态 + */ + private String lockStatus; + + /** + * 保留小数位数 + */ + private Integer pattern; + + /** + * 字段类型 + */ + private String dataType; + + private List children; + + public WeaTableColumnGroup() { + } + + public WeaTableColumnGroup(String width, String text, String column) { + super(width, text, column); + this.pattern = 0; + } + + public WeaTableColumnGroup(String width, String text, String column, String lockStatus) { + super(width, text, column); + this.lockStatus = lockStatus; + this.pattern = 0; + } + + public WeaTableColumnGroup(String width, String text, String column, String lockStatus, Integer pattern) { + super(width, text, column); + this.lockStatus = lockStatus; + this.pattern = pattern; + } + + public WeaTableColumnGroup(String width, String text, String column, String lockStatus, Integer pattern, String dataType) { + super(width, text, column); + this.lockStatus = lockStatus; + this.pattern = pattern; + this.dataType = dataType; + } + + + public WeaTableColumnGroup(String width, String text, String column, List children) { + super(width, text, column); + this.children = children; + this.pattern = 0; + } + + public WeaTableColumnGroup(String width, String text, String column, List children, String lockStatus) { + super(width, text, column); + this.children = children; + this.lockStatus = lockStatus; + this.pattern = 0; + } +} diff --git a/src/com/engine/salary/config/SalaryElogConfig.java b/src/com/engine/salary/config/SalaryElogConfig.java new file mode 100644 index 000000000..909fdb9c4 --- /dev/null +++ b/src/com/engine/salary/config/SalaryElogConfig.java @@ -0,0 +1,325 @@ +package com.engine.salary.config; + +import com.engine.hrmelog.util.LoggerTemplate; +import com.engine.hrmelog.util.LoggerTemplateBuilder; + +/** + * elog日志 + *

Copyright: Copyright (c) 2023

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SalaryElogConfig { + + /** + * 个税税率表 + * + * @return + */ + public final static LoggerTemplate taxRateLoggerTemplate = LoggerTemplateBuilder.build("hrsa", "taxrate"); + + /** + * 薪资项目 + * + * @return + */ + public static LoggerTemplate salaryItemLoggerTemplate = LoggerTemplateBuilder.build("hrsa", "salaryitem"); + + /** + * 个税扣缴义务人 + * + * @return + */ + public static LoggerTemplate taxAgentLoggerTemplate = LoggerTemplateBuilder.build("hrsa", "taxagent"); + + public static LoggerTemplate siCategoryLoggerTemplate = LoggerTemplateBuilder.build("hrsa", "siCategory"); + + public static LoggerTemplate siSchemeLoggerTemplate = LoggerTemplateBuilder.build("hrsa", "siScheme"); + + public static LoggerTemplate totalSchemeLoggerTemplate = LoggerTemplateBuilder.build("hrsa", "totalScheme"); + + /** + * 累计情况 + * + * @return + */ + public static LoggerTemplate addUpSituationLoggerTemplate = LoggerTemplateBuilder.build("hrsa", "addupsituation"); + + /** + * 累计专项附加扣除 + * + * @return + */ + public static LoggerTemplate addUpDeductionLoggerTemplate = LoggerTemplateBuilder.build("hrsa", "addupdeduction"); + + /** + * 其他免税扣除 + * + * @return + */ + public static LoggerTemplate otherDeductionLoggerTemplate = LoggerTemplateBuilder.build("hrsa", "otherdeduction"); + + /** + * 专项附加扣除 + * + * @return + */ + public static LoggerTemplate specialAddDeductionLoggerTemplate = LoggerTemplateBuilder.build("hrsa", "specialAddDeduction"); + + /** + * 减税 + * + * @return + */ + public static LoggerTemplate derateDeductionLoggerTemplate = LoggerTemplateBuilder.build("hrsa", "deratededuction"); + + /** + * 税延养老保险 + * + * @return + */ + public static LoggerTemplate endowmentInsuranceLoggerTemplate = LoggerTemplateBuilder.build("hrsa", "endowmentinsurance"); + + /** + * 税延养老保险 + * + * @return + */ + public static LoggerTemplate freeIncomeLoggerTemplate = LoggerTemplateBuilder.build("hrsa", "freeincome"); + + /** + * 捐赠免税 + * + * @return + */ + public static LoggerTemplate grantDonationLoggerTemplate = LoggerTemplateBuilder.build("hrsa", "grantdonation"); + + /** + * 捐赠免税 + * + * @return + */ + public static LoggerTemplate healthInsuranceLoggerTemplate = LoggerTemplateBuilder.build("hrsa", "healthinsurance"); + + /** + * 其他免税扣除 + * + * @return + */ + public static LoggerTemplate otherDerateDeductionLoggerTemplate = LoggerTemplateBuilder.build("hrsa", "otherderatededuction"); + + /** + * 考勤引用 + * + * @return + */ + public static LoggerTemplate attendQuoteLoggerTemplate = LoggerTemplateBuilder.build("hrsa", "attendquote"); + + /** + * 考勤引用字段管理 + * + * @return + */ + public static LoggerTemplate attendQuoteFieldLoggerTemplate = LoggerTemplateBuilder.build("hrsa", "attendfield"); + + /** + * 考勤引用字段设置 + * + * @return + */ + public static LoggerTemplate attendQuoteFieldSettingLoggerTemplate = LoggerTemplateBuilder.build("hrsa", "attendfieldset"); + + /** + * 薪资账套 + * + * @return + */ + public static LoggerTemplate salarySobLoggerTemplate = LoggerTemplateBuilder.build("hrsa", "salarysob"); + + /** + * 薪资核算 + * + * @return + */ + public static LoggerTemplate salaryAcctRecordLoggerTemplate = LoggerTemplateBuilder.build("hrsa", "acctrecord"); + /** + * 个税申报表 + * + * @return + */ + public static LoggerTemplate taxDeclarationLoggerTemplate = LoggerTemplateBuilder.build("hrsa", "taxdecla"); + + /** + * 福利档案 + * + * @return + */ + public static LoggerTemplate siArchivesLoggerTemplate = LoggerTemplateBuilder.build("hrsa", "siarchives"); + + /** + * 社保规则 + */ + public static LoggerTemplate archiveRuleLoggerTemplate = LoggerTemplateBuilder.build("hrsa", "archiverule"); + + /** + * 代缴机构 + * + * @return + */ + public static LoggerTemplate paymentAgencyLoggerTemplate = LoggerTemplateBuilder.build("hrsa", "paymentagency"); + + /** + * 福利核算 + * + * @return + */ + public static LoggerTemplate siAccountLoggerTemplate = LoggerTemplateBuilder.build("hrsa", "siaccount"); + + /** + * 工资单模板 + * + * @return + */ + public static LoggerTemplate salaryTemplateLoggerTemplate = LoggerTemplateBuilder.build("hrsa", "salarytemplate"); + + /** + * 工资单发放 + * + * @return + */ + public static LoggerTemplate salarySendLoggerTemplate = LoggerTemplateBuilder.build("hrsa", "salarysend"); + + /** + * 外部人员 + * + * @return + */ + public static LoggerTemplate extEmployeeLoggerTemplate = LoggerTemplateBuilder.build("hrsa", "extemployee"); + + /** + * 薪资档案 + * + * @return + */ + public static LoggerTemplate salaryArchiveLoggerTemplate = LoggerTemplateBuilder.build("hrsa", "salaryarchive"); + + /** + * 薪资档案-字段 + * + * @return + */ + public static LoggerTemplate salaryArchiveFieldLoggerTemplate = LoggerTemplateBuilder.build("hrsa", "salarcfield"); + /** + * 薪资档案-薪资项目调整 + * + * @return + */ + public static LoggerTemplate salaryArchiveItemAdjustLoggerTemplate = LoggerTemplateBuilder.build("hrsa", "salarcitemadj"); + + /** + * 薪资档案-批量调薪 + * + * @return + */ + public static LoggerTemplate salaryArchiveBatchAdjustLoggerTemplate = LoggerTemplateBuilder.build("hrsa", "salarcbatadj"); + + /** + * 自定义业务数据设置 + * + * @return + */ + public static LoggerTemplate customDataSetLoggerTemplate = LoggerTemplateBuilder.build("hrsa", "customdataset"); + + /** + * 自定义业务数据 + * + * @return + */ + public static LoggerTemplate customDataLoggerTemplate = LoggerTemplateBuilder.build("hrsa", "customdata"); + + + /** + * 人员报送 + * + * @return + */ + public static LoggerTemplate employeeDeclareLoggerTemplate = LoggerTemplateBuilder.build("hrsa", "empdeclare"); + + /** + * 单位扣款账号 + * + * @return + */ + public static LoggerTemplate withholdAccountLoggerTemplate = LoggerTemplateBuilder.build("hrsa", "whaccount"); + + /** + * 银行报盘 + * + * @return + */ + public static LoggerTemplate bankOfferLoggerTemplate = LoggerTemplateBuilder.build("hrsa", "bankoffer"); + + /** + * 银行报盘模板 + * + * @return + */ + public static LoggerTemplate bankOfferTemplateLoggerTemplate = LoggerTemplateBuilder.build("hrsa", "botemplate"); + + /** + * 薪酬体系标准(岗薪制) + * + * @return + */ + public static LoggerTemplate postSalaryLoggerTemplate = LoggerTemplateBuilder.build("hrsa", "postsalary"); + + /** + * 银行报盘模板 + * + * @return + */ + public static LoggerTemplate taxFreeDetailLoggerTemplate = LoggerTemplateBuilder.build("hrsa", "taxfreedetail"); + + /** + * 最优年终奖计税方案 + * + * @return + */ + public static LoggerTemplate annualBonusPlanLoggerTemplate = LoggerTemplateBuilder.build("hrsa", "annualplan"); + + /** + * 最优年终奖计税方案-累计情况 + * 最优年终奖计税方案-优化方案详情 + * + * @return + */ + public static LoggerTemplate annualBonusLoggerTemplate = LoggerTemplateBuilder.build("hrsa", "annualbonus"); + + /** + * 我的工资单 + * + * @return + */ + public static LoggerTemplate mySalaryBillLoggerTemplate = LoggerTemplateBuilder.build("hrsa", "mysalarybill"); + + /** + * 我的调薪记录 + * + * @return + */ + public static LoggerTemplate myAdjustRecordLoggerTemplate = LoggerTemplateBuilder.build("hrsa", "myadjustrecord"); + + /** + * 薪酬报表 + * + * @return + */ + public static LoggerTemplate salaryStatReportLoggerTemplate = LoggerTemplateBuilder.build("hrsa", "statreport"); + + /** + * 业务线 + */ + public static LoggerTemplate authLinkLoggerTemplate = LoggerTemplateBuilder.build("hrsa", "authlink"); +} diff --git a/src/com/engine/salary/config/SalaryPermissionConfig.java b/src/com/engine/salary/config/SalaryPermissionConfig.java new file mode 100644 index 000000000..7703e9267 --- /dev/null +++ b/src/com/engine/salary/config/SalaryPermissionConfig.java @@ -0,0 +1,194 @@ +//package com.engine.salary.config; +// +//import com.weaver.common.component.permission.container.FrontDataContainer; +//import com.weaver.common.mybatis.permission.config.PermissionConfig; +//import com.weaver.common.mybatis.permission.container.PermissionDataContainer; +//import com.weaver.common.mybatis.permission.model.PermissionModuleSourceBean; +//import com.weaver.common.mybatis.permission.model.PermissionModuleTargetBean; +//import com.weaver.common.mybatis.permission.service.PermissionModuleSourceService; +//import com.weaver.common.mybatis.permission.service.PermissionModuleTargetService; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.context.annotation.Configuration; +// +//import javax.annotation.PostConstruct; +// +///** +// * @description: 数据权限配置 +// * @author: xiajun +// * @modified By: xiajun +// * @date: Created in 2023/6/7 10:28 +// * @version:v1.0 +// */ +//@Configuration +//public class SalaryPermissionConfig { +// +// @Autowired +// private PermissionConfig permissionConfig; +// @Autowired +// private PermissionModuleSourceService permissionModuleSourceService; +// @Autowired +// private PermissionModuleTargetService permissionModuleTargetService; +// +// public static final String TABLE_NAME = "hrsa"; +// public static final String PERMISSION_ID = "salary_standard_share"; +// +// /** +// * 初始化模块支持的权限类型 +// */ +// @PostConstruct +// public void init() { +// +// // 初始化权限字典数据 +// permissionConfig.initPermissionData(); +// +// // 给permissionId指定sourceType 类型 ,可以是多个 +// PermissionModuleSourceBean permissionModuleSourceBean = new PermissionModuleSourceBean(); +// permissionModuleSourceBean.setPermissionId(PERMISSION_ID); +// permissionModuleSourceBean.setSourceType(1); // 指定资源 +// permissionModuleSourceService.addBySql(permissionModuleSourceBean); +// +// // 给permissionId指定targetType 类型 ,可以是多个 +// PermissionModuleTargetBean resourceTarget = new PermissionModuleTargetBean(); +// resourceTarget.setPermissionId(PERMISSION_ID); +// resourceTarget.setTargetType(1); // 人力资源 +// permissionModuleTargetService.addBySql(resourceTarget); +// +// PermissionModuleTargetBean departmentTarget = new PermissionModuleTargetBean(); +// departmentTarget.setPermissionId(PERMISSION_ID); +// departmentTarget.setTargetType(2); // 部门+安全级别 +// permissionModuleTargetService.addBySql(departmentTarget); +// +// PermissionModuleTargetBean departmentTarget2 = new PermissionModuleTargetBean(); +// departmentTarget2.setPermissionId(PERMISSION_ID); +// departmentTarget2.setTargetType(2001); // 部门+包含兼职部门 +// permissionModuleTargetService.addBySql(departmentTarget2); +// +// PermissionModuleTargetBean departmentTarget3 = new PermissionModuleTargetBean(); +// departmentTarget3.setPermissionId(PERMISSION_ID); +// departmentTarget3.setTargetType(3); // 部门+所有下级部门+安全级别 +// permissionModuleTargetService.addBySql(departmentTarget3); +// +// PermissionModuleTargetBean departmentTarget4 = new PermissionModuleTargetBean(); +// departmentTarget4.setPermissionId(PERMISSION_ID); +// departmentTarget4.setTargetType(3001); // 部门+所有下级部门+包含兼职部门 +// permissionModuleTargetService.addBySql(departmentTarget4); +// +// PermissionModuleTargetBean departmentTarget5 = new PermissionModuleTargetBean(); +// departmentTarget5.setPermissionId(PERMISSION_ID); +// departmentTarget5.setTargetType(3002); // 部门+所有下级部门+包含兼职部门+安全级别 +// permissionModuleTargetService.addBySql(departmentTarget5); +// +// PermissionModuleTargetBean departmentTarget6 = new PermissionModuleTargetBean(); +// departmentTarget6.setPermissionId(PERMISSION_ID); +// departmentTarget6.setTargetType(2002); // 部门+包含兼职部门+安全级别 +// permissionModuleTargetService.addBySql(departmentTarget6); +// +// PermissionModuleTargetBean branchTarget = new PermissionModuleTargetBean(); +// branchTarget.setPermissionId(PERMISSION_ID); +// branchTarget.setTargetType(5); // 分部+安全级别 +// permissionModuleTargetService.addBySql(branchTarget); +// +// PermissionModuleTargetBean branchTarget501 = new PermissionModuleTargetBean(); +// branchTarget501.setPermissionId(PERMISSION_ID); +// branchTarget501.setTargetType(501); // 分部+安全级别 +// permissionModuleTargetService.addBySql(branchTarget501); +// +// PermissionModuleTargetBean branchTarget502 = new PermissionModuleTargetBean(); +// branchTarget502.setPermissionId(PERMISSION_ID); +// branchTarget502.setTargetType(502); // 分部+安全级别+兼职 +// permissionModuleTargetService.addBySql(branchTarget502); +// +// PermissionModuleTargetBean branchTarget2 = new PermissionModuleTargetBean(); +// branchTarget2.setPermissionId(PERMISSION_ID); +// branchTarget2.setTargetType(6); // 分部+所有下级分部+安全级别 +// permissionModuleTargetService.addBySql(branchTarget2); +// +// PermissionModuleTargetBean roleTarget = new PermissionModuleTargetBean(); +// roleTarget.setPermissionId(PERMISSION_ID); +// roleTarget.setTargetType(10); // 角色+角色级别+安全级别 +// permissionModuleTargetService.addBySql(roleTarget); +// +// PermissionModuleTargetBean allPeopleTarget = new PermissionModuleTargetBean(); +// allPeopleTarget.setPermissionId(PERMISSION_ID); +// allPeopleTarget.setTargetType(11); // 所有人+安全级别 +// permissionModuleTargetService.addBySql(allPeopleTarget); +// +// PermissionModuleTargetBean positionTarget = new PermissionModuleTargetBean(); +// positionTarget.setPermissionId(PERMISSION_ID); +// positionTarget.setTargetType(12); // 岗位+指定部门 +// permissionModuleTargetService.addBySql(positionTarget); +// +// PermissionModuleTargetBean positionTarget12001 = new PermissionModuleTargetBean(); +// positionTarget12001.setPermissionId(PERMISSION_ID); +// positionTarget12001.setTargetType(12001); // 岗位+指定部门+安全级别 +// permissionModuleTargetService.addBySql(positionTarget12001); +// +// PermissionModuleTargetBean positionTarget12111 = new PermissionModuleTargetBean(); +// positionTarget12111.setPermissionId(PERMISSION_ID); +// positionTarget12111.setTargetType(12111); // 岗位+指定部门+包含兼职岗位 +// permissionModuleTargetService.addBySql(positionTarget12111); +// +// PermissionModuleTargetBean positionTarget12112 = new PermissionModuleTargetBean(); +// positionTarget12112.setPermissionId(PERMISSION_ID); +// positionTarget12112.setTargetType(12112); // 岗位+指定部门+包含兼职岗位+安全级别 +// permissionModuleTargetService.addBySql(positionTarget12112); +// +// PermissionModuleTargetBean positionTarget1201 = new PermissionModuleTargetBean(); +// positionTarget1201.setPermissionId(PERMISSION_ID); +// positionTarget1201.setTargetType(1201); // 兼职岗位+安全级别 +// permissionModuleTargetService.addBySql(positionTarget1201); +// +// PermissionModuleTargetBean positionTarget2 = new PermissionModuleTargetBean(); +// positionTarget2.setPermissionId(PERMISSION_ID); +// positionTarget2.setTargetType(13); // 岗位+指定分部 +// permissionModuleTargetService.addBySql(positionTarget2); +// +// PermissionModuleTargetBean positionTarget13001 = new PermissionModuleTargetBean(); +// positionTarget13001.setPermissionId(PERMISSION_ID); +// positionTarget13001.setTargetType(13001); // 岗位+指定分部+安全级别 +// permissionModuleTargetService.addBySql(positionTarget13001); +// +// PermissionModuleTargetBean positionTarget13110 = new PermissionModuleTargetBean(); +// positionTarget13110.setPermissionId(PERMISSION_ID); +// positionTarget13110.setTargetType(13110); // 岗位+指定分部+包含兼职岗位 + 安全级别 +// permissionModuleTargetService.addBySql(positionTarget13110); +// +// PermissionModuleTargetBean positionTarget1311 = new PermissionModuleTargetBean(); +// positionTarget1311.setPermissionId(PERMISSION_ID); +// positionTarget1311.setTargetType(1311); // 岗位+总部 +// permissionModuleTargetService.addBySql(positionTarget1311); +// +// PermissionModuleTargetBean positionTarget1312 = new PermissionModuleTargetBean(); +// positionTarget1312.setPermissionId(PERMISSION_ID); +// positionTarget1312.setTargetType(1312); // 岗位+总部+安全级别 +// permissionModuleTargetService.addBySql(positionTarget1312); +// +// PermissionModuleTargetBean positionTarget13111 = new PermissionModuleTargetBean(); +// positionTarget13111.setPermissionId(PERMISSION_ID); +// positionTarget13111.setTargetType(13111); // 岗位+总部+包含兼职岗位 +// permissionModuleTargetService.addBySql(positionTarget13111); +// +// PermissionModuleTargetBean positionTarget13112 = new PermissionModuleTargetBean(); +// positionTarget13112.setPermissionId(PERMISSION_ID); +// positionTarget13112.setTargetType(13112); // 岗位+总部+包含兼职岗位+安全级别 +// permissionModuleTargetService.addBySql(positionTarget13112); +// +// PermissionModuleTargetBean groupTarget = new PermissionModuleTargetBean(); +// groupTarget.setPermissionId(PERMISSION_ID); +// groupTarget.setTargetType(14); // 群组+安全级别 +// permissionModuleTargetService.addBySql(groupTarget); +// +// PermissionModuleTargetBean groupTarget2 = new PermissionModuleTargetBean(); +// groupTarget2.setPermissionId(PERMISSION_ID); +// groupTarget2.setTargetType(1411); // 群组 +// permissionModuleTargetService.addBySql(groupTarget2); +// +// // 创建权限表 +// // 一般模块要创建固定的权限表,类似流程模块可以调用这个接口,其他环境一般没有建表权限,以脚本的形式提供 +// // databaseService.createPermissionTable(TABLE_NAME,PERMISSION_ID); +// +// // 初始化permissionId和权限表的关系 +// FrontDataContainer.permissionFrontDataMap.put(PERMISSION_ID, TABLE_NAME); +// PermissionDataContainer.permissionDataContainer.put(PERMISSION_ID, TABLE_NAME); +// } +//} diff --git a/src/com/engine/salary/constant/HrmSalaryPayrollConf.java b/src/com/engine/salary/constant/HrmSalaryPayrollConf.java new file mode 100644 index 000000000..e8bc9e341 --- /dev/null +++ b/src/com/engine/salary/constant/HrmSalaryPayrollConf.java @@ -0,0 +1,15 @@ +package com.engine.salary.constant; + +import weaver.general.BaseBean; + +public class HrmSalaryPayrollConf { + + public static final BaseBean baseBean = new BaseBean(); + + public static final boolean GEN_PDF = "1".equals(baseBean.getPropValue("hrmSalaryPayroll", "genPdf")); + public static final boolean HAS_SIGN = "1".equals(baseBean.getPropValue("hrmSalaryPayroll", "hasSign")); + public static final String TO_PDF_TOOL_PATH = baseBean.getPropValue("hrmSalaryPayroll", "toPdfToolPath"); + public static final String GEN_PATH = baseBean.getPropValue("hrmSalaryPayroll", "genPath"); + + +} diff --git a/src/com/engine/salary/constant/SalaryArchiveConstant.java b/src/com/engine/salary/constant/SalaryArchiveConstant.java new file mode 100644 index 000000000..f114d1f05 --- /dev/null +++ b/src/com/engine/salary/constant/SalaryArchiveConstant.java @@ -0,0 +1,36 @@ +package com.engine.salary.constant; + +/** + * @Description: 薪资档案常量 + * @Author: wangxiangzhong + * @Date: 2022/5/27 13:32 + */ +public class SalaryArchiveConstant { + + /** + * 数字正则表达式 + * 包含负数、正数、小数、0、0.00000等 + */ + public static final String NUMBER_REGEX = "(-?[1-9]\\d*\\.?\\d+)|(-?0\\.\\d*[0-9])|(\\d+)"; + + + /** + * 列表中薪资项目动态列后缀标识 + */ + public static final String DYNAMIC_SUFFIX = "_salaryItem"; + + /** + * 调整前 + */ + public static final String ADJUST_BEFORE = "_adjustBefore"; + + /** + * 调整后 + */ + public static final String ADJUST_AFTER = "_adjustAfter"; + + /** + * 调整后 + */ + public static final String ZERO_IGNORE_REGEX = "\\.00"; +} diff --git a/src/com/engine/salary/constant/SalaryAuthConstant.java b/src/com/engine/salary/constant/SalaryAuthConstant.java new file mode 100644 index 000000000..f89a6805d --- /dev/null +++ b/src/com/engine/salary/constant/SalaryAuthConstant.java @@ -0,0 +1,18 @@ +package com.engine.salary.constant; + +/** + * 薪酬管理权限常量 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SalaryAuthConstant { + + + /** + * 薪酬总管理员表示 + */ + public static final String SALARY_CHIEF = "Salary:Chief"; +} diff --git a/src/com/engine/salary/constant/SalaryBillConstant.java b/src/com/engine/salary/constant/SalaryBillConstant.java new file mode 100644 index 000000000..1f121eafb --- /dev/null +++ b/src/com/engine/salary/constant/SalaryBillConstant.java @@ -0,0 +1,30 @@ +package com.engine.salary.constant; + +/** + * @author Harryxzy + * @ClassName SalaryBillConstant + * @date 2023/06/09 17:23 + * @description + */ +public class SalaryBillConstant { + + // 当前操作者姓名 + public static final String HRM_Name = "HRM_Name"; + // 当前操作者编号 + public static final String HRM_Num = "HRM_Num"; + // 当前操作者移动电话 + public static final String HRM_Mobile = "HRM_Mobile"; + // 当前操作者电子邮件 + public static final String HRM_Email = "HRM_Email"; + // 当前操作者人员id + public static final String HRM_CurrentOperatorId = "HRM_CurrentOperatorId"; + // 当前操作者分部 + public static final String HRM_Department = "HRM_Department"; + // + public static final String HRM_SecondDepartment = "HRM_SecondDepartment"; + // 当前日期 + public static final String HRM_CurrentDate = "HRM_CurrentDate"; + // 当前时间 + public static final String HRM_CurrentTime = "HRM_CurrentTime"; + public static final String HRM_prefix = "$"; +} \ No newline at end of file diff --git a/src/com/engine/salary/constant/SalaryDefaultTenantConstant.java b/src/com/engine/salary/constant/SalaryDefaultTenantConstant.java new file mode 100644 index 000000000..2d5ca8a1b --- /dev/null +++ b/src/com/engine/salary/constant/SalaryDefaultTenantConstant.java @@ -0,0 +1,14 @@ +package com.engine.salary.constant; + +/** + * 默认的租户key + *

Copyright: Copyright (c) 2024

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SalaryDefaultTenantConstant { + + public static final String DEFAULT_TENANT_KEY = "all_teams"; +} diff --git a/src/com/engine/salary/constant/SalaryFormulaFieldConstant.java b/src/com/engine/salary/constant/SalaryFormulaFieldConstant.java new file mode 100644 index 000000000..61910bf95 --- /dev/null +++ b/src/com/engine/salary/constant/SalaryFormulaFieldConstant.java @@ -0,0 +1,30 @@ +package com.engine.salary.constant; + +import java.util.regex.Pattern; + +/** + * 薪酬管理公式编辑器的常量 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SalaryFormulaFieldConstant { + + // 公式变量的所属模块 + public static final String MODULE = "hrmsalary"; + + // 公式中变量的fieldId的分隔符 + public static final String FIELD_ID_SEPARATOR = "_"; + + /** + * 公式中变量的fieldId的正则表达式 + */ + public static final String SALARY_REGEX = "(\\w+)" + SalaryFormulaFieldConstant.FIELD_ID_SEPARATOR + "(\\w+)"; + + /** + * 解析公式中变量的fieldId的正则表达式 + */ + public static final Pattern SALARY_PATTERN = Pattern.compile(SALARY_REGEX); +} diff --git a/src/com/engine/salary/constant/SalaryItemConstant.java b/src/com/engine/salary/constant/SalaryItemConstant.java new file mode 100644 index 000000000..58840b5f3 --- /dev/null +++ b/src/com/engine/salary/constant/SalaryItemConstant.java @@ -0,0 +1,44 @@ +package com.engine.salary.constant; + +/** + * 薪资项目常量 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SalaryItemConstant { + + /** + * 列表中薪资项目动态列后缀标识 + */ + public static final String DYNAMIC_SUFFIX = "_salaryItem"; + + /** + * 列表中浮动薪资项目动态列后缀标识 + */ + public static final String VARIABLE_ITEM_DYNAMIC_SUFFIX = "_variableItem"; + + /** + * 薪资核算导入缓存表头字段key + */ + public static final String RESULT_IMPORT_FIELD_SIGN="_salaryAcctResultImportFieldSign"; + + /** + * 社保福利台账导入缓存表头字段key(正常缴纳、补缴) + */ + public static final String SI_ACCOUNT_IMPORT_FIELD_SIGN="_SIAccountImportFieldSign"; + + /** + * 社保福利台账导入缓存表头字段key(补差) + */ + public static final String SI_ACCOUNT_BALANCE_IMPORT_FIELD_SIGN="_SIAccountBalanceImportFieldSign"; + + /** + * 薪资核算导出缓存表头字段key + */ + public static final String RESULT_EXPORT_FIELD_SIGN="_salaryAcctResultExportFieldSign"; + + +} diff --git a/src/com/engine/salary/constant/SalaryItemDataTypeConstant.java b/src/com/engine/salary/constant/SalaryItemDataTypeConstant.java new file mode 100644 index 000000000..c2150c2dc --- /dev/null +++ b/src/com/engine/salary/constant/SalaryItemDataTypeConstant.java @@ -0,0 +1,21 @@ +package com.engine.salary.constant; + +/** + * @description: 薪资项目的值的字段类型 + * @author: xiajun + * @modified By: xiajun + * @date: Created in 2/9/22 1:56 PM + * @version:v1.0 + */ +public class SalaryItemDataTypeConstant { + + /** + * 数字型 + */ + public static final String TYPE_NUMBER = "number"; + + /** + * 字符类型 + */ + public static final String TYPE_STRING = "string"; +} diff --git a/src/com/engine/salary/constant/SalaryTemplateSalaryItemSetGroupConstant.java b/src/com/engine/salary/constant/SalaryTemplateSalaryItemSetGroupConstant.java new file mode 100644 index 000000000..3c4083c61 --- /dev/null +++ b/src/com/engine/salary/constant/SalaryTemplateSalaryItemSetGroupConstant.java @@ -0,0 +1,25 @@ +package com.engine.salary.constant; + +/** + * @Description: 工资单模板项目设置分组id + * @Author: wangxiangzhong + * @Date: 2022/2/21 22:19 + */ +public class SalaryTemplateSalaryItemSetGroupConstant { + + /** + * 员工信息组id + */ + public static final String EMPLOYEE_INFO_GROUP_ID = String.valueOf(111111111111111111L); + + /** + * 无分类组id + */ + public static final String NO_TYPE_GROUP_ID = String.valueOf(222222222222222222L); + + /** + * 已发补发 + */ + public static final String REPLENISH_GROUP_ID = String.valueOf(333333333333333333L); + +} diff --git a/src/com/engine/salary/constant/SalrayCheckSecondAuthConstant.java b/src/com/engine/salary/constant/SalrayCheckSecondAuthConstant.java new file mode 100644 index 000000000..882b317f1 --- /dev/null +++ b/src/com/engine/salary/constant/SalrayCheckSecondAuthConstant.java @@ -0,0 +1,46 @@ +package com.engine.salary.constant; + +/** + * @Description: 二次身份认证常量 + * @Author: wangxiangzhong + * @Date: 2022/3/10 15:58 + */ +public class SalrayCheckSecondAuthConstant { + /** + * token参数名 + */ + public static final String TOKEN = "token"; + + // 错误编码============================================================================================ + /** + * 验证失败或token过期 + */ + public static final String CHECK_SECOND_FAIL = "checkSecondFail"; + + /** + * 二次身份认证服务异常 + */ + public static final String CHECK_SECOND_ERROR = "checkSecondError"; + + /** + * token参数缺失 + */ + public static final String CHECK_SECOND_FAIL_NO_TOKEN = "checkSecondFailNoToken"; + + // 模块编码============================================================================================ + /** + * 模块编码 + */ + public static final String MODULE_CODE = "HRMSALARY"; + + // 项目编码============================================================================================ + /** + * 工资单 + */ + public static final String SALARY_BILL = "SALARYBILL"; + + /** + * 我的薪资福利 + */ + public static final String SOCIAL_WlFARE_LIST = "SOCIALWlFARELIST"; +} diff --git a/src/com/engine/salary/constant/TaxAgentPermissionConstant.java b/src/com/engine/salary/constant/TaxAgentPermissionConstant.java new file mode 100644 index 000000000..85f16ec74 --- /dev/null +++ b/src/com/engine/salary/constant/TaxAgentPermissionConstant.java @@ -0,0 +1,24 @@ +package com.engine.salary.constant; + +/** + * @Description: 个税扣缴义务人分权 + * @Author: wangxiangzhong + * @Date: 2022/5/2 10:09 + */ +public class TaxAgentPermissionConstant { + + /** + * 菜单编码 + */ + public static final String MENU_CODE = "TaxAgent"; + + /** + * 权限编码-默认权限项 + */ + public static final String ITEM_CODE_DEFAULT = "TaxAgent.default"; + + /** + * 权限编码-分权开关 + */ + public static final String ITEM_CODE_DEVOLUTION = "TaxAgent.devolution"; +} diff --git a/src/com/engine/salary/constant/TaxDeclarationDataIndexConstant.java b/src/com/engine/salary/constant/TaxDeclarationDataIndexConstant.java new file mode 100644 index 000000000..38c9d09bc --- /dev/null +++ b/src/com/engine/salary/constant/TaxDeclarationDataIndexConstant.java @@ -0,0 +1,278 @@ +package com.engine.salary.constant; + +public class TaxDeclarationDataIndexConstant { + + /** + * 本期收入 + */ + public static final String INCOME = "income"; + + /** + * 累计收入 + */ + public static final String ADD_UP_INCOME = "addUpIncome"; + + /** + * 本期免税收入 + */ + public static final String TAX_FREE_INCOME = "taxFreeIncome"; + + /** + * 累计免税收入 + */ + public static final String ADD_UP_TAX_FREE_INCOME = "addUpTaxFreeIncome"; + + /** + * 基本养老保险费 + */ + public static final String ENDOWMENT_INSURANCE = "endowmentInsurance"; + + /** + * 基本医疗保险费 + */ + public static final String MEDICAL_INSURANCE = "medicalInsurance"; + + /** + * 失业保险费 + */ + public static final String UNEMPLOYMENT_INSURANCE = "unemploymentInsurance"; + + /** + * 住房公积金 + */ + public static final String HOUSING_PROVIDENT_FUND = "housingProvidentFund"; + + /** + * 社保个人合计 + */ + public static final String SOCIAL_SECURITY_TOTAL = "socialSecurityTotal"; + + /** + * 公积金个人合计 + */ + public static final String ACCUMULATION_FUND_TOTAL = "accumulationFundTotal"; + + /** + * 当前累计社保个人合计 + */ + public static final String ADD_UP_SOCIAL_SECURITY_TOTAL = "addUpSocialSecurityTotal"; + + /** + * 当前累计公积金个人合计 + */ + public static final String ADD_UP_ACCUMULATION_FUND_TOTAL = "addUpAccumulationFundTotal"; + + /** + * 当前累计企业(职业)年金及其他福利个人合计 + */ + public static final String ADD_UP_ENTERPRISE_AND_OTHER = "addUpEnterpriseAndOther"; + + /** + * 本月(次)专项扣除合计 + */ + public static final String SPECIAL_DEDUCTION = "specialDeduction"; + + /** + * 累计专项扣除 + */ + public static final String ADD_UP_SPECIAL_DEDUCTION = "addUpSpecialDeduction"; + + /** + * 累计子女教育 + */ + public static final String ADD_UP_CHILD_EDUCATION = "addUpChildEducation"; + + /** + * 累计住房贷款利息 + */ + public static final String ADD_UP_HOUSING_LOAN_INTEREST = "addUpHousingLoanInterest"; + + /** + * 累计住房租金 + */ + public static final String ADD_UP_HOUSING_RENT = "addUpHousingRent"; + + /** + * 累计继续教育 + */ + public static final String ADD_UP_CONTINUING_EDUCATION = "addUpContinuingEducation"; + + /** + * 累计赡养老人 + */ + public static final String ADD_UP_SUPPORT_ELDERLY = "addUpSupportElderly"; + + /** + * 累计大病医疗 + */ + public static final String ADD_UP_ILLNESS_MEDICAL = "addUpIllnessMedical"; + + /** + * 累计婴幼儿照护 + */ + public static final String ADD_UP_INFANT_CARE = "addUpInfantCare"; + + /** + * 累计个人养老金 + */ + public static final String ADD_UP_PRIVATE_PENSION = "addUpPrivatePension"; + + /** + * 累计专项附加扣除 + */ + public static final String ADD_UP_SPE_ADDI_DEDUCTION = "addUpSpeAddiDeduction"; + + /** + * 减除费用 + */ + public static final String SUBTRACTION = "subtraction"; + + /** + * 累计减除费用 + */ + public static final String ADD_UP_SUBTRACTION = "addUpSubtraction"; + + /** + * 企业(职业)年金 + */ + public static final String ANNUITY = "annuity"; + + /** + * 商业健康保险 + */ + public static final String COMMERCIAL_HEALTH_INSURANCE = "commercialHealthInsurance"; + + /** + * 税延养老保险 + */ + public static final String TAX_DEFERRED_ENDOWMENT_INSURANCE = "taxDeferredEndowmentInsurance"; + + /** + * 其他 + */ + public static final String OTHER = "other"; + + /** + * 本次其他扣除合计 + */ + public static final String OTHER_DEDUCTION = "otherDeduction"; + + /** + * 累计其他扣除 + */ + public static final String ADD_UP_OTHER_DEDUCTION = "addUpOtherDeduction"; + + /** + * 准予扣除的捐赠额 + */ + public static final String ALLOWED_DONATION = "allowedDonation"; + + /** + * 累计准予扣除的捐赠额 + */ + public static final String ADD_UP_ALLOWED_DONATION = "addUpAllowedDonation"; + + /** + * 累计应纳税所得额 + */ + public static final String ADD_UP_TAXABLE_INCOME = "addUpTaxableIncome"; + + /** + * 税率 + */ + public static final String TAX_RATE = "taxRate"; + + /** + * 速算扣除数 + */ + public static final String QUICK_DEDUCTION_FACTOR = "quickDeductionFactor"; + + /** + * 累计应纳税额 + */ + public static final String ADD_UP_TAX_PAYABLE = "addUpTaxPayable"; + + /** + * 累计已纳税额 + */ + public static final String ADD_UP_ADVANCE_TAX = "addUpAdvanceTax"; + + /** + * 减免税额 + */ + public static final String TAX_DEDUCTION = "taxDeduction"; + + /** + * 累计减免税额 + */ + public static final String ADD_UP_TAX_DEDUCTION = "addUpTaxDeduction"; + + /** + * 应补(退)税额 + */ + public static final String REFUNDED_OR_SUPPLEMENTED_TAX = "refundedOrSupplementedTax"; + + /** + * 个税调差 + */ + public static final String TAX_ADJUSTMENT = "taxAdjustment"; + + /** + * 劳务收入 + */ + public static final String LABOR_INCOME = "laborIncome"; + + /** + * 劳务免税收入 + */ + public static final String LABOR_TAX_FREE_INCOME = "laborTaxFreeIncome"; + + /** + * 所得项目 + */ + public static final String INCOME_ITEMS = "incomeItems"; + + /** + * 备注 + */ + public static final String DESCRIPTION = "description"; + + + //----------------------------年终奖----------------------------- + + /** + * 年终奖收入 + */ + public static final String ANNUAL_INCOME = "annualIncome"; + + /** + * 免税收入 + */ + public static final String ANNUAL_TAX_FREE_INCOME = "annualTaxFreeIncome"; + + /** + * 其他 + */ + public static final String ANNUAL_OTHER = "annualOther"; + + /** + * 准予扣除的捐赠额 + */ + public static final String ANNUAL_DONATE_TAX = "annualDonateTax"; + + /** + * 减免税额 + */ + public static final String ANNUAL_TAX_SAVINGS = "annualTaxSavings"; + + /** + * 备注 + */ + public static final String ANNUAL_REMARK = "annualRemark"; + + /** + * 税率 + */ + public static final String ANNUAL_TAX_RATE = "annualTaxRate"; + +} diff --git a/src/com/engine/salary/constant/TaxRateDataIndexConstant.java b/src/com/engine/salary/constant/TaxRateDataIndexConstant.java new file mode 100644 index 000000000..f77d025d6 --- /dev/null +++ b/src/com/engine/salary/constant/TaxRateDataIndexConstant.java @@ -0,0 +1,56 @@ +package com.engine.salary.constant; + +/** + * @description: 个税税率表明细表的dataIndex + * @author: xiajun + * @modified By: xiajun + * @date: Created in 1/17/22 1:58 PM + * @version:v1.0 + */ +public class TaxRateDataIndexConstant { + + /** + * 序号 + */ + public static final String INDEX_NUM = "indexNum"; + + /** + * 收入下限(不含) + */ + public static final String INCOME_LOWER_LIMIT = "incomeLowerLimit"; + + /** + * 收入上限(含) + */ + public static final String INCOME_UPPER_LIMIT = "incomeUpperLimit"; + + /** + * 免税固定值 + */ + public static final String DUTY_FREE_VALUE = "dutyFreeValue"; + + /** + * 免税比例 + */ + public static final String DUTY_FREE_RATE = "dutyFreeRate"; + + /** + * 应纳税所得额下限(不含) + */ + public static final String TAXABLE_INCOME_LOWER_LIMIT = "taxableIncomeLLimit"; + + /** + * 应纳税所得额上限(含) + */ + public static final String TAXABLE_INCOME_UPPER_LIMIT = "taxableIncomeULimit"; + + /** + * 税率 + */ + public static final String TAX_RATE = "taxRate"; + + /** + * 速算扣除数 + */ + public static final String TAX_DEDUCTION = "taxDeduction"; +} diff --git a/src/com/engine/salary/constant/des.json b/src/com/engine/salary/constant/des.json new file mode 100644 index 000000000..f970e4448 --- /dev/null +++ b/src/com/engine/salary/constant/des.json @@ -0,0 +1,1552 @@ +{ + "data": [ + { + "children": [ + { + "name": "CONCAT", + "chineseName": "链接多个文本", + "description": "可用于连接多个任意类型的文本、日期、数字变量或常量。最后一个字符可使用'#分隔符#'标记为分隔符", + "example": "CONCAT({总价}/10000, '万元')", + "result": "100万元", + "paramDescs": [ + "*文本1*(必选)", + "*文本2*(可选)", + "......" + ], + "formatString": "CONCAT(文本1, 文本2, [文本3, …],[#分隔符#])", + "paramArray": [], + "paramData": [], + "returnType": "string", + "type": "function", + "validForm": "current_data", + "paramCount": -1, + "paramStatuses": [ + { + "dataType": "string", + "must": true, + "infinite": true + } + ] + }, + { + "name": "TEXT", + "chineseName": "将变量转为文本", + "description": "将变量转为文本。", + "example": "TEXT({当前数据.性别})", + "result": "'男'", + "paramDescs": [ + "*变量*(必选)" + ], + "formatString": "TEXT(变量)", + "paramArray": [], + "paramData": [], + "returnType": "string", + "type": "function", + "validForm": "current_data", + "paramCount": 1, + "paramStatuses": [ + { + "dataType": "all", + "must": true, + "infinite": false + } + ] + }, + { + "name": "VALUE", + "chineseName": "将文本转为数字", + "description": "将文本转为数字。", + "example": "VALUE('23')", + "result": "23", + "paramDescs": [ + "*文本、数字、选项*(必选)" + ], + "formatString": "VALUE([文本、数字、选项])", + "paramArray": [], + "paramData": [], + "returnType": "number", + "type": "function", + "validForm": "current_data", + "paramCount": 1, + "paramStatuses": [ + { + "dataType": "all", + "must": true, + "infinite": false + } + ] + }, + { + "name": "LEN", + "chineseName": "返回文本长度", + "description": "返回文本的长度,中文、英文都算1个字符。", + "example": "LEN('大家好dajiahao')", + "result": "12", + "paramDescs": [ + "*变量或常量*(必选)" + ], + "formatString": "LEN(文本)", + "paramArray": [], + "paramData": [], + "returnType": "number", + "type": "function", + "validForm": "current_data", + "paramCount": 1, + "paramStatuses": [ + { + "dataType": "string", + "must": true, + "infinite": false + } + ] + }, + { + "name": "SEARCH", + "chineseName": "在文本中查找关键字", + "description": "在指定文本中查找关键字,返回第一次出现关键字的字符位置,文本的第一个字记为1。未找到,返回0。搜索开始位置,表示从文本的第几个字符开始搜索,默认为1。", + "example": "SEARCH('大家', '大家好大家好', 3)", + "result": "4", + "paramDescs": [ + "*文本关键字*(必选)", + "*文本*(必选)", + "*搜索开始位置*(可选)" + ], + "formatString": "SEARCH(关键字, 文本, [搜索开始位置])", + "paramArray": [], + "paramData": [], + "returnType": "number", + "type": "function", + "validForm": "current_data", + "paramCount": 3, + "paramStatuses": [ + { + "dataType": "string", + "must": true, + "infinite": false + }, + { + "dataType": "string", + "must": true, + "infinite": false + }, + { + "dataType": "number", + "must": false, + "infinite": false + } + ] + }, + { + "name": "REPLACE", + "chineseName": "替换文本中的字", + "description": "在原文本中,从替换位置开始,往后数指定的替换字符数,将这段文本替换为新文本。", + "example": "REPLACE('大家好大家好', 2, 3, 'dajia')", + "result": "'大dajia家好'", + "paramDescs": [ + "*文本*(必选)" + ], + "formatString": "REPLACE(原文本, 替换开始位置, 替换字符数, 新文本)", + "paramArray": [], + "paramData": [], + "returnType": "string", + "type": "function", + "validForm": "current_data", + "paramCount": 4, + "paramStatuses": [ + { + "dataType": "string", + "must": true, + "infinite": false + }, + { + "dataType": "number", + "must": true, + "infinite": false + }, + { + "dataType": "number", + "must": true, + "infinite": false + }, + { + "dataType": "string", + "must": true, + "infinite": false + } + ] + }, + { + "name": "REPT", + "chineseName": "将文本重复指定次数", + "description": "将文本重复指定次数。", + "example": "REPT('大家', 2)", + "result": "'大家大家'", + "paramDescs": [ + "*文本*(必选)", + "*重复次数*(必选)" + ], + "formatString": "REPT(文本, 重复次数)", + "paramArray": [], + "paramData": [], + "returnType": "string", + "type": "function", + "validForm": "current_data", + "paramCount": 2, + "paramStatuses": [ + { + "dataType": "string", + "must": true, + "infinite": false + }, + { + "dataType": "number", + "must": true, + "infinite": false + } + ] + }, + { + "name": "PAD", + "chineseName": "将文本填充至指定长度", + "description": "将原文本填充到指定长度,如果文本长度大于设置的长度,则不做任何操作。填充位置可用参数:'LEFT'、'RIGHT'。", + "example": "PAD('你好', 4, '你', 'LEFT')", + "result": "'你你你好'", + "paramDescs": [ + "*原文本*(必选)", + "*长度*(必选)", + "*填充用的文本*(必选)", + "*填充位置*(可选)" + ], + "formatString": "PAD(原文本, 长度, 填充用的文本, [填充位置])", + "paramArray": [], + "paramData": [], + "returnType": "string", + "type": "function", + "validForm": "current_data", + "paramCount": 4, + "paramStatuses": [ + { + "dataType": "string", + "must": true, + "infinite": false + }, + { + "dataType": "number", + "must": true, + "infinite": false + }, + { + "dataType": "string", + "must": true, + "infinite": false + }, + { + "dataType": "string", + "must": true, + "constType": [ + "RIGHT", + "LEFT" + ], + "infinite": false + } + ] + }, + { + "name": "TRIM", + "chineseName": "清除前后空格", + "description": "删除文本首尾的空格。", + "example": "TRIM(' 大家好 ')", + "result": "'大家好'", + "paramDescs": [ + "*文本*(必选)" + ], + "formatString": "TRIM(文本)", + "paramArray": [], + "paramData": [], + "returnType": "string", + "type": "function", + "validForm": "current_data", + "paramCount": 1, + "paramStatuses": [ + { + "dataType": "string", + "must": true, + "infinite": false + } + ] + }, + { + "name": "LEFT", + "chineseName": "返回文本左侧开始的文字", + "description": "从文本左侧开始,返回指定字符数的文字。", + "example": "LEFT('大家好', 2)", + "result": "'大家'", + "paramDescs": [ + "*文本*(必选)", + "*截取字符数*(必选)" + ], + "formatString": "LEFT(文本, 截取字符数)", + "paramArray": [], + "paramData": [], + "returnType": "string", + "type": "function", + "validForm": "current_data", + "paramCount": 2, + "paramStatuses": [ + { + "dataType": "string", + "must": true, + "infinite": false + }, + { + "dataType": "number", + "must": true, + "infinite": false + } + ] + }, + { + "name": "RIGHT", + "chineseName": "返回文本右侧开始的文字", + "description": "从文本右侧开始,返回指定字符数的文字。", + "example": "RIGHT('大家好', 2)", + "result": "'家好'", + "paramDescs": [ + "*文本*(必选)", + "*截取字符数*(必选)" + ], + "formatString": "RIGHT(文本, 截取字符数)", + "paramArray": [], + "paramData": [], + "returnType": "string", + "type": "function", + "validForm": "current_data", + "paramCount": 2, + "paramStatuses": [ + { + "dataType": "string", + "must": true, + "infinite": false + }, + { + "dataType": "number", + "must": true, + "infinite": false + } + ] + }, + { + "name": "MID", + "chineseName": "返回文本指定位置开始的文字", + "description": "从文本指定位置之后开始,返回指定字符数的文字。", + "example": "MID('大家好', 2, 1)", + "result": "'家'", + "paramDescs": [ + "*文本*(必选)", + "*指定位置*(必选)", + "*截取字符数*(必选)" + ], + "formatString": "MID(文本, 指定位置, 截取字符数)", + "paramArray": [], + "paramData": [], + "returnType": "string", + "type": "function", + "validForm": "current_data", + "paramCount": 3, + "paramStatuses": [ + { + "dataType": "string", + "must": true, + "infinite": false + }, + { + "dataType": "number", + "must": true, + "infinite": false + }, + { + "dataType": "number", + "must": true, + "infinite": false + } + ] + }, + { + "name": "SCORE", + "chineseName": "获取选项型控件分数", + "description": "获取选项型控件(单选框、复选框、下拉菜单)分数。", + "example": "SCORE({当前数据.单选框})", + "result": "选项分数(注:未设置选项分数时,结果为0)", + "paramDescs": [ + "*选项*(必选)" + ], + "formatString": "SCORE({选项})", + "paramArray": [], + "paramData": [], + "returnType": "number", + "type": "function", + "validForm": "current_data", + "paramCount": 1, + "paramStatuses": [ + { + "dataType": "option", + "must": true, + "infinite": false + } + ] + }, + { + "name": "IDCARD", + "chineseName": "身份证函数", + "description": "从身份证号码中获取相关信息,比如:生日(BD)、年龄(AGE)、籍贯(NA)、性别(GENDER)。", + "example": "IDCARD( ‘******19980706****’ , ‘BD’ )", + "result": "'1998-07-06'", + "paramDescs": [ + "*身份证号码*(必选)", + "*查找类型*(必选)" + ], + "formatString": "IDCARD({身份证号码}, {查找类型})", + "paramArray": [], + "paramData": [], + "returnType": "string", + "type": "function", + "validForm": "current_data", + "paramCount": 2, + "paramStatuses": [ + { + "dataType": "string", + "must": true, + "infinite": false + }, + { + "dataType": "string", + "must": true, + "constType": [ + "BD", + "NA", + "AGE", + "GENDER" + ], + "infinite": false + } + ] + }, + { + "name": "ISSTRING", + "chineseName": "是否是字符串", + "description": "判断是否是字符。", + "example": "ISSTRING('泛微123456')", + "result": "true", + "paramDescs": [ + "*变量或常量*(必选)" + ], + "formatString": "ISSTRING({任意控件})", + "paramArray": [], + "paramData": [], + "returnType": "boolean", + "type": "function", + "validForm": "current_data", + "paramCount": 1, + "paramStatuses": [ + { + "dataType": "all", + "must": true, + "infinite": false + } + ] + } + ], + "dataType": "char", + "name": "字符函数", + "action": "DataSource", + "type": "functions" + }, + { + "children": [ + { + "name": "TODAY", + "chineseName": "当前日期", + "description": "返回当天日期。", + "example": "TODAY()", + "result": "'2020-01-01'", + "formatString": "TODAY()", + "paramArray": [], + "paramData": [], + "returnType": "date", + "type": "function", + "validForm": "current_data", + "paramCount": 0 + }, + { + "name": "NOW", + "chineseName": "当前日期时间", + "description": "返回当天日期+时间。", + "example": "NOW()", + "result": "'2016-12-24 12:05:38'", + "formatString": "NOW()", + "paramArray": [], + "paramData": [], + "returnType": "date", + "type": "function", + "validForm": "current_data", + "paramCount": 0 + }, + { + "name": "DATEADD", + "chineseName": "对日期加减年、月、日", + "description": "对日期加减按照单位加减。单位默认为日,可选单位:年Y、月M、日D、时H、分I、秒S。", + "example": "DATEADD('2016-12-21', 3)
DATEADD('2016-12-24 20:00:00', 3, 'H')", + "result": "'2016-12-24'
'2016-12-24 23:00:00'", + "paramDescs": [ + "*日期*(必选)", + "*数值*(必选)", + "*单位*(可选)" + ], + "formatString": "DATEADD(日期,数值 , [单位])", + "paramArray": [], + "paramData": [], + "returnType": "date", + "type": "function", + "validForm": "current_data", + "paramCount": 3, + "paramStatuses": [ + { + "dataType": "date", + "must": true, + "infinite": false + }, + { + "dataType": "number", + "must": true, + "infinite": false + }, + { + "dataType": "string", + "must": true, + "constType": [ + "Y", + "M", + "D", + "H", + "I", + "S" + ], + "infinite": false + } + ] + }, + { + "name": "DATEDIFF", + "chineseName": "返回两个日期的差值", + "description": "根据指定的单位,返回日期2减去日期1的差值。当日期2小于日期1时,差值为负值。单位默认为日,可选单位:年Y、月M、日D、时H、分I、秒S。", + "example": "DATEDIF('2016-12-21', '2016-12-24')
DATEDIF('2016-12-24 20:00:00', '2016-12-25 20:00:00', 'H')", + "result": "3
24", + "paramDescs": [ + "*日期1*(必选)", + "*日期2*(必选)", + "*单位*(可选)" + ], + "formatString": "DATEDIFF(日期1, 日期2, [单位])", + "paramArray": [], + "paramData": [], + "returnType": "number", + "type": "function", + "validForm": "current_data", + "paramCount": 3, + "paramStatuses": [ + { + "dataType": "date", + "must": true, + "infinite": false + }, + { + "dataType": "date", + "must": true, + "infinite": false + }, + { + "dataType": "string", + "must": true, + "constType": [ + "Y", + "M", + "D", + "H", + "I", + "S" + ], + "infinite": false + } + ] + }, + { + "name": "DATEFORMAT", + "chineseName": "返回指定格式的日期", + "description": "将日期转为指定格式返回。
yyyy 将年份显示为1900-9999
yy 将年份显示为00-99
mm 将月份显示为 01–12
dd 将日期显示为 01–31", + "example": "DATEFORMAT('2016-12-24', 'YY-MM-DD')", + "result": "2016-12-24", + "paramDescs": [ + "*日期*(必选)", + "*日期格式*(必选)" + ], + "formatString": "DATEFORMAT(日期, 可选格式)", + "paramArray": [], + "paramData": [], + "returnType": "date", + "type": "function", + "validForm": "current_data", + "paramCount": 2, + "paramStatuses": [ + { + "dataType": "date", + "must": true, + "infinite": false + }, + { + "dataType": "string", + "must": true, + "infinite": false + } + ] + }, + { + "name": "YEAR", + "chineseName": "返回日期中的年", + "description": "返回指定日期中的年。", + "example": "YEAR('2016-12-24')", + "result": "2016", + "paramDescs": [ + "*日期*(必选)" + ], + "formatString": "YEAR(日期)", + "paramArray": [], + "paramData": [], + "returnType": "number", + "type": "function", + "validForm": "current_data", + "paramCount": 1, + "paramStatuses": [ + { + "dataType": "date", + "must": true, + "infinite": false + } + ] + }, + { + "name": "MONTH", + "chineseName": "返回日期中的月", + "description": "返回指定日期中的月。", + "example": "MONTH('2016-12-24')", + "result": "12", + "paramDescs": [ + "*日期*(必选)" + ], + "formatString": "MONTH(日期)", + "paramArray": [ + "String" + ], + "paramData": [], + "returnType": "number", + "type": "function", + "validForm": "current_data", + "paramCount": 1, + "paramStatuses": [ + { + "dataType": "date", + "must": true, + "infinite": false + } + ] + }, + { + "name": "DAY", + "chineseName": "返回日期中的日", + "description": "返回指定日期中的日。", + "example": "DAY('2016-12-24')", + "result": "24", + "paramDescs": [ + "*日期*(必选)" + ], + "formatString": "DAY(日期)", + "paramArray": [], + "paramData": [], + "returnType": "number", + "type": "function", + "validForm": "current_data", + "paramCount": 1, + "paramStatuses": [ + { + "dataType": "date", + "must": true, + "infinite": false + } + ] + }, + { + "name": "HOUR", + "chineseName": "返回日期中的小时", + "description": "返回指定日期中的小时。", + "example": "HOUR('2016-12-24 20:30:56')", + "result": "20", + "paramDescs": [ + "*日期*(必选)" + ], + "formatString": "HOUR(日期)", + "paramArray": [], + "paramData": [], + "returnType": "number", + "type": "function", + "validForm": "current_data", + "paramCount": 1, + "paramStatuses": [ + { + "dataType": "date", + "must": true, + "infinite": false + } + ] + }, + { + "name": "MINUTE", + "chineseName": "返回日期中的分钟", + "description": "返回指定日期中的分钟。", + "example": "MINUTE('2016-12-24 20:30:56')", + "result": "30", + "paramDescs": [ + "*日期*(必选)" + ], + "formatString": "MINUTE(日期)", + "paramArray": [], + "paramData": [], + "returnType": "number", + "type": "function", + "validForm": "current_data", + "paramCount": 1, + "paramStatuses": [ + { + "dataType": "date", + "must": true, + "infinite": false + } + ] + }, + { + "name": "SECOND", + "chineseName": "返回日期中的秒", + "description": "返回指定日期中的秒钟。", + "example": "SECOND('2016-12-24 20:30:56')", + "result": "56", + "paramDescs": [ + "*日期*(必选)" + ], + "formatString": "SECOND(日期)", + "paramArray": [], + "paramData": [], + "returnType": "number", + "type": "function", + "validForm": "current_data", + "paramCount": 1, + "paramStatuses": [ + { + "dataType": "date", + "must": true, + "infinite": false + } + ] + }, + { + "name": "WEEKNUM", + "chineseName": "返回日期为第几周", + "description": "返回指定日期为第几周,从每年第1天开始算第1周。", + "example": "WEEKNUM('2016-12-24')", + "result": "52", + "paramDescs": [ + "*日期*(必选)" + ], + "formatString": "WEEKNUM(日期)", + "paramArray": [], + "paramData": [], + "returnType": "number", + "type": "function", + "validForm": "current_data", + "paramCount": 1, + "paramStatuses": [ + { + "dataType": "date", + "must": true, + "infinite": false + } + ] + }, + { + "name": "WEEKDAY", + "chineseName": "返回日期为星期几", + "description": "返回指定日期为星期几。返回值为0~6,代表周日~周六。", + "example": "WEEKDAY('2016-12-24')", + "result": "6", + "paramDescs": [ + "*日期*(必选)" + ], + "formatString": "WEEKDAY(日期)", + "paramArray": [], + "paramData": [], + "returnType": "number", + "type": "function", + "validForm": "current_data", + "paramCount": 1, + "paramStatuses": [ + { + "dataType": "date", + "must": true, + "infinite": false + } + ] + }, + { + "name": "EOMONTH", + "chineseName": "返回某月最后一天日期", + "description": "将某月最后一天日期返回。日期可以为指定日期也可以是日期参数,之前的月数用负数表示,之后的月数用正数表示。所输入月数需为整数。", + "example": "EOMONTH('2021-11-07', -2)", + "result": "2021-09-30", + "paramDescs": [ + "*日期*(必选)", + "*数值*(必选)" + ], + "formatString": "EOMONTH(日期,指定日期之前或之后的月数)", + "paramArray": [], + "paramData": [], + "returnType": "string", + "type": "function", + "validForm": "current_data", + "paramCount": 2, + "paramStatuses": [ + { + "dataType": "date", + "must": true, + "infinite": false + }, + { + "dataType": "number", + "must": true, + "infinite": false + } + ] + }, + { + "name": "CURRYEAR", + "chineseName": "返回当前年份", + "description": "取当前日期的年份。", + "example": "假设当前时间为:2022年2月17日 11:20:30 ,CURRYEAR()", + "result": "2022", + "formatString": "CURRYEAR()", + "paramArray": [], + "paramData": [], + "returnType": "number", + "type": "function", + "validForm": "current_data", + "paramCount": 0 + }, + { + "name": "CURRMONTH", + "chineseName": "返回当前月份", + "description": "取当前日期的月份。", + "example": "假设当前时间为:2022年2月17日 11:20:30 ,CURRMONTH()", + "result": "2", + "formatString": "CURRMONTH()", + "paramArray": [], + "paramData": [], + "returnType": "number", + "type": "function", + "validForm": "current_data", + "paramCount": 0 + }, + { + "name": "CURRDAY", + "chineseName": "返回当前第几日(当月)", + "description": "取当前日期的天。", + "example": "假设当前时间为:2022年2月17日 11:20:30 ,CURRDAY()", + "result": "17", + "formatString": "CURRDAY()", + "paramArray": [], + "paramData": [], + "returnType": "number", + "type": "function", + "validForm": "current_data", + "paramCount": 0 + }, + { + "name": "CURRWEEK", + "chineseName": "返回当前是周几", + "description": "取当前日期是周几。", + "example": "假设当前时间为:2022年2月17日 11:20:30 ,CURRWEEK()", + "result": "4", + "formatString": "CURRWEEK()", + "paramArray": [], + "paramData": [], + "returnType": "number", + "type": "function", + "validForm": "current_data", + "paramCount": 0 + }, + { + "name": "CURRHOUR", + "chineseName": "返回当前小时", + "description": "取当前日期的小时。", + "example": "假设当前时间为:2022年2月17日 11:20:30 ,CURRHOUR()", + "result": "11", + "formatString": "CURRHOUR()", + "paramArray": [], + "paramData": [], + "returnType": "number", + "type": "function", + "validForm": "current_data", + "paramCount": 0 + }, + { + "name": "CURRMINUTE", + "chineseName": "返回当前分", + "description": "取当前日期的分钟。", + "example": "假设当前时间为:2022年2月17日 11:20:30 ,CURRMINUTE()", + "result": "20", + "formatString": "CURRMINUTE()", + "paramArray": [], + "paramData": [], + "returnType": "number", + "type": "function", + "validForm": "current_data", + "paramCount": 0 + }, + { + "name": "CURRSECOND", + "chineseName": "返回当前秒", + "description": "取当前日期的秒钟。", + "example": "假设当前时间为:2022年2月17日 11:20:30 ,CURRSECOND()", + "result": "30", + "formatString": "CURRSECOND()", + "paramArray": [], + "paramData": [], + "returnType": "number", + "type": "function", + "validForm": "current_data", + "paramCount": 0 + }, + { + "name": "MAXDATE", + "chineseName": "返回一组日期中的最大值", + "description": "取一组日期中的最大值。", + "example": "MAXDATE('2016-12-24', '2022-12-24')", + "result": "2022-12-24", + "paramDescs": [ + "*日期1*(必选)", + "*日期2*(必选)" + ], + "formatString": "MAXDATE(日期1,日期2,……)", + "paramArray": [], + "paramData": [], + "returnType": "date", + "type": "function", + "validForm": "current_data", + "paramCount": -1, + "paramStatuses": [ + { + "dataType": "date", + "must": true, + "infinite": true + } + ] + }, + { + "name": "MINDATE", + "chineseName": "返回一组日期中的最小值", + "description": "取一组日期中的最小值。", + "example": "MINDATE('2016-12-24', '2022-12-24')", + "result": "2016-12-24", + "paramDescs": [ + "*日期1*(必选)", + "*日期2*(必选)" + ], + "formatString": "MINDATE(日期1,日期2,……)", + "paramArray": [], + "paramData": [], + "returnType": "date", + "type": "function", + "validForm": "current_data", + "paramCount": -1, + "paramStatuses": [ + { + "dataType": "date", + "must": true, + "infinite": true + } + ] + }, + { + "name": "DAYSINMONTH", + "chineseName": "返回指定月的天数", + "description": "返回指定月的天数。", + "example": "DAYSINMONTH('2024-01-01')", + "result": "31", + "paramDescs": [ + "*日期*(必选)" + ], + "formatString": "DAYSINMONTH(日期)", + "paramArray": [], + "paramData": [], + "returnType": "number", + "type": "function", + "validForm": "days_in_month", + "paramCount": -1, + "paramStatuses": [ + { + "dataType": "date", + "must": true, + "infinite": true + } + ] + }, + ], + "dataType": "date", + "name": "日期函数", + "action": "DataSource", + "type": "functions" + }, + { + "children": [ + { + "name": "IF", + "chineseName": "如果条件为真,则...否则...", + "description": "如果条件为真,则执行表达式1,为假则执行表达式2。条件中不可嵌套使用IF函数。", + "example": "IF({员工表.年龄} > 60, '退休', '在职') ", + "result": "'退休'
'在职'", + "paramDescs": [ + "*条件*(必选)", + "*表达式1*(必选)", + "*表达式2*(必选)" + ], + "formatString": "IF(条件, 表达式1, 表达式2)", + "paramArray": [], + "paramData": [], + "returnType": "all", + "type": "function", + "validForm": "current_data", + "paramCount": 3, + "paramStatuses": [ + { + "dataType": "boolean", + "must": true, + "infinite": false + }, + { + "dataType": "all", + "must": true, + "infinite": false + }, + { + "dataType": "all", + "must": true, + "infinite": false + } + ] + }, + { + "name": "AND", + "chineseName": "且", + "description": "所有条件均为真,则返回真,否则返回假。逻辑操作AND的函数模式。", + "example": "AND(2 = 2, 2 < 2)", + "result": "false", + "paramDescs": [ + "*条件1*(必选)", + "*条件2*(可选,可输入多个参数)" + ], + "formatString": "AND(条件1, 条件2, [条件3, …])", + "paramArray": [], + "paramData": [], + "returnType": "boolean", + "type": "function", + "validForm": "current_data", + "paramCount": -1, + "paramStatuses": [ + { + "dataType": "boolean", + "must": true, + "infinite": true + } + ] + }, + { + "name": "OR", + "chineseName": "或", + "description": "任意一个条件为真,则返回真,否则返回假。逻辑操作OR的函数模式。", + "example": "OR(2 = 2, 2 > 3)", + "result": "true", + "paramDescs": [ + "*条件1*(必选)", + "*条件2*(可选,可输入多个参数)" + ], + "formatString": "OR(条件1, 条件2, [条件3, …])", + "paramArray": [], + "paramData": [], + "returnType": "boolean", + "type": "function", + "validForm": "current_data", + "paramCount": -1, + "paramStatuses": [ + { + "dataType": "boolean", + "must": true, + "infinite": true + } + ] + }, + { + "name": "NOT", + "chineseName": "反转真假结果", + "description": "对逻辑结果取反。", + "example": "NOT(2 > 3)", + "result": "true", + "paramDescs": [ + "*逻辑结果*(必选)" + ], + "formatString": "NOT(逻辑结果)", + "paramArray": [], + "paramData": [], + "returnType": "boolean", + "type": "function", + "validForm": "current_data", + "paramCount": 1, + "paramStatuses": [ + { + "dataType": "boolean", + "must": true, + "infinite": false + } + ] + }, + { + "name": "IN", + "chineseName": "变量是否包含在一组结果中", + "description": "任意类型的变量或常量等于一组同类型变量或常量结果中的任意一个,则返回真。", + "example": "IN(2, [2, 3, 4])", + "result": "true", + "paramDescs": [ + "*变量*(必选)", + "*变量数组*(必选)" + ], + "formatString": "IN(变量, [变量1, 变量2, …])", + "paramArray": [], + "paramData": [ + "{}", + "[]" + ], + "returnType": "boolean", + "type": "function", + "validForm": "current_data", + "paramCount": 2, + "paramStatuses": [ + { + "dataType": "all", + "must": true, + "infinite": false + }, + { + "dataType": "array", + "must": true, + "infinite": false + } + ] + }, + { + "name": "LIKE", + "chineseName": "文本是否包含任意一个关键字", + "description": "文本类型的变量或常量包含一组文本类型变量或常量结果中的任意一个,则返回真。逻辑操作LIKE的函数模式。", + "example": "LIKE('大家好', ['大家', '好'])", + "result": "true", + "paramDescs": [ + "*文本*(必选)", + "*文本数组*(必选)" + ], + "formatString": "LIKE(文本, [文本1, 文本2, …])", + "paramArray": [], + "paramData": [ + "{}", + "[]" + ], + "returnType": "boolean", + "type": "function", + "validForm": "current_data", + "paramCount": 2, + "paramStatuses": [ + { + "dataType": "string", + "must": true, + "infinite": false + }, + { + "dataType": "array", + "must": true, + "infinite": false + } + ] + }, + { + "name": "ISEMPTY", + "chineseName": "是否为空", + "description": "变量为空或未填写,则返回真。", + "example": "ISEMPTY({员工表.电话})", + "result": "true", + "paramDescs": [ + "*变量或常量*(可选)" + ], + "formatString": "ISEMPTY(变量)", + "paramArray": [], + "paramData": [], + "returnType": "boolean", + "type": "function", + "validForm": "current_data", + "paramCount": 1, + "paramStatuses": [ + { + "dataType": "all", + "must": true, + "infinite": false + } + ] + }, + { + "name": "TRUE", + "chineseName": "返回真", + "description": "返回真。", + "example": "TRUE()", + "result": "true", + "formatString": "TRUE()", + "paramArray": [], + "paramData": [], + "returnType": "boolean", + "type": "function", + "validForm": "current_data", + "paramCount": 0 + }, + { + "name": "FALSE", + "chineseName": "返回假", + "description": "返回假。", + "example": "FALSE()", + "result": "false", + "formatString": "FALSE()", + "paramArray": [], + "paramData": [], + "returnType": "boolean", + "type": "function", + "validForm": "current_data", + "paramCount": 0 + }, + { + "name": "IFS", + "chineseName": "多条件", + "description": "多个条件判断,位于单数位置的参数设置为条件,位于双数位置的参数设置为结果,最后一个参数为默认返回值,当所有条件都不满足的时候返回默认参数。", + "example": "IFS(1>1,1,1=1,2,0)", + "result": "2", + "paramDescs": [ + "*条件1*(必选)", + "*变量或常量*(必选)", + "*条件2*(必选)", + "*变量或常量*(必选)", + "*变量或常量*(必选)" + ], + "formatString": "IFS({条件1},{结果1},{条件2},{结果2}...{默认结果})", + "paramArray": [], + "paramData": [], + "returnType": "all", + "type": "function", + "validForm": "current_data", + "paramCount": -1, + "paramStatuses": [ + { + "dataType": "boolean", + "must": true, + "infinite": false + }, + { + "dataType": "all", + "must": true, + "infinite": false + }, + { + "dataType": "all", + "must": true, + "infinite": false + } + ] + }, + { + "name": "SWITCH", + "chineseName": "条件选择", + "description": "条件选择。", + "example": "SWITCH({字段1},1,'A',2,'B','C')", + "result": "假设字段1为2,结果:'B'", + "paramDescs": [ + "*变量或常量*(必选)", + "*变量或常量*(必选)", + "*变量或常量*(必选)", + "*变量或常量*(可选)", + "*变量或常量*(可选)", + "*变量或常量*(必选)" + ], + "formatString": "SWITCH({变量},{条件1},{结果1},{条件2},{结果2}...{默认结果})", + "paramArray": [], + "paramData": [], + "returnType": "all", + "type": "function", + "validForm": "current_data", + "paramCount": -1, + "paramStatuses": [ + { + "dataType": "all", + "must": true, + "infinite": false + }, + { + "dataType": "all", + "must": true, + "infinite": false + }, + { + "dataType": "all", + "must": true, + "infinite": false + } + ] + } + ], + "dataType": "logic", + "name": "逻辑函数", + "action": "DataSource", + "type": "functions" + }, + { + "children": [ + { + "name": "ROUNDUP", + "chineseName": "向上舍入", + "description": "根据设置的小数位精确度,返回对数值向上舍入后的值。小数位精确度取值可为正整数,0,负整数。如果小数位精确度为正整数,则向上舍入到指定的小数位。如果小数位精确度等于 0,则向上舍入到最接近的整数。如果小数位精确度为负整数,则在小数点左侧向上进行舍入。小数位精确度不支持变量。小数位精确度默认为0,即只保留整数。", + "example": "ROUNDUP(76.9,0)", + "result": "77", + "paramDescs": [ + "*数字*(必选)", + "*小数位精确度*(可选)" + ], + "formatString": "ROUNDUP(数字, [小数位精确度])", + "paramArray": [], + "paramData": [], + "returnType": "number", + "type": "function", + "validForm": "current_data", + "paramCount": 2, + "paramStatuses": [ + { + "dataType": "number", + "must": true, + "infinite": false + }, + { + "dataType": "number", + "must": true, + "infinite": false + } + ] + }, + { + "name": "ROUND", + "chineseName": "四舍五入", + "description": "根据设置的小数位精确度,返回对数值四舍五入后的值。小数位精确度取值可为正整数,0,负整数。如果小数位精确度为正整数,针对小数点后的数据进行四舍五入;如果小数位精确度等于 0,返回最接近数值的整数;如果小数位精确度为负整数,针对小数点前的数据进行四舍五入,被舍掉的数据用0占位。小数位精确度不支持变量。小数位精确度默认为0,即只保留整数。", + "example": "ROUND(123.456,2),ROUND(123.456,0),ROUND(123.456,-2)", + "result": "依次为123.46,123,100", + "paramDescs": [ + "*数字*(必选)", + "*小数位精确度*(可选)" + ], + "formatString": "ROUND(数字, [小数位精确度])", + "paramArray": [], + "paramData": [], + "returnType": "number", + "type": "function", + "validForm": "current_data", + "paramCount": 2, + "paramStatuses": [ + { + "dataType": "number", + "must": true, + "infinite": false + }, + { + "dataType": "number", + "must": true, + "infinite": false + } + ] + }, + { + "name": "ROUNDDOWN", + "chineseName": "向下舍入", + "description": "根据设置的小数位精确度,返回对数值向下舍入后的值。小数位精确度取值可为正整数,0,负整数。如果小数位精确度为正整数,则向下舍入到指定的小数位。如果小数位精确度等于 0,则向下舍入到最接近的整数。如果小数位精确度为负整数,则在小数点左侧向下进行舍入。小数位精确度不支持变量。小数位精确度默认为0,即只保留整数。", + "example": "ROUNDDOWN(76.9,0)", + "result": "76", + "paramDescs": [ + "*数字*(必选)", + "*小数位精确度*(可选)" + ], + "formatString": "ROUNDDOWN(数字, [小数位精确度])", + "paramArray": [], + "paramData": [], + "returnType": "number", + "type": "function", + "validForm": "current_data", + "paramCount": 2, + "paramStatuses": [ + { + "dataType": "number", + "must": true, + "infinite": false + }, + { + "dataType": "number", + "must": true, + "infinite": false + } + ] + }, + { + "name": "AGGREGATION", + "chineseName": "聚合运算", + "description": "将一组数据进行统计计算,支持最大值(MAX)、最小值(MIN)、平均值(AVG)。", + "example": "AGGREGATION(1 , 2,3,'AVG')", + "result": "2", + "paramDescs": [ + "*数字*(必选)", + "*聚合运算类型*(必选)" + ], + "formatString": "AGGREGATION({数字}...,{聚合运算类型})", + "paramArray": [], + "paramData": [], + "returnType": "number", + "type": "function", + "validForm": "current_data", + "paramCount": -1, + "paramStatuses": [ + { + "dataType": "number", + "must": true, + "infinite": true + }, + { + "dataType": "string", + "must": true, + "constType": [ + "avg", + "max", + "min" + ], + "infinite": false + } + ] + }, + { + "name": "MOD", + "chineseName": "求余", + "description": "将两个参数进行除法运算然后得出余数返回。", + "example": "MOD( 7 , 3 )", + "result": "1", + "paramDescs": [ + "*数字*(必选)", + "*数字*(必选)" + ], + "formatString": "ROUNDDOWN({数字},{数字})", + "paramArray": [], + "paramData": [], + "returnType": "number", + "type": "function", + "validForm": "current_data", + "paramCount": 2, + "paramStatuses": [ + { + "dataType": "number", + "must": true, + "infinite": false + }, + { + "dataType": "number", + "must": true, + "infinite": false + } + ] + }, + { + "name": "TRUNC", + "chineseName": "数字格式化", + "description": "将小数点格式化成指定位数。", + "example": "TRUNC( 2.123 , 2 )", + "result": "2.12", + "paramDescs": [ + "*数字*(必选)", + "*精度*(必选)" + ], + "formatString": "ROUNDDOWN({数字},{精度})", + "paramArray": [], + "paramData": [], + "returnType": "number", + "type": "function", + "validForm": "current_data", + "paramCount": 2, + "paramStatuses": [ + { + "dataType": "number", + "must": true, + "infinite": false + }, + { + "dataType": "number", + "must": true, + "infinite": false + } + ] + } + ], + "dataType": "math", + "name": "数学函数", + "action": "DataSource", + "type": "functions" + }, + { + "children": [ + { + "name": "GETMONEY", + "chineseName": "获取所给定数字的金额大写", + "description": "将金额转换成中文金额大写。", + "example": "GETMONEY({1234})", + "result": "壹仟贰佰叁拾肆元整", + "paramDescs": [ + "*数字*(必选)" + ], + "formatString": "GETMONEY({数字})", + "paramData": [], + "returnType": "", + "type": "function", + "validForm": "current_data", + "paramCount": 1, + "paramStatuses": [ + { + "dataType": "number", + "must": true, + "infinite": false + } + ] + } + ], + "dataType": "finance", + "name": "财务函数", + "action": "DataSource", + "type": "functions" + } + ] +} \ No newline at end of file diff --git a/src/com/engine/salary/encrypt/AESEncryptUtil.java b/src/com/engine/salary/encrypt/AESEncryptUtil.java new file mode 100644 index 000000000..99d68d106 --- /dev/null +++ b/src/com/engine/salary/encrypt/AESEncryptUtil.java @@ -0,0 +1,149 @@ +package com.engine.salary.encrypt; + +import com.engine.salary.sys.constant.SalarySysConstant; +import com.engine.salary.sys.entity.po.SalarySysConfPO; +import com.engine.salary.sys.enums.OpenEnum; +import org.apache.commons.lang3.StringUtils; +import weaver.general.AES; +import weaver.general.BaseBean; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * 此AES加密工具类仅用于关联应用设置中是否开启加密的应用使用 + * 如另有需要,请重写工具类 + */ +public class AESEncryptUtil { + + static BaseBean bb = new BaseBean(); + + static String aesEncryptScrect = bb.getPropValue("hrmSalary", "AESEncryptScrect"); + + static String aes4SalaryBillEncryptScrect = "OETEP8JBA1C8IH721C1513AE82IFPE5"; + + /** + * AES加密 + * + * @param source 原始数据 + * @return 加密数据 + */ + public static String encrypt(String source) { + //防止初始化老数据时二次加密 + if (StringUtils.isNotBlank(source) && !source.startsWith(SalarySysConstant.PRE_SIGN_ENCRYPT)) { + return SalarySysConstant.PRE_SIGN_ENCRYPT + AES.encrypt(source, aesEncryptScrect); + } + return source; + } + + /** + * 工资单推送-员工id加密 + * @param source + * @return + */ + public static String encrypt4SalaryBill(String source) { + //防止初始化老数据时二次加密 + if (StringUtils.isNotBlank(source) && !source.startsWith(SalarySysConstant.SALARY_BILL_PRE_SIGN_ENCRYPT)) { + return SalarySysConstant.SALARY_BILL_PRE_SIGN_ENCRYPT + AES.encrypt(source, aes4SalaryBillEncryptScrect); + } + return source; + } + + public static String decrypt4SalaryBill(String encryptStr) { + if (StringUtils.isNotBlank(encryptStr)) { + if (encryptStr.startsWith(SalarySysConstant.SALARY_BILL_PRE_SIGN_ENCRYPT)) { + encryptStr = encryptStr.substring(4, encryptStr.length()); + return AES.decrypt(encryptStr, aes4SalaryBillEncryptScrect); + } else { + return ""; + } + } + return encryptStr; + } + + + /** + * AES解密 + * + * @param encryptStr 加密字符串 + * @return 解密字符串 + */ + public static String decrypt(String encryptStr) { + if (StringUtils.isNotBlank(encryptStr)) { + if (encryptStr.startsWith(SalarySysConstant.PRE_SIGN_ENCRYPT)) { + encryptStr = encryptStr.substring(4, encryptStr.length()); + return AES.decrypt(encryptStr, aesEncryptScrect); + } else if (isNumeric(encryptStr) || + checkHaveChinese(encryptStr) || + encryptStr.startsWith("{") || + encryptStr.contains("-") || + encryptStr.contains(".") || + "null".equals(encryptStr) || + StringUtils.isBlank(encryptStr)) { + return encryptStr; + } else { + return AES.decrypt(encryptStr, aesEncryptScrect); + } + } + return encryptStr; + } + + /** + * 用于关闭加密设置后AES解密 + * + * @param encryptStr 加密字符串 + * @return 解密字符串 + */ + public static String closeEncryptSetting(String encryptStr, SalarySysConfPO sysConfPo) { + if (encryptStr == null) { + return null; + } else { + //AES_前缀的密文 + if (encryptStr.startsWith(SalarySysConstant.PRE_SIGN_ENCRYPT)) { + encryptStr = encryptStr.substring(4, encryptStr.length()); + return AES.decrypt(encryptStr, aesEncryptScrect); + } else if (isNumeric(encryptStr) || + checkHaveChinese(encryptStr) || + encryptStr.startsWith("{") || + encryptStr.contains("-") || + encryptStr.contains(".") || + "null".equals(encryptStr) || + StringUtils.isBlank(encryptStr)) { + return encryptStr; + } else if (sysConfPo == null || sysConfPo.getConfValue().equals(OpenEnum.OFF.getValue())) { + return AES.decrypt(encryptStr, aesEncryptScrect); + } else { + return encryptStr; + } + } + } + + /** + * 判断字符串是否为整数或者小数或者负数 + */ + public static boolean isNumeric(String str) { + + Pattern pattern = Pattern.compile("^-?\\d+(\\.\\d+)?$"); + Matcher isNum = pattern.matcher(str); + if (!isNum.matches()) { + return false; + } + return true; + + } + + /** + * 判断字符串是否包含中文字符 + */ + public static boolean checkHaveChinese(String countname) { + + Pattern p = Pattern.compile("[\u4e00-\u9fa5]"); + Matcher m = p.matcher(countname); + if (m.find()) { + return true; + } + + return false; + + } +} diff --git a/src/com/engine/salary/encrypt/EncryptSetting.java b/src/com/engine/salary/encrypt/EncryptSetting.java new file mode 100644 index 000000000..4954537fd --- /dev/null +++ b/src/com/engine/salary/encrypt/EncryptSetting.java @@ -0,0 +1,16 @@ +package com.engine.salary.encrypt; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class EncryptSetting { + + public boolean open; + +} \ No newline at end of file diff --git a/src/com/engine/salary/encrypt/EncryptUtil.java b/src/com/engine/salary/encrypt/EncryptUtil.java new file mode 100644 index 000000000..1509904d5 --- /dev/null +++ b/src/com/engine/salary/encrypt/EncryptUtil.java @@ -0,0 +1,167 @@ +package com.engine.salary.encrypt; + + +import com.engine.common.util.ServiceUtil; +import com.engine.salary.annotation.Encrypt; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.sys.service.SalarySysConfService; +import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.jetbrains.annotations.NotNull; +import weaver.hrm.User; + +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +@Slf4j +public class EncryptUtil { + private static final String NULL = "null"; + + private static String ifNull(String value){ + if (NULL.equals(value)) { + return null; + } + return value; + } + + private SalarySysConfService getSalarySysConfService(User user) { + return ServiceUtil.getService(SalarySysConfServiceImpl.class, user); + } + + public T encrypt(T data, Class clazz) { + if (data == null || clazz == null) { + return data; + } + boolean encryptIsOpen = getSalarySysConfService(null).encryptIsOpen(); + if (!encryptIsOpen) { + return data; + } + try { + List fieldList = getFields(clazz); + if (CollectionUtils.isNotEmpty(fieldList)) { + for (Field field : fieldList) { + field.setAccessible(true); + String fieldValue = (String)field.get(data); + if (StringUtils.isNotBlank(fieldValue)) { + String encryptValue = AESEncryptUtil.encrypt(fieldValue); + field.set(data, encryptValue); + } + } + } + return data; + } catch (Exception e) { + log.error("加密异常", e); + throw new SalaryRunTimeException("加密异常"); + } + } + + @NotNull + private static List getFields(Class clazz) { + List> allClasses = new ArrayList>(); + for (Class superClass = clazz; + superClass != null; + superClass = superClass.getSuperclass()) { + if (superClass != Object.class) { + allClasses.add(superClass); + } + } + List fieldList = + allClasses.stream() + .map(Class::getDeclaredFields) + .flatMap(Arrays::stream) + .filter(field -> field.isAnnotationPresent(Encrypt.class)).collect(Collectors.toList()); + return fieldList; + } + + public List encryptList(List dataList, Class clazz) { + if (CollectionUtils.isEmpty(dataList) || clazz == null) { + return dataList; + } + boolean encryptIsOpen = getSalarySysConfService(null).encryptIsOpen(); + if (!encryptIsOpen) { + return dataList; + } + try { + List fieldList = getFields(clazz); + if (CollectionUtils.isNotEmpty(fieldList)) { + for (T data : dataList) { + for (Field field : fieldList) { + field.setAccessible(true); + String fieldValue = (String) field.get(data); + if (StringUtils.isNotBlank(fieldValue)) { + String encryptValue = AESEncryptUtil.encrypt(fieldValue); + field.set(data, encryptValue); + } + } + } + + } + return dataList; + } catch (Exception e) { + log.error("批量加密异常", e); + throw new SalaryRunTimeException("批量加密异常"); + } + } + + public T decrypt(T data, Class clazz) { + if (data == null || clazz == null) { + return data; + } + boolean encryptIsOpen = getSalarySysConfService(null).encryptIsOpen(); + if (!encryptIsOpen) { + return data; + } + try { + List fieldList = getFields(clazz); + if (CollectionUtils.isNotEmpty(fieldList)) { + for (Field field : fieldList) { + field.setAccessible(true); + String fieldValue = (String) field.get(data); + if (StringUtils.isNotBlank(fieldValue)) { + String encryptValue = ifNull(AESEncryptUtil.decrypt(fieldValue)); + field.set(data, encryptValue); + } + } + } + return data; + } catch (Exception e) { + log.error("解密异常", e); + throw new SalaryRunTimeException("解密异常"); + } + } + + public List decryptList(List dataList, Class clazz) { + if (CollectionUtils.isEmpty(dataList) || clazz == null) { + return dataList; + } + boolean encryptIsOpen = getSalarySysConfService(null).encryptIsOpen(); + if (!encryptIsOpen) { + return dataList; + } + try { + List fieldList = getFields(clazz); + if (CollectionUtils.isNotEmpty(fieldList)) { + for (T data : dataList) { + for (Field field : fieldList) { + field.setAccessible(true); + String fieldValue = (String) field.get(data); + if (StringUtils.isNotBlank(fieldValue)) { + String encryptValue = ifNull(AESEncryptUtil.decrypt(fieldValue)); + field.set(data, encryptValue); + } + } + } + } + return dataList; + } catch (Exception e) { + log.error("批量解密异常", e); + throw new SalaryRunTimeException("批量解密异常"); + } + } + +} diff --git a/src/com/engine/salary/encrypt/TestEncrypt.java b/src/com/engine/salary/encrypt/TestEncrypt.java new file mode 100644 index 000000000..c1682862d --- /dev/null +++ b/src/com/engine/salary/encrypt/TestEncrypt.java @@ -0,0 +1,18 @@ +package com.engine.salary.encrypt; + +import weaver.general.AES; + +public class TestEncrypt { + public static void main(String[] args) { + String encrypt = AES.encrypt("1111999999999999999999", "990EB004A1C862721C1513AE90038C9E"); + System.out.println(encrypt); + String decrypt = AES.decrypt(encrypt, "990EB004A1C862721C1513AE90038C9E"); + System.out.println(decrypt); + +// String decrypt1 = AES.decrypt("50D79C50D9D2105E234369598623A1E7", "990EB004A1C862721C1513AE90038C9E"); + String decrypt1 = AES.decrypt("AB6AEA309B5F5224B27EC048B9D7BD82", "990EB004A1C862721C1513AE90038C9E"); + System.out.println(decrypt1); + +// AB6AEA309B5F5224B27EC048B9D7BD82 + } +} diff --git a/src/com/engine/salary/entity/agency/bo/PaymentAgencyBO.java b/src/com/engine/salary/entity/agency/bo/PaymentAgencyBO.java new file mode 100644 index 000000000..25956b123 --- /dev/null +++ b/src/com/engine/salary/entity/agency/bo/PaymentAgencyBO.java @@ -0,0 +1,57 @@ +package com.engine.salary.entity.agency.bo; + +import com.engine.salary.entity.agency.dto.PaymentAgencyFormDTO; +import com.engine.salary.entity.agency.dto.PaymentAgencyListDTO; +import com.engine.salary.entity.agency.po.PaymentAgencyPO; +import com.engine.salary.enums.sicategory.DeleteTypeEnum; +import com.engine.salary.util.db.IdGenerator; +import org.apache.commons.collections4.CollectionUtils; + +import java.time.LocalDateTime; +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; + + +public class PaymentAgencyBO { + +// public static Wrapper buildPaymentAgencyListWrapper(Long employeeId, String tenantKey) { +// LambdaQueryWrapper lambdaQueryWrapper = Wrappers.lambdaQuery(); +// lambdaQueryWrapper.eq(PaymentAgencyPO::getTenantKey, tenantKey); +// lambdaQueryWrapper.eq(PaymentAgencyPO::getDeleteType, DeleteTypeEnum.NOT_DELETED.getValue()); +// lambdaQueryWrapper.orderByDesc(PaymentAgencyPO::getUpdateTime); +// return lambdaQueryWrapper; +// } + + public static List buildPaymentAgencyDTOList(List paymentAgencyPOS, Long employeeId, String tenantKey) { + if (CollectionUtils.isEmpty(paymentAgencyPOS)) { + return Collections.emptyList(); + } + return paymentAgencyPOS.stream().map(e -> PaymentAgencyListDTO.builder() + .id(e.getId()) + .agencyName(e.getAgencyName()) + .remarks(e.getRemarks()).build() + ).collect(Collectors.toList()); + } + + public static PaymentAgencyFormDTO buildPaymentAgencyFormDTO(PaymentAgencyPO paymentAgencyPO, Long employeeId, String tenantKey) { + PaymentAgencyFormDTO paymentAgencyFormDTO = PaymentAgencyFormDTO.builder().build(); + paymentAgencyFormDTO.setId(paymentAgencyPO.getId()); + paymentAgencyFormDTO.setAgencyName(paymentAgencyPO.getAgencyName()); + paymentAgencyFormDTO.setRemarks(paymentAgencyFormDTO.getRemarks()); + return paymentAgencyFormDTO; + } + + public static PaymentAgencyPO buildPaymentAgencyPO(PaymentAgencyFormDTO paymentAgencyFormDTO, Long employeeId, String tenantKey) { + return PaymentAgencyPO.builder() + .id(IdGenerator.generate()) + .agencyName(paymentAgencyFormDTO.getAgencyName()) + .createTime(LocalDateTime.now()) + .creator(employeeId) + .tenantKey(tenantKey) + .deleteType(DeleteTypeEnum.NOT_DELETED.getValue()) + .updateTime(LocalDateTime.now()) + .remarks(paymentAgencyFormDTO.getRemarks()) + .build(); + } +} diff --git a/src/com/engine/salary/entity/agency/dto/PaymentAgencyFormDTO.java b/src/com/engine/salary/entity/agency/dto/PaymentAgencyFormDTO.java new file mode 100644 index 000000000..d6fcbc80d --- /dev/null +++ b/src/com/engine/salary/entity/agency/dto/PaymentAgencyFormDTO.java @@ -0,0 +1,58 @@ +package com.engine.salary.entity.agency.dto; + +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 代缴机构表单 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class PaymentAgencyFormDTO { + + //主键id") + @JsonSerialize(using = ToStringSerializer.class) + private Long id; + +// @SalaryForm( +// label = "名称", +// labelId = 84756, +// items = { +// @SalaryFormItem( +// itemType = WeaFormItemType.INPUT, +// required = true, +// maxLength = "50" +// ) +// } +// ) +// @NotBlank(message = "name is required") +// @Size(max = 50, message = "the maximum lenth is 50") +// //名称") + private String agencyName; + +// @SalaryForm( +// label = "备注", +// labelId = 84961, +// items = { +// @SalaryFormItem( +// itemType = WeaFormItemType.TEXTAREA, +// maxLength = "50" +// ) +// } +// ) +// @NotBlank(message = "name is required") +// @Size(max = 60, message = "the maximum lenth is 60") +// //名称") + private String remarks; +} diff --git a/src/com/engine/salary/entity/agency/dto/PaymentAgencyListDTO.java b/src/com/engine/salary/entity/agency/dto/PaymentAgencyListDTO.java new file mode 100644 index 000000000..6624cb584 --- /dev/null +++ b/src/com/engine/salary/entity/agency/dto/PaymentAgencyListDTO.java @@ -0,0 +1,55 @@ +package com.engine.salary.entity.agency.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 代缴机构列表 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +////"") +//@TableOperates(value = { +// @Operates(index = 0, text = "编辑", labelId = 87058), +// @Operates(index = 1, text = "删除", labelId = 87061) +//}) +public class PaymentAgencyListDTO { + + /** + * 主键id + */ +// 主键id") +// @JsonSerialize(using = ToStringSerializer.class) + private Long id; + + /** + * 社保福利代缴机构 + */ +// @WeaFormat( +// label = "社保福利代缴机构", +// labelId = 112448, +// tableColumn = @TableColumn(width = "200") +// ) +// 社保福利代缴机构") + private String agencyName; + + /** + * 备注 + */ +// @WeaFormat( +// label = "备注", +// labelId = 84961, +// tableColumn = @TableColumn(width = "300") +// ) +// 备注") + private String remarks; +} diff --git a/src/com/engine/salary/entity/agency/po/PaymentAgencyPO.java b/src/com/engine/salary/entity/agency/po/PaymentAgencyPO.java new file mode 100644 index 000000000..93045f86e --- /dev/null +++ b/src/com/engine/salary/entity/agency/po/PaymentAgencyPO.java @@ -0,0 +1,56 @@ +package com.engine.salary.entity.agency.po; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.time.LocalDateTime; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//hrsa_payment_agency +public class PaymentAgencyPO { + + /** + * 主键id + */ + private Long id; + + /** + * 机构名称 + */ + private String agencyName; + + /** + * 备注 + */ + private String remarks; + + /** + * 创建时间 + */ + private LocalDateTime createTime; + + /** + * 更新时间 + */ + private LocalDateTime updateTime; + + /** + * 创建人 + */ + private Long creator; + + /** + * 是否已删除。0:未删除、1:已删除 + */ + private Integer deleteType; + + /** + * 租户ID + */ + private String tenantKey; +} diff --git a/src/com/engine/salary/entity/auth/dto/AuthDataDTO.java b/src/com/engine/salary/entity/auth/dto/AuthDataDTO.java new file mode 100644 index 000000000..cd3d3600b --- /dev/null +++ b/src/com/engine/salary/entity/auth/dto/AuthDataDTO.java @@ -0,0 +1,38 @@ +package com.engine.salary.entity.auth.dto; + +import com.engine.salary.annotation.TableTitle; +import com.engine.salary.enums.auth.DataLinkEnum; +import com.engine.salary.enums.auth.DataTargetTypeEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class AuthDataDTO { + + private Long id; + + /** + * 连接符,交、并、补 + */ + @TableTitle(title = "连接",dataIndex = "linkName",key = "linkName") + private String linkName; + + private DataLinkEnum link; + + @TableTitle(title = "对象类型",dataIndex = "targetTypeName",key = "targetTypeName") + private String targetTypeName; + private DataTargetTypeEnum targetType; + + @TableTitle(title = "对象",dataIndex = "targetName",key = "targetName") + private String targetName; + private String target; + + @TableTitle(title = "批次",dataIndex = "sortedIndex",key = "sortedIndex") + private Integer sortedIndex; + +} diff --git a/src/com/engine/salary/entity/auth/dto/AuthLimitDTO.java b/src/com/engine/salary/entity/auth/dto/AuthLimitDTO.java new file mode 100644 index 000000000..1861a0251 --- /dev/null +++ b/src/com/engine/salary/entity/auth/dto/AuthLimitDTO.java @@ -0,0 +1,18 @@ +package com.engine.salary.entity.auth.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class AuthLimitDTO { + private Long taxAgentId; + + private List roleLimits; +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/auth/dto/AuthMemberDTO.java b/src/com/engine/salary/entity/auth/dto/AuthMemberDTO.java new file mode 100644 index 000000000..fe0b24e98 --- /dev/null +++ b/src/com/engine/salary/entity/auth/dto/AuthMemberDTO.java @@ -0,0 +1,26 @@ +package com.engine.salary.entity.auth.dto; + +import com.engine.salary.annotation.TableTitle; +import com.engine.salary.enums.auth.MemberTargetTypeEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class AuthMemberDTO { + + private Long id; + + @TableTitle(title = "对象类型",dataIndex = "targetTypeName",key = "targetTypeName") + private String targetTypeName; + private MemberTargetTypeEnum targetType; + + @TableTitle(title = "对象",dataIndex = "targetName",key = "targetName") + private String targetName; + private String target; + +} diff --git a/src/com/engine/salary/entity/auth/dto/AuthOptDTO.java b/src/com/engine/salary/entity/auth/dto/AuthOptDTO.java new file mode 100644 index 000000000..2a71e4129 --- /dev/null +++ b/src/com/engine/salary/entity/auth/dto/AuthOptDTO.java @@ -0,0 +1,77 @@ +package com.engine.salary.entity.auth.dto; + +import com.thoughtworks.xstream.annotations.XStreamAlias; +import com.thoughtworks.xstream.annotations.XStreamAsAttribute; +import com.thoughtworks.xstream.annotations.XStreamImplicit; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@XStreamAlias("config") +public class AuthOptDTO { + @XStreamAlias("name") + @XStreamAsAttribute + private String name; + + @XStreamAlias("key") + @XStreamAsAttribute + private String key; + + @XStreamImplicit(itemFieldName = "module") + private List modules; + + @Data + public static class Module { + @XStreamAlias("name") + @XStreamAsAttribute + private String name; + + @XStreamAlias("key") + @XStreamAsAttribute + private String key; + + @XStreamImplicit(itemFieldName = "page") + private List pages; + + @Data + public static class Page { + @XStreamAlias("name") + @XStreamAsAttribute + private String name; + + @XStreamAlias("key") + @XStreamAsAttribute + private String key; + + @XStreamAlias("limit") + @XStreamAsAttribute + private String limit; + + @XStreamImplicit(itemFieldName = "opt") + private List opts; + + @Data + public static class Opt { + @XStreamAlias("name") + @XStreamAsAttribute + private String name; + + @XStreamAlias("key") + @XStreamAsAttribute + private String key; + + @XStreamAlias("able") + @XStreamAsAttribute + private boolean able; + } + } + } +} + diff --git a/src/com/engine/salary/entity/auth/dto/AuthRoleDTO.java b/src/com/engine/salary/entity/auth/dto/AuthRoleDTO.java new file mode 100644 index 000000000..2dac34f8f --- /dev/null +++ b/src/com/engine/salary/entity/auth/dto/AuthRoleDTO.java @@ -0,0 +1,53 @@ +package com.engine.salary.entity.auth.dto; + +import com.engine.salary.annotation.TableTitle; +import com.engine.salary.entity.salarysob.po.SalarySobPO; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * 角色 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class AuthRoleDTO { + + private Long id; + + @TableTitle(title = "业务线", dataIndex = "name", key = "name") + private String name; + + @TableTitle(title = "描述", dataIndex = "description", key = "description") + private String description; + + /** + * 扣缴义务人资源 + */ + private List taxAgentIds; + + /** + * 账套资源 + */ + private List sobIds; + + @TableTitle(title = "资源", dataIndex = "resources", key = "resources") + private Integer resources; + + @TableTitle(title = "成员", dataIndex = "members", key = "members") + private Integer members; + + @TableTitle(title = "权限", dataIndex = "opts", key = "opts") + private Integer opts; + + @TableTitle(title = "数据", dataIndex = "datas", key = "datas") + private Integer datas; + + +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/auth/dto/AuthRoleDataDTO.java b/src/com/engine/salary/entity/auth/dto/AuthRoleDataDTO.java new file mode 100644 index 000000000..58ca3cc21 --- /dev/null +++ b/src/com/engine/salary/entity/auth/dto/AuthRoleDataDTO.java @@ -0,0 +1,32 @@ +package com.engine.salary.entity.auth.dto; + +import com.engine.salary.annotation.I18n; +import com.engine.salary.annotation.TableTitle; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class AuthRoleDataDTO { + + private Long id; + + @TableTitle(title = "姓名",dataIndex = "username",key = "username") + private String username; + + @TableTitle(title = "工号",dataIndex = "workCode",key = "workCode") + private String workCode; + + + @I18n + @TableTitle(title = "部门",dataIndex = "departmentName",key = "departmentName") + private String departmentName; + + @I18n + @TableTitle(title = "岗位",dataIndex = "jobtitleName",key = "jobtitleName") + private String jobtitleName; +} diff --git a/src/com/engine/salary/entity/auth/dto/AuthRoleEmpDTO.java b/src/com/engine/salary/entity/auth/dto/AuthRoleEmpDTO.java new file mode 100644 index 000000000..981bf9b0d --- /dev/null +++ b/src/com/engine/salary/entity/auth/dto/AuthRoleEmpDTO.java @@ -0,0 +1,32 @@ +package com.engine.salary.entity.auth.dto; + +import com.engine.salary.annotation.I18n; +import com.engine.salary.annotation.TableTitle; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class AuthRoleEmpDTO { + + private Long id; + + @TableTitle(title = "姓名",dataIndex = "username",key = "username") + private String username; + + @TableTitle(title = "工号",dataIndex = "workcode",key = "workcode") + private String workCode; + + + @I18n + @TableTitle(title = "部门",dataIndex = "departmentName",key = "departmentName") + private String departmentName; + + @I18n + @TableTitle(title = "岗位",dataIndex = "jobtitleName",key = "jobtitleName") + private String jobtitleName; +} diff --git a/src/com/engine/salary/entity/auth/dto/AuthTreeDTO.java b/src/com/engine/salary/entity/auth/dto/AuthTreeDTO.java new file mode 100644 index 000000000..9583bce12 --- /dev/null +++ b/src/com/engine/salary/entity/auth/dto/AuthTreeDTO.java @@ -0,0 +1,62 @@ +package com.engine.salary.entity.auth.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class AuthTreeDTO { + private Long roleEmpId; + + private List roles; + + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + public static class Role { + private Long roleId; + + private String roleName; + + private List resources; + private List opts; + private List datas; + + @lombok.Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + public static class Resource { + private Long resourceId; + private String resourceName; + private String resourceType; + } + + @lombok.Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + public static class Opt { + private Long optId; + private String page; + private String opt; + } + + @lombok.Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + public static class Data { + private Long dataId; + private Long employeeId; + } + } +} + diff --git a/src/com/engine/salary/entity/auth/dto/EmpOpt.java b/src/com/engine/salary/entity/auth/dto/EmpOpt.java new file mode 100644 index 000000000..d85e24fe4 --- /dev/null +++ b/src/com/engine/salary/entity/auth/dto/EmpOpt.java @@ -0,0 +1,19 @@ +package com.engine.salary.entity.auth.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Set; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class EmpOpt { + private Long employeeId; + + private Set opts; +} + diff --git a/src/com/engine/salary/entity/auth/dto/Opt.java b/src/com/engine/salary/entity/auth/dto/Opt.java new file mode 100644 index 000000000..f9171e390 --- /dev/null +++ b/src/com/engine/salary/entity/auth/dto/Opt.java @@ -0,0 +1,15 @@ +package com.engine.salary.entity.auth.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class Opt { + private String opt; +} + diff --git a/src/com/engine/salary/entity/auth/dto/PermissionDTO.java b/src/com/engine/salary/entity/auth/dto/PermissionDTO.java new file mode 100644 index 000000000..eb13937eb --- /dev/null +++ b/src/com/engine/salary/entity/auth/dto/PermissionDTO.java @@ -0,0 +1,5 @@ +package com.engine.salary.entity.auth.dto; + +public class PermissionDTO { + +} diff --git a/src/com/engine/salary/entity/auth/dto/RoleLimit.java b/src/com/engine/salary/entity/auth/dto/RoleLimit.java new file mode 100644 index 000000000..bad2017a1 --- /dev/null +++ b/src/com/engine/salary/entity/auth/dto/RoleLimit.java @@ -0,0 +1,19 @@ +package com.engine.salary.entity.auth.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class RoleLimit { + private Long roleId; + + private List sobIds; +} + diff --git a/src/com/engine/salary/entity/auth/dto/SobOptAuth.java b/src/com/engine/salary/entity/auth/dto/SobOptAuth.java new file mode 100644 index 000000000..cbae0bfd7 --- /dev/null +++ b/src/com/engine/salary/entity/auth/dto/SobOptAuth.java @@ -0,0 +1,19 @@ +package com.engine.salary.entity.auth.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Set; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SobOptAuth { + private Long sobId; + + private Set opts; +} + diff --git a/src/com/engine/salary/entity/auth/dto/TaxEmpOptAuth.java b/src/com/engine/salary/entity/auth/dto/TaxEmpOptAuth.java new file mode 100644 index 000000000..fffb519db --- /dev/null +++ b/src/com/engine/salary/entity/auth/dto/TaxEmpOptAuth.java @@ -0,0 +1,19 @@ +package com.engine.salary.entity.auth.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class TaxEmpOptAuth { + private Long taxAgentId; + + private List emps; +} + diff --git a/src/com/engine/salary/entity/auth/dto/TaxOptAuth.java b/src/com/engine/salary/entity/auth/dto/TaxOptAuth.java new file mode 100644 index 000000000..57b4765c7 --- /dev/null +++ b/src/com/engine/salary/entity/auth/dto/TaxOptAuth.java @@ -0,0 +1,19 @@ +package com.engine.salary.entity.auth.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Set; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class TaxOptAuth { + private Long taxAgentId; + + private Set opts; +} + diff --git a/src/com/engine/salary/entity/auth/param/AuthDataQueryParam.java b/src/com/engine/salary/entity/auth/param/AuthDataQueryParam.java new file mode 100644 index 000000000..28f53f712 --- /dev/null +++ b/src/com/engine/salary/entity/auth/param/AuthDataQueryParam.java @@ -0,0 +1,20 @@ +package com.engine.salary.entity.auth.param; + +import com.engine.salary.common.BaseQueryParam; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class AuthDataQueryParam extends BaseQueryParam { + + private Long roleId; + + private String username; + +} diff --git a/src/com/engine/salary/entity/auth/param/AuthDataSaveParam.java b/src/com/engine/salary/entity/auth/param/AuthDataSaveParam.java new file mode 100644 index 000000000..86784082f --- /dev/null +++ b/src/com/engine/salary/entity/auth/param/AuthDataSaveParam.java @@ -0,0 +1,41 @@ +package com.engine.salary.entity.auth.param; + + +import com.engine.salary.enums.auth.DataLinkEnum; +import com.engine.salary.enums.auth.DataTargetTypeEnum; +import com.engine.salary.util.valid.Modify; +import com.engine.salary.util.valid.ModifyTypeEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 数据 + *

Copyright: Copyright (c) 2024

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class AuthDataSaveParam { + private Long id; + + private Long roleId; + + private DataLinkEnum link; + + private DataTargetTypeEnum targetType; + + @Modify(modifyType = ModifyTypeEnum.RESTORE_SQL) + private String target; + + @Modify(modifyType = ModifyTypeEnum.RESTORE_SQL) + private String targetName; + + private Integer sortedIndex; +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/auth/param/AuthMemberQueryParam.java b/src/com/engine/salary/entity/auth/param/AuthMemberQueryParam.java new file mode 100644 index 000000000..e540a1590 --- /dev/null +++ b/src/com/engine/salary/entity/auth/param/AuthMemberQueryParam.java @@ -0,0 +1,20 @@ +package com.engine.salary.entity.auth.param; + +import com.engine.salary.common.BaseQueryParam; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class AuthMemberQueryParam extends BaseQueryParam { + + private Long roleId; + + private String username; + +} diff --git a/src/com/engine/salary/entity/auth/param/AuthMemberSaveParam.java b/src/com/engine/salary/entity/auth/param/AuthMemberSaveParam.java new file mode 100644 index 000000000..9486d1e96 --- /dev/null +++ b/src/com/engine/salary/entity/auth/param/AuthMemberSaveParam.java @@ -0,0 +1,29 @@ +package com.engine.salary.entity.auth.param; + + +import com.engine.salary.enums.auth.MemberTargetTypeEnum; +import com.engine.salary.util.valid.Modify; +import com.engine.salary.util.valid.ModifyTypeEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class AuthMemberSaveParam { + + private Long id; + + private Long roleId; + + private MemberTargetTypeEnum targetType; + + @Modify(modifyType = ModifyTypeEnum.RESTORE_SQL) + private String target; + + @Modify(modifyType = ModifyTypeEnum.RESTORE_SQL) + private String targetName; +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/auth/param/AuthOptSaveParam.java b/src/com/engine/salary/entity/auth/param/AuthOptSaveParam.java new file mode 100644 index 000000000..c720fedcc --- /dev/null +++ b/src/com/engine/salary/entity/auth/param/AuthOptSaveParam.java @@ -0,0 +1,26 @@ +package com.engine.salary.entity.auth.param; + + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class AuthOptSaveParam { + private Long roleId; + private List opts; + + @Data + public static class Opt { + + private String page; + + private String opt; + } +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/auth/param/AuthRoleListQueryParam.java b/src/com/engine/salary/entity/auth/param/AuthRoleListQueryParam.java new file mode 100644 index 000000000..ab71eb23a --- /dev/null +++ b/src/com/engine/salary/entity/auth/param/AuthRoleListQueryParam.java @@ -0,0 +1,59 @@ +package com.engine.salary.entity.auth.param; + +import com.engine.salary.common.BaseQueryParam; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class AuthRoleListQueryParam extends BaseQueryParam { + + /** + * 业务线名称 + */ + private String name; + + /** + * 业务线id + */ + private List roleIds; + + /** + * 扣缴义务人资源 + */ + private List taxAgentIds; + + /** + * 账套资源 + */ + private List sobIds; + + /** + * 成员id + */ + private List roleEmpIds; + + + /** + * 权限页面 + */ + private List pages; + + /** + * 权限项 + */ + private List opts; + + + /** + * 数据id + */ + private List employeeIds; + +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/auth/param/AuthRoleSaveParam.java b/src/com/engine/salary/entity/auth/param/AuthRoleSaveParam.java new file mode 100644 index 000000000..f1075d4ab --- /dev/null +++ b/src/com/engine/salary/entity/auth/param/AuthRoleSaveParam.java @@ -0,0 +1,44 @@ +package com.engine.salary.entity.auth.param; + +import com.engine.salary.util.valid.DataCheck; +import com.engine.salary.util.valid.RuntimeTypeEnum; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import com.engine.salary.entity.salarysob.po.SalarySobPO; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class AuthRoleSaveParam { + + @JsonSerialize(using = ToStringSerializer.class) + @DataCheck(require = true, runtime = {RuntimeTypeEnum.UPDATE}, message = "id不允许为空") + private Long id; + + + @DataCheck(require = true, max = 40, message = "名称不允许为空,名称不能超过40个字符") + private String name; + + @DataCheck(require = false, max = 400, message = "描述不能超过400个字符") + private String description; + + /** + * 扣缴义务人资源 + */ + private List taxAgentIds; + + + /** + * 账套资源 + */ + private List sobIds; + +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/auth/param/AuthSyncParam.java b/src/com/engine/salary/entity/auth/param/AuthSyncParam.java new file mode 100644 index 000000000..1ac9be40c --- /dev/null +++ b/src/com/engine/salary/entity/auth/param/AuthSyncParam.java @@ -0,0 +1,17 @@ +package com.engine.salary.entity.auth.param; + + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class AuthSyncParam { + + private Long roleId; + +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/auth/param/AuthTreeQueryParam.java b/src/com/engine/salary/entity/auth/param/AuthTreeQueryParam.java new file mode 100644 index 000000000..101faec0e --- /dev/null +++ b/src/com/engine/salary/entity/auth/param/AuthTreeQueryParam.java @@ -0,0 +1,28 @@ +package com.engine.salary.entity.auth.param; + + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class AuthTreeQueryParam { + + private Long roleEmpId; + + private List roleIds; + + private List employeeIds; + + private List pages; + + private List opts; + + +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/auth/po/AuthDataPO.java b/src/com/engine/salary/entity/auth/po/AuthDataPO.java new file mode 100644 index 000000000..b29b6992a --- /dev/null +++ b/src/com/engine/salary/entity/auth/po/AuthDataPO.java @@ -0,0 +1,92 @@ +package com.engine.salary.entity.auth.po; + +import com.engine.hrmelog.annotation.ElogTransform; +import com.engine.salary.enums.auth.DataLinkEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.Date; + +/** + * 数据 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class AuthDataPO { + @ElogTransform(name = "id") + private Long id; + + /** + * 角色id + */ + @ElogTransform(name = "角色id") + private Long roleId; + + /** + * 连接符,交、并、补 + * @see DataLinkEnum + */ + @ElogTransform(name = "连接符,交、并、补") + private Integer link; + + /** + * 数据类型,1:人员、2:部门、3:岗位、4:分部、5:角色、6:安全级别 、7:所有人 、8:登录人、9:账套、10:sql + */ + @ElogTransform(name = "数据类型") + private Integer targetType; + + /** + * 对象id + */ + @ElogTransform(name = "对象id") + private String target; + + /** + * 对象名称 + */ + @ElogTransform(name = "对象名称") + private String targetName; + + @ElogTransform(name = "排序") + private Integer sortedIndex; + + /** + * 创建人 + */ + @ElogTransform(name = "创建人") + private Long creator; + + /** + * 创建时间 + */ + @ElogTransform(name = "创建时间") + private Date createTime; + + /** + * 更新时间 + */ + @ElogTransform(name = "更新时间") + private Date updateTime; + + /** + * 是否已删除。0:未删除、1:已删除 + */ + @ElogTransform(name = "是否已删除。0:未删除、1:已删除") + private Integer deleteType; + + /** + * 租户ID + */ + @ElogTransform(name = "租户ID") + private String tenantKey; + + + //主键id集合 + private Collection ids; + +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/auth/po/AuthMemberPO.java b/src/com/engine/salary/entity/auth/po/AuthMemberPO.java new file mode 100644 index 000000000..218c1b3ae --- /dev/null +++ b/src/com/engine/salary/entity/auth/po/AuthMemberPO.java @@ -0,0 +1,71 @@ +package com.engine.salary.entity.auth.po; + +import com.engine.hrmelog.annotation.ElogTransform; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.Date; + +/** + * 成员 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@ElogTransform( name="成员" ) +public class AuthMemberPO { + private Long id; + /** + * 角色id + */ + @ElogTransform( name="角色id" ) + private Long roleId; + /** + * 对象类型,1:人员、2:部门、3:岗位、4:分部、5:角色、6:sql + */ + @ElogTransform( name="对象类型" ) + private Integer targetType; + /** + * 对象 + */ + @ElogTransform( name="对象" ) + private String target; + /** + * 对象 + */ + @ElogTransform( name="对象显示名" ) + private String targetName; + /** + * 创建人 + */ + @ElogTransform( name="创建人" ) + private Long creator; + /** + * 创建时间 + */ + @ElogTransform( name="创建时间" ) + private Date createTime; + /** + * 更新时间 + */ + @ElogTransform( name="更新时间" ) + private Date updateTime; + /** + * 是否已删除。0:未删除、1:已删除 + */ + @ElogTransform( name="是否已删除。0:未删除、1:已删除" ) + private Integer deleteType; + /** + * 租户ID + */ + @ElogTransform( name="租户ID" ) + private String tenantKey; + + //主键id集合 + private Collection ids; + +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/auth/po/AuthOptPO.java b/src/com/engine/salary/entity/auth/po/AuthOptPO.java new file mode 100644 index 000000000..10da3aed9 --- /dev/null +++ b/src/com/engine/salary/entity/auth/po/AuthOptPO.java @@ -0,0 +1,75 @@ +package com.engine.salary.entity.auth.po; + +import com.engine.hrmelog.annotation.ElogTransform; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.Date; + +/** + * 权限项 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class AuthOptPO { + @ElogTransform(name = "id") + private Long id; + + /** + * 角色id + */ + @ElogTransform(name = "角色id") + private Long roleId; + + /** + * 页面 + */ + @ElogTransform(name = "页面") + private String page; + + /** + * 权限项 + */ + @ElogTransform(name = "权限项") + private String opt; + + /** + * 创建人 + */ + @ElogTransform(name = "创建人") + private Long creator; + + /** + * 创建时间 + */ + @ElogTransform(name = "创建时间") + private Date createTime; + + /** + * 更新时间 + */ + @ElogTransform(name = "更新时间") + private Date updateTime; + + /** + * 是否已删除。0:未删除、1:已删除 + */ + @ElogTransform(name = "是否已删除。0:未删除、1:已删除") + private Integer deleteType; + + /** + * 租户ID + */ + @ElogTransform(name = "租户ID") + private String tenantKey; + + + //主键id集合 + private Collection ids; + +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/auth/po/AuthResourcePO.java b/src/com/engine/salary/entity/auth/po/AuthResourcePO.java new file mode 100644 index 000000000..a7fecdd46 --- /dev/null +++ b/src/com/engine/salary/entity/auth/po/AuthResourcePO.java @@ -0,0 +1,83 @@ +package com.engine.salary.entity.auth.po; + +import com.engine.hrmelog.annotation.ElogTransform; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.Date; + +/** + * 角色 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class AuthResourcePO { + + + @ElogTransform(name = "") + private Long id; + + /** + * 角色id + */ + @ElogTransform(name = "角色id") + private Long roleId; + + /** + * 对象类型,1:扣缴义务人 2:账套 + */ + @ElogTransform( name="对象类型" ) + private Integer targetType; + + /** + * 对象 + */ + @ElogTransform( name="对象" ) + private Long target; + + /** + * 对象 + */ + @ElogTransform( name="对象显示名" ) + private String targetName; + + /** + * 创建时间 + */ + @ElogTransform(name = "创建时间") + private Date createTime; + + + /** + * 更新时间 + */ + @ElogTransform(name = "更新时间") + private Date updateTime; + + /** + * 创建人 + */ + @ElogTransform(name = "创建人") + private Long creator; + + /** + * 是否已删除。0:未删除、1:已删除 + */ + @ElogTransform(name = "是否已删除。0:未删除、1:已删除") + private Integer deleteType; + + /** + * 租户ID + */ + @ElogTransform(name = "租户ID") + private String tenantKey; + + //主键id集合 + private Collection ids; + +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/auth/po/AuthRoleDataPO.java b/src/com/engine/salary/entity/auth/po/AuthRoleDataPO.java new file mode 100644 index 000000000..a28e5dbe1 --- /dev/null +++ b/src/com/engine/salary/entity/auth/po/AuthRoleDataPO.java @@ -0,0 +1,69 @@ +package com.engine.salary.entity.auth.po; + +import com.engine.hrmelog.annotation.ElogTransform; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.Date; + +/** + * 角色数据明细 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class AuthRoleDataPO { + @ElogTransform(name = "id") + private Long id; + + /** + * 角色id + */ + @ElogTransform(name = "角色id") + private Long roleId; + + /** + * 人员id + */ + @ElogTransform(name = "人员id") + private Long employeeId; + + /** + * 创建人 + */ + @ElogTransform(name = "创建人") + private Long creator; + + /** + * 创建时间 + */ + @ElogTransform(name = "创建时间") + private Date createTime; + + /** + * 更新时间 + */ + @ElogTransform(name = "更新时间") + private Date updateTime; + + /** + * 是否已删除。0:未删除、1:已删除 + */ + @ElogTransform(name = "是否已删除。0:未删除、1:已删除") + private Integer deleteType; + + /** + * 租户ID + */ + @ElogTransform(name = "租户ID") + private String tenantKey; + + + //主键id集合 + private Collection ids; + +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/auth/po/AuthRoleEmpPO.java b/src/com/engine/salary/entity/auth/po/AuthRoleEmpPO.java new file mode 100644 index 000000000..f3963f3f7 --- /dev/null +++ b/src/com/engine/salary/entity/auth/po/AuthRoleEmpPO.java @@ -0,0 +1,61 @@ +package com.engine.salary.entity.auth.po; + +import com.engine.hrmelog.annotation.ElogTransform; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.Date; + +/** + * 角色 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class AuthRoleEmpPO { + @ElogTransform(name = "") + private Long id; + /** + * 角色id + */ + @ElogTransform(name = "角色id") + private Long roleId; + /** + * 人员id + */ + @ElogTransform(name = "人员id") + private Long employeeId; + /** + * 创建人 + */ + @ElogTransform(name = "创建人") + private Long creator; + /** + * 创建时间 + */ + @ElogTransform(name = "创建时间") + private Date createTime; + /** + * 更新时间 + */ + @ElogTransform(name = "更新时间") + private Date updateTime; + /** + * 是否已删除。0:未删除、1:已删除 + */ + @ElogTransform(name = "是否已删除。0:未删除、1:已删除") + private Integer deleteType; + /** + * 租户ID + */ + @ElogTransform(name = "租户ID") + private String tenantKey; + + //主键id集合 + private Collection ids; + +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/auth/po/AuthRolePO.java b/src/com/engine/salary/entity/auth/po/AuthRolePO.java new file mode 100644 index 000000000..0475c9b08 --- /dev/null +++ b/src/com/engine/salary/entity/auth/po/AuthRolePO.java @@ -0,0 +1,69 @@ +package com.engine.salary.entity.auth.po; + +import com.engine.hrmelog.annotation.ElogTransform; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.Date; + +/** + * 角色 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@ElogTransform(name = "业务线") +public class AuthRolePO { + + private Long id; + + /** + * 名称 + */ + @ElogTransform(name = "名称") + private String name; + + /** + * 描述 + */ + @ElogTransform(name = "描述") + private String description; + + /** + * 创建人 + */ + @ElogTransform(name = "创建人") + private Long creator; + + /** + * 创建时间 + */ + @ElogTransform(name = "创建时间") + private Date createTime; + + /** + * 更新时间 + */ + @ElogTransform(name = "更新时间") + private Date updateTime; + + /** + * 是否已删除。0:未删除、1:已删除 + */ + @ElogTransform(name = "是否已删除。0:未删除、1:已删除") + private Integer deleteType; + + /** + * 租户ID + */ + @ElogTransform(name = "租户ID") + private String tenantKey; + + //主键id集合 + private Collection ids; + +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/auth/vo/Permission.java b/src/com/engine/salary/entity/auth/vo/Permission.java new file mode 100644 index 000000000..6faaa3a62 --- /dev/null +++ b/src/com/engine/salary/entity/auth/vo/Permission.java @@ -0,0 +1,40 @@ +package com.engine.salary.entity.auth.vo; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class Permission { + /** + * 是否开启了分权 + */ + private Boolean isOpenDevolution; + + /** + * 是否总管理员 + */ + private Boolean isChief; + + /** + * 是否扣缴义务人管理员 + */ + private Boolean isAdminEnable; + + /** + * 当前页面是否有权限 + */ + private boolean able; + + /** + * 权限项 + */ + private List opts; + +} diff --git a/src/com/engine/salary/entity/config/SalaryConfig.java b/src/com/engine/salary/entity/config/SalaryConfig.java new file mode 100644 index 000000000..175f6426f --- /dev/null +++ b/src/com/engine/salary/entity/config/SalaryConfig.java @@ -0,0 +1,49 @@ +package com.engine.salary.entity.config; + +import com.engine.salary.entity.salaryarchive.config.ArchiveFieldConfig; +import com.engine.salary.entity.salaryitem.config.SalaryItemAllConfig; +import com.engine.salary.entity.taxagent.config.TaxAgentConfig; +import com.engine.salary.entity.taxagent.po.TaxAgentBasePO; +import com.engine.salary.sys.config.SysConfig; +import com.thoughtworks.xstream.annotations.XStreamAlias; +import com.thoughtworks.xstream.annotations.XStreamImplicit; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@XStreamAlias("SalaryConfig") +public class SalaryConfig { + // //版本 +// @XStreamAlias("version") +// @XStreamAsAttribute +// private String version; +// + @XStreamAlias("SysConfig") + private SysConfig sysConfig; + + //社保方案 + + //薪资项目 + @XStreamAlias("SalaryItemConfig") + private SalaryItemAllConfig salaryItemConfig; + + //字段管理 + @XStreamAlias("ArchiveFieldConfig") + private ArchiveFieldConfig archiveFieldConfig; + + //分权基础设置 + @XStreamAlias("TaxAgentBaseConfig") + private TaxAgentBasePO taxAgentBaseConfig; + + //扣缴义务人 + @XStreamImplicit + private List taxAgentConfigs; + +} diff --git a/src/com/engine/salary/entity/datacollection/AddUpDeduction.java b/src/com/engine/salary/entity/datacollection/AddUpDeduction.java new file mode 100644 index 000000000..9a2213a0e --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/AddUpDeduction.java @@ -0,0 +1,139 @@ +package com.engine.salary.entity.datacollection; + +import com.engine.salary.annotation.Encrypt; +import com.engine.salary.annotation.SalaryFormulaVar; +import com.engine.hrmelog.annotation.ElogTransform; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.Date; +import java.util.List; + +/** + * 数据采集-累计专项附加扣除表 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//hrsa_add_up_deduction +@ElogTransform(name = "累计专项附加扣除") +public class AddUpDeduction { + /** + * 主键id + */ + @ElogTransform(name = "主键") + private Long id; + + /** + * 人员信息表的主键id + */ + @ElogTransform(name = "人员id") + private Long employeeId; + + /** + * 个税扣缴义务人的主键id + */ + @ElogTransform(name = "个税扣缴义务人id") + private Long taxAgentId; + + /** + * 申报月份 + */ + @ElogTransform(name = "申报月份") + private Date declareMonth; + + /** + * 累计子女教育 + */ + @ElogTransform(name = "累计子女教育") + @SalaryFormulaVar(defaultLabel = "累计子女教育", labelId = 86321, dataType = "number") + @Encrypt + private String addUpChildEducation; + + /** + * 累计继续教育 + */ + @ElogTransform(name = "累计继续教育") + @SalaryFormulaVar(defaultLabel = "累计继续教育", labelId = 86323, dataType = "number") + @Encrypt + private String addUpContinuingEducation; + + /** + * 累计住房贷款利息 + */ + @ElogTransform(name = "累计住房贷款利息") + @SalaryFormulaVar(defaultLabel = "累计住房贷款利息", labelId = 86324, dataType = "number") + @Encrypt + private String addUpHousingLoanInterest; + + /** + * 累计住房租金 + */ + @ElogTransform(name = "累计住房租金") + @SalaryFormulaVar(defaultLabel = "累计住房租金", labelId = 86325, dataType = "number") + @Encrypt + private String addUpHousingRent; + + /** + * 累计赡养老人 + */ + @ElogTransform(name = "累计赡养老人") + @SalaryFormulaVar(defaultLabel = "累计赡养老人", labelId = 86326, dataType = "number") + @Encrypt + private String addUpSupportElderly; + + /** + * 累计大病医疗 + */ + @ElogTransform(name = "累计大病医疗") + @SalaryFormulaVar(defaultLabel = "累计大病医疗", labelId = 105142, dataType = "number") + @Encrypt + private String addUpIllnessMedical; + + /** + * 累计婴幼儿照护 + */ + @ElogTransform(name = "累计婴幼儿照护") + @SalaryFormulaVar(defaultLabel = "累计婴幼儿照护", labelId = 117732, dataType = "number") + @Encrypt + private String addUpInfantCare; + + /** + * 创建时间 + */ + @ElogTransform(name = "创建时间") + private Date createTime; + + /** + * 更新时间 + */ + @ElogTransform(name = "更新时间") + private Date updateTime; + + /** + * 创建人 + */ + @ElogTransform(name = "创建人") + private Long creator; + + /** + * 是否已删除。0:未删除、1:已删除 + */ + @ElogTransform(name = "是否已删除") + private Integer deleteType; + + /** + * 租户ID + */ + @ElogTransform(name = "租户ID") + private String tenantKey; + + List employeeIds; + + Collection taxAgentIds; + +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/datacollection/AddUpSituation.java b/src/com/engine/salary/entity/datacollection/AddUpSituation.java new file mode 100644 index 000000000..b9d7278c6 --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/AddUpSituation.java @@ -0,0 +1,239 @@ +package com.engine.salary.entity.datacollection; + +import com.engine.salary.annotation.*; +import com.engine.hrmelog.annotation.ElogTransform; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.Date; +import java.util.List; +import java.util.Set; + +/** + * 数据采集-累计情况表 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@SalaryTable(pageId = "a4f83287-e3f9-4275-9527-7d06e54y6238", fields = "id,addUpSubtraction", operates = {@SalaryTableOperate(text = "删除",index = "0")}) +//hrsa_add_up_situation +@ElogTransform(name = "往期累计情况") +@Auth(page = "addUpSituation") +public class AddUpSituation { + /** + * 主键id + */ + @ElogTransform(name = "id") + private Long id; + + /** + * 人员信息表的主键id + */ + @ElogTransform(name = "创建人id") + private Long employeeId; + + /** + * 个税扣缴义务人的主键id + */ + @ElogTransform(name = "个税扣缴义务人id") + private Long taxAgentId; + + /** + * 税款所属期 + */ + @ElogTransform(name = "税款所属期") + private Date taxYearMonth; + private List taxYearMonthRange; + + /** + * 年份 + */ + @ElogTransform(name = "年份") + private Integer year; + + /** + * 累计收入额 + */ + @ElogTransform(name = "累计收入额") + @SalaryFormulaVar(defaultLabel = "累计收入额", labelId = 86712, dataType = "number") + @Encrypt + private String addUpIncome; + + /** + * 累计减除费用 + */ + @ElogTransform(name = "累计减除费用") + @SalaryFormulaVar(defaultLabel = "累计减除费用", labelId = 86711, dataType = "number") + @Encrypt + private String addUpSubtraction; + + /** + * 累计社保个人合计 + */ + @ElogTransform(name = "累计社保个人合计") + @SalaryFormulaVar(defaultLabel = "累计社保个人合计", labelId = 86710, dataType = "number") + @Encrypt + private String addUpSocialSecurityTotal; + + /** + * 累计公积金个人合计 + */ + @ElogTransform(name = "累计公积金个人合计") + @SalaryFormulaVar(defaultLabel = "累计公积金个人合计", labelId = 86709, dataType = "number") + @Encrypt + private String addUpAccumulationFundTotal; + + /** + * 累计子女教育 + */ + @ElogTransform(name = "累计子女教育") + @SalaryFormulaVar(defaultLabel = "累计子女教育", labelId = 86321, dataType = "number") + @Encrypt + private String addUpChildEducation; + + /** + * 累计继续教育 + */ + @ElogTransform(name = "累计继续教育") + @SalaryFormulaVar(defaultLabel = "累计继续教育", labelId = 86323, dataType = "number") + @Encrypt + private String addUpContinuingEducation; + + /** + * 累计住房贷款利息 + */ + @ElogTransform(name = "累计住房贷款利息") + @SalaryFormulaVar(defaultLabel = "累计住房贷款利息", labelId = 86324, dataType = "number") + @Encrypt + private String addUpHousingLoanInterest; + + /** + * 累计住房租金 + */ + @ElogTransform(name = "累计住房租金") + @SalaryFormulaVar(defaultLabel = "累计住房租金", labelId = 86325, dataType = "number") + @Encrypt + private String addUpHousingRent; + + /** + * 累计赡养老人 + */ + @ElogTransform(name = "累计赡养老人") + @SalaryFormulaVar(defaultLabel = "累计赡养老人", labelId = 86326, dataType = "number") + @Encrypt + private String addUpSupportElderly; + + /** + * 累计大病医疗 + */ + @ElogTransform(name = "累计大病医疗") + @SalaryFormulaVar(defaultLabel = "累计大病医疗", labelId = 105142, dataType = "number") + @Encrypt + private String addUpIllnessMedical; + + /** + * 累计婴幼儿照护 + */ + @ElogTransform(name = "累计婴幼儿照护") + @SalaryFormulaVar(defaultLabel = "累计婴幼儿照护", labelId = 117732, dataType = "number") + @Encrypt + private String addUpInfantCare; + + /** + * 累计婴幼儿照护 + */ + @ElogTransform(name = "累计个人养老金") + @SalaryFormulaVar(defaultLabel = "累计个人养老金", labelId = 117732, dataType = "number") + @Encrypt + private String addUpPrivatePension; + + /** + * 累计企业(职业)年金及其他福利 + */ + @ElogTransform(name = "累计企业(职业)年金及其他福利") + @SalaryFormulaVar(defaultLabel = "累计企业(职业)年金及其他福利", labelId = 90567, dataType = "number") + @Encrypt + private String addUpEnterpriseAndOther; + + /** + * 累计其他免税扣除 + */ + @ElogTransform(name = "累计其他免税扣除") + @SalaryFormulaVar(defaultLabel = "累计其他免税扣除", labelId = 93902, dataType = "number") + @Encrypt + private String addUpOtherDeduction; + + /** + * 累计免税收入 + */ + @ElogTransform(name = "累计免税收入") + @SalaryFormulaVar(defaultLabel = "累计免税收入", labelId = 86704, dataType = "number") + @Encrypt + private String addUpTaxExemptIncome; + + /** + * 累计准予扣除的捐赠额 + */ + @ElogTransform(name = "累计准予扣除的捐赠额") + @SalaryFormulaVar(defaultLabel = "累计准予扣除的捐赠额", labelId = 86703, dataType = "number") + @Encrypt + private String addUpAllowedDonation; + + /** + * 累计减免税额 + */ + @ElogTransform(name = "累计减免税额") + @SalaryFormulaVar(defaultLabel = "累计减免税额", labelId = 105478, dataType = "number") + @Encrypt + private String addUpTaxSavings; + + /** + * 累计已预扣预缴税额 + */ + @ElogTransform(name = "累计已预扣预缴税额") + @SalaryFormulaVar(defaultLabel = "累计已预扣预缴税额", labelId = 86702, dataType = "number") + @Encrypt + private String addUpAdvanceTax; + + /** + * 创建时间 + */ + @ElogTransform(name = "创建时间") + private Date createTime; + + /** + * 更新时间 + */ + @ElogTransform(name = "更新时间") + private Date updateTime; + + /** + * 创建人 + */ + @ElogTransform(name = "创建人") + private Long creator; + + /** + * 是否已删除。0:未删除、1:已删除 + */ + private Integer deleteType; + + /** + * 租户ID + */ + @ElogTransform(name = "租户") + private String tenantKey; + + + //条件 + Collection employeeIds; + Collection taxAgentIds; + + + private Set opts; + +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/datacollection/DataCollectionEmployee.java b/src/com/engine/salary/entity/datacollection/DataCollectionEmployee.java new file mode 100644 index 000000000..9203785c0 --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/DataCollectionEmployee.java @@ -0,0 +1,140 @@ +package com.engine.salary.entity.datacollection; + +import com.engine.salary.annotation.I18n; +import com.engine.salary.annotation.SalaryFormulaVar; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Map; + +/** + * 员工基本信息 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class DataCollectionEmployee { + + //员工id + @SalaryFormulaVar(defaultLabel = "员工id", labelId = 86184, dataType = "string") + private Long employeeId; + + // 个税扣缴义务人 +// private String taxAgentName; +// @SalaryFormulaVar(defaultLabel = "个税扣缴义务人", labelId = 86184, dataType = "string") +// private Long taxAgentId; + + //姓名 + @SalaryFormulaVar(defaultLabel = "姓名", labelId = 85429, dataType = "string") + @I18n + private String username; + + //部门 + @SalaryFormulaVar(defaultLabel = "部门", labelId = 86185, dataType = "string") + @I18n + private String departmentName; + @SalaryFormulaVar(defaultLabel = "部门ID", labelId = 86185, dataType = "string") + private Long departmentId; + + //分部名 + @SalaryFormulaVar(defaultLabel = "分部", labelId = 82465, dataType = "string") + @I18n + private String subcompanyName; + @SalaryFormulaVar(defaultLabel = "分部ID", labelId = 82465, dataType = "string") + private Long subcompanyid; + + //所属成本中心 + private Long costcenterId; + + //工作地点 + private Long locationId; + + //岗位 + @SalaryFormulaVar(defaultLabel = "岗位", labelId = 90633, dataType = "string") + @I18n + private String jobtitleName; + @SalaryFormulaVar(defaultLabel = "岗位ID", labelId = 90633, dataType = "string") + private Long jobtitleId; + + //入职日期 + @SalaryFormulaVar(defaultLabel = "入职日期", labelId = 86319, dataType = "string") + private String companystartdate; + + //手机号 + @SalaryFormulaVar(defaultLabel = "手机号", labelId = 98621, dataType = "string") + private String mobile; + + //离职日期 + private String dismissdate; + + @SalaryFormulaVar(defaultLabel = "状态编码", labelId = 98624, dataType = "string") + private String status; + + @SalaryFormulaVar(defaultLabel = "状态", labelId = 98622, dataType = "string") + private String statusName; + + //工号 + @SalaryFormulaVar(defaultLabel = "工号", labelId = 98622, dataType = "string") + private String workcode; + + //性别 + @SalaryFormulaVar(defaultLabel = "性别", labelId = 98622, dataType = "string") + private String sex; + + //邮件 + @SalaryFormulaVar(defaultLabel = "邮件", labelId = 92919, dataType = "string") + private String email; + + //电话 + @SalaryFormulaVar(defaultLabel = "电话", labelId = 98620, dataType = "string") + private String telephone; + + //职称 + @SalaryFormulaVar(defaultLabel = "职称", labelId = 98623, dataType = "string") + private String jobcall; + + @SalaryFormulaVar(defaultLabel = "职称ID", labelId = 98623, dataType = "string") + private Long jobcallId; + + //生日 + @SalaryFormulaVar(defaultLabel = "出生日期", labelId = 98624, dataType = "string") + private String birthday; + + private Double workYear; + private Double companyWorkYear; + + @SalaryFormulaVar(defaultLabel = "证件号码", labelId = 98624, dataType = "string") + private String idNo; + + + @SalaryFormulaVar(defaultLabel = "账号类型", labelId = 98622, dataType = "string") + private String accountTypeName; + + /** + * 账号类型 + * 0/null:主账号 1:次账号 + */ + @SalaryFormulaVar(defaultLabel = "账号类型编码", labelId = 98622, dataType = "string") + private Integer accountType; + + //是否是系统管理员 + private Boolean isAdmin; + + //是否外部人员 + private boolean extEmp; + + /** + * 扩展数据 + */ + private Map extendData; + + +} diff --git a/src/com/engine/salary/entity/datacollection/bo/AttendQuoteDataBO.java b/src/com/engine/salary/entity/datacollection/bo/AttendQuoteDataBO.java new file mode 100644 index 000000000..5b67306ca --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/bo/AttendQuoteDataBO.java @@ -0,0 +1,71 @@ +package com.engine.salary.entity.datacollection.bo; + +import com.engine.salary.entity.datacollection.po.AttendQuoteFieldPO; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; + +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +/** + * 考勤引用数据 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class AttendQuoteDataBO { + + @Override + public String toString() { + return "AttendQuoteDataBO{}"; + } + + /** + * 根据考勤模块来构建考勤数据 + */ + public static void buildAttendDataFromRemote( List> list, List attendQuoteFields, List> attendQuoteSyncData) { + if (CollectionUtils.isEmpty(list)) { + return; + } + list.forEach(m-> { + for (AttendQuoteFieldPO field : attendQuoteFields) { + if (StringUtils.isEmpty(field.getCode())) { + continue; + } + String key = field.getCode(); + //兼容出勤班次的key + if(key.startsWith("attendanceSerial_")){ + key = key.replace("attendanceSerial_", ""); + } + if (m.containsKey(key)) { + Map map = new LinkedHashMap<>(); + map.put("employeeId", m.get("resourceId")); + map.put("attendQuoteFieldId", field.getId()); + map.put("dataValue", m.get(key)); + attendQuoteSyncData.add(map); + } + } + }); + } + +// public static DataCollectionEmployee getCurrentUser4Remote() { +// DataCollectionEmployee se = UserContext.getCurrentUser(); +// if(se != null){ +// DataCollectionEmployee simple = new DataCollectionEmployee(); +// simple.setId(se.getId()); +// simple.setUserId(se.getUserId()); +// simple.setUsername(se.getUsername()); +// simple.setPinyin(se.getPinyin()); +// simple.setImUid(se.getImUid()); +// simple.setImCid(se.getImCid()); +// simple.setTenantKey(se.getTenantKey()); +// simple.setDepartment(se.getDepartment()); +// simple.setAuthorities(null); +// return simple; +// } +// return null; +// } +} diff --git a/src/com/engine/salary/entity/datacollection/bo/AttendQuoteFieldBO.java b/src/com/engine/salary/entity/datacollection/bo/AttendQuoteFieldBO.java new file mode 100644 index 000000000..1124145c8 --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/bo/AttendQuoteFieldBO.java @@ -0,0 +1,106 @@ +package com.engine.salary.entity.datacollection.bo; + +import com.cloudstore.eccom.pc.table.WeaTableColumn; +import com.engine.salary.util.SalaryI18nUtil; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; + +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + +/** + * 考勤引用-字段管理 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class AttendQuoteFieldBO { + + + public static List buildRecordTableColumns() { + List result = Lists.newArrayListWithExpectedSize(5); + result.add(new WeaTableColumn("20%", SalaryI18nUtil.getI18nLabel(87628, "字段名称"), "fieldName")); + result.add(new WeaTableColumn("20%", SalaryI18nUtil.getI18nLabel(87617, "来源"), "sourceType")); + result.add(new WeaTableColumn("20%", SalaryI18nUtil.getI18nLabel(84758, "类型"), "fieldType")); + result.add(new WeaTableColumn("20%", SalaryI18nUtil.getI18nLabel(87629, "是否启用"), "enableStatus")); + result.add(new WeaTableColumn("20%", SalaryI18nUtil.getI18nLabel(84961, "备注"), "description")); + return result; + } + +// public static Map buildEditableTableItemMap() { +// Map resultMap = Maps.newHashMapWithExpectedSize(9); +// resultMap.put("fieldName", new EditableTableItem(EditableTableItemType.INPUT, "", true)); +// resultMap.put("sourceType", new EditableTableItem(EditableTableItemType.INPUT, "", true)); +// resultMap.put("fieldType", new EditableTableItem(EditableTableItemType.INPUT, "", true)); +// resultMap.put("enableStatus", new EditableTableItem(EditableTableItemType.SWITCH, "", false)); +// resultMap.put("description", new EditableTableItem(EditableTableItemType.INPUT, "", true)); +// return resultMap; +// } + + /** + * 考勤模块固定字段编码 + * 注意:目前固定,后期考勤模块会管理维护 + * + * @return + */ + public static List> buildAttendFixedFields() { + List> attendFixedFields = new LinkedList<>(); + + //-------------------------------按小时------------------------------------------------------------ + + // 应出勤工时 + attendFixedFields.add(attendFixedField("workmins_hour", 92040, "应出勤工时")); + // 实际出勤工时 + attendFixedFields.add(attendFixedField("attendancemins_hour", 92042, "实际出勤工时")); + + // 迟到工时 + attendFixedFields.add(attendFixedField("belatemins_hour", 92043, "迟到时长")); + attendFixedFields.add(attendFixedField("gravebelatemins_hour", 92043, "严重迟到时长")); + // 早退工时 + attendFixedFields.add(attendFixedField("leaveearlymins_hour", 92044, "早退时长")); + attendFixedFields.add(attendFixedField("graveleaveearlymins_hour", 92044, "严重早退时长")); + + // 未出勤工时 +// attendFixedFields.add(attendFixedField("forgotcheckmins_hour", 92045, "漏签时长")); + // 旷工工时 + attendFixedFields.add(attendFixedField("absenteeism_hour", 92046, "旷工次数")); + attendFixedFields.add(attendFixedField("absenteeismmins_hour", 92046, "旷工工时")); + + //----------------------------按天------------------------------------------------------------- + + // 应出勤天数 + attendFixedFields.add(attendFixedField("workdays_day", 92059, "应出勤天数")); + // 实际出勤天数 + attendFixedFields.add(attendFixedField("attendancedays_day", 92061, "实际出勤天数")); + + /* ====== 异常缺勤 ==================================== */ + // 迟到天数 + attendFixedFields.add(attendFixedField("belate_day", 92062, "迟到次数")); + attendFixedFields.add(attendFixedField("gravebelate_day", 92043, "严重迟到次数")); + // 早退天数 + attendFixedFields.add(attendFixedField("leaveeearly_day", 92063, "早退次数")); + attendFixedFields.add(attendFixedField("graveleaveearly_day", 92044, "严重早退次数")); + // 未出勤天数 + attendFixedFields.add(attendFixedField("forgotcheck_day", 92064, "漏签次数")); + // 旷工天数 + attendFixedFields.add(attendFixedField("absenteeism_day", 92065, "旷工天数")); + + //请假 +// attendFixedFields.add(attendFixedField("leavemins_day", 92065, "请假时长")); +// attendFixedFields.add(attendFixedField("evectionmins_day", 92065, "出差时长")); +// attendFixedFields.add(attendFixedField("toutmins_day", 92065, "公出时长")); + + + return attendFixedFields; + } + + private static Map attendFixedField(String code, int labelId, String name) { + Map map = Maps.newHashMapWithExpectedSize(2); + map.put("code", code); + map.put("name", name); + return map; + } +} diff --git a/src/com/engine/salary/entity/datacollection/bo/DataCollectionBO.java b/src/com/engine/salary/entity/datacollection/bo/DataCollectionBO.java new file mode 100644 index 000000000..e216ddc7d --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/bo/DataCollectionBO.java @@ -0,0 +1,52 @@ +package com.engine.salary.entity.datacollection.bo; + +/** + * @Description: 数据采集 + * @Author: wangxiangzhong + * @Date: 2021/11/29 13:28 + */ +public class DataCollectionBO { + + @Override + public String toString() { + return "DataCollectionBO{}"; + } + +// /** +// * 添加日期范围 +// * +// * @param weaSearchCondition +// * @param employeeId +// * @param tenantKey +// */ +// public static void addDatePickerRangeOtherParams(WeaSearchCondition weaSearchCondition, String datePickerKey, Long employeeId, String tenantKey) { +// WeaSearchConditionItem datePickerItem = weaSearchCondition.getItems().get(datePickerKey); +// Map otherParams = Maps.newHashMap(); +// otherParams.put("isRange", true); +// otherParams.put("type", "day"); +// otherParams.put("startPlaceholder", SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 90648, "开始日期")); +// otherParams.put("endPlaceholder", SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 90649, "结束日期")); +// datePickerItem.setOtherParams(otherParams); +// weaSearchCondition.getItems().put(datePickerKey, datePickerItem); +// } +// +// /** +// * 获取身份证号 +// * +// * @param employeeId +// * @param simpleUserInfos +// */ +// public static String getIdNo(Long employeeId, List simpleUserInfos) { +// if (employeeId == null || CollectionUtils.isEmpty(simpleUserInfos)) { +// return StringUtils.EMPTY; +// } +// Optional optionalSimpleUserInfo = simpleUserInfos.stream() +// .filter(simpleUserInfo -> Objects.nonNull(simpleUserInfo) && Objects.nonNull(simpleUserInfo.getUser())).findFirst(); +// String idNo = StringUtils.EMPTY; +// if (optionalSimpleUserInfo.isPresent()) { +// SimpleUserInfo simpleUserInfo = optionalSimpleUserInfo.get(); +// idNo = Optional.of(simpleUserInfo).map(SimpleUserInfo::getIdNo).orElse(StringUtils.EMPTY); +// } +// return idNo; +// } +} diff --git a/src/com/engine/salary/entity/datacollection/bo/VariableArchiveBO.java b/src/com/engine/salary/entity/datacollection/bo/VariableArchiveBO.java new file mode 100644 index 000000000..f9d8345c8 --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/bo/VariableArchiveBO.java @@ -0,0 +1,281 @@ +package com.engine.salary.entity.datacollection.bo; + +import com.cloudstore.eccom.constant.WeaBoolAttr; +import com.cloudstore.eccom.pc.table.WeaTableColumn; +import com.engine.salary.constant.SalaryItemConstant; +import com.engine.salary.entity.datacollection.po.VariableItemPO; +import com.engine.salary.util.SalaryI18nUtil; + +import java.util.ArrayList; +import java.util.List; + +/** + * @Description: 浮动薪资档案 + * @Author: xzy + */ +public class VariableArchiveBO { + + @Override + public String toString() { + return "SalaryArchiveBO{}"; + } + + + + /** + * 构建表格动态列 + * + * @param variableItems + */ + public static List buildVariableArchiveTable(List variableItems) { + // 表格表头 + List columns = new ArrayList<>(); + WeaTableColumn idColumn = new WeaTableColumn("100px", "id", "id"); + idColumn.setIsPrimarykey(WeaBoolAttr.TRUE); + idColumn.setDisplay(WeaBoolAttr.FALSE); + columns.add(idColumn); + WeaTableColumn employeeIdColumn = new WeaTableColumn("100px", "人员信息表的主键id", "employeeId"); + employeeIdColumn.setDisplay(WeaBoolAttr.FALSE); + columns.add(employeeIdColumn); + columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(0, "薪资所属月"), "salaryMonth")); + columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(85429, "个税扣缴义务人"), "taxAgentName")); + columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(85429, "姓名"), "username")); + columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(86185, "部门"), "departmentName")); + columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(86186, "手机号"), "mobile")); + columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(86185, "工号"), "workcode")); + columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(86186, "证件号码"), "idNo")); + columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(86187, "入职日期"), "companystartdate")); + for (VariableItemPO variableItem : variableItems) { + columns.add(new WeaTableColumn("100px", variableItem.getName(), variableItem.getId() + SalaryItemConstant.VARIABLE_ITEM_DYNAMIC_SUFFIX)); + } + + return columns; + } + +// /** +// * 构建薪资档案数据 +// * +// * @param salaryArchiveList +// * @param salaryArchiveItemDataList +// * @param localDateRange +// * @param allEmployeeIds +// * @param isOnlyTaxAgent +// * @return +// */ +// public static List buildSalaryArchiveData(List salaryArchiveList, +// List salaryArchiveItemDataList, +// LocalDateRange localDateRange, +// List allEmployeeIds, +// boolean isOnlyTaxAgent) { +// // 开始日期 +// Date start = localDateRange.getFromDate(); +// // 结束日期 +// Date end = localDateRange.getEndDate(); +// +// List list = new ArrayList<>(); +// allEmployeeIds.forEach(e -> { +// // 同一个人的档案数据 +// List salaryArchives = salaryArchiveList.stream().filter(f -> f.getEmployeeId().equals(e)).collect(Collectors.toList()); +// List salaryArchiveIds = salaryArchives.stream().map(SalaryArchivePO::getId).collect(Collectors.toList()); +// // 同一个人的薪资项目调整历史数据 +// List salaryArchiveItems = salaryArchiveItemDataList.stream().filter(d -> salaryArchiveIds.contains(d.getSalaryArchiveId())).collect(Collectors.toList()); +// List salaryArchiveItemIds = salaryArchiveItems.stream().map(SalaryArchiveItemPO::getSalaryItemId).distinct().collect(Collectors.toList()); +// +// SalaryArchiveDataDTO salaryArchiveData = new SalaryArchiveDataDTO(); +// salaryArchiveData.setEmployeeId(e); +// List taxAgents = new ArrayList<>(); +// // 按个税扣缴义务人生效日期时间段切割 +// for (SalaryArchivePO salaryArchive : salaryArchives) { +// Date fromDate = salaryArchive.getPayStartDate(); +// Date endDate = salaryArchive.getPayEndDate(); +// // 起始发薪日不为空,且不能比结束日期晚,最后发薪日可空可不空,但是如果不为空,就不能比开始日期早,且起始发薪日不能晚于最后发薪日 +// boolean isEnable = fromDate != null && !fromDate.after(end) && (endDate == null || (!fromDate.after(endDate) && !endDate.before(start))); +// if (isEnable) { +// SalaryArchiveTaxAgentDataDTO taxAgent = new SalaryArchiveTaxAgentDataDTO(); +// taxAgent.setTaxAgentId(salaryArchive.getTaxAgentId()); +// // taxAgent.setIncomeCategory(salaryArchive.getIncomeCategory()); +// // taxAgent.setSalarySobIds(salaryArchiveSobList.stream().filter(sob->sob.getSalaryArchiveId().equals(salaryArchive.getId())).map(SalaryArchiveSobPO::getSalarySobId).distinct().collect(Collectors.toList())); +// taxAgent.setEffectiveDateRange(LocalDateRange.builder().fromDate((fromDate.before(start) ? start : fromDate)).endDate(endDate == null || endDate.after(end) ? end : endDate).build()); +// // 薪资项目数据按个税扣缴义务人切割 +// if (!isOnlyTaxAgent) { +// // 开始日期 +// Date startItem = taxAgent.getEffectiveDateRange().getFromDate(); +// // 结束日期 +// Date endItem = taxAgent.getEffectiveDateRange().getEndDate(); +// Date endTempItem = endItem; +// List salaryItemValues = new ArrayList<>(); +// for (Long salaryArchiveItemId : salaryArchiveItemIds) { +// boolean flag = false; +// for (SalaryArchiveItemPO salaryArchiveItem : salaryArchiveItems) { +// if (!salaryArchiveItemId.equals(salaryArchiveItem.getSalaryItemId()) || !salaryArchiveItem.getSalaryArchiveId().equals(salaryArchive.getId())) { +// continue; +// } +// Date fromDateItem = salaryArchiveItem.getEffectiveTime(); +// if (fromDateItem.after(endTempItem) || endTempItem.before(startItem)) { +// continue; +// } +// if (endTempItem.equals(startItem) && flag) { +// continue; +// } +// SalaryArchiveItemDataDTO salaryArchiveItemData = new SalaryArchiveItemDataDTO(); +// salaryArchiveItemData.setEffectiveDateRange(LocalDateRange.builder().fromDate((fromDateItem.before(startItem) ? startItem : fromDateItem)).endDate(endTempItem).build()); +// salaryArchiveItemData.setSalaryItemId(salaryArchiveItem.getSalaryItemId()); +// salaryArchiveItemData.setValue(salaryArchiveItem.getItemValue()); +// salaryItemValues.add(salaryArchiveItemData); +// flag = true; +// endTempItem = fromDateItem; +// } +// endTempItem = endItem; +// } +// taxAgent.setSalaryItemValues(salaryItemValues); +// } +// taxAgents.add(taxAgent); +// } +// } +// salaryArchiveData.setTaxAgents(taxAgents); +// list.add(salaryArchiveData); +// }); +// +// return list; +// } +// +// /** +// * 构建增量数据 +// * +// * @param taxAgentEmpChangeList +// * @param salaryArchiveList +// * @param salaryArchiveItemList +// * @param currentEmployeeId +// */ +// public static ChangeData buildChangeData(List taxAgentEmpChangeList, List salaryArchiveList, List salaryArchiveItemList, Long currentEmployeeId) { +// List changeIds = taxAgentEmpChangeList.stream().map(TaxAgentEmpChangePO::getId).collect(Collectors.toList()); +// // 根据个税扣缴义务人和人员以及增量类型分组 +// Map changeTypeMap = taxAgentEmpChangeList.stream().collect(Collectors.groupingBy(change -> change.getTaxAgentId() + "-" + change.getEmployeeId() + "-" + change.getChangeType(), Collectors.counting())); +// // 顺序倒转 +// Collections.reverse(taxAgentEmpChangeList); +// // 去重 +// taxAgentEmpChangeList = taxAgentEmpChangeList.stream() +// .collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(f -> f.getTaxAgentId() + "-" + f.getEmployeeId()))), ArrayList::new)); +// List taxAgentEmpChanges = taxAgentEmpChangeList +// .stream() +// // 不相等则保留,否则忽略 +// .filter(change -> !Objects.equals(changeTypeMap.get(change.getTaxAgentId() + "-" + change.getEmployeeId() + "-" + TaxAgentEmpChangeTypeEnum.ADD.getValue()) +// , changeTypeMap.get(change.getTaxAgentId() + "-" + change.getEmployeeId() + "-" + TaxAgentEmpChangeTypeEnum.DEL.getValue()))) +// .collect(Collectors.toList()); +// +// Date now = new Date(); +// Date today = new Date(); +// List stopStatus = Arrays.asList(SalaryArchiveStatusEnum.STOP_FROM_PENDING.getValue(), SalaryArchiveStatusEnum.STOP_FROM_SUSPEND.getValue()); +// List salaryArchiveAddTodoList = Lists.newArrayList(); +// List salaryArchiveUpdateTodoList = Lists.newArrayList(); +// List salaryArchiveItemAddTodos = Lists.newArrayList(); +// +// Map salaryArchiveListMap = SalaryEntityUtil.convert2Map(salaryArchiveList, k -> k.getTaxAgentId() + "-" + k.getEmployeeId()); +// taxAgentEmpChanges.forEach(change -> { +// SalaryArchivePO salaryArchive = salaryArchiveListMap.get(change.getTaxAgentId() + "-" + change.getEmployeeId()); +// // 如果是新增 说明:如果没有档案,则新增,如果有档案而且是停薪,就挪到待定薪中,以个税扣缴义务人和人员id判断唯一 +// if (change.getChangeType() == TaxAgentEmpChangeTypeEnum.ADD.getValue()) { +// if (salaryArchive != null) { +// // 停薪中跳回待定薪:从a调动到b又调动到a,或者是删除待办后再覆盖 +// if (stopStatus.contains(salaryArchive.getRunStatus())) { +// // 跳回待定薪 +// salaryArchive.setRunStatus(SalaryArchiveStatusEnum.PENDING.getValue()); +// if (salaryArchive.getRunStatus().equals(SalaryArchiveStatusEnum.STOP_FROM_SUSPEND.getValue())) { +// salaryArchive.setPayStartDate(today); +// salaryArchive.setPayEndDate(null); +// } +// salaryArchiveUpdateTodoList.add(salaryArchive); +// // 待停薪到停薪的就要复制最新的薪资项目 +// if (salaryArchive.getRunStatus().equals(SalaryArchiveStatusEnum.STOP_FROM_SUSPEND.getValue())) { +// // 拷贝最新的薪资项目数据 +// List salaryArchiveItemValuelList = salaryArchiveItemList.stream().filter(i -> i.getSalaryArchiveId().equals(salaryArchive.getId())).collect(Collectors.toList()); +// salaryArchiveItemValuelList.forEach(i -> { +// salaryArchiveItemAddTodos.add(SalaryArchiveItemPO.builder() +// .id(IdGenerator.generate()) +// .salaryArchiveId(salaryArchive.getId()) +// .employeeId(salaryArchive.getEmployeeId()) +// .effectiveTime(today) +// .adjustReason(SalaryArchiveItemAdjustReasonEnum.INIT.getValue()) +// .salaryItemId(i.getSalaryItemId()) +// .itemValue(i.getItemValue()) +// .description("") +// // 不用设置操作人 +// .operateTime(now) +// .createTime(now) +// .updateTime(now) +// .creator(currentEmployeeId) +// .deleteType(NumberUtils.INTEGER_ZERO) +// .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) +// .build()); +// }); +// } +// } +// } else { +// salaryArchiveAddTodoList.add(SalaryArchivePO.builder() +// .id(IdGenerator.generate()) +// .employeeId(change.getEmployeeId()) +// .taxAgentId(change.getTaxAgentId()) +// .employeeType(change.getEmployeeType()) +// .runStatus(SalaryArchiveStatusEnum.PENDING.getValue()) +// // .incomeCategory(IncomeCategoryEnum.WAGES_AND_SALARIES.getValue()) +// // .modifier(0L) +// .createTime(now) +// .updateTime(now) +// .creator(currentEmployeeId) +// .deleteType(NumberUtils.INTEGER_ZERO) +// .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) +// .build()); +// } +// // 如果是删除 说明:如果有档案并且是在定薪列表才处理,没档案不用管 +// } else if (change.getChangeType() == TaxAgentEmpChangeTypeEnum.DEL.getValue()) { +// if (salaryArchive != null) { +// if (salaryArchive.getRunStatus().equals(SalaryArchiveStatusEnum.FIXED.getValue())) { +// // 跳到待停薪 +// salaryArchive.setRunStatus(SalaryArchiveStatusEnum.SUSPEND.getValue()); +// // salaryArchive.setPayEndDate(today); +// salaryArchiveUpdateTodoList.add(salaryArchive); +// } else if (salaryArchive.getRunStatus().equals(SalaryArchiveStatusEnum.PENDING.getValue())) { +// // 跳到停薪 +// salaryArchive.setRunStatus(SalaryArchiveStatusEnum.STOP_FROM_PENDING.getValue()); +// salaryArchiveUpdateTodoList.add(salaryArchive); +// } +// } +// } +// }); +// +// return ChangeData.builder() +// .salaryArchiveAddTodoList(salaryArchiveAddTodoList) +// .salaryArchiveUpdateTodoList(salaryArchiveUpdateTodoList) +// .salaryArchiveItemAddTodos(salaryArchiveItemAddTodos) +// .changeIds(changeIds) +// .build(); +// } +// +// @Data +// @Builder +// @NoArgsConstructor +// @AllArgsConstructor +// public static class ChangeData { +// +// /** +// * 批量修改薪资档案 +// */ +// private List salaryArchiveAddTodoList; +// +// /** +// * 批量新增薪资档案 +// */ +// private List salaryArchiveUpdateTodoList; +// +// /** +// * 落库处理薪资项目 +// */ +// private List salaryArchiveItemAddTodos; +// +// /** +// * 删除增量数据 +// */ +// private List changeIds; +// } + +} diff --git a/src/com/engine/salary/entity/datacollection/bo/VariableArchiveExcelBO.java b/src/com/engine/salary/entity/datacollection/bo/VariableArchiveExcelBO.java new file mode 100644 index 000000000..56f7a14b0 --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/bo/VariableArchiveExcelBO.java @@ -0,0 +1,314 @@ +package com.engine.salary.entity.datacollection.bo; + +import cn.hutool.core.util.NumberUtil; +import com.engine.core.impl.Service; +import com.engine.salary.constant.SalaryDefaultTenantConstant; +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.datacollection.param.VariableArchiveImportHandleParam; +import com.engine.salary.entity.datacollection.po.VariableArchiveItemPO; +import com.engine.salary.entity.datacollection.po.VariableArchivePO; +import com.engine.salary.entity.datacollection.po.VariableItemPO; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import com.engine.salary.enums.UserStatusEnum; +import com.engine.salary.enums.salaryarchive.SalaryArchiveFieldTypeEnum; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.db.IdGenerator; +import com.google.common.base.Joiner; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.math.NumberUtils; +import weaver.general.Util; +import weaver.hrm.User; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * @Description: 浮动薪资档案-excel + * @Author: xzy + * @Date: 2024-08-08 10:51 + */ +public class VariableArchiveExcelBO extends Service { + + public static String userNameI18n; + public static String departmentI18n; + public static String jobNumI18n; + public static String hrStatusI18n; + public static String repeatMsg; + public static String taxAgentI18n; + public static String taxAgentRangeMsg; + public static String empRepeatMsg; + + public static String notEmptyI18n; + + public static String incomeCategoryI18n; + public static String salarySobI18n; + public static String effectiveTimeI18n; + public static String payStartDateI18n; + public static String payEndDateI18n; + public static String adjustReasonI18n; + public static String listTypeErrMsg; + public static String taxAgentNoExist; + public static String incomeCategoryNoExist; + public static String currSalarySobI18n; + public static String noExist; + public static String effectiveTimeErr; + public static String adjustReasonNoExist; + public static String dateErr; + public static String payStartUnableAfterEnd; + + public static String salaryItemNoBeforeCurrentEffectiveTime; + public static String salaryItemAdjustNoSame; + public static String salaryItemAdjustNoSameIneffective; + + public static String salaryArchiveErr; + public static String numberErr; + + /** + * 初始化i18n + */ + public static void initI18n() { + userNameI18n = SalaryI18nUtil.getI18nLabel(85429, "姓名"); + departmentI18n = SalaryI18nUtil.getI18nLabel(86185, "部门"); + jobNumI18n = SalaryI18nUtil.getI18nLabel(86317, "工号"); + hrStatusI18n = SalaryI18nUtil.getI18nLabel(109332, "人事状态"); + repeatMsg = "[" + Joiner.on(",").join(new List[]{Arrays.asList(userNameI18n, departmentI18n, jobNumI18n, hrStatusI18n)}) + "]"; + taxAgentI18n = SalaryI18nUtil.getI18nLabel(86184, "个税扣缴义务人"); + taxAgentRangeMsg = SalaryI18nUtil.getI18nLabel(132633, "该员工不在该个税扣缴义务人的人员范围中") + "," + SalaryI18nUtil.getI18nLabel(127308, "请检查") + repeatMsg; + empRepeatMsg = SalaryI18nUtil.getI18nLabel(121899, "员工信息重复,请检查") + repeatMsg; + + notEmptyI18n = SalaryI18nUtil.getI18nLabel(100577, "不能为空"); + + incomeCategoryI18n = SalaryI18nUtil.getI18nLabel(121908, "收入所得项目"); + salarySobI18n = SalaryI18nUtil.getI18nLabel(87889, "薪资账套"); + effectiveTimeI18n = SalaryI18nUtil.getI18nLabel(85904, "生效日期"); + payStartDateI18n = SalaryI18nUtil.getI18nLabel(109527, "起始发薪日期"); + payEndDateI18n = SalaryI18nUtil.getI18nLabel(109329, "最后发薪日期"); + adjustReasonI18n = SalaryI18nUtil.getI18nLabel(85431, "调整原因"); + + listTypeErrMsg = SalaryI18nUtil.getI18nLabel(115527, "该条数据不符合当前列表导入要求或其他列表存在该档案,不可导入"); + + taxAgentNoExist = SalaryI18nUtil.getI18nLabel(100545, "个税扣缴义务人不存在"); + incomeCategoryNoExist = SalaryI18nUtil.getI18nLabel(121923, "收入所得项目不存在"); + + currSalarySobI18n = SalaryI18nUtil.getI18nLabel(127213, "该收入所得项目"); + noExist = SalaryI18nUtil.getI18nLabel(127236, "不存在"); + + effectiveTimeErr = SalaryI18nUtil.getI18nLabel(102497, "生效日期错误或格式不正确,正确格式示例为'2022-01-01'、'2022/1/1'"); + adjustReasonNoExist = SalaryI18nUtil.getI18nLabel(100591, "调整原因不存在"); + + dateErr = SalaryI18nUtil.getI18nLabel(109819, "日期错误或格式不正确,正确格式示例为'2022-01-01'、'2022/1/1'"); + + payStartUnableAfterEnd = SalaryI18nUtil.getI18nLabel(109214, "起始发薪日期不可晚于最后发薪日"); + + salaryItemNoBeforeCurrentEffectiveTime = SalaryI18nUtil.getI18nLabel(100429, "生效日期不可早于当前已生效的调整日期"); + salaryItemAdjustNoSame = SalaryI18nUtil.getI18nLabel(100432, "调整前后不可相同"); + salaryItemAdjustNoSameIneffective = SalaryI18nUtil.getI18nLabel(100434, "与未生效的调整后不可相同"); + + salaryArchiveErr = SalaryI18nUtil.getI18nLabel(101723, "该员工的薪资档案记录有误,请检查"); + numberErr = SalaryI18nUtil.getI18nLabel(100581, "请输入数字"); + + } + + + /** + * 校验单行数据 + * + * @param map + * @param headers + * @param excelComments + * @param errorCount + * @param importHandleParam + * @return + */ + public static boolean singleRowCheck(List allTodoVariableArchives, + Map map, + List headers, + List> excelComments, + int errorCount, + VariableArchiveImportHandleParam importHandleParam, + User user) { + + boolean isError = false; + String rowindex = "第" + map.get("index") + "行"; + // 1.姓名 + String userName = Optional.ofNullable(map.get(userNameI18n)).orElse("").toString(); + String deparmentName = Optional.ofNullable(map.get(departmentI18n)).orElse("").toString(); + String mobileName = Optional.ofNullable(map.get("手机号")).orElse("").toString(); + String workcode = Optional.ofNullable(map.get("工号")).orElse("").toString(); + String idNo = Optional.ofNullable(map.get("证件号码")).orElse("").toString(); + + String validType = importHandleParam.getEmpValidType(); + List emps = new ArrayList<>(); + if ("0".equals(validType)) { + //“0”代表姓名+部门+手机号的匹配原则,“1”代表工号为唯一匹配原则 + emps = importHandleParam.getEmployees().stream().filter(e -> + (StringUtils.isBlank(userName) || Objects.equals(e.getUsername(), userName)) + && (StringUtils.isBlank(deparmentName) || Objects.equals(e.getDepartmentName(), deparmentName)) + && (StringUtils.isBlank(mobileName) || Objects.equals(e.getMobile(), mobileName))).collect(Collectors.toList()); + } else if ("1".equals(validType)) { + emps = importHandleParam.getEmployees().stream().filter(e -> (StringUtils.isBlank(workcode) || Objects.equals(e.getWorkcode(), workcode))) + .collect(Collectors.toList()); + } + else if ("2".equals(validType)) { + emps = importHandleParam.getEmployees().stream().filter(e -> (StringUtils.isBlank(idNo) || Objects.equals(e.getIdNo(), idNo))) + .collect(Collectors.toList()); + } + + List employeeSameIds = new ArrayList<>(); + if (CollectionUtils.isNotEmpty(emps) && emps.size() > 1) { + employeeSameIds = emps.stream().filter(e -> UserStatusEnum.getNormalStatus().contains(e.getStatus())).map(DataCollectionEmployee::getEmployeeId).collect(Collectors.toList()); + } + if (CollectionUtils.isNotEmpty(emps) && emps.size() == 1) { + employeeSameIds = emps.stream().map(DataCollectionEmployee::getEmployeeId).collect(Collectors.toList()); + } + Long employeeId = CollectionUtils.isNotEmpty(employeeSameIds) && employeeSameIds.size() == 1 && employeeSameIds.get(0) > 0 ? employeeSameIds.get(0) : null; + + if (employeeId == null) { + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowindex + "查找人员失败,请确定姓名、部门、手机号正确且唯一"); + excelComments.add(errorMessageMap); + isError = true; + return isError; + } + + // 个税扣缴义务人 + String taxAgentCellVal = Optional.ofNullable(map.get(taxAgentI18n)).orElse("").toString(); + map.put("taxAgent", taxAgentCellVal); + Optional optionalTaxAgent = importHandleParam.getTaxAgentList().stream().filter(m -> m.getName().equals(taxAgentCellVal)).findFirst(); + if (!optionalTaxAgent.isPresent()) { + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowindex + "个税扣缴义务人不存在,或不在权限范围内"); + excelComments.add(errorMessageMap); + isError = true; + return isError; + } + Long taxAgentId = optionalTaxAgent.get().getId(); + map.put("taxAgentId", taxAgentId); + + // 用于初始化导入数据校验 + map.put("employeeId", employeeId); + String repeatKey = optionalTaxAgent.get().getId() + "-" + employeeId.toString(); + if (allTodoVariableArchives.contains(repeatKey)) { + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowindex + "存在重复数据"); + excelComments.add(errorMessageMap); + isError = true; + return isError; + } else { + allTodoVariableArchives.add(repeatKey); + } + + // 构建薪资档案 + VariableArchivePO finalVariableArchive = buildVariableArchive(employeeId, taxAgentId, importHandleParam); + map.put("variableArchiveId", finalVariableArchive.getId()); + List needDelArchiveItemIds = new ArrayList<>(); + for (int j = 0; j < headers.size(); j++) { + String header = headers.get(j); + Object key = header; + if (key == null) { + continue; + } + String cellVal = Optional.ofNullable(map.get(key.toString())).orElse("").toString(); + + + boolean isNotEmpty = StringUtils.isNotEmpty(cellVal); + // 1.姓名列处理 + if (isNotEmpty && userNameI18n.equals(key.toString())) { + if (CollectionUtils.isEmpty(employeeSameIds) || employeeSameIds.size() > 1) { + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowindex + header + empRepeatMsg); + excelComments.add(errorMessageMap); + isError = true; + } + } else { + // 浮动薪资项目数据 + if (!isError) { + Optional optionalVariableItem = importHandleParam.getVariableItems().stream().filter(e -> Util.formatMultiLang(e.getName(), String.valueOf(user.getLanguage())).equals(key)).findFirst(); + + if (optionalVariableItem.isPresent()) { + VariableItemPO variableItemPO = optionalVariableItem.get(); + // 数值类型判断 + boolean isNotNumber = variableItemPO.getDataType().equals(SalaryArchiveFieldTypeEnum.NUMBER.getValue()) && StringUtils.isNotEmpty(cellVal) && !NumberUtil.isNumber(cellVal); + if (isNotNumber) { + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowindex + key + numberErr); + excelComments.add(errorMessageMap); + isError = true; + } + Long variableItemId = variableItemPO.getId(); + // 已生效 + List effectiveList = Optional.ofNullable(importHandleParam.getEffectiveItemListMap().get(finalVariableArchive.getId() + "-" + variableItemId)).orElse(Lists.newArrayList()); + // 先删除后新增 + needDelArchiveItemIds.addAll(effectiveList.stream().map(VariableArchiveItemPO::getId).collect(Collectors.toList())); + + // 导入时不需要处理的项目 + boolean isInitNull = CollectionUtils.isEmpty(effectiveList) && StringUtils.isEmpty(cellVal); + if (!isError && !isInitNull && StringUtils.isNotBlank(cellVal)) { + importHandleParam.getVariableArchiveItemSaves().add(VariableArchiveItemPO.builder() + .id(IdGenerator.generate()) + .employeeId(finalVariableArchive.getEmployeeId()) + .variableArchiveId(finalVariableArchive.getId()) + .variableItemId(variableItemId) + .itemValue(cellVal) + .creator(importHandleParam.getCurrentEmployeeId()) + .createTime(importHandleParam.getNowTime()) + .updateTime(importHandleParam.getNowTime()) + .deleteType(NumberUtils.INTEGER_ZERO) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .build()); + } + } + } + } + } + + // 如果当前校验行没问题,修改起始发薪日期和最终发薪日期等 + if (isError) { + // 将前面添加好的数据给过滤掉 + importHandleParam.setVariableArchiveSaves(importHandleParam.getVariableArchiveSaves().stream().filter(f -> !finalVariableArchive.getId().equals(f.getId())).collect(Collectors.toList())); + importHandleParam.setVariableArchiveItemSaves(importHandleParam.getVariableArchiveItemSaves().stream().filter(f -> !finalVariableArchive.getId().equals(f.getVariableArchiveId())).collect(Collectors.toList())); + } else { + importHandleParam.getVariableArchiveItemDelSalaryItemIds().addAll(needDelArchiveItemIds); + } + + return isError; + } + + + /** + * 构建浮动薪资档案对象 + * + * @param employeeId + * @param taxAgentId + * @param importHandleParam + * @return + */ + public static VariableArchivePO buildVariableArchive(Long employeeId, Long taxAgentId, VariableArchiveImportHandleParam importHandleParam) { + VariableArchivePO variableArchivePO = importHandleParam.getVariableArchivesMap().get(taxAgentId + "-" + employeeId); + if (variableArchivePO == null) { + // 新增浮动档案 + variableArchivePO = VariableArchivePO.builder() + .id(IdGenerator.generate()) + .employeeId(employeeId) + .taxAgentId(taxAgentId) + .salaryMonth(importHandleParam.getSalaryMonthDate()) + .createTime(importHandleParam.getNowTime()) + .updateTime(importHandleParam.getNowTime()) + .creator(importHandleParam.getCurrentEmployeeId()) + .deleteType(NumberUtils.INTEGER_ZERO) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .build(); + importHandleParam.getVariableArchiveSaves().add(variableArchivePO); + } + return variableArchivePO; + } + + + @Override + public String toString() { + return "SalaryArchiveExcelBO{}"; + } +} diff --git a/src/com/engine/salary/entity/datacollection/dto/AddUpDeductionDTO.java b/src/com/engine/salary/entity/datacollection/dto/AddUpDeductionDTO.java new file mode 100644 index 000000000..78b4ac20a --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/dto/AddUpDeductionDTO.java @@ -0,0 +1,170 @@ +package com.engine.salary.entity.datacollection.dto; + +import com.cloudstore.eccom.pc.table.WeaTableType; +import com.engine.salary.annotation.*; +import com.engine.salary.util.excel.ExcelProperty; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Set; + +/** + * 数据采集-累计专项附加扣除 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@SalaryTable(pageId = "a4f85287-e3f9-4275-adn9-7d06e54y67j8", tableType = WeaTableType.CHECKBOX, operates = { + @SalaryTableOperate(text = "查看明细") +}) +@Auth(page = "addUpDeduction") +public class AddUpDeductionDTO { + + /** + * 主键id + */ + @SalaryTableColumn(column = "id", display = false) + private Long id; + + /** + * 员工id + */ + private Long employeeId; + + /** + * 姓名 + */ + @ExcelProperty(index = 0) + @SalaryTableColumn(text = "姓名", width = "10%", column = "username") + @TableTitle(title = "姓名", dataIndex = "username", key = "username") + @I18n + private String username; + + /** + * 个税扣缴义务人 + */ + @ExcelProperty(index = 1) + @SalaryTableColumn(text = "个税扣缴义务人", width = "10%", column = "taxAgentName") + @TableTitle(title = "个税扣缴义务人", dataIndex = "taxAgentName", key = "taxAgentName") + private String taxAgentName; + + /** + * 个税扣缴义务人id + */ + private Long taxAgentId; + + /** + * 部门 + */ + @ExcelProperty(index = 2) + @SalaryTableColumn(text = "部门", width = "10%", column = "departmentName") + @TableTitle(title = "部门", dataIndex = "departmentName", key = "departmentName") + @I18n + private String departmentName; + + /** + * 手机号 + */ + @ExcelProperty(index = 3) + @SalaryTableColumn(text = "手机号", width = "10%", column = "mobile") + @TableTitle(title = "手机号", dataIndex = "mobile", key = "mobile") + private String mobile; + + /** + * 工号 + */ + @ExcelProperty(index = 4) + @SalaryTableColumn(text = "工号", width = "10%", column = "jobNum") + @TableTitle(title = "工号", dataIndex = "jobNum", key = "jobNum") + private String jobNum; + + /** + * 证件号码 + */ + @ExcelProperty(index = 5) + @SalaryTableColumn(text = "证件号码", width = "10%", column = "idNo") + @TableTitle(title = "证件号码", dataIndex = "idNo", key = "idNo") + private String idNo; + + /** + * 入职日期 + */ + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") + @ExcelProperty(index = 6, msg = "第7列,入职日期解析错误,标准格式应为yyyy-MM-dd,例如:2022-01-01") + @SalaryTableColumn(text = "入职日期", width = "10%", column = "hiredate") + @TableTitle(title = "入职日期", dataIndex = "hiredate", key = "hiredate") + private String hiredate; + + /** + * 累计子女教育 + */ + @ExcelProperty(index = 7, msg = "第8列,累计子女教育解析错误,请输入数字") + @SalaryTableColumn(text = "累计子女教育", width = "10%", column = "addUpChildEducation") + @TableTitle(title = "累计子女教育", dataIndex = "addUpChildEducation", key = "addUpChildEducation") + @Encrypt + private String addUpChildEducation; + + /** + * 累计继续教育 + */ + @ExcelProperty(index = 8, msg = "第9列,累计继续教育教育解析错误,请输入数字") + @SalaryTableColumn(text = "累计继续教育", width = "10%", column = "addUpContinuingEducation") + @TableTitle(title = "累计继续教育", dataIndex = "addUpContinuingEducation", key = "addUpContinuingEducation") + @Encrypt + private String addUpContinuingEducation; + + /** + * 累计住房贷款利息 + */ + @ExcelProperty(index = 9, msg = "第10列,累计住房贷款利息解析错误,请输入数字") + @SalaryTableColumn(text = "累计住房贷款利息", width = "10%", column = "addUpHousingLoanInterest") + @TableTitle(title = "累计住房贷款利息", dataIndex = "addUpHousingLoanInterest", key = "addUpHousingLoanInterest") + @Encrypt + private String addUpHousingLoanInterest; + + /** + * 累计住房租金 + */ + @ExcelProperty(index = 10, msg = "第11列,累计住房租金解析错误,请输入数字") + @SalaryTableColumn(text = "累计住房租金", width = "10%", column = "addUpHousingRent") + @TableTitle(title = "累计住房租金", dataIndex = "addUpHousingRent", key = "addUpHousingRent") + @Encrypt + private String addUpHousingRent; + + /** + * 累计赡养老人 + */ + @ExcelProperty(index = 11, msg = "第12列,累计赡养老人解析错误,请输入数字") + @SalaryTableColumn(text = "累计赡养老人", width = "10%", column = "addUpSupportElderly") + @TableTitle(title = "累计赡养老人", dataIndex = "addUpSupportElderly", key = "addUpSupportElderly") + @Encrypt + private String addUpSupportElderly; + + /** + * 累计大病医疗 + */ + @ExcelProperty(index = 12, msg = "第13列,累计大病医疗解析错误,请输入数字") + @SalaryTableColumn(text = "累计大病医疗", width = "10%", column = "addUpIllnessMedical") + @TableTitle(title = "累计大病医疗", dataIndex = "addUpIllnessMedical", key = "addUpIllnessMedical") + @Encrypt + private String addUpIllnessMedical; + + @ExcelProperty(index = 13, msg = "第14列,累计婴幼儿照护解析错误,请输入数字") + @SalaryTableColumn(text = "累计婴幼儿照护", width = "10%", column = "addUpInfantCare") + @TableTitle(title = "累计婴幼儿照护", dataIndex = "addUpInfantCare", key = "addUpInfantCare") + @Encrypt + private String addUpInfantCare; + + @SalaryTableColumn(text = "操作", width = "20%", column = "operate") + @TableTitle(title = "操作", dataIndex = "operate", key = "operate") + private Set opts; +} diff --git a/src/com/engine/salary/entity/datacollection/dto/AddUpDeductionRecordDTO.java b/src/com/engine/salary/entity/datacollection/dto/AddUpDeductionRecordDTO.java new file mode 100644 index 000000000..2c34eaef4 --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/dto/AddUpDeductionRecordDTO.java @@ -0,0 +1,131 @@ +package com.engine.salary.entity.datacollection.dto; + +import com.cloudstore.eccom.pc.table.WeaTableType; +import com.engine.salary.annotation.*; +import com.engine.salary.util.excel.ExcelProperty; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; +import java.util.Set; + + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//数据采集-累计专项附加扣除记录 +@SalaryTable(pageId = "a4f85287-3354-4275-adn9-7d06e54y6rj8", tableType = WeaTableType.CHECKBOX) +@Auth(page = "addUpDeduction") +public class AddUpDeductionRecordDTO { + + //主键id + @SalaryTableColumn(column = "id", display = false) + private Long id; + + //员工id + private Long employeeId; + + @ExcelProperty(index = 0) + @I18n + private String username; + + //申报月份 + @JsonFormat(pattern = "yyyy-MM", timezone = "GMT+8") + @SalaryTableColumn(text = "申报月份", width = "10%", column = "declareMonth", transmethod = "com.engine.salary.transmethod.TransMethod.timeToMoth") + @TableTitle(title = "申报月份", dataIndex = "declareMonth", key = "declareMonth") + @ExcelProperty(index = 1) + private Date declareMonth; + + //个税扣缴义务人 + @SalaryTableColumn(text = "个税扣缴义务人", width = "10%", column = "taxAgentName") + @TableTitle(title = "个税扣缴义务人", dataIndex = "taxAgentName", key = "taxAgentName") + @ExcelProperty(index = 2) + private String taxAgentName; + + /** + * 个税扣缴义务人id + */ + private Long taxAgentId; + + + //部门 + @SalaryTableColumn(text = "部门", width = "10%", column = "departmentName") + @TableTitle(title = "部门", dataIndex = "departmentName", key = "departmentName") + @ExcelProperty(index = 3) + @I18n + private String departmentName; + + //手机号 + @SalaryTableColumn(text = "手机号", width = "10%", column = "mobile") + @TableTitle(title = "手机号", dataIndex = "mobile", key = "mobile") + private String mobile; + + //工号 + @SalaryTableColumn(text = "工号", width = "10%", column = "jobNum") + @ExcelProperty(index = 4) + private String jobNum; + + /** + * 累计子女教育 + */ + @ExcelProperty(index = 5) + @SalaryTableColumn(text = "累计子女教育", width = "10%", column = "addUpChildEducation") + @TableTitle(title = "累计子女教育", dataIndex = "addUpChildEducation", key = "addUpChildEducation") + @Encrypt + private String addUpChildEducation; + + /** + * 累计继续教育 + */ + @ExcelProperty(index = 6) + @SalaryTableColumn(text = "累计继续教育", width = "10%", column = "addUpContinuingEducation") + @TableTitle(title = "累计继续教育", dataIndex = "addUpContinuingEducation", key = "addUpContinuingEducation") + @Encrypt + private String addUpContinuingEducation; + + /** + * 累计住房贷款利息 + */ + @ExcelProperty(index = 7) + @SalaryTableColumn(text = "累计住房贷款利息", width = "10%", column = "addUpHousingLoanInterest") + @TableTitle(title = "累计住房贷款利息", dataIndex = "addUpHousingLoanInterest", key = "addUpHousingLoanInterest") + @Encrypt + private String addUpHousingLoanInterest; + + /** + * 累计住房租金 + */ + @ExcelProperty(index = 8) + @SalaryTableColumn(text = "累计住房租金", width = "10%", column = "addUpHousingRent") + @TableTitle(title = "累计住房租金", dataIndex = "addUpHousingRent", key = "addUpHousingRent") + @Encrypt + private String addUpHousingRent; + + /** + * 累计赡养老人 + */ + @ExcelProperty(index = 9) + @SalaryTableColumn(text = "累计赡养老人", width = "10%", column = "addUpSupportElderly") + @TableTitle(title = "累计赡养老人", dataIndex = "addUpSupportElderly", key = "addUpSupportElderly") + @Encrypt + private String addUpSupportElderly; + + @ExcelProperty(index = 10) + @SalaryTableColumn(text = "累计大病医疗", width = "10%", column = "addUpIllnessMedical") + @TableTitle(title = "累计大病医疗", dataIndex = "addUpIllnessMedical", key = "addUpIllnessMedical") + @Encrypt + private String addUpIllnessMedical; + + @ExcelProperty(index = 11) + @SalaryTableColumn(text = "累计婴幼儿照护", width = "10%", column = "addUpInfantCare") + @TableTitle(title = "累计婴幼儿照护", dataIndex = "addUpInfantCare", key = "addUpInfantCare") + @Encrypt + private String addUpInfantCare; + + private Set opts; + +} diff --git a/src/com/engine/salary/entity/datacollection/dto/AddUpSituationDTO.java b/src/com/engine/salary/entity/datacollection/dto/AddUpSituationDTO.java new file mode 100644 index 000000000..e4aac1565 --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/dto/AddUpSituationDTO.java @@ -0,0 +1,222 @@ +package com.engine.salary.entity.datacollection.dto; + +import com.cloudstore.eccom.pc.table.WeaTableType; +import com.engine.salary.annotation.*; +import com.engine.salary.util.excel.ExcelProperty; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Set; + +/** + * 数据采集-累计情况表 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@SalaryTable(pageId = "a4f85287-e3f9-7841-adn9-7d06e54y6rj8", tableType = WeaTableType.CHECKBOX, operates = { + @SalaryTableOperate(text = "查看明细") +}) +@Auth(page = "addUpSituation") +public class AddUpSituationDTO { + //主键id + @JsonSerialize(using = ToStringSerializer.class) + @SalaryTableColumn(column = "id", display = false) + private Long id; + + //员工id + private Long employeeId; + + //年份 + private Integer year; + + //月份 + private Integer month; + + //姓名 + @SalaryTableColumn(text = "姓名", width = "10%", column = "username") + @TableTitle(title = "姓名", dataIndex = "username", key = "username") + @ExcelProperty(index = 0) + @I18n + private String username; +// +// @SalaryTableColumn(text = "申报月份", width = "10%", column = "username") +// private String taxYearMonth; + + //个税扣缴义务人 + @SalaryTableColumn(text = "个税扣缴义务人", width = "10%", column = "taxAgentName") + @TableTitle(title = "个税扣缴义务人", dataIndex = "taxAgentName", key = "taxAgentName") + @ExcelProperty(index = 1) + private String taxAgentName; + + /** + * 个税扣缴义务人id + */ + private Long taxAgentId; + + //部门 + @SalaryTableColumn(text = "部门", width = "10%", column = "departmentName") + @TableTitle(title = "部门", dataIndex = "departmentName", key = "departmentName") + @ExcelProperty(index = 2) + @I18n + private String departmentName; + + //手机号 + @SalaryTableColumn(text = "手机号", width = "10%", column = "mobile") + @TableTitle(title = "手机号", dataIndex = "mobile", key = "mobile") + @ExcelProperty(index = 3) + private String mobile; + + //工号 + @SalaryTableColumn(text = "工号", width = "10%", column = "jobNum") + @TableTitle(title = "工号", dataIndex = "jobNum", key = "jobNum") + @ExcelProperty(index = 4) + private String jobNum; + + //证件号码 + @SalaryTableColumn(text = "证件号码", width = "10%", column = "idNo") + @TableTitle(title = "证件号码", dataIndex = "idNo", key = "idNo") + @ExcelProperty(index = 5) + private String idNo; + + //入职日期 + @SalaryTableColumn(text = "入职日期", width = "10%", column = "hiredate") + @TableTitle(title = "入职日期", dataIndex = "hiredate", key = "hiredate") + @ExcelProperty(index = 6) + private String hiredate; + + //累计收入额 + @SalaryTableColumn(text = "累计收入额", width = "10%", column = "addUpIncome") + @TableTitle(title = "累计收入额", dataIndex = "addUpIncome", key = "addUpIncome") + @ExcelProperty(index = 7) + @Encrypt + private String addUpIncome; + + //累计减除费用 + @SalaryTableColumn(text = "累计减除费用", width = "10%", column = "addUpSubtraction") + @TableTitle(title = "累计减除费用", dataIndex = "addUpSubtraction", key = "addUpSubtraction") + @ExcelProperty(index = 8) + @Encrypt + private String addUpSubtraction; + + //累计社保个人合计 + @SalaryTableColumn(text = "累计社保个人合计", width = "10%", column = "addUpSocialSecurityTotal") + @TableTitle(title = "累计社保个人合计", dataIndex = "addUpSocialSecurityTotal", key = "addUpSocialSecurityTotal") + @ExcelProperty(index = 9) + @Encrypt + private String addUpSocialSecurityTotal; + + //累计公积金个人合计 + @SalaryTableColumn(text = "累计公积金个人合计", width = "10%", column = "addUpAccumulationFundTotal") + @TableTitle(title = "累计公积金个人合计", dataIndex = "addUpAccumulationFundTotal", key = "addUpAccumulationFundTotal") + @ExcelProperty(index = 10) + @Encrypt + private String addUpAccumulationFundTotal; + + //累计子女教育 + @SalaryTableColumn(text = "累计子女教育", width = "10%", column = "addUpChildEducation") + @TableTitle(title = "累计子女教育", dataIndex = "addUpChildEducation", key = "addUpChildEducation") + @ExcelProperty(index = 11) + @Encrypt + private String addUpChildEducation; + + //累计继续教育 + @SalaryTableColumn(text = "累计继续教育", width = "10%", column = "addUpContinuingEducation") + @TableTitle(title = "累计继续教育", dataIndex = "addUpContinuingEducation", key = "addUpContinuingEducation") + @ExcelProperty(index = 12) + @Encrypt + private String addUpContinuingEducation; + + //累计住房贷款利息 + @SalaryTableColumn(text = "累计住房贷款利息", width = "10%", column = "addUpHousingLoanInterest") + @TableTitle(title = "累计住房贷款利息", dataIndex = "addUpHousingLoanInterest", key = "addUpHousingLoanInterest") + @ExcelProperty(index = 13) + @Encrypt + private String addUpHousingLoanInterest; + + //累计住房租金 + @SalaryTableColumn(text = "累计住房租金", width = "10%", column = "addUpHousingRent") + @TableTitle(title = "累计住房租金", dataIndex = "addUpHousingRent", key = "addUpHousingRent") + @ExcelProperty(index = 14) + @Encrypt + private String addUpHousingRent; + + //累计赡养老人 + @SalaryTableColumn(text = "累计赡养老人", width = "10%", column = "addUpSupportElderly") + @TableTitle(title = "累计赡养老人", dataIndex = "addUpSupportElderly", key = "addUpSupportElderly") + @ExcelProperty(index = 15) + @Encrypt + private String addUpSupportElderly; + + //累计大病医疗 + @SalaryTableColumn(text = "累计大病医疗", width = "10%", column = "addUpIllnessMedical") + @TableTitle(title = "累计大病医疗", dataIndex = "addUpIllnessMedical", key = "addUpIllnessMedical") + @ExcelProperty(index = 16) + @Encrypt + private String addUpIllnessMedical; + + //累计企业(职业)年金及其他福利 + @SalaryTableColumn(text = "累计企业(职业)年金及其他福利", width = "10%", column = "addUpEnterpriseAndOther") + @TableTitle(title = "累计企业(职业)年金及其他福利", dataIndex = "addUpEnterpriseAndOther", key = "addUpEnterpriseAndOther") + @ExcelProperty(index = 17) + @Encrypt + private String addUpEnterpriseAndOther; + + //累计其他扣除 + @SalaryTableColumn(text = "累计其他扣除", width = "10%", column = "addUpOtherDeduction") + @TableTitle(title = "累计其他扣除", dataIndex = "addUpOtherDeduction", key = "addUpOtherDeduction") + @ExcelProperty(index = 18) + @Encrypt + private String addUpOtherDeduction; + + //累计免税收入 + @SalaryTableColumn(text = "累计免税收入", width = "10%", column = "addUpTaxExemptIncome") + @TableTitle(title = "累计免税收入", dataIndex = "addUpTaxExemptIncome", key = "addUpTaxExemptIncome") + @ExcelProperty(index = 19) + @Encrypt + private String addUpTaxExemptIncome; + + //累计准予扣除的捐赠额 + @SalaryTableColumn(text = "累计准予扣除的捐赠额", width = "10%", column = "addUpAllowedDonation") + @TableTitle(title = "累计准予扣除的捐赠额", dataIndex = "addUpAllowedDonation", key = "addUpAllowedDonation") + @ExcelProperty(index = 20) + @Encrypt + private String addUpAllowedDonation; + + //累计减免税额 + @SalaryTableColumn(text = "累计减免税额", width = "10%", column = "addUpTaxSavings") + @TableTitle(title = "累计减免税额", dataIndex = "addUpTaxSavings", key = "addUpTaxSavings") + @ExcelProperty(index = 21) + @Encrypt + private String addUpTaxSavings; + + //累计已预扣预缴税额 + @SalaryTableColumn(text = "累计已预扣预缴税额", width = "10%", column = "addUpAdvanceTax") + @TableTitle(title = "累计已预扣预缴税额", dataIndex = "addUpAdvanceTax", key = "addUpAdvanceTax") + @ExcelProperty(index = 22) + @Encrypt + private String addUpAdvanceTax; + + //累计婴幼儿照护 + @ExcelProperty(index = 23) + @SalaryTableColumn(text = "累计婴幼儿照护", width = "10%", column = "addUpInfantCare") + @TableTitle(title = "累计婴幼儿照护", dataIndex = "addUpInfantCare", key = "addUpInfantCare") + @Encrypt + private String addUpInfantCare; + + //累计个人养老金 + @ExcelProperty(index = 24) + @SalaryTableColumn(text = "累计个人养老金", width = "10%", column = "addUpPrivatePension") + @TableTitle(title = "累计个人养老金", dataIndex = "addUpPrivatePension", key = "addUpPrivatePension") + @Encrypt + private String addUpPrivatePension; + + @SalaryTableColumn(text = "操作", width = "20%", column = "operate") + @TableTitle(title = "操作", dataIndex = "operate", key = "operate") + private Set opts; +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/datacollection/dto/AddUpSituationRecordDTO.java b/src/com/engine/salary/entity/datacollection/dto/AddUpSituationRecordDTO.java new file mode 100644 index 000000000..5a9686b89 --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/dto/AddUpSituationRecordDTO.java @@ -0,0 +1,177 @@ +package com.engine.salary.entity.datacollection.dto; + +import com.cloudstore.eccom.pc.table.WeaTableType; +import com.engine.salary.annotation.*; +import com.engine.salary.util.excel.ExcelProperty; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; + + +/** + * 数据采集-累计情况记录列表 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@SalaryTable(pageId = "a5f85287-3354-4275-adn9-7d06e54y6rj8",tableType = WeaTableType.CHECKBOX) +@Auth(page = "addUpSituation") +public class AddUpSituationRecordDTO { + + @SalaryTableColumn(column = "id", display = false) + private Long id; + + @ExcelProperty(index = 0) + private String username; + + @JsonFormat(pattern = "yyyy-MM", timezone = "GMT+8") + @SalaryTableColumn(text = "税款所属期", width = "10%", column = "taxYearMonth", transmethod = "com.engine.salary.transmethod.TransMethod.timeToMoth") + @TableTitle(title = "税款所属期", dataIndex = "taxYearMonth", key = "taxYearMonth") + @ExcelProperty(index = 1) + private Date taxYearMonth; + + private Long employeeId; + + @SalaryTableColumn(text = "个税扣缴义务人", width = "10%", column = "taxAgentName") + @TableTitle(title = "个税扣缴义务人", dataIndex = "taxAgentName", key = "taxAgentName") + @ExcelProperty(index = 2) + private String taxAgentName; + + /** + * 个税扣缴义务人id + */ + private Long taxAgentId; + + @SalaryTableColumn(text = "部门", width = "10%", column = "departmentName") + @TableTitle(title = "部门", dataIndex = "departmentName", key = "departmentName") + @ExcelProperty(index = 3) + private String departmentName; + + @SalaryTableColumn(text = "手机号", width = "10%", column = "mobile") + @TableTitle(title = "手机号", dataIndex = "mobile", key = "mobile") + @ExcelProperty(index = 4) + private String mobile; + + @SalaryTableColumn(text = "工号", width = "10%", column = "jobNum") + @TableTitle(title = "工号", dataIndex = "jobNum", key = "jobNum") + @ExcelProperty(index = 5) + private String jobNum; + + @SalaryTableColumn(text = "累计收入额", width = "10%", column = "addUpIncome") + @TableTitle(title = "累计收入额", dataIndex = "addUpIncome", key = "addUpIncome") + @ExcelProperty(index = 6) + @Encrypt + private String addUpIncome; + + @SalaryTableColumn(text = "累计减除费用", width = "10%", column = "addUpSubtraction") + @TableTitle(title = "累计减除费用", dataIndex = "addUpSubtraction", key = "addUpSubtraction") + @ExcelProperty(index = 7) + @Encrypt + private String addUpSubtraction; + + @SalaryTableColumn(text = "累计社保个人合计", width = "10%", column = "addUpSocialSecurityTotal") + @TableTitle(title = "累计社保个人合计", dataIndex = "addUpSocialSecurityTotal", key = "addUpSocialSecurityTotal") + @ExcelProperty(index = 8) + @Encrypt + private String addUpSocialSecurityTotal; + + @SalaryTableColumn(text = "累计公积金个人合计", width = "10%", column = "addUpAccumulationFundTotal") + @TableTitle(title = "累计公积金个人合计", dataIndex = "addUpAccumulationFundTotal", key = "addUpAccumulationFundTotal") + @ExcelProperty(index = 9) + @Encrypt + private String addUpAccumulationFundTotal; + + @ExcelProperty(index = 10) + @SalaryTableColumn(text = "累计子女教育", width = "10%", column = "addUpChildEducation") + @TableTitle(title = "累计子女教育", dataIndex = "addUpChildEducation", key = "addUpChildEducation") + @Encrypt + private String addUpChildEducation; + + @ExcelProperty(index = 11) + @SalaryTableColumn(text = "累计继续教育", width = "10%", column = "addUpContinuingEducation") + @TableTitle(title = "累计继续教育", dataIndex = "addUpContinuingEducation", key = "addUpContinuingEducation") + @Encrypt + private String addUpContinuingEducation; + + @ExcelProperty(index = 12) + @SalaryTableColumn(text = "累计住房贷款利息", width = "10%", column = "addUpHousingLoanInterest") + @TableTitle(title = "累计住房贷款利息", dataIndex = "addUpHousingLoanInterest", key = "addUpHousingLoanInterest") + @Encrypt + private String addUpHousingLoanInterest; + + @ExcelProperty(index = 13) + @SalaryTableColumn(text = "累计住房租金", width = "10%", column = "addUpHousingRent") + @TableTitle(title = "累计住房租金", dataIndex = "addUpHousingRent", key = "addUpHousingRent") + @Encrypt + private String addUpHousingRent; + + @ExcelProperty(index = 14) + @SalaryTableColumn(text = "累计赡养老人", width = "10%", column = "addUpSupportElderly") + @TableTitle(title = "累计赡养老人", dataIndex = "addUpSupportElderly", key = "addUpSupportElderly") + @Encrypt + private String addUpSupportElderly; + + @ExcelProperty(index = 15) + @SalaryTableColumn(text = "累计大病医疗", width = "10%", column = "addUpIllnessMedical") + @TableTitle(title = "累计大病医疗", dataIndex = "addUpIllnessMedical", key = "addUpIllnessMedical") + @Encrypt + private String addUpIllnessMedical; + + @ExcelProperty(index = 16) + @SalaryTableColumn(text = "累计企业(职业)年金及其他福利", width = "10%", column = "addUpEnterpriseAndOther") + @TableTitle(title = "累计企业(职业)年金及其他福利", dataIndex = "addUpEnterpriseAndOther", key = "addUpEnterpriseAndOther") + @Encrypt + private String addUpEnterpriseAndOther; + + @ExcelProperty(index = 17) + @SalaryTableColumn(text = "累计其他扣除", width = "10%", column = "addUpOtherDeduction") + @TableTitle(title = "累计其他扣除", dataIndex = "addUpOtherDeduction", key = "addUpOtherDeduction") + @Encrypt + private String addUpOtherDeduction; + + @ExcelProperty(index = 18) + @SalaryTableColumn(text = "累计免税收入", width = "10%", column = "addUpTaxExemptIncome") + @TableTitle(title = "累计免税收入", dataIndex = "addUpTaxExemptIncome", key = "addUpTaxExemptIncome") + @Encrypt + private String addUpTaxExemptIncome; + + @ExcelProperty(index = 19) + @SalaryTableColumn(text = "累计准予扣除的捐赠额", width = "10%", column = "addUpAllowedDonation") + @TableTitle(title = "累计准予扣除的捐赠额", dataIndex = "addUpAllowedDonation", key = "addUpAllowedDonation") + @Encrypt + private String addUpAllowedDonation; + + @ExcelProperty(index = 20) + @SalaryTableColumn(text = "累计减免税额", width = "10%", column = "addUpTaxSavings") + @TableTitle(title = "累计减免税额", dataIndex = "addUpTaxSavings", key = "addUpTaxSavings") + @Encrypt + private String addUpTaxSavings; + + @ExcelProperty(index = 21) + @SalaryTableColumn(text = "累计已预扣预缴税额", width = "10%", column = "addUpAdvanceTax") + @TableTitle(title = "累计已预扣预缴税额", dataIndex = "addUpAdvanceTax", key = "addUpAdvanceTax") + @Encrypt + private String addUpAdvanceTax; + + @ExcelProperty(index = 22) + @SalaryTableColumn(text = "累计婴幼儿照护", width = "10%", column = "addUpInfantCare") + @TableTitle(title = "累计婴幼儿照护", dataIndex = "addUpInfantCare", key = "addUpInfantCare") + @Encrypt + private String addUpInfantCare; + + @ExcelProperty(index = 23) + @SalaryTableColumn(text = "累计个人养老金", width = "10%", column = "addUpPrivatePension") + @TableTitle(title = "累计个人养老金", dataIndex = "addUpPrivatePension", key = "addUpPrivatePension") + @Encrypt + private String addUpPrivatePension; +} diff --git a/src/com/engine/salary/entity/datacollection/dto/AttendQuoteDataBaseDTO.java b/src/com/engine/salary/entity/datacollection/dto/AttendQuoteDataBaseDTO.java new file mode 100644 index 000000000..839c3f779 --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/dto/AttendQuoteDataBaseDTO.java @@ -0,0 +1,61 @@ +package com.engine.salary.entity.datacollection.dto; + +import com.engine.salary.annotation.I18n; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Description: 数据采集-考勤引用数据 + * @Author: wangxiangzhong + * @Date: 2021-11-17 14:36 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class AttendQuoteDataBaseDTO { + + /** + * 主键id + */ + private Long id; + + /** + * 人员信息表的主键id + */ + private Long employeeId; + + /** + * 考勤引用表的主键id + */ + private Long attendQuoteId; + + /** + * 姓名 + */ + @I18n + private String username; + + /** + * 部门 + */ + @I18n + private String departmentName; + + /** + * 手机号 + */ + private String mobile; + + /** + * 工号 + */ + private String jobNum; + + /** + * 证件号码 + */ + private String idNo; +} diff --git a/src/com/engine/salary/entity/datacollection/dto/AttendQuoteDataDTO.java b/src/com/engine/salary/entity/datacollection/dto/AttendQuoteDataDTO.java new file mode 100644 index 000000000..ebc9b4c30 --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/dto/AttendQuoteDataDTO.java @@ -0,0 +1,29 @@ +package com.engine.salary.entity.datacollection.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * 数据采集-考勤模块设置字段 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class AttendQuoteDataDTO { + + //人员信息表的主键id + private Long employeeId; + + //考勤引用数据值 + private List dataValues; +} diff --git a/src/com/engine/salary/entity/datacollection/dto/AttendQuoteDataValueDTO.java b/src/com/engine/salary/entity/datacollection/dto/AttendQuoteDataValueDTO.java new file mode 100644 index 000000000..c77c6ea5a --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/dto/AttendQuoteDataValueDTO.java @@ -0,0 +1,27 @@ +package com.engine.salary.entity.datacollection.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 考勤引用数据值 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class AttendQuoteDataValueDTO { + + //考勤字段的主键id + private Long attendQuoteFieldId; + + //值 + private String dataValue; +} diff --git a/src/com/engine/salary/entity/datacollection/dto/AttendQuoteFieldFormDTO.java b/src/com/engine/salary/entity/datacollection/dto/AttendQuoteFieldFormDTO.java new file mode 100644 index 000000000..67885b12c --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/dto/AttendQuoteFieldFormDTO.java @@ -0,0 +1,40 @@ +package com.engine.salary.entity.datacollection.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 数据采集-考勤引用字段表单 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class AttendQuoteFieldFormDTO { + + //主键id") + private Long id; + + //字段名称") + private String fieldName; + + //字段类型。1:数值、2:文本") + private Integer fieldType; + + //是否启用。0:否、1:是") + private Integer enableStatus; + + //备注") + private String description; + +// private List getFieldTypeOptions() { +// return Arrays.stream(AttendQuoteFieldTypeEnum.values()).map(m->new WeaFormOption(m.name(), SalaryI18nUtil.getI18nLabel(TenantContext.getCurrentTenantKey(), UserContext.getCurrentEmployeeId(), m.getLabelId(), m.getDefaultLabel()))).collect(Collectors.toList()); +// } +} diff --git a/src/com/engine/salary/entity/datacollection/dto/AttendQuoteFieldListDTO.java b/src/com/engine/salary/entity/datacollection/dto/AttendQuoteFieldListDTO.java new file mode 100644 index 000000000..2dd6d04b1 --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/dto/AttendQuoteFieldListDTO.java @@ -0,0 +1,63 @@ +package com.engine.salary.entity.datacollection.dto; + +import com.cloudstore.eccom.pc.table.WeaTableType; +import com.engine.salary.annotation.SalaryTable; +import com.engine.salary.annotation.SalaryTableColumn; +import com.engine.salary.annotation.SalaryTableOperate; +import com.engine.salary.annotation.TableTitle; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 数据采集-考勤引用字段列表 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@SalaryTable(pageId = "b4f85287-e3f9-4275-adn9-7d06e54y6rj8", tableType = WeaTableType.CHECKBOX, operates = { + @SalaryTableOperate(text = "查看明细") +}) +public class AttendQuoteFieldListDTO { + //主键id + @JsonSerialize(using = ToStringSerializer.class) +// @SalaryTableColumn(column = "id", display = false) +// @TableTitle(title = "id",dataIndex = "id",key = "id") + private Long id; + + @SalaryTableColumn(text = "字段名称", width = "10%", column = "fieldName") + @TableTitle(title = "字段名称",dataIndex = "fieldName",key = "fieldName") + private String fieldName; + + //来源。1:自定义、2:考勤模块 + @SalaryTableColumn(text = "来源", width = "10%", column = "sourceType",transmethod = "com.engine.salary.transmethod.TransMethod.fieldSourceType") + @TableTitle(title = "来源",dataIndex = "sourceType",key = "sourceType") + private String sourceType; + + //来源。1:自定义、2:考勤模块 + private String sourceTypeValue; + + //字段类型。1:数值、2:文本 + @SalaryTableColumn(text = "类型", width = "10%", column = "fieldType",transmethod = "com.engine.salary.transmethod.TransMethod.fieldType") + @TableTitle(title = "类型",dataIndex = "fieldType",key = "fieldType") + private String fieldType; + + //是否启用。0:否、1:是 + @SalaryTableColumn(text = "是否启用", width = "10%", column = "enableStatus") + @TableTitle(title = "是否启用",dataIndex = "enableStatus",key = "enableStatus") + private Integer enableStatus; + + //备注 + @SalaryTableColumn(text = "备注", width = "10%", column = "description") + @TableTitle(title = "备注",dataIndex = "description",key = "description") + private String description; +} diff --git a/src/com/engine/salary/entity/datacollection/dto/AttendQuoteFieldSettingFieldListDTO.java b/src/com/engine/salary/entity/datacollection/dto/AttendQuoteFieldSettingFieldListDTO.java new file mode 100644 index 000000000..728e65840 --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/dto/AttendQuoteFieldSettingFieldListDTO.java @@ -0,0 +1,33 @@ +package com.engine.salary.entity.datacollection.dto; + +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 数据采集-考勤引用字段设置字段列表 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class AttendQuoteFieldSettingFieldListDTO { + + //字段的主键id + @JsonSerialize(using = ToStringSerializer.class) + private Long id; + + //字段名称 + private String name; + + //是否选中 + private Boolean checked; +} diff --git a/src/com/engine/salary/entity/datacollection/dto/AttendQuoteFieldSettingListDTO.java b/src/com/engine/salary/entity/datacollection/dto/AttendQuoteFieldSettingListDTO.java new file mode 100644 index 000000000..1cfcb4c6c --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/dto/AttendQuoteFieldSettingListDTO.java @@ -0,0 +1,32 @@ +package com.engine.salary.entity.datacollection.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * 数据采集-考勤引用字段设置列表 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class AttendQuoteFieldSettingListDTO { + + //字段组id + private String groupId; + + //字段组名称 + private String groupName; + + //字段列表") + private List items; +} diff --git a/src/com/engine/salary/entity/datacollection/dto/AttendQuoteListDTO.java b/src/com/engine/salary/entity/datacollection/dto/AttendQuoteListDTO.java new file mode 100644 index 000000000..f5c6fce5f --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/dto/AttendQuoteListDTO.java @@ -0,0 +1,84 @@ +package com.engine.salary.entity.datacollection.dto; + +import com.engine.salary.annotation.*; +import com.engine.salary.enums.auth.AuthCheckTypeEnum; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; +import java.util.Set; + +/** + * 数据采集-考勤引用列表 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@SalaryTable(pageId = "a4f852o1-e3f9-7841-adn9-7d06e54y6rj8", operates = { + @SalaryTableOperate(text = "查看", index = "0"), + @SalaryTableOperate(text = "删除", index = "1") +}) +@Auth(page = "attendQuote",checkType = AuthCheckTypeEnum.SOB) +public class AttendQuoteListDTO { + + @SalaryTableColumn(column = "id", display = false) + @JsonSerialize(using = ToStringSerializer.class) + private Long id; + + @SalaryTableColumn(text = "薪资所属月", width = "10%", column = "salaryYearMonth", transmethod = "com.engine.salary.transmethod.TransMethod.timeToMoth") + @JsonFormat(pattern = "yyyy-MM", timezone = "GMT+8") + @TableTitle(title = "薪资所属月", dataIndex = "salaryYearMonth", key = "salaryYearMonth") + private Date salaryYearMonth; + + @SalaryTableColumn(text = "关联账套", width = "10%", column = "salarySobName") + @TableTitle(title = "关联账套", dataIndex = "salarySobName", key = "salarySobName") + private String salarySobName; + + @SalaryTableColumn(text = "考勤周期", width = "10%", column = "attendCycle") + @TableTitle(title = "考勤周期", dataIndex = "attendCycle", key = "attendCycle") + private String attendCycle; + + @SalaryTableColumn(text = "来源", width = "10%", column = "sourceType") + @TableTitle(title = "来源", dataIndex = "sourceType", key = "sourceType") + private String sourceType; + + @SalaryTableColumn(text = "薪资周期", width = "10%", column = "salaryCycle") + @TableTitle(title = "薪资周期", dataIndex = "salaryCycle", key = "salaryCycle") + private String salaryCycle; + + @SalaryTableColumn(text = "操作人", width = "10%", column = "creator") + @TableTitle(title = "操作人", dataIndex = "creator", key = "creator") + private String creator; + + @SalaryTableColumn(text = "备注", width = "10%", column = "description") + @TableTitle(title = "备注", dataIndex = "description", key = "description") + private String description; + + /** + * 薪资核算状态。0:未核算、1:已核算 + */ + private Integer salaryAccountingStatus; + + /** + * 能否删除 + */ + private Boolean canDelete; + + /** + * 薪资账套id + */ + private Long salarySobId; + + private Set opts; +} diff --git a/src/com/engine/salary/entity/datacollection/dto/OtherDeductionListDTO.java b/src/com/engine/salary/entity/datacollection/dto/OtherDeductionListDTO.java new file mode 100644 index 000000000..a3c68530c --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/dto/OtherDeductionListDTO.java @@ -0,0 +1,128 @@ +package com.engine.salary.entity.datacollection.dto; + +import com.cloudstore.eccom.pc.table.WeaTableType; +import com.engine.salary.annotation.*; +import com.engine.salary.enums.auth.AuthCheckTypeEnum; +import com.engine.salary.util.excel.ExcelProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Set; + +/** + * 数据采集-其他免税扣除列表 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@SalaryTable(pageId = "a4f85287-e3f9-6612-adn9-7d06e54y6rj8", tableType = WeaTableType.CHECKBOX, operates = { + @SalaryTableOperate(text = "查看明细") +}) +@Auth(page = "otherDeduction", checkType = AuthCheckTypeEnum.TAX_EMP) +public class OtherDeductionListDTO { + + + //主键id + @SalaryTableColumn(column = "id", display = false) + private Long id; + + //员工id + private Long employeeId; + + //姓名 + @SalaryTableColumn(text = "姓名", width = "10%", column = "username") + @TableTitle(title = "姓名", dataIndex = "username", key = "username") + @ExcelProperty(index = 0) + @I18n + private String username; + + //个税扣缴义务人 + @SalaryTableColumn(text = "个税扣缴义务人", width = "10%", column = "taxAgentName") + @TableTitle(title = "个税扣缴义务人", dataIndex = "taxAgentName", key = "taxAgentName") + @ExcelProperty(index = 1) + private String taxAgentName; + + /** + * 个税扣缴义务人id + */ + private Long taxAgentId; + + //部门 + @SalaryTableColumn(text = "部门", width = "10%", column = "departmentName") + @TableTitle(title = "部门", dataIndex = "departmentName", key = "departmentName") + @ExcelProperty(index = 2) + @I18n + private String departmentName; + + //手机号 + @SalaryTableColumn(text = "手机号", width = "10%", column = "mobile") + @TableTitle(title = "手机号", dataIndex = "mobile", key = "mobile") + @ExcelProperty(index = 3) + private String mobile; + + //工号 + @SalaryTableColumn(text = "工号", width = "10%", column = "jobNum") + @TableTitle(title = "工号", dataIndex = "jobNum", key = "jobNum") + @ExcelProperty(index = 4) + private String jobNum; + + //证件号码 + @SalaryTableColumn(text = "证件号码", width = "10%", column = "idNo") + @TableTitle(title = "证件号码", dataIndex = "idNo", key = "idNo") + @ExcelProperty(index = 5) + private String idNo; + + //入职日期 + @ExcelProperty(index = 6) + @SalaryTableColumn(text = "入职日期", width = "10%", column = "hiredate") + @TableTitle(title = "入职日期", dataIndex = "hiredate", key = "hiredate") + private String hiredate; + + //商业健康保险 + @ExcelProperty(index = 7) + @SalaryTableColumn(text = "商业健康保险", width = "10%", column = "businessHealthyInsurance") + @TableTitle(title = "商业健康保险", dataIndex = "businessHealthyInsurance", key = "businessHealthyInsurance") + @Encrypt + private String businessHealthyInsurance; + + //税延养老保险 + @ExcelProperty(index = 8) + @SalaryTableColumn(text = "税延养老保险", width = "10%", column = "taxDelayEndowmentInsurance") + @TableTitle(title = "税延养老保险", dataIndex = "taxDelayEndowmentInsurance", key = "taxDelayEndowmentInsurance") + @Encrypt + private String taxDelayEndowmentInsurance; + + //其他 + @ExcelProperty(index = 9) + @SalaryTableColumn(text = "其他", width = "10%", column = "otherDeduction") + @TableTitle(title = "其他", dataIndex = "otherDeduction", key = "otherDeduction") + @Encrypt + private String otherDeduction; + + //准予扣除的捐赠额 + @ExcelProperty(index = 10) + @SalaryTableColumn(text = "准予扣除的捐赠额", width = "10%", column = "deductionAllowedDonation") + @TableTitle(title = "准予扣除的捐赠额", dataIndex = "deductionAllowedDonation", key = "deductionAllowedDonation") + @Encrypt + private String deductionAllowedDonation; + + @ExcelProperty(index = 11) + @SalaryTableColumn(text = "个人养老金", width = "10%", column = "privatePension") + @TableTitle(title = "个人养老金", dataIndex = "privatePension", key = "privatePension") + @Encrypt + private String privatePension; + + @SalaryTableColumn(text = "操作", width = "20%", column = "operate") + @TableTitle(title = "操作", dataIndex = "operate", key = "operate") + private String operate; + + private Set opts; +} diff --git a/src/com/engine/salary/entity/datacollection/dto/OtherDeductionRecordDTO.java b/src/com/engine/salary/entity/datacollection/dto/OtherDeductionRecordDTO.java new file mode 100644 index 000000000..5cdbec166 --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/dto/OtherDeductionRecordDTO.java @@ -0,0 +1,101 @@ +package com.engine.salary.entity.datacollection.dto; + +import com.cloudstore.eccom.pc.table.WeaTableType; +import com.engine.salary.annotation.Encrypt; +import com.engine.salary.annotation.SalaryTable; +import com.engine.salary.annotation.SalaryTableColumn; +import com.engine.salary.annotation.TableTitle; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; + +/** + * 其他免税扣除记录列表 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@SalaryTable(pageId = "a4f85287-e3f9-6612-adn9-7d98e54y6rj8", tableType = WeaTableType.CHECKBOX) +public class OtherDeductionRecordDTO { + + //主键id + @SalaryTableColumn(column = "id", display = false) + private Long id; + + //申报月份 + @JsonFormat(pattern = "yyyy-MM", timezone = "GMT+8") + @SalaryTableColumn(text = "申报月份", width = "10%", column = "declareMonth", transmethod = "com.engine.salary.transmethod.TransMethod.timeToMoth") + @TableTitle(title = "申报月份", dataIndex = "declareMonth", key = "declareMonth") + private Date declareMonth; + + //员工id + private Long employeeId; + + private String username; + + //个税扣缴义务人 + @SalaryTableColumn(text = "个税扣缴义务人", width = "10%", column = "taxAgentName") + @TableTitle(title = "个税扣缴义务人", dataIndex = "taxAgentName", key = "taxAgentName") + private String taxAgentName; + /** + * 个税扣缴义务人id + */ + private Long taxAgentId; + + + //部门 + @SalaryTableColumn(text = "部门", width = "10%", column = "departmentName") + @TableTitle(title = "部门", dataIndex = "departmentName", key = "departmentName") + private String departmentName; + + //手机号 + @SalaryTableColumn(text = "手机号", width = "10%", column = "mobile") + @TableTitle(title = "手机号", dataIndex = "mobile", key = "mobile") + private String mobile; + + private String idNo; + + //工号 + @SalaryTableColumn(text = "工号", width = "10%", column = "jobNum") + @TableTitle(title = "工号", dataIndex = "jobNum", key = "jobNum") + private String jobNum; + + //商业健康保险 + @SalaryTableColumn(text = "商业健康保险", width = "10%", column = "businessHealthyInsurance") + @TableTitle(title = "商业健康保险", dataIndex = "businessHealthyInsurance", key = "businessHealthyInsurance") + @Encrypt + private String businessHealthyInsurance; + + //税延养老保险 + @SalaryTableColumn(text = "税延养老保险", width = "10%", column = "taxDelayEndowmentInsurance") + @TableTitle(title = "税延养老保险", dataIndex = "taxDelayEndowmentInsurance", key = "taxDelayEndowmentInsurance") + @Encrypt + private String taxDelayEndowmentInsurance; + + //其他 + @SalaryTableColumn(text = "其他", width = "10%", column = "otherDeduction") + @TableTitle(title = "其他", dataIndex = "otherDeduction", key = "otherDeduction") + @Encrypt + private String otherDeduction; + + //准予扣除的捐赠额 + @SalaryTableColumn(text = "准予扣除的捐赠额", width = "10%", column = "deductionAllowedDonation") + @TableTitle(title = "准予扣除的捐赠额", dataIndex = "deductionAllowedDonation", key = "deductionAllowedDonation") + @Encrypt + private String deductionAllowedDonation; + + @SalaryTableColumn(text = "个人养老金", width = "10%", column = "privatePension") + @TableTitle(title = "个人养老金", dataIndex = "privatePension", key = "privatePension") + @Encrypt + private String privatePension; +} diff --git a/src/com/engine/salary/entity/datacollection/dto/SpecialAddDeductionListDTO.java b/src/com/engine/salary/entity/datacollection/dto/SpecialAddDeductionListDTO.java new file mode 100644 index 000000000..5a993906f --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/dto/SpecialAddDeductionListDTO.java @@ -0,0 +1,140 @@ +package com.engine.salary.entity.datacollection.dto; + +import com.cloudstore.eccom.pc.table.WeaTableType; +import com.engine.salary.annotation.*; +import com.engine.salary.util.excel.ExcelProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Set; + +/** + * 数据采集-专项附加扣除列表 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author lfc + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@SalaryTable(pageId = "a4f85287-e3f9-6612-adn9-7d06e54y6rj8", tableType = WeaTableType.CHECKBOX, operates = { + @SalaryTableOperate(text = "查看明细") +}) +@Auth(page = "specialAddDeduction") +public class SpecialAddDeductionListDTO { + + + //主键id + @SalaryTableColumn(column = "id", display = false) + private Long id; + + //员工id + private Long employeeId; + + //姓名 + @SalaryTableColumn(text = "姓名", width = "10%", column = "username") + @TableTitle(title = "姓名", dataIndex = "username", key = "username") + @ExcelProperty(index = 0) + @I18n + private String username; + + //个税扣缴义务人 + @SalaryTableColumn(text = "个税扣缴义务人", width = "10%", column = "taxAgentName") + @TableTitle(title = "个税扣缴义务人", dataIndex = "taxAgentName", key = "taxAgentName") + @ExcelProperty(index = 1) + private String taxAgentName; + + /** + * 个税扣缴义务人id + */ + private Long taxAgentId; + + //部门 + @SalaryTableColumn(text = "部门", width = "10%", column = "departmentName") + @TableTitle(title = "部门", dataIndex = "departmentName", key = "departmentName") + @ExcelProperty(index = 2) + @I18n + private String departmentName; + + //手机号 + @SalaryTableColumn(text = "手机号", width = "10%", column = "mobile") + @TableTitle(title = "手机号", dataIndex = "mobile", key = "mobile") + @ExcelProperty(index = 3) + private String mobile; + + //工号 + @SalaryTableColumn(text = "工号", width = "10%", column = "jobNum") + @TableTitle(title = "工号", dataIndex = "jobNum", key = "jobNum") + @ExcelProperty(index = 4) + private String jobNum; + + //证件号码 + @SalaryTableColumn(text = "证件号码", width = "10%", column = "idNo") + @TableTitle(title = "证件号码", dataIndex = "idNo", key = "idNo") + @ExcelProperty(index = 5) + private String idNo; + + //入职日期 + @ExcelProperty(index = 6) + @SalaryTableColumn(text = "入职日期", width = "10%", column = "hiredate") + @TableTitle(title = "入职日期", dataIndex = "hiredate", key = "hiredate") + private String hiredate; + + //子女教育 + @ExcelProperty(index = 7) + @SalaryTableColumn(text = "子女教育", width = "10%", column = "childrenEducation") + @TableTitle(title = "子女教育", dataIndex = "childrenEducation", key = "childrenEducation") + @Encrypt + private String childrenEducation; + + //继续教育 + @ExcelProperty(index = 8) + @SalaryTableColumn(text = "继续教育", width = "10%", column = "continuingEducation") + @TableTitle(title = "继续教育", dataIndex = "continuingEducation", key = "continuingEducation") + @Encrypt + private String continuingEducation; + + //住房贷款利息 + @ExcelProperty(index = 9) + @SalaryTableColumn(text = "住房贷款利息", width = "10%", column = "housingLoanInterest") + @TableTitle(title = "住房贷款利息", dataIndex = "housingLoanInterest", key = "housingLoanInterest") + @Encrypt + private String housingLoanInterest; + + //住房租金 + @ExcelProperty(index = 10) + @SalaryTableColumn(text = "住房租金", width = "10%", column = "housingRent") + @TableTitle(title = "住房租金", dataIndex = "housingRent", key = "housingRent") + @Encrypt + private String housingRent; + + //赡养老人 + @ExcelProperty(index = 11) + @SalaryTableColumn(text = "赡养老人", width = "10%", column = "supportingElder") + @TableTitle(title = "赡养老人", dataIndex = "supportingElder", key = "supportingElder") + @Encrypt + private String supportingElder; + + //大病医疗 + @ExcelProperty(index = 12) + @SalaryTableColumn(text = "大病医疗", width = "10%", column = "seriousIllnessTreatment") + @TableTitle(title = "大病医疗", dataIndex = "seriousIllnessTreatment", key = "seriousIllnessTreatment") + @Encrypt + private String seriousIllnessTreatment; + + //婴幼儿照护 + @ExcelProperty(index = 13) + @SalaryTableColumn(text = "婴幼儿照护", width = "10%", column = "infantCare") + @TableTitle(title = "婴幼儿照护", dataIndex = "infantCare", key = "infantCare") + @Encrypt + private String infantCare; + + @SalaryTableColumn(text = "操作", width = "20%", column = "operate") + @TableTitle(title = "操作", dataIndex = "operate", key = "operate") + private Set opts; +} diff --git a/src/com/engine/salary/entity/datacollection/dto/SpecialAddDeductionRecordDTO.java b/src/com/engine/salary/entity/datacollection/dto/SpecialAddDeductionRecordDTO.java new file mode 100644 index 000000000..f371232f5 --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/dto/SpecialAddDeductionRecordDTO.java @@ -0,0 +1,103 @@ +package com.engine.salary.entity.datacollection.dto; + +import com.cloudstore.eccom.pc.table.WeaTableType; +import com.engine.salary.annotation.*; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 其他免税扣除记录列表 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@SalaryTable(pageId = "a4f85287-e3f9-6612-adn9-7d98e54y6rj8", tableType = WeaTableType.CHECKBOX) +@Auth(page = "specialAddDeduction") +public class SpecialAddDeductionRecordDTO { + + //主键id + @SalaryTableColumn(column = "id", display = false) + private Long id; + + //员工id + private Long employeeId; + + private String username; + + //个税扣缴义务人 + @SalaryTableColumn(text = "个税扣缴义务人", width = "10%", column = "taxAgentName") + @TableTitle(title = "个税扣缴义务人", dataIndex = "taxAgentName", key = "taxAgentName") + private String taxAgentName; + /** + * 个税扣缴义务人id + */ + private Long taxAgentId; + + + //部门 + @SalaryTableColumn(text = "部门", width = "10%", column = "departmentName") + @TableTitle(title = "部门", dataIndex = "departmentName", key = "departmentName") + private String departmentName; + + //手机号 + @SalaryTableColumn(text = "手机号", width = "10%", column = "mobile") + @TableTitle(title = "手机号", dataIndex = "mobile", key = "mobile") + private String mobile; + + private String idNo; + + //工号 + @SalaryTableColumn(text = "工号", width = "10%", column = "jobNum") + @TableTitle(title = "工号", dataIndex = "jobNum", key = "jobNum") + private String jobNum; + + //子女教育 + @SalaryTableColumn(text = "子女教育", width = "10%", column = "childrenEducation") + @TableTitle(title = "子女教育", dataIndex = "childrenEducation", key = "childrenEducation") + @Encrypt + private String childrenEducation; + + //继续教育 + @SalaryTableColumn(text = "继续教育", width = "10%", column = "continuingEducation") + @TableTitle(title = "继续教育", dataIndex = "continuingEducation", key = "continuingEducation") + @Encrypt + private String continuingEducation; + + //住房贷款利息 + @SalaryTableColumn(text = "住房贷款利息", width = "10%", column = "housingLoanInterest") + @TableTitle(title = "住房贷款利息", dataIndex = "housingLoanInterest", key = "housingLoanInterest") + @Encrypt + private String housingLoanInterest; + + //住房租金 + @SalaryTableColumn(text = "住房租金", width = "10%", column = "housingRent") + @TableTitle(title = "住房租金", dataIndex = "housingRent", key = "housingRent") + @Encrypt + private String housingRent; + + //赡养老人 + @SalaryTableColumn(text = "赡养老人", width = "10%", column = "supportingElder") + @TableTitle(title = "赡养老人", dataIndex = "supportingElder", key = "supportingElder") + @Encrypt + private String supportingElder; + + //大病医疗 + @SalaryTableColumn(text = "大病医疗", width = "10%", column = "seriousIllnessTreatment") + @TableTitle(title = "大病医疗", dataIndex = "seriousIllnessTreatment", key = "seriousIllnessTreatment") + @Encrypt + private String seriousIllnessTreatment; + + //大病医疗 + @SalaryTableColumn(text = "婴幼儿照护", width = "10%", column = "infantCare") + @TableTitle(title = "婴幼儿照护", dataIndex = "infantCare", key = "infantCare") + @Encrypt + private String infantCare; +} diff --git a/src/com/engine/salary/entity/datacollection/dto/VariableArchiveItemDTO.java b/src/com/engine/salary/entity/datacollection/dto/VariableArchiveItemDTO.java new file mode 100644 index 000000000..f672cf27b --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/dto/VariableArchiveItemDTO.java @@ -0,0 +1,33 @@ +package com.engine.salary.entity.datacollection.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 浮动薪酬档案明细 + *

Copyright: Copyright (c) 2024

+ *

Company: 泛微软件

+ * + * @author xzy + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class VariableArchiveItemDTO { + + private Long id; + + /** + * 浮动项目id + */ + private Long variableItemId; + + /** + * 浮动值 + */ + private String itemValue; +} diff --git a/src/com/engine/salary/entity/datacollection/dto/VariableArchiveListDTO.java b/src/com/engine/salary/entity/datacollection/dto/VariableArchiveListDTO.java new file mode 100644 index 000000000..b3faa7e4c --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/dto/VariableArchiveListDTO.java @@ -0,0 +1,104 @@ +package com.engine.salary.entity.datacollection.dto; + +import com.cloudstore.eccom.pc.table.WeaTableType; +import com.engine.salary.annotation.Auth; +import com.engine.salary.annotation.I18n; +import com.engine.salary.annotation.SalaryTable; +import com.engine.salary.annotation.TableTitle; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; +import java.util.Set; + +/** + * 浮动薪资档案列表 + *

Copyright: Copyright (c) 2024

+ *

Company: 泛微软件

+ * + * @author xzy + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@SalaryTable(pageId = "bd985583-f84j-p2aj-p288-2hw3hosy6r6,", tableType = WeaTableType.CHECKBOX) +@Auth(page = "variableArchive") +public class VariableArchiveListDTO { + + @TableTitle(title = "id", dataIndex = "id", key = "id") + private Long id; + + @TableTitle(title = "人员信息表的主键id", dataIndex = "employeeId", key = "employeeId") + private Long employeeId; + + private Date salaryMonth; + + /** + * 个税扣缴义务人 + */ + @TableTitle(title = "个税扣缴义务人", dataIndex = "taxAgentName", key = "taxAgentName") + @I18n + private String taxAgentName; + + /** + * 个税扣缴义务人id + */ + private Long taxAgentId; + + /** + * 姓名 + */ + @TableTitle(title = "姓名", dataIndex = "username", key = "username") + @I18n + private String username; + + /** + * 分部 + */ + @TableTitle(title = "分部", dataIndex = "subcompanyName", key = "subcompanyName") + @I18n + private String subcompanyName; + + /** + * 部门 + */ + @TableTitle(title = "部门", dataIndex = "departmentName", key = "departmentName") + @I18n + private String departmentName; + + /** + * 电话 + */ + @TableTitle(title = "电话", dataIndex = "mobile", key = "mobile") + private String mobile; + + + /** + * 工号 + */ + @TableTitle(title = "工号", dataIndex = "workcode", key = "workcode") + private String workcode; + + /** + * 证件号码 + */ + @TableTitle(title = "证件号码", dataIndex = "idNo", key = "idNo") + private String idNo; + + /** + * 入职日期 + */ + private String companystartdate; + + /** + * 离职日期 + */ + private String dismissdate; + + private Set opts; + +} diff --git a/src/com/engine/salary/entity/datacollection/dto/VariableItemListDTO.java b/src/com/engine/salary/entity/datacollection/dto/VariableItemListDTO.java new file mode 100644 index 000000000..dc38ca99b --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/dto/VariableItemListDTO.java @@ -0,0 +1,37 @@ +package com.engine.salary.entity.datacollection.dto; + +import com.engine.salary.annotation.TableTitle; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 浮动薪资项目列表 + *

Copyright: Copyright (c) 2024

+ *

Company: 泛微软件

+ * + * @author xzy + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class VariableItemListDTO { + + @TableTitle(title = "id", dataIndex = "id", key = "id") + private Long id; + + @TableTitle(title = "项目名称", dataIndex = "name", key = "name") + private String name; + + @TableTitle(title = "字段类型", dataIndex = "dataType", key = "dataType") + private String dataType; + + /** + * 是否可删除 + */ + private boolean canDelete; + +} diff --git a/src/com/engine/salary/entity/datacollection/param/AddDeductionAutoAddParam.java b/src/com/engine/salary/entity/datacollection/param/AddDeductionAutoAddParam.java new file mode 100644 index 000000000..5a3c11b47 --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/param/AddDeductionAutoAddParam.java @@ -0,0 +1,24 @@ +package com.engine.salary.entity.datacollection.param; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; +import java.util.List; + +/** + * @description 数据采集-专项附加扣除一键累计参数 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class AddDeductionAutoAddParam { + String yearMonth = ""; + + Date yearMonthDate; + + List taxAgentIds; +} diff --git a/src/com/engine/salary/entity/datacollection/param/AddUpDeductionImportParam.java b/src/com/engine/salary/entity/datacollection/param/AddUpDeductionImportParam.java new file mode 100644 index 000000000..0941b0cbd --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/param/AddUpDeductionImportParam.java @@ -0,0 +1,31 @@ +package com.engine.salary.entity.datacollection.param; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 数据采集-累计专项附加扣除导入参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class AddUpDeductionImportParam { + + //上传文件id + String imageId; + + //税款所属期 + String declareMonth; + + //个税扣缴义务人 + String taxAgentId; + +} diff --git a/src/com/engine/salary/entity/datacollection/param/AddUpDeductionQueryParam.java b/src/com/engine/salary/entity/datacollection/param/AddUpDeductionQueryParam.java new file mode 100644 index 000000000..15cf175d7 --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/param/AddUpDeductionQueryParam.java @@ -0,0 +1,73 @@ +package com.engine.salary.entity.datacollection.param; + +import com.engine.salary.common.BaseQueryParam; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.Date; +import java.util.List; + +/** + * 数据采集-累计专项附加扣除查询参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class AddUpDeductionQueryParam extends BaseQueryParam { + + /** + * 主键id + */ + private Collection ids; + + //关键字(姓名、部门、工号) + private String keyword; + + //主键id + private Long id; + + //申报月份 + private List declareMonth; + private List declareMonthDate; + + //姓名 + private String username; + + //员工id + private Long employeeId; + + //个税扣缴义务人的主键id + private Long taxAgentId; + + private Collection taxAgentIds; + + //部门id + private List departmentIds; + + //工号 + private String jobNum; + + //证件号 + private String idNo; + + //入职日期 + private List hiredate; + + //手机号 + private String mobile; + + //累计专项附加扣除id(获取明细) + private Long accumulatedSpecialAdditionalDeductionId; + + //下载模板时是否带出现有数据 + private boolean hasData; +} diff --git a/src/com/engine/salary/entity/datacollection/param/AddUpDeductionRecordDeleteParam.java b/src/com/engine/salary/entity/datacollection/param/AddUpDeductionRecordDeleteParam.java new file mode 100644 index 000000000..4b9aa0e78 --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/param/AddUpDeductionRecordDeleteParam.java @@ -0,0 +1,29 @@ +package com.engine.salary.entity.datacollection.param; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * @author Harryxzy + * @date 2022/10/26 16:38 + * @description 累计专项附加扣-除删除参数 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class AddUpDeductionRecordDeleteParam { + + // 删除id + private List ids; + + // 申报月份 + private String declareMonth; + + // 个税扣缴义务人 + private String taxAgentId; +} diff --git a/src/com/engine/salary/entity/datacollection/param/AddUpDeductionRecordParam.java b/src/com/engine/salary/entity/datacollection/param/AddUpDeductionRecordParam.java new file mode 100644 index 000000000..0a9db66f8 --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/param/AddUpDeductionRecordParam.java @@ -0,0 +1,67 @@ +package com.engine.salary.entity.datacollection.param; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author Harryxzy + * @date 2022/10/25 16:26 + * @description 数据采集-累计专项附加扣除编辑参数 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class AddUpDeductionRecordParam { + + // 主键id + private Long id; + + // 员工id + private Long employeeId; + + private String username; + + // 申报月份 + private String declareMonth; + + // 个税扣缴义务人 + private String taxAgentName; + + // 个税扣缴义务人id + private Long taxAgentId; + + + // 部门 + private String departmentName; + + // 手机号 + private String mobile; + + // 工号 + private String jobNum; + + // 累计子女教育 + private String addUpChildEducation; + + // 累计继续教育 + private String addUpContinuingEducation; + + // 累计住房贷款利息 + private String addUpHousingLoanInterest; + + // 累计住房租金 + private String addUpHousingRent; + + // 累计赡养老人 + private String addUpSupportElderly; + + // 累计大病医疗 + private String addUpIllnessMedical; + + // 累计婴幼儿照护 + private String addUpInfantCare; + +} diff --git a/src/com/engine/salary/entity/datacollection/param/AddUpSituationDeleteParam.java b/src/com/engine/salary/entity/datacollection/param/AddUpSituationDeleteParam.java new file mode 100644 index 000000000..7bd5820c9 --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/param/AddUpSituationDeleteParam.java @@ -0,0 +1,29 @@ +package com.engine.salary.entity.datacollection.param; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * @author Harryxzy + * @date 2022/10/31 15:43 + * @description 往期累计情况删除参数 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class AddUpSituationDeleteParam { + // 删除id + private List ids; + + // 申报月份 + private String taxYearMonth; + + // 个税扣缴义务人 + private String taxAgentId; + +} diff --git a/src/com/engine/salary/entity/datacollection/param/AddUpSituationImportParam.java b/src/com/engine/salary/entity/datacollection/param/AddUpSituationImportParam.java new file mode 100644 index 000000000..e4d947d70 --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/param/AddUpSituationImportParam.java @@ -0,0 +1,29 @@ +package com.engine.salary.entity.datacollection.param; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 数据采集-累计情况导入参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class AddUpSituationImportParam { + + //上传文件id + String imageId; + + //税款所属期 + String taxYearMonth; + + +} diff --git a/src/com/engine/salary/entity/datacollection/param/AddUpSituationParam.java b/src/com/engine/salary/entity/datacollection/param/AddUpSituationParam.java new file mode 100644 index 000000000..d50184b2f --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/param/AddUpSituationParam.java @@ -0,0 +1,101 @@ +package com.engine.salary.entity.datacollection.param; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author Harryxzy + * @date 2022/10/27 21:14 + * @description 往期累计情况编辑参数 + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class AddUpSituationParam { + + //主键id + private Long id; + + //员工id + private Long employeeId; + + //申报年月 + private String taxYearMonth; + + //姓名 + private String username; + + //个税扣缴义务人 + private String taxAgentName; + + //个税扣缴义务人id + private Long taxAgentId; + + //部门 + private String departmentName; + + //手机号 + private String mobile; + + //工号 + private String jobNum; + + + //累计收入额 + private String addUpIncome; + + //累计减除费用 + private String addUpSubtraction; + + //累计社保个人合计 + private String addUpSocialSecurityTotal; + + //累计公积金个人合计 + private String addUpAccumulationFundTotal; + + //累计子女教育 + private String addUpChildEducation; + + //累计继续教育 + private String addUpContinuingEducation; + + //累计住房贷款利息 + private String addUpHousingLoanInterest; + + //累计住房租金 + private String addUpHousingRent; + + //累计赡养老人 + private String addUpSupportElderly; + + //累计大病医疗 + private String addUpIllnessMedical; + + //累计企业(职业)年金及其他福利 + private String addUpEnterpriseAndOther; + + //累计其他扣除 + private String addUpOtherDeduction; + + //累计免税收入 + private String addUpTaxExemptIncome; + + //累计准予扣除的捐赠额 + private String addUpAllowedDonation; + + //累计减免税额 + private String addUpTaxSavings; + + //累计已预扣预缴税额 + private String addUpAdvanceTax; + + //累计婴幼儿照护 + private String addUpInfantCare; + + //累计个人养老金 + private String addUpPrivatePension; + +} diff --git a/src/com/engine/salary/entity/datacollection/param/AddUpSituationQueryParam.java b/src/com/engine/salary/entity/datacollection/param/AddUpSituationQueryParam.java new file mode 100644 index 000000000..70998028f --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/param/AddUpSituationQueryParam.java @@ -0,0 +1,68 @@ +package com.engine.salary.entity.datacollection.param; + +import com.engine.salary.common.BaseQueryParam; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.Date; +import java.util.List; + +/** + * 数据采集-累计情况查询参数 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class AddUpSituationQueryParam extends BaseQueryParam { + + //主键id + private Collection ids; + + //关键字(姓名、部门、工号) + private String keyword; + + //主键id + private Long id; + + //纳税年度 + private Integer year; + + //税款所属期 + private List taxYearMonth; + private List taxYearMonthDate; + + //姓名 + private String username; + + //员工id + private Long employeeId; + + //个税扣缴义务人的主键id + private Long taxAgentId; + private List taxAgentIds; + + //部门id + private List departmentIds; + + //工号 + private String jobNum; + + //证件号 + private String idNo; + + //入职日期 + private List hiredate; + + //手机号 + private String mobile; + + //累计情况id(获取明细) + private Long accumulatedSituationId; + + //下载模板时是否带出现有数据 + private boolean hasData; +} diff --git a/src/com/engine/salary/entity/datacollection/param/AttendModuleSettingFieldParam.java b/src/com/engine/salary/entity/datacollection/param/AttendModuleSettingFieldParam.java new file mode 100644 index 000000000..aec0763d8 --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/param/AttendModuleSettingFieldParam.java @@ -0,0 +1,27 @@ +package com.engine.salary.entity.datacollection.param; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 数据采集-考勤模块字段参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class AttendModuleSettingFieldParam { + + //字段id + private Long id; + + //是否选中 + private Boolean checked; +} diff --git a/src/com/engine/salary/entity/datacollection/param/AttendQuoteCheckOperationParam.java b/src/com/engine/salary/entity/datacollection/param/AttendQuoteCheckOperationParam.java new file mode 100644 index 000000000..c5d99339b --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/param/AttendQuoteCheckOperationParam.java @@ -0,0 +1,35 @@ +package com.engine.salary.entity.datacollection.param; + +import com.engine.salary.util.valid.DataCheck; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.time.YearMonth; +import java.util.List; + +/** + * 考勤引用是否可以操作参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class AttendQuoteCheckOperationParam { + + //薪资所属月 + private YearMonth salaryYearMonth; + + @DataCheck(require = true, message = "薪资所属月必传") + private String salaryYearMonthStr; + + //关联账套id + @DataCheck(require = true, message = "关联账套id必传") + private List salarySobIds; +} diff --git a/src/com/engine/salary/entity/datacollection/param/AttendQuoteDataEditParam.java b/src/com/engine/salary/entity/datacollection/param/AttendQuoteDataEditParam.java new file mode 100644 index 000000000..5033ad73b --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/param/AttendQuoteDataEditParam.java @@ -0,0 +1,32 @@ +package com.engine.salary.entity.datacollection.param; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Map; + +/** + * @author Harryxzy + * @date 2022/10/28 14:33 + * @description 考勤引用编辑参数 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class AttendQuoteDataEditParam { + + //主键id" + private Long id; + + //考勤数据 + private Map attendQuoteData; + + +// //关键字(姓名/部门名称/手机号/工号)") +// private String keyword; + + +} diff --git a/src/com/engine/salary/entity/datacollection/param/AttendQuoteDataExportTemplateParam.java b/src/com/engine/salary/entity/datacollection/param/AttendQuoteDataExportTemplateParam.java new file mode 100644 index 000000000..7fa7c9c0d --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/param/AttendQuoteDataExportTemplateParam.java @@ -0,0 +1,29 @@ +package com.engine.salary.entity.datacollection.param; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.time.YearMonth; +import java.util.Collection; + +/** + * @Description: 数据采集-考勤引用数据导出模板参数 + * @Author: wangxiangzhong + * @Date: 2021-11-17 14:37 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class AttendQuoteDataExportTemplateParam { + //薪资所属月 + private YearMonth salaryYearMonth; + + //薪资账套id + private Long salarySobId; + + //主键id + private Collection ids; +} diff --git a/src/com/engine/salary/entity/datacollection/param/AttendQuoteDataImportParam.java b/src/com/engine/salary/entity/datacollection/param/AttendQuoteDataImportParam.java new file mode 100644 index 000000000..af910117f --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/param/AttendQuoteDataImportParam.java @@ -0,0 +1,36 @@ +package com.engine.salary.entity.datacollection.param; + +import com.engine.salary.util.valid.DataCheck; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 数据采集-考勤导入参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class AttendQuoteDataImportParam { + + //上传文件id + @DataCheck(require = true,message = "imageId为空") + String imageId; + + //薪资所属月 + @DataCheck(require = true,message = "薪资所属月为空") + String salaryYearMonth; + + //账套id + @DataCheck(require = true,message = "账套id为空") + Long salarySobId; + + +} diff --git a/src/com/engine/salary/entity/datacollection/param/AttendQuoteDataQueryParam.java b/src/com/engine/salary/entity/datacollection/param/AttendQuoteDataQueryParam.java new file mode 100644 index 000000000..095cbe9c4 --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/param/AttendQuoteDataQueryParam.java @@ -0,0 +1,48 @@ +package com.engine.salary.entity.datacollection.param; + +import com.engine.salary.common.BaseQueryParam; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; + +/** + * 数据采集-考勤引用数据 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//数据采集-考勤引用数据查询参数") +public class AttendQuoteDataQueryParam extends BaseQueryParam { + + //主键id") + private Collection ids; + + @JsonIgnore + private Long id; + + //关键字(姓名/部门名称/手机号/工号)") + private String keyword; + + //是否仅查看异动人员") + private Boolean isViewChangeEmployee; + + //考勤引用表的主键id(获取明细)") + private Long attendQuoteId; + + private Collection unAccountingIds; + + +// +// //人员信息表的主键id") +// private Long employeeId; +} diff --git a/src/com/engine/salary/entity/datacollection/param/AttendQuoteDataSaveParam.java b/src/com/engine/salary/entity/datacollection/param/AttendQuoteDataSaveParam.java new file mode 100644 index 000000000..8be6dad96 --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/param/AttendQuoteDataSaveParam.java @@ -0,0 +1,28 @@ +package com.engine.salary.entity.datacollection.param; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Description: 数据采集-考勤引用数据 + * @Author: wangxiangzhong + * @Date: 2021-11-17 14:37 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//数据采集-考勤引用数据保存参数") +public class AttendQuoteDataSaveParam { + + //主键") + private Long id; + + //人员信息表的主键id") + private Long employeeId; + + //考勤引用表的主键id") + private Long attendQuoteId; +} diff --git a/src/com/engine/salary/entity/datacollection/param/AttendQuoteDataSyncParam.java b/src/com/engine/salary/entity/datacollection/param/AttendQuoteDataSyncParam.java new file mode 100644 index 000000000..cfe868557 --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/param/AttendQuoteDataSyncParam.java @@ -0,0 +1,52 @@ +package com.engine.salary.entity.datacollection.param; + +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.util.SalaryI18nUtil; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; + +import java.util.Collection; +import java.util.List; + +/** + * 数据采集-考勤引用数据同步参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class AttendQuoteDataSyncParam { + + //薪资所属月 + private String salaryYearMonth; + + //关联账套id + private List salarySobIds; + + //账套外人员主键id + private Collection employeeIds; + + //备注 + private String description; + + public static void checkParam(AttendQuoteDataSyncParam saveParam) { + if (saveParam == null){ + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100294, "参数异常")); + } + if (StringUtils.isEmpty(saveParam.getSalaryYearMonth())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100294, "薪资所属月必传")); + } + if (CollectionUtils.isEmpty(saveParam.getSalarySobIds())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100295, "薪资账套必传")); + } + } +} diff --git a/src/com/engine/salary/entity/datacollection/param/AttendQuoteFieldQueryParam.java b/src/com/engine/salary/entity/datacollection/param/AttendQuoteFieldQueryParam.java new file mode 100644 index 000000000..40eb45720 --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/param/AttendQuoteFieldQueryParam.java @@ -0,0 +1,62 @@ +package com.engine.salary.entity.datacollection.param; + +import com.engine.salary.common.BaseQueryParam; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; + +import java.util.Collection; +import java.util.stream.Collectors; + +/** + * 数据采集-考勤引用字段 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//数据采集-考勤引用字段查询参数") +public class AttendQuoteFieldQueryParam extends BaseQueryParam { + + private Collection ids; + + private Long id; + + //字段名称 + private String fieldName; + + //根据编码删除 + private Collection codes; + //来源。1:自定义、2:考勤模块 + private Integer sourceType; + + private Integer enableStatus; + + /** + * 查询where语句 + * + * @param queryParam + */ + public static String genWhereSql(AttendQuoteFieldQueryParam queryParam) { + String whereSQl = "t1.delete_type = 0 "; + Collection ids = queryParam.getIds(); + if (CollectionUtils.isNotEmpty(ids)) { + String idsStr = ids.stream().map(String::valueOf).collect(Collectors.joining(",")); + whereSQl += " AND t1.id IN (" + idsStr + ")"; + } + String fieldName = queryParam.getFieldName(); + if (StringUtils.isNotBlank(fieldName)) { + whereSQl += " AND t1.field_name like '%" + fieldName + "%'"; + } + + return whereSQl; + } +} diff --git a/src/com/engine/salary/entity/datacollection/param/AttendQuoteFieldSaveParam.java b/src/com/engine/salary/entity/datacollection/param/AttendQuoteFieldSaveParam.java new file mode 100644 index 000000000..e97f71925 --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/param/AttendQuoteFieldSaveParam.java @@ -0,0 +1,52 @@ +package com.engine.salary.entity.datacollection.param; + +import com.engine.salary.enums.datacollection.AttendQuoteFieldTypeEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.apache.commons.lang3.StringUtils; + +/** + * @Description: 数据采集-考勤引用字段 + * @Author: wangxiangzhong + * @Date: 2021-11-17 14:37 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//数据采集-考勤引用字段保存参数") +public class AttendQuoteFieldSaveParam { + + //主键") + private Long id; + + //字段名称") + private String fieldName; + + //字段类型。1:数值、2:文本") + private AttendQuoteFieldTypeEnum fieldType; + + //是否启用。false:否、true:是") + private Boolean enableStatus; + + //备注") + private String description; + + public static void checkParam(AttendQuoteFieldSaveParam saveParam) { + if (StringUtils.isEmpty(saveParam.getFieldName())) { + throw new SalaryRunTimeException("字段名称必填"); + } + if (saveParam.getFieldType() == null) { + throw new SalaryRunTimeException("字段类型必传"); + } + if (saveParam.getEnableStatus() == null) { + throw new SalaryRunTimeException("是否启用必传"); + } + if (saveParam.getEnableStatus().equals(0) && saveParam.getEnableStatus().equals(1)) { + throw new SalaryRunTimeException("是否启用参数有误"); + } + } +} diff --git a/src/com/engine/salary/entity/datacollection/param/AttendQuoteFieldSettingQueryParam.java b/src/com/engine/salary/entity/datacollection/param/AttendQuoteFieldSettingQueryParam.java new file mode 100644 index 000000000..dd4ac69a8 --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/param/AttendQuoteFieldSettingQueryParam.java @@ -0,0 +1,29 @@ +package com.engine.salary.entity.datacollection.param; + +import com.engine.salary.enums.datacollection.AttendQuoteSourceTypeEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Description: 数据采集-考勤引用字段设置 + * @Author: wangxiangzhong + * @Date: 2021-12-01 13:43 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//数据采集-考勤引用字段设置查询参数") +public class AttendQuoteFieldSettingQueryParam { + + //考勤字段来源类型:QUOTE:引用,IMPORT:导入") + private AttendQuoteSourceTypeEnum sourceType; + + //关键字") + private String keyword; + + //是否只显示已选中字段") + private Boolean isViewChecked; +} diff --git a/src/com/engine/salary/entity/datacollection/param/AttendQuoteFieldSettingRecoverParam.java b/src/com/engine/salary/entity/datacollection/param/AttendQuoteFieldSettingRecoverParam.java new file mode 100644 index 000000000..0a894abe1 --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/param/AttendQuoteFieldSettingRecoverParam.java @@ -0,0 +1,28 @@ +package com.engine.salary.entity.datacollection.param; + +import com.engine.salary.enums.datacollection.AttendQuoteSourceTypeEnum; +import com.engine.salary.util.valid.DataCheck; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 数据采集-考勤引用字段设置 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//数据采集-考勤引用字段设置恢复默认设置参数") +public class AttendQuoteFieldSettingRecoverParam { + + //考勤字段来源类型:QUOTE:引用,IMPORT:导入") + @DataCheck(require = true,message = "考勤字段来源类型为空!") + private AttendQuoteSourceTypeEnum sourceType; +} diff --git a/src/com/engine/salary/entity/datacollection/param/AttendQuoteFieldSettingSaveParam.java b/src/com/engine/salary/entity/datacollection/param/AttendQuoteFieldSettingSaveParam.java new file mode 100644 index 000000000..876a54bc6 --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/param/AttendQuoteFieldSettingSaveParam.java @@ -0,0 +1,28 @@ +package com.engine.salary.entity.datacollection.param; + +import com.engine.salary.enums.datacollection.AttendQuoteSourceTypeEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * @Description: 数据采集-考勤引用字段设置 + * @Author: wangxiangzhong + * @Date: 2021-12-01 13:43 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//数据采集-考勤引用字段设置保存参数") +public class AttendQuoteFieldSettingSaveParam { + + //考勤字段来源类型:QUOTE:引用,IMPORT:导入") + private AttendQuoteSourceTypeEnum sourceType; + + //当前设置内容") + private List currentSettingFields; +} diff --git a/src/com/engine/salary/entity/datacollection/param/AttendQuoteQueryParam.java b/src/com/engine/salary/entity/datacollection/param/AttendQuoteQueryParam.java new file mode 100644 index 000000000..117c6bb56 --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/param/AttendQuoteQueryParam.java @@ -0,0 +1,34 @@ +package com.engine.salary.entity.datacollection.param; + +import com.engine.salary.common.BaseQueryParam; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.Date; +import java.util.List; + +/** + * 数据采集-考勤引用查询参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class AttendQuoteQueryParam extends BaseQueryParam { + + private Collection ids; + + private Collection salarySobIds; + + //薪资所属月 + private List salaryYearMonth; + private List salaryYearMonthDate; +} diff --git a/src/com/engine/salary/entity/datacollection/param/OtherDeductionExtendLastParam.java b/src/com/engine/salary/entity/datacollection/param/OtherDeductionExtendLastParam.java new file mode 100644 index 000000000..6277c0f63 --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/param/OtherDeductionExtendLastParam.java @@ -0,0 +1,21 @@ +package com.engine.salary.entity.datacollection.param; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.time.LocalDateTime; + +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class OtherDeductionExtendLastParam { + + private String declareMonth; + + private LocalDateTime yearMonthTime; + + private Integer taxAgentId; +} diff --git a/src/com/engine/salary/entity/datacollection/param/OtherDeductionImportParam.java b/src/com/engine/salary/entity/datacollection/param/OtherDeductionImportParam.java new file mode 100644 index 000000000..3ac3a98c9 --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/param/OtherDeductionImportParam.java @@ -0,0 +1,31 @@ +package com.engine.salary.entity.datacollection.param; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 数据采集-累计专项附加扣除导入参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class OtherDeductionImportParam { + + //上传文件id + String imageId; + + //税款所属期 + String declareMonth; + + //个税扣缴义务人 + String taxAgentId; + +} diff --git a/src/com/engine/salary/entity/datacollection/param/OtherDeductionParam.java b/src/com/engine/salary/entity/datacollection/param/OtherDeductionParam.java new file mode 100644 index 000000000..06311ed20 --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/param/OtherDeductionParam.java @@ -0,0 +1,63 @@ +package com.engine.salary.entity.datacollection.param; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author Harryxzy + * @date 2022/10/26 9:50 + * @description 数据采集-其他免税扣除 编辑参数 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class OtherDeductionParam { + + // 主键id + private Long id; + + // 申报月份 + private String declareMonth; + + // 员工id + private Long employeeId; + + private String username; + + // 个税扣缴义务人 + private String taxAgentName; + + // 个税扣缴义务人id + private Long taxAgentId; + + // 部门 + private String departmentName; + + // 手机号 + private String mobile; + + private String idNo; + + // 工号 + private String jobNum; + + // 商业健康保险 + private String businessHealthyInsurance; + + // 税延养老保险 + private String taxDelayEndowmentInsurance; + + // 其他 + private String otherDeduction; + + // 准予扣除的捐赠额 + private String deductionAllowedDonation; + + //个人养老金 + private String privatePension; + + +} diff --git a/src/com/engine/salary/entity/datacollection/param/OtherDeductionQueryParam.java b/src/com/engine/salary/entity/datacollection/param/OtherDeductionQueryParam.java new file mode 100644 index 000000000..d3683d46b --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/param/OtherDeductionQueryParam.java @@ -0,0 +1,65 @@ +package com.engine.salary.entity.datacollection.param; + +import com.engine.salary.common.BaseQueryParam; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.Date; +import java.util.List; + + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//数据采集-其他免税扣除查询参数 +public class OtherDeductionQueryParam extends BaseQueryParam { + + //主键id + private Collection ids; + + //关键字(姓名、部门、工号) + private String keyword; + + //主键id + private Long id; + + //申报年月 + private List declareMonth; + private List declareMonthDate; + + //姓名 + private String username; + + //员工id + private Long employeeId; + + //个税扣缴义务人的主键id + private Long taxAgentId; + private Collection taxAgentIds; + + //部门id + private List departmentIds; + + //工号 + private String jobNum; + + //证件号 + private String idNo; + + //入职日期 + private List hiredate; + + //手机号 + private String mobile; + + //其他免税扣除id(获取明细) + private Long otherTaxExemptDeductionId; + + + //下载模板是否带数据 + private boolean hasData; +} diff --git a/src/com/engine/salary/entity/datacollection/param/QuerySalaryCycleAndAttendCycleParam.java b/src/com/engine/salary/entity/datacollection/param/QuerySalaryCycleAndAttendCycleParam.java new file mode 100644 index 000000000..bed47634d --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/param/QuerySalaryCycleAndAttendCycleParam.java @@ -0,0 +1,25 @@ +package com.engine.salary.entity.datacollection.param; + +import com.engine.salary.util.valid.DataCheck; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.time.YearMonth; + + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class QuerySalaryCycleAndAttendCycleParam { + + //薪资所属月 + @DataCheck(require = true,message = "薪资所属月为空") + YearMonth salaryYearMonth; + + //账套id + @DataCheck(require = true,message = "账套id为空") + Long salarySobId; +} diff --git a/src/com/engine/salary/entity/datacollection/param/SpecialAddDeductionImportParam.java b/src/com/engine/salary/entity/datacollection/param/SpecialAddDeductionImportParam.java new file mode 100644 index 000000000..d221c7a69 --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/param/SpecialAddDeductionImportParam.java @@ -0,0 +1,28 @@ +package com.engine.salary.entity.datacollection.param; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 数据采集-累计专项附加扣除导入参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author lfc + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SpecialAddDeductionImportParam { + + //上传文件id + String imageId; + + //个税扣缴义务人 + String taxAgentId; + +} diff --git a/src/com/engine/salary/entity/datacollection/param/SpecialAddDeductionParam.java b/src/com/engine/salary/entity/datacollection/param/SpecialAddDeductionParam.java new file mode 100644 index 000000000..76408c9d4 --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/param/SpecialAddDeductionParam.java @@ -0,0 +1,80 @@ +package com.engine.salary.entity.datacollection.param; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author Harryxzy + * @date 2022/10/26 9:50 + * @description 数据采集-其他免税扣除 编辑参数 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SpecialAddDeductionParam { + + // 主键id + private Long id; + + // 员工id + private Long employeeId; + + private String username; + + // 个税扣缴义务人 + private String taxAgentName; + + // 个税扣缴义务人id + private Long taxAgentId; + + // 部门 + private String departmentName; + + // 手机号 + private String mobile; + + private String idNo; + + // 工号 + private String jobNum; + + /** + * 子女教育 + */ + private String childrenEducation; + + /** + * 继续教育 + */ + private String continuingEducation; + + /** + * 住房贷款利息 + */ + private String housingLoanInterest; + + /** + * 住房租金 + */ + private String housingRent; + + /** + * 赡养老人 + */ + private String supportingElder; + + /** + * 大病医疗 + */ + private String seriousIllnessTreatment; + + /** + * 婴幼儿照护 + */ + private String infantCare; + + +} diff --git a/src/com/engine/salary/entity/datacollection/param/SpecialAddDeductionQueryParam.java b/src/com/engine/salary/entity/datacollection/param/SpecialAddDeductionQueryParam.java new file mode 100644 index 000000000..26c478a8c --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/param/SpecialAddDeductionQueryParam.java @@ -0,0 +1,60 @@ +package com.engine.salary.entity.datacollection.param; + +import com.engine.salary.common.BaseQueryParam; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.Date; +import java.util.List; + + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//数据采集-其他免税扣除查询参数 +public class SpecialAddDeductionQueryParam extends BaseQueryParam { + + //主键id + private Collection ids; + + //关键字(姓名、部门、工号) + private String keyword; + + //主键id + private Long id; + + //姓名 + private String username; + + //员工id + private Long employeeId; + + //个税扣缴义务人的主键id + private Long taxAgentId; + private Collection taxAgentIds; + + //部门id + private List departmentIds; + + //工号 + private String jobNum; + + //证件号 + private String idNo; + + //入职日期 + private List hiredate; + + //手机号 + private String mobile; + + //其他免税扣除id(获取明细) + private Long specialAddDeductionId; + + //下载模板是否带数据 + private boolean hasData; +} diff --git a/src/com/engine/salary/entity/datacollection/param/SpecialAddDeductionRecordDeleteParam.java b/src/com/engine/salary/entity/datacollection/param/SpecialAddDeductionRecordDeleteParam.java new file mode 100644 index 000000000..58332b91a --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/param/SpecialAddDeductionRecordDeleteParam.java @@ -0,0 +1,25 @@ +package com.engine.salary.entity.datacollection.param; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * @author lfc + * @description 专项附加扣-除删除参数 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SpecialAddDeductionRecordDeleteParam { + + // 删除id + private List ids; + + // 个税扣缴义务人 + private String taxAgentId; +} diff --git a/src/com/engine/salary/entity/datacollection/param/VariableArchiveImportHandleParam.java b/src/com/engine/salary/entity/datacollection/param/VariableArchiveImportHandleParam.java new file mode 100644 index 000000000..b5ef4a61a --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/param/VariableArchiveImportHandleParam.java @@ -0,0 +1,104 @@ +package com.engine.salary.entity.datacollection.param; + +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.datacollection.po.VariableArchiveItemPO; +import com.engine.salary.entity.datacollection.po.VariableArchivePO; +import com.engine.salary.entity.datacollection.po.VariableItemPO; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.Date; +import java.util.List; +import java.util.Map; + +/** + * 数据采集-浮动薪酬导入参数 + *

Copyright: Copyright (c) 2024

+ *

Company: 泛微软件

+ * + * @author xzy + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class VariableArchiveImportHandleParam { + + // 上传文件id + String imageId; + + // 薪资所属月 + String salaryMonth; + + Date salaryMonthDate; + + // --------------------------- + Long currentEmployeeId; + + String tenantKey; + + /** + * 人员验证方式 + */ + String empValidType; + + /** + * 获取租户下所有的人员 + */ + List employees; + + /** + * 获取所有可被引用的浮动薪资项目 + */ + List variableItems; + + /** + * 查询已有的浮动薪资档案基本数据 + */ + Map variableArchivesMap; + + /** + * 浮动薪资项目id + */ + Collection variableItemIds; + + /** + * 查询已生效的浮动薪资项目数据 + */ + Map> effectiveItemListMap; + + /** + * 获取所有个税扣缴义务人 + */ + Collection taxAgentList; + + /** + * 当前时间 + */ + Date nowTime = new Date(); + + /** + * 当天 + */ + Date today = new Date(); + + /** + * 待保存浮动薪资档案 + */ + List variableArchiveSaves; + + /** + * 待保存浮动薪资档案-浮动薪资项目 + */ + List variableArchiveItemSaves; + + /** + * 待删除浮动薪资档案-浮动薪资项目 + */ + List variableArchiveItemDelSalaryItemIds; +} diff --git a/src/com/engine/salary/entity/datacollection/param/VariableArchiveQueryParam.java b/src/com/engine/salary/entity/datacollection/param/VariableArchiveQueryParam.java new file mode 100644 index 000000000..aec1d0f83 --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/param/VariableArchiveQueryParam.java @@ -0,0 +1,52 @@ +package com.engine.salary.entity.datacollection.param; + +import com.engine.salary.common.BaseQueryParam; +import com.engine.salary.util.valid.DataCheck; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.Date; +import java.util.List; + + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//数据采集-浮动薪酬查询参数 +public class VariableArchiveQueryParam extends BaseQueryParam { + + // 主键id + private Collection ids; + + // 主键id + private Long id; + + // 个税扣缴义务人 + private List taxAgentIds; + + // 薪资年月 + @DataCheck(require = true,message = "薪资所属月不能为空") + private String salaryMonth; + + private Date salaryMonthDate; + + // 姓名 + private String username; + + // 部门id + private List departmentIds; + + // 工号 + private String workcode; + + // 下载模板是否带数据 + private boolean hasData; + + private List employeeIds; + + private List columns; +} diff --git a/src/com/engine/salary/entity/datacollection/param/VariableArchiveSaveParam.java b/src/com/engine/salary/entity/datacollection/param/VariableArchiveSaveParam.java new file mode 100644 index 000000000..60e82cf91 --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/param/VariableArchiveSaveParam.java @@ -0,0 +1,38 @@ +package com.engine.salary.entity.datacollection.param; + +import com.engine.salary.entity.datacollection.dto.VariableArchiveItemDTO; +import com.engine.salary.util.valid.DataCheck; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; +import java.util.List; + + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//数据采集-浮动薪酬档案保存参数 +public class VariableArchiveSaveParam { + + // 主键id + private Long id; + + // 薪资年月 + @DataCheck(require = true,message = "薪资所属月不能为空") + private String salaryMonth; + + @DataCheck(require = true,message = "义务人id不能为空") + private Long taxAgentIds; + + private Date salaryMonthDate; + + // 人员id + private Long employeeId; + + // 浮动值 + private List itemValueList; +} diff --git a/src/com/engine/salary/entity/datacollection/param/VariableItemQueryParam.java b/src/com/engine/salary/entity/datacollection/param/VariableItemQueryParam.java new file mode 100644 index 000000000..a2dcc0b0b --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/param/VariableItemQueryParam.java @@ -0,0 +1,31 @@ +package com.engine.salary.entity.datacollection.param; + +import com.engine.salary.common.BaseQueryParam; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +// 浮动薪酬项目查询参数 +public class VariableItemQueryParam extends BaseQueryParam { + + /** + * 浮动薪酬项目名称 + */ + private String itemName; + + + private Long id; + + /** + * 项目ids + */ + private List itemIds; +} diff --git a/src/com/engine/salary/entity/datacollection/param/VariableItemSaveParam.java b/src/com/engine/salary/entity/datacollection/param/VariableItemSaveParam.java new file mode 100644 index 000000000..4b82aaef3 --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/param/VariableItemSaveParam.java @@ -0,0 +1,41 @@ +package com.engine.salary.entity.datacollection.param; + +import com.engine.salary.enums.salaryitem.SalaryDataTypeEnum; +import com.engine.salary.util.valid.DataCheck; +import com.engine.salary.util.valid.RuntimeTypeEnum; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + *

Copyright: Copyright (c) 2024

+ *

Company: 泛微软件

+ * + * @author xzy + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class VariableItemSaveParam { + + //主键id + @JsonSerialize(using = ToStringSerializer.class) + @DataCheck(require = true, runtime = {RuntimeTypeEnum.UPDATE}, message = "id不允许为空") + private Long id; + + //名称 + @DataCheck(require = true, max = 40, message = "名称不允许为空,名称不能超过40个字符") + private String name; + + /** + * 字段类型 + * @see SalaryDataTypeEnum + */ + @DataCheck(require = true, message = "字段类型不允许为空") + private String dataType; +} diff --git a/src/com/engine/salary/entity/datacollection/po/AttendQuoteDataPO.java b/src/com/engine/salary/entity/datacollection/po/AttendQuoteDataPO.java new file mode 100644 index 000000000..7f665b3fa --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/po/AttendQuoteDataPO.java @@ -0,0 +1,64 @@ +package com.engine.salary.entity.datacollection.po; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; + +/** + * 数据采集-考勤引用数据表 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//hrsa_attend_quote_data +public class AttendQuoteDataPO { + + /** + * 主键id + */ + private Long id; + + /** + * 人员信息表的主键id + */ + private Long employeeId; + + /** + * 考勤引用表的主键id + */ + private Long attendQuoteId; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 更新时间 + */ + private Date updateTime; + + /** + * 创建人 + */ + private Long creator; + + /** + * 是否已删除。0:未删除、1:已删除 + */ + private Integer deleteType; + + /** + * 租户ID + */ + private String tenantKey; +} diff --git a/src/com/engine/salary/entity/datacollection/po/AttendQuoteDataValuePO.java b/src/com/engine/salary/entity/datacollection/po/AttendQuoteDataValuePO.java new file mode 100644 index 000000000..b9c8cd84f --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/po/AttendQuoteDataValuePO.java @@ -0,0 +1,68 @@ +package com.engine.salary.entity.datacollection.po; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; +import java.util.List; + +/** + * 考勤引用数据值表 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//hrsa_attend_quote_data_value +public class AttendQuoteDataValuePO { + /** + * 主键 + */ + private Long id; + /** + * 人员信息表的主键id + */ + private Long employeeId; + /** + * 考勤引用表的主键id + */ + private Long attendQuoteId; + /** + * 考勤引用数据表的主键id + */ + private Long attendQuoteDataId; + /** + * 考勤引用字段表的主键id + */ + private Long attendQuoteFieldId; + /** + * 数据值 + */ + private String dataValue; + /** + * 创建时间 + */ + private Date createTime; + /** + * 更新时间 + */ + private Date updateTime; + /** + * 创建人 + */ + private Long creator; + /** + * 是否已删除。0:未删除、1:已删除 + */ + private Integer deleteType; + /** + * 租户ID + */ + private String tenantKey; + + //查询参数 + private List employeeIds; + +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/datacollection/po/AttendQuoteFieldPO.java b/src/com/engine/salary/entity/datacollection/po/AttendQuoteFieldPO.java new file mode 100644 index 000000000..a237aa48f --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/po/AttendQuoteFieldPO.java @@ -0,0 +1,93 @@ +package com.engine.salary.entity.datacollection.po; + +import com.engine.hrmelog.annotation.ElogTransform; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; + +/** + * 考勤引用字段表 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//hrsa_attend_quote_field +@ElogTransform( name ="考勤引用字段") +public class AttendQuoteFieldPO { + /** + * 主键 + */ + @ElogTransform( name ="主键") + private Long id; + + /** + * 字段名称 + */ + @ElogTransform( name ="字段名称") + private String fieldName; + + /** + * 来源。1:自定义、2:考勤模块 + */ + @ElogTransform( name ="来源") + private Integer sourceType; + + /** + * 字段类型。1:数值、2:文本 + */ + @ElogTransform( name ="字段类型") + private Integer fieldType; + + /** + * 是否启用。0:否、1:是 + */ + @ElogTransform( name ="是否启用") + private Integer enableStatus; + + /** + * 编码(对应考勤模块字段) + */ + @ElogTransform( name ="编码") + private String code; + + /** + * 备注 + */ + @ElogTransform( name ="备注") + private String description; + + /** + * 创建时间 + */ + @ElogTransform( name ="创建时间") + private Date createTime; + + /** + * 更新时间 + */ + @ElogTransform( name ="更新时间") + private Date updateTime; + + /** + * 创建人 + */ + @ElogTransform( name ="创建人") + private Long creator; + + /** + * 是否已删除。0:未删除、1:已删除 + */ + @ElogTransform( name ="是否已删除") + private Integer deleteType; + + /** + * 租户ID + */ + @ElogTransform( name ="租户") + private String tenantKey; + +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/datacollection/po/AttendQuoteFieldSettingPO.java b/src/com/engine/salary/entity/datacollection/po/AttendQuoteFieldSettingPO.java new file mode 100644 index 000000000..a6d0294f2 --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/po/AttendQuoteFieldSettingPO.java @@ -0,0 +1,56 @@ +package com.engine.salary.entity.datacollection.po; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; + +/** + * 考勤引用字段设置表 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//hrsa_attend_quote_sync_set +public class AttendQuoteFieldSettingPO { + /** + * 主键 + */ + private Long id; + /** + * 来源。1:引用、2:导入 + */ + private Integer sourceType; + /** + * 当前设置 + */ + private String currentSettingContent; + /** + * 默认设置 + */ + private String defaultSettingContent; + /** + * 创建时间 + */ + private Date createTime; + /** + * 更新时间 + */ + private Date updateTime; + /** + * 创建人 + */ + private Long creator; + /** + * 是否已删除。0:未删除、1:已删除 + */ + private Integer deleteType; + /** + * 租户ID + */ + private String tenantKey; + +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/datacollection/po/AttendQuotePO.java b/src/com/engine/salary/entity/datacollection/po/AttendQuotePO.java new file mode 100644 index 000000000..133e3f788 --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/po/AttendQuotePO.java @@ -0,0 +1,112 @@ +package com.engine.salary.entity.datacollection.po; + +import com.engine.hrmelog.annotation.ElogTransform; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.Date; + +/** + * 考勤引用表 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//hrsa_attend_quote +@ElogTransform(name = "考勤数据") +public class AttendQuotePO { + /** + * 主键 + */ + @ElogTransform(name = "主键") + private Long id; + /** + * 税款所属期 + */ + @ElogTransform(name = "税款所属期") + private Date salaryYearMonth; + /** + * 年份 + */ + @ElogTransform(name = "年份") + private Integer year; + + /** + * 月份 + */ + @ElogTransform(name = "月份") + private Integer month; + + /** + * 薪资账套表的主键id + */ + @ElogTransform(name = "薪资账套id") + private Long salarySobId; + + /** + * 来源。1:引用、2:导入 + */ + @ElogTransform(name = "来源") + private Integer sourceType; + + /** + * 薪资核算状态。0:未核算、1:已核算 + */ + @ElogTransform(name = "薪资核算状态") + private Integer salaryAccountingStatus; + + /** + * 考勤周期 + */ + @ElogTransform(name = "考勤周期") + private String attendCycle; + + /** + * 薪资周期 + */ + @ElogTransform(name = "薪资周期") + private String salaryCycle; + + /** + * 备注 + */ + @ElogTransform(name = "备注") + private String description; + + /** + * 创建时间 + */ + @ElogTransform(name = "创建时间") + private Date createTime; + + /** + * 更新时间 + */ + @ElogTransform(name = "更新时间") + private Date updateTime; + + /** + * 创建人 + */ + @ElogTransform(name = "创建人") + private Long creator; + + /** + * 是否已删除。0:未删除、1:已删除 + */ + private Integer deleteType; + + /** + * 租户ID + */ + @ElogTransform(name = "租户") + private String tenantKey; + + //主键id + private Collection ids; + +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/datacollection/po/OtherDeductionPO.java b/src/com/engine/salary/entity/datacollection/po/OtherDeductionPO.java new file mode 100644 index 000000000..033c82842 --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/po/OtherDeductionPO.java @@ -0,0 +1,123 @@ +package com.engine.salary.entity.datacollection.po; + +import com.engine.hrmelog.annotation.ElogTransform; +import com.engine.salary.annotation.Auth; +import com.engine.salary.annotation.Encrypt; +import com.engine.salary.annotation.SalaryFormulaVar; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.Date; +import java.util.List; + +/** + * 数据采集-其他免税扣除表 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@ElogTransform( name = "其他免税扣除") +@Auth(page = "otherDeduction") +public class OtherDeductionPO { + + /** + * 主键 + */ + @ElogTransform( name="主键id" ) + private Long id; + + /** + * 人员信息表的主键id + */ + @ElogTransform( name ="人员id") + private Long employeeId; + + /** + * 个税扣缴义务人的主键id + */ + @ElogTransform( name ="个税扣缴义务人id") + private Long taxAgentId; + + /** + * 申报月份 + */ + @ElogTransform( name ="税款所属期") + private Date declareMonth; + + /** + * 商业健康保险 + */ + @ElogTransform( name ="商业健康保险") + @SalaryFormulaVar(defaultLabel = "商业健康保险", labelId = 91238, dataType = "number") + @Encrypt + private String businessHealthyInsurance; + + /** + * 税延养老保险 + */ + @ElogTransform( name ="税延养老保险") + @SalaryFormulaVar(defaultLabel = "税延养老保险", labelId = 91239, dataType = "number") + @Encrypt + private String taxDelayEndowmentInsurance; + + /** + * 其他 + */ + @ElogTransform( name ="其他") + @SalaryFormulaVar(defaultLabel = "其他", labelId = 84500, dataType = "number") + @Encrypt + private String otherDeduction; + + /** + * 准予扣除的捐赠额 + */ + @ElogTransform( name ="准予扣除的捐赠额") + @SalaryFormulaVar(defaultLabel = "准予扣除的捐赠额", labelId = 91240, dataType = "number") + @Encrypt + private String deductionAllowedDonation; + + /** + * 个人养老金 + */ + @ElogTransform( name ="个人养老金") + @SalaryFormulaVar(defaultLabel = "个人养老金", labelId = 91240, dataType = "number") + @Encrypt + private String privatePension; + + /** + * 创建时间 + */ + @ElogTransform( name ="创建时间") + private Date createTime; + + /** + * 更新时间 + */ + @ElogTransform( name ="更新时间") + private Date updateTime; + + /** + * 创建人 + */ + @ElogTransform( name ="创建人id") + private Long creator; + + /** + * 是否已删除。0:未删除、1:已删除 + */ + private Integer deleteType; + + /** + * 租户ID + */ + @ElogTransform( name ="租户") + private String tenantKey; + + private List employeeIds; + private Collection taxAgentIds; + +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/datacollection/po/SpecialAddDeductionPO.java b/src/com/engine/salary/entity/datacollection/po/SpecialAddDeductionPO.java new file mode 100644 index 000000000..ce5f49f8a --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/po/SpecialAddDeductionPO.java @@ -0,0 +1,121 @@ +package com.engine.salary.entity.datacollection.po; + +import com.engine.salary.annotation.Encrypt; +import com.engine.hrmelog.annotation.ElogTransform; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.util.Collection; +import java.util.Date; + +/** + * 数据采集-专项附加扣除表 + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@Accessors(chain = true) +@ElogTransform( name = "专项附加扣除" ) +public class SpecialAddDeductionPO { + @ElogTransform( name="主键" ) + private Long id; + + /** + * 人员信息表的主键id + */ + @ElogTransform( name="人员id" ) + private Long employeeId; + + /** + * 个税扣缴义务人的主键id + */ + @ElogTransform( name="个税扣缴义务人id" ) + private Long taxAgentId; + + /** + * 子女教育 + */ + @ElogTransform( name="子女教育" ) + @Encrypt + private String childrenEducation; + + /** + * 继续教育 + */ + @ElogTransform( name="继续教育" ) + @Encrypt + private String continuingEducation; + + /** + * 住房贷款利息 + */ + @ElogTransform( name="住房贷款利息" ) + @Encrypt + private String housingLoanInterest; + + /** + * 住房租金 + */ + @ElogTransform( name="住房租金" ) + @Encrypt + private String housingRent; + + /** + * 赡养老人 + */ + @ElogTransform( name="赡养老人" ) + @Encrypt + private String supportingElder; + + /** + * 大病医疗 + */ + @ElogTransform( name="大病医疗" ) + @Encrypt + private String seriousIllnessTreatment; + + /** + * 婴幼儿照护 + */ + @ElogTransform( name="婴幼儿照护" ) + @Encrypt + private String infantCare; + + /** + * 创建时间 + */ + @ElogTransform( name="创建时间" ) + private Date createTime; + + /** + * 更新时间 + */ + @ElogTransform( name="更新时间" ) + private Date updateTime; + + /** + * 创建人 + */ + @ElogTransform( name="创建人" ) + private Long creator; + + /** + * 是否已删除。0:未删除、1:已删除 + */ + @ElogTransform( name="是否已删除" ) + private Integer deleteType; + + /** + * 租户ID + */ + @ElogTransform( name="租户" ) + private String tenantKey; + + private Collection employeeIds; + + private Collection ids; +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/datacollection/po/VariableArchiveItemPO.java b/src/com/engine/salary/entity/datacollection/po/VariableArchiveItemPO.java new file mode 100644 index 000000000..cd211f2d3 --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/po/VariableArchiveItemPO.java @@ -0,0 +1,78 @@ +package com.engine.salary.entity.datacollection.po; + +import com.engine.salary.annotation.Encrypt; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.Date; + +/** + * @author Harryxzy + * @ClassName VariableArchiveItemPO + * @date 2024/08/07 9:15 + * @description 浮动薪酬档案明细 + */ + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class VariableArchiveItemPO { + + private Long id; + + /** + * 员工id + */ + private Long employeeId; + + /** + * 浮动薪资档案主键id + */ + private Long variableArchiveId; + + /** + * 浮动项目id + */ + private Long variableItemId; + + /** + * 浮动值 + */ + @Encrypt + private String itemValue; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 更新时间 + */ + private Date updateTime; + + /** + * 创建人 + */ + private Long creator; + + /** + * 是否已删除。0:未删除、1:已删除 + */ + private Integer deleteType; + + /** + * 租户ID + */ + private String tenantKey; + + + //主键id集合 + private Collection ids; + private Collection variableArchiveIds; + +} diff --git a/src/com/engine/salary/entity/datacollection/po/VariableArchivePO.java b/src/com/engine/salary/entity/datacollection/po/VariableArchivePO.java new file mode 100644 index 000000000..c078f7dbc --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/po/VariableArchivePO.java @@ -0,0 +1,51 @@ +package com.engine.salary.entity.datacollection.po; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.Date; + +/** + * @author Harryxzy + * @ClassName VariableArchivePO + * @date 2024/08/07 9:16 + * @description 浮动薪酬档案 + */ + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class VariableArchivePO { + + private Long id; + + /** + * 人员id + */ + private Long employeeId; + + private Long taxAgentId; + + /** + * 薪资月份 + */ + private Date salaryMonth; + + private Date createTime; + + private Date updateTime; + + private Long creator; + + private Integer deleteType; + + private String tenantKey; + + //主键id集合 + private Collection ids; + +} diff --git a/src/com/engine/salary/entity/datacollection/po/VariableItemPO.java b/src/com/engine/salary/entity/datacollection/po/VariableItemPO.java new file mode 100644 index 000000000..78cfa8136 --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/po/VariableItemPO.java @@ -0,0 +1,58 @@ +package com.engine.salary.entity.datacollection.po; + +import com.engine.salary.enums.salaryitem.SalaryDataTypeEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.Date; + +/** + * @author Harryxzy + * @ClassName VariableItemPO + * @date 2024/08/07 9:14 + * @description 浮动薪酬项目 + */ + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class VariableItemPO { + + /** + * 浮动项目id + */ + private Long id; + + /** + * 浮动项目名称 + */ + private String name; + + private String code; + + /** + * 字段类型。string:字符、number:数字 + * + * @see SalaryDataTypeEnum + */ + private String dataType; + + private Date createTime; + + private Date updateTime; + + private Long creator; + + private Integer deleteType; + + private String tenantKey; + + + //主键id集合 + private Collection ids; + +} diff --git a/src/com/engine/salary/entity/extemp/dto/ExtEmpDTO.java b/src/com/engine/salary/entity/extemp/dto/ExtEmpDTO.java new file mode 100644 index 000000000..83f356300 --- /dev/null +++ b/src/com/engine/salary/entity/extemp/dto/ExtEmpDTO.java @@ -0,0 +1,57 @@ +package com.engine.salary.entity.extemp.dto; + + +import com.engine.hrmelog.annotation.ElogTransform; +import com.engine.salary.annotation.TableTitle; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 外部人员 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//hrsa_external_employee +@ElogTransform( name = "非系统人员") +public class ExtEmpDTO { + + @ElogTransform(name = "主键id") + private Long id; + + /** + * 姓名 + */ + @TableTitle(title = "姓名", dataIndex = "username", key = "username") + private String username; + + /** + * 部门 + */ + @TableTitle(title = "部门", dataIndex = "departmentName", key = "departmentName") + private String departmentName; + + + /** + * 分部 + */ + @TableTitle(title = "分部", dataIndex = "subcompanyName", key = "subcompanyName") + private String subcompanyName; + + /** + * 入职日期 + */ + @TableTitle(title = "入职日期", dataIndex = "companystartdate", key = "companystartdate") + private String companystartdate; + + + /** + * 工号 + */ + @TableTitle(title = "工号", dataIndex = "workcode", key = "workcode") + private String workcode; + +} diff --git a/src/com/engine/salary/entity/extemp/param/ExtEmpImportParam.java b/src/com/engine/salary/entity/extemp/param/ExtEmpImportParam.java new file mode 100644 index 000000000..f30f4f758 --- /dev/null +++ b/src/com/engine/salary/entity/extemp/param/ExtEmpImportParam.java @@ -0,0 +1,22 @@ +package com.engine.salary.entity.extemp.param; + +import com.engine.salary.util.valid.DataCheck; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Author: sy + * @Description: 非系统人员导入参数 + * @Date: 2023/7/26 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class ExtEmpImportParam { + //上传文件id + @DataCheck(require = true,message = "imageId为空") + String imageId; +} diff --git a/src/com/engine/salary/entity/extemp/param/ExtEmpQueryParam.java b/src/com/engine/salary/entity/extemp/param/ExtEmpQueryParam.java new file mode 100644 index 000000000..ac68f247f --- /dev/null +++ b/src/com/engine/salary/entity/extemp/param/ExtEmpQueryParam.java @@ -0,0 +1,27 @@ +package com.engine.salary.entity.extemp.param; + +import com.engine.salary.common.BaseQueryParam; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 数据采集-累计专项附加扣除查询参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class ExtEmpQueryParam extends BaseQueryParam { + + //姓名 + private String username; + + +} diff --git a/src/com/engine/salary/entity/extemp/param/ExtEmpSaveParam.java b/src/com/engine/salary/entity/extemp/param/ExtEmpSaveParam.java new file mode 100644 index 000000000..f38362d8a --- /dev/null +++ b/src/com/engine/salary/entity/extemp/param/ExtEmpSaveParam.java @@ -0,0 +1,101 @@ +package com.engine.salary.entity.extemp.param; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 数据采集-累计专项附加扣除查询参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class ExtEmpSaveParam { + + private Long id; + + /** + * 姓名 + */ + private String username; + /** + * 部门 + */ + private String departmentName; + /** + * 部门ID + */ + private Long departmentId; + /** + * 分部 + */ + private String subcompanyName; + /** + * 分部ID + */ + private Long subcompanyId; + /** + * 岗位 + */ + private String jobtitleName; + /** + * 岗位ID + */ + private Long jobtitleId; + /** + * 入职日期 + */ + private String companystartdate; + /** + * 手机 + */ + private String mobile; + /** + * 状态编码 + */ + private String status; + /** + * 工号 + */ + private String workcode; + /** + * 性别 + */ + private String sex; + /** + * 邮件 + */ + private String email; + /** + * 电话 + */ + private String telephone; + /** + * 职称 + */ + private String jobcall; + /** + * 出生日期 + */ + private String birthday; + /** + * 身份证号码 + */ + private String idNo; + /** + * 本人开户的银行卡卡号 + */ + private String bankCardNum; + /** + * 本人开户的银行卡开户支行全称 + */ + private String bankName; + +} diff --git a/src/com/engine/salary/entity/extemp/po/ExtEmpPO.java b/src/com/engine/salary/entity/extemp/po/ExtEmpPO.java new file mode 100644 index 000000000..221739f26 --- /dev/null +++ b/src/com/engine/salary/entity/extemp/po/ExtEmpPO.java @@ -0,0 +1,192 @@ +package com.engine.salary.entity.extemp.po; + + +import com.engine.salary.annotation.TableTitle; +import com.engine.hrmelog.annotation.ElogTransform; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.Date; + +/** + * 外部人员 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//hrsa_external_employee +@ElogTransform( name = "非系统人员") +public class ExtEmpPO { + + @ElogTransform(name = "主键id") + private Long id; + + /** + * 姓名 + */ + @TableTitle(title = "姓名", dataIndex = "username", key = "username") + @ElogTransform(name = "姓名") + private String username; + + /** + * 部门 + */ + @TableTitle(title = "部门", dataIndex = "departmentName", key = "departmentName") + @ElogTransform(name = "部门") + private String departmentName; + + /** + * 部门ID + */ + @ElogTransform(name = "部门ID") + private Long departmentId; + + /** + * 分部 + */ + + @TableTitle(title = "分部", dataIndex = "subcompanyName", key = "subcompanyName") + @ElogTransform(name = "分部") + private String subcompanyName; + + /** + * 分部ID + */ + @ElogTransform(name = "分部ID") + private Long subcompanyId; + + /** + * 岗位 + */ +// @TableTitle(title = "岗位", dataIndex = "jobtitleName", key = "jobtitleName") + @ElogTransform(name = "岗位") + private String jobtitleName; + + /** + * 岗位ID + */ + @ElogTransform(name = "岗位ID") + private Long jobtitleId; + + /** + * 入职日期 + */ + @TableTitle(title = "入职日期", dataIndex = "companystartdate", key = "companystartdate") + @ElogTransform(name = "入职日期") + private String companystartdate; + + /** + * 手机 + */ + @ElogTransform(name = "手机") + private String mobile; + + /** + * 状态编码 + */ + @ElogTransform(name = "状态编码") + private String status; + + /** + * 工号 + */ + @TableTitle(title = "工号", dataIndex = "workcode", key = "workcode") + @ElogTransform(name = "工号") + private String workcode; + + /** + * 性别 + */ + @ElogTransform(name = "性别") + private String sex; + + /** + * 邮件 + */ + @ElogTransform(name = "邮件") + private String email; + + /** + * 电话 + */ + @ElogTransform(name = "电话") + private String telephone; + + /** + * 职称 + */ + @ElogTransform(name = "职称") + private String jobcall; + + /** + * 出生日期 + */ + @ElogTransform(name = "出生日期") + private String birthday; + + /** + * 身份证号码 + */ + @ElogTransform(name = "身份证号码") + private String idNo; + + /** + * 本人开户的银行卡卡号 + */ + @ElogTransform(name = "本人开户的银行卡卡号") + private String bankCardNum; + + /** + * 本人开户的银行卡开户支行全称 + */ + @ElogTransform(name = "本人开户的银行卡开户支行全称") + private String bankName; + + /** + * 是否已删除。0:未删除、1:已删除 + */ + @ElogTransform(name = "是否已删除") + private Integer deleteType; + + /** + * 创建人 + */ + @ElogTransform(name = "创建人") + private Long creator; + + /** + * 修改人 + */ + @ElogTransform(name = "修改人") + private Long modifier; + + /** + * 创建时间 + */ + @ElogTransform(name = "创建时间") + private Date createTime; + + /** + * 修改时间 + */ + @ElogTransform(name = "修改时间") + private Date updateTime; + + /** + * 租户ID + */ + @ElogTransform(name = "租户ID") + private String tenantKey; + + private Collection ids; + private Collection subcompanyIds; + private Collection departmentIds; + + + private String departmentOrgName; + private String subcompanyOrgName; +} diff --git a/src/com/engine/salary/entity/hrm/DeptInfo.java b/src/com/engine/salary/entity/hrm/DeptInfo.java new file mode 100644 index 000000000..c9b6876ef --- /dev/null +++ b/src/com/engine/salary/entity/hrm/DeptInfo.java @@ -0,0 +1,35 @@ +package com.engine.salary.entity.hrm; + +import com.engine.salary.annotation.I18n; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 部门基本信息 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class DeptInfo { + + private Long id; + + /** + * 名称 + */ + @I18n + private String name; + + /** + * 所属分部id + */ + private Long subcompanyid1; +} diff --git a/src/com/engine/salary/entity/hrm/HrmStatus.java b/src/com/engine/salary/entity/hrm/HrmStatus.java new file mode 100644 index 000000000..26fbdb755 --- /dev/null +++ b/src/com/engine/salary/entity/hrm/HrmStatus.java @@ -0,0 +1,16 @@ +package com.engine.salary.entity.hrm; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class HrmStatus { + String id; + + String name; +} diff --git a/src/com/engine/salary/entity/hrm/JobCallInfo.java b/src/com/engine/salary/entity/hrm/JobCallInfo.java new file mode 100644 index 000000000..246ba1423 --- /dev/null +++ b/src/com/engine/salary/entity/hrm/JobCallInfo.java @@ -0,0 +1,32 @@ +package com.engine.salary.entity.hrm; + +import com.engine.salary.annotation.I18n; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 职称基本信息 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class JobCallInfo { + + private Long id; + + /** + * 名称 + */ + @I18n + private String name; + + +} diff --git a/src/com/engine/salary/entity/hrm/PositionInfo.java b/src/com/engine/salary/entity/hrm/PositionInfo.java new file mode 100644 index 000000000..2eb787624 --- /dev/null +++ b/src/com/engine/salary/entity/hrm/PositionInfo.java @@ -0,0 +1,32 @@ +package com.engine.salary.entity.hrm; + +import com.engine.salary.annotation.I18n; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 岗位基本信息 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class PositionInfo { + + private Long id; + + /** + * 名称 + */ + @I18n + private String name; + + +} diff --git a/src/com/engine/salary/entity/hrm/SubCompanyInfo.java b/src/com/engine/salary/entity/hrm/SubCompanyInfo.java new file mode 100644 index 000000000..e9e2637d3 --- /dev/null +++ b/src/com/engine/salary/entity/hrm/SubCompanyInfo.java @@ -0,0 +1,30 @@ +package com.engine.salary.entity.hrm; + +import com.engine.salary.annotation.I18n; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 分部信息 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SubCompanyInfo { + + private Long id; + + /** + * 名称 + */ + @I18n + private String name; +} diff --git a/src/com/engine/salary/entity/hrm/dto/EmployeeInfoExpandDTO.java b/src/com/engine/salary/entity/hrm/dto/EmployeeInfoExpandDTO.java new file mode 100644 index 000000000..f24cbffc6 --- /dev/null +++ b/src/com/engine/salary/entity/hrm/dto/EmployeeInfoExpandDTO.java @@ -0,0 +1,53 @@ +package com.engine.salary.entity.hrm.dto; + +import com.engine.salary.util.valid.Modify; +import com.engine.salary.util.valid.ModifyTypeEnum; +import com.engine.salary.util.valid.ValueTypeEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * 人员扩展参数 + *

Copyright: Copyright (c) 2023

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class EmployeeInfoExpandDTO { + + private Long id; + /** + * 功能模块 + */ + private String module; + /** + * 模块信息 + */ + private String moduleInfo; + /** + * 主键 + */ + private String pk; + + /** + * sql + */ + @Modify(modifyType = ModifyTypeEnum.RESTORE_SQL) + private String expandSql; + + /** + * 字段设置 + */ + @Modify(valueType = ValueTypeEnum.ARRAY) + private List fieldSettings; + +} diff --git a/src/com/engine/salary/entity/hrm/dto/FieldSetting.java b/src/com/engine/salary/entity/hrm/dto/FieldSetting.java new file mode 100644 index 000000000..1174b59ae --- /dev/null +++ b/src/com/engine/salary/entity/hrm/dto/FieldSetting.java @@ -0,0 +1,35 @@ +package com.engine.salary.entity.hrm.dto; + +import com.engine.salary.util.valid.Modify; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class FieldSetting { + + /** + * 字段 + */ + @Modify() + private String field; + + /** + * 显示 + */ + private String name; + + /** + * 值 + */ + private String value; + + /** + * 排序 + */ + private Integer index; +} diff --git a/src/com/engine/salary/entity/hrm/dto/HrmInfoDTO.java b/src/com/engine/salary/entity/hrm/dto/HrmInfoDTO.java new file mode 100644 index 000000000..f378fe85b --- /dev/null +++ b/src/com/engine/salary/entity/hrm/dto/HrmInfoDTO.java @@ -0,0 +1,26 @@ +package com.engine.salary.entity.hrm.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Author: sy + * @Description: 人员信息列表 + * @Date: 2022/11/21 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class HrmInfoDTO { + //员工id + private Long employeeId; + + //姓名 + private String username; + + + private Long target; +} diff --git a/src/com/engine/salary/entity/hrm/param/HrmQueryParam.java b/src/com/engine/salary/entity/hrm/param/HrmQueryParam.java new file mode 100644 index 000000000..0e6da1aa6 --- /dev/null +++ b/src/com/engine/salary/entity/hrm/param/HrmQueryParam.java @@ -0,0 +1,30 @@ +package com.engine.salary.entity.hrm.param; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; + +/** + * @Author: sy + * @Description: 人员查询 + * @Date: 2022/11/21 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class HrmQueryParam { + + private String userName; + + private int pageNum; + private int pageSize; + + private Collection ids; + + private String billMonth; + private Long paymentOrganization; +} diff --git a/src/com/engine/salary/entity/hrm/po/ExpandFieldSettingsPO.java b/src/com/engine/salary/entity/hrm/po/ExpandFieldSettingsPO.java new file mode 100644 index 000000000..8908ab69f --- /dev/null +++ b/src/com/engine/salary/entity/hrm/po/ExpandFieldSettingsPO.java @@ -0,0 +1,74 @@ +package com.engine.salary.entity.hrm.po; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.Date; + +/** + * 人员维度扩展表 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class ExpandFieldSettingsPO { + private Long id; + + /** + * 功能模块 + */ + private String module; + + /** + * 模块信息 + */ + private String moduleInfo; + + /** + * 主键 + */ + private String pk; + + /** + * sql + */ + private String expandSql; + + /** + * 字段设置 + */ + private String fieldSetting; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 更新时间 + */ + private Date updateTime; + + /** + * 创建人 + */ + private Long creator; + + /** + * 是否已删除。0:未删除、1:已删除 + */ + private Integer deleteType; + + /** + * 租户ID + */ + private String tenantKey; + + //主键id集合 + private Collection ids; + +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/hrm/po/HrmSnapshotPO.java b/src/com/engine/salary/entity/hrm/po/HrmSnapshotPO.java new file mode 100644 index 000000000..48411733a --- /dev/null +++ b/src/com/engine/salary/entity/hrm/po/HrmSnapshotPO.java @@ -0,0 +1,434 @@ +package com.engine.salary.entity.hrm.po; + +import com.engine.hrmelog.annotation.ElogTransform; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.math.BigDecimal; +import java.util.Collection; +import java.util.Date; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class HrmSnapshotPO { + + @ElogTransform(name = "id") + private Long id; + + /** + * 快照时间 + */ + @ElogTransform(name = "快照时间") + private Date snapshotTime; + + + /** + * 人员id + */ + @ElogTransform(name = "人员id") + private Long employeeId; + + /** + * 姓名 + */ + @ElogTransform(name = "姓名") + private String lastname; + + + /** + * 工资帐号1 + */ + @ElogTransform(name = "工资帐号1") + private String accountid1; + + /** + * 工资账号户名 + */ + @ElogTransform(name = "工资账号户名") + private String accountname; + + /** + * 帐号类型 + */ + @ElogTransform(name = "帐号类型") + private Integer accounttype; + + /** + * 公积金帐号 + */ + @ElogTransform(name = "公积金帐号") + private String accumfundaccount; + + /** + * 助理 + */ + @ElogTransform(name = "助理") + private Integer assistantid; + + /** + * 工资银行1 + */ + @ElogTransform(name = "工资银行1") + private Integer bankid1; + + /** + * 所属主帐号 + */ + @ElogTransform(name = "所属主帐号") + private Integer belongto; + + /** + * 入团时间 + */ + @ElogTransform(name = "入团时间") + private String bememberdate; + + /** + * 入党时间 + */ + @ElogTransform(name = "入党时间") + private String bepartydate; + + /** + * 生日 + */ + @ElogTransform(name = "生日") + private String birthday; + + /** + * 出生地 + */ + @ElogTransform(name = "出生地") + private String birthplace; + + /** + * 身份证号码 + */ + @ElogTransform(name = "身份证号码") + private String certificatenum; + + /** + * 公司开始日期 + */ + @ElogTransform(name = "公司开始日期") + private String companystartdate; + + /** + * 公司年限 + */ + @ElogTransform(name = "公司年限") + private BigDecimal companyworkyear; + + /** + * 所属成本中心 + */ + @ElogTransform(name = "所属成本中心") + private Integer costcenterid; + + /** + * 国家id + */ + @ElogTransform(name = "国家id") + private Integer countryid; + + /** + * 学位 + */ + @ElogTransform(name = "学位") + private String degree; + + /** + * 所属部门 + */ + @ElogTransform(name = "所属部门") + private Integer departmentid; + + /** + * 部门名称 + */ + @ElogTransform(name = "部门名称") + private String departmentname; + + /** + * 学历 + */ + @ElogTransform(name = "学历") + private Integer educationlevel; + + /** + * 电子邮件 + */ + @ElogTransform(name = "电子邮件") + private String email; + + + /** + * 合同结束日期 + */ + @ElogTransform(name = "合同结束日期") + private String enddate; + + /** + * 分机 + */ + @ElogTransform(name = "分机") + private String extphone; + + /** + * 传真 + */ + @ElogTransform(name = "传真") + private String fax; + + /** + * 民族 + */ + @ElogTransform(name = "民族") + private String folk; + + /** + * 健康状况 + */ + @ElogTransform(name = "健康状况") + private String healthinfo; + + /** + * 家庭住址 + */ + @ElogTransform(name = "家庭住址") + private String homeaddress; + + + /** + * 是否为工会会员 + */ + @ElogTransform(name = "是否为工会会员") + private String islabouunion; + + /** + * 职责描述 + */ + @ElogTransform(name = "职责描述") + private String jobactivitydesc; + + /** + * 职称 + */ + @ElogTransform(name = "职称") + private Integer jobcall; + + /** + * 职称名称 + */ + @ElogTransform(name = "职称名称") + private String jobcallname; + + /** + * 工作级别 + */ + @ElogTransform(name = "工作级别") + private Integer joblevel; + + /** + * 岗位 + */ + @ElogTransform(name = "岗位") + private Integer jobtitle; + + /** + * 岗位名称 + */ + @ElogTransform(name = "岗位名称") + private String jobtitlename; + + /** + * 最后登陆日期 + */ + @ElogTransform(name = "最后登陆日期") + private String lastlogindate; + + /** + * 工作地点 + */ + @ElogTransform(name = "工作地点") + private Integer locationid; + + /** + * 系统登陆帐号 + */ + @ElogTransform(name = "系统登陆帐号") + private String loginid; + + /** + * 经理 + */ + @ElogTransform(name = "经理") + private Integer managerid; + + /** + * 所有上级 + */ + @ElogTransform(name = "所有上级") + private String managerstr; + + /** + * 婚姻状况 + */ + @ElogTransform(name = "婚姻状况") + private String maritalstatus; + + /** + * 手机 + */ + @ElogTransform(name = "手机") + private String mobile; + + /** + * 其他电话 + */ + @ElogTransform(name = "其他电话") + private String mobilecall; + + /** + * 国籍 + */ + @ElogTransform(name = "国籍") + private Integer nationality; + + /** + * 籍贯 + */ + @ElogTransform(name = "籍贯") + private String nativeplace; + + /** + * 政治面貌 + */ + @ElogTransform(name = "政治面貌") + private String policy; + + /** + * 试用期结束日期 + */ + @ElogTransform(name = "试用期结束日期") + private String probationenddate; + + /** + * 户口 + */ + @ElogTransform(name = "户口") + private String regresidentplace; + + /** + * 居住地电话 + */ + @ElogTransform(name = "居住地电话") + private String residentphone; + + /** + * 居住地 + */ + @ElogTransform(name = "居住地") + private String residentplace; + + /** + * 居住地邮编 + */ + @ElogTransform(name = "居住地邮编") + private String residentpostcode; + + /** + * 用户类别 + */ + @ElogTransform(name = "用户类别") + private String resourcetype; + + /** + * 安全级别 + */ + @ElogTransform(name = "安全级别") + private Integer seclevel; + + /** + * 性别 + */ + @ElogTransform(name = "性别") + private String sex; + + + + /** + * 合同开始日期 + */ + @ElogTransform(name = "合同开始日期") + private String startdate; + + /** + * 0:试用
1:正式
2:临时
3:试用延期
4:解聘
5:离职
6:退休
7:无效 + */ + @ElogTransform(name = " 0:试用
1:正式
2:临时
3:试用延期
4:解聘
5:离职
6:退休
7:无效") + private Integer status; + + /** + * 所属分部1 + */ + @ElogTransform(name = "所属分部1") + private Integer subcompanyid1; + + /** + * 分部名称 + */ + @ElogTransform(name = "分部名称") + private String subcompanyname; + + /** + * 电话 + */ + @ElogTransform(name = "电话") + private String telephone; + + /** + * 暂住证号码 + */ + @ElogTransform(name = "暂住证号码") + private String tempresidentnumber; + + /** + * 用工性质 + */ + @ElogTransform(name = "用工性质") + private Integer usekind; + + /** + * 编号 + */ + @ElogTransform(name = "编号") + private String workcode; + + /** + * 办公室 + */ + @ElogTransform(name = "办公室") + private String workroom; + + /** + * 工作开始日期 + */ + @ElogTransform(name = "工作开始日期") + private String workstartdate; + + /** + * 工作年限 + */ + @ElogTransform(name = "工作年限") + private BigDecimal workyear; + + + //主键id集合 + private Collection ids; + +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/process/dto/SalaryAdjustmentDTO.java b/src/com/engine/salary/entity/process/dto/SalaryAdjustmentDTO.java new file mode 100644 index 000000000..d1d1d0544 --- /dev/null +++ b/src/com/engine/salary/entity/process/dto/SalaryAdjustmentDTO.java @@ -0,0 +1,18 @@ +package com.engine.salary.entity.process.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalaryAdjustmentDTO { + + private String isShow; + + private String url; + +} diff --git a/src/com/engine/salary/entity/progress/ProgressDTO.java b/src/com/engine/salary/entity/progress/ProgressDTO.java new file mode 100644 index 000000000..1401eaaef --- /dev/null +++ b/src/com/engine/salary/entity/progress/ProgressDTO.java @@ -0,0 +1,66 @@ +package com.engine.salary.entity.progress; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.io.Serializable; +import java.math.BigDecimal; + +/** + * 进度 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@Accessors(chain = true) +@NoArgsConstructor +@AllArgsConstructor +public class ProgressDTO implements Serializable { + + /** + * 当前步骤名称 + */ + private String title; + + /** + * 当前步骤名称的labelId + */ + private Long titleLabelId; + + /** + * 全部数量 + */ + private Integer totalQuantity; + + /** + * 已计算数量 + */ + private Integer calculatedQuantity; + + /** + * 进度百分比 + */ + private BigDecimal progress; + + /** + * true:计算正常、false:计算出错 + */ + private boolean status; + + /** + * 计算出错时的错误信息 + */ + private String message; + + /** + * 是否存在校验异常 + */ + private boolean checkStatus; +} diff --git a/src/com/engine/salary/entity/push/dto/PushRecordDTO.java b/src/com/engine/salary/entity/push/dto/PushRecordDTO.java new file mode 100644 index 000000000..74df0f8d4 --- /dev/null +++ b/src/com/engine/salary/entity/push/dto/PushRecordDTO.java @@ -0,0 +1,116 @@ +package com.engine.salary.entity.push.dto; + +import com.engine.hrmelog.annotation.ElogTransform; +import com.engine.salary.annotation.TableTitle; +import com.engine.salary.enums.push.PushRecordStatusEnum; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.Date; + +/** + * 数据推送记录列表 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class PushRecordDTO { + + @ElogTransform(name = "") + private Long id; + + + /** + * 记录名 + */ + @TableTitle(title = "记录名", dataIndex = "name", key = "name") + private String name; + + + /** + * 核算记录id + */ + private Long acctRecordId; + + + /** + * 推送配置id + */ + private Long settingId; + + /** + * 建模id + */ + private Integer modeId; + + /** + * 数据库表名 + */ + @TableTitle(title = "数据表名", dataIndex = "tableName", key = "tableName") + private String tableName; + + + /** + * 推送状态 + * + * @see PushRecordStatusEnum + */ + @TableTitle(title = "推送状态", dataIndex = "statusName", key = "statusName") + private String statusName; + private Integer status; + + /** + * 执行时间 + */ + @TableTitle(title = "执行开始时间", dataIndex = "startTime", key = "startTime") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date startTime; + + /** + * 结束时间 + */ + @TableTitle(title = "执行结束时间", dataIndex = "endTime", key = "endTime") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date endTime; + + + /** + * 推送类型,0推送,1撤回 + */ + private Integer type; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 创建人 + */ + private Long creator; + + /** + * 是否已删除。0:未删除、1:已删除 + */ + private Integer deleteType; + + /** + * 租户ID + */ + private String tenantKey; + + /** + * 更新时间 + */ + private Date updateTime; + + + //主键id集合 + private Collection ids; + +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/push/dto/PushRecordDetailDTO.java b/src/com/engine/salary/entity/push/dto/PushRecordDetailDTO.java new file mode 100644 index 000000000..de9d56fe5 --- /dev/null +++ b/src/com/engine/salary/entity/push/dto/PushRecordDetailDTO.java @@ -0,0 +1,94 @@ +package com.engine.salary.entity.push.dto; + +import com.engine.hrmelog.annotation.ElogTransform; +import com.engine.salary.annotation.TableTitle; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.Date; + +/** + * 数据推送配置 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class PushRecordDetailDTO { + + + @ElogTransform(name = "id") + private Long id; + + /** + * 推送记录id + */ + private Long recordId; + + /** + * 核算人员id + */ + private Long acctEmpId; + + @TableTitle(title = "人员", dataIndex = "username",key = "username") + private String username; + + /** + * 执行状态 + * @see com.engine.salary.enums.push.PushRecordDetailStatusEnum + */ + @TableTitle(title = "执行状态", dataIndex = "statusName",key = "statusName") + private String statusName; + private Integer status; + + /** + * 失败原因 + */ + @TableTitle(title = "失败原因", dataIndex = "fail_reason",key = "status") + private String failReason; + + /** + * 执行sql + */ + @ElogTransform(name = "执行sql") + private String execute; + + /** + * 创建时间 + */ + @ElogTransform(name = "创建时间") + private Date createTime; + + /** + * 创建人 + */ + @ElogTransform(name = "创建人") + private Long creator; + + /** + * 是否已删除。0:未删除、1:已删除 + */ + @ElogTransform(name = "是否已删除。0:未删除、1:已删除") + private Integer deleteType; + + + /** + * 租户ID + */ + @ElogTransform(name = "租户ID") + private String tenantKey; + + /** + * 更新时间 + */ + @ElogTransform(name = "更新时间") + private Date updateTime; + + + //主键id集合 + private Collection ids; + +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/push/dto/PushSettingDTO.java b/src/com/engine/salary/entity/push/dto/PushSettingDTO.java new file mode 100644 index 000000000..114d6fa5b --- /dev/null +++ b/src/com/engine/salary/entity/push/dto/PushSettingDTO.java @@ -0,0 +1,61 @@ +package com.engine.salary.entity.push.dto; + +import com.engine.hrmelog.annotation.ElogTransform; +import com.engine.salary.annotation.TableTitle; +import com.engine.salary.entity.salarysob.po.SalarySobPO; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * 数据推送配置 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class PushSettingDTO { + + @ElogTransform(name = "") + private Long id; + + + + @TableTitle(title = "任务名称", key = "name", dataIndex = "name") + private String name; + + /** + * 是否启用,0否 1是 + */ + @TableTitle(title = "是否启用", key = "able", dataIndex = "able") + private Integer able; + + + /** + * 薪资帐套集合 + */ + @TableTitle(title = "薪资帐套集合", key = "salarySobs", dataIndex = "salarySobs") + private List salarySobs; + + /** + * 建模id + */ + @TableTitle(title = "建模id", key = "modeId", dataIndex = "modeId") + private Integer modeId; + + /** + * 模块名称 + */ + @TableTitle(title = "模块名称", key = "modeName", dataIndex = "modeName") + private String modeName; + + /** + * 数据库表 + */ + @TableTitle(title = "数据库表名", key = "tableName", dataIndex = "tableName") + private String tableName; + +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/push/dto/PushSettingItemDTO.java b/src/com/engine/salary/entity/push/dto/PushSettingItemDTO.java new file mode 100644 index 000000000..22c8832d6 --- /dev/null +++ b/src/com/engine/salary/entity/push/dto/PushSettingItemDTO.java @@ -0,0 +1,65 @@ +package com.engine.salary.entity.push.dto; + +import com.engine.salary.annotation.TableTitle; +import com.engine.salary.enums.push.PushItemFieldEnum; +import com.engine.salary.enums.salaryformula.SalarySQLReferenceEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 数据推送配置明细 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class PushSettingItemDTO { + + + private Long id; + + /** + * 设置id + */ + private Long settingId; + + /** + * 项目 + */ + private String item; + + /** + * 项目名 + */ + @TableTitle(title = "项目名", dataIndex = "itemName", key = "itemName") + private String itemName; + + /** + * 项目类型 + * @see SalarySQLReferenceEnum + */ + private String source; + + private String sourceName; + + /** + * 数据库字段 + */ + @TableTitle(title = "数据库字段", dataIndex = "fieldName", key = "fieldName") + private String fieldName; + + /** + * 字段类型 + * @see PushItemFieldEnum + */ + private PushItemFieldEnum fieldType; + + @TableTitle(title = "字段类型", dataIndex = "fieldTypeName", key = "fieldTypeName") + private String fieldTypeName; + + @TableTitle(title = "排序", dataIndex = "sortedIndex", key = "sortedIndex") + private Integer sortedIndex; + +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/push/param/CreatePushParam.java b/src/com/engine/salary/entity/push/param/CreatePushParam.java new file mode 100644 index 000000000..5ef10fef4 --- /dev/null +++ b/src/com/engine/salary/entity/push/param/CreatePushParam.java @@ -0,0 +1,29 @@ +package com.engine.salary.entity.push.param; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + + +/** + * 创建推送记录 + *

Copyright: Copyright (c) 2024

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class CreatePushParam { + + + private List salaryAcctRecordIds; + + +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/push/param/PushParam.java b/src/com/engine/salary/entity/push/param/PushParam.java new file mode 100644 index 000000000..36aefd747 --- /dev/null +++ b/src/com/engine/salary/entity/push/param/PushParam.java @@ -0,0 +1,20 @@ +package com.engine.salary.entity.push.param; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class PushParam { + + + private List ids; + +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/push/param/PushSettingItemQueryParam.java b/src/com/engine/salary/entity/push/param/PushSettingItemQueryParam.java new file mode 100644 index 000000000..a24bc3b40 --- /dev/null +++ b/src/com/engine/salary/entity/push/param/PushSettingItemQueryParam.java @@ -0,0 +1,22 @@ +package com.engine.salary.entity.push.param; + +import com.engine.salary.common.BaseQueryParam; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 数据推送配置 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class PushSettingItemQueryParam extends BaseQueryParam { + + private Long settingId; + + + +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/push/param/PushSettingItemSaveParam.java b/src/com/engine/salary/entity/push/param/PushSettingItemSaveParam.java new file mode 100644 index 000000000..d095b9697 --- /dev/null +++ b/src/com/engine/salary/entity/push/param/PushSettingItemSaveParam.java @@ -0,0 +1,71 @@ +package com.engine.salary.entity.push.param; + +import com.engine.salary.enums.push.PushItemFieldEnum; +import com.engine.salary.enums.salaryformula.SalarySQLReferenceEnum; +import com.engine.salary.util.valid.DataCheck; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; + +/** + * 数据推送配置明细 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class PushSettingItemSaveParam { + + + private Long id; + + /** + * 设置id + */ + @DataCheck(require = true, message = "设置id为空") + private Long settingId; + + /** + * 项目 + */ + @DataCheck(require = true, message = "项目为空") + private String item; + + /** + * 项目名 + */ + @DataCheck(require = true, message = "项目名为空") + private String itemName; + + /** + * 项目类型 + * @see SalarySQLReferenceEnum + */ + @DataCheck(require = true, message = "数据来源") + private String source; + + /** + * 数据库字段 + */ + @DataCheck(require = true, message = "数据库字段为空") + private String fieldName; + + /** + * 字段类型 + */ + @DataCheck(require = true, message = "字段类型为空") + private PushItemFieldEnum fieldType; + + /** + * 排序 + */ + private Integer sortedIndex; + + + //主键id集合 + private Collection ids; + +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/push/param/PushSettingQueryParam.java b/src/com/engine/salary/entity/push/param/PushSettingQueryParam.java new file mode 100644 index 000000000..8d0a96e10 --- /dev/null +++ b/src/com/engine/salary/entity/push/param/PushSettingQueryParam.java @@ -0,0 +1,28 @@ +package com.engine.salary.entity.push.param; + +import com.engine.salary.common.BaseQueryParam; +import com.engine.salary.util.valid.DataCheck; +import com.engine.salary.util.valid.ValidTypeEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 数据推送配置 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class PushSettingQueryParam extends BaseQueryParam { + + + /** + * 任务名称 + */ + @DataCheck(require = true, type = ValidTypeEnum.STRING, max = 50, labelId = 86185, message = "任务名称为空") + private String name; + + +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/push/param/PushSettingSaveParam.java b/src/com/engine/salary/entity/push/param/PushSettingSaveParam.java new file mode 100644 index 000000000..cdc28d327 --- /dev/null +++ b/src/com/engine/salary/entity/push/param/PushSettingSaveParam.java @@ -0,0 +1,59 @@ +package com.engine.salary.entity.push.param; + +import com.engine.salary.util.valid.DataCheck; +import com.engine.salary.util.valid.ValidTypeEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * 数据推送配置 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class PushSettingSaveParam { + + private Long id; + + /** + * 任务名称 + */ + @DataCheck(require = true, type = ValidTypeEnum.STRING, max = 50, labelId = 86185, message = "任务名称为空") + private String name; + + /** + * 是否启用,0否 1是 + */ + @DataCheck(require = true, type = ValidTypeEnum.NUMBER, message = "是否启用为空") + private Integer able; + + + /** + * 薪资帐套集合 + */ + private List salarySobIds; + + /** + * 建模id + */ + private Integer modeId; + + /** + * 模块名称 + */ + private String modeName; + + + /** + * 数据库表 + */ + @DataCheck(require = true, message = "数据库表为空") + private String tableName; + + +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/push/param/RecordDetailListQueryParam.java b/src/com/engine/salary/entity/push/param/RecordDetailListQueryParam.java new file mode 100644 index 000000000..7a4619d2d --- /dev/null +++ b/src/com/engine/salary/entity/push/param/RecordDetailListQueryParam.java @@ -0,0 +1,22 @@ +package com.engine.salary.entity.push.param; + +import com.engine.salary.common.BaseQueryParam; +import com.engine.salary.util.valid.DataCheck; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class RecordDetailListQueryParam extends BaseQueryParam { + + @DataCheck(require = true, message = "推送记录id不能为空") + private Long recordId; + + private String name; + +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/push/param/RecordListQueryParam.java b/src/com/engine/salary/entity/push/param/RecordListQueryParam.java new file mode 100644 index 000000000..0dfe41108 --- /dev/null +++ b/src/com/engine/salary/entity/push/param/RecordListQueryParam.java @@ -0,0 +1,17 @@ +package com.engine.salary.entity.push.param; + +import com.engine.salary.common.BaseQueryParam; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class RecordListQueryParam extends BaseQueryParam { + private String name; + +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/push/param/WithdrawParam.java b/src/com/engine/salary/entity/push/param/WithdrawParam.java new file mode 100644 index 000000000..2535db525 --- /dev/null +++ b/src/com/engine/salary/entity/push/param/WithdrawParam.java @@ -0,0 +1,20 @@ +package com.engine.salary.entity.push.param; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WithdrawParam { + + + private List ids; + +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/push/param/WithdrawPushParam.java b/src/com/engine/salary/entity/push/param/WithdrawPushParam.java new file mode 100644 index 000000000..cc0915bc2 --- /dev/null +++ b/src/com/engine/salary/entity/push/param/WithdrawPushParam.java @@ -0,0 +1,29 @@ +package com.engine.salary.entity.push.param; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + + +/** + * 创建推送记录 + *

Copyright: Copyright (c) 2024

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WithdrawPushParam { + + + private List ids; + + +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/push/po/PushRecordDetailPO.java b/src/com/engine/salary/entity/push/po/PushRecordDetailPO.java new file mode 100644 index 000000000..88308a8b6 --- /dev/null +++ b/src/com/engine/salary/entity/push/po/PushRecordDetailPO.java @@ -0,0 +1,96 @@ +package com.engine.salary.entity.push.po; + +import com.engine.hrmelog.annotation.ElogTransform; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.Date; + +/** + * 数据推送配置 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class PushRecordDetailPO { + + + @ElogTransform(name = "id") + private Long id; + + /** + * 推送记录id + */ + @ElogTransform(name = "推送记录id") + private Long recordId; + + /** + * 核算人员id + */ + @ElogTransform(name = "核算人员id") + private Long acctEmpId; + + /** + * 核算人员id + */ + private Long dataId; + + /** + * 执行状态 + * @see com.engine.salary.enums.push.PushRecordDetailStatusEnum + */ + @ElogTransform(name = "执行状态") + private Integer status; + + /** + * 失败原因 + */ + @ElogTransform(name = "失败原因") + private String failReason; + + /** + * 执行sql + */ + @ElogTransform(name = "执行sql") + private String formula; + + /** + * 创建时间 + */ + @ElogTransform(name = "创建时间") + private Date createTime; + + /** + * 创建人 + */ + @ElogTransform(name = "创建人") + private Long creator; + + /** + * 是否已删除。0:未删除、1:已删除 + */ + @ElogTransform(name = "是否已删除。0:未删除、1:已删除") + private Integer deleteType; + + + /** + * 租户ID + */ + @ElogTransform(name = "租户ID") + private String tenantKey; + + /** + * 更新时间 + */ + @ElogTransform(name = "更新时间") + private Date updateTime; + + + //主键id集合 + private Collection ids; + +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/push/po/PushRecordPO.java b/src/com/engine/salary/entity/push/po/PushRecordPO.java new file mode 100644 index 000000000..a0ed7080a --- /dev/null +++ b/src/com/engine/salary/entity/push/po/PushRecordPO.java @@ -0,0 +1,123 @@ +package com.engine.salary.entity.push.po; + +import com.engine.hrmelog.annotation.ElogTransform; +import com.engine.salary.enums.push.PushRecordStatusEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.Date; + +/** + * 数据推送配置 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class PushRecordPO { + + @ElogTransform(name = "id") + private Long id; + + /** + * 记录名 + */ + @ElogTransform(name = "记录名") + private String name; + + + /** + * 核算记录id + */ + @ElogTransform(name = "核算记录id") + private Long acctRecordId; + + + /** + * 推送配置id + */ + @ElogTransform(name = "推送配置id") + private Long settingId; + + /** + * 建模id + */ + private Integer modeId; + + /** + * 数据库表名 + */ + private String tableName; + + + /** + * 推送状态 + * @see PushRecordStatusEnum + */ + @ElogTransform(name = "推送状态") + private Integer status; + + /** + * 失败原因 + */ + @ElogTransform(name = "失败原因") + private String failReason; + + /** + * 开始时间 + */ + @ElogTransform(name = "开始时间") + private Date startTime; + + /** + * + */ + @ElogTransform(name = "结束时间") + private Date endTime; + + + + /** + * 推送类型 + */ + @ElogTransform(name = "推送类型") + private Integer type; + + /** + * 创建时间 + */ + @ElogTransform(name = "创建时间") + private Date createTime; + + /** + * 创建人 + */ + @ElogTransform(name = "创建人") + private Long creator; + + /** + * 是否已删除。0:未删除、1:已删除 + */ + @ElogTransform(name = "是否已删除。0:未删除、1:已删除") + private Integer deleteType; + + /** + * 租户ID + */ + @ElogTransform(name = "租户ID") + private String tenantKey; + + /** + * 更新时间 + */ + @ElogTransform(name = "更新时间") + private Date updateTime; + + + //主键id集合 + private Collection ids; + +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/push/po/PushSettingItemPO.java b/src/com/engine/salary/entity/push/po/PushSettingItemPO.java new file mode 100644 index 000000000..71b16e335 --- /dev/null +++ b/src/com/engine/salary/entity/push/po/PushSettingItemPO.java @@ -0,0 +1,103 @@ +package com.engine.salary.entity.push.po; + +import com.engine.hrmelog.annotation.ElogTransform; +import com.engine.salary.enums.push.PushItemFieldEnum; +import com.engine.salary.enums.salaryformula.SalarySQLReferenceEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.Date; + +/** + * 数据推送配置明细 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class PushSettingItemPO { + + + @ElogTransform(name = "") + private Long id; + + /** + * 设置id + */ + @ElogTransform(name = "设置id") + private Long settingId; + + /** + * 项目 + */ + @ElogTransform(name = "项目") + private String item; + + /** + * 项目名 + */ + @ElogTransform(name = "项目名") + private String itemName; + + /** + * 项目类型 + * @see SalarySQLReferenceEnum + */ + @ElogTransform(name = "项目类型") + private String source; + + /** + * 数据库字段 + */ + @ElogTransform(name = "数据库字段") + private String fieldName; + + /** + * 字段类型 + * @see PushItemFieldEnum + */ + @ElogTransform(name = "字段类型") + private Integer fieldType; + + + @ElogTransform(name = "排序") + private Integer sortedIndex; + + /** + * 租户ID + */ + @ElogTransform(name = "租户ID") + private String tenantKey; + + /** + * 更新时间 + */ + @ElogTransform(name = "更新时间") + private Date updateTime; + + /** + * 创建时间 + */ + @ElogTransform(name = "创建时间") + private Date createTime; + + /** + * 创建人 + */ + @ElogTransform(name = "创建人") + private Long creator; + + /** + * 是否已删除。0:未删除、1:已删除 + */ + @ElogTransform(name = "是否已删除。0:未删除、1:已删除") + private Integer deleteType; + + + //主键id集合 + private Collection ids; + +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/push/po/PushSettingPO.java b/src/com/engine/salary/entity/push/po/PushSettingPO.java new file mode 100644 index 000000000..a997593f9 --- /dev/null +++ b/src/com/engine/salary/entity/push/po/PushSettingPO.java @@ -0,0 +1,93 @@ +package com.engine.salary.entity.push.po; + +import com.engine.hrmelog.annotation.ElogTransform; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.Date; +import java.util.List; + +/** + * 数据推送配置 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class PushSettingPO { + + @ElogTransform(name = "") + private Long id; + + /** + * 是否启用,0否 1是 + */ + @ElogTransform(name = "是否启用,0否 1是") + private Integer able; + + + @ElogTransform(name = "任务名称") + private String name; + + /** + * 薪资帐套集合 + */ + @ElogTransform(name = "薪资帐套集合") + private List salarySobIds; + + /** + * 建模id + */ + @ElogTransform(name = "建模id") + private Integer modeId; + + /** + * 模块名称 + */ + @ElogTransform(name = "模块名称") + private String modeName; + + /** + * 数据库表 + */ + @ElogTransform(name = "数据库表") + private String tableName; + + /** + * 租户ID + */ + @ElogTransform(name = "租户ID") + private String tenantKey; + + /** + * 更新时间 + */ + @ElogTransform(name = "更新时间") + private Date updateTime; + + /** + * 创建时间 + */ + @ElogTransform(name = "创建时间") + private Date createTime; + + /** + * 创建人 + */ + @ElogTransform(name = "创建人") + private Long creator; + + /** + * 是否已删除。0:未删除、1:已删除 + */ + @ElogTransform(name = "是否已删除。0:未删除、1:已删除") + private Integer deleteType; + + + //主键id集合 + private Collection ids; + +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/report/bo/SalaryAcctResultReportBO.java b/src/com/engine/salary/entity/report/bo/SalaryAcctResultReportBO.java new file mode 100644 index 000000000..5b6c4d2c9 --- /dev/null +++ b/src/com/engine/salary/entity/report/bo/SalaryAcctResultReportBO.java @@ -0,0 +1,100 @@ +package com.engine.salary.entity.report.bo; + +import com.engine.salary.constant.SalaryDefaultTenantConstant; +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.report.po.SalaryAcctResultReportPO; +import com.engine.salary.entity.salaryacct.param.SalaryAcctResultSaveParam; +import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO; +import com.engine.salary.entity.salaryacct.po.SalaryAcctResultTempPO; +import com.engine.salary.util.db.IdGenerator; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.math.NumberUtils; + +import java.util.*; +import java.util.stream.Collectors; + +public class SalaryAcctResultReportBO { + + + /** + * 薪资核算结果保存参数转换成薪资核算结果po + * + * @param saveParam 前端保存参数 + * @param salaryAcctEmployee 薪资核算人员po + * @param employeeId 当前登陆人员id + * @return + */ + public static List convert2PO(SalaryAcctResultSaveParam saveParam, + SalaryAcctEmployeePO salaryAcctEmployee, + Long employeeId, Map emps) { + if (CollectionUtils.isEmpty(saveParam.getItems())) { + return Collections.emptyList(); + } + Date now = new Date(); + return saveParam.getItems().stream() + .map(e -> { + SalaryAcctResultReportPO po = SalaryAcctResultReportPO.builder() + .id(IdGenerator.generate()) + .salarySobId(salaryAcctEmployee.getSalarySobId()) + .salaryItemId(e.getSalaryItemId()) + .salaryAcctRecordId(salaryAcctEmployee.getSalaryAcctRecordId()) + .salaryAcctEmpId(salaryAcctEmployee.getId().toString()) + .employeeId(salaryAcctEmployee.getEmployeeId().toString()) + .taxAgentId(salaryAcctEmployee.getTaxAgentId()) + .resultValue(e.getResultValue()) + .creator(employeeId) + .createTime(now) + .updateTime(now) + .deleteType(NumberUtils.INTEGER_ZERO) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .build(); + + DataCollectionEmployee dataCollectionEmployee = emps.get(salaryAcctEmployee.getEmployeeId()); + if (dataCollectionEmployee != null) { + po.setDepartmentId(dataCollectionEmployee.getDepartmentId()); + po.setSubcompanyId(dataCollectionEmployee.getSubcompanyid()); + po.setCostcenterId(dataCollectionEmployee.getCostcenterId()); + po.setJobtitleId(dataCollectionEmployee.getJobtitleId()); + po.setLocationId(dataCollectionEmployee.getLocationId()); + } + return po; + }) + .collect(Collectors.toList()); + } + + public static List convert2ReportPO(Collection temps, Map emps) { +// Map longDataCollectionEmployeeMap = SalaryEntityUtil.convert2Map(emps, DataCollectionEmployee::getEmployeeId); + if (CollectionUtils.isEmpty(temps)) { + return Collections.emptyList(); + } + return temps.stream().map(e -> { + SalaryAcctResultReportPO po = SalaryAcctResultReportPO.builder() + .id(IdGenerator.generate()) + .salarySobId(e.getSalarySobId()) + .salaryAcctEmpId(e.getSalaryAcctEmpId().toString()) + .salaryAcctRecordId(e.getSalaryAcctRecordId()) + .employeeId(e.getEmployeeId().toString()) + .taxAgentId(e.getTaxAgentId()) + .salaryItemId(e.getSalaryItemId()) + .resultValue(e.getResultValue()) + .originResultValue(e.getOriginResultValue()) + .creator(e.getCreator()) + .createTime(e.getCreateTime()) + .updateTime(e.getUpdateTime()) + .deleteType(e.getDeleteType()) + .tenantKey(e.getTenantKey()) + .build(); + + Long employeeId = e.getEmployeeId(); + DataCollectionEmployee dataCollectionEmployee = emps.get(employeeId); + if (dataCollectionEmployee != null) { + po.setDepartmentId(dataCollectionEmployee.getDepartmentId()); + po.setSubcompanyId(dataCollectionEmployee.getSubcompanyid()); + po.setCostcenterId(dataCollectionEmployee.getCostcenterId()); + po.setJobtitleId(dataCollectionEmployee.getJobtitleId()); + po.setLocationId(dataCollectionEmployee.getLocationId()); + } + return po; + }).collect(Collectors.toList()); + } +} diff --git a/src/com/engine/salary/entity/report/po/SalaryAcctResultReportPO.java b/src/com/engine/salary/entity/report/po/SalaryAcctResultReportPO.java new file mode 100644 index 000000000..67a2d7758 --- /dev/null +++ b/src/com/engine/salary/entity/report/po/SalaryAcctResultReportPO.java @@ -0,0 +1,98 @@ +package com.engine.salary.entity.report.po; + +import com.engine.salary.annotation.Encrypt; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.Date; + +/** + * 薪资核算结果表 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalaryAcctResultReportPO { + private Long id; + /** + * 薪资帐套id + */ + private Long salarySobId; + /** + * 薪资核算人员id + */ + @Encrypt + private String salaryAcctEmpId; + /** + * 薪资核算的id + */ + private Long salaryAcctRecordId; + /** + * 人员id + */ + @Encrypt + private String employeeId; + /** + * 个税扣缴义务人id + */ + private Long taxAgentId; + /** + * 薪资项目的id + */ + private Long salaryItemId; + /** + * 计算后的值 + */ + private String resultValue; + /** + * 回算前的值 + */ + private String originResultValue; + /** + * 创建人 + */ + private Long creator; + /** + * 创建时间 + */ + private Date createTime; + /** + * 更新时间 + */ + private Date updateTime; + /** + * 是否已删除。0:未删除、1:已删除 + */ + private Integer deleteType; + /** + * 租户ID + */ + private String tenantKey; + /** + * 所属部门 + */ + private Long departmentId; + /** + * 所属分部 + */ + private Long subcompanyId; + /** + * 所属成本中心 + */ + private Long costcenterId; + /** + * 岗位 + */ + private Long jobtitleId; + /** + * 工作地点 + */ + private Long locationId; + + //主键id集合 + private Collection ids; +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/salaryBill/bo/SalaryBillBO.java b/src/com/engine/salary/entity/salaryBill/bo/SalaryBillBO.java new file mode 100644 index 000000000..b36deb78b --- /dev/null +++ b/src/com/engine/salary/entity/salaryBill/bo/SalaryBillBO.java @@ -0,0 +1,964 @@ +package com.engine.salary.entity.salaryBill.bo; + +import cn.hutool.core.io.FileUtil; +import com.cloudstore.dev.api.bean.MessageBean; +import com.cloudstore.dev.api.bean.MessageType; +import com.cloudstore.dev.api.util.Util_Message; +import com.engine.salary.annotation.SalaryFormulaVar; +import com.engine.salary.constant.HrmSalaryPayrollConf; +import com.engine.salary.constant.SalaryArchiveConstant; +import com.engine.salary.constant.SalaryBillConstant; +import com.engine.salary.constant.SalaryTemplateSalaryItemSetGroupConstant; +import com.engine.salary.encrypt.AESEncryptUtil; +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.salaryBill.dto.*; +import com.engine.salary.entity.salaryBill.po.SalaryTemplatePO; +import com.engine.salary.entity.salaryformula.dto.SalaryFormulaEmployeeDTO; +import com.engine.salary.enums.salarybill.MessageChannelEnum; +import com.engine.salary.enums.salarybill.SalaryTemplateTextContentPositionEnum; +import com.engine.salary.enums.salarybill.SalaryTemplateWhetherEnum; +import com.engine.salary.util.SalaryDateUtil; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.pdf.HtmlToPdf; +import com.fapiao.neon.util.Base64Utils; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.math.NumberUtils; +import org.apache.pdfbox.multipdf.PDFMergerUtility; +import org.jetbrains.annotations.NotNull; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import weaver.common.MessageUtil; +import weaver.conn.RecordSet; +import weaver.email.EmailWorkRunnable; +import weaver.file.ImageFileManager; +import weaver.general.Util; +import weaver.hrm.company.SubCompanyComInfo; +import weaver.hrm.resource.ResourceComInfo; + +import java.io.*; +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.math.BigDecimal; +import java.text.SimpleDateFormat; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.util.*; + +import static com.engine.salary.constant.HrmSalaryPayrollConf.HAS_SIGN; + + +public class SalaryBillBO { + private static final Logger log = LoggerFactory.getLogger(SalaryBillBO.class); + + + @Override + public String toString() { + return "SalaryBillBO{}"; + } +// +// /** +// * 根据模板内容转为工资单模板对象 +// * 注意:不要通过反序列化,可能会因为历史原因修改字段名称而无法序列化 +// * +// * @param salaryTemplateContent +// * @return +// */ +// public static SalaryTemplatePO buildSalaryTemplateContent(String salaryTemplateContent) { +// Map map = JsonUtil.parseMap(salaryTemplateContent, Object.class); +// return SalaryTemplatePO.builder() +// .id(Long.valueOf(map.getOrDefault("id", "0").toString())) +// .name(map.getOrDefault("name", "").toString()) +// .salarySobId(Long.valueOf(map.getOrDefault("salarySobId", "0").toString())) +// .useType(Integer.valueOf(map.getOrDefault("useType", "0").toString())) +// .description(map.getOrDefault("description", "").toString()) +// .emailStatus(Integer.valueOf(map.getOrDefault("emailStatus", "0").toString())) +// .sendEmailId(Long.valueOf(map.getOrDefault("sendEmailId", "0").toString())) +//// .msgStatus(Integer.valueOf(map.getOrDefault("msgStatus","0").toString())) +//// .imStatus(Integer.valueOf(map.getOrDefault("imStatus","0").toString())) +//// .cloudBridgeStatus(Integer.valueOf(map.getOrDefault("cloudBridgeStatus","0").toString())) +// .theme(map.getOrDefault("theme", "").toString()) +// .background(map.getOrDefault("background", "").toString()) +// .textContent(map.getOrDefault("textContent", "").toString()) +// .textContentPosition(Integer.valueOf(map.getOrDefault("textContentPosition", "0").toString())) +// .salaryItemNullStatus(Integer.valueOf(map.getOrDefault("salaryItemNullStatus", "0").toString())) +// .salaryItemZeroStatus(Integer.valueOf(map.getOrDefault("salaryItemZeroStatus", "0").toString())) +// .salaryItemSetting(map.getOrDefault("salaryItemSetting", "").toString()) +// .replenishName(map.getOrDefault("replenishName", "").toString()) +//// .replTheme(map.getOrDefault("replTheme","").toString()) +//// .replBackground(map.getOrDefault("replBackground","").toString()) +//// .replTextContent(map.getOrDefault("replTextContent","").toString()) +//// .replTextContentPosition(Integer.valueOf(map.getOrDefault("replTextContentPosition","0").toString())) +//// .replSalaryItemNullStatus(Integer.valueOf(map.getOrDefault("replSalaryItemNullStatus","0").toString())) +//// .replSalaryItemZeroStatus(Integer.valueOf(map.getOrDefault("replSalaryItemZeroStatus","0").toString())) +//// .replenishSalaryItemSetting(map.getOrDefault("replenishSalaryItemSetting","").toString()) +// .build(); +// } + + /** + * 构建人员字段 + * 与SalaryAcctResultBO.buildEmployeeFieldName()的key value对调了一下 + * + * @return + */ + public static Map buildEmployeeFieldName() { + Field[] declaredFields = SalaryFormulaEmployeeDTO.class.getDeclaredFields(); + Map employeeFieldNameMap = Maps.newHashMapWithExpectedSize(declaredFields.length); + for (Field declaredField : declaredFields) { + if (!declaredField.isAnnotationPresent(SalaryFormulaVar.class)) { + continue; + } + SalaryFormulaVar annotation = declaredField.getAnnotation(SalaryFormulaVar.class); + employeeFieldNameMap.put(SalaryI18nUtil.getI18nLabel(annotation.labelId(), annotation.defaultLabel()), declaredField.getName()); + } + return employeeFieldNameMap; + } + + /** + * 构建工资单中的人员信息 + * + */ + public static void buildEmployeeInfo(SalaryBillSendDTO salaryBillSendParam, Map empInfo) { + + SalaryTemplateSalaryItemSetListDTO employeeInformation = salaryBillSendParam.getEmployeeInformation(); + Map employeeField = salaryBillSendParam.getEmployeeField(); + + if (employeeInformation == null || empInfo == null) { + return; + } + if (CollectionUtils.isNotEmpty(employeeInformation.getItems())) { + //获取员工信息的字段名和中文描述的map关系 + SalaryFormulaEmployeeDTO salaryFormulaEmployeeDTO = SalaryFormulaEmployeeDTO.builder() + .employeeId((long) empInfo.getOrDefault("employeeId", 0L)) + .taxAgentName(Util.null2String(empInfo.get("taxAgentName"))) + .departmentName(Util.null2String(empInfo.get("departmentName"))) + .companystartdate(Util.null2String(empInfo.get("companystartdate"))) + .email(Util.null2String(empInfo.get("email"))) + .sex(Util.null2String(empInfo.get("sex"))) + .mobile(Util.null2String(empInfo.get("mobile"))) + .jobtitleName(Util.null2String(empInfo.get("jobtitleName"))) + .status(Util.null2String(empInfo.get("status"))) + .telephone(Util.null2String(empInfo.get("telephone"))) + .username(Util.null2String(empInfo.get("username"))) + .workcode(Util.null2String(empInfo.get("workcode"))) + .idNo(Util.null2String(empInfo.get("idNo"))) + .statusName(Util.null2String(empInfo.get("statusName"))) +// .accountType((Integer) empInfo.getOrDefault("accountType",0)) + .accountTypeName(Util.null2String(empInfo.get("accountTypeName"))) + .build(); + List items = employeeInformation.getItems(); + for (SalaryTemplateSalaryItemListDTO e : items) { + String employeeFieldName = employeeField.get(e.getName()); + if (!StringUtils.isEmpty(employeeFieldName)) { + String getter = "get" + employeeFieldName.substring(0, 1).toUpperCase() + employeeFieldName.substring(1); + try { + Method method = salaryFormulaEmployeeDTO.getClass().getMethod(getter); + Object invoke = method.invoke(salaryFormulaEmployeeDTO); + e.setSalaryItemValue(Util.null2String(invoke)); + } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) { + log.error("no such method", e); + } + } + } + } + } + + /** + * 获取工资单标题 + * + * @return + */ + public static String getBillTitle(String theme, Date salaryMonth, Long employeeId) { + + String companyName = ""; + if (theme.contains("${companyName}")) { + if (employeeId != null) { + ResourceComInfo resourceComInfo = null; + SubCompanyComInfo subCompanyComInfo = new SubCompanyComInfo(); + try { + resourceComInfo = new ResourceComInfo(); + subCompanyComInfo = new SubCompanyComInfo(); + } catch (Exception e) { + log.error("资源异常", e); + } + companyName = subCompanyComInfo.getSubCompanyname(resourceComInfo.getSubCompanyID(employeeId + "")); + companyName = Util.formatMultiLang(companyName); + } + } + + return theme.replace("${companyName}", companyName) + .replace("${salaryMonth}", new SimpleDateFormat("yyyy年MM月").format(salaryMonth)) + .replace("${salaryYear}", new SimpleDateFormat("yyyy年").format(salaryMonth)); + } + +// /** +// * 构建发送消息 +// * +// * @param e +// * @param allEmployeeMap +// * @param salaryBillSendParam +// * @param currentEmployeeId +// * @param currentTenantKey +// * @return +// */ +// public static SendMessageEntity buildSendMessage(Map e, Map allEmployeeMap, SalaryBillSendDTO salaryBillSendParam, Long currentEmployeeId, String currentTenantKey) { +// // 构建用户基本信息 +// SalaryBillBO.buildEmployeeInfo(salaryBillSendParam.getEmployeeInformation(), allEmployeeMap.get(e.get("employeeId").toString()), salaryBillSendParam.getEmployeeField()); +// // 消息接收者 +// List receivers = Collections.singletonList(SalaryBillBO.buildUser(Long.valueOf(e.get("employeeId").toString()), Optional.ofNullable(e.get("email")).orElse("").toString(), currentTenantKey)); +// Entity entity = SalaryBillBO.buildEntity(e.get("id").toString(), currentEmployeeId, salaryBillSendParam.getEntityName()); +// EmailEntity emailInfo = new EmailEntity(); +// // 邮箱打开 +// if (salaryBillSendParam.isEnableEmail()) { +// String emailContent = SalaryBillBO.buildEmailContent(e, salaryBillSendParam); +// emailInfo = SalaryBillBO.buildEmailInfo(salaryBillSendParam.getText(), emailContent, salaryBillSendParam.getSalaryTemplate().getSendEmailId()); +// } +// return SalaryBillBO.buildSendMessageEntity(salaryBillSendParam, receivers, entity, emailInfo); +// } + + /** + * 发送Em消息 + */ + public static void sendMsg(SalaryBillSendDTO salaryBillSendParam, Long id, Long employeeId) { + SalaryTemplatePO template = salaryBillSendParam.getSalaryTemplate(); + String background = template.getBackground(); + String billTitle = getBillTitle(template.getTheme(), salaryBillSendParam.getSalaryDate(), employeeId); + MessageType messageType = MessageType.newInstance(499); // 消息来源(见文档第四点补充 必填) + Set userIdList = new HashSet<>(); // 接收人id 必填 + userIdList.add(employeeId.toString()); + String title = billTitle; // 标题 + String context = "点击查看详情"; // 内容 + // PC端链接 + String linkUrl = weaver.general.GCONST.getContextPath() + "/spa/hrmSalary/static/index.html#/main/hrmSalary/mobilepayroll?id=" + id + "&salaryCode=" + AESEncryptUtil.encrypt4SalaryBill(employeeId.toString()); + // 移动端链接 + String linkMobileUrl = weaver.general.GCONST.getContextPath() + "/spa/hrmSalary/static/index.html#/main/hrmSalary/mobilepayroll?type=phone&id=" + id + "&salaryCode=" + AESEncryptUtil.encrypt4SalaryBill(employeeId.toString()); + try { + MessageBean messageBean = Util_Message.createMessage(messageType, userIdList, title, context, linkUrl, linkMobileUrl); + messageBean.setCreater(Integer.parseInt(salaryBillSendParam.getSendUser().getUID() + ""));// 创建人id + messageBean.setBizState("0");// 需要修改消息为已处理等状态时传入,表示消息最初状态为待处理 + messageBean.setTargetId("499|" + id); //消息来源code +“|”+业务id需要修改消息为已处理等状态时传入 + + if (StringUtils.isNotBlank(background)) { + messageBean.setPictureUrl(background); + } else { + messageBean.setPictureUrl("/hrm/hrm_e9/images/payroll.jpg?pictype=jpg"); + } + Util_Message.store(messageBean); + } catch (IOException e) { + log.error("消息发送失败", e); + } + } + + public static void sendEmail(Map e, SalaryBillSendDTO salaryBillSendParam) { + String content = genPayrollHtmlContent(e, salaryBillSendParam); + // 消息接收者 + String receivers = Optional.ofNullable(e.get("email")).orElse("").toString(); + String title = getBillTitle(salaryBillSendParam.getSalaryTemplate().getTheme(), salaryBillSendParam.getSalaryDate(), Long.valueOf(e.get("employeeId").toString())); + + if (StringUtils.isNotBlank(receivers)) { + EmailWorkRunnable.threadModeReminder(receivers, title, content); + } + } + + public static void genPdf(Map e, SalaryBillSendDTO salaryBillSendParam) { + String content = genPayrollHtmlContent(e, salaryBillSendParam); + String yyyyMM = SalaryDateUtil.getFormatYearMonth(salaryBillSendParam.getSalaryDate()); + + Long sendId = salaryBillSendParam.getSalarySend().getId(); + Object id = e.getOrDefault("id", 1L); + String htmlPath = HrmSalaryPayrollConf.GEN_PATH + yyyyMM + File.separator + sendId + File.separator + id + ".html"; + + FileUtil.del(htmlPath); + File touch = FileUtil.touch(htmlPath); + FileUtil.appendUtf8String(content, touch); + + String pdfPath = HrmSalaryPayrollConf.GEN_PATH + yyyyMM + File.separator + sendId + File.separator + id + ".pdf"; + FileUtil.del(pdfPath); + HtmlToPdf.convert(HrmSalaryPayrollConf.TO_PDF_TOOL_PATH, htmlPath, pdfPath); + } + + /** + * 合并pdff + * + * @param pdfPath 最终合并的pdf + * @param filesToMerge 待合并的pdf + */ + public static void mergePdf(String pdfPath, List filesToMerge) { + + // 创建PDF合并工具实例 + PDFMergerUtility merger = new PDFMergerUtility(); + + // 遍历要合并的PDF文件列表 + for (String file : filesToMerge) { + if (FileUtil.isFile(file)) { + try { + merger.addSource(file); // 将每个文件添加到合并工具 + } catch (FileNotFoundException e) { + log.error("PDF合并失败1", e); + } + } + } + // 设置合并后的目标文件 + merger.setDestinationFileName(pdfPath); + try { + // 执行合并操作 + FileUtil.del(pdfPath); + merger.mergeDocuments(); + } catch (IOException e) { + log.error("PDF合并失败2", e); + } + } + + + @NotNull + private static String genPayrollHtmlContent(Map e, SalaryBillSendDTO salaryBillSendParam) { + StringBuilder emailContent = new StringBuilder(); + emailContent.append(""); + emailContent.append("
"); + SalaryBillBO.buildEmailContent(emailContent, e, salaryBillSendParam); + // 构建水印内容 + buildEmailWatermarkContent(emailContent, e, salaryBillSendParam); + emailContent.append("
"); + return emailContent.toString(); + } + + + public static byte[] readInputStream(InputStream is) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + byte[] buffer = new byte[1024]; + int length = 0; + try { + while ((length = is.read(buffer)) != -1) { + baos.write(buffer, 0, length); + } + baos.flush(); + } catch (IOException e) { + log.error(e.getMessage(), e); + } + byte[] data = baos.toByteArray(); + try { + is.close(); + baos.close(); + } catch (IOException e) { + log.error(e.getMessage(), e); + } + return data; + } + + public static void sendSMS(Map e, SalaryBillSendDTO salaryBillSendParam) { + + + SalaryTemplateSMSSetDTO smsSetting = salaryBillSendParam.getSmsSetting(); + String content = smsSetting != null ? smsSetting.getContent() : ""; + if (StringUtils.isBlank(content)) { + return; + } + + content = content.replace("\n", "\r\n") + .replace("{薪资所属月}", SalaryDateUtil.getFormatYearMonth(salaryBillSendParam.getSalaryDate())); + + for (SalaryTemplateSalaryItemListDTO item : salaryBillSendParam.getEmployeeInformation().getItems()) { + content = content.replace("{" + item.getName() + "}", Util.null2String(item.getSalaryItemValue())); + } + + for (SalaryTemplateSalaryItemSetListDTO salaryTemplateSalaryItemSetListDTO : salaryBillSendParam.getSalaryItemSetList()) { + for (SalaryTemplateSalaryItemListDTO item : salaryTemplateSalaryItemSetListDTO.getItems()) { + if (content.contains("{" + item.getName() + "}")) { + content = content.replace("{" + item.getName() + "}", e.getOrDefault(item.getId() + SalaryArchiveConstant.DYNAMIC_SUFFIX, "").toString()); + } + } + } + + try { + if (e.get("mobile") != null) { + MessageUtil.sendSMS(e.get("mobile").toString(), content); + } else { + log.error("发送短信失败,{}手机号为空", e.getOrDefault("username", "")); + } + } catch (Exception ex) { + log.error("发送短信失败", ex); + } + } + +// /** +// * 构建发送消息 +// * +// * @return +// */ +// public static SendMessageEntity buildSendMessageEntity(SalaryBillSendDTO salaryBillSendParam, List receivers, Entity entity, EmailEntity emailInfo) { +// SendMessageEntity smg = new SendMessageEntity(); +// // 模块 +// smg.setModule(MessageModule.HRSA); +// // 事件 +// smg.setEvent(MessageEvent.PAYROLL); +// +// // 发送者 +// smg.setSender(salaryBillSendParam.getSendUser() == null ? UserEntity.SYSTEM_USER : salaryBillSendParam.getSendUser()); +// // 接收者 +// smg.setReceivers(receivers); +// // 发送通道 +// smg.setChannels(salaryBillSendParam.getSendChannels()); +// +// // 消息内容 +// smg.setText(salaryBillSendParam.getTitle()); +// +// // 1.im +// smg.setEntity(entity); +// // 2.云桥 +// smg.setPcUrl(entity.getPcUrl()); +// smg.setAppUrl(entity.getH5Url()); +// smg.setTitle(salaryBillSendParam.getTitle()); +// smg.setContent(salaryBillSendParam.getTitle()); +// smg.setPicUrl(salaryBillSendParam.getPicUrl()); +// // 3.邮件 +// smg.setEmailInfo(emailInfo); +// +// return smg; +// } +// +// /** +// * 构建用户 +// * +// * @return +// */ +// public static UserEntity buildUser(Long employeeId, String email, String tenantKey) { +// UserEntity user = new UserEntity(employeeId, tenantKey); +// if (!StringUtils.isEmpty(email)) { +// user.setEmail(email); +// } +// return user; +// } + + /** + * 构建发送通道 + * + * @param salaryTemplate + * @return + */ + public static Set buildSendChannels(SalaryTemplatePO salaryTemplate) { + Set channels = new HashSet<>(); + if (salaryTemplate.getMsgStatus() == null || salaryTemplate.getMsgStatus().equals(SalaryTemplateWhetherEnum.TRUE.getValue())) { + channels.add(MessageChannelEnum.MSG); + } + if (salaryTemplate.getEmailStatus() != null && salaryTemplate.getEmailStatus().equals(SalaryTemplateWhetherEnum.TRUE.getValue()) && MessageUtil.checkSendEmail()) { + channels.add(MessageChannelEnum.EMAIL); + } + if (salaryTemplate.getSmsStatus() != null && salaryTemplate.getSmsStatus().equals(SalaryTemplateWhetherEnum.TRUE.getValue()) && MessageUtil.checkSendSMS()) { + channels.add(MessageChannelEnum.SMS); + } + return channels; + } +// +// /** +// * 构建实体 +// * +// * @param id +// * @param currentEmployeeId +// * @param name +// * @return +// */ +// public static Entity buildEntity(String id, Long currentEmployeeId, String name) { +// Entity e = new Entity(); +// e.setId(String.valueOf(IdGenerator.generate())); +// e.setModule(EntityType.hrmsalary.name()); +// e.setName(name); +// e.setH5Url("/mobile/salary/mySalaryBill/view/" + id); +//// e.setH5LinkeType(1); +// e.setPcUrl("/sp/salary/mySalaryBill/view/" + id); +//// e.setPcLinkeType(0); +// +// // im添加创建人创建时间、可在对应通道的模板中的内容或辅助信息标题等加上变量${creator}$和${createTime}$ +// e.setCreatorId(currentEmployeeId); +// e.setCreateTime(new Date()); +// return e; +// } +// +// /** +// * 构建邮件信息 +// * +// * @param emailSubject 邮件主题 +// * @param emailContent 邮件内容 +// * @param mailUserAccountId 邮箱账号id +// * @return +// */ +// public static EmailEntity buildEmailInfo(String emailSubject, String emailContent, Long mailUserAccountId) { +// EmailEntity entity = new EmailEntity(); +// entity.setEmailContent(emailContent); +// entity.setEmailSubject(emailSubject); +// // 发送者邮箱 +// entity.setMailUserAccountId(mailUserAccountId); +// return entity; +// } +// +// /** +// * 构建撤回消息 +// * +// * @param msgId +// * @param text +// * @param title +// * @param currentEmployeeId +// * @param currentTenantKey +// * @return +// */ +// public static CancleMessageEntity buildCancleMessageEntity(long msgId, String text, String title, Long currentEmployeeId, String currentTenantKey) { +// CancleMessageEntity cme = new CancleMessageEntity(); +// cme.setMsgId(msgId); +// // 模块 +// cme.setModule(MessageModule.HRSA); +// // 事件 +// cme.setEvent(MessageEvent.PAYROLL); +// +// cme.setText(text); +// +// Entity entity = new Entity(); +// entity.setId(String.valueOf(IdGenerator.generate())); +// entity.setModule(EntityType.hrmsalary.name()); +// entity.setName(title); +// cme.setEntity(entity); +// UserEntity user = new UserEntity(currentEmployeeId, currentTenantKey); +// cme.setOperator(user); +// return cme; +// } + + /** + * 构建邮件内容 + * 注意:样式只能在标签style属性中使用,否则样式不生效 + * + * @param e + * @param salaryBillSendParam + * @return + */ + public static void buildEmailContent(StringBuilder emailContent, Map e, SalaryBillSendDTO salaryBillSendParam) { + emailContent.append("
"); + // 1.标题 + emailContent.append("
"); +// emailContent.append(salaryBillSendParam.getTitle()); + emailContent.append(getBillTitle(salaryBillSendParam.getSalaryTemplate().getTheme(), salaryBillSendParam.getSalaryDate(), Long.valueOf(e.get("employeeId").toString()))); + emailContent.append("
"); + // 2.发送时间 + emailContent.append("
"); + emailContent.append(SalaryDateUtil.getFormatLocalDateTime(LocalDateTime.now())); + emailContent.append("
"); + // 3.背景图-base64 +// if (!StringUtils.isEmpty(salaryBillSendParam.getBackgroundBase64())) { +// emailContent.append("
"); +// } + // 3.背景图-url +// if (StringUtils.isNotEmpty(salaryBillSendParam.getSalaryTemplate().getBackground())) { +// emailContent.append("
"); +// } + + // 是否只有一个分组,如果是,则将文本内容放进薪资项目表格前后 + boolean isOnlyOneGroup = salaryBillSendParam.getSalaryItemSetList().stream().filter(st -> CollectionUtils.isNotEmpty(st.getItems())).count() == 1; + if (isOnlyOneGroup) { + buildOnlyOneGroupMailMain(emailContent, e, salaryBillSendParam); + } else { + buildMailMain(emailContent, e, salaryBillSendParam); + } + + //签章 + if (HAS_SIGN) { + RecordSet rs = new RecordSet(); + rs.execute("select * from DocSignature where hrmresid=" + e.getOrDefault("employeeId", "1") + " order by markid"); + if (rs.next()) { + int imagefileid = rs.getInt("imagefileid"); + InputStream imageInputStream = ImageFileManager.getInputStreamById(imagefileid); + byte[] data = readInputStream(imageInputStream); + String imageBase64 = "data:image/jpeg;base64," + Base64Utils.encodeToString(data); + emailContent.append("
\n" + " " + "
"); + } + } + emailContent.append("
"); + } + + /** + * 构建邮件内容主体 + * + * @param emailContent + * @param e + * @param salaryBillSendParam + */ + private static void buildMailMain(StringBuilder emailContent, Map e, SalaryBillSendDTO salaryBillSendParam) { + // 薪资项是否显示 + boolean isHideNull = salaryBillSendParam.getSalaryTemplate().getSalaryItemNullStatus().equals(SalaryTemplateWhetherEnum.TRUE.getValue()); + boolean isHideZero = salaryBillSendParam.getSalaryTemplate().getSalaryItemZeroStatus().equals(SalaryTemplateWhetherEnum.TRUE.getValue()); + // 3.文本内容-如果在薪资项目前 + emailContent.append("
"); + emailContent.append(salaryBillSendParam.getSalaryTemplate().getTextContent()); + emailContent.append("
"); + // 4.薪资项目内容 + emailContent.append("
"); + for (SalaryTemplateSalaryItemSetListDTO salaryItemSet : salaryBillSendParam.getSalaryItemSetList()) { + if (CollectionUtils.isEmpty(salaryItemSet.getItems())) { + continue; + } + emailContent.append("
"); + if (!salaryItemSet.getGroupId().equals(SalaryTemplateSalaryItemSetGroupConstant.NO_TYPE_GROUP_ID)) { + emailContent.append("
"); + // 4.1.薪资项目组名 + emailContent.append(salaryItemSet.getGroupName()); + emailContent.append("
"); + } + emailContent.append(""); + emailContent.append(""); + List items = salaryItemSet.getItems(); + List> itemsPartition = Lists.partition(items, 3); + itemsPartition.forEach(itemPartition -> { + emailContent.append(""); + for (int i = 0; i < itemPartition.size(); i++) { + SalaryTemplateSalaryItemListDTO salaryItem = itemPartition.get(i); + // 员工基本信息 + if (salaryItemSet.getGroupId().equals(SalaryTemplateSalaryItemSetGroupConstant.EMPLOYEE_INFO_GROUP_ID) && salaryBillSendParam.getEmployeeInformation() != null) { + Optional optionalEmpItem = salaryBillSendParam.getEmployeeInformation().getItems().stream().filter(f -> f.getId().equals(salaryItem.getId())).findFirst(); + // 4.2.员工信息 + emailContent.append(""); + + emailContent.append(""); + } else { + for (Object keyName : e.keySet()) { + if ((salaryItem.getId() + SalaryArchiveConstant.DYNAMIC_SUFFIX).equals(keyName.toString())) { + boolean isHide = (isHideNull && StringUtils.isEmpty(e.getOrDefault(keyName.toString(), StringUtils.EMPTY).toString())) + || + (isHideZero && NumberUtils.isCreatable(e.getOrDefault(keyName.toString(), "0").toString()) + && BigDecimal.ZERO.compareTo(new BigDecimal(e.getOrDefault(keyName.toString(), "0").toString())) == 0); + if (!isHide) { + // 4.2.薪资项目 + emailContent.append(""); + + emailContent.append(""); + } + break; + } + } + } + } + emailContent.append(""); + }); + emailContent.append(""); + emailContent.append("
"); + emailContent.append((optionalEmpItem.isPresent() ? optionalEmpItem.get().getName() : "")); + emailContent.append(""); + emailContent.append((optionalEmpItem.isPresent() ? optionalEmpItem.get().getSalaryItemValue() : "")); + emailContent.append(""); + emailContent.append(salaryItem.getName()); + emailContent.append(""); + emailContent.append(e.get(keyName.toString())); + emailContent.append("
"); + emailContent.append("
"); + } + emailContent.append("
"); + // 5.文本内容-如果在薪资项目后 + emailContent.append("
"); + emailContent.append(salaryBillSendParam.getSalaryTemplate().getTextContent()); + emailContent.append("
"); + } + + /** + * 构建邮件内容主体 + *

+ * 只有无分类,则将文本内容放进薪资项目表格前后 + * + * @param emailContent + * @param e + * @param salaryBillSendParam + */ + private static void buildOnlyOneGroupMailMain(StringBuilder emailContent, Map e, SalaryBillSendDTO salaryBillSendParam) { + // 薪资项是否显示 + boolean isHideNull = salaryBillSendParam.getSalaryTemplate().getSalaryItemNullStatus().equals(SalaryTemplateWhetherEnum.TRUE.getValue()); + boolean isHideZero = salaryBillSendParam.getSalaryTemplate().getSalaryItemZeroStatus().equals(SalaryTemplateWhetherEnum.TRUE.getValue()); + // 4.薪资项目内容 + emailContent.append("

"); + for (SalaryTemplateSalaryItemSetListDTO salaryItemSet : salaryBillSendParam.getSalaryItemSetList()) { + if (CollectionUtils.isEmpty(salaryItemSet.getItems())) { + continue; + } + emailContent.append("
"); + emailContent.append("
"); + + // 3.文本内容-如果在薪资项目前 + emailContent.append("
"); + emailContent.append("
"); + emailContent.append(""); + emailContent.append(salaryBillSendParam.getRemarkI18n()); + emailContent.append(""); + emailContent.append("
"); + emailContent.append("
"); + emailContent.append(salaryBillSendParam.getSalaryTemplate().getTextContent()); + emailContent.append("
"); + emailContent.append("
"); + + emailContent.append(""); + emailContent.append(""); + List items = salaryItemSet.getItems(); + List> itemsPartition = Lists.partition(items, 3); + itemsPartition.forEach(itemPartition -> { + emailContent.append(""); + for (int i = 0; i < itemPartition.size(); i++) { + SalaryTemplateSalaryItemListDTO salaryItem = itemPartition.get(i); + for (Object keyName : e.keySet()) { + if ((salaryItem.getId() + SalaryArchiveConstant.DYNAMIC_SUFFIX).equals(keyName.toString())) { + boolean isHide = (isHideNull && StringUtils.isEmpty(e.getOrDefault(keyName.toString(), StringUtils.EMPTY).toString())) + || + (isHideZero && NumberUtils.isCreatable(e.getOrDefault(keyName.toString(), "0").toString()) + && BigDecimal.ZERO.compareTo(new BigDecimal(e.getOrDefault(keyName.toString(), "0").toString())) == 0); + if (!isHide) { + // 4.2.薪资项目 + emailContent.append(""); + + emailContent.append(""); + } + break; + } + } + } + emailContent.append(""); + }); + + + emailContent.append(""); + emailContent.append("
"); + emailContent.append(salaryItem.getName()); + emailContent.append(""); + emailContent.append(e.get(keyName.toString())); + emailContent.append("
"); + + // 5.文本内容-如果在薪资项目后 + emailContent.append("
"); + emailContent.append("
"); + emailContent.append(""); + emailContent.append(salaryBillSendParam.getRemarkI18n()); + emailContent.append(""); + emailContent.append("
"); + + emailContent.append("
"); + emailContent.append(salaryBillSendParam.getSalaryTemplate().getTextContent()); + emailContent.append("
"); + emailContent.append("
"); + + emailContent.append("
"); + emailContent.append("
"); + } + emailContent.append("
"); + } + + + public static String HRM_Name = "HRM_Name"; + public static String HRM_Num = "HRM_Num"; + public static String HRM_Mobile = "HRM_Mobile"; + public static String HRM_Email = "HRM_Email"; + public static String HRM_CurrentOperatorId = "HRM_CurrentOperatorId"; + public static String HRM_Department = "HRM_Department"; + public static String HRM_SecondDepartment = "HRM_SecondDepartment"; + public static String HRM_CurrentDate = "HRM_CurrentDate"; + public static String HRM_CurrentTime = "HRM_CurrentTime"; + public static String HRM_prefix = "$"; + + /** + * 构建水印 + *

+ * 当前所拥有的变量 + * "HRM_Name",当前操作者姓名 + * "HRM_Num",当前操作者编号 + * "HRM_Mobile",当前操作者移动电话 + * "HRM_Email",当前操作者电子邮件 + * "HRM_CurrentOperatorId",当前操作者人员ID + * "HRM_Department",当前操作者部门 + * "HRM_SecondDepartment",当前操作者分部 + * "HRM_CurrentDate",当前日期 + * "HRM_CurrentTime"当前时间 + * + * @param emailContent + * @param e + * @param salaryBillSendParam + */ + private static void buildEmailWatermarkContent(StringBuilder emailContent, Map e, SalaryBillSendDTO salaryBillSendParam) { + if (Objects.isNull(salaryBillSendParam.getWatermarkSetting())) { + return; + } + String emailWmContentTemplate = salaryBillSendParam.getEmailWmContentTemplate(); + List wmTextFieldIds = salaryBillSendParam.getWmTextFieldIds(); + // 没有变量,则直接返回 + if (CollectionUtils.isEmpty(wmTextFieldIds)) { + emailContent.append(emailWmContentTemplate); + } else { + for (String wmTextFieldId : wmTextFieldIds) { + // 当前操作者姓名 + if (HRM_Name.equals(wmTextFieldId)) { + emailWmContentTemplate = emailWmContentTemplate.replace(HRM_prefix + HRM_Name, Optional.ofNullable(e.get("username")).orElse(StringUtils.EMPTY).toString()); + // 当前操作者编号 + } else if (HRM_Num.equals(wmTextFieldId)) { + emailWmContentTemplate = emailWmContentTemplate.replace(HRM_prefix + HRM_Num, Optional.ofNullable(e.get("jobNum")).orElse(StringUtils.EMPTY).toString()); + // 当前操作者移动电话 + } else if (HRM_Mobile.equals(wmTextFieldId)) { + emailWmContentTemplate = emailWmContentTemplate.replace(HRM_prefix + HRM_Mobile, Optional.ofNullable(e.get("mobile")).orElse(StringUtils.EMPTY).toString()); + // 当前操作者电子邮件 + } else if (HRM_Email.equals(wmTextFieldId)) { + emailWmContentTemplate = emailWmContentTemplate.replace(HRM_prefix + HRM_Email, Optional.ofNullable(e.get("email")).orElse(StringUtils.EMPTY).toString()); + // 当前操作者人员ID + } else if (HRM_CurrentOperatorId.equals(wmTextFieldId)) { + emailWmContentTemplate = emailWmContentTemplate.replace(HRM_prefix + HRM_CurrentOperatorId, Optional.ofNullable(e.get("id")).orElse(StringUtils.EMPTY).toString()); + // 当前操作者分部 + } else if (HRM_Department.equals(wmTextFieldId)) { + emailWmContentTemplate = emailWmContentTemplate.replace(HRM_prefix + HRM_Department, Optional.ofNullable(e.get("department")).orElse(StringUtils.EMPTY).toString()); + } else if (HRM_SecondDepartment.equals(wmTextFieldId)) { + emailWmContentTemplate = emailWmContentTemplate.replace(HRM_prefix + HRM_SecondDepartment, Optional.ofNullable(e.get("subCompanyName")).orElse(StringUtils.EMPTY).toString()); + // 当前日期 + } else if (HRM_CurrentDate.equals(wmTextFieldId)) { + emailWmContentTemplate = emailWmContentTemplate.replace(HRM_prefix + HRM_CurrentDate, SalaryDateUtil.getFormatLocalDate(LocalDate.now())); + // 当前时间 + } else if (HRM_CurrentTime.equals(wmTextFieldId)) { + emailWmContentTemplate = emailWmContentTemplate.replace(HRM_prefix + HRM_CurrentTime, SalaryDateUtil.getFormatLocalDateTime(LocalDateTime.now())); + } + } + emailContent.append(emailWmContentTemplate); + } + } + + + /** + * 获取工资单水印文本动态变量 + * + * @param domain + * @param salaryBillWatermark + * @return + */ + public static List getWmTextFieldIds(String domain, SalaryBillWatermarkDTO salaryBillWatermark) { + List wmTextFieldIds = Collections.emptyList(); + // 没有水印、关闭水印、或者系统水印,则不拼接 +// if (Objects.isNull(salaryBillWatermark) || !salaryBillWatermark.getWatermarkStatus() || !SalaryTemplateWatermarkTypeEnum.CUSTOM.getValue().equals(salaryBillWatermark.getWatermarkType())) { + if (Objects.isNull(salaryBillWatermark) || !salaryBillWatermark.getWatermarkStatus()) { + return wmTextFieldIds; + } + String wmClassify = salaryBillWatermark.getWmSetting().getOrDefault("wmClassify", StringUtils.EMPTY).toString(); + if ("text".equals(wmClassify)) { + wmTextFieldIds = (List) salaryBillWatermark.getWmSetting().getOrDefault("wmSelectedFieldIds", Collections.emptyList()); + + List empFields = Arrays.asList(HRM_Name, HRM_Num, HRM_Mobile, HRM_Email, HRM_CurrentOperatorId, HRM_Department); + if (wmTextFieldIds.contains(HRM_SecondDepartment)) { + // 需要查分部 + salaryBillWatermark.getWmSetting().put("needQuerySubDepart", true); + } + // 需要查人员 + salaryBillWatermark.getWmSetting().put("needQueryEmp", wmTextFieldIds.stream().anyMatch(empFields::contains)); + + salaryBillWatermark.getWmSetting().remove("wmImg"); + } else if ("image".equals(wmClassify)) { + List> wmImgs = Collections.emptyList(); + try { + wmImgs = (List>) salaryBillWatermark.getWmSetting().getOrDefault("wmImg", Collections.emptyList()); + } catch (Exception exception) { + log.error("工资单水印图片转换失败"); + } + if (CollectionUtils.isNotEmpty(wmImgs)) { + Map map = wmImgs.get(0); + String fileid = map.getOrDefault("fileid", StringUtils.EMPTY).toString(); + if (StringUtils.isNotEmpty(fileid)) { + + String imgSrc = domain + String.format("/weaver/weaver.file.FileDownload?fileid=%s", fileid); +// String imgSrc = domain + String.format("/papi/file/preview?type=imgs&fileId=%s&random=123456", fileid); + salaryBillWatermark.getWmSetting().put("wmImg", imgSrc); + } + } + + salaryBillWatermark.getWmSetting().remove("wmText"); + salaryBillWatermark.getWmSetting().remove("wmSelectedFieldIds"); + } + // 作为快照,去掉不必要的属性,节省空间 + salaryBillWatermark.getWmSetting().remove("wmOriginText"); + salaryBillWatermark.getWmSetting().remove("pureWmText"); + return wmTextFieldIds; + } + + + public static String buildEmailWmContentTemplate(boolean isEnableEmail, SalaryBillWatermarkDTO watermarkSetting) { + String emailWmContentTemplate = StringUtils.EMPTY; + // 没有水印、关闭水印,则不拼接 + if (!isEnableEmail || Objects.isNull(watermarkSetting) || !watermarkSetting.getWatermarkStatus()) { + return emailWmContentTemplate; + } + String wmClassify = watermarkSetting.getWmSetting().getOrDefault("wmClassify", StringUtils.EMPTY).toString(); + String variable = StringUtils.EMPTY; + if ("text".equals(wmClassify)) { + variable = watermarkSetting.getWmSetting().getOrDefault("wmText", StringUtils.EMPTY).toString(); + } else if ("image".equals(wmClassify)) { +// String imgSrc = watermarkSetting.getWmSetting().getOrDefault("wmImg", StringUtils.EMPTY).toString(); +// variable = ""; +// watermarkSetting.getWmSetting().put("wmImg", imgSrc); + // 邮件不支持图片水印 + return emailWmContentTemplate; + } + if (StringUtils.isEmpty(variable)) { + return emailWmContentTemplate; + } + + String wmNoTransparent = watermarkSetting.getWmSetting().getOrDefault("wmNoTransparent", "0.15").toString(); + double wmRotate = new Double(watermarkSetting.getWmSetting().getOrDefault("wmRotate", 0).toString()); + double noTransparent = new Double(wmNoTransparent) / 100.00; + StringBuilder emailWmContentTemp = new StringBuilder(); + emailWmContentTemp.append("

"); + emailWmContentTemp.append("
"); + for (int i = 0; i < 20; i++) { + emailWmContentTemp.append("
"); + for (int j = 0; j < 8; j++) { + emailWmContentTemp.append("
"); + // 赋值 + emailWmContentTemp.append(variable); + emailWmContentTemp.append("
"); + } + emailWmContentTemp.append("
"); + } + emailWmContentTemp.append("
"); + emailWmContentTemp.append("
"); + return emailWmContentTemp.toString(); + } + + public static String handleWmText(String wmText, List wmTextFieldIds, DataCollectionEmployee simpleEmployee) { + for (String wmTextFieldId : wmTextFieldIds) { + // 当前操作者姓名 + if (SalaryBillConstant.HRM_Name.equals(wmTextFieldId)) { + wmText = wmText.replace(SalaryBillConstant.HRM_prefix + SalaryBillConstant.HRM_Name, Objects.isNull(simpleEmployee) ? StringUtils.EMPTY : simpleEmployee.getUsername()); + // 当前操作者编号 + } else if (SalaryBillConstant.HRM_Num.equals(wmTextFieldId)) { + wmText = wmText.replace(SalaryBillConstant.HRM_prefix + SalaryBillConstant.HRM_Num, Objects.isNull(simpleEmployee) || StringUtils.isEmpty(simpleEmployee.getWorkcode()) ? StringUtils.EMPTY : simpleEmployee.getWorkcode()); + // 当前操作者移动电话 + } else if (SalaryBillConstant.HRM_Mobile.equals(wmTextFieldId)) { + wmText = wmText.replace(SalaryBillConstant.HRM_prefix + SalaryBillConstant.HRM_Mobile, Objects.isNull(simpleEmployee) || StringUtils.isEmpty(simpleEmployee.getMobile()) ? StringUtils.EMPTY : simpleEmployee.getMobile()); + // 当前操作者电子邮件 + } else if (SalaryBillConstant.HRM_Email.equals(wmTextFieldId)) { + wmText = wmText.replace(SalaryBillConstant.HRM_prefix + SalaryBillConstant.HRM_Email, Objects.isNull(simpleEmployee) || StringUtils.isEmpty(simpleEmployee.getEmail()) ? StringUtils.EMPTY : simpleEmployee.getEmail()); + // 当前操作者人员ID + } else if (SalaryBillConstant.HRM_CurrentOperatorId.equals(wmTextFieldId)) { + wmText = wmText.replace(SalaryBillConstant.HRM_prefix + SalaryBillConstant.HRM_CurrentOperatorId, Objects.isNull(simpleEmployee) ? StringUtils.EMPTY : simpleEmployee.getEmployeeId().toString()); + // 当前操作者部门 + } else if (SalaryBillConstant.HRM_Department.equals(wmTextFieldId)) { + wmText = wmText.replace(SalaryBillConstant.HRM_prefix + SalaryBillConstant.HRM_Department, Objects.isNull(simpleEmployee) || Objects.isNull(simpleEmployee.getDepartmentName()) ? StringUtils.EMPTY : simpleEmployee.getDepartmentName()); + // 当前操作者分部 + } else if (SalaryBillConstant.HRM_SecondDepartment.equals(wmTextFieldId)) { + wmText = wmText.replace(SalaryBillConstant.HRM_prefix + SalaryBillConstant.HRM_SecondDepartment, Objects.isNull(simpleEmployee) || Objects.isNull(simpleEmployee.getSubcompanyName()) ? StringUtils.EMPTY : simpleEmployee.getSubcompanyName()); + // 当前日期 + } else if (SalaryBillConstant.HRM_CurrentDate.equals(wmTextFieldId)) { + wmText = wmText.replace(SalaryBillConstant.HRM_prefix + SalaryBillConstant.HRM_CurrentDate, SalaryDateUtil.getFormatLocalDate(LocalDate.now())); + // 当前时间 + } else if (SalaryBillConstant.HRM_CurrentTime.equals(wmTextFieldId)) { + wmText = wmText.replace(SalaryBillConstant.HRM_prefix + SalaryBillConstant.HRM_CurrentTime, SalaryDateUtil.getFormatLocalDateTime(LocalDateTime.now())); + } + } + return wmText; + } + +} diff --git a/src/com/engine/salary/entity/salaryBill/bo/SalaryBillItemNameBO.java b/src/com/engine/salary/entity/salaryBill/bo/SalaryBillItemNameBO.java new file mode 100644 index 000000000..ce1deaf67 --- /dev/null +++ b/src/com/engine/salary/entity/salaryBill/bo/SalaryBillItemNameBO.java @@ -0,0 +1,30 @@ +package com.engine.salary.entity.salaryBill.bo; + +import com.engine.salary.entity.salaryBill.dto.SalaryBillItemNameDTO; +import com.engine.salary.entity.salaryBill.po.SalaryBillItemNamePO; +import org.apache.commons.collections4.CollectionUtils; + +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; + +/** + * @author Harryxzy + * @ClassName SalaryBillItemNameBO + * @date 2023/07/19 9:19 + * @description 工资单薪资项目展示名称 + */ +public class SalaryBillItemNameBO { + + public static List convert2ListDTO(List SalaryBillItemNamePOList){ + if (CollectionUtils.isEmpty(SalaryBillItemNamePOList)) { + return Collections.emptyList(); + } + return SalaryBillItemNamePOList.stream() + .map(po -> SalaryBillItemNameDTO.builder() + .salaryItemId(po.getSalaryItemId()) + .salaryItemShowName(po.getSalaryItemShowName()) + .build()) + .collect(Collectors.toList()); + } +} diff --git a/src/com/engine/salary/entity/salaryBill/bo/SalarySendRangeBO.java b/src/com/engine/salary/entity/salaryBill/bo/SalarySendRangeBO.java new file mode 100644 index 000000000..74fb8ef3e --- /dev/null +++ b/src/com/engine/salary/entity/salaryBill/bo/SalarySendRangeBO.java @@ -0,0 +1,186 @@ +package com.engine.salary.entity.salaryBill.bo; + +import com.engine.salary.entity.salaryBill.dto.SalarySendUserInfoDTO; +import com.engine.salary.entity.salaryBill.po.SalarySendRangeObj; +import com.engine.salary.enums.salarysend.SalarySendRangeTargetTypeEnum; +import com.engine.salary.enums.salarysend.SalarySendRangeTypeEnum; +import com.google.common.collect.Sets; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.apache.commons.collections4.CollectionUtils; + +import java.util.*; + +/** + * @Description: 工资单发放范围 + */ +@NoArgsConstructor +public class SalarySendRangeBO { + private static final SalarySendRangeItem EMPTY_ITEM = new SalarySendRangeItem(null, null, Collections.emptySet()); + + private static final Integer INCLUDED = 1; + private static final Integer EXCLUDED = -1; + private static final Integer NOT_IN = 0; + + /** + * 索引map + */ + private final Map> indexMap + = new HashMap<>(6); + + /** + * 排除所有人 + */ + private boolean isExcludeAll = false; + + /** + * 增加所有人 + */ + private boolean isIncludeAll = false; + + public boolean putNew(SalarySendRangeObj salarySendRangeObj) { + //如果已经设置了排除所有人 或者 添加所有人, 直接跳过处理 + if (isExcludeAll) { + return true; + } + Integer rangeType = salarySendRangeObj.getRangeType(); + SalarySendRangeTypeEnum rangeTypeE = SalarySendRangeTypeEnum.fromValue(rangeType); + + Integer targetType = salarySendRangeObj.getTargetType(); + SalarySendRangeTargetTypeEnum targetTypeE = SalarySendRangeTargetTypeEnum.fromValue(targetType); + + if (rangeTypeE == null || targetTypeE == null) { + return false; + } + //所有人 筛选 + if (targetTypeE == SalarySendRangeTargetTypeEnum.ALL) { + isIncludeAll = rangeTypeE == SalarySendRangeTypeEnum.INCLUDE_OBJ; + isExcludeAll = rangeTypeE == SalarySendRangeTypeEnum.EXCLUDE_OBJ; + } + //未存入时插入 + indexMap.computeIfAbsent(targetTypeE, k -> { + Map value = new HashMap<>(); + SalarySendRangeItem rangeItem = + new SalarySendRangeItem(rangeTypeE, targetTypeE, Sets.newHashSet(salarySendRangeObj.getTargetId())); + value.put(rangeTypeE, rangeItem); + return value; + }); + //已存在时更新 + indexMap.computeIfPresent(targetTypeE, (k, v) -> { + SalarySendRangeItem item = v.get(rangeTypeE); + if (null == item) { + item = new SalarySendRangeItem(rangeTypeE, targetTypeE, Sets.newHashSet(salarySendRangeObj.getTargetId())); + } else { + item.getTargetIds().add(salarySendRangeObj.getTargetId()); + } + v.put(rangeTypeE, item); + return v; + }); + return true; + } + + private Set getTargetIds(SalarySendRangeTargetTypeEnum targetType, SalarySendRangeTypeEnum rangeType) { + Map itemMap = indexMap.get(targetType); + if (itemMap != null) { + SalarySendRangeItem item = itemMap.getOrDefault(rangeType, EMPTY_ITEM); + return item.getTargetIds(); + } + return Collections.emptySet(); + } + + /** + * 判断是否在人员范围内 + * 如果已经有 所有人 的范围设置,不判断是否有其他范围直接返回 + * + * @param targetType 目标类型 + * @param targetId 目标id + * @return 是否在范围内 + */ + private int doJudgeInRange(SalarySendRangeTargetTypeEnum targetType, Long targetId) { + //如果所有人范围已经设置 + if (isExcludeAll) { + return EXCLUDED; + } + Set includeTargetIds = getTargetIds(targetType, SalarySendRangeTypeEnum.INCLUDE_OBJ); + Set excludeTargetIds = getTargetIds(targetType, SalarySendRangeTypeEnum.EXCLUDE_OBJ); + if (excludeTargetIds.contains(targetId)) { + return EXCLUDED; + } else if (includeTargetIds.contains(targetId)) { + return INCLUDED; + } else { + //默认值是是否选择所有人 + return isIncludeAll ? INCLUDED : NOT_IN; + } + } + + private int doJudgeInRange(SalarySendRangeTargetTypeEnum targetType, Collection targetIds) { + if (CollectionUtils.isEmpty(targetIds)) { + return NOT_IN; + } + //如果所有人范围已经设置 + if (isExcludeAll) { + return EXCLUDED; + } + if (isIncludeAll) { + return INCLUDED; + } + Set includeTargetIds = getTargetIds(targetType, SalarySendRangeTypeEnum.INCLUDE_OBJ); + Set excludeTargetIds = getTargetIds(targetType, SalarySendRangeTypeEnum.EXCLUDE_OBJ); + if (targetIds.stream().anyMatch(excludeTargetIds::contains)) { + return EXCLUDED; + } else if (targetIds.stream().anyMatch(includeTargetIds::contains)) { + return INCLUDED; + } else { + return NOT_IN; + } + } + + public boolean judgeInRange(SalarySendUserInfoDTO dto) { + //如果所有人范围已经设置 + if (isExcludeAll) { + return false; + } + Integer isInRange = NOT_IN; + // 默认值为是否选择所有人 + boolean result = isIncludeAll; + for (SalarySendRangeTargetTypeEnum targetType : SalarySendRangeTargetTypeEnum.values()) { + switch (targetType) { + case DEPT: + isInRange = doJudgeInRange(targetType, dto.getDepartmentId()); + break; + case USER: + isInRange = doJudgeInRange(targetType, dto.getResourceId()); + break; + case POSITION: + isInRange = doJudgeInRange(targetType, dto.getJobTitle()); + break; +// case TAX_AGENT: +// isInRange = doJudgeInRange(targetType, dto.getTaxAgentIds()); +// break; + case SUB_COMPANY: + isInRange = doJudgeInRange(targetType, dto.getSubCompanyId()); + break; + } + if (isInRange.equals(EXCLUDED)) { + //如果被排除,返回false + return false; + } else { + // 只要没有被排除,在范围内即为true + result |= isInRange.equals(INCLUDED); + } + } + return result; + } + + @AllArgsConstructor + @NoArgsConstructor + @Data + private static class SalarySendRangeItem { + private SalarySendRangeTypeEnum rangeType; + + private SalarySendRangeTargetTypeEnum targetType; + + private Set targetIds; + } +} diff --git a/src/com/engine/salary/entity/salaryBill/bo/SalaryTemplateBO.java b/src/com/engine/salary/entity/salaryBill/bo/SalaryTemplateBO.java new file mode 100644 index 000000000..9977e0a63 --- /dev/null +++ b/src/com/engine/salary/entity/salaryBill/bo/SalaryTemplateBO.java @@ -0,0 +1,192 @@ +package com.engine.salary.entity.salaryBill.bo; + +import cn.hutool.json.JSONUtil; +import com.engine.salary.constant.SalaryTemplateSalaryItemSetGroupConstant; +import com.engine.salary.entity.salaryBill.dto.SalaryTemplateSalaryItemListDTO; +import com.engine.salary.entity.salaryBill.dto.SalaryTemplateSalaryItemSetListDTO; +import com.engine.salary.entity.salaryBill.param.SalaryTemplateSaveParam; +import com.engine.salary.entity.salaryBill.po.SalaryTemplatePO; +import com.engine.salary.entity.salarysob.dto.SalarySobItemAggregateDTO; +import com.engine.salary.util.JsonUtil; +import com.engine.salary.util.SalaryI18nUtil; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang3.StringUtils; + +import java.util.Date; +import java.util.LinkedList; +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; + +/** + * @Description: 工资单 + */ +public class SalaryTemplateBO { + + @Override + public String toString() { + return "SalaryTemplateBO{}"; + } + + + /** + * 获取人员信息项目分类 + * + * @param salaryItemSetting + * @return + */ + public static SalaryTemplateSalaryItemSetListDTO getEmployeeInformation(List salaryItemSetting) { + Optional optionalEmployeeInformation = salaryItemSetting.stream().filter(e -> SalaryTemplateSalaryItemSetGroupConstant.EMPLOYEE_INFO_GROUP_ID.equals(e.getGroupId())).findFirst(); + SalaryTemplateSalaryItemSetListDTO employeeInformation = optionalEmployeeInformation.orElse(null); + // 排除名称为空的 + if (employeeInformation != null && org.apache.commons.collections.CollectionUtils.isNotEmpty(employeeInformation.getItems())) { + employeeInformation.setItems(employeeInformation.getItems().stream().filter(e -> StringUtils.isNotEmpty(e.getName())).collect(Collectors.toList())); + } + return employeeInformation; + } + + /** + * 保存参数转表数据 + * @param saveParam + * @param employeeId + * @return + */ + public static SalaryTemplatePO convertToPO(SalaryTemplateSaveParam saveParam, Long employeeId) { + if (saveParam == null) { + return null; + } + + return SalaryTemplatePO.builder() + .id(saveParam.getId()) + .name(saveParam.getName()) + .salarySobId(saveParam.getSalarySobId()) + .description(saveParam.getDescription()) + .emailStatus(saveParam.getEmailStatus()?1:0) +// .sendEmailId(saveParam.getEmailStatus()?saveParam.getSendEmail():0L) + .msgStatus(saveParam.getMsgStatus()?1:0) + .theme(saveParam.getTheme()) + .background(saveParam.getBackground()) + .textContent(saveParam.getTextContent()) + .textContentPosition(saveParam.getTextContentPosition()) + .salaryItemNullStatus(saveParam.getSalaryItemNullStatus()?1:0) + .salaryItemZeroStatus(saveParam.getSalaryItemZeroStatus()?1:0) + .salaryItemSetting(saveParam.getSalaryItemSetting() != null ? JSONUtil.toJsonStr(saveParam.getSalaryItemSetting()) : "") + .replenishName(saveParam.getReplenishName()) + .replenishRule(saveParam.getReplenishRule()) + .replenishSalaryItemSetting((saveParam.getSalaryItemSetting() != null ? JsonUtil.toJsonString(saveParam.getReplenishSalaryItemSetting()) : "")) + .autoSendStatus(saveParam.getAutoSendStatus()?1:0) + .autoSendDayOfMonth(saveParam.getAutoSendDayOfMonth()) + .autoSendTimeOfDay(saveParam.getAutoSendTimeOfDay()) + .ackFeedbackStatus(saveParam.getAckFeedbackStatus()?1:0) + .feedbackStatus(saveParam.getFeedbackStatus()?1:0) + .autoAckDays(saveParam.getAutoAckDays()) + .feedbackUrl(saveParam.getFeedbackUrl()) + .mobileFeedbackUrl(saveParam.getMobileFeedbackUrl()) + .createTime(new Date()) + .updateTime(new Date()) + .creator(employeeId) + .build(); + } + + public static List convertSalarySobItemAggregateToSalaryItemSet(SalarySobItemAggregateDTO salarySobItemAggregateDTO, boolean isReplenish) { + List groups = new LinkedList<>(); + if (salarySobItemAggregateDTO!=null) { + // 1.员工信息 + if (CollectionUtils.isNotEmpty(salarySobItemAggregateDTO.getEmpFields())) { + List items = new LinkedList<>(); + salarySobItemAggregateDTO.getEmpFields().stream().forEach(e->{ + items.add( + SalaryTemplateSalaryItemListDTO.builder() + .id(String.valueOf(e.getId())) + .salaryItemId(String.valueOf(e.getId())) + .name(e.getFieldName()) + .sortedIndex(e.getSortedIndex()) + .build() + ); + }); + groups.add( + SalaryTemplateSalaryItemSetListDTO.builder() + .groupId(SalaryTemplateSalaryItemSetGroupConstant.EMPLOYEE_INFO_GROUP_ID) + .groupName("员工信息") + .sortedIndex(-1) + .items(items) + .build()); + } + // 2.普通分组 + if (CollectionUtils.isNotEmpty(salarySobItemAggregateDTO.getItemGroups())) { + salarySobItemAggregateDTO.getItemGroups().stream().forEach(e->{ + List items = new LinkedList<>(); + e.getItems().stream().forEach(i->{ + items.add( + SalaryTemplateSalaryItemListDTO.builder() + .id(String.valueOf(i.getSalaryItemId())) + .salaryItemId(String.valueOf(i.getSalaryItemId())) + .name(i.getName()) + .salaryItemShowName(i.getName()) + .originName(i.getName()) + .sortedIndex(i.getSortedIndex()) + .build()); + }); + groups.add( + SalaryTemplateSalaryItemSetListDTO.builder() + .groupId(String.valueOf(e.getId())) + .groupName(e.getName()) + .sortedIndex(e.getSortedIndex()) + .items(items) + .build()); + }); + } + // 3.无分类 + if (CollectionUtils.isNotEmpty(salarySobItemAggregateDTO.getItems())) { + List items = new LinkedList<>(); + salarySobItemAggregateDTO.getItems().stream().forEach(e->{ + items.add( + SalaryTemplateSalaryItemListDTO.builder() + .id(String.valueOf(e.getSalaryItemId())) + .salaryItemId(String.valueOf(e.getSalaryItemId())) + .name(e.getName()) + .salaryItemShowName(e.getName()) + .originName(e.getName()) + .sortedIndex(e.getSortedIndex()) + .build()); + }); + groups.add( + SalaryTemplateSalaryItemSetListDTO.builder() + .groupId(SalaryTemplateSalaryItemSetGroupConstant.NO_TYPE_GROUP_ID) + .groupName("无分类") + .sortedIndex(salarySobItemAggregateDTO.getItemGroups().size()) + .items(items) + .build()); + } + + if (isReplenish) { + // 4.已发补发 + if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(salarySobItemAggregateDTO.getBackCalcItems())) { + List items = new LinkedList<>(); + salarySobItemAggregateDTO.getBackCalcItems().forEach(e -> { + items.add( + SalaryTemplateSalaryItemListDTO.builder() + .id(String.valueOf(e.getSalaryItemId())) + .salaryItemId(String.valueOf(e.getSalaryItemId())) + .name(e.getName()) + .salaryItemShowName(e.getName()) + .originName(e.getName()) + .sortedIndex(e.getSortedIndex()) + .build() + ); + }); + + groups.add( + SalaryTemplateSalaryItemSetListDTO.builder() + .groupId(SalaryTemplateSalaryItemSetGroupConstant.REPLENISH_GROUP_ID) + .groupName(SalaryI18nUtil.getI18nLabel(139698, "已发补发")) + .sortedIndex(groups.size() + 1) + .items(items) + .build()); + } + } + + } + return groups; + } +} diff --git a/src/com/engine/salary/entity/salaryBill/dto/MySalaryShowSetDTO.java b/src/com/engine/salary/entity/salaryBill/dto/MySalaryShowSetDTO.java new file mode 100644 index 000000000..7ca948821 --- /dev/null +++ b/src/com/engine/salary/entity/salaryBill/dto/MySalaryShowSetDTO.java @@ -0,0 +1,40 @@ +package com.engine.salary.entity.salaryBill.dto; + +import io.swagger.annotations.ApiModel; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Description: 我的薪资福利显示设置 + * @Author: wangxiangzhong + * @Date: 2023/8/7 13:05 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@ApiModel("工资单确认和反馈") +public class MySalaryShowSetDTO { + + /** + * 是否显示工资单列表 + */ + private Boolean salaryShowStatus; + + /** + * 是否显示社保福利列表 + */ + // private Boolean welfareShowStatus; + + /** + * 是否显示调薪记录列表 + */ + private Boolean adjustShowStatus; + + /** + * 是否显示个税扣缴义务人列 + */ + private Boolean taxAgentShowStatus; +} diff --git a/src/com/engine/salary/entity/salaryBill/dto/SalaryBaseSetFormDTO.java b/src/com/engine/salary/entity/salaryBill/dto/SalaryBaseSetFormDTO.java new file mode 100644 index 000000000..af7ee8655 --- /dev/null +++ b/src/com/engine/salary/entity/salaryBill/dto/SalaryBaseSetFormDTO.java @@ -0,0 +1,38 @@ +package com.engine.salary.entity.salaryBill.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author Harryxzy + * @ClassName SalaryBaseSetFormDTO + * @date 2023/06/09 11:36 + * @description 工资单基础设置表单 + */ + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalaryBaseSetFormDTO { + +// private Long id; + + // 启用水印 + private Boolean watermarkStatus; + + // 水印类型 + private String watermark; + + // 水印设置 + private Object watermarkSetting; + + // 工资单反馈设置 + private SalaryBillAckFeedbackDTO ackFeedbackSetting; + + //工资单时效查看限制 + private com.engine.salary.entity.salaryBill.dto.salaryBillViewingLimitSetting salaryBillViewingLimitSetting; + +} diff --git a/src/com/engine/salary/entity/salaryBill/dto/SalaryBillAckFeedbackDTO.java b/src/com/engine/salary/entity/salaryBill/dto/SalaryBillAckFeedbackDTO.java new file mode 100644 index 000000000..15b336d69 --- /dev/null +++ b/src/com/engine/salary/entity/salaryBill/dto/SalaryBillAckFeedbackDTO.java @@ -0,0 +1,46 @@ +package com.engine.salary.entity.salaryBill.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author Harryxzy + * @ClassName SalaryBillAckFeedbackDTO + * @date 2023/07/12 13:46 + * @description 工资单确认和反馈DTO + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalaryBillAckFeedbackDTO { + + /** + * 工资单确认是否开启。0:否,1:是 + */ + private String ackStatus; + + /** + * 工资单反馈是否开启。0:否,1:是 + */ + private String feedbackStatus; + + /** + * 反馈地址 + */ + private String feedBackUrl; + + + /** + * 移动端反馈地址 + */ + private String mobileFeedbackUrl; + + /** + * 超时自动确认天数 + */ + private Integer autoAckDays; + +} diff --git a/src/com/engine/salary/entity/salaryBill/dto/SalaryBillItemNameDTO.java b/src/com/engine/salary/entity/salaryBill/dto/SalaryBillItemNameDTO.java new file mode 100644 index 000000000..4deae25f5 --- /dev/null +++ b/src/com/engine/salary/entity/salaryBill/dto/SalaryBillItemNameDTO.java @@ -0,0 +1,30 @@ +package com.engine.salary.entity.salaryBill.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author Harryxzy + * @ClassName SalaryBillItemNameDTO + * @date 2023/07/19 9:21 + * @description 工资单薪资项目展示名称 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalaryBillItemNameDTO { + + /** + * 薪资项目id + */ + private Long salaryItemId; + + + /** + * 工资单展示名称 + */ + private String salaryItemShowName; +} diff --git a/src/com/engine/salary/entity/salaryBill/dto/SalaryBillSendDTO.java b/src/com/engine/salary/entity/salaryBill/dto/SalaryBillSendDTO.java new file mode 100644 index 000000000..dc9d31b73 --- /dev/null +++ b/src/com/engine/salary/entity/salaryBill/dto/SalaryBillSendDTO.java @@ -0,0 +1,99 @@ +package com.engine.salary.entity.salaryBill.dto; + +import com.engine.salary.entity.salaryBill.po.SalarySendPO; +import com.engine.salary.entity.salaryBill.po.SalaryTemplatePO; +import com.engine.salary.enums.salarybill.MessageChannelEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import weaver.hrm.User; + +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * 工资单发放信息 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//工资单发放信息 +public class SalaryBillSendDTO { + + /** + * 薪资所属月 + */ + private Date salaryDate; + + //消息标题 + private String title; + + //消息内容 + private String text; + + //工资单预览实体名 + private String entityName; + + //发送通道 + private Set sendChannels; + + //发送者 + private User sendUser; + + //工资单模板 + private SalaryTemplatePO salaryTemplate; + + //工资单背景图base64编码 + private String backgroundBase64; + + //云桥工资单消息图 + private String picUrl; + + //扣缴义务人名称 +// private String taxAgentName; + + //工资单模板-薪资项目设置 + private List salaryItemSetList; + + //短信模板 + private SalaryTemplateSMSSetDTO smsSetting; + + //工资单模板-员工基本信息 + private SalaryTemplateSalaryItemSetListDTO employeeInformation; + + //工资单模板-对应人员字段 + private Map employeeField; + + //工资单模板-发放说明标签国际化 + private String remarkI18n; + + //邮件是否可以发送邮件 +// private boolean isEnableEmail; + + //工资单发放 + private SalarySendPO salarySend; + + //收入所得项目类型 + private List incomeCategorys; + + //薪资项目收入所得类型 + private Map salaryItemIncomeCategoryMap; + + //工资单水印设置 + SalaryBillWatermarkDTO watermarkSetting; + + //邮件水印模板 + private String emailWmContentTemplate; + + //工资单水印文本动态变量 + private List wmTextFieldIds; +} diff --git a/src/com/engine/salary/entity/salaryBill/dto/SalaryBillWatermarkDTO.java b/src/com/engine/salary/entity/salaryBill/dto/SalaryBillWatermarkDTO.java new file mode 100644 index 000000000..7426d6fcc --- /dev/null +++ b/src/com/engine/salary/entity/salaryBill/dto/SalaryBillWatermarkDTO.java @@ -0,0 +1,37 @@ +package com.engine.salary.entity.salaryBill.dto; + +import com.engine.salary.enums.salarybill.SalaryTemplateWatermarkTypeEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Map; + +/** + * @Description: 工资单水印 + * @Author: Harryxzy + * @Date: 2023/6/09 11:15 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalaryBillWatermarkDTO { + + /** + * 水印是否开启。0:否,1:是 + */ + private Boolean watermarkStatus; + + /** + * 水印类型 + * @see SalaryTemplateWatermarkTypeEnum + */ + private String watermarkType; + + /** + * 自定义水印设置内容 + */ + private Map wmSetting; +} diff --git a/src/com/engine/salary/entity/salaryBill/dto/SalaryMySalaryBillListDTO.java b/src/com/engine/salary/entity/salaryBill/dto/SalaryMySalaryBillListDTO.java new file mode 100644 index 000000000..8824004c6 --- /dev/null +++ b/src/com/engine/salary/entity/salaryBill/dto/SalaryMySalaryBillListDTO.java @@ -0,0 +1,40 @@ +package com.engine.salary.entity.salaryBill.dto; + +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; + +/** + * @Description: 我的工资单 + * @Author: wangxiangzhong + * @Date: 2021/12/14 15:34 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalaryMySalaryBillListDTO { + + private Long id; + + @JsonFormat(pattern = "yyyy-MM", timezone = "GMT+8") + private Date salaryYearMonth; + + private String acctTimes; + + private String taxAgent; + + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date sendTime; + + + private Long employeeId; + + private String salaryCode; + + +} diff --git a/src/com/engine/salary/entity/salaryBill/dto/SalarySendBaseInfoDTO.java b/src/com/engine/salary/entity/salaryBill/dto/SalarySendBaseInfoDTO.java new file mode 100644 index 000000000..05b69d9bf --- /dev/null +++ b/src/com/engine/salary/entity/salaryBill/dto/SalarySendBaseInfoDTO.java @@ -0,0 +1,54 @@ +package com.engine.salary.entity.salaryBill.dto; + +import com.engine.salary.entity.salarysob.dto.SalarySobCycleDTO; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.time.YearMonth; + +/** + * @Description: 工资单发放基本信息 + * @Author: wangxiangzhong + * @Date: 2021/12/14 14:02 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +////"工资单发放基本信息") +public class SalarySendBaseInfoDTO { + +// 已发送") + private Integer sendNum; + +// 总数") + private Integer sendTotal; + +// 工资单模板") + private String template; + +// 薪资所属月") + @JsonSerialize(using = ToStringSerializer.class) + private YearMonth salaryMonth; + +// 薪资账套的周期") + private SalarySobCycleDTO salarySobCycle; + +// // 工资单发放类型 1:正常 2:补发 +// private String salaryAcctType; +// +// // 是否回算过 0:没有回算过,1:回算过 +// private Integer haveBackCalc; + + // 能否发送 + private Boolean canSend; + + /** + * 是否支持导出工资单pdf + */ + private Boolean showPdfBtn; +} diff --git a/src/com/engine/salary/entity/salaryBill/dto/SalarySendCheckDTO.java b/src/com/engine/salary/entity/salaryBill/dto/SalarySendCheckDTO.java new file mode 100644 index 000000000..4c04cb768 --- /dev/null +++ b/src/com/engine/salary/entity/salaryBill/dto/SalarySendCheckDTO.java @@ -0,0 +1,28 @@ +package com.engine.salary.entity.salaryBill.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author Harryxzy + * @date 2022/11/24 14:11 + * @description 工资单发放检查信息 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalarySendCheckDTO { + + // 核算id + private Long salaryAcctId; + + // 是否存在已经发送 + private boolean isAlreadySend; + + // 是否已经发送完成 + private boolean isSendFinished; + +} diff --git a/src/com/engine/salary/entity/salaryBill/dto/SalarySendDetailListDTO.java b/src/com/engine/salary/entity/salaryBill/dto/SalarySendDetailListDTO.java new file mode 100644 index 000000000..ae647ab04 --- /dev/null +++ b/src/com/engine/salary/entity/salaryBill/dto/SalarySendDetailListDTO.java @@ -0,0 +1,58 @@ +package com.engine.salary.entity.salaryBill.dto; + +import com.engine.salary.annotation.I18n; +import com.engine.salary.enums.datacollection.DataCollectionEmployeeTypeEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Description: 工资单发放信息 + * @Author: wangxiangzhong + * @Date: 2021-12-11 11:29 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//"工资单发放详情列表") +public class SalarySendDetailListDTO { + +// 主键id +// @JsonSerialize(using = ToStringSerializer.class) + private Long id; + + private Long employeeId; + + /** + * 人员类型,0或null组织架构,1非系统人员 + * + * @see DataCollectionEmployeeTypeEnum + */ + private Integer employeeType; + + /** + * 用于发送工资单邮件 + */ +// @JsonIgnore + private String email; + +// 姓名") + @I18n + private String username; + +// 个税扣缴义务人") + private String taxAgent; + private Long taxAgentId; + +// 部门") + @I18n + private String department; + +// 手机号") + private String mobile; + +// 工号") + private String jobNum; +} diff --git a/src/com/engine/salary/entity/salaryBill/dto/SalarySendInfoListDTO.java b/src/com/engine/salary/entity/salaryBill/dto/SalarySendInfoListDTO.java new file mode 100644 index 000000000..9bc3753a6 --- /dev/null +++ b/src/com/engine/salary/entity/salaryBill/dto/SalarySendInfoListDTO.java @@ -0,0 +1,82 @@ +package com.engine.salary.entity.salaryBill.dto; + +import com.engine.salary.annotation.I18n; +import com.engine.salary.annotation.TableTitle; +import com.engine.salary.enums.datacollection.DataCollectionEmployeeTypeEnum; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Description: 工资单发放信息 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +////"工资单发放信息列表") +//@TableOperates(tableType = WeaTableTypeEnum.CHECKBOX) +public class SalarySendInfoListDTO { + + @JsonSerialize(using = ToStringSerializer.class) + private Long id; + + private Long employeeId; + + @TableTitle(title = "姓名", dataIndex = "username", key = "username") + @I18n + private String username; + + + @TableTitle(title = "个税扣缴义务人", dataIndex = "taxAgent", key = "taxAgent") + private String taxAgent; + private Long taxAgentId; + + + @TableTitle(title = "部门", dataIndex = "department", key = "department") + @I18n + private String department; + + + @TableTitle(title = "手机号", dataIndex = "mobile", key = "mobile") + private String mobile; + + + @TableTitle(title = "工号", dataIndex = "jobNum", key = "jobNum") + private String jobNum; + + + @TableTitle(title = "发送状态", dataIndex = "sendStatus", key = "sendStatus") + private String sendStatus; + + @TableTitle(title = "查看状态", dataIndex = "billReadStatus", key = "billReadStatus") + private String billReadStatus; + + @TableTitle(title = "确认状态", dataIndex = "billConfirmStatus", key = "billConfirmStatus") + private String billConfirmStatus; + + private String email; + private Long salaryAcctRecordId; + /** + * 核算类型。0:正常,1:补发 + */ + private Integer salaryAcctType; + + /** + * 该模板是否开启了工资单反馈确认 + */ + private boolean needAck; + + + /** + * 人员类型,0或null组织架构,1非系统人员 + * + * @see DataCollectionEmployeeTypeEnum + */ + private Integer employeeType; + + +} diff --git a/src/com/engine/salary/entity/salaryBill/dto/SalarySendListDTO.java b/src/com/engine/salary/entity/salaryBill/dto/SalarySendListDTO.java new file mode 100644 index 000000000..ff2bb7d2a --- /dev/null +++ b/src/com/engine/salary/entity/salaryBill/dto/SalarySendListDTO.java @@ -0,0 +1,154 @@ +package com.engine.salary.entity.salaryBill.dto; + +import com.engine.salary.annotation.Auth; +import com.engine.salary.annotation.SalaryTable; +import com.engine.salary.annotation.SalaryTableColumn; +import com.engine.salary.annotation.SalaryTableOperate; +import com.engine.salary.enums.auth.AuthCheckTypeEnum; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; +import java.util.Set; + +/** + * @Description: 工资单发放 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@SalaryTable(pageId = "a4f85287-289dff07669d7a23de0ef88d2f7129e7", operates = { + @SalaryTableOperate(index = "0", text = "发放"), + @SalaryTableOperate(index = "1", text = "查看详情"), + @SalaryTableOperate(index = "2", text = "更新模板") +}) +@Auth(page = "salaryBill", checkType = AuthCheckTypeEnum.SOB, sobIdField = "salarySobId") +public class SalarySendListDTO { + + // 主键id + @SalaryTableColumn(column = "id", display = false) + private Long id; + +// 薪资所属月") +// @WeaFormat( +// label = "薪资所属月", +// labelId = 87614, +// tableColumn = @TableColumn(width = "10%") +// ) +// @JsonFormat(pattern = "yyyy-MM") + + // 薪资所属月 + @SalaryTableColumn(text = "薪资所属月", width = "10%", column = "salaryYearMonth") + private Date salaryYearMonth; + + /** + * 薪资账套id + */ + @JsonIgnore + private Long salarySobId; + +// 薪资账套") +// @WeaFormat( +// label = "薪资账套", +// labelId = 87889, +// tableColumn = @TableColumn(width = "35%") +// ) + + // 薪资账套 + @SalaryTableColumn(text = "薪资账套", width = "35%", column = "username") + private String salarySob; + + // 核算次数") +// 核算次数 + private String acctTimes; + + // 工资单模板") +// @WeaFormat( +// label = "工资单模板", +// labelId = 93214, +// tableColumn = @TableColumn(width = "25%") +// ) + @SalaryTableColumn(text = "工资单模板", width = "25%", column = "template") +// 工资单模板 + private String template; + + // 工资单模板Id") +// 工资单模板Id + @SalaryTableColumn(text = "工资单模板id", width = "0%", column = "templateId", display = false) + private Long templateId; + + /** + * 已发送数量 + */ +// @JsonIgnore + @SalaryTableColumn(text = "已发送数量", width = "0%", column = "sendNum", display = false) + private Integer sendNum; + + /** + * 发送总数 + */ +// @JsonIgnore + @SalaryTableColumn(text = "发送总数", width = "0%", column = "sendTotal", display = false) + private Integer sendTotal; + + // 已发放") +// @WeaFormat( +// label = "已发放", +// labelId = 93212, +// tableColumn = @TableColumn(width = "15%") +// ) +// 已发放 + @SalaryTableColumn(text = "已发放", width = "15%", column = "sendSituation") + private String sendSituation; + + // 最后发送时间") +// @WeaFormat( +// label = "最后发送时间", +// labelId = 93213, +// tableColumn = @TableColumn(width = "15%") +// ) +// @JsonFormat(pattern = "yyyy-MM-dd HH:mm") +// 最后发送时间 + @SalaryTableColumn(text = "最后发送时间", width = "15%", column = "lastSendTime") + private Date lastSendTime; + + /** + * 薪资核算ID + */ + private Long salaryAcctId; + + /** + * 发放状态。0:未冻结、1:已冻结 + */ + private Integer sendStatus; + + /** + * 工资单类型。0:正常,1:补发 + */ + private Integer salaryAcctType; + + /** + * 薪资记录核算类型。0:正常,1:补发 + */ + private Integer salaryAcctRecordType; + + /** + * 能够查看详情 + */ + private Boolean canSeeDetail; + /** + * 是否回算过 0:没有回算过,1:回算过 + */ +// private Integer haveBackCalc; + + /** + * 工资单确认反馈状态 + */ + private Integer ackFeedbackStatus; + + private Set opts; +} diff --git a/src/com/engine/salary/entity/salaryBill/dto/SalarySendRangeListDTO.java b/src/com/engine/salary/entity/salaryBill/dto/SalarySendRangeListDTO.java new file mode 100644 index 000000000..4a407645b --- /dev/null +++ b/src/com/engine/salary/entity/salaryBill/dto/SalarySendRangeListDTO.java @@ -0,0 +1,36 @@ +package com.engine.salary.entity.salaryBill.dto; + +import com.cloudstore.eccom.pc.table.WeaTableType; +import com.engine.salary.annotation.SalaryTable; +import com.engine.salary.annotation.SalaryTableColumn; +import com.engine.salary.annotation.TableTitle; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@SalaryTable(pageId = "a4fa2487-d36a82d0dc050a5465f1252f9ecaa107", + tableType = WeaTableType.CHECKBOX) +public class SalarySendRangeListDTO { + @JsonSerialize(using = ToStringSerializer.class) + @SalaryTableColumn(column = "id", display = false) + private Long id; + + private String grantType; + + @SalaryTableColumn(text = "对象", width = "50%", column = "includeObj") + @TableTitle(title = "对象", key = "includeObj", dataIndex = "includeObj") + private List includeObj; + + @SalaryTableColumn(text = "对象中排除", width = "50%", column = "excludeObj") + @TableTitle(title = "对象中排除", key = "excludeObj", dataIndex = "excludeObj") + private List excludeObj; +} diff --git a/src/com/engine/salary/entity/salaryBill/dto/SalarySendRangeObjDTO.java b/src/com/engine/salary/entity/salaryBill/dto/SalarySendRangeObjDTO.java new file mode 100644 index 000000000..e6a85c9ed --- /dev/null +++ b/src/com/engine/salary/entity/salaryBill/dto/SalarySendRangeObjDTO.java @@ -0,0 +1,44 @@ +package com.engine.salary.entity.salaryBill.dto; + +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 工资单发放撤回筛选范围对象 + */ +@AllArgsConstructor +@NoArgsConstructor +@Data +@Builder +public class SalarySendRangeObjDTO { + + /** + * id + */ + @JsonSerialize(using = ToStringSerializer.class) + private Long targetId; + + /** + * 名称 + */ + private String targetName; + + /** + * 类型 + */ + private Integer targetType; + + /** + * 类型名称 + */ + private String targetTypeName; + + /** + * @see com.engine.salary.enums.salarysend.SalarySendRangeTypeEnum + */ + private Integer rangeType; +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/salaryBill/dto/SalarySendUserInfoDTO.java b/src/com/engine/salary/entity/salaryBill/dto/SalarySendUserInfoDTO.java new file mode 100644 index 000000000..0b2648af0 --- /dev/null +++ b/src/com/engine/salary/entity/salaryBill/dto/SalarySendUserInfoDTO.java @@ -0,0 +1,38 @@ +package com.engine.salary.entity.salaryBill.dto; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@AllArgsConstructor +@NoArgsConstructor +@Data +public class SalarySendUserInfoDTO { + /** + * 岗位 + */ + private Long jobTitle; + + /** + * 部门 + */ + private Long departmentId; + + /** + * 分部 + */ + private Long subCompanyId; + + + /** + * 人员id + */ + private Long resourceId; + + /** + * 个税扣缴义务人id + */ + private List taxAgentIds; +} diff --git a/src/com/engine/salary/entity/salaryBill/dto/SalaryTemplateBaseFormDTO.java b/src/com/engine/salary/entity/salaryBill/dto/SalaryTemplateBaseFormDTO.java new file mode 100644 index 000000000..18ca1ebc4 --- /dev/null +++ b/src/com/engine/salary/entity/salaryBill/dto/SalaryTemplateBaseFormDTO.java @@ -0,0 +1,27 @@ +package com.engine.salary.entity.salaryBill.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; +import java.util.Map; + +/** + * @Description: 工资单模板 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalaryTemplateBaseFormDTO { + + private Long id; + + // 基础设置 + private Map salaryTemplateBaseSet; + + // 补发规则设置下拉列表 + private List> replenishRuleSetOption; +} diff --git a/src/com/engine/salary/entity/salaryBill/dto/SalaryTemplateBaseSetDTO.java b/src/com/engine/salary/entity/salaryBill/dto/SalaryTemplateBaseSetDTO.java new file mode 100644 index 000000000..93f0ec5e6 --- /dev/null +++ b/src/com/engine/salary/entity/salaryBill/dto/SalaryTemplateBaseSetDTO.java @@ -0,0 +1,106 @@ +package com.engine.salary.entity.salaryBill.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; +import java.util.Map; + +/** + * @Description: 工资单模板 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalaryTemplateBaseSetDTO { + + /* ===== 1.基础信息 ======================*/ + + //薪资账套") + private Long salarySob; + + private List> salarySobOptions; + + //工资单模板名称") + private String name; + + //备注") + private String description; + + + //补发工资单模板名称") + private String replenishName; + + //补发工资单名单生成规则") + private String replenishRule; + + //规则设置") + private String replenishRuleSet; + + + /* ===== 2.发送设置 ======================*/ + + //邮件") + private Boolean emailStatus; + + //发送地址") + private Long sendEmail; + + // 邮件列表 + private List> sendEmailOptions; + + //消息中心") + private Boolean msgStatus; + + /** + * 短信开启状态。0:关、1:开,默认关闭 + */ + private Integer smsStatus; + + /** + * 短信模板设置 + */ + private String smsSetting; + + // 是否启用工资单定时发送 + private Boolean autoSendStatus; + + // 自动发送工资单周期1:本月、2:上月 + private Integer autoSendCycleType; + + // 每月几号自动发送工资单 + private String autoSendDayOfMonth; + + // 发送时间 + private String autoSendTimeOfDay; + + /** + * 工资单确认反馈状态 + */ + private Boolean ackFeedbackStatus; + + /** + * 工资单确认反馈状态 + */ + private Boolean feedbackStatus; + + /** + * 自动确认超时天数 + */ + private Integer autoAckDays; + + /** + * 反馈流程地址 + * + */ + private String feedbackUrl; + + /** + * 移动端反馈流程地址 + * + */ + private String mobileFeedbackUrl; +} diff --git a/src/com/engine/salary/entity/salaryBill/dto/SalaryTemplateListDTO.java b/src/com/engine/salary/entity/salaryBill/dto/SalaryTemplateListDTO.java new file mode 100644 index 000000000..5fdaaef98 --- /dev/null +++ b/src/com/engine/salary/entity/salaryBill/dto/SalaryTemplateListDTO.java @@ -0,0 +1,72 @@ +package com.engine.salary.entity.salaryBill.dto; + +import com.engine.hrmelog.annotation.ElogTransform; +import com.engine.salary.annotation.*; +import com.engine.salary.enums.auth.AuthCheckTypeEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Set; + +/** + * @Description: 工资单模板 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@SalaryTable(pageId = "a4f85287-d36a8210dc050a5465fa852f9ecaa107", operates = { + @SalaryTableOperate(index = "0", text = "编辑" ), + @SalaryTableOperate(index = "1", text = "复制" ), + @SalaryTableOperate(index = "2", text = "删除" ), + @SalaryTableOperate(index = "3", text = "操作日志" ) +}) +@ElogTransform(name = "工资单模板") +@Auth(page = "salaryBill", checkType = AuthCheckTypeEnum.SOB) +public class SalaryTemplateListDTO { + + //主键id + @SalaryTableColumn(column = "id", display = false) + @TableTitle(title = "id", dataIndex = "id", key = "id",display = false) + @ElogTransform(name = "id") + private Long id; + + //工资单模板名称 + @SalaryTableColumn(text = "工资单模板名称", width = "20%", column = "name") + @TableTitle(title = "工资单模板名称", dataIndex = "name", key = "name") + @ElogTransform(name = "工资单模板名称") + private String name; + + //补发工资单模板名称 + @SalaryTableColumn(text = "补发工资单模板名称", width = "20%", column = "replenishName") + @TableTitle(title = "补发工资单模板名称", dataIndex = "replenishName", key = "replenishName") + @ElogTransform(name = "补发工资单模板名称") + private String replenishName; + + + //所属薪资账套 + @SalaryTableColumn(text = "所属薪资账套", width = "20%", column = "salarySob") + @TableTitle(title = "所属薪资账套", dataIndex = "salarySob", key = "salarySob") + @ElogTransform(name = "所属薪资账套") + private String salarySob; + + //默认使用 + @SalaryTableColumn(text = "默认使用", width = "20%", column = "useType") + @TableTitle(title = "默认使用", dataIndex = "useType", key = "useType") + @ElogTransform(name = "默认使用") + private String useType; + + // 备注 + @SalaryTableColumn(text = "备注", width = "20%", column = "description") + @TableTitle(title = "备注", dataIndex = "description", key = "description") + @ElogTransform(name = "备注") + private String description; + + // 薪资账套id + private Long salarySobId; + + + private Set opts; +} diff --git a/src/com/engine/salary/entity/salaryBill/dto/SalaryTemplateReplenishFormDTO.java b/src/com/engine/salary/entity/salaryBill/dto/SalaryTemplateReplenishFormDTO.java new file mode 100644 index 000000000..0e90569db --- /dev/null +++ b/src/com/engine/salary/entity/salaryBill/dto/SalaryTemplateReplenishFormDTO.java @@ -0,0 +1,33 @@ +package com.engine.salary.entity.salaryBill.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; +import java.util.Map; + +/** + * @author Harryxzy + * @date 2022/12/02 17:18 + * @description 工资单补发表单 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +////"工资单补发表单") +public class SalaryTemplateReplenishFormDTO { + +// 主键id") +// @JsonSerialize(using = ToStringSerializer.class) + private Long id; + +// 薪资项目设置") + private List replenishSalaryTemplateSalaryItemSet; + + // 工资单项目名称设置 + private Map salaryBillItemNameSet; + +} diff --git a/src/com/engine/salary/entity/salaryBill/dto/SalaryTemplateSMSDTO.java b/src/com/engine/salary/entity/salaryBill/dto/SalaryTemplateSMSDTO.java new file mode 100644 index 000000000..829c6c799 --- /dev/null +++ b/src/com/engine/salary/entity/salaryBill/dto/SalaryTemplateSMSDTO.java @@ -0,0 +1,23 @@ +package com.engine.salary.entity.salaryBill.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalaryTemplateSMSDTO { + + //展示名称 + private String itemName; + + //薪资项目 + private String itemKey; + + //来源 + private String source; +} diff --git a/src/com/engine/salary/entity/salaryBill/dto/SalaryTemplateSMSSetDTO.java b/src/com/engine/salary/entity/salaryBill/dto/SalaryTemplateSMSSetDTO.java new file mode 100644 index 000000000..ef21fc2fb --- /dev/null +++ b/src/com/engine/salary/entity/salaryBill/dto/SalaryTemplateSMSSetDTO.java @@ -0,0 +1,26 @@ +package com.engine.salary.entity.salaryBill.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 短信模板设置 + *

Copyright: Copyright (c) 2023

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalaryTemplateSMSSetDTO { + + /** + * 内容 + */ + private String content; +} diff --git a/src/com/engine/salary/entity/salaryBill/dto/SalaryTemplateSalaryItemListDTO.java b/src/com/engine/salary/entity/salaryBill/dto/SalaryTemplateSalaryItemListDTO.java new file mode 100644 index 000000000..858db75a1 --- /dev/null +++ b/src/com/engine/salary/entity/salaryBill/dto/SalaryTemplateSalaryItemListDTO.java @@ -0,0 +1,40 @@ +package com.engine.salary.entity.salaryBill.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Description: 工资单薪资项目 + * @Author: wangxiangzhong + * @Date: 2021-12-08 14:44 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +////"工资单薪资项目") +public class SalaryTemplateSalaryItemListDTO { + +// 薪资账套项目id") + private String id; + +// 薪资项目id") + private String salaryItemId; + +// 薪资项目值") + private String salaryItemValue; + + // 模板展示名称 salaryItemShowName+(originName) + private String name; + + // 薪资项目修改后展示名称 + private String salaryItemShowName; + + // 薪资项目名称原始值 + private String originName; + +// 顺序") + private Integer sortedIndex; +} diff --git a/src/com/engine/salary/entity/salaryBill/dto/SalaryTemplateSalaryItemSetListDTO.java b/src/com/engine/salary/entity/salaryBill/dto/SalaryTemplateSalaryItemSetListDTO.java new file mode 100644 index 000000000..c5527778f --- /dev/null +++ b/src/com/engine/salary/entity/salaryBill/dto/SalaryTemplateSalaryItemSetListDTO.java @@ -0,0 +1,31 @@ +package com.engine.salary.entity.salaryBill.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * @Description: 工资单薪资项目设置 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +////"工资单薪资项目设置") +public class SalaryTemplateSalaryItemSetListDTO { + +// 组id") + private String groupId; + +// 组名") + private String groupName; + +// 顺序") + private Integer sortedIndex; + +// 薪资项目") + private List items; +} diff --git a/src/com/engine/salary/entity/salaryBill/dto/SalaryTemplateShowFormDTO.java b/src/com/engine/salary/entity/salaryBill/dto/SalaryTemplateShowFormDTO.java new file mode 100644 index 000000000..43e52905b --- /dev/null +++ b/src/com/engine/salary/entity/salaryBill/dto/SalaryTemplateShowFormDTO.java @@ -0,0 +1,38 @@ +package com.engine.salary.entity.salaryBill.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; +import java.util.Map; + +/** + * @Description: 工资单模板 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +////"工资单显示设置表单") +public class SalaryTemplateShowFormDTO { + +// 主键id") + private Long id; + +// 插入变量") + private List vars; + +// 主题及其他设置") + private Map salaryTemplateShowSet; + +// 薪资项目设置") + private List salaryTemplateSalaryItemSet; + + // 补发工资薪资项目设置") + private List replenishSalaryTemplateSalaryItemSet; + + // 工资单项目名称设置 + private Map salaryBillItemNameSet; +} diff --git a/src/com/engine/salary/entity/salaryBill/dto/SalaryTemplateShowSetDTO.java b/src/com/engine/salary/entity/salaryBill/dto/SalaryTemplateShowSetDTO.java new file mode 100644 index 000000000..4b5efcd1c --- /dev/null +++ b/src/com/engine/salary/entity/salaryBill/dto/SalaryTemplateShowSetDTO.java @@ -0,0 +1,58 @@ +package com.engine.salary.entity.salaryBill.dto; + +import com.engine.salary.enums.salarybill.SalaryTemplateTextContentPositionEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * @Description: 工资单模板 + * @Author: wangxiangzhong + * @Date: 2021-12-08 14:44 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +////"主题及其他设置") +public class SalaryTemplateShowSetDTO { + +// 工资单主题") + private String theme; + +// 工资单背景图") + private String background; + +// 文本内容") + private String textContent; + +// 文本内容位置") + private String textContentPosition; + + private List> getTextContentPositionOptions () { + return Arrays.stream(SalaryTemplateTextContentPositionEnum.values()) + .map(m-> + { + Map map = new HashMap<>(); + map.put("id", String.valueOf(m.getValue())); + map.put("content", m.getDefaultLabel()); + return map; + }) + .collect(Collectors.toList()); + } + +// 薪资项为空时不显示") + private Boolean salaryItemNullStatus; + + +// 薪资项为0时不显示") + private Boolean salaryItemZeroStatus; + +} diff --git a/src/com/engine/salary/entity/salaryBill/dto/salaryBillViewingLimitSetting.java b/src/com/engine/salary/entity/salaryBill/dto/salaryBillViewingLimitSetting.java new file mode 100644 index 000000000..fbe9752bf --- /dev/null +++ b/src/com/engine/salary/entity/salaryBill/dto/salaryBillViewingLimitSetting.java @@ -0,0 +1,38 @@ +package com.engine.salary.entity.salaryBill.dto; + +import com.engine.salary.enums.salarybill.MonthTypeEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 工资单时效查看限制 + *

Copyright: Copyright (c) 2023

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class salaryBillViewingLimitSetting { + + /** + * 月份限制类型 + */ + private MonthTypeEnum monthType; + + /** + * 查看几月内的工资单 + */ + private Integer limitMonth; + + /** + * 首次查看后多少分钟不能查看工资单 + */ + private Integer burningAfterReadingMin; + +} diff --git a/src/com/engine/salary/entity/salaryBill/param/ReplenishFormQueryParam.java b/src/com/engine/salary/entity/salaryBill/param/ReplenishFormQueryParam.java new file mode 100644 index 000000000..840e8567e --- /dev/null +++ b/src/com/engine/salary/entity/salaryBill/param/ReplenishFormQueryParam.java @@ -0,0 +1,22 @@ +package com.engine.salary.entity.salaryBill.param; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author Harryxzy + * @date 2022/12/02 17:21 + * @description + */ +@Builder +@Data +@AllArgsConstructor +@NoArgsConstructor +public class ReplenishFormQueryParam { + + private Long id; + + private Long salarySobId; +} diff --git a/src/com/engine/salary/entity/salaryBill/param/SMSCodeCheckParam.java b/src/com/engine/salary/entity/salaryBill/param/SMSCodeCheckParam.java new file mode 100644 index 000000000..322db1253 --- /dev/null +++ b/src/com/engine/salary/entity/salaryBill/param/SMSCodeCheckParam.java @@ -0,0 +1,32 @@ +package com.engine.salary.entity.salaryBill.param; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 短信验证码发送参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SMSCodeCheckParam { + + /** + * 工资单id + */ + private Long id; + + /** + * 验证码 + */ + private String mobileCode; + +} diff --git a/src/com/engine/salary/entity/salaryBill/param/SMSCodeSendParam.java b/src/com/engine/salary/entity/salaryBill/param/SMSCodeSendParam.java new file mode 100644 index 000000000..9d25ea87a --- /dev/null +++ b/src/com/engine/salary/entity/salaryBill/param/SMSCodeSendParam.java @@ -0,0 +1,28 @@ +package com.engine.salary.entity.salaryBill.param; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 短信验证码发送参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SMSCodeSendParam { + + /** + * 工资单id + */ + private Long id; + + +} diff --git a/src/com/engine/salary/entity/salaryBill/param/SalaryBaseSetSaveParam.java b/src/com/engine/salary/entity/salaryBill/param/SalaryBaseSetSaveParam.java new file mode 100644 index 000000000..34ff4a72c --- /dev/null +++ b/src/com/engine/salary/entity/salaryBill/param/SalaryBaseSetSaveParam.java @@ -0,0 +1,62 @@ +package com.engine.salary.entity.salaryBill.param; + +import com.engine.salary.entity.salaryBill.dto.SalaryBillAckFeedbackDTO; +import com.engine.salary.enums.salarybill.SalaryTemplateWatermarkTypeEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.util.SalaryI18nUtil; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.apache.commons.lang3.StringUtils; + +import java.util.Map; +import java.util.Objects; + +/** + * @author Harryxzy + * @ClassName SalaryBaseSetSaveParam + * @date 2023/06/09 13:41 + * @description 工资单基础设置保存参数 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalaryBaseSetSaveParam { + + // 是否启用水印") + private Boolean watermarkStatus; + + // 水印类型") + private SalaryTemplateWatermarkTypeEnum watermark; + + // 自定义设置内容") + private Map wmSetting; + + // 工资单确认反馈设置 + private SalaryBillAckFeedbackDTO ackFeedbackSetting; + + //工资单时效性 + private com.engine.salary.entity.salaryBill.dto.salaryBillViewingLimitSetting salaryBillViewingLimitSetting; + + public static void checkParam(SalaryBaseSetSaveParam saveParam) { + if (Objects.isNull(saveParam.getWatermarkStatus())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(220418, "是否启用水印必传")); + } + // 如果开启了 + if (saveParam.getWatermarkStatus()) { + if (Objects.isNull(saveParam.getWatermark())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(220419, "水印类型必传")); + } + if (SalaryTemplateWatermarkTypeEnum.CUSTOM.equals(saveParam.getWatermark()) && (Objects.isNull(saveParam.getWmSetting()) || saveParam.getWmSetting().isEmpty())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(220419, "自定义水印的设置内容必传")); + } + } + if (Objects.isNull(saveParam.getAckFeedbackSetting()) || StringUtils.isBlank(saveParam.getAckFeedbackSetting().getAckStatus())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(220418, "工资单确认反馈信息必传")); + } + + } + +} diff --git a/src/com/engine/salary/entity/salaryBill/param/SalaryBillGetTokenParam.java b/src/com/engine/salary/entity/salaryBill/param/SalaryBillGetTokenParam.java new file mode 100644 index 000000000..2ab5be248 --- /dev/null +++ b/src/com/engine/salary/entity/salaryBill/param/SalaryBillGetTokenParam.java @@ -0,0 +1,26 @@ +package com.engine.salary.entity.salaryBill.param; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @ClassName SalaryBillGetTokenParam + * @author Harryxzy + * @date 2024/11/6 9:59 + * @description 第三方获取token参数 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalaryBillGetTokenParam { + + // 新 + private String salaryCode; + + // 老 未加密 + private String recipient; + +} diff --git a/src/com/engine/salary/entity/salaryBill/param/SalaryBillItemDetailQueryParam.java b/src/com/engine/salary/entity/salaryBill/param/SalaryBillItemDetailQueryParam.java new file mode 100644 index 000000000..7f5c96daf --- /dev/null +++ b/src/com/engine/salary/entity/salaryBill/param/SalaryBillItemDetailQueryParam.java @@ -0,0 +1,36 @@ +package com.engine.salary.entity.salaryBill.param; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * @author Harryxzy + * @date 2023/06/06 15:22 + * @description 我的工资单薪资项目明细查询 + */ + +@Builder +@Data +@AllArgsConstructor +@NoArgsConstructor +public class SalaryBillItemDetailQueryParam { + + /** + * 薪资核算记录id + */ + private Long salaryAcctId; + + /** + * 员工id + */ + private List employeeId; + + /** + * 薪资项目id + */ + private Long salaryItemId; +} diff --git a/src/com/engine/salary/entity/salaryBill/param/SalaryBillItemNameSaveParam.java b/src/com/engine/salary/entity/salaryBill/param/SalaryBillItemNameSaveParam.java new file mode 100644 index 000000000..9674df028 --- /dev/null +++ b/src/com/engine/salary/entity/salaryBill/param/SalaryBillItemNameSaveParam.java @@ -0,0 +1,46 @@ +package com.engine.salary.entity.salaryBill.param; + +import lombok.*; + +import java.util.List; + +/** + * @author Harryxzy + * @ClassName SalaryBillItemNameSaveParam + * @date 2023/07/19 10:20 + * @description 设置工资单项目展示名参数 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalaryBillItemNameSaveParam { + /** + * 工资单模板id + */ + private Long salaryTemplateId; + + /** + * 工资单类型。0:正常工资单、1:补发工资单 + */ + private Integer salaryBillType; + + private List itemShowNameSetting; + + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + public static class itemShowNameSetting { + /** + * 薪资项目id + */ + private Long salaryItemId; + + /** + * 工资单展示名称 + */ + private String salaryItemShowName; + } + +} diff --git a/src/com/engine/salary/entity/salaryBill/param/SalaryBillQueryParam.java b/src/com/engine/salary/entity/salaryBill/param/SalaryBillQueryParam.java new file mode 100644 index 000000000..4b43d69fc --- /dev/null +++ b/src/com/engine/salary/entity/salaryBill/param/SalaryBillQueryParam.java @@ -0,0 +1,38 @@ +package com.engine.salary.entity.salaryBill.param; + +import com.engine.salary.common.BaseQueryParam; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; +import java.util.List; + +/** + * @Description: 我的工资单 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +////"工资单发放信息查询参数") +public class SalaryBillQueryParam extends BaseQueryParam { + +// @JsonIgnore + private Long id; + +// 薪资所属月") + private List salaryYearMonth; + +// @JsonIgnore + private List salaryMonth; + + + private Date startSalaryMonth; + +// @JsonIgnore + private Long employeeId; + + private String token; +} diff --git a/src/com/engine/salary/entity/salaryBill/param/SalaryBillSalaryGroupQueryParam.java b/src/com/engine/salary/entity/salaryBill/param/SalaryBillSalaryGroupQueryParam.java new file mode 100644 index 000000000..36d8ab498 --- /dev/null +++ b/src/com/engine/salary/entity/salaryBill/param/SalaryBillSalaryGroupQueryParam.java @@ -0,0 +1,31 @@ +package com.engine.salary.entity.salaryBill.param; + +import com.engine.salary.common.BaseQueryParam; +import lombok.*; + +import java.util.List; + +@EqualsAndHashCode(callSuper = true) +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalaryBillSalaryGroupQueryParam extends BaseQueryParam { + + /** + * 薪资账套id + */ + private Long salarySobId; + + private Boolean isReplenish; + + /** + * 前端已有的分组id + */ + private List existSalaryGroupIds; + + /** + * 工资单模板id + */ + private Long salaryTemplateId; +} diff --git a/src/com/engine/salary/entity/salaryBill/param/SalaryBillSalaryItemQueryParam.java b/src/com/engine/salary/entity/salaryBill/param/SalaryBillSalaryItemQueryParam.java new file mode 100644 index 000000000..fa5540965 --- /dev/null +++ b/src/com/engine/salary/entity/salaryBill/param/SalaryBillSalaryItemQueryParam.java @@ -0,0 +1,26 @@ +package com.engine.salary.entity.salaryBill.param; + +import com.engine.salary.common.BaseQueryParam; +import lombok.*; + +import java.util.List; + +@EqualsAndHashCode(callSuper = true) +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalaryBillSalaryItemQueryParam extends BaseQueryParam { + + private Long salarySobId; + + private Long groupId; + + private String groupName; + + private Boolean isReplenish; + + private List existSalaryItemIds; + + private Long salaryTemplateId; +} diff --git a/src/com/engine/salary/entity/salaryBill/param/SalaryExportPdfParam.java b/src/com/engine/salary/entity/salaryBill/param/SalaryExportPdfParam.java new file mode 100644 index 000000000..a7085efad --- /dev/null +++ b/src/com/engine/salary/entity/salaryBill/param/SalaryExportPdfParam.java @@ -0,0 +1,26 @@ +package com.engine.salary.entity.salaryBill.param; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 工资单导出pdf参数 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalaryExportPdfParam { + + /** + * 工资单发放Id + */ + private Long salarySendId; + + /** + * 主键id + */ + private Long id; +} diff --git a/src/com/engine/salary/entity/salaryBill/param/SalaryPreviewParam.java b/src/com/engine/salary/entity/salaryBill/param/SalaryPreviewParam.java new file mode 100644 index 000000000..8d48e5118 --- /dev/null +++ b/src/com/engine/salary/entity/salaryBill/param/SalaryPreviewParam.java @@ -0,0 +1,32 @@ +package com.engine.salary.entity.salaryBill.param; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 工资单预览参数 + *

Copyright: Copyright (c) 2024

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalaryPreviewParam { + + /** + * 工资单id + */ + private Long salaryInfoId; + + /** + * 员工id + */ + private Long recipient; + +} diff --git a/src/com/engine/salary/entity/salaryBill/param/SalarySendDetailListQueryParam.java b/src/com/engine/salary/entity/salaryBill/param/SalarySendDetailListQueryParam.java new file mode 100644 index 000000000..ae526ad40 --- /dev/null +++ b/src/com/engine/salary/entity/salaryBill/param/SalarySendDetailListQueryParam.java @@ -0,0 +1,79 @@ +package com.engine.salary.entity.salaryBill.param; + +import com.engine.salary.common.BaseQueryParam; +import com.engine.salary.exception.SalaryRunTimeException; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.time.LocalDate; +import java.util.Collection; +import java.util.List; + +/** + * @Description: 工资单发放信息 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +////"工资单发放信息查询参数") +public class SalarySendDetailListQueryParam extends BaseQueryParam { + +// 主键id") + private Collection ids; + +// 工资单发放Id") + private Long salarySendId; + + /** + * 工资核算id + */ +// @JsonIgnore + private Long salaryAccountingId; + +// 关键字(姓名)") + private String keyword; + +// 姓名") + private String username; + private Long userId; + + +// 个税扣缴义务人的主键id") + private Long taxAgent; + +// 部门id") + private List departmentIds; + private String departmentIdStr; + + // 分部id + private List subCompanyIds; + private String subCompanyIdStr; + +// 岗位id") + private Long position; + +// 状态") + private String userstatus; + +// 入职日期") + private List hiredate; + +// 合并计税") + private Boolean mergeCountTax; + + /** + * 发送状态 + */ +// @JsonIgnore + private List sendStatuss; + + public static String checkParam(SalarySendDetailListQueryParam saveParam) { + if (saveParam.getSalarySendId() == null) { + throw new SalaryRunTimeException("工资单发放Id必传"); + } + return ""; + } +} diff --git a/src/com/engine/salary/entity/salaryBill/param/SalarySendDetailQueryParam.java b/src/com/engine/salary/entity/salaryBill/param/SalarySendDetailQueryParam.java new file mode 100644 index 000000000..1b49f639b --- /dev/null +++ b/src/com/engine/salary/entity/salaryBill/param/SalarySendDetailQueryParam.java @@ -0,0 +1,81 @@ +package com.engine.salary.entity.salaryBill.param; + +import com.engine.salary.common.BaseQueryParam; +import com.engine.salary.exception.SalaryRunTimeException; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.time.LocalDate; +import java.util.Collection; +import java.util.List; + +/** + * @Description: 工资单发放信息 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +////"工资单发放信息查询参数") +public class SalarySendDetailQueryParam extends BaseQueryParam { + +// 主键id") + private Collection ids; + +// 工资单发放Id") + private Long salarySendId; + + /** + * 工资核算id + */ +// @JsonIgnore + private Long salaryAccountingId; + +// 关键字(姓名)") + private String keyword; + +// 姓名") + private String username; + + private Long userId; + +// 个税扣缴义务人的主键id") + private Long taxAgentId; + +// 部门id") + private List departmentIds; + + // 分部id + private List subCompanyIds; + +// 岗位id") + private List positionIds; + +// 状态") + private String userstatus; + +// 入职日期") + private List hiredate; + +// 合并计税") + private Boolean mergeCountTax; + + /** + * 发送状态 + */ +// @JsonIgnore + private List sendStatuss; + + + // 导出时显示列定制信息 + List columns; + + public static String checkParam(SalarySendDetailQueryParam saveParam) { + if (saveParam.getSalarySendId() == null) { + throw new SalaryRunTimeException("工资单发放Id必传"); + } + return ""; + } +} diff --git a/src/com/engine/salary/entity/salaryBill/param/SalarySendGrantParam.java b/src/com/engine/salary/entity/salaryBill/param/SalarySendGrantParam.java new file mode 100644 index 000000000..dfabe74d5 --- /dev/null +++ b/src/com/engine/salary/entity/salaryBill/param/SalarySendGrantParam.java @@ -0,0 +1,45 @@ +package com.engine.salary.entity.salaryBill.param; + +import com.engine.salary.entity.salaryBill.po.SalaryTemplatePO; +import com.engine.salary.exception.SalaryRunTimeException; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * @Description: 工资单发放参数 + * @Author: wangxiangzhong + * @Date: 2021/12/13 16:18 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +////"工资单发放参数") +public class SalarySendGrantParam { + +// 主键id + private List ids; + +// 工资单发放Id + private Long salarySendId; + + /** + * 工资单发放范围id + */ + private List salarySendRangeIds; + + //模板,发消息用 + private SalaryTemplatePO template; + + public static String checkParam(SalarySendGrantParam param, Long employeeId, String tenantKey) { + if (param.getSalarySendId() == null) { + throw new SalaryRunTimeException("工资单发放Id必传"); + } + + return ""; + } +} diff --git a/src/com/engine/salary/entity/salaryBill/param/SalarySendInfoQueryParam.java b/src/com/engine/salary/entity/salaryBill/param/SalarySendInfoQueryParam.java new file mode 100644 index 000000000..981524986 --- /dev/null +++ b/src/com/engine/salary/entity/salaryBill/param/SalarySendInfoQueryParam.java @@ -0,0 +1,94 @@ +package com.engine.salary.entity.salaryBill.param; + +import com.engine.salary.common.BaseQueryParam; +import com.engine.salary.enums.salarybill.SalarySendStatusEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.time.LocalDate; +import java.util.Collection; +import java.util.List; + +/** + * @Description: 工资单发放信息 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +////"工资单发放信息查询参数") +public class SalarySendInfoQueryParam extends BaseQueryParam { + +// 主键id") + private Collection ids; + +// 工资单发放Id") + private Long salarySendId; + + /** + * 工资核算id + */ +// @JsonIgnore + private Long salaryAccountingId; + +// 关键字(姓名)") + private String keyword; + +// 姓名") + private String username; + private Long userId; + +// 个税扣缴义务人的主键id") + private Long taxAgentId; + +// 部门id") + private List departmentIds; + + // 分部id + private List subCompanyIds; + +// 岗位id") + private List positionIds; + +// 状态") + private String userstatus; + +// 入职日期") + private List hiredate; + +// 发送状态") + private SalarySendStatusEnum sendStatus; + + /** + * true= [已发送] + * false= [未发送,已撤回] + */ + private Boolean isGranted; + + /** + * 发送状态 + */ +// @JsonIgnore + private Integer sendStatusVal; + + /** + * 发送状态 + */ +// @JsonIgnore + private List sendStatuss; + + private String departmentIdStr; + + private String subCompanyIdStr; + + public static String checkParam(SalarySendInfoQueryParam saveParam) { + if (saveParam.getSalarySendId() == null) { + throw new SalaryRunTimeException("工资单发放Id必传"); + } + + return ""; + } +} diff --git a/src/com/engine/salary/entity/salaryBill/param/SalarySendQueryParam.java b/src/com/engine/salary/entity/salaryBill/param/SalarySendQueryParam.java new file mode 100644 index 000000000..ac127290a --- /dev/null +++ b/src/com/engine/salary/entity/salaryBill/param/SalarySendQueryParam.java @@ -0,0 +1,39 @@ +package com.engine.salary.entity.salaryBill.param; + +import com.engine.salary.common.BaseQueryParam; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.Date; +import java.util.List; + +/** + * 工资单发放 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalarySendQueryParam extends BaseQueryParam { + + private List salaryYearMonth; + + @JsonIgnore + private List salaryMonth; + + private List salaryMonthDate; + + private Collection salarySobIds; + + private Collection SalaryAccountingId; + +} diff --git a/src/com/engine/salary/entity/salaryBill/param/SalarySendRangeQueryParam.java b/src/com/engine/salary/entity/salaryBill/param/SalarySendRangeQueryParam.java new file mode 100644 index 000000000..15ae92097 --- /dev/null +++ b/src/com/engine/salary/entity/salaryBill/param/SalarySendRangeQueryParam.java @@ -0,0 +1,30 @@ +package com.engine.salary.entity.salaryBill.param; + +import com.engine.salary.common.BaseQueryParam; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +////"工资单发放范围查询参数") +public class SalarySendRangeQueryParam extends BaseQueryParam { + /** + * 发放类型 + * @see com.engine.salary.enums.salarysend.SalarySendGrantTypeEnum + */ + private String grantType; + + /** + * 发放单id + */ + private Long salarySendId; + + /** + * 对象名称关键字 + */ + private String targetName; +} diff --git a/src/com/engine/salary/entity/salaryBill/param/SalarySendRangeSaveParam.java b/src/com/engine/salary/entity/salaryBill/param/SalarySendRangeSaveParam.java new file mode 100644 index 000000000..7b4edd800 --- /dev/null +++ b/src/com/engine/salary/entity/salaryBill/param/SalarySendRangeSaveParam.java @@ -0,0 +1,122 @@ +package com.engine.salary.entity.salaryBill.param; + +import com.alibaba.nacos.client.naming.utils.CollectionUtils; +import com.engine.salary.entity.salaryBill.po.SalarySendRangeObj; +import com.engine.salary.entity.salaryBill.po.SalarySendRangePO; +import com.engine.salary.enums.salarysend.SalarySendGrantTypeEnum; +import com.engine.salary.enums.salarysend.SalarySendRangeTypeEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import weaver.hrm.User; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.stream.Collectors; + +import static com.engine.salary.constant.SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class SalarySendRangeSaveParam { + /** + * 发放id + */ + private Long salarySendId; + + + /** + * 发放范围id + */ + private Long salarySendRangeId; + + + /** + * 发放/撤回 + * + * @see SalarySendGrantTypeEnum + */ + private String grantType; + + + private List includeObjParams; + + + private List excludeObjParams; + + public static void checkParam(SalarySendRangeSaveParam saveParam, Long employeeId, String tenantKey) { + if (saveParam.getSalarySendId() == null) { + throw new SalaryRunTimeException("工资单发放id不能为空"); + } + + if (saveParam.getGrantType() == null) { + throw new SalaryRunTimeException("操作类型不能为空"); + } + + if (CollectionUtils.isEmpty(saveParam.getIncludeObjParams())) { + throw new SalaryRunTimeException("对象不能为空"); + } + } + + @Data + @AllArgsConstructor + @NoArgsConstructor + public static class SalarySendRangeTargetParam { + + /** + * 对象不能为空 + */ + private Long targetId; + + /** + * 对象类型不能为空 + * @see com.engine.salary.enums.salarysend.SalarySendRangeTargetTypeEnum + */ + private Integer targetType; + } + + public SalarySendRangePO toSalarySendRangePO(User user) { + return SalarySendRangePO.builder() + .id(salarySendRangeId) + .grantType(grantType) + .salarySendId(salarySendId) + .updateTime(new Date()) + .creator((long) user.getUID()) + .deleteType(0) + .tenantKey(DEFAULT_TENANT_KEY) + .createTime(salarySendId == null ? new Date() : null) + .build(); + } + + public List toSalarySendRangeObj(User user) { + List includeObjs = includeObjParams.stream() + .map(obj -> mapObj(user, obj)) + .map(obj->obj.setRangeType(SalarySendRangeTypeEnum.INCLUDE_OBJ.getValue())) + .collect(Collectors.toList()); + List excludeObjs = excludeObjParams.stream() + .map(obj -> mapObj(user, obj)) + .map(obj -> obj.setRangeType(SalarySendRangeTypeEnum.EXCLUDE_OBJ.getValue())) + .collect(Collectors.toList()); + List rangeObjs = new ArrayList<>(); + rangeObjs.addAll(includeObjs); + rangeObjs.addAll(excludeObjs); + return rangeObjs; + } + + private SalarySendRangeObj mapObj(User user, SalarySendRangeTargetParam obj) { + return SalarySendRangeObj.builder() + .salarySendRangeId(salarySendRangeId) + .salarySendId(salarySendId) + .targetId(obj.getTargetId()) + .targetType(obj.getTargetType()) + .deleteType(0) + .tenantKey(DEFAULT_TENANT_KEY) + .updateTime(new Date()) + .createTime(new Date()) + .creator((long) user.getUID()) + .build(); + } +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/salaryBill/param/SalarySendWithdrawParam.java b/src/com/engine/salary/entity/salaryBill/param/SalarySendWithdrawParam.java new file mode 100644 index 000000000..e9b4caabd --- /dev/null +++ b/src/com/engine/salary/entity/salaryBill/param/SalarySendWithdrawParam.java @@ -0,0 +1,33 @@ +package com.engine.salary.entity.salaryBill.param; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * 工资单发送参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalarySendWithdrawParam { + + // 主键id") + private List ids; + + // 工资单发放Id") + private Long salarySendId; + + //发送范围 + private List salarySendRangeIds; + +} diff --git a/src/com/engine/salary/entity/salaryBill/param/SalaryTemplateCopyParam.java b/src/com/engine/salary/entity/salaryBill/param/SalaryTemplateCopyParam.java new file mode 100644 index 000000000..53fb50eaf --- /dev/null +++ b/src/com/engine/salary/entity/salaryBill/param/SalaryTemplateCopyParam.java @@ -0,0 +1,36 @@ +package com.engine.salary.entity.salaryBill.param; + +import com.engine.salary.exception.SalaryRunTimeException; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.apache.commons.lang3.StringUtils; + +/** + * @Description: 工资单模板 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +////"工资单复制参数") +public class SalaryTemplateCopyParam { + +// 主键") + private Long id; + +// 模板名称") + private String name; + + private Long salarySobId; + + public static void checkParam(SalaryTemplateCopyParam copyParam) { + if (copyParam.getId() == null) { + throw new SalaryRunTimeException("id必选"); + } + if (StringUtils.isEmpty(copyParam.getName())) { + throw new SalaryRunTimeException("模板名称必填"); + } + } +} diff --git a/src/com/engine/salary/entity/salaryBill/param/SalaryTemplateDefaultUseParam.java b/src/com/engine/salary/entity/salaryBill/param/SalaryTemplateDefaultUseParam.java new file mode 100644 index 000000000..187e9eb5f --- /dev/null +++ b/src/com/engine/salary/entity/salaryBill/param/SalaryTemplateDefaultUseParam.java @@ -0,0 +1,27 @@ +package com.engine.salary.entity.salaryBill.param; + +import com.engine.salary.exception.SalaryRunTimeException; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Description: 工资单模板默认使用参数 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +////"工资单模板默认使用参数") +public class SalaryTemplateDefaultUseParam { + +// 主键") + private Long id; + + public static void checkParam(SalaryTemplateDefaultUseParam copyParam) { + if (copyParam.getId() == null) { + throw new SalaryRunTimeException("id必传"); + } + } +} diff --git a/src/com/engine/salary/entity/salaryBill/param/SalaryTemplateQueryParam.java b/src/com/engine/salary/entity/salaryBill/param/SalaryTemplateQueryParam.java new file mode 100644 index 000000000..662ffd2da --- /dev/null +++ b/src/com/engine/salary/entity/salaryBill/param/SalaryTemplateQueryParam.java @@ -0,0 +1,28 @@ +package com.engine.salary.entity.salaryBill.param; + +import com.engine.salary.common.BaseQueryParam; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; + +/** + * @Description: 工资单模板 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalaryTemplateQueryParam extends BaseQueryParam { + + // 主键id + private Collection ids; + + //薪资账套的主键id + private Long salarySobId; + + //工资单模板名称 + private String name; +} diff --git a/src/com/engine/salary/entity/salaryBill/param/SalaryTemplateSaveParam.java b/src/com/engine/salary/entity/salaryBill/param/SalaryTemplateSaveParam.java new file mode 100644 index 000000000..2f5bbb11a --- /dev/null +++ b/src/com/engine/salary/entity/salaryBill/param/SalaryTemplateSaveParam.java @@ -0,0 +1,180 @@ +package com.engine.salary.entity.salaryBill.param; + +import com.engine.salary.entity.salaryBill.dto.SalaryTemplateSMSSetDTO; +import com.engine.salary.entity.salaryBill.dto.SalaryTemplateSalaryItemSetListDTO; +import com.engine.salary.enums.salarybill.SalaryTemplateTextContentPositionEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.util.SalaryI18nUtil; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; + +import java.util.List; +import java.util.Objects; + +/** + * @Description: 工资单模板 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//"工资单模板保存参数 +public class SalaryTemplateSaveParam { + + // 主键 + private Long id; + + // 模板名称 + private String name; + + // 薪资账套表的主键id + private Long salarySobId; + + // 备注 + private String description; + + // 邮箱开启状态。false:关、true:开 + private Boolean emailStatus; + + // 发送地址 + private Long sendEmail; + + // 消息中心开启状态。false:关、true:开 + private Boolean msgStatus; + + // 短信开关 false:关、true:开 + private Boolean smsStatus; + + // 主题 + private String theme; + + // 背景图 + private String background; + + // 文本内容 + private String textContent; + + // 文本内容位置。1:薪资项目前、2:薪资项目后 + private Integer textContentPosition; + + // 薪资项为空时不显示开启状态。false:关、true:开 + private Boolean salaryItemNullStatus; + + // 薪资项为0时不显示开启状态。false:关、true:开 + private Boolean salaryItemZeroStatus; + + // 是否启用工资单定时发送。0:未启用、1:已启用 + private Boolean autoSendStatus; + + // 自动发送工资单周期1:本月、2:上月 + private Integer autoSendCycleType; + + // 每月几号自动发送工资单 + private String autoSendDayOfMonth; + + // 自动发放时间 + private String autoSendTimeOfDay; + + // 薪资项目设置 + private List salaryItemSetting; + + //短信模板 + private SalaryTemplateSMSSetDTO smsSetting; + + + // 补发工资单模板名称 + private String replenishName; + + // 补发工资单名单生成规则 + private String replenishRule; + + // 补发薪资项目设置 + private List replenishSalaryItemSetting; + + /** + * 工资单确认状态 + */ + private Boolean ackFeedbackStatus; + + /** + * 工资单反馈状态 + */ + private Boolean feedbackStatus; + + /** + * 自动确认超时天数 + */ + private Integer autoAckDays; + + /** + * 反馈流程地址 + */ + private String feedbackUrl; + + /** + * 移动端反馈流程地址 + */ + private String mobileFeedbackUrl; + + List salaryBillItemNameSetting; + + public static void checkParam(SalaryTemplateSaveParam saveParam) { + if (saveParam.getSalarySobId() == null) { + throw new SalaryRunTimeException("薪资账套表的主键id必传;"); + } + + if (StringUtils.isEmpty(saveParam.getName())) { + throw new SalaryRunTimeException("工资单模板名称必填;"); + } + + if (StringUtils.isEmpty(saveParam.getTheme())) { + throw new SalaryRunTimeException("工资单主题必填;"); + } + + if (StringUtils.isEmpty(saveParam.getReplenishName())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(139737, "补发工资单模板名称必填")); + } + + if (saveParam.getName().equals(saveParam.getReplenishName())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(140557, "工资单模板名称和补发工资单模板名称不可相同")); + } + + if (StringUtils.isEmpty(saveParam.getReplenishRule())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(139738, "补发工资单名单生成规则必填")); + } + + +// if (saveParam.getEmailStatus() && saveParam.getSendEmail() == null) { +// throw new SalaryRunTimeException("开启邮箱后,发送地址必选;"); +// } + + if (StringUtils.isNotEmpty(saveParam.getTextContent()) && saveParam.getTextContentPosition() == null) { + throw new SalaryRunTimeException("文本内容不为空时,文本内容位置必选;"); + } + + if (saveParam.getTextContentPosition() != null && saveParam.getTextContentPosition().equals(SalaryTemplateTextContentPositionEnum.BEFORE.getValue()) && saveParam.getTextContentPosition().equals(SalaryTemplateTextContentPositionEnum.AFTER.getValue())) { + throw new SalaryRunTimeException("文本内容位置参数不对;"); + } + + if (CollectionUtils.isEmpty(saveParam.getReplenishSalaryItemSetting())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(140509, "补发工资单模板的薪资项目设置不能为空")); + } + + if (Objects.isNull(saveParam.getAutoSendStatus())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(140509, "是否启用自动发放不能为空")); + } + + if (saveParam.getAutoSendStatus() == Boolean.TRUE) { + if (StringUtils.isBlank(saveParam.getAutoSendDayOfMonth())) + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(140509, "自动发放日期不能为空")); + if (Objects.isNull(saveParam.getAutoSendCycleType())) + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(140509, "自动发放周期不能为空")); + if (StringUtils.isBlank(saveParam.getAutoSendTimeOfDay())) + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(140509, "自动发放时间不能为空")); + } + } +} diff --git a/src/com/engine/salary/entity/salaryBill/po/SalaryBillItemNamePO.java b/src/com/engine/salary/entity/salaryBill/po/SalaryBillItemNamePO.java new file mode 100644 index 000000000..5dcf872d6 --- /dev/null +++ b/src/com/engine/salary/entity/salaryBill/po/SalaryBillItemNamePO.java @@ -0,0 +1,71 @@ +package com.engine.salary.entity.salaryBill.po; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.Date; + +/** + * @author Harryxzy + * @ClassName SalaryBillItemName + * @date 2023/07/18 15:55 + * @description 工资单薪资项目展示名称 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalaryBillItemNamePO { + private Long id; + + /** + * 薪资项目id + */ + private Long salaryItemId; + + /** + * 薪资项目展示名称 + */ + private String salaryItemShowName; + + /** + * 工资单模板id + */ + private Long salaryTemplateId; + + /** + * 工资单类型。0:正常工资单、1:补发工资单 + */ + private Integer salaryBillType; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 更新时间 + */ + private Date updateTime; + + /** + * 创建人 + */ + private Long creator; + + /** + * 是否已删除。0:未删除、1:已删除 + */ + private Integer deleteType; + + /** + * 租户ID + */ + private String tenantKey; + + //主键id集合 + private Collection ids; +} diff --git a/src/com/engine/salary/entity/salaryBill/po/SalaryBillWatermarkPO.java b/src/com/engine/salary/entity/salaryBill/po/SalaryBillWatermarkPO.java new file mode 100644 index 000000000..cccdd4867 --- /dev/null +++ b/src/com/engine/salary/entity/salaryBill/po/SalaryBillWatermarkPO.java @@ -0,0 +1,69 @@ +package com.engine.salary.entity.salaryBill.po; + +import com.engine.salary.enums.salarybill.SalaryTemplateWatermarkTypeEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; + +/** + * @author Harryxzy + * @ClassName SalaryBillWatermarkPO + * @date 2023/06/09 10:47 + * @description 工资单水印表 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalaryBillWatermarkPO { + + /** + * 主键id + */ + private Long id; + + /** + * 水印是否开启。0:否,1:是 + */ + private Integer watermarkStatus; + + /** + * 水印类型 + * @see SalaryTemplateWatermarkTypeEnum + */ + private String watermarkType; + + /** + * 自定义水印设置内容 + */ + private String watermarkSetting; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 更新时间 + */ + private Date updateTime; + + /** + * 创建人 + */ + private Long creator; + + /** + * 是否已删除。0:未删除、1:已删除 + */ + private Integer deleteType; + + /** + * 租户ID + */ + private String tenantKey; + +} diff --git a/src/com/engine/salary/entity/salaryBill/po/SalarySendInfoPO.java b/src/com/engine/salary/entity/salaryBill/po/SalarySendInfoPO.java new file mode 100644 index 000000000..8dea3fc47 --- /dev/null +++ b/src/com/engine/salary/entity/salaryBill/po/SalarySendInfoPO.java @@ -0,0 +1,124 @@ +package com.engine.salary.entity.salaryBill.po; + +import com.engine.salary.enums.datacollection.DataCollectionEmployeeTypeEnum; +import com.engine.salary.enums.salarybill.BillConfimStatusEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; + +/** + * 工资单发放信息 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//hrsa_salary_send_info +public class SalarySendInfoPO { + + /** + * 主键id + */ + private Long id; + + /** + * 工资单发放id + */ + private Long salarySendId; + + /** + * 薪资所属月 + */ + private Date salaryMonth; + + /** + * 薪资核算表的主键id + */ + private Long salaryAcctRecordId; + + /** + * 人员信息表的主键id + */ + private Long employeeId; + + /** + * 人员类型,0或null组织架构,1非系统人员 + * + * @see DataCollectionEmployeeTypeEnum + */ + private Integer employeeType; + + /** + * 人员信息表的主键id + */ + private Long taxAgentId; + + /** + * 发送状态。0:未发送、1:已发送、2:已撤回 + */ + private Integer sendStatus; + + /** + * 查看状态。0:未查看、1:已查看 + */ + private Integer billReadStatus; + + /** + * 确认状态 0:未确认、1:已确认、2:已反馈 + * @see BillConfimStatusEnum + */ + private Integer billConfirmStatus; + + /** + * 操作发送工资单人员id + */ + private Long sendEmployeeId; + + /** + * 发送时间 + */ + private Date sendTime; + + /** + * 核算类型。0:正常,1:补发 + */ + private Integer salaryAcctType; + + /** + * 工资单模板设置内容 + */ + private String salaryTemplate; + + /** + * 创建人 + */ + private Long creator; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 更新时间 + */ + private Date updateTime; + + /** + * 是否已删除。0:未删除、1:已删除 + */ + private Integer deleteType; + + /** + * 租户ID + */ + private String tenantKey; + + /** + * 首次查看时间 + */ + private Date firstReadingTime; +} diff --git a/src/com/engine/salary/entity/salaryBill/po/SalarySendPO.java b/src/com/engine/salary/entity/salaryBill/po/SalarySendPO.java new file mode 100644 index 000000000..7249346b6 --- /dev/null +++ b/src/com/engine/salary/entity/salaryBill/po/SalarySendPO.java @@ -0,0 +1,107 @@ +package com.engine.salary.entity.salaryBill.po; + +import com.engine.hrmelog.annotation.ElogTransform; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; + +/** + * @Description: 工资单发放 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +////hrsa_salary_send") +////工资单发放表") +@ElogTransform(name = "工资单发放") +public class SalarySendPO { + + /** + * 主键id + */ + @ElogTransform(name = "id") + private Long id; + + /** + * 薪资所属月 + */ + @ElogTransform(name = "薪资所属月") + private Date salaryMonth; + + /** + * 薪资核算id + */ + @ElogTransform(name = "薪资核算id") + private Long salaryAccountingId; + + /** + * 薪资账套id + */ + @ElogTransform(name = "薪资账套id") + private Long salarySobId; + + /** + * 已发送数量 + */ + @ElogTransform(name = "已发送数量") + private Integer sendNum; + + /** + * 发送总数 + */ + @ElogTransform(name = "发送总数") + private Integer sendTotal; + + /** + * 最后发送时间 + */ + @ElogTransform(name = "最后发送时间") + private Date lastSendTime; + + + /** + * 发放状态。0:未冻结、1:已冻结 + */ + @ElogTransform(name = "发放状态") + private Integer sendStatus; + + /** + * 核算类型。0:正常,1:补发 + */ + @ElogTransform(name = "核算类型") + private Integer salaryAcctType; + + + /** + * 创建人 + */ + @ElogTransform(name = "创建人") + private Long creator; + + /** + * 创建时间 + */ + @ElogTransform(name = "创建时间") + private Date createTime; + + /** + * 更新时间 + */ + @ElogTransform(name = "更新时间") + private Date updateTime; + + /** + * 是否已删除。0:未删除、1:已删除 + */ + @ElogTransform(name = "是否已删除") + private Integer deleteType; + + /** + * 租户ID + */ + private String tenantKey; +} diff --git a/src/com/engine/salary/entity/salaryBill/po/SalarySendRangeObj.java b/src/com/engine/salary/entity/salaryBill/po/SalarySendRangeObj.java new file mode 100644 index 000000000..f3f682063 --- /dev/null +++ b/src/com/engine/salary/entity/salaryBill/po/SalarySendRangeObj.java @@ -0,0 +1,71 @@ +package com.engine.salary.entity.salaryBill.po; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.util.Date; + +/** + * 工资单发放范围项目表 + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@Accessors(chain = true) +public class SalarySendRangeObj { + /** + * 主键id + */ + private Long id; + + /** + * 发放id + */ + private Long salarySendId; + + private Long salarySendRangeId; + + /** + * 范围类型;对象=1;对象中排除=2 + */ + private Integer rangeType; + + /** + * 目标类型,人员=1,部门=2,分部=3,岗位=4,个税扣缴义务人=5,所有人=0 + */ + private Integer targetType; + + /** + * 目标id + */ + private Long targetId; + + /** + * 创建人 + */ + private Long creator; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 更新时间 + */ + private Date updateTime; + + /** + * 是否已删除。0:未删除、1:已删除 + */ + private Integer deleteType; + + /** + * 租户ID + */ + private String tenantKey; +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/salaryBill/po/SalarySendRangePO.java b/src/com/engine/salary/entity/salaryBill/po/SalarySendRangePO.java new file mode 100644 index 000000000..0831b153b --- /dev/null +++ b/src/com/engine/salary/entity/salaryBill/po/SalarySendRangePO.java @@ -0,0 +1,57 @@ +package com.engine.salary.entity.salaryBill.po; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; + +/** + * 工资单发放范围表 + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class SalarySendRangePO { + /** + * 主键id + */ + private Long id; + + /** + * 发放id + */ + private Long salarySendId; + + /** + * 发放=grant;撤回=withdraw + */ + private String grantType; + + /** + * 创建人 + */ + private Long creator; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 更新时间 + */ + private Date updateTime; + + /** + * 是否已删除。0:未删除、1:已删除 + */ + private Integer deleteType; + + /** + * 租户ID + */ + private String tenantKey; +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/salaryBill/po/SalaryTemplatePO.java b/src/com/engine/salary/entity/salaryBill/po/SalaryTemplatePO.java new file mode 100644 index 000000000..825f82759 --- /dev/null +++ b/src/com/engine/salary/entity/salaryBill/po/SalaryTemplatePO.java @@ -0,0 +1,244 @@ +package com.engine.salary.entity.salaryBill.po; + +import com.engine.hrmelog.annotation.ElogTransform; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.Date; + +/** + * @Description: 工资单模板 + * @Author: wangxiangzhong + * @Date: 2021-12-08 14:44 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +////hrsa_salary_template") +////工资单模板表") +@ElogTransform(name = "工资单模板") +public class SalaryTemplatePO { + + /** + * 主键 + */ + @ElogTransform(name = "id") + private Long id; + + /** + * 名称 + */ + @ElogTransform(name = "名称") + private String name; + + /** + * 薪资账套表的主键id + */ + @ElogTransform(name = "薪资账套id") + private Long salarySobId; + + /** + * 使用类型。0:普通、1:默认 + */ + @ElogTransform(name = "使用类型") + private Integer useType; + + /** + * 备注 + */ + @ElogTransform(name = "备注") + private String description; + + /** + * 消息中心开启状态。0:关、1:开 ,默认开启 + */ + @ElogTransform(name = "消息中心开启状态") + private Integer msgStatus; + + /** + * 邮箱开启状态。0:关、1:开,默认关闭 + */ + @ElogTransform(name = "邮箱开启状态") + private Integer emailStatus; + + + /** + * 发送地址:公共邮箱账号id + */ + @ElogTransform(name = "邮箱发送地址") + private Long sendEmailId; + + + /** + * 短信开启状态。0:关、1:开,默认关闭 + */ + @ElogTransform(name = "短信开启状态") + private Integer smsStatus; + + /** + * 短信模板设置 + */ + @ElogTransform(name = "短信模板设置") + private String smsSetting; + + /** + * 薪酬水印 + */ + @ElogTransform(name = "薪酬水印") + private String salaryWatermark; + + /** + * 主题 + */ + @ElogTransform(name = "主题") + private String theme; + + /** + * 背景图 + */ + @ElogTransform(name = "背景图") + private String background; + + /** + * 文本内容 + */ + @ElogTransform(name = "文本内容") + private String textContent; + + /** + * 文本内容显示位置。1:薪资项目前、2:薪资项目后 + */ + @ElogTransform(name = "文本内容显示位置") + private Integer textContentPosition; + + /** + * 薪资项为空时不显示开启状态。0:关、1:开 + */ + @ElogTransform(name = "薪资项为空时不显示开启状态") + private Integer salaryItemNullStatus; + + /** + * 薪资项为0时不显示开启状态。0:关、1:开 + */ + @ElogTransform(name = "薪资项为0时不显示开启状态") + private Integer salaryItemZeroStatus; + + /** + * 薪资项目设置 + */ + @ElogTransform(name = "薪资项目设置") + private String salaryItemSetting; + + //=====================补发=================== + /** + * 补发工资单模板名称 + */ + @ElogTransform(name = "补发工资单模板名称") + private String replenishName; + + /** + * 补发工资单名单生成规则 + */ + @ElogTransform(name = "补发工资单名单生成规则") + private String replenishRule; + + /** + * 补发薪资项目设置 + */ + @ElogTransform(name = "补发薪资项目设置") + private String replenishSalaryItemSetting; + + + /** + * 是否启用工资单定时发送。0:未启用、1:已启用 + */ + @ElogTransform(name = "是否启用工资单定时发送") + private Integer autoSendStatus; + + /** + * 自动发送工资单周期1:本月、2:上月 + */ + @ElogTransform(name = "自动发送工资单周期1") + private Integer autoSendCycleType; + + /** + * 每月几号自动发送工资单 + */ + @ElogTransform(name = "每月几号自动发送工资单") + private String autoSendDayOfMonth; + + /** + * 自动发放时间 + */ + @ElogTransform(name = "自动发放时间") + private String autoSendTimeOfDay; + + /** + * 创建时间 + */ + @ElogTransform(name = "创建时间") + private Date createTime; + + /** + * 更新时间 + */ + @ElogTransform(name = "更新时间") + private Date updateTime; + + /** + * 创建人 + */ + @ElogTransform(name = "创建人") + private Long creator; + + /** + * 是否已删除。0:未删除、1:已删除 + */ + @ElogTransform(name = "是否已删除") + private Integer deleteType; + + /** + * 租户ID + */ + private String tenantKey; + + /** + * 工资单确认反馈状态 + */ + @ElogTransform(name = "工资单确认反馈状态") + private Integer ackFeedbackStatus; + + /** + * 工资单确认反馈状态 + */ + private Integer feedbackStatus; + + /** + * 自动确认超时天数 + */ + @ElogTransform(name = "自动确认超时天数") + private Integer autoAckDays; + + /** + * 反馈流程地址 + * + */ + @ElogTransform(name = "反馈流程地址") + private String feedbackUrl; + + + /** + * 移动端反馈流程地址 + * + */ + @ElogTransform(name = "移动端反馈流程地址") + private String mobileFeedbackUrl; + + + + private Collection salarySobIds; +} diff --git a/src/com/engine/salary/entity/salaryacct/bo/CalculateFormulaVarBO.java b/src/com/engine/salary/entity/salaryacct/bo/CalculateFormulaVarBO.java new file mode 100644 index 000000000..cd66dd76c --- /dev/null +++ b/src/com/engine/salary/entity/salaryacct/bo/CalculateFormulaVarBO.java @@ -0,0 +1,648 @@ +package com.engine.salary.entity.salaryacct.bo; + +import cn.hutool.core.util.NumberUtil; +import com.engine.salary.annotation.SalaryFormulaVar; +import com.engine.salary.common.LocalDateRange; +import com.engine.salary.constant.SalaryFormulaFieldConstant; +import com.engine.salary.constant.SalaryItemConstant; +import com.engine.salary.entity.datacollection.AddUpDeduction; +import com.engine.salary.entity.datacollection.AddUpSituation; +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.datacollection.dto.AttendQuoteDataDTO; +import com.engine.salary.entity.datacollection.dto.AttendQuoteDataValueDTO; +import com.engine.salary.entity.datacollection.dto.AttendQuoteFieldListDTO; +import com.engine.salary.entity.datacollection.po.OtherDeductionPO; +import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO; +import com.engine.salary.entity.salaryacct.po.SalaryAcctResultPO; +import com.engine.salary.entity.salaryarchive.dto.SalaryArchiveDataDTO; +import com.engine.salary.entity.salaryarchive.dto.SalaryArchiveItemDataDTO; +import com.engine.salary.entity.salaryarchive.dto.SalaryArchiveTaxAgentDataDTO; +import com.engine.salary.entity.salaryitem.po.SalaryItemPO; +import com.engine.salary.entity.salarysob.dto.SalarySobCycleDTO; +import com.engine.salary.entity.salarysob.po.SalarySobAdjustRulePO; +import com.engine.salary.enums.UserStatusEnum; +import com.engine.salary.enums.salaryformula.SalaryFormulaReferenceEnum; +import com.engine.salary.enums.salaryformula.SalarySQLReferenceEnum; +import com.engine.salary.enums.salarysob.SalarySobAdjustRuleTypeEnum; +import com.engine.salary.util.JsonUtil; +import com.engine.salary.util.SalaryDateUtil; +import com.engine.salary.util.SalaryEntityUtil; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import lombok.Data; +import lombok.experimental.Accessors; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.math.NumberUtils; +import weaver.general.Util; + +import java.lang.reflect.Field; +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.time.temporal.ChronoUnit; +import java.util.*; +import java.util.stream.Collectors; + +import static com.engine.salary.util.SalaryDateUtil.DATE_TIME_FORMATTER_PATTERN; + +/** + * 薪资核算-将数据转换成公式中的变量 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Accessors(chain = true) +public class CalculateFormulaVarBO { + + /** + * 员工信息 + */ + private List simpleEmployees; + + /** + * 薪资档案 + */ + private List salaryArchiveData; + + /** + * 累计情况 + */ + private List addUpSituationPOS; + + /** + * 累计专项附加扣除 + */ + private List addUpDeductionPOS; + + /** + * 其他扣除 + */ + private List otherDeductionPOS; + + /** + * 社保福利 + */ + private List> welfareData; + + /** + * 考勤数据 + */ + private List attendQuoteDataDTOS; + + /** + * 薪资核算结果(输入/导入的值) + */ + private List salaryAcctResultPOS; + + /** + * 浮动薪资档案 + */ + private List> variableArchiveList; + + /** + * 上月核算结果 + */ + List lastMonthResultPOS; + + public CalculateFormulaVarBO(List simpleEmployees, + List salaryArchiveData, + List addUpSituationPOS, + List addUpDeductionPOS, + List otherDeductionPOS, + List> welfareData, + List attendQuoteDataDTOS, + List salaryAcctResultPOS, + List> variableArchiveList, + List lastMonthResultPOS) { + this.simpleEmployees = simpleEmployees; + this.salaryArchiveData = salaryArchiveData; + this.addUpSituationPOS = addUpSituationPOS; + this.addUpDeductionPOS = addUpDeductionPOS; + this.otherDeductionPOS = otherDeductionPOS; + this.welfareData = welfareData; + this.attendQuoteDataDTOS = attendQuoteDataDTOS; + this.salaryAcctResultPOS = salaryAcctResultPOS; + this.variableArchiveList = variableArchiveList; + this.lastMonthResultPOS = lastMonthResultPOS; + } + + /** + * 将查询到的数据转换成公式变量 + * + * @param salaryAcctCalculateBO 核算参数 + * @return + */ + public Map> convert2FormulaVar(SalaryAcctCalculateBO salaryAcctCalculateBO) { + Map> resultMap = Maps.newHashMapWithExpectedSize(salaryAcctCalculateBO.getSalaryAcctEmployeePOS().size()); + // 处理薪资核算结果 + handleSalaryAcctResult(salaryAcctCalculateBO, resultMap); + // 处理薪资档案 + handleSalaryArchiveData(salaryAcctCalculateBO, resultMap); + // 处理浮动薪资档案 + handleVariableArchiveData(salaryAcctCalculateBO, resultMap); + // 处理往期累计情况 + handleAddUpSituation(resultMap); + // 处理累计专项附加扣除 + handleAddUpDeduction(resultMap); + // 处理其他扣除 + handleOtherDeduction(resultMap); + // 处理社保福利 + handleWelfareData(salaryAcctCalculateBO, resultMap); + // 处理考勤数据 + handleAttendQuoteData(salaryAcctCalculateBO, resultMap); + //处理核算人员信息 + handleSalaryAcctEmployee(salaryAcctCalculateBO, resultMap); + //处理人员信息 + handleSimpleEmployees(resultMap); + //处理上月薪资核算结果 + handleLastMonthResult(salaryAcctCalculateBO, resultMap); + return resultMap; + } + + /** + * 处理核算日期相关信息 + */ + private List handleSalarySobCycleDTO(SalaryAcctCalculateBO salaryAcctCalculateBO) { + + SalarySobCycleDTO salarySobCycleDTO = salaryAcctCalculateBO.getSalarySobCycleDTO(); + + salarySobCycleDTO.setSalaryDate(SalaryDateUtil.toDate(salarySobCycleDTO.getSalaryMonth(), 1)); + salarySobCycleDTO.setTaxDate(SalaryDateUtil.toDate(salarySobCycleDTO.getTaxCycle(), 1)); + salarySobCycleDTO.setSocialSecurityDate(SalaryDateUtil.toDate(salarySobCycleDTO.getSocialSecurityCycle(), 1)); + LocalDateRange salaryCycle = salarySobCycleDTO.getSalaryCycle(); + salarySobCycleDTO.setSalaryCycleFromDate(salaryCycle.getFromDate()); + salarySobCycleDTO.setSalaryCycleEndDate(salaryCycle.getEndDate()); + LocalDateRange attendCycle = salarySobCycleDTO.getAttendCycle(); + salarySobCycleDTO.setAttendCycleFromDate(attendCycle.getFromDate()); + salarySobCycleDTO.setAttendCycleEndDate(attendCycle.getEndDate()); + + Map map = JsonUtil.parseMap(salarySobCycleDTO, String.class); + + List formulaVarValues = Lists.newArrayList(); + Field[] declaredFields = SalarySobCycleDTO.class.getDeclaredFields(); + for (Field declaredField : declaredFields) { + if (declaredField.isAnnotationPresent(SalaryFormulaVar.class)) { + String fieldName = declaredField.getName(); + String fieldId = SalarySQLReferenceEnum.SALARY_CYCLE.getValue() + + SalaryFormulaFieldConstant.FIELD_ID_SEPARATOR + + fieldName; + String fieldValue = map.getOrDefault(fieldName, StringUtils.EMPTY); + //日期值取yyyy-MM-dd + if (StringUtils.isNotBlank(fieldValue) && fieldValue.length() > 10 && SalaryDateUtil.parse(fieldValue, DATE_TIME_FORMATTER_PATTERN) != null) { + fieldValue = fieldValue.substring(0, 10); + } + formulaVarValues.add(new FormulaVarValue().setFieldId(fieldId).setFieldValue(fieldValue)); + } + } + return formulaVarValues; + } + + + /** + * 处理薪资核算结果 + * + * @param salaryAcctCalculateBO 薪资核算参数 + * @param resultMap 返回结果集 + */ + private void handleSalaryAcctResult(SalaryAcctCalculateBO salaryAcctCalculateBO, Map> resultMap) { + // key:薪资项目的id、value:薪资项目的code + Map salaryItemCodeMap = SalaryEntityUtil.convert2Map(salaryAcctCalculateBO.getSalaryItemPOS(), SalaryItemPO::getId, SalaryItemPO::getCode); + // key:薪资项目的code、value:薪资项目的id + Map salaryCodeItemMap = SalaryEntityUtil.convert2Map(salaryAcctCalculateBO.getSalaryItemPOS(), SalaryItemPO::getCode, SalaryItemPO::getId); + // key:employeeId_taxAgentId、value:薪资核算结果集合 + Map> salaryAcctResultMap = SalaryEntityUtil.group2Map(salaryAcctResultPOS, + salaryAcctResultPO -> salaryAcctResultPO.getEmployeeId() + "_" + salaryAcctResultPO.getTaxAgentId()); + // +// List expressFormulas = salaryAcctCalculateBO.getExpressFormulas(); + // 填充到返回结果集中 + salaryAcctResultMap.forEach((key, salaryAcctResultPOS) -> { + List formulaVarValues = resultMap.computeIfAbsent(key, k -> Lists.newArrayList()); + formulaVarValues.addAll(salaryAcctResultPOS.stream() + .map(salaryAcctResultPO -> { + String fieldId = SalaryFormulaReferenceEnum.SALARY_ITEM.getValue() + + SalaryFormulaFieldConstant.FIELD_ID_SEPARATOR + + salaryItemCodeMap.getOrDefault(salaryAcctResultPO.getSalaryItemId(), StringUtils.EMPTY); + return new FormulaVarValue().setFieldId(fieldId).setFieldValue(salaryAcctResultPO.getResultValue()); + }) + .collect(Collectors.toList())); + Map salaryAcctResultPOMap = SalaryEntityUtil.convert2Map(salaryAcctResultPOS, SalaryAcctResultPO::getSalaryItemId); + formulaVarValues.addAll(salaryAcctCalculateBO.getIssuedFieldIds().stream() + .map(fieldId -> { + String originResultValue = salaryAcctResultPOMap.getOrDefault( + salaryCodeItemMap.get(fieldId), SalaryAcctResultPO.builder().originResultValue("").build()) + .getOriginResultValue(); + String fieldId2 = SalaryFormulaReferenceEnum.ISSUED.getValue() + + SalaryFormulaFieldConstant.FIELD_ID_SEPARATOR + + fieldId; + return new FormulaVarValue().setFieldId(fieldId2).setFieldValue(originResultValue); + }).collect(Collectors.toList())); + }); + } + + private void handleLastMonthResult(SalaryAcctCalculateBO salaryAcctCalculateBO, Map> resultMap) { + // key:薪资项目的id、value:薪资项目的code + Map salaryItemCodeMap = SalaryEntityUtil.convert2Map(salaryAcctCalculateBO.getSalaryItemPOS(), SalaryItemPO::getId, SalaryItemPO::getCode); + // key:employeeId_taxAgentId、value:薪资核算结果集合 + Map> salaryAcctResultMap = SalaryEntityUtil.group2Map(lastMonthResultPOS, + salaryAcctResultPO -> salaryAcctResultPO.getEmployeeId() + "_" + salaryAcctResultPO.getTaxAgentId()); + // 填充到返回结果集中 + salaryAcctResultMap.forEach((key, salaryAcctResultPOS) -> { + List formulaVarValues = resultMap.computeIfAbsent(key, k -> Lists.newArrayList()); + formulaVarValues.addAll(salaryAcctResultPOS.stream() + .map(salaryAcctResultPO -> { + String fieldId = SalaryFormulaReferenceEnum.LAST_MONTH_CALC.getValue() + + SalaryFormulaFieldConstant.FIELD_ID_SEPARATOR + + salaryItemCodeMap.getOrDefault(salaryAcctResultPO.getSalaryItemId(), StringUtils.EMPTY); + return new FormulaVarValue().setFieldId(fieldId).setFieldValue(salaryAcctResultPO.getResultValue()); + }) + .collect(Collectors.toList())); + }); + } + + /** + * 处理薪资档案(会涉及调薪计薪规则)+处理核算日期 + * + * @param salaryAcctCalculateBO 薪资核算参数 + * @param resultMap 返回结果集 + */ + private void handleSalaryArchiveData(SalaryAcctCalculateBO salaryAcctCalculateBO, Map> resultMap) { + // 调薪计薪规则 + Map salarySobAdjustRulePOMap = SalaryEntityUtil.convert2Map(salaryAcctCalculateBO.getSalarySobAdjustRulePOS(), + SalarySobAdjustRulePO::getSalaryItemId); + for (SalaryArchiveDataDTO salaryArchiveDataDTO : salaryArchiveData) { + for (SalaryArchiveTaxAgentDataDTO salaryArchiveTaxAgentDataDTO : salaryArchiveDataDTO.getTaxAgents()) { + String key = salaryArchiveDataDTO.getEmployeeId() + "_" + salaryArchiveTaxAgentDataDTO.getTaxAgentId(); + List formulaVarValues = resultMap.computeIfAbsent(key, k -> Lists.newArrayList()); + // 将薪资档案的值转换成公式中的变量,填充到返回结果集中 + formulaVarValues.addAll(handleSalaryArchiveItemVal(salaryAcctCalculateBO, salaryArchiveTaxAgentDataDTO.getSalaryItemValues(), salarySobAdjustRulePOMap)); + } + } + } + + private void handleVariableArchiveData(SalaryAcctCalculateBO salaryAcctCalculateBO, Map> resultMap) { + Map> variableArchiveMap = SalaryEntityUtil.convert2Map(variableArchiveList, map -> map.getOrDefault("taxAgentIds", "").toString() + "-" + map.getOrDefault("employeeId", "").toString()); + // 填充到返回结果集中 + for (SalaryAcctEmployeePO salaryAcctEmployeePO : salaryAcctCalculateBO.getSalaryAcctEmployeePOS()) { + List formulaVarValues = resultMap.computeIfAbsent(salaryAcctEmployeePO.getEmployeeId() + "_" + salaryAcctEmployeePO.getTaxAgentId(), + k -> Lists.newArrayList()); + + String key = salaryAcctEmployeePO.getTaxAgentId().toString() + "-" + salaryAcctEmployeePO.getEmployeeId().toString(); + Map map = variableArchiveMap.getOrDefault(key, Collections.emptyMap()); + formulaVarValues.addAll(salaryAcctCalculateBO.getVariableItems().stream().map(field -> { + String fieldId = SalaryFormulaReferenceEnum.VARIABLE_ITEM.getValue() + + SalaryFormulaFieldConstant.FIELD_ID_SEPARATOR + + field.getCode(); + + String value = map.getOrDefault(field.getId() + SalaryItemConstant.VARIABLE_ITEM_DYNAMIC_SUFFIX, StringUtils.EMPTY) == null ? StringUtils.EMPTY + : map.getOrDefault(field.getId() + SalaryItemConstant.VARIABLE_ITEM_DYNAMIC_SUFFIX, StringUtils.EMPTY).toString(); + return new FormulaVarValue().setFieldId(fieldId).setFieldValue(value); + }).collect(Collectors.toList())); + } + } + + /** + * 根据调薪计薪规则处理薪资档案的调薪,转换成公式编辑器中的变量 + * + * @param salaryAcctCalculateBO + * @param salaryArchiveItemDataList + * @param salarySobAdjustRulePOMap + * @return + */ + private List handleSalaryArchiveItemVal(SalaryAcctCalculateBO salaryAcctCalculateBO, + List salaryArchiveItemDataList, + Map salarySobAdjustRulePOMap) { + // 薪资周期 + LocalDateRange salaryCycle = salaryAcctCalculateBO.getSalarySobCycleDTO().getSalaryCycle(); + // key:薪资项目的id、value:薪资项目的code + Map salaryItemCodeMap = SalaryEntityUtil.convert2Map(salaryAcctCalculateBO.getSalaryItemPOS(), SalaryItemPO::getId, SalaryItemPO::getCode); + // 将薪资档案的调薪记录按照薪资项目id聚合(同一个薪资项目可能存在多次调薪,按照生效日期对调薪记录排序) + Map> dataMap = salaryArchiveItemDataList.stream() + .collect(Collectors.groupingBy(SalaryArchiveItemDataDTO::getSalaryItemId, + Collectors.collectingAndThen(Collectors.toList(), salaryArchiveItemDataDTOS -> salaryArchiveItemDataDTOS.stream() + .sorted(Comparator.comparing(salaryArchiveItemDataDTO -> salaryArchiveItemDataDTO.getEffectiveDateRange().getFromDate())) + .collect(Collectors.toList())))); + // 将薪资档案的值转换成公式编辑器中的变量 + List formulaVarValues = Lists.newArrayListWithExpectedSize(dataMap.size()); + for (Map.Entry> entry : dataMap.entrySet()) { + String value; + // 获取薪资项目的调薪规则 + SalarySobAdjustRulePO salaryAdjustmentRulePO = salarySobAdjustRulePOMap.get(entry.getKey()); + if (entry.getValue().size() > 2) { + // 如果薪资项目在薪资周期内经历了多次调薪,则默认分段计薪 + value = calculateBySalarySobAdjustRule(salaryCycle, SalarySobAdjustRuleTypeEnum.PARTITION, entry.getValue()); + } else if (salaryAdjustmentRulePO == null || entry.getValue().size() < 2) { + // 如果薪资项目没有设置调薪计薪规则,默认取薪资周期内薪资档案中最新的值 + // 如果薪资项目在薪资周期内没有调薪,默认取薪资周期内薪资档案中最新的值 + value = calculateBySalarySobAdjustRule(salaryCycle, SalarySobAdjustRuleTypeEnum.USE_AFTER_ADJUSTMENT, entry.getValue()); + } else { + // 如果薪资项目在薪资周期内只有一次调薪,则根据调薪计薪规则处理 + SalarySobAdjustRuleTypeEnum adjustRuleTypeEnum = salaryAdjustmentRulePO.getDayOfMonth() < SalaryDateUtil.dateToLocalDate(entry.getValue().get(0).getEffectiveDateRange().getEndDate()).getDayOfMonth() + ? SalarySobAdjustRuleTypeEnum.parseByValue(salaryAdjustmentRulePO.getAfterAdjustmentType()) + : SalarySobAdjustRuleTypeEnum.parseByValue(salaryAdjustmentRulePO.getBeforeAdjustmentType()); + // 根据调薪计薪规则处理薪资档案的调薪 + value = calculateBySalarySobAdjustRule(salaryCycle, adjustRuleTypeEnum, entry.getValue()); + } + String fieldId = SalaryFormulaReferenceEnum.SALARY_ARCHIVES.getValue() + + SalaryFormulaFieldConstant.FIELD_ID_SEPARATOR + + salaryItemCodeMap.getOrDefault(entry.getKey(), StringUtils.EMPTY); + formulaVarValues.add(new FormulaVarValue().setFieldId(fieldId).setFieldValue(value)); + } + return formulaVarValues; + } + + /** + * 根据调薪计薪规则计算调薪后的值 + * + * @param adjustRuleTypeEnum + * @param salaryArchiveItemDataDTOS + * @return + */ + private String calculateBySalarySobAdjustRule(LocalDateRange salaryCycle, + SalarySobAdjustRuleTypeEnum adjustRuleTypeEnum, + List salaryArchiveItemDataDTOS) { + if (Objects.isNull(adjustRuleTypeEnum)) { + return StringUtils.EMPTY; + } + String value; + switch (adjustRuleTypeEnum) { + case AVERAGE: + // 可能存在多次调薪 + // = (第一段的值+第二段的值+……)/n + value = String.valueOf(salaryArchiveItemDataDTOS.stream() + .mapToDouble(salaryArchiveItemDataDTO -> SalaryEntityUtil.empty2Zero(salaryArchiveItemDataDTO.getValue()).doubleValue()) + .average().orElse(NumberUtils.DOUBLE_ZERO)); + break; + case PARTITION: + // 可能存在多次调薪 + // = (第一段的值*第一段的自然日+第二段的值*第二段的自然日+……)/薪资所属月自然日 + BigDecimal valueSum = BigDecimal.ZERO; + for (int i = 0; i < salaryArchiveItemDataDTOS.size(); i++) { + SalaryArchiveItemDataDTO dataDTO = salaryArchiveItemDataDTOS.get(i); + BigDecimal dayDiff = new BigDecimal(SalaryDateUtil.dateToLocalDate(dataDTO.getEffectiveDateRange().getFromDate()).until(SalaryDateUtil.dateToLocalDate(dataDTO.getEffectiveDateRange().getEndDate()), ChronoUnit.DAYS)); + // 最后一段日期范围需要加一 + if (Objects.equals(i, salaryArchiveItemDataDTOS.size() - 1)) { + dayDiff = dayDiff.add(BigDecimal.ONE); + } + valueSum = valueSum.add(SalaryEntityUtil.empty2Zero(dataDTO.getValue()).multiply(dayDiff)); + } + value = valueSum.divide(new BigDecimal(SalaryDateUtil.dateToLocalDate(salaryCycle.getFromDate()).until(SalaryDateUtil.dateToLocalDate(salaryCycle.getEndDate()), ChronoUnit.DAYS)).add(BigDecimal.ONE), 2, RoundingMode.HALF_UP).toPlainString(); + break; + case USE_BEFORE_ADJUSTMENT: + // = 调薪前工资 + value = salaryArchiveItemDataDTOS.get(0).getValue(); + break; + case USE_AFTER_ADJUSTMENT: + // = 调薪后工资 + value = salaryArchiveItemDataDTOS.get(salaryArchiveItemDataDTOS.size() - 1).getValue(); + break; + default: + value = "0"; + break; + } + return value; + } + + /** + * 处理累计情况(工资、薪金) + * + * @param resultMap 返回结果集 + */ + private void handleAddUpSituation(Map> resultMap) { + // key:employeeId_taxAgentId、value:累计情况(工资、薪金)的数据 + Map addUpSituationPOMap = SalaryEntityUtil.convert2Map(addUpSituationPOS, + addUpSituationPO -> addUpSituationPO.getEmployeeId() + "_" + addUpSituationPO.getTaxAgentId()); + // 累计情况(工资、薪金)可选字段 + List fieldNames = Lists.newArrayList(); + Field[] declaredFields = AddUpSituation.class.getDeclaredFields(); + for (Field declaredField : declaredFields) { + if (declaredField.isAnnotationPresent(SalaryFormulaVar.class)) { + fieldNames.add(declaredField.getName()); + } + } + // 填充到返回结果集中 + addUpSituationPOMap.forEach((key, addUpSituationPO) -> { + List formulaVarValues = resultMap.computeIfAbsent(key, k -> Lists.newArrayList()); + Map map = JsonUtil.parseMap(addUpSituationPO, String.class); + formulaVarValues.addAll(fieldNames.stream().map(fieldName -> { + String fieldId = SalaryFormulaReferenceEnum.ADD_UP_SITUATION.getValue() + + SalaryFormulaFieldConstant.FIELD_ID_SEPARATOR + + fieldName; + return new FormulaVarValue().setFieldId(fieldId).setFieldValue(map.getOrDefault(fieldName, StringUtils.EMPTY)); + }).collect(Collectors.toList())); + }); + } + + /** + * 处理累计专项附加扣除 + * + * @param resultMap 返回结果集 + */ + private void handleAddUpDeduction(Map> resultMap) { + // key:employeeId_taxAgentId、value:累计专项附加扣除的数据 + Map addUpDeductionPOMap = SalaryEntityUtil.convert2Map(addUpDeductionPOS, + addUpDeductionPO -> addUpDeductionPO.getEmployeeId() + "_" + addUpDeductionPO.getTaxAgentId()); + // 累计专项附加扣除可选字段 + List fieldNames = Lists.newArrayList(); + Field[] declaredFields = AddUpDeduction.class.getDeclaredFields(); + for (Field declaredField : declaredFields) { + if (declaredField.isAnnotationPresent(SalaryFormulaVar.class)) { + fieldNames.add(declaredField.getName()); + } + } + // 填充到返回结果集中 + addUpDeductionPOMap.forEach((key, addUpDeductionPO) -> { + List formulaVarValues = resultMap.computeIfAbsent(key, k -> Lists.newArrayList()); + Map map = JsonUtil.parseMap(addUpDeductionPO, String.class); + formulaVarValues.addAll(fieldNames.stream().map(fieldName -> { + String fieldId = SalaryFormulaReferenceEnum.ADD_UP_DEDUCTIONS.getValue() + + SalaryFormulaFieldConstant.FIELD_ID_SEPARATOR + + fieldName; + return new FormulaVarValue().setFieldId(fieldId).setFieldValue(map.getOrDefault(fieldName, StringUtils.EMPTY)); + }).collect(Collectors.toList())); + }); + } + + /** + * 处理其他扣除 + * + * @param resultMap 返回结果集 + */ + private void handleOtherDeduction(Map> resultMap) { + // key:employeeId_taxAgentId、value:累计专项附加扣除的数据 + Map otherDeductionPOMap = SalaryEntityUtil.convert2Map(otherDeductionPOS, + otherDeductionPO -> otherDeductionPO.getEmployeeId() + "_" + otherDeductionPO.getTaxAgentId()); + // 累计专项附加扣除可选字段 + List fieldNames = Lists.newArrayList(); + Field[] declaredFields = OtherDeductionPO.class.getDeclaredFields(); + for (Field declaredField : declaredFields) { + if (declaredField.isAnnotationPresent(SalaryFormulaVar.class)) { + fieldNames.add(declaredField.getName()); + } + } + // 填充到返回结果集中 + otherDeductionPOMap.forEach((key, otherDeductionPO) -> { + List formulaVarValues = resultMap.computeIfAbsent(key, k -> Lists.newArrayList()); + Map map = JsonUtil.parseMap(otherDeductionPO, String.class); + formulaVarValues.addAll(fieldNames.stream().map(fieldName -> { + String fieldId = SalaryFormulaReferenceEnum.OTHER_DEDUCTION.getValue() + + SalaryFormulaFieldConstant.FIELD_ID_SEPARATOR + + fieldName; + return new FormulaVarValue().setFieldId(fieldId).setFieldValue(map.getOrDefault(fieldName, StringUtils.EMPTY)); + }).collect(Collectors.toList())); + }); + } + + /** + * 处理社保福利数据 + * + * @param resultMap 返回结果集 + */ + private void handleWelfareData(SalaryAcctCalculateBO salaryAcctCalculateBO, Map> resultMap) { + // 社保福利可选字段 + List fieldNames = Lists.newArrayList(salaryAcctCalculateBO.getWelfareColumns().values()); + // 社保福利数据 + Map> tempMap = new HashMap<>(); + welfareData.forEach(map -> { + String key = map.getOrDefault("employeeId", StringUtils.EMPTY) + "_" + map.getOrDefault("taxAgentId", StringUtils.EMPTY); + List formulaVarValues = tempMap.computeIfAbsent(key, k -> Lists.newArrayList()); + formulaVarValues.addAll(fieldNames.stream().map(fieldName -> { + String fieldId = SalaryFormulaReferenceEnum.WELFARE.getValue() + + SalaryFormulaFieldConstant.FIELD_ID_SEPARATOR + + fieldName; + return new FormulaVarValue().setFieldId(fieldId).setFieldValue(String.valueOf(map.getOrDefault(fieldName, StringUtils.EMPTY))); + }).collect(Collectors.toList())); + }); + // 填充到返回结果集中 + for (SalaryAcctEmployeePO salaryAcctEmployeePO : salaryAcctCalculateBO.getSalaryAcctEmployeePOS()) { + List formulaVarValues = resultMap.computeIfAbsent(salaryAcctEmployeePO.getEmployeeId() + "_" + salaryAcctEmployeePO.getTaxAgentId(), + k -> Lists.newArrayList()); + formulaVarValues.addAll(tempMap.getOrDefault(salaryAcctEmployeePO.getEmployeeId() + "_" + salaryAcctEmployeePO.getTaxAgentId(), Collections.emptyList())); + } + } + + /** + * 处理考勤引用数据 + * + * @param salaryAcctCalculateBO + * @param resultMap + */ + private void handleAttendQuoteData(SalaryAcctCalculateBO salaryAcctCalculateBO, Map> resultMap) { + // 考勤引用可选字段 + Set fieldNames = SalaryEntityUtil.properties(salaryAcctCalculateBO.getAttendQuoteFieldListDTOS(), AttendQuoteFieldListDTO::getId); + // 考勤引用数据 + Map> tempMap = Maps.newHashMapWithExpectedSize(attendQuoteDataDTOS.size()); + attendQuoteDataDTOS.forEach(attendQuoteDataDTO -> { + Map attendQuoteDataValueMap = SalaryEntityUtil.convert2Map(attendQuoteDataDTO.getDataValues(), AttendQuoteDataValueDTO::getAttendQuoteFieldId, AttendQuoteDataValueDTO::getDataValue); + Long key = attendQuoteDataDTO.getEmployeeId(); + List formulaVarValues = tempMap.computeIfAbsent(key, k -> Lists.newArrayList()); + formulaVarValues.addAll(fieldNames.stream().map(fieldName -> { + String fieldId = SalaryFormulaReferenceEnum.ATTEND.getValue() + + SalaryFormulaFieldConstant.FIELD_ID_SEPARATOR + + fieldName; + return new FormulaVarValue().setFieldId(fieldId).setFieldValue(attendQuoteDataValueMap.getOrDefault(fieldName, StringUtils.EMPTY)); + }).collect(Collectors.toList())); + }); + // 填充到返回结果集中 + for (SalaryAcctEmployeePO salaryAcctEmployeePO : salaryAcctCalculateBO.getSalaryAcctEmployeePOS()) { + List formulaVarValues = resultMap.computeIfAbsent(salaryAcctEmployeePO.getEmployeeId() + "_" + salaryAcctEmployeePO.getTaxAgentId(), + k -> Lists.newArrayList()); + formulaVarValues.addAll(tempMap.getOrDefault(salaryAcctEmployeePO.getEmployeeId(), Collections.emptyList())); + } + } + + /** + * 处理核算人员信息 + * + * @param salaryAcctCalculateBO + * @param resultMap + */ + private void handleSalaryAcctEmployee(SalaryAcctCalculateBO salaryAcctCalculateBO, Map> resultMap) { + List salaryAcctEmployeePOS = salaryAcctCalculateBO.getSalaryAcctEmployeePOS(); + + // key:employeeId_taxAgentId、value:核算人员信息 + Map salaryAcctEmployeeMap = SalaryEntityUtil.convert2Map(salaryAcctEmployeePOS, + po -> po.getEmployeeId() + "_" + po.getTaxAgentId()); + // 核算人员信息可选字段 + List fieldNames = Lists.newArrayList(); + Field[] declaredFields = SalaryAcctEmployeePO.class.getDeclaredFields(); + for (Field declaredField : declaredFields) { + if (declaredField.isAnnotationPresent(SalaryFormulaVar.class)) { + fieldNames.add(declaredField.getName()); + } + } + // 填充到返回结果集中 + salaryAcctEmployeeMap.forEach((key, po) -> { + List formulaVarValues = resultMap.computeIfAbsent(key, k -> Lists.newArrayList()); + Map map = JsonUtil.parseMap(po, String.class); + formulaVarValues.addAll(fieldNames.stream().map(fieldName -> { + String fieldId = SalarySQLReferenceEnum.SALARY_ACCT_EMPLOYEE.getValue() + + SalaryFormulaFieldConstant.FIELD_ID_SEPARATOR + + fieldName; + String fieldValue = map.getOrDefault(fieldName, StringUtils.EMPTY); + //判断是否是日期,日期值取yyyy-MM-dd + if (StringUtils.isNotBlank(fieldValue) && fieldValue.length() > 10 && SalaryDateUtil.parse(fieldValue, DATE_TIME_FORMATTER_PATTERN) != null) { + fieldValue = fieldValue.substring(0, 10); + } + return new FormulaVarValue().setFieldId(fieldId).setFieldValue(fieldValue); + }).collect(Collectors.toList())); + + //将薪资周期转换成公式中的变量,填充到返回结果集中 + formulaVarValues.addAll(handleSalarySobCycleDTO(salaryAcctCalculateBO)); + }); + + } + + /** + * 处理员工基本信息 + * + * @param resultMap + */ + private void handleSimpleEmployees(Map> resultMap) { + + // key:employeeId_taxAgentId、value:员工信息 + Map employeeMap = SalaryEntityUtil.convert2Map(simpleEmployees, + po -> po.getEmployeeId() + ""); + // 核算人员信息可选字段 + List fieldNames = Lists.newArrayList(); + Field[] declaredFields = DataCollectionEmployee.class.getDeclaredFields(); + for (Field declaredField : declaredFields) { + if (declaredField.isAnnotationPresent(SalaryFormulaVar.class)) { + fieldNames.add(declaredField.getName()); + } + } + // 填充到返回结果集中 + employeeMap.forEach((key, po) -> { + // 获取po的状态 + if (po.getStatus() != null && NumberUtil.isNumber(po.getStatus())) { + po.setStatusName(UserStatusEnum.getDefaultLabelByValue(new Integer(Util.null2s(po.getStatus(), "1")))); + } + List formulaVarValues = resultMap.computeIfAbsent(key, k -> Lists.newArrayList()); + Map map = JsonUtil.parseMap(po, String.class); + formulaVarValues.addAll(fieldNames.stream().map(fieldName -> { + String fieldId = SalarySQLReferenceEnum.EMPLOYEE_INFO.getValue() + + SalaryFormulaFieldConstant.FIELD_ID_SEPARATOR + + fieldName; + return new FormulaVarValue().setFieldId(fieldId).setFieldValue(map.getOrDefault(fieldName, StringUtils.EMPTY)); + }).collect(Collectors.toList())); + }); + + } + + + @Data + @Accessors(chain = true) + public static class FormulaVarValue { + + /** + * 公式变量id + */ + private String fieldId; + + /** + * 公式变量的值 + */ + private String fieldValue; + } +} diff --git a/src/com/engine/salary/entity/salaryacct/bo/ExpressFormulaBO.java b/src/com/engine/salary/entity/salaryacct/bo/ExpressFormulaBO.java new file mode 100644 index 000000000..04339eee2 --- /dev/null +++ b/src/com/engine/salary/entity/salaryacct/bo/ExpressFormulaBO.java @@ -0,0 +1,116 @@ +package com.engine.salary.entity.salaryacct.bo; + +import com.engine.salary.constant.SalaryFormulaFieldConstant; +import com.engine.salary.entity.salaryacct.po.SalaryAcctResultPO; +import com.engine.salary.entity.salaryformula.ExpressFormula; +import com.engine.salary.entity.salaryformula.po.FormulaVar; +import com.engine.salary.entity.salaryitem.po.SalaryItemPO; +import com.engine.salary.enums.salaryformula.SalaryFormulaReferenceEnum; +import com.engine.salary.util.SalaryEntityUtil; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.common.collect.Maps; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * 薪资核算公式 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class ExpressFormulaBO { + + /** + * 公式中变量的fieldId的正则表达式 + */ + private static final String SALARY_REGEX = "(\\w+)" + SalaryFormulaFieldConstant.FIELD_ID_SEPARATOR + "(\\w+)"; + + /** + * 解析公式中变量的fieldId的正则表达式 + */ + private static final Pattern SALARY_PATTERN = Pattern.compile(SALARY_REGEX); + + /** + * 解析公式中的变量 + * + * @param expressFormulas 公式详情 + * @return + */ + public static Map> buildFormulaVar(List expressFormulas) { + if (CollectionUtils.isEmpty(expressFormulas)) { + return Collections.emptyMap(); + } + Map> resultMap = Maps.newHashMapWithExpectedSize(expressFormulas.size()); + for (ExpressFormula expressFormula : expressFormulas) { + resultMap.put(expressFormula.getId(), expressFormula.getParameters()); + } + return resultMap; + } + + /** + * 给公式中的变量填入值 + * + * @param expressFormulas + * @param salaryItems + * @param acctResults + * @return + */ + public static Map> buildFormulaVar4Check(List expressFormulas, List salaryItems, List acctResults) { + if (CollectionUtils.isEmpty(expressFormulas)) { + return Collections.emptyMap(); + } + Map salaryItemCodeMap = SalaryEntityUtil.convert2Map(salaryItems, SalaryItemPO::getId, SalaryItemPO::getCode); + Map acctResultMap = SalaryEntityUtil.convert2Map(acctResults, e -> salaryItemCodeMap.getOrDefault(e.getSalaryItemId(), ""), SalaryAcctResultPO::getResultValue); + Map> formulaVarMap = buildFormulaVar(expressFormulas); + formulaVarMap.forEach((k, v) -> { + for (FormulaVar formulaVar : v) { + Matcher matcher = SALARY_PATTERN.matcher(formulaVar.getFieldId()); + if (matcher.find()) { + SalaryFormulaReferenceEnum referenceEnum = SalaryFormulaReferenceEnum.parseByValue(matcher.group(1)); + if (referenceEnum == SalaryFormulaReferenceEnum.SALARY_ITEM) { + formulaVar.setContent(acctResultMap.getOrDefault(matcher.group(2), "")); + } + } + } + }); + return formulaVarMap; + } + + /** + * 给公式中的变量填入值 + * + * @param expressFormula 公式 + * @param formulaVarValueMap 公式变量的值 + * @return + */ + public static List buildFormulaVar4Accounting(ExpressFormula expressFormula, Map formulaVarValueMap) throws JsonProcessingException { + List formulaVars = new ArrayList<>(); + for (FormulaVar formulaVar : expressFormula.getParameters()) { + // 公式变量的值 + String formulaVarValue = formulaVarValueMap.getOrDefault(formulaVar.getFieldId(), StringUtils.EMPTY); + // 如果公式的返回值类型为number,公式中的变量的值如果为空,公式运行的时候会报错,所以需要替换成0 + if (StringUtils.isEmpty(formulaVarValue) && "number".equals(formulaVar.getFieldType())) { + formulaVarValue = BigDecimal.ZERO.toPlainString(); + } else if (StringUtils.isEmpty(formulaVarValue) && "string".equals(formulaVar.getFieldType())) { + formulaVarValue = ""; + } + + ObjectMapper objectMapper = new ObjectMapper(); + FormulaVar copyVar = objectMapper.readValue(objectMapper.writeValueAsString(formulaVar), FormulaVar.class); + copyVar.setContent(formulaVarValue); + formulaVars.add(copyVar); + } + return formulaVars; + } +} diff --git a/src/com/engine/salary/entity/salaryacct/bo/SalaryAcctCalculateBO.java b/src/com/engine/salary/entity/salaryacct/bo/SalaryAcctCalculateBO.java new file mode 100644 index 000000000..e0a777bcd --- /dev/null +++ b/src/com/engine/salary/entity/salaryacct/bo/SalaryAcctCalculateBO.java @@ -0,0 +1,140 @@ +package com.engine.salary.entity.salaryacct.bo; + +import com.engine.salary.entity.datacollection.dto.AttendQuoteFieldListDTO; +import com.engine.salary.entity.datacollection.po.VariableItemPO; +import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO; +import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO; +import com.engine.salary.entity.salaryformula.ExpressFormula; +import com.engine.salary.entity.salaryitem.po.SalaryItemPO; +import com.engine.salary.entity.salarysob.dto.SalarySobCycleDTO; +import com.engine.salary.entity.salarysob.po.SalarySobAdjustRulePO; +import com.engine.salary.entity.salarysob.po.SalarySobItemPO; +import com.engine.salary.entity.salarysob.po.SalarySobPO; +import com.engine.salary.sys.enums.TaxDeclarationFunctionEnum; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.BlockingDeque; +import java.util.concurrent.CountDownLatch; + +/** + * 薪资核算 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Accessors(chain = true) +public class SalaryAcctCalculateBO { + + /** + * 当前薪资核算记录 + */ + private SalaryAcctRecordPO salaryAcctRecordPO; + + /** + * 账套 + */ + private SalarySobPO salarySobPO; + + /** + * 当前薪资核算记录的薪资周期、考勤周期…… + */ + private SalarySobCycleDTO salarySobCycleDTO; + + /** + * 相同税款所属期内其他薪资核算记录(薪资类型为工资薪金的账套的) + */ + private List otherSalaryAcctRecordPOS; + + /** + * 当前薪资核算记录所用的薪资账套下的薪资项目 + */ + private List salarySobItemPOS; + + /** + * 本次运算的薪资项目(已排好运算优先级) + */ + private List> salaryItemIdWithPriorityList; + + /** + * 本次运算涉及的所有公式 + */ + private List expressFormulas; + + /** + * 租户下所有的薪资项目 + */ + private List salaryItemPOS; + + /** + * 当前薪资核算所用账套设置的调薪计薪规则 + */ + private List salarySobAdjustRulePOS; + + /** + * 社保福利字段 + */ + private Map welfareColumns; + + /** + * 考勤引用字段 + */ + private List attendQuoteFieldListDTOS; + + /** + * 本次运算的薪资核算人员 + */ + private List salaryAcctEmployeePOS; + + /** + * 本次运算的回算薪资项目所涉及的变量 + */ + private Set issuedFieldIds; + + /** + * 核算结果临时表中的key + */ + private String calculateKey; + + /** + * 监视子线程运算结果 + */ + private CountDownLatch childMonitor; + + /** + * 所有子线程的运算结果 + */ + private BlockingDeque results; + + /** + * 系统算税启用状态 + */ + private TaxDeclarationFunctionEnum taxDeclarationFunction; + + /** + * 浮动薪资字段 + */ + private List variableItems; + + @Data + @AllArgsConstructor + public static class Result { + + /** + * 子线程是否运算成功 + */ + private boolean status; + + /** + * 子线程元算失败的错误信息 + */ + private String errMsg; + } +} diff --git a/src/com/engine/salary/entity/salaryacct/bo/SalaryAcctCalculatePriorityBO.java b/src/com/engine/salary/entity/salaryacct/bo/SalaryAcctCalculatePriorityBO.java new file mode 100644 index 000000000..197ad1245 --- /dev/null +++ b/src/com/engine/salary/entity/salaryacct/bo/SalaryAcctCalculatePriorityBO.java @@ -0,0 +1,248 @@ +package com.engine.salary.entity.salaryacct.bo; + +import com.engine.salary.constant.SalaryFormulaFieldConstant; +import com.engine.salary.entity.salaryformula.ExpressFormula; +import com.engine.salary.entity.salaryformula.po.FormulaVar; +import com.engine.salary.entity.salaryitem.po.SalaryItemPO; +import com.engine.salary.entity.salarysob.po.SalarySobBackItemPO; +import com.engine.salary.entity.salarysob.po.SalarySobItemPO; +import com.engine.salary.enums.salaryformula.SalaryFormulaReferenceEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.SalaryI18nUtil; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; + +import java.util.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import java.util.stream.Collectors; + +/** + * 薪资核算-薪资项目运算优先级 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SalaryAcctCalculatePriorityBO { + + /** + * 公式中变量的fieldId的正则表达式 + */ + private static final String SALARY_REGEX = "(\\w+)" + SalaryFormulaFieldConstant.FIELD_ID_SEPARATOR + "(\\w+)"; + + /** + * 解析公式中变量的fieldId的正则表达式 + */ + private static final Pattern SALARY_PATTERN = Pattern.compile(SALARY_REGEX); + + /** + * 计算优先级 + * + * @param salarySobItems + * @param salaryItems + * @param expressFormulas + * @return 根据计算优先级已经排好序,集合中是薪资账套中的薪资项目 + */ + public static List> calculatePriority(List salarySobItems, + List salaryItems, + List expressFormulas, + List salarySobBackItems, + Set issuedFieldIds) { + // 公式详情 + Map> formulaIdKeyMap = ExpressFormulaBO.buildFormulaVar(expressFormulas); + // key:薪资项目的id,value:薪资项目的po + Map salaryItemPOMap = SalaryEntityUtil.convert2Map(salaryItems, SalaryItemPO::getId); + // key:薪资项目的code,value:薪资项目的po + Map codeKeySalaryItemPOMap = SalaryEntityUtil.convert2Map(salaryItems, SalaryItemPO::getCode); + // key:薪资项目的id,value:薪资账套下的薪资项目副本的po + Map salaryItemIdKeySalarySobItemPOMap = SalaryEntityUtil.convert2Map(salarySobItems, SalarySobItemPO::getSalaryItemId); + // 薪资账套项目+薪资回算项目 + Set salarySobItemsAndBackItems = SalaryEntityUtil.properties(salarySobItems, SalarySobItemPO::getSalaryItemId); + salarySobItemsAndBackItems.addAll(SalaryEntityUtil.properties(salarySobBackItems, SalarySobBackItemPO::getSalaryItemId)); + Map salaryItemIdWithPriorityMap = Maps.newHashMapWithExpectedSize(salarySobItemsAndBackItems.size()); + // key:薪资回算项目id,value:薪资回算项目副本PO + Map salarySobBackItemPOMap = SalaryEntityUtil.convert2Map(salarySobBackItems, SalarySobBackItemPO::getSalaryItemId); + for (Long salaryItemId : salarySobItemsAndBackItems) { + calculate(salaryItemId, salaryItemPOMap, codeKeySalaryItemPOMap, salaryItemIdKeySalarySobItemPOMap, formulaIdKeyMap, salaryItemIdWithPriorityMap, null, salarySobBackItemPOMap, issuedFieldIds); + } + return SalaryEntityUtil.group2Map(salaryItemIdWithPriorityMap.values(), SalaryItemIdWithPriority::getPriority).values().stream() + .sorted(Comparator.comparingInt(list -> list.get(0).getPriority())) + .map(list -> SalaryEntityUtil.properties(list, SalaryItemIdWithPriority::getSalaryItemId, Collectors.toList())) + .collect(Collectors.toList()); + } + + + /** + * 计算薪资账套中的薪资项目的计算优先级 + * + * @param currentSalaryItemId + * @param salaryItemPOMap + * @param salaryItemIdKeySalarySobItemPOMap + * @param codeKeySalaryItemPOMap + * @param formulaIdKeyMap + * @param salaryItemIdWithPriorityMap + * @param pre + */ + private static void calculate(Long currentSalaryItemId, + Map salaryItemPOMap, + Map codeKeySalaryItemPOMap, + Map salaryItemIdKeySalarySobItemPOMap, + Map> formulaIdKeyMap, + Map salaryItemIdWithPriorityMap, + SalaryItemIdWithPriority pre, + Map salarySobBackItemPOMap, + Set issuedFieldIds) { + List salaryItemIds = Lists.newArrayList(); + // 获取公式详情 + List formulaVars; + if (salaryItemIdKeySalarySobItemPOMap.containsKey(currentSalaryItemId)) { + // 如果薪资项目在薪资账套中有副本,则取薪资账套中设置的公式 + SalarySobItemPO salarySobItemPO = salaryItemIdKeySalarySobItemPOMap.get(currentSalaryItemId); + formulaVars = formulaIdKeyMap.getOrDefault(salarySobItemPO.getFormulaId(), Collections.emptyList()); + } else if(salarySobBackItemPOMap.containsKey(currentSalaryItemId)){ + // 如果薪资项目在薪资账套中没有副本,则取薪资回算中设置的公式 + SalarySobBackItemPO salarySobBackItemPO = salarySobBackItemPOMap.get(currentSalaryItemId); + formulaVars = formulaIdKeyMap.getOrDefault(salarySobBackItemPO.getFormulaId(), Collections.emptyList()); + } else { + // 如果薪资项目在薪资账套及回算薪资项目中没有有副本,则取薪资项目中设置的公式 + SalaryItemPO salaryItemPO = salaryItemPOMap.get(currentSalaryItemId); + formulaVars = formulaIdKeyMap.getOrDefault(salaryItemPO.getFormulaId(), Collections.emptyList()); + } + // 解析公式详情中的变量,找出引用了哪些其他的薪资项目(需要先计算出引用的薪资项目才能计算当前的薪资项目) + for (FormulaVar formulaVar : formulaVars) { + String fieldId = formulaVar.getFieldId(); + if (StringUtils.isEmpty(fieldId)) { + continue; + } + Matcher matcher = SALARY_PATTERN.matcher(fieldId); + if (matcher.find()) { + SalaryFormulaReferenceEnum referenceEnum = SalaryFormulaReferenceEnum.parseByValue(matcher.group(1)); + // 分析公式中的回算变量包含哪些 + loadSalaryCalcFormula(referenceEnum, issuedFieldIds, matcher.group(2)); + if (referenceEnum == SalaryFormulaReferenceEnum.SALARY_ITEM) { + SalaryItemPO salaryItemPO = codeKeySalaryItemPOMap.get(matcher.group(2)); + if (salaryItemPO == null) { + continue; + } + salaryItemIds.add(salaryItemPO.getId()); + } + } + } + if (CollectionUtils.isEmpty(salaryItemIds)) { + SalaryItemIdWithPriority current = salaryItemIdWithPriorityMap.computeIfAbsent(currentSalaryItemId, k -> SalaryItemIdWithPriority.builder() + .priority(0) + .salaryItemId(currentSalaryItemId) + .preList(Collections.emptyList()) + .build()); + addPre(current, pre, salaryItemPOMap); + updatePriority(current); + return; + } + for (Long salaryItemId : salaryItemIds) { + SalaryItemIdWithPriority current = salaryItemIdWithPriorityMap.computeIfAbsent(currentSalaryItemId, k -> SalaryItemIdWithPriority.builder() + .priority(1) + .salaryItemId(currentSalaryItemId) + .preList(Collections.emptyList()) + .build()); + addPre(current, pre, salaryItemPOMap); + updatePriority(current); + calculate(salaryItemId, salaryItemPOMap, codeKeySalaryItemPOMap, salaryItemIdKeySalarySobItemPOMap, formulaIdKeyMap, salaryItemIdWithPriorityMap, current, Collections.emptyMap(), issuedFieldIds); + } + } + + private static void loadSalaryCalcFormula(SalaryFormulaReferenceEnum referenceEnum, Set issuedFieldIds, String fieldId) { + if (referenceEnum == SalaryFormulaReferenceEnum.ISSUED) { + issuedFieldIds.add(fieldId); + } + } + + /** + * 薪资项目被哪些薪资项目引用 + * + * @param current + * @param pre + */ + private static void addPre(SalaryItemIdWithPriority current, SalaryItemIdWithPriority pre, Map salaryItemPOMap) { + if (pre == null) { + return; + } + checkLoop(current, pre, salaryItemPOMap); + if (CollectionUtils.isEmpty(current.getPreList())) { + current.setPreList(Lists.newArrayList(pre)); + } else { + boolean isExist = current.getPreList().stream().anyMatch(e -> Objects.equals(e.getSalaryItemId(), pre.getSalaryItemId())); + if (!isExist) { + current.getPreList().add(pre); + } + } + } + + /** + * 检查薪资项目之间是否存在相互引用 + * + * @param current + */ + private static void checkLoop(SalaryItemIdWithPriority current, SalaryItemIdWithPriority pre, Map salaryItemPOMap) { + if (Objects.equals(pre.getSalaryItemId(), current.getSalaryItemId())) { + SalaryItemPO preSalaryItemPO = salaryItemPOMap.get(pre.getSalaryItemId()); + SalaryItemPO currentSalaryItemPO = salaryItemPOMap.get(current.getSalaryItemId()); + String errMsg = SalaryI18nUtil.getI18nLabel(101426, "{0}和{1}的公式中存在相互引用") + .replace("{0}", Optional.ofNullable(preSalaryItemPO).map(SalaryItemPO::getName).orElse(StringUtils.EMPTY)) + .replace("{1}", Optional.ofNullable(currentSalaryItemPO).map(SalaryItemPO::getName).orElse(StringUtils.EMPTY)); + throw new SalaryRunTimeException(errMsg); + } + if (CollectionUtils.isEmpty(pre.getPreList())) { + return; + } + for (SalaryItemIdWithPriority salaryItemIdWithPriority : pre.getPreList()) { + checkLoop(current, salaryItemIdWithPriority, salaryItemPOMap); + } + } + + /** + * 更新薪资账套中的薪资项目的计算优先级 + * + * @param current + */ + private static void updatePriority(SalaryItemIdWithPriority current) { + List preList = current.getPreList(); + if (CollectionUtils.isEmpty(preList)) { + return; + } + preList.stream() + .filter(e -> e.getPriority() <= current.getPriority()) + .forEach(e -> e.setPriority(current.getPriority() + 1)); + } + + + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + private static class SalaryItemIdWithPriority { + + /** + * 薪资账套中的薪资项目的计算优先级(数字越小,计算优先级越高,从0开始计算) + */ + private Integer priority; + + /** + * 薪资项目的id + */ + private Long salaryItemId; + + /** + * 当前层级中的上层 + */ + private List preList; + } +} diff --git a/src/com/engine/salary/entity/salaryacct/bo/SalaryAcctCheckBO.java b/src/com/engine/salary/entity/salaryacct/bo/SalaryAcctCheckBO.java new file mode 100644 index 000000000..d14a592f7 --- /dev/null +++ b/src/com/engine/salary/entity/salaryacct/bo/SalaryAcctCheckBO.java @@ -0,0 +1,81 @@ +//package com.engine.salary.entity.salaryacct.bo; +// +//import com.weaver.excel.formula.api.entity.ExpressFormula; +//import com.weaver.hrm.salary.entity.salaryacct.po.SalaryAcctEmployeePO; +//import com.weaver.hrm.salary.entity.salaryacct.po.SalaryAcctRecordPO; +//import com.weaver.hrm.salary.entity.salaryitem.po.SalaryItemPO; +//import com.weaver.hrm.salary.entity.salarysob.po.SalarySobCheckRulePO; +//import lombok.AllArgsConstructor; +//import lombok.Data; +//import lombok.experimental.Accessors; +// +//import java.util.List; +//import java.util.concurrent.BlockingDeque; +//import java.util.concurrent.CountDownLatch; +// +///** +// * @description: 薪资核算-校验 +// * @author: xiajun +// * @modified By: xiajun +// * @date: Created in 2/7/22 11:06 AM +// * @version:v1.0 +// */ +//@Data +//@Accessors(chain = true) +//public class SalaryAcctCheckBO { +// +// /** +// * 当前薪资核算记录 +// */ +// private SalaryAcctRecordPO salaryAcctRecordPO; +// +// /** +// * 本次运算所用的薪资账套下的校验规则 +// */ +// private List salarySobCheckRulePOS; +// +// /** +// * 本次运算涉及的所有公式 +// */ +// private List expressFormulas; +// +// /** +// * 租户下所有的薪资项目 +// */ +// private List salaryItemPOS; +// +// /** +// * 本次运算的薪资核算人员 +// */ +// private List salaryAcctEmployeePOS; +// +// /** +// * 核算结果临时表中的key +// */ +// private String calculateKey; +// +// /** +// * 监视子线程运算结果 +// */ +// private CountDownLatch childMonitor; +// +// /** +// * 所有子线程的运算结果 +// */ +// private BlockingDeque results; +// +// @Data +// @AllArgsConstructor +// public static class Result { +// +// /** +// * 子线程是否运算成功 +// */ +// private boolean status; +// +// /** +// * 子线程元算失败的错误信息 +// */ +// private String errMsg; +// } +//} diff --git a/src/com/engine/salary/entity/salaryacct/bo/SalaryAcctConfig.java b/src/com/engine/salary/entity/salaryacct/bo/SalaryAcctConfig.java new file mode 100644 index 000000000..70d8b96c9 --- /dev/null +++ b/src/com/engine/salary/entity/salaryacct/bo/SalaryAcctConfig.java @@ -0,0 +1,84 @@ +package com.engine.salary.entity.salaryacct.bo; + +import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO; +import com.engine.salary.entity.salaryacct.po.SalaryAcctSobConfigPO; +import com.engine.salary.entity.salarysob.po.*; +import com.engine.salary.enums.sicategory.DeleteTypeEnum; +import com.engine.salary.util.JsonUtil; +import com.engine.salary.util.db.IdGenerator; +import lombok.Builder; +import lombok.Data; + +import java.util.Date; +import java.util.List; + +@Data +@Builder +public class SalaryAcctConfig { + + private SalaryAcctRecordPO salaryAcctRecord; + + private SalarySobPO salarySob; + + private List salarySobEmpFields; + + private List salarySobItems; + + private List salarySobItemGroups; + + private List salarySobBackItems; + + @Deprecated + private List salarySobAdjustRules; + + @Deprecated + private List salarySobCheckRules; + + public SalaryAcctConfig(SalaryAcctRecordPO salaryAcctRecord, + SalarySobPO salarySob, + List salarySobEmpFields, + List salarySobItems, + List salarySobItemGroups, + List salarySobBackItems, + List salarySobAdjustRules, + List salarySobCheckRules) { + this.salaryAcctRecord = salaryAcctRecord; + this.salarySob = salarySob; + this.salarySobEmpFields = salarySobEmpFields; + this.salarySobItems = salarySobItems; + this.salarySobItemGroups = salarySobItemGroups; + this.salarySobBackItems = salarySobBackItems; + this.salarySobAdjustRules = salarySobAdjustRules; + this.salarySobCheckRules = salarySobCheckRules; + } + + public SalaryAcctSobConfigPO buildAcctSobConfig() { + Date now = new Date(); + return SalaryAcctSobConfigPO.builder() + .id(IdGenerator.generate()) + .salaryAcctRecordId(salaryAcctRecord.getId()) + .basicConfig(JsonUtil.toJsonString(salarySob)) + .employeeFieldConfig(JsonUtil.toJsonString(salarySobEmpFields)) + .itemConfig(JsonUtil.toJsonString(salarySobItems)) + .itemGroupConfig(JsonUtil.toJsonString(salarySobItemGroups)) + .backItemConfig(JsonUtil.toJsonString(salarySobBackItems)) + .adjustRuleConfig(JsonUtil.toJsonString(salarySobAdjustRules)) + .checkRuleConfig(JsonUtil.toJsonString(salarySobCheckRules)) + .tenantKey(salaryAcctRecord.getTenantKey()) + .deleteType(DeleteTypeEnum.NOT_DELETED.getValue()) + .creator(salaryAcctRecord.getCreator()) + .createTime(now) + .updateTime(now) + .build(); + } + + public static SalaryAcctConfig parse(SalaryAcctSobConfigPO po) { + return SalaryAcctConfig.builder() + .salarySob(JsonUtil.parseObject(po.getBasicConfig(), SalarySobPO.class)) + .salarySobEmpFields(JsonUtil.parseList(po.getEmployeeFieldConfig(), SalarySobEmpFieldPO.class)) + .salarySobItemGroups(JsonUtil.parseList(po.getItemGroupConfig(), SalarySobItemGroupPO.class)) + .salarySobItems(JsonUtil.parseList(po.getItemConfig(), SalarySobItemPO.class)) + .salarySobBackItems(JsonUtil.parseList(po.getBackItemConfig(), SalarySobBackItemPO.class)) + .build(); + } +} diff --git a/src/com/engine/salary/entity/salaryacct/bo/SalaryAcctConsolidatedTaxBO.java b/src/com/engine/salary/entity/salaryacct/bo/SalaryAcctConsolidatedTaxBO.java new file mode 100644 index 000000000..d5155f0ae --- /dev/null +++ b/src/com/engine/salary/entity/salaryacct/bo/SalaryAcctConsolidatedTaxBO.java @@ -0,0 +1,105 @@ +package com.engine.salary.entity.salaryacct.bo; + +import com.engine.salary.constant.TaxDeclarationDataIndexConstant; +import com.engine.salary.entity.salaryacct.po.SalaryAcctResultPO; +import com.engine.salary.entity.salaryitem.po.SalaryItemPO; +import com.engine.salary.util.SalaryEntityUtil; +import com.google.common.collect.Lists; +import org.apache.commons.lang3.StringUtils; + +import java.math.BigDecimal; +import java.util.List; +import java.util.Objects; +import java.util.Optional; + +public class SalaryAcctConsolidatedTaxBO { + + /** + * 处理合并计税的字段的值 + * + * @param resultValue 本次薪资核算的结果 + * @param salaryItem 当前正在核算的薪资项目 + * @param salaryItems 系统内所有的薪资项目 + * @param salaryAcctResults 其他设计合并计税的薪资核算结果 + * @return + */ + public static String handleConsolidatedTaxValue(String resultValue, + SalaryItemPO salaryItem, + List salaryItems, + List salaryAcctResults) { + // 社保福利的当月值都是0 + List welfareDataIndexList = Lists.newArrayList(TaxDeclarationDataIndexConstant.ENDOWMENT_INSURANCE, + TaxDeclarationDataIndexConstant.MEDICAL_INSURANCE, + TaxDeclarationDataIndexConstant.UNEMPLOYMENT_INSURANCE, + TaxDeclarationDataIndexConstant.HOUSING_PROVIDENT_FUND, + TaxDeclarationDataIndexConstant.SOCIAL_SECURITY_TOTAL, + TaxDeclarationDataIndexConstant.ACCUMULATION_FUND_TOTAL, + TaxDeclarationDataIndexConstant.SPECIAL_DEDUCTION); + if (welfareDataIndexList.contains(salaryItem.getCode())) { + return BigDecimal.ZERO.toPlainString(); + } + // 专项附加扣除的当月值都是0 + List speAddiDeductionDataIndexList = Lists.newArrayList(TaxDeclarationDataIndexConstant.ADD_UP_CHILD_EDUCATION, + TaxDeclarationDataIndexConstant.ADD_UP_HOUSING_LOAN_INTEREST, + TaxDeclarationDataIndexConstant.ADD_UP_HOUSING_RENT, + TaxDeclarationDataIndexConstant.ADD_UP_CONTINUING_EDUCATION, + TaxDeclarationDataIndexConstant.ADD_UP_SUPPORT_ELDERLY, + TaxDeclarationDataIndexConstant.ADD_UP_ILLNESS_MEDICAL, + TaxDeclarationDataIndexConstant.ADD_UP_INFANT_CARE); + if (speAddiDeductionDataIndexList.contains(salaryItem.getCode())) { + return BigDecimal.ZERO.toPlainString(); + } + // 本月(次)减除费用也是0 + if (TaxDeclarationDataIndexConstant.SUBTRACTION.equals(salaryItem.getCode())) { + return BigDecimal.ZERO.toPlainString(); + } + // 当前累计减除费用、当前累计专项扣除合计、当前累计专项附加扣除合计 + if (TaxDeclarationDataIndexConstant.ADD_UP_SUBTRACTION.equals(salaryItem.getCode()) + || TaxDeclarationDataIndexConstant.ADD_UP_SPECIAL_DEDUCTION.equals(salaryItem.getCode()) + || TaxDeclarationDataIndexConstant.ADD_UP_SPE_ADDI_DEDUCTION.equals(salaryItem.getCode())) { + return salaryAcctResults.stream() + .filter(e -> Objects.equals(e.getSalaryItemId(), salaryItem.getId())) + .findFirst() + .map(SalaryAcctResultPO::getResultValue) + .orElse(""); + } + // 当前累计收入 = 累计值 + 本次收入 + 上几次收入 + if (TaxDeclarationDataIndexConstant.ADD_UP_INCOME.equals(salaryItem.getCode())) { + Optional optional = salaryItems.stream().filter(e -> StringUtils.equals(e.getCode(), TaxDeclarationDataIndexConstant.INCOME)).map(SalaryItemPO::getId).findAny(); + if (!optional.isPresent()) { + return ""; + } + BigDecimal income = salaryAcctResults.stream() + .filter(e -> Objects.equals(e.getSalaryItemId(), optional.get())) + .map(e -> SalaryEntityUtil.empty2Zero(e.getResultValue())) + .reduce(BigDecimal.ZERO, BigDecimal::add); + return new BigDecimal(resultValue).add(income).toPlainString(); + } + // 个税调差为0 + if (TaxDeclarationDataIndexConstant.TAX_ADJUSTMENT.equals(salaryItem.getCode())) { + return BigDecimal.ZERO.toPlainString(); + } + // 当前累计已扣缴税额合计 = 累计值 + 上几次预扣预缴个税 - 个税调差 + if (TaxDeclarationDataIndexConstant.ADD_UP_ADVANCE_TAX.equals(salaryItem.getCode())) { + Optional optional = salaryItems.stream().filter(e -> StringUtils.equals(e.getCode(), TaxDeclarationDataIndexConstant.REFUNDED_OR_SUPPLEMENTED_TAX)).map(SalaryItemPO::getId).findAny(); + if (!optional.isPresent()) { + return ""; + } + BigDecimal refundedOrSupplementedTax = salaryAcctResults.stream() + .filter(e -> Objects.equals(e.getSalaryItemId(), optional.get())) + .map(e -> SalaryEntityUtil.empty2Zero(e.getResultValue())) + .reduce(BigDecimal.ZERO, BigDecimal::add); + // 个税调差 + Optional taxAdjustmentOptional = salaryItems.stream().filter(e -> StringUtils.equals(e.getCode(), TaxDeclarationDataIndexConstant.TAX_ADJUSTMENT)).map(SalaryItemPO::getId).findAny(); + BigDecimal taxAdjustment = BigDecimal.ZERO; + if (taxAdjustmentOptional.isPresent()) { + taxAdjustment = salaryAcctResults.stream() + .filter(e -> Objects.equals(e.getSalaryItemId(), taxAdjustmentOptional.get())) + .map(e -> SalaryEntityUtil.empty2Zero(e.getResultValue())) + .reduce(BigDecimal.ZERO, BigDecimal::add); + } + return new BigDecimal(resultValue).add(refundedOrSupplementedTax).subtract(taxAdjustment).toPlainString(); + } + return resultValue; + } +} diff --git a/src/com/engine/salary/entity/salaryacct/bo/SalaryAcctEmployeeBO.java b/src/com/engine/salary/entity/salaryacct/bo/SalaryAcctEmployeeBO.java new file mode 100644 index 000000000..a8dbc514e --- /dev/null +++ b/src/com/engine/salary/entity/salaryacct/bo/SalaryAcctEmployeeBO.java @@ -0,0 +1,171 @@ +package com.engine.salary.entity.salaryacct.bo; + +import com.engine.salary.constant.SalaryDefaultTenantConstant; +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.salaryacct.dto.SalaryAccEmployeeListDTO; +import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO; +import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO; +import com.engine.salary.entity.salaryarchive.dto.SalaryArchiveDataDTO; +import com.engine.salary.entity.salaryarchive.dto.SalaryArchiveTaxAgentDataDTO; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import com.engine.salary.enums.AccountTypeEnum; +import com.engine.salary.enums.UserStatusEnum; +import com.engine.salary.util.SalaryEntityUtil; +import com.google.common.collect.Lists; +import com.google.common.collect.Sets; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.math.NumberUtils; +import weaver.general.Util; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * 薪资核算人员 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SalaryAcctEmployeeBO { + + /** + * 将薪资核算人员po转换成薪资核算人员列表dto + * + * @param salaryAccountingEmployees + * @param taxAgents + * @param simpleEmployees + * @return + */ + public static List convert2EmployeeListDTO(List salaryAccountingEmployees, + List taxAgents, + List simpleEmployees) { + if (CollectionUtils.isEmpty(salaryAccountingEmployees)) { + return Collections.emptyList(); + } + Map taxAgentNameMap = SalaryEntityUtil.convert2Map(taxAgents, TaxAgentPO::getId, TaxAgentPO::getName); + Map simpleEmployeeMap = SalaryEntityUtil.convert2Map(simpleEmployees, DataCollectionEmployee::getEmployeeId); + return salaryAccountingEmployees.stream() + .map(e -> { + DataCollectionEmployee simpleEmployee = simpleEmployeeMap.get(e.getEmployeeId()); + if (simpleEmployee == null) { + return SalaryAccEmployeeListDTO.builder() + .id(e.getId()) + .employeeId(e.getId()) + .taxAgentId(e.getTaxAgentId()) + .taxAgentName(taxAgentNameMap.getOrDefault(e.getTaxAgentId(), StringUtils.EMPTY)) + .build(); + } + return SalaryAccEmployeeListDTO.builder() + .id(e.getId()) + .employeeId(simpleEmployee.getEmployeeId()) + .employeeName(simpleEmployee.getUsername()) + .taxAgentId(e.getTaxAgentId()) + .taxAgentName(taxAgentNameMap.getOrDefault(e.getTaxAgentId(), StringUtils.EMPTY)) + .departmentId(e.getDepartmentId()) + .departmentName(e.getDepartmentName()) + .status(UserStatusEnum.getDefaultLabelByValue(NumberUtils.toInt(e.getStatus()))) + .accountType(AccountTypeEnum.getDefaultLabelByValue(e.getAccountType())) + .mobile(simpleEmployee.getMobile()) + .jobNum(simpleEmployee.getWorkcode()) + .hireDate(simpleEmployee.getCompanystartdate()) + .dismissDate(simpleEmployee.getDismissdate()) + .build(); + }).collect(Collectors.toList()); + } + + public static List convert2Employee(Collection employee, + SalaryAcctRecordPO salaryAcctRecord, + List salaryArchiveTaxAgentData, + Long employeeId) { + if (CollectionUtils.isEmpty(employee)) { + return Collections.emptyList(); + } + List resultList = Lists.newArrayList(); + Map>> empIdKeyTaxAgentMap = SalaryEntityUtil.group2Map(salaryArchiveTaxAgentData, SalaryArchiveDataDTO::getEmployeeId, SalaryArchiveDataDTO::getTaxAgents); + Date now = new Date(); + for (DataCollectionEmployee emp : employee) { + Set taxAgentIds = Sets.newHashSet(); + Set> taxAgentSet = empIdKeyTaxAgentMap.getOrDefault(emp.getEmployeeId(), Collections.emptySet()); + for (List taxAgents : taxAgentSet) { + taxAgentIds.addAll(SalaryEntityUtil.properties(taxAgents, SalaryArchiveTaxAgentDataDTO::getTaxAgentId)); + } + if (CollectionUtils.isEmpty(taxAgentIds)) { + taxAgentIds.add(0L); + } + for (Long taxAgentId : taxAgentIds) { + SalaryAcctEmployeePO salaryAcctEmployee = SalaryAcctEmployeePO.builder() + .salaryAcctRecordId(salaryAcctRecord.getId()) + .salarySobId(salaryAcctRecord.getSalarySobId()) + .salaryMonth(salaryAcctRecord.getSalaryMonth()) + .employeeId(emp.getEmployeeId()) + .employeeType(emp.isExtEmp() ? 1 : 0) + .taxAgentId(taxAgentId) + .departmentId(emp.getDepartmentId()) + .departmentName(emp.getDepartmentName()) + .jobcall(emp.getJobcall()) + .jobcallId(emp.getJobcallId()) + .jobtitleId(emp.getJobtitleId()) + .jobtitleName(emp.getJobtitleName()) + .subcompanyId(emp.getSubcompanyid()) + .subcompanyName(emp.getSubcompanyName()) + .status(emp.getStatus()) + .accountType(emp.getAccountType()) + .creator(employeeId) + .createTime(now) + .updateTime(now) + .deleteType(0) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .build(); + resultList.add(salaryAcctEmployee); + } + } + return resultList; + } + + /** + * 核算人员信息替换实时信息 + * @param simpleEmployee + * @param acctEmployeePO + */ + public static void copyAcctEmp(DataCollectionEmployee simpleEmployee, SalaryAcctEmployeePO acctEmployeePO) { + simpleEmployee.setDepartmentId(acctEmployeePO.getDepartmentId()); + simpleEmployee.setDepartmentName(acctEmployeePO.getDepartmentName()); + simpleEmployee.setSubcompanyid(acctEmployeePO.getSubcompanyId()); + simpleEmployee.setSubcompanyName(acctEmployeePO.getSubcompanyName()); + simpleEmployee.setJobcallId(acctEmployeePO.getJobcallId()); + simpleEmployee.setJobcall(acctEmployeePO.getJobcall()); + simpleEmployee.setJobtitleId(acctEmployeePO.getJobtitleId()); + simpleEmployee.setJobtitleName(acctEmployeePO.getJobtitleName()); + simpleEmployee.setStatusName(UserStatusEnum.getDefaultLabelByValue(new Integer(Util.null2s(acctEmployeePO.getStatus(), "1")))); + simpleEmployee.setStatus(acctEmployeePO.getStatus()); + simpleEmployee.setAccountType(acctEmployeePO.getAccountType()); + simpleEmployee.setAccountTypeName(AccountTypeEnum.getDefaultLabelByValue(acctEmployeePO.getAccountType())); + } + + + public static List> partitionByEmployeeId(List salaryAcctEmployees) { + if (CollectionUtils.isEmpty(salaryAcctEmployees)) { + return Collections.emptyList(); + } + List employeeIdList = salaryAcctEmployees.stream() + .map(SalaryAcctEmployeePO::getEmployeeId) + .distinct() + .collect(Collectors.toList()); + // 每个线程处理多少个人员(一个线程最多处理10个人员) + int size = 100; + List> partition = Lists.partition(employeeIdList, size); + List> resultList = new ArrayList<>(); + Map> salaryAcctEmployeeMap = SalaryEntityUtil.group2Map(salaryAcctEmployees, SalaryAcctEmployeePO::getEmployeeId); + for (List employeeIds : partition) { + List temp = new ArrayList<>(); + for (Long employeeId : employeeIds) { + temp.addAll(salaryAcctEmployeeMap.getOrDefault(employeeId, Collections.emptyList())); + } + resultList.add(temp); + } + return resultList; + } +} diff --git a/src/com/engine/salary/entity/salaryacct/bo/SalaryAcctFormulaBO.java b/src/com/engine/salary/entity/salaryacct/bo/SalaryAcctFormulaBO.java new file mode 100644 index 000000000..b3335f05e --- /dev/null +++ b/src/com/engine/salary/entity/salaryacct/bo/SalaryAcctFormulaBO.java @@ -0,0 +1,140 @@ +package com.engine.salary.entity.salaryacct.bo; + +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO; +import com.engine.salary.entity.salaryformula.dto.SalaryFormulaEmployeeDTO; +import com.engine.salary.entity.salaryitem.po.SalaryItemPO; +import com.engine.salary.entity.salarysob.po.SalarySobBackItemPO; +import com.engine.salary.entity.salarysob.po.SalarySobItemPO; +import com.engine.salary.enums.UserStatusEnum; +import com.engine.salary.enums.salaryitem.SalaryDataTypeEnum; +import com.engine.salary.util.JsonUtil; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.SalaryI18nUtil; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import weaver.general.Util; + +import java.math.BigDecimal; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Optional; + +/** + * 薪资核算公式变量 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SalaryAcctFormulaBO { + + /** + * 对核算结果做舍入操作 + * + * @param value + * @param salaryItem + * @param salarySobBackItems 薪资账套回算项目List + * @param salarySobBackItemMap 薪资账套回算项目Map + * @param salaryItemIdKeySalarySobItemPOMap 薪资账套下薪资项目Map + * @return + */ + public static String roundResultValue(String value, SalaryItemPO salaryItem, + List salarySobBackItems, + Map salarySobBackItemMap, + Map salaryItemIdKeySalarySobItemPOMap) { + // 值为空,不需要四舍五入 + if (StringUtils.isEmpty(value) || salaryItem == null) { + return StringUtils.EMPTY; + } + // 薪资项目字段类型为string,无需四舍五入 + SalaryDataTypeEnum dataTypeEnum = SalaryDataTypeEnum.parseByValue(salaryItem.getDataType()); + if (dataTypeEnum == SalaryDataTypeEnum.STRING) { + return value; + } + // 获取薪资账套副本中的舍入规则和保留位数,拿不到再去薪资项目中取 + Integer salaryItemRoundingMode = Optional.ofNullable(salaryItemIdKeySalarySobItemPOMap.get(salaryItem.getId())).map(SalarySobItemPO::getRoundingMode) + .orElse(salaryItem.getRoundingMode()); + Integer salaryItemPattern = Optional.ofNullable(salaryItemIdKeySalarySobItemPOMap.get(salaryItem.getId())).map(SalarySobItemPO::getPattern) + .orElse(salaryItem.getPattern()); + if (CollectionUtils.isNotEmpty(salarySobBackItems) && salarySobBackItemMap.containsKey(salaryItem.getId())) { + // 薪资项目是回算项目 + salaryItemRoundingMode = salarySobBackItemMap.get(salaryItem.getId()).getRoundingMode(); + salaryItemPattern = salarySobBackItemMap.get(salaryItem.getId()).getPattern(); + } + BigDecimal bigDecimalValue = SalaryEntityUtil.empty2Zero(value); + return SalaryEntityUtil.carryRule(salaryItemPattern, salaryItemRoundingMode, bigDecimalValue).toPlainString(); + } + + /** + * 变量中的人员信息 + * + * @param simpleEmployee + * @return + */ + public static Map convert2FormulaEmployee(DataCollectionEmployee simpleEmployee, SalaryAcctEmployeePO salaryAcctEmployeePO, boolean dynamicEmpInfo) { + if (simpleEmployee == null) { + return Collections.emptyMap(); + } + String sexName = Optional.ofNullable(simpleEmployee.getSex()) + .map(sex -> StringUtils.equals(sex, "0") ? SalaryI18nUtil.getI18nLabel(102440, "男") + : SalaryI18nUtil.getI18nLabel(102442, "女")) + .orElse(StringUtils.EMPTY); + + SalaryFormulaEmployeeDTO formulaEmployee = null; + if (dynamicEmpInfo) { + formulaEmployee = SalaryFormulaEmployeeDTO.builder() + .employeeId(simpleEmployee.getEmployeeId()) + .username(simpleEmployee.getUsername()) + .email(simpleEmployee.getEmail()) + .mobile(simpleEmployee.getMobile()) + .telephone(simpleEmployee.getTelephone()) + .sex(sexName) + .status(simpleEmployee.getStatus()) + .statusName(simpleEmployee.getStatusName()) + .accountType(simpleEmployee.getAccountType()) + .accountTypeName(simpleEmployee.getAccountTypeName()) + .departmentName(simpleEmployee.getDepartmentName()) + .departmentId(simpleEmployee.getDepartmentId()) + .subcompanyName(simpleEmployee.getSubcompanyName()) + .subcompanyId(simpleEmployee.getSubcompanyid()) + .jobtitleName(simpleEmployee.getJobtitleName()) + .jobtitleId(simpleEmployee.getJobtitleId()) + .jobcall(simpleEmployee.getJobcall()) + .jobcallId(simpleEmployee.getJobcallId()) + .companystartdate(simpleEmployee.getCompanystartdate()) + .birthday(simpleEmployee.getBirthday()) + .workcode(simpleEmployee.getWorkcode()) + .idNo(simpleEmployee.getIdNo()) + .build(); + } else { + formulaEmployee = SalaryFormulaEmployeeDTO.builder() + .employeeId(simpleEmployee.getEmployeeId()) + .username(simpleEmployee.getUsername()) + .email(simpleEmployee.getEmail()) + .mobile(simpleEmployee.getMobile()) + .telephone(simpleEmployee.getTelephone()) + .sex(sexName) + .status(salaryAcctEmployeePO.getStatus()) + .statusName(UserStatusEnum.getDefaultLabelByValue(new Integer(Util.null2s(salaryAcctEmployeePO.getStatus(), "1")))) + .accountType(simpleEmployee.getAccountType()) + .accountTypeName(simpleEmployee.getAccountTypeName()) + .departmentName(salaryAcctEmployeePO.getDepartmentName()) + .departmentId(salaryAcctEmployeePO.getDepartmentId()) + .subcompanyName(salaryAcctEmployeePO.getSubcompanyName()) + .subcompanyId(salaryAcctEmployeePO.getSubcompanyId()) + .jobtitleName(salaryAcctEmployeePO.getJobtitleName()) + .jobtitleId(salaryAcctEmployeePO.getJobtitleId()) + .jobcall(salaryAcctEmployeePO.getJobcall()) + .jobcallId(salaryAcctEmployeePO.getJobcallId()) + .companystartdate(simpleEmployee.getCompanystartdate()) + .birthday(simpleEmployee.getBirthday()) + .workcode(simpleEmployee.getWorkcode()) + .idNo(simpleEmployee.getIdNo()) + .build(); + } + return JsonUtil.parseMap(JsonUtil.toJsonString(formulaEmployee), String.class); + } +} diff --git a/src/com/engine/salary/entity/salaryacct/bo/SalaryAcctRecordBO.java b/src/com/engine/salary/entity/salaryacct/bo/SalaryAcctRecordBO.java new file mode 100644 index 000000000..408da743f --- /dev/null +++ b/src/com/engine/salary/entity/salaryacct/bo/SalaryAcctRecordBO.java @@ -0,0 +1,181 @@ +package com.engine.salary.entity.salaryacct.bo; + +import com.cloudstore.eccom.pc.table.WeaTableOperate; +import com.engine.salary.constant.SalaryDefaultTenantConstant; +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.salaryBill.dto.SalarySendCheckDTO; +import com.engine.salary.entity.salaryacct.dto.SalaryAcctEmployeeCountDTO; +import com.engine.salary.entity.salaryacct.dto.SalaryAcctRecordListDTO; +import com.engine.salary.entity.salaryacct.param.SalaryAcctRecordSaveParam; +import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO; +import com.engine.salary.entity.salarysob.dto.SalarySobCycleDTO; +import com.engine.salary.entity.salarysob.po.SalarySobPO; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import com.engine.salary.enums.salaryaccounting.SalaryAcctRecordStatusEnum; +import com.engine.salary.util.SalaryDateUtil; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.SalaryI18nUtil; +import com.google.common.collect.Lists; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.math.NumberUtils; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * 薪资核算 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SalaryAcctRecordBO { + + /** + * 将薪资核算记录po转换成薪资核算记录列表dto + * + * @param salaryAcctRecordPOS + * @param salarySobs + * @param employeeComInfos + * @param salaryAcctEmployeeCountDTOS + * @return + */ + public static List convert2ListDTO(List salaryAcctRecordPOS, + List salarySobs, + List employeeComInfos, + List salaryAcctEmployeeCountDTOS, + List salarySendCheckResult, + List taxAgentPOS, + List needApprovalSalarySobIds, + boolean approvalCanFile, + boolean approvalCanReCalc) { + if (CollectionUtils.isEmpty(salaryAcctRecordPOS)) { + return Collections.emptyList(); + } + Map salarySobMap = SalaryEntityUtil.convert2Map(salarySobs, SalarySobPO::getId); + Map usernameMap = SalaryEntityUtil.convert2Map(employeeComInfos, DataCollectionEmployee::getEmployeeId, DataCollectionEmployee::getUsername); + Map empSizeMap = SalaryEntityUtil.convert2Map(salaryAcctEmployeeCountDTOS, SalaryAcctEmployeeCountDTO::getSalaryAcctRecordId, SalaryAcctEmployeeCountDTO::getCountBySalaryAcctRecordId); + Map salarySendMap = SalaryEntityUtil.convert2Map(salarySendCheckResult, SalarySendCheckDTO::getSalaryAcctId, SalarySendCheckDTO::isSendFinished); + Map taxAgentMap = SalaryEntityUtil.convert2Map(taxAgentPOS, TaxAgentPO::getId, TaxAgentPO::getName); + return salaryAcctRecordPOS.stream() + .map(salaryAcctRecordPO -> { + SalarySobPO salarySobPO = salarySobMap.get(salaryAcctRecordPO.getSalarySobId()); + SalaryAcctRecordStatusEnum salaryAcctRecordStatusEnum = SalaryAcctRecordStatusEnum.parseByValue(salaryAcctRecordPO.getStatus()); + // 只有未归档时可以"核算"、"删除"、"归档" + // 归档后、工资单全部发放以后可以"查看"、"重新核算"、"回算" + // 归档后、申报后可以"查看"、"重新核算" + List btnList = new ArrayList<>(); + if (SalaryAcctRecordStatusEnum.NOT_ARCHIVED == salaryAcctRecordStatusEnum) { + btnList.add(new WeaTableOperate("核算", null, "0")); + if(!Objects.equals(salaryAcctRecordPO.getBackCalcStatus(),NumberUtils.INTEGER_ONE)){ + btnList.add(new WeaTableOperate("删除", null, "1")); + } + if (approvalCanFile || !needApprovalSalarySobIds.contains(salaryAcctRecordPO.getSalarySobId())) { + btnList.add(new WeaTableOperate("归档", null, "2")); + } + } else if (SalaryAcctRecordStatusEnum.ARCHIVED == salaryAcctRecordStatusEnum && ( salarySendMap.get(salaryAcctRecordPO.getId()) ==Boolean.TRUE ) ){ + btnList.add(new WeaTableOperate("查看", null, "3")); + if (approvalCanReCalc || !needApprovalSalarySobIds.contains(salaryAcctRecordPO.getSalarySobId())) { + btnList.add(new WeaTableOperate("重新核算", null, "4")); + } + if(salaryAcctRecordPO.getBackCalcStatus() == null || salaryAcctRecordPO.getBackCalcStatus() == NumberUtils.INTEGER_ZERO) { + btnList.add(new WeaTableOperate("回算", null, "5")); + } + } else { + btnList.add(new WeaTableOperate("查看", null, "3")); + if (approvalCanReCalc || !needApprovalSalarySobIds.contains(salaryAcctRecordPO.getSalarySobId())) { + btnList.add(new WeaTableOperate("重新核算", null, "4")); + } + } + String taxAgentName = salarySobPO.getTaxAgentIds().stream().map(id -> taxAgentMap.getOrDefault(id, "")).collect(Collectors.joining(",")); + return SalaryAcctRecordListDTO.builder() + .id(salaryAcctRecordPO.getId()) + .salarySobName(Optional.ofNullable(salarySobPO).map(SalarySobPO::getName).orElse(StringUtils.EMPTY)) + .taxAgentName(taxAgentName) + .salaryMonth(SalaryDateUtil.localDate2YearMonth(salaryAcctRecordPO.getSalaryMonth()).toString()) + .taxCycle(SalaryDateUtil.localDate2YearMonth(salaryAcctRecordPO.getTaxCycle()).toString()) + .status(Optional.ofNullable(salaryAcctRecordStatusEnum) + .map(o -> SalaryI18nUtil.getI18nLabel(o.getLabelId(), o.getDefaultLabel())) + .orElse(StringUtils.EMPTY)) + .acctTimes(salaryAcctRecordPO.getAcctTimes()) + .acctTimesViable(salaryAcctRecordPO.getAcctTimes() >= 1) + .backCalcStatus(salaryAcctRecordPO.getBackCalcStatus() == null ? 0 : salaryAcctRecordPO.getBackCalcStatus()) + .employeeSize(empSizeMap.getOrDefault(salaryAcctRecordPO.getId(), NumberUtils.LONG_ZERO)) + .accountantName(usernameMap.getOrDefault(salaryAcctRecordPO.getCreator(), StringUtils.EMPTY)) + .updateTime(SalaryDateUtil.getFormatLocalDateTime(salaryAcctRecordPO.getUpdateTime())) + .description(salaryAcctRecordPO.getDescription()) + .approvalStatus(salaryAcctRecordPO.getApprovalStatus()) + .operate(btnList) + .opts(salaryAcctRecordPO.getOpts()) + .build(); + }).collect(Collectors.toList()); + } + + /** + * 将薪资核算保存参数转换成薪资核算记录po + * + * @param saveParam + * @param salarySobCycle + * @param acctTimes + * @param employeeId + * @return + */ + public static SalaryAcctRecordPO convert2PO(SalaryAcctRecordSaveParam saveParam, + SalarySobCycleDTO salarySobCycle, + int acctTimes, Long employeeId) { + Date now = new Date(); + return new SalaryAcctRecordPO() + .setSalaryMonth(SalaryDateUtil.localDateToDate(saveParam.getSalaryMonth().atDay(1))) + .setTaxCycle(SalaryDateUtil.localDateToDate(salarySobCycle.getTaxCycle().atDay(1))) + .setSalarySobId(saveParam.getSalarySobId()) + .setStatus(SalaryAcctRecordStatusEnum.NOT_ARCHIVED.getValue()) + .setAcctTimes(acctTimes + 1) + .setBackCalcStatus(0) + .setDescription(saveParam.getDescription()) + .setDeleteType(NumberUtils.INTEGER_ZERO) + .setCreator(employeeId) + .setCreateTime(now) + .setUpdateTime(now) + .setTenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY); + } + + /** + * 重新计算薪资核算记录的核算次数 + * + * @param deletedSalaryAcctRecordPOS 已经删除的薪资核算记录 + * @param toUpdateAcctTimesRecordPOS 待更新核算次数的薪资核算记录 + * @return + */ + public static List updateAcctTimes(List deletedSalaryAcctRecordPOS, + List toUpdateAcctTimesRecordPOS) { + if (CollectionUtils.isEmpty(toUpdateAcctTimesRecordPOS)) { + return Collections.emptyList(); + } + Date now = new Date(); + List resultList = Lists.newArrayListWithExpectedSize(toUpdateAcctTimesRecordPOS.size()); + // 已经删除的薪资核算记录id + Set deletedSalaryAcctRecordIds = SalaryEntityUtil.properties(deletedSalaryAcctRecordPOS, SalaryAcctRecordPO::getId); + // 已经删除的薪资核算记录组成的key集合(薪资账套id+薪资所属月) + Set deletedKeySet = SalaryEntityUtil.properties(deletedSalaryAcctRecordPOS, salaryAcctRecordPO -> + salaryAcctRecordPO.getSalarySobId() + SalaryDateUtil.getFormatYearMonth(salaryAcctRecordPO.getSalaryMonth())); + // 按照(薪资账套id+薪资所属月)作为key聚合而成的待更新核算次数的薪资核算记录map + Map> toUpdateAcctTimesRecordPOMap = SalaryEntityUtil.group2Map(toUpdateAcctTimesRecordPOS, salaryAcctRecordPO -> + salaryAcctRecordPO.getSalarySobId() + SalaryDateUtil.getFormatYearMonth(salaryAcctRecordPO.getSalaryMonth())); + for (String key : deletedKeySet) { + List salaryAcctRecordPOS = toUpdateAcctTimesRecordPOMap.getOrDefault(key, Collections.emptyList()) + .stream() + .filter(salaryAcctRecordPO -> !deletedSalaryAcctRecordIds.contains(salaryAcctRecordPO.getId())) + .sorted(Comparator.comparingLong(salaryAcctRecordPO -> SalaryDateUtil.localDateTime2EpochMilli(salaryAcctRecordPO.getCreateTime()))) + .collect(Collectors.toList()); + int acctTimes = 1; + for (SalaryAcctRecordPO salaryAcctRecordPO : salaryAcctRecordPOS) { + salaryAcctRecordPO.setAcctTimes(acctTimes++); + salaryAcctRecordPO.setUpdateTime(now); + resultList.add(salaryAcctRecordPO); + } + } + return resultList; + } +} diff --git a/src/com/engine/salary/entity/salaryacct/bo/SalaryAcctResultBO.java b/src/com/engine/salary/entity/salaryacct/bo/SalaryAcctResultBO.java new file mode 100644 index 000000000..b906a6a37 --- /dev/null +++ b/src/com/engine/salary/entity/salaryacct/bo/SalaryAcctResultBO.java @@ -0,0 +1,904 @@ +package com.engine.salary.entity.salaryacct.bo; + +import cn.hutool.core.util.NumberUtil; +import cn.hutool.core.util.ObjectUtil; +import com.engine.salary.annotation.SalaryFormulaVar; +import com.engine.salary.component.WeaTableColumnGroup; +import com.engine.salary.constant.SalaryDefaultTenantConstant; +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.salaryacct.dto.ConsolidatedTaxDetailDTO; +import com.engine.salary.entity.salaryacct.dto.SalaryAcctEmployeeInfoDTO; +import com.engine.salary.entity.salaryacct.dto.SalaryAcctResultDetailDTO; +import com.engine.salary.entity.salaryacct.dto.SalaryAcctResultListColumnDTO; +import com.engine.salary.entity.salaryacct.param.SalaryAcctResultSaveParam; +import com.engine.salary.entity.salaryacct.po.*; +import com.engine.salary.entity.salaryformula.dto.SalaryFormulaEmployeeDTO; +import com.engine.salary.entity.salaryitem.po.SalaryItemPO; +import com.engine.salary.entity.salarysob.dto.SalarySobEmpFieldDTO; +import com.engine.salary.entity.salarysob.dto.SalarySobItemAggregateDTO; +import com.engine.salary.entity.salarysob.dto.SalarySobItemDTO; +import com.engine.salary.entity.salarysob.dto.SalarySobItemGroupDTO; +import com.engine.salary.entity.salarysob.po.*; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import com.engine.salary.enums.AccountTypeEnum; +import com.engine.salary.enums.SalaryValueTypeEnum; +import com.engine.salary.enums.UserStatusEnum; +import com.engine.salary.enums.salaryaccounting.LockStatusEnum; +import com.engine.salary.enums.salaryitem.SalaryDataTypeEnum; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.page.SalaryPageUtil; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.math.NumberUtils; +import org.springframework.beans.BeanUtils; +import weaver.general.Util; + +import java.lang.reflect.Field; +import java.math.BigDecimal; +import java.util.*; +import java.util.stream.Collectors; + +/** + * 薪资核算结果 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SalaryAcctResultBO { + + /** + * 数据类型的后缀标识 + * 为了展示千分位,薪资核算结果列表、线上线下对比结果列表需要返回给前端列表字段的数据类型,字段索引+后缀标识 + */ + private static final String DATA_TYPE_SUFFIX = "_type"; + +// /** +// * 构建薪资核算结果列表的表头(线下对比) +// * +// * @param salarySobItemAggregateDTO +// * @return +// */ +// public static List buildTableColumns4ComparisonResult(SalarySobItemAggregateDTO salarySobItemAggregateDTO, Set excludeSalaryItemIds) { +// List columns = Lists.newArrayList(); +// // 员工信息字段 +// for (SalarySobEmpFieldDTO salarySobEmpFieldDTO : salarySobItemAggregateDTO.getEmpFields()) { +// columns.add(new WeaTableColumn("150", salarySobEmpFieldDTO.getFieldName(), salarySobEmpFieldDTO.getFieldId())); +// } +// // 薪资项目分组下的薪资项目 +// for (SalarySobItemGroupDTO salarySobItemGroupDTO : salarySobItemAggregateDTO.getItemGroups()) { +// if (CollectionUtils.isEmpty(salarySobItemGroupDTO.getItems())) { +// continue; +// } +// for (SalarySobItemDTO salarySobItemDTO : salarySobItemGroupDTO.getItems()) { +// if (excludeSalaryItemIds.contains(salarySobItemDTO.getSalaryItemId())) { +// continue; +// } +// columns.add(new WeaTableColumn("150", salarySobItemDTO.getName(), "" + salarySobItemDTO.getSalaryItemId())); +// } +// } +// // 没有分类的薪资项目 +// for (SalarySobItemDTO salarySobItemDTO : salarySobItemAggregateDTO.getItems()) { +// if (excludeSalaryItemIds.contains(salarySobItemDTO.getSalaryItemId())) { +// continue; +// } +// columns.add(new WeaTableColumn("150", salarySobItemDTO.getName(), "" + salarySobItemDTO.getSalaryItemId())); +// } +// return columns; +// } + + + /** + * 构建薪资核算结果列表的表头(线下对比) + * + * @param salarySobItemAggregateDTO + * @return + */ + public static List buildTableColumns4ComparisonResult(SalarySobItemAggregateDTO salarySobItemAggregateDTO, Set excludeSalaryItemIds) { + List columns = Lists.newArrayList(); + // 员工信息字段 + for (SalarySobEmpFieldDTO salarySobEmpFieldDTO : salarySobItemAggregateDTO.getEmpFields()) { + columns.add(new WeaTableColumnGroup("150", salarySobEmpFieldDTO.getFieldName(), salarySobEmpFieldDTO.getFieldId(), salarySobEmpFieldDTO.getFieldId())); + } + // 薪资项目分组下的薪资项目 + for (SalarySobItemGroupDTO salarySobItemGroupDTO : salarySobItemAggregateDTO.getItemGroups()) { + if (CollectionUtils.isEmpty(salarySobItemGroupDTO.getItems())) { + continue; + } + List childrenColumns = Lists.newArrayList(); + for (SalarySobItemDTO salarySobItemDTO : salarySobItemGroupDTO.getItems()) { + if (excludeSalaryItemIds.contains(salarySobItemDTO.getSalaryItemId())) { + continue; + } + childrenColumns.add(new WeaTableColumnGroup("150", salarySobItemDTO.getName(), "" + salarySobItemDTO.getSalaryItemId(), "" + salarySobItemDTO.getSalaryItemId())); + } + WeaTableColumnGroup weaTableColumnWapper = new WeaTableColumnGroup("150", salarySobItemGroupDTO.getName(), String.valueOf(salarySobItemGroupDTO.getId()), childrenColumns); + columns.add(weaTableColumnWapper); + } + // 没有分类的薪资项目 + for (SalarySobItemDTO salarySobItemDTO : salarySobItemAggregateDTO.getItems()) { + if (excludeSalaryItemIds.contains(salarySobItemDTO.getSalaryItemId())) { + continue; + } + columns.add(new WeaTableColumnGroup("150", salarySobItemDTO.getName(), "" + salarySobItemDTO.getSalaryItemId(), "" + salarySobItemDTO.getSalaryItemId())); + } + return columns; + } + + /** + * 构建薪资核算结果列表的表头(线下对比) + * + * @param salarySobItemAggregateDTO + * @return + */ + public static List buildTableColumns4ComparisonResultByGroup(SalarySobItemAggregateDTO salarySobItemAggregateDTO, Set excludeSalaryItemIds) { + List columns = Lists.newArrayList(); + // 员工信息字段 + for (SalarySobEmpFieldDTO salarySobEmpFieldDTO : salarySobItemAggregateDTO.getEmpFields()) { + columns.add(new WeaTableColumnGroup("150", salarySobEmpFieldDTO.getFieldName(), salarySobEmpFieldDTO.getFieldId(), salarySobEmpFieldDTO.getFieldId())); + } + // 薪资项目分组下的薪资项目 + for (SalarySobItemGroupDTO salarySobItemGroupDTO : salarySobItemAggregateDTO.getItemGroups()) { + if (CollectionUtils.isEmpty(salarySobItemGroupDTO.getItems())) { + continue; + } + List childrenColumns = Lists.newArrayList(); + for (SalarySobItemDTO salarySobItemDTO : salarySobItemGroupDTO.getItems()) { + if (excludeSalaryItemIds.contains(salarySobItemDTO.getSalaryItemId())) { + continue; + } + childrenColumns.add(new WeaTableColumnGroup("150", salarySobItemDTO.getName(), "" + salarySobItemDTO.getSalaryItemId(), "" + salarySobItemDTO.getSalaryItemId())); + } + WeaTableColumnGroup weaTableColumnWapper = new WeaTableColumnGroup("150", salarySobItemGroupDTO.getName(), String.valueOf(salarySobItemGroupDTO.getId()), childrenColumns); + columns.add(weaTableColumnWapper); + } + // 没有分类的薪资项目 + for (SalarySobItemDTO salarySobItemDTO : salarySobItemAggregateDTO.getItems()) { + if (excludeSalaryItemIds.contains(salarySobItemDTO.getSalaryItemId())) { + continue; + } + columns.add(new WeaTableColumnGroup("150", salarySobItemDTO.getName(), "" + salarySobItemDTO.getSalaryItemId(), "" + salarySobItemDTO.getSalaryItemId())); + } + return columns; + } + + /** + * 构建薪资核算结果列表的表头 + * + * @param salarySobItemAggregateDTO + * @return + */ + public static List buildTableColumns(SalarySobItemAggregateDTO salarySobItemAggregateDTO, List lockSalaryItemIds) { + List columns = Lists.newArrayList(); + // 员工信息字段 + for (SalarySobEmpFieldDTO salarySobEmpFieldDTO : salarySobItemAggregateDTO.getEmpFields()) { + columns.add(new WeaTableColumnGroup(SalaryPageUtil.selfAdaption(salarySobEmpFieldDTO.getFieldName(), 0), salarySobEmpFieldDTO.getFieldName(), salarySobEmpFieldDTO.getFieldId())); + } + // 薪资项目分组下的薪资项目 + for (SalarySobItemGroupDTO salarySobItemGroupDTO : salarySobItemAggregateDTO.getItemGroups()) { + if (CollectionUtils.isEmpty(salarySobItemGroupDTO.getItems())) { + continue; + } + List childrenColumns = Lists.newArrayList(); + for (SalarySobItemDTO salarySobItemDTO : salarySobItemGroupDTO.getItems()) { + if (lockSalaryItemIds.contains(salarySobItemDTO.getSalaryItemId())) { + childrenColumns.add(new WeaTableColumnGroup(SalaryPageUtil.selfAdaption(salarySobItemDTO.getName(), salarySobItemDTO.getWidth()), salarySobItemDTO.getName(), "" + salarySobItemDTO.getSalaryItemId(), LockStatusEnum.LOCK.getDefaultLabel(), salarySobItemDTO.getPattern(), salarySobItemDTO.getDataType())); + } else { + childrenColumns.add(new WeaTableColumnGroup(SalaryPageUtil.selfAdaption(salarySobItemDTO.getName(), salarySobItemDTO.getWidth()), salarySobItemDTO.getName(), "" + salarySobItemDTO.getSalaryItemId(), LockStatusEnum.UNLOCK.getDefaultLabel(), salarySobItemDTO.getPattern(), salarySobItemDTO.getDataType())); + } + } + WeaTableColumnGroup weaTableColumnWapper = new WeaTableColumnGroup(SalaryPageUtil.selfAdaption(salarySobItemGroupDTO.getName(), 0), salarySobItemGroupDTO.getName(), String.valueOf(salarySobItemGroupDTO.getId()), childrenColumns); + columns.add(weaTableColumnWapper); + } + // 没有分类的薪资项目 + for (SalarySobItemDTO salarySobItemDTO : salarySobItemAggregateDTO.getItems()) { + if (lockSalaryItemIds.contains(salarySobItemDTO.getSalaryItemId())) { + columns.add(new WeaTableColumnGroup(SalaryPageUtil.selfAdaption(salarySobItemDTO.getName(), salarySobItemDTO.getWidth()), salarySobItemDTO.getName(), "" + salarySobItemDTO.getSalaryItemId(), LockStatusEnum.LOCK.getDefaultLabel(), salarySobItemDTO.getPattern(), salarySobItemDTO.getDataType())); + } else { + columns.add(new WeaTableColumnGroup(SalaryPageUtil.selfAdaption(salarySobItemDTO.getName(), salarySobItemDTO.getWidth()), salarySobItemDTO.getName(), "" + salarySobItemDTO.getSalaryItemId(), LockStatusEnum.UNLOCK.getDefaultLabel(), salarySobItemDTO.getPattern(), salarySobItemDTO.getDataType())); + } + + } + // 回算的薪资项目 + for (SalarySobItemDTO salarySobItemDTO : salarySobItemAggregateDTO.getBackCalcItems()) { + if (lockSalaryItemIds.contains(salarySobItemDTO.getSalaryItemId())) { + columns.add(new WeaTableColumnGroup(SalaryPageUtil.selfAdaption(salarySobItemDTO.getName(), 0), salarySobItemDTO.getName(), "" + salarySobItemDTO.getSalaryItemId(), LockStatusEnum.LOCK.getDefaultLabel(), salarySobItemDTO.getPattern(), salarySobItemDTO.getDataType())); + } else { + columns.add(new WeaTableColumnGroup(SalaryPageUtil.selfAdaption(salarySobItemDTO.getName(), 0), salarySobItemDTO.getName(), "" + salarySobItemDTO.getSalaryItemId(), LockStatusEnum.UNLOCK.getDefaultLabel(), salarySobItemDTO.getPattern(), salarySobItemDTO.getDataType())); + } + + } + return columns; + } + + /** + * 构建核算结果表头-供报表使用 + * + * @param salarySobItemAggregateDTO + * @return + */ + public static Map buildColumns(SalarySobItemAggregateDTO salarySobItemAggregateDTO) { + Map map = new HashMap<>(); + // 员工信息字段 + for (SalarySobEmpFieldDTO salarySobEmpFieldDTO : salarySobItemAggregateDTO.getEmpFields()) { + map.put(salarySobEmpFieldDTO.getFieldId(), salarySobEmpFieldDTO.getFieldName()); + } + // 薪资项目分组下的薪资项目 + // 薪资项目分组下的薪资项目 + for (SalarySobItemGroupDTO salarySobItemGroupDTO : salarySobItemAggregateDTO.getItemGroups()) { + if (CollectionUtils.isEmpty(salarySobItemGroupDTO.getItems())) { + continue; + } + for (SalarySobItemDTO salarySobItemDTO : salarySobItemGroupDTO.getItems()) { + map.put(salarySobItemDTO.getSalaryItemId() + "", salarySobItemDTO.getName()); + } + + } + // 没有分类的薪资项目 + for (SalarySobItemDTO salarySobItemDTO : salarySobItemAggregateDTO.getItems()) { + map.put(salarySobItemDTO.getSalaryItemId() + "", salarySobItemDTO.getName()); + } + return map; + } + + /** + * 转船成薪资核算结果列表的表格数据 + * + * @param salaryItems + * @param salarySobEmpFields + * @param simpleEmployees + * @param salaryAcctEmployees + * @param salaryAccountingResults + * @param taxAgents + * @param consolidatedTaxSalaryAcctEmpIds + * @param customBackCalcParameters + * @param dynamicEmpInfo + * @return + */ + public static List> buildTableData(List salaryItems, + List salarySobEmpFields, + List simpleEmployees, + List salaryAcctEmployees, + List salaryAccountingResults, + List taxAgents, + Set consolidatedTaxSalaryAcctEmpIds, + Map customParameters, + Map customBackCalcParameters, + boolean dynamicEmpInfo) { + if (CollectionUtils.isEmpty(salaryAcctEmployees)) { + return Collections.emptyList(); + } + SalaryI18nUtil.i18nList(salaryAcctEmployees); + Map employeeMap = SalaryEntityUtil.convert2Map(simpleEmployees, DataCollectionEmployee::getEmployeeId); + Map taxAgentNameMap = SalaryEntityUtil.convert2Map(taxAgents, TaxAgentPO::getId, TaxAgentPO::getName); + Map> taxAcctEmpsMap = SalaryEntityUtil.group2Map(salaryAcctEmployees, SalaryAcctEmployeePO::getTaxAgentId); + Map> taxAcctResultMap = SalaryEntityUtil.group2Map(salaryAccountingResults, SalaryAcctResultPO::getTaxAgentId); + + List> result = new ArrayList<>(); + for (Long taxAgentId : taxAcctEmpsMap.keySet()) { + Map> acctResultMap = SalaryEntityUtil.group2Map(taxAcctResultMap.get(taxAgentId), SalaryAcctResultPO::getEmployeeId); + List> collect = taxAcctEmpsMap.get(taxAgentId).stream().map(e -> { + Map resultValueMap = SalaryEntityUtil.convert2Map(acctResultMap.getOrDefault(e.getEmployeeId(), Collections.emptyList()), + SalaryAcctResultPO::getSalaryItemId, SalaryAcctResultPO::getResultValue); + // 薪资项目的值 + Map map = SalaryEntityUtil.convert2Map(salaryItems, o -> "" + o.getId(), o -> resultValueMap.getOrDefault(o.getId(), StringUtils.EMPTY)); + // 薪资项目的字段类型(前端依据这个判断是否需要展示千分位) + Map dataTypeMap = SalaryEntityUtil.convert2Map(salaryItems, salaryItemPO -> salaryItemPO.getId() + DATA_TYPE_SUFFIX, SalaryItemPO::getDataType); + map.putAll(dataTypeMap); + // 人员信息字段的值 + Map fieldValueMap = SalaryAcctFormulaBO.convert2FormulaEmployee(employeeMap.get(e.getEmployeeId()), e, true); + for (SalarySobEmpFieldPO salarySobEmpField : salarySobEmpFields) { + // 员工信息字段的字段类型 + if (dynamicEmpInfo) { + map.put(salarySobEmpField.getFieldCode(), fieldValueMap.get(salarySobEmpField.getFieldCode())); + } else { + if ("departmentName".equals(salarySobEmpField.getFieldCode())) { + map.put("departmentName", e.getDepartmentName()); + } else if ("departmentId".equals(salarySobEmpField.getFieldCode())) { + map.put("departmentId", e.getDepartmentId()); + } else if ("subcompanyName".equals(salarySobEmpField.getFieldCode())) { + map.put("subcompanyName", e.getSubcompanyName()); + } else if ("subcompanyId".equals(salarySobEmpField.getFieldCode())) { + map.put("subcompanyId", e.getSubcompanyId()); + } else if ("jobcall".equals(salarySobEmpField.getFieldCode())) { + map.put("jobcall", e.getJobcall()); + } else if ("jobcallId".equals(salarySobEmpField.getFieldCode())) { + map.put("jobcallId", e.getJobcallId()); + } else if ("jobtitleName".equals(salarySobEmpField.getFieldCode())) { + map.put("jobtitleName", e.getJobtitleName()); + } else if ("jobtitleId".equals(salarySobEmpField.getFieldCode())) { + map.put("jobtitleId", e.getJobtitleId()); + } else if ("status".equals(salarySobEmpField.getFieldCode())) { + map.put("status", e.getStatus()); + } else if ("statusName".equals(salarySobEmpField.getFieldCode())) { + map.put("statusName", UserStatusEnum.getDefaultLabelByValue(new Integer(Util.null2s(e.getStatus(), "1")))); + } else if ("accountType".equals(salarySobEmpField.getFieldCode())) { + map.put("accountType", e.getAccountType()); + } else if ("accountTypeName".equals(salarySobEmpField.getFieldCode())) { + map.put("accountTypeName", AccountTypeEnum.getDefaultLabelByValue(e.getAccountType())); + } else { + map.put(salarySobEmpField.getFieldCode(), fieldValueMap.get(salarySobEmpField.getFieldCode())); + } + } + map.put(salarySobEmpField.getFieldCode() + DATA_TYPE_SUFFIX, SalaryDataTypeEnum.STRING.getValue()); + } + // 主键id + map.put("id", e.getId()); + //锁定数据 + map.put("lockItems", e.getLockItems() != null ? e.getLockItems().stream().filter(Objects::nonNull).map(Object::toString).collect(Collectors.toList()) : new ArrayList<>()); + //人员id + map.put("employeeId", e.getEmployeeId()); + // 个税扣缴义务人 + String taxAgentName = taxAgentNameMap.getOrDefault(e.getTaxAgentId(), StringUtils.EMPTY); + map.put("taxAgentName", taxAgentName); + // 是否属于"合并计税"的标记 + map.put("consolidatedTaxation", StringUtils.isNotEmpty(taxAgentName) && consolidatedTaxSalaryAcctEmpIds.contains(e.getId())); + // 个税扣缴义务人的字段类型 + map.put("taxAgentName" + DATA_TYPE_SUFFIX, SalaryDataTypeEnum.STRING.getValue()); + // 公式详情 + customParameters.putAll(customBackCalcParameters); + map.put("customParameters", customParameters); + return map; + }).collect(Collectors.toList()); + result.addAll(collect); + } + return result; + } + + /** + * 转转成薪资核算线下对比结果 + * + * @param salaryItems + * @param salarySobEmpFields + * @param simpleEmployees + * @param salaryAcctEmployees + * @param salaryAcctResultPOS + * @param excelAcctResultPOS + * @param taxAgents + * @param consolidatedTaxSalaryAcctEmpIds + * @return + */ + public static List> buildComparisonTableData(List salaryItems, + List salarySobEmpFields, + List simpleEmployees, + List salaryAcctEmployees, + List salaryAcctResultPOS, + List excelAcctResultPOS, + List taxAgents, + Map customParameters, + Set consolidatedTaxSalaryAcctEmpIds, + Set includeSalaryItemIds, + boolean dynamicEmpInfo) { + if (CollectionUtils.isEmpty(simpleEmployees)) { + return Collections.emptyList(); + } + Map> excelResultMap = SalaryEntityUtil.group2Map(excelAcctResultPOS, ExcelAcctResultPO::getSalaryAcctEmpId); + Map> acctResultMap = SalaryEntityUtil.group2Map(salaryAcctResultPOS, SalaryAcctResultPO::getSalaryAcctEmpId); + Map taxAgentNameMap = SalaryEntityUtil.convert2Map(taxAgents, TaxAgentPO::getId, TaxAgentPO::getName); + Map employeeMap = SalaryEntityUtil.convert2Map(simpleEmployees, DataCollectionEmployee::getEmployeeId); + List> resultList = Lists.newArrayListWithExpectedSize(salaryAcctEmployees.size()); + for (SalaryAcctEmployeePO salaryAcctEmployee : salaryAcctEmployees) { + // 线下值和系统值之间是否存在差异 + boolean different = false; + Map map = Maps.newHashMap(); + // 员工信息字段的值 + Map fieldValueMap = SalaryAcctFormulaBO.convert2FormulaEmployee(employeeMap.get(salaryAcctEmployee.getEmployeeId()), salaryAcctEmployee, false); + for (SalarySobEmpFieldPO salarySobEmpField : salarySobEmpFields) { + // 员工信息字段的字段类型 + if (dynamicEmpInfo) { + map.put(salarySobEmpField.getFieldCode(), fieldValueMap.get(salarySobEmpField.getFieldCode())); + } else { + if ("departmentName".equals(salarySobEmpField.getFieldCode())) { + map.put("departmentName", salaryAcctEmployee.getDepartmentName()); + } else if ("departmentId".equals(salarySobEmpField.getFieldCode())) { + map.put("departmentId", salaryAcctEmployee.getDepartmentId()); + } else if ("subcompanyName".equals(salarySobEmpField.getFieldCode())) { + map.put("subcompanyName", salaryAcctEmployee.getSubcompanyName()); + } else if ("jobcall".equals(salarySobEmpField.getFieldCode())) { + map.put("jobcall", salaryAcctEmployee.getJobcall()); + } else if ("jobcallId".equals(salarySobEmpField.getFieldCode())) { + map.put("jobcallId", salaryAcctEmployee.getJobcallId()); + } else if ("jobtitleName".equals(salarySobEmpField.getFieldCode())) { + map.put("jobtitleName", salaryAcctEmployee.getJobtitleName()); + } else if ("jobtitleId".equals(salarySobEmpField.getFieldCode())) { + map.put("jobtitleId", salaryAcctEmployee.getJobtitleId()); + } else if ("status".equals(salarySobEmpField.getFieldCode())) { + map.put("status", salaryAcctEmployee.getStatus()); + } else if ("statusName".equals(salarySobEmpField.getFieldCode())) { + map.put("statusName", UserStatusEnum.getDefaultLabelByValue(new Integer(Util.null2s(salaryAcctEmployee.getStatus(), "1")))); + } else if ("accountType".equals(salarySobEmpField.getFieldCode())) { + map.put("accountType", salaryAcctEmployee.getAccountType()); + } else if ("accountTypeName".equals(salarySobEmpField.getFieldCode())) { + map.put("accountTypeName", AccountTypeEnum.getDefaultLabelByValue(salaryAcctEmployee.getAccountType())); + } else { + map.put(salarySobEmpField.getFieldCode(), fieldValueMap.get(salarySobEmpField.getFieldCode())); + } + } + map.put(salarySobEmpField.getFieldCode() + DATA_TYPE_SUFFIX, SalaryDataTypeEnum.STRING.getValue()); + } + // 系统值 + Map acctResultValueMap = SalaryEntityUtil.convert2Map(acctResultMap.getOrDefault(salaryAcctEmployee.getId(), Collections.emptyList()), + SalaryAcctResultPO::getSalaryItemId, SalaryAcctResultPO::getResultValue); + // 线下值 + Map excelResultValueMap = SalaryEntityUtil.convert2Map(excelResultMap.getOrDefault(salaryAcctEmployee.getId(), Collections.emptyList()), + ExcelAcctResultPO::getSalaryItemId, ExcelAcctResultPO::getResultValue); + // 薪资项目字段的值 + for (SalaryItemPO salaryItem : salaryItems) { + Map temp = Maps.newHashMap(); + // 系统值 + String acctResultValue = acctResultValueMap.get(salaryItem.getId()); + // 线下值 + String excelResultValue = excelResultValueMap.get(salaryItem.getId()); + temp.put("acctResultValue", acctResultValue); + temp.put("excelResultValue", excelResultValue); + map.put(String.valueOf(salaryItem.getId()), temp); + // 薪资项目字段的字段类型 + map.put(salaryItem.getId() + DATA_TYPE_SUFFIX, salaryItem.getDataType()); + SalaryDataTypeEnum dataTypeEnum = SalaryDataTypeEnum.parseByValue(salaryItem.getDataType()); + if (dataTypeEnum == SalaryDataTypeEnum.NUMBER) { + if (NumberUtil.isNumber(acctResultValue) && NumberUtil.isNumber(excelResultValue)) { + if (new BigDecimal(acctResultValue).compareTo(new BigDecimal(excelResultValue)) != 0) { + different = true; + includeSalaryItemIds.add(salaryItem.getId()); + } + } else { + if (SalaryEntityUtil.empty2Zero(acctResultValue).compareTo(SalaryEntityUtil.empty2Zero(excelResultValue)) != 0) { + different = true; + includeSalaryItemIds.add(salaryItem.getId()); + } + } + } else { + if (!StringUtils.equals(acctResultValue, excelResultValue)) { + different = true; + includeSalaryItemIds.add(salaryItem.getId()); + } + } + } + // 主键id + map.put("id", salaryAcctEmployee.getId()); + // 个税扣缴义务人 + String taxAgentName = taxAgentNameMap.getOrDefault(salaryAcctEmployee.getTaxAgentId(), StringUtils.EMPTY); + map.put("taxAgentName", taxAgentName); + // 个税扣缴义务人的字段类型 + map.put("taxAgentName" + DATA_TYPE_SUFFIX, SalaryDataTypeEnum.STRING.getValue()); + // 是否属于"合并计税"的标记 + map.put("consolidatedTaxation", StringUtils.isNotEmpty(taxAgentName) && consolidatedTaxSalaryAcctEmpIds.contains(salaryAcctEmployee.getId())); + // 薪资项目的公式详情(前端需要展示) + map.put("customParameters", customParameters); + // 是否存在差异的标记 + map.put("different", different); + resultList.add(map); + } + return resultList; + } + + /** + * 转换成薪资核算结果详情dto + * + * @param simpleEmployee + * @param taxAgentPO + * @param salaryAcctEmployee + * @param salarySobEmpFields + * @param salarySobItemPOS + * @param salaryItems + * @param salaryAcctResults + * @return + */ + public static SalaryAcctResultDetailDTO convert2DetailDTO(DataCollectionEmployee simpleEmployee, + TaxAgentPO taxAgentPO, + SalaryAcctEmployeePO salaryAcctEmployee, + List salarySobEmpFields, + List salarySobItemGroupPOS, + List salarySobItemPOS, + List salaryItems, + List salaryAcctResults, + List salarySobBackItemPOS, + List salaryBackItemPOS, + Map salaryBackItemFormula, + Map formulaContentMap, + List lockItems) { + + // 员工信息字段 + Map employeeFieldValueMap = SalaryAcctFormulaBO.convert2FormulaEmployee(simpleEmployee, salaryAcctEmployee, false); + // 个税扣缴义务人 + employeeFieldValueMap.put("taxAgentName", Optional.ofNullable(taxAgentPO).map(TaxAgentPO::getName).orElse(StringUtils.EMPTY)); + Map employeeFieldNameMap = buildEmployeeFieldName(); + List canEditKeys = Arrays.asList("subcompany", "department", "jobtitle", "jobcall"); + List employeeInfos = salarySobEmpFields.stream() + .map(e -> { + String fieldCode = e.getFieldCode(); + String fieldType = employeeFieldNameMap.getOrDefault(fieldCode + "_type", StringUtils.EMPTY); + SalaryAcctEmployeeInfoDTO dto = SalaryAcctEmployeeInfoDTO.builder() + .fieldCode(fieldCode) + .fieldName(employeeFieldNameMap.getOrDefault(fieldCode, StringUtils.EMPTY)) + .fieldValue(employeeFieldValueMap.getOrDefault(fieldCode, StringUtils.EMPTY)) + .fieldType(fieldType) + .canEdit(fieldType.contains("Browser") ? true : false) + .build(); + + String codeKey = fieldCode.replace("Id", "").replace("Name", ""); + if (canEditKeys.contains(codeKey)) { + // 前端用于回写浏览框 + Map fieldValueMap = new HashMap<>(); + fieldValueMap.put("id", employeeFieldValueMap.getOrDefault(codeKey + "Id", StringUtils.EMPTY)); + fieldValueMap.put("name", employeeFieldValueMap.getOrDefault(codeKey + "Name", StringUtils.EMPTY)); + if (codeKey.equals("jobcall")) { + fieldValueMap.put("name", employeeFieldValueMap.getOrDefault("jobcall", StringUtils.EMPTY)); + } + dto.setFieldValue(fieldValueMap); + } + return dto; + }) + .collect(Collectors.toList()); + + List needRemoveFieldNames = new ArrayList(); + // 过滤出是浏览框类型的且人员信息中同时存在名称和id的字段 + employeeInfos.stream() + .filter(e -> e.getFieldType().contains("Browser")) + .map(e -> SalaryAcctEmployeeInfoDTO.builder().fieldName(e.getFieldName().replace("ID", "")).build()) + .collect(Collectors.groupingBy(SalaryAcctEmployeeInfoDTO::getFieldName)) + .forEach((k, v) -> { + if (v.size() > 1) { + needRemoveFieldNames.add(k + "ID"); + } + }); + + // 移除字段 + employeeInfos = employeeInfos.stream().filter(info -> !needRemoveFieldNames.contains(info.getFieldName())).collect(Collectors.toList()); + // 薪资项目的值 + Map resultValueMap = SalaryEntityUtil.convert2Map(salaryAcctResults, SalaryAcctResultPO::getSalaryItemId, SalaryAcctResultPO::getResultValue); + Map salaryItemMap = SalaryEntityUtil.convert2Map(salaryItems, SalaryItemPO::getId); + Map salaryBackItemMap = SalaryEntityUtil.convert2Map(salaryBackItemPOS, SalaryItemPO::getId); + Map> salarySobItemPOMap = SalaryEntityUtil.group2Map(salarySobItemPOS, SalarySobItemPO::getSalarySobItemGroupId); + + // 对分组进行排序 + salarySobItemGroupPOS = sortGroup(salarySobItemGroupPOS); + // 对分组内薪资项目排序 + sortItem(salarySobItemPOMap); + // 根据账套分组封装薪资项目的值 + List itemsByGroup = new ArrayList<>(); + for (SalarySobItemGroupPO groupPO : salarySobItemGroupPOS) { + List groupItems = salarySobItemPOMap.getOrDefault(groupPO.getId(), Collections.emptyList()); + if (CollectionUtils.isNotEmpty(groupItems)) { + List items = groupItems.stream() + .map(salarySobItemPO -> convert2SalaryAcctResultDetailItemDTO(salarySobItemPO, salaryItemMap.get(salarySobItemPO.getSalaryItemId()), resultValueMap, formulaContentMap, lockItems)) + .collect(Collectors.toList()); + itemsByGroup.add(SalaryAcctResultDetailDTO.SalaryAcctResultDetailItemByGroupDTO.builder() + .salarySobItemGroupId(groupPO.getId()) + .salarySobItemGroupName(groupPO.getName()) + .salaryItems(items) + .sortedIndex(groupPO.getSortedIndex()).build()); + } + } + // 未分类 + List noGroupItems = salarySobItemPOMap.getOrDefault(0L, Collections.emptyList()); + if (CollectionUtils.isNotEmpty(noGroupItems)) { + List items = noGroupItems.stream() + .map(salarySobItemPO -> convert2SalaryAcctResultDetailItemDTO(salarySobItemPO, salaryItemMap.get(salarySobItemPO.getSalaryItemId()), resultValueMap, formulaContentMap, lockItems)) + .collect(Collectors.toList()); + itemsByGroup.add(SalaryAcctResultDetailDTO.SalaryAcctResultDetailItemByGroupDTO.builder() + .salarySobItemGroupId(0L) + .salarySobItemGroupName("未分类") + .salaryItems(items) + .sortedIndex(itemsByGroup.size()).build()); + } + + +// // 公式项的值(不根据salaryItemPO的valueType判断是因为薪资项目的valueType属性改变后并不会同步更新薪资账套中的薪资项目的formulaId字段) +// List formulaItems = salarySobItemPOS.stream() +// .filter(salarySobItemPO -> salarySobItemPO.getFormulaId() > 0) +// .map(salarySobItemPO -> convert2SalaryAcctResultDetailItemDTO(salarySobItemPO, salaryItemMap.get(salarySobItemPO.getSalaryItemId()), resultValueMap)) +// .collect(Collectors.toList()); +// // 输入/导入项目的值 +// List inputItems = salarySobItemPOS.stream() +// .filter(salarySobItemPO -> salarySobItemPO.getFormulaId() <= 0) +// .map(salarySobItemPO -> convert2SalaryAcctResultDetailItemDTO(salarySobItemPO, salaryItemMap.get(salarySobItemPO.getSalaryItemId()), resultValueMap)) +// .collect(Collectors.toList()); +// // TODO 临时处理,后续删除,将已发补发加入输入、导入 +// formulaItems.addAll(salarySobBackItemPOS.stream() +// .map(salarySobBackItemPO -> backItemConvert2SalaryAcctResultDetailItemDTO(salarySobBackItemPO, salaryBackItemMap.get(salarySobBackItemPO.getSalaryItemId()), resultValueMap, salaryBackItemFormula)) +// .collect(Collectors.toList())); + // 已发/补发项目的值 + List issuedAndReissueItems = salarySobBackItemPOS.stream() + .map(salarySobBackItemPO -> backItemConvert2SalaryAcctResultDetailItemDTO(salarySobBackItemPO, salaryBackItemMap.get(salarySobBackItemPO.getSalaryItemId()), resultValueMap, salaryBackItemFormula)) + .collect(Collectors.toList()); + return SalaryAcctResultDetailDTO.builder() + .id(salaryAcctEmployee.getId()) + .employeeId(salaryAcctEmployee.getEmployeeId()) + .employeeInfos(employeeInfos) +// .formulaItems(formulaItems) +// .inputItems(inputItems) + .itemsByGroup(itemsByGroup) + .issuedAndReissueItems(issuedAndReissueItems) + .build(); + } + + public static List sortGroup(List salarySobItemGroupPOS) { + if (CollectionUtils.isEmpty(salarySobItemGroupPOS)) { + return Collections.emptyList(); + } + return salarySobItemGroupPOS.stream().sorted(Comparator.comparingInt(SalarySobItemGroupPO::getSortedIndex)).collect(Collectors.toList()); + } + + /** + * 薪资账套的薪资项目按照sortedIndex排序 + */ + public static void sortItem(Map> salarySobItemPOMap) { + for (Map.Entry> entry : salarySobItemPOMap.entrySet()) { + List items = entry.getValue(); + if (CollectionUtils.isNotEmpty(items)) { + List sortedValue = items.stream().sorted(Comparator.comparingInt(SalarySobItemPO::getSortedIndex)).collect(Collectors.toList()); + salarySobItemPOMap.put(entry.getKey(), sortedValue); + } + } + } + + /** + * 转换成薪资核算结果详情dto + * + * @param salarySobItemPO + * @param salaryItemPO + * @param resultValueMap + * @return + */ + private static SalaryAcctResultDetailDTO.SalaryAcctResultDetailItemDTO convert2SalaryAcctResultDetailItemDTO(SalarySobItemPO salarySobItemPO, + SalaryItemPO salaryItemPO, + Map resultValueMap, + Map formulaContentMap, + List lockItems) { + + SalaryValueTypeEnum salaryValueTypeEnum = SalaryValueTypeEnum.parseByValue(Optional.ofNullable(salarySobItemPO).map(SalarySobItemPO::getValueType).orElse(1)); + String itemFormulaContent; + if (Objects.equals(salaryValueTypeEnum.getValue(), SalaryValueTypeEnum.FORMULA.getValue())) { + itemFormulaContent = Optional.ofNullable(formulaContentMap.get(salarySobItemPO.getSalaryItemId().toString())).map(SalaryAcctResultListColumnDTO::getFormulaContent).orElse(""); + } else { + itemFormulaContent = salaryValueTypeEnum == null ? "" : salaryValueTypeEnum.getDefaultLabel(); + } + + // 薪资项目的数据类型 + return SalaryAcctResultDetailDTO.SalaryAcctResultDetailItemDTO.builder() + .salaryItemId(salarySobItemPO.getSalaryItemId()) + .salaryItemName(Optional.ofNullable(salaryItemPO).map(SalaryItemPO::getName).orElse(StringUtils.EMPTY)) + .resultValue(resultValueMap.getOrDefault(salarySobItemPO.getSalaryItemId(), StringUtils.EMPTY)) + .dataType(Optional.ofNullable(salaryItemPO).map(SalaryItemPO::getDataType).orElse(SalaryDataTypeEnum.NUMBER.getValue())) + .itemFormulaContent(itemFormulaContent) +// .canEdit(Objects.equals(Optional.ofNullable(salaryItemPO).map(SalaryItemPO::getUseInEmployeeSalary).orElse(0), 0)) + .canEdit(true) + .pattern(salarySobItemPO.getPattern()) + .lockStatus(lockItems.contains(salarySobItemPO.getSalaryItemId()) ? LockStatusEnum.LOCK.getDefaultLabel() : LockStatusEnum.UNLOCK.getDefaultLabel()) + .build(); + } + + /** + * 薪资回算项目转换成薪资核算结果详情dto + * + * @param salarySobBackItemPO + * @param salaryItemPO + * @param resultValueMap + * @return + */ + private static SalaryAcctResultDetailDTO.SalaryAcctResultDetailItemDTO backItemConvert2SalaryAcctResultDetailItemDTO(SalarySobBackItemPO salarySobBackItemPO, + SalaryItemPO salaryItemPO, + Map resultValueMap, + Map salaryBackItemFormula) { + // 薪资项目的数据类型 + return SalaryAcctResultDetailDTO.SalaryAcctResultDetailItemDTO.builder() + .salaryItemId(salarySobBackItemPO.getSalaryItemId()) + .salaryItemName(Optional.ofNullable(salaryItemPO).map(SalaryItemPO::getName).orElse(StringUtils.EMPTY)) + .resultValue(resultValueMap.getOrDefault(salarySobBackItemPO.getSalaryItemId(), StringUtils.EMPTY)) + .itemFormulaContent(salaryBackItemFormula.get(salarySobBackItemPO.getSalaryItemId())) + .dataType(Optional.ofNullable(salarySobBackItemPO).map(SalarySobBackItemPO::getDataType).orElse(SalaryDataTypeEnum.NUMBER.getValue())) + .canEdit(Objects.equals(Optional.ofNullable(salaryItemPO).map(SalaryItemPO::getUseInEmployeeSalary).orElse(0), 0)) + .build(); + } + + /** + * 薪资核算结果保存参数转换成薪资核算结果po + * + * @param saveParam 前端保存参数 + * @param salaryAcctEmployee 薪资核算人员po + * @param employeeId 当前登陆人员id + * @return + */ + public static List convert2PO(List salaryAcctResultPOSOld, + SalaryAcctResultSaveParam saveParam, + SalaryAcctEmployeePO salaryAcctEmployee, + Long employeeId) { + if (CollectionUtils.isEmpty(saveParam.getItems())) { + return Collections.emptyList(); + } + // 获取薪资项目回算前的值 + Map salaryAcctResultOldPOMap = salaryAcctResultPOSOld.stream() + .collect(Collectors.groupingBy(p -> p.getSalaryAcctEmpId() + "-" + p.getSalaryItemId(), + Collectors.collectingAndThen(Collectors.maxBy(Comparator.comparing(SalaryAcctResultPO::getId)), + s -> s.map(SalaryAcctResultPO::getOriginResultValue).orElse("")))); + Date now = new Date(); + return saveParam.getItems().stream() + .map(e -> SalaryAcctResultPO.builder() + .salarySobId(salaryAcctEmployee.getSalarySobId()) + .salaryItemId(e.getSalaryItemId()) + .salaryAcctRecordId(salaryAcctEmployee.getSalaryAcctRecordId()) + .salaryAcctEmpId(salaryAcctEmployee.getId()) + .employeeId(salaryAcctEmployee.getEmployeeId()) + .taxAgentId(salaryAcctEmployee.getTaxAgentId()) + .resultValue(StringUtils.trim(e.getResultValue())) + .originResultValue(salaryAcctResultOldPOMap.get(saveParam.getSalaryAcctEmpId() + "-" + e.getSalaryItemId())) + .creator(employeeId) + .createTime(now) + .updateTime(now) + .deleteType(NumberUtils.INTEGER_ZERO) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .build()) + .collect(Collectors.toList()); + } + + + public static List batchEditConvert2PO(Map salaryAcctResultOldPOMap, + List items, + SalaryAcctEmployeePO salaryAcctEmployee, + Long employeeId) { + if (CollectionUtils.isEmpty(items) || ObjectUtil.isEmpty(salaryAcctEmployee)) { + return Collections.emptyList(); + } + Date now = new Date(); + return items.stream() + .map(e -> SalaryAcctResultPO.builder() + .salarySobId(salaryAcctEmployee.getSalarySobId()) + .salaryItemId(e.getSalaryItemId()) + .salaryAcctRecordId(salaryAcctEmployee.getSalaryAcctRecordId()) + .salaryAcctEmpId(salaryAcctEmployee.getId()) + .employeeId(salaryAcctEmployee.getEmployeeId()) + .taxAgentId(salaryAcctEmployee.getTaxAgentId()) + .resultValue(StringUtils.trim(e.getResultValue())) + .originResultValue(salaryAcctResultOldPOMap.get(salaryAcctEmployee.getId() + "-" + e.getSalaryItemId())) + .creator(employeeId) + .createTime(now) + .updateTime(now) + .deleteType(NumberUtils.INTEGER_ZERO) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .build()) + .collect(Collectors.toList()); + } + + public static Map buildEmployeeFieldName() { + Field[] declaredFields = SalaryFormulaEmployeeDTO.class.getDeclaredFields(); + Map employeeFieldNameMap = Maps.newHashMapWithExpectedSize(declaredFields.length); + for (Field declaredField : declaredFields) { + if (!declaredField.isAnnotationPresent(SalaryFormulaVar.class)) { + continue; + } + SalaryFormulaVar annotation = declaredField.getAnnotation(SalaryFormulaVar.class); + employeeFieldNameMap.put(declaredField.getName(), SalaryI18nUtil.getI18nLabel(annotation.labelId(), annotation.defaultLabel())); + employeeFieldNameMap.put(declaredField.getName() + "_type", annotation.dataType()); + } + return employeeFieldNameMap; + } + + public static ConsolidatedTaxDetailDTO convert2ConsolidatedTaxDetailDTO(DataCollectionEmployee simpleEmployee, + TaxAgentPO taxAgent, + List salarySobEmpFields, + List salaryItems, + List salaryAcctEmployees, + List salarySobs, + List salaryAcctRecords, + List salaryAcctResults) { + return ConsolidatedTaxDetailDTO.builder() +// .employeeInfo(buildConsolidatedTaxationEmpInfo(simpleEmployee, taxAgent, salarySobEmpFields)) +// .salaryAcctResult(buildConsolidatedTaxationAcctResult(salaryItems, salaryAcctEmployees, salarySobs, salaryAcctRecords, salaryAcctResults)) + .build(); + } + + /** + * 合并计税详情-员工信息 + * + * @param simpleEmployee + * @param salarySobEmpFields + * @return + */ +// private static WeaForm buildConsolidatedTaxationEmpInfo(DataCollectionEmployee simpleEmployee, TaxAgent taxAgent, List salarySobEmpFields) { +// Map employeeFieldNameMap = buildEmployeeFieldName(); +// Map fieldValueMap = SalaryAcctFormulaBO.convert2FormulaEmployee(simpleEmployee); +// fieldValueMap.put("taxAgentName", taxAgent.getName()); +// Map data = Maps.newHashMap(); +// Map items = Maps.newHashMap(); +// List> layout = Lists.newArrayList(); +// List temp = Lists.newArrayList(); +// for (SalarySobEmpFieldPO field : salarySobEmpFields) { +// // 字段属性 +// WeaFormItem weaFormItem = new WeaFormItem(WeaFormItemType.INPUT); +// weaFormItem.setReadOnly(true); +// weaFormItem.setValue(fieldValueMap.getOrDefault(field.getFieldCode(), "")); +// items.put(field.getFieldCode(), weaFormItem); +// // 字段布局 +// if (temp.size() == 3) { +// layout.add(new ArrayList<>(temp)); +// temp = Lists.newArrayList(); +// } +// WeaFormLayout weaFormLayout = new WeaFormLayout(field.getFieldCode(), employeeFieldNameMap.getOrDefault(field.getFieldCode(), ""), new String[]{field.getFieldCode()}); +// temp.add(weaFormLayout); +// // 字段的值 +// data.put(field.getFieldCode(), weaFormItem.getValue()); +// } +// if (CollectionUtils.isNotEmpty(temp)) { +// layout.add(new ArrayList<>(temp)); +// } +// WeaForm weaForm = new WeaForm(); +// weaForm.setData(data); +// weaForm.setItems(items); +// weaForm.setLayout(layout); +// return weaForm; +// } + + + /** + * 合并计税详情-核算结果列表 + * + * @param salaryItems + * @param salaryAcctResults + * @return + */ +// private static WeaTable> buildConsolidatedTaxationAcctResult(List salaryItems, +// List salaryAcctEmployees, +// List salarySobs, +// List salaryAcctRecords, +// List salaryAcctResults) { +// // 薪资核算人员 +// Map salaryAcctEmployeeMap = SalaryEntityUtil.convert2Map(salaryAcctEmployees, SalaryAcctEmployeePO::getId); +// // 薪资账套 +// Map salarySobNameMap = SalaryEntityUtil.convert2Map(salarySobs, SalarySobPO::getId, SalarySobPO::getName); +// // 薪资核算记录 +// Map salaryAcctRecordMap = SalaryEntityUtil.convert2Map(salaryAcctRecords, SalaryAcctRecordPO::getId); +// // 薪资核算结果 +// Map> salaryAcctResultMap = SalaryEntityUtil.group2Map(salaryAcctResults, SalaryAcctResultPO::getSalaryAcctEmpId); +// List weaTableColumns = Lists.newArrayList(new WeaTableColumn("核算批次", "salarySobName")); +// weaTableColumns.addAll(salaryItems.stream() +// .map(e -> new WeaTableColumn(e.getName(), "" + e.getId(), false)) +// .collect(Collectors.toList())); +// WeaTable> weaTable = new WeaTable<>(); +// weaTable.setTableType(WeaTableTypeEnum.NONE); +// weaTable.setCurrent(0); +// weaTable.setPageSize(salaryAcctResultMap.size()); +// weaTable.setTotal(salaryAcctResultMap.size()); +// weaTable.setColumns(weaTableColumns); +// if (CollectionUtils.isEmpty(salaryAcctResults)) { +// return weaTable; +// } +// List> data = Lists.newArrayList(); +// salaryAcctResultMap.forEach((k, v) -> { +// // 薪资核算的结果 +// Map valueMap = SalaryEntityUtil.convert2Map(v, e -> "" + e.getSalaryItemId(), SalaryAcctResultPO::getResultValue); +// // 核算批次 +// SalaryAcctEmployeePO salaryAcctEmployeePO = salaryAcctEmployeeMap.get(k); +// SalaryAcctRecordPO salaryAcctRecordPO = salaryAcctRecordMap.get(salaryAcctEmployeePO.getSalaryAcctRecordId()); +// String salarySobName = salarySobNameMap.getOrDefault(salaryAcctRecordPO.getSalarySobId(), ""); +// valueMap.put("salarySobName", "第" + salaryAcctRecordPO.getAcctTimes() + "次(" + salarySobName + ")"); +// data.add(valueMap); +// }); +// weaTable.setData(data); +// weaTable.setDisplayData(data); +// return weaTable; +// } + + /** + * 薪资核算结果临时存储转成薪资核算结果po + * + * @param temps + * @return + */ + public static List convert2ResultPO(Collection temps) { + if (CollectionUtils.isEmpty(temps)) { + return Collections.emptyList(); + } + return temps.stream().map(e -> { + SalaryAcctResultPO salaryAcctResult = new SalaryAcctResultPO(); + BeanUtils.copyProperties(e, salaryAcctResult); + return salaryAcctResult; + }).collect(Collectors.toList()); + } + + +} diff --git a/src/com/engine/salary/entity/salaryacct/bo/SalaryAcctResultListContext.java b/src/com/engine/salary/entity/salaryacct/bo/SalaryAcctResultListContext.java new file mode 100644 index 000000000..a406eee1d --- /dev/null +++ b/src/com/engine/salary/entity/salaryacct/bo/SalaryAcctResultListContext.java @@ -0,0 +1,52 @@ +package com.engine.salary.entity.salaryacct.bo; + +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO; +import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO; +import com.engine.salary.entity.salarysob.dto.SalarySobItemAggregateDTO; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.util.*; + +/** + * 薪资核算人员 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Accessors(chain = true) +public class SalaryAcctResultListContext { + + private SalaryAcctRecordPO salaryAcctRecord; + + private SalarySobItemAggregateDTO salarySobItemAggregate; + + //存在合并计税的薪资核算人员(employeeId-taxAgentId)") + private Set sameTaxCycleKeySet; + + //薪资核算人员") + private List salaryAcctEmployees; + + private Integer total; + + private Map hrmStatusMap; + + private Map simpleEmployeeMap; + +// private Map extEmployeeMap; + + private Map taxAgentNameMap; + + public SalaryAcctResultListContext() { + this.sameTaxCycleKeySet = new HashSet<>(); + this.salaryAcctEmployees = new ArrayList<>(); + this.hrmStatusMap = new HashMap<>(); + this.simpleEmployeeMap = new HashMap<>(); +// this.extEmployeeMap = new HashMap<>(); + this.taxAgentNameMap = new HashMap<>(); + } +} diff --git a/src/com/engine/salary/entity/salaryacct/bo/SalaryAcctResultLogBO.java b/src/com/engine/salary/entity/salaryacct/bo/SalaryAcctResultLogBO.java new file mode 100644 index 000000000..f8270bb5b --- /dev/null +++ b/src/com/engine/salary/entity/salaryacct/bo/SalaryAcctResultLogBO.java @@ -0,0 +1,40 @@ +package com.engine.salary.entity.salaryacct.bo; + +import com.engine.salary.entity.salaryacct.po.SalaryAcctResultLogPO; +import com.engine.salary.entity.salaryacct.po.SalaryAcctResultPO; +import com.engine.salary.enums.salaryaccounting.SalaryAcctResultDataSourceEnum; +import com.engine.salary.util.db.IdGenerator; +import org.apache.commons.lang3.math.NumberUtils; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +/** + * @author Harryxzy + * @date 2023/05/12 16:54 + * @description + */ +public class SalaryAcctResultLogBO { + + public static List buildSalaryAcctResultLog(List salaryAcctResultList, Long uid, SalaryAcctResultDataSourceEnum datasource){ + Date now = new Date(); + List needInsertList = new ArrayList<>(); + salaryAcctResultList.stream().forEach(PO -> { + needInsertList.add(SalaryAcctResultLogPO.builder() + .id(IdGenerator.generate()) + .datasource(datasource.getValue()) + .salaryAcctRecordId(PO.getSalaryAcctRecordId()) + .salaryAcctResultId(PO.getId()) + .salaryAcctEmpId(PO.getSalaryAcctEmpId()) + .salaryItemId(PO.getSalaryItemId()) + .employeeId(PO.getEmployeeId()) + .operator(uid) + .operateTime(now) + .deleteType(NumberUtils.INTEGER_ZERO) + .updateTime(now) + .build()); + }); + return needInsertList; + } +} diff --git a/src/com/engine/salary/entity/salaryacct/bo/SalaryCalcContext.java b/src/com/engine/salary/entity/salaryacct/bo/SalaryCalcContext.java new file mode 100644 index 000000000..c1a88ba6a --- /dev/null +++ b/src/com/engine/salary/entity/salaryacct/bo/SalaryCalcContext.java @@ -0,0 +1,46 @@ +package com.engine.salary.entity.salaryacct.bo; + +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO; +import com.engine.salary.entity.salarysob.dto.SalarySobCycleDTO; +import com.engine.salary.entity.salarysob.po.SalarySobAdjustRulePO; +import lombok.Data; + +import java.util.List; +import java.util.Map; + +/** + * @description: 薪资核算上下文 + * @author: xiajun + * @modified By: xiajun + * @date: Created in 8/22/22 3:26 PM + * @version:v1.0 + */ +@Data +public class SalaryCalcContext { + + /** + * 当前核算人员 + */ + private DataCollectionEmployee simpleEmployee; + /** + * 员工状态 + */ + private Map hrmStatusMap; + /** + * 薪资核算记录 + */ + private SalaryAcctRecordPO salaryAcctRecord; + /** + * 考勤周期、薪资周期、税款所属期、社保福利台账月份 + */ + private SalarySobCycleDTO salarySobCycle; + /** + * 调薪计薪规则 + */ + private List salaryAdjustmentRules; + /** + * 本次薪资核算所涉及的公式 + */ + private SalaryCalcFormulaContext salaryCalcFormulaContext; +} diff --git a/src/com/engine/salary/entity/salaryacct/bo/SalaryCalcEmployeeContext.java b/src/com/engine/salary/entity/salaryacct/bo/SalaryCalcEmployeeContext.java new file mode 100644 index 000000000..fa07e673e --- /dev/null +++ b/src/com/engine/salary/entity/salaryacct/bo/SalaryCalcEmployeeContext.java @@ -0,0 +1,41 @@ +package com.engine.salary.entity.salaryacct.bo; + +import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO; +import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO; +import com.engine.salary.entity.salaryacct.po.SalaryAcctResultPO; +import lombok.Data; + +import java.util.List; +import java.util.Map; + +/** + * @description: + * @author: xiajun + * @modified By: xiajun + * @date: Created in 8/23/22 3:45 PM + * @version:v1.0 + */ +@Data +public class SalaryCalcEmployeeContext { + + /** + * key:formulaId、value:公式变量的值 + */ + private Map> formulaVarValueMap; + /** + * key:salaryAcctEmployeeId、value:薪资核算结果 + */ + private Map noDecryptAcctResultValueMap; + /** + * key:salaryAcctRecordId、value:薪资核算记录 + */ + private Map sameTaxCycleRecordMap; + /** + * key:employee-taxAgentId、value:薪资核算人员 + */ + private Map> sameTaxCycleEmployeeMap; + /** + * key:salaryAcctEmployeeId、value:薪资核算结果 + */ + private Map sameTaxCycleResultValueMap; +} diff --git a/src/com/engine/salary/entity/salaryacct/bo/SalaryCalcFormula.java b/src/com/engine/salary/entity/salaryacct/bo/SalaryCalcFormula.java new file mode 100644 index 000000000..937bffdc7 --- /dev/null +++ b/src/com/engine/salary/entity/salaryacct/bo/SalaryCalcFormula.java @@ -0,0 +1,53 @@ +package com.engine.salary.entity.salaryacct.bo; + +import com.engine.salary.enums.SalaryRoundingModeEnum; +import com.engine.salary.enums.salaryitem.SalaryDataTypeEnum; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * @description: 薪资核算计算优先级 + * @author: xiajun + * @modified By: xiajun + * @date: Created in 8/23/22 11:52 AM + * @version:v1.0 + */ +@Data +@Accessors(chain = true) +public class SalaryCalcFormula { + + /** + * 薪资项目id + */ + private Long salaryItemId; + /** + * 薪资项目的code + */ + private String salaryItemCode; + /** + * 薪资类型 + */ + private String incomeCategory; + /** + * 薪资档案引用。0:薪资档案未引用、1:薪资档案引用 + * 为处理历史数据而留,不再使用 + */ + @Deprecated + private Integer useInEmployeeSalary; + /** + * 字段类型 + */ + private SalaryDataTypeEnum dataType; + /** + * 舍入规则 + */ + private SalaryRoundingModeEnum roundingMode; + /** + * 小数位数 + */ + private Integer pattern; + /** + * 公式id + */ + private Long formulaId; +} diff --git a/src/com/engine/salary/entity/salaryacct/bo/SalaryCalcFormulaContext.java b/src/com/engine/salary/entity/salaryacct/bo/SalaryCalcFormulaContext.java new file mode 100644 index 000000000..bd8a60387 --- /dev/null +++ b/src/com/engine/salary/entity/salaryacct/bo/SalaryCalcFormulaContext.java @@ -0,0 +1,105 @@ +package com.engine.salary.entity.salaryacct.bo; + +import com.engine.salary.entity.salaryformula.ExpressFormula; +import com.engine.salary.entity.salaryitem.po.SalaryItemPO; +import com.googlecode.aviator.Expression; +import lombok.Data; + +import java.util.*; + +/** + * @description: 薪资核算公式 + * @author: xiajun + * @modified By: xiajun + * @date: Created in 8/22/22 3:33 PM + * @version:v1.0 + */ +@Data +public class SalaryCalcFormulaContext { + + /** + * 薪资核算所包含的薪资项目 + */ + private Map salaryItemMap; + + /** + * 本次薪资核算所涉及的公式编译后的对象 + */ + private Map expressionMap; + + /** + * 薪资核算所包含的公式 + */ + private Map expressFormulaMap; + + /** + * 薪资核算所包含的薪资项目id(按计算顺序排序好了) + */ + private List> salaryCalcFormulas; + + /** + * 所有公式中是否包含薪资档案 + */ + private Set salaryArchiveFieldIds; + + /** + * 所有公式中是否包含其他扣除 + */ + private Set otherDeductionFieldIds; + + /** + * 所有公式中是否包含专项附加扣除 + */ + private Set addUpDeductionFieldIds; + + /** + * 所有公式中是否包含往期累计情况 + */ + private Set addUpSituationFieldIds; + + /** + * 所有公式中是否包含考勤 + */ + private Set attendFieldIds; + + /** + * 所有公式中是否包含社保福利 + */ + private Set welfareFieldIds; + + /** + * 所有公式中是否包含人员信息 + */ + private Set employeeInfoFieldIds; + + /** + * 所有公式中是否包含外部人员 + */ + private Set extEmployeeFieldIds; + + /** + * 所有公式中包含的自定义业务数据表 + */ + private Map> customDataFieldIdMap; + + /** + * 所有公式中包含的已发 + */ + private Set issuedFieldIds; + + public SalaryCalcFormulaContext() { + this.salaryItemMap = new HashMap<>(); + this.expressFormulaMap = new HashMap<>(); + this.salaryCalcFormulas = new ArrayList<>(); + this.salaryArchiveFieldIds = new HashSet<>(); + this.otherDeductionFieldIds = new HashSet<>(); + this.addUpDeductionFieldIds = new HashSet<>(); + this.addUpSituationFieldIds = new HashSet<>(); + this.attendFieldIds = new HashSet<>(); + this.welfareFieldIds = new HashSet<>(); + this.employeeInfoFieldIds = new HashSet<>(); + this.extEmployeeFieldIds = new HashSet<>(); + this.customDataFieldIdMap = new HashMap<>(); + this.issuedFieldIds = new HashSet<>(); + } +} diff --git a/src/com/engine/salary/entity/salaryacct/bo/SalaryCalcResult.java b/src/com/engine/salary/entity/salaryacct/bo/SalaryCalcResult.java new file mode 100644 index 000000000..3b658c769 --- /dev/null +++ b/src/com/engine/salary/entity/salaryacct/bo/SalaryCalcResult.java @@ -0,0 +1,34 @@ +package com.engine.salary.entity.salaryacct.bo; + +import com.engine.salary.entity.salaryacct.po.SalaryAcctResultPO; +import lombok.AllArgsConstructor; +import lombok.Data; + +import java.util.List; + +/** + * @description: + * @author: xiajun + * @modified By: xiajun + * @date: 2022/8/22 20:45 + * @version:v1.0 + */ +@Data +@AllArgsConstructor +public class SalaryCalcResult { + + /** + * 子线程是否运算成功 + */ + private boolean status; + + /** + * 子线程元算失败的错误信息 + */ + private String errMsg; + + /** + * 计算结果 + */ + private List salaryAcctResultValues; +} diff --git a/src/com/engine/salary/entity/salaryacct/bo/SalaryCheckBO.java b/src/com/engine/salary/entity/salaryacct/bo/SalaryCheckBO.java new file mode 100644 index 000000000..c18da2797 --- /dev/null +++ b/src/com/engine/salary/entity/salaryacct/bo/SalaryCheckBO.java @@ -0,0 +1,228 @@ +//package com.engine.salary.entity.salaryacct.bo; +// +//import com.google.common.collect.Lists; +//import com.weaver.common.distribution.genid.IdGenerator; +//import com.weaver.hrm.salary.entity.salaryacct.param.SalaryAcctCheckParam; +//import com.weaver.hrm.salary.entity.salaryacct.po.SalaryCheckResultDetailTempPO; +//import com.weaver.hrm.salary.entity.salaryacct.po.SalaryCheckResultPO; +//import com.weaver.hrm.salary.entity.salaryacct.po.SalaryCheckResultRecordPO; +//import com.weaver.hrm.salary.util.SalaryEntityUtil; +//import lombok.Data; +//import org.apache.commons.collections4.CollectionUtils; +// +//import java.time.LocalDateTime; +//import java.util.Collection; +//import java.util.List; +//import java.util.Map; +//import java.util.stream.Collectors; +// +///** +// * @description: 薪资核算校验 +// * @author: xiajun +// * @modified By: xiajun +// * @date: Created in 12/17/21 4:31 PM +// * @version:v1.0 +// */ +//public class SalaryCheckBO { +// +// /** +// * 原来的校验异常 +// */ +// private Collection oldCheckResults; +// +// /** +// * 原来的校验异常明细 +// */ +// private Collection oldCheckResultRecords; +// +// /** +// * 新的校验异常明细的临时存储数据 +// */ +// private Collection salaryCheckResultDetailTemps; +// +// public SalaryCheckBO(Collection oldCheckResults, +// Collection oldCheckResultRecords, +// Collection salaryCheckResultDetailTemps) { +// this.oldCheckResults = oldCheckResults; +// this.oldCheckResultRecords = oldCheckResultRecords; +// this.salaryCheckResultDetailTemps = salaryCheckResultDetailTemps; +// } +// +// /** +// * 处理校验异常明细的临时存储数据 +// * +// * @param checkParam +// * @param employeeId +// * @param tenantKey +// * @return +// */ +// public Result handleSalaryCheckResultDetailTemp(SalaryAcctCheckParam checkParam, Long employeeId, String tenantKey) { +// Result result = new Result(); +// Map oldCheckResultMap = SalaryEntityUtil.convert2Map(oldCheckResults, SalaryCheckResultPO::getSalaryCheckRuleId); +// Map> checkRuleIdKeyTempMap = SalaryEntityUtil +// .group2Map(salaryCheckResultDetailTemps, SalaryCheckResultDetailTempPO::getSalaryCheckRuleId); +// if (CollectionUtils.isEmpty(checkParam.getIds())) { +// // 如果校验全部人员 +// handleAllCheck(checkParam, checkRuleIdKeyTempMap, result, employeeId, tenantKey); +// } else { +// // 如果校验部分人员 +// handlePartCheck(checkParam, oldCheckResultMap, checkRuleIdKeyTempMap, result, employeeId, tenantKey); +// } +// return result; +// } +// +// /** +// * 校验全部人员 +// * +// * @param checkParam +// * @param checkRuleIdKeyTempMap +// * @param result +// * @param employeeId +// * @param tenantKey +// */ +// private void handleAllCheck(SalaryAcctCheckParam checkParam, +// Map> checkRuleIdKeyTempMap, +// Result result, Long employeeId, String tenantKey) { +// LocalDateTime now = LocalDateTime.now(); +// checkRuleIdKeyTempMap.forEach((checkRuleId, salaryCheckResultDetailTempPOS) -> { +// // 校验异常 +// SalaryCheckResultPO salaryCheckResultPO = SalaryCheckResultPO.builder() +// .salaryAcctRecordId(checkParam.getSalaryAcctRecordId()) +// .salaryCheckRuleId(checkRuleId) +// .formulaId(salaryCheckResultDetailTempPOS.get(0).getFormulaId()) +// .ignoreType(0) +// .creator(employeeId) +// .createTime(now) +// .updateTime(now) +// .tenantKey(tenantKey) +// .deleteType(0) +// .build(); +// result.getNeedInsertCheckResults().add(salaryCheckResultPO); +// // 校验异常明细 +// for (SalaryCheckResultDetailTempPO salaryCheckResultDetailTempPO : salaryCheckResultDetailTempPOS) { +// SalaryCheckResultRecordPO salaryCheckResultRecordPO = convert2CheckResultRecordPO(salaryCheckResultPO.getId(), +// salaryCheckResultDetailTempPO, now, employeeId, tenantKey); +// result.getNeedInsertCheckResultRecords().add(salaryCheckResultRecordPO); +// } +// }); +// } +// +// /** +// * 校验部分人员 +// * +// * @param checkParam +// * @param oldCheckResultMap +// * @param checkRuleIdKeyTempMap +// * @param result +// * @param employeeId +// * @param tenantKey +// */ +// private void handlePartCheck(SalaryAcctCheckParam checkParam, +// Map oldCheckResultMap, +// Map> checkRuleIdKeyTempMap, +// Result result, Long employeeId, String tenantKey) { +// LocalDateTime now = LocalDateTime.now(); +// checkRuleIdKeyTempMap.forEach((checkRuleId, salaryCheckResultDetailTempPOS) -> { +// // 校验异常 +// SalaryCheckResultPO salaryCheckResultPO = oldCheckResultMap.computeIfAbsent(checkRuleId, +// k -> SalaryCheckResultPO.builder() +// .salaryAcctRecordId(checkParam.getSalaryAcctRecordId()) +// .salaryCheckRuleId(k) +// .formulaId(salaryCheckResultDetailTempPOS.get(0).getFormulaId()) +// .ignoreType(0) +// .creator(employeeId) +// .createTime(now) +// .updateTime(now) +// .tenantKey(tenantKey) +// .deleteType(0) +// .build()); +// // 校验异常明细 +// for (SalaryCheckResultDetailTempPO salaryCheckResultDetailTempPO : salaryCheckResultDetailTempPOS) { +// SalaryCheckResultRecordPO salaryCheckResultRecordPO = convert2CheckResultRecordPO(salaryCheckResultPO.getId(), +// salaryCheckResultDetailTempPO, now, employeeId, tenantKey); +// result.getNeedInsertCheckResultRecords().add(salaryCheckResultRecordPO); +// } +// }); +// // 需要删除的校验异常明细(属于本次校验人员的校验异常明细需要删除) +// List needDeleteCheckResultRecordIds = oldCheckResultRecords.stream() +// .filter(e -> checkParam.getIds().contains(e.getSalaryAcctEmpId())) +// .map(SalaryCheckResultRecordPO::getId) +// .collect(Collectors.toList()); +// result.getNeedDeleteCheckResultRecordIds().addAll(needDeleteCheckResultRecordIds); +// // 需要删除的异常异常(校验异常下已经没有校验异常明细时需要删除) +// Map> oldCheckResultRecordMap = SalaryEntityUtil +// .group2Map(oldCheckResultRecords, SalaryCheckResultRecordPO::getCheckResultId); +// oldCheckResultRecordMap.forEach((checkResultId, salaryCheckResultRecordPOS) -> { +// // 本次校验是否生成了校验异常明细 +// SalaryCheckResultPO checkResultPO = oldCheckResultMap.get(checkResultId); +// boolean hasSalaryCheckResultRecord = checkRuleIdKeyTempMap.containsKey(checkResultPO.getSalaryCheckRuleId()); +// // 原来的校验异常明细中是否包含其他人员的(非本次校验的人员) +// boolean hasOtherSalaryAcctEmployee = salaryCheckResultRecordPOS.stream().anyMatch(e -> !checkParam.getIds().contains(e.getSalaryAcctEmpId())); +// // 原来校验异常明细不包含其他人员,本次校验也没有生成新的校验异常明细,那么就需要删除校验异常 +// if (!hasOtherSalaryAcctEmployee && !hasSalaryCheckResultRecord) { +// result.getNeedDeleteCheckResultIds().add(checkResultId); +// } +// }); +// } +// +// /** +// * 转换成校验异常明细po +// * +// * @param checkResultId +// * @param salaryCheckResultDetailTempPO +// * @param now +// * @param employeeId +// * @param tenantKey +// * @return +// */ +// private SalaryCheckResultRecordPO convert2CheckResultRecordPO(Long checkResultId, +// SalaryCheckResultDetailTempPO salaryCheckResultDetailTempPO, +// LocalDateTime now, +// Long employeeId, +// String tenantKey) { +// return SalaryCheckResultRecordPO.builder() +// .checkResultId(checkResultId) +// .salaryAcctRecordId(salaryCheckResultDetailTempPO.getSalaryAcctRecordId()) +// .salaryCheckRuleId(salaryCheckResultDetailTempPO.getSalaryCheckRuleId()) +// .formulaId(salaryCheckResultDetailTempPO.getFormulaId()) +// .salaryAcctEmpId(salaryCheckResultDetailTempPO.getSalaryAcctEmpId()) +// .employeeId(salaryCheckResultDetailTempPO.getEmployeeId()) +// .creator(employeeId) +// .createTime(now) +// .updateTime(now) +// .tenantKey(tenantKey) +// .deleteType(0) +// .build(); +// } +// +// @Data +// public static class Result { +// +// /** +// * 需要删除的校验异常 +// */ +// private Collection needDeleteCheckResultIds; +// +// /** +// * 需要重新保存的校验异常 +// */ +// private Collection needInsertCheckResults; +// +// /** +// * 需要删除的校验异常明细 +// */ +// private Collection needDeleteCheckResultRecordIds; +// +// /** +// * 需要重新保存的校验异常明细 +// */ +// private Collection needInsertCheckResultRecords; +// +// private Result() { +// this.needDeleteCheckResultIds = Lists.newArrayList(); +// this.needInsertCheckResults = Lists.newArrayList(); +// this.needDeleteCheckResultRecordIds = Lists.newArrayList(); +// this.needInsertCheckResultRecords = Lists.newArrayList(); +// } +// } +//} diff --git a/src/com/engine/salary/entity/salaryacct/bo/SalaryCheckResultBO.java b/src/com/engine/salary/entity/salaryacct/bo/SalaryCheckResultBO.java new file mode 100644 index 000000000..a9d26843c --- /dev/null +++ b/src/com/engine/salary/entity/salaryacct/bo/SalaryCheckResultBO.java @@ -0,0 +1,93 @@ +//package com.engine.salary.entity.salaryacct.bo; +// +//import com.weaver.excel.formula.api.entity.ExpressFormula; +//import com.weaver.hrm.salary.entity.salaryacct.dto.SalaryCheckResultListDTO; +//import com.weaver.hrm.salary.entity.salaryacct.dto.SalaryCheckResultRecordCountDTO; +//import com.weaver.hrm.salary.entity.salaryacct.dto.SalaryCheckResultRecordListDTO; +//import com.weaver.hrm.salary.entity.salaryacct.po.SalaryCheckResultPO; +//import com.weaver.hrm.salary.entity.salaryacct.po.SalaryCheckResultRecordPO; +//import com.weaver.hrm.salary.entity.salarysob.po.SalarySobCheckRulePO; +//import com.weaver.hrm.salary.util.SalaryEntityUtil; +//import com.weaver.teams.domain.user.DataCollectionEmployee; +//import org.apache.commons.collections4.CollectionUtils; +//import org.apache.commons.lang3.StringUtils; +//import org.apache.commons.lang3.math.NumberUtils; +// +//import java.util.Collections; +//import java.util.List; +//import java.util.Map; +//import java.util.stream.Collectors; +// +///** +// * @description: 薪资核算校验结果 +// * @author: xiajun +// * @modified By: xiajun +// * @date: Created in 12/7/21 1:52 PM +// * @version:v1.0 +// */ +//public class SalaryCheckResultBO { +// +// /** +// * 转换成校验异常列表dto +// * +// * @param salaryCheckResults +// * @param salarySobCheckRules +// * @param expressFormulas +// * @param salaryCheckResultRecordCountDTOS +// * @return +// */ +// public static List convert2ListDTO(List salaryCheckResults, +// List salarySobCheckRules, +// List expressFormulas, +// List salaryCheckResultRecordCountDTOS) { +// if (CollectionUtils.isEmpty(salaryCheckResults)) { +// return Collections.emptyList(); +// } +// Map formulaMap = SalaryEntityUtil.convert2Map(expressFormulas, ExpressFormula::getId, ExpressFormula::getFormula); +// Map checkRuleMap = SalaryEntityUtil.convert2Map(salarySobCheckRules, SalarySobCheckRulePO::getId, SalarySobCheckRulePO::getName); +// Map ckResultRecordCountMap = SalaryEntityUtil.convert2Map(salaryCheckResultRecordCountDTOS, SalaryCheckResultRecordCountDTO::getSalaryCheckResultId, +// SalaryCheckResultRecordCountDTO::getCountBySalaryCheckResultId); +// return salaryCheckResults.stream() +// .map(e -> SalaryCheckResultListDTO.builder() +// .id(e.getId()) +// .checkRuleId(e.getSalaryCheckRuleId()) +// .checkRuleName(checkRuleMap.getOrDefault(e.getSalaryCheckRuleId(), StringUtils.EMPTY)) +// .employeeSize(ckResultRecordCountMap.getOrDefault(e.getId(), NumberUtils.LONG_ZERO)) +// .formulaId(e.getFormulaId()) +// .formulaContent(formulaMap.getOrDefault(e.getFormulaId(), StringUtils.EMPTY)) +// .build()) +// .collect(Collectors.toList()); +// } +// +// /** +// * 转换成校验异常明细列表dto +// * +// * @param salaryCheckResultRecords +// * @param salarySobCheckRules +// * @param expressFormulas +// * @param simpleEmployees +// * @return +// */ +// public static List convert2RecordListDTO(List salaryCheckResultRecords, +// List salarySobCheckRules, +// List expressFormulas, +// List simpleEmployees) { +// if (CollectionUtils.isEmpty(salaryCheckResultRecords)) { +// return Collections.emptyList(); +// } +// Map formulaMap = SalaryEntityUtil.convert2Map(expressFormulas, ExpressFormula::getId, ExpressFormula::getFormula); +// Map checkRuleMap = SalaryEntityUtil.convert2Map(salarySobCheckRules, SalarySobCheckRulePO::getId, SalarySobCheckRulePO::getName); +// Map employeeMap = SalaryEntityUtil.convert2Map(simpleEmployees, DataCollectionEmployee::getEmployeeId, DataCollectionEmployee::getName); +// return salaryCheckResultRecords.stream() +// .map(e -> SalaryCheckResultRecordListDTO.builder() +// .id(e.getId()) +// .checkRuleId(e.getSalaryCheckRuleId()) +// .checkRuleName(checkRuleMap.getOrDefault(e.getSalaryCheckRuleId(), "")) +// .formulaId(e.getFormulaId()) +// .formulaContent(formulaMap.getOrDefault(e.getFormulaId(), "")) +// .employeeId(e.getEmployeeId()) +// .employeeName(employeeMap.getOrDefault(e.getEmployeeId(), "")) +// .build()) +// .collect(Collectors.toList()); +// } +//} diff --git a/src/com/engine/salary/entity/salaryacct/dto/ConsolidatedTaxDetailDTO.java b/src/com/engine/salary/entity/salaryacct/dto/ConsolidatedTaxDetailDTO.java new file mode 100644 index 000000000..0a47df4a8 --- /dev/null +++ b/src/com/engine/salary/entity/salaryacct/dto/ConsolidatedTaxDetailDTO.java @@ -0,0 +1,27 @@ +package com.engine.salary.entity.salaryacct.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 合并计税详情 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class ConsolidatedTaxDetailDTO { + + //员工信息") + private Object employeeInfo; + + //合并计税详情") + private Object salaryAcctResult; +} diff --git a/src/com/engine/salary/entity/salaryacct/dto/SalaryAccEmployeeListDTO.java b/src/com/engine/salary/entity/salaryacct/dto/SalaryAccEmployeeListDTO.java new file mode 100644 index 000000000..40da19f1d --- /dev/null +++ b/src/com/engine/salary/entity/salaryacct/dto/SalaryAccEmployeeListDTO.java @@ -0,0 +1,69 @@ +package com.engine.salary.entity.salaryacct.dto; + +import com.engine.salary.annotation.TableTitle; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 薪资核算人员列表 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalaryAccEmployeeListDTO { + + //主键id + private Long id; + + //人员id + private Long employeeId; + + //姓名 + @TableTitle(title = "姓名", dataIndex = "employeeName", key = "employeeName") + private String employeeName; + + //个税扣缴义务人id + private Long taxAgentId; + + + //个税扣缴义务人 + @TableTitle(title = "个税扣缴义务人", dataIndex = "taxAgentName", key = "taxAgentName") + private String taxAgentName; + + //部门id + private Long departmentId; + + + @TableTitle(title = "部门", dataIndex = "departmentName", key = "departmentName") + private String departmentName; + + @TableTitle(title = "手机号", dataIndex = "mobile", key = "mobile") + private String mobile; + + + @TableTitle(title = "工号", dataIndex = "jobNum", key = "jobNum") + private String jobNum; + + + @TableTitle(title = "员工状态", dataIndex = "status", key = "status") + private String status; + + @TableTitle(title = "账号类型", dataIndex = "accountType", key = "accountType") + private String accountType; + + + @TableTitle(title = "入职日期", dataIndex = "hireDate", key = "hireDate") + private String hireDate; + + //离职日期 +// @TableTitle(title = "离职日期", dataIndex = "dismissDate", key = "dismissDate") + private String dismissDate; +} diff --git a/src/com/engine/salary/entity/salaryacct/dto/SalaryAcctEmpSearchConditionDTO.java b/src/com/engine/salary/entity/salaryacct/dto/SalaryAcctEmpSearchConditionDTO.java new file mode 100644 index 000000000..770399e3b --- /dev/null +++ b/src/com/engine/salary/entity/salaryacct/dto/SalaryAcctEmpSearchConditionDTO.java @@ -0,0 +1,60 @@ +package com.engine.salary.entity.salaryacct.dto; + +import com.engine.salary.common.LocalDateRange; + +/** + * 薪资核算人员确认高级搜索 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SalaryAcctEmpSearchConditionDTO { + +// @SalarySearchCondition( +// label = "姓名", +// labelId = 85429, +// needQuickSearch = true, +// quickSearchKey = "employeeName", +// items = @SalarySearchConditionItem(itemType = WeaSearchConditionItemType.INPUT, name = "employeeName") +// ) + private String employeeName; + +// @SalarySearchCondition( +// label = "个税扣缴义务人", +// labelId = 86184, +// items = @SalarySearchConditionItem(itemType = WeaSearchConditionItemType.SELECT, name = "taxAgentId") +// ) + private Long taxAgentId; + +// @SalarySearchCondition( +// label = "部门", +// labelId = 86185, +// items = @SalarySearchConditionItem(itemType = WeaSearchConditionItemType.BROWSER, +// browserType = "department", name = "departmentIds", browserModule = "hrmsalary", browserMultiple = true) +// ) + private Long departmentIds; + +// @SalarySearchCondition( +// label = "岗位", +// labelId = 90633, +// items = @SalarySearchConditionItem(itemType = WeaSearchConditionItemType.BROWSER, +// browserType = "position", name = "positionIds", browserModule = "hrmsalary", browserMultiple = true) +// ) + private Long positionIds; + +// @SalarySearchCondition( +// label = "状态", +// labelId = 91075, +// items = @SalarySearchConditionItem(itemType = WeaSearchConditionItemType.SELECT, optionsEnum = SalaryEmployeeStatusEnum.class, name = "status") +// ) + private String status; + +// @SalarySearchCondition( +// label = "离职日期", +// labelId = 95228, +// items = @SalarySearchConditionItem(itemType = WeaSearchConditionItemType.DATEPICKER, name = "dismissDate", isRange = true) +// ) + private LocalDateRange dismissDate; +} diff --git a/src/com/engine/salary/entity/salaryacct/dto/SalaryAcctEmployeeCountDTO.java b/src/com/engine/salary/entity/salaryacct/dto/SalaryAcctEmployeeCountDTO.java new file mode 100644 index 000000000..3bdf4e529 --- /dev/null +++ b/src/com/engine/salary/entity/salaryacct/dto/SalaryAcctEmployeeCountDTO.java @@ -0,0 +1,23 @@ +package com.engine.salary.entity.salaryacct.dto; + +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 薪资核算人员的数量 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Accessors(chain = true) +public class SalaryAcctEmployeeCountDTO { + +// //薪资核算记录id") + private Long salaryAcctRecordId; + +// //薪资核算人员的数量") + private Long countBySalaryAcctRecordId; +} diff --git a/src/com/engine/salary/entity/salaryacct/dto/SalaryAcctEmployeeInfoDTO.java b/src/com/engine/salary/entity/salaryacct/dto/SalaryAcctEmployeeInfoDTO.java new file mode 100644 index 000000000..6ee7bdcf6 --- /dev/null +++ b/src/com/engine/salary/entity/salaryacct/dto/SalaryAcctEmployeeInfoDTO.java @@ -0,0 +1,36 @@ +package com.engine.salary.entity.salaryacct.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 员工信息字段 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalaryAcctEmployeeInfoDTO { + + //字段名称 + private String fieldName; + + //字段值 + private Object fieldValue; + + // code + private String fieldCode; + + // 用于编辑时前端渲染对应输入选择框 + private String fieldType; + + // 是否可编辑 + private boolean canEdit; +} diff --git a/src/com/engine/salary/entity/salaryacct/dto/SalaryAcctImportFieldDTO.java b/src/com/engine/salary/entity/salaryacct/dto/SalaryAcctImportFieldDTO.java new file mode 100644 index 000000000..fe5376506 --- /dev/null +++ b/src/com/engine/salary/entity/salaryacct/dto/SalaryAcctImportFieldDTO.java @@ -0,0 +1,73 @@ +package com.engine.salary.entity.salaryacct.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * 薪资核算导入时生成导入模板的薪资项目 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalaryAcctImportFieldDTO { + +// //公式项 +// private Collection formulaItems; +// +// //sql项 +// private Collection sqlItems; +// +// //输入项 +// private Collection inputItems; + + // 根据账套分组的薪资项目 + private List itemsByGroup; + + // 缓存勾选项目 + private List checkItems; + + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + public static class ImportFieldDTO { + + //薪资项目id + private Long salaryItemId; + + //薪资项目名称 + private String salaryItemName; + + //薪资项目类型 + private String dataType; + } + + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + public static class ImportFieldByGroupDTO { + + //薪资账套分组id") + private Long salarySobItemGroupId; + + //薪资项目分组名称") + private String salarySobItemGroupName; + + //分组中包含的薪资项目 + private List salaryItems; + + //分组顺序 + private Integer sortedIndex; + } +} diff --git a/src/com/engine/salary/entity/salaryacct/dto/SalaryAcctRateDTO.java b/src/com/engine/salary/entity/salaryacct/dto/SalaryAcctRateDTO.java new file mode 100644 index 000000000..8044bed9e --- /dev/null +++ b/src/com/engine/salary/entity/salaryacct/dto/SalaryAcctRateDTO.java @@ -0,0 +1,41 @@ +package com.engine.salary.entity.salaryacct.dto; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; + +@Data +@Accessors(chain = true) +@AllArgsConstructor +public class SalaryAcctRateDTO { + + //"缓存索引") + private String index; + //"提示信息") + private String msg; + //"状态") + private boolean status; + //"是否已经完成") + private boolean finish; + //"总数") + private Integer totalQty; + //"已经计算的数量") + private Integer calcQty; + //"进度") + private BigDecimal rate; + //"校验异常") + private boolean checkStatus; + + public SalaryAcctRateDTO(String index) { + this.index = index; + this.msg = ""; + this.status = true; + this.finish = false; + this.totalQty = 1; + this.calcQty = 0; + this.rate = BigDecimal.ZERO; + this.checkStatus = true; + } +} diff --git a/src/com/engine/salary/entity/salaryacct/dto/SalaryAcctRecordFormDTO.java b/src/com/engine/salary/entity/salaryacct/dto/SalaryAcctRecordFormDTO.java new file mode 100644 index 000000000..5a78052ab --- /dev/null +++ b/src/com/engine/salary/entity/salaryacct/dto/SalaryAcctRecordFormDTO.java @@ -0,0 +1,39 @@ +package com.engine.salary.entity.salaryacct.dto; + +import com.engine.salary.entity.salarysob.dto.SalarySobCycleDTO; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +/** + * 薪资核算基本信息详情 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Accessors(chain = true) +@NoArgsConstructor +@AllArgsConstructor +public class SalaryAcctRecordFormDTO { + + private Long id; + + //薪资所属月 + private String salaryMonth; + + //薪资账套id + private Long salarySobId; + + //薪资账套名称 + private String salarySobName; + + //备注 + private String description; + + //周期提示信息 + private SalarySobCycleDTO cycleInfo; +} diff --git a/src/com/engine/salary/entity/salaryacct/dto/SalaryAcctRecordListDTO.java b/src/com/engine/salary/entity/salaryacct/dto/SalaryAcctRecordListDTO.java new file mode 100644 index 000000000..e3d9b8fcc --- /dev/null +++ b/src/com/engine/salary/entity/salaryacct/dto/SalaryAcctRecordListDTO.java @@ -0,0 +1,74 @@ +package com.engine.salary.entity.salaryacct.dto; + +import com.cloudstore.eccom.pc.table.WeaTableOperate; +import com.engine.salary.annotation.TableTitle; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; +import java.util.Set; + +/** + * 薪资核算列表 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalaryAcctRecordListDTO { + + //主键id + private Long id; + + @TableTitle(title = "薪资所属月", dataIndex = "salaryMonth", key = "salaryMonth") + private String salaryMonth; + + @TableTitle(title = "薪资账套", dataIndex = "salarySobName", key = "salarySobName") + private String salarySobName; + + @TableTitle(title = "个税扣缴义务人", dataIndex = "taxAgentName", key = "taxAgentName") + private String taxAgentName; + + @TableTitle(title = "是否回算过", dataIndex = "backCalcStatus", key = "backCalcStatus") + private Integer backCalcStatus; + + @TableTitle(title = "核算次数", dataIndex = "acctTimes", key = "acctTimes") + private Integer acctTimes; + + //核算次数是否显示 + private boolean acctTimesViable; + + @TableTitle(title = "税款所属期", dataIndex = "taxCycle", key = "taxCycle") + private String taxCycle; + + @TableTitle(title = "状态", dataIndex = "status", key = "status") + private String status; + + + @TableTitle(title = "核算人数", dataIndex = "employeeSize", key = "employeeSize") + private Long employeeSize; + + @TableTitle(title = "核算人", dataIndex = "accountantName", key = "accountantName") + private String accountantName; + + @TableTitle(title = "最后操作时间", dataIndex = "updateTime", key = "updateTime") + private String updateTime; + + @TableTitle(title = "备注", dataIndex = "description", key = "description") + private String description; + + @TableTitle(title = "审批状态", dataIndex = "approvalStatus", key = "approvalStatus") + private String approvalStatus; + + @TableTitle(title = "操作", dataIndex = "operate", key = "operate") + private List operate; + + private Set opts; +} diff --git a/src/com/engine/salary/entity/salaryacct/dto/SalaryAcctResultDetailDTO.java b/src/com/engine/salary/entity/salaryacct/dto/SalaryAcctResultDetailDTO.java new file mode 100644 index 000000000..8fadd2670 --- /dev/null +++ b/src/com/engine/salary/entity/salaryacct/dto/SalaryAcctResultDetailDTO.java @@ -0,0 +1,97 @@ +package com.engine.salary.entity.salaryacct.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * @description: 薪资核算结果详情 + * @author: xiajun + * @modified By: xiajun + * @date: Created in 12/9/21 5:13 PM + * @version:v1.0 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//薪资核算结果详情") +public class SalaryAcctResultDetailDTO { + + /** + * SalaryAcctEmployee的id + */ + //薪资核算结果id") + private Long id; + + //员工信息") + private Long employeeId; + + //员工信息") + private List employeeInfos; + + //公式项") + private List formulaItems; + + //输入项") + private List inputItems; + + // 根据账套分组的薪资项目 + private List itemsByGroup; + + //已发补发 + private List issuedAndReissueItems; + + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + public static class SalaryAcctResultDetailItemDTO { + + //薪资项目id") + private Long salaryItemId; + + //薪资项目名称") + private String salaryItemName; + + //核算结果的值") + private String resultValue; + + // 公式/输入 + private String itemFormulaContent; + + //数据类型:number、string") + private String dataType; + + //是否可编辑 + private Boolean canEdit; + + // 保留小数位数 + private Integer pattern; + + // 锁定状态 + private String lockStatus; + } + + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + public static class SalaryAcctResultDetailItemByGroupDTO { + + //薪资账套分组id") + private Long salarySobItemGroupId; + + //薪资项目分组名称") + private String salarySobItemGroupName; + + //分组中包含的薪资项目 + private List salaryItems; + + //分组顺序 + private Integer sortedIndex; + } +} diff --git a/src/com/engine/salary/entity/salaryacct/dto/SalaryAcctResultListColumnDTO.java b/src/com/engine/salary/entity/salaryacct/dto/SalaryAcctResultListColumnDTO.java new file mode 100644 index 000000000..3b43cb86c --- /dev/null +++ b/src/com/engine/salary/entity/salaryacct/dto/SalaryAcctResultListColumnDTO.java @@ -0,0 +1,32 @@ +package com.engine.salary.entity.salaryacct.dto; + +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 薪资核算结果的表头 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Accessors(chain = true) +public class SalaryAcctResultListColumnDTO { + + //薪资项目名称 + private String columnName; + + //公式id + @JsonSerialize(using = ToStringSerializer.class) + private Long formulaId; + + //公式内容 + private String formulaContent; + + //是否需要展示锁定标识 + private boolean showLock; +} diff --git a/src/com/engine/salary/entity/salaryacct/dto/SalaryAcctResultSearchConditionDTO.java b/src/com/engine/salary/entity/salaryacct/dto/SalaryAcctResultSearchConditionDTO.java new file mode 100644 index 000000000..57bbd85ad --- /dev/null +++ b/src/com/engine/salary/entity/salaryacct/dto/SalaryAcctResultSearchConditionDTO.java @@ -0,0 +1,72 @@ +package com.engine.salary.entity.salaryacct.dto; + +import com.engine.salary.common.LocalDateRange; + +import java.util.Collection; + +/** + * @description: 薪资核算结果高级搜索 + * @author: xiajun + * @modified By: xiajun + * @date: Created in 12/9/21 5:06 PM + * @version:v1.0 + */ +public class SalaryAcctResultSearchConditionDTO { + +// @SalarySearchCondition( +// label = "姓名", +// labelId = 85429, +// needQuickSearch = true, +// quickSearchKey = "employeeName", +// items = @SalarySearchConditionItem(itemType = WeaSearchConditionItemType.INPUT, name = "employeeName") +// ) + private String employeeName; + +// @SalarySearchCondition( +// label = "个税扣缴义务人", +// labelId = 86184, +// items = @SalarySearchConditionItem(itemType = WeaSearchConditionItemType.SELECT, name = "taxAgentId") +// ) + private Long taxAgentId; + +// @SalarySearchCondition( +// label = "部门", +// labelId = 86185, +// items = @SalarySearchConditionItem(itemType = WeaSearchConditionItemType.BROWSER, +// browserType = "department", name = "departmentIds", browserModule = "hrmsalary", browserMultiple = true) +// ) + private Collection departmentIds; + +// @SalarySearchCondition( +// label = "岗位", +// labelId = 90633, +// items = @SalarySearchConditionItem(itemType = WeaSearchConditionItemType.BROWSER, +// browserType = "position", name = "positionIds", browserModule = "hrmsalary", browserMultiple = true) +// ) + private Collection positionIds; + +// @SalarySearchCondition( +// label = "状态", +// labelId = 91075, +// items = @SalarySearchConditionItem(itemType = WeaSearchConditionItemType.SELECT, optionsEnum = SalaryEmployeeStatusEnum.class, name = "status") +// ) + private String status; + +// @SalarySearchCondition( +// label = "离职日期", +// labelId = 95228, +// items = @SalarySearchConditionItem(itemType = WeaSearchConditionItemType.DATEPICKER, name = "dismissDate", isRange = true) +// ) + private LocalDateRange dismissDate; + +// @SalarySearchCondition( +// label = "合并计税", +// labelId = 93289, +// items = @SalarySearchConditionItem(itemType = WeaSearchConditionItemType.RADIO, name = "consolidatedTaxation", options = "listTaxationOption()") +// ) + private String consolidatedTaxation; +// +// public List listTaxationOption() { +// return Collections.singletonList(new WeaSearchConditionOption("1", "是")); +// } +} diff --git a/src/com/engine/salary/entity/salaryacct/dto/SalaryAcctResultTemplateDTO.java b/src/com/engine/salary/entity/salaryacct/dto/SalaryAcctResultTemplateDTO.java new file mode 100644 index 000000000..6d5c0dcb3 --- /dev/null +++ b/src/com/engine/salary/entity/salaryacct/dto/SalaryAcctResultTemplateDTO.java @@ -0,0 +1,44 @@ +package com.engine.salary.entity.salaryacct.dto; + +import com.engine.salary.annotation.TableTitle; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @ClassName SalaryAcctResultTemplatePO + * @author Harryxzy + * @date 2024/3/26 15:08 + * @description 薪资核算导出模板 + */ +@AllArgsConstructor +@NoArgsConstructor +@Builder +@Data +public class SalaryAcctResultTemplateDTO { + /** + * 主键id + */ + private Long id; + + /** + * 模板名称 + */ + @TableTitle(title ="模板名称",key = "templateName",dataIndex = "templateName") + private String templateName; + + /** + * 薪资账套id + */ + private Long salarySobId; + + /** + * 薪资项目id + */ + private String salaryItemIds; + + @TableTitle(title ="创建时间",key = "createTime",dataIndex = "createTime") + private String createTime; + +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/salaryacct/dto/SalaryCheckResultListDTO.java b/src/com/engine/salary/entity/salaryacct/dto/SalaryCheckResultListDTO.java new file mode 100644 index 000000000..c9ac60aa7 --- /dev/null +++ b/src/com/engine/salary/entity/salaryacct/dto/SalaryCheckResultListDTO.java @@ -0,0 +1,66 @@ +//package com.engine.salary.entity.salaryacct.dto; +// +//import com.weaver.common.component.table.type.WeaTableTypeEnum; +//import com.weaver.hrm.salary.annotation.SalaryTable; +//import com.weaver.hrm.salary.annotation.SalaryTableColumn; +//import com.weaver.hrm.salary.annotation.SalaryTableOperate; +//import io.swagger.annotations.ApiModel; +//import io.swagger.annotations.ApiModelProperty; +//import lombok.AllArgsConstructor; +//import lombok.Builder; +//import lombok.Data; +//import lombok.NoArgsConstructor; +// +///** +// * @description: 薪资核算校验结果列表 +// * @author: xiajun +// * @modified By: xiajun +// * @date: Created in 12/7/21 1:21 PM +// * @version:v1.0 +// */ +//@Data +//@Builder +//@NoArgsConstructor +//@AllArgsConstructor +////"薪资核算校验结果列表") +//@SalaryTable( +// value = { +// @SalaryTableOperate(index = 0, text = "忽略", labelId = 92457), +// @SalaryTableOperate(index = 1, text = "查看明细", labelId = 86358) +// }, tableType = WeaTableTypeEnum.CHECKBOX, pageUid = "salaryCheckResultList" +//) +//public class SalaryCheckResultListDTO { +// +// //主键id") +// private Long id; +// +// //校验规则id") +// private Long checkRuleId; +// +// @SalaryTableColumn( +// label = "异常所属规则名称", +// labelId = 92455, +// width = "30%" +// ) +// //异常所属规则名称") +// private String checkRuleName; +// +// @SalaryTableColumn( +// label = "异常人数", +// labelId = 92456, +// width = "20%" +// ) +// //异常人数") +// private Long employeeSize; +// +// //校验规则公式id") +// private Long formulaId; +// +// @SalaryTableColumn( +// label = "校验规则", +// labelId = 86126, +// width = "50%" +// ) +// //校验规则公式内容") +// private String formulaContent; +//} diff --git a/src/com/engine/salary/entity/salaryacct/dto/SalaryCheckResultRecordCountDTO.java b/src/com/engine/salary/entity/salaryacct/dto/SalaryCheckResultRecordCountDTO.java new file mode 100644 index 000000000..e06fa54eb --- /dev/null +++ b/src/com/engine/salary/entity/salaryacct/dto/SalaryCheckResultRecordCountDTO.java @@ -0,0 +1,21 @@ +package com.engine.salary.entity.salaryacct.dto; + +import lombok.Data; + +/** + * 薪资核算结果校验异常的明细数量 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +public class SalaryCheckResultRecordCountDTO { + + //"薪资核算结果校验异常id + private Long salaryCheckResultId; + + //"薪资核算结果校验异常的明细数量 + private Long countBySalaryCheckResultId; +} diff --git a/src/com/engine/salary/entity/salaryacct/dto/SalaryCheckResultRecordListDTO.java b/src/com/engine/salary/entity/salaryacct/dto/SalaryCheckResultRecordListDTO.java new file mode 100644 index 000000000..d5048e95f --- /dev/null +++ b/src/com/engine/salary/entity/salaryacct/dto/SalaryCheckResultRecordListDTO.java @@ -0,0 +1,62 @@ +//package com.engine.salary.entity.salaryacct.dto; +// +//import com.weaver.hrm.salary.annotation.SalaryTable; +//import com.weaver.hrm.salary.annotation.SalaryTableColumn; +//import io.swagger.annotations.ApiModelProperty; +//import lombok.AllArgsConstructor; +//import lombok.Builder; +//import lombok.Data; +//import lombok.NoArgsConstructor; +// +///** +// * @description: 校验结果具体人员列表 +// * @author: xiajun +// * @modified By: xiajun +// * @date: Created in 12/7/21 1:29 PM +// * @version:v1.0 +// */ +//@Data +//@Builder +//@NoArgsConstructor +//@AllArgsConstructor +//@SalaryTable( +// pageUid = "salaryCheckResultRecordList" +//) +//public class SalaryCheckResultRecordListDTO { +// +// //主键id") +// private Long id; +// +// //校验规则id") +// private Long checkRuleId; +// +// @SalaryTableColumn( +// label = "异常所属规则名称", +// labelId = 92455, +// width = "30%" +// ) +// //异常所属规则名称") +// private String checkRuleName; +// +// //校验规则公式id") +// private Long formulaId; +// +// @SalaryTableColumn( +// label = "校验规则", +// labelId = 86126, +// width = "50%" +// ) +// //校验规则公式内容") +// private String formulaContent; +// +// //人员id") +// private Long employeeId; +// +// @SalaryTableColumn( +// label = "姓名", +// labelId = 85429, +// width = "20%" +// ) +// //人员姓名") +// private String employeeName; +//} diff --git a/src/com/engine/salary/entity/salaryacct/dto/SalaryComparisonResultListDTO.java b/src/com/engine/salary/entity/salaryacct/dto/SalaryComparisonResultListDTO.java new file mode 100644 index 000000000..2667b00bb --- /dev/null +++ b/src/com/engine/salary/entity/salaryacct/dto/SalaryComparisonResultListDTO.java @@ -0,0 +1,32 @@ +package com.engine.salary.entity.salaryacct.dto; + +import com.engine.salary.component.WeaTableColumnGroup; +import com.engine.salary.util.page.PageInfo; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.util.List; +import java.util.Map; + +/** + * 薪资核算线下对比结果列表 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Accessors(chain = true) +@NoArgsConstructor +@AllArgsConstructor +public class SalaryComparisonResultListDTO { + + //列表的表头 + private List weaTableColumns; + + //列表数据 + private PageInfo> data; +} diff --git a/src/com/engine/salary/entity/salaryacct/param/SalaryAcctCalculateParam.java b/src/com/engine/salary/entity/salaryacct/param/SalaryAcctCalculateParam.java new file mode 100644 index 000000000..52c3b7f13 --- /dev/null +++ b/src/com/engine/salary/entity/salaryacct/param/SalaryAcctCalculateParam.java @@ -0,0 +1,30 @@ +package com.engine.salary.entity.salaryacct.param; + +import com.engine.salary.util.valid.DataCheck; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; + +/** + * 薪资核算的参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalaryAcctCalculateParam { + + //核算人员的id,不是employeeId而是salaryAcctEmpId + private Collection ids; + + @DataCheck(require = true,message = "参数错误,薪资核算记录ID不能为空") + private Long salaryAcctRecordId; +} diff --git a/src/com/engine/salary/entity/salaryacct/param/SalaryAcctCheckParam.java b/src/com/engine/salary/entity/salaryacct/param/SalaryAcctCheckParam.java new file mode 100644 index 000000000..e6a7cc626 --- /dev/null +++ b/src/com/engine/salary/entity/salaryacct/param/SalaryAcctCheckParam.java @@ -0,0 +1,34 @@ +package com.engine.salary.entity.salaryacct.param; + +import com.engine.salary.util.valid.DataCheck; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.util.Collection; + +/** + * 薪资核算结果的校验参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Accessors(chain = true) +@NoArgsConstructor +@AllArgsConstructor +public class SalaryAcctCheckParam { + + /** + * 不是employeeId而是salaryAcctEmpId + */ + //核算人员的id + private Collection ids; + + //薪资核算记录id + @DataCheck(require = true,message = "参数错误,薪资核算记录ID不能为空") + private Long salaryAcctRecordId; +} diff --git a/src/com/engine/salary/entity/salaryacct/param/SalaryAcctEmpCheckTaxAgentParam.java b/src/com/engine/salary/entity/salaryacct/param/SalaryAcctEmpCheckTaxAgentParam.java new file mode 100644 index 000000000..67aa9b81d --- /dev/null +++ b/src/com/engine/salary/entity/salaryacct/param/SalaryAcctEmpCheckTaxAgentParam.java @@ -0,0 +1,19 @@ +package com.engine.salary.entity.salaryacct.param; + +import com.engine.salary.util.valid.DataCheck; +import lombok.Data; + +/** + * 检查薪资核算人员的个税扣缴义务人 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +public class SalaryAcctEmpCheckTaxAgentParam { + + @DataCheck(require = true,message = "参数错误,薪资核算记录ID不能为空") + private Long salaryAcctRecordId; +} diff --git a/src/com/engine/salary/entity/salaryacct/param/SalaryAcctEmpRefreshTaxAgentParam.java b/src/com/engine/salary/entity/salaryacct/param/SalaryAcctEmpRefreshTaxAgentParam.java new file mode 100644 index 000000000..baaf2a2a3 --- /dev/null +++ b/src/com/engine/salary/entity/salaryacct/param/SalaryAcctEmpRefreshTaxAgentParam.java @@ -0,0 +1,19 @@ +package com.engine.salary.entity.salaryacct.param; + +import com.engine.salary.util.valid.DataCheck; +import lombok.Data; + +/** + * 刷新薪资核算人员的个税扣缴义务人 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +public class SalaryAcctEmpRefreshTaxAgentParam { + + @DataCheck(require = true,message = "参数错误,薪资核算记录ID不能为空") + private Long salaryAcctRecordId; +} diff --git a/src/com/engine/salary/entity/salaryacct/param/SalaryAcctEmployeeAddParam.java b/src/com/engine/salary/entity/salaryacct/param/SalaryAcctEmployeeAddParam.java new file mode 100644 index 000000000..15bf4c09c --- /dev/null +++ b/src/com/engine/salary/entity/salaryacct/param/SalaryAcctEmployeeAddParam.java @@ -0,0 +1,25 @@ +package com.engine.salary.entity.salaryacct.param; + +import com.engine.salary.util.valid.DataCheck; +import lombok.Data; + +import java.util.Collection; + +/** + * @description: 薪资核算人员-从环比上月减少添加 + * @author: xiajun + * @modified By: xiajun + * @date: Created in 1/26/22 3:39 PM + * @version:v1.0 + */ +@Data +public class SalaryAcctEmployeeAddParam { + + //薪资核算记录id + @DataCheck(require = true,message = "参数错误,薪资核算记录ID不能为空") + private Long salaryAcctRecordId; + + //薪资核算记录人员id + @DataCheck(require = true,message = "参数错误,薪资核算人员不能为空") + private Collection ids; +} diff --git a/src/com/engine/salary/entity/salaryacct/param/SalaryAcctEmployeeDeleteParam.java b/src/com/engine/salary/entity/salaryacct/param/SalaryAcctEmployeeDeleteParam.java new file mode 100644 index 000000000..df60a56ef --- /dev/null +++ b/src/com/engine/salary/entity/salaryacct/param/SalaryAcctEmployeeDeleteParam.java @@ -0,0 +1,26 @@ +package com.engine.salary.entity.salaryacct.param; + +import com.engine.salary.util.valid.DataCheck; +import lombok.Data; + +import java.util.Collection; + +/** + * 薪资核算人员删除参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +public class SalaryAcctEmployeeDeleteParam { + + //薪资核算记录的id + @DataCheck(require = true,message = "参数错误,薪资核算记录ID不能为空") + private Long salaryAcctRecordId; + + //薪资核算人员的id + @DataCheck(require = true,message = "参数错误,薪资核算人员不能为空") + private Collection ids; +} diff --git a/src/com/engine/salary/entity/salaryacct/param/SalaryAcctEmployeeListQueryParam.java b/src/com/engine/salary/entity/salaryacct/param/SalaryAcctEmployeeListQueryParam.java new file mode 100644 index 000000000..a35dce175 --- /dev/null +++ b/src/com/engine/salary/entity/salaryacct/param/SalaryAcctEmployeeListQueryParam.java @@ -0,0 +1,61 @@ +package com.engine.salary.entity.salaryacct.param; + +import com.engine.salary.common.BaseQueryParam; +import com.engine.salary.enums.salaryaccounting.EmployeeTypeEnum; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import javax.validation.constraints.NotNull; +import java.util.Collection; + +/** + * 薪资核算人员列表查询条件 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Accessors(chain = true) +@NoArgsConstructor +@AllArgsConstructor +//薪资核算人员列表查询条件") +public class SalaryAcctEmployeeListQueryParam extends BaseQueryParam { + + /** + * 参数错误,薪资核算记录ID不能为空 + */ + @NotNull(message = "LABEL:99845") + //薪资核算记录id") + private Long salaryAcctRecordId; + + //人员姓名") + private String employeeName; + + //个税扣缴义务人") + private Long taxAgentId; + + //人员") + private Collection employeeIds; + + //部门") + private Collection departmentIds; + + //岗位") + private Collection positionIds; + + //状态") + private String status; + + //工号") + private String jobNum; + + //列表主键id") + private Collection ids; + + //薪资核算人员类型") + private EmployeeTypeEnum employeeType; +} diff --git a/src/com/engine/salary/entity/salaryacct/param/SalaryAcctEmployeeQueryParam.java b/src/com/engine/salary/entity/salaryacct/param/SalaryAcctEmployeeQueryParam.java new file mode 100644 index 000000000..f0437b8d0 --- /dev/null +++ b/src/com/engine/salary/entity/salaryacct/param/SalaryAcctEmployeeQueryParam.java @@ -0,0 +1,74 @@ +package com.engine.salary.entity.salaryacct.param; + +import com.engine.salary.common.BaseQueryParam; +import com.engine.salary.common.LocalDateRange; +import com.engine.salary.enums.salarysob.SalaryEmployeeStatusEnum; +import com.engine.salary.util.valid.DataCheck; +import lombok.*; + +import java.util.Collection; +import java.util.Date; +import java.util.List; +import java.util.Set; + +/** + * 薪资核算人员列表查询条件 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@EqualsAndHashCode(callSuper = true) +@NoArgsConstructor +@AllArgsConstructor +@Builder +public class SalaryAcctEmployeeQueryParam extends BaseQueryParam { + + //薪资核算记录id") + @DataCheck(require = true,message = "参数错误,薪资核算记录ID不能为空") + private Long salaryAcctRecordId; + + //人员姓名") + private String employeeName; + + //个税扣缴义务人") + private Long taxAgentId; + + //分部 + private List subcompanyIds; + + //部门") + private Collection departmentIds; + + + //岗位") + private Collection positionIds; + + /** + * 状态 + * @see SalaryEmployeeStatusEnum + */ + private SalaryEmployeeStatusEnum status; + //状态(多选) + private List statuses; + + //离职日期") + private LocalDateRange dismissDate; + + //薪资核算人员列表主键id") + private List ids; + + private String workcode; + + private List taxAgentIds; + private Set salaryMonths; + + + private Collection salaryAcctRecordIds; + private Collection salarySobIds; + private Collection employeeIds; + + +} diff --git a/src/com/engine/salary/entity/salaryacct/param/SalaryAcctEmployeeSaveParam.java b/src/com/engine/salary/entity/salaryacct/param/SalaryAcctEmployeeSaveParam.java new file mode 100644 index 000000000..fbce40bcc --- /dev/null +++ b/src/com/engine/salary/entity/salaryacct/param/SalaryAcctEmployeeSaveParam.java @@ -0,0 +1,30 @@ +package com.engine.salary.entity.salaryacct.param; + +import com.engine.salary.util.valid.DataCheck; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; + +/** + * 添加核算人员参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalaryAcctEmployeeSaveParam { + + @DataCheck(require = true, message = "参数错误,薪资核算记录ID不能为空") + private Long salaryAcctRecordId; + + @DataCheck(require = true, message = "参数错误,人员不能为空") + private Collection employeeIds; +} diff --git a/src/com/engine/salary/entity/salaryacct/param/SalaryAcctImportParam.java b/src/com/engine/salary/entity/salaryacct/param/SalaryAcctImportParam.java new file mode 100644 index 000000000..21201a6d5 --- /dev/null +++ b/src/com/engine/salary/entity/salaryacct/param/SalaryAcctImportParam.java @@ -0,0 +1,36 @@ +package com.engine.salary.entity.salaryacct.param; + +import com.engine.salary.util.valid.DataCheck; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalaryAcctImportParam { + + //上传文件id + @DataCheck(require = true,message = "imageId为空") + String imageId; + + //薪资核算记录的id + @DataCheck(require = true,message = "薪资核算记录id为空") + Long salaryAcctRecordId; + + // 导入表单字段缓存项目 + List salaryItems; + +} diff --git a/src/com/engine/salary/entity/salaryacct/param/SalaryAcctImportTemplateParam.java b/src/com/engine/salary/entity/salaryacct/param/SalaryAcctImportTemplateParam.java new file mode 100644 index 000000000..2c63a8909 --- /dev/null +++ b/src/com/engine/salary/entity/salaryacct/param/SalaryAcctImportTemplateParam.java @@ -0,0 +1,31 @@ +package com.engine.salary.entity.salaryacct.param; + +import com.engine.salary.util.valid.DataCheck; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +import java.util.Collection; + +/** + * 薪资核算导入数据时下载导入模板的参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Getter +@Setter +@NoArgsConstructor +@AllArgsConstructor +public class SalaryAcctImportTemplateParam extends SalaryAcctResultQueryParam { + + //薪资项目id") + @DataCheck(require = true,message = "薪资项目id不能为空") + private Collection salaryItemIds; + + //是否导出数据") + private String importType; +} diff --git a/src/com/engine/salary/entity/salaryacct/param/SalaryAcctRecordQueryParam.java b/src/com/engine/salary/entity/salaryacct/param/SalaryAcctRecordQueryParam.java new file mode 100644 index 000000000..8424aa765 --- /dev/null +++ b/src/com/engine/salary/entity/salaryacct/param/SalaryAcctRecordQueryParam.java @@ -0,0 +1,42 @@ +package com.engine.salary.entity.salaryacct.param; + +import com.engine.salary.common.BaseQueryParam; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.time.YearMonth; +import java.util.List; + +/** + * 薪资核算列表查询参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalaryAcctRecordQueryParam extends BaseQueryParam { + + //核算年月范围起") + private YearMonth startMonth; + + //核算年月范围止") + private YearMonth endMonth; + + //账套名称") + private String name; + + /** + * 扣缴义务人id集合 + */ + private List taxAgentIds; + + private String startMonthStr; + private String endMonthStr; +} diff --git a/src/com/engine/salary/entity/salaryacct/param/SalaryAcctRecordReAccountParam.java b/src/com/engine/salary/entity/salaryacct/param/SalaryAcctRecordReAccountParam.java new file mode 100644 index 000000000..a73565f02 --- /dev/null +++ b/src/com/engine/salary/entity/salaryacct/param/SalaryAcctRecordReAccountParam.java @@ -0,0 +1,19 @@ +package com.engine.salary.entity.salaryacct.param; + +import com.engine.salary.util.valid.DataCheck; +import lombok.Data; + +/** + * 重新核算 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +public class SalaryAcctRecordReAccountParam { + + @DataCheck(require = true, message = "参数错误,薪资核算记录ID不能为空") + private Long salaryAcctRecordId; +} diff --git a/src/com/engine/salary/entity/salaryacct/param/SalaryAcctRecordSaveParam.java b/src/com/engine/salary/entity/salaryacct/param/SalaryAcctRecordSaveParam.java new file mode 100644 index 000000000..62890c5da --- /dev/null +++ b/src/com/engine/salary/entity/salaryacct/param/SalaryAcctRecordSaveParam.java @@ -0,0 +1,39 @@ +package com.engine.salary.entity.salaryacct.param; + +import com.engine.salary.util.valid.DataCheck; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.time.YearMonth; + +/** + * 薪资核算基本信息保存参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//薪资核算基本信息保存参数 +public class SalaryAcctRecordSaveParam { + + //薪资所属月 + @DataCheck(require = true, message = "薪资所属月格式错误") + private YearMonth salaryMonth; + + private String salaryMonthStr; + + //薪资账套id + @DataCheck(require = true, message = "薪资账套ID不允许为空") + private Long salarySobId; + + //备注 + @DataCheck(max = 80, message = "备注不能超过80个字符") + private String description; +} diff --git a/src/com/engine/salary/entity/salaryacct/param/SalaryAcctResultBatchUpdateParam.java b/src/com/engine/salary/entity/salaryacct/param/SalaryAcctResultBatchUpdateParam.java new file mode 100644 index 000000000..89c06ad5e --- /dev/null +++ b/src/com/engine/salary/entity/salaryacct/param/SalaryAcctResultBatchUpdateParam.java @@ -0,0 +1,37 @@ +package com.engine.salary.entity.salaryacct.param; + +import com.engine.salary.util.valid.DataCheck; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * @ClassName SalaryAcctResultBatchUpdateParam + * @author Harryxzy + * @date 2023/12/4 13:48 + * @description 批量更新参数 + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class SalaryAcctResultBatchUpdateParam { + + //薪资核算记录的id + @DataCheck(require = true, message = "薪资核算记录ID不得为空") + private Long salaryAcctRecordId; + + //薪资项目的Id + @DataCheck(require = true, message = "薪资项目id不得为空") + private Long salaryItemId; + + // 薪资核算人员id + private List idList; + + //薪资项目值 + private String value; + +} diff --git a/src/com/engine/salary/entity/salaryacct/param/SalaryAcctResultLockParam.java b/src/com/engine/salary/entity/salaryacct/param/SalaryAcctResultLockParam.java new file mode 100644 index 000000000..555411825 --- /dev/null +++ b/src/com/engine/salary/entity/salaryacct/param/SalaryAcctResultLockParam.java @@ -0,0 +1,34 @@ +package com.engine.salary.entity.salaryacct.param; + +import com.engine.salary.enums.salaryaccounting.LockStatusEnum; +import com.engine.salary.util.valid.DataCheck; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 薪资数据单元格锁定 + *

Copyright: Copyright (c) 2024

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class SalaryAcctResultLockParam { + //锁定状态 + @DataCheck(require = true,message = "锁定状态不能为空") + private LockStatusEnum lockStatus; + + //薪资核算人员Id + @DataCheck(require = true,message = "薪资核算人员不能为空") + private Long acctEmpId; + + //薪资项目的Id + @DataCheck(require = true,message = "薪资项目不能为空") + private Long salaryItemId; +} diff --git a/src/com/engine/salary/entity/salaryacct/param/SalaryAcctResultLogQueryParam.java b/src/com/engine/salary/entity/salaryacct/param/SalaryAcctResultLogQueryParam.java new file mode 100644 index 000000000..b38d9d2b8 --- /dev/null +++ b/src/com/engine/salary/entity/salaryacct/param/SalaryAcctResultLogQueryParam.java @@ -0,0 +1,73 @@ +package com.engine.salary.entity.salaryacct.param; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; + +/** + * @author Harryxzy + * @date 2023/05/12 15:14 + * @description 薪资核算结果来源 + */ + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalaryAcctResultLogQueryParam { + + /** + * 主键id + */ + private Long id; + + /** + * 数据来源:1:手动编辑、2:导入 + */ + private Integer datasource; + + /** + * 薪资核算记录id + */ + private Long salaryAcctRecordId; + + /** + * 薪资核算结果id + */ + private Long salaryAcctResultId; + + /** + * 薪资核算人员id + */ + private Long salaryAcctEmpId; + + + /** + * 薪资项目id + */ + private Long salaryItemId; + + /** + * 人员id + */ + private Long employeeId; + + /** + * 操作人 + */ + private Long operator; + + + /** + * 操作时间 + */ + private Date operateTime; + + /** + * 是否已删除。0:未删除、1:已删除 + */ + private Integer deleteType; +} diff --git a/src/com/engine/salary/entity/salaryacct/param/SalaryAcctResultQueryParam.java b/src/com/engine/salary/entity/salaryacct/param/SalaryAcctResultQueryParam.java new file mode 100644 index 000000000..5f5749ac7 --- /dev/null +++ b/src/com/engine/salary/entity/salaryacct/param/SalaryAcctResultQueryParam.java @@ -0,0 +1,85 @@ +package com.engine.salary.entity.salaryacct.param; + +import com.engine.salary.common.BaseQueryParam; +import com.engine.salary.common.LocalDateRange; +import com.engine.salary.enums.common.FilterEnum; +import com.engine.salary.enums.salarysob.SalaryEmployeeStatusEnum; +import com.engine.salary.util.valid.DataCheck; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.List; + +/** + * 薪资核算结果查询参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalaryAcctResultQueryParam extends BaseQueryParam { + + //薪资核算记录id + @DataCheck(require = true, message = "参数错误,薪资核算记录ID不能为空") + private Long salaryAcctRecordId; + + //人员姓名 + private String employeeName; + + //个税扣缴义务人 + private Long taxAgentId; + + //分部 + private Collection subcompanyIds; + + //部门 + private Collection departmentIds; + + //岗位 + private Collection positionIds; + + //状态 + private SalaryEmployeeStatusEnum status; + //状态(多选) + private List statuses; + + //离职日期 + private LocalDateRange dismissDate; + + //是否合并计税 + private String consolidatedTaxation; + + //列表主键id + private Collection ids; + + private String workcode; + + //薪资项目id + private Collection salaryItemIds; + + /** + * 是否需要实时人员信息 + */ + private boolean dynamicEmpInfo; + + //其他条件 + private List otherConditions; + + + @Data + @NoArgsConstructor + @AllArgsConstructor + public static class OtherCondition { + private Long itemId; + private FilterEnum filter; + private List params; + } +} diff --git a/src/com/engine/salary/entity/salaryacct/param/SalaryAcctResultSaveParam.java b/src/com/engine/salary/entity/salaryacct/param/SalaryAcctResultSaveParam.java new file mode 100644 index 000000000..61568093c --- /dev/null +++ b/src/com/engine/salary/entity/salaryacct/param/SalaryAcctResultSaveParam.java @@ -0,0 +1,49 @@ +package com.engine.salary.entity.salaryacct.param; + +import com.engine.salary.entity.salaryacct.dto.SalaryAcctEmployeeInfoDTO; +import com.engine.salary.util.valid.DataCheck; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; + +/** + * 薪资核算结果保存参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalaryAcctResultSaveParam { + + //薪资核算人员的id + @DataCheck(require = true,message = "参数错误,薪资核算人员不能为空") + private Long salaryAcctEmpId; + + //各个薪资项目的值 + @DataCheck(require = true,message = "薪资项目的值的集合不能为空") + private Collection items; + + // 员工基础信息 + private Collection employeeInfos; + + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + public static class SalaryAcctResultDetailItemParam { + + //薪资项目的id + private Long salaryItemId; + + //核算结果的值 + private String resultValue; + } +} diff --git a/src/com/engine/salary/entity/salaryacct/param/SalaryAcctResultTemplateSaveParam.java b/src/com/engine/salary/entity/salaryacct/param/SalaryAcctResultTemplateSaveParam.java new file mode 100644 index 000000000..f251eb92d --- /dev/null +++ b/src/com/engine/salary/entity/salaryacct/param/SalaryAcctResultTemplateSaveParam.java @@ -0,0 +1,48 @@ +package com.engine.salary.entity.salaryacct.param; + +import com.engine.salary.common.BaseQueryParam; +import com.engine.salary.util.valid.DataCheck; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * @ClassName SalaryAcctResultTemplatePO + * @author Harryxzy + * @date 2024/3/26 15:08 + * @description 薪资核算导出模板 + */ +@AllArgsConstructor +@NoArgsConstructor +@Builder +@Data +public class SalaryAcctResultTemplateSaveParam extends BaseQueryParam { + /** + * 主键id + */ + private Long id; + + private List ids; + + /** + * 薪资账套id + */ + private Long salarySobId; + + private Long salaryAcctRecordId; + + /** + * 薪资项目id + */ + private List salaryItemIds; + + /** + * 模板名称 + */ + @DataCheck(require = true, message= "模板名称不能为空") + private String templateName; + +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/salaryacct/param/SalaryAcctResultUpdateLockStatusParam.java b/src/com/engine/salary/entity/salaryacct/param/SalaryAcctResultUpdateLockStatusParam.java new file mode 100644 index 000000000..c4ed999fd --- /dev/null +++ b/src/com/engine/salary/entity/salaryacct/param/SalaryAcctResultUpdateLockStatusParam.java @@ -0,0 +1,39 @@ +package com.engine.salary.entity.salaryacct.param; + +import com.engine.salary.enums.salaryaccounting.LockStatusEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Set; + +/** + * 更新核算锁定状态 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class SalaryAcctResultUpdateLockStatusParam { + //锁定状态 + private LockStatusEnum lockStatus; + + + //薪资核算记录的id + private Long salaryAcctRecordId; + + //薪资项目的Id + private Long salaryItemId; + + //薪资项目的IdList + private Set salaryItemIds; + + //薪资核算人员的id + private Set acctEmpIds; +} diff --git a/src/com/engine/salary/entity/salaryacct/param/SalaryCheckResultExportParam.java b/src/com/engine/salary/entity/salaryacct/param/SalaryCheckResultExportParam.java new file mode 100644 index 000000000..bdadb5552 --- /dev/null +++ b/src/com/engine/salary/entity/salaryacct/param/SalaryCheckResultExportParam.java @@ -0,0 +1,31 @@ +package com.engine.salary.entity.salaryacct.param; + +import com.engine.salary.util.valid.DataCheck; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; + +/** + * 薪资核算校验异常导出参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalaryCheckResultExportParam { + + //指定导出的id + private Collection ids; + + //薪资核算记录的id + @DataCheck(require = true,message = "参数错误,薪资核算记录ID不能为空") + private Long salaryAcctRecordId; +} diff --git a/src/com/engine/salary/entity/salaryacct/param/SalaryCheckResultQueryParam.java b/src/com/engine/salary/entity/salaryacct/param/SalaryCheckResultQueryParam.java new file mode 100644 index 000000000..966379063 --- /dev/null +++ b/src/com/engine/salary/entity/salaryacct/param/SalaryCheckResultQueryParam.java @@ -0,0 +1,27 @@ +package com.engine.salary.entity.salaryacct.param; + +import com.engine.salary.common.BaseQueryParam; +import com.engine.salary.util.valid.DataCheck; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 校验结果列表查询参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalaryCheckResultQueryParam extends BaseQueryParam { + + //薪资核算的id + @DataCheck(require = true,message = "参数错误,薪资核算记录ID不能为空") + private Long salaryAcctRecordId; +} diff --git a/src/com/engine/salary/entity/salaryacct/param/SalaryCheckResultRecordQueryParam.java b/src/com/engine/salary/entity/salaryacct/param/SalaryCheckResultRecordQueryParam.java new file mode 100644 index 000000000..8aa364317 --- /dev/null +++ b/src/com/engine/salary/entity/salaryacct/param/SalaryCheckResultRecordQueryParam.java @@ -0,0 +1,27 @@ +package com.engine.salary.entity.salaryacct.param; + +import com.engine.salary.common.BaseQueryParam; +import com.engine.salary.util.valid.DataCheck; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 校验结果明细列表查询参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalaryCheckResultRecordQueryParam extends BaseQueryParam { + + //校验结果id + @DataCheck(require = true,message = "核算异常的id不能为空") + private Long checkResultId; +} diff --git a/src/com/engine/salary/entity/salaryacct/param/SalaryComparisonResultExportParam.java b/src/com/engine/salary/entity/salaryacct/param/SalaryComparisonResultExportParam.java new file mode 100644 index 000000000..f7a0e716f --- /dev/null +++ b/src/com/engine/salary/entity/salaryacct/param/SalaryComparisonResultExportParam.java @@ -0,0 +1,20 @@ +package com.engine.salary.entity.salaryacct.param; + +import com.engine.salary.util.valid.DataCheck; +import lombok.Data; + +/** + * 薪资核算线下对比结果导入模板导出参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +public class SalaryComparisonResultExportParam { + + //薪资核算记录id + @DataCheck(require = true, message = "参数错误,薪资核算记录ID不能为空") + private Long salaryAcctRecordId; +} diff --git a/src/com/engine/salary/entity/salaryacct/param/SalaryComparisonResultQueryParam.java b/src/com/engine/salary/entity/salaryacct/param/SalaryComparisonResultQueryParam.java new file mode 100644 index 000000000..41b442e48 --- /dev/null +++ b/src/com/engine/salary/entity/salaryacct/param/SalaryComparisonResultQueryParam.java @@ -0,0 +1,23 @@ +package com.engine.salary.entity.salaryacct.param; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 薪资核算线下对比结果查询参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@EqualsAndHashCode(callSuper = true) +public class SalaryComparisonResultQueryParam extends SalaryAcctResultQueryParam { + + //仅显示有差异的人员") + private boolean onlyDiffEmployee; + + //仅显示有差异的薪资项目") + private boolean onlyDiffSalaryItem; +} diff --git a/src/com/engine/salary/entity/salaryacct/po/ExcelAcctResultPO.java b/src/com/engine/salary/entity/salaryacct/po/ExcelAcctResultPO.java new file mode 100644 index 000000000..4e7bc31d4 --- /dev/null +++ b/src/com/engine/salary/entity/salaryacct/po/ExcelAcctResultPO.java @@ -0,0 +1,95 @@ +package com.engine.salary.entity.salaryacct.po; + +import com.engine.salary.annotation.Encrypt; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.Date; + +/** + * 线下excel核算的结果 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//hrsa_excel_acct_result +public class ExcelAcctResultPO { + + /** + * 主键id + */ + private Long id; + + /** + * 薪资账套id + */ + private Long salarySobId; + + /** + * 薪资项目id + */ + private Long salaryItemId; + + /** + * 薪资核算的id + */ + private Long salaryAcctRecordId; + + /** + * 薪资核算人员id + */ + private Long salaryAcctEmpId; + + /** + * 人员id + */ + private Long employeeId; + + /** + * 个税扣缴义务人id + */ + private Long taxAgentId; + + /** + * 计算后的值 + */ + @Encrypt + private String resultValue; + + /** + * 租户key + */ + private String tenantKey; + + /** + * 创建人id + */ + private Long creator; + + /** + * 是否删除 + */ + private Integer deleteType; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 更新时间 + */ + private Date updateTime; + + //条件 + private Collection salaryAcctEmpIds; +} diff --git a/src/com/engine/salary/entity/salaryacct/po/SalaryAcctEmployeePO.java b/src/com/engine/salary/entity/salaryacct/po/SalaryAcctEmployeePO.java new file mode 100644 index 000000000..c456e80da --- /dev/null +++ b/src/com/engine/salary/entity/salaryacct/po/SalaryAcctEmployeePO.java @@ -0,0 +1,181 @@ +package com.engine.salary.entity.salaryacct.po; + +import com.engine.hrmelog.annotation.ElogTransform; +import com.engine.salary.annotation.Auth; +import com.engine.salary.annotation.I18n; +import com.engine.salary.annotation.SalaryFormulaVar; +import com.engine.salary.enums.datacollection.DataCollectionEmployeeTypeEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.util.Collection; +import java.util.Date; +import java.util.List; + +/** + * 薪资核算人员 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@Accessors(chain = true) +@NoArgsConstructor +@AllArgsConstructor +//hrsa_salary_acct_emp +@ElogTransform(name = "薪资核算人员") +@Auth(page = "salaryAcct") +public class SalaryAcctEmployeePO { + + /** + * 主键id + */ + @ElogTransform(name = "主键id") + private Long id; + + /** + * 薪资核算的id + */ + @ElogTransform(name = "核算记录id") + @SalaryFormulaVar(defaultLabel = "核算记录id", labelId = 86321, dataType = "number") + private Long salaryAcctRecordId; + + /** + * 薪资账套id + */ + @ElogTransform(name = "薪资账套id") + @SalaryFormulaVar(defaultLabel = "薪资账套id", labelId = 86321, dataType = "number") + private Long salarySobId; + + /** + * 人员id + */ + @ElogTransform(name = "人员id") + @SalaryFormulaVar(defaultLabel = "人员id", labelId = 86321, dataType = "number") + private Long employeeId; + + /** + * 人员类型,0或null组织架构,1非系统人员 + * + * @see DataCollectionEmployeeTypeEnum + */ + @ElogTransform(name = "人员类型") + private Integer employeeType; + + /** + * 个税扣缴义务人id + */ + @ElogTransform(name = "个税扣缴义务人id") + @SalaryFormulaVar(defaultLabel = "个税扣缴义务人id", labelId = 86321, dataType = "number") + private Long taxAgentId; + + /** + * 薪资所属月 + */ + @ElogTransform(name = "薪资所属月") + @SalaryFormulaVar(defaultLabel = "薪资所属月", labelId = 86321, dataType = "string") + private Date salaryMonth; + + /** + * 租户key + */ + @ElogTransform(name = "租户key") + private String tenantKey; + + /** + * 创建人id + */ + @ElogTransform(name = "创建人id") + private Long creator; + + /** + * 是否删除 + */ + @ElogTransform(name = "是否删除") + private Integer deleteType; + + /** + * 创建时间 + */ + @ElogTransform(name = "创建时间") + private Date createTime; + + /** + * 更新时间 + */ + @ElogTransform(name = "更新时间") + private Date updateTime; + + + @Deprecated + @ElogTransform(name = "锁定状态") + private Integer lockStatus; + + /** + * 分部 + */ + @I18n + @SalaryFormulaVar(defaultLabel = "分部", labelId = 86321, dataType = "string") + private String subcompanyName; + @SalaryFormulaVar(defaultLabel = "分部ID", labelId = 86321, dataType = "string") + private Long subcompanyId; + /** + * 部门 + */ + @I18n + @SalaryFormulaVar(defaultLabel = "部门", labelId = 86321, dataType = "string") + private String departmentName; + @SalaryFormulaVar(defaultLabel = "部门ID", labelId = 86321, dataType = "string") + private Long departmentId; + /** + * 岗位 + */ + @I18n + @SalaryFormulaVar(defaultLabel = "岗位", labelId = 86321, dataType = "string") + private String jobtitleName; + @SalaryFormulaVar(defaultLabel = "岗位ID", labelId = 86321, dataType = "string") + private Long jobtitleId; + /** + * 职称 + */ + @I18n + @SalaryFormulaVar(defaultLabel = "职称", labelId = 86321, dataType = "string") + private String jobcall; + @SalaryFormulaVar(defaultLabel = "职称ID", labelId = 86321, dataType = "string") + private Long jobcallId; + /** + * 状态 + */ + @SalaryFormulaVar(defaultLabel = "状态编码", labelId = 86321, dataType = "string") + private String status; + + //锁定的项目 + private List lockItems; + + + /** + * 主次账号 0/null:主账号 1:次账号 + */ + private Integer accountType; + + + + //--------条件---------- + //主键id集合 + private Collection ids; + + private Collection taxAgentIds; + + private Collection salaryAcctRecordIds; + private Collection salarySobIds; + + private Collection employeeIds; + + private Collection salaryMonths; +} diff --git a/src/com/engine/salary/entity/salaryacct/po/SalaryAcctRecordPO.java b/src/com/engine/salary/entity/salaryacct/po/SalaryAcctRecordPO.java new file mode 100644 index 000000000..a17ecf398 --- /dev/null +++ b/src/com/engine/salary/entity/salaryacct/po/SalaryAcctRecordPO.java @@ -0,0 +1,160 @@ +package com.engine.salary.entity.salaryacct.po; + +import com.engine.hrmelog.annotation.ElogTransform; +import com.engine.salary.annotation.Auth; +import com.engine.salary.common.LocalDateRange; +import com.engine.salary.enums.auth.AuthCheckTypeEnum; +import com.engine.salary.enums.salaryaccounting.SalaryAcctRecordStatusEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.util.Collection; +import java.util.Date; +import java.util.List; +import java.util.Set; + +/** + * 薪资核算表 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Accessors(chain = true) +@NoArgsConstructor +@AllArgsConstructor +@Builder +@ElogTransform( name = "薪资核算记录" ) +//hrsa_salary_acct_record +@Auth(page = "salaryAcct",checkType = AuthCheckTypeEnum.SOB) +public class SalaryAcctRecordPO { + + /** + * 主键id + */ + @ElogTransform( name = "主键id" ) + private Long id; + + /** + * 薪资所属月 + */ + @ElogTransform( name = "薪资所属月" ) + private Date salaryMonth; + + /** + * 税款所属期 + */ + @ElogTransform( name = "税款所属期" ) + private Date taxCycle; + + /** + * 薪资账套id + */ + @ElogTransform( name = "薪资账套id" ) + private Long salarySobId; + + /** + * 核算状态 + * @see SalaryAcctRecordStatusEnum + */ + @ElogTransform( name = "核算状态" ) + private Integer status; + + /** + * 本次核算是账套(salarySobId)在本月(salaryMonth)的第几次核算 + */ + @ElogTransform( name = "核算次数" ) + private Integer acctTimes; + + /** + * 是否是回算 0:不是回算、1:是回算 + */ + @ElogTransform( name = "是否是回算" ) + private Integer backCalcStatus; + + /** + * 回算(上次核算的薪资核算记录id) + */ + @Deprecated + private Long superId; + + /** + * 回算(最原始的那次薪资核算记录id) + */ + @Deprecated + private Long rootId; + + /** + * 备注 + */ + @ElogTransform( name = "备注" ) + private String description; + + /** + * 租户key + */ + @ElogTransform( name = "租户key" ) + private String tenantKey; + + /** + * 创建人id + */ + @ElogTransform( name = "创建人id" ) + private Long creator; + + /** + * 是否删除 + */ + @ElogTransform( name = "是否删除" ) + private Integer deleteType; + + /** + * 创建时间 + */ + @ElogTransform( name = "创建时间" ) + private Date createTime; + + /** + * 更新时间 + */ + @ElogTransform( name = "更新时间" ) + private Date updateTime; + + private Long taxAgentId; + + /** + * 审批流程id + */ + private String approvalId; + + /** + * 审批状态 + */ + private String approvalStatus; + + /** + * 锁定的薪资项目 + */ + @Deprecated + private List lockSalaryItemIds; + + + private Set opts; + + //查询条件------------------------------- + Collection ids; + + //薪资账套id + Collection salarySobIds; + + //税款所属期 + LocalDateRange salaryMonths; + + //税款所属期 + LocalDateRange taxCycleDateRange; +} diff --git a/src/com/engine/salary/entity/salaryacct/po/SalaryAcctResultLogPO.java b/src/com/engine/salary/entity/salaryacct/po/SalaryAcctResultLogPO.java new file mode 100644 index 000000000..e3d2bed60 --- /dev/null +++ b/src/com/engine/salary/entity/salaryacct/po/SalaryAcctResultLogPO.java @@ -0,0 +1,75 @@ +package com.engine.salary.entity.salaryacct.po; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; + +/** + * @author Harryxzy + * @date 2023/05/12 15:14 + * @description 薪资核算结果来源 + */ + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalaryAcctResultLogPO { + + /** + * 主键id + */ + private Long id; + + /** + * 数据来源:1:手动编辑、2:导入 + */ + private Integer datasource; + + /** + * 薪资核算记录id + */ + private Long salaryAcctRecordId; + + /** + * 薪资核算结果id + */ + private Long salaryAcctResultId; + + /** + * 薪资核算人员id + */ + private Long salaryAcctEmpId; + + + /** + * 薪资项目id + */ + private Long salaryItemId; + + /** + * 人员id + */ + private Long employeeId; + + /** + * 操作人 + */ + private Long operator; + + + /** + * 操作时间 + */ + private Date operateTime; + + /** + * 是否已删除。0:未删除、1:已删除 + */ + private Integer deleteType; + + private Date updateTime; +} diff --git a/src/com/engine/salary/entity/salaryacct/po/SalaryAcctResultPO.java b/src/com/engine/salary/entity/salaryacct/po/SalaryAcctResultPO.java new file mode 100644 index 000000000..4df634452 --- /dev/null +++ b/src/com/engine/salary/entity/salaryacct/po/SalaryAcctResultPO.java @@ -0,0 +1,121 @@ +package com.engine.salary.entity.salaryacct.po; + +import com.engine.salary.annotation.Encrypt; +import com.engine.hrmelog.annotation.ElogTransform; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.Date; + +/** + * 薪资核算结果 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//value = "hrsa_salary_acct_result +@ElogTransform( name="薪资核算结果" ) +public class SalaryAcctResultPO { + + /** + * 主键id + */ + @ElogTransform( name="主键" ) + private Long id; + + /** + * 薪资账套id + */ + @ElogTransform( name="薪资账套id" ) + private Long salarySobId; + + /** + * 薪资项目id + */ + @ElogTransform( name="薪资项目id" ) + private Long salaryItemId; + + /** + * 薪资核算的id + */ + @ElogTransform( name="薪资核算记录id" ) + private Long salaryAcctRecordId; + + /** + * 薪资核算人员id + */ + @ElogTransform( name="薪资核算人员id" ) + private Long salaryAcctEmpId; + + /** + * 人员id + */ + @ElogTransform( name="人员id" ) + private Long employeeId; + + /** + * 个税扣缴义务人id + */ + @ElogTransform( name="个税扣缴义务人id" ) + private Long taxAgentId; + + /** + * 计算后的值 + */ + @ElogTransform( name="计算后的值" ) + @Encrypt + private String resultValue; + + /** + * 回算前的值 + */ + @ElogTransform( name="回算前的值" ) + @Encrypt + private String originResultValue; + + /** + * 租户key + */ + @ElogTransform( name="租户" ) + private String tenantKey; + + /** + * 创建人id + */ + @ElogTransform( name="创建人" ) + private Long creator; + + /** + * 是否删除 + */ + private Integer deleteType; + + /** + * 创建时间 + */ + @ElogTransform( name="创建时间" ) + private Date createTime; + + /** + * 更新时间 + */ + @ElogTransform( name="更新时间" ) + private Date updateTime; + + //条件 + private Collection ids; + private Collection salaryAcctRecordIds; + private Collection salaryAcctEmpIds; + private Collection employeeIds; + private Collection taxAgentIds; + private Collection salaryItemIds; +} diff --git a/src/com/engine/salary/entity/salaryacct/po/SalaryAcctResultTempPO.java b/src/com/engine/salary/entity/salaryacct/po/SalaryAcctResultTempPO.java new file mode 100644 index 000000000..3e985265e --- /dev/null +++ b/src/com/engine/salary/entity/salaryacct/po/SalaryAcctResultTempPO.java @@ -0,0 +1,105 @@ +package com.engine.salary.entity.salaryacct.po; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.util.Collection; +import java.util.Date; + +/** + * @description: 薪资核算结果临时存储 + * @author: xiajun + * @modified By: xiajun + * @date: Created in 12/27/21 10:05 AM + * @version:v1.0 + */ +@Data +@Builder +@Accessors(chain = true) +@NoArgsConstructor +@AllArgsConstructor +//value = "hrsa_acct_result_temp") +public class SalaryAcctResultTempPO { + + /** + * 主键id + */ + private Long id; + + /** + * 核算生成的key + */ + private String calculateKey; + + /** + * 薪资账套id + */ + private Long salarySobId; + + /** + * 薪资项目id + */ + private Long salaryItemId; + + /** + * 薪资核算的id + */ + private Long salaryAcctRecordId; + + /** + * 薪资核算人员id + */ + private Long salaryAcctEmpId; + + /** + * 人员id + */ + private Long employeeId; + + /** + * 个税扣缴义务人id + */ + private Long taxAgentId; + + /** + * 计算后的值 + */ + private String resultValue; + + /** + * 回算前的值 + */ + private String originResultValue; + + /** + * 租户key + */ + private String tenantKey; + + /** + * 创建人id + */ + private Long creator; + + /** + * 是否删除 + */ + private Integer deleteType; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 更新时间 + */ + private Date updateTime; + + + //条件 + Collection ids; +} diff --git a/src/com/engine/salary/entity/salaryacct/po/SalaryAcctResultTemplatePO.java b/src/com/engine/salary/entity/salaryacct/po/SalaryAcctResultTemplatePO.java new file mode 100644 index 000000000..d5c4343f9 --- /dev/null +++ b/src/com/engine/salary/entity/salaryacct/po/SalaryAcctResultTemplatePO.java @@ -0,0 +1,61 @@ +package com.engine.salary.entity.salaryacct.po; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.Date; + +/** + * @ClassName SalaryAcctResultTemplatePO + * @author Harryxzy + * @date 2024/3/26 15:08 + * @description 薪资核算导出模板 + */ +@AllArgsConstructor +@NoArgsConstructor +@Builder +@Data +//hrsa_acct_result_template +public class SalaryAcctResultTemplatePO { + /** + * 主键id + */ + private Long id; + + /** + * 模板名称 + */ + private String templateName; + + /** + * 模板类型, 0:导出模板 1:公共导出模板 2:导入模板 + */ + private Integer type; + + /** + * 薪资账套id + */ + private Long salarySobId; + + /** + * 薪资项目id + */ + private String salaryItemIds; + + private Long creator; + + private Date updateTime; + + private Date createTime; + + private Integer deleteType; + + private String tenantKey; + + //主键id集合 + private Collection ids; + private Collection types; +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/salaryacct/po/SalaryAcctSobConfigPO.java b/src/com/engine/salary/entity/salaryacct/po/SalaryAcctSobConfigPO.java new file mode 100644 index 000000000..b6d09ecf8 --- /dev/null +++ b/src/com/engine/salary/entity/salaryacct/po/SalaryAcctSobConfigPO.java @@ -0,0 +1,100 @@ +package com.engine.salary.entity.salaryacct.po; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.Date; + +/** + * 账套快照 + *

Copyright: Copyright (c) 2024

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//hrsa_salary_acct_sob_config +public class SalaryAcctSobConfigPO { + + /** + * 主键id + */ + private Long id; + + /** + * 薪资核算记录id + */ + private Long salaryAcctRecordId; + + /** + * 薪资账套基本信息 + */ + private String basicConfig; + + /** + * 员工信息字段 + */ + private String employeeFieldConfig; + + /** + * 薪资项目 + */ + private String itemConfig; + + /** + * 薪资项目分类 + */ + private String itemGroupConfig; + + /** + * 回算薪资项目 + */ + private String backItemConfig; + + /** + * 调薪规则 + */ + @Deprecated + private String adjustRuleConfig; + + /** + * 校验规则 + */ + @Deprecated + private String checkRuleConfig; + + /** + * 租户key + */ + private String tenantKey; + + /** + * 创建人id + */ + private Long creator; + + /** + * 是否删除 + */ + private Integer deleteType; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 更新时间 + */ + private Date updateTime; + + //主键id集合 + private Collection ids; +} diff --git a/src/com/engine/salary/entity/salaryacct/po/SalaryCheckResultDetailTempPO.java b/src/com/engine/salary/entity/salaryacct/po/SalaryCheckResultDetailTempPO.java new file mode 100644 index 000000000..08d73b41d --- /dev/null +++ b/src/com/engine/salary/entity/salaryacct/po/SalaryCheckResultDetailTempPO.java @@ -0,0 +1,85 @@ +package com.engine.salary.entity.salaryacct.po; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.time.LocalDateTime; + +/** + * @description: 核算结果的校验结果明细临时存储 + * @author: xiajun + * @modified By: xiajun + * @date: Created in 12/27/21 3:41 PM + * @version:v1.0 + */ +@Data +@Builder +@Accessors(chain = true) +@NoArgsConstructor +@AllArgsConstructor +//value = "hrsa_ck_result_detail_temp") +public class SalaryCheckResultDetailTempPO { + + /** + * 主键id + */ + private Long id; + + /** + * 薪资核算id + */ + private Long salaryAcctRecordId; + + /** + * 校验规则id + */ + private Long salaryCheckRuleId; + + /** + * 公式id + */ + private Long formulaId; + + /** + * 薪资核算人员id + */ + private Long salaryAcctEmpId; + + /** + * 人员id + */ + private Long employeeId; + + /** + * 校验时生成的key + */ + private String calculateKey; + + /** + * 租户key + */ + private String tenantKey; + + /** + * 创建人id + */ + private Long creator; + + /** + * 是否删除 + */ + private Integer deleteType; + + /** + * 创建时间 + */ + private LocalDateTime createTime; + + /** + * 更新时间 + */ + private LocalDateTime updateTime; +} diff --git a/src/com/engine/salary/entity/salaryacct/po/SalaryCheckResultPO.java b/src/com/engine/salary/entity/salaryacct/po/SalaryCheckResultPO.java new file mode 100644 index 000000000..f8f8da978 --- /dev/null +++ b/src/com/engine/salary/entity/salaryacct/po/SalaryCheckResultPO.java @@ -0,0 +1,73 @@ +package com.engine.salary.entity.salaryacct.po; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.time.LocalDateTime; + +/** + * @description: 薪资核算校验异常结果 + * @author: xiajun + * @modified By: xiajun + * @date: Created in 12/7/21 10:44 AM + * @version:v1.0 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//value = "hrsa_check_result") +public class SalaryCheckResultPO { + + /** + * 主键id + */ + private Long id; + + /** + * 薪资核算id + */ + private Long salaryAcctRecordId; + + /** + * 校验规则id + */ + private Long salaryCheckRuleId; + + /** + * 公式id + */ + private Long formulaId; + + /** + * 是否忽略。0:未忽略、1:已忽略 + */ + private Integer ignoreType; + + /** + * 租户key + */ + private String tenantKey; + + /** + * 创建人id + */ + private Long creator; + + /** + * 是否删除 + */ + private Integer deleteType; + + /** + * 创建时间 + */ + private LocalDateTime createTime; + + /** + * 更新时间 + */ + private LocalDateTime updateTime; +} diff --git a/src/com/engine/salary/entity/salaryacct/po/SalaryCheckResultRecordPO.java b/src/com/engine/salary/entity/salaryacct/po/SalaryCheckResultRecordPO.java new file mode 100644 index 000000000..b57210197 --- /dev/null +++ b/src/com/engine/salary/entity/salaryacct/po/SalaryCheckResultRecordPO.java @@ -0,0 +1,83 @@ +package com.engine.salary.entity.salaryacct.po; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.time.LocalDateTime; + +/** + * @description: 薪资核算校验异常结果明细 + * @author: xiajun + * @modified By: xiajun + * @date: Created in 12/7/21 10:47 AM + * @version:v1.0 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//value = "hrsa_check_result_record") +public class SalaryCheckResultRecordPO { + + /** + * 主键id + */ + private Long id; + + /** + * 校验异常结果id + */ + private Long checkResultId; + + /** + * 薪资核算id + */ + private Long salaryAcctRecordId; + + /** + * 校验规则id + */ + private Long salaryCheckRuleId; + + /** + * 公式id + */ + private Long formulaId; + + /** + * 薪资核算人员id + */ + private Long salaryAcctEmpId; + + /** + * 人员id + */ + private Long employeeId; + + /** + * 租户key + */ + private String tenantKey; + + /** + * 创建人id + */ + private Long creator; + + /** + * 是否删除 + */ + private Integer deleteType; + + /** + * 创建时间 + */ + private LocalDateTime createTime; + + /** + * 更新时间 + */ + private LocalDateTime updateTime; +} diff --git a/src/com/engine/salary/entity/salaryarchive/bo/SalaryArchiveBO.java b/src/com/engine/salary/entity/salaryarchive/bo/SalaryArchiveBO.java new file mode 100644 index 000000000..75b26f972 --- /dev/null +++ b/src/com/engine/salary/entity/salaryarchive/bo/SalaryArchiveBO.java @@ -0,0 +1,329 @@ +package com.engine.salary.entity.salaryarchive.bo; + +import com.cloudstore.eccom.constant.WeaBoolAttr; +import com.cloudstore.eccom.pc.table.WeaTableColumn; +import com.engine.salary.common.LocalDateRange; +import com.engine.salary.constant.SalaryDefaultTenantConstant; +import com.engine.salary.constant.SalaryItemConstant; +import com.engine.salary.entity.salaryarchive.dto.SalaryArchiveDataDTO; +import com.engine.salary.entity.salaryarchive.dto.SalaryArchiveItemDataDTO; +import com.engine.salary.entity.salaryarchive.dto.SalaryArchiveTaxAgentDataDTO; +import com.engine.salary.entity.salaryarchive.po.SalaryArchiveItemPO; +import com.engine.salary.entity.salaryarchive.po.SalaryArchivePO; +import com.engine.salary.entity.salaryitem.po.SalaryItemPO; +import com.engine.salary.entity.taxagent.po.TaxAgentEmpChangePO; +import com.engine.salary.enums.salaryarchive.SalaryArchiveStatusEnum; +import com.engine.salary.enums.taxagent.TaxAgentEmpChangeTypeEnum; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.db.IdGenerator; +import com.google.common.collect.Lists; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.apache.commons.lang3.math.NumberUtils; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * @Description: 薪资档案 + * @Author: wangxiangzhong + * @Date: 2021-11-03 10:51 + */ +public class SalaryArchiveBO { + + @Override + public String toString() { + return "SalaryArchiveBO{}"; + } + + /** + * 添加日期范围 + * @param weaSearchCondition + * @param employeeId + * @param tenantKey + */ +// public static void addDatePickerRangeOtherParams(WeaSearchCondition weaSearchCondition, String datePickerKey, Long employeeId, String tenantKey) { +// WeaSearchConditionItem datePickerItem = weaSearchCondition.getItems().get(datePickerKey); +// Map otherParams = Maps.newHashMap(); +// otherParams.put("isRange", true); +// otherParams.put("type", "day"); +// otherParams.put("startPlaceholder", SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 90648, "开始日期")); +// otherParams.put("endPlaceholder", SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 90649, "结束日期")); +// datePickerItem.setOtherParams(otherParams); +// weaSearchCondition.getItems().put(datePickerKey, datePickerItem); +// } + + /** + * 构建表格动态列 + * + * @param salaryItems + */ + public static List buildSalaryArchiveTable(List salaryItems, boolean openSecondaryAccount) { + // 表格表头 + List columns = new ArrayList<>(); + WeaTableColumn idColumn = new WeaTableColumn("100px", "id", "id"); + idColumn.setIsPrimarykey(WeaBoolAttr.TRUE); + idColumn.setDisplay(WeaBoolAttr.FALSE); + columns.add(idColumn); + WeaTableColumn employeeIdColumn = new WeaTableColumn("100px", "人员信息表的主键id", "employeeId"); + employeeIdColumn.setDisplay(WeaBoolAttr.FALSE); + columns.add(employeeIdColumn); + columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(85429, "姓名"), "username")); + if (openSecondaryAccount) { + columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(85429, "账号类型"), "accountType")); + } + columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(86184, "个税扣缴义务人"), "taxAgentName")); + columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(86185, "分部"), "subcompanyName")); + columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(86185, "部门"), "departmentName")); + columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(86185, "工号"), "workcode")); + columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(86186, "手机号"), "mobile")); + columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(86186, "证件号码"), "idNo")); + columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(86187, "员工状态"), "employeeStatus")); + columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(86187, "起始发薪日期"), "payStartDate")); + columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(86187, "最后发薪日期"), "payEndDate")); + columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(86187, "入职日期"), "companystartdate").setDisplay(WeaBoolAttr.FALSE)); +// columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(86187, "离职日期"), "dismissdate").setDisplay(WeaBoolAttr.FALSE)); + for (SalaryItemPO salaryItem : salaryItems) { + columns.add(new WeaTableColumn("100px", salaryItem.getName(), salaryItem.getId() + SalaryItemConstant.DYNAMIC_SUFFIX)); + } + columns.add(new WeaTableColumn("100px", "操作", "operate")); + return columns; + } + + /** + * 构建薪资档案数据 + * + * @param salaryArchiveList + * @param salaryArchiveItemDataList + * @param localDateRange + * @param allEmployeeIds + * @param isOnlyTaxAgent + * @return + */ + public static List buildSalaryArchiveData(List salaryArchiveList, + List salaryArchiveItemDataList, + LocalDateRange localDateRange, + List allEmployeeIds, + boolean isOnlyTaxAgent) { + + // 开始日期 + Date start = localDateRange.getFromDate(); + // 结束日期 + Date end = localDateRange.getEndDate(); + + List list = new ArrayList<>(); + allEmployeeIds.forEach(e -> { + // 同一个人的档案数据 + List salaryArchives = salaryArchiveList.stream().filter(f -> f.getEmployeeId().equals(e)).collect(Collectors.toList()); + List salaryArchiveIds = salaryArchives.stream().map(SalaryArchivePO::getId).collect(Collectors.toList()); + // 同一个人的薪资项目调整历史数据 + List salaryArchiveItems = salaryArchiveItemDataList.stream().filter(d -> salaryArchiveIds.contains(d.getSalaryArchiveId())).collect(Collectors.toList()); + List salaryArchiveItemIds = salaryArchiveItems.stream().map(SalaryArchiveItemPO::getSalaryItemId).distinct().collect(Collectors.toList()); + + SalaryArchiveDataDTO salaryArchiveData = new SalaryArchiveDataDTO(); + salaryArchiveData.setEmployeeId(e); + List taxAgents = new ArrayList<>(); + // 按个税扣缴义务人生效日期时间段切割 + for (SalaryArchivePO salaryArchive : salaryArchives) { + Date fromDate = salaryArchive.getPayStartDate(); + Date endDate = salaryArchive.getPayEndDate(); + // 起始发薪日不为空,且不能比结束日期晚,最后发薪日可空可不空,但是如果不为空,就不能比开始日期早,且起始发薪日不能晚于最后发薪日 + boolean isEnable = fromDate != null && !fromDate.after(end) && (endDate == null || (!fromDate.after(endDate) && !endDate.before(start))); + if (isEnable) { + SalaryArchiveTaxAgentDataDTO taxAgent = new SalaryArchiveTaxAgentDataDTO(); + taxAgent.setTaxAgentId(salaryArchive.getTaxAgentId()); +// taxAgent.setIncomeCategory(salaryArchive.getIncomeCategory()); +// taxAgent.setSalarySobIds(salaryArchiveSobList.stream().filter(sob->sob.getSalaryArchiveId().equals(salaryArchive.getId())).map(SalaryArchiveSobPO::getSalarySobId).distinct().collect(Collectors.toList())); + taxAgent.setEffectiveDateRange(LocalDateRange.builder().fromDate((fromDate.before(start) ? start : fromDate)).endDate(endDate == null || endDate.after(end) ? end : endDate).build()); + // 薪资项目数据按个税扣缴义务人切割 + if (!isOnlyTaxAgent) { + // 开始日期 + Date startItem = taxAgent.getEffectiveDateRange().getFromDate(); + // 结束日期 + Date endItem = taxAgent.getEffectiveDateRange().getEndDate(); + Date endTempItem = endItem; + List salaryItemValues = new ArrayList<>(); + for (Long salaryArchiveItemId : salaryArchiveItemIds) { + boolean flag = false; + for (SalaryArchiveItemPO salaryArchiveItem : salaryArchiveItems) { + if (!salaryArchiveItemId.equals(salaryArchiveItem.getSalaryItemId()) || !salaryArchiveItem.getSalaryArchiveId().equals(salaryArchive.getId())) { + continue; + } + Date fromDateItem = salaryArchiveItem.getEffectiveTime(); + if (fromDateItem.after(endTempItem) || endTempItem.before(startItem)) { + continue; + } + if (endTempItem.equals(startItem) && flag) { + continue; + } + SalaryArchiveItemDataDTO salaryArchiveItemData = new SalaryArchiveItemDataDTO(); + salaryArchiveItemData.setEffectiveDateRange(LocalDateRange.builder().fromDate((fromDateItem.before(startItem) ? startItem : fromDateItem)).endDate(endTempItem).build()); + salaryArchiveItemData.setSalaryItemId(salaryArchiveItem.getSalaryItemId()); + salaryArchiveItemData.setValue(salaryArchiveItem.getItemValue()); + salaryItemValues.add(salaryArchiveItemData); + flag = true; + endTempItem = fromDateItem; + } + endTempItem = endItem; + } + taxAgent.setSalaryItemValues(salaryItemValues); + } + taxAgents.add(taxAgent); + } + } + salaryArchiveData.setTaxAgents(taxAgents); + list.add(salaryArchiveData); + }); + + return list; + } + + /** + * 构建增量数据 + * + * @param taxAgentEmpChangeList + * @param salaryArchiveList + * @param salaryArchiveItemList + * @param currentEmployeeId + */ + public static ChangeData buildChangeData(List taxAgentEmpChangeList, List salaryArchiveList, List salaryArchiveItemList, Long currentEmployeeId) { + List changeIds = taxAgentEmpChangeList.stream().map(TaxAgentEmpChangePO::getId).collect(Collectors.toList()); + // 根据个税扣缴义务人和人员以及增量类型分组 + Map changeTypeMap = taxAgentEmpChangeList.stream().collect(Collectors.groupingBy(change -> change.getTaxAgentId() + "-" + change.getEmployeeId() + "-" + change.getChangeType(), Collectors.counting())); + // 顺序倒转 + Collections.reverse(taxAgentEmpChangeList); + // 去重 + taxAgentEmpChangeList = taxAgentEmpChangeList.stream() + .collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(f -> f.getTaxAgentId() + "-" + f.getEmployeeId()))), ArrayList::new)); + List taxAgentEmpChanges = taxAgentEmpChangeList + .stream() + // 不相等则保留,否则忽略 + .filter(change -> !Objects.equals(changeTypeMap.get(change.getTaxAgentId() + "-" + change.getEmployeeId() + "-" + TaxAgentEmpChangeTypeEnum.ADD.getValue()) + , changeTypeMap.get(change.getTaxAgentId() + "-" + change.getEmployeeId() + "-" + TaxAgentEmpChangeTypeEnum.DEL.getValue()))) + .collect(Collectors.toList()); + + Date now = new Date(); + Date today = new Date(); + List stopStatus = Arrays.asList(SalaryArchiveStatusEnum.STOP_FROM_PENDING.getValue(), SalaryArchiveStatusEnum.STOP_FROM_SUSPEND.getValue()); + List salaryArchiveAddTodoList = Lists.newArrayList(); + List salaryArchiveUpdateTodoList = Lists.newArrayList(); + List salaryArchiveItemAddTodos = Lists.newArrayList(); + + Map salaryArchiveListMap = SalaryEntityUtil.convert2Map(salaryArchiveList, k -> k.getTaxAgentId() + "-" + k.getEmployeeId()); + taxAgentEmpChanges.forEach(change -> { + SalaryArchivePO salaryArchive = salaryArchiveListMap.get(change.getTaxAgentId() + "-" + change.getEmployeeId()); + // 如果是新增 说明:如果没有档案,则新增,如果有档案而且是停薪,就挪到待定薪中,以个税扣缴义务人和人员id判断唯一 + if (change.getChangeType() == TaxAgentEmpChangeTypeEnum.ADD.getValue()) { + if (salaryArchive != null) { + //存在历史档案不做处理 + +// // 停薪中跳回待定薪:从a调动到b又调动到a,或者是删除待办后再覆盖 +// if (stopStatus.contains(salaryArchive.getRunStatus())) { +// // 跳回待定薪 +// salaryArchive.setRunStatus(SalaryArchiveStatusEnum.PENDING.getValue()); +// if (salaryArchive.getRunStatus().equals(SalaryArchiveStatusEnum.STOP_FROM_SUSPEND.getValue())) { +// salaryArchive.setPayStartDate(today); +// salaryArchive.setPayEndDate(null); +// } +// salaryArchiveUpdateTodoList.add(salaryArchive); +// // 待停薪到停薪的就要复制最新的薪资项目 +// if (salaryArchive.getRunStatus().equals(SalaryArchiveStatusEnum.STOP_FROM_SUSPEND.getValue())) { +// // 拷贝最新的薪资项目数据 +// List salaryArchiveItemValuelList = salaryArchiveItemList.stream().filter(i -> i.getSalaryArchiveId().equals(salaryArchive.getId())).collect(Collectors.toList()); +// salaryArchiveItemValuelList.forEach(i -> { +// salaryArchiveItemAddTodos.add(SalaryArchiveItemPO.builder() +// .id(IdGenerator.generate()) +// .salaryArchiveId(salaryArchive.getId()) +// .employeeId(salaryArchive.getEmployeeId()) +// .effectiveTime(today) +// .adjustReason(SalaryArchiveItemAdjustReasonEnum.INIT.getValue()) +// .salaryItemId(i.getSalaryItemId()) +// .itemValue(i.getItemValue()) +// .description("") +// // 不用设置操作人 +// .operateTime(now) +// .createTime(now) +// .updateTime(now) +// .creator(currentEmployeeId) +// .deleteType(NumberUtils.INTEGER_ZERO) +// .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) +// .build()); +// }); +// } +// } + } else { + salaryArchiveAddTodoList.add(SalaryArchivePO.builder() + .id(IdGenerator.generate()) + .employeeId(change.getEmployeeId()) + .taxAgentId(change.getTaxAgentId()) + .employeeType(change.getEmployeeType()) + .runStatus(SalaryArchiveStatusEnum.PENDING.getValue()) +// .incomeCategory(IncomeCategoryEnum.WAGES_AND_SALARIES.getValue()) +// .modifier(0L) + .createTime(now) + .updateTime(now) + .creator(currentEmployeeId) + .deleteType(NumberUtils.INTEGER_ZERO) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .build()); + } + // 如果是删除 说明:如果有档案并且是在定薪列表才处理,没档案不用管 + } else if (change.getChangeType() == TaxAgentEmpChangeTypeEnum.DEL.getValue()) { + if (salaryArchive != null) { + if (salaryArchive.getRunStatus().equals(SalaryArchiveStatusEnum.FIXED.getValue())) { + // 跳到待停薪 + salaryArchive.setRunStatus(SalaryArchiveStatusEnum.SUSPEND.getValue()); +// salaryArchive.setPayEndDate(today); + salaryArchiveUpdateTodoList.add(salaryArchive); + } else if (salaryArchive.getRunStatus().equals(SalaryArchiveStatusEnum.PENDING.getValue())) { + // 跳到停薪 + salaryArchive.setRunStatus(SalaryArchiveStatusEnum.STOP_FROM_PENDING.getValue()); + salaryArchiveUpdateTodoList.add(salaryArchive); + } + } + } + }); + + return ChangeData.builder() + .salaryArchiveAddTodoList(salaryArchiveAddTodoList) + .salaryArchiveUpdateTodoList(salaryArchiveUpdateTodoList) + .salaryArchiveItemAddTodos(salaryArchiveItemAddTodos) + .changeIds(changeIds) + .build(); + } + + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + public static class ChangeData { + + /** + * 批量修改薪资档案 + */ + private List salaryArchiveAddTodoList; + + /** + * 批量新增薪资档案 + */ + private List salaryArchiveUpdateTodoList; + + /** + * 落库处理薪资项目 + */ + private List salaryArchiveItemAddTodos; + + /** + * 删除增量数据 + */ + private List changeIds; + } + + + public static boolean isNotExtEmp(SalaryArchivePO po) { + return po.getEmployeeType() == null || po.getEmployeeType() == 1; + } +} diff --git a/src/com/engine/salary/entity/salaryarchive/bo/SalaryArchiveExcelBO.java b/src/com/engine/salary/entity/salaryarchive/bo/SalaryArchiveExcelBO.java new file mode 100644 index 000000000..fb69bb2df --- /dev/null +++ b/src/com/engine/salary/entity/salaryarchive/bo/SalaryArchiveExcelBO.java @@ -0,0 +1,911 @@ +package com.engine.salary.entity.salaryarchive.bo; + +import cn.hutool.core.util.NumberUtil; +import com.engine.core.impl.Service; +import com.engine.salary.constant.SalaryDefaultTenantConstant; +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.salaryarchive.dto.SalaryArchiveInitImportDTO; +import com.engine.salary.entity.salaryarchive.dto.SalaryArchiveInitImportSameDTO; +import com.engine.salary.entity.salaryarchive.dto.SalaryItemAdjustValidDTO; +import com.engine.salary.entity.salaryarchive.param.SalaryArchiveImportHandleParam; +import com.engine.salary.entity.salaryarchive.po.SalaryArchiveItemPO; +import com.engine.salary.entity.salaryarchive.po.SalaryArchivePO; +import com.engine.salary.entity.salaryitem.po.SalaryItemPO; +import com.engine.salary.entity.salarysob.param.SalarySobRangeSaveParam; +import com.engine.salary.entity.taxagent.dto.TaxAgentManageRangeEmployeeDTO; +import com.engine.salary.entity.taxagent.param.TaxAgentManageRangeSaveParam; +import com.engine.salary.entity.taxagent.param.TaxAgentRangeSaveParam; +import com.engine.salary.enums.UserStatusEnum; +import com.engine.salary.enums.salaryarchive.*; +import com.engine.salary.enums.salarysob.SalaryEmployeeStatusEnum; +import com.engine.salary.enums.salarysob.TargetTypeEnum; +import com.engine.salary.util.SalaryDateUtil; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.db.IdGenerator; +import com.engine.salary.util.excel.ExcelComment; +import com.google.common.base.Joiner; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.math.NumberUtils; +import weaver.general.Util; +import weaver.hrm.User; + +import java.time.LocalDate; +import java.util.*; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.stream.Collectors; + +/** + * @Description: 薪资档案-excel + * @Author: wangxiangzhong + * @Date: 2021-11-03 10:51 + */ +public class SalaryArchiveExcelBO extends Service { + + public static String userNameI18n; + public static String departmentI18n; + public static String jobNumI18n; + public static String hrStatusI18n; + public static String repeatMsg; + public static String taxAgentI18n; + public static String taxAgentRangeMsg; + public static String empRepeatMsg; + + public static String notEmptyI18n; + + public static String incomeCategoryI18n; + public static String salarySobI18n; + public static String effectiveTimeI18n; + public static String payStartDateI18n; + public static String payEndDateI18n; + public static String adjustReasonI18n; + public static String listTypeErrMsg; + public static String taxAgentNoExist; + public static String incomeCategoryNoExist; + public static String currSalarySobI18n; + public static String noExist; + public static String effectiveTimeErr; + public static String adjustReasonNoExist; + public static String dateErr; + public static String payStartUnableAfterEnd; + + public static String salaryItemNoBeforeCurrentEffectiveTime; + public static String salaryItemAdjustNoSame; + public static String salaryItemAdjustNoSameIneffective; + + public static String salaryArchiveErr; + public static String numberErr; + + /** + * 初始化i18n + */ + public static void initI18n() { + userNameI18n = SalaryI18nUtil.getI18nLabel(85429, "姓名"); + departmentI18n = SalaryI18nUtil.getI18nLabel(86185, "部门"); + jobNumI18n = SalaryI18nUtil.getI18nLabel(86317, "工号"); + hrStatusI18n = SalaryI18nUtil.getI18nLabel(109332, "人事状态"); + repeatMsg = "[" + Joiner.on(",").join(new List[]{Arrays.asList(userNameI18n, departmentI18n, jobNumI18n, hrStatusI18n)}) + "]"; + taxAgentI18n = SalaryI18nUtil.getI18nLabel(86184, "个税扣缴义务人"); + taxAgentRangeMsg = SalaryI18nUtil.getI18nLabel(132633, "该员工不在该个税扣缴义务人的人员范围中") + "," + SalaryI18nUtil.getI18nLabel(127308, "请检查") + repeatMsg; + empRepeatMsg = SalaryI18nUtil.getI18nLabel(121899, "员工信息重复,请检查") + repeatMsg; + + notEmptyI18n = SalaryI18nUtil.getI18nLabel(100577, "不能为空"); + + incomeCategoryI18n = SalaryI18nUtil.getI18nLabel(121908, "收入所得项目"); + salarySobI18n = SalaryI18nUtil.getI18nLabel(87889, "薪资账套"); + effectiveTimeI18n = SalaryI18nUtil.getI18nLabel(85904, "生效日期"); + payStartDateI18n = SalaryI18nUtil.getI18nLabel(109527, "起始发薪日期"); + payEndDateI18n = SalaryI18nUtil.getI18nLabel(109329, "最后发薪日期"); + adjustReasonI18n = SalaryI18nUtil.getI18nLabel(85431, "调整原因"); + + listTypeErrMsg = SalaryI18nUtil.getI18nLabel(115527, "该条数据不符合当前列表导入要求或其他列表存在该档案,不可导入"); + + taxAgentNoExist = SalaryI18nUtil.getI18nLabel(100545, "个税扣缴义务人不存在"); + incomeCategoryNoExist = SalaryI18nUtil.getI18nLabel(121923, "收入所得项目不存在"); + + currSalarySobI18n = SalaryI18nUtil.getI18nLabel(127213, "该收入所得项目"); + noExist = SalaryI18nUtil.getI18nLabel(127236, "不存在"); + + effectiveTimeErr = SalaryI18nUtil.getI18nLabel(102497, "生效日期错误或格式不正确,正确格式示例为'2022-01-01'、'2022/1/1'"); + adjustReasonNoExist = SalaryI18nUtil.getI18nLabel(100591, "调整原因不存在"); + + dateErr = SalaryI18nUtil.getI18nLabel(109819, "日期错误或格式不正确,正确格式示例为'2022-01-01'、'2022/1/1'"); + + payStartUnableAfterEnd = SalaryI18nUtil.getI18nLabel(109214, "起始发薪日期不可晚于最后发薪日"); + + salaryItemNoBeforeCurrentEffectiveTime = SalaryI18nUtil.getI18nLabel(100429, "生效日期不可早于当前已生效的调整日期"); + salaryItemAdjustNoSame = SalaryI18nUtil.getI18nLabel(100432, "调整前后不可相同"); + salaryItemAdjustNoSameIneffective = SalaryI18nUtil.getI18nLabel(100434, "与未生效的调整后不可相同"); + + salaryArchiveErr = SalaryI18nUtil.getI18nLabel(101723, "该员工的薪资档案记录有误,请检查"); + numberErr = SalaryI18nUtil.getI18nLabel(100581, "请输入数字"); + + } + + /** + * 检查导入参数 + * + * @param message + * @param params + * @return + */ + public static String handleCheckParams(Map message, Map params) { + String errorMsg = ""; + + String listType = Optional.ofNullable(params.get("listType")).orElse("").toString(); + String importType = Optional.ofNullable(params.get("importType")).orElse("").toString(); + if (params == null) { + errorMsg = SalaryI18nUtil.getI18nLabel(100582, "参数必传"); + } else if (StringUtils.isEmpty(listType)) { + errorMsg = // SalaryI18nUtil.getI18nLabel( 100592, "导入类型必传") + "," + + SalaryI18nUtil.getI18nLabel(109712, "列表类型必传"); + } else { + Optional optionalListType = Arrays.stream(SalaryArchiveListTypeEnum.values()).filter(e -> e.getValue().equals(listType)).findFirst(); + if (optionalListType.isPresent()) { + // 定薪列表导入有调薪导入和初始化导入 + if (optionalListType.get().getValue().equals(SalaryArchiveListTypeEnum.FIXED.getValue())) { + Optional optional = Arrays.stream(SalaryArchiveImportTypeEnum.values()).filter(e -> e.getValue().equals(params.get("importType").toString())).findFirst(); + if (!optional.isPresent()) { + errorMsg = SalaryI18nUtil.getI18nLabel(100593, "导入类型不正确"); + } else { +// message.setDataType(message.getDataType() +// + "-" + SalaryI18nUtil.getI18nLabel( optionalListType.get().getLabelId(), optionalListType.get().getDefaultLabel()) +// + "-" + SalaryI18nUtil.getI18nLabel( optional.get().getLabelId(), optional.get().getDefaultLabel())); + } + } else { +// message.setDataType(message.getDataType() +// + "-" + SalaryI18nUtil.getI18nLabel( optionalListType.get().getLabelId(), optionalListType.get().getDefaultLabel())); + } + } else { + errorMsg = SalaryI18nUtil.getI18nLabel(109716, "列表类型不正确"); + } + } + return errorMsg; + } + + /** + * 检查导入列 + * + * @param importHandleParam + * @param headers + * @return + */ + public static String handleCheckHeaders(SalaryArchiveImportHandleParam importHandleParam, Map message, List headers) { + + List headerList = headers; + + List mustHeaders = Lists.newArrayList(); + + if (!importHandleParam.isProcess()) { + //流程中可以使用人员id + mustHeaders.add(userNameI18n); + } + mustHeaders.add(taxAgentI18n); +// mustHeaders.add(incomeCategoryI18n); +// mustHeaders.add(salarySobI18n); + if (importHandleParam.isPendingList()) { + mustHeaders.add(payStartDateI18n); + mustHeaders.add(payEndDateI18n); + } else if (importHandleParam.isFixedList()) { + if (importHandleParam.isInit()) { + mustHeaders.add(payStartDateI18n); + mustHeaders.add(payEndDateI18n); + mustHeaders.add(effectiveTimeI18n); + } else if (importHandleParam.isSalaryItemAdjust()) { + mustHeaders.add(adjustReasonI18n); + mustHeaders.add(effectiveTimeI18n); + } + } else if (importHandleParam.isSuspendList()) { + mustHeaders.add(payEndDateI18n); + } + // 缺少的必须列 + List lackHeaders = mustHeaders.stream().filter(item -> !headerList.contains(item)).collect(Collectors.toList()); + String checkHeaderI18n = SalaryI18nUtil.getI18nLabel(101850, "缺少如下列,请检查:"); + + return CollectionUtils.isNotEmpty(lackHeaders) ? checkHeaderI18n + Joiner.on(",").join((Iterable) lackHeaders) : ""; + } + + /** + * 创建excel单元格注释 + * + * @param excelComments + * @param commentData + * @param startRowIndex + * @param endRowIndex + * @param startColIndex + * @param endColIndex + */ + public static void createExcelComment(List excelComments, String commentData, int startRowIndex, int endRowIndex, int startColIndex, int endColIndex) { + ExcelComment excelComment = new ExcelComment(); + // 起始行,结束行,起始列,结束列 +// excelComment.setCommentSheet(new Integer[]{startRowIndex, endRowIndex, startColIndex, endColIndex}); +// excelComment.setCommentRange(new Integer[]{startRowIndex, endRowIndex, startColIndex, endColIndex}); +// excelComment.setCommentData(commentData); + excelComments.add(excelComment); + } + + /** + * 初始化导入数据校验 + * 说明:如果一个人的多条记录中有一个错那么就全部弄到错误文档中 + * + * @param isError + * @param rowNo + * @param map + * @param excelComments + * @param errorCount + * @param successCount + * @param errorData + * @param initImportData + * @param importHandleParam + * @return + */ + public static Map validInitImportData(boolean isError, int rowNo, Map map, List> excelComments, int errorCount, int successCount, List> errorData, List initImportData, SalaryArchiveImportHandleParam importHandleParam) { + Long employeeId = Long.valueOf(Optional.ofNullable(map.get("employeeId")).orElse("0").toString()); + Long taxAgentId = Long.valueOf(Optional.ofNullable(map.get("taxAgentId")).orElse("0").toString()); + Map validMap = new HashMap<>(); + validMap.put("errorCount", errorCount); + validMap.put("successCount", successCount); + if (employeeId.equals(0L) || taxAgentId.equals(0L)) { + return validMap; + } + Optional optionalInitImport = initImportData.stream().filter(f -> f.getEmployeeId().equals(employeeId) && f.getTaxAgentId().equals(taxAgentId)).findFirst(); + AtomicInteger finalErrorCount = new AtomicInteger(errorCount); + AtomicInteger finalSuccessCount = new AtomicInteger(successCount); + if (optionalInitImport.isPresent()) { + SalaryArchiveInitImportDTO initImport = optionalInitImport.get(); + List sames = initImport.getSames(); + sames.add(SalaryArchiveInitImportSameDTO.builder() + .isError(isError) + .rowNo(rowNo) + .row(map) + .build()); + Optional optionalSame = sames.stream().filter(SalaryArchiveInitImportSameDTO::isError).findFirst(); + // 只要是其中一行有错误 + if (optionalSame.isPresent()) { + sames.forEach(e -> { + if (!e.isError()) { + e.setError(Boolean.TRUE); + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", "第" + (e.getRowNo() + 1) + "行" + salaryArchiveErr); + excelComments.add(errorMessageMap); +// SalaryArchiveExcelBO.createExcelComment(excelComments, salaryArchiveErr, finalErrorCount.get() + 1, finalErrorCount.get() + 1, 0, 0); + finalErrorCount.addAndGet(1); + errorData.add(e.getRow()); + finalSuccessCount.addAndGet(-1); + } + }); + // 如果到目前为止都没错的话,则相互之间检验调整记录 + } else { + int nums = sames.size(); + // 1.生效时间不可重复 + List effectiveTimeList = sames.stream().map(m -> Optional.ofNullable(m.getRow().get("effectiveTime")).orElse("").toString()).distinct().collect(Collectors.toList()); + // 2.薪资项目共同决定是否重复 + List rowSameList = sames.stream().map(m -> { + Map row = m.getRow(); + return Optional.ofNullable(row.get("salaryItemVal")).orElse("").toString(); + }).distinct().collect(Collectors.toList()); + if (effectiveTimeList.size() != nums || rowSameList.size() != nums) { + sames.forEach(e -> { + if (!e.isError()) { + e.setError(Boolean.TRUE); + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", "第" + (e.getRowNo() + 1) + "行" + salaryArchiveErr); + excelComments.add(errorMessageMap); +// SalaryArchiveExcelBO.createExcelComment(excelComments, salaryArchiveErr, finalErrorCount.get() + 1, finalErrorCount.get() + 1, 0, 0); + finalErrorCount.addAndGet(1); + errorData.add(e.getRow()); + finalSuccessCount.addAndGet(-1); + } + }); + } + } + initImport.setSames(sames); + } else { + SalaryArchiveInitImportDTO initImport = new SalaryArchiveInitImportDTO(); + initImport.setEmployeeId(employeeId); + initImport.setTaxAgentId(taxAgentId); + List sames = Lists.newArrayList(); + sames.add(SalaryArchiveInitImportSameDTO.builder() + .isError(isError) + .rowNo(rowNo) + .row(map) + .build()); + initImport.setSames(sames); + initImportData.add(initImport); + } + // 如果出现错误 + if (isError || errorCount != finalErrorCount.get() || successCount != finalSuccessCount.get()) { + validMap.put("errorCount", finalErrorCount.get()); + validMap.put("successCount", finalSuccessCount.get()); + // 将前面添加好的数据给过滤掉 + List salaryArchiveIds = importHandleParam.getSalaryArchiveSaves().stream().filter(f -> f.getEmployeeId().equals(employeeId) && f.getTaxAgentId().equals(taxAgentId)).map(SalaryArchivePO::getId).collect(Collectors.toList()); + importHandleParam.setSalaryArchiveSaves(importHandleParam.getSalaryArchiveSaves().stream().filter(f -> !salaryArchiveIds.contains(f.getId())).collect(Collectors.toList())); + importHandleParam.setSalaryArchiveItemSaves(importHandleParam.getSalaryArchiveItemSaves().stream().filter(f -> !salaryArchiveIds.contains(f.getSalaryArchiveId())).collect(Collectors.toList())); + } + return validMap; + } + + /** + * 校验单行数据 + * + * @param allTodoSalaryArchives + * @param map + * @param headers + * @param effectiveTimeIndex + * @param excelComments + * @param errorCount + * @param importHandleParam + * @return + */ + public static boolean singleRowCheck(List allTodoSalaryArchives, Map map, List headers, int effectiveTimeIndex, List> excelComments, int errorCount, SalaryArchiveImportHandleParam importHandleParam, User user) { + //是否是流程 + boolean process = importHandleParam.isProcess(); + + boolean isError = false; + String rowindex = "第" + map.get("index") + "行"; + // 1.姓名 + String userName = Optional.ofNullable(map.get(userNameI18n)).orElse("").toString(); + String deparmentName = Optional.ofNullable(map.get(departmentI18n)).orElse("").toString(); + String mobileName = Optional.ofNullable(map.get("手机号")).orElse("").toString(); + String workcode = Optional.ofNullable(map.get("工号")).orElse("").toString(); + String idNo = Optional.ofNullable(map.get("证件号码")).orElse("").toString(); + + String validType = importHandleParam.getEmpValidType(); + List emps = new ArrayList<>(); + //外部人员 + if (importHandleParam.isExtEmp()) { + emps = importHandleParam.getEmployees().stream().filter(e -> + (StringUtils.isBlank(userName) || Objects.equals(e.getUsername(), userName)) + && (StringUtils.isBlank(deparmentName) || Objects.equals(e.getDepartmentName(), deparmentName)) + && (StringUtils.isBlank(mobileName) || Objects.equals(e.getMobile(), mobileName))).collect(Collectors.toList()); + } else { + if ("0".equals(validType)) { + //“0”代表姓名+部门+手机号的匹配原则,“1”代表工号为唯一匹配原则 + emps = importHandleParam.getEmployees().stream().filter(e -> + (StringUtils.isBlank(userName) || Objects.equals(e.getUsername(), userName)) + && (StringUtils.isBlank(deparmentName) || Objects.equals(e.getDepartmentName(), deparmentName)) + && (StringUtils.isBlank(mobileName) || Objects.equals(e.getMobile(), mobileName))).collect(Collectors.toList()); + } else if ("1".equals(validType)) { + emps = importHandleParam.getEmployees().stream().filter(e -> (StringUtils.isBlank(workcode) || Objects.equals(e.getWorkcode(), workcode))) + .collect(Collectors.toList()); + } + else if ("2".equals(validType)) { + emps = importHandleParam.getEmployees().stream().filter(e -> (StringUtils.isBlank(idNo) || Objects.equals(e.getIdNo(), idNo))) + .collect(Collectors.toList()); + } + } + + List employeeSameIds = new ArrayList<>(); + if (CollectionUtils.isNotEmpty(emps) && emps.size() > 1) { + employeeSameIds = emps.stream().filter(e -> UserStatusEnum.getNormalStatus().contains(e.getStatus())).map(DataCollectionEmployee::getEmployeeId).collect(Collectors.toList()); + } + if (CollectionUtils.isNotEmpty(emps) && emps.size() == 1) { + employeeSameIds = emps.stream().map(DataCollectionEmployee::getEmployeeId).collect(Collectors.toList()); + } + Long employeeId = CollectionUtils.isNotEmpty(employeeSameIds) && employeeSameIds.size() == 1 && employeeSameIds.get(0) > 0 ? employeeSameIds.get(0) : null; + + //员工id 流程使用 + String empId = Optional.ofNullable(map.get("员工id")).orElse("").toString(); + if (StringUtils.isNotBlank(empId)) { + employeeSameIds.clear(); + employeeSameIds.add(Long.valueOf(empId)); + employeeId = Long.valueOf(empId); + } + + if (employeeId == null) { + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowindex + "查找人员失败,请确定姓名、部门、手机号正确且唯一"); + excelComments.add(errorMessageMap); + isError = true; + return isError; + } + + + // 用于初始化导入数据校验 + map.put("employeeId", employeeId); +// String incomeCategoryCellVal = Optional.ofNullable(map.get(incomeCategoryI18n)).orElse("").toString(); +// Integer incomeCategory = SalaryArchiveBO.getIncomeCategoryValueByLabel(incomeCategoryCellVal, importHandleParam.getCurrentEmployeeId(), importHandleParam.getTenantKey()); + // 薪资账套 +// String salarySobCellVal = Optional.ofNullable(map.get(salarySobI18n)).orElse("").toString(); + // 2.生效日期 + String effectiveTimeCellVal = Optional.ofNullable(map.get(effectiveTimeI18n)).orElse("").toString().replaceAll(" 00:00:00", ""); + // 免得失败后,会追加 00:00:00 + map.put(effectiveTimeI18n, effectiveTimeCellVal); + map.put("effectiveTime", effectiveTimeCellVal); + Date effectiveTime = SalaryDateUtil.checkDay(effectiveTimeCellVal) ? SalaryDateUtil.dateStrToLocalDate(effectiveTimeCellVal) : null; + // 3.个税扣缴义务人 + String taxAgentCellVal = Optional.ofNullable(map.get(taxAgentI18n)).orElse("").toString(); + // 用于初始化导入的同一个人的记录校验 + map.put("taxAgent", taxAgentCellVal); + Optional optionalTaxAgent = importHandleParam.getTaxAgentList().stream().filter(m -> m.getTaxAgentName().equals(taxAgentCellVal)).findFirst(); + Long taxAgentId = optionalTaxAgent.map(TaxAgentManageRangeEmployeeDTO::getTaxAgentId).orElse(null); + + List finalEmployeeSameIds = employeeSameIds; + if (!optionalTaxAgent.isPresent()) { + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowindex + "个税扣缴义务人不存在"); + excelComments.add(errorMessageMap); + isError = true; + return isError; + } + Optional optionalTaxAgentEmp = optionalTaxAgent.get().getEmployeeList().stream().filter(f -> finalEmployeeSameIds.contains(f.getEmployeeId())).findFirst(); + if (!optionalTaxAgentEmp.isPresent()) { + if (process) { + //定薪流程中自动将人员添加进个税扣缴义务人中 + TaxAgentManageRangeSaveParam.TaxAgentSubAdminRangeTargetParam taxAgentSubAdminRangeTargetParam = new TaxAgentManageRangeSaveParam.TaxAgentSubAdminRangeTargetParam(); + taxAgentSubAdminRangeTargetParam.setTargetId(employeeId); + taxAgentSubAdminRangeTargetParam.setTargetType(TargetTypeEnum.EMPLOYEE); + + TaxAgentRangeSaveParam taxAgentRangeSaveParam = new TaxAgentRangeSaveParam(); + taxAgentRangeSaveParam.setTaxAgentId(taxAgentId); + taxAgentRangeSaveParam.setIncludeType(1); + taxAgentRangeSaveParam.setEmployeeStatus(Arrays.asList("0", "1", "2", "3", "4", "5", "6")); + taxAgentRangeSaveParam.setTargetParams(Collections.singletonList(taxAgentSubAdminRangeTargetParam)); + taxAgentRangeSaveParam.setSync(true); + importHandleParam.setTaxAgentRanges(Collections.singletonList(taxAgentRangeSaveParam)); + } +// else { +// Map errorMessageMap = Maps.newHashMap(); +// errorMessageMap.put("message", rowindex + taxAgentRangeMsg); +// excelComments.add(errorMessageMap); +//// SalaryArchiveExcelBO.createExcelComment(excelComments, taxAgentRangeMsg, errorCount + 1, errorCount + 1, 0, 0); +// isError = true; +// return isError; +// } + } else { + employeeId = optionalTaxAgentEmp.get().getEmployeeId(); + // 除了定薪中的初始化,其他导入存在相同的取第一条 + if (employeeId != null && taxAgentId != null && allTodoSalaryArchives.contains(employeeId + "-" + taxAgentId) && !importHandleParam.isInit()) { + return isError; + } + if (employeeId != null && taxAgentId != null) { + allTodoSalaryArchives.add(employeeId + "-" + taxAgentId); + } + } + + // 用于初始化导入重复记录判错 ===start + map.put("employeeId", employeeId); + map.put("taxAgentId", taxAgentId); + // 用于初始化导入重复记录判错 ===end + + // 4.调整原因[薪资项目] + String adjustReason = SalaryArchiveItemAdjustReasonEnum.getValueByDefaultLabel(Optional.ofNullable(map.get(adjustReasonI18n)).orElse("").toString()); + // 5.起始发薪日期 + String payStartDateCellVal = Optional.ofNullable(map.get(payStartDateI18n)).orElse("").toString().replaceAll(" 00:00:00", ""); + // 免得失败后,会追加 00:00:00 + map.put(payStartDateI18n, payStartDateCellVal); + map.put("payStartDate", payStartDateCellVal); + Date payStartDate = SalaryDateUtil.checkDay(payStartDateCellVal) ? SalaryDateUtil.dateStrToLocalDate(payStartDateCellVal) : null; + //生效日期默认取起始发薪日期 + if (effectiveTime == null) { + effectiveTime = payStartDate; + } + // 6.最后发薪日期 + String payEndDateCellVal = Optional.ofNullable(map.get(payEndDateI18n)).orElse("").toString().replaceAll(" 00:00:00", ""); + // 免得失败后,会追加 00:00:00 + map.put(payEndDateI18n, payEndDateCellVal); + map.put("payEndDate", payEndDateCellVal); + Date payEndDate = SalaryDateUtil.checkDay(payEndDateCellVal) ? SalaryDateUtil.dateStrToLocalDate(payEndDateCellVal) : null; + + // 构建薪资档案 + SalaryArchivePO finalSalaryArchive = buildSalaryArchive(employeeId, taxAgentId, importHandleParam); + // 不满足构建条件 + if (finalSalaryArchive == null) { + // SalaryI18nUtil.getI18nLabel( 100579, "姓名错误,系统内不存在该姓名") + // SalaryI18nUtil.getI18nLabel( 101653, "该人员的薪资档案不存在,请先初始化" + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowindex + listTypeErrMsg); + excelComments.add(errorMessageMap); +// SalaryArchiveExcelBO.createExcelComment(excelComments, listTypeErrMsg, errorCount + 1, errorCount + 1, 0, 0); + isError = true; + return isError; + } else { + map.put("salaryArchiveId", finalSalaryArchive.getId()); + } + for (int j = 0; j < headers.size(); j++) { + String header = headers.get(j); + Object key = header; + if (key == null) { + continue; + } + String cellVal = Optional.ofNullable(map.get(key.toString())).orElse("").toString(); + + // 必填判空 + boolean isEmpty = StringUtils.isEmpty(cellVal) && + ((userNameI18n.equals(key.toString()) && !process) || taxAgentI18n.equals(key.toString()) || incomeCategoryI18n.equals(key.toString()) || salarySobI18n.equals(key.toString()) + // 定薪列表初始化导入必填: 起始发薪日期、生效日期 + || ((payStartDateI18n.equals(key.toString()) || effectiveTimeI18n.equals(key.toString())) && importHandleParam.isInit()) + // 定薪列表调薪必填: 调整原因、生效日期 + || ((adjustReasonI18n.equals(key.toString()) || effectiveTimeI18n.equals(key.toString())) && importHandleParam.isSalaryItemAdjust()) + // 待停薪必填:最后发薪日期 + || (payEndDateI18n.equals(key.toString()) && importHandleParam.isSuspendList())); + boolean isNotEmpty = StringUtils.isNotEmpty(cellVal); + // 判空 + if (isEmpty) { + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowindex + header + notEmptyI18n); + excelComments.add(errorMessageMap); +// SalaryArchiveExcelBO.createExcelComment(excelComments, notEmptyI18n, errorCount + 1, errorCount + 1, j, j); + isError = true; + } + // 1.姓名列处理 + if (isNotEmpty && userNameI18n.equals(key.toString())) { + if (CollectionUtils.isEmpty(employeeSameIds) || employeeSameIds.size() > 1) { + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowindex + header + empRepeatMsg); + excelComments.add(errorMessageMap); +// SalaryArchiveExcelBO.createExcelComment(excelComments, empRepeatMsg, errorCount + 1, errorCount + 1, j, j); + isError = true; + } + // 2.个税扣缴义务人列处理 + } else if (isNotEmpty && taxAgentI18n.equals(key.toString())) { + if (taxAgentId == null) { + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowindex + header + taxAgentNoExist); + excelComments.add(errorMessageMap); +// SalaryArchiveExcelBO.createExcelComment(excelComments, taxAgentNoExist, errorCount + 1, errorCount + 1, j, j); + isError = true; + } + // 收入所得项目 + } +// else if (isNotEmpty && incomeCategoryI18n.equals(key.toString())) { +// if (incomeCategory == null) { +// SalaryArchiveExcelBO.createExcelComment(excelComments, incomeCategoryNoExist, errorCount + 1, errorCount + 1, j, j); +// isError = true; +// } else { +// finalSalaryArchive.setIncomeCategory(incomeCategory); +// } + // 薪资账套 +// } +// else if (isNotEmpty && salarySobI18n.equals(key.toString())) { +// List salarySobNames = Arrays.stream(salarySobCellVal.split(",")).distinct().collect(Collectors.toList()); +// List salarySobIds = Lists.newArrayList(); +// importHandleParam.getSalarySobList().forEach(sob -> { +// List incomeCategorys = StringUtils.isEmpty(sob.getIncomeCategory()) ? Lists.newArrayList() : JsonUtil.parseList(sob.getIncomeCategory(), Integer.class); +// if (salarySobNames.contains(sob.getName()) && incomeCategory != null && incomeCategorys.contains(incomeCategory)) { +// salarySobIds.add(sob.getId()); +// salarySobNames.remove(sob.getName()); +// } +// }); +// if (CollectionUtils.isNotEmpty(salarySobNames)) { +// SalaryArchiveExcelBO.createExcelComment(excelComments, currSalarySobI18n + (StringUtils.isEmpty(incomeCategoryCellVal) ? "" : "[" + incomeCategoryCellVal + "]") + ": " + salarySobI18n + "[" + Joiner.on(",").join(salarySobNames) + "]" + noExist, errorCount + 1, errorCount + 1, j, j); +// isError = true; +// } else { +// finalSalaryArchive.setIncomeCategory(incomeCategory); +// importHandleParam.getSalaryArchiveSobSaves().addAll(SalaryArchiveBO.buildSalaryArchiveSob(finalSalaryArchive.getId(), salarySobIds, importHandleParam.getNowTime(), importHandleParam.getCurrentEmployeeId(), importHandleParam.getTenantKey())); +// } + // 3.生效时间处理(定薪的调薪\定薪的初始化) +// } + else if (isNotEmpty && effectiveTimeI18n.equals(key.toString()) && effectiveTime == null && importHandleParam.isFixedList()) { + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowindex + header + effectiveTimeErr); + excelComments.add(errorMessageMap); +// SalaryArchiveExcelBO.createExcelComment(excelComments, effectiveTimeErr, errorCount + 1, errorCount + 1, j, j); + isError = true; + // 4.调整原因列(定薪的调薪) + } else if (isNotEmpty && adjustReasonI18n.equals(key.toString()) && StringUtils.isEmpty(adjustReason) && importHandleParam.isSalaryItemAdjust()) { + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowindex + header + adjustReasonNoExist); + excelComments.add(errorMessageMap); +// SalaryArchiveExcelBO.createExcelComment(excelComments, adjustReasonNoExist, errorCount + 1, errorCount + 1, j, j); + isError = true; + // 5.起始发薪日期处理(定薪的初始化\待定新) + } else if (isNotEmpty && payStartDateI18n.equals(key.toString()) && (importHandleParam.isInit() || importHandleParam.isPendingList())) { + if (payStartDate == null) { + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowindex + header + dateErr); + excelComments.add(errorMessageMap); +// SalaryArchiveExcelBO.createExcelComment(excelComments, dateErr, errorCount + 1, errorCount + 1, j, j); + isError = true; + } + // 正确的话,并且定薪或待定薪的档案存在 + if (payStartDate != null) { + if (payEndDate != null || finalSalaryArchive.getPayEndDate() != null) { + Date payEndDateTemp = payEndDate != null ? payEndDate : (finalSalaryArchive.getPayEndDate() != null ? finalSalaryArchive.getPayEndDate() : null); + // todo 1.定薪的允许编辑,若已存在已归档的核算数据则不可编辑 + + if (payEndDateTemp != null && payStartDate.after(payEndDateTemp)) { + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowindex + header + payStartUnableAfterEnd); + excelComments.add(errorMessageMap); +// SalaryArchiveExcelBO.createExcelComment(excelComments, payStartUnableAfterEnd, errorCount + 1, errorCount + 1, j, j); + isError = true; + } + } + // 2.待停薪只能不允许编辑起始发薪日期 + if (!importHandleParam.isSuspendList() && !isError) { + finalSalaryArchive.setPayStartDate(payStartDate); + } + } + // 6.最后发薪日期处理(待定薪\定薪的初始化\待停薪) + } else if (payEndDateI18n.equals(key.toString()) && !importHandleParam.isSalaryItemAdjust()) { + if (isNotEmpty) { + if (payEndDate == null) { + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowindex + header + dateErr); + excelComments.add(errorMessageMap); +// SalaryArchiveExcelBO.createExcelComment(excelComments, dateErr, errorCount + 1, errorCount + 1, j, j); + isError = true; + } + if (payEndDate != null) { + if (payStartDate != null || finalSalaryArchive.getPayStartDate() != null) { + Date payStartDateTemp = payStartDate != null ? payStartDate : (finalSalaryArchive.getPayStartDate() != null ? finalSalaryArchive.getPayStartDate() : null); + // todo 1.定薪的允许编辑,若已存在已归档的核算数据则不可编辑 + + // 2.待停薪只能不允许编辑起始发薪日期 + if (importHandleParam.isSuspendList()) { + payStartDateTemp = finalSalaryArchive.getPayStartDate(); + } + if (payStartDateTemp != null && payStartDateTemp.after(payEndDate)) { + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowindex + header + payStartUnableAfterEnd); + excelComments.add(errorMessageMap); +// SalaryArchiveExcelBO.createExcelComment(excelComments, payStartUnableAfterEnd, errorCount + 1, errorCount + 1, j, j); + isError = true; + } + } + if (!isError) { + finalSalaryArchive.setPayEndDate(payEndDate); + } + } + } else { + finalSalaryArchive.setPayEndDate(null); + } + // 7.薪资项目列处理(待定薪\定薪的初始化\定薪的调薪) + } else { + isError = handleSalaryItem(isError, effectiveTimeIndex, excelComments, errorCount, j, + effectiveTime, finalSalaryArchive, adjustReason, importHandleParam, key.toString(), cellVal, map, user); + } + } + + //账套关联 + Long finalEmployeeId = employeeId; + String sobIds = Optional.ofNullable(map.get("薪资账套ids")).orElse("").toString(); + List salarySobRangeSaveParams = new ArrayList<>(); + if (StringUtils.isNotBlank(sobIds)) { + salarySobRangeSaveParams = Arrays.stream(sobIds.split(",")).map(Long::valueOf).map(sobId -> { + + SalarySobRangeSaveParam.SalarySobRangeTargetParam salarySobRangeTargetParam = new SalarySobRangeSaveParam.SalarySobRangeTargetParam(); + salarySobRangeTargetParam.setTargetId(finalEmployeeId); + salarySobRangeTargetParam.setTargetType(TargetTypeEnum.EMPLOYEE); + salarySobRangeTargetParam.setEmployeeStatus(SalaryEmployeeStatusEnum.values()); + + SalarySobRangeSaveParam sobRangeSaveParam = new SalarySobRangeSaveParam(); + sobRangeSaveParam.setSalarySobId(sobId); + sobRangeSaveParam.setTargetParams(Collections.singletonList(salarySobRangeTargetParam)); + sobRangeSaveParam.setIncludeType(1); + sobRangeSaveParam.setEmployeeStatus(SalaryEmployeeStatusEnum.values()); + + return sobRangeSaveParam; + }).collect(Collectors.toList()); + } + + + // 如果当前校验行没问题,修改起始发薪日期和最终发薪日期等 + if (!isError) { + Optional optionalUpdate = importHandleParam.getSalaryArchiveUpdates().stream().filter(f -> f.getId().equals(finalSalaryArchive.getId())).findFirst(); + boolean unEnable = finalSalaryArchive.getPayStartDate() != null && finalSalaryArchive.getPayEndDate() != null && finalSalaryArchive.getPayStartDate().after(finalSalaryArchive.getPayEndDate()); + if (optionalUpdate.isPresent() && !unEnable) { + List updates = importHandleParam.getSalaryArchiveUpdates().stream().filter(f -> !f.getId().equals(finalSalaryArchive.getId())).collect(Collectors.toList()); + updates.add(finalSalaryArchive); + importHandleParam.setSalaryArchiveUpdates(updates); + } + Optional optionalSave = importHandleParam.getSalaryArchiveSaves().stream().filter(f -> f.getId().equals(finalSalaryArchive.getId())).findFirst(); + if (optionalSave.isPresent() && !unEnable) { + List saves = importHandleParam.getSalaryArchiveSaves().stream().filter(f -> !f.getId().equals(finalSalaryArchive.getId())).collect(Collectors.toList()); + saves.add(finalSalaryArchive); + importHandleParam.setSalaryArchiveSaves(saves); + } + //保存账套关联 + importHandleParam.setSalaryArchiveSobSaves(salarySobRangeSaveParams); + } else { + // 将前面添加好的数据给过滤掉 + importHandleParam.setSalaryArchiveSaves(importHandleParam.getSalaryArchiveSaves().stream().filter(f -> !finalSalaryArchive.getId().equals(f.getId())).collect(Collectors.toList())); + importHandleParam.setSalaryArchiveUpdates(importHandleParam.getSalaryArchiveUpdates().stream().filter(f -> !finalSalaryArchive.getId().equals(f.getId())).collect(Collectors.toList())); + importHandleParam.setSalaryArchiveItemDelSalaryItemIds(importHandleParam.getSalaryArchiveItemDelSalaryItemIds().stream().filter(f -> !finalSalaryArchive.getId().equals(f)).collect(Collectors.toList())); + importHandleParam.setSalaryArchiveItemSaves(importHandleParam.getSalaryArchiveItemSaves().stream().filter(f -> !finalSalaryArchive.getId().equals(f.getSalaryArchiveId())).collect(Collectors.toList())); +// importHandleParam.setSalaryArchiveSobSaves(importHandleParam.getSalaryArchiveSobSaves().stream().filter(f -> !finalSalaryArchive.getId().equals(f.getSalaryArchiveId())).collect(Collectors.toList())); + } + + return isError; + } + + /** + * 字符串转日期 + * 兼容/和- + * + * @param effectiveTime + * @return + */ + public static LocalDate dateStrToLocalDate(String effectiveTime) { + LocalDate localDate = null; + try { + if (effectiveTime.contains("/")) { + String[] strs = effectiveTime.split("/"); + localDate = LocalDate.of(Integer.parseInt(strs[0]), Integer.parseInt(strs[1]), Integer.parseInt(strs[2])); + } else if (effectiveTime.contains("-")) { + String[] strs = effectiveTime.replaceAll("-0", "-").split("-"); + // localDate = LocalDate.parse(effectiveTime, DateTimeFormatter.ofPattern("yyyy-MM-dd")); // 月份日期超过最大会被改为最大 + localDate = LocalDate.of(Integer.parseInt(strs[0]), Integer.parseInt(strs[1]), Integer.parseInt(strs[2])); + } + } catch (Exception e) { + } + + return localDate; + } + + /** + * 构建薪资档案对象 + * + * @param employeeId + * @param taxAgentId + * @param importHandleParam + * @return + */ + public static SalaryArchivePO buildSalaryArchive(Long employeeId, Long taxAgentId, SalaryArchiveImportHandleParam importHandleParam) { + SalaryArchivePO salaryArchive = importHandleParam.getSalaryArchivesMap().get(employeeId + "-" + taxAgentId); + if (salaryArchive != null) { + // 修改档案 + SalaryArchivePO sa = salaryArchive; + boolean isEnabled = + // 待定薪导入 + (sa.getRunStatus().equals(SalaryArchiveStatusEnum.PENDING.getValue()) && importHandleParam.isPendingList()) + // 调薪导入 + || ((sa.getRunStatus().equals(SalaryArchiveStatusEnum.FIXED.getValue()) || sa.getRunStatus().equals(SalaryArchiveStatusEnum.SUSPEND.getValue())) && importHandleParam.isFixedList() && !importHandleParam.isInit()) + // 初始化导入 + || importHandleParam.isInit() + // 待停薪导入 + || ((sa.getRunStatus().equals(SalaryArchiveStatusEnum.FIXED.getValue()) || sa.getRunStatus().equals(SalaryArchiveStatusEnum.SUSPEND.getValue())) && importHandleParam.isSuspendList()); + if (isEnabled) { + if (importHandleParam.isInit() && + (importHandleParam.getKeepStatus() == null || importHandleParam.getKeepStatus().equals(Boolean.FALSE))) { + sa.setRunStatus(SalaryArchiveStatusEnum.FIXED.getValue()); + } +// sa.setModifier(importHandleParam.getCurrentEmployeeId()); + salaryArchive = sa; + + importHandleParam.getSalaryArchiveUpdates().add(salaryArchive); + } + } else if (employeeId != null && taxAgentId != null && importHandleParam.isInit()) { + // 新增档案 + salaryArchive = SalaryArchivePO.builder() + .id(IdGenerator.generate()) + .employeeId(employeeId) + .taxAgentId(taxAgentId) + .runStatus(SalaryArchiveStatusEnum.FIXED.getValue()) + .createTime(importHandleParam.getNowTime()) + .updateTime(importHandleParam.getNowTime()) + .creator(importHandleParam.getCurrentEmployeeId()) +// .modifier(importHandleParam.getCurrentEmployeeId()) + .deleteType(NumberUtils.INTEGER_ZERO) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .employeeType(importHandleParam.isExtEmp() ? 1 : null) + .build(); + // 定薪action 保持状态为待定薪 + if (importHandleParam.isInit() && importHandleParam.getKeepStatus() != null && importHandleParam.getKeepStatus().equals(Boolean.TRUE)) { + salaryArchive.setRunStatus(SalaryArchiveStatusEnum.PENDING.getValue()); + } + importHandleParam.getSalaryArchiveSaves().add(salaryArchive); + } + return salaryArchive; + } + + /** + * 薪资项目处理 + * + * @param isError + * @param effectiveTimeIndex + * @param excelComments + * @param errorCount + * @param j + * @param effectiveTime + * @param finalSalaryArchive + * @param salaryItemAdjustReason + * @param importHandleParam + * @param key + * @param cellVal + * @param map + * @return + */ + public static boolean handleSalaryItem(boolean isError, int effectiveTimeIndex, + List> excelComments, int errorCount, int j, + Date effectiveTime, SalaryArchivePO finalSalaryArchive, String salaryItemAdjustReason, SalaryArchiveImportHandleParam importHandleParam, + String key, String cellVal, Map map, User user) { + + String rowindex = "第" + map.get("index") + "行"; + // 薪资项目数据 + if (isError || importHandleParam.isSuspendList() || (importHandleParam.isSalaryItemAdjust() && effectiveTime == null) || finalSalaryArchive == null) { + return isError; + } + Optional optionalSalaryItem = importHandleParam.getSalaryItems().stream().filter(e -> Util.formatMultiLang(e.getName(), String.valueOf(user.getLanguage())).equals(key)).findFirst(); + // 可以处理薪资项目的条件:有薪资项目+待定薪列表+定薪列表(调薪和初始化导入) + boolean isEnable = optionalSalaryItem.isPresent() && (importHandleParam.isPendingList() || importHandleParam.isInit() || importHandleParam.isSalaryItemAdjust()); + if (isEnable) { + SalaryItemPO salaryItemPO = optionalSalaryItem.get(); + // 数值类型判断 + boolean isNotNumber = salaryItemPO.getDataType().equals(SalaryArchiveFieldTypeEnum.NUMBER.getValue()) && StringUtils.isNotEmpty(cellVal) && !NumberUtil.isNumber(cellVal); + if (isNotNumber) { + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowindex + key + numberErr); + excelComments.add(errorMessageMap); +// SalaryArchiveExcelBO.createExcelComment(excelComments, numberErr, errorCount + 1, errorCount + 1, j, j); + isError = true; + return isError; + } + Long salaryItemId = salaryItemPO.getId(); + // 已生效 + List effectiveList = Optional.ofNullable(importHandleParam.getEffectiveItemListMap().get(finalSalaryArchive.getId() + "-" + salaryItemId)).orElse(Lists.newArrayList()); + // 当前已生效 + SalaryArchiveItemPO effectiveSalaryItem = CollectionUtils.isNotEmpty(effectiveList) && effectiveList.size() > 0 ? effectiveList.get(0) : null; + // 当前已生效的前一次调整 + SalaryArchiveItemPO effectiveBeforeSalaryItem = CollectionUtils.isNotEmpty(effectiveList) && effectiveList.size() > 1 ? effectiveList.get(1) : null; + // 未生效 + List ineffectiveItemList = importHandleParam.getIneffectiveItemListMap().get(finalSalaryArchive.getId() + "-" + salaryItemId); + SalaryArchiveItemPO ineffectiveSalaryItem = CollectionUtils.isEmpty(ineffectiveItemList) ? null : ineffectiveItemList.get(0); + // 待定薪和初始化:先删除后新增 + if (importHandleParam.isPendingList() || importHandleParam.isInit()) { + // 已经生效的 + importHandleParam.getSalaryArchiveItemDelSalaryItemIds().addAll(effectiveList.stream().map(SalaryArchiveItemPO::getId).collect(Collectors.toList())); + if (ineffectiveSalaryItem != null) { + importHandleParam.getSalaryArchiveItemDelSalaryItemIds().add(ineffectiveSalaryItem.getId()); + } + // 定薪列表调薪 + } else if (importHandleParam.isSalaryItemAdjust()) { + SalaryItemAdjustValidDTO salaryItemAdjustValid = SalaryArchiveItemBO.handleSalaryItemAdjustValid(effectiveSalaryItem, effectiveBeforeSalaryItem, ineffectiveSalaryItem, effectiveTime, importHandleParam.getToday(), cellVal, importHandleParam.getSalaryArchiveItemDelSalaryItemIds()); + if (salaryItemAdjustValid.isBefore()) { + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowindex + key + salaryItemNoBeforeCurrentEffectiveTime); + excelComments.add(errorMessageMap); + isError = true; + } else if (salaryItemAdjustValid.isSame()) { +// Map errorMessageMap = Maps.newHashMap(); +// errorMessageMap.put("message", rowindex + key + salaryItemAdjustNoSame); +// excelComments.add(errorMessageMap); +// isError = true; + + //调整前后相同的值都不做处理 + cellVal = ""; + } else if (salaryItemAdjustValid.isSameIneffective()) { +// Map errorMessageMap = Maps.newHashMap(); +// errorMessageMap.put("message", rowindex + key + salaryItemAdjustNoSameIneffective); +// excelComments.add(errorMessageMap); +// isError = true; + //调整前后相同的值都不做处理 + cellVal = ""; + } + } + // 导入时不需要处理的薪资项目 + boolean isInitNull = CollectionUtils.isEmpty(effectiveList) && CollectionUtils.isEmpty(ineffectiveItemList) && StringUtils.isEmpty(cellVal); + if (!isError && !isInitNull && StringUtils.isNotBlank(cellVal) && (importHandleParam.isPendingList() || importHandleParam.isInit() || importHandleParam.isSalaryItemAdjust())) { + importHandleParam.getSalaryArchiveItemSaves().add(SalaryArchiveItemPO.builder() + .id(IdGenerator.generate()) + .salaryArchiveId(finalSalaryArchive.getId()) + .employeeId(finalSalaryArchive.getEmployeeId()) + .effectiveTime(effectiveTime == null ? new Date() : effectiveTime) +// .adjustWay(SalaryArchiveAdjustWayEnum.IMPORT.getValue()) + .adjustReason(StringUtils.isEmpty(salaryItemAdjustReason) ? SalaryArchiveItemAdjustReasonEnum.INIT.getValue() : salaryItemAdjustReason) + .salaryItemId(salaryItemId) + .itemValue(cellVal) + .description(importHandleParam.getDescription() == null ? "" : importHandleParam.getDescription()) + .operator(importHandleParam.getCurrentEmployeeId()) + .operateTime(importHandleParam.getNowTime()) + .createTime(importHandleParam.getNowTime()) + .updateTime(importHandleParam.getNowTime()) + .creator(importHandleParam.getCurrentEmployeeId()) + .deleteType(NumberUtils.INTEGER_ZERO) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .build()); + } + // 用于初始化导入,同一个人的多行记录之间的薪资项目是否调整 + map.put("salaryItemVal", Optional.ofNullable(map.get("salaryItemVal")).orElse("").toString() + salaryItemId + cellVal); + } + return isError; + } + + @Override + public String toString() { + return "SalaryArchiveExcelBO{}"; + } +} diff --git a/src/com/engine/salary/entity/salaryarchive/bo/SalaryArchiveItemBO.java b/src/com/engine/salary/entity/salaryarchive/bo/SalaryArchiveItemBO.java new file mode 100644 index 000000000..0a321fa0e --- /dev/null +++ b/src/com/engine/salary/entity/salaryarchive/bo/SalaryArchiveItemBO.java @@ -0,0 +1,462 @@ +package com.engine.salary.entity.salaryarchive.bo; + +import com.engine.salary.entity.salaryarchive.dto.SalaryItemAdjustValidDTO; +import com.engine.salary.entity.salaryarchive.po.SalaryArchiveItemPO; +import com.google.common.collect.Lists; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; +import java.util.List; + +/** + * @Description: 薪资档案-薪资项目 + * @Author: wangxiangzhong + * @Date: 2021-11-03 10:51 + */ +public class SalaryArchiveItemBO { + @Override + public String toString() { + return "SalaryArchiveItemBO{}"; + } + + public static List buildLogEntity(List salaryArchiveItemSaves) { + List salaryArchiveItemSaveLogs = Lists.newArrayList(); + for (SalaryArchiveItemPO sai : salaryArchiveItemSaves) { + // BeanUtils.copyProperties(sai, saiNew);性能差 + salaryArchiveItemSaveLogs.add(SalaryArchiveItemPO.builder() + .id(sai.getId()) + .salaryArchiveId(sai.getSalaryArchiveId()) + .employeeId(sai.getEmployeeId()) + .effectiveTime(sai.getEffectiveTime()) + .adjustReason(sai.getAdjustReason()) + .salaryItemId(sai.getSalaryItemId()) + .itemValue(sai.getItemValue()) + .description(sai.getDescription()) + .operator(sai.getOperator()) + .operateTime(sai.getOperateTime()) + .createTime(sai.getCreateTime()) + .updateTime(sai.getUpdateTime()) + .creator(sai.getCreator()) + .deleteType(sai.getDeleteType()) + .tenantKey(sai.getTenantKey()) + .build()); + } + return salaryArchiveItemSaveLogs; + } + + /** + * 构建薪资项目基础信息表单 + * + * @param isView + * @param effectiveTime + * @param adjustReason + * @param description + * @param employeeId + * @param tenantKey + * @return + */ +// public static WeaForm buildSalaryArchiveItemForm(boolean isView, Date effectiveTime, String adjustReason, String description, Long employeeId, String tenantKey) { +// WeaForm salaryItemForm = SalaryFormatUtil.getInstance().buildForm(SalaryArchiveItemBaseDTO.class, SalaryArchiveItemBaseDTO.builder().build()); +// WeaFormItem descriptionItem = salaryItemForm.getItems().get("description"); +// if (!isView) { +// Map otherParams = Maps.newHashMap(); +// otherParams.put("showCount", true); +// otherParams.put("placeholder", SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 85987, "请输入")); +// descriptionItem.setOtherParams(otherParams); +// salaryItemForm.getItems().put("description", descriptionItem); +// } else { +// WeaFormItem effectiveTimeItem = salaryItemForm.getItems().get("effectiveTime"); +// effectiveTimeItem.setRequired(false); +// effectiveTimeItem.setReadOnly(true); +// salaryItemForm.getItems().put("effectiveTime", effectiveTimeItem); +// WeaFormItem adjustReasonItem = salaryItemForm.getItems().get("adjustReason"); +// adjustReasonItem.setRequired(false); +// adjustReasonItem.setReadOnly(true); +// salaryItemForm.getItems().put("adjustReason", adjustReasonItem); +// descriptionItem.setReadOnly(true); +// salaryItemForm.getItems().put("description", descriptionItem); +// } +// // 控件数据 +// Map data = salaryItemForm.getData(); +// data.put("effectiveTime", effectiveTime + ""); +// data.put("adjustReason", adjustReason); +// data.put("description", description); +// +// salaryItemForm.setData(data); +// return salaryItemForm; +// } + + /** + * 构建薪资档案调整明细 + * + * @param isView + * @param tableData + * @param salaryItemList + * @param employeeId + * @param tenantKey + * @return + */ +// public static EditableTable> buildSalaryArchiveItemAdjustDetailTable(boolean isView, List> tableData, List salaryItemList, Long employeeId, String tenantKey) { +// WeaTable> adjustDetailTable = new WeaTable<>(); +// adjustDetailTable.setPageUid(UUID.randomUUID().toString()); +// adjustDetailTable.setModule("hrmsalary"); +// +// List> salaryItems = salaryItemList.stream().map(m -> { +// Map salaryItemMap = new LinkedHashMap<>(); +// salaryItemMap.put("id", String.valueOf(m.getId())); +// salaryItemMap.put("content", m.getName()); +// salaryItemMap.put("dataType", m.getDataType()); +// return salaryItemMap; +// }).collect(Collectors.toList()); +// +// Page> page = new Page<>(0, 0, 0, false); +// page.setRecords(tableData); +// adjustDetailTable.setPage(page); +// adjustDetailTable.setDisplayData(tableData); +// adjustDetailTable.setTableType(isView ? WeaTableTypeEnum.NONE : WeaTableTypeEnum.CHECKBOX); +// +// EditableTable> editableTable = new EditableTable<>(adjustDetailTable); +// editableTable.setColumns(SalaryArchiveItemBO.buildRecordTableColumns(isView, employeeId, tenantKey)); +// editableTable.setComProps(SalaryArchiveItemBO.buildEditableTableItemMap(isView, salaryItems)); +// return editableTable; +// } + + /** + * 构建调薪记录表格 + * + * @param isView + * @param employeeId + * @param tenantKey +// * @return +// */ +// public static List buildRecordTableColumns(boolean isView, Long employeeId, String tenantKey) { +// List result = Lists.newArrayListWithExpectedSize(3); +// result.add(new SalaryWeaTableColumn(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 84960, "薪资项目"), "salaryItem", "150", WeaAlignEnum.CENTER.getStringVal(), "salaryItem", !isView)); +// result.add(new SalaryWeaTableColumn(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 85433, "调整前"), "salaryBefore", "150", WeaAlignEnum.CENTER.getStringVal(), "salaryBefore")); +// result.add(new SalaryWeaTableColumn(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 85434, "调整后"), "adjustAfter", "150", WeaAlignEnum.CENTER.getStringVal(), "adjustAfter", !isView)); +// return result; +// } + + /** + * 构建调薪记录表格字段 + * + * @param isView + * @param salaryItems + * @return + */ +// public static Map buildEditableTableItemMap(boolean isView, List> salaryItems) { +// Map resultMap = Maps.newHashMapWithExpectedSize(9); +// resultMap.put("salaryItem", new EditableTableItem(EditableTableItemType.SELECT, "", salaryItems, !isView, isView)); +// resultMap.put("salaryBefore", new EditableTableItem(EditableTableItemType.INPUT, "", true)); +// resultMap.put("adjustAfter", new EditableTableItem(EditableTableItemType.INPUT, "", null, !isView, isView)); +// return resultMap; +// } + + /** + * 处理调整记录 + * + * @param list + * @param hrmStatusList + * @param listMap + * @param employeeId + * @param tenantKey + */ +// public static void handleSalaryItemAdjustRecord(List list, List hrmStatusList, Map> listMap, Long employeeId, String tenantKey) { +// Map hrmStatusNameMap = SalaryEntityUtil.convert2Map(hrmStatusList, hrmStatus -> String.valueOf(hrmStatus.getCodeId()), HrmStatus::getName); +// list.forEach(m -> { +// List singleSalaryArchiveItems = Optional.ofNullable(listMap.get(m.getSalaryArchiveId() + "-" + m.getSalaryItemId())).orElse(Lists.newArrayList()); +// // 调整前 +// m.setAdjustAfter(CollectionUtils.isEmpty(singleSalaryArchiveItems) ? "" : singleSalaryArchiveItems.get(0).getItemValue()); +// if (!CollectionUtils.isEmpty(singleSalaryArchiveItems)) { +// singleSalaryArchiveItems.removeIf(a -> a.getId().equals(m.getId())); +// } +// SalaryArchiveItemPO salaryArchiveItem = CollectionUtils.isEmpty(singleSalaryArchiveItems) ? null : singleSalaryArchiveItems.get(0); +// // 调整后 +// m.setAdjustBefore(salaryArchiveItem == null ? "" : salaryArchiveItem.getItemValue()); +// +// m.setEmployeeStatus(Optional.ofNullable(hrmStatusNameMap.get(m.getEmployeeStatus())).orElse("")); +// m.setAdjustReason(SalaryArchiveItemAdjustReasonEnum.getDefaultLabelByValue(m.getAdjustReason(), employeeId, tenantKey)); +// }); +// } + + /** + * 薪资项目调整记录列表的高级搜索 + * + * @param conditionId + * @param userStatusOptions + * @param employeeId + * @param tenantKey + * @return + */ +// public static WeaSearchCondition getAdjustRecordSearchCondition(String conditionId, List userStatusOptions, Long employeeId, String tenantKey) { +// WeaSearchCondition weaSearchCondition = SalaryFormatUtil.getInstance() +// .buildCondition(SalaryItemAdjustRecordSearchConditionDTO.class, +// SalaryItemAdjustRecordSearchConditionDTO.builder() +// .userStatusOptions(userStatusOptions) +// .build(), +// conditionId); +// // 生效日期-添加范围 +// SalaryArchiveBO.addDatePickerRangeOtherParams(weaSearchCondition, "effectiveTime", employeeId, tenantKey); +// // 操作日期-添加范围 +// SalaryArchiveBO.addDatePickerRangeOtherParams(weaSearchCondition, "operateTime", employeeId, tenantKey); +// // 只保留常用条件 +// weaSearchCondition.setGroups(weaSearchCondition.getGroups().stream().filter(e -> "commonGroup".equals(e.getId())).collect(Collectors.toList())); +// return weaSearchCondition; +// } + + /** + * 构建调薪记录表格 + * + * @param adjustRecordTypeEnum + * @param effectiveItemListMap + * @param page + * @return + */ +// public static WeaTable buildSalaryItemAdjustRecordTable(SalaryArchiveAdjustRecordTypeEnum adjustRecordTypeEnum, Map> effectiveItemListMap, Page page) { +// WeaTable weaTable = FormatManager.getInstance().genTable(SalaryItemAdjustRecordListDTO.class, page); +// if (adjustRecordTypeEnum.equals(SalaryArchiveAdjustRecordTypeEnum.ADJUSTRECORD)) { +// /** +// * 行记录按钮权限控制 +// * 说明: +// * 1.早于当前已生效的则只有【查看】权限; +// * 2.等于当前已生效的有【编辑】、【操作日志】权限; +// * 3.未生效的有【编辑】、【删除】、【操作日志】权限; +// */ +// for (int i = 0; i < page.getRecords().size(); i++) { +// SalaryItemAdjustRecordListDTO salaryItemAdjustRecord = page.getRecords().get(i); +// Optional optional = CollectionUtils.emptyIfNull(effectiveItemListMap.get(salaryItemAdjustRecord.getSalaryArchiveId() + "-" + salaryItemAdjustRecord.getSalaryItemId())).stream().findFirst(); +// Date effectiveDate = optional.map(SalaryArchiveItemPO::getEffectiveTime).orElse(null); +// List permissions = weaTable.getOperatesPermission().get(i); +// for (int j = 0; j < permissions.size(); j++) { +// Permission permission = permissions.get(j); +// if (j > 0 && effectiveDate != null && salaryItemAdjustRecord.getEffectiveTime().isBefore(effectiveDate)) { +// permission.setVisible(false); +// permission.setDisabled(true); +// } else if (effectiveDate != null +// && ((j == 0 && !salaryItemAdjustRecord.getEffectiveTime().isBefore(effectiveDate)) +// || (j == 2 && salaryItemAdjustRecord.getEffectiveTime().equals(effectiveDate)))) { +// permission.setVisible(false); +// permission.setDisabled(false); +// } +// } +// } +// } +// // 除了删除列表,其他不需要复选框 +// if (!adjustRecordTypeEnum.equals(SalaryArchiveAdjustRecordTypeEnum.ADJUSTRECORDFORDELETE)) { +// weaTable.setTableType(WeaTableTypeEnum.NONE); +// } +// // 除了调薪列表,其他不需要操作列 +// if (!adjustRecordTypeEnum.equals(SalaryArchiveAdjustRecordTypeEnum.ADJUSTRECORD)) { +// weaTable.setOperates(Collections.emptyList()); +// } +// // 在外展示操作按钮 +// CollectionUtils.emptyIfNull(weaTable.getOperates()).forEach(operate -> { +// if (operate.getIndex() < 2) { +// operate.setOuter(Boolean.TRUE); +// } +// }); +// weaTable.setPageUid(adjustRecordTypeEnum.getPageUid()); +// weaTable.setModule("hrmsalary"); +// return weaTable; +// } + + /** + * 构建单个档案调薪记录表格 + * + * @param effectiveItemListMap + * @param salaryArchiveId + * @param pageUid + * @param listPage + * @return + */ +// public static WeaTable buildSingleSalaryItemAdjustRecordTable(Map> effectiveItemListMap, Long salaryArchiveId, String pageUid, Page listPage) { +// WeaTable weaTable = FormatManager.getInstance().genTable(SingleSalaryItemAdjustRecordListDTO.class, listPage); +// weaTable.setModule("hrmsalary"); +// // 行记录按钮权限控制 +// for (int i = 0; i < listPage.getRecords().size(); i++) { +// SingleSalaryItemAdjustRecordListDTO singleSalaryItemAdjustRecord = listPage.getRecords().get(i); +// Optional optional = CollectionUtils.emptyIfNull(effectiveItemListMap.get(salaryArchiveId + "-" + singleSalaryItemAdjustRecord.getSalaryItemId())).stream().findFirst(); +// Date effectiveDate = optional.map(SalaryArchiveItemPO::getEffectiveTime).orElse(null); +// List permissions = weaTable.getOperatesPermission().get(i); +// for (int j = 0; j < permissions.size(); j++) { +// Permission permission = permissions.get(j); +// if (SalaryArchiveAdjustWayEnum.BATCH.getValue().equals(singleSalaryItemAdjustRecord.getAdjustWay()) || (effectiveDate != null && singleSalaryItemAdjustRecord.getEffectiveTime().isBefore(effectiveDate))) { +// permission.setVisible(false); +// permission.setDisabled(true); +// } else if (j > 0 && singleSalaryItemAdjustRecord.getEffectiveTime().equals(effectiveDate)) { +// permission.setVisible(false); +// permission.setDisabled(false); +// } +// } +// } +// // 在外展示操作按钮 +// weaTable.getOperates().get(0).setOuter(Boolean.TRUE); +// weaTable.setPageUid(pageUid); +// return weaTable; +// } + + /** + * 构建变更数据 + * + * @return + */ +// public static ChangeData buildChangeData(SalaryArchivePO salaryArchive, SalaryArchiveItemSaveParam saveParam, List salaryArchiveItems, Map> effectiveItemListMap, Map> ineffectiveItemListMap, Long employeeId, String tenantKey) { +// // 待保存生效时间 +// Date saveEffectiveTime = saveParam.getEffectiveTime(); +// // 当天 +// Date today = Date.now(); +// // 当前时间 +// LocalDateTime nowTime = LocalDateTime.now(); +// +// List effectiveSalaryItemDels = Lists.newArrayList(); +// List salaryArchiveItemNews = Lists.newArrayList(); +// salaryArchiveItems.forEach(e -> { +// boolean isNotNumber = e.getDataType().equals(SalaryArchiveFieldTypeEnum.NUMBER.getValue()) && StringUtils.isNotEmpty(e.getAdjustValue()) && !Pattern.matches(SalaryArchiveConstant.NUMBER_REGEX, e.getAdjustValue()); +// if (isNotNumber) { +// throw new SalaryRunTimeException(e.getName() + ":" + SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 100581, "请输入数字")); +// } +// // 已生效 +// List effectiveList = Optional.ofNullable(effectiveItemListMap.get(salaryArchive.getId() + "-" + e.getSalaryItemId())).orElse(Lists.newArrayList()); +// // 当前已生效 +// SalaryArchiveItemPO effectiveSalaryItem = CollectionUtils.isNotEmpty(effectiveList) && effectiveList.size() > 0 ? effectiveList.get(0) : null; +// // 当前已生效的前一次调整 +// SalaryArchiveItemPO effectiveBeforeSalaryItem = CollectionUtils.isNotEmpty(effectiveList) && effectiveList.size() > 1 ? effectiveList.get(1) : null; +// // 未生效 +// SalaryArchiveItemPO ineffectiveSalaryItem = CollectionUtils.isEmpty(ineffectiveItemListMap.get(salaryArchive.getId() + "-" + e.getSalaryItemId())) ? null : ineffectiveItemListMap.get(salaryArchive.getId() + "-" + e.getSalaryItemId()).get(0); +// SalaryItemAdjustValidDTO salaryItemAdjustValid = handleSalaryItemAdjustValid(effectiveSalaryItem, effectiveBeforeSalaryItem, ineffectiveSalaryItem, saveEffectiveTime, today, e.getAdjustValue(), effectiveSalaryItemDels); +// if (salaryItemAdjustValid.isBefore()) { +// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 100429, "生效日期不可早于当前已生效的调整日期")); +// } else if (salaryItemAdjustValid.isSame()) { +// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 100432, "调整前后不可相同")); +// } else if (salaryItemAdjustValid.isSameIneffective()) { +// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 100434, "与未生效的调整后不可相同")); +// } +// +// salaryArchiveItemNews.add(SalaryArchiveItemBO.buildInsert(salaryArchive, e.getSalaryItemId(), e.getAdjustValue(), saveParam, nowTime, employeeId, tenantKey)); +// }); +// return ChangeData.builder() +// .effectiveSalaryItemDels(effectiveSalaryItemDels) +// .salaryArchiveItemNews(salaryArchiveItemNews) +// .build(); +// } + + /** + * 薪资项目调整校验处理 + * + * @param effectiveSalaryItem + * @param effectiveBeforeSalaryItem + * @param ineffectiveSalaryItem + * @param saveEffectiveTime + * @param today + * @param adjustValue + * @param salaryArchiveItemDelIds + * @return + */ + public static SalaryItemAdjustValidDTO handleSalaryItemAdjustValid(SalaryArchiveItemPO effectiveSalaryItem, + SalaryArchiveItemPO effectiveBeforeSalaryItem, + SalaryArchiveItemPO ineffectiveSalaryItem, + Date saveEffectiveTime, + Date today, + String adjustValue, + List salaryArchiveItemDelIds) { + + boolean isBefore = false; + boolean isSame = false; + boolean isSameIneffective = false; + if (effectiveSalaryItem != null) { + // 当前已经生效的时间 + Date effectiveTime = effectiveSalaryItem.getEffectiveTime(); + // 1.1 如果早于<当前已生效 + if (saveEffectiveTime.before(effectiveTime)) { + isBefore = true; + // 1.2 如果等于当前已生效 + } else if (saveEffectiveTime.equals(effectiveTime)) { + if (effectiveBeforeSalaryItem != null && effectiveBeforeSalaryItem.getItemValue().equals(adjustValue)) { + isSame = true; + } + if (ineffectiveSalaryItem != null && ineffectiveSalaryItem.getItemValue().equals(adjustValue)) { + isSameIneffective = true; + } + // 1.3 如果>已经生效且<=今天 + } else if (saveEffectiveTime.after(effectiveTime) && !saveEffectiveTime.after(today)) { + if (effectiveSalaryItem.getItemValue().equals(adjustValue)) { + isSame = true; + } + if (ineffectiveSalaryItem != null && ineffectiveSalaryItem.getItemValue().equals(adjustValue)) { + isSameIneffective = true; + } + // 1.4 如果>今天 + } else if (saveEffectiveTime.after(today) && effectiveSalaryItem.getItemValue().equals(adjustValue)) { + isSame = true; + } + } else if (ineffectiveSalaryItem != null && ineffectiveSalaryItem.getItemValue().equals(adjustValue)) { + isSameIneffective = true; + } + boolean isError = isBefore || isSame || isSameIneffective; + // 2.数据处理 + if (!isError && effectiveSalaryItem != null && saveEffectiveTime.equals(effectiveSalaryItem.getEffectiveTime())) { + salaryArchiveItemDelIds.add(effectiveSalaryItem.getId()); + } + if (!isError && ineffectiveSalaryItem != null && saveEffectiveTime.after(today)) { + salaryArchiveItemDelIds.add(ineffectiveSalaryItem.getId()); + } + return SalaryItemAdjustValidDTO.builder() + .isBefore(isBefore) + .isSame(isSame) + .isSameIneffective(isSameIneffective) + .salaryArchiveItemDelIds(salaryArchiveItemDelIds) + .build(); + } + +// /** +// * 插入 +// * +// * @param salaryArchive +// * @param saveParam +// * @param nowTime +// * @param employeeId +// * @param tenantKey +// */ +// public static SalaryArchiveItemPO buildInsert(SalaryArchivePO salaryArchive, Long salaryItemId, String adjustValue, SalaryArchiveItemSaveParam saveParam, LocalDateTime nowTime, Long employeeId, String tenantKey) { +// return SalaryArchiveItemPO.builder() +// .id(IdGenerator.generate()) +// .salaryArchiveId(saveParam.getSalaryArchiveId()) +// .employeeId(salaryArchive.getEmployeeId()) +// .effectiveTime(saveParam.getEffectiveTime()) +// .adjustWay(SalaryArchiveAdjustWayEnum.SINGLE.getValue()) +// .adjustReason(saveParam.getAdjustReason().getValue()) +// .description(saveParam.getDescription()) +// .salaryItemId(salaryItemId) +// // 调整后 +// .itemValue(adjustValue) +// .operator(employeeId) +// .operateTime(nowTime) +// .createTime(LocalDateTime.now()) +// .updateTime(LocalDateTime.now()) +// .creator(employeeId) +// .deleteType(NumberUtils.INTEGER_ZERO) +// .tenantKey(tenantKey) +// .build(); +// } + + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + public static class ChangeData { + + /** + * 薪资档案-项目删除 + */ + List effectiveSalaryItemDels; + + /** + * 薪资档案-项目新增 + */ + List salaryArchiveItemNews; + } + +} diff --git a/src/com/engine/salary/entity/salaryarchive/bo/TaxAgentBO.java b/src/com/engine/salary/entity/salaryarchive/bo/TaxAgentBO.java new file mode 100644 index 000000000..f60d27327 --- /dev/null +++ b/src/com/engine/salary/entity/salaryarchive/bo/TaxAgentBO.java @@ -0,0 +1,70 @@ +package com.engine.salary.entity.salaryarchive.bo; + +import com.engine.salary.entity.salaryarchive.dto.TaxAgentListDTO; +import com.engine.salary.entity.salaryarchive.param.TaxAgentSaveParam; +import com.engine.salary.entity.taxrate.TaxAgent; +import org.apache.commons.collections4.CollectionUtils; + +import java.util.Collection; +import java.util.Collections; +import java.util.Date; +import java.util.List; +import java.util.stream.Collectors; + +/** + * 个税扣缴义务人 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class TaxAgentBO { + + @Override + public String toString() { + return "TaxAgentBO{}"; + } + + /** + * 表数据转列表数据 + * @param individualTaxWithholdingAgents + * @param tenantKey + * @return + */ + public static List convertToListDTO(Collection individualTaxWithholdingAgents, String tenantKey) { + if (CollectionUtils.isEmpty(individualTaxWithholdingAgents)) { + return Collections.emptyList(); + } + return individualTaxWithholdingAgents.stream() + .map(e -> TaxAgentListDTO.builder() + .id(e.getId()) + .name(e.getName()) + .description(e.getDescription()) + .build()) + .collect(Collectors.toList()); + } + + /** + * 保存参数转表数据 + * @param saveParam + * @param employeeId + * @param tenantKey + * @return + */ + public static TaxAgent convertToPO(TaxAgentSaveParam saveParam, Long employeeId, String tenantKey) { + if (saveParam == null) { + return null; + } + Date now = new Date(); + return TaxAgent.builder() + .id(saveParam.getId()) + .name(saveParam.getName()) + .description(saveParam.getDescription()) + .createTime(now) + .updateTime(now) + .creator(employeeId) + .tenantKey(tenantKey) + .build(); + } +} diff --git a/src/com/engine/salary/entity/salaryarchive/config/ArchiveFieldConfig.java b/src/com/engine/salary/entity/salaryarchive/config/ArchiveFieldConfig.java new file mode 100644 index 000000000..bd4a1568a --- /dev/null +++ b/src/com/engine/salary/entity/salaryarchive/config/ArchiveFieldConfig.java @@ -0,0 +1,24 @@ +package com.engine.salary.entity.salaryarchive.config; + +import com.engine.salary.entity.salaryitem.po.SalaryItemPO; +import com.thoughtworks.xstream.annotations.XStreamAlias; +import com.thoughtworks.xstream.annotations.XStreamImplicit; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@XStreamAlias("ArchiveFieldConfig") +public class ArchiveFieldConfig { + + @XStreamImplicit + List salaryItems; + +} diff --git a/src/com/engine/salary/entity/salaryarchive/dto/DimissionSetFormDTO.java b/src/com/engine/salary/entity/salaryarchive/dto/DimissionSetFormDTO.java new file mode 100644 index 000000000..0a4244afb --- /dev/null +++ b/src/com/engine/salary/entity/salaryarchive/dto/DimissionSetFormDTO.java @@ -0,0 +1,36 @@ +package com.engine.salary.entity.salaryarchive.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 离职时段设置表单 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +////离职时段设置表单") +public class DimissionSetFormDTO { + +// @SalaryForm( +// label = "已离职时段", +// labelId = 93330, +// items = { +// @SalaryFormItem(itemType = WeaFormItemType.SELECT, required = true, options = "getDimissionTimeIntervalOptions()") +// } +// ) +// //已离职时段") + private String dimissionTimeInterval; + +// private List getDimissionTimeIntervalOptions () { +// return Arrays.stream(SalaryArchiveDimissionTimeIntervalEnum.values()).map(m->new WeaFormOption(String.valueOf(m.getValue()), SalaryI18nUtil.getI18nLabel(TenantContext.getCurrentTenantKey(), UserContext.getCurrentEmployeeId(), m.getLabelId(), m.getDefaultLabel()))).collect(Collectors.toList()); +// } +} diff --git a/src/com/engine/salary/entity/salaryarchive/dto/SalaryArchiveBaseInfoFormDTO.java b/src/com/engine/salary/entity/salaryarchive/dto/SalaryArchiveBaseInfoFormDTO.java new file mode 100644 index 000000000..dbe67cb51 --- /dev/null +++ b/src/com/engine/salary/entity/salaryarchive/dto/SalaryArchiveBaseInfoFormDTO.java @@ -0,0 +1,91 @@ +package com.engine.salary.entity.salaryarchive.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 薪资档案-基本信息 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +////薪资档案-基本信息") +public class SalaryArchiveBaseInfoFormDTO { + +// @SalaryForm( +// label = "姓名", +// labelId = 85429, +// layout = "0", +// items = { +// @SalaryFormItem(itemType = WeaFormItemType.INPUT, readOnly = true) +// } +// ) +// //姓名") + private String username; + + +// @SalaryForm( +// label = "部门", +// labelId = 86185, +// layout = "0", +// items = { +// @SalaryFormItem(itemType = WeaFormItemType.INPUT, readOnly = true) +// } +// ) +// //部门") + private String department; + + +// @SalaryForm( +// label = "岗位", +// labelId = 90633, +// layout = "0", +// items = { +// @SalaryFormItem(itemType = WeaFormItemType.INPUT, readOnly = true) +// } +// ) +// //岗位") + private String position; + +// @SalaryForm( +// label = "入职日期", +// labelId = 86319, +// layout = "1", +// items = { +// @SalaryFormItem(itemType = WeaFormItemType.INPUT, readOnly = true) +// } +// ) +// //入职日期") + private String hiredate; + +// @SalaryForm( +// label = "手机号", +// labelId = 86186, +// layout = "1", +// items = { +// @SalaryFormItem(itemType = WeaFormItemType.INPUT, readOnly = true) +// } +// ) +// //手机号") + private String mobile; + +// @SalaryForm( +// label = "个税扣缴义务人", +// labelId = 86184, +// layout = "1", +// items = { +// @SalaryFormItem(itemType = WeaFormItemType.INPUT, readOnly = true) +// } +// ) +// //个税扣缴义务人") + private String taxAgent; + +} diff --git a/src/com/engine/salary/entity/salaryarchive/dto/SalaryArchiveDataDTO.java b/src/com/engine/salary/entity/salaryarchive/dto/SalaryArchiveDataDTO.java new file mode 100644 index 000000000..674cca29c --- /dev/null +++ b/src/com/engine/salary/entity/salaryarchive/dto/SalaryArchiveDataDTO.java @@ -0,0 +1,29 @@ +package com.engine.salary.entity.salaryarchive.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * 薪资档案数据 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalaryArchiveDataDTO { + + //人员id + private Long employeeId; + + //个税扣缴义务人 + private List taxAgents; +} diff --git a/src/com/engine/salary/entity/salaryarchive/dto/SalaryArchiveFormDTO.java b/src/com/engine/salary/entity/salaryarchive/dto/SalaryArchiveFormDTO.java new file mode 100644 index 000000000..dca0f284c --- /dev/null +++ b/src/com/engine/salary/entity/salaryarchive/dto/SalaryArchiveFormDTO.java @@ -0,0 +1,43 @@ +package com.engine.salary.entity.salaryarchive.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; +import java.util.Map; + +/** + * 薪资档案 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//员工薪资档案 +public class SalaryArchiveFormDTO { + + //主键id + private Long id; + + //人员信息表的主键id + private Long employeeId; + + //基本信息 + private Map baseInfo; + + /** + * 发薪设置 + */ + private Map paySet; + + //薪资档案 + private List> adjustSalaryItems; + +} diff --git a/src/com/engine/salary/entity/salaryarchive/dto/SalaryArchiveInitImportDTO.java b/src/com/engine/salary/entity/salaryarchive/dto/SalaryArchiveInitImportDTO.java new file mode 100644 index 000000000..11f60015a --- /dev/null +++ b/src/com/engine/salary/entity/salaryarchive/dto/SalaryArchiveInitImportDTO.java @@ -0,0 +1,37 @@ +package com.engine.salary.entity.salaryarchive.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * 薪资档案初始化导入记录 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalaryArchiveInitImportDTO { + /** + * 人员id + */ + private Long employeeId; + + /** + * 个税扣缴义务人id + */ + private Long taxAgentId; + + /** + * 同一个人的多条记录 + */ + private List sames; +} diff --git a/src/com/engine/salary/entity/salaryarchive/dto/SalaryArchiveInitImportSameDTO.java b/src/com/engine/salary/entity/salaryarchive/dto/SalaryArchiveInitImportSameDTO.java new file mode 100644 index 000000000..e1ce3ef44 --- /dev/null +++ b/src/com/engine/salary/entity/salaryarchive/dto/SalaryArchiveInitImportSameDTO.java @@ -0,0 +1,38 @@ +package com.engine.salary.entity.salaryarchive.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Map; + +/** + * 薪资档案初始化导入相同记录 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalaryArchiveInitImportSameDTO { + + /** + * 当前行是否错误 + */ + private boolean isError; + + /** + * 行索引 + */ + private int rowNo; + + /** + * 对应行数据 + */ + private Map row; +} diff --git a/src/com/engine/salary/entity/salaryarchive/dto/SalaryArchiveItemBaseDTO.java b/src/com/engine/salary/entity/salaryarchive/dto/SalaryArchiveItemBaseDTO.java new file mode 100644 index 000000000..479581e4e --- /dev/null +++ b/src/com/engine/salary/entity/salaryarchive/dto/SalaryArchiveItemBaseDTO.java @@ -0,0 +1,56 @@ +package com.engine.salary.entity.salaryarchive.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 薪资项目调整-基本调整信息 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//薪资项目调整-基本调整信息") +public class SalaryArchiveItemBaseDTO { + +// @SalaryForm( +// label = "生效日期", +// labelId = 85904, +// items = { +// @SalaryFormItem(itemType = WeaFormItemType.DATEPICKER, required = true) +// } +// ) +// //生效日期") + private String effectiveTime; + +// @SalaryForm( +// label = "调整原因", +// labelId = 85431, +// items = { +// @SalaryFormItem(itemType = WeaFormItemType.SELECT, required = true, maxLength = "50", options = "getAdjustReasonOptions()") +// } +// ) +// //调整原因") + private Long adjustReason; + +// private List getAdjustReasonOptions () { +// return Arrays.stream(SalaryArchiveItemAdjustReasonEnum.values()).map(m->new WeaFormOption(String.valueOf(m.getValue()), SalaryI18nUtil.getI18nLabel(TenantContext.getCurrentTenantKey(), UserContext.getCurrentEmployeeId(), m.getLabelId(), m.getDefaultLabel()))).collect(Collectors.toList()); +// } + +// @SalaryForm( +// label = "备注", +// labelId = 84961, +// items = { +// @SalaryFormItem(itemType = WeaFormItemType.INPUT, maxLength = "20") +// } +// ) +// //备注") + private String description; +} diff --git a/src/com/engine/salary/entity/salaryarchive/dto/SalaryArchiveItemDataDTO.java b/src/com/engine/salary/entity/salaryarchive/dto/SalaryArchiveItemDataDTO.java new file mode 100644 index 000000000..260017e52 --- /dev/null +++ b/src/com/engine/salary/entity/salaryarchive/dto/SalaryArchiveItemDataDTO.java @@ -0,0 +1,32 @@ +package com.engine.salary.entity.salaryarchive.dto; + +import com.engine.salary.common.LocalDateRange; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 薪资档案-薪资项目数据 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//薪资档案-薪资项目数据") +public class SalaryArchiveItemDataDTO { + + //生效日期范围") + private LocalDateRange effectiveDateRange; + + //薪资项目id") + private Long salaryItemId; + + //薪资项目值") + private String value; +} diff --git a/src/com/engine/salary/entity/salaryarchive/dto/SalaryArchiveItemDataListDTO.java b/src/com/engine/salary/entity/salaryarchive/dto/SalaryArchiveItemDataListDTO.java new file mode 100644 index 000000000..24c632ede --- /dev/null +++ b/src/com/engine/salary/entity/salaryarchive/dto/SalaryArchiveItemDataListDTO.java @@ -0,0 +1,45 @@ +package com.engine.salary.entity.salaryarchive.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.time.LocalDate; + +/** + * 薪资档案 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//薪资档案-薪资项目数据列表 +public class SalaryArchiveItemDataListDTO { + + //薪资项目调整id + private Long salaryArchiveItemId; + + //人员id + private Long employeeId; + + //薪资档案id + private String salaryArchiveId; + + //调整原因 + private String adjustReason; + + //生效时间 + private LocalDate effectiveTime; + + //薪资项目id + private Long salaryItemId; + + //调整值 + private String adjustValue; +} diff --git a/src/com/engine/salary/entity/salaryarchive/dto/SalaryArchiveItemFormDTO.java b/src/com/engine/salary/entity/salaryarchive/dto/SalaryArchiveItemFormDTO.java new file mode 100644 index 000000000..086bd054a --- /dev/null +++ b/src/com/engine/salary/entity/salaryarchive/dto/SalaryArchiveItemFormDTO.java @@ -0,0 +1,36 @@ +package com.engine.salary.entity.salaryarchive.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Map; + +/** + * 薪资项目调整 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//薪资项目调整 +public class SalaryArchiveItemFormDTO { + + //薪资档案id") + private Long salaryArchiveId; + + //基本调整信息") + private Map salaryArchiveItemForm; + + //薪资项目调整明细") + private Map salaryArchiveItemDetail; + + //是否可以编辑 + private boolean canOperator; +} diff --git a/src/com/engine/salary/entity/salaryarchive/dto/SalaryArchiveListDTO.java b/src/com/engine/salary/entity/salaryarchive/dto/SalaryArchiveListDTO.java new file mode 100644 index 000000000..f25a6f588 --- /dev/null +++ b/src/com/engine/salary/entity/salaryarchive/dto/SalaryArchiveListDTO.java @@ -0,0 +1,130 @@ +package com.engine.salary.entity.salaryarchive.dto; + +import com.cloudstore.eccom.pc.table.WeaTableType; +import com.engine.salary.annotation.*; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; +import java.util.Set; + +/** + * 薪资档案列表 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@SalaryTable(pageId = "a4f85287-9876-4d11-adn9-7d06e54y6rj8", tableType = WeaTableType.CHECKBOX, operates = { + @SalaryTableOperate(index = "0", text = "编辑"), + @SalaryTableOperate(index = "1", text = "删除") +}) +@Auth(page = "salaryArchive") +public class SalaryArchiveListDTO { + + @TableTitle(title = "id", dataIndex = "id", key = "id") + private Long id; + + @TableTitle(title = "人员信息表的主键id", dataIndex = "employeeId", key = "employeeId") + @AuthField(fieldType = "employeeId") + private Long employeeId; + + private Integer employeeType; + + /** + * 姓名 + */ + @TableTitle(title = "姓名", dataIndex = "username", key = "username") + @I18n + private String username; + + /** + * 个税扣缴义务人 + */ + @TableTitle(title = "个税扣缴义务人", dataIndex = "taxAgentName", key = "taxAgentName") + private String taxAgentName; + @AuthField(fieldType = "taxAgentId") + private Long taxAgentId; + + /** + * 分部 + */ + @TableTitle(title = "分部", dataIndex = "subcompanyName", key = "subcompanyName") + @I18n + private String subcompanyName; + + /** + * 部门 + */ + @TableTitle(title = "部门", dataIndex = "departmentName", key = "departmentName") + @I18n + private String departmentName; + + /** + * 电话 + */ + @TableTitle(title = "电话", dataIndex = "mobile", key = "mobile") + private String mobile; + + /** + * 入职日期 + */ + private String companystartdate; + + /** + * 离职日期 + */ + private String dismissdate; + + /** + * 工号 + */ + @TableTitle(title = "工号", dataIndex = "workcode", key = "workcode") + private String workcode; + + /** + * 证件号码 + */ + @TableTitle(title = "证件号码", dataIndex = "idNo", key = "idNo") + private String idNo; + + /** + * 员工状态 + */ + @TableTitle(title = "员工状态", dataIndex = "employeeStatus", key = "employeeStatus") + private String employeeStatus; + + /** + * 起始发薪日期 + */ + @TableTitle(title = "起始发薪日期", dataIndex = "payStartDate", key = "payStartDate") + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") + private Date payStartDate; + + /** + * 最后发薪日期 + */ + @TableTitle(title = "最后发薪日期", dataIndex = "payEndDate", key = "payEndDate") + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") + private Date payEndDate; + + /** + * 档案状态 + * SalaryArchiveStatusEnum + */ + private String archiveStatus; + + //主次账号 0/null:主账号 1:次账号 + private Integer accountType; + + private Set opts; + +} diff --git a/src/com/engine/salary/entity/salaryarchive/dto/SalaryArchiveTaxAgentDataDTO.java b/src/com/engine/salary/entity/salaryarchive/dto/SalaryArchiveTaxAgentDataDTO.java new file mode 100644 index 000000000..bd1883cd2 --- /dev/null +++ b/src/com/engine/salary/entity/salaryarchive/dto/SalaryArchiveTaxAgentDataDTO.java @@ -0,0 +1,34 @@ +package com.engine.salary.entity.salaryarchive.dto; + +import com.engine.salary.common.LocalDateRange; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * 薪资档案-个税扣缴义务人数据 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//薪资档案-个税扣缴义务人数据") +public class SalaryArchiveTaxAgentDataDTO { + + //个税扣缴义务人id") + private Long taxAgentId; + + //生效日期范围") + private LocalDateRange effectiveDateRange; + + //薪资项目数据") + private List salaryItemValues; +} diff --git a/src/com/engine/salary/entity/salaryarchive/dto/SalaryArchiveTaxAgentFormDTO.java b/src/com/engine/salary/entity/salaryarchive/dto/SalaryArchiveTaxAgentFormDTO.java new file mode 100644 index 000000000..bd822869b --- /dev/null +++ b/src/com/engine/salary/entity/salaryarchive/dto/SalaryArchiveTaxAgentFormDTO.java @@ -0,0 +1,27 @@ +package com.engine.salary.entity.salaryarchive.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Map; + +/** + * @Description: 个税扣缴义务人调整 + * @Author: wangxiangzhong + * @Date: 2021/11/5 10:42 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//个税扣缴义务人调整") +public class SalaryArchiveTaxAgentFormDTO { + + //薪资档案id + private Long salaryArchiveId; + + //个税扣缴义务人调整 + private Map salaryArchiveTaxAgentForm; +} diff --git a/src/com/engine/salary/entity/salaryarchive/dto/SalaryItemAdjustRecordListDTO.java b/src/com/engine/salary/entity/salaryarchive/dto/SalaryItemAdjustRecordListDTO.java new file mode 100644 index 000000000..db2b4cb2b --- /dev/null +++ b/src/com/engine/salary/entity/salaryarchive/dto/SalaryItemAdjustRecordListDTO.java @@ -0,0 +1,92 @@ +package com.engine.salary.entity.salaryarchive.dto; + +import com.engine.salary.annotation.Encrypt; +import com.engine.salary.annotation.I18n; +import com.engine.salary.annotation.TableTitle; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; + +/** + * 薪资项目调整记录列表 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//薪资项目调整记录列表") +//@TableOperates(tableType = WeaTableTypeEnum.CHECKBOX) +public class SalaryItemAdjustRecordListDTO { + + //主键id") + @JsonSerialize(using = ToStringSerializer.class) + private Long id; + + /** + * 人员信息表的主键id + */ + private Long employeeId; + + @TableTitle(title = "姓名", dataIndex = "username", key = "username") + private String username; + + @TableTitle(title = "部门", dataIndex = "departmentName", key = "departmentName") + @I18n + private String departmentName; + + @TableTitle(title = "员工状态", dataIndex = "employeeStatus", key = "employeeStatus") + private String employeeStatus; + + @TableTitle(title = "调整项目", dataIndex = "adjustItem", key = "adjustItem") + private String adjustItem; + + @TableTitle(title = "调整前", dataIndex = "adjustBefore", key = "adjustBefore") + @Encrypt + private String adjustBefore; + + @TableTitle(title = "调整后", dataIndex = "adjustAfter", key = "adjustAfter") + @Encrypt + private String adjustAfter; + + @TableTitle(title = "调整原因", dataIndex = "adjustReason", key = "adjustReason") + private String adjustReason; + + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") + @TableTitle(title = "生效日期", dataIndex = "effectiveTime", key = "effectiveTime") + private Date effectiveTime; + + @TableTitle(title = "操作人", dataIndex = "operator", key = "operator") + @I18n + private String operator; + + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + @TableTitle(title = "操作时间", dataIndex = "operateTime", key = "operateTime") + private Date operateTime; + + @TableTitle(title = "备注", dataIndex = "description", key = "description") + private String description; + + /** + * 薪资档案id + */ + @JsonIgnore + private Long salaryArchiveId; + + /** + * 薪资项目id + */ + @JsonIgnore + private Long salaryItemId; +} diff --git a/src/com/engine/salary/entity/salaryarchive/dto/SalaryItemAdjustValidDTO.java b/src/com/engine/salary/entity/salaryarchive/dto/SalaryItemAdjustValidDTO.java new file mode 100644 index 000000000..3d5ccf6e9 --- /dev/null +++ b/src/com/engine/salary/entity/salaryarchive/dto/SalaryItemAdjustValidDTO.java @@ -0,0 +1,33 @@ +package com.engine.salary.entity.salaryarchive.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * @Description: 薪资项目调整校验 + * @Author: wangxiangzhong + * @Date: 2022/8/29 11:17 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//"薪资项目调整校验") +public class SalaryItemAdjustValidDTO { + + //生效日期不可早于当前已生效的调整日期") + private boolean isBefore; + + //调整前后不可相同") + private boolean isSame; + + //与未生效的调整后不可相同") + private boolean isSameIneffective; + + //待删除的薪资档案项目id") + private List salaryArchiveItemDelIds; +} diff --git a/src/com/engine/salary/entity/salaryarchive/dto/SingleSalaryItemAdjustRecordListDTO.java b/src/com/engine/salary/entity/salaryarchive/dto/SingleSalaryItemAdjustRecordListDTO.java new file mode 100644 index 000000000..379577748 --- /dev/null +++ b/src/com/engine/salary/entity/salaryarchive/dto/SingleSalaryItemAdjustRecordListDTO.java @@ -0,0 +1,71 @@ +package com.engine.salary.entity.salaryarchive.dto; + +import com.engine.salary.annotation.TableTitle; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; + +/** + * 薪资项目调整记录列表 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//薪资项目调整记录列表") +//@TableOperates(value = { +// @Operates(index = 0, text = "编辑" ,labelId = 59943), +// @Operates(index = 1, text = "删除" ,labelId = 59942) +//}, tableType = WeaTableTypeEnum.NONE) +public class SingleSalaryItemAdjustRecordListDTO { + +// @JsonSerialize(using = ToStringSerializer.class) + private Long id; + // + @TableTitle(title = "调整项目", dataIndex = "adjustItem", key = "adjustItem") + private String adjustItem; + + @TableTitle(title = "调整前", dataIndex = "adjustBefore", key = "adjustBefore") + private String adjustBefore; + + @TableTitle(title = "调整后", dataIndex = "adjustAfter", key = "adjustAfter") + private String adjustAfter; + + @TableTitle(title = "调整原因", dataIndex = "adjustReason", key = "adjustReason") + private String adjustReason; + + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") + @TableTitle(title = "生效日期", dataIndex = "effectiveTime", key = "effectiveTime") + private Date effectiveTime; + + @TableTitle(title = "操作人", dataIndex = "operator", key = "operator") + private String operator; + + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + @TableTitle(title = "操作时间", dataIndex = "operateTime", key = "operateTime") + private Date operateTime; + + @TableTitle(title = "备注", dataIndex = "description", key = "description") + private String description; + +// @JsonIgnore + private Long salaryArchiveId; + +// @JsonIgnore + private Long salaryItemId; + + + /** + * 是否能操作 + */ + private Boolean canOperator; +} diff --git a/src/com/engine/salary/entity/salaryarchive/dto/SingleTaxAgentAdjustRecordListDTO.java b/src/com/engine/salary/entity/salaryarchive/dto/SingleTaxAgentAdjustRecordListDTO.java new file mode 100644 index 000000000..160390275 --- /dev/null +++ b/src/com/engine/salary/entity/salaryarchive/dto/SingleTaxAgentAdjustRecordListDTO.java @@ -0,0 +1,76 @@ +package com.engine.salary.entity.salaryarchive.dto; + +import com.engine.salary.annotation.TableTitle; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; + +/** + * 个税扣缴义务人调整记录列表 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//个税扣缴义务人调整记录列表") +//@TableOperates(value = { +// @Operates(index = 0, text = "编辑" ,labelId = 59943), +// @Operates(index = 1, text = "删除" ,labelId = 59942) +//}, tableType = WeaTableTypeEnum.NONE) +public class SingleTaxAgentAdjustRecordListDTO { + // //主键id") +// @JsonSerialize(using = ToStringSerializer.class) + private Long id; + + @TableTitle(title = "调整前", dataIndex = "adjustBefore", key = "adjustBefore") + private String adjustBefore; + + @TableTitle(title = "调整后", dataIndex = "adjustAfter", key = "adjustAfter") + private String adjustAfter; + + @TableTitle(title = "调整原因", dataIndex = "adjustReason", key = "adjustReason") + private String adjustReason; + + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") + @TableTitle(title = "生效日期", dataIndex = "effectiveTime", key = "effectiveTime") + private Date effectiveTime; + + @TableTitle(title = "操作人", dataIndex = "operator", key = "operator") + private String operator; + + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + @TableTitle(title = "操作时间", dataIndex = "operateTime", key = "operateTime") + private Date operateTime; + // + + @TableTitle(title = "备注", dataIndex = "description", key = "description") + private String description; + + /** + * 薪资档案id + */ +// @JsonIgnore + private Long salaryArchiveId; + // + /** + * 个税扣缴义务人id + */ +// @JsonIgnore + private Long taxAgentId; + + /** + * 是否有操作按钮 + */ + private Boolean canOperator; + + +} diff --git a/src/com/engine/salary/entity/salaryarchive/dto/TaxAgentAdjustRecordListDTO.java b/src/com/engine/salary/entity/salaryarchive/dto/TaxAgentAdjustRecordListDTO.java new file mode 100644 index 000000000..dabb01488 --- /dev/null +++ b/src/com/engine/salary/entity/salaryarchive/dto/TaxAgentAdjustRecordListDTO.java @@ -0,0 +1,96 @@ +package com.engine.salary.entity.salaryarchive.dto; + +import com.cloudstore.eccom.pc.table.WeaTableType; +import com.engine.salary.annotation.SalaryTable; +import com.engine.salary.annotation.SalaryTableColumn; +import com.engine.salary.annotation.TableTitle; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; + +/** + * 个税扣缴义务人调整记录列表 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//个税扣缴义务人调整记录列表") +@SalaryTable(pageId = "a4f85287-e3f9-4275-1567-7d06e54y6rj8", tableType = WeaTableType.CHECKBOX) +public class TaxAgentAdjustRecordListDTO { + //主键id") + @JsonSerialize(using = ToStringSerializer.class) + @SalaryTableColumn(column = "id", display = false) + private Long id; + + /** + * 人员信息表的主键id + */ + private Long employeeId; + + @SalaryTableColumn(text = "姓名", width = "10%", column = "username") + @TableTitle(title = "姓名",dataIndex = "username",key = "username") + private String username; + + @SalaryTableColumn(text = "部门", width = "10%", column = "departmentName") + @TableTitle(title = "部门",dataIndex = "departmentName",key = "departmentName") + private String departmentName; + + @SalaryTableColumn(text = "员工状态", width = "10%", column = "employeeStatus") + @TableTitle(title = "员工状态",dataIndex = "employeeStatus",key = "employeeStatus") + private String employeeStatus; + + @SalaryTableColumn(text = "调整前", width = "10%", column = "adjustBefore") + @TableTitle(title = "调整前",dataIndex = "adjustBefore",key = "adjustBefore") + private String adjustBefore; + + @SalaryTableColumn(text = "调整后", width = "10%", column = "adjustAfter") + @TableTitle(title = "调整后",dataIndex = "adjustAfter",key = "adjustAfter") + private String adjustAfter; + + @SalaryTableColumn(text = "调整原因", width = "10%", column = "adjustReason") + @TableTitle(title = "调整原因",dataIndex = "adjustReason",key = "adjustReason") + private String adjustReason; + + @SalaryTableColumn(text = "生效日期", width = "10%", column = "effectiveTime") + @TableTitle(title = "生效日期",dataIndex = "effectiveTime",key = "effectiveTime") + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") + private Date effectiveTime; + + @SalaryTableColumn(text = "操作人", width = "10%", column = "operator") + @TableTitle(title = "操作人",dataIndex = "operator",key = "operator") + private String operator; + + @SalaryTableColumn(text = "操作时间", width = "10%", column = "operateTime") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + @TableTitle(title = "操作时间",dataIndex = "operateTime",key = "operateTime") + private Date operateTime; + + @SalaryTableColumn(text = "备注", width = "10%", column = "description") + @TableTitle(title = "备注",dataIndex = "description",key = "description") + private String description; + + /** + * 薪资档案id + */ + private Long salaryArchiveId; + + /** + * 个税扣缴义务人id + */ + @JsonIgnore + private Long taxAgentId; + +} diff --git a/src/com/engine/salary/entity/salaryarchive/dto/TaxAgentFormDTO.java b/src/com/engine/salary/entity/salaryarchive/dto/TaxAgentFormDTO.java new file mode 100644 index 000000000..94eee9bea --- /dev/null +++ b/src/com/engine/salary/entity/salaryarchive/dto/TaxAgentFormDTO.java @@ -0,0 +1,38 @@ +package com.engine.salary.entity.salaryarchive.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Description: 个税扣缴义务人表单 + * @Author: wangxiangzhong + * @Date: 2021/10/29 16:12 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//个税扣缴义务人表单") +public class TaxAgentFormDTO { + + //主键id") + private Long id; +// +// @WeaFormat( +// label = "名称", +// labelId = 1252, +// from = @Form(itemType = WeaFormItemType.INPUT, required = true, maxLength = "20") +// ) +// //名称") +// private String name; +// +// @WeaFormat( +// label = "备注", +// labelId = 84961, +// from = @Form(itemType = WeaFormItemType.INPUT, maxLength = "20") +// ) +// //备注") +// private String description; +} diff --git a/src/com/engine/salary/entity/salaryarchive/dto/TaxAgentListDTO.java b/src/com/engine/salary/entity/salaryarchive/dto/TaxAgentListDTO.java new file mode 100644 index 000000000..910f0c619 --- /dev/null +++ b/src/com/engine/salary/entity/salaryarchive/dto/TaxAgentListDTO.java @@ -0,0 +1,45 @@ +package com.engine.salary.entity.salaryarchive.dto; + +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Description: 个税扣缴义务人列表 + * @Author: wangxiangzhong + * @Date: 2021/10/29 15:39 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//个税扣缴义务人列表") +//@TableOperates(value = { +// @Operates(index = 0, text = "编辑" ,labelId = 59943), +// @Operates(index = 1, text = "删除" ,labelId = 59942) +//}, tableType = WeaTableTypeEnum.NONE) +public class TaxAgentListDTO { + + //主键id") + @JsonSerialize(using = ToStringSerializer.class) + private Long id; + +// //个税扣缴义务人名称") +// @WeaFormat( +// label = "个税扣缴义务人名称", +// labelId = 91558, +// tableColumn = @TableColumn(width = "40%") +// ) + private String name; +// +// //备注") +// @WeaFormat( +// label = "备注", +// labelId = 84961, +// tableColumn = @TableColumn(width = "40%") +// ) + private String description; +} diff --git a/src/com/engine/salary/entity/salaryarchive/param/SalaryArchiveDimissionSaveParam.java b/src/com/engine/salary/entity/salaryarchive/param/SalaryArchiveDimissionSaveParam.java new file mode 100644 index 000000000..1171987f8 --- /dev/null +++ b/src/com/engine/salary/entity/salaryarchive/param/SalaryArchiveDimissionSaveParam.java @@ -0,0 +1,25 @@ +package com.engine.salary.entity.salaryarchive.param; + +import com.engine.salary.enums.salaryarchive.SalaryArchiveDimissionTimeIntervalEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 薪资档案离职时段保存参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalaryArchiveDimissionSaveParam { + + //离职时段") + private SalaryArchiveDimissionTimeIntervalEnum dimissionTimeInterval; +} diff --git a/src/com/engine/salary/entity/salaryarchive/param/SalaryArchiveImportActionParam.java b/src/com/engine/salary/entity/salaryarchive/param/SalaryArchiveImportActionParam.java new file mode 100644 index 000000000..0f8e3a602 --- /dev/null +++ b/src/com/engine/salary/entity/salaryarchive/param/SalaryArchiveImportActionParam.java @@ -0,0 +1,50 @@ +package com.engine.salary.entity.salaryarchive.param; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import com.engine.salary.enums.salaryarchive.SalaryArchiveImportTypeEnum; + +import java.util.List; +import java.util.Map; + + +/** + * 薪资档案导入处理参数(action使用) + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author liuliang + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalaryArchiveImportActionParam { + /** + * 导入类型 + * + * @see SalaryArchiveImportTypeEnum + */ + String importType; + String listType; + + /** + * 导入数据 + */ + List> importDatas; + + private boolean addData; + + /** + * 说明 + */ + private String description; + + /** + * 档案状态是否保持不变 + */ + private Boolean keepStatus; +} diff --git a/src/com/engine/salary/entity/salaryarchive/param/SalaryArchiveImportHandleParam.java b/src/com/engine/salary/entity/salaryarchive/param/SalaryArchiveImportHandleParam.java new file mode 100644 index 000000000..155cba89c --- /dev/null +++ b/src/com/engine/salary/entity/salaryarchive/param/SalaryArchiveImportHandleParam.java @@ -0,0 +1,180 @@ +package com.engine.salary.entity.salaryarchive.param; + +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.salaryarchive.po.SalaryArchiveItemPO; +import com.engine.salary.entity.salaryarchive.po.SalaryArchivePO; +import com.engine.salary.entity.salaryitem.po.SalaryItemPO; +import com.engine.salary.entity.salarysob.param.SalarySobRangeSaveParam; +import com.engine.salary.entity.taxagent.dto.TaxAgentManageRangeEmployeeDTO; +import com.engine.salary.entity.taxagent.param.TaxAgentRangeSaveParam; +import com.engine.salary.enums.salaryarchive.SalaryArchiveImportTypeEnum; +import com.engine.salary.enums.salaryarchive.SalaryArchiveListTypeEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.Date; +import java.util.List; +import java.util.Map; + +/** + * 薪资档案导入处理参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalaryArchiveImportHandleParam { + + //**********************前端需传入参数**************************/ + + /** + * 上传文件id + */ + String imageId; + + /** + * 导入类型 + * + * @see SalaryArchiveImportTypeEnum + */ + String importType; + + /** + * 列表类型 + * @see SalaryArchiveListTypeEnum + */ + String listType; + + /** + * 是否处理数据 + */ + boolean onlyCheck; + + /** + * 是否是流程 + */ + boolean isProcess; + + /** + * 是否是外部人员 + */ + boolean isExtEmp; + + /** + * 说明 + */ + String description; + + //*****************************************************************/ + + Long currentEmployeeId; + String tenantKey; + + /** + * 人员验证方式 + */ + String empValidType; + + // 待定薪列表 + boolean isPendingList; + // 定薪列表 + boolean isFixedList; + // 待停薪列表 + boolean isSuspendList; + boolean isInit; + boolean isSalaryItemAdjust; + + /** + * 获取租户下所有的人员 + */ + List employees; + + + /** + * 获取所有个税扣缴义务人 + */ + Collection taxAgentList; + + /** + * 获取所有可被引用的薪资项目 + */ + List salaryItems; + + /** + * 查询已有的薪资档案基本数据 + */ + Map salaryArchivesMap; + + /** + * 薪资项目id + */ + Collection salaryItemIds; + + /** + * 查询已生效的薪资项目数据 + */ + Map> effectiveItemListMap; + + /** + * 查询未生效的薪资项目数据 + */ + Map> ineffectiveItemListMap; + + /** + * 当前时间 + */ + Date nowTime = new Date(); + + /** + * 当天 + */ + Date today = new Date(); + + /** + * 待保存薪资档案 + */ + List salaryArchiveSaves; + + /** + * 待修改薪资档案 + */ + List salaryArchiveUpdates; + + /** + * 待保存薪资档案-薪资项目 + */ + List salaryArchiveItemSaves; + + /** + * 待删除薪资档案-薪资项目 + */ + List salaryArchiveItemDelSalaryItemIds; + + /** + * 待生成的人员范围 + */ + List taxAgentRanges; + + /** + * 薪资账套 + */ +// List salarySobList; + + /** + * 薪资档案-账套关联 + */ + List salaryArchiveSobSaves; + + /** + * 薪资档案状态是否保持不变 + */ + Boolean keepStatus; +} diff --git a/src/com/engine/salary/entity/salaryarchive/param/SalaryArchiveItemDetailSaveParam.java b/src/com/engine/salary/entity/salaryarchive/param/SalaryArchiveItemDetailSaveParam.java new file mode 100644 index 000000000..7d0223ee3 --- /dev/null +++ b/src/com/engine/salary/entity/salaryarchive/param/SalaryArchiveItemDetailSaveParam.java @@ -0,0 +1,28 @@ +package com.engine.salary.entity.salaryarchive.param; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 薪资档案-薪资项目调整详情 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//薪资档案-薪资项目调整详情保存参数") +public class SalaryArchiveItemDetailSaveParam { + + //薪资档案项目表的主键id") + private Long salaryItemId; + + //调整值") + private String adjustValue; +} diff --git a/src/com/engine/salary/entity/salaryarchive/param/SalaryArchiveItemQueryParam.java b/src/com/engine/salary/entity/salaryarchive/param/SalaryArchiveItemQueryParam.java new file mode 100644 index 000000000..0683b02db --- /dev/null +++ b/src/com/engine/salary/entity/salaryarchive/param/SalaryArchiveItemQueryParam.java @@ -0,0 +1,33 @@ +package com.engine.salary.entity.salaryarchive.param; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.Date; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalaryArchiveItemQueryParam { + + Collection ids; + + /** + * 生效时间 + */ + private Date effectiveTime; + + Collection salaryItemIds; + + Collection salaryArchivesIds; + + Collection employeeIds; + + Long salaryArchiveId; + + Long salaryItemId; +} diff --git a/src/com/engine/salary/entity/salaryarchive/param/SalaryArchiveItemSaveParam.java b/src/com/engine/salary/entity/salaryarchive/param/SalaryArchiveItemSaveParam.java new file mode 100644 index 000000000..01329f8bc --- /dev/null +++ b/src/com/engine/salary/entity/salaryarchive/param/SalaryArchiveItemSaveParam.java @@ -0,0 +1,87 @@ +package com.engine.salary.entity.salaryarchive.param; + +import com.engine.salary.enums.salaryarchive.SalaryArchiveItemAdjustReasonEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.util.SalaryI18nUtil; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; + +import java.util.Date; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +/** + * 薪资项目调整保存参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//薪资项目调整保存参数") +public class SalaryArchiveItemSaveParam { + + // 主键id + private Long salaryArchiveItemId; + + //薪资档案id + private Long salaryArchiveId; + + //生效时间 + private Date effectiveTime; + + // 是否允许编辑 + private Boolean canOperator; + + /** + * 调整原因 + * + * @see SalaryArchiveItemAdjustReasonEnum + */ + private String adjustReason; + + //备注 + private String description; + + //薪资项目 + private List salaryArchiveItems; + + + + public static void checkParam(SalaryArchiveItemSaveParam saveParam) { + if (saveParam.getSalaryArchiveId() == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100305, "薪资档案id必传")); + } + if (saveParam.getAdjustReason() == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100306, "请选择调整原因")); + } +// if (SalaryArchiveItemAdjustReasonEnum.parseByValue(saveParam.getAdjustReason()) == null) { +// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100306, "调整原因不在范围内")); +// } + if (saveParam.getEffectiveTime() == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100307, "请选择生效日期")); + } + if (CollectionUtils.isEmpty(saveParam.getSalaryArchiveItems())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100308, "请输入薪资项目明细")); + } + Set salaryItemIds = new HashSet<>(); + for (SalaryArchiveItemDetailSaveParam e : saveParam.getSalaryArchiveItems()) { + if (e.getSalaryItemId() == null || StringUtils.isEmpty((e.getAdjustValue() + "").trim())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100309, "明细中的薪资项目不能为空并且调整后必须输入值")); + } + salaryItemIds.add(e.getSalaryItemId()); + } + if (saveParam.getSalaryArchiveItems().size() != salaryItemIds.size()) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100310, "明细中的薪资项目不能重复")); + } + } +} diff --git a/src/com/engine/salary/entity/salaryarchive/param/SalaryArchiveQueryParam.java b/src/com/engine/salary/entity/salaryarchive/param/SalaryArchiveQueryParam.java new file mode 100644 index 000000000..bbbd2cc80 --- /dev/null +++ b/src/com/engine/salary/entity/salaryarchive/param/SalaryArchiveQueryParam.java @@ -0,0 +1,121 @@ +package com.engine.salary.entity.salaryarchive.param; + +import com.engine.salary.common.BaseQueryParam; +import com.engine.salary.enums.salaryarchive.SalaryArchiveListTypeEnum; +import com.engine.salary.enums.salaryarchive.SalaryArchiveStatusEnum; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.Date; +import java.util.List; + +/** + * 薪资档案 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//薪资档案查询参数 +public class SalaryArchiveQueryParam extends BaseQueryParam { + + private Collection ids; + + //姓名 + private String username; + private Long employeeId; + + //个税扣缴义务人id + private Long taxAgentId; + + private List taxAgentIds; + private String taxAgentName; + + //分部id + private List subcompanyIds; + + //部门id + private List departmentIds; + + //岗位id + private List positionIds; + + //状态 + private String userstatus; + //状态(多选) + private List statuses; + + //入职日期 + private List hiredate; + + //导入类型 + private String importType; + + private Collection employeeIds; + + //导出模板时,是否包含数据 + private Boolean hasData; + + /** + * 档案状态 + * @see SalaryArchiveStatusEnum + */ + private String archiveStatus; + + /** + * 人事状态 + */ + private List personnelStatuss; + + /** + * 状态 + */ + @JsonIgnore + private List runStatusList; + + //列表类型:PENDING:待定薪;FIXED:发薪;SUSPEND:待停薪;STOP:停薪" + private SalaryArchiveListTypeEnum listType; + + private String workcode; + /** + * 是否是外部系统档案 + */ + private boolean extSalaryArchiveList; + + + private String payStartDateStartDateStr; + private String payStartDateEndDateStr; + + // 起始发薪日期起 + private Date payStartDateStartDate; + + // 起始发薪日期止 + private Date payStartDateEndDate; + + // 最后发薪日期起 + private String payEndDateStartDateStr; + // 最后发薪日期止 + private String payEndDateEndDateStr; + + // 最后发薪日期起 + private Date payEndDateStartDate; + + // 最后发薪日期止 + private Date payEndDateEndDate; + + // 调薪起始日期 + private Date adjustSalaryStartDate; + + // 调薪结束日期 + private Date adjustSalaryEndDate; + +} diff --git a/src/com/engine/salary/entity/salaryarchive/param/SalaryArchiveSaveParam.java b/src/com/engine/salary/entity/salaryarchive/param/SalaryArchiveSaveParam.java new file mode 100644 index 000000000..dc5bd96fc --- /dev/null +++ b/src/com/engine/salary/entity/salaryarchive/param/SalaryArchiveSaveParam.java @@ -0,0 +1,32 @@ +package com.engine.salary.entity.salaryarchive.param; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Description: 薪资档案 + * @Author: wangxiangzhong + * @Date: 2021-11-03 10:51 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//薪资档案保存参数") +public class SalaryArchiveSaveParam { + + //主键") + private Long id; + + //人员信息表的主键id") + private Long employeeId; + +// public static WeaResult checkParam(SalaryArchiveSaveParam saveParam, Long employeeId, String tenantKey) { +// if (saveParam.getEmployeeId() == null) { +// return WeaResult.fail(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 100311, "人员信息表的主键id必传")); +// } +// return WeaResult.success(StringUtils.EMPTY); +// } +} diff --git a/src/com/engine/salary/entity/salaryarchive/param/SalaryArchiveSetPaySaveParam.java b/src/com/engine/salary/entity/salaryarchive/param/SalaryArchiveSetPaySaveParam.java new file mode 100644 index 000000000..ba5b531b3 --- /dev/null +++ b/src/com/engine/salary/entity/salaryarchive/param/SalaryArchiveSetPaySaveParam.java @@ -0,0 +1,46 @@ +package com.engine.salary.entity.salaryarchive.param; + +import com.engine.salary.enums.salaryarchive.SalaryArchiveStatusEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; +import java.util.List; + +/** + * 发薪设置保存参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalaryArchiveSetPaySaveParam { + + //状态,PENDING:待定薪;FIXED:发薪;SUSPEND:待停薪 + private SalaryArchiveStatusEnum status; + + //薪资档案id + private Long salaryArchiveId; + + //收入所得项目 +// private Integer incomeCategory; +// +// //薪资账套 +// private List salarySobIds; + + //起始发薪日期 + private Date payStartDate; + + //最后发薪日期 + private Date payEndDate; + + //薪资项目:待定薪使用 + private List salaryArchiveItems; +} diff --git a/src/com/engine/salary/entity/salaryarchive/param/SalaryArchiveStopParam.java b/src/com/engine/salary/entity/salaryarchive/param/SalaryArchiveStopParam.java new file mode 100644 index 000000000..14dc448da --- /dev/null +++ b/src/com/engine/salary/entity/salaryarchive/param/SalaryArchiveStopParam.java @@ -0,0 +1,39 @@ +package com.engine.salary.entity.salaryarchive.param; + +import com.engine.salary.util.valid.DataCheck; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; + +/** + * 停薪 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalaryArchiveStopParam { + + /** + * 档案id + */ + @DataCheck(require = true, message = "薪资档案id为空") + private Long salaryArchiveId; + + /** + * 最后发薪日期 + */ + private Date payEndDate; + @DataCheck(require = true, message = "最后发薪日期为空") + private String payEndDateStr; + + +} diff --git a/src/com/engine/salary/entity/salaryarchive/param/SalaryArchiveTaxAgentQueryParam.java b/src/com/engine/salary/entity/salaryarchive/param/SalaryArchiveTaxAgentQueryParam.java new file mode 100644 index 000000000..432bfd505 --- /dev/null +++ b/src/com/engine/salary/entity/salaryarchive/param/SalaryArchiveTaxAgentQueryParam.java @@ -0,0 +1,27 @@ +package com.engine.salary.entity.salaryarchive.param; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.Date; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalaryArchiveTaxAgentQueryParam { + + /** + * 生效时间 + */ + private Date effectiveTime; + + Long salaryArchiveId; + + Collection salaryArchivesIds; + + Collection employeeIds; +} diff --git a/src/com/engine/salary/entity/salaryarchive/param/SalaryArchiveTaxAgentSaveParam.java b/src/com/engine/salary/entity/salaryarchive/param/SalaryArchiveTaxAgentSaveParam.java new file mode 100644 index 000000000..3d72ab3e6 --- /dev/null +++ b/src/com/engine/salary/entity/salaryarchive/param/SalaryArchiveTaxAgentSaveParam.java @@ -0,0 +1,57 @@ +package com.engine.salary.entity.salaryarchive.param; + +import com.engine.salary.enums.salaryarchive.SalaryArchiveTaxAgentAdjustReasonEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.util.SalaryI18nUtil; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; + +/** + * 个税扣缴义务人调整保存参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//个税扣缴义务人调整保存参数") +public class SalaryArchiveTaxAgentSaveParam { + + //薪资档案id") + private Long salaryArchiveId; + + //生效时间") + private Date effectiveTime; + + /** + * 调整原因 + * @see SalaryArchiveTaxAgentAdjustReasonEnum + */ + private String adjustReason; + + //个税扣缴义务人id") + private Long taxAgentId; + + public static void checkParam(SalaryArchiveTaxAgentSaveParam saveParam) { + if (saveParam.getSalaryArchiveId() == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel( 100305, "薪资档案id必传")); + } + if (saveParam.getAdjustReason() == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel( 100306, "请选择调整原因")); + } + if (saveParam.getEffectiveTime() == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel( 100307, "请选择生效日期")); + } + if (saveParam.getTaxAgentId() == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel( 100313, "请选择调整后的个税扣缴义务人")); + } + } +} diff --git a/src/com/engine/salary/entity/salaryarchive/param/SalaryItemAdjustBeforeParam.java b/src/com/engine/salary/entity/salaryarchive/param/SalaryItemAdjustBeforeParam.java new file mode 100644 index 000000000..162c6e43b --- /dev/null +++ b/src/com/engine/salary/entity/salaryarchive/param/SalaryItemAdjustBeforeParam.java @@ -0,0 +1,35 @@ +package com.engine.salary.entity.salaryarchive.param; + +import com.engine.salary.util.valid.DataCheck; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 薪资项目调整前参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//薪资项目调整记录查询参数 +public class SalaryItemAdjustBeforeParam { + + //薪资档案id + @DataCheck(require = true,message = "薪资档案id必传") + private Long salaryArchiveId; + + //薪资项目id + @DataCheck(require = true,message = "薪资项目id必传") + private Long salaryItemId; + + //薪资档案的薪资项目id + private Long salaryArchiveItemId; + +} diff --git a/src/com/engine/salary/entity/salaryarchive/param/SalaryItemAdjustRecordQueryParam.java b/src/com/engine/salary/entity/salaryarchive/param/SalaryItemAdjustRecordQueryParam.java new file mode 100644 index 000000000..6e2fc8415 --- /dev/null +++ b/src/com/engine/salary/entity/salaryarchive/param/SalaryItemAdjustRecordQueryParam.java @@ -0,0 +1,70 @@ +package com.engine.salary.entity.salaryarchive.param; + +import com.engine.salary.common.BaseQueryParam; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.Date; +import java.util.List; + +/** + * 薪资档案操作记录查询参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//薪资项目调整记录查询参数 +public class SalaryItemAdjustRecordQueryParam extends BaseQueryParam { + + //主键id + private Collection ids; + + //薪资档案id + private Long salaryArchiveId; + private List salaryArchiveIds; + + //关键字(姓名、部门、薪资项目名称) + private String keyword; + + //姓名 + private String username; + + //员工id + private Long employeeId; + + //部门id + private List departmentIds; + + //岗位 + private List positionIds; + + //状态 + private String userstatus; + + //项目名称 + private String adjustItem; + + //调整原因 + private String adjustReason; + + //生效日期 + private List effectiveTime; + + //操作日期 + private List operateTime; + + //操作人id + private List operatorIds; + + //备注 + private String description; +} diff --git a/src/com/engine/salary/entity/salaryarchive/param/SingleSalaryItemAdjustRecordQueryParam.java b/src/com/engine/salary/entity/salaryarchive/param/SingleSalaryItemAdjustRecordQueryParam.java new file mode 100644 index 000000000..b92199ef7 --- /dev/null +++ b/src/com/engine/salary/entity/salaryarchive/param/SingleSalaryItemAdjustRecordQueryParam.java @@ -0,0 +1,50 @@ +package com.engine.salary.entity.salaryarchive.param; + +import com.engine.salary.common.BaseQueryParam; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.time.LocalDate; +import java.util.List; + +/** + * 薪资档案操作记录查询参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//薪资项目调整记录查询参数 +public class SingleSalaryItemAdjustRecordQueryParam extends BaseQueryParam { + + //薪资档案id + private Long salaryArchiveId; + + //关键字(姓名、部门、薪资项目名称) + private String keyword; + + //项目名称 + private String adjustItem; + + //调整原因 + private String adjustReason; + + //生效日期 + private List effectiveTime; + + //操作日期 + private List operateTime; + + //操作人id + private List operatorIds; + + //备注 + private String description; +} diff --git a/src/com/engine/salary/entity/salaryarchive/param/SingleTaxAgentAdjustRecordQueryParam.java b/src/com/engine/salary/entity/salaryarchive/param/SingleTaxAgentAdjustRecordQueryParam.java new file mode 100644 index 000000000..47316e668 --- /dev/null +++ b/src/com/engine/salary/entity/salaryarchive/param/SingleTaxAgentAdjustRecordQueryParam.java @@ -0,0 +1,54 @@ +package com.engine.salary.entity.salaryarchive.param; + +import com.engine.salary.common.BaseQueryParam; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.time.LocalDate; +import java.util.Collection; +import java.util.List; + +/** + * 个税扣缴义务人调整记录查询参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//个税扣缴义务人调整记录查询参数 +public class SingleTaxAgentAdjustRecordQueryParam extends BaseQueryParam { + + //主键id + private Collection ids; + + //薪资档案id + private Long salaryArchiveId; + + //关键字(姓名、部门、个税扣缴义务人) + private String keyword; + + //个税扣缴义务人id + private Long taxAgentId; + + //调整原因 + private String adjustReason; + + //生效日期 + private List effectiveTime; + + //操作日期 + private List operateTime; + + //操作人id + private List operatorIds; + + //备注 + private String description; +} diff --git a/src/com/engine/salary/entity/salaryarchive/param/TaxAgentAdjustRecordQueryParam.java b/src/com/engine/salary/entity/salaryarchive/param/TaxAgentAdjustRecordQueryParam.java new file mode 100644 index 000000000..6fb5bbeec --- /dev/null +++ b/src/com/engine/salary/entity/salaryarchive/param/TaxAgentAdjustRecordQueryParam.java @@ -0,0 +1,66 @@ +package com.engine.salary.entity.salaryarchive.param; + +import com.engine.salary.common.BaseQueryParam; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.time.LocalDate; +import java.util.Collection; +import java.util.List; + +/** + * 个税扣缴义务人调整记录查询参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//个税扣缴义务人调整记录查询参数 +public class TaxAgentAdjustRecordQueryParam extends BaseQueryParam { + + //主键id + private Collection ids; + + //薪资档案id + private Long salaryArchiveId; + + //关键字(姓名、部门、个税扣缴义务人) + private String keyword; + + //姓名 + private String username; + + //部门id + private List departmentIds; + + //岗位id + private List positionIds; + + //状态 + private String userstatus; + + //个税扣缴义务人id + private Long taxAgentId; + + //调整原因 + private String adjustReason; + + //生效日期 + private List effectiveTime; + + //操作日期 + private List operateTime; + + //操作人id + private List operatorIds; + + //备注 + private String description; +} diff --git a/src/com/engine/salary/entity/salaryarchive/param/TaxAgentQueryParam.java b/src/com/engine/salary/entity/salaryarchive/param/TaxAgentQueryParam.java new file mode 100644 index 000000000..84b7a262d --- /dev/null +++ b/src/com/engine/salary/entity/salaryarchive/param/TaxAgentQueryParam.java @@ -0,0 +1,30 @@ +package com.engine.salary.entity.salaryarchive.param; + +import com.engine.salary.common.BaseQueryParam; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; + +/** + * 个税扣缴义务人查询参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//个税扣缴义务人查询参数") +public class TaxAgentQueryParam extends BaseQueryParam { + + private Collection ids; + + //个税扣缴义务人名称") + private String name; +} diff --git a/src/com/engine/salary/entity/salaryarchive/param/TaxAgentSaveParam.java b/src/com/engine/salary/entity/salaryarchive/param/TaxAgentSaveParam.java new file mode 100644 index 000000000..f9762fa5a --- /dev/null +++ b/src/com/engine/salary/entity/salaryarchive/param/TaxAgentSaveParam.java @@ -0,0 +1,38 @@ +package com.engine.salary.entity.salaryarchive.param; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 个税扣缴义务人保存参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//个税扣缴义务人保存参数") +public class TaxAgentSaveParam { + + //主键id + private Long id; + + //名称 + private String name; + + //备注 + private String description; + +// public static WeaResult checkParam(TaxAgentSaveParam saveParam, Long employeeId, String tenantKey) { +// if (StringUtils.isEmpty(saveParam.getName())) { +// return WeaResult.fail(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 100318, "名称必填")); +// } +// return WeaResult.success(StringUtils.EMPTY); +// } +} diff --git a/src/com/engine/salary/entity/salaryarchive/po/SalaryArchiveDimissionPO.java b/src/com/engine/salary/entity/salaryarchive/po/SalaryArchiveDimissionPO.java new file mode 100644 index 000000000..00958d9da --- /dev/null +++ b/src/com/engine/salary/entity/salaryarchive/po/SalaryArchiveDimissionPO.java @@ -0,0 +1,59 @@ +package com.engine.salary.entity.salaryarchive.po; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; + +/** + * 薪资档案离职时段表 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//hrsa_salary_archive_dimission +public class SalaryArchiveDimissionPO { + + /** + * 主键 + */ + private Long id; + + /** + * 离职时段 + */ + private String dimissionTimeInterval; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 更新时间 + */ + private Date updateTime; + + /** + * 创建人 + */ + private Long creator; + + /** + * 是否已删除。0:未删除、1:已删除 + */ + private Integer deleteType; + + /** + * 租户ID + */ + private String tenantKey; +} diff --git a/src/com/engine/salary/entity/salaryarchive/po/SalaryArchiveEmployeePO.java b/src/com/engine/salary/entity/salaryarchive/po/SalaryArchiveEmployeePO.java new file mode 100644 index 000000000..3451b26cc --- /dev/null +++ b/src/com/engine/salary/entity/salaryarchive/po/SalaryArchiveEmployeePO.java @@ -0,0 +1,31 @@ +package com.engine.salary.entity.salaryarchive.po; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 员工基本信息 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//员工基本信息") +public class SalaryArchiveEmployeePO { + + //员工id + private Long employeeId; + + //姓名 + private String username; + + //部门 + private String deparmentName; +} diff --git a/src/com/engine/salary/entity/salaryarchive/po/SalaryArchiveItemPO.java b/src/com/engine/salary/entity/salaryarchive/po/SalaryArchiveItemPO.java new file mode 100644 index 000000000..782d34348 --- /dev/null +++ b/src/com/engine/salary/entity/salaryarchive/po/SalaryArchiveItemPO.java @@ -0,0 +1,125 @@ +package com.engine.salary.entity.salaryarchive.po; + +import com.engine.salary.annotation.Encrypt; +import com.engine.hrmelog.annotation.ElogTransform; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.Date; + +/** + * 薪资档案薪资项目 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//hrsa_salary_archive_item +@ElogTransform( name="薪资档案调薪记录" ) +public class SalaryArchiveItemPO { + + /** + * 主键id + */ + @ElogTransform( name = "主键" ) + private Long id; + + /** + * 薪资档案表的主键id + */ + @ElogTransform( name = "薪资档案id" ) + private Long salaryArchiveId; + + /** + * 人员信息表的主键id + */ + @ElogTransform( name = "人员id" ) + private Long employeeId; + + /** + * 生效时间 + */ + @ElogTransform( name = "生效时间" ) + private Date effectiveTime; + + /** + * 调整原因 + */ + @ElogTransform( name = "调整原因" ) + private String adjustReason; + + /** + * 薪资项目表的主键id + */ + @ElogTransform( name = "薪资项目id" ) + private Long salaryItemId; + + /** + * 薪资项目值 + */ + @ElogTransform( name = "薪资项目值" ) + @Encrypt + private String itemValue; + + /** + * 备注 + */ + @ElogTransform( name = "备注" ) + private String description; + + /** + * 操作人 + */ + @ElogTransform( name = "操作人" ) + private Long operator; + + /** + * 操作时间 + */ + @ElogTransform( name = "操作时间" ) + private Date operateTime; + + /** + * 创建时间 + */ + @ElogTransform( name = "创建时间" ) + private Date createTime; + + /** + * 更新时间 + */ + @ElogTransform( name = "更新时间" ) + private Date updateTime; + + /** + * 创建人 + */ + @ElogTransform( name = "创建人" ) + private Long creator; + + /** + * 是否已删除。0:未删除、1:已删除 + */ + @ElogTransform( name = "是否已删除" ) + private Integer deleteType; + + /** + * 租户ID + */ + @ElogTransform( name = "租户" ) + private String tenantKey; + + + Collection ids; + Collection employeeIds; + Collection salaryItemIds; + +} diff --git a/src/com/engine/salary/entity/salaryarchive/po/SalaryArchivePO.java b/src/com/engine/salary/entity/salaryarchive/po/SalaryArchivePO.java new file mode 100644 index 000000000..25ad7601a --- /dev/null +++ b/src/com/engine/salary/entity/salaryarchive/po/SalaryArchivePO.java @@ -0,0 +1,144 @@ +package com.engine.salary.entity.salaryarchive.po; + +import com.engine.hrmelog.annotation.ElogTransform; +import com.engine.salary.annotation.Auth; +import com.engine.salary.enums.datacollection.DataCollectionEmployeeTypeEnum; +import com.engine.salary.enums.salaryarchive.SalaryArchiveStatusEnum; +import com.engine.salary.enums.salaryarchive.SalaryArchiveAddTypeEnum; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.Date; +import java.util.List; +import java.util.Set; + +/** + * 薪资档案 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//hrsa_salary_archive +@ElogTransform(name = "薪资档案") +@Auth(page = "salaryArchive") +public class SalaryArchivePO { + + /** + * 主键id + */ + @ElogTransform(name = "主键") + private Long id; + + /** + * 人员信息表的主键id + */ + @ElogTransform(name = "人员id") + private Long employeeId; + + /** + * 起始发薪日期 + */ + @ElogTransform(name = "起始发薪日期") + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") + private Date payStartDate; + + /** + * 最后发薪日期 + */ + @ElogTransform(name = "最后发薪日期") + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") + private Date payEndDate; + + /** + * 档案状态 + * + * @see SalaryArchiveStatusEnum + */ + @ElogTransform(name = "档案状态") + private String runStatus; + + /** + * 人员类型,0或null组织架构,1非系统人员 + * + * @see DataCollectionEmployeeTypeEnum + */ + @ElogTransform(name = "人员类型") + private Integer employeeType; + + + /** + * 定薪类型 + * + * @see SalaryArchiveAddTypeEnum + */ + @ElogTransform(name = "定薪类型") + private Integer addType; + + /** + * 停薪类型 + * + * @see + */ + @ElogTransform(name = "停薪类型") + private Integer stopType; + + /** + * 创建时间 + */ + @ElogTransform(name = "创建时间") + private Date createTime; + + /** + * 更新时间 + */ + @ElogTransform(name = "更新时间") + private Date updateTime; + + /** + * 创建人 + */ + @ElogTransform(name = "创建人") + private Long creator; + + /** + * 是否已删除。0:未删除、1:已删除 + */ + private Integer deleteType; + + /** + * 租户ID + */ + @ElogTransform(name = "租户") + private String tenantKey; + + /** + * 个税扣缴义务人的主键id + */ + @ElogTransform(name = "个税扣缴义务人id") + private Long taxAgentId; + + + + //---------条件------- + private Collection ids; + private Collection taxAgentIds; + private Collection employeeIds; + /** + * 状态 + */ + @JsonIgnore + private List runStatusList; + + private Set opts; +} diff --git a/src/com/engine/salary/entity/salaryarchive/po/SalaryArchiveTaxAgentPO.java b/src/com/engine/salary/entity/salaryarchive/po/SalaryArchiveTaxAgentPO.java new file mode 100644 index 000000000..1ec4f65e7 --- /dev/null +++ b/src/com/engine/salary/entity/salaryarchive/po/SalaryArchiveTaxAgentPO.java @@ -0,0 +1,99 @@ +package com.engine.salary.entity.salaryarchive.po; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.Date; + +/** + * 薪资档案个税扣缴义务人 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//hrsa_salary_archive_tax_agent +public class SalaryArchiveTaxAgentPO { + + /** + * 主键id + */ + private Long id; + + /** + * 薪资档案表的主键id + */ + private Long salaryArchiveId; + + /** + * 人员信息表的主键id + */ + private Long employeeId; + + /** + * 生效时间 + */ + private Date effectiveTime; + + /** + * 调整原因 + */ + private String adjustReason; + + private String description; + + /** + * 个税扣缴义务人的主键id + */ + private Long taxAgentId; + + /** + * 操作人 + */ + private Long operator; + + /** + * 操作时间 + */ + private Date operateTime; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 更新时间 + */ + private Date updateTime; + + /** + * 创建人 + */ + private Long creator; + + /** + * 是否已删除。0:未删除、1:已删除 + */ + private Integer deleteType; + + /** + * 租户ID + */ + private String tenantKey; + + + //条件 + Collection ids; + + Collection taxAgentIds; + +} diff --git a/src/com/engine/salary/entity/salaryformula/ExpressFormula.java b/src/com/engine/salary/entity/salaryformula/ExpressFormula.java new file mode 100644 index 000000000..442af9c76 --- /dev/null +++ b/src/com/engine/salary/entity/salaryformula/ExpressFormula.java @@ -0,0 +1,97 @@ +package com.engine.salary.entity.salaryformula; + +import com.engine.salary.entity.salaryformula.po.FormulaVar; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import net.minidev.json.annotate.JsonIgnore; + +import java.util.Date; +import java.util.List; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class ExpressFormula { + /** + * id + */ + private Long id; + /** + * 名称 + */ + private String name; + /** + * 备注 + */ + private String description; + /** + * 模块 + */ + @JsonIgnore + private String module; + /** + * 用途 + */ + @JsonIgnore + private String useFor; + /** + * 引用类型,formula,sql + */ + @JsonIgnore + private String referenceType; + /** + * 返回类型,number,string + */ + @JsonIgnore + private String returnType; + /** + * 校验类型,number,string + */ + @JsonIgnore + private String validateType; + /** + * 扩展参数 + */ + private String extendParam; + /** + * 公式内容 + */ + private String formula; + + /** + * 公式实际运行脚本 + */ + private String formulaRunScript; + + /** + * sql返回的列值 + */ + private String sqlReturnKey; + + /** + * 创建人 + */ + @JsonIgnore + private Long creator; + /** + * 是否删除0否1是 + */ + @JsonIgnore + private Integer deleteType; + /** + * 创建时间 + */ + @JsonIgnore + private Date createTime; + /** + * 修改时间 + */ + @JsonIgnore + private Date updateTime; + + + private List parameters; +} diff --git a/src/com/engine/salary/entity/salaryformula/bo/SalaryFormulaBO.java b/src/com/engine/salary/entity/salaryformula/bo/SalaryFormulaBO.java new file mode 100644 index 000000000..d8304094e --- /dev/null +++ b/src/com/engine/salary/entity/salaryformula/bo/SalaryFormulaBO.java @@ -0,0 +1,55 @@ +package com.engine.salary.entity.salaryformula.bo; + +import com.engine.salary.entity.salaryformula.ExpressFormula; +import com.engine.salary.entity.salaryformula.dto.ExpressFormulaDTO; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; + +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * 薪酬管理公式 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SalaryFormulaBO { + + public static List convert2DTO(List expressFormulas, Map returnTypeMap) { + if (CollectionUtils.isEmpty(expressFormulas)) { + return Collections.emptyList(); + } + return expressFormulas.stream() + .map(e -> { + String referenceType = returnTypeMap.getOrDefault(e.getId(), ""); + ExpressFormulaDTO build = ExpressFormulaDTO.builder() + .id(e.getId()) + .name(e.getName()) + .formula(e.getFormula()) + .description(e.getDescription()) + .extendParam(e.getExtendParam()) + .module(e.getModule()) + .parameters(e.getParameters()) + .referenceType(e.getReferenceType()) + .returnType(e.getReturnType()) + .useFor(e.getUseFor()) + .validateType(e.getValidateType()) + .build(); + if (StringUtils.isNotBlank(referenceType) && !StringUtils.equals(e.getReferenceType(), referenceType)) { + // 更换了取值方式,返回空对象进行前端处理 + build.setExtendParam(""); + build.setFormula(""); + build.setParameters(Collections.emptyList()); + build.setReferenceType(referenceType); + return build; + } + return build; + }) + .collect(Collectors.toList()); + } +} diff --git a/src/com/engine/salary/entity/salaryformula/config/FormluaConfig.java b/src/com/engine/salary/entity/salaryformula/config/FormluaConfig.java new file mode 100644 index 000000000..b84cf4f51 --- /dev/null +++ b/src/com/engine/salary/entity/salaryformula/config/FormluaConfig.java @@ -0,0 +1,27 @@ +package com.engine.salary.entity.salaryformula.config; + +import com.engine.salary.entity.salaryformula.po.FormulaPO; +import com.engine.salary.entity.salaryformula.po.FormulaVar; +import com.thoughtworks.xstream.annotations.XStreamAlias; +import com.thoughtworks.xstream.annotations.XStreamImplicit; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@XStreamAlias("FormluaConfig") +public class FormluaConfig { + + @XStreamImplicit + private List formulas; + + @XStreamImplicit + private List formulaVars; + +} diff --git a/src/com/engine/salary/entity/salaryformula/dto/ExpressFormulaDTO.java b/src/com/engine/salary/entity/salaryformula/dto/ExpressFormulaDTO.java new file mode 100644 index 000000000..57610003e --- /dev/null +++ b/src/com/engine/salary/entity/salaryformula/dto/ExpressFormulaDTO.java @@ -0,0 +1,69 @@ +package com.engine.salary.entity.salaryformula.dto; + +import com.engine.salary.entity.salaryformula.po.FormulaVar; +import com.engine.salary.util.valid.DataCheck; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * 薪酬管理公式 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class ExpressFormulaDTO { + + //公式id + private Long id; + + //公式名称 + private String name; + + //公式表达式 + private String formula; + + + + /** + * 备注 + */ + private String description; + /** + * 模块 + */ + @DataCheck(require = true,message = "模块为空") + private String module; + /** + * 用途 + */ + private String useFor; + /** + * 引用类型 + */ + private String referenceType; + /** + * 返回类型 + */ + private String returnType; + /** + * 校验类型 + */ + private String validateType; + /** + * 扩展参数 + */ + private String extendParam; + + + private List parameters; +} diff --git a/src/com/engine/salary/entity/salaryformula/dto/SalaryFormulaEmployeeDTO.java b/src/com/engine/salary/entity/salaryformula/dto/SalaryFormulaEmployeeDTO.java new file mode 100644 index 000000000..4d92e4d67 --- /dev/null +++ b/src/com/engine/salary/entity/salaryformula/dto/SalaryFormulaEmployeeDTO.java @@ -0,0 +1,112 @@ +package com.engine.salary.entity.salaryformula.dto; + +import com.engine.salary.annotation.SalaryFormulaVar; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 薪资公式计算器-员工基本信息 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalaryFormulaEmployeeDTO { + + private Long employeeId; + + @SalaryFormulaVar(defaultLabel = "个税扣缴义务人", labelId = 86184, dataType = "string") + private String taxAgentName; + @SalaryFormulaVar(defaultLabel = "个税扣缴义务人ID", labelId = 86184, dataType = "string") + private String taxAgentId; + + @SalaryFormulaVar(defaultLabel = "姓名", labelId = 85429, dataType = "string") + private String username; + + //部门 + @SalaryFormulaVar(defaultLabel = "部门", labelId = 86185, dataType = "departmentBrowser") + private String departmentName; + @SalaryFormulaVar(defaultLabel = "部门ID", labelId = 86185, dataType = "departmentBrowser") + private Long departmentId; + + + //分部 + @SalaryFormulaVar(defaultLabel = "分部", labelId = 82465, dataType = "subcompanyBrowser") + private String subcompanyName; + + @SalaryFormulaVar(defaultLabel = "分部ID", labelId = 82465, dataType = "subcompanyBrowser") + private Long subcompanyId; + + + + //岗位 + @SalaryFormulaVar(defaultLabel = "岗位", labelId = 90633, dataType = "jobtitleBrowser") + private String jobtitleName; + @SalaryFormulaVar(defaultLabel = "岗位ID", labelId = 90633, dataType = "jobtitleBrowser") + private Long jobtitleId; + + @SalaryFormulaVar(defaultLabel = "入职日期", labelId = 86319, dataType = "string") + private String companystartdate; + + //手机号 + @SalaryFormulaVar(defaultLabel = "手机号", labelId = 98621, dataType = "string") + private String mobile; + + //离职日期 + private String dissmissdate; + + //状态 + @SalaryFormulaVar(defaultLabel = "状态编码", labelId = 98621, dataType = "string") + private String status; + + @SalaryFormulaVar(defaultLabel = "状态", labelId = 98622, dataType = "string") + private String statusName; + + @SalaryFormulaVar(defaultLabel = "账号类型", labelId = 98622, dataType = "string") + private String accountTypeName; + + @SalaryFormulaVar(defaultLabel = "账号类型编码", labelId = 98622, dataType = "string") + private Integer accountType; + //工号 + @SalaryFormulaVar(defaultLabel = "工号", labelId = 98622, dataType = "string") + private String workcode; + + //性别 + @SalaryFormulaVar(defaultLabel = "性别", labelId = 98622, dataType = "string") + private String sex; + + + @SalaryFormulaVar(defaultLabel = "证件号码", labelId = 86318, dataType = "string") + private String idNo; + + //邮件 + @SalaryFormulaVar(defaultLabel = "邮件", labelId = 92919, dataType = "string") + private String email; + + + @SalaryFormulaVar(defaultLabel = "电话", labelId = 98620, dataType = "string") + private String telephone; + + + //职称 + @SalaryFormulaVar(defaultLabel = "职称", labelId = 98623, dataType = "jobcallBrowser") + private String jobcall; + @SalaryFormulaVar(defaultLabel = "职称ID", labelId = 98623, dataType = "jobcallBrowser") + private Long jobcallId; + + + @SalaryFormulaVar(defaultLabel = "出生日期", labelId = 98624, dataType = "string") + private String birthday; + + + + + +} diff --git a/src/com/engine/salary/entity/salaryformula/dto/SalaryFormulaTaxRateDTO.java b/src/com/engine/salary/entity/salaryformula/dto/SalaryFormulaTaxRateDTO.java new file mode 100644 index 000000000..0033a562c --- /dev/null +++ b/src/com/engine/salary/entity/salaryformula/dto/SalaryFormulaTaxRateDTO.java @@ -0,0 +1,71 @@ +package com.engine.salary.entity.salaryformula.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.math.BigDecimal; + +/** + * 薪资公式计算器-个税税率表 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalaryFormulaTaxRateDTO { + + /** + * 收入上限(含) + */ + //收入上限(含)", labelId = 84222, dataType = "number", fieldId = "income_upper_limit") + private BigDecimal incomeUpperLimit; + + /** + * 收入下限(不含) + */ + //收入下限(不含)", labelId = 84218, dataType = "number", fieldId = "income_lower_limit") + private BigDecimal incomeLowerLimit; + + /** + * 免税标准-固定值 + */ + //免税标准固定值", labelId = 84223, dataType = "number", fieldId = "duty_free_value") + private BigDecimal dutyFreeValue; + + /** + * 免税标准-比例 + */ + //免税标准比例", labelId = 84224, dataType = "number", fieldId = "duty_free_rate") + private BigDecimal dutyFreeRate; + + /** + * 应纳税所得额上限(含) + */ + //应纳税所得额上限", labelId = 84226, dataType = "number", fieldId = "taxable_income_ul") + private BigDecimal taxableIncomeULimit; + + /** + * 应纳税所得额下限(不含) + */ + //应纳税所得额下限", labelId = 84225, dataType = "number", fieldId = "taxable_income_ll") + private BigDecimal taxableIncomeLLimit; + + /** + * 税率 + */ + //税率", labelId = 84227, dataType = "number", fieldId = "tax_rate") + private BigDecimal taxRate; + + /** + * 速算扣除数 + */ + //速算扣除数", labelId = 84228, dataType = "number", fieldId = "tax_deduction") + private BigDecimal taxDeduction; +} diff --git a/src/com/engine/salary/entity/salaryformula/param/SalaryFormulaDetailQueryParam.java b/src/com/engine/salary/entity/salaryformula/param/SalaryFormulaDetailQueryParam.java new file mode 100644 index 000000000..aff64ddaa --- /dev/null +++ b/src/com/engine/salary/entity/salaryformula/param/SalaryFormulaDetailQueryParam.java @@ -0,0 +1,26 @@ +package com.engine.salary.entity.salaryformula.param; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author Harryxzy + * @ClassName SalaryFormulaDetailQueryParam + * @date 2023/07/25 10:17 + * @description + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalaryFormulaDetailQueryParam { + + // 公式id + private Long formulaId; + + // 取值类型 sql/formula + private String returnType; + +} diff --git a/src/com/engine/salary/entity/salaryformula/param/SalaryFormulaFieldQueryParam.java b/src/com/engine/salary/entity/salaryformula/param/SalaryFormulaFieldQueryParam.java new file mode 100644 index 000000000..bf9639405 --- /dev/null +++ b/src/com/engine/salary/entity/salaryformula/param/SalaryFormulaFieldQueryParam.java @@ -0,0 +1,29 @@ +package com.engine.salary.entity.salaryformula.param; + +import com.engine.salary.util.valid.DataCheck; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Map; + +/** + * 公式字段查询参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalaryFormulaFieldQueryParam { + + @DataCheck(require = true,message = "变量来源不可为空") + String sourceId; + + Map extendParam; +} diff --git a/src/com/engine/salary/entity/salaryformula/param/SalaryFormulaMockParam.java b/src/com/engine/salary/entity/salaryformula/param/SalaryFormulaMockParam.java new file mode 100644 index 000000000..f12d0decf --- /dev/null +++ b/src/com/engine/salary/entity/salaryformula/param/SalaryFormulaMockParam.java @@ -0,0 +1,25 @@ +package com.engine.salary.entity.salaryformula.param; + +import com.engine.salary.entity.salaryformula.po.FormulaVar; +import com.engine.salary.util.valid.DataCheck; +import com.engine.salary.util.valid.RuntimeTypeEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalaryFormulaMockParam { + /** + * id + */ + @DataCheck(require = true,message = "主键为空",runtime = RuntimeTypeEnum.UPDATE) + private Long id; + + private List parameters; +} diff --git a/src/com/engine/salary/entity/salaryformula/param/SalaryFormulaSaveParam.java b/src/com/engine/salary/entity/salaryformula/param/SalaryFormulaSaveParam.java new file mode 100644 index 000000000..705e09268 --- /dev/null +++ b/src/com/engine/salary/entity/salaryformula/param/SalaryFormulaSaveParam.java @@ -0,0 +1,71 @@ +package com.engine.salary.entity.salaryformula.param; + +import com.engine.salary.entity.salaryformula.po.FormulaVar; +import com.engine.salary.util.valid.DataCheck; +import com.engine.salary.util.valid.Modify; +import com.engine.salary.util.valid.ModifyTypeEnum; +import com.engine.salary.util.valid.RuntimeTypeEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalaryFormulaSaveParam { + /** + * id + */ + @DataCheck(require = true,message = "主键为空",runtime = RuntimeTypeEnum.UPDATE) + private Long id; + /** + * 名称 + */ + @DataCheck(require = true,message = "名称为空") + private String name; + /** + * 备注 + */ + private String description; + /** + * 模块 + */ + @DataCheck(require = true,message = "模块为空") + private String module; + /** + * 用途 + */ + private String useFor; + /** + * 引用类型 + * @see com.engine.salary.enums.salaryformula.ReferenceTypeEnum + */ + private String referenceType; + /** + * 返回类型 + */ + @DataCheck(require = true,message = "返回类型为空") + private String returnType; + /** + * 校验类型 + */ + @DataCheck(require = true,message = "校验类型为空") + private String validateType; + /** + * 扩展参数 + */ + private String extendParam; + /** + * 公式内容 + */ + @DataCheck(require = true,message = "公式内容为空") + @Modify(modifyType = ModifyTypeEnum.RESTORE_SQL) + private String formula; + + + private List parameters; +} diff --git a/src/com/engine/salary/entity/salaryformula/po/FormulaPO.java b/src/com/engine/salary/entity/salaryformula/po/FormulaPO.java new file mode 100644 index 000000000..8d688dd94 --- /dev/null +++ b/src/com/engine/salary/entity/salaryformula/po/FormulaPO.java @@ -0,0 +1,120 @@ +package com.engine.salary.entity.salaryformula.po; + +import com.thoughtworks.xstream.annotations.XStreamAlias; +import com.thoughtworks.xstream.annotations.XStreamAsAttribute; +import com.thoughtworks.xstream.annotations.XStreamImplicit; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.Date; +import java.util.List; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@XStreamAlias("Formula") +public class FormulaPO { + /** + * id + */ + @XStreamAlias("id") + @XStreamAsAttribute + private Long id; + /** + * 名称 + */ + @XStreamAlias("name") + @XStreamAsAttribute + private String name; + /** + * 备注 + */ + @XStreamAlias("description") + @XStreamAsAttribute + private String description; + /** + * 模块 + */ + @XStreamAlias("module") + @XStreamAsAttribute + private String module; + /** + * 用途 + */ + @XStreamAlias("useFor") + @XStreamAsAttribute + private String useFor; + /** + * 引用类型 + */ + @XStreamAlias("referenceType") + @XStreamAsAttribute + private String referenceType; + /** + * 返回类型 + */ + @XStreamAlias("returnType") + @XStreamAsAttribute + private String returnType; + /** + * 校验类型 + */ + @XStreamAlias("validateType") + @XStreamAsAttribute + private String validateType; + /** + * 扩展参数 + */ + @XStreamAlias("extendParam") + @XStreamAsAttribute + private String extendParam; + /** + * 公式内容 + */ + @XStreamAlias("formula") + @XStreamAsAttribute + private String formula; + + /** + * 公式实际运行脚本 + */ + @XStreamAlias("formulaRunScript") + @XStreamAsAttribute + private String formulaRunScript; + + /** + * 创建人 + */ + @XStreamAlias("creator") + @XStreamAsAttribute + private Long creator; + /** + * 是否删除0否1是 + */ + @XStreamAlias("deleteType") + @XStreamAsAttribute + private Integer deleteType; + /** + * 创建时间 + */ + @XStreamAlias("createTime") + @XStreamAsAttribute + private Date createTime; + /** + * 修改时间 + */ + @XStreamAlias("updateTime") + @XStreamAsAttribute + private Date updateTime; + + //主键id集合 + private Collection ids; + + + @XStreamImplicit + private List formulaVars; +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/salaryformula/po/FormulaVar.java b/src/com/engine/salary/entity/salaryformula/po/FormulaVar.java new file mode 100644 index 000000000..79f6bf88e --- /dev/null +++ b/src/com/engine/salary/entity/salaryformula/po/FormulaVar.java @@ -0,0 +1,100 @@ +package com.engine.salary.entity.salaryformula.po; + +import com.thoughtworks.xstream.annotations.XStreamAlias; +import com.thoughtworks.xstream.annotations.XStreamAsAttribute; +import com.thoughtworks.xstream.annotations.XStreamOmitField; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.Date; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@XStreamAlias("FormulaVar") +public class FormulaVar { + /** + * id + */ + @XStreamAlias("id") + @XStreamAsAttribute + private Long id; + /** + * 名称 + */ + @XStreamAlias("name") + @XStreamAsAttribute + private String name; + /** + * 公式id + */ + @XStreamAlias("formulaId") + @XStreamAsAttribute + private Long formulaId; + /** + * 字段id + */ + @XStreamAlias("fieldId") + @XStreamAsAttribute + private String fieldId; + /** + * 字段名称 + */ + @XStreamAlias("fieldName") + @XStreamAsAttribute + private String fieldName; + /** + * 字段类型,number,string + */ + @XStreamAlias("fieldType") + @XStreamAsAttribute + private String fieldType; + /** + * 来源 + */ + @XStreamAlias("source") + @XStreamAsAttribute + private String source; + /** + * 排序 + */ + @XStreamAlias("orderIndex") + @XStreamAsAttribute + private Integer orderIndex; + /** + * 创建人 + */ + @XStreamAlias("creator") + @XStreamAsAttribute + private Long creator; + /** + * 是否删除,0否1是 + */ + @XStreamAlias("deleteType") + @XStreamAsAttribute + private Integer deleteType; + /** + * 创建时间 + */ + @XStreamAlias("createTime") + @XStreamAsAttribute + private Date createTime; + /** + * 修改时间 + */ + @XStreamAlias("updateTime") + @XStreamAsAttribute + private Date updateTime; + + + //值 + @XStreamOmitField + private String content; + + + private Collection formulaIds; +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/salaryitem/bo/SalaryItemBO.java b/src/com/engine/salary/entity/salaryitem/bo/SalaryItemBO.java new file mode 100644 index 000000000..b0c5fd15f --- /dev/null +++ b/src/com/engine/salary/entity/salaryitem/bo/SalaryItemBO.java @@ -0,0 +1,302 @@ +package com.engine.salary.entity.salaryitem.bo; + +import com.engine.salary.annotation.SalaryTableColumn; +import com.engine.salary.constant.SalaryDefaultTenantConstant; +import com.engine.salary.entity.salaryformula.ExpressFormula; +import com.engine.salary.entity.salaryitem.dto.SalaryItemFormDTO; +import com.engine.salary.entity.salaryitem.dto.SalaryItemListDTO; +import com.engine.salary.entity.salaryitem.dto.SalaryItemSobListDTO; +import com.engine.salary.entity.salaryitem.param.SalaryItemSaveParam; +import com.engine.salary.entity.salaryitem.po.SalaryItemPO; +import com.engine.salary.entity.salaryitem.po.SysSalaryItemPO; +import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationAnnualListDTO; +import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationLaborListDTO; +import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationWageListDTO; +import com.engine.salary.enums.SalaryRoundingModeEnum; +import com.engine.salary.enums.SalarySystemTypeEnum; +import com.engine.salary.enums.SalaryValueTypeEnum; +import com.engine.salary.enums.salaryitem.SalaryDataTypeEnum; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.SalaryI18nUtil; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.math.NumberUtils; +import weaver.conn.util.IdGenerator; +import weaver.general.BaseBean; + +import java.lang.reflect.Field; +import java.util.*; +import java.util.stream.Collectors; + +/** + * 薪资项目 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SalaryItemBO { + + private static final BaseBean baseBean = new BaseBean(); + + + + + /** + * 构建薪资项目的查询参数 + * + * @param searchParam + * @param tenantKey + * @return + */ +// public static Wrapper buildQueryWrapper(SalaryItemSearchParam searchParam, String tenantKey) { +// LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(); +// wrapper.eq(SalaryItemPO::getTenantKey, tenantKey) +// .eq(SalaryItemPO::getDeleteType, 0) +// .like(!SalaryEntityUtil.isNullOrEmpty(searchParam.getName()), SalaryItemPO::getName, searchParam.getName()) +// .like(!SalaryEntityUtil.isNullOrEmpty(searchParam.getDescription()), SalaryItemPO::getDescription, searchParam.getDescription()) +// .notIn(SalaryEntityUtil.isNotNullOrEmpty(searchParam.getExcludeIds()), SalaryItemPO::getId, searchParam.getExcludeIds()); +// if (searchParam.getValueType() != null) { +// wrapper.eq(SalaryItemPO::getValueType, searchParam.getValueType().getValue()); +// } +// if (searchParam.getUseInEmployeeSalary() != null) { +// wrapper.eq(SalaryItemPO::getUseInEmployeeSalary, searchParam.getUseInEmployeeSalary().getValue()); +// } +// if (searchParam.getUseDefault() != null) { +// wrapper.eq(SalaryItemPO::getUseDefault, searchParam.getUseDefault().getValue()); +// } +// if (searchParam.getDataType() != null) { +// wrapper.eq(SalaryItemPO::getDataType, searchParam.getDataType().getValue()); +// } +// wrapper.orderByDesc(SalaryItemPO::getId); +// return wrapper; +// } + + /** + * 薪资项目po转换成薪资项目列表dto + * + * @param salaryItems 薪资项目po + * @param expressFormulas 公式详情 + * @return + */ + public static List convert2ListDTO(Collection salaryItems, List expressFormulas,List sysSalaryItemPOS) { + if (CollectionUtils.isEmpty(salaryItems)) { + return Collections.emptyList(); + } + + //强制开启账套的公式配置 + boolean openFormulaForcedEditing = "true".equals(baseBean.getPropValue("hrmSalary", "openFormulaForcedEditing")); + + Map formulaMap = SalaryEntityUtil.convert2Map(expressFormulas, ExpressFormula::getId, ExpressFormula::getFormula); + Map sysSalaryItemNameMap = SalaryEntityUtil.convert2Map(sysSalaryItemPOS, SysSalaryItemPO::getId, SysSalaryItemPO::getName); + return salaryItems.stream().map(salaryItemPO -> { + SalaryRoundingModeEnum salaryRoundingModeEnum = SalaryRoundingModeEnum.parseByValue(salaryItemPO.getRoundingMode()); + SalaryValueTypeEnum salaryValueTypeEnum = SalaryValueTypeEnum.parseByValue(salaryItemPO.getValueType()); + SalaryDataTypeEnum salaryDataTypeEnum = SalaryDataTypeEnum.parseByValue(salaryItemPO.getDataType()); + return SalaryItemListDTO.builder() + .id(salaryItemPO.getId()) + .code(salaryItemPO.getCode()) + .name(salaryItemPO.getName()) + .systemName(sysSalaryItemNameMap.getOrDefault(salaryItemPO.getSysSalaryItemId(), StringUtils.EMPTY)) + .useInEmployeeSalary(salaryItemPO.getUseInEmployeeSalary()) + .useDefault(salaryItemPO.getUseDefault()) + .hideDefault(salaryItemPO.getHideDefault() == null ? 0 : salaryItemPO.getHideDefault()) + .roundingMode(Optional.ofNullable(salaryRoundingModeEnum) + .map(e -> SalaryI18nUtil.getI18nLabel(e.getLabelId(), e.getDefaultLabel())) + .orElse(StringUtils.EMPTY)) + .pattern(salaryItemPO.getPattern()) + .valueType(Optional.ofNullable(salaryValueTypeEnum) + .map(e -> SalaryI18nUtil.getI18nLabel(e.getLabelId(), e.getDefaultLabel())) + .orElse(StringUtils.EMPTY)) + .dataType(Optional.ofNullable(salaryDataTypeEnum) + .map(e -> SalaryI18nUtil.getI18nLabel(e.getLabelId(), e.getDefaultLabel())) + .orElse(StringUtils.EMPTY)) + .formulaId(salaryItemPO.getFormulaId()) + .formulaContent(formulaMap.getOrDefault(salaryItemPO.getFormulaId(), "")) + .taxDeclarationColumn(buildTaxDeclarationColumn(salaryItemPO.getCode())) + .sortedIndex(salaryItemPO.getSortedIndex()) + .description(salaryItemPO.getDescription()) + .canDelete(true) + .canEdit(openFormulaForcedEditing ||Objects.equals(salaryItemPO.getCanEdit(), NumberUtils.INTEGER_ONE)) + .width(salaryItemPO.getWidth()) + .build(); + } + ).collect(Collectors.toList()); + } + + /** + * 薪资项目po转换成薪资账套中薪资项目列表dto + * + * @param salaryItems 薪资项目po + * @param expressFormulas 公式详情 + * @return + */ + public static List convert2itemSobListDTO(Collection salaryItems, List expressFormulas, List sysSalaryItemPOS) { + if (CollectionUtils.isEmpty(salaryItems)) { + return Collections.emptyList(); + } + //强制开启账套的公式配置 + boolean openFormulaForcedEditing = "true".equals(baseBean.getPropValue("hrmSalary", "openFormulaForcedEditing")); + + Map formulaMap = SalaryEntityUtil.convert2Map(expressFormulas, ExpressFormula::getId, ExpressFormula::getFormula); + Map sysSalaryItemNameMap = SalaryEntityUtil.convert2Map(sysSalaryItemPOS, SysSalaryItemPO::getId, SysSalaryItemPO::getName); + return salaryItems.stream().map(salaryItemPO -> { + SalaryRoundingModeEnum salaryRoundingModeEnum = SalaryRoundingModeEnum.parseByValue(salaryItemPO.getRoundingMode()); + SalaryValueTypeEnum salaryValueTypeEnum = SalaryValueTypeEnum.parseByValue(salaryItemPO.getValueType()); + SalaryDataTypeEnum salaryDataTypeEnum = SalaryDataTypeEnum.parseByValue(salaryItemPO.getDataType()); + return SalaryItemSobListDTO.builder() + .id(salaryItemPO.getId()) + .code(salaryItemPO.getCode()) + .name(salaryItemPO.getName()) + .systemName(sysSalaryItemNameMap.getOrDefault(salaryItemPO.getSysSalaryItemId(), StringUtils.EMPTY)) + .useInEmployeeSalary(salaryItemPO.getUseInEmployeeSalary()) + .useDefault(salaryItemPO.getUseDefault()) + .hideDefault(salaryItemPO.getHideDefault() == null ? 0 : salaryItemPO.getHideDefault()) + .roundingMode(salaryItemPO.getRoundingMode()) + .roundingModeShowValue(Optional.ofNullable(salaryRoundingModeEnum) + .map(e -> SalaryI18nUtil.getI18nLabel(e.getLabelId(), e.getDefaultLabel())) + .orElse(StringUtils.EMPTY)) + .pattern(salaryItemPO.getPattern()) + .valueType(salaryItemPO.getValueType()) + .valueTypeShowValue(Optional.ofNullable(salaryValueTypeEnum) + .map(e -> SalaryI18nUtil.getI18nLabel(e.getLabelId(), e.getDefaultLabel())) + .orElse(StringUtils.EMPTY)) + .dataType(salaryItemPO.getDataType()) + .dataTypeShowValue(Optional.ofNullable(salaryDataTypeEnum) + .map(e -> SalaryI18nUtil.getI18nLabel(e.getLabelId(), e.getDefaultLabel())) + .orElse(StringUtils.EMPTY)) + .formulaId(salaryItemPO.getFormulaId()) + .formulaContent(formulaMap.getOrDefault(salaryItemPO.getFormulaId(),"")) + .originFormulaContent(salaryValueTypeEnum.getValue() == SalaryValueTypeEnum.FORMULA.getValue() ? formulaMap.getOrDefault(salaryItemPO.getFormulaId(),"") : "") + .originSqlContent(salaryValueTypeEnum.getValue() == SalaryValueTypeEnum.SQL.getValue() ? formulaMap.getOrDefault(salaryItemPO.getFormulaId(),"") : "") + .taxDeclarationColumn(buildTaxDeclarationColumn(salaryItemPO.getCode())) + .canDelete(true) + .canEdit(openFormulaForcedEditing ||Objects.equals(salaryItemPO.getCanEdit(), NumberUtils.INTEGER_ONE)) + .sortedIndex(salaryItemPO.getSortedIndex()) + .description(salaryItemPO.getDescription()) + .salaryItemType(salaryItemPO.getUseInEmployeeSalary() == 0 ? "薪资项目" : "档案字段") + .defaultValue(salaryItemPO.getDefaultValue()) + .build(); + } + ).collect(Collectors.toList()); + } + + + /** + * 转换成薪资项目详情dto + * + * @param salaryItemPO + * @return + */ + public static SalaryItemFormDTO convert2FormDTO(SalaryItemPO salaryItemPO) { + return new SalaryItemFormDTO() + .setId(salaryItemPO.getId()) + .setName(salaryItemPO.getName()) + .setSystemType(salaryItemPO.getSystemType()) + .setUseDefault(salaryItemPO.getUseDefault()) + .setHideDefault(salaryItemPO.getHideDefault() == null ? 0 : salaryItemPO.getHideDefault()) + .setUseInEmployeeSalary(salaryItemPO.getUseInEmployeeSalary()) + .setRoundingMode(salaryItemPO.getRoundingMode()) + .setPattern(salaryItemPO.getPattern()) + .setValueType(salaryItemPO.getValueType()) + .setDataType(salaryItemPO.getDataType()) + .setFormulaId(salaryItemPO.getFormulaId()) + .setTaxDeclarationColumn(buildTaxDeclarationColumn(salaryItemPO.getCode())) + .setDescription(salaryItemPO.getDescription()) + .setCanEdit(salaryItemPO.getCanEdit()) + .setTaxAgentIds(salaryItemPO.getTaxAgentIds()) + .setSharedType(salaryItemPO.getSharedType()) + .setSortedIndex(salaryItemPO.getSortedIndex()) + .setWidth(salaryItemPO.getWidth()) + .setDefaultValue(salaryItemPO.getDefaultValue()); + } + + /** + * 个税申报表中的对应字段 + * + * @param code + * @return + */ + public static String buildTaxDeclarationColumn(String code) { + // 是否是个税申报表(正常工资薪金所得)中的字段 + for (Field declaredField : TaxDeclarationWageListDTO.class.getDeclaredFields()) { + if (!declaredField.isAnnotationPresent(SalaryTableColumn.class)) { + continue; + } + if (Objects.equals(code, declaredField.getName())) { + SalaryTableColumn annotation = declaredField.getAnnotation(SalaryTableColumn.class); + return SalaryI18nUtil.getI18nLabel((int) annotation.labelId(), annotation.text()); + } + } + // 是否是个税申报表(劳务报酬所得)中的字段 + for (Field declaredField : TaxDeclarationLaborListDTO.class.getDeclaredFields()) { + if (!declaredField.isAnnotationPresent(SalaryTableColumn.class)) { + continue; + } + // 时间紧迫,临时处理 + if (Objects.equals(code, declaredField.getName()) || Objects.equals(code, declaredField.getName() + "4")) { + SalaryTableColumn annotation = declaredField.getAnnotation(SalaryTableColumn.class); + return SalaryI18nUtil.getI18nLabel((int) annotation.labelId(), annotation.text()); + } + } + + // 是否是个税申报表(全年一次性奖金)中的字段 + for (Field declaredField : TaxDeclarationAnnualListDTO.class.getDeclaredFields()) { + if (!declaredField.isAnnotationPresent(SalaryTableColumn.class)) { + continue; + } + // 时间紧迫,临时处理 + if (Objects.equals(code, declaredField.getName()) || Objects.equals(code, declaredField.getName() + "2")) { + SalaryTableColumn annotation = declaredField.getAnnotation(SalaryTableColumn.class); + return SalaryI18nUtil.getI18nLabel((int) annotation.labelId(), annotation.text()); + } + } + return StringUtils.EMPTY; + } + + /** + * 保存参数/更新参数 转换成薪资项目po + * + * @param saveParam 保存参数/更新参数 + * @param employeeId 人员id + * @return + */ + public static SalaryItemPO convert2SalaryItemPO(SalaryItemSaveParam saveParam, Long employeeId) { + Date now = new Date(); + long id = com.engine.salary.util.db.IdGenerator.generate(); + SalaryItemPO salaryItemPO = SalaryItemPO.builder() + .id(id) + .code(IdGenerator.getUUID()) + .name(saveParam.getName()) + .systemType(SalarySystemTypeEnum.CUSTOM.getValue()) + .sysSalaryItemId(NumberUtils.LONG_ZERO) + .useDefault(saveParam.getUseDefault()) + .useInEmployeeSalary(saveParam.getUseInEmployeeSalary()) + .hideDefault(saveParam.getHideDefault()) + .roundingMode(saveParam.getRoundingMode() == null ? SalaryRoundingModeEnum.ROUNDING.getValue() : saveParam.getRoundingMode()) + .pattern(Optional.ofNullable(saveParam.getPattern()).orElse(2)) + .valueType(saveParam.getValueType()) + .dataType(saveParam.getDataType()) + .formulaId(Objects.equals(saveParam.getValueType(), SalaryValueTypeEnum.INPUT.getValue()) ? NumberUtils.LONG_ZERO : Optional.ofNullable(saveParam.getFormulaId()).orElse(NumberUtils.LONG_ZERO)) + .description(saveParam.getDescription()) + .canEdit(NumberUtils.INTEGER_ONE) + .creator(employeeId) + .deleteType(NumberUtils.INTEGER_ZERO) + .createTime(now) + .updateTime(now) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .sharedType(Optional.ofNullable(saveParam.getSharedType()).orElse(0)) + .taxAgentIds(saveParam.getTaxAgentIds()) + .sortedIndex(saveParam.getSortedIndex()) + .width(saveParam.getWidth()) + .defaultValue(saveParam.getDefaultValue()) + .build(); + // 开启了"薪资档案引用",取值方式固定为输入 +// if (Objects.equals(saveParam.getUseInEmployeeSalary(), NumberUtils.INTEGER_ONE)) { +// salaryItemPO.setValueType(SalaryValueTypeEnum.INPUT.getValue()); +// salaryItemPO.setFormulaId(NumberUtils.LONG_ZERO); +// } + return salaryItemPO; + } +} diff --git a/src/com/engine/salary/entity/salaryitem/bo/SysSalaryItemBO.java b/src/com/engine/salary/entity/salaryitem/bo/SysSalaryItemBO.java new file mode 100644 index 000000000..6defd200c --- /dev/null +++ b/src/com/engine/salary/entity/salaryitem/bo/SysSalaryItemBO.java @@ -0,0 +1,161 @@ +package com.engine.salary.entity.salaryitem.bo; + +import com.engine.salary.constant.SalaryDefaultTenantConstant; +import com.engine.salary.entity.salaryitem.dto.SalaryItemFormDTO; +import com.engine.salary.entity.salaryitem.dto.SysSalaryItemListDTO; +import com.engine.salary.entity.salaryitem.po.SalaryItemPO; +import com.engine.salary.entity.salaryitem.po.SysSalaryItemPO; +import com.engine.salary.enums.SalaryRoundingModeEnum; +import com.engine.salary.enums.SalarySystemTypeEnum; +import com.engine.salary.enums.SalaryValueTypeEnum; +import com.engine.salary.enums.salaryitem.SalaryDataTypeEnum; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.db.IdGenerator; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.math.NumberUtils; + +import java.time.LocalDateTime; +import java.util.*; +import java.util.stream.Collectors; + +/** + * 系统薪资项目 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SysSalaryItemBO { + /** + * 查询参数构建queryWrapper + * + * @param searchParam 系统薪资项目列表查询参数 + * @return + */ +// public static Wrapper buildQueryWrapper(SysSalaryItemSearchParam searchParam) { +// LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(); +// wrapper.eq(SysSalaryItemPO::getTenantKey, SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) +// .eq(SysSalaryItemPO::getDeleteType, 0) +// .like(SalaryEntityUtil.isNotNullOrEmpty(searchParam.getName()), SysSalaryItemPO::getName, searchParam.getName()) +// .notIn(SalaryEntityUtil.isNotNullOrEmpty(searchParam.getExcludeIds()), SysSalaryItemPO::getId, searchParam.getExcludeIds()); +// if (Objects.nonNull(searchParam.getDataType())) { +// wrapper.eq(SysSalaryItemPO::getDataType, searchParam.getDataType().getValue()); +// } +// wrapper.orderByDesc(SysSalaryItemPO::getId); +// return wrapper; +// } + + /** + * 系统薪资项目po转换成系统薪资项目列表dto + * + * @param sysSalaryItems 系统薪资项目集合 + * @return + */ + public static List convert2ListDTO(Collection sysSalaryItems) { + if (CollectionUtils.isEmpty(sysSalaryItems)) { + return Collections.emptyList(); + } + return sysSalaryItems.stream().map(sysSalaryItemPO -> { + SalaryRoundingModeEnum salaryRoundingModeEnum = SalaryRoundingModeEnum.parseByValue(sysSalaryItemPO.getRoundingMode()); + SalaryValueTypeEnum salaryValueTypeEnum = SalaryValueTypeEnum.parseByValue(sysSalaryItemPO.getValueType()); + SalaryDataTypeEnum salaryDataTypeEnum = SalaryDataTypeEnum.parseByValue(sysSalaryItemPO.getDataType()); + return SysSalaryItemListDTO.builder() + .id(sysSalaryItemPO.getId()) + .name(sysSalaryItemPO.getName()) + .roundingMode(Optional.ofNullable(salaryRoundingModeEnum) + .map(e -> SalaryI18nUtil.getI18nLabel(e.getLabelId(), e.getDefaultLabel())) + .orElse(StringUtils.EMPTY)) + .pattern(sysSalaryItemPO.getPattern()) + .valueType(Optional.ofNullable(salaryValueTypeEnum) + .map(e -> SalaryI18nUtil.getI18nLabel(e.getLabelId(), e.getDefaultLabel())) + .orElse(StringUtils.EMPTY)) + .dataType(Optional.ofNullable(salaryDataTypeEnum) + .map(e -> SalaryI18nUtil.getI18nLabel(e.getLabelId(), e.getDefaultLabel())) + .orElse(StringUtils.EMPTY)) + .taxDeclarationColumn(SalaryItemBO.buildTaxDeclarationColumn(sysSalaryItemPO.getCode())) + .build(); + } + ).collect(Collectors.toList()); + } + + /** + * 转换成薪资项目详情dto + * + * @param sysSalaryItemPO + * @return + */ + public static SalaryItemFormDTO convert2FormDTO(SysSalaryItemPO sysSalaryItemPO) { + return new SalaryItemFormDTO() + .setId(sysSalaryItemPO.getId()) + .setName(sysSalaryItemPO.getName()) + .setCanEdit(sysSalaryItemPO.getCanEdit()) + .setSystemType(sysSalaryItemPO.getSystemType()) + .setUseDefault(sysSalaryItemPO.getUseDefault()) + .setHideDefault(0) + .setUseInEmployeeSalary(sysSalaryItemPO.getUseInEmployeeSalary()) + .setRoundingMode(sysSalaryItemPO.getRoundingMode()) + .setPattern(sysSalaryItemPO.getPattern()) + .setValueType(sysSalaryItemPO.getValueType()) + .setDataType(sysSalaryItemPO.getDataType()) + .setFormulaId(sysSalaryItemPO.getFormulaId()) + .setDescription(sysSalaryItemPO.getDescription()) + .setSharedType(sysSalaryItemPO.getSharedType()) + .setTaxAgentIds(sysSalaryItemPO.getTaxAgentIds()); + } + + /** + * 系统薪资项目转换成自定义薪资项目 + * + * @param sysSalaryItems 系统薪资项目集合 + * @return + */ + public static List convert2SalaryItemPO(Collection sysSalaryItems, Long employeeId) { + if (CollectionUtils.isEmpty(sysSalaryItems)) { + return Collections.emptyList(); + } + LocalDateTime now = LocalDateTime.now(); + return sysSalaryItems.stream() + .map(e -> convert2SalaryItemPO(e, employeeId)) + .filter(Objects::nonNull) + .collect(Collectors.toList()); + } + + /** + * 系统薪资项目转换成自定义薪资项目 + * + * @param sysSalaryItemPO 系统薪资项目 + * @param employeeId 人员id + * @return + */ + private static SalaryItemPO convert2SalaryItemPO(SysSalaryItemPO sysSalaryItemPO, Long employeeId) { + if (sysSalaryItemPO == null) { + return null; + } + long id = IdGenerator.generate(); + return SalaryItemPO.builder() + .id(id) + .code(sysSalaryItemPO.getCode()) + .name(sysSalaryItemPO.getName()) + .systemType(SalarySystemTypeEnum.SYSTEM.getValue()) + .sysSalaryItemId(sysSalaryItemPO.getId()) + .useDefault(sysSalaryItemPO.getUseDefault()) + .useInEmployeeSalary(sysSalaryItemPO.getUseInEmployeeSalary()) + .roundingMode(sysSalaryItemPO.getRoundingMode()) + .pattern(sysSalaryItemPO.getPattern()) + .valueType(sysSalaryItemPO.getValueType()) + .dataType(sysSalaryItemPO.getDataType()) + .formulaId(sysSalaryItemPO.getFormulaId()) + .description(sysSalaryItemPO.getDescription()) + .canEdit(sysSalaryItemPO.getCanEdit()) + .creator(employeeId) + .deleteType(NumberUtils.INTEGER_ZERO) + .createTime(new Date()) + .updateTime(new Date()) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .taxAgentIds(sysSalaryItemPO.getTaxAgentIds()) + .sharedType(sysSalaryItemPO.getSharedType()) + .build(); + } +} diff --git a/src/com/engine/salary/entity/salaryitem/config/FormulaConfig.java b/src/com/engine/salary/entity/salaryitem/config/FormulaConfig.java new file mode 100644 index 000000000..4ba6d8581 --- /dev/null +++ b/src/com/engine/salary/entity/salaryitem/config/FormulaConfig.java @@ -0,0 +1,92 @@ +package com.engine.salary.entity.salaryitem.config; + +import com.thoughtworks.xstream.annotations.XStreamAlias; +import com.thoughtworks.xstream.annotations.XStreamAsAttribute; +import com.thoughtworks.xstream.annotations.XStreamImplicit; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.util.List; + + +@Data +@Accessors(chain = true) +@NoArgsConstructor +@AllArgsConstructor +@XStreamAlias("FormulaConfig") +public class FormulaConfig { + /** + * 主键id + */ + @XStreamAlias("id") + @XStreamAsAttribute + private Long id; + + /** + * 名称 + */ + @XStreamAlias("name") + @XStreamAsAttribute + private String name; + /** + * 备注 + */ + @XStreamAlias("description") + @XStreamAsAttribute + private String description; + /** + * 模块 + */ + @XStreamAlias("module") + @XStreamAsAttribute + private String module; + /** + * 用途 + */ + @XStreamAlias("useFor") + @XStreamAsAttribute + private String useFor; + /** + * 引用类型 + */ + @XStreamAlias("referenceType") + @XStreamAsAttribute + private String referenceType; + /** + * 返回类型 + */ + @XStreamAlias("returnType") + @XStreamAsAttribute + private String returnType; + /** + * 校验类型 + */ + @XStreamAlias("validateType") + @XStreamAsAttribute + private String validateType; + /** + * 扩展参数 + */ + @XStreamAlias("extendParam") + @XStreamAsAttribute + private String extendParam; + /** + * 公式内容 + */ + @XStreamAlias("formula") + @XStreamAsAttribute + private String formula; + + /** + * 公式实际运行脚本 + */ + @XStreamAlias("formulaRunScript") + @XStreamAsAttribute + private String formulaRunScript; + + @XStreamImplicit + private List varConfigs; + +} diff --git a/src/com/engine/salary/entity/salaryitem/config/FormulaVarConfig.java b/src/com/engine/salary/entity/salaryitem/config/FormulaVarConfig.java new file mode 100644 index 000000000..dcd2fc438 --- /dev/null +++ b/src/com/engine/salary/entity/salaryitem/config/FormulaVarConfig.java @@ -0,0 +1,74 @@ +package com.engine.salary.entity.salaryitem.config; + +import com.thoughtworks.xstream.annotations.XStreamAlias; +import com.thoughtworks.xstream.annotations.XStreamAsAttribute; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + + +@Data +@Accessors(chain = true) +@NoArgsConstructor +@AllArgsConstructor +@XStreamAlias("FormulaVarConfig") +public class FormulaVarConfig { + + /** + * 主键id + */ + @XStreamAlias("id") + @XStreamAsAttribute + private Long id; + + /** + * 名称 + */ + @XStreamAlias("name") + @XStreamAsAttribute + private String name; + + /** + * 公式id + */ + @XStreamAlias("formulaId") + @XStreamAsAttribute + private Long formulaId; + + /** + * 字段id + */ + @XStreamAlias("fieldId") + @XStreamAsAttribute + private String fieldId; + + /** + * 字段名称 + */ + @XStreamAlias("fieldName") + @XStreamAsAttribute + private String fieldName; + + /** + * 字段类型,number,string + */ + @XStreamAlias("fieldType") + @XStreamAsAttribute + private String fieldType; + + /** + * 来源 + */ + @XStreamAlias("source") + @XStreamAsAttribute + private String source; + + /** + * 排序 + */ + @XStreamAlias("orderIndex") + @XStreamAsAttribute + private Integer orderIndex; + +} diff --git a/src/com/engine/salary/entity/salaryitem/config/SalaryItemAllConfig.java b/src/com/engine/salary/entity/salaryitem/config/SalaryItemAllConfig.java new file mode 100644 index 000000000..06e657bb5 --- /dev/null +++ b/src/com/engine/salary/entity/salaryitem/config/SalaryItemAllConfig.java @@ -0,0 +1,23 @@ +package com.engine.salary.entity.salaryitem.config; + +import com.engine.salary.entity.salaryitem.po.SalaryItemPO; +import com.thoughtworks.xstream.annotations.XStreamAlias; +import com.thoughtworks.xstream.annotations.XStreamImplicit; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@XStreamAlias("SalaryItemConfig") +public class SalaryItemAllConfig { + + @XStreamImplicit + List salaryItems; +} diff --git a/src/com/engine/salary/entity/salaryitem/config/SalaryItemConfig.java b/src/com/engine/salary/entity/salaryitem/config/SalaryItemConfig.java new file mode 100644 index 000000000..8c1214012 --- /dev/null +++ b/src/com/engine/salary/entity/salaryitem/config/SalaryItemConfig.java @@ -0,0 +1,179 @@ +package com.engine.salary.entity.salaryitem.config; + +import com.engine.salary.enums.SalaryRoundingModeEnum; +import com.engine.salary.enums.SalarySystemTypeEnum; +import com.engine.salary.enums.SalaryValueTypeEnum; +import com.engine.salary.enums.salaryitem.SalaryDataTypeEnum; +import com.thoughtworks.xstream.annotations.XStreamAlias; +import com.thoughtworks.xstream.annotations.XStreamAsAttribute; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + + +@Data +@Accessors(chain = true) +@NoArgsConstructor +@AllArgsConstructor +@XStreamAlias("SalaryItemConfig") +public class SalaryItemConfig { + /** + * 主键id + */ + @XStreamAlias("id") + @XStreamAsAttribute + private Long id; + + /** + * 名称 + */ + @XStreamAlias("name") + @XStreamAsAttribute + private String name; + + /** + * 编号 + */ + @XStreamAlias("code") + @XStreamAsAttribute + private String code; + + /** + * 是否是系统项目 + * + * @see SalarySystemTypeEnum + */ + @XStreamAlias("systemType") + @XStreamAsAttribute + private Integer systemType; + + /** + * 系统薪资项目的id(是从哪个系统薪资项目复制过来的) + */ + @XStreamAlias("sysSalaryItemId") + @XStreamAsAttribute + private Long sysSalaryItemId; + + /** + * 默认使用。0:默认不适用、1:默认使用 + */ + @XStreamAlias("useDefault") + @XStreamAsAttribute + private Integer useDefault; + + /** + * 薪资档案引用。0:薪资档案未引用、1:薪资档案引用 + */ + @XStreamAlias("useInEmployeeSalary") + @XStreamAsAttribute + private Integer useInEmployeeSalary; + + /** + * 核算时隐藏 + */ + @XStreamAlias("hideDefault") + @XStreamAsAttribute + private Integer hideDefault; + + /** + * 进位规则 + * + * @see SalaryRoundingModeEnum + */ + @XStreamAlias("roundingMode") + @XStreamAsAttribute + private Integer roundingMode; + + /** + * 保留的小数位数 + */ + @XStreamAlias("pattern") + @XStreamAsAttribute + private Integer pattern; + + /** + * 取值方式 + * + * @see SalaryValueTypeEnum + */ + @XStreamAlias("valueType") + @XStreamAsAttribute + private Integer valueType; + + /** + * 字段类型 + * + * @see SalaryDataTypeEnum + */ + @XStreamAlias("dataType") + @XStreamAsAttribute + private String dataType; + + /** + * 公式 + */ + @XStreamAlias("formulaId") + @XStreamAsAttribute + private Long formulaId; + + /** + * 备注 + */ + @XStreamAlias("description") + @XStreamAsAttribute + private String description; + + /** + * 是否可以编辑。0:不可编辑、1:可编辑 + */ + @XStreamAlias("canEdit") + @XStreamAsAttribute + private Integer canEdit; + + /** + * 可见性 + */ + @XStreamAlias("sharedType") + @XStreamAsAttribute + private Integer sharedType; + + /** + * 可见范围 + */ + @XStreamAlias("taxAgentIds") + @XStreamAsAttribute + private String taxAgentIds; + + /** + * 0不可删除,1可删除 + */ + @XStreamAlias("canDelete") + @XStreamAsAttribute + private Integer canDelete; + + /** + * 排序 + */ + @XStreamAlias("sortedIndex") + @XStreamAsAttribute + private Integer sortedIndex; + + /** + * 宽度 + */ + @XStreamAlias("width") + @XStreamAsAttribute + private Integer width; + + /** + * 默认值 + */ + @XStreamAlias("defaultValue") + @XStreamAsAttribute + private String defaultValue; + + @XStreamAlias("FormulaConfig") + private FormulaConfig formulaConfig; + +} diff --git a/src/com/engine/salary/entity/salaryitem/config/SalaryItemExcelConfig.java b/src/com/engine/salary/entity/salaryitem/config/SalaryItemExcelConfig.java new file mode 100644 index 000000000..ab04abfae --- /dev/null +++ b/src/com/engine/salary/entity/salaryitem/config/SalaryItemExcelConfig.java @@ -0,0 +1,114 @@ +package com.engine.salary.entity.salaryitem.config; + +import com.engine.salary.enums.SalaryRoundingModeEnum; +import com.engine.salary.enums.SalaryValueTypeEnum; +import com.engine.salary.enums.salaryitem.SalaryDataTypeEnum; +import com.engine.salary.util.excel.ExcelHead; +import com.engine.salary.util.excel.ExcelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + + +@Data +@Accessors(chain = true) +@NoArgsConstructor +@AllArgsConstructor +public class SalaryItemExcelConfig { + + /** + * 名称 + */ + @ExcelHead(title="名称",dataIndex = "name") + @ExcelProperty(index = 0) + private String name; + + /** + * 默认使用。0:默认不适用、1:默认使用 + */ + @ExcelHead(title="是否默认使用",dataIndex = "useDefault") + @ExcelProperty(index = 1) + private String useDefault; + + /** + * 核算是否隐藏 + */ + @ExcelHead(title="核算是否隐藏",dataIndex = "hideDefault") + @ExcelProperty(index = 2) + private String hideDefault; + + /** + * 字段类型 + * + * @see SalaryDataTypeEnum + */ + @ExcelHead(title="字段类型",dataIndex = "dataType") + @ExcelProperty(index = 3) + private String dataType; + + /** + * 进位规则 + * + * @see SalaryRoundingModeEnum + */ + @ExcelHead(title="进位规则",dataIndex = "roundingMode") + @ExcelProperty(index = 4) + private String roundingMode; + + /** + * 保留的小数位数 + */ + @ExcelHead(title="保留的小数位数",dataIndex = "pattern") + @ExcelProperty(index = 5) + private String pattern; + + /** + * 取值方式 + * + * @see SalaryValueTypeEnum + */ + @ExcelHead(title="取值方式",dataIndex = "valueType") + @ExcelProperty(index = 6) + private String valueType; + + /** + * 公式 + */ + @ExcelHead(title="公式",dataIndex = "formula") + @ExcelProperty(index = 7) + private String formula; + + @ExcelHead(title="sql返回字段",dataIndex = "sqlReturnKey") + @ExcelProperty(index = 8) + private String extendParam; + + /** + * 排序 + */ + @ExcelHead(title="排序",dataIndex = "sortedIndex") + @ExcelProperty(index = 9) + private String sortedIndex; + + /** + * 宽度 + */ + @ExcelHead(title="宽度",dataIndex = "width") + @ExcelProperty(index = 10) + private String width; + + /** + * 默认值 + */ + @ExcelHead(title="默认值",dataIndex = "defaultValue") + @ExcelProperty(index = 11) + private String defaultValue; + + /** + * 备注 + */ + @ExcelHead(title="备注",dataIndex = "description") + @ExcelProperty(index = 12) + private String description; + +} diff --git a/src/com/engine/salary/entity/salaryitem/dto/SalaryFieldListDTO.java b/src/com/engine/salary/entity/salaryitem/dto/SalaryFieldListDTO.java new file mode 100644 index 000000000..e8a2afa8f --- /dev/null +++ b/src/com/engine/salary/entity/salaryitem/dto/SalaryFieldListDTO.java @@ -0,0 +1,87 @@ +package com.engine.salary.entity.salaryitem.dto; + +import com.cloudstore.eccom.pc.table.WeaTableType; +import com.engine.salary.annotation.SalaryTable; +import com.engine.salary.annotation.SalaryTableColumn; +import com.engine.salary.annotation.SalaryTableOperate; +import com.engine.salary.annotation.TableTitle; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 字段管理列表 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@SalaryTable(pageId = "a4f85287-e3f9-ab21-adn9-7d06e54y6r98", tableType = WeaTableType.CHECKBOX, operates = {@SalaryTableOperate(text = "编辑", index = "0"), @SalaryTableOperate(text = "删除", index = "1")}) +public class SalaryFieldListDTO { + + @JsonSerialize(using = ToStringSerializer.class) + @SalaryTableColumn(column = "id", display = false) + private Long id; + + @SalaryTableColumn(text = "名称", width = "10%", column = "name") + @TableTitle(title = "名称",dataIndex = "name",key = "name") + private String name; + + //默认使用 + @SalaryTableColumn(text = "默认使用", width = "10%", column = "useDefault") + @TableTitle(title = "默认使用",dataIndex = "useDefault",key = "useDefault") + private Integer useDefault; + + //核算时隐藏 + @SalaryTableColumn(text = "核算时隐藏", width = "10%", column = "hideDefault") + @TableTitle(title = "核算时隐藏",dataIndex = "hideDefault",key = "hideDefault") + private Integer hideDefault; + + //进位规则 + @SalaryTableColumn(text = "进位规则", width = "10%", column = "roundingMode",transmethod = "com.engine.salary.transmethod.TransMethod.roundingMode") + @TableTitle(title = "进位规则",dataIndex = "roundingMode",key = "roundingMode") + private String roundingMode; + + //保留小数位 + @SalaryTableColumn(text = "保留小数位", width = "10%", column = "pattern") + @TableTitle(title = "保留小数位",dataIndex = "pattern",key = "pattern") + private Integer pattern; + + //取值方式 + @SalaryTableColumn(text = "取值方式", width = "10%", column = "valueType",transmethod = "com.engine.salary.transmethod.TransMethod.datasource") + @TableTitle(title = "取值方式",dataIndex = "valueType",key = "valueType") + private String valueType; + + //公式id + private Long formulaId; + + //公式内容 + private String formulaContent; + + //备注 + @SalaryTableColumn(text = "备注", width = "10%", column = "description") + @TableTitle(title = "备注",dataIndex = "description",key = "description") + private String description; + + + //是否可以编辑 + private Boolean canEdit; + + //是否可以删除 + private Boolean canDelete; + + @SalaryTableColumn(text = "显示顺序", width = "10%", column = "sortedIndex") + @TableTitle(title = "显示顺序",dataIndex = "sortedIndex",key = "sortedIndex") + private String sortedIndex; + + @SalaryTableColumn(text = "操作", width = "20%", column = "operate") + private String operate; +} diff --git a/src/com/engine/salary/entity/salaryitem/dto/SalaryItemFormDTO.java b/src/com/engine/salary/entity/salaryitem/dto/SalaryItemFormDTO.java new file mode 100644 index 000000000..15585ff2d --- /dev/null +++ b/src/com/engine/salary/entity/salaryitem/dto/SalaryItemFormDTO.java @@ -0,0 +1,104 @@ +package com.engine.salary.entity.salaryitem.dto; + +import com.engine.salary.enums.SalaryRoundingModeEnum; +import com.engine.salary.enums.SalarySystemTypeEnum; +import com.engine.salary.enums.SalaryValueTypeEnum; +import com.engine.salary.enums.salaryitem.SalaryDataTypeEnum; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +/** + * 薪资项目表单 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Accessors(chain = true) +@NoArgsConstructor +@AllArgsConstructor +public class SalaryItemFormDTO { + + //主键id") + @JsonSerialize(using = ToStringSerializer.class) + private Long id; + + //名称") + private String name; + + //是否是系统内置的薪资项目") + /** + * @see SalarySystemTypeEnum + */ + private Integer systemType; + + //默认使用") + private Integer useDefault; + + //核算时隐藏") + private Integer hideDefault; + + //薪资档案引用") + private Integer useInEmployeeSalary; + + //字段类型 + /** + * @see SalaryDataTypeEnum + */ + private String dataType; + + //舍入规则") + /** + * @see SalaryRoundingModeEnum + */ + private Integer roundingMode; + + //保留小数位") + private Integer pattern; + + //取值方式") + /** + * @see SalaryValueTypeEnum + */ + private Integer valueType; + + //公式") + private Long formulaId; + + //公式内容") + private String formulaContent; + + // 用于前端展示 公式原始内容 + private String originFormulaContent; + // 用于前端展示 原始sql + private String originSqlContent; + + //备注") + private String description; + + //个税申报表对应字段") + private String taxDeclarationColumn; + + @JsonIgnore + //是否可以编辑") + private Integer canEdit; + + private Integer sharedType; + + private String taxAgentIds; + + private Integer sortedIndex; + + // 宽度 + private Integer width; + + // 默认值 + private String defaultValue; +} diff --git a/src/com/engine/salary/entity/salaryitem/dto/SalaryItemListDTO.java b/src/com/engine/salary/entity/salaryitem/dto/SalaryItemListDTO.java new file mode 100644 index 000000000..1e0af69d4 --- /dev/null +++ b/src/com/engine/salary/entity/salaryitem/dto/SalaryItemListDTO.java @@ -0,0 +1,113 @@ +package com.engine.salary.entity.salaryitem.dto; + +import com.cloudstore.eccom.pc.table.WeaTableType; +import com.engine.salary.annotation.SalaryTable; +import com.engine.salary.annotation.SalaryTableColumn; +import com.engine.salary.annotation.SalaryTableOperate; +import com.engine.salary.annotation.TableTitle; +import com.engine.salary.enums.salaryitem.SalaryDataTypeEnum; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 薪资项目列表 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@SalaryTable(pageId = "a4f85287-e3f9-7721-adn9-7d06e54y6r98", tableType = WeaTableType.CHECKBOX, operates = {@SalaryTableOperate(text = "编辑", index = "0"), @SalaryTableOperate(text = "删除", index = "1")}) +public class SalaryItemListDTO { + + @JsonSerialize(using = ToStringSerializer.class) + @SalaryTableColumn(column = "id", display = false) + private Long id; + + @SalaryTableColumn(text = "名称", width = "10%", column = "name") + @TableTitle(title = "名称",dataIndex = "name",key = "name") + private String name; + private String code; + + @SalaryTableColumn(text = "系统名", width = "10%", column = "systemName") + @TableTitle(title = "系统名",dataIndex = "systemName",key = "systemName") + private String systemName; + + //薪资档案引用 +// @SalaryTableColumn(text = "薪资档案引用", width = "10%", column = "useInEmployeeSalary") +// @TableTitle(title = "薪资档案引用",dataIndex = "useInEmployeeSalary",key = "useInEmployeeSalary") + private Integer useInEmployeeSalary; + + //默认使用 + @SalaryTableColumn(text = "默认使用", width = "10%", column = "useDefault") + @TableTitle(title = "默认使用",dataIndex = "useDefault",key = "useDefault") + private Integer useDefault; + + //核算时隐藏 + @SalaryTableColumn(text = "核算时隐藏", width = "10%", column = "hideDefault") + @TableTitle(title = "核算时隐藏",dataIndex = "hideDefault",key = "hideDefault") + private Integer hideDefault; + + //进位规则 + @SalaryTableColumn(text = "进位规则", width = "10%", column = "roundingMode",transmethod = "com.engine.salary.transmethod.TransMethod.roundingMode") + @TableTitle(title = "进位规则",dataIndex = "roundingMode",key = "roundingMode") + private String roundingMode; + + //保留小数位 + @SalaryTableColumn(text = "保留小数位", width = "10%", column = "pattern") + @TableTitle(title = "保留小数位",dataIndex = "pattern",key = "pattern") + private Integer pattern; + + //取值方式 + @SalaryTableColumn(text = "取值方式", width = "10%", column = "valueType",transmethod = "com.engine.salary.transmethod.TransMethod.datasource") + @TableTitle(title = "取值方式",dataIndex = "valueType",key = "valueType") + private String valueType; + + /** + * @see SalaryDataTypeEnum + */ + @SalaryTableColumn(text = "字段类型", width = "10%", column = "dataType",transmethod = "com.engine.salary.transmethod.TransMethod.dataType") + @TableTitle(title = "字段类型",dataIndex = "dataType",key = "dataType") + private String dataType; + + //公式id + private Long formulaId; + + //公式内容 + private String formulaContent; + + @SalaryTableColumn(text = "个税申报表对应字段", width = "10%", column = "taxDeclarationColumn") + @TableTitle(title = "个税申报表对应字段",dataIndex = "taxDeclarationColumn",key = "taxDeclarationColumn") + private String taxDeclarationColumn; + + //备注 + @SalaryTableColumn(text = "备注", width = "10%", column = "description") + @TableTitle(title = "备注",dataIndex = "description",key = "description") + private String description; + + + //是否可以编辑 + private Boolean canEdit; + + //是否可以删除 + private Boolean canDelete; + + //排序 + @SalaryTableColumn(text = "显示顺序", width = "10%", column = "sortedIndex") + @TableTitle(title = "显示顺序",dataIndex = "sortedIndex",key = "sortedIndex") + private Integer sortedIndex; + + // 宽度 + private Integer width; + + @SalaryTableColumn(text = "操作", width = "20%", column = "operate") + private String operate; +} diff --git a/src/com/engine/salary/entity/salaryitem/dto/SalaryItemSearchConditionDTO.java b/src/com/engine/salary/entity/salaryitem/dto/SalaryItemSearchConditionDTO.java new file mode 100644 index 000000000..ebb6836b5 --- /dev/null +++ b/src/com/engine/salary/entity/salaryitem/dto/SalaryItemSearchConditionDTO.java @@ -0,0 +1,98 @@ +//package com.engine.salary.entity.salaryitem.dto; +// +//import com.weaver.common.component.search.item.WeaSearchConditionItemType; +//import com.weaver.hrm.salary.annotation.SalarySearchCondition; +//import com.weaver.hrm.salary.annotation.SalarySearchConditionItem; +//import com.weaver.hrm.salary.enums.SalaryItemCategoryEnum; +//import com.weaver.hrm.salary.enums.SalaryItemTypeEnum; +//import com.weaver.hrm.salary.enums.SalaryOnOffEnum; +//import com.weaver.hrm.salary.enums.SalaryValueTypeEnum; +//import io.swagger.annotations.ApiModelProperty; +//import lombok.AllArgsConstructor; +//import lombok.Builder; +//import lombok.Data; +//import lombok.NoArgsConstructor; +// +//import java.util.Collection; +// +///** +// * @description: 薪资项目查询条件 +// * @author: xiajun +// * @modified By: xiajun +// * @date: Created in 10/28/21 9:27 AM +// * @version:v1.0 +// */ +//@Data +//@Builder +//@NoArgsConstructor +//@AllArgsConstructor +//public class SalaryItemSearchConditionDTO { +// +// @SalarySearchCondition( +// label = "薪资项目", +// labelId = 84960, +// needQuickSearch = true, +// quickSearchKey = "name", +// items = { +// @SalarySearchConditionItem(itemType = WeaSearchConditionItemType.INPUT, name = "name"), +// } +// ) +// private String name; +// +// @SalarySearchCondition( +// label = "备注", +// labelId = 84961, +// items = { +// @SalarySearchConditionItem(itemType = WeaSearchConditionItemType.INPUT, name = "description"), +// } +// ) +// private String description; +// +// @SalarySearchCondition( +// label = "属性", +// labelId = 84757, +// items = { +// @SalarySearchConditionItem(itemType = WeaSearchConditionItemType.SELECT, name = "category", optionsEnum = SalaryItemCategoryEnum.class), +// } +// ) +// private SalaryItemCategoryEnum category; +// +// @SalarySearchCondition( +// label = "类型", +// labelId = 84758, +// items = { +// @SalarySearchConditionItem(itemType = WeaSearchConditionItemType.SELECT, name = "itemType", optionsEnum = SalaryItemTypeEnum.class), +// } +// ) +// private SalaryItemTypeEnum itemType; +// +// @SalarySearchCondition( +// label = "薪资档案引用", +// labelId = 84759, +// items = { +// @SalarySearchConditionItem(itemType = WeaSearchConditionItemType.SELECT, name = "useInEmployeeSalary", optionsEnum = SalaryOnOffEnum.class), +// } +// ) +// private SalaryOnOffEnum useInEmployeeSalary; +// +// @SalarySearchCondition( +// label = "默认使用", +// labelId = 84760, +// items = { +// @SalarySearchConditionItem(itemType = WeaSearchConditionItemType.SELECT, name = "useDefault", optionsEnum = SalaryOnOffEnum.class), +// } +// ) +// private SalaryOnOffEnum useDefault; +// +// @SalarySearchCondition( +// label = "取值方式", +// labelId = 84766, +// items = { +// @SalarySearchConditionItem(itemType = WeaSearchConditionItemType.SELECT, name = "valueType", optionsEnum = SalaryValueTypeEnum.class) +// } +// ) +// private SalaryValueTypeEnum valueType; +// +// //需要排除的系统薪资项目") +// private Collection excludeIds; +//} diff --git a/src/com/engine/salary/entity/salaryitem/dto/SalaryItemSobListDTO.java b/src/com/engine/salary/entity/salaryitem/dto/SalaryItemSobListDTO.java new file mode 100644 index 000000000..f90b6ff41 --- /dev/null +++ b/src/com/engine/salary/entity/salaryitem/dto/SalaryItemSobListDTO.java @@ -0,0 +1,123 @@ +package com.engine.salary.entity.salaryitem.dto; + +import com.engine.salary.annotation.SalaryTableColumn; +import com.engine.salary.annotation.TableTitle; +import com.engine.salary.enums.salaryitem.SalaryDataTypeEnum; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author Harryxzy + * @date 2023/06/01 17:05 + * @description 薪资账套薪资项目列表 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalaryItemSobListDTO { + + @JsonSerialize(using = ToStringSerializer.class) + @SalaryTableColumn(column = "id", display = false) + private Long id; + + @SalaryTableColumn(text = "名称", width = "10%", column = "name") + @TableTitle(title = "名称",dataIndex = "name",key = "name") + private String name; + private String code; + + @SalaryTableColumn(text = "系统名", width = "10%", column = "systemName") + @TableTitle(title = "系统名",dataIndex = "systemName",key = "systemName") + private String systemName; + + //薪资档案引用 +// @SalaryTableColumn(text = "薪资档案引用", width = "10%", column = "useInEmployeeSalary") +// @TableTitle(title = "薪资档案引用",dataIndex = "useInEmployeeSalary",key = "useInEmployeeSalary") + private Integer useInEmployeeSalary; + + // 薪资项目类型 + @SalaryTableColumn(text = "项目类型", width = "10%", column = "salaryItemType") + @TableTitle(title = "项目类型",dataIndex = "salaryItemType",key = "salaryItemType") + private String salaryItemType; + + //默认使用 + @SalaryTableColumn(text = "默认使用", width = "10%", column = "useDefault") + @TableTitle(title = "默认使用",dataIndex = "useDefault",key = "useDefault") + private Integer useDefault; + + //核算时默认隐藏 + @SalaryTableColumn(text = "核算时隐藏", width = "10%", column = "hideDefault") + @TableTitle(title = "核算时隐藏",dataIndex = "hideDefault",key = "hideDefault") + private Integer hideDefault; + + //进位规则 + @SalaryTableColumn(text = "进位规则", width = "10%", column = "roundingModeShowValue",transmethod = "com.engine.salary.transmethod.TransMethod.roundingMode") + @TableTitle(title = "进位规则",dataIndex = "roundingModeShowValue",key = "roundingModeShowValue") + private String roundingModeShowValue; + + private Integer roundingMode; + + + //保留小数位 + @SalaryTableColumn(text = "保留小数位", width = "10%", column = "pattern") + @TableTitle(title = "保留小数位",dataIndex = "pattern",key = "pattern") + private Integer pattern; + + //取值方式 + @SalaryTableColumn(text = "取值方式", width = "10%", column = "valueTypeShowValue",transmethod = "com.engine.salary.transmethod.TransMethod.datasource") + @TableTitle(title = "取值方式",dataIndex = "valueTypeShowValue",key = "valueTypeShowValue") + private String valueTypeShowValue; + + private Integer valueType; + + /** + * @see SalaryDataTypeEnum + */ + @SalaryTableColumn(text = "字段类型", width = "10%", column = "dataTypeShowValue",transmethod = "com.engine.salary.transmethod.TransMethod.dataType") + @TableTitle(title = "字段类型",dataIndex = "dataTypeShowValue",key = "dataTypeShowValue") + private String dataTypeShowValue; + + private String dataType; + + //公式id + private Long formulaId; + + //公式内容 + private String formulaContent; + + @SalaryTableColumn(text = "个税申报表对应字段", width = "10%", column = "taxDeclarationColumn") + @TableTitle(title = "个税申报表对应字段",dataIndex = "taxDeclarationColumn",key = "taxDeclarationColumn") + private String taxDeclarationColumn; + + // 用于前端展示 公式原始内容 + private String originFormulaContent; + + // 用于前端展示 原始sql + private String originSqlContent; + //备注 + @SalaryTableColumn(text = "备注", width = "10%", column = "description") + @TableTitle(title = "备注",dataIndex = "description",key = "description") + private String description; + + + //是否可以编辑 + private Boolean canEdit; + + //是否可以删除 + private Boolean canDelete; + + //排序 + private Integer sortedIndex; + + // 默认值 + private String defaultValue; + + + @SalaryTableColumn(text = "操作", width = "20%", column = "operate") + private String operate; + +} diff --git a/src/com/engine/salary/entity/salaryitem/dto/SysSalaryItemListDTO.java b/src/com/engine/salary/entity/salaryitem/dto/SysSalaryItemListDTO.java new file mode 100644 index 000000000..1c892bd08 --- /dev/null +++ b/src/com/engine/salary/entity/salaryitem/dto/SysSalaryItemListDTO.java @@ -0,0 +1,62 @@ +package com.engine.salary.entity.salaryitem.dto; + +import com.cloudstore.eccom.pc.table.WeaTableType; +import com.engine.salary.annotation.SalaryTable; +import com.engine.salary.annotation.SalaryTableColumn; +import com.engine.salary.annotation.TableTitle; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 系统薪资项目列表 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@SalaryTable(pageId = "a4f85287-6111-7721-adn9-7d06e54y6rj9", + fields = " t.id, t.name, t.category, t.item_type as itemType, t.rounding_mode as roundingMode, t.pattern, t.value_type as valueType,t.data_type as dataType", + fromSql = " FROM hrsa_sys_salary_item t", + tableType = WeaTableType.CHECKBOX) +public class SysSalaryItemListDTO { + + //主键id") + @JsonSerialize(using = ToStringSerializer.class) + @SalaryTableColumn(column = "id", display = false) + private Long id; + + @SalaryTableColumn(text = "名称", width = "10%", column = "name") + @TableTitle(title = "名称", key = "name", dataIndex = "name") + private String name; + + @SalaryTableColumn(text = "进位规则", width = "10%", column = "roundingMode",transmethod = "com.engine.salary.transmethod.TransMethod.roundingMode") + @TableTitle(title = "进位规则", key = "roundingMode", dataIndex = "roundingMode") + private String roundingMode; + + @SalaryTableColumn(text = "保留小数位", width = "10%", column = "pattern") + @TableTitle(title = "保留小数位", key = "pattern", dataIndex = "pattern") + private Integer pattern; + + @SalaryTableColumn(text = "取值方式", width = "10%", column = "valueType",transmethod = "com.engine.salary.transmethod.TransMethod.datasource") + @TableTitle(title = "取值方式", key = "valueType", dataIndex = "valueType") + private String valueType; + + @SalaryTableColumn(text = "字段类型", width = "10%", column = "dataType",transmethod = "com.engine.salary.transmethod.TransMethod.dataType") + @TableTitle(title = "字段类型", key = "dataType", dataIndex = "dataType") + private String dataType; + +// @SalaryTableColumn(text = "个税申报表对应字段", width = "10%", column = "taxDeclarationColumn") + private String taxDeclarationColumn; + +// @SalaryTableColumn(text = "操作", width = "20%", column = "operate") +// private String operate; +} diff --git a/src/com/engine/salary/entity/salaryitem/dto/SysSalaryItemSearchConditionDTO.java b/src/com/engine/salary/entity/salaryitem/dto/SysSalaryItemSearchConditionDTO.java new file mode 100644 index 000000000..c86a3973f --- /dev/null +++ b/src/com/engine/salary/entity/salaryitem/dto/SysSalaryItemSearchConditionDTO.java @@ -0,0 +1,65 @@ +//package com.engine.salary.entity.salaryitem.dto; +// +//import com.weaver.common.component.search.item.WeaSearchConditionItemType; +//import com.weaver.hrm.salary.annotation.SalarySearchCondition; +//import com.weaver.hrm.salary.annotation.SalarySearchConditionItem; +//import com.weaver.hrm.salary.enums.SalaryItemCategoryEnum; +//import com.weaver.hrm.salary.enums.SalaryItemTypeEnum; +//import io.swagger.annotations.ApiModel; +//import io.swagger.annotations.ApiModelProperty; +//import lombok.AllArgsConstructor; +//import lombok.Builder; +//import lombok.Data; +//import lombok.NoArgsConstructor; +// +//import java.util.Collection; +// +///** +// * @description: 高级搜索(系统薪资项目) +// * @author: xiajun +// * @modified By: xiajun +// * @date: Created in 11/2/21 1:27 PM +// * @version:v1.0 +// */ +//@Data +//@Builder +//@NoArgsConstructor +//@AllArgsConstructor +////系统薪资项目高级搜索") +//public class SysSalaryItemSearchConditionDTO { +// +// @SalarySearchCondition( +// label = "薪资项目", +// labelId = 84960, +// needQuickSearch = true, +// quickSearchKey = "name", +// items = { +// @SalarySearchConditionItem(itemType = WeaSearchConditionItemType.INPUT, name = "name"), +// } +// ) +// //薪资项目名称") +// private String name; +// +// @SalarySearchCondition( +// label = "属性", +// labelId = 84757, +// items = { +// @SalarySearchConditionItem(itemType = WeaSearchConditionItemType.SELECT, name = "category", optionsEnum = SalaryItemCategoryEnum.class), +// } +// ) +// //属性") +// private SalaryItemCategoryEnum category; +// +// @SalarySearchCondition( +// label = "类型", +// labelId = 84758, +// items = { +// @SalarySearchConditionItem(itemType = WeaSearchConditionItemType.SELECT, name = "itemType", optionsEnum = SalaryItemTypeEnum.class), +// } +// ) +// //类型") +// private SalaryItemTypeEnum itemType; +// +// //需要排除的系统薪资项目") +// private Collection excludeIds; +//} diff --git a/src/com/engine/salary/entity/salaryitem/param/SalaryItemDownloadTemplateParam.java b/src/com/engine/salary/entity/salaryitem/param/SalaryItemDownloadTemplateParam.java new file mode 100644 index 000000000..36edcd24b --- /dev/null +++ b/src/com/engine/salary/entity/salaryitem/param/SalaryItemDownloadTemplateParam.java @@ -0,0 +1,24 @@ +package com.engine.salary.entity.salaryitem.param; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 薪资项目查询参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalaryItemDownloadTemplateParam { + + //下载模板是否带数据 + private boolean hasData; +} diff --git a/src/com/engine/salary/entity/salaryitem/param/SalaryItemExportParam.java b/src/com/engine/salary/entity/salaryitem/param/SalaryItemExportParam.java new file mode 100644 index 000000000..455472227 --- /dev/null +++ b/src/com/engine/salary/entity/salaryitem/param/SalaryItemExportParam.java @@ -0,0 +1,27 @@ +package com.engine.salary.entity.salaryitem.param; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * 导出参数 + *

Copyright: Copyright (c) 2024

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalaryItemExportParam { + + private List ids; + + +} diff --git a/src/com/engine/salary/entity/salaryitem/param/SalaryItemImportParam.java b/src/com/engine/salary/entity/salaryitem/param/SalaryItemImportParam.java new file mode 100644 index 000000000..15e2476af --- /dev/null +++ b/src/com/engine/salary/entity/salaryitem/param/SalaryItemImportParam.java @@ -0,0 +1,26 @@ +package com.engine.salary.entity.salaryitem.param; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 导入参数 + *

Copyright: Copyright (c) 2024

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalaryItemImportParam { + + /** + * 上传文件id + */ + String imageId; +} diff --git a/src/com/engine/salary/entity/salaryitem/param/SalaryItemSaveParam.java b/src/com/engine/salary/entity/salaryitem/param/SalaryItemSaveParam.java new file mode 100644 index 000000000..c7bfbd4bf --- /dev/null +++ b/src/com/engine/salary/entity/salaryitem/param/SalaryItemSaveParam.java @@ -0,0 +1,115 @@ +package com.engine.salary.entity.salaryitem.param; + +import com.engine.salary.enums.SalaryRoundingModeEnum; +import com.engine.salary.enums.SalarySystemTypeEnum; +import com.engine.salary.enums.SalaryValueTypeEnum; +import com.engine.salary.enums.salaryitem.SalaryDataTypeEnum; +import com.engine.salary.util.valid.DataCheck; +import com.engine.salary.util.valid.RuntimeTypeEnum; +import com.engine.salary.util.valid.ValidTypeEnum; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalaryItemSaveParam { + + //主键id + @JsonSerialize(using = ToStringSerializer.class) + @DataCheck(require = true, runtime = {RuntimeTypeEnum.UPDATE}, message = "id不允许为空") + private Long id; + + //名称 + @DataCheck(require = true, max = 40, message = "名称不允许为空,名称不能超过40个字符") + private String name; + + /** + * 是否是系统内置的薪资项目 + * + * @see SalarySystemTypeEnum + */ + private Integer systemType; + + //默认使用 + private Integer useDefault; + + //薪资档案引用 + private Integer useInEmployeeSalary; + + //核算时默认隐藏 + @DataCheck(require = true, message = "核算时隐藏不允许为空") + private Integer hideDefault; + + + /** + * 舍入规则 + * + * @see SalaryRoundingModeEnum + */ + @DataCheck(require = true, message = "舍入规则不允许为空") + private Integer roundingMode; + + //保留小数位 + @DataCheck(require = true, type = ValidTypeEnum.NUMBER, max = 10, message = "小数位最多为10") + private Integer pattern; + + /** + * 取值方式 + * + * @see SalaryValueTypeEnum + */ + @DataCheck(require = true, message = "取值方式不允许为空") + private Integer valueType; + + /** + * 字段类型 + * @see SalaryDataTypeEnum + */ + @DataCheck(require = true, message = "字段类型不允许为空") + private String dataType; + + + //公式 + private Long formulaId; + + //备注 + private String description; + + /** + * 可见范围:0公共|1私有 + */ + private Integer sharedType; + + /** + * 绑定人员范围,','分隔 + */ + private String taxAgentIds; + + /** + * 排序 + */ + private Integer sortedIndex; + + /** + * 宽度 + */ + private Integer width; + + /** + * 默认值 + */ + private String defaultValue; +} diff --git a/src/com/engine/salary/entity/salaryitem/param/SalaryItemSearchParam.java b/src/com/engine/salary/entity/salaryitem/param/SalaryItemSearchParam.java new file mode 100644 index 000000000..e0c63f108 --- /dev/null +++ b/src/com/engine/salary/entity/salaryitem/param/SalaryItemSearchParam.java @@ -0,0 +1,104 @@ +package com.engine.salary.entity.salaryitem.param; + +import com.engine.salary.common.BaseQueryParam; +import com.engine.salary.enums.SalaryOnOffEnum; +import com.engine.salary.enums.SalaryValueTypeEnum; +import com.engine.salary.enums.salaryitem.SalaryDataTypeEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; + +/** + * 薪资项目查询参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalaryItemSearchParam extends BaseQueryParam { + + // 账套id + private Long salarySobId; + + //名称 + private String name; + + //备注 + private String description; + + + /** + * 是否薪资档案引用 + * + * @see SalaryOnOffEnum + */ + private Integer useInEmployeeSalary; + + /** + * 是否默认使用 + * + * @see SalaryOnOffEnum + */ + private Integer useDefault; + + /** + * 取值方式 + * + * @see SalaryValueTypeEnum + */ + private Integer valueType; + + /** + * 字段类型 + * + * @see SalaryDataTypeEnum + */ + private Integer dataType; + + //需要排除的系统薪资项目@see + private Collection excludeIds; + + +// public static String makeSqlWhere(SalaryItemSearchParam searchParam) { +// +// String sqlWhere = " t.delete_type = 0 "; +// +// DBType dbType = DBType.get(new RecordSet().getDBType()); +// +// String name = searchParam.getName(); +// if (StringUtils.isNotBlank(name)) { +// sqlWhere += " AND t.name " + dbType.like(name); +// } +// String description = searchParam.getDescription(); +// if (StringUtils.isNotBlank(description)) { +// sqlWhere += " AND t.description " + dbType.like(description); +// } +// Integer useInEmployeeSalary = searchParam.getUseInEmployeeSalary(); +// if (useInEmployeeSalary != null) { +// sqlWhere += " AND t.use_in_employee_salary = " + useInEmployeeSalary; +// } +// Integer useDefault = searchParam.getUseDefault(); +// if (useDefault != null) { +// sqlWhere += " AND t.use_default = " + useDefault; +// } +// Integer valueType = searchParam.getValueType(); +// if (valueType != null) { +// sqlWhere += " AND t.value_type = " + valueType; +// } +// Collection excludeIds = searchParam.getExcludeIds(); +// if (CollectionUtils.isNotEmpty(excludeIds)) { +// String idsStr = excludeIds.stream().map(String::valueOf).collect(Collectors.joining(",")); +// sqlWhere += " AND t.id NOT IN (" + idsStr + ")"; +// } +// +// return sqlWhere; +// } +} diff --git a/src/com/engine/salary/entity/salaryitem/param/SyncSalaryItemParam.java b/src/com/engine/salary/entity/salaryitem/param/SyncSalaryItemParam.java new file mode 100644 index 000000000..aadc5f5aa --- /dev/null +++ b/src/com/engine/salary/entity/salaryitem/param/SyncSalaryItemParam.java @@ -0,0 +1,30 @@ +package com.engine.salary.entity.salaryitem.param; + +import com.engine.salary.util.valid.DataCheck; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * @author Harryxzy + * @ClassName SyncSalaryItemParam + * @date 2023/08/30 17:51 + * @description 同步薪资项目到账套中参数 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SyncSalaryItemParam { + + // 薪资项目id + @DataCheck(require = true, message = "薪资项目id不能为空") + private Long salaryItemId; + + // 薪资账套id + @DataCheck(require = true, message = "薪资账套不能为空") + private List salarySobIds; +} diff --git a/src/com/engine/salary/entity/salaryitem/param/SysSalaryItemSearchParam.java b/src/com/engine/salary/entity/salaryitem/param/SysSalaryItemSearchParam.java new file mode 100644 index 000000000..d16f47e96 --- /dev/null +++ b/src/com/engine/salary/entity/salaryitem/param/SysSalaryItemSearchParam.java @@ -0,0 +1,46 @@ +package com.engine.salary.entity.salaryitem.param; + +import com.engine.salary.common.BaseQueryParam; +import com.engine.salary.enums.SalaryItemCategoryEnum; +import com.engine.salary.enums.SalaryItemTypeEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; + +/** + * 系统薪资项目查询参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SysSalaryItemSearchParam extends BaseQueryParam { + + //名称 + private String name; + + /** + * 属性 + * + * @see SalaryItemCategoryEnum + */ + private String category; + + /** + * 分类 + * + * @see SalaryItemTypeEnum + */ + private String itemType; + + //需要排除的系统薪资项目 + private Collection excludeIds; +} diff --git a/src/com/engine/salary/entity/salaryitem/po/SalaryItemPO.java b/src/com/engine/salary/entity/salaryitem/po/SalaryItemPO.java new file mode 100644 index 000000000..e39198b51 --- /dev/null +++ b/src/com/engine/salary/entity/salaryitem/po/SalaryItemPO.java @@ -0,0 +1,259 @@ +package com.engine.salary.entity.salaryitem.po; + +import com.engine.hrmelog.annotation.ElogTransform; +import com.engine.salary.entity.salaryformula.po.FormulaPO; +import com.engine.salary.enums.SalaryRoundingModeEnum; +import com.engine.salary.enums.SalarySystemTypeEnum; +import com.engine.salary.enums.SalaryValueTypeEnum; +import com.engine.salary.enums.salaryitem.SalaryDataTypeEnum; +import com.thoughtworks.xstream.annotations.XStreamAlias; +import com.thoughtworks.xstream.annotations.XStreamAsAttribute; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.Date; + +/** + * 薪资项目 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//hrsa_salary_item +@ElogTransform(name = "薪资项目") +@XStreamAlias("SalaryItem") +public class SalaryItemPO { + + /** + * 主键id + */ + @ElogTransform(name = "主键id") + @XStreamAlias("id") + @XStreamAsAttribute + private Long id; + + /** + * 名称 + */ + @ElogTransform(name = "名称") + @XStreamAlias("name") + @XStreamAsAttribute + private String name; + + /** + * 编号 + */ + @ElogTransform(name = "编号") + @XStreamAlias("code") + @XStreamAsAttribute + private String code; + + /** + * 是否是系统项目 + * + * @see SalarySystemTypeEnum + */ + @ElogTransform(name = "是否是系统项目") + @XStreamAlias("systemType") + @XStreamAsAttribute + private Integer systemType; + + /** + * 系统薪资项目的id(是从哪个系统薪资项目复制过来的) + */ + @ElogTransform(name = "系统薪资项目的id") + @XStreamAlias("sysSalaryItemId") + @XStreamAsAttribute + private Long sysSalaryItemId; + + /** + * 默认使用。0:默认不适用、1:默认使用 + */ + @ElogTransform(name = "默认使用") + @XStreamAlias("useDefault") + @XStreamAsAttribute + private Integer useDefault; + + /** + * 薪资档案引用。0:薪资档案未引用、1:薪资档案引用 + */ + @ElogTransform(name = "薪资档案引用") + @XStreamAlias("useInEmployeeSalary") + @XStreamAsAttribute + private Integer useInEmployeeSalary; + + /** + * 核算时隐藏 + */ + @ElogTransform(name = "核算时隐藏") + @XStreamAlias("hideDefault") + @XStreamAsAttribute + private Integer hideDefault; + + /** + * 进位规则 + * + * @see SalaryRoundingModeEnum + */ + @ElogTransform(name = "进位规则") + @XStreamAlias("roundingMode") + @XStreamAsAttribute + private Integer roundingMode; + + /** + * 保留的小数位数 + */ + @ElogTransform(name = "保留的小数位数") + @XStreamAlias("pattern") + @XStreamAsAttribute + private Integer pattern; + + /** + * 取值方式 + * + * @see SalaryValueTypeEnum + */ + @ElogTransform(name = "取值方式") + @XStreamAlias("valueType") + @XStreamAsAttribute + private Integer valueType; + + /** + * 字段类型 + * + * @see SalaryDataTypeEnum + */ + @ElogTransform(name = "字段类型") + @XStreamAlias("dataType") + @XStreamAsAttribute + private String dataType; + + /** + * 公式 + */ + @ElogTransform(name = "公式") + @XStreamAlias("formulaId") + @XStreamAsAttribute + private Long formulaId; + + /** + * 备注 + */ + @ElogTransform(name = "备注") + @XStreamAlias("description") + @XStreamAsAttribute + private String description; + + /** + * 是否可以编辑。0:不可编辑、1:可编辑 + */ + @ElogTransform(name = "是否可以编辑") + @XStreamAlias("canEdit") + @XStreamAsAttribute + private Integer canEdit; + + /** + * 租户key + */ + @ElogTransform(name = "租户key") + @XStreamAlias("tenantKey") + @XStreamAsAttribute + private String tenantKey; + + /** + * 创建人id + */ + @ElogTransform(name = "创建人id") + @XStreamAlias("creator") + @XStreamAsAttribute + private Long creator; + + /** + * 是否删除 + */ + @ElogTransform(name = "是否删除") + @XStreamAlias("deleteType") + @XStreamAsAttribute + private Integer deleteType; + + /** + * 创建时间 + */ + @ElogTransform(name = "创建时间") + @XStreamAlias("createTime") + @XStreamAsAttribute + private Date createTime; + + /** + * 更新时间 + */ + @ElogTransform(name = "更新时间") + @XStreamAlias("updateTime") + @XStreamAsAttribute + private Date updateTime; + + //查询条件 + Collection ids; + + Collection sysSalaryItemIds; + + /** + * 可见性 + */ + @ElogTransform(name = "可见性") + @XStreamAlias("sharedType") + @XStreamAsAttribute + private Integer sharedType; + + /** + * 可见范围 + */ + @ElogTransform(name = "可见范围") + @XStreamAlias("taxAgentIds") + @XStreamAsAttribute + private String taxAgentIds; + + /** + * 0不可删除,1可删除 + */ + @ElogTransform(name = "是否已经删除") + @XStreamAlias("canDelete") + @XStreamAsAttribute + private Integer canDelete; + + /** + * 排序 + */ + @ElogTransform(name = "排序") + @XStreamAlias("sortedIndex") + @XStreamAsAttribute + private Integer sortedIndex; + + /** + * 宽度 + */ + @ElogTransform(name = "宽度") + @XStreamAlias("width") + @XStreamAsAttribute + private Integer width; + + /** + * 默认值 + */ + @ElogTransform(name = "默认值") + @XStreamAlias("defaultValue") + @XStreamAsAttribute + private String defaultValue; + + @XStreamAlias("Formula") + FormulaPO formula; +} diff --git a/src/com/engine/salary/entity/salaryitem/po/SysSalaryItemPO.java b/src/com/engine/salary/entity/salaryitem/po/SysSalaryItemPO.java new file mode 100644 index 000000000..b3af8dddb --- /dev/null +++ b/src/com/engine/salary/entity/salaryitem/po/SysSalaryItemPO.java @@ -0,0 +1,135 @@ +package com.engine.salary.entity.salaryitem.po; + +import com.engine.salary.enums.SalaryRoundingModeEnum; +import com.engine.salary.enums.SalarySystemTypeEnum; +import com.engine.salary.enums.SalaryValueTypeEnum; +import com.engine.salary.enums.salaryitem.SalaryDataTypeEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.Date; + +/** + * 系统内置的薪资项目 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//value = "hrsa_sys_salary_item", autoResultMap = true) +public class SysSalaryItemPO { + + /** + * 主键id + */ + private Long id; + + /** + * 名称 + */ + private String name; + + /** + * 编号 + */ + private String code; + + /** + * 是否是系统项目 + * + * @see SalarySystemTypeEnum + */ + private Integer systemType; + + /** + * 默认使用。0:默认不适用、1:默认使用 + */ + private Integer useDefault; + + /** + * 薪资档案引用。0:薪资档案未引用、1:薪资档案引用 + */ + private Integer useInEmployeeSalary; + + /** + * 进位规则 + * + * @see SalaryRoundingModeEnum + */ + private Integer roundingMode; + + /** + * 保留的小数位数 + */ + private Integer pattern; + + /** + * 取值方式 + * + * @see SalaryValueTypeEnum + */ + private Integer valueType; + + /** + * 字段类型 + * + * @see SalaryDataTypeEnum + */ + private String dataType; + + /** + * 公式 + */ + private Long formulaId; + + /** + * 备注 + */ + private String description; + + /** + * 是否可以编辑。0:不可编辑、1:可以编辑 + */ + private Integer canEdit; + + /** + * 租户key + */ + private String tenantKey; + + /** + * 创建人id + */ + private Long creator; + + /** + * 是否删除 + */ + private Integer deleteType; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 更新时间 + */ + private Date updateTime; + + //查询条件 + private Collection ids; + + + private Integer sharedType; + + private String taxAgentIds; +} diff --git a/src/com/engine/salary/entity/salarysob/bo/SalaryApprovalBO.java b/src/com/engine/salary/entity/salarysob/bo/SalaryApprovalBO.java new file mode 100644 index 000000000..f8657019c --- /dev/null +++ b/src/com/engine/salary/entity/salarysob/bo/SalaryApprovalBO.java @@ -0,0 +1,91 @@ +package com.engine.salary.entity.salarysob.bo; + +import com.engine.salary.entity.salaryitem.po.SalaryItemPO; +import com.engine.salary.entity.salarysob.dto.SalaryApprovalDTO; +import com.engine.salary.entity.salarysob.dto.SalarySobItemAggregateDTO; +import com.engine.salary.entity.salarysob.dto.SalarySobItemDTO; +import com.engine.salary.entity.salarysob.dto.SalarySobItemGroupDTO; +import com.engine.salary.entity.salarysob.po.SalaryApprovalRulePO; +import com.engine.salary.util.JsonUtil; +import com.engine.salary.util.SalaryEntityUtil; +import org.apache.commons.lang.StringUtils; +import weaver.hrm.User; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Map; + +/** + * @author Harryxzy + * @ClassName SalaryApprovalBO + * @date 2024/04/23 17:47 + * @description 薪资账套的薪资审批 + */ +public class SalaryApprovalBO { + + public static SalaryApprovalDTO convert2DTO(SalaryApprovalRulePO salaryApprovalRulePO, List salaryItemList) { + if (salaryApprovalRulePO == null) { + return new SalaryApprovalDTO(); + } + Map salaryItemNameMap = SalaryEntityUtil.convert2Map(salaryItemList, SalaryItemPO::getId, SalaryItemPO::getName); + List approvalItemGroups = JsonUtil.parseList(salaryApprovalRulePO.getApprovalGroupSetting(), SalaryApprovalDTO.approvalItemGroup.class); + for (SalaryApprovalDTO.approvalItemGroup group : approvalItemGroups) { + for(SalaryApprovalDTO.approvalItem item : group.getApprovalItems()) { + item.setSalaryItemName(salaryItemNameMap.getOrDefault(item.getSalaryItemId(), "")); + } + } + + return SalaryApprovalDTO.builder() + .id(salaryApprovalRulePO.getId()) + .salarySobId(salaryApprovalRulePO.getSalarySobId()) + .isOpenApproval(salaryApprovalRulePO.getOpenApproval().equals(1)) + .approvalWorkflowUrl(StringUtils.isBlank(salaryApprovalRulePO.getWorkflowUrl()) ? "" : salaryApprovalRulePO.getWorkflowUrl()) + .approvalItemGroup(approvalItemGroups) + .build(); + + } + + /** + * 将账套薪资项目设置转换成审批中的项目设置信息 + * @param aggregateBySalarySobId + */ + public static String sobItemAggregate2approvalGroupSetting(SalarySobItemAggregateDTO aggregateBySalarySobId) { + List groupList = new ArrayList<>(); + // 薪资项目分组 + List itemGroups = aggregateBySalarySobId.getItemGroups(); + for (SalarySobItemGroupDTO sobItemGroupDTO: itemGroups) { + SalaryApprovalDTO.approvalItemGroup approvalGroup = new SalaryApprovalDTO.approvalItemGroup(); + approvalGroup.setGroupName(sobItemGroupDTO.getName()); + approvalGroup.setSorted(sobItemGroupDTO.getSortedIndex()); + List approvalItemList = new ArrayList<>(); + for (SalarySobItemDTO groupItem : sobItemGroupDTO.getItems()) { + SalaryApprovalDTO.approvalItem approvalItem = new SalaryApprovalDTO.approvalItem(); + approvalItem.setSalaryItemId(groupItem.getSalaryItemId()); + approvalItem.setSalaryItemName(groupItem.getName()); + approvalItem.setSorted(groupItem.getSortedIndex()); + approvalItemList.add(approvalItem); + } + approvalGroup.setApprovalItems(approvalItemList); + groupList.add(approvalGroup); + } + // 未分类 + List items = aggregateBySalarySobId.getItems(); + List approvalItemList2 = new ArrayList<>(); + for (SalarySobItemDTO groupItem : items) { + SalaryApprovalDTO.approvalItem approvalItem = new SalaryApprovalDTO.approvalItem(); + approvalItem.setSalaryItemId(groupItem.getSalaryItemId()); + approvalItem.setSalaryItemName(groupItem.getName()); + approvalItem.setSorted(groupItem.getSortedIndex()); + approvalItemList2.add(approvalItem); + } + SalaryApprovalDTO.approvalItemGroup approvalGroup = new SalaryApprovalDTO.approvalItemGroup(); + approvalGroup.setGroupName("未分类"); + approvalGroup.setSorted(groupList.size()); + approvalGroup.setApprovalItems(approvalItemList2); + groupList.add(approvalGroup); + return JsonUtil.toJsonString(groupList); + } + + +} diff --git a/src/com/engine/salary/entity/salarysob/bo/SalarySobAdjustRuleBO.java b/src/com/engine/salary/entity/salarysob/bo/SalarySobAdjustRuleBO.java new file mode 100644 index 000000000..eadebc8d5 --- /dev/null +++ b/src/com/engine/salary/entity/salarysob/bo/SalarySobAdjustRuleBO.java @@ -0,0 +1,98 @@ +package com.engine.salary.entity.salarysob.bo; + +import com.engine.salary.constant.SalaryDefaultTenantConstant; +import com.engine.salary.entity.salaryitem.po.SalaryItemPO; +import com.engine.salary.entity.salarysob.dto.SalaryItemBaseDTO; +import com.engine.salary.entity.salarysob.dto.SalarySobAdjustRuleListDTO; +import com.engine.salary.entity.salarysob.param.SalarySobAdjustRuleSaveParam; +import com.engine.salary.entity.salarysob.po.SalarySobAdjustRulePO; +import com.engine.salary.util.SalaryEntityUtil; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.math.NumberUtils; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * 调薪规则 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SalarySobAdjustRuleBO { + + /** + * 调薪计薪规则po转换成调薪计薪规则列表dto + * + * @param salarySobAdjustRules 调薪计薪规则po + * @param salaryItems 薪资项目po + * @return + */ + public static List convert2ListDTO(List salarySobAdjustRules, List salaryItems) { + if (CollectionUtils.isEmpty(salarySobAdjustRules)) { + return Collections.emptyList(); + } + // key:薪资项目id、value:薪资项目的名称 + Map salaryItemNameMap = SalaryEntityUtil.convert2Map(salaryItems, SalaryItemPO::getId, SalaryItemPO::getName); + return salarySobAdjustRules.stream() + .map(e -> SalarySobAdjustRuleListDTO.builder() + .id(e.getId()) + .salaryItemId(e.getSalaryItemId()) + .salaryItemName(salaryItemNameMap.getOrDefault(e.getSalaryItemId(), "")) + .dayOfMonth(e.getDayOfMonth()) + .beforeAdjustmentType(e.getBeforeAdjustmentType()) + .afterAdjustmentType(e.getAfterAdjustmentType()) + .build()) + .collect(Collectors.toList()); + } + + /** + * 转换成调薪计薪规则可选的薪资项目dto + * 只有开启了"薪资档案引用"的薪资项目才可选 + * + * @param salaryItems 薪资项目po + * @return + */ + public static List convertItemBaseDTO(List salaryItems) { + if (CollectionUtils.isEmpty(salaryItems)) { + return Collections.emptyList(); + } + // 过滤开启了"薪资档案引用"的薪资项目 + return salaryItems.stream() + .filter(salaryItemPO -> Objects.equals(salaryItemPO.getUseInEmployeeSalary(), NumberUtils.INTEGER_ONE)) + .map(salaryItemPO -> new SalaryItemBaseDTO() + .setSalaryItemId(salaryItemPO.getId()) + .setSalaryItemName(salaryItemPO.getName())) + .collect(Collectors.toList()); + + } + + /** + * 保存参数转换成薪资账套的调薪计薪规则po + * + * @param saveParam 保存参数 + * @param employeeId 人员id + * @return + */ + public static List convert2PO(SalarySobAdjustRuleSaveParam saveParam, Long employeeId) { + if (CollectionUtils.isEmpty(saveParam.getRuleParams())) { + return Collections.emptyList(); + } + Date now = new Date(); + return saveParam.getRuleParams().stream() + .map(ruleParam -> new SalarySobAdjustRulePO() + .setSalarySobId(saveParam.getSalarySobId()) + .setSalaryItemId(ruleParam.getSalaryItemId()) + .setDayOfMonth(ruleParam.getDayOfMonth()) + .setBeforeAdjustmentType(ruleParam.getBeforeAdjustmentType()) + .setAfterAdjustmentType(ruleParam.getAfterAdjustmentType()) + .setCreator(employeeId) + .setCreateTime(now) + .setUpdateTime(now) + .setDeleteType(NumberUtils.INTEGER_ZERO) + .setTenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + ).collect(Collectors.toList()); + } +} diff --git a/src/com/engine/salary/entity/salarysob/bo/SalarySobBO.java b/src/com/engine/salary/entity/salarysob/bo/SalarySobBO.java new file mode 100644 index 000000000..cf06eec07 --- /dev/null +++ b/src/com/engine/salary/entity/salarysob/bo/SalarySobBO.java @@ -0,0 +1,124 @@ +package com.engine.salary.entity.salarysob.bo; + +import com.engine.salary.constant.SalaryDefaultTenantConstant; +import com.engine.salary.entity.salarysob.dto.SalarySobBasicFormDTO; +import com.engine.salary.entity.salarysob.param.SalarySobBasicSaveParam; +import com.engine.salary.entity.salarysob.po.SalarySobPO; +import com.engine.salary.enums.SalaryCycleTypeEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.util.SalaryI18nUtil; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.math.NumberUtils; + +import java.util.Date; +import java.util.Objects; + +/** + * 薪资账套 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ + +public class SalarySobBO { + + /** + * 薪资账套基础设置保存参数转换成薪资账套基础设置po + * + * @param saveParam 薪资账套基础设置保存参数 + * @param employeeId 人员id + * @return + */ + public static SalarySobPO convert2PO(SalarySobBasicSaveParam saveParam, Long employeeId) { + Date now = new Date(); + if (saveParam == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(84026, "参数错误")); + } + return SalarySobPO.builder() + .name(saveParam.getName()) + .incomeCategory(saveParam.getTaxableItems()) + .salaryCycleType(saveParam.getSalaryCycleType()) + .salaryCycleFromDay(saveParam.getSalaryCycleFromDay()) + .taxCycleType(saveParam.getTaxCycleType()) + .attendCycleType(saveParam.getAttendCycleType()) + .attendCycleFromDay(saveParam.getAttendCycleFromDay()) + .socialSecurityCycleType(saveParam.getSocialSecurityCycleType()) + .disable(NumberUtils.INTEGER_ZERO) + .creator(employeeId) + .createTime(now) + .updateTime(now) + .deleteType(NumberUtils.INTEGER_ZERO) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .taxAgentId(saveParam.getTaxAgentIds().get(0)) + .build(); + } + + /** + * 解析薪资账套列表的薪资周期 + * + * @param salarySobPO + * @return + */ + public static String buildSalaryCycle(SalarySobPO salarySobPO) { + String salaryCycleStr; + SalaryCycleTypeEnum salaryCycleTypeEnum = SalaryCycleTypeEnum.parseByValue(salarySobPO.getSalaryCycleType()); + if (salaryCycleTypeEnum == null) { + return StringUtils.EMPTY; + } + Integer salaryCycleFromDay = salarySobPO.getSalaryCycleFromDay(); + switch (salaryCycleTypeEnum) { + case BEFORE_LAST_MONTH: + salaryCycleStr = Objects.equals(salaryCycleFromDay, 1) ? SalaryI18nUtil.getI18nLabel(98395, "上上月1号——上上月最后一天") + : SalaryI18nUtil.getI18nLabel(98399, "上上月{0}号——上月{1}号") + .replace("{0}", "" + salaryCycleFromDay) + .replace("{1}", "" + (salaryCycleFromDay - 1)); + break; + case LAST_MONTH: + salaryCycleStr = Objects.equals(salaryCycleFromDay, 1) ? SalaryI18nUtil.getI18nLabel(98396, "上月1号——上月最后一天") + : SalaryI18nUtil.getI18nLabel(98400, "上月{0}号——本月{1}号") + .replace("{0}", "" + salaryCycleFromDay) + .replace("{1}", "" + (salaryCycleFromDay - 1)); + break; + case THIS_MONTH: + salaryCycleStr = Objects.equals(salaryCycleFromDay, 1) ? SalaryI18nUtil.getI18nLabel(98397, "本月1号——本月最后一天") + : SalaryI18nUtil.getI18nLabel(98401, "本月{0}号——下月{1}号") + .replace("{0}", "" + salaryCycleFromDay) + .replace("{1}", "" + (salaryCycleFromDay - 1)); + break; + case NEXT_MONTH: + salaryCycleStr = Objects.equals(salaryCycleFromDay, 1) ? SalaryI18nUtil.getI18nLabel(98398, "下月1号——下月最后一天") + : SalaryI18nUtil.getI18nLabel(98402, "下月{0}号——下下月{1}号") + .replace("{0}", "" + salaryCycleFromDay) + .replace("{1}", "" + (salaryCycleFromDay - 1)); + break; + default: + salaryCycleStr = ""; + } + return salaryCycleStr; + } + + /** + * 薪资账套po转换成薪资账套详情dto + * + * @param salarySobPO 薪资账套po + * @return + */ + public static SalarySobBasicFormDTO convert2FormDTO(SalarySobBasicFormDTO basicForm, SalarySobPO salarySobPO) { + return basicForm + .setId(salarySobPO.getId()) + .setName(salarySobPO.getName()) + .setName(salarySobPO.getName()) + .setTaxableItems(salarySobPO.getIncomeCategory()) + .setSalaryCycleType(salarySobPO.getSalaryCycleType()) + .setSalaryCycleFromDay(salarySobPO.getSalaryCycleFromDay()) + .setTaxCycleType(salarySobPO.getTaxCycleType()) + .setAttendCycleType(salarySobPO.getAttendCycleType()) + .setAttendCycleFromDay(salarySobPO.getAttendCycleFromDay()) + .setSocialSecurityCycleType(salarySobPO.getSocialSecurityCycleType()) + .setTaxAgentIds(salarySobPO.getTaxAgentIds()) + .setDescription(salarySobPO.getDescription()); + + } +} diff --git a/src/com/engine/salary/entity/salarysob/bo/SalarySobBackItemBO.java b/src/com/engine/salary/entity/salarysob/bo/SalarySobBackItemBO.java new file mode 100644 index 000000000..93447575c --- /dev/null +++ b/src/com/engine/salary/entity/salarysob/bo/SalarySobBackItemBO.java @@ -0,0 +1,70 @@ +package com.engine.salary.entity.salarysob.bo; + +import com.engine.salary.entity.salaryformula.ExpressFormula; +import com.engine.salary.entity.salaryitem.bo.SalaryItemBO; +import com.engine.salary.entity.salaryitem.po.SalaryItemPO; +import com.engine.salary.entity.salarysob.dto.SalarySobBackItemDTO; +import com.engine.salary.entity.salarysob.po.SalarySobBackItemPO; +import com.engine.salary.entity.salarysob.po.SalarySobDefaultBackItemPO; +import com.engine.salary.util.SalaryEntityUtil; +import com.google.common.collect.Lists; +import com.engine.salary.util.db.IdGenerator; +import org.apache.commons.collections.CollectionUtils; + +import java.util.Collections; +import java.util.List; +import java.util.Map; + +/** + * @author Harryxzy + * @date 2022/11/15 17:42 + * @description + */ +public class SalarySobBackItemBO { + + public static List getDefault() { + return Lists.newArrayList( + SalarySobDefaultBackItemPO.builder() + .id(IdGenerator.generate()) + .sysSalaryItemId(746777981115629575L) + .formulaId(0L) + .backCalcType(0).build(), + SalarySobDefaultBackItemPO.builder() + .id(IdGenerator.generate()) + .sysSalaryItemId(746777981115629576L) + .formulaId(0L) + .backCalcType(1).build()); + } + + + public static List convert2DTO(List salarySobBackItems, List salaryItems, List expressFormulas) { + if (CollectionUtils.isEmpty(salarySobBackItems)) { + return Collections.emptyList(); + } + List dtos = Lists.newArrayList(); + Map salaryItemMap = SalaryEntityUtil.convert2Map(salaryItems, SalaryItemPO::getId); + Map expressFormulaMap = SalaryEntityUtil.convert2Map(expressFormulas, ExpressFormula::getId, ExpressFormula::getFormula); + for (SalarySobBackItemPO salarySobBackItem : salarySobBackItems) { + SalaryItemPO salaryItem = salaryItemMap.get(salarySobBackItem.getSalaryItemId()); + SalarySobBackItemDTO dto = SalarySobBackItemDTO.builder() + .id(salarySobBackItem.getId()) + .salaryItemId(salaryItem.getId()) + .sysSalaryItemId(salaryItem.getSysSalaryItemId()) + .salarySobItemGroupId(0L) + .name(salaryItem.getName()) + .formulaId(salarySobBackItem.getFormulaId()) + .formulaContent(expressFormulaMap.getOrDefault(salarySobBackItem.getFormulaId(), "输入")) + .dataType(salaryItem.getDataType()) + .pattern(salarySobBackItem.getPattern()) + .taxDeclarationColumn(SalaryItemBO.buildTaxDeclarationColumn(salaryItem.getCode())) + .sortedIndex(0) + .canEdit(true) + .canDelete(false) + .incomeCategory("0") + .backCalcType(salarySobBackItem.getBackCalcType()).build(); + dtos.add(dto); + } + return dtos; + } + +} diff --git a/src/com/engine/salary/entity/salarysob/bo/SalarySobCheckRuleBO.java b/src/com/engine/salary/entity/salarysob/bo/SalarySobCheckRuleBO.java new file mode 100644 index 000000000..eb07d954a --- /dev/null +++ b/src/com/engine/salary/entity/salarysob/bo/SalarySobCheckRuleBO.java @@ -0,0 +1,94 @@ +package com.engine.salary.entity.salarysob.bo; + +import com.engine.salary.constant.SalaryDefaultTenantConstant; +import com.engine.salary.entity.salaryformula.ExpressFormula; +import com.engine.salary.entity.salarysob.dto.SalarySobCheckRuleFormDTO; +import com.engine.salary.entity.salarysob.dto.SalarySobCheckRuleListDTO; +import com.engine.salary.entity.salarysob.param.SalarySobCheckRuleSaveParam; +import com.engine.salary.entity.salarysob.po.SalarySobCheckRulePO; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.SalaryI18nUtil; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.math.NumberUtils; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * 薪资账套的校验规则 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SalarySobCheckRuleBO { + + /** + * 保存参数转换成薪资账套的校验规则po + * + * @param saveParam 保存参数 + * @param employeeId 人员id + * @return + */ + public static SalarySobCheckRulePO convert2PO(SalarySobCheckRuleSaveParam saveParam, Long employeeId) { + if (Objects.isNull(saveParam)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(84026, " 参数错误")); + } + Date now = new Date(); + return SalarySobCheckRulePO.builder() + .salarySobId(saveParam.getSalarySobId()) + .name(saveParam.getName()) + .formulaId(saveParam.getFormulaId()) + .description(saveParam.getDescription()) + .creator(employeeId) + .createTime(now) + .updateTime(now) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .deleteType(NumberUtils.INTEGER_ZERO) + .build(); + } + + /** + * 薪资账套的校验规则po转换成校验规则列表dto + * + * @param salarySobCheckRulePOS 薪资账套的校验规则po + * @param expressFormulas 公式详情 + * @return + */ + public static List convert2ListDTO(List salarySobCheckRulePOS, List expressFormulas) { + if (CollectionUtils.isEmpty(salarySobCheckRulePOS)) { + return Collections.emptyList(); + } + // key:公式id、value:公式详情 + Map formulaMap = SalaryEntityUtil.convert2Map(expressFormulas, ExpressFormula::getId, ExpressFormula::getFormula); + return salarySobCheckRulePOS.stream() + .map(salarySobCheckRulePO -> new SalarySobCheckRuleListDTO() + .setId(salarySobCheckRulePO.getId()) + .setName(salarySobCheckRulePO.getName()) + .setSalarySobId(salarySobCheckRulePO.getSalarySobId()) + .setFormulaId(salarySobCheckRulePO.getFormulaId()) + .setFormulaContent(formulaMap.getOrDefault(salarySobCheckRulePO.getFormulaId(), StringUtils.EMPTY)) + .setDescription(salarySobCheckRulePO.getDescription()) + ).collect(Collectors.toList()); + } + + /** + * 转换成校验规则详情dto + * + * @param salarySobCheckRulePO 校验规则po + * @param expressFormula 公式详情 + * @return + */ + public static SalarySobCheckRuleFormDTO convert2FormDTO(SalarySobCheckRulePO salarySobCheckRulePO, ExpressFormula expressFormula) { + return new SalarySobCheckRuleFormDTO() + .setId(salarySobCheckRulePO.getId()) + .setName(salarySobCheckRulePO.getName()) + .setSalarySobId(salarySobCheckRulePO.getSalarySobId()) + .setFormulaId(salarySobCheckRulePO.getFormulaId()) + .setFormulaContent(Optional.ofNullable(expressFormula).map(ExpressFormula::getFormula).orElse(StringUtils.EMPTY)) + .setDescription(salarySobCheckRulePO.getDescription()); + } +} diff --git a/src/com/engine/salary/entity/salarysob/bo/SalarySobCycleBO.java b/src/com/engine/salary/entity/salarysob/bo/SalarySobCycleBO.java new file mode 100644 index 000000000..37a505a31 --- /dev/null +++ b/src/com/engine/salary/entity/salarysob/bo/SalarySobCycleBO.java @@ -0,0 +1,109 @@ +package com.engine.salary.entity.salarysob.bo; + +import com.engine.salary.common.LocalDateRange; +import com.engine.salary.entity.salarysob.dto.SalarySobCycleDTO; +import com.engine.salary.entity.salarysob.po.SalarySobPO; +import com.engine.salary.enums.SalaryCycleTypeEnum; +import com.engine.salary.util.SalaryDateUtil; + +import java.time.*; +import java.util.Date; +import java.util.Objects; + +/** + * 薪资账套的薪资周期、税款所属期、考勤周期、福利台账月份 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SalarySobCycleBO { + + /** + * 根据薪资所属月计算出薪资账套的薪资周期、税款所属期、考勤周期、福利台账月份 + * + * @param salarySob 薪资账套 + * @param salaryMonth 薪资所属月 + * @return + */ + public static SalarySobCycleDTO buildSalarySobCycle(SalarySobPO salarySob, YearMonth salaryMonth) { + if (salarySob == null) { + return null; + } + + SalarySobCycleDTO salarySobCycleDTO = SalarySobCycleDTO.builder() + .salarySobId(salarySob.getId()) + .salaryMonth(salaryMonth) + .taxCycle(buildCycle(salaryMonth, salarySob.getTaxCycleType())) + .socialSecurityCycle(buildCycle(salaryMonth, salarySob.getSocialSecurityCycleType())) + .salaryCycle(buildCycleDateRange(salaryMonth, salarySob.getSalaryCycleType(), salarySob.getSalaryCycleFromDay())) + .attendCycle(buildCycleDateRange(salaryMonth, salarySob.getAttendCycleType(), salarySob.getAttendCycleFromDay())) + .build(); + + salarySobCycleDTO.setSalaryDate(SalaryDateUtil.toDate(salarySobCycleDTO.getSalaryMonth(), 1)); + salarySobCycleDTO.setTaxDate(SalaryDateUtil.toDate(salarySobCycleDTO.getTaxCycle(), 1)); + salarySobCycleDTO.setSocialSecurityDate(SalaryDateUtil.toDate(salarySobCycleDTO.getSocialSecurityCycle(), 1)); + LocalDateRange salaryCycle = salarySobCycleDTO.getSalaryCycle(); + salarySobCycleDTO.setSalaryCycleFromDate(salaryCycle.getFromDate()); + salarySobCycleDTO.setSalaryCycleEndDate(salaryCycle.getEndDate()); + LocalDateRange attendCycle = salarySobCycleDTO.getAttendCycle(); + salarySobCycleDTO.setAttendCycleFromDate(attendCycle.getFromDate()); + salarySobCycleDTO.setAttendCycleEndDate(attendCycle.getEndDate()); + + return salarySobCycleDTO; + } + + /** + * 根据薪资所属月、薪资账套所设置的税款所属期(或福利台账月份)计算出税款所属期、福利台账的具体月份 + * + * @param salaryMonth 薪资所属月 + * @param cycleType 薪资账套所设置的税款所属期(或福利台账月份) + * @return + */ + private static YearMonth buildCycle(YearMonth salaryMonth, Integer cycleType) { + if (Objects.equals(cycleType, SalaryCycleTypeEnum.BEFORE_LAST_MONTH.getValue())) { + return salaryMonth.plus(Period.ofMonths(-2)); + } + if (Objects.equals(cycleType, SalaryCycleTypeEnum.LAST_MONTH.getValue())) { + return salaryMonth.plus(Period.ofMonths(-1)); + } + if (Objects.equals(cycleType, SalaryCycleTypeEnum.THIS_MONTH.getValue())) { + return salaryMonth; + } + if (Objects.equals(cycleType, SalaryCycleTypeEnum.NEXT_MONTH.getValue())) { + return salaryMonth.plus(Period.ofMonths(1)); + } + return YearMonth.parse("2000-01"); + } + + /** + * 根据薪资所属月、薪资账套所设置的薪资周期(或考勤周期)、薪资周期起始日(活考勤周期起始日)计算出薪资账套的薪资周期、考勤周期的具体日期范围 + * + * @param salaryMonth 薪资所属月 + * @param cycleType 薪资账套所设置的薪资周期(或考勤周期) + * @param fromDay 薪资账套所设置的薪资周期起始日(或考勤周期起始日) + * @return + */ + private static LocalDateRange buildCycleDateRange(YearMonth salaryMonth, Integer cycleType, Integer fromDay) { + YearMonth result = buildCycle(salaryMonth, cycleType); + if (result == null) { + return null; + } + ZoneId zone = ZoneId.systemDefault(); + LocalDate fromDate = result.atEndOfMonth(); + if (fromDate.getDayOfMonth() > fromDay) { + fromDate = result.atDay(fromDay); + } + Instant fromInstant = fromDate.atStartOfDay().atZone(zone).toInstant(); + + LocalDate endDate = fromDate.plusMonths(1).plusDays(-1); + Instant endInstant = endDate.atStartOfDay().atZone(zone).toInstant(); + + + return LocalDateRange.builder() + .fromDate(Date.from(fromInstant)) + .endDate(Date.from(endInstant)) + .build(); + } +} diff --git a/src/com/engine/salary/entity/salarysob/bo/SalarySobDuplicateBO.java b/src/com/engine/salary/entity/salarysob/bo/SalarySobDuplicateBO.java new file mode 100644 index 000000000..6a64f4912 --- /dev/null +++ b/src/com/engine/salary/entity/salarysob/bo/SalarySobDuplicateBO.java @@ -0,0 +1,340 @@ +package com.engine.salary.entity.salarysob.bo; + +import com.engine.salary.constant.SalaryDefaultTenantConstant; +import com.engine.salary.entity.salarysob.po.*; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.engine.salary.util.db.IdGenerator; +import lombok.AllArgsConstructor; +import lombok.Data; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.math.NumberUtils; + +import java.util.Collections; +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * 薪资账套复制 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@AllArgsConstructor +public class SalarySobDuplicateBO { + + /** + * 薪资账套 + */ + private SalarySobPO salarySob; + + /** + * 薪资账套的员工信息字段 + */ + private List salarySobEmpFields; + + /** + * 薪资账套的薪资项目副本 + */ + private List salarySobItems; + + /** + * 薪资账套的薪资项目分类 + */ + private List salarySobItemGroups; + + /** + * 薪资账套的调薪计薪规则 + */ + private List salaryAdjustmentRules; + + /** + * 薪资账套的校验规则 + */ + private List salarySobCheckRules; + + /** + * 薪资账套的回算薪资项目 + */ + List salarySobBackItemPOS; + + /** + * 复制 + * + * @param employeeId + * @return + */ + public Result duplicate( Long employeeId) { + Result result = new Result(); + // 复制基础设置 + duplicateBase(result, salarySob, employeeId); + // 复制员工信息字段 + duplicateEmpField(result, salarySobEmpFields, employeeId); + // 复制薪资项目分类 + Map groupIdMap = duplicateSalarySobItemGroup(result, salarySobItemGroups, employeeId); + // 复制薪资项目副本 + duplicateSalarySobItem(result, salarySobItems, groupIdMap, employeeId); + // 复制调薪计薪规则 + duplicateSalaryAdjustmentRule(result, salaryAdjustmentRules, employeeId); + // 复制校验规则 + duplicateSalarySobCheckRule(result, salarySobCheckRules, employeeId); + duplicateEmpField(result, salarySobEmpFields, employeeId); + // 复制回算薪资项目 + duplicateSalarySobBackItem(result, salarySobBackItemPOS, employeeId); + return result; + } + + + /** + * 复制薪资账套的基础设置 + * + * @param salarySobPO 薪资账套po + * @param employeeId 人员id + + * @return + */ + private void duplicateBase(Result result, SalarySobPO salarySobPO, Long employeeId) { + Date now = new Date(); + result.setSalarySob(salarySobPO); + } + + /** + * 复制员工信息字段 + * + * @param result + * @param salarySobEmpFieldPOS + * @param employeeId + + */ + private void duplicateEmpField(Result result, List salarySobEmpFieldPOS, Long employeeId) { + if (CollectionUtils.isEmpty(salarySobEmpFieldPOS)) { + return; + } + Date now = new Date(); + List newSalarySobEmpFieldPOS = salarySobEmpFieldPOS.stream() + .map(salarySobEmpFieldPO -> new SalarySobEmpFieldPO() + .setSalarySobId(result.getSalarySob().getId()) + .setFieldCode(salarySobEmpFieldPO.getFieldCode()) + .setSortedIndex(salarySobEmpFieldPO.getSortedIndex()) + .setCanDelete(salarySobEmpFieldPO.getCanDelete()) + .setCreator(employeeId) + .setCreateTime(now) + .setUpdateTime(now) + .setDeleteType(NumberUtils.INTEGER_ZERO) + .setTenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + ).collect(Collectors.toList()); + result.setSalarySobEmpFields(newSalarySobEmpFieldPOS); + } + + /** + * 复制薪资项目分组 + * + * @param result 结果集 + * @param salarySobItemGroups 薪资项目分类po + * @param employeeId 人员id + 租户key + * @return + */ + private Map duplicateSalarySobItemGroup(Result result, List salarySobItemGroups, Long employeeId) { + Date now = new Date(); + if (CollectionUtils.isEmpty(salarySobItemGroups)) { + return Collections.emptyMap(); + } + Map oldIdKeyNewIdValueMap = Maps.newHashMapWithExpectedSize(salarySobItemGroups.size()); + List newSalarySobItemGroups = Lists.newArrayListWithExpectedSize(salarySobItemGroups.size()); + for (SalarySobItemGroupPO salarySobItemGroup : salarySobItemGroups) { + SalarySobItemGroupPO newSalarySobItemGroup = SalarySobItemGroupPO.builder() + .id(IdGenerator.generate()) + .name(salarySobItemGroup.getName()) + .salarySobId(result.getSalarySob().getId()) + .sortedIndex(salarySobItemGroup.getSortedIndex()) + .description(salarySobItemGroup.getDescription()) + .itemHide(salarySobItemGroup.getItemHide()) + .creator(employeeId) + .createTime(now) + .updateTime(now) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .deleteType(NumberUtils.INTEGER_ZERO) + .build(); + newSalarySobItemGroups.add(newSalarySobItemGroup); + oldIdKeyNewIdValueMap.put(salarySobItemGroup.getId(), newSalarySobItemGroup.getId()); + } + result.setSalarySobItemGroups(newSalarySobItemGroups); + return oldIdKeyNewIdValueMap; + } + + /** + * 复制薪资账套的薪资项目副本 + * + * @param salarySobItems 薪资项目副本po + * @param employeeId 人员id + 租户key + * @return + */ + private void duplicateSalarySobItem(Result result, List salarySobItems, Map groupIdMap, Long employeeId) { + Date now = new Date(); + if (CollectionUtils.isEmpty(salarySobItems)) { + return; + } + List newSalarySobItems = Lists.newArrayListWithExpectedSize(salarySobItems.size()); + for (SalarySobItemPO salarySobItem : salarySobItems) { + SalarySobItemPO newSalarySobItem = SalarySobItemPO.builder() + .salarySobId(result.getSalarySob().getId()) + .salarySobItemGroupId(groupIdMap.getOrDefault(salarySobItem.getSalarySobItemGroupId(), NumberUtils.LONG_ZERO)) + .salaryItemId(salarySobItem.getSalaryItemId()) + .formulaId(salarySobItem.getFormulaId()) + .sortedIndex(salarySobItem.getSortedIndex()) + .description(salarySobItem.getDescription()) + .canDelete(salarySobItem.getCanDelete()) + .itemHide(salarySobItem.getItemHide()) + .roundingMode(salarySobItem.getRoundingMode()) + .pattern(salarySobItem.getPattern()) + .valueType(salarySobItem.getValueType()) + .creator(employeeId) + .createTime(now) + .updateTime(now) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .deleteType(NumberUtils.INTEGER_ZERO) + .build(); + newSalarySobItems.add(newSalarySobItem); + } + result.setSalarySobItems(newSalarySobItems); + } + + /** + * 复制调薪计薪规则 + * + * @param result 结果集 + * @param salaryAdjustmentRules 调薪计薪规则po + * @param employeeId 人员id + 租户key + */ + private void duplicateSalaryAdjustmentRule(Result result, List salaryAdjustmentRules, Long employeeId) { + Date now = new Date(); + if (CollectionUtils.isEmpty(salaryAdjustmentRules)) { + return; + } + List newSalaryAdjustmentRules = Lists.newArrayListWithExpectedSize(salaryAdjustmentRules.size()); + for (SalarySobAdjustRulePO salaryAdjustmentRule : salaryAdjustmentRules) { + SalarySobAdjustRulePO newSalaryAdjustmentRule = new SalarySobAdjustRulePO() + .setSalarySobId(result.getSalarySob().getId()) + .setSalaryItemId(salaryAdjustmentRule.getSalaryItemId()) + .setDayOfMonth(salaryAdjustmentRule.getDayOfMonth()) + .setBeforeAdjustmentType(salaryAdjustmentRule.getBeforeAdjustmentType()) + .setAfterAdjustmentType(salaryAdjustmentRule.getAfterAdjustmentType()) + .setCreator(employeeId) + .setCreateTime(now) + .setUpdateTime(now) + .setTenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .setDeleteType(NumberUtils.INTEGER_ZERO); + newSalaryAdjustmentRules.add(newSalaryAdjustmentRule); + } + result.setSalaryAdjustmentRules(newSalaryAdjustmentRules); + } + + /** + * 复制校验规则 + * + * @param result 结果集 + * @param salarySobCheckRules 校验规则po + * @param employeeId 人员id + 租户key + * @return + */ + private void duplicateSalarySobCheckRule(Result result, List salarySobCheckRules, Long employeeId) { + if (CollectionUtils.isEmpty(salarySobCheckRules)) { + return; + } + Date now = new Date(); + List newSalarySobCheckRules = salarySobCheckRules.stream() + .map(e -> SalarySobCheckRulePO.builder() + .salarySobId(result.getSalarySob().getId()) + .name(e.getName()) + .formulaId(e.getFormulaId()) + .description(e.getDescription()) + .creator(employeeId) + .createTime(now) + .updateTime(now) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .deleteType(0) + .build()) + .collect(Collectors.toList()); + result.setSalarySobCheckRules(newSalarySobCheckRules); + } + + /** + * @description 复制回算薪资项目 + * @return void + * @author Harryxzy + * @date 2022/12/13 16:11 + */ + private void duplicateSalarySobBackItem(Result result, List salarySobBackItemPOS, Long employeeId) { + if (CollectionUtils.isEmpty(salarySobBackItemPOS)) { + return; + } + Date now = new Date(); + List newSalarySobBackItems = salarySobBackItemPOS.stream() + .map(e -> SalarySobBackItemPO.builder() + .id(IdGenerator.generate()) + .salarySobId(result.getSalarySob().getId()) + .salaryItemId(e.getSalaryItemId()) + .salaryItemCode(e.getSalaryItemCode()) + .dataType(e.getDataType()) + .roundingMode(e.getRoundingMode()) + .pattern(e.getPattern()) + .valueType(e.getValueType()) + .formulaId(e.getFormulaId()) + .backCalcType(e.getBackCalcType()) + .creator(employeeId) + .createTime(now) + .updateTime(now) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .deleteType(0) + .build()) + .collect(Collectors.toList()); + result.setSalarySobBackItems(newSalarySobBackItems); + } + + @Data + public static class Result { + + /** + * 薪资账套 + */ + private SalarySobPO salarySob; + + /** + * 员工信息字段 + */ + private List salarySobEmpFields; + + /** + * 薪资项目副本 + */ + private List salarySobItems; + + /** + * 薪资项目分类 + */ + private List salarySobItemGroups; + + /** + * 调薪计薪规则 + */ + private List salaryAdjustmentRules; + + /** + * 校验规则 + */ + private List salarySobCheckRules; + + /** + * 薪资回算项目 + */ + private List salarySobBackItems; + } +} diff --git a/src/com/engine/salary/entity/salarysob/bo/SalarySobItemAggregateBO.java b/src/com/engine/salary/entity/salarysob/bo/SalarySobItemAggregateBO.java new file mode 100644 index 000000000..b1a76a4a4 --- /dev/null +++ b/src/com/engine/salary/entity/salarysob/bo/SalarySobItemAggregateBO.java @@ -0,0 +1,268 @@ +package com.engine.salary.entity.salarysob.bo; + +import com.engine.salary.annotation.SalaryFormulaVar; +import com.engine.salary.entity.salaryformula.ExpressFormula; +import com.engine.salary.entity.salaryformula.dto.SalaryFormulaEmployeeDTO; +import com.engine.salary.entity.salaryitem.bo.SalaryItemBO; +import com.engine.salary.entity.salaryitem.po.SalaryItemPO; +import com.engine.salary.entity.salarysob.dto.*; +import com.engine.salary.entity.salarysob.po.*; +import com.engine.salary.enums.SalaryValueTypeEnum; +import com.engine.salary.enums.salarysob.IncomeCategoryEnum; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.SalaryI18nUtil; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import lombok.AllArgsConstructor; +import lombok.NoArgsConstructor; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.math.NumberUtils; +import weaver.general.BaseBean; + +import java.lang.reflect.Field; +import java.util.*; +import java.util.stream.Collectors; + +/** + * 将薪资账套的员工信息、薪资项目副本、薪资项目分类聚合在一起 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@AllArgsConstructor +@NoArgsConstructor +public class SalarySobItemAggregateBO { + + /** + * 薪资账套 + */ + private SalarySobPO salarySob; + + /** + * 薪资账套的员工信息 + */ + private List salarySobEmpFields; + + /** + * 薪资账套的薪资项目分类 + */ + private List salarySobItemGroups; + + /** + * 薪资账套的薪资项目副本 + */ + private List salarySobItems; + + /** + * 薪资账套的薪资项目副本所用公式详情 + */ + private List expressFormulas; + + /** + * 薪资账套的薪资项目副本所关联的薪资项目 + */ + private List salaryItems; + + /** + * 薪资回算项目 + */ + private List salarySobBackItems; + + /** + * 账套默认项目 + */ + List salarySobDefaultItemPOS; + + private final BaseBean baseBean = new BaseBean(); + + //强制开启账套的公式配置 + private final Boolean openFormulaForcedEditing = "true".equals(baseBean.getPropValue("hrmSalary", "openFormulaForcedEditing")); + + /** + * 转换成聚合dto + * + * @return + */ + public SalarySobItemAggregateDTO convert2AggregateDTO() { + List itemsWithoutGroup = Lists.newArrayList(); + // 薪资账套的薪资项目分类po转换成dto + List salarySobItemGroupDTOS = salarySobItemGroups.stream() + .map(e -> SalarySobItemGroupDTO.builder() + .id(e.getId()) + .salarySobId(e.getSalarySobId()) + .name(e.getName()) + .sortedIndex(e.getSortedIndex()) + .itemHide(e.getItemHide()) + .build()) + .collect(Collectors.toList()); + Map salarySobItemGroupDTOMap = SalaryEntityUtil.convert2Map(salarySobItemGroupDTOS, SalarySobItemGroupDTO::getId); + + salarySobDefaultItemPOS = salarySobDefaultItemPOS.stream().filter(po -> po.getSysSalaryItemId() != 0).collect(Collectors.toList()); + Map longIntegerMap = SalaryEntityUtil.convert2Map(salarySobDefaultItemPOS, SalarySobDefaultItemPO::getSysSalaryItemId, SalarySobDefaultItemPO::getCanDelete); + salaryItems.forEach(item -> { + if (item.getSystemType() == 1) { + item.setCanDelete(1); + if (item.getSysSalaryItemId() != null) { + item.setCanDelete(longIntegerMap.getOrDefault(item.getSysSalaryItemId(), 1)); + } + } + }); + + Map salaryItemMap = SalaryEntityUtil.convert2Map(salaryItems, SalaryItemPO::getId); + Map> salarySobItemMap = SalaryEntityUtil.group2Map(salarySobItems, SalarySobItemPO::getSalarySobItemGroupId); + Map formulaMap = SalaryEntityUtil.convert2Map(expressFormulas, ExpressFormula::getId, ExpressFormula::getFormula); + + + // 薪资账套的薪资项目副本po转换成dto + salarySobItemMap.forEach((k, v) -> { + List items = Lists.newArrayList(); + for (int i = 0; i < v.size(); i++) { + SalarySobItemPO salarySobItemPO = v.get(i); + SalaryItemPO salaryItemPO = salaryItemMap.get(salarySobItemPO.getSalaryItemId()); + if (salaryItemPO != null) { + Integer valueType = Optional.ofNullable(salarySobItemPO.getValueType()).orElse(salaryItemPO.getValueType()); + items.add(SalarySobItemDTO.builder() + .id(salarySobItemPO.getId()) + .salarySobId(salarySob.getId()) + .salaryItemGroupId(k) + .salaryItemId(salaryItemPO.getId()) + .dataType(salaryItemPO.getDataType()) + .valueType(valueType) + .roundingMode(Optional.ofNullable(salarySobItemPO.getRoundingMode()).orElse(salaryItemPO.getRoundingMode())) + .pattern(Optional.ofNullable(salarySobItemPO.getPattern()).orElse(salaryItemPO.getPattern())) + .name(salaryItemPO.getName()) + .itemHide(salarySobItemPO.getItemHide()) + .formulaId(salarySobItemPO.getFormulaId()) + .formulaContent(formulaMap.getOrDefault(salarySobItemPO.getFormulaId(), "")) + .originFormulaContent(valueType == SalaryValueTypeEnum.FORMULA.getValue() ? formulaMap.getOrDefault(salarySobItemPO.getFormulaId(), "") : "") + .originSqlContent(valueType == SalaryValueTypeEnum.SQL.getValue() ? formulaMap.getOrDefault(salarySobItemPO.getFormulaId(), "") : "") + .taxDeclarationColumn(SalaryItemBO.buildTaxDeclarationColumn(salaryItemPO.getCode())) + .sortedIndex(salarySobItemPO.getSortedIndex()) + .canEdit(openFormulaForcedEditing || Objects.equals(salaryItemPO.getCanEdit(), 1)) + .canDelete(openFormulaForcedEditing || salaryItemPO.getCanDelete() == null || Objects.equals(salaryItemPO.getCanDelete(), 1)) + .width(salaryItemPO.getWidth()) + .defaultValue(salaryItemPO.getDefaultValue()) + .build()); + } + } + if (!salarySobItemGroupDTOMap.containsKey(k)) { + itemsWithoutGroup.addAll(items); + } else { + SalarySobItemGroupDTO salarySobItemGroupDTO = salarySobItemGroupDTOMap.get(k); + salarySobItemGroupDTO.setItems(sortItem(items)); + } + }); + // 薪资账套的员工信息字段po转换成dto + List salarySobEmpFieldDTOS = buildEmpField(salarySobEmpFields); + + List incomeCategories = Lists.newArrayList(); +// List incomeCategoryValues = JsonUtil.parseList(salarySob.getIncomeCategory(), Integer.class); + Integer incomeCategory = salarySob.getIncomeCategory(); + List incomeCategoryValues = Lists.newArrayList(incomeCategory); + for (Integer incomeCategoryValue : incomeCategoryValues) { + IncomeCategoryEnum incomeCategoryEnum = IncomeCategoryEnum.parseByValue(incomeCategoryValue); + SalarySobItemIncomeCategoryDTO salarySobItemIncomeCategoryDTO = new SalarySobItemIncomeCategoryDTO() + .setId(incomeCategoryValue.longValue()) + .setName(Optional.ofNullable(incomeCategoryEnum) + .map(e -> SalaryI18nUtil.getI18nLabel(e.getLabelId(), e.getDefaultLabel())) + .orElse(StringUtils.EMPTY)) + .setItemGroups(sortItemGroup(salarySobItemGroupDTOS)) + .setItems(sortItem(itemsWithoutGroup)); + incomeCategories.add(salarySobItemIncomeCategoryDTO); + } + // 薪资回算项目 + List backCalcItems = salarySobBackItems.stream() + .map(salarySobBackItem -> { + SalaryItemPO salaryItem = salaryItemMap.get(salarySobBackItem.getSalaryItemId()); + return SalarySobItemDTO.builder() + .id(salarySobBackItem.getId()) + .salarySobId(salarySob.getId()) + .salaryItemId(salaryItem.getId()) + .salaryItemGroupId(0L) + .dataType(salaryItem.getDataType()) + .name(salaryItem.getName()) + .formulaId(salarySobBackItem.getFormulaId()) + .formulaContent(formulaMap.getOrDefault(salarySobBackItem.getFormulaId(), "输入")) + .taxDeclarationColumn(SalaryItemBO.buildTaxDeclarationColumn(salaryItem.getCode())) + .sortedIndex(0) + .canEdit(true) + .canDelete(false) + .build(); + }).collect(Collectors.toList()); + + + return SalarySobItemAggregateDTO.builder() + .salarySobId(salarySob.getId()) + .empFields(salarySobEmpFieldDTOS) + .items(sortItem(itemsWithoutGroup)) + .itemGroups(sortItemGroup(salarySobItemGroupDTOMap.values())) + .incomeCategories(incomeCategories) + .backCalcItems(backCalcItems) + .build(); + } + + /** + * 薪资账套的员工信息字段po转换成dto + * + * @param salarySobEmpFields 薪资账套的员工信息字段 + * @return + */ + public List buildEmpField(Collection salarySobEmpFields) { + if (CollectionUtils.isEmpty(salarySobEmpFields)) { + return Collections.emptyList(); + } + Field[] declaredFields = SalaryFormulaEmployeeDTO.class.getDeclaredFields(); + Map empFieldMap = Maps.newHashMapWithExpectedSize(declaredFields.length); + for (Field declaredField : declaredFields) { + if (!declaredField.isAnnotationPresent(SalaryFormulaVar.class)) { + continue; + } + SalaryFormulaVar annotation = declaredField.getAnnotation(SalaryFormulaVar.class); + empFieldMap.put(declaredField.getName(), SalaryI18nUtil.getI18nLabel(annotation.labelId(), annotation.defaultLabel())); + } + return salarySobEmpFields.stream() + .map(e -> SalarySobEmpFieldDTO.builder() + .id(e.getId()) + .salarySobId(e.getSalarySobId()) + .fieldId(e.getFieldCode()) + .fieldName(empFieldMap.getOrDefault(e.getFieldCode(), "")) + .sortedIndex(e.getSortedIndex()) + .canDelete(Objects.equals(e.getCanDelete(), NumberUtils.INTEGER_ONE)) + .build()) + .collect(Collectors.toList()); + } + + /** + * 薪资账套的薪资项目按照sortedIndex排序 + * + * @param items 待排序的薪资账套的薪资项目 + * @return + */ + private List sortItem(Collection items) { + if (CollectionUtils.isEmpty(items)) { + return Collections.emptyList(); + } + return items.stream().sorted(Comparator.comparingInt(SalarySobItemDTO::getSortedIndex)).collect(Collectors.toList()); + } + + /** + * 薪资账套的薪资项目分类按照sortedIndex排序 + * + * @param itemGroups 待排序的薪资账套的薪资项目分类 + * @return + */ + private List sortItemGroup(Collection itemGroups) { + if (CollectionUtils.isEmpty(itemGroups)) { + return Collections.emptyList(); + } + return itemGroups.stream().map(group -> { + if (group != null && CollectionUtils.isEmpty(group.getItems())) { + group.setItems(new ArrayList<>()); + } + return group; + }).sorted(Comparator.comparingInt(SalarySobItemGroupDTO::getSortedIndex)).collect(Collectors.toList()); + } +} diff --git a/src/com/engine/salary/entity/salarysob/bo/SalarySobItemBO.java b/src/com/engine/salary/entity/salarysob/bo/SalarySobItemBO.java new file mode 100644 index 000000000..3dfde99ef --- /dev/null +++ b/src/com/engine/salary/entity/salarysob/bo/SalarySobItemBO.java @@ -0,0 +1,189 @@ +package com.engine.salary.entity.salarysob.bo; + +import com.engine.salary.constant.SalaryDefaultTenantConstant; +import com.engine.salary.entity.salaryitem.po.SalaryItemPO; +import com.engine.salary.entity.salarysob.po.*; +import com.engine.salary.enums.sicategory.DeleteTypeEnum; +import com.engine.salary.util.SalaryEntityUtil; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.engine.salary.util.db.IdGenerator; +import lombok.Data; +import lombok.experimental.Accessors; +import org.apache.commons.lang3.math.NumberUtils; + +import java.util.*; +import java.util.function.Function; +import java.util.stream.Collectors; + +/** + * 薪资账套薪资项目 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SalarySobItemBO { + + /** + * 默认包含的员工信息字段转换成薪资账套员工信息字段po + * + * @param salarySobId 薪资账套id + * @param defaultEmpFieldList 默认包含的员工信息字段 + * @param employeeId 当前登陆人员id + * @return + */ + public static List convert2EmpFieldPO(Long salarySobId, List defaultEmpFieldList, Long employeeId) { + Date now = new Date(); + return defaultEmpFieldList.stream() + .map(field -> new SalarySobEmpFieldPO() + .setSalarySobId(salarySobId) + .setFieldCode(field.getFieldCode()) + .setSortedIndex(field.getSortedIndex()) + .setCanDelete(field.getCanDelete()) + .setCreator(employeeId) + .setCreateTime(now) + .setUpdateTime(now) + .setDeleteType(0) + .setTenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)) + .collect(Collectors.toList()); + } + + /** + * 转换成薪资账套的薪资项目副本po + * + * @param salarySobId + * @param salarySobDefaultItemGroupPOS + * @param salarySobDefaultItemPOS + * @param defaultSalaryItemPOS + * @param employeeId + * @param tenantKey + * @return + */ + public static Result initSalarySobItem(Long salarySobId, + List salarySobDefaultItemGroupPOS, + List salarySobDefaultItemPOS, + List defaultSalaryItemPOS, + Long employeeId, String tenantKey) { + Date now = new Date(); + // 处理薪资账套默认的薪资项目分类 + Map salarySobItemGroupIdMap = Maps.newHashMapWithExpectedSize(salarySobDefaultItemGroupPOS.size()); + List salarySobItemGroups = Lists.newArrayListWithExpectedSize(salarySobDefaultItemGroupPOS.size()); + for (SalarySobDefaultItemGroupPO salarySobDefaultItemGroupPO : salarySobDefaultItemGroupPOS) { + long salarySobItemGroupId = IdGenerator.generate(); + salarySobItemGroups.add(SalarySobItemGroupPO.builder() + .id(salarySobItemGroupId) + .name(salarySobDefaultItemGroupPO.getName()) + .salarySobId(salarySobId) + .sortedIndex(salarySobDefaultItemGroupPO.getSortedIndex()) + .description(salarySobDefaultItemGroupPO.getDescription()) + .creator(employeeId) + .createTime(now) + .updateTime(now) + .tenantKey(tenantKey) + .deleteType(NumberUtils.INTEGER_ZERO) + .build()); + salarySobItemGroupIdMap.put(salarySobDefaultItemGroupPO.getId(), salarySobItemGroupId); + } + + + List salarySobItems = Lists.newArrayListWithExpectedSize(defaultSalaryItemPOS.size()); + // 处理薪资账套默认的系统薪资项目 + Set sysSalaryItemIds = SalaryEntityUtil.properties(salarySobDefaultItemPOS, SalarySobDefaultItemPO::getSysSalaryItemId); + Map salaryItemPOMap = defaultSalaryItemPOS.stream() + .filter(salaryItemPO -> sysSalaryItemIds.contains(salaryItemPO.getSysSalaryItemId())) + .collect(Collectors.toMap(SalaryItemPO::getSysSalaryItemId, Function.identity(), (a, b) -> a)); + for (SalarySobDefaultItemPO salarySobDefaultItemPO : salarySobDefaultItemPOS) { + SalaryItemPO salaryItemPO = salaryItemPOMap.get(salarySobDefaultItemPO.getSysSalaryItemId()); + if (salaryItemPO==null)continue; + salarySobItems.add(SalarySobItemPO.builder() + .salarySobId(salarySobId) + .salarySobItemGroupId(salarySobItemGroupIdMap.getOrDefault(salarySobDefaultItemPO.getSobDefaultItemGroupId(), NumberUtils.LONG_ZERO)) + .salaryItemId(salaryItemPO.getId()) + .formulaId(salaryItemPO.getFormulaId()) + .sortedIndex(salarySobDefaultItemPO.getSortedIndex()) + .description(salaryItemPO.getDescription()) + .canDelete(salarySobDefaultItemPO.getCanDelete()) + .creator(employeeId) + .createTime(now) + .updateTime(now) + .tenantKey(tenantKey) + .deleteType(NumberUtils.INTEGER_ZERO) + .build()); + } + // 处理薪资账套默认的自定义薪资项目(开启了"默认使用") + for (int i = 0; i < defaultSalaryItemPOS.size(); i++) { + SalaryItemPO salaryItemPO = defaultSalaryItemPOS.get(i); + if (sysSalaryItemIds.contains(salaryItemPO.getSysSalaryItemId())) { + continue; + } + // 获取系统默认回算薪资项目的系统id + List backItemSysItemIds = SalarySobBackItemBO.getDefault().stream().map(SalarySobDefaultBackItemPO::getSysSalaryItemId).collect(Collectors.toList()); + if (backItemSysItemIds.contains(salaryItemPO.getSysSalaryItemId())) { + continue; + } + salarySobItems.add(SalarySobItemPO.builder() + .salarySobId(salarySobId) + .salarySobItemGroupId(NumberUtils.LONG_ZERO) + .salaryItemId(salaryItemPO.getId()) + .formulaId(salaryItemPO.getFormulaId()) + .sortedIndex(i) + .description(salaryItemPO.getDescription()) + .canDelete(NumberUtils.INTEGER_ONE) + .creator(employeeId) + .createTime(now) + .updateTime(now) + .tenantKey(tenantKey) + .deleteType(NumberUtils.INTEGER_ZERO) + .build()); + } + + // 薪资账套默认的回算薪资项目 + List salarySobBackItems = Lists.newArrayListWithExpectedSize(2); + for (SalarySobDefaultBackItemPO salarySobDefaultBackItemPO : SalarySobBackItemBO.getDefault()) { + Map sysSalaryItemMap = SalaryEntityUtil.convert2Map(defaultSalaryItemPOS, SalaryItemPO::getSysSalaryItemId); + SalaryItemPO salaryItemPO = sysSalaryItemMap.get(salarySobDefaultBackItemPO.getSysSalaryItemId()); + SalarySobBackItemPO salarySobBackItemPO = SalarySobBackItemPO.builder() + .id(IdGenerator.generate()) + .salarySobId(salarySobId) + .salaryItemId(salaryItemPO.getId()) + .salaryItemCode(salaryItemPO.getCode()) + .dataType(salaryItemPO.getDataType()) + .roundingMode(salaryItemPO.getRoundingMode()) + .pattern(salaryItemPO.getPattern()) + .valueType(salaryItemPO.getValueType()) + .formulaId(salarySobDefaultBackItemPO.getFormulaId()) + .backCalcType(salarySobDefaultBackItemPO.getBackCalcType()) + .creator(employeeId) + .createTime(now) + .updateTime(now) + .deleteType(DeleteTypeEnum.NOT_DELETED.getValue()) + .tenantKey(tenantKey).build(); + salarySobBackItems.add(salarySobBackItemPO); + } + + return new Result().setNeedInsertSalarySobItems(salarySobItems).setNeedInsertSalarySobItemGroups(salarySobItemGroups) + .setNeedInsertSalarySobBackItems(salarySobBackItems); + } + + @Data + @Accessors(chain = true) + public static class Result { + + /** + * 需要保存的薪资项目 + */ + List needInsertSalarySobItems; + + /** + * 需要保存的薪资项目分类 + */ + List needInsertSalarySobItemGroups; + + /** + * 需要保存的回算薪资项目 + */ + List needInsertSalarySobBackItems; + } +} diff --git a/src/com/engine/salary/entity/salarysob/bo/SalarySobItemSaveBO.java b/src/com/engine/salary/entity/salarysob/bo/SalarySobItemSaveBO.java new file mode 100644 index 000000000..ba7d5a361 --- /dev/null +++ b/src/com/engine/salary/entity/salarysob/bo/SalarySobItemSaveBO.java @@ -0,0 +1,133 @@ +package com.engine.salary.entity.salarysob.bo; + +import com.engine.salary.constant.SalaryDefaultTenantConstant; +import com.engine.salary.entity.salarysob.param.SalarySobItemSaveParam; +import com.engine.salary.entity.salarysob.po.SalarySobEmpFieldPO; +import com.engine.salary.entity.salarysob.po.SalarySobItemGroupPO; +import com.engine.salary.entity.salarysob.po.SalarySobItemPO; +import lombok.Data; +import lombok.experimental.Accessors; +import org.apache.commons.compress.utils.Lists; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.math.NumberUtils; + +import java.util.Collection; +import java.util.Date; +import java.util.List; +import java.util.Optional; + +/** + * 薪资账套的薪资项目副本保存 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SalarySobItemSaveBO { + + /** + * 处理前端传回的保存参数,转换成po + * + * @param saveParam + * @param employeeId + * @return + */ + public static Result handle(SalarySobItemSaveParam saveParam, Long employeeId) { + Date now = new Date(); + Result result = new Result() + .setNeedInsertSalarySobEmpFields(Lists.newArrayList()) + .setNeedInsertSalarySobItems(Lists.newArrayList()) + .setNeedInsertSalarySobItemGroups(Lists.newArrayList()); + // 处理需要新增的员工信息字段 + for (SalarySobItemSaveParam.SalarySobEmpFieldParam salarySobEmpFieldParam : saveParam.getEmpFields()) { + SalarySobEmpFieldPO salarySobEmpFieldPO = SalarySobEmpFieldPO.builder() + .salarySobId(saveParam.getSalarySobId()) + .fieldCode(salarySobEmpFieldParam.getFieldId()) + .sortedIndex(salarySobEmpFieldParam.getSortedIndex()) + .canDelete(NumberUtils.INTEGER_ONE) + .creator(employeeId) + .createTime(now) + .updateTime(now) + .deleteType(NumberUtils.INTEGER_ZERO) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .build(); + result.getNeedInsertSalarySobEmpFields().add(salarySobEmpFieldPO); + } + // 处理需要新增的薪资项目和薪资项目分组 + int sortedIndex = 0; + for (SalarySobItemSaveParam.SalarySobItemGroupParam itemGroupParam : saveParam.getItemGroups()) { + SalarySobItemGroupPO salarySobItemGroupPO = SalarySobItemGroupPO.builder() + .salarySobId(saveParam.getSalarySobId()) + .name(itemGroupParam.getName()) + .sortedIndex(sortedIndex++) + .description(StringUtils.EMPTY) + .creator(employeeId) + .createTime(now) + .updateTime(now) + .deleteType(NumberUtils.INTEGER_ZERO) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .build(); + result.getNeedInsertSalarySobItemGroups().add(salarySobItemGroupPO); + // 处理薪资项目分组中的薪资项目 + handleSalarySobItems(result, saveParam.getSalarySobId(), salarySobItemGroupPO.getId(), itemGroupParam.getItems(), employeeId, SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY); + } + // 处理未进行分组的薪资项目 + handleSalarySobItems(result, saveParam.getSalarySobId(), NumberUtils.LONG_ZERO, saveParam.getItems(), employeeId, SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY); + return result; + } + + /** + * 将前端传递的参数转换成SalarySobItemPO + * + * @param result + * @param salarySobId + * @param salarySobItemGroupId + * @param itemParams + * @param employeeId + * @param tenantKey + */ + private static void handleSalarySobItems(Result result, + Long salarySobId, + Long salarySobItemGroupId, + List itemParams, + Long employeeId, String tenantKey) { + Date now = new Date(); + for (SalarySobItemSaveParam.SalarySobItemParam itemParam : itemParams) { + SalarySobItemPO salarySobItemPO = SalarySobItemPO.builder() + .salarySobId(salarySobId) + .salaryItemId(itemParam.getSalaryItemId()) + .salarySobItemGroupId(salarySobItemGroupId) + .formulaId(Optional.ofNullable(itemParam.getFormulaId()).orElse(NumberUtils.LONG_ZERO)) + .sortedIndex(itemParam.getSortedIndex()) + .description(StringUtils.EMPTY) + .creator(employeeId) + .createTime(now) + .updateTime(now) + .deleteType(NumberUtils.INTEGER_ZERO) + .tenantKey(tenantKey) + .build(); + result.getNeedInsertSalarySobItems().add(salarySobItemPO); + } + } + + @Data + @Accessors(chain = true) + public static class Result { + + /** + * 薪资账套中需要新增的员工信息字段 + */ + private Collection needInsertSalarySobEmpFields; + + /** + * 薪资账套中需要新增的薪资项目副本 + */ + private Collection needInsertSalarySobItems; + + /** + * 薪资账套中需要新增的薪资项目分组 + */ + private Collection needInsertSalarySobItemGroups; + } +} diff --git a/src/com/engine/salary/entity/salarysob/bo/SalarySobRangeBO.java b/src/com/engine/salary/entity/salarysob/bo/SalarySobRangeBO.java new file mode 100644 index 000000000..743555800 --- /dev/null +++ b/src/com/engine/salary/entity/salarysob/bo/SalarySobRangeBO.java @@ -0,0 +1,172 @@ +package com.engine.salary.entity.salarysob.bo; + +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.hrm.DeptInfo; +import com.engine.salary.entity.hrm.PositionInfo; +import com.engine.salary.entity.hrm.SubCompanyInfo; +import com.engine.salary.entity.salarysob.dto.SalarySobRangeListDTO; +import com.engine.salary.entity.salarysob.param.SalarySobRangeEmpQueryParam; +import com.engine.salary.entity.salarysob.po.SalarySobRangePO; +import com.engine.salary.enums.salarysob.SalaryEmployeeStatusEnum; +import com.engine.salary.enums.salarysob.TargetTypeEnum; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.SalaryI18nUtil; +import com.google.common.collect.Lists; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * 薪资账套人员范围 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SalarySobRangeBO { + + /** + * 将薪资账套的人员范围转换成人员查询参数 + * + * @param salarySobRanges 薪资账套的人员范围 + * @return + */ + public static List convert2EmployeeQueryParam(List salarySobRanges) { + if (CollectionUtils.isEmpty(salarySobRanges)) { + return Collections.emptyList(); + } + List resultParams = Lists.newArrayListWithExpectedSize(salarySobRanges.size()); + salarySobRanges.stream().forEach( item -> { + List employeeStatus= new ArrayList<>(); + String[] split = item.getEmployeeStatuses().split(","); + List enumsList = Arrays.asList(split).stream().map(i-> Integer.valueOf(i)).collect(Collectors.toList()); + List salaryEmployeeStatusEnums = SalaryEmployeeStatusEnum.parseByValues(enumsList); + for(SalaryEmployeeStatusEnum e: salaryEmployeeStatusEnums){ + employeeStatus.add(e.getValue().toString()); + } + TargetTypeEnum targetTypeEnum = TargetTypeEnum.parseByValue(item.getTargetType()); + SalarySobRangeEmpQueryParam queryParam = SalarySobRangeEmpQueryParam.builder() + .targetType(Optional.ofNullable(targetTypeEnum).map(TargetTypeEnum::name).orElse(StringUtils.EMPTY)) + .targetIds(Arrays.asList(item.getTargetId())) + .target(item.getTarget()) + .employeeStatus(employeeStatus) + .build(); + resultParams.add(queryParam); + }); + return resultParams; + } + + /** + * 薪资账套的人员范围po转换成人员范围列表dto + * + * @param salarySobRanges 薪资账套的人员范围 + * @param employeeComInfos 人员信息 + * @param departmentComInfos 部门信息 + * @param positionComInfos 岗位信息 + * @return + */ + public static List convert2ListDTO(List salarySobRanges, + List employeeComInfos, + List departmentComInfos, + List subCompanyInfos, + List positionComInfos) { + if (CollectionUtils.isEmpty(salarySobRanges)) { + return Collections.emptyList(); + } + Map employeeComInfoMap = SalaryEntityUtil.convert2Map(employeeComInfos, DataCollectionEmployee::getEmployeeId, DataCollectionEmployee::getUsername); + Map departmentComInfoMap = SalaryEntityUtil.convert2Map(departmentComInfos, DeptInfo::getId, DeptInfo::getName); + Map subCompanyComInfoMap = SalaryEntityUtil.convert2Map(subCompanyInfos, SubCompanyInfo::getId, SubCompanyInfo::getName); + Map positionComInfoMap = SalaryEntityUtil.convert2Map(positionComInfos, PositionInfo::getId, PositionInfo::getName); + return salarySobRanges.stream() + .map(salarySobRangePO -> { + TargetTypeEnum targetTypeEnum = TargetTypeEnum.parseByValue(salarySobRangePO.getTargetType()); + + String employeeStatusesStr = parseByEmployeeStatuses(salarySobRangePO.getEmployeeStatuses()); + return SalarySobRangeListDTO.builder() + .id(salarySobRangePO.getId()) + .salarySobId(salarySobRangePO.getSalarySobId()) + .targetType(targetTypeEnum) + .targetTypeName(Optional.ofNullable(targetTypeEnum) + .map(e -> SalaryI18nUtil.getI18nLabel(e.getLabelId(), e.getDefaultLabel())) + .orElse(StringUtils.EMPTY)) + .targetId(salarySobRangePO.getTargetId()) + .target(salarySobRangePO.getTarget()) + .targetName(buildTargetName(salarySobRangePO, employeeComInfoMap, departmentComInfoMap, subCompanyComInfoMap, positionComInfoMap)) + .employeeStatus(employeeStatusesStr) + .status(parseByStatuses(salarySobRangePO.getEmployeeStatuses())) + .build(); + }) + .collect(Collectors.toList()); + } + + /** + * 转换employeeStatuses + * + * @param employeeStatuses + * @return + */ + private static String parseByEmployeeStatuses(String employeeStatuses) { + String[] split = employeeStatuses.split(","); + List enumsList = Arrays.asList(split).stream().map(item -> Integer.valueOf(item)).collect(Collectors.toList()); + List salaryEmployeeStatusEnums = SalaryEmployeeStatusEnum.parseByValues(enumsList); + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < salaryEmployeeStatusEnums.size(); i++) { + sb.append(salaryEmployeeStatusEnums.get(i).getDefaultLabel()); + if (i + 1 != salaryEmployeeStatusEnums.size()) { + sb.append(","); + } + } + return sb.toString(); + } + + private static String parseByStatuses(String employeeStatuses) { + String[] split = employeeStatuses.split(","); + List enumsList = Arrays.asList(split).stream().map(item -> Integer.valueOf(item)).collect(Collectors.toList()); + List salaryEmployeeStatusEnums = SalaryEmployeeStatusEnum.parseByValues(enumsList); + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < salaryEmployeeStatusEnums.size(); i++) { + sb.append(salaryEmployeeStatusEnums.get(i)); + if (i + 1 != salaryEmployeeStatusEnums.size()) { + sb.append(","); + } + } + return sb.toString(); + } + + /** + * 解析薪资账套人员范围中对象的名称(可能是人员名称、部门名称、岗位名称……) + * + * @param salarySobRange 薪资账套的人员范围 + * @param employeeComInfoMap 人员信息 + * @param departmentComInfoMap 部门信息 + * @param positionComInfoMap 岗位信息 + * @return + */ + private static String buildTargetName(SalarySobRangePO salarySobRange, + Map employeeComInfoMap, + Map departmentComInfoMap, + Map subCompanyComInfoMap, + Map positionComInfoMap) { + TargetTypeEnum targetTypeEnum = TargetTypeEnum.parseByValue(salarySobRange.getTargetType()); + if (Objects.isNull(targetTypeEnum)) { + return StringUtils.EMPTY; + } + switch (targetTypeEnum) { + case EMPLOYEE: + return employeeComInfoMap.getOrDefault(salarySobRange.getTargetId(), StringUtils.EMPTY); + case DEPT: + return departmentComInfoMap.getOrDefault(salarySobRange.getTargetId(), StringUtils.EMPTY); + case SUBCOMPANY: + return subCompanyComInfoMap.getOrDefault(salarySobRange.getTargetId(), StringUtils.EMPTY); + case POSITION: + return positionComInfoMap.getOrDefault(salarySobRange.getTargetId(), StringUtils.EMPTY); + case SQL: + return salarySobRange.getTarget(); + default: + return StringUtils.EMPTY; + } + } +} diff --git a/src/com/engine/salary/entity/salarysob/bo/SalarySobRangeSaveBO.java b/src/com/engine/salary/entity/salarysob/bo/SalarySobRangeSaveBO.java new file mode 100644 index 000000000..1662d83f1 --- /dev/null +++ b/src/com/engine/salary/entity/salarysob/bo/SalarySobRangeSaveBO.java @@ -0,0 +1,141 @@ +package com.engine.salary.entity.salarysob.bo; + +import com.engine.salary.constant.SalaryDefaultTenantConstant; +import com.engine.salary.entity.salarysob.param.SalarySobRangeSaveParam; +import com.engine.salary.entity.salarysob.po.SalarySobRangePO; +import com.engine.salary.enums.salarysob.SalaryEmployeeStatusEnum; +import com.engine.salary.enums.salarysob.TargetTypeEnum; +import com.engine.salary.util.SalaryEntityUtil; +import com.google.common.collect.Lists; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.apache.commons.collections4.CollectionUtils; + +import java.util.Collection; +import java.util.Date; +import java.util.List; +import java.util.Map; + +/** + * 薪资账套的人员范围保存 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SalarySobRangeSaveBO { + + /** + * 处理前端传回的保存参数,转换成对应的po(如果保存参数中的人员、部门、岗位等之前就已经添加过了,就不需要再次保存了) + * + * @param salarySobRanges + * @param saveParam + * @param employeeId + * @return + */ + public static Result handle(List salarySobRanges, SalarySobRangeSaveParam saveParam, Long employeeId, boolean isImport) { + Date now = new Date(); + Result handleResult = Result.builder() + .needInsertSalarySobRanges(Lists.newArrayList()) + .needUpdateSalarySobRanges(Lists.newArrayList()) + .build(); + if (CollectionUtils.isEmpty(saveParam.getTargetParams())) { + return handleResult; + } + Map salarySobRangeMap = SalaryEntityUtil.convert2Map(salarySobRanges, e -> e.getIncludeType() + "-" + e.getTargetType() + "-" + e.getTargetId()); + for (SalarySobRangeSaveParam.SalarySobRangeTargetParam targetParam : saveParam.getTargetParams()) { + if (targetParam.getTargetType() == TargetTypeEnum.SQL) { + SalarySobRangePO salarySobRangePO = SalarySobRangePO.builder() + .salarySobId(saveParam.getSalarySobId()) + .targetType(targetParam.getTargetType().getValue()) + .targetId(0L) + .target(targetParam.getTarget()) +// .employeeStatuses(parseEnumListToStr(saveParam.getEmployeeStatus())) +// .employeeStatus(saveParam.getEmployeeStatus().getValue()) + .includeType(saveParam.getIncludeType()) + .creator(employeeId) + .createTime(now) + .updateTime(now) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .deleteType(0) + .build(); + + if (isImport) { + salarySobRangePO.setEmployeeStatuses(parseEnumListToStr(targetParam.getEmployeeStatus())); + } else { + salarySobRangePO.setEmployeeStatuses(parseEnumListToStr(saveParam.getEmployeeStatus())); + } + + handleResult.getNeedInsertSalarySobRanges().add(salarySobRangePO); + }else { + String key = saveParam.getIncludeType() + "-" + targetParam.getTargetType().getValue() + "-" + targetParam.getTargetId(); + if (salarySobRangeMap.containsKey(key)) { + SalarySobRangePO salarySobRangePO = salarySobRangeMap.get(key); + if (isImport) { + salarySobRangePO.setEmployeeStatuses(parseEnumListToStr(targetParam.getEmployeeStatus())); + } else { + salarySobRangePO.setEmployeeStatuses(parseEnumListToStr(saveParam.getEmployeeStatus())); + } + salarySobRangePO.setUpdateTime(now); + handleResult.getNeedUpdateSalarySobRanges().add(salarySobRangePO); + continue; + } + SalarySobRangePO salarySobRangePO = SalarySobRangePO.builder() + .salarySobId(saveParam.getSalarySobId()) + .targetType(targetParam.getTargetType().getValue()) + .targetId(targetParam.getTargetId()) + .target(targetParam.getTarget()) +// .employeeStatuses(parseEnumListToStr(saveParam.getEmployeeStatus())) +// .employeeStatus(saveParam.getEmployeeStatus().getValue()) + .includeType(saveParam.getIncludeType()) + .creator(employeeId) + .createTime(now) + .updateTime(now) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .deleteType(0) + .build(); + + if (isImport) { + salarySobRangePO.setEmployeeStatuses(parseEnumListToStr(targetParam.getEmployeeStatus())); + } else { + salarySobRangePO.setEmployeeStatuses(parseEnumListToStr(saveParam.getEmployeeStatus())); + } + + handleResult.getNeedInsertSalarySobRanges().add(salarySobRangePO); + } + } + return handleResult; + } + + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + public static class Result { + + /** + * 需要更新的人员范围 + */ + private Collection needUpdateSalarySobRanges; + + /** + * 需要新增的人员范围 + */ + private Collection needInsertSalarySobRanges; + } + + public static String parseEnumListToStr(SalaryEmployeeStatusEnum[] salaryEmployeeStatusEnums) { + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < salaryEmployeeStatusEnums.length; i++) { + sb.append(salaryEmployeeStatusEnums[i].getValue().toString()); + if (i + 1 != salaryEmployeeStatusEnums.length) { + sb.append(","); + } + } + return sb.toString(); + } + +} diff --git a/src/com/engine/salary/entity/salarysob/config/SalarySobConfig.java b/src/com/engine/salary/entity/salarysob/config/SalarySobConfig.java new file mode 100644 index 000000000..b367cc5cf --- /dev/null +++ b/src/com/engine/salary/entity/salarysob/config/SalarySobConfig.java @@ -0,0 +1,38 @@ +package com.engine.salary.entity.salarysob.config; + +import com.engine.salary.entity.salarysob.po.*; +import com.thoughtworks.xstream.annotations.XStreamAlias; +import com.thoughtworks.xstream.annotations.XStreamImplicit; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@XStreamAlias("SalarySobConfig") +public class SalarySobConfig { + + @XStreamAlias("SalarySob") + private SalarySobPO salarySob; + + @XStreamImplicit + private List salarySobEmpFields; + + @XStreamImplicit + private List salarySobItemGroups; + + @XStreamImplicit + private List salarySobItems; + + @XStreamImplicit + private List salarySobBackItems; + + @XStreamImplicit + private List salarySobAdjustRules; + +} diff --git a/src/com/engine/salary/entity/salarysob/dto/SalaryApprovalDTO.java b/src/com/engine/salary/entity/salarysob/dto/SalaryApprovalDTO.java new file mode 100644 index 000000000..143d98fca --- /dev/null +++ b/src/com/engine/salary/entity/salarysob/dto/SalaryApprovalDTO.java @@ -0,0 +1,78 @@ +package com.engine.salary.entity.salarysob.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * 薪资审批设置列表 + *

Copyright: Copyright (c) 2024

+ *

Company: 泛微软件

+ * + * @author xuzhuoyan + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalaryApprovalDTO { + + // 主键id + private Long id; + + // 薪资账套id + private Long salarySobId; + + // 是否开启审批 + private Boolean isOpenApproval; + + // 审批流程地址 + private String approvalWorkflowUrl; + + // 审批项目信息 + private List approvalItemGroup; + + private Boolean canEdit; + + /** + * 审批项目信息分组形式 + */ + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + public static class approvalItemGroup { + + // 分组名称 + private String groupName; + + // 项目信息 + private List approvalItems; + + // 排序 + private Integer sorted; + } + + /** + * 审批薪资项目 + */ + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + public static class approvalItem { + // 薪资项目id + private Long salaryItemId; + + // 薪资项目名称 + private String salaryItemName; + + // 排序 + private Integer sorted; + + } +} diff --git a/src/com/engine/salary/entity/salarysob/dto/SalaryItemBaseDTO.java b/src/com/engine/salary/entity/salarysob/dto/SalaryItemBaseDTO.java new file mode 100644 index 000000000..4b6266ff1 --- /dev/null +++ b/src/com/engine/salary/entity/salarysob/dto/SalaryItemBaseDTO.java @@ -0,0 +1,26 @@ +package com.engine.salary.entity.salarysob.dto; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +/** + * 薪资账套的薪资项目副本 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Accessors(chain = true) +@NoArgsConstructor +@AllArgsConstructor +public class SalaryItemBaseDTO { + //薪资项目id + private Long salaryItemId; + + //薪资项目名称 + private String salaryItemName; +} diff --git a/src/com/engine/salary/entity/salarysob/dto/SalarySobAdjustRuleListDTO.java b/src/com/engine/salary/entity/salarysob/dto/SalarySobAdjustRuleListDTO.java new file mode 100644 index 000000000..208bc21a5 --- /dev/null +++ b/src/com/engine/salary/entity/salarysob/dto/SalarySobAdjustRuleListDTO.java @@ -0,0 +1,48 @@ +package com.engine.salary.entity.salarysob.dto; + +import com.engine.salary.enums.salarysob.SalarySobAdjustRuleTypeEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 调薪规则列表 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalarySobAdjustRuleListDTO { + + //主键id + private Long id; + + //薪资项目的id + private Long salaryItemId; + + //薪资项目的名称 + private String salaryItemName; + + //生效日期 + private Integer dayOfMonth; + + /** + * 在生效日期之前调薪如何调整 + * + * @see SalarySobAdjustRuleTypeEnum + */ + private Integer beforeAdjustmentType; + + /** + * 在生效日期之后调薪如何调整 + * + * @see SalarySobAdjustRuleTypeEnum + */ + private Integer afterAdjustmentType; +} diff --git a/src/com/engine/salary/entity/salarysob/dto/SalarySobBackItemAggregateDTO.java b/src/com/engine/salary/entity/salarysob/dto/SalarySobBackItemAggregateDTO.java new file mode 100644 index 000000000..7fed49e68 --- /dev/null +++ b/src/com/engine/salary/entity/salarysob/dto/SalarySobBackItemAggregateDTO.java @@ -0,0 +1,72 @@ +package com.engine.salary.entity.salarysob.dto; + +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * @author Harryxzy + * @date 2022/11/15 16:00 + * @description + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalarySobBackItemAggregateDTO { + + // 薪资账套的id + @JsonSerialize(using = ToStringSerializer.class) + private Long salarySobId; + + // 已发项目设置 + private List issuedItems; + + // 补发项目设置 + private List reissueItems; + + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + public static class SalarySobBackItemDTO{ + + // 主键id + @JsonSerialize(using = ToStringSerializer.class) + private Long id; + + // 薪资项目的名称 + private String name; + + // 薪资项目的id + @JsonSerialize(using = ToStringSerializer.class) + private Long salaryItemId; + + // 公式id + @JsonSerialize(using = ToStringSerializer.class) + private Long formulaId; + + // 公式详情 + private String formulaContent; + + // 字段类型 + private String dataType; + + // 显示顺序 + private Integer sortedIndex; + + // 是否可以编辑 + private boolean canEdit; + + // 是否可以删除 + private boolean canDelete; + + private String backCalcType; + } +} + diff --git a/src/com/engine/salary/entity/salarysob/dto/SalarySobBackItemDTO.java b/src/com/engine/salary/entity/salarysob/dto/SalarySobBackItemDTO.java new file mode 100644 index 000000000..ee984ed7f --- /dev/null +++ b/src/com/engine/salary/entity/salarysob/dto/SalarySobBackItemDTO.java @@ -0,0 +1,64 @@ +package com.engine.salary.entity.salarysob.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author Harryxzy + * @date 2022/11/18 9:52 + * @description 薪资回算项目 + */ +@Builder +@Data +@AllArgsConstructor +@NoArgsConstructor +public class SalarySobBackItemDTO { + + // 主键id + private Long id; + + // 薪资项目的id + private Long salaryItemId; + + // 系统薪资项目的id + private Long sysSalaryItemId; + + // 薪资项目分组id + private Long salarySobItemGroupId; + + // 薪资类型 + private String incomeCategory; + + // 名称 + private String name; + + // 公式 + private Long formulaId; + + // 公式内容 + private String formulaContent; + + // 字段类型 + private String dataType; + + // 小数位数 + private Integer pattern; + + // 小数位数 + private String taxDeclarationColumn; + + // 排序字段 + private Integer sortedIndex; + + // 是否可以编辑 + private boolean canEdit; + + // 是否可以删除 + private boolean canDelete; + + // 回算类型 + private Integer backCalcType; + +} diff --git a/src/com/engine/salary/entity/salarysob/dto/SalarySobBackItemFormDTO.java b/src/com/engine/salary/entity/salarysob/dto/SalarySobBackItemFormDTO.java new file mode 100644 index 000000000..8804ba72e --- /dev/null +++ b/src/com/engine/salary/entity/salarysob/dto/SalarySobBackItemFormDTO.java @@ -0,0 +1,52 @@ +package com.engine.salary.entity.salarysob.dto; + +import com.engine.salary.enums.SalaryRoundingModeEnum; +import com.engine.salary.enums.SalaryValueTypeEnum; +import com.engine.salary.enums.salaryitem.SalaryDataTypeEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; +import java.util.Map; + +/** + * @author Harryxzy + * @date 2022/11/16 14:42 + * @description 薪资账套下的回算薪资项目详情 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalarySobBackItemFormDTO { + + // 主键id + private Long id; + + // 薪资项目 + private List> salaryItem; + + // 字段类型 + private SalaryDataTypeEnum dataType; + + // 舍入规则 + private SalaryRoundingModeEnum roundingMode; + + // 保留小数位 + private String pattern; + + // 取值方式 + private SalaryValueTypeEnum valueType; + + // 公式id + private Long formulaId; + + // 公式内容 + private String formulaContent; + + // 个税申报表对应字段 + private String taxDeclarationColumn; + +} diff --git a/src/com/engine/salary/entity/salarysob/dto/SalarySobBasicFormDTO.java b/src/com/engine/salary/entity/salarysob/dto/SalarySobBasicFormDTO.java new file mode 100644 index 000000000..77b7221d7 --- /dev/null +++ b/src/com/engine/salary/entity/salarysob/dto/SalarySobBasicFormDTO.java @@ -0,0 +1,124 @@ +package com.engine.salary.entity.salarysob.dto; + +import com.engine.salary.component.WeaFormOption; +import com.engine.salary.enums.SalaryCycleTypeEnum; +import com.engine.salary.enums.SalarySobStatusEnum; +import com.engine.salary.enums.salarysob.IncomeCategoryEnum; +import com.engine.salary.util.SalaryI18nUtil; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import com.google.common.collect.Lists; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.util.Collections; +import java.util.List; + +/** + * 薪资账套基础信息表单 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Accessors(chain = true) +@NoArgsConstructor +@AllArgsConstructor +public class SalarySobBasicFormDTO { + + //主键 + @JsonSerialize(using = ToStringSerializer.class) + private Long id; + + + /** + * 名称 + */ + private String name; + + /** + * 扣缴义务人 + */ + private List taxAgentIds; + + /** + * 薪资类型 + * @see IncomeCategoryEnum + */ + private Integer taxableItems; + + /** + * 薪资周期 + * @see SalaryCycleTypeEnum + */ + private Integer salaryCycleType; + + //薪资周期的起始日期") + private Integer salaryCycleFromDay; + + /** + * 税款所属期 + * @see SalaryCycleTypeEnum + */ + private Integer taxCycleType; + + /** + * 考勤周期 + * @see SalaryCycleTypeEnum + */ + private Integer attendCycleType; + + //考勤周期起始日期") + private Integer attendCycleFromDay; + + /** + * 福利台账月份 + * @see SalaryCycleTypeEnum + */ + private Integer socialSecurityCycleType; + + //核算人员范围") + private String employeeRange; + + /** + * 目前薪资账套所处的步骤 + * @see SalarySobStatusEnum + */ + private Integer status; + + //备注") + private String description; + + /** + * 分权,是否可编辑 + */ + private Boolean canEdit; + + /** + * 薪资账套详情-薪资周期/考勤周期 + * + * @return + */ + public List listCycleFromDayOption() { + List resultList = Lists.newArrayListWithExpectedSize(31); + for (int i = 1; i <= 31; i++) { + resultList.add(new WeaFormOption(String.valueOf(i), SalaryI18nUtil.getI18nLabel(98382, "{0}号").replace("{0}", "" + i))); + } + return resultList; + } + + /** + * 薪资账套详情-核算人员范围 + * + * @return + */ + public List listEmployeeRangeOption() { + WeaFormOption weaFormOption = new WeaFormOption("1", SalaryI18nUtil.getI18nLabel(98381, "【入职日期≤薪资周期止】且【离职日期≥薪资周期起】")); + weaFormOption.setDisabled(true); + return Collections.singletonList(weaFormOption); + } +} diff --git a/src/com/engine/salary/entity/salarysob/dto/SalarySobCheckRuleFormDTO.java b/src/com/engine/salary/entity/salarysob/dto/SalarySobCheckRuleFormDTO.java new file mode 100644 index 000000000..2dd4decd5 --- /dev/null +++ b/src/com/engine/salary/entity/salarysob/dto/SalarySobCheckRuleFormDTO.java @@ -0,0 +1,53 @@ +package com.engine.salary.entity.salarysob.dto; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +/** + * 薪资账套校验规则表单 + */ +@Data +@Accessors(chain = true) +@NoArgsConstructor +@AllArgsConstructor +public class SalarySobCheckRuleFormDTO { + + //主键id") + private Long id; + + //薪资账套id") +// @NotNull(message = "薪资账套id不允许为空") + private Long salarySobId; + +// @SalaryForm( +// label = "规则名称", +// labelId = 100173, +// items = @SalaryFormItem(itemType = WeaFormItemType.INPUT, required = true, maxLength = "15") +// ) + //规则名称") +// @NotEmpty(message = "规则名称不允许为空") + private String name; + + //公式id") +// @NotNull(message = "校验规则不允许为空") +// @Positive(message = "校验规则不允许为空") + private Long formulaId; + +// @SalaryForm( +// label = "校验规则", +// labelId = 86126, +// items = @SalaryFormItem(itemType = WeaFormItemType.INPUT, required = true) +// ) + //校验规则") + private String formulaContent; + +// @SalaryForm( +// label = "备注", +// labelId = 84961, +// items = @SalaryFormItem(itemType = WeaFormItemType.INPUT, maxLength = "20") +// ) + //备注") + private String description; +} diff --git a/src/com/engine/salary/entity/salarysob/dto/SalarySobCheckRuleListDTO.java b/src/com/engine/salary/entity/salarysob/dto/SalarySobCheckRuleListDTO.java new file mode 100644 index 000000000..d0e409b28 --- /dev/null +++ b/src/com/engine/salary/entity/salarysob/dto/SalarySobCheckRuleListDTO.java @@ -0,0 +1,53 @@ +package com.engine.salary.entity.salarysob.dto; + +import com.cloudstore.eccom.pc.table.WeaTableType; +import com.engine.salary.annotation.SalaryTable; +import com.engine.salary.annotation.SalaryTableColumn; +import com.engine.salary.annotation.SalaryTableOperate; +import com.engine.salary.annotation.TableTitle; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +/** + * 薪资账套校验规则列表 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Accessors(chain = true) +@NoArgsConstructor +@AllArgsConstructor +@SalaryTable(pageId = "a4f85287-e3f9-4d11-adn9-7d06e54y6rj8", tableType = WeaTableType.CHECKBOX, operates = { + @SalaryTableOperate(index = "0", text = "编辑"), + @SalaryTableOperate(index = "1", text = "删除"), +}) +public class SalarySobCheckRuleListDTO { + + //主键id + @SalaryTableColumn(column = "id", display = false) + @TableTitle(title = "id", dataIndex = "id", key = "id") + private Long id; + + //薪资账套id + private Long salarySobId; + + @SalaryTableColumn(text = "名称", width = "10%", column = "name") + @TableTitle(title = "名称", dataIndex = "name", key = "name") + private String name; + + //公式id + private Long formulaId; + + @SalaryTableColumn(text = "校验规则", width = "10%", column = "formulaContent") + @TableTitle(title = "校验规则", dataIndex = "formulaContent", key = "formulaContent") + private String formulaContent; + + @SalaryTableColumn(text = "备注", width = "10%", column = "description") + @TableTitle(title = "备注", dataIndex = "description", key = "description") + private String description; +} diff --git a/src/com/engine/salary/entity/salarysob/dto/SalarySobCycleDTO.java b/src/com/engine/salary/entity/salarysob/dto/SalarySobCycleDTO.java new file mode 100644 index 000000000..70a688b10 --- /dev/null +++ b/src/com/engine/salary/entity/salarysob/dto/SalarySobCycleDTO.java @@ -0,0 +1,68 @@ +package com.engine.salary.entity.salarysob.dto; + +import com.engine.salary.annotation.SalaryFormulaVar; +import com.engine.salary.common.LocalDateRange; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.time.YearMonth; +import java.util.Date; + +/** + * 薪资账套的周期 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalarySobCycleDTO { + + //薪资账套id + private Long salarySobId; + + //薪资所属月 + @JsonSerialize(using = ToStringSerializer.class) + private YearMonth salaryMonth; + + //税款所属期 + @JsonSerialize(using = ToStringSerializer.class) + private YearMonth taxCycle; + + //社保福利所属期 + @JsonSerialize(using = ToStringSerializer.class) + private YearMonth socialSecurityCycle; + + //薪资周期") + private LocalDateRange salaryCycle; + + //考勤周期") + private LocalDateRange attendCycle; + + + /** + * 公式变量 + */ + @SalaryFormulaVar(defaultLabel = "薪资所属月", labelId = 86321, dataType = "string") + private Date salaryDate; + @SalaryFormulaVar(defaultLabel = "税款所属期", labelId = 86321, dataType = "string") + private Date taxDate; + @SalaryFormulaVar(defaultLabel = "社保福利所属期", labelId = 86321, dataType = "string") + private Date socialSecurityDate; + @SalaryFormulaVar(defaultLabel = "薪资周期起始日期", labelId = 86321, dataType = "string") + private Date salaryCycleFromDate; + @SalaryFormulaVar(defaultLabel = "薪资周期结束日期", labelId = 86321, dataType = "string") + private Date salaryCycleEndDate; + @SalaryFormulaVar(defaultLabel = "考勤周期起始日期", labelId = 86321, dataType = "string") + private Date attendCycleFromDate; + @SalaryFormulaVar(defaultLabel = "考勤周期结束日期", labelId = 86321, dataType = "string") + private Date attendCycleEndDate; +} diff --git a/src/com/engine/salary/entity/salarysob/dto/SalarySobEmpFieldDTO.java b/src/com/engine/salary/entity/salarysob/dto/SalarySobEmpFieldDTO.java new file mode 100644 index 000000000..149e2da8a --- /dev/null +++ b/src/com/engine/salary/entity/salarysob/dto/SalarySobEmpFieldDTO.java @@ -0,0 +1,44 @@ +package com.engine.salary.entity.salarysob.dto; + +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 薪资账套薪资项目-员工信息字段 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//薪资账套薪资项目-员工信息字段 +public class SalarySobEmpFieldDTO { + + //主键id + @JsonSerialize(using = ToStringSerializer.class) + private Long id; + + //薪资账套id + @JsonSerialize(using = ToStringSerializer.class) + private Long salarySobId; + + //字段id + private String fieldId; + + //字段名称 + private String fieldName; + + //排序字段 + private Integer sortedIndex; + + //是否允许删除。false:不允许删除、true:允许删除 + private boolean canDelete; +} diff --git a/src/com/engine/salary/entity/salarysob/dto/SalarySobItemAggregateDTO.java b/src/com/engine/salary/entity/salarysob/dto/SalarySobItemAggregateDTO.java new file mode 100644 index 000000000..9fff58c8c --- /dev/null +++ b/src/com/engine/salary/entity/salarysob/dto/SalarySobItemAggregateDTO.java @@ -0,0 +1,45 @@ +package com.engine.salary.entity.salarysob.dto; + +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * 薪资账套薪资项目详情 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//薪资账套薪资项目详情 +public class SalarySobItemAggregateDTO { + + //薪资账套的id + @JsonSerialize(using = ToStringSerializer.class) + private Long salarySobId; + + //薪资账套的薪资项目详情-员工信息 + private List empFields; + + //薪资账套的薪资项目详情-薪资项目分类 + private List itemGroups; + + //薪资账套的薪资项目详情-薪资项目(未分类) + private List items; + + //薪资账套的薪资项目按薪资类型分类(账套目前只含一个类型,只给核算表头带出公式使用。未来若账套包含多类型时,可用于扩展) + private List incomeCategories; + + // 已发薪资项目 + private List backCalcItems; +} diff --git a/src/com/engine/salary/entity/salarysob/dto/SalarySobItemDTO.java b/src/com/engine/salary/entity/salarysob/dto/SalarySobItemDTO.java new file mode 100644 index 000000000..9429f1522 --- /dev/null +++ b/src/com/engine/salary/entity/salarysob/dto/SalarySobItemDTO.java @@ -0,0 +1,118 @@ +package com.engine.salary.entity.salarysob.dto; + +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 薪资账套的薪资项目 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//薪资账套的薪资项目 +public class SalarySobItemDTO { + + //主键id + @JsonSerialize(using = ToStringSerializer.class) + private Long id; + + //薪资账套的id + @JsonSerialize(using = ToStringSerializer.class) + private Long salarySobId; + + //薪资项目的id + @JsonSerialize(using = ToStringSerializer.class) + private Long salaryItemId; + + //薪资项目分组的id + @JsonSerialize(using = ToStringSerializer.class) + private Long salaryItemGroupId; + + //名称 + private String name; + + + //是否是薪资档案引用 + private Integer useInEmployeeSalary; + + //是否是系统内置的薪资项目 @see SalarySystemTypeEnum + private Integer systemType; + + //默认使用 + private Integer useDefault; + + //属性 @see SalaryItemCategoryEnum + private Integer category; + + //类型(展示名称) + private String itemType; + + //类型 @see SalaryItemTypeEnum + private Integer itemTypeId; + + //取值方式 @see SalaryValueTypeEnum + private Integer valueType; + + private String dataType; + + //数据来源(展示名称) + private String dataSource; + + //数据来源 @see SalaryDataSourceEnum + private Integer dataSourceId; + + //公式 + @JsonSerialize(using = ToStringSerializer.class) + private Long formulaId; + + //公式内容 + private String formulaContent; + // 用于前端展示 公式原始内容 + private String originFormulaContent; + // 用于前端展示 原始sql + private String originSqlContent; + + + + //个税申报表对应字段 + private String taxDeclarationColumn; + + //排序字段 + private Integer sortedIndex; + + //是否可以编辑 + private boolean canEdit; + + //是否可以删除 + private boolean canDelete; + + //该分类是否隐藏(0不隐藏,1隐藏) + @JsonSerialize(using = ToStringSerializer.class) + private Long itemHide; + + /** + * 进位规则 + */ + private Integer roundingMode; + + /** + * 保留小数位数 + */ + private Integer pattern; + + // 显示宽度 + private Integer width; + + // 默认值 + private String defaultValue; +} diff --git a/src/com/engine/salary/entity/salarysob/dto/SalarySobItemFormDTO.java b/src/com/engine/salary/entity/salarysob/dto/SalarySobItemFormDTO.java new file mode 100644 index 000000000..890f52ee9 --- /dev/null +++ b/src/com/engine/salary/entity/salarysob/dto/SalarySobItemFormDTO.java @@ -0,0 +1,89 @@ +package com.engine.salary.entity.salarysob.dto; + +import com.engine.salary.enums.SalaryRoundingModeEnum; +import com.engine.salary.enums.SalaryValueTypeEnum; +import com.engine.salary.enums.salaryitem.SalaryDataTypeEnum; +import com.engine.salary.util.valid.DataCheck; +import com.engine.salary.util.valid.RuntimeTypeEnum; +import com.engine.salary.util.valid.ValidTypeEnum; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +/** + * 薪资账套-薪资项目表单 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author xzy + * @version 1.0 + **/ +@Data +@Accessors(chain = true) +@NoArgsConstructor +@AllArgsConstructor +public class SalarySobItemFormDTO { + + //主键id") + @JsonSerialize(using = ToStringSerializer.class) + @DataCheck(require = true, runtime = {RuntimeTypeEnum.UPDATE}, message = "id不允许为空") + private Long id; + + //名称") + private String name; + + //核算时隐藏") + @DataCheck(require = true, runtime = {RuntimeTypeEnum.UPDATE}, message = "核算时隐藏不允许为空") + private Integer itemHide; + + //字段类型 + /** + * @see SalaryDataTypeEnum + */ + private String dataType; + + //舍入规则") + /** + * @see SalaryRoundingModeEnum + */ + @DataCheck(require = true, runtime = {RuntimeTypeEnum.UPDATE}, message = "舍入规则不允许为空") + private Integer roundingMode; + + //保留小数位") + @DataCheck(require = true, type = ValidTypeEnum.NUMBER, max = 10, message = "小数位最多为10") + private Integer pattern; + + //取值方式") + /** + * @see SalaryValueTypeEnum + */ + @DataCheck(require = true, runtime = {RuntimeTypeEnum.UPDATE}, message = "取值方式不允许为空") + private Integer valueType; + + //公式") + private Long formulaId; + + //公式内容") + private String formulaContent; + + // 用于前端展示 公式原始内容 + private String originFormulaContent; + // 用于前端展示 原始sql + private String originSqlContent; + + //备注") + private String description; + + //是否可以编辑") + private Integer canEdit; + + + // 薪资档案引用。0:薪资档案未引用、1:薪资档案引用 + private Integer useInEmployeeSalary; + + // 默认值 + private String defaultValue; +} diff --git a/src/com/engine/salary/entity/salarysob/dto/SalarySobItemGroupDTO.java b/src/com/engine/salary/entity/salarysob/dto/SalarySobItemGroupDTO.java new file mode 100644 index 000000000..ee06db0a6 --- /dev/null +++ b/src/com/engine/salary/entity/salarysob/dto/SalarySobItemGroupDTO.java @@ -0,0 +1,47 @@ +package com.engine.salary.entity.salarysob.dto; + +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * 薪资账套的薪资项目分组 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//薪资项目的薪资醒目分组 +public class SalarySobItemGroupDTO { + + //薪资项目分组id") + @JsonSerialize(using = ToStringSerializer.class) + private Long id; + + //薪资账套id") + @JsonSerialize(using = ToStringSerializer.class) + private Long salarySobId; + + //薪资项目分组名称") + private String name; + + //薪资项目分组排序字段") + private Integer sortedIndex; + + //该分类是否隐藏(0不隐藏,1隐藏) + @JsonSerialize(using = ToStringSerializer.class) + private Long itemHide; + + //薪资项目分组下的薪资项目") + private List items; +} diff --git a/src/com/engine/salary/entity/salarysob/dto/SalarySobItemGroupFormDTO.java b/src/com/engine/salary/entity/salarysob/dto/SalarySobItemGroupFormDTO.java new file mode 100644 index 000000000..179026910 --- /dev/null +++ b/src/com/engine/salary/entity/salarysob/dto/SalarySobItemGroupFormDTO.java @@ -0,0 +1,39 @@ +package com.engine.salary.entity.salarysob.dto; + +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +/** + * 薪资账套薪资项目分组表单 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Accessors(chain = true) +@NoArgsConstructor +@AllArgsConstructor +//薪资账套薪资项目分组表单 +public class SalarySobItemGroupFormDTO { + + //主键id + @JsonSerialize(using = ToStringSerializer.class) + private Long id; + +// @SalaryForm( +// label = "名称", +// labelId = 84756, +// items = { +// @SalaryFormItem(itemType = WeaFormItemType.INPUT, required = true, maxLength = "40") +// } +// ) +// //名称") +// @NotEmpty(message = "名称不允许为空") + private String name; +} diff --git a/src/com/engine/salary/entity/salarysob/dto/SalarySobItemIncomeCategoryDTO.java b/src/com/engine/salary/entity/salarysob/dto/SalarySobItemIncomeCategoryDTO.java new file mode 100644 index 000000000..4827c1222 --- /dev/null +++ b/src/com/engine/salary/entity/salarysob/dto/SalarySobItemIncomeCategoryDTO.java @@ -0,0 +1,33 @@ +package com.engine.salary.entity.salarysob.dto; + +import lombok.Data; +import lombok.experimental.Accessors; + +import java.util.List; + +/** + * 薪资账套下的薪资项目按薪资类型分类 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Accessors(chain = true) +//薪资账套下的薪资项目按薪资类型分类 +public class SalarySobItemIncomeCategoryDTO { + + //薪资类型的id + private Long id; + + //薪资类型的名称 + private String name; + + //薪资账套的薪资项目详情-薪资项目分类 + private List itemGroups; + + //薪资账套的薪资项目详情-薪资项目(未分类) + private List items; + +} diff --git a/src/com/engine/salary/entity/salarysob/dto/SalarySobListDTO.java b/src/com/engine/salary/entity/salarysob/dto/SalarySobListDTO.java new file mode 100644 index 000000000..4d892d643 --- /dev/null +++ b/src/com/engine/salary/entity/salarysob/dto/SalarySobListDTO.java @@ -0,0 +1,73 @@ +package com.engine.salary.entity.salarysob.dto; + +import com.cloudstore.eccom.pc.table.WeaTableType; +import com.engine.salary.annotation.SalaryTable; +import com.engine.salary.annotation.SalaryTableColumn; +import com.engine.salary.annotation.SalaryTableOperate; +import com.engine.salary.annotation.TableTitle; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; +import java.util.Set; + +/** + * 薪资账套列表 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@SalaryTable(pageId = "b4f85287-e3f9-4d11-adn9-7d06e54y6rj8", tableType = WeaTableType.CHECKBOX, operates = { + @SalaryTableOperate(index = "0", text = "编辑"), + @SalaryTableOperate(index = "1", text = "复制"), + @SalaryTableOperate(index = "2", text = "操作日志"), + @SalaryTableOperate(index = "3", text = "关联人员"), + @SalaryTableOperate(index = "4", text = "删除") +}) +public class SalarySobListDTO { + + //主键id + @JsonSerialize(using = ToStringSerializer.class) + @SalaryTableColumn(column = "id", display = false) + private Long id; + + @SalaryTableColumn(text = "账套名称", width = "10%", column = "name") + @TableTitle(title = "账套名称", key = "name", dataIndex = "name") + private String name; + + @SalaryTableColumn(text = "个税扣缴义务人", width = "10%", column = "taxAgentName") + @TableTitle(title = "个税扣缴义务人", key = "taxAgentName", dataIndex = "taxAgentName") + private String taxAgentName; + + // 个税扣缴义务人ID + private List taxAgentIds; + + @SalaryTableColumn(text = "薪资周期", width = "10%", column = "salaryCycle", transmethod = "com.engine.salary.transmethod.TransMethod.buildSalaryCycle", otherPara = "column:salaryCycleFromDay") + @TableTitle(title = "薪资周期", key = "salaryCycle", dataIndex = "salaryCycle") + private String salaryCycle; + + @SalaryTableColumn(text = "薪资周期起始日期", width = "10%", column = "salaryCycleFromDay", display = false) + private String salaryCycleFromDay; + + @SalaryTableColumn(text = "启用", width = "10%", column = "disable") + @TableTitle(title = "启用", key = "disable", dataIndex = "disable") + private Integer disable; + + @SalaryTableColumn(text = "备注", width = "10%", column = "description") + @TableTitle(title = "备注", key = "description", dataIndex = "description") + private String description; + + @SalaryTableColumn(text = "操作", width = "20%", column = "operate") + @TableTitle(title = "操作", key = "operate", dataIndex = "operate") + private Set opts; +} diff --git a/src/com/engine/salary/entity/salarysob/dto/SalarySobRangeImportListDTO.java b/src/com/engine/salary/entity/salarysob/dto/SalarySobRangeImportListDTO.java new file mode 100644 index 000000000..86973e4a4 --- /dev/null +++ b/src/com/engine/salary/entity/salarysob/dto/SalarySobRangeImportListDTO.java @@ -0,0 +1,69 @@ +package com.engine.salary.entity.salarysob.dto; + +import com.cloudstore.eccom.pc.table.WeaTableType; +import com.engine.salary.annotation.SalaryTable; +import com.engine.salary.annotation.SalaryTableColumn; +import com.engine.salary.annotation.SalaryTableOperate; +import com.engine.salary.annotation.TableTitle; +import com.engine.salary.util.excel.ExcelProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author Harryxzy + * @date 2023/01/09 13:42 + * @description 薪资账套-人员范围-导入 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@SalaryTable(pageId = "a4f85287-e3f9-6614-adn9-7d06e54y6rj8", tableType = WeaTableType.CHECKBOX, operates = { + @SalaryTableOperate(text = "查看明细") +}) +public class SalarySobRangeImportListDTO { + + //主键id + @SalaryTableColumn(column = "id", display = false) + private Long id; + + //姓名 + @SalaryTableColumn(text = "姓名", width = "10%", column = "username") + @TableTitle(title = "姓名", dataIndex = "username", key = "username") + @ExcelProperty(index = 0) + private String username; + + + //部门 + @SalaryTableColumn(text = "部门", width = "10%", column = "departmentName") + @TableTitle(title = "部门", dataIndex = "departmentName", key = "departmentName") + @ExcelProperty(index = 1) + private String departmentName; + + //手机号 + @SalaryTableColumn(text = "手机号", width = "10%", column = "mobile") + @TableTitle(title = "手机号", dataIndex = "mobile", key = "mobile") + @ExcelProperty(index = 2) + private String mobile; + + //工号 + @SalaryTableColumn(text = "工号", width = "10%", column = "jobNum") + @TableTitle(title = "工号", dataIndex = "jobNum", key = "jobNum") + @ExcelProperty(index = 3) + private String jobNum; + + //证件号码 + @SalaryTableColumn(text = "证件号码", width = "10%", column = "idNo") + @TableTitle(title = "证件号码", dataIndex = "idNo", key = "idNo") + @ExcelProperty(index = 4) + private String idNo; + + //人员状态 + @SalaryTableColumn(text = "员工状态", width = "10%", column = "employeeStatus") + @TableTitle(title = "员工状态", dataIndex = "employeeStatus", key = "employeeStatus") + @ExcelProperty(index = 5) + private String employeeStatus; + +} diff --git a/src/com/engine/salary/entity/salarysob/dto/SalarySobRangeListDTO.java b/src/com/engine/salary/entity/salarysob/dto/SalarySobRangeListDTO.java new file mode 100644 index 000000000..1d6d234dc --- /dev/null +++ b/src/com/engine/salary/entity/salarysob/dto/SalarySobRangeListDTO.java @@ -0,0 +1,59 @@ +package com.engine.salary.entity.salarysob.dto; + +import com.cloudstore.eccom.pc.table.WeaTableType; +import com.engine.salary.annotation.SalaryTable; +import com.engine.salary.annotation.SalaryTableColumn; +import com.engine.salary.annotation.TableTitle; +import com.engine.salary.enums.salarysob.TargetTypeEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 薪资账套人员范围列表 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@SalaryTable(pageId = "b4f85287-e3f9-4d11-ad90-7d06e54y6rj8", tableType = WeaTableType.CHECKBOX) +public class SalarySobRangeListDTO { + + //主键id + @SalaryTableColumn(column = "id", display = false) + private Long id; + + //薪资账套的id + private Long salarySobId; + + /** + * 对象类型 + * + * @see TargetTypeEnum + */ + private TargetTypeEnum targetType; + + @SalaryTableColumn(text = "对象类型", width = "10%", column = "targetTypeName") + @TableTitle(title = "对象类型", dataIndex = "targetTypeName", key = "targetTypeName") + private String targetTypeName; + + @SalaryTableColumn(text = "对象", width = "10%", column = "targetName") + @TableTitle(title = "对象", dataIndex = "targetName", key = "targetName") + private String targetName; + + //对象 + private Long targetId; + private String target; + + @SalaryTableColumn(text = "员工状态", width = "10%", column = "employeeStatus") + @TableTitle(title = "员工状态", dataIndex = "employeeStatus", key = "employeeStatus") + private String employeeStatus; + + private String status; +} diff --git a/src/com/engine/salary/entity/salarysob/param/ApprovalRequestSaveParam.java b/src/com/engine/salary/entity/salarysob/param/ApprovalRequestSaveParam.java new file mode 100644 index 000000000..e3ef6882d --- /dev/null +++ b/src/com/engine/salary/entity/salarysob/param/ApprovalRequestSaveParam.java @@ -0,0 +1,27 @@ +package com.engine.salary.entity.salarysob.param; + +import com.engine.salary.util.valid.DataCheck; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @ClassName SalaryApprovalQueryParam + * @author Harryxzy + * @date 2024/4/23 15:05 + * @description 薪资审批流程id保存参数 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class ApprovalRequestSaveParam { + + // 流程id + @DataCheck(require = true, message = "流程id不能为空") + private String requestId; + + // 核算记录id + private Long salaryAcctRecordId; +} diff --git a/src/com/engine/salary/entity/salarysob/param/SalaryApprovalQueryParam.java b/src/com/engine/salary/entity/salarysob/param/SalaryApprovalQueryParam.java new file mode 100644 index 000000000..770bb7933 --- /dev/null +++ b/src/com/engine/salary/entity/salarysob/param/SalaryApprovalQueryParam.java @@ -0,0 +1,24 @@ +package com.engine.salary.entity.salarysob.param; + +import com.engine.salary.util.valid.DataCheck; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @ClassName SalaryApprovalQueryParam + * @author Harryxzy + * @date 2024/4/23 15:05 + * @description 薪资审批设置查询参数 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalaryApprovalQueryParam { + + // 薪资账套id + @DataCheck(require = true, message = "薪资账套的ID不允许为空") + private Long salarySobId; +} diff --git a/src/com/engine/salary/entity/salarysob/param/SalarySobAdjustRuleItemQueryParam.java b/src/com/engine/salary/entity/salarysob/param/SalarySobAdjustRuleItemQueryParam.java new file mode 100644 index 000000000..64fabfc59 --- /dev/null +++ b/src/com/engine/salary/entity/salarysob/param/SalarySobAdjustRuleItemQueryParam.java @@ -0,0 +1,33 @@ +package com.engine.salary.entity.salarysob.param; + +import com.engine.salary.util.valid.DataCheck; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; + +/** + * 调薪规则查询薪资项目 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalarySobAdjustRuleItemQueryParam { + + /** + * 薪资账套的ID不允许为空 + */ + @DataCheck(require = true, message = "薪资账套的ID不允许为空") + private Long salarySobId; + + //已经设置了需要排除的账套内的薪资项目副本id + private Collection excludeSalaryItemIds; +} diff --git a/src/com/engine/salary/entity/salarysob/param/SalarySobAdjustRuleQueryParam.java b/src/com/engine/salary/entity/salarysob/param/SalarySobAdjustRuleQueryParam.java new file mode 100644 index 000000000..1b77845cc --- /dev/null +++ b/src/com/engine/salary/entity/salarysob/param/SalarySobAdjustRuleQueryParam.java @@ -0,0 +1,25 @@ +package com.engine.salary.entity.salarysob.param; + +import com.engine.salary.util.valid.DataCheck; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @description: 调薪计薪规则查询参数 + * @author: xiajun + * @modified By: xiajun + * @date: Created in 12/31/21 1:52 PM + * @version:v1.0 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalarySobAdjustRuleQueryParam { + +// //薪资账套的id") + @DataCheck(require = true, message = "薪资账套的ID不允许为空") + private Long salarySobId; +} diff --git a/src/com/engine/salary/entity/salarysob/param/SalarySobAdjustRuleSaveParam.java b/src/com/engine/salary/entity/salarysob/param/SalarySobAdjustRuleSaveParam.java new file mode 100644 index 000000000..58a39981f --- /dev/null +++ b/src/com/engine/salary/entity/salarysob/param/SalarySobAdjustRuleSaveParam.java @@ -0,0 +1,58 @@ +package com.engine.salary.entity.salarysob.param; + +import com.engine.salary.enums.salarysob.SalarySobAdjustRuleTypeEnum; +import com.engine.salary.util.valid.DataCheck; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * @description: 调薪计薪规则保存参数 + * @author: xiajun + * @modified By: xiajun + * @date: Created in 12/31/21 11:03 AM + * @version:v1.0 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalarySobAdjustRuleSaveParam { + + //薪资账套的id + @DataCheck(require = true, message = "薪资账套的ID不允许为空") + private Long salarySobId; + + //规则参数 + private List ruleParams; + + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + public static class RuleParam { + + //薪资项目的id + private Long salaryItemId; + + //生效日期 + private Integer dayOfMonth; + + /** + * 在生效日期之前调薪如何调整 + * + * @see SalarySobAdjustRuleTypeEnum + */ + private Integer beforeAdjustmentType; + + /** + * 在生效日期之后调薪如何调整 + * + * @see SalarySobAdjustRuleTypeEnum + */ + private Integer afterAdjustmentType; + } +} diff --git a/src/com/engine/salary/entity/salarysob/param/SalarySobBackItemSaveParam.java b/src/com/engine/salary/entity/salarysob/param/SalarySobBackItemSaveParam.java new file mode 100644 index 000000000..bfe7f5057 --- /dev/null +++ b/src/com/engine/salary/entity/salarysob/param/SalarySobBackItemSaveParam.java @@ -0,0 +1,47 @@ +package com.engine.salary.entity.salarysob.param; + +import com.engine.salary.enums.SalaryRoundingModeEnum; +import com.engine.salary.enums.SalaryValueTypeEnum; +import com.engine.salary.enums.salaryitem.SalaryDataTypeEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author Harryxzy + * @date 2022/11/16 15:14 + * @description 薪资项目回算项目保存参数 + */ +@Builder +@Data +@AllArgsConstructor +@NoArgsConstructor +public class SalarySobBackItemSaveParam { + // 主键id + private Long id; + + // 薪资账套id + private Long salarySobId; + + // 薪资项目 + private Long salaryItemId; + + // 字段类型 + private SalaryDataTypeEnum dataType; + + // 舍入规则 + private SalaryRoundingModeEnum roundingMode; + + // 保留小数位 + private Integer pattern; + + // 取值方式 + private SalaryValueTypeEnum valueType; + + // 公式 + private Long formulaId; + + // 备注 + private String description; +} diff --git a/src/com/engine/salary/entity/salarysob/param/SalarySobBasicSaveParam.java b/src/com/engine/salary/entity/salarysob/param/SalarySobBasicSaveParam.java new file mode 100644 index 000000000..f8fcfd5fe --- /dev/null +++ b/src/com/engine/salary/entity/salarysob/param/SalarySobBasicSaveParam.java @@ -0,0 +1,100 @@ +package com.engine.salary.entity.salarysob.param; + +import com.engine.salary.enums.SalaryCycleTypeEnum; +import com.engine.salary.enums.salarysob.IncomeCategoryEnum; +import com.engine.salary.util.valid.DataCheck; +import com.engine.salary.util.valid.RuntimeTypeEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + + +/** + * 薪资账套保存参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalarySobBasicSaveParam { + + //主键id + + @DataCheck(require = true, runtime = RuntimeTypeEnum.UPDATE, message = "id不允许为空") + private Long id; + + //薪资账套的名称 + @DataCheck(require = true, max = 40, message = "名称不允许为空且不能超过40个字符长度") + private String name; + + /** + * 个税扣缴义务人的主键id + */ + private List taxAgentIds; + + /** + * 薪资类型不允许为空 + * + * @see IncomeCategoryEnum + */ + @DataCheck(require = true, message = "薪资类型不允许为空") + private Integer taxableItems; + + /** + * 薪资周期不允许为空 + * + * @see SalaryCycleTypeEnum + */ + @DataCheck(require = true, message = "薪资周期不允许为空") + private Integer salaryCycleType; + + /** + * 薪资周期的起始日期不允许为空 + */ + @DataCheck(require = true, message = "薪资周期的起始日期不允许为空") + private Integer salaryCycleFromDay; + + /** + * 税款所属期不允许为空 + * + * @see SalaryCycleTypeEnum + */ + @DataCheck(require = true, message = "税款所属期不允许为空") + private Integer taxCycleType; + + /** + * 考勤周期不允许为空 + * + * @see SalaryCycleTypeEnum + */ + @DataCheck(require = true, message = "考勤周期不允许为空") + private Integer attendCycleType; + + /** + * 考勤周期起始日期不允许为空 + */ + @DataCheck(require = true, message = "考勤周期起始日期不允许为空") + private Integer attendCycleFromDay; + + /** + * 福利台账月份不允许为空 + * + * @see SalaryCycleTypeEnum + */ + @DataCheck(require = true, message = "福利台账月份不允许为空") + private Integer socialSecurityCycleType; + + /** + * 备注不能超过80个字符 + */ + @DataCheck(max = 80, message = "备注不能超过80个字符") + private String description; +} diff --git a/src/com/engine/salary/entity/salarysob/param/SalarySobCheckRuleQueryParam.java b/src/com/engine/salary/entity/salarysob/param/SalarySobCheckRuleQueryParam.java new file mode 100644 index 000000000..648b5b791 --- /dev/null +++ b/src/com/engine/salary/entity/salarysob/param/SalarySobCheckRuleQueryParam.java @@ -0,0 +1,28 @@ +package com.engine.salary.entity.salarysob.param; + +import com.engine.salary.common.BaseQueryParam; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 薪资账套校验规则查询参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalarySobCheckRuleQueryParam extends BaseQueryParam { + + //薪资账套id") + private Long salarySobId; + + //名称") + private String name; +} diff --git a/src/com/engine/salary/entity/salarysob/param/SalarySobCheckRuleSaveParam.java b/src/com/engine/salary/entity/salarysob/param/SalarySobCheckRuleSaveParam.java new file mode 100644 index 000000000..76095c62b --- /dev/null +++ b/src/com/engine/salary/entity/salarysob/param/SalarySobCheckRuleSaveParam.java @@ -0,0 +1,40 @@ +package com.engine.salary.entity.salarysob.param; + +import com.engine.salary.util.valid.DataCheck; +import com.engine.salary.util.valid.RuntimeTypeEnum; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * @description: 薪资账套的校验规则保存参数 + * @author: xiajun + * @modified By: xiajun + * @date: Created in 1/20/22 10:31 AM + * @version:v1.0 + */ +@Data +@Accessors(chain = true) +public class SalarySobCheckRuleSaveParam { + + //主键id") + @DataCheck(require = true,runtime = RuntimeTypeEnum.UPDATE,message = "ID不允许为空") + private Long id; + + + //薪资账套id + @DataCheck(require = true, message = "薪资账套的ID不允许为空") + private Long salarySobId; + + //规则名称 + @DataCheck(require = true,max = 40, message = "名称不允许为空且最大字符不超过40") + private String name; + + + //公式id + @DataCheck(require = true, message = "校验规则公式不允许为空") + private Long formulaId; + + //备注 + @DataCheck(max = 80, message = "备注不能超过80个字符") + private String description; +} diff --git a/src/com/engine/salary/entity/salarysob/param/SalarySobDisableParam.java b/src/com/engine/salary/entity/salarysob/param/SalarySobDisableParam.java new file mode 100644 index 000000000..91e13d7dc --- /dev/null +++ b/src/com/engine/salary/entity/salarysob/param/SalarySobDisableParam.java @@ -0,0 +1,25 @@ +package com.engine.salary.entity.salarysob.param; + +import lombok.Data; + +/** + * 薪资账套禁用或启用保存参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +public class SalarySobDisableParam { + + /** + * 薪资账套的ID不允许为空 + */ + private Long id; + + /** + * 参数错误,只能选择启用或者禁用 + */ + private Integer disable; +} diff --git a/src/com/engine/salary/entity/salarysob/param/SalarySobDuplicateParam.java b/src/com/engine/salary/entity/salarysob/param/SalarySobDuplicateParam.java new file mode 100644 index 000000000..3e5cb8da9 --- /dev/null +++ b/src/com/engine/salary/entity/salarysob/param/SalarySobDuplicateParam.java @@ -0,0 +1,33 @@ +package com.engine.salary.entity.salarysob.param; + +import com.engine.salary.util.valid.DataCheck; +import lombok.Data; + +import java.util.List; + +/** + * 薪资账套复制参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +public class SalarySobDuplicateParam { + + /** + * 薪资账套的ID不允许为空 + */ + @DataCheck(require = true, message = "薪资账套的ID不允许为空") + private Long id; + + /** + * 名称不允许为空 + * 名称不能超过40个字符长度 + */ + @DataCheck(require = true, max = 40, message = "名称不允许为空且名称不能超过40个字符长度") + private String name; + + private List taxAgentIds; +} diff --git a/src/com/engine/salary/entity/salarysob/param/SalarySobItemSaveParam.java b/src/com/engine/salary/entity/salarysob/param/SalarySobItemSaveParam.java new file mode 100644 index 000000000..f0e9c4004 --- /dev/null +++ b/src/com/engine/salary/entity/salarysob/param/SalarySobItemSaveParam.java @@ -0,0 +1,123 @@ +package com.engine.salary.entity.salarysob.param; + +import com.engine.salary.util.valid.DataCheck; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * @description: 薪资账套薪资项目保存参数 + * @author: xiajun + * @modified By: xiajun + * @date: Created in 11/25/21 2:43 PM + * @version:v1.0 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalarySobItemSaveParam { + + //薪资账套id + @DataCheck(require = true, message = "薪资账套的ID不允许为空") + private Long salarySobId; + + //薪资账套薪资项目保存参数-员工信息字段 + @DataCheck(require = true, message = "员工信息字段不能为空") + private List empFields; + + //薪资账套薪资项目保存参数-薪资项目分组") + private List itemGroups; + + //薪资账套薪资项目保存参数-薪资项目(未分类)") + private List items; + + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + //"薪资账套薪资项目保存参数-员工基本信息字段") + public static class SalarySobEmpFieldParam { + + //主键id + private Long id; + + //员工基本信息字段") + private String fieldId; + + //显示顺序") + private Integer sortedIndex; + + private Boolean canDelete; + } + + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + //"薪资账套薪资项目保存参数-薪资项目") + public static class SalarySobItemParam { + + //主键id") + private Long id; + + //薪资项目的id") + private Long salaryItemId; + + //显示顺序") + private Integer sortedIndex; + + //公式") + private Long formulaId; + + //该分类是否隐藏(0不隐藏,1隐藏) + private Long itemHide; + + private Boolean canDelete; + + // 默认值 + private String defaultValue; + + /** + * 进位规则 + */ + private Integer roundingMode; + + /** + * 保留小数位数 + */ + private Integer pattern; + + /** + * 取值方式 + */ + private Integer valueType; + + } + + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + //"薪资账套薪资项目保存参数-薪资项目分类") + public static class SalarySobItemGroupParam { + + //主键id + private Long id; + + //分类名称" + private String name; + + //显示顺序 + private Integer sortedIndex; + + //分类下的薪资项目 + private List items; + + //该分类是否隐藏(0不隐藏,1隐藏) + private Long itemHide; + } +} diff --git a/src/com/engine/salary/entity/salarysob/param/SalarySobListQueryParam.java b/src/com/engine/salary/entity/salarysob/param/SalarySobListQueryParam.java new file mode 100644 index 000000000..e71a6e449 --- /dev/null +++ b/src/com/engine/salary/entity/salarysob/param/SalarySobListQueryParam.java @@ -0,0 +1,24 @@ +package com.engine.salary.entity.salarysob.param; + +import com.engine.salary.common.BaseQueryParam; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 账套查询 + *

Copyright: Copyright (c) 2024

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@EqualsAndHashCode(callSuper = true) +public class SalarySobListQueryParam extends BaseQueryParam { + + //薪资账套名称") + private String name; + + // 薪资账套id + private Long taxAgentId; +} diff --git a/src/com/engine/salary/entity/salarysob/param/SalarySobQueryParam.java b/src/com/engine/salary/entity/salarysob/param/SalarySobQueryParam.java new file mode 100644 index 000000000..d0555321d --- /dev/null +++ b/src/com/engine/salary/entity/salarysob/param/SalarySobQueryParam.java @@ -0,0 +1,31 @@ +package com.engine.salary.entity.salarysob.param; + +import com.engine.salary.common.BaseQueryParam; +import com.engine.salary.enums.auth.AuthFilterTypeEnum; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.List; + + +@Data +@EqualsAndHashCode(callSuper = true) +public class SalarySobQueryParam extends BaseQueryParam { + + /** + * 名称 + */ + private String name; + + /** + * 扣缴义务人id + */ + private Long taxAgentId; + + private List taxAgentIds; + + /** + * 数据过滤级别 + */ + private AuthFilterTypeEnum filterType; +} diff --git a/src/com/engine/salary/entity/salarysob/param/SalarySobRangeEmpQueryParam.java b/src/com/engine/salary/entity/salarysob/param/SalarySobRangeEmpQueryParam.java new file mode 100644 index 000000000..fc202ee92 --- /dev/null +++ b/src/com/engine/salary/entity/salarysob/param/SalarySobRangeEmpQueryParam.java @@ -0,0 +1,32 @@ +package com.engine.salary.entity.salarysob.param; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; + +/** + * @description: 薪资账套人员范围-直接查询 + * @author: xiajun + * @modified By: xiajun + * @date: Created in 12/3/21 1:24 PM + * @version:v1.0 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalarySobRangeEmpQueryParam { + + //对象类型") + private String targetType; + private String target; + + //对象id") + private Collection targetIds; + + //人员状态") + private Collection employeeStatus; +} diff --git a/src/com/engine/salary/entity/salarysob/param/SalarySobRangeExtSaveParam.java b/src/com/engine/salary/entity/salarysob/param/SalarySobRangeExtSaveParam.java new file mode 100644 index 000000000..69aedbb32 --- /dev/null +++ b/src/com/engine/salary/entity/salarysob/param/SalarySobRangeExtSaveParam.java @@ -0,0 +1,42 @@ +package com.engine.salary.entity.salarysob.param; + +import com.engine.salary.util.valid.DataCheck; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * 外部人员管理范围保存参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalarySobRangeExtSaveParam { + + //薪资账套的id + @DataCheck(require = true, message = "薪资账套的ID不允许为空") + private Long salarySobId; + + + /** + * 对象id + */ + private List targetIds; + + /** + * 对象类型。1:外部人员 + */ + private Long targetType; + + + +} diff --git a/src/com/engine/salary/entity/salarysob/param/SalarySobRangeImportParam.java b/src/com/engine/salary/entity/salarysob/param/SalarySobRangeImportParam.java new file mode 100644 index 000000000..aa2d8cc61 --- /dev/null +++ b/src/com/engine/salary/entity/salarysob/param/SalarySobRangeImportParam.java @@ -0,0 +1,25 @@ +package com.engine.salary.entity.salarysob.param; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author Harryxzy + * @date 2023/01/09 13:35 + * @description 薪资账套人员范围导入参数 + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class SalarySobRangeImportParam { + + //上传文件id + String imageId; + + //薪资账套id + String salarySobId; + +} diff --git a/src/com/engine/salary/entity/salarysob/param/SalarySobRangeQueryParam.java b/src/com/engine/salary/entity/salarysob/param/SalarySobRangeQueryParam.java new file mode 100644 index 000000000..41f66ec6b --- /dev/null +++ b/src/com/engine/salary/entity/salarysob/param/SalarySobRangeQueryParam.java @@ -0,0 +1,29 @@ +package com.engine.salary.entity.salarysob.param; + +import com.engine.salary.common.BaseQueryParam; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @description: 薪资账套人员范围查询条件 + * @author: xiajun + * @modified By: xiajun + * @date: Created in 11/22/21 11:10 AM + * @version:v1.0 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//薪资账套人员范围查询条件") +public class SalarySobRangeQueryParam extends BaseQueryParam { + + //@NotNull(message = "LABEL:90405") + //薪资账套的id") + private Long salarySobId; + + //对象名称") + private String targetName; +} diff --git a/src/com/engine/salary/entity/salarysob/param/SalarySobRangeSaveParam.java b/src/com/engine/salary/entity/salarysob/param/SalarySobRangeSaveParam.java new file mode 100644 index 000000000..aadd43306 --- /dev/null +++ b/src/com/engine/salary/entity/salarysob/param/SalarySobRangeSaveParam.java @@ -0,0 +1,75 @@ +package com.engine.salary.entity.salarysob.param; + +import com.engine.hrmelog.annotation.ElogTransform; +import com.engine.salary.enums.salarysob.SalaryEmployeeStatusEnum; +import com.engine.salary.enums.salarysob.TargetTypeEnum; +import com.engine.salary.util.valid.DataCheck; +import com.engine.salary.util.valid.RuntimeTypeEnum; +import com.engine.salary.util.valid.ValidTypeEnum; +import lombok.Data; + +import java.util.List; + +/** + * 薪资账套人员范围保存参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@ElogTransform( name = "薪资账套人员范围" ) +//薪资账套人员范围保存参数") +public class SalarySobRangeSaveParam { + + @DataCheck(require = true, message = "ID不允许为空",runtime = {RuntimeTypeEnum.UPDATE}) + private Long id; + + //薪资账套的id + @DataCheck(require = true, message = "薪资账套的ID不允许为空") + @ElogTransform( name = "薪资账套id" ) + private Long salarySobId; + + //是包含还是排除。0:排除、1:包含") + @DataCheck(require = true, type = ValidTypeEnum.NUMBER, max = 1, min = 0, message = "只能选择 关联人员范围/从范围中排除") + @ElogTransform( name = "关联人员范围/从范围中排除" ) + private Integer includeType; + + //对象 + @DataCheck(require = true, message = "对象不能为空") + @ElogTransform( name = "对象" ) + private List targetParams; + + //员工状态 + @DataCheck(require = true, message = "员工状态不允许为空") + @ElogTransform( name="员工状态" ) + private SalaryEmployeeStatusEnum[] employeeStatus; + + @Data + //薪资账套人员范围保存参数中的对象 + public static class SalarySobRangeTargetParam { + + //对象类型 + @DataCheck(require = true, message = "对象类型不能为空") + @ElogTransform( name="对象类型" ) + private TargetTypeEnum targetType; + + //对象id + @ElogTransform( name="对象id" ) + private Long targetId; + @ElogTransform( name="SQL" ) + + private String target; + + //员工状态 -- 导入使用 +// @DataCheck(require = true, message = "员工状态不允许为空") + private SalaryEmployeeStatusEnum[] employeeStatus; + + // 安全级别最小值 +// private Long minSecLevel; + + // 安全级别最大值 +// private Long maxSecLevel; + } +} diff --git a/src/com/engine/salary/entity/salarysob/param/UpdateCheckRuleFormulaParam.java b/src/com/engine/salary/entity/salarysob/param/UpdateCheckRuleFormulaParam.java new file mode 100644 index 000000000..16ef28ccd --- /dev/null +++ b/src/com/engine/salary/entity/salarysob/param/UpdateCheckRuleFormulaParam.java @@ -0,0 +1,30 @@ +package com.engine.salary.entity.salarysob.param; + +import com.engine.salary.util.valid.DataCheck; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @description: 更新校验规则的公式校验规则更新参数 + * @author: xiajun + * @modified By: xiajun + * @date: Created in 12/8/21 10:35 AM + * @version:v1.0 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class UpdateCheckRuleFormulaParam { + + + //校验规则的id + @DataCheck(require = true,message = "校验规则ID不能为空") + private Long id; + + //校验规则的公式id + @DataCheck(require = true,message = "校验规则公式能为空") + private Long formulaId; +} diff --git a/src/com/engine/salary/entity/salarysob/po/SalaryApprovalRulePO.java b/src/com/engine/salary/entity/salarysob/po/SalaryApprovalRulePO.java new file mode 100644 index 000000000..8683696a4 --- /dev/null +++ b/src/com/engine/salary/entity/salarysob/po/SalaryApprovalRulePO.java @@ -0,0 +1,70 @@ +package com.engine.salary.entity.salarysob.po; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.Date; + +/** + * @author Harryxzy + * @ClassName SalaryApprovalRulePO + * @date 2024/04/23 17:31 + * @description 薪资核算审批规则 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalaryApprovalRulePO { + /** + * 主键id + */ + private Long id; + + /** + * 薪资账套id + */ + private Long salarySobId; + + /** + * 是否开启工资单审批 + */ + private Integer openApproval; + + /** + * 审批薪资项目设置 + */ + private String approvalGroupSetting; + + /** + * 审批流程地址 + */ + private String workflowUrl; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 创建人id + */ + private Long creator; + + private Integer deleteType; + + /** + * 修改时间 + */ + private Date updateTime; + + //主键id集合 + private Collection ids; + + //薪资账套id集合 + private Collection salarySobIds; + +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/salarysob/po/SalarySobAdjustRulePO.java b/src/com/engine/salary/entity/salarysob/po/SalarySobAdjustRulePO.java new file mode 100644 index 000000000..ad793ed46 --- /dev/null +++ b/src/com/engine/salary/entity/salarysob/po/SalarySobAdjustRulePO.java @@ -0,0 +1,114 @@ +package com.engine.salary.entity.salarysob.po; + +import com.engine.salary.enums.salarysob.SalarySobAdjustRuleTypeEnum; +import com.thoughtworks.xstream.annotations.XStreamAlias; +import com.thoughtworks.xstream.annotations.XStreamAsAttribute; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.util.Collection; +import java.util.Date; + +/** + * 调薪计薪规则 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Accessors(chain = true) +@NoArgsConstructor +@AllArgsConstructor +@Builder +//hrsa_salary_sob_adjust_rule +@XStreamAlias("SalarySobAdjustRule") +public class SalarySobAdjustRulePO { + + /** + * 主键id + */ + @XStreamAlias("id") + @XStreamAsAttribute + private Long id; + + /** + * 薪资账套id + */ + @XStreamAlias("salarySobId") + @XStreamAsAttribute + private Long salarySobId; + + /** + * 薪资项目id + */ + @XStreamAlias("salaryItemId") + @XStreamAsAttribute + private Long salaryItemId; + + /** + * 生效日期 + */ + @XStreamAlias("dayOfMonth") + @XStreamAsAttribute + private Integer dayOfMonth; + + /** + * 在生效日期之前调薪如何调整 + * + * @see SalarySobAdjustRuleTypeEnum + */ + @XStreamAlias("beforeAdjustmentType") + @XStreamAsAttribute + private Integer beforeAdjustmentType; + + /** + * 在生效日期之后调薪如何调整 + * + * @see SalarySobAdjustRuleTypeEnum + */ + @XStreamAlias("afterAdjustmentType") + @XStreamAsAttribute + private Integer afterAdjustmentType; + + /** + * 租户key + */ + @XStreamAlias("tenantKey") + @XStreamAsAttribute + private String tenantKey; + + /** + * 创建人id + */ + @XStreamAlias("creator") + @XStreamAsAttribute + private Long creator; + + /** + * 是否删除 + */ + @XStreamAlias("deleteType") + @XStreamAsAttribute + private Integer deleteType; + + /** + * 创建时间 + */ + @XStreamAlias("createTime") + @XStreamAsAttribute + private Date createTime; + + /** + * 更新时间 + */ + @XStreamAlias("updateTime") + @XStreamAsAttribute + private Date updateTime; + + Collection ids; +} diff --git a/src/com/engine/salary/entity/salarysob/po/SalarySobBackItemPO.java b/src/com/engine/salary/entity/salarysob/po/SalarySobBackItemPO.java new file mode 100644 index 000000000..d5c91dddf --- /dev/null +++ b/src/com/engine/salary/entity/salarysob/po/SalarySobBackItemPO.java @@ -0,0 +1,197 @@ +package com.engine.salary.entity.salarysob.po; + +import com.engine.salary.entity.salaryformula.po.FormulaPO; +import com.engine.salary.entity.salaryitem.po.SalaryItemPO; +import com.engine.salary.enums.SalaryRoundingModeEnum; +import com.engine.salary.enums.SalaryValueTypeEnum; +import com.engine.salary.enums.salaryitem.SalaryDataTypeEnum; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.thoughtworks.xstream.annotations.XStreamAlias; +import com.thoughtworks.xstream.annotations.XStreamAsAttribute; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.apache.commons.collections4.CollectionUtils; + +import java.util.Collection; +import java.util.Comparator; +import java.util.Date; +import java.util.List; +import java.util.stream.Collectors; + +/** + * @author Harryxzy + * @date 2022/11/15 16:06 + * @description 薪资账套回算薪资项目 + * //hrsa_salary_sob_back_item") + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@XStreamAlias("SalarySobBackItem") +public class SalarySobBackItemPO{ + + /** + * 主键id + */ + @XStreamAlias("id") + @XStreamAsAttribute + private Long id; + + /** + * 薪资账套id + */ + @XStreamAlias("salarySobId") + @XStreamAsAttribute + private Long salarySobId; + + /** + * 薪资项目id + */ + @XStreamAlias("salaryItemId") + @XStreamAsAttribute + private Long salaryItemId; + + /** + * 薪资项目code + */ + @XStreamAlias("salaryItemCode") + @XStreamAsAttribute + private String salaryItemCode; + + /** + * 字段类型 + * + * @see SalaryDataTypeEnum + */ + @XStreamAlias("dataType") + @XStreamAsAttribute + private String dataType; + + /** + * 进位规则 + * + * @see SalaryRoundingModeEnum + */ + @XStreamAlias("roundingMode") + @XStreamAsAttribute + private Integer roundingMode; + + /** + * 保留的小数位数 + */ + @XStreamAlias("pattern") + @XStreamAsAttribute + private Integer pattern; + + /** + * 取值方式 + * + * @see SalaryValueTypeEnum + */ + @XStreamAlias("valueType") + @XStreamAsAttribute + private Integer valueType; + + /** + * 公式id + */ + @XStreamAlias("formulaId") + @XStreamAsAttribute + private Long formulaId; + + /** + * 0:已发项目、1:补发薪资项目 + */ + @XStreamAlias("backCalcType") + @XStreamAsAttribute + private Integer backCalcType; + + /** + * 默认值 + */ + @XStreamAlias("defaultValue") + @XStreamAsAttribute + private String defaultValue; + + /** + * 租户key + */ + @XStreamAlias("tenantKey") + @XStreamAsAttribute + @JsonIgnore + private String tenantKey; + + /** + * 创建人id + */ + @XStreamAlias("creator") + @XStreamAsAttribute + @JsonIgnore + private Long creator; + + /** + * 是否删除 + */ + @XStreamAlias("deleteType") + @XStreamAsAttribute + @JsonIgnore + private Integer deleteType; + + /** + * 创建时间 + */ + @XStreamAlias("createTime") + @XStreamAsAttribute + @JsonIgnore + private Date createTime; + + /** + * 更新时间 + */ + @XStreamAlias("updateTime") + @XStreamAsAttribute + @JsonIgnore + private Date updateTime; + + + + @XStreamAlias("SalaryItem") + private SalaryItemPO salaryItem; + + @XStreamAlias("Formula") + FormulaPO formula; + + + /** + * 薪资项目id + */ + private Collection salaryItemIds; + + public String toCompareString() { + return "SalarySobBackItemPO{" + + "salarySobId=" + salarySobId + + ", salaryItemId=" + salaryItemId + + ", salaryItemCode='" + salaryItemCode + '\'' + + ", dataType='" + dataType + '\'' + + ", roundingMode=" + roundingMode + + ", pattern=" + pattern + + ", valueType=" + valueType + + ", formulaId=" + formulaId + + ", backCalcType=" + backCalcType + + ", defaultValue=" + defaultValue + + '}'; + } + + public static String toCompareString(List salarySobBackItems) { + if (CollectionUtils.isEmpty(salarySobBackItems)) { + return ""; + } + return salarySobBackItems.stream() + .sorted(Comparator.comparingLong(SalarySobBackItemPO::getSalaryItemId)) + .map(SalarySobBackItemPO::toCompareString) + .collect(Collectors.joining(",")); + } +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/salarysob/po/SalarySobCheckRulePO.java b/src/com/engine/salary/entity/salarysob/po/SalarySobCheckRulePO.java new file mode 100644 index 000000000..857b82895 --- /dev/null +++ b/src/com/engine/salary/entity/salarysob/po/SalarySobCheckRulePO.java @@ -0,0 +1,77 @@ +package com.engine.salary.entity.salarysob.po; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.Date; + +/** + * 薪资账套校验规则 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//hrsa_salary_sob_check_rule") +public class SalarySobCheckRulePO { + + /** + * 主键id + */ + private Long id; + + /** + * 薪资账套id + */ + private Long salarySobId; + + /** + * 名称 + */ + private String name; + + /** + * 校验规则 + */ + private Long formulaId; + + /** + * 备注 + */ + private String description; + + /** + * 租户key + */ + private String tenantKey; + + /** + * 创建人id + */ + private Long creator; + + /** + * 是否删除 + */ + private Integer deleteType; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 更新时间 + */ + private Date updateTime; + + Collection ids; +} diff --git a/src/com/engine/salary/entity/salarysob/po/SalarySobDefaultBackItemPO.java b/src/com/engine/salary/entity/salarysob/po/SalarySobDefaultBackItemPO.java new file mode 100644 index 000000000..f86a64a35 --- /dev/null +++ b/src/com/engine/salary/entity/salarysob/po/SalarySobDefaultBackItemPO.java @@ -0,0 +1,67 @@ +package com.engine.salary.entity.salarysob.po; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.time.LocalDateTime; + +/** + * @author Harryxzy + * @date 2022/11/15 17:45 + * @description + */ + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalarySobDefaultBackItemPO { + + /** + * 主键id + */ + private Long id; + + /** + * 系统薪资项目id + */ + private Long sysSalaryItemId; + + /** + * 公式id + */ + private Long formulaId; + + /** + * 回算类型 + */ + private Integer backCalcType; + + /** + * 租户key + */ + private String tenantKey; + + /** + * 创建人id + */ + private Long creator; + + /** + * 是否删除 + */ + private Integer deleteType; + + /** + * 创建时间 + */ + private LocalDateTime createTime; + + /** + * 更新时间 + */ + private LocalDateTime updateTime; + +} diff --git a/src/com/engine/salary/entity/salarysob/po/SalarySobDefaultEmpFieldPO.java b/src/com/engine/salary/entity/salarysob/po/SalarySobDefaultEmpFieldPO.java new file mode 100644 index 000000000..af7faeb77 --- /dev/null +++ b/src/com/engine/salary/entity/salarysob/po/SalarySobDefaultEmpFieldPO.java @@ -0,0 +1,72 @@ +package com.engine.salary.entity.salarysob.po; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.util.Collection; +import java.util.Date; + +/** + * 薪资账套默认的员工信息字段 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Accessors(chain = true) +@NoArgsConstructor +@AllArgsConstructor +//hrsa_sob_default_emp_field") +public class SalarySobDefaultEmpFieldPO { + + /** + * 主键id + */ + private Long id; + + /** + * 字段code + */ + private String fieldCode; + + /** + * 排序字段 + */ + private Integer sortedIndex; + + /** + * 是否可以删除 + */ + private Integer canDelete; + + /** + * 租户key + */ + private String tenantKey; + + /** + * 创建人id + */ + private Long creator; + + /** + * 是否删除 + */ + private Integer deleteType; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 更新时间 + */ + private Date updateTime; + + Collection ids; +} diff --git a/src/com/engine/salary/entity/salarysob/po/SalarySobDefaultItemGroupPO.java b/src/com/engine/salary/entity/salarysob/po/SalarySobDefaultItemGroupPO.java new file mode 100644 index 000000000..bca70753e --- /dev/null +++ b/src/com/engine/salary/entity/salarysob/po/SalarySobDefaultItemGroupPO.java @@ -0,0 +1,79 @@ +package com.engine.salary.entity.salarysob.po; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.util.Collection; +import java.util.Date; + +/** + * 薪资账套默认的薪资项目分组 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@Accessors(chain = true) +@NoArgsConstructor +@AllArgsConstructor +//hrsa_sob_default_item_group +public class SalarySobDefaultItemGroupPO { + + /** + * 主键id + */ + private Long id; + + /** + * 薪资类型 + */ + private Integer incomeCategory; + + /** + * 名称 + */ + private String name; + + /** + * 显示顺序 + */ + private Integer sortedIndex; + + /** + * 备注 + */ + private String description; + + /** + * 租户key + */ + private String tenantKey; + + /** + * 创建人id + */ + private Long creator; + + /** + * 是否删除 + */ + private Integer deleteType; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 更新时间 + */ + private Date updateTime; + + Collection ids; +} diff --git a/src/com/engine/salary/entity/salarysob/po/SalarySobDefaultItemPO.java b/src/com/engine/salary/entity/salarysob/po/SalarySobDefaultItemPO.java new file mode 100644 index 000000000..41a7958e3 --- /dev/null +++ b/src/com/engine/salary/entity/salarysob/po/SalarySobDefaultItemPO.java @@ -0,0 +1,94 @@ +package com.engine.salary.entity.salarysob.po; + +import com.engine.salary.enums.salarysob.IncomeCategoryEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.Date; + +/** + * 薪资账套默认包含的薪资项目 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//hrsa_salary_sob_default_item +public class SalarySobDefaultItemPO { + + /** + * 主键id + */ + private Long id; + + /** + * 薪资类型 + * + * @see IncomeCategoryEnum + */ + private Integer incomeCategory; + + /** + * 系统默认的薪资项目id + */ + private Long sysSalaryItemId; + + + + /** + * 薪资账套默认的薪资项目分类id + */ + private Long sobDefaultItemGroupId; + + /** + * 显示顺序 + */ + private Integer sortedIndex; + + + + /** + * 能否编辑 + */ + private Integer canEdit; + + /** + * 能否删除 + */ + private Integer canDelete; + + /** + * 租户key + */ + private String tenantKey; + + /** + * 创建人id + */ + private Long creator; + + /** + * 是否删除 + */ + private Integer deleteType; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 更新时间 + */ + private Date updateTime; + + Collection ids; +} diff --git a/src/com/engine/salary/entity/salarysob/po/SalarySobEmpFieldPO.java b/src/com/engine/salary/entity/salarysob/po/SalarySobEmpFieldPO.java new file mode 100644 index 000000000..e92f33bf1 --- /dev/null +++ b/src/com/engine/salary/entity/salarysob/po/SalarySobEmpFieldPO.java @@ -0,0 +1,125 @@ +package com.engine.salary.entity.salarysob.po; + +import com.thoughtworks.xstream.annotations.XStreamAlias; +import com.thoughtworks.xstream.annotations.XStreamAsAttribute; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; +import org.apache.commons.collections4.CollectionUtils; + +import java.util.Collection; +import java.util.Comparator; +import java.util.Date; +import java.util.List; +import java.util.stream.Collectors; + +/** + * 薪资账套-薪资项目-员工基本信息 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@Accessors(chain = true) +@NoArgsConstructor +@AllArgsConstructor +//hrsa_salary_sob_emp_field +@XStreamAlias("SalarySobEmpField") +public class SalarySobEmpFieldPO { + + /** + * 主键id + */ + @XStreamAlias("id") + @XStreamAsAttribute + private Long id; + + /** + * 薪资账套id + */ + @XStreamAlias("salarySobId") + @XStreamAsAttribute + private Long salarySobId; + + /** + * 字段code + */ + @XStreamAlias("fieldCode") + @XStreamAsAttribute + private String fieldCode; + + /** + * 排序字段 + */ + @XStreamAlias("sortedIndex") + @XStreamAsAttribute + private Integer sortedIndex; + + /** + * 是否可以删除 + */ + @XStreamAlias("canDelete") + @XStreamAsAttribute + private Integer canDelete; + + /** + * 租户key + */ + @XStreamAlias("tenantKey") + @XStreamAsAttribute + private String tenantKey; + + /** + * 创建人id + */ + @XStreamAlias("creator") + @XStreamAsAttribute + private Long creator; + + /** + * 是否删除 + */ + @XStreamAlias("deleteType") + @XStreamAsAttribute + private Integer deleteType; + + /** + * 创建时间 + */ + @XStreamAlias("createTime") + @XStreamAsAttribute + private Date createTime; + + /** + * 更新时间 + */ + @XStreamAlias("updateTime") + @XStreamAsAttribute + private Date updateTime; + + Collection ids; + + public String toCompareString() { + return "SalarySobEmpFieldPO{" + + "salarySobId=" + salarySobId + + ", fieldCode='" + fieldCode + '\'' + + ", sortedIndex=" + sortedIndex + + ", canDelete=" + canDelete + + '}'; + } + + public static String toCompareString(List salarySobEmpFields) { + if (CollectionUtils.isEmpty(salarySobEmpFields)) { + return ""; + } + return salarySobEmpFields.stream() + .sorted(Comparator.comparingInt(SalarySobEmpFieldPO::getSortedIndex)) + .map(SalarySobEmpFieldPO::toCompareString) + .collect(Collectors.joining(",")); + } +} diff --git a/src/com/engine/salary/entity/salarysob/po/SalarySobExtRangePO.java b/src/com/engine/salary/entity/salarysob/po/SalarySobExtRangePO.java new file mode 100644 index 000000000..1e2c82838 --- /dev/null +++ b/src/com/engine/salary/entity/salarysob/po/SalarySobExtRangePO.java @@ -0,0 +1,65 @@ +package com.engine.salary.entity; + +import com.engine.salary.annotation.TableTitle; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.Date; + +/** + * 个税扣缴义务人的管理范围表 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalarySobExtRangePO { + + /** + * 主键id + */ + private Long id; + /** + * 账套id + */ + private Long salarySobId; + /** + * 对象id + */ + private Long targetId; + /** + * 对象类型。1:外部人员 + */ + private Integer targetType; + /** + * 租户ID + */ + private String tenantKey; + /** + * 更新时间 + */ + private Date updateTime; + + /** + * 创建时间 + */ + private Date createTime; + /** + * 创建人 + */ + private Long creator; + /** + * 是否已删除。0:未删除、1:已删除 + */ + private Integer deleteType; + + //主键id集合 + private Collection ids; + + @TableTitle(title = "名称", dataIndex = "targetName", key = "targetName") + private String targetName; + +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/salarysob/po/SalarySobItemGroupPO.java b/src/com/engine/salary/entity/salarysob/po/SalarySobItemGroupPO.java new file mode 100644 index 000000000..258f0f67f --- /dev/null +++ b/src/com/engine/salary/entity/salarysob/po/SalarySobItemGroupPO.java @@ -0,0 +1,133 @@ +package com.engine.salary.entity.salarysob.po; + +import com.thoughtworks.xstream.annotations.XStreamAlias; +import com.thoughtworks.xstream.annotations.XStreamAsAttribute; +import com.thoughtworks.xstream.annotations.XStreamImplicit; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.apache.commons.collections4.CollectionUtils; + +import java.util.Collection; +import java.util.Comparator; +import java.util.Date; +import java.util.List; +import java.util.stream.Collectors; + +/** + * 薪资账套薪资项目分组 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//hrsa_salary_sob_item_group +@XStreamAlias("SalarySobItemGroup") +public class SalarySobItemGroupPO { + + /** + * 主键id + */ + @XStreamAlias("id") + @XStreamAsAttribute + private Long id; + + /** + * 薪资账套的id + */ + @XStreamAlias("salarySobId") + @XStreamAsAttribute + private Long salarySobId; + + /** + * 薪资账套中薪资项目分组的名称 + */ + @XStreamAlias("name") + @XStreamAsAttribute + private String name; + + /** + * 排序字段 + */ + @XStreamAlias("sortedIndex") + @XStreamAsAttribute + private Integer sortedIndex; + + /** + * 备注 + */ + @XStreamAlias("description") + @XStreamAsAttribute + private String description; + + + //该分类是否隐藏(0不隐藏,1隐藏) + @XStreamAlias("itemHide") + @XStreamAsAttribute + private Long itemHide; + + /** + * 租户key + */ + @XStreamAlias("tenantKey") + @XStreamAsAttribute + private String tenantKey; + + /** + * 创建人id + */ + @XStreamAlias("creator") + @XStreamAsAttribute + private Long creator; + + /** + * 是否删除 + */ + @XStreamAlias("deleteType") + @XStreamAsAttribute + private Integer deleteType; + + /** + * 创建时间 + */ + @XStreamAlias("createTime") + @XStreamAsAttribute + private Date createTime; + + /** + * 更新时间 + */ + @XStreamAlias("updateTime") + @XStreamAsAttribute + private Date updateTime; + + @XStreamImplicit + private List salarySobItems; + + + Collection ids; + + public String toCompareString() { + return "SalarySobItemGroupPO{" + + "name='" + name + '\'' + + ", sortedIndex=" + sortedIndex + + ", itemHide=" + itemHide + + '}'; + } + + public static String toCompareString(List salarySobItemGroups) { + if (CollectionUtils.isEmpty(salarySobItemGroups)) { + return ""; + } + return salarySobItemGroups.stream() + .sorted(Comparator.comparing(SalarySobItemGroupPO::getSortedIndex)) + .map(SalarySobItemGroupPO::toCompareString) + .collect(Collectors.joining(",")); + } +} diff --git a/src/com/engine/salary/entity/salarysob/po/SalarySobItemHidePO.java b/src/com/engine/salary/entity/salarysob/po/SalarySobItemHidePO.java new file mode 100644 index 000000000..8ceb1db26 --- /dev/null +++ b/src/com/engine/salary/entity/salarysob/po/SalarySobItemHidePO.java @@ -0,0 +1,71 @@ +package com.engine.salary.entity.salarysob.po; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; + +/** + * @Description hrsa_salary_item_hide 薪资项目是否在薪资核算中展示 + * @author Harryxzy + * @date 2022/8/22 18:00 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalarySobItemHidePO { + + /** + * ID + */ + private Long id; + + /** + * 账套ID + */ + private Long salarySobId; + + /** + * 薪资项目ID + */ + private Long salaryItemId; + + /** + * 类型(是否是项目组 0-不是 1-是) + */ + private Integer isGroup; + + /** + * 是否隐藏(0-不隐藏 1-隐藏) + */ + private Long itemHide; + + /** + * 创建人 + */ + private Long creator; + + /** + * 是否删除 + */ + private Integer deleteType; + + /** + * 租户 + */ + private String tenantKey; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 更新时间 + */ + private Date updateTime; + +} diff --git a/src/com/engine/salary/entity/salarysob/po/SalarySobItemPO.java b/src/com/engine/salary/entity/salarysob/po/SalarySobItemPO.java new file mode 100644 index 000000000..011f992c4 --- /dev/null +++ b/src/com/engine/salary/entity/salarysob/po/SalarySobItemPO.java @@ -0,0 +1,211 @@ +package com.engine.salary.entity.salarysob.po; + +import com.engine.hrmelog.annotation.ElogTransform; +import com.engine.salary.entity.salaryformula.po.FormulaPO; +import com.engine.salary.entity.salaryitem.po.SalaryItemPO; +import com.engine.salary.enums.SalaryRoundingModeEnum; +import com.engine.salary.enums.SalaryValueTypeEnum; +import com.thoughtworks.xstream.annotations.XStreamAlias; +import com.thoughtworks.xstream.annotations.XStreamAsAttribute; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.apache.commons.collections4.CollectionUtils; + +import java.util.Collection; +import java.util.Comparator; +import java.util.Date; +import java.util.List; +import java.util.stream.Collectors; + +/** + * 薪资账套薪资项目 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//hrsa_salary_sob_item +@ElogTransform( name="薪资账套薪资项目" ) +@XStreamAlias("SalarySobItem") +public class SalarySobItemPO { + + /** + * 主键id + */ + @XStreamAlias("id") + @XStreamAsAttribute + private Long id; + + /** + * 薪资账套的id + */ + @XStreamAlias("salarySobId") + @XStreamAsAttribute + private Long salarySobId; + + /** + * 薪资项目的id + */ + @XStreamAlias("salaryItemId") + @XStreamAsAttribute + private Long salaryItemId; + + /** + * 薪资账套薪资项目分组id + */ + @XStreamAlias("salarySobItemGroupId") + @XStreamAsAttribute + private Long salarySobItemGroupId; + + /** + * 公式 + */ + @XStreamAlias("formulaId") + @XStreamAsAttribute + private Long formulaId; + + /** + * 排序字段 + */ + @XStreamAlias("sortedIndex") + @XStreamAsAttribute + private Integer sortedIndex; + + /** + * 备注 + */ + @XStreamAlias("description") + @XStreamAsAttribute + private String description; + + + /** + * 进位规则 + * + * @see SalaryRoundingModeEnum + */ + @XStreamAlias("roundingMode") + @XStreamAsAttribute + private Integer roundingMode; + + /** + * 保留的小数位数 + */ + @XStreamAlias("pattern") + @XStreamAsAttribute + private Integer pattern; + + /** + * 取值方式 + * + * @see SalaryValueTypeEnum + */ + @XStreamAlias("valueType") + @XStreamAsAttribute + private Integer valueType; + + + //该分类是否隐藏(0不隐藏,1隐藏) + @XStreamAlias("itemHide") + @XStreamAsAttribute + private Long itemHide; + + /** + * 默认值 + */ + @XStreamAlias("defaultValue") + @XStreamAsAttribute + private String defaultValue; + + /** + * 是否可以删除。0:不可删除、1:可以删除 + */ + @XStreamAlias("canDelete") + @XStreamAsAttribute + private Integer canDelete; + + /** + * 租户key + */ + @XStreamAlias("tenantKey") + @XStreamAsAttribute + private String tenantKey; + + /** + * 创建人id + */ + @XStreamAlias("creator") + @XStreamAsAttribute + private Long creator; + + /** + * 是否删除 + */ + @XStreamAlias("deleteType") + @XStreamAsAttribute + private Integer deleteType; + + /** + * 创建时间 + */ + @XStreamAlias("createTime") + @XStreamAsAttribute + private Date createTime; + + /** + * 更新时间 + */ + @XStreamAlias("updateTime") + @XStreamAsAttribute + private Date updateTime; + + @XStreamAlias("SalaryItem") + private SalaryItemPO salaryItem; + + @XStreamAlias("Formula") + private FormulaPO formula; + + //in + Collection ids; + Collection salarySobIds; + + + Collection salaryItemIds; + + Collection notInSalaryItemIds; + + + public String toCompareString() { + return "SalarySobItemPO{" + + "salarySobId=" + salarySobId + + ", salaryItemId=" + salaryItemId + + ", salarySobItemGroupId=" + salarySobItemGroupId + + ", formulaId=" + formulaId + + ", sortedIndex=" + sortedIndex + + ", canDelete=" + canDelete + + ", roundingMode=" + roundingMode + + ", pattern=" + pattern + + ", valueType=" + valueType + + ", itemHide=" + itemHide + + ", defaultValue=" + defaultValue + + '}'; + } + + public static String toCompareString(List salarySobItems) { + if (CollectionUtils.isEmpty(salarySobItems)) { + return ""; + } + return salarySobItems.stream() + .sorted(Comparator.comparingLong(SalarySobItemPO::getSalaryItemId)) + .map(SalarySobItemPO::toCompareString) + .collect(Collectors.joining(",")); + } + +} diff --git a/src/com/engine/salary/entity/salarysob/po/SalarySobPO.java b/src/com/engine/salary/entity/salarysob/po/SalarySobPO.java new file mode 100644 index 000000000..a24fd7b06 --- /dev/null +++ b/src/com/engine/salary/entity/salarysob/po/SalarySobPO.java @@ -0,0 +1,188 @@ +package com.engine.salary.entity.salarysob.po; + +import com.engine.hrmelog.annotation.ElogTransform; +import com.engine.salary.annotation.Auth; +import com.engine.salary.enums.auth.AuthCheckTypeEnum; +import com.engine.salary.util.valid.Compare; +import com.thoughtworks.xstream.annotations.XStreamAlias; +import com.thoughtworks.xstream.annotations.XStreamAsAttribute; +import com.thoughtworks.xstream.annotations.XStreamOmitField; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.util.Collection; +import java.util.Date; +import java.util.List; +import java.util.Set; + +/** + * 薪资帐套表 + */ +@Data +@Builder +@Accessors(chain = true) +@NoArgsConstructor +@AllArgsConstructor +@ElogTransform( name="薪资账套" ) +//hrsa_salary_sob +@XStreamAlias("SalarySob") +@Auth(page = "salarySob",checkType = AuthCheckTypeEnum.SOB,sobIdField="id") +public class SalarySobPO { + + /** + * 主键id + */ + @ElogTransform( name="主键" ) + @Compare + @XStreamOmitField + private Long id; + + /** + * 名称 + */ + @ElogTransform( name="名称" ) + @Compare + @XStreamAlias("name") + @XStreamAsAttribute + private String name; + + /** + * 个税扣缴义务人的主键id + */ + @ElogTransform( name="个税扣缴义务人id" ) + @XStreamAlias("taxAgentId") + @XStreamAsAttribute + @Deprecated + private Long taxAgentId; + + @XStreamOmitField + List taxAgentIds; + + /** + * 应税项目。1:正常工资薪金所得 + */ + @ElogTransform( name="薪资类型" ) + @Compare + @XStreamAlias("incomeCategory") + @XStreamAsAttribute + private Integer incomeCategory; + + /** + * 薪资周期。1:上上月、2:上月、3:本月、4:下月 + */ + @ElogTransform( name="薪资周期" ) + @Compare + @XStreamAlias("salaryCycleType") + @XStreamAsAttribute + private Integer salaryCycleType; + + /** + * 薪资周期的起始日期 + */ + @ElogTransform( name="薪资周期起始日期" ) + @Compare + @XStreamAlias("salaryCycleFromDay") + @XStreamAsAttribute + private Integer salaryCycleFromDay; + + /** + * 税款所属期。1:上上月、2:上月、3:本月、4:下月 + */ + @ElogTransform( name="税款所属期" ) + @Compare + @XStreamAlias("taxCycleType") + @XStreamAsAttribute + private Integer taxCycleType; + + /** + * 考勤周期。1:上上月、2:上月、3:本月、4:下月 + */ + @ElogTransform( name="考勤周期" ) + @Compare + @XStreamAlias("attendCycleType") + @XStreamAsAttribute + private Integer attendCycleType; + + /** + * 考勤周期的起始日期 + */ + @ElogTransform( name="考勤周期起始日期" ) + @Compare + @XStreamAlias("attendCycleFromDay") + @XStreamAsAttribute + private Integer attendCycleFromDay; + + /** + * 社保福利所属期。1:上上月、2:上月、3:本月、4:下月 + */ + @ElogTransform( name="社保福利所属期" ) + @Compare + @XStreamAlias("socialSecurityCycleType") + @XStreamAsAttribute + private Integer socialSecurityCycleType; + + /** + * 是否禁用。0:正常使用、1:禁用 + */ + @ElogTransform( name="是否禁用" ) + @XStreamAlias("disable") + @XStreamAsAttribute + private Integer disable; + + /** + * 描述 + */ + @ElogTransform( name="描述" ) + @XStreamAlias("description") + @XStreamAsAttribute + private String description; + + /** + * 创建人 + */ + @ElogTransform( name="创建人" ) + @XStreamAlias("creator") + @XStreamAsAttribute + private Long creator; + + /** + * 创建时间 + */ + @ElogTransform( name="创建时间" ) + @XStreamAlias("createTime") + @XStreamAsAttribute + private Date createTime; + + /** + * 更新时间 + */ + @ElogTransform( name="更新时间" ) + @XStreamAlias("updateTime") + @XStreamAsAttribute + private Date updateTime; + + /** + * 是否已删除。0:未删除、1:已删除 + */ + @ElogTransform( name="是否已删除" ) + @XStreamAlias("deleteType") + @XStreamAsAttribute + private Integer deleteType; + + /** + * 租户ID + */ + @ElogTransform( name="租户" ) + @XStreamAlias("tenantKey") + @XStreamAsAttribute + private String tenantKey; + + Collection ids; + + + private Set opts; + +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/salarysob/po/SalarySobRangePO.java b/src/com/engine/salary/entity/salarysob/po/SalarySobRangePO.java new file mode 100644 index 000000000..4ace5f3bd --- /dev/null +++ b/src/com/engine/salary/entity/salarysob/po/SalarySobRangePO.java @@ -0,0 +1,111 @@ +package com.engine.salary.entity.salarysob.po; + +import com.engine.hrmelog.annotation.ElogTransform; +import com.engine.salary.enums.salarysob.SalaryEmployeeStatusEnum; +import com.engine.salary.enums.salarysob.TargetTypeEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.Date; + +/** + * 关联人员 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//hrsa_salary_sob_range", autoResultMap = true) +@ElogTransform(name = "薪资账套关联人员") +public class SalarySobRangePO { + + /** + * 主键id + */ + @ElogTransform(name="id") + private Long id; + + /** + * 薪资账套的id + */ + @ElogTransform(name="薪资账套id") + private Long salarySobId; + + /** + * 对象类型 + * @see TargetTypeEnum + */ + @ElogTransform(name="对象类型") + private Integer targetType; + + /** + * 对象id + */ + @ElogTransform(name="对象id") + private Long targetId; + + /** + * 对象id + */ + @ElogTransform(name="SQL") + private String target; + /** + * 人员状态 + * @see SalaryEmployeeStatusEnum + */ + @ElogTransform(name="人员状态") + private Integer employeeStatus; + + /** + * 人员状态使用逗号分隔 + * @see SalaryEmployeeStatusEnum + */ + @ElogTransform(name="人员状态") + private String employeeStatuses; + + /** + * 是包含还是排除 0:排除、1:包含 + */ + @ElogTransform(name="是包含还是排除") + private Integer includeType; + + /** + * 租户key + */ + @ElogTransform(name="租户key") + private String tenantKey; + + /** + * 创建人id + */ + @ElogTransform(name="创建人id") + private Long creator; + + /** + * 是否删除 + */ + @ElogTransform(name="是否删除") + private Integer deleteType; + + /** + * 创建时间 + */ + @ElogTransform(name="创建时间") + private Date createTime; + + /** + * 更新时间 + */ + @ElogTransform(name="更新时间") + private Date updateTime; + + Collection ids; +} diff --git a/src/com/engine/salary/entity/salarysob/po/SobTaxLinkPO.java b/src/com/engine/salary/entity/salarysob/po/SobTaxLinkPO.java new file mode 100644 index 000000000..de4a47135 --- /dev/null +++ b/src/com/engine/salary/entity/salarysob/po/SobTaxLinkPO.java @@ -0,0 +1,74 @@ +package com.engine.salary.entity.salarysob.po; + +import com.engine.hrmelog.annotation.ElogTransform; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.Date; +import java.util.List; + +/** + * 数据 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SobTaxLinkPO { + + @ElogTransform(name = "id") + private Long id; + + /** + * 账套id + */ + @ElogTransform(name = "账套id") + private Long sobId; + + /** + * 扣缴义务人id + */ + @ElogTransform(name = "扣缴义务人id") + private Long taxAgentId; + + + /** + * 是否已删除。0:未删除、1:已删除 + */ + @ElogTransform(name = "是否已删除。0:未删除、1:已删除") + private Integer deleteType; + + + /** + * 更新时间 + */ + @ElogTransform(name = "更新时间") + private Date updateTime; + + /** + * 创建时间 + */ + @ElogTransform(name = "创建时间") + private Date createTime; + + /** + * 创建人 + */ + @ElogTransform(name = "创建人") + private Long creator; + + + /** + * 租户ID + */ + @ElogTransform(name = "租户ID") + private String tenantKey; + + //主键id集合 + private Collection ids; + private List taxAgentIds; + +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/salarysql/ExpressSQL.java b/src/com/engine/salary/entity/salarysql/ExpressSQL.java new file mode 100644 index 000000000..8d582fcb6 --- /dev/null +++ b/src/com/engine/salary/entity/salarysql/ExpressSQL.java @@ -0,0 +1,65 @@ +package com.engine.salary.entity.salarysql; + +import com.engine.salary.entity.salarysql.po.SQLVar; +import lombok.Data; + +import java.util.Date; +import java.util.List; + +@Data +public class ExpressSQL { + /** + * id + */ + private Long id; + /** + * 名称 + */ + private String name; + /** + * 备注 + */ + private String description; + /** + * 模块 + */ + private String module; + /** + * 用途 + */ + private String useFor; + + /** + * 扩展参数 + */ + private String extendParam; + /** + * sql内容 + */ + private String sql; + + /** + * sql实际运行脚本 + */ + private String sqlRunScript; + + /** + * 创建人 + */ + private Long creator; + /** + * 是否删除0否1是 + */ + private Integer deleteType; + /** + * 创建时间 + */ + private Date createTime; + /** + * 修改时间 + */ + private Date updateTime; + + + private List parameters; +} diff --git a/src/com/engine/salary/entity/salarysql/po/SQLPO.java b/src/com/engine/salary/entity/salarysql/po/SQLPO.java new file mode 100644 index 000000000..0506af86f --- /dev/null +++ b/src/com/engine/salary/entity/salarysql/po/SQLPO.java @@ -0,0 +1,64 @@ +package com.engine.salary.entity.salarysql.po; + +import lombok.Data; + +import java.util.Date; +import java.util.List; + +@Data +public class SQLPO { + /** + * id + */ + private Long id; + /** + * 名称 + */ + private String name; + /** + * 备注 + */ + private String description; + /** + * 模块 + */ + private String module; + /** + * 用途 + */ + private String useFor; + + /** + * 扩展参数 + */ + private String extendParam; + /** + * sql内容 + */ + private String sql; + + /** + * sql实际运行脚本 + */ + private String sqlRunScript; + + /** + * 创建人 + */ + private Long creator; + /** + * 是否删除0否1是 + */ + private Integer deleteType; + /** + * 创建时间 + */ + private Date createTime; + /** + * 修改时间 + */ + private Date updateTime; + + + private List parameters; +} diff --git a/src/com/engine/salary/entity/salarysql/po/SQLVar.java b/src/com/engine/salary/entity/salarysql/po/SQLVar.java new file mode 100644 index 000000000..60ac5262e --- /dev/null +++ b/src/com/engine/salary/entity/salarysql/po/SQLVar.java @@ -0,0 +1,67 @@ +package com.engine.salary.entity.salarysql.po; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SQLVar { + /** + * id + */ + private Long id; + /** + * 名称 + */ + private String name; + /** + * SQLid + */ + private Long SQLId; + /** + * 字段id + */ + private String fieldId; + /** + * 字段名称 + */ + private String fieldName; + /** + * 字段类型,number,string + */ + private String fieldType; + /** + * 来源 + */ + private String source; + /** + * 排序 + */ + private Integer orderIndex; + /** + * 创建人 + */ + private Long creator; + /** + * 是否删除,0否1是 + */ + private Integer deleteType; + /** + * 创建时间 + */ + private Date createTime; + /** + * 修改时间 + */ + private Date updateTime; + + + //值 + private String content; +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/setting/dto/PageListSettingDTO.java b/src/com/engine/salary/entity/setting/dto/PageListSettingDTO.java new file mode 100644 index 000000000..56648ec45 --- /dev/null +++ b/src/com/engine/salary/entity/setting/dto/PageListSettingDTO.java @@ -0,0 +1,18 @@ +package com.engine.salary.entity.setting.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class PageListSettingDTO { + + private String name; + + private String value; +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/setting/dto/PageListTemplateDTO.java b/src/com/engine/salary/entity/setting/dto/PageListTemplateDTO.java new file mode 100644 index 000000000..de493e128 --- /dev/null +++ b/src/com/engine/salary/entity/setting/dto/PageListTemplateDTO.java @@ -0,0 +1,74 @@ +package com.engine.salary.entity.setting.dto; + +import com.engine.salary.annotation.TableTitle; +import com.engine.salary.enums.common.SharedTypeEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * 薪资帐套表 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//hrsa_page_list_template +public class PageListTemplateDTO { + + + private Long id; + + + /** + * 模板名称 + */ + @TableTitle(title = "模板名称",dataIndex = "name",key = "name") + private String name; + + /** + * 页面 + */ + private String page; + + /** + * 设置 + */ + private List setting; + + /** + * 是否共享,0否,1是 + * @see SharedTypeEnum + */ + private Integer sharedType; + + @TableTitle(title = "可见性",dataIndex = "sharedTypeName",key = "sharedTypeName") + private String sharedTypeName; + + /** + * 是否系统模板 + */ + private Integer systemType; + + @TableTitle(title = "是否系统模板",dataIndex = "systemTypeName",key = "systemTypeName") + private String systemTypeName; + + @TableTitle(title = "范围",dataIndex = "limits",key = "limits") + private String limits; + + @TableTitle(title = "导出模板",dataIndex = "fileName",key = "fileName") + private String fileName; + private Integer fileId; + + + /** + * 限制 + */ + private List limitIds; + + private Boolean canEdit; + +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/setting/dto/PageListTemplateDetailDTO.java b/src/com/engine/salary/entity/setting/dto/PageListTemplateDetailDTO.java new file mode 100644 index 000000000..7826c24ce --- /dev/null +++ b/src/com/engine/salary/entity/setting/dto/PageListTemplateDetailDTO.java @@ -0,0 +1,19 @@ +package com.engine.salary.entity.setting.dto; + +import com.cloudstore.eccom.pc.table.WeaTableColumn; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class PageListTemplateDetailDTO { + private List setting; + private List checked; +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/setting/param/DownloadTemplateParam.java b/src/com/engine/salary/entity/setting/param/DownloadTemplateParam.java new file mode 100644 index 000000000..ee882d721 --- /dev/null +++ b/src/com/engine/salary/entity/setting/param/DownloadTemplateParam.java @@ -0,0 +1,24 @@ +package com.engine.salary.entity.setting.param; + +import com.engine.salary.util.valid.DataCheck; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class DownloadTemplateParam { + + @DataCheck(require = true,message = "请选择表头") + private List heads; + + @DataCheck(require = true,message = "请选择设置") + private List setting; + +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/setting/param/PageListColumnsQueryParam.java b/src/com/engine/salary/entity/setting/param/PageListColumnsQueryParam.java new file mode 100644 index 000000000..5f8072d19 --- /dev/null +++ b/src/com/engine/salary/entity/setting/param/PageListColumnsQueryParam.java @@ -0,0 +1,21 @@ +package com.engine.salary.entity.setting.param; + +import com.engine.salary.util.valid.DataCheck; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 薪资帐套表 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class PageListColumnsQueryParam { + + @DataCheck(require = true,message = "请选择页面") + private String page; + +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/setting/param/PageListSettingQueryParam.java b/src/com/engine/salary/entity/setting/param/PageListSettingQueryParam.java new file mode 100644 index 000000000..1825719e8 --- /dev/null +++ b/src/com/engine/salary/entity/setting/param/PageListSettingQueryParam.java @@ -0,0 +1,23 @@ +package com.engine.salary.entity.setting.param; + +import com.engine.salary.util.valid.DataCheck; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 薪资帐套表 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class PageListSettingQueryParam { + + @DataCheck(require = true,message = "请选择页面") + private String page; + + private String name; + +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/setting/param/PageListSettingResetParam.java b/src/com/engine/salary/entity/setting/param/PageListSettingResetParam.java new file mode 100644 index 000000000..6b110acd8 --- /dev/null +++ b/src/com/engine/salary/entity/setting/param/PageListSettingResetParam.java @@ -0,0 +1,22 @@ +package com.engine.salary.entity.setting.param; + +import com.engine.salary.util.valid.DataCheck; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 恢复默认值 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class PageListSettingResetParam { + /** + * 页面,0:薪资明细 + */ + @DataCheck(require = true,message = "请选择页面") + private String page; +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/setting/param/PageListSettingSaveParam.java b/src/com/engine/salary/entity/setting/param/PageListSettingSaveParam.java new file mode 100644 index 000000000..e164d4889 --- /dev/null +++ b/src/com/engine/salary/entity/setting/param/PageListSettingSaveParam.java @@ -0,0 +1,37 @@ +package com.engine.salary.entity.setting.param; + +import com.engine.salary.util.valid.DataCheck; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * 薪资帐套表 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class PageListSettingSaveParam { + + /** + * 默认设置 + */ + @DataCheck(require = true,message = "是否为默认设置") + private Integer defaultSetting; + + /** + * 页面,0:薪资明细 + */ + @DataCheck(require = true,message = "请选择页面") + private String page; + + /** + * 设置 + */ + @DataCheck(require = true,message = "请选择设置") + private List setting; +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/setting/param/PageListTemplateChangeParam.java b/src/com/engine/salary/entity/setting/param/PageListTemplateChangeParam.java new file mode 100644 index 000000000..3f8d05fd3 --- /dev/null +++ b/src/com/engine/salary/entity/setting/param/PageListTemplateChangeParam.java @@ -0,0 +1,31 @@ +package com.engine.salary.entity.setting.param; + +import com.engine.salary.util.valid.DataCheck; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 薪资帐套表 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class PageListTemplateChangeParam { + + /** + * 页面,0:薪资明细 + */ + @DataCheck(require = true,message = "请选择页面") + private String page; + + /** + * 模板id + */ + @DataCheck(require = true,message = "请选择模板") + private Long templateId; + + +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/setting/param/PageListTemplateDeleteParam.java b/src/com/engine/salary/entity/setting/param/PageListTemplateDeleteParam.java new file mode 100644 index 000000000..d02ac39b4 --- /dev/null +++ b/src/com/engine/salary/entity/setting/param/PageListTemplateDeleteParam.java @@ -0,0 +1,18 @@ +package com.engine.salary.entity.setting.param; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class PageListTemplateDeleteParam { + private List ids; + +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/setting/param/PageListTemplateQueryParam.java b/src/com/engine/salary/entity/setting/param/PageListTemplateQueryParam.java new file mode 100644 index 000000000..4170f5d2a --- /dev/null +++ b/src/com/engine/salary/entity/setting/param/PageListTemplateQueryParam.java @@ -0,0 +1,28 @@ +package com.engine.salary.entity.setting.param; + +import com.engine.salary.common.BaseQueryParam; +import com.engine.salary.util.valid.DataCheck; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 薪资帐套表 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class PageListTemplateQueryParam extends BaseQueryParam { + + private Long id; + + @DataCheck(require = true,message = "请选择页面") + private String page; + + /** + * 字段name + */ + private String name; +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/setting/param/PageListTemplateSaveParam.java b/src/com/engine/salary/entity/setting/param/PageListTemplateSaveParam.java new file mode 100644 index 000000000..cde28fdf9 --- /dev/null +++ b/src/com/engine/salary/entity/setting/param/PageListTemplateSaveParam.java @@ -0,0 +1,48 @@ +package com.engine.salary.entity.setting.param; + +import com.engine.salary.util.valid.DataCheck; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * 薪资帐套表 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class PageListTemplateSaveParam { + private Long id; + + /** + * 页面,0:薪资明细 + */ + @DataCheck(require = true,message = "请选择页面") + private String page; + + /** + * 模板名称 + */ + @DataCheck(require = true,message = "请选择模板名称") + private String name; + + @DataCheck(require = true,message = "请选择共享类型") + private Integer sharedType; + + private List limitIds; + + /** + * 设置 + */ + @DataCheck(require = true,message = "请选择设置") + private List setting; + + /** + * 导出模板id + */ + private Integer fileId; +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/setting/po/PageLinkPO.java b/src/com/engine/salary/entity/setting/po/PageLinkPO.java new file mode 100644 index 000000000..7037abe77 --- /dev/null +++ b/src/com/engine/salary/entity/setting/po/PageLinkPO.java @@ -0,0 +1,70 @@ +package com.engine.salary.entity.setting.po; + +import com.engine.hrmelog.annotation.ElogTransform; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.Date; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class PageLinkPO { + + @ElogTransform(name = "id") + private Long id; + + @ElogTransform(name = "人员id") + private Long employeeId; + + /** + * 页面 + */ + @ElogTransform(name = "页面") + private String page; + + /** + * 页面模板id + */ + @ElogTransform(name = "页面模板id") + private Long templateId; + + /** + * 租户ID + */ + @ElogTransform(name = "租户ID") + private String tenantKey; + + /** + * 更新时间 + */ + @ElogTransform(name = "更新时间") + private Date updateTime; + /** + * 创建时间 + */ + @ElogTransform(name = "创建时间") + private Date createTime; + + /** + * 创建人 + */ + @ElogTransform(name = "创建人") + private Long creator; + + + /** + * 是否已删除。0:未删除、1:已删除 + */ + @ElogTransform(name = "是否已删除。0:未删除、1:已删除") + private Integer deleteType; + + + //主键id集合 + private Collection ids; + +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/setting/po/PageListSettingPO.java b/src/com/engine/salary/entity/setting/po/PageListSettingPO.java new file mode 100644 index 000000000..5d706166a --- /dev/null +++ b/src/com/engine/salary/entity/setting/po/PageListSettingPO.java @@ -0,0 +1,75 @@ +package com.engine.salary.entity.setting.po; + +import com.engine.hrmelog.annotation.ElogTransform; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.Date; +import java.util.List; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//hrsa_page_list_setting +public class PageListSettingPO { + + @ElogTransform(name = "id") + private Long id; + + /** + * 页面,0:薪资明细 + */ + @ElogTransform(name = "页面,0:薪资明细") + private String page; + + /** + * 设置 + */ + @ElogTransform(name = "设置") + private List setting; + + /** + * 默认设置 + */ + private Integer defaultSetting; + + + /** + * 更新时间 + */ + @ElogTransform(name = "更新时间") + private Date updateTime; + + /** + * 创建时间 + */ + @ElogTransform(name = "创建时间") + private Date createTime; + + /** + * 创建人 + */ + @ElogTransform(name = "创建人") + private Long creator; + + /** + * 是否已删除。0:未删除、1:已删除 + */ + @ElogTransform(name = "是否已删除。0:未删除、1:已删除") + private Integer deleteType; + + /** + * 租户ID + */ + @ElogTransform(name = "租户ID") + private String tenantKey; + + + //主键id集合 + private Collection ids; + +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/setting/po/PageListTemplatePO.java b/src/com/engine/salary/entity/setting/po/PageListTemplatePO.java new file mode 100644 index 000000000..adebbf0e2 --- /dev/null +++ b/src/com/engine/salary/entity/setting/po/PageListTemplatePO.java @@ -0,0 +1,109 @@ +package com.engine.salary.entity.setting.po; + +import com.engine.hrmelog.annotation.ElogTransform; +import com.engine.salary.enums.common.SharedTypeEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.Date; +import java.util.List; + +/** + * 页面模板表 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//hrsa_page_list_template +public class PageListTemplatePO { + + + @ElogTransform(name = "id") + private Long id; + + + /** + * 模板名称 + */ + @ElogTransform(name = "模板名称") + private String name; + + /** + * 页面 + */ + @ElogTransform(name = "页面") + private String page; + + /** + * 设置 + */ + @ElogTransform(name = "设置") + private List setting; + + /** + * 是否共享,0否,1是 + * @see SharedTypeEnum + */ + @ElogTransform(name = "可见性:1私有,0共享") + private Integer sharedType; + + /** + * 是否系统模板 + */ + @ElogTransform(name = "是否系统模板,0否,1是") + private Integer systemType; + + + /** + * 限制 + */ + @ElogTransform(name = "限制") + private List limitIds; + + /** + * excel模板文件id + */ + @ElogTransform(name = "模板文件id") + private Integer fileId; + + /** + * 租户ID + */ + @ElogTransform(name = "租户ID") + private String tenantKey; + + /** + * 更新时间 + */ + @ElogTransform(name = "更新时间") + private Date updateTime; + + /** + * 创建时间 + */ + @ElogTransform(name = "创建时间") + private Date createTime; + + /** + * 创建人 + */ + @ElogTransform(name = "创建人") + private Long creator; + + /** + * 是否已删除。0:未删除、1:已删除 + */ + @ElogTransform(name = "是否已删除。0:未删除、1:已删除") + private Integer deleteType; + + + //主键id集合 + private Collection ids; + + private Boolean checked; + +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/siaccount/bo/InsuranceAccountBO.java b/src/com/engine/salary/entity/siaccount/bo/InsuranceAccountBO.java new file mode 100644 index 000000000..f2af2ac95 --- /dev/null +++ b/src/com/engine/salary/entity/siaccount/bo/InsuranceAccountBO.java @@ -0,0 +1,102 @@ +package com.engine.salary.entity.siaccount.bo; + + +import com.engine.salary.entity.siaccount.dto.InsuranceAccountBatchListDTO; +import com.engine.salary.entity.siaccount.po.InsuranceAccountBatchPO; +import com.engine.salary.enums.siaccount.BillStatusEnum; +import com.engine.salary.mapper.taxagent.TaxAgentMapper; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.SalaryEnumUtil; +import com.engine.salary.util.db.MapperProxyFactory; +import org.apache.commons.collections.CollectionUtils; + +import java.text.SimpleDateFormat; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; + +/** + * @Author weaver_cl + * @Description: + * @Date 2022/4/11 + * @Version V1.0 + **/ +public class InsuranceAccountBO { + +// public static Wrapper buildInspectListWrapper(String billMonth, String tenantKey) { +// LambdaQueryWrapper lambdaQueryWrapper = Wrappers.lambdaQuery(); +// lambdaQueryWrapper.eq(InsuranceAccountInspectPO::getTenantKey, tenantKey); +// lambdaQueryWrapper.eq(InsuranceAccountInspectPO::getDeleteType, DeleteTypeEnum.NOT_DELETED.getValue()); +// lambdaQueryWrapper.eq(InsuranceAccountInspectPO::getBillMonth, billMonth); +// return lambdaQueryWrapper; +// } +// +// public static Wrapper buildBatchListWrapper(String startTime, String endTime, String tenantKey) { +// LambdaQueryWrapper lambdaQueryWrapper = Wrappers.lambdaQuery(); +// lambdaQueryWrapper.eq(InsuranceAccountBatchPO::getTenantKey, tenantKey); +// lambdaQueryWrapper.eq(InsuranceAccountBatchPO::getDeleteType, DeleteTypeEnum.NOT_DELETED.getValue()); +// if (StringUtils.isNotBlank(startTime)) { +// lambdaQueryWrapper.ge(InsuranceAccountBatchPO::getBillMonth, startTime); +// } +// if (StringUtils.isNotBlank(endTime)) { +// lambdaQueryWrapper.le(InsuranceAccountBatchPO::getBillMonth, endTime); +// } +// lambdaQueryWrapper.orderByDesc(InsuranceAccountBatchPO::getBillMonth); +// return lambdaQueryWrapper; +// } +// + public static List buildAccountBatchDTOList(Collection list) { + if (CollectionUtils.isEmpty(list)) { + return Collections.emptyList(); + } + return list.stream().map(e -> InsuranceAccountBatchListDTO.builder() + .id(e.getId()) + .accountant(e.getAccountant()) + .billMonth(e.getBillMonth()) +// .billStatus(queryLabelId(e.getBillStatus()).getDefaultLabel()) + .billStatus(e.getBillStatus().toString()) + .fundNum(e.getFundNum()) + .fundPay(SalaryEntityUtil.thousandthConvert(e.getFundPay())) + .lastTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(e.getUpdateTime())) + .otherNum(e.getOtherNum()) + .otherPay(SalaryEntityUtil.thousandthConvert(e.getOtherPay())) + .remarks(e.getRemarks()) + .socialNum(e.getSocialNum()) + .socialPay(SalaryEntityUtil.thousandthConvert(e.getSocialPay())) + .paymentOrganization(e.getPaymentOrganization() != null ? MapperProxyFactory.getProxy(TaxAgentMapper.class).getById(e.getPaymentOrganization()).getName() : "") + .paymentOrganizationId(e.getPaymentOrganization()) + .creator(e.getCreator()) + .opts(e.getOpts()) + .build() + ).collect(Collectors.toList()); + } + + public static BillStatusEnum queryLabelId(Integer value) { + return SalaryEnumUtil.enumMatchByValue(value, BillStatusEnum.values(), BillStatusEnum.class); + } + +// +// public static Wrapper buildBillWrapper(String billMonth, PaymentStatusEnum paymentStatusEnum, Long employeeId, String tenantKey) { +// LambdaQueryWrapper queryWrapper = Wrappers.lambdaQuery(); +// queryWrapper.eq(InsuranceAccountDetailPO::getTenantKey, tenantKey); +// queryWrapper.eq(InsuranceAccountDetailPO::getDeleteType, DeleteTypeEnum.NOT_DELETED.getValue()); +// queryWrapper.eq(InsuranceAccountDetailPO::getBillMonth, billMonth); +// queryWrapper.eq(InsuranceAccountDetailPO::getPaymentStatus, paymentStatusEnum.getValue()); +// queryWrapper.orderByDesc(InsuranceAccountDetailPO::getUpdateTime); +// return queryWrapper; +// } +// +// public static Wrapper buildPersonBillWrapper(String startMonth, String endMonth, Long employeeId, String tenantKey) { +// LambdaQueryWrapper queryWrapper = Wrappers.lambdaQuery(); +// queryWrapper.eq(InsuranceAccountDetailPO::getTenantKey, tenantKey); +// queryWrapper.eq(InsuranceAccountDetailPO::getDeleteType, DeleteTypeEnum.NOT_DELETED.getValue()); +// queryWrapper.eq(InsuranceAccountDetailPO::getEmployeeId, employeeId); +// if (StringUtils.isNotBlank(startMonth) && StringUtils.isNotBlank(endMonth)) { +// queryWrapper.between(InsuranceAccountDetailPO::getBillMonth, startMonth, endMonth); +// } +// queryWrapper.orderByDesc(InsuranceAccountDetailPO::getBillMonth); +// return queryWrapper; +// } + +} diff --git a/src/com/engine/salary/entity/siaccount/bo/InsuranceComparisonResultBO.java b/src/com/engine/salary/entity/siaccount/bo/InsuranceComparisonResultBO.java new file mode 100644 index 000000000..c6e6b40a3 --- /dev/null +++ b/src/com/engine/salary/entity/siaccount/bo/InsuranceComparisonResultBO.java @@ -0,0 +1,470 @@ +package com.engine.salary.entity.siaccount.bo; + +import com.alibaba.fastjson.JSON; +import com.engine.salary.entity.salaryacct.po.ExcelAcctResultPO; +import com.engine.salary.entity.salaryacct.po.SalaryAcctResultPO; +import com.engine.salary.entity.salarysob.dto.SalarySobEmpFieldDTO; +import com.engine.salary.entity.sicategory.po.ICategoryPO; +import com.engine.salary.entity.siexport.po.AccountExportPO; +import com.engine.salary.entity.siexport.po.ExcelAccountExportPO; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import com.engine.salary.enums.salaryitem.SalaryDataTypeEnum; +import com.engine.salary.mapper.sicategory.ICategoryMapper; +import com.engine.salary.mapper.taxagent.TaxAgentMapper; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.db.MapperProxyFactory; +import com.engine.salary.util.page.Column; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; + +import java.util.*; +import java.util.function.Function; +import java.util.stream.Collectors; + +import static com.engine.salary.enums.UserStatusEnum.getDefaultLabelByValue; + +/** + * @Author: sy + * @Description: 福利核算线上线下对比结果 + * @Date: 2022/9/28 + **/ +public class InsuranceComparisonResultBO { + /** + * 数据类型的后缀标识 + * 为了展示千分位,福利核算结果列表、线上线下对比结果列表需要返回给前端列表字段的数据类型,字段索引+后缀标识 + */ + private static final String DATA_TYPE_SUFFIX = "_type"; + + + /** + * 构建福利核算结果列表的表头(线下对比) + * + */ + public static List buildTableColumns4ComparisonResult(Set insuranceBaseSet, Set insurancePerPaySet, Set insuranceComPaySet, boolean welBaseDiffSign) { + + List listAll = MapperProxyFactory.getProxy(ICategoryMapper.class).listAll(); + List socialWelfareList = listAll.stream().filter(e -> e.getWelfareType() == 1 && e.getIsUse() == 1 && insuranceBaseSet.contains(e.getId())).collect(Collectors.toList()); + List fundWelfareList = listAll.stream().filter(e -> e.getWelfareType() == 2 && e.getIsUse() == 1 && insuranceBaseSet.contains(e.getId())).collect(Collectors.toList()); + List otherWelfareList = listAll.stream().filter(e -> e.getWelfareType() == 3 && e.getIsUse() == 1 && insuranceBaseSet.contains(e.getId())).collect(Collectors.toList()); + + List socialWelPerList = listAll.stream().filter(e -> e.getWelfareType() == 1 && e.getIsUse() == 1 && insurancePerPaySet.contains(e.getId())).collect(Collectors.toList()); + List fundWelPerList = listAll.stream().filter(e -> e.getWelfareType() == 2 && e.getIsUse() == 1 && insurancePerPaySet.contains(e.getId())).collect(Collectors.toList()); + List otherWelPerList = listAll.stream().filter(e -> e.getWelfareType() == 3 && e.getIsUse() == 1 && insurancePerPaySet.contains(e.getId())).collect(Collectors.toList()); + + List socialWelComList = listAll.stream().filter(e -> e.getWelfareType() == 1 && e.getIsUse() == 1 && insuranceComPaySet.contains(e.getId())).collect(Collectors.toList()); + List fundWelComList = listAll.stream().filter(e -> e.getWelfareType() == 2 && e.getIsUse() == 1 && insuranceComPaySet.contains(e.getId())).collect(Collectors.toList()); + List otherWelComList = listAll.stream().filter(e -> e.getWelfareType() == 3 && e.getIsUse() == 1 && insuranceComPaySet.contains(e.getId())).collect(Collectors.toList()); + List columns = Lists.newArrayList(); + // 员工信息字段 + columns.add(new Column("姓名", "userName", "userName")); + columns.add(new Column("部门", "department", "department")); + columns.add(new Column("手机号", "mobile", "mobile")); + columns.add(new Column("工号", "workcode", "workcode")); + columns.add(new Column("员工状态", "employeeStatus", "employeeStatus")); + columns.add(new Column("数据来源", "sourceFrom", "sourceFrom")); + columns.add(new Column("个税扣缴义务人", "socialPayOrg", "socialPayOrg")); + columns.add(new Column("社保账号", "socialAccount", "socialAccount")); + columns.add(new Column("社保方案名称", "socialSchemeName", "socialSchemeName")); + //组装社保基数 + if (welBaseDiffSign) { + List socialComColumns = Lists.newArrayList(); + for (ICategoryPO po : socialWelfareList) { + columns.add(new Column(po.getInsuranceName() + SalaryI18nUtil.getI18nLabel(0, "申报基数") + SalaryI18nUtil.getI18nLabel(0,"个人") + , po.getId() + "socialPerBase", po.getId() + "socialPerBase")); + socialComColumns.add(new Column(po.getInsuranceName() + SalaryI18nUtil.getI18nLabel(0, "申报基数") + SalaryI18nUtil.getI18nLabel(0,"单位") + , po.getId() + "socialComBase", po.getId() + "socialComBase")); + } + columns.addAll(socialComColumns); + } else { + for (ICategoryPO po : socialWelfareList) { + columns.add(new Column(po.getInsuranceName() + "申报基数", po.getId() + "socialBase", po.getId() + "socialBase")); + } + } +// for (ICategoryPO po : socialWelfareList) { +// columns.add(new Column(po.getInsuranceName() + "申报基数", po.getId() + "socialBase", po.getId() + "socialBase")); +// } + columns.add(new Column("公积金账号", "fundAccount", "fundAccount")); + columns.add(new Column("公积金方案名称", "fundSchemeName", "fundSchemeName")); + //组装公积金基数 + if (welBaseDiffSign) { + List fundComColumns = Lists.newArrayList(); + for (ICategoryPO po : fundWelfareList) { + columns.add(new Column(po.getInsuranceName() + SalaryI18nUtil.getI18nLabel(0, "申报基数") + SalaryI18nUtil.getI18nLabel(0,"个人") + , po.getId() + "fundPerBase", po.getId() + "fundPerBase")); + fundComColumns.add(new Column(po.getInsuranceName() + SalaryI18nUtil.getI18nLabel(0, "申报基数") + SalaryI18nUtil.getI18nLabel(0,"单位") + , po.getId() + "fundComBase", po.getId() + "fundComBase")); + } + columns.addAll(fundComColumns); + } else { + for (ICategoryPO po : fundWelfareList) { + columns.add(new Column(po.getInsuranceName() + "申报基数", po.getId() + "fundBase", po.getId() + "fundBase")); + } + } +// for (ICategoryPO po : fundWelfareList) { +// columns.add(new Column(po.getInsuranceName() + "申报基数", po.getId() + "fundBase", po.getId() + "fundBase")); +// } + columns.add(new Column("补充公积金账号", "supplementFundAccount", "supplementFundAccount")); + columns.add(new Column("其他福利方案名称", "otherSchemeName", "otherSchemeName")); + //组装其他福利基数 + if (welBaseDiffSign) { + List otherComColumns = Lists.newArrayList(); + for (ICategoryPO po : otherWelfareList) { + columns.add(new Column(po.getInsuranceName() + SalaryI18nUtil.getI18nLabel(0, "申报基数") + SalaryI18nUtil.getI18nLabel(0,"个人") + , po.getId() + "otherPerBase", po.getId() + "otherPerBase")); + otherComColumns.add(new Column(po.getInsuranceName() + SalaryI18nUtil.getI18nLabel(0, "申报基数") + SalaryI18nUtil.getI18nLabel(0,"单位") + , po.getId() + "otherComBase", po.getId() + "otherComBase")); + } + columns.addAll(otherComColumns); + } else { + for (ICategoryPO po : otherWelfareList) { + columns.add(new Column(po.getInsuranceName() + "申报基数", po.getId() + "otherBase", po.getId() + "otherBase")); + } + } +// for (ICategoryPO po : otherWelfareList) { +// columns.add(new Column(po.getInsuranceName() + "申报基数", po.getId() + "otherBase", po.getId() + "otherBase")); +// } + + //社保个人(生育保险个人、工伤保险个人、失业保险个人、养老保险个人、医疗保险个人) + for (ICategoryPO po : socialWelPerList) { + columns.add(new Column(po.getInsuranceName() + "个人", po.getId() + "socialPer", po.getId() + "socialPer")); + } + columns.add(new Column("社保个人合计", "socialPerSum", "socialPerSum")); + //住房公积金个人、补充住房公积金个人 + for (ICategoryPO po : fundWelPerList) { + columns.add(new Column(po.getInsuranceName() + "个人", po.getId() + "fundPer", po.getId() + "fundPer")); + } + columns.add(new Column("公积金个人合计", "fundPerSum", "fundPerSum")); + //其他个人(比如企业年金个人) + for (ICategoryPO po : otherWelPerList) { + columns.add(new Column(po.getInsuranceName() + "个人", po.getId() + "otherPer", po.getId() + "otherPer")); + } + columns.add(new Column("其他福利个人合计", "otherPerSum", "otherPerSum")); + columns.add(new Column("个人合计", "perSum", "perSum")); + //社保单位(生育保险单位、工伤保险单位、失业保险单位、养老保险单位、医疗保险单位) + for (ICategoryPO po : socialWelComList) { + columns.add(new Column(po.getInsuranceName() + "单位", po.getId() + "socialCom", po.getId() + "socialCom")); + } + columns.add(new Column("社保单位合计", "socialComSum", "socialComSum")); + //住房公积金单位、补充住房公积金单位 + for (ICategoryPO po : fundWelComList) { + columns.add(new Column(po.getInsuranceName() + "单位", po.getId() + "fundCom", po.getId() + "fundCom")); + } + columns.add(new Column("公积金单位合计", "fundComSum", "fundComSum")); + //其他单位(比如企业年金单位) + for (ICategoryPO po : otherWelComList) { + columns.add(new Column(po.getInsuranceName() + "单位", po.getId() + "otherCom", po.getId() + "otherCom")); + } + columns.add(new Column("其他福利单位合计", "otherComSum", "otherComSum")); + columns.add(new Column("单位合计", "comSum", "comSum")); + + columns.add(new Column("社保合计", "socialSum", "socialSum")); + columns.add(new Column("公积金合计", "fundSum", "fundSum")); + columns.add(new Column("其他福利合计", "otherSum", "otherSum")); + columns.add(new Column("合计", "total", "total")); + return columns; + } + + /** + * 构建福利核算线下对比结果 + * + */ + public static List> buildComparisonTableData(List accountExportPOS, List excelAccountExportPOS + , Map schemeIdNameMap, boolean welBaseDiffSign) { + + Map> excelResultMap = SalaryEntityUtil.group2Map(excelAccountExportPOS, ExcelAccountExportPO::getEmployeeId); +// Map> acctResultMap = SalaryEntityUtil.group2Map(accountExportPOS, AccountExportPO::getWorkcode); + + List paymentList = MapperProxyFactory.getProxy(TaxAgentMapper.class).listAll(); + Map paymentMap = paymentList.stream().collect(Collectors.toMap(TaxAgentPO::getId, Function.identity())); + + List> resultList = Lists.newArrayListWithExpectedSize(accountExportPOS.size()); + + //遍历线上数据 + for (AccountExportPO accountExportPO : accountExportPOS) { + + Map map = Maps.newHashMap(); + // 记录线下值和系统值之间是否存在差异 + map.put("different", "false"); + + //设置基本字段信息和类型 + map.put("userName", accountExportPO.getUserName()); + map.put("userName" + DATA_TYPE_SUFFIX, SalaryDataTypeEnum.STRING.getValue()); + map.put("department", accountExportPO.getDepartmentName()); + map.put("department" + DATA_TYPE_SUFFIX, SalaryDataTypeEnum.STRING.getValue()); + map.put("mobile", accountExportPO.getTelephone()); + map.put("mobile" + DATA_TYPE_SUFFIX, SalaryDataTypeEnum.STRING.getValue()); + map.put("workcode", accountExportPO.getWorkcode()); + map.put("workcode" + DATA_TYPE_SUFFIX, SalaryDataTypeEnum.STRING.getValue()); + map.put("employeeStatus", accountExportPO.getUserStatus() == null ? "" : getDefaultLabelByValue(accountExportPO.getUserStatus())); + map.put("employeeStatus" + DATA_TYPE_SUFFIX, SalaryDataTypeEnum.STRING.getValue()); + map.put("socialPayOrg", paymentMap.get(accountExportPO.getSocialPayOrg()) == null ? "" : paymentMap.get(accountExportPO.getSocialPayOrg()).getName()); + map.put("socialPayOrg" + DATA_TYPE_SUFFIX, SalaryDataTypeEnum.STRING.getValue()); + + //社保账号、公积金账号、补充公积金账号 + map.put("fundAccount", accountExportPO.getFundAccount()); + map.put("fundAccount" + DATA_TYPE_SUFFIX, SalaryDataTypeEnum.STRING.getValue()); + map.put("socialAccount", accountExportPO.getSocialAccount()); + map.put("socialAccount" + DATA_TYPE_SUFFIX, SalaryDataTypeEnum.STRING.getValue()); + map.put("supplementFundAccount", accountExportPO.getSupplementFundAccount()); + map.put("supplementFundAccount" + DATA_TYPE_SUFFIX, SalaryDataTypeEnum.STRING.getValue()); + + //福利方案名称 + map.put("socialSchemeName", schemeIdNameMap.get(accountExportPO.getSocialSchemeId())); + map.put("fundSchemeName", schemeIdNameMap.get(accountExportPO.getFundSchemeId())); + map.put("otherSchemeName", schemeIdNameMap.get(accountExportPO.getOtherSchemeId())); + + //线下值 + List excelResultValueList = excelResultMap.get(accountExportPO.getEmployeeId()); + ExcelAccountExportPO excelAccountExportPO = new ExcelAccountExportPO(); + if (excelResultValueList != null && excelResultValueList.size() == 1) { + excelAccountExportPO = excelResultValueList.get(0); + } + if (welBaseDiffSign) { + //社保基数-个人,socialPaymentBaseString + welfareElementCompare(map, accountExportPO.getSocialPaymentBaseString(), excelAccountExportPO.getSocialPaymentBaseString(), "PerBase", 1); + //公积金基数-个人,fundPaymentBaseString + welfareElementCompare(map, accountExportPO.getFundPaymentBaseString(), excelAccountExportPO.getFundPaymentBaseString(), "PerBase", 2); + //其他福利基数-个人,otherPaymentBaseString + welfareElementCompare(map, accountExportPO.getOtherPaymentBaseString(), excelAccountExportPO.getOtherPaymentBaseString(), "PerBase", 3); + + //社保基数-公司,socialPaymentComBaseString + welfareElementCompare(map, accountExportPO.getSocialPaymentComBaseString(), excelAccountExportPO.getSocialPaymentComBaseString(), "ComBase", 1); + //公积金基数-公司,fundPaymentComBaseString + welfareElementCompare(map, accountExportPO.getFundPaymentComBaseString(), excelAccountExportPO.getFundPaymentComBaseString(), "ComBase", 2); + //其他福利基数-公司,otherPaymentComBaseString + welfareElementCompare(map, accountExportPO.getOtherPaymentComBaseString(), excelAccountExportPO.getOtherPaymentComBaseString(), "ComBase", 3); + } else { + //社保基数,socialPaymentBaseString + welfareElementCompare(map, accountExportPO.getSocialPaymentBaseString(), excelAccountExportPO.getSocialPaymentBaseString(), "Base", 1); + //公积金基数,fundPaymentBaseString + welfareElementCompare(map, accountExportPO.getFundPaymentBaseString(), excelAccountExportPO.getFundPaymentBaseString(), "Base", 2); + //其他福利基数,otherPaymentBaseString + welfareElementCompare(map, accountExportPO.getOtherPaymentBaseString(), excelAccountExportPO.getOtherPaymentBaseString(), "Base", 3); + } + //社保个人socialPerJson + welfareElementCompare(map, accountExportPO.getSocialPerJson(), excelAccountExportPO.getSocialPerJson(), "Per", 1); + //公积金个人fundPerJson + welfareElementCompare(map, accountExportPO.getFundPerJson(), excelAccountExportPO.getFundPerJson(), "Per", 2); + //其他个人otherPerJson + welfareElementCompare(map, accountExportPO.getOtherPerJson(), excelAccountExportPO.getOtherPerJson(), "Per", 3); + //社保单位socialComJson + welfareElementCompare(map, accountExportPO.getSocialComJson(), excelAccountExportPO.getSocialComJson(), "Com", 1); + //公积金单位fundComJson + welfareElementCompare(map, accountExportPO.getFundComJson(), excelAccountExportPO.getFundComJson(), "Com", 2); + //其他单位otherComJson + welfareElementCompare(map, accountExportPO.getOtherComJson(), excelAccountExportPO.getOtherComJson(), "Com", 3); + + //各种合计 + welfareSumCompare(map, accountExportPO, excelAccountExportPO); + + resultList.add(map); + } + return resultList; + } + + private static Map welfareElementCompare(Map map, String accountJson, String excelAccountJson, String welfareStand, Integer welfareType) { + List listAll = MapperProxyFactory.getProxy(ICategoryMapper.class).listAll(); + List accountWelfareList = listAll.stream().filter(e -> e.getWelfareType().equals(welfareType)).collect(Collectors.toList()); + + String baseTypeInfo = welfareType.equals(1) ? "social" : (welfareType.equals(2) ? "fund" : "other"); + + Map accountMap = JSON.parseObject(accountJson, HashMap.class); + Map excelAccountMap = JSON.parseObject(excelAccountJson, HashMap.class); + for (ICategoryPO welfare : accountWelfareList) { + Map temp = Maps.newHashMap(); + + if (accountMap != null && accountMap.get(welfare.getId().toString()) != null) { + temp.put("acctResultValue", dealNull(accountMap.get(welfare.getId().toString()))); + } else { + temp.put("acctResultValue", ""); + } + if (excelAccountMap != null && excelAccountMap.get(welfare.getId().toString()) != null) { + temp.put("excelResultValue", dealNull(excelAccountMap.get(welfare.getId().toString()))); + }else { + temp.put("excelResultValue", ""); + } + map.put(welfare.getId() + baseTypeInfo + welfareStand, temp); + // 薪资项目字段的字段类型 + map.put(welfare.getId() + baseTypeInfo + welfareStand + DATA_TYPE_SUFFIX, SalaryDataTypeEnum.STRING.getValue()); +// if (map.get("different").equals("false") && !temp.get("acctResultValue").equals(temp.get("excelResultValue"))) { +// map.put("different", "true"); +// } + if (map.get("different").equals("false") && SalaryEntityUtil.empty2Zero(temp.get("acctResultValue").toString()).compareTo(SalaryEntityUtil.empty2Zero(temp.get("excelResultValue").toString())) != 0) { + map.put("different", "true"); + } + } + return map; + + } + private static Map welfareSumCompare(Map map, AccountExportPO accountExportPO, ExcelAccountExportPO excelAccountExportPO) { + + //社保个人合计、公积金个人合计、其他福利个人合计、个人合计 + Map socialPerSumTemp = Maps.newHashMap(); + socialPerSumTemp.put("acctResultValue", dealNull(accountExportPO.getSocialPerSum())); + socialPerSumTemp.put("excelResultValue", dealNull(excelAccountExportPO.getSocialPerSum())); + map.put("socialPerSum", socialPerSumTemp); + map.put("socialPerSum" + DATA_TYPE_SUFFIX, SalaryDataTypeEnum.STRING.getValue()); +// if (map.get("different").equals("false") && !socialPerSumTemp.get("acctResultValue").equals(socialPerSumTemp.get("excelResultValue"))) { +// map.put("different", "true"); +// } + if (map.get("different").equals("false") && SalaryEntityUtil.empty2Zero(socialPerSumTemp.get("acctResultValue").toString()) + .compareTo(SalaryEntityUtil.empty2Zero(socialPerSumTemp.get("excelResultValue").toString())) != 0) { + map.put("different", "true"); + } + + Map fundPerSumTemp = Maps.newHashMap(); + fundPerSumTemp.put("acctResultValue", dealNull(accountExportPO.getFundPerSum())); + fundPerSumTemp.put("excelResultValue", dealNull(excelAccountExportPO.getFundPerSum())); + map.put("fundPerSum", fundPerSumTemp); + map.put("fundPerSum" + DATA_TYPE_SUFFIX, SalaryDataTypeEnum.STRING.getValue()); +// if (map.get("different").equals("false") && !fundPerSumTemp.get("acctResultValue").equals(fundPerSumTemp.get("excelResultValue"))) { +// map.put("different", "true"); +// } + if (map.get("different").equals("false") && SalaryEntityUtil.empty2Zero(fundPerSumTemp.get("acctResultValue").toString()) + .compareTo(SalaryEntityUtil.empty2Zero(fundPerSumTemp.get("excelResultValue").toString())) != 0) { + map.put("different", "true"); + } + + Map otherPerSumTemp = Maps.newHashMap(); + otherPerSumTemp.put("acctResultValue", dealNull(accountExportPO.getOtherPerSum())); + otherPerSumTemp.put("excelResultValue", dealNull(excelAccountExportPO.getOtherPerSum())); + map.put("otherPerSum", otherPerSumTemp); + map.put("otherPerSum" + DATA_TYPE_SUFFIX, SalaryDataTypeEnum.STRING.getValue()); +// if (map.get("different").equals("false") && !otherPerSumTemp.get("acctResultValue").equals(otherPerSumTemp.get("excelResultValue"))) { +// map.put("different", "true"); +// } + if (map.get("different").equals("false") && SalaryEntityUtil.empty2Zero(otherPerSumTemp.get("acctResultValue").toString()) + .compareTo(SalaryEntityUtil.empty2Zero(otherPerSumTemp.get("excelResultValue").toString())) != 0) { + map.put("different", "true"); + } + + Map perSumTemp = Maps.newHashMap(); + perSumTemp.put("acctResultValue", dealNull(accountExportPO.getPerSum())); + perSumTemp.put("excelResultValue", dealNull(excelAccountExportPO.getPerSum())); + map.put("perSum", perSumTemp); + map.put("perSum" + DATA_TYPE_SUFFIX, SalaryDataTypeEnum.STRING.getValue()); +// if (map.get("different").equals("false") && !perSumTemp.get("acctResultValue").equals(perSumTemp.get("excelResultValue"))) { +// map.put("different", "true"); +// } + if (map.get("different").equals("false") && SalaryEntityUtil.empty2Zero(perSumTemp.get("acctResultValue").toString()) + .compareTo(SalaryEntityUtil.empty2Zero(perSumTemp.get("excelResultValue").toString())) != 0) { + map.put("different", "true"); + } + + //社保单位合计、公积金单位合计、其他福利单位合计、单位合计 + Map socialComSumTemp = Maps.newHashMap(); + socialComSumTemp.put("acctResultValue", dealNull(accountExportPO.getSocialComSum())); + socialComSumTemp.put("excelResultValue", dealNull(excelAccountExportPO.getSocialComSum())); + map.put("socialComSum", socialComSumTemp); + map.put("socialComSum" + DATA_TYPE_SUFFIX, SalaryDataTypeEnum.STRING.getValue()); +// if (map.get("different").equals("false") && !socialComSumTemp.get("acctResultValue").equals(socialComSumTemp.get("excelResultValue"))) { +// map.put("different", "true"); +// } + if (map.get("different").equals("false") && SalaryEntityUtil.empty2Zero(socialComSumTemp.get("acctResultValue").toString()) + .compareTo(SalaryEntityUtil.empty2Zero(socialComSumTemp.get("excelResultValue").toString())) != 0) { + map.put("different", "true"); + } + + Map fundComSumTemp = Maps.newHashMap(); + fundComSumTemp.put("acctResultValue", dealNull(accountExportPO.getFundComSum())); + fundComSumTemp.put("excelResultValue", dealNull(excelAccountExportPO.getFundComSum())); + map.put("fundComSum", fundComSumTemp); + map.put("fundComSum" + DATA_TYPE_SUFFIX, SalaryDataTypeEnum.STRING.getValue()); +// if (map.get("different").equals("false") && !fundComSumTemp.get("acctResultValue").equals(fundComSumTemp.get("excelResultValue"))) { +// map.put("different", "true"); +// } + if (map.get("different").equals("false") && SalaryEntityUtil.empty2Zero(fundComSumTemp.get("acctResultValue").toString()) + .compareTo(SalaryEntityUtil.empty2Zero(fundComSumTemp.get("excelResultValue").toString())) != 0) { + map.put("different", "true"); + } + + Map otherComSumTemp = Maps.newHashMap(); + otherComSumTemp.put("acctResultValue", dealNull(accountExportPO.getOtherComSum())); + otherComSumTemp.put("excelResultValue", dealNull(excelAccountExportPO.getOtherComSum())); + map.put("otherComSum", otherComSumTemp); + map.put("otherComSum" + DATA_TYPE_SUFFIX, SalaryDataTypeEnum.STRING.getValue()); +// if (map.get("different").equals("false") && !otherComSumTemp.get("acctResultValue").equals(otherComSumTemp.get("excelResultValue"))) { +// map.put("different", "true"); +// } + if (map.get("different").equals("false") && SalaryEntityUtil.empty2Zero(otherComSumTemp.get("acctResultValue").toString()) + .compareTo(SalaryEntityUtil.empty2Zero(otherComSumTemp.get("excelResultValue").toString())) != 0) { + map.put("different", "true"); + } + + Map perComTemp = Maps.newHashMap(); + perComTemp.put("acctResultValue", dealNull(accountExportPO.getComSum())); + perComTemp.put("excelResultValue", dealNull(excelAccountExportPO.getComSum())); + map.put("comSum", perComTemp); + map.put("comSum" + DATA_TYPE_SUFFIX, SalaryDataTypeEnum.STRING.getValue()); +// if (map.get("different").equals("false") && !perComTemp.get("acctResultValue").equals(perComTemp.get("excelResultValue"))) { +// map.put("different", "true"); +// } + if (map.get("different").equals("false") && SalaryEntityUtil.empty2Zero(perComTemp.get("acctResultValue").toString()) + .compareTo(SalaryEntityUtil.empty2Zero(perComTemp.get("excelResultValue").toString())) != 0) { + map.put("different", "true"); + } + + //社保合计、公积金合计、其他福利合计、合计 + Map socialSumTemp = Maps.newHashMap(); + socialSumTemp.put("acctResultValue", dealNull(accountExportPO.getSocialSum())); + socialSumTemp.put("excelResultValue", dealNull(excelAccountExportPO.getSocialSum())); + map.put("socialSum", socialSumTemp); + map.put("socialSum" + DATA_TYPE_SUFFIX, SalaryDataTypeEnum.STRING.getValue()); +// if (map.get("different").equals("false") && !socialSumTemp.get("acctResultValue").equals(socialSumTemp.get("excelResultValue"))) { +// map.put("different", "true"); +// } + if (map.get("different").equals("false") && SalaryEntityUtil.empty2Zero(socialSumTemp.get("acctResultValue").toString()) + .compareTo(SalaryEntityUtil.empty2Zero(socialSumTemp.get("excelResultValue").toString())) != 0) { + map.put("different", "true"); + } + + Map fundSumTemp = Maps.newHashMap(); + fundSumTemp.put("acctResultValue", dealNull(accountExportPO.getFundSum())); + fundSumTemp.put("excelResultValue", dealNull(excelAccountExportPO.getFundSum())); + map.put("fundSum", fundSumTemp); + map.put("fundSum" + DATA_TYPE_SUFFIX, SalaryDataTypeEnum.STRING.getValue()); +// if (map.get("different").equals("false") && !fundSumTemp.get("acctResultValue").equals(fundSumTemp.get("excelResultValue"))) { +// map.put("different", "true"); +// } + if (map.get("different").equals("false") && SalaryEntityUtil.empty2Zero(fundSumTemp.get("acctResultValue").toString()) + .compareTo(SalaryEntityUtil.empty2Zero(fundSumTemp.get("excelResultValue").toString())) != 0) { + map.put("different", "true"); + } + + Map otherSumTemp = Maps.newHashMap(); + otherSumTemp.put("acctResultValue", dealNull(accountExportPO.getOtherSum())); + otherSumTemp.put("excelResultValue", dealNull(excelAccountExportPO.getOtherSum())); + map.put("otherSum", otherSumTemp); + map.put("otherSum" + DATA_TYPE_SUFFIX, SalaryDataTypeEnum.STRING.getValue()); +// if (map.get("different").equals("false") && !otherSumTemp.get("acctResultValue").equals(otherSumTemp.get("excelResultValue"))) { +// map.put("different", "true"); +// } + if (map.get("different").equals("false") && SalaryEntityUtil.empty2Zero(otherSumTemp.get("acctResultValue").toString()) + .compareTo(SalaryEntityUtil.empty2Zero(otherSumTemp.get("excelResultValue").toString())) != 0) { + map.put("different", "true"); + } + + Map totalTemp = Maps.newHashMap(); + totalTemp.put("acctResultValue", dealNull(accountExportPO.getTotal())); + totalTemp.put("excelResultValue", dealNull(excelAccountExportPO.getTotal())); + map.put("total", totalTemp); + map.put("total" + DATA_TYPE_SUFFIX, SalaryDataTypeEnum.STRING.getValue()); +// if (map.get("different").equals("false") && !totalTemp.get("acctResultValue").equals(totalTemp.get("excelResultValue"))) { +// map.put("different", "true"); +// } + if (map.get("different").equals("false") && SalaryEntityUtil.empty2Zero(totalTemp.get("acctResultValue").toString()) + .compareTo(SalaryEntityUtil.empty2Zero(totalTemp.get("excelResultValue").toString())) != 0) { + map.put("different", "true"); + } + + return map; + } + + private static String dealNull(String data) { + if (data == null || "0".equals(data) || "0.00".equals(data)) { + return ""; + } + return data; + } +} diff --git a/src/com/engine/salary/entity/siaccount/dto/InsuranceAccountBatchListDTO.java b/src/com/engine/salary/entity/siaccount/dto/InsuranceAccountBatchListDTO.java new file mode 100644 index 000000000..28939613b --- /dev/null +++ b/src/com/engine/salary/entity/siaccount/dto/InsuranceAccountBatchListDTO.java @@ -0,0 +1,120 @@ +package com.engine.salary.entity.siaccount.dto; + +import com.cloudstore.eccom.pc.table.WeaTableType; +import com.engine.salary.annotation.SalaryTable; +import com.engine.salary.annotation.SalaryTableOperate; +import com.engine.salary.annotation.TableTitle; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Set; + +/** + * @Author weaver_cl + * @Description: 福利台账列表 + * @Date 2022/4/11 + * @Version V1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@SalaryTable(pageId = "1f9fdc73-9cc2-4206-9b2c-6c6ac98d8500", tableType = WeaTableType.NONE,operates = { + @SalaryTableOperate(index = "0", text = "核算"), + @SalaryTableOperate(index = "1", text = "归档"), + @SalaryTableOperate(index = "2", text = "异常详情"), + @SalaryTableOperate(index = "3", text = "删除"), + @SalaryTableOperate(index = "4", text = "查看") +}) +public class InsuranceAccountBatchListDTO { + + /** + * 主键id + */ + @TableTitle(title = "id", dataIndex = "id", key = "id") + private Long id; + + /** + * 账单月份 + */ + @TableTitle(title = "账单月份", dataIndex = "billMonth", key = "billMonth") + private String billMonth; + + @TableTitle(title = "个税扣缴义务人", dataIndex = "paymentOrganization", key = "paymentOrganization") + private String paymentOrganization; + + private Long paymentOrganizationId; + + /** + * 账单状态 0-未归档 1-已归档 + */ + @TableTitle(title = "账单状态", dataIndex = "billStatus", key = "billStatus") + private String billStatus; + + /** + * 社保核算人数 + */ + @TableTitle(title = "社保核算人数", dataIndex = "socialNum", key = "socialNum") + private Integer socialNum; + + /** + * 公积金核算人数 + */ + @TableTitle(title = "公积金核算人数", dataIndex = "fundNum", key = "fundNum") + private Integer fundNum; + + /** + * 其他福利核算人数 + */ + @TableTitle(title = "其他福利核算人数", dataIndex = "otherNum", key = "otherNum") + private Integer otherNum; + + /** + * 社保缴费总额(单位+个人) + */ + @TableTitle(title = "社保缴费总额(单位+个人)", dataIndex = "socialPay", key = "socialPay") + private String socialPay; + + /** + * 公积金缴费总额(单位+个人) + */ + @TableTitle(title = "公积金缴费总额(单位+个人)", dataIndex = "fundPay", key = "fundPay") + private String fundPay; + + /** + * 其他福利缴费总额(单位+个人) + */ + @TableTitle(title = "其他福利缴费总额(单位+个人)", dataIndex = "otherPay", key = "otherPay") + private String otherPay; + + /** + * 核算人 + */ + @TableTitle(title = "核算人", dataIndex = "accountant", key = "accountant") + private String accountant; + + /** + * 创建核算人id + */ + private Long creator; + + /** + * 最后操作时间 + */ + @TableTitle(title = "最后操作时间", dataIndex = "lastTime", key = "lastTime") + private String lastTime; + + /** + * 备注 + */ + @TableTitle(title = "备注", dataIndex = "remarks", key = "remarks") + private String remarks; + + private Set opts; + + + + +} diff --git a/src/com/engine/salary/entity/siaccount/dto/InsuranceAccountTabDTO.java b/src/com/engine/salary/entity/siaccount/dto/InsuranceAccountTabDTO.java new file mode 100644 index 000000000..9b18c3d34 --- /dev/null +++ b/src/com/engine/salary/entity/siaccount/dto/InsuranceAccountTabDTO.java @@ -0,0 +1,44 @@ +package com.engine.salary.entity.siaccount.dto; + + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; +import java.util.Map; + +/** + * @Author weaver_cl + * @Description: 台账页tab + * @Date 2022/4/11 + * @Version V1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class InsuranceAccountTabDTO { + + /** + * tab列表 + */ + private List> tabList; + + /** + * 核算-true + * 查看-false + */ + private boolean isShow; + + /** + * 备注 + */ + private String remarks; + + /** + * 账单月份 + */ + private String billMonth; +} diff --git a/src/com/engine/salary/entity/siaccount/dto/InsuranceAccountViewListDTO.java b/src/com/engine/salary/entity/siaccount/dto/InsuranceAccountViewListDTO.java new file mode 100644 index 000000000..11f250657 --- /dev/null +++ b/src/com/engine/salary/entity/siaccount/dto/InsuranceAccountViewListDTO.java @@ -0,0 +1,52 @@ +package com.engine.salary.entity.siaccount.dto; + + +import com.cloudstore.eccom.pc.table.WeaTableType; +import com.engine.salary.annotation.SalaryTable; +import com.engine.salary.annotation.TableTitle; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Author weaver_cl + * @Description: 台账总览列表 + * @Date 2022/4/11 + * @Version V1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@SalaryTable(pageId = "b3afad76-a971-4fe3-8064-0cabdcb10b18", tableType = WeaTableType.NONE,operates = { +}) +public class InsuranceAccountViewListDTO { + + @TableTitle(title = "序号", dataIndex = "index", key = "index") + private Long index; + + @TableTitle(title = "个税扣缴义务人", dataIndex = "payOrg", key = "payOrg") + private String payOrg; + + @TableTitle(title = "社保人数", dataIndex = "socialNum", key = "socialNum") + private Integer socialNum; + + @TableTitle(title = "公积金人数", dataIndex = "fundNum", key = "fundNum") + private Integer fundNum; + + @TableTitle(title = "其他福利人数", dataIndex = "otherNum", key = "otherNum") + private Integer otherNum; + + @TableTitle(title = "社保缴费合计", dataIndex = "socialPaySum", key = "socialPaySum") + private String socialPaySum; + + @TableTitle(title = "公积金缴费合计", dataIndex = "fundPaySum", key = "fundPaySum") + private String fundPaySum; + + @TableTitle(title = "其他福利缴费合计", dataIndex = "otherPaySum", key = "otherPaySum") + private String otherPaySum; + + @TableTitle(title = "合计", dataIndex = "sum", key = "sum") + private String sum; +} diff --git a/src/com/engine/salary/entity/siaccount/dto/InsuranceAcctDetailImportFieldDTO.java b/src/com/engine/salary/entity/siaccount/dto/InsuranceAcctDetailImportFieldDTO.java new file mode 100644 index 000000000..4db8801bc --- /dev/null +++ b/src/com/engine/salary/entity/siaccount/dto/InsuranceAcctDetailImportFieldDTO.java @@ -0,0 +1,27 @@ +package com.engine.salary.entity.siaccount.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Author sy + * @Description 福利核算导入时生成导入模板的薪资(福利)项目 + * @Date 2022/9/2 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class InsuranceAcctDetailImportFieldDTO { + //字段id + private String fieldId; + + //薪资项目名称 + private String salaryItemName; + + //是否勾选 + private Boolean checked; + +} diff --git a/src/com/engine/salary/entity/siaccount/dto/InsuranceComparisonResultListDTO.java b/src/com/engine/salary/entity/siaccount/dto/InsuranceComparisonResultListDTO.java new file mode 100644 index 000000000..2b9a67c4e --- /dev/null +++ b/src/com/engine/salary/entity/siaccount/dto/InsuranceComparisonResultListDTO.java @@ -0,0 +1,29 @@ +package com.engine.salary.entity.siaccount.dto; + +import com.engine.salary.util.page.Column; +import com.engine.salary.util.page.PageInfo; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.util.List; +import java.util.Map; + +/** + * @Author: sy + * @Description: 福利核算线下对比结果列表 + * @Date: 2022/9/28 + **/ +@Data +@Accessors(chain = true) +@NoArgsConstructor +@AllArgsConstructor +public class InsuranceComparisonResultListDTO { + + //列表的表头 + private List weaTableColumns; + + //列表数据 + private PageInfo> data; +} diff --git a/src/com/engine/salary/entity/siaccount/dto/InsuranceCompensationDTO.java b/src/com/engine/salary/entity/siaccount/dto/InsuranceCompensationDTO.java new file mode 100644 index 000000000..312a52344 --- /dev/null +++ b/src/com/engine/salary/entity/siaccount/dto/InsuranceCompensationDTO.java @@ -0,0 +1,97 @@ +package com.engine.salary.entity.siaccount.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; +import java.util.Map; + +/** + * @Author: sy + * @Description: 福利台账-调差 + * @Date: 2022/11/23 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class InsuranceCompensationDTO { + + /** + * 主键id + */ + private Long id; + + /** + * 前端自定义id + */ + private String originId; + + /** + * 只读,true为实际调差记录,false为调差配置数据(非实际调差记录) + * + */ + private Boolean status; + + /** + * 缴纳组织 + */ + private Long paymentOrganization; + + /** + * 员工id + */ + private Long employeeId; + + /** + * 统计调差福利 + */ + private Integer welfareType; + + /** + * 统计调差福利类型 + */ + private String categoryType; + + /** + * 统计调差福利类型选项 + */ + private List> categoryTypeOptions; + + /** + * 国家核算金额 + */ + private String countryTotal; + + /** + * 公司核算金额 + */ + private String companyTotal; + + /** + * 应调差额 + */ + private String adjustmentTotal; + + /** + * 调差到 + */ + private Long adjustTo; + + /** + * 对象 + */ + private Long target; + + /** + * 对象选项 + */ + private Map targetOptions; + + /** + * 账单月份 + */ + private String billMonth; +} diff --git a/src/com/engine/salary/entity/siaccount/dto/SIAccountUtilDTO.java b/src/com/engine/salary/entity/siaccount/dto/SIAccountUtilDTO.java new file mode 100644 index 000000000..63921df3c --- /dev/null +++ b/src/com/engine/salary/entity/siaccount/dto/SIAccountUtilDTO.java @@ -0,0 +1,36 @@ +package com.engine.salary.entity.siaccount.dto; + + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SIAccountUtilDTO { + /** + * 数量 + */ + private int num; + /** + * 账单月份 + */ + private String billmonth; + /** + * 税款所属期 + */ + private String taxcycle; + /** + * 薪资所属月 + */ + private Date salaryMonth; + /** + * 社保福利所属期。1:上上月、2:上月、3:本月、4:下月 + */ + private Integer socialSecurityCycleType; +} diff --git a/src/com/engine/salary/entity/siaccount/param/AccountParam.java b/src/com/engine/salary/entity/siaccount/param/AccountParam.java new file mode 100644 index 000000000..34e11c6e5 --- /dev/null +++ b/src/com/engine/salary/entity/siaccount/param/AccountParam.java @@ -0,0 +1,48 @@ +package com.engine.salary.entity.siaccount.param; + + +import com.engine.salary.util.valid.DataCheck; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import java.util.List; + +/** + * @Author weaver_cl + * @Description: 保存并进入核算 + * @Date 2022/4/11 + * @Version V1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class AccountParam { + + //账单月份") + //@NotNull + @DataCheck(require = true,message = "账单月份不能为空") + private String billMonth; + + //备注") + //@Length(max = 60) + @DataCheck(max = 60,message = "备注长度不能超过60个字符") + private String remarks; + + //核算人员id集合") + private List ids; + + // 是否是首次核算 + private boolean flag = true; + + /** + * 个税扣缴义务人id + */ + @DataCheck(require = true,message = "个税扣缴义务人不能为空") + private Long paymentOrganization; + + // 是否核算后归档 + private boolean fileFlag = false; + +} diff --git a/src/com/engine/salary/entity/siaccount/param/BalanceAccountBaseParam.java b/src/com/engine/salary/entity/siaccount/param/BalanceAccountBaseParam.java new file mode 100644 index 000000000..fb0e402ba --- /dev/null +++ b/src/com/engine/salary/entity/siaccount/param/BalanceAccountBaseParam.java @@ -0,0 +1,64 @@ +package com.engine.salary.entity.siaccount.param; + +import com.engine.salary.util.valid.DataCheck; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + + +/** + * @Author: sy + * @Description: 组装补差基本数据 + * @Date: 2023/11/23 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class BalanceAccountBaseParam { + + //员工id") + private Long employeeId; + + //账单月份") + private String billMonth; + + /** + * 个税扣缴义务人id + */ + @DataCheck(require = true,message = "个税扣缴义务人不能为空") + private Long paymentOrganization; + + + /** + * 社保补缴金额_个人 + */ + private String socialPerJson; + + /** + * 社保补缴金额_单位 + */ + private String socialComJson; + + /** + * 公积金补缴金额_个人 + */ + private String fundPerJson; + + /** + * 公积金补缴金额_单位 + */ + private String fundComJson; + + /** + * 其他福利补缴金额_个人 + */ + private String otherPerJson; + + /** + * 其他福利补缴金额_单位 + */ + private String otherComJson; + +} diff --git a/src/com/engine/salary/entity/siaccount/param/CompensationParam.java b/src/com/engine/salary/entity/siaccount/param/CompensationParam.java new file mode 100644 index 000000000..7eeb7cb8f --- /dev/null +++ b/src/com/engine/salary/entity/siaccount/param/CompensationParam.java @@ -0,0 +1,48 @@ +package com.engine.salary.entity.siaccount.param; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Author: sy + * @Description: 福利台账-调差请求参数 + * @Date: 2022/11/23 + **/ +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder +public class CompensationParam { + + /** + * 缴纳组织 + */ + private Long paymentOrganization; + + /** + * 对象,指InsuranceAccountDetailPO.id + */ + private Long target; + + /** + * 指被调差的人员id + */ + private String employeeId; + + /** + * 账单月份 + */ + private String billMonth; + + /** + * 统计调差福利 + */ + private Integer welfareType; + + /** + * 统计调差福利项,即社保、公积金、其他福利类型下的具体项目 + */ + private String categoryType; +} diff --git a/src/com/engine/salary/entity/siaccount/param/DSTenantKeyThreadVar.java b/src/com/engine/salary/entity/siaccount/param/DSTenantKeyThreadVar.java new file mode 100644 index 000000000..28200f64e --- /dev/null +++ b/src/com/engine/salary/entity/siaccount/param/DSTenantKeyThreadVar.java @@ -0,0 +1,15 @@ +package com.engine.salary.entity.siaccount.param; + +/** + * @Author weaver_cl + * + * @Date 2022/4/13 + * @Version V1.0 + **/ +public class DSTenantKeyThreadVar { + public static ThreadLocal tenantKey = new ThreadLocal(); + public static ThreadLocal notDesensitization = new ThreadLocal(); + + public DSTenantKeyThreadVar() { + } +} diff --git a/src/com/engine/salary/entity/siaccount/param/EditAccountDetailParam.java b/src/com/engine/salary/entity/siaccount/param/EditAccountDetailParam.java new file mode 100644 index 000000000..735da0f7d --- /dev/null +++ b/src/com/engine/salary/entity/siaccount/param/EditAccountDetailParam.java @@ -0,0 +1,32 @@ +package com.engine.salary.entity.siaccount.param; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Author: sy + * @Description: 编辑福利报表 + * @Date: 2022/11/18 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class EditAccountDetailParam { + + private Long id; + + private String socialPerJson; + + private String socialComJson; + + private String fundPerJson; + + private String fundComJson; + + private String otherPerJson; + + private String otherComJson; +} diff --git a/src/com/engine/salary/entity/siaccount/param/ExcelInsuranceImportParam.java b/src/com/engine/salary/entity/siaccount/param/ExcelInsuranceImportParam.java new file mode 100644 index 000000000..7a9090845 --- /dev/null +++ b/src/com/engine/salary/entity/siaccount/param/ExcelInsuranceImportParam.java @@ -0,0 +1,30 @@ +package com.engine.salary.entity.siaccount.param; + +import com.engine.salary.util.valid.DataCheck; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Author: sy + * @Description: 福利核算-线下对比导入参数 + * @Date: 2022/9/27 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class ExcelInsuranceImportParam { + /** + * 上传文件id + */ + @DataCheck(require = true,message = "imageId为空") + String imageId; + + /** + * 账单月份 + */ + private String billMonth; + private String paymentOrganization; +} diff --git a/src/com/engine/salary/entity/siaccount/param/InspectAccountParam.java b/src/com/engine/salary/entity/siaccount/param/InspectAccountParam.java new file mode 100644 index 000000000..d52bcd056 --- /dev/null +++ b/src/com/engine/salary/entity/siaccount/param/InspectAccountParam.java @@ -0,0 +1,32 @@ +package com.engine.salary.entity.siaccount.param; + + +import com.engine.salary.util.valid.DataCheck; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * @Author weaver_cl + * @Description: 核算异常重新核算 + * @Date 2022/4/11 + * @Version V1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class InspectAccountParam { + + //核算异常主键id") + @DataCheck(require = true,message = "主键不能为空") + private List ids; + + //账单月份") + private String billMonth; + + private Long paymentOrganization; +} diff --git a/src/com/engine/salary/entity/siaccount/param/InsuranceAccountBatchParam.java b/src/com/engine/salary/entity/siaccount/param/InsuranceAccountBatchParam.java new file mode 100644 index 000000000..9e3d531aa --- /dev/null +++ b/src/com/engine/salary/entity/siaccount/param/InsuranceAccountBatchParam.java @@ -0,0 +1,32 @@ +package com.engine.salary.entity.siaccount.param; + +import com.engine.salary.common.BaseQueryParam; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * @Author weaver_cl + * + * @Date 2022/4/11 + * @Version V1.0 + **/ +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder +public class InsuranceAccountBatchParam extends BaseQueryParam { + + //开始时间 + private String startTime; + + //结束时间 + private String endTime; + + private List taxAgents; + + private Long paymentOrganization; +} diff --git a/src/com/engine/salary/entity/siaccount/param/InsuranceAccountDetailParam.java b/src/com/engine/salary/entity/siaccount/param/InsuranceAccountDetailParam.java new file mode 100644 index 000000000..d348af32b --- /dev/null +++ b/src/com/engine/salary/entity/siaccount/param/InsuranceAccountDetailParam.java @@ -0,0 +1,51 @@ +package com.engine.salary.entity.siaccount.param; + +import com.engine.salary.common.BaseQueryParam; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * @Author weaver_cl + * + * @Date 2022/4/11 + * @Version V1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class InsuranceAccountDetailParam extends BaseQueryParam { + + private String billMonth; //账单月份 + + private Integer paymentStatus; + + private List employeeIds; + + private String userName; + + private String paymentOrganization; + + /** + * 退差月份 + */ + private List recessionMonthList; + + private List taxAgents; + /** + * 核算创建人 + */ + private Long creator; + + private String workcode; + + private List departmentIds; + private List fixedDepartmentIds; + + private List subCompanyIds; + private List fixedSubCompanyIds; +} diff --git a/src/com/engine/salary/entity/siaccount/param/InsuranceAcctDetailImportTemplateParam.java b/src/com/engine/salary/entity/siaccount/param/InsuranceAcctDetailImportTemplateParam.java new file mode 100644 index 000000000..f0e92c62c --- /dev/null +++ b/src/com/engine/salary/entity/siaccount/param/InsuranceAcctDetailImportTemplateParam.java @@ -0,0 +1,29 @@ +package com.engine.salary.entity.siaccount.param; + +import com.engine.salary.util.valid.DataCheck; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +import java.util.Collection; +import java.util.List; + + +@Getter +@Setter +@NoArgsConstructor +@AllArgsConstructor +public class InsuranceAcctDetailImportTemplateParam { + + + /** + * 薪资项目id(薪资项目包含了福利项) + */ + @DataCheck(require = true,message = "福利核算项目name不能为空") + private List welfareNames; + + private String billMonth; + + private Long paymentOrganization; +} diff --git a/src/com/engine/salary/entity/siaccount/param/InsuranceAcctImportParam.java b/src/com/engine/salary/entity/siaccount/param/InsuranceAcctImportParam.java new file mode 100644 index 000000000..5f690e8db --- /dev/null +++ b/src/com/engine/salary/entity/siaccount/param/InsuranceAcctImportParam.java @@ -0,0 +1,27 @@ +package com.engine.salary.entity.siaccount.param; + +import com.engine.salary.util.valid.DataCheck; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Author sy + * @Description 福利核算导入参数 + * @Date 2022/9/1 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class InsuranceAcctImportParam { + + /** + * 上传文件id + */ + @DataCheck(require = true,message = "imageId为空") + String imageId; + + private String billMonth; +} diff --git a/src/com/engine/salary/entity/siaccount/param/InsuranceComparisonResultQueryParam.java b/src/com/engine/salary/entity/siaccount/param/InsuranceComparisonResultQueryParam.java new file mode 100644 index 000000000..703db7f76 --- /dev/null +++ b/src/com/engine/salary/entity/siaccount/param/InsuranceComparisonResultQueryParam.java @@ -0,0 +1,20 @@ +package com.engine.salary.entity.siaccount.param; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * @Author: sy + * @Description: 福利台账-线上线下对比结果查询参数 + * @Date: 2022/9/28 + **/ +@Data +@EqualsAndHashCode(callSuper = true) +public class InsuranceComparisonResultQueryParam extends InsuranceAccountDetailParam{ + + //仅显示有差异的人员") + private boolean onlyDiffEmployee; + + //仅显示有差异的薪资项目") +// private boolean onlyDiffSalaryItem; +} diff --git a/src/com/engine/salary/entity/siaccount/param/Permission.java b/src/com/engine/salary/entity/siaccount/param/Permission.java new file mode 100644 index 000000000..6b174e503 --- /dev/null +++ b/src/com/engine/salary/entity/siaccount/param/Permission.java @@ -0,0 +1,39 @@ +package com.engine.salary.entity.siaccount.param; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Author weaver_cl + * + * @Date 2022/4/12 + * @Version V1.0 + **/ +@Data +@Builder +public class Permission { + + private boolean visible; + + private boolean disabled; + + public Permission() { + this.visible = Boolean.TRUE; + this.disabled = Boolean.FALSE; + } + + public Permission(boolean visible) { + this.visible = Boolean.TRUE; + this.disabled = Boolean.FALSE; + this.visible = visible; + } + + public Permission(boolean visible, boolean disabled) { + this.visible = Boolean.TRUE; + this.disabled = Boolean.FALSE; + this.visible = visible; + this.disabled = disabled; + } +} diff --git a/src/com/engine/salary/entity/siaccount/param/QueryAccountDetailParam.java b/src/com/engine/salary/entity/siaccount/param/QueryAccountDetailParam.java new file mode 100644 index 000000000..49f5a7614 --- /dev/null +++ b/src/com/engine/salary/entity/siaccount/param/QueryAccountDetailParam.java @@ -0,0 +1,25 @@ +package com.engine.salary.entity.siaccount.param; + +import com.engine.salary.common.BaseQueryParam; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 查询福利报表 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class QueryAccountDetailParam extends BaseQueryParam { + String startMonth; + String endMonth; + Long employeeId; +} diff --git a/src/com/engine/salary/entity/siaccount/param/RecessionParam.java b/src/com/engine/salary/entity/siaccount/param/RecessionParam.java new file mode 100644 index 000000000..d1674bea4 --- /dev/null +++ b/src/com/engine/salary/entity/siaccount/param/RecessionParam.java @@ -0,0 +1,47 @@ +package com.engine.salary.entity.siaccount.param; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * @Author: sy + * @Description: 社保福利台账-退差请求体 + * @Date: 2022/11/15 + **/ +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder +public class RecessionParam { + + /** + * 退差月份 + */ + private List recessionMonthList; + + /** + * 退差项目 + */ + private List projects; + + /** + * 包含人员 + */ + private List includes; + + /** + * 排除人员 + */ + private List excludes; + + /** + * 账单月份 + */ + private String billMonth; + + private String paymentOrganization; +} diff --git a/src/com/engine/salary/entity/siaccount/param/SaveCommonAccountParam.java b/src/com/engine/salary/entity/siaccount/param/SaveCommonAccountParam.java new file mode 100644 index 000000000..bdc64065c --- /dev/null +++ b/src/com/engine/salary/entity/siaccount/param/SaveCommonAccountParam.java @@ -0,0 +1,40 @@ +package com.engine.salary.entity.siaccount.param; + +import com.engine.salary.util.valid.DataCheck; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * @Author weaver_cl + * @Description: 添加正常缴纳 + * @Date 2022/4/11 + * @Version V1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SaveCommonAccountParam { + + //包含人员") + private List includes; + + //剔除人员") + private List excludes; + + //账单月份") + private String billMonth; + + //删除人员的福利核算明细表id hrsa_bill_detail.id + private List ids; + + /** + * 个税扣缴义务人id + */ + @DataCheck(require = true,message = "个税扣缴义务人不能为空") + private Long paymentOrganization; +} diff --git a/src/com/engine/salary/entity/siaccount/param/SaveSupplementaryAccountParam.java b/src/com/engine/salary/entity/siaccount/param/SaveSupplementaryAccountParam.java new file mode 100644 index 000000000..097cf94fe --- /dev/null +++ b/src/com/engine/salary/entity/siaccount/param/SaveSupplementaryAccountParam.java @@ -0,0 +1,98 @@ +package com.engine.salary.entity.siaccount.param; + +import com.alibaba.fastjson.annotation.JSONField; +import com.alibaba.fastjson.serializer.ToStringSerializer; +import com.engine.salary.util.valid.DataCheck; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * @Author weaver_cl + * @Description: 添加补缴核算人员 + * @Date 2022/4/11 + * @Version V1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SaveSupplementaryAccountParam { + + //补缴月份") + private List billMonthList; + + //补缴项目") + @JSONField(serializeUsing = ToStringSerializer.class) + private List projects; + + //包含人员") + @JSONField(serializeUsing = ToStringSerializer.class) + private List includes; + + //排除人员") + @JSONField(serializeUsing = ToStringSerializer.class) + private List excludes; + + //账单月份") + private String billMonth; + + /** + * 个税扣缴义务人id + */ + @DataCheck(require = true,message = "个税扣缴义务人不能为空") + private Long paymentOrganization; + + /** + * 社保补缴基数 + */ + private String socialPaymentBaseString; + + /** + * 公积金补缴基数 + */ + private String fundPaymentBaseString; + + /** + * 其他福利补缴基数 + */ + private String otherPaymentBaseString; + + /** + * 社保补缴金额_个人 + */ + private String socialPaymentPerString; + + /** + * 社保补缴金额_单位 + */ + private String socialPaymentComString; + + /** + * 公积金补缴金额_个人 + */ + private String fundPaymentPerString; + + /** + * 公积金补缴金额_单位 + */ + private String fundPaymentComString; + + /** + * 其他福利补缴金额_个人 + */ + private String otherPaymentPerString; + + /** + * 其他福利补缴金额_单位 + */ + private String otherPaymentComString; + + /** + * 补缴类型 + */ + private String supplementType; +} diff --git a/src/com/engine/salary/entity/siaccount/param/SupplementAccountBaseParam.java b/src/com/engine/salary/entity/siaccount/param/SupplementAccountBaseParam.java new file mode 100644 index 000000000..7b42531c7 --- /dev/null +++ b/src/com/engine/salary/entity/siaccount/param/SupplementAccountBaseParam.java @@ -0,0 +1,101 @@ +package com.engine.salary.entity.siaccount.param; + +import com.engine.salary.util.valid.DataCheck; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * @Author weaver_cl + * @Description: 组装补缴基本数据 + * @Date 2022/4/11 + * @Version V1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SupplementAccountBaseParam { + + //员工id") + private Long employeeId; + + //账单月份") + private String billMonth; + + /** + * 个税扣缴义务人id + */ + @DataCheck(require = true,message = "个税扣缴义务人不能为空") + private Long paymentOrganization; + + //补缴月份") + private String supplementaryMonth; + + //补缴项目") + private List projects; + + /** + * 社保补缴基数 + */ + private String socialPaymentBaseString; + + /** + * 公积金补缴基数 + */ + private String fundPaymentBaseString; + + /** + * 其他福利补缴基数 + */ + private String otherPaymentBaseString; + + /** + * 社保补缴金额_个人 + */ + private String socialPaymentPerString; + + /** + * 社保补缴金额_单位 + */ + private String socialPaymentComString; + + /** + * 公积金补缴金额_个人 + */ + private String fundPaymentPerString; + + /** + * 公积金补缴金额_单位 + */ + private String fundPaymentComString; + + /** + * 其他福利补缴金额_个人 + */ + private String otherPaymentPerString; + + /** + * 其他福利补缴金额_单位 + */ + private String otherPaymentComString; + + /** + * 补缴类型 + */ + private String supplementType; + + + private String subcompanyName; + private Long subcompanyId; + private String departmentName; + private Long departmentId; + private String jobtitleName; + private Long jobtitleId; + private String jobcall; + private Long jobcallId; + private String status; +} diff --git a/src/com/engine/salary/entity/siaccount/po/ExcelInsuranceDetailPO.java b/src/com/engine/salary/entity/siaccount/po/ExcelInsuranceDetailPO.java new file mode 100644 index 000000000..9660b8602 --- /dev/null +++ b/src/com/engine/salary/entity/siaccount/po/ExcelInsuranceDetailPO.java @@ -0,0 +1,277 @@ +package com.engine.salary.entity.siaccount.po; + +import com.engine.salary.annotation.Encrypt; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; + +/** + * @Author: sy + * @Description: 线下Excel福利明细表 + * @Date: 2022/9/27 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//hrsa_excel_bill_detail +public class ExcelInsuranceDetailPO { + + /** + * 主键id + */ + private Long id; + + /** + * 员工id + */ + private Long employeeId; + + /** + * 账单月份,该处的账单月份即导入的数据需要对比的账单月份 + */ + private String billMonth; + + /** + * 账单状态 0-未归档 1-已归档 + */ + private Integer billStatus; + + /** + * 缴纳状态 + */ + private Integer paymentStatus; + + /** + * 补缴月份 + */ + private String supplementaryMonth; + + /** + * 补缴项目 + */ + private String supplementaryProjects; + + /** + * 数据来源 0-系统核算 1-临时数据 + */ + private Integer resourceFrom; + + /** + * 社保缴纳组织 + */ + private Long socialPayOrg; + + /** + * 社保账号 + */ + private String socialAccount; + + /** + * 公积金缴纳组织 + */ + private Long fundPayOrg; + + /** + * 公积金账号 + */ + private String fundAccount; + + /** + * 补充公积金账号 + */ + private String supplementFundAccount; + + /** + * 其他福利缴纳组织 + */ + private Long otherPayOrg; + + /** + * 社保方案ID + */ + private Long socialSchemeId; + + /** + * 社保缴纳基数 + */ + @Encrypt + private String socialPaymentBaseString; + + /** + * 社保缴纳基数——单位 + */ + @Encrypt + private String socialPaymentComBaseString; + + /** + * 公积金方案ID + */ + private Long fundSchemeId; + + /** + * 公积金缴纳基数 + */ + @Encrypt + private String fundPaymentBaseString; + + /** + * 公积金缴纳基数——单位 + */ + @Encrypt + private String fundPaymentComBaseString; + + /** + * 其他福利方案id + */ + private Long otherSchemeId; + + /** + * 其他福利缴纳基数 + */ + @Encrypt + private String otherPaymentBaseString; + + /** + * 其他福利缴纳基数——单位 + */ + @Encrypt + private String otherPaymentComBaseString; + + /** + * 社保个人缴费明细 + */ + @Encrypt + private String socialPerJson; + + /** + * 社保个人合计 + */ + @Encrypt + private String socialPerSum; + + /** + * 公积金个人缴费明细 + */ + @Encrypt + private String fundPerJson; + + /** + * 公积金个人合计 + */ + @Encrypt + private String fundPerSum; + + /** + * 其他福利个人缴费明细 + */ + @Encrypt + private String otherPerJson; + + /** + * 其他福利个人合计 + */ + @Encrypt + private String otherPerSum; + + /** + * 个人合计 + */ + @Encrypt + private String perSum; + + /** + * 社保单位缴费明细 + */ + @Encrypt + private String socialComJson; + + /** + * 社保单位合计 + */ + @Encrypt + private String socialComSum; + + /** + * 公积金单位缴费明细 + */ + private String fundComJson; + + /** + * 公积金单位合计 + */ + private String fundComSum; + + /** + * 其他福利单位缴费明细 + */ + private String otherComJson; + + /** + * 其他福利单位合计 + */ + private String otherComSum; + + /** + * 单位合计 + */ + @Encrypt + private String comSum; + + /** + * 社保合计 + */ + @Encrypt + private String socialSum; + + /** + * 公积金合计 + */ + @Encrypt + private String fundSum; + + /** + * 其他福利合计 + */ + @Encrypt + private String otherSum; + + /** + * 合计 + */ + @Encrypt + private String total; + + /** + * 创建人id + */ + private Long creator; + + /** + * 是否删除 + */ + private Integer deleteType; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 更新时间 + */ + private Date updateTime; + + /** + * 租户key + */ + private String tenantKey; + + /** + * 个税扣缴义务人 + */ + private Long paymentOrganization; +} diff --git a/src/com/engine/salary/entity/siaccount/po/InsuranceAccountBatchPO.java b/src/com/engine/salary/entity/siaccount/po/InsuranceAccountBatchPO.java new file mode 100644 index 000000000..5b610e6da --- /dev/null +++ b/src/com/engine/salary/entity/siaccount/po/InsuranceAccountBatchPO.java @@ -0,0 +1,149 @@ +package com.engine.salary.entity.siaccount.po; + +import com.engine.hrmelog.annotation.ElogTransform; +import com.engine.salary.annotation.Auth; +import com.engine.salary.annotation.Encrypt; +import com.engine.salary.enums.auth.AuthCheckTypeEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; +import java.util.Set; + + +/** + * @Author weaver_cl + * @Description: 核算主表 hrsa_bill_batch + * @Date 2022/4/11 + * @Version V1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//hrsa_bill_batch +@ElogTransform(name = "福利台账主表") +@Auth(page = "siAccount", checkType = AuthCheckTypeEnum.TAX, taxAgentIdField = "paymentOrganization") +public class InsuranceAccountBatchPO { + + /** + * 主键id + */ + @ElogTransform(name = "主键id") + private Long id; + + /** + * 账单月份 + */ + @ElogTransform(name = "账单月份") + private String billMonth; + + /** + * 账单状态 0-未归档 1-已归档 + */ + @ElogTransform(name = "账单状态") + private Integer billStatus; + + /** + * 社保核算人数 + */ + @ElogTransform(name = "社保核算人数") + private Integer socialNum; + + /** + * 公积金核算人数 + */ + @ElogTransform(name = "公积金核算人数") + private Integer fundNum; + + /** + * 其他福利核算人数 + */ + @ElogTransform(name = "其他福利核算人数") + private Integer otherNum; + + /** + * 社保缴费总额(单位+个人) + */ + @Encrypt + @ElogTransform(name = "社保缴费总额(单位+个人)") + private String socialPay; + + /** + * 公积金缴费总额(单位+个人) + */ + @Encrypt + @ElogTransform(name = "公积金缴费总额(单位+个人)") + private String fundPay; + + /** + * 其他福利缴费总额(单位+个人) + */ + @Encrypt + @ElogTransform(name = "其他福利缴费总额(单位+个人)") + private String otherPay; + + /** + * 核算人 + */ + @ElogTransform(name = "核算人") + private String accountant; + + /** + * 备注 + */ + @ElogTransform(name = "备注") + private String remarks; + + /** + * 创建人id + */ + @ElogTransform(name = "创建人id") + private Long creator; + + /** + * 是否删除 + */ + @ElogTransform(name = "是否删除") + private Integer deleteType; + + /** + * 创建时间 + */ + @ElogTransform(name = "创建时间") + private Date createTime; + + /** + * 更新时间 + */ + @ElogTransform(name = "更新时间") + private Date updateTime; + + /** + * 租户key + */ + @ElogTransform(name = "租户key") + private String tenantKey; + + /** + * 个税扣缴义务人 + */ + @ElogTransform(name = "个税扣缴义务人id") + private Long paymentOrganization; + + private String subcompanyName; + private Long subcompanyId; + private String departmentName; + private Long departmentId; + private String jobtitleName; + private Long jobtitleId; + private String jobcall; + private Long jobcallId; + private String status; + + + private Set opts; + +} diff --git a/src/com/engine/salary/entity/siaccount/po/InsuranceAccountDetailPO.java b/src/com/engine/salary/entity/siaccount/po/InsuranceAccountDetailPO.java new file mode 100644 index 000000000..310009f9c --- /dev/null +++ b/src/com/engine/salary/entity/siaccount/po/InsuranceAccountDetailPO.java @@ -0,0 +1,341 @@ +package com.engine.salary.entity.siaccount.po; + +import com.cloudstore.eccom.pc.table.WeaTableType; +import com.engine.salary.annotation.Encrypt; +import com.engine.salary.annotation.SalaryTable; +import com.engine.hrmelog.annotation.ElogTransform; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; + + +/** + * @Author weaver_cl + * @Description: 核算明细表 hrsa_bill_detail + * @Date 2022/4/11 + * @Version V1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@SalaryTable(pageId = "2394fba1-1381-428a-8532-4e1e6b86626e", tableType = WeaTableType.CHECKBOX) +//hrsa_bill_detail +@ElogTransform(name = "福利台账明细表") +public class InsuranceAccountDetailPO { + + /** + * 主键id + */ + @ElogTransform(name = "主键id") + private Long id; + + /** + * 员工id + */ + @ElogTransform(name = "员工id") + private Long employeeId; + + /** + * 账单月份 + */ + @ElogTransform(name = "账单月份") + private String billMonth; + + /** + * 账单状态 0-未归档 1-已归档 + */ + @ElogTransform(name = "账单状态") + private Integer billStatus; + + /** + * 缴纳状态 + */ + @ElogTransform(name = "缴纳状态") + private Integer paymentStatus; + + /** + * 补缴月份/退差月份 + */ + @ElogTransform(name = "补缴月份/退差月份") + private String supplementaryMonth; + + /** + * 补缴项目 + */ + @ElogTransform(name = "补缴项目") + private String supplementaryProjects; + + /** + * 数据来源 0-系统核算 1-临时数据 + */ + @ElogTransform(name = "数据来源") + private Integer resourceFrom; + + /** + * 社保缴纳组织 + */ + @ElogTransform(name = "社保缴纳组织") + private Long socialPayOrg; + + /** + * 社保账号 + */ + @ElogTransform(name = "社保账号") + private String socialAccount; + + /** + * 公积金缴纳组织 + */ + @ElogTransform(name = "公积金缴纳组织") + private Long fundPayOrg; + + /** + * 公积金账号 + */ + @ElogTransform(name = "公积金账号") + private String fundAccount; + + /** + * 补充公积金账号 + */ + @ElogTransform(name = "补充公积金账号") + private String supplementFundAccount; + + /** + * 其他福利缴纳组织 + */ + @ElogTransform(name = "其他福利缴纳组织") + private Long otherPayOrg; + + /** + * 社保方案ID + */ + @ElogTransform(name = "社保方案ID") + private Long socialSchemeId; + + /** + * 社保缴纳基数 + */ + @Encrypt + @ElogTransform(name = "社保缴纳基数") + private String socialPaymentBaseString; + + /** + * 社保缴纳基数——单位 + */ + @Encrypt + @ElogTransform(name = "社保缴纳基数——单位") + private String socialPaymentComBaseString; + + /** + * 公积金方案ID + */ + @ElogTransform(name = "公积金方案ID") + private Long fundSchemeId; + + /** + * 公积金缴纳基数 + */ + @Encrypt + @ElogTransform(name = "公积金缴纳基数") + private String fundPaymentBaseString; + + /** + * 公积金缴纳基数——单位 + */ + @Encrypt + @ElogTransform(name = "公积金缴纳基数——单位") + private String fundPaymentComBaseString; + + /** + * 其他福利方案id + */ + @ElogTransform(name = "其他福利方案id") + private Long otherSchemeId; + + /** + * 其他福利缴纳基数 + */ + @Encrypt + @ElogTransform(name = "其他福利缴纳基数") + private String otherPaymentBaseString; + + /** + * 其他福利缴纳基数——单位 + */ + @Encrypt + @ElogTransform(name = "其他福利缴纳基数——单位") + private String otherPaymentComBaseString; + + /** + * 社保个人缴费明细 + */ + @Encrypt + @ElogTransform(name = "社保个人缴费明细") + private String socialPerJson; + + /** + * 社保个人合计 + */ + @Encrypt + @ElogTransform(name = "社保个人合计") + private String socialPerSum; + + /** + * 公积金个人缴费明细 + */ + @Encrypt + @ElogTransform(name = "公积金个人缴费明细") + private String fundPerJson; + + /** + * 公积金个人合计 + */ + @Encrypt + @ElogTransform(name = "公积金个人合计") + private String fundPerSum; + + /** + * 其他福利个人缴费明细 + */ + @Encrypt + @ElogTransform(name = "其他福利个人缴费明细") + private String otherPerJson; + + /** + * 其他福利个人合计 + */ + @Encrypt + @ElogTransform(name = "其他福利个人合计") + private String otherPerSum; + + /** + * 个人合计 + */ + @Encrypt + @ElogTransform(name = "个人合计") + private String perSum; + + /** + * 社保单位缴费明细 + */ + @Encrypt + @ElogTransform(name = "社保单位缴费明细") + private String socialComJson; + + /** + * 社保单位合计 + */ + @Encrypt + @ElogTransform(name = "社保单位合计") + private String socialComSum; + + /** + * 公积金单位缴费明细 + */ + @ElogTransform(name = "公积金单位缴费明细") + private String fundComJson; + + /** + * 公积金单位合计 + */ + @ElogTransform(name = "公积金单位合计") + private String fundComSum; + + /** + * 其他福利单位缴费明细 + */ + @ElogTransform(name = "其他福利单位缴费明细") + private String otherComJson; + + /** + * 其他福利单位合计 + */ + @ElogTransform(name = "其他福利单位合计") + private String otherComSum; + + /** + * 单位合计 + */ + @Encrypt + @ElogTransform(name = "单位合计") + private String comSum; + + /** + * 社保合计 + */ + @Encrypt + @ElogTransform(name = "社保合计") + private String socialSum; + + /** + * 公积金合计 + */ + @Encrypt + @ElogTransform(name = "公积金合计") + private String fundSum; + + /** + * 其他福利合计 + */ + @Encrypt + @ElogTransform(name = "其他福利合计") + private String otherSum; + + /** + * 合计 + */ + @Encrypt + @ElogTransform(name = "合计") + private String total; + + /** + * 创建人id + */ + @ElogTransform(name = "创建人id") + private Long creator; + + /** + * 是否删除 + */ + @ElogTransform(name = "是否删除") + private Integer deleteType; + + /** + * 创建时间 + */ + @ElogTransform(name = "创建时间") + private Date createTime; + + /** + * 更新时间 + */ + @ElogTransform(name = "更新时间") + private Date updateTime; + + /** + * 租户key + */ + @ElogTransform(name = "租户key") + private String tenantKey; + + /** + * 个税扣缴义务人 + */ + @ElogTransform(name = "个税扣缴义务人") + private Long paymentOrganization; + + private String subcompanyName; + private Long subcompanyId; + private String departmentName; + private Long departmentId; + private String jobtitleName; + private Long jobtitleId; + private String jobcall; + private Long jobcallId; + private String status; +} diff --git a/src/com/engine/salary/entity/siaccount/po/InsuranceAccountDetailTempPO.java b/src/com/engine/salary/entity/siaccount/po/InsuranceAccountDetailTempPO.java new file mode 100644 index 000000000..8d6d5254f --- /dev/null +++ b/src/com/engine/salary/entity/siaccount/po/InsuranceAccountDetailTempPO.java @@ -0,0 +1,289 @@ +package com.engine.salary.entity.siaccount.po; + +import com.engine.salary.annotation.Encrypt; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; + + +/** + * @Author weaver_cl + * @Description: 核算明细临时表 hrsa_bill_detail_temp + * @Date 2022/4/11 + * @Version V1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class InsuranceAccountDetailTempPO { + + /** + * 主键id + */ + private Long id; + + /** + * 员工id + */ + private Long employeeId; + + /** + * 账单月份 + */ + private String billMonth; + + /** + * 账单状态 0-未归档 1-已归档 + */ + private Integer billStatus; + + /** + * 缴纳状态 + */ + private Integer paymentStatus; + + /** + * 补缴月份 + */ + private String supplementaryMonth; + + /** + * 补缴项目 + */ + private String supplementaryProjects; + + /** + * 数据来源 0-系统核算 1-临时数据 + */ + private Integer resourceFrom; + + /** + * 社保缴纳组织 + */ + private Long socialPayOrg; + + /** + * 社保账号 + */ + private String socialAccount; + + /** + * 公积金缴纳组织 + */ + private Long fundPayOrg; + + /** + * 公积金账号 + */ + private String fundAccount; + + /** + * 补充公积金账号 + */ + private String supplementFundAccount; + + /** + * 其他福利缴纳组织 + */ + private Long otherPayOrg; + + /** + * 社保方案ID + */ + private Long socialSchemeId; + + /** + * 社保缴纳基数 + */ + @Encrypt + private String socialPaymentBaseString; + + /** + * 社保缴纳基数——单位 + */ + @Encrypt + private String socialPaymentComBaseString; + /** + * 公积金方案ID + */ + private Long fundSchemeId; + + /** + * 公积金缴纳基数 + */ + @Encrypt + private String fundPaymentBaseString; + + /** + * 公积金缴纳基数——单位 + */ + @Encrypt + private String fundPaymentComBaseString; + + /** + * 其他福利方案id + */ + private Long otherSchemeId; + + /** + * 其他福利缴纳基数 + */ + @Encrypt + private String otherPaymentBaseString; + + /** + * 其他福利缴纳基数——单位 + */ + @Encrypt + private String otherPaymentComBaseString; + + + /** + * 社保个人缴费明细 + */ + @Encrypt + private String socialPerJson; + + /** + * 社保个人合计 + */ + @Encrypt + private String socialPerSum; + + /** + * 公积金个人缴费明细 + */ + @Encrypt + private String fundPerJson; + + /** + * 公积金个人合计 + */ + @Encrypt + private String fundPerSum; + + /** + * 其他福利个人缴费明细 + */ + @Encrypt + private String otherPerJson; + + /** + * 其他福利个人合计 + */ + @Encrypt + private String otherPerSum; + + /** + * 个人合计 + */ + @Encrypt + private String perSum; + + /** + * 社保单位缴费明细 + */ + @Encrypt + private String socialComJson; + + /** + * 社保单位合计 + */ + @Encrypt + private String socialComSum; + + /** + * 公积金单位缴费明细 + */ + private String fundComJson; + + /** + * 公积金单位合计 + */ + private String fundComSum; + + /** + * 其他福利单位缴费明细 + */ + private String otherComJson; + + /** + * 其他福利单位合计 + */ + private String otherComSum; + + /** + * 单位合计 + */ + @Encrypt + private String comSum; + + /** + * 社保合计 + */ + @Encrypt + private String socialSum; + + /** + * 公积金合计 + */ + @Encrypt + private String fundSum; + + /** + * 其他福利合计 + */ + @Encrypt + private String otherSum; + + /** + * 合计 + */ + @Encrypt + private String total; + + /** + * 创建人id + */ + private Long creator; + + /** + * 是否删除 + */ + private Integer deleteType; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 更新时间 + */ + private Date updateTime; + + /** + * 租户key + */ + private String tenantKey; + + /** + * 个税扣缴义务人 + */ + private Long paymentOrganization; + + + private String subcompanyName; + private Long subcompanyId; + private String departmentName; + private Long departmentId; + private String jobtitleName; + private Long jobtitleId; + private String jobcall; + private Long jobcallId; + private String status; +} diff --git a/src/com/engine/salary/entity/siaccount/po/InsuranceAccountInspectPO.java b/src/com/engine/salary/entity/siaccount/po/InsuranceAccountInspectPO.java new file mode 100644 index 000000000..b82f082a8 --- /dev/null +++ b/src/com/engine/salary/entity/siaccount/po/InsuranceAccountInspectPO.java @@ -0,0 +1,82 @@ +package com.engine.salary.entity.siaccount.po; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; + +/** + * @Author weaver_cl + * @Description: hrsa_bill_inspect 核算检查明细表 + * @Date 2022/4/11 + * @Version V1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//hrsa_bill_inspect +public class InsuranceAccountInspectPO { + + /** + * 主键id + */ + private Long id; + + /** + * 员工id + */ + private Long employeeId; + + /** + * 账单月份 + */ + private String billMonth; + + /** + * 缴纳状态 + */ + private Integer paymentStatus; + + /** + * 审核状态 0-忽略 1-重置 + */ + private Integer inspectStatus; + + /** + * 补缴月份 + */ + private String supplementaryMonth; + + /** + * 补缴项目 + */ + private String supplementaryProjects; + + /** + * 创建人id + */ + private Long creator; + + /** + * 是否删除 + */ + private Integer deleteType; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 更新时间 + */ + private Date updateTime; + + /** + * 租户key + */ + private String tenantKey; +} diff --git a/src/com/engine/salary/entity/siaccount/po/InsuranceCompensationConfigPO.java b/src/com/engine/salary/entity/siaccount/po/InsuranceCompensationConfigPO.java new file mode 100644 index 000000000..7bf4e8a79 --- /dev/null +++ b/src/com/engine/salary/entity/siaccount/po/InsuranceCompensationConfigPO.java @@ -0,0 +1,80 @@ +package com.engine.salary.entity.siaccount.po; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; + +/** + * @Author: sy + * @Description: 社保福利台账-调差配置表 + * @Date: 2022/11/28 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//hrsa_compensation_config +public class InsuranceCompensationConfigPO { + /** + * 主键id + */ + private Long id; + + /** + * 缴纳组织 + */ + private Long paymentAgency; + + /** + * 个税扣缴义务人 + */ + private Long paymentOrganization; + + /** + * 创建人id + */ + private Long creator; + + /** + * 是否删除 + */ + private Integer deleteType; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 更新时间 + */ + private Date updateTime; + + /** + * 租户key + */ + private String tenantKey; + + /** + * 统计调差福利 + */ + private Integer welfareType; + + /** + * 统计调差福利类型 + */ + private String categoryType; + + /** + * 调差到 + */ + private Long adjustTo; + + /** + * 员工id + */ + private Long employeeId; +} diff --git a/src/com/engine/salary/entity/siaccount/po/InsuranceCompensationPO.java b/src/com/engine/salary/entity/siaccount/po/InsuranceCompensationPO.java new file mode 100644 index 000000000..c4e8b1fe7 --- /dev/null +++ b/src/com/engine/salary/entity/siaccount/po/InsuranceCompensationPO.java @@ -0,0 +1,124 @@ +package com.engine.salary.entity.siaccount.po; + +import com.engine.hrmelog.annotation.ElogTransform; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.Date; + +/** + * @Author: sy + * @Description: 社保福利台账-调差历史记录表 + * @Date: 2022/11/23 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//hrsa_compensation_log +@ElogTransform(name = "福利台账-调差历史表") +public class InsuranceCompensationPO { + + /** + * 主键id + */ + @ElogTransform(name = "主键id") + private Long id; + + /** + * 缴纳组织 + */ + @ElogTransform(name = "缴纳组织") + private Long paymentAgency; + + /** + * 个税扣缴义务人 + */ + @ElogTransform(name = "个税扣缴义务人id") + private Long paymentOrganization; + + /** + * 创建人id + */ + @ElogTransform(name = "创建人id") + private Long creator; + + /** + * 是否删除 + */ + @ElogTransform(name = "是否删除") + private Integer deleteType; + + /** + * 创建时间 + */ + @ElogTransform(name = "创建时间") + private Date createTime; + + /** + * 更新时间 + */ + @ElogTransform(name = "更新时间") + private Date updateTime; + + /** + * 租户key + */ + @ElogTransform(name = "租户key") + private String tenantKey; + + /** + * 员工id + */ + @ElogTransform(name = "员工id") + private Long employeeId; + + /** + * 统计调差福利 + */ + @ElogTransform(name = "统计调差福利") + private Integer welfareType; + + /** + * 统计调差福利类型 + */ + @ElogTransform(name = "统计调差福利类型") + private String categoryType; + + /** + * 国家核算金额 + */ + @ElogTransform(name = "国家核算金额") + private String countryTotal; + + /** + * 公司核算金额 + */ + @ElogTransform(name = "公司核算金额") + private String companyTotal; + + /** + * 应调差额 + */ + @ElogTransform(name = "应调差额") + private String adjustmentTotal; + + /** + * 调差到 + */ + @ElogTransform(name = "调差到") + private Long adjustTo; + + /** + * 账单月份 + */ + @ElogTransform(name = "账单月份") + private String billMonth; + + //---------条件------- + private Collection ids; + private Collection employeeIds; +} diff --git a/src/com/engine/salary/entity/siarchives/bo/InsuranceArchivesBO.java b/src/com/engine/salary/entity/siarchives/bo/InsuranceArchivesBO.java new file mode 100644 index 000000000..710038513 --- /dev/null +++ b/src/com/engine/salary/entity/siarchives/bo/InsuranceArchivesBO.java @@ -0,0 +1,85 @@ +package com.engine.salary.entity.siarchives.bo; + +import com.engine.salary.entity.siarchives.dto.InsuranceArchivesFundSchemeDTO; +import com.engine.salary.entity.siarchives.dto.InsuranceArchivesOtherSchemeDTO; +import com.engine.salary.entity.siarchives.dto.InsuranceArchivesSocialSchemeDTO; +import com.engine.salary.entity.siarchives.po.InsuranceArchivesFundSchemePO; +import com.engine.salary.entity.siarchives.po.InsuranceArchivesOtherSchemePO; +import com.engine.salary.entity.siarchives.po.InsuranceArchivesSocialSchemePO; +import com.engine.salary.enums.sicategory.WelfareTypeEnum; +import com.engine.salary.util.SalaryEnumUtil; + +import java.util.Objects; + +/** + * @Author weaver_cl + * @Description: + * @Date 2022/3/15 + * @Version V1.0 + **/ +public class InsuranceArchivesBO { + + public static InsuranceArchivesSocialSchemeDTO convertSocialPOtoDTO(InsuranceArchivesSocialSchemePO po, Long employeeId) { + if (Objects.isNull(po)) { + return InsuranceArchivesSocialSchemeDTO.builder().build(); + } + return InsuranceArchivesSocialSchemeDTO.builder() + .socialName(po.getSocialSchemeId() == null ? null : String.valueOf(po.getSocialSchemeId())) + .socialSchemeId(po.getSocialSchemeId()) + .welfareType(SalaryEnumUtil.enumMatchByValue(po.getWelfareType(), WelfareTypeEnum.values(), WelfareTypeEnum.class)) + .id(po.getId()) + .employeeId(po.getEmployeeId()) + .nonPayment(po.getNonPayment()) + .paymentOrganization(po.getPaymentOrganization()) + .socialEndTime(po.getSocialEndTime()) + .socialStartTime(po.getSocialStartTime()) + .schemeAccount(po.getSocialAccount()) + .schemePaymentBaseString(po.getSocialPaymentBaseString()) + .schemePaymentComBaseString(po.getSocialPaymentComBaseString()) + .underTake(po.getUnderTake() == null ? null : String.valueOf(po.getUnderTake())) + .build(); + } + + + public static InsuranceArchivesFundSchemeDTO convertFundPOtoDTO(InsuranceArchivesFundSchemePO po, Long employeeId) { + if (Objects.isNull(po)) { + return InsuranceArchivesFundSchemeDTO.builder().build(); + } + return InsuranceArchivesFundSchemeDTO.builder() + .id(po.getId()) + .employeeId(po.getEmployeeId()) + .fundAccount(po.getFundAccount()) + .fundEndTime(po.getFundEndTime()) + .fundSchemeId(po.getFundSchemeId()) + .paymentOrganization(po.getPaymentOrganization()) + .fundPaymentBaseString(po.getFundPaymentBaseString()) + .fundPaymentComBaseString(po.getFundPaymentComBaseString()) + .fundStartTime(po.getFundStartTime()) + .supplementFundAccount(po.getSupplementFundAccount()) + .nonPayment(po.getNonPayment()) + .underTake(po.getUnderTake() == null ? null : String.valueOf(po.getUnderTake())) + .welfareType(SalaryEnumUtil.enumMatchByValue(po.getWelfareType(), WelfareTypeEnum.values(), WelfareTypeEnum.class)) + .build(); + } + + public static InsuranceArchivesOtherSchemeDTO convertOtherPOtoDTO(InsuranceArchivesOtherSchemePO po, Long employeeId) { + if (Objects.isNull(po)) { + return InsuranceArchivesOtherSchemeDTO.builder().build(); + } + return InsuranceArchivesOtherSchemeDTO.builder() + .id(po.getId()) + .employeeId(po.getEmployeeId()) + .underTake(po.getUnderTake() == null ? null : String.valueOf(po.getUnderTake())) + .nonPayment(po.getNonPayment()) + .otherName(po.getOtherSchemeId() == null ? null : String.valueOf(po.getOtherSchemeId())) + .otherSchemeId(po.getOtherSchemeId()) + .otherPaymentBaseString(po.getOtherPaymentBaseString()) + .otherPaymentComBaseString(po.getOtherPaymentComBaseString()) + .otherStartTime(po.getOtherStartTime()) + .otherEndTime(po.getOtherEndTime()) + .paymentOrganization(po.getPaymentOrganization()) + .welfareType(SalaryEnumUtil.enumMatchByValue(po.getWelfareType(), WelfareTypeEnum.values(), WelfareTypeEnum.class)) + .build(); + } + +} diff --git a/src/com/engine/salary/entity/siarchives/bo/InsuranceArchivesBaseInfoBO.java b/src/com/engine/salary/entity/siarchives/bo/InsuranceArchivesBaseInfoBO.java new file mode 100644 index 000000000..15a58cef6 --- /dev/null +++ b/src/com/engine/salary/entity/siarchives/bo/InsuranceArchivesBaseInfoBO.java @@ -0,0 +1,134 @@ +package com.engine.salary.entity.siarchives.bo; + +import com.engine.salary.constant.SalaryDefaultTenantConstant; +import com.engine.salary.entity.siarchives.po.InsuranceArchivesBaseInfoPO; +import com.engine.salary.entity.taxagent.po.TaxAgentEmpChangePO; +import com.engine.salary.enums.siaccount.EmployeeStatusEnum; +import com.engine.salary.enums.taxagent.TaxAgentEmpChangeTypeEnum; +import com.engine.salary.util.SalaryEntityUtil; +import com.google.common.collect.Lists; +import com.engine.salary.util.db.IdGenerator; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.apache.commons.lang3.math.NumberUtils; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * @Author: sy + * @Description: 社保福利档案基础信息 + * @Date: 2022/10/13 + **/ +public class InsuranceArchivesBaseInfoBO { + + @Override + public String toString() { + return "InsuranceArchivesBaseInfoBO{}"; + } + + /** + * 构建增量数据 + */ + public static InsuranceArchivesBaseInfoBO.ChangeData buildChangeData(List taxAgentEmpChangeList, List insuranceArchivesBaseInfoList, Long currentEmployeeId) { + List changeIds = taxAgentEmpChangeList.stream().map(TaxAgentEmpChangePO::getId).collect(Collectors.toList()); + // 根据个税扣缴义务人和人员以及增量类型分组 + Map changeTypeMap = taxAgentEmpChangeList.stream().collect(Collectors.groupingBy(change -> change.getTaxAgentId() + "-" + change.getEmployeeId() + "-" + change.getChangeType(), Collectors.counting())); + // 顺序倒转 + Collections.reverse(taxAgentEmpChangeList); + // 去重 + taxAgentEmpChangeList = taxAgentEmpChangeList.stream() + .collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(f -> f.getTaxAgentId() + "-" + f.getEmployeeId()))), ArrayList::new)); + List taxAgentEmpChanges = taxAgentEmpChangeList + .stream() + // 不相等则保留,否则忽略 + .filter(change -> !Objects.equals(changeTypeMap.get(change.getTaxAgentId() + "-" + change.getEmployeeId() + "-" + TaxAgentEmpChangeTypeEnum.ADD.getValue()) + , changeTypeMap.get(change.getTaxAgentId() + "-" + change.getEmployeeId() + "-" + TaxAgentEmpChangeTypeEnum.DEL.getValue()))) + .collect(Collectors.toList()); + + Date now = new Date(); + Date today = new Date(); + List baseInfoAddTodoList = Lists.newArrayList(); + List baseInfoUpdateTodoList = Lists.newArrayList(); + + Map insuranceArchivesBaseInfoListMap = SalaryEntityUtil.convert2Map(insuranceArchivesBaseInfoList, k -> k.getPaymentOrganization() + "-" + k.getEmployeeId()); + taxAgentEmpChanges.forEach(change -> { +// //以人员id筛选出侧面比较的档案数据,避免存在当前个税扣缴义务人外的该人员档案数据 +// List moreBaseInfos = insuranceArchivesBaseInfoList.stream().filter(f -> f.getEmployeeId().equals(change.getEmployeeId())).collect(Collectors.toList()); + //以个税扣缴义务人和人员id为条件筛选当前数据直接对比的档案数据 + InsuranceArchivesBaseInfoPO insuranceBaseInfo = insuranceArchivesBaseInfoListMap.get(change.getTaxAgentId() + "-" + change.getEmployeeId()); + // 如果是新增 说明:如果没有档案,则新增,如果有档案而且是停止缴纳,就转移到待增员中,以个税扣缴义务人和人员id判断唯一 + if (change.getChangeType() == TaxAgentEmpChangeTypeEnum.ADD.getValue()) { + if (insuranceBaseInfo != null) { + // 停止缴纳->待增员 + if (insuranceBaseInfo.getRunStatus().equals(EmployeeStatusEnum.STOP_PAYMENT_FROM_DEL.getValue()) || insuranceBaseInfo.getRunStatus().equals(EmployeeStatusEnum.STOP_PAYMENT_FROM_ADD.getValue())) { + insuranceBaseInfo.setRunStatus(EmployeeStatusEnum.STAY_ADD.getValue()); + insuranceBaseInfo.setUpdateTime(now); + baseInfoUpdateTodoList.add(insuranceBaseInfo); + } + } else { + //新增社保、公积金、其他福利档案 + // 新增基础信息 + baseInfoAddTodoList.add(InsuranceArchivesBaseInfoPO.builder() + .id(IdGenerator.generate()) + .employeeId(change.getEmployeeId()) + .paymentOrganization(change.getTaxAgentId()) + .runStatus(EmployeeStatusEnum.STAY_ADD.getValue()) + .createTime(now) + .updateTime(now) + .creator(currentEmployeeId) + .deleteType(NumberUtils.INTEGER_ZERO) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .employeeType(change.getEmployeeType()) + .build()); + } + // 如果是删除 说明:如果有档案并且是在缴纳中才处理,没档案不用管 + } else if (change.getChangeType() == TaxAgentEmpChangeTypeEnum.DEL.getValue()) { + if (insuranceBaseInfo != null) { + if (insuranceBaseInfo.getRunStatus().equals(EmployeeStatusEnum.PAYING.getValue())) { + // 正在缴纳->待减员 + insuranceBaseInfo.setRunStatus(EmployeeStatusEnum.STAY_DEL.getValue()); + insuranceBaseInfo.setUpdateTime(now); + baseInfoUpdateTodoList.add(insuranceBaseInfo); + + } else if (insuranceBaseInfo.getRunStatus().equals(EmployeeStatusEnum.STAY_ADD.getValue())) { + // 待增员->逻辑删除 + insuranceBaseInfo.setDeleteType(1); + insuranceBaseInfo.setUpdateTime(now); + baseInfoUpdateTodoList.add(insuranceBaseInfo); + } + } + } + }); + + return ChangeData.builder() + .baseInfoAddTodoList(baseInfoAddTodoList) + .baseInfoUpdateTodoList(baseInfoUpdateTodoList) + .changeIds(changeIds) + .build(); + } + + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + public static class ChangeData { + + /** + * 需要批量修改的福利档案基础信息 + */ + private List baseInfoAddTodoList; + + /** + * 需要批量新增的福利档案基础信息 + */ + private List baseInfoUpdateTodoList; + + /** + * 需要删除的增量数据 + */ + private List changeIds; + } +} diff --git a/src/com/engine/salary/entity/siarchives/dto/InsuranceArchivesBaseDTO.java b/src/com/engine/salary/entity/siarchives/dto/InsuranceArchivesBaseDTO.java new file mode 100644 index 000000000..eb0c243c7 --- /dev/null +++ b/src/com/engine/salary/entity/siarchives/dto/InsuranceArchivesBaseDTO.java @@ -0,0 +1,54 @@ +package com.engine.salary.entity.siarchives.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Author weaver_cl + * @Description: 员工档案基础信息 + * @Date 2022/3/15 + * @Version V1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class InsuranceArchivesBaseDTO { + + /** + * 姓名 + */ + private String username; + + /** + * 部门 + */ + private String department; + + /** + * 岗位 + */ + private String position; + + /** + * 入职时间 + */ + private String hiredate; + + /** + * 手机号 + */ + private String telephone; + + /** + * 离职时间 + */ + private String dimissionDate; + + /** + * 缴纳组织 + */ + private Long paymentAgency; +} diff --git a/src/com/engine/salary/entity/siarchives/dto/InsuranceArchivesBaseHistoryDTO.java b/src/com/engine/salary/entity/siarchives/dto/InsuranceArchivesBaseHistoryDTO.java new file mode 100644 index 000000000..97f88e52c --- /dev/null +++ b/src/com/engine/salary/entity/siarchives/dto/InsuranceArchivesBaseHistoryDTO.java @@ -0,0 +1,104 @@ +package com.engine.salary.entity.siarchives.dto; + +import com.engine.salary.annotation.Auth; +import com.engine.salary.annotation.TableTitle; +import com.engine.salary.enums.auth.AuthCheckTypeEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; +import java.util.Set; + +/** + * @Author: sy + * @Description: + * @Date: 2023/10/16 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Auth(page = "siArchive", checkType = AuthCheckTypeEnum.TAX_EMP, taxAgentIdField = "paymentOrganization", employeeIdField = "employeeId") +public class InsuranceArchivesBaseHistoryDTO { + + private Long id; + + /** + * 人员id + */ + private Long employeeId; + + /** + *个税扣缴义务人id + */ + private Long paymentOrganization; + + /** + * 福利类型 + */ + private Integer welfareType; + + /** + * 调整前方案id + */ + private Long adjustBeforeSchemeId; + /** + * 调整后方案id + */ + private Long adjustAfterSchemeId; + + /** + * 调整的福利项id + */ + private Long adjustWelfareItemId; + + /** + * 操作人 + */ + private Long operator; + + private String tenantKey; + + private Long creator; + + private Integer deleteType; + + private Date createTime; + + private Date updateTime; + + + private String adjustBeforeBaseJson; + + private String adjustAfterBaseJson; + + private String adjustBeforeComBaseJson; + + private String adjustAfterComBaseJson; + + @TableTitle(title = "对象", dataIndex = "employeeName", key = "employeeName") + private String employeeName; + @TableTitle(title = "个税扣缴义务人", dataIndex = "paymentOrganizationName", key = "paymentOrganizationName") + private String paymentOrganizationName; + @TableTitle(title = "福利项名称", dataIndex = "welfareItemName", key = "welfareItemName") + private String welfareItemName; + @TableTitle(title = "缴费对象", dataIndex = "paymentScope", key = "paymentScope") + private String paymentScope; + @TableTitle(title = "调整前方案", dataIndex = "adjustBeforeSchemeName", key = "adjustBeforeSchemeName") + private String adjustBeforeSchemeName; + @TableTitle(title = "调整前基数", dataIndex = "adjustBeforeBaseValue", key = "adjustBeforeBaseValue") + private String adjustBeforeBaseValue; + @TableTitle(title = "调整后方案", dataIndex = "adjustAfterSchemeName", key = "adjustAfterSchemeName") + private String adjustAfterSchemeName; + @TableTitle(title = "调整后基数", dataIndex = "adjustAfterBaseValue", key = "adjustAfterBaseValue") + private String adjustAfterBaseValue; + @TableTitle(title = "操作人", dataIndex = "operatorName", key = "operatorName") + private String operatorName; + @TableTitle(title = "操作时间", dataIndex = "operateTime", key = "operateTime") + private Date operateTime; + + + private Set opts; +} diff --git a/src/com/engine/salary/entity/siarchives/dto/InsuranceArchivesFundSchemeDTO.java b/src/com/engine/salary/entity/siarchives/dto/InsuranceArchivesFundSchemeDTO.java new file mode 100644 index 000000000..4fcfdbcd1 --- /dev/null +++ b/src/com/engine/salary/entity/siarchives/dto/InsuranceArchivesFundSchemeDTO.java @@ -0,0 +1,70 @@ +package com.engine.salary.entity.siarchives.dto; + +import com.engine.salary.enums.sicategory.WelfareTypeEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + + +/** + * @Author weaver_cl + * @Description: 员工福利档案公积金 + * @Date 2022/3/15 + * @Version V1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class InsuranceArchivesFundSchemeDTO { + + //主键id + private Long id; + + //员工id + private Long employeeId; + + //暂不缴纳 + private Integer nonPayment; + + //福利类型 + private WelfareTypeEnum welfareType; + + //公积金起始缴纳月 + private String fundStartTime; + + + //公积金最后缴纳月 + private String fundEndTime; + + + //公积金方案名称 + private Long fundName; + + //公积金方案id + private Long fundSchemeId; + + //private List siFundList; + + //公积金账号 + private String fundAccount; + + + //补充公积金账号 + private String supplementFundAccount; + + + //公积金缴纳组织 + private Long paymentOrganization; + + //private List paymentOrganizationList; + + // 公积金个人实际承担方 + private String underTake; + + //缴纳基数 + private String fundPaymentBaseString; + + private String fundPaymentComBaseString; +} diff --git a/src/com/engine/salary/entity/siarchives/dto/InsuranceArchivesOtherSchemeDTO.java b/src/com/engine/salary/entity/siarchives/dto/InsuranceArchivesOtherSchemeDTO.java new file mode 100644 index 000000000..3fa89c1c2 --- /dev/null +++ b/src/com/engine/salary/entity/siarchives/dto/InsuranceArchivesOtherSchemeDTO.java @@ -0,0 +1,62 @@ +package com.engine.salary.entity.siarchives.dto; + +import com.engine.salary.enums.sicategory.WelfareTypeEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + + +/** + * @Author weaver_cl + * @Description: 员工福利档案其他福利 + * @Date 2022/3/15 + * @Version V1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class InsuranceArchivesOtherSchemeDTO { + + //主键id + private Long id; + + //员工id + private Long employeeId; + + //暂不缴纳 + private Integer nonPayment; + + //福利类型 + private WelfareTypeEnum welfareType; + + //其他福利起始缴纳月 + private String otherStartTime; + + //其他福利最后缴纳月 + private String otherEndTime; + + //其他福利方案名称 + private String otherName; + + //其他福利方案id + private Long otherSchemeId; + + //private List siOtherList; + + + //其他福利缴纳组织 + private Long paymentOrganization; + + //private List paymentOrganizationList; + + //其他福利个人实际承担方 + private String underTake; + + private String otherPaymentBaseString; + + private String otherPaymentComBaseString; + + //private WeaForm otherPaymentBase; +} diff --git a/src/com/engine/salary/entity/siarchives/dto/InsuranceArchivesSocialSchemeDTO.java b/src/com/engine/salary/entity/siarchives/dto/InsuranceArchivesSocialSchemeDTO.java new file mode 100644 index 000000000..d4fc1dae8 --- /dev/null +++ b/src/com/engine/salary/entity/siarchives/dto/InsuranceArchivesSocialSchemeDTO.java @@ -0,0 +1,65 @@ +package com.engine.salary.entity.siarchives.dto; + +import com.engine.salary.enums.sicategory.WelfareTypeEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + + +/** + * @Author weaver_cl + * @Description: 员工福利档案社保 + * @Date 2022/3/15 + * @Version V1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class InsuranceArchivesSocialSchemeDTO { + + //主键id + private Long id; + + //员工id + private Long employeeId; + + //暂不缴纳 + private Integer nonPayment; + + //福利类型 + private WelfareTypeEnum welfareType; + + //社保起始缴纳月 + private String socialStartTime; + + //社保最后缴纳月 + private String socialEndTime; + + //社保方案名称 + private String socialName; + + //社保方案id + private Long socialSchemeId; + + //private List siSocialList; + + //社保账号 + private String schemeAccount; + + //社保缴纳组织 + private Long paymentOrganization; + + //private List paymentOrganizationList; + + //社保个人实际承担方 UndertakerEnum + private String underTake; + + //社保缴纳基数 + private String schemePaymentBaseString; + + //社保缴纳基数——单位 + private String schemePaymentComBaseString; + +} diff --git a/src/com/engine/salary/entity/siarchives/param/InsuranceArchivesFundSaveParam.java b/src/com/engine/salary/entity/siarchives/param/InsuranceArchivesFundSaveParam.java new file mode 100644 index 000000000..49481c8b4 --- /dev/null +++ b/src/com/engine/salary/entity/siarchives/param/InsuranceArchivesFundSaveParam.java @@ -0,0 +1,59 @@ +package com.engine.salary.entity.siarchives.param; + +import com.engine.salary.enums.sicategory.WelfareTypeEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Author weaver_cl + * @Description: 公积金档案保存 + * @Date 2022/3/17 + * @Version V1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class InsuranceArchivesFundSaveParam { + //主键id + private Long id; + + //员工id + private Long employeeId; + + //暂不缴纳 + private Integer nonPayment; + + //福利类型 + private WelfareTypeEnum welfareType; + + //公积金起始缴纳月 + private String fundStartTime; + + //公积金最后缴纳月 + private String fundEndTime; + + //公积金方案id + private Long fundSchemeId; + + //公积金方案名称 + private String fundName; + + //公积金账号 + private String fundAccount; + + //补充公积金账号 + private String supplementFundAccount; + + //公积金缴纳组织 + private Long paymentOrganization; + + //公积金个人实际承担方 + private Integer underTake; + + //公积金基数jsonString + private String paymentForm; + +} diff --git a/src/com/engine/salary/entity/siarchives/param/InsuranceArchivesListParam.java b/src/com/engine/salary/entity/siarchives/param/InsuranceArchivesListParam.java new file mode 100644 index 000000000..ab15e4b6a --- /dev/null +++ b/src/com/engine/salary/entity/siarchives/param/InsuranceArchivesListParam.java @@ -0,0 +1,123 @@ +package com.engine.salary.entity.siarchives.param; + +import com.engine.salary.common.BaseQueryParam; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.math.BigDecimal; +import java.util.Collection; +import java.util.List; + +/** + * @Author weaver_cl + * @Description: 高级查询档案列表 + * @Date 2022/3/17 + * @Version V1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class InsuranceArchivesListParam extends BaseQueryParam { + //姓名 + private String userName; + + //工号") + private String jobNum; + + //部门(多选)") + private List departmentIds; + + //分部(多选)") + private List subcompanyIds; + + private String departmentIdsStr; + private String subcompanyIdsStr; + + //状态(多线)") + private List statuses; + private String statusesStr; + + //岗位(多选)") + private List positions; + + private String positionsStr; + + //入职时间") + private String[] hireDate; + + //离职时间") + private String[] dimissionDate; + + //入职开始时间") + private String hiredateStart; + + //入职结束时间") + private String hiredateEnd; + + //离职开始时间") + private String dimissionDateStart; + + //离职结束时间") + private String dimissionDateEnd; + + //社保方案id") + private Long siSchemeId; + + //公积金方案id") + private Long fundSchemeId; + + //其他福利方案id") + private Long otherSchemeId; + + //导出档案员工id集合") + private List employeeIds; + + //分页起始索引") + private Long startNum; + + + //快捷搜索") + private String keyword; + + //快捷搜索和高级搜索标识") + private String dataSource; + + //是否导出原有数据") + private Boolean exportData; + + //是否导出所有核酸异常数据") + private Boolean inspectAll; + + //主键id集合") + private List ids; + + //账单月份") + private String billMonth; + + //是否导出模板") + private Boolean templateFlag; + + //分权 + private Boolean needAuth; + //个税扣缴义务人下人员 + private Collection taxAgentEmployeeIds; + //个税扣缴义务人 + private Collection taxAgentIds; + //个税扣缴义务人id + private Long taxAgentId; + //福利执行状态 + private List runStatuses; + + /** + * 人事状态 + */ + private List personnelStatuses; + + /** + * 是否是外部系统档案 + */ + private boolean extWelArchiveList; +} diff --git a/src/com/engine/salary/entity/siarchives/param/InsuranceArchivesOtherSaveParam.java b/src/com/engine/salary/entity/siarchives/param/InsuranceArchivesOtherSaveParam.java new file mode 100644 index 000000000..c3ed3481c --- /dev/null +++ b/src/com/engine/salary/entity/siarchives/param/InsuranceArchivesOtherSaveParam.java @@ -0,0 +1,53 @@ +package com.engine.salary.entity.siarchives.param; + +import com.engine.salary.enums.sicategory.WelfareTypeEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Author weaver_cl + * @Description: 其他福利档案保存 + * @Date 2022/3/17 + * @Version V1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class InsuranceArchivesOtherSaveParam { + + //主键id + private Long id; + + //员工id + private Long employeeId; + + //暂不缴纳 + private Integer nonPayment; + + //福利类型 + private WelfareTypeEnum welfareType; + + //其他福利起始缴纳月 + private String otherStartTime; + + //其他福利最后缴纳月 + private String otherEndTime; + + //其他福利方案id + private Long otherSchemeId; + + //其他福利方案名称 + private String otherName; + + //其他福利缴纳组织 + private Long paymentOrganization; + + //其他福利个人实际承担方 + private Integer underTake; + + //其他福利基数jsonString + private String paymentForm; +} diff --git a/src/com/engine/salary/entity/siarchives/param/InsuranceArchivesSaveParam.java b/src/com/engine/salary/entity/siarchives/param/InsuranceArchivesSaveParam.java new file mode 100644 index 000000000..25f72a711 --- /dev/null +++ b/src/com/engine/salary/entity/siarchives/param/InsuranceArchivesSaveParam.java @@ -0,0 +1,33 @@ +package com.engine.salary.entity.siarchives.param; + +import com.engine.salary.enums.sicategory.WelfareTypeEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Author weaver_cl + * @Description: 社保档案保存 + * @Date 2022/3/16 + * @Version V1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class InsuranceArchivesSaveParam { + + private WelfareTypeEnum welfareType; + + private String baseForm; + + private String paymentForm; + + private String paymentComForm; + + /** + * 是否修改数据为上限或下限 + */ + private Boolean changeData; +} diff --git a/src/com/engine/salary/entity/siarchives/param/InsuranceArchivesSocialSaveParam.java b/src/com/engine/salary/entity/siarchives/param/InsuranceArchivesSocialSaveParam.java new file mode 100644 index 000000000..6c3cbebc9 --- /dev/null +++ b/src/com/engine/salary/entity/siarchives/param/InsuranceArchivesSocialSaveParam.java @@ -0,0 +1,56 @@ +package com.engine.salary.entity.siarchives.param; + +import com.engine.salary.enums.sicategory.WelfareTypeEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Author weaver_cl + * @Description: 社保档案保存 + * @Date 2022/3/16 + * @Version V1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class InsuranceArchivesSocialSaveParam { + + //主键id + private Long id; + + //员工id + private Long employeeId; + + //暂不缴纳 + private Integer nonPayment; + + //福利类型 + private WelfareTypeEnum welfareType; + + //社保起始缴纳月 + private String socialStartTime; + + //社保最后缴纳月 + private String socialEndTime; + + //社保方案id + private Long socialSchemeId; + + //社保方案名称 + private String socialName; + + //社保账号 + private String schemeAccount; + + //社保缴纳组织 + private Long paymentOrganization; + + //社保个人实际承担方 + private Integer underTake; + + //基数jsonString + private String paymentForm; +} diff --git a/src/com/engine/salary/entity/siarchives/param/SIArchiveBaseHistoryListParam.java b/src/com/engine/salary/entity/siarchives/param/SIArchiveBaseHistoryListParam.java new file mode 100644 index 000000000..efa7b7bc1 --- /dev/null +++ b/src/com/engine/salary/entity/siarchives/param/SIArchiveBaseHistoryListParam.java @@ -0,0 +1,28 @@ +package com.engine.salary.entity.siarchives.param; + +import com.engine.salary.enums.sicategory.WelfareTypeEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Author: sy + * @Description: 基数调整历史列表查询参数 + * @Date: 2023/10/17 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SIArchiveBaseHistoryListParam { + + private WelfareTypeEnum welfareTypeEnum; + + private Long employeeId; + private Long operator; + private Long paymentOrganization; + + private int current; + private int pageSize; +} diff --git a/src/com/engine/salary/entity/siarchives/param/SIArchiveImportActionParam.java b/src/com/engine/salary/entity/siarchives/param/SIArchiveImportActionParam.java new file mode 100644 index 000000000..33ea12705 --- /dev/null +++ b/src/com/engine/salary/entity/siarchives/param/SIArchiveImportActionParam.java @@ -0,0 +1,39 @@ +package com.engine.salary.entity.siarchives.param; + +import com.engine.salary.enums.salaryarchive.SalaryArchiveImportTypeEnum; +import com.engine.salary.enums.siaccount.EmployeeStatusEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; +import java.util.Map; + +/** + * @Author: sy + * @Description: 社保福利档案导入处理参数(action使用) + * @Date: 2022/11/10 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SIArchiveImportActionParam { + + /** + * 导入类型 + * + * @see EmployeeStatusEnum + */ + + String runStatus; + + /** + * 导入数据 + * + */ + List> importDatas; + + private boolean addData; +} diff --git a/src/com/engine/salary/entity/siarchives/param/SIArchiveImportParam.java b/src/com/engine/salary/entity/siarchives/param/SIArchiveImportParam.java new file mode 100644 index 000000000..24e53e232 --- /dev/null +++ b/src/com/engine/salary/entity/siarchives/param/SIArchiveImportParam.java @@ -0,0 +1,56 @@ +package com.engine.salary.entity.siarchives.param; + +import com.engine.salary.entity.taxagent.param.TaxAgentRangeSaveParam; +import com.engine.salary.enums.siaccount.EmployeeStatusEnum; +import com.engine.salary.util.valid.DataCheck; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; +import java.util.Map; + +/** + * @Author: sy + * @Description: 社保福利档案导入处理参数 + * @Date: 2022/11/10 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SIArchiveImportParam { + + /** + * 上传文件id + */ + String imageId; + + /** + * 导入类型 + * + * @see EmployeeStatusEnum + */ + + String runStatus; + + /** + * 导入数据 + * + */ + List> importDatas; + + private boolean addData; + + /** + * 待生成的人员范围 + */ + List taxAgentRanges; + /** + * 是否是流程 + */ + boolean isProcess; + + +} diff --git a/src/com/engine/salary/entity/siarchives/po/InsuranceArchivesAccountPO.java b/src/com/engine/salary/entity/siarchives/po/InsuranceArchivesAccountPO.java new file mode 100644 index 000000000..f2a2de17f --- /dev/null +++ b/src/com/engine/salary/entity/siarchives/po/InsuranceArchivesAccountPO.java @@ -0,0 +1,27 @@ +package com.engine.salary.entity.siarchives.po; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Author weaver_cl + * + * @Date 2022/3/17 + * @Version V1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class InsuranceArchivesAccountPO { + + private InsuranceArchivesSocialSchemePO social; + + private InsuranceArchivesFundSchemePO fund; + + private InsuranceArchivesOtherSchemePO other; + + private InsuranceArchivesBaseInfoPO BaseInfo; +} diff --git a/src/com/engine/salary/entity/siarchives/po/InsuranceArchivesBaseHistoryPO.java b/src/com/engine/salary/entity/siarchives/po/InsuranceArchivesBaseHistoryPO.java new file mode 100644 index 000000000..52d31f804 --- /dev/null +++ b/src/com/engine/salary/entity/siarchives/po/InsuranceArchivesBaseHistoryPO.java @@ -0,0 +1,82 @@ +package com.engine.salary.entity.siarchives.po; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; + +/** + * @Author: sy + * @Description: 福利档案基数调整记录 + * @Date: 2023/10/16 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//hrsa_insurance_base_history +public class InsuranceArchivesBaseHistoryPO { + + private Long id; + + /** + * 人员id + */ + private Long employeeId; + + /** + * 个税扣缴义务人id + */ + private Long paymentOrganization; + + /** + * 福利类别 + */ + private Integer welfareType; + + /** + * 调整前方案id + */ + private Long adjustBeforeSchemeId; + /** + * 调整后方案id + */ + private Long adjustAfterSchemeId; + /** + * 调整前基数值 + */ + private String adjustBeforeBaseValue; + /** + * 调整后基数值 + */ + private String adjustAfterBaseValue; + + /** + * 调整的福利项id + */ + private Long adjustWelfareItemId; + + /** + * 操作人 + */ + private Long operator; + + /** + * 操作时间 + */ + private Date operateTime; + + private String tenantKey; + + private Long creator; + + private Integer deleteType; + + private Date createTime; + + private Date updateTime; + + private String paymentScope; +} diff --git a/src/com/engine/salary/entity/siarchives/po/InsuranceArchivesBaseInfoPO.java b/src/com/engine/salary/entity/siarchives/po/InsuranceArchivesBaseInfoPO.java new file mode 100644 index 000000000..fcd72acd7 --- /dev/null +++ b/src/com/engine/salary/entity/siarchives/po/InsuranceArchivesBaseInfoPO.java @@ -0,0 +1,117 @@ +package com.engine.salary.entity.siarchives.po; + +import com.engine.hrmelog.annotation.ElogTransform; +import com.engine.salary.annotation.Auth; +import com.engine.salary.enums.auth.AuthCheckTypeEnum; +import com.engine.salary.enums.datacollection.DataCollectionEmployeeTypeEnum; +import com.engine.salary.enums.siaccount.EmployeeStatusEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.Date; +import java.util.Set; + +/** + * @Author: sy + * @Description: 社保福利档案基础信息 + * @Date: 2022/10/8 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//hrsa_insurance_base_info +@ElogTransform(name = "福利档案主表") +@Auth(page = "siArchive", checkType = AuthCheckTypeEnum.TAX_EMP, employeeIdField = "employeeId", taxAgentIdField = "paymentOrganization") +public class InsuranceArchivesBaseInfoPO { + /** + * 主键id + */ + @ElogTransform(name = "主键id") + private Long id; + + /** + * 员工id + */ + @ElogTransform(name = "员工id") + private Long employeeId; + + /** + * 个税扣缴义务人id + */ + @ElogTransform(name = "个税扣缴义务人id") + private Long paymentOrganization; + + /** + * 社保档案id + */ + @ElogTransform(name = "社保档案id") + private Long socialArchivesId; + + /** + * 公积金档案id + */ + @ElogTransform(name = "公积金档案id") + private Long fundArchivesId; + + /** + * 其他福利档案id + */ + @ElogTransform(name = "其他福利档案id") + private Long otherArchivesId; + + /** + * 租户key + */ + @ElogTransform(name = "租户key") + private String tenantKey; + + /** + * 创建人id + */ + @ElogTransform(name = "创建人id") + private Long creator; + + /** + * 是否删除 + */ + @ElogTransform(name = "是否删除") + private Integer deleteType; + + /** + * 创建时间 + */ + @ElogTransform(name = "创建时间") + private Date createTime; + + /** + * 更新时间 + */ + @ElogTransform(name = "更新时间") + private Date updateTime; + + /** + * 福利执行状态 + * @see EmployeeStatusEnum + */ + @ElogTransform(name = "福利执行状态") + private String runStatus; + + /** + * 人员类型,0或null组织架构,1非系统人员 + * + * @see DataCollectionEmployeeTypeEnum + */ + @ElogTransform(name = "人员类型") + private Integer employeeType; + + //---------条件------- + private Collection ids; + private Collection employeeIds; + + + private Set opts; +} diff --git a/src/com/engine/salary/entity/siarchives/po/InsuranceArchivesEmployeePO.java b/src/com/engine/salary/entity/siarchives/po/InsuranceArchivesEmployeePO.java new file mode 100644 index 000000000..9df1f4c3a --- /dev/null +++ b/src/com/engine/salary/entity/siarchives/po/InsuranceArchivesEmployeePO.java @@ -0,0 +1,90 @@ +package com.engine.salary.entity.siarchives.po; + +import com.engine.salary.annotation.Auth; +import com.engine.salary.annotation.I18n; +import com.engine.salary.enums.UserStatusEnum; +import com.engine.salary.enums.auth.AuthCheckTypeEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.math.BigDecimal; +import java.util.Set; + +/** + * @Author weaver_cl + * + * @Date 2022/3/17 + * @Version V1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Auth(page = "siArchive", checkType = AuthCheckTypeEnum.TAX_EMP, taxAgentIdField = "paymentOrganization", employeeIdField = "employeeId") +public class InsuranceArchivesEmployeePO { + private Long employeeId;//员工id + + /** + * 缴纳组织 + */ + private Long paymentOrganization; + + @I18n + private String userName; + + private BigDecimal departmentId; + + private String jobNum; + + private String telephone; + + private String idNo; + + @I18n + private String departmentName; + + /** + * 分部 + */ + @I18n + private String subcompanyName; + + + private BigDecimal position; + + private Integer userStatus; + + private UserStatusEnum userStatusEnum; + + private String hiredate; + + /** + * 入职日期 + */ + private String companystartdate; + + /** + * 离职日期 + */ + private String dimissionDate; + + private Long siSchemeId; + + private Long fundSchemeId; + + private Long otherSchemeId; + + private Long baseInfoId; + /** + * 社保、公积金、其他福利档案id + */ + private Long socialId; + + private Long fundId; + + private Long otherId; + + private Set opts; +} diff --git a/src/com/engine/salary/entity/siarchives/po/InsuranceArchivesFundSchemePO.java b/src/com/engine/salary/entity/siarchives/po/InsuranceArchivesFundSchemePO.java new file mode 100644 index 000000000..e4e9573c4 --- /dev/null +++ b/src/com/engine/salary/entity/siarchives/po/InsuranceArchivesFundSchemePO.java @@ -0,0 +1,141 @@ +package com.engine.salary.entity.siarchives.po; + +import com.engine.salary.annotation.Encrypt; +import com.engine.hrmelog.annotation.ElogTransform; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; + +/** + * @Author weaver_cl + * @Description: 公积金档案表 hrsa_fund_archives + * @Date 2022/3/12 + * @Version V1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//hrsa_fund_archives +@ElogTransform(name = "福利档案明细表-公积金信息") +public class InsuranceArchivesFundSchemePO { + /** + * 主键id + */ + @ElogTransform(name = "主键id") + private Long id; + + /** + * 员工id + */ + @ElogTransform(name = "员工id") + private Long employeeId; + + /** + * 福利类型 + */ + @ElogTransform(name = "福利类型") + private Integer welfareType; + + /** + * 暂不缴纳 + */ + @ElogTransform(name = "是否暂不缴纳") + private Integer nonPayment; + + /** + * 公积金起始缴纳月 + */ + @ElogTransform(name = "公积金起始缴纳月") + private String fundStartTime; + + /** + * 公积金最后缴纳月 + */ + @ElogTransform(name = "公积金最后缴纳月") + private String fundEndTime; + + /** + * 公积金方案名称 + */ + /*//公积金方案名称") + private String fundName;*/ + + /** + * 公积金方案id + */ + @ElogTransform(name = "公积金方案id") + private Long fundSchemeId; + + /** + * 公积金账号 + */ + @ElogTransform(name = "公积金账号") + private String fundAccount; + + /** + * 补充公积金账号 + */ + @ElogTransform(name = "补充公积金账号") + private String supplementFundAccount; + + /** + * 公积金缴纳组织 + */ + @ElogTransform(name = "公积金缴纳组织") + private Long paymentOrganization; + + /** + * 公积金个人实际承担方 + */ + @ElogTransform(name = "公积金个人实际承担方") + private Integer underTake; + + /** + * 公积金缴纳基数 + */ + @Encrypt + @ElogTransform(name = "公积金缴纳基数") + private String fundPaymentBaseString; + + /** + * 公积金缴纳基数——单位 + */ + @Encrypt + @ElogTransform(name = "公积金缴纳基数——单位") + private String fundPaymentComBaseString; + + + /** + * 租户key + */ + @ElogTransform(name = "租户key") + private String tenantKey; + + /** + * 创建人id + */ + @ElogTransform(name = "创建人id") + private Long creator; + + /** + * 是否删除 + */ + @ElogTransform(name = "是否删除") + private Integer deleteType; + + /** + * 创建时间 + */ + @ElogTransform(name = "创建时间") + private Date createTime; + + /** + * 更新时间 + */ + @ElogTransform(name = "更新时间") + private Date updateTime; +} diff --git a/src/com/engine/salary/entity/siarchives/po/InsuranceArchivesOtherSchemePO.java b/src/com/engine/salary/entity/siarchives/po/InsuranceArchivesOtherSchemePO.java new file mode 100644 index 000000000..c8086a1e1 --- /dev/null +++ b/src/com/engine/salary/entity/siarchives/po/InsuranceArchivesOtherSchemePO.java @@ -0,0 +1,128 @@ +package com.engine.salary.entity.siarchives.po; + +import com.engine.salary.annotation.Encrypt; +import com.engine.hrmelog.annotation.ElogTransform; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; + +/** + * @Author weaver_cl + * @Description: hrsa_other_archives 其他福利档案表 + * @Date 2022/3/12 + * @Version V1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//hrsa_other_archives +@ElogTransform(name = "福利档案明细表-其他福利信息") +public class InsuranceArchivesOtherSchemePO { + /** + * 主键id + */ + @ElogTransform(name = "主键id") + private Long id; + + /** + * 员工id + */ + @ElogTransform(name = "员工id") + private Long employeeId; + + /** + * 暂不缴纳 + */ + @ElogTransform(name = "是否暂不缴纳") + private Integer nonPayment; + + /** + * 福利类型 + */ + @ElogTransform(name = "福利类型") + private Integer welfareType; + + /** + * 其他福利起始缴纳月 + */ + @ElogTransform(name = "其他福利起始缴纳月") + private String otherStartTime; + + /** + * 其他福利最后缴纳月 + */ + @ElogTransform(name = "其他福利最后缴纳月") + private String otherEndTime; + + /** + * 其他福利方案名称 + */ + /*//其他福利方案名称") + private String otherName;*/ + + /** + * 其他福利方案id + */ + @ElogTransform(name = "其他福利方案id") + private Long otherSchemeId; + + /** + * 其他福利缴纳组织 + */ + @ElogTransform(name = "其他福利缴纳组织") + private Long paymentOrganization; + + /** + * 其他福利个人实际承担方 + */ + @ElogTransform(name = "其他福利个人实际承担方") + private Integer underTake; + + /** + * 其他福利缴纳基数 + */ + @Encrypt + @ElogTransform(name = "其他福利缴纳基数") + private String otherPaymentBaseString; + + /** + * 其他福利缴纳基数——单位 + */ + @Encrypt + @ElogTransform(name = "其他福利缴纳基数——单位") + private String otherPaymentComBaseString; + + /** + * 租户key + */ + @ElogTransform(name = "租户key") + private String tenantKey; + + /** + * 创建人id + */ + @ElogTransform(name = "创建人id") + private Long creator; + + /** + * 是否删除 + */ + @ElogTransform(name = "是否删除") + private Integer deleteType; + + /** + * 创建时间 + */ + @ElogTransform(name = "创建时间") + private Date createTime; + + /** + * 更新时间 + */ + @ElogTransform(name = "更新时间") + private Date updateTime; +} diff --git a/src/com/engine/salary/entity/siarchives/po/InsuranceArchivesSocialSchemePO.java b/src/com/engine/salary/entity/siarchives/po/InsuranceArchivesSocialSchemePO.java new file mode 100644 index 000000000..a0b4a8b87 --- /dev/null +++ b/src/com/engine/salary/entity/siarchives/po/InsuranceArchivesSocialSchemePO.java @@ -0,0 +1,135 @@ +package com.engine.salary.entity.siarchives.po; + +import com.engine.salary.annotation.Encrypt; +import com.engine.hrmelog.annotation.ElogTransform; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; + +/** + * @Author weaver_cl + * @Description: hrsa_social_archives 社保档案表 + * @Date 2022/3/12 + * @Version V1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//hrsa_social_archives +@ElogTransform(name = "福利档案明细表-社保信息") +public class InsuranceArchivesSocialSchemePO { + + /** + * 主键id + */ + @ElogTransform(name = "主键id") + private Long id; + + /** + * 员工id + */ + @ElogTransform(name = "员工id") + private Long employeeId; + + /** + * 暂不缴纳 + */ + @ElogTransform(name = "是否暂不缴纳") + private Integer nonPayment; + + /** + * 福利类型 + */ + @ElogTransform(name = "福利类型") + private Integer welfareType; + + /** + * 社保起始缴纳月 + */ + @ElogTransform(name = "社保起始缴纳月") + private String socialStartTime; + + /** + * 社保最后缴纳月 + */ + @ElogTransform(name = "社保最后缴纳月") + private String socialEndTime; + + /** + * 社保方案名称 + */ + /* //社保方案名称") + private String socialName;*/ + + /** + * 社保方案id + */ + @ElogTransform(name = "社保方案id") + private Long socialSchemeId; + + /** + * 社保账号 + */ + @ElogTransform(name = "社保账号") + private String socialAccount; + + /** + * 社保缴纳组织 + */ + @ElogTransform(name = "社保缴纳组织") + private Long paymentOrganization; + + /** + * 社保个人实际承担方 + */ + @ElogTransform(name = "社保个人实际承担方") + private Integer underTake; + + /** + * 社保缴纳基数 + */ + @Encrypt + @ElogTransform(name = "社保缴纳基数") + private String socialPaymentBaseString; + + /** + * 社保缴纳基数——单位 + */ + @Encrypt + @ElogTransform(name = "社保缴纳基数——单位") + private String socialPaymentComBaseString; + + /** + * 租户key + */ + @ElogTransform(name = "租户key") + private String tenantKey; + + /** + * 创建人id + */ + @ElogTransform(name = "创建人id") + private Long creator; + + /** + * 是否删除 + */ + @ElogTransform(name = "是否删除") + private Integer deleteType; + + /** + * 创建时间 + */ + @ElogTransform(name = "创建时间") + private Date createTime; + + /** + * 更新时间 + */ + @ElogTransform(name = "更新时间") + private Date updateTime; +} diff --git a/src/com/engine/salary/entity/sicategory/bo/ICategoryBO.java b/src/com/engine/salary/entity/sicategory/bo/ICategoryBO.java new file mode 100644 index 000000000..8bf7052ac --- /dev/null +++ b/src/com/engine/salary/entity/sicategory/bo/ICategoryBO.java @@ -0,0 +1,40 @@ +package com.engine.salary.entity.sicategory.bo; + +import com.engine.salary.constant.SalaryDefaultTenantConstant; +import com.engine.salary.entity.sicategory.dto.ICategoryFormDTO; +import com.engine.salary.entity.sicategory.po.ICategoryPO; +import com.engine.salary.enums.sicategory.DataTypeEnum; +import com.engine.salary.util.SalaryEnumUtil; +import com.engine.salary.util.db.IdGenerator; + +import java.util.Date; +import java.util.Objects; + +/** + * @Author weaver_cl + * + * @Date 2022/3/10 + * @Version V1.0 + **/ +public class ICategoryBO { + + public static ICategoryPO convertToInsuranceCategoryPO(ICategoryFormDTO dto, Long employeeId) { + if (Objects.isNull(dto)) { + return null; + } + return ICategoryPO.builder() + .id(IdGenerator.generate()) + .paymentScope(SalaryEnumUtil.enumArrToString(dto.getPaymentScope())) + .welfareType(dto.getWelfareType().getValue()) + .insuranceName(dto.getInsuranceName()) + .isUse(0) + .dataType(DataTypeEnum.CUSTOM.getValue()) + .createTime(new Date()) + .updateTime(new Date()) + .creator(employeeId) + .deleteType(0) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .build(); + + } +} diff --git a/src/com/engine/salary/entity/sicategory/bo/InsuranceCategoryBO.java b/src/com/engine/salary/entity/sicategory/bo/InsuranceCategoryBO.java new file mode 100644 index 000000000..ea128ab01 --- /dev/null +++ b/src/com/engine/salary/entity/sicategory/bo/InsuranceCategoryBO.java @@ -0,0 +1,102 @@ +//package com.engine.salary.entity.sicategory.bo; +// +//import com.baomidou.mybatisplus.core.conditions.Wrapper; +//import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +//import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; +//import com.baomidou.mybatisplus.core.toolkit.Wrappers; +//import com.weaver.common.distribution.genid.IdGenerator; +//import com.weaver.hrm.salary.entity.sicategory.dto.InsuranceCategoryFormDTO; +//import com.weaver.hrm.salary.entity.sicategory.dto.InsuranceCategoryListDTO; +//import com.weaver.hrm.salary.entity.sicategory.po.InsuranceCategoryPO; +//import com.weaver.hrm.salary.enums.sicategory.PaymentScopeEnum; +//import com.weaver.hrm.salary.enums.sicategory.WelfareTypeEnum; +//import com.weaver.hrm.salary.util.SalaryEnumUtil; +//import com.weaver.hrm.salary.util.SalaryI18nUtil; +//import org.apache.commons.lang3.StringUtils; +//import org.springframework.beans.BeanUtils; +// +//import java.time.LocalDateTime; +//import java.util.*; +//import java.util.stream.Collectors; +// +///** +// * @Description: +// * @Author: zhangheng +// * @CreateDate: 2021/11/12 9:08 +// * @Version: v1.0 +// */ +//public class InsuranceCategoryBO { +// +// public static InsuranceCategoryFormDTO convertToInsuranceCategoryFromDTO(InsuranceCategoryPO insuranceCategoryPO, Long employeeId, String tenantKey) { +// InsuranceCategoryFormDTO insuranceCategoryFormDTO = new InsuranceCategoryFormDTO(); +// BeanUtils.copyProperties(insuranceCategoryPO, insuranceCategoryFormDTO); +// if (insuranceCategoryPO.getWelfareType() != null) { +// insuranceCategoryFormDTO.setWelfareType(InsuranceCategoryBO.matchWelfareTypeEnum(insuranceCategoryPO.getWelfareType())); +// } +// if (StringUtils.isNotBlank(insuranceCategoryPO.getPaymentScope())) { +// insuranceCategoryFormDTO.setPaymentScope(SalaryEnumUtil.stringToEnums(insuranceCategoryPO.getPaymentScope(), ",")); +// } +// return insuranceCategoryFormDTO; +// } +// +// public static InsuranceCategoryPO convertToInsuranceCategoryPO(InsuranceCategoryFormDTO dto, Long employeeId, String tenantKey) { +// if (Objects.isNull(dto)) { +// return null; +// } +// return InsuranceCategoryPO.builder() +// .paymentScope(SalaryEnumUtil.enumArrToString(dto.getPaymentScope())) +// .welfareType(dto.getWelfareType().getValue()) +// .insuranceName(dto.getInsuranceName()) +// .isUse(dto.getIsUse()) +// .createTime(LocalDateTime.now()) +// .updateTime(LocalDateTime.now()) +// .creator(employeeId) +// .tenantKey(tenantKey) +// .build(); +// +// } +// +// public static Wrapper buildCustomCategoryListWrapper(WelfareTypeEnum welfareType,) { +// LambdaQueryWrapper lambdaQueryWrapper = Wrappers.lambdaQuery(); +// lambdaQueryWrapper.eq(InsuranceCategoryPO::getTenantKey, tenantKey) +// .eq(InsuranceCategoryPO::getDeleteType, 0); +// if (welfareType != null) { +// lambdaQueryWrapper.eq(InsuranceCategoryPO::getWelfareType, welfareType.getValue()); +// } +// lambdaQueryWrapper.orderByDesc(InsuranceCategoryPO::getUpdateTime); +// return lambdaQueryWrapper; +// } +// +// public static List convertToCustomCategoryList(Collection insuranceCategoryPOS, +// Long employeeId, String tenantKey) { +// if (CollectionUtils.isEmpty(insuranceCategoryPOS)) { +// return Collections.emptyList(); +// } +// return insuranceCategoryPOS.stream().map(item -> +// InsuranceCategoryListDTO.builder() +// .id(item.getId()) +// .isUse(item.getIsUse()) +// .welfareType(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, matchWelfareTypeEnum(item.getWelfareType()).getLabelId(), +// matchWelfareTypeEnum(item.getWelfareType()).getDefaultLabel())) +// .paymentScopt(buildPaymentScope(item.getPaymentScope(), employeeId, tenantKey)) +// .insuranceName(item.getInsuranceName()) +// .build() +// ).collect(Collectors.toList()); +// } +// +// public static String buildPaymentScope(String paymentScopeValues, Long employeeId, String tenantKey) { +// if (StringUtils.isBlank(paymentScopeValues)) { +// return ""; +// } +// List collect = Arrays.stream(paymentScopeValues.split(",")).map(item -> { +// PaymentScopeEnum paymentScopeEnum = SalaryEnumUtil.enumMatchByValue(Integer.valueOf(item), PaymentScopeEnum.values(), PaymentScopeEnum.class); +// return SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, paymentScopeEnum.getLabelId(), paymentScopeEnum.getDefaultLabel()); +// }).collect(Collectors.toList()); +// +// return StringUtils.join(collect, "、"); +// } +// +// public static WelfareTypeEnum matchWelfareTypeEnum(Integer value) { +// return SalaryEnumUtil.enumMatchByValue(value, WelfareTypeEnum.values(), WelfareTypeEnum.class); +// } +//} diff --git a/src/com/engine/salary/entity/sicategory/dto/ICategoryDTO.java b/src/com/engine/salary/entity/sicategory/dto/ICategoryDTO.java new file mode 100644 index 000000000..b63254f4c --- /dev/null +++ b/src/com/engine/salary/entity/sicategory/dto/ICategoryDTO.java @@ -0,0 +1,53 @@ +package com.engine.salary.entity.sicategory.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author Harryxzy + * @date 2022/10/14 13:54 + * @description + */ +@Builder +@Data +@AllArgsConstructor +@NoArgsConstructor +public class ICategoryDTO { + + /** + * 主键id + */ + private Long id; + + /** + * 福利名称 + */ + private String insuranceName; + + /** + * 福利类型 + */ + private Integer welfareType; + + /** + * 福利类型 + */ + private String welfareTypeSpan; + + /** + * 缴纳对象 + */ + private String paymentScope; + + /** + * 缴纳对象 + */ + private String paymentScopeSpan; + + /** + * 是否启用 + */ + private Integer isUse; +} diff --git a/src/com/engine/salary/entity/sicategory/dto/ICategoryFormDTO.java b/src/com/engine/salary/entity/sicategory/dto/ICategoryFormDTO.java new file mode 100644 index 000000000..515b1bc13 --- /dev/null +++ b/src/com/engine/salary/entity/sicategory/dto/ICategoryFormDTO.java @@ -0,0 +1,48 @@ +package com.engine.salary.entity.sicategory.dto; + +import com.engine.salary.enums.sicategory.PaymentScopeEnum; +import com.engine.salary.enums.sicategory.WelfareTypeEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Author weaver_cl + * @Description: 自定义福利表单 + * @Date 2022/3/9 + * @Version V1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class ICategoryFormDTO { + + /** + * 主键id + */ + private Long id; + + /** + * 福利名称 + */ + private String insuranceName; + + /** + * 福利类型 + */ + private WelfareTypeEnum welfareType; + + /** + * 缴纳对象 + */ + private PaymentScopeEnum[] paymentScope; + + /** + * 是否启用 + */ + private Integer isUse; + + +} diff --git a/src/com/engine/salary/entity/sicategory/dto/ICategoryListDTO.java b/src/com/engine/salary/entity/sicategory/dto/ICategoryListDTO.java new file mode 100644 index 000000000..238d4ec13 --- /dev/null +++ b/src/com/engine/salary/entity/sicategory/dto/ICategoryListDTO.java @@ -0,0 +1,58 @@ +package com.engine.salary.entity.sicategory.dto; + +import com.engine.salary.annotation.SalaryTable; +import com.engine.salary.annotation.SalaryTableColumn; +import com.engine.salary.annotation.TableTitle; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Author weaver_cl + * + * @Date 2022/3/11 + * @Version V1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@SalaryTable(pageId = "ee8c0e7f-4096-4150-9491-823e24d37765", + fields = "id, insurance_name, is_use, welfare_type, payment_scope", + fromSql = "FROM hrsa_insurance_category", + orderby = "id desc", + primarykey = "id" + // operates = { + // @SalaryTableOperate(index = "0", text = "编辑"), + // } +) +public class ICategoryListDTO { + + @SalaryTableColumn(column = "id", display = false) + private Long id; + + + @SalaryTableColumn(column = "insurance_name", width = "20%", text = "福利名称") + @TableTitle(title = "福利名称",dataIndex = "insuranceName",key = "insuranceName") + private String insuranceName; + + + @SalaryTableColumn(column = "is_use", width = "20%", text = "是否启用") + @TableTitle(title = "启用",dataIndex = "isUse",key = "isUse") + private Integer isUse; + + @SalaryTableColumn(column = "welfare_type", width = "20%", text = "类型", transmethod ="com.engine.salary.transmethod.ICategoryTransMethod.getWelfareTypeName") + @TableTitle(title = "类型",dataIndex = "welfareType",key = "welfareType") + private String welfareType; + private String welfareTypeSpan; + + + @SalaryTableColumn(column = "payment_scope", width = "30%", text = "缴纳对象",transmethod = "com.engine.salary.transmethod.ICategoryTransMethod.getPaymentcopeTypeName") + @TableTitle(title = "缴纳对象",dataIndex = "paymentScope",key = "paymentScope") + private String paymentScope; + private String paymentScopeSpan; + + @SalaryTableColumn(column = "operate", width = "10%", text = "操作") + private String operate; +} diff --git a/src/com/engine/salary/entity/sicategory/param/ICategoryListQueryParam.java b/src/com/engine/salary/entity/sicategory/param/ICategoryListQueryParam.java new file mode 100644 index 000000000..cf0e79c62 --- /dev/null +++ b/src/com/engine/salary/entity/sicategory/param/ICategoryListQueryParam.java @@ -0,0 +1,8 @@ +package com.engine.salary.entity.sicategory.param; + +import com.engine.salary.enums.sicategory.WelfareTypeEnum; + +public class ICategoryListQueryParam { + WelfareTypeEnum welfareType; + +} diff --git a/src/com/engine/salary/entity/sicategory/param/UpdateStatusParam.java b/src/com/engine/salary/entity/sicategory/param/UpdateStatusParam.java new file mode 100644 index 000000000..ccb54749f --- /dev/null +++ b/src/com/engine/salary/entity/sicategory/param/UpdateStatusParam.java @@ -0,0 +1,29 @@ +package com.engine.salary.entity.sicategory.param; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Author weaver_cl + * @Description: 自定义福利状态更新 + * @Date 2022/3/10 + * @Version V1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class UpdateStatusParam { + + /** + * id + */ + private Long id; + + /** + * 状态 + */ + private Integer isUse; +} diff --git a/src/com/engine/salary/entity/sicategory/po/ICategoryPO.java b/src/com/engine/salary/entity/sicategory/po/ICategoryPO.java new file mode 100644 index 000000000..b2fd625b3 --- /dev/null +++ b/src/com/engine/salary/entity/sicategory/po/ICategoryPO.java @@ -0,0 +1,76 @@ +package com.engine.salary.entity.sicategory.po; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; + +/** + * @Author weaver_cl + * @Description: hrsa_insurance_category 福利类型配置表 + * @Date 2022/3/9 + * @Version V1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class ICategoryPO { + + /** + * 主键id + */ + private Long id; + + /** + * 福利名称 + */ + private String insuranceName; + + /** + * 福利类型 1-社保,2-公积金,3-企业年金及其它福利' + */ + private Integer welfareType; + + /** + * 是否启用 0-停用 1-启用 + */ + private Integer isUse; + + /** + * 缴费对象 1-公司 2-个人 + */ + private String paymentScope; + + /** + * 数据类型(0-自定义 1-系统) + */ + private Integer dataType; + + /** + * 租户key + */ + private String tenantKey; + + /** + * 创建人id + */ + private Long creator; + + /** + * 是否删除 + */ + private Integer deleteType; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 更新时间 + */ + private Date updateTime; +} diff --git a/src/com/engine/salary/entity/siexport/param/InsuranceExportParam.java b/src/com/engine/salary/entity/siexport/param/InsuranceExportParam.java new file mode 100644 index 000000000..ae4cfc61a --- /dev/null +++ b/src/com/engine/salary/entity/siexport/param/InsuranceExportParam.java @@ -0,0 +1,48 @@ +package com.engine.salary.entity.siexport.param; + +import com.engine.salary.common.BaseQueryParam; +import com.engine.salary.util.valid.DataCheck; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + + +/** + * @Author weaver_cl + * @Description: 导出 + * @Date 2022/3/7 + * @Version V1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class InsuranceExportParam extends BaseQueryParam { + + //@NotBlank + @DataCheck(require = true,message = "账单月份不可为空") + private String billMonth; + + private String paymentOrganization; + + private Long creator; + + private Integer paymentStatus; + + private List employeeIds; + + private String userName; + + + /** + * 退差月份 + */ + private List recessionMonthList; + + private List taxAgents; + + private String workcode; +} diff --git a/src/com/engine/salary/entity/siexport/po/AccountExportPO.java b/src/com/engine/salary/entity/siexport/po/AccountExportPO.java new file mode 100644 index 000000000..cb7324228 --- /dev/null +++ b/src/com/engine/salary/entity/siexport/po/AccountExportPO.java @@ -0,0 +1,33 @@ +package com.engine.salary.entity.siexport.po; + +import com.engine.salary.annotation.I18n; +import com.engine.salary.entity.siaccount.po.InsuranceAccountDetailPO; +import lombok.Data; + +/** + * @Author weaver_cl + * @Description: + * @Date 2022/3/7 + * @Version V1.0 + **/ +@Data +public class AccountExportPO extends InsuranceAccountDetailPO { + + @I18n + private String userName; + + private String telephone; + + private String idNo; + + @I18n + private String departmentName; + @I18n + private String fixedDepartmentName; + + + private Integer userStatus; + private Integer fixedUserStatus; + + private String workcode; +} diff --git a/src/com/engine/salary/entity/siexport/po/ExcelAccountExportPO.java b/src/com/engine/salary/entity/siexport/po/ExcelAccountExportPO.java new file mode 100644 index 000000000..df88ef3e2 --- /dev/null +++ b/src/com/engine/salary/entity/siexport/po/ExcelAccountExportPO.java @@ -0,0 +1,61 @@ +package com.engine.salary.entity.siexport.po; + +import com.engine.salary.entity.siaccount.po.ExcelInsuranceDetailPO; + +/** + * @Author: sy + * @Description: + * @Date: 2022/9/28 + **/ +public class ExcelAccountExportPO extends ExcelInsuranceDetailPO { + + private String userName; + + private String telephone; + + private String departmentName; + + private Integer userStatus; + + private String workcode; + + public void setWorkcode(String workcode) { + this.workcode = workcode; + } + + public String getWorkcode() { + return workcode; + } + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public String getTelephone() { + return telephone; + } + + public void setTelephone(String telephone) { + this.telephone = telephone; + } + + public String getDepartmentName() { + return departmentName; + } + + public void setDepartmentName(String departmentName) { + this.departmentName = departmentName; + } + + public Integer getUserStatus() { + return userStatus; + } + + public void setUserStatus(Integer userStatus) { + this.userStatus = userStatus; + } +} diff --git a/src/com/engine/salary/entity/sischeme/bo/InsuranceSchemeBO.java b/src/com/engine/salary/entity/sischeme/bo/InsuranceSchemeBO.java new file mode 100644 index 000000000..f1f844e0d --- /dev/null +++ b/src/com/engine/salary/entity/sischeme/bo/InsuranceSchemeBO.java @@ -0,0 +1,94 @@ +package com.engine.salary.entity.sischeme.bo; + +import com.engine.salary.constant.SalaryDefaultTenantConstant; +import com.engine.salary.entity.sischeme.dto.InsuranceSchemeDTO; +import com.engine.salary.entity.sischeme.dto.InsuranceSchemeDetailDTO; +import com.engine.salary.entity.sischeme.po.InsuranceSchemeDetailPO; +import com.engine.salary.entity.sischeme.po.InsuranceSchemePO; +import com.engine.salary.enums.sicategory.DeleteTypeEnum; +import com.engine.salary.enums.sicategory.IsPaymentEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import org.apache.commons.collections4.CollectionUtils; + +import java.util.Collections; +import java.util.Date; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; + +/** + * @Author weaver_cl + * @Description: 福利方案业务方法 + * @Date 2022/3/8 + * @Version V1.0 + **/ +public class InsuranceSchemeBO { + + private InsuranceSchemeBO() { + throw new SalaryRunTimeException("该类不需要创建实例"); + } + + + public static InsuranceSchemePO convert2BatchPO(InsuranceSchemeDTO dto, Long employeeId) { + if (Objects.isNull(dto)) { + return null; + } + + return InsuranceSchemePO.builder() + .schemeName(dto.getSchemeName()) + .paymentType(dto.getPaymentType().getValue()) + .welfareType(dto.getWelfareType().getValue()) + .sharedType(dto.getSharedType()) + .taxAgentIds(dto.getTaxAgentIds()) + .isUse(1) + .paymentArea(dto.getPaymentArea()) + .remarks(dto.getRemarks()) + .creator(employeeId) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .createTime(new Date()) + .updateTime(new Date()) + .deleteType(0) + .build(); + } + + + public static List convertToInsuranceSchemeDetailPoList(List list, long employeeId,Long primaryId) { + if (CollectionUtils.isEmpty(list)) { + return Collections.emptyList(); + } + return list.stream().map(item -> InsuranceSchemeDetailPO.builder() + .insuranceId(item.getInsuranceId()) + .primaryId(primaryId) + .createTime(new Date()) + .creator(employeeId) + .deleteType(DeleteTypeEnum.NOT_DELETED.getValue()) + .effectiveTime(item.getEffectiveTime()) + .expirationTime(item.getExpirationTime()) + .fixedCost(item.getFixedCost() != null ? item.getFixedCost().toString() : "0.000") + .isPayment(item.getIsPayment() ? IsPaymentEnum.YES.getValue() : IsPaymentEnum.NO.getValue()) + .lowerLimit(item.getLowerLimit() != null ? item.getLowerLimit().toString() : "0.000") + .paymentScope(item.getPaymentScopeValue()) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .upperLimit(item.getUpperLimit() != null ? item.getUpperLimit().toString() : "0.000") + .paymentProportion(item.getPaymentProportion() != null ? item.getPaymentProportion().toString() : "0.0000") + .rententionRule(item.getRententionRule() != null ? Integer.valueOf(item.getRententionRule()) : null) + .paymentCycle(Integer.parseInt(item.getPaymentCycle())) + .cycleSetting(item.getCycleSetting()) + .accountType(Integer.parseInt(item.getAccountType())) + .updateTime(new Date()) + .validNum(item.getValidNum()==null ? 2 : item.getValidNum()) + .build() + ).collect(Collectors.toList()); + } + + public static InsuranceSchemePO buildInsuranceSchemePO(InsuranceSchemePO po, InsuranceSchemeDTO dto) { + po.setUpdateTime(new Date()); + po.setPaymentArea(dto.getPaymentArea()); + po.setPaymentType(dto.getPaymentType().getValue()); + po.setSchemeName(dto.getSchemeName()); + po.setRemarks(dto.getRemarks()); + po.setSharedType(dto.getSharedType()); + po.setTaxAgentIds(dto.getTaxAgentIds()); + return po; + } +} diff --git a/src/com/engine/salary/entity/sischeme/dto/InsuranceSchemeDTO.java b/src/com/engine/salary/entity/sischeme/dto/InsuranceSchemeDTO.java new file mode 100644 index 000000000..f27776bc1 --- /dev/null +++ b/src/com/engine/salary/entity/sischeme/dto/InsuranceSchemeDTO.java @@ -0,0 +1,67 @@ +package com.engine.salary.entity.sischeme.dto; + +import com.engine.salary.enums.sicategory.PaymentTypeEnum; +import com.engine.salary.enums.sicategory.SharedTypeEnum; +import com.engine.salary.enums.sicategory.WelfareTypeEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Author weaver_cl + * @Description: 社保方案基础信息表单 + * @Date 2022/3/7 + * @Version V1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class InsuranceSchemeDTO { + + /** + * 主键id + */ + private Long id; + + /** + * 缴纳地区 + */ + private String paymentArea; + + /** + * 缴纳类型 + */ + private PaymentTypeEnum paymentType; + + /** + * 方案名称 + */ + private String schemeName; + + /** + * 共享权限 + * @see SharedTypeEnum + */ + private String sharedType; + + /** + * 个税扣缴义务人 + */ + private String taxAgentIds; + + /** + * 备注 + */ + private String remarks; + + /** + * 福利类型 + */ + private WelfareTypeEnum welfareType; + + + +} + diff --git a/src/com/engine/salary/entity/sischeme/dto/InsuranceSchemeDetailDTO.java b/src/com/engine/salary/entity/sischeme/dto/InsuranceSchemeDetailDTO.java new file mode 100644 index 000000000..c291c7eff --- /dev/null +++ b/src/com/engine/salary/entity/sischeme/dto/InsuranceSchemeDetailDTO.java @@ -0,0 +1,111 @@ +package com.engine.salary.entity.sischeme.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.math.BigDecimal; + +/** + * @Author weaver_cl + * @Description: 福利方案明细表单 + * @Date 2022/3/7 + * @Version V1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class InsuranceSchemeDetailDTO { + + /** + * 主键id + */ + private Long id; + + /** + * 社保方案主表id + */ + private Long primaryId; + + /** + * 险种id + */ + private Long insuranceId; + + /** + * 险种名称 + */ + private String insuranceName; + + /** + * 是否缴费 + */ + private Boolean isPayment; + + /** + * 生效年月(含) + */ + private String effectiveTime; + + /** + * 失效年月(不含) + */ + private String expirationTime; + + /** + * 缴纳对象枚举label 1-公司 2-个人 + */ + private String paymentScope; + + /** + * 缴纳对象枚举value 1-公司 2-个人 + */ + private Integer paymentScopeValue; + + /** + * 基数上限 + */ + private BigDecimal upperLimit; + + /** + * 基数下限 + */ + private BigDecimal lowerLimit; + + /** + * 缴纳比例 + */ + private BigDecimal paymentProportion; + + /** + * 固定费用 + */ + private BigDecimal fixedCost; + + /** + * 有效小数位 + */ + private Integer validNum; + + /** + * 进位规则 + */ + private String rententionRule; + + /** + * 缴纳周期 + */ + private String paymentCycle; + + /** + * 核算方式 + */ + private String accountType; + + /** + * 缴纳周期规则设置 + */ + private String cycleSetting; +} diff --git a/src/com/engine/salary/entity/sischeme/dto/InsuranceSchemeListDTO.java b/src/com/engine/salary/entity/sischeme/dto/InsuranceSchemeListDTO.java new file mode 100644 index 000000000..a077df22a --- /dev/null +++ b/src/com/engine/salary/entity/sischeme/dto/InsuranceSchemeListDTO.java @@ -0,0 +1,63 @@ +package com.engine.salary.entity.sischeme.dto; + +import com.cloudstore.eccom.pc.table.WeaTableType; +import com.engine.salary.annotation.SalaryTable; +import com.engine.salary.annotation.SalaryTableOperate; +import com.engine.salary.annotation.TableTitle; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Author weaver_cl + * + * @Date 2022/4/22 + * @Version V1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@SalaryTable(pageId = "f5f6fcf7-9db5-25da-419f-750f62a6095c", tableType = WeaTableType.NONE,operates = { + @SalaryTableOperate(index = "0", text = "编辑"), + @SalaryTableOperate(index = "1", text = "复制"), +}) +public class InsuranceSchemeListDTO { + + @TableTitle(title = "id", dataIndex = "id", key = "id",display = false) + private Long id; + + @TableTitle(title = "方案名称", dataIndex = "schemeName", key = "schemeName") + private String schemeName; + + @TableTitle(title = "缴纳类型", dataIndex = "paymentType", key = "paymentType") + private String paymentType; + + /* @WeaFormat( + label = "缴纳地区", + labelId = 87613, + tableColumn = @TableColumn(width = "10%") + )* + * 等前端组件,暂时频闭 + / + */ + @TableTitle(title = "缴纳地区", dataIndex = "paymentArea", key = "paymentArea",display = false) + private String paymentArea; + + @TableTitle(title = "缴纳范围", dataIndex = "paymentScope", key = "paymentScope") + private String paymentScope; + + + @TableTitle(title = "备注", dataIndex = "remarks", key = "remarks") + private String remarks; + + /* @WeaFormat( + label = "参保人数", + labelId = 87619, + tableColumn = @TableColumn(width = "5%") + ) + 参保人数") + private String Num;*/ + +} diff --git a/src/com/engine/salary/entity/sischeme/param/InsuranceSchemeDetailUpdateParam.java b/src/com/engine/salary/entity/sischeme/param/InsuranceSchemeDetailUpdateParam.java new file mode 100644 index 000000000..1fc83a32f --- /dev/null +++ b/src/com/engine/salary/entity/sischeme/param/InsuranceSchemeDetailUpdateParam.java @@ -0,0 +1,61 @@ +package com.engine.salary.entity.sischeme.param; + +import com.engine.salary.entity.sischeme.dto.InsuranceSchemeDTO; +import com.engine.salary.entity.sischeme.dto.InsuranceSchemeDetailDTO; +import com.engine.salary.enums.sicategory.WelfareTypeEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.math.BigDecimal; +import java.util.List; + + +/** + * @Author sy + * @Description: 福利方案明细修改 + * @Date 2023/8/21 + * @Version V1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class InsuranceSchemeDetailUpdateParam { + + /** + * 社保方案主表id + */ + private Long primaryId; + + /** + * 险种id + */ + private Long insuranceId; + + /** + * 是否缴费 + */ + private Integer isPayment; + + + /** + * 缴纳对象枚举value 1-公司 2-个人 + */ + private Integer paymentScope; + + + /** + * 缴纳比例 + */ + private String paymentProportion; + + /** + * 固定费用 + */ + private String fixedCost; + + + +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/sischeme/param/InsuranceSchemeParam.java b/src/com/engine/salary/entity/sischeme/param/InsuranceSchemeParam.java new file mode 100644 index 000000000..cdc4b29f4 --- /dev/null +++ b/src/com/engine/salary/entity/sischeme/param/InsuranceSchemeParam.java @@ -0,0 +1,46 @@ +package com.engine.salary.entity.sischeme.param; + +import com.engine.salary.common.BaseQueryParam; +import com.engine.salary.enums.sicategory.PaymentTypeEnum; +import com.engine.salary.enums.sicategory.WelfareTypeEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Author weaver_cl + * + * @Date 2022/4/22 + * @Version V1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class InsuranceSchemeParam extends BaseQueryParam { + + //方案名称或者缴纳地区搜索条件 + private String searchCondition; + + private WelfareTypeEnum welfareTypeEnum; + + /** + * 缴纳类型 + */ + private PaymentTypeEnum paymentTypeEnum; + + /** + * 方案名称 + */ + private String schemeName; + + /** + * 缴纳类型 + */ + private Integer paymentType; + /** + * 福利类型 + */ + private Integer welfareType; +} diff --git a/src/com/engine/salary/entity/sischeme/param/InsuranceSchemeReqParam.java b/src/com/engine/salary/entity/sischeme/param/InsuranceSchemeReqParam.java new file mode 100644 index 000000000..c9ed91a55 --- /dev/null +++ b/src/com/engine/salary/entity/sischeme/param/InsuranceSchemeReqParam.java @@ -0,0 +1,54 @@ +package com.engine.salary.entity.sischeme.param; + +import com.engine.salary.entity.sischeme.dto.InsuranceSchemeDTO; +import com.engine.salary.entity.sischeme.dto.InsuranceSchemeDetailDTO; +import com.engine.salary.enums.sicategory.WelfareTypeEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + + +/** + * @Author weaver_cl + * @Description: 福利方案DTO + * @Date 2022/3/8 + * @Version V1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class InsuranceSchemeReqParam { + + private Boolean isMobile; + + /** + * 福利方案基本信息 + */ + private InsuranceSchemeDTO insuranceScheme; + + /** + * 福利方案明细 + */ + private List insuranceSchemeDetailList; + + /** + * 福利类型 + */ + private WelfareTypeEnum welfareTypeEnum; + + private List ids; + + /** + * 是否修改档案数据为上限或下限 + */ + private Boolean changeData; + + /** + * 校验是否有档案不满足上下限 + */ + private Boolean validate; +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/sischeme/param/SISchemaImportParam.java b/src/com/engine/salary/entity/sischeme/param/SISchemaImportParam.java new file mode 100644 index 000000000..7e49621c2 --- /dev/null +++ b/src/com/engine/salary/entity/sischeme/param/SISchemaImportParam.java @@ -0,0 +1,30 @@ +package com.engine.salary.entity.sischeme.param; + +import com.engine.salary.util.valid.DataCheck; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 福利档案导入参数 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SISchemaImportParam { + //上传文件id + @DataCheck(require = true,message = "imageId为空") + String imageId; + + /** + * 福利执行状态 + */ + String runStatus; + + /** + * 是否是外部人员 + */ + boolean isExtEmp; +} diff --git a/src/com/engine/salary/entity/sischeme/po/InsuranceSchemeDetailPO.java b/src/com/engine/salary/entity/sischeme/po/InsuranceSchemeDetailPO.java new file mode 100644 index 000000000..e7ce260f1 --- /dev/null +++ b/src/com/engine/salary/entity/sischeme/po/InsuranceSchemeDetailPO.java @@ -0,0 +1,156 @@ +package com.engine.salary.entity.sischeme.po; + +import com.engine.salary.annotation.Encrypt; +import com.engine.hrmelog.annotation.ElogTransform; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; + + +/** + * @Author weaver_cl + * @Description: hrsa_scheme_detail 社保方案明细主表 + * @Date 2022/3/8 + * @Version V1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//hrsa_scheme_detail +@ElogTransform(name = "福利方案明细") +public class InsuranceSchemeDetailPO { + + /** + * 主键id + */ + @ElogTransform(name = "主键id") + private Long id; + + /** + * 社保方案主表id + */ + @ElogTransform(name = "方案主表id") + private Long primaryId; + + /** + * 险种id + */ + @ElogTransform(name = "福利项id") + private Long insuranceId; + + /** + * 生效年月(含) + */ + @ElogTransform(name = "生效年月") + private String effectiveTime; + + /** + * 失效年月(不含) + */ + @ElogTransform(name = "失效年月") + private String expirationTime; + + /** + * 是否缴费 0-否 1-是 + */ + @ElogTransform(name = "是否缴费") + private Integer isPayment; + + /** + * 缴纳对象 + */ + @ElogTransform(name = "缴纳对象") + private Integer paymentScope; + + /** + * 基数上限 + */ + @Encrypt + @ElogTransform(name = "基数上限") + private String upperLimit; + + /** + * 基数下限 + */ + @Encrypt + @ElogTransform(name = "基数下限") + private String lowerLimit; + + /** + * 缴纳比例 + */ + @ElogTransform(name = "缴纳比例") + private String paymentProportion; + + /** + * 固定费用 + */ + @Encrypt + @ElogTransform(name = "固定费用") + private String fixedCost; + + /** + * 有效小数位 + */ + @ElogTransform(name = "有效小数位") + private Integer validNum; + + /** + * 进位规则 + */ + @ElogTransform(name = "进位规则") + private Integer rententionRule; + + /** + * 缴纳周期,0不进行周期缴纳,1进行周期缴纳 + */ + @ElogTransform(name = "是否周期缴纳") + private Integer paymentCycle; + + /** + * 核算方式 + */ + @ElogTransform(name = "核算方式") + private Integer accountType; + + /** + * 缴纳周期规则设置 + */ + @ElogTransform(name = "缴纳周期规则设置") + private String cycleSetting; + + /** + * 创建人id + */ + @ElogTransform(name = "创建人id") + private Long creator; + + /** + * 是否删除 + */ + @ElogTransform(name = "是否删除") + private Integer deleteType; + + /** + * 创建时间 + */ + @ElogTransform(name = "创建时间") + private Date createTime; + + /** + * 更新时间 + */ + @ElogTransform(name = "更新时间") + private Date updateTime; + + /** + * 租户key + */ + @ElogTransform(name = "租户key") + private String tenantKey; +} + diff --git a/src/com/engine/salary/entity/sischeme/po/InsuranceSchemePO.java b/src/com/engine/salary/entity/sischeme/po/InsuranceSchemePO.java new file mode 100644 index 000000000..e832d801d --- /dev/null +++ b/src/com/engine/salary/entity/sischeme/po/InsuranceSchemePO.java @@ -0,0 +1,113 @@ +package com.engine.salary.entity.sischeme.po; + +import com.engine.hrmelog.annotation.ElogTransform; +import com.engine.salary.enums.sicategory.SharedTypeEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; + + +/** + * @Author weaver_cl + * @Description: hrsa_social_security_scheme 社保方案主表 + * @Date 2022/3/7 + * @Version V1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//hrsa_social_security_scheme +@ElogTransform(name = "福利方案") +public class InsuranceSchemePO { + + /** + * 主键id + */ + @ElogTransform(name = "主键id") + private Long id; + + /** + * 缴纳地区 + */ + @ElogTransform(name = "缴纳地区") + private String paymentArea; + + /** + * 方案名称 + */ + @ElogTransform(name = "方案名称") + private String schemeName; + + /** + * 缴纳类型 + */ + @ElogTransform(name = "缴纳类型") + private Integer paymentType; + + /** + * 福利类型 + */ + @ElogTransform(name = "福利类型") + private Integer welfareType; + + /** + * 共享权限 + * + * @see SharedTypeEnum + */ + @ElogTransform(name = "共享权限") + private String sharedType; + + /** + * 个税扣缴义务人 + */ + @ElogTransform(name = "个税扣缴义务人") + private String taxAgentIds; + + + /** + * 是否启用 0-停用 1-启用 + */ + @ElogTransform(name = "是否启用") + private Integer isUse; + + /** + * 备注 + */ + @ElogTransform(name = "备注") + private String remarks; + + /** + * 创建人id + */ + @ElogTransform(name = "创建人id") + private Long creator; + + /** + * 是否删除 + */ + @ElogTransform(name = "是否删除") + private Integer deleteType; + + /** + * 创建时间 + */ + @ElogTransform(name = "创建时间") + private Date createTime; + + /** + * 更新时间 + */ + @ElogTransform(name = "更新时间") + private Date updateTime; + + /** + * 租户key + */ + @ElogTransform(name = "租户key") + private String tenantKey; +} diff --git a/src/com/engine/salary/entity/sischeme/vo/InsuranceSchemeFormVO.java b/src/com/engine/salary/entity/sischeme/vo/InsuranceSchemeFormVO.java new file mode 100644 index 000000000..9dda04288 --- /dev/null +++ b/src/com/engine/salary/entity/sischeme/vo/InsuranceSchemeFormVO.java @@ -0,0 +1,29 @@ +package com.engine.salary.entity.sischeme.vo; + +import com.engine.salary.entity.sischeme.dto.InsuranceSchemeDTO; +import com.engine.salary.entity.sischeme.dto.InsuranceSchemeDetailDTO; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * @Author weaver_cl + * + * @Date 2022/3/7 + * @Version V1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class InsuranceSchemeFormVO { + + //福利方案基本设置 + private InsuranceSchemeDTO schemeBatch; + + //福利方案设置 + private List schemeDetailList; +} diff --git a/src/com/engine/salary/entity/sischeme/vo/SISchemeTableVO.java b/src/com/engine/salary/entity/sischeme/vo/SISchemeTableVO.java new file mode 100644 index 000000000..21e2f9d5a --- /dev/null +++ b/src/com/engine/salary/entity/sischeme/vo/SISchemeTableVO.java @@ -0,0 +1,84 @@ +package com.engine.salary.entity.sischeme.vo; + +import com.engine.salary.annotation.SalaryTable; +import com.engine.salary.annotation.SalaryTableColumn; +import com.engine.salary.annotation.SalaryTableOperate; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Author weaver_cl + * + * @Date 2022/3/10 + * @Version V1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@SalaryTable(pageId = "98acb87d-1509-4078-8061-41ff45e9573b", + fields = "a.id," + + "a.scheme_name," + + "a.payment_type as paymentType," + + "GROUP_CONCAT(b.insurance_id SEPARATOR ',') insurance_id," + + "GROUP_CONCAT(c.insurance_name SEPARATOR ',') insurance_name," + + "a.remarks", + fromSql = "FROM hrsa_social_security_scheme a," + + "hrsa_scheme_detail b," + + "hrsa_insurance_category c", + orderby = "id desc", + groupby = "id", + primarykey = "id", + operates = { + @SalaryTableOperate(index = "0", text = "编辑"), + @SalaryTableOperate(index = "1", text = "复制") + } +) +public class SISchemeTableVO { + /** + * 主键 + */ + @SalaryTableColumn(column = "id", display = false) + private Long id; + + /** + * 方案名称 + */ + @SalaryTableColumn(column = "scheme_name", width = "20%", text = "方案名称") + private String schemeName; + + /** + * 缴纳类型 + */ + @SalaryTableColumn(column = "paymentType", width = "10%", text = "缴纳类型", transmethod = "com.engine.salary.transmethod.SISchemeTransMethod.getPaymentType") + private String paymentType; + + + /** + * 方案id + */ + @SalaryTableColumn(column = "insurance_id", text = "方案id",display = false) + private String insuranceId; + + + /** + * 福利名称 + */ + @SalaryTableColumn(column = "insurance_name", width = "30%", text = "福利名称") + private String insuranceName; + + /** + * 方案名称 + */ + @SalaryTableColumn(column = "remarks", width = "30%", text = "备注") + private String remarks; + + + /** + * 操作 + */ + @SalaryTableColumn(column = "operate", width = "10%", text = "操作") + private String operate; +} diff --git a/src/com/engine/salary/entity/taxagent/bo/TaxAgentBO.java b/src/com/engine/salary/entity/taxagent/bo/TaxAgentBO.java new file mode 100644 index 000000000..fa550a4dd --- /dev/null +++ b/src/com/engine/salary/entity/taxagent/bo/TaxAgentBO.java @@ -0,0 +1,437 @@ +package com.engine.salary.entity.taxagent.bo; + +import com.engine.salary.constant.SalaryDefaultTenantConstant; +import com.engine.salary.entity.agency.po.PaymentAgencyPO; +import com.engine.salary.entity.auth.po.AuthRolePO; +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.hrm.DeptInfo; +import com.engine.salary.entity.hrm.HrmStatus; +import com.engine.salary.entity.hrm.PositionInfo; +import com.engine.salary.entity.hrm.SubCompanyInfo; +import com.engine.salary.entity.taxagent.dto.TaxAgentEmployeeDTO; +import com.engine.salary.entity.taxagent.dto.TaxAgentListDTO; +import com.engine.salary.entity.taxagent.dto.TaxAgentManageRangeListDTO; +import com.engine.salary.entity.taxagent.dto.TaxAgentSubAdminListDTO; +import com.engine.salary.entity.taxagent.param.TaxAgentManageRangeSaveParam; +import com.engine.salary.entity.taxagent.param.TaxAgentSaveParam; +import com.engine.salary.entity.taxagent.param.TaxAgentSubAdminRangeSaveParam; +import com.engine.salary.entity.taxagent.po.TaxAgentAdminPO; +import com.engine.salary.entity.taxagent.po.TaxAgentManageRangePO; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import com.engine.salary.entity.taxagent.po.TaxAgentSubAdminPO; +import com.engine.salary.enums.salarysob.TargetTypeEnum; +import com.engine.salary.enums.taxagent.TaxAgentRangeTypeEnum; +import com.engine.salary.util.JsonUtil; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.page.Column; +import com.engine.salary.util.page.PageInfo; +import com.google.common.base.Joiner; +import com.google.common.collect.Lists; +import com.engine.salary.util.db.IdGenerator; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * 个税扣缴义务人 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class TaxAgentBO { + + @Override + public String toString() { + return "TaxAgentBO{}"; + } + + /** + * 根据个税扣缴义务人id和用户id判断是否匹配 + * + * @param taxAgentEmployees + * @param taxAgentId + * @param employeeId + * @return + */ + public static boolean checkTaxAgentAndEmployee(List taxAgentEmployees, Long taxAgentId, Long employeeId) { + if (CollectionUtils.isEmpty(taxAgentEmployees) && taxAgentId == null) { + return false; + } + return taxAgentEmployees.stream().anyMatch(t -> t.getTaxAgentId().equals(taxAgentId) && employeeId.equals(t.getEmployeeId())); + } + + /** + * 构建表格 + * + * @param isOpenDevolution + */ + public static void buildTaxAgentTable(PageInfo> listPage, boolean isOpenDevolution) { + // 表格表头 + List columns = new ArrayList<>(); + String name = SalaryI18nUtil.getI18nLabel(91558, "个税扣缴义务人名称"); + String employeeRange = SalaryI18nUtil.getI18nLabel(86125, "人员范围"); + String admins = SalaryI18nUtil.getI18nLabel(106259, "管理员"); + String subAdmins = SalaryI18nUtil.getI18nLabel(106283, "分管理员"); +// String paymentAgency = SalaryI18nUtil.getI18nLabel(112448, "社保福利代缴机构"); + String description = SalaryI18nUtil.getI18nLabel(84961, "备注"); + String sortedIndex = SalaryI18nUtil.getI18nLabel(84962, "显示顺序"); + + columns.add(new Column(name, "name", "name")); + columns.add(new Column(employeeRange, "employeeRange", "employeeRange")); + if (isOpenDevolution) { + columns.add(new Column(admins, "admins", "admins")); + } + columns.add(new Column(description, "description", "description")); + columns.add(new Column(sortedIndex, "sortedIndex", "sortedIndex")); + listPage.setColumns(columns); + } + + /** + * 表数据转列表数据 + * + * @param taxAgents + * @return + */ + public static List convertToListDTO(Collection taxAgents) { + if (CollectionUtils.isEmpty(taxAgents)) { + return Collections.emptyList(); + } + return taxAgents.stream() + .map(e -> TaxAgentListDTO.builder() + .id(e.getId()) + .name(e.getName()) + .description(e.getDescription()) + .build()) + .collect(Collectors.toList()); + } + + /** + * 表数据转列表数据 + * + * @param taxAgents + * @return + */ + public static List> convertToTableListDTO(List taxAgents, List paymentAgencyPOS) { + return convertToTableListDTO(Boolean.FALSE, taxAgents, paymentAgencyPOS, null, null); + } + + /** + * 表数据转列表数据 + * + * @param taxAgents + * @return + */ + public static List> convertToTableListDTO(List taxAgents, List paymentAgencyPOS, List taxAgentAdmins, + List adminList) { + return convertToTableListDTO(Boolean.TRUE, taxAgents, paymentAgencyPOS, taxAgentAdmins, adminList); + } + + /** + * 表数据转列表数据 + * + * @param taxAgents + * @param adminList + * @return + */ + public static List> convertToTableListDTO(Boolean isDevolution, List taxAgents, List paymentAgencyPOS, + List taxAgentAdmins, + List adminList) { + if (CollectionUtils.isEmpty(taxAgents)) { + return Collections.emptyList(); + } + return taxAgents.stream() + .map(e -> { + Map map = new LinkedHashMap<>(); + map.put("id", e.getId()); + map.put("name", e.getName()); + map.put("employeeRange", "设置"); +// map.put("role", rolelistMap.getOrDefault(e.getId(), Collections.emptyList()).stream().map(AuthRolePO::getName).collect(Collectors.joining(","))); + if (isDevolution) { + List empIds = taxAgentAdmins.stream().filter(t -> t.getTaxAgentId().equals(e.getId())).map(TaxAgentAdminPO::getEmployeeId).collect(Collectors.toList()); + List admins = adminList.stream().filter(a -> empIds.contains(a.getEmployeeId())).map(DataCollectionEmployee::getUsername).collect(Collectors.toList()); + map.put("admins", CollectionUtils.isEmpty(admins) ? "" : Joiner.on(",").join((Iterable) admins)); + map.put("subAdmins", "设置"); + } + map.put("paymentAgency", buildPaymentAgency(e.getPaymentAgency(), paymentAgencyPOS)); + map.put("description", e.getDescription()); + map.put("sortedIndex", e.getSortedIndex()); + return map; + }).collect(Collectors.toList()); + } + + public static List> buildPaymentAgency(String originStr, List paymentAgencyPOS) { + List> paymentAgencyList = new ArrayList<>(); + if (CollectionUtils.isEmpty(paymentAgencyPOS)) { + return paymentAgencyList; + } + originStr = StringUtils.isBlank(originStr) ? "" : originStr; + String finalOriginStr = originStr; + return paymentAgencyPOS.stream().map(e -> { + HashMap temp = new HashMap<>(); + temp.put("id", e.getId()); + temp.put("agencyName", e.getAgencyName()); + if (finalOriginStr.contains(String.valueOf(e.getId()))) { + temp.put("status", true); + } else { + temp.put("status", false); + } + return temp; + }).collect(Collectors.toList()); + } + + /** + * 保存参数转表数据 + * + * @param saveParam + * @param employeeId + * @return + */ + public static TaxAgentPO convertToPO(TaxAgentSaveParam saveParam, Long employeeId) { + if (saveParam == null) { + return null; + } + Date now = new Date(); + return TaxAgentPO.builder() +// .id(saveParam.getId()) + .name(saveParam.getName()) + .description(saveParam.getDescription()) + .createTime(now) + .updateTime(now) + .creator(employeeId) + .deleteType(0) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .sortedIndex(saveParam.getSortedIndex()) + .build(); + } + + /** + * 表数据转列表数据(分管理员) + * + * @param list + * @param range + * @param subAdminList + * @return + */ + public static List convertToSubAdminListDTO(List list, String range, List subAdminList) { + if (CollectionUtils.isEmpty(list)) { + return Collections.emptyList(); + } + return list.stream() + .map(e -> { + Optional optionalUsername = subAdminList.stream().filter(a -> e.getEmployeeId().equals(a.getEmployeeId())).map(DataCollectionEmployee::getUsername).findFirst(); + return TaxAgentSubAdminListDTO.builder() + .id(e.getId()) + .subAdmin(optionalUsername.isPresent() ? optionalUsername.get() : "") + .range(range) + .description(e.getRemark()) + .build(); + }) + .collect(Collectors.toList()); + } + + /** + * 管理范围列表转换 + * + * @param taxAgentManageRanges + * @param employeeComInfos + * @param departmentComInfos + * @param subDepartmentComInfos + * @param positionComInfos + * @param hrmStatusList + * @return + */ + public static List convert2ListDTO(List taxAgentManageRanges, List employeeComInfos, + List departmentComInfos, List subDepartmentComInfos, + List positionComInfos, List hrmStatusList) { + if (CollectionUtils.isEmpty(taxAgentManageRanges)) { + return Collections.emptyList(); + } + Map employeeComInfoMap = SalaryEntityUtil.convert2Map(employeeComInfos, DataCollectionEmployee::getEmployeeId, DataCollectionEmployee::getUsername); + Map departmentComInfoMap = SalaryEntityUtil.convert2Map(departmentComInfos, DeptInfo::getId, DeptInfo::getName); + Map subDepartmentComInfoMap = SalaryEntityUtil.convert2Map(subDepartmentComInfos, SubCompanyInfo::getId, SubCompanyInfo::getName); + Map positionComInfoMap = SalaryEntityUtil.convert2Map(positionComInfos, PositionInfo::getId, PositionInfo::getName); + + Map hrmStatusNameMap = SalaryEntityUtil.convert2Map(hrmStatusList, hrmStatus -> String.valueOf(hrmStatus.getId()), HrmStatus::getName); + + return taxAgentManageRanges.stream() + .map(taxAgentManageRange -> { + TargetTypeEnum targetTypeEnum = TargetTypeEnum.parseByValue(taxAgentManageRange.getTargetType()); + return TaxAgentManageRangeListDTO.builder() + .id(taxAgentManageRange.getId()) + .targetType(targetTypeEnum) + .targetTypeName(Optional.ofNullable(targetTypeEnum) + .map(e -> SalaryI18nUtil.getI18nLabel(e.getLabelId(), e.getDefaultLabel())) + .orElse(StringUtils.EMPTY)) + .targetId(taxAgentManageRange.getTargetId()) + .target(taxAgentManageRange.getTarget()) + .targetName(buildTargetName(taxAgentManageRange, employeeComInfoMap, departmentComInfoMap, subDepartmentComInfoMap, positionComInfoMap)) + .employeeStatus(buildEmployeeStatus(hrmStatusNameMap, taxAgentManageRange.getEmployeeStatus())) + .status(buildStatus(taxAgentManageRange.getEmployeeStatus())) + .build(); + }) + .collect(Collectors.toList()); + } + + private static String buildEmployeeStatus(Map hrmStatusNameMap, String employeeStatus) { + List employeeStatusList = JsonUtil.parseList(employeeStatus, String.class); + if (CollectionUtils.isEmpty(employeeStatusList)) { + return StringUtils.EMPTY; + } + return employeeStatusList.stream() + .map(hrmStatusNameMap::get) + .collect(Collectors.joining(",")); + } + + private static String buildStatus( String employeeStatus) { + List employeeStatusList = JsonUtil.parseList(employeeStatus, String.class); + if (CollectionUtils.isEmpty(employeeStatusList)) { + return StringUtils.EMPTY; + } + return String.join(",", employeeStatusList); + } + + /** + * 构建对象名 + * + * @param taxAgentManageRange + * @param employeeComInfoMap + * @param departmentComInfoMap + * @param subDepartmentComInfoMap + * @param positionComInfoMap + * @return + */ + private static String buildTargetName(TaxAgentManageRangePO taxAgentManageRange, Map employeeComInfoMap, Map departmentComInfoMap, + Map subDepartmentComInfoMap, Map positionComInfoMap) { + TargetTypeEnum targetTypeEnum = TargetTypeEnum.parseByValue(taxAgentManageRange.getTargetType()); + if (Objects.isNull(targetTypeEnum)) { + return StringUtils.EMPTY; + } + switch (targetTypeEnum) { + case EMPLOYEE: + return employeeComInfoMap.getOrDefault(taxAgentManageRange.getTargetId(), StringUtils.EMPTY); + case DEPT: + return departmentComInfoMap.getOrDefault(taxAgentManageRange.getTargetId(), StringUtils.EMPTY); + case SUBCOMPANY: + return subDepartmentComInfoMap.getOrDefault(taxAgentManageRange.getTargetId(), StringUtils.EMPTY); + case POSITION: + return positionComInfoMap.getOrDefault(taxAgentManageRange.getTargetId(), StringUtils.EMPTY); + case SQL: + return taxAgentManageRange.getTarget(); + default: + return StringUtils.EMPTY; + } + } + + public static Result handleTaxAgentRange(List taxAgentManageRanges, TaxAgentManageRangeSaveParam saveParam, Long taxAgentId, Long employeeId, boolean isImport) { + return handleManageRange(taxAgentManageRanges, saveParam, TaxAgentRangeTypeEnum.TAXAGENT, taxAgentId, 0L, employeeId, isImport); + } + + /** + * 处理前端传回的保存参数,转换成对应的po(如果保存参数中的人员、部门、岗位等之前就已经添加过了,就不需要再次保存了) + * + * @param taxAgentManageRanges + * @param saveParam + * @param taxAgentId + * @param subAdminId + * @param employeeId + * @return + */ + private static Result handleManageRange(List taxAgentManageRanges, TaxAgentManageRangeSaveParam saveParam, + TaxAgentRangeTypeEnum rangeTypeEnum, Long taxAgentId, Long subAdminId, Long employeeId, boolean isImport) { + Date now = new Date(); + Result handleResult = Result.builder() + .needInsertTaxAgentManageRanges(Lists.newArrayList()) + .needUpdateTaxAgentManageRanges(Lists.newArrayList()) + .build(); + if (CollectionUtils.isEmpty(saveParam.getTargetParams())) { + return handleResult; + } + Map taxAgentManageRangeMap = SalaryEntityUtil.convert2Map(taxAgentManageRanges, + e -> e.getIncludeType() + "-" + e.getTargetType() + "-" + e.getTargetId() + "-" + e.getRangeType()); + for (TaxAgentSubAdminRangeSaveParam.TaxAgentSubAdminRangeTargetParam targetParam : saveParam.getTargetParams()) { + if (targetParam.getTargetType() == TargetTypeEnum.SQL) { + TaxAgentManageRangePO taxAgentManageRange = TaxAgentManageRangePO.builder() + .id(IdGenerator.generate()) + .taxAgentId(taxAgentId) + .taxAgentSubAdminId(subAdminId) + .rangeType(rangeTypeEnum.getValue()) + .targetType(targetParam.getTargetType().getValue()) + .targetId(0L) + .target(targetParam.getTarget()) + .includeType(saveParam.getIncludeType()) + .creator(employeeId) + .createTime(now) + .updateTime(now) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .deleteType(0) + .build(); + if (isImport) { + taxAgentManageRange.setEmployeeStatus(JsonUtil.toJsonString(targetParam.getEmployeeStatus())); + } else { + taxAgentManageRange.setEmployeeStatus(JsonUtil.toJsonString(saveParam.getEmployeeStatus())); + } + handleResult.getNeedInsertTaxAgentManageRanges().add(taxAgentManageRange); + } else { + String key = saveParam.getIncludeType() + "-" + targetParam.getTargetType().getValue() + "-" + targetParam.getTargetId() + "-" + rangeTypeEnum.getValue(); + if (taxAgentManageRangeMap.containsKey(key)) { + TaxAgentManageRangePO taxAgentManageRange = taxAgentManageRangeMap.get(key); + if (isImport) { + taxAgentManageRange.setEmployeeStatus(JsonUtil.toJsonString(targetParam.getEmployeeStatus())); + } else { + taxAgentManageRange.setEmployeeStatus(JsonUtil.toJsonString(saveParam.getEmployeeStatus())); + } + taxAgentManageRange.setUpdateTime(now); + handleResult.getNeedUpdateTaxAgentManageRanges().add(taxAgentManageRange); + continue; + } + TaxAgentManageRangePO taxAgentManageRange = TaxAgentManageRangePO.builder() + .id(IdGenerator.generate()) + .taxAgentId(taxAgentId) + .taxAgentSubAdminId(subAdminId) + .rangeType(rangeTypeEnum.getValue()) + .targetType(targetParam.getTargetType().getValue()) + .targetId(targetParam.getTargetId()) + .includeType(saveParam.getIncludeType()) + .creator(employeeId) + .createTime(now) + .updateTime(now) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .deleteType(0) + .build(); + if (isImport) { + taxAgentManageRange.setEmployeeStatus(JsonUtil.toJsonString(targetParam.getEmployeeStatus())); + } else { + taxAgentManageRange.setEmployeeStatus(JsonUtil.toJsonString(saveParam.getEmployeeStatus())); + } + handleResult.getNeedInsertTaxAgentManageRanges().add(taxAgentManageRange); + } + } + return handleResult; + } + + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + public static class Result { + + /** + * 需要更新的人员范围 + */ + private Collection needUpdateTaxAgentManageRanges; + + /** + * 需要新增的人员范围 + */ + private Collection needInsertTaxAgentManageRanges; + } +} diff --git a/src/com/engine/salary/entity/taxagent/config/TaxAgentConfig.java b/src/com/engine/salary/entity/taxagent/config/TaxAgentConfig.java new file mode 100644 index 000000000..be17791cd --- /dev/null +++ b/src/com/engine/salary/entity/taxagent/config/TaxAgentConfig.java @@ -0,0 +1,28 @@ +package com.engine.salary.entity.taxagent.config; + +import com.engine.salary.entity.salarysob.config.SalarySobConfig; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import com.thoughtworks.xstream.annotations.XStreamAlias; +import com.thoughtworks.xstream.annotations.XStreamImplicit; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@XStreamAlias("TaxAgentConfig") +public class TaxAgentConfig { + + @XStreamAlias("TaxAgent") + private TaxAgentPO taxAgent; + + //薪资账套 + @XStreamImplicit + private List salarySobConfigs; + +} diff --git a/src/com/engine/salary/entity/taxagent/dto/TaxAgentAdjustRecordForFormSearchConditionDTO.java b/src/com/engine/salary/entity/taxagent/dto/TaxAgentAdjustRecordForFormSearchConditionDTO.java new file mode 100644 index 000000000..0316a764b --- /dev/null +++ b/src/com/engine/salary/entity/taxagent/dto/TaxAgentAdjustRecordForFormSearchConditionDTO.java @@ -0,0 +1,99 @@ +//package com.engine.salary.entity.taxagent.dto; +// +//import com.weaver.common.component.search.item.WeaSearchConditionItemType; +//import com.weaver.common.component.search.item.WeaSearchConditionOption; +//import com.weaver.hrm.salary.annotation.SalarySearchCondition; +//import com.weaver.hrm.salary.annotation.SalarySearchConditionItem; +//import com.weaver.hrm.salary.enums.SalaryUserStatusEnum; +//import com.weaver.hrm.salary.enums.salaryarchive.SalaryArchiveTaxAgentAdjustReasonEnum; +//import com.weaver.hrm.salary.util.SalaryI18nUtil; +//import com.weaver.teams.security.context.TenantContext; +//import com.weaver.teams.security.context.UserContext; +//import lombok.AllArgsConstructor; +//import lombok.Builder; +//import lombok.Data; +//import lombok.NoArgsConstructor; +// +//import java.util.Arrays; +//import java.util.List; +//import java.util.stream.Collectors; +// +///** +// * @Description: 薪资档案操作记录 +// * @Author: wangxiangzhong +// * @Date: 2021/11/24 17:09 +// */ +//@Data +//@Builder +//@NoArgsConstructor +//@AllArgsConstructor +//public class TaxAgentAdjustRecordForFormSearchConditionDTO { +// +// @SalarySearchCondition( +// label = "个税扣缴义务人", +// labelId = 86184, +// needQuickSearch = true, +// items = { +// @SalarySearchConditionItem(itemType = WeaSearchConditionItemType.SELECT, name = "taxAgent", options = "getTaxAgentOptions()"), +// } +// ) +// private String taxAgent; +// +// /** +// * 个税扣缴义务人选项 +// */ +// private List taxAgentOptions; +// +// @SalarySearchCondition( +// label = "调整原因", +// labelId = 85431, +// items = { +// @SalarySearchConditionItem(itemType = WeaSearchConditionItemType.SELECT, name = "adjustReason", options = "getAdjustReasonOptions()"), +// } +// ) +// private SalaryArchiveTaxAgentAdjustReasonEnum adjustReason; +// +// @SalarySearchCondition( +// label = "生效日期", +// labelId = 85904, +// items = { +// @SalarySearchConditionItem(itemType = WeaSearchConditionItemType.DATEPICKER, name = "effectiveTime") +// } +// ) +// private String effectiveTime; +// +// @SalarySearchCondition( +// label = "操作日期", +// labelId = 91058, +// items = { +// @SalarySearchConditionItem(itemType = WeaSearchConditionItemType.DATEPICKER, name = "operateTime") +// } +// ) +// private String operateTime; +// +// @SalarySearchCondition( +// label = "操作人", +// labelId = 85435, +// items = { +// @SalarySearchConditionItem(itemType = WeaSearchConditionItemType.BROWSER, browserType = "resource", browserMultiple = true, name = "operator", browserModule = "hrmsalary") +// } +// ) +// private String operator; +// +// @SalarySearchCondition( +// label = "备注", +// labelId = 84961, +// items = { +// @SalarySearchConditionItem(itemType = WeaSearchConditionItemType.INPUT, name = "description"), +// } +// ) +// private String description; +// +// private List getUserStatus(){ +// return Arrays.stream(SalaryUserStatusEnum.values()).map(m->new WeaSearchConditionOption(m.name(), SalaryI18nUtil.getI18nLabel(TenantContext.getCurrentTenantKey(), UserContext.getCurrentEmployeeId(), m.getLabelId(), m.getDefaultLabel()))).collect(Collectors.toList()); +// } +// +// private List getAdjustReasonOptions(){ +// return Arrays.stream(SalaryArchiveTaxAgentAdjustReasonEnum.values()).map(m->new WeaSearchConditionOption(m.name(), SalaryI18nUtil.getI18nLabel(TenantContext.getCurrentTenantKey(), UserContext.getCurrentEmployeeId(), m.getLabelId(), m.getDefaultLabel()))).collect(Collectors.toList()); +// } +//} diff --git a/src/com/engine/salary/entity/taxagent/dto/TaxAgentAdjustRecordListDTO.java b/src/com/engine/salary/entity/taxagent/dto/TaxAgentAdjustRecordListDTO.java new file mode 100644 index 000000000..ae82be06e --- /dev/null +++ b/src/com/engine/salary/entity/taxagent/dto/TaxAgentAdjustRecordListDTO.java @@ -0,0 +1,136 @@ +//package com.engine.salary.entity.taxagent.dto; +// +//import com.fasterxml.jackson.annotation.JsonFormat; +//import com.fasterxml.jackson.annotation.JsonIgnore; +//import com.fasterxml.jackson.databind.annotation.JsonSerialize; +//import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +//import com.weaver.common.authority.format.TableColumn; +//import com.weaver.common.authority.format.TableOperates; +//import com.weaver.common.authority.format.WeaFormat; +//import com.weaver.common.component.table.type.WeaTableTypeEnum; +//import io.swagger.annotations.ApiModel; +//import io.swagger.annotations.ApiModelProperty; +//import lombok.AllArgsConstructor; +//import lombok.Builder; +//import lombok.Data; +//import lombok.NoArgsConstructor; +// +//import java.time.LocalDate; +//import java.util.Date; +// +///** +// * @Description: 个税扣缴义务人调整记录列表 +// * @Author: wangxiangzhong +// * @Date: 2021/11/1 16:34 +// */ +//@Data +//@Builder +//@NoArgsConstructor +//@AllArgsConstructor +////"个税扣缴义务人调整记录列表") +//@TableOperates(tableType = WeaTableTypeEnum.CHECKBOX) +//public class TaxAgentAdjustRecordListDTO { +// 主键id") +// @JsonSerialize(using = ToStringSerializer.class) +// private Long id; +// +// /** +// * 人员信息表的主键id +// */ +// private Long employeeId; +// +// 姓名") +// @WeaFormat( +// label = "姓名", +// labelId = 85429, +// tableColumn = @TableColumn(width = "100") +// ) +// private String username; +// +// 部门") +// @WeaFormat( +// label = "部门", +// labelId = 86185, +// tableColumn = @TableColumn(width = "100") +// ) +// private String departmentName; +// +// 员工状态") +// @WeaFormat( +// label = "员工状态", +// labelId = 86187, +// tableColumn = @TableColumn(width = "100") +// ) +// private String employeeStatus; +// +// 调整前") +// @WeaFormat( +// label = "调整前", +// labelId = 85433, +// tableColumn = @TableColumn(width = "100") +// ) +// private String adjustBefore; +// +// 调整后") +// @WeaFormat( +// label = "调整后", +// labelId = 85434, +// tableColumn = @TableColumn(width = "100") +// ) +// private String adjustAfter; +// +// 调整原因") +// @WeaFormat( +// label = "调整原因", +// labelId = 85431, +// tableColumn = @TableColumn(width = "100") +// ) +// private String adjustReason; +// +// 生效日期") +// @WeaFormat( +// label = "生效日期", +// labelId = 85904, +// tableColumn = @TableColumn(width = "100") +// ) +// @JsonFormat(pattern = "yyyy-MM-dd") +// private LocalDate effectiveTime; +// +// 操作人") +// @WeaFormat( +// label = "操作人", +// labelId = 85435, +// tableColumn = @TableColumn(width = "100") +// ) +// private String operator; +// +// 操作时间") +// @WeaFormat( +// label = "操作时间", +// labelId = 85436, +// tableColumn = @TableColumn(width = "150") +// ) +// @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") +// private Date operateTime; +// +// 备注") +// @WeaFormat( +// label = "备注", +// labelId = 84961, +// tableColumn = @TableColumn(width = "100") +// ) +// private String description; +// +// /** +// * 薪资档案id +// */ +// @JsonIgnore +// private Long salaryArchiveId; +// +// /** +// * 个税扣缴义务人id +// */ +// @JsonIgnore +// private Long taxAgentId; +// +//} diff --git a/src/com/engine/salary/entity/taxagent/dto/TaxAgentAdjustRecordSearchConditionDTO.java b/src/com/engine/salary/entity/taxagent/dto/TaxAgentAdjustRecordSearchConditionDTO.java new file mode 100644 index 000000000..e2e7ef399 --- /dev/null +++ b/src/com/engine/salary/entity/taxagent/dto/TaxAgentAdjustRecordSearchConditionDTO.java @@ -0,0 +1,139 @@ +//package com.engine.salary.entity.taxagent.dto; +// +//import com.weaver.common.component.search.item.WeaSearchConditionItemType; +//import com.weaver.common.component.search.item.WeaSearchConditionOption; +//import com.weaver.hrm.salary.annotation.SalarySearchCondition; +//import com.weaver.hrm.salary.annotation.SalarySearchConditionItem; +//import com.weaver.hrm.salary.enums.SalaryUserStatusEnum; +//import com.weaver.hrm.salary.enums.salaryarchive.SalaryArchiveTaxAgentAdjustReasonEnum; +//import com.weaver.hrm.salary.util.SalaryI18nUtil; +//import com.weaver.teams.api.user.UserStatus; +//import com.weaver.teams.security.context.TenantContext; +//import com.weaver.teams.security.context.UserContext; +//import lombok.AllArgsConstructor; +//import lombok.Builder; +//import lombok.Data; +//import lombok.NoArgsConstructor; +// +//import java.util.Arrays; +//import java.util.List; +//import java.util.stream.Collectors; +// +///** +// * @Description: 薪资档案操作记录 +// * @Author: wangxiangzhong +// * @Date: 2021/11/24 17:09 +// */ +//@Data +//@Builder +//@NoArgsConstructor +//@AllArgsConstructor +//public class TaxAgentAdjustRecordSearchConditionDTO { +// +// @SalarySearchCondition( +// label = "姓名", +// labelId = 85429, +// needQuickSearch = true, +// quickSearchKey = "username", +// items = { +// @SalarySearchConditionItem(itemType = WeaSearchConditionItemType.INPUT, name = "username"), +// } +// ) +// private String username; +// +// @SalarySearchCondition( +// label = "岗位", +// labelId = 90633, +// items = { +// @SalarySearchConditionItem(itemType = WeaSearchConditionItemType.BROWSER, browserType = "position", browserMultiple = true, name = "position", browserModule = "hrmsalary") +// } +// ) +// private String position; +// +// @SalarySearchCondition( +// label = "状态", +// labelId = 91075, +// items = { +// @SalarySearchConditionItem(itemType = WeaSearchConditionItemType.SELECT, name = "status", options = "getUserStatus()") +// } +// ) +// private UserStatus status; +// +// @SalarySearchCondition( +// label = "部门", +// labelId = 86185, +// needQuickSearch = true, +// items = { +// @SalarySearchConditionItem(itemType = WeaSearchConditionItemType.BROWSER, browserType = "department", browserMultiple = true, name = "department", browserModule = "hrmsalary") +// } +// ) +// private String department; +// +// @SalarySearchCondition( +// label = "个税扣缴义务人", +// labelId = 86184, +// needQuickSearch = true, +// items = { +// @SalarySearchConditionItem(itemType = WeaSearchConditionItemType.SELECT, name = "taxAgent", options = "getTaxAgentOptions()"), +// } +// ) +// private String taxAgent; +// +// /** +// * 个税扣缴义务人选项 +// */ +// private List taxAgentOptions; +// +// @SalarySearchCondition( +// label = "调整原因", +// labelId = 85431, +// items = { +// @SalarySearchConditionItem(itemType = WeaSearchConditionItemType.SELECT, name = "adjustReason", options = "getAdjustReasonOptions()"), +// } +// ) +// private SalaryArchiveTaxAgentAdjustReasonEnum adjustReason; +// +// @SalarySearchCondition( +// label = "生效日期", +// labelId = 85904, +// items = { +// @SalarySearchConditionItem(itemType = WeaSearchConditionItemType.DATEPICKER, name = "effectiveTime") +// } +// ) +// private String effectiveTime; +// +// @SalarySearchCondition( +// label = "操作日期", +// labelId = 91058, +// items = { +// @SalarySearchConditionItem(itemType = WeaSearchConditionItemType.DATEPICKER, name = "operateTime") +// } +// ) +// private String operateTime; +// +// @SalarySearchCondition( +// label = "操作人", +// labelId = 85435, +// items = { +// @SalarySearchConditionItem(itemType = WeaSearchConditionItemType.BROWSER, browserType = "resource", browserMultiple = true, name = "operator", browserModule = "hrmsalary") +// } +// ) +// private String operator; +// +// @SalarySearchCondition( +// label = "备注", +// labelId = 84961, +// items = { +// @SalarySearchConditionItem(itemType = WeaSearchConditionItemType.INPUT, name = "description"), +// } +// ) +// private String description; +// +// private List getUserStatus(){ +// return Arrays.stream(SalaryUserStatusEnum.values()).map(m->new WeaSearchConditionOption(m.name(), SalaryI18nUtil.getI18nLabel(TenantContext.getCurrentTenantKey(), UserContext.getCurrentEmployeeId(), m.getLabelId(), m.getDefaultLabel()))).collect(Collectors.toList()); +// } +// +// private List getAdjustReasonOptions(){ +// return Arrays.stream(SalaryUserStatusEnum.values()).map(m->new WeaSearchConditionOption(m.name(), SalaryI18nUtil.getI18nLabel(TenantContext.getCurrentTenantKey(), UserContext.getCurrentEmployeeId(), m.getLabelId(), m.getDefaultLabel()))).collect(Collectors.toList()); +// } +//} diff --git a/src/com/engine/salary/entity/taxagent/dto/TaxAgentBaseFormDTO.java b/src/com/engine/salary/entity/taxagent/dto/TaxAgentBaseFormDTO.java new file mode 100644 index 000000000..580ddd585 --- /dev/null +++ b/src/com/engine/salary/entity/taxagent/dto/TaxAgentBaseFormDTO.java @@ -0,0 +1,30 @@ +package com.engine.salary.entity.taxagent.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 个税扣缴义务人基础信息表单 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class TaxAgentBaseFormDTO { + +// @SalaryForm( +// label = "启用分权", +// labelId = 106270, +// items = { +// @SalaryFormItem(itemType = WeaFormItemType.SWITCH) +// } +// ) + private Boolean devolutionStatus; +} diff --git a/src/com/engine/salary/entity/taxagent/dto/TaxAgentEmployeeDTO.java b/src/com/engine/salary/entity/taxagent/dto/TaxAgentEmployeeDTO.java new file mode 100644 index 000000000..aae1dd4e9 --- /dev/null +++ b/src/com/engine/salary/entity/taxagent/dto/TaxAgentEmployeeDTO.java @@ -0,0 +1,37 @@ +package com.engine.salary.entity.taxagent.dto; + +import lombok.Builder; +import lombok.Data; + +/** + * 个税扣缴义务人以及管理范围中的人员 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +public class TaxAgentEmployeeDTO { + + /** + * 个税扣缴义务人id + */ + private Long taxAgentId; + + /** + * 个税扣缴义务人名称 + */ + private String taxAgentName; + + /** + * 人员id + */ + private Long employeeId; + + /** + * 名字 + */ + private String username; +} diff --git a/src/com/engine/salary/entity/taxagent/dto/TaxAgentEmployeeOptionDTO.java b/src/com/engine/salary/entity/taxagent/dto/TaxAgentEmployeeOptionDTO.java new file mode 100644 index 000000000..3a1264cff --- /dev/null +++ b/src/com/engine/salary/entity/taxagent/dto/TaxAgentEmployeeOptionDTO.java @@ -0,0 +1,25 @@ +package com.engine.salary.entity.taxagent.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 个税扣缴义务人人员选项 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class TaxAgentEmployeeOptionDTO { + + private Long id; + + private String content; +} diff --git a/src/com/engine/salary/entity/taxagent/dto/TaxAgentEmployeeTaxAgentDTO.java b/src/com/engine/salary/entity/taxagent/dto/TaxAgentEmployeeTaxAgentDTO.java new file mode 100644 index 000000000..976fcddc1 --- /dev/null +++ b/src/com/engine/salary/entity/taxagent/dto/TaxAgentEmployeeTaxAgentDTO.java @@ -0,0 +1,29 @@ +package com.engine.salary.entity.taxagent.dto; + +import lombok.Builder; +import lombok.Data; + +import java.util.List; + +/** + * 管理范围的人员与个税扣缴义务人的关联数据 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +public class TaxAgentEmployeeTaxAgentDTO { + + /** + * 人员id + */ + private Long employeeId; + + /** + * 个税扣缴义务人id列表 + */ + private List taxAgentIds; +} diff --git a/src/com/engine/salary/entity/taxagent/dto/TaxAgentFormDTO.java b/src/com/engine/salary/entity/taxagent/dto/TaxAgentFormDTO.java new file mode 100644 index 000000000..e9f7d5cbd --- /dev/null +++ b/src/com/engine/salary/entity/taxagent/dto/TaxAgentFormDTO.java @@ -0,0 +1,37 @@ +package com.engine.salary.entity.taxagent.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * 个税扣缴义务人表单 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class TaxAgentFormDTO { + + private Long id; + + //名称 + private String name; + + //管理员 + private List adminUserIds; + + //排序 + private Integer sortedIndex; + + //备注 + private String description; +} diff --git a/src/com/engine/salary/entity/taxagent/dto/TaxAgentListDTO.java b/src/com/engine/salary/entity/taxagent/dto/TaxAgentListDTO.java new file mode 100644 index 000000000..9223f2b9a --- /dev/null +++ b/src/com/engine/salary/entity/taxagent/dto/TaxAgentListDTO.java @@ -0,0 +1,42 @@ +package com.engine.salary.entity.taxagent.dto; + +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Description: 个税扣缴义务人列表 + * @Author: wangxiangzhong + * @Date: 2021/10/29 15:39 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +////"个税扣缴义务人列表") +//@TableOperates(value = { +// @Operates(index = 0, text = "编辑" ,labelId = 59943), +// @Operates(index = 1, text = "删除" ,labelId = 59942) +//}, tableType = WeaTableTypeEnum.NONE) +public class TaxAgentListDTO { + + @JsonSerialize(using = ToStringSerializer.class) + private Long id; + +// @WeaFormat( +// label = "个税扣缴义务人名称", +// labelId = 91558, +// tableColumn = @TableColumn(width = "40%") +// ) + private String name; + +// @WeaFormat( +// label = "备注", +// labelId = 84961, +// tableColumn = @TableColumn(width = "40%") +// ) + private String description; +} diff --git a/src/com/engine/salary/entity/taxagent/dto/TaxAgentManageRangeEmployeeDTO.java b/src/com/engine/salary/entity/taxagent/dto/TaxAgentManageRangeEmployeeDTO.java new file mode 100644 index 000000000..367f71d53 --- /dev/null +++ b/src/com/engine/salary/entity/taxagent/dto/TaxAgentManageRangeEmployeeDTO.java @@ -0,0 +1,47 @@ +package com.engine.salary.entity.taxagent.dto; + +import lombok.Builder; +import lombok.Data; + +import java.util.List; + +/** + * 个税扣缴义务人以及管理范围中的人员 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +public class TaxAgentManageRangeEmployeeDTO { + + /** + * 个税扣缴义务人id + */ + private Long taxAgentId; + + /** + * 名称 + */ + private String taxAgentName; + + /** + * 人员列表 + */ + private List employeeList; + + @Data + public static class TaxAgentEmployee { + /** + * 人员id + */ + private Long employeeId; + + /** + * 名字 + */ + private String username; + } +} diff --git a/src/com/engine/salary/entity/taxagent/dto/TaxAgentManageRangeEmployeeListDTO.java b/src/com/engine/salary/entity/taxagent/dto/TaxAgentManageRangeEmployeeListDTO.java new file mode 100644 index 000000000..efb2bd799 --- /dev/null +++ b/src/com/engine/salary/entity/taxagent/dto/TaxAgentManageRangeEmployeeListDTO.java @@ -0,0 +1,80 @@ +package com.engine.salary.entity.taxagent.dto; + +import com.cloudstore.eccom.pc.table.WeaTableType; +import com.engine.salary.annotation.SalaryTable; +import com.engine.salary.annotation.SalaryTableColumn; +import com.engine.salary.annotation.SalaryTableOperate; +import com.engine.salary.annotation.TableTitle; +import com.engine.salary.util.excel.ExcelProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author Harryxzy + * @date 2023/01/06 10:48 + * @description 个税扣缴义务人-人员范围 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@SalaryTable(pageId = "a4f85287-e3f9-6614-adn9-7d06e54y6rj8", tableType = WeaTableType.CHECKBOX, operates = { + @SalaryTableOperate(text = "查看明细") +}) +public class TaxAgentManageRangeEmployeeListDTO { + + //主键id + @SalaryTableColumn(column = "id", display = false) + private Long id; + + //员工id + private Long employeeId; + + //姓名 + @SalaryTableColumn(text = "姓名", width = "10%", column = "username") + @TableTitle(title = "姓名", dataIndex = "username", key = "username") + @ExcelProperty(index = 0) + private String username; + + + /** + * 个税扣缴义务人id + */ + private Long taxAgentId; + + //部门 + @SalaryTableColumn(text = "部门", width = "10%", column = "departmentName") + @TableTitle(title = "部门", dataIndex = "departmentName", key = "departmentName") + @ExcelProperty(index = 1) + private String departmentName; + + //手机号 + @SalaryTableColumn(text = "手机号", width = "10%", column = "mobile") + @TableTitle(title = "手机号", dataIndex = "mobile", key = "mobile") + @ExcelProperty(index = 2) + private String mobile; + + //工号 + @SalaryTableColumn(text = "工号", width = "10%", column = "jobNum") + @TableTitle(title = "工号", dataIndex = "jobNum", key = "jobNum") + @ExcelProperty(index = 3) + private String jobNum; + + // + @SalaryTableColumn(text = "证件号码", width = "10%", column = "idNo") + @TableTitle(title = "证件号码", dataIndex = "idNo", key = "idNo") + @ExcelProperty(index = 4) + private String idNo; + + //人员状态 + @SalaryTableColumn(text = "员工状态", width = "10%", column = "employeeStatus") + @TableTitle(title = "员工状态", dataIndex = "employeeStatus", key = "employeeStatus") + @ExcelProperty(index = 5) + private String employeeStatus; + + + + +} diff --git a/src/com/engine/salary/entity/taxagent/dto/TaxAgentManageRangeFormDTO.java b/src/com/engine/salary/entity/taxagent/dto/TaxAgentManageRangeFormDTO.java new file mode 100644 index 000000000..406145ad7 --- /dev/null +++ b/src/com/engine/salary/entity/taxagent/dto/TaxAgentManageRangeFormDTO.java @@ -0,0 +1,37 @@ +package com.engine.salary.entity.taxagent.dto; + +import com.engine.salary.entity.hrm.HrmStatus; +import com.engine.salary.enums.salarysob.TargetTypeEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.List; +import java.util.Map; + +/** + * 范围表单 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class TaxAgentManageRangeFormDTO { + + //对象类型 + private TargetTypeEnum targetType; + + //对象id + private Long targetId; + + private List> targetTypeList; + + private Collection employeeStatus; +} diff --git a/src/com/engine/salary/entity/taxagent/dto/TaxAgentManageRangeListDTO.java b/src/com/engine/salary/entity/taxagent/dto/TaxAgentManageRangeListDTO.java new file mode 100644 index 000000000..db8f3411f --- /dev/null +++ b/src/com/engine/salary/entity/taxagent/dto/TaxAgentManageRangeListDTO.java @@ -0,0 +1,64 @@ +package com.engine.salary.entity.taxagent.dto; + +import com.engine.salary.annotation.SalaryTableColumn; +import com.engine.salary.annotation.TableTitle; +import com.engine.salary.enums.salarysob.TargetTypeEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 个税扣缴义务人管理范围列表 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class TaxAgentManageRangeListDTO { + + //主键id + private Long id; + + //对象类型 + private TargetTypeEnum targetType; + + @SalaryTableColumn( + text = "对象类型", + labelId = 90394, + width = "30%", + column="targetTypeName" + ) + //对象类型") + @TableTitle(title ="对象类型",key = "targetTypeName",dataIndex = "targetTypeName") + private String targetTypeName; + + @SalaryTableColumn( + text = "对象", + labelId = 90396, + width = "30%", + column="targetName" + ) + @TableTitle(title ="对象",key = "targetName",dataIndex = "targetName") + private String targetName; + + //对象id") + private Long targetId; + private String target; + + @SalaryTableColumn( + text = "员工状态", + labelId = 86187, + width = "30%", + column="employeeStatus" + ) + @TableTitle(title ="员工状态",key = "employeeStatus",dataIndex = "employeeStatus") + private String employeeStatus; + + private String status; +} diff --git a/src/com/engine/salary/entity/taxagent/dto/TaxAgentSubAdminBaseFormDTO.java b/src/com/engine/salary/entity/taxagent/dto/TaxAgentSubAdminBaseFormDTO.java new file mode 100644 index 000000000..8fa634d4f --- /dev/null +++ b/src/com/engine/salary/entity/taxagent/dto/TaxAgentSubAdminBaseFormDTO.java @@ -0,0 +1,33 @@ +package com.engine.salary.entity.taxagent.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * 个税扣缴义务人分管理员基础设置表单 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class TaxAgentSubAdminBaseFormDTO { + + //主键id + private Long id; + + + //分管理员 + private List subAdminUser; + + //备注 + private String description; +} diff --git a/src/com/engine/salary/entity/taxagent/dto/TaxAgentSubAdminListDTO.java b/src/com/engine/salary/entity/taxagent/dto/TaxAgentSubAdminListDTO.java new file mode 100644 index 000000000..3b7936356 --- /dev/null +++ b/src/com/engine/salary/entity/taxagent/dto/TaxAgentSubAdminListDTO.java @@ -0,0 +1,40 @@ +package com.engine.salary.entity.taxagent.dto; + +import com.engine.salary.annotation.TableTitle; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 个税扣缴义务人分管理员列表 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class TaxAgentSubAdminListDTO { + + //主键id + @JsonSerialize(using = ToStringSerializer.class) + private Long id; + + //分管理员 + @TableTitle(title = "分管理员", key = "subAdmin", dataIndex = "subAdmin") + private String subAdmin; + + //管理范围 + @TableTitle(title = "管理范围", key = "range", dataIndex = "range") + private String range; + + //备注 + @TableTitle(title = "备注", key = "description", dataIndex = "description") + private String description; +} diff --git a/src/com/engine/salary/entity/taxagent/param/TaxAgentAdjustRecordQueryParam.java b/src/com/engine/salary/entity/taxagent/param/TaxAgentAdjustRecordQueryParam.java new file mode 100644 index 000000000..3c3bce1d5 --- /dev/null +++ b/src/com/engine/salary/entity/taxagent/param/TaxAgentAdjustRecordQueryParam.java @@ -0,0 +1,65 @@ +package com.engine.salary.entity.taxagent.param; + +import com.engine.salary.common.BaseQueryParam; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.Date; +import java.util.List; + +/** + * 个税扣缴义务人调整记录查询参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class TaxAgentAdjustRecordQueryParam extends BaseQueryParam { + + //主键id + private Collection ids; + + //薪资档案id + private Long salaryArchiveId; + + //关键字(姓名、部门、个税扣缴义务人) + private String keyword; + + //姓名 + private String username; + + //部门id + private List departmentIds; + + //岗位id + private List positionIds; + + //状态 + private String userstatus; + + //个税扣缴义务人id + private Long taxAgentId; + + //调整原因 + private String adjustReason; + + //生效日期 + private List effectiveTime; + + //操作日期 + private List operateTime; + + //操作人id + private List operatorIds; + + //备注 + private String description; +} diff --git a/src/com/engine/salary/entity/taxagent/param/TaxAgentAdminChangeCheckParam.java b/src/com/engine/salary/entity/taxagent/param/TaxAgentAdminChangeCheckParam.java new file mode 100644 index 000000000..f25474c2b --- /dev/null +++ b/src/com/engine/salary/entity/taxagent/param/TaxAgentAdminChangeCheckParam.java @@ -0,0 +1,30 @@ +package com.engine.salary.entity.taxagent.param; + +import com.engine.salary.util.valid.DataCheck; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 个税扣缴义务人保存参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class TaxAgentAdminChangeCheckParam { + + //个税扣缴义务人id + @DataCheck(require = true,message = "个税扣缴义务人id为空") + private Long taxAgentId; + + //管理员主键id + @DataCheck(require = true,message = "管理员主键为空") + private Long adminUserId; +} diff --git a/src/com/engine/salary/entity/taxagent/param/TaxAgentEmpSaveParam.java b/src/com/engine/salary/entity/taxagent/param/TaxAgentEmpSaveParam.java new file mode 100644 index 000000000..259580ee3 --- /dev/null +++ b/src/com/engine/salary/entity/taxagent/param/TaxAgentEmpSaveParam.java @@ -0,0 +1,30 @@ +package com.engine.salary.entity.taxagent.param; + +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * 个税扣缴义务人的关联人员保存参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class TaxAgentEmpSaveParam { + + //个税口角义务人的主键id + private Long taxAgentId; + + //关联人员列表 + private List salaryEmployeeList; +} diff --git a/src/com/engine/salary/entity/taxagent/param/TaxAgentImportParam.java b/src/com/engine/salary/entity/taxagent/param/TaxAgentImportParam.java new file mode 100644 index 000000000..028dc12ee --- /dev/null +++ b/src/com/engine/salary/entity/taxagent/param/TaxAgentImportParam.java @@ -0,0 +1,24 @@ +package com.engine.salary.entity.taxagent.param; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author Harryxzy + * @date 2023/01/06 9:48 + * @description 个税扣缴义务人人员范围导入 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class TaxAgentImportParam { + + //上传文件id + String imageId; + + //个税扣缴义务人 + Long taxAgentId; +} diff --git a/src/com/engine/salary/entity/taxagent/param/TaxAgentManageRangeEmpQueryParam.java b/src/com/engine/salary/entity/taxagent/param/TaxAgentManageRangeEmpQueryParam.java new file mode 100644 index 000000000..9a21b9ee8 --- /dev/null +++ b/src/com/engine/salary/entity/taxagent/param/TaxAgentManageRangeEmpQueryParam.java @@ -0,0 +1,32 @@ +package com.engine.salary.entity.taxagent.param; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; + +/** + * 管理范围转人员-查询参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class TaxAgentManageRangeEmpQueryParam { + + //对象类型 + private String targetType; + + //对象id + private Collection targetIds; + + //人员状态 + private Collection employeeStatus; +} diff --git a/src/com/engine/salary/entity/taxagent/param/TaxAgentManageRangeExtSaveParam.java b/src/com/engine/salary/entity/taxagent/param/TaxAgentManageRangeExtSaveParam.java new file mode 100644 index 000000000..a4e4969cf --- /dev/null +++ b/src/com/engine/salary/entity/taxagent/param/TaxAgentManageRangeExtSaveParam.java @@ -0,0 +1,36 @@ +package com.engine.salary.entity.taxagent.param; + +import lombok.Data; + +import java.util.List; + +/** + * 外部人员管理范围保存参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +public class TaxAgentManageRangeExtSaveParam { + + /** + * 对象id + */ + private List targetIds; + + /** + * 对象类型。1:外部人员 + */ + private Long targetType; + + /** + * 个税扣缴义务人的id + */ + private Long taxAgentId; + + //是否同步/异步执行生成档案 + private boolean sync; + +} diff --git a/src/com/engine/salary/entity/taxagent/param/TaxAgentManageRangeQueryParam.java b/src/com/engine/salary/entity/taxagent/param/TaxAgentManageRangeQueryParam.java new file mode 100644 index 000000000..e7f5020f1 --- /dev/null +++ b/src/com/engine/salary/entity/taxagent/param/TaxAgentManageRangeQueryParam.java @@ -0,0 +1,22 @@ +package com.engine.salary.entity.taxagent.param; + +import com.engine.salary.common.BaseQueryParam; +import lombok.Data; + +/** + * 管理范围查询参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +//@Builder +//@NoArgsConstructor +//@AllArgsConstructor +public class TaxAgentManageRangeQueryParam extends BaseQueryParam { + + //对象") + private String targetName; +} diff --git a/src/com/engine/salary/entity/taxagent/param/TaxAgentManageRangeSaveParam.java b/src/com/engine/salary/entity/taxagent/param/TaxAgentManageRangeSaveParam.java new file mode 100644 index 000000000..2f4c4f749 --- /dev/null +++ b/src/com/engine/salary/entity/taxagent/param/TaxAgentManageRangeSaveParam.java @@ -0,0 +1,71 @@ +package com.engine.salary.entity.taxagent.param; + +import com.engine.salary.enums.salarysob.TargetTypeEnum; +import com.engine.salary.util.valid.DataCheck; +import com.engine.salary.util.valid.Modify; +import com.engine.salary.util.valid.ModifyTypeEnum; +import lombok.Data; + +import java.util.Collection; +import java.util.List; + +/** + * 管理范围保存参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +public class TaxAgentManageRangeSaveParam { + + private Long id; + + /** + * 只能选择 关联人员范围/从范围中排除 + */ + @DataCheck(require = true, max = 1, min = 0, message = "只能选择。0:排除、1:包含") + private Integer includeType; + + /** + * 对象不能为空 + */ + @DataCheck(require = true, message = "对象不能为空") + private List targetParams; + + /** + * 员工状态不允许为空 + */ + @DataCheck(require = true,message = "员工状态不允许为空") + private Collection employeeStatus; + + /** + * 个税扣缴义务人分管理员管理范围保存参数中的对象 + */ + @Data + public static class TaxAgentSubAdminRangeTargetParam { + + /** + * 对象类型不能为空 + */ + @DataCheck(require = true,message = "对象类型不能为空") + private TargetTypeEnum targetType; + + /** + * 对象不能为空 + */ + private Long targetId; + + /** + * sql + */ + @Modify(modifyType = ModifyTypeEnum.RESTORE_SQL) + private String target; + + /** + * 导入使用,员工状态 + */ + private Collection employeeStatus; + } +} diff --git a/src/com/engine/salary/entity/taxagent/param/TaxAgentQueryParam.java b/src/com/engine/salary/entity/taxagent/param/TaxAgentQueryParam.java new file mode 100644 index 000000000..410b0b2b4 --- /dev/null +++ b/src/com/engine/salary/entity/taxagent/param/TaxAgentQueryParam.java @@ -0,0 +1,29 @@ +package com.engine.salary.entity.taxagent.param; + +import com.engine.salary.common.BaseQueryParam; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; + +/** + * 个税扣缴义务人查询参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class TaxAgentQueryParam extends BaseQueryParam { + + private Collection ids; + + //个税扣缴义务人名称 + private String name; +} diff --git a/src/com/engine/salary/entity/taxagent/param/TaxAgentRangeDownloadTemplateParam.java b/src/com/engine/salary/entity/taxagent/param/TaxAgentRangeDownloadTemplateParam.java new file mode 100644 index 000000000..3f6919ed2 --- /dev/null +++ b/src/com/engine/salary/entity/taxagent/param/TaxAgentRangeDownloadTemplateParam.java @@ -0,0 +1,22 @@ +package com.engine.salary.entity.taxagent.param; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author Harryxzy + * @date 2023/01/05 14:39 + * @description 个税扣缴义务人的人员范围导入模板参数 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class TaxAgentRangeDownloadTemplateParam { + /** + * 个税扣缴义务人的id + */ + private Long taxAgentId; +} diff --git a/src/com/engine/salary/entity/taxagent/param/TaxAgentRangeExtQueryParam.java b/src/com/engine/salary/entity/taxagent/param/TaxAgentRangeExtQueryParam.java new file mode 100644 index 000000000..29ea1586c --- /dev/null +++ b/src/com/engine/salary/entity/taxagent/param/TaxAgentRangeExtQueryParam.java @@ -0,0 +1,29 @@ +package com.engine.salary.entity.taxagent.param; + +import com.engine.salary.common.BaseQueryParam; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 个税扣缴义务人人员范围查询参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//个税扣缴义务人人员范围查询参数 +public class TaxAgentRangeExtQueryParam extends BaseQueryParam { + + //个税扣缴义务人id + private Long taxAgentId; + + //对象") + private String targetName; +} diff --git a/src/com/engine/salary/entity/taxagent/param/TaxAgentRangeQueryParam.java b/src/com/engine/salary/entity/taxagent/param/TaxAgentRangeQueryParam.java new file mode 100644 index 000000000..f6c2a34aa --- /dev/null +++ b/src/com/engine/salary/entity/taxagent/param/TaxAgentRangeQueryParam.java @@ -0,0 +1,25 @@ +package com.engine.salary.entity.taxagent.param; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 个税扣缴义务人人员范围查询参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//个税扣缴义务人人员范围查询参数 +public class TaxAgentRangeQueryParam extends TaxAgentManageRangeQueryParam { + + //个税扣缴义务人id + private Long taxAgentId; +} diff --git a/src/com/engine/salary/entity/taxagent/param/TaxAgentRangeSaveParam.java b/src/com/engine/salary/entity/taxagent/param/TaxAgentRangeSaveParam.java new file mode 100644 index 000000000..25333e242 --- /dev/null +++ b/src/com/engine/salary/entity/taxagent/param/TaxAgentRangeSaveParam.java @@ -0,0 +1,25 @@ +package com.engine.salary.entity.taxagent.param; + +import com.engine.salary.util.valid.DataCheck; +import lombok.Data; + +/** + * 个税扣缴义务人的人员范围保存参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +public class TaxAgentRangeSaveParam extends TaxAgentManageRangeSaveParam { + + /** + * 个税扣缴义务人的id不允许为空 + */ + @DataCheck(require = true,message = "个税扣缴义务人的id不允许为空") + private Long taxAgentId; + + //是否同步/异步执行生成档案 + private boolean sync; +} diff --git a/src/com/engine/salary/entity/taxagent/param/TaxAgentSaveBaseParam.java b/src/com/engine/salary/entity/taxagent/param/TaxAgentSaveBaseParam.java new file mode 100644 index 000000000..d6b1ef205 --- /dev/null +++ b/src/com/engine/salary/entity/taxagent/param/TaxAgentSaveBaseParam.java @@ -0,0 +1,22 @@ +package com.engine.salary.entity.taxagent.param; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Description: 个税扣缴义务人基础信息保存参数 + * @Author: wangxiangzhong + * @Date: 2022/3/21 9:55 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//个税扣缴义务人基础信息保存参数") +public class TaxAgentSaveBaseParam { + + //"启用分权" + private Boolean devolutionStatus; +} diff --git a/src/com/engine/salary/entity/taxagent/param/TaxAgentSaveParam.java b/src/com/engine/salary/entity/taxagent/param/TaxAgentSaveParam.java new file mode 100644 index 000000000..c8100c98d --- /dev/null +++ b/src/com/engine/salary/entity/taxagent/param/TaxAgentSaveParam.java @@ -0,0 +1,46 @@ +package com.engine.salary.entity.taxagent.param; + +import com.engine.salary.util.valid.DataCheck; +import com.engine.salary.util.valid.RuntimeTypeEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * 个税扣缴义务人保存参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class TaxAgentSaveParam { + + //主键id + @DataCheck(require = true, message = "id为空", runtime = {RuntimeTypeEnum.UPDATE}) + private Long id; + + //名称 + @DataCheck(require = true, max = 40, message = "名称必填且不超过40个字符") + private String name; + + //管理员主键id + private List adminUserIds; + + //代缴机构 + private String paymentAgency; + + //备注 + @DataCheck( max = 50, message = "备注不超过50个字符") + private String description; + + // 排序id + private Integer sortedIndex; +} diff --git a/src/com/engine/salary/entity/taxagent/param/TaxAgentSubAdminBaseFormParam.java b/src/com/engine/salary/entity/taxagent/param/TaxAgentSubAdminBaseFormParam.java new file mode 100644 index 000000000..40278cc6b --- /dev/null +++ b/src/com/engine/salary/entity/taxagent/param/TaxAgentSubAdminBaseFormParam.java @@ -0,0 +1,30 @@ +package com.engine.salary.entity.taxagent.param; + +import com.engine.salary.util.valid.DataCheck; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 分管理员基础设置表单参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//分管理员基础设置表单参数 +public class TaxAgentSubAdminBaseFormParam { + + //分管理员的id + private Long id; + + //个税扣缴义务人的id + @DataCheck(require = true, message = "个税扣缴义务人的id为空") + private Long taxAgentId; +} diff --git a/src/com/engine/salary/entity/taxagent/param/TaxAgentSubAdminBaseSaveParam.java b/src/com/engine/salary/entity/taxagent/param/TaxAgentSubAdminBaseSaveParam.java new file mode 100644 index 000000000..40e6c35b9 --- /dev/null +++ b/src/com/engine/salary/entity/taxagent/param/TaxAgentSubAdminBaseSaveParam.java @@ -0,0 +1,33 @@ +package com.engine.salary.entity.taxagent.param; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 分管理员基础设置保存参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class TaxAgentSubAdminBaseSaveParam { + + //主键id + private Long id; + + //个税扣缴义务人的id + private Long taxAgentId; + + //分管理员的id + private Long subAdminUserId; + + //备注 + private String description; +} diff --git a/src/com/engine/salary/entity/taxagent/param/TaxAgentSubAdminEmpSaveParam.java b/src/com/engine/salary/entity/taxagent/param/TaxAgentSubAdminEmpSaveParam.java new file mode 100644 index 000000000..66dfaa868 --- /dev/null +++ b/src/com/engine/salary/entity/taxagent/param/TaxAgentSubAdminEmpSaveParam.java @@ -0,0 +1,33 @@ +package com.engine.salary.entity.taxagent.param; + +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * 个税扣缴义务人分管理员的关联人员保存参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class TaxAgentSubAdminEmpSaveParam { + + //个税口角义务人的主键id + private Long taxAgentId; + + //分管理员的主键id + private Long subAdminId; + + //关联人员列表 + private List salaryEmployeeList; +} diff --git a/src/com/engine/salary/entity/taxagent/param/TaxAgentSubAdminQueryParam.java b/src/com/engine/salary/entity/taxagent/param/TaxAgentSubAdminQueryParam.java new file mode 100644 index 000000000..6dec062b2 --- /dev/null +++ b/src/com/engine/salary/entity/taxagent/param/TaxAgentSubAdminQueryParam.java @@ -0,0 +1,27 @@ +package com.engine.salary.entity.taxagent.param; + +import com.engine.salary.common.BaseQueryParam; +import com.engine.salary.util.valid.DataCheck; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 个税扣缴义务人分管理员查询参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class TaxAgentSubAdminQueryParam extends BaseQueryParam { + + //个税扣缴义务人id + @DataCheck(require = true,message = "个税扣缴义务人id为空") + private Long taxAgentId; +} diff --git a/src/com/engine/salary/entity/taxagent/param/TaxAgentSubAdminRangeQueryParam.java b/src/com/engine/salary/entity/taxagent/param/TaxAgentSubAdminRangeQueryParam.java new file mode 100644 index 000000000..493d99d35 --- /dev/null +++ b/src/com/engine/salary/entity/taxagent/param/TaxAgentSubAdminRangeQueryParam.java @@ -0,0 +1,24 @@ +package com.engine.salary.entity.taxagent.param; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 个税扣缴义务人分管理员管理范围查询参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class TaxAgentSubAdminRangeQueryParam extends TaxAgentManageRangeQueryParam { + + //分管理员id + private Long subAdminId; +} diff --git a/src/com/engine/salary/entity/taxagent/param/TaxAgentSubAdminRangeSaveParam.java b/src/com/engine/salary/entity/taxagent/param/TaxAgentSubAdminRangeSaveParam.java new file mode 100644 index 000000000..2638a435a --- /dev/null +++ b/src/com/engine/salary/entity/taxagent/param/TaxAgentSubAdminRangeSaveParam.java @@ -0,0 +1,22 @@ +package com.engine.salary.entity.taxagent.param; + +import com.engine.salary.util.valid.DataCheck; +import lombok.Data; + +/** + * 个税扣缴义务人分管理员管理范围保存参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +public class TaxAgentSubAdminRangeSaveParam extends TaxAgentManageRangeSaveParam { + + /** + * 分管理员的id不允许为空 + */ + @DataCheck(require = true, message = "分管理员的id不允许为空") + private Long subAdminId; +} diff --git a/src/com/engine/salary/entity/taxagent/po/TaxAgentAdminPO.java b/src/com/engine/salary/entity/taxagent/po/TaxAgentAdminPO.java new file mode 100644 index 000000000..88859fe56 --- /dev/null +++ b/src/com/engine/salary/entity/taxagent/po/TaxAgentAdminPO.java @@ -0,0 +1,70 @@ +package com.engine.salary.entity.taxagent.po; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.Date; + +/** + * 个税扣缴义务人管理员 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//hrsa_tax_agent_admin") +public class TaxAgentAdminPO { + /** + * 主键id + */ + private Long id; + + /** + * 个税扣缴义务人的主键id + */ + private Long taxAgentId; + + /** + * 人员信息表的主键id + */ + private Long employeeId; + + /** + * 租户key + */ + private String tenantKey; + + /** + * 创建人id + */ + private Long creator; + + /** + * 是否删除 + */ + private Integer deleteType; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 更新时间 + */ + private Date updateTime; + + + + private Collection taxAgentIds; + private Collection ids; + +} diff --git a/src/com/engine/salary/entity/taxagent/po/TaxAgentBasePO.java b/src/com/engine/salary/entity/taxagent/po/TaxAgentBasePO.java new file mode 100644 index 000000000..58e02c10e --- /dev/null +++ b/src/com/engine/salary/entity/taxagent/po/TaxAgentBasePO.java @@ -0,0 +1,79 @@ +package com.engine.salary.entity.taxagent.po; + +import com.thoughtworks.xstream.annotations.XStreamAlias; +import com.thoughtworks.xstream.annotations.XStreamAsAttribute; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.Date; + +/** + * 个税扣缴义务人基础信息 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//hrsa_tax_agent_base") +@XStreamAlias("TaxAgentBase") +public class TaxAgentBasePO { + + /** + * 主键id + */ + @XStreamAlias("id") + @XStreamAsAttribute + private Long id; + + /** + * 分权开关 + */ + @XStreamAlias("devolutionStatus") + @XStreamAsAttribute + private Integer devolutionStatus; + + /** + * 租户key + */ + @XStreamAlias("tenantKey") + @XStreamAsAttribute + private String tenantKey; + + /** + * 创建人id + */ + @XStreamAlias("creator") + @XStreamAsAttribute + private Long creator; + + /** + * 是否删除 + */ + @XStreamAlias("deleteType") + @XStreamAsAttribute + private Integer deleteType; + + /** + * 创建时间 + */ + @XStreamAlias("createTime") + @XStreamAsAttribute + private Date createTime; + + /** + * 更新时间 + */ + @XStreamAlias("updateTime") + @XStreamAsAttribute + private Date updateTime; + + private Collection ids; +} diff --git a/src/com/engine/salary/entity/taxagent/po/TaxAgentEmpChangePO.java b/src/com/engine/salary/entity/taxagent/po/TaxAgentEmpChangePO.java new file mode 100644 index 000000000..90d382f0a --- /dev/null +++ b/src/com/engine/salary/entity/taxagent/po/TaxAgentEmpChangePO.java @@ -0,0 +1,96 @@ +package com.engine.salary.entity.taxagent.po; + +import com.engine.salary.enums.datacollection.DataCollectionEmployeeTypeEnum; +import com.engine.salary.enums.taxagent.TaxAgentEmpChangeModuleEnum; +import com.engine.salary.enums.taxagent.TaxAgentEmpChangeTypeEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.Date; + +/** + * 个税扣缴义务人管理范围的增量人员 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//hrsa_tax_agent_emp_change") +public class TaxAgentEmpChangePO { + + /** + * 主键id + */ + private Long id; + + /** + * 个税扣缴义务人的主键id + */ + private Long taxAgentId; + + /** + * 人员信息表的主键id + */ + private Long employeeId; + + /** + * 人员姓名 + */ + private String employeeName; + + /** + * 增量类型 + * + * @see TaxAgentEmpChangeTypeEnum + */ + private Integer changeType; + + /** + * 增量类型 + * + * @see TaxAgentEmpChangeModuleEnum + */ + private Integer moduleType; + + /** + * 人员类型,0或null组织架构,1非系统人员 + * + * @see DataCollectionEmployeeTypeEnum + */ + private Integer employeeType; + + /** + * 租户key + */ + private String tenantKey; + + /** + * 创建人id + */ + private Long creator; + + /** + * 是否删除 + */ + private Integer deleteType; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 更新时间 + */ + private Date updateTime; + + private Collection ids; +} diff --git a/src/com/engine/salary/entity/taxagent/po/TaxAgentEmpPO.java b/src/com/engine/salary/entity/taxagent/po/TaxAgentEmpPO.java new file mode 100644 index 000000000..ba8c2f0c1 --- /dev/null +++ b/src/com/engine/salary/entity/taxagent/po/TaxAgentEmpPO.java @@ -0,0 +1,81 @@ +package com.engine.salary.entity.taxagent.po; + +import com.engine.salary.enums.datacollection.DataCollectionEmployeeTypeEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.Date; + +/** + * 个税扣缴义务人管理范围的人员 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//hrsa_tax_agent_emp", autoResultMap = true) +public class TaxAgentEmpPO { + + /** + * 主键id + */ + private Long id; + + /** + * 个税扣缴义务人的主键id + */ + private Long taxAgentId; + + /** + * 人员信息表的主键id + */ + private Long employeeId; + + /** + * 人员姓名 + */ + private String employeeName; + + /** + * 租户key + */ + private String tenantKey; + + /** + * 创建人id + */ + private Long creator; + + /** + * 是否删除 + */ + private Integer deleteType; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 更新时间 + */ + private Date updateTime; + + /** + * 人员类型,0或null组织架构,1非系统人员 + * + * @see DataCollectionEmployeeTypeEnum + */ + private Integer employeeType; + + private Collection taxAgentIds; + private Collection ids; +} diff --git a/src/com/engine/salary/entity/taxagent/po/TaxAgentEmployeePO.java b/src/com/engine/salary/entity/taxagent/po/TaxAgentEmployeePO.java new file mode 100644 index 000000000..8b4adfcf6 --- /dev/null +++ b/src/com/engine/salary/entity/taxagent/po/TaxAgentEmployeePO.java @@ -0,0 +1,40 @@ +package com.engine.salary.entity.taxagent.po; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; + +/** + * 员工基本信息 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class TaxAgentEmployeePO { + + //员工id") + private Long employeeId; + + //姓名") + private String username; + + //部门") + private String departmentName; + + //状态") + private String status; + + //人事状态") +// private String personnelStatus; + + private Collection ids; +} diff --git a/src/com/engine/salary/entity/taxagent/po/TaxAgentExtRangePO.java b/src/com/engine/salary/entity/taxagent/po/TaxAgentExtRangePO.java new file mode 100644 index 000000000..071380108 --- /dev/null +++ b/src/com/engine/salary/entity/taxagent/po/TaxAgentExtRangePO.java @@ -0,0 +1,69 @@ +package com.engine.salary.entity.taxagent.po; + +import com.engine.salary.annotation.TableTitle; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.Date; + +/** + * 个税扣缴义务人的管理范围表 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class TaxAgentExtRangePO { + + /** + * 主键id + */ + private Long id; + /** + * 对象id + */ + private Long targetId; + /** + * 对象类型。1:外部人员 + */ + private Integer targetType; + /** + * 个税扣缴义务人的id + */ + private Long taxAgentId; + /** + * 租户ID + */ + private String tenantKey; + /** + * 更新时间 + */ + private Date updateTime; + + /** + * 创建时间 + */ + private Date createTime; + /** + * 创建人 + */ + private Long creator; + /** + * 是否已删除。0:未删除、1:已删除 + */ + private Integer deleteType; + + //主键id集合 + private Collection ids; + + /** + * 名字 + */ + @TableTitle(title = "姓名",key = "targetName",dataIndex = "targetName") + private String targetName; + + +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/taxagent/po/TaxAgentManageRangePO.java b/src/com/engine/salary/entity/taxagent/po/TaxAgentManageRangePO.java new file mode 100644 index 000000000..7b088913c --- /dev/null +++ b/src/com/engine/salary/entity/taxagent/po/TaxAgentManageRangePO.java @@ -0,0 +1,115 @@ +package com.engine.salary.entity.taxagent.po; + +import com.engine.hrmelog.annotation.ElogTransform; +import com.engine.salary.enums.salarysob.TargetTypeEnum; +import com.engine.salary.enums.taxagent.TaxAgentRangeTypeEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.Date; + +/** + * 个税扣缴义务人的管理范围表 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//hrsa_tax_agent_manage_range +@ElogTransform( name="个税扣缴义务人管理范围" ) +public class TaxAgentManageRangePO { + + /** + * 主键id + */ + @ElogTransform( name ="主键") + private Long id; + + /** + * 分管理员的id + */ + private Long taxAgentSubAdminId; + + /** + * 个税扣缴义务人的主键id + */ + @ElogTransform( name ="个税扣缴义务人id") + private Long taxAgentId; + + /** + * 范围类型 + * @see TaxAgentRangeTypeEnum + */ + @ElogTransform( name ="范围类型") + private Integer rangeType; + + /** + * 对象类型 + * @see TargetTypeEnum + */ + @ElogTransform( name ="对象类型") + private Integer targetType; + + /** + * 对象id + */ + @ElogTransform( name ="对象id") + private Long targetId; + + @ElogTransform( name ="SQL") + private String target; + + /** + * 人员状态 + */ + @ElogTransform( name ="人员状态") + private String employeeStatus; + + /** + * 是包含还是排除 0:排除、1:包含 + */ + @ElogTransform( name ="是包含还是排除 0:排除、1:包含") + private Integer includeType; + + /** + * 租户key + */ + @ElogTransform( name ="租户key") + private String tenantKey; + + /** + * 创建人id + */ + @ElogTransform( name ="创建人id") + private Long creator; + + /** + * 是否删除 + */ + private Integer deleteType; + + /** + * 创建时间 + */ + @ElogTransform( name ="创建时间") + private Date createTime; + + /** + * 更新时间 + */ + @ElogTransform( name ="更新时间") + private Date updateTime; + + + private Collection taxAgentIds; + private Collection ids; + private Collection taxAgentSubAdminIds; +} diff --git a/src/com/engine/salary/entity/taxagent/po/TaxAgentPO.java b/src/com/engine/salary/entity/taxagent/po/TaxAgentPO.java new file mode 100644 index 000000000..f84602b40 --- /dev/null +++ b/src/com/engine/salary/entity/taxagent/po/TaxAgentPO.java @@ -0,0 +1,116 @@ +package com.engine.salary.entity.taxagent.po; + +import com.engine.hrmelog.annotation.ElogTransform; +import com.engine.salary.annotation.Auth; +import com.engine.salary.enums.auth.AuthCheckTypeEnum; +import com.thoughtworks.xstream.annotations.XStreamAlias; +import com.thoughtworks.xstream.annotations.XStreamAsAttribute; +import com.thoughtworks.xstream.annotations.XStreamOmitField; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.Date; +import java.util.Set; + +/** + * 个税扣缴义务人 hrsa_tax_agent + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@ElogTransform(name = "个税扣缴义务人") +@XStreamAlias("TaxAgent") +@Auth(page = "", checkType = AuthCheckTypeEnum.TAX,taxAgentIdField = "id") +public class TaxAgentPO { + + /** + * 主键id + */ + @ElogTransform(name = "主键id") + @XStreamOmitField + private Long id; + + /** + * 名称 + */ + @ElogTransform(name = "名称") + @XStreamAlias("name") + @XStreamAsAttribute + private String name; + + /** + * 代缴机构 + */ + // @ElogTransform(name = "代缴机构") + @XStreamAlias("paymentAgency") + @XStreamAsAttribute + private String paymentAgency; + + + /** + * 排序 + */ + @XStreamAlias("sortedIndex") + @XStreamAsAttribute + private Integer sortedIndex; + + /** + * 备注 + */ + @ElogTransform(name = "备注") + @XStreamAlias("description") + @XStreamAsAttribute + private String description; + + /** + * 租户key + */ + @XStreamAlias("tenantKey") + @XStreamAsAttribute + private String tenantKey; + + /** + * 创建人id + */ + @ElogTransform(name = "创建人id") + @XStreamAlias("creator") + @XStreamAsAttribute + private Long creator; + + /** + * 是否删除 + */ + @XStreamAlias("deleteType") + @XStreamAsAttribute + private Integer deleteType; + + /** + * 创建时间 + */ + @ElogTransform(name = "创建时间") + @XStreamAlias("createTime") + @XStreamAsAttribute + private Date createTime; + + /** + * 更新时间 + */ + @ElogTransform(name = "updateTime") + @XStreamAlias("updateTime") + @XStreamAsAttribute + private Date updateTime; + + + private Collection ids; + + Set opts; +} diff --git a/src/com/engine/salary/entity/taxagent/po/TaxAgentSubAdminEmpPO.java b/src/com/engine/salary/entity/taxagent/po/TaxAgentSubAdminEmpPO.java new file mode 100644 index 000000000..b9134228e --- /dev/null +++ b/src/com/engine/salary/entity/taxagent/po/TaxAgentSubAdminEmpPO.java @@ -0,0 +1,78 @@ +package com.engine.salary.entity.taxagent.po; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.Date; + +/** + * 个税扣缴义务人管理范围的人员 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//hrsa_tax_agent_sub_admin_emp", autoResultMap = true) +public class TaxAgentSubAdminEmpPO { + + /** + * 主键id + */ + private Long id; + + /** + * 个税扣缴义务人的主键id + */ + private Long taxAgentId; + + /** + * 分管理员的id + */ + private Long taxAgentSubAdminId; + + /** + * 人员信息表的主键id + */ + private Long employeeId; + + /** + * 人员姓名 + */ + private String employeeName; + + /** + * 租户key + */ + private String tenantKey; + + /** + * 创建人id + */ + private Long creator; + + /** + * 是否删除 + */ + private Integer deleteType; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 更新时间 + */ + private Date updateTime; + + private Collection ids; + +} diff --git a/src/com/engine/salary/entity/taxagent/po/TaxAgentSubAdminPO.java b/src/com/engine/salary/entity/taxagent/po/TaxAgentSubAdminPO.java new file mode 100644 index 000000000..60e2f9ff8 --- /dev/null +++ b/src/com/engine/salary/entity/taxagent/po/TaxAgentSubAdminPO.java @@ -0,0 +1,74 @@ +package com.engine.salary.entity.taxagent.po; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.Date; + +/** + * 个税扣缴义务人分管理员 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//hrsa_tax_agent_sub_admin") +//个税扣缴义务人分管理员") +public class TaxAgentSubAdminPO { + + /** + * 主键id + */ + private Long id; + + /** + * 个税扣缴义务人的主键id + */ + private Long taxAgentId; + + /** + * 人员信息表的主键id + */ + private Long employeeId; + + /** + * 备注 + */ + private String remark; + + /** + * 租户key + */ + private String tenantKey; + + /** + * 创建人id + */ + private Long creator; + + /** + * 是否删除 + */ + private Integer deleteType; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 更新时间 + */ + private Date updateTime; + + private Collection ids; + +} diff --git a/src/com/engine/salary/entity/taxdeclaration/bo/TaxDeclarationBO.java b/src/com/engine/salary/entity/taxdeclaration/bo/TaxDeclarationBO.java new file mode 100644 index 000000000..66aec4865 --- /dev/null +++ b/src/com/engine/salary/entity/taxdeclaration/bo/TaxDeclarationBO.java @@ -0,0 +1,744 @@ +package com.engine.salary.entity.taxdeclaration.bo; + +import com.engine.salary.constant.SalaryDefaultTenantConstant; +import com.engine.salary.constant.TaxDeclarationDataIndexConstant; +import com.engine.salary.encrypt.EncryptUtil; +import com.engine.salary.entity.datacollection.AddUpSituation; +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.salaryacct.po.SalaryAcctResultPO; +import com.engine.salary.entity.salaryitem.po.SalaryItemPO; +import com.engine.salary.entity.salarysob.po.SalarySobPO; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationDetailListDTO; +import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationListDTO; +import com.engine.salary.entity.taxdeclaration.param.TaxDeclarationSaveParam; +import com.engine.salary.entity.taxdeclaration.po.TaxDeclarationDetailPO; +import com.engine.salary.entity.taxdeclaration.po.TaxDeclarationPO; +import com.engine.salary.enums.salaryaccounting.EmployeeTypeEnum; +import com.engine.salary.enums.salarysob.IncomeCategoryEnum; +import com.engine.salary.util.SalaryDateUtil; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.page.PageInfo; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.engine.salary.util.db.IdGenerator; +import lombok.Data; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.collections4.MapUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.math.NumberUtils; +import weaver.hrm.User; + +import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.util.*; +import java.util.stream.Collectors; + +/** + * 个税申报表 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class TaxDeclarationBO { + private static EncryptUtil encryptUtil = new EncryptUtil(); + + public static List convert2ListDTO(List taxDeclarations, + List simpleEmployees, + List taxAgents) { + if (CollectionUtils.isEmpty(simpleEmployees)) { + simpleEmployees = new ArrayList<>(); + } + Map taxAgentNameMap = SalaryEntityUtil.convert2Map(taxAgents, TaxAgentPO::getId, + TaxAgentPO::getName); + Map employeeNameMap = SalaryEntityUtil.convert2Map(simpleEmployees, DataCollectionEmployee::getEmployeeId, DataCollectionEmployee::getUsername); + return taxDeclarations.stream() + .map(taxDeclarationPO -> { + IncomeCategoryEnum incomeCategoryEnum = IncomeCategoryEnum.parseByValue(taxDeclarationPO.getIncomeCategory()); + return TaxDeclarationListDTO.builder() + .id(taxDeclarationPO.getId()) + .incomeCategory(Optional.ofNullable(incomeCategoryEnum) + .map(o -> SalaryI18nUtil.getI18nLabel(o.getLabelId(), o.getDefaultLabel())) + .orElse(StringUtils.EMPTY)) + .salaryMonth(taxDeclarationPO.getSalaryMonth()) + .taxAgentId(taxDeclarationPO.getTaxAgentId()) + .taxAgentName(taxAgentNameMap.getOrDefault(taxDeclarationPO.getTaxAgentId(), "")) + .taxCycle(taxDeclarationPO.getTaxCycle()) + .operateEmployeeId(taxDeclarationPO.getCreator()) + .operateEmployeeName(employeeNameMap.getOrDefault(taxDeclarationPO.getCreator(), "")) + .operateTime(SalaryDateUtil.getFormatLocalDateTime(taxDeclarationPO.getCreateTime())) + .description(taxDeclarationPO.getDescription()) + .opts(taxDeclarationPO.getOpts()) + .build(); + }) + .collect(Collectors.toList()); + } + + public static void buildDetailListDTO(Long taxDeclarationId, + PageInfo page, + List taxDeclarationDetails, + List simpleEmployees) { + if (CollectionUtils.isEmpty(taxDeclarationDetails)) { + return; + } + int index = (page.getNextPage() - 1) * page.getSize(); + List dtos = Lists.newArrayListWithExpectedSize(simpleEmployees.size()); + Map> taxDeclarationDetailMap = SalaryEntityUtil.group2Map(taxDeclarationDetails, TaxDeclarationDetailPO::getEmployeeId); + for (DataCollectionEmployee simpleEmployee : simpleEmployees) { + Map valueMap = SalaryEntityUtil.convert2Map(taxDeclarationDetailMap.get(simpleEmployee.getEmployeeId()), TaxDeclarationDetailPO::getFieldCode, TaxDeclarationDetailPO::getFieldValue); + TaxDeclarationDetailListDTO dto = new TaxDeclarationDetailListDTO(); + dto.setId(simpleEmployee.getEmployeeId()); + dto.setTaxDeclarationId(taxDeclarationId); + dto.setSeq(++index); + dto.setEmployeeId(simpleEmployee.getEmployeeId()); + dto.setEmployeeName(simpleEmployee.getUsername()); + dto.setIdCardType(SalaryI18nUtil.getI18nLabel(101696, "身份证")); + dto.setIdCardNo(""); + dto.setTaxpayerIdNo(""); + dto.setResidentType(SalaryI18nUtil.getI18nLabel(101697, "居民")); + dto.setIncomeType(SalaryI18nUtil.getI18nLabel(101698, "工资、薪金")); + dto.setIncome(valueMap.getOrDefault("income", "")); + dto.setFee(valueMap.getOrDefault("fee", "")); + dto.setTaxFreeIncome(valueMap.getOrDefault("taxFreeIncome", "")); + dto.setSubtraction(valueMap.getOrDefault("subtraction", "")); + dto.setEndowmentInsurance(valueMap.getOrDefault("endowmentInsurance", "")); + dto.setMedicalInsurance(valueMap.getOrDefault("medicalInsurance", "")); + dto.setUnemploymentInsurance(valueMap.getOrDefault("unemploymentInsurance", "")); + dto.setHousingProvidentFund(valueMap.getOrDefault("housingProvidentFund", "")); + dto.setAnnuity(valueMap.getOrDefault("annuity", "")); + dto.setCommercialHealthInsurance(valueMap.getOrDefault("commercialHealthInsurance", "")); + dto.setTaxDeferredEndowmentInsurance(valueMap.getOrDefault("taxDeferredEndowmentInsurance", "")); + dto.setOriginalValueOfProperty(valueMap.getOrDefault("originalValueOfProperty", "")); + dto.setDeductedTax(valueMap.getOrDefault("deductedTax", "")); + dto.setOther(valueMap.getOrDefault("other", "")); + dto.setAddUpIncome(valueMap.getOrDefault("addUpIncome", "")); + dto.setAddUpSubtraction(valueMap.getOrDefault("addUpSubtraction", "")); + dto.setAddUpSpecialDeduction(valueMap.getOrDefault("addUpSpecialDeduction", "")); + dto.setAddUpChildEducation(valueMap.getOrDefault("addUpChildEducation", "")); + dto.setAddUpContinuingEducation(valueMap.getOrDefault("addUpContinuingEducation", "")); + dto.setAddUpHousingLoanInterest(valueMap.getOrDefault("addUpHousingLoanInterest", "")); + dto.setAddUpHousingRent(valueMap.getOrDefault("addUpHousingRent", "")); + dto.setAddUpSupportElderly(valueMap.getOrDefault("addUpSupportElderly", "")); + dto.setAddUpOther(valueMap.getOrDefault("addUpOtherDeduction", "")); + dto.setLessTaxProportion(valueMap.getOrDefault("lessTaxProportion", "")); + dto.setAllowedDonation(valueMap.getOrDefault("addUpAllowedDonation", "")); + dto.setTaxableIncome(valueMap.getOrDefault("addUpTaxableIncome", "")); + dto.setTaxRate(valueMap.getOrDefault("taxRate", "")); + dto.setQuickDeductionFactor(valueMap.getOrDefault("quickDeductionFactor", "")); + dto.setTaxPayable(valueMap.getOrDefault("addUpTaxPayable", "")); + dto.setTaxSavings(valueMap.getOrDefault("addUpTaxDeduction", "")); + dto.setTaxWithheld(valueMap.getOrDefault("taxWithheld", "")); + dto.setRefundedOrSupplementedTax(valueMap.getOrDefault("refundedOrSupplementedTax", "")); + dtos.add(dto); + } + page.setList(dtos); + } + + public static Result handle(TaxDeclarationSaveParam saveParam, + Date taxCycle, + User user, + List salaryItems, + List salarySobs, + List salaryAcctResults) { + Result result = new Result(); + if (CollectionUtils.isEmpty(salaryAcctResults)) { + return result; + } + // 薪资项目聚合成map(为了根据code获取id) + Map salaryItemMap = SalaryEntityUtil.convert2Map(salaryItems, SalaryItemPO::getCode, SalaryItemPO::getId); + // 薪资账套聚合成map(为了根据id获取incomeCategory) + Map salarySobPOMap = SalaryEntityUtil.convert2Map(salarySobs, SalarySobPO::getId); + // 薪资核算结果按照个税扣缴义务人id、所用薪资账套的incomeCategory聚合成map + Map>> taxAgentIdKeyAcctResultMap = salaryAcctResults.stream() + .collect(Collectors.groupingBy(SalaryAcctResultPO::getTaxAgentId, + Collectors.groupingBy(salaryAcctResultPO -> salarySobPOMap.get(salaryAcctResultPO.getSalarySobId()).getIncomeCategory()))); + // 一个个税扣缴义务人,一种薪资类型生成一张个税申报表 + taxAgentIdKeyAcctResultMap.forEach((taxAgentId, incomeCategoryKeyAcctResultPOMap) -> { + incomeCategoryKeyAcctResultPOMap.forEach((incomeCategory, salaryAcctResultPOS) -> { + // 新增的个税申报表 + TaxDeclarationPO taxDeclaration = convert2PO(saveParam, user, taxCycle, taxAgentId, incomeCategory); + result.getNeedInsertTaxDeclarations().add(taxDeclaration); + if (Objects.equals(incomeCategory, IncomeCategoryEnum.WAGES_AND_SALARIES.getValue())) { + // 生成个税申报表 + handleTaxDeclaration4Wage(result, taxDeclaration, salaryAcctResultPOS, salaryItemMap); + // 生成往期累计情况 + handleAddUpSituation(result, taxDeclaration, salaryAcctResultPOS, salaryItemMap); + } + if (Objects.equals(incomeCategory, IncomeCategoryEnum.REMUNERATION_FOR_LABOR.getValue())) { + // 生成个税申报表 + handleTaxDeclaration4Labor(result, taxDeclaration, salaryAcctResultPOS, salaryItemMap); + } + if (Objects.equals(incomeCategory, IncomeCategoryEnum.ONETIME_ANNUAL_BONUS.getValue())) { + // 生成个税申报表 + handleTaxDeclaration4Annual(result, taxDeclaration, salaryAcctResultPOS, salaryItemMap); + } + }); + }); + return result; + } + + /** + * 生成个税申报表明细(正常工资薪金所得) + * + * @param result + * @param taxDeclaration + * @param salaryAcctResults + * @param salaryItemMap + */ + private static void handleTaxDeclaration4Wage(Result result, + TaxDeclarationPO taxDeclaration, + List salaryAcctResults, + Map salaryItemMap) { + if (CollectionUtils.isEmpty(salaryAcctResults)) { + return; + } + // 核算结果按照人员id分类 + Map> salaryAcctResultPOMap = SalaryEntityUtil.group2Map(salaryAcctResults, + salaryAcctResultPO -> EmployeeTypeEnum.ORGANIZATION.getValue() + "_" + salaryAcctResultPO.getEmployeeId()); + salaryAcctResultPOMap.forEach((key, salaryAcctResultPOS) -> { + String[] keyArray = StringUtils.split(key, "_"); + // 员工类型 + Integer employeeType = Integer.parseInt(keyArray[0]); + // 员工id + Long employeeId = Long.parseLong(keyArray[1]); + Map valueMap = Maps.newHashMapWithExpectedSize(17); + Map> resultMap = SalaryEntityUtil.group2Map(salaryAcctResultPOS, SalaryAcctResultPO::getSalaryItemId); + // 本期收入 + BigDecimal income = SalaryEntityUtil.reduce(resultMap.get(salaryItemMap.getOrDefault(TaxDeclarationDataIndexConstant.INCOME, 0L)), + salaryAcctResultPO -> SalaryEntityUtil.empty2Zero(salaryAcctResultPO.getResultValue())); + valueMap.put(TaxDeclarationDataIndexConstant.INCOME, income.toPlainString()); + // 本期免税收入 + BigDecimal taxFreeIncome = findValue(TaxDeclarationDataIndexConstant.TAX_FREE_INCOME, resultMap, salaryItemMap); + valueMap.put(TaxDeclarationDataIndexConstant.TAX_FREE_INCOME, taxFreeIncome.toPlainString()); + // 基本养老保险 + BigDecimal endowmentInsurance = findValue(TaxDeclarationDataIndexConstant.ENDOWMENT_INSURANCE, resultMap, salaryItemMap); + valueMap.put(TaxDeclarationDataIndexConstant.ENDOWMENT_INSURANCE, endowmentInsurance.toPlainString()); + // 基本医疗保险 + BigDecimal medicalInsurance = findValue(TaxDeclarationDataIndexConstant.MEDICAL_INSURANCE, resultMap, salaryItemMap); + valueMap.put(TaxDeclarationDataIndexConstant.MEDICAL_INSURANCE, medicalInsurance.toPlainString()); + // 失业保险费 + BigDecimal unemploymentInsurance = findValue(TaxDeclarationDataIndexConstant.UNEMPLOYMENT_INSURANCE, resultMap, salaryItemMap); + valueMap.put(TaxDeclarationDataIndexConstant.UNEMPLOYMENT_INSURANCE, unemploymentInsurance.toPlainString()); + // 住房公积金 + BigDecimal housingProvidentFund = findValue(TaxDeclarationDataIndexConstant.HOUSING_PROVIDENT_FUND, resultMap, salaryItemMap); + valueMap.put(TaxDeclarationDataIndexConstant.HOUSING_PROVIDENT_FUND, housingProvidentFund.toPlainString()); + // 累计子女教育 + BigDecimal addUpChildEducation = findValue(TaxDeclarationDataIndexConstant.ADD_UP_CHILD_EDUCATION, resultMap, salaryItemMap); + valueMap.put(TaxDeclarationDataIndexConstant.ADD_UP_CHILD_EDUCATION, addUpChildEducation.toPlainString()); + // 累计继续教育 + BigDecimal addUpContinuingEducation = findValue(TaxDeclarationDataIndexConstant.ADD_UP_CONTINUING_EDUCATION, resultMap, salaryItemMap); + valueMap.put(TaxDeclarationDataIndexConstant.ADD_UP_CONTINUING_EDUCATION, addUpContinuingEducation.toPlainString()); + // 累计住房贷款利息 + BigDecimal addUpHousingLoanInterest = findValue(TaxDeclarationDataIndexConstant.ADD_UP_HOUSING_LOAN_INTEREST, resultMap, salaryItemMap); + valueMap.put(TaxDeclarationDataIndexConstant.ADD_UP_HOUSING_LOAN_INTEREST, addUpHousingLoanInterest.toPlainString()); + // 累计住房租金 + BigDecimal addUpHousingRent = findValue(TaxDeclarationDataIndexConstant.ADD_UP_HOUSING_RENT, resultMap, salaryItemMap); + valueMap.put(TaxDeclarationDataIndexConstant.ADD_UP_HOUSING_RENT, addUpHousingRent.toPlainString()); + // 累计赡养老人 + BigDecimal addUpSupportElderly = findValue(TaxDeclarationDataIndexConstant.ADD_UP_SUPPORT_ELDERLY, resultMap, salaryItemMap); + valueMap.put(TaxDeclarationDataIndexConstant.ADD_UP_SUPPORT_ELDERLY, addUpSupportElderly.toPlainString()); + // 累计大病医疗 + BigDecimal addUpIllnessMedical = findValue(TaxDeclarationDataIndexConstant.ADD_UP_ILLNESS_MEDICAL, resultMap, salaryItemMap); + valueMap.put(TaxDeclarationDataIndexConstant.ADD_UP_ILLNESS_MEDICAL, addUpIllnessMedical.toPlainString()); + // 累计婴幼儿照护 + BigDecimal addUpInfantCare = findValue(TaxDeclarationDataIndexConstant.ADD_UP_INFANT_CARE, resultMap, salaryItemMap); + valueMap.put(TaxDeclarationDataIndexConstant.ADD_UP_INFANT_CARE, addUpInfantCare.toPlainString()); + // 累计个人养老金 + BigDecimal addUpPrivatePension = findValue(TaxDeclarationDataIndexConstant.ADD_UP_PRIVATE_PENSION, resultMap, salaryItemMap); + valueMap.put(TaxDeclarationDataIndexConstant.ADD_UP_PRIVATE_PENSION, addUpPrivatePension.toPlainString()); + // 企业(职业)年金 + BigDecimal annuity = findValue(TaxDeclarationDataIndexConstant.ANNUITY, resultMap, salaryItemMap); + valueMap.put(TaxDeclarationDataIndexConstant.ANNUITY, annuity.toPlainString()); + // 商业健康保险 + BigDecimal commercialHealthInsurance = findValue(TaxDeclarationDataIndexConstant.COMMERCIAL_HEALTH_INSURANCE, resultMap, salaryItemMap); + valueMap.put(TaxDeclarationDataIndexConstant.COMMERCIAL_HEALTH_INSURANCE, commercialHealthInsurance.toPlainString()); + // 税延养老保险 + BigDecimal taxDeferredEndowmentInsurance = findValue(TaxDeclarationDataIndexConstant.TAX_DEFERRED_ENDOWMENT_INSURANCE, resultMap, salaryItemMap); + valueMap.put(TaxDeclarationDataIndexConstant.TAX_DEFERRED_ENDOWMENT_INSURANCE, taxDeferredEndowmentInsurance.toPlainString()); + // 其他 + BigDecimal other = findValue(TaxDeclarationDataIndexConstant.OTHER, resultMap, salaryItemMap); + valueMap.put(TaxDeclarationDataIndexConstant.OTHER, other.toPlainString()); + // 准予扣除的捐赠额 + BigDecimal allowedDonation = findValue(TaxDeclarationDataIndexConstant.ALLOWED_DONATION, resultMap, salaryItemMap); + valueMap.put(TaxDeclarationDataIndexConstant.ALLOWED_DONATION, allowedDonation.toPlainString()); + // 减免税额 + BigDecimal taxDeduction = findValue(TaxDeclarationDataIndexConstant.TAX_DEDUCTION, resultMap, salaryItemMap); + valueMap.put(TaxDeclarationDataIndexConstant.TAX_DEDUCTION, taxDeduction.toPlainString()); + // 生成个税申报表详情 + result.getNeedInsertTaxDeclarationDetails().addAll(convert2DetailPO(taxDeclaration, employeeType, employeeId, valueMap)); + }); + } + + /** + * 生成个税申报表明细(劳务报酬所得) + * + * @param result + * @param taxDeclaration + * @param salaryAcctResults + * @param salaryItemMap + */ + private static void handleTaxDeclaration4Labor(Result result, + TaxDeclarationPO taxDeclaration, + List salaryAcctResults, + Map salaryItemMap) { + if (CollectionUtils.isEmpty(salaryAcctResults)) { + return; + } + // 核算结果按照人员id分类 + Map> salaryAcctResultPOMap = SalaryEntityUtil.group2Map(salaryAcctResults, salaryAcctResultPO -> EmployeeTypeEnum.ORGANIZATION.getValue() + "_" + salaryAcctResultPO.getEmployeeId()); + salaryAcctResultPOMap.forEach((key, salaryAcctResultPOS) -> { + String[] keyArray = StringUtils.split(key, "_"); + Integer employeeType = Integer.parseInt(keyArray[0]); + Long employeeId = Long.parseLong(keyArray[1]); + Map valueMap = Maps.newHashMapWithExpectedSize(7); + Map> resultMap = SalaryEntityUtil.group2Map(salaryAcctResultPOS, SalaryAcctResultPO::getSalaryItemId); + // 所得项目 + String incomeItems = resultMap.getOrDefault(salaryItemMap.getOrDefault(TaxDeclarationDataIndexConstant.INCOME_ITEMS, 0L), Collections.emptyList()).stream() + .map(SalaryAcctResultPO::getResultValue) + .findAny() + .orElse(StringUtils.EMPTY); + valueMap.put(TaxDeclarationDataIndexConstant.INCOME_ITEMS, incomeItems); + // 收入 + BigDecimal laborIncome = findValue(TaxDeclarationDataIndexConstant.LABOR_INCOME, resultMap, salaryItemMap); + valueMap.put(TaxDeclarationDataIndexConstant.LABOR_INCOME, laborIncome.toPlainString()); + // 免税收入 + BigDecimal laborTaxFreeIncome = findValue(TaxDeclarationDataIndexConstant.LABOR_TAX_FREE_INCOME, resultMap, salaryItemMap); + valueMap.put(TaxDeclarationDataIndexConstant.LABOR_TAX_FREE_INCOME, laborTaxFreeIncome.toPlainString()); + // 商业健康保险 + BigDecimal commercialHealthInsurance = findValue(TaxDeclarationDataIndexConstant.COMMERCIAL_HEALTH_INSURANCE, resultMap, salaryItemMap); + valueMap.put(TaxDeclarationDataIndexConstant.COMMERCIAL_HEALTH_INSURANCE, commercialHealthInsurance.toPlainString()); + // 税延养老保险 + BigDecimal taxDeferredEndowmentInsurance = findValue(TaxDeclarationDataIndexConstant.TAX_DEFERRED_ENDOWMENT_INSURANCE, resultMap, salaryItemMap); + valueMap.put(TaxDeclarationDataIndexConstant.TAX_DEFERRED_ENDOWMENT_INSURANCE, taxDeferredEndowmentInsurance.toPlainString()); + // 其他 + BigDecimal other = findValue(TaxDeclarationDataIndexConstant.OTHER, resultMap, salaryItemMap); + valueMap.put(TaxDeclarationDataIndexConstant.OTHER, other.toPlainString()); + // 准予扣除的捐赠额 + BigDecimal allowedDonation = findValue(TaxDeclarationDataIndexConstant.ALLOWED_DONATION, resultMap, salaryItemMap); + valueMap.put(TaxDeclarationDataIndexConstant.ALLOWED_DONATION, allowedDonation.toPlainString()); + // 生成个税申报表详情 + result.getNeedInsertTaxDeclarationDetails().addAll(convert2DetailPO(taxDeclaration, employeeType, employeeId, valueMap)); + }); + } + + /** + * 生成个税申报表明细(年终奖) + * + * @param result + * @param taxDeclaration + * @param salaryAcctResults + * @param salaryItemMap + */ + private static void handleTaxDeclaration4Annual(Result result, + TaxDeclarationPO taxDeclaration, + List salaryAcctResults, + Map salaryItemMap) { + if (CollectionUtils.isEmpty(salaryAcctResults)) { + return; + } + // 核算结果按照人员id分类 + Map> salaryAcctResultPOMap = SalaryEntityUtil.group2Map(salaryAcctResults, salaryAcctResultPO -> EmployeeTypeEnum.ORGANIZATION.getValue() + "_" + salaryAcctResultPO.getEmployeeId()); + salaryAcctResultPOMap.forEach((key, salaryAcctResultPOS) -> { + String[] keyArray = StringUtils.split(key, "_"); + Integer employeeType = Integer.parseInt(keyArray[0]); + Long employeeId = Long.parseLong(keyArray[1]); + Map valueMap = Maps.newHashMapWithExpectedSize(7); + Map> resultMap = SalaryEntityUtil.group2Map(salaryAcctResultPOS, SalaryAcctResultPO::getSalaryItemId); + // 全年一次性奖金额 + BigDecimal laborIncome = findValue(TaxDeclarationDataIndexConstant.ANNUAL_INCOME, resultMap, salaryItemMap); + valueMap.put(TaxDeclarationDataIndexConstant.ANNUAL_INCOME, laborIncome.toPlainString()); + // 免税收入 + BigDecimal laborTaxFreeIncome = findValue(TaxDeclarationDataIndexConstant.ANNUAL_TAX_FREE_INCOME, resultMap, salaryItemMap); + valueMap.put(TaxDeclarationDataIndexConstant.ANNUAL_TAX_FREE_INCOME, laborTaxFreeIncome.toPlainString()); + // 其他 + BigDecimal other = findValue(TaxDeclarationDataIndexConstant.ANNUAL_OTHER, resultMap, salaryItemMap); + valueMap.put(TaxDeclarationDataIndexConstant.ANNUAL_OTHER, other.toPlainString()); + // 准予扣除的捐赠额 + BigDecimal allowedDonation = findValue(TaxDeclarationDataIndexConstant.ANNUAL_DONATE_TAX, resultMap, salaryItemMap); + valueMap.put(TaxDeclarationDataIndexConstant.ANNUAL_DONATE_TAX, allowedDonation.toPlainString()); + // 减免税额 + BigDecimal annualTaxSavings = findValue(TaxDeclarationDataIndexConstant.ANNUAL_TAX_SAVINGS, resultMap, salaryItemMap); + valueMap.put(TaxDeclarationDataIndexConstant.ANNUAL_TAX_SAVINGS, annualTaxSavings.toPlainString()); + // 备注 + String annualRemark = findStringValue(TaxDeclarationDataIndexConstant.ANNUAL_REMARK, resultMap, salaryItemMap); + valueMap.put(TaxDeclarationDataIndexConstant.ANNUAL_REMARK, annualRemark); + // 生成个税申报表详情 + result.getNeedInsertTaxDeclarationDetails().addAll(convert2DetailPO(taxDeclaration, employeeType, employeeId, valueMap)); + }); + } + + /** + * 往期累计情况 + * + * @param result + * @param taxDeclaration + * @param salaryAcctResults + * @param salaryItemMap + */ + private static void handleAddUpSituation(Result result, + TaxDeclarationPO taxDeclaration, + List salaryAcctResults, + Map salaryItemMap) { + if (CollectionUtils.isEmpty(salaryAcctResults)) { + return; + } + // 核算结果按照人员id分类 + Map> salaryAcctResultPOMap = SalaryEntityUtil.group2Map(salaryAcctResults, salaryAcctResultPO -> EmployeeTypeEnum.ORGANIZATION.getValue() + "_" + salaryAcctResultPO.getEmployeeId()); + salaryAcctResultPOMap.forEach((key, salaryAcctResultPOS) -> { + String[] keyArray = key.split("_"); + Integer employeeType = Integer.parseInt(keyArray[0]); + Long employeeId = Long.parseLong(keyArray[1]); + Map> resultMap = SalaryEntityUtil.group2Map(salaryAcctResultPOS, SalaryAcctResultPO::getSalaryItemId); + // 累计收入额 + BigDecimal addUpIncome = findAddUpValue(TaxDeclarationDataIndexConstant.ADD_UP_INCOME, resultMap, salaryItemMap); + // 累计免税收入 + BigDecimal addUpTaxFreeIncome = findAddUpValue(TaxDeclarationDataIndexConstant.ADD_UP_TAX_FREE_INCOME, resultMap, salaryItemMap); + // 累计减除费用 + BigDecimal addUpSubtraction = findAddUpValue(TaxDeclarationDataIndexConstant.ADD_UP_SUBTRACTION, resultMap, salaryItemMap); + // 累计社保个人合计 + BigDecimal addUpSocialSecurityTotal = findAddUpValue(TaxDeclarationDataIndexConstant.ADD_UP_SOCIAL_SECURITY_TOTAL, resultMap, salaryItemMap); + // 累计公积金个人合计 + BigDecimal addUpAccumulationFundTotal = findAddUpValue(TaxDeclarationDataIndexConstant.ADD_UP_ACCUMULATION_FUND_TOTAL, resultMap, salaryItemMap); + // 累计子女教育 + BigDecimal addUpChildEducation = findAddUpValue(TaxDeclarationDataIndexConstant.ADD_UP_CHILD_EDUCATION, resultMap, salaryItemMap); + // 累计继续教育 + BigDecimal addUpContinuingEducation = findAddUpValue(TaxDeclarationDataIndexConstant.ADD_UP_CONTINUING_EDUCATION, resultMap, salaryItemMap); + // 累计住房贷款利息 + BigDecimal addUpHousingLoanInterest = findAddUpValue(TaxDeclarationDataIndexConstant.ADD_UP_HOUSING_LOAN_INTEREST, resultMap, salaryItemMap); + // 累计住房租金 + BigDecimal addUpHousingRent = findAddUpValue(TaxDeclarationDataIndexConstant.ADD_UP_HOUSING_RENT, resultMap, salaryItemMap); + // 累计赡养老人 + BigDecimal addUpSupportElderly = findAddUpValue(TaxDeclarationDataIndexConstant.ADD_UP_SUPPORT_ELDERLY, resultMap, salaryItemMap); + // 累计大病医疗 + BigDecimal addUpIllnessMedical = findAddUpValue(TaxDeclarationDataIndexConstant.ADD_UP_ILLNESS_MEDICAL, resultMap, salaryItemMap); + // 累计婴幼儿照护 + BigDecimal addUpInfantCare = findAddUpValue(TaxDeclarationDataIndexConstant.ADD_UP_INFANT_CARE, resultMap, salaryItemMap); + // 累计个人养老金 + BigDecimal addUpPrivatePension = findAddUpValue(TaxDeclarationDataIndexConstant.ADD_UP_PRIVATE_PENSION, resultMap, salaryItemMap); + // 累计企业(职业)年金及其他福利 + BigDecimal addUpEnterpriseAndOther = findAddUpValue(TaxDeclarationDataIndexConstant.ADD_UP_ENTERPRISE_AND_OTHER, resultMap, salaryItemMap); + // 累计其他免税扣除 + BigDecimal addUpOtherDeduction = findAddUpValue(TaxDeclarationDataIndexConstant.ADD_UP_OTHER_DEDUCTION, resultMap, salaryItemMap); + // 累计准予扣除的捐赠额 + BigDecimal addUpAllowedDonation = findAddUpValue(TaxDeclarationDataIndexConstant.ADD_UP_ALLOWED_DONATION, resultMap, salaryItemMap); + // 累计应纳税所得额 + BigDecimal addUpTaxableIncome = findAddUpValue(TaxDeclarationDataIndexConstant.ADD_UP_TAXABLE_INCOME, resultMap, salaryItemMap); + // 累计应纳税额 + BigDecimal addUpTaxPayable = findAddUpValue(TaxDeclarationDataIndexConstant.ADD_UP_TAX_PAYABLE, resultMap, salaryItemMap); + //累计减免税额 + BigDecimal addUpTaxDeduction = findAddUpValue(TaxDeclarationDataIndexConstant.ADD_UP_TAX_DEDUCTION, resultMap, salaryItemMap); + // 累计已预扣预缴税额 + List resultPOS = resultMap.get(salaryItemMap.getOrDefault(TaxDeclarationDataIndexConstant.ADD_UP_ADVANCE_TAX, 0L)); + BigDecimal addUpAdvanceTax = resultPOS == null ? BigDecimal.ZERO : resultPOS.stream() + .map(salaryAcctResultPO -> SalaryEntityUtil.empty2Zero(salaryAcctResultPO.getResultValue())) + .min(BigDecimal::compareTo) + .orElse(BigDecimal.ZERO); + // 本月(次)应补(退)税额 + BigDecimal refundedOrSupplementedTax = SalaryEntityUtil.reduce(resultMap.get(salaryItemMap.getOrDefault(TaxDeclarationDataIndexConstant.REFUNDED_OR_SUPPLEMENTED_TAX, 0L)), + salaryAcctResultPO -> SalaryEntityUtil.empty2Zero(salaryAcctResultPO.getResultValue())); + // 生成往期累计情况 + AddUpSituation accumulatedSituation = AddUpSituation.builder() + .employeeId(employeeId) +// .employeeType(employeeType) + .taxAgentId(taxDeclaration.getTaxAgentId()) + .taxYearMonth(taxDeclaration.getTaxCycle()) + .year(SalaryDateUtil.date2Year(taxDeclaration.getTaxCycle())) + .addUpIncome(addUpIncome.toPlainString()) + .addUpSocialSecurityTotal(addUpSocialSecurityTotal.toPlainString()) + .addUpAccumulationFundTotal(addUpAccumulationFundTotal.toPlainString()) + .addUpEnterpriseAndOther(addUpEnterpriseAndOther.toPlainString()) + .addUpSubtraction(addUpSubtraction.toPlainString()) + .addUpChildEducation(addUpChildEducation.toPlainString()) + .addUpContinuingEducation(addUpContinuingEducation.toPlainString()) + .addUpHousingLoanInterest(addUpHousingLoanInterest.toPlainString()) + .addUpHousingRent(addUpHousingRent.toPlainString()) + .addUpSupportElderly(addUpSupportElderly.toPlainString()) + .addUpIllnessMedical(addUpIllnessMedical.toPlainString()) + .addUpInfantCare(addUpInfantCare.toPlainString()) + .addUpPrivatePension(addUpPrivatePension.toPlainString()) + .addUpOtherDeduction(addUpOtherDeduction.toPlainString()) + .addUpTaxExemptIncome(addUpTaxFreeIncome.toPlainString()) + .addUpAllowedDonation(addUpAllowedDonation.toPlainString()) + .addUpAdvanceTax(addUpAdvanceTax.add(refundedOrSupplementedTax).toPlainString()) + .addUpTaxSavings(addUpTaxDeduction.toPlainString()) + .creator(taxDeclaration.getCreator()) + .createTime(taxDeclaration.getCreateTime()) + .updateTime(taxDeclaration.getUpdateTime()) + .tenantKey(taxDeclaration.getTenantKey()) + .deleteType(NumberUtils.INTEGER_ZERO) + .build(); + encryptUtil.encrypt(accumulatedSituation, AddUpSituation.class); + result.getNeedInsertAddUpSituations().add(accumulatedSituation); + }); + } + + +// private static void handleTaxDeclarationDetail(Result result, +// TaxDeclarationPO taxDeclaration, +// List salaryAcctResults, +// Map salaryItemMap) { +// if (CollectionUtils.isEmpty(salaryAcctResults)) { +// return; +// } +// // 核算结果按照人员id分类 +// Map> acctResultMap = SalaryEntityUtil.group2Map(salaryAcctResults, SalaryAcctResultPO::getEmployeeId); +// acctResultMap.forEach((k, v) -> { +// Long employeeId = k; +// Map valueMap = new HashMap<>(); +// Map> resultMap = SalaryEntityUtil.group2Map(v, SalaryAcctResultPO::getSalaryItemId); +// // 收入 +// BigDecimal income = SalaryEntityUtil.reduce(resultMap.get(salaryItemMap.getOrDefault("income", 0L)), e -> SalaryEntityUtil.empty2Zero(e.getResultValue())); +// valueMap.put("income", income); +// // 费用 +// BigDecimal fee = BigDecimal.ZERO; +// valueMap.put("fee", fee); +// // 免税收入 +// BigDecimal taxFreeIncome = BigDecimal.ZERO; +// valueMap.put("taxFreeIncome", taxFreeIncome); +// // 减除费用 +// BigDecimal subtraction = findValue("subtraction", resultMap, salaryItemMap); +// valueMap.put("subtraction", subtraction); +// // 基本养老保险 +// BigDecimal endowmentInsurance = findValue("endowmentInsurance", resultMap, salaryItemMap); +// valueMap.put("endowmentInsurance", endowmentInsurance); +// // 基本医疗保险 +// BigDecimal medicalInsurance = findValue("medicalInsurance", resultMap, salaryItemMap); +// valueMap.put("medicalInsurance", medicalInsurance); +// // 失业保险 +// BigDecimal unemploymentInsurance = findValue("unemploymentInsurance", resultMap, salaryItemMap); +// valueMap.put("unemploymentInsurance", unemploymentInsurance); +// // 住房公积金 +// BigDecimal housingProvidentFund = findValue("housingProvidentFund", resultMap, salaryItemMap); +// valueMap.put("housingProvidentFund", housingProvidentFund); +// // 年金 +// BigDecimal annuity = findValue("annuity", resultMap, salaryItemMap); +// valueMap.put("annuity", annuity); +// // 商业健康保险 +// BigDecimal commercialHealthInsurance = findValue("commercialHealthInsurance", resultMap, salaryItemMap); +// valueMap.put("commercialHealthInsurance", commercialHealthInsurance); +// // 税延养老保险 +// BigDecimal taxDeferredEndowmentInsurance = findValue("taxDeferredEndowmentInsurance", resultMap, salaryItemMap); +// valueMap.put("taxDeferredEndowmentInsurance", taxDeferredEndowmentInsurance); +// // 财产原值 +// BigDecimal originalValueOfProperty = findValue("originalValueOfProperty", resultMap, salaryItemMap); +// valueMap.put("originalValueOfProperty", originalValueOfProperty); +// // 允许扣除的税费 +// BigDecimal deductedTax = findValue("deductedTax", resultMap, salaryItemMap); +// valueMap.put("deductedTax", deductedTax); +// // 其他 +// BigDecimal other = findValue("other", resultMap, salaryItemMap); +// valueMap.put("other", other); +// // 累计收入 +// BigDecimal addUpIncome = findAddUpValue("addUpIncome", resultMap, salaryItemMap); +// valueMap.put("addUpIncome", addUpIncome); +// // 累计免税收入 +// BigDecimal addUpTaxFreeIncome = findAddUpValue("addUpTaxFreeIncome", resultMap, salaryItemMap); +// valueMap.put("addUpTaxFreeIncome", addUpTaxFreeIncome); +// // 累计减除费用 +// BigDecimal addUpSubtraction = findAddUpValue("addUpSubtraction", resultMap, salaryItemMap); +// valueMap.put("addUpSubtraction", addUpSubtraction); +// // 累计专项扣除 +// BigDecimal addUpSpecialDeduction = findAddUpValue("addUpSpecialDeduction", resultMap, salaryItemMap); +// valueMap.put("addUpSpecialDeduction", addUpSpecialDeduction); +// // 累计子女教育 +// BigDecimal addUpChildEducation = findAddUpValue("addUpChildEducation", resultMap, salaryItemMap); +// valueMap.put("addUpChildEducation", addUpChildEducation); +// // 累计继续教育 +// BigDecimal addUpContinuingEducation = findAddUpValue("addUpContinuingEducation", resultMap, salaryItemMap); +// valueMap.put("addUpContinuingEducation", addUpContinuingEducation); +// // 累计住房贷款利息 +// BigDecimal addUpHousingLoanInterest = findAddUpValue("addUpHousingLoanInterest", resultMap, salaryItemMap); +// valueMap.put("addUpHousingLoanInterest", addUpHousingLoanInterest); +// // 累计住房租金 +// BigDecimal addUpHousingRent = findAddUpValue("addUpHousingRent", resultMap, salaryItemMap); +// valueMap.put("addUpHousingRent", addUpHousingRent); +// // 累计赡养老人 +// BigDecimal addUpSupportElderly = findAddUpValue("addUpSupportElderly", resultMap, salaryItemMap); +// valueMap.put("addUpSupportElderly", addUpSupportElderly); +// // 累计大病医疗 +// BigDecimal addUpIllnessMedical = findAddUpValue("addUpIllnessMedical", resultMap, salaryItemMap); +// valueMap.put("addUpIllnessMedical", addUpIllnessMedical); +// // 累计婴幼儿照护 +// BigDecimal addUpInfantCare = findAddUpValue("addUpInfantCare", resultMap, salaryItemMap); +// valueMap.put("addUpInfantCare", addUpInfantCare); +// // 累计其他扣除 +// BigDecimal addUpOtherDeduction = findAddUpValue("addUpOtherDeduction", resultMap, salaryItemMap); +// valueMap.put("addUpOtherDeduction", addUpOtherDeduction); +// // 减按计税比例 +// BigDecimal lessTaxProportion = BigDecimal.ONE; +// valueMap.put("lessTaxProportion", lessTaxProportion); +// // 准允扣除的捐赠额 +// BigDecimal addUpAllowedDonation = findAddUpValue("addUpAllowedDonation", resultMap, salaryItemMap); +// valueMap.put("addUpAllowedDonation", addUpAllowedDonation); +// // 应纳税所得额 +// BigDecimal addUpTaxableIncome = findAddUpValue("addUpTaxableIncome", resultMap, salaryItemMap); +// valueMap.put("addUpTaxableIncome", addUpTaxableIncome); +// // 税率 +// BigDecimal taxRate = findAddUpValue("taxRate", resultMap, salaryItemMap); +// valueMap.put("taxRate", taxRate); +// // 速算扣除数 +// BigDecimal quickDeductionFactor = findAddUpValue("quickDeductionFactor", resultMap, salaryItemMap); +// valueMap.put("quickDeductionFactor", quickDeductionFactor); +// // 应纳税额 +// BigDecimal addUpTaxPayable = findAddUpValue("addUpTaxPayable", resultMap, salaryItemMap); +// valueMap.put("addUpTaxPayable", addUpTaxPayable); +// // 减免税额 +// BigDecimal addUpTaxDeduction = BigDecimal.ZERO; +// valueMap.put("addUpTaxDeduction", addUpTaxDeduction); +// // 减免税额 +// BigDecimal taxDeduction = findValue("taxDeduction", resultMap, salaryItemMap); +// valueMap.put("taxDeduction", taxDeduction); +// // 应补缴税额 +// BigDecimal refundedOrSupplementedTax = SalaryEntityUtil.reduce(resultMap.get(salaryItemMap.getOrDefault("refundedOrSupplementedTax", 0L)), +// e -> SalaryEntityUtil.empty2Zero(e.getResultValue())); +// valueMap.put("refundedOrSupplementedTax", refundedOrSupplementedTax); +// // 已扣缴税额 +// BigDecimal taxWithheld = addUpTaxPayable.subtract(refundedOrSupplementedTax); +// valueMap.put("taxWithheld", taxWithheld); +// +// valueMap.forEach((key, value) -> { +// TaxDeclarationDetailPO detailPO = TaxDeclarationDetailPO.builder() +// .taxDeclarationId(taxDeclaration.getId()) +// .employeeId(k) +// .fieldCode(key) +// .fieldValue(value.toPlainString()) +// .creator(taxDeclaration.getCreator()) +// .createTime(taxDeclaration.getCreateTime()) +// .updateTime(taxDeclaration.getUpdateTime()) +// .deleteType(0) +// .tenantKey(taxDeclaration.getTenantKey()) +// .build(); +// result.getNeedInsertTaxDeclarationDetails().add(detailPO); +// }); +// // 累计社保个人合计 +// BigDecimal addUpSocialSecurityTotal = findAddUpValue("addUpSocialSecurityTotal", resultMap, salaryItemMap); +// // 累计公积金个人合计 +// BigDecimal addUpAccumulationFundTotal = findAddUpValue("addUpAccumulationFundTotal", resultMap, salaryItemMap); +// // 累计年金及其他福利合计 +// BigDecimal addUpEnterpriseAndOther = findAddUpValue("addUpEnterpriseAndOther", resultMap, salaryItemMap); +// +// // 更新累计情况 +// AddUpSituation accumulatedSituation = AddUpSituation.builder() +// .employeeId(employeeId) +// .taxAgentId(taxDeclaration.getTaxAgentId()) +// .taxYearMonth(taxDeclaration.getTaxCycle()) +// .year(SalaryDateUtil.date2Year(taxDeclaration.getTaxCycle())) +// .addUpIncome(addUpIncome.toPlainString()) +// .addUpSocialSecurityTotal(addUpSocialSecurityTotal.toPlainString()) +// .addUpAccumulationFundTotal(addUpAccumulationFundTotal.toPlainString()) +// .addUpEnterpriseAndOther(addUpEnterpriseAndOther.toPlainString()) +// .addUpSubtraction(addUpSubtraction.toPlainString()) +// .addUpChildEducation(addUpChildEducation.toPlainString()) +// .addUpContinuingEducation(addUpContinuingEducation.toPlainString()) +// .addUpHousingLoanInterest(addUpHousingLoanInterest.toPlainString()) +// .addUpHousingRent(addUpHousingRent.toPlainString()) +// .addUpSupportElderly(addUpSupportElderly.toPlainString()) +// .addUpIllnessMedical(addUpIllnessMedical.toPlainString()) +// .addUpInfantCare(addUpInfantCare.toPlainString()) +// .addUpOtherDeduction(addUpOtherDeduction.toPlainString()) +// .addUpTaxExemptIncome(addUpTaxFreeIncome.toPlainString()) +// .addUpAllowedDonation(addUpAllowedDonation.toPlainString()) +// .addUpAdvanceTax(addUpTaxPayable.toPlainString()) +//// .addUpTaxSavings(taxDeduction.toPlainString()) +// .creator(taxDeclaration.getCreator()) +// .createTime(taxDeclaration.getCreateTime()) +// .updateTime(taxDeclaration.getUpdateTime()) +// .tenantKey(taxDeclaration.getTenantKey()) +// .deleteType(NumberUtils.INTEGER_ZERO) +// .build(); +// result.getNeedInsertAccumulatedSituations().add(accumulatedSituation); +// }); +// } + + private static TaxDeclarationPO convert2PO(TaxDeclarationSaveParam saveParam, User user, Date taxCycle, Long taxAgentId, Integer incomeCategory) { + LocalDateTime now = LocalDateTime.now(); + if (saveParam.getDescription() == null) { + saveParam.setDescription(""); + } + return TaxDeclarationPO.builder() + .id(IdGenerator.generate()) + .incomeCategory(incomeCategory) + .taxAgentId(taxAgentId) + .salaryMonth(SalaryDateUtil.localDateToDate(saveParam.getSalaryMonth().atDay(1))) + .taxCycle(taxCycle) + .description(saveParam.getDescription()) + .creator((long) user.getUID()) + .createTime(SalaryDateUtil.localDateTimeToDate(now)) + .updateTime(SalaryDateUtil.localDateTimeToDate(now)) + .deleteType(0) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .build(); + } + + /** + * 根据参数生成个税申报表详情po + * + * @param taxDeclaration + * @param employeeId + * @param valueMap + * @return + */ + private static List convert2DetailPO(TaxDeclarationPO taxDeclaration, Integer employeeType, Long employeeId, Map valueMap) { + if (MapUtils.isEmpty(valueMap)) { + return Collections.emptyList(); + } + List taxDeclarationDetailPOS = Lists.newArrayListWithExpectedSize(valueMap.size()); + valueMap.forEach((fieldCode, fieldValue) -> { + TaxDeclarationDetailPO taxDeclarationDetailPO = TaxDeclarationDetailPO.builder() + .id(IdGenerator.generate()) + .taxDeclarationId(taxDeclaration.getId()) + .employeeType(employeeType) + .employeeId(employeeId) + .fieldCode(fieldCode) + .fieldValue(fieldValue) + .creator(taxDeclaration.getCreator()) + .createTime(taxDeclaration.getCreateTime()) + .updateTime(taxDeclaration.getUpdateTime()) + .deleteType(NumberUtils.INTEGER_ZERO) + .tenantKey(taxDeclaration.getTenantKey()) + .build(); + taxDeclarationDetailPOS.add(taxDeclarationDetailPO); + }); + return taxDeclarationDetailPOS; + } + + private static BigDecimal findValue(String fieldCode, Map> resultMap, Map salaryItemMap) { + return resultMap.getOrDefault(salaryItemMap.getOrDefault(fieldCode, 0L), Collections.emptyList()).stream() + .map(e -> SalaryEntityUtil.empty2Zero(e.getResultValue())) + .filter(e -> e.compareTo(BigDecimal.ZERO) > 0) + .findAny() + .orElse(BigDecimal.ZERO); + } + + private static BigDecimal findAddUpValue(String fieldCode, Map> resultMap, Map salaryItemMap) { + return resultMap.getOrDefault(salaryItemMap.getOrDefault(fieldCode, 0L), Collections.emptyList()).stream() + .map(e -> SalaryEntityUtil.empty2Zero(e.getResultValue())) + .max(Comparator.comparingDouble(BigDecimal::doubleValue)) + .orElse(BigDecimal.ZERO); + } + + private static String findStringValue(String fieldCode, Map> resultMap, Map salaryItemMap) { + return resultMap.getOrDefault(salaryItemMap.getOrDefault(fieldCode, 0L), Collections.emptyList()).stream() + .map(SalaryAcctResultPO::getResultValue) + .findFirst().orElse(""); + } + + @Data + public static class Result { + + private Collection needInsertTaxDeclarations; + + private Collection needInsertTaxDeclarationDetails; + + private Collection needInsertAddUpSituations; + + public Result() { + this.needInsertTaxDeclarations = Lists.newArrayList(); + this.needInsertTaxDeclarationDetails = Lists.newArrayList(); + this.needInsertAddUpSituations = Lists.newArrayList(); + } + } +} diff --git a/src/com/engine/salary/entity/taxdeclaration/bo/TaxDeclarationDetailBO.java b/src/com/engine/salary/entity/taxdeclaration/bo/TaxDeclarationDetailBO.java new file mode 100644 index 000000000..0fe5a0815 --- /dev/null +++ b/src/com/engine/salary/entity/taxdeclaration/bo/TaxDeclarationDetailBO.java @@ -0,0 +1,181 @@ +package com.engine.salary.entity.taxdeclaration.bo; + +import com.engine.salary.constant.TaxDeclarationDataIndexConstant; +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationAnnualListDTO; +import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationEmployeeDTO; +import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationLaborListDTO; +import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationWageListDTO; +import com.engine.salary.entity.taxdeclaration.po.TaxDeclarationDetailPO; +import com.engine.salary.enums.salaryaccounting.EmployeeTypeEnum; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.SalaryI18nUtil; +import com.google.common.collect.Lists; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import weaver.general.Util; + +import java.util.*; + +/** + * 个税申报表详情 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class TaxDeclarationDetailBO { + + /** + * 转换成个税申报表详情列表(正常工资薪金所得) + * + * @param taxDeclarationDetailPOS + * @param simpleEmployees + * @return + */ + public static List convert2ListDTO4Wage(List taxDeclarationDetailPOS, + List taxDeclarationEmployeeDTOS, + List simpleEmployees) { + if (CollectionUtils.isEmpty(taxDeclarationDetailPOS)) { + return Collections.emptyList(); + } + List taxDeclarationWageListDTOS = Lists.newArrayListWithExpectedSize(taxDeclarationEmployeeDTOS.size()); + Map> employeeIdKeyTaxDeclarationDetailPOMap = SalaryEntityUtil.group2Map(taxDeclarationDetailPOS, + taxDeclarationDetailPO -> EmployeeTypeEnum.ORGANIZATION.getValue() + "_" + taxDeclarationDetailPO.getEmployeeId()); + Map simpleEmployeeMap = SalaryEntityUtil.convert2Map(simpleEmployees, DataCollectionEmployee::getEmployeeId); + for (TaxDeclarationEmployeeDTO dto : taxDeclarationEmployeeDTOS) { + Map fieldCodeKeyFieldValueMap = SalaryEntityUtil.convert2Map(employeeIdKeyTaxDeclarationDetailPOMap.get(dto.getEmployeeType() + "_" + dto.getEmployeeId()), + TaxDeclarationDetailPO::getFieldCode, TaxDeclarationDetailPO::getFieldValue); + TaxDeclarationWageListDTO taxDeclarationWageListDTO = TaxDeclarationWageListDTO.builder() + .cardType(SalaryI18nUtil.getI18nLabel(105564, "居民身份证")) + .income(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.INCOME)) + .taxFreeIncome(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.TAX_FREE_INCOME)) + .endowmentInsurance(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.ENDOWMENT_INSURANCE)) + .medicalInsurance(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.MEDICAL_INSURANCE)) + .unemploymentInsurance(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.UNEMPLOYMENT_INSURANCE)) + .housingProvidentFund(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.HOUSING_PROVIDENT_FUND)) + .addUpChildEducation(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.ADD_UP_CHILD_EDUCATION)) + .addUpHousingLoanInterest(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.ADD_UP_HOUSING_LOAN_INTEREST)) + .addUpHousingRent(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.ADD_UP_HOUSING_RENT)) + .addUpContinuingEducation(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.ADD_UP_CONTINUING_EDUCATION)) + .addUpSupportElderly(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.ADD_UP_SUPPORT_ELDERLY)) + .addUpIllnessMedical(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.ADD_UP_ILLNESS_MEDICAL)) + .addUpInfantCare(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.ADD_UP_INFANT_CARE)) + .addUpPrivatePension(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.ADD_UP_PRIVATE_PENSION)) + .annuity(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.ANNUITY)) + .commercialHealthInsurance(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.COMMERCIAL_HEALTH_INSURANCE)) + .taxDeferredEndowmentInsurance(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.TAX_DEFERRED_ENDOWMENT_INSURANCE)) + .other(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.OTHER)) + .allowedDonation(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.ALLOWED_DONATION)) + .taxDeduction(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.TAX_DEDUCTION)) + .description(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.DESCRIPTION)).build(); + if (dto.getEmployeeType() == null || Objects.equals(dto.getEmployeeType(), EmployeeTypeEnum.ORGANIZATION.getValue())) { + DataCollectionEmployee simpleEmployee = simpleEmployeeMap.get(dto.getEmployeeId()); + taxDeclarationWageListDTO.setId(simpleEmployee.getEmployeeId()) + .setEmployeeId(simpleEmployee.getEmployeeId()) + .setJobNum(simpleEmployee.getWorkcode()) + .setUsername(simpleEmployee.getUsername()) + .setCardNum(Optional.ofNullable(simpleEmployee).map(DataCollectionEmployee::getIdNo).orElse(StringUtils.EMPTY)); + } else { +// ExtEmployeePO extEmployeePO = extEmployeePOMap.get(dto.getEmployeeId()); +// taxDeclarationWageListDTO.setId(extEmployeePO.getId()) +// .setEmployeeId(extEmployeePO.getId()) +// .setJobNum(StringUtils.EMPTY) +// .setUsername(extEmployeePO.getUsername()) +// .setCardNum(extEmployeePO.getCardNum()); + } + taxDeclarationWageListDTOS.add(taxDeclarationWageListDTO); + } + return taxDeclarationWageListDTOS; + } + + /** + * 转换成个税申报表详情列表(劳务报酬所得) + * + * @param taxDeclarationDetailPOS + * @param simpleEmployees + * @return + */ + public static List convert2ListDTO4Labor(List taxDeclarationDetailPOS, + List taxDeclarationEmployeeDTOS, + List simpleEmployees) { + if (CollectionUtils.isEmpty(taxDeclarationDetailPOS)) { + return Collections.emptyList(); + } + List taxDeclarationLaborListDTOS = Lists.newArrayListWithExpectedSize(taxDeclarationEmployeeDTOS.size()); + Map> employeeIdKeyTaxDeclarationDetailPOMap = SalaryEntityUtil.group2Map(taxDeclarationDetailPOS, + taxDeclarationDetailPO -> taxDeclarationDetailPO.getEmployeeType() + "_" + taxDeclarationDetailPO.getEmployeeId()); + Map simpleEmployeeMap = SalaryEntityUtil.convert2Map(simpleEmployees, DataCollectionEmployee::getEmployeeId); + for (TaxDeclarationEmployeeDTO dto : taxDeclarationEmployeeDTOS) { + Map fieldCodeKeyFieldValueMap = SalaryEntityUtil.convert2Map(employeeIdKeyTaxDeclarationDetailPOMap.get(dto.getEmployeeType() + "_" + dto.getEmployeeId()), + TaxDeclarationDetailPO::getFieldCode, TaxDeclarationDetailPO::getFieldValue); + TaxDeclarationLaborListDTO taxDeclarationLaborListDTO = new TaxDeclarationLaborListDTO() + .setId(dto.getEmployeeId()) + .setEmployeeId(dto.getEmployeeId()) + .setCardType(SalaryI18nUtil.getI18nLabel(105564, "居民身份证")) + .setIncomeItems(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.INCOME_ITEMS)) + .setLaborIncome(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.LABOR_INCOME)) + .setLaborTaxFreeIncome(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.LABOR_TAX_FREE_INCOME)) + .setCommercialHealthInsurance(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.COMMERCIAL_HEALTH_INSURANCE)) + .setTaxDeferredEndowmentInsurance(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.TAX_DEFERRED_ENDOWMENT_INSURANCE)) + .setOther(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.OTHER)) + .setAllowedDonation(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.ALLOWED_DONATION)) + .setTaxDeduction(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.TAX_DEDUCTION)) + .setDescription(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.DESCRIPTION)); + if (dto.getEmployeeType() == null || Objects.equals(dto.getEmployeeType(), EmployeeTypeEnum.ORGANIZATION.getValue())) { + DataCollectionEmployee simpleEmployee = simpleEmployeeMap.get(dto.getEmployeeId()); + taxDeclarationLaborListDTO.setJobNum(simpleEmployee.getWorkcode()) + .setUsername(simpleEmployee.getUsername()) + .setCardNum(Optional.ofNullable(simpleEmployee).map(DataCollectionEmployee::getIdNo).orElse(StringUtils.EMPTY)); + } else { + + } + taxDeclarationLaborListDTOS.add(taxDeclarationLaborListDTO); + } + return taxDeclarationLaborListDTOS; + } + + /** + * 转换成个税申报表详情列表(年终奖) + * + * @param taxDeclarationDetailPOS + * @param simpleEmployees + * @return + */ + public static List convert2ListDTO4Annual(List taxDeclarationDetailPOS, + List taxDeclarationEmployeeDTOS, + List simpleEmployees) { + if (CollectionUtils.isEmpty(taxDeclarationDetailPOS)) { + return Collections.emptyList(); + } + List taxDeclarationLaborListDTOS = Lists.newArrayListWithExpectedSize(taxDeclarationEmployeeDTOS.size()); + Map> employeeIdKeyTaxDeclarationDetailPOMap = SalaryEntityUtil.group2Map(taxDeclarationDetailPOS, + taxDeclarationDetailPO -> taxDeclarationDetailPO.getEmployeeType() + "_" + taxDeclarationDetailPO.getEmployeeId()); + Map simpleEmployeeMap = SalaryEntityUtil.convert2Map(simpleEmployees, DataCollectionEmployee::getEmployeeId); + for (TaxDeclarationEmployeeDTO dto : taxDeclarationEmployeeDTOS) { + Map fieldCodeKeyFieldValueMap = SalaryEntityUtil.convert2Map(employeeIdKeyTaxDeclarationDetailPOMap.get(dto.getEmployeeType() + "_" + dto.getEmployeeId()), + TaxDeclarationDetailPO::getFieldCode, TaxDeclarationDetailPO::getFieldValue); + TaxDeclarationAnnualListDTO taxDeclarationLaborListDTO = new TaxDeclarationAnnualListDTO() + .setId(dto.getEmployeeId()) + .setEmployeeId(dto.getEmployeeId()) + .setCardType(SalaryI18nUtil.getI18nLabel(105564, "居民身份证")) + .setAnnualIncome(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.ANNUAL_INCOME)) + .setAnnualTaxFreeIncome(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.ANNUAL_TAX_FREE_INCOME)) + .setAnnualOther(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.ANNUAL_OTHER)) + .setAnnualDonateTax(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.ANNUAL_DONATE_TAX)) + .setAnnualTaxSavings(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.ANNUAL_TAX_SAVINGS)) + .setAnnualRemark(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.ANNUAL_REMARK)); + if (dto.getEmployeeType() == null || Objects.equals(dto.getEmployeeType(), EmployeeTypeEnum.ORGANIZATION.getValue())) { + DataCollectionEmployee simpleEmployee = simpleEmployeeMap.getOrDefault(dto.getEmployeeId(),new DataCollectionEmployee()); + taxDeclarationLaborListDTO.setJobNum(Util.null2String(simpleEmployee.getWorkcode())) + .setUsername(Util.null2String(simpleEmployee.getUsername())) + .setCardNum(Optional.ofNullable(simpleEmployee).map(DataCollectionEmployee::getIdNo).orElse(StringUtils.EMPTY)); + } else { + + } + taxDeclarationLaborListDTOS.add(taxDeclarationLaborListDTO); + } + return taxDeclarationLaborListDTOS; + } +} diff --git a/src/com/engine/salary/entity/taxdeclaration/bo/TaxDeclarationDetailListColumn.java b/src/com/engine/salary/entity/taxdeclaration/bo/TaxDeclarationDetailListColumn.java new file mode 100644 index 000000000..0664942dc --- /dev/null +++ b/src/com/engine/salary/entity/taxdeclaration/bo/TaxDeclarationDetailListColumn.java @@ -0,0 +1,870 @@ +package com.engine.salary.entity.taxdeclaration.bo; + +import com.cloudstore.eccom.pc.table.WeaTableColumn; +import com.engine.salary.util.JsonUtil; +import com.engine.salary.util.SalaryI18nUtil; +import com.google.common.collect.Lists; +import java.util.List; + +/** + * @description: 个税申报表明细的表头 + * @author: xiajun + * @modified By: xiajun + * @date: Created in 12/15/21 11:31 AM + * @version:v1.0 + */ +public class TaxDeclarationDetailListColumn { + + private static final String COLUMN = " [\n" + + " {\n" + + " title: '序号',\n" + + " titleLabelId: 84162,\n" + + " dataIndex: 'seq_p',\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " rowSpan : 3,\n" + + " children : [\n" + + " {\n" + + " className : \"weapp-salary-hide\",\n" + + " children : [\n" + + " {\n" + + " className : \"weapp-salary-hide\",\n" + + " children : [\n" + + " {\n" + + " title: '1',\n" + + " dataIndex: 'seq',\n" + + " }\n" + + " ]\n" + + " }\n" + + " ]\n" + + " },\n" + + " ]\n" + + " },\n" + + " {\n" + + " title: '姓名',\n" + + " titleLabelId: 85429,\n" + + " dataIndex: 'employeeName_p',\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " rowSpan : 3,\n" + + " children : [\n" + + " {\n" + + " className : \"weapp-salary-hide\",\n" + + " children : [\n" + + " {\n" + + " className : \"weapp-salary-hide\",\n" + + " children : [\n" + + " {\n" + + " title: '2',\n" + + " dataIndex: 'employeeName'\n" + + " }\n" + + " ]\n" + + " }\n" + + " ]\n" + + " },\n" + + " ]\n" + + " },\n" + + " {\n" + + " title: '身份证件类型',\n" + + " titleLabelId: 102781,\n" + + " dataIndex: 'idCardType_p',\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " rowSpan : 3,\n" + + " children : [\n" + + " {\n" + + " className : \"weapp-salary-hide\",\n" + + " children : [\n" + + " {\n" + + " className : \"weapp-salary-hide\",\n" + + " children : [\n" + + " {\n" + + " title: '3',\n" + + " dataIndex: 'idCardType'\n" + + " }\n" + + " ]\n" + + " }\n" + + " ]\n" + + " },\n" + + " ]\n" + + " },\n" + + " {\n" + + " title: '身份证件号码',\n" + + " titleLabelId: 102782,\n" + + " dataIndex: 'idCardNo_p',\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " rowSpan : 3,\n" + + " children : [\n" + + " {\n" + + " className : \"weapp-salary-hide\",\n" + + " children : [\n" + + " {\n" + + " className : \"weapp-salary-hide\",\n" + + " children : [\n" + + " {\n" + + " title: '4',\n" + + " dataIndex: 'idCardNo'\n" + + " }\n" + + " ]\n" + + " }\n" + + " ]\n" + + " },\n" + + " ]\n" + + " },\n" + + " {\n" + + " title: '纳税人识别号',\n" + + " titleLabelId: 102783,\n" + + " dataIndex: 'taxpayerIdNo_p',\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " rowSpan : 3,\n" + + " children : [\n" + + " {\n" + + " className : \"weapp-salary-hide\",\n" + + " children : [\n" + + " {\n" + + " className : \"weapp-salary-hide\",\n" + + " children : [\n" + + " {\n" + + " title: '5',\n" + + " dataIndex: 'taxpayerIdNo'\n" + + " }\n" + + " ]\n" + + " }\n" + + " ]\n" + + " },\n" + + " ]\n" + + " },\n" + + " {\n" + + " title: '是否为非居民个人',\n" + + " titleLabelId: 102785,\n" + + " dataIndex: 'isPersonal_p',\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " rowSpan : 3,\n" + + " children : [\n" + + " {\n" + + " className : \"weapp-salary-hide\",\n" + + " children : [\n" + + " {\n" + + " className : \"weapp-salary-hide\",\n" + + " children : [\n" + + " {\n" + + " title: '6',\n" + + " dataIndex: 'isPersonal'\n" + + " }\n" + + " ]\n" + + " }\n" + + " ]\n" + + " },\n" + + " ]\n" + + " },\n" + + " {\n" + + " title: '所得项目',\n" + + " titleLabelId: 102786,\n" + + " dataIndex: 'incomeType_p',\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " rowSpan : 3,\n" + + " children : [\n" + + " {\n" + + " className : \"weapp-salary-hide\",\n" + + " children : [\n" + + " {\n" + + " className : \"weapp-salary-hide\",\n" + + " children : [\n" + + " {\n" + + " title: '7',\n" + + " dataIndex: 'incomeType'\n" + + " }\n" + + " ]\n" + + " }\n" + + " ]\n" + + " },\n" + + " ]\n" + + " },\n" + + " {\n" + + " title: '本月(次)情况',\n" + + " titleLabelId: 102787,\n" + + " dataIndex: 'condition_p',\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " children : [\n" + + " {\n" + + " title: '收入额计算',\n" + + " titleLabelId: 102788,\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " dataIndex: 'income_calc_p',\n" + + " children : [\n" + + " {\n" + + " title: '收入',\n" + + " titleLabelId: 96689,\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " dataIndex: 'income_p',\n" + + " children : [\n" + + " {\n" + + " title: '8',\n" + + " dataIndex: 'income'\n" + + " },\n" + + " ]\n" + + " },\n" + + " {\n" + + " title: '费用',\n" + + " titleLabelId: 102789,\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " dataIndex: 'fee_p',\n" + + " children : [\n" + + " {\n" + + " title: '9',\n" + + " dataIndex: 'fee'\n" + + " },\n" + + " ]\n" + + " },\n" + + " {\n" + + " title: '免税收入',\n" + + " titleLabelId: 102790,\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " dataIndex: 'taxFreeIncome_p',\n" + + " children : [\n" + + " {\n" + + " title: '10',\n" + + " dataIndex: 'taxFreeIncome'\n" + + " },\n" + + " ]\n" + + " },\n" + + " ]\n" + + " },\n" + + " {\n" + + " title: '减除费用',\n" + + " titleLabelId: 102791,\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " dataIndex: 'subtraction_p',\n" + + " rowSpan : 2,\n" + + " children : [\n" + + " {\n" + + " className: \"weapp-salary-hide\",\n" + + " children : [\n" + + " {\n" + + " title: '11',\n" + + " dataIndex: 'subtraction'\n" + + " },\n" + + " ]\n" + + " },\n" + + " ]\n" + + " },\n" + + " {\n" + + " title: '专项扣除',\n" + + " titleLabelId: 85829,\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " dataIndex: 'special_deduction_p',\n" + + " children : [\n" + + " {\n" + + " title: '基本养老保险费',\n" + + " titleLabelId: 102792,\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " dataIndex: 'endowment_insurance_p',\n" + + " children : [\n" + + " {\n" + + " title: '12',\n" + + " dataIndex: 'endowmentInsurance'\n" + + " },\n" + + " ]\n" + + " },\n" + + " {\n" + + " title: '基本医疗保险费',\n" + + " titleLabelId: 102793,\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " dataIndex: 'medical_insurance_p',\n" + + " children : [\n" + + " {\n" + + " title: '13',\n" + + " dataIndex: 'medicalInsurance'\n" + + " },\n" + + " ]\n" + + " },\n" + + " {\n" + + " title: '失业保险费',\n" + + " titleLabelId: 102794,\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " dataIndex: 'unemployment_insurance_p',\n" + + " children : [\n" + + " {\n" + + " title: '14',\n" + + " dataIndex: 'unemploymentInsurance'\n" + + " },\n" + + " ]\n" + + " },\n" + + " {\n" + + " title: '住房公积金',\n" + + " titleLabelId: 102795,\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " dataIndex: 'housing_fund_p',\n" + + " children : [\n" + + " {\n" + + " title: '15',\n" + + " dataIndex: 'housingProvidentFund'\n" + + " },\n" + + " ]\n" + + " },\n" + + " ]\n" + + " },\n" + + " {\n" + + " title: '其他扣除',\n" + + " titleLabelId: 85831,\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " dataIndex: 'other_deduction_p',\n" + + " children : [\n" + + " {\n" + + " title: '年金',\n" + + " titleLabelId: 102796,\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " dataIndex: 'annuity_p',\n" + + " children : [\n" + + " {\n" + + " title: '16',\n" + + " dataIndex: 'annuity'\n" + + " },\n" + + " ]\n" + + " },\n" + + " {\n" + + " title: '商业健康保险',\n" + + " titleLabelId: 91238,\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " dataIndex: 'commercial_health_insurance_p',\n" + + " children : [\n" + + " {\n" + + " title: '17',\n" + + " dataIndex: 'commercialHealthInsurance'\n" + + " },\n" + + " ]\n" + + " },\n" + + " {\n" + + " title: '税延养老保险',\n" + + " titleLabelId: 91239,\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " dataIndex: 'tax_deferred_endowment_insurance_p',\n" + + " children : [\n" + + " {\n" + + " title: '18',\n" + + " dataIndex: 'taxDeferredEndowmentInsurance'\n" + + " },\n" + + " ]\n" + + " },\n" + + " {\n" + + " title: '财产原值',\n" + + " titleLabelId: 102797,\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " dataIndex: 'originalValueOfProperty_p',\n" + + " children : [\n" + + " {\n" + + " title: '19',\n" + + " dataIndex: 'originalValueOfProperty'\n" + + " },\n" + + " ]\n" + + " },\n" + + " {\n" + + " title: '允许扣除的税费',\n" + + " titleLabelId: 102798,\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " dataIndex: 'deductedTax_p',\n" + + " children : [\n" + + " {\n" + + " title: '20',\n" + + " dataIndex: 'deductedTax'\n" + + " },\n" + + " ]\n" + + " },\n" + + " {\n" + + " title: '其他',\n" + + " titleLabelId: 102799,\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " dataIndex: 'other_p',\n" + + " children : [\n" + + " {\n" + + " title: '21',\n" + + " dataIndex: 'other'\n" + + " },\n" + + " ]\n" + + " },\n" + + " ]\n" + + " },\n" + + " ]\n" + + " },\n" + + "\n" + + " {\n" + + " title: '累计情况(工资、薪金)',\n" + + " titleLabelId: 87521,\n" + + " dataIndex: 'cumsituation_p',\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " children : [\n" + + " {\n" + + " title: '累计收入额',\n" + + " titleLabelId: 86712,\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " dataIndex: 'addUpIncome_p',\n" + + " rowSpan : 2,\n" + + " children : [\n" + + " {\n" + + " className: \"weapp-salary-hide\",\n" + + " children : [\n" + + " {\n" + + " title: '22',\n" + + " dataIndex: 'addUpIncome'\n" + + " },\n" + + " ]\n" + + " },\n" + + " ]\n" + + " },\n" + + " {\n" + + " title: '累计减除费用',\n" + + " titleLabelId: 86711,\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " dataIndex: 'addUpSubtraction_p',\n" + + " rowSpan : 2,\n" + + " children : [\n" + + " {\n" + + " className: \"weapp-salary-hide\",\n" + + " children : [\n" + + " {\n" + + " title: '23',\n" + + " dataIndex: 'addUpSubtraction'\n" + + " },\n" + + " ]\n" + + " },\n" + + " ]\n" + + " },\n" + + " {\n" + + " title: '累计专项扣除',\n" + + " titleLabelId: 102800,\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " dataIndex: 'addUpSpecialDeduction_p',\n" + + " rowSpan : 2,\n" + + " children : [\n" + + " {\n" + + " className: \"weapp-salary-hide\",\n" + + " children : [\n" + + " {\n" + + " title: '24',\n" + + " dataIndex: 'addUpSpecialDeduction'\n" + + " },\n" + + " ]\n" + + " },\n" + + " ]\n" + + " },\n" + + "\n" + + "\n" + + " {\n" + + " title: '累计专项附加扣除',\n" + + " titleLabelId: 85380,\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " dataIndex: 'income_calc_p',\n" + + " children : [\n" + + " {\n" + + " title: '子女教育',\n" + + " titleLabelId: 102801,\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " dataIndex: 'addUpChildEducation_p',\n" + + " children : [\n" + + " {\n" + + " title: '25',\n" + + " dataIndex: 'addUpChildEducation'\n" + + " },\n" + + " ]\n" + + " },\n" + + " {\n" + + " title: '赡养老人',\n" + + " titleLabelId: 102802,\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " dataIndex: 'addUpSupportElderly_p',\n" + + " children : [\n" + + " {\n" + + " title: '26',\n" + + " dataIndex: 'addUpSupportElderly'\n" + + " },\n" + + " ]\n" + + " },\n" + + " {\n" + + " title: '住房贷款利息',\n" + + " titleLabelId: 102803,\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " dataIndex: 'addUpHousingLoanInterest_p',\n" + + " children : [\n" + + " {\n" + + " title: '27',\n" + + " dataIndex: 'addUpHousingLoanInterest'\n" + + " },\n" + + " ]\n" + + " },\n" + + " {\n" + + " title: '住房租金',\n" + + " titleLabelId: 102804,\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " dataIndex: 'addUpHousingRent_p',\n" + + " children : [\n" + + " {\n" + + " title: '28',\n" + + " dataIndex: 'addUpHousingRent'\n" + + " },\n" + + " ]\n" + + " },\n" + + " {\n" + + " title: '继续教育',\n" + + " titleLabelId: 102805,\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " dataIndex: 'addUpContinuingEducation_p',\n" + + " children : [\n" + + " {\n" + + " title: '29',\n" + + " dataIndex: 'addUpContinuingEducation'\n" + + " },\n" + + " ]\n" + + " },\n" + + " ]\n" + + " },\n" + + " {\n" + + " title: '累计其他扣除',\n" + + " titleLabelId: 90569,\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " dataIndex: 'addUpOther_p',\n" + + " rowSpan : 2,\n" + + " children : [\n" + + " {\n" + + " className: \"weapp-salary-hide\",\n" + + " children : [\n" + + " {\n" + + " title: '30',\n" + + " dataIndex: 'addUpOther'\n" + + " },\n" + + " ]\n" + + " },\n" + + " ]\n" + + " },\n" + + "\n" + + " ]\n" + + " },\n" + + "\n" + + " {\n" + + " title: '减按计税比例',\n" + + " titleLabelId: 102806,\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " dataIndex: 'lessTaxProportion_p',\n" + + " rowSpan : 3,\n" + + " children : [\n" + + " {\n" + + " className : \"weapp-salary-hide\",\n" + + " children : [\n" + + " {\n" + + " className : \"weapp-salary-hide\",\n" + + " children : [\n" + + " {\n" + + " title: '31',\n" + + " dataIndex: 'lessTaxProportion'\n" + + " }\n" + + " ]\n" + + " }\n" + + " ]\n" + + " },\n" + + " ]\n" + + " },\n" + + "\n" + + " {\n" + + " title: '准予扣除的捐赠额',\n" + + " titleLabelId: 91240,\n" + + " dataIndex: 'allowedDonation_p',\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " rowSpan : 3,\n" + + " children : [\n" + + " {\n" + + " className : \"weapp-salary-hide\",\n" + + " children : [\n" + + " {\n" + + " className : \"weapp-salary-hide\",\n" + + " children : [\n" + + " {\n" + + " title: '32',\n" + + " dataIndex: 'allowedDonation'\n" + + " }\n" + + " ]\n" + + " }\n" + + " ]\n" + + " },\n" + + " ]\n" + + " },\n" + + "\n" + + " {\n" + + " title: '税款计算',\n" + + " titleLabelId: 102807,\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " dataIndex: 'cumsituation_p',\n" + + " children : [\n" + + " {\n" + + " title: '应纳税所得额',\n" + + " titleLabelId: 96693,\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " dataIndex: 'taxableIncome_p',\n" + + " rowSpan : 2,\n" + + " children : [\n" + + " {\n" + + " className: \"weapp-salary-hide\",\n" + + " children : [\n" + + " {\n" + + " title: '33',\n" + + " dataIndex: 'taxableIncome'\n" + + " },\n" + + " ]\n" + + " },\n" + + " ]\n" + + " },\n" + + " {\n" + + " title: '税率/预扣率',\n" + + " titleLabelId: 102808,\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " dataIndex: 'taxRate_p',\n" + + " rowSpan : 2,\n" + + " children : [\n" + + " {\n" + + " className: \"weapp-salary-hide\",\n" + + " children : [\n" + + " {\n" + + " title: '34',\n" + + " dataIndex: 'taxRate'\n" + + " },\n" + + " ]\n" + + " },\n" + + " ]\n" + + " },\n" + + " {\n" + + " title: '速算扣除数',\n" + + " titleLabelId: 84228,\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " dataIndex: 'quickDeductionFactor_p',\n" + + " rowSpan : 2,\n" + + " children : [\n" + + " {\n" + + " className: \"weapp-salary-hide\",\n" + + " children : [\n" + + " {\n" + + " title: '35',\n" + + " dataIndex: 'quickDeductionFactor'\n" + + " },\n" + + " ]\n" + + " },\n" + + " ]\n" + + " },\n" + + " {\n" + + " title: '应纳税额',\n" + + " titleLabelId: 102809,\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " dataIndex: 'taxPayable_p',\n" + + " rowSpan : 2,\n" + + " children : [\n" + + " {\n" + + " className: \"weapp-salary-hide\",\n" + + " children : [\n" + + " {\n" + + " title: '36',\n" + + " dataIndex: 'taxPayable'\n" + + " },\n" + + " ]\n" + + " },\n" + + " ]\n" + + " },\n" + + " {\n" + + " title: '减免税额',\n" + + " titleLabelId: 102810,\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " dataIndex: 'taxSavings_p',\n" + + " rowSpan : 2,\n" + + " children : [\n" + + " {\n" + + " className: \"weapp-salary-hide\",\n" + + " children : [\n" + + " {\n" + + " title: '37',\n" + + " dataIndex: 'taxSavings'\n" + + " },\n" + + " ]\n" + + " },\n" + + " ]\n" + + " },\n" + + " {\n" + + " title: '已扣缴税额',\n" + + " titleLabelId: 102811,\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " dataIndex: 'taxWithheld_p',\n" + + " rowSpan : 2,\n" + + " children : [\n" + + " {\n" + + " className: \"weapp-salary-hide\",\n" + + " children : [\n" + + " {\n" + + " title: '38',\n" + + " dataIndex: 'taxWithheld'\n" + + " },\n" + + " ]\n" + + " },\n" + + " ]\n" + + " },\n" + + " {\n" + + " title: '应补(退)税额',\n" + + " titleLabelId: 102812,\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " dataIndex: 'refundedOrSupplementedTax_p',\n" + + " rowSpan : 2,\n" + + " children : [\n" + + " {\n" + + " className: \"weapp-salary-hide\",\n" + + " children : [\n" + + " {\n" + + " title: '39',\n" + + " dataIndex: 'refundedOrSupplementedTax'\n" + + " },\n" + + " ]\n" + + " },\n" + + " ]\n" + + " },\n" + + " ]\n" + + " },\n" + + "\n" + + "\n" + + " {\n" + + " title: '备注',\n" + + " titleLabelId: 84961,\n" + + " ellipsis : false,\n" + + " newLine : true,\n" + + " dataIndex: 'description_p',\n" + + " rowSpan : 3,\n" + + " children : [\n" + + " {\n" + + " className : \"weapp-salary-hide\",\n" + + " children : [\n" + + " {\n" + + " className : \"weapp-salary-hide\",\n" + + " children : [\n" + + " {\n" + + " title: '40',\n" + + " dataIndex: 'description'\n" + + " }\n" + + " ]\n" + + " }\n" + + " ]\n" + + " },\n" + + " ]\n" + + " },\n" + + " ]"; + + /** + * 个税申报表导出的表头 + * + * @return + */ + public static String[] listHeader() { + return new String[]{ + SalaryI18nUtil.getI18nLabel(84162, "序号"), + SalaryI18nUtil.getI18nLabel(85429, "姓名"), + SalaryI18nUtil.getI18nLabel(102781, "身份证件类型"), + SalaryI18nUtil.getI18nLabel(102782, "身份证件号码"), + SalaryI18nUtil.getI18nLabel(102783, "纳税人识别号"), + SalaryI18nUtil.getI18nLabel(102785, "是否为非居民个人"), + SalaryI18nUtil.getI18nLabel(102786, "所得项目"), + SalaryI18nUtil.getI18nLabel(96689, "收入"), + SalaryI18nUtil.getI18nLabel(102789, "费用"), + SalaryI18nUtil.getI18nLabel(102790, "免税收入"), + SalaryI18nUtil.getI18nLabel(102791, "减除费用"), + SalaryI18nUtil.getI18nLabel(102792, "基本养老保险费"), + SalaryI18nUtil.getI18nLabel(102793, "基本医疗保险费"), + SalaryI18nUtil.getI18nLabel(102794, "失业保险费"), + SalaryI18nUtil.getI18nLabel(102795, "住房公积金"), + SalaryI18nUtil.getI18nLabel(102796, "年金"), + SalaryI18nUtil.getI18nLabel(91238, "商业健康保险"), + SalaryI18nUtil.getI18nLabel(91239, "税延养老保险"), + SalaryI18nUtil.getI18nLabel(102797, "财产原值"), + SalaryI18nUtil.getI18nLabel(102798, "允许扣除的税费"), + SalaryI18nUtil.getI18nLabel(102799, "其他"), + SalaryI18nUtil.getI18nLabel(86712, "累计收入额"), + SalaryI18nUtil.getI18nLabel(86711, "累计减除费用"), + SalaryI18nUtil.getI18nLabel(102800, "累计专项扣除"), + SalaryI18nUtil.getI18nLabel(102801, "子女教育"), + SalaryI18nUtil.getI18nLabel(102802, "赡养老人"), + SalaryI18nUtil.getI18nLabel(102803, "住房贷款利息"), + SalaryI18nUtil.getI18nLabel(102804, "住房租金"), + SalaryI18nUtil.getI18nLabel(102805, "继续教育"), + SalaryI18nUtil.getI18nLabel(90569, "累计其他扣除"), + SalaryI18nUtil.getI18nLabel(102806, "减按计税比例"), + SalaryI18nUtil.getI18nLabel(91240, "准予扣除的捐赠额"), + SalaryI18nUtil.getI18nLabel(96693, "应纳税所得额"), + SalaryI18nUtil.getI18nLabel(102808, "税率/预扣率"), + SalaryI18nUtil.getI18nLabel(84228, "速算扣除数"), + SalaryI18nUtil.getI18nLabel(102809, "应纳税额"), + SalaryI18nUtil.getI18nLabel(102810, "减免税额"), + SalaryI18nUtil.getI18nLabel(102811, "已扣缴税额"), + SalaryI18nUtil.getI18nLabel(102812, "应补(退)税额"), + SalaryI18nUtil.getI18nLabel(84961, "备注")}; + } + + /** + * 解析个税申报表的标头 + * + * @return + */ + public static List listTableColumn() { + List weaTableColumns = Lists.newArrayList(JsonUtil.parseList(TaxDeclarationDetailListColumn.COLUMN, WeaTableColumn.class)); +// for (WeaTableColumn weaTableColumn : weaTableColumns) { +// buildTitle(weaTableColumn); +// } + return weaTableColumns; + } + + /** + * 个税申报表表头多语言 + * + * @param weaTableColumn + */ +// private static void buildTitle(WeaTableColumn weaTableColumn) { +// weaTableColumn.setTitle(SalaryI18nUtil.getI18nLabel(weaTableColumn.getTitleLabelId(), weaTableColumn.getTitle())); +// if (CollectionUtils.isNotEmpty(weaTableColumn.getChildren())) { +// for (WeaTableColumnWapper weaTableColumnWapper : weaTableColumn.getChildren()) { +// buildTitle(weaTableColumnWapper); +// } +// } +// } +} diff --git a/src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationAnnualListDTO.java b/src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationAnnualListDTO.java new file mode 100644 index 000000000..696a3f9f7 --- /dev/null +++ b/src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationAnnualListDTO.java @@ -0,0 +1,100 @@ +package com.engine.salary.entity.taxdeclaration.dto; + +import com.engine.salary.annotation.SalaryTableColumn; +import com.engine.salary.annotation.TableTitle; +import com.engine.salary.util.excel.ExcelHead; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 个税申报表详情列表(劳务报酬所得) + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Accessors(chain = true) +public class TaxDeclarationAnnualListDTO { + + //主键id + @JsonSerialize(using = ToStringSerializer.class) + private Long id; + + //人员id + @JsonSerialize(using = ToStringSerializer.class) + private Long employeeId; + + @SalaryTableColumn( + text = "工号", width = "10%", column = "jobNum" + ) + @TableTitle(title ="工号",dataIndex = "jobNum",key = "jobNum") + @ExcelHead(title ="工号",dataIndex = "jobNum") + private String jobNum; + + @SalaryTableColumn( + text = "姓名", width = "10%", column = "username" + ) + @TableTitle(title ="姓名",dataIndex = "username",key = "username") + @ExcelHead(title ="姓名",dataIndex = "username") + private String username; + + @SalaryTableColumn( + text = "证件类型", width = "10%", column = "cardType" + ) + @TableTitle(title ="证件类型",dataIndex = "cardType",key = "cardType") + @ExcelHead(title ="证件类型",dataIndex = "cardType") + private String cardType; + + @SalaryTableColumn( + text = "证件号码", width = "10%", column = "cardNum" + ) + @TableTitle(title ="证件号码",dataIndex = "cardNum",key = "cardNum") + @ExcelHead(title ="证件号码",dataIndex = "cardNum") + private String cardNum; + + @SalaryTableColumn( + text = "全年一次性奖金额", width = "10%", column = "annualIncome" + ) + @TableTitle(title ="全年一次性奖金额",dataIndex = "annualIncome",key = "annualIncome") + @ExcelHead(title ="全年一次性奖金额",dataIndex = "annualIncome") + private String annualIncome; + + @SalaryTableColumn( + text = "免税收入", width = "10%", column = "annualTaxFreeIncome" + ) + @TableTitle(title ="免税收入",dataIndex = "annualTaxFreeIncome",key = "annualTaxFreeIncome") + @ExcelHead(title ="免税收入",dataIndex = "annualTaxFreeIncome") + private String annualTaxFreeIncome; + + @SalaryTableColumn( + text = "其他", width = "10%", column = "annualOther" + ) + @TableTitle(title ="其他",dataIndex = "annualOther",key = "annualOther") + @ExcelHead(title ="其他",dataIndex = "annualOther") + private String annualOther; + + @SalaryTableColumn( + text = "准予扣除的捐赠额", width = "10%", column = "annualDonateTax" + ) + @TableTitle(title ="准予扣除的捐赠额",dataIndex = "annualDonateTax",key = "annualDonateTax") + @ExcelHead(title ="准予扣除的捐赠额",dataIndex = "annualDonateTax") + private String annualDonateTax; + + @SalaryTableColumn( + text = "减免税额", width = "10%", column = "annualTaxSavings" + ) + @TableTitle(title ="减免税额",dataIndex = "annualTaxSavings",key = "annualTaxSavings") + @ExcelHead(title ="减免税额",dataIndex = "annualTaxSavings") + private String annualTaxSavings; + + @SalaryTableColumn( + text = "备注", width = "10%", column = "annualRemark" + ) + @TableTitle(title ="备注",dataIndex = "annualRemark",key = "annualRemark") + @ExcelHead(title ="备注",dataIndex = "annualRemark") + private String annualRemark; +} diff --git a/src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationDetailListDTO.java b/src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationDetailListDTO.java new file mode 100644 index 000000000..9f690c6c1 --- /dev/null +++ b/src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationDetailListDTO.java @@ -0,0 +1,275 @@ +package com.engine.salary.entity.taxdeclaration.dto; + +import com.engine.salary.annotation.TableTitle; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @description: 个税申报表详情列表 + * @author: xiajun + * @modified By: xiajun + * @date: Created in 12/15/21 10:31 AM + * @version:v1.0 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class TaxDeclarationDetailListDTO { + + /** + * 主键id + */ + private Long id; + + /** + * 个税申报记录id + */ + private Long taxDeclarationId; + + /** + * 序号 + */ + private Integer seq; + + /** + * 人员id + */ + private Long employeeId; + + /** + * 姓名 + */ + @TableTitle(title = "姓名", dataIndex = "employeeName", key = "employeeName") + private String employeeName; + + /** + * 身份证件类型 + */ + @TableTitle(title = "身份证件类型", dataIndex = "idCardType", key = "idCardType") + private String idCardType; + + /** + * 身份证件号码 + */ + @TableTitle(title = "身份证件号码", dataIndex = "idCardNo", key = "idCardNo") + private String idCardNo; + + /** + * 纳税人识别号 + */ + @TableTitle(title = "纳税人识别号", dataIndex = "taxpayerIdNo", key = "taxpayerIdNo") + private String taxpayerIdNo; + + /** + * 是居民还是非居民 + */ + @TableTitle(title = "是居民还是非居民", dataIndex = "residentType", key = "residentType") + private String residentType; + + /** + * 所得项目 + */ + @TableTitle(title = "所得项目", dataIndex = "incomeType", key = "incomeType") + private String incomeType; + + /** + * 收入 + */ + @TableTitle(title = "收入", dataIndex = "income", key = "income") + private String income; + + /** + * 费用 + */ + @TableTitle(title = "费用", dataIndex = "fee", key = "fee") + private String fee; + + /** + * 免税收入 + */ + @TableTitle(title = "免税收入", dataIndex = "taxFreeIncome", key = "taxFreeIncome") + private String taxFreeIncome; + + /** + * 减除费用 + */ + @TableTitle(title = "减除费用", dataIndex = "subtraction", key = "subtraction") + private String subtraction; + + /** + * 养老保险 + */ + @TableTitle(title = "养老保险", dataIndex = "endowmentInsurance", key = "endowmentInsurance") + private String endowmentInsurance; + + /** + * 医疗保险 + */ + @TableTitle(title = "医疗保险", dataIndex = "medicalInsurance", key = "medicalInsurance") + private String medicalInsurance; + + /** + * 失业保险 + */ + @TableTitle(title = "失业保险", dataIndex = "unemploymentInsurance", key = "unemploymentInsurance") + private String unemploymentInsurance; + + /** + * 住房公积金 + */ + @TableTitle(title = "住房公积金", dataIndex = "housingProvidentFund", key = "housingProvidentFund") + private String housingProvidentFund; + + /** + * 年金 + */ + @TableTitle(title = "年金", dataIndex = "annuity", key = "annuity") + private String annuity; + + /** + * 商业健康保险 + */ + @TableTitle(title = "商业健康保险", dataIndex = "commercialHealthInsurance", key = "commercialHealthInsurance") + private String commercialHealthInsurance; + + /** + * 税延养老保险 + */ + @TableTitle(title = "税延养老保险", dataIndex = "taxDeferredEndowmentInsurance", key = "taxDeferredEndowmentInsurance") + private String taxDeferredEndowmentInsurance; + + /** + * 财产原值 + */ + @TableTitle(title = "财产原值", dataIndex = "originalValueOfProperty", key = "originalValueOfProperty") + private String originalValueOfProperty; + + /** + * 允许扣除的税费 + */ + @TableTitle(title = "允许扣除的税费", dataIndex = "deductedTax", key = "deductedTax") + private String deductedTax; + + /** + * 其他 + */ + @TableTitle(title = "其他", dataIndex = "other", key = "other") + private String other; + + /** + * 累计收入额 + */ + @TableTitle(title = "累计收入额", dataIndex = "addUpIncome", key = "addUpIncome") + private String addUpIncome; + + /** + * 累计减除费用 + */ + @TableTitle(title = "累计减除费用", dataIndex = "addUpSubtraction", key = "addUpSubtraction") + private String addUpSubtraction; + + /** + * 累计专项扣除 + */ + @TableTitle(title = "累计专项扣除", dataIndex = "addUpSpecialDeduction", key = "addUpSpecialDeduction") + private String addUpSpecialDeduction; + + /** + * 累计子女教育 + */ + @TableTitle(title = "累计子女教育", dataIndex = "addUpChildEducation", key = "addUpChildEducation") + private String addUpChildEducation; + + /** + * 累计继续教育 + */ + @TableTitle(title = "累计继续教育", dataIndex = "addUpContinuingEducation", key = "addUpContinuingEducation") + private String addUpContinuingEducation; + + /** + * 累计住房贷款利息 + */ + @TableTitle(title = "累计住房贷款利息", dataIndex = "addUpHousingLoanInterest", key = "addUpHousingLoanInterest") + private String addUpHousingLoanInterest; + + /** + * 累计住房租金 + */ + @TableTitle(title = "累计住房租金", dataIndex = "addUpHousingRent", key = "addUpHousingRent") + private String addUpHousingRent; + + /** + * 累计赡养老人 + */ + @TableTitle(title = "累计赡养老人", dataIndex = "addUpSupportElderly", key = "addUpSupportElderly") + private String addUpSupportElderly; + + /** + * 累计其他扣除 + */ + @TableTitle(title = "累计其他扣除", dataIndex = "addUpOther", key = "addUpOther") + private String addUpOther; + + /** + * 减按计税比例 + */ + @TableTitle(title = "减按计税比例", dataIndex = "lessTaxProportion", key = "lessTaxProportion") + private String lessTaxProportion; + + /** + * 准允扣除的捐赠额 + */ + @TableTitle(title = "准允扣除的捐赠额", dataIndex = "allowedDonation", key = "allowedDonation") + private String allowedDonation; + + /** + * 应纳税所得额 + */ + @TableTitle(title = "应纳税所得额", dataIndex = "taxableIncome", key = "taxableIncome") + private String taxableIncome; + + /** + * 税率 + */ + @TableTitle(title = "税率", dataIndex = "taxRate", key = "taxRate") + private String taxRate; + + /** + * 速算扣除数 + */ + @TableTitle(title = "速算扣除数", dataIndex = "quickDeductionFactor", key = "quickDeductionFactor") + private String quickDeductionFactor; + + /** + * 应纳税款 + */ + @TableTitle(title = "应纳税款", dataIndex = "taxPayable", key = "taxPayable") + private String taxPayable; + + /** + * 减免税额 + */ + @TableTitle(title = "减免税额", dataIndex = "taxSavings", key = "taxSavings") + private String taxSavings; + + /** + * 已扣缴税额 + */ + @TableTitle(title = "已扣缴税额", dataIndex = "taxWithheld", key = "taxWithheld") + private String taxWithheld; + + /** + * 应补(退)税额 + */ + @TableTitle(title = "应补(退)税额", dataIndex = "refundedOrSupplementedTax", key = "refundedOrSupplementedTax") + private String refundedOrSupplementedTax; + + /** + * 备注 + */ + @TableTitle(title = "备注", dataIndex = "description", key = "description") + private String description; +} diff --git a/src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationEmployeeDTO.java b/src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationEmployeeDTO.java new file mode 100644 index 000000000..10c5ec845 --- /dev/null +++ b/src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationEmployeeDTO.java @@ -0,0 +1,21 @@ +package com.engine.salary.entity.taxdeclaration.dto; + +import lombok.Data; + +/** + * 个税申报表中的人员(组织架构中的人员+外部人员) + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +public class TaxDeclarationEmployeeDTO { + + //员工类型") + private Integer employeeType; + + //人员id") + private Long employeeId; +} diff --git a/src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationFormDTO.java b/src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationFormDTO.java new file mode 100644 index 000000000..b8b120063 --- /dev/null +++ b/src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationFormDTO.java @@ -0,0 +1,33 @@ +package com.engine.salary.entity.taxdeclaration.dto; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.time.YearMonth; + +/** + * @description: 个税申报记录表单 + * @author: xiajun + * @modified By: xiajun + * @date: Created in 12/15/21 9:40 AM + * @version:v1.0 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class TaxDeclarationFormDTO { + + //薪资所属月") + private YearMonth salaryMonth; + + //个税扣缴义务人id") + private Long taxAgentId; + + //个税扣缴义务人名称") + private String taxAgentName; + + //备注") + private String description; +} diff --git a/src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationInfoDTO.java b/src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationInfoDTO.java new file mode 100644 index 000000000..11900c619 --- /dev/null +++ b/src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationInfoDTO.java @@ -0,0 +1,34 @@ +package com.engine.salary.entity.taxdeclaration.dto; + +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.time.YearMonth; + +/** + * @description: 个税申报表信息 + * @author: xiajun + * @modified By: xiajun + * @date: Created in 12/16/21 3:22 PM + * @version:v1.0 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class TaxDeclarationInfoDTO { + + //薪资所属月") + @JsonSerialize(using = ToStringSerializer.class) + private YearMonth salaryMonth; + + //个税扣缴义务人id") + private Long taxAgentId; + + //个税扣缴义务人名称") + private String taxAgentName; +} diff --git a/src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationLaborListDTO.java b/src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationLaborListDTO.java new file mode 100644 index 000000000..ce03fd52c --- /dev/null +++ b/src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationLaborListDTO.java @@ -0,0 +1,121 @@ +package com.engine.salary.entity.taxdeclaration.dto; + +import com.engine.salary.annotation.SalaryTableColumn; +import com.engine.salary.annotation.TableTitle; +import com.engine.salary.util.excel.ExcelHead; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 个税申报表详情列表(劳务报酬所得) + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Accessors(chain = true) +public class TaxDeclarationLaborListDTO { + + //主键id + @JsonSerialize(using = ToStringSerializer.class) + private Long id; + + //人员id + @JsonSerialize(using = ToStringSerializer.class) + private Long employeeId; + + @SalaryTableColumn( + text = "工号", width = "10%", column = "jobNum" + ) + @TableTitle(title = "工号", dataIndex = "jobNum", key = "jobNum") + @ExcelHead(title = "工号", dataIndex = "jobNum") + private String jobNum; + + @SalaryTableColumn( + text = "姓名", width = "10%", column = "username" + ) + @TableTitle(title = "姓名", dataIndex = "username", key = "username") + @ExcelHead(title = "姓名", dataIndex = "username") + private String username; + + @SalaryTableColumn( + text = "证件类型", width = "10%", column = "cardType" + ) + @TableTitle(title = "证件类型", dataIndex = "cardType", key = "cardType") + @ExcelHead(title = "证件类型", dataIndex = "cardType") + private String cardType; + + @SalaryTableColumn( + text = "证件号码", width = "10%", column = "cardNum" + ) + @TableTitle(title = "证件号码", dataIndex = "cardNum", key = "cardNum") + @ExcelHead(title = "证件号码", dataIndex = "cardNum") + private String cardNum; + + @SalaryTableColumn( + text = "所得项目", width = "10%", column = "incomeItems" + ) + @TableTitle(title = "所得项目", dataIndex = "incomeItems", key = "incomeItems") + @ExcelHead(title = "所得项目", dataIndex = "incomeItems") + private String incomeItems; + + @SalaryTableColumn( + text = "劳务收入", width = "10%", column = "laborIncome" + ) + @TableTitle(title = "劳务收入", dataIndex = "laborIncome", key = "laborIncome") + @ExcelHead(title = "劳务收入", dataIndex = "laborIncome") + private String laborIncome; + + @SalaryTableColumn( + text = "劳务免税收入", width = "10%", column = "laborTaxFreeIncome" + ) + @TableTitle(title = "劳务免税收入", dataIndex = "laborTaxFreeIncome", key = "laborTaxFreeIncome") + @ExcelHead(title = "劳务免税收入", dataIndex = "laborTaxFreeIncome") + private String laborTaxFreeIncome; + + @SalaryTableColumn( + text = "商业健康保险", width = "10%", column = "commercialHealthInsurance" + ) + @TableTitle(title = "商业健康保险", dataIndex = "commercialHealthInsurance", key = "commercialHealthInsurance") + @ExcelHead(title = "商业健康保险", dataIndex = "commercialHealthInsurance") + private String commercialHealthInsurance; + + @SalaryTableColumn( + text = "税延养老保险", width = "10%", column = "taxDeferredEndowmentInsurance" + ) + @TableTitle(title = "税延养老保险", dataIndex = "taxDeferredEndowmentInsurance", key = "taxDeferredEndowmentInsurance") + @ExcelHead(title = "税延养老保险", dataIndex = "taxDeferredEndowmentInsurance") + private String taxDeferredEndowmentInsurance; + + @SalaryTableColumn( + text = "其他", width = "10%", column = "other" + ) + @TableTitle(title = "其他", dataIndex = "other", key = "other") + @ExcelHead(title = "其他", dataIndex = "other") + private String other; + + @SalaryTableColumn( + text = "准予扣除的捐赠额", width = "10%", column = "allowedDonation" + ) + @TableTitle(title = "准予扣除的捐赠额", dataIndex = "allowedDonation", key = "allowedDonation") + @ExcelHead(title = "准予扣除的捐赠额", dataIndex = "allowedDonation") + private String allowedDonation; + + @SalaryTableColumn( + text = "减免税额", width = "10%", column = "taxDeduction" + ) + @TableTitle(title = "减免税额", dataIndex = "taxDeduction", key = "taxDeduction") + @ExcelHead(title = "减免税额", dataIndex = "taxDeduction") + private String taxDeduction; + + @SalaryTableColumn( + text = "备注", width = "10%", column = "description" + ) + @TableTitle(title = "备注", dataIndex = "description", key = "description") + @ExcelHead(title = "备注", dataIndex = "description") + private String description; +} diff --git a/src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationListDTO.java b/src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationListDTO.java new file mode 100644 index 000000000..5104871b5 --- /dev/null +++ b/src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationListDTO.java @@ -0,0 +1,70 @@ +package com.engine.salary.entity.taxdeclaration.dto; + +import com.cloudstore.eccom.pc.table.WeaTableType; +import com.engine.salary.annotation.SalaryTable; +import com.engine.salary.annotation.SalaryTableOperate; +import com.engine.salary.annotation.TableTitle; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; +import java.util.Set; + +/** + * 个税申报记录列表 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@SalaryTable(pageId = "a4f85287-e3f9-4275-adn9-7d06e54y6rj8", tableType = WeaTableType.CHECKBOX, operates = { + @SalaryTableOperate(text = "查看") +}) +public class TaxDeclarationListDTO { + + @JsonSerialize(using = ToStringSerializer.class) + private Long id; + + @TableTitle(title = "薪资类型", dataIndex = "incomeCategory", key = "incomeCategory") + private String incomeCategory; + + @JsonFormat(pattern = "yyyy-MM", timezone = "GMT+8") + @TableTitle(title = "薪资所属月", dataIndex = "salaryMonth", key = "salaryMonth") + private Date salaryMonth; + + //@TableTitle(title = "个税扣缴义务人", dataIndex = "taxAgentId", key = "taxAgentId") + private Long taxAgentId; + + @TableTitle(title = "个税扣缴义务人", dataIndex = "taxAgentName", key = "taxAgentName") + private String taxAgentName; + + @JsonFormat(pattern = "yyyy-MM", timezone = "GMT+8") + @TableTitle(title = "税款所属期", dataIndex = "taxCycle", key = "taxCycle") + private Date taxCycle; + + //@TableTitle(title = "操作人id", dataIndex = "operateEmployeeId", key = "operateEmployeeId") + private Long operateEmployeeId; + + @TableTitle(title = "操作人", dataIndex = "operateEmployeeName", key = "operateEmployeeName") + private String operateEmployeeName; + + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") + @TableTitle(title = "操作时间", dataIndex = "operateTime", key = "operateTime") + private String operateTime; + + @TableTitle(title = "备注", dataIndex = "description", key = "description") + private String description; + + private Set opts; + +} diff --git a/src/com/engine/salary/entity/taxdeclaration/param/TaxDeclarationDetailListQueryParam.java b/src/com/engine/salary/entity/taxdeclaration/param/TaxDeclarationDetailListQueryParam.java new file mode 100644 index 000000000..e2e32c347 --- /dev/null +++ b/src/com/engine/salary/entity/taxdeclaration/param/TaxDeclarationDetailListQueryParam.java @@ -0,0 +1,29 @@ +package com.engine.salary.entity.taxdeclaration.param; + +import com.engine.salary.common.BaseQueryParam; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +/** + * 个税申报记录详情列表查询参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@Accessors(chain = true) +@NoArgsConstructor +@AllArgsConstructor +public class TaxDeclarationDetailListQueryParam extends BaseQueryParam { + + //"个税申报记录id") + private Long taxDeclarationId; + + private String taxDeclarationIdStr; +} diff --git a/src/com/engine/salary/entity/taxdeclaration/param/TaxDeclarationListQueryParam.java b/src/com/engine/salary/entity/taxdeclaration/param/TaxDeclarationListQueryParam.java new file mode 100644 index 000000000..521fadd56 --- /dev/null +++ b/src/com/engine/salary/entity/taxdeclaration/param/TaxDeclarationListQueryParam.java @@ -0,0 +1,31 @@ +package com.engine.salary.entity.taxdeclaration.param; + +import com.engine.salary.common.BaseQueryParam; +import lombok.*; + +import java.time.YearMonth; + +/** + * 个税申报记录查询条件 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class TaxDeclarationListQueryParam extends BaseQueryParam { + + //薪资所属月范围起点 + private YearMonth fromSalaryMonth; + + //薪资所属月范围终点 + private YearMonth endSalaryMonth; + + private String fromSalaryMonthStr; + + private String endSalaryMonthStr; +} diff --git a/src/com/engine/salary/entity/taxdeclaration/param/TaxDeclarationSaveParam.java b/src/com/engine/salary/entity/taxdeclaration/param/TaxDeclarationSaveParam.java new file mode 100644 index 000000000..8fffb93cc --- /dev/null +++ b/src/com/engine/salary/entity/taxdeclaration/param/TaxDeclarationSaveParam.java @@ -0,0 +1,53 @@ +package com.engine.salary.entity.taxdeclaration.param; + +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.time.YearMonth; +import java.util.Date; + +/** + * 生成个税申报表参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class TaxDeclarationSaveParam { + + /** + * 个税申报id + */ + private Long taxDeclarationId; + + /** + * 薪资所属月 + */ + private YearMonth salaryMonth; + + /** + * 个税扣缴义务人 + */ + private Long taxAgentId; + + /** + * 备注 + */ + private String description; + + private String salaryMonthStr; + + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") + private Date taxCycle; + + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") + private Date salaryDate; +} diff --git a/src/com/engine/salary/entity/taxdeclaration/po/TaxDeclarationDetailPO.java b/src/com/engine/salary/entity/taxdeclaration/po/TaxDeclarationDetailPO.java new file mode 100644 index 000000000..e7c4e49b2 --- /dev/null +++ b/src/com/engine/salary/entity/taxdeclaration/po/TaxDeclarationDetailPO.java @@ -0,0 +1,90 @@ +package com.engine.salary.entity.taxdeclaration.po; + +import com.engine.salary.annotation.Encrypt; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; + +/** + * 个税申报表详情 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//hrsa_tax_declaration_detail +public class TaxDeclarationDetailPO { + + /** + * 主键id + */ + private Long id; + + /** + * 个税申报记录id + */ + private Long taxDeclarationId; + + /** + * 人员id + */ + private Long employeeId; + + /** + * 人员类型 + */ + private Integer employeeType; + + /** + * 申报表字段code + */ + private String fieldCode; + + /** + * 申报表字段的值 + */ + @Encrypt + private String fieldValue; + + + /** + * 租户key + */ + private String tenantKey; + + /** + * 创建人id + */ + private Long creator; + + /** + * 是否删除 + */ + private Integer deleteType; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 更新时间 + */ + private Date updateTime; + + + + +// /** +// * 应税项目。1:正常工资薪金所得 +// */ +// private Integer incomeCategory; +} diff --git a/src/com/engine/salary/entity/taxdeclaration/po/TaxDeclarationPO.java b/src/com/engine/salary/entity/taxdeclaration/po/TaxDeclarationPO.java new file mode 100644 index 000000000..7a02a14d2 --- /dev/null +++ b/src/com/engine/salary/entity/taxdeclaration/po/TaxDeclarationPO.java @@ -0,0 +1,96 @@ +package com.engine.salary.entity.taxdeclaration.po; + +import com.engine.salary.annotation.Auth; +import com.engine.salary.common.LocalDateRange; +import com.engine.salary.enums.auth.AuthCheckTypeEnum; +import com.engine.salary.enums.salarysob.IncomeCategoryEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.Date; +import java.util.Set; + +/** + * 个税申报记录 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//hrsa_tax_declaration +@Auth(page = "taxDeclaration",checkType = AuthCheckTypeEnum.TAX) +public class TaxDeclarationPO { + + /** + * 主键id + */ + private Long id; + + /** + * 薪资所属月 + */ + private Date salaryMonth; + + /** + * 税款所属期 + */ + private Date taxCycle; + + /** + * 个税扣缴义务人id + */ + private Long taxAgentId; + + /** + * 薪资类型 + * + * @see IncomeCategoryEnum + */ + private Integer incomeCategory; + + /** + * 备注 + */ + private String description; + + /** + * 租户key + */ + private String tenantKey; + + /** + * 创建人id + */ + private Long creator; + + /** + * 是否删除 + */ + private Integer deleteType; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 更新时间 + */ + private Date updateTime; + + //税款所属期 + LocalDateRange salaryMonths; + + + + private Collection taxAgentIds; + private Set opts; +} diff --git a/src/com/engine/salary/entity/taxrate/SysTaxRateBase.java b/src/com/engine/salary/entity/taxrate/SysTaxRateBase.java new file mode 100644 index 000000000..e62c2b758 --- /dev/null +++ b/src/com/engine/salary/entity/taxrate/SysTaxRateBase.java @@ -0,0 +1,58 @@ +package com.engine.salary.entity.taxrate; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.Date; + +/** + * 系统内置的税率表 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SysTaxRateBase { + /** + * 创建时间 + */ + private Date createTime; + /** + * 创建人 + */ + private Long creator; + /** + * 是否已删除。0:未删除、1:已删除 + */ + private Integer deleteType; + /** + * 描述 + */ + private String description; + /** + * 主键 + */ + private Long id; + /** + * 名称 + */ + private String name; + /** + * 是否是系统默认的。0:自定义、1:系统默认 + */ + private Integer systemType; + /** + * 租户ID + */ + private String tenantKey; + /** + * 更新时间 + */ + private Date updateTime; + + private Collection ids; + +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/taxrate/SysTaxRateDetailPO.java b/src/com/engine/salary/entity/taxrate/SysTaxRateDetailPO.java new file mode 100644 index 000000000..dbff1f4b3 --- /dev/null +++ b/src/com/engine/salary/entity/taxrate/SysTaxRateDetailPO.java @@ -0,0 +1,109 @@ +package com.engine.salary.entity.taxrate; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.math.BigDecimal; +import java.util.Collection; +import java.util.Date; + +/** + * 系统默认的税率表明细 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//hrsa_sys_tax_rate_detail +public class SysTaxRateDetailPO { + + /** + * 主键id + */ + private Long id; + + /** + * 税率主表的id + */ + private Long baseId; + + /** + * 序号 + */ + private Integer indexNum; + + /** + * 收入上限(含) + */ + private BigDecimal incomeUpperLimit; + + /** + * 收入下限(不含) + */ + private BigDecimal incomeLowerLimit; + + /** + * 免税标准-固定值 + */ + private BigDecimal dutyFreeValue; + + /** + * 免税标准-比例 + */ + private BigDecimal dutyFreeRate; + + /** + * 应纳税所得额上限(含) + */ + private BigDecimal taxableIncomeULimit; + + /** + * 应纳税所得额下限(不含) + */ + private BigDecimal taxableIncomeLLimit; + + /** + * 税率 + */ + private BigDecimal taxRate; + + /** + * 速算扣除数 + */ + private BigDecimal taxDeduction; + + /** + * 租户key + */ + private String tenantKey; + + /** + * 创建人id + */ + private Long creator; + + /** + * 是否删除 + */ + private Integer deleteType; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 更新时间 + */ + private Date updateTime; + + //条件 + Collection ids; +} diff --git a/src/com/engine/salary/entity/taxrate/TaxAgent.java b/src/com/engine/salary/entity/taxrate/TaxAgent.java new file mode 100644 index 000000000..f7b6850a3 --- /dev/null +++ b/src/com/engine/salary/entity/taxrate/TaxAgent.java @@ -0,0 +1,73 @@ +package com.engine.salary.entity.taxrate; + +import java.time.LocalDateTime; +import java.util.Date; +import java.util.Map; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import static com.engine.salary.constant.SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY; + +/** + * 个税扣缴义务人表 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class TaxAgent { + /** + * 创建时间 + */ + private Date createTime; + /** + * 创建人 + */ + private Long creator; + /** + * 是否已删除。0:未删除、1:已删除 + */ + private Integer deleteType; + /** + * 描述 + */ + private String description; + /** + * 主键 + */ + private Long id; + /** + * 名称 + */ + private String name; + /** + * 租户ID + */ + private String tenantKey; + /** + * 更新时间 + */ + private Date updateTime; + + + public static TaxAgent convertToPO(Map param, Long employeeId) { + if (param == null) { + return null; + } + return TaxAgent.builder() + .id(param.get("id") == null ? null : (long) param.get("id")) + .name(param.get("name") == null ? null : (String) param.get("name")) + .description(param.get("description") == null ? null : (String) param.get("description")) + .deleteType(0) + .createTime(new Date()) + .updateTime(new Date()) + .creator(employeeId) + .tenantKey(DEFAULT_TENANT_KEY) +// .tenantKey(tenantKey) + .build(); + } + +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/taxrate/TaxRateBase.java b/src/com/engine/salary/entity/taxrate/TaxRateBase.java new file mode 100644 index 000000000..04c20ea82 --- /dev/null +++ b/src/com/engine/salary/entity/taxrate/TaxRateBase.java @@ -0,0 +1,58 @@ +package com.engine.salary.entity.taxrate; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.Date; + +/** + * 税率主表 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class TaxRateBase { + /** + * 创建时间 + */ + private Date createTime; + /** + * 创建人 + */ + private Long creator; + /** + * 是否已删除。0:未删除、1:已删除 + */ + private Integer deleteType; + /** + * 描述 + */ + private String description; + /** + * 主键 + */ + private Long id; + /** + * 名称 + */ + private String name; + /** + * 是否是系统默认的。0:自定义、1:系统默认 + */ + private Integer systemType; + /** + * 租户ID + */ + private String tenantKey; + /** + * 更新时间 + */ + private Date updateTime; + + private Collection ids; + +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/taxrate/TaxRateDetail.java b/src/com/engine/salary/entity/taxrate/TaxRateDetail.java new file mode 100644 index 000000000..a1653e996 --- /dev/null +++ b/src/com/engine/salary/entity/taxrate/TaxRateDetail.java @@ -0,0 +1,84 @@ +package com.engine.salary.entity.taxrate; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 税率明细表 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class TaxRateDetail { + /** + * 税率主表hrsa_tax_rate_base的id + */ + private Long baseId; + /** + * 创建时间 + */ + private Date createTime; + /** + * 创建人 + */ + private Long creator; + /** + * 是否已删除。0:未删除、1:已删除 + */ + private Integer deleteType; + /** + * 免税标准-比例 + */ + private BigDecimal dutyFreeRate; + /** + * 免税标准-固定值 + */ + private BigDecimal dutyFreeValue; + /** + * 主键 + */ + private Long id; + /** + * 收入下限(不含) + */ + private BigDecimal incomeLowerLimit; + /** + * 收入上限(含) + */ + private BigDecimal incomeUpperLimit; + /** + * 序号 + */ + private Integer indexNum; + /** + * 速算扣除数 + */ + private BigDecimal taxDeduction; + /** + * 税率 + */ + private BigDecimal taxRate; + /** + * 应纳税所得额下限(不含) + */ + private BigDecimal taxableIncomeLl; + /** + * 应纳税所得额上限(含) + */ + private BigDecimal taxableIncomeUl; + /** + * 租户ID + */ + private String tenantKey; + /** + * 更新时间 + */ + private Date updateTime; + +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/taxrate/bo/TaxRateBO.java b/src/com/engine/salary/entity/taxrate/bo/TaxRateBO.java new file mode 100644 index 000000000..5b9b2cbe5 --- /dev/null +++ b/src/com/engine/salary/entity/taxrate/bo/TaxRateBO.java @@ -0,0 +1,136 @@ +package com.engine.salary.entity.taxrate.bo; + +import com.engine.salary.constant.SalaryDefaultTenantConstant; +import com.engine.salary.entity.taxrate.TaxRateBase; +import com.engine.salary.entity.taxrate.TaxRateDetail; +import com.engine.salary.entity.taxrate.param.TaxRateBaseSaveParam; +import com.engine.salary.entity.taxrate.param.TaxRateDetailSaveParam; +import com.engine.salary.enums.SalarySystemTypeEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import org.apache.commons.collections4.CollectionUtils; + +import java.math.BigDecimal; +import java.util.*; +import java.util.stream.Collectors; + +/** + * 税率表业务方法 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class TaxRateBO { + + private TaxRateBO() { + throw new SalaryRunTimeException("该类不需要创建实例"); + } + + /** + * 转换成个税税率表的前端列表 + * + * @param taxRateBatches + * @return + */ +// public static List convert2ListDTO(Collection taxRateBatches) { +// if (CollectionUtils.isEmpty(taxRateBatches)) { +// return Collections.emptyList(); +// } +// return taxRateBatches.stream() +// .map(taxRateBatchPO -> { +// SalarySystemTypeEnum typeEnum = SalarySystemTypeEnum.parseByValue(taxRateBatchPO.getSystemType()); +// return TaxRateListDTO.builder() +// .id(taxRateBatchPO.getId()) +// .name(taxRateBatchPO.getName()) +// .systemType(Optional.ofNullable(typeEnum).map(e -> SalaryI18nUtil.getI18nLabel(e.getLabelId(), e.getDefaultLabel())).orElse(StringUtils.EMPTY)) +// .createTime(SalaryDateUtil.getFormatLocalDate(taxRateBatchPO.getCreateTime())) +// .description(taxRateBatchPO.getDescription()) +// .build(); +// }) +// .collect(Collectors.toList()); +// } + + /** + * 转转成个税税率表的明细 + * + * @param taxRateRecords + * @return + */ +// public static List convert2RecordDTO(Collection taxRateRecords) { +// if (CollectionUtils.isEmpty(taxRateRecords)) { +// return Collections.emptyList(); +// } +// return taxRateRecords.stream() +// .map(e -> TaxRateRecordDTO.builder() +// .id(e.getId()) +// .batchId(e.getBaseId()) +// .indexNum(e.getIndexNum()) +// .incomeUpperLimit(e.getIncomeUpperLimit()) +// .incomeLowerLimit(e.getIncomeLowerLimit()) +// .dutyFreeValue(e.getDutyFreeValue()) +// .dutyFreeRate(e.getDutyFreeRate()) +// .taxableIncomeULimit(e.getTaxableIncomeULimit()) +// .taxableIncomeLLimit(e.getTaxableIncomeLLimit()) +// .taxRate(e.getTaxRate()) +// .taxDeduction(e.getTaxDeduction()) +// .build()) +// .collect(Collectors.toList()); +// } + + /** + * 个税税率表的基本信息的保存参数转换成对应的PO实体 + * + * @param saveParam + * @param employeeId + * @return + */ + public static TaxRateBase convert2BatchPO(TaxRateBaseSaveParam saveParam, Long employeeId) { + if (saveParam == null) { + return null; + } + return TaxRateBase.builder() + .name(saveParam.getName()) + .systemType(SalarySystemTypeEnum.CUSTOM.getValue()) + .description(saveParam.getDescription()) + .createTime(new Date()) + .updateTime(new Date()) + .creator(employeeId) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .deleteType(0) + .build(); + } + + /** + * 个税税率表的明细的保存参数转换成对应的PO实体 + * + * @param saveParams + * @param employeeId + * @return + */ + public static List convert2RecordPO(Long taxRateBatchId, Collection saveParams, Long employeeId) { + if (CollectionUtils.isEmpty(saveParams)) { + return Collections.emptyList(); + } + return saveParams.stream() + .map(e -> TaxRateDetail.builder() + .baseId(taxRateBatchId) + .indexNum(e.getIndexNum()) + .incomeUpperLimit(e.getIncomeUpperLimit()) + .incomeLowerLimit(e.getIncomeLowerLimit()) + .dutyFreeValue(e.getDutyFreeValue()) + .dutyFreeRate(e.getDutyFreeRate()) + .taxableIncomeUl(Optional.ofNullable(e.getTaxableIncomeUl()).orElse(BigDecimal.ZERO)) + .taxableIncomeLl(Optional.ofNullable(e.getTaxableIncomeLl()).orElse(BigDecimal.ZERO)) + .taxRate(Optional.ofNullable(e.getTaxRate()).orElse(BigDecimal.ZERO)) + .taxDeduction(Optional.ofNullable(e.getTaxDeduction()).orElse(BigDecimal.ZERO)) + .createTime(new Date()) + .updateTime(new Date()) + .creator(employeeId) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .deleteType(0) + .build()) + .collect(Collectors.toList()); + } + +} diff --git a/src/com/engine/salary/entity/taxrate/bo/TaxRateDetailBO.java b/src/com/engine/salary/entity/taxrate/bo/TaxRateDetailBO.java new file mode 100644 index 000000000..551a927ef --- /dev/null +++ b/src/com/engine/salary/entity/taxrate/bo/TaxRateDetailBO.java @@ -0,0 +1,93 @@ +//package com.engine.salary.entity.taxrate.bo; +// +//import com.engine.salary.entity.taxrate.TaxRateDetail; +//import com.engine.salary.util.JsonUtil; +//import org.apache.commons.collections4.CollectionUtils; +//import org.apache.commons.lang3.StringUtils; +// +//import java.util.Collection; +//import java.util.List; +//import java.util.Map; +//import java.util.Objects; +// +///** +// * @description: 税率表明细 +// * @author: xiajun +// * @modified By: xiajun +// * @date: Created in 2/18/22 2:07 PM +// * @version:v1.0 +// */ +//public class TaxRateDetailBO { +// +// /** +// * 根据公式条件获取对应的税率 +// * +// * @param taxRateDetailPOS +// * @param isOr +// * @param formulaFilterDataList +// * @return +// */ +// public static TaxRateDetail filter(List taxRateDetailPOS, boolean isOr, Collection formulaFilterDataList) { +// if (CollectionUtils.isEmpty(taxRateDetailPOS)) { +// return null; +// } +// return taxRateDetailPOS.stream() +// .filter(taxRateDetailPO -> { +// for (FormulaFilterData formulaFilterData : formulaFilterDataList) { +// boolean result = filterByFormulaFilterData(taxRateDetailPO, formulaFilterData); +// // 如果公式中的条件是or,只要有一个条件为true就返回true +// if (isOr && result) { +// return true; +// } +// // 如果公式中的条件是and,只要有一个条件为false就返回false +// if (!isOr && !result) { +// return false; +// } +// } +// // 如果公式中的条件是or,前面没有一个条件为true,则返回false +// // 如果公式中的条件是and, 前面没有一个条件为false,则返回true +// return !isOr; +// }) +// .findFirst() +// .orElse(null); +// } +// +// /** +// * 根据公式条件和个税税率表的字段比对,看是否满足公式中的条件 +// * +// * @param taxRateDetailPO +// * @param formulaFilterData +// * @return +// */ +// private static boolean filterByFormulaFilterData(TaxRateDetail taxRateDetailPO, FormulaFilterData formulaFilterData) { +// Map map = JsonUtil.parseMap(taxRateDetailPO, Object.class); +// switch (formulaFilterData.getTerm()) { +// case FormulaFilterData.TERM_EQ: +// case FormulaFilterData.TERM_BEQ: +// case FormulaFilterData.TERM_SEQ: +// return Objects.equals(map.get(formulaFilterData.getFieldId()), formulaFilterData.getContent()); +// case FormulaFilterData.TERM_NOT_EQ: +// return !Objects.equals(map.get(formulaFilterData.getFieldId()), formulaFilterData.getContent()); +// case FormulaFilterData.TERM_NULL: +// return Objects.isNull(map.get(formulaFilterData.getFieldId())); +// case FormulaFilterData.TERM_NOT_NULL: +// return Objects.nonNull(map.get(formulaFilterData.getFieldId())); +// case FormulaFilterData.TERM_LIKE: +// return StringUtils.contains(String.valueOf(map.get(formulaFilterData.getFieldId())), formulaFilterData.getContent()); +// case FormulaFilterData.TERM_GT: +// return SalaryEntityUtil.empty2Zero(String.valueOf(map.get(formulaFilterData.getFieldId()))) +// .compareTo(SalaryEntityUtil.empty2Zero(formulaFilterData.getContent())) > 0; +// case FormulaFilterData.TERM_GE: +// return SalaryEntityUtil.empty2Zero(String.valueOf(map.get(formulaFilterData.getFieldId()))) +// .compareTo(SalaryEntityUtil.empty2Zero(formulaFilterData.getContent())) >= 0; +// case FormulaFilterData.TERM_LE: +// return SalaryEntityUtil.empty2Zero(String.valueOf(map.get(formulaFilterData.getFieldId()))) +// .compareTo(SalaryEntityUtil.empty2Zero(formulaFilterData.getContent())) <= 0; +// case FormulaFilterData.TERM_LT: +// return SalaryEntityUtil.empty2Zero(String.valueOf(map.get(formulaFilterData.getFieldId()))) +// .compareTo(SalaryEntityUtil.empty2Zero(formulaFilterData.getContent())) < 0; +// default: +// return false; +// } +// } +//} diff --git a/src/com/engine/salary/entity/taxrate/param/TaxAgentQueryParam.java b/src/com/engine/salary/entity/taxrate/param/TaxAgentQueryParam.java new file mode 100644 index 000000000..e506b0c5e --- /dev/null +++ b/src/com/engine/salary/entity/taxrate/param/TaxAgentQueryParam.java @@ -0,0 +1,25 @@ +package com.engine.salary.entity.taxrate.param; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.lang.reflect.Array; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class TaxAgentQueryParam { + + private Collection ids; + + private String name; + + +} diff --git a/src/com/engine/salary/entity/taxrate/param/TaxRateBaseSaveParam.java b/src/com/engine/salary/entity/taxrate/param/TaxRateBaseSaveParam.java new file mode 100644 index 000000000..73b3bc6f1 --- /dev/null +++ b/src/com/engine/salary/entity/taxrate/param/TaxRateBaseSaveParam.java @@ -0,0 +1,28 @@ +package com.engine.salary.entity.taxrate.param; + +import lombok.Data; + + +/** + * @description: 个税税率表主表保存参数 + * @author: xiajun + * @modified By: xiajun + * @date: Created in 1/17/22 3:19 PM + * @version:v1.0 + */ +@Data +public class TaxRateBaseSaveParam { + + private Long id; + + /** + * 名称不允许为空 + * 名称不能超过40个字符 + */ + private String name; + + /** + * 说明不能超过80个字符 + */ + private String description; +} diff --git a/src/com/engine/salary/entity/taxrate/param/TaxRateDetailSaveParam.java b/src/com/engine/salary/entity/taxrate/param/TaxRateDetailSaveParam.java new file mode 100644 index 000000000..3ac2c6a3b --- /dev/null +++ b/src/com/engine/salary/entity/taxrate/param/TaxRateDetailSaveParam.java @@ -0,0 +1,49 @@ +package com.engine.salary.entity.taxrate.param; + +import lombok.Data; + +import java.math.BigDecimal; + +/** + * @description: 个税税率表明细表保存参数 + * @author: xiajun + * @modified By: xiajun + * @date: Created in 1/17/22 3:22 PM + * @version:v1.0 + */ +@Data +public class TaxRateDetailSaveParam { + + //taxRateDetailMapper("主键id") + private Long id; + + //taxRateDetailMapper("税率主表id") + private Long batchId; + + //taxRateDetailMapper("序号") + private Integer indexNum; + + //taxRateDetailMapper("收入上限(含)") + private BigDecimal incomeUpperLimit; + + //taxRateDetailMapper("收入下限(不含)") + private BigDecimal incomeLowerLimit; + + //taxRateDetailMapper("免税标准-固定值") + private BigDecimal dutyFreeValue; + + //taxRateDetailMapper("免税标准-比例") + private BigDecimal dutyFreeRate; + + //taxRateDetailMapper("应纳税所得额上限(含)") + private BigDecimal taxableIncomeUl; + + //taxRateDetailMapper("应纳税所得额下限(不含)") + private BigDecimal taxableIncomeLl; + + //taxRateDetailMapper("税率") + private BigDecimal taxRate; + + //taxRateDetailMapper("速算扣除数") + private BigDecimal taxDeduction; +} diff --git a/src/com/engine/salary/entity/taxrate/param/TaxRateSaveParam.java b/src/com/engine/salary/entity/taxrate/param/TaxRateSaveParam.java new file mode 100644 index 000000000..a9107beee --- /dev/null +++ b/src/com/engine/salary/entity/taxrate/param/TaxRateSaveParam.java @@ -0,0 +1,32 @@ +package com.engine.salary.entity.taxrate.param; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * @description: 税率表保存 + * @author: xiajun + * @modified By: xiajun + * @date: Created in 10/20/21 1:59 PM + * @version:v1.0 + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class TaxRateSaveParam { + + /** + * 基本信息不允许为空 + */ +// //基本信息") + private TaxRateBaseSaveParam taxRateBatch; + + /** + * 详细设置不允许为空 + */ +// //详细设置") + private List taxRateRecords; +} diff --git a/src/com/engine/salary/entity/taxrate/vo/TaxAgentTableVO.java b/src/com/engine/salary/entity/taxrate/vo/TaxAgentTableVO.java new file mode 100644 index 000000000..9ebc23670 --- /dev/null +++ b/src/com/engine/salary/entity/taxrate/vo/TaxAgentTableVO.java @@ -0,0 +1,51 @@ +package com.engine.salary.entity.taxrate.vo; + +import com.engine.salary.annotation.SalaryTable; +import com.engine.salary.annotation.SalaryTableColumn; +import com.engine.salary.annotation.SalaryTableOperate; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 个税扣缴义务人表 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@SalaryTable(pageId = "a4f85287-e3f9-4275-ab18-7d06e54y6rj8", + fields = "id, name, description, create_time, update_time, creator, delete_type, tenant_key", + fromSql = "FROM hrsa_tax_agent", + orderby = "id desc", + primarykey = "id", + operates = {@SalaryTableOperate(text = "删除")} +) +public class TaxAgentTableVO { + + /** + * 主键 + */ + @SalaryTableColumn(column = "id", display = false) + private Long id; + + /** + * 名称 + */ + @SalaryTableColumn(column = "name", width = "30%", text = "个税扣缴义务人名称") + private String name; + + /** + * 描述 + */ + @SalaryTableColumn(column = "description", width = "30%", text = "备注") + private String description; + + /** + * 操作 + */ + @SalaryTableColumn(column = "operate", width = "20%", text = "操作") + private String operate; + +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/taxrate/vo/TaxDeclarationListVO.java b/src/com/engine/salary/entity/taxrate/vo/TaxDeclarationListVO.java new file mode 100644 index 000000000..6da2aab85 --- /dev/null +++ b/src/com/engine/salary/entity/taxrate/vo/TaxDeclarationListVO.java @@ -0,0 +1,78 @@ +package com.engine.salary.entity.taxrate.vo; + +import com.engine.salary.annotation.SalaryTable; +import com.engine.salary.annotation.SalaryTableColumn; +import com.engine.salary.annotation.SalaryTableOperate; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @description: 个税申报记录列表 + * @author: xiajun + * @modified By: xiajun + * @date: Created in 12/15/21 9:31 AM + * @version:v1.0 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@SalaryTable(pageId = "a4f85287-e3f9-4275-9527-7d06e54y6rj8", + fields = "id, salary_month, tax_cycle, tax_agent_id, description,creator, create_time, update_time, delete_type, tenant_key", + fromSql = "from hrsa_tax_declaration", + orderby = "id desc", + primarykey = "id", + operates = {@SalaryTableOperate(text = "查看")} +) +public class TaxDeclarationListVO { + + private Long id; + + @SalaryTableColumn( + text = "薪资所属月", + column = "salaryMonth", + width = "10%" + ) + private String salaryMonth; + + private Long taxAgentId; + + /* @SalaryTableColumn( + text = "个税扣缴义务人", + column = "taxAgentName", + width = "20%" + ) + private String taxAgentName;*/ + + @SalaryTableColumn( + text = "税款所属期", + column = "taxCycle", + width = "10%" + ) + private String taxCycle; + + private Long operateEmployeeId; + + /* @SalaryTableColumn( + text = "操作人", + column = "operateEmployeeName", + width = "10%" + ) + private String operateEmployeeName; +*/ + /* @SalaryTableColumn( + text = "操作时间", + column = "operateTime", + width = "20%" + ) + private String operateTime;*/ + + @SalaryTableColumn( + text = "备注", + column = "description", + width = "30%" + ) + private String description; +} diff --git a/src/com/engine/salary/entity/taxrate/vo/TaxRateFormVo.java b/src/com/engine/salary/entity/taxrate/vo/TaxRateFormVo.java new file mode 100644 index 000000000..8549dc55a --- /dev/null +++ b/src/com/engine/salary/entity/taxrate/vo/TaxRateFormVo.java @@ -0,0 +1,31 @@ +package com.engine.salary.entity.taxrate.vo; + +import com.engine.salary.entity.taxrate.TaxRateBase; +import com.engine.salary.entity.taxrate.TaxRateDetail; +import com.engine.salary.enums.SalarySystemTypeEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.util.List; + +@Data +@Builder +@Accessors(chain = true) +@NoArgsConstructor +@AllArgsConstructor +////税率表税表") +public class TaxRateFormVo { + +// //是否是系统默认。CUSTOM:自定义、SYSTEM:系统") + private SalarySystemTypeEnum systemType; + +// //基本信息") + private TaxRateBase taxRateBatch; + +// //详细设置") + private List taxRateRecords; + +} diff --git a/src/com/engine/salary/entity/taxrate/vo/TaxRateTableVO.java b/src/com/engine/salary/entity/taxrate/vo/TaxRateTableVO.java new file mode 100644 index 000000000..97b65df82 --- /dev/null +++ b/src/com/engine/salary/entity/taxrate/vo/TaxRateTableVO.java @@ -0,0 +1,60 @@ +package com.engine.salary.entity.taxrate.vo; + +import com.engine.salary.annotation.SalaryTable; +import com.engine.salary.annotation.SalaryTableColumn; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 税率表试图实体 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@SalaryTable(pageId = "a4f85287-e3f9-4275-9527-1206e54y6rj8", + fields = "id, name, system_type, description, create_time,creator,delete_type, tenant_key, update_time", + orderby = "id desc", + primarykey = "id" +) +public class TaxRateTableVO { + + + /** + * 主键 + */ + @SalaryTableColumn(column = "id", display = false) + private Long id; + + /** + * 名称 + */ + @SalaryTableColumn(text = "名称", width = "20", column = "name") + private String name; + + /** + * 是否是系统默认的。0:自定义、1:系统默认 + */ + @SalaryTableColumn(text = "表单类型", width = "20", column = "system_type", transmethod = "com.engine.salary.transmethod.TaxRateTransMethod.getSystemTypeName") + private Integer systemType; + + /** + * 描述 + */ + @SalaryTableColumn(text = "说明", width = "20", column = "description") + private String description; + + /** + * 操作 + */ + @SalaryTableColumn(text = "操作", width = "20", column = "operate") + private String operate; + +} \ No newline at end of file diff --git a/src/com/engine/salary/enums/AccountTypeEnum.java b/src/com/engine/salary/enums/AccountTypeEnum.java new file mode 100644 index 000000000..34368239c --- /dev/null +++ b/src/com/engine/salary/enums/AccountTypeEnum.java @@ -0,0 +1,68 @@ +package com.engine.salary.enums; + +import java.util.Arrays; +import java.util.Objects; +import java.util.Optional; + +/** + * 账号类型 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public enum AccountTypeEnum implements BaseEnum { + + MAIN(0, "主账号", 1), + SECOND(1, "次账号", 1); + + private Integer value; + private String defaultLabel; + private int labelId; + + + AccountTypeEnum(Integer value, String defaultLabel, int labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + @Override + public Integer getValue() { + return value; + } + + @Override + public String getDefaultLabel() { + return defaultLabel; + } + + @Override + public Integer getLabelId() { + return labelId; + } + + public static String getDefaultLabelByValue(Integer value) { + if (value == null) { + return MAIN.defaultLabel; + } + Optional optional = Arrays.stream(AccountTypeEnum.values()).filter(r -> r.getValue().equals(value)).findFirst(); + return optional.isPresent() ? optional.get().defaultLabel : ""; + } + + + public static AccountTypeEnum parseByValue(Integer value) { + if (value == null) { + return MAIN; + } + + for (AccountTypeEnum statusEnum : AccountTypeEnum.values()) { + if (Objects.equals(statusEnum.getValue(), value)) { + return statusEnum; + } + } + return MAIN; + } + +} diff --git a/src/com/engine/salary/enums/BaseEnum.java b/src/com/engine/salary/enums/BaseEnum.java new file mode 100644 index 000000000..20c99eea6 --- /dev/null +++ b/src/com/engine/salary/enums/BaseEnum.java @@ -0,0 +1,20 @@ +package com.engine.salary.enums; + +/** + * 基础枚举 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public interface BaseEnum { + + String name(); + + T getValue(); + + Integer getLabelId(); + + String getDefaultLabel(); +} diff --git a/src/com/engine/salary/enums/OperateTypeEnum.java b/src/com/engine/salary/enums/OperateTypeEnum.java new file mode 100644 index 000000000..524a6f603 --- /dev/null +++ b/src/com/engine/salary/enums/OperateTypeEnum.java @@ -0,0 +1,50 @@ +package com.engine.salary.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * 操作类型 + *

Copyright: Copyright (c) 2023

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Getter +@AllArgsConstructor +public enum OperateTypeEnum implements BaseEnum{ + + READ("0", "查看",1111), + ADD("1", "新建", 94607), + UPDATE("2", "更新", 249295), + DELETE("3", "删除", 87061), + FILE("4", "归档", 92144), + CANCEL_FILE("5", "取消归档", 145989), + CLEAR("6", "一键清空", 158473), + CALCULATE("7", "核算", 94146), + SYNC("8", "同步", 93950), + EXCEL_IMPORT("9", "导入", 87622), + EXCEL_EXPORT("9", "导出", 87622); + + private final String value; + + private final String defaultLabel; + + private final Integer labelId; + + @Override + public String getValue() { + return value; + } + + @Override + public Integer getLabelId() { + return labelId; + } + + @Override + public String getDefaultLabel() { + return defaultLabel; + } +} diff --git a/src/com/engine/salary/enums/SalaryCycleTypeEnum.java b/src/com/engine/salary/enums/SalaryCycleTypeEnum.java new file mode 100644 index 000000000..9def3061a --- /dev/null +++ b/src/com/engine/salary/enums/SalaryCycleTypeEnum.java @@ -0,0 +1,56 @@ +package com.engine.salary.enums; + + +import java.util.Objects; + +/** + * 薪资周期 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public enum SalaryCycleTypeEnum implements BaseEnum { + + BEFORE_LAST_MONTH(1, "上上月", 86075), + LAST_MONTH(2, "上月", 86074), + THIS_MONTH(3, "本月", 86072), + NEXT_MONTH(4, "下月", 86073); + + private int value; + + private String defaultLabel; + + private int labelId; + + SalaryCycleTypeEnum(int value, String defaultLabel, int labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + @Override + public Integer getValue() { + return value; + } + + @Override + public String getDefaultLabel() { + return defaultLabel; + } + + @Override + public Integer getLabelId() { + return labelId; + } + + public static SalaryCycleTypeEnum parseByValue(int value) { + for (SalaryCycleTypeEnum salaryCycleTypeEnum : SalaryCycleTypeEnum.values()) { + if (Objects.equals(salaryCycleTypeEnum.getValue(), value)) { + return salaryCycleTypeEnum; + } + } + return null; + } +} diff --git a/src/com/engine/salary/enums/SalaryDataSourceEnum.java b/src/com/engine/salary/enums/SalaryDataSourceEnum.java new file mode 100644 index 000000000..a26a75aa8 --- /dev/null +++ b/src/com/engine/salary/enums/SalaryDataSourceEnum.java @@ -0,0 +1,75 @@ +package com.engine.salary.enums; + +import java.util.Arrays; +import java.util.Objects; + +/** + * 薪资账目取值方式 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public enum SalaryDataSourceEnum implements BaseEnum { + + INPUT_IMPORT(0, "输入/导入", 92004), + CUSTOM_FORMULA(1, "自定义公式", 92001), + SALARY_ITEM(2, "薪资项目", 84960), + EMPLOYEE_INFO(3, "员工基本信息", 85366), + SALARY_ARCHIVES(4, "薪资档案", 85368), + CUMULATIVE_SITUATION(5, "累计情况(工资、薪金)", 87521), + SPE_ADDI_DEDUCTIONS(6, "累计专项附加扣除", 85380), + SOCIAL_SECURITY(7, "社保福利", 87522), + OTHER_DEDUCTION(8, "其他扣除", 85831), + ; + + private int value; + + private String defaultLabel; + + private int labelId; + + SalaryDataSourceEnum(int value, String defaultLabel, int labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + @Override + public Integer getValue() { + return value; + } + + @Override + public String getDefaultLabel() { + return defaultLabel; + } + + @Override + public Integer getLabelId() { + return labelId; + } + + public static SalaryDataSourceEnum parseByValue(int value) { + for (SalaryDataSourceEnum salaryDataSourceEnum : SalaryDataSourceEnum.values()) { + if (Objects.equals(salaryDataSourceEnum.getValue(), value)) { + return salaryDataSourceEnum; + } + } + return null; + } + + public static String getDefaultLabelByValue(Integer value) { + if (value == null) { + return ""; + } + SalaryDataSourceEnum[] enumAry = SalaryDataSourceEnum.values(); + for(int i = 0; i < Arrays.asList(enumAry).size(); i++){ + if (Integer.valueOf(enumAry[i].getValue()).equals(value)) { + return enumAry[i].getDefaultLabel(); + } + } + return ""; + } +} diff --git a/src/com/engine/salary/enums/SalaryItemCategoryEnum.java b/src/com/engine/salary/enums/SalaryItemCategoryEnum.java new file mode 100644 index 000000000..84585d22a --- /dev/null +++ b/src/com/engine/salary/enums/SalaryItemCategoryEnum.java @@ -0,0 +1,58 @@ +package com.engine.salary.enums; + + +import java.util.Objects; + +/** + * @description: 薪资项目属性 + * @author: xiajun + * @modified By: xiajun + * @date: Created in 10/25/21 2:23 PM + * @version:v1.0 + */ +public enum SalaryItemCategoryEnum implements BaseEnum { + + PRE_TAX_ADD(1, "税前加项", 84492), + PRE_TAX_DUD(2, "税前减项", 84493), + AFTER_TAX_ADD(3, "税后加项", 84494), + AFTER_TAX_DUD(4, "税后减项", 84495), + SUM(5, "统计项", 84497), + TAX(6, "税费项", 84498), + OTHER(7, "其他项", 84499); + + private int value; + + private String defaultLabel; + + private int labelId; + + SalaryItemCategoryEnum(int value, String defaultLabel, int labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + @Override + public Integer getValue() { + return value; + } + + @Override + public String getDefaultLabel() { + return defaultLabel; + } + + @Override + public Integer getLabelId() { + return labelId; + } + + public static SalaryItemCategoryEnum parseByValue(int value) { + for (SalaryItemCategoryEnum categoryEnum : SalaryItemCategoryEnum.values()) { + if (Objects.equals(categoryEnum.getValue(), value)) { + return categoryEnum; + } + } + return null; + } +} diff --git a/src/com/engine/salary/enums/SalaryItemTypeEnum.java b/src/com/engine/salary/enums/SalaryItemTypeEnum.java new file mode 100644 index 000000000..ba446b447 --- /dev/null +++ b/src/com/engine/salary/enums/SalaryItemTypeEnum.java @@ -0,0 +1,81 @@ +package com.engine.salary.enums; + + +import java.util.Objects; + +/** + * @description: 薪资项目类型 + * @author: xiajun + * @modified By: xiajun + * @date: Created in 10/25/21 2:34 PM + * @version:v1.0 + */ +public enum SalaryItemTypeEnum implements BaseEnum { + + SALARY(1, SalaryItemCategoryEnum.PRE_TAX_ADD, "工资薪金", 85818), + BONUS(2, SalaryItemCategoryEnum.PRE_TAX_ADD, "全年一次性奖金", 85820), + INTEREST_DIVIDEND(3, SalaryItemCategoryEnum.PRE_TAX_ADD, "利息股息红利", 85821), + LABOR_REMUNERATION(4, SalaryItemCategoryEnum.PRE_TAX_ADD, "劳务报酬", 85822), + REMUNERATION(5, SalaryItemCategoryEnum.PRE_TAX_ADD, "稿酬", 85823), + ROYALTIES(6, SalaryItemCategoryEnum.PRE_TAX_ADD, "特许权使用费", 85824), + ACCIDENTAL_INCOME(7, SalaryItemCategoryEnum.PRE_TAX_ADD, "偶然所得", 85825), + SEVERANCE_COMPENSATION(8, SalaryItemCategoryEnum.PRE_TAX_ADD, "离职补偿金", 85826), + PRE_TAX_DEDUCTION(9, SalaryItemCategoryEnum.PRE_TAX_DUD, "税前扣款", 85828), + SPECIAL_DEDUCTION(10, SalaryItemCategoryEnum.PRE_TAX_DUD, "专项扣除", 85829), + SPECIAL_ADDITIONAL_DEDUCTION(11, SalaryItemCategoryEnum.PRE_TAX_DUD, "专项附加扣除", 85830), + OTHER_DEDUCTIONS(12, SalaryItemCategoryEnum.PRE_TAX_DUD, "其他扣除", 85831), + AFTER_TAX_REIMBURSEMENT(13, SalaryItemCategoryEnum.AFTER_TAX_ADD, "税后报销", 85832), + AFTER_TAX_ADJUSTMENT(14, SalaryItemCategoryEnum.AFTER_TAX_ADD, "税后调整", 85833), + AFTER_TAX_DEDUCTION(15, SalaryItemCategoryEnum.AFTER_TAX_DUD, "税后扣款", 85834), + TAX(16, SalaryItemCategoryEnum.TAX, "税费", 85835), + EMPLOYEE_INFO(18, SalaryItemCategoryEnum.OTHER, "员工基本信息", 85366), + ATTEND_INFO(20, SalaryItemCategoryEnum.OTHER, "员工考勤信息", 98890), + OTHER(19, SalaryItemCategoryEnum.OTHER, "其他数值", 100114), + TEXT(17, SalaryItemCategoryEnum.OTHER, "其他文本", 100115), + OTHER_LOGIC(21, SalaryItemCategoryEnum.OTHER, "其他逻辑", 100116), + STATISTICAL_ITEM(22, SalaryItemCategoryEnum.SUM, "统计项", 84497), + ; + + private int value; + + private SalaryItemCategoryEnum category; + + private String defaultLabel; + + private int labelId; + + SalaryItemTypeEnum(int value, SalaryItemCategoryEnum category, String defaultLabel, int labelId) { + this.value = value; + this.category = category; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + @Override + public Integer getValue() { + return value; + } + + public SalaryItemCategoryEnum getCategory() { + return category; + } + + @Override + public String getDefaultLabel() { + return defaultLabel; + } + + @Override + public Integer getLabelId() { + return labelId; + } + + public static SalaryItemTypeEnum parseByValue(int value) { + for (SalaryItemTypeEnum salaryItemTypeEnum : SalaryItemTypeEnum.values()) { + if (Objects.equals(salaryItemTypeEnum.getValue(), value)) { + return salaryItemTypeEnum; + } + } + return null; + } +} diff --git a/src/com/engine/salary/enums/SalaryJobFlagEnum.java b/src/com/engine/salary/enums/SalaryJobFlagEnum.java new file mode 100644 index 000000000..6309c0b74 --- /dev/null +++ b/src/com/engine/salary/enums/SalaryJobFlagEnum.java @@ -0,0 +1,31 @@ +package com.engine.salary.enums; + +/** + * 个税扣缴义务人角色类型 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public enum SalaryJobFlagEnum { + normal("normal", "在职"), + unavailable("unavailable", "非在职"); + + private String value; + + private String defaultLabel; + + SalaryJobFlagEnum(String value, String defaultLabel) { + this.value = value; + this.defaultLabel = defaultLabel; + } + + public String getValue() { + return value; + } + + public String getDefaultLabel() { + return defaultLabel; + } +} diff --git a/src/com/engine/salary/enums/SalaryOnOffEnum.java b/src/com/engine/salary/enums/SalaryOnOffEnum.java new file mode 100644 index 000000000..99b31eb4d --- /dev/null +++ b/src/com/engine/salary/enums/SalaryOnOffEnum.java @@ -0,0 +1,62 @@ +package com.engine.salary.enums; + + + +/** + * 开关枚举 + *

Copyright: Copyright (c) 2024

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public enum SalaryOnOffEnum implements BaseEnum { + + ON(1, "是", 84967), + OFF(0, "否", 84968); + + private int value; + + private String defaultLabel; + + private int labelId; + + SalaryOnOffEnum(int value, String defaultLabel, int labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + @Override + public Integer getValue() { + return value; + } + + @Override + public String getDefaultLabel() { + return defaultLabel; + } + + @Override + public Integer getLabelId() { + return labelId; + } + + public static SalaryOnOffEnum parseByValue(int value) { + for (SalaryOnOffEnum item : values()) { + if (item.getValue().equals(value)) { + return item; + } + } + return OFF; + } + + public static SalaryOnOffEnum parseByDefaultLabel(String defaultLabel) { + for (SalaryOnOffEnum item : values()) { + if (item.getDefaultLabel().equals(defaultLabel)) { + return item; + } + } + return OFF; + } +} diff --git a/src/com/engine/salary/enums/SalaryRoundingModeEnum.java b/src/com/engine/salary/enums/SalaryRoundingModeEnum.java new file mode 100644 index 000000000..a47733891 --- /dev/null +++ b/src/com/engine/salary/enums/SalaryRoundingModeEnum.java @@ -0,0 +1,81 @@ +package com.engine.salary.enums; + + +import java.util.Arrays; +import java.util.Objects; + +/** + * 进位规则 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public enum SalaryRoundingModeEnum implements BaseEnum { + + RAW_DATA(1, "原始数据", 84504), + ROUNDING(2, "四舍五入", 84505), + ROUND_UP(3, "向上舍入", 84506), + ROUND_DOWN(4, "向下舍入", 84507), + CEILING(5, "见分进角", 84507), + UP_EVEN(6, "向上求偶", 84507); + + private int value; + + private String defaultLabel; + + private int labelId; + + SalaryRoundingModeEnum(int value, String defaultLabel, int labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + public static String getDefaultLabelByValue(Integer value) { + if (value == null) { + return ""; + } + SalaryRoundingModeEnum[] enumAry = SalaryRoundingModeEnum.values(); + for (int i = 0; i < Arrays.asList(enumAry).size(); i++) { + if (Integer.valueOf(enumAry[i].getValue()).equals(value)) { + return enumAry[i].getDefaultLabel(); + } + } + return ""; + } + + @Override + public Integer getValue() { + return value; + } + + @Override + public String getDefaultLabel() { + return defaultLabel; + } + + @Override + public Integer getLabelId() { + return labelId; + } + + public static SalaryRoundingModeEnum parseByValue(int value) { + for (SalaryRoundingModeEnum modeEnum : SalaryRoundingModeEnum.values()) { + if (Objects.equals(modeEnum.getValue(), value)) { + return modeEnum; + } + } + return ROUNDING; + } + + public static SalaryRoundingModeEnum parseByDefaultLabel(String defaultLabel) { + for (SalaryRoundingModeEnum modeEnum : SalaryRoundingModeEnum.values()) { + if (Objects.equals(modeEnum.getDefaultLabel(), defaultLabel)) { + return modeEnum; + } + } + return ROUNDING; + } +} diff --git a/src/com/engine/salary/enums/SalarySobStatusEnum.java b/src/com/engine/salary/enums/SalarySobStatusEnum.java new file mode 100644 index 000000000..31557f24f --- /dev/null +++ b/src/com/engine/salary/enums/SalarySobStatusEnum.java @@ -0,0 +1,47 @@ +package com.engine.salary.enums; + + + +/** + * @description: 薪资账套设置步骤状态 + * @author: xiajun + * @modified By: xiajun + * @date: Created in 11/9/21 3:09 PM + * @version:v1.0 + */ +public enum SalarySobStatusEnum implements BaseEnum { + + START(0, "开始", 86123), + BASIC_INFO(1, "基础信息", 86124), + EMPLOYEE_SCOPE(2, "人员范围", 86125), + SALARY_ITEM(3, "薪资项目", 84960), + CHECK_RULE(4, "校验规则", 86126), + END(99, "结束", 86127); + + private int value; + + private String defaultLabel; + + private int labelId; + + SalarySobStatusEnum(int value, String defaultLabel, int labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + @Override + public Integer getValue() { + return value; + } + + @Override + public String getDefaultLabel() { + return defaultLabel; + } + + @Override + public Integer getLabelId() { + return labelId; + } +} diff --git a/src/com/engine/salary/enums/SalarySystemTypeEnum.java b/src/com/engine/salary/enums/SalarySystemTypeEnum.java new file mode 100644 index 000000000..8ce14a0dc --- /dev/null +++ b/src/com/engine/salary/enums/SalarySystemTypeEnum.java @@ -0,0 +1,54 @@ +package com.engine.salary.enums; + + +import java.util.Objects; + +/** + * @description: 税率表表单类型 + * @author: xiajun + * @modified By: xiajun + * @date: Created in 10/19/21 4:05 PM + * @version:v1.0 + */ +public enum SalarySystemTypeEnum implements BaseEnum { + + CUSTOM(0, "自定义表单", 83993), + SYSTEM(1, "系统表单", 83994), + ; + + private int value; + + private String defaultLabel; + + private int labelId; + + SalarySystemTypeEnum(int value, String defaultLabel, int labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + @Override + public Integer getValue() { + return value; + } + + @Override + public String getDefaultLabel() { + return defaultLabel; + } + + @Override + public Integer getLabelId() { + return labelId; + } + + public static SalarySystemTypeEnum parseByValue(int value) { + for (SalarySystemTypeEnum typeEnum : SalarySystemTypeEnum.values()) { + if (Objects.equals(typeEnum.getValue(), value)) { + return typeEnum; + } + } + return null; + } +} diff --git a/src/com/engine/salary/enums/SalaryValueTypeEnum.java b/src/com/engine/salary/enums/SalaryValueTypeEnum.java new file mode 100644 index 000000000..3f50e75fc --- /dev/null +++ b/src/com/engine/salary/enums/SalaryValueTypeEnum.java @@ -0,0 +1,79 @@ +package com.engine.salary.enums; + + +import java.util.Arrays; +import java.util.Objects; + +/** + * 字段类型 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public enum SalaryValueTypeEnum implements BaseEnum { + + INPUT(1, "输入", 84976), + FORMULA(2, "公式", 84977), + SQL(3, "SQL", 84977); + + private int value; + + private String defaultLabel; + + private int labelId; + + SalaryValueTypeEnum(int value, String defaultLabel, int labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + @Override + public Integer getValue() { + return value; + } + + @Override + public String getDefaultLabel() { + return defaultLabel; + } + + @Override + public Integer getLabelId() { + return labelId; + } + + public static SalaryValueTypeEnum parseByValue(int value) { + for (SalaryValueTypeEnum salaryValueTypeEnum : SalaryValueTypeEnum.values()) { + if (Objects.equals(salaryValueTypeEnum.getValue(), value)) { + return salaryValueTypeEnum; + } + } + return INPUT; + } + + public static SalaryValueTypeEnum parseByDefaultLabel(String defaultLabel) { + for (SalaryValueTypeEnum salaryValueTypeEnum : SalaryValueTypeEnum.values()) { + if (Objects.equals(salaryValueTypeEnum.getDefaultLabel(), defaultLabel)) { + return salaryValueTypeEnum; + } + } + return INPUT; + } + + + public static String getDefaultLabelByValue(Integer value) { + if (value == null) { + return ""; + } + SalaryValueTypeEnum[] enumAry = SalaryValueTypeEnum.values(); + for (int i = 0; i < Arrays.asList(enumAry).size(); i++) { + if (Integer.valueOf(enumAry[i].getValue()).equals(value)) { + return enumAry[i].getDefaultLabel(); + } + } + return INPUT.getDefaultLabel(); + } +} diff --git a/src/com/engine/salary/enums/UserStatusEnum.java b/src/com/engine/salary/enums/UserStatusEnum.java new file mode 100644 index 000000000..cdf894769 --- /dev/null +++ b/src/com/engine/salary/enums/UserStatusEnum.java @@ -0,0 +1,115 @@ +package com.engine.salary.enums; + +import com.engine.salary.entity.hrm.HrmStatus; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * 人员状态 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public enum UserStatusEnum implements BaseEnum { + + TRIAL(0, "试用", 1), + FORMAL(1, "正式", 1), + TEMPORARY(2, "临时", 1), + DELAY(3, "试用延期", 1), + FIRE(4, "解雇", 1), + DEPARTURE(5, "离职", 1), + RETIRED(6, "退休", 1), + INVALID(7, "无效", 1); + + private Integer value; + private String defaultLabel; + private int labelId; + + + UserStatusEnum(Integer value, String defaultLabel, int labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + @Override + public Integer getValue() { + return value; + } + + @Override + public String getDefaultLabel() { + return defaultLabel; + } + + @Override + public Integer getLabelId() { + return labelId; + } + + public static String getDefaultLabelByValue(Integer value) { + Optional optional = Arrays.stream(UserStatusEnum.values()).filter(r -> r.getValue().equals(value)).findFirst(); + return optional.isPresent() ? optional.get().defaultLabel : ""; + } + + public static List> getList() { + return Arrays.stream(UserStatusEnum.values()) + .filter(v -> v != INVALID) + .map(v -> { + Map m = new HashMap(); + m.put("id", v.value.toString()); + m.put("content", v.defaultLabel); + return m; + }).collect(Collectors.toList()); + } + + /** + * 在职状态 + * + * @return + */ + public static List getNormalStatus() { + return Arrays.asList(TRIAL.getValue().toString(), FORMAL.getValue().toString(), TEMPORARY.getValue().toString(), DELAY.getValue().toString()); + } + + /** + * 离职状态 + * + * @return + */ + public static List getUnavailableStatus() { + return Arrays.asList(FIRE.getValue().toString(), DEPARTURE.getValue().toString(), RETIRED.getValue().toString()); + } + + /** + * 全部状态 + * + * @return + */ + public static List getAllStatus() { + return Arrays.asList(TRIAL.getValue().toString(), FORMAL.getValue().toString(), TEMPORARY.getValue().toString(), DELAY.getValue().toString(),FIRE.getValue().toString(), DEPARTURE.getValue().toString(), RETIRED.getValue().toString()); + } + + public static List getEffectiveList() { + return Arrays.stream(UserStatusEnum.values()).filter(v -> v != INVALID).collect(Collectors.toList()); + } + + public static List getHrmStatusList() { + return Arrays.stream(UserStatusEnum.values()) + .filter(v -> v != INVALID) + .map(v -> HrmStatus.builder().id(v.value.toString()).name(v.defaultLabel).build()).collect(Collectors.toList()); + } + + public static UserStatusEnum parseByValue(Integer value) { + for (UserStatusEnum statusEnum : UserStatusEnum.values()) { + if (Objects.equals(statusEnum.getValue(), value)) { + return statusEnum; + } + } + return null; + } + +} diff --git a/src/com/engine/salary/enums/auth/AuthCheckTypeEnum.java b/src/com/engine/salary/enums/auth/AuthCheckTypeEnum.java new file mode 100644 index 000000000..97538076c --- /dev/null +++ b/src/com/engine/salary/enums/auth/AuthCheckTypeEnum.java @@ -0,0 +1,59 @@ +package com.engine.salary.enums.auth; + +import com.engine.salary.enums.BaseEnum; +import com.engine.salary.exception.SalaryRunTimeException; + +import java.util.Objects; + +/** + * 权限验证方式 + *

Copyright: Copyright (c) 2024

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public enum AuthCheckTypeEnum implements BaseEnum { + + + TAX_EMP("TAX_EMP", "扣缴义务人和人员混合验证", 87627), + EMP("EMP", "人员验证", 87626), + TAX("TAX", "扣缴义务人验证", 87626), + SOB("SOB", "账套验证", 87626); + + + private String value; + private String defaultLabel; + private int labelId; + + AuthCheckTypeEnum(String value, String defaultLabel, int labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + + @Override + public String getValue() { + return value; + } + + @Override + public String getDefaultLabel() { + return defaultLabel; + } + + @Override + public Integer getLabelId() { + return labelId; + } + + public static AuthCheckTypeEnum parseByValue(String value) { + for (AuthCheckTypeEnum typeEnum : AuthCheckTypeEnum.values()) { + if (Objects.equals(typeEnum.getValue(), value)) { + return typeEnum; + } + } + throw new SalaryRunTimeException("未找到对应的枚举"); + } +} diff --git a/src/com/engine/salary/enums/auth/AuthFilterTypeEnum.java b/src/com/engine/salary/enums/auth/AuthFilterTypeEnum.java new file mode 100644 index 000000000..c9af4e243 --- /dev/null +++ b/src/com/engine/salary/enums/auth/AuthFilterTypeEnum.java @@ -0,0 +1,59 @@ +package com.engine.salary.enums.auth; + +import com.engine.salary.enums.BaseEnum; +import com.engine.salary.exception.SalaryRunTimeException; + +import java.util.Objects; + +/** + * 权限过滤 + *

Copyright: Copyright (c) 2024

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public enum AuthFilterTypeEnum implements BaseEnum { + + DATA_OPT("DATA_OPT", "数据&功能权限", 87626), + QUERY_DATA("QUERY_DATA", "获取可查询数据", 87627), + ADMIN_DATA("ADMIN_DATA", "获取可管理数据", 87627), + NO_AUTH("ADMIN_DATA", "获取可管理数据", 87627); + + + + private String value; + private String defaultLabel; + private int labelId; + + AuthFilterTypeEnum(String value, String defaultLabel, int labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + + @Override + public String getValue() { + return value; + } + + @Override + public String getDefaultLabel() { + return defaultLabel; + } + + @Override + public Integer getLabelId() { + return labelId; + } + + public static AuthFilterTypeEnum parseByValue(String value) { + for (AuthFilterTypeEnum typeEnum : AuthFilterTypeEnum.values()) { + if (Objects.equals(typeEnum.getValue(), value)) { + return typeEnum; + } + } + throw new SalaryRunTimeException("未找到对应的枚举"); + } +} diff --git a/src/com/engine/salary/enums/auth/DataLinkEnum.java b/src/com/engine/salary/enums/auth/DataLinkEnum.java new file mode 100644 index 000000000..e99cbf9a6 --- /dev/null +++ b/src/com/engine/salary/enums/auth/DataLinkEnum.java @@ -0,0 +1,79 @@ +package com.engine.salary.enums.auth; + +import cn.hutool.core.collection.CollectionUtil; +import com.engine.salary.enums.BaseEnum; +import com.engine.salary.exception.SalaryRunTimeException; + +import java.util.Collection; +import java.util.HashSet; +import java.util.Objects; +import java.util.Set; + +/** + * 或者、并且、排除 + *

Copyright: Copyright (c) 2024

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public enum DataLinkEnum implements BaseEnum { + + + OR(1, "并集运算", 87627) { + @Override + public Set calculation(Collection coll1, Collection coll2) { + return new HashSet<>(CollectionUtil.union(coll1, coll2)); + } + }, + AND(2, "交集运算", 87626) { + @Override + public Set calculation(Collection coll1, Collection coll2) { + return new HashSet<>(CollectionUtil.intersection(coll1, coll2)); + } + }, + NOT_IN(3, "补集运算", 87626) { + @Override + public Set calculation(Collection coll1, Collection coll2) { + return new HashSet<>(CollectionUtil.disjunction(coll1, coll2)); + } + }; + + + private Integer value; + private String defaultLabel; + private int labelId; + + DataLinkEnum(Integer value, String defaultLabel, int labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + public abstract Set calculation(Collection coll1, Collection coll2); + + + @Override + public Integer getValue() { + return value; + } + + @Override + public String getDefaultLabel() { + return defaultLabel; + } + + @Override + public Integer getLabelId() { + return labelId; + } + + public static DataLinkEnum parseByValue(int value) { + for (DataLinkEnum typeEnum : DataLinkEnum.values()) { + if (Objects.equals(typeEnum.getValue(), value)) { + return typeEnum; + } + } + throw new SalaryRunTimeException("未找到对应的枚举"); + } +} diff --git a/src/com/engine/salary/enums/auth/DataTargetTypeEnum.java b/src/com/engine/salary/enums/auth/DataTargetTypeEnum.java new file mode 100644 index 000000000..056b42fd4 --- /dev/null +++ b/src/com/engine/salary/enums/auth/DataTargetTypeEnum.java @@ -0,0 +1,176 @@ +package com.engine.salary.enums.auth; + +import com.engine.common.service.HrmCommonService; +import com.engine.common.service.impl.HrmCommonServiceImpl; +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.taxagent.po.TaxAgentEmpPO; +import com.engine.salary.enums.BaseEnum; +import com.engine.salary.enums.datacollection.UseEmployeeTypeEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.service.impl.SalaryEmployeeServiceImpl; +import com.engine.salary.service.impl.TaxAgentEmpServiceImpl; +import com.engine.salary.util.SalaryEntityUtil; +import com.google.common.collect.Lists; +import weaver.conn.RecordSet; + +import java.util.*; + +/** + * 对象类型,1:人员、2:部门、3:岗位、4:分部、5:角色、6:安全级别 、7:所有人 、8:登录人、9:账套、10:sql + *

Copyright: Copyright (c) 2024

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public enum DataTargetTypeEnum implements BaseEnum { + + + EMP(1, "人员", 87627) { + @Override + public Set getEmpIds(String target, Object... param) { + Set list = new HashSet<>(); + list.add(Long.valueOf(target)); + return list; + } + }, + DEPARTMENT(2, "部门", 87626) { + @Override + public Set getEmpIds(String target, Object... param) { + SalaryEmployeeServiceImpl salaryEmployeeService = new SalaryEmployeeServiceImpl(); + return new HashSet<>(salaryEmployeeService.listByDepartment(Collections.singletonList(Long.valueOf(target)))); + } + }, + JOB(3, "岗位", 87626) { + @Override + public Set getEmpIds(String target, Object... param) { + SalaryEmployeeServiceImpl salaryEmployeeService = new SalaryEmployeeServiceImpl(); + return new HashSet<>(salaryEmployeeService.listByJob(Collections.singletonList(Long.valueOf(target)))); + } + }, + SUB_COMPANY(4, "分部", 87626) { + @Override + public Set getEmpIds(String target, Object... param) { + SalaryEmployeeServiceImpl salaryEmployeeService = new SalaryEmployeeServiceImpl(); + return new HashSet<>(salaryEmployeeService.listBySubCompany(Collections.singletonList(Long.valueOf(target)))); + } + }, + ROLE(5, "角色", 87626) { + @Override + public Set getEmpIds(String target, Object... param) { + HrmCommonService hrmCommonService = new HrmCommonServiceImpl(); + Set memberList = new HashSet<>(); + List ids = hrmCommonService.getRoleMembers(target, "2"); + ids.forEach(id -> memberList.add(Long.parseLong(id.toString()))); + return memberList; + } + }, + LEVEL(6, "安全级别", 87626) { + @Override + public Set getEmpIds(String target, Object... param) { + String[] split = target.split("-"); + int minLevel = split[0] == null ? 0 : Integer.parseInt(split[0]); + int maxLevel = split[1] == null ? 100 : Integer.parseInt(split[1]); + Set memberList = new HashSet<>(); + RecordSet rs = new RecordSet(); + if (rs.execute("select id from hrmresource where level between " + minLevel + " and " + maxLevel + " and status not in (7) and (accounttype is null or accounttype = 0) ")) { + while (rs.next()) { + memberList.add(Long.parseLong(rs.getString("id"))); + } + } + return memberList; + } + }, +// ALL(7, "所有人", 87626) { +// @Override +// public Set getEmpIds(String target, Object... param) { +// Set memberList = new HashSet<>(); +// RecordSet rs = new RecordSet(); +// if (rs.execute("select id from hrmresource where status not in (7) and (accounttype is null or accounttype = 0) ")) { +// while (rs.next()) { +// memberList.add(Long.parseLong(rs.getString("id"))); +// } +// } +// return memberList; +// } +// }, +// LOGIN_PERSON(8, "登录人", 87626) { +// //参数1,登录人信息 +// @Override +// public Set getEmpIds(String target, Object... param) { +// LoginPersonTargetTypeEnum loginPersonTargetTypeEnum = LoginPersonTargetTypeEnum.parseByValue(Integer.parseInt(target)); +// return loginPersonTargetTypeEnum.getEmpIds((DataCollectionEmployee) param[0]); +// } +// }, + SOB(9, "账套", 87626) { + @Override + public Set getEmpIds(String target, Object... param) { + SalaryEmployeeServiceImpl salaryEmployeeService = new SalaryEmployeeServiceImpl(); + List employeeList = salaryEmployeeService.listBySalarySobId(Long.valueOf(target),true); + return SalaryEntityUtil.properties(employeeList, DataCollectionEmployee::getEmployeeId); + } + }, + TAX(10, "扣缴义务人", 87626) { + @Override + public Set getEmpIds(String target, Object... param) { + TaxAgentEmpServiceImpl taxAgentEmpServiceImpl = new TaxAgentEmpServiceImpl(); + List taxIds = Lists.newArrayList(Long.valueOf(target)); + List taxAgentEmpPOS = taxAgentEmpServiceImpl.listByTaxAgentIds(taxIds, UseEmployeeTypeEnum.ORG); + return SalaryEntityUtil.properties(taxAgentEmpPOS, TaxAgentEmpPO::getEmployeeId); + } + }, + SQL(11, "SQL", 87626) { + @Override + public Set getEmpIds(String target, Object... param) { + //参数1,登录人信息 +// DataCollectionEmployee employee = (DataCollectionEmployee) param[0]; +// target = target.replaceAll("$uid$", Util.null2String(employee.getEmployeeId())); + Set memberList = new HashSet<>(); + RecordSet rs = new RecordSet(); + if (rs.execute(target)) { + while (rs.next()) { + memberList.add(Long.parseLong(rs.getString("id"))); + } + } + return memberList; + } + }; + + + private Integer value; + private String defaultLabel; + private int labelId; + + DataTargetTypeEnum(Integer value, String defaultLabel, int labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + public abstract Set getEmpIds(String target, Object... param); + + + @Override + public Integer getValue() { + return value; + } + + @Override + public String getDefaultLabel() { + return defaultLabel; + } + + @Override + public Integer getLabelId() { + return labelId; + } + + public static DataTargetTypeEnum parseByValue(int value) { + for (DataTargetTypeEnum typeEnum : DataTargetTypeEnum.values()) { + if (Objects.equals(typeEnum.getValue(), value)) { + return typeEnum; + } + } + throw new SalaryRunTimeException("未找到对应的枚举"); + } +} diff --git a/src/com/engine/salary/enums/auth/LoginPersonTargetTypeEnum.java b/src/com/engine/salary/enums/auth/LoginPersonTargetTypeEnum.java new file mode 100644 index 000000000..75c97749e --- /dev/null +++ b/src/com/engine/salary/enums/auth/LoginPersonTargetTypeEnum.java @@ -0,0 +1,123 @@ +package com.engine.salary.enums.auth; + +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.enums.BaseEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import weaver.conn.RecordSet; + +import java.util.*; + +/** + * 登录人信息类型 + *

Copyright: Copyright (c) 2024

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public enum LoginPersonTargetTypeEnum implements BaseEnum { + + + self(1, "本人", 87627) { + @Override + public Set getEmpIds(DataCollectionEmployee employee) { + Set memberList = new HashSet<>(); + memberList.add(employee.getEmployeeId()); + return memberList; + } + }, + SUBORDINATE(2, "下属", 87626) { + @Override + public Set getEmpIds(DataCollectionEmployee employee) { + String sql = "select id from hrmresource where status not in (7) and (accounttype is null or accounttype = 0) and managerstr like '%," + employee.getEmployeeId() + ",%' and "; + Set memberList = new HashSet<>(); + RecordSet rs = new RecordSet(); + if (rs.execute(sql)) { + while (rs.next()) { + memberList.add(Long.parseLong(rs.getString("id"))); + } + } + return memberList; + } + }, + DEPARTMENT(3, "本部门", 87626) { + @Override + public Set getEmpIds(DataCollectionEmployee employee) { + String sql = "select id from hrmresource where status not in (7) and (accounttype is null or accounttype = 0) and departmentid =" + employee.getDepartmentId(); + Set memberList = new HashSet<>(); + RecordSet rs = new RecordSet(); + if (rs.execute(sql)) { + while (rs.next()) { + memberList.add(Long.parseLong(rs.getString("id"))); + } + } + return memberList; + } + }, + SUB_COMPANY(4, "本分部", 87626) { + @Override + public Set getEmpIds(DataCollectionEmployee employee) { + String sql = "select id from hrmresource where status not in (7) and (accounttype is null or accounttype = 0) and subcompanyid1 =" + employee.getSubcompanyid(); + Set memberList = new HashSet<>(); + RecordSet rs = new RecordSet(); + if (rs.execute(sql)) { + while (rs.next()) { + memberList.add(Long.parseLong(rs.getString("id"))); + } + } + return memberList; + } + }, + JOB(5, "本岗位", 87626) { + @Override + public Set getEmpIds(DataCollectionEmployee employee) { + String sql = "select id from hrmresource where status not in (7) and (accounttype is null or accounttype = 0) and jobtitle =" + employee.getJobtitleId(); + Set memberList = new HashSet<>(); + RecordSet rs = new RecordSet(); + if (rs.execute(sql)) { + while (rs.next()) { + memberList.add(Long.parseLong(rs.getString("id"))); + } + } + return memberList; + } + }; + + + private Integer value; + private String defaultLabel; + private int labelId; + + LoginPersonTargetTypeEnum(Integer value, String defaultLabel, int labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + public abstract Set getEmpIds(DataCollectionEmployee employee); + + + @Override + public Integer getValue() { + return value; + } + + @Override + public String getDefaultLabel() { + return defaultLabel; + } + + @Override + public Integer getLabelId() { + return labelId; + } + + public static LoginPersonTargetTypeEnum parseByValue(int value) { + for (LoginPersonTargetTypeEnum typeEnum : LoginPersonTargetTypeEnum.values()) { + if (Objects.equals(typeEnum.getValue(), value)) { + return typeEnum; + } + } + throw new SalaryRunTimeException("未找到对应的枚举"); + } +} diff --git a/src/com/engine/salary/enums/auth/MemberTargetTypeEnum.java b/src/com/engine/salary/enums/auth/MemberTargetTypeEnum.java new file mode 100644 index 000000000..9c02cfef6 --- /dev/null +++ b/src/com/engine/salary/enums/auth/MemberTargetTypeEnum.java @@ -0,0 +1,121 @@ +package com.engine.salary.enums.auth; + +import com.engine.common.service.HrmCommonService; +import com.engine.common.service.impl.HrmCommonServiceImpl; +import com.engine.salary.enums.BaseEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.service.impl.SalaryEmployeeServiceImpl; +import weaver.conn.RecordSet; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.Set; +import java.util.stream.Collectors; + +/** + * 成员类型,1:人员、2:部门、3:岗位、4:分部、5:角色、6:sql + *

Copyright: Copyright (c) 2024

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public enum MemberTargetTypeEnum implements BaseEnum { + + + EMP(1, "人员", 87627) { + @Override + public List getEmpIds(Set targets) { + return targets.stream().map(Long::valueOf).collect(Collectors.toList()); + } + }, + DEPARTMENT(2, "部门", 87626) { + @Override + public List getEmpIds(Set targets) { + List deptIds = targets.stream().map(Long::valueOf).collect(Collectors.toList()); + SalaryEmployeeServiceImpl salaryEmployeeService = new SalaryEmployeeServiceImpl(); + return salaryEmployeeService.listByDepartment(deptIds); + } + }, + JOB(3, "岗位", 87626) { + @Override + public List getEmpIds(Set targets) { + List ids = targets.stream().map(Long::valueOf).collect(Collectors.toList()); + SalaryEmployeeServiceImpl salaryEmployeeService = new SalaryEmployeeServiceImpl(); + return salaryEmployeeService.listByJob(ids); + } + }, + SUB_COMPANY(4, "分部", 87626) { + @Override + public List getEmpIds(Set targets) { + List ids = targets.stream().map(Long::valueOf).collect(Collectors.toList()); + SalaryEmployeeServiceImpl salaryEmployeeService = new SalaryEmployeeServiceImpl(); + return salaryEmployeeService.listBySubCompany(ids); + } + }, + ROLE(5, "角色", 87626) { + @Override + public List getEmpIds(Set targets) { + HrmCommonService hrmCommonService = new HrmCommonServiceImpl(); + List memberList = new ArrayList<>(); + targets.forEach(roleId -> { + memberList.addAll(hrmCommonService.getRoleMembers(roleId, "2")); + }); + return memberList.stream().map(id -> Long.parseLong(id.toString())).collect(Collectors.toList()); + } + }, + SQL(6, "sql", 87626) { + @Override + public List getEmpIds(Set targets) { + List memberList = new ArrayList<>(); + targets.forEach(sql -> { + RecordSet rs = new RecordSet(); + if (rs.execute(sql)) { + while (rs.next()) { + memberList.add(Long.parseLong(rs.getString("id"))); + } + } + }); + return memberList; + } + }; + + + private Integer value; + private String defaultLabel; + private int labelId; + + MemberTargetTypeEnum(Integer value, String defaultLabel, int labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + public abstract List getEmpIds(Set targets); + + + @Override + public Integer getValue() { + return value; + } + + @Override + public String getDefaultLabel() { + return defaultLabel; + } + + @Override + public Integer getLabelId() { + return labelId; + } + + public static MemberTargetTypeEnum parseByValue(int value) { + for (MemberTargetTypeEnum typeEnum : MemberTargetTypeEnum.values()) { + if (Objects.equals(typeEnum.getValue(), value)) { + return typeEnum; + } + } + throw new SalaryRunTimeException("未找到对应的枚举"); + } +} diff --git a/src/com/engine/salary/enums/auth/ResourceTargetTypeEnum.java b/src/com/engine/salary/enums/auth/ResourceTargetTypeEnum.java new file mode 100644 index 000000000..d4bfc372d --- /dev/null +++ b/src/com/engine/salary/enums/auth/ResourceTargetTypeEnum.java @@ -0,0 +1,75 @@ +package com.engine.salary.enums.auth; + +import com.engine.salary.enums.BaseEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.service.impl.SalaryEmployeeServiceImpl; + +import java.util.List; +import java.util.Objects; +import java.util.Set; +import java.util.stream.Collectors; + +/** + * 资源类型,1:扣缴义务人 2:账套 + *

Copyright: Copyright (c) 2024

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public enum ResourceTargetTypeEnum implements BaseEnum { + + + TAX_AGENT(1, "扣缴义务人", 87627) { + @Override + public List getEmpIds(Set targets) { + return targets.stream().map(Long::valueOf).collect(Collectors.toList()); + } + }, + SOB(2, "账套", 87626) { + @Override + public List getEmpIds(Set targets) { + List deptIds = targets.stream().map(Long::valueOf).collect(Collectors.toList()); + SalaryEmployeeServiceImpl salaryEmployeeService = new SalaryEmployeeServiceImpl(); + return salaryEmployeeService.listByDepartment(deptIds); + } + }; + + + private Integer value; + private String defaultLabel; + private int labelId; + + ResourceTargetTypeEnum(Integer value, String defaultLabel, int labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + public abstract List getEmpIds(Set targets); + + + @Override + public Integer getValue() { + return value; + } + + @Override + public String getDefaultLabel() { + return defaultLabel; + } + + @Override + public Integer getLabelId() { + return labelId; + } + + public static ResourceTargetTypeEnum parseByValue(int value) { + for (ResourceTargetTypeEnum typeEnum : ResourceTargetTypeEnum.values()) { + if (Objects.equals(typeEnum.getValue(), value)) { + return typeEnum; + } + } + throw new SalaryRunTimeException("未找到对应的枚举"); + } +} diff --git a/src/com/engine/salary/enums/common/FilterEnum.java b/src/com/engine/salary/enums/common/FilterEnum.java new file mode 100644 index 000000000..ae7de1221 --- /dev/null +++ b/src/com/engine/salary/enums/common/FilterEnum.java @@ -0,0 +1,132 @@ +package com.engine.salary.enums.common; + +import com.engine.salary.enums.BaseEnum; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.math.NumberUtils; + +import java.math.BigDecimal; +import java.util.List; +import java.util.function.Predicate; + +public enum FilterEnum implements BaseEnum { + + BT("BT", "包含", 1) { + @Override + public Predicate filter(List params) { + return a -> a != null && a.contains(params.get(0)); + } + }, + EQ("EQ", "等于", 1) { + @Override + public Predicate filter(List params) { + return a -> { + if (NumberUtils.isCreatable(a) && NumberUtils.isCreatable(params.get(0))) { + return new BigDecimal(a).compareTo(new BigDecimal(params.get(0))) == 0; + } else { + return a != null && a.equals(params.get(0)); + } + }; + } + }, + NE("NE", "不等于", 1) { + @Override + public Predicate filter(List params) { + return a -> { + if (NumberUtils.isCreatable(a) && NumberUtils.isCreatable(params.get(0))) { + return new BigDecimal(a).compareTo(new BigDecimal(params.get(0))) != 0; + } else { + return a != null && !a.equals(params.get(0)); + } + }; + } + }, + GT("GT", "大于", 1) { + @Override + public Predicate filter(List params) { + return a -> { + if (NumberUtils.isCreatable(a) && NumberUtils.isCreatable(params.get(0))) { + return new BigDecimal(a).compareTo(new BigDecimal(params.get(0))) > 0; + } + return false; + }; + } + }, + LT("LT", "小于", 1) { + @Override + public Predicate filter(List params) { + return a -> { + if (NumberUtils.isCreatable(a) && NumberUtils.isCreatable(params.get(0))) { + return new BigDecimal(a).compareTo(new BigDecimal(params.get(0))) < 0; + } + return false; + }; + } + }, + GE("GE", "大于等于", 1) { + @Override + public Predicate filter(List params) { + return a -> { + if (NumberUtils.isCreatable(a) && NumberUtils.isCreatable(params.get(0))) { + return new BigDecimal(a).compareTo(new BigDecimal(params.get(0))) >= 0; + } + return false; + }; + } + }, + LE("LE", "小于等于", 1) { + @Override + public Predicate filter(List params) { + return a -> { + if (NumberUtils.isCreatable(a) && NumberUtils.isCreatable(params.get(0))) { + return new BigDecimal(a).compareTo(new BigDecimal(params.get(0))) <= 0; + } + return false; + }; + } + }, + ISEMPTY("ISEMPTY", "为空", 1) { + @Override + public Predicate filter(List params) { + return StringUtils::isEmpty; + } + }, + ISNOTEMPTY("ISNOTEMPTY", "不为空", 1) { + @Override + public Predicate filter(List params) { + return StringUtils::isNotEmpty; + } + }; + + + FilterEnum(String value, String defaultLabel, int labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + private String value; + + private String defaultLabel; + + private int labelId; + + public abstract Predicate filter(List params); + + + @Override + public String getValue() { + return value; + } + + @Override + public Integer getLabelId() { + return labelId; + } + + @Override + public String getDefaultLabel() { + return defaultLabel; + } + + +} diff --git a/src/com/engine/salary/enums/common/SharedTypeEnum.java b/src/com/engine/salary/enums/common/SharedTypeEnum.java new file mode 100644 index 000000000..286962c24 --- /dev/null +++ b/src/com/engine/salary/enums/common/SharedTypeEnum.java @@ -0,0 +1,48 @@ +package com.engine.salary.enums.common; + +import com.engine.salary.enums.BaseEnum; + +import java.util.Objects; + + +public enum SharedTypeEnum implements BaseEnum { + PRIVATE(1, "私有", 86569), + PUBLIC(0, "共享", 86568); + + private Integer value; + + private String defaultLabel; + + private Integer labelId; + + SharedTypeEnum(Integer value, String defaultLabel, Integer labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + + @Override + public Integer getValue() { + return this.value; + } + + @Override + public Integer getLabelId() { + return this.labelId; + } + + @Override + public String getDefaultLabel() { + return this.defaultLabel; + } + + public static SharedTypeEnum parseByValue(Integer value) { + for (SharedTypeEnum enums : SharedTypeEnum.values()) { + if (Objects.equals(enums.getValue(), value)) { + return enums; + } + } + return PUBLIC; + } +} diff --git a/src/com/engine/salary/enums/datacollection/AttendQuoteFieldSourceTypeEnum.java b/src/com/engine/salary/enums/datacollection/AttendQuoteFieldSourceTypeEnum.java new file mode 100644 index 000000000..f354869a5 --- /dev/null +++ b/src/com/engine/salary/enums/datacollection/AttendQuoteFieldSourceTypeEnum.java @@ -0,0 +1,63 @@ +package com.engine.salary.enums.datacollection; + +import java.util.Arrays; + +/** + * @Description: 考勤引用-来源 + * @Author: wangxiangzhong + * @Date: 2021-11-17 14:37 + */ +public enum AttendQuoteFieldSourceTypeEnum { + DEFAULT(1, "自定义", 87627), + ATTEND(2, "考勤模块", 87626); + + private int value; + + private String defaultLabel; + + private int labelId; + + AttendQuoteFieldSourceTypeEnum(int value, String defaultLabel, int labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + public int getValue() { + return value; + } + + public String getDefaultLabel() { + return defaultLabel; + } + + public int getLabelId() { + return labelId; + } + + public static String getDefaultLabelByValue(Integer value) { + if (value == null) { + return ""; + } + AttendQuoteFieldSourceTypeEnum[] enumAry = AttendQuoteFieldSourceTypeEnum.values(); + for(int i = 0; i < Arrays.asList(enumAry).size(); i++){ + if (Integer.valueOf(enumAry[i].getValue()).equals(value)) { + return enumAry[i].getDefaultLabel(); + } + } + return ""; + } + + public static String getNameByValue(Integer value) { + if (value == null) { + return ""; + } + AttendQuoteFieldSourceTypeEnum[] enumAry = AttendQuoteFieldSourceTypeEnum.values(); + for(int i = 0; i < Arrays.asList(enumAry).size(); i++){ + if (Integer.valueOf(enumAry[i].getValue()).equals(value)) { + return enumAry[i].name(); + } + } + return ""; + } +} diff --git a/src/com/engine/salary/enums/datacollection/AttendQuoteFieldTypeEnum.java b/src/com/engine/salary/enums/datacollection/AttendQuoteFieldTypeEnum.java new file mode 100644 index 000000000..166d0d49a --- /dev/null +++ b/src/com/engine/salary/enums/datacollection/AttendQuoteFieldTypeEnum.java @@ -0,0 +1,50 @@ +package com.engine.salary.enums.datacollection; + +import java.util.Arrays; + +/** + * @Description: 考勤引用-来源 + * @Author: wangxiangzhong + * @Date: 2021-11-17 14:37 + */ +public enum AttendQuoteFieldTypeEnum { + NUMBER(1, "数值", 87625), + TEXT(2, "文本", 85393); + + private int value; + + private String defaultLabel; + + private int labelId; + + AttendQuoteFieldTypeEnum(int value, String defaultLabel, int labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + public int getValue() { + return value; + } + + public String getDefaultLabel() { + return defaultLabel; + } + + public int getLabelId() { + return labelId; + } + + public static String getDefaultLabelByValue(Integer value) { + if (value == null) { + return ""; + } + AttendQuoteFieldTypeEnum[] enumAry = AttendQuoteFieldTypeEnum.values(); + for(int i = 0; i < Arrays.asList(enumAry).size(); i++){ + if (Integer.valueOf(enumAry[i].getValue()).equals(value)) { + return enumAry[i].getDefaultLabel(); + } + } + return ""; + } +} diff --git a/src/com/engine/salary/enums/datacollection/AttendQuoteSourceTypeEnum.java b/src/com/engine/salary/enums/datacollection/AttendQuoteSourceTypeEnum.java new file mode 100644 index 000000000..c9072d4fa --- /dev/null +++ b/src/com/engine/salary/enums/datacollection/AttendQuoteSourceTypeEnum.java @@ -0,0 +1,50 @@ +package com.engine.salary.enums.datacollection; + +import java.util.Arrays; + +/** + * @Description: 考勤引用-来源 + * @Author: wangxiangzhong + * @Date: 2021-11-17 14:37 + */ +public enum AttendQuoteSourceTypeEnum { + QUOTE(1, "引用", 87621), + IMPORT(2, "导入", 87622); + + private int value; + + private String defaultLabel; + + private int labelId; + + AttendQuoteSourceTypeEnum(int value, String defaultLabel, int labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + public int getValue() { + return value; + } + + public String getDefaultLabel() { + return defaultLabel; + } + + public int getLabelId() { + return labelId; + } + + public static String getDefaultLabelByValue(Integer value) { + if (value == null) { + return ""; + } + AttendQuoteSourceTypeEnum[] enumAry = AttendQuoteSourceTypeEnum.values(); + for(int i = 0; i < Arrays.asList(enumAry).size(); i++){ + if (Integer.valueOf(enumAry[i].getValue()).equals(value)) { + return enumAry[i].getDefaultLabel(); + } + } + return ""; + } +} diff --git a/src/com/engine/salary/enums/datacollection/DataCollectionEmployeeTypeEnum.java b/src/com/engine/salary/enums/datacollection/DataCollectionEmployeeTypeEnum.java new file mode 100644 index 000000000..6811ae3fb --- /dev/null +++ b/src/com/engine/salary/enums/datacollection/DataCollectionEmployeeTypeEnum.java @@ -0,0 +1,53 @@ +package com.engine.salary.enums.datacollection; + +import com.engine.salary.enums.BaseEnum; + +import java.util.Arrays; +import java.util.Optional; + +/** + * 人员类型 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public enum DataCollectionEmployeeTypeEnum implements BaseEnum { + + ORGANIZATION(0, "组织架构", 109125), + EXT_EMPLOYEE(1, "非系统人员", 119127), + ; + + private int value; + + private String defaultLabel; + + private int labelId; + + DataCollectionEmployeeTypeEnum(int value, String defaultLabel, int labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + @Override + public Integer getValue() { + return value; + } + + @Override + public Integer getLabelId() { + return labelId; + } + + @Override + public String getDefaultLabel() { + return defaultLabel; + } + + public static String getNameByValue(String value) { + Optional optional = Arrays.stream(DataCollectionEmployeeTypeEnum.values()).filter(r -> r.getValue().toString().equals(value)).findFirst(); + return optional.isPresent() ? optional.get().name() : ""; + } +} diff --git a/src/com/engine/salary/enums/datacollection/UseEmployeeTypeEnum.java b/src/com/engine/salary/enums/datacollection/UseEmployeeTypeEnum.java new file mode 100644 index 000000000..64b0cdde2 --- /dev/null +++ b/src/com/engine/salary/enums/datacollection/UseEmployeeTypeEnum.java @@ -0,0 +1,54 @@ +package com.engine.salary.enums.datacollection; + +import com.engine.salary.enums.BaseEnum; + +import java.util.Arrays; +import java.util.Optional; + +/** + * 人员使用枚举 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public enum UseEmployeeTypeEnum implements BaseEnum { + + ORG(0, "组织架构", 109125), + EXT(1, "非系统人员", 119127), + ALL(2, "所有人员", 119127), + ; + + private int value; + + private String defaultLabel; + + private int labelId; + + UseEmployeeTypeEnum(int value, String defaultLabel, int labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + @Override + public Integer getValue() { + return value; + } + + @Override + public Integer getLabelId() { + return labelId; + } + + @Override + public String getDefaultLabel() { + return defaultLabel; + } + + public static String getNameByValue(String value) { + Optional optional = Arrays.stream(UseEmployeeTypeEnum.values()).filter(r -> r.getValue().toString().equals(value)).findFirst(); + return optional.isPresent() ? optional.get().name() : ""; + } +} diff --git a/src/com/engine/salary/enums/push/PushItemFieldEnum.java b/src/com/engine/salary/enums/push/PushItemFieldEnum.java new file mode 100644 index 000000000..375e21823 --- /dev/null +++ b/src/com/engine/salary/enums/push/PushItemFieldEnum.java @@ -0,0 +1,125 @@ +package com.engine.salary.enums.push; + +import cn.hutool.core.util.NumberUtil; +import com.engine.salary.enums.BaseEnum; +import com.engine.salary.util.SalaryDateUtil; +import org.apache.commons.lang3.StringUtils; + +import java.math.BigDecimal; +import java.util.Arrays; +import java.util.Objects; + +import static com.engine.salary.util.SalaryDateUtil.DATE_FORMATTER_PATTERN; + +/** + * 推送数据来源 + *

Copyright: Copyright (c) 2024

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public enum PushItemFieldEnum implements BaseEnum { + + NUMBER(1, "数值", 87625) { + @Override + public Object convertValue(String value) { + if (NumberUtil.isNumber(value)) { + return new BigDecimal(value).toPlainString(); + } + return "null"; + } + }, + TEXT(2, "文本", 85393) { + @Override + public Object convertValue(String value) { + return String.format("'%s'",value); + } + }, + // DATE(3, "日期", 85393) { +// @Override +// public Object convertValue(String value) { +// +// //to_date('2022-05-10 16:03:02','yyyy-MM-dd HH24:mi:ss') +// return value; +// } +// }, + YEAR(4, "日期文本-年", 85393) { + @Override + public Object convertValue(String value) { + if (StringUtils.isNotBlank(value) && SalaryDateUtil.parse(value, DATE_FORMATTER_PATTERN) != null) { + value = value.substring(0, 4); + } + return String.format("'%s'",value); + } + }, + YEAR_MONTH(5, "日期文本-年月", 85393) { + @Override + public Object convertValue(String value) { + if (StringUtils.isNotBlank(value) && SalaryDateUtil.parse(value, DATE_FORMATTER_PATTERN) != null) { + value = value.substring(0, 7); + } + return String.format("'%s'",value); + } + }, + YEAR_MONTH_DAY(6, "日期文本-年月日", 85393) { + @Override + public Object convertValue(String value) { + if (StringUtils.isNotBlank(value) && SalaryDateUtil.parse(value, DATE_FORMATTER_PATTERN) != null) { + value = value.substring(0, 10); + } + return String.format("'%s'",value); + } + }; + + private int value; + + private String defaultLabel; + + private int labelId; + + PushItemFieldEnum(int value, String defaultLabel, int labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + @Override + public Integer getValue() { + return value; + } + + @Override + public String getDefaultLabel() { + return defaultLabel; + } + + @Override + public Integer getLabelId() { + return labelId; + } + + public abstract Object convertValue(String value); + + public static PushItemFieldEnum parseByValue(int value) { + for (PushItemFieldEnum salaryDataSourceEnum : PushItemFieldEnum.values()) { + if (Objects.equals(salaryDataSourceEnum.getValue(), value)) { + return salaryDataSourceEnum; + } + } + return TEXT; + } + + public static String getDefaultLabelByValue(Integer value) { + if (value == null) { + return ""; + } + PushItemFieldEnum[] enumAry = PushItemFieldEnum.values(); + for (int i = 0; i < Arrays.asList(enumAry).size(); i++) { + if (enumAry[i].getValue().equals(value)) { + return enumAry[i].getDefaultLabel(); + } + } + return ""; + } +} diff --git a/src/com/engine/salary/enums/push/PushRecordDetailStatusEnum.java b/src/com/engine/salary/enums/push/PushRecordDetailStatusEnum.java new file mode 100644 index 000000000..c2d677d42 --- /dev/null +++ b/src/com/engine/salary/enums/push/PushRecordDetailStatusEnum.java @@ -0,0 +1,71 @@ +package com.engine.salary.enums.push; + +import com.engine.salary.enums.BaseEnum; + +import java.util.Arrays; +import java.util.Objects; + +/** + * 推送记录状态 + *

Copyright: Copyright (c) 2024

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public enum PushRecordDetailStatusEnum implements BaseEnum { + PREPARE(0, "待推送", 87625), + SUCCESS(1, "推送成功", 85393), + FAIL(2, "推送失败", 85393), + WITHDRAW_SUCCESS(3, "已撤回", 85393), + WITHDRAW_FAIL(4, "撤回失败", 85393); + + private int value; + + private String defaultLabel; + + private int labelId; + + PushRecordDetailStatusEnum(int value, String defaultLabel, int labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + @Override + public Integer getValue() { + return value; + } + + @Override + public String getDefaultLabel() { + return defaultLabel; + } + + @Override + public Integer getLabelId() { + return labelId; + } + + public static PushRecordDetailStatusEnum parseByValue(int value) { + for (PushRecordDetailStatusEnum salaryDataSourceEnum : PushRecordDetailStatusEnum.values()) { + if (Objects.equals(salaryDataSourceEnum.getValue(), value)) { + return salaryDataSourceEnum; + } + } + return PREPARE; + } + + public static String getDefaultLabelByValue(Integer value) { + if (value == null) { + return ""; + } + PushRecordDetailStatusEnum[] enumAry = PushRecordDetailStatusEnum.values(); + for (int i = 0; i < Arrays.asList(enumAry).size(); i++) { + if (enumAry[i].getValue().equals(value)) { + return enumAry[i].getDefaultLabel(); + } + } + return ""; + } +} diff --git a/src/com/engine/salary/enums/push/PushRecordStatusEnum.java b/src/com/engine/salary/enums/push/PushRecordStatusEnum.java new file mode 100644 index 000000000..3e3ea14c4 --- /dev/null +++ b/src/com/engine/salary/enums/push/PushRecordStatusEnum.java @@ -0,0 +1,74 @@ +package com.engine.salary.enums.push; + +import com.engine.salary.enums.BaseEnum; + +import java.util.Arrays; +import java.util.Objects; + +/** + * 推送记录状态 + *

Copyright: Copyright (c) 2024

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public enum PushRecordStatusEnum implements BaseEnum { + DATA_PREPARE(0, "准备中", 87625), + DATA_FINISH(1, "准备完毕", 87625), + RUN_PROGRESS(2, "推送中", 85393), + RUN_SUCCESS(3, "推送成功", 85393), + RUN_FAIL(4, "推送失败", 85393), + WITHDRAW(5, "撤回中", 85393), + WITHDRAW_SUCCESS(6, "已撤回", 85393), + WITHDRAW_FAIL(7, "撤回失败", 85393); + + private int value; + + private String defaultLabel; + + private int labelId; + + PushRecordStatusEnum(int value, String defaultLabel, int labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + @Override + public Integer getValue() { + return value; + } + + @Override + public String getDefaultLabel() { + return defaultLabel; + } + + @Override + public Integer getLabelId() { + return labelId; + } + + public static PushRecordStatusEnum parseByValue(int value) { + for (PushRecordStatusEnum salaryDataSourceEnum : PushRecordStatusEnum.values()) { + if (Objects.equals(salaryDataSourceEnum.getValue(), value)) { + return salaryDataSourceEnum; + } + } + return DATA_PREPARE; + } + + public static String getDefaultLabelByValue(Integer value) { + if (value == null) { + return ""; + } + PushRecordStatusEnum[] enumAry = PushRecordStatusEnum.values(); + for (int i = 0; i < Arrays.asList(enumAry).size(); i++) { + if (enumAry[i].getValue().equals(value)) { + return enumAry[i].getDefaultLabel(); + } + } + return ""; + } +} diff --git a/src/com/engine/salary/enums/push/PushRecordTypeEnum.java b/src/com/engine/salary/enums/push/PushRecordTypeEnum.java new file mode 100644 index 000000000..9fc79f308 --- /dev/null +++ b/src/com/engine/salary/enums/push/PushRecordTypeEnum.java @@ -0,0 +1,68 @@ +package com.engine.salary.enums.push; + +import com.engine.salary.enums.BaseEnum; + +import java.util.Arrays; +import java.util.Objects; + +/** + * 推送记录状态 + *

Copyright: Copyright (c) 2024

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public enum PushRecordTypeEnum implements BaseEnum { + PUSH(0, "推送", 85393), + WITHDRAW(1, "撤回", 85393); + + private int value; + + private String defaultLabel; + + private int labelId; + + PushRecordTypeEnum(int value, String defaultLabel, int labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + @Override + public Integer getValue() { + return value; + } + + @Override + public String getDefaultLabel() { + return defaultLabel; + } + + @Override + public Integer getLabelId() { + return labelId; + } + + public static PushRecordTypeEnum parseByValue(int value) { + for (PushRecordTypeEnum salaryDataSourceEnum : PushRecordTypeEnum.values()) { + if (Objects.equals(salaryDataSourceEnum.getValue(), value)) { + return salaryDataSourceEnum; + } + } + return null; + } + + public static String getDefaultLabelByValue(Integer value) { + if (value == null) { + return ""; + } + PushRecordTypeEnum[] enumAry = PushRecordTypeEnum.values(); + for (int i = 0; i < Arrays.asList(enumAry).size(); i++) { + if (enumAry[i].getValue().equals(value)) { + return enumAry[i].getDefaultLabel(); + } + } + return ""; + } +} diff --git a/src/com/engine/salary/enums/salaryaccounting/EmployeeTypeEnum.java b/src/com/engine/salary/enums/salaryaccounting/EmployeeTypeEnum.java new file mode 100644 index 000000000..c110eba77 --- /dev/null +++ b/src/com/engine/salary/enums/salaryaccounting/EmployeeTypeEnum.java @@ -0,0 +1,40 @@ +package com.engine.salary.enums.salaryaccounting; + +import com.engine.salary.enums.BaseEnum; + +/** + * 人员类型 + */ +public enum EmployeeTypeEnum implements BaseEnum { + + ORGANIZATION(0, "组织架构", 109125), + EXT_EMPLOYEE(1, "非系统人员", 119127), + ; + + private int value; + + private String defaultLabel; + + private int labelId; + + EmployeeTypeEnum(int value, String defaultLabel, int labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + @Override + public Integer getValue() { + return value; + } + + @Override + public Integer getLabelId() { + return labelId; + } + + @Override + public String getDefaultLabel() { + return defaultLabel; + } +} diff --git a/src/com/engine/salary/enums/salaryaccounting/LockStatusEnum.java b/src/com/engine/salary/enums/salaryaccounting/LockStatusEnum.java new file mode 100644 index 000000000..e7fa758c2 --- /dev/null +++ b/src/com/engine/salary/enums/salaryaccounting/LockStatusEnum.java @@ -0,0 +1,46 @@ +package com.engine.salary.enums.salaryaccounting; + +import com.engine.salary.enums.BaseEnum; + + +public enum LockStatusEnum implements BaseEnum { + LOCK(1, "LOCK", 0), + UNLOCK(0, "UNLOCK", 0); + + private Integer value; + + private String defaultLabel; + + private int labelId; + + + LockStatusEnum(Integer value, String defaultLabel, int labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + @Override + public Integer getValue() { + return value; + } + + @Override + public Integer getLabelId() { + return labelId; + } + + @Override + public String getDefaultLabel() { + return defaultLabel; + } + + public static LockStatusEnum getByValue(Integer value) { + for (LockStatusEnum lockStatusEnum : LockStatusEnum.values()) { + if (lockStatusEnum.getValue().equals(value)) { + return lockStatusEnum; + } + } + return UNLOCK; + } +} diff --git a/src/com/engine/salary/enums/salaryaccounting/SalaryAcctRecordStatusEnum.java b/src/com/engine/salary/enums/salaryaccounting/SalaryAcctRecordStatusEnum.java new file mode 100644 index 000000000..c8e56cb1d --- /dev/null +++ b/src/com/engine/salary/enums/salaryaccounting/SalaryAcctRecordStatusEnum.java @@ -0,0 +1,57 @@ +package com.engine.salary.enums.salaryaccounting; + +import com.engine.salary.enums.BaseEnum; + +import java.util.Objects; + +/** + * 薪资核算的状态 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public enum SalaryAcctRecordStatusEnum implements BaseEnum { + + NOT_ARCHIVED(1, "未归档", 91870), + ARCHIVED(2, "已归档", 91862), + DECLARED(3, "已申报", 100119), + ; + + private int value; + + private String defaultLabel; + + private int labelId; + + SalaryAcctRecordStatusEnum(int value, String defaultLabel, int labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + @Override + public Integer getValue() { + return value; + } + + @Override + public Integer getLabelId() { + return labelId; + } + + @Override + public String getDefaultLabel() { + return defaultLabel; + } + + public static SalaryAcctRecordStatusEnum parseByValue(Integer value) { + for (SalaryAcctRecordStatusEnum salaryAcctRecordStatusEnum : SalaryAcctRecordStatusEnum.values()) { + if (Objects.equals(salaryAcctRecordStatusEnum.getValue(), value)) { + return salaryAcctRecordStatusEnum; + } + } + return null; + } +} diff --git a/src/com/engine/salary/enums/salaryaccounting/SalaryAcctResultDataSourceEnum.java b/src/com/engine/salary/enums/salaryaccounting/SalaryAcctResultDataSourceEnum.java new file mode 100644 index 000000000..e2d498049 --- /dev/null +++ b/src/com/engine/salary/enums/salaryaccounting/SalaryAcctResultDataSourceEnum.java @@ -0,0 +1,56 @@ +package com.engine.salary.enums.salaryaccounting; + +import com.engine.salary.enums.BaseEnum; + +import java.util.Objects; + +/** + * 薪资核算结果的数据来源 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public enum SalaryAcctResultDataSourceEnum implements BaseEnum { + + EDIT(1, "手动编辑", 91870), + IMPORT(2, "导入", 91862) + ; + + private int value; + + private String defaultLabel; + + private int labelId; + + SalaryAcctResultDataSourceEnum(int value, String defaultLabel, int labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + @Override + public Integer getValue() { + return value; + } + + @Override + public Integer getLabelId() { + return labelId; + } + + @Override + public String getDefaultLabel() { + return defaultLabel; + } + + public static SalaryAcctResultDataSourceEnum parseByValue(Integer value) { + for (SalaryAcctResultDataSourceEnum SalaryAcctResultDataSourceEnum : SalaryAcctResultDataSourceEnum.values()) { + if (Objects.equals(SalaryAcctResultDataSourceEnum.getValue(), value)) { + return SalaryAcctResultDataSourceEnum; + } + } + return null; + } +} diff --git a/src/com/engine/salary/enums/salaryarchive/ArchiveStatusEnum.java b/src/com/engine/salary/enums/salaryarchive/ArchiveStatusEnum.java new file mode 100644 index 000000000..b927d3eb6 --- /dev/null +++ b/src/com/engine/salary/enums/salaryarchive/ArchiveStatusEnum.java @@ -0,0 +1,42 @@ +package com.engine.salary.enums.salaryarchive; + +import com.engine.salary.enums.BaseEnum; + +/** + * 薪资档案-状态 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public enum ArchiveStatusEnum implements BaseEnum { + + EFFICIENT("EFFICIENT", "有效", 93335), + ARCHIVE("ARCHIVE", "封存", 93336); + + private String value; + + private String defaultLabel; + + private int labelId; + + ArchiveStatusEnum(String value, String defaultLabel, int labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + public String getValue() { + return value; + } + + public String getDefaultLabel() { + return defaultLabel; + } + + public Integer getLabelId() { + return labelId; + } + +} diff --git a/src/com/engine/salary/enums/salaryarchive/IndividualTaxWithholdingAgentStatusEnum.java b/src/com/engine/salary/enums/salaryarchive/IndividualTaxWithholdingAgentStatusEnum.java new file mode 100644 index 000000000..76410323f --- /dev/null +++ b/src/com/engine/salary/enums/salaryarchive/IndividualTaxWithholdingAgentStatusEnum.java @@ -0,0 +1,48 @@ +package com.engine.salary.enums.salaryarchive; + +import java.util.Arrays; + + +public enum IndividualTaxWithholdingAgentStatusEnum { + + UN_VALIDATE(0, "未校验", 85255), + VALIDATE_SUCCESS(1, "校验成功", 85256), + VALIDATE_FAIL(2, "校验失败", 85257); + + private int value; + + private String defaultLabel; + + private int labelId; + + IndividualTaxWithholdingAgentStatusEnum(int value, String defaultLabel, int labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + public int getValue() { + return value; + } + + public String getDefaultLabel() { + return defaultLabel; + } + + public int getLabelId() { + return labelId; + } + + public static String getDefaultLabelByValue(Integer value) { + if (value == null) { + return ""; + } + IndividualTaxWithholdingAgentStatusEnum[] enumAry = IndividualTaxWithholdingAgentStatusEnum.values(); + for(int i = 0; i < Arrays.asList(enumAry).size(); i++){ + if (Integer.valueOf(enumAry[i].getValue()).equals(value)) { + return enumAry[i].getDefaultLabel(); + } + } + return ""; + } +} diff --git a/src/com/engine/salary/enums/salaryarchive/SalaryArchiveAddTypeEnum.java b/src/com/engine/salary/enums/salaryarchive/SalaryArchiveAddTypeEnum.java new file mode 100644 index 000000000..0983e7b9c --- /dev/null +++ b/src/com/engine/salary/enums/salaryarchive/SalaryArchiveAddTypeEnum.java @@ -0,0 +1,43 @@ +package com.engine.salary.enums.salaryarchive; + + +/** + * 薪资档案-定薪类型 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public enum SalaryArchiveAddTypeEnum { + + INDUCTION(0, "入职", 85901), + REHIRE(2, "返聘", 109535), + TAXAGENTADJUST(1, "调整个税扣缴义务人", 93910); + + private int value; + + private String defaultLabel; + + private int labelId; + + SalaryArchiveAddTypeEnum(int value, String defaultLabel, int labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + public int getValue() { + return value; + } + + public String getDefaultLabel() { + return defaultLabel; + } + + public int getLabelId() { + return labelId; + } + + +} diff --git a/src/com/engine/salary/enums/salaryarchive/SalaryArchiveAdjustRecordTypeEnum.java b/src/com/engine/salary/enums/salaryarchive/SalaryArchiveAdjustRecordTypeEnum.java new file mode 100644 index 000000000..6fd513664 --- /dev/null +++ b/src/com/engine/salary/enums/salaryarchive/SalaryArchiveAdjustRecordTypeEnum.java @@ -0,0 +1,26 @@ +package com.engine.salary.enums.salaryarchive; + +/** + * 薪资档案调薪记录列表类型 + *

Copyright: Copyright (c) 2023

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public enum SalaryArchiveAdjustRecordTypeEnum { + + MYADJUSTRECORD("myAdjustRecordList"), + ADJUSTRECORD("adjustRecordList"), + ADJUSTRECORDFORDELETE("adjustRecordForDeleteList"); + + private String pageUid; + + SalaryArchiveAdjustRecordTypeEnum(String pageUid) { + this.pageUid = pageUid; + } + + public String getPageUid() { + return pageUid; + } +} diff --git a/src/com/engine/salary/enums/salaryarchive/SalaryArchiveAdjustWayEnum.java b/src/com/engine/salary/enums/salaryarchive/SalaryArchiveAdjustWayEnum.java new file mode 100644 index 000000000..f46f5df5c --- /dev/null +++ b/src/com/engine/salary/enums/salaryarchive/SalaryArchiveAdjustWayEnum.java @@ -0,0 +1,25 @@ +package com.engine.salary.enums.salaryarchive; + +/** + * @Description: 薪资档案-调薪方式 + * @Author: wangxiangzhong + * @Date: 2022/4/11 19:46 + */ +public enum SalaryArchiveAdjustWayEnum { + // 单个调薪 + SINGLE(1), + // 导入调薪 + IMPORT(2), + // 批量调薪 + BATCH(3); + + private Integer value; + + SalaryArchiveAdjustWayEnum(int value) { + this.value = value; + } + + public Integer getValue() { + return value; + } +} diff --git a/src/com/engine/salary/enums/salaryarchive/SalaryArchiveDimissionTimeIntervalEnum.java b/src/com/engine/salary/enums/salaryarchive/SalaryArchiveDimissionTimeIntervalEnum.java new file mode 100644 index 000000000..54ae7860d --- /dev/null +++ b/src/com/engine/salary/enums/salaryarchive/SalaryArchiveDimissionTimeIntervalEnum.java @@ -0,0 +1,41 @@ +package com.engine.salary.enums.salaryarchive; + +/** + * @Description: 已离职时段 + * @Author: wangxiangzhong + * @Date: 2021/12/13 18:56 + */ +public enum SalaryArchiveDimissionTimeIntervalEnum { + + HALFMONTH("HALFMONTH", "半个月", 93335), + ONEMONTH("ONEMONTH", "一个月", 93336), + TWOMONTH("TWOMONTH", "两个月", 93337), + THREEMONTH("THREEMONTH", "三个月", 93338), + FOURMONTH("FOURMONTH", "四个月", 93339), + FIVEMONTH("FIVEMONTH", "五个月", 93340), + HALFYEAR("HALFYEAR", "半年", 93341); + + private String value; + + private String defaultLabel; + + private int labelId; + + SalaryArchiveDimissionTimeIntervalEnum(String value, String defaultLabel, int labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + public String getValue() { + return value; + } + + public String getDefaultLabel() { + return defaultLabel; + } + + public int getLabelId() { + return labelId; + } +} diff --git a/src/com/engine/salary/enums/salaryarchive/SalaryArchiveFieldTypeEnum.java b/src/com/engine/salary/enums/salaryarchive/SalaryArchiveFieldTypeEnum.java new file mode 100644 index 000000000..6ef302e20 --- /dev/null +++ b/src/com/engine/salary/enums/salaryarchive/SalaryArchiveFieldTypeEnum.java @@ -0,0 +1,58 @@ +package com.engine.salary.enums.salaryarchive; + +import com.engine.salary.enums.BaseEnum; +import com.engine.salary.util.SalaryI18nUtil; + +import java.util.Arrays; +import java.util.Optional; + +/** + * 薪资项目的字段类型 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public enum SalaryArchiveFieldTypeEnum implements BaseEnum { + NUMBER("number", "数值", 87625), + STRING("string", "字符", 105093), + ; + + private String value; + + private String defaultLabel; + + private int labelId; + + SalaryArchiveFieldTypeEnum(String value, String defaultLabel, int labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + @Override + public String getValue() { + return this.value; + } + + @Override + public Integer getLabelId() { + return this.labelId; + } + + @Override + public String getDefaultLabel() { + return this.defaultLabel; + } + + public static String getDefaultLabelByValue(String value, Long employeeId, String tenantKey) { + Optional optional = Arrays.stream(SalaryArchiveFieldTypeEnum.values()).filter(r->r.getValue().equals(value)).findFirst(); + return optional.isPresent()? SalaryI18nUtil.getI18nLabel(optional.get().getLabelId(), optional.get().getDefaultLabel()):""; + } + + public static String getNameByValue(String value) { + Optional optional = Arrays.stream(SalaryArchiveFieldTypeEnum.values()).filter(r->r.getValue().equals(value)).findFirst(); + return optional.map(Enum::name).orElse(""); + } +} diff --git a/src/com/engine/salary/enums/salaryarchive/SalaryArchiveImportTypeEnum.java b/src/com/engine/salary/enums/salaryarchive/SalaryArchiveImportTypeEnum.java new file mode 100644 index 000000000..aa2d2a838 --- /dev/null +++ b/src/com/engine/salary/enums/salaryarchive/SalaryArchiveImportTypeEnum.java @@ -0,0 +1,51 @@ +package com.engine.salary.enums.salaryarchive; + +import org.apache.commons.lang3.StringUtils; + +/** + * 薪资档案导入类型 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public enum SalaryArchiveImportTypeEnum { + + SALARYITEMADJUST("salaryItemAdjust", "调薪", 85985), + TAXAGENTADJUST("taxAgentAdjust", "调整个税扣缴义务人", 93910), + INIT("init", "档案初始化", 101600); + + private String value; + + private String defaultLabel; + + private int labelId; + + SalaryArchiveImportTypeEnum(String value, String defaultLabel, int labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + public String getValue() { + return value; + } + + public String getDefaultLabel() { + return defaultLabel; + } + + public int getLabelId() { + return labelId; + } + + public static SalaryArchiveImportTypeEnum parseByValue(String value) { + for (SalaryArchiveImportTypeEnum enums : SalaryArchiveImportTypeEnum.values()) { + if (StringUtils.equals(enums.getValue(), value)) { + return enums; + } + } + return null; + } +} diff --git a/src/com/engine/salary/enums/salaryarchive/SalaryArchiveItemAdjustReasonEnum.java b/src/com/engine/salary/enums/salaryarchive/SalaryArchiveItemAdjustReasonEnum.java new file mode 100644 index 000000000..626635040 --- /dev/null +++ b/src/com/engine/salary/enums/salaryarchive/SalaryArchiveItemAdjustReasonEnum.java @@ -0,0 +1,88 @@ +package com.engine.salary.enums.salaryarchive; + +import com.engine.salary.enums.BaseEnum; +import com.engine.salary.util.SalaryI18nUtil; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * 薪资档案-薪资项目调整原因 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public enum SalaryArchiveItemAdjustReasonEnum implements BaseEnum { + + ONBOARD("ONBOARD", "入职", 85901), + PROBATION_REVIEW("PROBATION_REVIEW", "转正", 85984), + SALARY_ADJUSTMENT("SALARY_ADJUSTMENT", "调薪", 85985), + PROMOTION("PROMOTION", "晋升", 85985), + DEMOTION("DEMOTION", "降职", 85985), + JOB_TRANSFER("JOB_TRANSFER", "调岗", 85985), + POSITION_OR_SALARY_ADJUSTMENT("POSITION_OR_SALARY_ADJUSTMENT", "调岗调薪", 85986), + DIMISSION("DIMISSION", "离职", 85902), + OTHER("OTHER", "其他", 84500), + INIT("INIT", "初始化", 85903); + + private String value; + + private String defaultLabel; + + private int labelId; + + SalaryArchiveItemAdjustReasonEnum(String value, String defaultLabel, int labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + public String getValue() { + return value; + } + + public String getDefaultLabel() { + return defaultLabel; + } + + public Integer getLabelId() { + return labelId; + } + + public static String getValueByDefaultLabel(String defaultLabel) { + if (defaultLabel == null) { + return ""; + } + SalaryArchiveItemAdjustReasonEnum[] enumAry = SalaryArchiveItemAdjustReasonEnum.values(); + for(int i = 0; i < Arrays.asList(enumAry).size(); i++){ + if (enumAry[i].getDefaultLabel().equals(defaultLabel)) { + return enumAry[i].getValue(); + } + } + return ""; + } + public static String getDefaultLabelByValue(String value) { + Optional optionalAdjustReason = Arrays.stream(SalaryArchiveItemAdjustReasonEnum.values()).filter(r->r.getValue().equals(value)).findFirst(); + return optionalAdjustReason.isPresent()? SalaryI18nUtil.getI18nLabel(optionalAdjustReason.get().getLabelId(), optionalAdjustReason.get().getDefaultLabel()):""; + } + + public static SalaryArchiveItemAdjustReasonEnum parseByValue(String value) { + for (SalaryArchiveItemAdjustReasonEnum optionalAdjustReason : SalaryArchiveItemAdjustReasonEnum.values()) { + if (Objects.equals(optionalAdjustReason.getValue(), value)) { + return optionalAdjustReason; + } + } + return null; + } + + public static List> getList(){ + return Arrays.stream(SalaryArchiveItemAdjustReasonEnum.values()).map(e -> { + Map map = new HashMap<>(); + map.put("id", e.getValue()); + map.put("content", e.getDefaultLabel()); + return map; + }).collect(Collectors.toList()); + } +} diff --git a/src/com/engine/salary/enums/salaryarchive/SalaryArchiveListTypeEnum.java b/src/com/engine/salary/enums/salaryarchive/SalaryArchiveListTypeEnum.java new file mode 100644 index 000000000..014bb4052 --- /dev/null +++ b/src/com/engine/salary/enums/salaryarchive/SalaryArchiveListTypeEnum.java @@ -0,0 +1,53 @@ +package com.engine.salary.enums.salaryarchive; + +import org.apache.commons.lang3.StringUtils; + +/** + * 薪资档案列表类型 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public enum SalaryArchiveListTypeEnum { + + PENDING("PENDING", "待定薪", 107875), + FIXED("FIXED", "发薪", 109713), + SUSPEND("SUSPEND", "待停薪", 107879), + STOP("STOP", "停薪", 109348), + EXT("EXT", "非系统人员", 109348); + + private String value; + + private String defaultLabel; + + private int labelId; + + SalaryArchiveListTypeEnum(String value, String defaultLabel, int labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + public String getValue() { + return value; + } + + public String getDefaultLabel() { + return defaultLabel; + } + + public int getLabelId() { + return labelId; + } + + public static SalaryArchiveListTypeEnum parseByValue(String value) { + for (SalaryArchiveListTypeEnum enums : SalaryArchiveListTypeEnum.values()) { + if (StringUtils.equals(enums.getValue(), value)) { + return enums; + } + } + return null; + } +} diff --git a/src/com/engine/salary/enums/salaryarchive/SalaryArchiveStatusEnum.java b/src/com/engine/salary/enums/salaryarchive/SalaryArchiveStatusEnum.java new file mode 100644 index 000000000..882d6680c --- /dev/null +++ b/src/com/engine/salary/enums/salaryarchive/SalaryArchiveStatusEnum.java @@ -0,0 +1,46 @@ +package com.engine.salary.enums.salaryarchive; + +import java.util.Objects; + +/** + * 薪资档案状态 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public enum SalaryArchiveStatusEnum { + + PENDING("PENDING", "待定薪"), + FIXED("FIXED", "发薪"), + SUSPEND("SUSPEND", "待停薪"), + STOP_FROM_PENDING("STOP_FROM_PENDING", "停薪_来自待定薪"), + STOP_FROM_SUSPEND("STOP_FROM_SUSPEND", "停薪_来自待停薪"); + + private String value; + + private String defaultLabel; + + SalaryArchiveStatusEnum(String value, String defaultLabel) { + this.value = value; + this.defaultLabel = defaultLabel; + } + + public String getValue() { + return value; + } + + public String getDefaultLabel() { + return defaultLabel; + } + + public static SalaryArchiveStatusEnum parseByValue(String value) { + for (SalaryArchiveStatusEnum salaryArchiveStatusEnum : SalaryArchiveStatusEnum.values()) { + if (Objects.equals(salaryArchiveStatusEnum.getValue(), value)) { + return salaryArchiveStatusEnum; + } + } + return null; + } +} diff --git a/src/com/engine/salary/enums/salaryarchive/SalaryArchiveTaxAgentAdjustReasonEnum.java b/src/com/engine/salary/enums/salaryarchive/SalaryArchiveTaxAgentAdjustReasonEnum.java new file mode 100644 index 000000000..126bfee59 --- /dev/null +++ b/src/com/engine/salary/enums/salaryarchive/SalaryArchiveTaxAgentAdjustReasonEnum.java @@ -0,0 +1,68 @@ +package com.engine.salary.enums.salaryarchive; + +import com.engine.salary.util.SalaryI18nUtil; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * 薪资档案-个税扣缴义务人调整原因 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public enum SalaryArchiveTaxAgentAdjustReasonEnum { + + ADJUSTMENT("ADJUSTMENT", "调动", 85899), + CHANGE("CHANGE", "变更", 85900), + ONBOARD("ONBOARD", "入职", 85901), + DIMISSION("DIMISSION", "离职", 85902), + OTHER("OTHER", "其他", 84500), + INIT("INIT", "初始化", 85903); + + private String value; + + private String defaultLabel; + + private int labelId; + + SalaryArchiveTaxAgentAdjustReasonEnum(String value, String defaultLabel, int labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + public String getValue() { + return value; + } + + public String getDefaultLabel() { + return defaultLabel; + } + + public int getLabelId() { + return labelId; + } + + public static String getValueByDefaultLabel(String defaultLabel) { + Optional optionalAdjustReason = Arrays.stream(SalaryArchiveTaxAgentAdjustReasonEnum.values()).filter(r->SalaryI18nUtil.getI18nLabel(r.getLabelId(), r.getDefaultLabel()).equals(defaultLabel)).findFirst(); + return optionalAdjustReason.isPresent()?optionalAdjustReason.get().getValue():""; + } + + public static String getDefaultLabelByValue(String value) { + Optional optionalAdjustReason = Arrays.stream(SalaryArchiveTaxAgentAdjustReasonEnum.values()).filter(r->r.getValue().equals(value)).findFirst(); + return optionalAdjustReason.isPresent()? SalaryI18nUtil.getI18nLabel(optionalAdjustReason.get().getLabelId(), optionalAdjustReason.get().getDefaultLabel()):""; + } + + public static List> getList(){ + return Arrays.stream(SalaryArchiveTaxAgentAdjustReasonEnum.values()).map(e -> { + Map map = new HashMap<>(); + map.put("id", e.getValue()); + map.put("content", e.getDefaultLabel()); + return map; + }).collect(Collectors.toList()); + } + +} diff --git a/src/com/engine/salary/enums/salarybill/BillConfimStatusEnum.java b/src/com/engine/salary/enums/salarybill/BillConfimStatusEnum.java new file mode 100644 index 000000000..2a1626532 --- /dev/null +++ b/src/com/engine/salary/enums/salarybill/BillConfimStatusEnum.java @@ -0,0 +1,71 @@ +package com.engine.salary.enums.salarybill; + +import com.engine.salary.enums.BaseEnum; + +import java.util.Arrays; + +/** + * @ClassName BillConfimStatusEnum + * @author Harryxzy + * @date 2023/7/10 17:03 + * @description 工资单确认 + */ +public enum BillConfimStatusEnum implements BaseEnum { + + UNCONFIRMED(0, "未确认", 93286), + CONFIRMED(1, "已确认", 93212), + FEEDBACK(2, "已反馈", 0); + + private final int value; + + private final String defaultLabel; + + private final int labelId; + + BillConfimStatusEnum(int value, String defaultLabel, int labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + @Override + public Integer getValue() { + return value; + } + + @Override + public String getDefaultLabel() { + return defaultLabel; + } + + @Override + public Integer getLabelId() { + return labelId; + } + + public static String getDefaultLabelByValue(Integer value) { + if (value == null) { + return ""; + } + BillConfimStatusEnum[] enumAry = BillConfimStatusEnum.values(); + for(int i = 0; i < Arrays.asList(enumAry).size(); i++){ + if (enumAry[i].getValue().equals(value)) { + return enumAry[i].getDefaultLabel(); + } + } + return ""; + } + + public static String getNameByValue(Integer value) { + if (value == null) { + return ""; + } + BillConfimStatusEnum[] enumAry = BillConfimStatusEnum.values(); + for(int i = 0; i < Arrays.asList(enumAry).size(); i++){ + if (enumAry[i].getValue().equals(value)) { + return enumAry[i].name(); + } + } + return ""; + } +} diff --git a/src/com/engine/salary/enums/salarybill/BillReadStatusEnum.java b/src/com/engine/salary/enums/salarybill/BillReadStatusEnum.java new file mode 100644 index 000000000..09fd47107 --- /dev/null +++ b/src/com/engine/salary/enums/salarybill/BillReadStatusEnum.java @@ -0,0 +1,70 @@ +package com.engine.salary.enums.salarybill; + +import com.engine.salary.enums.BaseEnum; + +import java.util.Arrays; + +/** + * @ClassName BillReadStatusEnum + * @author Harryxzy + * @date 2023/7/10 17:13 + * @description 工资单查看 + */ +public enum BillReadStatusEnum implements BaseEnum { + + UNREAD(0, "未查看", 93286), + READED(1, "已查看", 93212); + + private int value; + + private String defaultLabel; + + private int labelId; + + BillReadStatusEnum(int value, String defaultLabel, int labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + @Override + public Integer getValue() { + return value; + } + + @Override + public String getDefaultLabel() { + return defaultLabel; + } + + @Override + public Integer getLabelId() { + return labelId; + } + + public static String getDefaultLabelByValue(Integer value) { + if (value == null) { + return ""; + } + BillReadStatusEnum[] enumAry = BillReadStatusEnum.values(); + for(int i = 0; i < Arrays.asList(enumAry).size(); i++){ + if (Integer.valueOf(enumAry[i].getValue()).equals(value)) { + return enumAry[i].getDefaultLabel(); + } + } + return ""; + } + + public static String getNameByValue(Integer value) { + if (value == null) { + return ""; + } + BillReadStatusEnum[] enumAry = BillReadStatusEnum.values(); + for(int i = 0; i < Arrays.asList(enumAry).size(); i++){ + if (Integer.valueOf(enumAry[i].getValue()).equals(value)) { + return enumAry[i].name(); + } + } + return ""; + } +} diff --git a/src/com/engine/salary/enums/salarybill/MessageChannelEnum.java b/src/com/engine/salary/enums/salarybill/MessageChannelEnum.java new file mode 100644 index 000000000..164d0e168 --- /dev/null +++ b/src/com/engine/salary/enums/salarybill/MessageChannelEnum.java @@ -0,0 +1,73 @@ +package com.engine.salary.enums.salarybill; + +import com.engine.salary.enums.BaseEnum; + +import java.util.Arrays; + +/** + * 消息通道 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public enum MessageChannelEnum implements BaseEnum { + + MSG(0, "系统消息", 93212), + EMAIL(1, "邮件", 93286), + SMS(2, "短信", 93287); + + private int value; + + private String defaultLabel; + + private int labelId; + + MessageChannelEnum(int value, String defaultLabel, int labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + @Override + public Integer getValue() { + return value; + } + + @Override + public String getDefaultLabel() { + return defaultLabel; + } + + @Override + public Integer getLabelId() { + return labelId; + } + + public static String getDefaultLabelByValue(Integer value) { + if (value == null) { + return ""; + } + MessageChannelEnum[] enumAry = MessageChannelEnum.values(); + for(int i = 0; i < Arrays.asList(enumAry).size(); i++){ + if (Integer.valueOf(enumAry[i].getValue()).equals(value)) { + return enumAry[i].getDefaultLabel(); + } + } + return ""; + } + + public static String getNameByValue(Integer value) { + if (value == null) { + return ""; + } + MessageChannelEnum[] enumAry = MessageChannelEnum.values(); + for(int i = 0; i < Arrays.asList(enumAry).size(); i++){ + if (Integer.valueOf(enumAry[i].getValue()).equals(value)) { + return enumAry[i].name(); + } + } + return ""; + } +} diff --git a/src/com/engine/salary/enums/salarybill/MonthTypeEnum.java b/src/com/engine/salary/enums/salarybill/MonthTypeEnum.java new file mode 100644 index 000000000..ea6f8b34a --- /dev/null +++ b/src/com/engine/salary/enums/salarybill/MonthTypeEnum.java @@ -0,0 +1,82 @@ +package com.engine.salary.enums.salarybill; + +import com.engine.salary.enums.BaseEnum; + +import java.util.Arrays; +import java.util.Objects; + +/** + * 工资单限制月份类型 + *

Copyright: Copyright (c) 2024

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public enum MonthTypeEnum implements BaseEnum { + + SALARY_DATE(0, "薪资所属月", 93286), + SEND_DATE(1, "发放日期", 93212); + + private int value; + + private String defaultLabel; + + private int labelId; + + MonthTypeEnum(int value, String defaultLabel, int labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + @Override + public Integer getValue() { + return value; + } + + @Override + public String getDefaultLabel() { + return defaultLabel; + } + + @Override + public Integer getLabelId() { + return labelId; + } + + public static String getDefaultLabelByValue(Integer value) { + if (value == null) { + return ""; + } + MonthTypeEnum[] enumAry = MonthTypeEnum.values(); + for(int i = 0; i < Arrays.asList(enumAry).size(); i++){ + if (Integer.valueOf(enumAry[i].getValue()).equals(value)) { + return enumAry[i].getDefaultLabel(); + } + } + return ""; + } + + public static String getNameByValue(Integer value) { + if (value == null) { + return ""; + } + MonthTypeEnum[] enumAry = MonthTypeEnum.values(); + for(int i = 0; i < Arrays.asList(enumAry).size(); i++){ + if (Integer.valueOf(enumAry[i].getValue()).equals(value)) { + return enumAry[i].name(); + } + } + return ""; + } + + public static MonthTypeEnum parseByValue(int value) { + for (MonthTypeEnum e : MonthTypeEnum.values()) { + if (Objects.equals(e.getValue(), value)) { + return e; + } + } + return SALARY_DATE; + } +} diff --git a/src/com/engine/salary/enums/salarybill/SalarySendStatusEnum.java b/src/com/engine/salary/enums/salarybill/SalarySendStatusEnum.java new file mode 100644 index 000000000..85624f462 --- /dev/null +++ b/src/com/engine/salary/enums/salarybill/SalarySendStatusEnum.java @@ -0,0 +1,65 @@ +package com.engine.salary.enums.salarybill; + +import com.engine.salary.enums.BaseEnum; + +import java.util.Arrays; + +public enum SalarySendStatusEnum implements BaseEnum { + + UNSEND(0, "未发放", 93286), + ALREADYSEND(1, "已发放", 93212), + WITHDRAW(2, "已撤回", 93287); + + private int value; + + private String defaultLabel; + + private int labelId; + + SalarySendStatusEnum(int value, String defaultLabel, int labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + @Override + public Integer getValue() { + return value; + } + + @Override + public String getDefaultLabel() { + return defaultLabel; + } + + @Override + public Integer getLabelId() { + return labelId; + } + + public static String getDefaultLabelByValue(Integer value) { + if (value == null) { + return ""; + } + SalarySendStatusEnum[] enumAry = SalarySendStatusEnum.values(); + for(int i = 0; i < Arrays.asList(enumAry).size(); i++){ + if (Integer.valueOf(enumAry[i].getValue()).equals(value)) { + return enumAry[i].getDefaultLabel(); + } + } + return ""; + } + + public static String getNameByValue(Integer value) { + if (value == null) { + return ""; + } + SalarySendStatusEnum[] enumAry = SalarySendStatusEnum.values(); + for(int i = 0; i < Arrays.asList(enumAry).size(); i++){ + if (Integer.valueOf(enumAry[i].getValue()).equals(value)) { + return enumAry[i].name(); + } + } + return ""; + } +} diff --git a/src/com/engine/salary/enums/salarybill/SalaryTemplateReplenishRuleEnum.java b/src/com/engine/salary/enums/salarybill/SalaryTemplateReplenishRuleEnum.java new file mode 100644 index 000000000..0ff3b9b3b --- /dev/null +++ b/src/com/engine/salary/enums/salarybill/SalaryTemplateReplenishRuleEnum.java @@ -0,0 +1,38 @@ +package com.engine.salary.enums.salarybill; + +/** + * @author Harryxzy + * @date 2022/12/02 15:44 + * @description 补发工资名单规则 + */ +public enum SalaryTemplateReplenishRuleEnum { + + ALL("ALL", "全部", 85155), + + BYRULE("BYRULE", "按规则", 138972); + + private String value; + + private String defaultLabel; + + private int labelId; + + SalaryTemplateReplenishRuleEnum(String value, String defaultLabel, int labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + public String getValue() { + return value; + } + + public String getDefaultLabel() { + return defaultLabel; + } + + public int getLabelId() { + return labelId; + } + +} diff --git a/src/com/engine/salary/enums/salarybill/SalaryTemplateTextContentPositionEnum.java b/src/com/engine/salary/enums/salarybill/SalaryTemplateTextContentPositionEnum.java new file mode 100644 index 000000000..0a827320b --- /dev/null +++ b/src/com/engine/salary/enums/salarybill/SalaryTemplateTextContentPositionEnum.java @@ -0,0 +1,30 @@ +package com.engine.salary.enums.salarybill; + +public enum SalaryTemplateTextContentPositionEnum { + BEFORE(1, "薪资项目前", 92937), + AFTER(2, "薪资项目后", 92938); + + private int value; + + private String defaultLabel; + + private int labelId; + + SalaryTemplateTextContentPositionEnum(int value, String defaultLabel, int labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + public int getValue() { + return value; + } + + public String getDefaultLabel() { + return defaultLabel; + } + + public int getLabelId() { + return labelId; + } +} diff --git a/src/com/engine/salary/enums/salarybill/SalaryTemplateVarEnum.java b/src/com/engine/salary/enums/salarybill/SalaryTemplateVarEnum.java new file mode 100644 index 000000000..01592b9a0 --- /dev/null +++ b/src/com/engine/salary/enums/salarybill/SalaryTemplateVarEnum.java @@ -0,0 +1,32 @@ +package com.engine.salary.enums.salarybill; + +public enum SalaryTemplateVarEnum { + + SALARYYEARMONTH("SALARYYEARMONTH", "薪资所属月", 87614), + SALARY_YEAR("SALARY_YEAR", "薪资所属年", 92936), + CORPORATENAME("CORPORATENAME", "公司名称", 92936); + + private String value; + + private String defaultLabel; + + private int labelId; + + SalaryTemplateVarEnum(String value, String defaultLabel, int labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + public String getValue() { + return value; + } + + public String getDefaultLabel() { + return defaultLabel; + } + + public int getLabelId() { + return labelId; + } +} diff --git a/src/com/engine/salary/enums/salarybill/SalaryTemplateWatermarkTypeEnum.java b/src/com/engine/salary/enums/salarybill/SalaryTemplateWatermarkTypeEnum.java new file mode 100644 index 000000000..ff054639d --- /dev/null +++ b/src/com/engine/salary/enums/salarybill/SalaryTemplateWatermarkTypeEnum.java @@ -0,0 +1,33 @@ +package com.engine.salary.enums.salarybill; + +import com.engine.salary.enums.BaseEnum; + +public enum SalaryTemplateWatermarkTypeEnum implements BaseEnum { + + DEFAULT("DEFAULT", "系统默认水印", 220057), + CUSTOM("CUSTOM", "自定义水印", 220058); + + private String value; + + private String defaultLabel; + + private int labelId; + + SalaryTemplateWatermarkTypeEnum(String value, String defaultLabel, int labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + public String getValue() { + return value; + } + + public String getDefaultLabel() { + return defaultLabel; + } + + public Integer getLabelId() { + return labelId; + } +} diff --git a/src/com/engine/salary/enums/salarybill/SalaryTemplateWhetherEnum.java b/src/com/engine/salary/enums/salarybill/SalaryTemplateWhetherEnum.java new file mode 100644 index 000000000..87dd585fa --- /dev/null +++ b/src/com/engine/salary/enums/salarybill/SalaryTemplateWhetherEnum.java @@ -0,0 +1,45 @@ +package com.engine.salary.enums.salarybill; + +import java.util.Arrays; + +public enum SalaryTemplateWhetherEnum { + TRUE(1, "是", 84967), + FALSE(0, "否", 84968); + + private int value; + + private String defaultLabel; + + private int labelId; + + SalaryTemplateWhetherEnum(int value, String defaultLabel, int labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + public Integer getValue() { + return value; + } + + public String getDefaultLabel() { + return defaultLabel; + } + + public Integer getLabelId() { + return labelId; + } + + public static String getNameByValue(Integer value) { + if (value == null) { + return ""; + } + SalaryTemplateWhetherEnum[] enumAry = SalaryTemplateWhetherEnum.values(); + for(int i = 0; i < Arrays.asList(enumAry).size(); i++){ + if (Integer.valueOf(enumAry[i].getValue()).equals(value)) { + return enumAry[i].name(); + } + } + return ""; + } +} diff --git a/src/com/engine/salary/enums/salaryformula/FormulaVarFieldTypeEnum.java b/src/com/engine/salary/enums/salaryformula/FormulaVarFieldTypeEnum.java new file mode 100644 index 000000000..661f34dbc --- /dev/null +++ b/src/com/engine/salary/enums/salaryformula/FormulaVarFieldTypeEnum.java @@ -0,0 +1,31 @@ +package com.engine.salary.enums.salaryformula; + +import java.util.Arrays; +import java.util.Objects; + +public enum FormulaVarFieldTypeEnum { + NUMBER("number", "数值"), + STRING("string", "字符"); + + private String value; + + private String label; + + FormulaVarFieldTypeEnum(String value, String label) { + this.value = value; + this.label = label; + } + + public String getValue() { + return value; + } + + public String getLabel() { + return label; + } + + + public static FormulaVarFieldTypeEnum parseByValue(String value) { + return Arrays.stream(FormulaVarFieldTypeEnum.values()).filter(typeEnum -> Objects.equals(typeEnum.getValue(), value)).findFirst().orElse(null); + } +} diff --git a/src/com/engine/salary/enums/salaryformula/ReferenceTypeEnum.java b/src/com/engine/salary/enums/salaryformula/ReferenceTypeEnum.java new file mode 100644 index 000000000..081d19165 --- /dev/null +++ b/src/com/engine/salary/enums/salaryformula/ReferenceTypeEnum.java @@ -0,0 +1,32 @@ +package com.engine.salary.enums.salaryformula; + +import java.util.Arrays; +import java.util.Objects; + +public enum ReferenceTypeEnum { + FORMULA("formula", "公式"), + SQL("sql", "SQL"), + BackCalc("backCalc", "回算"); + + private String value; + + private String label; + + ReferenceTypeEnum(String value, String label) { + this.value = value; + this.label = label; + } + + public String getValue() { + return value; + } + + public String getLabel() { + return label; + } + + + public static ReferenceTypeEnum parseByValue(String value) { + return Arrays.stream(ReferenceTypeEnum.values()).filter(typeEnum -> Objects.equals(typeEnum.getValue(), value)).findFirst().orElse(null); + } +} diff --git a/src/com/engine/salary/enums/salaryformula/ReturnTypeEnum.java b/src/com/engine/salary/enums/salaryformula/ReturnTypeEnum.java new file mode 100644 index 000000000..19eb4835b --- /dev/null +++ b/src/com/engine/salary/enums/salaryformula/ReturnTypeEnum.java @@ -0,0 +1,31 @@ +package com.engine.salary.enums.salaryformula; + +import java.util.Arrays; +import java.util.Objects; + +public enum ReturnTypeEnum { + NUMBER("number", "数值"), + STRING("string", "字符"); + + private String value; + + private String label; + + ReturnTypeEnum(String value, String label) { + this.value = value; + this.label = label; + } + + public String getValue() { + return value; + } + + public String getLabel() { + return label; + } + + + public static ReturnTypeEnum parseByValue(String value) { + return Arrays.stream(ReturnTypeEnum.values()).filter(typeEnum -> Objects.equals(typeEnum.getValue(), value)).findFirst().orElse(null); + } +} diff --git a/src/com/engine/salary/enums/salaryformula/SalaryFormulaReferenceEnum.java b/src/com/engine/salary/enums/salaryformula/SalaryFormulaReferenceEnum.java new file mode 100644 index 000000000..eafb0e32e --- /dev/null +++ b/src/com/engine/salary/enums/salaryformula/SalaryFormulaReferenceEnum.java @@ -0,0 +1,68 @@ +package com.engine.salary.enums.salaryformula; + + +import com.engine.salary.enums.BaseEnum; + +import java.util.Objects; + +/** + * 薪资项目公式引用分类 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public enum SalaryFormulaReferenceEnum implements BaseEnum { + + SALARY_ITEM("salaryItem", "薪资项目", 84960), + // SALARY_ITEM_OF_HISTORY("salaryItemOfHistory", "历史台账薪资项目", 85364), + LAST_MONTH_CALC("lastMonthCalc", "上月核算", 257728), + EMPLOYEE_INFO("employeeInfo", "员工基本信息", 85366), + SALARY_ARCHIVES("salaryArchives", "薪资档案", 85368), + ATTEND("attend", "考勤引用", 85367), + ADD_UP_SITUATION("addUpSituation", "往期累计情况", 104412), + ADD_UP_DEDUCTIONS("addUpDeductions", "累计专项附加扣除", 85380), + WELFARE("welfare", "社保福利", 87522), + OTHER_DEDUCTION("otherDeduction", "其他免税扣除", 93849), + SALARY_ACCT_EMPLOYEE("salaryAcctEmployee", "核算基本信息", 85368), + SALARY_CYCLE("SalaryCycle", "核算日期", 85368), + VARIABLE_ITEM("variableItem", "浮动薪资项目", 0), + ISSUED("ISSUED", "已发", 0); + + private String value; + + private String defaultLabel; + + private int labelId; + + SalaryFormulaReferenceEnum(String value, String defaultLabel, int labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + @Override + public String getValue() { + return value; + } + + @Override + public String getDefaultLabel() { + return defaultLabel; + } + + @Override + public Integer getLabelId() { + return labelId; + } + + public static SalaryFormulaReferenceEnum parseByValue(String value) { + for (SalaryFormulaReferenceEnum referenceEnum : SalaryFormulaReferenceEnum.values()) { + if (Objects.equals(referenceEnum.getValue(), value)) { + return referenceEnum; + } + } + return null; + } +} diff --git a/src/com/engine/salary/enums/salaryformula/SalarySQLReferenceEnum.java b/src/com/engine/salary/enums/salaryformula/SalarySQLReferenceEnum.java new file mode 100644 index 000000000..72d3e6dfe --- /dev/null +++ b/src/com/engine/salary/enums/salaryformula/SalarySQLReferenceEnum.java @@ -0,0 +1,57 @@ +package com.engine.salary.enums.salaryformula; + + +import com.engine.salary.enums.BaseEnum; + +import java.util.Objects; + +/** + * 薪资项目SQL公式引用分类 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public enum SalarySQLReferenceEnum implements BaseEnum { + + EMPLOYEE_INFO("employeeInfo", "员工基本信息", 85366), + SALARY_ACCT_EMPLOYEE("salaryAcctEmployee", "核算基本信息", 85368), + SALARY_CYCLE("SalaryCycle", "核算日期", 85368), + SALARY_ITEM("salaryItem", "薪资项目", 85368); + private String value; + + private String defaultLabel; + + private int labelId; + + SalarySQLReferenceEnum(String value, String defaultLabel, int labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + @Override + public String getValue() { + return value; + } + + @Override + public String getDefaultLabel() { + return defaultLabel; + } + + @Override + public Integer getLabelId() { + return labelId; + } + + public static SalarySQLReferenceEnum parseByValue(String value) { + for (SalarySQLReferenceEnum referenceEnum : SalarySQLReferenceEnum.values()) { + if (Objects.equals(referenceEnum.getValue(), value)) { + return referenceEnum; + } + } + return EMPLOYEE_INFO; + } +} diff --git a/src/com/engine/salary/enums/salaryformula/ValidateTypeEnum.java b/src/com/engine/salary/enums/salaryformula/ValidateTypeEnum.java new file mode 100644 index 000000000..4112b9ce5 --- /dev/null +++ b/src/com/engine/salary/enums/salaryformula/ValidateTypeEnum.java @@ -0,0 +1,31 @@ +package com.engine.salary.enums.salaryformula; + +import java.util.Arrays; +import java.util.Objects; + +public enum ValidateTypeEnum { + NUMBER("number", "数值"), + STRING("string", "字符"); + + private String value; + + private String label; + + ValidateTypeEnum(String value, String label) { + this.value = value; + this.label = label; + } + + public String getValue() { + return value; + } + + public String getLabel() { + return label; + } + + + public static ValidateTypeEnum parseByValue(String value) { + return Arrays.stream(ValidateTypeEnum.values()).filter(typeEnum -> Objects.equals(typeEnum.getValue(), value)).findFirst().orElse(null); + } +} diff --git a/src/com/engine/salary/enums/salaryitem/SalaryDataTypeEnum.java b/src/com/engine/salary/enums/salaryitem/SalaryDataTypeEnum.java new file mode 100644 index 000000000..fa5c76f40 --- /dev/null +++ b/src/com/engine/salary/enums/salaryitem/SalaryDataTypeEnum.java @@ -0,0 +1,79 @@ +package com.engine.salary.enums.salaryitem; + +import com.engine.salary.enums.BaseEnum; +import com.engine.salary.enums.SalaryValueTypeEnum; + +import java.util.Arrays; +import java.util.Objects; + +/** + * 薪资项目的字段类型 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public enum SalaryDataTypeEnum implements BaseEnum { + STRING("string", "字符", 105093), + NUMBER("number", "数值", 87625), + ; + + private String value; + + private String defaultLabel; + + private int labelId; + + SalaryDataTypeEnum(String value, String defaultLabel, int labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + @Override + public String getValue() { + return this.value; + } + + @Override + public Integer getLabelId() { + return this.labelId; + } + + @Override + public String getDefaultLabel() { + return this.defaultLabel; + } + + public static SalaryDataTypeEnum parseByValue(String value) { + for (SalaryDataTypeEnum salaryDataTypeEnum : SalaryDataTypeEnum.values()) { + if (Objects.equals(salaryDataTypeEnum.getValue(), value)) { + return salaryDataTypeEnum; + } + } + return STRING; + } + + public static String getDefaultLabelByValue(String value) { + if (value == null) { + return ""; + } + SalaryDataTypeEnum[] enumAry = SalaryDataTypeEnum.values(); + for(int i = 0; i < Arrays.asList(enumAry).size(); i++){ + if (enumAry[i].getValue().equals(value)) { + return enumAry[i].getDefaultLabel(); + } + } + return ""; + } + + public static SalaryDataTypeEnum parseByDefaultLabel(String defaultLabel) { + for (SalaryDataTypeEnum typeEnum : SalaryDataTypeEnum.values()) { + if (Objects.equals(typeEnum.getDefaultLabel(), defaultLabel)) { + return typeEnum; + } + } + return STRING; + } +} diff --git a/src/com/engine/salary/enums/salarysend/SalaryAutoSendCycleTypeEnum.java b/src/com/engine/salary/enums/salarysend/SalaryAutoSendCycleTypeEnum.java new file mode 100644 index 000000000..dfe02a0be --- /dev/null +++ b/src/com/engine/salary/enums/salarysend/SalaryAutoSendCycleTypeEnum.java @@ -0,0 +1,54 @@ +package com.engine.salary.enums.salarysend; + + +import com.engine.salary.enums.BaseEnum; + +import java.util.Objects; + +/** + * @ClassName SalaryAutoSendCycleTypeEnum + * @author Harryxzy + * @date 2023/7/4 17:30 + * @description 自动发送工资单周期 + */ +public enum SalaryAutoSendCycleTypeEnum implements BaseEnum { + + THIS_MONTH(1, "本月", 86072), + NEXT_MONTH(2, "下月", 86073); + + private int value; + + private String defaultLabel; + + private int labelId; + + SalaryAutoSendCycleTypeEnum(int value, String defaultLabel, int labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + @Override + public Integer getValue() { + return value; + } + + @Override + public String getDefaultLabel() { + return defaultLabel; + } + + @Override + public Integer getLabelId() { + return labelId; + } + + public static SalaryAutoSendCycleTypeEnum parseByValue(int value) { + for (SalaryAutoSendCycleTypeEnum salaryCycleTypeEnum : SalaryAutoSendCycleTypeEnum.values()) { + if (Objects.equals(salaryCycleTypeEnum.getValue(), value)) { + return salaryCycleTypeEnum; + } + } + return null; + } +} diff --git a/src/com/engine/salary/enums/salarysend/SalarySendGrantTypeEnum.java b/src/com/engine/salary/enums/salarysend/SalarySendGrantTypeEnum.java new file mode 100644 index 000000000..36d9114c8 --- /dev/null +++ b/src/com/engine/salary/enums/salarysend/SalarySendGrantTypeEnum.java @@ -0,0 +1,50 @@ +package com.engine.salary.enums.salarysend; + +import cn.hutool.core.util.StrUtil; + +import java.util.Arrays; +import java.util.Objects; + +public enum SalarySendGrantTypeEnum { + GRANT("grant", "发放", 98590), + WITHDRAW("withdraw", "撤回", 93351); + + private String value; + + private String defaultLabel; + + private int labelId; + + SalarySendGrantTypeEnum(String value, String defaultLabel, int labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + public String getValue() { + return value; + } + + public String getDefaultLabel() { + return defaultLabel; + } + + public int getLabelId() { + return labelId; + } + + public static String getDefaultLabelByValue(String value, Long employeeId, String tenantKey) { + return Arrays.stream(SalarySendGrantTypeEnum.values()).filter(r -> r.getValue().equals(value)).findFirst() + .map(SalarySendGrantTypeEnum::getDefaultLabel) + .orElse(StrUtil.EMPTY); + } + + public SalarySendGrantTypeEnum fromValue(String value) { + for (SalarySendGrantTypeEnum salarySendGrantTypeEnum : values()) { + if (Objects.equals(salarySendGrantTypeEnum.getValue(), value)) { + return salarySendGrantTypeEnum; + } + } + return null; + } +} \ No newline at end of file diff --git a/src/com/engine/salary/enums/salarysend/SalarySendRangeTargetTypeEnum.java b/src/com/engine/salary/enums/salarysend/SalarySendRangeTargetTypeEnum.java new file mode 100644 index 000000000..3cfe90888 --- /dev/null +++ b/src/com/engine/salary/enums/salarysend/SalarySendRangeTargetTypeEnum.java @@ -0,0 +1,48 @@ +package com.engine.salary.enums.salarysend; + +import com.engine.salary.enums.BaseEnum; +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.Objects; + +@AllArgsConstructor +@Getter +public enum SalarySendRangeTargetTypeEnum implements BaseEnum { + USER(1, "人员", 100133), + DEPT(2, "部门", 86185), + SUB_COMPANY(3, "分部", 107369), + POSITION(4, "岗位", 90633), +// TAX_AGENT(5, "个税扣缴义务人", 86184), + ALL(0, "所有人", 107729); + + private final int value; + + private final String defaultLabel; + + private final int labelId; + + @Override + public Integer getLabelId() { + return labelId; + } + + @Override + public Integer getValue() { + return value; + } + + @Override + public String getDefaultLabel() { + return defaultLabel; + } + + public static SalarySendRangeTargetTypeEnum fromValue(Integer value) { + for (SalarySendRangeTargetTypeEnum targetTypeEnum : SalarySendRangeTargetTypeEnum.values()) { + if (Objects.equals(targetTypeEnum.getValue(), value)) { + return targetTypeEnum; + } + } + return null; + } +} \ No newline at end of file diff --git a/src/com/engine/salary/enums/salarysend/SalarySendRangeTypeEnum.java b/src/com/engine/salary/enums/salarysend/SalarySendRangeTypeEnum.java new file mode 100644 index 000000000..a604013b3 --- /dev/null +++ b/src/com/engine/salary/enums/salarysend/SalarySendRangeTypeEnum.java @@ -0,0 +1,53 @@ +package com.engine.salary.enums.salarysend; + +import com.engine.salary.enums.BaseEnum; +import com.engine.salary.util.SalaryI18nUtil; +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.Arrays; +import java.util.Optional; + +@AllArgsConstructor +@Getter +public enum SalarySendRangeTypeEnum implements BaseEnum { + + INCLUDE_OBJ(1, "对象", 90396), + EXCLUDE_OBJ(2, "对象中排除", 142728); + + private final int value; + + private final String defaultLabel; + + private final int labelId; + + @Override + public Integer getLabelId() { + return labelId; + } + + @Override + public Integer getValue() { + return value; + } + + @Override + public String getDefaultLabel() { + return defaultLabel; + } + + public static String getDefaultLabelByValue(Integer value, Long employeeId, String tenantKey) { + Optional optional = Arrays.stream(SalarySendRangeTypeEnum.values()).filter(r->Integer.valueOf(r.getValue()).equals(value)).findFirst(); + return optional.isPresent()? SalaryI18nUtil.getI18nLabel(optional.get().getLabelId(), optional.get().getDefaultLabel()):""; + } + + public static SalarySendRangeTypeEnum fromValue(int value) { + for (SalarySendRangeTypeEnum salarySendRangeTypeEnum : values()) { + boolean equals = salarySendRangeTypeEnum.getValue().equals(value); + if (equals) { + return salarySendRangeTypeEnum; + } + } + return null; + } +} diff --git a/src/com/engine/salary/enums/salarysob/IncomeCategoryEnum.java b/src/com/engine/salary/enums/salarysob/IncomeCategoryEnum.java new file mode 100644 index 000000000..6fc084f52 --- /dev/null +++ b/src/com/engine/salary/enums/salarysob/IncomeCategoryEnum.java @@ -0,0 +1,62 @@ +package com.engine.salary.enums.salarysob; + +import com.engine.salary.enums.BaseEnum; + +import java.util.Objects; + +/** + * 应税项目 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public enum IncomeCategoryEnum implements BaseEnum { + + WAGES_AND_SALARIES(1, "正常工资薪金所得", 98656), + + REMUNERATION_FOR_LABOR(4, "劳务报酬所得", 105218), + + // 暂时注释掉,后续会开放 + ONETIME_ANNUAL_BONUS(2,"全年一次性奖金收入", 0) +// +// OTHER(11, "其他所得", 0), + ; + + private int value; + + private String defaultLabel; + + private int labelId; + + IncomeCategoryEnum(int value, String defaultLabel, int labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + @Override + public Integer getValue() { + return value; + } + + @Override + public Integer getLabelId() { + return labelId; + } + + @Override + public String getDefaultLabel() { + return defaultLabel; + } + + public static IncomeCategoryEnum parseByValue(Integer value) { + for (IncomeCategoryEnum incomeCategoryEnum : IncomeCategoryEnum.values()) { + if (Objects.equals(incomeCategoryEnum.getValue(), value)) { + return incomeCategoryEnum; + } + } + return null; + } +} diff --git a/src/com/engine/salary/enums/salarysob/SalaryEmployeeStatusEnum.java b/src/com/engine/salary/enums/salarysob/SalaryEmployeeStatusEnum.java new file mode 100644 index 000000000..02d9cb735 --- /dev/null +++ b/src/com/engine/salary/enums/salarysob/SalaryEmployeeStatusEnum.java @@ -0,0 +1,160 @@ +package com.engine.salary.enums.salarysob; + + +import cn.hutool.core.util.ObjectUtil; +import com.engine.salary.enums.BaseEnum; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Objects; + +/** + * 人员状态 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public enum SalaryEmployeeStatusEnum implements BaseEnum { + + TRIAL(0, "试用", 100121), + + FORMAL(1, "正式", 100122), + + TEMPORARY(2, "临时", 100123), + + DELAY(3, "试用延期", 100124), + + FIRE(4, "解雇", 100125), + + DEPARTURE(5, "离职", 100126), + + RETIRED(6, "退休", 100127), + ; + + private int value; + + private String defaultLabel; + + private int labelId; + + SalaryEmployeeStatusEnum(int value, String defaultLabel, int labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + @Override + public Integer getValue() { + return value; + } + + @Override + public Integer getLabelId() { + return labelId; + } + + @Override + public String getDefaultLabel() { + return defaultLabel; + } + + public static SalaryEmployeeStatusEnum parseByValue(Integer value) { + for (SalaryEmployeeStatusEnum statusEnum : SalaryEmployeeStatusEnum.values()) { + if (Objects.equals(statusEnum.getValue(), value)) { + return statusEnum; + } + } + return null; + } + + + public static List parseByValues(List value) { + ArrayList results = new ArrayList<>(); + for (SalaryEmployeeStatusEnum statusEnum : SalaryEmployeeStatusEnum.values()) { + for(Integer v : value){ + if(Objects.equals(statusEnum.getValue(),v)){ + results.add(statusEnum); + } + } + } + return results; + } + + /** + * @description 获取所有人员状态的value值的list + * @return List + * @author Harryxzy + * @date 2023/1/9 14:34 + */ + public static List getAllSalaryEmployeeStatusValues() { + List values = new ArrayList<>(); + for (SalaryEmployeeStatusEnum statusEnum : SalaryEmployeeStatusEnum.values()) { + values.add(ObjectUtil.toString(statusEnum.getValue())); + } + return values; + } + + + /** + * @description 根据string”、“间隔的格式,获取所有人员状态value集合 + * @return List + * @author Harryxzy + * @date 2023/1/9 14:35 + */ + public static List parseByFormatStr(String statusStr, Boolean[] haveError) { + List result = new ArrayList<>(); + String[] status = statusStr.split("、"); + Arrays.stream(status).forEach(s -> { + + String value = null; + for (SalaryEmployeeStatusEnum statusEnum : SalaryEmployeeStatusEnum.values()) { + if (Objects.equals(statusEnum.getDefaultLabel(), s)) { + value = ObjectUtil.toString(statusEnum.getValue()); + break; + } + } + if(value != null ){ + result.add(value); + }else{ + haveError[0] = true; + return; + } + }); + return result; + } + + + /** + * @description 根据string”、“间隔的格式,获取所有人员状态枚举数组 + * @return List + * @author Harryxzy + * @date 2023/1/9 14:35 + */ + public static SalaryEmployeeStatusEnum[] getEnumsParseByFormatStr(String statusStr, Boolean[] haveError) { + List result = new ArrayList<>(); + String[] status = statusStr.split("、"); + Arrays.stream(status).forEach(s -> { + + SalaryEmployeeStatusEnum value = null; + for (SalaryEmployeeStatusEnum statusEnum : SalaryEmployeeStatusEnum.values()) { + if (Objects.equals(statusEnum.getDefaultLabel(), s)) { + value =statusEnum; + break; + } + } + if(value != null ){ + result.add(value); + }else{ + haveError[0] = true; + return; + } + }); + SalaryEmployeeStatusEnum[] array = new SalaryEmployeeStatusEnum[result.size()]; + result.toArray(array); + return array; + } + +} diff --git a/src/com/engine/salary/enums/salarysob/SalarySobAdjustRuleTypeEnum.java b/src/com/engine/salary/enums/salarysob/SalarySobAdjustRuleTypeEnum.java new file mode 100644 index 000000000..e79fe70da --- /dev/null +++ b/src/com/engine/salary/enums/salarysob/SalarySobAdjustRuleTypeEnum.java @@ -0,0 +1,58 @@ +package com.engine.salary.enums.salarysob; + +import com.engine.salary.enums.BaseEnum; + +import java.util.Objects; + +/** + * 调薪规则 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public enum SalarySobAdjustRuleTypeEnum implements BaseEnum { + + USE_BEFORE_ADJUSTMENT(1,"取调薪前薪资", 100121), + USE_AFTER_ADJUSTMENT(2, "取调薪后薪资",100131), + AVERAGE(3, "平均值", 100132), + PARTITION(4, "分段计薪",97005), + ; + + SalarySobAdjustRuleTypeEnum(int value, String defaultLabel, int labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + private int value; + + private String defaultLabel; + + private int labelId; + + @Override + public Integer getValue() { + return value; + } + + @Override + public Integer getLabelId() { + return labelId; + } + + @Override + public String getDefaultLabel() { + return defaultLabel; + } + + public static SalarySobAdjustRuleTypeEnum parseByValue(Integer value){ + for (SalarySobAdjustRuleTypeEnum salarySobAdjustRuleTypeEnum : SalarySobAdjustRuleTypeEnum.values()) { + if(Objects.equals(salarySobAdjustRuleTypeEnum.getValue(), value)){ + return salarySobAdjustRuleTypeEnum; + } + } + return null; + } +} diff --git a/src/com/engine/salary/enums/salarysob/TargetTypeEnum.java b/src/com/engine/salary/enums/salarysob/TargetTypeEnum.java new file mode 100644 index 000000000..051a336ff --- /dev/null +++ b/src/com/engine/salary/enums/salarysob/TargetTypeEnum.java @@ -0,0 +1,76 @@ +package com.engine.salary.enums.salarysob; + + +import com.engine.salary.enums.BaseEnum; +import com.google.common.collect.Maps; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * 人员范围的对象类型 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public enum TargetTypeEnum implements BaseEnum { + EMPLOYEE(1, "人员", 100133), + DEPT(2, "部门", 86185), + SUBCOMPANY(3, "分部", 107369), + POSITION(4, "岗位", 90633), + ALL(5, "所有人", 107729), + SQL(6, "SQL", 107729); + private int value; + + private String defaultLabel; + + private int labelId; + + TargetTypeEnum(int value, String defaultLabel, int labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + + @Override + public Integer getValue() { + return value; + } + + @Override + public Integer getLabelId() { + return labelId; + } + + @Override + public String getDefaultLabel() { + return defaultLabel; + } + + /** + * 获取下拉列表 + * + * @return + */ + public static List> getSelectList() { + return Arrays.asList(TargetTypeEnum.values()).stream().filter(e -> e != ALL ).map(e -> { + Map map = Maps.newHashMap(); + map.put("id", e.name()); + map.put("name", e.defaultLabel); + map.put("value", e.value); + return map; + }).collect(Collectors.toList()); + } + + public static TargetTypeEnum parseByValue(Integer value) { + for (TargetTypeEnum targetTypeEnum : TargetTypeEnum.values()) { + if (Objects.equals(targetTypeEnum.getValue(), value)) { + return targetTypeEnum; + } + } + return null; + } +} diff --git a/src/com/engine/salary/enums/setting/PageListSettingPageEnum.java b/src/com/engine/salary/enums/setting/PageListSettingPageEnum.java new file mode 100644 index 000000000..49110ae17 --- /dev/null +++ b/src/com/engine/salary/enums/setting/PageListSettingPageEnum.java @@ -0,0 +1,39 @@ +package com.engine.salary.enums.setting; + +import com.engine.salary.enums.BaseEnum; + +/** + * 人员类型 + */ +public enum PageListSettingPageEnum implements BaseEnum { + + SALARY_DETAILS_REPORT("salary_details_report", "薪资明细报表", 109125) + ; + + private String value; + + private String defaultLabel; + + private int labelId; + + PageListSettingPageEnum(String value, String defaultLabel, int labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + @Override + public String getValue() { + return value; + } + + @Override + public Integer getLabelId() { + return labelId; + } + + @Override + public String getDefaultLabel() { + return defaultLabel; + } +} diff --git a/src/com/engine/salary/enums/siaccount/BillStatusEnum.java b/src/com/engine/salary/enums/siaccount/BillStatusEnum.java new file mode 100644 index 000000000..2a98dc955 --- /dev/null +++ b/src/com/engine/salary/enums/siaccount/BillStatusEnum.java @@ -0,0 +1,39 @@ +package com.engine.salary.enums.siaccount; + +import com.engine.salary.enums.BaseEnum; + +/** + * @Description: + * @Author: zhangheng + * @CreateDate: 2021/12/3 16:23 + * @Version: v1.0 + */ +public enum BillStatusEnum implements BaseEnum { + NOT_ARCHIVED(0, "未归档", 91870), + + ARCHIVED(1, "已归档", 91862); + + private Integer value; + + private String defaultLable; + + private Integer labelId; + + BillStatusEnum(Integer value, String defaultLable, Integer labelId) { + this.value = value; + this.defaultLable = defaultLable; + this.labelId = labelId; + } + + public Integer getValue() { + return this.value; + } + + public Integer getLabelId() { + return this.labelId; + } + + public String getDefaultLabel() { + return this.defaultLable; + } +} diff --git a/src/com/engine/salary/enums/siaccount/EmployeeStatusEnum.java b/src/com/engine/salary/enums/siaccount/EmployeeStatusEnum.java new file mode 100644 index 000000000..fd9f9dff8 --- /dev/null +++ b/src/com/engine/salary/enums/siaccount/EmployeeStatusEnum.java @@ -0,0 +1,59 @@ +package com.engine.salary.enums.siaccount; + +import com.engine.salary.enums.BaseEnum; + +import java.util.Objects; + + +/** + * 福利档案人员状态枚举 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public enum EmployeeStatusEnum implements BaseEnum { + + STAY_ADD("1", "待增员", 106667), + PAYING("2", "正在缴纳", 106668), + STAY_DEL("3", "待减员", 106669), + STOP_PAYMENT_FROM_ADD("4", "停止缴纳-来自待增员", 106670), + STOP_PAYMENT_FROM_DEL("5", "停止缴纳-来自待减员", 106671); + + private String value; + + private String defaultLable; + + private Integer labelId; + + EmployeeStatusEnum(String value, String defaultLable, Integer labelId) { + this.value = value; + this.defaultLable = defaultLable; + this.labelId = labelId; + } + + @Override + public String getValue() { + return this.value; + } + + @Override + public Integer getLabelId() { + return this.labelId; + } + + @Override + public String getDefaultLabel() { + return this.defaultLable; + } + + public static EmployeeStatusEnum parseByValue(String value){ + for (EmployeeStatusEnum employeeStatusEnum : EmployeeStatusEnum.values()) { + if(Objects.equals(employeeStatusEnum.getValue(), value)){ + return employeeStatusEnum; + } + } + return null; + } +} diff --git a/src/com/engine/salary/enums/siaccount/InspectStatusEnum.java b/src/com/engine/salary/enums/siaccount/InspectStatusEnum.java new file mode 100644 index 000000000..a8746abf1 --- /dev/null +++ b/src/com/engine/salary/enums/siaccount/InspectStatusEnum.java @@ -0,0 +1,39 @@ +package com.engine.salary.enums.siaccount; + +import com.engine.salary.enums.BaseEnum; + +/** + * @Description: + * @Author: zhangheng + * @CreateDate: 2022/1/4 9:13 + * @Version: v1.0 + */ +public enum InspectStatusEnum implements BaseEnum { + IGNORE(0, "忽略", 92457), + + COMFORED(1, "重置", 93869); + + private Integer value; + + private String defaultLable; + + private Integer labelId; + + InspectStatusEnum(Integer value, String defaultLable, Integer labelId) { + this.value = value; + this.defaultLable = defaultLable; + this.labelId = labelId; + } + + public Integer getValue() { + return this.value; + } + + public Integer getLabelId() { + return this.labelId; + } + + public String getDefaultLabel() { + return this.defaultLable; + } +} diff --git a/src/com/engine/salary/enums/siaccount/PaymentStatusEnum.java b/src/com/engine/salary/enums/siaccount/PaymentStatusEnum.java new file mode 100644 index 000000000..cd4fe410d --- /dev/null +++ b/src/com/engine/salary/enums/siaccount/PaymentStatusEnum.java @@ -0,0 +1,43 @@ +package com.engine.salary.enums.siaccount; + + +import com.engine.salary.enums.BaseEnum; + +/** + * @Description: + * @Author: zhangheng + * @CreateDate: 2021/12/6 9:32 + * @Version: v1.0 + */ +public enum PaymentStatusEnum implements BaseEnum { + + COMMON(0, "正常缴纳", 92265), + REPAIR(1, "补缴", 92266), + PAYMENT(2,"代缴",121755), + RECESSION(3,"退差",134057), + BALANCE(4,"补差",139823); + + private Integer value; + + private String defaultLable; + + private Integer labelId; + + PaymentStatusEnum(Integer value, String defaultLable, Integer labelId) { + this.value = value; + this.defaultLable = defaultLable; + this.labelId = labelId; + } + + public Integer getValue() { + return this.value; + } + + public Integer getLabelId() { + return this.labelId; + } + + public String getDefaultLabel() { + return this.defaultLable; + } +} diff --git a/src/com/engine/salary/enums/siaccount/ProjectTypeEnum.java b/src/com/engine/salary/enums/siaccount/ProjectTypeEnum.java new file mode 100644 index 000000000..246a6e701 --- /dev/null +++ b/src/com/engine/salary/enums/siaccount/ProjectTypeEnum.java @@ -0,0 +1,41 @@ +package com.engine.salary.enums.siaccount; + +import com.engine.salary.enums.BaseEnum; + + +public enum ProjectTypeEnum implements BaseEnum { + ALL(0, "全部", 85155), + SOCIAL(1, "社保", 86568), + FUND(2, "公积金", 86569), + OTHER(3, "企业年金及其他福利", 93112), + ENDOWMENT_INSURANCE(4, "养老保险", 93113), + MEDICAL_INSURANCE(5, "医疗保险", 93114); + + private int value; + + private String defaultLabel; + + private int labelId; + + ProjectTypeEnum(int value, String defaultLabel, int labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + @Override + public Integer getValue() { + return value; + } + + @Override + public Integer getLabelId() { + return labelId; + } + + @Override + public String getDefaultLabel() { + return defaultLabel; + } + +} diff --git a/src/com/engine/salary/enums/siaccount/ResourceFromEnum.java b/src/com/engine/salary/enums/siaccount/ResourceFromEnum.java new file mode 100644 index 000000000..7b50b909d --- /dev/null +++ b/src/com/engine/salary/enums/siaccount/ResourceFromEnum.java @@ -0,0 +1,42 @@ +package com.engine.salary.enums.siaccount; + +import com.engine.salary.enums.BaseEnum; + +/** + * @Description: + * @Author: zhangheng + * @CreateDate: 2021/12/6 9:37 + * @Version: v1.0 + */ +public enum ResourceFromEnum implements BaseEnum { + + SYSTEM(0, "系统核算", 92268), + + Temporary(1, "临时", 92269), + + IMPORT(2,"导入",87622); + + private Integer value; + + private String defaultLable; + + private Integer labelId; + + ResourceFromEnum(Integer value, String defaultLable, Integer labelId) { + this.value = value; + this.defaultLable = defaultLable; + this.labelId = labelId; + } + + public Integer getValue() { + return this.value; + } + + public Integer getLabelId() { + return this.labelId; + } + + public String getDefaultLabel() { + return this.defaultLable; + } +} diff --git a/src/com/engine/salary/enums/sicategory/DataTypeEnum.java b/src/com/engine/salary/enums/sicategory/DataTypeEnum.java new file mode 100644 index 000000000..2d3694209 --- /dev/null +++ b/src/com/engine/salary/enums/sicategory/DataTypeEnum.java @@ -0,0 +1,31 @@ +package com.engine.salary.enums.sicategory; + +/** + * @Description: + * @Author: zhangheng + * @CreateDate: 2021/11/19 14:18 + * @Version: v1.0 + */ +public enum DataTypeEnum { + + CUSTOM(0, "自定义"), + + SYSTEM(1, "系统"); + + private Integer value; + + private String desc; + + DataTypeEnum(Integer value, String desc) { + this.value = value; + this.desc = desc; + } + + public Integer getValue() { + return value; + } + + public String getDesc() { + return desc; + } +} diff --git a/src/com/engine/salary/enums/sicategory/DeleteTypeEnum.java b/src/com/engine/salary/enums/sicategory/DeleteTypeEnum.java new file mode 100644 index 000000000..6e3845b34 --- /dev/null +++ b/src/com/engine/salary/enums/sicategory/DeleteTypeEnum.java @@ -0,0 +1,31 @@ +package com.engine.salary.enums.sicategory; + +/** + * @Description: + * @Author: zhangheng + * @CreateDate: 2021/11/19 14:20 + * @Version: v1.0 + */ +public enum DeleteTypeEnum { + + NOT_DELETED(0, "未删除"), + + DELETED(1, "已删除"); + + private Integer value; + + private String desc; + + DeleteTypeEnum(Integer value, String desc) { + this.value = value; + this.desc = desc; + } + + public Integer getValue() { + return value; + } + + public String getDesc() { + return desc; + } +} diff --git a/src/com/engine/salary/enums/sicategory/IncludeTypeEnum.java b/src/com/engine/salary/enums/sicategory/IncludeTypeEnum.java new file mode 100644 index 000000000..582e156c1 --- /dev/null +++ b/src/com/engine/salary/enums/sicategory/IncludeTypeEnum.java @@ -0,0 +1,28 @@ +package com.engine.salary.enums.sicategory; + +/** + * @Description: + * @Author: zhangheng + * @CreateDate: 2021/12/2 9:26 + * @Version: v1.0 + */ +public enum IncludeTypeEnum { + INCLUDE(1, "包含"), + EXCLUDE(0, "不包含"); + private Integer value; + + private String desc; + + IncludeTypeEnum(Integer value, String desc) { + this.value = value; + this.desc = desc; + } + + public Integer getValue() { + return value; + } + + public String getDesc() { + return desc; + } +} diff --git a/src/com/engine/salary/enums/sicategory/IsPaymentEnum.java b/src/com/engine/salary/enums/sicategory/IsPaymentEnum.java new file mode 100644 index 000000000..4897625d8 --- /dev/null +++ b/src/com/engine/salary/enums/sicategory/IsPaymentEnum.java @@ -0,0 +1,29 @@ +package com.engine.salary.enums.sicategory; + +/** + * @Description: + * @Author: zhangheng + * @CreateDate: 2021/11/18 13:29 + * @Version: v1.0 + */ +public enum IsPaymentEnum { + YES(1, "缴费"), + + NO(0, "不缴费"); + + private Integer value; + private String desc; + + IsPaymentEnum(Integer value, String desc) { + this.value = value; + this.desc = desc; + } + + public Integer getValue() { + return value; + } + + public String getDesc() { + return desc; + } +} diff --git a/src/com/engine/salary/enums/sicategory/IsUseEnum.java b/src/com/engine/salary/enums/sicategory/IsUseEnum.java new file mode 100644 index 000000000..a5497f4b6 --- /dev/null +++ b/src/com/engine/salary/enums/sicategory/IsUseEnum.java @@ -0,0 +1,30 @@ +package com.engine.salary.enums.sicategory; + +/** + * @Description: + * @Author: zhangheng + * @CreateDate: 2021/11/19 14:24 + * @Version: v1.0 + */ +public enum IsUseEnum { + START(1, "启用"), + + STOP(0, "停用"); + + private Integer value; + + private String desc; + + IsUseEnum(Integer value, String desc) { + this.value = value; + this.desc = desc; + } + + public Integer getValue() { + return value; + } + + public String getDesc() { + return desc; + } +} diff --git a/src/com/engine/salary/enums/sicategory/NonPaymentEnum.java b/src/com/engine/salary/enums/sicategory/NonPaymentEnum.java new file mode 100644 index 000000000..704420108 --- /dev/null +++ b/src/com/engine/salary/enums/sicategory/NonPaymentEnum.java @@ -0,0 +1,31 @@ +package com.engine.salary.enums.sicategory; + +/** + * @Description: + * @Author: zhangheng + * @CreateDate: 2021/11/29 9:24 + * @Version: v1.0 + */ +public enum NonPaymentEnum { + + YES(0, "缴纳"), + + NO(1, "不缴纳"); + + private Integer value; + + private String desc; + + NonPaymentEnum(Integer value, String desc) { + this.value = value; + this.desc = desc; + } + + public Integer getValue() { + return value; + } + + public String getDesc() { + return desc; + } +} diff --git a/src/com/engine/salary/enums/sicategory/PaymentScopeEnum.java b/src/com/engine/salary/enums/sicategory/PaymentScopeEnum.java new file mode 100644 index 000000000..0a4cdd74b --- /dev/null +++ b/src/com/engine/salary/enums/sicategory/PaymentScopeEnum.java @@ -0,0 +1,46 @@ +package com.engine.salary.enums.sicategory; + + +import com.engine.salary.enums.BaseEnum; + +import java.util.Arrays; + +public enum PaymentScopeEnum implements BaseEnum { + SCOPE_COMPANY(1, "公司", 87158), + SCOPE_PERSON(2, "个人", 87159); + + private Integer value; + private String defaultLable; + private Integer labelId; + + PaymentScopeEnum(Integer value, String defaultLable, Integer labelId) { + this.value = value; + this.defaultLable = defaultLable; + this.labelId = labelId; + } + + public Integer getValue() { + return this.value; + } + + public Integer getLabelId() { + return this.labelId; + } + + public String getDefaultLabel() { + return this.defaultLable; + } + + public static String getDefaultLabelByValue(Integer value){ + if (value == null) { + return ""; + }; + PaymentScopeEnum[] enumAry = PaymentScopeEnum.values(); + for(int i = 0; i < Arrays.asList(enumAry).size(); i++){ + if (Integer.valueOf(enumAry[i].getValue()).equals(value)) { + return enumAry[i].getDefaultLabel(); + } + } + return ""; + } +} diff --git a/src/com/engine/salary/enums/sicategory/PaymentTypeEnum.java b/src/com/engine/salary/enums/sicategory/PaymentTypeEnum.java new file mode 100644 index 000000000..2bcb6dce5 --- /dev/null +++ b/src/com/engine/salary/enums/sicategory/PaymentTypeEnum.java @@ -0,0 +1,38 @@ +package com.engine.salary.enums.sicategory; + +import com.engine.salary.enums.BaseEnum; + +/** + * @Description: + * @Author: zhangheng + * @CreateDate: 2021/11/16 13:11 + * @Version: v1.0 + */ +public enum PaymentTypeEnum implements BaseEnum { + SCHEME_TOWN(1, "城镇", 87410), + SCHEME_VILLAGE(2, "农村", 87411); + + private Integer value; + + private String defaultLabel; + + private Integer labelId; + + PaymentTypeEnum(Integer value, String defaultLabel, Integer labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + public Integer getValue() { + return this.value; + } + + public Integer getLabelId() { + return this.labelId; + } + + public String getDefaultLabel() { + return this.defaultLabel; + } +} diff --git a/src/com/engine/salary/enums/sicategory/RententionRuleEnum.java b/src/com/engine/salary/enums/sicategory/RententionRuleEnum.java new file mode 100644 index 000000000..c48ebd3fb --- /dev/null +++ b/src/com/engine/salary/enums/sicategory/RententionRuleEnum.java @@ -0,0 +1,56 @@ +package com.engine.salary.enums.sicategory; + + +import com.engine.salary.enums.BaseEnum; + +import java.math.BigDecimal; +import java.util.Arrays; + +@Deprecated +public enum RententionRuleEnum implements BaseEnum { + ROUND(BigDecimal.ROUND_HALF_UP, "四舍五入", 84505), + CEIL(BigDecimal.ROUND_UP, "向上舍入", 84506), + FLOOR(BigDecimal.ROUND_DOWN, "向下舍入", 84507), + CEILING(5, "见分进角", 84507), + UP_EVEN(6, "向上求偶", 84507); + + private int value; + + private String defaultLabel; + + private int lavelId; + + RententionRuleEnum(int value, String defaultLabel, int labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.lavelId = labelId; + } + + @Override + public Integer getValue() { + return this.value; + } + + @Override + public Integer getLabelId() { + return this.lavelId; + } + + @Override + public String getDefaultLabel() { + return this.defaultLabel; + } + + public static String getDefaultLabelByValue(Integer value) { + if (value == null) { + return ""; + } + RententionRuleEnum[] enumAry = RententionRuleEnum.values(); + for(int i = 0; i < Arrays.asList(enumAry).size(); i++){ + if (Integer.valueOf(enumAry[i].getValue()).equals(value)) { + return enumAry[i].getDefaultLabel(); + } + } + return ""; + } +} diff --git a/src/com/engine/salary/enums/sicategory/SharedTypeEnum.java b/src/com/engine/salary/enums/sicategory/SharedTypeEnum.java new file mode 100644 index 000000000..7ff3d03cd --- /dev/null +++ b/src/com/engine/salary/enums/sicategory/SharedTypeEnum.java @@ -0,0 +1,37 @@ +package com.engine.salary.enums.sicategory; + +import com.engine.salary.enums.BaseEnum; + + +public enum SharedTypeEnum implements BaseEnum { + PUBLIC("0", "公共", 86568), + PRIVATE("1", "私有", 86569); + + private String value; + + private String defaultLabel; + + private Integer labelId; + + SharedTypeEnum(String value, String defaultLabel, Integer labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + + @Override + public String getValue() { + return this.value; + } + + @Override + public Integer getLabelId() { + return this.labelId; + } + + @Override + public String getDefaultLabel() { + return this.defaultLabel; + } +} diff --git a/src/com/engine/salary/enums/sicategory/UndertakerEnum.java b/src/com/engine/salary/enums/sicategory/UndertakerEnum.java new file mode 100644 index 000000000..d3dbda8d5 --- /dev/null +++ b/src/com/engine/salary/enums/sicategory/UndertakerEnum.java @@ -0,0 +1,39 @@ +package com.engine.salary.enums.sicategory; + +import com.engine.salary.enums.BaseEnum; + +/** + * @Description: + * @Author: zhangheng + * @CreateDate: 2021/11/25 16:43 + * @Version: v1.0 + */ +public enum UndertakerEnum implements BaseEnum { + + SCOPE_COMPANY(1, "公司", 87158), + SCOPE_PERSON(2, "个人", 87159); + + private Integer value; + + private String defaultLable; + + private Integer labelId; + + UndertakerEnum(Integer value, String defaultLable, Integer labelId) { + this.value = value; + this.defaultLable = defaultLable; + this.labelId = labelId; + } + + public Integer getValue() { + return this.value; + } + + public Integer getLabelId() { + return this.labelId; + } + + public String getDefaultLabel() { + return this.defaultLable; + } +} diff --git a/src/com/engine/salary/enums/sicategory/WelfareTypeEnum.java b/src/com/engine/salary/enums/sicategory/WelfareTypeEnum.java new file mode 100644 index 000000000..fea16dc65 --- /dev/null +++ b/src/com/engine/salary/enums/sicategory/WelfareTypeEnum.java @@ -0,0 +1,53 @@ +package com.engine.salary.enums.sicategory; + +import com.engine.salary.enums.BaseEnum; + +import java.util.Arrays; + + +public enum WelfareTypeEnum implements BaseEnum { + SOCIAL_SECURITY(1, "社保", 86568), + ACCUMULATION_FUND(2, "公积金", 86569), + OTHER(3, "企业年金及其它福利", 86570); + + private Integer value; + + private String defaultLabel; + + private Integer labelId; + + WelfareTypeEnum(Integer value, String defaultLabel, Integer labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + + @Override + public Integer getValue() { + return this.value; + } + + @Override + public Integer getLabelId() { + return this.labelId; + } + + @Override + public String getDefaultLabel() { + return this.defaultLabel; + } + + public static String getDefaultLabelByValue(Integer value){ + if (value == null) { + return ""; + }; + WelfareTypeEnum[] enumAry = WelfareTypeEnum.values(); + for(int i = 0; i < Arrays.asList(enumAry).size(); i++){ + if (Integer.valueOf(enumAry[i].getValue()).equals(value)) { + return enumAry[i].getDefaultLabel(); + } + } + return ""; + } +} diff --git a/src/com/engine/salary/enums/taxagent/TaxAgentEmpChangeModuleEnum.java b/src/com/engine/salary/enums/taxagent/TaxAgentEmpChangeModuleEnum.java new file mode 100644 index 000000000..b1edea29d --- /dev/null +++ b/src/com/engine/salary/enums/taxagent/TaxAgentEmpChangeModuleEnum.java @@ -0,0 +1,32 @@ +package com.engine.salary.enums.taxagent; + +/** + * 模块类型 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public enum TaxAgentEmpChangeModuleEnum { + + SALARY_ARCHIVE(1, "薪资档案"), + INSURANCE_ARCHIVE(2, "社保档案"); + + private int value; + + private String defaultLabel; + + TaxAgentEmpChangeModuleEnum(int value, String defaultLabel) { + this.value = value; + this.defaultLabel = defaultLabel; + } + + public int getValue() { + return value; + } + + public String getDefaultLabel() { + return defaultLabel; + } +} diff --git a/src/com/engine/salary/enums/taxagent/TaxAgentEmpChangeTypeEnum.java b/src/com/engine/salary/enums/taxagent/TaxAgentEmpChangeTypeEnum.java new file mode 100644 index 000000000..b34217ffb --- /dev/null +++ b/src/com/engine/salary/enums/taxagent/TaxAgentEmpChangeTypeEnum.java @@ -0,0 +1,32 @@ +package com.engine.salary.enums.taxagent; + +/** + * 增量类型 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public enum TaxAgentEmpChangeTypeEnum { + + ADD(1, "新增"), + DEL(2, "删除"); + + private int value; + + private String defaultLabel; + + TaxAgentEmpChangeTypeEnum(int value, String defaultLabel) { + this.value = value; + this.defaultLabel = defaultLabel; + } + + public int getValue() { + return value; + } + + public String getDefaultLabel() { + return defaultLabel; + } +} diff --git a/src/com/engine/salary/enums/taxagent/TaxAgentRangeTypeEnum.java b/src/com/engine/salary/enums/taxagent/TaxAgentRangeTypeEnum.java new file mode 100644 index 000000000..c89faa539 --- /dev/null +++ b/src/com/engine/salary/enums/taxagent/TaxAgentRangeTypeEnum.java @@ -0,0 +1,49 @@ +package com.engine.salary.enums.taxagent; + +import com.engine.salary.util.SalaryI18nUtil; + +import java.util.Arrays; +import java.util.Optional; + +/** + * 范围类型 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public enum TaxAgentRangeTypeEnum { + + TAXAGENT(1, "个税扣缴义务人", 86184), + SUBADMIN(2, "分管理员", 106283); + + private int value; + + private String defaultLabel; + + private int labelId; + + TaxAgentRangeTypeEnum(int value, String defaultLabel, int labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + public int getValue() { + return value; + } + + public String getDefaultLabel() { + return defaultLabel; + } + + public int getLabelId() { + return labelId; + } + + public static String getDefaultLabelByValue(Integer value, Long employeeId, String tenantKey) { + Optional optional = Arrays.stream(TaxAgentRangeTypeEnum.values()).filter(r -> Integer.valueOf(r.getValue()).equals(value)).findFirst(); + return optional.isPresent() ? SalaryI18nUtil.getI18nLabel(optional.get().getLabelId(), optional.get().getDefaultLabel()) : ""; + } +} diff --git a/src/com/engine/salary/enums/taxagent/TaxAgentRoleTypeEnum.java b/src/com/engine/salary/enums/taxagent/TaxAgentRoleTypeEnum.java new file mode 100644 index 000000000..f5cde5746 --- /dev/null +++ b/src/com/engine/salary/enums/taxagent/TaxAgentRoleTypeEnum.java @@ -0,0 +1,31 @@ +package com.engine.salary.enums.taxagent; + +/** + * @Description: 个税扣缴义务人角色类型 + * @Author: wangxiangzhong + * @Date: 2022-04-22 14:37 + */ +public enum TaxAgentRoleTypeEnum { + + CHIEF(0, "总管理员"), + ADMIN(1, "管理员"), + SUBADMIN(2, "分管理员"), + NONE(3, "其他"); + + private int value; + + private String defaultLabel; + + TaxAgentRoleTypeEnum(int value, String defaultLabel) { + this.value = value; + this.defaultLabel = defaultLabel; + } + + public int getValue() { + return value; + } + + public String getDefaultLabel() { + return defaultLabel; + } +} diff --git a/src/com/engine/salary/exception/ExceptionUtil.java b/src/com/engine/salary/exception/ExceptionUtil.java new file mode 100644 index 000000000..4c33b16e4 --- /dev/null +++ b/src/com/engine/salary/exception/ExceptionUtil.java @@ -0,0 +1,17 @@ +package com.engine.salary.exception; + +public class ExceptionUtil { + public static String getRealMessage(Throwable e) { + while (e != null) { + Throwable cause = e.getCause(); + if (cause == null) { + return e.getMessage(); + } + e = cause; + } + return ""; + } +} + + + diff --git a/src/com/engine/salary/exception/SalaryRunTimeException.java b/src/com/engine/salary/exception/SalaryRunTimeException.java new file mode 100644 index 000000000..4629dfcf0 --- /dev/null +++ b/src/com/engine/salary/exception/SalaryRunTimeException.java @@ -0,0 +1,15 @@ +package com.engine.salary.exception; + +public class SalaryRunTimeException extends RuntimeException { + public SalaryRunTimeException(String message) { + super(message); + } + + public SalaryRunTimeException(Throwable cause) { + super(cause); + } + + public SalaryRunTimeException(String message, Throwable cause) { + super(message, cause); + } +} diff --git a/src/com/engine/salary/formlua/constant/FormluaConstant.java b/src/com/engine/salary/formlua/constant/FormluaConstant.java new file mode 100644 index 000000000..c88d7090d --- /dev/null +++ b/src/com/engine/salary/formlua/constant/FormluaConstant.java @@ -0,0 +1,1558 @@ +package com.engine.salary.formlua.constant; + + +public class FormluaConstant { + + public static final String DES = "{\n" + + " \"data\": [\n" + + " {\n" + + " \"children\": [\n" + + " {\n" + + " \"name\": \"CONCAT\",\n" + + " \"chineseName\": \"链接多个文本\",\n" + + " \"description\": \"可用于连接多个任意类型的文本、日期、数字变量或常量。最后一个字符可使用'#分隔符#'标记为分隔符\",\n" + + " \"example\": \"CONCAT({总价}/10000, '万元')\",\n" + + " \"result\": \"100万元\",\n" + + " \"paramDescs\": [\n" + + " \"*文本1*(必选)\",\n" + + " \"*文本2*(可选)\",\n" + + " \"......\"\n" + + " ],\n" + + " \"formatString\": \"CONCAT(文本1, 文本2, [文本3, …],[#分隔符#])\",\n" + + " \"paramArray\": [],\n" + + " \"paramData\": [],\n" + + " \"returnType\": \"string\",\n" + + " \"type\": \"function\",\n" + + " \"validForm\": \"current_data\",\n" + + " \"paramCount\": -1,\n" + + " \"paramStatuses\": [\n" + + " {\n" + + " \"dataType\": \"string\",\n" + + " \"must\": true,\n" + + " \"infinite\": true\n" + + " }\n" + + " ]\n" + + " },\n" + + " {\n" + + " \"name\": \"TEXT\",\n" + + " \"chineseName\": \"将变量转为文本\",\n" + + " \"description\": \"将变量转为文本。\",\n" + + " \"example\": \"TEXT({当前数据.性别})\",\n" + + " \"result\": \"'男'\",\n" + + " \"paramDescs\": [\n" + + " \"*变量*(必选)\"\n" + + " ],\n" + + " \"formatString\": \"TEXT(变量)\",\n" + + " \"paramArray\": [],\n" + + " \"paramData\": [],\n" + + " \"returnType\": \"string\",\n" + + " \"type\": \"function\",\n" + + " \"validForm\": \"current_data\",\n" + + " \"paramCount\": 1,\n" + + " \"paramStatuses\": [\n" + + " {\n" + + " \"dataType\": \"all\",\n" + + " \"must\": true,\n" + + " \"infinite\": false\n" + + " }\n" + + " ]\n" + + " },\n" + + " {\n" + + " \"name\": \"VALUE\",\n" + + " \"chineseName\": \"将文本转为数字\",\n" + + " \"description\": \"将文本转为数字。\",\n" + + " \"example\": \"VALUE('23')\",\n" + + " \"result\": \"23\",\n" + + " \"paramDescs\": [\n" + + " \"*文本、数字、选项*(必选)\"\n" + + " ],\n" + + " \"formatString\": \"VALUE([文本、数字、选项])\",\n" + + " \"paramArray\": [],\n" + + " \"paramData\": [],\n" + + " \"returnType\": \"number\",\n" + + " \"type\": \"function\",\n" + + " \"validForm\": \"current_data\",\n" + + " \"paramCount\": 1,\n" + + " \"paramStatuses\": [\n" + + " {\n" + + " \"dataType\": \"all\",\n" + + " \"must\": true,\n" + + " \"infinite\": false\n" + + " }\n" + + " ]\n" + + " },\n" + + " {\n" + + " \"name\": \"LEN\",\n" + + " \"chineseName\": \"返回文本长度\",\n" + + " \"description\": \"返回文本的长度,中文、英文都算1个字符。\",\n" + + " \"example\": \"LEN('大家好dajiahao')\",\n" + + " \"result\": \"12\",\n" + + " \"paramDescs\": [\n" + + " \"*变量或常量*(必选)\"\n" + + " ],\n" + + " \"formatString\": \"LEN(文本)\",\n" + + " \"paramArray\": [],\n" + + " \"paramData\": [],\n" + + " \"returnType\": \"number\",\n" + + " \"type\": \"function\",\n" + + " \"validForm\": \"current_data\",\n" + + " \"paramCount\": 1,\n" + + " \"paramStatuses\": [\n" + + " {\n" + + " \"dataType\": \"string\",\n" + + " \"must\": true,\n" + + " \"infinite\": false\n" + + " }\n" + + " ]\n" + + " },\n" + + " {\n" + + " \"name\": \"SEARCH\",\n" + + " \"chineseName\": \"在文本中查找关键字\",\n" + + " \"description\": \"在指定文本中查找关键字,返回第一次出现关键字的字符位置,文本的第一个字记为1。未找到,返回0。搜索开始位置,表示从文本的第几个字符开始搜索,默认为1。\",\n" + + " \"example\": \"SEARCH('大家', '大家好大家好', 3)\",\n" + + " \"result\": \"4\",\n" + + " \"paramDescs\": [\n" + + " \"*文本关键字*(必选)\",\n" + + " \"*文本*(必选)\",\n" + + " \"*搜索开始位置*(可选)\"\n" + + " ],\n" + + " \"formatString\": \"SEARCH(关键字, 文本, [搜索开始位置])\",\n" + + " \"paramArray\": [],\n" + + " \"paramData\": [],\n" + + " \"returnType\": \"number\",\n" + + " \"type\": \"function\",\n" + + " \"validForm\": \"current_data\",\n" + + " \"paramCount\": 3,\n" + + " \"paramStatuses\": [\n" + + " {\n" + + " \"dataType\": \"string\",\n" + + " \"must\": true,\n" + + " \"infinite\": false\n" + + " },\n" + + " {\n" + + " \"dataType\": \"string\",\n" + + " \"must\": true,\n" + + " \"infinite\": false\n" + + " },\n" + + " {\n" + + " \"dataType\": \"number\",\n" + + " \"must\": false,\n" + + " \"infinite\": false\n" + + " }\n" + + " ]\n" + + " },\n" + + " {\n" + + " \"name\": \"REPLACE\",\n" + + " \"chineseName\": \"替换文本中的字\",\n" + + " \"description\": \"在原文本中,从替换位置开始,往后数指定的替换字符数,将这段文本替换为新文本。\",\n" + + " \"example\": \"REPLACE('大家好大家好', 2, 3, 'dajia')\",\n" + + " \"result\": \"'大dajia家好'\",\n" + + " \"paramDescs\": [\n" + + " \"*文本*(必选)\"\n" + + " ],\n" + + " \"formatString\": \"REPLACE(原文本, 替换开始位置, 替换字符数, 新文本)\",\n" + + " \"paramArray\": [],\n" + + " \"paramData\": [],\n" + + " \"returnType\": \"string\",\n" + + " \"type\": \"function\",\n" + + " \"validForm\": \"current_data\",\n" + + " \"paramCount\": 4,\n" + + " \"paramStatuses\": [\n" + + " {\n" + + " \"dataType\": \"string\",\n" + + " \"must\": true,\n" + + " \"infinite\": false\n" + + " },\n" + + " {\n" + + " \"dataType\": \"number\",\n" + + " \"must\": true,\n" + + " \"infinite\": false\n" + + " },\n" + + " {\n" + + " \"dataType\": \"number\",\n" + + " \"must\": true,\n" + + " \"infinite\": false\n" + + " },\n" + + " {\n" + + " \"dataType\": \"string\",\n" + + " \"must\": true,\n" + + " \"infinite\": false\n" + + " }\n" + + " ]\n" + + " },\n" + + " {\n" + + " \"name\": \"REPT\",\n" + + " \"chineseName\": \"将文本重复指定次数\",\n" + + " \"description\": \"将文本重复指定次数。\",\n" + + " \"example\": \"REPT('大家', 2)\",\n" + + " \"result\": \"'大家大家'\",\n" + + " \"paramDescs\": [\n" + + " \"*文本*(必选)\",\n" + + " \"*重复次数*(必选)\"\n" + + " ],\n" + + " \"formatString\": \"REPT(文本, 重复次数)\",\n" + + " \"paramArray\": [],\n" + + " \"paramData\": [],\n" + + " \"returnType\": \"string\",\n" + + " \"type\": \"function\",\n" + + " \"validForm\": \"current_data\",\n" + + " \"paramCount\": 2,\n" + + " \"paramStatuses\": [\n" + + " {\n" + + " \"dataType\": \"string\",\n" + + " \"must\": true,\n" + + " \"infinite\": false\n" + + " },\n" + + " {\n" + + " \"dataType\": \"number\",\n" + + " \"must\": true,\n" + + " \"infinite\": false\n" + + " }\n" + + " ]\n" + + " },\n" + + " {\n" + + " \"name\": \"PAD\",\n" + + " \"chineseName\": \"将文本填充至指定长度\",\n" + + " \"description\": \"将原文本填充到指定长度,如果文本长度大于设置的长度,则不做任何操作。填充位置可用参数:'LEFT'、'RIGHT'。\",\n" + + " \"example\": \"PAD('你好', 4, '你', 'LEFT')\",\n" + + " \"result\": \"'你你你好'\",\n" + + " \"paramDescs\": [\n" + + " \"*原文本*(必选)\",\n" + + " \"*长度*(必选)\",\n" + + " \"*填充用的文本*(必选)\",\n" + + " \"*填充位置*(可选)\"\n" + + " ],\n" + + " \"formatString\": \"PAD(原文本, 长度, 填充用的文本, [填充位置])\",\n" + + " \"paramArray\": [],\n" + + " \"paramData\": [],\n" + + " \"returnType\": \"string\",\n" + + " \"type\": \"function\",\n" + + " \"validForm\": \"current_data\",\n" + + " \"paramCount\": 4,\n" + + " \"paramStatuses\": [\n" + + " {\n" + + " \"dataType\": \"string\",\n" + + " \"must\": true,\n" + + " \"infinite\": false\n" + + " },\n" + + " {\n" + + " \"dataType\": \"number\",\n" + + " \"must\": true,\n" + + " \"infinite\": false\n" + + " },\n" + + " {\n" + + " \"dataType\": \"string\",\n" + + " \"must\": true,\n" + + " \"infinite\": false\n" + + " },\n" + + " {\n" + + " \"dataType\": \"string\",\n" + + " \"must\": true,\n" + + " \"constType\": [\n" + + " \"RIGHT\",\n" + + " \"LEFT\"\n" + + " ],\n" + + " \"infinite\": false\n" + + " }\n" + + " ]\n" + + " },\n" + + " {\n" + + " \"name\": \"TRIM\",\n" + + " \"chineseName\": \"清除前后空格\",\n" + + " \"description\": \"删除文本首尾的空格。\",\n" + + " \"example\": \"TRIM(' 大家好 ')\",\n" + + " \"result\": \"'大家好'\",\n" + + " \"paramDescs\": [\n" + + " \"*文本*(必选)\"\n" + + " ],\n" + + " \"formatString\": \"TRIM(文本)\",\n" + + " \"paramArray\": [],\n" + + " \"paramData\": [],\n" + + " \"returnType\": \"string\",\n" + + " \"type\": \"function\",\n" + + " \"validForm\": \"current_data\",\n" + + " \"paramCount\": 1,\n" + + " \"paramStatuses\": [\n" + + " {\n" + + " \"dataType\": \"string\",\n" + + " \"must\": true,\n" + + " \"infinite\": false\n" + + " }\n" + + " ]\n" + + " },\n" + + " {\n" + + " \"name\": \"LEFT\",\n" + + " \"chineseName\": \"返回文本左侧开始的文字\",\n" + + " \"description\": \"从文本左侧开始,返回指定字符数的文字。\",\n" + + " \"example\": \"LEFT('大家好', 2)\",\n" + + " \"result\": \"'大家'\",\n" + + " \"paramDescs\": [\n" + + " \"*文本*(必选)\",\n" + + " \"*截取字符数*(必选)\"\n" + + " ],\n" + + " \"formatString\": \"LEFT(文本, 截取字符数)\",\n" + + " \"paramArray\": [],\n" + + " \"paramData\": [],\n" + + " \"returnType\": \"string\",\n" + + " \"type\": \"function\",\n" + + " \"validForm\": \"current_data\",\n" + + " \"paramCount\": 2,\n" + + " \"paramStatuses\": [\n" + + " {\n" + + " \"dataType\": \"string\",\n" + + " \"must\": true,\n" + + " \"infinite\": false\n" + + " },\n" + + " {\n" + + " \"dataType\": \"number\",\n" + + " \"must\": true,\n" + + " \"infinite\": false\n" + + " }\n" + + " ]\n" + + " },\n" + + " {\n" + + " \"name\": \"RIGHT\",\n" + + " \"chineseName\": \"返回文本右侧开始的文字\",\n" + + " \"description\": \"从文本右侧开始,返回指定字符数的文字。\",\n" + + " \"example\": \"RIGHT('大家好', 2)\",\n" + + " \"result\": \"'家好'\",\n" + + " \"paramDescs\": [\n" + + " \"*文本*(必选)\",\n" + + " \"*截取字符数*(必选)\"\n" + + " ],\n" + + " \"formatString\": \"RIGHT(文本, 截取字符数)\",\n" + + " \"paramArray\": [],\n" + + " \"paramData\": [],\n" + + " \"returnType\": \"string\",\n" + + " \"type\": \"function\",\n" + + " \"validForm\": \"current_data\",\n" + + " \"paramCount\": 2,\n" + + " \"paramStatuses\": [\n" + + " {\n" + + " \"dataType\": \"string\",\n" + + " \"must\": true,\n" + + " \"infinite\": false\n" + + " },\n" + + " {\n" + + " \"dataType\": \"number\",\n" + + " \"must\": true,\n" + + " \"infinite\": false\n" + + " }\n" + + " ]\n" + + " },\n" + + " {\n" + + " \"name\": \"MID\",\n" + + " \"chineseName\": \"返回文本指定位置开始的文字\",\n" + + " \"description\": \"从文本指定位置之后开始,返回指定字符数的文字。\",\n" + + " \"example\": \"MID('大家好', 2, 1)\",\n" + + " \"result\": \"'家'\",\n" + + " \"paramDescs\": [\n" + + " \"*文本*(必选)\",\n" + + " \"*指定位置*(必选)\",\n" + + " \"*截取字符数*(必选)\"\n" + + " ],\n" + + " \"formatString\": \"MID(文本, 指定位置, 截取字符数)\",\n" + + " \"paramArray\": [],\n" + + " \"paramData\": [],\n" + + " \"returnType\": \"string\",\n" + + " \"type\": \"function\",\n" + + " \"validForm\": \"current_data\",\n" + + " \"paramCount\": 3,\n" + + " \"paramStatuses\": [\n" + + " {\n" + + " \"dataType\": \"string\",\n" + + " \"must\": true,\n" + + " \"infinite\": false\n" + + " },\n" + + " {\n" + + " \"dataType\": \"number\",\n" + + " \"must\": true,\n" + + " \"infinite\": false\n" + + " },\n" + + " {\n" + + " \"dataType\": \"number\",\n" + + " \"must\": true,\n" + + " \"infinite\": false\n" + + " }\n" + + " ]\n" + + " },\n" + + " {\n" + + " \"name\": \"SCORE\",\n" + + " \"chineseName\": \"获取选项型控件分数\",\n" + + " \"description\": \"获取选项型控件(单选框、复选框、下拉菜单)分数。\",\n" + + " \"example\": \"SCORE({当前数据.单选框})\",\n" + + " \"result\": \"选项分数(注:未设置选项分数时,结果为0)\",\n" + + " \"paramDescs\": [\n" + + " \"*选项*(必选)\"\n" + + " ],\n" + + " \"formatString\": \"SCORE({选项})\",\n" + + " \"paramArray\": [],\n" + + " \"paramData\": [],\n" + + " \"returnType\": \"number\",\n" + + " \"type\": \"function\",\n" + + " \"validForm\": \"current_data\",\n" + + " \"paramCount\": 1,\n" + + " \"paramStatuses\": [\n" + + " {\n" + + " \"dataType\": \"option\",\n" + + " \"must\": true,\n" + + " \"infinite\": false\n" + + " }\n" + + " ]\n" + + " },\n" + + " {\n" + + " \"name\": \"IDCARD\",\n" + + " \"chineseName\": \"身份证函数\",\n" + + " \"description\": \"从身份证号码中获取相关信息,比如:生日(BD)、年龄(AGE)、籍贯(NA)、性别(GENDER)。\",\n" + + " \"example\": \"IDCARD( ‘******19980706****’ , ‘BD’ )\",\n" + + " \"result\": \"'1998-07-06'\",\n" + + " \"paramDescs\": [\n" + + " \"*身份证号码*(必选)\",\n" + + " \"*查找类型*(必选)\"\n" + + " ],\n" + + " \"formatString\": \"IDCARD({身份证号码}, {查找类型})\",\n" + + " \"paramArray\": [],\n" + + " \"paramData\": [],\n" + + " \"returnType\": \"string\",\n" + + " \"type\": \"function\",\n" + + " \"validForm\": \"current_data\",\n" + + " \"paramCount\": 2,\n" + + " \"paramStatuses\": [\n" + + " {\n" + + " \"dataType\": \"string\",\n" + + " \"must\": true,\n" + + " \"infinite\": false\n" + + " },\n" + + " {\n" + + " \"dataType\": \"string\",\n" + + " \"must\": true,\n" + + " \"constType\": [\n" + + " \"BD\",\n" + + " \"NA\",\n" + + " \"AGE\",\n" + + " \"GENDER\"\n" + + " ],\n" + + " \"infinite\": false\n" + + " }\n" + + " ]\n" + + " },\n" + + " {\n" + + " \"name\": \"ISSTRING\",\n" + + " \"chineseName\": \"是否是字符串\",\n" + + " \"description\": \"判断是否是字符。\",\n" + + " \"example\": \"ISSTRING('泛微123456')\",\n" + + " \"result\": \"true\",\n" + + " \"paramDescs\": [\n" + + " \"*变量或常量*(必选)\"\n" + + " ],\n" + + " \"formatString\": \"ISSTRING({任意控件})\",\n" + + " \"paramArray\": [],\n" + + " \"paramData\": [],\n" + + " \"returnType\": \"boolean\",\n" + + " \"type\": \"function\",\n" + + " \"validForm\": \"current_data\",\n" + + " \"paramCount\": 1,\n" + + " \"paramStatuses\": [\n" + + " {\n" + + " \"dataType\": \"all\",\n" + + " \"must\": true,\n" + + " \"infinite\": false\n" + + " }\n" + + " ]\n" + + " }\n" + + " ],\n" + + " \"dataType\": \"char\",\n" + + " \"name\": \"字符函数\",\n" + + " \"action\": \"DataSource\",\n" + + " \"type\": \"functions\"\n" + + " },\n" + + " {\n" + + " \"children\": [\n" + + " {\n" + + " \"name\": \"TODAY\",\n" + + " \"chineseName\": \"当前日期\",\n" + + " \"description\": \"返回当天日期。\",\n" + + " \"example\": \"TODAY()\",\n" + + " \"result\": \"'2020-01-01'\",\n" + + " \"formatString\": \"TODAY()\",\n" + + " \"paramArray\": [],\n" + + " \"paramData\": [],\n" + + " \"returnType\": \"date\",\n" + + " \"type\": \"function\",\n" + + " \"validForm\": \"current_data\",\n" + + " \"paramCount\": 0\n" + + " },\n" + + " {\n" + + " \"name\": \"NOW\",\n" + + " \"chineseName\": \"当前日期时间\",\n" + + " \"description\": \"返回当天日期+时间。\",\n" + + " \"example\": \"NOW()\",\n" + + " \"result\": \"'2016-12-24 12:05:38'\",\n" + + " \"formatString\": \"NOW()\",\n" + + " \"paramArray\": [],\n" + + " \"paramData\": [],\n" + + " \"returnType\": \"date\",\n" + + " \"type\": \"function\",\n" + + " \"validForm\": \"current_data\",\n" + + " \"paramCount\": 0\n" + + " },\n" + + " {\n" + + " \"name\": \"DATEADD\",\n" + + " \"chineseName\": \"对日期加减年、月、日\",\n" + + " \"description\": \"对日期加减按照单位加减。单位默认为日,可选单位:年Y、月M、日D、时H、分I、秒S。\",\n" + + " \"example\": \"DATEADD('2016-12-21', 3)
DATEADD('2016-12-24 20:00:00', 3, 'H')\",\n" + + " \"result\": \"'2016-12-24'
'2016-12-24 23:00:00'\",\n" + + " \"paramDescs\": [\n" + + " \"*日期*(必选)\",\n" + + " \"*数值*(必选)\",\n" + + " \"*单位*(可选)\"\n" + + " ],\n" + + " \"formatString\": \"DATEADD(日期,数值 , [单位])\",\n" + + " \"paramArray\": [],\n" + + " \"paramData\": [],\n" + + " \"returnType\": \"date\",\n" + + " \"type\": \"function\",\n" + + " \"validForm\": \"current_data\",\n" + + " \"paramCount\": 3,\n" + + " \"paramStatuses\": [\n" + + " {\n" + + " \"dataType\": \"date\",\n" + + " \"must\": true,\n" + + " \"infinite\": false\n" + + " },\n" + + " {\n" + + " \"dataType\": \"number\",\n" + + " \"must\": true,\n" + + " \"infinite\": false\n" + + " },\n" + + " {\n" + + " \"dataType\": \"string\",\n" + + " \"must\": true,\n" + + " \"constType\": [\n" + + " \"Y\",\n" + + " \"M\",\n" + + " \"D\",\n" + + " \"H\",\n" + + " \"I\",\n" + + " \"S\"\n" + + " ],\n" + + " \"infinite\": false\n" + + " }\n" + + " ]\n" + + " },\n" + + " {\n" + + " \"name\": \"DATEDIFF\",\n" + + " \"chineseName\": \"返回两个日期的差值\",\n" + + " \"description\": \"根据指定的单位,返回日期2减去日期1的差值。当日期2小于日期1时,差值为负值。单位默认为日,可选单位:年Y、月M、日D、时H、分I、秒S。\",\n" + + " \"example\": \"DATEDIF('2016-12-21', '2016-12-24')
DATEDIF('2016-12-24 20:00:00', '2016-12-25 20:00:00', 'H')\",\n" + + " \"result\": \"3
24\",\n" + + " \"paramDescs\": [\n" + + " \"*日期1*(必选)\",\n" + + " \"*日期2*(必选)\",\n" + + " \"*单位*(可选)\"\n" + + " ],\n" + + " \"formatString\": \"DATEDIFF(日期1, 日期2, [单位])\",\n" + + " \"paramArray\": [],\n" + + " \"paramData\": [],\n" + + " \"returnType\": \"number\",\n" + + " \"type\": \"function\",\n" + + " \"validForm\": \"current_data\",\n" + + " \"paramCount\": 3,\n" + + " \"paramStatuses\": [\n" + + " {\n" + + " \"dataType\": \"date\",\n" + + " \"must\": true,\n" + + " \"infinite\": false\n" + + " },\n" + + " {\n" + + " \"dataType\": \"date\",\n" + + " \"must\": true,\n" + + " \"infinite\": false\n" + + " },\n" + + " {\n" + + " \"dataType\": \"string\",\n" + + " \"must\": true,\n" + + " \"constType\": [\n" + + " \"Y\",\n" + + " \"M\",\n" + + " \"D\",\n" + + " \"H\",\n" + + " \"I\",\n" + + " \"S\"\n" + + " ],\n" + + " \"infinite\": false\n" + + " }\n" + + " ]\n" + + " },\n" + + " {\n" + + " \"name\": \"DATEFORMAT\",\n" + + " \"chineseName\": \"返回指定格式的日期\",\n" + + " \"description\": \"将日期转为指定格式返回。
yyyy 将年份显示为1900-9999
yy 将年份显示为00-99
mm 将月份显示为 01–12
dd 将日期显示为 01–31\",\n" + + " \"example\": \"DATEFORMAT('2016-12-24', 'YY-MM-DD')\",\n" + + " \"result\": \"2016-12-24\",\n" + + " \"paramDescs\": [\n" + + " \"*日期*(必选)\",\n" + + " \"*日期格式*(必选)\"\n" + + " ],\n" + + " \"formatString\": \"DATEFORMAT(日期, 可选格式)\",\n" + + " \"paramArray\": [],\n" + + " \"paramData\": [],\n" + + " \"returnType\": \"date\",\n" + + " \"type\": \"function\",\n" + + " \"validForm\": \"current_data\",\n" + + " \"paramCount\": 2,\n" + + " \"paramStatuses\": [\n" + + " {\n" + + " \"dataType\": \"date\",\n" + + " \"must\": true,\n" + + " \"infinite\": false\n" + + " },\n" + + " {\n" + + " \"dataType\": \"string\",\n" + + " \"must\": true,\n" + + " \"infinite\": false\n" + + " }\n" + + " ]\n" + + " },\n" + + " {\n" + + " \"name\": \"YEAR\",\n" + + " \"chineseName\": \"返回日期中的年\",\n" + + " \"description\": \"返回指定日期中的年。\",\n" + + " \"example\": \"YEAR('2016-12-24')\",\n" + + " \"result\": \"2016\",\n" + + " \"paramDescs\": [\n" + + " \"*日期*(必选)\"\n" + + " ],\n" + + " \"formatString\": \"YEAR(日期)\",\n" + + " \"paramArray\": [],\n" + + " \"paramData\": [],\n" + + " \"returnType\": \"number\",\n" + + " \"type\": \"function\",\n" + + " \"validForm\": \"current_data\",\n" + + " \"paramCount\": 1,\n" + + " \"paramStatuses\": [\n" + + " {\n" + + " \"dataType\": \"date\",\n" + + " \"must\": true,\n" + + " \"infinite\": false\n" + + " }\n" + + " ]\n" + + " },\n" + + " {\n" + + " \"name\": \"MONTH\",\n" + + " \"chineseName\": \"返回日期中的月\",\n" + + " \"description\": \"返回指定日期中的月。\",\n" + + " \"example\": \"MONTH('2016-12-24')\",\n" + + " \"result\": \"12\",\n" + + " \"paramDescs\": [\n" + + " \"*日期*(必选)\"\n" + + " ],\n" + + " \"formatString\": \"MONTH(日期)\",\n" + + " \"paramArray\": [\n" + + " \"String\"\n" + + " ],\n" + + " \"paramData\": [],\n" + + " \"returnType\": \"number\",\n" + + " \"type\": \"function\",\n" + + " \"validForm\": \"current_data\",\n" + + " \"paramCount\": 1,\n" + + " \"paramStatuses\": [\n" + + " {\n" + + " \"dataType\": \"date\",\n" + + " \"must\": true,\n" + + " \"infinite\": false\n" + + " }\n" + + " ]\n" + + " },\n" + + " {\n" + + " \"name\": \"DAY\",\n" + + " \"chineseName\": \"返回日期中的日\",\n" + + " \"description\": \"返回指定日期中的日。\",\n" + + " \"example\": \"DAY('2016-12-24')\",\n" + + " \"result\": \"24\",\n" + + " \"paramDescs\": [\n" + + " \"*日期*(必选)\"\n" + + " ],\n" + + " \"formatString\": \"DAY(日期)\",\n" + + " \"paramArray\": [],\n" + + " \"paramData\": [],\n" + + " \"returnType\": \"number\",\n" + + " \"type\": \"function\",\n" + + " \"validForm\": \"current_data\",\n" + + " \"paramCount\": 1,\n" + + " \"paramStatuses\": [\n" + + " {\n" + + " \"dataType\": \"date\",\n" + + " \"must\": true,\n" + + " \"infinite\": false\n" + + " }\n" + + " ]\n" + + " },\n" + + " {\n" + + " \"name\": \"HOUR\",\n" + + " \"chineseName\": \"返回日期中的小时\",\n" + + " \"description\": \"返回指定日期中的小时。\",\n" + + " \"example\": \"HOUR('2016-12-24 20:30:56')\",\n" + + " \"result\": \"20\",\n" + + " \"paramDescs\": [\n" + + " \"*日期*(必选)\"\n" + + " ],\n" + + " \"formatString\": \"HOUR(日期)\",\n" + + " \"paramArray\": [],\n" + + " \"paramData\": [],\n" + + " \"returnType\": \"number\",\n" + + " \"type\": \"function\",\n" + + " \"validForm\": \"current_data\",\n" + + " \"paramCount\": 1,\n" + + " \"paramStatuses\": [\n" + + " {\n" + + " \"dataType\": \"date\",\n" + + " \"must\": true,\n" + + " \"infinite\": false\n" + + " }\n" + + " ]\n" + + " },\n" + + " {\n" + + " \"name\": \"MINUTE\",\n" + + " \"chineseName\": \"返回日期中的分钟\",\n" + + " \"description\": \"返回指定日期中的分钟。\",\n" + + " \"example\": \"MINUTE('2016-12-24 20:30:56')\",\n" + + " \"result\": \"30\",\n" + + " \"paramDescs\": [\n" + + " \"*日期*(必选)\"\n" + + " ],\n" + + " \"formatString\": \"MINUTE(日期)\",\n" + + " \"paramArray\": [],\n" + + " \"paramData\": [],\n" + + " \"returnType\": \"number\",\n" + + " \"type\": \"function\",\n" + + " \"validForm\": \"current_data\",\n" + + " \"paramCount\": 1,\n" + + " \"paramStatuses\": [\n" + + " {\n" + + " \"dataType\": \"date\",\n" + + " \"must\": true,\n" + + " \"infinite\": false\n" + + " }\n" + + " ]\n" + + " },\n" + + " {\n" + + " \"name\": \"SECOND\",\n" + + " \"chineseName\": \"返回日期中的秒\",\n" + + " \"description\": \"返回指定日期中的秒钟。\",\n" + + " \"example\": \"SECOND('2016-12-24 20:30:56')\",\n" + + " \"result\": \"56\",\n" + + " \"paramDescs\": [\n" + + " \"*日期*(必选)\"\n" + + " ],\n" + + " \"formatString\": \"SECOND(日期)\",\n" + + " \"paramArray\": [],\n" + + " \"paramData\": [],\n" + + " \"returnType\": \"number\",\n" + + " \"type\": \"function\",\n" + + " \"validForm\": \"current_data\",\n" + + " \"paramCount\": 1,\n" + + " \"paramStatuses\": [\n" + + " {\n" + + " \"dataType\": \"date\",\n" + + " \"must\": true,\n" + + " \"infinite\": false\n" + + " }\n" + + " ]\n" + + " },\n" + + " {\n" + + " \"name\": \"WEEKNUM\",\n" + + " \"chineseName\": \"返回日期为第几周\",\n" + + " \"description\": \"返回指定日期为第几周,从每年第1天开始算第1周。\",\n" + + " \"example\": \"WEEKNUM('2016-12-24')\",\n" + + " \"result\": \"52\",\n" + + " \"paramDescs\": [\n" + + " \"*日期*(必选)\"\n" + + " ],\n" + + " \"formatString\": \"WEEKNUM(日期)\",\n" + + " \"paramArray\": [],\n" + + " \"paramData\": [],\n" + + " \"returnType\": \"number\",\n" + + " \"type\": \"function\",\n" + + " \"validForm\": \"current_data\",\n" + + " \"paramCount\": 1,\n" + + " \"paramStatuses\": [\n" + + " {\n" + + " \"dataType\": \"date\",\n" + + " \"must\": true,\n" + + " \"infinite\": false\n" + + " }\n" + + " ]\n" + + " },\n" + + " {\n" + + " \"name\": \"WEEKDAY\",\n" + + " \"chineseName\": \"返回日期为星期几\",\n" + + " \"description\": \"返回指定日期为星期几。返回值为0~6,代表周日~周六。\",\n" + + " \"example\": \"WEEKDAY('2016-12-24')\",\n" + + " \"result\": \"6\",\n" + + " \"paramDescs\": [\n" + + " \"*日期*(必选)\"\n" + + " ],\n" + + " \"formatString\": \"WEEKDAY(日期)\",\n" + + " \"paramArray\": [],\n" + + " \"paramData\": [],\n" + + " \"returnType\": \"number\",\n" + + " \"type\": \"function\",\n" + + " \"validForm\": \"current_data\",\n" + + " \"paramCount\": 1,\n" + + " \"paramStatuses\": [\n" + + " {\n" + + " \"dataType\": \"date\",\n" + + " \"must\": true,\n" + + " \"infinite\": false\n" + + " }\n" + + " ]\n" + + " },\n" + + " {\n" + + " \"name\": \"EOMONTH\",\n" + + " \"chineseName\": \"返回某月最后一天日期\",\n" + + " \"description\": \"将某月最后一天日期返回。日期可以为指定日期也可以是日期参数,之前的月数用负数表示,之后的月数用正数表示。所输入月数需为整数。\",\n" + + " \"example\": \"EOMONTH('2021-11-07', -2)\",\n" + + " \"result\": \"2021-09-30\",\n" + + " \"paramDescs\": [\n" + + " \"*日期*(必选)\",\n" + + " \"*数值*(必选)\"\n" + + " ],\n" + + " \"formatString\": \"EOMONTH(日期,指定日期之前或之后的月数)\",\n" + + " \"paramArray\": [],\n" + + " \"paramData\": [],\n" + + " \"returnType\": \"string\",\n" + + " \"type\": \"function\",\n" + + " \"validForm\": \"current_data\",\n" + + " \"paramCount\": 2,\n" + + " \"paramStatuses\": [\n" + + " {\n" + + " \"dataType\": \"date\",\n" + + " \"must\": true,\n" + + " \"infinite\": false\n" + + " },\n" + + " {\n" + + " \"dataType\": \"number\",\n" + + " \"must\": true,\n" + + " \"infinite\": false\n" + + " }\n" + + " ]\n" + + " },\n" + + " {\n" + + " \"name\": \"CURRYEAR\",\n" + + " \"chineseName\": \"返回当前年份\",\n" + + " \"description\": \"取当前日期的年份。\",\n" + + " \"example\": \"假设当前时间为:2022年2月17日 11:20:30 ,CURRYEAR()\",\n" + + " \"result\": \"2022\",\n" + + " \"formatString\": \"CURRYEAR()\",\n" + + " \"paramArray\": [],\n" + + " \"paramData\": [],\n" + + " \"returnType\": \"number\",\n" + + " \"type\": \"function\",\n" + + " \"validForm\": \"current_data\",\n" + + " \"paramCount\": 0\n" + + " },\n" + + " {\n" + + " \"name\": \"CURRMONTH\",\n" + + " \"chineseName\": \"返回当前月份\",\n" + + " \"description\": \"取当前日期的月份。\",\n" + + " \"example\": \"假设当前时间为:2022年2月17日 11:20:30 ,CURRMONTH()\",\n" + + " \"result\": \"2\",\n" + + " \"formatString\": \"CURRMONTH()\",\n" + + " \"paramArray\": [],\n" + + " \"paramData\": [],\n" + + " \"returnType\": \"number\",\n" + + " \"type\": \"function\",\n" + + " \"validForm\": \"current_data\",\n" + + " \"paramCount\": 0\n" + + " },\n" + + " {\n" + + " \"name\": \"CURRDAY\",\n" + + " \"chineseName\": \"返回当前第几日(当月)\",\n" + + " \"description\": \"取当前日期的天。\",\n" + + " \"example\": \"假设当前时间为:2022年2月17日 11:20:30 ,CURRDAY()\",\n" + + " \"result\": \"17\",\n" + + " \"formatString\": \"CURRDAY()\",\n" + + " \"paramArray\": [],\n" + + " \"paramData\": [],\n" + + " \"returnType\": \"number\",\n" + + " \"type\": \"function\",\n" + + " \"validForm\": \"current_data\",\n" + + " \"paramCount\": 0\n" + + " },\n" + + " {\n" + + " \"name\": \"CURRWEEK\",\n" + + " \"chineseName\": \"返回当前是周几\",\n" + + " \"description\": \"取当前日期是周几。\",\n" + + " \"example\": \"假设当前时间为:2022年2月17日 11:20:30 ,CURRWEEK()\",\n" + + " \"result\": \"4\",\n" + + " \"formatString\": \"CURRWEEK()\",\n" + + " \"paramArray\": [],\n" + + " \"paramData\": [],\n" + + " \"returnType\": \"number\",\n" + + " \"type\": \"function\",\n" + + " \"validForm\": \"current_data\",\n" + + " \"paramCount\": 0\n" + + " },\n" + + " {\n" + + " \"name\": \"CURRHOUR\",\n" + + " \"chineseName\": \"返回当前小时\",\n" + + " \"description\": \"取当前日期的小时。\",\n" + + " \"example\": \"假设当前时间为:2022年2月17日 11:20:30 ,CURRHOUR()\",\n" + + " \"result\": \"11\",\n" + + " \"formatString\": \"CURRHOUR()\",\n" + + " \"paramArray\": [],\n" + + " \"paramData\": [],\n" + + " \"returnType\": \"number\",\n" + + " \"type\": \"function\",\n" + + " \"validForm\": \"current_data\",\n" + + " \"paramCount\": 0\n" + + " },\n" + + " {\n" + + " \"name\": \"CURRMINUTE\",\n" + + " \"chineseName\": \"返回当前分\",\n" + + " \"description\": \"取当前日期的分钟。\",\n" + + " \"example\": \"假设当前时间为:2022年2月17日 11:20:30 ,CURRMINUTE()\",\n" + + " \"result\": \"20\",\n" + + " \"formatString\": \"CURRMINUTE()\",\n" + + " \"paramArray\": [],\n" + + " \"paramData\": [],\n" + + " \"returnType\": \"number\",\n" + + " \"type\": \"function\",\n" + + " \"validForm\": \"current_data\",\n" + + " \"paramCount\": 0\n" + + " },\n" + + " {\n" + + " \"name\": \"CURRSECOND\",\n" + + " \"chineseName\": \"返回当前秒\",\n" + + " \"description\": \"取当前日期的秒钟。\",\n" + + " \"example\": \"假设当前时间为:2022年2月17日 11:20:30 ,CURRSECOND()\",\n" + + " \"result\": \"30\",\n" + + " \"formatString\": \"CURRSECOND()\",\n" + + " \"paramArray\": [],\n" + + " \"paramData\": [],\n" + + " \"returnType\": \"number\",\n" + + " \"type\": \"function\",\n" + + " \"validForm\": \"current_data\",\n" + + " \"paramCount\": 0\n" + + " },\n" + + " {\n" + + " \"name\": \"MAXDATE\",\n" + + " \"chineseName\": \"返回一组日期中的最大值\",\n" + + " \"description\": \"取一组日期中的最大值。\",\n" + + " \"example\": \"MAXDATE('2016-12-24', '2022-12-24')\",\n" + + " \"result\": \"2022-12-24\",\n" + + " \"paramDescs\": [\n" + + " \"*日期1*(必选)\",\n" + + " \"*日期2*(必选)\"\n" + + " ],\n" + + " \"formatString\": \"MAXDATE(日期1,日期2,……)\",\n" + + " \"paramArray\": [],\n" + + " \"paramData\": [],\n" + + " \"returnType\": \"date\",\n" + + " \"type\": \"function\",\n" + + " \"validForm\": \"current_data\",\n" + + " \"paramCount\": -1,\n" + + " \"paramStatuses\": [\n" + + " {\n" + + " \"dataType\": \"date\",\n" + + " \"must\": true,\n" + + " \"infinite\": true\n" + + " }\n" + + " ]\n" + + " },\n" + + " {\n" + + " \"name\": \"MINDATE\",\n" + + " \"chineseName\": \"返回一组日期中的最小值\",\n" + + " \"description\": \"取一组日期中的最小值。\",\n" + + " \"example\": \"MINDATE('2016-12-24', '2022-12-24')\",\n" + + " \"result\": \"2016-12-24\",\n" + + " \"paramDescs\": [\n" + + " \"*日期1*(必选)\",\n" + + " \"*日期2*(必选)\"\n" + + " ],\n" + + " \"formatString\": \"MINDATE(日期1,日期2,……)\",\n" + + " \"paramArray\": [],\n" + + " \"paramData\": [],\n" + + " \"returnType\": \"date\",\n" + + " \"type\": \"function\",\n" + + " \"validForm\": \"current_data\",\n" + + " \"paramCount\": -1,\n" + + " \"paramStatuses\": [\n" + + " {\n" + + " \"dataType\": \"date\",\n" + + " \"must\": true,\n" + + " \"infinite\": true\n" + + " }\n" + + " ]\n" + + " },\n" + + " {\n" + + " \"name\": \"DAYSINMONTH\",\n" + + " \"chineseName\": \"返回指定月的天数\",\n" + + " \"description\": \"返回指定月的天数。\",\n" + + " \"example\": \"DAYSINMONTH('2024-01-01')\",\n" + + " \"result\": \"31\",\n" + + " \"paramDescs\": [\n" + + " \"*日期*(必选)\"\n" + + " ],\n" + + " \"formatString\": \"DAYSINMONTH(日期)\",\n" + + " \"paramArray\": [],\n" + + " \"paramData\": [],\n" + + " \"returnType\": \"number\",\n" + + " \"type\": \"function\",\n" + + " \"validForm\": \"days_in_month\",\n" + + " \"paramCount\": -1,\n" + + " \"paramStatuses\": [\n" + + " {\n" + + " \"dataType\": \"date\",\n" + + " \"must\": true,\n" + + " \"infinite\": true\n" + + " }\n" + + " ]\n" + + " },\n" + + " ],\n" + + " \"dataType\": \"date\",\n" + + " \"name\": \"日期函数\",\n" + + " \"action\": \"DataSource\",\n" + + " \"type\": \"functions\"\n" + + " },\n" + + " {\n" + + " \"children\": [\n" + + " {\n" + + " \"name\": \"IF\",\n" + + " \"chineseName\": \"如果条件为真,则...否则...\",\n" + + " \"description\": \"如果条件为真,则执行表达式1,为假则执行表达式2。条件中不可嵌套使用IF函数。\",\n" + + " \"example\": \"IF({员工表.年龄} > 60, '退休', '在职') \",\n" + + " \"result\": \"'退休'
'在职'\",\n" + + " \"paramDescs\": [\n" + + " \"*条件*(必选)\",\n" + + " \"*表达式1*(必选)\",\n" + + " \"*表达式2*(必选)\"\n" + + " ],\n" + + " \"formatString\": \"IF(条件, 表达式1, 表达式2)\",\n" + + " \"paramArray\": [],\n" + + " \"paramData\": [],\n" + + " \"returnType\": \"all\",\n" + + " \"type\": \"function\",\n" + + " \"validForm\": \"current_data\",\n" + + " \"paramCount\": 3,\n" + + " \"paramStatuses\": [\n" + + " {\n" + + " \"dataType\": \"boolean\",\n" + + " \"must\": true,\n" + + " \"infinite\": false\n" + + " },\n" + + " {\n" + + " \"dataType\": \"all\",\n" + + " \"must\": true,\n" + + " \"infinite\": false\n" + + " },\n" + + " {\n" + + " \"dataType\": \"all\",\n" + + " \"must\": true,\n" + + " \"infinite\": false\n" + + " }\n" + + " ]\n" + + " },\n" + + " {\n" + + " \"name\": \"AND\",\n" + + " \"chineseName\": \"且\",\n" + + " \"description\": \"所有条件均为真,则返回真,否则返回假。逻辑操作AND的函数模式。\",\n" + + " \"example\": \"AND(2 = 2, 2 < 2)\",\n" + + " \"result\": \"false\",\n" + + " \"paramDescs\": [\n" + + " \"*条件1*(必选)\",\n" + + " \"*条件2*(可选,可输入多个参数)\"\n" + + " ],\n" + + " \"formatString\": \"AND(条件1, 条件2, [条件3, …])\",\n" + + " \"paramArray\": [],\n" + + " \"paramData\": [],\n" + + " \"returnType\": \"boolean\",\n" + + " \"type\": \"function\",\n" + + " \"validForm\": \"current_data\",\n" + + " \"paramCount\": -1,\n" + + " \"paramStatuses\": [\n" + + " {\n" + + " \"dataType\": \"boolean\",\n" + + " \"must\": true,\n" + + " \"infinite\": true\n" + + " }\n" + + " ]\n" + + " },\n" + + " {\n" + + " \"name\": \"OR\",\n" + + " \"chineseName\": \"或\",\n" + + " \"description\": \"任意一个条件为真,则返回真,否则返回假。逻辑操作OR的函数模式。\",\n" + + " \"example\": \"OR(2 = 2, 2 > 3)\",\n" + + " \"result\": \"true\",\n" + + " \"paramDescs\": [\n" + + " \"*条件1*(必选)\",\n" + + " \"*条件2*(可选,可输入多个参数)\"\n" + + " ],\n" + + " \"formatString\": \"OR(条件1, 条件2, [条件3, …])\",\n" + + " \"paramArray\": [],\n" + + " \"paramData\": [],\n" + + " \"returnType\": \"boolean\",\n" + + " \"type\": \"function\",\n" + + " \"validForm\": \"current_data\",\n" + + " \"paramCount\": -1,\n" + + " \"paramStatuses\": [\n" + + " {\n" + + " \"dataType\": \"boolean\",\n" + + " \"must\": true,\n" + + " \"infinite\": true\n" + + " }\n" + + " ]\n" + + " },\n" + + " {\n" + + " \"name\": \"NOT\",\n" + + " \"chineseName\": \"反转真假结果\",\n" + + " \"description\": \"对逻辑结果取反。\",\n" + + " \"example\": \"NOT(2 > 3)\",\n" + + " \"result\": \"true\",\n" + + " \"paramDescs\": [\n" + + " \"*逻辑结果*(必选)\"\n" + + " ],\n" + + " \"formatString\": \"NOT(逻辑结果)\",\n" + + " \"paramArray\": [],\n" + + " \"paramData\": [],\n" + + " \"returnType\": \"boolean\",\n" + + " \"type\": \"function\",\n" + + " \"validForm\": \"current_data\",\n" + + " \"paramCount\": 1,\n" + + " \"paramStatuses\": [\n" + + " {\n" + + " \"dataType\": \"boolean\",\n" + + " \"must\": true,\n" + + " \"infinite\": false\n" + + " }\n" + + " ]\n" + + " },\n" + + " {\n" + + " \"name\": \"IN\",\n" + + " \"chineseName\": \"变量是否包含在一组结果中\",\n" + + " \"description\": \"任意类型的变量或常量等于一组同类型变量或常量结果中的任意一个,则返回真。\",\n" + + " \"example\": \"IN(2, [2, 3, 4])\",\n" + + " \"result\": \"true\",\n" + + " \"paramDescs\": [\n" + + " \"*变量*(必选)\",\n" + + " \"*变量数组*(必选)\"\n" + + " ],\n" + + " \"formatString\": \"IN(变量, [变量1, 变量2, …])\",\n" + + " \"paramArray\": [],\n" + + " \"paramData\": [\n" + + " \"{}\",\n" + + " \"[]\"\n" + + " ],\n" + + " \"returnType\": \"boolean\",\n" + + " \"type\": \"function\",\n" + + " \"validForm\": \"current_data\",\n" + + " \"paramCount\": 2,\n" + + " \"paramStatuses\": [\n" + + " {\n" + + " \"dataType\": \"all\",\n" + + " \"must\": true,\n" + + " \"infinite\": false\n" + + " },\n" + + " {\n" + + " \"dataType\": \"array\",\n" + + " \"must\": true,\n" + + " \"infinite\": false\n" + + " }\n" + + " ]\n" + + " },\n" + + " {\n" + + " \"name\": \"LIKE\",\n" + + " \"chineseName\": \"文本是否包含任意一个关键字\",\n" + + " \"description\": \"文本类型的变量或常量包含一组文本类型变量或常量结果中的任意一个,则返回真。逻辑操作LIKE的函数模式。\",\n" + + " \"example\": \"LIKE('大家好', ['大家', '好'])\",\n" + + " \"result\": \"true\",\n" + + " \"paramDescs\": [\n" + + " \"*文本*(必选)\",\n" + + " \"*文本数组*(必选)\"\n" + + " ],\n" + + " \"formatString\": \"LIKE(文本, [文本1, 文本2, …])\",\n" + + " \"paramArray\": [],\n" + + " \"paramData\": [\n" + + " \"{}\",\n" + + " \"[]\"\n" + + " ],\n" + + " \"returnType\": \"boolean\",\n" + + " \"type\": \"function\",\n" + + " \"validForm\": \"current_data\",\n" + + " \"paramCount\": 2,\n" + + " \"paramStatuses\": [\n" + + " {\n" + + " \"dataType\": \"string\",\n" + + " \"must\": true,\n" + + " \"infinite\": false\n" + + " },\n" + + " {\n" + + " \"dataType\": \"array\",\n" + + " \"must\": true,\n" + + " \"infinite\": false\n" + + " }\n" + + " ]\n" + + " },\n" + + " {\n" + + " \"name\": \"ISEMPTY\",\n" + + " \"chineseName\": \"是否为空\",\n" + + " \"description\": \"变量为空或未填写,则返回真。\",\n" + + " \"example\": \"ISEMPTY({员工表.电话})\",\n" + + " \"result\": \"true\",\n" + + " \"paramDescs\": [\n" + + " \"*变量或常量*(可选)\"\n" + + " ],\n" + + " \"formatString\": \"ISEMPTY(变量)\",\n" + + " \"paramArray\": [],\n" + + " \"paramData\": [],\n" + + " \"returnType\": \"boolean\",\n" + + " \"type\": \"function\",\n" + + " \"validForm\": \"current_data\",\n" + + " \"paramCount\": 1,\n" + + " \"paramStatuses\": [\n" + + " {\n" + + " \"dataType\": \"all\",\n" + + " \"must\": true,\n" + + " \"infinite\": false\n" + + " }\n" + + " ]\n" + + " },\n" + + " {\n" + + " \"name\": \"TRUE\",\n" + + " \"chineseName\": \"返回真\",\n" + + " \"description\": \"返回真。\",\n" + + " \"example\": \"TRUE()\",\n" + + " \"result\": \"true\",\n" + + " \"formatString\": \"TRUE()\",\n" + + " \"paramArray\": [],\n" + + " \"paramData\": [],\n" + + " \"returnType\": \"boolean\",\n" + + " \"type\": \"function\",\n" + + " \"validForm\": \"current_data\",\n" + + " \"paramCount\": 0\n" + + " },\n" + + " {\n" + + " \"name\": \"FALSE\",\n" + + " \"chineseName\": \"返回假\",\n" + + " \"description\": \"返回假。\",\n" + + " \"example\": \"FALSE()\",\n" + + " \"result\": \"false\",\n" + + " \"formatString\": \"FALSE()\",\n" + + " \"paramArray\": [],\n" + + " \"paramData\": [],\n" + + " \"returnType\": \"boolean\",\n" + + " \"type\": \"function\",\n" + + " \"validForm\": \"current_data\",\n" + + " \"paramCount\": 0\n" + + " },\n" + + " {\n" + + " \"name\": \"IFS\",\n" + + " \"chineseName\": \"多条件\",\n" + + " \"description\": \"多个条件判断,位于单数位置的参数设置为条件,位于双数位置的参数设置为结果,最后一个参数为默认返回值,当所有条件都不满足的时候返回默认参数。\",\n" + + " \"example\": \"IFS(1>1,1,1=1,2,0)\",\n" + + " \"result\": \"2\",\n" + + " \"paramDescs\": [\n" + + " \"*条件1*(必选)\",\n" + + " \"*变量或常量*(必选)\",\n" + + " \"*条件2*(必选)\",\n" + + " \"*变量或常量*(必选)\",\n" + + " \"*变量或常量*(必选)\"\n" + + " ],\n" + + " \"formatString\": \"IFS({条件1},{结果1},{条件2},{结果2}...{默认结果})\",\n" + + " \"paramArray\": [],\n" + + " \"paramData\": [],\n" + + " \"returnType\": \"all\",\n" + + " \"type\": \"function\",\n" + + " \"validForm\": \"current_data\",\n" + + " \"paramCount\": -1,\n" + + " \"paramStatuses\": [\n" + + " {\n" + + " \"dataType\": \"boolean\",\n" + + " \"must\": true,\n" + + " \"infinite\": false\n" + + " },\n" + + " {\n" + + " \"dataType\": \"all\",\n" + + " \"must\": true,\n" + + " \"infinite\": false\n" + + " },\n" + + " {\n" + + " \"dataType\": \"all\",\n" + + " \"must\": true,\n" + + " \"infinite\": false\n" + + " }\n" + + " ]\n" + + " },\n" + + " {\n" + + " \"name\": \"SWITCH\",\n" + + " \"chineseName\": \"条件选择\",\n" + + " \"description\": \"条件选择。\",\n" + + " \"example\": \"SWITCH({字段1},1,'A',2,'B','C')\",\n" + + " \"result\": \"假设字段1为2,结果:'B'\",\n" + + " \"paramDescs\": [\n" + + " \"*变量或常量*(必选)\",\n" + + " \"*变量或常量*(必选)\",\n" + + " \"*变量或常量*(必选)\",\n" + + " \"*变量或常量*(可选)\",\n" + + " \"*变量或常量*(可选)\",\n" + + " \"*变量或常量*(必选)\"\n" + + " ],\n" + + " \"formatString\": \"SWITCH({变量},{条件1},{结果1},{条件2},{结果2}...{默认结果})\",\n" + + " \"paramArray\": [],\n" + + " \"paramData\": [],\n" + + " \"returnType\": \"all\",\n" + + " \"type\": \"function\",\n" + + " \"validForm\": \"current_data\",\n" + + " \"paramCount\": -1,\n" + + " \"paramStatuses\": [\n" + + " {\n" + + " \"dataType\": \"all\",\n" + + " \"must\": true,\n" + + " \"infinite\": false\n" + + " },\n" + + " {\n" + + " \"dataType\": \"all\",\n" + + " \"must\": true,\n" + + " \"infinite\": false\n" + + " },\n" + + " {\n" + + " \"dataType\": \"all\",\n" + + " \"must\": true,\n" + + " \"infinite\": false\n" + + " }\n" + + " ]\n" + + " }\n" + + " ],\n" + + " \"dataType\": \"logic\",\n" + + " \"name\": \"逻辑函数\",\n" + + " \"action\": \"DataSource\",\n" + + " \"type\": \"functions\"\n" + + " },\n" + + " {\n" + + " \"children\": [\n" + + " {\n" + + " \"name\": \"ROUNDUP\",\n" + + " \"chineseName\": \"向上舍入\",\n" + + " \"description\": \"根据设置的小数位精确度,返回对数值向上舍入后的值。小数位精确度取值可为正整数,0,负整数。如果小数位精确度为正整数,则向上舍入到指定的小数位。如果小数位精确度等于 0,则向上舍入到最接近的整数。如果小数位精确度为负整数,则在小数点左侧向上进行舍入。小数位精确度不支持变量。小数位精确度默认为0,即只保留整数。\",\n" + + " \"example\": \"ROUNDUP(76.9,0)\",\n" + + " \"result\": \"77\",\n" + + " \"paramDescs\": [\n" + + " \"*数字*(必选)\",\n" + + " \"*小数位精确度*(可选)\"\n" + + " ],\n" + + " \"formatString\": \"ROUNDUP(数字, [小数位精确度])\",\n" + + " \"paramArray\": [],\n" + + " \"paramData\": [],\n" + + " \"returnType\": \"number\",\n" + + " \"type\": \"function\",\n" + + " \"validForm\": \"current_data\",\n" + + " \"paramCount\": 2,\n" + + " \"paramStatuses\": [\n" + + " {\n" + + " \"dataType\": \"number\",\n" + + " \"must\": true,\n" + + " \"infinite\": false\n" + + " },\n" + + " {\n" + + " \"dataType\": \"number\",\n" + + " \"must\": true,\n" + + " \"infinite\": false\n" + + " }\n" + + " ]\n" + + " },\n" + + " {\n" + + " \"name\": \"ROUND\",\n" + + " \"chineseName\": \"四舍五入\",\n" + + " \"description\": \"根据设置的小数位精确度,返回对数值四舍五入后的值。小数位精确度取值可为正整数,0,负整数。如果小数位精确度为正整数,针对小数点后的数据进行四舍五入;如果小数位精确度等于 0,返回最接近数值的整数;如果小数位精确度为负整数,针对小数点前的数据进行四舍五入,被舍掉的数据用0占位。小数位精确度不支持变量。小数位精确度默认为0,即只保留整数。\",\n" + + " \"example\": \"ROUND(123.456,2),ROUND(123.456,0),ROUND(123.456,-2)\",\n" + + " \"result\": \"依次为123.46,123,100\",\n" + + " \"paramDescs\": [\n" + + " \"*数字*(必选)\",\n" + + " \"*小数位精确度*(可选)\"\n" + + " ],\n" + + " \"formatString\": \"ROUND(数字, [小数位精确度])\",\n" + + " \"paramArray\": [],\n" + + " \"paramData\": [],\n" + + " \"returnType\": \"number\",\n" + + " \"type\": \"function\",\n" + + " \"validForm\": \"current_data\",\n" + + " \"paramCount\": 2,\n" + + " \"paramStatuses\": [\n" + + " {\n" + + " \"dataType\": \"number\",\n" + + " \"must\": true,\n" + + " \"infinite\": false\n" + + " },\n" + + " {\n" + + " \"dataType\": \"number\",\n" + + " \"must\": true,\n" + + " \"infinite\": false\n" + + " }\n" + + " ]\n" + + " },\n" + + " {\n" + + " \"name\": \"ROUNDDOWN\",\n" + + " \"chineseName\": \"向下舍入\",\n" + + " \"description\": \"根据设置的小数位精确度,返回对数值向下舍入后的值。小数位精确度取值可为正整数,0,负整数。如果小数位精确度为正整数,则向下舍入到指定的小数位。如果小数位精确度等于 0,则向下舍入到最接近的整数。如果小数位精确度为负整数,则在小数点左侧向下进行舍入。小数位精确度不支持变量。小数位精确度默认为0,即只保留整数。\",\n" + + " \"example\": \"ROUNDDOWN(76.9,0)\",\n" + + " \"result\": \"76\",\n" + + " \"paramDescs\": [\n" + + " \"*数字*(必选)\",\n" + + " \"*小数位精确度*(可选)\"\n" + + " ],\n" + + " \"formatString\": \"ROUNDDOWN(数字, [小数位精确度])\",\n" + + " \"paramArray\": [],\n" + + " \"paramData\": [],\n" + + " \"returnType\": \"number\",\n" + + " \"type\": \"function\",\n" + + " \"validForm\": \"current_data\",\n" + + " \"paramCount\": 2,\n" + + " \"paramStatuses\": [\n" + + " {\n" + + " \"dataType\": \"number\",\n" + + " \"must\": true,\n" + + " \"infinite\": false\n" + + " },\n" + + " {\n" + + " \"dataType\": \"number\",\n" + + " \"must\": true,\n" + + " \"infinite\": false\n" + + " }\n" + + " ]\n" + + " },\n" + + " {\n" + + " \"name\": \"AGGREGATION\",\n" + + " \"chineseName\": \"聚合运算\",\n" + + " \"description\": \"将一组数据进行统计计算,支持最大值(MAX)、最小值(MIN)、平均值(AVG)。\",\n" + + " \"example\": \"AGGREGATION(1 , 2,3,'AVG')\",\n" + + " \"result\": \"2\",\n" + + " \"paramDescs\": [\n" + + " \"*数字*(必选)\",\n" + + " \"*聚合运算类型*(必选)\"\n" + + " ],\n" + + " \"formatString\": \"AGGREGATION({数字}...,{聚合运算类型})\",\n" + + " \"paramArray\": [],\n" + + " \"paramData\": [],\n" + + " \"returnType\": \"number\",\n" + + " \"type\": \"function\",\n" + + " \"validForm\": \"current_data\",\n" + + " \"paramCount\": -1,\n" + + " \"paramStatuses\": [\n" + + " {\n" + + " \"dataType\": \"number\",\n" + + " \"must\": true,\n" + + " \"infinite\": true\n" + + " },\n" + + " {\n" + + " \"dataType\": \"string\",\n" + + " \"must\": true,\n" + + " \"constType\": [\n" + + " \"avg\",\n" + + " \"max\",\n" + + " \"min\"\n" + + " ],\n" + + " \"infinite\": false\n" + + " }\n" + + " ]\n" + + " },\n" + + " {\n" + + " \"name\": \"MOD\",\n" + + " \"chineseName\": \"求余\",\n" + + " \"description\": \"将两个参数进行除法运算然后得出余数返回。\",\n" + + " \"example\": \"MOD( 7 , 3 )\",\n" + + " \"result\": \"1\",\n" + + " \"paramDescs\": [\n" + + " \"*数字*(必选)\",\n" + + " \"*数字*(必选)\"\n" + + " ],\n" + + " \"formatString\": \"ROUNDDOWN({数字},{数字})\",\n" + + " \"paramArray\": [],\n" + + " \"paramData\": [],\n" + + " \"returnType\": \"number\",\n" + + " \"type\": \"function\",\n" + + " \"validForm\": \"current_data\",\n" + + " \"paramCount\": 2,\n" + + " \"paramStatuses\": [\n" + + " {\n" + + " \"dataType\": \"number\",\n" + + " \"must\": true,\n" + + " \"infinite\": false\n" + + " },\n" + + " {\n" + + " \"dataType\": \"number\",\n" + + " \"must\": true,\n" + + " \"infinite\": false\n" + + " }\n" + + " ]\n" + + " },\n" + + " {\n" + + " \"name\": \"TRUNC\",\n" + + " \"chineseName\": \"数字格式化\",\n" + + " \"description\": \"将小数点格式化成指定位数。\",\n" + + " \"example\": \"TRUNC( 2.123 , 2 )\",\n" + + " \"result\": \"2.12\",\n" + + " \"paramDescs\": [\n" + + " \"*数字*(必选)\",\n" + + " \"*精度*(必选)\"\n" + + " ],\n" + + " \"formatString\": \"ROUNDDOWN({数字},{精度})\",\n" + + " \"paramArray\": [],\n" + + " \"paramData\": [],\n" + + " \"returnType\": \"number\",\n" + + " \"type\": \"function\",\n" + + " \"validForm\": \"current_data\",\n" + + " \"paramCount\": 2,\n" + + " \"paramStatuses\": [\n" + + " {\n" + + " \"dataType\": \"number\",\n" + + " \"must\": true,\n" + + " \"infinite\": false\n" + + " },\n" + + " {\n" + + " \"dataType\": \"number\",\n" + + " \"must\": true,\n" + + " \"infinite\": false\n" + + " }\n" + + " ]\n" + + " }\n" + + " ],\n" + + " \"dataType\": \"math\",\n" + + " \"name\": \"数学函数\",\n" + + " \"action\": \"DataSource\",\n" + + " \"type\": \"functions\"\n" + + " },\n" + + " {\n" + + " \"children\": [\n" + + " {\n" + + " \"name\": \"GETMONEY\",\n" + + " \"chineseName\": \"获取所给定数字的金额大写\",\n" + + " \"description\": \"将金额转换成中文金额大写。\",\n" + + " \"example\": \"GETMONEY({1234})\",\n" + + " \"result\": \"壹仟贰佰叁拾肆元整\",\n" + + " \"paramDescs\": [\n" + + " \"*数字*(必选)\"\n" + + " ],\n" + + " \"formatString\": \"GETMONEY({数字})\",\n" + + " \"paramData\": [],\n" + + " \"returnType\": \"\",\n" + + " \"type\": \"function\",\n" + + " \"validForm\": \"current_data\",\n" + + " \"paramCount\": 1,\n" + + " \"paramStatuses\": [\n" + + " {\n" + + " \"dataType\": \"number\",\n" + + " \"must\": true,\n" + + " \"infinite\": false\n" + + " }\n" + + " ]\n" + + " }\n" + + " ],\n" + + " \"dataType\": \"finance\",\n" + + " \"name\": \"财务函数\",\n" + + " \"action\": \"DataSource\",\n" + + " \"type\": \"functions\"\n" + + " }\n" + + " ]\n" + + "}"; +} diff --git a/src/com/engine/salary/formlua/core/QLExpressContext.java b/src/com/engine/salary/formlua/core/QLExpressContext.java new file mode 100644 index 000000000..4fa77597f --- /dev/null +++ b/src/com/engine/salary/formlua/core/QLExpressContext.java @@ -0,0 +1,18 @@ +package com.engine.salary.formlua.core; + +import com.ql.util.express.IExpressContext; + +import java.util.HashMap; +import java.util.Map; + +@SuppressWarnings("serial") +public class QLExpressContext extends HashMap implements + IExpressContext { + + + public QLExpressContext(Map aProperties) { + super(aProperties); + } + + +} diff --git a/src/com/engine/salary/formlua/core/QlExpress.java b/src/com/engine/salary/formlua/core/QlExpress.java new file mode 100644 index 000000000..9660ff1fe --- /dev/null +++ b/src/com/engine/salary/formlua/core/QlExpress.java @@ -0,0 +1,279 @@ +package com.engine.salary.formlua.core; + +import com.engine.salary.formlua.entity.parameter.DataType; +import com.engine.salary.formlua.entity.parameter.FuncNames; +import com.engine.salary.formlua.entity.standard.ExcelResult; +import com.engine.salary.formlua.func.compare.*; +import com.engine.salary.formlua.func.date.DateTimeService; +import com.engine.salary.formlua.func.date.DateTimeServiceImpl; +import com.engine.salary.formlua.func.finance.FinanceService; +import com.engine.salary.formlua.func.finance.FinanceServiceImpl; +import com.engine.salary.formlua.func.find.FindFuncsService; +import com.engine.salary.formlua.func.logic.IfOperator; +import com.engine.salary.formlua.func.logic.LogicService; +import com.engine.salary.formlua.func.logic.LogicServiceImpl; +import com.engine.salary.formlua.func.math.MathFuncsService; +import com.engine.salary.formlua.func.math.MathFuncsServiceImpl; +import com.engine.salary.formlua.func.string.StringFormulaService; +import com.engine.salary.formlua.func.string.StringFormulaServiceImpl; +import com.engine.salary.formlua.util.ExpressRegularUtil; +import com.ql.util.express.DynamicParamsUtil; +import com.ql.util.express.ExpressRunner; +import com.ql.util.express.IExpressContext; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.lang.reflect.InvocationTargetException; +import java.util.Map; +import java.util.regex.PatternSyntaxException; + +/** + * 执行业务类 + */ +public class QlExpress { + + public static ExpressRunner runner; + + static { + runner = new ExpressRunner(true, false); + runner.setShortCircuit(true); + } + + private static boolean isInitialRunner = false; + + +// AggregationFunc aggregationFunc; + + LogicService logicService = new LogicServiceImpl(); + + DateTimeService dateTimeService = new DateTimeServiceImpl(); + + StringFormulaService stringFormulaService = new StringFormulaServiceImpl(); + + MathFuncsService mathFuncsService = new MathFuncsServiceImpl(); + + FindFuncsService findFuncsService; + +// private ExcelFuncs excelFuncs; +// +// private HrmDbService hrmDbService; + + private FinanceService financeService = new FinanceServiceImpl(); + // private RemoteExcelformulaService remoteExcelformulaService; + private String errorInfo; + protected final Logger logger = LoggerFactory.getLogger(this.getClass()); + + + /** + * @param statement 执行语句 + * @param context 上下文 + * @throws Exception + */ + public ExcelResult execute(String statement, Map context) { + String expressSql = statement; + initRunner(runner); + DynamicParamsUtil.supportDynamicParams = true; + //初步的语法的格式校验 + IExpressContext expressContext = new QLExpressContext(context); +// ThreadLocalData threadLocalData=new ThreadLocalData(); +// threadLocalData.setExpressContext(context); +// ParamContext.get().setValue("formulaParam",threadLocalData); +// ParamContext.get().setValue("currentUser",simpleEmployee); + ExcelResult excelResult = new ExcelResult(); + try { + ExpressRegularUtil.checkFuncExpress(expressSql); + expressSql = expressSql.replaceAll("\\{", ""); + expressSql = expressSql.replaceAll("\\}", ""); + + excelResult.setExpress(expressSql); + excelResult.setExpressContext(expressContext); + Object obj = runner.execute(expressSql, expressContext, null, true, false); + + if (obj != null) { + if (obj instanceof DataType) { + DataType dataType = (DataType) obj; + excelResult.setData(dataType.getContent()); + excelResult.setDataType(dataType.getDataType()); + } else { + excelResult.setData(obj); + } + excelResult.setStatus(true); + } else { + excelResult.setStatus(false); + } + return excelResult; + } catch (Throwable e) { + logger.error("express run err", e); + while (e.getCause() != null) { + e = e.getCause(); + } + String errorMsg = e.getMessage(); + if (e instanceof PatternSyntaxException) { + PatternSyntaxException patternSyntaxException = (PatternSyntaxException) e; + errorMsg = patternSyntaxException.getDescription(); + } else { + if (null != e.getCause()) { + errorMsg = e.getCause().getMessage(); + if (e.getCause() instanceof InvocationTargetException) { + InvocationTargetException invocationTargetException = (InvocationTargetException) e.getCause(); + errorMsg = invocationTargetException.getTargetException().getMessage(); + } + } + } + + excelResult.setStatus(false); + excelResult.setErrorMsg(errorMsg); + return excelResult; + } + } + + private void initRunner(ExpressRunner runner) { + if (isInitialRunner) { + return; + } + synchronized (runner) { + if (isInitialRunner) { + return; + } + try { + //比较函数 + runner.replaceOperator("=", new EqOperator("=")); + runner.replaceOperator("==", new EqOperator("=")); + runner.replaceOperator("!=", new NotEqueOperator("!=")); + + runner.replaceOperator(">", new GreaterOperator(">")); + runner.replaceOperator("<", new LessOperator("<")); + runner.replaceOperator(">=", new GreaterEqOperator(">=")); + runner.replaceOperator("<=", new LessEqOperator("<=")); + + runner.replaceOperator("+", new WOperatorAdd("+")); + runner.replaceOperator("-", new WOperatorReduce("-")); + runner.replaceOperator("*", new WOperatorMulti("*")); + runner.replaceOperator("/", new WOperatorDiv("/")); + //逻辑函数 + runner.replaceOperator("IF", new IfOperator("IF")); + runner.addFunctionOfServiceMethod(FuncNames.AND.toString(), logicService, FuncNames.AND.getName(), new Class[]{Object[].class}, ""); + runner.addFunctionOfServiceMethod(FuncNames.OR.toString(), logicService, FuncNames.OR.getName(), new Class[]{Object[].class}, ""); + runner.addFunctionOfServiceMethod(FuncNames.NOT.toString(), logicService, FuncNames.NOT.getName(), new Class[]{Object[].class}, ""); + runner.replaceOperator("IN", new InOperator("in")); + runner.addFunctionOfServiceMethod(FuncNames.LIKE.toString(), logicService, FuncNames.LIKE.getName(), new Class[]{Object[].class}, ""); + runner.addFunctionOfServiceMethod(FuncNames.ISEMPTY.toString(), logicService, FuncNames.ISEMPTY.getName(), new Class[]{Object[].class}, ""); + runner.addFunctionOfServiceMethod(FuncNames.TRUE.toString(), logicService, FuncNames.TRUE.getName(), new Class[]{Object[].class}, ""); + runner.addFunctionOfServiceMethod(FuncNames.FALSE.toString(), logicService, FuncNames.FALSE.getName(), new Class[]{Object[].class}, ""); + runner.addFunctionOfServiceMethod(FuncNames.IFS.toString(), logicService, FuncNames.IFS.getName(), new Class[]{Object[].class}, ""); + runner.addFunctionOfServiceMethod(FuncNames.SWITCH.toString(), logicService, FuncNames.SWITCH.getName(), new Class[]{Object[].class}, ""); + runner.addFunctionOfServiceMethod(FuncNames.FIND.toString(), logicService, FuncNames.FIND.getName(), new Class[]{Object[].class}, ""); + + //日期函数 + runner.addFunctionOfServiceMethod("TODAY", dateTimeService, "today", new Class[]{Object[].class}, ""); + runner.addFunctionOfServiceMethod("NOW", dateTimeService, "now", new Class[]{Object[].class}, ""); + runner.addFunctionOfServiceMethod("DATEADD", dateTimeService, "dateAdd", new Class[]{Object[].class}, errorInfo); + runner.addFunctionOfServiceMethod("DATEDIFF", dateTimeService, "dateDiff", new Class[]{Object[].class}, ""); + runner.addFunctionOfServiceMethod("DATEFORMAT", dateTimeService, "dateFormat", new Class[]{Object[].class}, ""); + runner.addFunctionOfServiceMethod("YEAR", dateTimeService, "year", new Class[]{Object[].class}, ""); + runner.addFunctionOfServiceMethod("MONTH", dateTimeService, "month", new Class[]{Object[].class}, ""); + runner.addFunctionOfServiceMethod("DAY", dateTimeService, "day", new Class[]{Object[].class}, ""); + runner.addFunctionOfServiceMethod("HOUR", dateTimeService, "hour", new Class[]{Object[].class}, ""); + runner.addFunctionOfServiceMethod("MINUTE", dateTimeService, "minute", new Class[]{Object[].class}, ""); + runner.addFunctionOfServiceMethod("SECOND", dateTimeService, "seconds", new Class[]{Object[].class}, ""); + runner.addFunctionOfServiceMethod("WEEKNUM", dateTimeService, "weekNum", new Class[]{Object[].class}, ""); + runner.addFunctionOfServiceMethod("WEEKDAY", dateTimeService, "weekDay", new Class[]{Object[].class}, ""); + runner.addFunctionOfServiceMethod("EOMONTH", dateTimeService, "eoMonth", new Class[]{Object[].class}, ""); +// runner.addFunctionOfServiceMethod("NETWORKDAYSPI", dateTimeService, "workdayIntl", new Class[]{Object[].class}, ""); + runner.addFunctionOfServiceMethod("CURRYEAR", dateTimeService, "currYear", new Class[]{Object[].class}, ""); + runner.addFunctionOfServiceMethod("CURRMONTH", dateTimeService, "currMonth", new Class[]{Object[].class}, ""); + runner.addFunctionOfServiceMethod("CURRDAY", dateTimeService, "currDay", new Class[]{Object[].class}, ""); + runner.addFunctionOfServiceMethod("CURRWEEK", dateTimeService, "currWeek", new Class[]{Object[].class}, ""); + runner.addFunctionOfServiceMethod("CURRHOUR", dateTimeService, "currHour", new Class[]{Object[].class}, ""); + runner.addFunctionOfServiceMethod("CURRMINUTE", dateTimeService, "currMinute", new Class[]{Object[].class}, ""); + runner.addFunctionOfServiceMethod("CURRSECOND", dateTimeService, "currSecond", new Class[]{Object[].class}, ""); + runner.addFunctionOfServiceMethod("MAXDATE", dateTimeService, "maxDate", new Class[]{Object[].class}, ""); + runner.addFunctionOfServiceMethod("MINDATE", dateTimeService, "minDate", new Class[]{Object[].class}, ""); + runner.addFunctionOfServiceMethod("DAYSINMONTH", dateTimeService, "daysInMonth", new Class[]{Object[].class}, ""); +// runner.addFunctionOfServiceMethod("DAYOFMONTH", dateTimeService, "dayOfMonth", new Class[]{Object[].class}, ""); + + //聚合函数 +// runner.addFunctionOfServiceMethod("COUNT", aggregationFunc, "counts", new Class[]{Object[].class}, "COUNT参数错误"); +// runner.addFunctionOfServiceMethod("AVG", aggregationFunc, "avgs", new Class[]{Object[].class}, "AVG参数错误"); +// runner.addFunctionOfServiceMethod("SUM", aggregationFunc, "sumNumber", new Class[]{Object[].class}, "SUM参数错误"); +// runner.addFunctionOfServiceMethod("MAX", aggregationFunc, "maxNumber", new Class[]{Object[].class}, "MAX参数错误"); +// runner.addFunctionOfServiceMethod("MIN", aggregationFunc, "minNumber", new Class[]{Object[].class}, "MIN参数错误"); + + //字符串函数 + runner.addFunctionOfServiceMethod("CONCAT", stringFormulaService, "concatString", new Class[]{Object[].class}, ""); + runner.addFunctionOfServiceMethod("SEARCH", stringFormulaService, "search", new Class[]{Object[].class}, ""); + runner.addFunctionOfServiceMethod("TEXT", stringFormulaService, "text", new Class[]{Object[].class}, ""); + runner.addFunctionOfServiceMethod("PAD", stringFormulaService, "pad", new Class[]{Object[].class}, ""); + runner.addFunctionOfServiceMethod("REPLACE", stringFormulaService, "replace", new Class[]{Object[].class}, ""); + runner.addFunctionOfServiceMethod("VALUE", stringFormulaService, "value", new Class[]{Object[].class}, ""); + runner.addFunctionOfServiceMethod("LEN", stringFormulaService, "len", new Class[]{Object[].class}, ""); + runner.addFunctionOfServiceMethod("LEFT", stringFormulaService, "left", new Class[]{Object[].class}, ""); + runner.addFunctionOfServiceMethod("RIGHT", stringFormulaService, "right", new Class[]{Object[].class}, ""); + runner.addFunctionOfServiceMethod("MID", stringFormulaService, "mid", new Class[]{Object[].class}, ""); + runner.addFunctionOfServiceMethod("REPT", stringFormulaService, "repeat", new Class[]{Object[].class}, ""); + runner.addFunctionOfServiceMethod("TRIM", stringFormulaService, "trim", new Class[]{Object[].class}, ""); + runner.addFunctionOfServiceMethod("SCORE", stringFormulaService, "score", new Class[]{Object[].class}, ""); + runner.addFunctionOfServiceMethod("IDCARD", stringFormulaService, "idCard", new Class[]{Object[].class}, ""); + runner.addFunctionOfServiceMethod(FuncNames.ISSTRING.toString(), stringFormulaService, FuncNames.ISSTRING.getName(), new Class[]{Object[].class}, ""); + + //数学函数 + runner.addFunctionOfServiceMethod("ROUNDUP", mathFuncsService, "roundUp", new Class[]{Object[].class}, ""); + runner.addFunctionOfServiceMethod("ROUND", mathFuncsService, "round", new Class[]{Object[].class}, ""); + runner.addFunctionOfServiceMethod("ROUNDDOWN", mathFuncsService, "roundDown", new Class[]{Object[].class}, ""); + runner.addFunctionOfServiceMethod(FuncNames.AGGREGATION.toString(), mathFuncsService, FuncNames.AGGREGATION.getName(), new Class[]{Object[].class}, ""); + runner.addFunctionOfServiceMethod(FuncNames.MOD.toString(), mathFuncsService, FuncNames.MOD.getName(), new Class[]{Object[].class}, ""); + runner.addFunctionOfServiceMethod(FuncNames.TRUNC.toString(), mathFuncsService, FuncNames.TRUNC.getName(), new Class[]{Object.class, Object.class}, ""); + runner.addFunctionOfServiceMethod(FuncNames.ISINT.toString(), mathFuncsService, FuncNames.ISINT.getName(), new Class[]{Object[].class}, ""); + runner.addFunctionOfServiceMethod(FuncNames.ISNUMBER.toString(), mathFuncsService, FuncNames.ISNUMBER.getName(), new Class[]{Object[].class}, ""); + + //查找函数 +// runner.addFunctionOfServiceMethod(FuncNames.CHOOSE.toString(), findFuncsService, "chooseOne", new Class[]{Object[].class}, ""); +// runner.addFunctionOfServiceMethod(FuncNames.MATCH.toString(), findFuncsService, "match", new Class[]{Object[].class}, ""); +// runner.addFunctionOfServiceMethod(FuncNames.VLOOKUPS.toString(), findFuncsService, "vlookups", new Class[]{Object[].class}, ""); + + //数据库函数-hrm +// runner.addFunctionOfServiceMethod(FuncNames.GETHRMNAME.toString(), hrmDbService, FuncNames.GETHRMNAME.getName(), new Class[]{Object[].class}, ""); +// runner.addFunctionOfServiceMethod(FuncNames.GETHRMMOBILE.toString(), hrmDbService, FuncNames.GETHRMMOBILE.getName(), new Class[]{Object[].class}, ""); + + //财务函数 + runner.addFunctionOfServiceMethod(FuncNames.GETMONEY.toString(), financeService, FuncNames.GETMONEY.getName(), new Class[]{Object[].class}, ""); + + //数据库函数-hrm +// runner.addFunctionOfServiceMethod(FuncNames.GETHRMLOGINID.toString(), hrmDbService, "getHrmLoginId", new Class[]{Object[].class}, ""); +// runner.addFunctionOfServiceMethod(FuncNames.GETHRMWORKCODE.toString(), hrmDbService, "getHrmWorkcode", new Class[]{Object[].class}, ""); +// runner.addFunctionOfServiceMethod(FuncNames.GETHRMMANAGER.toString(), hrmDbService, "getHrmManager", new Class[]{Object[].class}, ""); +// runner.addFunctionOfServiceMethod(FuncNames.GETHRMALLMANAGER.toString(), hrmDbService, "getHrmAllManager", new Class[]{Object[].class}, ""); +// runner.addFunctionOfServiceMethod(FuncNames.GETHRMDEPARTMENT.toString(), hrmDbService, "getHrmDepartment", new Class[]{Object[].class}, ""); +// runner.addFunctionOfServiceMethod(FuncNames.GETHRMSUBCOMPANY.toString(), hrmDbService, "getHrmSubcompany", new Class[]{Object[].class}, ""); +// runner.addFunctionOfServiceMethod(FuncNames.GETDEPARTMENTNAME.toString(), hrmDbService, "getDepartmentName", new Class[]{Object[].class}, ""); +// runner.addFunctionOfServiceMethod(FuncNames.GETDEPARTMENTCODE.toString(), hrmDbService, "getDepartmentCode", new Class[]{Object[].class}, ""); +// runner.addFunctionOfServiceMethod(FuncNames.GETSUPERDEPARTMENT.toString(), hrmDbService, "getSuperDepartment", new Class[]{Object[].class}, ""); +// runner.addFunctionOfServiceMethod(FuncNames.GETALLSUPERDEPARTMENT.toString(), hrmDbService, "getAllSuperDepartment", new Class[]{Object[].class}, ""); +// runner.addFunctionOfServiceMethod(FuncNames.GETSUBCOMPANYNAME.toString(), hrmDbService, "getSubcompanyName", new Class[]{Object[].class}, ""); +// runner.addFunctionOfServiceMethod(FuncNames.GETSUBCOMPANYCODE.toString(), hrmDbService, "getSubcompanyCode", new Class[]{Object[].class}, ""); +// runner.addFunctionOfServiceMethod(FuncNames.GETSUPERSUBCOMPANY.toString(), hrmDbService, "getSuperSubcompany", new Class[]{Object[].class}, ""); +// runner.addFunctionOfServiceMethod(FuncNames.GETALLSUPERSUBCOMPANY.toString(), hrmDbService, "getAllSuperSubcompany", new Class[]{Object[].class}, ""); + + //加载模块自定义函数 +// try { +// List otherFuncList=excelFuncs.getOtherFuncs(); +// if(otherFuncList!=null && otherFuncList.size()>0){ +// //为每个方法实例化一个ExcelExtendFuncService +// for (ExcelFunc excelFunc:otherFuncList){ +// //每个接口调度类实例化时指定模块和函数名 +// ExcelExtendFuncService excelExtendFuncService=new ExcelExtendFuncServiceImpl(excelFunc.getModule(),excelFunc.getName()); +// //将自定义函数放入context上下文中 +// runner.addFunctionOfServiceMethod(excelFunc.getName(),excelExtendFuncService, RpcMethod.execute.toString(),new Class[]{Object[].class},""); +// } +// } +// } catch (Exception e) { +// logger.error("err",e); +// } + } catch (Exception e) { + logger.error("初始化失败表达式", e); + throw new RuntimeException("初始化失败表达式"); + } + } + isInitialRunner = true; + } +} diff --git a/src/com/engine/salary/formlua/core/QlExpressTest.java b/src/com/engine/salary/formlua/core/QlExpressTest.java new file mode 100644 index 000000000..fd94569ca --- /dev/null +++ b/src/com/engine/salary/formlua/core/QlExpressTest.java @@ -0,0 +1,33 @@ +package com.engine.salary.formlua.core; + +import com.engine.salary.formlua.entity.standard.ExcelResult; +import com.ql.util.express.DefaultContext; +import com.ql.util.express.ExpressRunner; + +import java.util.HashMap; +import java.util.Map; + +/** + * 执行业务类 + */ +public class QlExpressTest { + private static ExpressRunner runner = new ExpressRunner(true, false); + + public static void main(String[] args) throws Exception { + QlExpress express = new QlExpress(); + Map context = new HashMap<>(); + context.put("a", 1); + context.put("b", 2); + String formula = "IF(a>b,a,b)"; + ExcelResult execute = express.execute(formula, context); + System.out.println(execute.getData()); + + + + DefaultContext context2 = new DefaultContext(); + context2.put("a", 1); + context2.put("b", 2); + Object data = runner.execute("if(a>b){a}else{b}", context2, null, true, false); + System.out.println(data.toString()); + } +} diff --git a/src/com/engine/salary/formlua/core/exception/ErrorType.java b/src/com/engine/salary/formlua/core/exception/ErrorType.java new file mode 100644 index 000000000..c165c1964 --- /dev/null +++ b/src/com/engine/salary/formlua/core/exception/ErrorType.java @@ -0,0 +1,70 @@ +package com.engine.salary.formlua.core.exception; + +import com.engine.salary.util.SalaryI18nUtil; + +public enum ErrorType { + /** + * 函数参数不能为空 + */ + NOT_NULL(SalaryI18nUtil.getI18nLabel(91326, "函数参数不能为空")), + /** + * 参数不能为空 + */ + VAR_NOT_NULL(SalaryI18nUtil.getI18nLabel(32804, "参数不能为空")), + /** + * 函数参数错误,参数类型需为数字字段 + */ + MUST_NUM(SalaryI18nUtil.getI18nLabel(91327, "函数参数错误,参数类型需为数字字段")), + /** + * 函数参数类型错误,参数需为表格 + */ + MUST_FORM(SalaryI18nUtil.getI18nLabel(91330, "函数参数类型错误,参数需为表格")), + /** + * + */ + MUST_FORM_FIELD(SalaryI18nUtil.getI18nLabel(91331, "函数参数错误,参数类型需为表格字段")), + CANT_FORM_FIELD(SalaryI18nUtil.getI18nLabel(91427, "比较操作符参数不能是表格字段")), + /** + * + */ + CND_NOT_NULL(SalaryI18nUtil.getI18nLabel(11575, "条件不能为空")), + /** + * + */ + MIN_VAR_COUNT(SalaryI18nUtil.getI18nLabel(91332, "函数的最少参数个数")), + /** + * + */ + MAX_VAR_COUNT(SalaryI18nUtil.getI18nLabel(91333, "函数的最多参数个数")), + /** + * + */ + CANNOT_HAVE_VAR(SalaryI18nUtil.getI18nLabel(91334, "函数不能有参数")), + /** + * + */ + RETURN_TYPE_DIFF(SalaryI18nUtil.getI18nLabel(91335, "函数多个条件的返回值必须一致")), + /** + * + */ + VAR_COUNT_MUST_Odd(SalaryI18nUtil.getI18nLabel(91336, "函数最后一个参数需为默认返回值")), + /** + * + */ + VAR_TYPE_WRONG(SalaryI18nUtil.getI18nLabel(91337, "函数参数类型错误")), + /** + * + */ + VAR_MUST_HAVE_DATE(SalaryI18nUtil.getI18nLabel(91338, "函数日期参数必须包含年月日")), + /** + * + */ + VAR_TYPE_MUST_BE(SalaryI18nUtil.getI18nLabel(91339, "函数参数类型错误,参数类型需为")), + /** + * + */ + CANNOT_FIND_TEN(SalaryI18nUtil.getI18nLabel(91361, "函数未能获取到租户")); + + ErrorType(String name) { + } +} diff --git a/src/com/engine/salary/formlua/core/exception/ExcelRunTimeException.java b/src/com/engine/salary/formlua/core/exception/ExcelRunTimeException.java new file mode 100644 index 000000000..cd4a7736f --- /dev/null +++ b/src/com/engine/salary/formlua/core/exception/ExcelRunTimeException.java @@ -0,0 +1,24 @@ +package com.engine.salary.formlua.core.exception; + + + +public class ExcelRunTimeException extends Exception{ + private String info; + + public ExcelRunTimeException(String info) { + super(info,new Exception(info)); + this.info = info; + } + + public ExcelRunTimeException() { + } + + public String getInfo() { + return info; + } + + public void setInfo(String info) { + this.info = info; + } + +} diff --git a/src/com/engine/salary/formlua/entity/parameter/DataType.java b/src/com/engine/salary/formlua/entity/parameter/DataType.java new file mode 100644 index 000000000..f049136a6 --- /dev/null +++ b/src/com/engine/salary/formlua/entity/parameter/DataType.java @@ -0,0 +1,279 @@ +package com.engine.salary.formlua.entity.parameter; + +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.formlua.entity.standard.FormulaFilterData; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + + +public class DataType implements Serializable { + public final static String STRING="string"; + public final static String NUMBER="number"; + public final static String DATE="date"; + public final static String OPTION="option"; + public final static String BOOL="boolean"; + public final static String FORM="form"; + public final static String DATASOURCE="dataSource"; + private static final long serialVersionUID = 4694252986617988427L; + /** + * 非COUNT函数使用 + */ + private String fieldId; + /** + * 数据类型 + */ + private String dataType; + /** + * 数据类型,表单可以直接从FormField中获取 + */ + private String componentKey; + /** + * 模块标识,聚合函数使用 + */ + private String module; + /** + * 人员参数 + */ + private DataCollectionEmployee employee; + /** + * 表单ID,也可以是数据源ID,聚合函数、查找函数使用 + */ + private Long formId; + /** + * 子表ID,聚合函数使用 + */ + private Long subFormId; + /** + * 字段值,包括:数字类型、文本类型、日期类型、选项类型的ID等 + */ + private Object content; + /** + * 富文本的值 + */ + private String text; + /** + * 分数,表单控件中只有选项型控件有分数 + */ + private Double score; + /** + * 标题 + */ + private String name; + /** + * 保留字段兼容老数据使用的 + */ + private String aggCndKey; + /** + * 选项数据的文本内容 + */ + private String optionContent; + /** + * 明细子表数据 + */ + private List subFormData; + /** + * 保留字段,兼容老数据使用 + */ +// private FormField formField; + /** + * 高级搜索条件,由函数的逻辑操作符和逻辑函数构建,模块不需要处理 + */ + List formulaFilterDataList=null; + private List subLogic=new ArrayList<>(); + public static boolean checkType(String dataTypeL,String dataTypeR){ + if(returnType(dataTypeL).equalsIgnoreCase(dataTypeR)){ + return true; + }else { + return false; + } + } + public static String returnType(String type){ + String finalType; + switch (type){ + case "string": + case "date": + finalType="string"; + break; + case "boolean": + finalType="boolean"; + break; + case "form": + finalType="form"; + break; + case "dataSource": + case "option": + finalType="option"; + break; + case "number": + finalType="number"; + break; + default: + finalType=type; + break; + } + return finalType; + } + public DataType() { + } + public DataType(String dataType, Object content,String componentKey) { + this.dataType = dataType; + this.content = content; + this.componentKey=componentKey; + } + public DataType(String dataType, Object content) { + this.dataType = dataType; + this.content = content; + } + + public DataType(String dataType, String module, DataCollectionEmployee employee, Long formId, Object content, String text, Double score) { + this.dataType = dataType; + this.module = module; + this.employee = employee; + this.formId = formId; + this.content = content; + this.text = text; + this.score = score; + } + + public List getSubLogic() { + return subLogic; + } + + public void setSubLogic(List subLogic) { + this.subLogic = subLogic; + } + + public String getOptionContent() { + return optionContent; + } + + public void setOptionContent(String optionContent) { + this.optionContent = optionContent; + } + + public String getComponentKey() { + return componentKey; + } + + public void setComponentKey(String componentKey) { + this.componentKey = componentKey; + } + + public Long getSubFormId() { + return subFormId; + } + + public void setSubFormId(Long subFormId) { + this.subFormId = subFormId; + } + +// public FormField getFormField() { +// return formField; +// } +// +// public void setFormField(FormField formField) { +// this.formField = formField; +// } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public DataCollectionEmployee getEmployee() { + return employee; + } + + public void setEmployee(DataCollectionEmployee employee) { + this.employee = employee; + } + + public String getModule() { + return module; + } + + public void setModule(String module) { + this.module = module; + } + + public static String getSTRING() { + return STRING; + } + + public Long getFormId() { + return formId; + } + + public void setFormId(Long formId) { + this.formId = formId; + } + + public String getFieldId() { + return fieldId; + } + + public void setFieldId(String fieldId) { + this.fieldId = fieldId; + } + + public String getDataType() { + return dataType; + } + + public void setDataType(String dataType) { + this.dataType = dataType; + } + + public Object getContent() { + return content; + } + + public void setContent(Object content) { + this.content = content; + } + + public String getText() { + return text; + } + + public void setText(String text) { + this.text = text; + } + + public String getAggCndKey() { + return aggCndKey; + } + + public void setAggCndKey(String aggCndKey) { + this.aggCndKey = aggCndKey; + } + + public Double getScore() { + return score; + } + + public void setScore(Double score) { + this.score = score; + } + + public List getSubFormData() { + return subFormData; + } + + public void setSubFormData(List subFormData) { + this.subFormData = subFormData; + } + + public List getFormulaFilterDataList() { + return formulaFilterDataList; + } + + public void setFormulaFilterDataList(List formulaFilterDataList) { + this.formulaFilterDataList = formulaFilterDataList; + } +} diff --git a/src/com/engine/salary/formlua/entity/parameter/DateAndString.java b/src/com/engine/salary/formlua/entity/parameter/DateAndString.java new file mode 100644 index 000000000..4e660c0af --- /dev/null +++ b/src/com/engine/salary/formlua/entity/parameter/DateAndString.java @@ -0,0 +1,5 @@ +package com.engine.salary.formlua.entity.parameter; + + +public class DateAndString { +} diff --git a/src/com/engine/salary/formlua/entity/parameter/ExcelFunc.java b/src/com/engine/salary/formlua/entity/parameter/ExcelFunc.java new file mode 100644 index 000000000..83d23af7f --- /dev/null +++ b/src/com/engine/salary/formlua/entity/parameter/ExcelFunc.java @@ -0,0 +1,138 @@ +package com.engine.salary.formlua.entity.parameter; + +import com.alibaba.fastjson.JSONObject; + + +public class ExcelFunc { + + private String name;//函数名称 + private String chineseName;//中文 + private String description;//函数描述 + private String formatString;//函数格式 + private String[] paramArray;//函数参数列表 + private String[] paramData;//参数默认数据 + private String returnType;//返回类型 + private String type="function";// + private String validForm;//有效的表单类型 current用户当前表单、all 用户所有表单 + private JSONObject jsonFormat; + private String module; + public ExcelFunc(){} + + /** + * + * @param name 名称 + * @param description 描述 + * @param formatString 格式 + * @param paramArray 参数列表 + * @param returnType 返回类型 + */ + public ExcelFunc(String name,String chineseName, String description, String formatString, String[] paramArray,String[] paramData, String returnType,JSONObject jsonFormat,String validForm) { + this.name = name; + this.chineseName=chineseName; + this.description = description; + this.formatString = formatString; + this.paramArray = paramArray; + this.returnType = returnType; + this.jsonFormat=jsonFormat; + this.paramData=paramData; + this.validForm=validForm; + } + public ExcelFunc(String name,String chineseName, String description, String formatString, String[] paramArray,String[] paramData, String returnType,String validForm) { + this.name = name; + this.chineseName=chineseName; + this.description = description; + this.formatString = formatString; + this.paramArray = paramArray; + this.returnType = returnType; + this.paramData=paramData; + this.validForm=validForm; + } + + public String getModule() { + return module; + } + + public void setModule(String module) { + this.module = module; + } + + public String getValidForm() { + return validForm; + } + + public void setValidForm(String validForm) { + this.validForm = validForm; + } + + public String getChineseName() { + return chineseName; + } + + public void setChineseName(String chineseName) { + this.chineseName = chineseName; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getFormatString() { + return formatString; + } + + public void setFormatString(String formatString) { + this.formatString = formatString; + } + + public String[] getParamArray() { + return paramArray; + } + + public void setParamArray(String[] paramArray) { + this.paramArray = paramArray; + } + + public String getReturnType() { + return returnType; + } + + public void setReturnType(String returnType) { + this.returnType = returnType; + } + + public JSONObject getJsonFormat() { + return jsonFormat; + } + + public void setJsonFormat(JSONObject jsonFormat) { + this.jsonFormat = jsonFormat; + } + + public String[] getParamData() { + return paramData; + } + + public void setParamData(String[] paramData) { + this.paramData = paramData; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } +} diff --git a/src/com/engine/salary/formlua/entity/parameter/ExcelFuncs.java b/src/com/engine/salary/formlua/entity/parameter/ExcelFuncs.java new file mode 100644 index 000000000..6ba9cb7bd --- /dev/null +++ b/src/com/engine/salary/formlua/entity/parameter/ExcelFuncs.java @@ -0,0 +1,467 @@ +package com.engine.salary.formlua.entity.parameter; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.engine.salary.util.SalaryI18nUtil; +import org.apache.commons.compress.utils.Lists; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +import java.util.LinkedList; +import java.util.List; + + + +public class ExcelFuncs { + protected final Logger logger = LoggerFactory.getLogger(getClass()); + final static private String ALLFORM="all"; + final static private String CURRENTDATA="current_data"; + static String normalStr="{\"key\":\"\",\"fieldId\":\"\",\"componentKey\":\"\",\"term\":\"\",\"formId\":\"\",\"content\":\"\",\"fieldType\":\"\"}"; + static public JSONObject normalJson= JSON.parseObject(normalStr); + static private String[] nullParamDatas=new String[]{}; + static private String[] paramDatas=new String[]{}; + static private String[] allParamDatas=new String[]{"{}","[]"}; + static private String[] moduleList=new String[]{"biaoge","workflow"}; + private FuncDescUtil funcDescUtil; + public List getCompList(){ + //比较操作符 + List compList=new LinkedList<>(); + ExcelFunc excelFunc=null; + String [] paramArray=new String[]{}; + excelFunc=new ExcelFunc(">",SalaryI18nUtil.getI18nLabel(12132,"大于"), "","",paramArray,paramDatas,"Boolean",CURRENTDATA); + compList.add(excelFunc); + + excelFunc=new ExcelFunc(">=",SalaryI18nUtil.getI18nLabel(27694,"大于等于"), "","",paramArray,paramDatas,"Boolean",CURRENTDATA); + compList.add(excelFunc); + + excelFunc=new ExcelFunc("<",SalaryI18nUtil.getI18nLabel(20009,"小于"), "","",paramArray,paramDatas,"Boolean",CURRENTDATA); + compList.add(excelFunc); + + excelFunc=new ExcelFunc("<=",SalaryI18nUtil.getI18nLabel(15251,"小于等于"), "","",paramArray,paramDatas,"Boolean",CURRENTDATA); + compList.add(excelFunc); + + paramArray=new String[]{}; + excelFunc=new ExcelFunc("=",SalaryI18nUtil.getI18nLabel(15112,"等于"), "","",paramArray,paramDatas,"Boolean",CURRENTDATA); + compList.add(excelFunc); + + paramArray=new String[]{}; + excelFunc=new ExcelFunc("!=", SalaryI18nUtil.getI18nLabel(14897,"不等于"), "","",paramArray,paramDatas,"Boolean",CURRENTDATA); + compList.add(excelFunc); + + return compList; + } + + /** + * 日期函数的列表 + * @return + */ + public List getDateList(){ + //日期函数 + List dateList=new LinkedList<>(); + ExcelFunc excelFunc=null; + String [] paramArray=new String[]{}; + excelFunc=new ExcelFunc("TODAY",SalaryI18nUtil.getI18nLabel(94924,"当前日期"), funcDescUtil.get("TODAY"),"TODAY()",paramArray,nullParamDatas,"String",CURRENTDATA); + dateList.add(excelFunc); + + paramArray=new String[]{}; + excelFunc=new ExcelFunc("NOW",SalaryI18nUtil.getI18nLabel(94925,"当前日期时间"), funcDescUtil.get("NOW"),"NOW()",paramArray,nullParamDatas,"String",CURRENTDATA); + dateList.add(excelFunc); + + paramArray=new String[]{}; + excelFunc=new ExcelFunc("DATEADD",SalaryI18nUtil.getI18nLabel(94926,"对日期加减年、月、日"), funcDescUtil.get("DATEADD"),"DATEADD(日期, 数值, ['单位'])",nullParamDatas,paramArray,"String",CURRENTDATA); + dateList.add(excelFunc); + + paramArray=new String[]{}; + excelFunc=new ExcelFunc("DATEDIFF",SalaryI18nUtil.getI18nLabel(94927,"返回两个日期的差值"), funcDescUtil.get("DATEDIFF"),"DATEDIFF(日期1, 日期2, ['单位'])",nullParamDatas,paramArray,"Number",CURRENTDATA); + dateList.add(excelFunc); + + paramArray=new String[]{}; + excelFunc=new ExcelFunc("DATEFORMAT",SalaryI18nUtil.getI18nLabel(94928,"返回指定格式的日期"), funcDescUtil.get("DATEFORMAT"),"DATEFORMAT(日期, '可选格式')",paramArray,nullParamDatas,"String",CURRENTDATA); + dateList.add(excelFunc); + + paramArray=new String[]{}; + excelFunc=new ExcelFunc("YEAR",SalaryI18nUtil.getI18nLabel(94929,"返回日期中的年"), funcDescUtil.get("YEAR"),"YEAR(日期)",paramArray,nullParamDatas,"Number",CURRENTDATA); + dateList.add(excelFunc); + + paramArray=new String[]{"String"}; + excelFunc=new ExcelFunc("MONTH",SalaryI18nUtil.getI18nLabel(94930,"返回日期中的月"), funcDescUtil.get("MONTH"),"MONTH(日期)",paramArray,nullParamDatas,"Number",CURRENTDATA); + dateList.add(excelFunc); + + paramArray=new String[]{}; + excelFunc=new ExcelFunc("DAY",SalaryI18nUtil.getI18nLabel(94931,"返回日期中的日"), funcDescUtil.get("DAY"),"DAY(日期)",paramArray,nullParamDatas,"Number",CURRENTDATA); + dateList.add(excelFunc); + + paramArray=new String[]{}; + excelFunc=new ExcelFunc("HOUR",SalaryI18nUtil.getI18nLabel(94932,"返回日期中的小时"), funcDescUtil.get("HOUR"),"HOUR(日期)",paramArray,nullParamDatas,"Number",CURRENTDATA); + dateList.add(excelFunc); + + paramArray=new String[]{}; + excelFunc=new ExcelFunc("MINUTE",SalaryI18nUtil.getI18nLabel(94933,"返回日期中的分钟"), funcDescUtil.get("MINUTE"),"MINUTE(日期)",paramArray,nullParamDatas,"Number",CURRENTDATA); + dateList.add(excelFunc); + + paramArray=new String[]{}; + excelFunc=new ExcelFunc("SECOND",SalaryI18nUtil.getI18nLabel(94934,"返回日期中的秒"), funcDescUtil.get("SECOND"),"SECOND(日期)",paramArray,nullParamDatas,"Number",CURRENTDATA); + dateList.add(excelFunc); + + paramArray=new String[]{}; + excelFunc=new ExcelFunc("WEEKNUM",SalaryI18nUtil.getI18nLabel(94936,"返回日期为第几周"), funcDescUtil.get("WEEKNUM"),"WEEKNUM(日期)",paramArray,nullParamDatas,"Number",CURRENTDATA); + dateList.add(excelFunc); + + paramArray=new String[]{}; + excelFunc=new ExcelFunc("WEEKDAY",SalaryI18nUtil.getI18nLabel(94937,"返回日期为星期几"), funcDescUtil.get("WEEKDAY"),"WEEKDAY(日期)",paramArray,nullParamDatas,"Number",CURRENTDATA); + dateList.add(excelFunc); + + paramArray=new String[]{}; + excelFunc=new ExcelFunc("NETWORKDAYSPI",SalaryI18nUtil.getI18nLabel(94938,"返回指定日期之间包含的工作日天数(仅限的过去时间)"), funcDescUtil.get("NETWORKDAYSPI"),"NETWORKDAYSPI(日期1, 日期2, 成员)",paramArray,nullParamDatas,"Number",CURRENTDATA); + dateList.add(excelFunc); + + paramArray=new String[]{}; + excelFunc=new ExcelFunc("EOMONTH",SalaryI18nUtil.getI18nLabel(94939,"返回某月最后一天日期"), funcDescUtil.get("EOMONTH"),"EOMONTH(日期,指定日期之前或之后的月数)",paramArray,nullParamDatas,"Number",CURRENTDATA); + dateList.add(excelFunc); + + paramArray=new String[]{}; + excelFunc=new ExcelFunc("CURRYEAR",SalaryI18nUtil.getI18nLabel(101059,"返回当前年份"), funcDescUtil.get("CURRYEAR"),"CURRYEAR()",paramArray,nullParamDatas,"String",CURRENTDATA); + dateList.add(excelFunc); + + paramArray=new String[]{}; + excelFunc=new ExcelFunc("CURRMONTH",SalaryI18nUtil.getI18nLabel(101060,"返回当前月份"), funcDescUtil.get("CURRMONTH"),"CURRMONTH()",paramArray,nullParamDatas,"String",CURRENTDATA); + dateList.add(excelFunc); + + paramArray=new String[]{}; + excelFunc=new ExcelFunc("CURRDAY",SalaryI18nUtil.getI18nLabel(101061,"返回当前第几日(当月)"), funcDescUtil.get("CURRDAY"),"CURRDAY()",paramArray,nullParamDatas,"String",CURRENTDATA); + dateList.add(excelFunc); + + paramArray=new String[]{}; + excelFunc=new ExcelFunc("CURRWEEK",SalaryI18nUtil.getI18nLabel(101062,"返回当前是周几"), funcDescUtil.get("CURRWEEK"),"CURRWEEK()",paramArray,nullParamDatas,"String",CURRENTDATA); + dateList.add(excelFunc); + + paramArray=new String[]{}; + excelFunc=new ExcelFunc("CURRHOUR",SalaryI18nUtil.getI18nLabel(101063,"返回当前小时"), funcDescUtil.get("CURRHOUR"),"CURRHOUR()",paramArray,nullParamDatas,"String",CURRENTDATA); + dateList.add(excelFunc); + + paramArray=new String[]{}; + excelFunc=new ExcelFunc("CURRMINUTE",SalaryI18nUtil.getI18nLabel(101064,"返回当前分"), funcDescUtil.get("CURRMINUTE"),"CURRMINUTE()",paramArray,nullParamDatas,"String",CURRENTDATA); + dateList.add(excelFunc); + + paramArray=new String[]{}; + excelFunc=new ExcelFunc("CURRSECOND",SalaryI18nUtil.getI18nLabel(101065,"返回当前秒"), funcDescUtil.get("CURRSECOND"),"CURRSECOND()",paramArray,nullParamDatas,"String",CURRENTDATA); + dateList.add(excelFunc); + paramArray=new String[]{}; + excelFunc=new ExcelFunc("MAXDATE",SalaryI18nUtil.getI18nLabel(100803,"返回一组日期中的最大值"), funcDescUtil.get("MAXDATE"),"MAXDATE(日期1,日期2,……)",paramArray,nullParamDatas,"String",CURRENTDATA); + dateList.add(excelFunc); + + paramArray=new String[]{}; + excelFunc=new ExcelFunc("MINDATE",SalaryI18nUtil.getI18nLabel(100805,"返回一组日期中的最小值"), funcDescUtil.get("MINDATE"),"MINDATE(日期1,日期2,……)",paramArray,nullParamDatas,"String",CURRENTDATA); + dateList.add(excelFunc); + return dateList; + } + + /** + * 逻辑函数的列表 + * @return + */ + public List getLogicList(){ + //逻辑函数 + List logicList=new LinkedList<>(); + ExcelFunc excelFunc=null; + String [] paramArray=new String[]{}; + excelFunc=new ExcelFunc("IF",SalaryI18nUtil.getI18nLabel(94940,"如果条件为真,则...否则..."), funcDescUtil.get("IF"),"IF(条件, 表达式1, 表达式2)",paramArray,nullParamDatas,"Object",CURRENTDATA); + logicList.add(excelFunc); + + paramArray=new String[]{}; + excelFunc=new ExcelFunc("AND",SalaryI18nUtil.getI18nLabel(51100,"且"), funcDescUtil.get("AND"),"AND(条件1, 条件2, [条件3, …])",paramArray,nullParamDatas,"Boolean",CURRENTDATA); + logicList.add(excelFunc); + + paramArray=new String[]{}; + excelFunc=new ExcelFunc("OR",SalaryI18nUtil.getI18nLabel(35824,"或"), funcDescUtil.get("OR"),"OR(条件1, 条件2, [条件3, …])",paramArray,nullParamDatas,"Boolean",CURRENTDATA); + logicList.add(excelFunc); + + paramArray=new String[]{}; + excelFunc=new ExcelFunc("NOT",SalaryI18nUtil.getI18nLabel(94942,"反转真假结果"), funcDescUtil.get("NOT"),"NOT(逻辑结果)",paramArray,nullParamDatas,"Boolean",CURRENTDATA); + logicList.add(excelFunc); + + paramArray=new String[]{}; + excelFunc=new ExcelFunc("IN",SalaryI18nUtil.getI18nLabel(94943,"变量是否包含在一组结果中"), funcDescUtil.get("IN"),"IN(变量, [变量1, 变量2, …])",paramArray,allParamDatas,"Boolean",CURRENTDATA); + logicList.add(excelFunc); + + paramArray=new String[]{}; + excelFunc=new ExcelFunc("LIKE",SalaryI18nUtil.getI18nLabel(94944,"文本是否包含任意一个关键字"), funcDescUtil.get("LIKE"),"LIKE(文本, [文本1, 文本2, …])",paramArray,allParamDatas,"Boolean",CURRENTDATA); + logicList.add(excelFunc); + + paramArray=new String[]{}; + excelFunc=new ExcelFunc("ISEMPTY",SalaryI18nUtil.getI18nLabel(94945,"是否为空"), funcDescUtil.get("ISEMPTY"),"ISEMPTY(变量)",paramArray,paramDatas,"Boolean",CURRENTDATA); + logicList.add(excelFunc); + + paramArray=new String[]{}; + excelFunc=new ExcelFunc("TRUE",SalaryI18nUtil.getI18nLabel(94946,"返回真"), funcDescUtil.get("TRUE"),"TRUE()",paramArray,nullParamDatas,"Boolean",CURRENTDATA); + logicList.add(excelFunc); + + paramArray=new String[]{}; + excelFunc=new ExcelFunc("FALSE",SalaryI18nUtil.getI18nLabel(94947,"返回假"), funcDescUtil.get("FALSE"),"FALSE()",paramArray,nullParamDatas,"Boolean",CURRENTDATA); + logicList.add(excelFunc); + + paramArray=new String[]{}; + excelFunc=new ExcelFunc("IFS",SalaryI18nUtil.getI18nLabel(94948,"多条件"), funcDescUtil.get("IFS"),"IFS({条件1},{结果1},{条件2},{结果2}...{默认结果})",paramArray,nullParamDatas,"Object",CURRENTDATA); + logicList.add(excelFunc); + + paramArray=new String[]{}; + excelFunc=new ExcelFunc("FIND",SalaryI18nUtil.getI18nLabel(31835,"查找"), funcDescUtil.get("FIND"),"FIND([{查找值1},{查找值2}...{查找值N}],[{查找目标1},{查找目标2}...{查找目标N}])",paramArray,nullParamDatas,"Boolean",CURRENTDATA); + logicList.add(excelFunc); + return logicList; + } + + /** + * 字符函数的列表 + * @return + */ + public List getStringList(){ + //字符函数 + List stringList=new LinkedList<>(); + ExcelFunc excelFunc=null; + String [] paramArray=new String[]{}; + excelFunc=new ExcelFunc("CONCAT",SalaryI18nUtil.getI18nLabel(94949,"链接多个文本"), funcDescUtil.get("CONCAT"),"CONCAT(文本1, 文本2, [文本3, …])",paramArray,nullParamDatas,"String",CURRENTDATA); + stringList.add(excelFunc); + + paramArray=new String[]{}; + excelFunc=new ExcelFunc("TEXT",SalaryI18nUtil.getI18nLabel(94950,"将变量转为文本"), funcDescUtil.get("TEXT"),"TEXT(变量)",paramArray,nullParamDatas,"String",CURRENTDATA); + stringList.add(excelFunc); + + paramArray=new String[]{}; + excelFunc=new ExcelFunc("VALUE",SalaryI18nUtil.getI18nLabel(94951,"将文本转为数字"), funcDescUtil.get("VALUE"),"VALUE(文本)",paramArray,nullParamDatas,"Number",CURRENTDATA); + stringList.add(excelFunc); + + paramArray=new String[]{}; + excelFunc=new ExcelFunc("LEN",SalaryI18nUtil.getI18nLabel(94952,"返回文本长度"), funcDescUtil.get("LEN"),"LEN(文本)",paramArray,nullParamDatas,"Number",CURRENTDATA); + stringList.add(excelFunc); + + paramArray=new String[]{}; + excelFunc=new ExcelFunc("SEARCH",SalaryI18nUtil.getI18nLabel(94953,"在文本中查找关键字"), funcDescUtil.get("SEARCH"),"SEARCH(关键字, 文本, [搜索开始位置])",paramArray,nullParamDatas,"Number",CURRENTDATA); + stringList.add(excelFunc); + + paramArray=new String[]{}; + excelFunc=new ExcelFunc("REPLACE",SalaryI18nUtil.getI18nLabel(94954,"替换文本中的字"), funcDescUtil.get("REPLACE"),"REPLACE(原文本, 替换开始位置, 替换字符数, 新文本)",paramArray,nullParamDatas,"String",CURRENTDATA); + stringList.add(excelFunc); + + paramArray=new String[]{}; + excelFunc=new ExcelFunc("REPT",SalaryI18nUtil.getI18nLabel(94955,"将文本重复指定次数"), funcDescUtil.get("REPT"),"REPT(文本, 重复次数)",paramArray,nullParamDatas,"String",CURRENTDATA); + stringList.add(excelFunc); + + paramArray=new String[]{}; + excelFunc=new ExcelFunc("PAD",SalaryI18nUtil.getI18nLabel(94956,"将文本填充至指定长度"), funcDescUtil.get("PAD"),"PAD(原文本, 长度, 填充用的文本, ['填充位置'])",paramArray,nullParamDatas,"String",CURRENTDATA); + stringList.add(excelFunc); + + paramArray=new String[]{}; + excelFunc=new ExcelFunc("TRIM",SalaryI18nUtil.getI18nLabel(94957,"清除前后空格"), funcDescUtil.get("TRIM"),"TRIM(文本)",paramArray,nullParamDatas,"String",CURRENTDATA); + stringList.add(excelFunc); + + paramArray=new String[]{}; + excelFunc=new ExcelFunc("LEFT",SalaryI18nUtil.getI18nLabel(94958,"返回文本左侧开始的文字"), funcDescUtil.get("LEFT"),"LEFT(文本, 截取字符数)",paramArray,nullParamDatas,"String",CURRENTDATA); + stringList.add(excelFunc); + + paramArray=new String[]{}; + excelFunc=new ExcelFunc("RIGHT",SalaryI18nUtil.getI18nLabel(94959,"返回文本右侧开始的文字"), funcDescUtil.get("RIGHT"),"RIGHT(文本, 截取字符数)",paramArray,nullParamDatas,"String",CURRENTDATA); + stringList.add(excelFunc); + + paramArray=new String[]{}; + excelFunc=new ExcelFunc("MID",SalaryI18nUtil.getI18nLabel(94960,"返回文本指定位置开始的文字"), funcDescUtil.get("MID"),"MID(文本, 指定位置, 截取字符数)",paramArray,nullParamDatas,"String",CURRENTDATA); + stringList.add(excelFunc); + + paramArray=new String[]{}; + excelFunc=new ExcelFunc("SCORE",SalaryI18nUtil.getI18nLabel(94961,"获取选项型控件分数"), funcDescUtil.get("SCORE"),"SCORE({选项型控件})",paramArray,nullParamDatas,"String",CURRENTDATA); + stringList.add(excelFunc); + + paramArray=new String[]{}; + excelFunc=new ExcelFunc("IDCARD",SalaryI18nUtil.getI18nLabel(94962,"身份证函数"), funcDescUtil.get("IDCARD"),"IDCARD({身份证号码}, {查找类型})",paramArray,nullParamDatas,"String",CURRENTDATA); + stringList.add(excelFunc); + + + + paramArray=new String[]{}; + excelFunc=new ExcelFunc("ISSTRING",SalaryI18nUtil.getI18nLabel(0,"是否是字符串"), funcDescUtil.get("ISSTRING"),"ISSTRING({任意控件})",paramArray,nullParamDatas,"String",CURRENTDATA); + stringList.add(excelFunc); + +// paramArray=new String[]{}; +// excelFunc=new ExcelFunc("SUBSTRING",SalaryI18nUtil.getI18nLabel(97524,"字符截取函数"), funcDescUtil.get("SUBSTRING"),"SUBSTRING({源字符}, {截取开始位置},{截取结束位置})",paramArray,nullParamDatas,"String",CURRENTDATA); +// stringList.add(excelFunc); +// paramArray=new String[]{}; +// excelFunc=new ExcelFunc("SUBSTITUE",SalaryI18nUtil.getI18nLabel(97525,"字符查找替换函数"), funcDescUtil.get("SUBSTITUE"),"SUBSTITUE({源字符}, {被替换字符},{新字符})",paramArray,nullParamDatas,"String",CURRENTDATA); +// stringList.add(excelFunc); +// paramArray=new String[]{}; +// excelFunc=new ExcelFunc("LOWER",SalaryI18nUtil.getI18nLabel(97526,"字符转小写函数"), funcDescUtil.get("LOWER"),"LOWER({源字符})",paramArray,nullParamDatas,"String",CURRENTDATA); +// stringList.add(excelFunc); +// paramArray=new String[]{}; +// excelFunc=new ExcelFunc("UPPER",SalaryI18nUtil.getI18nLabel(97527,"字符转大写函数"), funcDescUtil.get("UPPER"),"UPPER({源字符})",paramArray,nullParamDatas,"String",CURRENTDATA); +// stringList.add(excelFunc); +// paramArray=new String[]{}; +// excelFunc=new ExcelFunc("EXACT",SalaryI18nUtil.getI18nLabel(97528,"字符比较函数"), funcDescUtil.get("EXACT"),"EXACT({字符1}, {字符2})",paramArray,nullParamDatas,"String",CURRENTDATA); +// stringList.add(excelFunc); + return stringList; + } + + /** + * 数学函数的列表 + * @return + */ + public List getMathList(){ + List mathList=new LinkedList<>(); + ExcelFunc excelFunc=null; + String [] paramArray=new String[]{}; + excelFunc=new ExcelFunc("ROUNDUP",SalaryI18nUtil.getI18nLabel(94963,"向上舍入"), funcDescUtil.get("ROUNDUP"),"ROUNDUP(数值, [小数位精确度])",paramArray,nullParamDatas,"Number",CURRENTDATA); + mathList.add(excelFunc); + + paramArray=new String[]{}; + excelFunc=new ExcelFunc("ROUND",SalaryI18nUtil.getI18nLabel(17392,"四舍五入"), funcDescUtil.get("ROUND"),"ROUND(数值, [小数位精确度])",paramArray,nullParamDatas,"Number",CURRENTDATA); + mathList.add(excelFunc); + + paramArray=new String[]{}; + excelFunc=new ExcelFunc("ROUNDDOWN",SalaryI18nUtil.getI18nLabel(94964,"向下舍入"), funcDescUtil.get("ROUNDDOWN"),"ROUNDDOWN(数值, [小数位精确度])",paramArray,nullParamDatas,"Number",CURRENTDATA); + mathList.add(excelFunc); + + paramArray=new String[]{}; + excelFunc=new ExcelFunc("AGGREGATION",SalaryI18nUtil.getI18nLabel(94965,"聚合运算"), funcDescUtil.get("AGGREGATION"),"AGGREGATION({数字}...,{聚合运算类型})",paramArray,nullParamDatas,"Number",CURRENTDATA); + mathList.add(excelFunc); + + paramArray=new String[]{}; + excelFunc=new ExcelFunc("MOD",SalaryI18nUtil.getI18nLabel(94966,"求余"), funcDescUtil.get("MOD"),"ROUNDDOWN({数字},{数字})",paramArray,nullParamDatas,"Number",CURRENTDATA); + mathList.add(excelFunc); + + paramArray=new String[]{}; + excelFunc=new ExcelFunc("TRUNC",SalaryI18nUtil.getI18nLabel(94967,"数字格式化"), funcDescUtil.get("TRUNC"),"ROUNDDOWN({数字},{精度})",paramArray,nullParamDatas,"Number",CURRENTDATA); + mathList.add(excelFunc); + + + paramArray=new String[]{}; + excelFunc=new ExcelFunc("ISINT",SalaryI18nUtil.getI18nLabel(0,"字符内容是否是整数"), funcDescUtil.get("ISINT"),"ISINT({字符})",paramArray,nullParamDatas,"String",CURRENTDATA); + mathList.add(excelFunc); + + paramArray=new String[]{}; + excelFunc=new ExcelFunc("ISNUMBER",SalaryI18nUtil.getI18nLabel(0,"字符内容是否是数字"), funcDescUtil.get("ISNUMBER"),"ISNUMBER({字符})",paramArray,nullParamDatas,"String",CURRENTDATA); + mathList.add(excelFunc); + + return mathList; + + } + + /** + * 查找函数的列表 + * @return + */ + public List getFindList(){ + List findList=new LinkedList<>(); + ExcelFunc excelFunc=null; + String [] paramArray=new String[]{}; + excelFunc=new ExcelFunc("CHOOSE",SalaryI18nUtil.getI18nLabel(94968,"返回索引范围内指定的值"), funcDescUtil.get("CHOOSE"),"CHOOSE(数据源,[条件])",paramArray,nullParamDatas,"Array",CURRENTDATA); + findList.add(excelFunc); + + paramArray=new String[]{}; + excelFunc=new ExcelFunc("VLOOKUPS",SalaryI18nUtil.getI18nLabel(94969,"按列查找,返回所需值"), funcDescUtil.get("VLOOKUPS"),"VLOOKUPS(表,[条件],[返回参数])",paramArray,nullParamDatas,"Array",CURRENTDATA); + findList.add(excelFunc); + + paramArray=new String[]{}; + excelFunc=new ExcelFunc("MATCH",SalaryI18nUtil.getI18nLabel(94970,"返回指定数值在指定数组区域中的位置"), funcDescUtil.get("MATCH"),"MATCH(值,[数组])",paramArray,nullParamDatas,"Number",CURRENTDATA); + findList.add(excelFunc); + return findList; + } + + /** + * 聚合函数 COUNT(表格, [统计条件]) + * @return + */ + public List getAggList(){ + List aggList=new LinkedList<>(); + ExcelFunc excelFunc=null; + + String [] paramArray=new String[]{"Form","Number","Boolean"}; + excelFunc=new ExcelFunc("COUNT", SalaryI18nUtil.getI18nLabel(16654,"计数"), funcDescUtil.get("COUNT"),"COUNT(表格)",paramArray,paramDatas,"Number",ALLFORM); + aggList.add(excelFunc); + + paramArray=new String[]{"Number","Number","Boolean"}; + excelFunc=new ExcelFunc("SUM",SalaryI18nUtil.getI18nLabel(95012,"求和") , funcDescUtil.get("SUM"),"SUM(数字字段)",paramArray,paramDatas,"Number",ALLFORM); + aggList.add(excelFunc); + + paramArray=new String[]{"Number","Number","Boolean"}; + excelFunc=new ExcelFunc("AVG",SalaryI18nUtil.getI18nLabel(19550,"平均值"), funcDescUtil.get("AVG"),"AVG(数字字段)",paramArray,paramDatas,"Number",ALLFORM); + aggList.add(excelFunc); + + paramArray=new String[]{"Number","Number","Boolean"}; + excelFunc=new ExcelFunc("MIN",SalaryI18nUtil.getI18nLabel(12318,"最小值"), funcDescUtil.get("MIN"),"MIN(表格)",paramArray,paramDatas,"Number",ALLFORM); + aggList.add(excelFunc); + + paramArray=new String[]{"Number","Number","Boolean"}; + excelFunc=new ExcelFunc("MAX",SalaryI18nUtil.getI18nLabel(66750,"最大值"), funcDescUtil.get("MAX"),"MAX(表格)",paramArray,paramDatas,"Number",ALLFORM); + aggList.add(excelFunc); + return aggList; + } + + /** + * 财务类函数列表 + * @return + */ + public Object getFinanceList(){ + ExcelFunc excelFunc = null; + List funcs = Lists.newArrayList(); + excelFunc = new ExcelFunc("GETMONEY",SalaryI18nUtil.getI18nLabel(0,"获取锁给定数字的金额大写"), funcDescUtil.get("GETMONEY"),"GETMONEY({数字})",null,nullParamDatas,"",CURRENTDATA); + funcs.add(excelFunc); + + return funcs; + } + /** + * 数据库函数列表 + * @return + */ + public Object getDataBaseList() { + ExcelFunc excelFunc = null; + List funcs = Lists.newArrayList(); + +// excelFunc = new ExcelFunc("GETHRMLOGINID",SalaryI18nUtil.getI18nLabel(100807,"返回指定人员系统账号"), funcDescUtil.get("GETHRMLOGINID"),"GETHRMLOGINID({表单.人员})",null,nullParamDatas,"",CURRENTDATA); +// funcs.add(excelFunc); +// +// excelFunc = new ExcelFunc("GETHRMWORKCODE",SalaryI18nUtil.getI18nLabel(100809,"返回指定人员编号"), funcDescUtil.get("GETHRMWORKCODE"),"GETHRMWORKCODE({表单.人员})",null,nullParamDatas,"",CURRENTDATA); +// funcs.add(excelFunc); +// +// excelFunc = new ExcelFunc("GETHRMMANAGER",SalaryI18nUtil.getI18nLabel(100811,"返回指定人员直接上级"), funcDescUtil.get("GETHRMMANAGER"),"GETHRMMANAGER({表单.人员})",null,nullParamDatas,"",CURRENTDATA); +// funcs.add(excelFunc); +// +// excelFunc = new ExcelFunc("GETHRMALLMANAGER",SalaryI18nUtil.getI18nLabel(100813,"返回指定人员所有上级"), funcDescUtil.get("GETHRMALLMANAGER"),"GETHRMALLMANAGER({表单.人员})",null,nullParamDatas,"",CURRENTDATA); +// funcs.add(excelFunc); +// +// excelFunc = new ExcelFunc("GETHRMDEPARTMENT",SalaryI18nUtil.getI18nLabel(100815,"返回指定人员部门"), funcDescUtil.get("GETHRMDEPARTMENT"),"GETHRMDEPARTMENT({表单.人员})",null,nullParamDatas,"",CURRENTDATA); +// funcs.add(excelFunc); +// +// excelFunc = new ExcelFunc("GETHRMSUBCOMPANY",SalaryI18nUtil.getI18nLabel(100817,"返回指定人员分部"), funcDescUtil.get("GETHRMSUBCOMPANY"),"GETHRMSUBCOMPANY({表单.人员})",null,nullParamDatas,"",CURRENTDATA); +// funcs.add(excelFunc); +// +// excelFunc = new ExcelFunc("GETDEPARTMENTNAME",SalaryI18nUtil.getI18nLabel(100819,"返回指定部门名称"), funcDescUtil.get("GETDEPARTMENTNAME"),"GETDEPARTMENTNAME({表单.部门})",null,nullParamDatas,"",CURRENTDATA); +// funcs.add(excelFunc); +// +// excelFunc = new ExcelFunc("GETDEPARTMENTCODE",SalaryI18nUtil.getI18nLabel(100821,"返回指定部门编号"), funcDescUtil.get("GETDEPARTMENTCODE"),"GETDEPARTMENTCODE({表单.部门})",null,nullParamDatas,"",CURRENTDATA); +// funcs.add(excelFunc); +// +// excelFunc = new ExcelFunc("GETSUPERDEPARTMENT",SalaryI18nUtil.getI18nLabel(100823,"返回指定部门直接上级部门"), funcDescUtil.get("GETSUPERDEPARTMENT"),"GETSUPERDEPARTMENT({表单.部门})",null,nullParamDatas,"",CURRENTDATA); +// funcs.add(excelFunc); +// +// excelFunc = new ExcelFunc("GETALLSUPERDEPARTMENT",SalaryI18nUtil.getI18nLabel(100825,"返回指定部门所有上级部门"), funcDescUtil.get("GETALLSUPERDEPARTMENT"),"GETALLSUPERDEPARTMENT({表单.部门})",null,nullParamDatas,"",CURRENTDATA); +// funcs.add(excelFunc); +// +// excelFunc = new ExcelFunc("GETSUBCOMPANYNAME",SalaryI18nUtil.getI18nLabel(100827,"返回指定分部名称"), funcDescUtil.get("GETSUBCOMPANYNAME"),"GETSUBCOMPANYNAME({表单.分部})",null,nullParamDatas,"",CURRENTDATA); +// funcs.add(excelFunc); +// +// excelFunc = new ExcelFunc("GETSUBCOMPANYCODE",SalaryI18nUtil.getI18nLabel(100829,"返回指定分部编号"), funcDescUtil.get("GETSUBCOMPANYCODE"),"GETSUBCOMPANYCODE({表单.分部})",null,nullParamDatas,"",CURRENTDATA); +// funcs.add(excelFunc); +// +// excelFunc = new ExcelFunc("GETSUPERSUBCOMPANY",SalaryI18nUtil.getI18nLabel(100831,"返回指定分部直接上级分部"), funcDescUtil.get("GETSUPERSUBCOMPANY"),"GETSUPERSUBCOMPANY({表单.分部})",null,nullParamDatas,"",CURRENTDATA); +// funcs.add(excelFunc); +// +// excelFunc = new ExcelFunc("GETALLSUPERSUBCOMPANY",SalaryI18nUtil.getI18nLabel(100833,"返回指定分部所有上级分部"), funcDescUtil.get("GETALLSUPERSUBCOMPANY"),"GETALLSUPERSUBCOMPANY({表单.分部})",null,nullParamDatas,"",CURRENTDATA); +// funcs.add(excelFunc); + + excelFunc = new ExcelFunc("GETHRMNAME",SalaryI18nUtil.getI18nLabel(100833,"获取人员名称"), funcDescUtil.get("GETHRMNAME"),"GETHRMNAME({人员})",null,nullParamDatas,"",CURRENTDATA); + funcs.add(excelFunc); + + excelFunc = new ExcelFunc("GETHRMMOBILE",SalaryI18nUtil.getI18nLabel(100833,"获取人员手机号码"), funcDescUtil.get("GETHRMMOBILE"),"GETHRMMOBILE({人员})",null,nullParamDatas,"",CURRENTDATA); + funcs.add(excelFunc); + + return funcs; + } +} diff --git a/src/com/engine/salary/formlua/entity/parameter/FormulaContext.java b/src/com/engine/salary/formlua/entity/parameter/FormulaContext.java new file mode 100644 index 000000000..d51715e23 --- /dev/null +++ b/src/com/engine/salary/formlua/entity/parameter/FormulaContext.java @@ -0,0 +1,35 @@ +package com.engine.salary.formlua.entity.parameter; + +import com.alibaba.fastjson.JSONObject; + + +public class FormulaContext { + public static ThreadLocal fmCtx=new ThreadLocal(); + + private JSONObject formulaJson=new JSONObject(); + + public static FormulaContext get(){ + if(null==fmCtx.get()){ + fmCtx.set(new FormulaContext()); + } + return fmCtx.get(); + } + + public JSONObject getFormulaJson() { + return formulaJson; + } + public void setValue(String func){ + if(formulaJson.getInteger(func)!=null){ + int i=formulaJson.getInteger(func)+1; + formulaJson.put(func,i); + }else { + formulaJson.put(func,1); + } + } + public Integer getValue(String func){ + return formulaJson.getInteger(func); + } + public void removeContext(){ + fmCtx.remove(); + } +} \ No newline at end of file diff --git a/src/com/engine/salary/formlua/entity/parameter/FuncDescUtil.java b/src/com/engine/salary/formlua/entity/parameter/FuncDescUtil.java new file mode 100644 index 000000000..83d0a2c81 --- /dev/null +++ b/src/com/engine/salary/formlua/entity/parameter/FuncDescUtil.java @@ -0,0 +1,133 @@ +package com.engine.salary.formlua.entity.parameter; + +import com.engine.salary.util.SalaryI18nUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.HashMap; +import java.util.Map; + + + +public class FuncDescUtil { + protected final Logger logger = LoggerFactory.getLogger(FuncDescUtil.class); + Map funcMap = new HashMap(); + + public void initData() { + //聚合函数 + funcMap.put("COUNT", SalaryI18nUtil.getI18nLabel(94986, "返回指定表格中满足条件的数据条数。示例:COUNT({员工表})")); + funcMap.put("SUM", SalaryI18nUtil.getI18nLabel(94987, "返回指定表格中满足条件的数据,其指定数字字段值的总和。统计条件中不可嵌套使用统计函数。示例:SUM({员工表.工资})")); + funcMap.put("AVG", SalaryI18nUtil.getI18nLabel(94988, "返回指定表格中满足条件的数据,其指定数字字段值的平均值。统计条件中不可嵌套使用统计函数。示例:AVG({员工表.工资})")); + funcMap.put("MIN", SalaryI18nUtil.getI18nLabel(94989, "返回指定表格中满足条件的数据,其指定数字字段值的最小值。统计条件中不可嵌套使用统计函数。示例:MIN({员工表.工资})")); + funcMap.put("MAX", SalaryI18nUtil.getI18nLabel(94990, "返回指定表格中满足条件的数据,其指定数字字段值的最大值。统计条件中不可嵌套使用统计函数。示例:MAX({员工表.工资})")); + //日期函数 + funcMap.put("TODAY", SalaryI18nUtil.getI18nLabel(97678, "返回当天日期。示例:TODAY() 结果: '2020-01-01'")); + funcMap.put("NOW", SalaryI18nUtil.getI18nLabel(97689, "返回当天日期+时间。示例:NOW() 结果: '2016-12-24 12:05:38'")); + funcMap.put("DATEADD", SalaryI18nUtil.getI18nLabel(97691, "对日期加减按照单位加减。单位默认为日,可选单位:年Y、月M、日D、时H、分I、秒S。示例:
DATEADD('2016-12-21', 3) 结果: '2016-12-24'
DATEADD('2016-12-24 20:00:00', 3, 'H') 结果: '2016-12-24 23:00:00'")); + funcMap.put("DATEDIFF", SalaryI18nUtil.getI18nLabel(97692, "根据指定的单位,返回日期2减去日期1的差值。当日期2小于日期1时,差值为负值。单位默认为日,可选单位:年Y、月M、日D、时H、分I、秒S。
示例:
DATEDIF('2016-12-21', '2016-12-24') 结果: 3
DATEDIF('2016-12-24 20:00:00', '2016-12-25 20:00:00', 'H') 结果: 24")); + funcMap.put("DATEFORMAT", SalaryI18nUtil.getI18nLabel(97693, "将日期转为指定格式返回。 示例:
DATEFORMAT('2016-12-24', 'YY年MM月DD日') 结果: 2016年12月24日
yyyy 将年份显示为1900-9999
yy 将年份显示为00-99
mm 将月份显示为 01–12
dd 将日期显示为 01–31")); + funcMap.put("YEAR", SalaryI18nUtil.getI18nLabel(97694, "返回指定日期中的年。示例:
YEAR('2016-12-24') 结果: 2016")); + funcMap.put("MONTH", SalaryI18nUtil.getI18nLabel(97695, "返回指定日期中的月。示例:
MONTH('2016-12-24') 结果: 12")); + funcMap.put("DAY", SalaryI18nUtil.getI18nLabel(97696, "返回指定日期中的日。示例:
DAY('2016-12-24') 结果: 24")); + funcMap.put("HOUR", SalaryI18nUtil.getI18nLabel(97697, "返回指定日期中的小时。示例:
HOUR('2016-12-24 20:30:56') 结果: 20")); + funcMap.put("MINUTE", SalaryI18nUtil.getI18nLabel(97698, "返回指定日期中的分钟。示例:
MINUTE('2016-12-24 20:30:56') 结果: 30")); + funcMap.put("SECOND", SalaryI18nUtil.getI18nLabel(97699, "返回指定日期中的秒钟。示例:
SECOND('2016-12-24 20:30:56') 结果: 56")); + funcMap.put("WEEKNUM", SalaryI18nUtil.getI18nLabel(97700, "返回指定日期为第几周,从每年第1天开始算第1周。示例:
WEEKNUM('2016-12-24') 结果: 52")); + funcMap.put("WEEKDAY", SalaryI18nUtil.getI18nLabel(97701, "返回指定日期为星期几。返回值为0~6,代表周日~周六。示例:
WEEKDAY('2016-12-24') 结果: 6")); + funcMap.put("EOMONTH", SalaryI18nUtil.getI18nLabel(97702, "将某月最后一天日期返回。日期可以为指定日期也可以是日期参数,之前的月数用负数表示,之后的月数用正数表示。所输入月数需为整数。
示例:EOMONTH('2021-11-07', -2)
结果:2021-09-30")); + funcMap.put("NETWORKDAYSPI", SalaryI18nUtil.getI18nLabel(97703, "将指定日期(仅限的过去时间,最大支持跨度为365天)之间包含的工作日天数返回。注意:此函数只能选择过去的时间才可使用,跨度不能超过365天。当日期2小于日期1时,差值为负值。单位默认为日。
示例:想知道李四在2021-11-07和2021-11-12之间的工作日天数。
NETWORKDAYSPI('2021-11-07', '2021-11-12','李四')
结果:5")); + funcMap.put("MAXDATE", SalaryI18nUtil.getI18nLabel(100804, "取一组日期中的最大值。示例:
MAXDATE('2016-12-24', '2022-12-24') 结果: 2022-12-24")); + funcMap.put("MINDATE", SalaryI18nUtil.getI18nLabel(100806, "取一组日期中的最小值。示例:
MINDATE('2016-12-24', '2022-12-24') 结果: 2016-12-24")); + //日期中的当前时间操作 + funcMap.put("CURRYEAR", SalaryI18nUtil.getI18nLabel(101066, "取当前日期的年份。示例:
假设当前时间为:2022年2月17日 11:20:30 ,CURRYEAR() 结果: 2022")); + funcMap.put("CURRMONTH", SalaryI18nUtil.getI18nLabel(101067, "取当前日期的月份。示例:
假设当前时间为:2022年2月17日 11:20:30 ,CURRMONTH() 结果: 2")); + funcMap.put("CURRDAY", SalaryI18nUtil.getI18nLabel(101068, "取当前日期的天。示例:
假设当前时间为:2022年2月17日 11:20:30 ,CURRDAY() 结果: 17")); + funcMap.put("CURRWEEK", SalaryI18nUtil.getI18nLabel(101069, "取当前日期是周几。示例:
假设当前时间为:2022年2月17日 11:20:30 ,CURRWEEK() 结果: 4")); + funcMap.put("CURRHOUR", SalaryI18nUtil.getI18nLabel(101070, "取当前日期的小时。示例:
假设当前时间为:2022年2月17日 11:20:30 ,CURRHOUR() 结果: 11")); + funcMap.put("CURRMINUTE", SalaryI18nUtil.getI18nLabel(101071, "取当前日期的分钟。示例:
假设当前时间为:2022年2月17日 11:20:30 ,CURRMINUTE() 结果: 20")); + funcMap.put("CURRSECOND", SalaryI18nUtil.getI18nLabel(101072, "取当前日期的秒钟。示例:
假设当前时间为:2022年2月17日 11:20:30 ,CURRSECOND() 结果: 30")); + + //逻辑函数 + funcMap.put("IF", SalaryI18nUtil.getI18nLabel(97704, "如果条件为真,则执行表达式1,为假则执行表达式2。条件中不可嵌套使用IF函数。示例:
IF({员工表.年龄} > 60, '退休', '在职')、IF({员工表.年龄} > 60, IF({员工表.性别} = {员工表.性别.女}, '退休', '在职'), '在职')")); + funcMap.put("AND", SalaryI18nUtil.getI18nLabel(97705, "所有条件均为真,则返回真,否则返回假。逻辑操作AND的函数模式。示例:
AND(2 = 2, 2 < 2)")); + funcMap.put("OR", SalaryI18nUtil.getI18nLabel(97706, "任意一个条件为真,则返回真,否则返回假。逻辑操作OR的函数模式。示例:
OR(2 = 2, 2 > 3)")); + funcMap.put("NOT", SalaryI18nUtil.getI18nLabel(97707, "对逻辑结果取反。示例:
NOT(2 > 3)")); + funcMap.put("IN", SalaryI18nUtil.getI18nLabel(97708, "任意类型的变量或常量等于一组同类型变量或常量结果中的任意一个,则返回真。示例:
IN(2, [2, 3, 4])")); + funcMap.put("LIKE", SalaryI18nUtil.getI18nLabel(97709, "文本类型的变量或常量包含一组文本类型变量或常量结果中的任意一个,则返回真。逻辑操作LIKE的函数模式。示例:
LIKE('大家好', ['大家', '好'])")); + funcMap.put("TRUE", SalaryI18nUtil.getI18nLabel(97710, "返回真。示例:TRUE()")); + funcMap.put("FALSE", SalaryI18nUtil.getI18nLabel(97712, "返回假。示例:FALSE()")); + funcMap.put("IFS", SalaryI18nUtil.getI18nLabel(97713, "多个条件判断,位于单数位置的参数设置为条件,位于双数位置的参数设置为结果,最后一个参数为默认返回值,当所有条件都不满足的时候返回默认参数。示例:IFS(1>1,1,1=1,2,0),结果:2")); + funcMap.put("FIND", SalaryI18nUtil.getI18nLabel(97714, "用指定参数去另一个参数列表中查找匹配项,指定参数时,填写1则去第一个参数列表中查找,2则是第二个参数列表里匹配查找第一个参数,成功则返回true,失败返回false。示例:FIND([1,2,3],[1,2,3,4],1),结果:true")); + + //文本函数 + funcMap.put("CONCAT", SalaryI18nUtil.getI18nLabel(97730, "可用于连接多个任意类型的文本、日期、数字变量或常量。示例:
CONCAT({总价}/10000, '万元')")); + funcMap.put("TEXT", SalaryI18nUtil.getI18nLabel(97731, "将变量转为文本。示例:
TEXT({当前数据.性别}) 结果: '男'")); + funcMap.put("VALUE", SalaryI18nUtil.getI18nLabel(97732, "将文本转为数字。示例:
VALUE('23') 结果: 23")); + funcMap.put("LEN", SalaryI18nUtil.getI18nLabel(97733, "返回文本的长度,中文、英文都算1个字符。示例:
LEN('大家好dajiahao') 结果: 12")); + funcMap.put("SEARCH", SalaryI18nUtil.getI18nLabel(97734, "在指定文本中查找关键字,返回第一次出现关键字的字符位置,文本的第一个字记为1。未找到,返回0。搜索开始位置,表示从文本的第几个字符开始搜索,默认为1。示例:
SEARCH('大家', '大家好大家好', 3) 结果: 4")); + funcMap.put("REPLACE", SalaryI18nUtil.getI18nLabel(97735, "在原文本中,从替换位置开始,往后数指定的替换字符数,将这段文本替换为新文本。示例:
REPLACE('大家好大家好', 2, 3, 'dajia') 结果: '大dajia家好'")); + funcMap.put("REPT", SalaryI18nUtil.getI18nLabel(97736, "将文本重复指定次数。示例:
REPT('大家', 2) 结果: '大家大家'")); + funcMap.put("PAD", SalaryI18nUtil.getI18nLabel(97737, "将原文本填充到指定长度,如果文本长度大于设置的长度,则不做任何操作。填充位置可用参数:'LEFT'、'RIGHT'。示例:
PAD('你好', 4, '你', 'LEFT') 结果: '你你你好'")); + funcMap.put("TRIM", SalaryI18nUtil.getI18nLabel(97738, "删除文本首尾的空格。示例:
TRIM(' 大家好 ') 结果: '大家好'")); + funcMap.put("LEFT", SalaryI18nUtil.getI18nLabel(97739, "从文本左侧开始,返回指定字符数的文字。示例:
LEFT('大家好', 2) 结果: '大家'")); + funcMap.put("RIGHT", SalaryI18nUtil.getI18nLabel(97740, "从文本右侧开始,返回指定字符数的文字。示例:
RIGHT('大家好', 2) 结果: '家好'")); + funcMap.put("MID", SalaryI18nUtil.getI18nLabel(97741, "从文本指定位置之后开始,返回指定字符数的文字。示例:
MID('大家好', 2, 1) 结果: '家'")); + funcMap.put("ISEMPTY", SalaryI18nUtil.getI18nLabel(97742, "变量为空或未填写,则返回真。示例:
ISEMPTY({员工表.电话})")); + funcMap.put("IDCARD", SalaryI18nUtil.getI18nLabel(97743, "从身份证号码中获取相关信息,比如:生日(BD)、年龄(AGE)、籍贯(NA)、性别(GENDER)。示例:
IDCARD( ‘******19980706****’ , ‘BD’ ) 结果: '1998-07-06'")); + funcMap.put("SCORE", SalaryI18nUtil.getI18nLabel(97744, "获取选项型控件(单选框、复选框、下拉菜单)分数。示例:SCORE({当前数据.单选框}) 结果:选项分数
注:未设置选项分数时,结果为0")); + funcMap.put("SUBSTRING", SalaryI18nUtil.getI18nLabel(97745, "字符截取函数,用于按起始位置截取字符。
示例:SUBSTRING('abcdefg',2,3)
结果:bc")); + funcMap.put("SUBSTITUE", SalaryI18nUtil.getI18nLabel(97746, "字符查找替换函数,替换字符中的所有关键词为新字符。
示例:SUBSTITUE('泛微移动办公','泛微','eteams')
结果:eteams移动办公")); + funcMap.put("LOWER", SalaryI18nUtil.getI18nLabel(97747, "将字符中的字母转为小写。
示例:LOWER('abc')
结果:ABC")); + funcMap.put("UPPER", SalaryI18nUtil.getI18nLabel(97748, "将字符中的字母转为大写。
示例:LOWER('ABC')
结果:abc")); + funcMap.put("EXACT", SalaryI18nUtil.getI18nLabel(97749, "比较两个字符是否相等,区分字母的大小写。
示例:EXACT('泛微Eteams','泛微eteams')
结果:false")); + funcMap.put("ISSTRING", SalaryI18nUtil.getI18nLabel(0, "判断是否是字符。
示例:ISSTRING('泛微Eteams')
结果:true")); + + //数学函数 + funcMap.put("ROUND", SalaryI18nUtil.getI18nLabel(97750, "根据设置的小数位精确度,返回对数值四舍五入后的值。小数位精确度取值可为正整数,0,负整数。如果小数位精确度为正整数,针对小数点后的数据进行四舍五入;如果小数位精确度等于 0,返回最接近数值的整数;如果小数位精确度为负整数,针对小数点前的数据进行四舍五入,被舍掉的数据用0占位。小数位精确度不支持变量。小数位精确度默认为0,即只保留整数。
示例:ROUND(123.456,2),ROUND(123.456,0),ROUND(123.456,-2)
结果:依次为123.46,123,100")); + funcMap.put("ROUNDUP", SalaryI18nUtil.getI18nLabel(97751, "根据设置的小数位精确度,返回对数值向上舍入后的值。小数位精确度取值可为正整数,0,负整数。如果小数位精确度为正整数,则向上舍入到指定的小数位。如果小数位精确度等于 0,则向上舍入到最接近的整数。如果小数位精确度为负整数,则在小数点左侧向上进行舍入。小数位精确度不支持变量。小数位精确度默认为0,即只保留整数。示例:ROUNDDOWN(76.9,0)结果:77")); + funcMap.put("ROUNDDOWN", SalaryI18nUtil.getI18nLabel(97752, "根据设置的小数位精确度,返回对数值向下舍入后的值。小数位精确度取值可为正整数,0,负整数。如果小数位精确度为正整数,则向下舍入到指定的小数位。如果小数位精确度等于 0,则向下舍入到最接近的整数。如果小数位精确度为负整数,则在小数点左侧向下进行舍入。小数位精确度不支持变量。小数位精确度默认为0,即只保留整数。
示例:ROUNDDOWN(76.9,0)
结果:76")); + funcMap.put("AGGREGATION", SalaryI18nUtil.getI18nLabel(97753, "将一组数据进行统计计算,支持最大值(MAX)、最小值(MIN)、平均值(AVG)。示例:AGGREGATION(1 , 2,3,'AVG'),结果:2")); + funcMap.put("MOD", SalaryI18nUtil.getI18nLabel(97754, "将两个参数进行除法运算然后得出余数返回。示例:MOD( 7 , 3 ),结果:1")); + funcMap.put("TRUNC", SalaryI18nUtil.getI18nLabel(97755, "将小数点格式化成指定位数。示例:TRUNC( 2.123 , 2 ),结果:2.12")); + funcMap.put("ISINT", SalaryI18nUtil.getI18nLabel(0, "判断字符内容是否是整数。示例:ISINT( 2.123 ),结果:false")); + funcMap.put("ISNUMBER", SalaryI18nUtil.getI18nLabel(0, "判断字符内容是否是数字。示例:ISNUMBER('2.123'),结果:true")); + + //查找函数 + funcMap.put("CHOOSE", SalaryI18nUtil.getI18nLabel(97756, "根据条件获取指定数据源中的全部数据。数据源支持选表单、表单中的字段。
示例:想知道税表中,收入大于15000的数值
CHOOSE({税表}, {税表.收入}>15000)
结果:返回税表中收入大于15000的集合")); + funcMap.put("MATCH", SalaryI18nUtil.getI18nLabel(97757, "将指定数值在指定数组区域中的位置返回。若数组中无指定值,返回null。
示例:MATCH(15000, [1000, 15000, 2000])
结果:1")); + funcMap.put("VLOOKUPS", SalaryI18nUtil.getI18nLabel(97758, "按列查找,返回所需值。常用于薪酬模块。根据条件获取查询参数所在列的返回参数的值。返回参数可填写多个,用英文逗号隔开。若查询不到返回null。
示例:VLOOKUPS({税表},{税表.收入},AND({税表.收入}>{税表.应纳税所得额下限},{税表.收入}<{税表.应纳税所得额上限}),[{税表.税率},{税表.速算扣除数}])
结果:按列查找返回税表中收入所在的收入区间所对应的税率和速算扣除数的数值")); + + //数据库函数 + funcMap.put("GETHRMLOGINID", SalaryI18nUtil.getI18nLabel(100808, "获取指定人员系统账号。
示例:GETHRMLOGINID({表单.张三})
结果:zhangsan@qq.com")); + funcMap.put("GETHRMWORKCODE", SalaryI18nUtil.getI18nLabel(100810, "获取指定人员编号。
示例:GETHRMWORKCODE({表单.张三})
结果:A001")); + funcMap.put("GETHRMMANAGER", SalaryI18nUtil.getI18nLabel(100812, "获取指定人员直接上级。
示例:GETHRMMANAGER({表单.张三})
结果:返回张三的直接上级")); + funcMap.put("GETHRMALLMANAGER", SalaryI18nUtil.getI18nLabel(100814, "获取指定人员所有上级。
示例:GETHRMMANAGER({表单.张三})
结果:返回张三的所有上级形成的数组")); + funcMap.put("GETHRMDEPARTMENT", SalaryI18nUtil.getI18nLabel(100816, "获取指定人员部门。
示例:GETHRMDEPARTMENT({表单.张三})
结果:返回张三的部门")); + funcMap.put("GETHRMSUBCOMPANY", SalaryI18nUtil.getI18nLabel(100818, "获取指定人员分部。
示例:GETHRMSUBCOMPANY({表单.张三})
结果:返回张三的分部")); + funcMap.put("GETDEPARTMENTNAME", SalaryI18nUtil.getI18nLabel(100820, "获取指定部门名称。
示例:GETDEPARTMENTNAME({表单.A部门})
结果:A部门")); + funcMap.put("GETDEPARTMENTCODE", SalaryI18nUtil.getI18nLabel(100822, "获取指定部门编号。
示例:GETDEPARTMENTCODE({表单.A部门})
结果:A001")); + funcMap.put("GETSUPERDEPARTMENT", SalaryI18nUtil.getI18nLabel(100824, "获取指定部门直接上级部门。
示例:GETDEPARTMENTCODE({表单.A部门})
结果:A部门的直接上级部门")); + funcMap.put("GETALLSUPERDEPARTMENT", SalaryI18nUtil.getI18nLabel(100826, "获取指定部门所有上级部门。
示例:GETALLSUPERDEPARTMENT({表单.A部门})
结果:A部门的所有上级部门形成的数组")); + funcMap.put("GETSUBCOMPANYNAME", SalaryI18nUtil.getI18nLabel(100828, "获取指定分部名称。
示例:GETSUBCOMPANYNAME({表单.A分部})
结果:A分部")); + funcMap.put("GETSUBCOMPANYCODE", SalaryI18nUtil.getI18nLabel(100830, "获取指定分部编号。
示例:GETSUBCOMPANYCODE({表单.A分部})
结果:B001")); + funcMap.put("GETSUPERSUBCOMPANY", SalaryI18nUtil.getI18nLabel(100832, "获取指定分部直接上级分部。
示例:GETSUPERSUBCOMPANY({表单.A分部})
结果:A分部的直接上级分部")); + funcMap.put("GETALLSUPERSUBCOMPANY", SalaryI18nUtil.getI18nLabel(100834, "获取指定分部所有上级分部。
示例:GETALLSUPERSUBCOMPANY({表单.A分部})
结果:A分部的所有上级分部形成的数组")); + funcMap.put("GETHRMNAME", SalaryI18nUtil.getI18nLabel(100834, "获取指定人员的姓名。
示例:GETHRMNAME({U:张三})
结果:张三")); + funcMap.put("GETHRMMOBILE", SalaryI18nUtil.getI18nLabel(100834, "获取指定人员的手机号码。
示例:GETHRMMOBILE({U:张三})
结果:13123232323")); + + //财务函数 + funcMap.put("GETMONEY", SalaryI18nUtil.getI18nLabel(0, "将金额转换成中文金额大写。
示例:GETMONEY({1234})
结果:壹仟贰佰叁拾肆元整")); + + } + + public String get(String key) { + if (funcMap.size() > 0) { +// logger.info("描述数据存在:"+funcMap.size()); + } else { + logger.info("初始化函数描述数据"); + initData(); + } + + return funcMap.get(key); + } +} diff --git a/src/com/engine/salary/formlua/entity/parameter/FuncNames.java b/src/com/engine/salary/formlua/entity/parameter/FuncNames.java new file mode 100644 index 000000000..b70235490 --- /dev/null +++ b/src/com/engine/salary/formlua/entity/parameter/FuncNames.java @@ -0,0 +1,20 @@ +package com.engine.salary.formlua.entity.parameter; + + +public enum FuncNames { + AND("and"), OR("or"), IF("ifF"), LIKE("likeFunc"), DATEDIFF("dateDiff"), DATEADD("dateAdd"), NOW("now"), DATEFORMAT("dateFormat"), COUNT("counts"), SUM("sumNumber"), MAX("maxNumber"), MIN("minNumber"), CONCAT("concatString"), SEARCH("search"), TEXT("text"), PAD("pad"), REPLACE("replace"), VALUE("value"), LEN("len"), LEFT("left"), RIGHT("right"), MID("mid"), TRUE("isTrue"), FALSE("isFalse"), NOT("not"), ISEMPTY("isEmpty"), TODAY("today"), IFS("ifs"), AGGREGATION("aggregation"), MOD("mod"), FIND("find"), SWITCH("switchs"), TRUNC("Trunc"), IDCARD("idCard"), + RANDOMNUMBER("randomNumber"), ROUNDUP("roundUp"), ROUNDDOWN("roundDown"), ROUND("round"), ADDRESS("addressAnalysis"), EOMONTH("eoMonth"), NETWORKDAYSPI("networkdaysPastIntl"), + CHOOSE("choose"), MATCH("match"), VLOOKUPS("vlookups"), GETHRMLOGINID("getHrmLoginId"), GETHRMWORKCODE("getHrmWorkcode"), GETHRMMANAGER("getHrmManager"), GETHRMALLMANAGER("getHrmAllManager"), + GETHRMDEPARTMENT("getHrmDepartment"), GETHRMSUBCOMPANY("getHrmSubcompany"), GETDEPARTMENTNAME("getDepartmentName"), GETDEPARTMENTCODE("getDepartmentCode"), GETSUPERDEPARTMENT("getSuperDepartment"), + GETALLSUPERDEPARTMENT("getAllSuperDepartment"), GETSUBCOMPANYNAME("getSubcompanyName"), GETSUBCOMPANYCODE("getSubcompanyCode"), GETSUPERSUBCOMPANY("getSuperSubcompany"), GETALLSUPERSUBCOMPANY("getAllSuperSubcompany"), + ISINT("isInt"), ISNUMBER("isNumber"), ISSTRING("isString"), GETMONEY("getMoney"), GETHRMNAME("getHrmName"), GETHRMMOBILE("getHrmMobile"); + String name; + + FuncNames(String name) { + this.name = name; + } + + public String getName() { + return name; + } +} diff --git a/src/com/engine/salary/formlua/entity/parameter/IllegalList.java b/src/com/engine/salary/formlua/entity/parameter/IllegalList.java new file mode 100644 index 000000000..5ed75febf --- /dev/null +++ b/src/com/engine/salary/formlua/entity/parameter/IllegalList.java @@ -0,0 +1,19 @@ +package com.engine.salary.formlua.entity.parameter; + + + +public class IllegalList { + private final String[] operArray=new String[]{"<",">","+","-","*","/","{","}","[","]","(",")","=","!=","'","\"","!",".",">=","<="}; + private final String[] nameIllegalArray=new String[]{"<",">","+","-","*","/","{","}","[","]","(",")","=","!=","'","\"","!",".", + "LIKE","like",">=","<=","IN","IF","AND","OR","TRUE","FALSE","NOW","DATEDIFF","DATEADD","Y","M","D","H","I","S","WEEKNUM", + "WEEKDAY","TODAY","DATEFORMAT","COUNT","SUM","MAX","MIN","CONCAT","SEARCH","TEXT","PAD","REPLACE","VALUE","LEN","LEFT","RIGHT","MID"}; + private IllegalList(){} + private static IllegalList illegalList=new IllegalList(); + public static IllegalList getInstance(){return illegalList;} + public String[] getNameIllegalArray() { + return nameIllegalArray; + } + public String[] getOperArray() { + return operArray; + } +} diff --git a/src/com/engine/salary/formlua/entity/parameter/ParamContext.java b/src/com/engine/salary/formlua/entity/parameter/ParamContext.java new file mode 100644 index 000000000..afc1b65e5 --- /dev/null +++ b/src/com/engine/salary/formlua/entity/parameter/ParamContext.java @@ -0,0 +1,30 @@ +package com.engine.salary.formlua.entity.parameter; + +import com.alibaba.fastjson.JSONObject; + +/** + * @className: + * @Description:本地线程存储的Excel函数变量context,线程结束后会清空释放当前线程的变量context + * @Author: + * @date: + */ +public class ParamContext { + public static ThreadLocal fmCtx=new ThreadLocal(); + private JSONObject jsonObject=new JSONObject(); + + public static ParamContext get(){ + if(null==fmCtx.get()){ + fmCtx.set(new ParamContext()); + } + return fmCtx.get(); + } + public void setValue(String func,Object value){ + jsonObject.put(func,value); + } + public Object getValue(String func){ + return jsonObject.get(func); + } + public void removeContext(){ + fmCtx.remove(); + } +} diff --git a/src/com/engine/salary/formlua/entity/parameter/ParamFactory.java b/src/com/engine/salary/formlua/entity/parameter/ParamFactory.java new file mode 100644 index 000000000..b0cbab51e --- /dev/null +++ b/src/com/engine/salary/formlua/entity/parameter/ParamFactory.java @@ -0,0 +1,127 @@ +package com.engine.salary.formlua.entity.parameter; + +/** + * @className:默认本地参数 + * @Description:注释 + * @Author: + * @date: + */ +public class ParamFactory { + private String charValue; + private Double doubleValue; + private Integer integerValue; + private Long longValue; + private Float floatValue; + private Boolean boolValue; + private String dateTimeValue; + private String selectValue; + private String timeValue; + private String textValue; + private ParamFactory(){} + + private ParamFactory(String charValue, Double doubleValue, Integer integerValue, Long longValue, Float floatValue, Boolean boolValue,String dateTimeValue,String selectValue,String timeValue,String textValue) { + this.charValue = charValue; + this.doubleValue = doubleValue; + this.integerValue = integerValue; + this.longValue = longValue; + this.floatValue = floatValue; + this.boolValue = boolValue; + this.dateTimeValue=dateTimeValue; + this.selectValue=selectValue; + this.timeValue=timeValue; + this.textValue=textValue; + } + + private static ParamFactory paramFactory=new ParamFactory("2020-01-12 12:23:33",5.2,2020,100L,new Float(20.4),true,"2020-01-12 12:23:33","8428149709910469289","12:12:30","abcd"); + public static ParamFactory getInstance(){ + return paramFactory; + } + + public String getTimeValue() { + return timeValue; + } + + public void setTimeValue(String timeValue) { + this.timeValue = timeValue; + } + + public String getSelectValue() { + return selectValue; + } + + public void setSelectValue(String selectValue) { + this.selectValue = selectValue; + } + + public String getCharValue() { + return charValue; + } + + public void setCharValue(String charValue) { + this.charValue = charValue; + } + + public Double getDoubleValue() { + return doubleValue; + } + + public String getDateTimeValue() { + return dateTimeValue; + } + + public void setDateTimeValue(String dateTimeValue) { + this.dateTimeValue = dateTimeValue; + } + + public void setDoubleValue(Double doubleValue) { + this.doubleValue = doubleValue; + } + + public Integer getIntegerValue() { + return integerValue; + } + + public void setIntegerValue(Integer integerValue) { + this.integerValue = integerValue; + } + + public Long getLongValue() { + return longValue; + } + + public void setLongValue(Long longValue) { + this.longValue = longValue; + } + + public Float getFloatValue() { + return floatValue; + } + + public void setFloatValue(Float floatValue) { + this.floatValue = floatValue; + } + + public Boolean getBoolValue() { + return boolValue; + } + + public void setBoolValue(Boolean boolValue) { + this.boolValue = boolValue; + } + + public static ParamFactory getParamFactory() { + return paramFactory; + } + + public static void setParamFactory(ParamFactory paramFactory) { + ParamFactory.paramFactory = paramFactory; + } + + public String getTextValue() { + return textValue; + } + + public void setTextValue(String textValue) { + this.textValue = textValue; + } +} diff --git a/src/com/engine/salary/formlua/entity/parameter/ParamType.java b/src/com/engine/salary/formlua/entity/parameter/ParamType.java new file mode 100644 index 000000000..f11a1ceca --- /dev/null +++ b/src/com/engine/salary/formlua/entity/parameter/ParamType.java @@ -0,0 +1,15 @@ +package com.engine.salary.formlua.entity.parameter; + + +public enum ParamType { + STRING("String"),INTEGER("Integer"),DOUBLE("Double"),LONG("Long"),SHORT("Short"),JSONOBJECT("JSONObject"),FLOAT("Float"),BOOLEAN("Boolean"); + String name; + ParamType(String name) { + this.name=name; + } + + public String getName() { + return name; + } + +} diff --git a/src/com/engine/salary/formlua/entity/parameter/ReturnType.java b/src/com/engine/salary/formlua/entity/parameter/ReturnType.java new file mode 100644 index 000000000..601a097cb --- /dev/null +++ b/src/com/engine/salary/formlua/entity/parameter/ReturnType.java @@ -0,0 +1,13 @@ +package com.engine.salary.formlua.entity.parameter; + + +public class ReturnType { + public final static int BOOLEAN_VALUE=0; + public final static int NUMBER_VALUE=1; + public final static int STRING_VALUE=2; + public final static String[] NUMBER_TYPE=new String[]{"NumberComponent","Money","Raty","score","Monitor"}; + public final static String[] DATETIME_TYPE=new String[]{"DateComponent","DateInterval"}; + public final static String[] CHECK_TYPE=new String[]{"RadioBox","CheckBox","Select","ComboSelect"}; + public final static String[] DROPDOWN_LIST=new String[]{"Select","ComboSelect"}; + public final static String[]CHECKBOX_LIST=new String[]{"RadioBox","CheckBox"}; +} diff --git a/src/com/engine/salary/formlua/entity/parameter/ThreadLocalData.java b/src/com/engine/salary/formlua/entity/parameter/ThreadLocalData.java new file mode 100644 index 000000000..7e9c14289 --- /dev/null +++ b/src/com/engine/salary/formlua/entity/parameter/ThreadLocalData.java @@ -0,0 +1,59 @@ +package com.engine.salary.formlua.entity.parameter; + +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import org.mozilla.javascript.commonjs.module.provider.ModuleSource; + +import java.util.Iterator; +import java.util.Map; + + +public class ThreadLocalData { + private Map expressContext; + private ModuleSource moduleSource; + + private DataCollectionEmployee employee; + + public ModuleSource getModuleSource() { + return moduleSource; + } + + public void setModuleSource(ModuleSource moduleSource) { + this.moduleSource = moduleSource; + } + + public DataCollectionEmployee getEmployee() { + return employee; + } + + public void setEmployee(DataCollectionEmployee employee) { + this.employee = employee; + } + + public Map getExpressContext() { + return expressContext; + } + + public void setExpressContext(Map expressContext) { + transMap(expressContext); + this.expressContext = expressContext; + } + + private void transMap(Map expressContext){ + Iterator iterator=expressContext.keySet().iterator(); + while (iterator.hasNext()){ + String key=iterator.next(); + Object obj=expressContext.get(key); + if(obj instanceof DataType){ + DataType dataType=(DataType)obj; + if(dataType.getFieldId()!=null){ + int idx=key.indexOf(dataType.getFieldId().toString()); + if(idx>=0){ + String localKey=key.substring(0,idx+dataType.getFieldId().toString().length()); + dataType.setAggCndKey(localKey); + } + } + + } + } + } +} diff --git a/src/com/engine/salary/formlua/entity/standard/AggFunc.java b/src/com/engine/salary/formlua/entity/standard/AggFunc.java new file mode 100644 index 000000000..34215605c --- /dev/null +++ b/src/com/engine/salary/formlua/entity/standard/AggFunc.java @@ -0,0 +1,8 @@ +package com.engine.salary.formlua.entity.standard; + +public enum AggFunc { + count("计数"),avg("平均数"),min("最小数"),max("最大数"),sum("合计数"); + + AggFunc(String name) { + } +} diff --git a/src/com/engine/salary/formlua/entity/standard/ExcelModuleFixField.java b/src/com/engine/salary/formlua/entity/standard/ExcelModuleFixField.java new file mode 100644 index 000000000..92e05d744 --- /dev/null +++ b/src/com/engine/salary/formlua/entity/standard/ExcelModuleFixField.java @@ -0,0 +1,34 @@ +package com.engine.salary.formlua.entity.standard; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class ExcelModuleFixField { + /** + * 审批发起人 + */ + public static String FLOW_CREATOR="creator"; + /** + * 审批请求ID + */ + public static String FLOW_REQUEST_ID="requestid"; + /** + * 审批发起人所属部门 + */ + public static String FLOW_CREATOR_DEPT="creator_depart"; + /** + * 上报收集人 + */ + public static String REPORT_CREATOR="creator"; + /** + * 上报名称 + */ + public static String REPORT_NAME="name"; + /** + * 上报提交人 + */ + public static String REPORT_REPORTER="reporter"; + + public static List ALLFIXFIELD = new ArrayList<>(Arrays.asList(FLOW_CREATOR,FLOW_CREATOR_DEPT,FLOW_REQUEST_ID,REPORT_CREATOR,REPORT_NAME,REPORT_REPORTER)); +} diff --git a/src/com/engine/salary/formlua/entity/standard/ExcelPage.java b/src/com/engine/salary/formlua/entity/standard/ExcelPage.java new file mode 100644 index 000000000..dddf2300c --- /dev/null +++ b/src/com/engine/salary/formlua/entity/standard/ExcelPage.java @@ -0,0 +1,56 @@ +package com.engine.salary.formlua.entity.standard; + +import java.io.Serializable; +import java.util.List; + +/** + * @author + */ +public class ExcelPage implements Serializable { + private static final long serialVersionUID = -3149769813337109956L; + private int pageNo; + private int pageSize; + private int count; + private String keywords; + private List pageResult; + + public String getKeywords() { + return keywords; + } + + public void setKeywords(String keywords) { + this.keywords = keywords; + } + + public int getCount() { + return count; + } + + public void setCount(int count) { + this.count = count; + } + + public int getPageNo() { + return pageNo; + } + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + public List getPageResult() { + return pageResult; + } + + public void setPageResult(List pageResult) { + this.pageResult = pageResult; + } +} diff --git a/src/com/engine/salary/formlua/entity/standard/ExcelResult.java b/src/com/engine/salary/formlua/entity/standard/ExcelResult.java new file mode 100644 index 000000000..defa5cde4 --- /dev/null +++ b/src/com/engine/salary/formlua/entity/standard/ExcelResult.java @@ -0,0 +1,175 @@ +package com.engine.salary.formlua.entity.standard; + +import com.ql.util.express.IExpressContext; + +import java.io.Serializable; +import java.math.BigDecimal; + +public class ExcelResult implements Serializable { + private static final long serialVersionUID = 4578033427466119428L; + + + /** + * 执行语句 + */ + private String express; + + /** + * 上下文 + */ + private IExpressContext expressContext; + + /** + * 文本、数字、日期从这里取值 + */ + private Object data; + /** + * 布尔值从这里取值 + */ + private boolean boolData; + private String stringData; + private BigDecimal numberData; + /** + * 执行状态,true为执行成功,false为执行失败 + */ + private boolean status; + private String errorMsg; + private String formulaId; + private String dataType; + + + /** + * 运行时间 + */ + private long runTime; + + public ExcelResult() { + } + + public ExcelResult(boolean status, Object data, String errorMsg) { + this.status = status; + this.data = data; + this.errorMsg = errorMsg; + } + + public String getExpress() { + return express; + } + + public void setExpress(String express) { + this.express = express; + } + + public IExpressContext getExpressContext() { + return expressContext; + } + + public void setExpressContext(IExpressContext expressContext) { + this.expressContext = expressContext; + } + + + public String getDataType() { + return dataType; + } + + public void setDataType(String dataType) { + this.dataType = dataType; + } + + public String getFormulaId() { + return formulaId; + } + + public void setFormulaId(String formulaId) { + this.formulaId = formulaId; + } + + public boolean isBoolData() { + return boolData; + } + + public String getStringData() { + return stringData; + } + + public void setStringData(String stringData) { + this.stringData = stringData; + } + + public BigDecimal getNumberData() { + return numberData; + } + + public void setNumberData(BigDecimal numberData) { + this.numberData = numberData; + } + + public String getErrorMsg() { + return errorMsg; + } + + public void setErrorMsg(String errorMsg) { + this.errorMsg = errorMsg; + } + + public boolean getBoolData() { + return boolData; + } + + public void setBoolData(boolean boolData) { + this.boolData = boolData; + } + + public Object getData() { + return data; + } + + public void setData(Object data) { + this.data = data; + } + + public boolean isStatus() { + return status; + } + + public void setStatus(boolean status) { + this.status = status; + } + + public long getRunTime() { + return runTime; + } + + public void setRunTime(long runTime) { + this.runTime = runTime; + } + + public String getData2String() { + if (data == null) { + return ""; + } else { + if (data instanceof BigDecimal) { + return ((BigDecimal) data).toPlainString(); + } else { + return data.toString(); + } + } + } + + @Override + public String toString() { + return "ExcelResult{" + + "express='" + express + '\'' + + ", expressContext=" + expressContext + + ", data=" + data + + ", boolData=" + boolData + + ", stringData='" + stringData + '\'' + + ", numberData=" + numberData + + ", status=" + status + + ", errorMsg='" + errorMsg + '\'' + + ", formulaId='" + formulaId + '\'' + + ", dataType='" + dataType + '\'' + + '}'; + } +} diff --git a/src/com/engine/salary/formlua/entity/standard/FormulaCategory.java b/src/com/engine/salary/formlua/entity/standard/FormulaCategory.java new file mode 100644 index 000000000..fbc482888 --- /dev/null +++ b/src/com/engine/salary/formlua/entity/standard/FormulaCategory.java @@ -0,0 +1,58 @@ +package com.engine.salary.formlua.entity.standard; + +import java.io.Serializable; + +/** + * @author roy + */ +public class FormulaCategory implements Serializable { + private static final long serialVersionUID = 376155360889274784L; + /** + * 分类ID + */ + private String id; + /** + * 分类名称 + */ + private String name; + /** + * 所属模块 + */ + private String module; + /** + * 类别,和module保持一致即可,为兼容老数据的保留字段 + */ + private String type; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getModule() { + return module; + } + + public void setModule(String module) { + this.module = module; + } +} diff --git a/src/com/engine/salary/formlua/entity/standard/FormulaDataSource.java b/src/com/engine/salary/formlua/entity/standard/FormulaDataSource.java new file mode 100644 index 000000000..83bdbcf52 --- /dev/null +++ b/src/com/engine/salary/formlua/entity/standard/FormulaDataSource.java @@ -0,0 +1,37 @@ +package com.engine.salary.formlua.entity.standard; + +import java.io.Serializable; + +/** + * @author roy + */ +public class FormulaDataSource implements Serializable { + private static final long serialVersionUID = 8657467498740290598L; + private String dataId; + private String title; + private String module; + + public String getDataId() { + return dataId; + } + + public void setDataId(String dataId) { + this.dataId = dataId; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getModule() { + return module; + } + + public void setModule(String module) { + this.module = module; + } +} diff --git a/src/com/engine/salary/formlua/entity/standard/FormulaFilterData.java b/src/com/engine/salary/formlua/entity/standard/FormulaFilterData.java new file mode 100644 index 000000000..a27498278 --- /dev/null +++ b/src/com/engine/salary/formlua/entity/standard/FormulaFilterData.java @@ -0,0 +1,299 @@ +package com.engine.salary.formlua.entity.standard; + +import java.io.Serializable; +import java.util.List; + +/** + * @author roy + */ +public class FormulaFilterData implements Serializable { + public static final String CONDITION_AND = "and"; + public static final String CONDITION_OR = "or"; + public static final String TERM_EQ = "eq"; + public static final String TERM_NOT_EQ = "neq"; + public static final String TERM_NULL = "null"; + public static final String TERM_NOT_NULL = "notnull"; + public static final String TERM_LIKE = "like"; + public static final String TERM_GT = "gt"; + public static final String TERM_GE = "ge"; + public static final String TERM_LE = "le"; + public static final String TERM_LT = "lt"; + public static final String TERM_BEQ = "beq"; + public static final String TERM_SEQ = "seq"; + public static final String SOURCE_TYPE_CONSTANT = "constant"; + public static final String SOURCE_TYPE_VARIABLE = "variable"; + private static final long serialVersionUID = 2902385161856666369L; + /** + * 字段ID + */ + private String fieldId; + /** + * 明细子表ID + */ + private String subFormId; + /** + * 控件名称 + */ + private String componentKey; + /** + * 操作符,具体符号在上面的静态变量中 + */ + private String term; + private String tremStr; + /** + * 条件的值 + */ + private String content; + /** + * 范围条件的截止范围 + */ + private String endContent; + /** + * 选项条件的值 + */ + private List ids; +// private List children; + private List contents; + private List idObjects; + private String dateType; + private List allUserIds; + private List allDeptIds; + private String operateId; + private String departmentId; + private List deptFieldIds; + private String subDept; + private List pIds; + private String sourceType; + private String sourceFile; + private String idsStr; + private String sortStr; + private String condition = "and"; + private List selectIds; + private String format; + private boolean isFixed; +// private List filterFormDataIdsList; + + public String getFieldId() { + return fieldId; + } + + public void setFieldId(String fieldId) { + this.fieldId = fieldId; + } + + public String getSubFormId() { + return subFormId; + } + + public void setSubFormId(String subFormId) { + this.subFormId = subFormId; + } + + public String getComponentKey() { + return componentKey; + } + + public void setComponentKey(String componentKey) { + this.componentKey = componentKey; + } + + public String getTerm() { + return term; + } + + public void setTerm(String term) { + this.term = term; + } + + public String getTremStr() { + return tremStr; + } + + public void setTremStr(String tremStr) { + this.tremStr = tremStr; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getEndContent() { + return endContent; + } + + public void setEndContent(String endContent) { + this.endContent = endContent; + } + + public List getIds() { + return ids; + } + + public void setIds(List ids) { + this.ids = ids; + } + +// public List getChildren() { +// return children; +// } +// +// public void setChildren(List children) { +// this.children = children; +// } + + public List getContents() { + return contents; + } + + public void setContents(List contents) { + this.contents = contents; + } + + public List getIdObjects() { + return idObjects; + } + + public void setIdObjects(List idObjects) { + this.idObjects = idObjects; + } + + public String getDateType() { + return dateType; + } + + public void setDateType(String dateType) { + this.dateType = dateType; + } + + public List getAllUserIds() { + return allUserIds; + } + + public void setAllUserIds(List allUserIds) { + this.allUserIds = allUserIds; + } + + public List getAllDeptIds() { + return allDeptIds; + } + + public void setAllDeptIds(List allDeptIds) { + this.allDeptIds = allDeptIds; + } + + public String getOperateId() { + return operateId; + } + + public void setOperateId(String operateId) { + this.operateId = operateId; + } + + public String getDepartmentId() { + return departmentId; + } + + public void setDepartmentId(String departmentId) { + this.departmentId = departmentId; + } + + public List getDeptFieldIds() { + return deptFieldIds; + } + + public void setDeptFieldIds(List deptFieldIds) { + this.deptFieldIds = deptFieldIds; + } + + public String getSubDept() { + return subDept; + } + + public void setSubDept(String subDept) { + this.subDept = subDept; + } + + public List getpIds() { + return pIds; + } + + public void setpIds(List pIds) { + this.pIds = pIds; + } + + public String getSourceType() { + return sourceType; + } + + public void setSourceType(String sourceType) { + this.sourceType = sourceType; + } + + public String getSourceFile() { + return sourceFile; + } + + public void setSourceFile(String sourceFile) { + this.sourceFile = sourceFile; + } + + public String getIdsStr() { + return idsStr; + } + + public void setIdsStr(String idsStr) { + this.idsStr = idsStr; + } + + public String getSortStr() { + return sortStr; + } + + public void setSortStr(String sortStr) { + this.sortStr = sortStr; + } + + public String getCondition() { + return condition; + } + + public void setCondition(String condition) { + this.condition = condition; + } + + public List getSelectIds() { + return selectIds; + } + + public void setSelectIds(List selectIds) { + this.selectIds = selectIds; + } + + public String getFormat() { + return format; + } + + public void setFormat(String format) { + this.format = format; + } + + public boolean isFixed() { + return isFixed; + } + + public void setFixed(boolean fixed) { + isFixed = fixed; + } + +// public List getFilterFormDataIdsList() { +// return filterFormDataIdsList; +// } +// +// public void setFilterFormDataIdsList(List filterFormDataIdsList) { +// this.filterFormDataIdsList = filterFormDataIdsList; +// } +} diff --git a/src/com/engine/salary/formlua/entity/standard/FormulaModuleCategory.java b/src/com/engine/salary/formlua/entity/standard/FormulaModuleCategory.java new file mode 100644 index 000000000..50dc2a8fa --- /dev/null +++ b/src/com/engine/salary/formlua/entity/standard/FormulaModuleCategory.java @@ -0,0 +1,34 @@ +package com.engine.salary.formlua.entity.standard; + +import java.io.Serializable; + +/** + * @author + */ +public class FormulaModuleCategory implements Serializable { + private static final long serialVersionUID = 561339364277864462L; + /** + * 分类名称 + */ + private String content; + /** + * 分类ID + */ + private String id; + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } +} diff --git a/src/com/engine/salary/formlua/entity/standard/execute/ExclDataType.java b/src/com/engine/salary/formlua/entity/standard/execute/ExclDataType.java new file mode 100644 index 000000000..f12b32047 --- /dev/null +++ b/src/com/engine/salary/formlua/entity/standard/execute/ExclDataType.java @@ -0,0 +1,8 @@ +package com.engine.salary.formlua.entity.standard.execute; + +public enum ExclDataType { + text("文本类型"),integral("整数类型"),decimal("小数类型"),datasource("数据源或选项类型"),bool("布尔类型"); + + ExclDataType(String name) { + } +} diff --git a/src/com/engine/salary/formlua/entity/standard/execute/ExclFixField.java b/src/com/engine/salary/formlua/entity/standard/execute/ExclFixField.java new file mode 100644 index 000000000..4ba17274f --- /dev/null +++ b/src/com/engine/salary/formlua/entity/standard/execute/ExclFixField.java @@ -0,0 +1,67 @@ +package com.engine.salary.formlua.entity.standard.execute; + +/** + * 固定字段标准类 + */ +public class ExclFixField { + /** + * 固定字段或系统字段的类属性名 + */ + private String properName; + /** + * 数据类型 + */ + private ExclDataType exclDataType; + /** + * 固定字段或系统字段的值 + */ + private Object value; + /** + * 所属来源数据的ID + */ + private String sourceId; + /** + * 所属模块 + */ + private String module; + + public String getProperName() { + return properName; + } + + public void setProperName(String properName) { + this.properName = properName; + } + + public ExclDataType getExclDataType() { + return exclDataType; + } + + public void setExclDataType(ExclDataType exclDataType) { + this.exclDataType = exclDataType; + } + + public Object getValue() { + return value; + } + + public void setValue(Object value) { + this.value = value; + } + + public String getSourceId() { + return sourceId; + } + + public void setSourceId(String sourceId) { + this.sourceId = sourceId; + } + + public String getModule() { + return module; + } + + public void setModule(String module) { + this.module = module; + } +} diff --git a/src/com/engine/salary/formlua/entity/standard/execute/FixFieldType.java b/src/com/engine/salary/formlua/entity/standard/execute/FixFieldType.java new file mode 100644 index 000000000..fcfcca5ee --- /dev/null +++ b/src/com/engine/salary/formlua/entity/standard/execute/FixFieldType.java @@ -0,0 +1,11 @@ +package com.engine.salary.formlua.entity.standard.execute; + +/** + * 固定字段分类 + */ +public enum FixFieldType { + Text("文本型"),Num("数字型"),Relate("关联型"),Select("选项型"),Employee("人员"),Department("部门"); + + FixFieldType(String name) { + } +} diff --git a/src/com/engine/salary/formlua/func/compare/CommonOper.java b/src/com/engine/salary/formlua/func/compare/CommonOper.java new file mode 100644 index 000000000..ad7921ee2 --- /dev/null +++ b/src/com/engine/salary/formlua/func/compare/CommonOper.java @@ -0,0 +1,71 @@ +package com.engine.salary.formlua.func.compare; + + +import com.engine.salary.formlua.entity.parameter.DataType; +import com.engine.salary.formlua.util.ExcelParamUtil; + +import java.util.ArrayList; +import java.util.List; + +public class CommonOper { + + public static List operDivMultiList(Object obj1,Object obj2,String oper){ + List resultList=new ArrayList<>(); + if( (obj1 instanceof Object[] && !(obj2 instanceof Object[])) || (obj2 instanceof Object[] && !(obj1 instanceof Object[])) ){ + Object[] arrayParam; + Object param; + boolean firstArray=false; + if(obj1 instanceof Object[]){ + arrayParam=(Object[])obj1; + param=obj2; + firstArray=true; + }else { + arrayParam=(Object[])obj2; + param=obj1; + } + for (int i=0;i operAddReduceList(Object obj1,Object obj2){ + List resultList=new ArrayList<>(); + Object[] param1=(Object[])obj1; + Object[] param2=(Object[])obj2; + if(param1.length!=param2.length){ + throw new RuntimeException("参数列表长度不一致"); + } + for (int i=0;i filterFormDataList = new ArrayList<>(); +// FormulaFilterData filterData = new FormulaFilterData(); +// String content = null; +// try { +// if (obj1 instanceof DataType) { +// DataType dataType1 = (DataType) obj1; +// if (StringUtils.isEmpty(dataType1.getComponentKey())) { +// dataType1.setComponentKey(dataType1.getDataType()); +// } +// if (obj2 instanceof DataType) { +//// content = ((DataType) obj2).getContent()+""; +// DataType paramDataType = (DataType) obj2; +// if (paramDataType == null || paramDataType.getContent() == null) { +// content = ""; +// } else { +// content = paramDataType.getContent() + ""; +// } +// } else { +// content = obj2 + ""; +// } +// if (content != null) { +// String componentKey = dataType1.getComponentKey(); +// filterData.setFieldId(dataType1.getFieldId()); +// if (dataType1.getSubFormId() != null) { +// filterData.setSubFormId(dataType1.getSubFormId() + ""); +// } +// filterData.setComponentKey(componentKey); +// if (StringUtils.isEmpty(content)) { +//// filterData.setTerm(FilterFormData.TERM_NOT_NULL); +// } else { +//// //选项控件 +//// if (ComponentConfig.isOptionComponent(componentKey)) { +//// filterData.setTerm(FilterFormData.TERM_NOT_EQ); +//// List ids = new ArrayList<>(); +//// String[] idsArray = content.split(","); +//// for (String idStr : idsArray) { +//// if (StringUtils.isNotBlank(idStr)) { +//// ids.add(idStr); +//// } +//// } +//// filterData.setIds(ids); +//// //其他 +//// } else { +//// filterData.setTerm(FilterFormData.TERM_NOT_EQ); +//// filterData.setContent(content); +////// if(ComponentConfig.isNumberComponent(dataType1.getComponentKey()) || dataType1.getComponentKey().equalsIgnoreCase(DataType.NUMBER)){ +////// if(StringUtils.isEmpty(content)){ +////// filterData.setContent("0"); +////// } +////// } +//// } +// } +// } +// filterFormDataList.add(filterData); +//// dataType.setFormulaFilterDataList(filterFormDataList); +// dataType.setComponentKey(dataType1.getComponentKey()); +// dataType.setSubFormId(dataType1.getSubFormId()); +// } +// } catch (Exception e) { +// logger.error("err", e); +// } +// +// } +// +// /** +// * 构建大于、小于、大于等于、小于等于的搜索条件 +// * +// * @param dataType +// * @param name +// * @param obj1 +// * @param obj2 +// */ +// public static void buildLessMoreFilterParam(DataType dataType, String name, Object obj1, Object obj2) { +// List filterFormDataList = new ArrayList<>(); +// FormulaFilterData filterData = new FormulaFilterData(); +// try { +// logger.info(name + "执行结果:" + JSON.toJSONString(dataType)); +// if (obj1 instanceof DataType) { +// DataType dataType1 = (DataType) obj1; +// if (StringUtils.isEmpty(dataType1.getComponentKey())) { +// dataType1.setComponentKey(dataType1.getDataType()); +// } +// String content = null; +// if (obj2 instanceof DataType) { +//// content = ((DataType) obj2).getContent()+""; +// DataType paramDataType = (DataType) obj2; +// if (paramDataType == null || paramDataType.getContent() == null) { +// content = ""; +// } else { +// content = paramDataType.getContent() + ""; +// } +// } else { +// content = obj2 + ""; +// } +// if (content != null) { +// String componentKey = dataType1.getComponentKey(); +// if (ComponentConfig.isNumberComponent(componentKey) +// || componentKey.equals(ComponentType.DateComponent.toString()) +// || componentKey.equals(ComponentType.TimeComponent.toString()) +// || dataType1.getComponentKey().equalsIgnoreCase(DataType.STRING) +// || dataType1.getComponentKey().equalsIgnoreCase(DataType.NUMBER) +// || dataType1.getComponentKey().equalsIgnoreCase(DataType.STRING) +// || dataType1.getComponentKey().equalsIgnoreCase(DataType.BOOL)) { +// +// filterData.setFieldId(dataType1.getFieldId() + ""); +// if (dataType1.getSubFormId() != null) { +// filterData.setSubFormId(dataType1.getSubFormId() + ""); +// } +// filterData.setComponentKey(componentKey); +// switch (name) { +// case ">=": +// filterData.setTerm(FilterFormData.TERM_GE); +// break; +// case ">": +// filterData.setTerm(FilterFormData.TERM_GT); +// break; +// case "<=": +// filterData.setTerm(FilterFormData.TERM_LE); +// break; +// case "<": +// filterData.setTerm(FilterFormData.TERM_LT); +// break; +// default: +// break; +// } +// filterData.setContent(content); +// } +// } +// filterFormDataList.add(filterData); +// dataType.setFormulaFilterDataList(filterFormDataList); +// dataType.setComponentKey(dataType1.getComponentKey()); +// dataType.setSubFormId(dataType1.getSubFormId()); +// } +// } catch (Exception e) { +// logger.error("err", e); +// } +// +// } +// +// /** +// * 校验大于、小于、小于等于、大于等于操作符的入参 +// * +// * @param name +// * @param obj1 +// * @param obj2 +// * @return +// */ +// public static boolean checkLessMoreParam(String name, Object obj1, Object obj2) { +// if (obj1 instanceof FormField) { +// String componentKey = ((FormField) obj1).getComponentKey(); +// if (ComponentConfig.isNumberComponent(componentKey)) { +// if (obj2 instanceof Number) { +// return true; +// } else if (obj2 instanceof DataType && ((DataType) obj2).getDataType().equalsIgnoreCase(DataType.NUMBER)) { +// return true; +// } else { +// throw new RuntimeException("筛选条件[" + name + "]:数字控件右边必须是数字"); +// } +// } +// if (componentKey.equals(ComponentType.DateComponent.toString())) { +// if (obj2 instanceof String && Validator.isDate((String) obj2)) { +// return true; +// } else if (obj2 instanceof DataType && ((DataType) obj2).getDataType().equalsIgnoreCase(DataType.STRING)) { +// return true; +// } else { +// throw new RuntimeException("筛选条件[" + name + "]:日期控件右边必须是日期字符串"); +// } +// +// } +// if (componentKey.equals(ComponentType.TimeComponent.toString())) { +// if (obj2 instanceof String && Validator.isTime((String) obj2)) { +// return true; +// } else if (obj2 instanceof DataType && ((DataType) obj2).getDataType().equalsIgnoreCase(DataType.STRING)) { +// return true; +// } else { +// throw new RuntimeException("筛选条件[" + name + "]:时间控件右边必须是时间字符串"); +// } +// } +// } +// throw new RuntimeException("筛选条件[" + name + "]:左边必须是数字控件或时间控件"); +// } +// +// /** +// * 校验等于号的入参 +// * +// * @param obj1 +// * @param obj2 +// * @return +// */ +// public static boolean checkEqParam(Object obj1, Object obj2) { +// if (obj1 instanceof DataType) { +// String componentKey = ((FormField) obj1).getComponentKey(); +// if (ComponentConfig.isNumberComponent(componentKey)) { +// if (obj2 instanceof DataType) { +// if (((DataType) obj2).getDataType().equalsIgnoreCase(DataType.NUMBER)) { +// return true; +// } else { +// throw new RuntimeException("筛选条件[=]:数字控件右边必须是数字"); +// } +// } else if (StringUtils.isEmpty(obj2 + "") || Validator.isFloat(obj2 + "")) { +// return true; +// } else { +// throw new RuntimeException("筛选条件[=]:数字控件右边必须是数字"); +// } +// } else if (ComponentConfig.isOptionComponent(componentKey)) { +// if (StringUtils.isEmpty(obj2 + "") || (obj2 instanceof DataType && ((DataType) obj2).getDataType().equalsIgnoreCase(DataType.OPTION))) { +// return true; +// } else { +// throw new RuntimeException("筛选条件[=]:选项控件右边必须是选项"); +// } +// } else { +// if (StringUtils.isEmpty(obj2 + "") || obj2 instanceof String || obj2 instanceof Character) { +// return true; +// } else if (obj2 instanceof DataType) { +// if (((DataType) obj2).getDataType().equalsIgnoreCase(DataType.STRING)) { +// return true; +// } else if (((DataType) obj2).getDataType().equalsIgnoreCase(DataType.STRING)) { +// return true; +// } else { +// throw new RuntimeException("筛选条件[=]:文本控件右边必须是字符"); +// } +// } else { +// throw new RuntimeException("筛选条件[=]:文本控件右边必须是字符"); +// } +// } +// } +// throw new RuntimeException("筛选条件[=]:左边必须是表单控件"); +// } +// +// /** +// * 校验不等于号的入参 +// * +// * @param obj1 +// * @param obj2 +// * @return +// */ +// public static boolean checkNotEqParam(Object obj1, Object obj2) { +// if (obj1 instanceof FormField) { +// String componentKey = ((FormField) obj1).getComponentKey(); +// if (ComponentConfig.isNumberComponent(componentKey)) { +// if (obj2 instanceof DataType) { +// if (((DataType) obj2).getDataType().equalsIgnoreCase(DataType.NUMBER)) { +// return true; +// } else { +// throw new RuntimeException("筛选条件[!=]:数字控件右边必须是数字"); +// } +// } else if (StringUtils.isEmpty(obj2 + "") || Validator.isFloat(obj2 + "")) { +// return true; +// } else { +// throw new RuntimeException("筛选条件[!=]:数字控件右边必须是数字"); +// } +// } else if (ComponentConfig.isOptionComponent(componentKey)) { +// if (StringUtils.isEmpty(obj2 + "") || (obj2 instanceof DataType && ((DataType) obj2).getDataType().equalsIgnoreCase(DataType.OPTION))) { +// return true; +// } else { +// throw new RuntimeException("筛选条件[!=]:选项控件右边必须是选项"); +// } +// } else { +// if (StringUtils.isEmpty(obj2 + "") || obj2 instanceof String || obj2 instanceof Character) { +// return true; +// } else if (obj2 instanceof DataType) { +// if (((DataType) obj2).getDataType().equalsIgnoreCase(DataType.STRING)) { +// return true; +// } else if (((DataType) obj2).getDataType().equalsIgnoreCase(DataType.STRING)) { +// return true; +// } else if (((DataType) obj2).getDataType().equalsIgnoreCase(DataType.STRING)) { +// return true; +// } else { +// throw new RuntimeException("筛选条件[!=]:文本控件右边必须是字符"); +// } +// } else { +// throw new RuntimeException("筛选条件[!=]:文本控件右边必须是字符"); +// } +// } +// } +// throw new RuntimeException("筛选条件[!=]:左边必须是表单控件"); +// } +//} diff --git a/src/com/engine/salary/formlua/func/compare/EqOperator.java b/src/com/engine/salary/formlua/func/compare/EqOperator.java new file mode 100644 index 000000000..679149b83 --- /dev/null +++ b/src/com/engine/salary/formlua/func/compare/EqOperator.java @@ -0,0 +1,239 @@ +package com.engine.salary.formlua.func.compare; + +import com.engine.salary.formlua.core.exception.ErrorType; +import com.engine.salary.formlua.entity.parameter.DataType; +import com.engine.salary.formlua.util.CompareUtil; +import com.engine.salary.formlua.util.DateUtil; +import com.engine.salary.formlua.util.ExcelParamUtil; +import com.ql.util.express.ArraySwap; +import com.ql.util.express.InstructionSetContext; +import com.ql.util.express.OperateData; +import com.ql.util.express.instruction.op.OperatorEqualsLessMore; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Arrays; +import java.util.Date; +import java.util.List; + + +public class EqOperator extends OperatorEqualsLessMore { + protected final Logger logger = LoggerFactory.getLogger(getClass()); + public EqOperator(String aName) { + super(aName); + } + + public EqOperator(String aAliasName, String aName, String aErrorInfo) { + super(aAliasName, aName, aErrorInfo); + } + + @Override + public OperateData executeInner(InstructionSetContext context, ArraySwap list) throws Exception { + return super.executeInner(context, list); + } + + @Override + public Object executeInner(Object... list) throws Exception { + DataType result=new DataType(); + result.setDataType(DataType.BOOL); + String oper="="; + if(list.length!=2){ + throw new RuntimeException("[=]"+ ErrorType.MAX_VAR_COUNT.name()); + } + Object op1=list[0]; + Object op2=list[1]; + //校验参数类型 + String datatype= ExcelParamUtil.checkParamType(op1); + String dataType2=ExcelParamUtil.checkParamType(op2); + if(op2 instanceof Object[]){ + Object[] objectParams=(Object[])op2; + if(objectParams[0] instanceof DataType){ + DataType paramDataType=(DataType)objectParams[0]; + dataType2=paramDataType.getDataType(); + }else{ + dataType2=ExcelParamUtil.checkParamType(objectParams[0]); + } + } + + if(datatype.equals(DataType.OPTION)||dataType2.equals(DataType.OPTION)){ + //对option的特殊处理,获取option的字符串后根据逗号分割,然后排序数组,数组长度不一致返回false,一致则循环对比直到同样下标的数据不一致返回false,否则为true + try { + String[] firstOptions=new String[]{}; + String[] secondOptions=new String[]{}; + result.setContent(true); + firstOptions= CompareUtil.genArray(op1,"option"); + secondOptions=CompareUtil.genArray(op2,"option"); + Arrays.sort(firstOptions); + Arrays.sort(secondOptions); + +// logger.info("比较选项:"+JSON.toJSONString(firstOptions)+"-->"+JSON.toJSONString(secondOptions)); + if(firstOptions.length!=secondOptions.length){ + result.setContent(false); + }else{ + int i=0; + for (;i dataList=ExcelParamUtil.converParamValue(op1,op2); + if(ExcelParamUtil.getParamType(op1).toLowerCase().equals("double")||ExcelParamUtil.getParamType(op2).toLowerCase().equals("double")){ + boolean r=OperatorEqualsLessMore.executeInner("=",ExcelParamUtil.convertParamValToNumber(dataList.get(0)),ExcelParamUtil.convertParamValToNumber(dataList.get(1))); + result.setContent(r); + }else if(op1 instanceof DataType && op2 instanceof DataType && DateUtil.isDateComponent(op1) && DateUtil.isDateComponent(op2)){ + + + Object dateStringOne=null; + if(op1 instanceof DataType){ + DataType dataTypeOne=(DataType)op1; + dateStringOne=dataTypeOne.getContent(); + }else{ + dateStringOne=op1; + } + + Object dateStringTwo=null; + if(op2 instanceof DataType){ + DataType dataTypeTwo=(DataType)op2; + dateStringTwo=dataTypeTwo.getContent(); + }else{ + dateStringTwo=op2; + } + boolean dateResult=false; + Date firstDate=DateUtil.buildDateByDateChar(dateStringOne==null?"":dateStringOne+""); + Date secondDate= DateUtil.buildDateByDateChar(dateStringTwo==null?"":dateStringTwo+""); + if (firstDate == null && secondDate == null){ + dateResult= true; + }else if(firstDate==null || secondDate ==null){ + dateResult= false; + }else{ + dateResult= firstDate.getTime()==secondDate.getTime(); + } + result.setContent(dateResult); + }else { + Object firstParam=ExcelParamUtil.getParamContent(dataList.get(0),""); + Object secondParam=ExcelParamUtil.getParamContent(dataList.get(1),""); + if((firstParam instanceof String || firstParam instanceof Character) && (secondParam instanceof String || secondParam instanceof Character)){ + if(firstParam.toString().length()==1&&secondParam.toString().length()==1){ + boolean r=firstParam.toString().equals(secondParam.toString()); + result.setContent(r); + return result; + } + } + boolean r=OperatorEqualsLessMore.executeInner("=",firstParam,secondParam); + result.setContent(r); + } + } catch (Exception e) { + logger.error("err",e); + } + } +// buildFilterParam(result,op1,op2); + return result.getContent(); + } + + /** + * 构建搜索条件参数 + * @param dataType + * @param obj1 + * @param obj2 + */ +// private void buildFilterParam(DataType dataType,Object obj1,Object obj2){ +// List filterFormDataList=new ArrayList<>(); +// FormulaFilterData filterData=new FormulaFilterData(); +// String content = null; +// try { +// if(obj1!=null && (obj1 instanceof DataType)){ +// DataType dataType1=(DataType)obj1; +// if(StringUtils.isEmpty(dataType1.getComponentKey())){ +// dataType1.setComponentKey(dataType1.getDataType()); +// } +// if(obj2 instanceof DataType) { +//// content = ((DataType) obj2).getContent()+""; +// DataType paramDataType=(DataType) obj2; +// if(paramDataType==null || paramDataType.getContent() == null){ +// content = ""; +// }else{ +// content = paramDataType.getContent()+""; +// } +// }else { +// content = obj2+""; +// } +// if ( content != null) { +// filterData.setFieldId(dataType1.getFieldId()); +// if(dataType1.getSubFormId() != null) { +// filterData.setSubFormId(dataType1.getSubFormId()+""); +// } +// +// filterData.setComponentKey(dataType1.getComponentKey()); +// if(StringUtils.isEmpty(content)) { +// filterData.setTerm(FilterFormData.TERM_NULL); +// }else{ +// filterData.setTerm(FilterFormData.TERM_EQ); +// if(StringUtils.isNotEmpty(dataType1.getComponentKey())){ +// //数字类型 +// if(ComponentConfig.isNumberComponent(dataType1.getComponentKey()) +// || dataType1.getComponentKey().equals(ComponentType.DateComponent.toString()) +// || dataType1.getComponentKey().equals(ComponentType.TimeComponent.toString()) +// || dataType1.getComponentKey().equalsIgnoreCase(DataType.STRING) +// || dataType1.getComponentKey().equalsIgnoreCase(DataType.NUMBER)|| +// dataType1.getComponentKey().equalsIgnoreCase(DataType.DATE) +// || dataType1.getComponentKey().equalsIgnoreCase(DataType.BOOL) +// ) { +// filterData.setContent(content); +// //选项控件 +// }else if(ComponentConfig.isOptionComponent(dataType1.getComponentKey())) { +// List ids = new ArrayList<>(); +// String[] idsArray = content.split(","); +// for(String idStr : idsArray) { +// if(StringUtils.isNotBlank(idStr)) { +// ids.add(idStr); +// } +// } +// filterData.setIds(ids); +// //文本型 +// }else { +// filterData.setContent(content); +// } +// } +// +// } +// } +// if(filterData!=null){ +// filterFormDataList.add(filterData); +// } +// +// logger.info("=号构建过滤参数:"+(filterFormDataList!=null? JSON.toJSONString(filterFormDataList):"NULL")); +// dataType.setFormulaFilterDataList(filterFormDataList); +// dataType.setComponentKey(dataType1.getComponentKey()); +// dataType.setSubFormId(dataType1.getSubFormId()); +// } +// } catch (Exception e) { +// logger.error("err",e); +// } +// +// } + + +} diff --git a/src/com/engine/salary/formlua/func/compare/GreaterEqOperator.java b/src/com/engine/salary/formlua/func/compare/GreaterEqOperator.java new file mode 100644 index 000000000..1b5146cd6 --- /dev/null +++ b/src/com/engine/salary/formlua/func/compare/GreaterEqOperator.java @@ -0,0 +1,104 @@ +package com.engine.salary.formlua.func.compare; + +import com.engine.salary.formlua.entity.parameter.DataType; +import com.engine.salary.formlua.util.CompareUtil; +import com.engine.salary.formlua.util.DateUtil; +import com.engine.salary.formlua.util.ExcelParamUtil; +import com.ql.util.express.instruction.op.OperatorEqualsLessMore; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Arrays; +import java.util.Date; +import java.util.List; + + +public class GreaterEqOperator extends OperatorEqualsLessMore { + protected final Logger logger = LoggerFactory.getLogger(this.getClass()); + + @Override + public Object executeInner(Object op1, Object op2) throws Exception { + DataType result = new DataType(); + result.setDataType(DataType.BOOL); + String datatype = ExcelParamUtil.checkParamType(op1); + //对option的特殊处理,获取option的字符串后根据逗号分割,然后排序数组,数组长度不一致返回false,一致则循环对比直到同样下标的数据不一致返回false,否则为true + try { + if (datatype.equals(DataType.OPTION)) { + result.setContent(true); + String[] firstOptions = new String[]{}; + String[] secondOptions = new String[]{}; + firstOptions = CompareUtil.genArray(op1, "option"); + secondOptions = CompareUtil.genArray(op2, "option"); + Arrays.sort(firstOptions); + Arrays.sort(secondOptions); + if (firstOptions.length != secondOptions.length) { + result.setContent(false); + } else { + int i = 0; + for (; i < firstOptions.length; i++) { + boolean loopresult = OperatorEqualsLessMore.executeInner(">=", firstOptions[i], secondOptions[i]); + if (!loopresult) { + result.setContent(false); + break; + } + } + } + } else if (op1 instanceof DataType && op2 instanceof DataType && DateUtil.isDateComponent(op1) && DateUtil.isDateComponent(op2)) { + + + Object dateStringOne = null; + if (op1 instanceof DataType) { + DataType dataTypeOne = (DataType) op1; + dateStringOne = dataTypeOne.getContent(); + } else { + dateStringOne = op1; + } + + Object dateStringTwo = null; + if (op2 instanceof DataType) { + DataType dataTypeTwo = (DataType) op2; + dateStringTwo = dataTypeTwo.getContent(); + } else { + dateStringTwo = op2; + } + boolean dateResult = false; + Date firstDate = DateUtil.buildDateByDateChar(dateStringOne == null ? "" : dateStringOne + ""); + Date secondDate = DateUtil.buildDateByDateChar(dateStringTwo == null ? "" : dateStringTwo + ""); + if (firstDate == null && secondDate == null) { + dateResult = true; + } else if (firstDate == null && secondDate != null) { + dateResult = false; + } else if (firstDate != null && secondDate == null) { + dateResult = true; + } else { + dateResult = firstDate.getTime() >= secondDate.getTime(); + } + result.setContent(dateResult); + } else { + List dataList = ExcelParamUtil.converParamValue(op1, op2); + boolean r; + if (ExcelParamUtil.getParamType(op1).toLowerCase().equals("double") || ExcelParamUtil.getParamType(op2).toLowerCase().equals("double")) { + r = OperatorEqualsLessMore.executeInner(">=", ExcelParamUtil.convertParamValToNumber(dataList.get(0)), ExcelParamUtil.convertParamValToNumber(dataList.get(1))); + } else { + r = OperatorEqualsLessMore.executeInner(">=", ExcelParamUtil.getParamContent(dataList.get(0), ""), ExcelParamUtil.getParamContent(dataList.get(1), "")); + } + result.setContent(r); + } + } catch (Exception e) { + logger.error("err", e); + result.setContent(false); + } +// Compareutils.buildLessMoreFilterParam(result,this.name,op1,op2); + return result.getContent(); + } + + public GreaterEqOperator(String aAliasName, String aName, String aErrorInfo) { + super(aAliasName, aName, aErrorInfo); + } + + public GreaterEqOperator(String aName) { + super(aName); + } + + +} diff --git a/src/com/engine/salary/formlua/func/compare/GreaterOperator.java b/src/com/engine/salary/formlua/func/compare/GreaterOperator.java new file mode 100644 index 000000000..1540b887c --- /dev/null +++ b/src/com/engine/salary/formlua/func/compare/GreaterOperator.java @@ -0,0 +1,101 @@ +package com.engine.salary.formlua.func.compare; + +import com.engine.salary.formlua.entity.parameter.DataType; +import com.engine.salary.formlua.util.CompareUtil; +import com.engine.salary.formlua.util.DateUtil; +import com.engine.salary.formlua.util.ExcelParamUtil; +import com.ql.util.express.instruction.op.OperatorEqualsLessMore; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Arrays; +import java.util.Date; + + +public class GreaterOperator extends OperatorEqualsLessMore { + protected final Logger logger = LoggerFactory.getLogger(getClass()); + + @Override + public Object executeInner(Object op1, Object op2) throws Exception { + DataType result = new DataType(); + result.setDataType(DataType.BOOL); +// IgnoreParamFilter.filterCompareFunc(op1,op2,">"); + String datatype = ExcelParamUtil.checkParamType(op1); + //对option的特殊处理,获取option的字符串后根据逗号分割,然后排序数组,数组长度不一致返回false,一致则循环对比直到同样下标的数据不一致返回false,否则为true + try { + if (datatype.equals(DataType.OPTION)) { + result.setContent(true); + String[] firstOptions = new String[]{}; + String[] secondOptions = new String[]{}; + firstOptions = CompareUtil.genArray(op1, "option"); + secondOptions = CompareUtil.genArray(op2, "option"); + Arrays.sort(firstOptions); + Arrays.sort(secondOptions); + if (firstOptions.length != secondOptions.length) { + result.setContent(false); + } else { + int i = 0; + for (; i < firstOptions.length; i++) { + boolean loopresult = OperatorEqualsLessMore.executeInner(">", firstOptions[i], secondOptions[i]); + if (!loopresult) { + result.setContent(false); + break; + } + } + } + } else if (op1 instanceof DataType && op2 instanceof DataType && DateUtil.isDateComponent(op1) && DateUtil.isDateComponent(op2)) { + + + Object dateStringOne = null; + if (op1 instanceof DataType) { + DataType dataTypeOne = (DataType) op1; + dateStringOne = dataTypeOne.getContent(); + } else { + dateStringOne = op1; + } + + Object dateStringTwo = null; + if (op2 instanceof DataType) { + DataType dataTypeTwo = (DataType) op2; + dateStringTwo = dataTypeTwo.getContent(); + } else { + dateStringTwo = op2; + } + boolean dateResult = false; + Date firstDate = DateUtil.buildDateByDateChar(dateStringOne == null ? "" : dateStringOne + ""); + Date secondDate = DateUtil.buildDateByDateChar(dateStringTwo == null ? "" : dateStringTwo + ""); + if (firstDate == null && secondDate == null) { + dateResult = false; + } else if (firstDate == null && secondDate != null) { + dateResult = false; + } else if (firstDate != null && secondDate == null) { + dateResult = true; + } else { + dateResult = firstDate.getTime() > secondDate.getTime(); + } + result.setContent(dateResult); + } else { + boolean r; + if (ExcelParamUtil.getParamType(op1).toLowerCase().equals("double") || ExcelParamUtil.getParamType(op2).toLowerCase().equals("double")) { + r = OperatorEqualsLessMore.executeInner(">", ExcelParamUtil.convertParamValToNumber(op1), ExcelParamUtil.convertParamValToNumber(op2)); + } else { + r = OperatorEqualsLessMore.executeInner(">", ExcelParamUtil.getParamContent(op1, ""), ExcelParamUtil.getParamContent(op2, "")); + } + result.setContent(r); + } + } catch (Exception e) { + logger.error("err", e); + result.setContent(false); + } +// Compareutils.buildLessMoreFilterParam(result, this.name, op1, op2); + return result.getContent(); + } + + public GreaterOperator(String aName) { + super(aName); + } + + public GreaterOperator(String aAliasName, String aName, String aErrorInfo) { + super(aAliasName, aName, aErrorInfo); + } +} diff --git a/src/com/engine/salary/formlua/func/compare/InOperator.java b/src/com/engine/salary/formlua/func/compare/InOperator.java new file mode 100644 index 000000000..22d7dcf6f --- /dev/null +++ b/src/com/engine/salary/formlua/func/compare/InOperator.java @@ -0,0 +1,97 @@ +package com.engine.salary.formlua.func.compare; + +import com.alibaba.fastjson.JSON; +import com.engine.salary.formlua.entity.parameter.DataType; +import com.engine.salary.formlua.func.logic.LogicUtils; +import com.engine.salary.formlua.util.ExcelParamUtil; +import com.engine.salary.formlua.util.IgnoreParamFilter; +import com.ql.util.express.instruction.op.OperatorIn; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.ArrayList; +import java.util.List; + + +public class InOperator extends OperatorIn { + protected final Logger logger = LoggerFactory.getLogger(this.getClass()); + @Override + public Object executeInner(Object[] list) throws Exception { + DataType result=new DataType(); + result.setDataType(DataType.BOOL); + if(list.length<1||list[1]==null){ + Integer number= IgnoreParamFilter.getSetFuncNumber("IN"); + } + List paramList=new ArrayList<>(); + paramList.add(list[0]); + Object[] objectArray=(Object[])list[1]; + for (int i=0;i(); + paramList.add(null); + List dataArray=new ArrayList<>(); + if(list[0] instanceof DataType){ + DataType dataType=(DataType)list[0]; + if(dataType.getDataType().equals(DataType.OPTION)){ + if(dataType.getContent()!=null){ + String[] arrys=dataType.getContent().toString().split(","); + for (int i=0;i dataList=ExcelParamUtil.converParamValue(op1,op2); + boolean r; + if(ExcelParamUtil.getParamType(op1).toLowerCase().equals("double")||ExcelParamUtil.getParamType(op2).toLowerCase().equals("double")){ + r=OperatorEqualsLessMore.executeInner("<=",ExcelParamUtil.convertParamValToNumber(dataList.get(0)),ExcelParamUtil.convertParamValToNumber(dataList.get(1))); + }else { + r=OperatorEqualsLessMore.executeInner("<=",ExcelParamUtil.getParamContent(dataList.get(0),""),ExcelParamUtil.getParamContent(dataList.get(1),"")); + } + result.setContent(r); + } + } catch (Exception e) { + logger.error("err",e); + result.setContent(false); + } +// Compareutils.buildLessMoreFilterParam(result,this.name,op1,op2); + return result.getContent(); + } + + public LessEqOperator(String aName) { + super(aName); + } + + public LessEqOperator(String aAliasName, String aName, String aErrorInfo) { + super(aAliasName, aName, aErrorInfo); + } +} diff --git a/src/com/engine/salary/formlua/func/compare/LessOperator.java b/src/com/engine/salary/formlua/func/compare/LessOperator.java new file mode 100644 index 000000000..862042c6f --- /dev/null +++ b/src/com/engine/salary/formlua/func/compare/LessOperator.java @@ -0,0 +1,104 @@ +package com.engine.salary.formlua.func.compare; + +import com.engine.salary.formlua.entity.parameter.DataType; +import com.engine.salary.formlua.util.CompareUtil; +import com.engine.salary.formlua.util.DateUtil; +import com.engine.salary.formlua.util.ExcelParamUtil; +import com.ql.util.express.instruction.op.OperatorEqualsLessMore; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Arrays; +import java.util.Date; +import java.util.List; + + +public class LessOperator extends OperatorEqualsLessMore { + protected final Logger logger = LoggerFactory.getLogger(this.getClass()); + @Override + public Object executeInner(Object op1, Object op2) throws Exception { + DataType result=new DataType(); + result.setDataType(DataType.BOOL); +// IgnoreParamFilter.filterCompareFunc(op1,op2,"<"); + String datatype= ExcelParamUtil.checkParamType(op1); + + //对option的特殊处理,获取option的字符串后根据逗号分割,然后排序数组,数组长度不一致返回false,一致则循环对比直到同样下标的数据不一致返回false,否则为true + try { + if(datatype.equals(DataType.OPTION)){ + result.setContent(true); + String[] firstOptions=new String[]{}; + String[] secondOptions=new String[]{}; + firstOptions= CompareUtil.genArray(op1,"option"); + secondOptions=CompareUtil.genArray(op2,"option"); + Arrays.sort(firstOptions); + Arrays.sort(secondOptions); + if(firstOptions.length!=secondOptions.length){ + result.setContent(false); + }else{ + int i=0; + for (;i dataList=ExcelParamUtil.converParamValue(op1,op2); + boolean r; + if(ExcelParamUtil.getParamType(op1).toLowerCase().equals("double")||ExcelParamUtil.getParamType(op2).toLowerCase().equals("double")){ + r=OperatorEqualsLessMore.executeInner("<",ExcelParamUtil.convertParamValToNumber(dataList.get(0)),ExcelParamUtil.convertParamValToNumber(dataList.get(1))); + }else { + r=OperatorEqualsLessMore.executeInner("<",ExcelParamUtil.getParamContent(dataList.get(0),""),ExcelParamUtil.getParamContent(dataList.get(1),"")); + } + result.setContent(r); + } + } catch (Exception e) { + logger.error("err",e); + result.setContent(false); + } +// Compareutils.buildLessMoreFilterParam(result,this.name,op1,op2); + return result.getContent(); + } + + public LessOperator(String aName) { + super(aName); + } + + public LessOperator(String aAliasName, String aName, String aErrorInfo) { + super(aAliasName, aName, aErrorInfo); + } + +} diff --git a/src/com/engine/salary/formlua/func/compare/NotEqueOperator.java b/src/com/engine/salary/formlua/func/compare/NotEqueOperator.java new file mode 100644 index 000000000..80589c977 --- /dev/null +++ b/src/com/engine/salary/formlua/func/compare/NotEqueOperator.java @@ -0,0 +1,102 @@ +package com.engine.salary.formlua.func.compare; + +import com.engine.salary.formlua.entity.parameter.DataType; +import com.engine.salary.formlua.util.CompareUtil; +import com.engine.salary.formlua.util.DateUtil; +import com.engine.salary.formlua.util.ExcelParamUtil; +import com.ql.util.express.instruction.op.OperatorEqualsLessMore; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Date; +import java.util.List; + +public class NotEqueOperator extends OperatorEqualsLessMore { + protected final Logger logger = LoggerFactory.getLogger(this.getClass()); + + @Override + public Object executeInner(Object op1, Object op2) throws Exception { + DataType result = new DataType(); + result.setDataType(DataType.BOOL); +// IgnoreParamFilter.filterCompareFunc(op1,op2,"!="); + String datatype = ExcelParamUtil.checkParamType(op1); + + //对option的特殊处理,获取option的字符串后根据逗号分割,然后排序数组,数组长度不一致返回false,一致则循环对比直到同样下标的数据不一致返回false,否则为true + try { + if (datatype.equals(DataType.OPTION)) { + result.setContent(true); + String[] firstOptions = new String[]{}; + String[] secondOptions = new String[]{}; + firstOptions = CompareUtil.genArray(op1, "option"); + secondOptions = CompareUtil.genArray(op2, "option"); + if (firstOptions.length != secondOptions.length) { + result.setContent(true); + } else { + int i = 0; + for (; i < firstOptions.length; i++) { + boolean loopresult = OperatorEqualsLessMore.executeInner("!=", firstOptions[i], secondOptions[i]); + if (!loopresult) { + result.setContent(false); + break; + } + } + } + } else if (op1 instanceof DataType && op2 instanceof DataType && DateUtil.isDateComponent(op1) && DateUtil.isDateComponent(op2)) { + + + Object dateStringOne = null; + if (op1 instanceof DataType) { + DataType dataTypeOne = (DataType) op1; + dateStringOne = dataTypeOne.getContent(); + } else { + dateStringOne = op1; + } + + Object dateStringTwo = null; + if (op2 instanceof DataType) { + DataType dataTypeTwo = (DataType) op2; + dateStringTwo = dataTypeTwo.getContent(); + } else { + dateStringTwo = op2; + } + boolean dateResult = false; + Date firstDate = DateUtil.buildDateByDateChar(dateStringOne == null ? "" : dateStringOne + ""); + Date secondDate = DateUtil.buildDateByDateChar(dateStringTwo == null ? "" : dateStringTwo + ""); + if (firstDate == null && secondDate == null) { + dateResult = false; + } else if ((firstDate == null && secondDate != null) || (firstDate != null && secondDate == null)) { + dateResult = true; + } else { + dateResult = firstDate.getTime() != secondDate.getTime(); + } + result.setContent(dateResult); + } else { + List dataList = ExcelParamUtil.converParamValue(op1, op2); + Object firstParam = ExcelParamUtil.getParamContent(dataList.get(0), ""); + Object secondParam = ExcelParamUtil.getParamContent(dataList.get(1), ""); + if ((firstParam instanceof String || firstParam instanceof Character) && (secondParam instanceof String || secondParam instanceof Character)) { + if (firstParam.toString().length() == 1 && secondParam.toString().length() == 1) { + boolean r = !(firstParam.toString().equals(secondParam.toString())); + result.setContent(r); + return result; + } + } + boolean r = OperatorEqualsLessMore.executeInner("!=", firstParam, secondParam); + result.setContent(r); + } + } catch (Exception e) { + logger.error("err", e); + result.setContent(false); + } +// Compareutils.buildNotEqFilterParam(result, op1, op2); + return result.getContent(); + } + + public NotEqueOperator(String aName) { + super(aName); + } + + public NotEqueOperator(String aAliasName, String aName, String aErrorInfo) { + super(aAliasName, aName, aErrorInfo); + } +} diff --git a/src/com/engine/salary/formlua/func/compare/OperatorInTest.java b/src/com/engine/salary/formlua/func/compare/OperatorInTest.java new file mode 100644 index 000000000..ec5701582 --- /dev/null +++ b/src/com/engine/salary/formlua/func/compare/OperatorInTest.java @@ -0,0 +1,38 @@ +package com.engine.salary.formlua.func.compare; + +import com.engine.salary.formlua.entity.parameter.DataType; +import com.engine.salary.formlua.util.ExcelParamUtil; +import com.engine.salary.formlua.util.IgnoreParamFilter; +import com.ql.util.express.instruction.op.OperatorIn; + +import java.util.ArrayList; +import java.util.List; + + +public class OperatorInTest extends OperatorIn { + + @Override + public Object executeInner(Object[] list) throws Exception { + DataType result=new DataType(); + result.setDataType(DataType.BOOL); + result.setContent(true); + if(list.length<2||list[1]==null){ + Integer number= IgnoreParamFilter.getSetFuncNumber("IN"); + } + List paramList=new ArrayList<>(); + paramList.add(list[0]); + Object[] objectArray=(Object[])list[1]; + for (int i=0;i operList= CommonOper.operAddReduceList(obj1,obj2); + for (int i=0;i operList = CommonOper.operDivMultiList(firstParam, secondParam, "/"); + Object[] results = new Object[operList.size()]; + for (int i = 0; i < operList.size(); i++) { + Object[] excuteArray = operList.get(i); + results[i] = super.executeInner(excuteArray); + } + return results; + } catch (Exception e) { + logger.error("err", e); + return 0; + } + } + newList[0] = firstParam; + newList[1] = secondParam; + try { + Object r = super.executeInner(newList); + result.setContent(new BigDecimal(r + "")); + } catch (Exception e) { + logger.error("除法计算异常返回0:" + e.getMessage()); + result.setContent(0); + } + return result; + } + + public WOperatorDiv(String name) { + super(name); + } +} diff --git a/src/com/engine/salary/formlua/func/compare/WOperatorMulti.java b/src/com/engine/salary/formlua/func/compare/WOperatorMulti.java new file mode 100644 index 000000000..962da3bbf --- /dev/null +++ b/src/com/engine/salary/formlua/func/compare/WOperatorMulti.java @@ -0,0 +1,55 @@ +package com.engine.salary.formlua.func.compare; + +import com.engine.salary.formlua.entity.parameter.DataType; +import com.engine.salary.formlua.util.ExcelParamUtil; +import com.ql.util.express.instruction.op.OperatorMultiDiv; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.math.BigDecimal; +import java.util.List; + + +public class WOperatorMulti extends OperatorMultiDiv { + protected final Logger logger = LoggerFactory.getLogger(this.getClass()); + @Override + public Object executeInner(Object[] list) throws Exception { + DataType result=new DataType(); + result.setDataType(DataType.NUMBER); + Object[] newList=new Object[2]; +// IgnoreParamFilter.checkNumberOper(list,"*"); + Object firstParam= ExcelParamUtil.getParamContent(list[0],""); + Object secondParam=ExcelParamUtil.getParamContent(list[1],""); + if(StringUtils.isEmpty(firstParam+"") || StringUtils.isEmpty(secondParam+"")){ + result.setContent(0); + return result; + } + if(firstParam instanceof Object[] || secondParam instanceof Object[]){ + List operList= CommonOper.operDivMultiList(firstParam,secondParam,"*"); + Object[] results=new Object[operList.size()]; + for (int i=0;i operList= CommonOper.operAddReduceList(obj1,obj2); + for (int i=0;i 0) { + return new DataType(DataType.STRING, ""); + } + formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String nowStr = formatter.format(new Date()); + return new DataType(DataType.STRING, nowStr); + } + + /** + * 返回当前日期 + * + * @return + */ + @Override + public DataType today(Object... objects) { + int number = IgnoreParamFilter.getSetFuncNumber(FuncNames.TODAY.toString()); + if (objects.length > 0) { + return new DataType(DataType.STRING, ""); + } + formatter = new SimpleDateFormat("yyyy-MM-dd"); + String dateStr = formatter.format(new Date()); + return new DataType(DataType.STRING, dateStr); + } + + /** + * 格式化时间日期 + * + * @param objects + * @return + */ + @Override + public DataType dateFormat(Object... objects) { + Class[] typeObjects = new Class[]{DateAndString.class, String.class}; + String func = "DATEFORMAT"; + IgnoreParamFilter.commonFilter(func, 2, 2, typeObjects, objects); + Object result = objects[0]; + String dateStr = ""; + Object p1 = objects[0]; + Object p2 = objects[1]; + if (ExcelParamUtil.checkIsNull(p1, p2)) { + throw new RuntimeException("日期格式化函数参数不能为空"); + } + if (p1 instanceof DataType) { + DataType dataType = (DataType) p1; + dateStr = ExcelParamUtil.getParamContent(dataType.getContent(), "date") != null ? ExcelParamUtil.getParamContent(dataType.getContent(), "date").toString() : ""; + } else { + if (p1 instanceof Date) { + dateStr = formatter.format(p1); + } else { + dateStr = p1.toString(); + } + } + String formatStr = (ExcelParamUtil.getParamContent(p2, "string") != null ? ExcelParamUtil.getParamContent(p2, "string") : "").toString().replaceAll("D", "d"); + try { + String formatterStr = DateUtil.buildFormat(dateStr); + formatter = new SimpleDateFormat(formatterStr); + Date sourceDate = formatter.parse(dateStr); + formatter = new SimpleDateFormat(formatStr); + dateStr = formatter.format(sourceDate); + result = dateStr; + } catch (ParseException e) { + logger.error("err", e); + return new DataType(DataType.STRING, ""); + } + + return new DataType(DataType.STRING, result); + } + + /** + * 两个日期加减 + * + * @param + * @param + * @return + */ + @Override + public DataType dateDiff(Object... objects) { + Class[] typeObjects = new Class[]{DateAndString.class, DateAndString.class, String.class}; + IgnoreParamFilter.commonFilter("DATEDIFF", 2, 3, typeObjects, objects); + Long secondsL = new Long(60 * 60 * 1000);//计算日期时间间距的单位,默认为小时 + + Long nd = buildSecondsFmt("D"); + Long nh = buildSecondsFmt("H"); + Long nm = buildSecondsFmt("I"); + Long ns = buildSecondsFmt("S"); + + + Double result = new Double(0); + String type = "D"; + String sContent = DateUtil.getContent(objects[0], formatter); + String eContent = DateUtil.getContent(objects[1], formatter); + if (ExcelParamUtil.checkIsNull(sContent, eContent, ExcelParamUtil.CHECKLEVEL_STRING)) { + return new DataType(DataType.NUMBER, 0); + } + Date startDate = null; + Date endDate = null; + + format = DateUtil.buildFormat(sContent); + startDate = formateDateStr(sContent, format); + format = DateUtil.buildFormat(eContent); + endDate = formateDateStr(eContent, format); + if (startDate == null || endDate == null) { + return new DataType(DataType.NUMBER, 0); + } + Calendar cal1 = Calendar.getInstance(); + cal1.setTime(startDate); + //当前时间 + Calendar cal2 = Calendar.getInstance(); + cal2.setTime(endDate); + + + long diff = cal2.getTime().getTime() - cal1.getTime().getTime(); + + if (objects.length == 3) { + type = ExcelParamUtil.getParamContent(objects[2], "string") != null ? ExcelParamUtil.getParamContent(objects[2], "string").toString() : ""; + secondsL = buildSecondsFmt(type); + } + Double time = new Double(0); + boolean checkType = true; + switch (type) { + case "Y": + time = DateTimeServiceImpl.getTime(startDate, endDate) / (nd.doubleValue()) / 365.0; + break; + case "M": + Long monthR = DateTimeServiceImpl.getByField(cal1, cal2, Calendar.YEAR) * 12 + DateTimeServiceImpl.getByField(cal1, cal2, Calendar.MONTH); + time = monthR.doubleValue(); + break; + case "D": + double dayR = DateTimeServiceImpl.getTime(startDate, endDate) / (nd.doubleValue()); + time = dayR; + break; + case "H": + double hourH = DateTimeServiceImpl.getTime(startDate, endDate) / (nh.doubleValue()); + time = hourH; + break; + case "I": + double minuR = DateTimeServiceImpl.getTime(startDate, endDate) / (nm.doubleValue()); + time = minuR; + break; + case "S": + double seconR = DateTimeServiceImpl.getTime(startDate, endDate) / ns.doubleValue(); + time = seconR; + break; + default: + checkType = false; + break; + } + if (!checkType) { + return new DataType(DataType.STRING, ""); + } + BigDecimal b = new BigDecimal(time); + double f1 = b.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); + result = f1; + return new DataType(DataType.NUMBER, result); + } + + /** + * 日期加减天数 + * + * @param objects + * @return + */ + @Override + public DataType dateAdd(Object... objects) { + Class[] typeObjects = new Class[]{DateAndString.class, Integer.class, String.class}; + IgnoreParamFilter.commonFilter("DATEADD", 2, 3, typeObjects, objects); + + String type = "D"; + if (objects.length == 3) { + type = objects[2].toString(); + } + + Object tcontent = DateUtil.getContent(objects[0], formatter); + Double numD = Double.parseDouble(ExcelParamUtil.getParamContent(objects[1], "") != null ? ExcelParamUtil.getParamContent(objects[1], "").toString() : ""); + + int num = numD.intValue(); + if (ExcelParamUtil.checkIsNull(tcontent, numD, type, ExcelParamUtil.CHECKLEVEL_STRING)) { + return new DataType(DataType.STRING, ""); + } + Object result = ""; + + try { + Date date = null; + if (tcontent instanceof String || tcontent instanceof Character) { + format = DateUtil.buildFormat(tcontent.toString()); + if (null == format) { + return new DataType(DataType.STRING, ""); + } + date = formateDateStr(tcontent.toString(), format); + } else { + date = (Date) tcontent; + } + Calendar cal = Calendar.getInstance(); + cal.setTime(date); + boolean checkType = true; + switch (type) { + case "Y": + cal.add(Calendar.YEAR, num); + break; + case "M": + cal.add(Calendar.MONTH, num); + break; + case "D": + cal.add(Calendar.DAY_OF_MONTH, num); + break; + case "H": + cal.add(Calendar.HOUR_OF_DAY, num); + break; + case "I": + cal.add(Calendar.MINUTE, num); + break; + case "S": + cal.add(Calendar.SECOND, num); + break; + default: + checkType = false; + break; + } + if (!checkType) { + String func = "DATEADD"; + return new DataType(DataType.STRING, ""); + } + Date newDate = cal.getTime(); + String nDate = formateDateStr(newDate, format); + result = nDate; + + } catch (ParseException e) { + logger.error("err", e); + } + return new DataType(DataType.STRING, result); + } + + /** + * 返回年份 + * + * @param objects + * @return + */ + @Override + public DataType year(Object... objects) { + Object reuslt = new Object(); + Class[] typeObjects = new Class[]{DateAndString.class}; + IgnoreParamFilter.commonFilter("YEAR", 1, 1, typeObjects, objects); + Object obj = objects[0]; + Object date = DateUtil.getContent(obj, formatter); + if (ExcelParamUtil.checkIsNull(date, ExcelParamUtil.CHECKLEVEL_STRING)) { + return new DataType(DataType.NUMBER, 0); + } + int year = 0; + try { + year = getDateTimeValue(date, "Y", "YEAR"); + reuslt = year; + } catch (ParseException e) { + logger.error("err", e); + throw new RuntimeException(e); + } + + return new DataType(DataType.NUMBER, reuslt); + } + + /** + * 返回是今年第几月 + * + * @param objects + * @return + */ + @Override + public DataType month(Object... objects) { + + Object reuslt = new Object(); + Class[] typeObjects = new Class[]{DateAndString.class}; + IgnoreParamFilter.commonFilter("MONTH", 1, 1, typeObjects, objects); + Object obj = objects[0]; + Object date = DateUtil.getContent(obj, formatter); + if (ExcelParamUtil.checkIsNull(date, ExcelParamUtil.CHECKLEVEL_STRING)) { + return new DataType(DataType.NUMBER, 0); + } + boolean isDate = checkDateString(date != null ? date.toString() : ""); + if (!isDate) { + return new DataType(DataType.NUMBER, 0); + } + int month = 0; + try { + month = getDateTimeValue(date, "M", "MONTH"); + reuslt = month + 1; + } catch (ParseException e) { + logger.error("err", e); + throw new RuntimeException(e); + } + + return new DataType(DataType.NUMBER, reuslt); + + } + + /** + * 返回日期是本月几号 + * + * @param objects + * @return + */ + @Override + public DataType day(Object... objects) { + Object reuslt = new Object(); + Class[] typeObjects = new Class[]{DateAndString.class}; + IgnoreParamFilter.commonFilter("DAY", 1, 1, typeObjects, objects); + Object obj = objects[0]; + Object date = DateUtil.getContent(obj, formatter); + if (ExcelParamUtil.checkIsNull(date, ExcelParamUtil.CHECKLEVEL_STRING)) { + return new DataType(DataType.NUMBER, 0); + } + int day = 0; + try { + day = getDateTimeValue(date, "D", "DAY"); + reuslt = day; + } catch (ParseException e) { + logger.error("err", e); + throw new RuntimeException(e); + } + + return new DataType(DataType.NUMBER, reuslt); + + } + + /** + * 返回时钟位置 + * + * @param objects + * @return + */ + @Override + public DataType hour(Object... objects) { + + Object reuslt = new Object(); + Class[] typeObjects = new Class[]{DateAndString.class}; + IgnoreParamFilter.commonFilter("HOUR", 1, 1, typeObjects, objects); + Object obj = objects[0]; + Object date = DateUtil.getContent(obj, formatter); + if (ExcelParamUtil.checkIsNull(date, ExcelParamUtil.CHECKLEVEL_STRING)) { + return new DataType(DataType.NUMBER, 0); + } + Integer hour = 0; + try { + hour = getDateTimeValue(date, "H", "HOUR"); + reuslt = hour; + } catch (ParseException e) { + logger.error("err", e); + throw new RuntimeException(e); + } + + return new DataType(DataType.NUMBER, reuslt); + + } + + /** + * 返回分钟位置 + * + * @param objects + * @return + */ + @Override + public DataType minute(Object... objects) { + Object reuslt = new Object(); + Class[] typeObjects = new Class[]{DateAndString.class}; + IgnoreParamFilter.commonFilter("MINUTE", 1, 1, typeObjects, objects); + Object obj = objects[0]; + Object date = DateUtil.getContent(obj, formatter); + if (ExcelParamUtil.checkIsNull(date, ExcelParamUtil.CHECKLEVEL_STRING)) { + return new DataType(DataType.NUMBER, 0); + } + int minute = 0; + try { + minute = getDateTimeValue(date, "I", "MINUTE"); + + reuslt = minute; + } catch (ParseException e) { + logger.error("err", e); + throw new RuntimeException(e); + } + + return new DataType(DataType.NUMBER, reuslt); + } + + /*** + * 返回秒钟位置 + * @param objects + * @return + */ + @Override + public DataType seconds(Object... objects) { + Object reuslt = new Object(); + Class[] typeObjects = new Class[]{DateAndString.class}; + IgnoreParamFilter.commonFilter("SECOND", 1, 1, typeObjects, objects); + Object obj = objects[0]; + Object date = DateUtil.getContent(obj, formatter); + if (ExcelParamUtil.checkIsNull(date, ExcelParamUtil.CHECKLEVEL_STRING)) { + return new DataType(DataType.NUMBER, 0); + } + int seconds = 0; + try { + seconds = getDateTimeValue(date, "S", "SECOND"); + reuslt = seconds; + } catch (ParseException e) { + logger.error("err", e); + throw new RuntimeException(e); + } + + return new DataType(DataType.NUMBER, reuslt); + + } + + /** + * 计算是本月的第几周 + * + * @param objects + * @return + */ + @Override + public DataType weekNum(Object... objects) { + Class[] typeObjects = new Class[]{DateAndString.class}; + IgnoreParamFilter.commonFilter("WEEKNUM", 1, 1, typeObjects, objects); + Object obj = objects[0]; + Object date = DateUtil.getContent(obj, formatter); + if (ExcelParamUtil.checkIsNull(date, ExcelParamUtil.CHECKLEVEL_STRING)) { + return new DataType(DataType.NUMBER, 0); + } + int weekNum = 0; + try { + weekNum = getDateTimeValue(date, "WM", "WEEKNUM"); + } catch (ParseException e) { + logger.error("err", e); + throw new RuntimeException(e); + } + return new DataType(DataType.NUMBER, weekNum); + } + + /** + * 判断是周几,因为周几是从周天的0开始算,所以返回数据需要减1 + * + * @param objects + * @return + */ + @Override + public DataType weekDay(Object... objects) { + Class[] typeObjects = new Class[]{DateAndString.class}; + IgnoreParamFilter.commonFilter("WEEKDAY", 1, 1, typeObjects, objects); + Object obj = objects[0]; + Object date = DateUtil.getContent(obj, formatter); + if (ExcelParamUtil.checkIsNull(date, ExcelParamUtil.CHECKLEVEL_STRING)) { + return new DataType(DataType.NUMBER, 0); + } + int weekDay = 0; + try { + weekDay = getDateTimeValue(date, "DW", "WEEKDAY"); + } catch (ParseException e) { + logger.error("err", e); + } + return new DataType(DataType.NUMBER, weekDay > 0 ? (weekDay - 1) : weekDay); + } + + @Override + public DataType dayOfMonth(Object... objects) { + String dayType = ""; + if (objects != null && objects.length > 0 && objects[0] != null) { + dayType = objects[0].toString(); + } + + // 获取当前年份、月份、日期 + Calendar cale = null; + // 获取当月第一天和最后一天 + SimpleDateFormat formatTemp = new SimpleDateFormat("yyyy-MM-dd HH:mm"); + String firstday = "", lastday = ""; + String date = ""; + switch (dayType.toLowerCase()) { + case "first": + // 获取当前月的第一天 + cale = Calendar.getInstance(); + cale.add(Calendar.MONTH, 0); + cale.set(Calendar.DAY_OF_MONTH, 1); + cale.set(Calendar.HOUR_OF_DAY, 0); + cale.set(Calendar.MINUTE, 0); + firstday = formatTemp.format(cale.getTime()); + date = firstday; + break; + case "last": + // 获取当前月的最后一天 + cale = Calendar.getInstance(); + cale.add(Calendar.MONTH, 1); + cale.set(Calendar.DAY_OF_MONTH, 0); + cale.set(Calendar.HOUR_OF_DAY, 0); + cale.set(Calendar.MINUTE, 0); + lastday = formatTemp.format(cale.getTime()); + date = lastday; + break; + default: + // 获取指定的某一天 + if (dayType == null || dayType.trim().equalsIgnoreCase("")) { + dayType = "0"; + } + cale = Calendar.getInstance(); + cale.add(Calendar.MONTH, 1); + cale.set(Calendar.DAY_OF_MONTH, Integer.parseInt(dayType)); + cale.set(Calendar.HOUR_OF_DAY, 0); + cale.set(Calendar.MINUTE, 0); + lastday = formatTemp.format(cale.getTime()); + date = lastday; + break; + } + return new DataType(DataType.STRING, date); + } + + @Override + public DataType monthOfYear(Object... objects) { + String dayType = ""; + if (objects != null && objects.length > 0 && objects[0] != null) { + dayType = objects[0].toString(); + } + if (dayType == null || dayType.equalsIgnoreCase("")) { + dayType = "0"; + } + int month = Integer.parseInt(dayType); + if (month > 0) { + month -= 1; + } + SimpleDateFormat formatTemp = new SimpleDateFormat("yyyy-MM-dd HH:mm"); + Calendar cale = Calendar.getInstance(); + cale.set(cale.get(Calendar.YEAR), month, 1); + + String lastday = formatTemp.format(cale.getTime()); + System.out.println(lastday); + return new DataType(DataType.STRING, lastday); + } + + @Override + public DataType timeOfDay(Object... objects) { + String dayType = ""; + if (objects != null && objects.length > 0 && objects[0] != null) { + dayType = objects[0].toString(); + } + SimpleDateFormat dayFormatTemp = new SimpleDateFormat("yyyy-MM-dd"); + SimpleDateFormat formatTemp = new SimpleDateFormat("HH:mm"); + Calendar cale = Calendar.getInstance(); + try { + cale.setTime(new Date()); + } catch (Exception e) { + logger.error("err", e); + } + cale.set(Calendar.HOUR_OF_DAY, Integer.parseInt(dayType)); + cale.set(Calendar.MINUTE, 0); + String lastday = formatTemp.format(cale.getTime()); + return new DataType(DataType.STRING, lastday); + } + + @Override + public DataType eoMonth(Object... objects) { + Object result = ""; + //校验 + Class[] typeObjects = new Class[]{DateAndString.class, Integer.class}; + IgnoreParamFilter.commonFilter("EOMONTH", 1, 2, typeObjects, objects); + + //获取日期和加减参数 + Object dateObj = objects[0]; + Object dateContent = dateObj != null ? DateUtil.getContent(dateObj, formatter) : null; + + Object tempObj = objects.length > 1 ? objects[1] : null; + Object numObj = tempObj != null && ExcelParamUtil.getParamContent(tempObj, "") != null ? ExcelParamUtil.getParamContent(tempObj, "").toString() : null; + + int num = numObj != null ? Integer.parseInt(numObj + "") : 0; + if (ExcelParamUtil.checkIsNull(dateContent, ExcelParamUtil.CHECKLEVEL_STRING)) { + throw new RuntimeException("日期参数不能为空"); + } + + try { + Date date = null; + if (dateContent instanceof String || dateContent instanceof Character) { + format = DateUtil.buildFormat(dateContent.toString()); + if (null == format) { + return null; + } + date = formateDateStr(dateContent.toString(), format); + } else { + date = (Date) dateContent; + } + + //在传入日期上进行月份加减操作,并设置为当月第一天 + Calendar cal = Calendar.getInstance(); + cal.setTime(date); + cal.add(Calendar.MONTH, num); + cal.set(Calendar.DAY_OF_MONTH, 1); + + //取该月最后一天 + cal.add(Calendar.MONTH, 1); + cal.add(Calendar.DAY_OF_MONTH, -1); + + Date newDate = cal.getTime(); + result = formateDateStr(newDate, format); + } catch (ParseException e) { + logger.error("eoMonth执行出错:" + e.getMessage(), e); + } + return new DataType(DataType.STRING, result); + } + +// @Override +// public DataType workdayIntl(Object... objects) { +// //校验 +// Object result = null; +// IgnoreParamFilter.commonFilter("NETWORKDAYSPI", 3, 3, null, objects); +// +// //获取开始日期 +// Object startObj = objects[0]; +// Object startDateObj = startObj != null ? DateUtil.getContent(startObj, formatter) : null; +// +// Date startDate = null; +// if (startDateObj != null) { +// +// if (startDateObj instanceof String || startDateObj instanceof Character) { +// format = DateUtil.buildFormat(startDateObj.toString()); +// if (null == format) { +// logger.error("workdayIntl函数执行时,开始时间获取format为空,已返回null"); +// return null; +// } +// startDate = formateDateStr(startDateObj.toString(), format); +// } else { +// startDate = (Date) startDateObj; +// } +// } +// +// //结束日期 +// Object endObj = objects[1]; +// Object endDateObj = endObj != null ? DateUtil.getContent(endObj, formatter) : null; +// +// Date endDate = null; +// if (endDateObj != null) { +// +// if (endDateObj instanceof String || endDateObj instanceof Character) { +// format = DateUtil.buildFormat(endDateObj.toString()); +// if (null == format) { +// logger.error("workdayIntl函数执行时,结束时间获取format为空,已返回null"); +// return null; +// } +// endDate = formateDateStr(endDateObj.toString(), format); +// } else { +// endDate = (Date) endDateObj; +// } +// } +// +// //人员参数 +// Object employeeObj = objects[2]; +// String empIdStr = employeeObj != null ? ((DataType) employeeObj).getContent() + "" : null; +// +// DataCollectionEmployee currEmp = employeeObj != null ? ((DataType) employeeObj).getEmployee() : null; +// String tenantKey = currEmp != null ? currEmp.getTenantKey() : null; +// +// if (ExcelParamUtil.checkIsNull(startDate, endDate, empIdStr, ExcelParamUtil.CHECKLEVEL_STRING)) { +// throw new RuntimeException("NETWORKDAYSPI函数参数不能为空"); +// } +// +// if (StringUtils.isEmpty(tenantKey)) { +// logger.error("workdayIntl函数执行时,tenantKey,已返回null"); +// return null; +// } +// +// //结果是否取相反数 +// boolean isOpposite = false; +// Date begin = startDate; +// Date end = endDate; +// +// if (startDate.after(end)) { +// isOpposite = true; +// begin = endDate; +// end = startDate; +// } +// +// //结束时间临界值为昨天23:59:59 +// Date yesterdayEnd = new Date(); +// yesterdayEnd = DateUtils.addDays(yesterdayEnd, -1); +// yesterdayEnd = com.weaver.teams.util.DateUtils.setTimeToEndOfDay(yesterdayEnd); +// +// //最小时间大于昨天最后一刻,则计算结果为0 +// if (begin.after(yesterdayEnd)) { +// return new DataType(DataType.NUMBER, 0); +// } +// //最大日期大于昨天最后一刻,另结束时间等于昨天最后一刻 +// if (end.after(yesterdayEnd)) { +// end = yesterdayEnd; +// } +// +// //间隔天数 +// int workDays = 0; +// //是否购买了考勤模块 +// boolean attendPay = tenantHttpInvokerService.isPayModule(tenantKey, TenantModuleType.attend); +// +// if (attendPay) { +// //按考勤规则设置来 +// Long empId = Long.parseLong(empIdStr); +// Map> tempMap = null; +// +// try { +// WeaverSentinelContext.setDowngradeType(false); +// tempMap = remoteAttendService.queryDayType(Lists.newArrayList(empId), begin, end, tenantKey); +// } catch (Exception e) { +// if (WeaverDubboSentinelUtil.isRpcNoProviderException(e)) { +// //降级逻辑编写 +// logger.info("******workdayIntl的remoteAttendService.queryDayType走了weaver-common-excel-formula中的降级******"); +// return new DataType(DataType.NUMBER, 0); +// } else { +// logger.error("workdayIntl的remoteAttendService.queryDayType查询出错:" + e.getMessage()); +// } +// } +// +// if (MapUtils.isNotEmpty(tempMap)) { +// Map dayTypeMap = tempMap.get(empId); +// if (MapUtils.isEmpty(dayTypeMap)) { +// dayTypeMap = Maps.newHashMap(); +// } +// +// Date attendDate = null; +// AttendDayType dayType = null; +// int days = DateUtil.daysBetween(begin, end); +// +// //计算工作日天数 +// for (int i = 0; i <= days; i++) { +// attendDate = DateUtils.addDays(begin, i); +// String dayStr = DateFormatUtils.format(attendDate, "yyyy-MM-dd"); +// +// dayType = dayTypeMap.get(dayStr); +// if (dayType != null && dayType == AttendDayType.WORK) { +// workDays++; +// } +// } +// } +// } else { +// //按法定节假日算 +// List tempHolidays = Lists.newArrayList(); +// List holidays = null; +// +// try { +// WeaverSentinelContext.setDowngradeType(false); +// holidays = remoteAttend4FormService.queryDefaultHoliday(begin, end); +// } catch (Exception e) { +// if (WeaverDubboSentinelUtil.isRpcNoProviderException(e)) { +// //降级逻辑编写 +// logger.info("******workdayIntl的remoteAttend4FormService.queryDefaultHoliday走了weaver-common-excel-formula中的降级******"); +// return new DataType(DataType.NUMBER, 0); +// } else { +// logger.error("workdayIntl的remoteAttend4FormService.queryDefaultHoliday查询出错:" + e.getMessage()); +// } +// } +// +// if (CollectionUtils.isNotEmpty(holidays)) { +// for (Attend4FormDay tempDay : holidays) { +// String dayStr = DateFormatUtils.format(tempDay.getDay(), "yyyy-MM-dd"); +// tempHolidays.add(dayStr); +// } +// } +// +// Date attendDate = null; +// Calendar cal = Calendar.getInstance(); +// int days = DateUtil.daysBetween(begin, end); +// +// //计算工作日天数 +// for (int i = 0; i <= days; i++) { +// attendDate = DateUtils.addDays(begin, i); +// String dayStr = DateFormatUtils.format(attendDate, "yyyy-MM-dd"); +// +// //节假日 +// if (tempHolidays.contains(dayStr)) { +// continue; +// } +// +// //周末 +// cal.setTime(attendDate); +// if (cal.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY || cal.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) { +// continue; +// } +// +// //工作日 +// workDays++; +// } +// } +// if (isOpposite) { +// workDays = workDays * (-1); +// } +// +// logger.info("workdayIntl计算结果:" + workDays); +// return new DataType(DataType.NUMBER, workDays); +// +// } + + @Override + public DataType maxDate(Object... objects) { + Object dateObj = null; + Date date = null; + Date maxDate = null; + + //取最大日期 + for (int i = 0; i < objects.length; i++) { + dateObj = objects[i]; + if (dateObj == null) continue; + + //如果类型是DataType + if (dateObj instanceof DataType) { + DataType dataType = (DataType) dateObj; + dateObj = dataType.getContent(); + } + if (dateObj == null) continue; + + //字符串或Date强转 + if (dateObj instanceof String || dateObj instanceof Character) { + String format = DateUtil.buildFormat(dateObj.toString()); + if (StringUtils.isNotEmpty(format)) date = formateDateStr(dateObj.toString(), format); + } else { + date = (Date) dateObj; + } + + if (date != null && (maxDate == null || date.after(maxDate))) maxDate = date; + } + + //日期格式化 + String rtnStr = maxDate != null ? DateFormatUtils.format(maxDate, "yyyy-MM-dd") : ""; + return new DataType(DataType.STRING, rtnStr); + } + + @Override + public DataType minDate(Object... objects) { + Object dateObj = null; + Date date = null; + Date minDate = null; + + //取最小日期 + for (int i = 0; i < objects.length; i++) { + dateObj = objects[i]; + if (dateObj == null) continue; + + //如果类型是DataType + if (dateObj instanceof DataType) { + DataType dataType = (DataType) dateObj; + dateObj = dataType.getContent(); + } + if (dateObj == null) continue; + + if (dateObj instanceof String || dateObj instanceof Character) { + String format = DateUtil.buildFormat(dateObj.toString()); + if (StringUtils.isNotEmpty(format)) date = formateDateStr(dateObj.toString(), format); + } else { + date = (Date) dateObj; + } + + if (date != null && (minDate == null || date.before(minDate))) minDate = date; + } + + //日期格式化 + String rtnStr = minDate != null ? DateFormatUtils.format(minDate, "yyyy-MM-dd") : ""; + return new DataType(DataType.STRING, rtnStr); + } + + @Override + public DataType compareDate(Object... objects) { + Date first = null; + Date second = null; + Object paramObj = objects[0]; + Object paramObjSecond = objects[1]; + if (paramObj instanceof DataType) { + DataType dataType = (DataType) paramObj; + if (dataType.getContent() != null && StringUtils.isNotEmpty(dataType.getContent() + "")) { + boolean isDate = DateUtil.isDateComponent(paramObj); + if (isDate) { + first = DateUtil.buildDateByDateChar(dataType.getContent() + ""); + } + } + } else { + first = DateUtil.buildDateByDateChar(paramObj + ""); + } + + if (paramObjSecond instanceof DataType) { + DataType dataType = (DataType) paramObjSecond; + if (dataType.getContent() != null && StringUtils.isNotEmpty(dataType.getContent() + "")) { + boolean isDate = DateUtil.isDateComponent(paramObjSecond); + if (isDate) { + second = DateUtil.buildDateByDateChar(dataType.getContent() + ""); + } + } + } else { + second = DateUtil.buildDateByDateChar(paramObjSecond + ""); + } + + if (first == null || second == null) { + return new DataType(DataType.BOOL, false); + } + + if (first.getTime() - second.getTime() != 0) { + return new DataType(DataType.BOOL, false); + } else { + return new DataType(DataType.BOOL, true); + } + } + + @Override + public DataType currYear(Object... objects) { + Calendar cal = Calendar.getInstance(); + cal.setTime(new Date()); + int year = cal.get(Calendar.YEAR); + return new DataType(DataType.NUMBER, year); + } + + @Override + public DataType currMonth(Object... objects) { + Calendar cal = Calendar.getInstance(); + cal.setTime(new Date()); + int year = cal.get(Calendar.MONTH) + 1; + return new DataType(DataType.NUMBER, year); + } + + @Override + public DataType currDay(Object... objects) { + Calendar cal = Calendar.getInstance(); + cal.setTime(new Date()); + int year = cal.get(Calendar.DAY_OF_MONTH); + return new DataType(DataType.NUMBER, year); + } + + @Override + public DataType currWeek(Object... objects) { + int weekDay = 0; + try { + weekDay = getDateTimeValue(new Date(), "DW", "WEEKDAY"); + } catch (ParseException e) { + logger.error("err", e); + throw new RuntimeException(e); + } + return new DataType(DataType.NUMBER, weekDay > 0 ? (weekDay - 1) : weekDay); + } + + @Override + public DataType currHour(Object... objects) { + Calendar cal = Calendar.getInstance(); + cal.setTime(new Date()); + int year = cal.get(Calendar.HOUR_OF_DAY); + return new DataType(DataType.NUMBER, year); + } + + @Override + public DataType currMinute(Object... objects) { + Calendar cal = Calendar.getInstance(); + cal.setTime(new Date()); + int year = cal.get(Calendar.MINUTE); + return new DataType(DataType.NUMBER, year); + } + + @Override + public DataType currSecond(Object... objects) { + Calendar cal = Calendar.getInstance(); + cal.setTime(new Date()); + int year = cal.get(Calendar.SECOND); + return new DataType(DataType.NUMBER, year); + } + + @Override + public DataType daysInMonth(Object... objects) { + Class[] typeObjects = new Class[]{DateAndString.class}; + IgnoreParamFilter.commonFilter("YEAR", 1, 1, typeObjects, objects); + Object obj = objects[0]; + Object date = DateUtil.getContent(obj, formatter); + if (ExcelParamUtil.checkIsNull(date, ExcelParamUtil.CHECKLEVEL_STRING)) { + return new DataType(DataType.NUMBER, 0); + } + int year = 0; + try { + year = getDateTimeValue(date, "Y", "YEAR"); + } catch (ParseException e) { + logger.error("err", e); + throw new RuntimeException(e); + } + + IgnoreParamFilter.commonFilter("MONTH", 1, 1, typeObjects, objects); + int month = 0; + try { + month = getDateTimeValue(date, "M", "MONTH") + 1; + } catch (ParseException e) { + logger.error("err", e); + throw new RuntimeException(e); + } + + YearMonth yearMonth = YearMonth.of(year, month); + int daysInMonth = yearMonth.lengthOfMonth(); + return new DataType(DataType.NUMBER, daysInMonth); + } + /*******以下为日期函数的一些公共逻辑********/ + + + /** + * 获取日期时间的单位值,指定类型为Type,默认为 'D' 天数 + * + * @param date + * @param type + * @return + * @throws ParseException + */ + public Integer getDateTimeValue(Object date, String type, String func) throws ParseException { + int result = 0; + try { + boolean isTime = false; + Date fDate = null; + if (date instanceof String) { + boolean isDate = checkDateString(date != null ? date.toString() : ""); + if (!isDate) { + return 0; + } + format = DateUtil.buildFormat(date.toString(), type); + if (format == null) { + format = DateUtil.buildFormat(date.toString()); + } + fDate = formateDateStr(date.toString(), format); + if (date.toString().indexOf(":") > 0 && date.toString().indexOf("-") < 0) { + isTime = true; + if (!type.equals("H") && !type.equals("I") && !type.equals("S")) { + Integer number = IgnoreParamFilter.getSetFuncNumber(func); + JSONObject errorJson = ErrorUtil.buildError(func, number, number, func + "函数参数错误"); + throw new RuntimeException(errorJson.getString("msg")); + } + } + } else { + fDate = (Date) date; + } + + int calendarType = 0; + switch (type) { + case "Y": + calendarType = Calendar.YEAR; + break; + case "M": + calendarType = Calendar.MONTH; + break; + case "D": + calendarType = Calendar.DAY_OF_MONTH; + break; + case "H": + if (isTime) { + return Integer.parseInt(date.toString().split(":")[0]); + } + calendarType = Calendar.HOUR_OF_DAY; + break; + case "I": + if (isTime) { + return Integer.parseInt(date.toString().split(":")[1]); + } + calendarType = Calendar.MINUTE; + break; + case "S": + if (isTime) { + return Integer.parseInt(date.toString().split(":")[2]); + } + calendarType = Calendar.SECOND; + break; + case "WM": + calendarType = Calendar.WEEK_OF_YEAR; + long startTime1 = fDate.getTime(); + Calendar calendar = Calendar.getInstance(); + calendar.setFirstDayOfWeek(Calendar.SUNDAY);//设置星期一为一周开始的第一天 + calendar.setMinimalDaysInFirstWeek(4);//可以不用设置 + calendar.setTimeInMillis(startTime1);//获得当前的时间戳 + int weekOfYear = calendar.get(calendarType);//获得当前日期属于今年的第几周 + result = weekOfYear; + logger.info("当前是第" + result + "周"); + return result; + case "DW": + calendarType = Calendar.DAY_OF_WEEK; + break; + default: + calendarType = Calendar.HOUR_OF_DAY; + break; + } + calendar.setTime(fDate); + result = calendar.get(calendarType); + } catch (RuntimeException e) { + logger.error("err", e); + result = 0; + } + return result; + } + + /** + * 格式化日期时间 + * + * @param dateStr 日期时间原字符串 + * @param format 格式 + * @return + * @throws ParseException + */ + private Date formateDateStr(String dateStr, String format) { + SimpleDateFormat sdf = new SimpleDateFormat(format); + Date ndate = null; + try { + ndate = sdf.parse(dateStr); + } catch (ParseException e) { + logger.error("err", e); + throw new RuntimeException(e); + } + return ndate; + } + + /** + * 格式日期时间为字符串 + * + * @param date + * @param format + * @return + * @throws ParseException + */ + private String formateDateStr(Date date, String format) throws ParseException { + SimpleDateFormat sdf = new SimpleDateFormat(format); + String ndate = sdf.format(date); + return ndate; + } + + + /** + * 判断时间间距的单位类型 + * + * @param type + * @return + */ + private Long buildSecondsFmt(String type) { + Long secondsL = null; + switch (type) { + case "Y": + secondsL = (long) (365 * 24 * 60 * 60 * 1000); + break; + case "M": + secondsL = (long) (30 * 24 * 60 * 60 * 1000); + break; + case "D": + secondsL = (long) (24 * 60 * 60 * 1000); + break; + case "H": + secondsL = (long) (60 * 60 * 1000); + break; + case "I": + secondsL = (long) (60 * 1000); + break; + case "S": + secondsL = 1000L; + break; + default: + secondsL = (long) (60 * 60 * 1000); + break; + } + return secondsL; + } + + static Calendar calendar2 = Calendar.getInstance(); + public static SimpleDateFormat formatter2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + static String format2 = "yyyy-MM-dd HH:mm:ss"; + + + public static Integer getDateTimeValue2(Object date, String type, String func) throws ParseException { + int result = 0; + boolean isTime = false; + Date fDate = null; + if (date instanceof String) { + format2 = DateUtil.buildFormat(date.toString()); + fDate = formateDateStr2(date.toString(), format2); + if (date.toString().indexOf(":") > 0 && !date.toString().contains("-")) { + isTime = true; + if (!type.equals("H") && !type.equals("I") && !type.equals("S")) { + Integer number = IgnoreParamFilter.getSetFuncNumber(func); + JSONObject errorJson = ErrorUtil.buildError(func, number, number, func + "函数参数错误"); + throw new RuntimeException(errorJson.getString("msg")); + } + } + } else { + fDate = (Date) date; + } + + int calendarType = 0; + switch (type) { + case "Y": + calendarType = Calendar.YEAR; + break; + case "M": + calendarType = Calendar.MONTH; + break; + case "D": + calendarType = Calendar.DAY_OF_MONTH; + break; + case "H": + if (isTime) { + return Integer.parseInt(date.toString().split(":")[0]); + } + calendarType = Calendar.HOUR_OF_DAY; + break; + case "I": + if (isTime) { + return Integer.parseInt(date.toString().split(":")[1]); + } + calendarType = Calendar.MINUTE; + break; + case "S": + if (isTime) { + return Integer.parseInt(date.toString().split(":")[2]); + } + calendarType = Calendar.SECOND; + break; + case "WM": + calendarType = Calendar.WEEK_OF_MONTH; + break; + case "DW": + calendarType = Calendar.DAY_OF_WEEK; + break; + default: + calendarType = Calendar.HOUR_OF_DAY; + break; + } + calendar2.setTime(fDate); + result = calendar2.get(calendarType); + return result; + } + + private static Date formateDateStr2(String dateStr, String format) throws ParseException { + SimpleDateFormat sdf = new SimpleDateFormat(format); + Date ndate = null; + ndate = sdf.parse(dateStr); + return ndate; + } + + private boolean checkDateString(String dateString) { + List datafList = new ArrayList(); + datafList.add("yyyyMMddHHmmss"); + datafList.add("yyyyMMdd"); + datafList.add("yyyyMMddHHmm"); + datafList.add("HH:mm"); + datafList.add("HH:mm:ss"); + if (RegularUtil.isNumber(dateString)) { + return false; + } + boolean r = false; + for (String s : datafList) { + SimpleDateFormat sdf = new SimpleDateFormat(s); + + Date ndate = null; + try { + ndate = sdf.parse(dateString); + r = true; + break; + } catch (ParseException e) { + logger.error(e.getMessage()); + r = false; + } + } + if (r) { + if (RegularUtil.isNumber(dateString)) { + r = false; + } + } + return r; + } + + + public static double getBetween(String beginTime, String endTime, String returnPattern) throws ParseException { + + String format = DateUtil.buildFormat(beginTime); + SimpleDateFormat sdf = new SimpleDateFormat(format); + Date beginDate = sdf.parse(beginTime); + + format = DateUtil.buildFormat(endTime); + sdf = new SimpleDateFormat(format); + Date endDate = sdf.parse(endTime); + + Calendar beginCalendar = Calendar.getInstance(); + Calendar endCalendar = Calendar.getInstance(); + beginCalendar.setTime(beginDate); + endCalendar.setTime(endDate); + + double resutl; + switch (returnPattern) { + case "Y": + resutl = DateTimeServiceImpl.getTime(beginDate, endDate) / (24 * 60 * 60 * 1000) / 365.0; + break; + case "M": + resutl = DateTimeServiceImpl.getByField(beginCalendar, endCalendar, Calendar.YEAR) * 12 + DateTimeServiceImpl.getByField(beginCalendar, endCalendar, Calendar.MONTH); + break; + case "D": + resutl = DateTimeServiceImpl.getTime(beginDate, endDate) / (24 * 60 * 60 * 1000); + break; + case "H": + Long nd = new Long(60 * 60 * 1000); + resutl = DateTimeServiceImpl.getTime(beginDate, endDate) / (nd.doubleValue()); + break; + case "I": + resutl = DateTimeServiceImpl.getTime(beginDate, endDate) / (60 * 1000); + break; + case "S": + resutl = DateTimeServiceImpl.getTime(beginDate, endDate) / 1000; + break; + default: + resutl = 0L; + break; + } + return resutl; + } + + + private static Long getByField(Calendar beginCalendar, Calendar endCalendar, int calendarField) { + int r = endCalendar.get(calendarField) - beginCalendar.get(calendarField); + return (long) r; + } + + private static long getTime(Date beginDate, Date endDate) { + return endDate.getTime() - beginDate.getTime(); + } + +// public static void main(String[] args) { +// try { +// logger.info(DateTimeServiceImpl.getBetween("2017-05-02 22:00:00", "2016-10-02 23:15:00", "Y")); +// } catch (ParseException e) { +// logger.error("err",e); +// } +// +// } +} diff --git a/src/com/engine/salary/formlua/func/finance/FinanceService.java b/src/com/engine/salary/formlua/func/finance/FinanceService.java new file mode 100644 index 000000000..29861d790 --- /dev/null +++ b/src/com/engine/salary/formlua/func/finance/FinanceService.java @@ -0,0 +1,15 @@ +package com.engine.salary.formlua.func.finance; + +import com.engine.salary.formlua.entity.parameter.DataType; + +/** + * 财务函数分类 + */ +public interface FinanceService { + /** + * 金额转换 + * @param objects + * @return + */ + public DataType getMoney(Object... objects); +} diff --git a/src/com/engine/salary/formlua/func/finance/FinanceServiceImpl.java b/src/com/engine/salary/formlua/func/finance/FinanceServiceImpl.java new file mode 100644 index 000000000..e3b4f1d24 --- /dev/null +++ b/src/com/engine/salary/formlua/func/finance/FinanceServiceImpl.java @@ -0,0 +1,118 @@ +package com.engine.salary.formlua.func.finance; + +import com.engine.salary.formlua.entity.parameter.DataType; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.math.BigDecimal; +public class FinanceServiceImpl implements FinanceService{ + protected final Logger logger = LoggerFactory.getLogger(this.getClass()); + @Override + public DataType getMoney(Object... objects) { + DataType moneyDataType=new DataType(); + moneyDataType.setDataType(DataType.STRING); + moneyDataType.setContent(""); + if(objects!=null && objects.length>0){ + String money=null; + if(objects[0] instanceof DataType){ + DataType dataType=(DataType)objects[0]; + money=dataType.getContent()==null?null:dataType.getContent().toString(); + }else{ + if(objects[0]!=null){ + money=objects[0].toString(); + } + } + moneyDataType=convertCurrency(money); + } + return moneyDataType; + } + public DataType convertCurrency(String param) { + // 汉字的数字 + String[] cnNums = new String[]{"零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖"}; + // 基本单位 + String[] cnIntRadice = new String[]{"", "拾", "佰", "仟"}; + // 对应整数部分扩展单位 + String[] cnIntUnits = new String[]{"", "万", "亿", "兆"}; + // 对应小数部分单位 + String[] cnDecUnits = new String[]{"角", "分", "毫", "厘"}; + // 整数金额时后面跟的字符 + String cnInteger = "整"; + // 整型完以后的单位 + String cnIntLast = "元"; + // 最大处理的数字 + BigDecimal maxNum = new BigDecimal(999999999999999.9999); + // 金额整数部分 + String integerNum; + // 金额小数部分 + String decimalNum; + // 输出的中文金额字符串 + String chineseStr = ""; + // 分离金额后用的数组,预定义 + String[] parts; + BigDecimal money=null; + if (param == null || param.equalsIgnoreCase("")) { + return new DataType(DataType.STRING,""); + } + money = new BigDecimal(param); + if (money.compareTo(maxNum)==0) { + // 超出最大处理数字 + return new DataType(DataType.STRING,""); + } + if (money.intValue() == 0) { + chineseStr = cnNums[0] + cnIntLast + cnInteger; + return new DataType(DataType.STRING,chineseStr); + } + // 转换为字符串 + //如果是整数 + if (param.indexOf('.') == -1) { + integerNum = money.intValue()+""; + decimalNum = ""; + //如果存在小数 + } else { + parts = param.split("\\."); + integerNum = parts[0]; + decimalNum = parts[1]; + } + // 获取整型部分转换 + if (integerNum.length() > 0) { + int zeroCount = 0; + int intLen = integerNum.length(); + for (int i = 0; i < intLen; i++) { + String n = integerNum.substring(i, i+1); + int p = intLen - i - 1; + int q = p / 4; + int m = p % 4; + if (n.equals("0")) { + zeroCount++; + } else { + if (zeroCount > 0) { + chineseStr += cnNums[0]; + } + // 归零 + zeroCount = 0; + chineseStr += cnNums[Integer.parseInt(n)] + cnIntRadice[m]; + } + if (m == 0 && zeroCount < 4) { + chineseStr += cnIntUnits[q]; + } + } + chineseStr += cnIntLast; + } + // 小数部分 + if (!decimalNum.equals("")) { + int decLen = decimalNum.length(); + for (int i = 0; i < decLen; i++) { + String n = decimalNum.substring(i, i+1); + if (!n.equals("0")) { + chineseStr += cnNums[Integer.parseInt(n)] + cnDecUnits[i]; + } + } + } + if (chineseStr.equals("")) { + chineseStr += cnNums[0] + cnIntLast + cnInteger; + } else if (decimalNum.equals("")) { + chineseStr += cnInteger; + } + return new DataType(DataType.STRING,chineseStr); + } +} diff --git a/src/com/engine/salary/formlua/func/find/FindFuncsService.java b/src/com/engine/salary/formlua/func/find/FindFuncsService.java new file mode 100644 index 000000000..65bdcba0e --- /dev/null +++ b/src/com/engine/salary/formlua/func/find/FindFuncsService.java @@ -0,0 +1,31 @@ +package com.engine.salary.formlua.func.find; + + +import com.engine.salary.formlua.entity.parameter.DataType; + +/** + * 查找函数 + */ +public interface FindFuncsService { + Object chooseOne(Object... objects); + /** + * choose函数 + * @param objs + * @return + */ + Object choose(Object... objs); + + /** + * match函数 + * @param objs + * @return + */ + DataType match(Object... objs); + + /** + * vlookups函数 + * @param objs + * @return + */ + Object vlookups(Object... objs); +} diff --git a/src/com/engine/salary/formlua/func/find/FindFuncsServiceImpl.java b/src/com/engine/salary/formlua/func/find/FindFuncsServiceImpl.java new file mode 100644 index 000000000..8cc816f77 --- /dev/null +++ b/src/com/engine/salary/formlua/func/find/FindFuncsServiceImpl.java @@ -0,0 +1,188 @@ +//package com.engine.salary.formlua.func.find; +// +//import com.alibaba.fastjson.JSON; +//import com.alibaba.fastjson.JSONObject; +//import com.engine.salary.entity.datacollection.DataCollectionEmployee; +//import com.engine.salary.formlua.entity.parameter.DataType; +//import com.engine.salary.formlua.entity.parameter.FuncNames; +//import com.engine.salary.formlua.entity.standard.FormulaFilterData; +//import com.engine.salary.formlua.util.ErrorUtil; +//import com.engine.salary.formlua.util.ExcelParamUtil; +//import com.engine.salary.formlua.util.IgnoreParamFilter; +//import com.weaver.excel.formula.core.rpc.RpcMethod; +//import org.apache.commons.beanutils.BeanUtils; +//import org.apache.commons.compress.utils.Lists; +//import org.apache.commons.lang.ArrayUtils; +//import org.apache.commons.lang.StringUtils; +//import org.slf4j.Logger; +//import org.slf4j.LoggerFactory; +// +//import java.lang.reflect.Array; +//import java.lang.reflect.InvocationTargetException; +//import java.util.List; +//import java.util.Map; +// +//public class FindFuncsServiceImpl implements FindFuncsService{ +// protected final Logger logger = LoggerFactory.getLogger(this.getClass()); +// private ExcelDubboInvoker excelDubboInvoker; +// +// @Override +// public Object chooseOne(Object... objects) { +// DataType chooseResult=new DataType(); +// if(objects != null && objects.length>=2){ +// List dataList= ExcelParamUtil.getParamContent(objects); +// Object firstData=dataList.get(0); +// for (int i=1;i filterDatas = conditionObj != null ? conditionObj.getFormulaFilterDataList(): Lists.newArrayList(); +// DataCollectionEmployee user = formObj.getEmployee(); +// +// Object[] params = {formId, filterDatas, user}; +// return excelDubboInvoker.invokeCommonDubbo(DataType.class,formObj.getModule()+"", RpcMethod.choose, params); +// } +// +// @Override +// public DataType match(Object... objects) { +// //参数校验 +// String func = FuncNames.MATCH.toString(); +// IgnoreParamFilter.commonFilter(func,2,2, null, objects); +// +// Object valueObj = objects[0]; +// Object[] arrayObj = null; +// +// //将第二个参数转数组 +// try{ +// arrayObj = (Object[]) objects[1]; +// }catch (Exception e){ +// Integer number = IgnoreParamFilter.getSetFuncNumber(func); +// JSONObject errorJson = ErrorUtil.buildError(func,number,number,func+"函数第二个参数必须是数组类型"); +// throw new RuntimeException(errorJson.getString("msg")); +// } +// +// //所在下标 +// int index = ArrayUtils.indexOf(arrayObj, valueObj); +// return new DataType(DataType.NUMBER, index); +// } +// +// @Override +// public Object vlookups(Object... objects) { +// //参数校验 +// String func = FuncNames.VLOOKUPS.toString(); +// IgnoreParamFilter.commonFilter(func,3,3, null, objects); +// +// DataType formObj = (DataType)objects[0]; +// DataType conditionObj = objects[1] != null ? (DataType)objects[1] : null; +// //拿出返回数据 +// Object returnObjs=objects[2]; +// //初始化数组 +// DataType[] rtnCols = null; +// //判断是否是数组 +// if(returnObjs!=null && returnObjs.getClass().isArray()){ +// logger.info("执行器查找函数返回数据为DataType数组"+JSON.toJSONString(returnObjs)); +// //获取数组长度 +// int len= Array.getLength(returnObjs); +// rtnCols=new DataType[len]; +// //遍历并转换数据后放入rtnCols +// for(int i=0;i fieldIds = Lists.newArrayList(); +// if(!ArrayUtils.isEmpty(rtnCols)){ +// for (DataType item : rtnCols) { +// if(item != null && StringUtils.isNotEmpty(item.getFieldId())) fieldIds.add(item.getFieldId()); +// } +// } +// +// Long formId = formObj.getFormId(); +// List filterDatas = conditionObj != null ? conditionObj.getFormulaFilterDataList() : Lists.newArrayList(); +// DataCollectionEmployee user = formObj.getEmployee(); +// +// Object[] params = {formId+"", filterDatas, fieldIds, null,user}; +// +// DataType[] dataTypes=new DataType[1]; +// Object dubboResult=excelDubboInvoker.invokeCommonDubbo(List.class,formObj.getModule()+"", RpcMethod.vlookups, params); +// logger.info("返回结果:"+JSON.toJSONString(dubboResult)); +// +// if(dubboResult!=null && dubboResult instanceof List){ +// try { +// List resultObjectList=(List)dubboResult; +// dataTypes=new DataType[resultObjectList.size()]; +// for(int i =0;i classa=Class.forName(map.get("class").toString()) ; +// Object typeObject=classa.newInstance(); +// BeanUtils.populate(typeObject,map); +// if(typeObject instanceof DataType){ +// dataTypes[i]=(DataType) typeObject; +// } +// }else if(resultParam instanceof DataType){ +// dataTypes[i]=(DataType) resultParam; +// }else{ +// logger.info("Dubbo接口返回异常数据类型:"+resultParam.getClass().getName()); +// } +// } +// } catch (ClassNotFoundException e) { +// e.printStackTrace(); +// } catch (InstantiationException e) { +// e.printStackTrace(); +// } catch (IllegalAccessException e) { +// e.printStackTrace(); +// } catch (InvocationTargetException e) { +// e.printStackTrace(); +// }catch (Exception e){ +// e.printStackTrace(); +// } +// }else{ +// DataType nomalData=new DataType(DataType.NUMBER, 0); +// dataTypes[0]=nomalData; +// } +// return dataTypes.length==1?dataTypes[0]:dataTypes; +// } +//} diff --git a/src/com/engine/salary/formlua/func/logic/IfOperator.java b/src/com/engine/salary/formlua/func/logic/IfOperator.java new file mode 100644 index 000000000..b826836fb --- /dev/null +++ b/src/com/engine/salary/formlua/func/logic/IfOperator.java @@ -0,0 +1,96 @@ +package com.engine.salary.formlua.func.logic; + +import com.alibaba.fastjson.JSONObject; +import com.engine.salary.formlua.core.exception.ExcelRunTimeException; +import com.engine.salary.formlua.entity.parameter.DataType; +import com.engine.salary.formlua.util.ErrorUtil; +import com.engine.salary.formlua.util.ExcelParamUtil; +import com.engine.salary.formlua.util.IgnoreParamFilter; +import com.ql.util.express.ArraySwap; +import com.ql.util.express.InstructionSetContext; +import com.ql.util.express.OperateData; +import com.ql.util.express.instruction.op.OperatorIf; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +public class IfOperator extends OperatorIf { + protected final Logger logger = LoggerFactory.getLogger(this.getClass()); + + @Override + public OperateData executeInner(InstructionSetContext parent, ArraySwap list) throws Exception { + Integer number = IgnoreParamFilter.getSetFuncNumber("IF"); + if (list == null || list.length != 3) { + JSONObject errorJson = ErrorUtil.buildError("IF", number, number, "IF函数只允许三个参数"); + throw new ExcelRunTimeException("IF函数只允许三个参数"); + } + Object obj = list.get(0).getObject(parent); + boolean isDataTypeBool = false; + DataType boolDtaType = null; + if (obj != null && obj instanceof DataType) { + boolDtaType = (DataType) obj; + if (boolDtaType.getContent() != null && (boolDtaType.getContent() instanceof Boolean)) { + isDataTypeBool = true; + obj = boolDtaType.getContent(); + } else { + switch (obj + "") { + case "true": + obj = true; + isDataTypeBool = true; + break; + case "false": + obj = false; + isDataTypeBool = true; + break; + default: + isDataTypeBool = false; + break; + } + } + } else if (obj instanceof Boolean) { + isDataTypeBool = true; + } + if (obj == null) { + JSONObject errorJson = ErrorUtil.buildError("IF", number, number, "IF函数参数不能为空"); + throw new RuntimeException(errorJson.getString("msg")); + } else if (!(obj instanceof Boolean) && (!(obj instanceof DataType))) { + JSONObject errorJson = ErrorUtil.buildError("IF", number, number, "IF函数判断条件必须是真假值"); + throw new RuntimeException(errorJson.getString("msg")); + } else if (!isDataTypeBool) { + JSONObject errorJson = ErrorUtil.buildError("IF", number, number, "IF函数判断条件必须是真假值"); + throw new RuntimeException(errorJson.getString("msg")); + } else { + if (((Boolean) obj).booleanValue() == true) { + OperateData operateData = list.get(1); + Object object = operateData.getObject(parent); +// if(object instanceof DataType){ +// String type= ExcelParamUtil.getParamType(object); +// if(type.equalsIgnoreCase("date")){ +// object=ExcelParamUtil.getParamContent(object,"string"); +// } +// } + OperateData operateData1 = new OperateData(ExcelParamUtil.getParamContent(object, ""), operateData.getType(parent)); + return operateData1; + } else { + OperateData operateData = list.get(2); + Object object = operateData.getObject(parent); +// if(object instanceof DataType){ +// String type=ExcelParamUtil.getParamType(object); +// if(type.equalsIgnoreCase("date")){ +// object=ExcelParamUtil.getParamContent(object,"string"); +// } +// } + OperateData operateData1 = new OperateData(ExcelParamUtil.getParamContent(object, ""), operateData.getType(parent)); + return operateData1; + } + } + } + + public IfOperator(String aName) { + super(aName); + } + + public IfOperator(String aAliasName, String aName, String aErrorInfo) { + super(aAliasName, aName, aErrorInfo); + } +} diff --git a/src/com/engine/salary/formlua/func/logic/LogicService.java b/src/com/engine/salary/formlua/func/logic/LogicService.java new file mode 100644 index 000000000..94d0ea106 --- /dev/null +++ b/src/com/engine/salary/formlua/func/logic/LogicService.java @@ -0,0 +1,26 @@ +package com.engine.salary.formlua.func.logic; + +import com.engine.salary.formlua.entity.parameter.DataType; + + +public interface LogicService { + public Boolean not(Object... object); + + public Boolean isEmpty(Object... objs); + + public Boolean isTrue(Object... objs); + + public Boolean isFalse(Object... objs); + + public DataType and(Object... objs); + + public DataType or(Object... objs); + + public DataType likeFunc(Object... objects); + + public DataType ifs(Object... objects); + + public DataType find(Object... objects); + + public DataType switchs(Object... objects); +} diff --git a/src/com/engine/salary/formlua/func/logic/LogicServiceImpl.java b/src/com/engine/salary/formlua/func/logic/LogicServiceImpl.java new file mode 100644 index 000000000..f550fd861 --- /dev/null +++ b/src/com/engine/salary/formlua/func/logic/LogicServiceImpl.java @@ -0,0 +1,496 @@ +package com.engine.salary.formlua.func.logic; + +import com.alibaba.fastjson.JSONObject; +import com.engine.salary.formlua.entity.parameter.DataType; +import com.engine.salary.formlua.entity.parameter.FuncNames; +import com.engine.salary.formlua.util.ErrorUtil; +import com.engine.salary.formlua.util.ExcelParamUtil; +import com.engine.salary.formlua.util.IgnoreParamFilter; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Objects; + +/** + * @className: + * @Description:Excel逻辑函数 + * @Author: + * @date: + */ +public class LogicServiceImpl implements LogicService { + protected final Logger logger = LoggerFactory.getLogger(this.getClass()); + + @Override + public Boolean not(Object... objects) { + DataType resultdataType = new DataType(); + resultdataType.setDataType(DataType.BOOL); + Class[] typeObjects = new Class[]{boolean.class}; + IgnoreParamFilter.commonFilter("NOT", 1, 1, typeObjects, objects); + Object object = objects[0]; + if (object == null) { + resultdataType.setContent(false); + return false; + } + Boolean cnd; + if (object instanceof DataType) { + DataType dataType = (DataType) object; + cnd = dataType.getContent() != null ? ((Boolean) dataType.getContent()) : false; + } else { + cnd = (boolean) object; + } + + resultdataType.setContent(!cnd); + return (Boolean) resultdataType.getContent(); + } + + @Override + public Boolean isEmpty(Object... objs) { + int number = IgnoreParamFilter.getSetFuncNumber(FuncNames.ISEMPTY.toString()); + if (objs.length != 1) { + throw new RuntimeException("ISEMPTY函数只允许一个参数"); + } + boolean result = false; + if (null == objs || objs.length == 0) { + DataType dataType = new DataType(); + dataType.setDataType(DataType.BOOL); + dataType.setContent(true); + return true; + } + for (int i = 0; i < objs.length; i++) { + Object obj = objs[i]; + if (obj == null) { + DataType dataType = new DataType(); + dataType.setDataType(DataType.BOOL); + dataType.setContent(true); + return true; + } + if (obj instanceof DataType) { + DataType objDataType = (DataType) obj; + if (objDataType.getDataType().equalsIgnoreCase(DataType.NUMBER)) { + Object numberContent = objDataType.getContent(); + if (numberContent == null || numberContent.toString().equalsIgnoreCase("")) { + result = true; + break; + } + } + } + obj = ExcelParamUtil.getParamContent(obj, ""); + if (null == obj || null == ExcelParamUtil.getParamContent(obj, "") || ExcelParamUtil.getParamContent(obj, "").equals("")) { + result = true; + break; + } + } + DataType dataType = new DataType(); + dataType.setDataType(DataType.BOOL); + dataType.setContent(result); + return result; + } + + @Override + public Boolean isTrue(Object... objects) { + int number = IgnoreParamFilter.getSetFuncNumber(FuncNames.TRUE.toString()); + if (objects.length > 0) { + throw new RuntimeException("TRUE函数不能有参数"); + } + DataType dataType = new DataType(); + dataType.setDataType(DataType.BOOL); + dataType.setContent(true); + return (Boolean) dataType.getContent(); + } + + @Override + public Boolean isFalse(Object... objects) { + int number = IgnoreParamFilter.getSetFuncNumber(FuncNames.FALSE.toString()); + if (objects.length > 0) { + JSONObject errorJson = ErrorUtil.buildError(FuncNames.FALSE.toString(), number, number, "FALSE函数不能有参数"); + throw new RuntimeException(errorJson.getString("msg")); + } + DataType dataType = new DataType(); + dataType.setDataType(DataType.BOOL); + dataType.setContent(false); + return (Boolean) dataType.getContent(); + } + + + @Override + public DataType and(Object... objs) { + IgnoreParamFilter.filterLogicAndORFunc(objs, "AND"); + Object result; + int trueCount = 0; + int falseCount = 0; + DataType dataType = new DataType(); + for (int i = 0; i < objs.length; i++) { + boolean bool; + if (objs[i] instanceof DataType) { + DataType paramdataType = (DataType) objs[i]; + bool = paramdataType.getContent() != null ? ((Boolean) paramdataType.getContent()) : false; + //如果参数存在底层Logic运算,把运算记录加入到当前AND函数的运算记录中 + if (paramdataType.getSubLogic() != null && paramdataType.getSubLogic().size() > 0) { + dataType.getSubLogic().addAll(paramdataType.getSubLogic()); + } + } else { + bool = (boolean) objs[i]; + } + + if (bool) { + trueCount++; + } else { + falseCount++; + } + } + if (trueCount == objs.length) { + result = true; + } else { + result = false; + } + + dataType.setDataType(DataType.BOOL); + dataType.setContent(result); + dataType.getSubLogic().add("and"); + + LogicUtils.buildAndOrFilterParam("AND", dataType, objs); + return dataType; + } + + @Override + public DataType or(Object... objs) { + IgnoreParamFilter.filterLogicAndORFunc(objs, "OR"); + Object result; + int trueCount = 0; + int falseCount = 0; + DataType dataType = new DataType(); + for (int i = 0; i < objs.length; i++) { + boolean bool; + if (objs[i] instanceof DataType) { + DataType paramdataType = (DataType) objs[i]; + bool = paramdataType.getContent() != null ? ((Boolean) paramdataType.getContent()) : false; + //如果参数存在底层Logic运算,把运算记录加入到当前AND函数的运算记录中 + if (paramdataType.getSubLogic() != null && paramdataType.getSubLogic().size() > 0) { + dataType.getSubLogic().addAll(paramdataType.getSubLogic()); + } + } else { + bool = (boolean) objs[i]; + } + if (bool) { + trueCount++; + } else { + falseCount++; + } + } + if (trueCount > 0) { + result = true; + } else { + result = false; + } + + dataType.setDataType(DataType.BOOL); + dataType.setContent(result); + dataType.getSubLogic().add("or"); + LogicUtils.buildAndOrFilterParam("OR", dataType, objs); + return dataType; + } + + + @Override + public DataType likeFunc(Object... objects) { + IgnoreParamFilter.filterLikeFunc(objects); + Object object = objects[0]; + Object result = false; + String txtS = ""; + if (object instanceof DataType) { + txtS = ExcelParamUtil.getParamContent(object, "string").toString(); + } else { + txtS = object.toString(); + } + if (null == txtS || txtS.trim().equals("")) { + return new DataType(DataType.BOOL, false); + } + Object[] partamArray = (Object[]) objects[1]; + for (int i = 0; i < partamArray.length; i++) { + Object cnd = partamArray[i]; + String cndStr = ""; + if (cnd instanceof DataType) { + DataType cndJson = (DataType) cnd; + cndStr = ExcelParamUtil.getParamContent(cndJson, "string").toString(); + } else { + cndStr = cnd.toString(); + } + + int ridx = txtS.indexOf(cndStr); + if (ridx >= 0 ? true : false) { + result = ridx >= 0 ? true : false; + break; + } + + + } + DataType dataType = new DataType(DataType.BOOL, result); + LogicUtils.buildLikeFilterParam(dataType, objects); + return dataType; + } + + @Override + public DataType ifs(Object... objects) { + int number = IgnoreParamFilter.getSetFuncNumber(FuncNames.IFS.toString()); + if (objects.length == 0 || objects.length % 2 != 1 || objects.length < 3) { + JSONObject errorJson = ErrorUtil.buildError(FuncNames.IFS.toString(), number, number, "IFS函数的参数必须大于3个且为单数"); + throw new RuntimeException(errorJson.getString("msg")); + } + int testI; + for (testI = 1; testI <= objects.length; testI++) { + if (testI % 2 > 0 && testI != objects.length) { + Object cndObj = objects[testI - 1]; + if (!(cndObj instanceof Boolean) && !(cndObj instanceof DataType)) { + JSONObject errorJson = ErrorUtil.buildError(FuncNames.IFS.toString(), number, number, "IFS函数条件必须为真假值"); + throw new RuntimeException(errorJson.getString("msg")); + } else if (cndObj instanceof DataType) { + DataType boolDataType = (DataType) cndObj; + if (boolDataType.getContent() != null && !(boolDataType.getContent() instanceof Boolean)) { + JSONObject errorJson = ErrorUtil.buildError(FuncNames.IFS.toString(), number, number, "IFS函数条件必须为真假值"); + throw new RuntimeException(errorJson.getString("msg")); + } + } + } + } + + boolean paramCheck = checkParamType(objects); + if (!paramCheck) { + JSONObject errorJson = ErrorUtil.buildError(FuncNames.IFS.toString(), number, number, "IFS函数多个条件的返回值必须一致"); + throw new RuntimeException(errorJson.getString("msg")); + } + + int i; + for (i = 1; i <= objects.length; i++) { + if (i % 2 == 0) { + Object cndObj = objects[i - 2]; + if (cndObj instanceof Boolean) { + Boolean cnd = (Boolean) cndObj; + if (cnd) { + if (objects[i - 1] instanceof DataType) { + return (DataType) objects[i - 1]; + } else { + return new DataType(DataType.returnType(ExcelParamUtil.getParamType(objects[i - 1].getClass().getName())), objects[i - 1]); + } +// return new DataType(DataType.BOOL,objects[i-1]); + } + } else if (cndObj instanceof DataType) { + DataType boolData = (DataType) cndObj; + Boolean cnd = boolData.getContent() != null ? ((Boolean) boolData.getContent()) : false; + if (cnd) { + if (objects[i - 1] instanceof DataType) { + return (DataType) objects[i - 1]; + } else { + return new DataType(DataType.returnType(ExcelParamUtil.getParamType(objects[i - 1].getClass().getName())), objects[i - 1]); + } + + } + } + } + } + //如果没有条件符合,返回默认值,最后一个参数为默认值 + Object result = ExcelParamUtil.getParamContent(objects[objects.length - 1], ""); + if (result instanceof DataType) { + return (DataType) result; + } else { + return new DataType(DataType.returnType(ExcelParamUtil.getParamType(result.getClass().getName())), result); + } + + } + + @Override + public DataType find(Object... objects) { + + return new DataType(DataType.BOOL, finds(objects)); + } + + @Override + public DataType switchs(Object... objects) { + if (objects == null || objects.length == 0) { + throw new RuntimeException("参数不能为空"); + } + if (objects.length < 4) { + throw new RuntimeException("switch函数的参数长度必须大于4个"); + } + if (objects.length % 2 != 0) { + throw new RuntimeException("switch函数的参数长度必须为双数"); + } + Object source = objects[0]; + Object defaultValue = objects[objects.length - 1]; + if (source instanceof DataType) { + source = ExcelParamUtil.getParamContent(source, ""); + } + if (defaultValue instanceof DataType) { + defaultValue = ExcelParamUtil.getParamContent(defaultValue, ""); + } + Object result = null; + for (int i = 1; i < objects.length - 1; i++) { + if (i % 2 != 0) { + Object param = objects[i]; + Object value = null; + if (param instanceof DataType) { + value = ExcelParamUtil.getParamContent(param, ""); + } else { + value = param; + } + if (Objects.equals(source.toString(), value.toString())) { + result = objects[i + 1]; + break; + } + } + } + if (result == null) { + result = defaultValue; + } + + + return new DataType(DataType.BOOL, result); + } + + public Boolean finds(Object... objects) { + + if (null == objects || objects.length < 2) { + throw new RuntimeException("参数不能为空"); + } + + //获取查找类型 1:用第二个参数去第一个里面找。2:用第一个参数去第二个里面找 + String type = null; + int vali = 2; + if (objects.length >= 3) { + if (objects[objects.length - 1] instanceof Integer) { + vali = Integer.parseInt(objects[objects.length - 1].toString()); + if (vali != 1 && vali != 2) { + throw new RuntimeException("FIND函数第三个参数只允许1和2"); + } + } else { + throw new RuntimeException("FIND函数第三个参数只允许1和2"); + } + } + + + //将参数转换成List,要判断参数是数组还是单个对象 + List objs1 = null; + List objs2 = null; + if (objects[0] instanceof Object[]) { + Object[] transObj = (Object[]) objects[0]; + objs1 = Arrays.asList(transObj); + } else { + objs1 = Arrays.asList(objects[0]); + } + if (objects[1] instanceof Object[]) { + Object[] transObj = (Object[]) objects[1]; + objs2 = Arrays.asList(transObj); + } else { + objs2 = Arrays.asList(objects[1]); + } + + + if (objs1.size() == 0 || objs2.size() == 0) { + throw new RuntimeException("参数不能为空"); + } + + //判断参数类型是否一致 + List all = new ArrayList<>(); + all.addAll(objs1); + all.addAll(objs2); + for (Object obj : all) { + String localType = ""; + if (obj instanceof DataType) { + String paramType = ExcelParamUtil.getParamType(obj); + if (!paramType.toLowerCase().equals("option")) { + localType = ExcelParamUtil.checkParamType(paramType); + } else { + localType = paramType; + } + } else { + localType = ExcelParamUtil.checkParamType(ExcelParamUtil.getParamType(obj.getClass().getName())); + } + if (type == null) { + type = localType; + } else { + if (!type.equalsIgnoreCase(localType)) { + throw new RuntimeException("参数类型不一致"); + } + } + } + + //根据超找类型判断谁是查找目标,谁是查找依据 + List targetList = new ArrayList<>(); + List keyList = new ArrayList<>(); + switch (vali) { + case 1: + targetList = transOptionData(objs1); + keyList = transOptionData(objs2); + break; + case 2: + targetList = transOptionData(objs2); + keyList = transOptionData(objs1); + break; + default: + throw new RuntimeException("查找类型错误"); + } + + for (Object keyO : keyList) { + for (Object target : targetList) { + if (keyO.equals(target)) { + return true; + } + } + } + + return false; + } + + private List transOptionData(List dataList) { + List contentArrays = new ArrayList<>(); + for (Object data : dataList) { + Object param1 = ExcelParamUtil.getParamContent(data, ""); + //获取依据数据的类型 + String keyType = ""; + if (data instanceof DataType) { + keyType = ExcelParamUtil.getParamType(data); + } else { + keyType = ExcelParamUtil.getParamType(data.getClass().getName()); + } + keyType = ExcelParamUtil.checkParamType(keyType); + + if (keyType.toLowerCase().equals(DataType.OPTION)) { + contentArrays.addAll(Arrays.asList(param1.toString().split(","))); + } else if (data instanceof Character) { + contentArrays.add(param1.toString()); + } else if (keyType.toLowerCase().equals("number")) { + contentArrays.add(Double.parseDouble(param1.toString())); + } else { + contentArrays.add(param1); + } + } + return contentArrays; + } + + private boolean checkParamType(Object[] objects) { + boolean result = false; + String type = null; + for (int i = 1; i <= objects.length; i++) { + if (i % 2 == 0) { + Object obj = objects[i - 1]; + String typeStr = ExcelParamUtil.getParamType(obj); + typeStr = ExcelParamUtil.checkParamType(typeStr); + if (type == null) { + type = typeStr; + } else { + result = typeStr.equalsIgnoreCase(type); + if (!result) { + return result; + } + + } + } + } + String typeStr = ExcelParamUtil.checkParamType(ExcelParamUtil.getParamType(objects[objects.length - 1])); + result = type.equalsIgnoreCase(typeStr); + return result; + } + +} diff --git a/src/com/engine/salary/formlua/func/logic/LogicUtils.java b/src/com/engine/salary/formlua/func/logic/LogicUtils.java new file mode 100644 index 000000000..e1fc796f3 --- /dev/null +++ b/src/com/engine/salary/formlua/func/logic/LogicUtils.java @@ -0,0 +1,109 @@ +package com.engine.salary.formlua.func.logic; + +import com.engine.salary.formlua.entity.parameter.DataType; +import com.engine.salary.formlua.entity.standard.FormulaFilterData; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.ArrayList; +import java.util.List; + +/** + * 逻辑函数构建条件工具类 + */ +public class LogicUtils { + protected static final Logger logger = LoggerFactory.getLogger(LogicUtils.class); + /** + * 构建AND和OR函数的条件 + * @param func + * @param dataType + * @param objs + */ + public static void buildAndOrFilterParam(String func,DataType dataType,Object... objs){ + List filterFormDataList=new ArrayList<>(); + try { + if(objs != null && objs.length > 0) { + for(int i=0;i paramFilterDataList=paramData.getFormulaFilterDataList(); + if(paramFilterDataList!=null){ + paramFilterDataList.forEach(val->{ + if(func.equalsIgnoreCase("AND")){ + val.setCondition(FormulaFilterData.CONDITION_AND); + }else if(func.equalsIgnoreCase("OR")){ + val.setCondition(FormulaFilterData.CONDITION_OR); + } + + }); + filterFormDataList.addAll(paramFilterDataList); + } + } + } +// dataType.setFormulaFilterDataList(filterFormDataList); + } + } catch (Exception e) { + logger.error("err",e); + } + } + + /** + * 构建Like函数的过滤条件 + * @param dataType + * @param objs + */ + public static void buildLikeFilterParam(DataType dataType,Object... objs){ + try { + if(dataType != null && objs.length > 0) { + if(dataType.getDataType().equalsIgnoreCase(DataType.DATASOURCE) || dataType.getDataType().equalsIgnoreCase(DataType.OPTION) || dataType.getDataType().equalsIgnoreCase(DataType.FORM)) { + throw new RuntimeException("筛选条件函数[LIKE]:第一个参数不能是选项型"); + } + List formulaFilterDataList=new ArrayList<>(); + FormulaFilterData formulaFilterData=new FormulaFilterData(); + List contents = new ArrayList(); + for(Object str : objs) { + if(str instanceof DataType){ + DataType data=(DataType)str; + contents.add(data.getContent()+""); + }else { + contents.add(str+""); + } + } + formulaFilterData.setContents(contents); +// formulaFilterData.setTerm(FilterFormData.TERM_LIKE); +// formulaFilterData.setFieldId(dataType.getFieldId()+""); +// formulaFilterDataList.add(formulaFilterData); +// dataType.setFormulaFilterDataList(formulaFilterDataList); + } + } catch (RuntimeException RuntimeException) { + RuntimeException.printStackTrace(); + } + } + + public static void buildInFilterParam(DataType dataType, Object... objs){ + try { + if(dataType != null && objs.length > 0) { + if(!dataType.getDataType().equalsIgnoreCase(DataType.DATASOURCE) && !dataType.getDataType().equalsIgnoreCase(DataType.OPTION)) { + return; + } + List formulaFilterDataList=new ArrayList<>(); + FormulaFilterData formulaFilterData=new FormulaFilterData(); + List ids = new ArrayList(); + for(Object option : objs) { + if(option instanceof DataType){ + DataType data=(DataType)option; + ids.add(data.getContent()+""); + } + } + formulaFilterData.setIds(ids); + formulaFilterData.setFieldId(dataType.getFieldId()+""); +// formulaFilterData.setTerm(FilterFormData.TERM_EQ); +// formulaFilterDataList.add(formulaFilterData); +// dataType.setFormulaFilterDataList(formulaFilterDataList); + } + } catch (Exception e) { + logger.error("err",e); + } + } + +} diff --git a/src/com/engine/salary/formlua/func/math/MathFuncsService.java b/src/com/engine/salary/formlua/func/math/MathFuncsService.java new file mode 100644 index 000000000..7f9565aad --- /dev/null +++ b/src/com/engine/salary/formlua/func/math/MathFuncsService.java @@ -0,0 +1,79 @@ +package com.engine.salary.formlua.func.math; + +import com.engine.salary.formlua.entity.parameter.DataType; + +public interface MathFuncsService { + /** + * 向上取整 + * @param object + * @return + */ + public DataType roundUp(Object... object); + + /** + * 向下取整 + * @param object + * @return + */ + public DataType roundDown(Object... object); + + /** + * 四舍五入 + * @param object + * @return + */ + public DataType round(Object... object); + + /** + * 统计函数 + * @param objects + * @return + */ + public DataType aggregation(Object... objects); + + /** + * 取余函数 + * @param objects + * @return + */ + public DataType mod(Object... objects); + + /** + * 精度控制函数 + * @param number + * @param numDigits + * @return + */ + public DataType Trunc(Object number,Object numDigits); + + /** + * 随机数 + * @param length 随机数长度 + * @param type 随机数类型,分为纯数字、纯英文字母、英文和数字的组合 + * @return + */ + public DataType randomNumber(Object length,Object type); + + /** + * 分组函数 + * @param objects 分组的数据 + * @return 返回一个结果集,这个结果集不能直接使用,要通过其他函数继续运算得出结果,比如aggregation统计函数 + */ + public DataType group(Object... objects); + + /** + * 是否是整数 + * @param objects + * @return + */ + public DataType isInt(Object... objects); + + /** + * 是否是数字 + * @param objects + * @return + */ + public DataType isNumber(Object... objects); + + +} diff --git a/src/com/engine/salary/formlua/func/math/MathFuncsServiceImpl.java b/src/com/engine/salary/formlua/func/math/MathFuncsServiceImpl.java new file mode 100644 index 000000000..22027195d --- /dev/null +++ b/src/com/engine/salary/formlua/func/math/MathFuncsServiceImpl.java @@ -0,0 +1,465 @@ +package com.engine.salary.formlua.func.math; + +import com.alibaba.fastjson.JSONObject; +import com.engine.salary.formlua.entity.parameter.DataType; +import com.engine.salary.formlua.entity.parameter.FuncNames; +import com.engine.salary.formlua.util.ErrorUtil; +import com.engine.salary.formlua.util.ExcelParamUtil; +import com.engine.salary.formlua.util.IgnoreParamFilter; +import com.engine.salary.formlua.util.RegularUtil; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Random; + +public class MathFuncsServiceImpl implements MathFuncsService { + private final String randomNumber = "NUM"; + private final String randomChar = "CHAR"; + private final String randomNumANDChar = "FIX"; + + @Override + public DataType roundUp(Object... objects) { + Integer errorNumber = IgnoreParamFilter.getSetFuncNumber(FuncNames.ROUNDUP.getName()); + Object number = null; + Object object = objects[0]; + + //小数位 + int numDigits = 0; + Object numDigitsObj = null; + + //获取小数点位数参数 + if (objects != null && objects.length > 1) { + numDigitsObj = objects[1]; + + if (numDigitsObj != null && numDigitsObj instanceof DataType) { + numDigitsObj = ExcelParamUtil.getParamContent(numDigitsObj, ""); + } + } + + //整数校验 + if (numDigitsObj != null) { + try { + numDigits = (int) numDigitsObj; + } catch (Exception e) { + throw new RuntimeException("小数点位数必须是整数"); + } + } + + if (object instanceof DataType) { + DataType dataType = (DataType) object; + if (dataType.getDataType().equalsIgnoreCase(DataType.STRING) || dataType.getDataType().equalsIgnoreCase(DataType.DATE) || dataType.getDataType().equalsIgnoreCase(DataType.OPTION)) { + JSONObject errorJson = ErrorUtil.buildError(FuncNames.ROUNDUP.toString(), errorNumber, errorNumber, "ROUNDUP函数只接受数字参数"); + throw new RuntimeException(errorJson.getString("msg")); + } + number = dataType.getContent(); + } else { + BigDecimal db = new BigDecimal(object.toString()); + number = db; + } + if (!RegularUtil.isNumber(number)) { + JSONObject errorJson = ErrorUtil.buildError(FuncNames.ROUNDUP.toString(), errorNumber, errorNumber, "ROUNDUP函数只接受数字参数"); + throw new RuntimeException(errorJson.getString("msg")); + } + + BigDecimal bigDecimal = new BigDecimal(number + ""); + Double result = bigDecimal.setScale(numDigits, BigDecimal.ROUND_CEILING).doubleValue(); + + if (numDigits == 0) return new DataType(DataType.NUMBER, result.intValue()); + return new DataType(DataType.NUMBER, result, "ComponentType.NumberComponent".toString()); + } + + @Override + public DataType roundDown(Object... objects) { + Integer errorNumber = IgnoreParamFilter.getSetFuncNumber(FuncNames.ROUNDDOWN.getName()); + Object number = null; + Object object = objects[0]; + + //小数位 + int numDigits = 0; + Object numDigitsObj = null; + + //获取小数点位数参数 + if (objects != null && objects.length > 1) { + numDigitsObj = objects[1]; + + if (numDigitsObj != null && numDigitsObj instanceof DataType) { + numDigitsObj = ExcelParamUtil.getParamContent(numDigitsObj, ""); + } + } + + //整数校验 + if (numDigitsObj != null) { + try { + numDigits = (int) numDigitsObj; + } catch (Exception e) { + throw new RuntimeException("小数点位数必须是整数"); + } + } + + if (object instanceof DataType) { + DataType dataType = (DataType) object; + if (dataType.getDataType().equalsIgnoreCase(DataType.STRING) || dataType.getDataType().equalsIgnoreCase(DataType.DATE) || dataType.getDataType().equalsIgnoreCase(DataType.OPTION)) { + return new DataType(DataType.NUMBER, 0, "ComponentType.NumberComponent".toString()); + } + number = dataType.getContent(); + } else { + BigDecimal db = new BigDecimal(object.toString()); + number = db; + } + + if (!RegularUtil.isNumber(number)) { + return new DataType(DataType.NUMBER, 0, "ComponentType.NumberComponent".toString()); + } + + BigDecimal bigDecimal = new BigDecimal(number + ""); + Double result = bigDecimal.setScale(numDigits, BigDecimal.ROUND_FLOOR).doubleValue(); + + if (numDigits == 0) return new DataType(DataType.NUMBER, result.intValue()); + return new DataType(DataType.NUMBER, result, "ComponentType.NumberComponent".toString()); + } + + @Override + public DataType round(Object... objects) { + Integer errorNumber = IgnoreParamFilter.getSetFuncNumber(FuncNames.ROUND.getName()); + Object number = null; + Object object = objects[0]; + + //小数位 + int numDigits = 0; + Object numDigitsObj = null; + + //获取小数点位数参数 + if (objects != null && objects.length > 1) { + numDigitsObj = objects[1]; + + if (numDigitsObj != null && numDigitsObj instanceof DataType) { + numDigitsObj = ExcelParamUtil.getParamContent(numDigitsObj, ""); + } + } + + //整数校验 + if (numDigitsObj != null) { + try { + numDigits = (int) numDigitsObj; + } catch (Exception e) { + throw new RuntimeException("小数点位数必须是整数"); + } + } + + if (object instanceof DataType) { + DataType dataType = (DataType) object; + if (dataType.getDataType().equalsIgnoreCase(DataType.STRING) || dataType.getDataType().equalsIgnoreCase(DataType.DATE) || dataType.getDataType().equalsIgnoreCase(DataType.OPTION)) { + return new DataType(DataType.NUMBER, 0, "ComponentType.NumberComponent".toString()); + } + number = dataType.getContent(); + } else { + BigDecimal db = new BigDecimal(object.toString()); + number = db; + } + + if (!RegularUtil.isNumber(number)) { + return new DataType(DataType.NUMBER, 0, "ComponentType.NumberComponent".toString()); + } + + BigDecimal bigDecimal = new BigDecimal(number + ""); + Double result = bigDecimal.setScale(numDigits, BigDecimal.ROUND_HALF_UP).doubleValue(); + + if (numDigits == 0) return new DataType(DataType.NUMBER, result.intValue()); + return new DataType(DataType.NUMBER, result, "ComponentType.NumberComponent".toString()); + } + + @Override + public DataType aggregation(Object... objects) { + Integer errorNumber = IgnoreParamFilter.getSetFuncNumber(FuncNames.AGGREGATION.getName()); + Double result = 0d; + if (objects.length == 0 || objects.length < 2) { + return new DataType(DataType.NUMBER, result, "ComponentType.NumberComponent".toString()); + } + List dataList = new ArrayList(); + for (int i = 0; i < objects.length - 1; i++) { + boolean isArray = false; + String paramType; + Object objectData; + if (objects[i] instanceof DataType) { + DataType dataType1 = (DataType) objects[i]; + paramType = dataType1.getDataType(); + objectData = ExcelParamUtil.getParamContent(dataType1, "string"); + } else if (objects[i] instanceof Object[]) { + Object[] arrayObjs = (Object[]) objects[i]; + String arrayType = null; + objectData = ""; + for (Object arrayObj : arrayObjs) { + String lcoalType = ""; + if (arrayObj instanceof DataType) { + lcoalType = ExcelParamUtil.getParamType(arrayObj); + objectData += ExcelParamUtil.getParamContent((DataType) arrayObj, "string") + "#"; + } else { + lcoalType = ExcelParamUtil.getParamType(arrayObj.getClass().getName()); + objectData += arrayObj + "#"; + } + if (arrayType == null) { + arrayType = lcoalType; + } else { + if (!arrayType.equals(lcoalType)) { + JSONObject errorJson = ErrorUtil.buildError(FuncNames.AGGREGATION.toString(), errorNumber, errorNumber, "操作符参数类型不一致"); + throw new RuntimeException(errorJson.getString("msg")); + } + } + } + paramType = arrayType; + isArray = true; + } else { + paramType = ExcelParamUtil.getParamType(objects[i].getClass().getName()); + objectData = objects[i]; + } + paramType = ExcelParamUtil.checkParamType(paramType); + if (!paramType.equalsIgnoreCase(DataType.NUMBER)) { + JSONObject errorJson = ErrorUtil.buildError(FuncNames.AGGREGATION.toString(), errorNumber, errorNumber, "统计函数只允许数字"); + throw new RuntimeException(errorJson.getString("msg")); + } + if (isArray) { + String[] arrayStrs = objectData.toString().split("#"); + for (String arrayStr : arrayStrs) { + Double data = Double.parseDouble(arrayStr); + dataList.add(data); + } + } else { + Double data = Double.parseDouble(objectData.toString()); + dataList.add(data); + } + + } + + String aggType = objects[objects.length - 1].toString().toLowerCase(); + + Collections.sort(dataList); + switch (aggType) { + case "avg": + for (Double data : dataList) { + result += data; + } + result = result / dataList.size(); + break; + case "max": + result = dataList.get(dataList.size() - 1); + break; + case "min": + result = dataList.get(0); + break; + default: + JSONObject errorJson = ErrorUtil.buildError(FuncNames.AGGREGATION.toString(), errorNumber, errorNumber, "统计函数需要类型参数"); + throw new RuntimeException(errorJson.getString("msg")); + } + return new DataType(DataType.NUMBER, result, "ComponentType.NumberComponent".toString()); + } + + @Override + public DataType mod(Object... objects) { + Integer errorNumber = IgnoreParamFilter.getSetFuncNumber(FuncNames.MOD.getName()); + if (objects.length != 2) { + return new DataType(DataType.NUMBER, 0, "ComponentType.NumberComponent".toString()); + } + + Double doubleOne = 0d; + Double doubleTwo = 0d; + for (int i = 0; i < objects.length; i++) { + Object paramObj = objects[i]; + String type; + if (paramObj instanceof DataType) { + DataType paramDataType = (DataType) paramObj; + type = paramDataType.getDataType(); + } else { + type = ExcelParamUtil.getParamType(paramObj.getClass().getName()); + } + if (!type.equalsIgnoreCase(DataType.NUMBER)) { + return new DataType(DataType.NUMBER, 0, "ComponentType.NumberComponent".toString()); + } + if (i == 0) { + doubleOne = Double.parseDouble(ExcelParamUtil.getParamContent(paramObj, "string").toString()); + } else { + doubleTwo = Double.parseDouble(ExcelParamUtil.getParamContent(paramObj, "string").toString()); + } + } + + + Double value = doubleOne % doubleTwo; + return new DataType(DataType.NUMBER, value, "ComponentType.NumberComponent".toString()); + } + + @Override + public DataType Trunc(Object number, Object numDigits) { + Integer errorNumber = IgnoreParamFilter.getSetFuncNumber(FuncNames.TRUNC.getName()); + Object f1 = 0; + Object numberVal; + Object digitsVal; + if (number instanceof DataType) { + numberVal = ExcelParamUtil.getParamContent(number, ""); + } else { + numberVal = number; + } + + if (numDigits instanceof DataType) { + digitsVal = ExcelParamUtil.getParamContent(numDigits, ""); + } else { + digitsVal = numDigits; + } + + if (RegularUtil.isNumber(numberVal) && RegularUtil.isNumber(digitsVal)) { + Double d = Double.parseDouble(digitsVal.toString()); + int digitsIntVal = d.intValue(); + if (digitsIntVal > 5) { + digitsIntVal = 5; + } + BigDecimal b = new BigDecimal(numberVal.toString()); + f1 = b.setScale(digitsIntVal, BigDecimal.ROUND_HALF_UP).doubleValue(); + if (digitsIntVal == 0) { + f1 = b.intValue(); + } + } else { + JSONObject errorJson = ErrorUtil.buildError(FuncNames.TRUNC.toString(), errorNumber, errorNumber, "小数点格式化只允许数字"); + throw new RuntimeException(errorJson.getString("msg")); + } + return new DataType(DataType.NUMBER, f1, "ComponentType.NumberComponent".toString()); + } + + @Override + public DataType randomNumber(Object length, Object type) { + String value = ""; + Integer errorNumber = IgnoreParamFilter.getSetFuncNumber(FuncNames.RANDOMNUMBER.getName()); + Double numberLength = 0.0; + Object param = 10; + String dataValueType = ""; + if (length != null) { + if (length instanceof DataType) { + DataType dataType = (DataType) length; + dataValueType = ExcelParamUtil.checkParamType(dataType); + param = ExcelParamUtil.getParamContent(length, ""); + } else { + dataValueType = ExcelParamUtil.checkParamType(length); + param = length; + } + } + //判断length长度数据类型是否合规 + if (!dataValueType.equalsIgnoreCase("number")) { + JSONObject errorJson = ErrorUtil.buildError(FuncNames.RANDOMNUMBER.toString(), errorNumber, errorNumber, "随机数函数只允许数字参数"); + throw new RuntimeException(errorJson.getString("msg")); + } + //判断用户设置的length是否大于0,生成的随机数长度必须是大于1的 + if (param != null) { + numberLength = Double.parseDouble(param.toString()); + if (numberLength <= 0) { + JSONObject errorJson = ErrorUtil.buildError(FuncNames.RANDOMNUMBER.toString(), errorNumber, errorNumber, "随机数函数长度必须大于0"); + throw new RuntimeException(errorJson.getString("msg")); + } + } + + String typeString = randomNumber; + if (type != null) { + if (type instanceof DataType) { + DataType dataType = (DataType) length; + typeString = ExcelParamUtil.getParamContent(type, "").toString(); + } else { + typeString = type.toString(); + } + } + + switch (typeString) { + case randomNumber: + value = randomFunc(numberLength, randomNumber); + break; + case randomChar: + value = randomFunc(numberLength, randomChar); + break; + case randomNumANDChar: + value = randomFunc(numberLength, randomNumANDChar); + break; + default: + JSONObject errorJson = ErrorUtil.buildError(FuncNames.RANDOMNUMBER.toString(), errorNumber, errorNumber, "随机数的返回值只允许数字、字符以及数字和字符的混合类型"); + throw new RuntimeException(errorJson.getString("msg")); + + } + + return new DataType(DataType.NUMBER, value, "ComponentType.NumberComponent".toString()); + } + + @Override + public DataType group(Object... objects) { + return null; + } + + @Override + public DataType isInt(Object... objects) { + boolean isInt = false; + if (objects[0] instanceof DataType) { + DataType dataType = (DataType) objects[0]; + isInt = RegularUtil.isInteger(dataType.getContent()); + } else { + isInt = RegularUtil.isInteger(objects[0]); + } + return new DataType(DataType.BOOL, isInt); + } + + @Override + public DataType isNumber(Object... objects) { + boolean isInt = false; + if (objects[0] instanceof DataType) { + DataType dataType = (DataType) objects[0]; + isInt = RegularUtil.isNumber(dataType.getContent()); + } else { + isInt = RegularUtil.isNumber(objects[0]); + } + return new DataType(DataType.BOOL, isInt); + } + + private String randomFunc(Double length, String type) { + Random r = new Random(); + StringBuffer sbff = new StringBuffer(); + + //数字类型随机数 + if (type.equalsIgnoreCase("number")) { + for (double i = 0; i < length; i++) { + sbff.append(r.nextInt(10)); + } + return sbff.toString(); + //英文字母类型随机数 + } else if (type.equalsIgnoreCase("char")) { + for (double i = 0; i < length; i++) { + int charInt = r.nextInt(26) + 'A'; + sbff.append((char) charInt); + } + return sbff.toString(); + //组合类型随机数 + } else { + //如果长度等于1,就不适合做数字字符随机数组合,将长度改为2 + double numloop = 1; + double charloop = 1; + if (length == 1) { + length = 2.0; + } else { + //如果长度是奇数 + if (length % 2 > 0) { + charloop = (length - 1) / 2; + numloop = charloop + 1; + } else { + charloop = length / 2; + numloop = charloop; + } + } + for (double i = 0; i < charloop; i++) { + int charInt = r.nextInt(26) + 'a'; + sbff.append((char) charInt); + } + String charRandom = sbff.toString(); + sbff.setLength(0); + sbff.append(charRandom); + for (double i = 0; i < numloop; i++) { + sbff.append(r.nextInt(10)); + } + + return sbff.toString(); + } + } + +} diff --git a/src/com/engine/salary/formlua/func/string/ExtractType.java b/src/com/engine/salary/formlua/func/string/ExtractType.java new file mode 100644 index 000000000..302b1571a --- /dev/null +++ b/src/com/engine/salary/formlua/func/string/ExtractType.java @@ -0,0 +1,7 @@ +package com.engine.salary.formlua.func.string; + +public class ExtractType { + public final static String CITY="CITY"; + public final static String PROVINCE="PROVINCE"; + public final static String TOWN="TOWN"; +} diff --git a/src/com/engine/salary/formlua/func/string/StringFormulaService.java b/src/com/engine/salary/formlua/func/string/StringFormulaService.java new file mode 100644 index 000000000..011b9f680 --- /dev/null +++ b/src/com/engine/salary/formlua/func/string/StringFormulaService.java @@ -0,0 +1,186 @@ +package com.engine.salary.formlua.func.string; + +import com.engine.salary.formlua.entity.parameter.DataType; + +/** + * @className: + * @Description:Excel文本函数 + * @Author: + * @date: + */ +public interface StringFormulaService { + /** + * 连接字符串 + * @param objs + * @return + */ + public DataType concatString(Object... objs); + + /** + * 转为文本 + * @param obj + * @return + */ + public DataType text(Object... obj); + + /** + * 文本转数字 + * @param txt + * @return + */ + public DataType value(Object... txt); + + /** + * 文本长度 + * @param txt + * @return + */ + public DataType len(Object... txt); + + /** + * 检索关键字 + * @param objects + * @return + */ + public DataType search(Object... objects); + + /** + * 替换文本 + * @param objects + * @return + */ + public DataType replace(Object... objects); + + /** + * 重复文本拼接返回 + * @param objects + * @return + */ + public DataType repeat(Object... objects); + + /** + * 填充文本至指定长度 + * @param objects + * @return + */ + public DataType pad(Object... objects); + + /** + * 去除首尾空格 + * @param objects + * @return + */ + public DataType trim(Object... objects); + + /** + * 返回文本左侧开始的文字 + * @param objects + * @return + */ + public DataType left(Object... objects); + /** + * 返回文本右侧开始的文字 + * @param objects + * @return + */ + public DataType right(Object... objects); + /** + * 返回文本指定位置开始的文字 + * @param objects + * @return + */ + public DataType mid(Object... objects); + + /** + * 返回分数,同value函数逻辑 + * @param objects + * @return + */ + public DataType score(Object... objects); + + /*** + * 操作身份证信息 + * @param objects + * @return + */ + public DataType idCard(Object... objects); + + public DataType sex(String idCard); + + public DataType nativePlace(String idCard); + + public DataType age(String idCard); + + public DataType bd(String idCard); + + /** + * 地址解析函数 + * @param address 具体地址 + * @param level 想获取的行政级别,省市区 + * @return + */ + public DataType addressAnalysis(Object address,Object level); + + /** + * 字符截取函数 + * @param objects 第一个源字符,第二个是截取开始位置,第二个是截取结束位置 + * @return + */ + public DataType subString(Object... objects); + + /** + * 字符查找替换函数 + * @param objects 第一个参数是源字符串,第二个参数是被替换字符,第三个参数是替换时使用的新字符 + * @return + */ + public DataType substitue(Object... objects); + + /** + * 字符提取函数,第一个参数是源字符,第二个参数是提取类型 + * @param objects + * @return + */ + public DataType extract(Object... objects); + + /** + * 字符转小写 + * @param objects + * @return + */ + public DataType lower(Object... objects); + + /** + * 字符转大写 + * @param objects + * @return + */ + public DataType upper(Object... objects); + + /** + * 字符比较,是否完全相等,区分大小写 + * @param objects + * @return + */ + public DataType exact(Object... objects); + + /** + * 是否是字符串 + * @param objects + * @return + */ + public DataType isString(Object... objects); + + /** + * 是否是JSON字符串 + * @param objects + * @return + */ + public DataType isJson(Object... objects); + + /** + * 从JSON中获取值 + * @param objects + * @return + */ + public DataType getJSONValue(Object... objects); +} diff --git a/src/com/engine/salary/formlua/func/string/StringFormulaServiceImpl.java b/src/com/engine/salary/formlua/func/string/StringFormulaServiceImpl.java new file mode 100644 index 000000000..f18557327 --- /dev/null +++ b/src/com/engine/salary/formlua/func/string/StringFormulaServiceImpl.java @@ -0,0 +1,811 @@ +package com.engine.salary.formlua.func.string; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.engine.salary.formlua.entity.parameter.DataType; +import com.engine.salary.formlua.entity.parameter.FuncNames; +import com.engine.salary.formlua.func.date.DateTimeServiceImpl; +import com.engine.salary.formlua.func.math.MathFuncsService; +import com.engine.salary.formlua.util.*; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.math.BigDecimal; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * @className: + * @Description:Excel文本函数 + * @Author: + * @date: + */ +public class StringFormulaServiceImpl implements StringFormulaService { + protected final Logger logger = LoggerFactory.getLogger(this.getClass()); + MathFuncsService mathFuncsService; + + private final String[] fillPositonArray=new String[]{"LEFT","RIGHT"}; + + private final static String PROVINCE="province"; + private final static String CITY="city"; + private final static String TOWN="town"; + private final static String ADDR="addr"; + /** + * 连接字符串 + * @param objs + * @return + */ + @Override + public DataType concatString(Object... objs) { + + List newObjs=new ArrayList<>(); + for (int i=0;i0){ + for(Object object:newObjs){ + if(object instanceof DataType){ + DataType dataType=(DataType)object; + if(dataType.getDataType().equalsIgnoreCase(DataType.NUMBER)){ + newString.append(dataType.getContent()); + }else{ + newString.append(ExcelParamUtil.getParamContent(object,"string")); + } + }else { + newString.append(ExcelParamUtil.getParamContent(object,"string")); + } + + } + } + return new DataType(DataType.STRING,newString.toString()); + } + + /** + * 转成String + * @param objs + * @return + */ + @Override + public DataType text(Object... objs) { + String func="TEXT"; + Integer number=IgnoreParamFilter.getSetFuncNumber(func); + if(null==objs||objs.length>1){ + throw new RuntimeException(func+"函数参数只允许一个参数"); + } + Object obj=objs[0]; + if(null==obj){ + throw new RuntimeException(func+"函数参数为空"); + } + Object result; + if(obj instanceof DataType){ + DataType dataType=(DataType)obj; + if(dataType.getDataType().equalsIgnoreCase(DataType.NUMBER)){ + result=dataType.getContent(); + }else if(dataType.getDataType().equalsIgnoreCase(DataType.OPTION)){ + result=dataType.getOptionContent(); + }else if(dataType.getComponentKey()!=null && dataType.getComponentKey().equalsIgnoreCase("FileComponent")){ + result=dataType.getOptionContent(); + }else{ + result=ExcelParamUtil.getParamContent(dataType,DataType.STRING).toString(); + } + }else { + result=obj.toString(); + } + + return new DataType(DataType.STRING,result); + } + + + /** + * 转成Int类型 + * 提取字符中的数字并返回 + * @param objs + * @return + */ + @Override + public DataType value(Object... objs) { + boolean isNumber=false; + Object txt=objs[0]; + Object result; + Class[] typeObjects=new Class[]{}; + IgnoreParamFilter.commonFilter("VALUE",1,1,typeObjects,objs); + String numberStr; + + if(txt instanceof DataType){ + DataType dataType=(DataType)txt; + if(dataType.getDataType().toLowerCase().equals(DataType.NUMBER)){ + isNumber=true; + if(ExcelParamUtil.getParamContent(txt,"string")==null){ + numberStr="0"; + }else { + numberStr=ExcelParamUtil.getParamContent(txt,"string").toString(); + } + + }else { + if(ExcelParamUtil.getParamContent(txt,"string")==null){ + numberStr="0"; + }else{ + numberStr=ExcelParamUtil.getParamContent(txt,"string").toString(); + } + if(!RegularUtil.isNumber(numberStr)){ + numberStr="0"; + } + } + + }else { + if(RegularUtil.isNumber(txt.toString())){ + isNumber=true; + numberStr=txt.toString(); + }else { + numberStr="0"; + } + } + + if(numberStr.indexOf(".")>0){ + if(numberStr.length()>17){ + numberStr=numberStr.substring(0,17); + } + result=new BigDecimal(numberStr); + }else { + if(numberStr.length()>16){ + numberStr=numberStr.substring(0,16); + } + result=Long.parseLong(numberStr); + } + return new DataType(DataType.NUMBER,result); + } + + + /** + * 获取字符串长度 + * @param txt + * @return + */ + @Override + public DataType len(Object... txt) { + Class[] typeObjects=new Class[]{String.class}; + IgnoreParamFilter.commonFilter("LEN",1,1,typeObjects,txt); + int length=ExcelParamUtil.getParamContent(txt[0],"string").toString().length(); + return new DataType(DataType.NUMBER,length); + } + + /** + *搜索字符返回位置下标 + * 第一个参数是搜索字符 + * 第二个参数是源字符串 + * @param objects + * @return + */ + @Override + public DataType search(Object... objects) { + Class[] typeObjects=new Class[]{String.class,String.class,Integer.class}; + int idx=0; + IgnoreParamFilter.commonFilter("SEARCH",2,3,typeObjects,objects); + if(objects.length==3){ + Object idxObj=ExcelParamUtil.getParamContent(objects[2],"option"); + if(idxObj.toString().indexOf(".")>0){ + idx=Integer.parseInt(idxObj.toString().split("\\.")[0]); + }else { + idx=Integer.parseInt(idxObj.toString()); + } + idx=idx>=0?idx:0; + idx=idx==0?idx:idx-1; + } + String sourceStr=ExcelParamUtil.getParamContent(objects[1],"string").toString(); + String searchWord=ExcelParamUtil.getParamContent(objects[0],"string").toString(); + int findIdx=sourceStr.indexOf(searchWord,idx); + findIdx=findIdx<0?0:findIdx+1; + return new DataType(DataType.NUMBER,findIdx); + } + + /** + * 替换字符函数 + * 第一个参数是源字符串 + * 第二个参数是替换开始位置,以0开始 + * 第三个参数是替换字符的长度,从替换位置开始到结束的字符,为需要替换的字符串 + * 第四个参数作为替换字符 + * @param objects + * @return + */ + @Override + public DataType replace(Object... objects) { + Object result; + Class[] typeObjects=new Class[]{String.class,Integer.class,Integer.class,String.class}; + IgnoreParamFilter.commonFilter("REPLACE",4,4,typeObjects,objects); + String sourceStr=ExcelParamUtil.getParamContent(objects[0],"string").toString(); + Double ridxD=Double.parseDouble(ExcelParamUtil.getParamContent(objects[1],"string").toString()); + int repIdx=ridxD.intValue(); + + Double repD=Double.parseDouble(ExcelParamUtil.getParamContent(objects[2],"string").toString()); + int repLenth=repD.intValue(); + + + String repWord=ExcelParamUtil.getParamContent(objects[3],"string").toString(); + int replaceLength=(repIdx-1)+repLenth; + if(replaceLength>sourceStr.length()){ +// throw new RunTimeException(errorJson.getString("msg")); + replaceLength=sourceStr.length(); + } + String cutStr=sourceStr.substring(repIdx-1,replaceLength); + sourceStr=sourceStr.replaceFirst(cutStr,repWord); + result=sourceStr; + return new DataType(DataType.STRING,result); + } + + /** + * 参数重复叠加函数 + * 第一个参数为源字符 + * 第二个为叠加次数 + * @param objects + * @return + */ + @Override + public DataType repeat(Object... objects) { + Object result; + Class[] typeObjects=new Class[]{String.class,Integer.class}; + IgnoreParamFilter.commonFilter("REPEAT",2,2,typeObjects,objects); + String str=ExcelParamUtil.getParamContent(objects[0],"string").toString(); + Double repeatD=Double.parseDouble(ExcelParamUtil.getParamContent(objects[1],"string").toString()); + int repeat=repeatD.intValue(); + repeat=repeat>=1?repeat:1; + StringBuffer sbf=new StringBuffer(); + sbf.append(str); + for(int i=1;i=0?sourceLength:0; + String fillStr=ExcelParamUtil.getParamContent(objects[2],"string").toString(); + String fillPosition="RIGHT"; + if(objects.length==4){ + fillPosition=ExcelParamUtil.getParamContent(objects[3],"string").toString(); + Arrays.sort(fillPositonArray); + if(Arrays.binarySearch(fillPositonArray,fillPosition)<0){ + String func="TEXT"; + Integer number=IgnoreParamFilter.getSetFuncNumber(func); + throw new RuntimeException(func+"函数第四个参数值不正确"); + } + } + if(sourceStr.length() chars=new ArrayList<>(); + sourceStr=ExcelParamUtil.appendString(fillStr,sourceStr,sourceLength,fillPosition); + } + result=sourceStr; + return new DataType(DataType.STRING,result); + } + + + + /** + * 去首尾空格 + * @param objects + * @return + */ + @Override + public DataType trim(Object... objects) { + Object result; + Class[] typeObjects=new Class[]{String.class}; + IgnoreParamFilter.commonFilter("TRIM",1,1,typeObjects,objects); + + String sourceStr=ExcelParamUtil.getParamContent(objects[0],"string").toString().trim(); + result=sourceStr; + return new DataType(DataType.STRING,result); + } + /** + * 字符左截取函数 + * 返回从左边开始到指定位置的字符串 + * 第一个参数是源字符串 + * 第二个参数是截取长度 + * @param objects + * @return + */ + @Override + public DataType left(Object... objects) { + Object result; + Class[] typeObjects=new Class[]{String.class,Integer.class}; + IgnoreParamFilter.commonFilter("LEFT",2,2,typeObjects,objects); + String sourceStr=ExcelParamUtil.getParamContent(objects[0],"string").toString(); + Double cutIdxD=Double.parseDouble(ExcelParamUtil.getParamContent(objects[1],"string").toString()); + int cutIdx=cutIdxD.intValue(); + cutIdx=cutIdx>=0?cutIdx:1; + if(cutIdx>sourceStr.length()){ + cutIdx=sourceStr.length(); + } + sourceStr=sourceStr.substring(0,cutIdx); + result=sourceStr; + return new DataType(DataType.STRING,result); + } + + /** + * 字符右截取函数 + * 返回从右边开始到指定位置的字符串 + * 第一个参数是源字符串 + * 第二个参数是截取长度 + * @param objects + * @return + */ + @Override + public DataType right(Object... objects) { + Object result; + Class[] typeObjects=new Class[]{String.class,Integer.class}; + IgnoreParamFilter.commonFilter("RIGHT",2,2,typeObjects,objects); + String sourceStr=ExcelParamUtil.getParamContent(objects[0],"string").toString(); + Double cutIdxD=Double.parseDouble(ExcelParamUtil.getParamContent(objects[1],"string").toString()); + int cutIdx=cutIdxD.intValue(); + cutIdx=cutIdx>=0?cutIdx:1; + if(cutIdx>sourceStr.length()){ + cutIdx=sourceStr.length(); + } + sourceStr=sourceStr.substring(sourceStr.length()-cutIdx); + result=sourceStr; + return new DataType(DataType.STRING,result); + } + + /** + * 字符自由截取函数 + * 第一个参数是源字符串 + * 第二个参数是截取开始位置 + * 第三个参数是截取结束位置 + * @param objects + * @return + */ + @Override + public DataType mid(Object... objects) { + Object result; + Class[] typeObjects=new Class[]{String.class,Integer.class,Integer.class}; + IgnoreParamFilter.commonFilter("MID",3,3,typeObjects,objects); + String sourceStr=ExcelParamUtil.getParamContent(objects[0],"string").toString(); + if(null==sourceStr||sourceStr.trim().equals("")){ + return new DataType(DataType.STRING,""); + } + Double cutidxD=Double.parseDouble(ExcelParamUtil.getParamContent(objects[1],"string").toString()); + int cutIdx=cutidxD.intValue(); + cutIdx=cutIdx>0?cutIdx:1; + Double cutStrLenD=Double.parseDouble(ExcelParamUtil.getParamContent(objects[2],"string").toString()); + int cutStrLen=cutStrLenD.intValue(); + cutStrLen=cutStrLen>0?cutStrLen:1; + if((cutIdx-1+cutStrLen)>sourceStr.length()){ + sourceStr=sourceStr.substring(cutIdx-1,sourceStr.length()); + }else { + sourceStr=sourceStr.substring(cutIdx-1,(cutIdx-1)+cutStrLen); + } + + result=sourceStr; + return new DataType(DataType.STRING,result); + } + + @Override + public DataType score(Object... objs) { + Object result; + DataType fraction=(DataType)objs[0]; + result=fraction.getScore(); + if(result==null){ + result=0; + } + return new DataType(DataType.NUMBER,result); + } + + @Override + public DataType idCard(Object... objects) { + Object result=""; +// IgnoreParamFilter.checkValiIdCard("IDCARD",objects); + String operType=ExcelParamUtil.getParamContent(objects[1],"string").toString(); + String idCard=ExcelParamUtil.getParamContent(objects[0],"string").toString(); + RegularUtil.validateIDCard(idCard); + if(idCard.length()!=18&&idCard.length()!=15){ + Integer number=IgnoreParamFilter.getSetFuncNumber("IDCARD"); + throw new RuntimeException("只能计算中国大陆的身份证"); + } + DataType exeResult=new DataType(); + if(operType.equalsIgnoreCase("BD")){ + exeResult=bd(idCard); + }else if(operType.equalsIgnoreCase("NA")){ + exeResult=nativePlace(idCard); + }else if(operType.equalsIgnoreCase("AGE")){ + exeResult=age(idCard); + }else if(operType.equalsIgnoreCase("GENDER")){ + exeResult=sex(idCard); + } + return exeResult; + } + + @Override + public DataType sex(String IDCard){ + String sex =""; + //15位身份证号 + if (IDCard.length() == 15){ + if (Integer.parseInt(IDCard.substring(14, 15)) % 2 == 0) { + sex = "女"; + } else { + sex = "男"; + } + //18位身份证号 + }else if(IDCard.length() == 18){ + // 判断性别 + if (Integer.parseInt(IDCard.substring(16).substring(0, 1)) % 2 == 0) { + sex = "女"; + } else { + sex = "男"; + } + } + return new DataType(DataType.STRING,sex); + } + + @Override + public DataType nativePlace(String idCard){ + int nativePlaceCode=Integer.parseInt(idCard.substring(0, 6)); + String nativePlace= NativePlace.getNativePlace(nativePlaceCode); + return new DataType(DataType.STRING,nativePlace); + } + + @Override + public DataType age(String idCard){ + Object age=0; + SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); + DataType datatype=bd(idCard); + String birthdayStr=datatype.getContent()!=null?datatype.getContent()+"":""; + try { + if(StringUtils.isNotEmpty(birthdayStr)){ + String today=formatter.format(new Date()); + Double ageN= DateTimeServiceImpl.getBetween(birthdayStr,today,"Y");//使用日期函数获取日期间隔年数 + DataType dataType=mathFuncsService.roundDown(ageN);//做一次向下取整 + if(dataType!=null && dataType.getContent()!=null){ + age=dataType.getContent(); + } + } + } catch (ParseException e) { + logger.error("err",e); + } + return new DataType(DataType.NUMBER,age); + } + + @Override + public DataType bd(String idCard){ + String result=null; + Calendar c=Calendar.getInstance(); + Integer number=IgnoreParamFilter.getSetFuncNumber("IDCARD"); + switch(idCard.length()) { + case 18: + case 15: + String year = idCard.substring(6, 10); + if(Integer.decode(year) <1900 && Integer.decode(year)>c.get(Calendar.YEAR)){ + + JSONObject errorJson=ErrorUtil.buildError("IDCARD",number,number,"IDCARD函数身份证字符不正确"); + throw new RuntimeException(errorJson.getString("msg")); + } + + String month = idCard.substring(10,12); + if(Integer.parseInt(month)<1 && Integer.parseInt(month)>12){ + JSONObject errorJson= ErrorUtil.buildError("IDCARD",number,number,"IDCARD函数身份证字符不正确"); + throw new RuntimeException(errorJson.getString("msg")); + } + + String day = idCard.substring(12,14); + c.set(Integer.parseInt(year) ,Integer.parseInt(month), 0); + if(Integer.parseInt(day)>c.get(Calendar.DAY_OF_MONTH)){ + JSONObject errorJson=ErrorUtil.buildError("IDCARD",number,number,"IDCARD函数身份证字符不正确"); + throw new RuntimeException(errorJson.getString("msg")); + } + + String birth=year+"-"+month+"-"+day; + result=birth; + break; + + } + return new DataType(DataType.STRING,result); + } + + @Override + public DataType addressAnalysis(Object obj1, Object obj2) { + Integer number=IgnoreParamFilter.getSetFuncNumber(FuncNames.ADDRESS.getName()); + + String addressType=ExcelParamUtil.checkParamType(obj1); + String levelType=ExcelParamUtil.checkParamType(obj2); + if(!addressType.equalsIgnoreCase("string") || !levelType.equalsIgnoreCase("string")){ + JSONObject errorJson=ErrorUtil.buildError(FuncNames.ADDRESS.toString(),number,number,"地址解析函数的参数只允许字符类型"); + throw new RuntimeException(errorJson.getString("msg")); + } + String address=""; + String level=""; + if(obj1 instanceof DataType){ + address=ExcelParamUtil.getParamContent(obj1).toString(); + }else{ + address=obj1.toString(); + } + + if(obj2 instanceof DataType){ + level=ExcelParamUtil.getParamContent(obj2).toString(); + }else { + level=obj2.toString(); + } + + Map placeMap=NativePlace.getAddressInfo(address); + String result=""; + switch (level){ + case PROVINCE: + result=placeMap.get(PROVINCE); + break; + case CITY: + result=placeMap.get(CITY); + break; + case TOWN: + result=placeMap.get(TOWN); + break; + case ADDR: + result=placeMap.get(ADDR); + default: + JSONObject errorJson=ErrorUtil.buildError(FuncNames.ADDRESS.toString(),number,number,"行政区块只支持省、市、区县"); + throw new RuntimeException(errorJson.getString("msg")); + + } + return new DataType(DataType.STRING,result); + } + + @Override + public DataType subString(Object... objects) { + String newString=""; + if(objects!=null && objects.length==3){ + String sourceString=null; + BigDecimal subIdx=null; + BigDecimal subEndIdx=null; + if(objects[0] instanceof DataType){ + sourceString=ExcelParamUtil.getParamContent(objects[0],"string").toString(); + }else{ + sourceString=objects[0]+""; + } + //如果字符为空,直接返回 + if(sourceString==null || sourceString.length()==0){ + return new DataType(DataType.STRING,newString); + } + if(objects[1] instanceof DataType){ + subIdx=new BigDecimal(ExcelParamUtil.getParamContent(objects[1],"").toString()); + }else{ + subIdx=new BigDecimal(objects[1]+""); + } + + if(objects[2] instanceof DataType){ + subEndIdx=new BigDecimal(ExcelParamUtil.getParamContent(objects[2],"").toString()); + }else{ + subEndIdx=new BigDecimal(objects[2]+""); + } + + //如果截取位置小于0或者大于字符长度,直接返回 + if(subIdx.intValue()<0 || subIdx.intValue()>sourceString.length()){ + return new DataType(DataType.STRING,newString); + } + //如果截取位置小于0或者大于字符长度,直接返回 + if(subEndIdx.intValue()<0 || subEndIdx.intValue()>sourceString.length()){ + return new DataType(DataType.STRING,newString); + } + newString=sourceString.substring(subIdx.intValue()-1,subEndIdx.intValue()); + } + return new DataType(DataType.STRING,newString); + } + + @Override + public DataType substitue(Object... objects) { + String newString=""; + if(objects!=null && objects.length==3){ + String sourceString=null; + String replaceChar=null; + String newChar=null; + if(objects[0] instanceof DataType){ + sourceString=ExcelParamUtil.getParamContent(objects[0],"string").toString(); + }else{ + sourceString=objects[0]+""; + } + + if(objects[1] instanceof DataType){ + replaceChar=ExcelParamUtil.getParamContent(objects[1],"string").toString(); + }else{ + replaceChar=objects[1]+""; + } + + if(objects[2] instanceof DataType){ + newChar=ExcelParamUtil.getParamContent(objects[2],"string").toString(); + }else{ + newChar=objects[2]+""; + } + + if(sourceString==null || replaceChar.length()>sourceString.length() || newChar.length()>sourceString.length()){ + return new DataType(DataType.STRING,newString); + } + newString=sourceString.replaceAll(replaceChar,newChar); + } + return new DataType(DataType.STRING,newString); + } + + @Override + public DataType extract(Object... objects) { + return null; + } + + @Override + public DataType lower(Object... objects) { + String sourceString=""; + if(objects!=null){ + if(objects[0]!=null){ + if(objects[0] instanceof DataType){ + sourceString=ExcelParamUtil.getParamContent(objects[0],"string").toString(); + }else { + sourceString=objects[0]+""; + } + } + } + return new DataType(DataType.STRING,sourceString.toLowerCase()); + } + + @Override + public DataType upper(Object... objects) { + String sourceString=""; + if(objects!=null){ + if(objects[0]!=null){ + if(objects[0] instanceof DataType){ + sourceString=ExcelParamUtil.getParamContent(objects[0],"string").toString(); + }else { + sourceString=objects[0]+""; + } + } + } + return new DataType(DataType.STRING,sourceString.toUpperCase()); + } + + @Override + public DataType exact(Object... objects) { + boolean eq=false; + if(objects!=null && objects.length==2){ + String sourceOne=""; + String sourceTwo=""; + if(objects[0] instanceof DataType){ + sourceOne=ExcelParamUtil.getParamContent(objects[0],"string").toString(); + }else{ + sourceOne=objects[0]+""; + } + if(objects[1] instanceof DataType){ + sourceTwo=ExcelParamUtil.getParamContent(objects[1],"string").toString(); + }else{ + sourceTwo=objects[1]+""; + } + if(sourceOne!=null && sourceTwo!=null){ + eq=sourceOne.equals(sourceTwo); + return new DataType(DataType.BOOL,eq); + }else if(sourceOne == null && sourceTwo == null){ + return new DataType(DataType.BOOL,true); + }else if(sourceOne == null && sourceTwo != null){ + return new DataType(DataType.BOOL,false); + }else if(sourceOne != null && sourceTwo == null){ + return new DataType(DataType.BOOL,false); + } + + } + return new DataType(DataType.BOOL,eq); + } + + @Override + public DataType isString(Object... objects) { + Object object=objects[0]; + String fieldType=""; + DataType resultDataType; + if(object instanceof DataType){ + DataType dataType=(DataType)object; + fieldType= ExcelParamUtil.checkParamType(dataType.getDataType()); + }else { + fieldType= ExcelParamUtil.getParamType(object.getClass().getName()); + } + if(fieldType.equalsIgnoreCase("string")){ + resultDataType=new DataType(DataType.BOOL,true); + }else{ + resultDataType=new DataType(DataType.BOOL,false); + } + return resultDataType; + } + + @Override + public DataType isJson(Object... objects) { + Object object=objects[0]; + String fieldType=""; + DataType resultDataType; + Object content=null; + if(object instanceof DataType){ + DataType dataType=(DataType)object; + content=dataType.getContent(); + fieldType= ExcelParamUtil.checkParamType(dataType.getDataType()); + }else { + fieldType= ExcelParamUtil.getParamType(object.getClass().getName()); + content=object; + } + if(fieldType.equalsIgnoreCase("string")){ + if(content!=null){ + try { + JSON.parseObject(content+""); + resultDataType=new DataType(DataType.BOOL,true); + } catch (Exception e) { + logger.error("err",e); + resultDataType=new DataType(DataType.BOOL,false); + } + }else{ + resultDataType=new DataType(DataType.BOOL,false); + } + }else{ + resultDataType=new DataType(DataType.BOOL,false); + } + return resultDataType; + } + + @Override + public DataType getJSONValue(Object... objects) { + Object object=objects[0]; + Object objectKeyObj=objects[1]; + String fieldType=""; + DataType resultDataType; + Object content=null; + Object objectKey=null; + if(object instanceof DataType){ + DataType dataType=(DataType)object; + content=dataType.getContent(); + fieldType= ExcelParamUtil.checkParamType(dataType.getDataType()); + }else { + fieldType= ExcelParamUtil.getParamType(object.getClass().getName()); + content=object; + } + + if(objectKeyObj instanceof DataType){ + DataType dataType=(DataType)objectKeyObj; + objectKey=dataType.getContent(); + }else{ + objectKey=objectKeyObj; + } + + if(fieldType.equalsIgnoreCase("string")){ + if(content!=null){ + try { + JSONObject jsonObject=JSON.parseObject(content+""); + Object jsonValue=jsonObject.get(objectKey+""); + resultDataType=new DataType(DataType.STRING,jsonValue==null?"":jsonValue.toString()); + } catch (Exception e) { + logger.info("err",e); + resultDataType=new DataType(DataType.STRING,""); + } + }else{ + resultDataType=new DataType(DataType.STRING,""); + } + }else{ + resultDataType=new DataType(DataType.STRING,""); + } + return resultDataType; + } +} diff --git a/src/com/engine/salary/formlua/util/CompareUtil.java b/src/com/engine/salary/formlua/util/CompareUtil.java new file mode 100644 index 000000000..570e1e998 --- /dev/null +++ b/src/com/engine/salary/formlua/util/CompareUtil.java @@ -0,0 +1,24 @@ +package com.engine.salary.formlua.util; + + +public class CompareUtil { + public static String[] genArray(Object obj, String type) { + String[] resultArray = new String[]{}; + if (obj.getClass().isArray()) { + Object[] op1Array = (Object[]) obj; + resultArray = new String[op1Array.length]; + for (int i = 0; i < op1Array.length; i++) { + if (ExcelParamUtil.getParamContent(op1Array[i], type) != null) { + String p = ExcelParamUtil.getParamContent(op1Array[i], type).toString(); + resultArray[i] = p; + } + } + } else { + if (ExcelParamUtil.getParamContent(obj, type) != null) { + String opStr = ExcelParamUtil.getParamContent(obj, type).toString(); + resultArray = opStr.split(","); + } + } + return resultArray; + } +} diff --git a/src/com/engine/salary/formlua/util/DateUtil.java b/src/com/engine/salary/formlua/util/DateUtil.java new file mode 100644 index 000000000..5eddb6eb0 --- /dev/null +++ b/src/com/engine/salary/formlua/util/DateUtil.java @@ -0,0 +1,211 @@ +package com.engine.salary.formlua.util; + +import com.engine.salary.formlua.entity.parameter.DataType; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.time.DateUtils; +import org.joda.time.DateTime; +import org.joda.time.Days; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; + + +public class DateUtil { + protected static final Logger logger = LoggerFactory.getLogger(DateUtil.class); + private static String[] parsePatterns = {"yyyy-MM-dd","yyyy年MM月dd日", + "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy/MM/dd", + "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyyMMdd","yy-MM","yy/MM"}; + private static String[] dateComponentKeyList={"DateComponent","DateInterval","TimeComponent"}; + public static void main(String args[]){ + } + /** + * 构建日期对象 + * @param dateChar + * @return + */ + public static Date buildDateByDateChar(String dateChar){ + + Date resultDate=null; + if(StringUtils.isEmpty(dateChar)){ + return resultDate; + } + String formatString=buildFormat(dateChar); + if(StringUtils.isEmpty(formatString)){ + return resultDate; + } + SimpleDateFormat simpleDateFormat=new SimpleDateFormat(formatString); + simpleDateFormat.setLenient(false); + try { + resultDate=simpleDateFormat.parse(dateChar); + } catch (ParseException e) { + logger.error("err",e); + } + return resultDate; + } + + /** + * 判断是否是日期控件 + * @param data + * @return + */ + public static boolean isDateComponent(Object data){ + if(data instanceof DataType){ + DataType dataType=(DataType)data; + if(dataType.getComponentKey()!=null){ + for (String dateKey:dateComponentKeyList){ + if(dateKey.equalsIgnoreCase(dataType.getComponentKey())){ + return true; + } + } + } + }else if(data!=null && isValidDate(data+"")){ + return true; + } + + return false; + } + + + public static boolean isValidDate(String str) { + boolean convertSuccess=false; + for(String s:parsePatterns){ + convertSuccess=parseDateString(str,s); + if(convertSuccess){ + break; + } + } + return convertSuccess; + } + + public static boolean parseDateString(String dateString,String formatString){ + boolean convertSuccess=true; + SimpleDateFormat format = new SimpleDateFormat(formatString); + try { + format.setLenient(false); + format.parse(dateString); + } catch (ParseException e) { +// logger.error("err",e); + convertSuccess=false; + } + return convertSuccess; + } + /** + * 判断日期时间的格式 + * @param dateTimeStr + * @return + */ + public static String buildFormat(String dateTimeStr,String type){ + String fmateStr=null; + int len=dateTimeStr.length(); + switch (type){ + case "Y": + fmateStr="yyyy"; + break; + case "M": + fmateStr="yyyy-MM"; + break; + case "D": + fmateStr="yyyy-MM-dd"; + break; + case "H": + fmateStr="yyyy-MM-dd HH"; + break; + case "I": + fmateStr="yyyy-MM-dd HH:mm"; + break; + case "S": + fmateStr="yyyy-MM-dd HH:mm:ss"; + break; + } + return fmateStr; + } + + public static String buildFormat(String dateTimeStr){ + String fmateStr=null; + int len=dateTimeStr.length(); + switch (len){ + case 4: + if(dateTimeStr.indexOf(":")<0){ + fmateStr="yyyy"; + }else if(dateTimeStr.indexOf("-")<0){ + fmateStr="H:mm"; + } + break; + case 5: + if(dateTimeStr.indexOf(":")<0){ + fmateStr="yy-MM"; + }else if(dateTimeStr.indexOf("-")<0){ + fmateStr="HH:mm"; + } + break; + case 7: + if(dateTimeStr.indexOf(":")<0){ + fmateStr="yyyy-MM"; + }else if(dateTimeStr.indexOf("-")<0){ + fmateStr="H:mm:ss"; + } + break; + case 8: + fmateStr="HH:mm:ss"; + break; + case 9: + fmateStr="yyyy-MM-dd"; + break; + case 10: + fmateStr="yyyy-MM-dd"; + break; + case 13: + fmateStr="yyyy-MM-dd HH"; + break; + case 16: + fmateStr="yyyy-MM-dd HH:mm"; + break; + case 19: + fmateStr="yyyy-MM-dd HH:mm:ss"; + break; + default: + fmateStr=""; + } + return fmateStr; + } + + /** + * 判断参数类型,并且获取content属性的值,或者String类型直接返回 + * @param obj + * @return + */ + public static String getContent(Object obj, SimpleDateFormat formatter){ + String date=""; + if(obj instanceof String || obj instanceof Character){ + date=obj.toString(); + }else if(obj instanceof Date){ + date=formatter.format(obj); + }else{ + DataType dataType=(DataType)obj; + Object content=dataType.getText(); + if(null!=content){ + date=content.toString(); + }else { + date = dataType.getContent() == null ? null : dataType.getContent().toString(); + } + } + return date; + } + + /** + * 计算日期间相隔天数 + * @param start + * @param end + * @return + */ + public static int daysBetween(Date start, Date end) { + if(start == null || end == null || start.getTime() >= end.getTime()) return 0; + + Date startDate = DateUtils.truncate(start, Calendar.DATE); + return Days.daysBetween(new DateTime(startDate), new DateTime(end)).getDays(); + } +} diff --git a/src/com/engine/salary/formlua/util/ErrorUtil.java b/src/com/engine/salary/formlua/util/ErrorUtil.java new file mode 100644 index 000000000..2ed8d55fd --- /dev/null +++ b/src/com/engine/salary/formlua/util/ErrorUtil.java @@ -0,0 +1,33 @@ +package com.engine.salary.formlua.util; + +import com.alibaba.fastjson.JSONObject; + + +public class ErrorUtil { + private static JSONObject errorJson=new JSONObject(); + public static JSONObject buildDataError(String func,int errorIdx,Object errorData,String msg){ + errorJson.put("msg",msg); + errorJson.put("func",func); + errorJson.put("errorIdx",errorIdx); + errorJson.put("errorData",errorData); + errorJson.put("excute",false); + return errorJson; + } + public static JSONObject buildError(String func,Integer errorIdx,Integer errorFunc,String msg){ + errorJson.put("msg",msg); + errorJson.put("func",func); + errorJson.put("errorIdx",errorIdx); + errorJson.put("errorFunc",errorFunc); + errorJson.put("excute",false); + return errorJson; + } + public static JSONObject buildError(String func,int errorIdx,int endIndex,Object errorData,String msg){ + errorJson.put("msg",msg); + errorJson.put("func",func); + errorJson.put("errorIdx",errorIdx); + errorJson.put("errorEndIdx",endIndex); + errorJson.put("errorData",errorData); + errorJson.put("excute",false); + return errorJson; + } +} diff --git a/src/com/engine/salary/formlua/util/ExcelParamUtil.java b/src/com/engine/salary/formlua/util/ExcelParamUtil.java new file mode 100644 index 000000000..0e51fe919 --- /dev/null +++ b/src/com/engine/salary/formlua/util/ExcelParamUtil.java @@ -0,0 +1,1125 @@ +package com.engine.salary.formlua.util; + +import com.alibaba.fastjson.JSONObject; +import com.engine.salary.formlua.entity.parameter.DataType; +import com.engine.salary.formlua.entity.parameter.IllegalList; +import com.engine.salary.formlua.entity.parameter.ParamType; +import com.engine.salary.formlua.entity.standard.execute.FixFieldType; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.lang.reflect.Array; +import java.math.BigDecimal; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + + +public class ExcelParamUtil { + protected static final Logger logger = LoggerFactory.getLogger(ExcelParamUtil.class); + public final static String[] NUMBERFIELD = new String[]{"NumberComponent", "Money", "Monitor", "Raty", "ProgressBar", FixFieldType.Num.toString(), DataType.NUMBER}; + public final static String[] DATEFIELD = new String[]{"DateComponent", "DateInterval", "TimeComponent", DataType.DATE}; + public final static String[] TEXTFIELD = new String[]{"Text", "TextArea", "Email", "Phone", "Mobile", "IDCard", "FileComponent", "SerialNumber", "PositionComponent", "Paragraph", FixFieldType.Text.toString(), DataType.STRING}; + public final static String[] SELECTFIELD = new String[]{"ImageComponent", "RadioBox", "CheckBox", "Select", "ComboSelect", "ImageRadioBox", "ImageCheckBox", "TreeSelect", "MatrixComponent", FixFieldType.Select.toString(), "option", "employee", "department", "subcompany", "operator", DataType.OPTION}; + public final static String[] DATASOURCEFIELD = new String[]{"Employee", "Department", "Mainline", "Task", "Document", "Workflow", "AgendaComponent", "FormComponent", "CustomerComponent", "ClueComponent", "Subcompany", + "OrderComponent", "ContactComponent", "ChanceComponent", "ProductionComponent", "ContractComponent", "ActivityComponent", "WorkreportComponent", "CompetitorComponent", "KpiFlowComponent", "Ebuilder", "QuoteComponent", "AttendComponent", "DataSource", + FixFieldType.Department.toString(), FixFieldType.Employee.toString()}; + + private static String[] funcArray = IllegalList.getInstance().getNameIllegalArray(); + private final static String[] NUMBERCOMPONENTS = new String[]{"NumberComponent", "Money", "Raty", "ProgressBar", "Monitor"}; + private static String[] numberTypes = new String[]{"Integer", "integer", "Long", "Double", "Float", "float", "int", "double", "long", "float", "bigdecimal", "BigDecimal"}; + public final static String CHECKLEVEL_NULL = "NULL"; + public final static String CHECKLEVEL_STRING = "STRING"; + + /** + * 自定义脚本生成调用的逻辑 + * + * @param funcString + * @return + */ + public static String initFunc(String funcString) { + if (StringUtils.isEmpty(funcString)) { + return funcString; + } + int startIdx = funcString.indexOf("("); + int endIdx = funcString.indexOf(")"); + int funcIdx = funcString.indexOf("function"); + if (startIdx == -1) { + throw new RuntimeException("【语法错误】缺少左括号("); + } else if (endIdx == -1) { + throw new RuntimeException("【语法错误】缺少右括号)"); + } else if (funcIdx == -1) { + throw new RuntimeException("【语法错误】缺少function关键字"); + } + String funcName = funcString.substring(funcIdx + 8, startIdx).trim(); + String paramStr = funcString.substring(startIdx + 1, endIdx); + if (paramStr.trim().equalsIgnoreCase("")) { + funcString += funcName + "();"; + return funcString; + } + String[] paramStrArray = paramStr.split(","); + logger.info("总参数个数:" + paramStrArray.length); + String paramNames = ""; + for (int i = 0; i < paramStrArray.length; i++) { + String paramName = paramStrArray[i].trim(); + if (paramNames.equalsIgnoreCase("")) { + paramNames = paramName; + } else { + paramNames += "," + paramName; + } + + } + funcString += funcName + "(" + paramNames + ");"; + return funcString; + } + + public static String initFuncOnly(String funcString) { + if (StringUtils.isEmpty(funcString)) { + return funcString; + } + int startIdx = funcString.indexOf("("); + int endIdx = funcString.indexOf(")"); + int funcIdx = funcString.indexOf("function"); + if (startIdx == -1) { + throw new RuntimeException("【语法错误】缺少左括号("); + } else if (endIdx == -1) { + throw new RuntimeException("【语法错误】缺少右括号)"); + } else if (funcIdx == -1) { + throw new RuntimeException("【语法错误】缺少function关键字"); + } + String funcName = funcString.substring(funcIdx + 8, startIdx).trim(); + String paramStr = funcString.substring(startIdx + 1, endIdx); + if (paramStr.trim().equalsIgnoreCase("")) { + funcString += funcName + "();"; + return funcString; + } + String[] paramStrArray = paramStr.split(","); + logger.info("总参数个数:" + paramStrArray.length); + String paramNames = ""; + for (int i = 0; i < paramStrArray.length; i++) { + String paramName = paramStrArray[i].trim(); + paramName = paramName.replaceAll("int|String|Double|Float|float|double|Integer|boolean|Boolean|Object|object", "").trim(); + if (paramNames.equalsIgnoreCase("")) { + paramNames = paramName; + } else { + paramNames += "," + paramName; + } + + } + String func = funcName + "(" + paramNames + ");"; + return func; + } + + + /** + * 判断控件所属的数据类型 + * + * @param compnentKey FormField中的ComponentKey + * @return + */ + public static String findType(String compnentKey) { + List numberList = Arrays.asList(NUMBERFIELD); + List textList = Arrays.asList(TEXTFIELD); + List selectList = Arrays.asList(SELECTFIELD); + List dataSourceList = Arrays.asList(DATASOURCEFIELD); + List dateList = Arrays.asList(DATEFIELD); + if (numberList.contains(compnentKey)) { + return DataType.NUMBER; + } else if (textList.contains(compnentKey)) { + return DataType.STRING; + } else if (dateList.contains(compnentKey)) { + return DataType.STRING; + } else if (selectList.contains(compnentKey)) { + return DataType.OPTION; + } else if (dataSourceList.contains(compnentKey)) { + return DataType.OPTION; + } else { + return ""; + } + } + + public static String findDataType(String compnentKey) { + List numberList = Arrays.asList(NUMBERFIELD); + List textList = Arrays.asList(TEXTFIELD); + List selectList = Arrays.asList(SELECTFIELD); + List dataSourceList = Arrays.asList(DATASOURCEFIELD); + List dateList = Arrays.asList(DATEFIELD); + if (numberList.contains(compnentKey)) { + return DataType.NUMBER; + } else if (textList.contains(compnentKey)) { + return DataType.STRING; + } else if (dateList.contains(compnentKey)) { + return DataType.STRING; + } else if (selectList.contains(compnentKey)) { + return DataType.OPTION; + } else if (dataSourceList.contains(compnentKey)) { + return DataType.OPTION; + } else { + return DataType.STRING; + } + } + + public static String findTestDataType(String compnentKey) { + List numberList = Arrays.asList(NUMBERFIELD); + List textList = Arrays.asList(TEXTFIELD); + List selectList = Arrays.asList(SELECTFIELD); + List dataSourceList = Arrays.asList(DATASOURCEFIELD); + List dateList = Arrays.asList(DATEFIELD); + if (numberList.contains(compnentKey)) { + return DataType.NUMBER; + } else if (textList.contains(compnentKey)) { + return DataType.STRING; + } else if (dateList.contains(compnentKey)) { + return DataType.DATE; + } else if (selectList.contains(compnentKey)) { + return DataType.OPTION; + } else if (dataSourceList.contains(compnentKey)) { + return DataType.OPTION; + } else { + return DataType.STRING; + } + } + + /** + * 判断变量是否为空 + * + * @param objects + * @return + */ + public static boolean checkIsNull(Object... objects) { + String checkLevel = objects[objects.length - 1].toString(); + List formulavars = new ArrayList<>(); + for (int i = 0; i < objects.length; i++) { + Object object = objects[i]; + if (object instanceof Array) { + Object[] subArray = (Object[]) object; + for (int j = 0; j < subArray.length; j++) { + formulavars.add(subArray[j]); + } + } else { + formulavars.add(object); + } + } + + for (Object object : formulavars) { + switch (checkLevel) { + case CHECKLEVEL_NULL: + if (null == object) { + return true; + } + break; + case CHECKLEVEL_STRING: + if (null == object) { + return true; + } + if (object instanceof String || object instanceof Character) { + if (object.toString().trim().equals("")) { + return true; + } + } + break; + } + + } + return false; + } + + /** + * 替换所有中文参数为Key + * + * @param sql + * @param replaceArray + * @return + */ + public static String replaceAllParam(String sql, String[] replaceArray) { + String partternStr = "\\{.+?\\}{1}?"; + Pattern pt = Pattern.compile(partternStr); + Matcher matcher = pt.matcher(sql); + + int loop = 0; + while (matcher.find()) { + String matherString = matcher.group(); + matherString = matherString.replaceAll("(\\{|\\})", ""); + String replaceStr = replaceArray[loop]; + sql = sql.replaceFirst(matherString, replaceStr); + loop++; + } + return sql; + } + + /** + * 找到聚合函数的条件参数 + * + * @param sql + * @return + */ + public static List findAggParam(String sql) { + List list = new LinkedList<>(); + String partternStr = "(COUNT|SUM|MIN|MAX|AVG){1}\\(+.+?\\)+"; + Pattern pt = Pattern.compile(partternStr); + Matcher matcher = pt.matcher(sql); + while (matcher.find()) { + String aggStr = matcher.group(); + aggStr = aggStr.replaceAll("(COUNT|SUM|MIN|MAX|AVG){1}", ""); + String[] paramArray = aggStr.split(",", 2); + if (paramArray.length == 2) { + String cndParam = paramArray[1]; + cndParam = cndParam.substring(0, cndParam.length() - 1); + list.add(cndParam); + } + } + + + return list; + } + + /** + * 替换聚合函数的条件参数,一般是从规则库返回过来的条件语句 + * + * @param sql + * @param replaceArray + * @return + */ + public static String replaceAggParam(String sql, List replaceArray) { + String partternStr = "(COUNT|SUM|MIN|MAX|AVG){1}\\(.+?\\){1}?"; + Pattern pt = Pattern.compile(partternStr); + Matcher matcher = pt.matcher(sql); + String paramPattStr = "\\(.+?\\){1}?"; + Pattern ppatt = Pattern.compile(paramPattStr); + int loop = 0; + while (matcher.find()) { + String matherString = matcher.group(); + String[] paramStrArray = matherString.replaceAll("(\\(|\\))", "").split(","); + String newmatherString = matherString.replace(paramStrArray[1], "{" + replaceArray.get(loop) + "}"); + sql = sql.replace(matherString, newmatherString); + loop++; + } + return sql; + } + + +// public static void checkParamArrayDataType(List formulavars) { +// for (FormulaVar formulaVar : formulavars) { +// if (formulaVar.getComponentKey() != null && !formulaVar.getComponentKey().equals("")) { +// String componentKey = formulaVar.getComponentKey(); +// Arrays.sort(NUMBERCOMPONENTS); +// int searchIdx = Arrays.binarySearch(NUMBERCOMPONENTS, componentKey); +// if (searchIdx >= 0) { +// formulaVar.setFieldType("Number"); +// } +// Arrays.sort(ReturnType.CHECK_TYPE); +// if (Arrays.binarySearch(ReturnType.CHECK_TYPE, componentKey) >= 0) { +// formulaVar.setFieldType("String"); +// } +// if (formulaVar.getOptionId() != null) { +// formulaVar.setFieldType("String"); +// } +// } +// +// } +// } + + + /** + * 替换语句中的参数为参数列表中的Key + * + * @param sql + * @param formulaVars + * @return + */ +// public static String replaceAllParam(String sql, List formulaVars) { +// if (null == formulaVars) { +// return sql; +// } +// //正则表达式匹配所有用 { } 括号包起来的变量,然后跟参数列表中的参数一一对应做替换 +// String partternStr = "\\{.+?\\}{1}?"; +// Pattern pt = Pattern.compile(partternStr); +// Matcher matcher = pt.matcher(sql); +// +// int loop = 0; +// //替换逻辑 +// while (matcher.find()) { +// String matherString = matcher.group(); +// //替换特殊字符 +// matherString = matherString.replace("{", ""); +// matherString = matherString.replace("}", ""); +// matherString = matherString.replace("(", "\\("); +// matherString = matherString.replace(")", "\\)"); +// matherString = matherString.replaceAll("\\+", "\\\\+"); +// matherString = matherString.replaceAll("\\-", "\\\\-"); +// matherString = matherString.replaceAll("\\*", "\\\\*"); +// matherString = matherString.replaceAll("\\/", "\\\\/"); +// if (formulaVars != null && loop < formulaVars.size()) { +// FormulaVar formulaVar = formulaVars.get(loop); +// //如果参数异常,获取Key为空,根据数据中相应的值做判断,判断是什么类型的控件 +// if (formulaVar.getKey() == null) { +// //表格类型变量替换 +// if (formulaVar.getFormId() != null && formulaVar.getFieldId() == null) { +// sql = sql.replaceFirst(matherString, formulaVar.getFormId().toString()); +// //普通变量的替换 +// } else if (formulaVar.getFormId() != null && formulaVar.getFieldId() != null && formulaVar.getOptionId() == null) { +// sql = sql.replaceFirst(matherString, formulaVar.getFieldId().toString()); +// } else if (formulaVar.getOptionId() != null) { +// //选项型变量的替换是用optionID +// sql = sql.replaceFirst(matherString, formulaVar.getOptionId().toString()); +// } else { +// sql = sql.replaceFirst(matherString, formulaVar.getOptionId().toString()); +// } +// } else { +// //普通变量的替换是用Key +// sql = sql.replaceFirst(matherString, formulaVar.getKey()); +// } +// loop++; +// } +// } +// +// ExcelParamUtil.findAggParam(sql); +// +// if (loop != formulaVars.size()) { +// throw new RuntimeException("参数列表与执行语句不一致"); +// } +// return sql; +// } + + + /** + * 替换参数 + * + * @param sourceString + * @return + */ + public static String replaceParam(String sourceString) { + String formatStr = sourceString.replace(">", ">") + .replace("<", "<"); + return formatStr; + } + + /** + * 过滤 除了数字外的其他参数类型 + * + * @param param + * @return + */ + public static boolean inNumber(Object param) { + boolean r = false; + Class[] paramClasses = new Class[]{Integer.class, Double.class, Float.class, Long.class, Short.class}; + for (int i = 0; i < paramClasses.length; i++) { + if ((param.equals(paramClasses[i].getName())) || (param.equals(getParamType(paramClasses[i].getName())))) { + r = true; + break; + } + } + return r; + } + + /** + * 获取参数名 + * + * @param typeAllName + * @return + */ + public static String getParamType(String typeAllName) { + int fnameIdx = typeAllName.lastIndexOf("."); + typeAllName = typeAllName.substring(fnameIdx + 1); + List numberList = Arrays.asList(numberTypes); + if (typeAllName.equals("Character")) { + return "String"; + } else if (numberList.contains(typeAllName.toLowerCase())) { + return "Number"; + } + return typeAllName; + } + + /** + * 获取参数类型 + * + * @param + * @return + */ + public static String getParamType(Object dataType) { + if (dataType instanceof DataType) { + DataType data = (DataType) dataType; + String filedType = data.getDataType(); + filedType = filedType.toLowerCase(); + + switch (filedType) { + case "number": + filedType = ParamType.DOUBLE.getName(); + break; + case "string": + filedType = ParamType.STRING.getName(); + break; + case "boolean": + filedType = ParamType.BOOLEAN.getName(); + break; + case "select": + filedType = ParamType.STRING.getName(); + break; + case "text": + filedType = ParamType.STRING.getName(); + break; + case "employee": + filedType = ParamType.STRING.getName(); + break; + case "department": + filedType = ParamType.STRING.getName(); + break; + case "integer": + filedType = ParamType.DOUBLE.getName(); + break; + case "double": + filedType = ParamType.DOUBLE.getName(); + break; + case "float": + filedType = ParamType.DOUBLE.getName(); + break; + case "int": + filedType = ParamType.DOUBLE.getName(); + break; + case "long": + filedType = ParamType.DOUBLE.getName(); + break; + case "bigdecimal": + filedType = ParamType.DOUBLE.getName(); + break; + + } + return filedType; + } else { + return getParamType(dataType.getClass().getName()); + } + } + + /** + * 从DataType中获取值 + * + * @param object + * @return + */ + public static List getParamContent(Object object) { + List dataList = new ArrayList<>(); + if (object != null) { + if (object instanceof DataType) { + DataType data = (DataType) object; + dataList.add(getDataTypeContent(data)); + return dataList; + } else if (object instanceof List) { + List sourceDataList = (List) object; + for (Object paramObj : sourceDataList) { + if (paramObj instanceof DataType) { + DataType pramDataType = (DataType) paramObj; + dataList.add(pramDataType.getContent()); + } else { + dataList.add(paramObj); + } + } + return dataList; + } else if (object instanceof Object[]) { + Object[] sourceDataList = (Object[]) object; + for (Object paramObj : sourceDataList) { + if (paramObj instanceof DataType) { + DataType pramDataType = (DataType) paramObj; + dataList.add(pramDataType.getContent()); + } else { + dataList.add(paramObj); + } + } + return dataList; + } else { + dataList.add(object); + return dataList; + } + } + dataList.add(object); + return dataList; + } + + public static Object getDataTypeContent(DataType dataType) { + String properType = ""; + Object content = null; + if (StringUtils.isNotEmpty(dataType.getComponentKey())) { + properType = dataType.getComponentKey(); + } else if (StringUtils.isNotEmpty(dataType.getDataType())) { + properType = dataType.getDataType(); + } + switch (findType(properType)) { + case DataType.NUMBER: + case DataType.STRING: + case DataType.DATE: + content = dataType.getContent(); + break; + case DataType.OPTION: + content = dataType.getContent(); + break; + } + return content; + } + + /** + * 获取JSON的content内容 + * + * @param object + * @return + */ + public static Object getParamContent(Object object, String funcType) { + Object result = null; + if (object instanceof DataType) { + DataType dataType = (DataType) object; + switch (dataType.getDataType()) { + case DataType.DATE: + if (dataType.getContent() == null || dataType.getContent().equals("")) { + return ""; + } + String format = DateUtil.buildFormat(dataType.getContent().toString()); + SimpleDateFormat formatter = new SimpleDateFormat(format); + try { + Date date = formatter.parse(dataType.getContent().toString()); + result = funcType.equalsIgnoreCase("string") ? dataType.getContent() : date.getTime(); + } catch (ParseException e) { + logger.error("err", e); + } + break; + case DataType.NUMBER: + if (null == dataType.getContent() || dataType.getContent().equals("")) { + return 0; + } + if (funcType.equalsIgnoreCase("string")) { + result = dataType.getContent(); + + } else { + if (!RegularUtil.isNumber(dataType.getContent())) { + return 0; + } + if (dataType.getContent().toString().indexOf(".") >= 0) { +// result=Double.parseDouble(dataType.getContent().toString()); + result = new BigDecimal(dataType.getContent().toString()); + } else if (dataType.getContent().toString().length() <= 9) { + result = Integer.parseInt(dataType.getContent().toString()); + } else { + result = Long.parseLong(dataType.getContent().toString()); + } + } + break; + case DataType.STRING: + if (null == dataType.getContent()) { + result = ""; + } else { + result = dataType.getContent().toString().trim(); + } + + break; + case DataType.OPTION: + if (funcType.equalsIgnoreCase("string")) { + if (StringUtils.isNotEmpty(dataType.getOptionContent())) { + result = dataType.getOptionContent(); + } else { + result = ""; + } + + } else { + result = dataType.getContent(); + } + break; + case DataType.BOOL: + result = dataType.getContent(); + break; + default: + if (dataType.getContent() == null) { + return ""; + } + result = dataType.getContent().toString(); + break; + } + } else if (object instanceof Date) { + Date date = (Date) object; + result = date.getTime(); + } else { + if (funcType.equalsIgnoreCase(DataType.BOOL)) { + result = object == null ? false : object; + } else if (object instanceof Boolean) { + result = object; + } else if (object instanceof Integer || object instanceof Double || object instanceof Long || object instanceof BigDecimal) { + result = object; + } else { + result = object == null ? "" : object + ""; + } + + } + return result; + } + + /** + * 获取参数的数据类型,从DataType中获取或者直接获取 + * + * @param object + * @return + */ + public static String checkParamType(Object object) { + String typeName = null; + if (object instanceof DataType) { + DataType dataType = (DataType) object; + typeName = dataType.getDataType(); + } else { + typeName = ExcelParamUtil.getParamType(object.getClass().getName()); + } + return typeName; + } + +// /** +// * 运行公式时的参数设置 +// * +// * @param formulavars +// * @param expressMap +// * @return +// */ +// public static Map buildParam(List formulavars, Map expressMap) { +// checkParamArrayDataType(formulavars);//检查控件类型,设置相应控件对应的数据类型 +// for (FormulaVar formulaVar : formulavars) { +// DataType dataType = new DataType(); +// String key = null; +// if (formulaVar.getFormId() != null && formulaVar.getFieldId() == null) { +// key = "form" + formulaVar.getFormId(); +// } else if (formulaVar.getFieldId() != null && formulaVar.getOptionId() == null) { +// String fieldId = formulaVar.getFieldId().toString(); +// key = "field" + fieldId; +// dataType.setFieldId(fieldId); +// } else if (formulaVar.getOptionId() != null) { +// key = "option" + formulaVar.getOptionId(); +// dataType.setContent(formulaVar.getOptionId()); +// } else { +// key = "option" + formulaVar.getOptionId(); +// } +// +// Arrays.sort(funcArray); +// int sidx = Arrays.binarySearch(funcArray, key); +// if (sidx >= 0) { +// throw new RuntimeException("变量名非法"); +// } +// if (formulaVar.getOptionId() != null) { +// dataType.setDataType(DataType.OPTION); +// } +// if (expressMap.containsKey(key)) { +// String newKey = ExcelParamUtil.randomNumber() + "_" + key; +// expressMap.put(newKey, dataType); +// formulaVar.setKey(newKey); +// } else { +// expressMap.put(key, dataType); +// } +// } +// +// return expressMap; +// } +// +// /*** +// * 验证函数时构建参数设置参数值 +// * 把FormulaVar类型的参数封装成DataType类型参数 +// * @param formulavars 入参类型 +// * @param expressMap 返回Map +// * @return +// */ +// public static Map buildLocalParam(List formulavars, Map expressMap, DataCollectionEmployee employee) { +// +// checkParamArrayDataType(formulavars);//检查控件类型,设置相应控件对应的数据类型 +// for (FormulaVar formulaVar : formulavars) { +// DataType dataType = new DataType(); +// dataType.setScore(0d); +// dataType.setName((null == formulaVar.getName() || formulaVar.getName().equals("")) ? formulaVar.getParent() : formulaVar.getName()); +// dataType.setFieldId(formulaVar.getFieldId() != null ? formulaVar.getFieldId().toString() : null); +// String key = null; +// if (formulaVar.getModule() != null && !formulaVar.getModule().equals("")) { +// try { +// dataType.setModule(formulaVar.getModule()); +// } catch (IllegalArgumentException e) { +// logger.error("err", e); +// dataType.setModule(formulaVar.getModule()); +// } +// } +// dataType.setFormId(formulaVar.getFormId() != null ? Long.parseLong(formulaVar.getFormId()) : null); +// if (formulaVar.getName() != null && formulaVar.getName().equals("当前操作人")) { +// key = formulaVar.getKey(); +// formulaVar.setContent(employee.getUserId().toString()); +// dataType.setContent(formulaVar.getContent()); +// dataType.setText(formulaVar.getContent()); +// dataType.setDataType(DataType.OPTION); +// } else { +// if (formulaVar.getFormId() != null && formulaVar.getFieldId() == null && formulaVar.getOptionId() == null) { +// key = "form" + formulaVar.getFormId().toString(); +// ThreadLocalData threadLocalData = new ThreadLocalData(); +// threadLocalData.setEmployee(employee); +// threadLocalData.setModuleSource(ModuleSource.biaoge); +// ParamContext.get().setValue(formulaVar.getFormId().toString(), threadLocalData); +// } else if (formulaVar.getFieldId() != null && formulaVar.getOptionId() == null) { +// String fieldId = formulaVar.getFieldId().toString(); +// key = "field" + fieldId; +// dataType.setFieldId(fieldId); +// } else if (formulaVar.getOptionId() != null) { +// key = "option" + formulaVar.getOptionId().toString(); +// dataType.setContent(formulaVar.getOptionId()); +// dataType.setText(formulaVar.getName()); +// dataType.setFormId(null); +// } else { +// key = "option" + formulaVar.getOptionId().toString(); +// } +// } +// +// Arrays.sort(funcArray); +// int sidx = Arrays.binarySearch(funcArray, key); +// if (sidx >= 0) { +// throw new RuntimeException("变量名非法"); +// } +// if (formulaVar.getOptionId() != null) { +// dataType.setDataType(DataType.OPTION); +// } +// +// if (StringUtils.isEmpty(dataType.getDataType())) { +// String typeKey = null; +// if (StringUtils.isNotEmpty(formulaVar.getFieldType())) { +// typeKey = formulaVar.getFieldType(); +// } else if (StringUtils.isNotEmpty(formulaVar.getType())) { +// typeKey = formulaVar.getType(); +// } else if (StringUtils.isNotEmpty(formulaVar.getFieldType())) { +// typeKey = formulaVar.getFieldType(); +// } +// dataType.setDataType(ExcelParamUtil.findTestDataType(typeKey)); +// } +// if (StringUtils.isEmpty(dataType.getComponentKey())) { +// dataType.setComponentKey(formulaVar.getComponentKey()); +// } +// if (expressMap.containsKey(key)) { +// String newKey = key + ExcelParamUtil.randomNumber(); +// formulaVar.setKey(newKey); +// dataType.setAggCndKey(key); +// expressMap.put(newKey, dataType); +// } else { +// expressMap.put(key, dataType); +// } +// } +// +// return expressMap; +// } + + /** + * 格式化变量为数字 + * + * @param + */ + public static Object convertParamValToNumber(Object op1) { + BigDecimal oop1 = new BigDecimal(ExcelParamUtil.getParamContent(op1, "string").toString()); + return oop1; + } + + /** + * 格式化参数 + * + * @param op1 + * @param op2 + * @return + */ + public static List converParamValue(Object op1, Object op2) { + List list = new ArrayList<>(); + + + if (op1 instanceof DataType) { + list.add(op1); + DataType op1Data = (DataType) op1; + if (!(op2 instanceof DataType) && op1Data.getDataType().toLowerCase().equals("date")) { + DataType dataType = new DataType(); + dataType.setDataType(DataType.STRING); + dataType.setContent(op2); + list.add(dataType); + } else if (op2 instanceof DataType && op1Data.getDataType().toLowerCase().equals("date")) { + DataType dataType = (DataType) op2; + dataType.setDataType(DataType.STRING); + list.add(dataType); + } else { + list.add(op2); + } + + } else if (op2 instanceof DataType) { + DataType op2Data = (DataType) op2; + if (!(op1 instanceof DataType) && op2Data.getDataType().toLowerCase().equals("date")) { + DataType dataType = new DataType(); + dataType.setDataType(DataType.STRING); + dataType.setContent(op1); + list.add(dataType); + } else if (op1 instanceof DataType && op2Data.getDataType().toLowerCase().equals("date")) { + DataType dataType = (DataType) op1; + dataType.setDataType(DataType.STRING); + list.add(dataType); + } else { + list.add(op1); + } + list.add(op2); + } else { + list.add(op1); + list.add(op2); + } + + return list; + } + + /** + * 统一处理参数类型不一致问题 + * + * @param typeName + * @return + */ + public static String checkParamType(String typeName) { + typeName = typeName.toLowerCase(); + switch (typeName) { + case "option": + typeName = ParamType.STRING.getName(); + break; + case "date": + typeName = DataType.STRING; + break; + case "number": + typeName = DataType.NUMBER; + break; + case "string": + typeName = ParamType.STRING.getName(); + break; + case "boolean": + typeName = ParamType.BOOLEAN.getName(); + break; + case "select": + typeName = ParamType.STRING.getName(); + break; + case "text": + typeName = ParamType.STRING.getName(); + break; + case "employee": + typeName = ParamType.STRING.getName(); + break; + case "department": + typeName = ParamType.STRING.getName(); + break; + case "integer": + typeName = DataType.NUMBER; + break; + case "double": + typeName = DataType.NUMBER; + break; + case "float": + typeName = DataType.NUMBER; + break; + case "int": + typeName = DataType.NUMBER; + break; + case "long": + typeName = DataType.NUMBER; + break; + case "bigdecimal": + typeName = DataType.NUMBER; + break; + + } + return typeName; + } + + public static String getKeyString(Object obj) { + if (obj instanceof JSONObject) { + JSONObject jsonObject = (JSONObject) obj; + return jsonObject.getString("key"); + } else { + return obj.toString(); + } + } + + /** + * 替换变量的错误位置 + * + * @param startIdx + * @param endIdx + * @param excuteStr + */ + public static Map replaceErrorPlace(int startIdx, int endIdx, String errorFunc, String excuteStr, Map paramMap) { + Map kvMap = loopMap(paramMap); + Map replaceMap = new HashMap<>(); + String excuteLeftStr = excuteStr.substring(0, startIdx); + if (!excuteLeftStr.equals("")) { + Iterator wordItaretor = kvMap.keySet().iterator(); + while (wordItaretor.hasNext()) { + String key = wordItaretor.next(); + String name = kvMap.get(key); + if (excuteLeftStr.indexOf(key) >= 0) { + String newStr = excuteLeftStr.replaceAll(key, name); + startIdx = startIdx - (excuteLeftStr.length() - newStr.length()); + } + } + + } + if (kvMap.get(errorFunc) != null) { + endIdx = startIdx + kvMap.get(errorFunc).length() - 1; + } else { + endIdx = startIdx + errorFunc.length() - 1; + } + + replaceMap.put("startIdx", startIdx); + replaceMap.put("endIdx", endIdx); + return replaceMap; + } + + public static Map loopMap(Map paramMap) { + Map kvMap = new HashMap<>(); + + Set set = paramMap.keySet(); + Iterator iterator = set.iterator(); + while (iterator.hasNext()) { + String key = iterator.next(); + DataType dataType = (DataType) paramMap.get(key); + kvMap.put(key, dataType.getName()); + } + return kvMap; + } + + public static boolean isNumber(Object object) { + String type = ExcelParamUtil.getParamType(object.getClass().getName()); + Arrays.sort(numberTypes); + if (Arrays.binarySearch(numberTypes, type) >= 0) { + return true; + } + return false; + } + + public static String randomNumber() { + int max = 1000, min = 1; + long randomNum = System.currentTimeMillis(); + int ran3 = (int) (randomNum % (max - min) + min); + return ran3 + ""; + } + + /** + * 长度不够则添加元素的字符串拼接 + * + * @param chars 将要拼接的字符 + * @param sourceStr 源字符 + * @param targetLength 目标字符长度 + * @param place 位置在左还是右 + * @return + */ + public static String appendString(String chars, String sourceStr, int targetLength, String place) { + StringBuilder builder = new StringBuilder(sourceStr); + + while (true) { + //长度相等,不做处理 + if (builder.length() == targetLength) { + break; + } else if (builder.length() > targetLength) { + //源字符长度大于目标长度则截取 + int length = builder.length() - targetLength; + + if ("LEFT".equals(place)) { + String tempStr = builder.substring(length, builder.length()); + builder.replace(0, builder.length(), tempStr); + } else { + String tempStr = builder.substring(0, targetLength); + builder.replace(0, builder.length(), tempStr); + } + break; + } + + //源字符长度小于目标长度则不断拼接 + if ("LEFT".equals(place)) { + builder.insert(0, chars.replaceAll(",", "")); + } else { + builder.append(chars.replaceAll(",", "")); + } + } + return builder.toString(); + } + +// public static FormulaVar getFixFieldVar(List list, String key) { +// FormulaVar formulaVar = new FormulaVar(); +// for (FixedField fixedField : list) { +// if (fixedField.getKey().equals(key)) { +// Component component = (Component) fixedField.getMatchs().get(0); +// ComponentType componentType = component.getComponentKey(); +// if (componentType.equals(ComponentType.Text)) { +// +// } +// } +// } +// return formulaVar; +// } + + public static String findAggCndStr(String sql, Map paramMap) { + String partternStr = "(COUNT|SUM|MIN|MAX|AVG|count|sum|min|max)+\\(+(.)+\\)+"; + Pattern pattern = Pattern.compile(partternStr); + Matcher matcher = pattern.matcher(sql); + int i = 0; + while (matcher.find()) { + String cnd = matcher.group(); + String[] cndArray = cnd.split(",", 2); + if (cndArray.length == 2) { + String realCnd = cndArray[1].substring(0, cndArray[1].length() - 1); + String key = "cnd" + i + Math.abs(realCnd.hashCode()) + ""; + sql = sql.replace(realCnd, key); + realCnd = realCnd.replace("{", ""); + realCnd = realCnd.replace("}", ""); + paramMap.put(key, realCnd); + } + i++; + } + return sql; + } + + + /** + * 执行语句的断句算法,通过计算小括号的数量进行断句断点的确定,然后拆分语句 + * + * @param sql + */ + public static String spliteSql(String sql, Map paramMap) { + List strList = new ArrayList<>(); + int pointIdx = 0; + char[] charArray = sql.toCharArray(); + int leftBrakets = 0; + char brackeLeft = '('; + char brackeRight = ')'; + boolean find = false; + for (int i = 0; i < charArray.length; i++) { + char charstr = charArray[i]; + if (charstr == brackeLeft) { + find = true; + leftBrakets++; + } + if (leftBrakets != 0 && charstr == brackeRight) { + leftBrakets--; + } + if (find && leftBrakets == 0) { + pointIdx = i; + break; + } + } + pointIdx += 1; + if (pointIdx == sql.length()) { + strList.add(sql.substring(0, pointIdx)); + } else { + strList.add(sql.substring(0, pointIdx)); + strList.add(sql.substring(pointIdx)); + } + String replaceSql = ""; + for (String s : strList) { + String[] cndArray = s.split("(COUNT|SUM|MIN|MAX|count|sum|min|max)"); + if (cndArray.length == 2) { + if (cndArray[0].equals("")) { + replaceSql += findAggCndStr(s, paramMap); + } else { + String realCnd = s.substring(cndArray[0].length() - 1 >= 0 ? cndArray[0].length() : 0); + replaceSql += cndArray[0] + findAggCndStr(realCnd, paramMap); + } + + } else { + replaceSql += findAggCndStr(s, paramMap); + } + + } + sql = replaceSql; + return sql; + } + +} diff --git a/src/com/engine/salary/formlua/util/ExcelResult.java b/src/com/engine/salary/formlua/util/ExcelResult.java new file mode 100644 index 000000000..aaf70d575 --- /dev/null +++ b/src/com/engine/salary/formlua/util/ExcelResult.java @@ -0,0 +1,36 @@ +package com.engine.salary.formlua.util; + +import java.io.Serializable; + +/** + * @author + */ +public class ExcelResult implements Serializable { + private Object data; + private int code; + private String errorInfo; + + public Object getData() { + return data; + } + + public void setData(Object data) { + this.data = data; + } + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public String getErrorInfo() { + return errorInfo; + } + + public void setErrorInfo(String errorInfo) { + this.errorInfo = errorInfo; + } +} diff --git a/src/com/engine/salary/formlua/util/ExcelStandardUtil.java b/src/com/engine/salary/formlua/util/ExcelStandardUtil.java new file mode 100644 index 000000000..fc6e95fab --- /dev/null +++ b/src/com/engine/salary/formlua/util/ExcelStandardUtil.java @@ -0,0 +1,492 @@ +//package com.engine.salary.formlua.util; +// +// +//import com.alibaba.fastjson.JSON; +//import com.weaver.common.form.component.base.ComponentType; +//import com.weaver.excel.formula.api.entity.DataOption; +//import com.weaver.excel.formula.api.entity.FormulaVar; +//import com.weaver.excel.formula.entity.parameter.DataType; +//import com.weaver.excel.formula.entity.parameter.ParamFactory; +//import com.weaver.excel.formula.entity.standard.front.CurrentVar; +//import com.weaver.teams.domain.user.DataCollectionEmployee; +//import com.weaver.teams.util.StringUtils; +//import org.slf4j.Logger; +//import org.slf4j.LoggerFactory; +// +//import java.util.HashMap; +//import java.util.List; +//import java.util.Map; +//import java.util.regex.Matcher; +//import java.util.regex.Pattern; +// +//public class ExcelStandardUtil { +// protected static final Logger logger = LoggerFactory.getLogger(ExcelStandardUtil.class); +// +// public static Map replaceAllParam(String sql, List localVars,List dataVars, DataCollectionEmployee employee){ +// if(null!=localVars){ +// for (FormulaVar formulaVar:localVars){ +// if(StringUtils.isNotEmpty(formulaVar.getDataId()) && StringUtils.isEmpty(formulaVar.getFormId())){ +// formulaVar.setFormId(formulaVar.getDataId()); +// } +// if(StringUtils.isNotEmpty(formulaVar.getId()) && formulaVar.getId().equalsIgnoreCase("current_department")){ +// formulaVar.setType("department"); +// formulaVar.setComponentKey(ComponentType.Department.toString()); +// } +// if(StringUtils.isNotEmpty(formulaVar.getId()) && formulaVar.getId().equalsIgnoreCase("current_superior")){ +// formulaVar.setType("employee"); +// formulaVar.setComponentKey(ComponentType.Employee.toString()); +// } +// } +// } +// +// Map dataMap=new HashMap<>(); +// Map paramKeyMap=new HashMap<>(); +// //正则表达式匹配所有用 { } 括号包起来的变量,然后跟参数列表中的参数一一对应做替换 +// String partternStr="\\{.+?\\}{1}?"; +// Pattern pt=Pattern.compile(partternStr); +// Matcher matcher=pt.matcher(sql); +// +// int loop=0; +// //替换逻辑 +// while (matcher.find()){ +// String matherString=matcher.group(); +// //替换特殊字符 +// matherString=matherString.replace("{",""); +// matherString=matherString.replace("}",""); +// matherString=matherString.replace("(","\\("); +// matherString=matherString.replace(")","\\)"); +// matherString=matherString.replaceAll("\\+","\\\\+"); +// matherString=matherString.replaceAll("\\-","\\\\-"); +// matherString=matherString.replaceAll("\\*","\\\\*"); +// matherString=matherString.replaceAll("\\/","\\\\/"); +// if(localVars!=null&&loop"+JSON.toJSONString(dataType)); +// } +// }else{ +// String typeKey=localFormulaVar.getProperKey(); +// if(StringUtils.isNotEmpty(localFormulaVar.getFieldType())){ +// typeKey=localFormulaVar.getFieldType(); +// }else if(StringUtils.isNotEmpty(localFormulaVar.getType())){ +// typeKey=localFormulaVar.getType(); +// }else if(StringUtils.isNotEmpty(localFormulaVar.getFieldType())){ +// typeKey=localFormulaVar.getFieldType(); +// localFormulaVar.setComponentKey(localFormulaVar.getFieldType()); +// } +// dataType.setDataType(ExcelParamUtil.findDataType(typeKey)); +// dataType.setFieldId(localFormulaVar.getFieldId()); +// dataType.setFormId(StringUtils.isNotEmpty(localFormulaVar.getFormId())?Long.parseLong(localFormulaVar.getFormId()):null); +// try { +// dataType.setModule(localFormulaVar.getModule()); +// } catch (IllegalArgumentException e) { +// logger.error("err",e); +// dataType.setModule(localFormulaVar.getModule()); +// } +// dataType.setContent(""); +// if(!paramKeyMap.containsKey(key)){ +// paramKeyMap.put(key,dataType); +// }else{ +// logger.info("存在同名参数:"+key+"-->"+JSON.toJSONString(dataType)); +// } +// } +// } +// loop++; +// } +// } +//// if(loop!=localVars.size()){ +//// throw new RuntimeException("参数列表与执行语句不一致"); +//// } +// dataMap.put("param",paramKeyMap); +// dataMap.put("sql",sql); +// return dataMap; +// } +// +// public static Map replaceAllParamForTest(String sql, List formulaVars, DataCollectionEmployee employee){ +// if(null==formulaVars){ +// return null; +// } +// for (FormulaVar formulaVar:formulaVars){ +// if(StringUtils.isNotEmpty(formulaVar.getDataId()) && StringUtils.isEmpty(formulaVar.getFormId())){ +// formulaVar.setFormId(formulaVar.getDataId()); +// if(StringUtils.isNotEmpty(formulaVar.getType()) && StringUtils.isEmpty(formulaVar.getComponentKey())){ +// if(formulaVar.getType().equalsIgnoreCase("operator") || formulaVar.getType().equalsIgnoreCase("employee")){ +// formulaVar.setComponentKey(""); +// } +// } +// } +// if(StringUtils.isNotEmpty(formulaVar.getId()) && formulaVar.getId().equalsIgnoreCase("current_department")){ +// formulaVar.setType("department"); +// formulaVar.setComponentKey("Department"); +// } +// if(StringUtils.isNotEmpty(formulaVar.getId()) && formulaVar.getId().equalsIgnoreCase("current_superior")){ +// formulaVar.setType("employee"); +// formulaVar.setComponentKey("Employee"); +// } +// } +// Map dataMap=new HashMap<>(); +// Map paramKeyMap=new HashMap<>(); +// //正则表达式匹配所有用 { } 括号包起来的变量,然后跟参数列表中的参数一一对应做替换 +// String partternStr="\\{.+?\\}{1}?"; +// Pattern pt=Pattern.compile(partternStr); +// Matcher matcher=pt.matcher(sql); +// +// int loop=0; +// //替换逻辑 +// while (matcher.find()){ +// String matherString=matcher.group(); +// //替换特殊字符 +// matherString=matherString.replace("{",""); +// matherString=matherString.replace("}",""); +// matherString=matherString.replace("(","\\("); +// matherString=matherString.replace(")","\\)"); +// matherString=matherString.replaceAll("\\+","\\\\+"); +// matherString=matherString.replaceAll("\\-","\\\\-"); +// matherString=matherString.replaceAll("\\*","\\\\*"); +// matherString=matherString.replaceAll("\\/","\\\\/"); +// if(formulaVars!=null&&loop dataVars,DataCollectionEmployee employee){ +// DataType dataType =new DataType(); +// if(localFormulaVar == null){ +// return null; +// } +// +// String typeKey=localFormulaVar.getProperKey(); +// if(StringUtils.isNotEmpty(localFormulaVar.getFieldType())){ +// typeKey=localFormulaVar.getFieldType(); +// }else if(StringUtils.isNotEmpty(localFormulaVar.getType())){ +// typeKey=localFormulaVar.getType(); +// }else if(StringUtils.isNotEmpty(localFormulaVar.getFieldType())){ +// typeKey=localFormulaVar.getFieldType(); +// localFormulaVar.setComponentKey(localFormulaVar.getFieldType()); +// } +// logger.info(localFormulaVar.getId()+"typeKey=:"+typeKey); +// switch (ExcelParamUtil.findDataType(typeKey)){ +// case DataType.DATE: +// dataType.setDataType(DataType.STRING); +// setContent(dataType,typeKey,localFormulaVar.getFieldId(),dataVars,"field"); +// if(dataType.getContent()==null){ +// dataType.setContent(""); +// } +// break; +// case DataType.STRING: +// dataType.setDataType(DataType.STRING); +// setContent(dataType,typeKey,localFormulaVar.getFieldId(),dataVars,"field"); +// if(dataType.getContent()==null){ +// dataType.setContent(""); +// } +// break; +// case DataType.NUMBER: +// dataType.setDataType(DataType.NUMBER); +// setContent(dataType,typeKey,localFormulaVar.getFieldId(),dataVars,"field"); +// break; +// case DataType.OPTION: +// logger.info("函数构建选项型:"+JSON.toJSONString(localFormulaVar)); +// dataType.setDataType(DataType.OPTION); +// setContent(dataType,typeKey,localFormulaVar.getFieldId(),dataVars,"option"); +// if(dataType.getContent() == null){ +// dataType.setContent(localFormulaVar.getId()!=null?localFormulaVar.getId():localFormulaVar.getOptionId()); +// dataType.setText(dataType.getContent()+""); +// } +// //当前操作人赋值 +// if(localFormulaVar.getId()!=null){ +// switch (localFormulaVar.getId()){ +// case "current_user": +// dataType.setContent(employee.getId()); +// dataType.setOptionContent(employee.getName()); +// break; +// case "current_superior": +// dataType.setContent(employee.getSuperiorId()); +// break; +// case "current_department": +// dataType.setContent(employee.getDepartmentId()); +// break; +// case "current_position": +// dataType.setContent(employee.getPositionId()); +// break; +// default: +// break; +// } +// logger.info("当前操作人赋值完成:"+JSON.toJSONString(dataType)); +// } +// break; +// case DataType.DATASOURCE: +// dataType.setDataType(DataType.DATASOURCE); +// setContent(dataType,typeKey,localFormulaVar.getFieldId(),dataVars,"option"); +// break; +// default: +// logger.info("未匹配到参数类型:"+(JSON.toJSONString(localFormulaVar))); +// break; +// } +// if(StringUtils.isNotEmpty(localFormulaVar.getDataType())){ +// dataType.setDataType(localFormulaVar.getDataType()); +// } +// if(StringUtils.isEmpty(dataType.getComponentKey())){ +// if(StringUtils.isNotEmpty(localFormulaVar.getFieldType())){ +// dataType.setComponentKey(localFormulaVar.getFieldType()); +// }else if(StringUtils.isNotEmpty(localFormulaVar.getProperKey())){ +// dataType.setComponentKey(localFormulaVar.getProperKey()); +// }else if(StringUtils.isNotEmpty(localFormulaVar.getComponentKey())){ +// dataType.setComponentKey(localFormulaVar.getComponentKey()); +// } +// } +// dataType.setFieldId(localFormulaVar.getFieldId()+""); +// dataType.setFormId(localFormulaVar.getFormId()!=null?Long.parseLong(localFormulaVar.getFormId()):null); +// dataType.setEmployee(employee); +// if(StringUtils.isNotEmpty(localFormulaVar.getModule())){ +// try { +// dataType.setModule(localFormulaVar.getModule()); +// } catch (IllegalArgumentException e) { +// logger.error("err",e); +// dataType.setModule(localFormulaVar.getModule()); +// } +// } +// dataType.setName(localFormulaVar.getTitle()!=null?localFormulaVar.getTitle():localFormulaVar.getName()); +// logger.info("构建值完毕:"+JSON.toJSONString(dataType)); +// return dataType; +// } +// private static void setContent(DataType dataType,String typeKey,String sourceVar,List targetVarList,String type){ +// if(sourceVar==null){ +// return ; +// } +// for (FormulaVar loopVar:targetVarList){ +// switch (type){ +// case "field": +// if(sourceVar.equalsIgnoreCase(loopVar.getFieldId())){ +// dataType.setContent(loopVar.getContent()!=null?loopVar.getContent():""); +// dataType.setText(dataType.getContent()+""); +// if(StringUtils.isNotEmpty(loopVar.getsFormId())){ +// dataType.setSubFormId(Long.parseLong(loopVar.getsFormId())); +// } +// dataType.setComponentKey(loopVar.getComponentKey()); +// }else{ +// dataType.setComponentKey(typeKey); +// } +// break; +// case "form": +// if(sourceVar.equalsIgnoreCase(loopVar.getFormId())){ +// dataType.setContent(loopVar.getContent()); +// } +// break; +// case "option": +// if(sourceVar.equalsIgnoreCase(loopVar.getFieldId())){ +// dataType.setContent(loopVar.getContent()); +// if(dataType.getContent()==null){ +// dataType.setContent(loopVar.getOptionId()); +// dataType.setText(loopVar.getOptionId()); +// } +// //常量 +// if(StringUtils.isNotEmpty(loopVar.getOptionContent())){ +// dataType.setOptionContent(loopVar.getOptionContent()); +// }else if(loopVar.getDataOptionList()!=null && loopVar.getDataOptionList().size()>0){ +// String optionContents=""; +// List dataOptions=loopVar.getDataOptionList(); +// for(DataOption dataOption:dataOptions){ +// optionContents+=dataOption.getOptionContent()+","; +// } +// if(optionContents.lastIndexOf(",")>0){ +// optionContents=optionContents.substring(0,optionContents.lastIndexOf(",")); +// } +// dataType.setOptionContent(optionContents); +// }else {//变量 +// dataType.setOptionContent(loopVar.getContent()); +// } +// +// dataType.setScore(loopVar.getScore()); +// if(StringUtils.isNotEmpty(loopVar.getsFormId())){ +// dataType.setSubFormId(Long.parseLong(loopVar.getsFormId())); +// } +// dataType.setComponentKey(loopVar.getComponentKey()); +// } +// break; +// default: +// break; +// } +// } +// } +//} diff --git a/src/com/engine/salary/formlua/util/ExpressRegularUtil.java b/src/com/engine/salary/formlua/util/ExpressRegularUtil.java new file mode 100644 index 000000000..7a31f2fe1 --- /dev/null +++ b/src/com/engine/salary/formlua/util/ExpressRegularUtil.java @@ -0,0 +1,234 @@ +package com.engine.salary.formlua.util; + +import com.alibaba.fastjson.JSONObject; +import com.engine.salary.formlua.entity.parameter.FormulaContext; +import org.apache.commons.lang3.StringUtils; + +import java.util.HashMap; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import java.util.regex.PatternSyntaxException; + + +public class ExpressRegularUtil { + private static final String[] checkRegularNullParameter = new String[]{"TRUE", "FALSE", "NOW", "TODAY"}; + private static final String[] operSymbs = new String[]{">", ">=", "=", "<", "<=", "\\+", "-", "\\*", "\\/", "!="}; + private static final String checkRegularParameter = "AND|OR|IF|NOT|LIKE|DATEDIFF|DATEADD|WEEKNUM|WEEKDAY|DATEFORMAT|Y|M|D|H|I|S|COUNT|SUM|MAX|MIN|CONCAT|SEARCH|TEXT|PAD|REPLACE|VALUE|LEN|LEFT|RIGHT|MID"; + private final static String leftCircleBracket = "Unmatched closing '('"; + private final static String rightCircleBracket = "Unmatched closing ')'"; + private final static String leftSquareBracket = "Unmatched closing '['"; + private final static String rightSquareeBracket = "Unmatched closing ']'"; + private final static String leftBigBracket = "Unmatched closing '{'"; + private final static String rightBigBracket = "Unmatched closing '}'"; + + public static boolean checkFuncExpress(String str) { + filter(str); + return true; + } + + public static boolean isContainChinese(String str) { + Pattern p = Pattern.compile("[\u4E00-\u9FA5|\\!|\\,|\\。|\\(|\\)|\\《|\\》|\\“|\\”|\\?|\\:|\\;|\\【|\\】]"); + Matcher m = p.matcher(str); + if (m.find()) { + return true; + } + return false; + } + + private static void filter(String formula) { + try { + testSymbol(formula); + checkNullRegular(formula); + checkOperatorNullParam(formula); + formula = formula.replaceAll("", "#"); + String leftReplace = ""; + String rightReplace = ""; + leftReplace = formula.replaceAll("\\(", ""); + rightReplace = formula.replaceAll("\\)", ""); + if (leftReplace.length() > rightReplace.length()) { + PatternSyntaxException patternSyntaxException = new PatternSyntaxException(leftCircleBracket, formula, formula.lastIndexOf(")")); + throw patternSyntaxException; + } + if (leftReplace.length() < rightReplace.length()) { + PatternSyntaxException patternSyntaxException = new PatternSyntaxException(rightCircleBracket, formula, formula.indexOf("(")); + throw patternSyntaxException; + } + + leftReplace = formula.replaceAll("\\{", ""); + rightReplace = formula.replaceAll("}", ""); + if (leftReplace.length() > rightReplace.length()) { + PatternSyntaxException patternSyntaxException = new PatternSyntaxException(leftBigBracket, formula, formula.lastIndexOf("}")); + throw patternSyntaxException; + } + if (leftReplace.length() < rightReplace.length()) { + PatternSyntaxException patternSyntaxException = new PatternSyntaxException(rightBigBracket, formula, formula.indexOf("{")); + throw patternSyntaxException; + } + + leftReplace = formula.replaceAll("\\[", ""); + rightReplace = formula.replaceAll("]", ""); + if (leftReplace.length() > rightReplace.length()) { + PatternSyntaxException patternSyntaxException = new PatternSyntaxException(leftSquareBracket, formula, formula.lastIndexOf("]")); + throw patternSyntaxException; + } + if (leftReplace.length() < rightReplace.length()) { + PatternSyntaxException patternSyntaxException = new PatternSyntaxException(rightSquareeBracket, formula, formula.indexOf("[")); + throw patternSyntaxException; + } + + } catch (PatternSyntaxException e) { + String error = e.getDescription().trim(); + int errorIdx = e.getIndex(); + int errorEndIdx = -1; + switch (error) { + case leftCircleBracket: + error = "'('括号没有找到"; + errorEndIdx = -1; + break; + case rightCircleBracket: + error = "'('括号没有闭合"; + errorEndIdx = -1; + break; + case leftSquareBracket: + error = "'['括号没有找到"; + errorEndIdx = -1; + break; + case rightSquareeBracket: + error = "'['括号没有闭合"; + errorEndIdx = -1; + break; + case leftBigBracket: + error = "'{'括号没有找到"; + errorEndIdx = -1; + break; + case rightBigBracket: + error = "'{'括号没有闭合"; + errorEndIdx = -1; + break; + case "TRUE函数不能有参数": + errorEndIdx = errorIdx + 4; + break; + case "FALSE函数不能有参数": + errorEndIdx = errorIdx + 5; + break; + case "NOW函数不能有参数": + errorEndIdx = errorIdx + 3; + break; + case "TODAY函数不能有参数": + errorEndIdx = errorIdx + 5; + break; + + } + JSONObject catchJson = null; + if (errorEndIdx < 0) { + catchJson = ErrorUtil.buildError(formula, errorIdx + 1, null, error); + } else { + catchJson = ErrorUtil.buildError(formula, errorIdx + 1, errorEndIdx, null, error); + } + + catchJson.put("formula", formula); + throw new PatternSyntaxException(catchJson.toJSONString(), null, errorIdx + 1); + } + } + + private static void checkNullRegular(String formula) { + String filterPattern = null; + for (int i = 0; i < checkRegularNullParameter.length; i++) { + int eidx = formula.indexOf(checkRegularNullParameter[i]); + if (eidx >= 0) { + if (FormulaContext.get().getValue(checkRegularNullParameter[i]) != null) { + Integer paramCount = FormulaContext.get().getValue(checkRegularNullParameter[i]); + paramCount++; + FormulaContext.get().setValue(checkRegularNullParameter[i]); + } else { + FormulaContext.get().setValue(checkRegularNullParameter[i]); + } + filterPattern = checkRegularNullParameter[i] + "{1}\\({1}\\){1}"; + Pattern pattern = Pattern.compile(filterPattern); + Matcher matcher = pattern.matcher(formula); + boolean excuteBool = matcher.find(); + if (!excuteBool) { + eidx = 0; + Integer errorCount = FormulaContext.get().getFormulaJson().getInteger(checkRegularNullParameter[i]); + String[] errorCutArray = formula.split(checkRegularNullParameter[i]); + for (int fi = 0; fi < errorCount; fi++) { + eidx += errorCutArray[fi].length(); + if (errorCutArray.length > 1 && fi > 0) { + eidx += checkRegularNullParameter[i].length(); + } + } + PatternSyntaxException patternSyntaxException = new PatternSyntaxException(checkRegularNullParameter[i] + "函数不能有参数", formula, eidx); + throw patternSyntaxException; + } + } else { + + } + } + } + + private static void checkOperatorNullParam(String formula) { + formula = formula.trim(); + JSONObject errorJson = new JSONObject(); + Map operMap = new HashMap<>(); + + for (int i = 0; i < operSymbs.length; i++) { + String operSymb = operSymbs[i]; + if (formula.indexOf(operSymb) < 0) { + continue; + } + if (operMap.get(operSymb) == null) { + operMap.put(operSymb, 1); + } else { + operMap.put(operSymb, operMap.get(operSymb) + 1); + } + String commonP = "(" + operSymb + ")"; + Pattern wrongPone = Pattern.compile("^.+" + commonP + "+?$"); + Pattern wrongPtwo = Pattern.compile("^" + commonP + "+?.+$"); + Pattern wrongPthree = Pattern.compile("^" + commonP + "+?$"); + + Matcher m = wrongPone.matcher(formula); + + if (m.find()) { + errorJson = ErrorUtil.buildError(operSymb, formula.length(), operMap.get(operSymb), "操作符两端的参数不能为空"); + throw new RuntimeException(errorJson.getString("msg")); + } + + Matcher mtwo = wrongPtwo.matcher(formula); + if (mtwo.find()) { + //-,负数特殊处理 + if (StringUtils.equals(operSymb, "-")) { + return; + } + errorJson = ErrorUtil.buildError(operSymb, 1, operMap.get(operSymb), "操作符两端的参数不能为空"); + throw new RuntimeException(errorJson.getString("msg")); + } + + Matcher mthree = wrongPthree.matcher(formula); + if (mthree.find()) { + errorJson = ErrorUtil.buildError(operSymb, 1, operMap.get(operSymb), "操作符两端的参数不能为空"); + throw new RuntimeException(errorJson.getString("msg")); + } + + } + + + } + + public static void testSymbol(String formula) { + Pattern pattern = Pattern.compile(",+?\\s*\\)"); + Matcher m = pattern.matcher(formula); + if (m.find()) { + int idx = formula.indexOf(m.group()); + PatternSyntaxException patternSyntaxException = new PatternSyntaxException("参数格式错误", formula, idx); + throw patternSyntaxException; + } + } + + public static void main(String args[]) { + + checkOperatorNullParam(" abc>="); + } + + +} diff --git a/src/com/engine/salary/formlua/util/IgnoreFilter.java b/src/com/engine/salary/formlua/util/IgnoreFilter.java new file mode 100644 index 000000000..a5ab03f14 --- /dev/null +++ b/src/com/engine/salary/formlua/util/IgnoreFilter.java @@ -0,0 +1,21 @@ +package com.engine.salary.formlua.util; + +import java.util.LinkedList; +import java.util.List; + + +public class IgnoreFilter { + private static List list=new LinkedList(); + public static boolean contains(String key){ + list.add("formId"); + return list.contains(key); + } + public static boolean containsFixedKey(String key){ + list.add("operators"); + list.add("names"); + list.add("createTimes"); + list.add("types"); + list.add("datastatus"); + return list.contains(key); + } +} diff --git a/src/com/engine/salary/formlua/util/IgnoreParamFilter.java b/src/com/engine/salary/formlua/util/IgnoreParamFilter.java new file mode 100644 index 000000000..b8db227e4 --- /dev/null +++ b/src/com/engine/salary/formlua/util/IgnoreParamFilter.java @@ -0,0 +1,766 @@ +package com.engine.salary.formlua.util; + +import com.alibaba.fastjson.JSONObject; +import com.engine.salary.formlua.core.exception.ErrorType; +import com.engine.salary.formlua.entity.parameter.DataType; +import com.engine.salary.formlua.entity.parameter.FormulaContext; +import com.engine.salary.formlua.entity.parameter.FuncNames; +import com.weaver.esb.server.enums.ParamType; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.*; + + +public class IgnoreParamFilter { + protected static final Logger logger = LoggerFactory.getLogger(IgnoreParamFilter.class); + private static JSONObject errorJson = null; + private static String[] dateFuncs = new String[]{"YEAR", "MONTH", "DAY", "HOUR", "MINUTE", "SECOND"}; + private static String[] numberOperArray = new String[]{">", "<", ">=", "<="}; + + public static void main(String[] args) throws Exception { + DataType dataType = new DataType(); + dataType.setDataType(DataType.NUMBER); + dataType.setContent(0.0); +// DataType dataType2=new DataType(); +// dataType2.setDataType(DataType.STRING); +// DataType dataType3=new DataType(); +// dataType3.setDataType(DataType.STRING); + + filterCompareFunc("", 0.5); + } + + /** + * 判断是人员参数 + * + * @param object + * @return + */ + public static boolean isEmployee(Object object) { +// if (object instanceof DataType) { +// DataType dataType = (DataType) object; +// if (dataType.getComponentKey() != null && dataType.getComponentKey().equalsIgnoreCase(ComponentType.Employee.toString())) { +// return true; +// } +// } + return false; + } + + /** + * 通用的校验参数类型一致的方法 + * + * @param objects + * @return + */ + public static boolean checkType(Object... objects) { + if (objects == null || objects.length == 0) { + return true; + } + Map typeCheckMap = new HashMap<>(); + int i; + for (i = 0; i < objects.length; i++) { + Object obj = objects[i]; + if (obj instanceof DataType) { + DataType dataType = (DataType) obj; + if (StringUtils.isNotEmpty(dataType.getDataType())) { + typeCheckMap.put(DataType.returnType(dataType.getDataType()).toLowerCase(), obj); + } else if (StringUtils.isNotEmpty(dataType.getComponentKey())) { + typeCheckMap.put(DataType.returnType(dataType.getComponentKey()).toLowerCase(), obj); + } + } else { + String localtype = obj.getClass().getName(); + typeCheckMap.put(DataType.returnType(ExcelParamUtil.getParamType(localtype).toLowerCase()), obj); + } + } + if (typeCheckMap.keySet().size() > 1) { + return false; + } else { + return true; + } + } + + /** + * 校验参数是否统一了类型 + * + * @param objects + * @return + */ + public static boolean commonCheckParamsType(Object... objects) { + if (objects == null || objects.length == 0) { + return false; + } + String type = null; + String objFunc = objects[objects.length - 1].toString(); + for (int i = 0; i < objects.length - 1; i++) { + Object obj = objects[i]; + + String loopType = ExcelParamUtil.getParamType(obj); + if (type == null) { + type = loopType; + } else { + if (!type.equalsIgnoreCase(loopType)) { + return false; + } + } + } + return true; + } + + public static void filterParams(String func, int min, int max, Object... objects) { + Integer number = getSetFuncNumber(func); + if (null == objects) { + errorJson = ErrorUtil.buildError(func, 0, number, func + "函数参数为空"); + throw new RuntimeException(errorJson.getString("msg")); + } + if (objects.length < min) { + errorJson = ErrorUtil.buildError(func, 0, number, func + "函数至少需要" + min + "个参数"); + throw new RuntimeException(errorJson.getString("msg")); + } + if (max > 0 && objects.length > max) { + errorJson = ErrorUtil.buildError(func, 0, number, func + "函数最多允许" + max + "个参数"); + throw new RuntimeException(errorJson.getString("msg")); + } + } + + public static void filterDateParamTypes(String func, int funcNumber, Class[] typeClasses, Object... objects) { + Integer number = funcNumber; + if (null == objects || null == typeClasses || objects.length == 0 || typeClasses.length == 0 || objects.length > typeClasses.length) { + errorJson = ErrorUtil.buildError(func, 0, number, func + "函数参数错误"); + throw new RuntimeException(errorJson.getString("msg")); + } + } + + /** + * 通用验证方法 + * + * @param func + * @param min + * @param max + * @param typeClasses + * @param objects + */ + public static void commonFilter(String func, int min, int max, Class[] typeClasses, Object... objects) { + Integer number = getSetFuncNumber(func); + if (null == objects) { + errorJson = ErrorUtil.buildError(func, 0, number, func + "函数参数为空"); + throw new RuntimeException(errorJson.getString("msg")); + } + if (objects.length < min) { + errorJson = ErrorUtil.buildError(func, 0, number, func + "函数至少需要" + min + "个参数"); + throw new RuntimeException(errorJson.getString("msg")); + } + if (max > 0 && objects.length > max) { + errorJson = ErrorUtil.buildError(func, 0, number, func + "函数最多允许" + max + "个参数"); + throw new RuntimeException(errorJson.getString("msg")); + } + if (typeClasses != null && typeClasses.length > 0) { + if (null == objects || objects.length == 0 || typeClasses.length == 0 || objects.length > typeClasses.length) { + errorJson = ErrorUtil.buildError(func, 0, number, func + "函数参数错误"); + throw new RuntimeException(errorJson.getString("msg")); + } + for (int i = 0; i < objects.length; i++) { + String fieldType = null; + String paramType = ExcelParamUtil.getParamType(typeClasses[i].getName()); + paramType = ExcelParamUtil.checkParamType(paramType); + if (objects[i] instanceof DataType) { + DataType dataType = (DataType) objects[i]; + List datafunclist = Arrays.asList(dateFuncs); + if (datafunclist.contains(func)) { + fieldType = dataType.getDataType(); + } else { + fieldType = ExcelParamUtil.checkParamType(dataType.getDataType()); + } + } else { + fieldType = ExcelParamUtil.getParamType(objects[i].getClass().getName()); + fieldType = ExcelParamUtil.checkParamType(fieldType); + } + if (null == fieldType) { + errorJson = ErrorUtil.buildError(func, i + 1, number, func + "函数参数错误"); + throw new RuntimeException(errorJson.getString("msg")); + } + boolean compareResult = false; + if (paramType.equals("dateandstring") && (fieldType.toLowerCase().equals("string") || fieldType.toLowerCase().equals("date"))) { + compareResult = true; + } else if (paramType.toLowerCase().equals(fieldType.toLowerCase())) { + compareResult = true; + } else if (ExcelParamUtil.inNumber(paramType) && ExcelParamUtil.inNumber(fieldType)) { + compareResult = true; + } else { + if (!compareResult) { + errorJson = ErrorUtil.buildError(func, (i + 1), number, func + "函数参数类型错误"); + throw new RuntimeException(errorJson.getString("msg")); + } + } + } + } + + } + + + /** + * 过滤字符串函数参数 + * + * @param objects + */ + public static void filterStringConcat(int min, int max, Object... objects) { + + Integer number = getSetFuncNumber(FuncNames.CONCAT.toString()); + String func = FuncNames.CONCAT.toString(); + if (objects.length < min) { + errorJson = ErrorUtil.buildError(func, number, number, "CONCAT函数至少需要" + min + "个参数"); + throw new RuntimeException(errorJson.getString("msg")); + } + if (max > 0 && objects.length > max) { + errorJson = ErrorUtil.buildError(func, number, number, "CONCAT函数最多允许" + min + "个参数"); + throw new RuntimeException(errorJson.getString("msg")); + } + } + + + /** + * 过滤聚合函数参数 + * + * @param objects + * @throws RuntimeException + */ + public static void filterAggFunc(String func, Object... objects) throws RuntimeException { + Integer number = getSetFuncNumber(func); + Map map = new HashMap<>(); + boolean mustNumber = false; + if (objects == null) { + errorJson = ErrorUtil.buildError(func, number, number, func + ErrorType.VAR_TYPE_WRONG.name()); + throw new RuntimeException(errorJson.getString("msg")); + } + if (objects.length > 2) { + errorJson = ErrorUtil.buildError(func, number, number, func + "函数最多只支持两个参数"); + throw new RuntimeException(errorJson.getString("msg")); + } + checkArrayParamNull(func, number, objects); + Object obj = objects[0]; + if (func.equals("MAX") || func.equals("MIN") || func.equals("AVG") || func.equals("SUM")) { + mustNumber = true; + } + if (!(obj instanceof DataType)) { + number = getSetFuncNumber(obj.toString()); + errorJson = ErrorUtil.buildError(obj.toString(), number, number, func + "函数参数错误"); + throw new RuntimeException(errorJson.getString("msg")); + } + String paramType = ""; + DataType dataType = (DataType) objects[0]; + if (dataType.getFormId() == null && dataType.getFieldId() == null) { + number = getSetFuncNumber(obj.toString()); + errorJson = ErrorUtil.buildError(obj.toString(), number, number, func + "函数参数错误"); + throw new RuntimeException(errorJson.getString("msg")); + } + + //除了 + if (mustNumber) { + if (objects[0] instanceof DataType && dataType.getDataType() != null) { + paramType = ExcelParamUtil.checkParamType(dataType.getDataType()); + if (paramType != null) { + paramType = ExcelParamUtil.checkParamType(paramType); + } + } else { + errorJson = ErrorUtil.buildError(func, number, number, func + "函数参数错误"); + throw new RuntimeException(errorJson.getString("msg")); + } + if (paramType == null || !(paramType.equals(DataType.NUMBER))) { + errorJson = ErrorUtil.buildError(func, number, number, func + "第一个变量必须为数字字段"); + throw new RuntimeException(errorJson.getString("msg")); + } + } else { + if (dataType.getFormId() == null) { + errorJson = ErrorUtil.buildError(func, number, number, func + "第一个变量必须为表格"); + throw new RuntimeException(errorJson.getString("msg")); + } + } + + for (int i = 0; i < objects.length; i++) { + Object param = objects[i]; + if (param != null && param instanceof DataType) { + DataType pramDataType = (DataType) param; + if (pramDataType.getSubLogic() != null && pramDataType.getSubLogic().size() > 1) { + throw new RuntimeException(func + "函数的参数不能嵌套使用逻辑函数(AND、OR)"); + } + } + } + + } + + public static void filterInFunc(Object... objects) { + String oper = objects[objects.length - 1].toString(); + Integer number = getSetFuncNumber(oper); + List params = (List) objects[0]; + if (params.size() < 2) { + errorJson = ErrorUtil.buildError(oper, number, number, "IN操作符第二个条件至少需要两个参数"); + throw new RuntimeException(errorJson.getString("msg")); + } + String type = null; + for (Object object : params) { + String thisType; + if (object instanceof DataType) { + thisType = ((DataType) object).getDataType(); + if (type == null) { + type = thisType; + } else { + if (!thisType.equals(type)) { + errorJson = ErrorUtil.buildError(oper, number, number, "IN操作符参数类型不一致"); + throw new RuntimeException(errorJson.getString("msg")); + } + } + } + } + } + + /*** + * 过滤比较操作符的参数类型 + * @param objects + */ + public static void filterCompareFunc(Object... objects) throws Exception { + String oper = objects[objects.length - 1].toString(); + Integer number = getSetFuncNumber(oper); + String type1 = ""; + String type2 = ""; + + for (int i = 0; i < objects.length; i++) { + Object object = objects[i]; + if (object == null) { + throw new RuntimeException("[" + oper + "]" + ErrorType.VAR_NOT_NULL.name()); + } + } + if (objects.length < 2) { + throw new RuntimeException("[" + oper + "]" + ErrorType.VAR_NOT_NULL.name()); + } + boolean isDate = false; + for (int i = 0; i < objects.length - 1; i++) { + + Object object = objects[i]; + if (object == null) { + throw new RuntimeException("[" + oper + "]" + ErrorType.VAR_NOT_NULL.name()); + } + String typeName = ""; + + if (object instanceof DataType) { + DataType param = (DataType) object; + typeName = param.getDataType(); + if (typeName.equalsIgnoreCase(DataType.FORM)) { + throw new RuntimeException("[" + oper + "]" + ErrorType.CANT_FORM_FIELD.name()); + } + + if (!typeName.toLowerCase().equals("option")) { + typeName = ExcelParamUtil.checkParamType(typeName.toLowerCase()); + } + if (typeName.toLowerCase().equals(DataType.DATE.toLowerCase())) { + typeName = DataType.STRING; + isDate = true; + } + } else { + //校验比较操作符中的数组是不是为空 + if (object instanceof Object[]) { + Object[] arrayP = (Object[]) object; + if (arrayP.length == 0) { + throw new RuntimeException("[" + oper + "]" + ErrorType.VAR_NOT_NULL.name()); + } + if (arrayP[0] instanceof DataType) { + DataType arrayParamOne = (DataType) arrayP[0]; + typeName = arrayParamOne.getDataType(); + } else { + typeName = ExcelParamUtil.getParamType(arrayP[0].getClass().getName()); + } + } else { + typeName = ExcelParamUtil.getParamType(object.getClass().getName()); + + } + if (!typeName.equalsIgnoreCase("option")) { + typeName = ExcelParamUtil.checkParamType(typeName); + } + } + //判断非等于和不等于操作符的两端参数是否为数字,不是数字返回错误 + if (!isDate && !oper.equals("=") && !oper.equals("!=") && (typeName.toLowerCase().equals(DataType.OPTION))) { + errorJson = ErrorUtil.buildError(oper, 1, number, "比较操作符'" + oper + "'不支持选项类型的运算"); + throw new RuntimeException(errorJson.getString("msg")); + } + + + if (i == 0) { + type1 = typeName; + } else { + type2 = typeName; + } + } + List operList = Arrays.asList(numberOperArray); + if (operList.contains(oper) && (type1.equalsIgnoreCase("string") || type2.equalsIgnoreCase("string"))) { + String msg = "[" + oper + "]操作符不允许非数字类型参数"; + throw new RuntimeException(msg); + } + if (!IgnoreParamFilter.checkType(objects[0], objects[1])) { + errorJson = ErrorUtil.buildError(oper, 1, number, "比较操作符参数类型不一致"); + throw new RuntimeException(errorJson.getString("msg")); + } + + if (objects[0] instanceof Object[]) { + errorJson = ErrorUtil.buildError(oper, 1, number, "比较操作符不支持数组参数"); + throw new RuntimeException(errorJson.getString("msg")); + } + } + + /** + * 过滤日期函数参数 + * + * @param objects + * @throws Exception + */ + public static void filterDateFunc(Object... objects) throws Exception { + Integer number = getSetFuncNumber(""); + boolean isWrong = false; + if (objects.length < 2) { + errorJson = ErrorUtil.buildError("Date", 0, number, "日期函数参数错误"); + throw new RuntimeException(errorJson.getString("msg")); + } + int idx = 1; + for (Object object : objects) { + + if (!(object instanceof String) && !(object instanceof Date) && !(object instanceof DataType)) { + isWrong = true; + break; + + } else if (object instanceof DataType) { + Object content; + DataType dataType = (DataType) object; + content = dataType.getContent(); + if (!(content instanceof String) && !(content instanceof Date) && !(content instanceof DataType)) { + isWrong = true; + break; + } + } + idx++; + } + if (isWrong) { + errorJson = ErrorUtil.buildDataError("Date", idx, objects, "日期函数参数错误"); + throw new RuntimeException(errorJson.getString("msg")); + } + + } + + + /** + * 逻辑函数过滤器 + * + * @param objects + */ + public static void filterLogicAndORFunc(Object... objects) { + String method = objects[objects.length - 1].toString(); + FormulaContext.get().setValue(method); + Object[] paramArray = (Object[]) objects[0]; + Integer number = getSetFuncNumber(method); + if (null == paramArray || paramArray.length == 0) { + errorJson = ErrorUtil.buildError(method, 0, number, method + "函数参数不能为空"); + throw new RuntimeException(errorJson.getString("msg")); + } + for (int i = 0; i < paramArray.length; i++) { + String fieldType = null; + if (paramArray[i] instanceof DataType) { + DataType dataType = (DataType) paramArray[i]; + fieldType = dataType.getDataType(); + } else { + fieldType = ExcelParamUtil.getParamType(paramArray[i].getClass().getName()); + } + fieldType = ExcelParamUtil.checkParamType(fieldType); + if (!fieldType.equalsIgnoreCase(ParamType.BOOLEAN.getValue())) { + errorJson = ErrorUtil.buildError(method, (i + 1), number, method + "函数第" + (i + 1) + "个条件必须为真假值"); + throw new RuntimeException(errorJson.getString("msg")); + } + } + } + + /** + * 判断IF函数的参数合法性 + * + * @param objects + */ + public static void filterIfFunc(Object... objects) { + Integer number = getSetFuncNumber("IF"); + String cndType = ""; + if (objects[0] instanceof DataType) { + DataType dataType = (DataType) objects[0]; + cndType = dataType.getDataType(); + } else { + cndType = ExcelParamUtil.getParamType(objects[0].getClass().getName()); + } + cndType = ExcelParamUtil.checkParamType(cndType); + if (null == cndType || !cndType.equals(ParamType.BOOLEAN.getValue())) { + errorJson = ErrorUtil.buildError("If", 0, number, "IF函数条件应为真假值类型"); + throw new RuntimeException(errorJson.getString("msg")); + } + + String pType1 = ""; + String pType2 = ""; + if (objects[1] instanceof DataType) { + DataType dataType = (DataType) objects[1]; + pType1 = dataType.getDataType(); + } else { + pType1 = ExcelParamUtil.getParamType(objects[1].getClass().getName()); + } + pType1 = ExcelParamUtil.checkParamType(pType1); + if (objects[2] instanceof DataType) { + DataType dataType = (DataType) objects[2]; + pType2 = dataType.getDataType(); + } else { + pType2 = ExcelParamUtil.getParamType(objects[2].getClass().getName()); + } + pType2 = ExcelParamUtil.checkParamType(pType2); + if (!pType1.equals(pType2)) { + errorJson = ErrorUtil.buildError("If", 0, number, "IF函数表达式返回值不一致"); + throw new RuntimeException(errorJson.getString("msg")); + } + } + + public static void filterLikeFunc(Object... objects) { + Integer number = getSetFuncNumber("LIKE"); + String sourceTxt = ""; + List params = new ArrayList() { + }; + if (objects.length < 2) { + errorJson = ErrorUtil.buildError("LIKE", 0, number, "LIKE函数至少需要两个参数"); + throw new RuntimeException(errorJson.getString("msg")); + } else if (objects.length > 2) { + errorJson = ErrorUtil.buildError("LIKE", 0, number, "LIKE函数最多支持两个参数"); + throw new RuntimeException(errorJson.getString("msg")); + } + for (Object obj : objects) { + if (obj.getClass().isArray()) { + Object[] subArray = (Object[]) obj; + for (int i = 0; i < subArray.length; i++) { + params.add(subArray[i]); + } + } else { + params.add(obj); + } + } + Object object = params.get(0); + if (object instanceof DataType) { + DataType dataType = (DataType) object; + sourceTxt = dataType.getDataType(); + } else { + sourceTxt = ExcelParamUtil.getParamType(object.getClass().getName()); + } + sourceTxt = ExcelParamUtil.checkParamType(sourceTxt); + if (null == sourceTxt || !sourceTxt.toLowerCase().equals(ParamType.STRING.getValue().toLowerCase())) { + String key = ExcelParamUtil.getKeyString(object); + number = getSetFuncNumber(key); + errorJson = ErrorUtil.buildError(key, 0, number, "LIKE函数第1个参数应该为文本类型"); + throw new RuntimeException(errorJson.getString("msg")); + } + + for (int i = 0; i < params.size(); i++) { + Object txtObj = params.get(i); + if (null == txtObj) { + errorJson = ErrorUtil.buildError("LIKE", (i + 1), number, "LIKE函数条件错误"); + throw new RuntimeException(errorJson.getString("msg")); + } + String txt = ""; + if (txtObj instanceof DataType) { + DataType dataType = (DataType) txtObj; + txt = dataType.getDataType(); + } else { + txt = ExcelParamUtil.getParamType(txtObj.getClass().getName()); + } + txt = ExcelParamUtil.checkParamType(txt); + if (!txt.toLowerCase().equals(ExcelParamUtil.getParamType(ParamType.STRING.getValue().toLowerCase()))) { + errorJson = ErrorUtil.buildError("LIKE", (i + 1), number, "LIKE函数条件数组第" + (i + 1) + "个参数应该为文本类型"); + throw new RuntimeException(errorJson.getString("msg")); + } + } + + } + + + public static int getSetFuncNumber(String func) { + Integer number = 0; + FormulaContext.get().getValue(func); + if (number == null || number == 0) { + FormulaContext.get().setValue(func); + number = FormulaContext.get().getValue(func); + } else { + FormulaContext.get().setValue(func); + number = FormulaContext.get().getValue(func); + } + return number; + } + + public static void checkArrayParamNull(String func, int number, Object[] objects) { + for (Object object : objects) { + if (object == null) { + errorJson = ErrorUtil.buildError(func, 0, number, func + "函数条件存在未知参数"); + throw new RuntimeException(errorJson.getString("msg")); + } + } + } + + /** + * 校验数学加减乘除运算符号 + * + * @param objects + * @param oper + */ + public static void checkNumberOper(Object[] objects, String oper) { + Integer number = getSetFuncNumber(""); + if (objects.length != 2) { + errorJson = ErrorUtil.buildError(oper, 1, number, "操作符只支持数字类型的运算"); + throw new RuntimeException(errorJson.getString("msg")); + } + String type1 = ""; + String type2 = ""; + for (int i = 0; i < objects.length; i++) { + + Object object = objects[i]; + if (object == null) { + errorJson = ErrorUtil.buildError(oper, 1, number, "[" + oper + "]" + "操作符参数不能为空"); + throw new RuntimeException(errorJson.getString("msg")); + } + String typeName = ""; + + if (object instanceof DataType) { + DataType param = (DataType) object; + if (param.getContent() == null) { + param.setContent(0);//没有值时给0,保存函数运算结果 + } + if (param.getName() != null && param.getName().equals("当前表格")) { + errorJson = ErrorUtil.buildError(oper, 1, number, "[" + oper + "]" + "操作符参数不能为空"); + throw new RuntimeException(errorJson.getString("msg")); + } + typeName = param.getDataType(); + if (!typeName.toLowerCase().equals("option")) { + typeName = ExcelParamUtil.checkParamType(typeName.toLowerCase()); + } + if (typeName.toLowerCase().equals(DataType.DATE.toLowerCase())) { + typeName = DataType.STRING; + } + } else if (object instanceof Date) { + typeName = "string"; + //当参数为数组时 + } else if (object instanceof Object[]) { + Object[] objArray = (Object[]) object; + String arrayType = null; + for (Object obj : objArray) { + String localType = null; + if (obj instanceof DataType) { + localType = ExcelParamUtil.getParamType(obj); + localType = ExcelParamUtil.checkParamType(localType); + } else { + localType = ExcelParamUtil.getParamType(obj.getClass().getName()).toLowerCase(); + localType = ExcelParamUtil.checkParamType(localType); + } + if (arrayType == null) { + arrayType = localType; + } else { + if (!arrayType.equals(localType)) { + errorJson = ErrorUtil.buildError(oper, 1, number, "操作符参数类型不一致"); + throw new RuntimeException(errorJson.getString("msg")); + } + } + } + typeName = arrayType; + } else { + typeName = ExcelParamUtil.getParamType(object.getClass().getName()); + typeName = ExcelParamUtil.checkParamType(typeName); + } + //判断非等于和不等于操作符的两端参数是否为数字,不是数字返回错误 + if (!typeName.toLowerCase().equals(DataType.NUMBER)) { + errorJson = ErrorUtil.buildError(oper, 1, number, "操作符只支持数字类型的运算"); + throw new RuntimeException(errorJson.getString("msg")); + } + + if (i == 0) { + type1 = typeName; + } else { + type2 = typeName; + } + } + if (!type1.toLowerCase().equals(type2.toLowerCase()) || type1.equals("") || type2.equals("")) { + errorJson = ErrorUtil.buildError(oper, 1, number, "操作符参数类型不一致"); + throw new RuntimeException(errorJson.getString("msg")); + } + + } + + /** + * 校验分数取值函数 + * + * @param func + * @param objects + */ + public static void checkFraction(String func, Object... objects) { + Integer number = getSetFuncNumber(func); + if (objects == null || objects.length == 0) { + errorJson = ErrorUtil.buildError(func, 0, number, func + "函数参数为空"); + throw new RuntimeException(errorJson.getString("msg")); + } + if (objects.length > 1) { + errorJson = ErrorUtil.buildError(func, 0, number, func + "函数参数错误"); + throw new RuntimeException(errorJson.getString("msg")); + } + Object object = objects[0]; + if (object instanceof DataType) { + DataType dataType = (DataType) object; + if (null == dataType.getScore()) { + errorJson = ErrorUtil.buildError(func, 0, number, func + "函数参数类型错误"); + throw new RuntimeException(errorJson.getString("msg")); + } + } + + } + + public static void checkValiIdCard(String func, Object... objects) { + Integer number = getSetFuncNumber(func); + if (objects == null || objects.length == 0) { + errorJson = ErrorUtil.buildError(func, 0, number, func + "函数参数为空"); + throw new RuntimeException(errorJson.getString("msg")); + } + if (objects.length != 2) { + errorJson = ErrorUtil.buildError(func, 0, number, func + "函数只允许两个参数"); + throw new RuntimeException(errorJson.getString("msg")); + } + if (objects[0] instanceof DataType) { + DataType dataType = (DataType) objects[0]; + if (dataType.getDataType().equalsIgnoreCase(DataType.OPTION) || dataType.getDataType().equalsIgnoreCase(DataType.DATE)) { + errorJson = ErrorUtil.buildError(func, 0, number, func + "函数只允许操作数字或字符"); + throw new RuntimeException(errorJson.getString("msg")); + } + } + } + + /** + * 校验参数类型 + * + * @param paramArray + * @param exclDataTypeList + * @return + */ + public static List checkParamType(Object[] paramArray, List exclDataTypeList) { + List errorIdxList = new ArrayList(); + if (paramArray != null && paramArray.length != 0) { + for (int i = 0; i < paramArray.length; i++) { + Object object = paramArray[i]; + if (object instanceof DataType) { + DataType paramDataType = (DataType) object; + if (paramDataType.getDataType() != null && !paramDataType.getDataType().equalsIgnoreCase(exclDataTypeList.get(i))) { + errorIdxList.add(i); + return errorIdxList; + } + } else { + String typeString = ExcelParamUtil.getParamType(object.getClass().getName()); + typeString = DataType.returnType(typeString); + if (!typeString.equalsIgnoreCase(exclDataTypeList.get(0))) { + errorIdxList.add(i); + return errorIdxList; + } + } + } + } + return errorIdxList; + } + + +} diff --git a/src/com/engine/salary/formlua/util/NativePlace.java b/src/com/engine/salary/formlua/util/NativePlace.java new file mode 100644 index 000000000..94aa01640 --- /dev/null +++ b/src/com/engine/salary/formlua/util/NativePlace.java @@ -0,0 +1,7162 @@ +package com.engine.salary.formlua.util; + +import org.apache.commons.lang.StringUtils; + +import java.util.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class NativePlace { + + public static void main(String args[]){ + Map placeMap=getAddressInfo("湖南省长沙市雨花区蔡锷路103号"); + } + /** + * 解析地址 + * @param address + * @return + */ + public static Map getAddressInfo(String address) { + //1级 省 直辖市 自治区 2级 市 自治州 地区 3级:区县市旗 + String province = null, city = null, provinceAndCity = null, town = null ,addr=null; + Map row = new LinkedHashMap<>(); + List> table = new ArrayList<>(); + Map resultMap = new HashMap<>(4); + + //不解析香港、澳门、台湾,这些特别行政地区过于特殊 + if (address.startsWith("香港")) { + resultMap.put("province","香港"); + return resultMap; + } else if (address.contains("澳门")) { + resultMap.put("province","澳门"); + return resultMap; + } else if (address.contains("台湾")) { + resultMap.put("province","台湾"); + return resultMap; + } else { + //普通地址,先将省市匹配出来,用户输入的时候必须要有至少两个级别的行政单位 + String regex = "((?[^市]+市|.*?自治州|.*?区|.*县)(?[^区]+区|.*?市|.*?县|.*?路|.*?街|.*?道|.*?镇|.*?旗)(?.*))"; + Matcher m = Pattern.compile(regex).matcher(address); + //匹配出省市后再拆分出省自治区直辖市,上面的正则先从整体角度匹配,确保地址的基本信息正确, + //拆分省市的时候,只要匹配到了省、直辖市、自治区,那么剩下的全部视为二级行政单位名称 + // 拆分的时候如果没有省级行政单位,那就只返回一个区 + while (m.find()) { + provinceAndCity = m.group("provinceAndCity"); + String regex2 = "((?[^省]+省|.+自治区|上海市|北京市|天津市|重庆市|上海|北京|天津|重庆)(?.*))"; + Matcher m2 = Pattern.compile(regex2).matcher(provinceAndCity); + while (m2.find()) { + province = m2.group("province"); + row.put("province", province == null ? "" : province.trim()); + city = m2.group("city"); + row.put("city", city == null ? "" : city.trim()); + } + town = m.group("town"); + addr = m.group("detailAddress"); + row.put("town", town == null ? "" : town.trim()); + row.put("addr",addr == null ? "" :addr.trim()); + table.add(row); + } + } + //对直辖市自治区做二次调整,提取名称,直辖市的二级行政单位和一级名称保持一致,自治区去掉后面的自治区后缀 + if (table != null && table.size() > 0) { + if (StringUtils.isNotBlank(table.get(0).get("province"))) { + province = table.get(0).get("province"); + //如果用户输入的是自治区,对自治区进行处理,自治区的一共五个,一个西藏两个名字,其他的是四个或者3个名字,这里截取后会存在多一个字符的情况,后面会接着处理 + if (province.contains("自治区")) { + if (province.contains("内蒙古")) { + province = province.substring(0,4); + } else { + province = province.substring(0,3); + } + + } + } + if (StringUtils.isNotBlank(province)) { + //直辖市的二级行政单位也是自己 + if (StringUtils.isNotBlank(table.get(0).get("city"))) { + city = table.get(0).get("city"); + if (city.equals("上海市") || city.equals("重庆市") || city.equals("北京市") || city.equals("天津市")) { + province = table.get(0).get("city"); + } + } + + else if (province.equals("上海市") || province.equals("重庆市") || province.equals("北京市") || province.equals("天津市")) { + city = province; + } + //所有直辖市、自治区,名称去掉行政单位(区、市) + if (StringUtils.isNotBlank(table.get(0).get("town"))) { + town = table.get(0).get("town"); + } + //对提取名称多出一个字的情况做处理,直辖市的去掉"市" + province = province.substring(0,province.length() - 1); + + } + + } else { + return resultMap; + } + resultMap.put("province",province); + resultMap.put("city",city); + resultMap.put("town",town); + resultMap.put("addr",addr); + return resultMap; + } + + + + + + public static String getNativePlace(int nativePlaceCode) { + int shengCode = nativePlaceCode / 10000; + int shiCode = nativePlaceCode / 100; + int quxianCode = nativePlaceCode; + String sheng = getNameString(shengCode); + String shi = getNameString(shiCode); + String quxian = getNameString(quxianCode); + String nativePlace = ""; + if (sheng != null) { + nativePlace += sheng; + } + if (shi != null) { + nativePlace += shi; + } + if (quxian != null) { + nativePlace += quxian; + } + return sheng; + } + + private static String getNameString(int code) { + switch (code) { + case 11: + return "北京市"; + case 1101: + return "市辖区"; + case 110101: + return "东城区"; + case 110102: + return "西城区"; + case 110105: + return "朝阳区"; + case 110106: + return "丰台区"; + case 110107: + return "石景山区"; + case 110108: + return "海淀区"; + case 110109: + return "门头沟区"; + case 110111: + return "房山区"; + case 110112: + return "通州区"; + case 110113: + return "顺义区"; + case 110114: + return "昌平区"; + case 110115: + return "大兴区"; + case 110116: + return "怀柔区"; + case 110117: + return "平谷区"; + case 1102: + return "县"; + case 110228: + return "密云县"; + case 110229: + return "延庆县"; + case 12: + return "天津市"; + case 1201: + return "市辖区"; + case 120101: + return "和平区"; + case 120102: + return "河东区"; + case 120103: + return "河西区"; + case 120104: + return "南开区"; + case 120105: + return "河北区"; + case 120106: + return "红桥区"; + case 120110: + return "东丽区"; + case 120111: + return "西青区"; + case 120112: + return "津南区"; + case 120113: + return "北辰区"; + case 120114: + return "武清区"; + case 120115: + return "宝坻区"; + case 120116: + return "滨海新区"; + case 1202: + return "县"; + case 120221: + return "宁河县"; + case 120223: + return "静海县"; + case 120225: + return "蓟县"; + case 13: + return "河北省"; + case 1301: + return "石家庄市"; + case 130101: + return "市辖区"; + case 130102: + return "长安区"; + case 130104: + return "桥西区"; + case 130105: + return "新华区"; + case 130107: + return "井陉矿区"; + case 130108: + return "裕华区"; + case 130109: + return "藁城区"; + case 130110: + return "鹿泉区"; + case 130111: + return "栾城区"; + case 130121: + return "井陉县"; + case 130123: + return "正定县"; + case 130125: + return "行唐县"; + case 130126: + return "灵寿县"; + case 130127: + return "高邑县"; + case 130128: + return "深泽县"; + case 130129: + return "赞皇县"; + case 130130: + return "无极县"; + case 130131: + return "平山县"; + case 130132: + return "元氏县"; + case 130133: + return "赵县"; + case 130183: + return "晋州市"; + case 130184: + return "新乐市"; + case 1302: + return "唐山市"; + case 130201: + return "市辖区"; + case 130202: + return "路南区"; + case 130203: + return "路北区"; + case 130204: + return "古冶区"; + case 130205: + return "开平区"; + case 130207: + return "丰南区"; + case 130208: + return "丰润区"; + case 130209: + return "曹妃甸区"; + case 130223: + return "滦县"; + case 130224: + return "滦南县"; + case 130225: + return "乐亭县"; + case 130227: + return "迁西县"; + case 130229: + return "玉田县"; + case 130281: + return "遵化市"; + case 130283: + return "迁安市"; + case 1303: + return "秦皇岛市"; + case 130301: + return "市辖区"; + case 130302: + return "海港区"; + case 130303: + return "山海关区"; + case 130304: + return "北戴河区"; + case 130321: + return "青龙满族自治县"; + case 130322: + return "昌黎县"; + case 130323: + return "抚宁县"; + case 130324: + return "卢龙县"; + case 1304: + return "邯郸市"; + case 130401: + return "市辖区"; + case 130402: + return "邯山区"; + case 130403: + return "丛台区"; + case 130404: + return "复兴区"; + case 130406: + return "峰峰矿区"; + case 130421: + return "邯郸县"; + case 130423: + return "临漳县"; + case 130424: + return "成安县"; + case 130425: + return "大名县"; + case 130426: + return "涉县"; + case 130427: + return "磁县"; + case 130428: + return "肥乡县"; + case 130429: + return "永年县"; + case 130430: + return "邱县"; + case 130431: + return "鸡泽县"; + case 130432: + return "广平县"; + case 130433: + return "馆陶县"; + case 130434: + return "魏县"; + case 130435: + return "曲周县"; + case 130481: + return "武安市"; + case 1305: + return "邢台市"; + case 130501: + return "市辖区"; + case 130502: + return "桥东区"; + case 130503: + return "桥西区"; + case 130521: + return "邢台县"; + case 130522: + return "临城县"; + case 130523: + return "内丘县"; + case 130524: + return "柏乡县"; + case 130525: + return "隆尧县"; + case 130526: + return "任县"; + case 130527: + return "南和县"; + case 130528: + return "宁晋县"; + case 130529: + return "巨鹿县"; + case 130530: + return "新河县"; + case 130531: + return "广宗县"; + case 130532: + return "平乡县"; + case 130533: + return "威县"; + case 130534: + return "清河县"; + case 130535: + return "临西县"; + case 130581: + return "南宫市"; + case 130582: + return "沙河市"; + case 1306: + return "保定市"; + case 130601: + return "市辖区"; + case 130602: + return "新市区"; + case 130603: + return "北市区"; + case 130604: + return "南市区"; + case 130621: + return "满城县"; + case 130622: + return "清苑县"; + case 130623: + return "涞水县"; + case 130624: + return "阜平县"; + case 130625: + return "徐水县"; + case 130626: + return "定兴县"; + case 130627: + return "唐县"; + case 130628: + return "高阳县"; + case 130629: + return "容城县"; + case 130630: + return "涞源县"; + case 130631: + return "望都县"; + case 130632: + return "安新县"; + case 130633: + return "易县"; + case 130634: + return "曲阳县"; + case 130635: + return "蠡县"; + case 130636: + return "顺平县"; + case 130637: + return "博野县"; + case 130638: + return "雄县"; + case 130681: + return "涿州市"; + case 130683: + return "安国市"; + case 130684: + return "高碑店市"; + case 1307: + return "张家口市"; + case 130701: + return "市辖区"; + case 130702: + return "桥东区"; + case 130703: + return "桥西区"; + case 130705: + return "宣化区"; + case 130706: + return "下花园区"; + case 130721: + return "宣化县"; + case 130722: + return "张北县"; + case 130723: + return "康保县"; + case 130724: + return "沽源县"; + case 130725: + return "尚义县"; + case 130726: + return "蔚县"; + case 130727: + return "阳原县"; + case 130728: + return "怀安县"; + case 130729: + return "万全县"; + case 130730: + return "怀来县"; + case 130731: + return "涿鹿县"; + case 130732: + return "赤城县"; + case 130733: + return "崇礼县"; + case 1308: + return "承德市"; + case 130801: + return "市辖区"; + case 130802: + return "双桥区"; + case 130803: + return "双滦区"; + case 130804: + return "鹰手营子矿区"; + case 130821: + return "承德县"; + case 130822: + return "兴隆县"; + case 130823: + return "平泉县"; + case 130824: + return "滦平县"; + case 130825: + return "隆化县"; + case 130826: + return "丰宁满族自治县"; + case 130827: + return "宽城满族自治县"; + case 130828: + return "围场满族蒙古族自治县"; + case 1309: + return "沧州市"; + case 130901: + return "市辖区"; + case 130902: + return "新华区"; + case 130903: + return "运河区"; + case 130921: + return "沧县"; + case 130922: + return "青县"; + case 130923: + return "东光县"; + case 130924: + return "海兴县"; + case 130925: + return "盐山县"; + case 130926: + return "肃宁县"; + case 130927: + return "南皮县"; + case 130928: + return "吴桥县"; + case 130929: + return "献县"; + case 130930: + return "孟村回族自治县"; + case 130981: + return "泊头市"; + case 130982: + return "任丘市"; + case 130983: + return "黄骅市"; + case 130984: + return "河间市"; + case 1310: + return "廊坊市"; + case 131001: + return "市辖区"; + case 131002: + return "安次区"; + case 131003: + return "广阳区"; + case 131022: + return "固安县"; + case 131023: + return "永清县"; + case 131024: + return "香河县"; + case 131025: + return "大城县"; + case 131026: + return "文安县"; + case 131028: + return "大厂回族自治县"; + case 131081: + return "霸州市"; + case 131082: + return "三河市"; + case 1311: + return "衡水市"; + case 131101: + return "市辖区"; + case 131102: + return "桃城区"; + case 131121: + return "枣强县"; + case 131122: + return "武邑县"; + case 131123: + return "武强县"; + case 131124: + return "饶阳县"; + case 131125: + return "安平县"; + case 131126: + return "故城县"; + case 131127: + return "景县"; + case 131128: + return "阜城县"; + case 131181: + return "冀州市"; + case 131182: + return "深州市"; + case 1390: + return "省直辖县级行政区划"; + case 139001: + return "定州市"; + case 139002: + return "辛集市"; + case 14: + return "山西省"; + case 1401: + return "太原市"; + case 140101: + return "市辖区"; + case 140105: + return "小店区"; + case 140106: + return "迎泽区"; + case 140107: + return "杏花岭区"; + case 140108: + return "尖草坪区"; + case 140109: + return "万柏林区"; + case 140110: + return "晋源区"; + case 140121: + return "清徐县"; + case 140122: + return "阳曲县"; + case 140123: + return "娄烦县"; + case 140181: + return "古交市"; + case 1402: + return "大同市"; + case 140201: + return "市辖区"; + case 140202: + return "城区"; + case 140203: + return "矿区"; + case 140211: + return "南郊区"; + case 140212: + return "新荣区"; + case 140221: + return "阳高县"; + case 140222: + return "天镇县"; + case 140223: + return "广灵县"; + case 140224: + return "灵丘县"; + case 140225: + return "浑源县"; + case 140226: + return "左云县"; + case 140227: + return "大同县"; + case 1403: + return "阳泉市"; + case 140301: + return "市辖区"; + case 140302: + return "城区"; + case 140303: + return "矿区"; + case 140311: + return "郊区"; + case 140321: + return "平定县"; + case 140322: + return "盂县"; + case 1404: + return "长治市"; + case 140401: + return "市辖区"; + case 140402: + return "城区"; + case 140411: + return "郊区"; + case 140421: + return "长治县"; + case 140423: + return "襄垣县"; + case 140424: + return "屯留县"; + case 140425: + return "平顺县"; + case 140426: + return "黎城县"; + case 140427: + return "壶关县"; + case 140428: + return "长子县"; + case 140429: + return "武乡县"; + case 140430: + return "沁县"; + case 140431: + return "沁源县"; + case 140481: + return "潞城市"; + case 1405: + return "晋城市"; + case 140501: + return "市辖区"; + case 140502: + return "城区"; + case 140521: + return "沁水县"; + case 140522: + return "阳城县"; + case 140524: + return "陵川县"; + case 140525: + return "泽州县"; + case 140581: + return "高平市"; + case 1406: + return "朔州市"; + case 140601: + return "市辖区"; + case 140602: + return "朔城区"; + case 140603: + return "平鲁区"; + case 140621: + return "山阴县"; + case 140622: + return "应县"; + case 140623: + return "右玉县"; + case 140624: + return "怀仁县"; + case 1407: + return "晋中市"; + case 140701: + return "市辖区"; + case 140702: + return "榆次区"; + case 140721: + return "榆社县"; + case 140722: + return "左权县"; + case 140723: + return "和顺县"; + case 140724: + return "昔阳县"; + case 140725: + return "寿阳县"; + case 140726: + return "太谷县"; + case 140727: + return "祁县"; + case 140728: + return "平遥县"; + case 140729: + return "灵石县"; + case 140781: + return "介休市"; + case 1408: + return "运城市"; + case 140801: + return "市辖区"; + case 140802: + return "盐湖区"; + case 140821: + return "临猗县"; + case 140822: + return "万荣县"; + case 140823: + return "闻喜县"; + case 140824: + return "稷山县"; + case 140825: + return "新绛县"; + case 140826: + return "绛县"; + case 140827: + return "垣曲县"; + case 140828: + return "夏县"; + case 140829: + return "平陆县"; + case 140830: + return "芮城县"; + case 140881: + return "永济市"; + case 140882: + return "河津市"; + case 1409: + return "忻州市"; + case 140901: + return "市辖区"; + case 140902: + return "忻府区"; + case 140921: + return "定襄县"; + case 140922: + return "五台县"; + case 140923: + return "代县"; + case 140924: + return "繁峙县"; + case 140925: + return "宁武县"; + case 140926: + return "静乐县"; + case 140927: + return "神池县"; + case 140928: + return "五寨县"; + case 140929: + return "岢岚县"; + case 140930: + return "河曲县"; + case 140931: + return "保德县"; + case 140932: + return "偏关县"; + case 140981: + return "原平市"; + case 1410: + return "临汾市"; + case 141001: + return "市辖区"; + case 141002: + return "尧都区"; + case 141021: + return "曲沃县"; + case 141022: + return "翼城县"; + case 141023: + return "襄汾县"; + case 141024: + return "洪洞县"; + case 141025: + return "古县"; + case 141026: + return "安泽县"; + case 141027: + return "浮山县"; + case 141028: + return "吉县"; + case 141029: + return "乡宁县"; + case 141030: + return "大宁县"; + case 141031: + return "隰县"; + case 141032: + return "永和县"; + case 141033: + return "蒲县"; + case 141034: + return "汾西县"; + case 141081: + return "侯马市"; + case 141082: + return "霍州市"; + case 1411: + return "吕梁市"; + case 141101: + return "市辖区"; + case 141102: + return "离石区"; + case 141121: + return "文水县"; + case 141122: + return "交城县"; + case 141123: + return "兴县"; + case 141124: + return "临县"; + case 141125: + return "柳林县"; + case 141126: + return "石楼县"; + case 141127: + return "岚县"; + case 141128: + return "方山县"; + case 141129: + return "中阳县"; + case 141130: + return "交口县"; + case 141181: + return "孝义市"; + case 141182: + return "汾阳市"; + case 15: + return "内蒙古自治区"; + case 1501: + return "呼和浩特市"; + case 150101: + return "市辖区"; + case 150102: + return "新城区"; + case 150103: + return "回民区"; + case 150104: + return "玉泉区"; + case 150105: + return "赛罕区"; + case 150121: + return "土默特左旗"; + case 150122: + return "托克托县"; + case 150123: + return "和林格尔县"; + case 150124: + return "清水河县"; + case 150125: + return "武川县"; + case 1502: + return "包头市"; + case 150201: + return "市辖区"; + case 150202: + return "东河区"; + case 150203: + return "昆都仑区"; + case 150204: + return "青山区"; + case 150205: + return "石拐区"; + case 150206: + return "白云鄂博矿区"; + case 150207: + return "九原区"; + case 150221: + return "土默特右旗"; + case 150222: + return "固阳县"; + case 150223: + return "达尔罕茂明安联合旗"; + case 1503: + return "乌海市"; + case 150301: + return "市辖区"; + case 150302: + return "海勃湾区"; + case 150303: + return "海南区"; + case 150304: + return "乌达区"; + case 1504: + return "赤峰市"; + case 150401: + return "市辖区"; + case 150402: + return "红山区"; + case 150403: + return "元宝山区"; + case 150404: + return "松山区"; + case 150421: + return "阿鲁科尔沁旗"; + case 150422: + return "巴林左旗"; + case 150423: + return "巴林右旗"; + case 150424: + return "林西县"; + case 150425: + return "克什克腾旗"; + case 150426: + return "翁牛特旗"; + case 150428: + return "喀喇沁旗"; + case 150429: + return "宁城县"; + case 150430: + return "敖汉旗"; + case 1505: + return "通辽市"; + case 150501: + return "市辖区"; + case 150502: + return "科尔沁区"; + case 150521: + return "科尔沁左翼中旗"; + case 150522: + return "科尔沁左翼后旗"; + case 150523: + return "开鲁县"; + case 150524: + return "库伦旗"; + case 150525: + return "奈曼旗"; + case 150526: + return "扎鲁特旗"; + case 150581: + return "霍林郭勒市"; + case 1506: + return "鄂尔多斯市"; + case 150601: + return "市辖区"; + case 150602: + return "东胜区"; + case 150621: + return "达拉特旗"; + case 150622: + return "准格尔旗"; + case 150623: + return "鄂托克前旗"; + case 150624: + return "鄂托克旗"; + case 150625: + return "杭锦旗"; + case 150626: + return "乌审旗"; + case 150627: + return "伊金霍洛旗"; + case 1507: + return "呼伦贝尔市"; + case 150701: + return "市辖区"; + case 150702: + return "海拉尔区"; + case 150703: + return "扎赉诺尔区"; + case 150721: + return "阿荣旗"; + case 150722: + return "莫力达瓦达斡尔族自治旗"; + case 150723: + return "鄂伦春自治旗"; + case 150724: + return "鄂温克族自治旗"; + case 150725: + return "陈巴尔虎旗"; + case 150726: + return "新巴尔虎左旗"; + case 150727: + return "新巴尔虎右旗"; + case 150781: + return "满洲里市"; + case 150782: + return "牙克石市"; + case 150783: + return "扎兰屯市"; + case 150784: + return "额尔古纳市"; + case 150785: + return "根河市"; + case 1508: + return "巴彦淖尔市"; + case 150801: + return "市辖区"; + case 150802: + return "临河区"; + case 150821: + return "五原县"; + case 150822: + return "磴口县"; + case 150823: + return "乌拉特前旗"; + case 150824: + return "乌拉特中旗"; + case 150825: + return "乌拉特后旗"; + case 150826: + return "杭锦后旗"; + case 1509: + return "乌兰察布市"; + case 150901: + return "市辖区"; + case 150902: + return "集宁区"; + case 150921: + return "卓资县"; + case 150922: + return "化德县"; + case 150923: + return "商都县"; + case 150924: + return "兴和县"; + case 150925: + return "凉城县"; + case 150926: + return "察哈尔右翼前旗"; + case 150927: + return "察哈尔右翼中旗"; + case 150928: + return "察哈尔右翼后旗"; + case 150929: + return "四子王旗"; + case 150981: + return "丰镇市"; + case 1522: + return "兴安盟"; + case 152201: + return "乌兰浩特市"; + case 152202: + return "阿尔山市"; + case 152221: + return "科尔沁右翼前旗"; + case 152222: + return "科尔沁右翼中旗"; + case 152223: + return "扎赉特旗"; + case 152224: + return "突泉县"; + case 1525: + return "锡林郭勒盟"; + case 152501: + return "二连浩特市"; + case 152502: + return "锡林浩特市"; + case 152522: + return "阿巴嘎旗"; + case 152523: + return "苏尼特左旗"; + case 152524: + return "苏尼特右旗"; + case 152525: + return "东乌珠穆沁旗"; + case 152526: + return "西乌珠穆沁旗"; + case 152527: + return "太仆寺旗"; + case 152528: + return "镶黄旗"; + case 152529: + return "正镶白旗"; + case 152530: + return "正蓝旗"; + case 152531: + return "多伦县"; + case 1529: + return "阿拉善盟"; + case 152921: + return "阿拉善左旗"; + case 152922: + return "阿拉善右旗"; + case 152923: + return "额济纳旗"; + case 21: + return "辽宁省"; + case 2101: + return "沈阳市"; + case 210101: + return "市辖区"; + case 210102: + return "和平区"; + case 210103: + return "沈河区"; + case 210104: + return "大东区"; + case 210105: + return "皇姑区"; + case 210106: + return "铁西区"; + case 210111: + return "苏家屯区"; + case 210112: + return "浑南区"; + case 210113: + return "沈北新区"; + case 210114: + return "于洪区"; + case 210122: + return "辽中县"; + case 210123: + return "康平县"; + case 210124: + return "法库县"; + case 210181: + return "新民市"; + case 2102: + return "大连市"; + case 210201: + return "市辖区"; + case 210202: + return "中山区"; + case 210203: + return "西岗区"; + case 210204: + return "沙河口区"; + case 210211: + return "甘井子区"; + case 210212: + return "旅顺口区"; + case 210213: + return "金州区"; + case 210224: + return "长海县"; + case 210281: + return "瓦房店市"; + case 210282: + return "普兰店市"; + case 210283: + return "庄河市"; + case 2103: + return "鞍山市"; + case 210301: + return "市辖区"; + case 210302: + return "铁东区"; + case 210303: + return "铁西区"; + case 210304: + return "立山区"; + case 210311: + return "千山区"; + case 210321: + return "台安县"; + case 210323: + return "岫岩满族自治县"; + case 210381: + return "海城市"; + case 2104: + return "抚顺市"; + case 210401: + return "市辖区"; + case 210402: + return "新抚区"; + case 210403: + return "东洲区"; + case 210404: + return "望花区"; + case 210411: + return "顺城区"; + case 210421: + return "抚顺县"; + case 210422: + return "新宾满族自治县"; + case 210423: + return "清原满族自治县"; + case 2105: + return "本溪市"; + case 210501: + return "市辖区"; + case 210502: + return "平山区"; + case 210503: + return "溪湖区"; + case 210504: + return "明山区"; + case 210505: + return "南芬区"; + case 210521: + return "本溪满族自治县"; + case 210522: + return "桓仁满族自治县"; + case 2106: + return "丹东市"; + case 210601: + return "市辖区"; + case 210602: + return "元宝区"; + case 210603: + return "振兴区"; + case 210604: + return "振安区"; + case 210624: + return "宽甸满族自治县"; + case 210681: + return "东港市"; + case 210682: + return "凤城市"; + case 2107: + return "锦州市"; + case 210701: + return "市辖区"; + case 210702: + return "古塔区"; + case 210703: + return "凌河区"; + case 210711: + return "太和区"; + case 210726: + return "黑山县"; + case 210727: + return "义县"; + case 210781: + return "凌海市"; + case 210782: + return "北镇市"; + case 2108: + return "营口市"; + case 210801: + return "市辖区"; + case 210802: + return "站前区"; + case 210803: + return "西市区"; + case 210804: + return "鲅鱼圈区"; + case 210811: + return "老边区"; + case 210881: + return "盖州市"; + case 210882: + return "大石桥市"; + case 2109: + return "阜新市"; + case 210901: + return "市辖区"; + case 210902: + return "海州区"; + case 210903: + return "新邱区"; + case 210904: + return "太平区"; + case 210905: + return "清河门区"; + case 210911: + return "细河区"; + case 210921: + return "阜新蒙古族自治县"; + case 210922: + return "彰武县"; + case 2110: + return "辽阳市"; + case 211001: + return "市辖区"; + case 211002: + return "白塔区"; + case 211003: + return "文圣区"; + case 211004: + return "宏伟区"; + case 211005: + return "弓长岭区"; + case 211011: + return "太子河区"; + case 211021: + return "辽阳县"; + case 211081: + return "灯塔市"; + case 2111: + return "盘锦市"; + case 211101: + return "市辖区"; + case 211102: + return "双台子区"; + case 211103: + return "兴隆台区"; + case 211121: + return "大洼县"; + case 211122: + return "盘山县"; + case 2112: + return "铁岭市"; + case 211201: + return "市辖区"; + case 211202: + return "银州区"; + case 211204: + return "清河区"; + case 211221: + return "铁岭县"; + case 211223: + return "西丰县"; + case 211224: + return "昌图县"; + case 211281: + return "调兵山市"; + case 211282: + return "开原市"; + case 2113: + return "朝阳市"; + case 211301: + return "市辖区"; + case 211302: + return "双塔区"; + case 211303: + return "龙城区"; + case 211321: + return "朝阳县"; + case 211322: + return "建平县"; + case 211324: + return "喀喇沁左翼蒙古族自治县"; + case 211381: + return "北票市"; + case 211382: + return "凌源市"; + case 2114: + return "葫芦岛市"; + case 211401: + return "市辖区"; + case 211402: + return "连山区"; + case 211403: + return "龙港区"; + case 211404: + return "南票区"; + case 211421: + return "绥中县"; + case 211422: + return "建昌县"; + case 211481: + return "兴城市"; + case 22: + return "吉林省"; + case 2201: + return "长春市"; + case 220101: + return "市辖区"; + case 220102: + return "南关区"; + case 220103: + return "宽城区"; + case 220104: + return "朝阳区"; + case 220105: + return "二道区"; + case 220106: + return "绿园区"; + case 220112: + return "双阳区"; + case 220113: + return "九台区"; + case 220122: + return "农安县"; + case 220182: + return "榆树市"; + case 220183: + return "德惠市"; + case 2202: + return "吉林市"; + case 220201: + return "市辖区"; + case 220202: + return "昌邑区"; + case 220203: + return "龙潭区"; + case 220204: + return "船营区"; + case 220211: + return "丰满区"; + case 220221: + return "永吉县"; + case 220281: + return "蛟河市"; + case 220282: + return "桦甸市"; + case 220283: + return "舒兰市"; + case 220284: + return "磐石市"; + case 2203: + return "四平市"; + case 220301: + return "市辖区"; + case 220302: + return "铁西区"; + case 220303: + return "铁东区"; + case 220322: + return "梨树县"; + case 220323: + return "伊通满族自治县"; + case 220381: + return "公主岭市"; + case 220382: + return "双辽市"; + case 2204: + return "辽源市"; + case 220401: + return "市辖区"; + case 220402: + return "龙山区"; + case 220403: + return "西安区"; + case 220421: + return "东丰县"; + case 220422: + return "东辽县"; + case 2205: + return "通化市"; + case 220501: + return "市辖区"; + case 220502: + return "东昌区"; + case 220503: + return "二道江区"; + case 220521: + return "通化县"; + case 220523: + return "辉南县"; + case 220524: + return "柳河县"; + case 220581: + return "梅河口市"; + case 220582: + return "集安市"; + case 2206: + return "白山市"; + case 220601: + return "市辖区"; + case 220602: + return "浑江区"; + case 220605: + return "江源区"; + case 220621: + return "抚松县"; + case 220622: + return "靖宇县"; + case 220623: + return "长白朝鲜族自治县"; + case 220681: + return "临江市"; + case 2207: + return "松原市"; + case 220701: + return "市辖区"; + case 220702: + return "宁江区"; + case 220721: + return "前郭尔罗斯蒙古族自治县"; + case 220722: + return "长岭县"; + case 220723: + return "乾安县"; + case 220781: + return "扶余市"; + case 2208: + return "白城市"; + case 220801: + return "市辖区"; + case 220802: + return "洮北区"; + case 220821: + return "镇赉县"; + case 220822: + return "通榆县"; + case 220881: + return "洮南市"; + case 220882: + return "大安市"; + case 2224: + return "延边朝鲜族自治州"; + case 222401: + return "延吉市"; + case 222402: + return "图们市"; + case 222403: + return "敦化市"; + case 222404: + return "珲春市"; + case 222405: + return "龙井市"; + case 222406: + return "和龙市"; + case 222424: + return "汪清县"; + case 222426: + return "安图县"; + case 23: + return "黑龙江省"; + case 2301: + return "哈尔滨市"; + case 230101: + return "市辖区"; + case 230102: + return "道里区"; + case 230103: + return "南岗区"; + case 230104: + return "道外区"; + case 230108: + return "平房区"; + case 230109: + return "松北区"; + case 230110: + return "香坊区"; + case 230111: + return "呼兰区"; + case 230112: + return "阿城区"; + case 230123: + return "依兰县"; + case 230124: + return "方正县"; + case 230125: + return "宾县"; + case 230126: + return "巴彦县"; + case 230127: + return "木兰县"; + case 230128: + return "通河县"; + case 230129: + return "延寿县"; + case 230182: + return "双城市"; + case 230183: + return "尚志市"; + case 230184: + return "五常市"; + case 2302: + return "齐齐哈尔市"; + case 230201: + return "市辖区"; + case 230202: + return "龙沙区"; + case 230203: + return "建华区"; + case 230204: + return "铁锋区"; + case 230205: + return "昂昂溪区"; + case 230206: + return "富拉尔基区"; + case 230207: + return "碾子山区"; + case 230208: + return "梅里斯达斡尔族区"; + case 230221: + return "龙江县"; + case 230223: + return "依安县"; + case 230224: + return "泰来县"; + case 230225: + return "甘南县"; + case 230227: + return "富裕县"; + case 230229: + return "克山县"; + case 230230: + return "克东县"; + case 230231: + return "拜泉县"; + case 230281: + return "讷河市"; + case 2303: + return "鸡西市"; + case 230301: + return "市辖区"; + case 230302: + return "鸡冠区"; + case 230303: + return "恒山区"; + case 230304: + return "滴道区"; + case 230305: + return "梨树区"; + case 230306: + return "城子河区"; + case 230307: + return "麻山区"; + case 230321: + return "鸡东县"; + case 230381: + return "虎林市"; + case 230382: + return "密山市"; + case 2304: + return "鹤岗市"; + case 230401: + return "市辖区"; + case 230402: + return "向阳区"; + case 230403: + return "工农区"; + case 230404: + return "南山区"; + case 230405: + return "兴安区"; + case 230406: + return "东山区"; + case 230407: + return "兴山区"; + case 230421: + return "萝北县"; + case 230422: + return "绥滨县"; + case 2305: + return "双鸭山市"; + case 230501: + return "市辖区"; + case 230502: + return "尖山区"; + case 230503: + return "岭东区"; + case 230505: + return "四方台区"; + case 230506: + return "宝山区"; + case 230521: + return "集贤县"; + case 230522: + return "友谊县"; + case 230523: + return "宝清县"; + case 230524: + return "饶河县"; + case 2306: + return "大庆市"; + case 230601: + return "市辖区"; + case 230602: + return "萨尔图区"; + case 230603: + return "龙凤区"; + case 230604: + return "让胡路区"; + case 230605: + return "红岗区"; + case 230606: + return "大同区"; + case 230621: + return "肇州县"; + case 230622: + return "肇源县"; + case 230623: + return "林甸县"; + case 230624: + return "杜尔伯特蒙古族自治县"; + case 2307: + return "伊春市"; + case 230701: + return "市辖区"; + case 230702: + return "伊春区"; + case 230703: + return "南岔区"; + case 230704: + return "友好区"; + case 230705: + return "西林区"; + case 230706: + return "翠峦区"; + case 230707: + return "新青区"; + case 230708: + return "美溪区"; + case 230709: + return "金山屯区"; + case 230710: + return "五营区"; + case 230711: + return "乌马河区"; + case 230712: + return "汤旺河区"; + case 230713: + return "带岭区"; + case 230714: + return "乌伊岭区"; + case 230715: + return "红星区"; + case 230716: + return "上甘岭区"; + case 230722: + return "嘉荫县"; + case 230781: + return "铁力市"; + case 2308: + return "佳木斯市"; + case 230801: + return "市辖区"; + case 230803: + return "向阳区"; + case 230804: + return "前进区"; + case 230805: + return "东风区"; + case 230811: + return "郊区"; + case 230822: + return "桦南县"; + case 230826: + return "桦川县"; + case 230828: + return "汤原县"; + case 230833: + return "抚远县"; + case 230881: + return "同江市"; + case 230882: + return "富锦市"; + case 2309: + return "七台河市"; + case 230901: + return "市辖区"; + case 230902: + return "新兴区"; + case 230903: + return "桃山区"; + case 230904: + return "茄子河区"; + case 230921: + return "勃利县"; + case 2310: + return "牡丹江市"; + case 231001: + return "市辖区"; + case 231002: + return "东安区"; + case 231003: + return "阳明区"; + case 231004: + return "爱民区"; + case 231005: + return "西安区"; + case 231024: + return "东宁县"; + case 231025: + return "林口县"; + case 231081: + return "绥芬河市"; + case 231083: + return "海林市"; + case 231084: + return "宁安市"; + case 231085: + return "穆棱市"; + case 2311: + return "黑河市"; + case 231101: + return "市辖区"; + case 231102: + return "爱辉区"; + case 231121: + return "嫩江县"; + case 231123: + return "逊克县"; + case 231124: + return "孙吴县"; + case 231181: + return "北安市"; + case 231182: + return "五大连池市"; + case 2312: + return "绥化市"; + case 231201: + return "市辖区"; + case 231202: + return "北林区"; + case 231221: + return "望奎县"; + case 231222: + return "兰西县"; + case 231223: + return "青冈县"; + case 231224: + return "庆安县"; + case 231225: + return "明水县"; + case 231226: + return "绥棱县"; + case 231281: + return "安达市"; + case 231282: + return "肇东市"; + case 231283: + return "海伦市"; + case 2327: + return "大兴安岭地区"; + case 232721: + return "呼玛县"; + case 232722: + return "塔河县"; + case 232723: + return "漠河县"; + case 31: + return "上海市"; + case 3101: + return "市辖区"; + case 310101: + return "黄浦区"; + case 310104: + return "徐汇区"; + case 310105: + return "长宁区"; + case 310106: + return "静安区"; + case 310107: + return "普陀区"; + case 310108: + return "闸北区"; + case 310109: + return "虹口区"; + case 310110: + return "杨浦区"; + case 310112: + return "闵行区"; + case 310113: + return "宝山区"; + case 310114: + return "嘉定区"; + case 310115: + return "浦东新区"; + case 310116: + return "金山区"; + case 310117: + return "松江区"; + case 310118: + return "青浦区"; + case 310120: + return "奉贤区"; + case 3102: + return "县"; + case 310230: + return "崇明县"; + case 32: + return "江苏省"; + case 3201: + return "南京市"; + case 320101: + return "市辖区"; + case 320102: + return "玄武区"; + case 320104: + return "秦淮区"; + case 320105: + return "建邺区"; + case 320106: + return "鼓楼区"; + case 320111: + return "浦口区"; + case 320113: + return "栖霞区"; + case 320114: + return "雨花台区"; + case 320115: + return "江宁区"; + case 320116: + return "六合区"; + case 320117: + return "溧水区"; + case 320118: + return "高淳区"; + case 3202: + return "无锡市"; + case 320201: + return "市辖区"; + case 320202: + return "崇安区"; + case 320203: + return "南长区"; + case 320204: + return "北塘区"; + case 320205: + return "锡山区"; + case 320206: + return "惠山区"; + case 320211: + return "滨湖区"; + case 320281: + return "江阴市"; + case 320282: + return "宜兴市"; + case 3203: + return "徐州市"; + case 320301: + return "市辖区"; + case 320302: + return "鼓楼区"; + case 320303: + return "云龙区"; + case 320305: + return "贾汪区"; + case 320311: + return "泉山区"; + case 320312: + return "铜山区"; + case 320321: + return "丰县"; + case 320322: + return "沛县"; + case 320324: + return "睢宁县"; + case 320381: + return "新沂市"; + case 320382: + return "邳州市"; + case 3204: + return "常州市"; + case 320401: + return "市辖区"; + case 320402: + return "天宁区"; + case 320404: + return "钟楼区"; + case 320405: + return "戚墅堰区"; + case 320411: + return "新北区"; + case 320412: + return "武进区"; + case 320481: + return "溧阳市"; + case 320482: + return "金坛市"; + case 3205: + return "苏州市"; + case 320501: + return "市辖区"; + case 320505: + return "虎丘区"; + case 320506: + return "吴中区"; + case 320507: + return "相城区"; + case 320508: + return "姑苏区"; + case 320509: + return "吴江区"; + case 320581: + return "常熟市"; + case 320582: + return "张家港市"; + case 320583: + return "昆山市"; + case 320585: + return "太仓市"; + case 3206: + return "南通市"; + case 320601: + return "市辖区"; + case 320602: + return "崇川区"; + case 320611: + return "港闸区"; + case 320612: + return "通州区"; + case 320621: + return "海安县"; + case 320623: + return "如东县"; + case 320681: + return "启东市"; + case 320682: + return "如皋市"; + case 320684: + return "海门市"; + case 3207: + return "连云港市"; + case 320701: + return "市辖区"; + case 320703: + return "连云区"; + case 320706: + return "海州区"; + case 320707: + return "赣榆区"; + case 320722: + return "东海县"; + case 320723: + return "灌云县"; + case 320724: + return "灌南县"; + case 3208: + return "淮安市"; + case 320801: + return "市辖区"; + case 320802: + return "清河区"; + case 320803: + return "淮安区"; + case 320804: + return "淮阴区"; + case 320811: + return "清浦区"; + case 320826: + return "涟水县"; + case 320829: + return "洪泽县"; + case 320830: + return "盱眙县"; + case 320831: + return "金湖县"; + case 3209: + return "盐城市"; + case 320901: + return "市辖区"; + case 320902: + return "亭湖区"; + case 320903: + return "盐都区"; + case 320921: + return "响水县"; + case 320922: + return "滨海县"; + case 320923: + return "阜宁县"; + case 320924: + return "射阳县"; + case 320925: + return "建湖县"; + case 320981: + return "东台市"; + case 320982: + return "大丰市"; + case 3210: + return "扬州市"; + case 321001: + return "市辖区"; + case 321002: + return "广陵区"; + case 321003: + return "邗江区"; + case 321012: + return "江都区"; + case 321023: + return "宝应县"; + case 321081: + return "仪征市"; + case 321084: + return "高邮市"; + case 3211: + return "镇江市"; + case 321101: + return "市辖区"; + case 321102: + return "京口区"; + case 321111: + return "润州区"; + case 321112: + return "丹徒区"; + case 321181: + return "丹阳市"; + case 321182: + return "扬中市"; + case 321183: + return "句容市"; + case 3212: + return "泰州市"; + case 321201: + return "市辖区"; + case 321202: + return "海陵区"; + case 321203: + return "高港区"; + case 321204: + return "姜堰区"; + case 321281: + return "兴化市"; + case 321282: + return "靖江市"; + case 321283: + return "泰兴市"; + case 3213: + return "宿迁市"; + case 321301: + return "市辖区"; + case 321302: + return "宿城区"; + case 321311: + return "宿豫区"; + case 321322: + return "沭阳县"; + case 321323: + return "泗阳县"; + case 321324: + return "泗洪县"; + case 33: + return "浙江省"; + case 3301: + return "杭州市"; + case 330101: + return "市辖区"; + case 330102: + return "上城区"; + case 330103: + return "下城区"; + case 330104: + return "江干区"; + case 330105: + return "拱墅区"; + case 330106: + return "西湖区"; + case 330108: + return "滨江区"; + case 330109: + return "萧山区"; + case 330110: + return "余杭区"; + case 330122: + return "桐庐县"; + case 330127: + return "淳安县"; + case 330182: + return "建德市"; + case 330183: + return "富阳市"; + case 330185: + return "临安市"; + case 3302: + return "宁波市"; + case 330201: + return "市辖区"; + case 330203: + return "海曙区"; + case 330204: + return "江东区"; + case 330205: + return "江北区"; + case 330206: + return "北仑区"; + case 330211: + return "镇海区"; + case 330212: + return "鄞州区"; + case 330225: + return "象山县"; + case 330226: + return "宁海县"; + case 330281: + return "余姚市"; + case 330282: + return "慈溪市"; + case 330283: + return "奉化市"; + case 3303: + return "温州市"; + case 330301: + return "市辖区"; + case 330302: + return "鹿城区"; + case 330303: + return "龙湾区"; + case 330304: + return "瓯海区"; + case 330322: + return "洞头县"; + case 330324: + return "永嘉县"; + case 330326: + return "平阳县"; + case 330327: + return "苍南县"; + case 330328: + return "文成县"; + case 330329: + return "泰顺县"; + case 330381: + return "瑞安市"; + case 330382: + return "乐清市"; + case 3304: + return "嘉兴市"; + case 330401: + return "市辖区"; + case 330402: + return "南湖区"; + case 330411: + return "秀洲区"; + case 330421: + return "嘉善县"; + case 330424: + return "海盐县"; + case 330481: + return "海宁市"; + case 330482: + return "平湖市"; + case 330483: + return "桐乡市"; + case 3305: + return "湖州市"; + case 330501: + return "市辖区"; + case 330502: + return "吴兴区"; + case 330503: + return "南浔区"; + case 330521: + return "德清县"; + case 330522: + return "长兴县"; + case 330523: + return "安吉县"; + case 3306: + return "绍兴市"; + case 330601: + return "市辖区"; + case 330602: + return "越城区"; + case 330603: + return "柯桥区"; + case 330604: + return "上虞区"; + case 330624: + return "新昌县"; + case 330681: + return "诸暨市"; + case 330683: + return "嵊州市"; + case 3307: + return "金华市"; + case 330701: + return "市辖区"; + case 330702: + return "婺城区"; + case 330703: + return "金东区"; + case 330723: + return "武义县"; + case 330726: + return "浦江县"; + case 330727: + return "磐安县"; + case 330781: + return "兰溪市"; + case 330782: + return "义乌市"; + case 330783: + return "东阳市"; + case 330784: + return "永康市"; + case 3308: + return "衢州市"; + case 330801: + return "市辖区"; + case 330802: + return "柯城区"; + case 330803: + return "衢江区"; + case 330822: + return "常山县"; + case 330824: + return "开化县"; + case 330825: + return "龙游县"; + case 330881: + return "江山市"; + case 3309: + return "舟山市"; + case 330901: + return "市辖区"; + case 330902: + return "定海区"; + case 330903: + return "普陀区"; + case 330921: + return "岱山县"; + case 330922: + return "嵊泗县"; + case 3310: + return "台州市"; + case 331001: + return "市辖区"; + case 331002: + return "椒江区"; + case 331003: + return "黄岩区"; + case 331004: + return "路桥区"; + case 331021: + return "玉环县"; + case 331022: + return "三门县"; + case 331023: + return "天台县"; + case 331024: + return "仙居县"; + case 331081: + return "温岭市"; + case 331082: + return "临海市"; + case 3311: + return "丽水市"; + case 331101: + return "市辖区"; + case 331102: + return "莲都区"; + case 331121: + return "青田县"; + case 331122: + return "缙云县"; + case 331123: + return "遂昌县"; + case 331124: + return "松阳县"; + case 331125: + return "云和县"; + case 331126: + return "庆元县"; + case 331127: + return "景宁畲族自治县"; + case 331181: + return "龙泉市"; + case 34: + return "安徽省"; + case 3401: + return "合肥市"; + case 340101: + return "市辖区"; + case 340102: + return "瑶海区"; + case 340103: + return "庐阳区"; + case 340104: + return "蜀山区"; + case 340111: + return "包河区"; + case 340121: + return "长丰县"; + case 340122: + return "肥东县"; + case 340123: + return "肥西县"; + case 340124: + return "庐江县"; + case 340181: + return "巢湖市"; + case 3402: + return "芜湖市"; + case 340201: + return "市辖区"; + case 340202: + return "镜湖区"; + case 340203: + return "弋江区"; + case 340207: + return "鸠江区"; + case 340208: + return "三山区"; + case 340221: + return "芜湖县"; + case 340222: + return "繁昌县"; + case 340223: + return "南陵县"; + case 340225: + return "无为县"; + case 3403: + return "蚌埠市"; + case 340301: + return "市辖区"; + case 340302: + return "龙子湖区"; + case 340303: + return "蚌山区"; + case 340304: + return "禹会区"; + case 340311: + return "淮上区"; + case 340321: + return "怀远县"; + case 340322: + return "五河县"; + case 340323: + return "固镇县"; + case 3404: + return "淮南市"; + case 340401: + return "市辖区"; + case 340402: + return "大通区"; + case 340403: + return "田家庵区"; + case 340404: + return "谢家集区"; + case 340405: + return "八公山区"; + case 340406: + return "潘集区"; + case 340421: + return "凤台县"; + case 3405: + return "马鞍山市"; + case 340501: + return "市辖区"; + case 340503: + return "花山区"; + case 340504: + return "雨山区"; + case 340506: + return "博望区"; + case 340521: + return "当涂县"; + case 340522: + return "含山县"; + case 340523: + return "和县"; + case 3406: + return "淮北市"; + case 340601: + return "市辖区"; + case 340602: + return "杜集区"; + case 340603: + return "相山区"; + case 340604: + return "烈山区"; + case 340621: + return "濉溪县"; + case 3407: + return "铜陵市"; + case 340701: + return "市辖区"; + case 340702: + return "铜官山区"; + case 340703: + return "狮子山区"; + case 340711: + return "郊区"; + case 340721: + return "铜陵县"; + case 3408: + return "安庆市"; + case 340801: + return "市辖区"; + case 340802: + return "迎江区"; + case 340803: + return "大观区"; + case 340811: + return "宜秀区"; + case 340822: + return "怀宁县"; + case 340823: + return "枞阳县"; + case 340824: + return "潜山县"; + case 340825: + return "太湖县"; + case 340826: + return "宿松县"; + case 340827: + return "望江县"; + case 340828: + return "岳西县"; + case 340881: + return "桐城市"; + case 3410: + return "黄山市"; + case 341001: + return "市辖区"; + case 341002: + return "屯溪区"; + case 341003: + return "黄山区"; + case 341004: + return "徽州区"; + case 341021: + return "歙县"; + case 341022: + return "休宁县"; + case 341023: + return "黟县"; + case 341024: + return "祁门县"; + case 3411: + return "滁州市"; + case 341101: + return "市辖区"; + case 341102: + return "琅琊区"; + case 341103: + return "南谯区"; + case 341122: + return "来安县"; + case 341124: + return "全椒县"; + case 341125: + return "定远县"; + case 341126: + return "凤阳县"; + case 341181: + return "天长市"; + case 341182: + return "明光市"; + case 3412: + return "阜阳市"; + case 341201: + return "市辖区"; + case 341202: + return "颍州区"; + case 341203: + return "颍东区"; + case 341204: + return "颍泉区"; + case 341221: + return "临泉县"; + case 341222: + return "太和县"; + case 341225: + return "阜南县"; + case 341226: + return "颍上县"; + case 341282: + return "界首市"; + case 3413: + return "宿州市"; + case 341301: + return "市辖区"; + case 341302: + return "埇桥区"; + case 341321: + return "砀山县"; + case 341322: + return "萧县"; + case 341323: + return "灵璧县"; + case 341324: + return "泗县"; + case 3415: + return "六安市"; + case 341501: + return "市辖区"; + case 341502: + return "金安区"; + case 341503: + return "裕安区"; + case 341521: + return "寿县"; + case 341522: + return "霍邱县"; + case 341523: + return "舒城县"; + case 341524: + return "金寨县"; + case 341525: + return "霍山县"; + case 3416: + return "亳州市"; + case 341601: + return "市辖区"; + case 341602: + return "谯城区"; + case 341621: + return "涡阳县"; + case 341622: + return "蒙城县"; + case 341623: + return "利辛县"; + case 3417: + return "池州市"; + case 341701: + return "市辖区"; + case 341702: + return "贵池区"; + case 341721: + return "东至县"; + case 341722: + return "石台县"; + case 341723: + return "青阳县"; + case 3418: + return "宣城市"; + case 341801: + return "市辖区"; + case 341802: + return "宣州区"; + case 341821: + return "郎溪县"; + case 341822: + return "广德县"; + case 341823: + return "泾县"; + case 341824: + return "绩溪县"; + case 341825: + return "旌德县"; + case 341881: + return "宁国市"; + case 35: + return "福建省"; + case 3501: + return "福州市"; + case 350101: + return "市辖区"; + case 350102: + return "鼓楼区"; + case 350103: + return "台江区"; + case 350104: + return "仓山区"; + case 350105: + return "马尾区"; + case 350111: + return "晋安区"; + case 350121: + return "闽侯县"; + case 350122: + return "连江县"; + case 350123: + return "罗源县"; + case 350124: + return "闽清县"; + case 350125: + return "永泰县"; + case 350128: + return "平潭县"; + case 350181: + return "福清市"; + case 350182: + return "长乐市"; + case 3502: + return "厦门市"; + case 350201: + return "市辖区"; + case 350203: + return "思明区"; + case 350205: + return "海沧区"; + case 350206: + return "湖里区"; + case 350211: + return "集美区"; + case 350212: + return "同安区"; + case 350213: + return "翔安区"; + case 3503: + return "莆田市"; + case 350301: + return "市辖区"; + case 350302: + return "城厢区"; + case 350303: + return "涵江区"; + case 350304: + return "荔城区"; + case 350305: + return "秀屿区"; + case 350322: + return "仙游县"; + case 3504: + return "三明市"; + case 350401: + return "市辖区"; + case 350402: + return "梅列区"; + case 350403: + return "三元区"; + case 350421: + return "明溪县"; + case 350423: + return "清流县"; + case 350424: + return "宁化县"; + case 350425: + return "大田县"; + case 350426: + return "尤溪县"; + case 350427: + return "沙县"; + case 350428: + return "将乐县"; + case 350429: + return "泰宁县"; + case 350430: + return "建宁县"; + case 350481: + return "永安市"; + case 3505: + return "泉州市"; + case 350501: + return "市辖区"; + case 350502: + return "鲤城区"; + case 350503: + return "丰泽区"; + case 350504: + return "洛江区"; + case 350505: + return "泉港区"; + case 350521: + return "惠安县"; + case 350524: + return "安溪县"; + case 350525: + return "永春县"; + case 350526: + return "德化县"; + case 350527: + return "金门县"; + case 350581: + return "石狮市"; + case 350582: + return "晋江市"; + case 350583: + return "南安市"; + case 3506: + return "漳州市"; + case 350601: + return "市辖区"; + case 350602: + return "芗城区"; + case 350603: + return "龙文区"; + case 350622: + return "云霄县"; + case 350623: + return "漳浦县"; + case 350624: + return "诏安县"; + case 350625: + return "长泰县"; + case 350626: + return "东山县"; + case 350627: + return "南靖县"; + case 350628: + return "平和县"; + case 350629: + return "华安县"; + case 350681: + return "龙海市"; + case 3507: + return "南平市"; + case 350701: + return "市辖区"; + case 350702: + return "延平区"; + case 350721: + return "顺昌县"; + case 350722: + return "浦城县"; + case 350723: + return "光泽县"; + case 350724: + return "松溪县"; + case 350725: + return "政和县"; + case 350781: + return "邵武市"; + case 350782: + return "武夷山市"; + case 350783: + return "建瓯市"; + case 350784: + return "建阳市"; + case 3508: + return "龙岩市"; + case 350801: + return "市辖区"; + case 350802: + return "新罗区"; + case 350821: + return "长汀县"; + case 350822: + return "永定县"; + case 350823: + return "上杭县"; + case 350824: + return "武平县"; + case 350825: + return "连城县"; + case 350881: + return "漳平市"; + case 3509: + return "宁德市"; + case 350901: + return "市辖区"; + case 350902: + return "蕉城区"; + case 350921: + return "霞浦县"; + case 350922: + return "古田县"; + case 350923: + return "屏南县"; + case 350924: + return "寿宁县"; + case 350925: + return "周宁县"; + case 350926: + return "柘荣县"; + case 350981: + return "福安市"; + case 350982: + return "福鼎市"; + case 36: + return "江西省"; + case 3601: + return "南昌市"; + case 360101: + return "市辖区"; + case 360102: + return "东湖区"; + case 360103: + return "西湖区"; + case 360104: + return "青云谱区"; + case 360105: + return "湾里区"; + case 360111: + return "青山湖区"; + case 360121: + return "南昌县"; + case 360122: + return "新建县"; + case 360123: + return "安义县"; + case 360124: + return "进贤县"; + case 3602: + return "景德镇市"; + case 360201: + return "市辖区"; + case 360202: + return "昌江区"; + case 360203: + return "珠山区"; + case 360222: + return "浮梁县"; + case 360281: + return "乐平市"; + case 3603: + return "萍乡市"; + case 360301: + return "市辖区"; + case 360302: + return "安源区"; + case 360313: + return "湘东区"; + case 360321: + return "莲花县"; + case 360322: + return "上栗县"; + case 360323: + return "芦溪县"; + case 3604: + return "九江市"; + case 360401: + return "市辖区"; + case 360402: + return "庐山区"; + case 360403: + return "浔阳区"; + case 360421: + return "九江县"; + case 360423: + return "武宁县"; + case 360424: + return "修水县"; + case 360425: + return "永修县"; + case 360426: + return "德安县"; + case 360427: + return "星子县"; + case 360428: + return "都昌县"; + case 360429: + return "湖口县"; + case 360430: + return "彭泽县"; + case 360481: + return "瑞昌市"; + case 360482: + return "共青城市"; + case 3605: + return "新余市"; + case 360501: + return "市辖区"; + case 360502: + return "渝水区"; + case 360521: + return "分宜县"; + case 3606: + return "鹰潭市"; + case 360601: + return "市辖区"; + case 360602: + return "月湖区"; + case 360622: + return "余江县"; + case 360681: + return "贵溪市"; + case 3607: + return "赣州市"; + case 360701: + return "市辖区"; + case 360702: + return "章贡区"; + case 360703: + return "南康区"; + case 360721: + return "赣县"; + case 360722: + return "信丰县"; + case 360723: + return "大余县"; + case 360724: + return "上犹县"; + case 360725: + return "崇义县"; + case 360726: + return "安远县"; + case 360727: + return "龙南县"; + case 360728: + return "定南县"; + case 360729: + return "全南县"; + case 360730: + return "宁都县"; + case 360731: + return "于都县"; + case 360732: + return "兴国县"; + case 360733: + return "会昌县"; + case 360734: + return "寻乌县"; + case 360735: + return "石城县"; + case 360781: + return "瑞金市"; + case 3608: + return "吉安市"; + case 360801: + return "市辖区"; + case 360802: + return "吉州区"; + case 360803: + return "青原区"; + case 360821: + return "吉安县"; + case 360822: + return "吉水县"; + case 360823: + return "峡江县"; + case 360824: + return "新干县"; + case 360825: + return "永丰县"; + case 360826: + return "泰和县"; + case 360827: + return "遂川县"; + case 360828: + return "万安县"; + case 360829: + return "安福县"; + case 360830: + return "永新县"; + case 360881: + return "井冈山市"; + case 3609: + return "宜春市"; + case 360901: + return "市辖区"; + case 360902: + return "袁州区"; + case 360921: + return "奉新县"; + case 360922: + return "万载县"; + case 360923: + return "上高县"; + case 360924: + return "宜丰县"; + case 360925: + return "靖安县"; + case 360926: + return "铜鼓县"; + case 360981: + return "丰城市"; + case 360982: + return "樟树市"; + case 360983: + return "高安市"; + case 3610: + return "抚州市"; + case 361001: + return "市辖区"; + case 361002: + return "临川区"; + case 361021: + return "南城县"; + case 361022: + return "黎川县"; + case 361023: + return "南丰县"; + case 361024: + return "崇仁县"; + case 361025: + return "乐安县"; + case 361026: + return "宜黄县"; + case 361027: + return "金溪县"; + case 361028: + return "资溪县"; + case 361029: + return "东乡县"; + case 361030: + return "广昌县"; + case 3611: + return "上饶市"; + case 361101: + return "市辖区"; + case 361102: + return "信州区"; + case 361121: + return "上饶县"; + case 361122: + return "广丰县"; + case 361123: + return "玉山县"; + case 361124: + return "铅山县"; + case 361125: + return "横峰县"; + case 361126: + return "弋阳县"; + case 361127: + return "余干县"; + case 361128: + return "鄱阳县"; + case 361129: + return "万年县"; + case 361130: + return "婺源县"; + case 361181: + return "德兴市"; + case 37: + return "山东省"; + case 3701: + return "济南市"; + case 370101: + return "市辖区"; + case 370102: + return "历下区"; + case 370103: + return "市中区"; + case 370104: + return "槐荫区"; + case 370105: + return "天桥区"; + case 370112: + return "历城区"; + case 370113: + return "长清区"; + case 370124: + return "平阴县"; + case 370125: + return "济阳县"; + case 370126: + return "商河县"; + case 370181: + return "章丘市"; + case 3702: + return "青岛市"; + case 370201: + return "市辖区"; + case 370202: + return "市南区"; + case 370203: + return "市北区"; + case 370211: + return "黄岛区"; + case 370212: + return "崂山区"; + case 370213: + return "李沧区"; + case 370214: + return "城阳区"; + case 370281: + return "胶州市"; + case 370282: + return "即墨市"; + case 370283: + return "平度市"; + case 370285: + return "莱西市"; + case 3703: + return "淄博市"; + case 370301: + return "市辖区"; + case 370302: + return "淄川区"; + case 370303: + return "张店区"; + case 370304: + return "博山区"; + case 370305: + return "临淄区"; + case 370306: + return "周村区"; + case 370321: + return "桓台县"; + case 370322: + return "高青县"; + case 370323: + return "沂源县"; + case 3704: + return "枣庄市"; + case 370401: + return "市辖区"; + case 370402: + return "市中区"; + case 370403: + return "薛城区"; + case 370404: + return "峄城区"; + case 370405: + return "台儿庄区"; + case 370406: + return "山亭区"; + case 370481: + return "滕州市"; + case 3705: + return "东营市"; + case 370501: + return "市辖区"; + case 370502: + return "东营区"; + case 370503: + return "河口区"; + case 370521: + return "垦利县"; + case 370522: + return "利津县"; + case 370523: + return "广饶县"; + case 3706: + return "烟台市"; + case 370601: + return "市辖区"; + case 370602: + return "芝罘区"; + case 370611: + return "福山区"; + case 370612: + return "牟平区"; + case 370613: + return "莱山区"; + case 370634: + return "长岛县"; + case 370681: + return "龙口市"; + case 370682: + return "莱阳市"; + case 370683: + return "莱州市"; + case 370684: + return "蓬莱市"; + case 370685: + return "招远市"; + case 370686: + return "栖霞市"; + case 370687: + return "海阳市"; + case 3707: + return "潍坊市"; + case 370701: + return "市辖区"; + case 370702: + return "潍城区"; + case 370703: + return "寒亭区"; + case 370704: + return "坊子区"; + case 370705: + return "奎文区"; + case 370724: + return "临朐县"; + case 370725: + return "昌乐县"; + case 370781: + return "青州市"; + case 370782: + return "诸城市"; + case 370783: + return "寿光市"; + case 370784: + return "安丘市"; + case 370785: + return "高密市"; + case 370786: + return "昌邑市"; + case 3708: + return "济宁市"; + case 370801: + return "市辖区"; + case 370811: + return "任城区"; + case 370812: + return "兖州区"; + case 370826: + return "微山县"; + case 370827: + return "鱼台县"; + case 370828: + return "金乡县"; + case 370829: + return "嘉祥县"; + case 370830: + return "汶上县"; + case 370831: + return "泗水县"; + case 370832: + return "梁山县"; + case 370881: + return "曲阜市"; + case 370883: + return "邹城市"; + case 3709: + return "泰安市"; + case 370901: + return "市辖区"; + case 370902: + return "泰山区"; + case 370911: + return "岱岳区"; + case 370921: + return "宁阳县"; + case 370923: + return "东平县"; + case 370982: + return "新泰市"; + case 370983: + return "肥城市"; + case 3710: + return "威海市"; + case 371001: + return "市辖区"; + case 371002: + return "环翠区"; + case 371003: + return "文登区"; + case 371082: + return "荣成市"; + case 371083: + return "乳山市"; + case 3711: + return "日照市"; + case 371101: + return "市辖区"; + case 371102: + return "东港区"; + case 371103: + return "岚山区"; + case 371121: + return "五莲县"; + case 371122: + return "莒县"; + case 3712: + return "莱芜市"; + case 371201: + return "市辖区"; + case 371202: + return "莱城区"; + case 371203: + return "钢城区"; + case 3713: + return "临沂市"; + case 371301: + return "市辖区"; + case 371302: + return "兰山区"; + case 371311: + return "罗庄区"; + case 371312: + return "河东区"; + case 371321: + return "沂南县"; + case 371322: + return "郯城县"; + case 371323: + return "沂水县"; + case 371324: + return "兰陵县"; + case 371325: + return "费县"; + case 371326: + return "平邑县"; + case 371327: + return "莒南县"; + case 371328: + return "蒙阴县"; + case 371329: + return "临沭县"; + case 3714: + return "德州市"; + case 371401: + return "市辖区"; + case 371402: + return "德城区"; + case 371403: + return "陵城区"; + case 371422: + return "宁津县"; + case 371423: + return "庆云县"; + case 371424: + return "临邑县"; + case 371425: + return "齐河县"; + case 371426: + return "平原县"; + case 371427: + return "夏津县"; + case 371428: + return "武城县"; + case 371481: + return "乐陵市"; + case 371482: + return "禹城市"; + case 3715: + return "聊城市"; + case 371501: + return "市辖区"; + case 371502: + return "东昌府区"; + case 371521: + return "阳谷县"; + case 371522: + return "莘县"; + case 371523: + return "茌平县"; + case 371524: + return "东阿县"; + case 371525: + return "冠县"; + case 371526: + return "高唐县"; + case 371581: + return "临清市"; + case 3716: + return "滨州市"; + case 371601: + return "市辖区"; + case 371602: + return "滨城区"; + case 371603: + return "沾化区"; + case 371621: + return "惠民县"; + case 371622: + return "阳信县"; + case 371623: + return "无棣县"; + case 371625: + return "博兴县"; + case 371626: + return "邹平县"; + case 3717: + return "菏泽市"; + case 371701: + return "市辖区"; + case 371702: + return "牡丹区"; + case 371721: + return "曹县"; + case 371722: + return "单县"; + case 371723: + return "成武县"; + case 371724: + return "巨野县"; + case 371725: + return "郓城县"; + case 371726: + return "鄄城县"; + case 371727: + return "定陶县"; + case 371728: + return "东明县"; + case 41: + return "河南省"; + case 4101: + return "郑州市"; + case 410101: + return "市辖区"; + case 410102: + return "中原区"; + case 410103: + return "二七区"; + case 410104: + return "管城回族区"; + case 410105: + return "金水区"; + case 410106: + return "上街区"; + case 410108: + return "惠济区"; + case 410122: + return "中牟县"; + case 410181: + return "巩义市"; + case 410182: + return "荥阳市"; + case 410183: + return "新密市"; + case 410184: + return "新郑市"; + case 410185: + return "登封市"; + case 4102: + return "开封市"; + case 410201: + return "市辖区"; + case 410202: + return "龙亭区"; + case 410203: + return "顺河回族区"; + case 410204: + return "鼓楼区"; + case 410205: + return "禹王台区"; + case 410211: + return "金明区"; + case 410221: + return "杞县"; + case 410222: + return "通许县"; + case 410223: + return "尉氏县"; + case 410224: + return "开封县"; + case 410225: + return "兰考县"; + case 4103: + return "洛阳市"; + case 410301: + return "市辖区"; + case 410302: + return "老城区"; + case 410303: + return "西工区"; + case 410304: + return "瀍河回族区"; + case 410305: + return "涧西区"; + case 410306: + return "吉利区"; + case 410311: + return "洛龙区"; + case 410322: + return "孟津县"; + case 410323: + return "新安县"; + case 410324: + return "栾川县"; + case 410325: + return "嵩县"; + case 410326: + return "汝阳县"; + case 410327: + return "宜阳县"; + case 410328: + return "洛宁县"; + case 410329: + return "伊川县"; + case 410381: + return "偃师市"; + case 4104: + return "平顶山市"; + case 410401: + return "市辖区"; + case 410402: + return "新华区"; + case 410403: + return "卫东区"; + case 410404: + return "石龙区"; + case 410411: + return "湛河区"; + case 410421: + return "宝丰县"; + case 410422: + return "叶县"; + case 410423: + return "鲁山县"; + case 410425: + return "郏县"; + case 410481: + return "舞钢市"; + case 410482: + return "汝州市"; + case 4105: + return "安阳市"; + case 410501: + return "市辖区"; + case 410502: + return "文峰区"; + case 410503: + return "北关区"; + case 410505: + return "殷都区"; + case 410506: + return "龙安区"; + case 410522: + return "安阳县"; + case 410523: + return "汤阴县"; + case 410526: + return "滑县"; + case 410527: + return "内黄县"; + case 410581: + return "林州市"; + case 4106: + return "鹤壁市"; + case 410601: + return "市辖区"; + case 410602: + return "鹤山区"; + case 410603: + return "山城区"; + case 410611: + return "淇滨区"; + case 410621: + return "浚县"; + case 410622: + return "淇县"; + case 4107: + return "新乡市"; + case 410701: + return "市辖区"; + case 410702: + return "红旗区"; + case 410703: + return "卫滨区"; + case 410704: + return "凤泉区"; + case 410711: + return "牧野区"; + case 410721: + return "新乡县"; + case 410724: + return "获嘉县"; + case 410725: + return "原阳县"; + case 410726: + return "延津县"; + case 410727: + return "封丘县"; + case 410728: + return "长垣县"; + case 410781: + return "卫辉市"; + case 410782: + return "辉县市"; + case 4108: + return "焦作市"; + case 410801: + return "市辖区"; + case 410802: + return "解放区"; + case 410803: + return "中站区"; + case 410804: + return "马村区"; + case 410811: + return "山阳区"; + case 410821: + return "修武县"; + case 410822: + return "博爱县"; + case 410823: + return "武陟县"; + case 410825: + return "温县"; + case 410882: + return "沁阳市"; + case 410883: + return "孟州市"; + case 4109: + return "濮阳市"; + case 410901: + return "市辖区"; + case 410902: + return "华龙区"; + case 410922: + return "清丰县"; + case 410923: + return "南乐县"; + case 410926: + return "范县"; + case 410927: + return "台前县"; + case 410928: + return "濮阳县"; + case 4110: + return "许昌市"; + case 411001: + return "市辖区"; + case 411002: + return "魏都区"; + case 411023: + return "许昌县"; + case 411024: + return "鄢陵县"; + case 411025: + return "襄城县"; + case 411081: + return "禹州市"; + case 411082: + return "长葛市"; + case 4111: + return "漯河市"; + case 411101: + return "市辖区"; + case 411102: + return "源汇区"; + case 411103: + return "郾城区"; + case 411104: + return "召陵区"; + case 411121: + return "舞阳县"; + case 411122: + return "临颍县"; + case 4112: + return "三门峡市"; + case 411201: + return "市辖区"; + case 411202: + return "湖滨区"; + case 411221: + return "渑池县"; + case 411222: + return "陕县"; + case 411224: + return "卢氏县"; + case 411281: + return "义马市"; + case 411282: + return "灵宝市"; + case 4113: + return "南阳市"; + case 411301: + return "市辖区"; + case 411302: + return "宛城区"; + case 411303: + return "卧龙区"; + case 411321: + return "南召县"; + case 411322: + return "方城县"; + case 411323: + return "西峡县"; + case 411324: + return "镇平县"; + case 411325: + return "内乡县"; + case 411326: + return "淅川县"; + case 411327: + return "社旗县"; + case 411328: + return "唐河县"; + case 411329: + return "新野县"; + case 411330: + return "桐柏县"; + case 411381: + return "邓州市"; + case 4114: + return "商丘市"; + case 411401: + return "市辖区"; + case 411402: + return "梁园区"; + case 411403: + return "睢阳区"; + case 411421: + return "民权县"; + case 411422: + return "睢县"; + case 411423: + return "宁陵县"; + case 411424: + return "柘城县"; + case 411425: + return "虞城县"; + case 411426: + return "夏邑县"; + case 411481: + return "永城市"; + case 4115: + return "信阳市"; + case 411501: + return "市辖区"; + case 411502: + return "浉河区"; + case 411503: + return "平桥区"; + case 411521: + return "罗山县"; + case 411522: + return "光山县"; + case 411523: + return "新县"; + case 411524: + return "商城县"; + case 411525: + return "固始县"; + case 411526: + return "潢川县"; + case 411527: + return "淮滨县"; + case 411528: + return "息县"; + case 4116: + return "周口市"; + case 411601: + return "市辖区"; + case 411602: + return "川汇区"; + case 411621: + return "扶沟县"; + case 411622: + return "西华县"; + case 411623: + return "商水县"; + case 411624: + return "沈丘县"; + case 411625: + return "郸城县"; + case 411626: + return "淮阳县"; + case 411627: + return "太康县"; + case 411628: + return "鹿邑县"; + case 411681: + return "项城市"; + case 4117: + return "驻马店市"; + case 411701: + return "市辖区"; + case 411702: + return "驿城区"; + case 411721: + return "西平县"; + case 411722: + return "上蔡县"; + case 411723: + return "平舆县"; + case 411724: + return "正阳县"; + case 411725: + return "确山县"; + case 411726: + return "泌阳县"; + case 411727: + return "汝南县"; + case 411728: + return "遂平县"; + case 411729: + return "新蔡县"; + case 4190: + return "省直辖县级行政区划"; + case 419001: + return "济源市"; + case 42: + return "湖北省"; + case 4201: + return "武汉市"; + case 420101: + return "市辖区"; + case 420102: + return "江岸区"; + case 420103: + return "江汉区"; + case 420104: + return "硚口区"; + case 420105: + return "汉阳区"; + case 420106: + return "武昌区"; + case 420107: + return "青山区"; + case 420111: + return "洪山区"; + case 420112: + return "东西湖区"; + case 420113: + return "汉南区"; + case 420114: + return "蔡甸区"; + case 420115: + return "江夏区"; + case 420116: + return "黄陂区"; + case 420117: + return "新洲区"; + case 4202: + return "黄石市"; + case 420201: + return "市辖区"; + case 420202: + return "黄石港区"; + case 420203: + return "西塞山区"; + case 420204: + return "下陆区"; + case 420205: + return "铁山区"; + case 420222: + return "阳新县"; + case 420281: + return "大冶市"; + case 4203: + return "十堰市"; + case 420301: + return "市辖区"; + case 420302: + return "茅箭区"; + case 420303: + return "张湾区"; + case 420304: + return "郧阳区"; + case 420322: + return "郧西县"; + case 420323: + return "竹山县"; + case 420324: + return "竹溪县"; + case 420325: + return "房县"; + case 420381: + return "丹江口市"; + case 4205: + return "宜昌市"; + case 420501: + return "市辖区"; + case 420502: + return "西陵区"; + case 420503: + return "伍家岗区"; + case 420504: + return "点军区"; + case 420505: + return "猇亭区"; + case 420506: + return "夷陵区"; + case 420525: + return "远安县"; + case 420526: + return "兴山县"; + case 420527: + return "秭归县"; + case 420528: + return "长阳土家族自治县"; + case 420529: + return "五峰土家族自治县"; + case 420581: + return "宜都市"; + case 420582: + return "当阳市"; + case 420583: + return "枝江市"; + case 4206: + return "襄阳市"; + case 420601: + return "市辖区"; + case 420602: + return "襄城区"; + case 420606: + return "樊城区"; + case 420607: + return "襄州区"; + case 420624: + return "南漳县"; + case 420625: + return "谷城县"; + case 420626: + return "保康县"; + case 420682: + return "老河口市"; + case 420683: + return "枣阳市"; + case 420684: + return "宜城市"; + case 4207: + return "鄂州市"; + case 420701: + return "市辖区"; + case 420702: + return "梁子湖区"; + case 420703: + return "华容区"; + case 420704: + return "鄂城区"; + case 4208: + return "荆门市"; + case 420801: + return "市辖区"; + case 420802: + return "东宝区"; + case 420804: + return "掇刀区"; + case 420821: + return "京山县"; + case 420822: + return "沙洋县"; + case 420881: + return "钟祥市"; + case 4209: + return "孝感市"; + case 420901: + return "市辖区"; + case 420902: + return "孝南区"; + case 420921: + return "孝昌县"; + case 420922: + return "大悟县"; + case 420923: + return "云梦县"; + case 420981: + return "应城市"; + case 420982: + return "安陆市"; + case 420984: + return "汉川市"; + case 4210: + return "荆州市"; + case 421001: + return "市辖区"; + case 421002: + return "沙市区"; + case 421003: + return "荆州区"; + case 421022: + return "公安县"; + case 421023: + return "监利县"; + case 421024: + return "江陵县"; + case 421081: + return "石首市"; + case 421083: + return "洪湖市"; + case 421087: + return "松滋市"; + case 4211: + return "黄冈市"; + case 421101: + return "市辖区"; + case 421102: + return "黄州区"; + case 421121: + return "团风县"; + case 421122: + return "红安县"; + case 421123: + return "罗田县"; + case 421124: + return "英山县"; + case 421125: + return "浠水县"; + case 421126: + return "蕲春县"; + case 421127: + return "黄梅县"; + case 421181: + return "麻城市"; + case 421182: + return "武穴市"; + case 4212: + return "咸宁市"; + case 421201: + return "市辖区"; + case 421202: + return "咸安区"; + case 421221: + return "嘉鱼县"; + case 421222: + return "通城县"; + case 421223: + return "崇阳县"; + case 421224: + return "通山县"; + case 421281: + return "赤壁市"; + case 4213: + return "随州市"; + case 421301: + return "市辖区"; + case 421303: + return "曾都区"; + case 421321: + return "随县"; + case 421381: + return "广水市"; + case 4228: + return "恩施土家族苗族自治州"; + case 422801: + return "恩施市"; + case 422802: + return "利川市"; + case 422822: + return "建始县"; + case 422823: + return "巴东县"; + case 422825: + return "宣恩县"; + case 422826: + return "咸丰县"; + case 422827: + return "来凤县"; + case 422828: + return "鹤峰县"; + case 4290: + return "省直辖县级行政区划"; + case 429004: + return "仙桃市"; + case 429005: + return "潜江市"; + case 429006: + return "天门市"; + case 429021: + return "神农架林区"; + case 43: + return "湖南省"; + case 4301: + return "长沙市"; + case 430101: + return "市辖区"; + case 430102: + return "芙蓉区"; + case 430103: + return "天心区"; + case 430104: + return "岳麓区"; + case 430105: + return "开福区"; + case 430111: + return "雨花区"; + case 430112: + return "望城区"; + case 430121: + return "长沙县"; + case 430124: + return "宁乡县"; + case 430181: + return "浏阳市"; + case 4302: + return "株洲市"; + case 430201: + return "市辖区"; + case 430202: + return "荷塘区"; + case 430203: + return "芦淞区"; + case 430204: + return "石峰区"; + case 430211: + return "天元区"; + case 430221: + return "株洲县"; + case 430223: + return "攸县"; + case 430224: + return "茶陵县"; + case 430225: + return "炎陵县"; + case 430281: + return "醴陵市"; + case 4303: + return "湘潭市"; + case 430301: + return "市辖区"; + case 430302: + return "雨湖区"; + case 430304: + return "岳塘区"; + case 430321: + return "湘潭县"; + case 430381: + return "湘乡市"; + case 430382: + return "韶山市"; + case 4304: + return "衡阳市"; + case 430401: + return "市辖区"; + case 430405: + return "珠晖区"; + case 430406: + return "雁峰区"; + case 430407: + return "石鼓区"; + case 430408: + return "蒸湘区"; + case 430412: + return "南岳区"; + case 430421: + return "衡阳县"; + case 430422: + return "衡南县"; + case 430423: + return "衡山县"; + case 430424: + return "衡东县"; + case 430426: + return "祁东县"; + case 430481: + return "耒阳市"; + case 430482: + return "常宁市"; + case 4305: + return "邵阳市"; + case 430501: + return "市辖区"; + case 430502: + return "双清区"; + case 430503: + return "大祥区"; + case 430511: + return "北塔区"; + case 430521: + return "邵东县"; + case 430522: + return "新邵县"; + case 430523: + return "邵阳县"; + case 430524: + return "隆回县"; + case 430525: + return "洞口县"; + case 430527: + return "绥宁县"; + case 430528: + return "新宁县"; + case 430529: + return "城步苗族自治县"; + case 430581: + return "武冈市"; + case 4306: + return "岳阳市"; + case 430601: + return "市辖区"; + case 430602: + return "岳阳楼区"; + case 430603: + return "云溪区"; + case 430611: + return "君山区"; + case 430621: + return "岳阳县"; + case 430623: + return "华容县"; + case 430624: + return "湘阴县"; + case 430626: + return "平江县"; + case 430681: + return "汨罗市"; + case 430682: + return "临湘市"; + case 4307: + return "常德市"; + case 430701: + return "市辖区"; + case 430702: + return "武陵区"; + case 430703: + return "鼎城区"; + case 430721: + return "安乡县"; + case 430722: + return "汉寿县"; + case 430723: + return "澧县"; + case 430724: + return "临澧县"; + case 430725: + return "桃源县"; + case 430726: + return "石门县"; + case 430781: + return "津市市"; + case 4308: + return "张家界市"; + case 430801: + return "市辖区"; + case 430802: + return "永定区"; + case 430811: + return "武陵源区"; + case 430821: + return "慈利县"; + case 430822: + return "桑植县"; + case 4309: + return "益阳市"; + case 430901: + return "市辖区"; + case 430902: + return "资阳区"; + case 430903: + return "赫山区"; + case 430921: + return "南县"; + case 430922: + return "桃江县"; + case 430923: + return "安化县"; + case 430981: + return "沅江市"; + case 4310: + return "郴州市"; + case 431001: + return "市辖区"; + case 431002: + return "北湖区"; + case 431003: + return "苏仙区"; + case 431021: + return "桂阳县"; + case 431022: + return "宜章县"; + case 431023: + return "永兴县"; + case 431024: + return "嘉禾县"; + case 431025: + return "临武县"; + case 431026: + return "汝城县"; + case 431027: + return "桂东县"; + case 431028: + return "安仁县"; + case 431081: + return "资兴市"; + case 4311: + return "永州市"; + case 431101: + return "市辖区"; + case 431102: + return "零陵区"; + case 431103: + return "冷水滩区"; + case 431121: + return "祁阳县"; + case 431122: + return "东安县"; + case 431123: + return "双牌县"; + case 431124: + return "道县"; + case 431125: + return "江永县"; + case 431126: + return "宁远县"; + case 431127: + return "蓝山县"; + case 431128: + return "新田县"; + case 431129: + return "江华瑶族自治县"; + case 4312: + return "怀化市"; + case 431201: + return "市辖区"; + case 431202: + return "鹤城区"; + case 431221: + return "中方县"; + case 431222: + return "沅陵县"; + case 431223: + return "辰溪县"; + case 431224: + return "溆浦县"; + case 431225: + return "会同县"; + case 431226: + return "麻阳苗族自治县"; + case 431227: + return "新晃侗族自治县"; + case 431228: + return "芷江侗族自治县"; + case 431229: + return "靖州苗族侗族自治县"; + case 431230: + return "通道侗族自治县"; + case 431281: + return "洪江市"; + case 4313: + return "娄底市"; + case 431301: + return "市辖区"; + case 431302: + return "娄星区"; + case 431321: + return "双峰县"; + case 431322: + return "新化县"; + case 431381: + return "冷水江市"; + case 431382: + return "涟源市"; + case 4331: + return "湘西土家族苗族自治州"; + case 433101: + return "吉首市"; + case 433122: + return "泸溪县"; + case 433123: + return "凤凰县"; + case 433124: + return "花垣县"; + case 433125: + return "保靖县"; + case 433126: + return "古丈县"; + case 433127: + return "永顺县"; + case 433130: + return "龙山县"; + case 44: + return "广东省"; + case 4401: + return "广州市"; + case 440101: + return "市辖区"; + case 440103: + return "荔湾区"; + case 440104: + return "越秀区"; + case 440105: + return "海珠区"; + case 440106: + return "天河区"; + case 440111: + return "白云区"; + case 440112: + return "黄埔区"; + case 440113: + return "番禺区"; + case 440114: + return "花都区"; + case 440115: + return "南沙区"; + case 440116: + return "萝岗区"; + case 440117: + return "从化区"; + case 440118: + return "增城区"; + case 4402: + return "韶关市"; + case 440201: + return "市辖区"; + case 440203: + return "武江区"; + case 440204: + return "浈江区"; + case 440205: + return "曲江区"; + case 440222: + return "始兴县"; + case 440224: + return "仁化县"; + case 440229: + return "翁源县"; + case 440232: + return "乳源瑶族自治县"; + case 440233: + return "新丰县"; + case 440281: + return "乐昌市"; + case 440282: + return "南雄市"; + case 4403: + return "深圳市"; + case 440301: + return "市辖区"; + case 440303: + return "罗湖区"; + case 440304: + return "福田区"; + case 440305: + return "南山区"; + case 440306: + return "宝安区"; + case 440307: + return "龙岗区"; + case 440308: + return "盐田区"; + case 4404: + return "珠海市"; + case 440401: + return "市辖区"; + case 440402: + return "香洲区"; + case 440403: + return "斗门区"; + case 440404: + return "金湾区"; + case 4405: + return "汕头市"; + case 440501: + return "市辖区"; + case 440507: + return "龙湖区"; + case 440511: + return "金平区"; + case 440512: + return "濠江区"; + case 440513: + return "潮阳区"; + case 440514: + return "潮南区"; + case 440515: + return "澄海区"; + case 440523: + return "南澳县"; + case 4406: + return "佛山市"; + case 440601: + return "市辖区"; + case 440604: + return "禅城区"; + case 440605: + return "南海区"; + case 440606: + return "顺德区"; + case 440607: + return "三水区"; + case 440608: + return "高明区"; + case 4407: + return "江门市"; + case 440701: + return "市辖区"; + case 440703: + return "蓬江区"; + case 440704: + return "江海区"; + case 440705: + return "新会区"; + case 440781: + return "台山市"; + case 440783: + return "开平市"; + case 440784: + return "鹤山市"; + case 440785: + return "恩平市"; + case 4408: + return "湛江市"; + case 440801: + return "市辖区"; + case 440802: + return "赤坎区"; + case 440803: + return "霞山区"; + case 440804: + return "坡头区"; + case 440811: + return "麻章区"; + case 440823: + return "遂溪县"; + case 440825: + return "徐闻县"; + case 440881: + return "廉江市"; + case 440882: + return "雷州市"; + case 440883: + return "吴川市"; + case 4409: + return "茂名市"; + case 440901: + return "市辖区"; + case 440902: + return "茂南区"; + case 440904: + return "电白区"; + case 440981: + return "高州市"; + case 440982: + return "化州市"; + case 440983: + return "信宜市"; + case 4412: + return "肇庆市"; + case 441201: + return "市辖区"; + case 441202: + return "端州区"; + case 441203: + return "鼎湖区"; + case 441223: + return "广宁县"; + case 441224: + return "怀集县"; + case 441225: + return "封开县"; + case 441226: + return "德庆县"; + case 441283: + return "高要市"; + case 441284: + return "四会市"; + case 4413: + return "惠州市"; + case 441301: + return "市辖区"; + case 441302: + return "惠城区"; + case 441303: + return "惠阳区"; + case 441322: + return "博罗县"; + case 441323: + return "惠东县"; + case 441324: + return "龙门县"; + case 4414: + return "梅州市"; + case 441401: + return "市辖区"; + case 441402: + return "梅江区"; + case 441403: + return "梅县区"; + case 441422: + return "大埔县"; + case 441423: + return "丰顺县"; + case 441424: + return "五华县"; + case 441426: + return "平远县"; + case 441427: + return "蕉岭县"; + case 441481: + return "兴宁市"; + case 4415: + return "汕尾市"; + case 441501: + return "市辖区"; + case 441502: + return "城区"; + case 441521: + return "海丰县"; + case 441523: + return "陆河县"; + case 441581: + return "陆丰市"; + case 4416: + return "河源市"; + case 441601: + return "市辖区"; + case 441602: + return "源城区"; + case 441621: + return "紫金县"; + case 441622: + return "龙川县"; + case 441623: + return "连平县"; + case 441624: + return "和平县"; + case 441625: + return "东源县"; + case 4417: + return "阳江市"; + case 441701: + return "市辖区"; + case 441702: + return "江城区"; + case 441721: + return "阳西县"; + case 441723: + return "阳东县"; + case 441781: + return "阳春市"; + case 4418: + return "清远市"; + case 441801: + return "市辖区"; + case 441802: + return "清城区"; + case 441803: + return "清新区"; + case 441821: + return "佛冈县"; + case 441823: + return "阳山县"; + case 441825: + return "连山壮族瑶族自治县"; + case 441826: + return "连南瑶族自治县"; + case 441881: + return "英德市"; + case 441882: + return "连州市"; + case 4419: + return "东莞市"; + case 4420: + return "中山市"; + case 4451: + return "潮州市"; + case 445101: + return "市辖区"; + case 445102: + return "湘桥区"; + case 445103: + return "潮安区"; + case 445122: + return "饶平县"; + case 4452: + return "揭阳市"; + case 445201: + return "市辖区"; + case 445202: + return "榕城区"; + case 445203: + return "揭东区"; + case 445222: + return "揭西县"; + case 445224: + return "惠来县"; + case 445281: + return "普宁市"; + case 4453: + return "云浮市"; + case 445301: + return "市辖区"; + case 445302: + return "云城区"; + case 445303: + return "云安区"; + case 445321: + return "新兴县"; + case 445322: + return "郁南县"; + case 445381: + return "罗定市"; + case 45: + return "广西壮族自治区"; + case 4501: + return "南宁市"; + case 450101: + return "市辖区"; + case 450102: + return "兴宁区"; + case 450103: + return "青秀区"; + case 450105: + return "江南区"; + case 450107: + return "西乡塘区"; + case 450108: + return "良庆区"; + case 450109: + return "邕宁区"; + case 450122: + return "武鸣县"; + case 450123: + return "隆安县"; + case 450124: + return "马山县"; + case 450125: + return "上林县"; + case 450126: + return "宾阳县"; + case 450127: + return "横县"; + case 4502: + return "柳州市"; + case 450201: + return "市辖区"; + case 450202: + return "城中区"; + case 450203: + return "鱼峰区"; + case 450204: + return "柳南区"; + case 450205: + return "柳北区"; + case 450221: + return "柳江县"; + case 450222: + return "柳城县"; + case 450223: + return "鹿寨县"; + case 450224: + return "融安县"; + case 450225: + return "融水苗族自治县"; + case 450226: + return "三江侗族自治县"; + case 4503: + return "桂林市"; + case 450301: + return "市辖区"; + case 450302: + return "秀峰区"; + case 450303: + return "叠彩区"; + case 450304: + return "象山区"; + case 450305: + return "七星区"; + case 450311: + return "雁山区"; + case 450312: + return "临桂区"; + case 450321: + return "阳朔县"; + case 450323: + return "灵川县"; + case 450324: + return "全州县"; + case 450325: + return "兴安县"; + case 450326: + return "永福县"; + case 450327: + return "灌阳县"; + case 450328: + return "龙胜各族自治县"; + case 450329: + return "资源县"; + case 450330: + return "平乐县"; + case 450331: + return "荔浦县"; + case 450332: + return "恭城瑶族自治县"; + case 4504: + return "梧州市"; + case 450401: + return "市辖区"; + case 450403: + return "万秀区"; + case 450405: + return "长洲区"; + case 450406: + return "龙圩区"; + case 450421: + return "苍梧县"; + case 450422: + return "藤县"; + case 450423: + return "蒙山县"; + case 450481: + return "岑溪市"; + case 4505: + return "北海市"; + case 450501: + return "市辖区"; + case 450502: + return "海城区"; + case 450503: + return "银海区"; + case 450512: + return "铁山港区"; + case 450521: + return "合浦县"; + case 4506: + return "防城港市"; + case 450601: + return "市辖区"; + case 450602: + return "港口区"; + case 450603: + return "防城区"; + case 450621: + return "上思县"; + case 450681: + return "东兴市"; + case 4507: + return "钦州市"; + case 450701: + return "市辖区"; + case 450702: + return "钦南区"; + case 450703: + return "钦北区"; + case 450721: + return "灵山县"; + case 450722: + return "浦北县"; + case 4508: + return "贵港市"; + case 450801: + return "市辖区"; + case 450802: + return "港北区"; + case 450803: + return "港南区"; + case 450804: + return "覃塘区"; + case 450821: + return "平南县"; + case 450881: + return "桂平市"; + case 4509: + return "玉林市"; + case 450901: + return "市辖区"; + case 450902: + return "玉州区"; + case 450903: + return "福绵区"; + case 450921: + return "容县"; + case 450922: + return "陆川县"; + case 450923: + return "博白县"; + case 450924: + return "兴业县"; + case 450981: + return "北流市"; + case 4510: + return "百色市"; + case 451001: + return "市辖区"; + case 451002: + return "右江区"; + case 451021: + return "田阳县"; + case 451022: + return "田东县"; + case 451023: + return "平果县"; + case 451024: + return "德保县"; + case 451025: + return "靖西县"; + case 451026: + return "那坡县"; + case 451027: + return "凌云县"; + case 451028: + return "乐业县"; + case 451029: + return "田林县"; + case 451030: + return "西林县"; + case 451031: + return "隆林各族自治县"; + case 4511: + return "贺州市"; + case 451101: + return "市辖区"; + case 451102: + return "八步区"; + case 451121: + return "昭平县"; + case 451122: + return "钟山县"; + case 451123: + return "富川瑶族自治县"; + case 4512: + return "河池市"; + case 451201: + return "市辖区"; + case 451202: + return "金城江区"; + case 451221: + return "南丹县"; + case 451222: + return "天峨县"; + case 451223: + return "凤山县"; + case 451224: + return "东兰县"; + case 451225: + return "罗城仫佬族自治县"; + case 451226: + return "环江毛南族自治县"; + case 451227: + return "巴马瑶族自治县"; + case 451228: + return "都安瑶族自治县"; + case 451229: + return "大化瑶族自治县"; + case 451281: + return "宜州市"; + case 4513: + return "来宾市"; + case 451301: + return "市辖区"; + case 451302: + return "兴宾区"; + case 451321: + return "忻城县"; + case 451322: + return "象州县"; + case 451323: + return "武宣县"; + case 451324: + return "金秀瑶族自治县"; + case 451381: + return "合山市"; + case 4514: + return "崇左市"; + case 451401: + return "市辖区"; + case 451402: + return "江州区"; + case 451421: + return "扶绥县"; + case 451422: + return "宁明县"; + case 451423: + return "龙州县"; + case 451424: + return "大新县"; + case 451425: + return "天等县"; + case 451481: + return "凭祥市"; + case 46: + return "海南省"; + case 4601: + return "海口市"; + case 460101: + return "市辖区"; + case 460105: + return "秀英区"; + case 460106: + return "龙华区"; + case 460107: + return "琼山区"; + case 460108: + return "美兰区"; + case 4602: + return "三亚市"; + case 460201: + return "市辖区"; + case 460202: + return "海棠区"; + case 460203: + return "吉阳区"; + case 460204: + return "天涯区"; + case 460205: + return "崖州区"; + case 4603: + return "三沙市"; + case 4690: + return "省直辖县级行政区划"; + case 469001: + return "五指山市"; + case 469002: + return "琼海市"; + case 469003: + return "儋州市"; + case 469005: + return "文昌市"; + case 469006: + return "万宁市"; + case 469007: + return "东方市"; + case 469021: + return "定安县"; + case 469022: + return "屯昌县"; + case 469023: + return "澄迈县"; + case 469024: + return "临高县"; + case 469025: + return "白沙黎族自治县"; + case 469026: + return "昌江黎族自治县"; + case 469027: + return "乐东黎族自治县"; + case 469028: + return "陵水黎族自治县"; + case 469029: + return "保亭黎族苗族自治县"; + case 469030: + return "琼中黎族苗族自治县"; + case 50: + return "重庆市"; + case 5001: + return "市辖区"; + case 500101: + return "万州区"; + case 500102: + return "涪陵区"; + case 500103: + return "渝中区"; + case 500104: + return "大渡口区"; + case 500105: + return "江北区"; + case 500106: + return "沙坪坝区"; + case 500107: + return "九龙坡区"; + case 500108: + return "南岸区"; + case 500109: + return "北碚区"; + case 500110: + return "綦江区"; + case 500111: + return "大足区"; + case 500112: + return "渝北区"; + case 500113: + return "巴南区"; + case 500114: + return "黔江区"; + case 500115: + return "长寿区"; + case 500116: + return "江津区"; + case 500117: + return "合川区"; + case 500118: + return "永川区"; + case 500119: + return "南川区"; + case 500120: + return "璧山区"; + case 500151: + return "铜梁区"; + case 5002: + return "县"; + case 500223: + return "潼南县"; + case 500226: + return "荣昌县"; + case 500228: + return "梁平县"; + case 500229: + return "城口县"; + case 500230: + return "丰都县"; + case 500231: + return "垫江县"; + case 500232: + return "武隆县"; + case 500233: + return "忠县"; + case 500234: + return "开县"; + case 500235: + return "云阳县"; + case 500236: + return "奉节县"; + case 500237: + return "巫山县"; + case 500238: + return "巫溪县"; + case 500240: + return "石柱土家族自治县"; + case 500241: + return "秀山土家族苗族自治县"; + case 500242: + return "酉阳土家族苗族自治县"; + case 500243: + return "彭水苗族土家族自治县"; + case 51: + return "四川省"; + case 5101: + return "成都市"; + case 510101: + return "市辖区"; + case 510104: + return "锦江区"; + case 510105: + return "青羊区"; + case 510106: + return "金牛区"; + case 510107: + return "武侯区"; + case 510108: + return "成华区"; + case 510112: + return "龙泉驿区"; + case 510113: + return "青白江区"; + case 510114: + return "新都区"; + case 510115: + return "温江区"; + case 510121: + return "金堂县"; + case 510122: + return "双流县"; + case 510124: + return "郫县"; + case 510129: + return "大邑县"; + case 510131: + return "蒲江县"; + case 510132: + return "新津县"; + case 510181: + return "都江堰市"; + case 510182: + return "彭州市"; + case 510183: + return "邛崃市"; + case 510184: + return "崇州市"; + case 5103: + return "自贡市"; + case 510301: + return "市辖区"; + case 510302: + return "自流井区"; + case 510303: + return "贡井区"; + case 510304: + return "大安区"; + case 510311: + return "沿滩区"; + case 510321: + return "荣县"; + case 510322: + return "富顺县"; + case 5104: + return "攀枝花市"; + case 510401: + return "市辖区"; + case 510402: + return "东区"; + case 510403: + return "西区"; + case 510411: + return "仁和区"; + case 510421: + return "米易县"; + case 510422: + return "盐边县"; + case 5105: + return "泸州市"; + case 510501: + return "市辖区"; + case 510502: + return "江阳区"; + case 510503: + return "纳溪区"; + case 510504: + return "龙马潭区"; + case 510521: + return "泸县"; + case 510522: + return "合江县"; + case 510524: + return "叙永县"; + case 510525: + return "古蔺县"; + case 5106: + return "德阳市"; + case 510601: + return "市辖区"; + case 510603: + return "旌阳区"; + case 510623: + return "中江县"; + case 510626: + return "罗江县"; + case 510681: + return "广汉市"; + case 510682: + return "什邡市"; + case 510683: + return "绵竹市"; + case 5107: + return "绵阳市"; + case 510701: + return "市辖区"; + case 510703: + return "涪城区"; + case 510704: + return "游仙区"; + case 510722: + return "三台县"; + case 510723: + return "盐亭县"; + case 510724: + return "安县"; + case 510725: + return "梓潼县"; + case 510726: + return "北川羌族自治县"; + case 510727: + return "平武县"; + case 510781: + return "江油市"; + case 5108: + return "广元市"; + case 510801: + return "市辖区"; + case 510802: + return "利州区"; + case 510811: + return "昭化区"; + case 510812: + return "朝天区"; + case 510821: + return "旺苍县"; + case 510822: + return "青川县"; + case 510823: + return "剑阁县"; + case 510824: + return "苍溪县"; + case 5109: + return "遂宁市"; + case 510901: + return "市辖区"; + case 510903: + return "船山区"; + case 510904: + return "安居区"; + case 510921: + return "蓬溪县"; + case 510922: + return "射洪县"; + case 510923: + return "大英县"; + case 5110: + return "内江市"; + case 511001: + return "市辖区"; + case 511002: + return "市中区"; + case 511011: + return "东兴区"; + case 511024: + return "威远县"; + case 511025: + return "资中县"; + case 511028: + return "隆昌县"; + case 5111: + return "乐山市"; + case 511101: + return "市辖区"; + case 511102: + return "市中区"; + case 511111: + return "沙湾区"; + case 511112: + return "五通桥区"; + case 511113: + return "金口河区"; + case 511123: + return "犍为县"; + case 511124: + return "井研县"; + case 511126: + return "夹江县"; + case 511129: + return "沐川县"; + case 511132: + return "峨边彝族自治县"; + case 511133: + return "马边彝族自治县"; + case 511181: + return "峨眉山市"; + case 5113: + return "南充市"; + case 511301: + return "市辖区"; + case 511302: + return "顺庆区"; + case 511303: + return "高坪区"; + case 511304: + return "嘉陵区"; + case 511321: + return "南部县"; + case 511322: + return "营山县"; + case 511323: + return "蓬安县"; + case 511324: + return "仪陇县"; + case 511325: + return "西充县"; + case 511381: + return "阆中市"; + case 5114: + return "眉山市"; + case 511401: + return "市辖区"; + case 511402: + return "东坡区"; + case 511421: + return "仁寿县"; + case 511422: + return "彭山县"; + case 511423: + return "洪雅县"; + case 511424: + return "丹棱县"; + case 511425: + return "青神县"; + case 5115: + return "宜宾市"; + case 511501: + return "市辖区"; + case 511502: + return "翠屏区"; + case 511503: + return "南溪区"; + case 511521: + return "宜宾县"; + case 511523: + return "江安县"; + case 511524: + return "长宁县"; + case 511525: + return "高县"; + case 511526: + return "珙县"; + case 511527: + return "筠连县"; + case 511528: + return "兴文县"; + case 511529: + return "屏山县"; + case 5116: + return "广安市"; + case 511601: + return "市辖区"; + case 511602: + return "广安区"; + case 511603: + return "前锋区"; + case 511621: + return "岳池县"; + case 511622: + return "武胜县"; + case 511623: + return "邻水县"; + case 511681: + return "华蓥市"; + case 5117: + return "达州市"; + case 511701: + return "市辖区"; + case 511702: + return "通川区"; + case 511703: + return "达川区"; + case 511722: + return "宣汉县"; + case 511723: + return "开江县"; + case 511724: + return "大竹县"; + case 511725: + return "渠县"; + case 511781: + return "万源市"; + case 5118: + return "雅安市"; + case 511801: + return "市辖区"; + case 511802: + return "雨城区"; + case 511803: + return "名山区"; + case 511822: + return "荥经县"; + case 511823: + return "汉源县"; + case 511824: + return "石棉县"; + case 511825: + return "天全县"; + case 511826: + return "芦山县"; + case 511827: + return "宝兴县"; + case 5119: + return "巴中市"; + case 511901: + return "市辖区"; + case 511902: + return "巴州区"; + case 511903: + return "恩阳区"; + case 511921: + return "通江县"; + case 511922: + return "南江县"; + case 511923: + return "平昌县"; + case 5120: + return "资阳市"; + case 512001: + return "市辖区"; + case 512002: + return "雁江区"; + case 512021: + return "安岳县"; + case 512022: + return "乐至县"; + case 512081: + return "简阳市"; + case 5132: + return "阿坝藏族羌族自治州"; + case 513221: + return "汶川县"; + case 513222: + return "理县"; + case 513223: + return "茂县"; + case 513224: + return "松潘县"; + case 513225: + return "九寨沟县"; + case 513226: + return "金川县"; + case 513227: + return "小金县"; + case 513228: + return "黑水县"; + case 513229: + return "马尔康县"; + case 513230: + return "壤塘县"; + case 513231: + return "阿坝县"; + case 513232: + return "若尔盖县"; + case 513233: + return "红原县"; + case 5133: + return "甘孜藏族自治州"; + case 513321: + return "康定县"; + case 513322: + return "泸定县"; + case 513323: + return "丹巴县"; + case 513324: + return "九龙县"; + case 513325: + return "雅江县"; + case 513326: + return "道孚县"; + case 513327: + return "炉霍县"; + case 513328: + return "甘孜县"; + case 513329: + return "新龙县"; + case 513330: + return "德格县"; + case 513331: + return "白玉县"; + case 513332: + return "石渠县"; + case 513333: + return "色达县"; + case 513334: + return "理塘县"; + case 513335: + return "巴塘县"; + case 513336: + return "乡城县"; + case 513337: + return "稻城县"; + case 513338: + return "得荣县"; + case 5134: + return "凉山彝族自治州"; + case 513401: + return "西昌市"; + case 513422: + return "木里藏族自治县"; + case 513423: + return "盐源县"; + case 513424: + return "德昌县"; + case 513425: + return "会理县"; + case 513426: + return "会东县"; + case 513427: + return "宁南县"; + case 513428: + return "普格县"; + case 513429: + return "布拖县"; + case 513430: + return "金阳县"; + case 513431: + return "昭觉县"; + case 513432: + return "喜德县"; + case 513433: + return "冕宁县"; + case 513434: + return "越西县"; + case 513435: + return "甘洛县"; + case 513436: + return "美姑县"; + case 513437: + return "雷波县"; + case 52: + return "贵州省"; + case 5201: + return "贵阳市"; + case 520101: + return "市辖区"; + case 520102: + return "南明区"; + case 520103: + return "云岩区"; + case 520111: + return "花溪区"; + case 520112: + return "乌当区"; + case 520113: + return "白云区"; + case 520115: + return "观山湖区"; + case 520121: + return "开阳县"; + case 520122: + return "息烽县"; + case 520123: + return "修文县"; + case 520181: + return "清镇市"; + case 5202: + return "六盘水市"; + case 520201: + return "钟山区"; + case 520203: + return "六枝特区"; + case 520221: + return "水城县"; + case 520222: + return "盘县"; + case 5203: + return "遵义市"; + case 520301: + return "市辖区"; + case 520302: + return "红花岗区"; + case 520303: + return "汇川区"; + case 520321: + return "遵义县"; + case 520322: + return "桐梓县"; + case 520323: + return "绥阳县"; + case 520324: + return "正安县"; + case 520325: + return "道真仡佬族苗族自治县"; + case 520326: + return "务川仡佬族苗族自治县"; + case 520327: + return "凤冈县"; + case 520328: + return "湄潭县"; + case 520329: + return "余庆县"; + case 520330: + return "习水县"; + case 520381: + return "赤水市"; + case 520382: + return "仁怀市"; + case 5204: + return "安顺市"; + case 520401: + return "市辖区"; + case 520402: + return "西秀区"; + case 520421: + return "平坝县"; + case 520422: + return "普定县"; + case 520423: + return "镇宁布依族苗族自治县"; + case 520424: + return "关岭布依族苗族自治县"; + case 520425: + return "紫云苗族布依族自治县"; + case 5205: + return "毕节市"; + case 520501: + return "市辖区"; + case 520502: + return "七星关区"; + case 520521: + return "大方县"; + case 520522: + return "黔西县"; + case 520523: + return "金沙县"; + case 520524: + return "织金县"; + case 520525: + return "纳雍县"; + case 520526: + return "威宁彝族回族苗族自治县"; + case 520527: + return "赫章县"; + case 5206: + return "铜仁市"; + case 520601: + return "市辖区"; + case 520602: + return "碧江区"; + case 520603: + return "万山区"; + case 520621: + return "江口县"; + case 520622: + return "玉屏侗族自治县"; + case 520623: + return "石阡县"; + case 520624: + return "思南县"; + case 520625: + return "印江土家族苗族自治县"; + case 520626: + return "德江县"; + case 520627: + return "沿河土家族自治县"; + case 520628: + return "松桃苗族自治县"; + case 5223: + return "黔西南布依族苗族自治州"; + case 522301: + return "兴义市"; + case 522322: + return "兴仁县"; + case 522323: + return "普安县"; + case 522324: + return "晴隆县"; + case 522325: + return "贞丰县"; + case 522326: + return "望谟县"; + case 522327: + return "册亨县"; + case 522328: + return "安龙县"; + case 5226: + return "黔东南苗族侗族自治州"; + case 522601: + return "凯里市"; + case 522622: + return "黄平县"; + case 522623: + return "施秉县"; + case 522624: + return "三穗县"; + case 522625: + return "镇远县"; + case 522626: + return "岑巩县"; + case 522627: + return "天柱县"; + case 522628: + return "锦屏县"; + case 522629: + return "剑河县"; + case 522630: + return "台江县"; + case 522631: + return "黎平县"; + case 522632: + return "榕江县"; + case 522633: + return "从江县"; + case 522634: + return "雷山县"; + case 522635: + return "麻江县"; + case 522636: + return "丹寨县"; + case 5227: + return "黔南布依族苗族自治州"; + case 522701: + return "都匀市"; + case 522702: + return "福泉市"; + case 522722: + return "荔波县"; + case 522723: + return "贵定县"; + case 522725: + return "瓮安县"; + case 522726: + return "独山县"; + case 522727: + return "平塘县"; + case 522728: + return "罗甸县"; + case 522729: + return "长顺县"; + case 522730: + return "龙里县"; + case 522731: + return "惠水县"; + case 522732: + return "三都水族自治县"; + case 53: + return "云南省"; + case 5301: + return "昆明市"; + case 530101: + return "市辖区"; + case 530102: + return "五华区"; + case 530103: + return "盘龙区"; + case 530111: + return "官渡区"; + case 530112: + return "西山区"; + case 530113: + return "东川区"; + case 530114: + return "呈贡区"; + case 530122: + return "晋宁县"; + case 530124: + return "富民县"; + case 530125: + return "宜良县"; + case 530126: + return "石林彝族自治县"; + case 530127: + return "嵩明县"; + case 530128: + return "禄劝彝族苗族自治县"; + case 530129: + return "寻甸回族彝族自治县"; + case 530181: + return "安宁市"; + case 5303: + return "曲靖市"; + case 530301: + return "市辖区"; + case 530302: + return "麒麟区"; + case 530321: + return "马龙县"; + case 530322: + return "陆良县"; + case 530323: + return "师宗县"; + case 530324: + return "罗平县"; + case 530325: + return "富源县"; + case 530326: + return "会泽县"; + case 530328: + return "沾益县"; + case 530381: + return "宣威市"; + case 5304: + return "玉溪市"; + case 530401: + return "市辖区"; + case 530402: + return "红塔区"; + case 530421: + return "江川县"; + case 530422: + return "澄江县"; + case 530423: + return "通海县"; + case 530424: + return "华宁县"; + case 530425: + return "易门县"; + case 530426: + return "峨山彝族自治县"; + case 530427: + return "新平彝族傣族自治县"; + case 530428: + return "元江哈尼族彝族傣族自治县"; + case 5305: + return "保山市"; + case 530501: + return "市辖区"; + case 530502: + return "隆阳区"; + case 530521: + return "施甸县"; + case 530522: + return "腾冲县"; + case 530523: + return "龙陵县"; + case 530524: + return "昌宁县"; + case 5306: + return "昭通市"; + case 530601: + return "市辖区"; + case 530602: + return "昭阳区"; + case 530621: + return "鲁甸县"; + case 530622: + return "巧家县"; + case 530623: + return "盐津县"; + case 530624: + return "大关县"; + case 530625: + return "永善县"; + case 530626: + return "绥江县"; + case 530627: + return "镇雄县"; + case 530628: + return "彝良县"; + case 530629: + return "威信县"; + case 530630: + return "水富县"; + case 5307: + return "丽江市"; + case 530701: + return "市辖区"; + case 530702: + return "古城区"; + case 530721: + return "玉龙纳西族自治县"; + case 530722: + return "永胜县"; + case 530723: + return "华坪县"; + case 530724: + return "宁蒗彝族自治县"; + case 5308: + return "普洱市"; + case 530801: + return "市辖区"; + case 530802: + return "思茅区"; + case 530821: + return "宁洱哈尼族彝族自治县"; + case 530822: + return "墨江哈尼族自治县"; + case 530823: + return "景东彝族自治县"; + case 530824: + return "景谷傣族彝族自治县"; + case 530825: + return "镇沅彝族哈尼族拉祜族自治县"; + case 530826: + return "江城哈尼族彝族自治县"; + case 530827: + return "孟连傣族拉祜族佤族自治县"; + case 530828: + return "澜沧拉祜族自治县"; + case 530829: + return "西盟佤族自治县"; + case 5309: + return "临沧市"; + case 530901: + return "市辖区"; + case 530902: + return "临翔区"; + case 530921: + return "凤庆县"; + case 530922: + return "云县"; + case 530923: + return "永德县"; + case 530924: + return "镇康县"; + case 530925: + return "双江拉祜族佤族布朗族傣族自治县"; + case 530926: + return "耿马傣族佤族自治县"; + case 530927: + return "沧源佤族自治县"; + case 5323: + return "楚雄彝族自治州"; + case 532301: + return "楚雄市"; + case 532322: + return "双柏县"; + case 532323: + return "牟定县"; + case 532324: + return "南华县"; + case 532325: + return "姚安县"; + case 532326: + return "大姚县"; + case 532327: + return "永仁县"; + case 532328: + return "元谋县"; + case 532329: + return "武定县"; + case 532331: + return "禄丰县"; + case 5325: + return "红河哈尼族彝族自治州"; + case 532501: + return "个旧市"; + case 532502: + return "开远市"; + case 532503: + return "蒙自市"; + case 532504: + return "弥勒市"; + case 532523: + return "屏边苗族自治县"; + case 532524: + return "建水县"; + case 532525: + return "石屏县"; + case 532527: + return "泸西县"; + case 532528: + return "元阳县"; + case 532529: + return "红河县"; + case 532530: + return "金平苗族瑶族傣族自治县"; + case 532531: + return "绿春县"; + case 532532: + return "河口瑶族自治县"; + case 5326: + return "文山壮族苗族自治州"; + case 532601: + return "文山市"; + case 532622: + return "砚山县"; + case 532623: + return "西畴县"; + case 532624: + return "麻栗坡县"; + case 532625: + return "马关县"; + case 532626: + return "丘北县"; + case 532627: + return "广南县"; + case 532628: + return "富宁县"; + case 5328: + return "西双版纳傣族自治州"; + case 532801: + return "景洪市"; + case 532822: + return "勐海县"; + case 532823: + return "勐腊县"; + case 5329: + return "大理白族自治州"; + case 532901: + return "大理市"; + case 532922: + return "漾濞彝族自治县"; + case 532923: + return "祥云县"; + case 532924: + return "宾川县"; + case 532925: + return "弥渡县"; + case 532926: + return "南涧彝族自治县"; + case 532927: + return "巍山彝族回族自治县"; + case 532928: + return "永平县"; + case 532929: + return "云龙县"; + case 532930: + return "洱源县"; + case 532931: + return "剑川县"; + case 532932: + return "鹤庆县"; + case 5331: + return "德宏傣族景颇族自治州"; + case 533102: + return "瑞丽市"; + case 533103: + return "芒市"; + case 533122: + return "梁河县"; + case 533123: + return "盈江县"; + case 533124: + return "陇川县"; + case 5333: + return "怒江傈僳族自治州"; + case 533321: + return "泸水县"; + case 533323: + return "福贡县"; + case 533324: + return "贡山独龙族怒族自治县"; + case 533325: + return "兰坪白族普米族自治县"; + case 5334: + return "迪庆藏族自治州"; + case 533421: + return "香格里拉县"; + case 533422: + return "德钦县"; + case 533423: + return "维西傈僳族自治县"; + case 54: + return "西藏自治区"; + case 5401: + return "拉萨市"; + case 540101: + return "市辖区"; + case 540102: + return "城关区"; + case 540121: + return "林周县"; + case 540122: + return "当雄县"; + case 540123: + return "尼木县"; + case 540124: + return "曲水县"; + case 540125: + return "堆龙德庆县"; + case 540126: + return "达孜县"; + case 540127: + return "墨竹工卡县"; + case 5402: + return "日喀则市"; + case 540202: + return "桑珠孜区"; + case 540221: + return "南木林县"; + case 540222: + return "江孜县"; + case 540223: + return "定日县"; + case 540224: + return "萨迦县"; + case 540225: + return "拉孜县"; + case 540226: + return "昂仁县"; + case 540227: + return "谢通门县"; + case 540228: + return "白朗县"; + case 540229: + return "仁布县"; + case 540230: + return "康马县"; + case 540231: + return "定结县"; + case 540232: + return "仲巴县"; + case 540233: + return "亚东县"; + case 540234: + return "吉隆县"; + case 540235: + return "聂拉木县"; + case 540236: + return "萨嘎县"; + case 540237: + return "岗巴县"; + case 5421: + return "昌都地区"; + case 542121: + return "昌都县"; + case 542122: + return "江达县"; + case 542123: + return "贡觉县"; + case 542124: + return "类乌齐县"; + case 542125: + return "丁青县"; + case 542126: + return "察雅县"; + case 542127: + return "八宿县"; + case 542128: + return "左贡县"; + case 542129: + return "芒康县"; + case 542132: + return "洛隆县"; + case 542133: + return "边坝县"; + case 5422: + return "山南地区"; + case 542221: + return "乃东县"; + case 542222: + return "扎囊县"; + case 542223: + return "贡嘎县"; + case 542224: + return "桑日县"; + case 542225: + return "琼结县"; + case 542226: + return "曲松县"; + case 542227: + return "措美县"; + case 542228: + return "洛扎县"; + case 542229: + return "加查县"; + case 542231: + return "隆子县"; + case 542232: + return "错那县"; + case 542233: + return "浪卡子县"; + case 5424: + return "那曲地区"; + case 542421: + return "那曲县"; + case 542422: + return "嘉黎县"; + case 542423: + return "比如县"; + case 542424: + return "聂荣县"; + case 542425: + return "安多县"; + case 542426: + return "申扎县"; + case 542427: + return "索县"; + case 542428: + return "班戈县"; + case 542429: + return "巴青县"; + case 542430: + return "尼玛县"; + case 542431: + return "双湖县"; + case 5425: + return "阿里地区"; + case 542521: + return "普兰县"; + case 542522: + return "札达县"; + case 542523: + return "噶尔县"; + case 542524: + return "日土县"; + case 542525: + return "革吉县"; + case 542526: + return "改则县"; + case 542527: + return "措勤县"; + case 5426: + return "林芝地区"; + case 542621: + return "林芝县"; + case 542622: + return "工布江达县"; + case 542623: + return "米林县"; + case 542624: + return "墨脱县"; + case 542625: + return "波密县"; + case 542626: + return "察隅县"; + case 542627: + return "朗县"; + case 61: + return "陕西省"; + case 6101: + return "西安市"; + case 610101: + return "市辖区"; + case 610102: + return "新城区"; + case 610103: + return "碑林区"; + case 610104: + return "莲湖区"; + case 610111: + return "灞桥区"; + case 610112: + return "未央区"; + case 610113: + return "雁塔区"; + case 610114: + return "阎良区"; + case 610115: + return "临潼区"; + case 610116: + return "长安区"; + case 610122: + return "蓝田县"; + case 610124: + return "周至县"; + case 610125: + return "户县"; + case 610126: + return "高陵县"; + case 6102: + return "铜川市"; + case 610201: + return "市辖区"; + case 610202: + return "王益区"; + case 610203: + return "印台区"; + case 610204: + return "耀州区"; + case 610222: + return "宜君县"; + case 6103: + return "宝鸡市"; + case 610301: + return "市辖区"; + case 610302: + return "渭滨区"; + case 610303: + return "金台区"; + case 610304: + return "陈仓区"; + case 610322: + return "凤翔县"; + case 610323: + return "岐山县"; + case 610324: + return "扶风县"; + case 610326: + return "眉县"; + case 610327: + return "陇县"; + case 610328: + return "千阳县"; + case 610329: + return "麟游县"; + case 610330: + return "凤县"; + case 610331: + return "太白县"; + case 6104: + return "咸阳市"; + case 610401: + return "市辖区"; + case 610402: + return "秦都区"; + case 610403: + return "杨陵区"; + case 610404: + return "渭城区"; + case 610422: + return "三原县"; + case 610423: + return "泾阳县"; + case 610424: + return "乾县"; + case 610425: + return "礼泉县"; + case 610426: + return "永寿县"; + case 610427: + return "彬县"; + case 610428: + return "长武县"; + case 610429: + return "旬邑县"; + case 610430: + return "淳化县"; + case 610431: + return "武功县"; + case 610481: + return "兴平市"; + case 6105: + return "渭南市"; + case 610501: + return "市辖区"; + case 610502: + return "临渭区"; + case 610521: + return "华县"; + case 610522: + return "潼关县"; + case 610523: + return "大荔县"; + case 610524: + return "合阳县"; + case 610525: + return "澄城县"; + case 610526: + return "蒲城县"; + case 610527: + return "白水县"; + case 610528: + return "富平县"; + case 610581: + return "韩城市"; + case 610582: + return "华阴市"; + case 6106: + return "延安市"; + case 610601: + return "市辖区"; + case 610602: + return "宝塔区"; + case 610621: + return "延长县"; + case 610622: + return "延川县"; + case 610623: + return "子长县"; + case 610624: + return "安塞县"; + case 610625: + return "志丹县"; + case 610626: + return "吴起县"; + case 610627: + return "甘泉县"; + case 610628: + return "富县"; + case 610629: + return "洛川县"; + case 610630: + return "宜川县"; + case 610631: + return "黄龙县"; + case 610632: + return "黄陵县"; + case 6107: + return "汉中市"; + case 610701: + return "市辖区"; + case 610702: + return "汉台区"; + case 610721: + return "南郑县"; + case 610722: + return "城固县"; + case 610723: + return "洋县"; + case 610724: + return "西乡县"; + case 610725: + return "勉县"; + case 610726: + return "宁强县"; + case 610727: + return "略阳县"; + case 610728: + return "镇巴县"; + case 610729: + return "留坝县"; + case 610730: + return "佛坪县"; + case 6108: + return "榆林市"; + case 610801: + return "市辖区"; + case 610802: + return "榆阳区"; + case 610821: + return "神木县"; + case 610822: + return "府谷县"; + case 610823: + return "横山县"; + case 610824: + return "靖边县"; + case 610825: + return "定边县"; + case 610826: + return "绥德县"; + case 610827: + return "米脂县"; + case 610828: + return "佳县"; + case 610829: + return "吴堡县"; + case 610830: + return "清涧县"; + case 610831: + return "子洲县"; + case 6109: + return "安康市"; + case 610901: + return "市辖区"; + case 610902: + return "汉滨区"; + case 610921: + return "汉阴县"; + case 610922: + return "石泉县"; + case 610923: + return "宁陕县"; + case 610924: + return "紫阳县"; + case 610925: + return "岚皋县"; + case 610926: + return "平利县"; + case 610927: + return "镇坪县"; + case 610928: + return "旬阳县"; + case 610929: + return "白河县"; + case 6110: + return "商洛市"; + case 611001: + return "市辖区"; + case 611002: + return "商州区"; + case 611021: + return "洛南县"; + case 611022: + return "丹凤县"; + case 611023: + return "商南县"; + case 611024: + return "山阳县"; + case 611025: + return "镇安县"; + case 611026: + return "柞水县"; + case 62: + return "甘肃省"; + case 6201: + return "兰州市"; + case 620101: + return "市辖区"; + case 620102: + return "城关区"; + case 620103: + return "七里河区"; + case 620104: + return "西固区"; + case 620105: + return "安宁区"; + case 620111: + return "红古区"; + case 620121: + return "永登县"; + case 620122: + return "皋兰县"; + case 620123: + return "榆中县"; + case 6202: + return "嘉峪关市"; + case 620201: + return "市辖区"; + case 6203: + return "金昌市"; + case 620301: + return "市辖区"; + case 620302: + return "金川区"; + case 620321: + return "永昌县"; + case 6204: + return "白银市"; + case 620401: + return "市辖区"; + case 620402: + return "白银区"; + case 620403: + return "平川区"; + case 620421: + return "靖远县"; + case 620422: + return "会宁县"; + case 620423: + return "景泰县"; + case 6205: + return "天水市"; + case 620501: + return "市辖区"; + case 620502: + return "秦州区"; + case 620503: + return "麦积区"; + case 620521: + return "清水县"; + case 620522: + return "秦安县"; + case 620523: + return "甘谷县"; + case 620524: + return "武山县"; + case 620525: + return "张家川回族自治县"; + case 6206: + return "武威市"; + case 620601: + return "市辖区"; + case 620602: + return "凉州区"; + case 620621: + return "民勤县"; + case 620622: + return "古浪县"; + case 620623: + return "天祝藏族自治县"; + case 6207: + return "张掖市"; + case 620701: + return "市辖区"; + case 620702: + return "甘州区"; + case 620721: + return "肃南裕固族自治县"; + case 620722: + return "民乐县"; + case 620723: + return "临泽县"; + case 620724: + return "高台县"; + case 620725: + return "山丹县"; + case 6208: + return "平凉市"; + case 620801: + return "市辖区"; + case 620802: + return "崆峒区"; + case 620821: + return "泾川县"; + case 620822: + return "灵台县"; + case 620823: + return "崇信县"; + case 620824: + return "华亭县"; + case 620825: + return "庄浪县"; + case 620826: + return "静宁县"; + case 6209: + return "酒泉市"; + case 620901: + return "市辖区"; + case 620902: + return "肃州区"; + case 620921: + return "金塔县"; + case 620922: + return "瓜州县"; + case 620923: + return "肃北蒙古族自治县"; + case 620924: + return "阿克塞哈萨克族自治县"; + case 620981: + return "玉门市"; + case 620982: + return "敦煌市"; + case 6210: + return "庆阳市"; + case 621001: + return "市辖区"; + case 621002: + return "西峰区"; + case 621021: + return "庆城县"; + case 621022: + return "环县"; + case 621023: + return "华池县"; + case 621024: + return "合水县"; + case 621025: + return "正宁县"; + case 621026: + return "宁县"; + case 621027: + return "镇原县"; + case 6211: + return "定西市"; + case 621101: + return "市辖区"; + case 621102: + return "安定区"; + case 621121: + return "通渭县"; + case 621122: + return "陇西县"; + case 621123: + return "渭源县"; + case 621124: + return "临洮县"; + case 621125: + return "漳县"; + case 621126: + return "岷县"; + case 6212: + return "陇南市"; + case 621201: + return "市辖区"; + case 621202: + return "武都区"; + case 621221: + return "成县"; + case 621222: + return "文县"; + case 621223: + return "宕昌县"; + case 621224: + return "康县"; + case 621225: + return "西和县"; + case 621226: + return "礼县"; + case 621227: + return "徽县"; + case 621228: + return "两当县"; + case 6229: + return "临夏回族自治州"; + case 622901: + return "临夏市"; + case 622921: + return "临夏县"; + case 622922: + return "康乐县"; + case 622923: + return "永靖县"; + case 622924: + return "广河县"; + case 622925: + return "和政县"; + case 622926: + return "东乡族自治县"; + case 622927: + return "积石山保安族东乡族撒拉族自治县"; + case 6230: + return "甘南藏族自治州"; + case 623001: + return "合作市"; + case 623021: + return "临潭县"; + case 623022: + return "卓尼县"; + case 623023: + return "舟曲县"; + case 623024: + return "迭部县"; + case 623025: + return "玛曲县"; + case 623026: + return "碌曲县"; + case 623027: + return "夏河县"; + case 63: + return "青海省"; + case 6301: + return "西宁市"; + case 630101: + return "市辖区"; + case 630102: + return "城东区"; + case 630103: + return "城中区"; + case 630104: + return "城西区"; + case 630105: + return "城北区"; + case 630121: + return "大通回族土族自治县"; + case 630122: + return "湟中县"; + case 630123: + return "湟源县"; + case 6302: + return "海东市"; + case 630202: + return "乐都区"; + case 630221: + return "平安县"; + case 630222: + return "民和回族土族自治县"; + case 630223: + return "互助土族自治县"; + case 630224: + return "化隆回族自治县"; + case 630225: + return "循化撒拉族自治县"; + case 6322: + return "海北藏族自治州"; + case 632221: + return "门源回族自治县"; + case 632222: + return "祁连县"; + case 632223: + return "海晏县"; + case 632224: + return "刚察县"; + case 6323: + return "黄南藏族自治州"; + case 632321: + return "同仁县"; + case 632322: + return "尖扎县"; + case 632323: + return "泽库县"; + case 632324: + return "河南蒙古族自治县"; + case 6325: + return "海南藏族自治州"; + case 632521: + return "共和县"; + case 632522: + return "同德县"; + case 632523: + return "贵德县"; + case 632524: + return "兴海县"; + case 632525: + return "贵南县"; + case 6326: + return "果洛藏族自治州"; + case 632621: + return "玛沁县"; + case 632622: + return "班玛县"; + case 632623: + return "甘德县"; + case 632624: + return "达日县"; + case 632625: + return "久治县"; + case 632626: + return "玛多县"; + case 6327: + return "玉树藏族自治州"; + case 632701: + return "玉树市"; + case 632722: + return "杂多县"; + case 632723: + return "称多县"; + case 632724: + return "治多县"; + case 632725: + return "囊谦县"; + case 632726: + return "曲麻莱县"; + case 6328: + return "海西蒙古族藏族自治州"; + case 632801: + return "格尔木市"; + case 632802: + return "德令哈市"; + case 632821: + return "乌兰县"; + case 632822: + return "都兰县"; + case 632823: + return "天峻县"; + case 64: + return "宁夏回族自治区"; + case 6401: + return "银川市"; + case 640101: + return "市辖区"; + case 640104: + return "兴庆区"; + case 640105: + return "西夏区"; + case 640106: + return "金凤区"; + case 640121: + return "永宁县"; + case 640122: + return "贺兰县"; + case 640181: + return "灵武市"; + case 6402: + return "石嘴山市"; + case 640201: + return "市辖区"; + case 640202: + return "大武口区"; + case 640205: + return "惠农区"; + case 640221: + return "平罗县"; + case 6403: + return "吴忠市"; + case 640301: + return "市辖区"; + case 640302: + return "利通区"; + case 640303: + return "红寺堡区"; + case 640323: + return "盐池县"; + case 640324: + return "同心县"; + case 640381: + return "青铜峡市"; + case 6404: + return "固原市"; + case 640401: + return "市辖区"; + case 640402: + return "原州区"; + case 640422: + return "西吉县"; + case 640423: + return "隆德县"; + case 640424: + return "泾源县"; + case 640425: + return "彭阳县"; + case 6405: + return "中卫市"; + case 640501: + return "市辖区"; + case 640502: + return "沙坡头区"; + case 640521: + return "中宁县"; + case 640522: + return "海原县"; + case 65: + return "新疆维吾尔自治区"; + case 6501: + return "乌鲁木齐市"; + case 650101: + return "市辖区"; + case 650102: + return "天山区"; + case 650103: + return "沙依巴克区"; + case 650104: + return "新市区"; + case 650105: + return "水磨沟区"; + case 650106: + return "头屯河区"; + case 650107: + return "达坂城区"; + case 650109: + return "米东区"; + case 650121: + return "乌鲁木齐县"; + case 6502: + return "克拉玛依市"; + case 650201: + return "市辖区"; + case 650202: + return "独山子区"; + case 650203: + return "克拉玛依区"; + case 650204: + return "白碱滩区"; + case 650205: + return "乌尔禾区"; + case 6521: + return "吐鲁番地区"; + case 652101: + return "吐鲁番市"; + case 652122: + return "鄯善县"; + case 652123: + return "托克逊县"; + case 6522: + return "哈密地区"; + case 652201: + return "哈密市"; + case 652222: + return "巴里坤哈萨克自治县"; + case 652223: + return "伊吾县"; + case 6523: + return "昌吉回族自治州"; + case 652301: + return "昌吉市"; + case 652302: + return "阜康市"; + case 652323: + return "呼图壁县"; + case 652324: + return "玛纳斯县"; + case 652325: + return "奇台县"; + case 652327: + return "吉木萨尔县"; + case 652328: + return "木垒哈萨克自治县"; + case 6527: + return "博尔塔拉蒙古自治州"; + case 652701: + return "博乐市"; + case 652702: + return "阿拉山口市"; + case 652722: + return "精河县"; + case 652723: + return "温泉县"; + case 6528: + return "巴音郭楞蒙古自治州"; + case 652801: + return "库尔勒市"; + case 652822: + return "轮台县"; + case 652823: + return "尉犁县"; + case 652824: + return "若羌县"; + case 652825: + return "且末县"; + case 652826: + return "焉耆回族自治县"; + case 652827: + return "和静县"; + case 652828: + return "和硕县"; + case 652829: + return "博湖县"; + case 6529: + return "阿克苏地区"; + case 652901: + return "阿克苏市"; + case 652922: + return "温宿县"; + case 652923: + return "库车县"; + case 652924: + return "沙雅县"; + case 652925: + return "新和县"; + case 652926: + return "拜城县"; + case 652927: + return "乌什县"; + case 652928: + return "阿瓦提县"; + case 652929: + return "柯坪县"; + case 6530: + return "克孜勒苏柯尔克孜自治州"; + case 653001: + return "阿图什市"; + case 653022: + return "阿克陶县"; + case 653023: + return "阿合奇县"; + case 653024: + return "乌恰县"; + case 6531: + return "喀什地区"; + case 653101: + return "喀什市"; + case 653121: + return "疏附县"; + case 653122: + return "疏勒县"; + case 653123: + return "英吉沙县"; + case 653124: + return "泽普县"; + case 653125: + return "莎车县"; + case 653126: + return "叶城县"; + case 653127: + return "麦盖提县"; + case 653128: + return "岳普湖县"; + case 653129: + return "伽师县"; + case 653130: + return "巴楚县"; + case 653131: + return "塔什库尔干塔吉克自治县"; + case 6532: + return "和田地区"; + case 653201: + return "和田市"; + case 653221: + return "和田县"; + case 653222: + return "墨玉县"; + case 653223: + return "皮山县"; + case 653224: + return "洛浦县"; + case 653225: + return "策勒县"; + case 653226: + return "于田县"; + case 653227: + return "民丰县"; + case 6540: + return "伊犁哈萨克自治州"; + case 654002: + return "伊宁市"; + case 654003: + return "奎屯市"; + case 654021: + return "伊宁县"; + case 654022: + return "察布查尔锡伯自治县"; + case 654023: + return "霍城县"; + case 654024: + return "巩留县"; + case 654025: + return "新源县"; + case 654026: + return "昭苏县"; + case 654027: + return "特克斯县"; + case 654028: + return "尼勒克县"; + case 6542: + return "塔城地区"; + case 654201: + return "塔城市"; + case 654202: + return "乌苏市"; + case 654221: + return "额敏县"; + case 654223: + return "沙湾县"; + case 654224: + return "托里县"; + case 654225: + return "裕民县"; + case 654226: + return "和布克赛尔蒙古自治县"; + case 6543: + return "阿勒泰地区"; + case 654301: + return "阿勒泰市"; + case 654321: + return "布尔津县"; + case 654322: + return "富蕴县"; + case 654323: + return "福海县"; + case 654324: + return "哈巴河县"; + case 654325: + return "青河县"; + case 654326: + return "吉木乃县"; + case 6590: + return "自治区直辖县级行政区划"; + case 659001: + return "石河子市"; + case 659002: + return "阿拉尔市"; + case 659003: + return "图木舒克市"; + case 659004: + return "五家渠市"; + case 71: + return "台湾省"; + case 81: + return "香港特别行政区"; + case 82: + return "澳门特别行政区"; + default: + return null; + } + } + +} diff --git a/src/com/engine/salary/formlua/util/RegularUtil.java b/src/com/engine/salary/formlua/util/RegularUtil.java new file mode 100644 index 000000000..9ea89a9dc --- /dev/null +++ b/src/com/engine/salary/formlua/util/RegularUtil.java @@ -0,0 +1,241 @@ +package com.engine.salary.formlua.util; + + +import java.util.HashMap; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * @className: + * @Description:正则表达式工具 + * @Author: + * @date: + */ +public class RegularUtil { + public static void validateIDCard(String idCard){ + Pattern pattern = Pattern.compile("^[1-9]\\d{5}(18|19|([23]\\d))\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{3}[0-9Xx]$"); + Matcher matcher = pattern.matcher(idCard); + if (!matcher.matches()) { + throw new RuntimeException("身份证号码不合法"); + } + } + public static void checkAggCnd(String formula){ + String startPartternStr="^(OR\\(|AND\\()"; + Pattern startPattern = Pattern.compile(startPartternStr); + Matcher startMatcher = startPattern.matcher(formula); + if(!startMatcher.find()){ + throw new RuntimeException("条件筛选函数只允许AND函数与OR函数"); + } +// else { +// String partternStr="(AND|OR)+\\(+(.)+\\)+"; +// Pattern pattern = Pattern.compile(partternStr); +// Matcher matcher = pattern.matcher(formula); +// while (matcher.find()){ +// String fr=matcher.group(); +// logger.info(fr); +// fr=fr.replaceAll("(AND|OR)",""); +// String partternStr2="(.)+\\(+(.)+\\)+"; +// Pattern pattern2 = Pattern.compile(partternStr2); +// Matcher matcher2 = pattern2.matcher(fr); +// if(matcher2.find()){ +// throw new RuntimeException("条件筛选参数不正确"); +// } +// } +// } + } + public static boolean isNumber(Object obj) { + if(obj==null){ + return false; + } + String nstr=obj.toString(); + String reg = "\\d+(\\.\\d+)?"; + if(nstr.startsWith("-")){ + nstr=nstr.substring(1); + } + Boolean strResult = nstr.matches(reg); + return strResult; + } + + /** + * 判断是否是0或正整数 + * @param obj + * @return + */ + public static boolean isNonNegativeInteger(Object obj) { + if(obj == null) return false; + String nstr = obj.toString(); + + String reg = "^[1-9]\\d*|0$"; + return nstr.matches(reg); + } + + /** + * 是否是整数,正整数、0、负整数 + * @param obj + * @return + */ + public static boolean isInteger(Object obj){ + if(obj == null) return false; + String nstr = obj.toString(); + + String reg = "^-?[1-9]\\d*$"; + return nstr.matches(reg); + } + + /** + * IF函数的规则判断 + * @param str + * @return + */ + public static Map checkIfFunc(String str){ + Map rmap=new HashMap(); + str=str.trim().replaceAll(" ",""); + boolean r=true; + String patt="if{1}\\({1}\\w+[<|>|!=|==]+\\w+\\){1}[\\w\\{\\}]*"; + String charCheckIf="if{1}"; + String charCheckLf="if{1}\\({1}"; + String charCheckRf="\\){1}"; + String paramLeft="\\({1}\\w+[<|>|!=]+"; + String paramRight="[<|>|!=]+\\w+\\){1}"; + String paramOperSym="[<|>|!=]+"; + Pattern rPattern = Pattern.compile(patt); + Pattern ifPattern=Pattern.compile(charCheckIf); + Pattern leftPattern=Pattern.compile(charCheckLf); + Pattern rightPattern=Pattern.compile(charCheckRf); + Pattern leftParamPatt=Pattern.compile(paramLeft); + Pattern rightParamPatt = Pattern.compile(paramRight); + Pattern operSybmPattern=Pattern.compile(paramOperSym); + + //先测试整条语句是否符合规则 + boolean pOneResult=rPattern.matcher(str).find(); + + + if(!pOneResult){ + //以下为逐一排查问题的位置 + boolean pIfResult =ifPattern.matcher(str).find(); + boolean leftResult=leftPattern.matcher(str).find(); + boolean rightResult=rightPattern.matcher(str).find(); + boolean lpResult=leftParamPatt.matcher(str).find(); + boolean rpResult=rightParamPatt.matcher(str).find(); + boolean operSybmResult=operSybmPattern.matcher(str).find(); + r=false; + rmap.put("result",r); + if(!pIfResult){ + rmap.put("info","格式不正确缺少if标识符"); + }else if(!leftResult){ + rmap.put("info","格式不正确缺少左括号(标识符"); + }else if(!rightResult){ + rmap.put("info","格式不正确缺少右括号)标识符"); + }else if(!lpResult){ + rmap.put("info","格式不正确缺少左侧参数"); + }else if(!rpResult){ + rmap.put("info","格式不正确缺少右侧参数"); + }else if(!operSybmResult){ + rmap.put("info","格式不正确缺少操作符"); + }else{ + rmap.put("info","格式未通过格式验证"); + } + + } + return rmap; + } + /** + * 判断是否含有字母 + * @param str + * @return + */ + public static boolean containsLetter(String str) { + String patt="[a-z|A-Z]"; + Pattern r = Pattern.compile(patt); + Matcher matcher = r.matcher(str); + return matcher.find(); + } + + /** + * 判断是否含有数字 + * @param str + * @return + */ + public static boolean containsNum(String str) { + String patt="[0-9]"; + Pattern r = Pattern.compile(patt); + Matcher matcher = r.matcher(str); + return matcher.find(); + } + + /** + * 判断是否含有非字母 + * @param str + * @return + */ + public static boolean containsNotLetter(String str) { + String patt="[^a-z|^A-Z]"; + Pattern r = Pattern.compile(patt); + Matcher matcher = r.matcher(str); + return matcher.find(); + } + + /** + * 判断是否包含非数字 + * @param str + * @return + */ + public static boolean containsNotNum(String str){ + String patt="[^0-9]"; + Pattern r = Pattern.compile(patt); + Matcher matcher = r.matcher(str); + return matcher.find(); + } + /** + * 替换非字母 + * @param str + * @return + */ + public static String containsNotLetterR(String str,String replaceStr) { + String patt="[^a-z|^A-Z]"; + Pattern r = Pattern.compile(patt); + Matcher matcher = r.matcher(str); + return matcher.replaceAll(replaceStr); + } + /** + * 替换非数字 + * @param str + * @param replaceStr + * @return + */ + public static String containsNotNumR(String str,String replaceStr){ + String patt="[^0-9]"; + Pattern r = Pattern.compile(patt); + Matcher matcher = r.matcher(str); + return matcher.replaceAll(replaceStr); + } + + /** + * 判断是否含有字母并替换 + * @param str + * @param replaceStr + * @return + */ + public static String containsLetterR(String str,String replaceStr) { + String patt="[a-z|A-Z]"; + Pattern r = Pattern.compile(patt); + Matcher matcher = r.matcher(str); + str=matcher.replaceAll(replaceStr); + return str; + } + + /** + * 判断是否含有数字并替换 + * @param str + * @param replaceStr + * @return + */ + public static String containsNumR(String str,String replaceStr) { + String patt="[0-9]"; + Pattern r = Pattern.compile(patt); + Matcher matcher = r.matcher(str); + return matcher.replaceAll(replaceStr); + } + +} diff --git a/src/com/engine/salary/formlua/util/SortUtil.java b/src/com/engine/salary/formlua/util/SortUtil.java new file mode 100644 index 000000000..f3081283e --- /dev/null +++ b/src/com/engine/salary/formlua/util/SortUtil.java @@ -0,0 +1,49 @@ +package com.engine.salary.formlua.util; + + +public class SortUtil { + /** + * 数组快速排序 + * @param array + * @param left + * @param right + */ + public static void sort(int[] array, int left, int right){ + if(left > right) { + return; + } + // base中存放基准数 + int base = array[left]; + int i = left, j = right; + while(i != j) { + // 顺序很重要,先从右边开始往左找,直到找到比base值小的数 + while(array[j] >= base && i < j) { + j--; + } + + // 再从左往右边找,直到找到比base值大的数 + while(array[i] <= base && i < j) { + i++; + } + + // 上面的循环结束表示找到了位置或者(i>=j)了,交换两个数在数组中的位置 + if(i < j) { + int tmp = array[i]; + array[i] = array[j]; + array[j] = tmp; + } + } + + // 将基准数放到中间的位置(基准数归位) + array[left] = array[i]; + array[i] = base; + + // 递归,继续向基准的左右两边执行和上面同样的操作 + // i的索引处为上面已确定好的基准值的位置,无需再处理 + sort(array, left, i - 1); + sort(array, i + 1, right); + } + + + +} diff --git a/src/com/engine/salary/formlua/util/standard/ExcelDataType.java b/src/com/engine/salary/formlua/util/standard/ExcelDataType.java new file mode 100644 index 000000000..0618130ef --- /dev/null +++ b/src/com/engine/salary/formlua/util/standard/ExcelDataType.java @@ -0,0 +1,8 @@ +package com.engine.salary.formlua.util.standard; + +public enum ExcelDataType { + string("字符类型"),number("数字类型"),date("日期类型"),option("选项类型"),form("表格类型"),dataSource("数据源类型"); + + ExcelDataType(String name) { + } +} diff --git a/src/com/engine/salary/handle/LongListTypeHandler.java b/src/com/engine/salary/handle/LongListTypeHandler.java new file mode 100644 index 000000000..43b175a6f --- /dev/null +++ b/src/com/engine/salary/handle/LongListTypeHandler.java @@ -0,0 +1,49 @@ +package com.engine.salary.handle; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import lombok.extern.slf4j.Slf4j; +import org.apache.ibatis.type.BaseTypeHandler; +import org.apache.ibatis.type.JdbcType; + +import java.sql.CallableStatement; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; + +/** + * 集合的转换 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Slf4j +public class LongListTypeHandler extends BaseTypeHandler> { + + @Override + public void setNonNullParameter(PreparedStatement preparedStatement, int i, List list, JdbcType jdbcType) throws SQLException { + preparedStatement.setString(i, JSON.toJSONString(list)); + } + + @Override + public List getNullableResult(ResultSet resultSet, String s) throws SQLException { + List jsonArray = JSONArray.parseArray(resultSet.getString(s), Long.class); + return jsonArray == null ? new ArrayList<>() : jsonArray; + } + + @Override + public List getNullableResult(ResultSet resultSet, int i) throws SQLException { + List jsonArray = JSONArray.parseArray(resultSet.getString(i), Long.class); + return jsonArray == null ? new ArrayList<>() : jsonArray; + } + + @Override + public List getNullableResult(CallableStatement callableStatement, int i) throws SQLException { + List jsonArray = JSONArray.parseArray(callableStatement.getString(i), Long.class); + return jsonArray == null ? new ArrayList<>() : jsonArray; + } +} diff --git a/src/com/engine/salary/handle/SalaryListTypeHandler.java b/src/com/engine/salary/handle/SalaryListTypeHandler.java new file mode 100644 index 000000000..81e731c80 --- /dev/null +++ b/src/com/engine/salary/handle/SalaryListTypeHandler.java @@ -0,0 +1,49 @@ +package com.engine.salary.handle; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import lombok.extern.slf4j.Slf4j; +import org.apache.ibatis.type.BaseTypeHandler; +import org.apache.ibatis.type.JdbcType; + +import java.sql.CallableStatement; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; + +/** + * 集合的转换 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Slf4j +public class SalaryListTypeHandler extends BaseTypeHandler { + + @Override + public void setNonNullParameter(PreparedStatement preparedStatement, int i, List list, JdbcType jdbcType) throws SQLException { + preparedStatement.setString(i, JSON.toJSONString(list)); + } + + @Override + public List getNullableResult(ResultSet resultSet, String s) throws SQLException { + JSONArray jsonArray = JSONArray.parseArray(resultSet.getString(s)); + return jsonArray == null ? new ArrayList<>() : jsonArray; + } + + @Override + public List getNullableResult(ResultSet resultSet, int i) throws SQLException { + JSONArray jsonArray = JSONArray.parseArray(resultSet.getString(i)); + return jsonArray == null ? new ArrayList<>() : jsonArray; + } + + @Override + public List getNullableResult(CallableStatement callableStatement, int i) throws SQLException { + JSONArray jsonArray = JSONArray.parseArray(callableStatement.getString(i)); + return jsonArray == null ? new ArrayList<>() : jsonArray; + } +} diff --git a/src/com/engine/salary/maintainer/MaintainerController.java b/src/com/engine/salary/maintainer/MaintainerController.java new file mode 100644 index 000000000..c184a6082 --- /dev/null +++ b/src/com/engine/salary/maintainer/MaintainerController.java @@ -0,0 +1,111 @@ +package com.engine.salary.maintainer; + +import com.engine.common.util.ServiceUtil; +import com.engine.salary.maintainer.datacollection.AddUpSituationManager; +import com.engine.salary.maintainer.salaryacct.SalaryAcctManager; +import com.engine.salary.maintainer.salaryacct.SalaryAcctSupplementParam; +import com.engine.salary.maintainer.salaryarchive.SalaryArchiveManager; +import com.engine.salary.util.ResponseResult; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import java.util.Arrays; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * 累计专项附加扣除 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Slf4j +public class MaintainerController { + + private SalaryAcctManager getSalaryAcctManager(User user) { + return ServiceUtil.getService(SalaryAcctManager.class, user); + } + + private AddUpSituationManager getAddUpSituationManager(User user) { + return ServiceUtil.getService(AddUpSituationManager.class, user); + } + + private SalaryArchiveManager getSalaryArchiveManager(User user) { + return ServiceUtil.getService(SalaryArchiveManager.class, user); + } + + //---------------------------薪资核算 start ------------------------------------ + + /** + * 补充核算 + * + * @return + */ + @GET + @Path("/acct/supplement") + @Produces(MediaType.APPLICATION_JSON) + public String supplementAcctRecord(@Context HttpServletRequest request, @Context HttpServletResponse response) { + String type = request.getParameter("type"); + String salaryAcctRecordStrIds = request.getParameter("salaryAcctRecordStrIds"); + String salarySobStrIds = request.getParameter("salarySobStrIds"); + String salaryItemStrIds = request.getParameter("salaryItemStrIds"); + SalaryAcctSupplementParam queryParam = SalaryAcctSupplementParam.builder() + .type(type) + .salaryAcctRecordStrIds(salaryAcctRecordStrIds) + .salarySobStrIds(salarySobStrIds) + .salaryItemStrIds(salaryItemStrIds) + .build(); + if (StringUtils.isNotBlank(salaryAcctRecordStrIds)) { + queryParam.setSalaryAcctRecordIds(Arrays.stream(salaryAcctRecordStrIds.split(",")).map(Long::valueOf).collect(Collectors.toList())); + } + if (StringUtils.isNotBlank(salarySobStrIds)) { + queryParam.setSalarySobIds(Arrays.stream(salarySobStrIds.split(",")).map(Long::valueOf).collect(Collectors.toList())); + } + if (StringUtils.isNotBlank(salaryItemStrIds)) { + queryParam.setSalaryItemIds(Arrays.stream(salaryItemStrIds.split(",")).map(Long::valueOf).collect(Collectors.toList())); + } + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalaryAcctManager(user)::supplementAcctRecord, queryParam); + } + + + //---------------------------薪资核算 end ------------------------------------ + + + //---------------------------数据采集 往期累计情况 start ------------------------------------ + + /** + * 恢复所有已申报的往期累计数据 + * + * @return + */ + @GET + @Path("/addupsituation/recover") + @Produces(MediaType.APPLICATION_JSON) + public String recoverAddUpSituationHistoryData(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult, Boolean>(user).run(getAddUpSituationManager(user)::recoverAddUpHistoryData); + } + //---------------------------数据采集 往期累计情况 end ------------------------------------ + + + @GET + @Path("/salaryArchive/initPayStartDate") + @Produces(MediaType.APPLICATION_JSON) + public String initPayDate(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryArchiveManager(user)::initPayStartDate); + } + +} diff --git a/src/com/engine/salary/maintainer/datacollection/AddUpSituationManager.java b/src/com/engine/salary/maintainer/datacollection/AddUpSituationManager.java new file mode 100644 index 000000000..8a9ca719a --- /dev/null +++ b/src/com/engine/salary/maintainer/datacollection/AddUpSituationManager.java @@ -0,0 +1,68 @@ +package com.engine.salary.maintainer.datacollection; + +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.entity.taxdeclaration.param.TaxDeclarationSaveParam; +import com.engine.salary.entity.taxdeclaration.po.TaxDeclarationPO; +import com.engine.salary.mapper.taxdeclaration.TaxDeclarationMapper; +import com.engine.salary.service.TaxDeclarationService; +import com.engine.salary.service.impl.TaxDeclarationServiceImpl; +import com.engine.salary.util.SalaryDateUtil; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.db.MapperProxyFactory; +import weaver.general.BaseBean; + +import java.text.SimpleDateFormat; +import java.time.LocalDate; +import java.time.YearMonth; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * @author Harryxzy + * @date 2023/04/23 17:23 + * @description 往期累计情况维护类 + */ +public class AddUpSituationManager extends Service { + + private TaxDeclarationMapper getTaxDeclarationMapper() { + return MapperProxyFactory.getProxy(TaxDeclarationMapper.class); + } + + private TaxDeclarationService getTaxDeclarationService() { + return ServiceUtil.getService(TaxDeclarationServiceImpl.class, user); + } + + public boolean recoverAddUpHistoryData() { + // 获取已有的个税申报表记录 + List taxDeclarationList = getTaxDeclarationMapper().listSome(new TaxDeclarationPO()); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM"); + Map taxDeclarationMap = SalaryEntityUtil.convert2Map(taxDeclarationList, TaxDeclarationPO::getId, PO -> PO.getTaxAgentId() + "-" + sdf.format(PO.getSalaryMonth())); + BaseBean bb = new BaseBean(); + List taxDeclarationIds = taxDeclarationList.stream().map(TaxDeclarationPO::getId).collect(Collectors.toList()); + bb.writeLog("往期累计数据恢复DataIds:" + taxDeclarationIds); + bb.writeLog("往期累计数据恢复DataMap:" + taxDeclarationMap); + boolean result = true; + // 循环调用生成申报单接口 + for (int i = 0; i < taxDeclarationList.size(); i++) { + TaxDeclarationPO po = taxDeclarationList.get(i); + bb.writeLog("开始删除生成:" + po.getTaxAgentId() + "-" + po.getSalaryMonth()); + // 删除记录 + int delete = getTaxDeclarationMapper().deleteByIdZj(po.getId()); + LocalDate localDate = SalaryDateUtil.dateToLocalDate(po.getSalaryMonth()); + // 调用生成申报单接口 + YearMonth yearMonth = YearMonth.of(localDate.getYear(), localDate.getMonth()); + try { + getTaxDeclarationService().save(TaxDeclarationSaveParam.builder().salaryMonth(yearMonth).salaryDate(po.getSalaryMonth()).taxCycle(po.getTaxCycle()).taxAgentId(po.getTaxAgentId()).build()); + } catch (Exception e) { + bb.writeLog("错误:" + e); + result = false; + continue; + } + } + return result; + } + + +} diff --git a/src/com/engine/salary/maintainer/salaryacct/SalaryAcctManager.java b/src/com/engine/salary/maintainer/salaryacct/SalaryAcctManager.java new file mode 100644 index 000000000..289b898bd --- /dev/null +++ b/src/com/engine/salary/maintainer/salaryacct/SalaryAcctManager.java @@ -0,0 +1,387 @@ +package com.engine.salary.maintainer.salaryacct; + +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.datacollection.dto.AttendQuoteFieldListDTO; +import com.engine.salary.entity.salaryacct.bo.SalaryAcctCalculateBO; +import com.engine.salary.entity.salaryacct.bo.SalaryAcctCalculatePriorityBO; +import com.engine.salary.entity.progress.ProgressDTO; +import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO; +import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO; +import com.engine.salary.entity.salaryacct.po.SalaryAcctResultPO; +import com.engine.salary.entity.salaryacct.po.SalaryAcctResultTempPO; +import com.engine.salary.entity.salaryformula.ExpressFormula; +import com.engine.salary.entity.salaryitem.po.SalaryItemPO; +import com.engine.salary.entity.salarysob.dto.SalarySobCycleDTO; +import com.engine.salary.entity.salarysob.po.SalarySobAdjustRulePO; +import com.engine.salary.entity.salarysob.po.SalarySobBackItemPO; +import com.engine.salary.entity.salarysob.po.SalarySobItemPO; +import com.engine.salary.entity.salarysob.po.SalarySobPO; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.mapper.salaryacct.SalaryAcctResultMapper; +import com.engine.salary.service.*; +import com.engine.salary.service.impl.*; +import com.engine.salary.sys.enums.TaxDeclarationFunctionEnum; +import com.engine.salary.sys.service.SalarySysConfService; +import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.db.MapperProxyFactory; +import com.engine.salary.util.valid.ValidUtil; +import com.google.common.collect.Lists; +import com.weaver.util.threadPool.ThreadPoolUtil; +import com.weaver.util.threadPool.constant.ModulePoolEnum; +import com.weaver.util.threadPool.entity.LocalRunnable; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.collections4.MapUtils; +import org.apache.commons.lang.math.NumberUtils; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.BeanUtils; +import org.springframework.jdbc.datasource.DataSourceTransactionManager; +import weaver.hrm.User; + +import java.math.BigDecimal; +import java.util.*; +import java.util.concurrent.BlockingDeque; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.LinkedBlockingDeque; +import java.util.stream.Collectors; + +/** + * 薪资核算维护类 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Slf4j +public class SalaryAcctManager extends Service { + private SalaryAcctResultMapper getSalaryAcctResultMapper() { + return MapperProxyFactory.getProxy(SalaryAcctResultMapper.class); + } + + private SalaryAcctEmployeeService getSalaryAcctEmployeeService(User user) { + return ServiceUtil.getService(SalaryAcctEmployeeServiceImpl.class, user); + } + + private SalaryAcctResultService getSalaryAcctResultService(User user) { + return ServiceUtil.getService(SalaryAcctResultServiceImpl.class, user); + } + + private SalarySobItemService getSalarySobItemService(User user) { + return ServiceUtil.getService(SalarySobItemServiceImpl.class, user); + } + + private SalaryItemService getSalaryItemService(User user) { + return ServiceUtil.getService(SalaryItemServiceImpl.class, user); + } + + private SalarySobEmpFieldService getSalarySobEmpFieldService(User user) { + return ServiceUtil.getService(SalarySobEmpFieldServiceImpl.class, user); + } + + private SalarySobService getSalarySobService(User user) { + return ServiceUtil.getService(SalarySobServiceImpl.class, user); + } + + private SalaryAcctRecordService getSalaryAcctRecordService(User user) { + return ServiceUtil.getService(SalaryAcctRecordServiceImpl.class, user); + } + + private TaxAgentService getTaxAgentService(User user) { + return ServiceUtil.getService(TaxAgentServiceImpl.class, user); + } + + private SalaryEmployeeService getSalaryEmployeeService(User user) { + return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user); + } + + private SalaryFormulaService getSalaryFormulaService(User user) { + return ServiceUtil.getService(SalaryFormulaServiceImpl.class, user); + } + + private SalarySobAdjustRuleService getSalarySobAdjustRuleService(User user) { + return ServiceUtil.getService(SalarySobAdjustRuleServiceImpl.class, user); + } + + + private SalaryAcctCalculateService getSalaryAcctCalculateService(User user) { + return ServiceUtil.getService(SalaryAcctCalculateServiceImpl.class, user); + } + + private ProgressService getSalaryAcctProgressService(User user) { + return ServiceUtil.getService(ProgressServiceImpl.class, user); + } + + private DataSourceTransactionManager dataSourceTransactionManager; + + private SalaryAcctResultTempService getSalaryAcctResultTempService(User user) { + return ServiceUtil.getService(SalaryAcctResultTempServiceImpl.class, user); + } + + private SIAccountService getSIAccountService(User user) { + return ServiceUtil.getService(SIAccountServiceImpl.class, user); + } + + private AttendQuoteFieldService getAttendQuoteFieldService(User user) { + return ServiceUtil.getService(AttendQuoteFieldServiceImpl.class, user); + } + + private SalaryAcctReportService getSalaryAcctReportService(User user) { + return ServiceUtil.getService(SalaryAcctReportServiceImpl.class, user); + } + + private SalarySobItemGroupService getSalarySobItemGroupService(User user) { + return ServiceUtil.getService(SalarySobItemGroupServiceImpl.class, user); + } + + private SalarySobBackItemService getSalarySobBackItemService(User user) { + return ServiceUtil.getService(SalarySobBackItemServiceImpl.class, user); + } + + private SalarySysConfService getSalarySysConfService(User user) { + return ServiceUtil.getService(SalarySysConfServiceImpl.class, user); + } + + + + /** + * 补充核算 + * 核算已归档后,需要重新核算某一项 + */ + public void supplementAcctRecord(SalaryAcctSupplementParam param) { + ValidUtil.doValidator(param); + + + //待补算的记录 + List salaryAcctRecordPOS = new ArrayList<>(); + + if (StringUtils.equals(param.getType(), "sob")) { + + List salarySobIds = param.getSalarySobIds(); + + if (CollectionUtils.isEmpty(salarySobIds)) { + throw new SalaryRunTimeException("补算账套为空!"); + } + //获取账套下面所有的核算记录 + salaryAcctRecordPOS = getSalaryAcctRecordService(user).listBySalarySobIds(salarySobIds); + + if (CollectionUtils.isEmpty(salaryAcctRecordPOS)) { + throw new SalaryRunTimeException("账套下不存在核算记录"); + } + + } else if (StringUtils.equals(param.getType(), "record")) { + + List salaryAcctRecordIds = param.getSalaryAcctRecordIds(); + + salaryAcctRecordPOS = getSalaryAcctRecordService(user).listByIds(salaryAcctRecordIds); + + if (CollectionUtils.isEmpty(salaryAcctRecordPOS)) { + throw new SalaryRunTimeException("核算记录不存在"); + } + } else { + throw new SalaryRunTimeException("补算方式异常!"); + } + + salaryAcctRecordPOS.forEach(salaryAcctRecordPO -> { + param.setSalaryAcctRecordId(salaryAcctRecordPO.getId()); + calculate(param); + }); + + } + + /** + * 补算 + * + * @param calculateParam 薪资核算的参数 + */ + public void calculate(SalaryAcctSupplementParam calculateParam) { + log.info("补算开始{}", calculateParam); + + //核算记录 + Long salaryAcctRecordId = calculateParam.getSalaryAcctRecordId(); + + //当前登陆人员 + DataCollectionEmployee simpleEmployee = new DataCollectionEmployee(); + simpleEmployee.setEmployeeId((long) user.getUID()); + + // 检查是否正在核算中 + ProgressDTO salaryAcctProgressDTO = getSalaryAcctProgressService(user).getProgress("SUPPLEMENT_ACCT_PROGRESS_" + salaryAcctRecordId); + if (Objects.nonNull(salaryAcctProgressDTO) && salaryAcctProgressDTO.isStatus() && Optional.ofNullable(salaryAcctProgressDTO.getProgress()).orElse(BigDecimal.ZERO).compareTo(BigDecimal.ONE) < 0) { + return; + } + // 初始化进度 + ProgressDTO initProgress = new ProgressDTO() + .setTitle(SalaryI18nUtil.getI18nLabel(97515, "核算中")) + .setTitleLabelId(97515L) + .setTotalQuantity(NumberUtils.INTEGER_ONE) + .setCalculatedQuantity(NumberUtils.INTEGER_ZERO) + .setProgress(BigDecimal.ZERO) + .setStatus(true) + .setMessage(StringUtils.EMPTY); + getSalaryAcctProgressService(user).initProgress("SUPPLEMENT_ACCT_PROGRESS_" + salaryAcctRecordId, initProgress); + calculate(calculateParam, simpleEmployee); + } + + + public void calculate(SalaryAcctSupplementParam calculateParam, DataCollectionEmployee simpleEmployee) { + Long salaryAcctRecordId = calculateParam.getSalaryAcctRecordId(); + try { + // 1、查询薪资核算记录 + SalaryAcctRecordPO salaryAcctRecordPO = getSalaryAcctRecordService(user).getById(salaryAcctRecordId); + if (Objects.isNull(salaryAcctRecordPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98747, "薪资核算记录不存在或已被删除")); + } + //查询对应账套 + SalarySobPO salarySobPO = getSalarySobService(user).getById(salaryAcctRecordPO.getSalarySobId()); + if (Objects.isNull(salarySobPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98747, "薪资账套不存在或已被删除")); + } + // 2、查询薪资核算记录的薪资周期、考勤周期等 + SalarySobCycleDTO salarySobCycleDTO = getSalaryAcctRecordService(user).getSalarySobCycleById(salaryAcctRecordId); + // 3、查询薪资核算记录所用薪资账套的薪资项目副本 + List salarySobItemPOS = getSalarySobItemService(user).listBySalarySobId(salaryAcctRecordPO.getSalarySobId()); + if (CollectionUtils.isEmpty(salarySobItemPOS)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(99151, "当前所用的薪资账套未选择任何薪资项目,无法核算")); + } + // 回算薪资项目 + List salarySobBackItems = Collections.emptyList(); + if (Objects.equals(salaryAcctRecordPO.getBackCalcStatus(), 1)) { + salarySobBackItems = getSalarySobBackItemService(user).listBySalarySobId(salaryAcctRecordPO.getSalarySobId()); + } + // 4、查询当前租户的所有薪资项目 + List salaryItemPOS = getSalaryItemService(user).listAll(); + // 5、查询薪资核算记录所用薪资账套的调薪计薪规则 + List salarySobAdjustRulePOS = getSalarySobAdjustRuleService(user).listBySalarySobId(salaryAcctRecordPO.getSalarySobId()); + // 6、查询社保福利的所有字段 + Map welfareColumns = getSIAccountService(user).welfareColumns(); + // 7、查询考勤引用的所有字段 + List attendQuoteFieldListDTOS = getAttendQuoteFieldService(user).listAll(); + + //fixme 先全部锁定 + +// //将除重新核算的项目外的所有的值都锁定 +// List salaryItemIds = calculateParam.getSalaryItemIds(); +// List lockSalaryItemIds = salaryItemPOS.stream().map(SalaryItemPO::getId).filter(id -> !salaryItemIds.contains(id)).collect(Collectors.toList()); +// Map acctResults = new HashMap<>(); +// if (CollectionUtils.isNotEmpty(lockSalaryItemIds)) { +// List acctResultPOS = getSalaryAcctResultService(user).listBySalaryAcctRecordIds(Collections.singleton(salaryAcctRecordId)); +// acctResults = Optional.ofNullable(acctResultPOS) +// .orElse(new ArrayList<>()) +// .stream() +// .filter(po -> lockSalaryItemIds.contains(po.getSalaryItemId())) +// .collect(Collectors.toMap(po -> po.getSalaryItemId() + "_" + po.getSalaryAcctEmpId(), a -> a, (a, b) -> a)); +// } + + + // 8、查询公式详情 + Set formulaIds = SalaryEntityUtil.properties(salarySobItemPOS, SalarySobItemPO::getFormulaId); + formulaIds.addAll(SalaryEntityUtil.properties(salaryItemPOS, SalaryItemPO::getFormulaId)); + formulaIds.addAll(SalaryEntityUtil.properties(salarySobBackItems, SalarySobBackItemPO::getFormulaId)); + List expressFormulas = getSalaryFormulaService(user).listExpressFormula(formulaIds); + // 本次运算的回算薪资项目所涉及的变量 + Set issuedFieldIds = new HashSet<>(); + // 9、计算薪资项目的运算优先级 + List> salarySobItemsWithPriority = SalaryAcctCalculatePriorityBO.calculatePriority(salarySobItemPOS, salaryItemPOS, expressFormulas, salarySobBackItems, issuedFieldIds); + // 10、根据id查询其他合并计税的薪资核算记录 + List otherSalaryAcctRecordPOS = getSalaryAcctRecordService(user).listById4OtherConsolidatedTax(salaryAcctRecordPO.getId()); + // 11、查询本次核算人员 + List salaryAcctEmployeePOS = getSalaryAcctEmployeeService(user).listBySalaryAcctRecordId(salaryAcctRecordPO.getId()); + if (CollectionUtils.isEmpty(salaryAcctEmployeePOS)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(103378, "薪资核算人员不能为空")); + } + // 11.1、初始化进度 + ProgressDTO initProgress = new ProgressDTO().setTitle(SalaryI18nUtil.getI18nLabel(97515, "核算中")).setTitleLabelId(97515L).setTotalQuantity(salaryAcctEmployeePOS.size() * 2 + 1).setCalculatedQuantity(0).setProgress(BigDecimal.ZERO).setStatus(true).setMessage(StringUtils.EMPTY); + getSalaryAcctProgressService(user).initProgress("SUPPLEMENT_ACCT_PROGRESS_" + salaryAcctRecordId, initProgress); + // 12、对薪资核算人员进行拆分 + List> partition = Lists.partition(salaryAcctEmployeePOS, 100); + // 12.1、监控子线程的任务执行 + CountDownLatch childMonitor = new CountDownLatch(partition.size()); + // 12.2、记录子线程的执行结果 + BlockingDeque calculateResults = new LinkedBlockingDeque<>(partition.size()); + // 12.3、生成本次运算的key + String calculateKey = UUID.randomUUID().toString(); + // 12.4、是否采用系统算税 + TaxDeclarationFunctionEnum taxDeclarationFunction = getSalarySysConfService(user).getTaxDeclaration(); + // 12.4、多线程运算,运算结果存放在临时表中 + for (List acctEmployeePOS : partition) { + SalaryAcctCalculateBO salaryAcctCalculateBO = new SalaryAcctCalculateBO() + .setSalaryAcctRecordPO(salaryAcctRecordPO) + .setSalarySobPO(salarySobPO) + .setSalarySobCycleDTO(salarySobCycleDTO) + .setOtherSalaryAcctRecordPOS(otherSalaryAcctRecordPOS) + .setSalarySobItemPOS(salarySobItemPOS) + .setSalaryItemIdWithPriorityList(salarySobItemsWithPriority) + .setExpressFormulas(expressFormulas) + .setSalaryItemPOS(salaryItemPOS) + .setSalarySobAdjustRulePOS(salarySobAdjustRulePOS) + .setWelfareColumns(MapUtils.emptyIfNull(welfareColumns)) + .setAttendQuoteFieldListDTOS(attendQuoteFieldListDTOS) + .setSalaryAcctEmployeePOS(acctEmployeePOS) + .setIssuedFieldIds(issuedFieldIds) + .setChildMonitor(childMonitor) + .setResults(calculateResults) + .setCalculateKey(calculateKey) + .setTaxDeclarationFunction(taxDeclarationFunction); + List finalSalarySobBackItems = salarySobBackItems; + LocalRunnable localRunnable = new LocalRunnable() { + @Override + public void execute() { + getSalaryAcctCalculateService(user).calculate(salaryAcctCalculateBO, simpleEmployee, finalSalarySobBackItems); + } + }; + ThreadPoolUtil.fixedPoolExecute(ModulePoolEnum.HRM, "salaryAcctCalculate", localRunnable); + } + // 13、等待所有子线程执行完毕 + childMonitor.await(); + // 14、判断子线程执行结果 + boolean allSuccess = calculateResults.stream().allMatch(SalaryAcctCalculateBO.Result::isStatus); + if (!allSuccess) { + // 薪资核算实现的线程的错误信息 + String errorMsg = calculateResults.stream().filter(result -> !result.isStatus()).map(SalaryAcctCalculateBO.Result::getErrMsg).collect(Collectors.joining("|")); + getSalaryAcctProgressService(user).fail("SUPPLEMENT_ACCT_PROGRESS_" + salaryAcctRecordId, errorMsg); + // 删除薪资核算临时存储表中的数据 + getSalaryAcctResultTempService(user).deleteByCalculateKey(calculateKey); + return; + } + // 15、处理核算结果临时表数据 + handleSalaryAcctResultTemp(calculateParam, calculateKey); + + getSalaryAcctProgressService(user).finish("SUPPLEMENT_ACCT_PROGRESS_" + salaryAcctRecordId, true); + + } catch (Exception e) { + log.info("薪资核算出错:{}", e.getMessage(), e); + getSalaryAcctProgressService(user).fail("SUPPLEMENT_ACCT_PROGRESS_" + salaryAcctRecordId, SalaryI18nUtil.getI18nLabel(99642, "薪资核算出错") + ": " + e.getMessage()); + } + } + + /** + * 处理薪资核算临时存储表中的数据 + * + * @param calculateParam + * @param calculateKey + */ + private void handleSalaryAcctResultTemp(SalaryAcctSupplementParam calculateParam, String calculateKey) { + // 查询薪资核算结果的临时存储 + List salaryAcctResultTempPOS = getSalaryAcctResultTempService(user).listByCalculateKey(calculateKey); + // 删除原来的薪资核算结果 + List salaryItemIds = calculateParam.getSalaryItemIds(); + getSalaryAcctResultMapper().deleteBySalaryAcctRecordIdAndSalaryItemIds(calculateParam.getSalaryAcctRecordId(), salaryItemIds); + // 保存薪资的薪资核算结果 + List salaryAcctResultPOS = salaryAcctResultTempPOS.stream() + .filter(salaryAcctResultTempPO -> salaryItemIds.contains(salaryAcctResultTempPO.getSalaryItemId())) + .map(e -> { + SalaryAcctResultPO salaryAcctResult = new SalaryAcctResultPO(); + BeanUtils.copyProperties(e, salaryAcctResult); + return salaryAcctResult; + }).collect(Collectors.toList()); + getSalaryAcctResultService(user).batchSave(salaryAcctResultPOS); + // 删除薪资核算临时存储表中的数据 + getSalaryAcctResultTempService(user).deleteByCalculateKey(calculateKey); + } + + +} diff --git a/src/com/engine/salary/maintainer/salaryacct/SalaryAcctSupplementParam.java b/src/com/engine/salary/maintainer/salaryacct/SalaryAcctSupplementParam.java new file mode 100644 index 000000000..b70912377 --- /dev/null +++ b/src/com/engine/salary/maintainer/salaryacct/SalaryAcctSupplementParam.java @@ -0,0 +1,54 @@ +package com.engine.salary.maintainer.salaryacct; + +import com.engine.salary.util.valid.DataCheck; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * 薪资补充核算的参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalaryAcctSupplementParam { + + + //前端传入 + /** + * 补算方式,0按核算记录进行补充核算,1按账套进行补充核算 + */ + @DataCheck(require = true, message = "补算方式为空") + private String type; + + /** + * 按核算记录进行补充核算 + */ + private List salaryAcctRecordIds; + private String salaryAcctRecordStrIds; + + /** + * 按账套进行补充核算 + */ + private List salarySobIds; + private String salarySobStrIds; + + /** + * 待核算的项目 + */ + @DataCheck(require = true, message = "补算项目为空") + private List salaryItemIds; + private String salaryItemStrIds; + + //核算使用 + private Long salaryAcctRecordId; +} diff --git a/src/com/engine/salary/maintainer/salaryacct/SupAcctThread.java b/src/com/engine/salary/maintainer/salaryacct/SupAcctThread.java new file mode 100644 index 000000000..696ac6ad5 --- /dev/null +++ b/src/com/engine/salary/maintainer/salaryacct/SupAcctThread.java @@ -0,0 +1,42 @@ +package com.engine.salary.maintainer.salaryacct; + +import com.engine.salary.entity.datacollection.DataCollectionEmployee; + +public abstract class SupAcctThread implements Runnable { + + private SalaryAcctSupplementParam calculateParam; + + private DataCollectionEmployee simpleEmployee; + + public SalaryAcctSupplementParam getCalculateParam() { + return calculateParam; + } + + public void setCalculateParam(SalaryAcctSupplementParam calculateParam) { + this.calculateParam = calculateParam; + } + + public DataCollectionEmployee getSimpleEmployee() { + return simpleEmployee; + } + + public void setSimpleEmployee(DataCollectionEmployee simpleEmployee) { + this.simpleEmployee = simpleEmployee; + } + + public SupAcctThread(SalaryAcctSupplementParam calculateParam, DataCollectionEmployee simpleEmployee) { + this.calculateParam = calculateParam; + this.simpleEmployee = simpleEmployee; + } + + @Override + public void run() { + try { + execute(calculateParam, simpleEmployee); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public abstract void execute(SalaryAcctSupplementParam calculateParam, DataCollectionEmployee simpleEmployee) throws Exception; +} diff --git a/src/com/engine/salary/maintainer/salaryarchive/SalaryArchiveManager.java b/src/com/engine/salary/maintainer/salaryarchive/SalaryArchiveManager.java new file mode 100644 index 000000000..cbd52a6ca --- /dev/null +++ b/src/com/engine/salary/maintainer/salaryarchive/SalaryArchiveManager.java @@ -0,0 +1,64 @@ +package com.engine.salary.maintainer.salaryarchive; + +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.salaryarchive.po.SalaryArchivePO; +import com.engine.salary.enums.salaryarchive.SalaryArchiveStatusEnum; +import com.engine.salary.mapper.archive.SalaryArchiveMapper; +import com.engine.salary.service.SalaryArchiveService; +import com.engine.salary.service.SalaryEmployeeService; +import com.engine.salary.service.impl.SalaryArchiveServiceImpl; +import com.engine.salary.service.impl.SalaryEmployeeServiceImpl; +import com.engine.salary.util.SalaryDateUtil; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.db.MapperProxyFactory; +import org.apache.commons.lang3.StringUtils; +import weaver.hrm.User; + +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +public class SalaryArchiveManager extends Service { + private SalaryArchiveService getSalaryArchiveService(User user) { + return ServiceUtil.getService(SalaryArchiveServiceImpl.class, user); + } + + private SalaryEmployeeService getSalaryEmployeeService(User user) { + return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user); + } + + private SalaryArchiveMapper getSalaryArchiveMapper() { + return MapperProxyFactory.getProxy(SalaryArchiveMapper.class); + } + + public Boolean initPayStartDate() { + //获取所有待定薪档案 + List list = getSalaryArchiveService(user).listSome(SalaryArchivePO.builder().runStatus(SalaryArchiveStatusEnum.PENDING.getValue()).build()); + + //过滤已存在起始发薪日期的数据 + List needData = list.stream().filter(po -> po.getPayStartDate() == null).collect(Collectors.toList()); + List empIds = SalaryEntityUtil.properties(needData, SalaryArchivePO::getEmployeeId, Collectors.toList()); + + //获取人员信息 + List emps = getSalaryEmployeeService(user).getEmployeeByIds(empIds); + Map longDataCollectionEmployeeMap = SalaryEntityUtil.convert2Map(emps, DataCollectionEmployee::getEmployeeId); + + //设置起始发薪日期 + List collect1 = needData.stream().peek(po -> { + Long employeeId = po.getEmployeeId(); + DataCollectionEmployee orDefault = longDataCollectionEmployeeMap.getOrDefault(employeeId, new DataCollectionEmployee()); + String companystartdate = orDefault.getCompanystartdate(); + if (StringUtils.isNotBlank(companystartdate)&&SalaryDateUtil.checkDay(companystartdate)) { + Date parse = SalaryDateUtil.parse(companystartdate, SalaryDateUtil.DATE_FORMATTER_PATTERN); + po.setPayStartDate(parse); + } + }).collect(Collectors.toList()); + + collect1.forEach(getSalaryArchiveMapper()::update); + + return null; + } +} diff --git a/src/com/engine/salary/mapper/InsuranceExportMapper.java b/src/com/engine/salary/mapper/InsuranceExportMapper.java new file mode 100644 index 000000000..b4ef25f66 --- /dev/null +++ b/src/com/engine/salary/mapper/InsuranceExportMapper.java @@ -0,0 +1,22 @@ +package com.engine.salary.mapper; + +import com.engine.salary.entity.siaccount.param.InsuranceComparisonResultQueryParam; +import com.engine.salary.entity.siexport.param.InsuranceExportParam; +import com.engine.salary.entity.siexport.po.AccountExportPO; +import com.engine.salary.entity.siexport.po.ExcelAccountExportPO; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +public interface InsuranceExportMapper { + + List exportExcelAccount(@Param("param") InsuranceComparisonResultQueryParam param); + + List exportAccount(@Param("paymentStatus") Integer paymentStatus, @Param("param") InsuranceExportParam param); + + List exportRecessionAccount(@Param("paymentStatus") Integer paymentStatus, @Param("param") InsuranceExportParam param); + + List exportExtAccount(@Param("paymentStatus") Integer paymentStatus, @Param("param") InsuranceExportParam param); + + List exportExtExcelAccount(@Param("param") InsuranceComparisonResultQueryParam param); +} diff --git a/src/com/engine/salary/mapper/InsuranceExportMapper.xml b/src/com/engine/salary/mapper/InsuranceExportMapper.xml new file mode 100644 index 000000000..3a5397af8 --- /dev/null +++ b/src/com/engine/salary/mapper/InsuranceExportMapper.xml @@ -0,0 +1,321 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/com/engine/salary/mapper/SQLMapper.java b/src/com/engine/salary/mapper/SQLMapper.java new file mode 100644 index 000000000..9afff661a --- /dev/null +++ b/src/com/engine/salary/mapper/SQLMapper.java @@ -0,0 +1,20 @@ +package com.engine.salary.mapper; + +import org.apache.ibatis.annotations.Param; + +import java.util.List; +import java.util.Map; + +/** + * SQLMapper + *

Copyright: Copyright (c) 2024

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public interface SQLMapper { + List runSQL(@Param("sql") String sql); + + List listLong(@Param("sql") String sql); +} diff --git a/src/com/engine/salary/mapper/SQLMapper.xml b/src/com/engine/salary/mapper/SQLMapper.xml new file mode 100644 index 000000000..b487b3f53 --- /dev/null +++ b/src/com/engine/salary/mapper/SQLMapper.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/src/com/engine/salary/mapper/SysTaxRateBaseMapper.java b/src/com/engine/salary/mapper/SysTaxRateBaseMapper.java new file mode 100644 index 000000000..c982dd448 --- /dev/null +++ b/src/com/engine/salary/mapper/SysTaxRateBaseMapper.java @@ -0,0 +1,75 @@ +package com.engine.salary.mapper; + +import com.engine.salary.entity.taxrate.SysTaxRateBase; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; + + +public interface SysTaxRateBaseMapper { + + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + SysTaxRateBase getById(Long id); + + /** + * 新增,插入所有字段 + * + * @param sysTaxRateBase 新增的记录 + * @return 返回影响行数 + */ + int insert(SysTaxRateBase sysTaxRateBase); + + /** + * 新增,忽略null字段 + * + * @param sysTaxRateBase 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(SysTaxRateBase sysTaxRateBase); + + /** + * 修改,修改所有字段 + * + * @param sysTaxRateBase 修改的记录 + * @return 返回影响行数 + */ + int update(SysTaxRateBase sysTaxRateBase); + + /** + * 修改,忽略null字段 + * + * @param sysTaxRateBase 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(SysTaxRateBase sysTaxRateBase); + + /** + * 删除记录 + * + * @param sysTaxRateBase 待删除的记录 + * @return 返回影响行数 + */ + int delete(SysTaxRateBase sysTaxRateBase); + + List selectByIds(@Param("ids") Collection ids); + + /** + * 条件查询 + */ + List listBySome(@Param("param") SysTaxRateBase param); + +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/SysTaxRateBaseMapper.xml b/src/com/engine/salary/mapper/SysTaxRateBaseMapper.xml new file mode 100644 index 000000000..9ebe4337f --- /dev/null +++ b/src/com/engine/salary/mapper/SysTaxRateBaseMapper.xml @@ -0,0 +1,333 @@ + + + + + + + + + + + + + + + + + + t.create_time + , t.creator + , t.delete_type + , t.description + , t.id + , t.name + , t.system_type + , t.tenant_key + , t.update_time + + + + + AND id IN + + #{id} + + + + AND name = #{param.name} + + + + + + + + + + + + INSERT INTO hrsa_sys_tax_rate_base + + create_time, + creator, + delete_type, + description, + id, + name, + system_type, + tenant_key, + update_time, + + + #{createTime}, + #{creator}, + #{deleteType}, + #{description}, + #{id}, + #{name}, + #{systemType}, + #{tenantKey}, + #{updateTime}, + + + + + + select hrsa_sys_tax_rate_base_id.currval from dual + + INSERT INTO hrsa_sys_tax_rate_base + + create_time, + creator, + delete_type, + description, + id, + name, + system_type, + tenant_key, + update_time, + + + #{createTime}, + #{creator}, + #{deleteType}, + #{description}, + #{id}, + #{name}, + #{systemType}, + #{tenantKey}, + #{updateTime}, + + + + + + INSERT INTO hrsa_sys_tax_rate_base + + + + create_time, + + + creator, + + + delete_type, + + + description, + + + id, + + + name, + + + system_type, + + + tenant_key, + + + update_time, + + + + + #{createTime}, + + + #{creator}, + + + #{deleteType}, + + + #{description}, + + + #{id}, + + + #{name}, + + + #{systemType}, + + + #{tenantKey}, + + + #{updateTime}, + + + + + + + + select hrsa_sys_tax_rate_base_id.currval from dual + + INSERT INTO hrsa_sys_tax_rate_base + + + + create_time, + + + creator, + + + delete_type, + + + description, + + + id, + + + name, + + + system_type, + + + tenant_key, + + + update_time, + + + + + #{createTime}, + + + #{creator}, + + + #{deleteType}, + + + #{description}, + + + #{id}, + + + #{name}, + + + #{systemType}, + + + #{tenantKey}, + + + #{updateTime}, + + + + + + + UPDATE hrsa_sys_tax_rate_base + + create_time=#{createTime}, + creator=#{creator}, + delete_type=#{deleteType}, + description=#{description}, + name=#{name}, + system_type=#{systemType}, + tenant_key=#{tenantKey}, + update_time=#{updateTime}, + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_sys_tax_rate_base + + + create_time=#{createTime}, + + + creator=#{creator}, + + + delete_type=#{deleteType}, + + + description=#{description}, + + + name=#{name}, + + + system_type=#{systemType}, + + + tenant_key=#{tenantKey}, + + + update_time=#{updateTime}, + + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_sys_tax_rate_base + SET delete_type=1 + WHERE id = #{id} + AND delete_type = 0 + + + + + + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/SysTaxRateDetailMapper.java b/src/com/engine/salary/mapper/SysTaxRateDetailMapper.java new file mode 100644 index 000000000..62df84702 --- /dev/null +++ b/src/com/engine/salary/mapper/SysTaxRateDetailMapper.java @@ -0,0 +1,19 @@ +package com.engine.salary.mapper; + +import com.engine.salary.entity.taxrate.SysTaxRateDetailPO; + +import java.util.List; + + +public interface SysTaxRateDetailMapper { + + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listByBaseId(Long baseId); + + + +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/SysTaxRateDetailMapper.xml b/src/com/engine/salary/mapper/SysTaxRateDetailMapper.xml new file mode 100644 index 000000000..a9b89a563 --- /dev/null +++ b/src/com/engine/salary/mapper/SysTaxRateDetailMapper.xml @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + t + . + id + , t.base_id + , t.index_num + , t.income_lower_limit + , t.income_upper_limit + , t.duty_free_value + , t.duty_free_rate + , t.taxable_income_ll + , t.taxable_income_ul + , t.tax_rate + , t.tax_deduction + , t.create_time + , t.update_time + , t.creator + , t.delete_type + , t.tenant_key + + + + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/TaxRateBaseMapper.java b/src/com/engine/salary/mapper/TaxRateBaseMapper.java new file mode 100644 index 000000000..98c671c20 --- /dev/null +++ b/src/com/engine/salary/mapper/TaxRateBaseMapper.java @@ -0,0 +1,80 @@ +package com.engine.salary.mapper; + +import com.engine.salary.entity.taxrate.TaxRateBase; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; + + +public interface TaxRateBaseMapper { + + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + TaxRateBase getById(Long id); + + /** + * 新增,插入所有字段 + * + * @param taxRateBase 新增的记录 + * @return 返回影响行数 + */ + int insert(TaxRateBase taxRateBase); + + /** + * 新增,忽略null字段 + * + * @param taxRateBase 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(TaxRateBase taxRateBase); + + /** + * 修改,修改所有字段 + * + * @param taxRateBase 修改的记录 + * @return 返回影响行数 + */ + int update(TaxRateBase taxRateBase); + + /** + * 修改,忽略null字段 + * + * @param taxRateBase 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(TaxRateBase taxRateBase); + + /** + * 删除记录 + * + * @param taxRateBase 待删除的记录 + * @return 返回影响行数 + */ + int delete(TaxRateBase taxRateBase); + + + + List selectByIds(@Param("ids") Collection ids); + + /** + * 条件查询 + * @return + */ + List listBySome(@Param("param") TaxRateBase param); + + void deleteByIds(@Param("ids") Collection ids); + +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/TaxRateBaseMapper.xml b/src/com/engine/salary/mapper/TaxRateBaseMapper.xml new file mode 100644 index 000000000..185132237 --- /dev/null +++ b/src/com/engine/salary/mapper/TaxRateBaseMapper.xml @@ -0,0 +1,277 @@ + + + + + + + + + + + + + + + + + + t + . + create_time + , t.creator + , t.delete_type + , t.description + , t.id + , t.name + , t.system_type + , t.tenant_key + , t.update_time + + + + + AND id IN + + #{id} + + + + AND name like CONCAT('%',#{param.name},'%') + + + + + + + + + + + + + INSERT INTO hrsa_tax_rate_base + + create_time, + creator, + delete_type, + description, + id, + name, + system_type, + tenant_key, + update_time, + + + #{createTime}, + #{creator}, + #{deleteType}, + #{description}, + #{id}, + #{name}, + #{systemType}, + #{tenantKey}, + #{updateTime}, + + + + + + select hrsa_tax_rate_base_id.currval from dual + + INSERT INTO hrsa_tax_rate_base + + create_time, + creator, + delete_type, + description, + id, + name, + system_type, + tenant_key, + update_time, + + + #{createTime}, + #{creator}, + #{deleteType}, + #{description}, + #{id}, + #{name}, + #{systemType}, + #{tenantKey}, + #{updateTime}, + + + + + + INSERT INTO hrsa_tax_rate_base + + + + create_time, + + + creator, + + + delete_type, + + + description, + + + id, + + + name, + + + system_type, + + + tenant_key, + + + update_time, + + + + + #{createTime}, + + + #{creator}, + + + #{deleteType}, + + + #{description}, + + + #{id}, + + + #{name}, + + + #{systemType}, + + + #{tenantKey}, + + + #{updateTime}, + + + + + + + UPDATE hrsa_tax_rate_base + + create_time=#{createTime}, + creator=#{creator}, + delete_type=#{deleteType}, + description=#{description}, + name=#{name}, + system_type=#{systemType}, + tenant_key=#{tenantKey}, + update_time=#{updateTime}, + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_tax_rate_base + + + create_time=#{createTime}, + + + creator=#{creator}, + + + delete_type=#{deleteType}, + + + description=#{description}, + + + name=#{name}, + + + system_type=#{systemType}, + + + tenant_key=#{tenantKey}, + + + update_time=#{updateTime}, + + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_tax_rate_base + SET delete_type=1 + WHERE id = #{id} + AND delete_type = 0 + + + + + + + + + UPDATE hrsa_tax_rate_base + SET delete_type = 1 + WHERE delete_type = 0 + AND id IN + + #{id} + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/TaxRateDetailMapper.java b/src/com/engine/salary/mapper/TaxRateDetailMapper.java new file mode 100644 index 000000000..dae45fc2f --- /dev/null +++ b/src/com/engine/salary/mapper/TaxRateDetailMapper.java @@ -0,0 +1,75 @@ +package com.engine.salary.mapper; + +import com.engine.salary.entity.taxrate.TaxRateDetail; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; + + +public interface TaxRateDetailMapper { + + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + TaxRateDetail getById(Long id); + + /** + * 新增,插入所有字段 + * + * @param taxRateDetail 新增的记录 + * @return 返回影响行数 + */ + int insert(TaxRateDetail taxRateDetail); + + /** + * 新增,忽略null字段 + * + * @param taxRateDetail 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(TaxRateDetail taxRateDetail); + + /** + * 修改,修改所有字段 + * + * @param taxRateDetail 修改的记录 + * @return 返回影响行数 + */ + int update(TaxRateDetail taxRateDetail); + + /** + * 修改,忽略null字段 + * + * @param taxRateDetail 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(TaxRateDetail taxRateDetail); + + /** + * 删除记录 + * + * @param taxRateDetail 待删除的记录 + * @return 返回影响行数 + */ + int delete(TaxRateDetail taxRateDetail); + + + void deleteByBatchIds(@Param("baseIds") Collection baseIds); + + List listByBaseId(Long baseId); + + + +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/TaxRateDetailMapper.xml b/src/com/engine/salary/mapper/TaxRateDetailMapper.xml new file mode 100644 index 000000000..5f4bd9d9b --- /dev/null +++ b/src/com/engine/salary/mapper/TaxRateDetailMapper.xml @@ -0,0 +1,471 @@ + + + + + + + + + + + + + + + + + + + + + + + + + t.base_id + , t.create_time + , t.creator + , t.delete_type + , t.duty_free_rate + , t.duty_free_value + , t.id + , t.income_lower_limit + , t.income_upper_limit + , t.index_num + , t.tax_deduction + , t.tax_rate + , t.taxable_income_ll + , t.taxable_income_ul + , t.tenant_key + , t.update_time + + + + + + + + + + + INSERT INTO hrsa_tax_rate_detail + + base_id, + create_time, + creator, + delete_type, + duty_free_rate, + duty_free_value, + id, + income_lower_limit, + income_upper_limit, + index_num, + tax_deduction, + tax_rate, + taxable_income_ll, + taxable_income_ul, + tenant_key, + update_time, + + + #{baseId}, + #{createTime}, + #{creator}, + #{deleteType}, + #{dutyFreeRate}, + #{dutyFreeValue}, + #{id}, + #{incomeLowerLimit}, + #{incomeUpperLimit}, + #{indexNum}, + #{taxDeduction}, + #{taxRate}, + #{taxableIncomeLl}, + #{taxableIncomeUl}, + #{tenantKey}, + #{updateTime}, + + + + + + select hrsa_tax_rate_detail_id.currval from dual + + INSERT INTO hrsa_tax_rate_detail + + base_id, + create_time, + creator, + delete_type, + duty_free_rate, + duty_free_value, + id, + income_lower_limit, + income_upper_limit, + index_num, + tax_deduction, + tax_rate, + taxable_income_ll, + taxable_income_ul, + tenant_key, + update_time, + + + #{baseId}, + #{createTime}, + #{creator}, + #{deleteType}, + #{dutyFreeRate}, + #{dutyFreeValue}, + #{id}, + #{incomeLowerLimit}, + #{incomeUpperLimit}, + #{indexNum}, + #{taxDeduction}, + #{taxRate}, + #{taxableIncomeLl}, + #{taxableIncomeUl}, + #{tenantKey}, + #{updateTime}, + + + + + + INSERT INTO hrsa_tax_rate_detail + + + + base_id, + + + create_time, + + + creator, + + + delete_type, + + + duty_free_rate, + + + duty_free_value, + + + id, + + + income_lower_limit, + + + income_upper_limit, + + + index_num, + + + tax_deduction, + + + tax_rate, + + + taxable_income_ll, + + + taxable_income_ul, + + + tenant_key, + + + update_time, + + + + + #{baseId}, + + + #{createTime}, + + + #{creator}, + + + #{deleteType}, + + + #{dutyFreeRate}, + + + #{dutyFreeValue}, + + + #{id}, + + + #{incomeLowerLimit}, + + + #{incomeUpperLimit}, + + + #{indexNum}, + + + #{taxDeduction}, + + + #{taxRate}, + + + #{taxableIncomeLl}, + + + #{taxableIncomeUl}, + + + #{tenantKey}, + + + #{updateTime}, + + + + + + + select hrsa_tax_rate_detail_id.currval from dual + + INSERT INTO hrsa_tax_rate_detail + + + + base_id, + + + create_time, + + + creator, + + + delete_type, + + + duty_free_rate, + + + duty_free_value, + + + id, + + + income_lower_limit, + + + income_upper_limit, + + + index_num, + + + tax_deduction, + + + tax_rate, + + + taxable_income_ll, + + + taxable_income_ul, + + + tenant_key, + + + update_time, + + + + + #{baseId}, + + + #{createTime}, + + + #{creator}, + + + #{deleteType}, + + + #{dutyFreeRate}, + + + #{dutyFreeValue}, + + + #{id}, + + + #{incomeLowerLimit}, + + + #{incomeUpperLimit}, + + + #{indexNum}, + + + #{taxDeduction}, + + + #{taxRate}, + + + #{taxableIncomeLl}, + + + #{taxableIncomeUl}, + + + #{tenantKey}, + + + #{updateTime}, + + + + + + + + + UPDATE hrsa_tax_rate_detail + + base_id=#{baseId}, + create_time=#{createTime}, + creator=#{creator}, + delete_type=#{deleteType}, + duty_free_rate=#{dutyFreeRate}, + duty_free_value=#{dutyFreeValue}, + income_lower_limit=#{incomeLowerLimit}, + income_upper_limit=#{incomeUpperLimit}, + index_num=#{indexNum}, + tax_deduction=#{taxDeduction}, + tax_rate=#{taxRate}, + taxable_income_ll=#{taxableIncomeLl}, + taxable_income_ul=#{taxableIncomeUl}, + tenant_key=#{tenantKey}, + update_time=#{updateTime}, + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_tax_rate_detail + + + base_id=#{baseId}, + + + create_time=#{createTime}, + + + creator=#{creator}, + + + delete_type=#{deleteType}, + + + duty_free_rate=#{dutyFreeRate}, + + + duty_free_value=#{dutyFreeValue}, + + + income_lower_limit=#{incomeLowerLimit}, + + + income_upper_limit=#{incomeUpperLimit}, + + + index_num=#{indexNum}, + + + tax_deduction=#{taxDeduction}, + + + tax_rate=#{taxRate}, + + + taxable_income_ll=#{taxableIncomeLl}, + + + taxable_income_ul=#{taxableIncomeUl}, + + + tenant_key=#{tenantKey}, + + + update_time=#{updateTime}, + + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_tax_rate_detail + SET delete_type=1 + WHERE id = #{id} + AND delete_type = 0 + + + + UPDATE hrsa_tax_rate_detail + SET delete_type = 1 + WHERE delete_type = 0 + AND base_id IN + + #{baseId} + + + + + + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/archive/SalaryArchiveDimissionMapper.java b/src/com/engine/salary/mapper/archive/SalaryArchiveDimissionMapper.java new file mode 100644 index 000000000..68fb4a171 --- /dev/null +++ b/src/com/engine/salary/mapper/archive/SalaryArchiveDimissionMapper.java @@ -0,0 +1,64 @@ +package com.engine.salary.mapper.archive; + +import com.engine.salary.entity.salaryarchive.po.SalaryArchiveDimissionPO; + +import java.util.List; + +public interface SalaryArchiveDimissionMapper { + + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + /** + * 条件查询 + * + * @return 返回集合,没有返回空List + */ + List listSome(SalaryArchiveDimissionPO salaryArchiveDimission); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + SalaryArchiveDimissionPO getById(Long id); + + /** + * 新增,忽略null字段 + * + * @param salaryArchiveDimission 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(SalaryArchiveDimissionPO salaryArchiveDimission); + + /** + * 修改,修改所有字段 + * + * @param salaryArchiveDimission 修改的记录 + * @return 返回影响行数 + */ + int update(SalaryArchiveDimissionPO salaryArchiveDimission); + + /** + * 修改,忽略null字段 + * + * @param salaryArchiveDimission 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(SalaryArchiveDimissionPO salaryArchiveDimission); + + /** + * 删除记录 + * + * @param salaryArchiveDimission 待删除的记录 + * @return 返回影响行数 + */ + int delete(SalaryArchiveDimissionPO salaryArchiveDimission); + +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/archive/SalaryArchiveDimissionMapper.xml b/src/com/engine/salary/mapper/archive/SalaryArchiveDimissionMapper.xml new file mode 100644 index 000000000..7fd7908be --- /dev/null +++ b/src/com/engine/salary/mapper/archive/SalaryArchiveDimissionMapper.xml @@ -0,0 +1,241 @@ + + + + + + + + + + + + + + + + t + . + id + , t.dimission_time_interval + , t.create_time + , t.update_time + , t.creator + , t.delete_type + , t.tenant_key + + + + + + + + + + + + + + + INSERT INTO hrsa_salary_archive_dimission + + + + id, + + + dimission_time_interval, + + + create_time, + + + update_time, + + + creator, + + + delete_type, + + + tenant_key, + + + + + #{id}, + + + #{dimissionTimeInterval}, + + + #{createTime}, + + + #{updateTime}, + + + #{creator}, + + + #{deleteType}, + + + #{tenantKey}, + + + + + + + select hrsa_salary_archive_dimission_id.currval from dual + + INSERT INTO hrsa_salary_archive_dimission + + + + id, + + + dimission_time_interval, + + + create_time, + + + update_time, + + + creator, + + + delete_type, + + + tenant_key, + + + + + #{id}, + + + #{dimissionTimeInterval}, + + + #{createTime}, + + + #{updateTime}, + + + #{creator}, + + + #{deleteType}, + + + #{tenantKey}, + + + + + + + UPDATE hrsa_salary_archive_dimission + + dimission_time_interval=#{dimissionTimeInterval}, + create_time=#{createTime}, + update_time=#{updateTime}, + creator=#{creator}, + delete_type=#{deleteType}, + tenant_key=#{tenantKey}, + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_salary_archive_dimission + + + dimission_time_interval=#{dimissionTimeInterval}, + + + create_time=#{createTime}, + + + update_time=#{updateTime}, + + + creator=#{creator}, + + + delete_type=#{deleteType}, + + + tenant_key=#{tenantKey}, + + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_salary_archive_dimission + SET delete_type=1 + WHERE id = #{id} + AND delete_type = 0 + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/archive/SalaryArchiveItemMapper.java b/src/com/engine/salary/mapper/archive/SalaryArchiveItemMapper.java new file mode 100644 index 000000000..f3105e794 --- /dev/null +++ b/src/com/engine/salary/mapper/archive/SalaryArchiveItemMapper.java @@ -0,0 +1,102 @@ +package com.engine.salary.mapper.archive; + +import com.engine.salary.common.LocalDateRange; +import com.engine.salary.entity.salaryarchive.dto.SalaryItemAdjustRecordListDTO; +import com.engine.salary.entity.salaryarchive.param.SalaryArchiveItemQueryParam; +import com.engine.salary.entity.salaryarchive.param.SalaryItemAdjustRecordQueryParam; +import com.engine.salary.entity.salaryarchive.po.SalaryArchiveItemPO; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +public interface SalaryArchiveItemMapper { + + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + /** + * 条件查询 + * + * @return 返回集合,没有返回空List + */ + List listSome(SalaryArchiveItemPO salaryArchiveItem); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + SalaryArchiveItemPO getById(Long id); + + /** + * 新增,忽略null字段 + * + * @param salaryArchiveItem 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(SalaryArchiveItemPO salaryArchiveItem); + + /** + * 修改,修改所有字段 + * + * @param salaryArchiveItem 修改的记录 + * @return 返回影响行数 + */ + int update(SalaryArchiveItemPO salaryArchiveItem); + + /** + * 修改,忽略null字段 + * + * @param salaryArchiveItem 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(SalaryArchiveItemPO salaryArchiveItem); + + /** + * 删除记录 + * + * @param salaryArchiveItem 待删除的记录 + * @return 返回影响行数 + */ + int delete(SalaryArchiveItemPO salaryArchiveItem); + + + + /** + * 批量插入 + * @param salaryArchiveItemSaves + */ + void batchInsert(@Param("collection") List salaryArchiveItemSaves); + + /** + * 查询薪资项目调整记录列表 + * @param param + * @param salaryItemIds + * @return + */ + List salaryItemAdjustRecordList(@Param("param") SalaryItemAdjustRecordQueryParam param, @Param("salaryItemIds") List salaryItemIds); + + + List listByParam(@Param("param")SalaryArchiveItemQueryParam build); + + List getIneffectiveSalaryItems(@Param("param") SalaryArchiveItemQueryParam build); + + List getEffectiveSalaryItems(@Param("param") SalaryArchiveItemQueryParam build); + + void deleteBatchIds(@Param("effectiveSalaryItemDels") List effectiveSalaryItemDels); + + + void deleteBySalaryArchiveId(@Param("salaryArchiveIds") List salaryArchiveIds); + + void batchDeleteHistoryData(SalaryArchiveItemPO build); + + int batchUpdate(@Param("collection") List pos); + + List listByArchiveIdAndEffectiveTime(@Param("salaryArchivesIds")List salaryArchiveIds, @Param("effectiveRange")LocalDateRange dateRange); +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/archive/SalaryArchiveItemMapper.xml b/src/com/engine/salary/mapper/archive/SalaryArchiveItemMapper.xml new file mode 100644 index 000000000..d0830bad3 --- /dev/null +++ b/src/com/engine/salary/mapper/archive/SalaryArchiveItemMapper.xml @@ -0,0 +1,1219 @@ + + + + + + + + + + + + + + + + + + + + + + + + t + . + id + , t.salary_archive_id + , t.employee_id + , t.effective_time + , t.adjust_reason + , t.salary_item_id + , t.item_value + , t.description + , t.operator + , t.operate_time + , t.create_time + , t.update_time + , t.creator + , t.delete_type + , t.tenant_key + + + + + + + + + + + + + + + INSERT INTO hrsa_salary_archive_item + + + + id, + + + salary_archive_id, + + + employee_id, + + + effective_time, + + + adjust_reason, + + + salary_item_id, + + + item_value, + + + description, + + + operator, + + + operate_time, + + + create_time, + + + update_time, + + + creator, + + + delete_type, + + + tenant_key, + + + + + #{id}, + + + #{salaryArchiveId}, + + + #{employeeId}, + + + #{effectiveTime}, + + + #{adjustReason}, + + + #{salaryItemId}, + + + #{itemValue}, + + + #{description}, + + + #{operator}, + + + #{operateTime}, + + + #{createTime}, + + + #{updateTime}, + + + #{creator}, + + + #{deleteType}, + + + #{tenantKey}, + + + + + + + select hrsa_salary_archive_item_id.currval from dual + + INSERT INTO hrsa_salary_archive_item + + + + id, + + + salary_archive_id, + + + employee_id, + + + effective_time, + + + adjust_reason, + + + salary_item_id, + + + item_value, + + + description, + + + operator, + + + operate_time, + + + create_time, + + + update_time, + + + creator, + + + delete_type, + + + tenant_key, + + + + + #{id}, + + + #{salaryArchiveId}, + + + #{employeeId}, + + + #{effectiveTime}, + + + #{adjustReason}, + + + #{salaryItemId}, + + + #{itemValue}, + + + #{description}, + + + #{operator}, + + + #{operateTime}, + + + #{createTime}, + + + #{updateTime}, + + + #{creator}, + + + #{deleteType}, + + + #{tenantKey}, + + + + + + + UPDATE hrsa_salary_archive_item + + salary_archive_id=#{salaryArchiveId}, + employee_id=#{employeeId}, + effective_time=#{effectiveTime}, + adjust_reason=#{adjustReason}, + salary_item_id=#{salaryItemId}, + item_value=#{itemValue}, + description=#{description}, + operator=#{operator}, + operate_time=#{operateTime}, + create_time=#{createTime}, + update_time=#{updateTime}, + creator=#{creator}, + delete_type=#{deleteType}, + tenant_key=#{tenantKey}, + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_salary_archive_item + + + salary_archive_id=#{salaryArchiveId}, + + + employee_id=#{employeeId}, + + + effective_time=#{effectiveTime}, + + + adjust_reason=#{adjustReason}, + + + salary_item_id=#{salaryItemId}, + + + item_value=#{itemValue}, + + + description=#{description}, + + + operator=#{operator}, + + + operate_time=#{operateTime}, + + + create_time=#{createTime}, + + + update_time=#{updateTime}, + + + creator=#{creator}, + + + delete_type=#{deleteType}, + + + tenant_key=#{tenantKey}, + + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_salary_archive_item + SET delete_type=1 + WHERE id = #{id} + AND delete_type = 0 + + + + + INSERT INTO hrsa_salary_archive_item ( + salary_archive_id, + employee_id, + effective_time, + adjust_reason, + salary_item_id, + item_value, + description, + operator, + operate_time, + create_time, + update_time, + creator, + tenant_key + ) + VALUES + + ( + #{item.salaryArchiveId}, + #{item.employeeId}, + #{item.effectiveTime}, + #{item.adjustReason}, + #{item.salaryItemId}, + #{item.itemValue}, + #{item.description}, + #{item.operator}, + #{item.operateTime}, + #{item.createTime}, + #{item.updateTime}, + #{item.creator}, + #{item.tenantKey} + ) + + + + INSERT INTO hrsa_salary_archive_item ( + salary_archive_id, + employee_id, + effective_time, + adjust_reason, + salary_item_id, + item_value, + description, + operator, + operate_time, + create_time, + update_time, + creator, + tenant_key + ) + + + select + #{item.salaryArchiveId,jdbcType=DOUBLE}, + #{item.employeeId,jdbcType=DOUBLE}, + #{item.effectiveTime,jdbcType=DATE}, + #{item.adjustReason,jdbcType=VARCHAR}, + #{item.salaryItemId,jdbcType=DOUBLE}, + #{item.itemValue,jdbcType=VARCHAR}, + #{item.description,jdbcType=VARCHAR}, + #{item.operator,jdbcType=DOUBLE}, + #{item.operateTime,jdbcType=DATE}, + #{item.createTime,jdbcType=DATE}, + #{item.updateTime,jdbcType=DATE}, + #{item.creator,jdbcType=DOUBLE}, + #{item.tenantKey,jdbcType=VARCHAR} + from dual + + + + + INSERT INTO hrsa_salary_archive_item ( + salary_archive_id, + employee_id, + effective_time, + adjust_reason, + salary_item_id, + item_value, + description, + operator, + operate_time, + create_time, + update_time, + creator, + tenant_key + ) + VALUES + ( + #{item.salaryArchiveId}, + #{item.employeeId}, + #{item.effectiveTime}, + #{item.adjustReason}, + #{item.salaryItemId}, + #{item.itemValue}, + #{item.description}, + #{item.operator}, + #{item.operateTime}, + #{item.createTime}, + #{item.updateTime}, + #{item.creator}, + #{item.tenantKey} + ) + + + + + id, + salary_archive_id, + employee_id, + effective_time, + adjust_reason, + salary_item_id, + item_value, + description, + operator, + operate_time, + create_time, + update_time, + creator, + tenant_key + + + + + + + + + t1.id, + t1.employee_id, + t1.effective_time, + t1.adjust_reason, + t2.name AS adjust_item, + t1.item_value AS adjust_after, + o.lastname AS operator, + t1.operate_time, + t1.description, + t1.salary_archive_id, + t1.salary_item_id + + + + + AND t1.id IN + + #{id} + + + + + AND t1.employee_id = #{param.employeeId} + + + + AND t1.salary_archive_id = #{param.salaryArchiveId} + + + + AND e.lastname like CONCAT('%',#{param.username},'%') + + + + AND e.jobtitle IN + + #{id} + + + + + AND e.status = #{param.userstatus} + + + + AND d.id IN + + #{id} + + + + + AND t1.adjust_reason = #{param.adjustReason} + + + + AND (t1.effective_time BETWEEN #{param.effectiveTime[0]} AND #{param.effectiveTime[1]}) + + + + AND (t1.operate_time BETWEEN CONCAT(#{param.operateTime[0]},' 00:00:00') AND + CONCAT(#{param.operateTime[1]},' 23:59:59')) + + + + AND t1.operator IN + + #{id} + + + + + AND t1.description like CONCAT('%',#{param.description},'%') + + + + + AND t1.id IN + + #{id} + + + + + AND t1.employee_id = #{param.employeeId} + + + + AND t1.salary_archive_id = #{param.salaryArchiveId} + + + + AND e.lastname like '%'||#{param.username}||'%' + + + + AND e.jobtitle IN + + #{id} + + + + + AND e.status = #{param.userstatus} + + + + AND d.id IN + + #{id} + + + + + AND t1.adjust_reason = #{param.adjustReason} + + + + AND (t1.effective_time BETWEEN #{param.effectiveTime[0]} AND #{param.effectiveTime[1]}) + + + + AND (t1.operate_time BETWEEN #{param.operateTime[0]}||' 00:00:00' AND #{param.operateTime[1]}||' 23:59:59' ) + + + + AND t1.operator IN + + #{id} + + + + + AND t1.description like '%'||#{param.description}||'%' + + + + + AND t1.id IN + + #{id} + + + + + AND t1.employee_id = #{param.employeeId} + + + + AND t1.salary_archive_id = #{param.salaryArchiveId} + + + + AND e.lastname like '%'+#{param.username}+'%' + + + + AND e.jobtitle IN + + #{id} + + + + + AND e.status = #{param.userstatus} + + + + AND d.id IN + + #{id} + + + + + AND t1.adjust_reason = #{param.adjustReason} + + + + AND (t1.effective_time BETWEEN #{param.effectiveTime[0]} AND #{param.effectiveTime[1]}) + + + + AND (t1.operate_time BETWEEN #{param.operateTime[0]}+' 00:00:00' AND #{param.operateTime[1]}+' 23:59:59' ) + + + + AND t1.operator IN + + #{id} + + + + + AND t1.description like '%'+#{param.description}+'%' + + + + + + + + + + + + + + + + UPDATE hrsa_salary_archive_item + SET delete_type = 1 + WHERE delete_type = 0 + AND (id IN + + + + + + ) OR id IN ( + , + + + #{Id} + + + ) + + + + + UPDATE hrsa_salary_archive_item + SET delete_type = 1 + WHERE delete_type = 0 + AND salary_archive_id IN + + #{salaryArchiveId} + + + + + UPDATE hrsa_salary_archive_item + SET delete_type = 1 + WHERE delete_type = 0 + AND id IN + + #{id} + + + + + update hrsa_salary_archive_item + + + + + when id=#{item.id} then #{item.deleteType} + + + + + + + when id=#{item.id} then #{item.itemValue} + + + + + where + id in + + #{item.id} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + item.id as item_id + ,item.name as item_name + , item.code as item_code + , item.system_type as item_system_type + , item.sys_salary_item_id as item_sys_salary_item_id + , item.use_default as item_use_default + , item.use_in_employee_salary as item_use_in_employee_salary + , item.rounding_mode as item_rounding_mode + , item.pattern as item_pattern + , item.value_type as item_value_type + , item.formula_id as item_formula_id + , item.description as item_description + , item.can_edit as item_can_edit + , item.can_delete as item_can_delete + , item.data_type as item_data_type + , item.shared_type as item_shared_type + , item.tax_agent_ids as item_tax_agent_ids + , item.sorted_index as item_sorted_index + , item.hide_default as item_hide_default + , item.width as item_width + , item.default_value as item_default_value + + + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/archive/SalaryArchiveMapper.java b/src/com/engine/salary/mapper/archive/SalaryArchiveMapper.java new file mode 100644 index 000000000..a11f48491 --- /dev/null +++ b/src/com/engine/salary/mapper/archive/SalaryArchiveMapper.java @@ -0,0 +1,146 @@ +package com.engine.salary.mapper.archive; + +import com.engine.salary.entity.salaryarchive.dto.SalaryArchiveListDTO; +import com.engine.salary.entity.salaryarchive.param.SalaryArchiveQueryParam; +import com.engine.salary.entity.salaryarchive.po.SalaryArchivePO; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.Date; +import java.util.List; + +public interface SalaryArchiveMapper { + + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + /** + * 修改,修改所有字段 + * + * @param salaryArchive 修改的记录 + * @return 返回影响行数 + */ + int update(SalaryArchivePO salaryArchive); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + SalaryArchivePO getById(Long id); + + /** + * 删除记录 + * + * @param salaryArchive 待删除的记录 + * @return 返回影响行数 + */ + int delete(SalaryArchivePO salaryArchive); + + + /** + * 查询薪资档案列表 + * + * @param param + * @return + */ + List list(@Param("param") SalaryArchiveQueryParam param); + + /** + * 外部人员 + * @param queryParam + * @return + */ + List listExtSalaryArchive(@Param("param")SalaryArchiveQueryParam queryParam); + + + /** + * 批量插入 + * + * @param salaryArchiveSaves + */ + void batchInsert(@Param("collection") List salaryArchiveSaves); + + /** + * 批量更新 + * + * @param salaryArchiveUpdates + */ + void batchUpdate(@Param("collection") List salaryArchiveUpdates); + + /** + * 获取历史数据 + * + * @return + */ + List getHistoryData(); + + /** + * 删除历史数据 + * + * @param build + * @return + */ + void batchDeleteHistoryData(SalaryArchivePO build); + + /** + * 条件查询 + * + * @param param + * @return + */ + List listSome(@Param("param") SalaryArchivePO param); + + + /** + * 获取人员状态为空的数据 + * + * @return + */ + List getStatusIsNullData(); + + /** + * 更新状态 + * + * @param build + */ + void updateStatus(SalaryArchivePO build); + + + void updateRunStatusByIdsAndPayEndDate(SalaryArchivePO po); + + void updateFixed(SalaryArchivePO build); + + void updateSuspend(SalaryArchivePO build); + + void gotoFixed(@Param("ids") Collection ids); + + void gotoStop(@Param("ids") Collection ids); + + void gotoPendingFromStop(@Param("ids") Collection ids); + + void gotoFixedFromStop(@Param("ids") Collection ids); + + void deletePendingTodo(@Param("ids") Collection ids); + + void deleteSuspendTodo(@Param("ids") Collection ids); + + void deleteByIds(@Param("ids")Collection deleteIds); + + List listPayEndDateIsNull(@Param("ids")List employeeIds); + + List listPayStartDateIsNull(@Param("runStatus")String runStatus); + + /** + * 更新起始发薪日期 + * @param salaryArchiveId + * @param date + */ + void updatePayStartDateById(@Param("id")Long salaryArchiveId, @Param("payStartDate")Date date); +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/archive/SalaryArchiveMapper.xml b/src/com/engine/salary/mapper/archive/SalaryArchiveMapper.xml new file mode 100644 index 000000000..17229b2e9 --- /dev/null +++ b/src/com/engine/salary/mapper/archive/SalaryArchiveMapper.xml @@ -0,0 +1,883 @@ + + + + + + + + + + + + + + + + + + + + + t + . + id + , t.employee_id + , t.create_time + , t.update_time + , t.creator + , t.delete_type + , t.tenant_key + , t.tax_agent_id + , t.pay_start_date + , t.pay_end_date + , t.run_status + , t.employee_type + + + + + + + UPDATE hrsa_salary_archive + + employee_id=#{employeeId}, + create_time=#{createTime}, + update_time=#{updateTime}, + creator=#{creator}, + delete_type=#{deleteType}, + tenant_key=#{tenantKey}, + tax_agent_id=#{taxAgentId}, + pay_start_date=#{payStartDate}, + pay_end_date=#{payEndDate}, + run_status=#{runStatus}, + employee_type=#{employeeType}, + + WHERE id = #{id} + + + + + + + + UPDATE hrsa_salary_archive + SET delete_type=1 + WHERE id = #{id} + AND delete_type = 0 + + + + + t + . + id + , t.employee_id + , t.create_time + , t.update_time + , t.creator + , t.delete_type + , t.tenant_key + , t.tax_agent_id + , t.pay_start_date + , t.pay_end_date + , t.run_status + , t.employee_type + , e.mobile + , e.workcode + , e.certificatenum as idNo + , e.lastname as username + , e.status AS employeeStatus + , e.companystartdate as companystartdate + , e.enddate as dismissdate + , e.status AS employeeStatus + ,e.certificatenum as idNo + ,e.accounttype as accountType + , d.departmentname AS departmentName + , c.subcompanyname AS subcompanyName + + + + + + + + + + + + + INSERT INTO hrsa_salary_archive ( + id, + employee_id, + create_time, + update_time, + creator, + tenant_key, + tax_agent_id, + pay_start_date, + pay_end_date, + run_status, + employee_type + ) + VALUES + + ( + #{item.id}, + #{item.employeeId}, + #{item.createTime}, + #{item.updateTime}, + #{item.creator}, + #{item.tenantKey}, + #{item.taxAgentId}, + #{item.payStartDate}, + #{item.payEndDate}, + #{item.runStatus}, + #{item.employeeType} + ) + + + + INSERT INTO hrsa_salary_archive ( + id, + employee_id, + create_time, + update_time, + creator, + tenant_key, + tax_agent_id, + pay_start_date, + pay_end_date, + run_status, + employee_type + ) + + + select + #{item.id,jdbcType=DOUBLE}, + #{item.employeeId,jdbcType=DOUBLE}, + #{item.createTime,jdbcType=DATE}, + #{item.updateTime,jdbcType=DATE}, + #{item.creator,jdbcType=DOUBLE}, + #{item.tenantKey,jdbcType=VARCHAR}, + #{item.taxAgentId,jdbcType=DOUBLE}, + #{item.payStartDate,jdbcType=DATE}, + #{item.payEndDate,jdbcType=DATE}, + #{item.runStatus,jdbcType=VARCHAR}, + #{item.employeeType,jdbcType=INTEGER} + from dual + + + + + INSERT INTO hrsa_salary_archive ( + id, + employee_id, + create_time, + update_time, + creator, + tenant_key, + tax_agent_id, + pay_start_date, + pay_end_date, + run_status, + employee_type + ) + VALUES + ( + #{item.id}, + #{item.employeeId}, + #{item.createTime}, + #{item.updateTime}, + #{item.creator}, + #{item.tenantKey}, + #{item.taxAgentId}, + #{item.payStartDate}, + #{item.payEndDate}, + #{item.runStatus}, + #{item.employeeType} + ) + + + + + update hrsa_salary_archive + + + + + when id=#{item.id} then #{item.runStatus} + + + + + + + when id=#{item.id} then #{item.payStartDate} + + + + + + + when id=#{item.id} then #{item.payEndDate} + + + + + + + when id=#{item.id} then #{item.updateTime} + + + + + where + id in + + #{item.id} + + + + + + UPDATE hrsa_salary_archive + + + run_status=#{item.runStatus}, + + + pay_start_date=#{item.payStartDate}, + + + pay_end_date=#{item.payEndDate}, + + + WHERE id = #{item.id} AND delete_type = 0 + + + + + + + + + UPDATE hrsa_salary_archive + SET delete_type=1 + WHERE delete_type = 0 + and tax_agent_id is null + AND id IN + + #{id} + + + + + UPDATE hrsa_salary_archive + SET delete_type=1 + WHERE delete_type = 0 + AND id IN + + #{id} + + + + + + + + + + + + + UPDATE hrsa_salary_archive + + run_status=#{runStatus} + + WHERE id IN + + #{id} + + + + + UPDATE hrsa_salary_archive + + run_status=#{runStatus} + + WHERE id IN + + #{id} + + and pay_end_date is null + + + + UPDATE hrsa_salary_archive + + run_status='FIXED' + + WHERE run_status = 'SUSPEND' and pay_end_date is not null and pay_end_date ]]> #{payEndDate} + + + + UPDATE hrsa_salary_archive + + run_status='SUSPEND' + + WHERE run_status = 'FIXED' and pay_end_date is not null and pay_end_date #{payEndDate} + + + + UPDATE hrsa_salary_archive + + run_status='FIXED' + + WHERE run_status = 'PENDING' and pay_start_date is not null + and id IN + + #{id} + + + + + UPDATE hrsa_salary_archive + + run_status='STOP_FROM_SUSPEND' + + WHERE run_status = 'SUSPEND' and pay_end_date is not null + and id IN + + #{id} + + + + + UPDATE hrsa_salary_archive + + run_status='PENDING' + + WHERE run_status = 'STOP_FROM_PENDING' + and id IN + + #{id} + + + + + UPDATE hrsa_salary_archive + + run_status='FIXED' + + WHERE run_status = 'STOP_FROM_SUSPEND' + and id IN + + #{id} + + + + + UPDATE hrsa_salary_archive + + run_status='STOP_FROM_PENDING' + + WHERE run_status = 'PENDING' + and id IN + + #{id} + + + + + UPDATE hrsa_salary_archive + + run_status='FIXED', + pay_end_date= null + + WHERE id IN + + #{id} + + + + UPDATE hrsa_salary_archive + + pay_start_date= #{payStartDate} + + WHERE id = #{id} + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/archive/SalaryArchiveTaxAgentMapper.java b/src/com/engine/salary/mapper/archive/SalaryArchiveTaxAgentMapper.java new file mode 100644 index 000000000..0fdef3a71 --- /dev/null +++ b/src/com/engine/salary/mapper/archive/SalaryArchiveTaxAgentMapper.java @@ -0,0 +1,98 @@ +package com.engine.salary.mapper.archive; + +import com.engine.salary.entity.salaryarchive.dto.TaxAgentAdjustRecordListDTO; +import com.engine.salary.entity.salaryarchive.param.SalaryArchiveTaxAgentQueryParam; +import com.engine.salary.entity.salaryarchive.param.TaxAgentAdjustRecordQueryParam; +import com.engine.salary.entity.salaryarchive.po.SalaryArchiveTaxAgentPO; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +public interface SalaryArchiveTaxAgentMapper { + + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + /** + * 条件查询 + * + * @return 返回集合,没有返回空List + */ + List listSome(SalaryArchiveTaxAgentPO salaryArchiveTaxAgent); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + SalaryArchiveTaxAgentPO getById(Long id); + + /** + * 新增,忽略null字段 + * + * @param salaryArchiveTaxAgent 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(SalaryArchiveTaxAgentPO salaryArchiveTaxAgent); + + /** + * 修改,修改所有字段 + * + * @param salaryArchiveTaxAgent 修改的记录 + * @return 返回影响行数 + */ + int update(SalaryArchiveTaxAgentPO salaryArchiveTaxAgent); + + /** + * 修改,忽略null字段 + * + * @param salaryArchiveTaxAgent 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(SalaryArchiveTaxAgentPO salaryArchiveTaxAgent); + + /** + * 删除记录 + * + * @param salaryArchiveTaxAgent 待删除的记录 + * @return 返回影响行数 + */ + int delete(SalaryArchiveTaxAgentPO salaryArchiveTaxAgent); + + List listByParam(@Param("param") SalaryArchiveTaxAgentQueryParam build); + + void deleteBySalaryArchiveId(@Param("collection") List salaryArchiveIds); + + List getEffectiveTaxAgentList(SalaryArchiveTaxAgentQueryParam build); + + List getIneffectiveTaxAgentList(SalaryArchiveTaxAgentQueryParam build); + + void deleteBatchIds(List list); + + /** + * 批量插入 + * + * @param salaryArchiveTaxAgentSaves + */ + void batchInsert(@Param("collection") List salaryArchiveTaxAgentSaves); + + /** + * 查询薪资项目调整记录列表 + * + * @param param + * @return + */ + List taxAgentAdjustRecordList(@Param("param") TaxAgentAdjustRecordQueryParam param); + + List getTaxAgentLtTimeBySalaryArchiveId(SalaryArchiveTaxAgentQueryParam build); + + List getAdjustBeforeTaxAgent(SalaryArchiveTaxAgentPO build); + + void batchDeleteHistoryData(SalaryArchiveTaxAgentPO build); +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/archive/SalaryArchiveTaxAgentMapper.xml b/src/com/engine/salary/mapper/archive/SalaryArchiveTaxAgentMapper.xml new file mode 100644 index 000000000..3639039e2 --- /dev/null +++ b/src/com/engine/salary/mapper/archive/SalaryArchiveTaxAgentMapper.xml @@ -0,0 +1,844 @@ + + + + + + + + + + + + + + + + + + + + + + + t + . + id + , t.salary_archive_id + , t.employee_id + , t.effective_time + , t.adjust_reason + , t.tax_agent_id + , t.operator + , t.operate_time + , t.description + , t.create_time + , t.update_time + , t.creator + , t.delete_type + , t.tenant_key + + + + + + + + + + + + + + + INSERT INTO hrsa_salary_archive_tax_agent + + + + id, + + + salary_archive_id, + + + employee_id, + + + effective_time, + + + adjust_reason, + + + tax_agent_id, + + + operator, + + + operate_time, + + + description, + + + create_time, + + + update_time, + + + creator, + + + delete_type, + + + tenant_key, + + + + + #{id}, + + + #{salaryArchiveId}, + + + #{employeeId}, + + + #{effectiveTime}, + + + #{adjustReason}, + + + #{taxAgentId}, + + + #{operator}, + + + #{operateTime}, + + + #{description}, + + + #{createTime}, + + + #{updateTime}, + + + #{creator}, + + + #{deleteType}, + + + #{tenantKey}, + + + + + + + select hrsa_salary_archive_tax_agent_id.currval from dual + + INSERT INTO hrsa_salary_archive_tax_agent + + + + id, + + + salary_archive_id, + + + employee_id, + + + effective_time, + + + adjust_reason, + + + tax_agent_id, + + + operator, + + + operate_time, + + + description, + + + create_time, + + + update_time, + + + creator, + + + delete_type, + + + tenant_key, + + + + + #{id}, + + + #{salaryArchiveId}, + + + #{employeeId}, + + + #{effectiveTime}, + + + #{adjustReason}, + + + #{taxAgentId}, + + + #{operator}, + + + #{operateTime}, + + + #{description}, + + + #{createTime}, + + + #{updateTime}, + + + #{creator}, + + + #{deleteType}, + + + #{tenantKey}, + + + + + + + UPDATE hrsa_salary_archive_tax_agent + + salary_archive_id=#{salaryArchiveId}, + employee_id=#{employeeId}, + effective_time=#{effectiveTime}, + adjust_reason=#{adjustReason}, + tax_agent_id=#{taxAgentId}, + operator=#{operator}, + operate_time=#{operateTime}, + description=#{description}, + create_time=#{createTime}, + update_time=#{updateTime}, + creator=#{creator}, + delete_type=#{deleteType}, + tenant_key=#{tenantKey}, + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_salary_archive_tax_agent + + + salary_archive_id=#{salaryArchiveId}, + + + employee_id=#{employeeId}, + + + effective_time=#{effectiveTime}, + + + adjust_reason=#{adjustReason}, + + + tax_agent_id=#{taxAgentId}, + + + operator=#{operator}, + + + operate_time=#{operateTime}, + + + description=#{description}, + + + create_time=#{createTime}, + + + update_time=#{updateTime}, + + + creator=#{creator}, + + + delete_type=#{deleteType}, + + + tenant_key=#{tenantKey}, + + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_salary_archive_tax_agent + SET delete_type=1 + WHERE id = #{id} + AND delete_type = 0 + + + + + + + + UPDATE hrsa_salary_archive_tax_agent + SET delete_type = 1 + WHERE delete_type = 0 + AND salary_archive_id IN + + #{salaryArchiveId} + + + + + + + + + UPDATE hrsa_salary_archive_tax_agent + SET delete_type = 1 + WHERE delete_type = 0 + AND id IN + + #{id} + + + + + + salary_archive_id + , + employee_id, + effective_time, + adjust_reason, + tax_agent_id, + operator, + operate_time, + create_time, + update_time, + creator, + tenant_key + + + + + INSERT INTO hrsa_salary_archive_tax_agent ( + + ) + VALUES + + ( + #{item.salaryArchiveId}, + #{item.employeeId}, + #{item.effectiveTime}, + #{item.adjustReason}, + #{item.taxAgentId}, + #{item.operator}, + #{item.operateTime}, + #{item.createTime}, + #{item.updateTime}, + #{item.creator}, + #{item.tenantKey} + ) + + + + INSERT INTO hrsa_salary_archive_tax_agent ( + + ) + + select + #{item.salaryArchiveId,jdbcType=DOUBLE}, + #{item.employeeId,jdbcType=DOUBLE}, + #{item.effectiveTime,jdbcType=DATE}, + #{item.adjustReason,jdbcType=VARCHAR}, + #{item.taxAgentId,jdbcType=DOUBLE}, + #{item.operator,jdbcType=DOUBLE}, + #{item.operateTime,jdbcType=DATE}, + #{item.createTime,jdbcType=DATE}, + #{item.updateTime,jdbcType=DATE}, + #{item.creator,jdbcType=DOUBLE}, + #{item.tenantKey,jdbcType=VARCHAR} + from dual + + + + + INSERT INTO hrsa_salary_archive_tax_agent ( + + ) + VALUES + ( + #{item.salaryArchiveId}, + #{item.employeeId}, + #{item.effectiveTime}, + #{item.adjustReason}, + #{item.taxAgentId}, + #{item.operator}, + #{item.operateTime}, + #{item.createTime}, + #{item.updateTime}, + #{item.creator}, + #{item.tenantKey} + ) + + + + + + + + + t1 + . + id + , + t1.employee_id, + e.lastname as username, + e.status AS employeeStatus, + d.departmentname AS departmentName, + t1.effective_time, + t1.adjust_reason, + t1.tax_agent_id AS adjust_after, + o.lastname AS operator, + t1.operate_time, + t1.description, + t1.salary_archive_id, + t1.tax_agent_id + + + + + AND t1.id IN + + #{id} + + + + + AND t1.salary_archive_id = #{param.salaryArchiveId} + + + + AND e.lastname like CONCAT('%',#{param.username},'%') + + + + AND e.position IN + + #{id} + + + + + AND e.status = #{param.userstatus} + + + + AND d.id IN + + #{id} + + + + + AND t1.adjust_reason = #{param.adjustReason} + + + + AND (t1.effective_time BETWEEN #{param.effectiveTime[0]} AND #{param.effectiveTime[1]}) + + + + AND (t1.operate_time BETWEEN CONCAT(#{param.operateTime[0]},' 00:00:00') AND + CONCAT(#{param.operateTime[1]},' 23:59:59')) + + + + AND t1.operator IN + + #{id} + + + + + AND t1.description like CONCAT('%',#{param.description},'%') + + + + + AND t1.id IN + + #{id} + + + + + AND t1.salary_archive_id = #{param.salaryArchiveId} + + + + AND e.lastname like '%'||#{param.username}||'%' + + + + AND e.position IN + + #{id} + + + + + AND e.status = #{param.userstatus} + + + + AND d.id IN + + #{id} + + + + + AND t1.adjust_reason = #{param.adjustReason} + + + + AND (t1.effective_time BETWEEN #{param.effectiveTime[0]} AND #{param.effectiveTime[1]}) + + + + AND (t1.operate_time BETWEEN #{param.operateTime[0]}||' 00:00:00' AND #{param.operateTime[1]}||' 23:59:59' ) + + + + AND t1.operator IN + + #{id} + + + + + AND t1.description like '%'||#{param.description}||'%' + + + + + AND t1.id IN + + #{id} + + + + + AND t1.salary_archive_id = #{param.salaryArchiveId} + + + + AND e.lastname like '%'+#{param.username}+'%' + + + + AND e.position IN + + #{id} + + + + + AND e.status = #{param.userstatus} + + + + AND d.id IN + + #{id} + + + + + AND t1.adjust_reason = #{param.adjustReason} + + + + AND (t1.effective_time BETWEEN #{param.effectiveTime[0]} AND #{param.effectiveTime[1]}) + + + + AND (t1.operate_time BETWEEN #{param.operateTime[0]}+' 00:00:00' AND #{param.operateTime[1]}+' 23:59:59' ) + + + + AND t1.operator IN + + #{id} + + + + + AND t1.description like '%'+#{param.description}+'%' + + + + + + + + + UPDATE hrsa_salary_archive_tax_agent + SET delete_type = 1 + WHERE delete_type = 0 + AND id IN + + #{id} + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/auth/AuthDataMapper.java b/src/com/engine/salary/mapper/auth/AuthDataMapper.java new file mode 100644 index 000000000..fde50bd66 --- /dev/null +++ b/src/com/engine/salary/mapper/auth/AuthDataMapper.java @@ -0,0 +1,79 @@ +package com.engine.salary.mapper.auth; + +import com.engine.salary.entity.auth.po.AuthDataPO; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; + +public interface AuthDataMapper { + + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + /** + * 条件查询 + * + * @return 返回集合,没有返回空List + */ + List listSome(AuthDataPO authData); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + AuthDataPO getById(Long id); + + /** + * 新增,忽略null字段 + * + * @param authData 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(AuthDataPO authData); + + /** + * 修改,修改所有字段 + * + * @param authData 修改的记录 + * @return 返回影响行数 + */ + int update(AuthDataPO authData); + + /** + * 修改,忽略null字段 + * + * @param authData 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(AuthDataPO authData); + + /** + * 删除记录 + * + * @param authData 待删除的记录 + * @return 返回影响行数 + */ + int delete(AuthDataPO authData); + + /** + * 批量删除记录 + * + * @param ids 主键id集合 + */ + void deleteByIds(@Param("ids") Collection ids); + + + /** + * 根据角色id删除 + * @param roleId roleId + */ + void deleteByRoleId(Long roleId); +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/auth/AuthDataMapper.xml b/src/com/engine/salary/mapper/auth/AuthDataMapper.xml new file mode 100644 index 000000000..b63821cba --- /dev/null +++ b/src/com/engine/salary/mapper/auth/AuthDataMapper.xml @@ -0,0 +1,276 @@ + + + + + + + + + + + + + + + + + + + + + t + . + id + , t.role_id + , t.link + , t.target_type + , t.target + , t.target_name + , t.sorted_index + , t.creator + , t.create_time + , t.update_time + , t.delete_type + , t.tenant_key + + + + + + + + + + + + + + + INSERT INTO hrsa_auth_data + + + + id, + + + role_id, + + + link, + + + target_type, + + + target, + + + target_name, + + + sorted_index, + + + creator, + + + create_time, + + + update_time, + + + delete_type, + + + tenant_key, + + + + + #{id}, + + + #{roleId}, + + + #{link}, + + + #{targetType}, + + + #{target}, + + + #{targetName}, + + + #{sortedIndex}, + + + #{creator}, + + + #{createTime}, + + + #{updateTime}, + + + #{deleteType}, + + + #{tenantKey}, + + + + + + + UPDATE hrsa_auth_data + + role_id=#{roleId}, + link=#{link}, + target_type=#{targetType}, + target=#{target}, + target_name=#{targetName}, + sorted_index=#{sortedIndex}, + creator=#{creator}, + create_time=#{createTime}, + update_time=#{updateTime}, + delete_type=#{deleteType}, + tenant_key=#{tenantKey}, + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_auth_data + + + role_id=#{roleId}, + + + link=#{link}, + + + target_type=#{targetType}, + + + target=#{target}, + + + target_name=#{targetName}, + + + sorted_index=#{sortedIndex}, + + + creator=#{creator}, + + + create_time=#{createTime}, + + + update_time=#{updateTime}, + + + delete_type=#{deleteType}, + + + tenant_key=#{tenantKey}, + + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_auth_data + SET delete_type=1 + WHERE id = #{id} + AND delete_type = 0 + + + + UPDATE hrsa_auth_data + SET delete_type = 1 + WHERE delete_type = 0 + AND id IN + + #{id} + + + + + UPDATE hrsa_auth_data + SET delete_type = 1 + WHERE delete_type = 0 + AND role_id=#{roleId} + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/auth/AuthMapper.java b/src/com/engine/salary/mapper/auth/AuthMapper.java new file mode 100644 index 000000000..70533cafa --- /dev/null +++ b/src/com/engine/salary/mapper/auth/AuthMapper.java @@ -0,0 +1,27 @@ +package com.engine.salary.mapper.auth; + +import com.engine.salary.entity.auth.dto.AuthTreeDTO; +import com.engine.salary.entity.auth.dto.SobOptAuth; +import com.engine.salary.entity.auth.dto.TaxEmpOptAuth; +import com.engine.salary.entity.auth.dto.TaxOptAuth; +import com.engine.salary.entity.auth.param.AuthTreeQueryParam; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +public interface AuthMapper { + + List getTaxEmpOptAuth(@Param("uid") Long uid, @Param("page") String page); + + List getTaxOptAuth(@Param("uid") Long uid, @Param("page") String page); + + List getSobOptAuth(@Param("uid") Long uid, @Param("page") String page); + + List getLimitSobs(@Param("uid") Long uid); + + List getLimitTaxAgents(@Param("uid") Long uid); + + List getOptsByPage(@Param("uid") Long uid, @Param("page") String page); + + AuthTreeDTO authTree(AuthTreeQueryParam param); +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/auth/AuthMapper.xml b/src/com/engine/salary/mapper/auth/AuthMapper.xml new file mode 100644 index 000000000..f1ce490b1 --- /dev/null +++ b/src/com/engine/salary/mapper/auth/AuthMapper.xml @@ -0,0 +1,168 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/auth/AuthMemberMapper.java b/src/com/engine/salary/mapper/auth/AuthMemberMapper.java new file mode 100644 index 000000000..a5cabd93f --- /dev/null +++ b/src/com/engine/salary/mapper/auth/AuthMemberMapper.java @@ -0,0 +1,78 @@ +package com.engine.salary.mapper.auth; + +import com.engine.salary.entity.auth.po.AuthMemberPO; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; + +public interface AuthMemberMapper { + + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + /** + * 条件查询 + * + * @return 返回集合,没有返回空List + */ + List listSome(AuthMemberPO authMember); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + AuthMemberPO getById(Long id); + + /** + * 新增,忽略null字段 + * + * @param authMember 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(AuthMemberPO authMember); + + /** + * 修改,修改所有字段 + * + * @param authMember 修改的记录 + * @return 返回影响行数 + */ + int update(AuthMemberPO authMember); + + /** + * 修改,忽略null字段 + * + * @param authMember 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(AuthMemberPO authMember); + + /** + * 删除记录 + * + * @param authMember 待删除的记录 + * @return 返回影响行数 + */ + int delete(AuthMemberPO authMember); + + /** + * 批量删除记录 + * @param ids 主键id集合 + */ + void deleteByIds(@Param("ids") Collection ids); + + /** + * 根据角色id删除 + * @param roleId roleId + */ + void deleteByRoleId(Long roleId); + +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/auth/AuthMemberMapper.xml b/src/com/engine/salary/mapper/auth/AuthMemberMapper.xml new file mode 100644 index 000000000..8bde81000 --- /dev/null +++ b/src/com/engine/salary/mapper/auth/AuthMemberMapper.xml @@ -0,0 +1,241 @@ + + + + + + + + + + + + + + + + + + + t.id + , t.role_id + , t.target_type + , t.target + , t.target_name + , t.creator + , t.create_time + , t.update_time + , t.delete_type + , t.tenant_key + + + + + + + + + + + + + + + INSERT INTO hrsa_auth_member + + + + id, + + + role_id, + + + target_type, + + + target, + + + target_name, + + + creator, + + + create_time, + + + update_time, + + + delete_type, + + + tenant_key, + + + + + #{id}, + + + #{roleId}, + + + #{targetType}, + + + #{target}, + + + #{targetName}, + + + #{creator}, + + + #{createTime}, + + + #{updateTime}, + + + #{deleteType}, + + + #{tenantKey}, + + + + + + + UPDATE hrsa_auth_member + + role_id=#{roleId}, + target_type=#{targetType}, + target=#{target}, + target_name=#{targetName}, + creator=#{creator}, + create_time=#{createTime}, + update_time=#{updateTime}, + delete_type=#{deleteType}, + tenant_key=#{tenantKey}, + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_auth_member + + + role_id=#{roleId}, + + + target_type=#{targetType}, + + + target=#{target}, + + + target_name=#{targetName}, + + + creator=#{creator}, + + + create_time=#{createTime}, + + + update_time=#{updateTime}, + + + delete_type=#{deleteType}, + + + tenant_key=#{tenantKey}, + + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_auth_member + SET delete_type=1 + WHERE id = #{id} AND delete_type = 0 + + + + UPDATE hrsa_auth_member + SET delete_type = 1 + WHERE delete_type = 0 + AND id IN + + #{id} + + + + + + UPDATE hrsa_auth_member + SET delete_type=1 + WHERE role_id = #{roleId} AND delete_type = 0 + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/auth/AuthOptMapper.java b/src/com/engine/salary/mapper/auth/AuthOptMapper.java new file mode 100644 index 000000000..7dcc172ea --- /dev/null +++ b/src/com/engine/salary/mapper/auth/AuthOptMapper.java @@ -0,0 +1,79 @@ +package com.engine.salary.mapper.auth; + +import com.engine.salary.entity.auth.po.AuthOptPO; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; + +public interface AuthOptMapper { + + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + /** + * 条件查询 + * + * @return 返回集合,没有返回空List + */ + List listSome(AuthOptPO authOpt); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + AuthOptPO getById(Long id); + + /** + * 新增,忽略null字段 + * + * @param authOpt 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(AuthOptPO authOpt); + + /** + * 修改,修改所有字段 + * + * @param authOpt 修改的记录 + * @return 返回影响行数 + */ + int update(AuthOptPO authOpt); + + /** + * 修改,忽略null字段 + * + * @param authOpt 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(AuthOptPO authOpt); + + /** + * 删除记录 + * + * @param authOpt 待删除的记录 + * @return 返回影响行数 + */ + int delete(AuthOptPO authOpt); + + /** + * 批量删除记录 + * @param ids 主键id集合 + */ + void deleteByIds(@Param("ids") Collection ids); + + + /** + * 根据角色id删除 + * @param roleId roleId + */ + void deleteByRoleId(Long roleId); + +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/auth/AuthOptMapper.xml b/src/com/engine/salary/mapper/auth/AuthOptMapper.xml new file mode 100644 index 000000000..8ee16cf89 --- /dev/null +++ b/src/com/engine/salary/mapper/auth/AuthOptMapper.xml @@ -0,0 +1,230 @@ + + + + + + + + + + + + + + + + + + t + . + id + , t.role_id + , t.page + , t.opt + , t.creator + , t.create_time + , t.update_time + , t.delete_type + , t.tenant_key + + + + + + + + + + + + + + + INSERT INTO hrsa_auth_opt + + + + id, + + + role_id, + + + page, + + + opt, + + + creator, + + + create_time, + + + update_time, + + + delete_type, + + + tenant_key, + + + + + #{id}, + + + #{roleId}, + + + #{page}, + + + #{opt}, + + + #{creator}, + + + #{createTime}, + + + #{updateTime}, + + + #{deleteType}, + + + #{tenantKey}, + + + + + + + UPDATE hrsa_auth_opt + + role_id=#{roleId}, + page=#{page}, + opt=#{opt}, + creator=#{creator}, + create_time=#{createTime}, + update_time=#{updateTime}, + delete_type=#{deleteType}, + tenant_key=#{tenantKey}, + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_auth_opt + + + role_id=#{roleId}, + + + page=#{page}, + + + opt=#{opt}, + + + creator=#{creator}, + + + create_time=#{createTime}, + + + update_time=#{updateTime}, + + + delete_type=#{deleteType}, + + + tenant_key=#{tenantKey}, + + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_auth_opt + SET delete_type=1 + WHERE id = #{id} + AND delete_type = 0 + + + + UPDATE hrsa_auth_opt + SET delete_type = 1 + WHERE delete_type = 0 + AND id IN + + #{id} + + + + + UPDATE hrsa_auth_opt + SET delete_type=1 + WHERE role_id = #{roleId} AND delete_type = 0 + + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/auth/AuthResourceMapper.java b/src/com/engine/salary/mapper/auth/AuthResourceMapper.java new file mode 100644 index 000000000..36d44af71 --- /dev/null +++ b/src/com/engine/salary/mapper/auth/AuthResourceMapper.java @@ -0,0 +1,78 @@ +package com.engine.salary.mapper.auth; + +import com.engine.salary.entity.auth.po.AuthResourcePO; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; + +public interface AuthResourceMapper { + + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + /** + * 条件查询 + * + * @return 返回集合,没有返回空List + */ + List listSome(AuthResourcePO authLimit); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + AuthResourcePO getById(Long id); + + /** + * 新增,忽略null字段 + * + * @param authLimit 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(AuthResourcePO authLimit); + + /** + * 修改,修改所有字段 + * + * @param authLimit 修改的记录 + * @return 返回影响行数 + */ + int update(AuthResourcePO authLimit); + + /** + * 修改,忽略null字段 + * + * @param authLimit 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(AuthResourcePO authLimit); + + /** + * 删除记录 + * + * @param authLimit 待删除的记录 + * @return 返回影响行数 + */ + int delete(AuthResourcePO authLimit); + + /** + * 批量删除记录 + * @param ids 主键id集合 + */ + void deleteByIds(@Param("ids") Collection ids); + + + /** + * 根据角色id删除 + * @param roleId roleId + */ + void deleteByRoleId(Long roleId); +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/auth/AuthResourceMapper.xml b/src/com/engine/salary/mapper/auth/AuthResourceMapper.xml new file mode 100644 index 000000000..ed6c47fa9 --- /dev/null +++ b/src/com/engine/salary/mapper/auth/AuthResourceMapper.xml @@ -0,0 +1,243 @@ + + + + + + + + + + + + + + + + + + + t.create_time + , t.creator + , t.delete_type + , t.id + , t.role_id + , t.target + , t.target_name + , t.target_type + , t.tenant_key + , t.update_time + + + + + + + + + + + + + + + INSERT INTO hrsa_auth_resource + + + + create_time, + + + creator, + + + delete_type, + + + id, + + + role_id, + + + target, + + + target_name, + + + target_type, + + + tenant_key, + + + update_time, + + + + + #{createTime}, + + + #{creator}, + + + #{deleteType}, + + + #{id}, + + + #{roleId}, + + + #{target}, + + + #{targetName}, + + + #{targetType}, + + + #{tenantKey}, + + + #{updateTime}, + + + + + + + UPDATE hrsa_auth_resource + + create_time=#{createTime}, + creator=#{creator}, + delete_type=#{deleteType}, + role_id=#{roleId}, + target=#{target}, + target_name=#{targetName}, + target_type=#{targetType}, + tenant_key=#{tenantKey}, + update_time=#{updateTime}, + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_auth_resource + + + create_time=#{createTime}, + + + creator=#{creator}, + + + delete_type=#{deleteType}, + + + role_id=#{roleId}, + + + target=#{target}, + + + target_name=#{targetName}, + + + target_type=#{targetType}, + + + tenant_key=#{tenantKey}, + + + update_time=#{updateTime}, + + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_auth_resource + SET delete_type=1 + WHERE id = #{id} AND delete_type = 0 + + + + UPDATE hrsa_auth_resource + SET delete_type = 1 + WHERE delete_type = 0 + AND id IN + + #{id} + + + + + + UPDATE hrsa_auth_resource + SET delete_type = 1 + WHERE delete_type = 0 + AND role_id=#{roleId} + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/auth/AuthRoleDataMapper.java b/src/com/engine/salary/mapper/auth/AuthRoleDataMapper.java new file mode 100644 index 000000000..8d3f04621 --- /dev/null +++ b/src/com/engine/salary/mapper/auth/AuthRoleDataMapper.java @@ -0,0 +1,87 @@ +package com.engine.salary.mapper.auth; + +import com.engine.salary.entity.auth.dto.AuthRoleDataDTO; +import com.engine.salary.entity.auth.po.AuthRoleDataPO; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; + +public interface AuthRoleDataMapper { + + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + /** + * 条件查询 + * + * @return 返回集合,没有返回空List + */ + List listSome(AuthRoleDataPO authRoleData); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + AuthRoleDataPO getById(Long id); + + /** + * 新增,忽略null字段 + * + * @param authRoleData 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(AuthRoleDataPO authRoleData); + + /** + * 批量插入 + * + * @param authRoleData + */ + void batchInsert(@Param("collection") List authRoleData); + + /** + * 修改,修改所有字段 + * + * @param authRoleData 修改的记录 + * @return 返回影响行数 + */ + int update(AuthRoleDataPO authRoleData); + + /** + * 修改,忽略null字段 + * + * @param authRoleData 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(AuthRoleDataPO authRoleData); + + /** + * 删除记录 + * + * @param authRoleData 待删除的记录 + * @return 返回影响行数 + */ + int delete(AuthRoleDataPO authRoleData); + + /** + * 批量删除记录 + * @param ids 主键id集合 + */ + void deleteByIds(@Param("ids") Collection ids); + + /** + * 根据角色id删除 + * @param roleId roleId + */ + void deleteByRoleId(Long roleId); + + List listRoleData(Long roleId); +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/auth/AuthRoleDataMapper.xml b/src/com/engine/salary/mapper/auth/AuthRoleDataMapper.xml new file mode 100644 index 000000000..027331605 --- /dev/null +++ b/src/com/engine/salary/mapper/auth/AuthRoleDataMapper.xml @@ -0,0 +1,311 @@ + + + + + + + + + + + + + + + + + t + . + id + , t.role_id + , t.employee_id + , t.creator + , t.create_time + , t.update_time + , t.delete_type + , t.tenant_key + + + + + + + + + + + + + + + INSERT INTO hrsa_auth_role_data + + + + id, + + + role_id, + + + employee_id, + + + creator, + + + create_time, + + + update_time, + + + delete_type, + + + tenant_key, + + + + + #{id}, + + + #{roleId}, + + + #{employeeId}, + + + #{creator}, + + + #{createTime}, + + + #{updateTime}, + + + #{deleteType}, + + + #{tenantKey}, + + + + + + + + INSERT INTO hrsa_auth_role_data + ( + id, + role_id, + employee_id, + creator, + create_time, + update_time, + delete_type, + tenant_key + ) + VALUES + + + ( + #{item.id}, + #{item.roleId}, + #{item.employeeId}, + #{item.creator}, + #{item.createTime}, + #{item.updateTime}, + #{item.deleteType}, + #{item.tenantKey} + ) + + + + + + + INSERT INTO hrsa_auth_role_data ( + id, + role_id, + employee_id, + creator, + create_time, + update_time, + delete_type, + tenant_key + ) + + + select + #{item.id,jdbcType=DOUBLE}, + #{item.roleId,jdbcType=DOUBLE}, + #{item.employeeId,jdbcType=DOUBLE}, + #{item.creator,jdbcType=DOUBLE}, + #{item.createTime,jdbcType=DATE}, + #{item.updateTime,jdbcType=DATE}, + #{item.deleteType,jdbcType=INTEGER}, + #{item.tenantKey,jdbcType=VARCHAR} + from dual + + + + + + + INSERT INTO hrsa_auth_role_data ( + id, + role_id, + employee_id, + creator, + create_time, + update_time, + delete_type, + tenant_key + ) + VALUES + ( + #{item.id}, + #{item.roleId}, + #{item.employeeId}, + #{item.creator}, + #{item.createTime}, + #{item.updateTime}, + #{item.deleteType}, + #{item.tenantKey} + ) + + + + + + UPDATE hrsa_auth_role_data + + role_id=#{roleId}, + employee_id=#{employeeId}, + creator=#{creator}, + create_time=#{createTime}, + update_time=#{updateTime}, + delete_type=#{deleteType}, + tenant_key=#{tenantKey}, + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_auth_role_data + + + role_id=#{roleId}, + + + employee_id=#{employeeId}, + + + creator=#{creator}, + + + create_time=#{createTime}, + + + update_time=#{updateTime}, + + + delete_type=#{deleteType}, + + + tenant_key=#{tenantKey}, + + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_auth_role_data + SET delete_type=1 + WHERE id = #{id} + AND delete_type = 0 + + + + UPDATE hrsa_auth_role_data + SET delete_type = 1 + WHERE delete_type = 0 + AND id IN + + #{id} + + + + + delete from hrsa_auth_role_data + WHERE role_id = #{roleId} AND delete_type = 0 + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/auth/AuthRoleEmpMapper.java b/src/com/engine/salary/mapper/auth/AuthRoleEmpMapper.java new file mode 100644 index 000000000..eea6e0ab0 --- /dev/null +++ b/src/com/engine/salary/mapper/auth/AuthRoleEmpMapper.java @@ -0,0 +1,87 @@ +package com.engine.salary.mapper.auth; + +import com.engine.salary.entity.auth.dto.AuthRoleEmpDTO; +import com.engine.salary.entity.auth.po.AuthRoleEmpPO; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; + +public interface AuthRoleEmpMapper { + + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + /** + * 条件查询 + * + * @return 返回集合,没有返回空List + */ + List listSome(AuthRoleEmpPO authRoleEmp); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + AuthRoleEmpPO getById(Long id); + + /** + * 新增,忽略null字段 + * + * @param authRoleEmp 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(AuthRoleEmpPO authRoleEmp); + + /** + * 批量插入 + * + * @param authRoleEmp + */ + void batchInsert(@Param("collection") List authRoleEmp); + + /** + * 修改,修改所有字段 + * + * @param authRoleEmp 修改的记录 + * @return 返回影响行数 + */ + int update(AuthRoleEmpPO authRoleEmp); + + /** + * 修改,忽略null字段 + * + * @param authRoleEmp 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(AuthRoleEmpPO authRoleEmp); + + /** + * 删除记录 + * + * @param authRoleEmp 待删除的记录 + * @return 返回影响行数 + */ + int delete(AuthRoleEmpPO authRoleEmp); + + /** + * 批量删除记录 + * @param ids 主键id集合 + */ + void deleteByIds(@Param("ids") Collection ids); + + /** + * 根据角色id删除 + * @param roleId roleId + */ + void deleteByRoleId(Long roleId); + + List getByRoleId(Long roleId); +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/auth/AuthRoleEmpMapper.xml b/src/com/engine/salary/mapper/auth/AuthRoleEmpMapper.xml new file mode 100644 index 000000000..db7b3fb2f --- /dev/null +++ b/src/com/engine/salary/mapper/auth/AuthRoleEmpMapper.xml @@ -0,0 +1,318 @@ + + + + + + + + + + + + + + + + + t + . + id + , t.role_id + , t.employee_id + , t.creator + , t.create_time + , t.update_time + , t.delete_type + , t.tenant_key + + + + + + + + + + + + + + + INSERT INTO hrsa_auth_role_emp + + + + id, + + + role_id, + + + employee_id, + + + creator, + + + create_time, + + + update_time, + + + delete_type, + + + tenant_key, + + + + + #{id}, + + + #{roleId}, + + + #{employeeId}, + + + #{creator}, + + + #{createTime}, + + + #{updateTime}, + + + #{deleteType}, + + + #{tenantKey}, + + + + + + + + INSERT INTO hrsa_auth_role_emp + ( + id, + role_id, + employee_id, + creator, + create_time, + update_time, + delete_type, + tenant_key + ) + VALUES + + + ( + #{item.id}, + #{item.roleId}, + #{item.employeeId}, + #{item.creator}, + #{item.createTime}, + #{item.updateTime}, + #{item.deleteType}, + #{item.tenantKey} + ) + + + + + + + INSERT INTO hrsa_auth_role_emp ( + id, + role_id, + employee_id, + creator, + create_time, + update_time, + delete_type, + tenant_key + ) + + + select + #{item.id,jdbcType=DOUBLE}, + #{item.roleId,jdbcType=DOUBLE}, + #{item.employeeId,jdbcType=DOUBLE}, + #{item.creator,jdbcType=DOUBLE}, + #{item.createTime,jdbcType=DATE}, + #{item.updateTime,jdbcType=DATE}, + #{item.deleteType,jdbcType=INTEGER}, + #{item.tenantKey,jdbcType=VARCHAR} + from dual + + + + + + + INSERT INTO hrsa_auth_role_emp ( + id, + role_id, + employee_id, + creator, + create_time, + update_time, + delete_type, + tenant_key + ) + VALUES + ( + #{item.id}, + #{item.roleId}, + #{item.employeeId}, + #{item.creator}, + #{item.createTime}, + #{item.updateTime}, + #{item.deleteType}, + #{item.tenantKey} + ) + + + + + + UPDATE hrsa_auth_role_emp + + role_id=#{roleId}, + employee_id=#{employeeId}, + creator=#{creator}, + create_time=#{createTime}, + update_time=#{updateTime}, + delete_type=#{deleteType}, + tenant_key=#{tenantKey}, + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_auth_role_emp + + + role_id=#{roleId}, + + + employee_id=#{employeeId}, + + + creator=#{creator}, + + + create_time=#{createTime}, + + + update_time=#{updateTime}, + + + delete_type=#{deleteType}, + + + tenant_key=#{tenantKey}, + + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_auth_role_emp + SET delete_type=1 + WHERE id = #{id} + AND delete_type = 0 + + + + + UPDATE hrsa_auth_role_emp + SET delete_type = 1 + WHERE delete_type = 0 + AND id IN + + #{id} + + + + + + UPDATE hrsa_auth_role_emp + SET delete_type=1 + WHERE role_id = #{roleId} + AND delete_type = 0 + + + + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/auth/AuthRoleMapper.java b/src/com/engine/salary/mapper/auth/AuthRoleMapper.java new file mode 100644 index 000000000..1e958fb8f --- /dev/null +++ b/src/com/engine/salary/mapper/auth/AuthRoleMapper.java @@ -0,0 +1,76 @@ +package com.engine.salary.mapper.auth; + +import com.engine.salary.entity.auth.param.AuthRoleListQueryParam; +import com.engine.salary.entity.auth.po.AuthRolePO; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; + +public interface AuthRoleMapper { + + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + /** + * 条件查询 + * + * @return 返回集合,没有返回空List + */ + List listSome(AuthRolePO authRole); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + AuthRolePO getById(Long id); + + /** + * 新增,忽略null字段 + * + * @param authRole 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(AuthRolePO authRole); + + /** + * 修改,修改所有字段 + * + * @param authRole 修改的记录 + * @return 返回影响行数 + */ + int update(AuthRolePO authRole); + + /** + * 修改,忽略null字段 + * + * @param authRole 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(AuthRolePO authRole); + + /** + * 删除记录 + * + * @param authRole 待删除的记录 + * @return 返回影响行数 + */ + int delete(AuthRolePO authRole); + + /** + * 批量删除记录 + * + * @param ids 主键id集合 + */ + void deleteByIds(@Param("ids") Collection ids); + + + List list(AuthRoleListQueryParam param); +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/auth/AuthRoleMapper.xml b/src/com/engine/salary/mapper/auth/AuthRoleMapper.xml new file mode 100644 index 000000000..8a25166da --- /dev/null +++ b/src/com/engine/salary/mapper/auth/AuthRoleMapper.xml @@ -0,0 +1,296 @@ + + + + + + + + + + + + + + + + + t + . + id + , t.name + , t.description + , t.creator + , t.create_time + , t.update_time + , t.delete_type + , t.tenant_key + + + + + + + + + + + + + + + INSERT INTO hrsa_auth_role + + + + id, + + + name, + + + description, + + + creator, + + + create_time, + + + update_time, + + + delete_type, + + + tenant_key, + + + + + #{id}, + + + #{name}, + + + #{description}, + + + #{creator}, + + + #{createTime}, + + + #{updateTime}, + + + #{deleteType}, + + + #{tenantKey}, + + + + + + + UPDATE hrsa_auth_role + + name=#{name}, + description=#{description}, + creator=#{creator}, + create_time=#{createTime}, + update_time=#{updateTime}, + delete_type=#{deleteType}, + tenant_key=#{tenantKey}, + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_auth_role + + + name=#{name}, + + + description=#{description}, + + + creator=#{creator}, + + + create_time=#{createTime}, + + + update_time=#{updateTime}, + + + delete_type=#{deleteType}, + + + tenant_key=#{tenantKey}, + + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_auth_role + SET delete_type=1 + WHERE id = #{id} + AND delete_type = 0 + + + + UPDATE hrsa_auth_role + SET delete_type = 1 + WHERE delete_type = 0 + AND id IN + + #{id} + + + + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/datacollection/AddUpDeductionMapper.java b/src/com/engine/salary/mapper/datacollection/AddUpDeductionMapper.java new file mode 100644 index 000000000..6aedf838c --- /dev/null +++ b/src/com/engine/salary/mapper/datacollection/AddUpDeductionMapper.java @@ -0,0 +1,81 @@ +package com.engine.salary.mapper.datacollection; +import java.util.Date; + +import com.engine.salary.entity.datacollection.AddUpDeduction; +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.datacollection.dto.AddUpDeductionDTO; +import com.engine.salary.entity.datacollection.dto.AddUpDeductionRecordDTO; +import com.engine.salary.entity.datacollection.param.AddUpDeductionQueryParam; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + + +public interface AddUpDeductionMapper { + + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + AddUpDeduction getById(Long id); + + + /** + * 获取所有员工 + * @return + */ + List listEmployee(); + + /** + * 查询数据采集-累计专项附加扣除列表 + * @param param + * @return + */ + List list(@Param("param") AddUpDeductionQueryParam param); + + /** + * 根据条件查询 + * @param param + * @return + */ + List listSome(@Param("param") AddUpDeduction param); + + /** + * 批量插入 + * @param pos + */ + void insertData(@Param("collection") List pos); + + /** + * 批量修改 + * @param updateList + */ + void updateData(@Param("collection") List updateList); + + void updateDataAndDeclareMonth(@Param("collection") List updateList); + + List recordList(@Param("param") AddUpDeductionQueryParam param); + + + /** + * @description 批量删除 + * @return void + * @author Harryxzy + * @date 2022/10/27 9:54 + */ + void deleteData(@Param("collection")List longs); + + int countByDeclareAfter(@Param("minDeclareMonth") Date minDeclareMonth, + @Param("maxDeclareMonth") Date maxDeclareMonth, + @Param("taxAgentIds") List taxAgentIds); +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/datacollection/AddUpDeductionMapper.xml b/src/com/engine/salary/mapper/datacollection/AddUpDeductionMapper.xml new file mode 100644 index 000000000..5393e4363 --- /dev/null +++ b/src/com/engine/salary/mapper/datacollection/AddUpDeductionMapper.xml @@ -0,0 +1,676 @@ + + + + + add_up_child_education, + add_up_continuing_education, + add_up_housing_loan_interest, + add_up_housing_rent, + add_up_support_elderly, + create_time, + creator, + declare_month, + delete_type, + employee_id, + id, + tax_agent_id, + tenant_key, + update_time, + add_up_illness_medical, + add_up_infant_care + + + + + + + + + + + + + + + + + + + + + + + t + . + add_up_child_education + , t.add_up_continuing_education + , t.add_up_housing_loan_interest + , t.add_up_housing_rent + , t.add_up_support_elderly + , t.create_time + , t.creator + , t.declare_month + , t.delete_type + , t.employee_id + , t.id + , t.tax_agent_id + , t.tenant_key + , t.update_time + , t.add_up_illness_medical + , t.add_up_infant_care + + + + + UPDATE hrsa_add_up_deduction + SET delete_type = 1 + WHERE delete_type = 0 + AND id IN + + #{id} + + + + + + + + + + + + + + + + + + + t1 + . + id + , + t1.declare_month, + t1.employee_id, + e.lastname as username, + e.certificatenum as idNo, + d.departmentname AS departmentName, + e.mobile, + e.workcode as job_num, + e.companystartdate as hiredate, + t2.name AS taxAgentName, + t2.id AS taxAgentId, + t1.add_up_child_education, + t1.add_up_continuing_education, + t1.add_up_housing_loan_interest, + t1.add_up_housing_rent, + t1.add_up_support_elderly, + t1.add_up_illness_medical, + t1.add_up_infant_care + + + + + AND t1.id IN + + #{id} + + + + AND t1.employee_id = #{param.employeeId} + + + + AND + ( + e.lastname like CONCAT('%',#{param.keyword},'%') + OR d.departmentname like CONCAT('%',#{param.keyword},'%') + OR e.workcode like CONCAT('%',#{param.keyword},'%') + ) + + + + + AND t1.declare_month = #{param.declareMonthDate[0]} + + + AND (t1.declare_month BETWEEN #{param.declareMonthDate[0]} AND #{param.declareMonthDate[1]}) + + + + + AND e.lastname like CONCAT('%',#{param.username},'%') + + + + AND t1.tax_agent_id = #{param.taxAgentId} + + + AND t1.tax_agent_id IN + + #{id} + + + + + AND d.id IN + + #{id} + + + + + AND e.workcode like CONCAT('%',#{param.jobNum},'%') + + + + AND (e.companystartdate BETWEEN #{param.hiredate[0]} AND #{param.hiredate[1]}) + + + + AND e.mobile like CONCAT('%',#{param.mobile},'%') + + + + + + + AND t1.id IN + + #{id} + + + + AND t1.employee_id = #{param.employeeId} + + + + AND + ( + e.lastname like '%'||#{param.keyword}||'%' + OR d.departmentname like '%'||#{param.keyword}||'%' + OR e.workcode like '%'||#{param.keyword}||'%' + ) + + + + + AND t1.declare_month = #{param.declareMonthDate[0]} + + + AND (t1.declare_month BETWEEN #{param.declareMonthDate[0]} AND #{param.declareMonthDate[1]}) + + + + + AND e.lastname like '%'||#{param.username}||'%' + + + + AND t1.tax_agent_id = #{param.taxAgentId} + + + AND t1.tax_agent_id IN + + #{id} + + + + AND d.id IN + + #{id} + + + + + AND e.workcode like '%'||#{param.jobNum}||'%' + + + + AND (e.companystartdate BETWEEN #{param.hiredate[0]} AND #{param.hiredate[1]}) + + + + AND e.mobile like '%'||#{param.mobile}||'%' + + + + + AND t1.id IN + + #{id} + + + + AND t1.employee_id = #{param.employeeId} + + + + AND + ( + e.lastname like '%'+#{param.keyword}+'%' + OR d.departmentname like '%'+#{param.keyword}+'%' + OR e.workcode like '%'+#{param.keyword}+'%' + ) + + + + + AND t1.declare_month = #{param.declareMonthDate[0]} + + + AND (t1.declare_month BETWEEN #{param.declareMonthDate[0]} AND #{param.declareMonthDate[1]}) + + + + + AND e.lastname like '%'+#{param.username}+'%' + + + + AND t1.tax_agent_id = #{param.taxAgentId} + + + AND t1.tax_agent_id IN + + #{id} + + + + AND d.id IN + + #{id} + + + + + AND e.workcode like '%'+#{param.jobNum}+'%' + + + + AND (e.companystartdate BETWEEN #{param.hiredate[0]} AND #{param.hiredate[1]}) + + + + AND e.mobile like '%'+#{param.mobile}+'%' + + + + + + + + + + + + + + INSERT INTO hrsa_add_up_deduction( + employee_id, + tax_agent_id, + declare_month, + add_up_child_education, + add_up_continuing_education, + add_up_housing_loan_interest, + add_up_housing_rent, + add_up_support_elderly, + add_up_illness_medical, + add_up_infant_care, + create_time, + update_time, + creator, + tenant_key + ) + VALUES + + ( + #{item.employeeId}, + #{item.taxAgentId}, + #{item.declareMonth}, + #{item.addUpChildEducation}, + #{item.addUpContinuingEducation}, + #{item.addUpHousingLoanInterest}, + #{item.addUpHousingRent}, + #{item.addUpSupportElderly}, + #{item.addUpIllnessMedical}, + #{item.addUpInfantCare}, + #{item.createTime}, + #{item.updateTime}, + #{item.creator}, + #{item.tenantKey} + ) + + + + INSERT INTO hrsa_add_up_deduction( + employee_id, + tax_agent_id, + declare_month, + add_up_child_education, + add_up_continuing_education, + add_up_housing_loan_interest, + add_up_housing_rent, + add_up_support_elderly, + add_up_illness_medical, + add_up_infant_care, + create_time, + update_time, + creator, + tenant_key + ) + + + select + #{item.employeeId,jdbcType=DOUBLE}, + #{item.taxAgentId,jdbcType=DOUBLE}, + #{item.declareMonth,jdbcType=DATE}, + #{item.addUpChildEducation,jdbcType=VARCHAR}, + #{item.addUpContinuingEducation,jdbcType=VARCHAR}, + #{item.addUpHousingLoanInterest,jdbcType=VARCHAR}, + #{item.addUpHousingRent,jdbcType=VARCHAR}, + #{item.addUpSupportElderly,jdbcType=VARCHAR}, + #{item.addUpIllnessMedical,jdbcType=VARCHAR}, + #{item.addUpInfantCare,jdbcType=VARCHAR}, + #{item.createTime,jdbcType=DATE}, + #{item.updateTime,jdbcType=DATE}, + #{item.creator,jdbcType=DOUBLE}, + #{item.tenantKey,jdbcType=VARCHAR} + from dual + + + + + INSERT INTO hrsa_add_up_deduction( + employee_id, + tax_agent_id, + declare_month, + add_up_child_education, + add_up_continuing_education, + add_up_housing_loan_interest, + add_up_housing_rent, + add_up_support_elderly, + add_up_illness_medical, + add_up_infant_care, + create_time, + update_time, + creator, + tenant_key + ) + VALUES + ( + #{item.employeeId}, + #{item.taxAgentId}, + #{item.declareMonth}, + #{item.addUpChildEducation}, + #{item.addUpContinuingEducation}, + #{item.addUpHousingLoanInterest}, + #{item.addUpHousingRent}, + #{item.addUpSupportElderly}, + #{item.addUpIllnessMedical}, + #{item.addUpInfantCare}, + #{item.createTime}, + #{item.updateTime}, + #{item.creator}, + #{item.tenantKey} + ) + + + + + update hrsa_add_up_deduction + + + + + when id=#{item.id} then #{item.addUpChildEducation} + + + + + + + when id=#{item.id} then #{item.addUpContinuingEducation} + + + + + + + when id=#{item.id} then #{item.addUpHousingLoanInterest} + + + + + + + when id=#{item.id} then #{item.addUpHousingRent} + + + + + + + when id=#{item.id} then #{item.addUpSupportElderly} + + + + + + + when id=#{item.id} then #{item.addUpIllnessMedical} + + + + + + + when id=#{item.id} then #{item.addUpInfantCare} + + + + + where + id in + + #{item.id} + + + + + update hrsa_add_up_deduction + + + + + when id=#{item.id} then #{item.addUpChildEducation} + + + + + + + when id=#{item.id} then #{item.addUpContinuingEducation} + + + + + + + when id=#{item.id} then #{item.addUpHousingLoanInterest} + + + + + + + when id=#{item.id} then #{item.addUpHousingRent} + + + + + + + when id=#{item.id} then #{item.addUpSupportElderly} + + + + + + + when id=#{item.id} then #{item.addUpIllnessMedical} + + + + + + + when id=#{item.id} then #{item.addUpInfantCare} + + + + + + + when id=#{item.id} then #{item.declareMonth} + + + + + where + id in + + #{item.id} + + + + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/datacollection/AddUpSituationMapper.java b/src/com/engine/salary/mapper/datacollection/AddUpSituationMapper.java new file mode 100644 index 000000000..1a7e85c48 --- /dev/null +++ b/src/com/engine/salary/mapper/datacollection/AddUpSituationMapper.java @@ -0,0 +1,68 @@ +package com.engine.salary.mapper.datacollection; + +import com.engine.salary.entity.datacollection.AddUpSituation; +import com.engine.salary.entity.datacollection.dto.AddUpSituationDTO; +import com.engine.salary.entity.datacollection.dto.AddUpSituationRecordDTO; +import com.engine.salary.entity.datacollection.param.AddUpSituationQueryParam; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; + + +public interface AddUpSituationMapper { + + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + AddUpSituation getById(Long id); + + /** + * 查询数据采集-累计专项附加扣除列表 + * @param param + * @return + */ + List list(@Param("param") AddUpSituationQueryParam param); + + List recordList(@Param("param") AddUpSituationQueryParam param); + + /** + * 根据条件查询 + * @param param + * @return + */ + List listSome(@Param("param") AddUpSituation param); + + /** + * 批量插入 + * @param pos + */ + void insertData(@Param("collection") List pos); + + /** + * 批量修改 + * @param updateList + */ + void updateData(@Param("collection") List updateList); + + + void deleteByTaxYearMonthAndTaxAgentIds(@Param("param") AddUpSituation params); + + void deleteByIds(@Param("ids") Collection ids); + + /** + * 批量删除 + */ + void deleteData(List longs); +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/datacollection/AddUpSituationMapper.xml b/src/com/engine/salary/mapper/datacollection/AddUpSituationMapper.xml new file mode 100644 index 000000000..2b5c45519 --- /dev/null +++ b/src/com/engine/salary/mapper/datacollection/AddUpSituationMapper.xml @@ -0,0 +1,788 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + t + . + add_up_accumulation_fund_total + , t.add_up_advance_tax + , t.add_up_allowed_donation + , t.add_up_child_education + , t.add_up_continuing_education + , t.add_up_enterprise_and_other + , t.add_up_housing_loan_interest + , t.add_up_housing_rent + , t.add_up_income + , t.add_up_other_deduction + , t.add_up_social_security_total + , t.add_up_subtraction + , t.add_up_support_elderly + , t.add_up_tax_exempt_income + , t.create_time + , t.creator + , t.delete_type + , t.employee_id + , t.id + , t.tax_agent_id + , t.tax_year_month + , t.tenant_key + , t.update_time + , t.year + , t.add_up_illness_medical + , t.add_up_tax_savings + , t.add_up_infant_care + , t.add_up_private_pension + + + + + UPDATE hrsa_add_up_situation + SET delete_type = 1 + WHERE delete_type = 0 + AND id IN + + #{id} + + + + + + + + + + + + t1 + . + id + , + t1.tax_year_month, + t1.employee_id, + e.lastname as username, + d.departmentName AS departmentName, + e.mobile, + e.workcode as job_num, + e.companystartdate as hiredate, + e.certificatenum as idNo, + t2.name AS tax_agent_name, + t2.id AS tax_agent_id, + t1.add_up_income, + t1.add_up_subtraction, + t1.add_up_social_security_total, + t1.add_up_accumulation_fund_total, + t1.add_up_child_education, + t1.add_up_continuing_education, + t1.add_up_housing_loan_interest, + t1.add_up_housing_rent, + t1.add_up_support_elderly, + t1.add_up_illness_medical, + t1.add_up_infant_care, + t1.add_up_private_pension, + t1.add_up_enterprise_and_other, + t1.add_up_other_deduction, + t1.add_up_tax_exempt_income, + t1.add_up_allowed_donation, + t1.add_up_tax_savings, + t1.add_up_advance_tax + + + + + AND t1.id IN + + #{id} + + + + AND t1.year = #{param.year} + + + AND t1.employee_id = #{param.employeeId} + + + + AND + ( + e.lastname like CONCAT('%',#{param.keyword},'%') + OR d.departmentname like CONCAT('%',#{param.keyword},'%') + OR e.workcode like CONCAT('%',#{param.keyword},'%') + ) + + + + + AND t1.tax_year_month = #{param.taxYearMonthDate[0]} + + + AND (t1.tax_year_month BETWEEN #{param.taxYearMonthDate[0]} AND #{param.taxYearMonthDate[1]}) + + + + + AND e.lastname like CONCAT('%',#{param.username},'%') + + + AND t1.tax_agent_id = #{param.taxAgentId} + + + AND t1.tax_agent_id IN + + #{id} + + + + + AND d.id IN + + #{id} + + + + + AND e.workcode like CONCAT('%',#{param.jobNum},'%') + + + + AND (e.companystartdate BETWEEN #{param.hiredate[0]} AND #{param.hiredate[1]}) + + + + AND e.mobile like CONCAT('%',#{param.mobile},'%') + + + + + AND t1.id IN + + #{id} + + + + AND t1.year = #{param.year} + + + AND t1.employee_id = #{param.employeeId} + + + + AND + ( + e.lastname like '%'||#{param.keyword}||'%' + OR d.departmentname like '%'||#{param.keyword}||'%' + OR e.workcode like '%'||#{param.keyword}||'%' + ) + + + + + AND t1.tax_year_month = #{param.taxYearMonthDate[0]} + + + AND (t1.tax_year_month BETWEEN #{param.taxYearMonthDate[0]} AND #{param.taxYearMonthDate[1]}) + + + + + AND e.lastname like '%'||#{param.username}||'%' + + + AND t1.tax_agent_id = #{param.taxAgentId} + + + AND t1.tax_agent_id IN + + #{id} + + + + AND d.id IN + + #{id} + + + + + AND e.workcode like '%'||#{param.jobNum}||'%' + + + + AND (e.companystartdate BETWEEN #{param.hiredate[0]} AND #{param.hiredate[1]}) + + + + AND e.mobile like '%'||#{param.mobile}||'%' + + + + + AND t1.id IN + + #{id} + + + + AND t1.year = #{param.year} + + + AND t1.employee_id = #{param.employeeId} + + + + AND + ( + e.lastname like '%'+#{param.keyword}+'%' + OR d.departmentname like '%'+#{param.keyword}+'%' + OR e.workcode like '%'+#{param.keyword}+'%' + ) + + + + + AND t1.tax_year_month = #{param.taxYearMonthDate[0]} + + + AND (t1.tax_year_month BETWEEN #{param.taxYearMonthDate[0]} AND #{param.taxYearMonthDate[1]}) + + + + + AND e.lastname like '%'+#{param.username}+'%' + + + AND t1.tax_agent_id = #{param.taxAgentId} + + + AND t1.tax_agent_id IN + + #{id} + + + + AND d.id IN + + #{id} + + + + + AND e.workcode like '%'+#{param.jobNum}+'%' + + + + AND (e.companystartdate BETWEEN #{param.hiredate[0]} AND #{param.hiredate[1]}) + + + + AND e.mobile like '%'+#{param.mobile}+'%' + + + + + + + + + + + + + INSERT INTO hrsa_add_up_situation( + employee_id, + tax_agent_id, + tax_year_month, + year, + add_up_income, + add_up_subtraction, + add_up_social_security_total, + add_up_accumulation_fund_total, + add_up_child_education, + add_up_continuing_education, + add_up_housing_loan_interest, + add_up_housing_rent, + add_up_support_elderly, + add_up_enterprise_and_other, + add_up_other_deduction, + add_up_tax_exempt_income, + add_up_allowed_donation, + add_up_advance_tax, + create_time, + update_time, + creator, + tenant_key, + add_up_tax_savings, + add_up_illness_medical, + add_up_infant_care, + add_up_private_pension + ) + VALUES + + ( + #{item.employeeId}, + #{item.taxAgentId}, + #{item.taxYearMonth}, + #{item.year}, + #{item.addUpIncome}, + #{item.addUpSubtraction}, + #{item.addUpSocialSecurityTotal}, + #{item.addUpAccumulationFundTotal}, + #{item.addUpChildEducation}, + #{item.addUpContinuingEducation}, + #{item.addUpHousingLoanInterest}, + #{item.addUpHousingRent}, + #{item.addUpSupportElderly}, + #{item.addUpEnterpriseAndOther}, + #{item.addUpOtherDeduction}, + #{item.addUpTaxExemptIncome}, + #{item.addUpAllowedDonation}, + #{item.addUpAdvanceTax}, + #{item.createTime}, + #{item.updateTime}, + #{item.creator}, + #{item.tenantKey}, + #{item.addUpTaxSavings}, + #{item.addUpIllnessMedical}, + #{item.addUpInfantCare}, + #{item.addUpPrivatePension} + ) + + + + INSERT INTO hrsa_add_up_situation( + employee_id, + tax_agent_id, + tax_year_month, + year, + add_up_income, + add_up_subtraction, + add_up_social_security_total, + add_up_accumulation_fund_total, + add_up_child_education, + add_up_continuing_education, + add_up_housing_loan_interest, + add_up_housing_rent, + add_up_support_elderly, + add_up_enterprise_and_other, + add_up_other_deduction, + add_up_tax_exempt_income, + add_up_allowed_donation, + add_up_advance_tax, + create_time, + update_time, + creator, + tenant_key, + add_up_tax_savings, + add_up_illness_medical, + add_up_infant_care, + add_up_private_pension + ) + + + select + #{item.employeeId,jdbcType=DOUBLE}, + #{item.taxAgentId,jdbcType=DOUBLE}, + #{item.taxYearMonth,jdbcType=DATE}, + #{item.year,jdbcType=INTEGER}, + #{item.addUpIncome,jdbcType=VARCHAR}, + #{item.addUpSubtraction,jdbcType=VARCHAR}, + #{item.addUpSocialSecurityTotal,jdbcType=VARCHAR}, + #{item.addUpAccumulationFundTotal,jdbcType=VARCHAR}, + #{item.addUpChildEducation,jdbcType=VARCHAR}, + #{item.addUpContinuingEducation,jdbcType=VARCHAR}, + #{item.addUpHousingLoanInterest,jdbcType=VARCHAR}, + #{item.addUpHousingRent,jdbcType=VARCHAR}, + #{item.addUpSupportElderly,jdbcType=VARCHAR}, + #{item.addUpEnterpriseAndOther,jdbcType=VARCHAR}, + #{item.addUpOtherDeduction,jdbcType=VARCHAR}, + #{item.addUpTaxExemptIncome,jdbcType=VARCHAR}, + #{item.addUpAllowedDonation,jdbcType=VARCHAR}, + #{item.addUpAdvanceTax,jdbcType=VARCHAR}, + #{item.createTime,jdbcType=DATE}, + #{item.updateTime,jdbcType=DATE}, + #{item.creator,jdbcType=DOUBLE}, + #{item.tenantKey,jdbcType=VARCHAR}, + #{item.addUpTaxSavings,jdbcType=VARCHAR}, + #{item.addUpIllnessMedical,jdbcType=VARCHAR}, + #{item.addUpInfantCare,jdbcType=VARCHAR}, + #{item.addUpPrivatePension,jdbcType=VARCHAR} + from dual + + + + + INSERT INTO hrsa_add_up_situation( + employee_id, + tax_agent_id, + tax_year_month, + year, + add_up_income, + add_up_subtraction, + add_up_social_security_total, + add_up_accumulation_fund_total, + add_up_child_education, + add_up_continuing_education, + add_up_housing_loan_interest, + add_up_housing_rent, + add_up_support_elderly, + add_up_enterprise_and_other, + add_up_other_deduction, + add_up_tax_exempt_income, + add_up_allowed_donation, + add_up_advance_tax, + create_time, + update_time, + creator, + tenant_key, + add_up_tax_savings, + add_up_illness_medical, + add_up_infant_care, + add_up_private_pension + ) + VALUES + ( + #{item.employeeId}, + #{item.taxAgentId}, + #{item.taxYearMonth}, + #{item.year}, + #{item.addUpIncome}, + #{item.addUpSubtraction}, + #{item.addUpSocialSecurityTotal}, + #{item.addUpAccumulationFundTotal}, + #{item.addUpChildEducation}, + #{item.addUpContinuingEducation}, + #{item.addUpHousingLoanInterest}, + #{item.addUpHousingRent}, + #{item.addUpSupportElderly}, + #{item.addUpEnterpriseAndOther}, + #{item.addUpOtherDeduction}, + #{item.addUpTaxExemptIncome}, + #{item.addUpAllowedDonation}, + #{item.addUpAdvanceTax}, + #{item.createTime}, + #{item.updateTime}, + #{item.creator}, + #{item.tenantKey}, + #{item.addUpTaxSavings}, + #{item.addUpIllnessMedical}, + #{item.addUpInfantCare}, + #{item.addUpPrivatePension} + ) + + + + + update hrsa_add_up_situation + + + + + when id=#{item.id} then #{item.addUpIncome} + + + + + + + when id=#{item.id} then #{item.addUpSubtraction} + + + + + + + when id=#{item.id} then #{item.addUpSocialSecurityTotal} + + + + + + + when id=#{item.id} then #{item.addUpAccumulationFundTotal} + + + + + + + when id=#{item.id} then #{item.addUpChildEducation} + + + + + + + when id=#{item.id} then #{item.addUpContinuingEducation} + + + + + + + when id=#{item.id} then #{item.addUpHousingLoanInterest} + + + + + + + when id=#{item.id} then #{item.addUpHousingRent} + + + + + + + when id=#{item.id} then #{item.addUpSupportElderly} + + + + + + + when id=#{item.id} then #{item.addUpEnterpriseAndOther} + + + + + + + when id=#{item.id} then #{item.addUpOtherDeduction} + + + + + + + when id=#{item.id} then #{item.addUpTaxExemptIncome} + + + + + + + when id=#{item.id} then #{item.addUpAllowedDonation} + + + + + + + when id=#{item.id} then #{item.addUpAdvanceTax} + + + + + + + when id=#{item.id} then #{item.addUpTaxSavings} + + + + + + + when id=#{item.id} then #{item.addUpIllnessMedical} + + + + + + + when id=#{item.id} then #{item.addUpInfantCare} + + + + + + + when id=#{item.id} then #{item.addUpPrivatePension} + + + + + where + id in + + #{item.id} + + + + + + + + + UPDATE hrsa_add_up_situation + SET delete_type = 1 + WHERE delete_type = 0 + AND tax_year_month = #{param.taxYearMonth} + + AND tax_agent_id IN + + #{taxAgentId} + + + + + + UPDATE hrsa_add_up_situation + SET delete_type = 1 + WHERE delete_type = 0 + AND id IN + + #{id} + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/datacollection/AttendQuoteDataMapper.java b/src/com/engine/salary/mapper/datacollection/AttendQuoteDataMapper.java new file mode 100644 index 000000000..aa4bfff5c --- /dev/null +++ b/src/com/engine/salary/mapper/datacollection/AttendQuoteDataMapper.java @@ -0,0 +1,85 @@ +package com.engine.salary.mapper.datacollection; + +import com.engine.salary.entity.datacollection.dto.AttendQuoteDataBaseDTO; +import com.engine.salary.entity.datacollection.param.AttendQuoteDataQueryParam; +import com.engine.salary.entity.datacollection.po.AttendQuoteDataPO; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; + + +public interface AttendQuoteDataMapper { + + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + AttendQuoteDataPO getById(Long id); + + /** + * 新增,忽略null字段 + * + * @param AttendQuoteDataPO 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(AttendQuoteDataPO AttendQuoteDataPO); + + /** + * 修改,修改所有字段 + * + * @param AttendQuoteDataPO 修改的记录 + * @return 返回影响行数 + */ + int update(AttendQuoteDataPO AttendQuoteDataPO); + + /** + * 修改,忽略null字段 + * + * @param AttendQuoteDataPO 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(AttendQuoteDataPO AttendQuoteDataPO); + + /** + * 删除记录 + * + * @param AttendQuoteDataPO 待删除的记录 + * @return 返回影响行数 + */ + int delete(AttendQuoteDataPO AttendQuoteDataPO); + + + /** + * 批量删除数据采集-考勤引用数据 + * @param attendQuoteIds + */ + void deleteByAttendQuoteIds(@Param("attendQuoteIds") Collection attendQuoteIds); + + /** + * 批量插入数据采集-考勤引用数据 + * @param pos + */ + void insertData(@Param("collection") List pos); + + /** + * 查询数据采集-考勤引用数据列表 + * @param param + * @return + */ + List list(@Param("param") AttendQuoteDataQueryParam param); + + + List listSome(@Param("param") AttendQuoteDataQueryParam param); +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/datacollection/AttendQuoteDataMapper.xml b/src/com/engine/salary/mapper/datacollection/AttendQuoteDataMapper.xml new file mode 100644 index 000000000..ca51de22a --- /dev/null +++ b/src/com/engine/salary/mapper/datacollection/AttendQuoteDataMapper.xml @@ -0,0 +1,399 @@ + + + + + + + + + + + + + + + + + t + . + id + , t.employee_id + , t.attend_quote_id + , t.create_time + , t.update_time + , t.creator + , t.delete_type + , t.tenant_key + + + + + + + + + + + INSERT INTO hrsa_attend_quote_data + + + + id, + + + employee_id, + + + attend_quote_id, + + + create_time, + + + update_time, + + + creator, + + + delete_type, + + + tenant_key, + + + + + #{id}, + + + #{employeeId}, + + + #{attendQuoteId}, + + + #{createTime}, + + + #{updateTime}, + + + #{creator}, + + + #{deleteType}, + + + #{tenantKey}, + + + + + + + UPDATE hrsa_attend_quote_data + + employee_id=#{employeeId}, + attend_quote_id=#{attendQuoteId}, + create_time=#{createTime}, + update_time=#{updateTime}, + creator=#{creator}, + delete_type=#{deleteType}, + tenant_key=#{tenantKey}, + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_attend_quote_data + + + employee_id=#{employeeId}, + + + attend_quote_id=#{attendQuoteId}, + + + create_time=#{createTime}, + + + update_time=#{updateTime}, + + + creator=#{creator}, + + + delete_type=#{deleteType}, + + + tenant_key=#{tenantKey}, + + + WHERE id = #{id} AND delete_type = 0 + + + + + + + UPDATE hrsa_attend_quote_data + SET delete_type=1 + WHERE id = #{id} + AND delete_type = 0 + + + + + t1.id, + t1.employee_id, + t1.attend_quote_id, + e.lastname as username, + d.departmentname AS departmentName, + e.mobile, + e.workcode as job_num, + e.certificatenum as idNo + + + + + AND t1.id IN + + #{id} + + + + + AND + ( + e.lastname like CONCAT('%',#{param.keyword},'%') + OR d.departmentname like CONCAT('%',#{param.keyword},'%') + OR e.workcode like CONCAT('%',#{param.keyword},'%') + OR e.mobile like CONCAT('%',#{param.keyword},'%') + ) + + + AND t1.attend_quote_id = #{param.attendQuoteId} + + + AND t1.attend_quote_id IN + + #{id} + + + + + + + AND t1.id IN + + #{id} + + + + + AND + ( + e.lastname like '%'||#{param.keyword}||'%' + OR d.departmentname like '%'||#{param.keyword}||'%' + OR e.workcode like '%'||#{param.keyword}||'%' + OR e.mobile like '%'||#{param.keyword}||'%' + ) + + + AND t1.attend_quote_id = #{param.attendQuoteId} + + + AND t1.attend_quote_id IN + + #{id} + + + + + + AND t1.id IN + + #{id} + + + + + AND + ( + e.lastname like '%'+#{param.keyword}+'%' + OR d.departmentname like '%'+#{param.keyword}+'%' + OR e.workcode like '%'+#{param.keyword}+'%' + OR e.mobile like '%'+#{param.keyword}+'%' + ) + + + AND t1.attend_quote_id = #{param.attendQuoteId} + + + AND t1.attend_quote_id IN + + #{id} + + + + + + + + + + UPDATE hrsa_attend_quote_data + SET delete_type = 1 + WHERE delete_type = 0 + AND attend_quote_id IN + + #{attendQuoteId} + + + + + INSERT INTO hrsa_attend_quote_data( + id, + employee_id, + attend_quote_id, + create_time, + update_time, + creator, + tenant_key) + VALUES + + ( + #{item.id}, + #{item.employeeId}, + #{item.attendQuoteId}, + #{item.createTime}, + #{item.updateTime}, + #{item.creator}, + #{item.tenantKey} + ) + + + + INSERT INTO hrsa_attend_quote_data( + id, + employee_id, + attend_quote_id, + create_time, + update_time, + creator, + tenant_key) + + + select + #{item.id,jdbcType=DOUBLE}, + #{item.employeeId,jdbcType=DOUBLE}, + #{item.attendQuoteId,jdbcType=DOUBLE}, + #{item.createTime,jdbcType=DATE}, + #{item.updateTime,jdbcType=DATE}, + #{item.creator,jdbcType=DOUBLE}, + #{item.tenantKey,jdbcType=VARCHAR} + from dual + + + + + INSERT INTO hrsa_attend_quote_data( + id, + employee_id, + attend_quote_id, + create_time, + update_time, + creator, + tenant_key) + VALUES + ( + #{item.id}, + #{item.employeeId}, + #{item.attendQuoteId}, + #{item.createTime}, + #{item.updateTime}, + #{item.creator}, + #{item.tenantKey} + ) + + + + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/datacollection/AttendQuoteDataValueMapper.java b/src/com/engine/salary/mapper/datacollection/AttendQuoteDataValueMapper.java new file mode 100644 index 000000000..852ec5316 --- /dev/null +++ b/src/com/engine/salary/mapper/datacollection/AttendQuoteDataValueMapper.java @@ -0,0 +1,76 @@ +package com.engine.salary.mapper.datacollection; + +import com.engine.salary.entity.datacollection.po.AttendQuoteDataValuePO; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; + + +public interface AttendQuoteDataValueMapper { + + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + AttendQuoteDataValuePO getById(Long id); + + /** + * 新增,忽略null字段 + * + * @param AttendQuoteDataValuePO 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(AttendQuoteDataValuePO AttendQuoteDataValuePO); + + /** + * 修改,修改所有字段 + * + * @param AttendQuoteDataValuePO 修改的记录 + * @return 返回影响行数 + */ + int update(AttendQuoteDataValuePO AttendQuoteDataValuePO); + + /** + * 修改,忽略null字段 + * + * @param AttendQuoteDataValuePO 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(AttendQuoteDataValuePO AttendQuoteDataValuePO); + + int updateDataValueByFiledIdAndEmployeeId(AttendQuoteDataValuePO attendQuoteDataValuePO); + /** + * 删除记录 + * + * @param AttendQuoteDataValuePO 待删除的记录 + * @return 返回影响行数 + */ + int delete(AttendQuoteDataValuePO AttendQuoteDataValuePO); + + /** + * 批量删除数据采集-考勤引用数据 + * @param attendQuoteDataIds + */ + void deleteByAttendQuoteDataIds(@Param("attendQuoteDataIds") Collection attendQuoteDataIds); + + /** + * 批量插入数据采集-考勤引用数据 + * @param values + */ + void insertData(@Param("collection") List values); + + List listSome(@Param("param") AttendQuoteDataValuePO param); + + void deleteByAttendIds(@Param("attendIds") Collection quoteIds); +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/datacollection/AttendQuoteDataValueMapper.xml b/src/com/engine/salary/mapper/datacollection/AttendQuoteDataValueMapper.xml new file mode 100644 index 000000000..30d790e9d --- /dev/null +++ b/src/com/engine/salary/mapper/datacollection/AttendQuoteDataValueMapper.xml @@ -0,0 +1,403 @@ + + + + + + + + + + + + + + + + + + + + t + . + id + , t.employee_id + , t.attend_quote_id + , t.attend_quote_data_id + , t.attend_quote_field_id + , t.data_value + , t.create_time + , t.update_time + , t.creator + , t.delete_type + , t.tenant_key + + + + + + + + + + + INSERT INTO hrsa_attend_quote_data_value + + + + id, + + + employee_id, + + + attend_quote_id, + + + attend_quote_data_id, + + + attend_quote_field_id, + + + data_value, + + + create_time, + + + update_time, + + + creator, + + + delete_type, + + + tenant_key, + + + + + #{id}, + + + #{employeeId}, + + + #{attendQuoteId}, + + + #{attendQuoteDataId}, + + + #{attendQuoteFieldId}, + + + #{dataValue}, + + + #{createTime}, + + + #{updateTime}, + + + #{creator}, + + + #{deleteType}, + + + #{tenantKey}, + + + + + + + select hrsa_attend_quote_data_value_id.currval from dual + + INSERT INTO hrsa_attend_quote_data_value + + + + id, + + + employee_id, + + + attend_quote_id, + + + attend_quote_data_id, + + + attend_quote_field_id, + + + data_value, + + + create_time, + + + update_time, + + + creator, + + + delete_type, + + + tenant_key, + + + + + #{id}, + + + #{employeeId}, + + + #{attendQuoteId}, + + + #{attendQuoteDataId}, + + + #{attendQuoteFieldId}, + + + #{dataValue}, + + + #{createTime}, + + + #{updateTime}, + + + #{creator}, + + + #{deleteType}, + + + #{tenantKey}, + + + + + + + UPDATE hrsa_attend_quote_data_value + + employee_id=#{employeeId}, + attend_quote_id=#{attendQuoteId}, + attend_quote_data_id=#{attendQuoteDataId}, + attend_quote_field_id=#{attendQuoteFieldId}, + data_value=#{dataValue}, + create_time=#{createTime}, + update_time=#{updateTime}, + creator=#{creator}, + delete_type=#{deleteType}, + tenant_key=#{tenantKey}, + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_attend_quote_data_value + + + employee_id=#{employeeId}, + + + attend_quote_id=#{attendQuoteId}, + + + attend_quote_data_id=#{attendQuoteDataId}, + + + attend_quote_field_id=#{attendQuoteFieldId}, + + + data_value=#{dataValue}, + + + create_time=#{createTime}, + + + update_time=#{updateTime}, + + + creator=#{creator}, + + + delete_type=#{deleteType}, + + + tenant_key=#{tenantKey}, + + + WHERE id = #{id} AND delete_type = 0 + + + + + UPDATE hrsa_attend_quote_data_value + + + data_value=#{dataValue}, + + + WHERE employee_id = #{employeeId} AND delete_type = 0 AND attend_quote_field_id = #{attendQuoteFieldId} + + + + + + UPDATE hrsa_attend_quote_data_value + SET delete_type=1 + WHERE id = #{id} + AND delete_type = 0 + + + + + UPDATE hrsa_attend_quote_data_value + SET delete_type = 1 + WHERE delete_type = 0 + AND attend_quote_data_id IN + + #{attendQuoteDataId} + + + + + INSERT INTO hrsa_attend_quote_data_value( + employee_id, + attend_quote_id, + attend_quote_data_id, + attend_quote_field_id, + data_value, + create_time, + update_time, + creator, + tenant_key) + VALUES + + ( + #{item.employeeId}, + #{item.attendQuoteId}, + #{item.attendQuoteDataId}, + #{item.attendQuoteFieldId}, + #{item.dataValue}, + #{item.createTime}, + #{item.updateTime}, + #{item.creator}, + #{item.tenantKey} + ) + + + + INSERT INTO hrsa_attend_quote_data_value( + employee_id, + attend_quote_id, + attend_quote_data_id, + attend_quote_field_id, + data_value, + create_time, + update_time, + creator, + tenant_key) + + + select + #{item.employeeId,jdbcType=DOUBLE}, + #{item.attendQuoteId,jdbcType=DOUBLE}, + #{item.attendQuoteDataId,jdbcType=DOUBLE}, + #{item.attendQuoteFieldId,jdbcType=DOUBLE}, + #{item.dataValue,jdbcType=VARCHAR}, + #{item.createTime,jdbcType=DATE}, + #{item.updateTime,jdbcType=DATE}, + #{item.creator,jdbcType=DOUBLE}, + #{item.tenantKey,jdbcType=VARCHAR} + from dual + + + + + INSERT INTO hrsa_attend_quote_data_value( + employee_id, + attend_quote_id, + attend_quote_data_id, + attend_quote_field_id, + data_value, + create_time, + update_time, + creator, + tenant_key) + VALUES + ( + #{item.employeeId}, + #{item.attendQuoteId}, + #{item.attendQuoteDataId}, + #{item.attendQuoteFieldId}, + #{item.dataValue}, + #{item.createTime}, + #{item.updateTime}, + #{item.creator}, + #{item.tenantKey} + ) + + + + + + + + UPDATE hrsa_attend_quote_data_value + SET delete_type = 1 + WHERE delete_type = 0 + AND attend_quote_id IN + + #{attendId} + + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/datacollection/AttendQuoteFieldMapper.java b/src/com/engine/salary/mapper/datacollection/AttendQuoteFieldMapper.java new file mode 100644 index 000000000..01a4f6be6 --- /dev/null +++ b/src/com/engine/salary/mapper/datacollection/AttendQuoteFieldMapper.java @@ -0,0 +1,113 @@ +package com.engine.salary.mapper.datacollection; + +import com.engine.salary.entity.datacollection.dto.AttendQuoteFieldListDTO; +import com.engine.salary.entity.datacollection.param.AttendQuoteFieldQueryParam; +import com.engine.salary.entity.datacollection.po.AttendQuoteFieldPO; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; + +public interface AttendQuoteFieldMapper { + + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + AttendQuoteFieldPO getById(Long id); + + /** + * 新增,忽略null字段 + * + * @param AttendQuoteFieldPO 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(AttendQuoteFieldPO AttendQuoteFieldPO); + + /** + * 修改,修改所有字段 + * + * @param AttendQuoteFieldPO 修改的记录 + * @return 返回影响行数 + */ + int update(AttendQuoteFieldPO AttendQuoteFieldPO); + + /** + * 修改,忽略null字段 + * + * @param AttendQuoteFieldPO 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(AttendQuoteFieldPO AttendQuoteFieldPO); + + /** + * 删除记录 + * + * @param AttendQuoteFieldPO 待删除的记录 + * @return 返回影响行数 + */ + int delete(AttendQuoteFieldPO AttendQuoteFieldPO); + + /** + * 删除考勤的字段 + * + * @param param + * @return + */ + int deleteAttendByCode(@Param("param") AttendQuoteFieldQueryParam param); + + + /** + * 查询数据采集-考勤引用字段列表 + * + * @param param + * @return + */ + List list(@Param("param") AttendQuoteFieldQueryParam param); + + + /** + * 批量删除数据采集-考勤引用字段 + * + * @param ids + */ + void deleteByIds(@Param("ids") Collection ids); + + /** + * 插入 + * + * @param saves + */ + void saveBatch(@Param("saves") List saves); + + /** + * 更新字段名 + * + * @param updates + */ + void updateNameByCode(@Param("updates") List updates); + + /** + * 条件查询 + * + * @param param + * @return + */ + List listSome(@Param("param") AttendQuoteFieldPO param); + + /** + * 获取出勤班次 + * @return + */ + List getAttendanceSerials(); +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/datacollection/AttendQuoteFieldMapper.xml b/src/com/engine/salary/mapper/datacollection/AttendQuoteFieldMapper.xml new file mode 100644 index 000000000..38ad1cf90 --- /dev/null +++ b/src/com/engine/salary/mapper/datacollection/AttendQuoteFieldMapper.xml @@ -0,0 +1,493 @@ + + + + + + + + + + + + + + + + + + + + + t + . + id + , t.field_name + , t.source_type + , t.field_type + , t.enable_status + , t.code + , t.description + , t.create_time + , t.update_time + , t.creator + , t.delete_type + , t.tenant_key + + + + + + + + + + + INSERT INTO hrsa_attend_quote_field + + + + id, + + + field_name, + + + source_type, + + + field_type, + + + enable_status, + + + code, + + + description, + + + create_time, + + + update_time, + + + creator, + + + delete_type, + + + tenant_key, + + + + + #{id}, + + + #{fieldName}, + + + #{sourceType}, + + + #{fieldType}, + + + #{enableStatus}, + + + #{code}, + + + #{description}, + + + #{createTime}, + + + #{updateTime}, + + + #{creator}, + + + #{deleteType}, + + + #{tenantKey}, + + + + + + + select hrsa_attend_quote_field_id.currval from dual + + INSERT INTO hrsa_attend_quote_field + + + + id, + + + field_name, + + + source_type, + + + field_type, + + + enable_status, + + + code, + + + description, + + + create_time, + + + update_time, + + + creator, + + + delete_type, + + + tenant_key, + + + + + #{id}, + + + #{fieldName}, + + + #{sourceType}, + + + #{fieldType}, + + + #{enableStatus}, + + + #{code}, + + + #{description}, + + + #{createTime}, + + + #{updateTime}, + + + #{creator}, + + + #{deleteType}, + + + #{tenantKey}, + + + + + + + UPDATE hrsa_attend_quote_field + + field_name=#{fieldName}, + source_type=#{sourceType}, + field_type=#{fieldType}, + enable_status=#{enableStatus}, + code=#{code}, + description=#{description}, + create_time=#{createTime}, + update_time=#{updateTime}, + creator=#{creator}, + delete_type=#{deleteType}, + tenant_key=#{tenantKey}, + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_attend_quote_field + + + field_name=#{fieldName}, + + + source_type=#{sourceType}, + + + field_type=#{fieldType}, + + + enable_status=#{enableStatus}, + + + code=#{code}, + + + description=#{description}, + + + create_time=#{createTime}, + + + update_time=#{updateTime}, + + + creator=#{creator}, + + + delete_type=#{deleteType}, + + + tenant_key=#{tenantKey}, + + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_attend_quote_field + SET delete_type=1 + WHERE id = #{id} + AND delete_type = 0 + + + + UPDATE hrsa_attend_quote_field + SET delete_type=1 + WHERE delete_type = 0 + AND source_type= 2 + AND code IN + + #{code} + + + + + + + t1 + . + id + , + t1.field_name, + t1.source_type, + t1.field_type, + t1.enable_status, + t1.description + + + + + AND t1.id IN + + #{id} + + + + AND t1.field_name like CONCAT('%',#{param.fieldName},'%') + + + + + AND t1.id IN + + #{id} + + + + AND t1.field_name like '%'||#{param.fieldName}||'%' + + + + + AND t1.id IN + + #{id} + + + + AND t1.field_name like '%'+#{param.fieldName}+'%' + + + + + + + INSERT INTO hrsa_attend_quote_field + (field_name,source_type,field_type,enable_status,code,description,create_time,update_time,creator,delete_type,tenant_key) + VALUES + + ( + #{item.fieldName}, + #{item.sourceType}, + #{item.fieldType}, + #{item.enableStatus}, + #{item.code}, + #{item.description}, + #{item.createTime},#{item.updateTime}, #{item.creator}, 0, #{item.tenantKey} + ) + + + + INSERT INTO hrsa_attend_quote_field + (field_name,source_type,field_type,enable_status,code,description,create_time,update_time,creator,delete_type,tenant_key) + + + select + #{item.fieldName,jdbcType=VARCHAR}, + #{item.sourceType,jdbcType=INTEGER}, + #{item.fieldType,jdbcType=INTEGER}, + #{item.enableStatus,jdbcType=INTEGER}, + #{item.code,jdbcType=VARCHAR}, + #{item.description,jdbcType=VARCHAR}, + #{item.createTime,jdbcType=DATE}, + #{item.updateTime,jdbcType=DATE}, + #{item.creator,jdbcType=DOUBLE}, + 0, + #{item.tenantKey,jdbcType=VARCHAR} + from dual + + + + + INSERT INTO hrsa_attend_quote_field + (field_name,source_type,field_type,enable_status,code,description,create_time,update_time,creator,delete_type,tenant_key) + VALUES + ( + #{item.fieldName}, + #{item.sourceType}, + #{item.fieldType}, + #{item.enableStatus}, + #{item.code}, + #{item.description}, + #{item.createTime},#{item.updateTime}, #{item.creator}, 0, #{item.tenantKey} + ) + + + + + update hrsa_attend_quote_field + + + + + when code=#{item.code} then #{item.fieldName} + + + + + + + when code=#{item.code} then #{item.updateTime} + + + + + where + + + + code in + + #{item.code} + + + + + + UPDATE hrsa_attend_quote_field + + + field_name=#{item.fieldName}, + + + update_time=#{item.updateTime}, + + + WHERE code = #{item.code} + + + + + + + + + UPDATE hrsa_attend_quote_field + SET delete_type=1 + WHERE + id IN + + #{id} + + AND delete_type = 0 + + + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/datacollection/AttendQuoteMapper.java b/src/com/engine/salary/mapper/datacollection/AttendQuoteMapper.java new file mode 100644 index 000000000..ac368db28 --- /dev/null +++ b/src/com/engine/salary/mapper/datacollection/AttendQuoteMapper.java @@ -0,0 +1,83 @@ +package com.engine.salary.mapper.datacollection; + +import com.engine.salary.entity.datacollection.dto.AttendQuoteListDTO; +import com.engine.salary.entity.datacollection.param.AttendQuoteQueryParam; +import com.engine.salary.entity.datacollection.po.AttendQuotePO; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; + + +public interface AttendQuoteMapper { + + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + AttendQuotePO getById(Long id); + + /** + * 新增,忽略null字段 + * + * @param AttendQuotePO 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(AttendQuotePO AttendQuotePO); + + /** + * 修改,修改所有字段 + * + * @param AttendQuotePO 修改的记录 + * @return 返回影响行数 + */ + int update(AttendQuotePO AttendQuotePO); + + /** + * 修改,忽略null字段 + * + * @param AttendQuotePO 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(AttendQuotePO AttendQuotePO); + + /** + * 删除记录 + * + * @param AttendQuotePO 待删除的记录 + * @return 返回影响行数 + */ + int delete(AttendQuotePO AttendQuotePO); + + + /** + * 查询数据采集-考勤引用列表 + * + * @param param + * @return + */ + List list(@Param("param") AttendQuoteQueryParam param); + + + /** + * 批量删除数据采集-考勤引用 + * + * @param ids + */ + void deleteByIds(@Param("ids") Collection ids); + + List listSome(@Param("param") AttendQuotePO param); + + +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/datacollection/AttendQuoteMapper.xml b/src/com/engine/salary/mapper/datacollection/AttendQuoteMapper.xml new file mode 100644 index 000000000..68424e89e --- /dev/null +++ b/src/com/engine/salary/mapper/datacollection/AttendQuoteMapper.xml @@ -0,0 +1,319 @@ + + + + + + + + + + + + + + + + + + + + + + + + t + . + id + , t.salary_year_month + , t.year + , t.month + , t.salary_sob_id + , t.source_type + , t.salary_accounting_status + , t.attend_cycle + , t.salary_cycle + , t.description + , t.create_time + , t.update_time + , t.creator + , t.delete_type + , t.tenant_key + + + + + + + + + + + INSERT INTO hrsa_attend_quote + + + + id, + + + salary_year_month, + + + year, + + + month, + + + salary_sob_id, + + + source_type, + + + salary_accounting_status, + + + attend_cycle, + + + salary_cycle, + + + description, + + + create_time, + + + update_time, + + + creator, + + + delete_type, + + + tenant_key, + + + + + #{id}, + + + #{salaryYearMonth}, + + + #{year}, + + + #{month}, + + + #{salarySobId}, + + + #{sourceType}, + + + #{salaryAccountingStatus}, + + + #{attendCycle}, + + + #{salaryCycle}, + + + #{description}, + + + #{createTime}, + + + #{updateTime}, + + + #{creator}, + + + #{deleteType}, + + + #{tenantKey}, + + + + + + + UPDATE hrsa_attend_quote + + salary_year_month=#{salaryYearMonth}, + year=#{year}, + month=#{month}, + salary_sob_id=#{salarySobId}, + source_type=#{sourceType}, + salary_accounting_status=#{salaryAccountingStatus}, + attend_cycle=#{attendCycle}, + salary_cycle=#{salaryCycle}, + description=#{description}, + create_time=#{createTime}, + update_time=#{updateTime}, + creator=#{creator}, + delete_type=#{deleteType}, + tenant_key=#{tenantKey}, + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_attend_quote + + + salary_year_month=#{salaryYearMonth}, + + + year=#{year}, + + + month=#{month}, + + + salary_sob_id=#{salarySobId}, + + + source_type=#{sourceType}, + + + salary_accounting_status=#{salaryAccountingStatus}, + + + attend_cycle=#{attendCycle}, + + + salary_cycle=#{salaryCycle}, + + + description=#{description}, + + + create_time=#{createTime}, + + + update_time=#{updateTime}, + + + creator=#{creator}, + + + delete_type=#{deleteType}, + + + tenant_key=#{tenantKey}, + + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_attend_quote + SET delete_type=1 + WHERE id = #{id} + AND delete_type = 0 + + + + + t1 + . + id + , + t1.salary_year_month, + t1.salary_sob_id AS salarySobId, + t2.name AS salary_sob_name, + t1.source_type, + t1.attend_cycle, + t1.salary_cycle, + t1.description, + e.lastname AS creator, + t1.salary_accounting_status + + + + + AND t1.id IN + + #{id} + + + + AND t1.salary_sob_id IN + + #{id} + + + + + + AND t1.salary_year_month = #{param.salaryYearMonthDate[0]} + + + AND (t1.salary_year_month BETWEEN #{param.salaryYearMonthDate[0]} AND #{param.salaryYearMonthDate[1]}) + + + + + + + + UPDATE hrsa_attend_quote + SET delete_type = 1 + WHERE delete_type = 0 + AND id IN + + #{id} + + + + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/datacollection/AttendQuoteSyncSetMapper.java b/src/com/engine/salary/mapper/datacollection/AttendQuoteSyncSetMapper.java new file mode 100644 index 000000000..929bfca26 --- /dev/null +++ b/src/com/engine/salary/mapper/datacollection/AttendQuoteSyncSetMapper.java @@ -0,0 +1,67 @@ +package com.engine.salary.mapper.datacollection; + +import com.engine.salary.entity.datacollection.po.AttendQuoteFieldSettingPO; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + + +public interface AttendQuoteSyncSetMapper { + + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + AttendQuoteFieldSettingPO getById(Long id); + + /** + * 新增,忽略null字段 + * + * @param AttendQuoteSyncSetPO 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(AttendQuoteFieldSettingPO AttendQuoteSyncSetPO); + + /** + * 修改,修改所有字段 + * + * @param AttendQuoteSyncSetPO 修改的记录 + * @return 返回影响行数 + */ + int update(AttendQuoteFieldSettingPO AttendQuoteSyncSetPO); + + /** + * 修改,忽略null字段 + * + * @param AttendQuoteSyncSetPO 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(AttendQuoteFieldSettingPO AttendQuoteSyncSetPO); + + /** + * 删除记录 + * + * @param AttendQuoteSyncSetPO 待删除的记录 + * @return 返回影响行数 + */ + int delete(AttendQuoteFieldSettingPO AttendQuoteSyncSetPO); + + /** + * 条件查询 + * @param param + * @return + */ + List listSome(@Param("param")AttendQuoteFieldSettingPO param); + +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/datacollection/AttendQuoteSyncSetMapper.xml b/src/com/engine/salary/mapper/datacollection/AttendQuoteSyncSetMapper.xml new file mode 100644 index 000000000..4239b9155 --- /dev/null +++ b/src/com/engine/salary/mapper/datacollection/AttendQuoteSyncSetMapper.xml @@ -0,0 +1,249 @@ + + + + + + + + + + + + + + + + + + t + . + id + , t.source_type + , t.current_setting_content + , t.default_setting_content + , t.create_time + , t.update_time + , t.creator + , t.delete_type + , t.tenant_key + + + + + + + + + + + INSERT INTO hrsa_attend_quote_sync_set + + + + id, + + + source_type, + + + current_setting_content, + + + default_setting_content, + + + create_time, + + + update_time, + + + creator, + + + delete_type, + + + tenant_key, + + + + + #{id}, + + + #{sourceType}, + + + #{currentSettingContent}, + + + #{defaultSettingContent}, + + + #{createTime}, + + + #{updateTime}, + + + #{creator}, + + + #{deleteType}, + + + #{tenantKey}, + + + + + + + select hrsa_attend_quote_sync_set_id.currval from dual + + INSERT INTO hrsa_attend_quote_sync_set + + + + id, + + + source_type, + + + current_setting_content, + + + default_setting_content, + + + create_time, + + + update_time, + + + creator, + + + delete_type, + + + tenant_key, + + + + + #{id}, + + + #{sourceType}, + + + #{currentSettingContent}, + + + #{defaultSettingContent}, + + + #{createTime}, + + + #{updateTime}, + + + #{creator}, + + + #{deleteType}, + + + #{tenantKey}, + + + + + + + UPDATE hrsa_attend_quote_sync_set + + source_type=#{sourceType}, + current_setting_content=#{currentSettingContent}, + default_setting_content=#{defaultSettingContent}, + create_time=#{createTime}, + update_time=#{updateTime}, + creator=#{creator}, + delete_type=#{deleteType}, + tenant_key=#{tenantKey}, + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_attend_quote_sync_set + + + source_type=#{sourceType}, + + + current_setting_content=#{currentSettingContent}, + + + default_setting_content=#{defaultSettingContent}, + + + create_time=#{createTime}, + + + update_time=#{updateTime}, + + + creator=#{creator}, + + + delete_type=#{deleteType}, + + + tenant_key=#{tenantKey}, + + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_attend_quote_sync_set + SET delete_type=1 + WHERE id = #{id} + AND delete_type = 0 + + + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/datacollection/EmployMapper.java b/src/com/engine/salary/mapper/datacollection/EmployMapper.java new file mode 100644 index 000000000..120c7a352 --- /dev/null +++ b/src/com/engine/salary/mapper/datacollection/EmployMapper.java @@ -0,0 +1,184 @@ +package com.engine.salary.mapper.datacollection; + +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.hrm.DeptInfo; +import com.engine.salary.entity.hrm.JobCallInfo; +import com.engine.salary.entity.hrm.PositionInfo; +import com.engine.salary.entity.hrm.SubCompanyInfo; +import com.engine.salary.entity.hrm.dto.HrmInfoDTO; +import com.engine.salary.entity.hrm.param.HrmQueryParam; +import com.engine.salary.entity.salarysob.param.SalarySobRangeEmpQueryParam; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; + + +public interface EmployMapper { + + /** + * 只查人力资源表 + * @return + */ + List listAll(); + + /** + * 获取所有员工,关联部门 + * + * @return + */ + List listEmployee(); + + /** + * 单表查询 + * @param ids + * @return + */ + List getEmployeeByIds(@Param("collection") List ids); + + /** + * 单表查询 包括次账号 + * @param ids + * @return + */ + List getEmployeeByIdsIncludeAccountType(@Param("collection") List ids); + + /** + * 多表联查 + * @param ids + * @return + */ + List getEmployeeByIdsAll(@Param("collection") List ids); + + + /** + * 根据薪资账套的人员范围转换而成的查询参数查询人员 + * + * @param queryParams 薪资账套的人员范围转换而成的查询参数 + * @return + */ + List listByParams(@Param("params") Collection queryParams); + + List listByVirtualParams(@Param("params") Collection queryParams); + + + /** + * 多表,详细信息 + * @param employeeId + * @return + */ + DataCollectionEmployee getEmployeeById(Long employeeId); + + /** + * 报表专用 + * @return + */ + List listAllForReport(); + + /** + * 所以岗位 + * @param ids + * @return + */ + List listPositionInfo(@Param("collection") List ids); + + /** + * 所以岗位id 获取岗位信息 + * @param id + * @return + */ + PositionInfo getPositionInfoById(@Param("positionId") Long id); + + /** + * 所以部门 + * @param departmentIds + * @return + */ + List getDeptInfoList(@Param("departmentIds") List departmentIds); + + + /** + * 虚拟部门(其他组织维度) + * @param virtualDepartmentIds + * @return + */ + List getVirtualDeptInfoList(@Param("virtualDepartmentIds") List virtualDepartmentIds); + + + /** + * 所以分部 + * @param subDepartmentIds + * @return + */ + List getSubCompanyInfoList(@Param("subDepartmentIds") List subDepartmentIds); + + /** + * 根据分部id获取分部信息 + * @param subDepartmentId + * @return + */ + SubCompanyInfo getSubCompanyInfoById(@Param("subDepartmentId")Long subDepartmentId); + + /** + * 虚拟分部 + * @param virtualSubCompanyIds + * @return + */ + List getVirtualSubCompanyInfoList(@Param("virtualSubCompanyIds") List virtualSubCompanyIds); + + + List listHrmInfoByIdAndName(@Param("param") HrmQueryParam param); + List listExtHrmInfoByIdAndName(@Param("param") HrmQueryParam param); + + + /** + * 根据部门名称查询部门 + */ + List getDeptInfosByName(String name); + + /** + * 根据分部名称查询分部 + */ + List getSubCompanyInfosByName(String name); + + /** + * 根据部门id查询部门 + */ + DeptInfo getDeptInfoById(Long id); + + /** + * 获取大于离职日期的 离职、退休、解聘人员信息 + * @return + */ + List listByDismissDate(String dismissDate); + + /** + * 根据虚拟部门获取人员信息 + * @param virtualDepartmentIds + * @return + */ + List listVirtualEmpByVirtualDepIds(@Param("virtualDepartmentIds") List virtualDepartmentIds); + + /** + * 根据虚拟分部获取人员信息 + * @param virtualSubCompanyIds + * @return + */ + List listVirtualEmpByVirtualSubCompanyIds(@Param("virtualSubCompanyIds") List virtualSubCompanyIds); + + /** + * 根据分部、部门获取查询 + * @param subCompanyIds + * @param departmentIds + * @return + */ + List listBySubCompanyOrDepartment(@Param("subCompanyIds") List subCompanyIds, @Param("departmentIds") List departmentIds); + + JobCallInfo getJobCallInfoById(@Param("jobCallId") Long jobCallId); + + List listBySubCompany(@Param("subCompanyIds") List subCompanyIds); + + List listByDepartment(@Param("departmentIds") List departmentIds); + + List listByJob(@Param("jobIds") List jobIds); +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/datacollection/EmployMapper.xml b/src/com/engine/salary/mapper/datacollection/EmployMapper.xml new file mode 100644 index 000000000..fb71c7ffe --- /dev/null +++ b/src/com/engine/salary/mapper/datacollection/EmployMapper.xml @@ -0,0 +1,665 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + AND + ( + a.lastname like CONCAT('%',#{userName},'%') + ) + + + + + AND + ( + a.lastname like '%'||#{userName}||'%' + ) + + + + + AND + ( + a.lastname like '%'+#{userName}+'%' + ) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/datacollection/OtherDeductionMapper.java b/src/com/engine/salary/mapper/datacollection/OtherDeductionMapper.java new file mode 100644 index 000000000..7638a60cc --- /dev/null +++ b/src/com/engine/salary/mapper/datacollection/OtherDeductionMapper.java @@ -0,0 +1,52 @@ +package com.engine.salary.mapper.datacollection; + +import com.engine.salary.entity.datacollection.dto.OtherDeductionListDTO; +import com.engine.salary.entity.datacollection.dto.OtherDeductionRecordDTO; +import com.engine.salary.entity.datacollection.param.OtherDeductionQueryParam; +import com.engine.salary.entity.datacollection.po.OtherDeductionPO; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + + +public interface OtherDeductionMapper { + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + OtherDeductionPO getById(Long id); + + + /** + * 查询数据采集-其他免税扣除列表 + * @param param + * @return + */ + List list(@Param("param") OtherDeductionQueryParam param); + + + List recordList(@Param("param") OtherDeductionQueryParam param); + + List listSome(@Param("param") OtherDeductionPO param); + + /** + * 批量插入 + * @param pos + */ + void insertData(@Param("collection") List pos); + + /** + * 批量修改 + * @param pos + */ + void updateData(@Param("collection") List pos); + + /** + * 批量删除 + * @param longs + */ + void deleteData(List longs); +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/datacollection/OtherDeductionMapper.xml b/src/com/engine/salary/mapper/datacollection/OtherDeductionMapper.xml new file mode 100644 index 000000000..f21fed4a1 --- /dev/null +++ b/src/com/engine/salary/mapper/datacollection/OtherDeductionMapper.xml @@ -0,0 +1,483 @@ + + + + + + + + + + + + + + + + + + + + + + + t + . + id + , t.employee_id + , t.tax_agent_id + , t.declare_month + , t.business_healthy_insurance + , t.tax_delay_endowment_insurance + , t.other_deduction + , t.deduction_allowed_donation + , t.create_time + , t.update_time + , t.creator + , t.delete_type + , t.tenant_key + , t.private_pension + + + + + UPDATE hrsa_other_deduction + SET delete_type = 1 + WHERE delete_type = 0 + AND id IN + + #{id} + + + + + + + + + + + + t1 + . + id + , + t1.declare_month, + t1.employee_id, + t2.id AS tax_agent_id, + t2.name AS tax_agent_name, + e.lastname as username, + e.certificatenum as idNo, + d.departmentname AS departmentName, + e.mobile, + e.workcode as job_num, + e.companystartdate as hiredate, + t1.business_healthy_insurance, + t1.tax_delay_endowment_insurance, + t1.other_deduction, + t1.deduction_allowed_donation, + t1.private_pension + + + + + AND t1.id IN + + #{id} + + + + AND t1.employee_id = #{param.employeeId} + + + + AND + ( + e.lastname like CONCAT('%',#{param.keyword},'%') + OR d.departmentname like CONCAT('%',#{param.keyword},'%') + OR e.workcode like CONCAT('%',#{param.keyword},'%') + ) + + + + + AND t1.declare_month = #{param.declareMonthDate[0]} + + + AND (t1.declare_month BETWEEN #{param.declareMonthDate[0]} AND #{param.declareMonthDate[1]}) + + + + + AND e.lastname like CONCAT('%',#{param.username},'%') + + + + AND t1.tax_agent_id = #{param.taxAgentId} + + + AND t1.tax_agent_id IN + + #{id} + + + + + AND d.id IN + + #{id} + + + + + AND e.workcode like CONCAT('%',#{param.jobNum},'%') + + + + AND (e.companystartdate BETWEEN #{param.hiredate[0]} AND #{param.hiredate[1]}) + + + + AND e.mobile like CONCAT('%',#{param.mobile},'%') + + + + + AND t1.id IN + + #{id} + + + + AND t1.employee_id = #{param.employeeId} + + + + AND + ( + e.lastname like '%'||#{param.keyword}||'%' + OR d.departmentname like '%'||#{param.keyword}||'%' + OR e.workcode like '%'||#{param.keyword}||'%' + ) + + + + + AND t1.declare_month = #{param.declareMonthDate[0]} + + + AND (t1.declare_month BETWEEN #{param.declareMonthDate[0]} AND #{param.declareMonthDate[1]}) + + + + + AND e.lastname like '%'||#{param.username}||'%' + + + + AND t1.tax_agent_id = #{param.taxAgentId} + + + AND t1.tax_agent_id IN + + #{id} + + + + AND d.id IN + + #{id} + + + + + AND e.workcode like '%'||#{param.jobNum}||'%' + + + + AND (e.companystartdate BETWEEN #{param.hiredate[0]} AND #{param.hiredate[1]}) + + + + AND e.mobile like '%'||#{param.mobile}||'%' + + + + + AND t1.id IN + + #{id} + + + + AND t1.employee_id = #{param.employeeId} + + + + AND + ( + e.lastname like '%'+#{param.keyword}+'%' + OR d.departmentname like '%'+#{param.keyword}+'%' + OR e.workcode like '%'+#{param.keyword}+'%' + ) + + + + + AND t1.declare_month = #{param.declareMonthDate[0]} + + + AND (t1.declare_month BETWEEN #{param.declareMonthDate[0]} AND #{param.declareMonthDate[1]}) + + + + + AND e.lastname like '%'+#{param.username}+'%' + + + + AND t1.tax_agent_id = #{param.taxAgentId} + + + AND t1.tax_agent_id IN + + #{id} + + + + AND d.id IN + + #{id} + + + + + AND e.workcode like '%'+#{param.jobNum}+'%' + + + + AND (e.companystartdate BETWEEN #{param.hiredate[0]} AND #{param.hiredate[1]}) + + + + AND e.mobile like '%'+#{param.mobile}+'%' + + + + + + + + + + + INSERT INTO hrsa_other_deduction( + employee_id, + tax_agent_id, + declare_month, + business_healthy_insurance, + tax_delay_endowment_insurance, + other_deduction, + deduction_allowed_donation, + private_pension, + create_time, + update_time, + creator, + tenant_key + ) + VALUES + + ( + #{item.employeeId}, + #{item.taxAgentId}, + #{item.declareMonth}, + #{item.businessHealthyInsurance}, + #{item.taxDelayEndowmentInsurance}, + #{item.otherDeduction}, + #{item.deductionAllowedDonation}, + #{item.privatePension}, + #{item.createTime}, + #{item.updateTime}, + #{item.creator}, + #{item.tenantKey} + ) + + + + INSERT INTO hrsa_other_deduction( + employee_id, + tax_agent_id, + declare_month, + business_healthy_insurance, + tax_delay_endowment_insurance, + other_deduction, + deduction_allowed_donation, + private_pension, + create_time, + update_time, + creator, + tenant_key + ) + + + select + #{item.employeeId,jdbcType=DOUBLE}, + #{item.taxAgentId,jdbcType=DOUBLE}, + #{item.declareMonth,jdbcType=DATE}, + #{item.businessHealthyInsurance,jdbcType=VARCHAR}, + #{item.taxDelayEndowmentInsurance,jdbcType=VARCHAR}, + #{item.otherDeduction,jdbcType=VARCHAR}, + #{item.deductionAllowedDonation,jdbcType=VARCHAR}, + #{item.privatePension,jdbcType=VARCHAR}, + #{item.createTime,jdbcType=DATE}, + #{item.updateTime,jdbcType=DATE}, + #{item.creator,jdbcType=DOUBLE}, + #{item.tenantKey,jdbcType=VARCHAR} + from dual + + + + + INSERT INTO hrsa_other_deduction( + employee_id, + tax_agent_id, + declare_month, + business_healthy_insurance, + tax_delay_endowment_insurance, + other_deduction, + deduction_allowed_donation, + private_pension, + create_time, + update_time, + creator, + tenant_key + ) + VALUES + ( + #{item.employeeId}, + #{item.taxAgentId}, + #{item.declareMonth}, + #{item.businessHealthyInsurance}, + #{item.taxDelayEndowmentInsurance}, + #{item.otherDeduction}, + #{item.deductionAllowedDonation}, + #{item.privatePension}, + #{item.createTime}, + #{item.updateTime}, + #{item.creator}, + #{item.tenantKey} + ) + + + + + update hrsa_other_deduction + + + + + when id=#{item.id} then #{item.businessHealthyInsurance} + + + + + + + when id=#{item.id} then #{item.taxDelayEndowmentInsurance} + + + + + + + when id=#{item.id} then #{item.otherDeduction} + + + + + + + when id=#{item.id} then #{item.deductionAllowedDonation} + + + + + + + when id=#{item.id} then #{item.privatePension} + + + + + + + when id=#{item.id} then #{item.updateTime} + + + + + where + id in + + #{item.id} + + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/datacollection/SpecialAddDeductionMapper.java b/src/com/engine/salary/mapper/datacollection/SpecialAddDeductionMapper.java new file mode 100644 index 000000000..1ab7d778a --- /dev/null +++ b/src/com/engine/salary/mapper/datacollection/SpecialAddDeductionMapper.java @@ -0,0 +1,37 @@ +package com.engine.salary.mapper.datacollection; + +import com.engine.salary.entity.datacollection.dto.SpecialAddDeductionListDTO; +import com.engine.salary.entity.datacollection.dto.SpecialAddDeductionRecordDTO; +import com.engine.salary.entity.datacollection.param.SpecialAddDeductionQueryParam; +import com.engine.salary.entity.datacollection.po.SpecialAddDeductionPO; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +public interface SpecialAddDeductionMapper { + int insertSelective(SpecialAddDeductionPO record); + + int updateByPrimaryKeySelective(SpecialAddDeductionPO record); + + SpecialAddDeductionPO getById(Long id); + + int updateBatchSelective(@Param("list") List list); + + int batchInsert(@Param("list") List list); + + List listDtoByParam(@Param("param") SpecialAddDeductionQueryParam param); + + List listByTaxAgentIds(@Param("taxAgentIds") List taxAgentIds); + + List listByParam(@Param("param") SpecialAddDeductionQueryParam param); + + int deleteByIds(@Param("ids")List id); + + + List getByEmployeeIds(@Param("employeeIds") List employeeIds, + @Param("taxAgentId") Long taxAgentId); + + List listAll(); + + List listSome(SpecialAddDeductionPO specialAddDeduction); +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/datacollection/SpecialAddDeductionMapper.xml b/src/com/engine/salary/mapper/datacollection/SpecialAddDeductionMapper.xml new file mode 100644 index 000000000..442fe485e --- /dev/null +++ b/src/com/engine/salary/mapper/datacollection/SpecialAddDeductionMapper.xml @@ -0,0 +1,755 @@ + + + + + + + + + + + + + + + + + + + + + + + + + t1.id, + t1.employee_id, + t1.tax_agent_id, + t1.children_education, + t1.continuing_education, + t1.housing_loan_interest, + t1.housing_rent, + t1.supporting_elder, + t1.serious_illness_treatment, + t1.infant_care, + t1.create_time, + t1.update_time, + t1.creator, + t1.delete_type, + t1.tenant_key + + + + t1.id, + t1.employee_id, + t2.id AS tax_agent_id, + t2.name AS tax_agent_name, + e.lastname as username, + e.certificatenum as idNo, + d.departmentname AS departmentName, + e.mobile, + e.workcode as job_num, + e.companystartdate as hiredate, + t1.children_education, + t1.continuing_education, + t1.housing_loan_interest, + t1.housing_rent, + t1.serious_illness_treatment, + t1.supporting_elder, + t1.infant_care + + + + + AND t1.id IN + + #{id} + + + + AND t1.id = #{param.specialAddDeductionId} + + + AND t1.employee_id = #{param.employeeId} + + + + AND + ( + e.lastname like CONCAT('%',#{param.keyword},'%') + OR d.departmentname like CONCAT('%',#{param.keyword},'%') + OR e.workcode like CONCAT('%',#{param.keyword},'%') + ) + + + + AND e.lastname like CONCAT('%',#{param.username},'%') + + + + AND t1.tax_agent_id = #{param.taxAgentId} + + + AND t1.tax_agent_id IN + + #{id} + + + + + AND d.id IN + + #{id} + + + + + AND e.workcode like CONCAT('%',#{param.jobNum},'%') + + + + AND (e.companystartdate BETWEEN #{param.hiredate[0]} AND #{param.hiredate[1]}) + + + + AND e.mobile like CONCAT('%',#{param.mobile},'%') + + + + + AND t1.id IN + + #{id} + + + + AND t1.id = #{param.specialAddDeductionId} + + + AND t1.employee_id = #{param.employeeId} + + + + AND + ( + e.lastname like '%'||#{param.keyword}||'%' + OR d.departmentname like '%'||#{param.keyword}||'%' + OR e.workcode like '%'||#{param.keyword}||'%' + ) + + + + AND e.lastname like '%'||#{param.username}||'%' + + + + AND t1.tax_agent_id = #{param.taxAgentId} + + + AND t1.tax_agent_id IN + + #{id} + + + + AND d.id IN + + #{id} + + + + + AND e.workcode like '%'||#{param.jobNum}||'%' + + + + AND (e.companystartdate BETWEEN #{param.hiredate[0]} AND #{param.hiredate[1]}) + + + + AND e.mobile like '%'||#{param.mobile}||'%' + + + + + AND t1.id IN + + #{id} + + + + AND t1.id = #{param.specialAddDeductionId} + + + AND t1.employee_id = #{param.employeeId} + + + + AND + ( + e.lastname like '%'+#{param.keyword}+'%' + OR d.departmentname like '%'+#{param.keyword}+'%' + OR e.workcode like '%'+#{param.keyword}+'%' + ) + + + + AND e.lastname like '%'+#{param.username}+'%' + + + + AND t1.tax_agent_id = #{param.taxAgentId} + + + AND t1.tax_agent_id IN + + #{id} + + + + AND d.id IN + + #{id} + + + + + AND e.workcode like '%'+#{param.jobNum}+'%' + + + + AND (e.companystartdate BETWEEN #{param.hiredate[0]} AND #{param.hiredate[1]}) + + + + AND e.mobile like '%'+#{param.mobile}+'%' + + + + + + + insert into hrsa_special_add_deduction + + + employee_id, + + + tax_agent_id, + + + children_education, + + + continuing_education, + + + housing_loan_interest, + + + housing_rent, + + + supporting_elder, + + + serious_illness_treatment, + + + infant_care, + + + create_time, + + + update_time, + + + creator, + + delete_type, + + tenant_key, + + + + + #{employeeId,jdbcType=BIGINT}, + + + #{taxAgentId,jdbcType=BIGINT}, + + + #{childrenEducation,jdbcType=VARCHAR}, + + + #{continuingEducation,jdbcType=VARCHAR}, + + + #{housingLoanInterest,jdbcType=VARCHAR}, + + + #{housingRent,jdbcType=VARCHAR}, + + + #{supportingElder,jdbcType=VARCHAR}, + + + #{seriousIllnessTreatment,jdbcType=VARCHAR}, + + + #{infantCare,jdbcType=VARCHAR}, + + + #{createTime,jdbcType=TIMESTAMP}, + + + #{updateTime,jdbcType=TIMESTAMP}, + + + #{creator,jdbcType=BIGINT}, + + 0, + + #{tenantKey,jdbcType=VARCHAR}, + + + + + + select hrsa_special_a_d_id.currval from dual + + insert into hrsa_special_add_deduction + + + employee_id, + + + tax_agent_id, + + + children_education, + + + continuing_education, + + + housing_loan_interest, + + + housing_rent, + + + supporting_elder, + + + serious_illness_treatment, + + + infant_care, + + + create_time, + + + update_time, + + + creator, + + delete_type, + + tenant_key, + + + + + #{employeeId,jdbcType=BIGINT}, + + + #{taxAgentId,jdbcType=BIGINT}, + + + #{childrenEducation,jdbcType=VARCHAR}, + + + #{continuingEducation,jdbcType=VARCHAR}, + + + #{housingLoanInterest,jdbcType=VARCHAR}, + + + #{housingRent,jdbcType=VARCHAR}, + + + #{supportingElder,jdbcType=VARCHAR}, + + + #{seriousIllnessTreatment,jdbcType=VARCHAR}, + + + #{infantCare,jdbcType=VARCHAR}, + + + #{createTime,jdbcType=TIMESTAMP}, + + + #{updateTime,jdbcType=TIMESTAMP}, + + + #{creator,jdbcType=BIGINT}, + + 0, + + #{tenantKey,jdbcType=VARCHAR}, + + + + + + update hrsa_special_add_deduction + + + employee_id = #{employeeId,jdbcType=BIGINT}, + + + tax_agent_id = #{taxAgentId,jdbcType=BIGINT}, + + + children_education = #{childrenEducation,jdbcType=VARCHAR}, + + + continuing_education = #{continuingEducation,jdbcType=VARCHAR}, + + + housing_loan_interest = #{housingLoanInterest,jdbcType=VARCHAR}, + + + housing_rent = #{housingRent,jdbcType=VARCHAR}, + + + supporting_elder = #{supportingElder,jdbcType=VARCHAR}, + + + serious_illness_treatment = #{seriousIllnessTreatment,jdbcType=VARCHAR}, + + + infant_care = #{infantCare,jdbcType=VARCHAR}, + + + create_time = #{createTime,jdbcType=TIMESTAMP}, + + + update_time = #{updateTime,jdbcType=TIMESTAMP}, + + + creator = #{creator,jdbcType=BIGINT}, + + + delete_type = #{deleteType,jdbcType=INTEGER}, + + + tenant_key = #{tenantKey,jdbcType=VARCHAR}, + + + where id = #{id,jdbcType=BIGINT} + + + + + update hrsa_special_add_deduction + + + + + when id = #{item.id,jdbcType=BIGINT} then #{item.employeeId,jdbcType=BIGINT} + + + + + + + when id = #{item.id,jdbcType=BIGINT} then #{item.taxAgentId,jdbcType=BIGINT} + + + + + + + when id = #{item.id,jdbcType=BIGINT} then #{item.childrenEducation,jdbcType=VARCHAR} + + + + + + + when id = #{item.id,jdbcType=BIGINT} then #{item.continuingEducation,jdbcType=VARCHAR} + + + + + + + when id = #{item.id,jdbcType=BIGINT} then #{item.housingLoanInterest,jdbcType=VARCHAR} + + + + + + + when id = #{item.id,jdbcType=BIGINT} then #{item.housingRent,jdbcType=VARCHAR} + + + + + + + when id = #{item.id,jdbcType=BIGINT} then #{item.supportingElder,jdbcType=VARCHAR} + + + + + + + when id = #{item.id,jdbcType=BIGINT} then #{item.seriousIllnessTreatment,jdbcType=VARCHAR} + + + + + + + when id = #{item.id,jdbcType=BIGINT} then #{item.infantCare,jdbcType=VARCHAR} + + + + + + + when id = #{item.id,jdbcType=BIGINT} then #{item.createTime,jdbcType=TIMESTAMP} + + + + + + + when id = #{item.id,jdbcType=BIGINT} then #{item.updateTime,jdbcType=TIMESTAMP} + + + + + + + when id = #{item.id,jdbcType=BIGINT} then #{item.creator,jdbcType=BIGINT} + + + + + + + when id = #{item.id,jdbcType=BIGINT} then #{item.deleteType,jdbcType=INTEGER} + + + + + + + when id = #{item.id,jdbcType=BIGINT} then #{item.tenantKey,jdbcType=VARCHAR} + + + + + where id in + + #{item.id,jdbcType=BIGINT} + + + + + + insert into hrsa_special_add_deduction + (employee_id, tax_agent_id, children_education, continuing_education, + housing_loan_interest, housing_rent, supporting_elder, serious_illness_treatment, + infant_care, create_time, update_time, creator, delete_type, tenant_key) + values + + (#{item.employeeId,jdbcType=BIGINT}, #{item.taxAgentId,jdbcType=BIGINT}, + #{item.childrenEducation,jdbcType=VARCHAR}, #{item.continuingEducation,jdbcType=VARCHAR}, + #{item.housingLoanInterest,jdbcType=VARCHAR}, #{item.housingRent,jdbcType=VARCHAR}, + #{item.supportingElder,jdbcType=VARCHAR}, #{item.seriousIllnessTreatment,jdbcType=VARCHAR}, + #{item.infantCare,jdbcType=VARCHAR}, #{item.createTime,jdbcType=TIMESTAMP}, + #{item.updateTime,jdbcType=TIMESTAMP}, + #{item.creator,jdbcType=BIGINT}, 0, #{item.tenantKey,jdbcType=VARCHAR}) + + + + + insert into hrsa_special_add_deduction + (employee_id, tax_agent_id, children_education, continuing_education, + housing_loan_interest, housing_rent, supporting_elder, serious_illness_treatment, + infant_care, create_time, update_time, creator, delete_type, tenant_key) + + select + #{item.employeeId,jdbcType=BIGINT}, #{item.taxAgentId,jdbcType=BIGINT}, + #{item.childrenEducation,jdbcType=VARCHAR}, #{item.continuingEducation,jdbcType=VARCHAR}, + #{item.housingLoanInterest,jdbcType=VARCHAR}, #{item.housingRent,jdbcType=VARCHAR}, + #{item.supportingElder,jdbcType=VARCHAR}, #{item.seriousIllnessTreatment,jdbcType=VARCHAR}, + #{item.infantCare,jdbcType=VARCHAR}, #{item.createTime,jdbcType=TIMESTAMP}, + #{item.updateTime,jdbcType=TIMESTAMP}, + #{item.creator,jdbcType=BIGINT}, 0, #{item.tenantKey,jdbcType=VARCHAR} + from dual + + + + + + + + + + + update hrsa_special_add_deduction + set delete_type = 1 + where id in ( + + #{id} + + ) and delete_type = 0 + + + + + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/datacollection/VariableArchiveItemMapper.java b/src/com/engine/salary/mapper/datacollection/VariableArchiveItemMapper.java new file mode 100644 index 000000000..28a30febe --- /dev/null +++ b/src/com/engine/salary/mapper/datacollection/VariableArchiveItemMapper.java @@ -0,0 +1,89 @@ +package com.engine.salary.mapper.datacollection; + +import com.engine.salary.entity.datacollection.po.VariableArchiveItemPO; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * @author Harryxzy + * @ClassName VariableArchiveItemMapper + * @date 2024/08/07 9:22 + * @description 浮动薪酬档案明细 + */ +public interface VariableArchiveItemMapper { + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + /** + * 条件查询 + * + * @return 返回集合,没有返回空List + */ + List listSome(@Param("param") VariableArchiveItemPO variableArchiveItem); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + VariableArchiveItemPO getById(Long id); + + /** + * 新增,忽略null字段 + * + * @param variableArchiveItem 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(VariableArchiveItemPO variableArchiveItem); + + /** + * 修改,修改所有字段 + * + * @param variableArchiveItem 修改的记录 + * @return 返回影响行数 + */ + int update(VariableArchiveItemPO variableArchiveItem); + + /** + * 修改,忽略null字段 + * + * @param variableArchiveItem 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(VariableArchiveItemPO variableArchiveItem); + + /** + * 删除记录 + * + * @param variableArchiveItem 待删除的记录 + * @return 返回影响行数 + */ + int delete(VariableArchiveItemPO variableArchiveItem); + + /** + * 查询浮动薪酬档案中已使用的浮动薪资项目 + * + * @return + */ + List listUsingItems(); + + /** + * + * @param insertList + * @return + */ + int batchInsert(@Param("collection") List insertList); + + void deleteByIds(@Param("collection")List part); + + void deleteByArchiveIds(@Param("collection")List part); + + void updateBatchSelective(@Param("list")List variableArchiveItemPOS); +} diff --git a/src/com/engine/salary/mapper/datacollection/VariableArchiveItemMapper.xml b/src/com/engine/salary/mapper/datacollection/VariableArchiveItemMapper.xml new file mode 100644 index 000000000..365c21579 --- /dev/null +++ b/src/com/engine/salary/mapper/datacollection/VariableArchiveItemMapper.xml @@ -0,0 +1,365 @@ + + + + + + + + + + + + + + + + + + + t.id + , t.employee_id + , t.variable_archive_id + , t.variable_item_id + , t.item_value + , t.create_time + , t.update_time + , t.creator + , t.delete_type + , t.tenant_key + + + + + + + + + + + + + + + + + INSERT INTO hrsa_variable_archive_item + + + + id, + + + employee_id, + + + variable_archive_id, + + + variable_item_id, + + + item_value, + + + create_time, + + + update_time, + + + creator, + + + delete_type, + + + tenant_key, + + + + + #{id}, + + + #{employeeId}, + + + #{variableArchiveId}, + + + #{variableItemId}, + + + #{itemValue}, + + + #{createTime}, + + + #{updateTime}, + + + #{creator}, + + + #{deleteType}, + + + #{tenantKey}, + + + + + + INSERT INTO hrsa_variable_archive_item ( + id + , employee_id + , variable_archive_id + , variable_item_id + , item_value + , create_time + , update_time + , creator + , delete_type + , tenant_key + ) + VALUES + + ( + #{item.id}, + #{item.employeeId}, + #{item.variableArchiveId}, + #{item.variableItemId}, + #{item.itemValue}, + #{item.createTime}, + #{item.updateTime}, + #{item.creator}, + #{item.deleteType}, + #{item.tenantKey} + ) + + + + INSERT INTO hrsa_variable_archive_item ( + id + , employee_id + , variable_archive_id + , variable_item_id + , item_value + , create_time + , update_time + , creator + , delete_type + , tenant_key + ) + + + select + #{item.id,jdbcType=DOUBLE}, + #{item.employeeId,jdbcType=DOUBLE}, + #{item.variableArchiveId,jdbcType=DOUBLE}, + #{item.variableItemId,jdbcType=DOUBLE}, + #{item.itemValue,jdbcType=VARCHAR}, + #{item.createTime,jdbcType=DATE}, + #{item.updateTime,jdbcType=DATE}, + #{item.creator,jdbcType=DOUBLE}, + #{item.deleteType,jdbcType=INTEGER}, + #{item.tenantKey,jdbcType=VARCHAR} + from dual + + + + + INSERT INTO hrsa_variable_archive_item ( + id + , employee_id + , variable_archive_id + , variable_item_id + , item_value + , create_time + , update_time + , creator + , delete_type + , tenant_key + ) + VALUES + ( + #{item.id}, + #{item.employeeId}, + #{item.variableArchiveId}, + #{item.variableItemId}, + #{item.itemValue}, + #{item.createTime}, + #{item.updateTime}, + #{item.creator}, + #{item.deleteType}, + #{item.tenantKey} + ) + + + + + + UPDATE hrsa_variable_archive_item + + employee_id=#{employeeId}, + variable_archive_id=#{variableArchiveId}, + variable_item_id=#{variableItemId}, + item_value=#{itemValue}, + create_time=#{createTime}, + update_time=#{updateTime}, + creator=#{creator}, + delete_type=#{deleteType}, + tenant_key=#{tenantKey}, + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_variable_archive_item + + + employee_id=#{employeeId}, + + + variable_archive_id=#{variableArchiveId}, + + + variable_item_id=#{variableItemId}, + + + item_value=#{itemValue}, + + + create_time=#{createTime}, + + + update_time=#{updateTime}, + + + creator=#{creator}, + + + delete_type=#{deleteType}, + + + tenant_key=#{tenantKey}, + + + WHERE id = #{id} AND delete_type = 0 + + + update hrsa_variable_archive_item + + + + + when id = #{item.id} then #{item.itemValue} + + + + + where id in + + #{item.id} + + + + + + + UPDATE hrsa_variable_archive_item + SET delete_type=1 + WHERE id = #{id} AND delete_type = 0 + + + + UPDATE hrsa_variable_archive_item + SET delete_type=1 + WHERE delete_type = 0 + + AND id IN + + #{id} + + + + + + UPDATE hrsa_variable_archive_item + SET delete_type=1 + WHERE delete_type = 0 + + AND variable_archive_id IN + + #{id} + + + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/datacollection/VariableArchiveMapper.java b/src/com/engine/salary/mapper/datacollection/VariableArchiveMapper.java new file mode 100644 index 000000000..635c22d98 --- /dev/null +++ b/src/com/engine/salary/mapper/datacollection/VariableArchiveMapper.java @@ -0,0 +1,81 @@ +package com.engine.salary.mapper.datacollection; + +import com.engine.salary.entity.datacollection.dto.VariableArchiveListDTO; +import com.engine.salary.entity.datacollection.param.VariableArchiveQueryParam; +import com.engine.salary.entity.datacollection.po.VariableArchivePO; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * @author Harryxzy + * @ClassName VariableArchiveMapper + * @date 2024/08/07 9:18 + * @description 浮动薪酬档案 + */ +public interface VariableArchiveMapper { + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + /** + * 条件查询 + * + * @return 返回集合,没有返回空List + */ + List listSome(VariableArchivePO variableArchive); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + VariableArchivePO getById(Long id); + + /** + * 新增,忽略null字段 + * + * @param variableArchive 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(VariableArchivePO variableArchive); + + /** + * 修改,修改所有字段 + * + * @param variableArchive 修改的记录 + * @return 返回影响行数 + */ + int update(VariableArchivePO variableArchive); + + /** + * 修改,忽略null字段 + * + * @param variableArchive 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(VariableArchivePO variableArchive); + + /** + * 删除记录 + * + * @param variableArchive 待删除的记录 + * @return 返回影响行数 + */ + int delete(VariableArchivePO variableArchive); + + /** + * 删除记录 + * + * @param variableArchiveIds 待删除的记录id + * @return 返回影响行数 + */ + int deleteByIds(@Param("ids")List variableArchiveIds); + + List list(@Param("param")VariableArchiveQueryParam queryParam); +} diff --git a/src/com/engine/salary/mapper/datacollection/VariableArchiveMapper.xml b/src/com/engine/salary/mapper/datacollection/VariableArchiveMapper.xml new file mode 100644 index 000000000..b9e9b94b4 --- /dev/null +++ b/src/com/engine/salary/mapper/datacollection/VariableArchiveMapper.xml @@ -0,0 +1,412 @@ + + + + + + + + + + + + + + + + + t.id + , t.employee_id + , t.tax_agent_id + , t.salary_month + , t.create_time + , t.update_time + , t.creator + , t.delete_type + , t.tenant_key + + + + + + + + + + + + + + t.id + , t.employee_id + , t.tax_agent_id + , t.salary_month + , t.create_time + , t.update_time + , t.creator + , t.delete_type + , e.mobile + , e.workcode + , e.certificatenum as idNo + , e.lastname as username + , e.certificatenum as idNo + , e.companystartdate as companystartdate + , e.enddate as dismissdate + , d.departmentname AS departmentName + , c.subcompanyname AS subcompanyName + , a.name AS taxAgentName + , a.id AS taxAgentId + + + + + + + + + + INSERT INTO hrsa_variable_archive + + + + id, + + + tax_agent_id, + + + employee_id, + + + salary_month, + + + create_time, + + + update_time, + + + creator, + + + delete_type, + + + tenant_key, + + + + + #{id}, + + + #{taxAgentId}, + + + #{employeeId}, + + + #{salaryMonth}, + + + #{createTime}, + + + #{updateTime}, + + + #{creator}, + + + #{deleteType}, + + + #{tenantKey}, + + + + + + + + + UPDATE hrsa_variable_archive + + employee_id=#{employeeId}, + salary_month=#{salaryMonth}, + create_time=#{createTime}, + update_time=#{updateTime}, + creator=#{creator}, + delete_type=#{deleteType}, + tenant_key=#{tenantKey}, + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_variable_archive + + + employee_id=#{employeeId}, + + + salary_month=#{salaryMonth}, + + + create_time=#{createTime}, + + + update_time=#{updateTime}, + + + creator=#{creator}, + + + delete_type=#{deleteType}, + + + tenant_key=#{tenantKey}, + + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_variable_archive + SET delete_type=1 + WHERE id = #{id} AND delete_type = 0 + + + + UPDATE hrsa_variable_archive + SET delete_type=1 + WHERE delete_type = 0 + AND id IN + + #{id} + + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/datacollection/VariableItemMapper.java b/src/com/engine/salary/mapper/datacollection/VariableItemMapper.java new file mode 100644 index 000000000..a886e64c3 --- /dev/null +++ b/src/com/engine/salary/mapper/datacollection/VariableItemMapper.java @@ -0,0 +1,68 @@ +package com.engine.salary.mapper.datacollection; + +import com.engine.salary.entity.datacollection.po.VariableItemPO; + +import java.util.List; + +/** + * @author Harryxzy + * @ClassName VariableItemMapper + * @date 2024/08/07 9:26 + * @description 浮动薪酬项目 + */ +public interface VariableItemMapper { + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + /** + * 条件查询 + * + * @return 返回集合,没有返回空List + */ + List listSome(VariableItemPO variableItem); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + VariableItemPO getById(Long id); + + /** + * 新增,忽略null字段 + * + * @param variableItem 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(VariableItemPO variableItem); + + /** + * 修改,修改所有字段 + * + * @param variableItem 修改的记录 + * @return 返回影响行数 + */ + int update(VariableItemPO variableItem); + + /** + * 修改,忽略null字段 + * + * @param variableItem 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(VariableItemPO variableItem); + + /** + * 删除记录 + * + * @param variableItem 待删除的记录 + * @return 返回影响行数 + */ + int delete(VariableItemPO variableItem); +} diff --git a/src/com/engine/salary/mapper/datacollection/VariableItemMapper.xml b/src/com/engine/salary/mapper/datacollection/VariableItemMapper.xml new file mode 100644 index 000000000..f7b634091 --- /dev/null +++ b/src/com/engine/salary/mapper/datacollection/VariableItemMapper.xml @@ -0,0 +1,210 @@ + + + + + + + + + + + + + + + + + + t.id + , t.name + , t.code + , t.data_type + , t.create_time + , t.update_time + , t.creator + , t.delete_type + , t.tenant_key + + + + + + + + + + + + + + + INSERT INTO hrsa_variable_item + + + + id, + + + name, + + + code, + + + data_type, + + + create_time, + + + update_time, + + + creator, + + + delete_type, + + + tenant_key, + + + + + #{id}, + + + #{name}, + + + #{code}, + + + #{dataType}, + + + #{createTime}, + + + #{updateTime}, + + + #{creator}, + + + #{deleteType}, + + + #{tenantKey}, + + + + + + + UPDATE hrsa_variable_item + + name=#{name}, + code=#{code}, + data_type=#{dataType}, + create_time=#{createTime}, + update_time=#{updateTime}, + creator=#{creator}, + delete_type=#{deleteType}, + tenant_key=#{tenantKey}, + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_variable_item + + + name=#{name}, + + + code=#{code}, + + + data_type=#{dataType}, + + + create_time=#{createTime}, + + + update_time=#{updateTime}, + + + creator=#{creator}, + + + delete_type=#{deleteType}, + + + tenant_key=#{tenantKey}, + + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_variable_item + SET delete_type=1 + WHERE id = #{id} AND delete_type = 0 + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/extemp/ExternalEmployeeMapper.java b/src/com/engine/salary/mapper/extemp/ExternalEmployeeMapper.java new file mode 100644 index 000000000..010241611 --- /dev/null +++ b/src/com/engine/salary/mapper/extemp/ExternalEmployeeMapper.java @@ -0,0 +1,92 @@ +package com.engine.salary.mapper.extemp; + +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.extemp.po.ExtEmpPO; +import com.engine.salary.entity.salarysob.param.SalarySobRangeEmpQueryParam; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; + +public interface ExternalEmployeeMapper { + + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + ExtEmpPO getById(Long id); + + List listSome(ExtEmpPO po); + + /** + * 新增,忽略null字段 + * + * @param externalEmployee 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(ExtEmpPO externalEmployee); + + /** + * 修改,修改所有字段 + * + * @param externalEmployee 修改的记录 + * @return 返回影响行数 + */ + int update(ExtEmpPO externalEmployee); + + /** + * 修改,忽略null字段 + * + * @param externalEmployee 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(ExtEmpPO externalEmployee); + + /** + * 删除记录 + * + * @return 返回影响行数 + */ + int delete(Long id); + + /** + * 根据薪资账套的人员范围转换而成的查询参数查询人员 + * + * @param queryParams 薪资账套的人员范围转换而成的查询参数 + * @return + */ + Collection listByParams( @Param("params") List queryParams); + + /** + * 获取所有员工,关联部门 + * + * @return + */ + List listEmployee(); + + /** + * 多表联查 + * @param ids + * @return + */ + List getEmployeeByIdsAll(@Param("collection")List ids); + + /** + * 报表专用 + * @return + */ + Collection listAllForReport(); + + + List listSomeDataCollectionEmployee(ExtEmpPO po); +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/extemp/ExternalEmployeeMapper.xml b/src/com/engine/salary/mapper/extemp/ExternalEmployeeMapper.xml new file mode 100644 index 000000000..f09431009 --- /dev/null +++ b/src/com/engine/salary/mapper/extemp/ExternalEmployeeMapper.xml @@ -0,0 +1,720 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + t + . + id + , t.username + , t.department_name + , t.department_id + , t.subcompany_name + , t.subcompany_id + , t.jobtitle_name + , t.jobtitle_id + , t.companystartdate + , t.mobile + , t.status + , t.workcode + , t.sex + , t.email + , t.telephone + , t.jobcall + , t.birthday + , t.id_no + , t.bank_card_num + , t.bank_name + , t.delete_type + , t.creator + , t.modifier + , t.create_time + , t.update_time + , t.tenant_key + + + + + + + + + + + + + + + + + + + + + INSERT INTO hrsa_external_employee + + + + id, + + + username, + + + department_name, + + + department_id, + + + subcompany_name, + + + subcompany_id, + + + jobtitle_name, + + + jobtitle_id, + + + companystartdate, + + + mobile, + + + status, + + + workcode, + + + sex, + + + email, + + + telephone, + + + jobcall, + + + birthday, + + + id_no, + + + bank_card_num, + + + bank_name, + + + delete_type, + + + creator, + + + modifier, + + + create_time, + + + update_time, + + + tenant_key, + + + + + #{id}, + + + #{username}, + + + #{departmentName}, + + + #{departmentId}, + + + #{subcompanyName}, + + + #{subcompanyId}, + + + #{jobtitleName}, + + + #{jobtitleId}, + + + #{companystartdate}, + + + #{mobile}, + + + #{status}, + + + #{workcode}, + + + #{sex}, + + + #{email}, + + + #{telephone}, + + + #{jobcall}, + + + #{birthday}, + + + #{idNo}, + + + #{bankCardNum}, + + + #{bankName}, + + + #{deleteType}, + + + #{creator}, + + + #{modifier}, + + + #{createTime}, + + + #{updateTime}, + + + #{tenantKey}, + + + + + + + UPDATE hrsa_external_employee + + username=#{username}, + department_name=#{departmentName}, + department_id=#{departmentId}, + subcompany_name=#{subcompanyName}, + subcompany_id=#{subcompanyId}, + jobtitle_name=#{jobtitleName}, + jobtitle_id=#{jobtitleId}, + companystartdate=#{companystartdate}, + mobile=#{mobile}, + status=#{status}, + workcode=#{workcode}, + sex=#{sex}, + email=#{email}, + telephone=#{telephone}, + jobcall=#{jobcall}, + birthday=#{birthday}, + id_no=#{idNo}, + bank_card_num=#{bankCardNum}, + bank_name=#{bankName}, + delete_type=#{deleteType}, + creator=#{creator}, + modifier=#{modifier}, + create_time=#{createTime}, + update_time=#{updateTime}, + tenant_key=#{tenantKey}, + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_external_employee + + + username=#{username}, + + + department_name=#{departmentName}, + + department_id=#{departmentId}, + + subcompany_name=#{subcompanyName}, + + subcompany_id=#{subcompanyId}, + + jobtitle_name=#{jobtitleName}, + + + jobtitle_id=#{jobtitleId}, + + + companystartdate=#{companystartdate}, + + + mobile=#{mobile}, + + + status=#{status}, + + + workcode=#{workcode}, + + + sex=#{sex}, + + + email=#{email}, + + + telephone=#{telephone}, + + + jobcall=#{jobcall}, + + + birthday=#{birthday}, + + + id_no=#{idNo}, + + + bank_card_num=#{bankCardNum}, + + + bank_name=#{bankName}, + + + delete_type=#{deleteType}, + + + creator=#{creator}, + + + modifier=#{modifier}, + + + create_time=#{createTime}, + + + update_time=#{updateTime}, + + + tenant_key=#{tenantKey}, + + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_external_employee + SET delete_type=1 + WHERE id = #{id} + AND delete_type = 0 + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/formula/FormulaMapper.java b/src/com/engine/salary/mapper/formula/FormulaMapper.java new file mode 100644 index 000000000..874e026ba --- /dev/null +++ b/src/com/engine/salary/mapper/formula/FormulaMapper.java @@ -0,0 +1,65 @@ +package com.engine.salary.mapper.formula; + +import com.engine.salary.entity.salaryformula.po.FormulaPO; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.Date; +import java.util.List; + +public interface FormulaMapper { + + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + List list2All(); + + /** + * 条件查询 + * + * @return 返回集合,没有返回空List + */ + List listSome(FormulaPO formula); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + FormulaPO getById(Long id); + + /** + * 新增,忽略null字段 + * + * @param formula 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(FormulaPO formula); + + + /** + * 修改,忽略null字段 + * + * @param formula 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(FormulaPO formula); + + /** + * 删除记录 + * + * @param formula 待删除的记录 + * @return 返回影响行数 + */ + int delete(FormulaPO formula); + + List listByIds(@Param("ids")Collection ids); + + void deleteIn(@Param("ids")List ids,@Param("yesterday") Date yesterday); +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/formula/FormulaMapper.xml b/src/com/engine/salary/mapper/formula/FormulaMapper.xml new file mode 100644 index 000000000..6fa8c2ba8 --- /dev/null +++ b/src/com/engine/salary/mapper/formula/FormulaMapper.xml @@ -0,0 +1,309 @@ + + + + + + + + + + + + + + + + + + + + + + + + t + . + id + , t.name + , t.description + , t.module + , t.use_for + , t.reference_type + , t.return_type + , t.validate_type + , t.extend_param + , t.formula + , t.formulaRunScript + , t.creator + , t.delete_type + , t.create_time + , t.update_time + + + + + + + + + + + + + + + + + INSERT INTO hrsa_formula + + + + id, + + + name, + + + description, + + + module, + + + use_for, + + + reference_type, + + + return_type, + + + validate_type, + + + extend_param, + + + formula, + + + formulaRunScript, + + + creator, + + + delete_type, + + + create_time, + + + update_time, + + + + + #{id}, + + + #{name}, + + + #{description}, + + + #{module}, + + + #{useFor}, + + + #{referenceType}, + + + #{returnType}, + + + #{validateType}, + + + #{extendParam}, + + + #{formula}, + + + #{formulaRunScript}, + + + #{creator}, + + + #{deleteType}, + + + #{createTime}, + + + #{updateTime}, + + + + + + + + UPDATE hrsa_formula + + + name=#{name}, + + + description=#{description}, + + + module=#{module}, + + + use_for=#{useFor}, + + + reference_type=#{referenceType}, + + + return_type=#{returnType}, + + + validate_type=#{validateType}, + + + extend_param=#{extendParam}, + + + formula=#{formula}, + + + formulaRunScript=#{formulaRunScript}, + + + creator=#{creator}, + + + delete_type=#{deleteType}, + + + create_time=#{createTime}, + + + update_time=#{updateTime}, + + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_formula + SET delete_type=1 + WHERE id = #{id} + AND delete_type = 0 + + + + + + + + UPDATE hrsa_formula + SET delete_type=1 + WHERE + delete_type = 0 + AND id IN + + #{id} + + and create_time #{yesterday} + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/formula/FormulaVarMapper.java b/src/com/engine/salary/mapper/formula/FormulaVarMapper.java new file mode 100644 index 000000000..f92f0c846 --- /dev/null +++ b/src/com/engine/salary/mapper/formula/FormulaVarMapper.java @@ -0,0 +1,53 @@ +package com.engine.salary.mapper.formula; + +import com.engine.salary.entity.salaryformula.po.FormulaVar; +import org.apache.ibatis.annotations.Param; + +import java.util.Date; +import java.util.List; + +public interface FormulaVarMapper { + + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + /** + * 条件查询 + * + * @return 返回集合,没有返回空List + */ + List listSome(FormulaVar formulaVar); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + FormulaVar getById(Long id); + + /** + * 新增,忽略null字段 + * + * @param formulaVar 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(FormulaVar formulaVar); + + /** + * 修改,忽略null字段 + * + * @param formulaVar 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(FormulaVar formulaVar); + + void deleteByFormulaId(Long formulaId); + + void deleteInFormulaIds(@Param("formulaIds") List formulaIds,@Param("yesterday") Date yesterday); +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/formula/FormulaVarMapper.xml b/src/com/engine/salary/mapper/formula/FormulaVarMapper.xml new file mode 100644 index 000000000..8842e2475 --- /dev/null +++ b/src/com/engine/salary/mapper/formula/FormulaVarMapper.xml @@ -0,0 +1,245 @@ + + + + + + + + + + + + + + + + + + + + + t + . + id + , t.name + , t.formula_id + , t.field_id + , t.field_name + , t.field_type + , t.source + , t.order_index + , t.creator + , t.delete_type + , t.create_time + , t.update_time + + + + + + + + + + + + + + + INSERT INTO hrsa_formula_var + + + id, + + + name, + + + formula_id, + + + field_id, + + + field_name, + + + field_type, + + + source, + + + order_index, + + + creator, + + + delete_type, + + + create_time, + + + update_time, + + + + + #{id}, + + + #{name}, + + + #{formulaId}, + + + #{fieldId}, + + + #{fieldName}, + + + #{fieldType}, + + + #{source}, + + + #{orderIndex}, + + + #{creator}, + + + #{deleteType}, + + + #{createTime}, + + + #{updateTime}, + + + + + + + + UPDATE hrsa_formula_var + + + name=#{name}, + + + formula_id=#{formulaId}, + + + field_id=#{fieldId}, + + + field_name=#{fieldName}, + + + field_type=#{fieldType}, + + + source=#{source}, + + + order_index=#{orderIndex}, + + + creator=#{creator}, + + + delete_type=#{deleteType}, + + + create_time=#{createTime}, + + + update_time=#{updateTime}, + + + WHERE id = #{id} AND delete_type = 0 + + + + + UPDATE hrsa_formula_var + SET delete_type=1 + WHERE formula_id = #{formulaId} + AND delete_type = 0 + + + + UPDATE hrsa_formula_var + SET delete_type=1 + WHERE delete_type = 0 + AND formula_id IN + + #{formulaId} + + and create_time #{yesterday} + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/hrm/ExpandFieldSettingsMapper.java b/src/com/engine/salary/mapper/hrm/ExpandFieldSettingsMapper.java new file mode 100644 index 000000000..9d1c9fab9 --- /dev/null +++ b/src/com/engine/salary/mapper/hrm/ExpandFieldSettingsMapper.java @@ -0,0 +1,73 @@ +package com.engine.salary.mapper.hrm; + +import com.engine.salary.entity.hrm.po.ExpandFieldSettingsPO; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; + +public interface ExpandFieldSettingsMapper { + + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + /** + * 条件查询 + * + * @return 返回集合,没有返回空List + */ + List listSome(ExpandFieldSettingsPO expandFieldSettings); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + ExpandFieldSettingsPO getById(Long id); + + /** + * 新增,忽略null字段 + * + * @param expandFieldSettings 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(ExpandFieldSettingsPO expandFieldSettings); + + /** + * 修改,修改所有字段 + * + * @param expandFieldSettings 修改的记录 + * @return 返回影响行数 + */ + int update(ExpandFieldSettingsPO expandFieldSettings); + + /** + * 修改,忽略null字段 + * + * @param expandFieldSettings 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(ExpandFieldSettingsPO expandFieldSettings); + + /** + * 删除记录 + * + * @param expandFieldSettings 待删除的记录 + * @return 返回影响行数 + */ + int delete(ExpandFieldSettingsPO expandFieldSettings); + + /** + * 批量删除记录 + * @param ids 主键id集合 + */ + void deleteByIds(@Param("ids") Collection ids); + + ExpandFieldSettingsPO getByModule(String module); +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/hrm/ExpandFieldSettingsMapper.xml b/src/com/engine/salary/mapper/hrm/ExpandFieldSettingsMapper.xml new file mode 100644 index 000000000..47a24568e --- /dev/null +++ b/src/com/engine/salary/mapper/hrm/ExpandFieldSettingsMapper.xml @@ -0,0 +1,259 @@ + + + + + + + + + + + + + + + + + + + + t + . + id + , t.module + , t.module_info + , t.pk + , t.expand_sql + , t.field_setting + , t.create_time + , t.update_time + , t.creator + , t.delete_type + , t.tenant_key + + + + + + + + + + + + + + + INSERT INTO hrsa_expand_field_settings + + + id, + + + module, + + + module_info, + + + pk, + + + expand_sql, + + + field_setting, + + + create_time, + + + update_time, + + + creator, + + + delete_type, + + + tenant_key, + + + + + #{id}, + + + #{module}, + + + #{moduleInfo}, + + + #{pk}, + + + #{expandSql}, + + + #{fieldSetting}, + + + #{createTime}, + + + #{updateTime}, + + + #{creator}, + + + #{deleteType}, + + + #{tenantKey}, + + + + + + + + + UPDATE hrsa_expand_field_settings + + module=#{module}, + module_info=#{moduleInfo}, + pk=#{pk}, + expand_sql=#{expandSql}, + field_setting=#{fieldSetting}, + create_time=#{createTime}, + update_time=#{updateTime}, + creator=#{creator}, + delete_type=#{deleteType}, + tenant_key=#{tenantKey}, + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_expand_field_settings + + + module=#{module}, + + + module_info=#{moduleInfo}, + + + pk=#{pk}, + + + expand_sql=#{expandSql}, + + + field_setting=#{fieldSetting}, + + + create_time=#{createTime}, + + + update_time=#{updateTime}, + + + creator=#{creator}, + + + delete_type=#{deleteType}, + + + tenant_key=#{tenantKey}, + + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_expand_field_settings + SET delete_type=1 + WHERE id = #{id} + AND delete_type = 0 + + + + UPDATE hrsa_expand_field_settings + SET delete_type = 1 + WHERE delete_type = 0 + AND id IN + + #{id} + + + + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/hrm/HrmSnapshotMapper.java b/src/com/engine/salary/mapper/hrm/HrmSnapshotMapper.java new file mode 100644 index 000000000..81082b003 --- /dev/null +++ b/src/com/engine/salary/mapper/hrm/HrmSnapshotMapper.java @@ -0,0 +1,87 @@ +package com.engine.salary.mapper.hrm; + +import com.engine.salary.entity.hrm.po.HrmSnapshotPO; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.Date; +import java.util.List; + +public interface HrmSnapshotMapper { + + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + List snapshot(@Param("employeeId")Long employeeId, @Param("snapshotTime")Date snapshotTime); + + /** + * 条件查询 + * + * @return 返回集合,没有返回空List + */ + List listSome(HrmSnapshotPO hrmSnapshot); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + HrmSnapshotPO getById(Long id); + + /** + * 新增,忽略null字段 + * + * @param hrmSnapshot 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(HrmSnapshotPO hrmSnapshot); + + + /** + * 修改,修改所有字段 + * + * @param hrmSnapshot 修改的记录 + * @return 返回影响行数 + */ + int update(HrmSnapshotPO hrmSnapshot); + + /** + * 修改,忽略null字段 + * + * @param hrmSnapshot 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(HrmSnapshotPO hrmSnapshot); + + /** + * 删除记录 + * + * @param hrmSnapshot 待删除的记录 + * @return 返回影响行数 + */ + int delete(HrmSnapshotPO hrmSnapshot); + + /** + * 批量删除记录 + * + * @param ids 主键id集合 + */ + void deleteByIds(@Param("ids") Collection ids); + + void deleteBySnapshotTime(Date snapshotTime); + + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List currentEmpData(); + + +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/hrm/HrmSnapshotMapper.xml b/src/com/engine/salary/mapper/hrm/HrmSnapshotMapper.xml new file mode 100644 index 000000000..d56a738ea --- /dev/null +++ b/src/com/engine/salary/mapper/hrm/HrmSnapshotMapper.xml @@ -0,0 +1,1201 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + t + . + ACCOUNTID1 + , t.ACCOUNTNAME + , t.ACCOUNTTYPE + , t.ACCUMFUNDACCOUNT + , t.ASSISTANTID + , t.BANKID1 + , t.BELONGTO + , t.BEMEMBERDATE + , t.BEPARTYDATE + , t.BIRTHDAY + , t.BIRTHPLACE + , t.CERTIFICATENUM + , t.companystartdate + , t.companyworkyear + , t.COSTCENTERID + , t.COUNTRYID + , t.DEGREE + , t.DEPARTMENTID + , t.DEPARTMENTNAME + , t.EDUCATIONLEVEL + , t.EMAIL + , t.employee_id + , t.ENDDATE + , t.EXTPHONE + , t.FAX + , t.FOLK + , t.HEALTHINFO + , t.HOMEADDRESS + , t.ID + , t.ISLABOUUNION + , t.JOBACTIVITYDESC + , t.JOBCALL + , t.jobcallname + , t.JOBLEVEL + , t.JOBTITLE + , t.JOBTITLENAME + , t.LASTLOGINDATE + , t.LASTNAME + , t.LOCATIONID + , t.loginid + , t.MANAGERID + , t.MANAGERSTR + , t.MARITALSTATUS + , t.MOBILE + , t.MOBILECALL + , t.NATIONALITY + , t.NATIVEPLACE + , t.POLICY + , t.PROBATIONENDDATE + , t.REGRESIDENTPLACE + , t.RESIDENTPHONE + , t.RESIDENTPLACE + , t.RESIDENTPOSTCODE + , t.RESOURCETYPE + , t.SECLEVEL + , t.SEX + , t.snapshot_time + , t.STARTDATE + , t.STATUS + , t.SUBCOMPANYID1 + , t.SUBCOMPANYNAME + , t.TELEPHONE + , t.TEMPRESIDENTNUMBER + , t.USEKIND + , t.WORKCODE + , t.WORKROOM + , t.workstartdate + , t.workyear + + + + + + + + + + + + + + + + + + INSERT INTO hrsa_hrm_snapshot + + + + ACCOUNTID1, + + + ACCOUNTNAME, + + + ACCOUNTTYPE, + + + ACCUMFUNDACCOUNT, + + + ASSISTANTID, + + + BANKID1, + + + BELONGTO, + + + BEMEMBERDATE, + + + BEPARTYDATE, + + + BIRTHDAY, + + + BIRTHPLACE, + + + CERTIFICATENUM, + + + companystartdate, + + + companyworkyear, + + + COSTCENTERID, + + + COUNTRYID, + + + DEGREE, + + + DEPARTMENTID, + + + DEPARTMENTNAME, + + + EDUCATIONLEVEL, + + + EMAIL, + + + employee_id, + + + ENDDATE, + + + EXTPHONE, + + + FAX, + + + FOLK, + + + HEALTHINFO, + + + HOMEADDRESS, + + + ID, + + + ISLABOUUNION, + + + JOBACTIVITYDESC, + + + JOBCALL, + + + jobcallname, + + + JOBLEVEL, + + + JOBTITLE, + + + JOBTITLENAME, + + + LASTLOGINDATE, + + + LASTNAME, + + + LOCATIONID, + + + loginid, + + + MANAGERID, + + + MANAGERSTR, + + + MARITALSTATUS, + + + MOBILE, + + + MOBILECALL, + + + NATIONALITY, + + + NATIVEPLACE, + + + POLICY, + + + PROBATIONENDDATE, + + + REGRESIDENTPLACE, + + + RESIDENTPHONE, + + + RESIDENTPLACE, + + + RESIDENTPOSTCODE, + + + RESOURCETYPE, + + + SECLEVEL, + + + SEX, + + + snapshot_time, + + + STARTDATE, + + + STATUS, + + + SUBCOMPANYID1, + + + SUBCOMPANYNAME, + + + TELEPHONE, + + + TEMPRESIDENTNUMBER, + + + USEKIND, + + + WORKCODE, + + + WORKROOM, + + + workstartdate, + + + workyear, + + + + + #{accountid1}, + + + #{accountname}, + + + #{accounttype}, + + + #{accumfundaccount}, + + + #{assistantid}, + + + #{bankid1}, + + + #{belongto}, + + + #{bememberdate}, + + + #{bepartydate}, + + + #{birthday}, + + + #{birthplace}, + + + #{certificatenum}, + + + #{companystartdate}, + + + #{companyworkyear}, + + + #{costcenterid}, + + + #{countryid}, + + + #{degree}, + + + #{departmentid}, + + + #{departmentname}, + + + #{educationlevel}, + + + #{email}, + + + #{employeeId}, + + + #{enddate}, + + + #{extphone}, + + + #{fax}, + + + #{folk}, + + + #{healthinfo}, + + + #{homeaddress}, + + + #{id}, + + + #{islabouunion}, + + + #{jobactivitydesc}, + + + #{jobcall}, + + + #{jobcallname}, + + + #{joblevel}, + + + #{jobtitle}, + + + #{jobtitlename}, + + + #{lastlogindate}, + + + #{lastname}, + + + #{locationid}, + + + #{loginid}, + + + #{managerid}, + + + #{managerstr}, + + + #{maritalstatus}, + + + #{mobile}, + + + #{mobilecall}, + + + #{nationality}, + + + #{nativeplace}, + + + #{policy}, + + + #{probationenddate}, + + + #{regresidentplace}, + + + #{residentphone}, + + + #{residentplace}, + + + #{residentpostcode}, + + + #{resourcetype}, + + + #{seclevel}, + + + #{sex}, + + + #{snapshotTime}, + + + #{startdate}, + + + #{status}, + + + #{subcompanyid1}, + + + #{subcompanyname}, + + + #{telephone}, + + + #{tempresidentnumber}, + + + #{usekind}, + + + #{workcode}, + + + #{workroom}, + + + #{workstartdate}, + + + #{workyear}, + + + + + + + UPDATE hrsa_hrm_snapshot + + ACCOUNTID1=#{accountid1}, + ACCOUNTNAME=#{accountname}, + ACCOUNTTYPE=#{accounttype}, + ACCUMFUNDACCOUNT=#{accumfundaccount}, + ASSISTANTID=#{assistantid}, + BANKID1=#{bankid1}, + BELONGTO=#{belongto}, + BEMEMBERDATE=#{bememberdate}, + BEPARTYDATE=#{bepartydate}, + BIRTHDAY=#{birthday}, + BIRTHPLACE=#{birthplace}, + CERTIFICATENUM=#{certificatenum}, + companystartdate=#{companystartdate}, + companyworkyear=#{companyworkyear}, + COSTCENTERID=#{costcenterid}, + COUNTRYID=#{countryid}, + DEGREE=#{degree}, + DEPARTMENTID=#{departmentid}, + DEPARTMENTNAME=#{departmentname}, + EDUCATIONLEVEL=#{educationlevel}, + EMAIL=#{email}, + employee_id=#{employeeId}, + ENDDATE=#{enddate}, + EXTPHONE=#{extphone}, + FAX=#{fax}, + FOLK=#{folk}, + HEALTHINFO=#{healthinfo}, + HOMEADDRESS=#{homeaddress}, + ISLABOUUNION=#{islabouunion}, + JOBACTIVITYDESC=#{jobactivitydesc}, + JOBCALL=#{jobcall}, + jobcallname=#{jobcallname}, + JOBLEVEL=#{joblevel}, + JOBTITLE=#{jobtitle}, + JOBTITLENAME=#{jobtitlename}, + LASTLOGINDATE=#{lastlogindate}, + LASTNAME=#{lastname}, + LOCATIONID=#{locationid}, + loginid=#{loginid}, + MANAGERID=#{managerid}, + MANAGERSTR=#{managerstr}, + MARITALSTATUS=#{maritalstatus}, + MOBILE=#{mobile}, + MOBILECALL=#{mobilecall}, + NATIONALITY=#{nationality}, + NATIVEPLACE=#{nativeplace}, + POLICY=#{policy}, + PROBATIONENDDATE=#{probationenddate}, + REGRESIDENTPLACE=#{regresidentplace}, + RESIDENTPHONE=#{residentphone}, + RESIDENTPLACE=#{residentplace}, + RESIDENTPOSTCODE=#{residentpostcode}, + RESOURCETYPE=#{resourcetype}, + SECLEVEL=#{seclevel}, + SEX=#{sex}, + snapshot_time=#{snapshotTime}, + STARTDATE=#{startdate}, + STATUS=#{status}, + SUBCOMPANYID1=#{subcompanyid1}, + SUBCOMPANYNAME=#{subcompanyname}, + TELEPHONE=#{telephone}, + TEMPRESIDENTNUMBER=#{tempresidentnumber}, + USEKIND=#{usekind}, + WORKCODE=#{workcode}, + WORKROOM=#{workroom}, + workstartdate=#{workstartdate}, + workyear=#{workyear}, + + WHERE ID = #{id} + + + + + + UPDATE hrsa_hrm_snapshot + + + ACCOUNTID1=#{accountid1}, + + + ACCOUNTNAME=#{accountname}, + + + ACCOUNTTYPE=#{accounttype}, + + + ACCUMFUNDACCOUNT=#{accumfundaccount}, + + + ASSISTANTID=#{assistantid}, + + + BANKID1=#{bankid1}, + + + BELONGTO=#{belongto}, + + + BEMEMBERDATE=#{bememberdate}, + + + BEPARTYDATE=#{bepartydate}, + + + BIRTHDAY=#{birthday}, + + + BIRTHPLACE=#{birthplace}, + + + CERTIFICATENUM=#{certificatenum}, + + + companystartdate=#{companystartdate}, + + + companyworkyear=#{companyworkyear}, + + + COSTCENTERID=#{costcenterid}, + + + COUNTRYID=#{countryid}, + + + DEGREE=#{degree}, + + + DEPARTMENTID=#{departmentid}, + + + DEPARTMENTNAME=#{departmentname}, + + + EDUCATIONLEVEL=#{educationlevel}, + + + EMAIL=#{email}, + + + employee_id=#{employeeId}, + + + ENDDATE=#{enddate}, + + + EXTPHONE=#{extphone}, + + + FAX=#{fax}, + + + FOLK=#{folk}, + + + HEALTHINFO=#{healthinfo}, + + + HOMEADDRESS=#{homeaddress}, + + + ISLABOUUNION=#{islabouunion}, + + + JOBACTIVITYDESC=#{jobactivitydesc}, + + + JOBCALL=#{jobcall}, + + + jobcallname=#{jobcallname}, + + + JOBLEVEL=#{joblevel}, + + + JOBTITLE=#{jobtitle}, + + + JOBTITLENAME=#{jobtitlename}, + + + LASTLOGINDATE=#{lastlogindate}, + + + LASTNAME=#{lastname}, + + + LOCATIONID=#{locationid}, + + + loginid=#{loginid}, + + + MANAGERID=#{managerid}, + + + MANAGERSTR=#{managerstr}, + + + MARITALSTATUS=#{maritalstatus}, + + + MOBILE=#{mobile}, + + + MOBILECALL=#{mobilecall}, + + + NATIONALITY=#{nationality}, + + + NATIVEPLACE=#{nativeplace}, + + + POLICY=#{policy}, + + + PROBATIONENDDATE=#{probationenddate}, + + + REGRESIDENTPLACE=#{regresidentplace}, + + + RESIDENTPHONE=#{residentphone}, + + + RESIDENTPLACE=#{residentplace}, + + + RESIDENTPOSTCODE=#{residentpostcode}, + + + RESOURCETYPE=#{resourcetype}, + + + SECLEVEL=#{seclevel}, + + + SEX=#{sex}, + + + snapshot_time=#{snapshotTime}, + + + STARTDATE=#{startdate}, + + + STATUS=#{status}, + + + SUBCOMPANYID1=#{subcompanyid1}, + + + SUBCOMPANYNAME=#{subcompanyname}, + + + TELEPHONE=#{telephone}, + + + TEMPRESIDENTNUMBER=#{tempresidentnumber}, + + + USEKIND=#{usekind}, + + + WORKCODE=#{workcode}, + + + WORKROOM=#{workroom}, + + + workstartdate=#{workstartdate}, + + + workyear=#{workyear}, + + + WHERE ID = #{id} + + + + + + UPDATE hrsa_hrm_snapshot + SET delete_type=1 + WHERE id = #{id} + AND delete_type = 0 + + + + UPDATE hrsa_hrm_snapshot + SET delete_type = 1 + WHERE id IN + + #{id} + + + + + delete from hrsa_hrm_snapshot + WHERE snapshot_time = #{snapshotTime} + + + + e + . + ID as employee_id + ,e.loginid + ,e.LASTNAME + ,e.SEX + ,e.BIRTHDAY + ,e.NATIONALITY + ,e.MARITALSTATUS + ,e.TELEPHONE + ,e.MOBILE + ,e.MOBILECALL + ,e.EMAIL + ,e.LOCATIONID + ,e.WORKROOM + ,e.HOMEADDRESS + ,e.RESOURCETYPE + ,e.STARTDATE + ,e.ENDDATE + ,e.JOBTITLE + ,j.JOBTITLENAME + ,e.JOBACTIVITYDESC + ,e.JOBLEVEL + ,e.SECLEVEL + ,e.DEPARTMENTID + ,d.DEPARTMENTNAME + ,e.SUBCOMPANYID1 + ,c.SUBCOMPANYNAME + ,e.COSTCENTERID + ,e.MANAGERID + ,e.ASSISTANTID + ,e.BANKID1 + ,e.ACCOUNTID1 + ,e.LASTLOGINDATE + ,e.CERTIFICATENUM + ,e.NATIVEPLACE + ,e.EDUCATIONLEVEL + ,e.BEMEMBERDATE + ,e.BEPARTYDATE + ,e.WORKCODE + ,e.REGRESIDENTPLACE + ,e.HEALTHINFO + ,e.RESIDENTPLACE + ,e.POLICY + ,e.DEGREE + ,e.USEKIND + ,e.JOBCALL + ,job.NAME as jobcallname + ,e.ACCUMFUNDACCOUNT + ,e.BIRTHPLACE + ,e.FOLK + ,e.RESIDENTPHONE + ,e.RESIDENTPOSTCODE + ,e.EXTPHONE + ,e.MANAGERSTR + ,e.STATUS + ,e.FAX + ,e.ISLABOUUNION + ,e.TEMPRESIDENTNUMBER + ,e.PROBATIONENDDATE + ,e.COUNTRYID + ,e.ACCOUNTTYPE + ,e.BELONGTO + ,e.ACCOUNTNAME + ,e.companystartdate + ,e.workstartdate + ,e.companyworkyear + ,e.workyear + + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/push/PushRecordDetailMapper.java b/src/com/engine/salary/mapper/push/PushRecordDetailMapper.java new file mode 100644 index 000000000..1c63a36c2 --- /dev/null +++ b/src/com/engine/salary/mapper/push/PushRecordDetailMapper.java @@ -0,0 +1,76 @@ +package com.engine.salary.mapper.push; + +import com.engine.salary.entity.push.dto.PushRecordDetailDTO; +import com.engine.salary.entity.push.po.PushRecordDetailPO; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; + +public interface PushRecordDetailMapper { + + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + /** + * 条件查询 + * + * @return 返回集合,没有返回空List + */ + List listSome(PushRecordDetailPO pushRecordDetail); + + List listDTO(PushRecordDetailDTO dto); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + PushRecordDetailPO getById(Long id); + + /** + * 新增,忽略null字段 + * + * @param pushRecordDetail 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(PushRecordDetailPO pushRecordDetail); + + /** + * 修改,修改所有字段 + * + * @param pushRecordDetail 修改的记录 + * @return 返回影响行数 + */ + int update(PushRecordDetailPO pushRecordDetail); + + /** + * 修改,忽略null字段 + * + * @param pushRecordDetail 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(PushRecordDetailPO pushRecordDetail); + + /** + * 删除记录 + * + * @param pushRecordDetail 待删除的记录 + * @return 返回影响行数 + */ + int delete(PushRecordDetailPO pushRecordDetail); + + /** + * 批量删除记录 + * @param ids 主键id集合 + */ + void deleteByIds(@Param("ids") Collection ids); + + void deleteByRecordId(Long acctRecordId); +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/push/PushRecordDetailMapper.xml b/src/com/engine/salary/mapper/push/PushRecordDetailMapper.xml new file mode 100644 index 000000000..73220be28 --- /dev/null +++ b/src/com/engine/salary/mapper/push/PushRecordDetailMapper.xml @@ -0,0 +1,316 @@ + + + + + + + + + + + + + + + + + + + + + t + . + acct_emp_id + , t.create_time + , t.creator + , t.delete_type + , t.formula + , t.id + , t.record_id + , t.status + , t.tenant_key + , t.update_time + , t.fail_reason + , t.data_id + + + + + + + + + + + + + + + + + INSERT INTO hrsa_push_record_detail + + + + acct_emp_id, + + + create_time, + + + creator, + + + delete_type, + + + formula, + + + id, + + + record_id, + + + status, + + + tenant_key, + + + update_time, + + + fail_reason, + + + data_id, + + + + + #{acctEmpId}, + + + #{createTime}, + + + #{creator}, + + + #{deleteType}, + + + #{formula}, + + + #{id}, + + + #{recordId}, + + + #{status}, + + + #{tenantKey}, + + + #{updateTime}, + + + #{failReason}, + + + #{dataId}, + + + + + + + UPDATE hrsa_push_record_detail + + acct_emp_id=#{acctEmpId}, + create_time=#{createTime}, + creator=#{creator}, + delete_type=#{deleteType}, + formula=#{formula}, + record_id=#{recordId}, + status=#{status}, + tenant_key=#{tenantKey}, + update_time=#{updateTime}, + fail_reason=#{failReason}, + data_id=#{dataId}, + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_push_record_detail + + + acct_emp_id=#{acctEmpId}, + + + create_time=#{createTime}, + + + creator=#{creator}, + + + delete_type=#{deleteType}, + + + formula=#{formula}, + + + record_id=#{recordId}, + + + status=#{status}, + + + tenant_key=#{tenantKey}, + + + update_time=#{updateTime}, + + + fail_reason=#{failReason}, + + + data_id=#{dataId}, + + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_push_record_detail + SET delete_type=1 + WHERE id = #{id} + AND delete_type = 0 + + + + UPDATE hrsa_push_record_detail + SET delete_type = 1 + WHERE delete_type = 0 + AND id IN + + #{id} + + + + + UPDATE hrsa_push_record_detail + SET delete_type=1 + WHERE record_id=#{recordId} + AND delete_type = 0 + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/push/PushRecordMapper.java b/src/com/engine/salary/mapper/push/PushRecordMapper.java new file mode 100644 index 000000000..dfcf7fd05 --- /dev/null +++ b/src/com/engine/salary/mapper/push/PushRecordMapper.java @@ -0,0 +1,75 @@ +package com.engine.salary.mapper.push; + +import com.engine.salary.entity.push.po.PushRecordPO; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; + +public interface PushRecordMapper { + + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + /** + * 条件查询 + * + * @return 返回集合,没有返回空List + */ + List listSome(PushRecordPO pushRecord); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + PushRecordPO getById(Long id); + + /** + * 新增,忽略null字段 + * + * @param pushRecord 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(PushRecordPO pushRecord); + + + /** + * 修改,修改所有字段 + * + * @param pushRecord 修改的记录 + * @return 返回影响行数 + */ + int update(PushRecordPO pushRecord); + + /** + * 修改,忽略null字段 + * + * @param pushRecord 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(PushRecordPO pushRecord); + + /** + * 删除记录 + * + * @param pushRecord 待删除的记录 + * @return 返回影响行数 + */ + int delete(PushRecordPO pushRecord); + + /** + * 批量删除记录 + * @param ids 主键id集合 + */ + void deleteByIds(@Param("ids") Collection ids); + + int countBeforeBatch(Long batchId); + +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/push/PushRecordMapper.xml b/src/com/engine/salary/mapper/push/PushRecordMapper.xml new file mode 100644 index 000000000..48e1a2765 --- /dev/null +++ b/src/com/engine/salary/mapper/push/PushRecordMapper.xml @@ -0,0 +1,335 @@ + + + + + + + + + + + + + + + + + + + + + + + + + t + . + acct_record_id + , t.mode_id + , t.table_name + , t.create_time + , t.creator + , t.delete_type + , t.id + , t.name + , t.setting_id + , t.status + , t.tenant_key + , t.type + , t.update_time + , t.fail_reason + , t.start_time + , t.end_time + + + + + + + + + + + + + + + INSERT INTO hrsa_push_record + + + + mode_id, + + + table_name, + + + acct_record_id, + + + create_time, + + + creator, + + + delete_type, + + + id, + + + name, + + + setting_id, + + + status, + + + tenant_key, + + + type, + + + update_time, + + + fail_reason, + + + start_time, + + + end_time, + + + + + #{modeId}, + + + #{tableName}, + + + #{acctRecordId}, + + + #{createTime}, + + + #{creator}, + + + #{deleteType}, + + + #{id}, + + + #{name}, + + + #{settingId}, + + + #{status}, + + + #{tenantKey}, + + + #{type}, + + + #{updateTime}, + + + #{failReason}, + + + #{startTime}, + + + #{endTime}, + + + + + + + UPDATE hrsa_push_record + + mode_id=#{modeId}, + table_name=#{tableName}, + acct_record_id=#{acctRecordId}, + create_time=#{createTime}, + creator=#{creator}, + delete_type=#{deleteType}, + name=#{name}, + setting_id=#{settingId}, + status=#{status}, + tenant_key=#{tenantKey}, + type=#{type}, + update_time=#{updateTime}, + fail_reason=#{failReason}, + start_time=#{startTime}, + end_time=#{endTime}, + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_push_record + + + mode_id=#{modeId}, + + + table_name=#{tableName}, + + + acct_record_id=#{acctRecordId}, + + + create_time=#{createTime}, + + + creator=#{creator}, + + + delete_type=#{deleteType}, + + + name=#{name}, + + + setting_id=#{settingId}, + + + status=#{status}, + + + tenant_key=#{tenantKey}, + + + type=#{type}, + + + update_time=#{updateTime}, + + + fail_reason=#{failReason}, + + + start_time=#{startTime}, + + + end_time=#{endTime}, + + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_push_record + SET delete_type=1 + WHERE id = #{id} + AND delete_type = 0 + + + + UPDATE hrsa_push_record + SET delete_type = 1 + WHERE delete_type = 0 + AND id IN + + #{id} + + + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/push/PushSettingItemMapper.java b/src/com/engine/salary/mapper/push/PushSettingItemMapper.java new file mode 100644 index 000000000..3f550b532 --- /dev/null +++ b/src/com/engine/salary/mapper/push/PushSettingItemMapper.java @@ -0,0 +1,72 @@ +package com.engine.salary.mapper.push; + +import com.engine.salary.entity.push.po.PushSettingItemPO; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; + +public interface PushSettingItemMapper { + + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + /** + * 条件查询 + * + * @return 返回集合,没有返回空List + */ + List listSome(PushSettingItemPO pushSettingItem); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + PushSettingItemPO getById(Long id); + + /** + * 新增,忽略null字段 + * + * @param pushSettingItem 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(PushSettingItemPO pushSettingItem); + + /** + * 修改,修改所有字段 + * + * @param pushSettingItem 修改的记录 + * @return 返回影响行数 + */ + int update(PushSettingItemPO pushSettingItem); + + /** + * 修改,忽略null字段 + * + * @param pushSettingItem 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(PushSettingItemPO pushSettingItem); + + /** + * 删除记录 + * + * @param pushSettingItem 待删除的记录 + * @return 返回影响行数 + */ + int delete(PushSettingItemPO pushSettingItem); + + /** + * 批量删除记录 + * @param ids 主键id集合 + */ + void deleteByIds(@Param("ids") Collection ids); + +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/push/PushSettingItemMapper.xml b/src/com/engine/salary/mapper/push/PushSettingItemMapper.xml new file mode 100644 index 000000000..2c5322940 --- /dev/null +++ b/src/com/engine/salary/mapper/push/PushSettingItemMapper.xml @@ -0,0 +1,284 @@ + + + + + + + + + + + + + + + + + + + + + + t + . + create_time + , t.creator + , t.delete_type + , t.field_name + , t.field_type + , t.id + , t.item + , t.item_name + , t.source + , t.setting_id + , t.tenant_key + , t.update_time + , t.sorted_index + + + + + + + + + + + + + + + INSERT INTO hrsa_push_setting_item + + + + create_time, + + + creator, + + + delete_type, + + + field_name, + + + field_type, + + + id, + + + item, + + + item_name, + + + source, + + + setting_id, + + + sorted_index, + + + tenant_key, + + + update_time, + + + + + #{createTime}, + + + #{creator}, + + + #{deleteType}, + + + #{fieldName}, + + + #{fieldType}, + + + #{id}, + + + #{item}, + + + #{itemName}, + + + #{source}, + + + #{settingId}, + + + #{sortedIndex}, + + + #{tenantKey}, + + + #{updateTime}, + + + + + + + UPDATE hrsa_push_setting_item + + create_time=#{createTime}, + creator=#{creator}, + delete_type=#{deleteType}, + field_name=#{fieldName}, + field_type=#{fieldType}, + item=#{item}, + item_name=#{itemName}, + source=#{source}, + setting_id=#{settingId}, + sorted_index=#{sortedIndex}, + tenant_key=#{tenantKey}, + update_time=#{updateTime}, + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_push_setting_item + + + create_time=#{createTime}, + + + creator=#{creator}, + + + delete_type=#{deleteType}, + + + field_name=#{fieldName}, + + + field_type=#{fieldType}, + + + item=#{item}, + + + item_name=#{itemName}, + + + source=#{source}, + + + setting_id=#{settingId}, + + + sorted_index=#{sortedIndex}, + + + tenant_key=#{tenantKey}, + + + update_time=#{updateTime}, + + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_push_setting_item + SET delete_type=1 + WHERE id = #{id} + AND delete_type = 0 + + + + UPDATE hrsa_push_setting_item + SET delete_type = 1 + WHERE delete_type = 0 + AND id IN + + #{id} + + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/push/PushSettingMapper.java b/src/com/engine/salary/mapper/push/PushSettingMapper.java new file mode 100644 index 000000000..dcfe71ccc --- /dev/null +++ b/src/com/engine/salary/mapper/push/PushSettingMapper.java @@ -0,0 +1,73 @@ +package com.engine.salary.mapper.push; + +import com.engine.salary.entity.push.po.PushSettingPO; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; + +public interface PushSettingMapper { + + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + /** + * 条件查询 + * + * @return 返回集合,没有返回空List + */ + List listSome(PushSettingPO pushSetting); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + PushSettingPO getById(Long id); + + /** + * 新增,忽略null字段 + * + * @param pushSetting 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(PushSettingPO pushSetting); + + + /** + * 修改,修改所有字段 + * + * @param pushSetting 修改的记录 + * @return 返回影响行数 + */ + int update(PushSettingPO pushSetting); + + /** + * 修改,忽略null字段 + * + * @param pushSetting 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(PushSettingPO pushSetting); + + /** + * 删除记录 + * + * @param pushSetting 待删除的记录 + * @return 返回影响行数 + */ + int delete(PushSettingPO pushSetting); + + /** + * 批量删除记录 + * @param ids 主键id集合 + */ + void deleteByIds(@Param("ids") Collection ids); + +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/push/PushSettingMapper.xml b/src/com/engine/salary/mapper/push/PushSettingMapper.xml new file mode 100644 index 000000000..c421fa71f --- /dev/null +++ b/src/com/engine/salary/mapper/push/PushSettingMapper.xml @@ -0,0 +1,268 @@ + + + + + + + + + + + + + + + + + + + + + t + . + able + , t.create_time + , t.creator + , t.delete_type + , t.name + , t.id + , t.mode_id + , t.mode_name + , t.salary_sob_ids + , t.table_name + , t.tenant_key + , t.update_time + + + + + + + + + + + + + + + INSERT INTO hrsa_push_setting + + + + able, + + + create_time, + + + creator, + + + delete_type, + + + name, + + + id, + + + mode_id, + + + mode_name, + + + salary_sob_ids, + + + table_name, + + + tenant_key, + + + update_time, + + + + + #{able}, + + + #{createTime}, + + + #{creator}, + + + #{deleteType}, + + + #{name}, + + + #{id}, + + + #{modeId}, + + + #{modeName}, + + + #{salarySobIds, jdbcType=ARRAY, typeHandler=com.engine.salary.handle.LongListTypeHandler}, + + + #{tableName}, + + + #{tenantKey}, + + + #{updateTime}, + + + + + + + UPDATE hrsa_push_setting + + able=#{able}, + create_time=#{createTime}, + creator=#{creator}, + delete_type=#{deleteType}, + name=#{name}, + mode_id=#{modeId}, + mode_name=#{modeName}, + salary_sob_ids=#{salarySobIds, jdbcType=ARRAY, typeHandler=com.engine.salary.handle.LongListTypeHandler}, + table_name=#{tableName}, + tenant_key=#{tenantKey}, + update_time=#{updateTime}, + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_push_setting + + + able=#{able}, + + + create_time=#{createTime}, + + + creator=#{creator}, + + + delete_type=#{deleteType}, + + + name=#{name}, + + + mode_id=#{modeId}, + + + mode_name=#{modeName}, + + + salary_sob_ids=#{salarySobIds, jdbcType=ARRAY, typeHandler=com.engine.salary.handle.LongListTypeHandler}, + + + table_name=#{tableName}, + + + tenant_key=#{tenantKey}, + + + update_time=#{updateTime}, + + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_push_setting + SET delete_type=1 + WHERE id = #{id} + AND delete_type = 0 + + + + UPDATE hrsa_push_setting + SET delete_type = 1 + WHERE delete_type = 0 + AND id IN + + #{id} + + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/report/SalaryAcctResultReportMapper.java b/src/com/engine/salary/mapper/report/SalaryAcctResultReportMapper.java new file mode 100644 index 000000000..6a78ae80d --- /dev/null +++ b/src/com/engine/salary/mapper/report/SalaryAcctResultReportMapper.java @@ -0,0 +1,55 @@ +package com.engine.salary.mapper.report; + +import com.engine.salary.entity.report.po.SalaryAcctResultReportPO; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; + +public interface SalaryAcctResultReportMapper { + + + /** + * 条件查询 + * + * @return 返回集合,没有返回空List + */ + List listSome(SalaryAcctResultReportPO salaryAcctResultReportPO); + + /** + * 新增,忽略null字段 + * + * @param salaryAcctResultReport 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(SalaryAcctResultReportPO salaryAcctResultReport); + + + /** + * 删除记录 + * + * @param salaryAcctResultReportPO 待删除的记录 + * @return 返回影响行数 + */ + int delete(SalaryAcctResultReportPO salaryAcctResultReportPO); + + /** + * 批量新增 + */ + void batchInsert(@Param("collection") Collection reports); + + void deleteBySalaryAcctRecordIds(@Param("list") Collection list); + + void deleteBySalaryAcctRecordId(Long salaryAcctRecordId); + + void deleteBySalaryAcctEmpIds(@Param("list") Collection salaryAcctEmpIds); + + /** + * 根据薪资核算id、薪资项目id删除薪资核算结果 + * + * @param salaryAcctEmpIds + * @param salaryItemIds + */ + void deleteByAcctEmpIdsAndSalaryItemIds(@Param("salaryAcctEmpIds") Collection salaryAcctEmpIds, + @Param("salaryItemIds") Collection salaryItemIds); +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/report/SalaryAcctResultReportMapper.xml b/src/com/engine/salary/mapper/report/SalaryAcctResultReportMapper.xml new file mode 100644 index 000000000..16860033d --- /dev/null +++ b/src/com/engine/salary/mapper/report/SalaryAcctResultReportMapper.xml @@ -0,0 +1,425 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + t + . + id + , t.salary_sob_id + , t.salary_acct_emp_id + , t.salary_acct_record_id + , t.employee_id + , t.tax_agent_id + , t.salary_item_id + , t.result_value + , t.creator + , t.create_time + , t.update_time + , t.delete_type + , t.tenant_key + , t.department_id + , t.subcompany_id + , t.costcenter_id + , t.jobtitle_id + , t.location_id + + + + + + + + + INSERT INTO hrsa_salary_acct_result_report + + + + costcenter_id, + + + create_time, + + + creator, + + + delete_type, + + + department_id, + + + employee_id, + + + id, + + + jobtitle_id, + + + location_id, + + + result_value, + + + origin_result_value, + + + salary_acct_emp_id, + + + salary_acct_record_id, + + + salary_item_id, + + + salary_sob_id, + + + subcompany_id, + + + tax_agent_id, + + + tenant_key, + + + update_time, + + + + + #{costcenterId}, + + + #{createTime}, + + + #{creator}, + + + #{deleteType}, + + + #{departmentId}, + + + #{employeeId}, + + + #{id}, + + + #{jobtitleId}, + + + #{locationId}, + + + #{resultValue}, + + + #{originResultValue}, + + + #{salaryAcctEmpId}, + + + #{salaryAcctRecordId}, + + + #{salaryItemId}, + + + #{salarySobId}, + + + #{subcompanyId}, + + + #{taxAgentId}, + + + #{tenantKey}, + + + #{updateTime}, + + + + + + + + UPDATE hrsa_salary_acct_result_report + SET delete_type=1 + WHERE id = #{id} + AND delete_type = 0 + + + + INSERT INTO hrsa_salary_acct_result_report( + id + , salary_sob_id + , salary_acct_emp_id + , salary_acct_record_id + , employee_id + , tax_agent_id + , salary_item_id + , result_value + , creator + , create_time + , update_time + , delete_type + , tenant_key + , department_id + , subcompany_id + , costcenter_id + , jobtitle_id + , location_id) + VALUES + + ( + #{item.id} + , #{item.salarySobId} + , #{item.salaryAcctEmpId} + , #{item.salaryAcctRecordId} + , #{item.employeeId} + , #{item.taxAgentId} + , #{item.salaryItemId} + , #{item.resultValue} + , #{item.creator} + , #{item.createTime} + , #{item.updateTime} + , #{item.deleteType} + , #{item.tenantKey} + , #{item.departmentId} + , #{item.subcompanyId} + , #{item.costcenterId} + , #{item.jobtitleId} + , #{item.locationId} + ) + + + + + INSERT INTO hrsa_salary_acct_result_report( + id + , salary_sob_id + , salary_acct_emp_id + , salary_acct_record_id + , employee_id + , tax_agent_id + , salary_item_id + , result_value + , creator + , create_time + , update_time + , delete_type + , tenant_key + , department_id + , subcompany_id + , costcenter_id + , jobtitle_id + , location_id) + + select + #{item.id,jdbcType=DOUBLE} + , #{item.salarySobId,jdbcType=DOUBLE} + , #{item.salaryAcctEmpId,jdbcType=VARCHAR} + , #{item.salaryAcctRecordId,jdbcType=DOUBLE} + , #{item.employeeId,jdbcType=VARCHAR} + , #{item.taxAgentId,jdbcType=DOUBLE} + , #{item.salaryItemId,jdbcType=DOUBLE} + , #{item.resultValue,jdbcType=VARCHAR} + , #{item.creator,jdbcType=DOUBLE} + , #{item.createTime,jdbcType=DATE} + , #{item.updateTime,jdbcType=DATE} + , #{item.deleteType,jdbcType=INTEGER} + , #{item.tenantKey,jdbcType=VARCHAR} + , #{item.departmentId,jdbcType=DOUBLE} + , #{item.subcompanyId,jdbcType=DOUBLE} + , #{item.costcenterId,jdbcType=DOUBLE} + , #{item.jobtitleId,jdbcType=DOUBLE} + , #{item.locationId,jdbcType=DOUBLE} + from dual + + + + + + INSERT INTO hrsa_salary_acct_result_report + ( + id + , salary_sob_id + , salary_acct_emp_id + , salary_acct_record_id + , employee_id + , tax_agent_id + , salary_item_id + , result_value + , creator + , create_time + , update_time + , delete_type + , tenant_key + , department_id + , subcompany_id + , costcenter_id + , jobtitle_id + , location_id) + VALUES + ( + #{item.id} + , #{item.salarySobId} + , #{item.salaryAcctEmpId} + , #{item.salaryAcctRecordId} + , #{item.employeeId} + , #{item.taxAgentId} + , #{item.salaryItemId} + , #{item.resultValue} + , #{item.creator} + , #{item.createTime} + , #{item.updateTime} + , #{item.deleteType} + , #{item.tenantKey} + , #{item.departmentId} + , #{item.subcompanyId} + , #{item.costcenterId} + , #{item.jobtitleId} + , #{item.locationId} + ) + + + + + + DELETE FROM hrsa_salary_acct_result_report + WHERE delete_type = 0 + AND salary_acct_record_id IN + + #{salaryAcctRecordId} + + + + + DELETE + FROM hrsa_salary_acct_result_report + WHERE delete_type = 0 + AND salary_acct_record_id = #{salaryAcctRecordId} + + + + DELETE FROM hrsa_salary_acct_result_report + WHERE delete_type = 0 + AND salary_acct_emp_id IN + + #{salaryAcctEmpId} + + + + + + DELETE FROM hrsa_salary_acct_result_report + WHERE delete_type = 0 + AND salary_acct_emp_id IN + + #{salaryAcctEmpId} + + AND salary_item_id IN + + #{salaryItemId} + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/report/SalaryStatisticsDimensionMapper.java b/src/com/engine/salary/mapper/report/SalaryStatisticsDimensionMapper.java new file mode 100644 index 000000000..a941af555 --- /dev/null +++ b/src/com/engine/salary/mapper/report/SalaryStatisticsDimensionMapper.java @@ -0,0 +1,66 @@ +package com.engine.salary.mapper.report; + +import com.engine.salary.report.entity.po.SalaryStatisticsDimensionPO; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +public interface SalaryStatisticsDimensionMapper { + + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + /** + * 条件查询 + * + * @return 返回集合,没有返回空List + */ + List listSome(SalaryStatisticsDimensionPO salaryStatsDim); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + SalaryStatisticsDimensionPO getById(Long id); + + /** + * 新增,忽略null字段 + * + * @param salaryStatsDim 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(SalaryStatisticsDimensionPO salaryStatsDim); + + /** + * 修改,修改所有字段 + * + * @param salaryStatsDim 修改的记录 + * @return 返回影响行数 + */ + int update(SalaryStatisticsDimensionPO salaryStatsDim); + + /** + * 修改,忽略null字段 + * + * @param salaryStatsDim 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(SalaryStatisticsDimensionPO salaryStatsDim); + + /** + * 删除记录 + * + * @param salaryStatsDim 待删除的记录 + * @return 返回影响行数 + */ + int delete(SalaryStatisticsDimensionPO salaryStatsDim); + + void batDelete(@Param("ids") List ids); +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/report/SalaryStatisticsDimensionMapper.xml b/src/com/engine/salary/mapper/report/SalaryStatisticsDimensionMapper.xml new file mode 100644 index 000000000..09890b22b --- /dev/null +++ b/src/com/engine/salary/mapper/report/SalaryStatisticsDimensionMapper.xml @@ -0,0 +1,303 @@ + + + + + + + + + + + + + + + + + + + + + + t + . + create_time + , t.creator + , t.delete_type + , t.dim_code + , t.dim_name + , t.dim_type + , t.id + , t.is_default + , t.label_id + , t.remark + , t.setting + , t.tenant_key + , t.update_time + + + + + + + + + + + + AND dim_name like CONCAT('%',#{dimNameLike},'%') + + + + + AND dim_name like '%'||#{dimName}||'%' + + + + + AND dim_name like '%'+#{dimNameLike}+'%' + + + + + + + + + + INSERT INTO hrsa_salary_stats_dim + + + + create_time, + + + creator, + + + delete_type, + + + dim_code, + + + dim_name, + + + dim_type, + + + id, + + + is_default, + + + label_id, + + + remark, + + + setting, + + + tenant_key, + + + update_time, + + + + + #{createTime}, + + + #{creator}, + + + #{deleteType}, + + + #{dimCode}, + + + #{dimName}, + + + #{dimType}, + + + #{id}, + + + #{isDefault}, + + + #{labelId}, + + + #{remark}, + + + #{setting}, + + + #{tenantKey}, + + + #{updateTime}, + + + + + + + UPDATE hrsa_salary_stats_dim + + create_time=#{createTime}, + creator=#{creator}, + delete_type=#{deleteType}, + dim_code=#{dimCode}, + dim_name=#{dimName}, + dim_type=#{dimType}, + is_default=#{isDefault}, + label_id=#{labelId}, + remark=#{remark}, + setting=#{setting}, + tenant_key=#{tenantKey}, + update_time=#{updateTime}, + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_salary_stats_dim + + + create_time=#{createTime}, + + + creator=#{creator}, + + + delete_type=#{deleteType}, + + + dim_code=#{dimCode}, + + + dim_name=#{dimName}, + + + dim_type=#{dimType}, + + + is_default=#{isDefault}, + + + label_id=#{labelId}, + + + remark=#{remark}, + + + setting=#{setting}, + + + tenant_key=#{tenantKey}, + + + update_time=#{updateTime}, + + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_salary_stats_dim + SET delete_type=1 + WHERE id = #{id} + AND delete_type = 0 + + + + UPDATE hrsa_salary_stats_dim + SET delete_type=1 + WHERE + id IN + + #{id} + + AND delete_type = 0 + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/report/SalaryStatisticsEChartsSettingMapper.java b/src/com/engine/salary/mapper/report/SalaryStatisticsEChartsSettingMapper.java new file mode 100644 index 000000000..d9c4d7ada --- /dev/null +++ b/src/com/engine/salary/mapper/report/SalaryStatisticsEChartsSettingMapper.java @@ -0,0 +1,72 @@ +package com.engine.salary.mapper.report; + +import com.engine.salary.report.entity.po.SalaryStatisticsEChartsSettingPO; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; + +public interface SalaryStatisticsEChartsSettingMapper { + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + /** + * 条件查询 + * + * @return 返回集合,没有返回空List + */ + List listSome(SalaryStatisticsEChartsSettingPO SalaryStatisticsEChartsSettingPO); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + SalaryStatisticsEChartsSettingPO getById(Long id); + + /** + * 新增,忽略null字段 + * + * @param SalaryStatisticsEChartsSettingPO 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(SalaryStatisticsEChartsSettingPO SalaryStatisticsEChartsSettingPO); + + /** + * 修改,修改所有字段 + * + * @param SalaryStatisticsEChartsSettingPO 修改的记录 + * @return 返回影响行数 + */ + int update(SalaryStatisticsEChartsSettingPO SalaryStatisticsEChartsSettingPO); + + /** + * 修改,忽略null字段 + * + * @param SalaryStatisticsEChartsSettingPO 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(SalaryStatisticsEChartsSettingPO SalaryStatisticsEChartsSettingPO); + + /** + * 删除记录 + * + * @param SalaryStatisticsEChartsSettingPO 待删除的记录 + * @return 返回影响行数 + */ + int delete(SalaryStatisticsEChartsSettingPO SalaryStatisticsEChartsSettingPO); + + /** + * 批量删除记录 + * @param ids 主键id集合 + */ + void deleteByIds(@Param("ids") Collection ids); + + void deleteByReportId(Long reportId); +} diff --git a/src/com/engine/salary/mapper/report/SalaryStatisticsEChartsSettingMapper.xml b/src/com/engine/salary/mapper/report/SalaryStatisticsEChartsSettingMapper.xml new file mode 100644 index 000000000..35c17deb4 --- /dev/null +++ b/src/com/engine/salary/mapper/report/SalaryStatisticsEChartsSettingMapper.xml @@ -0,0 +1,321 @@ + + + + + + + + + + + + + + + + + + + + + + + + t + . + charts_type + , t.create_time + , t.creator + , t.delete_type + , t.dimension_range + , t.id + , t.item_col_sort_value + , t.item_col_value + , t.item_sort_value + , t.item_values + , t.report_id + , t.sort_num + , t.sort_type + , t.tenant_key + , t.update_time + + + + + + + + + + + + + + + INSERT INTO hrsa_salary_echarts_setting + + + + charts_type, + + + create_time, + + + creator, + + + delete_type, + + + dimension_range, + + + id, + + + item_col_sort_value, + + + item_col_value, + + + item_sort_value, + + + item_values, + + + report_id, + + + sort_num, + + + sort_type, + + + tenant_key, + + + update_time, + + + + + #{chartsType}, + + + #{createTime}, + + + #{creator}, + + + #{deleteType}, + + + #{dimensionRange}, + + + #{id}, + + + #{itemColSortValue}, + + + #{itemColValue}, + + + #{itemSortValue}, + + + #{itemValues}, + + + #{reportId}, + + + #{sortNum}, + + + #{sortType}, + + + #{tenantKey}, + + + #{updateTime}, + + + + + + + UPDATE hrsa_salary_echarts_setting + + charts_type=#{chartsType}, + create_time=#{createTime}, + creator=#{creator}, + delete_type=#{deleteType}, + dimension_range=#{dimensionRange}, + item_col_sort_value=#{itemColSortValue}, + item_col_value=#{itemColValue}, + item_sort_value=#{itemSortValue}, + item_values=#{itemValues}, + report_id=#{reportId}, + sort_num=#{sortNum}, + sort_type=#{sortType}, + tenant_key=#{tenantKey}, + update_time=#{updateTime}, + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_salary_echarts_setting + + + charts_type=#{chartsType}, + + + create_time=#{createTime}, + + + creator=#{creator}, + + + delete_type=#{deleteType}, + + + dimension_range=#{dimensionRange}, + + + item_col_sort_value=#{itemColSortValue}, + + + item_col_value=#{itemColValue}, + + + item_sort_value=#{itemSortValue}, + + + item_values=#{itemValues}, + + + report_id=#{reportId}, + + + sort_num=#{sortNum}, + + + sort_type=#{sortType}, + + + tenant_key=#{tenantKey}, + + + update_time=#{updateTime}, + + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_salary_echarts_setting + SET delete_type=1 + WHERE id = #{id} + AND delete_type = 0 + + + + UPDATE hrsa_salary_echarts_setting + SET delete_type = 1 + WHERE delete_type = 0 + AND id IN + + #{id} + + + + + UPDATE hrsa_salary_echarts_setting + SET delete_type=1 + WHERE report_id = #{reportId} + AND delete_type = 0 + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/report/SalaryStatisticsItemMapper.java b/src/com/engine/salary/mapper/report/SalaryStatisticsItemMapper.java new file mode 100644 index 000000000..65913ab29 --- /dev/null +++ b/src/com/engine/salary/mapper/report/SalaryStatisticsItemMapper.java @@ -0,0 +1,73 @@ +package com.engine.salary.mapper.report; + +import com.engine.salary.report.entity.po.SalaryStatisticsItemPO; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; + +public interface SalaryStatisticsItemMapper { + + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + /** + * 条件查询 + * + * @return 返回集合,没有返回空List + */ + List listSome(SalaryStatisticsItemPO SalaryStatisticsItemPO); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + SalaryStatisticsItemPO getById(Long id); + + /** + * 新增,忽略null字段 + * + * @param SalaryStatisticsItemPO 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(SalaryStatisticsItemPO SalaryStatisticsItemPO); + + /** + * 修改,修改所有字段 + * + * @param SalaryStatisticsItemPO 修改的记录 + * @return 返回影响行数 + */ + int update(SalaryStatisticsItemPO SalaryStatisticsItemPO); + + /** + * 修改,忽略null字段 + * + * @param SalaryStatisticsItemPO 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(SalaryStatisticsItemPO SalaryStatisticsItemPO); + + /** + * 删除记录 + * + * @param SalaryStatisticsItemPO 待删除的记录 + * @return 返回影响行数 + */ + int delete(SalaryStatisticsItemPO SalaryStatisticsItemPO); + + /** + * 批量删除记录 + * @param ids 主键id集合 + */ + void deleteByIds(@Param("ids") Collection ids); + + void deleteByReportIds(@Param("reportIds") List reportIds); +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/report/SalaryStatisticsItemMapper.xml b/src/com/engine/salary/mapper/report/SalaryStatisticsItemMapper.xml new file mode 100644 index 000000000..69abc9536 --- /dev/null +++ b/src/com/engine/salary/mapper/report/SalaryStatisticsItemMapper.xml @@ -0,0 +1,401 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + t + . + avg_rule + , t.count_rule + , t.create_time + , t.creator + , t.delete_type + , t.id + , t.index_value + , t.item_name + , t.item_value + , t.max_rule + , t.median_rule + , t.min_rule + , t.stat_report_id + , t.sum_rule + , t.tenant_key + , t.unit_type + , t.update_time + , t.last_rule + , t.old_rule + , t.frequent_rule + , t.tile_rule + + + + + + + + + + + + + + + INSERT INTO hrsa_salary_statistics_item + + + + avg_rule, + + + count_rule, + + + create_time, + + + creator, + + + delete_type, + + + id, + + + index_value, + + + item_name, + + + item_value, + + + max_rule, + + + median_rule, + + + min_rule, + + + stat_report_id, + + + sum_rule, + + + tenant_key, + + + unit_type, + + + update_time, + + + last_rule, + + + old_rule, + + + frequent_rule, + + + tile_rule, + + + + + #{avgRule}, + + + #{countRule}, + + + #{createTime}, + + + #{creator}, + + + #{deleteType}, + + + #{id}, + + + #{indexValue}, + + + #{itemName}, + + + #{itemValue}, + + + #{maxRule}, + + + #{medianRule}, + + + #{minRule}, + + + #{statReportId}, + + + #{sumRule}, + + + #{tenantKey}, + + + #{unitType}, + + + #{updateTime}, + + + #{lastRule}, + + + #{oldRule}, + + + #{frequentRule}, + + + #{tileRule}, + + + + + + + UPDATE hrsa_salary_statistics_item + + avg_rule=#{avgRule}, + count_rule=#{countRule}, + create_time=#{createTime}, + creator=#{creator}, + delete_type=#{deleteType}, + index_value=#{indexValue}, + item_name=#{itemName}, + item_value=#{itemValue}, + max_rule=#{maxRule}, + median_rule=#{medianRule}, + min_rule=#{minRule}, + stat_report_id=#{statReportId}, + sum_rule=#{sumRule}, + tenant_key=#{tenantKey}, + unit_type=#{unitType}, + update_time=#{updateTime}, + last_rule=#{lastRule}, + old_rule=#{oldRule}, + frequent_rule=#{frequentRule}, + tile_rule=#{tileRule}, + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_salary_statistics_item + + + avg_rule=#{avgRule}, + + + count_rule=#{countRule}, + + + create_time=#{createTime}, + + + creator=#{creator}, + + + delete_type=#{deleteType}, + + + index_value=#{indexValue}, + + + item_name=#{itemName}, + + + item_value=#{itemValue}, + + + max_rule=#{maxRule}, + + + median_rule=#{medianRule}, + + + min_rule=#{minRule}, + + + stat_report_id=#{statReportId}, + + + sum_rule=#{sumRule}, + + + tenant_key=#{tenantKey}, + + + unit_type=#{unitType}, + + + update_time=#{updateTime}, + + + last_rule=#{lastRule}, + + + old_rule=#{oldRule}, + + + frequent_rule=#{frequentRule}, + + + tile_rule=#{tileRule}, + + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_salary_statistics_item + SET delete_type=1 + WHERE id = #{id} + AND delete_type = 0 + + + + UPDATE hrsa_salary_statistics_item + SET delete_type = 1 + WHERE delete_type = 0 + AND id IN + + #{id} + + + + + UPDATE hrsa_salary_statistics_item + SET delete_type = 1 + WHERE delete_type = 0 + AND stat_report_id IN + + #{reportIds} + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/report/SalaryStatisticsPushMapper.java b/src/com/engine/salary/mapper/report/SalaryStatisticsPushMapper.java new file mode 100644 index 000000000..bc49e30f6 --- /dev/null +++ b/src/com/engine/salary/mapper/report/SalaryStatisticsPushMapper.java @@ -0,0 +1,83 @@ +package com.engine.salary.mapper.report; + +import com.engine.salary.report.entity.po.SalaryStatisticsPushPO; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * @author Harryxzy + * @ClassName SalaryStatisticsPushMapper + * @date 2023/09/11 10:36 + * @description 报表分享 + */ +public interface SalaryStatisticsPushMapper { + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + /** + * 条件查询 + * + * @return 返回集合,没有返回空List + */ + List listSome(SalaryStatisticsPushPO SalaryStatisticsPushPO); + + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + SalaryStatisticsPushPO getById(Long id); + + /** + * 新增,忽略null字段 + * + * @param SalaryStatisticsPushPO 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(SalaryStatisticsPushPO SalaryStatisticsPushPO); + + /** + * 修改,修改所有字段 + * + * @param SalaryStatisticsPushPO 修改的记录 + * @return 返回影响行数 + */ + int update(SalaryStatisticsPushPO SalaryStatisticsPushPO); + + /** + * 修改,忽略null字段 + * + * @param SalaryStatisticsPushPO 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(SalaryStatisticsPushPO SalaryStatisticsPushPO); + + /** + * 删除记录 + * + * @param SalaryStatisticsPushPO 待删除的记录 + * @return 返回影响行数 + */ + int delete(SalaryStatisticsPushPO SalaryStatisticsPushPO); + + /** + * 获取该用户最新创建的分享记录 + * @param empId + */ + List listLatestRecordByCreator(@Param("empId") Long empId); + + /** + * 根据报表id模糊查询 + * @param reportId + * @return + */ + List listByReportIdAndIds(@Param("reportId") String reportId, @Param("ids") List ids); +} diff --git a/src/com/engine/salary/mapper/report/SalaryStatisticsPushMapper.xml b/src/com/engine/salary/mapper/report/SalaryStatisticsPushMapper.xml new file mode 100644 index 000000000..faebe7b3d --- /dev/null +++ b/src/com/engine/salary/mapper/report/SalaryStatisticsPushMapper.xml @@ -0,0 +1,358 @@ + + + + + + + + + + + + + + + + + + + + + + + + t.id + , t.create_time + , t.update_time + , t.creator + , t.delete_type + , t.tenant_key + , t.report_ids + , t.start_time + , t.end_time + , t.push_channel + , t.email_account + , t.mark + , t.push_title + , t.email_account_id + , t.remind + + + + + + + + + + + + + + + + + + + + + + + INSERT INTO hrsa_report_push + + + + id, + + + create_time, + + + update_time, + + + creator, + + + delete_type, + + + tenant_key, + + + report_ids, + + + start_time, + + + end_time, + + + push_channel, + + + email_account, + + + mark, + + + push_title, + + + email_account_id, + + + remind, + + + + + #{id}, + + + #{createTime}, + + + #{updateTime}, + + + #{creator}, + + + #{deleteType}, + + + #{tenantKey}, + + + #{reportIds}, + + + #{startTime}, + + + #{endTime}, + + + #{pushChannel}, + + + #{emailAccount}, + + + #{mark}, + + + #{pushTitle}, + + + #{emailAccountId}, + + + #{remind}, + + + + + + + UPDATE hrsa_report_push + + create_time=#{createTime}, + update_time=#{updateTime}, + creator=#{creator}, + delete_type=#{deleteType}, + tenant_key=#{tenantKey}, + report_ids=#{reportIds}, + start_time=#{startTime}, + end_time=#{endTime}, + push_channel=#{pushChannel}, + email_account=#{emailAccount}, + mark=#{mark}, + push_title=#{pushTitle}, + email_account_id=#{emailAccountId}, + remind=#{remind}, + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_report_push + + + create_time=#{createTime}, + + + update_time=#{updateTime}, + + + creator=#{creator}, + + + delete_type=#{deleteType}, + + + tenant_key=#{tenantKey}, + + + report_ids=#{reportIds}, + + + start_time=#{startTime}, + + + end_time=#{endTime}, + + + push_channel=#{pushChannel}, + + + email_account=#{emailAccount}, + + + mark=#{mark}, + + + push_title=#{pushTitle}, + + + email_account_id=#{emailAccountId}, + + + remind=#{remind}, + + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_report_push + SET delete_type=1 + WHERE id = #{id} AND delete_type = 0 + + + + diff --git a/src/com/engine/salary/mapper/report/SalaryStatisticsReportMapper.java b/src/com/engine/salary/mapper/report/SalaryStatisticsReportMapper.java new file mode 100644 index 000000000..0a318ae78 --- /dev/null +++ b/src/com/engine/salary/mapper/report/SalaryStatisticsReportMapper.java @@ -0,0 +1,71 @@ +package com.engine.salary.mapper.report; + +import com.engine.salary.report.entity.po.SalaryStatisticsReportPO; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; + +public interface SalaryStatisticsReportMapper { + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + /** + * 条件查询 + * + * @return 返回集合,没有返回空List + */ + List listSome(SalaryStatisticsReportPO SalaryStatisticsReportPO); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + SalaryStatisticsReportPO getById(Long id); + + /** + * 新增,忽略null字段 + * + * @param SalaryStatisticsReportPO 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(SalaryStatisticsReportPO SalaryStatisticsReportPO); + + /** + * 修改,修改所有字段 + * + * @param SalaryStatisticsReportPO 修改的记录 + * @return 返回影响行数 + */ + int update(SalaryStatisticsReportPO SalaryStatisticsReportPO); + + /** + * 修改,忽略null字段 + * + * @param SalaryStatisticsReportPO 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(SalaryStatisticsReportPO SalaryStatisticsReportPO); + + /** + * 删除记录 + * + * @param id 待删除的记录 + * @return 返回影响行数 + */ + int delete(Long id); + + /** + * 批量删除记录 + * @param ids 主键id集合 + * @return + */ + void deleteByIds(@Param("ids") Collection ids); +} diff --git a/src/com/engine/salary/mapper/report/SalaryStatisticsReportMapper.xml b/src/com/engine/salary/mapper/report/SalaryStatisticsReportMapper.xml new file mode 100644 index 000000000..4b04c8342 --- /dev/null +++ b/src/com/engine/salary/mapper/report/SalaryStatisticsReportMapper.xml @@ -0,0 +1,476 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + t + . + create_time + , t.creator + , t.delete_type + , t.depart_setting + , t.dimension + , t.employee_setting + , t.grade_setting + , t.hiredate_setting + , t.id + , t.income_category_setting + , t.leavedate_setting + , t.position_setting + , t.remark + , t.report_name + , t.salary_end_month + , t.salary_start_month + , t.second_dimension + , t.sort_index + , t.sort_type + , t.status_setting + , t.sub_company_setting + , t.tax_agent_setting + , t.tenant_key + , t.update_time + , t.time_type + , t.salary_sob_setting + + + + + + + + + + + + + + + INSERT INTO hrsa_salary_stats_report + + + + create_time, + + + creator, + + + delete_type, + + + depart_setting, + + + dimension, + + + employee_setting, + + + grade_setting, + + + hiredate_setting, + + + id, + + + income_category_setting, + + + leavedate_setting, + + + position_setting, + + + remark, + + + report_name, + + + time_type, + + + salary_end_month, + + + salary_start_month, + + + second_dimension, + + + sort_index, + + + sort_type, + + + status_setting, + + + sub_company_setting, + + + tax_agent_setting, + + + salary_sob_setting, + + + tenant_key, + + + update_time, + + + + + #{createTime}, + + + #{creator}, + + + #{deleteType}, + + + #{departSetting}, + + + #{dimension}, + + + #{employeeSetting}, + + + #{gradeSetting}, + + + #{hiredateSetting}, + + + #{id}, + + + #{incomeCategorySetting}, + + + #{leavedateSetting}, + + + #{positionSetting}, + + + #{remark}, + + + #{reportName}, + + + #{timeType}, + + + #{salaryEndMonth}, + + + #{salaryStartMonth}, + + + #{secondDimension}, + + + #{sortIndex}, + + + #{sortType}, + + + #{statusSetting}, + + + #{subCompanySetting}, + + + #{taxAgentSetting}, + + + #{salarySobSetting}, + + + #{tenantKey}, + + + #{updateTime}, + + + + + + + UPDATE hrsa_salary_stats_report + + create_time=#{createTime}, + creator=#{creator}, + delete_type=#{deleteType}, + depart_setting=#{departSetting}, + dimension=#{dimension}, + employee_setting=#{employeeSetting}, + grade_setting=#{gradeSetting}, + hiredate_setting=#{hiredateSetting}, + income_category_setting=#{incomeCategorySetting}, + leavedate_setting=#{leavedateSetting}, + position_setting=#{positionSetting}, + remark=#{remark}, + report_name=#{reportName}, + time_type=#{timeType}, + salary_end_month=#{salaryEndMonth}, + salary_start_month=#{salaryStartMonth}, + second_dimension=#{secondDimension}, + sort_index=#{sortIndex}, + sort_type=#{sortType}, + status_setting=#{statusSetting}, + sub_company_setting=#{subCompanySetting}, + tax_agent_setting=#{taxAgentSetting}, + salary_sob_setting=#{salarySobSetting}, + tenant_key=#{tenantKey}, + update_time=#{updateTime}, + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_salary_stats_report + + + create_time=#{createTime}, + + + creator=#{creator}, + + + delete_type=#{deleteType}, + + + depart_setting=#{departSetting}, + + + dimension=#{dimension}, + + + employee_setting=#{employeeSetting}, + + + grade_setting=#{gradeSetting}, + + + hiredate_setting=#{hiredateSetting}, + + + income_category_setting=#{incomeCategorySetting}, + + + leavedate_setting=#{leavedateSetting}, + + + position_setting=#{positionSetting}, + + + remark=#{remark}, + + + report_name=#{reportName}, + + + time_type=#{timeType}, + + + salary_end_month=#{salaryEndMonth}, + + + salary_start_month=#{salaryStartMonth}, + + + second_dimension=#{secondDimension}, + + + sort_index=#{sortIndex}, + + + sort_type=#{sortType}, + + + status_setting=#{statusSetting}, + + + sub_company_setting=#{subCompanySetting}, + + + tax_agent_setting=#{taxAgentSetting}, + + + salary_sob_setting=#{salarySobSetting}, + + + tenant_key=#{tenantKey}, + + + update_time=#{updateTime}, + + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_salary_stats_report + SET delete_type=1 + WHERE id = #{id} + AND delete_type = 0 + + + + UPDATE hrsa_salary_stats_report + SET delete_type = 1 + WHERE delete_type = 0 + AND id IN + + #{id} + + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/report/salaryStatisticsPushDetailMapper.java b/src/com/engine/salary/mapper/report/salaryStatisticsPushDetailMapper.java new file mode 100644 index 000000000..e2cd55093 --- /dev/null +++ b/src/com/engine/salary/mapper/report/salaryStatisticsPushDetailMapper.java @@ -0,0 +1,81 @@ +package com.engine.salary.mapper.report; + +import com.engine.salary.report.entity.po.SalaryStatisticsPushDetailPO; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * @author Harryxzy + * @ClassName SalaryStatisticsPushPOMapper + * @date 2023/09/11 11:01 + * @description 报表分享明细 + */ +public interface salaryStatisticsPushDetailMapper { + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + /** + * 条件查询 + * + * @return 返回集合,没有返回空List + */ + List listSome(SalaryStatisticsPushDetailPO SalaryStatisticsPushDetailPO); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + SalaryStatisticsPushDetailPO getById(Long id); + + /** + * 新增,忽略null字段 + * + * @param SalaryStatisticsPushDetailPO 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(SalaryStatisticsPushDetailPO SalaryStatisticsPushDetailPO); + + /** + * 修改,修改所有字段 + * + * @param SalaryStatisticsPushDetailPO 修改的记录 + * @return 返回影响行数 + */ + int update(SalaryStatisticsPushDetailPO SalaryStatisticsPushDetailPO); + + /** + * 修改,忽略null字段 + * + * @param SalaryStatisticsPushDetailPO 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(SalaryStatisticsPushDetailPO SalaryStatisticsPushDetailPO); + + /** + * 删除记录 + * + * @param SalaryStatisticsPushDetailPO 待删除的记录 + * @return 返回影响行数 + */ + int delete(SalaryStatisticsPushDetailPO SalaryStatisticsPushDetailPO); + + /** + * 根据批次id查询 + * @param batchIds + */ + List queryPushDetailPOByBatchId(@Param("batchIds") List batchIds); + + /** + * 根据批次id、员工id查询 + * @param + */ + List queryPushDetailPOByBatchIdAndEmpIds(@Param("batchId")Long batchId, @Param("empIds")List sharedBy); +} diff --git a/src/com/engine/salary/mapper/report/salaryStatisticsPushDetailMapper.xml b/src/com/engine/salary/mapper/report/salaryStatisticsPushDetailMapper.xml new file mode 100644 index 000000000..03bb7321e --- /dev/null +++ b/src/com/engine/salary/mapper/report/salaryStatisticsPushDetailMapper.xml @@ -0,0 +1,319 @@ + + + + + + + + + + + + + + + + + + + + + + + t.id + , t.create_time + , t.update_time + , t.creator + , t.delete_type + , t.tenant_key + , t.msg_id + , t.employee_id + , t.push_time + , t.push_status + , t.reback_time + , t.reback_status + , t.batch_id + , t.view_status + + + + + + + + + + + + + + + + + + + INSERT INTO hrsa_report_push_detail + + + + id, + + + create_time, + + + update_time, + + + creator, + + + delete_type, + + + tenant_key, + + + msg_id, + + + employee_id, + + + push_time, + + + push_status, + + + reback_time, + + + reback_status, + + + batch_id, + + + view_status, + + + + + #{id}, + + + #{createTime}, + + + #{updateTime}, + + + #{creator}, + + + #{deleteType}, + + + #{tenantKey}, + + + #{msgId}, + + + #{employeeId}, + + + #{pushTime}, + + + #{pushStatus}, + + + #{rebackTime}, + + + #{rebackStatus}, + + + #{batchId}, + + + #{viewStatus}, + + + + + + + UPDATE hrsa_report_push_detail + + create_time=#{createTime}, + update_time=#{updateTime}, + creator=#{creator}, + delete_type=#{deleteType}, + tenant_key=#{tenantKey}, + msg_id=#{msgId}, + employee_id=#{employeeId}, + push_time=#{pushTime}, + push_status=#{pushStatus}, + reback_time=#{rebackTime}, + reback_status=#{rebackStatus}, + batch_id=#{batchId}, + view_status=#{viewStatus}, + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_report_push_detail + + + create_time=#{createTime}, + + + update_time=#{updateTime}, + + + creator=#{creator}, + + + delete_type=#{deleteType}, + + + tenant_key=#{tenantKey}, + + + msg_id=#{msgId}, + + + employee_id=#{employeeId}, + + + push_time=#{pushTime}, + + + push_status=#{pushStatus}, + + + + reback_time = null, + + + reback_time=#{rebackTime}, + + + + reback_status=#{rebackStatus}, + + + batch_id=#{batchId}, + + + view_status=#{viewStatus}, + + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_report_push_detail + SET delete_type=1 + WHERE id = #{id} AND delete_type = 0 + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/salaryacct/ExcelAcctResultMapper.java b/src/com/engine/salary/mapper/salaryacct/ExcelAcctResultMapper.java new file mode 100644 index 000000000..4bc5038a8 --- /dev/null +++ b/src/com/engine/salary/mapper/salaryacct/ExcelAcctResultMapper.java @@ -0,0 +1,56 @@ +package com.engine.salary.mapper.salaryacct; + +import com.engine.salary.entity.salaryacct.po.ExcelAcctResultPO; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; + +/** + * 线下excel核算的结果 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public interface ExcelAcctResultMapper { + + /** + * 分页查询ExcelAcctResult和SalaryAcctResult的employeeId + * + * @return + */ + List listEmployeeIdUnionSalaryAcctResult(@Param("employeeIds") Collection employeeIds, + @Param("salaryAcctRecordId") Long salaryAcctRecordId); + + /** + * 批量新增 + * + * @param excelAcctResults + */ + void batchInsert(@Param("collection") Collection excelAcctResults); + + /** + * 根据薪资核算记录id删除 + * + * @param salaryAcctEmployeeIds + */ + void deleteBySalaryAcctEmployeeIds(@Param("salaryAcctEmployeeIds") Collection salaryAcctEmployeeIds); + + /** + * 根据薪资核算记录id删除 + * + * @param salaryAcctRecordIds + */ + void deleteBySalaryAcctRecordIds(@Param("salaryAcctRecordIds") Collection salaryAcctRecordIds); + + /** + * 条件查询 + * + * @return 返回集合,没有返回空List + */ + List listSome(ExcelAcctResultPO excelAcctResult); + + int batchUpdate(@Param("collection") List excelAcctResultPos); +} diff --git a/src/com/engine/salary/mapper/salaryacct/ExcelAcctResultMapper.xml b/src/com/engine/salary/mapper/salaryacct/ExcelAcctResultMapper.xml new file mode 100644 index 000000000..afbd2083e --- /dev/null +++ b/src/com/engine/salary/mapper/salaryacct/ExcelAcctResultMapper.xml @@ -0,0 +1,222 @@ + + + + + + + + INSERT INTO hrsa_excel_acct_result(salary_sob_id, salary_acct_emp_id, salary_acct_record_id, employee_id, + salary_item_id, result_value, creator, create_time, update_time, + delete_type, tenant_key,tax_agent_id) + VALUES + + ( + #{item.salarySobId}, + #{item.salaryAcctEmpId}, + #{item.salaryAcctRecordId}, + #{item.employeeId}, + #{item.salaryItemId}, + #{item.resultValue}, + #{item.creator}, + #{item.createTime}, + #{item.updateTime}, + #{item.deleteType}, + #{item.tenantKey}, + #{item.taxAgentId} + ) + + + + INSERT INTO hrsa_excel_acct_result(salary_sob_id, salary_acct_emp_id, salary_acct_record_id, employee_id, + salary_item_id, result_value, creator, create_time, update_time, + delete_type, tenant_key,tax_agent_id) + + + select + #{item.salarySobId,jdbcType=DOUBLE}, + #{item.salaryAcctEmpId,jdbcType=DOUBLE}, + #{item.salaryAcctRecordId,jdbcType=DOUBLE}, + #{item.employeeId,jdbcType=DOUBLE}, + #{item.salaryItemId,jdbcType=DOUBLE}, + #{item.resultValue,jdbcType=VARCHAR}, + #{item.creator,jdbcType=DOUBLE}, + #{item.createTime,jdbcType=DATE}, + #{item.updateTime,jdbcType=DATE}, + #{item.deleteType,jdbcType=INTEGER}, + #{item.tenantKey,jdbcType=VARCHAR}, + #{item.taxAgentId,jdbcType=DOUBLE} + from dual + + + + + INSERT INTO hrsa_excel_acct_result( salary_sob_id, salary_acct_emp_id, salary_acct_record_id, employee_id, + salary_item_id, result_value, creator, create_time, update_time, + delete_type, tenant_key, tax_agent_id) + VALUES + ( + #{item.salarySobId}, + #{item.salaryAcctEmpId}, + #{item.salaryAcctRecordId}, + #{item.employeeId}, + #{item.salaryItemId}, + #{item.resultValue}, + #{item.creator}, + #{item.createTime}, + #{item.updateTime}, + #{item.deleteType}, + #{item.tenantKey}, + #{item.taxAgentId} + ) + + + + + DELETE FROM hrsa_excel_acct_result + WHERE salary_acct_emp_id IN + + #{salaryAcctEmployeeId} + + + + + DELETE FROM hrsa_excel_acct_result + WHERE salary_acct_record_id IN + + #{salaryAcctRecordId} + + + + + + + + + + + + + + + + + + + + + + + t.id + , t.salary_sob_id + , t.salary_acct_emp_id + , t.salary_acct_record_id + , t.employee_id + , t.salary_item_id + , t.result_value + , t.creator + , t.create_time + , t.update_time + , t.delete_type + , t.tenant_key + , t.tax_agent_id + + + + + + + update hrsa_excel_acct_result + + + + + when id=#{item.id} then #{item.resultValue} + + + + + + + when id=#{item.id} then #{item.deleteType} + + + + + where + id in + + #{item.id} + + + diff --git a/src/com/engine/salary/mapper/salaryacct/SalaryAcctEmployeeMapper.java b/src/com/engine/salary/mapper/salaryacct/SalaryAcctEmployeeMapper.java new file mode 100644 index 000000000..a7f66818a --- /dev/null +++ b/src/com/engine/salary/mapper/salaryacct/SalaryAcctEmployeeMapper.java @@ -0,0 +1,129 @@ +package com.engine.salary.mapper.salaryacct; + +import com.engine.salary.entity.salaryacct.dto.SalaryAcctEmployeeCountDTO; +import com.engine.salary.entity.salaryacct.param.SalaryAcctEmployeeQueryParam; +import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; +import java.util.Set; + +/** + * 薪资核算人员 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public interface SalaryAcctEmployeeMapper { + + /** + * 批量插入 + * + * @param salaryAccountingEmployees + */ + void batchInsert(@Param("collection") Collection salaryAccountingEmployees); + + /** + * 统计薪资核算记录的人数 + * + * @param salaryAcctRecordIds + * @return + */ + List countGroupBySalaryAcctRecordId(@Param("salaryAcctRecordIds") Collection salaryAcctRecordIds); + + /** + * 查询合并计税的人员(分页) + * + * @param otherSalaryAcctRecordIds 相同税款所属期内的其他工资薪金类型的薪资账套的薪资核算记录id + * @param param 人员查询参数 + * @return + */ + List listPage4ConsolidatedTax(@Param("otherSalaryAcctRecordIds") Collection otherSalaryAcctRecordIds, + @Param("param") SalaryAcctEmployeeQueryParam param); + + /** + * 查询合并计税的人员 + * + * @param otherSalaryAcctRecordIds 相同税款所属期内的其他工资薪金类型的薪资账套的薪资核算记录id + * @param param 人员查询参数 + * @return + */ + List list4ConsolidatedTax(@Param("otherSalaryAcctRecordIds") Collection otherSalaryAcctRecordIds, + @Param("param") SalaryAcctEmployeeQueryParam param); + + /** + * 分页查询薪资核算人员 + * + * @param param + * @return + */ + List listPage(@Param("param") SalaryAcctEmployeeQueryParam param); + + /** + * 查询薪资核算人员 + * + * @param param + * @return + */ + List list(@Param("param") SalaryAcctEmployeeQueryParam param); + + /** + * 分页查询薪资核算人员环比减少的人员 + * + * @param lastMonSalaryAcctRecordIds + * @param param + * @return + */ + List listPage4Reduce(@Param("lastMonSalaryAcctRecordIds") Collection lastMonSalaryAcctRecordIds, + @Param("param") SalaryAcctEmployeeQueryParam param); + + /** + * 查询薪资核算人员环比减少的人员 + * + * @param lastMonSalaryAcctRecordIds + * @param param + * @return + */ + List list4Reduce(@Param("lastMonSalaryAcctRecordIds") Collection lastMonSalaryAcctRecordIds, + @Param("param") SalaryAcctEmployeeQueryParam param); + + /** + * 根据主键id删除 + * + * @param ids + */ + void deleteByIds(@Param("ids") Collection ids); + + /** + * 根据薪资核算记录id删除 + * + * @param salaryAcctRecordIds + */ + void deleteBySalaryAcctRecordIds(@Param("salaryAcctRecordIds") Collection salaryAcctRecordIds); + + /** + * 条件查询 + * + * @return 返回集合,没有返回空List + */ + List listSome(SalaryAcctEmployeePO salaryAcctEmp); + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + SalaryAcctEmployeePO getById(Long id); + + void lockByAcctEmpIds(@Param("lockStatus") Integer lockStatus, @Param("acctEmpIds") Set acctEmpIds); + + void lockByRecordId(@Param("lockStatus") Integer lockStatus, @Param("recordId") Long recordId); + + void updateIgnoreNull(@Param("salaryAcctEmployeePO")SalaryAcctEmployeePO salaryAcctEmployeePO); + + void lock(SalaryAcctEmployeePO salaryAcctEmployeePO); +} diff --git a/src/com/engine/salary/mapper/salaryacct/SalaryAcctEmployeeMapper.xml b/src/com/engine/salary/mapper/salaryacct/SalaryAcctEmployeeMapper.xml new file mode 100644 index 000000000..9aeca4df9 --- /dev/null +++ b/src/com/engine/salary/mapper/salaryacct/SalaryAcctEmployeeMapper.xml @@ -0,0 +1,1250 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + t + . + id + , + t.salary_acct_record_id, + t.salary_sob_id, + t.employee_id, + t.tax_agent_id, + t.salary_month, + t.creator, + t.create_time, + t.update_time, + t.delete_type, + t.tenant_key, + t.employee_type, + t.lock_status, + t.subcompany_name, + t.subcompany_id, + t.department_name, + t.department_id, + t.jobtitle_name, + t.jobtitle_id, + t.jobcall, + t.jobcall_id, + t.status, + t.lock_items, + t.account_type + + + + emp1 + . + id + , emp1.salary_acct_record_id, emp1.salary_sob_id, emp1.employee_id, emp1.tax_agent_id, emp1.salary_month, + emp1.creator, emp1.create_time, emp1.update_time, emp1.delete_type, emp1.tenant_key,emp1.employee_type + + + + INSERT INTO hrsa_salary_acct_emp( + salary_acct_record_id, salary_sob_id, employee_id, tax_agent_id, salary_month, + creator, create_time, update_time, delete_type, tenant_key,employee_type,lock_status, + subcompany_name, + subcompany_id, + department_name, + department_id, + jobtitle_name, + jobtitle_id, + jobcall, + jobcall_id, + status, + account_type) + VALUES + + ( + #{emp.salaryAcctRecordId}, + #{emp.salarySobId}, + #{emp.employeeId}, + #{emp.taxAgentId}, + #{emp.salaryMonth}, + #{emp.creator}, + #{emp.createTime}, + #{emp.updateTime}, + #{emp.deleteType}, + #{emp.tenantKey}, + #{emp.employeeType}, + #{emp.lockStatus}, + #{emp.subcompanyName}, + #{emp.subcompanyId}, + #{emp.departmentName}, + #{emp.departmentId}, + #{emp.jobtitleName}, + #{emp.jobtitleId}, + #{emp.jobcall}, + #{emp.jobcallId}, + #{emp.status}, + #{emp.accountType} + ) + + + + INSERT INTO hrsa_salary_acct_emp( + salary_acct_record_id, salary_sob_id, employee_id, tax_agent_id, salary_month, + creator, create_time, update_time, delete_type, tenant_key,employee_type,lock_status, + subcompany_name, + subcompany_id, + department_name, + department_id, + jobtitle_name, + jobtitle_id, + jobcall, + jobcall_id, + status, + account_type + ) + + select + #{emp.salaryAcctRecordId,jdbcType=DOUBLE}, + #{emp.salarySobId,jdbcType=DOUBLE}, + #{emp.employeeId,jdbcType=DOUBLE}, + #{emp.taxAgentId,jdbcType=DOUBLE}, + #{emp.salaryMonth,jdbcType=DATE}, + #{emp.creator,jdbcType=DOUBLE}, + #{emp.createTime,jdbcType=DATE}, + #{emp.updateTime,jdbcType=DATE}, + #{emp.deleteType,jdbcType=INTEGER}, + #{emp.tenantKey,jdbcType=VARCHAR}, + #{emp.employeeType,jdbcType=INTEGER}, + #{emp.lockStatus,jdbcType=INTEGER}, + #{emp.subcompanyName,jdbcType=VARCHAR}, + #{emp.subcompanyId,jdbcType=DOUBLE}, + #{emp.departmentName,jdbcType=VARCHAR}, + #{emp.departmentId,jdbcType=DOUBLE}, + #{emp.jobtitleName,jdbcType=VARCHAR}, + #{emp.jobtitleId,jdbcType=DOUBLE}, + #{emp.jobcall,jdbcType=VARCHAR}, + #{emp.jobcallId,jdbcType=DOUBLE}, + #{emp.status,jdbcType=VARCHAR}, + #{emp.accountType,jdbcType=INTEGER} + from dual + + + + + INSERT INTO hrsa_salary_acct_emp( + salary_acct_record_id, salary_sob_id, employee_id, tax_agent_id, salary_month, + creator, create_time, update_time, delete_type, tenant_key,employee_type,lock_status, + subcompany_name, + subcompany_id, + department_name, + department_id, + jobtitle_name, + jobtitle_id, + jobcall, + jobcall_id, + status, + account_type + ) + VALUES + ( + #{emp.salaryAcctRecordId}, + #{emp.salarySobId}, + #{emp.employeeId}, + #{emp.taxAgentId}, + #{emp.salaryMonth}, + #{emp.creator}, + #{emp.createTime}, + #{emp.updateTime}, + #{emp.deleteType}, + #{emp.tenantKey}, + #{emp.employeeType}, + #{emp.lockStatus}, + #{emp.subcompanyName}, + #{emp.subcompanyId}, + #{emp.departmentName}, + #{emp.departmentId}, + #{emp.jobtitleName}, + #{emp.jobtitleId}, + #{emp.jobcall}, + #{emp.jobcallId}, + #{emp.status}, + #{emp.accountType} + ) + + + + + + + + + + + + + + + + + + + + + + + + AND t.salary_acct_record_id = #{param.salaryAcctRecordId} + + + AND t.id IN + + #{id} + + + + AND t.tax_agent_id = #{param.taxAgentId} + + + AND t.tax_agent_id IN + + #{taxAgentId} + + + + AND t.salary_month IN + + #{salaryMonth} + + + -- 分部 + + AND t.subcompany_id IN + + #{subcompanyId} + + + -- 部门 + + AND t.department_id IN + + #{departmentId} + + + + AND t.jobtitle_id IN + + #{positionId} + + + + AND t.status IN + + #{userStatus} + + + + AND t.employee_id IN + ( + SELECT id FROM hrmresource em WHERE em.status not in (7) + + + AND em.lastname LIKE CONCAT('%',#{param.employeeName},'%') + + + AND em.workcode like CONCAT('%',#{param.workcode},'%') + + + union all + + SELECT id FROM hrsa_external_employee extem WHERE extem.status not in (7) + + AND extem.username LIKE CONCAT('%',#{param.employeeName},'%') + + + AND extem.workcode like CONCAT('%',#{param.workcode},'%') + + ) + + + AND t.salary_acct_record_id IN + + #{salaryAcctRecordId} + + + + AND t.employee_id IN + + #{employeeId} + + + + AND t.salary_sob_id IN + + #{salarySobId} + + + + + + AND t.salary_acct_record_id = #{param.salaryAcctRecordId} + + + AND t.id IN + + #{id} + + + + AND t.tax_agent_id = #{param.taxAgentId} + + + AND t.tax_agent_id IN + + #{taxAgentId} + + + + AND t.salary_month IN + + #{salaryMonth} + + + -- 分部 + + AND t.subcompany_id IN + + #{subcompanyId} + + + -- 部门 + + AND t.department_id IN + + #{departmentId} + + + + AND t.jobtitle_id IN + + #{positionId} + + + + AND t.status IN + + #{userStatus} + + + + AND t.employee_id IN + ( + SELECT id FROM hrmresource em WHERE em.status not in (7) + + + AND em.lastname LIKE '%'||#{param.employeeName}||'%' + + + AND em.workcode like '%'||#{param.workcode}||'%' + + union all + SELECT id FROM hrsa_external_employee extem WHERE extem.status not in (7) + + AND extem.username LIKE '%'||#{param.employeeName}||'%' + + + AND extem.workcode like '%'||#{param.workcode}||'%' + + ) + + + AND t.salary_acct_record_id IN + + #{salaryAcctRecordId} + + + + AND t.employee_id IN + + #{employeeId} + + + + AND t.salary_sob_id IN + + #{salarySobId} + + + + + + AND t.salary_acct_record_id = #{param.salaryAcctRecordId} + + + AND t.id IN + + #{id} + + + + AND t.tax_agent_id = #{param.taxAgentId} + + + AND t.tax_agent_id IN + + #{taxAgentId} + + + + AND t.salary_month IN + + #{salaryMonth} + + + -- 分部 + + AND t.subcompany_id IN + + #{subcompanyId} + + + -- 部门 + + AND t.department_id IN + + #{departmentId} + + + + AND t.jobtitle_id IN + + #{positionId} + + + + AND t.status IN + + #{userStatus} + + + + AND t.employee_id IN + ( + SELECT id FROM hrmresource em WHERE em.status not in (7) + + + AND em.lastname LIKE '%'+#{param.employeeName}+'%' + + + AND em.workcode like '%'+#{param.workcode}+'%' + + union all + + SELECT id FROM hrsa_external_employee extem WHERE extem.status not in (7) + + AND extem.username LIKE '%'+#{param.employeeName}+'%' + + + AND extem.workcode like '%'+#{param.workcode}+'%' + + ) + + + AND t.salary_acct_record_id IN + + #{salaryAcctRecordId} + + + + AND t.employee_id IN + + #{employeeId} + + + + AND t.salary_sob_id IN + + #{salarySobId} + + + + + + + + + + + + + + UPDATE hrsa_salary_acct_emp + SET delete_type = 1 + WHERE delete_type = 0 + AND id IN + + #{id} + + + + + DELETE FROM hrsa_salary_acct_emp + WHERE delete_type = 0 + AND salary_acct_record_id IN + + #{salaryAcctRecordId} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + t + . + id + , t.salary_acct_record_id + , t.salary_sob_id + , t.employee_id + , t.tax_agent_id + , t.salary_month + , t.creator + , t.create_time + , t.update_time + , t.delete_type + , t.tenant_key + , t.employee_type + , t.lock_status + , t.subcompany_name + , t.subcompany_id + , t.department_name + , t.department_id + , t.jobtitle_name + , t.jobtitle_id + , t.jobcall + , t.jobcall_id + , t.status + , t.lock_items + , t.account_type + + + + + + + + + + + + UPDATE hrsa_salary_acct_emp + SET lock_status = #{lockStatus} + WHERE delete_type = 0 + AND id IN + + #{acctEmpId} + + + + + UPDATE hrsa_salary_acct_emp + SET lock_status = #{lockStatus} + WHERE delete_type = 0 + AND salary_acct_record_id = #{recordId} + + + + UPDATE hrsa_salary_acct_emp + + + salary_acct_record_id=#{salaryAcctEmployeePO.salaryAcctRecordId}, + + + salary_sob_id=#{salaryAcctEmployeePO.salarySobId}, + + + employee_id=#{salaryAcctEmployeePO.employeeId}, + + + tax_agent_id=#{salaryAcctEmployeePO.taxAgentId}, + + + salary_month=#{salaryAcctEmployeePO.salaryMonth}, + + + create_time=#{salaryAcctEmployeePO.createTime}, + + + update_time=#{salaryAcctEmployeePO.updateTime}, + + + tenant_key=#{salaryAcctEmployeePO.tenantKey}, + + + employee_type=#{salaryAcctEmployeePO.employeeType}, + + + lock_status=#{salaryAcctEmployeePO.lockStatus}, + + + subcompany_name=#{salaryAcctEmployeePO.subcompanyName}, + + + subcompany_id=#{salaryAcctEmployeePO.subcompanyId}, + + + department_name=#{salaryAcctEmployeePO.departmentName}, + + + department_id=#{salaryAcctEmployeePO.departmentId}, + + + jobtitle_name=#{salaryAcctEmployeePO.jobtitleName}, + + + jobtitle_id=#{salaryAcctEmployeePO.jobtitleId}, + + + jobcall=#{salaryAcctEmployeePO.jobcall}, + + + jobcall_id=#{salaryAcctEmployeePO.jobcallId}, + + + status=#{salaryAcctEmployeePO.status}, + + + account_type=#{salaryAcctEmployeePO.accountType}, + + + WHERE id = #{salaryAcctEmployeePO.id} AND delete_type = 0 + + + + UPDATE hrsa_salary_acct_emp + + lock_items = + #{lockItems, jdbcType=ARRAY, typeHandler=com.engine.salary.handle.SalaryListTypeHandler}, + + WHERE id = #{id} AND delete_type = 0 + + + diff --git a/src/com/engine/salary/mapper/salaryacct/SalaryAcctRecordMapper.java b/src/com/engine/salary/mapper/salaryacct/SalaryAcctRecordMapper.java new file mode 100644 index 000000000..83110f1e6 --- /dev/null +++ b/src/com/engine/salary/mapper/salaryacct/SalaryAcctRecordMapper.java @@ -0,0 +1,84 @@ +package com.engine.salary.mapper.salaryacct; + +import com.engine.salary.common.LocalDateRange; +import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.Date; +import java.util.List; +import java.util.Set; + +public interface SalaryAcctRecordMapper { + + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + /** + * 条件查询 + * + * @return 返回集合,没有返回空List + * @param salaryAcctRecord + */ + List listSome(SalaryAcctRecordPO salaryAcctRecord); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + SalaryAcctRecordPO getById(Long id); + + /** + * 新增,忽略null字段 + * + * @param salaryAcctRecord 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(SalaryAcctRecordPO salaryAcctRecord); + + /** + * 修改,修改所有字段 + * + * @param salaryAcctRecord 修改的记录 + * @return 返回影响行数 + */ + int update(SalaryAcctRecordPO salaryAcctRecord); + + /** + * 修改,忽略null字段 + * + * @param salaryAcctRecord 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(SalaryAcctRecordPO salaryAcctRecord); + + /** + * 删除记录 + * + * @param salaryAcctRecord 待删除的记录 + * @return 返回影响行数 + */ + int delete(SalaryAcctRecordPO salaryAcctRecord); + + /** + * 批量删除 + * + * @param ids + */ + void deleteByIds(@Param("ids") Collection ids); + + List listByCreateDate(@Param(value = "createRange") LocalDateRange createRange, @Param(value = "salarySobIds") Set salarySobIds); + + void updateLockSalaryItemIds(SalaryAcctRecordPO salaryAcctRecord); + + List getBackCalcRecordByIds(@Param("collection") Set salaryAcctIds); + + void updateDate(@Param("id")Long id, @Param("updateTime")Date updateTime); +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/salaryacct/SalaryAcctRecordMapper.xml b/src/com/engine/salary/mapper/salaryacct/SalaryAcctRecordMapper.xml new file mode 100644 index 000000000..12d7e6c4a --- /dev/null +++ b/src/com/engine/salary/mapper/salaryacct/SalaryAcctRecordMapper.xml @@ -0,0 +1,463 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + t + . + id + , t.salary_month + , t.tax_cycle + , t.salary_sob_id + , t.status + , t.acct_times + , t.description + , t.creator + , t.create_time + , t.update_time + , t.delete_type + , t.tenant_key + , t.back_calc_status + , t.lock_salary_item_ids + , t.approval_status + , t.approval_id + + + + + + + + + + + + + + + + + + INSERT INTO hrsa_salary_acct_record + + + + id, + + + salary_month, + + + tax_cycle, + + + salary_sob_id, + + + status, + + + acct_times, + + + description, + + + creator, + + + create_time, + + + update_time, + + + delete_type, + + + tenant_key, + + + + + #{id}, + + + #{salaryMonth}, + + + #{taxCycle}, + + + #{salarySobId}, + + + #{status}, + + + #{acctTimes}, + + + #{description}, + + + #{creator}, + + + #{createTime}, + + + #{updateTime}, + + + #{deleteType}, + + + #{tenantKey}, + + + + + + + select hrsa_salary_acct_record_id.currval from dual + + INSERT INTO hrsa_salary_acct_record + + + + id, + + + salary_month, + + + tax_cycle, + + + salary_sob_id, + + + status, + + + acct_times, + + + description, + + + creator, + + + create_time, + + + update_time, + + + delete_type, + + + tenant_key, + + + + + #{id}, + + + #{salaryMonth}, + + + #{taxCycle}, + + + #{salarySobId}, + + + #{status}, + + + #{acctTimes}, + + + #{description}, + + + #{creator}, + + + #{createTime}, + + + #{updateTime}, + + + #{deleteType}, + + + #{tenantKey}, + + + + + + + UPDATE hrsa_salary_acct_record + + salary_month=#{salaryMonth}, + tax_cycle=#{taxCycle}, + salary_sob_id=#{salarySobId}, + status=#{status}, + acct_times=#{acctTimes}, + description=#{description}, + creator=#{creator}, + create_time=#{createTime}, + update_time=#{updateTime}, + delete_type=#{deleteType}, + tenant_key=#{tenantKey}, + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_salary_acct_record + + + salary_month=#{salaryMonth}, + + + tax_cycle=#{taxCycle}, + + + salary_sob_id=#{salarySobId}, + + + status=#{status}, + + + acct_times=#{acctTimes}, + + + description=#{description}, + + + creator=#{creator}, + + + create_time=#{createTime}, + + + update_time=#{updateTime}, + + + delete_type=#{deleteType}, + + + tenant_key=#{tenantKey}, + + + back_calc_status=#{backCalcStatus}, + + + approval_id=#{approvalId}, + + + approval_status=#{approvalStatus}, + + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_salary_acct_record + SET delete_type=1 + WHERE id = #{id} + AND delete_type = 0 + + + + UPDATE hrsa_salary_acct_record + SET delete_type = 1 + WHERE delete_type = 0 + AND id IN + + #{id} + + + + + + + UPDATE hrsa_salary_acct_record + + lock_salary_item_ids = + #{lockSalaryItemIds, jdbcType=ARRAY, typeHandler=com.engine.salary.handle.SalaryListTypeHandler}, + + WHERE id = #{id} AND delete_type = 0 + + + + UPDATE hrsa_salary_acct_record + SET update_time=#{updateTime} + WHERE delete_type = 0 + AND id = #{id} + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/salaryacct/SalaryAcctResultLogMapper.java b/src/com/engine/salary/mapper/salaryacct/SalaryAcctResultLogMapper.java new file mode 100644 index 000000000..c69a4ce49 --- /dev/null +++ b/src/com/engine/salary/mapper/salaryacct/SalaryAcctResultLogMapper.java @@ -0,0 +1,81 @@ +package com.engine.salary.mapper.salaryacct; + +import com.engine.salary.entity.salaryacct.param.SalaryAcctResultLogQueryParam; +import com.engine.salary.entity.salaryacct.po.SalaryAcctResultLogPO; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.Date; +import java.util.List; + +/** + * @author Harryxzy + * @date 2023/05/12 15:21 + * @description + */ +public interface SalaryAcctResultLogMapper { + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + /** + * 条件查询 + * + * @return 返回集合,没有返回空List + */ + List listSome(SalaryAcctResultLogQueryParam queryParam); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + SalaryAcctResultLogPO getById(Long id); + + /** + * 新增,忽略null字段 + * + * @param salaryAcctResultLog 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(SalaryAcctResultLogPO salaryAcctResultLog); + + /** + * 修改,修改所有字段 + * + * @param salaryAcctResultLog 修改的记录 + * @return 返回影响行数 + */ + int update(SalaryAcctResultLogPO salaryAcctResultLog); + + /** + * 修改,忽略null字段 + * + * @param salaryAcctResultLog 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(SalaryAcctResultLogPO salaryAcctResultLog); + + /** + * 删除记录 + * + * @param salaryAcctResultLog 待删除的记录 + * @return 返回影响行数 + */ + int delete(SalaryAcctResultLogPO salaryAcctResultLog); + + void batchInsert(List SalaryAcctResultLogList); + + /** + * 根据薪资核算人员删除数据,除了已经锁定的值 + * @param salaryAcctEmployeeIds + * @param lockSalaryItemIds + */ + void deleteBySalaryAcctEmpIdExceptItemIds(@Param("salaryAcctEmployeeIds") List salaryAcctEmployeeIds, + @Param("exceptItems") Collection lockSalaryItemIds, @Param("updateTime") Date updateTime); +} diff --git a/src/com/engine/salary/mapper/salaryacct/SalaryAcctResultLogMapper.xml b/src/com/engine/salary/mapper/salaryacct/SalaryAcctResultLogMapper.xml new file mode 100644 index 000000000..66f70fa85 --- /dev/null +++ b/src/com/engine/salary/mapper/salaryacct/SalaryAcctResultLogMapper.xml @@ -0,0 +1,306 @@ + + + + + + + + + + + + + + + + + + + t.datasource + , t.delete_type + , t.employee_id + , t.id + , t.operate_time + , t.operator + , t.salary_acct_emp_id + , t.salary_acct_record_id + , t.salary_acct_result_id + , t.salary_item_id + + + + + + + + + + + + + + + INSERT INTO hrsa_salary_acct_result_log + + + + datasource, + + + delete_type, + + + employee_id, + + + id, + + + operate_time, + + + operator, + + + salary_acct_emp_id, + + + salary_acct_record_id, + + + salary_acct_result_id, + + + salary_item_id, + + + + + #{datasource}, + + + #{deleteType}, + + + #{employeeId}, + + + #{id}, + + + #{operateTime}, + + + #{operator}, + + + #{salaryAcctEmpId}, + + + #{salaryAcctRecordId}, + + + #{salaryAcctResultId}, + + + #{salaryItemId}, + + + + + + INSERT INTO hrsa_salary_acct_result_log(id, datasource, salary_acct_record_id, salary_acct_result_id, salary_acct_emp_id, + salary_item_id, employee_id, operator, operate_time, delete_type, update_time) + VALUES + + ( + #{item.id}, + #{item.datasource}, + #{item.salaryAcctRecordId}, + #{item.salaryAcctResultId}, + #{item.salaryAcctEmpId}, + #{item.salaryItemId}, + #{item.employeeId}, + #{item.operator}, + #{item.operateTime}, + #{item.deleteType}, + #{item.updateTime} + ) + + + + INSERT INTO hrsa_salary_acct_result_log(id, datasource, salary_acct_record_id, salary_acct_result_id, salary_acct_emp_id, + salary_item_id, employee_id, operator, operate_time, delete_type, update_time) + + select + #{item.id,jdbcType=DOUBLE}, + #{item.datasource,jdbcType=INTEGER}, + #{item.salaryAcctRecordId,jdbcType=DOUBLE}, + #{item.salaryAcctResultId,jdbcType=DOUBLE}, + #{item.salaryAcctEmpId,jdbcType=DOUBLE}, + #{item.salaryItemId,jdbcType=DOUBLE}, + #{item.employeeId,jdbcType=DOUBLE}, + #{item.operator,jdbcType=,jdbcType=DOUBLE}, + #{item.operateTime,jdbcType=DATE}, + #{item.deleteType,jdbcType=INTEGER}, + #{item.updateTime,jdbcType=DATE} + from dual + + + + + INSERT INTO hrsa_salary_acct_result_log(id, datasource, salary_acct_record_id, salary_acct_result_id, salary_acct_emp_id, + salary_item_id, employee_id, operator, operate_time, delete_type, update_time) + VALUES + ( + #{item.id}, + #{item.datasource}, + #{item.salaryAcctRecordId}, + #{item.salaryAcctResultId}, + #{item.salaryAcctEmpId}, + #{item.salaryItemId}, + #{item.employeeId}, + #{item.operator}, + #{item.operateTime}, + #{item.deleteType}, + #{item.updateTime} + ) + + + + + + UPDATE hrsa_salary_acct_result_log + + datasource=#{datasource}, + delete_type=#{deleteType}, + employee_id=#{employeeId}, + operate_time=#{operateTime}, + operator=#{operator}, + salary_acct_emp_id=#{salaryAcctEmpId}, + salary_acct_record_id=#{salaryAcctRecordId}, + salary_acct_result_id=#{salaryAcctResultId}, + salary_item_id=#{salaryItemId}, + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_salary_acct_result_log + + + datasource=#{datasource}, + + + delete_type=#{deleteType}, + + + employee_id=#{employeeId}, + + + operate_time=#{operateTime}, + + + operator=#{operator}, + + + salary_acct_emp_id=#{salaryAcctEmpId}, + + + salary_acct_record_id=#{salaryAcctRecordId}, + + + salary_acct_result_id=#{salaryAcctResultId}, + + + salary_item_id=#{salaryItemId}, + + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_salary_acct_result_log + SET delete_type=1 + WHERE id = #{id} AND delete_type = 0 + + + + + UPDATE hrsa_salary_acct_result_log + SET delete_type=1, update_time = #{updateTime} + WHERE delete_type = 0 + + AND salary_acct_emp_id IN + + #{acctEmpId} + + + + + AND salary_item_id NOT IN + + #{itemId} + + + + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/salaryacct/SalaryAcctResultMapper.java b/src/com/engine/salary/mapper/salaryacct/SalaryAcctResultMapper.java new file mode 100644 index 000000000..545b5a81b --- /dev/null +++ b/src/com/engine/salary/mapper/salaryacct/SalaryAcctResultMapper.java @@ -0,0 +1,137 @@ +package com.engine.salary.mapper.salaryacct; + +import com.engine.salary.entity.salaryacct.po.SalaryAcctResultPO; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; + +public interface SalaryAcctResultMapper { + + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + /** + * 条件查询 + * + * @return 返回集合,没有返回空List + */ + List listSome(SalaryAcctResultPO salaryAcctResult); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + SalaryAcctResultPO getById(Long id); + + /** + * 新增,忽略null字段 + * + * @param salaryAcctResult 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(SalaryAcctResultPO salaryAcctResult); + + /** + * 修改,修改所有字段 + * + * @param salaryAcctResult 修改的记录 + * @return 返回影响行数 + */ + int update(SalaryAcctResultPO salaryAcctResult); + + /** + * 修改,忽略null字段 + * + * @param salaryAcctResult 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(SalaryAcctResultPO salaryAcctResult); + + /** + * 删除记录 + * + * @param salaryAcctResult 待删除的记录 + * @return 返回影响行数 + */ + int delete(SalaryAcctResultPO salaryAcctResult); + + + /** + * 查询同一个薪资所属月内的所有核算结果 + * + * @param salaryAcctRecordIds + * @param tenantKey + * @return + */ + List listSameSalaryMonthResult(@Param("salaryAcctRecordIds") Collection salaryAcctRecordIds, + @Param("tenantKey") String tenantKey); + + /** + * 批量新增 + * + * @param salaryAccountingResults + */ + void batchInsert(@Param("collection") Collection salaryAccountingResults); + + /** + * 根据薪资核算id删除薪资核算结果 + * + * @param salaryAcctRecordIds + */ + void deleteBySalaryAcctRecordIds(@Param("salaryAcctRecordIds") Collection salaryAcctRecordIds); + + /** + * 根据薪资核算id删除薪资核算结果 + * + * @param salaryAcctEmpIds + */ + void deleteBySalaryAcctEmpIds(@Param("salaryAcctEmpIds") Collection salaryAcctEmpIds); + + /** + * 根据薪资核算人员id、薪资项目id删除薪资核算结果 + * + * @param salaryAcctEmpIds + * @param salaryItemIds + */ + void deleteByAcctEmpIdsAndSalaryItemIds(@Param("salaryAcctEmpIds") List salaryAcctEmpIds, + @Param("salaryItemIds") Collection salaryItemIds); + + /** + * + * @param salaryAcctRecordId + * @param salaryItemIds + */ + void deleteBySalaryAcctRecordIdAndSalaryItemIds(@Param("salaryAcctRecordId") Long salaryAcctRecordId, + @Param("salaryItemIds") Collection salaryItemIds); + + /** + * 根据薪资核算id删除薪资核算结果 + * + * @param ids + */ + void deleteByIds(@Param("ids") Collection ids); + + /** + * 批量修改 + * @param pos + */ + int batchUpdate(@Param("collection") List pos); + + /** + * @description 批量更新回算薪资项目 + * @return null + * @author Harryxzy + * @date 2022/11/24 21:12 + */ + void batchUpdateOriginResultValue(@Param("collection") List subSalaryAcctResultValues); + + List getAcctEmpIsExist(@Param("empIds")List empIds); +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/salaryacct/SalaryAcctResultMapper.xml b/src/com/engine/salary/mapper/salaryacct/SalaryAcctResultMapper.xml new file mode 100644 index 000000000..8e5696f95 --- /dev/null +++ b/src/com/engine/salary/mapper/salaryacct/SalaryAcctResultMapper.xml @@ -0,0 +1,621 @@ + + + + + + + + + + + + + + + + + + + + + + t + . + id + , t.salary_sob_id + , t.salary_acct_emp_id + , t.salary_acct_record_id + , t.employee_id + , t.tax_agent_id + , t.salary_item_id + , t.result_value + , t.origin_result_value + , t.creator + , t.create_time + , t.update_time + , t.delete_type + , t.tenant_key + + + + + + + + + + + + + + + INSERT INTO hrsa_salary_acct_result + + + + id, + + + salary_sob_id, + + + salary_acct_emp_id, + + + salary_acct_record_id, + + + employee_id, + + + tax_agent_id, + + + salary_item_id, + + + result_value, + + + creator, + + + create_time, + + + update_time, + + + delete_type, + + + tenant_key, + + + + + #{id}, + + + #{salarySobId}, + + + #{salaryAcctEmpId}, + + + #{salaryAcctRecordId}, + + + #{employeeId}, + + + #{taxAgentId}, + + + #{salaryItemId}, + + + #{resultValue}, + + + #{creator}, + + + #{createTime}, + + + #{updateTime}, + + + #{deleteType}, + + + #{tenantKey}, + + + + + + + select hrsa_salary_acct_result_id.currval from dual + + INSERT INTO hrsa_salary_acct_result + + + + id, + + + salary_sob_id, + + + salary_acct_emp_id, + + + salary_acct_record_id, + + + employee_id, + + + tax_agent_id, + + + salary_item_id, + + + result_value, + + + creator, + + + create_time, + + + update_time, + + + delete_type, + + + tenant_key, + + + + + #{id}, + + + #{salarySobId}, + + + #{salaryAcctEmpId}, + + + #{salaryAcctRecordId}, + + + #{employeeId}, + + + #{taxAgentId}, + + + #{salaryItemId}, + + + #{resultValue}, + + + #{creator}, + + + #{createTime}, + + + #{updateTime}, + + + #{deleteType}, + + + #{tenantKey}, + + + + + + + UPDATE hrsa_salary_acct_result + + salary_sob_id=#{salarySobId}, + salary_acct_emp_id=#{salaryAcctEmpId}, + salary_acct_record_id=#{salaryAcctRecordId}, + employee_id=#{employeeId}, + tax_agent_id=#{taxAgentId}, + salary_item_id=#{salaryItemId}, + result_value=#{resultValue}, + creator=#{creator}, + create_time=#{createTime}, + update_time=#{updateTime}, + delete_type=#{deleteType}, + tenant_key=#{tenantKey}, + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_salary_acct_result + + + salary_sob_id=#{salarySobId}, + + + salary_acct_emp_id=#{salaryAcctEmpId}, + + + salary_acct_record_id=#{salaryAcctRecordId}, + + + employee_id=#{employeeId}, + + + tax_agent_id=#{taxAgentId}, + + + salary_item_id=#{salaryItemId}, + + + result_value=#{resultValue}, + + + creator=#{creator}, + + + create_time=#{createTime}, + + + update_time=#{updateTime}, + + + delete_type=#{deleteType}, + + + tenant_key=#{tenantKey}, + + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_salary_acct_result + SET delete_type=1 + WHERE id = #{id} + AND delete_type = 0 + + + + + + + + + + + + + + + + + + + + id + , salary_sob_id, salary_acct_emp_id, salary_acct_record_id, employee_id, tax_agent_id, + salary_item_id, result_value, creator, create_time, update_time, + delete_type, tenant_key + + + + + + + INSERT INTO hrsa_salary_acct_result( salary_sob_id, salary_acct_emp_id, salary_acct_record_id, employee_id, + tax_agent_id, salary_item_id, result_value, origin_result_value, creator, create_time, update_time, delete_type, tenant_key) + VALUES + + ( + #{item.salarySobId}, + #{item.salaryAcctEmpId}, + #{item.salaryAcctRecordId}, + #{item.employeeId}, + #{item.taxAgentId}, + #{item.salaryItemId}, + #{item.resultValue}, + #{item.originResultValue}, + #{item.creator}, + #{item.createTime}, + #{item.updateTime}, + #{item.deleteType}, + #{item.tenantKey} + ) + + + + INSERT INTO hrsa_salary_acct_result( salary_sob_id, salary_acct_emp_id, salary_acct_record_id, employee_id, + tax_agent_id, salary_item_id, result_value, origin_result_value, creator, create_time, update_time, delete_type, tenant_key) + + + select + #{item.salarySobId,jdbcType=DOUBLE}, + #{item.salaryAcctEmpId,jdbcType=DOUBLE}, + #{item.salaryAcctRecordId,jdbcType=DOUBLE}, + #{item.employeeId,jdbcType=DOUBLE}, + #{item.taxAgentId,jdbcType=DOUBLE}, + #{item.salaryItemId,jdbcType=DOUBLE}, + #{item.resultValue,jdbcType=VARCHAR}, + #{item.originResultValue,jdbcType=VARCHAR}, + #{item.creator,jdbcType=DOUBLE}, + #{item.createTime,jdbcType=DATE}, + #{item.updateTime,jdbcType=DATE}, + #{item.deleteType,jdbcType=INTEGER}, + #{item.tenantKey,jdbcType=VARCHAR} + from dual + + + + + INSERT INTO hrsa_salary_acct_result(salary_sob_id, salary_acct_emp_id, salary_acct_record_id, employee_id, + tax_agent_id, salary_item_id, result_value, origin_result_value, creator, create_time, update_time, delete_type, tenant_key) + VALUES + ( + #{item.salarySobId}, + #{item.salaryAcctEmpId}, + #{item.salaryAcctRecordId}, + #{item.employeeId}, + #{item.taxAgentId}, + #{item.salaryItemId}, + #{item.resultValue}, + #{item.originResultValue}, + #{item.creator}, + #{item.createTime}, + #{item.updateTime}, + #{item.deleteType}, + #{item.tenantKey} + ) + + + + + DELETE FROM hrsa_salary_acct_result + WHERE delete_type = 0 + AND salary_acct_record_id IN + + #{salaryAcctRecordId} + + + + + DELETE FROM hrsa_salary_acct_result + WHERE delete_type = 0 + AND salary_acct_emp_id IN + + #{salaryAcctEmpId} + + + + + DELETE FROM hrsa_salary_acct_result + WHERE delete_type = 0 + AND salary_acct_emp_id IN + + #{salaryAcctEmpId} + + AND salary_item_id IN + + #{salaryItemId} + + + + + DELETE FROM hrsa_salary_acct_result + WHERE delete_type = 0 + AND salary_acct_record_id =#{salaryAcctRecordId} + AND salary_item_id IN + + #{salaryItemId} + + + + + DELETE FROM hrsa_salary_acct_result + WHERE delete_type = 0 + AND id IN + + #{id} + + + + + + update hrsa_salary_acct_result + + + + + when id=#{item.id} then #{item.resultValue} + + + + + + + + when id=#{item.id} then #{item.originResultValue} + + + + + + + + when id=#{item.id} then #{item.deleteType} + + + + + where + id in + + #{item.id} + + + + + update hrsa_salary_acct_result + + + + + when id=#{item.id} then #{item.originResultValue} + + + + + where + id in + + #{item.id} + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/salaryacct/SalaryAcctResultTempMapper.java b/src/com/engine/salary/mapper/salaryacct/SalaryAcctResultTempMapper.java new file mode 100644 index 000000000..cdc586280 --- /dev/null +++ b/src/com/engine/salary/mapper/salaryacct/SalaryAcctResultTempMapper.java @@ -0,0 +1,54 @@ +package com.engine.salary.mapper.salaryacct; + +import com.engine.salary.entity.salaryacct.po.SalaryAcctResultTempPO; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; + +/** + * 薪资核算结果临时存储 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public interface SalaryAcctResultTempMapper { + + /** + * 批量插入 + * + * @param salaryAcctResultTemps + */ + void batchInsert(@Param("collection") Collection salaryAcctResultTemps); + + /** + * 根据薪资核算记录id删除薪资核算结果 + * + * @param salaryAcctRecordIds + */ + void deleteBySalaryAcctRecordIds(@Param("salaryAcctRecordIds") Collection salaryAcctRecordIds); + + /** + * 根据薪资核算人员id删除薪资核算结果 + * + * @param salaryAcctEmpIds + */ + void deleteBySalaryAcctEmpIds(@Param("salaryAcctEmpIds") Collection salaryAcctEmpIds); + + /** + * 根据key删除薪资核算结果 + * + * @param calculateKey + */ + void deleteByCalculateKey(@Param("calculateKey") String calculateKey); + + /** + * 条件查询 + * + * @return 返回集合,没有返回空List + */ + List listSome(SalaryAcctResultTempPO acctResultTemp); + +} diff --git a/src/com/engine/salary/mapper/salaryacct/SalaryAcctResultTempMapper.xml b/src/com/engine/salary/mapper/salaryacct/SalaryAcctResultTempMapper.xml new file mode 100644 index 000000000..5397380ec --- /dev/null +++ b/src/com/engine/salary/mapper/salaryacct/SalaryAcctResultTempMapper.xml @@ -0,0 +1,198 @@ + + + + + + INSERT INTO hrsa_acct_result_temp(salary_sob_id, salary_acct_emp_id, salary_acct_record_id, employee_id, + tax_agent_id, salary_item_id, result_value, origin_result_value, calculate_key, creator, create_time, update_time, delete_type, + tenant_key) + VALUES + + ( + #{item.salarySobId}, + #{item.salaryAcctEmpId}, + #{item.salaryAcctRecordId}, + #{item.employeeId}, + #{item.taxAgentId}, + #{item.salaryItemId}, + #{item.resultValue}, + #{item.originResultValue}, + #{item.calculateKey}, + #{item.creator}, + #{item.createTime}, + #{item.updateTime}, + #{item.deleteType}, + #{item.tenantKey} + ) + + + + INSERT INTO hrsa_acct_result_temp(salary_sob_id, salary_acct_emp_id, salary_acct_record_id, employee_id, + tax_agent_id, salary_item_id, result_value, origin_result_value,calculate_key, creator, create_time, update_time, delete_type, + tenant_key) + + + select + #{item.salarySobId,jdbcType=DOUBLE}, + #{item.salaryAcctEmpId,jdbcType=DOUBLE}, + #{item.salaryAcctRecordId,jdbcType=DOUBLE}, + #{item.employeeId,jdbcType=DOUBLE}, + #{item.taxAgentId,jdbcType=DOUBLE}, + #{item.salaryItemId,jdbcType=DOUBLE}, + #{item.resultValue,jdbcType=VARCHAR}, + #{item.originResultValue,jdbcType=VARCHAR}, + #{item.calculateKey,jdbcType=VARCHAR}, + #{item.creator,jdbcType=DOUBLE}, + #{item.createTime,jdbcType=DATE}, + #{item.updateTime,jdbcType=DATE}, + #{item.deleteType,jdbcType=INTEGER}, + #{item.tenantKey,jdbcType=VARCHAR} + from dual + + + + + INSERT INTO hrsa_acct_result_temp( salary_sob_id, salary_acct_emp_id, salary_acct_record_id, employee_id, + tax_agent_id, salary_item_id, result_value, origin_result_value, calculate_key, creator, create_time, update_time, delete_type, + tenant_key) + VALUES + ( + #{item.salarySobId}, + #{item.salaryAcctEmpId}, + #{item.salaryAcctRecordId}, + #{item.employeeId}, + #{item.taxAgentId}, + #{item.salaryItemId}, + #{item.resultValue}, + #{item.originResultValue}, + #{item.calculateKey}, + #{item.creator}, + #{item.createTime}, + #{item.updateTime}, + #{item.deleteType}, + #{item.tenantKey} + ) + + + + + + DELETE FROM hrsa_acct_result_temp + WHERE AND delete_type = 0 + AND salary_acct_record_id IN + + #{salaryAcctRecordId} + + + + + DELETE FROM hrsa_acct_result_temp + WHERE delete_type = 0 + AND salary_acct_emp_id IN + + #{salaryAcctEmpId} + + + + + DELETE FROM hrsa_acct_result_temp + WHERE delete_type = 0 + AND calculate_key = #{calculateKey} + + + + + + + + + + + + + + + + + + + + + + + + t.id + , t.calculate_key + , t.salary_sob_id + , t.salary_acct_emp_id + , t.salary_acct_record_id + , t.employee_id + , t.tax_agent_id + , t.salary_item_id + , t.result_value + , t.origin_result_value + , t.creator + , t.create_time + , t.update_time + , t.delete_type + , t.tenant_key + + + + + + diff --git a/src/com/engine/salary/mapper/salaryacct/SalaryAcctResultTemplateMapper.java b/src/com/engine/salary/mapper/salaryacct/SalaryAcctResultTemplateMapper.java new file mode 100644 index 000000000..19bd121f8 --- /dev/null +++ b/src/com/engine/salary/mapper/salaryacct/SalaryAcctResultTemplateMapper.java @@ -0,0 +1,66 @@ +package com.engine.salary.mapper.salaryacct; + +import com.engine.salary.entity.salaryacct.po.SalaryAcctResultTemplatePO; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +public interface SalaryAcctResultTemplateMapper { + + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + /** + * 条件查询 + * + * @return 返回集合,没有返回空List + */ + List listSome(SalaryAcctResultTemplatePO salaryAcctResultTemplate); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + SalaryAcctResultTemplatePO getById(Long id); + + /** + * 新增,忽略null字段 + * + * @param salaryAcctResultTemplate 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(SalaryAcctResultTemplatePO salaryAcctResultTemplate); + + /** + * 修改,修改所有字段 + * + * @param salaryAcctResultTemplate 修改的记录 + * @return 返回影响行数 + */ + int update(SalaryAcctResultTemplatePO salaryAcctResultTemplate); + + /** + * 修改,忽略null字段 + * + * @param salaryAcctResultTemplate 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(SalaryAcctResultTemplatePO salaryAcctResultTemplate); + + /** + * 删除记录 + * + * @param id 待删除的记录 + * @return 返回影响行数 + */ + int deleteById(Long id); + + int deleteByIds(@Param("ids") List ids); +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/salaryacct/SalaryAcctResultTemplateMapper.xml b/src/com/engine/salary/mapper/salaryacct/SalaryAcctResultTemplateMapper.xml new file mode 100644 index 000000000..bd1ba58d5 --- /dev/null +++ b/src/com/engine/salary/mapper/salaryacct/SalaryAcctResultTemplateMapper.xml @@ -0,0 +1,242 @@ + + + + + + + + + + + + + + + + + + + t.create_time + , t.creator + , t.delete_type + , t.id + , t.salary_item_ids + , t.salary_sob_id + , t.template_name + , t.tenant_key + , t.update_time + , t.type + + + + + + + + + + + + + + + INSERT INTO hrsa_acct_result_template + + + + create_time, + + + creator, + + + delete_type, + + + id, + + + salary_item_ids, + + + salary_sob_id, + + + template_name, + + + tenant_key, + + + update_time, + + + type, + + + + + #{createTime}, + + + #{creator}, + + + #{deleteType}, + + + #{id}, + + + #{salaryItemIds}, + + + #{salarySobId}, + + + #{templateName}, + + + #{tenantKey}, + + + #{updateTime}, + + + #{type}, + + + + + + + UPDATE hrsa_acct_result_template + + create_time=#{createTime}, + creator=#{creator}, + delete_type=#{deleteType}, + salary_item_ids=#{salaryItemIds}, + salary_sob_id=#{salarySobId}, + template_name=#{templateName}, + tenant_key=#{tenantKey}, + update_time=#{updateTime}, + type=#{type}, + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_acct_result_template + + + create_time=#{createTime}, + + + creator=#{creator}, + + + delete_type=#{deleteType}, + + + salary_item_ids=#{salaryItemIds}, + + + salary_sob_id=#{salarySobId}, + + + template_name=#{templateName}, + + + tenant_key=#{tenantKey}, + + + update_time=#{updateTime}, + + + type=#{type}, + + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_acct_result_template + SET delete_type=1 + WHERE id = #{id} AND delete_type = 0 + + + UPDATE hrsa_acct_result_template + SET delete_type=1 + WHERE delete_type = 0 + + AND id IN + + #{id} + + + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/salaryacct/SalaryAcctSobConfigMapper.java b/src/com/engine/salary/mapper/salaryacct/SalaryAcctSobConfigMapper.java new file mode 100644 index 000000000..9d8e0525f --- /dev/null +++ b/src/com/engine/salary/mapper/salaryacct/SalaryAcctSobConfigMapper.java @@ -0,0 +1,80 @@ +package com.engine.salary.mapper.salaryacct; + +import com.engine.salary.entity.salaryacct.po.SalaryAcctSobConfigPO; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; + +public interface SalaryAcctSobConfigMapper { + + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + /** + * 条件查询 + * + * @return 返回集合,没有返回空List + */ + List listSome(SalaryAcctSobConfigPO salaryAcctSobConfig); + + /** + * 根据核算id查询 + * @param salaryAcctRecordId + * @return + */ + SalaryAcctSobConfigPO getBySalaryAcctRecordId(Long salaryAcctRecordId); + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + SalaryAcctSobConfigPO getById(Long id); + + /** + * 新增,忽略null字段 + * + * @param salaryAcctSobConfig 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(SalaryAcctSobConfigPO salaryAcctSobConfig); + + /** + * 修改,修改所有字段 + * + * @param salaryAcctSobConfig 修改的记录 + * @return 返回影响行数 + */ + int update(SalaryAcctSobConfigPO salaryAcctSobConfig); + + /** + * 修改,忽略null字段 + * + * @param salaryAcctSobConfig 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(SalaryAcctSobConfigPO salaryAcctSobConfig); + + /** + * 删除记录 + * + * @param salaryAcctSobConfig 待删除的记录 + * @return 返回影响行数 + */ + int delete(SalaryAcctSobConfigPO salaryAcctSobConfig); + + /** + * 批量删除记录 + * @param ids 主键id集合 + */ + void deleteByIds(@Param("ids") Collection ids); + + void deleteBySalaryAcctRecordIds(@Param("salaryAcctRecordIds") Collection salaryAcctRecordIds); + +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/salaryacct/SalaryAcctSobConfigMapper.xml b/src/com/engine/salary/mapper/salaryacct/SalaryAcctSobConfigMapper.xml new file mode 100644 index 000000000..97cf9eafa --- /dev/null +++ b/src/com/engine/salary/mapper/salaryacct/SalaryAcctSobConfigMapper.xml @@ -0,0 +1,316 @@ + + + + + + + + + + + + + + + + + + + + + + + t + . + adjust_rule_config + , t.back_item_config + , t.basic_config + , t.check_rule_config + , t.create_time + , t.creator + , t.delete_type + , t.employee_field_config + , t.id + , t.item_config + , t.item_group_config + , t.salary_acct_record_id + , t.tenant_key + , t.update_time + + + + + + + + + + + + + + + + + INSERT INTO hrsa_salary_acct_sob_config + + + + adjust_rule_config, + + + back_item_config, + + + basic_config, + + + check_rule_config, + + + create_time, + + + creator, + + + delete_type, + + + employee_field_config, + + + id, + + + item_config, + + + item_group_config, + + + salary_acct_record_id, + + + tenant_key, + + + update_time, + + + + + #{adjustRuleConfig}, + + + #{backItemConfig}, + + + #{basicConfig}, + + + #{checkRuleConfig}, + + + #{createTime}, + + + #{creator}, + + + #{deleteType}, + + + #{employeeFieldConfig}, + + + #{id}, + + + #{itemConfig}, + + + #{itemGroupConfig}, + + + #{salaryAcctRecordId}, + + + #{tenantKey}, + + + #{updateTime}, + + + + + + + UPDATE hrsa_salary_acct_sob_config + + adjust_rule_config=#{adjustRuleConfig}, + back_item_config=#{backItemConfig}, + basic_config=#{basicConfig}, + check_rule_config=#{checkRuleConfig}, + create_time=#{createTime}, + creator=#{creator}, + delete_type=#{deleteType}, + employee_field_config=#{employeeFieldConfig}, + item_config=#{itemConfig}, + item_group_config=#{itemGroupConfig}, + salary_acct_record_id=#{salaryAcctRecordId}, + tenant_key=#{tenantKey}, + update_time=#{updateTime}, + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_salary_acct_sob_config + + + adjust_rule_config=#{adjustRuleConfig}, + + + back_item_config=#{backItemConfig}, + + + basic_config=#{basicConfig}, + + + check_rule_config=#{checkRuleConfig}, + + + create_time=#{createTime}, + + + creator=#{creator}, + + + delete_type=#{deleteType}, + + + employee_field_config=#{employeeFieldConfig}, + + + item_config=#{itemConfig}, + + + item_group_config=#{itemGroupConfig}, + + + salary_acct_record_id=#{salaryAcctRecordId}, + + + tenant_key=#{tenantKey}, + + + update_time=#{updateTime}, + + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_salary_acct_sob_config + SET delete_type=1 + WHERE id = #{id} + AND delete_type = 0 + + + + UPDATE hrsa_salary_acct_sob_config + SET delete_type = 1 + WHERE delete_type = 0 + AND id IN + + #{id} + + + + + UPDATE hrsa_salary_acct_sob_config + SET delete_type = 1 + WHERE delete_type = 0 + AND salary_acct_record_id IN + + #{salaryAcctRecordId} + + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/salarybill/SalaryBillItemNameMapper.java b/src/com/engine/salary/mapper/salarybill/SalaryBillItemNameMapper.java new file mode 100644 index 000000000..8833c47c6 --- /dev/null +++ b/src/com/engine/salary/mapper/salarybill/SalaryBillItemNameMapper.java @@ -0,0 +1,102 @@ +package com.engine.salary.mapper.salarybill; + +import com.engine.salary.entity.salaryBill.po.SalaryBillItemNamePO; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; + +/** + * @author Harryxzy + * @ClassName SalaryBillItemNameMapper + * @date 2023/07/18 15:58 + * @description 工资单薪资项目展示名 + */ +public interface SalaryBillItemNameMapper { + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + /** + * 条件查询 + * + * @return 返回集合,没有返回空List + */ + List listSome(SalaryBillItemNamePO salaryBillItemNamePO); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + SalaryBillItemNamePO getById(Long id); + + /** + * 新增,忽略null字段 + * + * @param salaryBillItemNamePO 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(SalaryBillItemNamePO salaryBillItemNamePO); + + /** + * 修改,修改所有字段 + * + * @param salaryBillItemNamePO 修改的记录 + * @return 返回影响行数 + */ + int update(SalaryBillItemNamePO salaryBillItemNamePO); + + /** + * 修改,忽略null字段 + * + * @param salaryBillItemNamePO 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(SalaryBillItemNamePO salaryBillItemNamePO); + + /** + * 删除记录 + * + * @param id 待删除的记录id + * @return 返回影响行数 + */ + int delete(Long id); + + /** + * 批量更新 + * @param salaryBillItemNamePO + */ + void batchUpdate(@Param("collection") List salaryBillItemNamePO); + + /** + * 批量插入 + * @param salaryBillItemNamePO + */ + void batchInsert(@Param("collection") List salaryBillItemNamePO); + + /** + * 根据薪资项目、模板id、模板类型批量删除 + * @param salaryItemIds + * @param salaryTemplateId + * @param salaryBillType + */ + void deleteByItemIdsAndTemplateId(@Param("salaryItemIds") List salaryItemIds, @Param("salaryTemplateId") Long salaryTemplateId, @Param("salaryBillType") Integer salaryBillType); + + /** + * 根据idList删除 + * @param ids + */ + void deleteByIds(@Param("collection") List ids); + + /** + * 根据模板id删除 + * @param ids + */ + void deleteByTemplateIds(@Param("collection") Collection ids); +} diff --git a/src/com/engine/salary/mapper/salarybill/SalaryBillItemNameMapper.xml b/src/com/engine/salary/mapper/salarybill/SalaryBillItemNameMapper.xml new file mode 100644 index 000000000..d00b52f35 --- /dev/null +++ b/src/com/engine/salary/mapper/salarybill/SalaryBillItemNameMapper.xml @@ -0,0 +1,344 @@ + + + + + + + + + + + + + + + + + + t.id + , t.salary_item_id + , t.salary_item_show_name + , t.salary_template_id + , t.salary_bill_type + , t.delete_type + , t.creator + , t.create_time + , t.update_time + , t.tenant_key + + + + + + + + + + + + + + + INSERT INTO hrsa_salary_bill_item_name + + + + id, + + + salary_item_id, + + + salary_item_show_name, + + + salary_template_id, + + + salary_bill_type, + + + creator, + + + create_time, + + + update_time, + + + delete_type, + + + tenant_key, + + + + + #{id}, + + + #{salaryItemId}, + + + #{salaryItemShowName}, + + + #{salaryTemplateId}, + + + #{salaryBillType}, + + + #{creator}, + + + #{createTime}, + + + #{updateTime}, + + + #{deleteType}, + + + #{tenantKey}, + + + + + + INSERT INTO hrsa_salary_bill_item_name ( + id, + salary_template_id, + salary_item_id, + salary_item_show_name, + salary_bill_type, + creator, + create_time, + update_time, + delete_type, + tenant_key + ) + VALUES + + ( + #{item.id}, + #{item.salaryTemplateId}, + #{item.salaryItemId}, + #{item.salaryItemShowName}, + #{item.salaryBillType}, + #{item.creator}, + #{item.createTime}, + #{item.updateTime}, + #{item.deleteType}, + #{item.tenantKey} + ) + + + + INSERT INTO hrsa_salary_bill_item_name ( + id, + salary_template_id, + salary_item_id, + salary_item_show_name, + salary_bill_type, + creator, + create_time, + update_time, + delete_type, + tenant_key + ) + + select + #{item.id,jdbcType=DOUBLE}, + #{item.salaryTemplateId,jdbcType=DOUBLE}, + #{item.salaryItemId,jdbcType=DOUBLE}, + #{item.salaryItemShowName,jdbcType=VARCHAR}, + #{item.salaryBillType,jdbcType=INTEGER}, + #{item.creator,jdbcType=DOUBLE}, + #{item.createTime,jdbcType=DATE}, + #{item.updateTime,jdbcType=DATE}, + #{item.deleteType,jdbcType=INTEGER}, + #{item.tenantKey,jdbcType=VARCHAR} + from dual + + + + + INSERT INTO hrsa_salary_bill_item_name ( + id, + salary_template_id, + salary_item_id, + salary_item_show_name, + salary_bill_type, + creator, + create_time, + update_time, + delete_type, + tenant_key + ) + VALUES + ( + #{item.id}, + #{item.salaryTemplateId}, + #{item.salaryItemId}, + #{item.salaryItemShowName}, + #{item.salaryBillType}, + #{item.creator}, + #{item.createTime}, + #{item.updateTime}, + #{item.deleteType}, + #{item.tenantKey} + ) + + + + + + UPDATE hrsa_salary_bill_item_name + + salary_item_id=#{salaryItemId}, + salary_item_show_name=#{salaryItemShowName}, + salary_template_id=#{salaryTemplateId}, + salary_bill_type=#{salaryBillType}, + creator=#{creator}, + create_time={createTime}, + update_time=#{updateTime}, + tenant_key=#{tenantKey} + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_salary_bill_item_name + + + salary_item_id=#{salaryItemId}, + + + salary_item_show_name=#{salaryItemShowName}, + + + salary_template_id=#{salaryTemplateId}, + + + salary_bill_type=#{salaryBillType}, + + + creator=#{creator}, + + + create_time=#{createTime}, + + + update_time=#{updateTime}, + + + tenant_key=#{tenantKey}, + + + WHERE id = #{id} AND delete_type = 0 + + + + UPDATE hrsa_salary_bill_item_name + + + + WHEN id = #{item.id} THEN #{item.salaryItemShowName} + + + + + WHEN id = #{item.id} THEN #{item.updateTime} + + + + WHERE delete_type = 0 + AND id IN + + #{item.id} + + + + + + + UPDATE hrsa_salary_bill_item_name + SET delete_type=1 + WHERE id = #{id} AND delete_type = 0 + + + + UPDATE hrsa_salary_bill_item_name + SET delete_type=1 + WHERE delete_type = 0 + AND salary_template_id = #{salaryTemplateId} + AND salary_bill_type = #{salaryBillType} + AND salary_item_id IN + + #{itemId} + + + + + UPDATE hrsa_salary_bill_item_name + SET delete_type=1 + WHERE delete_type = 0 + AND id IN + + #{id} + + + + UPDATE hrsa_salary_bill_item_name + SET delete_type=1 + WHERE delete_type = 0 + AND salary_template_id IN + + #{id} + + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/salarybill/SalaryBillWatermarkMapper.java b/src/com/engine/salary/mapper/salarybill/SalaryBillWatermarkMapper.java new file mode 100644 index 000000000..b153510fa --- /dev/null +++ b/src/com/engine/salary/mapper/salarybill/SalaryBillWatermarkMapper.java @@ -0,0 +1,73 @@ +package com.engine.salary.mapper.salarybill; + +import com.engine.salary.entity.salaryBill.po.SalaryBillWatermarkPO; + +import java.util.List; + +/** + * @author Harryxzy + * @ClassName SalaryBillWatermarkMapper + * @date 2023/06/09 11:13 + * @description + */ +public interface SalaryBillWatermarkMapper { + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + /** + * 条件查询 + * + * @return 返回集合,没有返回空List + */ + List listSome(SalaryBillWatermarkPO salaryBillWatermark); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + SalaryBillWatermarkPO getById(Long id); + + /** + * 新增,忽略null字段 + * + * @param salaryBillWatermark 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(SalaryBillWatermarkPO salaryBillWatermark); + + /** + * 修改,修改所有字段 + * + * @param salaryBillWatermark 修改的记录 + * @return 返回影响行数 + */ + int update(SalaryBillWatermarkPO salaryBillWatermark); + + /** + * 修改,忽略null字段 + * + * @param salaryBillWatermark 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(SalaryBillWatermarkPO salaryBillWatermark); + + /** + * 删除记录 + * + * @param salaryBillWatermark 待删除的记录 + * @return 返回影响行数 + */ + int delete(SalaryBillWatermarkPO salaryBillWatermark); + + /** + * 删除所有生效水印记录 + */ + void deleteAll(); +} diff --git a/src/com/engine/salary/mapper/salarybill/SalaryBillWatermarkMapper.xml b/src/com/engine/salary/mapper/salarybill/SalaryBillWatermarkMapper.xml new file mode 100644 index 000000000..3b77a7926 --- /dev/null +++ b/src/com/engine/salary/mapper/salarybill/SalaryBillWatermarkMapper.xml @@ -0,0 +1,215 @@ + + + + + + + + + + + + + + + + + + t.create_time + , t.creator + , t.delete_type + , t.id + , t.tenant_key + , t.update_time + , t.watermark_setting + , t.watermark_status + , t.watermark_type + + + + + + + + + + + + + + + INSERT INTO hrsa_salary_bill_watermark + + + + create_time, + + + creator, + + + delete_type, + + + id, + + + tenant_key, + + + update_time, + + + watermark_setting, + + + watermark_status, + + + watermark_type, + + + + + #{createTime}, + + + #{creator}, + + + #{deleteType}, + + + #{id}, + + + #{tenantKey}, + + + #{updateTime}, + + + #{watermarkSetting}, + + + #{watermarkStatus}, + + + #{watermarkType}, + + + + + + + UPDATE hrsa_salary_bill_watermark + + create_time=#{createTime}, + creator=#{creator}, + delete_type=#{deleteType}, + tenant_key=#{tenantKey}, + update_time=#{updateTime}, + watermark_setting=#{watermarkSetting}, + watermark_status=#{watermarkStatus}, + watermark_type=#{watermarkType}, + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_salary_bill_watermark + + + create_time=#{createTime}, + + + creator=#{creator}, + + + delete_type=#{deleteType}, + + + tenant_key=#{tenantKey}, + + + update_time=#{updateTime}, + + + watermark_setting=#{watermarkSetting}, + + + watermark_status=#{watermarkStatus}, + + + watermark_type=#{watermarkType}, + + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_salary_bill_watermark + SET delete_type=1 + WHERE id = #{id} AND delete_type = 0 + + + UPDATE hrsa_salary_bill_watermark + SET delete_type=1 + WHERE delete_type = 0 + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/salarybill/SalarySendInfoMapper.java b/src/com/engine/salary/mapper/salarybill/SalarySendInfoMapper.java new file mode 100644 index 000000000..2da9e21b9 --- /dev/null +++ b/src/com/engine/salary/mapper/salarybill/SalarySendInfoMapper.java @@ -0,0 +1,117 @@ +package com.engine.salary.mapper.salarybill; + +import com.engine.salary.entity.salaryBill.dto.SalaryMySalaryBillListDTO; +import com.engine.salary.entity.salaryBill.dto.SalarySendDetailListDTO; +import com.engine.salary.entity.salaryBill.dto.SalarySendInfoListDTO; +import com.engine.salary.entity.salaryBill.param.SalaryBillQueryParam; +import com.engine.salary.entity.salaryBill.param.SalarySendDetailQueryParam; +import com.engine.salary.entity.salaryBill.param.SalarySendInfoQueryParam; +import com.engine.salary.entity.salaryBill.po.SalarySendInfoPO; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; +import java.util.Set; + +/** + * 工资单发放信息 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public interface SalarySendInfoMapper { + + SalarySendInfoPO getById(@Param("id") Long id); + + List listSalaryAccRecordIds(@Param("param") SalarySendDetailQueryParam param); + + /** + * 查询工资单发放信息列表 + * @param param + * @return + */ + List list(@Param("param") SalarySendInfoQueryParam param); + + /** + * 分页查询工资单发放信息列表 + * @param page + * @param param + * @param tenantKey + * @return + */ +// IPage list(Page page, @Param("param") SalarySendInfoQueryParam param, @Param("tenantKey") String tenantKey); + + /** + * 查询工资单发放详情列表 + * + * @param param + * @param otherSalaryAccRecordIds + * @return + */ + List detailList(@Param("param") SalarySendDetailQueryParam param, + @Param("otherSalaryAccRecordIds") Set otherSalaryAccRecordIds); + + /** + * 分页查询工资单发放详情列表 + * @param page + * @param param + * @param tenantKey + * @return + */ +// IPage detailList(Page page, @Param("param") SalarySendDetailQueryParam param, @Param("tenantKey") String tenantKey); + + /** + * 分页查询我的工资单列表 + * @param queryParam + * @return + */ + List mySalaryBillList(@Param("param") SalaryBillQueryParam queryParam); + + + /** + * 批量插入工资单信息记录 + * @param pos + */ + void batchInsert(@Param("collection") List pos); + + /** + * 发放、撤回工资单 + * @param po + * @param salarySendId + * @param statusList + * @param ids + */ + void updateGrantWithdraw(@Param("po") SalarySendInfoPO po, @Param("salarySendId")Long salarySendId, @Param("statusList")List statusList, @Param("ids")Collection ids); + + /** + * 根据现有字段查询 + * @param params + * @return + */ + List listSome(SalarySendInfoPO params); + + /** + * 根据id更新 + * @param po + */ + void updateIgnoreNull(SalarySendInfoPO po); + + void deleteBySalaryAcctRecordIds(@Param("salaryAcctRecordId") Collection ids); + + List getNeedSendInfoList(@Param("salarySendIds") List salarySendIds); + + /** + * 自动确认工资单 + * @param needAutoIds + */ + void autoConfirmSalaryBill(@Param("ids") List needAutoIds); + + /** + * 根据薪资账套id获取已发送,确认状态为未确认的工资单 + * @param salarySobIds + * @return + */ + List listUnConfirmedSendInfo(@Param("salarySobIds") List salarySobIds); +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/salarybill/SalarySendInfoMapper.xml b/src/com/engine/salary/mapper/salarybill/SalarySendInfoMapper.xml new file mode 100644 index 000000000..4870fdfde --- /dev/null +++ b/src/com/engine/salary/mapper/salarybill/SalarySendInfoMapper.xml @@ -0,0 +1,843 @@ + + + + + + + + + + + + + + + + + + + + + + + + + t.id + , t.salary_send_id + , t.salary_month + , t.salary_acct_record_id + , t.employee_id + , t.tax_agent_id + , t.send_status + , t.send_time + , t.salary_template + , t.creator + , t.create_time + , t.update_time + , t.delete_type + , t.tenant_key + , t.salary_acct_type + , t.employee_type + , t.bill_read_status + , t.bill_confirm_status + , t.send_employee_id + , t.first_reading_time + + + update hrsa_salary_send_info + set delete_type = 1 + where salary_acct_record_id in + + #{id} + + + + + + + + INSERT INTO hrsa_salary_send_info ( + id, + salary_send_id, + salary_month, + salary_acct_record_id, + tax_agent_id, + employee_id, + send_status, + creator, + create_time, + update_time, + tenant_key, + salary_acct_type, + employee_type + ) + VALUES + + ( + #{item.id}, + #{item.salarySendId}, + #{item.salaryMonth}, + #{item.salaryAcctRecordId}, + #{item.taxAgentId}, + #{item.employeeId}, + #{item.sendStatus}, + #{item.creator}, + #{item.createTime}, + #{item.updateTime}, + #{item.tenantKey}, + #{item.salaryAcctType}, + #{item.employeeType} + ) + + + + INSERT INTO hrsa_salary_send_info ( + id, + salary_send_id, + salary_month, + salary_acct_record_id, + tax_agent_id, + employee_id, + send_status, + creator, + create_time, + update_time, + tenant_key, + salary_acct_type, + employee_type + ) + + + select + #{item.id,jdbcType=DOUBLE}, + #{item.salarySendId,jdbcType=DOUBLE}, + #{item.salaryMonth,jdbcType=DATE}, + #{item.salaryAcctRecordId,jdbcType=DOUBLE}, + #{item.taxAgentId,jdbcType=DOUBLE}, + #{item.employeeId,jdbcType=DOUBLE}, + #{item.sendStatus,jdbcType=INTEGER}, + #{item.creator,jdbcType=DOUBLE}, + #{item.createTime,jdbcType=DATE}, + #{item.updateTime,jdbcType=DATE}, + #{item.tenantKey,jdbcType=VARCHAR}, + #{item.salaryAcctType,jdbcType=INTEGER}, + #{item.employeeType,jdbcType=INTEGER} + from dual + + + + + INSERT INTO hrsa_salary_send_info ( + id, + salary_send_id, + salary_month, + salary_acct_record_id, + tax_agent_id, + employee_id, + send_status, + creator, + create_time, + update_time, + tenant_key, + salary_acct_type, + employee_type + ) + VALUES + ( + #{item.id}, + #{item.salarySendId}, + #{item.salaryMonth}, + #{item.salaryAcctRecordId}, + #{item.taxAgentId}, + #{item.employeeId}, + #{item.sendStatus}, + #{item.creator}, + #{item.createTime}, + #{item.updateTime}, + #{item.tenantKey}, + #{item.salaryAcctType}, + #{item.employeeType} + ) + + + + + t1.id, + t1.salary_acct_record_id as salaryAcctRecordId, + t1.salary_acct_type as salaryAcctType, + t1.tax_agent_id as taxAgentId, + e.lastname as username, + t2.name AS tax_agent, + d.departmentname AS department, + e.mobile, + e.workcode as jobNum, + t1.send_status, + t1.employee_id, + t1.salary_month, + t1.employee_type, + t1.bill_read_status as billReadStatus, + t1.bill_confirm_status as billConfirmStatus, + e.email + + + + + AND t1.id IN + + #{id} + + + + + AND t1.salary_send_id = #{param.salarySendId} + + + + AND e.lastname like CONCAT('%',#{param.keyword},'%') + + + + AND e.lastname like CONCAT('%',#{param.username},'%') + + + AND e.id = #{param.userId} + + + + AND t2.id = #{param.taxAgentId} + + + + AND d.id IN + + #{id} + + + + + AND e.jobtitle IN + + #{id} + + + + + AND e.status = #{param.userstatus} + + + + AND t1.send_status IN + + #{status} + + + + + AND (e.hiredate BETWEEN #{param.hiredate[0]} AND #{param.hiredate[1]}) + + + + + AND t1.id IN + + #{id} + + + + + AND t1.salary_send_id = #{param.salarySendId} + + + + AND e.lastname like '%'||#{param.keyword}||'%' + + + + AND e.lastname like '%'||#{param.username}||'%' + + + + AND e.id = #{param.userId} + + + + AND t2.id = #{param.taxAgentId} + + + + AND d.id IN + + #{id} + + + + + AND e.jobtitle IN + + #{id} + + + + + AND e.status = #{param.userstatus} + + + + AND t1.send_status IN + + #{status} + + + + + AND (e.hiredate BETWEEN #{param.hiredate[0]} AND #{param.hiredate[1]}) + + + + + AND t1.id IN + + #{id} + + + + + AND t1.salary_send_id = #{param.salarySendId} + + + + AND e.lastname like '%'+#{param.keyword}+'%' + + + + AND e.lastname like '%'+#{param.username}+'%' + + + + AND e.id = #{param.userId} + + + + AND t2.id = #{param.taxAgentId} + + + + AND d.id IN + + #{id} + + + + + AND e.jobtitle IN + + #{id} + + + + + AND e.status = #{param.userstatus} + + + + AND t1.send_status IN + + #{status} + + + + + AND (e.hiredate BETWEEN #{param.hiredate[0]} AND #{param.hiredate[1]}) + + + + + + + + + + + + + + + + + + + + + + UPDATE + hrsa_salary_send_info + + + first_reading_time = null, + + send_status = #{po.sendStatus}, + + + send_time = #{po.sendTime}, + + + delete_type = #{po.deleteType}, + + + salary_template = #{po.salaryTemplate}, + + + bill_read_status = #{po.billReadStatus}, + + + bill_confirm_status = #{po.billConfirmStatus}, + + + send_employee_id = #{po.sendEmployeeId} + + + + WHERE + delete_type = 0 + + AND send_status IN + + + #{status} + + + + + + AND id IN + + #{id} + + + + AND salary_send_id = #{salarySendId} + + + + + + + + + + + UPDATE hrsa_salary_send_info + + + salary_send_id=#{salarySendId}, + + + salary_month=#{salaryMonth}, + + + salary_acct_record_id=#{salaryAcctRecordId}, + + + employee_id=#{employeeId}, + + + tax_agent_id=#{taxAgentId}, + + + send_status=#{sendStatus}, + + + send_time=#{sendTime}, + + + salary_template=#{salaryTemplate}, + + + creator=#{creator}, + + + create_time=#{createTime}, + + + update_time=#{updateTime}, + + + delete_type=#{deleteType}, + + + tenant_key=#{tenantKey}, + + + bill_read_status=#{billReadStatus}, + + + bill_confirm_status=#{billConfirmStatus}, + + + first_reading_time=#{firstReadingTime}, + + + WHERE id = #{id} AND delete_type = 0 + + + UPDATE hrsa_salary_send_info + set + bill_confirm_status = 1 + where + delete_type = 0 + + AND id IN + + #{id} + + + + + diff --git a/src/com/engine/salary/mapper/salarybill/SalarySendMapper.java b/src/com/engine/salary/mapper/salarybill/SalarySendMapper.java new file mode 100644 index 000000000..95e3e73ed --- /dev/null +++ b/src/com/engine/salary/mapper/salarybill/SalarySendMapper.java @@ -0,0 +1,70 @@ +package com.engine.salary.mapper.salarybill; + +import com.engine.salary.entity.salaryBill.dto.SalarySendListDTO; +import com.engine.salary.entity.salaryBill.param.SalarySendQueryParam; +import com.engine.salary.entity.salaryBill.po.SalarySendPO; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; +import java.util.Map; + +/** + * @Description: 工资单发放 + * @Author: wangxiangzhong + * @Date: 2021-12-11 11:28 + */ + +public interface SalarySendMapper { + + /** + * 查询工资单发放列表 + * @param param + * @return + */ + List list(@Param("param") SalarySendQueryParam param); + + /** + * 分页查询工资单发放列表 + * @param page + * @param param + * @param tenantKey + * @return + */ +// IPage list(Page page, @Param("param") SalarySendQueryParam param, @Param("tenantKey") String tenantKey); + + /** + * 根据主键id获取工资单发放 + * @param id + * @return + */ + SalarySendPO getById(@Param("id") Long id); + + + /** + * 根据id更新 + * @param po + */ + void updateIgnoreNull(SalarySendPO po); + + List listSomeWithCondition(@Param("param")Map condition); + + /** + * 根据现有字段查询 + * @param params + * @return + */ + List listSome(SalarySendPO params); + + void insertIgnoreNull(SalarySendPO salarySend); + + void batchHandleSendStatusHistory(); + + void batchHandleSalaryAcctTypeHistory(); + + void deleteBySalaryAcctRecordIds(@Param("salaryAcctRecordId") Collection ids); + + List getNeedSendListBySalarySobIds(@Param("salarySobIds")List salarySobIds); + + List getByIds(@Param("ids") List salarySendId); +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/salarybill/SalarySendMapper.xml b/src/com/engine/salary/mapper/salarybill/SalarySendMapper.xml new file mode 100644 index 000000000..e3d729fd4 --- /dev/null +++ b/src/com/engine/salary/mapper/salarybill/SalarySendMapper.xml @@ -0,0 +1,371 @@ + + + + + + + + + + + + + + + + + + + + id, + salary_month, + salary_accounting_id, + salary_sob_id, + send_num, + send_total, + last_send_time, + send_status, + salary_acct_type, + creator, + create_time, + update_time, + delete_type, + tenant_key + + + t1.id, + t1.salary_accounting_id AS salaryAcctId, + t1.send_status AS sendStatus, + t1.salary_acct_type AS salaryAcctType, + t2.salary_month AS salaryYearMonth, + t3.name AS salarySob, + t3.id AS salarySobId, + t1.send_num, + t1.send_total, + t1.last_send_time, + t2.acct_times, + t2.back_calc_status AS salaryAcctRecordType + + + + + + + AND t2.salary_month = #{param.salaryMonthDate[0]} + + + AND (t2.salary_month BETWEEN #{param.salaryMonthDate[0]} AND #{param.salaryMonthDate[1]}) + + + + AND t3.id IN + + #{id} + + + + + update hrsa_salary_send + set delete_type = 1 + where salary_accounting_id in + + #{id} + + + + + + + + + + UPDATE hrsa_salary_send + + + salary_month=#{salaryMonth}, + + + salary_accounting_id=#{salaryAccountingId}, + + + salary_sob_id=#{salarySobId}, + + + send_num=#{sendNum}, + + + send_total=#{sendTotal}, + + + last_send_time=#{lastSendTime}, + + + creator=#{creator}, + + + create_time=#{createTime}, + + + update_time=#{updateTime}, + + + delete_type=#{deleteType}, + + + tenant_key=#{tenantKey}, + + + send_status=#{sendStatus}, + + + WHERE id = #{id} AND delete_type = 0 + + + + update hrsa_salary_send + set send_status = 0 + where send_status is NULL + + + + + update hrsa_salary_send + set salary_acct_type = 0 + where salary_acct_type is NULL + + + + + + + + + + + + + + INSERT INTO hrsa_salary_send + + + id, + + + salary_month, + + + salary_accounting_id, + + + salary_sob_id, + + + send_num, + + + send_total, + + + send_status, + + + salary_acct_type, + + + last_send_time, + + + creator, + + + create_time, + + + update_time, + + + delete_type, + + + tenant_key, + + + + + + #{id}, + + + #{salaryMonth}, + + + #{salaryAccountingId}, + + + #{salarySobId}, + + + #{sendNum}, + + + #{sendTotal}, + + + #{sendStatus}, + + + #{salaryAcctType}, + + + #{lastSendTime}, + + + #{creator}, + + + #{createTime}, + + + #{updateTime}, + + + #{deleteType}, + + + #{tenantKey}, + + + + + + + + + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/salarybill/SalarySendRangeMapper.java b/src/com/engine/salary/mapper/salarybill/SalarySendRangeMapper.java new file mode 100644 index 000000000..aee1b22aa --- /dev/null +++ b/src/com/engine/salary/mapper/salarybill/SalarySendRangeMapper.java @@ -0,0 +1,34 @@ +package com.engine.salary.mapper.salarybill; + +import com.engine.salary.entity.salaryBill.dto.SalarySendRangeListDTO; +import com.engine.salary.entity.salaryBill.param.SalarySendRangeQueryParam; +import com.engine.salary.entity.salaryBill.po.SalarySendRangePO; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +public interface SalarySendRangeMapper { + int deleteByPrimaryKey(Long id); + + int insertSelective(SalarySendRangePO record); + + SalarySendRangePO selectByPrimaryKey(Long id); + + int updateByPrimaryKeySelective(SalarySendRangePO record); + + List selectByAll(SalarySendRangePO salarySendRangePO); + + List selectBySendIdAndGrantType(@Param("salarySendId") Long salarySendId, + @Param("grantType") String grantType); + + List selectIdsBySendIdAndGrantType(@Param("salarySendId") Long salarySendId, + @Param("grantType") String grantType); + + int updateBatchSelective(List list); + + int batchInsert(@Param("list") List list); + + List selectByParam(@Param("queryParam") SalarySendRangeQueryParam queryParam); + + +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/salarybill/SalarySendRangeMapper.xml b/src/com/engine/salary/mapper/salarybill/SalarySendRangeMapper.xml new file mode 100644 index 000000000..b3b46a54c --- /dev/null +++ b/src/com/engine/salary/mapper/salarybill/SalarySendRangeMapper.xml @@ -0,0 +1,358 @@ + + + + + + + + + + + + + + + + + + + + + + + + id, salary_send_id, grant_type, creator, create_time, update_time, delete_type, tenant_key + + + + update hrsa_salary_send_range + set delete_type = 1 + where id = #{id,jdbcType=BIGINT} and delete_type = 0 + + + + + + insert into hrsa_salary_send_range + + + salary_send_id, + + + grant_type, + + + creator, + + + create_time, + + + update_time, + + + delete_type, + + + tenant_key, + + + + + #{salarySendId,jdbcType=BIGINT}, + + + #{grantType,jdbcType=VARCHAR}, + + + #{creator,jdbcType=BIGINT}, + + + #{createTime,jdbcType=TIMESTAMP}, + + + #{updateTime,jdbcType=TIMESTAMP}, + + + #{deleteType,jdbcType=INTEGER}, + + + #{tenantKey,jdbcType=VARCHAR}, + + + + + + + select HRSA_S_S_R_ID.currval from dual + + insert into hrsa_salary_send_range + + id, + + salary_send_id, + + + grant_type, + + + creator, + + + create_time, + + + update_time, + + + delete_type, + + + tenant_key, + + + + #{id,jdbcType=BIGINT}, + + #{salarySendId,jdbcType=BIGINT}, + + + #{grantType,jdbcType=VARCHAR}, + + + #{creator,jdbcType=BIGINT}, + + + #{createTime,jdbcType=TIMESTAMP}, + + + #{updateTime,jdbcType=TIMESTAMP}, + + + #{deleteType,jdbcType=INTEGER}, + + + #{tenantKey,jdbcType=VARCHAR}, + + + + + + + + update hrsa_salary_send_range + + + salary_send_id = #{salarySendId,jdbcType=BIGINT}, + + + grant_type = #{grantType,jdbcType=VARCHAR}, + + + creator = #{creator,jdbcType=BIGINT}, + + + create_time = #{createTime,jdbcType=TIMESTAMP}, + + + update_time = #{updateTime,jdbcType=TIMESTAMP}, + + + delete_type = #{deleteType,jdbcType=INTEGER}, + + + tenant_key = #{tenantKey,jdbcType=VARCHAR}, + + + where id = #{id,jdbcType=BIGINT} + + + + + + + + + + + + update hrsa_salary_send_range + + + + + when id = #{item.id,jdbcType=BIGINT} then #{item.salarySendId,jdbcType=BIGINT} + + + + + + + when id = #{item.id,jdbcType=BIGINT} then #{item.grantType,jdbcType=VARCHAR} + + + + + + + when id = #{item.id,jdbcType=BIGINT} then #{item.creator,jdbcType=BIGINT} + + + + + + + when id = #{item.id,jdbcType=BIGINT} then #{item.createTime,jdbcType=TIMESTAMP} + + + + + + + when id = #{item.id,jdbcType=BIGINT} then #{item.updateTime,jdbcType=TIMESTAMP} + + + + + + + when id = #{item.id,jdbcType=BIGINT} then #{item.deleteType,jdbcType=INTEGER} + + + + + + + when id = #{item.id,jdbcType=BIGINT} then #{item.tenantKey,jdbcType=VARCHAR} + + + + + where id in + + #{item.id,jdbcType=BIGINT} + + + + + + + insert into hrsa_salary_send_range + (salary_send_id, grant_type, creator, create_time, update_time, delete_type, tenant_key + ) + values + + (#{item.salarySendId,jdbcType=BIGINT}, #{item.grantType,jdbcType=VARCHAR}, #{item.creator,jdbcType=BIGINT}, + #{item.createTime,jdbcType=TIMESTAMP}, #{item.updateTime,jdbcType=TIMESTAMP}, #{item.deleteType,jdbcType=INTEGER}, + #{item.tenantKey,jdbcType=VARCHAR}) + + + + + insert into hrsa_salary_send_range + (salary_send_id, grant_type, creator, create_time, update_time, delete_type, tenant_key + ) + values + (#{item.salarySendId,jdbcType=BIGINT}, #{item.grantType,jdbcType=VARCHAR}, #{item.creator,jdbcType=BIGINT}, + #{item.createTime,jdbcType=TIMESTAMP}, #{item.updateTime,jdbcType=TIMESTAMP}, #{item.deleteType,jdbcType=INTEGER}, + #{item.tenantKey,jdbcType=VARCHAR}) + + + + + insert into hrsa_salary_send_range + (salary_send_id, grant_type, creator, create_time, update_time, delete_type, tenant_key + ) + select + + #{item.salarySendId,jdbcType=BIGINT}, #{item.grantType,jdbcType=VARCHAR}, #{item.creator,jdbcType=BIGINT}, + #{item.createTime,jdbcType=TIMESTAMP}, #{item.updateTime,jdbcType=TIMESTAMP}, #{item.deleteType,jdbcType=INTEGER}, + #{item.tenantKey,jdbcType=VARCHAR} + + from dual + + + + + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/salarybill/SalarySendRangeObjMapper.java b/src/com/engine/salary/mapper/salarybill/SalarySendRangeObjMapper.java new file mode 100644 index 000000000..ad98471c9 --- /dev/null +++ b/src/com/engine/salary/mapper/salarybill/SalarySendRangeObjMapper.java @@ -0,0 +1,35 @@ +package com.engine.salary.mapper.salarybill; + +import com.engine.salary.entity.salaryBill.dto.SalarySendUserInfoDTO; +import com.engine.salary.entity.salaryBill.po.SalarySendRangeObj; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; + +public interface SalarySendRangeObjMapper { + int deleteByPrimaryKey(Long id); + + int insertSelective(SalarySendRangeObj record); + + SalarySendRangeObj selectByPrimaryKey(Long id); + + int updateByPrimaryKeySelective(SalarySendRangeObj record); + + List selectByAll(SalarySendRangeObj salarySendRangeObj); + + List listBySalarySendIdAndRangeIds(@Param("salarySendId") Long salarySendId, + @Param("salarySendRangeIds") List salarySendRangeId, + @Param("tenantKey") String tenantKey); + + int updateBatchSelective(List list); + + void deleteByRangeIds(@Param("salarySendRangeIds") List salarySendRangeIds, + @Param("tenantKey") String tenantKey); + + int batchInsert(@Param("list") List list); + + int deleteBySalarySendIds(@Param("salarySendIds") Collection salarySendIds); + + List getUserInfoByEmployeeIds(@Param("employeeIds") List employeeIds); +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/salarybill/SalarySendRangeObjMapper.xml b/src/com/engine/salary/mapper/salarybill/SalarySendRangeObjMapper.xml new file mode 100644 index 000000000..68737ab47 --- /dev/null +++ b/src/com/engine/salary/mapper/salarybill/SalarySendRangeObjMapper.xml @@ -0,0 +1,363 @@ + + + + + + + + + + + + + + + + + + + + + + id, salary_send_id, salary_send_range_id, range_type, target_type, target_id, creator, + create_time, update_time, delete_type, tenant_key + + + + + + + delete from hrsa_salary_send_range_obj + where id = #{id,jdbcType=BIGINT} + + + + + insert into hrsa_salary_send_range_obj + + + salary_send_id, + + + salary_send_range_id, + + + range_type, + + + target_type, + + + target_id, + + + creator, + + + create_time, + + + update_time, + + + delete_type, + + + tenant_key, + + + + + #{salarySendId,jdbcType=BIGINT}, + + + #{salarySendRangeId,jdbcType=BIGINT}, + + + #{rangeType,jdbcType=INTEGER}, + + + #{targetType,jdbcType=INTEGER}, + + + #{targetId,jdbcType=BIGINT}, + + + #{creator,jdbcType=BIGINT}, + + + #{createTime,jdbcType=TIMESTAMP}, + + + #{updateTime,jdbcType=TIMESTAMP}, + + + #{deleteType,jdbcType=INTEGER}, + + + #{tenantKey,jdbcType=VARCHAR}, + + + + + + + update hrsa_salary_send_range_obj + + + salary_send_id = #{salarySendId,jdbcType=BIGINT}, + + + salary_send_range_id = #{salarySendRangeId,jdbcType=BIGINT}, + + + range_type = #{rangeType,jdbcType=INTEGER}, + + + target_type = #{targetType,jdbcType=INTEGER}, + + + target_id = #{targetId,jdbcType=BIGINT}, + + + creator = #{creator,jdbcType=BIGINT}, + + + create_time = #{createTime,jdbcType=TIMESTAMP}, + + + update_time = #{updateTime,jdbcType=TIMESTAMP}, + + + delete_type = #{deleteType,jdbcType=INTEGER}, + + + tenant_key = #{tenantKey,jdbcType=VARCHAR}, + + + where id = #{id,jdbcType=BIGINT} + + + + + + + + + update hrsa_salary_send_range_obj + + + + + when id = #{item.id,jdbcType=BIGINT} then #{item.salarySendId,jdbcType=BIGINT} + + + + + + + when id = #{item.id,jdbcType=BIGINT} then #{item.salarySendRangeId,jdbcType=BIGINT} + + + + + + + when id = #{item.id,jdbcType=BIGINT} then #{item.rangeType,jdbcType=INTEGER} + + + + + + + when id = #{item.id,jdbcType=BIGINT} then #{item.targetType,jdbcType=INTEGER} + + + + + + + when id = #{item.id,jdbcType=BIGINT} then #{item.targetId,jdbcType=BIGINT} + + + + + + + when id = #{item.id,jdbcType=BIGINT} then #{item.creator,jdbcType=BIGINT} + + + + + + + when id = #{item.id,jdbcType=BIGINT} then #{item.createTime,jdbcType=TIMESTAMP} + + + + + + + when id = #{item.id,jdbcType=BIGINT} then #{item.updateTime,jdbcType=TIMESTAMP} + + + + + + + when id = #{item.id,jdbcType=BIGINT} then #{item.deleteType,jdbcType=INTEGER} + + + + + + + when id = #{item.id,jdbcType=BIGINT} then #{item.tenantKey,jdbcType=VARCHAR} + + + + + where id in + + #{item.id,jdbcType=BIGINT} + + + + + insert into hrsa_salary_send_range_obj + (salary_send_id, salary_send_range_id, range_type, target_type, target_id, creator, + create_time, update_time, delete_type, tenant_key) + values + + (#{item.salarySendId,jdbcType=BIGINT}, #{item.salarySendRangeId,jdbcType=BIGINT}, + #{item.rangeType,jdbcType=INTEGER}, #{item.targetType,jdbcType=INTEGER}, #{item.targetId,jdbcType=BIGINT}, + #{item.creator,jdbcType=BIGINT}, #{item.createTime,jdbcType=TIMESTAMP}, #{item.updateTime,jdbcType=TIMESTAMP}, + #{item.deleteType,jdbcType=INTEGER}, #{item.tenantKey,jdbcType=VARCHAR}) + + + + + insert into hrsa_salary_send_range_obj + (salary_send_id, salary_send_range_id, range_type, target_type, target_id, creator, + create_time, update_time, delete_type, tenant_key) + values (#{item.salarySendId,jdbcType=BIGINT}, #{item.salarySendRangeId,jdbcType=BIGINT}, + #{item.rangeType,jdbcType=INTEGER}, #{item.targetType,jdbcType=INTEGER}, + #{item.targetId,jdbcType=BIGINT}, + #{item.creator,jdbcType=BIGINT}, #{item.createTime,jdbcType=TIMESTAMP}, + #{item.updateTime,jdbcType=TIMESTAMP}, + #{item.deleteType,jdbcType=INTEGER}, #{item.tenantKey,jdbcType=VARCHAR}) + + + + insert into hrsa_salary_send_range_obj + (salary_send_id, salary_send_range_id, range_type, target_type, target_id, creator, + create_time, update_time, delete_type, tenant_key) + + select + #{item.salarySendId,jdbcType=BIGINT}, #{item.salarySendRangeId,jdbcType=BIGINT}, + #{item.rangeType,jdbcType=INTEGER}, #{item.targetType,jdbcType=INTEGER}, #{item.targetId,jdbcType=BIGINT}, + #{item.creator,jdbcType=BIGINT}, #{item.createTime,jdbcType=TIMESTAMP}, #{item.updateTime,jdbcType=TIMESTAMP}, + #{item.deleteType,jdbcType=INTEGER}, #{item.tenantKey,jdbcType=VARCHAR} + from dual + + + + + update hrsa_salary_send_range_obj + set delete_type = 1 + where salary_send_id in ( + + #{salarySendId} + + ) + and delete_type = 0 + + + + update hrsa_salary_send_range_obj + set delete_type = 1 + where delete_type = 0 + and salary_send_range_id in ( + + #{salarySendId} + + ) + + + + + + + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/salarybill/SalaryTemplateMapper.java b/src/com/engine/salary/mapper/salarybill/SalaryTemplateMapper.java new file mode 100644 index 000000000..aa20c6480 --- /dev/null +++ b/src/com/engine/salary/mapper/salarybill/SalaryTemplateMapper.java @@ -0,0 +1,76 @@ +package com.engine.salary.mapper.salarybill; + +import com.engine.salary.entity.salaryBill.dto.SalaryTemplateListDTO; +import com.engine.salary.entity.salaryBill.param.SalaryTemplateQueryParam; +import com.engine.salary.entity.salaryBill.po.SalaryTemplatePO; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; + +/** + * @Description: 工资单模板设置 + */ + +public interface SalaryTemplateMapper { + /** + * 查询工资单模板列表 + * @param param + * @return + */ + List list(@Param("param") SalaryTemplateQueryParam param); + + /** + * 分页查询工资单模板列表 + * @param page + * @param param + * @param tenantKey + * @return + */ +// IPage list(Page page, @Param("param") SalaryTemplateQueryParam param, @Param("tenantKey") String tenantKey); + + /** + * 根据主键id获取工资单模板 + * @param id + * @return + */ + SalaryTemplatePO getById(@Param("id") Long id); + + /** + * 批量删除工资单模板 + * @param ids + */ + void deleteByIds(@Param("ids") Collection ids); + + /** + * 根据id更新数据 + * @param salaryTemplateNew + */ + void updateIgnoreNull(SalaryTemplatePO salaryTemplateNew); + + /** + * 根据现有字段查询 + * @param params + * @return + */ + List listSome(SalaryTemplatePO params); + + /** + * 新增 + * @param salaryTemplatePO + */ + void insertIgnoreNull(SalaryTemplatePO salaryTemplatePO); + + /** + * 查询默认模板 + */ + List listDefaultTemplates(@Param("ids")List ids); + + /** + * 通过账套修改默认使用状态 + * @param po + */ + void updateUsetypeBySalarySobId(SalaryTemplatePO po); + + List listDTO(SalaryTemplatePO param); +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/salarybill/SalaryTemplateMapper.xml b/src/com/engine/salary/mapper/salarybill/SalaryTemplateMapper.xml new file mode 100644 index 000000000..b6e9d4003 --- /dev/null +++ b/src/com/engine/salary/mapper/salarybill/SalaryTemplateMapper.xml @@ -0,0 +1,1017 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + t + . + id + , t.name + , t.salary_sob_id + , t.use_type + , t.description + , t.email_status + , t.sms_status + , t.send_email_id + , t.msg_status + , t.theme + , t.background + , t.text_content + , t.text_content_position + , t.salary_item_null_status + , t.salary_item_zero_status + , t.salary_item_setting + , t.replenish_name + , t.replenish_rule + , t.replenish_salary_item_setting + , t.auto_send_status + , t.auto_send_cycle_type + , t.auto_send_day_of_month + , t.auto_send_time_of_day + , t.ack_feedback_status + , t.feedback_status + , t.auto_ack_days + , t.feedback_url + , t.mobile_feedback_url + , t.create_time + , t.update_time + , t.creator + , t.delete_type + , t.sms_setting + + + + + t1 + . + id + , + t1.name, + t2.name AS salary_sob, + t1.use_type, + t1.description + + + + + AND t1.id IN + + #{id} + + + + + AND t1.name like CONCAT('%',#{param.name},'%') + + + + AND t1.salary_sob_id = #{param.salarySobId} + + + + + AND t1.id IN + + #{id} + + + + + AND t1.name like '%'||#{param.name}||'%' + + + + AND t1.salary_sob_id = #{param.salarySobId} + + + + + AND t1.id IN + + #{id} + + + + + AND t1.name like '%'+#{param.name}+'%' + + + + AND t1.salary_sob_id = #{param.salarySobId} + + + + + + + + + UPDATE hrsa_salary_template + SET delete_type = 1 + WHERE delete_type = 0 + AND id IN + + #{id} + + + + + + + + + + + + + + + + + + UPDATE hrsa_salary_template + + + name=#{name}, + + + salary_sob_id=#{salarySobId}, + + + use_type=#{useType}, + + + description=#{description}, + + + email_status=#{emailStatus}, + + + sms_status=#{smsStatus}, + + + send_email_id=#{sendEmailId}, + + + msg_status=#{msgStatus}, + + + theme=#{theme}, + + + background=#{background}, + + + text_content=#{textContent}, + + + text_content_position=#{textContentPosition}, + + + salary_item_null_status=#{salaryItemNullStatus}, + + + salary_item_zero_status=#{salaryItemZeroStatus}, + + + salary_item_setting=#{salaryItemSetting}, + + + replenish_name=#{replenishName}, + + + replenish_rule=#{replenishRule}, + + + replenish_salary_item_setting=#{replenishSalaryItemSetting}, + + + auto_send_status=#{autoSendStatus}, + + + auto_send_cycle_type=#{autoSendCycleType}, + + + auto_send_day_of_month=#{autoSendDayOfMonth}, + + + auto_send_time_of_day=#{autoSendTimeOfDay}, + + + ack_feedback_status=#{ackFeedbackStatus}, + + + feedback_status=#{feedbackStatus}, + + + auto_ack_days=#{autoAckDays}, + + + feedback_url=#{feedbackUrl}, + + + mobile_feedback_url=#{mobileFeedbackUrl}, + + + create_time=#{createTime}, + + + update_time=#{updateTime}, + + + creator=#{creator}, + + + sms_setting=#{smsSetting} + + + WHERE id = #{id} AND delete_type = 0 + + + + + + INSERT INTO hrsa_salary_template + + + + id, + + + name, + + + salary_sob_id, + + + use_type, + + + description, + + + email_status, + + + send_email_id, + + + msg_status, + + + sms_status, + + + theme, + + + background, + + + text_content, + + + text_content_position, + + + salary_item_null_status, + + + salary_item_zero_status, + + + salary_item_setting, + + + replenish_name, + + + replenish_rule, + + + replenish_salary_item_setting, + + + auto_send_status, + + + auto_send_cycle_type, + + + auto_send_day_of_month, + + + auto_send_time_of_day, + + + ack_feedback_status, + + + feedback_status, + + + auto_ack_days, + + + feedback_url, + + + mobile_feedback_url, + + + create_time, + + + update_time, + + + creator, + + + delete_type, + + + tenant_key, + + + sms_setting, + + + + + #{id}, + + + #{name}, + + + #{salarySobId}, + + + #{useType}, + + + #{description}, + + + #{emailStatus}, + + + #{sendEmailId}, + + + #{msgStatus}, + + + #{smsStatus}, + + + #{theme}, + + + #{background}, + + + #{textContent}, + + + #{textContentPosition}, + + + #{salaryItemNullStatus}, + + + #{salaryItemZeroStatus}, + + + #{salaryItemSetting}, + + + #{replenishName}, + + + #{replenishRule}, + + + #{replenishSalaryItemSetting}, + + + #{autoSendStatus}, + + + #{autoSendCycleType}, + + + #{autoSendDayOfMonth}, + + + #{autoSendTimeOfDay}, + + + #{ackFeedbackStatus}, + + + #{feedbackStatus}, + + + #{autoAckDays}, + + + #{feedbackUrl}, + + + #{mobileFeedbackUrl}, + + + #{createTime}, + + + #{updateTime}, + + + #{creator}, + + + #{deleteType}, + + + #{tenantKey}, + + + #{smsSetting}, + + + + + + + select hrsa_salary_template_id.currval from dual + + INSERT INTO hrsa_salary_template + + + + id, + + + name, + + + salary_sob_id, + + + use_type, + + + description, + + + email_status, + + + send_email_id, + + + msg_status, + + + sms_status, + + + theme, + + + background, + + + text_content, + + + text_content_position, + + + salary_item_null_status, + + + salary_item_zero_status, + + + salary_item_setting, + + + replenish_name, + + + replenish_rule, + + + replenish_salary_item_setting, + + + auto_send_status, + + + auto_send_cycle_type, + + + auto_send_day_of_month, + + + auto_send_time_of_day, + + + ack_feedback_status, + + + feedback_status, + + + auto_ack_days, + + + feedback_url, + + + mobile_feedback_url, + + + create_time, + + + update_time, + + + creator, + + + delete_type, + + + tenant_key, + + + sms_setting, + + + + + #{id}, + + + #{name}, + + + #{salarySobId}, + + + #{useType}, + + + #{description}, + + + #{emailStatus}, + + + #{sendEmailId}, + + + #{msgStatus}, + + + #{smsStatus}, + + + #{theme}, + + + #{background}, + + + #{textContent}, + + + #{textContentPosition}, + + + #{salaryItemNullStatus}, + + + #{salaryItemZeroStatus}, + + + #{salaryItemSetting}, + + + #{replenishName}, + + + #{replenishRule}, + + + #{replenishSalaryItemSetting}, + + + #{autoSendStatus}, + + + #{autoSendCycleType}, + + + #{autoSendDayOfMonth}, + + + #{autoSendTimeOfDay}, + + + #{ackFeedbackStatus}, + + + #{feedbackStatus}, + + + #{autoAckDays}, + + + #{feedbackUrl}, + + + #{mobileFeedbackUrl}, + + + #{createTime}, + + + #{updateTime}, + + + #{creator}, + + + #{deleteType}, + + + #{tenantKey}, + + + #{smsSetting}, + + + + + + + + UPDATE hrsa_salary_template + + + use_type=#{useType} + + + WHERE salary_sob_id=#{salarySobId} AND delete_type = 0 + + + + diff --git a/src/com/engine/salary/mapper/salaryitem/SalaryItemMapper.java b/src/com/engine/salary/mapper/salaryitem/SalaryItemMapper.java new file mode 100644 index 000000000..bc07a947d --- /dev/null +++ b/src/com/engine/salary/mapper/salaryitem/SalaryItemMapper.java @@ -0,0 +1,78 @@ +package com.engine.salary.mapper.salaryitem; + +import com.engine.salary.entity.salaryitem.config.SalaryItemExcelConfig; +import com.engine.salary.entity.salaryitem.param.SalaryItemSearchParam; +import com.engine.salary.entity.salaryitem.po.SalaryItemPO; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; + +public interface SalaryItemMapper { + + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + SalaryItemPO getById(Long id); + + /** + * 条件查询 + * + * @return 返回集合,没有返回空List + */ + List listSome(SalaryItemPO salaryItem); + + /** + * 新增,忽略null字段 + * + * @param SalaryItemPO 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(SalaryItemPO SalaryItemPO); + + + /** + * 修改,忽略null字段 + * + * @param SalaryItemPO 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(SalaryItemPO SalaryItemPO); + + /** + * 删除记录 + * + * @param SalaryItemPO 待删除的记录 + * @return 返回影响行数 + */ + int delete(SalaryItemPO SalaryItemPO); + + void batchInsert(Collection salaryItems); + + void deleteByIds(@Param("ids") Collection ids); + + List listByParam(@Param("param") SalaryItemSearchParam param); + + List listByParamOrderById(@Param("param") SalaryItemSearchParam param); + + void batchUpdateSortedIndex(@Param("collection")List salaryItemPOS); + + SalaryItemPO getByName(String name); + SalaryItemPO getByCode(String code); + + List getConfig(@Param("ids") Collection ids); + + + +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/salaryitem/SalaryItemMapper.xml b/src/com/engine/salary/mapper/salaryitem/SalaryItemMapper.xml new file mode 100644 index 000000000..693e9f222 --- /dev/null +++ b/src/com/engine/salary/mapper/salaryitem/SalaryItemMapper.xml @@ -0,0 +1,655 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + t + . + id + , + t.name, + t.code, + t.system_type, + t.sys_salary_item_id, + t.use_default, + t.use_in_employee_salary, + t.rounding_mode, + t.pattern, + t.value_type, + t.formula_id, + t.description, + t.can_edit, + t.can_delete, + t.creator, + t.delete_type, + t.tenant_key, + t.create_time, + t.update_time, + t.data_type, + t.shared_type, + t.tax_agent_ids, + t.sorted_index, + t.hide_default, + t.width, + t.default_value + + + + + + + + + + + + + + INSERT INTO hrsa_salary_item + + + + id, + + + name, + + + code, + + + system_type, + + + sys_salary_item_id, + + + use_default, + + + use_in_employee_salary, + + + hide_default, + + + rounding_mode, + + + pattern, + + + value_type, + + + formula_id, + + + description, + + + can_edit, + + + creator, + + + delete_type, + + + tenant_key, + + + create_time, + + + update_time, + + + data_type, + + + shared_type, + + + tax_agent_ids, + + + sorted_index, + + + width, + + + default_value, + + + + + #{id}, + + + #{name}, + + + #{code}, + + + #{systemType}, + + + #{sysSalaryItemId}, + + + #{useDefault}, + + + #{useInEmployeeSalary}, + + + #{hideDefault}, + + + #{roundingMode}, + + + #{pattern}, + + + #{valueType}, + + + #{formulaId}, + + + #{description}, + + + #{canEdit}, + + + #{creator}, + + + #{deleteType}, + + + #{tenantKey}, + + + #{createTime}, + + + #{updateTime}, + + + #{dataType}, + + + #{sharedType}, + + + #{taxAgentIds}, + + + #{sortedIndex}, + + + #{width}, + + + #{defaultValue}, + + + + + + + + UPDATE hrsa_salary_item + + + name=#{name}, + + + code=#{code}, + + + system_type=#{systemType}, + + + sys_salary_item_id=#{sysSalaryItemId}, + + + use_default=#{useDefault}, + + + use_in_employee_salary=#{useInEmployeeSalary}, + + + hide_default=#{hideDefault}, + + + rounding_mode=#{roundingMode}, + + + pattern=#{pattern}, + + + value_type=#{valueType}, + + + formula_id=#{formulaId}, + + + description=#{description}, + + + can_edit=#{canEdit}, + + + creator=#{creator}, + + + delete_type=#{deleteType}, + + + tenant_key=#{tenantKey}, + + + create_time=#{createTime}, + + + update_time=#{updateTime}, + + + data_type=#{dataType}, + + + shared_type=#{sharedType}, + + + tax_agent_ids=#{taxAgentIds}, + + + width=#{width}, + + + sorted_index=#{sortedIndex}, + + + default_value=#{defaultValue}, + + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_salary_item + SET delete_type=1 + WHERE id = #{id} + AND delete_type = 0 + + + + + INSERT INTO hrsa_salary_item + (id, name, code, system_type, sys_salary_item_id, use_default, use_in_employee_salary, + rounding_mode, pattern, value_type, formula_id, description, can_edit, create_time, + update_time, creator, delete_type, tenant_key, data_type, shared_type, tax_agent_ids) + VALUES + + (#{item.id},#{item.name}, #{item.code}, #{item.systemType}, #{item.sysSalaryItemId}, + #{item.useDefault}, #{item.useInEmployeeSalary}, #{item.roundingMode}, + #{item.pattern}, + #{item.valueType}, #{item.formulaId}, #{item.description}, #{item.canEdit}, + #{item.createTime}, #{item.updateTime}, #{item.creator}, 0, #{item.tenantKey}, #{item.dataType}, + #{item.sharedType}, #{item.taxAgentIds}) + + + + INSERT INTO hrsa_salary_item + (id,name, code, system_type, sys_salary_item_id, use_default, use_in_employee_salary, + rounding_mode, pattern, value_type, formula_id, description, can_edit, create_time, + update_time, creator, delete_type, tenant_key, data_type, shared_type, tax_agent_ids) + + + select + #{item.id,jdbcType=DOUBLE}, + #{item.name,jdbcType=VARCHAR}, + #{item.code,jdbcType=VARCHAR}, + #{item.systemType,jdbcType=INTEGER}, + #{item.sysSalaryItemId,jdbcType=DOUBLE}, + #{item.useDefault,jdbcType=INTEGER}, + #{item.useInEmployeeSalary,jdbcType=INTEGER}, + #{item.roundingMode,jdbcType=INTEGER}, + #{item.pattern,jdbcType=INTEGER}, + #{item.valueType,jdbcType=INTEGER}, + #{item.formulaId,jdbcType=DOUBLE}, + #{item.description,jdbcType=VARCHAR}, + #{item.canEdit,jdbcType=INTEGER}, + #{item.createTime,jdbcType=DATE}, + #{item.updateTime,jdbcType=DATE}, + #{item.creator,jdbcType=DOUBLE}, + 0, + #{item.tenantKey,jdbcType=VARCHAR}, + #{item.dataType,jdbcType=VARCHAR}, + #{item.sharedType,jdbcType=INTEGER}, + #{item.taxAgentIds,jdbcType=VARCHAR} + from dual + + + + + INSERT INTO hrsa_salary_item + (id,name, code, system_type, sys_salary_item_id, use_default, use_in_employee_salary, + rounding_mode, pattern, value_type, formula_id, description, can_edit, create_time, + update_time, creator, delete_type, tenant_key, data_type, shared_type, tax_agent_ids) + VALUES + (#{item.id},#{item.name}, #{item.code}, #{item.systemType}, #{item.sysSalaryItemId}, + #{item.useDefault}, #{item.useInEmployeeSalary}, #{item.roundingMode}, + #{item.pattern}, + #{item.valueType}, #{item.formulaId}, #{item.description}, #{item.canEdit}, + #{item.createTime}, #{item.updateTime}, #{item.creator}, 0, #{item.tenantKey}, #{item.dataType}, + #{item.sharedType}, #{item.taxAgentIds}) + + + + + UPDATE hrsa_salary_item + SET delete_type = 1 + WHERE delete_type = 0 + AND id IN + + #{id} + + + + update hrsa_salary_item + + + + + when id=#{item.id} then #{item.sortedIndex} + + + + + where + id in + + #{item.id} + + + + + + + + + + + AND name like CONCAT('%',#{param.name},'%') + + + AND description like CONCAT('%',#{param.description},'%') + + + AND id NOT IN + + #{id} + + + + AND use_in_employee_salary = #{param.useInEmployeeSalary} + + + AND use_default = #{param.useDefault} + + + AND value_type = #{param.valueType} + + + + + AND name like '%'||#{param.name}||'%' + + + AND description like '%'||#{param.description}||'%' + + + AND id NOT IN + + #{id} + + + + AND use_in_employee_salary = #{param.useInEmployeeSalary} + + + AND use_default = #{param.useDefault} + + + AND value_type = #{param.valueType} + + + + + AND name like '%'+#{param.name}+'%' + + + AND description like '%'+#{param.description}+'%' + + + AND id NOT IN + + #{id} + + + + AND use_in_employee_salary = #{param.useInEmployeeSalary} + + + AND use_default = #{param.useDefault} + + + AND value_type = #{param.valueType} + + + + + + + + + + + + + + + + + + + + + + + + + + + item.name as name + , item.use_default as use_default + , item.hide_default as hide_default + , item.data_type as data_type + , item.rounding_mode as rounding_mode + , item.pattern as pattern + , item.value_type as value_type + , f.formula as formula + , f.extend_param as extend_param + , item.sorted_index as sorted_index + , item.width as width + , item.default_value as default_value + , item.description as description + + + + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/salaryitem/SysSalaryItemMapper.java b/src/com/engine/salary/mapper/salaryitem/SysSalaryItemMapper.java new file mode 100644 index 000000000..64fc27445 --- /dev/null +++ b/src/com/engine/salary/mapper/salaryitem/SysSalaryItemMapper.java @@ -0,0 +1,73 @@ +package com.engine.salary.mapper.salaryitem; + +import com.engine.salary.entity.salaryitem.po.SysSalaryItemPO; + +import java.util.List; + + +public interface SysSalaryItemMapper { + + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + /** + * 条件查询 + * @param po + * @return + */ + List listSome(SysSalaryItemPO po); + + /** + * 条件查询 + * @param po + * @return + */ + List listLikeName(SysSalaryItemPO po); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + SysSalaryItemPO getById(Long id); + + /** + * 新增,忽略null字段 + * + * @param SysSalaryItemPO 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(SysSalaryItemPO SysSalaryItemPO); + + /** + * 修改,修改所有字段 + * + * @param SysSalaryItemPO 修改的记录 + * @return 返回影响行数 + */ + int update(SysSalaryItemPO SysSalaryItemPO); + + /** + * 修改,忽略null字段 + * + * @param SysSalaryItemPO 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(SysSalaryItemPO SysSalaryItemPO); + + /** + * 删除记录 + * + * @param SysSalaryItemPO 待删除的记录 + * @return 返回影响行数 + */ + int delete(SysSalaryItemPO SysSalaryItemPO); + + SysSalaryItemPO selectOneByName(String name); +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/salaryitem/SysSalaryItemMapper.xml b/src/com/engine/salary/mapper/salaryitem/SysSalaryItemMapper.xml new file mode 100644 index 000000000..5f0f1977d --- /dev/null +++ b/src/com/engine/salary/mapper/salaryitem/SysSalaryItemMapper.xml @@ -0,0 +1,828 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + t + . + id + , t.name + , t.code + , t.system_type + , t.item_type + , t.use_default + , t.use_in_employee_salary + , t.rounding_mode + , t.pattern + , t.value_type + , t.formula_id + , t.description + , t.can_edit + , t.creator + , t.delete_type + , t.tenant_key + , t.create_time + , t.update_time + , t.data_type + + + + + + + + + + + + + + + + + + + + + + + + + + INSERT INTO hrsa_sys_salary_item + + + + id, + + + name, + + + code, + + + system_type, + + + use_default, + + + use_in_employee_salary, + + + rounding_mode, + + + pattern, + + + value_type, + + + formula_id, + + + description, + + + can_edit, + + + data_type, + + + creator, + + + delete_type, + + + tenant_key, + + + create_time, + + + update_time, + + + + + #{id}, + + + #{name}, + + + #{code}, + + + #{systemType}, + + + #{useDefault}, + + + #{useInEmployeeSalary}, + + + #{roundingMode}, + + + #{pattern}, + + + #{valueType}, + + + #{formulaId}, + + + #{description}, + + + #{canEdit}, + + + #{dataType}, + + + #{creator}, + + + #{deleteType}, + + + #{tenantKey}, + + + #{createTime}, + + + #{updateTime}, + + + + + + + select hrsa_sys_salary_item_id.currval from dual + + INSERT INTO hrsa_sys_salary_item + + + + id, + + + name, + + + code, + + + system_type, + + + use_default, + + + use_in_employee_salary, + + + rounding_mode, + + + pattern, + + + value_type, + + + formula_id, + + + description, + + + can_edit, + + + data_type, + + + creator, + + + delete_type, + + + tenant_key, + + + create_time, + + + update_time, + + + + + #{id}, + + + #{name}, + + + #{code}, + + + #{systemType}, + + + #{useDefault}, + + + #{useInEmployeeSalary}, + + + #{roundingMode}, + + + #{pattern}, + + + #{valueType}, + + + #{formulaId}, + + + #{description}, + + + #{canEdit}, + + + #{dataType}, + + + #{creator}, + + + #{deleteType}, + + + #{tenantKey}, + + + #{createTime}, + + + #{updateTime}, + + + + + + + UPDATE hrsa_sys_salary_item + + name=#{name}, + code=#{code}, + system_type=#{systemType}, + use_default=#{useDefault}, + use_in_employee_salary=#{useInEmployeeSalary}, + rounding_mode=#{roundingMode}, + pattern=#{pattern}, + value_type=#{valueType}, + formula_id=#{formulaId}, + description=#{description}, + can_edit=#{canEdit}, + data_type=#{dataType}, + creator=#{creator}, + delete_type=#{deleteType}, + tenant_key=#{tenantKey}, + create_time=#{createTime}, + update_time=#{updateTime}, + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_sys_salary_item + + + name=#{name}, + + + code=#{code}, + + + system_type=#{systemType}, + + + use_default=#{useDefault}, + + + use_in_employee_salary=#{useInEmployeeSalary}, + + + rounding_mode=#{roundingMode}, + + + pattern=#{pattern}, + + + value_type=#{valueType}, + + + formula_id=#{formulaId}, + + + description=#{description}, + + + can_edit=#{canEdit}, + + + data_type=#{dataType}, + + + creator=#{creator}, + + + delete_type=#{deleteType}, + + + tenant_key=#{tenantKey}, + + + create_time=#{createTime}, + + + update_time=#{updateTime}, + + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_sys_salary_item + SET delete_type=1 + WHERE id = #{id} + AND delete_type = 0 + + + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/salarysob/SalaryApprovalRuleMapper.java b/src/com/engine/salary/mapper/salarysob/SalaryApprovalRuleMapper.java new file mode 100644 index 000000000..0aea946f8 --- /dev/null +++ b/src/com/engine/salary/mapper/salarysob/SalaryApprovalRuleMapper.java @@ -0,0 +1,72 @@ +package com.engine.salary.mapper.salarysob; + +import com.engine.salary.entity.salarysob.po.SalaryApprovalRulePO; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * @author Harryxzy + * @ClassName SalaryApprovalRuleMapper + * @date 2024/04/23 17:36 + * @description + */ +public interface SalaryApprovalRuleMapper { + + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + /** + * 条件查询 + * + * @return 返回集合,没有返回空List + */ + List listSome(SalaryApprovalRulePO salaryApprovalRule); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + SalaryApprovalRulePO getById(Long id); + + /** + * 新增,忽略null字段 + * + * @param salaryApprovalRule 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(SalaryApprovalRulePO salaryApprovalRule); + + /** + * 修改,修改所有字段 + * + * @param salaryApprovalRule 修改的记录 + * @return 返回影响行数 + */ + int update(SalaryApprovalRulePO salaryApprovalRule); + + /** + * 修改,忽略null字段 + * + * @param salaryApprovalRule 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(SalaryApprovalRulePO salaryApprovalRule); + + /** + * 删除记录 + * + * @param salaryApprovalRule 待删除的记录 + * @return 返回影响行数 + */ + int delete(SalaryApprovalRulePO salaryApprovalRule); + + void deleteBySalarySobId(@Param("salarySobId") Long salarySobId); +} diff --git a/src/com/engine/salary/mapper/salarysob/SalaryApprovalRuleMapper.xml b/src/com/engine/salary/mapper/salarysob/SalaryApprovalRuleMapper.xml new file mode 100644 index 000000000..9d21ed200 --- /dev/null +++ b/src/com/engine/salary/mapper/salarysob/SalaryApprovalRuleMapper.xml @@ -0,0 +1,222 @@ + + + + + + + + + + + + + + + + + + t.approval_group_setting + , t.create_time + , t.creator + , t.delete_type + , t.id + , t.open_approval + , t.salary_sob_id + , t.update_time + , t.workflow_url + + + + + + + + + + + + + + + INSERT INTO hrsa_salary_approval_rule + + + + approval_group_setting, + + + create_time, + + + creator, + + + delete_type, + + + id, + + + open_approval, + + + salary_sob_id, + + + update_time, + + + workflow_url, + + + + + #{approvalGroupSetting}, + + + #{createTime}, + + + #{creator}, + + + #{deleteType}, + + + #{id}, + + + #{openApproval}, + + + #{salarySobId}, + + + #{updateTime}, + + + #{workflowUrl}, + + + + + + + UPDATE hrsa_salary_approval_rule + + approval_group_setting=#{approvalGroupSetting}, + create_time=#{createTime}, + creator=#{creator}, + delete_type=#{deleteType}, + open_approval=#{openApproval}, + salary_sob_id=#{salarySobId}, + update_time=#{updateTime}, + workflow_url=#{workflowUrl}, + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_salary_approval_rule + + + approval_group_setting=#{approvalGroupSetting}, + + + create_time=#{createTime}, + + + creator=#{creator}, + + + delete_type=#{deleteType}, + + + open_approval=#{openApproval}, + + + salary_sob_id=#{salarySobId}, + + + update_time=#{updateTime}, + + + workflow_url=#{workflowUrl}, + + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_salary_approval_rule + SET delete_type=1 + WHERE id = #{id} AND delete_type = 0 + + + + UPDATE hrsa_salary_approval_rule + SET delete_type=1 + WHERE salary_sob_id = #{salarySobId} AND delete_type = 0 + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/salarysob/SalarySobAdjustRuleMapper.java b/src/com/engine/salary/mapper/salarysob/SalarySobAdjustRuleMapper.java new file mode 100644 index 000000000..281e45521 --- /dev/null +++ b/src/com/engine/salary/mapper/salarysob/SalarySobAdjustRuleMapper.java @@ -0,0 +1,82 @@ +package com.engine.salary.mapper.salarysob; + +import com.engine.salary.entity.salarysob.po.SalarySobAdjustRulePO; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; + +public interface SalarySobAdjustRuleMapper { + + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + /** + * 条件查询 + * + * @return 返回集合,没有返回空List + */ + List listSome(SalarySobAdjustRulePO salarySobAdjustRule); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + SalarySobAdjustRulePO getById(Long id); + + /** + * 新增,忽略null字段 + * + * @param salarySobAdjustRule 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(SalarySobAdjustRulePO salarySobAdjustRule); + + /** + * 修改,修改所有字段 + * + * @param salarySobAdjustRule 修改的记录 + * @return 返回影响行数 + */ + int update(SalarySobAdjustRulePO salarySobAdjustRule); + + /** + * 修改,忽略null字段 + * + * @param salarySobAdjustRule 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(SalarySobAdjustRulePO salarySobAdjustRule); + + /** + * 删除记录 + * + * @param salarySobAdjustRule 待删除的记录 + * @return 返回影响行数 + */ + int delete(SalarySobAdjustRulePO salarySobAdjustRule); + + + /** + * 批量插入 + * + * @param salaryAdjustmentRules + */ + void batchInsert(@Param("collection") Collection salaryAdjustmentRules); + + /** + * 根据账套id批量删除 + * + * @param salarySobIds + */ + void deleteBySalarySobIds(@Param("salarySobIds") Collection salarySobIds); + + +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/salarysob/SalarySobAdjustRuleMapper.xml b/src/com/engine/salary/mapper/salarysob/SalarySobAdjustRuleMapper.xml new file mode 100644 index 000000000..de9d25332 --- /dev/null +++ b/src/com/engine/salary/mapper/salarysob/SalarySobAdjustRuleMapper.xml @@ -0,0 +1,400 @@ + + + + + + + + + + + + + + + + + + + + t + . + id + , t.salary_sob_id + , t.salary_item_id + , t.day_of_month + , t.before_adjustment_type + , t.after_adjustment_type + , t.creator + , t.create_time + , t.update_time + , t.delete_type + , t.tenant_key + + + + + + + + + + + + + + + INSERT INTO hrsa_salary_sob_adjust_rule + + + + id, + + + salary_sob_id, + + + salary_item_id, + + + day_of_month, + + + before_adjustment_type, + + + after_adjustment_type, + + + creator, + + + create_time, + + + update_time, + + + delete_type, + + + tenant_key, + + + + + #{id}, + + + #{salarySobId}, + + + #{salaryItemId}, + + + #{dayOfMonth}, + + + #{beforeAdjustmentType}, + + + #{afterAdjustmentType}, + + + #{creator}, + + + #{createTime}, + + + #{updateTime}, + + + #{deleteType}, + + + #{tenantKey}, + + + + + + + select hrsa_salary_sob_adjust_rule_id.currval from dual + + INSERT INTO hrsa_salary_sob_adjust_rule + + + + id, + + + salary_sob_id, + + + salary_item_id, + + + day_of_month, + + + before_adjustment_type, + + + after_adjustment_type, + + + creator, + + + create_time, + + + update_time, + + + delete_type, + + + tenant_key, + + + + + #{id}, + + + #{salarySobId}, + + + #{salaryItemId}, + + + #{dayOfMonth}, + + + #{beforeAdjustmentType}, + + + #{afterAdjustmentType}, + + + #{creator}, + + + #{createTime}, + + + #{updateTime}, + + + #{deleteType}, + + + #{tenantKey}, + + + + + + + UPDATE hrsa_salary_sob_adjust_rule + + salary_sob_id=#{salarySobId}, + salary_item_id=#{salaryItemId}, + day_of_month=#{dayOfMonth}, + before_adjustment_type=#{beforeAdjustmentType}, + after_adjustment_type=#{afterAdjustmentType}, + creator=#{creator}, + create_time=#{createTime}, + update_time=#{updateTime}, + delete_type=#{deleteType}, + tenant_key=#{tenantKey}, + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_salary_sob_adjust_rule + + + salary_sob_id=#{salarySobId}, + + + salary_item_id=#{salaryItemId}, + + + day_of_month=#{dayOfMonth}, + + + before_adjustment_type=#{beforeAdjustmentType}, + + + after_adjustment_type=#{afterAdjustmentType}, + + + creator=#{creator}, + + + create_time=#{createTime}, + + + update_time=#{updateTime}, + + + delete_type=#{deleteType}, + + + tenant_key=#{tenantKey}, + + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_salary_sob_adjust_rule + SET delete_type=1 + WHERE id = #{id} + AND delete_type = 0 + + + + + INSERT INTO hrsa_salary_sob_adjust_rule + ( salary_sob_id, salary_item_id, day_of_month, + before_adjustment_type, after_adjustment_type, creator, create_time, update_time, + delete_type, tenant_key) + VALUES + + ( + #{item.salarySobId}, + #{item.salaryItemId}, + #{item.dayOfMonth}, + #{item.beforeAdjustmentType}, + #{item.afterAdjustmentType}, + #{item.creator}, + #{item.createTime}, + #{item.updateTime}, + #{item.deleteType}, + #{item.tenantKey} + ) + + + + INSERT INTO hrsa_salary_sob_adjust_rule + ( salary_sob_id, salary_item_id, day_of_month, + before_adjustment_type, after_adjustment_type, creator, create_time, update_time, + delete_type, tenant_key) + + + select + #{item.salarySobId,jdbcType=DOUBLE}, + #{item.salaryItemId,jdbcType=DOUBLE}, + #{item.dayOfMonth,jdbcType=INTEGER}, + #{item.beforeAdjustmentType,jdbcType=INTEGER}, + #{item.afterAdjustmentType,jdbcType=INTEGER}, + #{item.creator,jdbcType=DOUBLE}, + #{item.createTime,jdbcType=DATE}, + #{item.updateTime,jdbcType=DATE}, + #{item.deleteType,jdbcType=INTEGER}, + #{item.tenantKey,jdbcType=VARCHAR} + from dual + + + + + INSERT INTO hrsa_salary_sob_adjust_rule + (salary_sob_id, salary_item_id, day_of_month, + before_adjustment_type, after_adjustment_type, creator, create_time, update_time, + delete_type, tenant_key) + VALUES + ( + #{item.salarySobId}, + #{item.salaryItemId}, + #{item.dayOfMonth}, + #{item.beforeAdjustmentType}, + #{item.afterAdjustmentType}, + #{item.creator}, + #{item.createTime}, + #{item.updateTime}, + #{item.deleteType}, + #{item.tenantKey} + ) + + + + + UPDATE hrsa_salary_sob_adjust_rule + SET delete_type = 1 + WHERE delete_type = 0 + AND salary_sob_id IN + + #{salarySobId} + + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/salarysob/SalarySobBackItemMapper.java b/src/com/engine/salary/mapper/salarysob/SalarySobBackItemMapper.java new file mode 100644 index 000000000..0804eb48e --- /dev/null +++ b/src/com/engine/salary/mapper/salarysob/SalarySobBackItemMapper.java @@ -0,0 +1,88 @@ +package com.engine.salary.mapper.salarysob; + +import com.engine.salary.entity.salarysob.po.SalarySobBackItemPO; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; + +/** + * @author Harryxzy + * @date 2022/11/15 16:31 + * @description + */ +public interface SalarySobBackItemMapper { + + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + /** + * 条件查询 + * + * @return 返回集合,没有返回空List + */ + List listSome(SalarySobBackItemPO salarySobBackItem); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + SalarySobBackItemPO getById(Long id); + + /** + * 新增,忽略null字段 + * + * @param salarySobBackItem 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(SalarySobBackItemPO salarySobBackItem); + + /** + * 修改,修改所有字段 + * + * @param salarySobBackItem 修改的记录 + * @return 返回影响行数 + */ + int update(SalarySobBackItemPO salarySobBackItem); + + /** + * 修改,忽略null字段 + * + * @param salarySobBackItem 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(SalarySobBackItemPO salarySobBackItem); + + /** + * 删除记录 + * + * @param salarySobBackItem 待删除的记录 + * @return 返回影响行数 + */ + int delete(SalarySobBackItemPO salarySobBackItem); + + void batchInsert(@Param("collection") List needInsertSalarySobBackItems); + + /** + * @description 根据薪资账套获取回算薪资项目数 + * @return Long + * @author Harryxzy + * @date 2022/11/18 13:57 + */ + Long countBySalarySobIdIn(@Param("salarySobIdCollection")Collection salarySobIdCollection); + + /** + * @description 根据薪资账套删除 + * @return void + * @author Harryxzy + * @date 2022/11/22 14:17 + */ + int deleteBySalarySobIds( @Param("salarySobIdList") Collection salarySobIdList); +} diff --git a/src/com/engine/salary/mapper/salarysob/SalarySobBackItemMapper.xml b/src/com/engine/salary/mapper/salarysob/SalarySobBackItemMapper.xml new file mode 100644 index 000000000..85c51b081 --- /dev/null +++ b/src/com/engine/salary/mapper/salarysob/SalarySobBackItemMapper.xml @@ -0,0 +1,393 @@ + + + + + id, + salary_sob_id, + salary_item_id, + salary_item_code, + data_type, + rounding_mode, + pattern, + value_type, + formula_id, + back_calc_type, + tenant_key, + creator, + delete_type, + create_time, + update_time + + + + + + + + + + + + + + + + + + + + + t.id + , t.salary_sob_id + , t.salary_item_id + , t.salary_item_code + , t.data_type + , t.rounding_mode + , t.pattern + , t.value_type + , t.formula_id + , t.back_calc_type + , t.tenant_key + , t.creator + , t.delete_type + , t.create_time + , t.update_time + , t.default_value + + + + + + + + + + + + + + + + + + + + + + INSERT INTO hrsa_salary_sob_back_item + + + + id, + + + salary_sob_id, + + + salary_item_id, + + + salary_item_code, + + + data_type, + + + rounding_mode, + + + pattern, + + + value_type, + + + formula_id, + + + back_calc_type, + + + tenant_key, + + + creator, + + + delete_type, + + + create_time, + + + update_time, + + + + + #{id}, + + + #{salarySobId}, + + + #{salaryItemId}, + + + #{salaryItemCode}, + + + #{dataType}, + + + #{roundingMode}, + + + #{pattern}, + + + #{valueType}, + + + #{formulaId}, + + + #{backCalcType}, + + + #{tenantKey}, + + + #{creator}, + + + #{deleteType}, + + + #{createTime}, + + + #{updateTime}, + + + + + + INSERT INTO hrsa_salary_sob_back_item + (id, salary_sob_id, salary_item_id, salary_item_code, data_type, rounding_mode, pattern, + value_type, formula_id, back_calc_type, tenant_key, creator, delete_type, create_time, + update_time) + VALUES + + (#{item.id},#{item.salarySobId}, #{item.salaryItemId}, #{item.salaryItemCode}, #{item.dataType}, + #{item.roundingMode}, #{item.pattern}, #{item.valueType}, + #{item.formulaId}, + #{item.backCalcType}, #{item.tenantKey}, #{item.creator}, 0, + #{item.createTime}, #{item.updateTime}) + + + + + + INSERT INTO hrsa_salary_sob_back_item + (id, salary_sob_id, salary_item_id, salary_item_code, data_type, rounding_mode, pattern, + value_type, formula_id, back_calc_type, tenant_key, creator, delete_type, create_time, + update_time) + + select + #{item.id,jdbcType=DOUBLE},#{item.salarySobId,jdbcType=DOUBLE}, #{item.salaryItemId,jdbcType=DOUBLE}, #{item.salaryItemCode,jdbcType=VARCHAR}, #{item.dataType,jdbcType=VARCHAR}, + #{item.roundingMode,jdbcType=INTEGER}, #{item.pattern,jdbcType=INTEGER}, #{item.valueType,jdbcType=INTEGER}, + #{item.formulaId,jdbcType=DOUBLE}, + #{item.backCalcType,jdbcType=INTEGER}, #{item.tenantKey,jdbcType=VARCHAR}, #{item.creator,jdbcType=DOUBLE}, 0, + #{item.createTime,jdbcType=DATE}, #{item.updateTime,jdbcType=DATE} + from dual + + + + + INSERT INTO hrsa_salary_sob_back_item + (id, salary_sob_id, salary_item_id, salary_item_code, data_type, rounding_mode, pattern, + value_type, formula_id, back_calc_type, tenant_key, creator, delete_type, create_time, + update_time) + VALUES + (#{item.id},#{item.salarySobId}, #{item.salaryItemId}, #{item.salaryItemCode}, #{item.dataType}, + #{item.roundingMode}, #{item.pattern}, #{item.valueType}, + #{item.formulaId}, + #{item.backCalcType}, #{item.tenantKey}, #{item.creator}, 0, + #{item.createTime}, #{item.updateTime}) + + + + + + UPDATE hrsa_salary_sob_back_item + + salary_sob_id=#{salarySobId}, + salary_item_id=#{salaryItemId}, + salary_item_code=#{salaryItemCode}, + data_type=#{dataType}, + rounding_mode=#{roundingMode}, + pattern=#{pattern}, + value_type=#{valueType}, + formula_id=#{formulaId}, + back_calc_type=#{backCalcType}, + tenant_key=#{tenantKey}, + creator=#{creator}, + delete_type=#{deleteType}, + create_time=#{createTime}, + update_time=#{updateTime}, + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_salary_sob_back_item + + + salary_sob_id=#{salarySobId}, + + + salary_item_id=#{salaryItemId}, + + + salary_item_code=#{salaryItemCode}, + + + data_type=#{dataType}, + + + rounding_mode=#{roundingMode}, + + + pattern=#{pattern}, + + + value_type=#{valueType}, + + + formula_id=#{formulaId}, + + + back_calc_type=#{backCalcType}, + + + tenant_key=#{tenantKey}, + + + creator=#{creator}, + + + delete_type=#{deleteType}, + + + create_time=#{createTime}, + + + update_time=#{updateTime}, + + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_salary_sob_back_item + SET delete_type=1 + WHERE id = #{id} AND delete_type = 0 + + + + + + + update hrsa_salary_sob_back_item + set delete_type = 1 + where + salary_sob_id in + + #{item,jdbcType=NUMERIC} + + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/salarysob/SalarySobCheckRuleMapper.java b/src/com/engine/salary/mapper/salarysob/SalarySobCheckRuleMapper.java new file mode 100644 index 000000000..d8888e5a0 --- /dev/null +++ b/src/com/engine/salary/mapper/salarysob/SalarySobCheckRuleMapper.java @@ -0,0 +1,91 @@ +package com.engine.salary.mapper.salarysob; + +import com.engine.salary.entity.salarysob.param.SalarySobCheckRuleQueryParam; +import com.engine.salary.entity.salarysob.po.SalarySobCheckRulePO; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; + +public interface SalarySobCheckRuleMapper { + + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + /** + * 条件查询 + * + * @return 返回集合,没有返回空List + */ + List listSome(SalarySobCheckRulePO salarySobCheckRule); + + List listByParam(SalarySobCheckRuleQueryParam param); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + SalarySobCheckRulePO getById(Long id); + + /** + * 新增,忽略null字段 + * + * @param salarySobCheckRule 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(SalarySobCheckRulePO salarySobCheckRule); + + /** + * 修改,修改所有字段 + * + * @param salarySobCheckRule 修改的记录 + * @return 返回影响行数 + */ + int update(SalarySobCheckRulePO salarySobCheckRule); + + /** + * 修改,忽略null字段 + * + * @param salarySobCheckRule 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(SalarySobCheckRulePO salarySobCheckRule); + + /** + * 删除记录 + * + * @param salarySobCheckRule 待删除的记录 + * @return 返回影响行数 + */ + int delete(SalarySobCheckRulePO salarySobCheckRule); + + /** + * 根据主键id删除 + * + * @param ids + */ + void deleteByIds(@Param("ids") Collection ids); + + /** + * 根据薪资账套id删除 + * + * @param salarySobIds + */ + void deleteBySalarySobIds(@Param("salarySobIds") Collection salarySobIds); + + /** + * 批量保存 + * + * @param salarySobCheckRules + */ + void batchInsert(@Param("collection") Collection salarySobCheckRules); + + +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/salarysob/SalarySobCheckRuleMapper.xml b/src/com/engine/salary/mapper/salarysob/SalarySobCheckRuleMapper.xml new file mode 100644 index 000000000..a3cb8efce --- /dev/null +++ b/src/com/engine/salary/mapper/salarysob/SalarySobCheckRuleMapper.xml @@ -0,0 +1,420 @@ + + + + + + + + + + + + + + + + + + + t + . + id + , t.salary_sob_id + , t.name + , t.formula_id + , t.description + , t.create_time + , t.update_time + , t.creator + , t.delete_type + , t.tenant_key + + + + + + + + + + + + + + + + + + AND salary_sob_id = #{salarySobId} + + + AND name like CONCAT('%',#{name},'%') + + + + + + AND salary_sob_id = #{salarySobId} + + + AND name like '%'||#{name}||'%' + + + + + + AND salary_sob_id = #{salarySobId} + + + AND name like '%'+#{name}+'%' + + + + + + + INSERT INTO hrsa_salary_sob_check_rule + + + + id, + + + salary_sob_id, + + + name, + + + formula_id, + + + description, + + + create_time, + + + update_time, + + + creator, + + + delete_type, + + + tenant_key, + + + + + #{id}, + + + #{salarySobId}, + + + #{name}, + + + #{formulaId}, + + + #{description}, + + + #{createTime}, + + + #{updateTime}, + + + #{creator}, + + + #{deleteType}, + + + #{tenantKey}, + + + + + + + select hrsa_salary_sob_check_rule_id.currval from dual + + INSERT INTO hrsa_salary_sob_check_rule + + + + id, + + + salary_sob_id, + + + name, + + + formula_id, + + + description, + + + create_time, + + + update_time, + + + creator, + + + delete_type, + + + tenant_key, + + + + + #{id}, + + + #{salarySobId}, + + + #{name}, + + + #{formulaId}, + + + #{description}, + + + #{createTime}, + + + #{updateTime}, + + + #{creator}, + + + #{deleteType}, + + + #{tenantKey}, + + + + + + + UPDATE hrsa_salary_sob_check_rule + + salary_sob_id=#{salarySobId}, + name=#{name}, + formula_id=#{formulaId}, + description=#{description}, + create_time=#{createTime}, + update_time=#{updateTime}, + creator=#{creator}, + delete_type=#{deleteType}, + tenant_key=#{tenantKey}, + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_salary_sob_check_rule + + + salary_sob_id=#{salarySobId}, + + + name=#{name}, + + + formula_id=#{formulaId}, + + + description=#{description}, + + + create_time=#{createTime}, + + + update_time=#{updateTime}, + + + creator=#{creator}, + + + delete_type=#{deleteType}, + + + tenant_key=#{tenantKey}, + + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_salary_sob_check_rule + SET delete_type=1 + WHERE id = #{id} + AND delete_type = 0 + + + + + UPDATE hrsa_salary_sob_check_rule + SET delete_type = 1 + WHERE delete_type = 0 + AND id IN + + #{id} + + + + + UPDATE hrsa_salary_sob_check_rule + SET delete_type = 1 + WHERE delete_type = 0 + AND salary_sob_id IN + + #{salarySobId} + + + + + INSERT INTO hrsa_salary_sob_check_rule( salary_sob_id, name, formula_id, description, create_time, + update_time, creator, delete_type, tenant_key) + VALUES + + ( + #{item.salarySobId}, + #{item.name}, + #{item.formulaId}, + #{item.description}, + #{item.createTime}, + #{item.updateTime}, + #{item.creator}, + #{item.deleteType}, + #{item.tenantKey} + ) + + + + INSERT INTO hrsa_salary_sob_check_rule(salary_sob_id, name, formula_id, description, create_time, + update_time, creator, delete_type, tenant_key) + + + select + #{item.salarySobId,jdbcType=DOUBLE}, + #{item.name,jdbcType=VARCHAR}, + #{item.formulaId,jdbcType=DOUBLE}, + #{item.description,jdbcType=VARCHAR}, + #{item.createTime,jdbcType=DATE}, + #{item.updateTime,jdbcType=DATE}, + #{item.creator,jdbcType=DOUBLE}, + #{item.deleteType,jdbcType=INTEGER}, + #{item.tenantKey,jdbcType=VARCHAR} + from dual + + + + + INSERT INTO hrsa_salary_sob_check_rule(salary_sob_id, name, formula_id, description, create_time, + update_time, creator, delete_type, tenant_key) + VALUES + ( + #{item.salarySobId}, + #{item.name}, + #{item.formulaId}, + #{item.description}, + #{item.createTime}, + #{item.updateTime}, + #{item.creator}, + #{item.deleteType}, + #{item.tenantKey} + ) + + + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/salarysob/SalarySobDefaultEmpFieldMapper.java b/src/com/engine/salary/mapper/salarysob/SalarySobDefaultEmpFieldMapper.java new file mode 100644 index 000000000..5a517d5a3 --- /dev/null +++ b/src/com/engine/salary/mapper/salarysob/SalarySobDefaultEmpFieldMapper.java @@ -0,0 +1,67 @@ +package com.engine.salary.mapper.salarysob; + +import com.engine.salary.entity.salarysob.po.SalarySobDefaultEmpFieldPO; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; + +public interface SalarySobDefaultEmpFieldMapper { + + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + /** + * 条件查询 + * + * @return 返回集合,没有返回空List + */ + List listSome(SalarySobDefaultEmpFieldPO sobDefaultEmpField); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + SalarySobDefaultEmpFieldPO getById(Long id); + + /** + * 新增,忽略null字段 + * + * @param sobDefaultEmpField 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(SalarySobDefaultEmpFieldPO sobDefaultEmpField); + + /** + * 修改,修改所有字段 + * + * @param sobDefaultEmpField 修改的记录 + * @return 返回影响行数 + */ + int update(SalarySobDefaultEmpFieldPO sobDefaultEmpField); + + /** + * 修改,忽略null字段 + * + * @param sobDefaultEmpField 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(SalarySobDefaultEmpFieldPO sobDefaultEmpField); + + /** + * 删除记录 + * + * @param sobDefaultEmpField 待删除的记录 + * @return 返回影响行数 + */ + int delete(SalarySobDefaultEmpFieldPO sobDefaultEmpField); + + void deleteByIds(@Param("ids") Collection ids); +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/salarysob/SalarySobDefaultEmpFieldMapper.xml b/src/com/engine/salary/mapper/salarysob/SalarySobDefaultEmpFieldMapper.xml new file mode 100644 index 000000000..aa08c7658 --- /dev/null +++ b/src/com/engine/salary/mapper/salarysob/SalarySobDefaultEmpFieldMapper.xml @@ -0,0 +1,294 @@ + + + + + + + + + + + + + + + + + + t + . + id + , t.field_code + , t.sorted_index + , t.can_delete + , t.creator + , t.create_time + , t.update_time + , t.delete_type + , t.tenant_key + + + + + + + + + + + + + + + INSERT INTO hrsa_sob_default_emp_field + + + + id, + + + field_code, + + + sorted_index, + + + can_delete, + + + creator, + + + create_time, + + + update_time, + + + delete_type, + + + tenant_key, + + + + + #{id}, + + + #{fieldCode}, + + + #{sortedIndex}, + + + #{canDelete}, + + + #{creator}, + + + #{createTime}, + + + #{updateTime}, + + + #{deleteType}, + + + #{tenantKey}, + + + + + + + + select hrsa_sob_default_emp_field_id.currval from dual + + INSERT INTO hrsa_sob_default_emp_field + + + + id, + + + field_code, + + + sorted_index, + + + can_delete, + + + creator, + + + create_time, + + + update_time, + + + delete_type, + + + tenant_key, + + + + + #{id}, + + + #{fieldCode}, + + + #{sortedIndex}, + + + #{canDelete}, + + + #{creator}, + + + #{createTime}, + + + #{updateTime}, + + + #{deleteType}, + + + #{tenantKey}, + + + + + + + UPDATE hrsa_sob_default_emp_field + + field_code=#{fieldCode}, + sorted_index=#{sortedIndex}, + can_delete=#{canDelete}, + creator=#{creator}, + create_time=#{createTime}, + update_time=#{updateTime}, + delete_type=#{deleteType}, + tenant_key=#{tenantKey}, + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_sob_default_emp_field + + + field_code=#{fieldCode}, + + + sorted_index=#{sortedIndex}, + + + can_delete=#{canDelete}, + + + creator=#{creator}, + + + create_time=#{createTime}, + + + update_time=#{updateTime}, + + + delete_type=#{deleteType}, + + + tenant_key=#{tenantKey}, + + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_sob_default_emp_field + SET delete_type=1 + WHERE id = #{id} + AND delete_type = 0 + + + + UPDATE hrsa_sob_default_emp_field + SET delete_type = 1 + WHERE delete_type = 0 + AND id IN + + #{id} + + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/salarysob/SalarySobDefaultItemGroupMapper.java b/src/com/engine/salary/mapper/salarysob/SalarySobDefaultItemGroupMapper.java new file mode 100644 index 000000000..3ed42b0f9 --- /dev/null +++ b/src/com/engine/salary/mapper/salarysob/SalarySobDefaultItemGroupMapper.java @@ -0,0 +1,64 @@ +package com.engine.salary.mapper.salarysob; + +import com.engine.salary.entity.salarysob.po.SalarySobDefaultItemGroupPO; + +import java.util.List; + +public interface SalarySobDefaultItemGroupMapper { + + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + /** + * 条件查询 + * + * @return 返回集合,没有返回空List + */ + List listSome(SalarySobDefaultItemGroupPO sobDefaultItemGroup); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + SalarySobDefaultItemGroupPO getById(Long id); + + /** + * 新增,忽略null字段 + * + * @param sobDefaultItemGroup 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(SalarySobDefaultItemGroupPO sobDefaultItemGroup); + + /** + * 修改,修改所有字段 + * + * @param sobDefaultItemGroup 修改的记录 + * @return 返回影响行数 + */ + int update(SalarySobDefaultItemGroupPO sobDefaultItemGroup); + + /** + * 修改,忽略null字段 + * + * @param sobDefaultItemGroup 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(SalarySobDefaultItemGroupPO sobDefaultItemGroup); + + /** + * 删除记录 + * + * @param sobDefaultItemGroup 待删除的记录 + * @return 返回影响行数 + */ + int delete(SalarySobDefaultItemGroupPO sobDefaultItemGroup); + +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/salarysob/SalarySobDefaultItemGroupMapper.xml b/src/com/engine/salary/mapper/salarysob/SalarySobDefaultItemGroupMapper.xml new file mode 100644 index 000000000..81e68abdd --- /dev/null +++ b/src/com/engine/salary/mapper/salarysob/SalarySobDefaultItemGroupMapper.xml @@ -0,0 +1,304 @@ + + + + + + + + + + + + + + + + + + + t + . + id + , t.income_category + , t.name + , t.sorted_index + , t.description + , t.create_time + , t.update_time + , t.creator + , t.delete_type + , t.tenant_key + + + + + + + + + + + + + + + INSERT INTO hrsa_sob_default_item_group + + + + id, + + + income_category, + + + name, + + + sorted_index, + + + description, + + + create_time, + + + update_time, + + + creator, + + + delete_type, + + + tenant_key, + + + + + #{id}, + + + #{incomeCategory}, + + + #{name}, + + + #{sortedIndex}, + + + #{description}, + + + #{createTime}, + + + #{updateTime}, + + + #{creator}, + + + #{deleteType}, + + + #{tenantKey}, + + + + + + + select hrsa_sob_default_item_group_id.currval from dual + + INSERT INTO hrsa_sob_default_item_group + + + + id, + + + income_category, + + + name, + + + sorted_index, + + + description, + + + create_time, + + + update_time, + + + creator, + + + delete_type, + + + tenant_key, + + + + + #{id}, + + + #{incomeCategory}, + + + #{name}, + + + #{sortedIndex}, + + + #{description}, + + + #{createTime}, + + + #{updateTime}, + + + #{creator}, + + + #{deleteType}, + + + #{tenantKey}, + + + + + + + UPDATE hrsa_sob_default_item_group + + income_category=#{incomeCategory}, + name=#{name}, + sorted_index=#{sortedIndex}, + description=#{description}, + create_time=#{createTime}, + update_time=#{updateTime}, + creator=#{creator}, + delete_type=#{deleteType}, + tenant_key=#{tenantKey}, + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_sob_default_item_group + + + income_category=#{incomeCategory}, + + + name=#{name}, + + + sorted_index=#{sortedIndex}, + + + description=#{description}, + + + create_time=#{createTime}, + + + update_time=#{updateTime}, + + + creator=#{creator}, + + + delete_type=#{deleteType}, + + + tenant_key=#{tenantKey}, + + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_sob_default_item_group + SET delete_type=1 + WHERE id = #{id} + AND delete_type = 0 + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/salarysob/SalarySobDefaultItemMapper.java b/src/com/engine/salary/mapper/salarysob/SalarySobDefaultItemMapper.java new file mode 100644 index 000000000..6b834effe --- /dev/null +++ b/src/com/engine/salary/mapper/salarysob/SalarySobDefaultItemMapper.java @@ -0,0 +1,66 @@ +package com.engine.salary.mapper.salarysob; + +import com.engine.salary.entity.salarysob.po.SalarySobDefaultItemPO; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + + +public interface SalarySobDefaultItemMapper { + + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + /** + * 条件查询 + * + * @return 返回集合,没有返回空List + */ + List listSome(SalarySobDefaultItemPO salarySobDefaultItem); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + SalarySobDefaultItemPO getById(Long id); + + /** + * 新增,忽略null字段 + * + * @param salarySobDefaultItem 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(SalarySobDefaultItemPO salarySobDefaultItem); + + /** + * 修改,修改所有字段 + * + * @param salarySobDefaultItem 修改的记录 + * @return 返回影响行数 + */ + int update(SalarySobDefaultItemPO salarySobDefaultItem); + + /** + * 修改,忽略null字段 + * + * @param salarySobDefaultItem 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(SalarySobDefaultItemPO salarySobDefaultItem); + + /** + * 删除记录 + * + * @param salarySobDefaultItem 待删除的记录 + * @return 返回影响行数 + */ + int delete(SalarySobDefaultItemPO salarySobDefaultItem); + +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/salarysob/SalarySobDefaultItemMapper.xml b/src/com/engine/salary/mapper/salarysob/SalarySobDefaultItemMapper.xml new file mode 100644 index 000000000..424133cfd --- /dev/null +++ b/src/com/engine/salary/mapper/salarysob/SalarySobDefaultItemMapper.xml @@ -0,0 +1,340 @@ + + + + + + + + + + + + + + + + + + + + + t + . + id + , t.income_category + , t.sys_salary_item_id + , t.can_edit + , t.can_delete + , t.creator + , t.create_time + , t.update_time + , t.delete_type + , t.tenant_key + , t.sob_default_item_group_id + , t.sorted_index + + + + + + + + + + + + + + + INSERT INTO hrsa_salary_sob_default_item + + + + id, + + + income_category, + + + sys_salary_item_id, + + + can_edit, + + + can_delete, + + + creator, + + + create_time, + + + update_time, + + + delete_type, + + + tenant_key, + + + sob_default_item_group_id, + + + sorted_index, + + + + + #{id}, + + + #{incomeCategory}, + + + #{sysSalaryItemId}, + + + #{canEdit}, + + + #{canDelete}, + + + #{creator}, + + + #{createTime}, + + + #{updateTime}, + + + #{deleteType}, + + + #{tenantKey}, + + + #{sobDefaultItemGroupId}, + + + #{sortedIndex}, + + + + + + + select hrsa_salary_sob_default_item_id.currval from dual + + INSERT INTO hrsa_salary_sob_default_item + + + + id, + + + income_category, + + + sys_salary_item_id, + + + can_edit, + + + can_delete, + + + creator, + + + create_time, + + + update_time, + + + delete_type, + + + tenant_key, + + + sob_default_item_group_id, + + + sorted_index, + + + + + #{id}, + + + #{incomeCategory}, + + + #{sysSalaryItemId}, + + + #{canEdit}, + + + #{canDelete}, + + + #{creator}, + + + #{createTime}, + + + #{updateTime}, + + + #{deleteType}, + + + #{tenantKey}, + + + #{sobDefaultItemGroupId}, + + + #{sortedIndex}, + + + + + + + UPDATE hrsa_salary_sob_default_item + + income_category=#{incomeCategory}, + sys_salary_item_id=#{sysSalaryItemId}, + can_edit=#{canEdit}, + can_delete=#{canDelete}, + creator=#{creator}, + create_time=#{createTime}, + update_time=#{updateTime}, + delete_type=#{deleteType}, + tenant_key=#{tenantKey}, + sob_default_item_group_id=#{sobDefaultItemGroupId}, + sorted_index=#{sortedIndex}, + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_salary_sob_default_item + + + income_category=#{incomeCategory}, + + + sys_salary_item_id=#{sysSalaryItemId}, + + + can_edit=#{canEdit}, + + + can_delete=#{canDelete}, + + + creator=#{creator}, + + + create_time=#{createTime}, + + + update_time=#{updateTime}, + + + delete_type=#{deleteType}, + + + tenant_key=#{tenantKey}, + + + sob_default_item_group_id=#{sobDefaultItemGroupId}, + + + sorted_index=#{sortedIndex}, + + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_salary_sob_default_item + SET delete_type=1 + WHERE id = #{id} + AND delete_type = 0 + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/salarysob/SalarySobEmpFieldMapper.java b/src/com/engine/salary/mapper/salarysob/SalarySobEmpFieldMapper.java new file mode 100644 index 000000000..8221abb24 --- /dev/null +++ b/src/com/engine/salary/mapper/salarysob/SalarySobEmpFieldMapper.java @@ -0,0 +1,95 @@ +package com.engine.salary.mapper.salarysob; + +import com.engine.salary.entity.salarysob.po.SalarySobEmpFieldPO; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; + +public interface SalarySobEmpFieldMapper { + + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + /** + * 条件查询 + * + * @return 返回集合,没有返回空List + */ + List listSome(SalarySobEmpFieldPO SalarySobEmpFieldPO); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + SalarySobEmpFieldPO getById(Long id); + + /** + * 新增,忽略null字段 + * + * @param SalarySobEmpFieldPO 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(SalarySobEmpFieldPO SalarySobEmpFieldPO); + + /** + * 修改,修改所有字段 + * + * @param SalarySobEmpFieldPO 修改的记录 + * @return 返回影响行数 + */ + int update(SalarySobEmpFieldPO SalarySobEmpFieldPO); + + /** + * 修改,忽略null字段 + * + * @param SalarySobEmpFieldPO 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(SalarySobEmpFieldPO SalarySobEmpFieldPO); + + /** + * 删除记录 + * + * @param SalarySobEmpFieldPO 待删除的记录 + * @return 返回影响行数 + */ + int delete(SalarySobEmpFieldPO SalarySobEmpFieldPO); + + + /** + * 批量插入 + * + * @param salarySobEmpFields + */ + void batchInsert(@Param("collection") Collection salarySobEmpFields); + + /** + * 批量更新 + * + * @param salarySobEmpFields + */ + void batchUpdate(@Param("collection") Collection salarySobEmpFields); + + /** + * 根据主键id删除 + * + * @param ids + */ + void deleteByIds(@Param("ids") Collection ids); + + /** + * 根据薪资账套id删除 + * + * @param salarySobIds + */ + void deleteBySalarySobIds(@Param("salarySobIds") Collection salarySobIds); + +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/salarysob/SalarySobEmpFieldMapper.xml b/src/com/engine/salary/mapper/salarysob/SalarySobEmpFieldMapper.xml new file mode 100644 index 000000000..bde24704a --- /dev/null +++ b/src/com/engine/salary/mapper/salarysob/SalarySobEmpFieldMapper.xml @@ -0,0 +1,406 @@ + + + + + + + + + + + + + + + + + + + t + . + id + , t.salary_sob_id + , t.field_code + , t.sorted_index + , t.can_delete + , t.creator + , t.create_time + , t.update_time + , t.delete_type + , t.tenant_key + + + + + + + + + + + + + + + INSERT INTO hrsa_salary_sob_emp_field + + + + id, + + + salary_sob_id, + + + field_code, + + + sorted_index, + + + can_delete, + + + creator, + + + create_time, + + + update_time, + + + delete_type, + + + tenant_key, + + + + + #{id}, + + + #{salarySobId}, + + + #{fieldCode}, + + + #{sortedIndex}, + + + #{canDelete}, + + + #{creator}, + + + #{createTime}, + + + #{updateTime}, + + + #{deleteType}, + + + #{tenantKey}, + + + + + + + select hrsa_salary_sob_emp_field_id.currval from dual + + INSERT INTO hrsa_salary_sob_emp_field + + + + id, + + + salary_sob_id, + + + field_code, + + + sorted_index, + + + can_delete, + + + creator, + + + create_time, + + + update_time, + + + delete_type, + + + tenant_key, + + + + + #{id}, + + + #{salarySobId}, + + + #{fieldCode}, + + + #{sortedIndex}, + + + #{canDelete}, + + + #{creator}, + + + #{createTime}, + + + #{updateTime}, + + + #{deleteType}, + + + #{tenantKey}, + + + + + + + UPDATE hrsa_salary_sob_emp_field + + salary_sob_id=#{salarySobId}, + field_code=#{fieldCode}, + sorted_index=#{sortedIndex}, + can_delete=#{canDelete}, + creator=#{creator}, + create_time=#{createTime}, + update_time=#{updateTime}, + delete_type=#{deleteType}, + tenant_key=#{tenantKey}, + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_salary_sob_emp_field + + + salary_sob_id=#{salarySobId}, + + + field_code=#{fieldCode}, + + + sorted_index=#{sortedIndex}, + + + can_delete=#{canDelete}, + + + creator=#{creator}, + + + create_time=#{createTime}, + + + update_time=#{updateTime}, + + + delete_type=#{deleteType}, + + + tenant_key=#{tenantKey}, + + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_salary_sob_emp_field + SET delete_type=1 + WHERE id = #{id} + AND delete_type = 0 + + + + + + INSERT INTO + hrsa_salary_sob_emp_field(salary_sob_id, field_code, sorted_index,can_delete, creator, create_time, update_time, + delete_type, tenant_key) + VALUES + + ( + #{item.salarySobId}, + #{item.fieldCode}, + #{item.sortedIndex}, + #{item.canDelete}, + #{item.creator}, + #{item.createTime}, + #{item.updateTime}, + 0, + #{item.tenantKey} + ) + + + + INSERT INTO + hrsa_salary_sob_emp_field( salary_sob_id, field_code, sorted_index,can_delete, creator, create_time, update_time, + delete_type, tenant_key) + + + select + #{item.salarySobId,jdbcType=DOUBLE}, + #{item.fieldCode,jdbcType=VARCHAR}, + #{item.sortedIndex,jdbcType=INTEGER}, + #{item.canDelete,jdbcType=INTEGER}, + #{item.creator,jdbcType=DOUBLE}, + #{item.createTime,jdbcType=DATE}, + #{item.updateTime,jdbcType=DATE}, + 0, + #{item.tenantKey,jdbcType=VARCHAR} + from dual + + + + + INSERT INTO + hrsa_salary_sob_emp_field(salary_sob_id, field_code, sorted_index,can_delete, creator, create_time, update_time, + delete_type, tenant_key) + VALUES + ( + #{item.salarySobId}, + #{item.fieldCode}, + #{item.sortedIndex}, + #{item.canDelete}, + #{item.creator}, + #{item.createTime}, + #{item.updateTime}, + 0, + #{item.tenantKey} + ) + + + + + UPDATE hrsa_salary_sob_emp_field + + + + WHEN id = #{item.id} THEN #{item.sortedIndex} + + + + + WHEN id = #{item.id} THEN #{item.updateTime} + + + + WHERE delete_type = 0 + AND id IN + + #{item.id} + + + + + UPDATE hrsa_salary_sob_emp_field + SET delete_type = 1 + WHERE delete_type = 0 + AND id IN + + #{id} + + + + + UPDATE hrsa_salary_sob_emp_field + SET delete_type = 1 + WHERE delete_type = 0 + AND salary_sob_id IN + + #{salarySobId} + + + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/salarysob/SalarySobExtRangeMapper.java b/src/com/engine/salary/mapper/salarysob/SalarySobExtRangeMapper.java new file mode 100644 index 000000000..b8c01933c --- /dev/null +++ b/src/com/engine/salary/mapper/salarysob/SalarySobExtRangeMapper.java @@ -0,0 +1,69 @@ +package com.engine.salary.mapper.salarysob; + +import com.engine.salary.entity.SalarySobExtRangePO; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; + +public interface SalarySobExtRangeMapper { + + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + /** + * 条件查询 + * + * @return 返回集合,没有返回空List + */ + List listSome(SalarySobExtRangePO salarySobExtRange); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + SalarySobExtRangePO getById(Long id); + + /** + * 新增,忽略null字段 + * + * @param salarySobExtRange 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(SalarySobExtRangePO salarySobExtRange); + + /** + * 修改,修改所有字段 + * + * @param salarySobExtRange 修改的记录 + * @return 返回影响行数 + */ + int update(SalarySobExtRangePO salarySobExtRange); + + /** + * 修改,忽略null字段 + * + * @param salarySobExtRange 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(SalarySobExtRangePO salarySobExtRange); + + /** + * 删除记录 + * + * @param salarySobExtRange 待删除的记录 + * @return 返回影响行数 + */ + int delete(SalarySobExtRangePO salarySobExtRange); + + List listPage4Ext(SalarySobExtRangePO build); + + void deleteByIds(@Param("ids") Collection ids); +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/salarysob/SalarySobExtRangeMapper.xml b/src/com/engine/salary/mapper/salarysob/SalarySobExtRangeMapper.xml new file mode 100644 index 000000000..066bf3d61 --- /dev/null +++ b/src/com/engine/salary/mapper/salarysob/SalarySobExtRangeMapper.xml @@ -0,0 +1,250 @@ + + + + + + + + + + + + + + + + + + t.create_time + , t.creator + , t.delete_type + , t.id + , t.salary_sob_id + , t.target_id + , t.target_type + , t.tenant_key + , t.update_time + + + + + + + + + + + + + + + INSERT INTO hrsa_salary_sob_ext_range + + + + create_time, + + + creator, + + + delete_type, + + + id, + + + salary_sob_id, + + + target_id, + + + target_type, + + + tenant_key, + + + update_time, + + + + + #{createTime}, + + + #{creator}, + + + #{deleteType}, + + + #{id}, + + + #{salarySobId}, + + + #{targetId}, + + + #{targetType}, + + + #{tenantKey}, + + + #{updateTime}, + + + + + + + UPDATE hrsa_salary_sob_ext_range + + create_time=#{createTime}, + creator=#{creator}, + delete_type=#{deleteType}, + salary_sob_id=#{salarySobId}, + target_id=#{targetId}, + target_type=#{targetType}, + tenant_key=#{tenantKey}, + update_time=#{updateTime}, + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_salary_sob_ext_range + + + create_time=#{createTime}, + + + creator=#{creator}, + + + delete_type=#{deleteType}, + + + salary_sob_id=#{salarySobId}, + + + target_id=#{targetId}, + + + target_type=#{targetType}, + + + tenant_key=#{tenantKey}, + + + update_time=#{updateTime}, + + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_salary_sob_ext_range + SET delete_type=1 + WHERE id = #{id} AND delete_type = 0 + + + + + + + + UPDATE hrsa_salary_sob_ext_range + SET delete_type=1 + WHERE id IN + + #{id} + + and delete_type=0 + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/salarysob/SalarySobItemGroupMapper.java b/src/com/engine/salary/mapper/salarysob/SalarySobItemGroupMapper.java new file mode 100644 index 000000000..30a1ec4f4 --- /dev/null +++ b/src/com/engine/salary/mapper/salarysob/SalarySobItemGroupMapper.java @@ -0,0 +1,89 @@ +package com.engine.salary.mapper.salarysob; + +import com.engine.salary.entity.salarysob.po.SalarySobItemGroupPO; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; + +public interface SalarySobItemGroupMapper { + + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + /** + * 条件查询 + * + * @return 返回集合,没有返回空List + */ + List listSome(SalarySobItemGroupPO salarySobItemGroup); + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + SalarySobItemGroupPO getById(Long id); + + /** + * 新增,忽略null字段 + * + * @param salarySobItemGroup 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(SalarySobItemGroupPO salarySobItemGroup); + + /** + * 修改,修改所有字段 + * + * @param salarySobItemGroup 修改的记录 + * @return 返回影响行数 + */ + int update(SalarySobItemGroupPO salarySobItemGroup); + + /** + * 修改,忽略null字段 + * + * @param salarySobItemGroup 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(SalarySobItemGroupPO salarySobItemGroup); + + /** + * 删除记录 + * + * @param salarySobItemGroup 待删除的记录 + * @return 返回影响行数 + */ + int delete(SalarySobItemGroupPO salarySobItemGroup); + + + + /** + * 根据薪资账套id删除 + * + * @param salarySobIds + */ + void deleteBySalarySobIds(@Param("salarySobIds") Collection salarySobIds); + + /** + * 根据主键id删除 + * + * @param ids + */ + void deleteByIds(@Param("ids") Collection ids); + + /** + * 批量保存 + * + * @param salarySobItemGroups + */ + void batchInsert(@Param("collection") Collection salarySobItemGroups); + + +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/salarysob/SalarySobItemGroupMapper.xml b/src/com/engine/salary/mapper/salarysob/SalarySobItemGroupMapper.xml new file mode 100644 index 000000000..7b89d50d7 --- /dev/null +++ b/src/com/engine/salary/mapper/salarysob/SalarySobItemGroupMapper.xml @@ -0,0 +1,322 @@ + + + + + + + + + + + + + + + + + + + + t + . + id + , t.salary_sob_id + , t.name + , t.sorted_index + , t.description + , t.create_time + , t.update_time + , t.creator + , t.delete_type + , t.tenant_key + , t.item_hide + + + + + + + + + + + + + + + + + INSERT INTO hrsa_salary_sob_item_group + + + + id, + + + salary_sob_id, + + + name, + + + sorted_index, + + + description, + + + create_time, + + + update_time, + + + creator, + + + delete_type, + + + tenant_key, + + + item_hide, + + + + + #{id}, + + + #{salarySobId}, + + + #{name}, + + + #{sortedIndex}, + + + #{description}, + + + #{createTime}, + + + #{updateTime}, + + + #{creator}, + + + #{deleteType}, + + + #{tenantKey}, + + + #{itemHide}, + + + + + + + UPDATE hrsa_salary_sob_item_group + + salary_sob_id=#{salarySobId}, + name=#{name}, + sorted_index=#{sortedIndex}, + description=#{description}, + create_time=#{createTime}, + update_time=#{updateTime}, + creator=#{creator}, + delete_type=#{deleteType}, + tenant_key=#{tenantKey}, + item_hide=#{itemHide}, + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_salary_sob_item_group + + + salary_sob_id=#{salarySobId}, + + + name=#{name}, + + + sorted_index=#{sortedIndex}, + + + description=#{description}, + + + create_time=#{createTime}, + + + update_time=#{updateTime}, + + + creator=#{creator}, + + + delete_type=#{deleteType}, + + + tenant_key=#{tenantKey}, + + + item_hide=#{itemHide}, + + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_salary_sob_item_group + SET delete_type=1 + WHERE id = #{id} + AND delete_type = 0 + + + + + UPDATE hrsa_salary_sob_item_group + SET delete_type = 1 + WHERE delete_type = 0 + AND salary_sob_id IN + + #{salarySobId} + + + + + UPDATE hrsa_salary_sob_item_group + SET delete_type = 1 + WHERE delete_type = 0 + AND id IN + + #{id} + + + + + INSERT INTO hrsa_salary_sob_item_group(id, salary_sob_id, name, sorted_index, description, create_time, + update_time, creator, tenant_key,item_hide) + VALUES + + ( + #{item.id}, + #{item.salarySobId}, + #{item.name}, + #{item.sortedIndex}, + #{item.description}, + #{item.createTime}, + #{item.updateTime}, + #{item.creator}, + #{item.tenantKey}, + #{item.itemHide} + ) + + + + INSERT INTO hrsa_salary_sob_item_group(id, salary_sob_id, name, sorted_index, description, create_time, + update_time, creator, tenant_key,item_hide) + + + select + #{item.id,jdbcType=DOUBLE}, + #{item.salarySobId,jdbcType=DOUBLE}, + #{item.name,jdbcType=VARCHAR}, + #{item.sortedIndex,jdbcType=INTEGER}, + #{item.description,jdbcType=VARCHAR}, + #{item.createTime,jdbcType=DATE}, + #{item.updateTime,jdbcType=DATE}, + #{item.creator,jdbcType=DOUBLE}, + #{item.tenantKey,jdbcType=VARCHAR}, + #{item.itemHide,jdbcType=VARCHAR} + from dual + + + + + INSERT INTO hrsa_salary_sob_item_group(id, salary_sob_id, name, sorted_index, description, create_time, + update_time, creator, tenant_key,item_hide) + VALUES + ( + #{item.id}, + #{item.salarySobId}, + #{item.name}, + #{item.sortedIndex}, + #{item.description}, + #{item.createTime}, + #{item.updateTime}, + #{item.creator}, + #{item.tenantKey}, + #{item.itemHide} + ) + + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/salarysob/SalarySobItemHideMapper.java b/src/com/engine/salary/mapper/salarysob/SalarySobItemHideMapper.java new file mode 100644 index 000000000..77106cd38 --- /dev/null +++ b/src/com/engine/salary/mapper/salarysob/SalarySobItemHideMapper.java @@ -0,0 +1,32 @@ +package com.engine.salary.mapper.salarysob; + +import com.engine.salary.entity.salarysob.po.SalarySobItemHidePO; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; + +public interface SalarySobItemHideMapper { + + /** + * 根据账套id获取关闭显示开关的itemID + * @param salarySobPO + * @return + */ + List listHideItemIds(SalarySobItemHidePO salarySobPO); + + /*** + * @description 删除薪资账套的薪资项目隐藏信息 + * @return void + * @author Harryxzy + * @date 2022/9/22 9:14 + */ + void deleteBySalarySobIds(@Param("ids") Collection ids); + + void update(SalarySobItemHidePO salarySobPO); + + + void updateByItemId(SalarySobItemHidePO salarySobGroupItemHidePO); + + List listSome(@Param("param") SalarySobItemHidePO po); +} diff --git a/src/com/engine/salary/mapper/salarysob/SalarySobItemHideMapper.xml b/src/com/engine/salary/mapper/salarysob/SalarySobItemHideMapper.xml new file mode 100644 index 000000000..05fc565c6 --- /dev/null +++ b/src/com/engine/salary/mapper/salarysob/SalarySobItemHideMapper.xml @@ -0,0 +1,75 @@ + + + + + delete from hrsa_salary_item_hide + WHERE delete_type = 0 + AND salary_sob_id IN + + #{salarySobId} + + + + + + + + + + + + + UPDATE hrsa_salary_item_hide + + item_hide=#{itemHide}, + update_time=#{updateTime} + + WHERE id = #{id} AND delete_type = 0 + + + + + UPDATE hrsa_salary_item_hide + + item_hide=#{itemHide}, + update_time=#{updateTime} + + WHERE salary_sob_id = #{salarySobId} AND salary_item_id= #{salaryItemId} AND delete_type = 0 + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/salarysob/SalarySobItemMapper.java b/src/com/engine/salary/mapper/salarysob/SalarySobItemMapper.java new file mode 100644 index 000000000..dd2e00621 --- /dev/null +++ b/src/com/engine/salary/mapper/salarysob/SalarySobItemMapper.java @@ -0,0 +1,100 @@ +package com.engine.salary.mapper.salarysob; + +import com.engine.salary.entity.salarysob.po.SalarySobItemPO; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; + + +public interface SalarySobItemMapper { + + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + /** + * 条件查询 + * + * @return 返回集合,没有返回空List + */ + List listSome(SalarySobItemPO salarySobItemPO); + + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + SalarySobItemPO getById(Long id); + + + /** + * 修改,修改所有字段 + * + * @param salarySobItemPO 修改的记录 + * @return 返回影响行数 + */ + int update(SalarySobItemPO salarySobItemPO); + + /** + * 修改,忽略null字段 + * + * @param salarySobItemPO 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(SalarySobItemPO salarySobItemPO); + + /** + * 删除记录 + * + * @param salarySobItemPO 待删除的记录 + * @return 返回影响行数 + */ + int delete(SalarySobItemPO salarySobItemPO); + + + /** + * 根据薪资账套id删除 + * + * @param salarySobIds + */ + void deleteBySalarySobIds(@Param("salarySobIds") Collection salarySobIds); + + /** + * 根据主键id删除 + * + * @param ids + */ + void deleteByIds(@Param("ids") Collection ids); + + /** + * 批量保存 + * + * @param salarySobItems + */ + void batchInsert(@Param("collection") Collection salarySobItems); + + + /** + * 删除工资项目是否显示 + * + * @param salarySobIds + */ + void deleteItemShowBySalarySobId(@Param("salarySobIds")Collection salarySobIds); + + /** + * 根据账套id以及薪资项目分组获取 + * @param + */ + List listBySalarySobIdAndGroupId(@Param("salarySobId") Long salarySobId,@Param("salarySobItemGroupIds") Collection salarySobItemGroupIds); + + + void deleteByGroupIds(@Param("groupIds") List needDeleteGroupIds); + +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/salarysob/SalarySobItemMapper.xml b/src/com/engine/salary/mapper/salarysob/SalarySobItemMapper.xml new file mode 100644 index 000000000..03b5a240f --- /dev/null +++ b/src/com/engine/salary/mapper/salarysob/SalarySobItemMapper.xml @@ -0,0 +1,372 @@ + + + + + + + + + + + + + + + + + + + + + + + + t + . + create_time + , t.creator + , t.delete_type + , t.description + , t.formula_id + , t.id + , t.salary_item_id + , t.salary_sob_id + , t.salary_sob_item_group_id + , t.sorted_index + , t.tenant_key + , t.update_time + , t.can_delete + , t.rounding_mode + , t.pattern + , t.value_type + , t.default_value + , t.item_hide + + + + + + + + + + + + + + + + + UPDATE hrsa_salary_sob_item + + create_time=#{createTime}, + creator=#{creator}, + delete_type=#{deleteType}, + description=#{description}, + formula_id=#{formulaId}, + salary_item_id=#{salaryItemId}, + salary_sob_id=#{salarySobId}, + salary_sob_item_group_id=#{salarySobItemGroupId}, + sorted_index=#{sortedIndex}, + tenant_key=#{tenantKey}, + update_time=#{updateTime}, + can_delete=#{canDelete}, + rounding_mode=#{roundingMode}, + pattern=#{pattern}, + value_type=#{valueType}, + item_hide=#{itemHide}, + default_value=#{defaultValue}, + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_salary_sob_item + + + create_time=#{createTime}, + + + creator=#{creator}, + + + delete_type=#{deleteType}, + + + description=#{description}, + + + formula_id=#{formulaId}, + + + salary_item_id=#{salaryItemId}, + + + salary_sob_id=#{salarySobId}, + + + salary_sob_item_group_id=#{salarySobItemGroupId}, + + + sorted_index=#{sortedIndex}, + + + tenant_key=#{tenantKey}, + + + update_time=#{updateTime}, + + + can_delete=#{canDelete}, + + + rounding_mode=#{roundingMode}, + + + pattern=#{pattern}, + + + value_type=#{valueType}, + + + default_value=#{defaultValue}, + + + item_hide=#{itemHide}, + + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_salary_sob_item + SET delete_type=1 + WHERE id = #{id} + AND delete_type = 0 + + + + + DELETE FROM hrsa_salary_item_hide + WHERE delete_type = 0 + AND salary_sob_id IN + + #{salarySobId} + + + + + + UPDATE hrsa_salary_sob_item + SET delete_type = 1 + WHERE delete_type = 0 + AND salary_sob_id IN + + #{salarySobId} + + + + + UPDATE hrsa_salary_sob_item + SET delete_type = 1 + WHERE delete_type = 0 + AND id IN + + #{id} + + + + + INSERT INTO hrsa_salary_sob_item(salary_sob_id, salary_item_id, salary_sob_item_group_id, formula_id, + sorted_index, description, create_time, update_time, creator, delete_type, tenant_key,can_delete,rounding_mode,pattern,value_type,item_hide,default_value) + VALUES + + ( + #{item.salarySobId}, + #{item.salaryItemId}, + #{item.salarySobItemGroupId}, + #{item.formulaId}, + #{item.sortedIndex}, + #{item.description}, + #{item.createTime}, + #{item.updateTime}, + #{item.creator}, + #{item.deleteType}, + #{item.tenantKey}, + #{item.canDelete}, + #{item.roundingMode}, + #{item.pattern}, + #{item.valueType}, + #{item.itemHide}, + #{item.defaultValue} + ) + + + + INSERT INTO hrsa_salary_sob_item( salary_sob_id, salary_item_id, salary_sob_item_group_id, formula_id, + sorted_index, description, create_time, update_time, creator, delete_type, tenant_key,can_delete,rounding_mode,pattern,value_type,item_hide,default_value) + + + select + #{item.salarySobId,jdbcType=DOUBLE}, + #{item.salaryItemId,jdbcType=DOUBLE}, + #{item.salarySobItemGroupId,jdbcType=DOUBLE}, + #{item.formulaId,jdbcType=DOUBLE}, + #{item.sortedIndex,jdbcType=INTEGER}, + #{item.description,jdbcType=VARCHAR}, + #{item.createTime,jdbcType=DATE}, + #{item.updateTime,jdbcType=DATE}, + #{item.creator,jdbcType=DOUBLE}, + #{item.deleteType,jdbcType=INTEGER}, + #{item.tenantKey,jdbcType=VARCHAR}, + #{item.canDelete,jdbcType=INTEGER}, + #{item.roundingMode,jdbcType=INTEGER}, + #{item.pattern,jdbcType=INTEGER}, + #{item.valueType,jdbcType=INTEGER}, + #{item.itemHide,jdbcType=DOUBLE}, + #{item.defaultValue,jdbcType=VARCHAR} + from dual + + + + + INSERT INTO hrsa_salary_sob_item( salary_sob_id, salary_item_id, salary_sob_item_group_id, formula_id, + sorted_index, description, create_time, update_time, creator, delete_type, tenant_key,can_delete,rounding_mode,pattern,value_type,item_hide,default_value) + VALUES + ( + #{item.salarySobId}, + #{item.salaryItemId}, + #{item.salarySobItemGroupId}, + #{item.formulaId}, + #{item.sortedIndex}, + #{item.description}, + #{item.createTime}, + #{item.updateTime}, + #{item.creator}, + #{item.deleteType}, + #{item.tenantKey}, + #{item.canDelete}, + #{item.roundingMode}, + #{item.pattern}, + #{item.valueType}, + #{item.itemHide}, + #{item.defaultValue} + ) + + + + + + UPDATE hrsa_salary_sob_item + SET delete_type = 1 + WHERE delete_type = 0 + AND salary_sob_item_group_id IN + + #{groupId} + + + + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/salarysob/SalarySobMapper.java b/src/com/engine/salary/mapper/salarysob/SalarySobMapper.java new file mode 100644 index 000000000..8ed87d861 --- /dev/null +++ b/src/com/engine/salary/mapper/salarysob/SalarySobMapper.java @@ -0,0 +1,61 @@ +package com.engine.salary.mapper.salarysob; + +import com.engine.salary.entity.salarysob.po.SalarySobPO; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; + +public interface SalarySobMapper { + + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + /** + * 条件查询 + * + * @return 返回集合,没有返回空List + */ + List listSome(SalarySobPO SalarySobPO); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + SalarySobPO getById(Long id); + + /** + * 新增,忽略null字段 + * + * @param SalarySobPO 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(SalarySobPO SalarySobPO); + + + /** + * 修改,忽略null字段 + * + * @param SalarySobPO 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(SalarySobPO SalarySobPO); + + void deleteByIds(@Param("ids") Collection ids); + + List listByParam(@Param("param") SalarySobPO SalarySobPO); + + List listByName(SalarySobPO build); + + + List listByTaxAgentId(Long taxAgentId); + + List listByTaxAgentIds(@Param("taxAgentIds") List taxAgentIds); +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/salarysob/SalarySobMapper.xml b/src/com/engine/salary/mapper/salarysob/SalarySobMapper.xml new file mode 100644 index 000000000..dc81cec68 --- /dev/null +++ b/src/com/engine/salary/mapper/salarysob/SalarySobMapper.xml @@ -0,0 +1,541 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + t + . + id + , t.name + , t.income_category + , t.salary_cycle_type + , t.salary_cycle_from_day + , t.tax_cycle_type + , t.attend_cycle_type + , t.attend_cycle_from_day + , t.social_security_cycle_type + , t.disable + , t.description + , t.creator + , t.create_time + , t.update_time + , t.delete_type + , t.tenant_key + , t.tax_agent_id + , l.tax_agent_id as taxAgentId + + + + + + + + + + + + + + + INSERT INTO hrsa_salary_sob + + + + id, + + + name, + + + income_category, + + + salary_cycle_type, + + + salary_cycle_from_day, + + + tax_cycle_type, + + + attend_cycle_type, + + + attend_cycle_from_day, + + + social_security_cycle_type, + + + disable, + + + description, + + + creator, + + + create_time, + + + update_time, + + + delete_type, + + + tenant_key, + + + tax_agent_id, + + + + + #{id}, + + + #{name}, + + + #{incomeCategory}, + + + #{salaryCycleType}, + + + #{salaryCycleFromDay}, + + + #{taxCycleType}, + + + #{attendCycleType}, + + + #{attendCycleFromDay}, + + + #{socialSecurityCycleType}, + + + #{disable}, + + + #{description}, + + + #{creator}, + + + #{createTime}, + + + #{updateTime}, + + + #{deleteType}, + + + #{tenantKey}, + + + #{taxAgentId}, + + + + + + + + + select hrsa_salary_sob_id.currval from dual + + + INSERT INTO hrsa_salary_sob + + + + id, + + + name, + + + income_category, + + + salary_cycle_type, + + + salary_cycle_from_day, + + + tax_cycle_type, + + + attend_cycle_type, + + + attend_cycle_from_day, + + + social_security_cycle_type, + + + disable, + + + description, + + + creator, + + + create_time, + + + update_time, + + + delete_type, + + + tenant_key, + + + tax_agent_id, + + + + + #{id}, + + + #{name}, + + + #{incomeCategory}, + + + #{salaryCycleType}, + + + #{salaryCycleFromDay}, + + + #{taxCycleType}, + + + #{attendCycleType}, + + + #{attendCycleFromDay}, + + + #{socialSecurityCycleType}, + + + #{disable}, + + + #{description}, + + + #{creator}, + + + #{createTime}, + + + #{updateTime}, + + + #{deleteType}, + + + #{tenantKey}, + + + #{taxAgentId}, + + + + + + + UPDATE hrsa_salary_sob + + name=#{name}, + income_category=#{incomeCategory}, + salary_cycle_type=#{salaryCycleType}, + salary_cycle_from_day=#{salaryCycleFromDay}, + tax_cycle_type=#{taxCycleType}, + attend_cycle_type=#{attendCycleType}, + attend_cycle_from_day=#{attendCycleFromDay}, + social_security_cycle_type=#{socialSecurityCycleType}, + disable=#{disable}, + description=#{description}, + creator=#{creator}, + create_time=#{createTime}, + update_time=#{updateTime}, + delete_type=#{deleteType}, + tenant_key=#{tenantKey}, + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_salary_sob + + + name=#{name}, + + + income_category=#{incomeCategory}, + + + salary_cycle_type=#{salaryCycleType}, + + + salary_cycle_from_day=#{salaryCycleFromDay}, + + + tax_cycle_type=#{taxCycleType}, + + + attend_cycle_type=#{attendCycleType}, + + + attend_cycle_from_day=#{attendCycleFromDay}, + + + social_security_cycle_type=#{socialSecurityCycleType}, + + + disable=#{disable}, + + + description=#{description}, + + + creator=#{creator}, + + + create_time=#{createTime}, + + + update_time=#{updateTime}, + + + delete_type=#{deleteType}, + + + tenant_key=#{tenantKey}, + + + tax_agent_id=#{taxAgentId}, + + + WHERE id = #{id} AND delete_type = 0 + + + + + UPDATE hrsa_salary_sob + SET delete_type = 1 + WHERE delete_type = 0 + AND id IN + + #{id} + + + + + + + + + AND t.name like CONCAT('%',#{param.name},'%') + + + + + AND t.name like '%'||#{param.name}||'%' + + + + + AND t.name like '%'+#{param.name}+'%' + + + + + + + AND t.name like CONCAT('%',#{name},'%') + + + + + AND t.name like '%'||#{name}||'%' + + + + + AND t.name like '%'+#{name}+'%' + + + + + + + + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/salarysob/SalarySobRangeMapper.java b/src/com/engine/salary/mapper/salarysob/SalarySobRangeMapper.java new file mode 100644 index 000000000..c442f6b69 --- /dev/null +++ b/src/com/engine/salary/mapper/salarysob/SalarySobRangeMapper.java @@ -0,0 +1,93 @@ +package com.engine.salary.mapper.salarysob; + +import com.engine.salary.entity.salarysob.param.SalarySobRangeEmpQueryParam; +import com.engine.salary.entity.salarysob.po.SalarySobRangePO; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; + +public interface SalarySobRangeMapper { + + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + /** + * 条件查询 + * + * @return 返回集合,没有返回空List + */ + List listSome(SalarySobRangePO salarySobRange); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + SalarySobRangePO getById(Long id); + + /** + * 新增,忽略null字段 + * + * @param salarySobRange 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(SalarySobRangePO salarySobRange); + + /** + * 修改,修改所有字段 + * + * @param salarySobRange 修改的记录 + * @return 返回影响行数 + */ + int update(SalarySobRangePO salarySobRange); + + /** + * 修改,忽略null字段 + * + * @param salarySobRange 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(SalarySobRangePO salarySobRange); + + /** + * 删除记录 + * + * @param salarySobRange 待删除的记录 + * @return 返回影响行数 + */ + int delete(SalarySobRangePO salarySobRange); + + + /** + * 批量保存 + */ + void batchInsert(@Param("collection") Collection salarySobRanges); + + /** + * 按薪资账套id删除 + */ + void deleteBySalarySobIds(@Param("salarySobIds") Collection salarySobIds); + + /** + * 按照主键id删除 + */ + void deleteByIds(@Param("ids") Collection ids); + + /** + * 获取薪资账套的适用人员 + */ + List listEmployeeIds(@Param("params") Collection params); + + /** + * 更新人员状态使用逗号分割 + * @param item + */ + void updateEmployeeStatuses(@Param("param") SalarySobRangePO item); +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/salarysob/SalarySobRangeMapper.xml b/src/com/engine/salary/mapper/salarysob/SalarySobRangeMapper.xml new file mode 100644 index 000000000..e05bdf60f --- /dev/null +++ b/src/com/engine/salary/mapper/salarysob/SalarySobRangeMapper.xml @@ -0,0 +1,480 @@ + + + + + + + + + + + + + + + + + + + + + t + . + id + , t.salary_sob_id + , t.target_type + , t.target_id + , t.target + , t.employee_status + , t.include_type + , t.creator + , t.create_time + , t.update_time + , t.delete_type + , t.tenant_key + , t.employee_statuses + + + + + + + + + + + + + + + INSERT INTO hrsa_salary_sob_range + + + + id, + + + salary_sob_id, + + + target_type, + + + target_id, + + + target, + + + employee_status, + + + include_type, + + + creator, + + + create_time, + + + update_time, + + + delete_type, + + + tenant_key, + + + + + #{id}, + + + #{salarySobId}, + + + #{targetType}, + + + #{targetId}, + + + #{target}, + + + #{employeeStatus}, + + + #{includeType}, + + + #{creator}, + + + #{createTime}, + + + #{updateTime}, + + + #{deleteType}, + + + #{tenantKey}, + + + + + + + select hrsa_salary_sob_range_id.currval from dual + + INSERT INTO hrsa_salary_sob_range + + + + id, + + + salary_sob_id, + + + target_type, + + + target_id, + + + target, + + + employee_status, + + + include_type, + + + creator, + + + create_time, + + + update_time, + + + delete_type, + + + tenant_key, + + + + + #{id}, + + + #{salarySobId}, + + + #{targetType}, + + + #{targetId}, + + + #{target}, + + + #{employeeStatus}, + + + #{includeType}, + + + #{creator}, + + + #{createTime}, + + + #{updateTime}, + + + #{deleteType}, + + + #{tenantKey}, + + + + + + + UPDATE hrsa_salary_sob_range + + salary_sob_id=#{salarySobId}, + target_type=#{targetType}, + target_id=#{targetId}, + target=#{target}, + employee_status=#{employeeStatus}, + include_type=#{includeType}, + creator=#{creator}, + create_time=#{createTime}, + update_time=#{updateTime}, + delete_type=#{deleteType}, + tenant_key=#{tenantKey}, + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_salary_sob_range + + + salary_sob_id=#{salarySobId}, + + + target_type=#{targetType}, + + + target_id=#{targetId}, + + + target=#{target}, + + + employee_statuses=#{employeeStatuses}, + + + include_type=#{includeType}, + + + creator=#{creator}, + + + create_time=#{createTime}, + + + update_time=#{updateTime}, + + + delete_type=#{deleteType}, + + + tenant_key=#{tenantKey}, + + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_salary_sob_range + SET delete_type=1 + WHERE id = #{id} + AND delete_type = 0 + + + + + INSERT INTO hrsa_salary_sob_range(salary_sob_id, target_type, target_id,target, employee_status, include_type, + creator, create_time, update_time, delete_type, tenant_key,employee_statuses) + VALUES + + ( + #{item.salarySobId}, + #{item.targetType.value}, + #{item.targetId}, + #{item.target}, + #{item.employeeStatus.value}, + #{item.includeType}, + #{item.creator}, + #{item.createTime}, + #{item.updateTime}, + #{item.deleteType}, + #{item.tenantKey}, + #{item.employeeStatuses} + ) + + + + INSERT INTO hrsa_salary_sob_range(salary_sob_id, target_type, target_id,target, employee_status, include_type, + creator, create_time, update_time, delete_type, tenant_key,employee_statuses) + + + select + #{item.salarySobId,jdbcType=DOUBLE}, + #{item.targetType.value,jdbcType=INTEGER}, + #{item.targetId,jdbcType=DOUBLE}, + #{item.target,jdbcType=VARCHAR}, + #{item.employeeStatus.value,jdbcType=INTEGER}, + #{item.includeType,jdbcType=INTEGER}, + #{item.creator,jdbcType=DOUBLE}, + #{item.createTime,jdbcType=DATE}, + #{item.updateTime,jdbcType=DATE}, + #{item.deleteType,jdbcType=INTEGER}, + #{item.tenantKey,jdbcType=VARCHAR}, + #{item.employeeStatuses,jdbcType=VARCHAR} + from dual + + + + + INSERT INTO hrsa_salary_sob_range( salary_sob_id, target_type, target_id,target, employee_status, include_type, + creator, create_time, update_time, delete_type, tenant_key,employee_statuses) + VALUES + ( + #{item.salarySobId}, + #{item.targetType.value}, + #{item.targetId}, + #{item.target}, + #{item.employeeStatus.value}, + #{item.includeType}, + #{item.creator}, + #{item.createTime}, + #{item.updateTime}, + #{item.deleteType}, + #{item.tenantKey}, + #{item.employeeStatuses} + ) + + + + UPDATE hrsa_salary_sob_range + SET delete_type = 1 + WHERE delete_type = 0 + AND salary_sob_id IN + + #{salarySobId} + + + + + UPDATE hrsa_salary_sob_range + SET delete_type = 1 + WHERE delete_type = 0 + AND id IN + + #{id} + + + + + UPDATE hrsa_salary_sob_range set employee_statuses = #{param.employeeStatuses} WHERE id = #{param.id} + + + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/salarysob/SobTaxLinkMapper.java b/src/com/engine/salary/mapper/salarysob/SobTaxLinkMapper.java new file mode 100644 index 000000000..da9b6b444 --- /dev/null +++ b/src/com/engine/salary/mapper/salarysob/SobTaxLinkMapper.java @@ -0,0 +1,76 @@ +package com.engine.salary.mapper.salarysob; + +import com.engine.salary.entity.salarysob.po.SobTaxLinkPO; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; + +public interface SobTaxLinkMapper { + + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + /** + * 条件查询 + * + * @return 返回集合,没有返回空List + */ + List listSome(SobTaxLinkPO sobTaxLink); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + SobTaxLinkPO getById(Long id); + + /** + * 新增,忽略null字段 + * + * @param sobTaxLink 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(SobTaxLinkPO sobTaxLink); + + /** + * 修改,修改所有字段 + * + * @param sobTaxLink 修改的记录 + * @return 返回影响行数 + */ + int update(SobTaxLinkPO sobTaxLink); + + /** + * 修改,忽略null字段 + * + * @param sobTaxLink 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(SobTaxLinkPO sobTaxLink); + + /** + * 删除记录 + * + * @param sobTaxLink 待删除的记录 + * @return 返回影响行数 + */ + int delete(SobTaxLinkPO sobTaxLink); + + /** + * 批量删除记录 + * @param ids 主键id集合 + */ + void deleteByIds(@Param("ids") Collection ids); + + void deleteBySobId(Long id); + + int count(); + +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/salarysob/SobTaxLinkMapper.xml b/src/com/engine/salary/mapper/salarysob/SobTaxLinkMapper.xml new file mode 100644 index 000000000..8fe16ab03 --- /dev/null +++ b/src/com/engine/salary/mapper/salarysob/SobTaxLinkMapper.xml @@ -0,0 +1,226 @@ + + + + + + + + + + + + + + + + + t + . + create_time + , t.creator + , t.delete_type + , t.id + , t.sob_id + , t.tax_agent_id + , t.tenant_key + , t.update_time + + + + + + + + + + + + + + + INSERT INTO hrsa_sob_tax_link + + + + create_time, + + + creator, + + + delete_type, + + + id, + + + sob_id, + + + tax_agent_id, + + + tenant_key, + + + update_time, + + + + + #{createTime}, + + + #{creator}, + + + #{deleteType}, + + + #{id}, + + + #{sobId}, + + + #{taxAgentId}, + + + #{tenantKey}, + + + #{updateTime}, + + + + + + + + UPDATE hrsa_sob_tax_link + + create_time=#{createTime}, + creator=#{creator}, + delete_type=#{deleteType}, + sob_id=#{sobId}, + tax_agent_id=#{taxAgentId}, + tenant_key=#{tenantKey}, + update_time=#{updateTime}, + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_sob_tax_link + + + create_time=#{createTime}, + + + creator=#{creator}, + + + delete_type=#{deleteType}, + + + sob_id=#{sobId}, + + + tax_agent_id=#{taxAgentId}, + + + tenant_key=#{tenantKey}, + + + update_time=#{updateTime}, + + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_sob_tax_link + SET delete_type=1 + WHERE id = #{id} + AND delete_type = 0 + + + + UPDATE hrsa_sob_tax_link + SET delete_type = 1 + WHERE delete_type = 0 + AND id IN + + #{id} + + + + + UPDATE hrsa_sob_tax_link + SET delete_type = 1 + WHERE delete_type = 0 + AND sob_id=#{sobId} + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/setting/PageLinkMapper.java b/src/com/engine/salary/mapper/setting/PageLinkMapper.java new file mode 100644 index 000000000..c0d806049 --- /dev/null +++ b/src/com/engine/salary/mapper/setting/PageLinkMapper.java @@ -0,0 +1,73 @@ +package com.engine.salary.mapper.setting; + +import com.engine.salary.entity.setting.po.PageLinkPO; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; + +public interface PageLinkMapper { + + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + /** + * 条件查询 + * + * @return 返回集合,没有返回空List + */ + List listSome(PageLinkPO pageLink); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + PageLinkPO getById(Long id); + + /** + * 新增,忽略null字段 + * + * @param pageLink 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(PageLinkPO pageLink); + + + /** + * 修改,修改所有字段 + * + * @param pageLink 修改的记录 + * @return 返回影响行数 + */ + int update(PageLinkPO pageLink); + + /** + * 修改,忽略null字段 + * + * @param pageLink 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(PageLinkPO pageLink); + + /** + * 删除记录 + * + * @param pageLink 待删除的记录 + * @return 返回影响行数 + */ + int delete(PageLinkPO pageLink); + + /** + * 批量删除记录 + * @param ids 主键id集合 + */ + void deleteByIds(@Param("ids") Collection ids); + +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/setting/PageLinkMapper.xml b/src/com/engine/salary/mapper/setting/PageLinkMapper.xml new file mode 100644 index 000000000..ec66fde24 --- /dev/null +++ b/src/com/engine/salary/mapper/setting/PageLinkMapper.xml @@ -0,0 +1,224 @@ + + + + + + + + + + + + + + + + + + t + . + create_time + , t.creator + , t.delete_type + , t.employee_id + , t.id + , t.page + , t.template_id + , t.tenant_key + , t.update_time + + + + + + + + + + + + + + + INSERT INTO hrsa_page_link + + + + create_time, + + + creator, + + + delete_type, + + + employee_id, + + + id, + + + page, + + + template_id, + + + tenant_key, + + + update_time, + + + + + #{createTime}, + + + #{creator}, + + + #{deleteType}, + + + #{employeeId}, + + + #{id}, + + + #{page}, + + + #{templateId}, + + + #{tenantKey}, + + + #{updateTime}, + + + + + + + + UPDATE hrsa_page_link + + create_time=#{createTime}, + creator=#{creator}, + delete_type=#{deleteType}, + employee_id=#{employeeId}, + page=#{page}, + template_id=#{templateId}, + tenant_key=#{tenantKey}, + update_time=#{updateTime}, + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_page_link + + + create_time=#{createTime}, + + + creator=#{creator}, + + + delete_type=#{deleteType}, + + + employee_id=#{employeeId}, + + + page=#{page}, + + + template_id=#{templateId}, + + + tenant_key=#{tenantKey}, + + + update_time=#{updateTime}, + + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_page_link + SET delete_type=1 + WHERE id = #{id} + AND delete_type = 0 + + + + UPDATE hrsa_page_link + SET delete_type = 1 + WHERE delete_type = 0 + AND id IN + + #{id} + + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/setting/PageListSettingMapper.java b/src/com/engine/salary/mapper/setting/PageListSettingMapper.java new file mode 100644 index 000000000..2bcdd1f88 --- /dev/null +++ b/src/com/engine/salary/mapper/setting/PageListSettingMapper.java @@ -0,0 +1,78 @@ +package com.engine.salary.mapper.setting; + +import com.engine.salary.entity.setting.po.PageListSettingPO; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; + +public interface PageListSettingMapper { + + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + /** + * 条件查询 + * + * @return 返回集合,没有返回空List + */ + List listSome(PageListSettingPO pageListSetting); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + PageListSettingPO getById(Long id); + + /** + * 新增,忽略null字段 + * + * @param pageListSetting 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(PageListSettingPO pageListSetting); + + /** + * 修改,修改所有字段 + * + * @param pageListSetting 修改的记录 + * @return 返回影响行数 + */ + int update(PageListSettingPO pageListSetting); + + /** + * 修改,忽略null字段 + * + * @param pageListSetting 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(PageListSettingPO pageListSetting); + + /** + * 删除记录 + * + * @param pageListSetting 待删除的记录 + * @return 返回影响行数 + */ + int delete(PageListSettingPO pageListSetting); + + /** + * 批量删除记录 + * + * @param ids 主键id集合 + */ + void deleteByIds(@Param("ids") Collection ids); + + //获取页面默认配置 + PageListSettingPO getByPage(@Param("page") String page, @Param("defaultSetting") Integer defaultSetting, @Param("creator") Long creator); + + //获取页面配置模板 + List getTemplatesByPage(String page); +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/setting/PageListSettingMapper.xml b/src/com/engine/salary/mapper/setting/PageListSettingMapper.xml new file mode 100644 index 000000000..ed8f14bb4 --- /dev/null +++ b/src/com/engine/salary/mapper/setting/PageListSettingMapper.xml @@ -0,0 +1,242 @@ + + + + + + + + + + + + + + + + + + t + . + create_time + , t.creator + , t.delete_type + , t.id + , t.page + , t.setting + , t.tenant_key + , t.update_time + , t.default_setting + + + + + + + + + + + + + + + INSERT INTO hrsa_page_list_setting + + + + create_time, + + + creator, + + + delete_type, + + + id, + + + page, + + + setting, + + + tenant_key, + + + update_time, + + + default_setting, + + + + + #{createTime}, + + + #{creator}, + + + #{deleteType}, + + + #{id}, + + + #{page}, + + + #{setting, jdbcType=ARRAY, typeHandler=com.engine.salary.handle.SalaryListTypeHandler}, + + + #{tenantKey}, + + + #{updateTime}, + + + #{defaultSetting}, + + + + + + + + UPDATE hrsa_page_list_setting + + create_time=#{createTime}, + creator=#{creator}, + delete_type=#{deleteType}, + page=#{page}, + setting=#{setting, jdbcType=ARRAY, typeHandler=com.engine.salary.handle.SalaryListTypeHandler}, + tenant_key=#{tenantKey}, + update_time=#{updateTime}, + default_setting=#{defaultSetting}, + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_page_list_setting + + + create_time=#{createTime}, + + + creator=#{creator}, + + + delete_type=#{deleteType}, + + + page=#{page}, + + + setting=#{setting, jdbcType=ARRAY, typeHandler=com.engine.salary.handle.SalaryListTypeHandler}, + + + tenant_key=#{tenantKey}, + + + update_time=#{updateTime}, + + + default_setting=#{defaultSetting}, + + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_page_list_setting + SET delete_type=1 + WHERE id = #{id} + AND delete_type = 0 + + + + UPDATE hrsa_page_list_setting + SET delete_type = 1 + WHERE delete_type = 0 + AND id IN + + #{id} + + + + + + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/setting/PageListTemplateMapper.java b/src/com/engine/salary/mapper/setting/PageListTemplateMapper.java new file mode 100644 index 000000000..b729cd64e --- /dev/null +++ b/src/com/engine/salary/mapper/setting/PageListTemplateMapper.java @@ -0,0 +1,73 @@ +package com.engine.salary.mapper.setting; + +import com.engine.salary.entity.setting.po.PageListTemplatePO; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; + +public interface PageListTemplateMapper { + + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + /** + * 条件查询 + * + * @return 返回集合,没有返回空List + */ + List listSome(PageListTemplatePO pageListTemplate); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + PageListTemplatePO getById(Long id); + + /** + * 新增,忽略null字段 + * + * @param pageListTemplate 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(PageListTemplatePO pageListTemplate); + + + /** + * 修改,修改所有字段 + * + * @param pageListTemplate 修改的记录 + * @return 返回影响行数 + */ + int update(PageListTemplatePO pageListTemplate); + + /** + * 修改,忽略null字段 + * + * @param pageListTemplate 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(PageListTemplatePO pageListTemplate); + + /** + * 删除记录 + * + * @param pageListTemplate 待删除的记录 + * @return 返回影响行数 + */ + int delete(PageListTemplatePO pageListTemplate); + + /** + * 批量删除记录 + * @param ids 主键id集合 + */ + void deleteByIds(@Param("ids") Collection ids); + +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/setting/PageListTemplateMapper.xml b/src/com/engine/salary/mapper/setting/PageListTemplateMapper.xml new file mode 100644 index 000000000..e24131e5f --- /dev/null +++ b/src/com/engine/salary/mapper/setting/PageListTemplateMapper.xml @@ -0,0 +1,279 @@ + + + + + + + + + + + + + + + + + + + + + + t + . + create_time + , t.creator + , t.delete_type + , t.id + , t.limit_ids + , t.name + , t.page + , t.setting + , t.shared_type + , t.system_type + , t.tenant_key + , t.update_time + , t.file_id + + + + + + + + + + + + + + + INSERT INTO hrsa_page_list_template + + + + create_time, + + + creator, + + + delete_type, + + + id, + + + limit_ids, + + + name, + + + page, + + + setting, + + + shared_type, + + + system_type, + + + tenant_key, + + + update_time, + + + file_id, + + + + + #{createTime}, + + + #{creator}, + + + #{deleteType}, + + + #{id}, + + + #{limitIds, jdbcType=ARRAY, typeHandler=com.engine.salary.handle.SalaryListTypeHandler}, + + + #{name}, + + + #{page}, + + + #{setting , jdbcType=ARRAY, typeHandler=com.engine.salary.handle.SalaryListTypeHandler}, + + + #{sharedType}, + + + #{systemType}, + + + #{tenantKey}, + + + #{updateTime}, + + + #{fileId}, + + + + + + + UPDATE hrsa_page_list_template + + create_time=#{createTime}, + creator=#{creator}, + delete_type=#{deleteType}, + limit_ids=#{limitIds, jdbcType=ARRAY, typeHandler=com.engine.salary.handle.SalaryListTypeHandler}, + name=#{name}, + page=#{page}, + setting=#{setting, jdbcType=ARRAY, typeHandler=com.engine.salary.handle.SalaryListTypeHandler}, + shared_type=#{sharedType}, + system_type=#{systemType}, + tenant_key=#{tenantKey}, + update_time=#{updateTime}, + file_id=#{fileId}, + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_page_list_template + + + create_time=#{createTime}, + + + creator=#{creator}, + + + delete_type=#{deleteType}, + + + limit_ids=#{limitIds, jdbcType=ARRAY, typeHandler=com.engine.salary.handle.SalaryListTypeHandler}, + + + name=#{name}, + + + page=#{page}, + + + setting=#{setting, jdbcType=ARRAY, typeHandler=com.engine.salary.handle.SalaryListTypeHandler}, + + + shared_type=#{sharedType}, + + + system_type=#{systemType}, + + + tenant_key=#{tenantKey}, + + + update_time=#{updateTime}, + + file_id=#{fileId}, + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_page_list_template + SET delete_type=1 + WHERE id = #{id} + AND delete_type = 0 + + + + UPDATE hrsa_page_list_template + SET delete_type = 1 + WHERE delete_type = 0 + AND id IN + + #{id} + + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/siaccount/ExcelInsuranceDetailMapper.java b/src/com/engine/salary/mapper/siaccount/ExcelInsuranceDetailMapper.java new file mode 100644 index 000000000..1129a814f --- /dev/null +++ b/src/com/engine/salary/mapper/siaccount/ExcelInsuranceDetailMapper.java @@ -0,0 +1,43 @@ +package com.engine.salary.mapper.siaccount; + +import com.engine.salary.entity.siaccount.po.ExcelInsuranceDetailPO; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; + +/** + * @author songyang + */ +public interface ExcelInsuranceDetailMapper { + + /** + * 查询对比数据 + * @param billMonth 账单月份 + * @param paymentOrganization 个税扣缴义务人 + * @param employeeId 人员id + * @return + */ + List queryCompareList(@Param("billMonth") String billMonth, @Param("paymentOrganization") Long paymentOrganization, @Param("employeeId") Long employeeId); + + /** + * 根据id删除 + * + * @param id + */ + void deleteById(@Param("id") Long id); + + /** + * 根据id批量删除 + */ + void batchDelByIds(@Param("ids") Collection ids); + + /** + * 批量保存 + */ + void batchSave(@Param("accounts") Collection accounts); + + List listAll(); + + void updateBatchSelective(@Param("list")List excelInsuranceDetailPOS); +} diff --git a/src/com/engine/salary/mapper/siaccount/ExcelInsuranceDetailMapper.xml b/src/com/engine/salary/mapper/siaccount/ExcelInsuranceDetailMapper.xml new file mode 100644 index 000000000..53c1265b1 --- /dev/null +++ b/src/com/engine/salary/mapper/siaccount/ExcelInsuranceDetailMapper.xml @@ -0,0 +1,593 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + t + . + id + , t.employee_id + , e.status as employee_status + , t.bill_month + , t.bill_status + , t.payment_status + , t.supplementary_month + , t.supplementary_projects + , t.resource_from + , t.social_pay_org + , t.social_account + , t.fund_pay_org + , t.fund_account + , t.supplement_fund_account + , t.other_pay_org + , t.social_scheme_id + , t.social_payment_base_string + , t.social_payment_com_base_string + , t.fund_scheme_id + , t.fund_payment_base_string + , t.fund_payment_com_base_string + , t.other_scheme_id + , t.other_payment_base_string + , t.other_payment_com_base_string + , t.social_per_json + , t.social_per_sum + , t.fund_per_json + , t.fund_per_sum + , t.other_per_json + , t.other_per_sum + , t.per_sum + , t.social_com_json + , t.social_com_sum + , t.fund_com_json + , t.fund_com_sum + , t.other_com_json + , t.other_com_sum + , t.com_sum + , t.social_sum + , t.fund_sum + , t.other_sum + , t.total + , t.creator + , t.delete_type + , t.create_time + , t.update_time + , t.tenant_key + , t.payment_organization + + + + + AND + t.bill_month = #{param.billMonth} + + + AND + t.payment_status = #{param.paymentStatus} + + + AND + t.payment_organization = #{param.paymentOrganization} + + + + + update hrsa_excel_bill_detail + + + + + + when id = #{item.id} then #{item.socialPaymentComBaseString} + + + + + + + when id = #{item.id} then #{item.fundPaymentComBaseString} + + + + + + + when id = #{item.id} then #{item.otherPaymentComBaseString} + + + + + + + when id = #{item.id} then #{item.socialPaymentBaseString} + + + + + + + when id = #{item.id} then #{item.fundPaymentBaseString} + + + + + + + when id = #{item.id} then #{item.otherPaymentBaseString} + + + + + + + when id = #{item.id} then #{item.socialPerJson} + + + + + + + when id = #{item.id} then #{item.socialPerSum} + + + + + + + when id = #{item.id} then #{item.fundPerJson} + + + + + + + when id = #{item.id} then #{item.fundPerSum} + + + + + + + when id = #{item.id} then #{item.otherPerJson} + + + + + + + when id = #{item.id} then #{item.otherPerSum} + + + + + + + when id = #{item.id} then #{item.perSum} + + + + + + + when id = #{item.id} then #{item.socialComJson} + + + + + + + when id = #{item.id} then #{item.socialComSum} + + + + + + + when id = #{item.id} then #{item.fundComJson} + + + + + + + when id = #{item.id} then #{item.fundComSum} + + + + + + + when id = #{item.id} then #{item.otherComJson} + + + + + + + when id = #{item.id} then #{item.otherComSum} + + + + + + + when id = #{item.id} then #{item.comSum} + + + + + + + when id = #{item.id} then #{item.socialSum} + + + + + + + when id = #{item.id} then #{item.fundSum} + + + + + + + when id = #{item.id} then #{item.otherSum} + + + + + + + when id = #{item.id} then #{item.total} + + + + + where id in + + #{item.id} + + + + + + + + + UPDATE hrsa_excel_bill_detail + SET delete_type = 1 + WHERE id = #{id} + AND delete_type = 0 + + + + + UPDATE hrsa_excel_bill_detail + SET delete_type = 1 + WHERE delete_type = 0 + + AND id IN + + #{id} + + + + + + + INSERT INTO hrsa_excel_bill_detail + (id,employee_id,bill_month,bill_status,payment_status,supplementary_month,supplementary_projects,resource_from,social_pay_org,social_account,social_scheme_id,social_payment_base_string, + fund_pay_org,fund_account,supplement_fund_account,fund_scheme_id,fund_payment_base_string,other_pay_org,other_scheme_id,other_payment_base_string,social_per_json, + social_per_sum,fund_per_json,fund_per_sum,other_per_json,other_per_sum,per_sum,social_com_json,social_com_sum,fund_com_json,fund_com_sum,other_com_json,other_com_sum, + com_sum,social_sum,fund_sum,other_sum,total,creator,create_time,update_time,delete_type,tenant_key,payment_organization, + social_payment_com_base_string,fund_payment_com_base_string,other_payment_com_base_string) + VALUES + + ( + #{item.id}, + #{item.employeeId}, + #{item.billMonth}, + #{item.billStatus}, + #{item.paymentStatus}, + #{item.supplementaryMonth}, + #{item.supplementaryProjects}, + #{item.resourceFrom}, + #{item.socialPayOrg}, + #{item.socialAccount}, + #{item.socialSchemeId}, + #{item.socialPaymentBaseString}, + #{item.fundPayOrg}, + #{item.fundAccount}, + #{item.supplementFundAccount}, + #{item.fundSchemeId}, + #{item.fundPaymentBaseString}, + #{item.otherPayOrg}, + #{item.otherSchemeId}, + #{item.otherPaymentBaseString}, + #{item.socialPerJson}, + #{item.socialPerSum}, + #{item.fundPerJson}, + #{item.fundPerSum}, + #{item.otherPerJson}, + #{item.otherPerSum}, + #{item.perSum}, + #{item.socialComJson}, + #{item.socialComSum}, + #{item.fundComJson}, + #{item.fundComSum}, + #{item.otherComJson}, + #{item.otherComSum}, + #{item.comSum}, + #{item.socialSum}, + #{item.fundSum}, + #{item.otherSum}, + #{item.total}, + #{item.creator}, + #{item.createTime}, + #{item.updateTime}, + #{item.deleteType}, + #{item.tenantKey}, + #{item.paymentOrganization}, + #{item.socialPaymentComBaseString}, + #{item.fundPaymentComBaseString}, + #{item.otherPaymentComBaseString} + ) + + + + INSERT INTO hrsa_excel_bill_detail + (id,employee_id,bill_month,bill_status,payment_status,supplementary_month,supplementary_projects,resource_from,social_pay_org,social_account,social_scheme_id,social_payment_base_string, + fund_pay_org,fund_account,supplement_fund_account,fund_scheme_id,fund_payment_base_string,other_pay_org,other_scheme_id,other_payment_base_string,social_per_json, + social_per_sum,fund_per_json,fund_per_sum,other_per_json,other_per_sum,per_sum,social_com_json,social_com_sum,fund_com_json,fund_com_sum,other_com_json,other_com_sum, + com_sum,social_sum,fund_sum,other_sum,total,creator,create_time,update_time,delete_type,tenant_key,payment_organization, + social_payment_com_base_string,fund_payment_com_base_string,other_payment_com_base_string) + + select + #{item.id,jdbcType=DOUBLE}, + #{item.employeeId,jdbcType=DOUBLE}, + #{item.billMonth,jdbcType=VARCHAR}, + #{item.billStatus,jdbcType=INTEGER}, + #{item.paymentStatus,jdbcType=INTEGER}, + #{item.supplementaryMonth,jdbcType=VARCHAR}, + #{item.supplementaryProjects,jdbcType=VARCHAR}, + #{item.resourceFrom,jdbcType=INTEGER}, + #{item.socialPayOrg,jdbcType=DOUBLE}, + #{item.socialAccount,jdbcType=VARCHAR}, + #{item.socialSchemeId,jdbcType=DOUBLE}, + #{item.socialPaymentBaseString,jdbcType=VARCHAR}, + #{item.fundPayOrg,jdbcType=DOUBLE}, + #{item.fundAccount,jdbcType=VARCHAR}, + #{item.supplementFundAccount,jdbcType=VARCHAR}, + #{item.fundSchemeId,jdbcType=DOUBLE}, + #{item.fundPaymentBaseString,jdbcType=VARCHAR}, + #{item.otherPayOrg,jdbcType=DOUBLE}, + #{item.otherSchemeId,jdbcType=DOUBLE}, + #{item.otherPaymentBaseString,jdbcType=VARCHAR}, + #{item.socialPerJson,jdbcType=VARCHAR}, + #{item.socialPerSum,jdbcType=VARCHAR}, + #{item.fundPerJson,jdbcType=VARCHAR}, + #{item.fundPerSum,jdbcType=VARCHAR}, + #{item.otherPerJson,jdbcType=VARCHAR}, + #{item.otherPerSum,jdbcType=VARCHAR}, + #{item.perSum,jdbcType=VARCHAR}, + #{item.socialComJson,jdbcType=VARCHAR}, + #{item.socialComSum,jdbcType=VARCHAR}, + #{item.fundComJson,jdbcType=VARCHAR}, + #{item.fundComSum,jdbcType=VARCHAR}, + #{item.otherComJson,jdbcType=VARCHAR}, + #{item.otherComSum,jdbcType=VARCHAR}, + #{item.comSum,jdbcType=VARCHAR}, + #{item.socialSum,jdbcType=VARCHAR}, + #{item.fundSum,jdbcType=VARCHAR}, + #{item.otherSum,jdbcType=VARCHAR}, + #{item.total,jdbcType=VARCHAR}, + #{item.creator,jdbcType=DOUBLE}, + #{item.createTime}, + #{item.updateTime}, + #{item.deleteType}, + #{item.tenantKey,jdbcType=VARCHAR}, + #{item.paymentOrganization,jdbcType=DOUBLE}, + #{item.socialPaymentComBaseString,jdbcType=VARCHAR}, + #{item.fundPaymentComBaseString,jdbcType=VARCHAR}, + #{item.otherPaymentComBaseString,jdbcType=VARCHAR} + from dual + + + + + INSERT INTO hrsa_excel_bill_detail + (id,employee_id,bill_month,bill_status,payment_status,supplementary_month,supplementary_projects,resource_from,social_pay_org,social_account,social_scheme_id,social_payment_base_string, + fund_pay_org,fund_account,supplement_fund_account,fund_scheme_id,fund_payment_base_string,other_pay_org,other_scheme_id,other_payment_base_string,social_per_json, + social_per_sum,fund_per_json,fund_per_sum,other_per_json,other_per_sum,per_sum,social_com_json,social_com_sum,fund_com_json,fund_com_sum,other_com_json,other_com_sum, + com_sum,social_sum,fund_sum,other_sum,total,creator,create_time,update_time,delete_type,tenant_key,payment_organization, + social_payment_com_base_string,fund_payment_com_base_string,other_payment_com_base_string) + VALUES + ( + #{item.id}, + #{item.employeeId}, + #{item.billMonth}, + #{item.billStatus}, + #{item.paymentStatus}, + #{item.supplementaryMonth}, + #{item.supplementaryProjects}, + #{item.resourceFrom}, + #{item.socialPayOrg}, + #{item.socialAccount}, + #{item.socialSchemeId}, + #{item.socialPaymentBaseString}, + #{item.fundPayOrg}, + #{item.fundAccount}, + #{item.supplementFundAccount}, + #{item.fundSchemeId}, + #{item.fundPaymentBaseString}, + #{item.otherPayOrg}, + #{item.otherSchemeId}, + #{item.otherPaymentBaseString}, + #{item.socialPerJson}, + #{item.socialPerSum}, + #{item.fundPerJson}, + #{item.fundPerSum}, + #{item.otherPerJson}, + #{item.otherPerSum}, + #{item.perSum}, + #{item.socialComJson}, + #{item.socialComSum}, + #{item.fundComJson}, + #{item.fundComSum}, + #{item.otherComJson}, + #{item.otherComSum}, + #{item.comSum}, + #{item.socialSum}, + #{item.fundSum}, + #{item.otherSum}, + #{item.total}, + #{item.creator}, + #{item.createTime}, + #{item.updateTime}, + #{item.deleteType}, + #{item.tenantKey}, + #{item.paymentOrganization}, + #{item.socialPaymentComBaseString}, + #{item.fundPaymentComBaseString}, + #{item.otherPaymentComBaseString} + ) + + + + + + + AND e.lastname like CONCAT('%',#{userName},'%') + + + + + + AND e.lastname like '%'||#{userName}||'%' + + + + + + AND e.lastname like '%'+#{userName}+'%' + + + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/siaccount/InsuranceAccountBatchMapper.java b/src/com/engine/salary/mapper/siaccount/InsuranceAccountBatchMapper.java new file mode 100644 index 000000000..7a183297d --- /dev/null +++ b/src/com/engine/salary/mapper/siaccount/InsuranceAccountBatchMapper.java @@ -0,0 +1,70 @@ +package com.engine.salary.mapper.siaccount; + +import com.engine.salary.entity.siaccount.param.InsuranceAccountBatchParam; +import com.engine.salary.entity.siaccount.po.InsuranceAccountBatchPO; +import com.engine.salary.entity.siarchives.po.InsuranceArchivesOtherSchemePO; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * @Author weaver_cl + * + * @Date 2022/4/11 + * @Version V1.0 + **/ +public interface InsuranceAccountBatchMapper { + + /** + * 查询福利台账列表 + * @param queryParam + * @return + */ + List list(@Param("param")InsuranceAccountBatchParam queryParam); + + /** + * 根据账单月份查询 + * @param billMonth + * @return + */ + InsuranceAccountBatchPO getByBillMonth(@Param("billMonth") String billMonth,@Param("paymentOrganization") Long paymentOrganization); + + /** + * 插入 + * @param insuranceAccountBatchPO + */ + void insert(InsuranceAccountBatchPO insuranceAccountBatchPO); + + + + /** + * 根据主键删除 + * @param id + */ + void deleteById(@Param("id") Long id); + + + /** + * 更新 + * @param pos + */ + void updateById(InsuranceAccountBatchPO pos); + + InsuranceAccountBatchPO getById(@Param("id") Long id); + + + /** + * + * @param billMonth + * @param billStatus + * @return + */ + InsuranceAccountBatchPO getByBillStatus(@Param("billMonth") String billMonth,@Param("billStatus")Integer billStatus, @Param("paymentOrganization") Long paymentOrganization); + + + List listByTimeRange(@Param("minDate") String minDate, @Param("maxDate") String maxDate); + + List listAll(); + + int batchUpdate(@Param("collection") List pos); +} diff --git a/src/com/engine/salary/mapper/siaccount/InsuranceAccountBatchMapper.xml b/src/com/engine/salary/mapper/siaccount/InsuranceAccountBatchMapper.xml new file mode 100644 index 000000000..4b45cb2f3 --- /dev/null +++ b/src/com/engine/salary/mapper/siaccount/InsuranceAccountBatchMapper.xml @@ -0,0 +1,301 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + t + . + id + , t.bill_month + , t.bill_status + , t.social_num + , t.fund_num + , t.other_num + , t.social_pay + , t.fund_pay + , t.other_pay + , t.accountant + , t.remarks + , t.creator + , t.delete_type + , t.create_time + , t.update_time + , t.tenant_key + , t.payment_organization + + + + INSERT INTO hrsa_bill_batch + + bill_month, + bill_status, + social_num, + fund_num, + other_num, + social_pay, + fund_pay, + other_pay, + accountant, + remarks, + creator, + delete_type, + create_time, + update_time, + tenant_key, + payment_organization, + + + #{billMonth}, + #{billStatus}, + #{socialNum}, + #{fundNum}, + #{otherNum}, + #{socialPay}, + #{fundPay}, + #{otherPay}, + #{accountant}, + #{remarks}, + #{creator}, + #{deleteType}, + #{createTime}, + #{updateTime}, + #{tenantKey}, + #{paymentOrganization}, + + + + + + + select nvl(max(id),0)+1 from hrsa_bill_batch + + INSERT INTO hrsa_bill_batch + + bill_month, + bill_status, + social_num, + fund_num, + other_num, + social_pay, + fund_pay, + other_pay, + accountant, + remarks, + creator, + delete_type, + create_time, + update_time, + tenant_key, + payment_organization, + + + #{billMonth}, + #{billStatus}, + #{socialNum}, + #{fundNum}, + #{otherNum}, + #{socialPay}, + #{fundPay}, + #{otherPay}, + #{accountant}, + #{remarks}, + #{creator}, + #{deleteType}, + #{createTime}, + #{updateTime}, + #{tenantKey}, + #{paymentOrganization}, + + + + + + + AND + t.bill_month between #{param.startTime} and #{param.endTime} + + + AND + t.payment_organization = #{param.paymentOrganization} + + + AND + t.payment_organization in + + #{taxAgent} + + + + + + + + + + + + + + + + + + UPDATE hrsa_bill_batch + SET delete_type = 1 + WHERE delete_type = 0 + AND id = #{id} + + + + + UPDATE hrsa_bill_batch + + + accountant=#{accountant}, + + + update_time=#{updateTime}, + + + social_pay=#{socialPay}, + + + social_num=#{socialNum}, + + + fund_num=#{fundNum}, + + + fund_pay=#{fundPay}, + + + other_num=#{otherNum}, + + + other_pay=#{otherPay}, + + + bill_status=#{billStatus} + + + WHERE id = #{id} AND delete_type = 0 + + AND payment_organization = #{paymentOrganization} + + + + + + + + + update hrsa_bill_batch + + + + + when id=#{item.id} then #{item.otherPay} + + + + + + + when id=#{item.id} then #{item.socialPay} + + + + + + + when id=#{item.id} then #{item.fundPay} + + + + + + + when id=#{item.id} then #{item.deleteType} + + + + + where + id in + + #{item.id} + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/siaccount/InsuranceAccountDetailMapper.java b/src/com/engine/salary/mapper/siaccount/InsuranceAccountDetailMapper.java new file mode 100644 index 000000000..faf48f4bc --- /dev/null +++ b/src/com/engine/salary/mapper/siaccount/InsuranceAccountDetailMapper.java @@ -0,0 +1,203 @@ +package com.engine.salary.mapper.siaccount; + +import com.engine.salary.entity.siaccount.param.InsuranceAccountDetailParam; +import com.engine.salary.entity.siaccount.param.SupplementAccountBaseParam; +import com.engine.salary.entity.siaccount.po.InsuranceAccountDetailPO; +import com.engine.salary.entity.siarchives.po.InsuranceArchivesEmployeePO; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; + +/** + * @Author weaver_cl + * @Date 2022/4/11 + * @Version V1.0 + **/ +public interface InsuranceAccountDetailMapper { + + /** + * 查询正常缴纳列表 + * + * @param queryParam + * @return + */ + List list(@Param("param") InsuranceAccountDetailParam queryParam); + + /** + * 查询正常缴纳列表_非系统人员 + * + * @param queryParam + * @return + */ + List extList(@Param("param") InsuranceAccountDetailParam queryParam); + + /** + * 通过id查询 + */ + InsuranceAccountDetailPO getById(@Param("id") Long id); + + /** + * 根据账单月份获取所有员工 + * + * @param time + * @return + */ + List selectAccountIds(@Param("time") String time, @Param("paymentOrganization") Long paymentOrganization); + + + /** + * 根据缴纳组织获取员工id + * + * @param paymentOrganization + * @return + */ + List selectEmpByPaymentOrg(@Param("paymentOrganization") Long paymentOrganization); + + /** + * 根据id删除 + * + * @param id + */ + void deleteById(@Param("id") Long id); + + /** + * 批量删除 + */ + void batchDelAccountDetails(@Param("employeeIds") Collection employeeIds, @Param("billMonth") String billMonth, @Param("paymentOrganization") Long paymentOrganization, @Param("paymentStatus") Integer paymentStatus); + + /** + * 根据id批量删除 + */ + void batchDelAccountDetailsByIds(@Param("ids") Collection ids); + + /** + * 批量保存 + * + * @param accounts + */ + void batchSaveAccountDetails(@Param("accounts") Collection accounts); + + + /** + * 条件查询 + * + * @param billMonth + * @return + */ + List selectList(@Param("billMonth") String billMonth, @Param("paymentOrganization") Long paymentOrganization); + + List queryList(@Param("billMonth") String billMonth, @Param("paymentOrganization") Long paymentOrganization, @Param("employeeIds") Collection employeeIds); + + /** + * 查询正常缴纳数据 + * @param billMonth 账单月份 + * @param paymentOrganization 个税扣缴义务人 + * @param employeeId 人员id + * @return + */ + List queryNormalList(@Param("billMonth") String billMonth, @Param("paymentOrganization") Long paymentOrganization, @Param("employeeId") Long employeeId); + + /** + * 查询补缴数据 + * @param billMonth 账单月份 + * @param paymentOrganization 个税扣缴义务人 + * @param employeeId 人员id + * @param supplementaryMonth 补缴月份 + * @return + */ + List querySupplementList(@Param("billMonth") String billMonth, @Param("paymentOrganization") Long paymentOrganization, @Param("employeeId") Long employeeId, @Param("supplementaryMonth") String supplementaryMonth); + + /** + * 查询补缴数据 + * @param billMonth 账单月份 + * @param paymentOrganization 个税扣缴义务人 + * @return + */ + List querySupplementListByBillMonth(@Param("billMonth") String billMonth, @Param("paymentOrganization") Long paymentOrganization); + + /** + * 查询补差数据 + * @param billMonth 账单月份 + * @param paymentOrganization 个税扣缴义务人 + * @return + */ + List queryBalanceListByBillMonth(@Param("billMonth") String billMonth, @Param("paymentOrganization") Long paymentOrganization); + + /** + * 查询正常缴纳数据 + * @param billMonth 账单月份 + * @param paymentOrganization 个税扣缴义务人 + * @return + */ + List queryNormalListByBillMonth(@Param("billMonth") String billMonth, @Param("paymentOrganization") Long paymentOrganization); + /** + * 根据账单月份删除 + * + * @param billMonth + */ + void batchDeleteNotFile(@Param("billMonth") String billMonth, @Param("paymentOrganization") Long paymentOrganization); + + + /** + * 批量删除 + * + * @param pos + */ + void batchDelSupplementAccountDetails(@Param("pos") Collection pos); + + + /** + * 根据员工id批量删除 + * + * @param pos + */ + void batchDelSupplementDetailsByIds(@Param("pos") Collection pos); + + + void batchUnConfirmedInspectDetails(@Param("ids") Collection ids); + + + void batchIgnoreInspectDetails(@Param("ids") Collection ids); + + + List changeList(@Param("userName") String userName); + + /** + * 根据员工id和账单月份更新数据 + */ + void updateByEmployeeIdAndBillMonth(InsuranceAccountDetailPO po); + + List listAll(); + + int batchUpdate(@Param("collection") List pos); + + /** + * 根据id更新数据 + */ + void updateById(InsuranceAccountDetailPO po); + + + /** + * 删除退差数据(账单月份+退差月份+缴纳状态+人员id+个税扣缴义务人) + */ + void deleteRecessionData(InsuranceAccountDetailPO po); + + /** + * 获取数据(账单月份+缴纳状态+人员id+个税扣缴义务人) + */ + InsuranceAccountDetailPO getOneByBpep(InsuranceAccountDetailPO po); + + /** + * 获取补差数据(账单月份+人员id+个税扣缴义务人) + */ + List queryBalanceList(InsuranceAccountDetailPO po); + + /** + * 根据id删除 + * @param ids + */ + void deleteByIds(@Param("ids")List ids); + + void deleteByEmpIds(@Param("employeeIds")List deleteEmployeeIds, @Param("billMonth") String billMonth, @Param("paymentOrganization") Long paymentOrganization); +} diff --git a/src/com/engine/salary/mapper/siaccount/InsuranceAccountDetailMapper.xml b/src/com/engine/salary/mapper/siaccount/InsuranceAccountDetailMapper.xml new file mode 100644 index 000000000..1f077543d --- /dev/null +++ b/src/com/engine/salary/mapper/siaccount/InsuranceAccountDetailMapper.xml @@ -0,0 +1,1624 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + t + . + id + , t.employee_id + , e.status as employee_status + , t.bill_month + , t.bill_status + , t.payment_status + , t.supplementary_month + , t.supplementary_projects + , t.resource_from + , t.social_pay_org + , t.social_account + , t.fund_pay_org + , t.fund_account + , t.supplement_fund_account + , t.other_pay_org + , t.social_scheme_id + , t.social_payment_base_string + , t.social_payment_com_base_string + , t.fund_scheme_id + , t.fund_payment_base_string + , t.fund_payment_com_base_string + , t.other_scheme_id + , t.other_payment_base_string + , t.other_payment_com_base_string + , t.social_per_json + , t.social_per_sum + , t.fund_per_json + , t.fund_per_sum + , t.other_per_json + , t.other_per_sum + , t.per_sum + , t.social_com_json + , t.social_com_sum + , t.fund_com_json + , t.fund_com_sum + , t.other_com_json + , t.other_com_sum + , t.com_sum + , t.social_sum + , t.fund_sum + , t.other_sum + , t.total + , t.creator + , t.delete_type + , t.create_time + , t.update_time + , t.tenant_key + , t.payment_organization + , t.subcompany_name + , t.subcompany_id + , t.department_name + , t.department_id + , t.jobtitle_name + , t.jobtitle_id + , t.jobcall + , t.jobcall_id + , t.status + + + t + . + id + , t.employee_id + , t.bill_month + , t.bill_status + , t.payment_status + , t.supplementary_month + , t.supplementary_projects + , t.resource_from + , t.social_pay_org + , t.social_account + , t.fund_pay_org + , t.fund_account + , t.supplement_fund_account + , t.other_pay_org + , t.social_scheme_id + , t.social_payment_base_string + , t.social_payment_com_base_string + , t.fund_scheme_id + , t.fund_payment_base_string + , t.fund_payment_com_base_string + , t.other_scheme_id + , t.other_payment_base_string + , t.other_payment_com_base_string + , t.social_per_json + , t.social_per_sum + , t.fund_per_json + , t.fund_per_sum + , t.other_per_json + , t.other_per_sum + , t.per_sum + , t.social_com_json + , t.social_com_sum + , t.fund_com_json + , t.fund_com_sum + , t.other_com_json + , t.other_com_sum + , t.com_sum + , t.social_sum + , t.fund_sum + , t.other_sum + , t.total + , t.creator + , t.delete_type + , t.create_time + , t.update_time + , t.tenant_key + , t.payment_organization + + + + + AND + t.bill_month = #{param.billMonth} + + + AND + t.payment_status = #{param.paymentStatus} + + + AND + t.payment_organization = #{param.paymentOrganization} + + + + + + + + + + AND + ( + e.lastname like CONCAT('%',#{param.userName},'%') + ) + + + AND e.workcode like CONCAT('%',#{param.workcode},'%') + + + AND t.employee_id IN + + #{employeeId} + + + + AND t.bill_month IN + + #{recessionMonth} + + + + AND t.payment_organization IN + + #{taxAgent} + + + + AND t.department_id IN + + #{fixedDepartmentId} + + + + AND t.subcompany_id IN + + #{fixedSubCompanyId} + + + + + AND e.departmentid IN + + #{departmentId} + + + + AND e.subcompanyid1 IN + + #{subCompanyId} + + + + + + AND + ( + e.lastname like '%'||#{param.userName}||'%' + ) + + + AND e.workcode like '%'||#{param.workcode}||'%' + + + AND t.employee_id IN + + #{employeeId} + + + + AND t.bill_month IN + + #{recessionMonth} + + + + AND t.payment_organization IN + + #{taxAgent} + + + + AND t.department_id IN + + #{fixedDepartmentId} + + + + AND t.subcompany_id IN + + #{fixedSubCompanyId} + + + + AND e.departmentid IN + + #{departmentId} + + + + AND e.subcompanyid1 IN + + #{subCompanyId} + + + + + + AND + ( + e.lastname like '%'+#{param.userName}+'%' + ) + + + AND e.workcode like '%'+#{param.workcode}+'%' + + + AND t.employee_id IN + + #{employeeId} + + + + AND t.bill_month IN + + #{recessionMonth} + + + + AND t.payment_organization IN + + #{taxAgent} + + + + AND t.department_id IN + + #{fixedDepartmentId} + + + + AND t.subcompany_id IN + + #{fixedSubCompanyId} + + + + AND e.departmentid IN + + #{departmentId} + + + + AND e.subcompanyid1 IN + + #{subCompanyId} + + + + + + + AND + ( + e.userName like CONCAT('%',#{param.userName},'%') + ) + + + AND e.workcode like CONCAT('%',#{param.workcode},'%') + + + AND t.employee_id IN + + #{employeeId} + + + + AND t.bill_month IN + + #{recessionMonth} + + + + AND t.payment_organization IN + + #{taxAgent} + + + + AND t.department_id IN + + #{fixedDepartmentId} + + + + AND t.subcompany_id IN + + #{fixedSubCompanyId} + + + + AND e.department_id IN + + #{departmentId} + + + + AND e.subcompany_id IN + + #{subCompanyId} + + + + + + AND + ( + e.userName like '%'||#{param.userName}||'%' + ) + + + AND e.workcode like '%'||#{param.workcode}||'%' + + + AND t.employee_id IN + + #{employeeId} + + + + AND t.bill_month IN + + #{recessionMonth} + + + + AND t.payment_organization IN + + #{taxAgent} + + + + AND t.department_id IN + + #{fixedDepartmentId} + + + + AND t.subcompany_id IN + + #{fixedSubCompanyId} + + + + AND e.department_id IN + + #{departmentId} + + + + AND e.subcompany_id IN + + #{subCompanyId} + + + + + + AND + ( + e.userName like '%'+#{param.userName}+'%' + ) + + + AND e.workcode like '%'+#{param.workcode}+'%' + + + AND t.employee_id IN + + #{employeeId} + + + + AND t.bill_month IN + + #{recessionMonth} + + + + AND t.payment_organization IN + + #{taxAgent} + + + + AND t.department_id IN + + #{fixedDepartmentId} + + + + AND t.subcompany_id IN + + #{fixedSubCompanyId} + + + + AND e.department_id IN + + #{departmentId} + + + + AND e.subcompany_id IN + + #{subCompanyId} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + UPDATE hrsa_bill_detail + SET delete_type = 1 + WHERE id = #{id} + AND delete_type = 0 + + + + DELETE + FROM hrsa_bill_detail + WHERE delete_type = 0 + AND bill_month = #{billMonth} + AND bill_status = 0 + + AND payment_organization = #{paymentOrganization} + + + + + + UPDATE hrsa_bill_detail + SET delete_type = 1 + WHERE delete_type = 0 + AND id IN + + #{po.id} + + + + + UPDATE + hrsa_bill_inspect + SET + inspect_status = 0 + WHERE + delete_type = 0 + AND id IN + + #{id} + + + + + UPDATE + hrsa_bill_inspect + SET + inspect_status = 1 + WHERE + delete_type = 0 + AND id IN + + #{id} + + + + + + + UPDATE hrsa_bill_detail + SET delete_type = 1 + WHERE delete_type = 0 + AND payment_status = #{paymentStatus} + AND bill_month = #{billMonth} + AND payment_organization = #{paymentOrganization} + + AND employee_id IN + + #{employeeId} + + + + + + + UPDATE hrsa_bill_detail + SET delete_type = 1 + WHERE delete_type = 0 + + AND id IN + + #{id} + + + + + + UPDATE hrsa_bill_detail + SET delete_type = 1 + WHERE delete_type = 0 + AND employee_id IN + + #{po.employeeId} + + + + + + INSERT INTO hrsa_bill_detail + (employee_id,bill_month,bill_status,payment_status,supplementary_month,supplementary_projects,resource_from,social_pay_org,social_account,social_scheme_id,social_payment_base_string, + fund_pay_org,fund_account,supplement_fund_account,fund_scheme_id,fund_payment_base_string,other_pay_org,other_scheme_id,other_payment_base_string,social_per_json, + social_per_sum,fund_per_json,fund_per_sum,other_per_json,other_per_sum,per_sum,social_com_json,social_com_sum,fund_com_json,fund_com_sum,other_com_json,other_com_sum, + com_sum,social_sum,fund_sum,other_sum,total,creator,create_time,update_time,delete_type,tenant_key,payment_organization, + social_payment_com_base_string,fund_payment_com_base_string,other_payment_com_base_string, + subcompany_name,subcompany_id,department_name,department_id,jobtitle_name,jobtitle_id,jobcall,jobcall_id,status) + VALUES + + ( + #{item.employeeId}, + #{item.billMonth}, + #{item.billStatus}, + #{item.paymentStatus}, + #{item.supplementaryMonth}, + #{item.supplementaryProjects}, + #{item.resourceFrom}, + #{item.socialPayOrg}, + #{item.socialAccount}, + #{item.socialSchemeId}, + #{item.socialPaymentBaseString}, + #{item.fundPayOrg}, + #{item.fundAccount}, + #{item.supplementFundAccount}, + #{item.fundSchemeId}, + #{item.fundPaymentBaseString}, + #{item.otherPayOrg}, + #{item.otherSchemeId}, + #{item.otherPaymentBaseString}, + #{item.socialPerJson}, + #{item.socialPerSum}, + #{item.fundPerJson}, + #{item.fundPerSum}, + #{item.otherPerJson}, + #{item.otherPerSum}, + #{item.perSum}, + #{item.socialComJson}, + #{item.socialComSum}, + #{item.fundComJson}, + #{item.fundComSum}, + #{item.otherComJson}, + #{item.otherComSum}, + #{item.comSum}, + #{item.socialSum}, + #{item.fundSum}, + #{item.otherSum}, + #{item.total}, + #{item.creator}, + #{item.createTime}, + #{item.updateTime}, + #{item.deleteType}, + #{item.tenantKey}, + #{item.paymentOrganization}, + #{item.socialPaymentComBaseString}, + #{item.fundPaymentComBaseString}, + #{item.otherPaymentComBaseString}, + #{item.subcompanyName}, + #{item.subcompanyId}, + #{item.departmentName}, + #{item.departmentId}, + #{item.jobtitleName}, + #{item.jobtitleId}, + #{item.jobcall}, + #{item.jobcallId}, + #{item.status} + ) + + + + INSERT INTO hrsa_bill_detail + (employee_id,bill_month,bill_status,payment_status,supplementary_month,supplementary_projects,resource_from,social_pay_org,social_account,social_scheme_id,social_payment_base_string, + fund_pay_org,fund_account,supplement_fund_account,fund_scheme_id,fund_payment_base_string,other_pay_org,other_scheme_id,other_payment_base_string,social_per_json, + social_per_sum,fund_per_json,fund_per_sum,other_per_json,other_per_sum,per_sum,social_com_json,social_com_sum,fund_com_json,fund_com_sum,other_com_json,other_com_sum, + com_sum,social_sum,fund_sum,other_sum,total,creator,create_time,update_time,delete_type,tenant_key,payment_organization, + social_payment_com_base_string,fund_payment_com_base_string,other_payment_com_base_string, + subcompany_name,subcompany_id,department_name,department_id,jobtitle_name,jobtitle_id,jobcall,jobcall_id,status) + + select + #{item.employeeId,jdbcType=DOUBLE}, + #{item.billMonth,jdbcType=VARCHAR}, + #{item.billStatus,jdbcType=INTEGER}, + #{item.paymentStatus,jdbcType=INTEGER}, + #{item.supplementaryMonth,jdbcType=VARCHAR}, + #{item.supplementaryProjects,jdbcType=VARCHAR}, + #{item.resourceFrom,jdbcType=INTEGER}, + #{item.socialPayOrg,jdbcType=DOUBLE}, + #{item.socialAccount,jdbcType=VARCHAR}, + #{item.socialSchemeId,jdbcType=DOUBLE}, + #{item.socialPaymentBaseString,jdbcType=VARCHAR}, + #{item.fundPayOrg,jdbcType=DOUBLE}, + #{item.fundAccount,jdbcType=VARCHAR}, + #{item.supplementFundAccount,jdbcType=VARCHAR}, + #{item.fundSchemeId,jdbcType=DOUBLE}, + #{item.fundPaymentBaseString,jdbcType=VARCHAR}, + #{item.otherPayOrg,jdbcType=DOUBLE}, + #{item.otherSchemeId,jdbcType=DOUBLE}, + #{item.otherPaymentBaseString,jdbcType=VARCHAR}, + #{item.socialPerJson,jdbcType=VARCHAR}, + #{item.socialPerSum,jdbcType=VARCHAR}, + #{item.fundPerJson,jdbcType=VARCHAR}, + #{item.fundPerSum,jdbcType=VARCHAR}, + #{item.otherPerJson,jdbcType=VARCHAR}, + #{item.otherPerSum,jdbcType=VARCHAR}, + #{item.perSum,jdbcType=VARCHAR}, + #{item.socialComJson,jdbcType=VARCHAR}, + #{item.socialComSum,jdbcType=VARCHAR}, + #{item.fundComJson,jdbcType=VARCHAR}, + #{item.fundComSum,jdbcType=VARCHAR}, + #{item.otherComJson,jdbcType=VARCHAR}, + #{item.otherComSum,jdbcType=VARCHAR}, + #{item.comSum,jdbcType=VARCHAR}, + #{item.socialSum,jdbcType=VARCHAR}, + #{item.fundSum,jdbcType=VARCHAR}, + #{item.otherSum,jdbcType=VARCHAR}, + #{item.total,jdbcType=VARCHAR}, + #{item.creator,jdbcType=DOUBLE}, + #{item.createTime}, + #{item.updateTime}, + #{item.deleteType}, + #{item.tenantKey,jdbcType=VARCHAR}, + #{item.paymentOrganization,jdbcType=DOUBLE}, + #{item.socialPaymentComBaseString,jdbcType=VARCHAR}, + #{item.fundPaymentComBaseString,jdbcType=VARCHAR}, + #{item.otherPaymentComBaseString,jdbcType=VARCHAR}, + #{item.subcompanyName,jdbcType=VARCHAR}, + #{item.subcompanyId,jdbcType=DOUBLE}, + #{item.departmentName,jdbcType=VARCHAR}, + #{item.departmentId,jdbcType=DOUBLE}, + #{item.jobtitleName,jdbcType=VARCHAR}, + #{item.jobtitleId,jdbcType=DOUBLE}, + #{item.jobcall,jdbcType=VARCHAR}, + #{item.jobcallId,jdbcType=DOUBLE}, + #{item.status,jdbcType=VARCHAR} + from dual + + + + + INSERT INTO hrsa_bill_detail + (employee_id,bill_month,bill_status,payment_status,supplementary_month,supplementary_projects,resource_from,social_pay_org,social_account,social_scheme_id,social_payment_base_string, + fund_pay_org,fund_account,supplement_fund_account,fund_scheme_id,fund_payment_base_string,other_pay_org,other_scheme_id,other_payment_base_string,social_per_json, + social_per_sum,fund_per_json,fund_per_sum,other_per_json,other_per_sum,per_sum,social_com_json,social_com_sum,fund_com_json,fund_com_sum,other_com_json,other_com_sum, + com_sum,social_sum,fund_sum,other_sum,total,creator,create_time,update_time,delete_type,tenant_key,payment_organization, + social_payment_com_base_string,fund_payment_com_base_string,other_payment_com_base_string, + subcompany_name,subcompany_id,department_name,department_id,jobtitle_name,jobtitle_id,jobcall,jobcall_id,status) + VALUES + ( + #{item.employeeId}, + #{item.billMonth}, + #{item.billStatus}, + #{item.paymentStatus}, + #{item.supplementaryMonth}, + #{item.supplementaryProjects}, + #{item.resourceFrom}, + #{item.socialPayOrg}, + #{item.socialAccount}, + #{item.socialSchemeId}, + #{item.socialPaymentBaseString}, + #{item.fundPayOrg}, + #{item.fundAccount}, + #{item.supplementFundAccount}, + #{item.fundSchemeId}, + #{item.fundPaymentBaseString}, + #{item.otherPayOrg}, + #{item.otherSchemeId}, + #{item.otherPaymentBaseString}, + #{item.socialPerJson}, + #{item.socialPerSum}, + #{item.fundPerJson}, + #{item.fundPerSum}, + #{item.otherPerJson}, + #{item.otherPerSum}, + #{item.perSum}, + #{item.socialComJson}, + #{item.socialComSum}, + #{item.fundComJson}, + #{item.fundComSum}, + #{item.otherComJson}, + #{item.otherComSum}, + #{item.comSum}, + #{item.socialSum}, + #{item.fundSum}, + #{item.otherSum}, + #{item.total}, + #{item.creator}, + #{item.createTime}, + #{item.updateTime}, + #{item.deleteType}, + #{item.tenantKey}, + #{item.paymentOrganization}, + #{item.socialPaymentComBaseString}, + #{item.fundPaymentComBaseString}, + #{item.otherPaymentComBaseString}, + #{item.subcompanyName}, + #{item.subcompanyId}, + #{item.departmentName}, + #{item.departmentId}, + #{item.jobtitleName}, + #{item.jobtitleId}, + #{item.jobcall}, + #{item.jobcallId}, + #{item.status} + ) + + + + + + + AND e.lastname like CONCAT('%',#{userName},'%') + + + + + + AND e.lastname like '%'||#{userName}||'%' + + + + + + AND e.lastname like '%'+#{userName}+'%' + + + + + + + UPDATE hrsa_bill_detail + + + social_per_json = #{socialPerJson}, + social_per_sum = #{socialPerSum}, + fund_per_json = #{fundPerJson}, + fund_per_sum = #{fundPerSum}, + other_per_json = #{otherPerJson}, + other_per_sum = #{otherPerSum}, + per_sum = #{perSum}, + com_sum = #{comSum}, + social_com_json = #{socialComJson}, + social_com_sum = #{socialComSum}, + fund_com_json = #{fundComJson}, + fund_com_sum = #{fundComSum}, + other_com_json = #{otherComJson}, + other_com_sum = #{otherComSum}, + social_sum = #{socialSum}, + fund_sum = #{fundSum}, + other_sum = #{otherSum}, + total = #{total}, + update_time = #{updateTime}, + supplementary_month = + #{supplementaryMonth}, + + + + WHERE id = #{id} + + + + + + update hrsa_bill_detail + + + + + when id=#{item.id} then #{item.socialPaymentBaseString} + + + + + + + when id=#{item.id} then #{item.fundPaymentBaseString} + + + + + + + when id=#{item.id} then #{item.otherPaymentBaseString} + + + + + + + when id=#{item.id} then #{item.socialPaymentComBaseString} + + + + + + + when id=#{item.id} then #{item.fundPaymentComBaseString} + + + + + + + when id=#{item.id} then #{item.otherPaymentComBaseString} + + + + + + + when id=#{item.id} then #{item.socialPerJson} + + + + + + + when id=#{item.id} then #{item.socialPerSum} + + + + + + + when id=#{item.id} then #{item.fundPerJson} + + + + + + + when id=#{item.id} then #{item.fundPerSum} + + + + + + + when id=#{item.id} then #{item.otherPerJson} + + + + + + + when id=#{item.id} then #{item.otherPerSum} + + + + + + + when id=#{item.id} then #{item.perSum} + + + + + + + when id=#{item.id} then #{item.socialComJson} + + + + + + + when id=#{item.id} then #{item.socialComSum} + + + + + + + when id=#{item.id} then #{item.fundComJson} + + + + + + + when id=#{item.id} then #{item.fundComSum} + + + + + + + when id=#{item.id} then #{item.otherComJson} + + + + + + + when id=#{item.id} then #{item.otherComSum} + + + + + + + when id=#{item.id} then #{item.comSum} + + + + + + + when id=#{item.id} then #{item.socialSum} + + + + + + + when id=#{item.id} then #{item.fundSum} + + + + + + + when id=#{item.id} then #{item.otherSum} + + + + + + + when id=#{item.id} then #{item.total} + + + + + + + when id=#{item.id} then #{item.deleteType} + + + + + where + id in + + #{item.id} + + + + + + + UPDATE hrsa_bill_detail + + + social_per_json = #{socialPerJson}, + social_per_sum = #{socialPerSum}, + fund_per_json = #{fundPerJson}, + fund_per_sum = #{fundPerSum}, + other_per_json = #{otherPerJson}, + other_per_sum = #{otherPerSum}, + per_sum = #{perSum}, + com_sum = #{comSum}, + social_com_json = #{socialComJson}, + social_com_sum = #{socialComSum}, + fund_com_json = #{fundComJson}, + fund_com_sum = #{fundComSum}, + other_com_json = #{otherComJson}, + other_com_sum = #{otherComSum}, + social_sum = #{socialSum}, + fund_sum = #{fundSum}, + other_sum = #{otherSum}, + total = #{total}, + update_time = #{updateTime}, + supplementary_month = + #{supplementaryMonth}, + + + + WHERE id = #{id} + + + + UPDATE hrsa_bill_detail + SET delete_type = 1 + WHERE delete_type = 0 + AND bill_month = #{billMonth} + AND payment_status = #{paymentStatus} + AND payment_organization = #{paymentOrganization} + AND supplementary_month = #{supplementaryMonth} + AND employee_id = #{employeeId} + + + + UPDATE hrsa_bill_detail + SET delete_type = 1 + WHERE delete_type = 0 + + AND id IN + + #{id} + + + + + UPDATE hrsa_bill_detail + SET delete_type = 1 + WHERE delete_type = 0 + AND bill_month = #{billMonth} + AND payment_organization = #{paymentOrganization} + AND employee_id in + + #{employeeId} + + + + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/siaccount/InsuranceAccountInspectMapper.java b/src/com/engine/salary/mapper/siaccount/InsuranceAccountInspectMapper.java new file mode 100644 index 000000000..479afd7ac --- /dev/null +++ b/src/com/engine/salary/mapper/siaccount/InsuranceAccountInspectMapper.java @@ -0,0 +1,44 @@ +package com.engine.salary.mapper.siaccount; + +import com.engine.salary.entity.siaccount.po.InsuranceAccountInspectPO; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; + +/** + * @Author weaver_cl + * + * @Date 2022/4/14 + * @Version V1.0 + **/ +public interface InsuranceAccountInspectMapper { + + /** + * 批量删除 + * @param pos + */ + void batchDelInspectDetails(@Param("pos") Collection pos); + + /** + * 批量保存 + * @param pos + */ + void batchSaveInspectDetails(@Param("pos") Collection pos); + + + /** + * + * @param inspectStatus + * @param billMonth + * @return + */ + List getByInspectStatusAndBillMonth(@Param("inspectStatus")Integer inspectStatus,@Param("billMonth")String billMonth); + + + List getByInspectStatusAndIds(@Param("inspectStatus")Integer inspectStatus,@Param("ids")Collection ids); + + List getList(@Param("billMonth")String billMonth,@Param("inspectStatus")Integer inspectStatus,@Param("ids")Collection ids); + + List getByBillMonth(@Param("billMonth")String billMonth); +} diff --git a/src/com/engine/salary/mapper/siaccount/InsuranceAccountInspectMapper.xml b/src/com/engine/salary/mapper/siaccount/InsuranceAccountInspectMapper.xml new file mode 100644 index 000000000..92e9e14f9 --- /dev/null +++ b/src/com/engine/salary/mapper/siaccount/InsuranceAccountInspectMapper.xml @@ -0,0 +1,163 @@ + + + + + + + + + + + + + + + + + + + + + t.id + , t.employee_id + , t.bill_month + , t.payment_status + , t.inspect_status + , t.supplementary_month + , t.supplementary_projects + , t.creator + , t.delete_type + , t.create_time + , t.update_time + , t.tenant_key + + + + + + + AND t.id IN + + #{id} + + + + + + + + + + + + + + + UPDATE hrsa_bill_inspect + SET delete_type = 1 + WHERE delete_type = 0 + AND id IN + + #{po.id} + + + + + + INSERT INTO hrsa_bill_inspect + (employee_id,bill_month,payment_status,inspect_status,supplementary_month, + supplementary_projects,creator,delete_type,create_time,update_time,tenant_key) + VALUES + + ( + #{item.employeeId}, + #{item.billMonth}, + #{item.paymentStatus}, + #{item.inspectStatus}, + #{item.supplementaryMonth}, + #{item.supplementaryProjects}, + #{item.creator}, + #{item.deleteType}, + #{item.createTime}, + #{item.updateTime}, + #{item.tenantKey} + ) + + + + INSERT INTO hrsa_bill_inspect + (employee_id,bill_month,payment_status,inspect_status,supplementary_month, + supplementary_projects,creator,delete_type,create_time,update_time,tenant_key) + + + select + #{item.employeeId,jdbcType=DOUBLE}, + #{item.billMonth,jdbcType=VARCHAR}, + #{item.paymentStatus,jdbcType=INTEGER}, + #{item.inspectStatus,jdbcType=INTEGER}, + #{item.supplementaryMonth,jdbcType=VARCHAR}, + #{item.supplementaryProjects,jdbcType=VARCHAR}, + #{item.creator,jdbcType=DOUBLE}, + #{item.deleteType,jdbcType=INTEGER}, + #{item.createTime,jdbcType=DATE}, + #{item.updateTime,jdbcType=DATE}, + #{item.tenantKey,jdbcType=VARCHAR} + from dual + + + + + INSERT INTO hrsa_bill_inspect + (employee_id,bill_month,payment_status,inspect_status,supplementary_month, + supplementary_projects,creator,delete_type,create_time,update_time,tenant_key) + VALUES + ( + #{item.employeeId}, + #{item.billMonth}, + #{item.paymentStatus}, + #{item.inspectStatus}, + #{item.supplementaryMonth}, + #{item.supplementaryProjects}, + #{item.creator}, + #{item.deleteType}, + #{item.createTime}, + #{item.updateTime}, + #{item.tenantKey} + ) + + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/siaccount/InsuranceCompensationConfigMapper.java b/src/com/engine/salary/mapper/siaccount/InsuranceCompensationConfigMapper.java new file mode 100644 index 000000000..e9756492f --- /dev/null +++ b/src/com/engine/salary/mapper/siaccount/InsuranceCompensationConfigMapper.java @@ -0,0 +1,19 @@ +package com.engine.salary.mapper.siaccount; + +import com.engine.salary.entity.siaccount.po.InsuranceCompensationConfigPO; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; + +public interface InsuranceCompensationConfigMapper { + + void batchInsert(@Param("collection") Collection compensationConfigPOS); + + void insert(InsuranceCompensationConfigPO compensationConfigPO); + + void deleteByPayOrg(Long paymentOrganization); + + List queryByPayOrg(@Param("paymentOrganization") Long paymentOrganization); + +} diff --git a/src/com/engine/salary/mapper/siaccount/InsuranceCompensationConfigMapper.xml b/src/com/engine/salary/mapper/siaccount/InsuranceCompensationConfigMapper.xml new file mode 100644 index 000000000..fda8f1f01 --- /dev/null +++ b/src/com/engine/salary/mapper/siaccount/InsuranceCompensationConfigMapper.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + t.id + , t.payment_agency + , t.employee_id + , t.payment_organization + , t.welfare_type + , t.category_type + , t.adjust_to + , t.create_time + , t.update_time + , t.creator + , t.delete_type + , t.tenant_key + + + + INSERT INTO hrsa_compensation_config( + id, + employee_id, + payment_organization, + welfare_type, + category_type, + adjust_to, + create_time, + update_time, + creator, + delete_type, + tenant_key + ) + VALUES + + ( + #{item.id}, + #{item.employeeId}, + #{item.paymentOrganization}, + #{item.welfareType}, + #{item.categoryType}, + #{item.adjustTo}, + #{item.createTime}, + #{item.updateTime}, + #{item.creator}, + #{item.deleteType}, + #{item.tenantKey} + ) + + + + INSERT INTO hrsa_compensation_config( + id, + employee_id, + payment_organization, + welfare_type, + category_type, + adjust_to, + create_time, + update_time, + creator, + delete_type, + tenant_key + ) + + + select + #{item.id,jdbcType=DOUBLE}, + #{item.employeeId,jdbcType=DOUBLE}, + #{item.paymentOrganization,jdbcType=DOUBLE}, + #{item.welfareType,jdbcType=INTEGER}, + #{item.categoryType,jdbcType=VARCHAR}, + #{item.adjustTo,jdbcType=DOUBLE}, + #{item.createTime,jdbcType=DATE}, + #{item.updateTime,jdbcType=DATE}, + #{item.creator,jdbcType=DOUBLE}, + #{item.deleteType,jdbcType=INTEGER}, + #{item.tenantKey,jdbcType=VARCHAR} + + from dual + + + + + INSERT INTO hrsa_compensation_config( + id, + employee_id, + payment_organization, + welfare_type, + category_type, + adjust_to, + create_time, + update_time, + creator, + delete_type, + tenant_key + ) + VALUES + ( + #{item.id}, + #{item.employeeId}, + #{item.paymentOrganization}, + #{item.welfareType}, + #{item.categoryType}, + #{item.adjustTo}, + #{item.createTime}, + #{item.updateTime}, + #{item.creator}, + #{item.deleteType}, + #{item.tenantKey} + ) + + + + + insert into hrsa_compensation_config ( + id, + employee_id, + payment_organization, + welfare_type, + category_type, + adjust_to, + create_time, + update_time, + creator, + delete_type, + tenant_key) + VALUES ( + #{id}, + #{employeeId}, + #{paymentOrganization}, + #{welfareType}, + #{categoryType}, + #{adjustTo}, + #{createTime}, + #{updateTime}, + #{creator}, + #{deleteType}, + #{tenantKey}) + + + + UPDATE hrsa_compensation_config + SET delete_type = 1 + WHERE payment_organization = #{paymentOrganization} + AND delete_type = 0 + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/siaccount/InsuranceCompensationMapper.java b/src/com/engine/salary/mapper/siaccount/InsuranceCompensationMapper.java new file mode 100644 index 000000000..ff149a787 --- /dev/null +++ b/src/com/engine/salary/mapper/siaccount/InsuranceCompensationMapper.java @@ -0,0 +1,29 @@ +package com.engine.salary.mapper.siaccount; + +import com.engine.salary.entity.siaccount.po.InsuranceCompensationPO; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; + +public interface InsuranceCompensationMapper { + + void batchInsert(@Param("collection") Collection insuranceCompensationPOS); + + void insert(InsuranceCompensationPO insuranceCompensationPO); + + InsuranceCompensationPO getById(Long id); + + List queryByBillMonthAndPayOrg(@Param("billMonth") String billMonth, @Param("paymentOrganization") Long paymentOrganization); + + InsuranceCompensationPO getOneByBillMonthPayOrgEmpId(InsuranceCompensationPO insuranceCompensationPO); + List getListByBillMonthPayOrgEmpId(InsuranceCompensationPO insuranceCompensationPO); + + List getByBillMonthPayOrgEmpIds(InsuranceCompensationPO insuranceCompensationPO); + + void deleteById(Long id); + + void deleteByBillMonthAndPayOrg(@Param("billMonth") String billMonth, @Param("paymentOrganization") Long paymentOrganization); + + void deleteByBillMonthPayOrgEmpIds(InsuranceCompensationPO insuranceCompensationPO); +} diff --git a/src/com/engine/salary/mapper/siaccount/InsuranceCompensationMapper.xml b/src/com/engine/salary/mapper/siaccount/InsuranceCompensationMapper.xml new file mode 100644 index 000000000..0f2aa206b --- /dev/null +++ b/src/com/engine/salary/mapper/siaccount/InsuranceCompensationMapper.xml @@ -0,0 +1,281 @@ + + + + + + + + + + + + + + + + + + + + + + + + + t.id + , t.payment_agency + , t.employee_id + , t.payment_organization + , t.welfare_type + , t.category_type + , t.country_total + , t.company_total + , t.adjustment_total + , t.adjust_to + , t.bill_month + , t.create_time + , t.update_time + , t.creator + , t.delete_type + , t.tenant_key + + + + INSERT INTO hrsa_compensation_log( + id, + employee_id, + payment_organization, + welfare_type, + category_type, + country_total, + company_total, + adjustment_total, + adjust_to, + bill_month, + create_time, + update_time, + creator, + delete_type, + tenant_key + ) + VALUES + + ( + #{item.id}, + #{item.employeeId}, + #{item.paymentOrganization}, + #{item.welfareType}, + #{item.categoryType}, + #{item.countryTotal}, + #{item.companyTotal}, + #{item.adjustmentTotal}, + #{item.adjustTo}, + #{item.billMonth}, + #{item.createTime}, + #{item.updateTime}, + #{item.creator}, + #{item.deleteType}, + #{item.tenantKey} + ) + + + + INSERT INTO hrsa_compensation_log( + id, + employee_id, + payment_organization, + welfare_type, + category_type, + country_total, + company_total, + adjustment_total, + adjust_to, + bill_month, + create_time, + update_time, + creator, + delete_type, + tenant_key + ) + + + select + #{item.id,jdbcType=DOUBLE}, + #{item.employeeId,jdbcType=DOUBLE}, + #{item.paymentOrganization,jdbcType=DOUBLE}, + #{item.welfareType,jdbcType=INTEGER}, + #{item.categoryType,jdbcType=VARCHAR}, + #{item.countryTotal,jdbcType=VARCHAR}, + #{item.companyTotal,jdbcType=VARCHAR}, + #{item.adjustmentTotal,jdbcType=VARCHAR}, + #{item.adjustTo,jdbcType=DOUBLE}, + #{item.billMonth,jdbcType=VARCHAR}, + #{item.createTime,jdbcType=DATE}, + #{item.updateTime,jdbcType=DATE}, + #{item.creator,jdbcType=DOUBLE}, + #{item.deleteType,jdbcType=INTEGER}, + #{item.tenantKey,jdbcType=VARCHAR} + from dual + + + + + INSERT INTO hrsa_compensation_log( + id, + employee_id, + payment_organization, + welfare_type, + category_type, + country_total, + company_total, + adjustment_total, + adjust_to, + bill_month, + create_time, + update_time, + creator, + delete_type, + tenant_key + ) + VALUES + ( + #{item.id}, + #{item.employeeId}, + #{item.paymentOrganization}, + #{item.welfareType}, + #{item.categoryType}, + #{item.countryTotal}, + #{item.companyTotal}, + #{item.adjustmentTotal}, + #{item.adjustTo}, + #{item.billMonth}, + #{item.createTime}, + #{item.updateTime}, + #{item.creator}, + #{item.deleteType}, + #{item.tenantKey} + ) + + + + + insert into hrsa_compensation_log ( + id, + employee_id, + payment_organization, + welfare_type, + category_type, + country_total, + company_total, + adjustment_total, + adjust_to, + bill_month, + create_time, + update_time, + creator, + delete_type, + tenant_key) + VALUES ( + #{id}, + #{employeeId}, + #{paymentOrganization}, + #{welfareType}, + #{categoryType}, + #{countryTotal}, + #{companyTotal}, + #{adjustmentTotal}, + #{adjustTo}, + #{billMonth}, + #{createTime}, + #{updateTime}, + #{creator}, + #{deleteType}, + #{tenantKey}) + + + + + + + + + + + + + + + + + + UPDATE hrsa_compensation_log + SET delete_type = 1 + WHERE id = #{id} + AND delete_type = 0 + + + + UPDATE hrsa_compensation_log + SET delete_type = 1 + WHERE bill_month = #{billMonth} + AND payment_organization = #{paymentOrganization} + AND delete_type = 0 + + + + UPDATE hrsa_compensation_log + SET delete_type = 1 + WHERE bill_month = #{billMonth} + AND payment_organization = #{paymentOrganization} + AND delete_type = 0 + + AND employee_id IN + + #{employeeId} + + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/siaccount/SIAccountDetailMapper.java b/src/com/engine/salary/mapper/siaccount/SIAccountDetailMapper.java new file mode 100644 index 000000000..bcd4769f4 --- /dev/null +++ b/src/com/engine/salary/mapper/siaccount/SIAccountDetailMapper.java @@ -0,0 +1,17 @@ +package com.engine.salary.mapper.siaccount; + +import com.engine.salary.entity.siaccount.param.QueryAccountDetailParam; +import com.engine.salary.entity.siaccount.po.InsuranceAccountDetailPO; + +import java.util.List; + + +public interface SIAccountDetailMapper { + + /** + * 条件查询 + * + * @return 返回集合,没有返回空List + */ + List listSome(QueryAccountDetailParam param); +} diff --git a/src/com/engine/salary/mapper/siaccount/SIAccountDetailMapper.xml b/src/com/engine/salary/mapper/siaccount/SIAccountDetailMapper.xml new file mode 100644 index 000000000..8480eaa94 --- /dev/null +++ b/src/com/engine/salary/mapper/siaccount/SIAccountDetailMapper.xml @@ -0,0 +1,116 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + t.id + , t.employee_id + , t.bill_month + , t.bill_status + , t.payment_status + , t.supplementary_month + , t.supplementary_projects + , t.resource_from + , t.social_pay_org + , t.social_account + , t.social_scheme_id + , t.social_payment_base_string + , t.fund_pay_org + , t.fund_account + , t.supplement_fund_account + , t.fund_scheme_id + , t.fund_payment_base_string + , t.other_pay_org + , t.other_scheme_id + , t.other_payment_base_string + , t.social_per_json + , t.social_per_sum + , t.fund_per_json + , t.fund_per_sum + , t.other_per_json + , t.other_per_sum + , t.per_sum + , t.social_com_json + , t.social_com_sum + , t.fund_com_json + , t.fund_com_sum + , t.other_com_json + , t.other_com_sum + , t.com_sum + , t.social_sum + , t.fund_sum + , t.other_sum + , t.total + , t.creator + , t.create_time + , t.update_time + , t.delete_type + , t.tenant_key + + + + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/siaccount/SIAccountDetailTempMapper.java b/src/com/engine/salary/mapper/siaccount/SIAccountDetailTempMapper.java new file mode 100644 index 000000000..7a470a222 --- /dev/null +++ b/src/com/engine/salary/mapper/siaccount/SIAccountDetailTempMapper.java @@ -0,0 +1,47 @@ +package com.engine.salary.mapper.siaccount; + +import com.engine.salary.entity.siaccount.po.InsuranceAccountDetailTempPO; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; + +/** + * @Author weaver_cl + * + * @Date 2022/4/13 + * @Version V1.0 + **/ +public interface SIAccountDetailTempMapper { + + /** + * 批量删除 + * @param employeeIds + * @param billMonth + */ + void batchDelAccountTempDetails(@Param("employeeIds") Collection employeeIds, @Param("billMonth") String billMonth); + + /** + * 批量删除 + * @param employeeIds + * @param billMonth + */ + void batchDelByEmpIdsAndMonthAndPayOrg(@Param("employeeIds") Collection employeeIds, @Param("billMonth") String billMonth, @Param("paymentOrganization") Long paymentOrganization); + + void batchDelByMonthAndPayOrg(@Param("billMonth") String billMonth, @Param("paymentOrganization") Long paymentOrganization); + + /** + * 批量保存 + * @param accounts + */ + void batchSaveAccountTempDetails(@Param("accounts") Collection accounts); + + + /** + * 获取 + * @param employeeIds + * @param billMonth + * @return + */ + List getListByEmployeeIdsAndBillMonth(@Param("employeeIds") Collection employeeIds, @Param("billMonth") String billMonth,@Param("paymentOrganization") Long paymentOrganization); +} diff --git a/src/com/engine/salary/mapper/siaccount/SIAccountDetailTempMapper.xml b/src/com/engine/salary/mapper/siaccount/SIAccountDetailTempMapper.xml new file mode 100644 index 000000000..a5fa46fca --- /dev/null +++ b/src/com/engine/salary/mapper/siaccount/SIAccountDetailTempMapper.xml @@ -0,0 +1,376 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + t + . + id + , t.employee_id + , t.bill_month + , t.bill_status + , t.payment_status + , t.supplementary_month + , t.supplementary_projects + , t.resource_from + , t.social_pay_org + , t.social_account + , t.fund_pay_org + , t.fund_account + , t.supplement_fund_account + , t.other_pay_org + , t.social_scheme_id + , t.social_payment_base_string + , t.social_payment_com_base_string + , t.fund_scheme_id + , t.fund_payment_base_string + , t.fund_payment_com_base_string + , t.other_scheme_id + , t.other_payment_base_string + , t.other_payment_com_base_string + , t.social_per_json + , t.social_per_sum + , t.fund_per_json + , t.fund_per_sum + , t.other_per_json + , t.other_per_sum + , t.per_sum + , t.social_com_json + , t.social_com_sum + , t.fund_com_json + , t.fund_com_sum + , t.other_com_json + , t.other_com_sum + , t.com_sum + , t.social_sum + , t.fund_sum + , t.other_sum + , t.total + , t.creator + , t.delete_type + , t.create_time + , t.update_time + , t.tenant_key + , t.payment_organization + , t.subcompany_name as subcompanyName + , t.subcompany_id as subcompanyId + , t.department_name as departmentName + , t.department_id as departmentId + , t.jobtitle_name as jobtitleName + , t.jobtitle_id as jobtitleId + , t.jobcall as jobcall + , t.jobcall_id as jobcallId + , t.status as status + + + + + + UPDATE hrsa_bill_detail_temp + SET delete_type = 1 + WHERE delete_type = 0 + AND bill_month = #{billMonth} + AND employee_id IN + + #{employeeId} + + + + + + UPDATE hrsa_bill_detail_temp + SET delete_type = 1 + WHERE delete_type = 0 + AND bill_month = #{billMonth} + AND payment_organization = #{paymentOrganization} + AND employee_id IN + + #{employeeId} + + + + + UPDATE hrsa_bill_detail_temp + SET delete_type = 1 + WHERE delete_type = 0 + AND bill_month = #{billMonth} + AND payment_organization = #{paymentOrganization} + + + + + INSERT INTO hrsa_bill_detail_temp + (employee_id,bill_month,bill_status,payment_status,supplementary_month,resource_from,social_pay_org,social_account,social_scheme_id,social_payment_base_string, + fund_pay_org,fund_account,supplement_fund_account,fund_scheme_id,fund_payment_base_string,other_pay_org,other_scheme_id,other_payment_base_string,social_per_json, + social_per_sum,fund_per_json,fund_per_sum,other_per_json,other_per_sum,per_sum,social_com_json,social_com_sum,fund_com_json,fund_com_sum,other_com_json,other_com_sum, + com_sum,social_sum,fund_sum,other_sum,total,creator,create_time,update_time,delete_type,tenant_key,payment_organization, + social_payment_com_base_string,fund_payment_com_base_string,other_payment_com_base_string, + subcompany_name,subcompany_id,department_name,department_id,jobtitle_name,jobtitle_id,jobcall,jobcall_id,status) + VALUES + + ( + #{item.employeeId}, + #{item.billMonth}, + #{item.billStatus}, + #{item.paymentStatus}, + #{item.supplementaryMonth}, + #{item.resourceFrom}, + #{item.socialPayOrg}, + #{item.socialAccount}, + #{item.socialSchemeId}, + #{item.socialPaymentBaseString}, + #{item.fundPayOrg}, + #{item.fundAccount}, + #{item.supplementFundAccount}, + #{item.fundSchemeId}, + #{item.fundPaymentBaseString}, + #{item.otherPayOrg}, + #{item.otherSchemeId}, + #{item.otherPaymentBaseString}, + #{item.socialPerJson}, + #{item.socialPerSum}, + #{item.fundPerJson}, + #{item.fundPerSum}, + #{item.otherPerJson}, + #{item.otherPerSum}, + #{item.perSum}, + #{item.socialComJson}, + #{item.socialComSum}, + #{item.fundComJson}, + #{item.fundComSum}, + #{item.otherComJson}, + #{item.otherComSum}, + #{item.comSum}, + #{item.socialSum}, + #{item.fundSum}, + #{item.otherSum}, + #{item.total}, + #{item.creator}, + #{item.createTime}, + #{item.updateTime}, + #{item.deleteType}, + #{item.tenantKey}, + #{item.paymentOrganization}, + #{item.socialPaymentComBaseString}, + #{item.fundPaymentComBaseString}, + #{item.otherPaymentComBaseString}, + #{item.subcompanyName}, + #{item.subcompanyId}, + #{item.departmentName}, + #{item.departmentId}, + #{item.jobtitleName}, + #{item.jobtitleId}, + #{item.jobcall}, + #{item.jobcallId}, + #{item.status} + ) + + + + INSERT INTO hrsa_bill_detail_temp + (employee_id,bill_month,bill_status,payment_status,supplementary_month,resource_from,social_pay_org,social_account,social_scheme_id,social_payment_base_string, + fund_pay_org,fund_account,supplement_fund_account,fund_scheme_id,fund_payment_base_string,other_pay_org,other_scheme_id,other_payment_base_string,social_per_json, + social_per_sum,fund_per_json,fund_per_sum,other_per_json,other_per_sum,per_sum,social_com_json,social_com_sum,fund_com_json,fund_com_sum,other_com_json,other_com_sum, + com_sum,social_sum,fund_sum,other_sum,total,creator,create_time,update_time,delete_type,tenant_key,payment_organization, + social_payment_com_base_string,fund_payment_com_base_string,other_payment_com_base_string, + subcompany_name,subcompany_id,department_name,department_id,jobtitle_name,jobtitle_id,jobcall,jobcall_id,status) + + + select + #{item.employeeId,jdbcType=DOUBLE}, + #{item.billMonth,jdbcType=VARCHAR}, + #{item.billStatus,jdbcType=INTEGER}, + #{item.paymentStatus,jdbcType=INTEGER}, + #{item.supplementaryMonth,jdbcType=VARCHAR}, + #{item.resourceFrom,jdbcType=INTEGER}, + #{item.socialPayOrg,jdbcType=DOUBLE}, + #{item.socialAccount,jdbcType=VARCHAR}, + #{item.socialSchemeId,jdbcType=DOUBLE}, + #{item.socialPaymentBaseString,jdbcType=VARCHAR}, + #{item.fundPayOrg,jdbcType=DOUBLE}, + #{item.fundAccount,jdbcType=VARCHAR}, + #{item.supplementFundAccount,jdbcType=VARCHAR}, + #{item.fundSchemeId,jdbcType=DOUBLE}, + #{item.fundPaymentBaseString,jdbcType=VARCHAR}, + #{item.otherPayOrg,jdbcType=DOUBLE}, + #{item.otherSchemeId,jdbcType=DOUBLE}, + #{item.otherPaymentBaseString,jdbcType=VARCHAR}, + #{item.socialPerJson,jdbcType=VARCHAR}, + #{item.socialPerSum,jdbcType=VARCHAR}, + #{item.fundPerJson,jdbcType=VARCHAR}, + #{item.fundPerSum,jdbcType=VARCHAR}, + #{item.otherPerJson,jdbcType=VARCHAR}, + #{item.otherPerSum,jdbcType=VARCHAR}, + #{item.perSum,jdbcType=VARCHAR}, + #{item.socialComJson,jdbcType=VARCHAR}, + #{item.socialComSum,jdbcType=VARCHAR}, + #{item.fundComJson,jdbcType=VARCHAR}, + #{item.fundComSum,jdbcType=VARCHAR}, + #{item.otherComJson,jdbcType=VARCHAR}, + #{item.otherComSum,jdbcType=VARCHAR}, + #{item.comSum,jdbcType=VARCHAR}, + #{item.socialSum,jdbcType=VARCHAR}, + #{item.fundSum,jdbcType=VARCHAR}, + #{item.otherSum,jdbcType=VARCHAR}, + #{item.total,jdbcType=VARCHAR}, + #{item.creator,jdbcType=DOUBLE}, + #{item.createTime}, + #{item.updateTime}, + #{item.deleteType}, + #{item.tenantKey,jdbcType=VARCHAR}, + #{item.paymentOrganization,jdbcType=DOUBLE}, + #{item.socialPaymentComBaseString,jdbcType=VARCHAR}, + #{item.fundPaymentComBaseString,jdbcType=VARCHAR}, + #{item.otherPaymentComBaseString,jdbcType=VARCHAR}, + #{item.subcompanyName,jdbcType=VARCHAR}, + #{item.subcompanyId,jdbcType=DOUBLE}, + #{item.departmentName,jdbcType=VARCHAR}, + #{item.departmentId,jdbcType=DOUBLE}, + #{item.jobtitleName,jdbcType=VARCHAR}, + #{item.jobtitleId,jdbcType=DOUBLE}, + #{item.jobcall,jdbcType=VARCHAR}, + #{item.jobcallId,jdbcType=DOUBLE}, + #{item.status,jdbcType=VARCHAR} + from dual + + + + + INSERT INTO hrsa_bill_detail_temp + (employee_id,bill_month,bill_status,payment_status,supplementary_month,resource_from,social_pay_org,social_account,social_scheme_id,social_payment_base_string, + fund_pay_org,fund_account,supplement_fund_account,fund_scheme_id,fund_payment_base_string,other_pay_org,other_scheme_id,other_payment_base_string,social_per_json, + social_per_sum,fund_per_json,fund_per_sum,other_per_json,other_per_sum,per_sum,social_com_json,social_com_sum,fund_com_json,fund_com_sum,other_com_json,other_com_sum, + com_sum,social_sum,fund_sum,other_sum,total,creator,create_time,update_time,delete_type,tenant_key,payment_organization, + social_payment_com_base_string,fund_payment_com_base_string,other_payment_com_base_string, + subcompany_name,subcompany_id,department_name,department_id,jobtitle_name,jobtitle_id,jobcall,jobcall_id,status) + VALUES + ( + #{item.employeeId}, + #{item.billMonth}, + #{item.billStatus}, + #{item.paymentStatus}, + #{item.supplementaryMonth}, + #{item.resourceFrom}, + #{item.socialPayOrg}, + #{item.socialAccount}, + #{item.socialSchemeId}, + #{item.socialPaymentBaseString}, + #{item.fundPayOrg}, + #{item.fundAccount}, + #{item.supplementFundAccount}, + #{item.fundSchemeId}, + #{item.fundPaymentBaseString}, + #{item.otherPayOrg}, + #{item.otherSchemeId}, + #{item.otherPaymentBaseString}, + #{item.socialPerJson}, + #{item.socialPerSum}, + #{item.fundPerJson}, + #{item.fundPerSum}, + #{item.otherPerJson}, + #{item.otherPerSum}, + #{item.perSum}, + #{item.socialComJson}, + #{item.socialComSum}, + #{item.fundComJson}, + #{item.fundComSum}, + #{item.otherComJson}, + #{item.otherComSum}, + #{item.comSum}, + #{item.socialSum}, + #{item.fundSum}, + #{item.otherSum}, + #{item.total}, + #{item.creator}, + #{item.createTime}, + #{item.updateTime}, + #{item.deleteType}, + #{item.tenantKey}, + #{item.paymentOrganization}, + #{item.socialPaymentComBaseString}, + #{item.fundPaymentComBaseString}, + #{item.otherPaymentComBaseString}, + #{item.subcompanyName}, + #{item.subcompanyId}, + #{item.departmentName}, + #{item.departmentId}, + #{item.jobtitleName}, + #{item.jobtitleId}, + #{item.jobcall}, + #{item.jobcallId}, + #{item.status} + ) + + + + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/siaccount/SIAccountUtilMapper.java b/src/com/engine/salary/mapper/siaccount/SIAccountUtilMapper.java new file mode 100644 index 000000000..6431ed141 --- /dev/null +++ b/src/com/engine/salary/mapper/siaccount/SIAccountUtilMapper.java @@ -0,0 +1,37 @@ +package com.engine.salary.mapper.siaccount; + +import com.engine.salary.entity.siaccount.dto.SIAccountUtilDTO; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; + +public interface SIAccountUtilMapper { + + List checkIfBusinessaccounting(Long id); + + /** + * 删除社保前校验是否已经被使用 + * @param id + * @return + */ + List checkBeforeDeleteSocialscheme(@Param("ids") Collection id); + /** + * 删除公积金前校验是否已经被使用 + * @param id + * @return + */ + List checkBeforeDeleteAccumulationfund(@Param("ids") Collection id); + /** + * 删除其他福利方案前校验是否已经被使用 + * @param id + * @return + */ + List checkBeforeDeleteOtherscheme(@Param("ids") Collection id); + /** + * 删除其他福利方案前校验是否已经被使用 + * @param id + * @return + */ + List checkBeforeDeleteBill(@Param("ids") Collection id,@Param("welfareTypeId") Integer welfareTypeId); +} diff --git a/src/com/engine/salary/mapper/siaccount/SIAccountUtilMapper.xml b/src/com/engine/salary/mapper/siaccount/SIAccountUtilMapper.xml new file mode 100644 index 000000000..6d02de0c6 --- /dev/null +++ b/src/com/engine/salary/mapper/siaccount/SIAccountUtilMapper.xml @@ -0,0 +1,90 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/siarchives/FundSchemeMapper.java b/src/com/engine/salary/mapper/siarchives/FundSchemeMapper.java new file mode 100644 index 000000000..07396a02b --- /dev/null +++ b/src/com/engine/salary/mapper/siarchives/FundSchemeMapper.java @@ -0,0 +1,111 @@ +package com.engine.salary.mapper.siarchives; + +import com.engine.salary.entity.siarchives.po.InsuranceArchivesEmployeePO; +import com.engine.salary.entity.siarchives.po.InsuranceArchivesFundSchemePO; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; + +/** + * @Author weaver_cl + * + * @Date 2022/3/15 + * @Version V1.0 + **/ +public interface FundSchemeMapper { + + /** + * 根据员工id获取 + * @param employeeId + * @return + */ + List getFundByEmployeeId(@Param("employeeIds")List employeeId); + + /** + * 根据人员id和个税扣缴人id获取记录 + * @param insuranceArchivesEmployeePO + * @return + */ + List getFundByEmployeeIdAndPayOrg(@Param("param") InsuranceArchivesEmployeePO insuranceArchivesEmployeePO); + + + /** + * 根据ids获取多条 + * @param ids + * @return + */ + List getFundById(@Param("ids")List ids); + + /** + * 根据id获取单条 + * @param id + * @return + */ + InsuranceArchivesFundSchemePO getOneById(@Param("id")Long id); + + /** + * 批量删除 + * @param singletonList + */ + void batchDeleteByEmployeeIds(@Param("employeeIds") Collection singletonList); + + /** + * 根据人员id和个税扣缴义务人删除档案 + * @param insuranceArchivesFundSchemePO + */ + void deleteByEmployeeIdAndPayOrg(@Param("param") InsuranceArchivesFundSchemePO insuranceArchivesFundSchemePO); + /** + * 批量保存 + * @param singletonList + */ + void batchSave(@Param("fundSchemePOS") List singletonList); + + /** + * 根据个税扣缴义务人id获取目标账单月可以进行缴纳的人员id + * 筛选条件为账单月是否在起始缴纳月和最后缴纳月之间 + * @param paymentOrganization + * @return + */ + List listCanPayEmpIds(@Param("paymentOrganization")Long paymentOrganization, @Param("billMonth")String billMonth, @Param("nonPayment") Integer nonPayment); + + List listAll(); + + int batchUpdate(@Param("collection") List pos); + + /** + * 批量更新最后缴纳月 + * @param ids + * @param endTime + */ + void batchUpdateEndTime(@Param("ids")List ids, @Param("endTime")String endTime); + + int updateById(InsuranceArchivesFundSchemePO insuranceArchivesFundSchemePO); + + /** + * 批量更新最后缴纳月为null + * @param ids + */ + void batchUpdateEndTimeToNull(@Param("ids")List ids); + + /** + * 根据id删除 + * @param fundArchiveDelIds + */ + void deleteByIds(@Param("ids")List fundArchiveDelIds); + + /** + * 新增 + * @param insuranceArchivesFundSchemePO + */ + void insert(InsuranceArchivesFundSchemePO insuranceArchivesFundSchemePO); + + /** + * 更新最后缴纳月 + * @param id + * @param endTime + */ + void updateEndTime(@Param("id")Long id, @Param("endTime")String endTime); + + List listBySchemeId(@Param("fundSchemeId")Long id, @Param("runStatuses")List runStatus); +} diff --git a/src/com/engine/salary/mapper/siarchives/FundSchemeMapper.xml b/src/com/engine/salary/mapper/siarchives/FundSchemeMapper.xml new file mode 100644 index 000000000..8cb8fc4e0 --- /dev/null +++ b/src/com/engine/salary/mapper/siarchives/FundSchemeMapper.xml @@ -0,0 +1,423 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + t.id + , t.employee_id + , t.non_payment + , t.welfare_type + , t.fund_start_time + , t.fund_end_time + , t.fund_scheme_id + , t.fund_account + , t.supplement_fund_account + , t.payment_organization + , t.under_take + , t.fund_payment_base_string + , t.fund_payment_com_base_string + , t.create_time + , t.update_time + , t.creator + , t.delete_type + , t.tenant_key + + + + + + + + + + + + + + + + + + UPDATE hrsa_fund_archives + SET delete_type = 1 + WHERE delete_type = 0 + + AND employee_id IN + + #{employeeId} + + + + + + + UPDATE hrsa_fund_archives + SET delete_type = 1 + WHERE delete_type = 0 + + AND id IN + + #{id} + + + + + + + + UPDATE hrsa_fund_archives + SET delete_type = 1 + WHERE employee_id = #{param.employeeId} + AND payment_organization = #{param.paymentOrganization} + AND delete_type = 0 + + + + + INSERT INTO hrsa_fund_archives( + fund_scheme_id, + fund_account, + fund_end_time, + fund_start_time, + fund_payment_base_string, + fund_payment_com_base_string, + supplement_fund_account, + create_time, + creator, + non_payment, + delete_type, + tenant_key, + under_take, + payment_organization, + update_time, + welfare_type, + employee_id) + VALUES + + ( + #{item.fundSchemeId}, + #{item.fundAccount}, + #{item.fundEndTime}, + #{item.fundStartTime}, + #{item.fundPaymentBaseString}, + #{item.fundPaymentComBaseString}, + #{item.supplementFundAccount}, + #{item.createTime}, + #{item.creator}, + #{item.nonPayment}, + #{item.deleteType}, + #{item.tenantKey}, + #{item.underTake}, + #{item.paymentOrganization}, + #{item.updateTime}, + #{item.welfareType}, + #{item.employeeId} + ) + + + + INSERT INTO hrsa_fund_archives( + fund_scheme_id, + fund_account, + fund_end_time, + fund_start_time, + fund_payment_base_string, + fund_payment_com_base_string, + supplement_fund_account, + create_time, + creator, + non_payment, + delete_type, + tenant_key, + under_take, + payment_organization, + update_time, + welfare_type, + employee_id) + + select + #{item.fundSchemeId,jdbcType=DOUBLE}, + #{item.fundAccount,jdbcType=VARCHAR}, + #{item.fundEndTime,jdbcType=VARCHAR}, + #{item.fundStartTime,jdbcType=VARCHAR}, + #{item.fundPaymentBaseString,jdbcType=VARCHAR}, + #{item.fundPaymentComBaseString,jdbcType=VARCHAR}, + #{item.supplementFundAccount,jdbcType=VARCHAR}, + #{item.createTime,jdbcType=DATE}, + #{item.creator,jdbcType=DOUBLE}, + #{item.nonPayment,jdbcType=INTEGER}, + #{item.deleteType,jdbcType=INTEGER}, + #{item.tenantKey,jdbcType=VARCHAR}, + #{item.underTake,jdbcType=INTEGER}, + #{item.paymentOrganization,jdbcType=DOUBLE}, + #{item.updateTime,jdbcType=DATE}, + #{item.welfareType,jdbcType=INTEGER}, + #{item.employeeId,jdbcType=DOUBLE} + from dual + + + + + INSERT INTO hrsa_fund_archives( + fund_scheme_id, + fund_account, + fund_end_time, + fund_start_time, + fund_payment_base_string, + fund_payment_com_base_string, + supplement_fund_account, + create_time, + creator, + non_payment, + delete_type, + tenant_key, + under_take, + payment_organization, + update_time, + welfare_type, + employee_id) + VALUES + ( + #{item.fundSchemeId}, + #{item.fundAccount}, + #{item.fundEndTime}, + #{item.fundStartTime}, + #{item.fundPaymentBaseString}, + #{item.fundPaymentComBaseString}, + #{item.supplementFundAccount}, + #{item.createTime}, + #{item.creator}, + #{item.nonPayment}, + #{item.deleteType}, + #{item.tenantKey}, + #{item.underTake}, + #{item.paymentOrganization}, + #{item.updateTime}, + #{item.welfareType}, + #{item.employeeId} + ) + + + + + + + + + + + + update hrsa_fund_archives + + + + + when id=#{item.id} then #{item.fundPaymentBaseString} + + + + + + + when id=#{item.id} then #{item.fundPaymentComBaseString} + + + + + + + when id=#{item.id} then #{item.deleteType} + + + + + where + id in + + #{item.id} + + + + + + UPDATE hrsa_fund_archives + SET fund_end_time = #{endTime} + WHERE delete_type = 0 + + AND id IN + + #{id} + + + + + + + UPDATE hrsa_fund_archives + + welfare_type = #{welfareType}, + fund_payment_base_string = #{fundPaymentBaseString}, + fund_payment_com_base_string = #{fundPaymentComBaseString}, + fund_scheme_id = #{fundSchemeId}, + fund_end_time = #{fundEndTime}, + fund_start_time = #{fundStartTime}, + non_payment = #{nonPayment}, + tenant_key = #{tenantKey}, + employee_id = #{employeeId}, + update_time = #{updateTime}, + under_take = #{underTake}, + fund_account = #{fundAccount}, + payment_organization = #{paymentOrganization}, + supplement_fund_account = #{supplementFundAccount}, + + WHERE id = #{id} AND delete_type = 0 + + + + + UPDATE hrsa_fund_archives + SET fund_end_time = null + WHERE delete_type = 0 + + AND id IN + + #{id} + + + + + UPDATE hrsa_fund_archives + SET fund_end_time = #{endTime} + WHERE delete_type = 0 + AND id = #{id} + + + + + INSERT INTO hrsa_fund_archives( + fund_scheme_id, + fund_account, + fund_end_time, + fund_start_time, + fund_payment_base_string, + fund_payment_com_base_string, + supplement_fund_account, + create_time, + creator, + non_payment, + delete_type, + tenant_key, + under_take, + payment_organization, + update_time, + welfare_type, + employee_id) + VALUES + ( + #{fundSchemeId}, + #{fundAccount}, + #{fundEndTime}, + #{fundStartTime}, + #{fundPaymentBaseString}, + #{fundPaymentComBaseString}, + #{supplementFundAccount}, + #{createTime}, + #{creator}, + #{nonPayment}, + #{deleteType}, + #{tenantKey}, + #{underTake}, + #{paymentOrganization}, + #{updateTime}, + #{welfareType}, + #{employeeId} + ) + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/siarchives/InsuranceBaseAdjustHistoryMapper.java b/src/com/engine/salary/mapper/siarchives/InsuranceBaseAdjustHistoryMapper.java new file mode 100644 index 000000000..39ab84890 --- /dev/null +++ b/src/com/engine/salary/mapper/siarchives/InsuranceBaseAdjustHistoryMapper.java @@ -0,0 +1,30 @@ +package com.engine.salary.mapper.siarchives; + +import com.engine.salary.entity.siarchives.dto.InsuranceArchivesBaseHistoryDTO; +import com.engine.salary.entity.siarchives.po.InsuranceArchivesBaseHistoryPO; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * @Author sy + * @Date 2023/10/16 + **/ +public interface InsuranceBaseAdjustHistoryMapper { + + /** + * 批量保存 + */ + void batchSave(@Param("infos") List infos); + + /** + * 根据人员id和个税扣缴义务人id获取基数调整记录 + */ + List listByEmployeeIdAndPayOrg(@Param("paymentOrganization")Long paymentOrganization, @Param("employeeId")Long employeeId); + + /** + * 根据操作人或操作对象获取基数调整记录 + */ + List listByEmployeeIdAndOperator(@Param("operator")Long operator, @Param("employeeId")Long employeeId); + List listByExtEmpIdAndOperator(@Param("operator")Long operator, @Param("employeeId")Long employeeId); +} diff --git a/src/com/engine/salary/mapper/siarchives/InsuranceBaseAdjustHistoryMapper.xml b/src/com/engine/salary/mapper/siarchives/InsuranceBaseAdjustHistoryMapper.xml new file mode 100644 index 000000000..0752177a1 --- /dev/null +++ b/src/com/engine/salary/mapper/siarchives/InsuranceBaseAdjustHistoryMapper.xml @@ -0,0 +1,243 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + t.id + , t.employee_id + , t.payment_organization + , t.welfare_type + , t.adjust_before_scheme_id + , t.adjust_after_scheme_id + , t.adjust_before_base_value + , t.adjust_after_base_value + , t.adjust_welfare_item_id + , t.payment_scope + , t.operator + , t.operate_time + , t.create_time + , t.update_time + , t.creator + , t.delete_type + , t.tenant_key + + + + INSERT INTO hrsa_insurance_base_history + (id,employee_id,payment_organization,welfare_type, + adjust_before_scheme_id,adjust_after_scheme_id, + adjust_before_base_value,adjust_after_base_value, + adjust_welfare_item_id,operator,operate_time, + tenant_key,creator,delete_type,create_time,update_time,payment_scope) + VALUES + + ( + #{item.id}, + #{item.employeeId}, + #{item.paymentOrganization}, + #{item.welfareType}, + #{item.adjustBeforeSchemeId}, + #{item.adjustAfterSchemeId}, + #{item.adjustBeforeBaseValue}, + #{item.adjustAfterBaseValue}, + #{item.adjustWelfareItemId}, + #{item.operator}, + #{item.operateTime}, + #{item.tenantKey}, + #{item.creator}, + #{item.deleteType}, + #{item.createTime}, + #{item.updateTime}, + #{item.paymentScope} + ) + + + + INSERT INTO hrsa_insurance_base_history + (id,employee_id,payment_organization,welfare_type, + adjust_before_scheme_id,adjust_after_scheme_id, + adjust_before_base_value,adjust_after_base_value, + adjust_welfare_item_id,operator,operate_time, + tenant_key,creator,delete_type,create_time,update_time,payment_scope) + + select + #{item.id,jdbcType=DOUBLE}, + #{item.employeeId,jdbcType=DOUBLE}, + #{item.paymentOrganization,jdbcType=DOUBLE}, + #{item.welfareType,jdbcType=DOUBLE}, + #{item.adjustBeforeSchemeId,jdbcType=DOUBLE}, + #{item.adjustAfterSchemeId,jdbcType=DOUBLE}, + #{item.adjustBeforeBaseValue,jdbcType=VARCHAR}, + #{item.adjustAfterBaseValue,jdbcType=VARCHAR}, + #{item.adjustWelfareItemId,jdbcType=DOUBLE}, + #{item.operator,jdbcType=DOUBLE}, + #{item.operateTime}, + #{item.tenantKey,jdbcType=VARCHAR}, + #{item.creator,jdbcType=DOUBLE}, + #{item.deleteType}, + #{item.createTime}, + #{item.updateTime}, + #{item.paymentScope} + from dual + + + + + INSERT INTO hrsa_insurance_base_history + (id,employee_id,payment_organization,welfare_type, + adjust_before_scheme_id,adjust_after_scheme_id, + adjust_before_base_value,adjust_after_base_value, + adjust_welfare_item_id,operator,operate_time, + tenant_key,creator,delete_type,create_time,update_time,payment_scope) + VALUES + ( + #{item.id}, + #{item.employeeId}, + #{item.paymentOrganization}, + #{item.welfareType}, + #{item.adjustBeforeSchemeId}, + #{item.adjustAfterSchemeId}, + #{item.adjustBeforeBaseValue}, + #{item.adjustAfterBaseValue}, + #{item.adjustWelfareItemId}, + #{item.operator}, + #{item.operateTime}, + #{item.tenantKey}, + #{item.creator}, + #{item.deleteType}, + #{item.createTime}, + #{item.updateTime}, + #{item.paymentScope} + ) + + + + + + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/siarchives/InsuranceBaseInfoMapper.java b/src/com/engine/salary/mapper/siarchives/InsuranceBaseInfoMapper.java new file mode 100644 index 000000000..4e933213d --- /dev/null +++ b/src/com/engine/salary/mapper/siarchives/InsuranceBaseInfoMapper.java @@ -0,0 +1,139 @@ +package com.engine.salary.mapper.siarchives; + +import com.engine.salary.entity.siarchives.param.InsuranceArchivesListParam; +import com.engine.salary.entity.siarchives.po.InsuranceArchivesBaseInfoPO; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; + +/** + * @Author sy + * @Date 2022/10/08 + **/ +public interface InsuranceBaseInfoMapper { + + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + List listByEmployeeIds(@Param("employeeIds")Collection employeeIds); + + /** + * 查询对应id集合的记录 + * + * @return 返回集合,没有返回空List + */ + List listByIds(@Param("ids")Collection ids); + + /** + * 查询对应id的记录 + */ + InsuranceArchivesBaseInfoPO getById(@Param("id")Long id); + + /** + * 获取当前福利档案基础信息(由当前的社保、公积金、其他福利信息表获取) + * 当设置employeeIds时,则是通过人员id、社保、公积金、其他福利信息表获取指定人员的福利档案基础信息 + */ + List getInsuranceBaseInfoListByInsuranceDetail(@Param("employeeIds")List employeeIds); + + /** + * 获取当前福利档案基础信息(由福利档案基础信息表获取) + */ + List getInsuranceBaseInfoList(); + + /** + * 批量保存 + */ + void batchSave(@Param("infos") List infos); + + /** + * 批量删除 + */ + void batchDeleteByEmployeeIds(@Param("employeeIds")List employeeIds); + + /** + * 根据人员id和个税扣缴义务人删除档案 + * @param insuranceArchivesBaseInfoPO + */ + void deleteByEmployeeIdAndPayOrg(@Param("param") InsuranceArchivesBaseInfoPO insuranceArchivesBaseInfoPO); + /** + * 根据个税扣缴义务人id获取基础信息列表 + * @param paymentOrganization + * @return + */ + List getSocialByPaymentOrganization(@Param("paymentOrganization")Long paymentOrganization); + + /** + * 获取可以置为正在缴纳的人员基础信息列表 + * @return + */ + List getRePayList(String today); + + /** + * 获取可以置为待减员的人员基础信息列表 + * @return + */ + List getReStayDelList(String today); + + /** + * 根据人事状态和社保执行状态获取基础信息列表 + * @param + * @return + */ + List getAbnormalList(@Param("param") InsuranceArchivesListParam param); + + /** + * 根据个税扣缴义务人和人员id获取单条数据 + */ + InsuranceArchivesBaseInfoPO getOneByEmployeeIdAndPayOrg(@Param("paymentOrganization")Long paymentOrganization, @Param("employeeId")Long employeeId); + + /** + * 根据ids重置runStatus + * @param po + */ + void updateRunStatusByIds(InsuranceArchivesBaseInfoPO po); + + /** + * 根据employeeIds重置runStatus + * @param po + */ + void updateRunStatusByEmployeeIds(InsuranceArchivesBaseInfoPO po); + + /** + * 批量更新 + * + * @param insuranceArchivesBaseInfoPOS + */ + void batchUpdate(@Param("collection") Collection insuranceArchivesBaseInfoPOS); + + /** + * 根据id删除 + * @param archiveDelIds + */ + void deleteByIds(@Param("ids")List archiveDelIds); + + /** + * 根据id更新 + * + * @param po + */ + void updateById(InsuranceArchivesBaseInfoPO po); + + /** + * 获取没有设置社保、公积金最后缴纳月的档案 + * @param employeeIds + * @return + */ + List listEndDateIsNull(@Param("employeeIds") List employeeIds); + + /** + * 获取没有设置社保、公积金最后缴纳月的档案 + * @param employeeIds + * @return + */ + List listStartDateIsNull(@Param("employeeIds") List employeeIds); +} diff --git a/src/com/engine/salary/mapper/siarchives/InsuranceBaseInfoMapper.xml b/src/com/engine/salary/mapper/siarchives/InsuranceBaseInfoMapper.xml new file mode 100644 index 000000000..d42fc0d04 --- /dev/null +++ b/src/com/engine/salary/mapper/siarchives/InsuranceBaseInfoMapper.xml @@ -0,0 +1,417 @@ + + + + + + + + + + + + + + + + + + + + + + + t.id + , t.employee_id + , t.payment_organization + , t.social_archives_id + , t.fund_archives_id + , t.other_archives_id + , t.run_status + , t.create_time + , t.update_time + , t.creator + , t.delete_type + , t.tenant_key + , t.employee_type + + + + + + + + + + + + + + + + + + + INSERT INTO hrsa_insurance_base_info + (id,employee_id,payment_organization,social_archives_id,fund_archives_id,other_archives_id,tenant_key,creator,delete_type,create_time,update_time,run_status, employee_type) + VALUES + + ( + #{item.id}, + #{item.employeeId}, + #{item.paymentOrganization}, + #{item.socialArchivesId}, + #{item.fundArchivesId}, + #{item.otherArchivesId}, + #{item.tenantKey}, + #{item.creator}, + #{item.deleteType}, + #{item.createTime}, + #{item.updateTime}, + #{item.runStatus}, + #{item.employeeType} + ) + + + + INSERT INTO hrsa_insurance_base_info + (id,employee_id,payment_organization,social_archives_id,fund_archives_id,other_archives_id,tenant_key,creator,delete_type,create_time,update_time,run_status, employee_type) + + select + #{item.id,jdbcType=DOUBLE}, + #{item.employeeId,jdbcType=DOUBLE}, + #{item.paymentOrganization,jdbcType=DOUBLE}, + #{item.socialArchivesId,jdbcType=DOUBLE}, + #{item.fundArchivesId,jdbcType=DOUBLE}, + #{item.otherArchivesId,jdbcType=DOUBLE}, + #{item.tenantKey,jdbcType=VARCHAR}, + #{item.creator,jdbcType=DOUBLE}, + #{item.deleteType}, + #{item.createTime}, + #{item.updateTime}, + #{item.runStatus,jdbcType=VARCHAR}, + #{item.employeeType} + from dual + + + + + INSERT INTO hrsa_insurance_base_info + (id,employee_id,payment_organization,social_archives_id,fund_archives_id,other_archives_id,tenant_key,creator,delete_type,create_time,update_time,run_status, employee_type) + VALUES + ( + #{item.id}, + #{item.employeeId}, + #{item.paymentOrganization}, + #{item.socialArchivesId}, + #{item.fundArchivesId}, + #{item.otherArchivesId}, + #{item.tenantKey}, + #{item.creator}, + #{item.deleteType}, + #{item.createTime}, + #{item.updateTime}, + #{item.runStatus}, + #{item.employeeType} + ) + + + + + + UPDATE hrsa_insurance_base_info + SET delete_type = 1 + WHERE delete_type = 0 + + AND employee_id IN + + #{employeeId} + + + + + + UPDATE hrsa_insurance_base_info + SET delete_type = 1 + WHERE delete_type = 0 + + AND id IN + + #{id} + + + + + + + UPDATE hrsa_insurance_base_info + SET delete_type = 1 + WHERE employee_id = #{param.employeeId} + AND payment_organization = #{param.paymentOrganization} + AND delete_type = 0 + + + + + + + + + + + + + + + + + + + UPDATE hrsa_insurance_base_info + + run_status=#{runStatus} + + WHERE id IN + + #{id} + + + + + + UPDATE hrsa_insurance_base_info + + run_status=#{runStatus} + + WHERE employee_id IN + + #{employeeId} + + + + + + UPDATE hrsa_insurance_base_info + + + + WHEN id = #{item.id} THEN #{item.runStatus} + + + + + WHEN id = #{item.id} THEN #{item.updateTime} + + + + + WHEN id = #{item.id} THEN #{item.deleteType} + + + + WHERE delete_type = 0 + AND id IN + + #{item.id} + + + + + UPDATE hrsa_insurance_base_info + + + employee_id = #{employeeId}, + payment_organization = #{paymentOrganization}, + social_archives_id = #{socialArchivesId}, + fund_archives_id = #{fundArchivesId}, + other_archives_id = #{otherArchivesId}, + run_status = #{runStatus}, + create_time = #{createTime}, + update_time = #{updateTime}, + creator = #{creator}, + delete_type = #{deleteType}, + tenant_key = #{tenantKey}, + + WHERE id = #{id} + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/siarchives/OtherSchemeMapper.java b/src/com/engine/salary/mapper/siarchives/OtherSchemeMapper.java new file mode 100644 index 000000000..86b237085 --- /dev/null +++ b/src/com/engine/salary/mapper/siarchives/OtherSchemeMapper.java @@ -0,0 +1,110 @@ +package com.engine.salary.mapper.siarchives; + +import com.engine.salary.entity.siarchives.po.InsuranceArchivesEmployeePO; +import com.engine.salary.entity.siarchives.po.InsuranceArchivesOtherSchemePO; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; + +/** + * @Author weaver_cl + * + * @Date 2022/3/15 + * @Version V1.0 + **/ +public interface OtherSchemeMapper { + + /** + * 根据员工id获取 + * @param employeeId + * @return + */ + List getOtherByEmployeeId(@Param("employeeIds")List employeeId); + + /** + * 根据人员id和个税扣缴人id获取记录 + * @param insuranceArchivesEmployeePO + * @return + */ + List getOtherByEmployeeIdAndPayOrg(@Param("param") InsuranceArchivesEmployeePO insuranceArchivesEmployeePO); + + /** + * 根据id获取 + * @param ids + * @return + */ + List getOtherById(@Param("ids")List ids); + + /** + * 根据id获取单条 + * @param id + * @return + */ + InsuranceArchivesOtherSchemePO getOneById(@Param("id")Long id); + + /** + * 批量删除 + * @param singletonList + */ + void batchDeleteByEmployeeIds(@Param("employeeIds") Collection singletonList); + + /** + * 根据人员id和个税扣缴义务人删除档案 + * @param insuranceArchivesOtherSchemePO + */ + void deleteByEmployeeIdAndPayOrg(@Param("param") InsuranceArchivesOtherSchemePO insuranceArchivesOtherSchemePO); + /** + * 批量保存 + * @param singletonList + */ + void batchSave(@Param("otherSchemePOS") List singletonList); + + /** + * 根据个税扣缴义务人id获取目标账单月可以进行缴纳的人员id + * 筛选条件为账单月是否在起始缴纳月和最后缴纳月之间 + * @param paymentOrganization + * @return + */ + List listCanPayEmpIds(@Param("paymentOrganization")Long paymentOrganization, @Param("billMonth")String billMonth, @Param("nonPayment") Integer nonPayment); + + List listAll(); + + int batchUpdate(@Param("collection") List pos); + + /** + * 批量更新最后缴纳月 + * @param ids + * @param endTime + */ + void batchUpdateEndTime(@Param("ids")List ids, @Param("endTime")String endTime); + + int updateById(InsuranceArchivesOtherSchemePO insuranceArchivesOtherSchemePO); + + /** + * 批量更新最后缴纳月为null + * @param ids + */ + void batchUpdateEndTimeToNull(@Param("ids")List ids); + + /** + * 根据id删除 + * @param otherArchiveDelIds + */ + void deleteByIds(@Param("ids") List otherArchiveDelIds); + + /** + * 新增 + * @param insuranceArchivesOtherSchemePO + */ + void insert(InsuranceArchivesOtherSchemePO insuranceArchivesOtherSchemePO); + + /** + * 更新最后缴纳月 + * @param id + * @param endTime + */ + void updateEndTime(@Param("id")Long id, @Param("endTime")String endTime); + + List listBySchemeId(@Param("schemeId") Long schemeId, @Param("runStatuses") List runStatuses); +} diff --git a/src/com/engine/salary/mapper/siarchives/OtherSchemeMapper.xml b/src/com/engine/salary/mapper/siarchives/OtherSchemeMapper.xml new file mode 100644 index 000000000..7b9c59fb5 --- /dev/null +++ b/src/com/engine/salary/mapper/siarchives/OtherSchemeMapper.xml @@ -0,0 +1,406 @@ + + + + + + + + + + + + + + + + + + + + + + + + + t.id + , t.employee_id + , t.non_payment + , t.welfare_type + , t.other_start_time + , t.other_end_time + , t.other_scheme_id + , t.payment_organization + , t.under_take + , t.other_payment_base_string + , t.other_payment_com_base_string + , t.create_time + , t.update_time + , t.creator + , t.delete_type + , t.tenant_key + + + + + + + + + + + + + + + + + + UPDATE hrsa_other_archives + SET delete_type = 1 + WHERE delete_type = 0 + AND employee_id IN + + + #{employeeId} + + + + + + + UPDATE hrsa_other_archives + SET delete_type = 1 + WHERE delete_type = 0 + AND id IN + + + #{id} + + + + + + + UPDATE hrsa_other_archives + SET delete_type = 1 + WHERE employee_id = #{param.employeeId} + AND payment_organization = #{param.paymentOrganization} + AND delete_type = 0 + + + + + INSERT INTO hrsa_other_archives( + other_scheme_id, + other_start_time, + under_take, + tenant_key, + welfare_type, + other_end_time, + employee_id, + delete_type, + update_time, + create_time, + non_payment, + creator, + payment_organization, + other_payment_base_string, + other_payment_com_base_string) + VALUES + + ( + #{item.otherSchemeId}, + #{item.otherStartTime}, + #{item.underTake}, + #{item.tenantKey}, + #{item.welfareType}, + #{item.otherEndTime}, + #{item.employeeId}, + #{item.deleteType}, + #{item.updateTime}, + #{item.createTime}, + #{item.nonPayment}, + #{item.creator}, + #{item.paymentOrganization}, + #{item.otherPaymentBaseString}, + #{item.otherPaymentComBaseString} + ) + + + + INSERT INTO hrsa_other_archives( + other_scheme_id, + other_start_time, + under_take, + tenant_key, + welfare_type, + other_end_time, + employee_id, + delete_type, + update_time, + create_time, + non_payment, + creator, + payment_organization, + other_payment_base_string, + other_payment_com_base_string) + + select + #{item.otherSchemeId,jdbcType=DOUBLE}, + #{item.otherStartTime,jdbcType=VARCHAR}, + #{item.underTake,jdbcType=INTEGER}, + #{item.tenantKey,jdbcType=VARCHAR}, + #{item.welfareType,jdbcType=INTEGER}, + #{item.otherEndTime,jdbcType=VARCHAR}, + #{item.employeeId,jdbcType=DOUBLE}, + #{item.deleteType,jdbcType=INTEGER}, + #{item.updateTime,jdbcType=DATE}, + #{item.createTime,jdbcType=DATE}, + #{item.nonPayment,jdbcType=INTEGER}, + #{item.creator,jdbcType=DOUBLE}, + #{item.paymentOrganization,jdbcType=DOUBLE}, + #{item.otherPaymentBaseString,jdbcType=VARCHAR}, + #{item.otherPaymentComBaseString,jdbcType=VARCHAR} + from dual + + + + + INSERT INTO hrsa_other_archives( + other_scheme_id, + other_start_time, + under_take, + tenant_key, + welfare_type, + other_end_time, + employee_id, + delete_type, + update_time, + create_time, + non_payment, + creator, + payment_organization, + other_payment_base_string, + other_payment_com_base_string) + VALUES + ( + #{item.otherSchemeId}, + #{item.otherStartTime}, + #{item.underTake}, + #{item.tenantKey}, + #{item.welfareType}, + #{item.otherEndTime}, + #{item.employeeId}, + #{item.deleteType}, + #{item.updateTime}, + #{item.createTime}, + #{item.nonPayment}, + #{item.creator}, + #{item.paymentOrganization}, + #{item.otherPaymentBaseString}, + #{item.otherPaymentComBaseString} + ) + + + + + + + + + + + + update hrsa_other_archives + + + + + when id=#{item.id} then #{item.employeeId} + + + + + + + when id=#{item.id} then #{item.otherPaymentBaseString} + + + + + + + when id=#{item.id} then #{item.otherPaymentComBaseString} + + + + + + + when id=#{item.id} then #{item.deleteType} + + + + + where + id in + + #{item.id} + + + + + + UPDATE hrsa_other_archives + SET other_end_time = #{endTime} + WHERE delete_type = 0 + + AND id IN + + #{id} + + + + + + + UPDATE hrsa_other_archives + + welfare_type = #{welfareType}, + other_payment_base_string = #{otherPaymentBaseString}, + other_payment_com_base_string = #{otherPaymentComBaseString}, + other_scheme_id = #{otherSchemeId}, + other_end_time = #{otherEndTime}, + other_start_time = #{otherStartTime}, + non_payment = #{nonPayment}, + tenant_key = #{tenantKey}, + employee_id = #{employeeId}, + update_time = #{updateTime}, + under_take = #{underTake}, + payment_organization = #{paymentOrganization}, + + WHERE id = #{id} AND delete_type = 0 + + + + + UPDATE hrsa_other_archives + SET other_end_time = null + WHERE delete_type = 0 + + AND id IN + + #{id} + + + + + + UPDATE hrsa_other_archives + SET other_end_time = #{endTime} + WHERE delete_type = 0 + AND id = #{id} + + + + INSERT INTO hrsa_other_archives( + other_scheme_id, + other_start_time, + under_take, + tenant_key, + welfare_type, + other_end_time, + employee_id, + delete_type, + update_time, + create_time, + non_payment, + creator, + payment_organization, + other_payment_base_string, + other_payment_com_base_string) + VALUES + ( + #{otherSchemeId}, + #{otherStartTime}, + #{underTake}, + #{tenantKey}, + #{welfareType}, + #{otherEndTime}, + #{employeeId}, + #{deleteType}, + #{updateTime}, + #{createTime}, + #{nonPayment}, + #{creator}, + #{paymentOrganization}, + #{otherPaymentBaseString}, + #{otherPaymentComBaseString} + ) + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/siarchives/SocialSchemeMapper.java b/src/com/engine/salary/mapper/siarchives/SocialSchemeMapper.java new file mode 100644 index 000000000..101546745 --- /dev/null +++ b/src/com/engine/salary/mapper/siarchives/SocialSchemeMapper.java @@ -0,0 +1,141 @@ +package com.engine.salary.mapper.siarchives; + +import com.engine.salary.entity.siarchives.param.InsuranceArchivesListParam; +import com.engine.salary.entity.siarchives.po.InsuranceArchivesEmployeePO; +import com.engine.salary.entity.siarchives.po.InsuranceArchivesSocialSchemePO; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; + +/** + * @Author weaver_cl + * + * @Date 2022/3/15 + * @Version V1.0 + **/ +public interface SocialSchemeMapper { + + /** + * 根据员工id获取 + * @param employeeId + * @return + */ + List getSocialByEmployeeId(@Param("employeeIds")List employeeId); + + /** + * 根据人员id和个税扣缴人id获取记录 + * @param insuranceArchivesEmployeePO + * @return + */ + List getSocialByEmployeeIdAndPayOrg(@Param("param")InsuranceArchivesEmployeePO insuranceArchivesEmployeePO); + + /** + * 根据ids获取多条 + * @param ids + * @return + */ + List getSocialById(@Param("ids")List ids); + + /** + * 根据id获取单条 + * @param id + * @return + */ + InsuranceArchivesSocialSchemePO getOneById(@Param("id")Long id); + + /** + * 批量删除 + * @param singletonList + */ + void batchDeleteByEmployeeIds(@Param("employeeIds") Collection singletonList); + + /** + * 根据人员id和个税扣缴义务人删除档案 + * @param insuranceArchivesSocialSchemePO + */ + void deleteByEmployeeIdAndPayOrg(@Param("param") InsuranceArchivesSocialSchemePO insuranceArchivesSocialSchemePO); + /** + * 批量保存 + * @param singletonList + */ + void batchSave(@Param("socialSchemePOS") List singletonList); + + /** + * 人员档案信息 + * @param param + * @return + */ + List listPageEmployeePOS(@Param("param") InsuranceArchivesListParam param); + + /** + * 信息提示 + * @return + */ + List tips(); + + + List queryEmployeeList(@Param("param") InsuranceArchivesListParam param); + + List queryExtEmployeeList(@Param("param") InsuranceArchivesListParam param); + + /** + * 根据社保缴纳组织id获取 + * @param paymentOrganization + * @return + */ + List getSocialByPaymentOrganization(@Param("paymentOrganization")Long paymentOrganization); + + /** + * 根据个税扣缴义务人id获取目标账单月可以进行缴纳的人员id + * 筛选条件为账单月是否在起始缴纳月和最后缴纳月之间 + * @param paymentOrganization + * @return + */ + List listCanPayEmpIds(@Param("paymentOrganization")Long paymentOrganization, @Param("billMonth")String billMonth, @Param("nonPayment")Integer nonPayment); + + List listAll(); + + int batchUpdate(@Param("collection") List insuranceArchivesSocialSchemePos); + + /** + * 批量更新最后缴纳月 + * @param ids + * @param endTime + */ + void batchUpdateEndTime(@Param("ids")List ids, @Param("endTime")String endTime); + + /** + * 更新,更新全部字段 + * @param insuranceArchivesSocialSchemePO + * @return + */ + int updateById(InsuranceArchivesSocialSchemePO insuranceArchivesSocialSchemePO); + + /** + * 批量更新最后缴纳月为null + * @param ids + */ + void batchUpdateEndTimeToNull(@Param("ids")List ids); + + /** + * 根据id删除 + * @param socialArchiveDelIds + */ + void deleteByIds(@Param("ids")List socialArchiveDelIds); + + /** + * 新增 + * @param insuranceArchivesSocialSchemePO + */ + void insert(InsuranceArchivesSocialSchemePO insuranceArchivesSocialSchemePO); + + /** + * 更新最后缴纳月 + * @param id + * @param endTime + */ + void updateEndTime(@Param("id")Long id, @Param("endTime")String endTime); + + List listBySchemeId(@Param("schemeId")Long schemeId, @Param("runStatuses")List runStatus); +} diff --git a/src/com/engine/salary/mapper/siarchives/SocialSchemeMapper.xml b/src/com/engine/salary/mapper/siarchives/SocialSchemeMapper.xml new file mode 100644 index 000000000..6bf5b3da9 --- /dev/null +++ b/src/com/engine/salary/mapper/siarchives/SocialSchemeMapper.xml @@ -0,0 +1,1063 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + t.id + , t.employee_id + , t.non_payment + , t.welfare_type + , t.social_start_time + , t.social_end_time + , t.social_scheme_id + , t.social_account + , t.payment_organization + , t.under_take + , t.social_payment_base_string + , t.social_payment_com_base_string + , t.create_time + , t.update_time + , t.creator + , t.delete_type + , t.tenant_key + + + + + + + + + + + + + + + + + + UPDATE hrsa_social_archives + SET delete_type = 1 + WHERE delete_type = 0 + + AND employee_id IN + + #{employeeId} + + + + + + UPDATE hrsa_social_archives + SET delete_type = 1 + WHERE delete_type = 0 + + AND id IN + + #{id} + + + + + + + UPDATE hrsa_social_archives + SET delete_type = 1 + WHERE employee_id = #{param.employeeId} + AND payment_organization = #{param.paymentOrganization} + AND delete_type = 0 + + + + + INSERT INTO hrsa_social_archives( + welfare_type, + delete_type, + social_payment_base_string, + social_payment_com_base_string, + social_scheme_id, + create_time, + social_end_time, + social_start_time, + creator, + non_payment, + tenant_key, + employee_id, + update_time, + under_take, + social_account, + payment_organization) + VALUES + + ( + #{item.welfareType}, + #{item.deleteType}, + #{item.socialPaymentBaseString}, + #{item.socialPaymentComBaseString}, + #{item.socialSchemeId}, + #{item.createTime}, + #{item.socialEndTime}, + #{item.socialStartTime}, + #{item.creator}, + #{item.nonPayment}, + #{item.tenantKey}, + #{item.employeeId}, + #{item.updateTime}, + #{item.underTake}, + #{item.socialAccount}, + #{item.paymentOrganization} + ) + + + + INSERT INTO hrsa_social_archives( + welfare_type, + delete_type, + social_payment_base_string, + social_payment_com_base_string, + social_scheme_id, + create_time, + social_end_time, + social_start_time, + creator, + non_payment, + tenant_key, + employee_id, + update_time, + under_take, + social_account, + payment_organization) + + select + #{item.welfareType,jdbcType=INTEGER}, + #{item.deleteType,jdbcType=INTEGER}, + #{item.socialPaymentBaseString,jdbcType=VARCHAR}, + #{item.socialPaymentComBaseString,jdbcType=VARCHAR}, + #{item.socialSchemeId,jdbcType=DOUBLE}, + #{item.createTime,jdbcType=DATE}, + #{item.socialEndTime,jdbcType=VARCHAR}, + #{item.socialStartTime,jdbcType=VARCHAR}, + #{item.creator,jdbcType=DOUBLE}, + #{item.nonPayment,jdbcType=INTEGER}, + #{item.tenantKey,jdbcType=VARCHAR}, + #{item.employeeId,jdbcType=DOUBLE}, + #{item.updateTime,jdbcType=DATE}, + #{item.underTake,jdbcType=INTEGER}, + #{item.socialAccount,jdbcType=VARCHAR}, + #{item.paymentOrganization,jdbcType=DOUBLE} + from dual + + + + + INSERT INTO hrsa_social_archives( + welfare_type, + delete_type, + social_payment_base_string, + social_payment_com_base_string, + social_scheme_id, + create_time, + social_end_time, + social_start_time, + creator, + non_payment, + tenant_key, + employee_id, + update_time, + under_take, + social_account, + payment_organization) + VALUES + ( + #{item.welfareType}, + #{item.deleteType}, + #{item.socialPaymentBaseString}, + #{item.socialPaymentComBaseString}, + #{item.socialSchemeId}, + #{item.createTime}, + #{item.socialEndTime}, + #{item.socialStartTime}, + #{item.creator}, + #{item.nonPayment}, + #{item.tenantKey}, + #{item.employeeId}, + #{item.updateTime}, + #{item.underTake}, + #{item.socialAccount}, + #{item.paymentOrganization} + ) + + + + + + + + + + AND + ( + a.lastname like CONCAT('%',#{param.keyword},'%') + OR a.workcode like CONCAT('%',#{param.keyword},'%') + ) + + + + + AND + ( + e.lastname like '%'||#{param.keyword}||'%' + OR e.workcode like '%'||#{param.keyword}||'%' + ) + + + + + AND + ( + e.lastname like '%'+#{param.keyword}+'%' + OR e.workcode like '%'+#{param.keyword}+'%' + ) + + + + + + + AND a.departmentid IN + + #{departmentId} + + + + + AND a.status IN + + #{status} + + + + + AND a.jobtitle IN + + #{position} + + + + + AND a.companystartdate between #{param.hiredateStart} and #{param.hiredateEnd} + + + + AND f.dismissdate between #{param.dimissionDateStart} and #{param.dimissionDateEnd} + + + + AND c.social_scheme_id = #{param.siSchemeId} + + + AND d.fund_scheme_id = #{param.fundSchemeId} + + + AND e.other_scheme_id = #{param.otherSchemeId} + + + + + + + + + + + + + + + + + + + AND + ( + e.lastname like CONCAT('%',#{param.keyword},'%') + ) + + + AND e.lastname like CONCAT('%',#{param.userName},'%') + + + AND e.workcode like CONCAT('%',#{param.jobNum},'%') + + + AND e.departmentid IN + + #{departmentId} + + + + AND e.subcompanyid1 IN + + #{subcompanyId} + + + + AND e.STATUS IN + + #{userStatus} + + + + AND e.jobtitle IN + + #{position} + + + + AND e.companystartdate > #{param.hiredateStart} + + + AND e.companystartdate < #{param.hiredateEnd} + + + AND e.enddate > #{param.dimissionDateStart} + + + AND e.enddate < #{param.dimissionDateEnd} + + + AND siSchemeId = #{param.siSchemeId} + + + AND fundSchemeId = #{param.fundSchemeId} + + + AND otherSchemeId = #{param.otherSchemeId} + + + AND base.payment_organization = #{param.taxAgentId} + + + AND base.run_status IN + + #{runStatus} + + + + + AND e.ID IN + + #{item} + + + + + AND base.id IN + + #{item} + + + + + + + AND + ( + e.lastname like '%'+#{param.keyword}+'%' + ) + + + AND e.lastname like '%'+#{param.userName}+'%' + + + AND e.workcode like '%'+#{param.jobNum}+'%' + + + AND e.departmentid IN + + #{departmentId} + + + + AND e.subcompanyid1 IN + + #{subcompanyId} + + + + AND e.STATUS IN + + #{userStatus} + + + + AND e.jobtitle IN + + #{position} + + + + AND e.companystartdate > #{param.hiredateStart} + + + AND e.companystartdate < #{param.hiredateEnd} + + + AND e.enddate > #{param.dimissionDateStart} + + + AND e.enddate < #{param.dimissionDateEnd} + + + AND siSchemeId = #{param.siSchemeId} + + + AND fundSchemeId = #{param.fundSchemeId} + + + AND otherSchemeId = #{param.otherSchemeId} + + + AND base.payment_organization = #{param.taxAgentId} + + + AND base.run_status IN + + #{runStatus} + + + + AND e.ID IN + + #{item} + + + + AND base.id IN + + #{item} + + + + + + + + AND + ( + e.lastname like '%'||#{param.keyword}||'%' + ) + + + AND e.lastname like '%'||#{param.userName}||'%' + + + AND e.workcode like '%'||#{param.jobNum}||'%' + + + AND e.departmentid IN + + #{departmentId} + + + + AND e.subcompanyid1 IN + + #{subcompanyId} + + + + AND e.STATUS IN + + #{userStatus} + + + + AND e.jobtitle IN + + #{position} + + + + AND e.companystartdate > #{param.hiredateStart} + + + AND e.companystartdate < #{param.hiredateEnd} + + + AND e.enddate > #{param.dimissionDateStart} + + + AND e.enddate < #{param.dimissionDateEnd} + + + AND siSchemeId = #{param.siSchemeId} + + + AND fundSchemeId = #{param.fundSchemeId} + + + AND otherSchemeId = #{param.otherSchemeId} + + + AND base.payment_organization = #{param.taxAgentId} + + + AND base.run_status IN + + #{runStatus} + + + + AND e.ID IN + + #{item} + + + + AND base.id IN + + #{item} + + + + + + + AND + ( + e.username like CONCAT('%',#{param.keyword},'%') + ) + + + AND e.username like CONCAT('%',#{param.userName},'%') + + + AND e.workcode like CONCAT('%',#{param.jobNum},'%') + + + AND e.department_id IN + + #{departmentId} + + + + AND e.subcompany_id IN + + #{subcompanyId} + + + + AND e.status IN + + #{userStatus} + + + + AND e.jobtitle_id IN + + #{position} + + + + AND e.companystartdate > #{param.hiredateStart} + + + AND e.companystartdate < #{param.hiredateEnd} + + + AND siSchemeId = #{param.siSchemeId} + + + AND fundSchemeId = #{param.fundSchemeId} + + + AND otherSchemeId = #{param.otherSchemeId} + + + AND base.payment_organization = #{param.taxAgentId} + + + AND base.run_status IN + + #{runStatus} + + + + + AND e.id IN + + #{item} + + + + + AND base.id IN + + #{item} + + + + + + + AND + ( + e.username like '%'+#{param.keyword}+'%' + ) + + + AND e.username like '%'+#{param.userName}+'%' + + + AND e.workcode like '%'+#{param.jobNum}+'%' + + + AND e.department_id IN + + #{departmentId} + + + + AND e.subcompany_id IN + + #{subcompanyId} + + + + AND e.status IN + + #{userStatus} + + + + AND e.jobtitle_id IN + + #{position} + + + + AND e.companystartdate > #{param.hiredateStart} + + + AND e.companystartdate < #{param.hiredateEnd} + + + + AND siSchemeId = #{param.siSchemeId} + + + AND fundSchemeId = #{param.fundSchemeId} + + + AND otherSchemeId = #{param.otherSchemeId} + + + AND base.payment_organization = #{param.taxAgentId} + + + AND base.run_status IN + + #{runStatus} + + + + AND e.id IN + + #{item} + + + + AND base.id IN + + #{item} + + + + + + + + AND + ( + e.username like '%'||#{param.keyword}||'%' + ) + + + AND e.username like '%'||#{param.userName}||'%' + + + AND e.workcode like '%'||#{param.jobNum}||'%' + + + AND e.department_id IN + + #{departmentId} + + + + AND e.subcompany_id IN + + #{subcompanyId} + + + + AND e.status IN + + #{userStatus} + + + + AND e.jobtitle_id IN + + #{position} + + + + AND e.companystartdate > #{param.hiredateStart} + + + AND e.companystartdate < #{param.hiredateEnd} + + + AND siSchemeId = #{param.siSchemeId} + + + AND fundSchemeId = #{param.fundSchemeId} + + + AND otherSchemeId = #{param.otherSchemeId} + + + AND base.payment_organization = #{param.taxAgentId} + + + AND base.run_status IN + + #{runStatus} + + + + AND e.id IN + + #{item} + + + + AND base.id IN + + #{item} + + + + + + + + + + + + + + + + update hrsa_social_archives + + + + + when id=#{item.id} then #{item.socialPaymentBaseString} + + + + + + + when id=#{item.id} then #{item.socialPaymentComBaseString} + + + + + + + when id=#{item.id} then #{item.deleteType} + + + + + where + id in + + #{item.id} + + + + + + UPDATE hrsa_social_archives + SET social_end_time = #{endTime} + WHERE delete_type = 0 + + AND id IN + + #{id} + + + + + + + UPDATE hrsa_social_archives + + welfare_type = #{welfareType}, + social_payment_base_string = #{socialPaymentBaseString}, + social_payment_com_base_string = #{socialPaymentComBaseString}, + social_scheme_id = #{socialSchemeId}, + social_end_time = #{socialEndTime}, + social_start_time = #{socialStartTime}, + non_payment = #{nonPayment}, + tenant_key = #{tenantKey}, + employee_id = #{employeeId}, + update_time = #{updateTime}, + under_take = #{underTake}, + social_account = #{socialAccount}, + payment_organization = #{paymentOrganization}, + + WHERE id = #{id} AND delete_type = 0 + + + + + UPDATE hrsa_social_archives + SET social_end_time = null + WHERE delete_type = 0 + + AND id IN + + #{id} + + + + + + UPDATE hrsa_social_archives + SET social_end_time = #{endTime} + WHERE delete_type = 0 AND id = #{id} + + + + + INSERT INTO hrsa_social_archives( + welfare_type, + delete_type, + social_payment_base_string, + social_payment_com_base_string, + social_scheme_id, + create_time, + social_end_time, + social_start_time, + creator, + non_payment, + tenant_key, + employee_id, + update_time, + under_take, + social_account, + payment_organization) + VALUES + ( + #{welfareType}, + #{deleteType}, + #{socialPaymentBaseString}, + #{socialPaymentComBaseString}, + #{socialSchemeId}, + #{createTime}, + #{socialEndTime}, + #{socialStartTime}, + #{creator}, + #{nonPayment}, + #{tenantKey}, + #{employeeId}, + #{updateTime}, + #{underTake}, + #{socialAccount}, + #{paymentOrganization} + ) + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/sicategory/ICategoryMapper.java b/src/com/engine/salary/mapper/sicategory/ICategoryMapper.java new file mode 100644 index 000000000..cf50c9395 --- /dev/null +++ b/src/com/engine/salary/mapper/sicategory/ICategoryMapper.java @@ -0,0 +1,106 @@ +package com.engine.salary.mapper.sicategory; + +import com.engine.salary.entity.sicategory.dto.ICategoryListDTO; +import com.engine.salary.entity.sicategory.po.ICategoryPO; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * @Author weaver_cl + * + * @Date 2022/3/9 + * @Version V1.0 + **/ +public interface ICategoryMapper { + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + ICategoryPO getById(Long id); + + + ICategoryPO getByIdAndDataType(@Param("id") Long id,@Param("dataType") Integer dataType); + + + /** + * 查询所有 + * @return + */ + List listAll(); + + + /** + * 根据福利名称获取 + * @param insuranceName + * @return + */ + List listByName(String insuranceName); + + /** + * 新增,插入所有字段 + * + * @param iCategoryPO 新增的记录 + * @return 返回影响行数 + */ + int insert(ICategoryPO iCategoryPO); + + /** + * 更新,更新修改的字段 + * @param iCategoryPO + * @return + */ + void update(ICategoryPO iCategoryPO); + + + /** + * 根据id更新状态 + * @param iCategoryPO + */ + void updateById(ICategoryPO iCategoryPO); + + + /** + * 根据id更新福利名称 + * @param iCategoryPO + */ + void updateNameById(ICategoryPO iCategoryPO); + + /** + * 根据id更新福利名称和缴费对象 + * @param iCategoryPO + */ + void updateNameAndPayScopeById(ICategoryPO iCategoryPO); + + /** + * 根据类型查询福利类型 + * + * @return + */ + List listByWelfareType(@Param("welfareType") Integer welfareType, + @Param("dataType") Integer dataType); + + /** + * 根据数据类型查询 + * @param dataType + * @return + */ + List listByDataType(@Param("dataType") Integer dataType); + + /** + * 自定义福利列表 + * @param welfareType + * @return + */ + List listCustomInsurance(@Param("welfareType") Integer welfareType); + + /** + * 根据id删除自定义福利项 + * @param iCategoryPO + */ + void deleteCustomCategoryById(ICategoryPO iCategoryPO); +} diff --git a/src/com/engine/salary/mapper/sicategory/ICategoryMapper.xml b/src/com/engine/salary/mapper/sicategory/ICategoryMapper.xml new file mode 100644 index 000000000..9045bb11f --- /dev/null +++ b/src/com/engine/salary/mapper/sicategory/ICategoryMapper.xml @@ -0,0 +1,223 @@ + + + + + + + + + + + + + + + + + + + + t.id + , t.insurance_name + , t.welfare_type + , t.is_use + , t.payment_scope + , t.data_type + , t.create_time + , t.update_time + , t.creator + , t.delete_type + , t.tenant_key + + + + + AND data_type = #{dataType} + + + + + + + + + + + INSERT INTO hrsa_insurance_category + + id, + insurance_name, + welfare_type, + is_use, + payment_scope, + data_type, + create_time, + update_time, + creator, + delete_type, + tenant_key, + + + #{id}, + #{insuranceName}, + #{welfareType}, + #{isUse}, + #{paymentScope}, + #{dataType}, + #{createTime}, + #{updateTime}, + #{creator}, + #{deleteType}, + #{tenantKey}, + + + + + INSERT INTO hrsa_insurance_category + + id, + insurance_name, + welfare_type, + is_use, + payment_scope, + data_type, + create_time, + update_time, + creator, + delete_type, + tenant_key, + + + #{id}, + #{insuranceName}, + #{welfareType}, + #{isUse}, + #{paymentScope}, + #{dataType}, + #{createTime}, + #{updateTime}, + #{creator}, + #{deleteType}, + #{tenantKey}, + + + + + + + + + + + + + + + + + + + + + + UPDATE hrsa_insurance_category + + update_time=#{updateTime}, + insurance_name=#{insuranceName}, + welfare_type=#{welfareType}, + payment_scope=#{paymentScope}, + + WHERE id = #{id} AND delete_type = 0 + + + + + UPDATE hrsa_insurance_category + SET is_use = #{isUse} + WHERE id = #{id} + + + + UPDATE hrsa_insurance_category + SET insurance_name = #{insuranceName} + WHERE id = #{id} AND data_type = 0 + + + + + UPDATE hrsa_insurance_category + + update_time=#{updateTime}, + insurance_name=#{insuranceName}, + payment_scope=#{paymentScope}, + + WHERE id = #{id} AND data_type = 0 + + + + + + + + UPDATE hrsa_insurance_category + + update_time=#{updateTime}, + delete_type = 1 + + WHERE id = #{id} AND delete_type = 0 AND data_type = 0 + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/sischeme/InsuranceSchemeDetailMapper.java b/src/com/engine/salary/mapper/sischeme/InsuranceSchemeDetailMapper.java new file mode 100644 index 000000000..9af378c42 --- /dev/null +++ b/src/com/engine/salary/mapper/sischeme/InsuranceSchemeDetailMapper.java @@ -0,0 +1,82 @@ +package com.engine.salary.mapper.sischeme; + +import com.engine.salary.entity.sischeme.po.InsuranceSchemeDetailPO; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; + +/** + * @Author weaver_cl + * + * @Date 2022/3/8 + * @Version V1.0 + **/ +public interface InsuranceSchemeDetailMapper { + + /** + * 查询当前方案下面配置的福利类型明细 + * + * @return list + */ + List queryListBySchemeId(@Param("schemeId")Long schemeId); + + /** + * 新增,插入所有字段 + * + * @param insuranceSchemeDetailPO 新增的记录 + * @return 返回影响行数 + */ + int insert(InsuranceSchemeDetailPO insuranceSchemeDetailPO); + + + /** + * 批量删除 + * @param primaryIds + */ + void batchDeleteByPrimaryIds(@Param("primaryIds") Collection primaryIds); + + /** + * 根据险种id和是否缴费查询社保方案明细表 + * + * @param insuranceId 险种id + * @param isPayment 是否缴费 + * @return list + */ + List queryListByInsuranceIdIsPayment(@Param("insuranceId") Long insuranceId, @Param("isPayment") Integer isPayment); + + + /** + * + * @param primaryId + * @param paymentScope + * @param insuranceId + * @return + */ + InsuranceSchemeDetailPO getByPPI(@Param("primaryId") Long primaryId, @Param("paymentScope") Integer paymentScope, + @Param("insuranceId") Long insuranceId); + + List getByPI(@Param("primaryId") Long primaryId, @Param("insuranceId") Long insuranceId); + + /** + * 根据主键和是否缴费查询 + * @param primaryId + * @param isPayment + * @return + */ + List queryListByPrimaryIdIsPayment(@Param("primaryId") Long primaryId, @Param("isPayment") Integer isPayment, + @Param("welfareType") Integer welfareType); + + + List queryInsuranceSchemeDetailList(@Param("primaryId") Long primaryId, @Param("isPayment") Integer isPayment); + + void deleteByIds(@Param("ids")Collection ids); + + List listAll(); + + List listBySchemeIds(@Param("schemeIds")Collection schemeIds); + + int batchUpdate(@Param("collection") List insuranceSchemeDetailPos); + + int updateAll(InsuranceSchemeDetailPO insuranceSchemeDetailPo); +} diff --git a/src/com/engine/salary/mapper/sischeme/InsuranceSchemeDetailMapper.xml b/src/com/engine/salary/mapper/sischeme/InsuranceSchemeDetailMapper.xml new file mode 100644 index 000000000..d4b15075f --- /dev/null +++ b/src/com/engine/salary/mapper/sischeme/InsuranceSchemeDetailMapper.xml @@ -0,0 +1,360 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + t.id + , t.primary_id + , t.insurance_id + , t.effective_time + , t.expiration_time + , t.is_payment + , t.payment_scope + , t.upper_limit + , t.lower_limit + , t.payment_proportion + , t.fixed_cost + , t.valid_num + , t.rentention_rule + , t.payment_cycle + , t.account_type + , t.cycle_setting + , t.create_time + , t.update_time + , t.creator + , t.delete_type + , t.tenant_key + + + + + t.id + , t.primary_id + , t.insurance_id + , t.is_payment + , t.payment_scope + , t.payment_proportion + , t.fixed_cost + , t.valid_num + , t.rentention_rule + , t.create_time + , t.update_time + , t.creator + , t.delete_type + , t.tenant_key + + + + + + + + + + + + AND primary_id = #{primaryId} + + + + + + + + + + INSERT INTO hrsa_scheme_detail + + primary_id, + insurance_id, + effective_time, + expiration_time, + is_payment, + payment_scope, + upper_limit, + lower_limit, + payment_proportion, + fixed_cost, + valid_num, + rentention_rule, + payment_cycle, + account_type, + cycle_setting, + create_time, + update_time, + creator, + delete_type, + tenant_key, + + + #{primaryId}, + #{insuranceId}, + #{effectiveTime}, + #{expirationTime}, + #{isPayment}, + #{paymentScope}, + #{upperLimit}, + #{lowerLimit}, + #{paymentProportion}, + #{fixedCost}, + #{validNum}, + #{rententionRule}, + #{paymentCycle}, + #{accountType}, + #{cycleSetting}, + #{createTime}, + #{updateTime}, + #{creator}, + #{deleteType}, + #{tenantKey}, + + + + + + select hrsa_scheme_detail_id.currval from dual + + INSERT INTO hrsa_scheme_detail + + primary_id, + insurance_id, + effective_time, + expiration_time, + is_payment, + payment_scope, + upper_limit, + lower_limit, + payment_proportion, + fixed_cost, + valid_num, + rentention_rule, + payment_cycle, + account_type, + cycle_setting, + create_time, + update_time, + creator, + delete_type, + tenant_key, + + + #{primaryId}, + #{insuranceId}, + #{effectiveTime}, + #{expirationTime}, + #{isPayment}, + #{paymentScope}, + #{upperLimit}, + #{lowerLimit}, + #{paymentProportion}, + #{fixedCost}, + #{validNum}, + #{rententionRule}, + #{paymentCycle}, + #{accountType}, + #{cycleSetting}, + #{createTime}, + #{updateTime}, + #{creator}, + #{deleteType}, + #{tenantKey}, + + + + + UPDATE hrsa_scheme_detail + SET delete_type = 1 + WHERE delete_type = 0 + AND primary_id IN + + #{primaryIds} + + + + + + + + + + + + + + UPDATE + hrsa_scheme_detail + SET delete_type = 1 + WHERE primary_id IN + + #{id} + + + + + + + + + update hrsa_scheme_detail + + + + + when id=#{item.id} then #{item.upperLimit} + + + + + + + when id=#{item.id} then #{item.fixedCost} + + + + + + + when id=#{item.id} then #{item.lowerLimit} + + + + + + + when id=#{item.id} then #{item.deleteType} + + + + + where + id in + + #{item.id} + + + + + update hrsa_scheme_detail + + + payment_scope=#{paymentScope}, + + + is_payment=#{isPayment}, + + + delete_type=#{deleteType}, + + + payment_proportion=#{paymentProportion}, + + + upper_limit=#{upperLimit}, + + + lower_limit=#{lowerLimit}, + + + update_time=#{updateTime}, + + + fixed_cost=#{fixedCost}, + + + valid_num=#{validNum}, + + + rentention_rule=#{rententionRule}, + + + WHERE id = #{id} AND delete_type = 0 + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/sischeme/InsuranceSchemeMapper.java b/src/com/engine/salary/mapper/sischeme/InsuranceSchemeMapper.java new file mode 100644 index 000000000..11cbfd0b2 --- /dev/null +++ b/src/com/engine/salary/mapper/sischeme/InsuranceSchemeMapper.java @@ -0,0 +1,71 @@ +package com.engine.salary.mapper.sischeme; + +import com.engine.salary.entity.sischeme.param.InsuranceSchemeParam; +import com.engine.salary.entity.sischeme.po.InsuranceSchemePO; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; + +/** + * @Author weaver_cl + * + * @Date 2022/3/7 + * @Version V1.0 + **/ +public interface InsuranceSchemeMapper { + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + InsuranceSchemePO getById(Long id); + + /** + * 新增,插入所有字段 + * @param insuranceSchemePO 新增的记录 + * @return 返回影响行数 + */ + int insert(InsuranceSchemePO insuranceSchemePO); + + /** + * 更新,更新修改的字段 + * @param insuranceSchemePO + * @return + */ + int update(InsuranceSchemePO insuranceSchemePO); + + /** + * 根据名称查询 + * @param schemeName + * @return + */ + List listByName(String schemeName); + + + /** + * 查询所有 + * @return + */ + List listAll(); + + List listBySchemeIds(@Param("schemeIds")Collection schemeIds); + + + /** + * 获取名称 + * @param schemeId + * @return + */ + String querySchemeName(@Param("schemeId") Long schemeId); + + + + List listByWelfareType(@Param("welfareType")Integer welfareType); + List list(InsuranceSchemeParam param); + + + void deleteByIds(@Param("ids")Collection ids); +} diff --git a/src/com/engine/salary/mapper/sischeme/InsuranceSchemeMapper.xml b/src/com/engine/salary/mapper/sischeme/InsuranceSchemeMapper.xml new file mode 100644 index 000000000..d70a73724 --- /dev/null +++ b/src/com/engine/salary/mapper/sischeme/InsuranceSchemeMapper.xml @@ -0,0 +1,231 @@ + + + + + + + + + + + + + + + + + + + + + + + t.id + , t.payment_area + , t.payment_type + , t.scheme_name + , t.welfare_type + , t.is_use + , t.remarks + , t.create_time + , t.update_time + , t.creator + , t.delete_type + , t.tenant_key + , t.shared_type + , t.tax_agent_ids + + + + + + AND scheme_name like CONCAT('%',#{schemeName},'%') + + + + + AND scheme_name like '%'||#{schemeName}||'%' + + + + + AND scheme_name like '%'+#{schemeName}+'%' + + + + + + + + + + + + + + + + + + + + INSERT INTO hrsa_social_security_scheme + + payment_area, + payment_type, + scheme_name, + welfare_type, + is_use, + remarks, + create_time, + update_time, + creator, + delete_type, + tenant_key, + shared_type, + tax_agent_ids + + + #{paymentArea}, + #{paymentType}, + #{schemeName}, + #{welfareType}, + #{isUse}, + #{remarks}, + #{createTime}, + #{updateTime}, + #{creator}, + #{deleteType}, + #{tenantKey}, + #{sharedType}, + #{taxAgentIds} + + + + + + select hrsa_social_s_s_id.currval from dual + + INSERT INTO hrsa_social_security_scheme + + payment_area, + payment_type, + scheme_name, + welfare_type, + is_use, + remarks, + create_time, + update_time, + creator, + delete_type, + tenant_key, + shared_type, + tax_agent_ids + + + #{paymentArea}, + #{paymentType}, + #{schemeName}, + #{welfareType}, + #{isUse}, + #{remarks}, + #{createTime}, + #{updateTime}, + #{creator}, + #{deleteType}, + #{tenantKey}, + #{sharedType}, + #{taxAgentIds} + + + + + + UPDATE hrsa_social_security_scheme + + update_time=#{updateTime}, + payment_area=#{paymentArea}, + payment_type=#{paymentType}, + scheme_name=#{schemeName}, + remarks=#{remarks}, + shared_type=#{sharedType}, + tax_agent_ids=#{taxAgentIds} + + WHERE id = #{id} AND delete_type = 0 + + + + + + + + + UPDATE hrsa_social_security_scheme + SET delete_type=1 + WHERE id IN + + #{id} + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/sys/SalarySysConfMapper.java b/src/com/engine/salary/mapper/sys/SalarySysConfMapper.java new file mode 100644 index 000000000..88f07ce7f --- /dev/null +++ b/src/com/engine/salary/mapper/sys/SalarySysConfMapper.java @@ -0,0 +1,79 @@ +package com.engine.salary.mapper.sys; + +import com.engine.salary.sys.entity.po.SalarySysConfPO; +import org.apache.ibatis.annotations.Param; + +import java.util.Date; +import java.util.List; + +public interface SalarySysConfMapper { + + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + /** + * 条件查询 + * + * @return 返回集合,没有返回空List + */ + List listSome(SalarySysConfPO SalarySysConfPO); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + SalarySysConfPO getById(Long id); + + /** + * 新增,忽略null字段 + * + * @param SalarySysConfPO 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(SalarySysConfPO SalarySysConfPO); + + /** + * 修改,修改所有字段 + * + * @param SalarySysConfPO 修改的记录 + * @return 返回影响行数 + */ + int update(SalarySysConfPO SalarySysConfPO); + + /** + * 修改,忽略null字段 + * + * @param SalarySysConfPO 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(SalarySysConfPO SalarySysConfPO); + + /** + * 删除记录 + * + * @param salarySysConf 待删除的记录 + * @return 返回影响行数 + */ + int delete(SalarySysConfPO salarySysConf); + + SalarySysConfPO getOneByCode(String confKey); + + int countByCode(String confKey); + + /** + * @description 获取个税申报功能重启时间 + * @return Date + * @author Harryxzy + * @date 2022/11/9 21:09 + */ + Date getTaxDeclarationRebootDate(); + + List getListByCodes(@Param("codes") List codes); +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/sys/SalarySysConfMapper.xml b/src/com/engine/salary/mapper/sys/SalarySysConfMapper.xml new file mode 100644 index 000000000..a30c8e822 --- /dev/null +++ b/src/com/engine/salary/mapper/sys/SalarySysConfMapper.xml @@ -0,0 +1,253 @@ + + + + + + + + + + + + + + + + + + + t + . + id + , t.conf_key + , t.conf_value + , t.title + , t.module + , t.order_weight + , t.description + , t.delete_type + , t.create_time + , t.update_time + + + + + + + + + + + + + + + INSERT INTO hrsa_salary_sys_conf + + + + id, + + + conf_key, + + + conf_value, + + + title, + + + module, + + + order_weight, + + + description, + + + delete_type, + + + create_time, + + + update_time, + + + + + #{id}, + + + #{confKey}, + + + #{confValue}, + + + #{title}, + + + #{module}, + + + #{orderWeight}, + + + #{description}, + + + #{deleteType}, + + + #{createTime}, + + + #{updateTime}, + + + + + + + UPDATE hrsa_salary_sys_conf + + conf_key=#{confKey}, + conf_value=#{confValue}, + title=#{title}, + module=#{module}, + order_weight=#{orderWeight}, + description=#{description}, + delete_type=#{deleteType}, + create_time=#{createTime}, + update_time=#{updateTime}, + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_salary_sys_conf + + + conf_key=#{confKey}, + + + conf_value=#{confValue}, + + + title=#{title}, + + + module=#{module}, + + + order_weight=#{orderWeight}, + + + description=#{description}, + + + delete_type=#{deleteType}, + + + create_time=#{createTime}, + + + update_time=#{updateTime}, + + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_salary_sys_conf + SET delete_type=1 + WHERE id = #{id} + AND delete_type = 0 + + + + + + + + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/taxagent/TaxAgentAdminMapper.java b/src/com/engine/salary/mapper/taxagent/TaxAgentAdminMapper.java new file mode 100644 index 000000000..ebd54d390 --- /dev/null +++ b/src/com/engine/salary/mapper/taxagent/TaxAgentAdminMapper.java @@ -0,0 +1,67 @@ +package com.engine.salary.mapper.taxagent; + +import com.engine.salary.entity.taxagent.po.TaxAgentAdminPO; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; + +public interface TaxAgentAdminMapper { + + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + TaxAgentAdminPO getById(Long id); + + /** + * 条件查询 + * + * @return 返回集合,没有返回空List + */ + List listSome(TaxAgentAdminPO taxAgentAdmin); + + /** + * 新增,忽略null字段 + * + * @param TaxAgentAdminPO 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(TaxAgentAdminPO TaxAgentAdminPO); + + /** + * 修改,修改所有字段 + * + * @param TaxAgentAdminPO 修改的记录 + * @return 返回影响行数 + */ + int update(TaxAgentAdminPO TaxAgentAdminPO); + + /** + * 修改,忽略null字段 + * + * @param TaxAgentAdminPO 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(TaxAgentAdminPO TaxAgentAdminPO); + + /** + * 删除记录 + * + * @param TaxAgentAdminPO 待删除的记录 + * @return 返回影响行数 + */ + int delete(TaxAgentAdminPO TaxAgentAdminPO); + + void deleteByTaxAgentIds(@Param("taxAgentIds") Collection taxAgentIds); +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/taxagent/TaxAgentAdminMapper.xml b/src/com/engine/salary/mapper/taxagent/TaxAgentAdminMapper.xml new file mode 100644 index 000000000..ad3e4b720 --- /dev/null +++ b/src/com/engine/salary/mapper/taxagent/TaxAgentAdminMapper.xml @@ -0,0 +1,209 @@ + + + + + + + + + + + + + + + + + t + . + create_time + , t.creator + , t.delete_type + , t.employee_id + , t.id + , t.tax_agent_id + , t.tenant_key + , t.update_time + + + + + + + + + + + + + + + INSERT INTO hrsa_tax_agent_admin + + + + create_time, + + + creator, + + + delete_type, + + + employee_id, + + + id, + + + tax_agent_id, + + + tenant_key, + + + update_time, + + + + + #{createTime}, + + + #{creator}, + + + #{deleteType}, + + + #{employeeId}, + + + #{id}, + + + #{taxAgentId}, + + + #{tenantKey}, + + + #{updateTime}, + + + + + + + UPDATE hrsa_tax_agent_admin + + create_time=#{createTime}, + creator=#{creator}, + delete_type=#{deleteType}, + employee_id=#{employeeId}, + tax_agent_id=#{taxAgentId}, + tenant_key=#{tenantKey}, + update_time=#{updateTime}, + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_tax_agent_admin + + + create_time=#{createTime}, + + + creator=#{creator}, + + + delete_type=#{deleteType}, + + + employee_id=#{employeeId}, + + + tax_agent_id=#{taxAgentId}, + + + tenant_key=#{tenantKey}, + + + update_time=#{updateTime}, + + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_tax_agent_admin + SET delete_type=1 + WHERE id = #{id} + AND delete_type = 0 + + + + + UPDATE hrsa_tax_agent_admin + SET delete_type=1 + WHERE delete_type = 0 + AND tax_agent_id IN + + #{taxAgentId} + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/taxagent/TaxAgentBaseMapper.java b/src/com/engine/salary/mapper/taxagent/TaxAgentBaseMapper.java new file mode 100644 index 000000000..0cac81090 --- /dev/null +++ b/src/com/engine/salary/mapper/taxagent/TaxAgentBaseMapper.java @@ -0,0 +1,68 @@ +package com.engine.salary.mapper.taxagent; + +import com.engine.salary.entity.taxagent.po.TaxAgentBasePO; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + + +public interface TaxAgentBaseMapper { + + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + TaxAgentBasePO getById(Long id); + + + + /** + * 条件查询 + * + * @return 返回集合,没有返回空List + */ + List listSome(TaxAgentBasePO taxAgentBase); + + /** + * 新增,忽略null字段 + * + * @param taxAgentBase 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(TaxAgentBasePO taxAgentBase); + + /** + * 修改,修改所有字段 + * + * @param taxAgentBase 修改的记录 + * @return 返回影响行数 + */ + int update(TaxAgentBasePO taxAgentBase); + + /** + * 修改,忽略null字段 + * + * @param taxAgentBase 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(TaxAgentBasePO taxAgentBase); + + /** + * 删除记录 + * + * @param taxAgentBase 待删除的记录 + * @return 返回影响行数 + */ + int delete(TaxAgentBasePO taxAgentBase); + +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/taxagent/TaxAgentBaseMapper.xml b/src/com/engine/salary/mapper/taxagent/TaxAgentBaseMapper.xml new file mode 100644 index 000000000..0d2cee524 --- /dev/null +++ b/src/com/engine/salary/mapper/taxagent/TaxAgentBaseMapper.xml @@ -0,0 +1,180 @@ + + + + + + + + + + + + + + + + t.create_time + , t.creator + , t.delete_type + , t.devolution_status + , t.id + , t.tenant_key + , t.update_time + + + + + + + + + + + + + + + INSERT INTO hrsa_tax_agent_base + + + + create_time, + + + creator, + + + delete_type, + + + devolution_status, + + + id, + + + tenant_key, + + + update_time, + + + + + #{createTime}, + + + #{creator}, + + + #{deleteType}, + + + #{devolutionStatus}, + + + #{id}, + + + #{tenantKey}, + + + #{updateTime}, + + + + + + + UPDATE hrsa_tax_agent_base + + create_time=#{createTime}, + creator=#{creator}, + delete_type=#{deleteType}, + devolution_status=#{devolutionStatus}, + tenant_key=#{tenantKey}, + update_time=#{updateTime}, + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_tax_agent_base + + + create_time=#{createTime}, + + + creator=#{creator}, + + + delete_type=#{deleteType}, + + + devolution_status=#{devolutionStatus}, + + + tenant_key=#{tenantKey}, + + + update_time=#{updateTime}, + + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_tax_agent_base + SET delete_type=1 + WHERE id = #{id} AND delete_type = 0 + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/taxagent/TaxAgentEmpChangeMapper.java b/src/com/engine/salary/mapper/taxagent/TaxAgentEmpChangeMapper.java new file mode 100644 index 000000000..ec5b744be --- /dev/null +++ b/src/com/engine/salary/mapper/taxagent/TaxAgentEmpChangeMapper.java @@ -0,0 +1,76 @@ +package com.engine.salary.mapper.taxagent; + +import com.engine.salary.entity.taxagent.po.TaxAgentEmpChangePO; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; + + +public interface TaxAgentEmpChangeMapper { + + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + TaxAgentEmpChangePO getById(Long id); + + + /** + * 条件查询 + * + * @return 返回集合,没有返回空List + */ + List listSome(TaxAgentEmpChangePO taxAgentEmpChange); + + /** + * 新增,忽略null字段 + * + * @param taxAgentEmpChange 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(TaxAgentEmpChangePO taxAgentEmpChange); + + /** + * 修改,修改所有字段 + * + * @param taxAgentEmpChange 修改的记录 + * @return 返回影响行数 + */ + int update(TaxAgentEmpChangePO taxAgentEmpChange); + + /** + * 修改,忽略null字段 + * + * @param taxAgentEmpChange 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(TaxAgentEmpChangePO taxAgentEmpChange); + + /** + * 删除记录 + * + * @param taxAgentEmpChange 待删除的记录 + * @return 返回影响行数 + */ + int delete(TaxAgentEmpChangePO taxAgentEmpChange); + + void deleteByIds(@Param("ids") Collection ids); + + /** + * 批量插入 + * + * @param saves + */ + void batchInsert(@Param("collection") List saves); +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/taxagent/TaxAgentEmpChangeMapper.xml b/src/com/engine/salary/mapper/taxagent/TaxAgentEmpChangeMapper.xml new file mode 100644 index 000000000..5d245ddb7 --- /dev/null +++ b/src/com/engine/salary/mapper/taxagent/TaxAgentEmpChangeMapper.xml @@ -0,0 +1,374 @@ + + + + + + + + + + + + + + + + + + + + + t + . + change_type + , t.create_time + , t.creator + , t.delete_type + , t.employee_id + , t.employee_name + , t.id + , t.module_type + , t.tax_agent_id + , t.tenant_key + , t.update_time + , t.employee_type + + + + + + + + + + + + + + + INSERT INTO hrsa_tax_agent_emp_change + + + + change_type, + + + create_time, + + + creator, + + + delete_type, + + + employee_id, + + + employee_name, + + + id, + + + module_type, + + + tax_agent_id, + + + tenant_key, + + + update_time, + + + employee_type, + + + + + #{changeType}, + + + #{createTime}, + + + #{creator}, + + + #{deleteType}, + + + #{employeeId}, + + + #{employeeName}, + + + #{id}, + + + #{moduleType}, + + + #{taxAgentId}, + + + #{tenantKey}, + + + #{updateTime}, + + + #{employeeType}, + + + + + + + UPDATE hrsa_tax_agent_emp_change + + change_type=#{changeType}, + create_time=#{createTime}, + creator=#{creator}, + delete_type=#{deleteType}, + employee_id=#{employeeId}, + employee_name=#{employeeName}, + module_type=#{moduleType}, + tax_agent_id=#{taxAgentId}, + tenant_key=#{tenantKey}, + update_time=#{updateTime}, + employee_type=#{employeeType}, + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_tax_agent_emp_change + + + change_type=#{changeType}, + + + create_time=#{createTime}, + + + creator=#{creator}, + + + delete_type=#{deleteType}, + + + employee_id=#{employeeId}, + + + employee_name=#{employeeName}, + + + module_type=#{moduleType}, + + + tax_agent_id=#{taxAgentId}, + + + tenant_key=#{tenantKey}, + + + update_time=#{updateTime}, + + + employee_type=#{employeeType}, + + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_tax_agent_emp_change + SET delete_type=1 + WHERE id = #{id} + AND delete_type = 0 + + + + UPDATE hrsa_tax_agent_emp_change + SET delete_type=1 + WHERE delete_type = 0 + AND (id IN + + + + + + ) OR id IN ( + , + + + #{Id} + + + ) + + + + + INSERT INTO hrsa_tax_agent_emp_change( + id, + employee_id, + tax_agent_id, + employee_name, + change_type, + module_type, + create_time, + update_time, + creator, + employee_type, + tenant_key + ) + VALUES + + ( + #{item.id}, + #{item.employeeId}, + #{item.taxAgentId}, + #{item.employeeName}, + #{item.changeType}, + #{item.moduleType}, + #{item.createTime}, + #{item.updateTime}, + #{item.creator}, + #{item.employeeType}, + #{item.tenantKey} + ) + + + + INSERT INTO hrsa_tax_agent_emp_change( + id, + employee_id, + tax_agent_id, + employee_name, + change_type, + module_type, + create_time, + update_time, + creator, + employee_type, + tenant_key + ) + + + select + #{item.id,jdbcType=DOUBLE}, + #{item.employeeId,jdbcType=DOUBLE}, + #{item.taxAgentId,jdbcType=DOUBLE}, + #{item.employeeName,jdbcType=VARCHAR}, + #{item.changeType,jdbcType=INTEGER}, + #{item.moduleType,jdbcType=INTEGER}, + #{item.createTime,jdbcType=DATE}, + #{item.updateTime,jdbcType=DATE}, + #{item.creator,jdbcType=DOUBLE}, + #{item.employeeType,jdbcType=INTEGER}, + #{item.tenantKey,jdbcType=VARCHAR} + from dual + + + + + INSERT INTO hrsa_tax_agent_emp_change( + id, + employee_id, + tax_agent_id, + employee_name, + change_type, + module_type, + create_time, + update_time, + creator, + employee_type, + tenant_key + ) + VALUES + ( + #{item.id}, + #{item.employeeId}, + #{item.taxAgentId}, + #{item.employeeName}, + #{item.changeType}, + #{item.moduleType}, + #{item.createTime}, + #{item.updateTime}, + #{item.creator}, + #{item.employeeType}, + #{item.tenantKey} + ) + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/taxagent/TaxAgentEmpMapper.java b/src/com/engine/salary/mapper/taxagent/TaxAgentEmpMapper.java new file mode 100644 index 000000000..ba42c39d4 --- /dev/null +++ b/src/com/engine/salary/mapper/taxagent/TaxAgentEmpMapper.java @@ -0,0 +1,78 @@ +package com.engine.salary.mapper.taxagent; + +import com.engine.salary.entity.taxagent.po.TaxAgentEmpPO; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; + + +public interface TaxAgentEmpMapper { + + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + TaxAgentEmpPO getById(Long id); + + + /** + * 条件查询 + * + * @return 返回集合,没有返回空List + */ + List listSome(TaxAgentEmpPO taxAgentEmp); + + /** + * 新增,忽略null字段 + * + * @param taxAgentEmp 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(TaxAgentEmpPO taxAgentEmp); + + /** + * 修改,修改所有字段 + * + * @param taxAgentEmp 修改的记录 + * @return 返回影响行数 + */ + int update(TaxAgentEmpPO taxAgentEmp); + + /** + * 修改,忽略null字段 + * + * @param taxAgentEmp 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(TaxAgentEmpPO taxAgentEmp); + + /** + * 删除记录 + * + * @param taxAgentEmp 待删除的记录 + * @return 返回影响行数 + */ + int delete(TaxAgentEmpPO taxAgentEmp); + + void deleteByIds(@Param("ids") Collection ids); + + /** + * 批量插入 + * + * @param saves + */ + void batchInsert(@Param("collection") List saves); + +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/taxagent/TaxAgentEmpMapper.xml b/src/com/engine/salary/mapper/taxagent/TaxAgentEmpMapper.xml new file mode 100644 index 000000000..a74e1c1aa --- /dev/null +++ b/src/com/engine/salary/mapper/taxagent/TaxAgentEmpMapper.xml @@ -0,0 +1,331 @@ + + + + + + + + + + + + + + + + + + + t + . + create_time + , t.creator + , t.delete_type + , t.employee_id + , t.employee_name + , t.id + , t.tax_agent_id + , t.tenant_key + , t.update_time + , t.employee_type + + + + + + + + + + + + + + + INSERT INTO hrsa_tax_agent_emp + + + + create_time, + + + creator, + + + delete_type, + + + employee_id, + + + employee_name, + + + id, + + + tax_agent_id, + + + tenant_key, + + + update_time, + + + employee_type, + + + + + #{createTime}, + + + #{creator}, + + + #{deleteType}, + + + #{employeeId}, + + + #{employeeName}, + + + #{id}, + + + #{taxAgentId}, + + + #{tenantKey}, + + + #{updateTime}, + + + #{employeeType}, + + + + + + + UPDATE hrsa_tax_agent_emp + + create_time=#{createTime}, + creator=#{creator}, + delete_type=#{deleteType}, + employee_id=#{employeeId}, + employee_name=#{employeeName}, + tax_agent_id=#{taxAgentId}, + tenant_key=#{tenantKey}, + update_time=#{updateTime}, + employee_type=#{employeeType}, + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_tax_agent_emp + + + create_time=#{createTime}, + + + creator=#{creator}, + + + delete_type=#{deleteType}, + + + employee_id=#{employeeId}, + + + employee_name=#{employeeName}, + + + tax_agent_id=#{taxAgentId}, + + + tenant_key=#{tenantKey}, + + + update_time=#{updateTime}, + + + employee_type=#{employeeType}, + + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_tax_agent_emp + SET delete_type=1 + WHERE id = #{id} + AND delete_type = 0 + + + + UPDATE hrsa_tax_agent_emp + SET delete_type=1 + WHERE delete_type = 0 + AND id IN + + #{id} + + + + + INSERT INTO hrsa_tax_agent_emp( + id, + employee_id, + tax_agent_id, + employee_name, + create_time, + update_time, + creator, + employee_type, + tenant_key + ) + VALUES + + ( + #{item.id}, + #{item.employeeId}, + #{item.taxAgentId}, + #{item.employeeName}, + #{item.createTime}, + #{item.updateTime}, + #{item.creator}, + #{item.employeeType}, + #{item.tenantKey} + ) + + + + INSERT INTO hrsa_tax_agent_emp( + id, + employee_id, + tax_agent_id, + employee_name, + create_time, + update_time, + creator, + employee_type, + tenant_key + ) + + + select + #{item.id,jdbcType=DOUBLE}, + #{item.employeeId,jdbcType=DOUBLE}, + #{item.taxAgentId,jdbcType=DOUBLE}, + #{item.employeeName,jdbcType=VARCHAR}, + #{item.createTime,jdbcType=DATE}, + #{item.updateTime,jdbcType=DATE}, + #{item.creator,jdbcType=DOUBLE}, + #{item.employeeType,jdbcType=INTEGER}, + #{item.tenantKey,jdbcType=VARCHAR} + from dual + + + + + INSERT INTO hrsa_tax_agent_emp( + id, + employee_id, + tax_agent_id, + employee_name, + create_time, + update_time, + creator, + employee_type, + tenant_key + ) + VALUES + ( + #{item.id}, + #{item.employeeId}, + #{item.taxAgentId}, + #{item.employeeName}, + #{item.createTime}, + #{item.updateTime}, + #{item.creator}, + #{item.employeeType}, + #{item.tenantKey} + ) + + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/taxagent/TaxAgentExtRangeMapper.java b/src/com/engine/salary/mapper/taxagent/TaxAgentExtRangeMapper.java new file mode 100644 index 000000000..b25c935c6 --- /dev/null +++ b/src/com/engine/salary/mapper/taxagent/TaxAgentExtRangeMapper.java @@ -0,0 +1,69 @@ +package com.engine.salary.mapper.taxagent; + +import com.engine.salary.entity.taxagent.po.TaxAgentExtRangePO; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; + +public interface TaxAgentExtRangeMapper { + + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + /** + * 条件查询 + * + * @return 返回集合,没有返回空List + */ + List listSome(TaxAgentExtRangePO taxAgentExtRange); + + List list(TaxAgentExtRangePO taxAgentExtRange); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + TaxAgentExtRangePO getById(Long id); + + /** + * 新增,忽略null字段 + * + * @param taxAgentExtRange 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(TaxAgentExtRangePO taxAgentExtRange); + + /** + * 修改,修改所有字段 + * + * @param taxAgentExtRange 修改的记录 + * @return 返回影响行数 + */ + int update(TaxAgentExtRangePO taxAgentExtRange); + + /** + * 修改,忽略null字段 + * + * @param taxAgentExtRange 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(TaxAgentExtRangePO taxAgentExtRange); + + /** + * 删除记录 + * + * @param taxAgentExtRange 待删除的记录 + * @return 返回影响行数 + */ + int delete(TaxAgentExtRangePO taxAgentExtRange); + + void deleteByIds(@Param("ids")Collection ids); +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/taxagent/TaxAgentExtRangeMapper.xml b/src/com/engine/salary/mapper/taxagent/TaxAgentExtRangeMapper.xml new file mode 100644 index 000000000..9483e76a0 --- /dev/null +++ b/src/com/engine/salary/mapper/taxagent/TaxAgentExtRangeMapper.xml @@ -0,0 +1,253 @@ + + + + + + + + + + + + + + + + + + t + . + create_time + , t.creator + , t.delete_type + , t.id + , t.target_id + , t.target_type + , t.tax_agent_id + , t.tenant_key + , t.update_time + + + + + + + + + + + + + + + + + INSERT INTO hrsa_tax_agent_ext_range + + + + create_time, + + + creator, + + + delete_type, + + + id, + + + target_id, + + + target_type, + + + tax_agent_id, + + + tenant_key, + + + update_time, + + + + + #{createTime}, + + + #{creator}, + + + #{deleteType}, + + + #{id}, + + + #{targetId}, + + + #{targetType}, + + + #{taxAgentId}, + + + #{tenantKey}, + + + #{updateTime}, + + + + + + + UPDATE hrsa_tax_agent_ext_range + + create_time=#{createTime}, + creator=#{creator}, + delete_type=#{deleteType}, + target_id=#{targetId}, + target_type=#{targetType}, + tax_agent_id=#{taxAgentId}, + tenant_key=#{tenantKey}, + update_time=#{updateTime}, + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_tax_agent_ext_range + + + create_time=#{createTime}, + + + creator=#{creator}, + + + delete_type=#{deleteType}, + + + target_id=#{targetId}, + + + target_type=#{targetType}, + + + tax_agent_id=#{taxAgentId}, + + + tenant_key=#{tenantKey}, + + + update_time=#{updateTime}, + + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_tax_agent_ext_range + SET delete_type=1 + WHERE id = #{id} + AND delete_type = 0 + + + + UPDATE hrsa_tax_agent_ext_range + SET delete_type=1 + WHERE id in + + #{id} + + AND delete_type = 0 + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/taxagent/TaxAgentManageRangeMapper.java b/src/com/engine/salary/mapper/taxagent/TaxAgentManageRangeMapper.java new file mode 100644 index 000000000..66821fa9f --- /dev/null +++ b/src/com/engine/salary/mapper/taxagent/TaxAgentManageRangeMapper.java @@ -0,0 +1,74 @@ +package com.engine.salary.mapper.taxagent; + +import com.engine.salary.entity.taxagent.po.TaxAgentManageRangePO; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; + + +public interface TaxAgentManageRangeMapper { + + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + TaxAgentManageRangePO getById(Long id); + + /** + * 条件查询 + * + * @return 返回集合,没有返回空List + */ + List listSome(TaxAgentManageRangePO taxAgentManageRange); + + + /** + * 新增,忽略null字段 + * + * @param taxAgentManageRange 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(TaxAgentManageRangePO taxAgentManageRange); + + /** + * 修改,修改所有字段 + * + * @param taxAgentManageRange 修改的记录 + * @return 返回影响行数 + */ + int update(TaxAgentManageRangePO taxAgentManageRange); + + /** + * 修改,忽略null字段 + * + * @param taxAgentManageRange 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(TaxAgentManageRangePO taxAgentManageRange); + + /** + * 删除记录 + * + * @param taxAgentManageRange 待删除的记录 + * @return 返回影响行数 + */ + int delete(TaxAgentManageRangePO taxAgentManageRange); + + void deleteByIds(@Param("ids") Collection ids); + + void deleteByTaxAgentIds(@Param("taxAgentIds") Collection taxAgentIds); + + void deleteBySubAdminIds(Collection subAdminIds); +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/taxagent/TaxAgentManageRangeMapper.xml b/src/com/engine/salary/mapper/taxagent/TaxAgentManageRangeMapper.xml new file mode 100644 index 000000000..3538c3ab4 --- /dev/null +++ b/src/com/engine/salary/mapper/taxagent/TaxAgentManageRangeMapper.xml @@ -0,0 +1,344 @@ + + + + + + + + + + + + + + + + + + + + + + + + t.create_time + , t.creator + , t.delete_type +-- , t.employee_id + , t.employee_status + , t.id + , t.include_type + , t.range_type + , t.target_id + , t.target + , t.target_type + , t.tax_agent_id + , t.tax_agent_sub_admin_id + , t.tenant_key + , t.update_time + + + + + + + + + + + + + + + INSERT INTO hrsa_tax_agent_manage_range + + + + create_time, + + + creator, + + + delete_type, + + + + + + employee_status, + + + id, + + + include_type, + + + range_type, + + + target_id, + + + target, + + + target_type, + + + tax_agent_id, + + + tax_agent_sub_admin_id, + + + tenant_key, + + + update_time, + + + + + #{createTime}, + + + #{creator}, + + + #{deleteType}, + + + + + + #{employeeStatus}, + + + #{id}, + + + #{includeType}, + + + #{rangeType}, + + + #{targetId}, + + + #{target}, + + + #{targetType}, + + + #{taxAgentId}, + + + #{taxAgentSubAdminId}, + + + #{tenantKey}, + + + #{updateTime}, + + + + + + + UPDATE hrsa_tax_agent_manage_range + + create_time=#{createTime}, + creator=#{creator}, + delete_type=#{deleteType}, +-- employee_id=#{employeeId}, + employee_status=#{employeeStatus}, + include_type=#{includeType}, + range_type=#{rangeType}, + target_id=#{targetId}, + target=#{target}, + target_type=#{targetType}, + tax_agent_id=#{taxAgentId}, + tax_agent_sub_admin_id=#{taxAgentSubAdminId}, + tenant_key=#{tenantKey}, + update_time=#{updateTime}, + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_tax_agent_manage_range + + + create_time=#{createTime}, + + + creator=#{creator}, + + + delete_type=#{deleteType}, + + + + + + employee_status=#{employeeStatus}, + + + include_type=#{includeType}, + + + range_type=#{rangeType}, + + + target_id=#{targetId}, + + + target=#{target}, + + + target_type=#{targetType}, + + + tax_agent_id=#{taxAgentId}, + + + tax_agent_sub_admin_id=#{taxAgentSubAdminId}, + + + tenant_key=#{tenantKey}, + + + update_time=#{updateTime}, + + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_tax_agent_manage_range + SET delete_type=1 + WHERE id = #{id} AND delete_type = 0 + + + + UPDATE hrsa_tax_agent_manage_range + SET delete_type=1 + WHERE + id IN + + #{id} + + AND delete_type = 0 + + + + UPDATE hrsa_tax_agent_manage_range + SET delete_type=1 + WHERE + tax_agent_id IN + + #{taxAgentId} + + AND delete_type = 0 + + + + UPDATE hrsa_tax_agent_manage_range + SET delete_type=1 + WHERE + tax_agent_sub_admin_id IN + + #{subAdminId} + + AND delete_type = 0 + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/taxagent/TaxAgentMapper.java b/src/com/engine/salary/mapper/taxagent/TaxAgentMapper.java new file mode 100644 index 000000000..865e47591 --- /dev/null +++ b/src/com/engine/salary/mapper/taxagent/TaxAgentMapper.java @@ -0,0 +1,75 @@ +package com.engine.salary.mapper.taxagent; + +import com.engine.salary.entity.taxagent.config.TaxAgentConfig; +import com.engine.salary.entity.taxagent.param.TaxAgentQueryParam; +import com.engine.salary.entity.taxagent.po.TaxAgentEmployeePO; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; + +import java.util.Collection; +import java.util.List; + +public interface TaxAgentMapper { + + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + TaxAgentPO getById(Long id); + + + /** + * 新增,忽略null字段 + * + * @param taxAgent 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(TaxAgentPO taxAgent); + + /** + * 修改,修改所有字段 + * + * @param taxAgent 修改的记录 + * @return 返回影响行数 + */ + int update(TaxAgentPO taxAgent); + + /** + * 条件查询 + * @param taxAgent + * @return + */ + List listBySome(@Param("param") TaxAgentQueryParam taxAgent); + + + /** + * 根据名称查询 + * @param name + * @return + */ + @Select("SELECT * FROM hrsa_tax_agent WHERE delete_type = 0 and name = #{name}") + List listByName(String name); + + /** + * 批量删除个税扣缴义务人 + * + * @param ids + */ + void deleteByIds(@Param("ids") Collection ids); + + List listEmployee(); + + List getAllConfig(); + +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/taxagent/TaxAgentMapper.xml b/src/com/engine/salary/mapper/taxagent/TaxAgentMapper.xml new file mode 100644 index 000000000..20d164b94 --- /dev/null +++ b/src/com/engine/salary/mapper/taxagent/TaxAgentMapper.xml @@ -0,0 +1,281 @@ + + + + + + + + + + + + + + + + + + t.create_time + , t.creator + , t.delete_type + , t.description + , t.id + , t.name + , t.tenant_key + , t.update_time + , t.sorted_index + + + + + AND id IN + + #{id} + + + + AND name like CONCAT('%',#{param.name},'%') + + + + + + + AND id IN + + #{id} + + + + AND name like '%'||#{param.name}||'%' + + + + + + AND id IN + + #{id} + + + + AND name like '%'+#{param.name}+'%' + + + + + + + + + + + + + + + + INSERT INTO hrsa_tax_agent + + + + create_time, + + + creator, + + + delete_type, + + + description, + + + id, + + + name, + + + tenant_key, + + + update_time, + + + sorted_index, + + + + + #{createTime}, + + + #{creator}, + + + #{deleteType}, + + + #{description}, + + + #{id}, + + + #{name}, + + + #{tenantKey}, + + + #{updateTime}, + + + #{sortedIndex}, + + + + + + + + + select hrsa_tax_agent_id.currval from dual + + INSERT INTO hrsa_tax_agent + + + + create_time, + + + creator, + + + delete_type, + + + description, + + + id, + + + name, + + + tenant_key, + + + update_time, + + + sorted_index, + + + + + #{createTime}, + + + #{creator}, + + + #{deleteType}, + + + #{description}, + + + #{id}, + + + #{name}, + + + #{tenantKey}, + + + #{updateTime}, + + + #{sortedIndex}, + + + + + + UPDATE hrsa_tax_agent + + create_time=#{createTime}, + creator=#{creator}, + delete_type=#{deleteType}, + description=#{description}, + name=#{name}, + tenant_key=#{tenantKey}, + update_time=#{updateTime}, + sorted_index=#{sortedIndex} + + WHERE id = #{id} AND delete_type = 0 + + + + + UPDATE hrsa_tax_agent + SET delete_type = 1 + WHERE delete_type = 0 + AND id IN + + #{id} + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationDetailMapper.java b/src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationDetailMapper.java new file mode 100644 index 000000000..cbe931b93 --- /dev/null +++ b/src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationDetailMapper.java @@ -0,0 +1,73 @@ +package com.engine.salary.mapper.taxdeclaration; + +import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationEmployeeDTO; +import com.engine.salary.entity.taxdeclaration.param.TaxDeclarationDetailListQueryParam; +import com.engine.salary.entity.taxdeclaration.po.TaxDeclarationDetailPO; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; + + +public interface TaxDeclarationDetailMapper { + + + /** + * 分页查询人员id + * + * @param param + * @return + */ + List listPage4EmployeeId(@Param("param") TaxDeclarationDetailListQueryParam param); + + /** + * 查询人员id + * + * @param taxDeclarationId + * @return + */ + List list4EmployeeId(@Param("taxDeclarationId") Long taxDeclarationId); + + + /** + * 批量插入 + * + * @param taxDeclarationDetails + */ + void batchInsert(@Param("collection") Collection taxDeclarationDetails); + + /** + * 统计一共多少人员 + * + * @param taxDeclarationId + * @return + */ + int countEmployeeId(@Param("taxDeclarationId") Long taxDeclarationId); + /** + * 分页查询人员id + * + * @param taxDeclarationId + * @return + */ + List listEmployeeId(@Param("taxDeclarationId") Long taxDeclarationId); + + /** + * 查询个税申报表明细 + * + * @param taxDeclarationId + * @param employeeIds + * @return + */ + List listByTaxDeclarationIdAndEmployeeIds(@Param("taxDeclarationId") Long taxDeclarationId, @Param("collection") Collection employeeIds); + + /** + * 根据个税申报表id删除 + * + * @param taxDeclarationIds + */ + void deleteByTaxDeclarationIds(@Param("taxDeclarationIds") Collection taxDeclarationIds); + + List listAll(); + + int batchUpdate(@Param("collection") List taxDeclarationDetailPos); +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationDetailMapper.xml b/src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationDetailMapper.xml new file mode 100644 index 000000000..232e769bf --- /dev/null +++ b/src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationDetailMapper.xml @@ -0,0 +1,198 @@ + + + + + + + + + + + + + + + + + + + + t + . + create_time + , t.creator + , t.delete_type + , t.employee_id + , t.field_code + , t.field_value + , t.id + , t.tax_declaration_id + , t.tenant_key + , t.update_time + , t.employee_type + + + + + + + + + + + + + + + + + + + INSERT INTO hrsa_tax_declaration_detail + (id, tax_declaration_id, employee_id, field_code, field_value, creator, + create_time, update_time, delete_type, tenant_key, employee_type) + VALUES + + ( + #{item.id}, + #{item.taxDeclarationId}, + #{item.employeeId}, + #{item.fieldCode}, + #{item.fieldValue}, + #{item.creator}, + #{item.createTime}, + #{item.updateTime}, + #{item.deleteType}, + #{item.tenantKey}, + #{item.employeeType} + ) + + + + + INSERT INTO hrsa_tax_declaration_detail + (id, tax_declaration_id, employee_id, field_code, field_value, creator, + create_time, update_time, delete_type, tenant_key, employee_type) + + + select + #{item.id,jdbcType=DOUBLE}, + #{item.taxDeclarationId,jdbcType=DOUBLE}, + #{item.employeeId,jdbcType=DOUBLE}, + #{item.fieldCode,jdbcType=VARCHAR}, + #{item.fieldValue,jdbcType=VARCHAR}, + #{item.creator,jdbcType=DOUBLE}, + #{item.createTime,jdbcType=VARCHAR}, + #{item.updateTime,jdbcType=VARCHAR}, + #{item.deleteType,jdbcType=INTEGER}, + #{item.tenantKey,jdbcType=VARCHAR}, + #{item.employeeType,jdbcType=INTEGER} + from dual + + + + + INSERT INTO hrsa_tax_declaration_detail + (id,tax_declaration_id, employee_id, field_code, field_value, creator, + create_time, update_time, delete_type, tenant_key, employee_type) + VALUES + ( + #{item.id}, + #{item.taxDeclarationId}, + #{item.employeeId}, + #{item.fieldCode}, + #{item.fieldValue}, + #{item.creator}, + #{item.createTime}, + #{item.updateTime}, + #{item.deleteType}, + #{item.tenantKey}, + #{item.employeeType} + ) + + + + + + UPDATE hrsa_tax_declaration_detail + SET delete_type = 1 + WHERE delete_type = 0 + AND tax_declaration_id IN + + #{taxDeclarationIds} + + + + + + + + + update hrsa_tax_declaration_detail + + + + + when id=#{item.id} then #{item.fieldValue} + + + + + + + when id=#{item.id} then #{item.deleteType} + + + + + where + id in + + #{item.id} + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationMapper.java b/src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationMapper.java new file mode 100644 index 000000000..5785ed794 --- /dev/null +++ b/src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationMapper.java @@ -0,0 +1,44 @@ +package com.engine.salary.mapper.taxdeclaration; + +import com.engine.salary.entity.taxdeclaration.po.TaxDeclarationPO; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; + + +public interface TaxDeclarationMapper { + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + TaxDeclarationPO getById(Long id); + + + /** + * 条件查询 + * + * @return 返回集合,没有返回空List + */ + + List listSome(TaxDeclarationPO taxDeclarationPO); + /** + * 批量插入 + * + * @param taxDeclarationDetails + */ + void batchInsert(@Param("collection") Collection taxDeclarationDetails); + + /** + * 根据id删除个税申报表 + * + * @param ids + */ + void deleteByIds(@Param("ids") Collection ids); + + int deleteByIdZj(Long id); +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationMapper.xml b/src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationMapper.xml new file mode 100644 index 000000000..1810e8970 --- /dev/null +++ b/src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationMapper.xml @@ -0,0 +1,150 @@ + + + + + + + + + + + + + + + + + + + + t + . + create_time + , t.creator + , t.delete_type + , t.description + , t.id + , t.salary_month + , t.tax_agent_id + , t.tax_cycle + , t.tenant_key + , t.update_time + ,t.income_category + + + + UPDATE hrsa_tax_declaration + SET delete_type = 1 + WHERE delete_type = 0 + AND id = #{id} + + + + + + + + + + + INSERT INTO hrsa_tax_declaration(id, salary_month, tax_cycle, tax_agent_id, description, + creator, create_time, update_time, delete_type, tenant_key ,income_category) + VALUES + + ( + #{item.id}, + #{item.salaryMonth}, + #{item.taxCycle}, + #{item.taxAgentId}, + #{item.description}, + #{item.creator}, + #{item.createTime}, + #{item.updateTime}, + #{item.deleteType}, + #{item.tenantKey}, + #{item.incomeCategory} + ) + + + + INSERT INTO hrsa_tax_declaration(id,salary_month, tax_cycle, tax_agent_id, description, + creator, create_time, update_time, delete_type, tenant_key ,income_category) + + + select + #{item.id,jdbcType=DOUBLE}, + #{item.salaryMonth,jdbcType=DATE}, + #{item.taxCycle,jdbcType=DATE}, + #{item.taxAgentId,jdbcType=DOUBLE}, + #{item.description,jdbcType=VARCHAR}, + #{item.creator,jdbcType=DOUBLE}, + #{item.createTime,jdbcType=DATE}, + #{item.updateTime,jdbcType=DATE}, + #{item.deleteType,jdbcType=INTEGER}, + #{item.tenantKey,jdbcType=VARCHAR}, + #{item.incomeCategory,jdbcType=INTEGER} + from dual + + + + + INSERT INTO hrsa_tax_declaration(id,salary_month, tax_cycle, tax_agent_id, description, + creator, create_time, update_time, delete_type, tenant_key ,income_category) + VALUES + ( + #{item.id}, + #{item.salaryMonth}, + #{item.taxCycle}, + #{item.taxAgentId}, + #{item.description}, + #{item.creator}, + #{item.createTime}, + #{item.updateTime}, + #{item.deleteType}, + #{item.tenantKey}, + #{item.incomeCategory} + ) + + + + + + UPDATE hrsa_tax_declaration + SET delete_type = 1 + WHERE delete_type = 0 + AND id IN + + #{id} + + + + \ No newline at end of file diff --git a/src/com/engine/salary/process/salaryArchive/SalaryArchiveActionAPI.java b/src/com/engine/salary/process/salaryArchive/SalaryArchiveActionAPI.java new file mode 100644 index 000000000..2fa4e2126 --- /dev/null +++ b/src/com/engine/salary/process/salaryArchive/SalaryArchiveActionAPI.java @@ -0,0 +1,127 @@ +package com.engine.salary.process.salaryArchive; + +import com.engine.common.util.ServiceUtil; +import com.engine.salary.entity.salaryarchive.dto.SalaryArchiveFormDTO; +import com.engine.salary.entity.salaryarchive.param.SalaryArchiveImportActionParam; +import com.engine.salary.entity.salaryarchive.po.SalaryArchivePO; +import com.engine.salary.util.ResponseResult; +import com.engine.salary.wrapper.SalaryArchiveWrapper; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import lombok.extern.slf4j.Slf4j; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import java.util.List; +import java.util.Map; + + +/** + * 薪资档案流程使用 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author liuliang + * @version 1.0 + **/ +@Slf4j +public class SalaryArchiveActionAPI { + + private SalaryArchiveWrapper getSalaryArchiveWrapper(User user) { + return ServiceUtil.getService(SalaryArchiveWrapper.class, user); + } + + /** + * 前置校验、列表添加接口 + * @param importData + * @return + */ + @POST + @Path("/checkImportSalaryArchiveListAdd") + @Produces(MediaType.APPLICATION_JSON) + public String importSalaryArchiveInit(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryArchiveImportActionParam importData) { + User user = HrmUserVarify.getUser(request, response); + importData.setImportType("init"); + importData.setAddData(false); + return new ResponseResult>(user).run(getSalaryArchiveWrapper(user)::checkSalaryArchiveInit, importData); + } + + /** + * 初始化档案 + * @param importData + * @return + */ + @POST + @Path("/initSalaryArchive") + @Produces(MediaType.APPLICATION_JSON) + public String salaryArchiveListInit(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryArchiveImportActionParam importData) { + User user = HrmUserVarify.getUser(request, response); + importData.setImportType("init"); + importData.setAddData(true); + return new ResponseResult>(user).run(getSalaryArchiveWrapper(user)::importSalaryArchiveInit, importData); + } + + @POST + @Path("/checkAdjustmentSalaryArchive") + @Produces(MediaType.APPLICATION_JSON) + public String checkAdjustmentSalaryArchive(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryArchiveImportActionParam importData) { + User user = HrmUserVarify.getUser(request, response); + importData.setImportType("salaryItemAdjust"); + importData.setAddData(true); + return new ResponseResult>(user).run(getSalaryArchiveWrapper(user)::checkAdjustmentSalaryArchive, importData); + } + + @POST + @Path("/adjustmentSalaryArchive") + @Produces(MediaType.APPLICATION_JSON) + public String adjustmentSalaryArchive(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryArchiveImportActionParam importData) { + User user = HrmUserVarify.getUser(request, response); + importData.setImportType("salaryItemAdjust"); + importData.setAddData(true); + return new ResponseResult>(user).run(getSalaryArchiveWrapper(user)::adjustmentSalaryArchive, importData); + } + + /** + * 获取档案信息,默认需要传人员和扣缴义务人id,若只传人员id,发现多个发薪档案会抛出异常提示 + * + * 废弃,该接口仅返回基础信息。前端调用较为复杂,以后才有获取生效数据接口 + * @param request + * @param response + * @param param + * @return 档案基础信息 + */ + @POST + @Path("/salaryArchiveInfo") + @Produces(MediaType.APPLICATION_JSON) + @Deprecated + public String adjustmentSalaryArchive(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryArchiveProcessQueryParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryArchiveWrapper(user)::getSalaryArchiveInfo, param); + } + + /** + * 获取档案信息,默认需要传人员和扣缴义务人id,若只传人员id,发现多个发薪档案会抛出异常提示 + * + * 废弃,该接口仅返回基础信息。前端调用较为复杂,以后才有获取生效数据接口 + * @param request + * @param response + * @param param + * @return 档案基础信息 + */ + @POST + @Path("/v2/salaryArchiveInfo") + @Produces(MediaType.APPLICATION_JSON) + public String salaryArchiveInfo(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryArchiveProcessQueryParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalaryArchiveWrapper(user)::getSalaryArchiveInfoV2, param); + } + + + +} diff --git a/src/com/engine/salary/process/salaryArchive/SalaryArchiveInfo.java b/src/com/engine/salary/process/salaryArchive/SalaryArchiveInfo.java new file mode 100644 index 000000000..f244624a3 --- /dev/null +++ b/src/com/engine/salary/process/salaryArchive/SalaryArchiveInfo.java @@ -0,0 +1,44 @@ +package com.engine.salary.process.salaryArchive; + +import com.engine.salary.enums.salaryarchive.SalaryArchiveStatusEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.List; + +/** + * 薪资档案 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//薪资档案查询参数 +public class SalaryArchiveInfo { + + private Collection ids; + + /** + * 员工id + */ + private Long employeeId; + + /** + * 扣缴义务人id + */ + private Long taxAgentId; + + /** + * 档案状态 + * @see SalaryArchiveStatusEnum + */ + private List runStatusList; +} diff --git a/src/com/engine/salary/process/salaryArchive/SalaryArchiveProcessQueryParam.java b/src/com/engine/salary/process/salaryArchive/SalaryArchiveProcessQueryParam.java new file mode 100644 index 000000000..04bbeef2d --- /dev/null +++ b/src/com/engine/salary/process/salaryArchive/SalaryArchiveProcessQueryParam.java @@ -0,0 +1,44 @@ +package com.engine.salary.process.salaryArchive; + +import com.engine.salary.enums.salaryarchive.SalaryArchiveStatusEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.List; + +/** + * 薪资档案 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//薪资档案查询参数 +public class SalaryArchiveProcessQueryParam { + + private Collection ids; + + /** + * 员工id + */ + private Long employeeId; + + /** + * 扣缴义务人id + */ + private Long taxAgentId; + + /** + * 档案状态 + * @see SalaryArchiveStatusEnum + */ + private List runStatusList; +} diff --git a/src/com/engine/salary/process/siArchives/SIArchiveActionAPI.java b/src/com/engine/salary/process/siArchives/SIArchiveActionAPI.java new file mode 100644 index 000000000..657cd3e60 --- /dev/null +++ b/src/com/engine/salary/process/siArchives/SIArchiveActionAPI.java @@ -0,0 +1,64 @@ +package com.engine.salary.process.siArchives; + +import com.engine.common.util.ServiceUtil; +import com.engine.salary.entity.siarchives.param.SIArchiveImportParam; +import com.engine.salary.enums.siaccount.EmployeeStatusEnum; +import com.engine.salary.service.SISchemeService; +import com.engine.salary.service.impl.SISchemeServiceImpl; +import com.engine.salary.util.ResponseResult; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import lombok.extern.slf4j.Slf4j; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import java.util.Map; + +/** + * @Author: sy + * @Description: 社保福利档案流程使用 + * @Date: 2022/11/10 + **/ +@Slf4j +public class SIArchiveActionAPI { + + private SISchemeService getService(User user) { + return ServiceUtil.getService(SISchemeServiceImpl.class,user); + } + + /** + * 前置校验、列表添加接口 + * @param importData + * @return + */ + @POST + @Path("/checkImportSIArchiveListAdd") + @Produces(MediaType.APPLICATION_JSON) + public String checkImportSIArchiveListAdd(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SIArchiveImportParam importData) { + User user = HrmUserVarify.getUser(request, response); + importData.setRunStatus(EmployeeStatusEnum.STAY_ADD.getValue()); + importData.setAddData(false); + return new ResponseResult>(user).run(getService(user)::checkSIArchiveAdd, importData); + } + + /** + * 新增社保福利档案 + * @param importData + * @return + */ + @POST + @Path("/addSIArchive") + @Produces(MediaType.APPLICATION_JSON) + public String addSIArchive(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SIArchiveImportParam importData) { + User user = HrmUserVarify.getUser(request, response); + importData.setRunStatus(EmployeeStatusEnum.STAY_ADD.getValue()); + importData.setAddData(true); + return new ResponseResult>(user).run(getService(user)::addSIArchive, importData); + } +} diff --git a/src/com/engine/salary/remote/attend/cmd/GetKQReportCmd.java b/src/com/engine/salary/remote/attend/cmd/GetKQReportCmd.java new file mode 100644 index 000000000..e7cfcd63f --- /dev/null +++ b/src/com/engine/salary/remote/attend/cmd/GetKQReportCmd.java @@ -0,0 +1,603 @@ +package com.engine.salary.remote.attend.cmd; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.*; +import com.engine.kq.util.KQDurationCalculatorUtil; +import com.engine.kq.util.PageUidFactory; +import weaver.common.DateUtil; +import weaver.conn.RecordSet; +import weaver.general.TimeUtil; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.hrm.company.DepartmentComInfo; +import weaver.hrm.company.SubCompanyComInfo; +import weaver.hrm.job.JobTitlesComInfo; +import weaver.hrm.resource.ResourceComInfo; +import weaver.systeminfo.SystemEnv; + +import java.math.BigDecimal; +import java.util.*; + +public class GetKQReportCmd extends AbstractCommonCommand> { + + public GetKQReportCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + RecordSet rs = new RecordSet(); + String sql = ""; + try{ + String pageUid = PageUidFactory.getHrmPageUid("KQReport"); + + SubCompanyComInfo subCompanyComInfo = new SubCompanyComInfo(); + DepartmentComInfo departmentComInfo = new DepartmentComInfo(); + ResourceComInfo resourceComInfo = new ResourceComInfo(); + JobTitlesComInfo jobTitlesComInfo = new JobTitlesComInfo(); + KQLeaveRulesBiz kqLeaveRulesBiz = new KQLeaveRulesBiz(); + KQReportBiz kqReportBiz = new KQReportBiz(); + + JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data"))); + String attendanceSerial = Util.null2String(jsonObj.get("attendanceSerial")); + String fromDate = Util.null2String(jsonObj.get("fromDate")); + String toDate = Util.null2String(jsonObj.get("toDate")); + String typeselect =Util.null2String(jsonObj.get("typeselect")); + if(typeselect.length()==0)typeselect = "3"; + if(!typeselect.equals("") && !typeselect.equals("0")&& !typeselect.equals("6")){ + if(typeselect.equals("1")){ + fromDate = TimeUtil.getCurrentDateString(); + toDate = TimeUtil.getCurrentDateString(); + }else{ + fromDate = TimeUtil.getDateByOption(typeselect,"0"); + toDate = TimeUtil.getDateByOption(typeselect,"1"); + } + } + String subCompanyId = Util.null2String(jsonObj.get("subCompanyId")); + String departmentId = Util.null2String(jsonObj.get("departmentId")); + String resourceId = Util.null2String(jsonObj.get("resourceId")); + String allLevel = Util.null2String(jsonObj.get("allLevel")); + String isNoAccount = Util.null2String(jsonObj.get("isNoAccount")); + String viewScope = Util.null2String(jsonObj.get("viewScope")); + String isFromMyAttendance = Util.null2String(jsonObj.get("isFromMyAttendance"));//是否是来自我的考勤的请求,如果是,不加载考勤报表权限共享的限制,不然我的考勤会提示无权限 + int pageIndex = Util.getIntValue(Util.null2String(jsonObj.get("pageIndex")), 1); + int pageSize = KQReportBiz.getPageSize(Util.null2String(jsonObj.get("pageSize")),pageUid,user.getUID()); + int count = 0; + int pageCount = 0; + int isHavePre = 0; + int isHaveNext = 0; + + + String rightSql = kqReportBiz.getReportRight("1",""+user.getUID(),"a"); + if(isFromMyAttendance.equals("1")){ + rightSql = ""; + } + + List> leaveRules = kqLeaveRulesBiz.getAllLeaveRules(); + List columns = new ArrayList(); + Map column = null; + List datas = new ArrayList(); + Map data = null; + Map mapChildColumnInfo = null; + List childColumns = null; + KQReportFieldComInfo kqReportFieldComInfo = new KQReportFieldComInfo(); + while (kqReportFieldComInfo.next()){ + if(Util.null2String(kqReportFieldComInfo.getParentid()).length()>0)continue; + if(kqReportFieldComInfo.getFieldname().equals("kqCalendar"))continue; + if(KQReportFieldComInfo.cascadekey2fieldname.keySet().contains(kqReportFieldComInfo.getFieldname()))continue; + if(!kqReportFieldComInfo.getReportType().equals("all") && !kqReportFieldComInfo.getReportType().equals("month"))continue; + if("leave".equalsIgnoreCase(kqReportFieldComInfo.getFieldname())&&leaveRules.size()==0)continue; + + column = new HashMap(); + column.put("title", SystemEnv.getHtmlLabelNames(kqReportFieldComInfo.getFieldlabel(), user.getLanguage())); + column.put("unit", KQReportBiz.getUnitType(kqReportFieldComInfo, user)); + column.put("dataIndex", kqReportFieldComInfo.getFieldname()); + column.put("type", kqReportFieldComInfo.getFieldname()); + column.put("key", kqReportFieldComInfo.getFieldname()); + column.put("isSystem", kqReportFieldComInfo.getIsSystem()); + mapChildColumnInfo = this.getChildColumnsInfo(kqReportFieldComInfo.getFieldname(),user); + childColumns = (List)mapChildColumnInfo.get("childColumns"); + if(childColumns.size()>0) {//跨列width取子列的width + column.put("rowSpan", 1); + column.put("width", mapChildColumnInfo.get("sumChildColumnWidth")); + column.put("children", childColumns); + }else{ + column.put("rowSpan", 3); + column.put("width", Util.getIntValue(kqReportFieldComInfo.getWidth())); + } + column.put("showDetial",kqReportFieldComInfo.getShowDetial()); + columns.add(column); + columns.addAll(this.getCascadeKeyColumnsInfo(kqReportFieldComInfo.getCascadekey(),user)); + } + + boolean isEnd = false; + Calendar cal = DateUtil.getCalendar(); + String today = DateUtil.getCurrentDate(); +// if(DateUtil.compDate(today, toDate)>0){//结束日期不大于今天 +// toDate = today; +// if(DateUtil.compDate(today, fromDate)>0){//结束日期不大于今天 +// fromDate = today; +// } +// } + +// childColumns = new ArrayList<>(); +// for(String date=fromDate; !isEnd;) { +// if(date.equals(toDate)) isEnd = true; +// column = new HashMap(); +// column.put("title", DateUtil.geDayOfMonth(date)); +// column.put("dataIndex", date); +// column.put("key", date); +// column.put("type", date); +// column.put("rowSpan", 1); +// column.put("width", 65); +// column.put("isCalendar", 1); +// childColumns.add(column); +// cal.setTime(DateUtil.parseToDate(date)); +// date = DateUtil.getDate(cal.getTime(), 1); +// } + +// column = new HashMap(); +// column.put("title", SystemEnv.getHtmlLabelName(386476, user.getLanguage())); +// column.put("dataIndex", "kqCalendar"); +// column.put("key", "kqCalendar"); +// if(childColumns.size()>0) {//跨列width取子列的width +// column.put("rowSpan", 1); +// column.put("width", childColumns.size()*65); +// column.put("children", childColumns); +// } +// columns.add(column); + + String forgotBeginWorkCheck_field = " sum(b.forgotBeginWorkCheck) "; + + if(rs.getDBType().equalsIgnoreCase("oracle")) { + forgotBeginWorkCheck_field = " sum(nvl(b.forgotBeginWorkCheck,0)) "; + }else if((rs.getDBType()).equalsIgnoreCase("mysql")){ + forgotBeginWorkCheck_field = " sum(ifnull(b.forgotBeginWorkCheck,0)) "; + }else { + forgotBeginWorkCheck_field = " sum(isnull(b.forgotBeginWorkCheck,0)) "; + } + + Map definedFieldInfo = new KQFormatBiz().getDefinedField(); + String definedFieldSum = Util.null2String(definedFieldInfo.get("definedFieldSum")); + + String backFields = " a.id,a.lastname,a.workcode,a.dsporder,b.resourceid,a.subcompanyid1 as subcompanyid,a.departmentid,a.jobtitle," + + " sum(b.workdays) as workdays,sum(b.workMins) as workMins,sum(b.attendancedays) as attendancedays," + + " sum(b.attendanceMins) as attendanceMins,sum(b.beLate) as beLate,sum(b.beLateMins) as beLateMins, " + + " sum(b.graveBeLate) as graveBeLate, sum(b.graveBeLateMins) as graveBeLateMins,sum(b.leaveEearly) as leaveEearly," + + " sum(b.leaveEarlyMins) as leaveEarlyMins, sum(b.graveLeaveEarly) as graveLeaveEarly, " + + " sum(b.graveLeaveEarlyMins) as graveLeaveEarlyMins,sum(b.absenteeism) as absenteeism, " + + " sum(b.signdays) as signdays,sum(b.signmins) as signmins, "+ + " sum(b.absenteeismMins) as absenteeismMins, sum(b.forgotCheck)+"+forgotBeginWorkCheck_field+" as forgotCheck "+(definedFieldSum.length()>0?","+definedFieldSum+"":""); + + if(rs.getDBType().equals("oracle")){ + backFields = "/*+ index(kq_format_total IDX_KQ_FORMAT_TOTAL_KQDATE) */ "+backFields; + } + String sqlFrom = " from hrmresource a, kq_format_total b where a.id= b.resourceid and b.kqdate >='"+fromDate+"' and b.kqdate <='"+toDate+"'"; + String sqlWhere = rightSql; + String groupBy = " group by a.id,a.lastname,a.workcode,a.dsporder,b.resourceid,a.subcompanyid1,a.departmentid,a.jobtitle "; + if(subCompanyId.length()>0){ + sqlWhere +=" and b.subcompanyid in("+subCompanyId+") "; + } + + if(departmentId.length()>0){ + sqlWhere +=" and b.departmentid in("+departmentId+") "; + } + + if(resourceId.length()>0){ + sqlWhere +=" and b.resourceid in("+resourceId+") "; + } + + if(viewScope.equals("4")){//我的下属 + if(allLevel.equals("1")){//所有下属 + sqlWhere+=" and a.managerstr like '%,"+user.getUID()+",%'"; + }else{ + sqlWhere+=" and a.managerid="+user.getUID();//直接下属 + } + } + if (!"1".equals(isNoAccount)) { + sqlWhere += " and a.loginid is not null "+(rs.getDBType().equals("oracle")?"":" and a.loginid<>'' "); + } + + sql = " select count(*) as c from ( select 1 as c "+sqlFrom+sqlWhere+groupBy+") t"; + rs.execute(sql); + if (rs.next()){ + count = rs.getInt("c"); + } + + if (count <= 0) { + pageCount = 0; + } + + pageCount = count / pageSize + ((count % pageSize > 0) ? 1 : 0); + + isHaveNext = (pageIndex + 1 <= pageCount) ? 1 : 0; + + isHavePre = (pageIndex - 1 >= 1) ? 1 : 0; + + String orderBy = " order by t.dsporder asc, t.lastname asc "; + String descOrderBy = " order by t.dsporder desc, t.lastname desc "; + + //默认排序设置 start,有性能问题,先取消,后面再看看有没有好的方式 +// String orderBySql = "select * from kq_report_order where userId=? and sort=1 order by orders"; +// rs.executeQuery(orderBySql, user.getUID()); +// if (rs.getCounts() <= 0) { +// orderBySql = "select * from kq_report_order where userId=0 and sort=1 order by orders"; +// rs.executeQuery(orderBySql); +// } +// while (rs.next()) { +// String dataIndex = rs.getString("dataIndex"); +// String ascOrDesc = rs.getString("ascOrDesc"); +// String ascOrDesc1 = (ascOrDesc.equals("")||ascOrDesc.equals("asc"))?"desc":"asc"; +// if (dataIndex.equals("organization")) { +// orderBy += ",showOrderOfDeptTree " + ascOrDesc + ",dept_id " + ascOrDesc; +// descOrderBy += ",showOrderOfDeptTree " + ascOrDesc1 + ",dept_id " + ascOrDesc1; +// } +// if (dataIndex.equalsIgnoreCase("dspOrder") || dataIndex.equalsIgnoreCase("lastName")) { +// orderBy += "," + dataIndex + " " + ascOrDesc + ",id " + ascOrDesc; +// descOrderBy += "," + dataIndex + " " + ascOrDesc1 + ",id " + ascOrDesc1; +// } else if (dataIndex.equalsIgnoreCase("deptShowOrder") || dataIndex.equalsIgnoreCase("deptName")) { +// orderBy += "," + dataIndex + " " + ascOrDesc + ",dept_id " + ascOrDesc; +// descOrderBy += "," + dataIndex + " " + ascOrDesc1 + ",dept_id " + ascOrDesc1; +// } else if (dataIndex.equalsIgnoreCase("subcomShowOrder") || dataIndex.equalsIgnoreCase("subcomName")) { +// orderBy += "," + dataIndex + " " + ascOrDesc + ",subcom_id " + ascOrDesc; +// descOrderBy += "," + dataIndex + " " + ascOrDesc1 + ",subcom_id " + ascOrDesc1; +// } +// } +// orderBy = orderBy.startsWith(",") ? orderBy.substring(1) : orderBy; +// descOrderBy = descOrderBy.startsWith(",") ? descOrderBy.substring(1) : descOrderBy; +// orderBy = orderBy.equals("") ? " t.dspOrder,t.id " : orderBy; +// descOrderBy = descOrderBy.equals("") ? " t.dspOrder,t.id " : descOrderBy; +// orderBy = "order by "+orderBy; + + sql = backFields + sqlFrom + sqlWhere + groupBy; + +// if (pageIndex > 0 && pageSize > 0) { +// if (rs.getDBType().equals("oracle")) { +// sql = " select * from (select " + sql+") t "+orderBy; +// sql = "select * from ( select row_.*, rownum rownum_ from ( " + sql + " ) row_ where rownum <= " +// + (pageIndex * pageSize) + ") where rownum_ > " + ((pageIndex - 1) * pageSize); +// } else if (rs.getDBType().equals("mysql")) { +// sql = " select * from (select " + sql+") t "+orderBy; +// sql = "select t1.* from (" + sql + ") t1 limit " + ((pageIndex - 1) * pageSize) + "," + pageSize; +// } else { +// orderBy = " order by dsporder asc, lastname asc "; +// descOrderBy = " order by dsporder desc, lastname desc "; +// if (pageIndex > 1) { +// int topSize = pageSize; +// if (pageSize * pageIndex > count) { +// topSize = count - (pageSize * (pageIndex - 1)); +// } +// sql = " select top " + topSize + " * from ( select top " + topSize + " * from ( select top " +// + (pageIndex * pageSize) + sql + orderBy+ " ) tbltemp1 " + descOrderBy + ") tbltemp2 " + orderBy; +// } else { +// sql = " select top " + pageSize + sql+orderBy; +// } +// } +// } else { + sql = " select " + sql; +// } + Map flowData = kqReportBiz.getFlowData(params,user); + rs.execute(sql); + while (rs.next()) { + data = new HashMap<>(); + kqReportFieldComInfo.setTofirstRow(); + String id = rs.getString("id"); + data.put("resourceId",id); + while (kqReportFieldComInfo.next()){ + if(!Util.null2String(kqReportFieldComInfo.getIsdataColumn()).equals("1"))continue; + if(!kqReportFieldComInfo.getReportType().equals("all") && !kqReportFieldComInfo.getReportType().equals("month"))continue; + if("leave".equalsIgnoreCase(kqReportFieldComInfo.getFieldname())&&leaveRules.size()==0){ + continue; + } + String fieldName = kqReportFieldComInfo.getFieldname(); + String fieldValue = ""; + if(fieldName.equals("subcompany")){ + String tmpSubcompanyId = Util.null2String(rs.getString("subcompanyid")); + if(tmpSubcompanyId.length()==0){ + tmpSubcompanyId = Util.null2String(resourceComInfo.getSubCompanyID(id)); + } + data.put("subcompanyId",tmpSubcompanyId); + fieldValue = subCompanyComInfo.getSubCompanyname(tmpSubcompanyId); + }else if(fieldName.equals("department")){ + String tmpDepartmentId = Util.null2String(rs.getString("departmentid")); + if(tmpDepartmentId.length()==0){ + tmpDepartmentId = Util.null2String(resourceComInfo.getDepartmentID(id)); + } + data.put("departmentId",tmpDepartmentId); + fieldValue = departmentComInfo.getDepartmentname(tmpDepartmentId); + }else if(fieldName.equals("jobtitle")){ + String tmpJobtitleId = Util.null2String(rs.getString("jobtitle")); + if(tmpJobtitleId.length()==0){ + tmpJobtitleId = Util.null2String(resourceComInfo.getJobTitle(id)); + } + data.put("jobtitleId",tmpJobtitleId); + fieldValue = jobTitlesComInfo.getJobTitlesname(tmpJobtitleId); + }else if(fieldName.equals("attendanceSerial")){ + List serialIds = null; + if(attendanceSerial.length()>0){ + serialIds = Util.splitString2List(attendanceSerial,","); + } + for(int i=0;serialIds!=null&&i0) { + if(fieldValue.length() == 0){ + fieldValue="0"; + }else{ + if (kqReportFieldComInfo.getUnittype().equals("2")) { + fieldValue = KQDurationCalculatorUtil.getDurationRound(("" + (Util.getDoubleValue(fieldValue) / 60.0))); + } + } + } + } + data.put(fieldName,fieldValue); + } + + //请假 + List> allLeaveRules = kqLeaveRulesBiz.getAllLeaveRules(); + Map leaveRule = null; + for(int i=0;allLeaveRules!=null&&i)allLeaveRules.get(i); + String flowType = Util.null2String("leaveType_"+leaveRule.get("id")); + String leaveData = Util.null2String(flowData.get(id+"|"+flowType)); + String flowLeaveBackType = Util.null2String("leavebackType_"+leaveRule.get("id")); + String leavebackData = Util.null2s(Util.null2String(flowData.get(id+"|"+flowLeaveBackType)),"0.0"); + String b_flowLeaveData = ""; + String flowLeaveData = ""; + try{ + //以防止出现精度问题 + if(leaveData.length() == 0){ + leaveData = "0.0"; + } + if(leavebackData.length() == 0){ + leavebackData = "0.0"; + } + BigDecimal b_leaveData = new BigDecimal(leaveData); + BigDecimal b_leavebackData = new BigDecimal(leavebackData); + b_flowLeaveData = b_leaveData.subtract(b_leavebackData).toString(); + if(Util.getDoubleValue(b_flowLeaveData, -1) < 0){ + b_flowLeaveData = "0.0"; + } + }catch (Exception e){ + writeLog("GetKQReportCmd:leaveData"+leaveData+":leavebackData:"+leavebackData+":"+e); + } + + //考虑下冻结的数据 + if(b_flowLeaveData.length() > 0){ + flowLeaveData = KQDurationCalculatorUtil.getDurationRound(b_flowLeaveData); + }else{ + flowLeaveData = KQDurationCalculatorUtil.getDurationRound(Util.null2String(Util.getDoubleValue(leaveData,0.0)-Util.getDoubleValue(leavebackData,0.0))); + } + data.put(flowType,flowLeaveData); + } + + Map detialDatas = kqReportBiz.getDetialDatas(id,fromDate,toDate,user); + isEnd = false; + for(String date=fromDate; !isEnd;) { + if(date.equals(toDate)) isEnd = true; + if(DateUtil.compDate(today, date)>0){ + data.put(date,""); + }else{ + data.put(date,detialDatas.get(id+"|"+date)==null?SystemEnv.getHtmlLabelName(26593, user.getLanguage()):detialDatas.get(id+"|"+date)); + } + cal.setTime(DateUtil.parseToDate(date)); + date = DateUtil.getDate(cal.getTime(), 1); + } + datas.add(data); + } + + List lsHolidays = KQHolidaySetBiz.getHolidaySetListByScope(""+user.getUID(),fromDate,toDate); + retmap.put("holidays", lsHolidays); + + retmap.put("columns",columns); + retmap.put("datas",datas); + retmap.put("pagesize", pageSize); + retmap.put("pageindex", pageIndex); + retmap.put("count", count); + retmap.put("pagecount", pageCount); + retmap.put("ishavepre", isHavePre); + retmap.put("ishavenext", isHaveNext); + }catch (Exception e){ + writeLog(e); + } + return retmap; + } + + private Map getChildColumnsInfo(String parentid, User user){ + Map returnMap = new HashMap<>(); + List lsChildColumns = new ArrayList<>(); + Map column = null; + int sumChildColumnWidth = 0; + if(parentid.equals("attendanceSerial")){//考勤班次 + KQShiftManagementComInfo kqShiftManagementComInfo = new KQShiftManagementComInfo(); + JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data"))); + List serialIds = null; + if(Util.null2String(jsonObj.get("attendanceSerial")).length()>0){ + serialIds = Util.splitString2List(Util.null2String(jsonObj.get("attendanceSerial")),","); + } + for(int i=0;serialIds!=null&&i> leaveRules = kqLeaveRulesBiz.getAllLeaveRules(); + for(int i=0;leaveRules!=null&&i leaveRule = leaveRules.get(i); + String id = "leaveType_"+Util.null2String(leaveRule.get("id")); + String name = Util.null2String(leaveRule.get("name")); + String unitType = Util.null2String(leaveRule.get("unitType")); + column = new HashMap(); + column.put("title", name); + column.put("unit", KQUnitBiz.isLeaveHour(unitType) ?SystemEnv.getHtmlLabelName(391, user.getLanguage()):SystemEnv.getHtmlLabelName(1925, user.getLanguage())); + column.put("width", 65); + column.put("dataIndex", id); + column.put("key", id); + column.put("rowSpan", 2); + column.put("colSpan", 1); + column.put("showDetial","1"); + sumChildColumnWidth+=65; + lsChildColumns.add(column); + } + }else if(parentid.equals("overtime")){ + String[] overtimeChild = {"overtime_nonleave","overtime_4leave","overtimeTotal"}; + for(int i=0;i0){ + if(unitType.equals("1")){ + unitTypeName=SystemEnv.getHtmlLabelName(1925, user.getLanguage()); + }else if(unitType.equals("2")){ + unitTypeName=SystemEnv.getHtmlLabelName(391, user.getLanguage()); + }else if(unitType.equals("3")){ + unitTypeName=SystemEnv.getHtmlLabelName(18083, user.getLanguage()); + } + } + column.put("unit", unitTypeName); + } + column.put("title", SystemEnv.getHtmlLabelNames(fieldlabel, user.getLanguage())); + column.put("dataIndex", id); + column.put("key", id); + column.put("rowSpan", 1); + Map mapChildColumnInfo = getChildColumnsInfo(id, user); + int childWidth = 65; + List childColumns = (List)mapChildColumnInfo.get("childColumns"); + if(childColumns.size()>0) {//跨列width取子列的width + column.put("children", childColumns); + childWidth = Util.getIntValue(Util.null2String(mapChildColumnInfo.get("sumChildColumnWidth")),65); + } + column.put("width", childWidth+""); + sumChildColumnWidth+=childWidth; + lsChildColumns.add(column); + } + }else{ + KQReportFieldComInfo kqReportFieldComInfo = new KQReportFieldComInfo(); + while (kqReportFieldComInfo.next()){ + if(kqReportFieldComInfo.getParentid().equals(parentid)) { + if(!kqReportFieldComInfo.getReportType().equals("month"))continue; + column = new HashMap(); + column.put("title", SystemEnv.getHtmlLabelNames(kqReportFieldComInfo.getFieldlabel(), user.getLanguage())); + column.put("unit", KQReportBiz.getUnitType(kqReportFieldComInfo, user)); + column.put("width", Util.getIntValue(kqReportFieldComInfo.getWidth())); + column.put("dataIndex", kqReportFieldComInfo.getFieldname()); + column.put("key", kqReportFieldComInfo.getFieldname()); + column.put("rowSpan", 1); + column.put("colSpan", 1); + column.put("showDetial",kqReportFieldComInfo.getShowDetial()); + sumChildColumnWidth+=Util.getIntValue(kqReportFieldComInfo.getWidth()); + lsChildColumns.add(column); + } + } + } + returnMap.put("childColumns",lsChildColumns); + returnMap.put("sumChildColumnWidth",sumChildColumnWidth); + return returnMap; + } + + private List getCascadeKeyColumnsInfo(String cascadeKey, User user){ + List lsChildColumns = new ArrayList<>(); + if(Util.null2String(cascadeKey).length()==0){ + return lsChildColumns; + } + Map column = null; + List lsCascadeKey = Util.splitString2List(cascadeKey,","); + KQReportFieldComInfo kqReportFieldComInfo = new KQReportFieldComInfo(); + for(int i=0;i> { + + public GetSearchListCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + Map resultMap = new HashMap(); + /** + * 分页控件返回的值 + * currentPage:当前页数 + * pageSize:每页多少条数据 + */ + int currentPage = Util.getIntValue((String) params.get("currentPage"), 1); + int pageSize = Util.getIntValue((String) params.get("pageSize"), 10); + /** + * 时间范围选择的年份 + * dateScope:5-本年、8-上一年 + * selectedYear:指定年份 + */ + String dateScope = Util.null2String(params.get("dateScope")); + String selectedYear = Util.null2String(params.get("selectedYear")); + if (dateScope.equals("5") || dateScope.equals("8")) { + selectedYear = TimeUtil.getDateByOption(dateScope, "0").substring(0, 4); + } + /** + * 数据范围 + * dataScope:0-总部、1-分部、2-分部、3-人员、4-我的下属 + * subcomId:指定分部ID + * deptId:指定部门ID + * resourceId:指定人员ID + * allLevel:是否包含下级下属:0-不包含、1-包含 + */ + String dataScope = Util.null2String(params.get("dataScope")); + String subcomId = Util.null2String(params.get("subcomId")); + String deptId = Util.null2String(params.get("deptId")); + String resourceId = Util.null2String(params.get("resourceId")); + String allLevel = Util.null2String(params.get("allLevel")); + /** + * isNoAccount:是否显示无账号人员:true-显示、false-不显示 + */ + String isNoAccount = Util.null2String(params.get("isNoAccount")); + + try { + /** + * 获取考勤报表权限共享设置 + */ + KQReportBiz kqReportBiz = new KQReportBiz(); +// String rightStr = kqReportBiz.getReportRight("4", "" + user.getUID(), "a"); + String rightStr =""; + + /** + * 拼凑查询结果列表的表头 + */ + List> columnsList = new ArrayList>(); + List hrmFieldBeanList = new ArrayList(); + HrmFieldBean hrmFieldBean = null; + String[] tempArr = new String[]{"lastName,413", "subcom,141", "dept,124", "jobtitle,6086","workcode,714", "companyStartDate,1516"}; + for (int i = 0; i < tempArr.length; i++) { + String[] fieldInfo = tempArr[i].split(","); + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname(fieldInfo[0]); + hrmFieldBean.setFieldlabel(fieldInfo[1]); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("1"); + hrmFieldBean.setViewAttr(1); + hrmFieldBean.setIsFormField(true); + hrmFieldBeanList.add(hrmFieldBean); + } + + /**********************************************************************************************************/ + + /**获取假期类型的相关设置*/ + + /*请假类型的ID*/ + String leaveRulesId = ""; + + /*假期类型的名称,用作查询结果列表的表头显示*/ + String leaveName = ""; + + /*最小请假单位:1-按天请假、2-按半天请假、3-按小时请假、4-按整天请假*/ + int minimumUnit = 1; + + /*请假单位的显示名称是天还是小时*/ + String unitName = ""; + + /*是否开启假期余额,没有开启假期余额时需要提示“不限制余额*/ + int balanceEnable = 0; + + /**********************************************************************************************************/ + + /*是否是混合模式(福利年假+法定年假)*/ + boolean isMixMode = false; + + //是否是调休 + boolean isTiaoXiu = false; + + /**********************************************************************************************************/ + + /*获取当前日期*/ + String currentDate = DateUtil.getCurrentDate(); + + Map balanceMap = new HashMap(); + KQLeaveRulesComInfo rulesComInfo = new KQLeaveRulesComInfo(); + rulesComInfo.setTofirstRow(); + while (rulesComInfo.next()) { + if (rulesComInfo.getIsEnable().equals("0")) { + continue;//此假期类型没有启用 + } + + /*获取假期类型的设置 start*/ + leaveRulesId = rulesComInfo.getId(); + leaveName = Util.formatMultiLang(rulesComInfo.getLeaveName(), "" + user.getLanguage()); + minimumUnit = Util.getIntValue(rulesComInfo.getMinimumUnit(), 1); + if (minimumUnit == 1 || minimumUnit == 2 || minimumUnit == 4) { + unitName = SystemEnv.getHtmlLabelName(389325, user.getLanguage());//(天) + } else { + unitName = SystemEnv.getHtmlLabelName(389326, user.getLanguage());//(小时) + } + String showName = leaveName + unitName; + balanceEnable = Util.getIntValue(rulesComInfo.getBalanceEnable(), 0); + + isMixMode = KQLeaveRulesBiz.isMixMode(leaveRulesId); + isTiaoXiu = KQLeaveRulesBiz.isTiaoXiu(leaveRulesId); + /*获取假期类型的设置 end*/ + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname(rulesComInfo.getId()); + hrmFieldBean.setFieldlabelname(showName); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("1"); + hrmFieldBean.setViewAttr(1); + hrmFieldBean.setIsFormField(true); + hrmFieldBeanList.add(hrmFieldBean); + + /*判断该假期规则是否开启了假期余额,若没有开启,则无需查找该假期的余额,直接遍历下一个假期*/ + if (balanceEnable == 0) { + continue; + } + //如果是调休,获取假期余额的方式有些不同 + if(isTiaoXiu){ + params.put("leaveRulesId",leaveRulesId); + params.put("showAll","false"); + Map _balanceMap = KQBalanceOfLeaveBiz.getRestAmountMapByDis5(params,user); + balanceMap.putAll(_balanceMap); + continue; + } + + /*查询指定年份指定假期的余额数据,并放入集合中,用于后续拼凑查询结果数据*/ + KQTransMethod transMethod = new KQTransMethod(); + RecordSet recordSet = new RecordSet(); + String sql = "select a.id hrmResourceId,a.companyStartDate,a.workStartDate,b.* from HrmResource a left join kq_balanceOfLeave b on a.id=b.resourceId " + + "and belongYear='" + selectedYear + "' and b.leaveRulesId=" + leaveRulesId + " where 1=1 "; + if (recordSet.getDBType().equalsIgnoreCase("sqlserver")) { + sql = "select a.id hrmResourceId,a.companyStartDate,a.workStartDate,b.*,ROW_NUMBER() OVER(order by dspOrder,a.id) as rn from HrmResource a left join kq_balanceOfLeave b on a.id=b.resourceId " + + "and belongYear='" + selectedYear + "' and b.leaveRulesId=" + leaveRulesId + " where 1=1 "; + } else if (recordSet.getDBType().equalsIgnoreCase("mysql")) { + sql = "select a.id hrmResourceId,a.companyStartDate,a.workStartDate,b.* from HrmResource a left join kq_balanceOfLeave b on a.id=b.resourceId " + + "and belongYear='" + selectedYear + "' and b.leaveRulesId=" + leaveRulesId + " where 1=1 "; + } + if (dataScope.equals("0")) { + //总部 + } else if (dataScope.equals("1")) { + sql += " and a.subcompanyId1 in (" + subcomId + ") "; + } else if (dataScope.equals("2")) { + sql += " and a.departmentId in (" + deptId + ") "; + } else if (dataScope.equals("3")) { + sql += " and a.id in (" + resourceId + ")"; + } else if (dataScope.equals("4")) { + if (allLevel.equals("1")) { + sql += " and (a.id=" + user.getUID() + " or a.managerStr like '%," + user.getUID() + ",%' )"; + } else { + sql += " and (a.id=" + user.getUID() + " or a.managerid = " + user.getUID() + ")"; + } + } + if (isNoAccount.equals("false")) { + if (recordSet.getDBType().equalsIgnoreCase("sqlserver") + || recordSet.getDBType().equalsIgnoreCase("mysql")) { + sql += " and (loginId is not null and loginId<>'')"; + } else { + sql += " and (loginId is not null)"; + } + } + //考勤报表共享设置 + if (!rightStr.equals("") && !dataScope.equals("4")) { + sql += rightStr; + } + if (!recordSet.getDBType().equalsIgnoreCase("sqlserver")) { + sql += " order by dspOrder,hrmResourceId "; + } + + String pageSql = "select * from (select tmp.*,rownum rn from (" + sql + ") tmp where rownum<=" + (pageSize * currentPage) + ") where rn>=" + (pageSize * (currentPage - 1) + 1); + if (recordSet.getDBType().equalsIgnoreCase("sqlserver")) { + pageSql = "select t.* from (" + sql + ") t where 1=1 and rn>=" + (pageSize * (currentPage - 1) + 1) + " and rn<=" + (pageSize * currentPage); + } else if (recordSet.getDBType().equalsIgnoreCase("mysql")) { + pageSql = sql + " limit " + (currentPage - 1) * pageSize + "," + pageSize; + } + recordSet.executeQuery(pageSql); + while (recordSet.next()) { + String hrmResourceId = recordSet.getString("hrmResourceId"); + //所属年份 + String belongYear = recordSet.getString("belongYear"); + //失效日期 + String effectiveDate = recordSet.getString("effectiveDate"); + //失效日期 + String expirationDate = recordSet.getString("expirationDate"); + /*判断假期余额的有效期*/ + boolean status = KQBalanceOfLeaveBiz.getBalanceStatus(leaveRulesId, hrmResourceId, belongYear, currentDate,effectiveDate,expirationDate); + if (!status) { + continue; + } + BigDecimal baseAmount = new BigDecimal(Util.getDoubleValue(recordSet.getString("baseAmount"), 0.00));//假期基数 + BigDecimal usedAmount = new BigDecimal(Util.getDoubleValue(recordSet.getString("usedAmount"), 0.00));//已用假期 + BigDecimal extraAmount = new BigDecimal(Util.getDoubleValue(recordSet.getString("extraAmount"), 0.00));//额外假期 + BigDecimal baseAmount2 = new BigDecimal(Util.getDoubleValue(recordSet.getString("baseAmount2"), 0.00));//用于混合模式时:福利年假基数 + BigDecimal usedAmount2 = new BigDecimal(Util.getDoubleValue(recordSet.getString("usedAmount2"), 0.00));//用于混合模式时:已用福利年假 + BigDecimal extraAmount2 = new BigDecimal(Util.getDoubleValue(recordSet.getString("extraAmount2"), 0.00));//用于混合模式时:额外福利年假 + + BigDecimal restAmount = new BigDecimal(0); + if (isMixMode) { + /*释放规则*/ + baseAmount = KQBalanceOfLeaveBiz.getCanUseAmount(hrmResourceId, leaveRulesId, belongYear, baseAmount, "legal", currentDate); + baseAmount2 = KQBalanceOfLeaveBiz.getCanUseAmount(hrmResourceId, leaveRulesId, belongYear, baseAmount2, "welfare", currentDate); + + restAmount = baseAmount.add(extraAmount).subtract(usedAmount).add(baseAmount2).add(extraAmount2).subtract(usedAmount2); + } else { + /*释放规则*/ + baseAmount = KQBalanceOfLeaveBiz.getCanUseAmount(hrmResourceId, leaveRulesId, belongYear, baseAmount, "", currentDate); + + restAmount = baseAmount.add(extraAmount).subtract(usedAmount); + } + balanceMap.put(hrmResourceId + "_" + leaveRulesId, restAmount); + } + } + + /** + * 用于拼凑查询结果列表的表数据 + */ + SubCompanyComInfo subCompanyComInfo = new SubCompanyComInfo(); + DepartmentComInfo departmentComInfo = new DepartmentComInfo(); + JobTitlesComInfo jobTitlesComInfo = new JobTitlesComInfo(); + List> dataList = new ArrayList>(); + Map dataMap = new HashMap(); + RecordSet recordSet = new RecordSet(); + String sql = "select * from HrmResource a where 1=1 "; + if (recordSet.getDBType().equalsIgnoreCase("sqlserver")) { + sql = "select *,ROW_NUMBER() OVER(order by dspOrder,id) as rn from HrmResource a where 1=1 "; + } + if (dataScope.equals("0")) { + //总部 + } else if (dataScope.equals("1")) { + sql += " and a.subcompanyId1 in (" + subcomId + ") "; + } else if (dataScope.equals("2")) { + sql += " and a.departmentId in (" + deptId + ") "; + } else if (dataScope.equals("3")) { + sql += " and a.id in (" + resourceId + ")"; + } else if (dataScope.equals("4")) { + if (allLevel.equals("1")) { + sql += " and (a.id=" + user.getUID() + " or a.managerStr like '%," + user.getUID() + ",%' )"; + } else { + sql += " and (a.id=" + user.getUID() + " or a.managerid = " + user.getUID() + ")"; + } + } + if (isNoAccount.equals("false")) { + if (recordSet.getDBType().equalsIgnoreCase("sqlserver") + || recordSet.getDBType().equalsIgnoreCase("mysql")) { + sql += " and (a.loginId is not null and a.loginId<>'')"; + } else { + sql += " and (a.loginId is not null)"; + } + } + //考勤报表共享设置 + if (!rightStr.equals("") && !dataScope.equals("4")) { + sql += rightStr; + } + if (!recordSet.getDBType().equalsIgnoreCase("sqlserver")) { + sql += " order by dspOrder,id "; + } + String pageSql = "select * from (select tmp.*,rownum rn from (" + sql + ") tmp where rownum<=" + (pageSize * currentPage) + ") where rn>=" + (pageSize * (currentPage - 1) + 1); + if (recordSet.getDBType().equalsIgnoreCase("sqlserver")) { + pageSql = "select t.* from (" + sql + ") t where 1=1 and rn>=" + (pageSize * (currentPage - 1) + 1) + " and rn<=" + (pageSize * currentPage); + } else if (recordSet.getDBType().equalsIgnoreCase("mysql")) { + pageSql = sql + " limit " + (currentPage - 1) * pageSize + "," + pageSize; + } + recordSet.executeQuery(pageSql); + while (recordSet.next()) { + dataMap = new HashMap(); + + String id = recordSet.getString("id"); + String lastName = Util.formatMultiLang(recordSet.getString("lastName"), "" + user.getLanguage()); + String departmentId = recordSet.getString("departmentId"); + String subcompanyId = recordSet.getString("subcompanyId1"); + String jobtitleId = recordSet.getString("jobtitle"); + String workcode = recordSet.getString("workcode"); + String companyStartdate = recordSet.getString("companyStartdate"); + + dataMap.put("id", id); + dataMap.put("lastName", lastName); + dataMap.put("subcom", Util.formatMultiLang(subCompanyComInfo.getSubcompanyname(subcompanyId), "" + user.getLanguage())); + dataMap.put("dept", Util.formatMultiLang(departmentComInfo.getDepartmentname(departmentId), "" + user.getLanguage())); + dataMap.put("jobtitle", Util.formatMultiLang(jobTitlesComInfo.getJobTitlesname(jobtitleId), "" + user.getLanguage())); + dataMap.put("workcode", workcode); + dataMap.put("companyStartDate", companyStartdate); + dataMap.put("subcomId", subcompanyId); + dataMap.put("deptId", departmentId); + dataMap.put("jobtitleId", jobtitleId); + + rulesComInfo.setTofirstRow(); + while (rulesComInfo.next()) { + if (rulesComInfo.getIsEnable().equals("0")) { + continue; + } + /*该假期没有开启余额限制,显示不限制余额*/ + if (rulesComInfo.getBalanceEnable().equals("0")) { + dataMap.put(rulesComInfo.getId(), SystemEnv.getHtmlLabelName(389731, user.getLanguage()));//不限制余额 + continue; + } + BigDecimal restAmount = balanceMap.get(id + "_" + rulesComInfo.getId()); + dataMap.put(rulesComInfo.getId(), restAmount != null ? restAmount.setScale(2, RoundingMode.HALF_UP).toPlainString() : "0"); + } + dataList.add(dataMap); + } + + columnsList = HrmFieldUtil.getHrmDetailTable(hrmFieldBeanList, null, user); + resultMap.put("columns", columnsList); + resultMap.put("datas", dataList); + } catch (Exception e) { + e.printStackTrace(); + } + return resultMap; + } +} diff --git a/src/com/engine/salary/remote/attend/entity/Attend4Salary.java b/src/com/engine/salary/remote/attend/entity/Attend4Salary.java new file mode 100644 index 000000000..39703a559 --- /dev/null +++ b/src/com/engine/salary/remote/attend/entity/Attend4Salary.java @@ -0,0 +1,34 @@ +package com.engine.salary.remote.attend.entity; + +import com.engine.salary.util.valid.DataCheck; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; +import java.util.List; +import java.util.Map; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class Attend4Salary { + + @DataCheck(require = true,message = "开始日期为空!") + private Date beginDate; + + @DataCheck(require = true,message = "结束日期为空!") + private Date endDate; + + private String unit; + + @DataCheck(require = true,message = "考勤人员为空!") + private List onlyEmpIds; + + private Map extendParam; + + /** + * 出勤班次 + */ + private String attendanceSerial; +} diff --git a/src/com/engine/salary/remote/attend/service/RemoteAttend4SalaryService.java b/src/com/engine/salary/remote/attend/service/RemoteAttend4SalaryService.java new file mode 100644 index 000000000..e784bf361 --- /dev/null +++ b/src/com/engine/salary/remote/attend/service/RemoteAttend4SalaryService.java @@ -0,0 +1,35 @@ +package com.engine.salary.remote.attend.service; + +import com.engine.salary.remote.attend.entity.Attend4Salary; + +import java.util.List; +import java.util.Map; + +public interface RemoteAttend4SalaryService { + + /** + * 考勤报表列 + * @return + */ + List> getColumns(); + + /** + * 考勤报表数据 + * @param attend4Salary + * @return + */ + List> getDatas(Attend4Salary attend4Salary); + + /** + * 获取假期余额列 + * @return + */ + List> getBalanceOfLeaveColumns(); + + /** + * 假期值 + * @param attend4Salary + * @return + */ + List> getBalanceOfLeaveDatas(Attend4Salary attend4Salary); +} diff --git a/src/com/engine/salary/remote/attend/service/impl/RemoteAttend4SalaryServiceImpl.java b/src/com/engine/salary/remote/attend/service/impl/RemoteAttend4SalaryServiceImpl.java new file mode 100644 index 000000000..c54bbf10b --- /dev/null +++ b/src/com/engine/salary/remote/attend/service/impl/RemoteAttend4SalaryServiceImpl.java @@ -0,0 +1,252 @@ +package com.engine.salary.remote.attend.service.impl; + +import com.alibaba.druid.support.json.JSONUtils; +import com.alibaba.fastjson.JSONObject; +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.kq.cmd.report.GetKQReportCmd; +import com.engine.salary.mapper.datacollection.AttendQuoteFieldMapper; +import com.engine.salary.remote.attend.cmd.GetSearchListCmd; +import com.engine.salary.remote.attend.entity.Attend4Salary; +import com.engine.salary.remote.attend.service.RemoteAttend4SalaryService; +import com.engine.salary.sys.service.SalarySysConfService; +import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl; +import com.engine.salary.util.SalaryDateUtil; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.db.MapperProxyFactory; +import com.engine.salary.util.valid.ValidUtil; +import com.google.common.base.Joiner; +import com.google.common.collect.Maps; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.math.NumberUtils; +import weaver.general.BaseBean; +import weaver.general.Util; +import weaver.hrm.User; + +import java.time.LocalDate; +import java.util.*; +import java.util.stream.Collectors; + +import static com.engine.salary.sys.constant.SalarySysConstant.ATTENDANCE_SERIAL_COLLECTION_BTN; + +@Slf4j +public class RemoteAttend4SalaryServiceImpl extends Service implements RemoteAttend4SalaryService { + private final Boolean isLog = "true".equals(new BaseBean().getPropValue("hrmSalary", "log")); + + private AttendQuoteFieldMapper getAttendQuoteFieldMapper() { + return MapperProxyFactory.getProxy(AttendQuoteFieldMapper.class); + } + + private SalarySysConfService getSalarySysConfService(User user) { + return ServiceUtil.getService(SalarySysConfServiceImpl.class, user); + } + + //是否采集考勤班次数据 + boolean isCollectAttendanceSerial = "1".equals(getSalarySysConfService(user).getValueByCode(ATTENDANCE_SERIAL_COLLECTION_BTN)); + + + @Override + public List> getColumns() { + + //是否采集考勤班次数据 + String attendanceSerial = ""; + if (isCollectAttendanceSerial) { + List attendanceSerials = getAttendQuoteFieldMapper().getAttendanceSerials(); + attendanceSerial = Joiner.on(",").join((Iterable) attendanceSerials); + } + + Map paramsMap = new HashMap(); + paramsMap.put("typeselect", "3"); + paramsMap.put("viewScope", "0"); + paramsMap.put("isNoAccount", "1"); + paramsMap.put("attendanceSerial", attendanceSerial); + paramsMap.put("isFromMyAttendance", "1"); + Map temp = new HashMap(); + temp.put("data", JSONObject.toJSONString(paramsMap)); + temp.put("reportType", "month"); + List datas = (List) commandExecutor.execute(new GetKQReportCmd(temp, user)).get("columns"); + if (isLog) { + log.info("同步考勤字段,{}", JSONUtils.toJSONString(datas)); + } + List> columns = new ArrayList<>(); + datas.stream().filter(column -> Objects.nonNull(column.get("dataIndex"))).forEach(column -> { + String dataIndex = column.get("dataIndex").toString(); + //请假 + if (dataIndex.equals("leave") && column.get("children") != null) { + List list = (List) column.get("children"); + if (CollectionUtils.isNotEmpty(list)) { + list.stream() + .filter(leave -> leave.get("dataIndex") != null && StringUtils.isNotBlank(leave.get("dataIndex").toString())) + .forEach(leave -> { + Map map = Maps.newHashMapWithExpectedSize(2); + map.put("code", leave.get("dataIndex").toString()); + map.put("name", Util.null2String(column.get("title")) + "-" + leave.get("title") + "(" + leave.get("unit").toString() + ")"); + columns.add(map); + }); + } + } + //出勤班次 + else if (dataIndex.equals("attendanceSerial") && column.get("children") != null) { + List list = (List) column.get("children"); + if (CollectionUtils.isNotEmpty(list)) { + list.stream() + .filter(leave -> leave.get("dataIndex") != null && StringUtils.isNotBlank(leave.get("dataIndex").toString())) + .forEach(leave -> { + Map map = Maps.newHashMapWithExpectedSize(2); + map.put("code", "attendanceSerial_" + leave.get("dataIndex").toString()); + String unit = "".equals(leave.get("unit").toString()) ? "" : "(" + leave.get("unit").toString() + ")"; + map.put("name", Util.null2String(column.get("title")) + "-" + leave.get("title") + unit); + columns.add(map); + }); + } + } + //加班 + else if (dataIndex.equals("overtime") && column.get("children") != null) { + List list = (List) column.get("children"); + if (CollectionUtils.isNotEmpty(list)) { + for (int i = 0; i < list.size(); i++) { + Map overtimeMap = list.get(i); + if (overtimeMap.get("dataIndex") != null && StringUtils.isNotBlank(overtimeMap.get("dataIndex").toString()) && overtimeMap.get("children") == null) { + Map map = Maps.newHashMapWithExpectedSize(2); + map.put("code", overtimeMap.get("dataIndex").toString()); + map.put("name", Util.null2String(column.get("title")) + "-" + overtimeMap.get("title") + "(" + overtimeMap.get("unit").toString() + ")"); + columns.add(map); + } + if (overtimeMap.get("dataIndex") != null && StringUtils.isNotBlank(overtimeMap.get("dataIndex").toString()) && overtimeMap.get("children") != null) { + List overtimes = (List) overtimeMap.get("children"); + if (CollectionUtils.isNotEmpty(overtimes)) { + overtimes.stream().filter(leave -> leave.get("dataIndex") != null && StringUtils.isNotBlank(leave.get("dataIndex").toString())) + .forEach(leave -> { + Map map = Maps.newHashMapWithExpectedSize(2); + map.put("code", leave.get("dataIndex").toString()); + map.put("name", Util.null2String(column.get("title")) + "-" + Util.null2String(overtimeMap.get("title")) + "-" + leave.get("title") + "(" + leave.get("unit").toString() + ")"); + columns.add(map); + }); + } + } + + } + } + } + //普通考勤 + else { + if (column.get("unit") != null && StringUtils.isNotBlank(column.get("unit").toString())) { + Map map = Maps.newHashMapWithExpectedSize(2); + map.put("code", dataIndex); + map.put("name", column.get("title") + "(" + column.get("unit").toString() + ")"); + columns.add(map); + } + } + }); + + //假期余额字段 + columns.addAll(getBalanceOfLeaveColumns()); + return columns; + } + + @Override + public List> getDatas(Attend4Salary attend4Salary) { + List> list = new ArrayList<>(); + + try { + ValidUtil.doValidator(attend4Salary); + Map paramsMap = new HashMap(); + paramsMap.put("pageIndex", 1); + paramsMap.put("pageSize", 500); + paramsMap.put("typeselect", "6"); + paramsMap.put("fromDate", SalaryDateUtil.getFormatLocalDate(attend4Salary.getBeginDate())); + paramsMap.put("toDate", SalaryDateUtil.getFormatLocalDate(attend4Salary.getEndDate())); + paramsMap.put("viewScope", "3"); + List resourceIds = attend4Salary.getOnlyEmpIds().stream().map(String::valueOf).collect(Collectors.toList()); + paramsMap.put("resourceId", String.join(",", resourceIds)); + paramsMap.put("isNoAccount", "1"); + //班次 + paramsMap.put("attendanceSerial", isCollectAttendanceSerial ? attend4Salary.getAttendanceSerial() : ""); + paramsMap.put("isFromMyAttendance", "1"); + Map temp = new HashMap(); + temp.put("data", JSONObject.toJSONString(paramsMap)); + temp.put("reportType", "month"); + + log.info("salaryAttend开始获取的考勤数据,参数{}", temp); + list = (List>) commandExecutor.execute(new GetKQReportCmd(temp, user)).get("datas"); + if (isLog) { + log.info("salaryAttend获取的考勤数据,{}", JSONUtils.toJSONString(list)); + } + } catch (Exception e) { + log.error("salaryAttend获取考勤数据失败", e); + } + + try { + //假期余额信息 + List> balanceOfLeaveDatas = getBalanceOfLeaveDatas(attend4Salary); + Map> balanceMap = SalaryEntityUtil.convert2Map(balanceOfLeaveDatas, m -> m.get("id")); + + //给有考勤的赋值 + List attendEmpIds = list.stream().map(attend -> { + String resourceId = attend.get("resourceId"); + Map map = balanceMap.getOrDefault(resourceId, new HashMap<>()); + for (String key : map.keySet()) { + attend.put("balanceOfLeave_" + key, map.get(key)); + } + return resourceId; + }).collect(Collectors.toList()); + + //没有考勤,但有假期余额的人赋值 + List> balanceOfLeaveList = balanceMap.keySet().stream() + .filter(k -> !attendEmpIds.contains(k)) + .map(k -> { + Map result = new HashMap<>(); + result.put("resourceId", k); + Map map = balanceMap.get(k); + for (String key : map.keySet()) { + result.put("balanceOfLeave_" + key, map.get(key)); + } + return result; + }) + .collect(Collectors.toList()); + list.addAll(balanceOfLeaveList); + } catch (Exception e) { + log.error("salaryAttend获取假期数据失败", e); + } + return list; + } + + @Override + public List> getBalanceOfLeaveColumns() { + Map paramsMap = new HashMap(); + paramsMap.put("dateScope", "6"); + paramsMap.put("selectedYear", LocalDate.now().getYear()); + paramsMap.put("dataScope", "3"); + paramsMap.put("resourceId", 92); + paramsMap.put("status", "9"); + paramsMap.put("isNoAccount", true); + List> columns = (List>) commandExecutor.execute(new GetSearchListCmd(paramsMap, user)).get("columns"); + + List> balanceOfLeaveColumns = columns.stream() + .filter(column -> NumberUtils.isCreatable(column.get("key"))) + .map(column -> { + Map map = Maps.newHashMapWithExpectedSize(2); + map.put("code", "balanceOfLeave_" + column.get("key")); + map.put("name", "假期余额-" + column.get("title")); + return map; + }).collect(Collectors.toList()); + + return balanceOfLeaveColumns; + } + + + @Override + public List> getBalanceOfLeaveDatas(Attend4Salary attend4Salary) { + Map paramsMap = new HashMap(); + paramsMap.put("currentPage", "1"); + paramsMap.put("pageSize", "500"); + paramsMap.put("selectedYear", SalaryDateUtil.date2Year(attend4Salary.getBeginDate())); + paramsMap.put("dataScope", "3"); + paramsMap.put("resourceId", attend4Salary.getOnlyEmpIds().stream().map(String::valueOf).collect(Collectors.joining(","))); + paramsMap.put("status", "9"); + paramsMap.put("isNoAccount", true); + return (List>) commandExecutor.execute(new GetSearchListCmd(paramsMap, user)).get("datas"); + } +} diff --git a/src/com/engine/salary/remote/mode/cmd/GetModeList.java b/src/com/engine/salary/remote/mode/cmd/GetModeList.java new file mode 100644 index 000000000..bbb70bf6f --- /dev/null +++ b/src/com/engine/salary/remote/mode/cmd/GetModeList.java @@ -0,0 +1,139 @@ +package com.engine.salary.remote.mode.cmd; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.cube.biz.AppHelper; +import com.engine.cube.biz.DetachHelper; +import com.weaver.formmodel.util.StringHelper; +import weaver.conn.RecordSet; +import weaver.formmode.FormModeConfig; +import weaver.formmode.service.ModelInfoService; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.hrm.company.SubCompanyComInfo; +import weaver.hrm.moduledetach.ManageDetachComInfo; +import weaver.workflow.workflow.WorkflowBillComInfo; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class GetModeList extends AbstractCommonCommand> { + private FormModeConfig formModeConfig = new FormModeConfig(); + public GetModeList(Map params, User user){ + this.params = params; + this.user = user; + } + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + Map result = new HashMap(); + ManageDetachComInfo ManageDetachComInfo = new ManageDetachComInfo(); + boolean isUseFmManageDetach=ManageDetachComInfo.isUseFmManageDetach(); + int appid = Util.getIntValue(Util.null2String(params.get("appid")),1) ; + String aLLorCurrentKey = Util.null2String(params.get("aLLorCurrentKey")); + int appidForAppname =Util.getIntValue(Util.null2String(this.params.get("appidForAppname")),1); + ModelInfoService modelInfoService = new ModelInfoService(); + modelInfoService.setUser(user); + List> list; + int currentSubCompanyId = Util.getIntValue(Util.null2String(params.get("currentSubCompanyId")), -1); + if(user.getUID()==1&&isUseFmManageDetach&¤tSubCompanyId<1){ + isUseFmManageDetach = false; + } + if(isUseFmManageDetach) { + Map detach=DetachHelper.getUserDetachInfo(user, currentSubCompanyId, "FORMMODEAPP:ALL"); + if(currentSubCompanyId<1){ + currentSubCompanyId=Util.getIntValue(Util.null2String(detach.get("defaultSubCompanyId"))); + } + list = modelInfoService.getModelInfoByAppIdDetach(appid, currentSubCompanyId); + } else { + list = modelInfoService.getModelInfoByAppId(appid); + } + WorkflowBillComInfo workflowBillComInfo = new WorkflowBillComInfo(); + ArrayList> modeList = new ArrayList>(); + + String vsql = "SELECT m.formid,m.virtualformtype,m.vformtype FROM ModeFormExtend m WHERE m.isvirtualform=1"; + RecordSet rs = new RecordSet(); + rs.execute(vsql); + Map map = new HashMap(); + while(rs.next()){ + String formid = rs.getString("formid"); + String virtualformtype = rs.getString("virtualformtype"); + String vformtype = rs.getString("vformtype"); + map.put(formid, virtualformtype+"_"+vformtype); + } + FormModeConfig formModeConfig = new FormModeConfig(); + String VirtualFormPermissions = formModeConfig.getVirtualFormPermissions(); + String modeids = formModeConfig.getModeid(); + for(Map mode : list) { + Map newMode = new HashMap(); + String key = Util.null2String(mode.get("id")); + String formid = Util.null2String(mode.get("formid")); + String isvirtualform = Util.null2String(mode.get("isvirtualform")); + String virtualrightopen = Util.null2String(mode.get("virtualrightopen")); + if(StringHelper.isEmpty(isvirtualform)){ + isvirtualform = "0"; + } + String tableName = Util.null2String(workflowBillComInfo.getTablename(formid)); + String virtualformtype = ""; + String vformtype = ""; + if("1".equals(isvirtualform)){ + continue; + } + newMode.put("key",key ); + newMode.put("domid",key ); + newMode.put("name", Util.null2String(mode.get("modename"))); + newMode.put("subname", tableName); + newMode.put("isvirtualform", isvirtualform); + newMode.put("virtualformtype", virtualformtype); + newMode.put("vformtype", vformtype); + modeList.add(newMode); + } + result.put("appid",appid+""); + String appsubcompanyid = ""; + String appsubcompanyidname = ""; + if(appid>0){ + String sql = "SELECT subcompanyid FROM modetreefield WHERE id="+appid; + rs.execute(sql); + if(rs.next()){ + int subcompanyid = rs.getInt("subcompanyid"); + if(subcompanyid>0){ + appsubcompanyid = subcompanyid+""; + SubCompanyComInfo subCompanyComInfo = new SubCompanyComInfo(); + appsubcompanyidname = subCompanyComInfo.getSubcompanyname(appsubcompanyid); + } + } + } + String appName = AppHelper.getAppName(appidForAppname+""); + boolean issysadmin = user.getUID() == 1; + result.put("appName",appName); + result.put("issysadmin",issysadmin); + result.put("aLLorCurrentKey",aLLorCurrentKey); + result.put("appsubcompanyid",appsubcompanyid); + result.put("appsubcompanyidname",appsubcompanyidname); + result.put("modeList",modeList); + result.put("canDeleteModeInfo",formModeConfig.isCanDeleteModeInfo()); + return result; + } + + + public boolean isHadRight(String modeid){ + RecordSet rs = new RecordSet(); + rs.executeQuery("select count(1) as rightcount from moderightinfo where modeid=? and ((righttype=0 and (sharetype<80 or sharetype>100)) or (righttype in (1,2,3) and (sharetype<80 or sharetype>100)))",modeid); + int rightcount=0; + if(rs.next()){ + rightcount = Util.getIntValue(rs.getString("rightcount"),0); + } + if(rightcount>0){ + return true; + }else{ + return false; + } + } +} diff --git a/src/com/engine/salary/report/common/constant/DbCrudConstant.java b/src/com/engine/salary/report/common/constant/DbCrudConstant.java new file mode 100644 index 000000000..2ec6a8eb8 --- /dev/null +++ b/src/com/engine/salary/report/common/constant/DbCrudConstant.java @@ -0,0 +1,10 @@ +package com.engine.salary.report.common.constant; + + +public class DbCrudConstant { + + /** + * 默认分片大小 + */ + public static final int DEF_PART_SIZE = 1000; +} diff --git a/src/com/engine/salary/report/common/constant/SalaryConstant.java b/src/com/engine/salary/report/common/constant/SalaryConstant.java new file mode 100644 index 000000000..b6af93d9d --- /dev/null +++ b/src/com/engine/salary/report/common/constant/SalaryConstant.java @@ -0,0 +1,12 @@ +package com.engine.salary.report.common.constant; + +/** + * 薪资常量 + */ +public class SalaryConstant { + + /** + * 列表中薪资项目动态列后缀标识 + */ + public static final String DYNAMIC_SUFFIX = "_salaryItem"; +} diff --git a/src/com/engine/salary/report/common/constant/SalaryReportModule.java b/src/com/engine/salary/report/common/constant/SalaryReportModule.java new file mode 100644 index 000000000..655f5e2d0 --- /dev/null +++ b/src/com/engine/salary/report/common/constant/SalaryReportModule.java @@ -0,0 +1,6 @@ +package com.engine.salary.report.common.constant; + +public class SalaryReportModule { + + public final static String BROWSER_MODULE = "salaryreport"; +} diff --git a/src/com/engine/salary/report/common/constant/SalaryStatisticsDimensionConstant.java b/src/com/engine/salary/report/common/constant/SalaryStatisticsDimensionConstant.java new file mode 100644 index 000000000..46d93b57e --- /dev/null +++ b/src/com/engine/salary/report/common/constant/SalaryStatisticsDimensionConstant.java @@ -0,0 +1,139 @@ +package com.engine.salary.report.common.constant; + +/** + * 薪资报表统计维度常量 + */ +public class SalaryStatisticsDimensionConstant { + + // 默认维度 start ==================================================================================== + /** + * 薪资所属月 + */ + public static final String DM_SALARY_MONTH = "salaryMonth"; + + /** + * 个税扣缴义务人 + */ + public static final String DM_TAX_AGENT = "taxAgent"; + + /** + * 收入所得类型 + */ + public static final String DM_INCOME_CATEGORY = "incomeCategory"; + + /** + * 分部 + */ + public static final String DM_SUB_COMPANY = "subCompany"; + + /** + * 部门 + */ + public static final String DM_DEPARTMENT = "department"; + + /** + * 岗位 + */ + public static final String DM_POSITION = "position"; + + /** + * 职级 + */ + public static final String DM_GRADE = "grade"; + + /** + * 人事状态 + */ + public static final String DM_HRM_STATUS = "hrmStatus"; + + /** + * 人员类型 + */ + public static final String DM_EMPLOYEE_TYPE = "employeeType"; + + /** + * 人员 + */ + public static final String DM_EMPLOYEE = "employee"; + + /** + * 年度 + */ + public static final String DM_YEAR = "year"; + + /** + * 半年度 + */ + public static final String DM_HALF_YEAR = "halfYear"; + + /** + * 季度 + */ + public static final String DM_QUARTER = "quarter"; + +// /** +// * 月度 用薪资所属月,所以没必要了 +// */ +// public static final String DM_MONTH = "month"; + // 默认维度 end ==================================================================================== + + /** + * 性别 + */ + public static final String DM_SEX = "sex"; + + /** + * 职称 + */ + public static final String DM_JOB_CALL = "job_call"; + + /** + * 上级 + */ + public static final String DM_SUPERIOR = "superior"; + + /** + * 婚姻状况 + */ + public static final String DM_MARITAL_STATUS = "marital_status"; + + /** + * 学历 + */ + public static final String DM_EDUCATION = "education"; + + /** + * 学位 + */ + public static final String DM_DEGREE = "degree"; + + /** + * 民族 + */ + public static final String DM_NATION = "nation"; + + /** + * 户口类型 + */ + public static final String DM_HOUSEHOLD_TYPE = "household_type"; + + /** + * 政治面貌 + */ + public static final String DM_POLITICS_STATUS = "politics_status"; + + /** + * 年龄 + */ + public static final String DM_AGE = "age"; + + /** + * 工龄 + */ + public static final String DM_WORK_YEAR = "work_year"; + + /** + * 司龄 + */ + public static final String DM_COMPANY_YEAR = "company_year"; +} diff --git a/src/com/engine/salary/report/entity/bo/SalaryStatisticsEmployeeBO.java b/src/com/engine/salary/report/entity/bo/SalaryStatisticsEmployeeBO.java new file mode 100644 index 000000000..470c0690e --- /dev/null +++ b/src/com/engine/salary/report/entity/bo/SalaryStatisticsEmployeeBO.java @@ -0,0 +1,62 @@ +package com.engine.salary.report.entity.bo; + +import com.engine.salary.util.SalaryDateUtil; +import com.google.common.collect.Sets; +import org.apache.commons.collections4.CollectionUtils; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * 薪酬统计员工明细 + */ +public class SalaryStatisticsEmployeeBO { + + /** + * 年月参数处理,注意:薪资所属月居然是用字符串存储的,无法通过sql between处理 + * + * @param year + * @param salaryMonth + * @return + */ + public static Set getSalaryMonths(Integer year, List salaryMonth) { + Set salaryMonths = Sets.newHashSet(); + // 年份参数 + if (Objects.nonNull(year)) { + List months = Arrays.asList("01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"); + for (int i = 0; i < months.size(); i++) { + salaryMonths.add(year + "-" + months.get(i)); + } + } + // 薪资所属月参数,如果已经有年的就取交集 + if (CollectionUtils.isNotEmpty(salaryMonth)) { + salaryMonth = (salaryMonth.size() > 2 ? salaryMonth.subList(0, 1) : salaryMonth); + if (salaryMonth.size() == 2) { + if (salaryMonth.get(0).after(salaryMonth.get(1))) { + salaryMonths.clear(); + salaryMonths.add("2000-01"); + } else { + Date startYearMonth = salaryMonth.get(0); + Date endYearMonth = salaryMonth.get(1); + Set yearMonths = Sets.newHashSet(); + while (!startYearMonth.after(endYearMonth)) { + yearMonths.add(SalaryDateUtil.getFormatYearMonth(startYearMonth)); + startYearMonth = SalaryDateUtil.plusMonths(startYearMonth, 1); + } + if (CollectionUtils.isNotEmpty(salaryMonths)) { + Set finalSalaryMonths = salaryMonths; + salaryMonths = yearMonths.stream().filter(finalSalaryMonths::contains).collect(Collectors.toSet()); + salaryMonths = CollectionUtils.isEmpty(salaryMonths) ? Sets.newHashSet("2000-01") : salaryMonths; + } else { + salaryMonths = yearMonths; + } + } + } else { + String singMonth = SalaryDateUtil.getFormatYearMonth(salaryMonth.get(0)); + salaryMonths.add(CollectionUtils.isNotEmpty(salaryMonths) ? (salaryMonths.contains(singMonth) ? singMonth : "2000-01") : singMonth); + } + } + + return salaryMonths; + } +} diff --git a/src/com/engine/salary/report/entity/bo/SalaryStatisticsReportBO.java b/src/com/engine/salary/report/entity/bo/SalaryStatisticsReportBO.java new file mode 100644 index 000000000..9ad7fb2fc --- /dev/null +++ b/src/com/engine/salary/report/entity/bo/SalaryStatisticsReportBO.java @@ -0,0 +1,1294 @@ +package com.engine.salary.report.entity.bo; + +import cn.hutool.core.util.NumberUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; +import com.cloudstore.eccom.pc.table.WeaTableColumn; +import com.engine.common.util.ServiceUtil; +import com.engine.salary.component.WeaTableColumnGroup; +import com.engine.salary.entity.hrm.dto.EmployeeInfoExpandDTO; +import com.engine.salary.entity.hrm.dto.FieldSetting; +import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO; +import com.engine.salary.report.common.constant.SalaryStatisticsDimensionConstant; +import com.engine.salary.report.entity.dto.SalaryStatisticsItemRuleDTO; +import com.engine.salary.report.entity.param.ExportColumn; +import com.engine.salary.report.entity.param.ExportCommonParam; +import com.engine.salary.report.entity.param.SalaryStatisticsDimensionSaveParam; +import com.engine.salary.report.entity.param.SalaryStatisticsReportDataQueryParam; +import com.engine.salary.report.entity.po.SalaryStatisticsDimensionPO; +import com.engine.salary.report.entity.po.SalaryStatisticsItemPO; +import com.engine.salary.report.entity.po.SalaryStatisticsReportPO; +import com.engine.salary.report.enums.SalaryStatisticsItemStringRuleEnum; +import com.engine.salary.report.enums.UnitTypeEnum; +import com.engine.salary.report.service.SalaryStatisticsDimensionService; +import com.engine.salary.report.service.impl.SalaryStatisticsDimensionServiceImpl; +import com.engine.salary.report.util.ReportDataUtil; +import com.engine.salary.report.util.ReportTimeUtil; +import com.engine.salary.util.SalaryDateUtil; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.page.PageInfo; +import com.google.common.base.Joiner; +import com.google.common.collect.Maps; +import com.google.common.collect.Sets; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.collections4.MapUtils; +import org.apache.commons.compress.utils.Lists; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.BeanUtils; +import weaver.hrm.User; + +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.util.*; +import java.util.function.Function; +import java.util.stream.Collectors; + +/** + * 薪酬统计报表 + */ +public class SalaryStatisticsReportBO { + + public static final String COUNT = "count"; + public static final String SUM = "sum"; + public static final String AVG = "avg"; + public static final String MAX = "max"; + public static final String MIN = "min"; + public static final String MEDIAN = "median"; + + public static final String ZERO = "0"; + public static final String ONE = "1"; + public static final String COMMA = ","; + public static final String UD = "_"; + + public static final String K_NOW = "_now"; + public static final String K_RATIO = "_ratio"; + public static final String K_LAST = "_last"; + public static final String K_SAME = "_same"; + + public static final String P_NOW = "_now"; + public static final String P_LAST = "_last"; + public static final String P_SAME = "_same"; + public static final String P_RATIO = "_ratio"; + public static final String P_M2M_D_VALUE = "_m2m_d_value"; + public static final String P_M2M_INCREASE = "_m2m_increase"; + public static final String P_M2M_UPPER_LIMIT = "_m2m_upperLimit"; + public static final String P_M2M_LOWER_LIMIT = "_m2m_lowerLimit"; + public static final String P_Y2Y_D_VALUE = "_y2y_d_value"; + public static final String P_Y2Y_INCREASE = "_y2y_increase"; + public static final String P_Y2Y_UPPER_LIMIT = "_y2y_upperLimit"; + public static final String P_Y2Y_LOWER_LIMIT = "_y2y_lowerLimit"; + + public static final String COL_WIDTH = "150"; + + public static final String PERCENT = "%"; + public static final String D_ZERO = "0.00"; + + public static final BigDecimal HUNDRED = new BigDecimal(100); + + public static final String G_NO_ITEM = "noItem"; + public static final String G_YEAR = "year"; + public static final String G_ITEM = "ITEM"; + + private static SalaryStatisticsDimensionService getSalaryStatisticsDimensionService() { + return ServiceUtil.getService(SalaryStatisticsDimensionServiceImpl.class, new User(1)); + } + + /** + * 参数转换 + * + * @param param + * @param po + */ + public static void poToQueryParam(SalaryStatisticsReportDataQueryParam param, SalaryStatisticsReportPO po) { + String salaryStartMonth = param.getSalaryStartMonth(); + if (salaryStartMonth == null) { + param.setSalaryStartMonth(SalaryDateUtil.getFormatYearMonth(po.getSalaryStartMonth())); + } else { + param.setSalaryStartMonth(SalaryDateUtil.getFormatYearMonth(SalaryDateUtil.dateStrToLocalDate(salaryStartMonth))); + } + String salaryEndMonth = param.getSalaryEndMonth(); + if (salaryEndMonth == null) { + param.setSalaryEndMonth(SalaryDateUtil.getFormatYearMonth(po.getSalaryEndMonth())); + } else { + param.setSalaryEndMonth(SalaryDateUtil.getFormatYearMonth(SalaryDateUtil.dateStrToLocalDate(salaryEndMonth))); + } + + String key = "id"; + if (po.getTaxAgentSetting() != null) { + param.setTaxAgent(((List) JSON.parseArray(po.getTaxAgentSetting(), Map.class)).stream().map(m -> Long.valueOf(m.get(key).toString())).collect(Collectors.toList())); + } + if (po.getSalarySobSetting() != null) { + param.setSalarySob(((List) JSON.parseArray(po.getSalarySobSetting(), Map.class)).stream().map(m -> Long.valueOf(m.get(key).toString())).collect(Collectors.toList())); + } +// param.setIncomeCategory(((List) JSON.parseArray(po.getIncomeCategorySetting(), Map.class)).stream().map(m -> Integer.valueOf(m.get(key).toString())).collect(Collectors.toList())); + if (po.getSubCompanySetting() != null) { + param.setSubCompany(((List) JSON.parseArray(po.getSubCompanySetting(), Map.class)).stream().map(m -> Long.valueOf(m.get(key).toString())).collect(Collectors.toList())); + } + if (po.getDepartSetting() != null) { + param.setDepart(((List) JSON.parseArray(po.getDepartSetting(), Map.class)).stream().map(m -> Long.valueOf(m.get(key).toString())).collect(Collectors.toList())); + } +// param.setGrade(((List) JSON.parseArray(po.getGradeSetting(), Map.class)).stream().map(m -> Long.valueOf(m.get(key).toString())).collect(Collectors.toList())); + if (po.getPositionSetting() != null) { + param.setPosition(((List) JSON.parseArray(po.getPositionSetting(), Map.class)).stream().map(m -> Long.valueOf(m.get(key).toString())).collect(Collectors.toList())); + } + if (po.getStatusSetting() != null) { + param.setStatus(((List) JSON.parseArray(po.getStatusSetting(), Map.class)).stream().map(m -> m.get(key).toString()).collect(Collectors.toList())); + } + if (po.getEmployeeSetting() != null) { + param.setEmployee(((List) JSON.parseArray(po.getEmployeeSetting(), Map.class)).stream().map(m -> Long.valueOf(m.get(key).toString())).collect(Collectors.toList())); + } + if (po.getHiredateSetting() != null) { + param.setHiredate(JSON.parseArray(po.getHiredateSetting(), Date.class)); + } +// param.setLeavedate(JSON.parseArray(po.getLeavedateSetting(), LocalDate.class)); + } + + /** + * 参数转换获取上一期 + * + * @param param + * @param dimension + * @return + */ + public static SalaryStatisticsReportDataQueryParam lastParamConvert(SalaryStatisticsReportDataQueryParam param, SalaryStatisticsDimensionPO dimension) { + SalaryStatisticsReportDataQueryParam lastParam = new SalaryStatisticsReportDataQueryParam(); + BeanUtils.copyProperties(param, lastParam); + // 薪资所属月 + if (SalaryStatisticsDimensionConstant.DM_SALARY_MONTH.equals(dimension.getDimCode())) { + lastParam.setSalaryStartMonth(ReportTimeUtil.getLastYearMonth(param.getSalaryStartMonth())); + lastParam.setSalaryEndMonth(ReportTimeUtil.getLastYearMonth(param.getSalaryEndMonth())); + // 年份 + } else if (SalaryStatisticsDimensionConstant.DM_YEAR.equals(dimension.getDimCode())) { + lastParam.setSalaryStartMonth(ReportTimeUtil.getSameYearMonth(param.getSalaryStartMonth())); + lastParam.setSalaryEndMonth(ReportTimeUtil.getSameYearMonth(param.getSalaryEndMonth())); + // 半年度 + } else if (SalaryStatisticsDimensionConstant.DM_HALF_YEAR.equals(dimension.getDimCode())) { + lastParam.setSalaryStartMonth(ReportTimeUtil.getPlusYearMonth(param.getSalaryStartMonth(), -6)); + lastParam.setSalaryEndMonth(ReportTimeUtil.getPlusYearMonth(param.getSalaryEndMonth(), -6)); + // 季度 + } else if (SalaryStatisticsDimensionConstant.DM_QUARTER.equals(dimension.getDimCode())) { + lastParam.setSalaryStartMonth(ReportTimeUtil.getPlusYearMonth(param.getSalaryStartMonth(), -3)); + lastParam.setSalaryEndMonth(ReportTimeUtil.getPlusYearMonth(param.getSalaryEndMonth(), -3)); + } else { + Map timeDiff = ReportTimeUtil.getLastRange(param.getSalaryStartMonth(), param.getSalaryEndMonth()); + lastParam.setSalaryStartMonth(timeDiff.get("startMonth")); + lastParam.setSalaryEndMonth(timeDiff.get("endMonth")); + } + return lastParam; + } + + public static SalaryStatisticsReportDataQueryParam sameParamConvert(SalaryStatisticsReportDataQueryParam param) { + SalaryStatisticsReportDataQueryParam sameParam = new SalaryStatisticsReportDataQueryParam(); + BeanUtils.copyProperties(param, sameParam); + sameParam.setSalaryStartMonth(ReportTimeUtil.getSameYearMonth(param.getSalaryStartMonth())); + sameParam.setSalaryEndMonth(ReportTimeUtil.getSameYearMonth(param.getSalaryEndMonth())); + return sameParam; + } + + /** + * 计算项目 + * + * @param list + * @param lastList + * @param salaryAcctResultValueMap + * @param salaryStatisticsItemList + * @return + */ + public static Map calculateItem(List list, List lastList, List sameList, Map> salaryAcctResultValueMap, List salaryStatisticsItemList) { + List> nowDetail = po2map(list, salaryAcctResultValueMap); + List> lastDetail = po2map(lastList, salaryAcctResultValueMap); + List> sameDetail = po2map(sameList, salaryAcctResultValueMap); + Map result = new HashMap<>(); + salaryStatisticsItemList.forEach(item -> { + // 1.计数规则数据处理 + calculate4Count(result, item, nowDetail, lastDetail, sameDetail); + // 2.求和规则数据处理 + calculate4Sum(result, item, nowDetail, lastDetail, sameDetail); + // 3.平均值规则数据处理 + calculate4Avg(result, item, nowDetail, lastDetail, sameDetail); + // 4.最大值规则数据处理 + calculate4Max(result, item, nowDetail, lastDetail, sameDetail); + // 5.最小值规则数据处理 + calculate4Min(result, item, nowDetail, lastDetail, sameDetail); + // 6.中位数规则数据处理 + calculate4Median(result, item, nowDetail, lastDetail, sameDetail); + // 7.最近值 + calculate4Last(result, item, nowDetail, lastDetail, sameDetail); + // 8.最久值 + calculate4Old(result, item, nowDetail, lastDetail, sameDetail); + // 9.最频繁 + calculate4Frequent(result, item, nowDetail, lastDetail, sameDetail); + // 10.平铺 + calculate4Tile(result, item, nowDetail, lastDetail, sameDetail); + }); + return result; + } + + private static void calculate4Count(Map result, SalaryStatisticsItemPO item, List> nowDetail, List> lastDetail, List> sameDetail) { + SalaryStatisticsItemRuleDTO countRule = JSON.parseObject(item.getCountRule(), SalaryStatisticsItemRuleDTO.class); + if (countRule == null || countRule.getTotalValue() != 1) { + return; + } + BigDecimal countDecimal = new BigDecimal(CollectionUtils.isNotEmpty(nowDetail) ? nowDetail.size() : 0); + // 本期 + if (countRule.getTotalValue() == 1) { + // 本期和占比赋值 + nowAndRatio(result, item, countRule, COUNT, countDecimal); + } + // 上期 + if (countRule.getM2mValue() == 1) { + BigDecimal lastCountDecimal = new BigDecimal(CollectionUtils.isNotEmpty(lastDetail) ? lastDetail.size() : 0); + // 上期和环比赋值 + lastM2m(result, item, countRule, COUNT, countDecimal, lastCountDecimal); + } + // 同期 + if (countRule.getY2yValue() == 1) { + BigDecimal sameCountDecimal = new BigDecimal(CollectionUtils.isNotEmpty(sameDetail) ? sameDetail.size() : 0); + // 同期和同比赋值 + sameY2y(result, item, countRule, COUNT, countDecimal, sameCountDecimal); + } + } + + + private static void calculate4Sum(Map result, SalaryStatisticsItemPO item, List> nowDetail, List> lastDetail, List> sameDetail) { + SalaryStatisticsItemRuleDTO sumRule = JSON.parseObject(item.getSumRule(), SalaryStatisticsItemRuleDTO.class); + if (sumRule == null || sumRule.getTotalValue() != 1) { + return; + } + BigDecimal sumDecimal = new BigDecimal(ZERO); + if (sumRule.getTotalValue() == 1) { + if (StringUtils.isNotEmpty(item.getItemValue())) { + String[] itemValues = item.getItemValue().split(COMMA); + for (String itemId : itemValues) { + for (Map x : nowDetail) { + if (MapUtils.isNotEmpty(x) && StringUtils.isNotBlank(x.get(itemId)) && NumberUtil.isNumber(x.get(itemId).trim())) { + sumDecimal = sumDecimal.add(new BigDecimal(x.get(itemId).trim())); + } + } + } + } + nowAndRatio(result, item, sumRule, SUM, sumDecimal); + } + // 上期 + if (sumRule.getM2mValue() == 1) { + BigDecimal lastSumDecimal = new BigDecimal(ZERO); + if (StringUtils.isNotEmpty(item.getItemValue())) { + String[] lastItemValues = item.getItemValue().split(COMMA); + for (String itemId : lastItemValues) { + for (Map y : lastDetail) { + if (MapUtils.isNotEmpty(y) && StringUtils.isNotBlank(y.get(itemId)) && NumberUtil.isNumber(y.get(itemId).trim())) { + lastSumDecimal = lastSumDecimal.add(new BigDecimal(y.get(itemId).trim())); + } + } + } + } + lastM2m(result, item, sumRule, SUM, sumDecimal, lastSumDecimal); + } + // 同期 + if (sumRule.getY2yValue() == 1) { + BigDecimal sameSumDecimal = new BigDecimal(ZERO); + if (StringUtils.isNotEmpty(item.getItemValue())) { + String[] lastItemValues = item.getItemValue().split(COMMA); + for (String itemId : lastItemValues) { + for (Map y : sameDetail) { + if (MapUtils.isNotEmpty(y) && StringUtils.isNotBlank(y.get(itemId)) && NumberUtil.isNumber(y.get(itemId).trim())) { + sameSumDecimal = sameSumDecimal.add(new BigDecimal(y.get(itemId).trim())); + } + } + } + } + sameY2y(result, item, sumRule, SUM, sumDecimal, sameSumDecimal); + } + } + + private static void calculate4Avg(Map result, SalaryStatisticsItemPO item, List> nowDetail, List> lastDetail, List> sameDetail) { + SalaryStatisticsItemRuleDTO avgRule = JSON.parseObject(item.getAvgRule(), SalaryStatisticsItemRuleDTO.class); + if (avgRule == null || avgRule.getTotalValue() != 1) { + return; + } + BigDecimal avgDecimal = new BigDecimal(ZERO); + // 本期 + if (avgRule.getTotalValue() == 1) { + if (StringUtils.isNotEmpty(item.getItemValue())) { + String[] itemValues = item.getItemValue().split(COMMA); + for (String itemId : itemValues) { + for (Map x : nowDetail) { + if (MapUtils.isNotEmpty(x) && StringUtils.isNotBlank(x.get(itemId)) && NumberUtil.isNumber(x.get(itemId).trim())) { + avgDecimal = avgDecimal.add(new BigDecimal(x.get(itemId).trim())); + } + } + } + } + avgDecimal = avgDecimal.divide(new BigDecimal(CollectionUtils.isEmpty(nowDetail) ? 1 : nowDetail.size()), 2, RoundingMode.HALF_UP); + nowAndRatio(result, item, avgRule, AVG, avgDecimal); + } + // 上期 + if (avgRule.getM2mValue() == 1) { + BigDecimal lastAvgDecimal = new BigDecimal(ZERO); + if (StringUtils.isNotEmpty(item.getItemValue())) { + String[] lastItemValues = item.getItemValue().split(COMMA); + for (String itemId : lastItemValues) { + for (Map y : lastDetail) { + if (MapUtils.isNotEmpty(y) && StringUtils.isNotBlank(y.get(itemId)) && NumberUtil.isNumber(y.get(itemId).trim())) { + lastAvgDecimal = lastAvgDecimal.add(new BigDecimal(y.get(itemId).trim())); + } + } + } + } + lastAvgDecimal = lastAvgDecimal.divide(new BigDecimal(CollectionUtils.isEmpty(lastDetail) ? 1 : lastDetail.size()), 2, RoundingMode.HALF_UP); + lastM2m(result, item, avgRule, AVG, avgDecimal, lastAvgDecimal); + } + // 同期 + if (avgRule.getY2yValue() == 1) { + BigDecimal sameAvgDecimal = new BigDecimal(ZERO); + if (StringUtils.isNotEmpty(item.getItemValue())) { + String[] lastItemValues = item.getItemValue().split(COMMA); + for (String itemId : lastItemValues) { + for (Map y : sameDetail) { + if (MapUtils.isNotEmpty(y) && StringUtils.isNotBlank(y.get(itemId)) && NumberUtil.isNumber(y.get(itemId).trim())) { + sameAvgDecimal = sameAvgDecimal.add(new BigDecimal(y.get(itemId).trim())); + } + } + } + } + sameAvgDecimal = sameAvgDecimal.divide(new BigDecimal(CollectionUtils.isEmpty(sameDetail) ? 1 : sameDetail.size()), 2, RoundingMode.HALF_UP); + sameY2y(result, item, avgRule, AVG, avgDecimal, sameAvgDecimal); + } + } + + private static void calculate4Max(Map result, SalaryStatisticsItemPO item, List> nowDetail, List> lastDetail, List> sameDetail) { + SalaryStatisticsItemRuleDTO maxRule = JSON.parseObject(item.getMaxRule(), SalaryStatisticsItemRuleDTO.class); + if (maxRule == null || maxRule.getTotalValue() != 1) { + return; + } + BigDecimal maxDecimal = new BigDecimal(ZERO); + // 本期 + if (maxRule.getTotalValue() == 1) { + List decimalList = Lists.newArrayList(); + if (StringUtils.isNotEmpty(item.getItemValue())) { + String[] itemValues = item.getItemValue().split(COMMA); + for (String itemId : itemValues) { + for (Map x : nowDetail) { + if (MapUtils.isNotEmpty(x) && StringUtils.isNotBlank(x.get(itemId)) && NumberUtil.isNumber(x.get(itemId).trim())) { + decimalList.add(new BigDecimal(x.get(itemId).trim())); + } + } + } + } + // 本期合计 + maxDecimal = max(decimalList); + nowAndRatio(result, item, maxRule, MAX, maxDecimal); + } + // 上期 + if (maxRule.getM2mValue() == 1) { + List decimalList = Lists.newArrayList(); + if (StringUtils.isNotEmpty(item.getItemValue())) { + String[] lastItemValues = item.getItemValue().split(COMMA); + for (String itemId : lastItemValues) { + for (Map y : lastDetail) { + if (MapUtils.isNotEmpty(y) && StringUtils.isNotBlank(y.get(itemId)) && NumberUtil.isNumber(y.get(itemId).trim())) { + decimalList.add(new BigDecimal(y.get(itemId).trim())); + } + } + } + } + BigDecimal lastMaxDecimal = max(decimalList); + lastM2m(result, item, maxRule, MAX, maxDecimal, lastMaxDecimal); + } + // 同期 + if (maxRule.getY2yValue() == 1) { + List decimalList = Lists.newArrayList(); + if (StringUtils.isNotEmpty(item.getItemValue())) { + String[] lastItemValues = item.getItemValue().split(COMMA); + for (String itemId : lastItemValues) { + for (Map y : sameDetail) { + if (MapUtils.isNotEmpty(y) && StringUtils.isNotBlank(y.get(itemId)) && NumberUtil.isNumber(y.get(itemId).trim())) { + decimalList.add(new BigDecimal(y.get(itemId).trim())); + } + } + } + } + BigDecimal sameMaxDecimal = max(decimalList); + sameY2y(result, item, maxRule, MAX, maxDecimal, sameMaxDecimal); + } + } + + private static void calculate4Min(Map result, SalaryStatisticsItemPO item, List> nowDetail, List> lastDetail, List> sameDetail) { + SalaryStatisticsItemRuleDTO minRule = JSON.parseObject(item.getMinRule(), SalaryStatisticsItemRuleDTO.class); + if (minRule == null || minRule.getTotalValue() != 1) { + return; + } + BigDecimal minDecimal = new BigDecimal(ZERO); + // 本期 + if (minRule.getTotalValue() == 1) { + List decimalList = Lists.newArrayList(); + if (StringUtils.isNotEmpty(item.getItemValue())) { + String[] itemValues = item.getItemValue().split(COMMA); + for (String itemId : itemValues) { + for (Map x : nowDetail) { + if (MapUtils.isNotEmpty(x) && StringUtils.isNotBlank(x.get(itemId)) && NumberUtil.isNumber(x.get(itemId).trim())) { + decimalList.add(new BigDecimal(x.get(itemId).trim())); + } + } + } + } + // 本期合计 + minDecimal = min(decimalList); + nowAndRatio(result, item, minRule, MIN, minDecimal); + } + // 上期 + if (minRule.getM2mValue() == 1) { + List decimalList = Lists.newArrayList(); + if (StringUtils.isNotEmpty(item.getItemValue())) { + String[] lastItemValues = item.getItemValue().split(COMMA); + for (String itemId : lastItemValues) { + for (Map y : lastDetail) { + if (MapUtils.isNotEmpty(y) && StringUtils.isNotBlank(y.get(itemId)) && NumberUtil.isNumber(y.get(itemId).trim()) ) { + decimalList.add(new BigDecimal(y.get(itemId).trim())); + } + } + } + } + BigDecimal lastMinDecimal = min(decimalList); + lastM2m(result, item, minRule, MIN, minDecimal, lastMinDecimal); + } + // 同期 + if (minRule.getY2yValue() == 1) { + List decimalList = Lists.newArrayList(); + if (StringUtils.isNotEmpty(item.getItemValue())) { + String[] lastItemValues = item.getItemValue().split(COMMA); + for (String itemId : lastItemValues) { + for (Map y : sameDetail) { + if (MapUtils.isNotEmpty(y) && StringUtils.isNotBlank(y.get(itemId)) && NumberUtil.isNumber(y.get(itemId).trim())) { + decimalList.add(new BigDecimal(y.get(itemId).trim())); + } + } + } + } + BigDecimal sameMinDecimal = min(decimalList); + sameY2y(result, item, minRule, MIN, minDecimal, sameMinDecimal); + } + } + + private static void calculate4Median(Map result, SalaryStatisticsItemPO item, List> nowDetail, List> lastDetail, List> sameDetail) { + SalaryStatisticsItemRuleDTO medianRule = JSON.parseObject(item.getMedianRule(), SalaryStatisticsItemRuleDTO.class); + if (medianRule == null || medianRule.getTotalValue() != 1) { + return; + } + BigDecimal medianDecimal = new BigDecimal(ZERO); + // 本期 + if (medianRule.getTotalValue() == 1) { + List decimalList = Lists.newArrayList(); + if (StringUtils.isNotEmpty(item.getItemValue())) { + String[] itemValues = item.getItemValue().split(COMMA); + for (String itemId : itemValues) { + for (Map x : nowDetail) { + if (MapUtils.isNotEmpty(x) && StringUtils.isNotBlank(x.get(itemId)) && NumberUtil.isNumber(x.get(itemId).trim())) { + decimalList.add(new BigDecimal(x.get(itemId).trim())); + } + } + } + } + // 本期合计 + medianDecimal = median(decimalList); + nowAndRatio(result, item, medianRule, MEDIAN, medianDecimal); + } + // 上期 + if (medianRule.getM2mValue() == 1) { + List decimalList = Lists.newArrayList(); + if (StringUtils.isNotEmpty(item.getItemValue())) { + String[] lastItemValues = item.getItemValue().split(COMMA); + for (String itemId : lastItemValues) { + for (Map y : lastDetail) { + if (MapUtils.isNotEmpty(y) && StringUtils.isNotBlank(y.get(itemId)) && NumberUtil.isNumber(y.get(itemId).trim())) { + decimalList.add(new BigDecimal(y.get(itemId).trim())); + } + } + } + } + BigDecimal lastMedianDecimal = median(decimalList); + lastM2m(result, item, medianRule, MEDIAN, medianDecimal, lastMedianDecimal); + } + // 同期 + if (medianRule.getY2yValue() == 1) { + List decimalList = Lists.newArrayList(); + if (StringUtils.isNotEmpty(item.getItemValue())) { + String[] lastItemValues = item.getItemValue().split(COMMA); + for (String itemId : lastItemValues) { + for (Map y : sameDetail) { + if (MapUtils.isNotEmpty(y) && StringUtils.isNotBlank(y.get(itemId)) && NumberUtil.isNumber(y.get(itemId).trim())) { + decimalList.add(new BigDecimal(y.get(itemId).trim())); + } + } + } + } + BigDecimal sameMedianDecimal = median(decimalList); + sameY2y(result, item, medianRule, MEDIAN, medianDecimal, sameMedianDecimal); + } + } + + /** + * 最新的值 + * + * @param result + * @param item + * @param nowDetail + * @param lastDetail + * @param sameDetail + */ + private static void calculate4Last(Map result, SalaryStatisticsItemPO item, List> nowDetail, List> lastDetail, List> sameDetail) { + SalaryStatisticsItemRuleDTO lastRule = JSON.parseObject(item.getLastRule(), SalaryStatisticsItemRuleDTO.class); + if (lastRule == null || lastRule.getTotalValue() != 1) { + return; + } + String lastValue = ""; + // 本期 + if (lastRule.getTotalValue() == 1) { + List decimalList = Lists.newArrayList(); + if (StringUtils.isNotEmpty(item.getItemValue())) { + String[] itemValues = item.getItemValue().split(COMMA); + for (String itemId : itemValues) { + for (Map x : nowDetail) { + if (MapUtils.isNotEmpty(x) && StringUtils.isNotBlank(x.get(itemId))) { + decimalList.add(x.get(itemId)); + } + } + } + } + // 本期最近值 + lastValue = last(decimalList); + nowAndRatio(result, item, lastRule, SalaryStatisticsItemStringRuleEnum.LAST.getValue(), lastValue); + } + } + + /** + * 最旧的值 + * + * @param result + * @param item + * @param nowDetail + * @param lastDetail + * @param sameDetail + */ + private static void calculate4Old(Map result, SalaryStatisticsItemPO item, List> nowDetail, List> lastDetail, List> sameDetail) { + SalaryStatisticsItemRuleDTO oldRule = JSON.parseObject(item.getOldRule(), SalaryStatisticsItemRuleDTO.class); + if (oldRule == null || oldRule.getTotalValue() != 1) { + return; + } + String value = ""; + // 本期 + if (oldRule.getTotalValue() == 1) { + List decimalList = Lists.newArrayList(); + if (StringUtils.isNotEmpty(item.getItemValue())) { + String[] itemValues = item.getItemValue().split(COMMA); + for (String itemId : itemValues) { + for (Map x : nowDetail) { + if (MapUtils.isNotEmpty(x) && StringUtils.isNotBlank(x.get(itemId))) { + decimalList.add(x.get(itemId)); + } + } + } + } + // 本期最近值 + value = old(decimalList); + nowAndRatio(result, item, oldRule, SalaryStatisticsItemStringRuleEnum.OLD.getValue(), value); + } + } + + /** + * 最频繁 + * + * @param result + * @param item + * @param nowDetail + * @param lastDetail + * @param sameDetail + */ + private static void calculate4Frequent(Map result, SalaryStatisticsItemPO item, List> nowDetail, List> lastDetail, List> sameDetail) { + SalaryStatisticsItemRuleDTO frequentRule = JSON.parseObject(item.getFrequentRule(), SalaryStatisticsItemRuleDTO.class); + if (frequentRule == null || frequentRule.getTotalValue() != 1) { + return; + } + String value = ""; + // 本期 + if (frequentRule.getTotalValue() == 1) { + List decimalList = Lists.newArrayList(); + if (StringUtils.isNotEmpty(item.getItemValue())) { + String[] itemValues = item.getItemValue().split(COMMA); + for (String itemId : itemValues) { + for (Map x : nowDetail) { + if (MapUtils.isNotEmpty(x) && StringUtils.isNotBlank(x.get(itemId))) { + decimalList.add(x.get(itemId)); + } + } + } + } + // 本期最近值 + value = frequent(decimalList); + nowAndRatio(result, item, frequentRule, SalaryStatisticsItemStringRuleEnum.FREQUENT.getValue(), value); + } + } + + /** + * 平铺 + * + * @param result + * @param item + * @param nowDetail + * @param lastDetail + * @param sameDetail + */ + private static void calculate4Tile(Map result, SalaryStatisticsItemPO item, List> nowDetail, List> lastDetail, List> sameDetail) { + SalaryStatisticsItemRuleDTO tileRule = JSON.parseObject(item.getTileRule(), SalaryStatisticsItemRuleDTO.class); + if (tileRule == null || tileRule.getTotalValue() != 1) { + return; + } + String value = ""; + // 本期 + if (tileRule.getTotalValue() == 1) { + List decimalList = Lists.newArrayList(); + if (StringUtils.isNotEmpty(item.getItemValue())) { + String[] itemValues = item.getItemValue().split(COMMA); + for (String itemId : itemValues) { + for (Map x : nowDetail) { + if (MapUtils.isNotEmpty(x) && StringUtils.isNotBlank(x.get(itemId))) { + decimalList.add(x.get(itemId)); + } + } + } + } + // 本期最近值 + value = tile(decimalList); + nowAndRatio(result, item, tileRule, SalaryStatisticsItemStringRuleEnum.TILE.getValue(), value); + } + } + + + /** + * 本期和占比赋值 + * + * @param result + * @param item + * @param rule + * @param ruleKey + * @param sumDecimal + */ + private static void nowAndRatio(Map result, SalaryStatisticsItemPO item, SalaryStatisticsItemRuleDTO rule, String ruleKey, BigDecimal sumDecimal) { + String keyPrefix = item.getId().toString() + UD + ruleKey; + // 本期合计 + result.put(keyPrefix + K_NOW, ReportDataUtil.thousandthConvert(unitTypeConvert(sumDecimal, item.getUnitType()))); + // 占比:和本期合计一样的值,便于计算 + if (rule.getRatioValue() == 1) { + result.put(keyPrefix + K_RATIO, result.get(keyPrefix + K_NOW)); + } + } + + /** + * 本期和占比赋值 + * + * @param result + * @param item + * @param rule + * @param ruleKey + * @param sumDecimal + */ + private static void nowAndRatio(Map result, SalaryStatisticsItemPO item, SalaryStatisticsItemRuleDTO rule, String ruleKey, String sumDecimal) { + String keyPrefix = item.getId().toString() + UD + ruleKey; + // 本期合计 + result.put(keyPrefix + K_NOW, sumDecimal); + } + + /** + * 环比赋值 + * + * @param result + * @param item + * @param rule + * @param ruleKey + * @param nowValue + * @param lastValue + */ + private static void lastM2m(Map result, SalaryStatisticsItemPO item, SalaryStatisticsItemRuleDTO rule, String ruleKey, BigDecimal nowValue, BigDecimal lastValue) { + String keyPrefix = item.getId().toString() + UD + ruleKey; + // 上期合计 + result.put(keyPrefix + P_LAST, ReportDataUtil.thousandthConvert(unitTypeConvert(lastValue, item.getUnitType()))); + // 合计环比差值 + result.put(keyPrefix + P_M2M_D_VALUE, ReportDataUtil.thousandthConvert(unitTypeConvert(nowValue.subtract(lastValue), item.getUnitType()))); + // 合计环比增幅 + result.put(keyPrefix + P_M2M_INCREASE, radio(nowValue, lastValue)); + // 合计环比上限 + result.put(keyPrefix + P_M2M_UPPER_LIMIT, rule.getM2mUpperLimit().toString() + PERCENT); + // 合计环比下限 + result.put(keyPrefix + P_M2M_LOWER_LIMIT, rule.getM2mLowerLimit().toString() + PERCENT); + } + + /** + * 同比赋值 + * + * @param result + * @param item + * @param rule + * @param ruleKey + * @param nowValue + * @param sameValue + */ + private static void sameY2y(Map result, SalaryStatisticsItemPO item, SalaryStatisticsItemRuleDTO rule, String ruleKey, BigDecimal nowValue, BigDecimal sameValue) { + String keyPrefix = item.getId().toString() + UD + ruleKey; + // 同期合计 + result.put(keyPrefix + P_SAME, ReportDataUtil.thousandthConvert(unitTypeConvert(sameValue, item.getUnitType()))); + // 合计同比差值 + result.put(keyPrefix + P_Y2Y_D_VALUE, ReportDataUtil.thousandthConvert(unitTypeConvert(nowValue.subtract(sameValue), item.getUnitType()))); + // 合计同比增幅 + result.put(keyPrefix + P_Y2Y_INCREASE, radio(nowValue, sameValue)); + // 合计同比上限 + result.put(keyPrefix + P_Y2Y_UPPER_LIMIT, rule.getY2yUpperLimit() == null ? "" : rule.getY2yUpperLimit().toString() + PERCENT); + // 合计同比下限 + result.put(keyPrefix + P_Y2Y_LOWER_LIMIT, rule.getY2yLowerLimit() == null ? "" : rule.getY2yLowerLimit().toString() + PERCENT); + } + + /** + * 最大值 + * + * @param list + * @return + */ + public static BigDecimal max(List list) { + if (CollectionUtils.isEmpty(list)) return new BigDecimal(D_ZERO); +// BigDecimal max = Collections.max(list); + + BigDecimal sum = list.get(0); + for (int i = 1; i < list.size(); i++) { + sum = sum.max(list.get(i)); + } + return sum; + } + + /** + * 最小值 + * + * @param list + * @return + */ + public static BigDecimal min(List list) { + if (CollectionUtils.isEmpty(list)) return new BigDecimal(D_ZERO); +// BigDecimal min = Collections.min(list); + BigDecimal sum = list.get(0); + for (int i = 1; i < list.size(); i++) { + sum = sum.min(list.get(i)); + } + return sum; + } + + /** + * 中位数 + * + * @param list + * @return + */ + public static BigDecimal median(List list) { + if (CollectionUtils.isEmpty(list)) return new BigDecimal(D_ZERO); + Collections.sort(list); + int size = list.size(); + if (size % 2 == 1) { + return list.get((size - 1) / 2); + } else { + return (list.get(size / 2 - 1).add(list.get(size / 2))).divide(new BigDecimal(2), 2, RoundingMode.HALF_UP); + } + } + + /** + * 最新的值 + * + * @param list + * @return + */ + public static String last(List list) { + if (CollectionUtils.isEmpty(list)) { + return ""; + } + return list.get(0); + } + + /** + * 最旧的值 + * + * @param list + * @return + */ + public static String old(List list) { + if (CollectionUtils.isEmpty(list)) { + return ""; + } + return list.get(list.size() - 1); + } + + /** + * 最频繁 + * + * @param list + * @return + */ + public static String frequent(List list) { + if (CollectionUtils.isEmpty(list)) { + return ""; + } + return list.stream() + .collect(Collectors.groupingBy(Function.identity(), Collectors.counting())) + .entrySet() + .stream() + .max(Map.Entry.comparingByValue()) + .map(Map.Entry::getKey) + .orElse(""); + } + + /** + * 平铺 + * + * @param list + * @return + */ + public static String tile(List list) { + if (CollectionUtils.isEmpty(list)) { + return ""; + } + return Joiner.on(",").join((Iterable) list); + } + + + public static List> po2map(List list, Map> salaryAcctResultValueMap) { + if (CollectionUtils.isEmpty(list)) { + return new ArrayList<>(); + } + return list.stream().map(sa -> salaryAcctResultValueMap.get(sa.getId())).collect(Collectors.toList()); + } + + public static String unitTypeConvert(BigDecimal bigDecimal, Integer unitType) { + switch (unitType) { + case 3: + return bigDecimal.divide(BigDecimal.valueOf(1000), 2, RoundingMode.HALF_UP).toPlainString(); + case 4: + return bigDecimal.divide(BigDecimal.valueOf(1000000), 2, RoundingMode.HALF_UP).toPlainString(); + default: + return bigDecimal.toPlainString(); + } + } + + public static String radio(BigDecimal origin, BigDecimal last) { + if (ReportDataUtil.zeroJudge(last)) { + return "--"; + } + BigDecimal subtract = origin.subtract(last).multiply(HUNDRED); + BigDecimal divide = subtract.divide(last, 2, RoundingMode.HALF_UP); + return divide.toPlainString() + PERCENT; + } + + /** + * 定量-组距式分组list分割 + * 说明: + * 1.如果是年:每个人的年份值在这个区间内;如果没有所属字段:各个字段值在区间内;如果有所属字敦:则该所属字段在区间内的数据 + * 2.区间内的话,就把id搞出来 + * 3.符合id的list筛选出来返回 + * + * @param groupSpacing + * @param groupBelong + * @param dimCode + * @param list + * @param yearMap + * @param salaryAcctResultValueMap + * @param salaryStatisticsItemList + * @return + */ + public static List listAcctEmpByRationGroupSpacing(SalaryStatisticsDimensionSaveParam.Setting4RationGroupSpacing groupSpacing, String groupBelong, String dimCode, List list, Map yearMap, Map> salaryAcctResultValueMap, List salaryStatisticsItemList) { + Set ids = Sets.newHashSet(); + + for (SalaryAcctEmployeePO sa : list) { + salaryStatisticsItemList.forEach(item -> { + BigDecimal sumDecimal = handle4GroupValue(groupBelong, dimCode, sa, yearMap, salaryAcctResultValueMap, item); + boolean isRight = ((!groupSpacing.isIncludeStart() && sumDecimal.compareTo(new BigDecimal(groupSpacing.getStartValue())) > 0) + || (groupSpacing.isIncludeStart() && sumDecimal.compareTo(new BigDecimal(groupSpacing.getStartValue())) >= 0)) + && ((!groupSpacing.isIncludeEnd() && sumDecimal.compareTo(new BigDecimal(groupSpacing.getEndValue())) < 0) + || (groupSpacing.isIncludeEnd() && sumDecimal.compareTo(new BigDecimal(groupSpacing.getEndValue())) <= 0)); + if (isRight) { + ids.add(sa.getId()); + } + }); + } + + return list.stream().filter(i -> ids.contains(i.getId())).collect(Collectors.toList()); + } + + private static BigDecimal handle4GroupValue(String groupBelong, String dimCode, SalaryAcctEmployeePO sa, Map yearMap, Map> salaryAcctResultValueMap, SalaryStatisticsItemPO item) { + BigDecimal sumDecimal = new BigDecimal(ZERO); + if (G_NO_ITEM.equals(groupBelong)) { + if (StringUtils.isNotEmpty(item.getItemValue())) { + String[] itemValues = item.getItemValue().split(COMMA); + for (String itemId : itemValues) { + if (salaryAcctResultValueMap.get(sa.getId()) != null && StringUtils.isNotBlank(salaryAcctResultValueMap.get(sa.getId()).get(itemId))) { + sumDecimal = sumDecimal.add(new BigDecimal(salaryAcctResultValueMap.get(sa.getId()).get(itemId))); + } + } + } + } else if (G_ITEM.equals(groupBelong)) { + if (salaryAcctResultValueMap.get(sa.getId()) != null && StringUtils.isNotBlank(salaryAcctResultValueMap.get(sa.getId()).get(dimCode))) { + sumDecimal = sumDecimal.add(new BigDecimal(salaryAcctResultValueMap.get(sa.getId()).get(dimCode))); + } + } else if (G_YEAR.equals(groupBelong)) { + if (StringUtils.isNotBlank(yearMap.get(sa.getEmployeeId()))) { + sumDecimal = new BigDecimal(yearMap.get(sa.getEmployeeId())); + } + } + return sumDecimal; + } + + private static String handle4GroupValue(String dimCode, SalaryAcctEmployeePO sa, Map> salaryAcctResultValueMap, SalaryStatisticsItemPO item) { + if (salaryAcctResultValueMap.get(sa.getId()) != null) { + String value = salaryAcctResultValueMap.get(sa.getId()).get(dimCode); + if (StringUtils.isNotBlank(value)) { + return value; + } + } + return ""; + } + + /** + * 定量-单项式分组list分割 + * + * @param groupIndividual + * @param groupBelong + * @param dimCode + * @param list + * @param yearMap + * @param salaryAcctResultValueMap + * @param salaryStatisticsItemList + * @return + */ + public static List listAcctEmpByRationGroupIndividual(SalaryStatisticsDimensionSaveParam.Setting4RationGroupIndividual groupIndividual, String groupBelong, String dimCode, List list, Map yearMap, Map> salaryAcctResultValueMap, List salaryStatisticsItemList) { + Set ids = Sets.newHashSet(); + + for (SalaryAcctEmployeePO sa : list) { + salaryStatisticsItemList.forEach(item -> { + BigDecimal sumDecimal = handle4GroupValue(groupBelong, dimCode, sa, yearMap, salaryAcctResultValueMap, item); + + if (sumDecimal.compareTo(new BigDecimal(groupIndividual.getValue())) == 0) { + ids.add(sa.getId()); + } + }); + } + + return list.stream().filter(i -> ids.contains(i.getId())).collect(Collectors.toList()); + } + + public static List listAcctEmpByRationGroupIndividual(String groupIndividual, String dimCode, List list, Map yearMap, Map> salaryAcctResultValueMap, List salaryStatisticsItemList) { + Set ids = Sets.newHashSet(); + + for (SalaryAcctEmployeePO sa : list) { + salaryStatisticsItemList.forEach(item -> { + String value = handle4GroupValue(dimCode, sa, salaryAcctResultValueMap, item); + + if (StrUtil.equals(groupIndividual, value)) { + ids.add(sa.getId()); + } + }); + } + + return list.stream().filter(i -> ids.contains(i.getId())).collect(Collectors.toList()); + } + + public static Map checkLoad(List salaryStatisticsItemList) { + boolean isNow = false; + boolean isLast = false; + boolean isSame = false; + for (SalaryStatisticsItemPO item : salaryStatisticsItemList) { + SalaryStatisticsItemRuleDTO countRule = JSON.parseObject(item.getCountRule(), SalaryStatisticsItemRuleDTO.class); + SalaryStatisticsItemRuleDTO sumRule = JSON.parseObject(item.getSumRule(), SalaryStatisticsItemRuleDTO.class); + SalaryStatisticsItemRuleDTO avgRule = JSON.parseObject(item.getAvgRule(), SalaryStatisticsItemRuleDTO.class); + SalaryStatisticsItemRuleDTO maxRule = JSON.parseObject(item.getMaxRule(), SalaryStatisticsItemRuleDTO.class); + SalaryStatisticsItemRuleDTO minRule = JSON.parseObject(item.getMinRule(), SalaryStatisticsItemRuleDTO.class); + SalaryStatisticsItemRuleDTO medianRule = JSON.parseObject(item.getMedianRule(), SalaryStatisticsItemRuleDTO.class); + + if ((countRule != null && countRule.getTotalValue() == 1) || (sumRule != null && sumRule.getTotalValue() == 1) || (avgRule != null && avgRule.getTotalValue() == 1) || (maxRule != null && maxRule.getTotalValue() == 1) || (minRule != null && minRule.getTotalValue() == 1) || (medianRule != null && medianRule.getTotalValue() == 1)) { + isNow = true; + } + if ((countRule != null && countRule.getM2mValue() == 1) || (sumRule != null && sumRule.getM2mValue() == 1) || (avgRule != null && avgRule.getM2mValue() == 1) || (maxRule != null && maxRule.getM2mValue() == 1) || (minRule != null && minRule.getM2mValue() == 1) || (medianRule != null && medianRule.getM2mValue() == 1)) { + isLast = true; + } + if ((countRule != null && countRule.getY2yValue() == 1) || (sumRule != null && sumRule.getY2yValue() == 1) || (avgRule != null && avgRule.getY2yValue() == 1) || (maxRule != null && maxRule.getY2yValue() == 1) || (minRule != null && minRule.getY2yValue() == 1) || (medianRule != null && medianRule.getY2yValue() == 1)) { + isSame = true; + } + } + Map map = Maps.newHashMap(); + map.put("isNow", isNow); + map.put("isLast", isLast); + map.put("isSame", isSame); + return map; + } + + /** + * 构建合计 + * + * @param page + * @param salaryStatisticsItemList + * @param employeeId + */ + public static Map buildTotal(PageInfo> page, List salaryStatisticsItemList, Long employeeId) { + Map salaryStatisticsItemMap = SalaryEntityUtil.convert2Map(salaryStatisticsItemList, k -> k.getId() + "-" + employeeId); + + List> records = page.getList(); + if (CollectionUtils.isNotEmpty(records)) { + Set keys = records.get(0).keySet(); + Map map = new HashMap<>(); + map.put("dimension", SalaryI18nUtil.getI18nLabel(93278, "合计")); + Map itemPOMap = new HashMap<>(); + keys.forEach(key -> { + if (key.contains(COUNT + K_NOW) || key.contains(COUNT + K_LAST) || key.contains(COUNT + K_SAME) + || key.contains(SUM + K_NOW) || key.contains(SUM + K_LAST) || key.contains(SUM + K_SAME) + || key.contains(AVG + K_NOW) || key.contains(AVG + K_LAST) || key.contains(AVG + K_SAME) + || key.contains(MAX + K_NOW) || key.contains(MAX + K_LAST) || key.contains(MAX + K_SAME) + || key.contains(MIN + K_NOW) || key.contains(MIN + K_LAST) || key.contains(MIN + K_SAME) + || key.contains(MEDIAN + K_NOW) || key.contains(MEDIAN + K_LAST) || key.contains(MEDIAN + K_SAME)) { + String keyStr = key.split(UD)[0]; + SalaryStatisticsItemPO salaryStatisticsItem = salaryStatisticsItemMap.get(Long.valueOf(keyStr) + "-" + employeeId); + itemPOMap.put(salaryStatisticsItem.getId(), salaryStatisticsItem); + // 累加 + BigDecimal countNow = new BigDecimal(ZERO); + for (Map kv : records) { + String temp = String.valueOf(kv.get(key)).replace(COMMA, ""); + countNow = countNow.add(new BigDecimal(temp)); + } + map.put(key, ReportDataUtil.thousandthConvert(unitTypeConvert(countNow, UnitTypeEnum.YUAN.getValue()))); + } + // 有占比的话 + if (key.contains(K_RATIO)) { + map.put(key, "100%"); + } + }); + Set keySet = new HashSet<>(map.keySet()); + List ruleKeys = Arrays.asList(COUNT, SUM, AVG, MAX, MIN, MEDIAN); + String keyPrefix; + for (String key : keySet) { + if (key.equals("dimension") || key.contains(K_RATIO)) { + continue; + } + for (String rule : ruleKeys) { + String idStr = key.split(UD)[0]; + keyPrefix = idStr + UD + rule; + SalaryStatisticsItemPO salaryStatisticsItem = itemPOMap.get(Long.valueOf(idStr)); + String countNowValue = Optional.ofNullable(map.get(keyPrefix + K_NOW)).orElse(D_ZERO).toString().replace(COMMA, ""); + BigDecimal countNow = new BigDecimal(countNowValue); + String countLastValue = Optional.ofNullable(map.get(keyPrefix + K_LAST)).orElse(D_ZERO).toString().replace(COMMA, ""); + BigDecimal countLast = new BigDecimal(countLastValue); + map.put(keyPrefix + P_M2M_INCREASE, radio(countNow, countLast)); + map.put(keyPrefix + P_M2M_D_VALUE, ReportDataUtil.thousandthConvert(unitTypeConvert(countNow.subtract(countLast), UnitTypeEnum.YUAN.getValue()))); + map.put(keyPrefix + P_M2M_LOWER_LIMIT, ""); + map.put(keyPrefix + P_M2M_UPPER_LIMIT, ""); + String countSameValue = Optional.ofNullable(map.get(keyPrefix + K_SAME)).orElse(D_ZERO).toString().replace(COMMA, ""); + BigDecimal countSame = new BigDecimal(countSameValue); + map.put(keyPrefix + P_Y2Y_INCREASE, radio(countNow, countSame)); + map.put(keyPrefix + P_Y2Y_D_VALUE, ReportDataUtil.thousandthConvert(unitTypeConvert(countNow.subtract(countSame), UnitTypeEnum.YUAN.getValue()))); + map.put(keyPrefix + P_Y2Y_LOWER_LIMIT, ""); + map.put(keyPrefix + P_Y2Y_UPPER_LIMIT, ""); + } + } + // 占比计算 + for (Map record : records) { + keys.forEach(key -> { + if (key.contains(K_RATIO)) { + String total = String.valueOf(map.get(key.replace(K_RATIO, K_NOW))).replace(COMMA, ""); + String temp = String.valueOf(record.get(key)).replace(COMMA, ""); + record.put(key, total.equals(D_ZERO) ? D_ZERO + PERCENT : (new BigDecimal(temp).multiply(HUNDRED).divide(new BigDecimal(total), 2, RoundingMode.HALF_UP)).toPlainString() + PERCENT); + } + }); + } + return map; +// records.add(map); + } + return Maps.newHashMap(); + } + + /** + * 构建报表动态列 + * + * @param dimensionName + * @param salaryStatisticsItemList + * @return + */ + public static List buildReportColumns(SalaryStatisticsDimensionPO dimensionName, List salaryStatisticsItemList) { + List result = new ArrayList<>(); + + result.add(new WeaTableColumnGroup("150", dimensionName.getDimName(), "dimension")); + + //扩展维度属性 + EmployeeInfoExpandDTO expandFieldSettings = getSalaryStatisticsDimensionService().getExpandFieldSettings("dim_" + dimensionName.getDimCode()); + List fieldSettings = Optional.ofNullable(Optional.ofNullable(expandFieldSettings).orElse(new EmployeeInfoExpandDTO()).getFieldSettings()).orElse(new ArrayList<>()); + fieldSettings.stream().sorted(Comparator.comparing(FieldSetting::getIndex)).forEach(setting -> { + result.add(new WeaTableColumnGroup("150", setting.getName(), setting.getField())); + }); + + Map itemMap = salaryStatisticsItemList.stream().collect(Collectors.toMap(SalaryStatisticsItemPO::getId, Function.identity())); + Map itemIdNameMap = salaryStatisticsItemList.stream().collect(LinkedHashMap::new, (map, item) -> map.put(item.getId(), item.getItemName()), LinkedHashMap::putAll); + itemIdNameMap.forEach((k, v) -> { + WeaTableColumnGroup weaTableColumn = new WeaTableColumnGroup("300", v, k.toString()); + SalaryStatisticsItemPO itemPO = itemMap.get(k); + List children = new ArrayList<>(); + // 1.合计规则children + SalaryStatisticsItemRuleDTO countRule = JSON.parseObject(itemPO.getCountRule(), SalaryStatisticsItemRuleDTO.class); + if (countRule != null && 1 == countRule.getTotalValue()) { + children.add(new WeaTableColumnGroup(COL_WIDTH, SalaryI18nUtil.getI18nLabel(157127, "本周期(计数)"), k + UD + COUNT + P_NOW)); + } + if (countRule != null && 1 == countRule.getRatioValue()) { + children.add(new WeaTableColumnGroup(COL_WIDTH, SalaryI18nUtil.getI18nLabel(174288, "本周期占比(计数)"), k + UD + COUNT + P_RATIO)); + } + if (countRule != null && 1 == countRule.getM2mValue()) { + children.add(new WeaTableColumnGroup(COL_WIDTH, SalaryI18nUtil.getI18nLabel(157128, "上周期(计数)"), k + UD + COUNT + P_LAST)); + children.add(new WeaTableColumnGroup(COL_WIDTH, SalaryI18nUtil.getI18nLabel(157129, "计数环比差值"), k + UD + COUNT + P_M2M_D_VALUE)); + children.add(new WeaTableColumnGroup(COL_WIDTH, SalaryI18nUtil.getI18nLabel(157130, "计数环比增幅"), k + UD + COUNT + P_M2M_INCREASE)); + } + if (countRule != null && 1 == countRule.getY2yValue()) { + children.add(new WeaTableColumnGroup(COL_WIDTH, SalaryI18nUtil.getI18nLabel(180672, "同比周期(计数)"), k + UD + COUNT + P_SAME)); + children.add(new WeaTableColumnGroup(COL_WIDTH, SalaryI18nUtil.getI18nLabel(174391, "计数同比差值"), k + UD + COUNT + P_Y2Y_D_VALUE)); + children.add(new WeaTableColumnGroup(COL_WIDTH, SalaryI18nUtil.getI18nLabel(174392, "计数同比增幅"), k + UD + COUNT + P_Y2Y_INCREASE)); + } + // 2.求和规则children + SalaryStatisticsItemRuleDTO totalRule = JSON.parseObject(itemPO.getSumRule(), SalaryStatisticsItemRuleDTO.class); + if (totalRule != null && 1 == totalRule.getTotalValue()) { + children.add(new WeaTableColumnGroup(COL_WIDTH, SalaryI18nUtil.getI18nLabel(157145, "本周期(求和)"), k + UD + SUM + P_NOW)); + } + if (totalRule != null && 1 == totalRule.getRatioValue()) { + children.add(new WeaTableColumnGroup(COL_WIDTH, SalaryI18nUtil.getI18nLabel(174289, "本周期占比(求和)"), k + UD + SUM + P_RATIO)); + } + if (totalRule != null && 1 == totalRule.getM2mValue()) { + children.add(new WeaTableColumnGroup(COL_WIDTH, SalaryI18nUtil.getI18nLabel(157146, "上周期(求和)"), k + UD + SUM + P_LAST)); + children.add(new WeaTableColumnGroup(COL_WIDTH, SalaryI18nUtil.getI18nLabel(157147, "求和环比差值"), k + UD + SUM + P_M2M_D_VALUE)); + children.add(new WeaTableColumnGroup(COL_WIDTH, SalaryI18nUtil.getI18nLabel(157148, "求和环比增幅"), k + UD + SUM + P_M2M_INCREASE)); + } + if (totalRule != null && 1 == totalRule.getY2yValue()) { + children.add(new WeaTableColumnGroup(COL_WIDTH, SalaryI18nUtil.getI18nLabel(180673, "同比周期(求和)"), k + UD + SUM + P_SAME)); + children.add(new WeaTableColumnGroup(COL_WIDTH, SalaryI18nUtil.getI18nLabel(174388, "求和同比差值"), k + UD + SUM + P_Y2Y_D_VALUE)); + children.add(new WeaTableColumnGroup(COL_WIDTH, SalaryI18nUtil.getI18nLabel(174389, "求和同比增幅"), k + UD + SUM + P_Y2Y_INCREASE)); + } + // 3.平均值规则children + SalaryStatisticsItemRuleDTO avgRule = JSON.parseObject(itemPO.getAvgRule(), SalaryStatisticsItemRuleDTO.class); + if (avgRule != null && 1 == avgRule.getTotalValue()) { + children.add(new WeaTableColumnGroup(COL_WIDTH, SalaryI18nUtil.getI18nLabel(174258, "本周期(平均值)"), k + UD + AVG + P_NOW)); + } + if (avgRule != null && 1 == avgRule.getRatioValue()) { + children.add(new WeaTableColumnGroup(COL_WIDTH, SalaryI18nUtil.getI18nLabel(174290, "本周期占比(平均值)"), k + UD + AVG + P_RATIO)); + } + if (avgRule != null && 1 == avgRule.getM2mValue()) { + children.add(new WeaTableColumnGroup(COL_WIDTH, SalaryI18nUtil.getI18nLabel(174257, "上周期(平均值)"), k + UD + AVG + P_LAST)); + children.add(new WeaTableColumnGroup(COL_WIDTH, SalaryI18nUtil.getI18nLabel(174256, "平均值环比差值"), k + UD + AVG + P_M2M_D_VALUE)); + children.add(new WeaTableColumnGroup(COL_WIDTH, SalaryI18nUtil.getI18nLabel(174255, "平均值环比增幅"), k + UD + AVG + P_M2M_INCREASE)); + } + if (avgRule != null && 1 == avgRule.getY2yValue()) { + children.add(new WeaTableColumnGroup(COL_WIDTH, SalaryI18nUtil.getI18nLabel(180674, "同比周期(平均值)"), k + UD + AVG + P_SAME)); + children.add(new WeaTableColumnGroup(COL_WIDTH, SalaryI18nUtil.getI18nLabel(174385, "平均值同比差值"), k + UD + AVG + P_Y2Y_D_VALUE)); + children.add(new WeaTableColumnGroup(COL_WIDTH, SalaryI18nUtil.getI18nLabel(174386, "平均值同比增幅"), k + UD + AVG + P_Y2Y_INCREASE)); + } + // 4.最大值规则children + SalaryStatisticsItemRuleDTO maxRule = JSON.parseObject(itemPO.getMaxRule(), SalaryStatisticsItemRuleDTO.class); + if (maxRule != null && 1 == maxRule.getTotalValue()) { + children.add(new WeaTableColumnGroup(COL_WIDTH, SalaryI18nUtil.getI18nLabel(174254, "本周期(最大值)"), k + UD + MAX + P_NOW)); + } + if (maxRule != null && 1 == maxRule.getRatioValue()) { + children.add(new WeaTableColumnGroup(COL_WIDTH, SalaryI18nUtil.getI18nLabel(174291, "本周期占比(最大值)"), k + UD + MAX + P_RATIO)); + } + if (maxRule != null && 1 == maxRule.getM2mValue()) { + children.add(new WeaTableColumnGroup(COL_WIDTH, SalaryI18nUtil.getI18nLabel(174253, "上周期(最大值)"), k + UD + MAX + P_LAST)); + children.add(new WeaTableColumnGroup(COL_WIDTH, SalaryI18nUtil.getI18nLabel(174252, "最大值环比差值"), k + UD + MAX + P_M2M_D_VALUE)); + children.add(new WeaTableColumnGroup(COL_WIDTH, SalaryI18nUtil.getI18nLabel(174251, "最大值环比增幅"), k + UD + MAX + P_M2M_INCREASE)); + } + if (maxRule != null && 1 == maxRule.getY2yValue()) { + children.add(new WeaTableColumnGroup(COL_WIDTH, SalaryI18nUtil.getI18nLabel(180675, "同比周期(最大值)"), k + UD + MAX + P_SAME)); + children.add(new WeaTableColumnGroup(COL_WIDTH, SalaryI18nUtil.getI18nLabel(174382, "最大值同比差值"), k + UD + MAX + P_Y2Y_D_VALUE)); + children.add(new WeaTableColumnGroup(COL_WIDTH, SalaryI18nUtil.getI18nLabel(174383, "最大值同比增幅"), k + UD + MAX + P_Y2Y_INCREASE)); + } + // 5.最小值规则children + SalaryStatisticsItemRuleDTO minRule = JSON.parseObject(itemPO.getMinRule(), SalaryStatisticsItemRuleDTO.class); + if (minRule != null && 1 == minRule.getTotalValue()) { + children.add(new WeaTableColumnGroup(COL_WIDTH, SalaryI18nUtil.getI18nLabel(174250, "本周期(最小值)"), k + UD + MIN + P_NOW)); + } + if (minRule != null && 1 == minRule.getRatioValue()) { + children.add(new WeaTableColumnGroup(COL_WIDTH, SalaryI18nUtil.getI18nLabel(174292, "本周期占比(最小值)"), k + UD + MIN + P_RATIO)); + } + if (minRule != null && 1 == minRule.getM2mValue()) { + children.add(new WeaTableColumnGroup(COL_WIDTH, SalaryI18nUtil.getI18nLabel(174249, "上周期(最小值)"), k + UD + MIN + P_LAST)); + children.add(new WeaTableColumnGroup(COL_WIDTH, SalaryI18nUtil.getI18nLabel(174248, "最小值环比差值"), k + UD + MIN + P_M2M_D_VALUE)); + children.add(new WeaTableColumnGroup(COL_WIDTH, SalaryI18nUtil.getI18nLabel(174247, "最小值环比增幅"), k + UD + MIN + P_M2M_INCREASE)); + } + if (minRule != null && 1 == minRule.getY2yValue()) { + children.add(new WeaTableColumnGroup(COL_WIDTH, SalaryI18nUtil.getI18nLabel(180676, "同比周期(最小值)"), k + UD + MIN + P_SAME)); + children.add(new WeaTableColumnGroup(COL_WIDTH, SalaryI18nUtil.getI18nLabel(174379, "最小值同比差值"), k + UD + MIN + P_Y2Y_D_VALUE)); + children.add(new WeaTableColumnGroup(COL_WIDTH, SalaryI18nUtil.getI18nLabel(174380, "最小值同比增幅"), k + UD + MIN + P_Y2Y_INCREASE)); + } + // 6.中位数规则children + SalaryStatisticsItemRuleDTO medianRule = JSON.parseObject(itemPO.getMedianRule(), SalaryStatisticsItemRuleDTO.class); + if (medianRule != null && 1 == medianRule.getTotalValue()) { + children.add(new WeaTableColumnGroup(COL_WIDTH, SalaryI18nUtil.getI18nLabel(174246, "本周期(中位数)"), k + UD + MEDIAN + P_NOW)); + } + if (medianRule != null && 1 == medianRule.getRatioValue()) { + children.add(new WeaTableColumnGroup(COL_WIDTH, SalaryI18nUtil.getI18nLabel(174293, "本周期占比(中位数)"), k + UD + MEDIAN + P_RATIO)); + } + if (medianRule != null && 1 == medianRule.getM2mValue()) { + children.add(new WeaTableColumnGroup(COL_WIDTH, SalaryI18nUtil.getI18nLabel(174245, "上周期(中位数)"), k + UD + MEDIAN + P_LAST)); + children.add(new WeaTableColumnGroup(COL_WIDTH, SalaryI18nUtil.getI18nLabel(174244, "中位数环比差值"), k + UD + MEDIAN + P_M2M_D_VALUE)); + children.add(new WeaTableColumnGroup(COL_WIDTH, SalaryI18nUtil.getI18nLabel(174243, "中位数环比增幅"), k + UD + MEDIAN + P_M2M_INCREASE)); + } + if (medianRule != null && 1 == medianRule.getY2yValue()) { + children.add(new WeaTableColumnGroup(COL_WIDTH, SalaryI18nUtil.getI18nLabel(180677, "同比周期(中位数)"), k + UD + MEDIAN + P_SAME)); + children.add(new WeaTableColumnGroup(COL_WIDTH, SalaryI18nUtil.getI18nLabel(174376, "中位数同比差值"), k + UD + MEDIAN + P_Y2Y_D_VALUE)); + children.add(new WeaTableColumnGroup(COL_WIDTH, SalaryI18nUtil.getI18nLabel(174377, "中位数同比增幅"), k + UD + MEDIAN + P_Y2Y_INCREASE)); + } + // 7.最新值children + SalaryStatisticsItemRuleDTO lastRule = JSON.parseObject(itemPO.getLastRule(), SalaryStatisticsItemRuleDTO.class); + if (lastRule != null && 1 == lastRule.getTotalValue()) { + children.add(new WeaTableColumnGroup(COL_WIDTH, SalaryI18nUtil.getI18nLabel(174246, "最新值"), k + UD + SalaryStatisticsItemStringRuleEnum.LAST.getValue() + P_NOW)); + } + // 8.最旧值children + SalaryStatisticsItemRuleDTO oldRule = JSON.parseObject(itemPO.getOldRule(), SalaryStatisticsItemRuleDTO.class); + if (oldRule != null && 1 == oldRule.getTotalValue()) { + children.add(new WeaTableColumnGroup(COL_WIDTH, SalaryI18nUtil.getI18nLabel(174246, "最旧值"), k + UD + SalaryStatisticsItemStringRuleEnum.OLD.getValue() + P_NOW)); + } + // 9.最频繁children + SalaryStatisticsItemRuleDTO frequentRule = JSON.parseObject(itemPO.getFrequentRule(), SalaryStatisticsItemRuleDTO.class); + if (frequentRule != null && 1 == frequentRule.getTotalValue()) { + children.add(new WeaTableColumnGroup(COL_WIDTH, SalaryI18nUtil.getI18nLabel(174246, "最频繁"), k + UD + SalaryStatisticsItemStringRuleEnum.FREQUENT.getValue() + P_NOW)); + } + // 10.平铺children + SalaryStatisticsItemRuleDTO tileRule = JSON.parseObject(itemPO.getTileRule(), SalaryStatisticsItemRuleDTO.class); + if (tileRule != null && 1 == tileRule.getTotalValue()) { + children.add(new WeaTableColumnGroup(COL_WIDTH, SalaryI18nUtil.getI18nLabel(174246, "平铺"), k + UD + SalaryStatisticsItemStringRuleEnum.TILE.getValue() + P_NOW)); + } + weaTableColumn.setChildren(children); + result.add(weaTableColumn); + }); + return result; + } + + public static ExportCommonParam buildExportParam(String dimName, List weaTableColumns, List> records) { + List columns = com.google.common.collect.Lists.newArrayList(); + weaTableColumns.forEach(column -> { + WeaTableColumnGroup WeaTableColumnGroup = (WeaTableColumnGroup) column; + ExportColumn exportColumn = new ExportColumn(); + exportColumn.setKeyIndex(WeaTableColumnGroup.getColumn()); + exportColumn.setValue(WeaTableColumnGroup.getText()); + if (CollectionUtils.isNotEmpty(WeaTableColumnGroup.getChildren())) { + List subColumns = com.google.common.collect.Lists.newArrayList(); + for (WeaTableColumnGroup sub : WeaTableColumnGroup.getChildren()) { + ExportColumn subColumn = new ExportColumn(); + subColumn.setKeyIndex(sub.getColumn()); + subColumn.setValue(sub.getText()); + subColumns.add(subColumn); + } + exportColumn.setChildren(subColumns); + } + columns.add(exportColumn); + }); + ExportCommonParam exportParam = new ExportCommonParam(); + exportParam.setDimensionName(dimName); + exportParam.setColumns(columns); + exportParam.setData(records); + + return exportParam; + } +} diff --git a/src/com/engine/salary/report/entity/dto/SalaryReportCacheInfo.java b/src/com/engine/salary/report/entity/dto/SalaryReportCacheInfo.java new file mode 100644 index 000000000..855a73542 --- /dev/null +++ b/src/com/engine/salary/report/entity/dto/SalaryReportCacheInfo.java @@ -0,0 +1,34 @@ +package com.engine.salary.report.entity.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; +import java.util.Map; + +/** + * 分析图数据展示范围设置 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//"报表查询入参") +public class SalaryReportCacheInfo { + + List reports; + + class Report { + String key; + List conditions; + } + + + class Condition { + String key; + Map result; + } + +} diff --git a/src/com/engine/salary/report/entity/dto/SalaryStatisticsDimensionFormDTO.java b/src/com/engine/salary/report/entity/dto/SalaryStatisticsDimensionFormDTO.java new file mode 100644 index 000000000..5e78018f6 --- /dev/null +++ b/src/com/engine/salary/report/entity/dto/SalaryStatisticsDimensionFormDTO.java @@ -0,0 +1,29 @@ +package com.engine.salary.report.entity.dto; + +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 薪酬统计维度表单 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//"薪酬统计维度表单") +public class SalaryStatisticsDimensionFormDTO { + + //主键id") + @JsonSerialize(using = ToStringSerializer.class) + private Long id; + + //统计维度基础表单") + private Object baseForm; + + //分组设置") + private Object groupSetting; +} diff --git a/src/com/engine/salary/report/entity/dto/SalaryStatisticsDimensionListDTO.java b/src/com/engine/salary/report/entity/dto/SalaryStatisticsDimensionListDTO.java new file mode 100644 index 000000000..f0fb237af --- /dev/null +++ b/src/com/engine/salary/report/entity/dto/SalaryStatisticsDimensionListDTO.java @@ -0,0 +1,48 @@ +package com.engine.salary.report.entity.dto; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 薪酬统计维度列表 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//"薪酬统计维度列表") +public class SalaryStatisticsDimensionListDTO { + + //主键id") + @JsonSerialize(using = ToStringSerializer.class) + private Long id; + + // 统计维度") + private String dimName; + + // 描述") + private String remark; + + // 维度类型") + private String dimType; + + //是否默认") + @JsonIgnore + private Integer isDefault; + + // 能否删除 + private boolean canDelete; + + // 能否编辑 + private boolean canEdit; +} diff --git a/src/com/engine/salary/report/entity/dto/SalaryStatisticsEchartsDTO.java b/src/com/engine/salary/report/entity/dto/SalaryStatisticsEchartsDTO.java new file mode 100644 index 000000000..cc3dfff7a --- /dev/null +++ b/src/com/engine/salary/report/entity/dto/SalaryStatisticsEchartsDTO.java @@ -0,0 +1,52 @@ +package com.engine.salary.report.entity.dto; + +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * 分析图数据展示范围设置 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//"报表查询入参") +public class SalaryStatisticsEchartsDTO { + // 分析图配置表id") + @JsonSerialize(using = ToStringSerializer.class) + private Long id; + + //报表id") + @JsonSerialize(using = ToStringSerializer.class) + private Long reportId; + + //报表类型") + private Integer chartsType; + + // 统计项目") + private List itemValues; + + //统计列") + private String itemColValue; + + // 维度统计范围") + private Integer dimensionRange; + + //排序统计项目") + private String itemSortValue; + + // 排序列") + private String itemColSortValue; + + // 排序类型") + private Integer sortType; + + // 排序取数值") + private Integer sortNum; +} diff --git a/src/com/engine/salary/report/entity/dto/SalaryStatisticsEmployeeDetailResultDTO.java b/src/com/engine/salary/report/entity/dto/SalaryStatisticsEmployeeDetailResultDTO.java new file mode 100644 index 000000000..1023b6c4b --- /dev/null +++ b/src/com/engine/salary/report/entity/dto/SalaryStatisticsEmployeeDetailResultDTO.java @@ -0,0 +1,38 @@ +package com.engine.salary.report.entity.dto; + +import com.cloudstore.eccom.pc.table.WeaTableType; +import com.engine.salary.annotation.SalaryTable; +import com.engine.salary.annotation.SalaryTableOperate; +import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO; +import com.engine.salary.entity.salaryacct.po.SalaryAcctResultPO; +import com.engine.salary.entity.salaryitem.po.SalaryItemPO; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * 薪酬统计员工明细核算结果 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//"薪酬统计员工明细核算结果") +@SalaryTable(pageId = "a4f85287-9876-4d11-adn9-7d06e54y6672", tableType = WeaTableType.CHECKBOX, operates = { + @SalaryTableOperate(index = "0", text = "编辑"), + @SalaryTableOperate(index = "1", text = "删除") +}) +public class SalaryStatisticsEmployeeDetailResultDTO { + + //核算人员") + private List salaryAcctEmployeeList; + + //核算结果") + private List salaryAcctResultValueList; + + //薪资项目") + private List salaryItemList; +} diff --git a/src/com/engine/salary/report/entity/dto/SalaryStatisticsEmployeeListDTO.java b/src/com/engine/salary/report/entity/dto/SalaryStatisticsEmployeeListDTO.java new file mode 100644 index 000000000..791c01c30 --- /dev/null +++ b/src/com/engine/salary/report/entity/dto/SalaryStatisticsEmployeeListDTO.java @@ -0,0 +1,54 @@ +package com.engine.salary.report.entity.dto; + +import com.engine.salary.annotation.TableTitle; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 薪酬统计员工列表 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalaryStatisticsEmployeeListDTO { + + //主键id + @JsonSerialize(using = ToStringSerializer.class) + private Long id; + + //姓名 + @TableTitle(title = "姓名", dataIndex = "name", key = "name") + private String name; + + //分部 + @TableTitle(title = "分部", dataIndex = "subCompany", key = "subCompany") + private String subCompany; + + //部门 + @TableTitle(title = "部门", dataIndex = "department", key = "department") + private String department; + + //岗位 + @TableTitle(title = "岗位", dataIndex = "position", key = "position") + private String position; + + // 员工状态 + @TableTitle(title = "员工状态", dataIndex = "status", key = "status") + private String status; + + //工号 + @TableTitle(title = "工号", dataIndex = "jobNum", key = "jobNum") + private String jobNum; + + //证件号码 + @TableTitle(title = "证件号码", dataIndex = "idNo", key = "idNo") + private String idNo; + + //人员类型 + private Integer employeeType; +} diff --git a/src/com/engine/salary/report/entity/dto/SalaryStatisticsItemFormDTO.java b/src/com/engine/salary/report/entity/dto/SalaryStatisticsItemFormDTO.java new file mode 100644 index 000000000..19e601bbd --- /dev/null +++ b/src/com/engine/salary/report/entity/dto/SalaryStatisticsItemFormDTO.java @@ -0,0 +1,30 @@ +package com.engine.salary.report.entity.dto; + +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Map; + +/** + * 薪酬统计自定义统计项表单 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalaryStatisticsItemFormDTO { + + //主键id + @JsonSerialize(using = ToStringSerializer.class) + private Long id; + + //基础表单 + private Object baseForm; + + //统计规则 + private Map ruleData; +} diff --git a/src/com/engine/salary/report/entity/dto/SalaryStatisticsItemRuleDTO.java b/src/com/engine/salary/report/entity/dto/SalaryStatisticsItemRuleDTO.java new file mode 100644 index 000000000..02cce6b8b --- /dev/null +++ b/src/com/engine/salary/report/entity/dto/SalaryStatisticsItemRuleDTO.java @@ -0,0 +1,42 @@ +package com.engine.salary.report.entity.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.math.BigDecimal; + +/** + * 薪酬统计报表自定义统计项目规则 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalaryStatisticsItemRuleDTO { + + //是否有合计列。若是文本,代表是否显示 + private Integer totalValue; + + //是否有占比列 + private Integer ratioValue; + + //是否有环比列 + private Integer m2mValue; + + //合计环比上限 + private BigDecimal m2mUpperLimit; + + //合计环比下限 + private BigDecimal m2mLowerLimit; + + //是否有同比列 + private Integer y2yValue; + + //合计同比上限 + private BigDecimal y2yUpperLimit; + + //合计同比下限 + private BigDecimal y2yLowerLimit; +} diff --git a/src/com/engine/salary/report/entity/dto/SalaryStatisticsItemStringRuleDTO.java b/src/com/engine/salary/report/entity/dto/SalaryStatisticsItemStringRuleDTO.java new file mode 100644 index 000000000..d41c75db1 --- /dev/null +++ b/src/com/engine/salary/report/entity/dto/SalaryStatisticsItemStringRuleDTO.java @@ -0,0 +1,23 @@ +package com.engine.salary.report.entity.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 薪酬统计报表自定义统计字符项目规则 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalaryStatisticsItemStringRuleDTO { + + + /** + * 是否启用 + */ + private Integer ableValue; + +} diff --git a/src/com/engine/salary/report/entity/dto/SalaryStatisticsPushDetail.java b/src/com/engine/salary/report/entity/dto/SalaryStatisticsPushDetail.java new file mode 100644 index 000000000..a075e19ac --- /dev/null +++ b/src/com/engine/salary/report/entity/dto/SalaryStatisticsPushDetail.java @@ -0,0 +1,25 @@ +package com.engine.salary.report.entity.dto; + +import com.engine.salary.util.page.PageInfo; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Description: 薪酬报表推送详情 + * @Author: zhangheng + * @CreateDate: 2023/5/23 + * @Version: v1.0 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalaryStatisticsPushDetail { + + private SalaryStatisticsPushDetailFormDTO detailForm; + + private PageInfo detailTable; + +} diff --git a/src/com/engine/salary/report/entity/dto/SalaryStatisticsPushDetailFormDTO.java b/src/com/engine/salary/report/entity/dto/SalaryStatisticsPushDetailFormDTO.java new file mode 100644 index 000000000..66fcf666a --- /dev/null +++ b/src/com/engine/salary/report/entity/dto/SalaryStatisticsPushDetailFormDTO.java @@ -0,0 +1,36 @@ +package com.engine.salary.report.entity.dto; + +import com.engine.salary.annotation.TableTitle; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Description: 薪酬报表推送详情表单 + * @Author: zhangheng + * @CreateDate: 2023/5/23 + * @Version: v1.0 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalaryStatisticsPushDetailFormDTO { + + + @TableTitle(title = "分享报表", dataIndex = "reportName", key = "reportName") + private String reportName; + + @TableTitle(title = "报表查看有效时间", dataIndex = "effectiveTime", key = "effectiveTime") + private String effectiveTime; + + @TableTitle(title = "邮件账号", dataIndex = "emailAccount", key = "emailAccount") + private String emailAccount; + + @TableTitle(title = "报表分享渠道", dataIndex = "channel", key = "channel") + private String channel; + + @TableTitle(title = "分享说明", dataIndex = "remark", key = "remark") + private String remark; +} diff --git a/src/com/engine/salary/report/entity/dto/SalaryStatisticsPushDetailTableDTO.java b/src/com/engine/salary/report/entity/dto/SalaryStatisticsPushDetailTableDTO.java new file mode 100644 index 000000000..7702ab2c8 --- /dev/null +++ b/src/com/engine/salary/report/entity/dto/SalaryStatisticsPushDetailTableDTO.java @@ -0,0 +1,48 @@ +package com.engine.salary.report.entity.dto; + +import com.engine.salary.annotation.TableTitle; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Description: 薪酬统计维度列表 + * @Author: zhangheng + * @CreateDate: 2023/5/23 + * @Version: v1.0 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalaryStatisticsPushDetailTableDTO { + + // 主键id + @JsonSerialize(using = ToStringSerializer.class) + private Long id; + + @TableTitle(title = "姓名", dataIndex = "userName", key = "userName") + private String userName; + + @JsonSerialize(using = ToStringSerializer.class) + private Long employeeId; + + @TableTitle(title = "分享时间", dataIndex = "pushTime", key = "pushTime") + private String pushTime; + + @TableTitle(title = "分享状态", dataIndex = "pushStatus", key = "pushStatus") + private String pushStatus; + + @TableTitle(title = "查看状态", dataIndex = "viewStatus", key = "viewStatus") + private String viewStatus; + + @TableTitle(title = "撤回时间", dataIndex = "rebackTime", key = "rebackTime") + private String rebackTime; + + @TableTitle(title = "撤回状态", dataIndex = "rebackStatus", key = "rebackStatus") + private String rebackStatus; + +} diff --git a/src/com/engine/salary/report/entity/dto/SalaryStatisticsPushTableDTO.java b/src/com/engine/salary/report/entity/dto/SalaryStatisticsPushTableDTO.java new file mode 100644 index 000000000..7505e14b9 --- /dev/null +++ b/src/com/engine/salary/report/entity/dto/SalaryStatisticsPushTableDTO.java @@ -0,0 +1,42 @@ +package com.engine.salary.report.entity.dto; + +import com.engine.salary.annotation.TableTitle; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Description: 薪酬统计维度列表 + * @Author: zhangheng + * @CreateDate: 2023/5/23 + * @Version: v1.0 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalaryStatisticsPushTableDTO { + + // 主键id + @JsonSerialize(using = ToStringSerializer.class) + private Long id; + + @TableTitle(title = "分享报表", dataIndex = "reportName", key = "reportName") + private String reportName; + + // 数据查询有效时间 + @TableTitle(title = "数据查询有效时间", dataIndex = "effectiveTime", key = "effectiveTime") + private String effectiveTime; + + // 分享成功的被分享人 + @TableTitle(title = "分享成功的被分享人", dataIndex = "successPush", key = "successPush") + private String successPush; + + // 被分享人查看情况 + @TableTitle(title = "被分享人查看情况", dataIndex = "sharedView", key = "sharedView") + private String sharedView; + +} diff --git a/src/com/engine/salary/report/entity/dto/SalaryStatisticsReportDataDTO.java b/src/com/engine/salary/report/entity/dto/SalaryStatisticsReportDataDTO.java new file mode 100644 index 000000000..bb70ecad4 --- /dev/null +++ b/src/com/engine/salary/report/entity/dto/SalaryStatisticsReportDataDTO.java @@ -0,0 +1,54 @@ +package com.engine.salary.report.entity.dto; + +import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO; +import com.engine.salary.report.entity.po.SalaryStatisticsItemPO; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * 薪酬统计报表自定义统计项目规则 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//"薪酬统计报表数据") +public class SalaryStatisticsReportDataDTO { + + //本期数据") + private List list; + + //上期数据") + private List lastList; + + // 同期数据") + private List sameList; + + //统计项目") + private List salaryStatisticsItemList; + + //当前登录人id") + @JsonSerialize(using = ToStringSerializer.class) + private Long employeeId; + + //租户key") + private String tenantKey; + + //维度值 + private String dimensionValue; + + //根据dimensionValue获取到的本期数据 + private List listByDimensionValue; + +} diff --git a/src/com/engine/salary/report/entity/dto/SalaryStatisticsReportFormDTO.java b/src/com/engine/salary/report/entity/dto/SalaryStatisticsReportFormDTO.java new file mode 100644 index 000000000..95c88d855 --- /dev/null +++ b/src/com/engine/salary/report/entity/dto/SalaryStatisticsReportFormDTO.java @@ -0,0 +1,32 @@ +package com.engine.salary.report.entity.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * 薪酬统计报表表单 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//"薪酬统计报表表单") +public class SalaryStatisticsReportFormDTO { + + //报表名称") + private String reportName; + + //统计维度") + private String dimension; + + private List statsDimOptions; +} diff --git a/src/com/engine/salary/report/entity/dto/SubEmployeeTableDTO.java b/src/com/engine/salary/report/entity/dto/SubEmployeeTableDTO.java new file mode 100644 index 000000000..981e30ac2 --- /dev/null +++ b/src/com/engine/salary/report/entity/dto/SubEmployeeTableDTO.java @@ -0,0 +1,36 @@ +package com.engine.salary.report.entity.dto; + +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.io.Serializable; + + +@Data +@Accessors(chain = true) +//人员信息过滤中间类") +public class SubEmployeeTableDTO implements Serializable { + + private static final long serialVersionUID = -7204043277857506702L; + + @JsonSerialize(using = ToStringSerializer.class) + private Long id; + + private String name; + + private String subCompany; + + private String department; + + private String position; + + private String status; + + private String idNo; + + private String jobNum; + + private Integer employeeType; +} diff --git a/src/com/engine/salary/report/entity/dto/SubTableChartsDTO.java b/src/com/engine/salary/report/entity/dto/SubTableChartsDTO.java new file mode 100644 index 000000000..78b681b01 --- /dev/null +++ b/src/com/engine/salary/report/entity/dto/SubTableChartsDTO.java @@ -0,0 +1,47 @@ +package com.engine.salary.report.entity.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//"报表查询入参") +public class SubTableChartsDTO { + + //分析图配置表id") + private Long id; + + //报表id") + private Long tableId; + + //报表类型") + private Integer chartsType; + + //统计项目") + private List itemValues; + + //统计列") + private String itemColValue; + + //维度统计范围") + private Integer dimensionRange; + + // 排序统计项目") + private String itemSortValue; + + //排序列") + private String itemColSortValue; + + //排序类型") + private Integer sortType; + + //排序取数值") + private Integer sortNum; +} diff --git a/src/com/engine/salary/report/entity/dto/TaxAgentViewDTO.java b/src/com/engine/salary/report/entity/dto/TaxAgentViewDTO.java new file mode 100644 index 000000000..bd3907290 --- /dev/null +++ b/src/com/engine/salary/report/entity/dto/TaxAgentViewDTO.java @@ -0,0 +1,24 @@ +package com.engine.salary.report.entity.dto; + +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//"管理员/总管理员查看个税扣缴义务人") +public class TaxAgentViewDTO { + + // 是否能够查看操作全部个税扣缴义务人") + private Boolean isEnableAll; + + //可以查看操作的个税扣缴义务人列表") + private List taxAgentList; +} diff --git a/src/com/engine/salary/report/entity/param/ExportColumn.java b/src/com/engine/salary/report/entity/param/ExportColumn.java new file mode 100644 index 000000000..ef5fa5e57 --- /dev/null +++ b/src/com/engine/salary/report/entity/param/ExportColumn.java @@ -0,0 +1,20 @@ +package com.engine.salary.report.entity.param; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@NoArgsConstructor +@AllArgsConstructor +//"表头") +public class ExportColumn { + + private String keyIndex; + + private String value; + + private List children; +} diff --git a/src/com/engine/salary/report/entity/param/ExportCommonParam.java b/src/com/engine/salary/report/entity/param/ExportCommonParam.java new file mode 100644 index 000000000..1c441a4cf --- /dev/null +++ b/src/com/engine/salary/report/entity/param/ExportCommonParam.java @@ -0,0 +1,33 @@ +package com.engine.salary.report.entity.param; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; +import java.util.Map; + +@Data +@NoArgsConstructor +@AllArgsConstructor +//"通用层叠表导出") +public class ExportCommonParam { + + //columns") + private List columns; + + //data") + private List> data; + + //excel名称") + private String sheetName; + + //维度名称") + private String dimensionName; + + //操作员") + private String userName; + + //加密") + private String sharePassword; +} diff --git a/src/com/engine/salary/report/entity/param/SalaryAcctEmployeeQueryParam.java b/src/com/engine/salary/report/entity/param/SalaryAcctEmployeeQueryParam.java new file mode 100644 index 000000000..fb4131bb4 --- /dev/null +++ b/src/com/engine/salary/report/entity/param/SalaryAcctEmployeeQueryParam.java @@ -0,0 +1,34 @@ +package com.engine.salary.report.entity.param; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; +import java.util.List; + +/** + * 薪酬统计员工明细查询参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//"薪资核算员工查询参数") +public class SalaryAcctEmployeeQueryParam { + + // 关键字") + private String keyword; + + // 年份") + private Integer year; + + //薪资所属月") + private List salaryMonth; +} \ No newline at end of file diff --git a/src/com/engine/salary/report/entity/param/SalaryEmployeeQueryParam.java b/src/com/engine/salary/report/entity/param/SalaryEmployeeQueryParam.java new file mode 100644 index 000000000..195c23d27 --- /dev/null +++ b/src/com/engine/salary/report/entity/param/SalaryEmployeeQueryParam.java @@ -0,0 +1,39 @@ +package com.engine.salary.report.entity.param; + +import lombok.Data; +import lombok.experimental.Accessors; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; + +import java.util.Collection; + +/** + * 人员查询条件 + */ +@Data +@Accessors(chain = true) +public class SalaryEmployeeQueryParam { + + //人员名称 + private String usernameLike; + + //部门 + private Collection departmentIds; + + //岗位 + private Collection positionIds; + + //状态 + private String personnelStatus; + + //工号 + private String jobNumLike; + + public boolean isEmpty(){ + return StringUtils.isEmpty(usernameLike) + && CollectionUtils.isEmpty(departmentIds) + && CollectionUtils.isEmpty(positionIds) + && StringUtils.isEmpty(personnelStatus) + && StringUtils.isEmpty(jobNumLike); + } +} diff --git a/src/com/engine/salary/report/entity/param/SalaryStatisticsDataPerspectiveQueryParam.java b/src/com/engine/salary/report/entity/param/SalaryStatisticsDataPerspectiveQueryParam.java new file mode 100644 index 000000000..d0afd0c00 --- /dev/null +++ b/src/com/engine/salary/report/entity/param/SalaryStatisticsDataPerspectiveQueryParam.java @@ -0,0 +1,87 @@ +package com.engine.salary.report.entity.param; + +import com.engine.salary.common.BaseQueryParam; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; +import java.util.List; + +/** + * 薪酬统计数据透视查询参数 + *

Copyright: Copyright (c) 2023

+ *

Company: 泛微软件

+ * + * @author Harryxzy + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalaryStatisticsDataPerspectiveQueryParam extends BaseQueryParam { + + //报表id + private Long id; + + //统计维度 + private Long dimensionId; + + //统计维度值 + private String dimensionValue; + + @JsonIgnore + //薪资所属月-开始月 + private String salaryStartMonth; + + @JsonIgnore + // 薪资所属月-终止月 + private String salaryEndMonth; + + @JsonIgnore + //个税扣缴义务人配置 + private List taxAgent; + + @JsonIgnore + //收入所得项目配置 + private List incomeCategory; + + @JsonIgnore + //分部配置 + private List subCompany; + + @JsonIgnore + //部门配置 + private List depart; + + @JsonIgnore + //职级配置 + private List grade; + + @JsonIgnore + // 岗位配置 + private List position; + + @JsonIgnore + //人员状态配置 + private List status; + + @JsonIgnore + //人员 + private List employee; + + @JsonIgnore + // 入职日期 + private List hiredate; + + @JsonIgnore + // 离职日期 + private List leavedate; + + + // 是否是分享报表 + private boolean isShare; +} \ No newline at end of file diff --git a/src/com/engine/salary/report/entity/param/SalaryStatisticsDimensionQueryParam.java b/src/com/engine/salary/report/entity/param/SalaryStatisticsDimensionQueryParam.java new file mode 100644 index 000000000..fd55e7b49 --- /dev/null +++ b/src/com/engine/salary/report/entity/param/SalaryStatisticsDimensionQueryParam.java @@ -0,0 +1,26 @@ +package com.engine.salary.report.entity.param; + +import com.engine.salary.common.BaseQueryParam; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 薪酬统计维度查询参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//"薪酬统计维度查询参数") +public class SalaryStatisticsDimensionQueryParam extends BaseQueryParam { + + //名称") + private String dimName; +} diff --git a/src/com/engine/salary/report/entity/param/SalaryStatisticsDimensionSaveParam.java b/src/com/engine/salary/report/entity/param/SalaryStatisticsDimensionSaveParam.java new file mode 100644 index 000000000..3de5f955b --- /dev/null +++ b/src/com/engine/salary/report/entity/param/SalaryStatisticsDimensionSaveParam.java @@ -0,0 +1,132 @@ +package com.engine.salary.report.entity.param; + +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.report.enums.SalaryStatisticsDimensionTypeEnum; +import com.engine.salary.util.SalaryI18nUtil; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; + +import java.util.List; +import java.util.Objects; + +/** + * 薪酬统计维度保存参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//"薪酬统计维度保存参数") +public class SalaryStatisticsDimensionSaveParam { + + //薪酬统计维度主键id") + private Long id; + + //薪酬统计维度类型") + private SalaryStatisticsDimensionTypeEnum dimType; + + //薪酬统计维度名称") + private String dimName; + + //薪酬统计维度编码-》用于组距和单项式的所属字段") + private String dimCode; + + //备注") + private String remark; + + //薪酬统计维度定性设置保存参数") + private Setting4Qualitative setting4Qualitative; + + //薪酬统计维度定量-组距式分组设置保存参数") + private List setting4RationGroupSpacing; + + //薪酬统计维度定量-单项式分组设置保存参数") + private List setting4RationGroupIndividual; + + public static void checkParam(SalaryStatisticsDimensionSaveParam saveParam) { + if (StringUtils.isEmpty(saveParam.getDimName())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(161289, "统计维度名称必填")); + } + saveParam.setDimName(saveParam.getDimName().trim()); + if (Objects.isNull(saveParam.getDimType())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(161290, "统计维度类型必传")); + } + if (SalaryStatisticsDimensionTypeEnum.QUALITATIVE.equals(saveParam.getDimType())) { + if (Objects.isNull(saveParam.getSetting4Qualitative())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(161291, "统计维度必选")); + } + if (Objects.isNull(saveParam.getSetting4Qualitative().getId())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(161292, "统计维度关联参数错误")); + } + } else if (SalaryStatisticsDimensionTypeEnum.RATION_GROUP_SPACING.equals(saveParam.getDimType())) { + if (CollectionUtils.isEmpty(saveParam.getSetting4RationGroupSpacing())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(161293, "分组设置不能为空")); + } + saveParam.getSetting4RationGroupSpacing().forEach(s -> { + if (Objects.isNull(s.getId()) || StringUtils.isEmpty(s.getStartValue()) || StringUtils.isEmpty(s.getEndValue())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(161294, "分组设置参数错误")); + } + }); + } else if (SalaryStatisticsDimensionTypeEnum.RATION_GROUP_INDIVIDUAL.equals(saveParam.getDimType())) { + if (CollectionUtils.isEmpty(saveParam.getSetting4RationGroupIndividual())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(161293, "分组设置不能为空")); + } + saveParam.getSetting4RationGroupIndividual().forEach(s -> { + if (Objects.isNull(s.getId()) || StringUtils.isEmpty(s.getValue())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(161294, "分组设置参数错误")); + } + }); + } + } + + @Data + //"薪酬统计维度定性设置保存参数") + public static class Setting4Qualitative { + + //关联id") + private String id; + + //统计维度名称") + private String name; + } + + @Data + //"薪酬统计维度定量-组距式分组设置保存参数") + public static class Setting4RationGroupSpacing { + + //id") + private Long id; + + //起始是否包含") + private boolean includeStart; + + // 起始值") + private String startValue; + + // 结束是否包含") + private boolean includeEnd; + + //结束值") + private String endValue; + } + + @Data + //"薪酬统计维度定量-单项式分组设置保存参数") + public static class Setting4RationGroupIndividual { + + //id") + private Long id; + + // 值") + private String value; + } +} diff --git a/src/com/engine/salary/report/entity/param/SalaryStatisticsEmployeeDetailQueryParam.java b/src/com/engine/salary/report/entity/param/SalaryStatisticsEmployeeDetailQueryParam.java new file mode 100644 index 000000000..08080aa1c --- /dev/null +++ b/src/com/engine/salary/report/entity/param/SalaryStatisticsEmployeeDetailQueryParam.java @@ -0,0 +1,44 @@ +package com.engine.salary.report.entity.param; + +import com.engine.salary.common.BaseQueryParam; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; +import java.util.List; + +/** + * 薪酬统计员工详情查询参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//"薪酬统计员工详情查询参数 +public class SalaryStatisticsEmployeeDetailQueryParam extends BaseQueryParam { + + //主键id + private List ids; + + //人员表的主键id + private Long employeeId; + + //收入所得类型 + private Integer incomeCategory; + + //个税扣缴义务人 + private Long taxAgentId; + + //年份 + private Integer year; + + //薪资所属月 + private List salaryMonth; +} \ No newline at end of file diff --git a/src/com/engine/salary/report/entity/param/SalaryStatisticsEmployeeQueryParam.java b/src/com/engine/salary/report/entity/param/SalaryStatisticsEmployeeQueryParam.java new file mode 100644 index 000000000..b0be690c1 --- /dev/null +++ b/src/com/engine/salary/report/entity/param/SalaryStatisticsEmployeeQueryParam.java @@ -0,0 +1,38 @@ +package com.engine.salary.report.entity.param; + +import com.engine.salary.common.BaseQueryParam; +import com.engine.salary.report.enums.EmployeeTypeEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; +import java.util.List; + +/** + * 薪酬统计员工明细查询参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//"薪酬统计员工明细查询参数") +public class SalaryStatisticsEmployeeQueryParam extends BaseQueryParam { + //关键字") + private String keyword; + + //年份") + private Integer year; + + //薪资所属月") + private List salaryMonth; + + //人员类型,ORGANIZATION:内部人员 |EXT_EMPLOYEE:外部人员") + private EmployeeTypeEnum employeeType; +} \ No newline at end of file diff --git a/src/com/engine/salary/report/entity/param/SalaryStatisticsEmployeeSalaryQueryParam.java b/src/com/engine/salary/report/entity/param/SalaryStatisticsEmployeeSalaryQueryParam.java new file mode 100644 index 000000000..a5d6b0253 --- /dev/null +++ b/src/com/engine/salary/report/entity/param/SalaryStatisticsEmployeeSalaryQueryParam.java @@ -0,0 +1,56 @@ +package com.engine.salary.report.entity.param; + +import com.engine.salary.common.BaseQueryParam; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; +import java.util.List; + +/** + * @author Harryxzy + * @ClassName f + * @date 2024/03/25 9:56 + * @description + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//"薪酬统计员工明细查询参数") +public class SalaryStatisticsEmployeeSalaryQueryParam extends BaseQueryParam { + + // 关键字 + private String keyword; + + //人员ids + private List employeeIds; + + // 起始年月 + private String startDateStr; + private Date startDate; + + // 结束年月 + private String endDateStr; + private Date endDate; + + // 个税扣缴义务人id + private List taxAgentIds; + + // 分部id + private List subCompanyIds; + + // 部门id + private List departmentIds; + + // 是否是导出 + private boolean isExport; + + // 部分导出id + private List ids; + + // 导出时显示列定制信息 + List columns; +} \ No newline at end of file diff --git a/src/com/engine/salary/report/entity/param/SalaryStatisticsItemGetFormParam.java b/src/com/engine/salary/report/entity/param/SalaryStatisticsItemGetFormParam.java new file mode 100644 index 000000000..47371c1bf --- /dev/null +++ b/src/com/engine/salary/report/entity/param/SalaryStatisticsItemGetFormParam.java @@ -0,0 +1,26 @@ +package com.engine.salary.report.entity.param; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 薪酬统计报表自定义统计项目保存参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalaryStatisticsItemGetFormParam { + //统计项目id + private Long id; + + //统计项目 + private Long itemId; +} diff --git a/src/com/engine/salary/report/entity/param/SalaryStatisticsItemSaveParam.java b/src/com/engine/salary/report/entity/param/SalaryStatisticsItemSaveParam.java new file mode 100644 index 000000000..933843736 --- /dev/null +++ b/src/com/engine/salary/report/entity/param/SalaryStatisticsItemSaveParam.java @@ -0,0 +1,69 @@ +package com.engine.salary.report.entity.param; + +import com.engine.salary.report.entity.dto.SalaryStatisticsItemRuleDTO; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * 薪酬统计报表自定义统计项目保存参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalaryStatisticsItemSaveParam { + //统计项目id + private Long id; + + // 报表id + private Long statReportId; + + //统计项目 + private List itemValue; + + //统计项名称 + private String itemName; + + //计数规则 + private SalaryStatisticsItemRuleDTO countRule; + + //求和规则 + private SalaryStatisticsItemRuleDTO sumRule; + + //平均值规则 + private SalaryStatisticsItemRuleDTO avgRule; + + //最大值规则 + private SalaryStatisticsItemRuleDTO maxRule; + + //最小值规则 + private SalaryStatisticsItemRuleDTO minRule; + + //中位数规则 + private SalaryStatisticsItemRuleDTO medianRule; + + //最近值 + private SalaryStatisticsItemRuleDTO lastRule; + + //最旧值 + private SalaryStatisticsItemRuleDTO oldRule; + + //频繁出现 + private SalaryStatisticsItemRuleDTO frequentRule; + + //平铺 + private SalaryStatisticsItemRuleDTO tileRule; + + + //统计单位 + private Integer unitType; +} diff --git a/src/com/engine/salary/report/entity/param/SalaryStatisticsPushDetailParam.java b/src/com/engine/salary/report/entity/param/SalaryStatisticsPushDetailParam.java new file mode 100644 index 000000000..004b79c97 --- /dev/null +++ b/src/com/engine/salary/report/entity/param/SalaryStatisticsPushDetailParam.java @@ -0,0 +1,26 @@ +package com.engine.salary.report.entity.param; + +import com.engine.salary.common.BaseQueryParam; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author Harryxzy + * @ClassName SalaryStatisticsPushDetailParam + * @date 2023/09/11 15:40 + * @description 获取发送消息记录详情 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalaryStatisticsPushDetailParam extends BaseQueryParam { + + // 主键id + private Long id; + + // 姓名 + private String userNameSearch; +} diff --git a/src/com/engine/salary/report/entity/param/SalaryStatisticsPushParam.java b/src/com/engine/salary/report/entity/param/SalaryStatisticsPushParam.java new file mode 100644 index 000000000..86f90c086 --- /dev/null +++ b/src/com/engine/salary/report/entity/param/SalaryStatisticsPushParam.java @@ -0,0 +1,64 @@ +package com.engine.salary.report.entity.param; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * @Description: 消息发送 + * @Author: zhangheng + * @CreateDate: 2023/5/23 + * @Version: v1.0 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalaryStatisticsPushParam { + + /*********************************前端传送参数*******************************************/ + // 快照id列表 + private List reportIds; + + // 分享主题 + private String pushTitle; + + // 被分享人 + private List sharedBy; + + // 开始时间 + private String startTime; + + // 结束时间 + private String endTime; + + // 消息渠道 + private List pushChannel; + + // 已查看提醒 + private Integer remind; + + // 邮件地址 + private String emailAdress; + + // 邮件账号id + private Long emailAccountId; + + // 分享说明 + private String mark; + + // 渠道组件值 + private String config; + + // 渠道组件业务id + private Long businessId; + /**********************************后端补齐参数*********************************************/ + // 域名 + private String domain; + + // 分享批次id + private Long id; +} diff --git a/src/com/engine/salary/report/entity/param/SalaryStatisticsReportDataQueryParam.java b/src/com/engine/salary/report/entity/param/SalaryStatisticsReportDataQueryParam.java new file mode 100644 index 000000000..481d6d887 --- /dev/null +++ b/src/com/engine/salary/report/entity/param/SalaryStatisticsReportDataQueryParam.java @@ -0,0 +1,115 @@ +package com.engine.salary.report.entity.param; + +import com.engine.salary.common.BaseQueryParam; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.*; + +import java.util.Date; +import java.util.List; + +/** + * 薪酬统计报表数据查询参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@ToString +//"薪酬统计报表数据查询参数 +public class SalaryStatisticsReportDataQueryParam extends BaseQueryParam { + //报表id + private Long id; + + //统计维度 + private Long dimensionId; + + @JsonIgnore + //薪资所属月-开始月 + private String salaryStartMonth; + + @JsonIgnore + // 薪资所属月-终止月 + private String salaryEndMonth; + + @JsonIgnore + //个税扣缴义务人配置 + private List taxAgent; + + //薪资账套配置 + @JsonIgnore + private List salarySob; + + @JsonIgnore + //收入所得项目配置 + private List incomeCategory; + + @JsonIgnore + //分部配置 + private List subCompany; + + @JsonIgnore + //部门配置 + private List depart; + + @JsonIgnore + //职级配置 + private List grade; + + @JsonIgnore + // 岗位配置 + private List position; + + @JsonIgnore + //人员状态配置 + private List status; + + @JsonIgnore + //人员 + private List employee; + + @JsonIgnore + // 入职日期 + private List hiredate; + + @JsonIgnore + // 离职日期 + private List leavedate; + + //统计单位 + private Integer unitType; + + // 是否是分享报表 + private boolean isShare; + + // "分享批次id + private Long batchId; + + @Override + public String toString() { + return "SalaryStatisticsReportDataQueryParam{" + + "id=" + id + + ", dimensionId=" + dimensionId + + ", salaryStartMonth='" + salaryStartMonth + '\'' + + ", salaryEndMonth='" + salaryEndMonth + '\'' + + ", taxAgent=" + taxAgent + + ", salarySob=" + salarySob + + ", incomeCategory=" + incomeCategory + + ", subCompany=" + subCompany + + ", depart=" + depart + + ", grade=" + grade + + ", position=" + position + + ", status=" + status + + ", employee=" + employee + + ", hiredate=" + hiredate + + ", leavedate=" + leavedate + + ", unitType=" + unitType + + ", isShare=" + isShare + + ", batchId=" + batchId + + '}'; + } +} diff --git a/src/com/engine/salary/report/entity/param/SalaryStatisticsReportQueryParam.java b/src/com/engine/salary/report/entity/param/SalaryStatisticsReportQueryParam.java new file mode 100644 index 000000000..dc9a61bb8 --- /dev/null +++ b/src/com/engine/salary/report/entity/param/SalaryStatisticsReportQueryParam.java @@ -0,0 +1,26 @@ +package com.engine.salary.report.entity.param; + +import com.engine.salary.common.BaseQueryParam; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 薪资统计报表查询参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//"薪资统计报表查询参数 +public class SalaryStatisticsReportQueryParam extends BaseQueryParam { + + //报表名称 + private String reportName; +} diff --git a/src/com/engine/salary/report/entity/param/SalaryStatisticsReportSaveParam.java b/src/com/engine/salary/report/entity/param/SalaryStatisticsReportSaveParam.java new file mode 100644 index 000000000..78f582a46 --- /dev/null +++ b/src/com/engine/salary/report/entity/param/SalaryStatisticsReportSaveParam.java @@ -0,0 +1,48 @@ +package com.engine.salary.report.entity.param; + +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.util.SalaryI18nUtil; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; + +import java.util.List; + +/** + * 薪酬统计报表保存参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//"薪酬统计报表保存参数") +public class SalaryStatisticsReportSaveParam { + + //薪酬统计报表主键id") + private Long id; + + // 薪酬统计报表名称") + private String reportName; + + // 统计维度id") + private List dimensionIds; + + + public static void checkParam(SalaryStatisticsReportSaveParam saveParam) { + if (StringUtils.isEmpty(saveParam.getReportName())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel( 161842, "统计报表名称必填")); + } + saveParam.setReportName(saveParam.getReportName().trim()); + if (CollectionUtils.isEmpty(saveParam.getDimensionIds())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel( 161843, "统计维度必传")); + } + } +} diff --git a/src/com/engine/salary/report/entity/param/SalaryStatisticsSearchConditionSaveParam.java b/src/com/engine/salary/report/entity/param/SalaryStatisticsSearchConditionSaveParam.java new file mode 100644 index 000000000..3884fcf8f --- /dev/null +++ b/src/com/engine/salary/report/entity/param/SalaryStatisticsSearchConditionSaveParam.java @@ -0,0 +1,87 @@ +package com.engine.salary.report.entity.param; + +import com.engine.salary.report.entity.po.SalaryStatisticsItemPO; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.time.LocalDate; +import java.util.Date; +import java.util.List; +import java.util.Map; + +/** + * 薪资报表统计条件保存参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class SalaryStatisticsSearchConditionSaveParam { + //报表id + private Long id; + + //统计维度 + private Long dimension; + + /** + * 1、上月 + * 2、本月 + * 3、一季度 + * 4、二季度 + * 5、三季度 + * 6、四季度 + * 7、上半年 + * 8、下半年 + * 9、本年 + * 10、自定义 + */ + //事件类型 + private Integer timeType; + + //薪资所属月-开始月 + private Date salaryStartMonth; + + //薪资所属月-终止月 + private Date salaryEndMonth; + + //个税扣缴义务人配置 + private List> taxAgent; + + //薪资账套配置 + private List> salarySob; + + //收入所得项目配置 + private List> incomeCategory; + + //分部配置 + private List> subCompany; + + //部门配置 + private List> department; + + //职级配置 + private List> grade; + + //岗位配置 + private List> position; + + //人员状态配置 + private List> status; + + //人员 + private List> employee; + + //入职日期 + private List hiredate; + + //离职日期 + private List leavedate; + + //统计项列表 + private List items; +} diff --git a/src/com/engine/salary/report/entity/param/SubTableDataQueryParam.java b/src/com/engine/salary/report/entity/param/SubTableDataQueryParam.java new file mode 100644 index 000000000..2ff0c8bb8 --- /dev/null +++ b/src/com/engine/salary/report/entity/param/SubTableDataQueryParam.java @@ -0,0 +1,66 @@ +package com.engine.salary.report.entity.param; + +import com.engine.salary.common.BaseQueryParam; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + + +@Data +@NoArgsConstructor +@AllArgsConstructor +//"报表数据查询入参") +public class SubTableDataQueryParam extends BaseQueryParam { + //报表id") + private Long id; + + //个税扣缴义务人配置") + private List payOrg; + + //缴纳组织配置") + private List payAgency; + + // 分部配置") + private List subCompany; + + // 部门配置") + private List depart; + + //职级配置") + private List grade; + + //岗位配置") + private List position; + + //人员状态配置") + private List status; + + //人员类型配置") + private Integer employeeType; + + //开始月") + private String startMonth; + + //人员") + private List employee; + + // 缴纳类型") + private List paymentType; + + //终止月") + private String endMonth; + + //统计单位") + private Integer unitType; + + //统计维度") + private String dimension; + + //统计维度名称") + private String dimensionName; + + //是否导出人员维度数据") + private Boolean empExport; +} diff --git a/src/com/engine/salary/report/entity/param/SubTableItemParam.java b/src/com/engine/salary/report/entity/param/SubTableItemParam.java new file mode 100644 index 000000000..8bb433931 --- /dev/null +++ b/src/com/engine/salary/report/entity/param/SubTableItemParam.java @@ -0,0 +1,33 @@ +package com.engine.salary.report.entity.param; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +//"报表查询入参") +public class SubTableItemParam { + + //福利项id") + private Long id; + + //报表id") + private Long tableId; + + // 统计项目") + private String itemValue; + + //统计项名称") + private String itemName; + + // 求和规则") + private String totalRule; + + // 计数规则") + private String countRule; + + // 统计单位") + private Integer unitType; +} diff --git a/src/com/engine/salary/report/entity/param/SubTableParam.java b/src/com/engine/salary/report/entity/param/SubTableParam.java new file mode 100644 index 000000000..996d3aeea --- /dev/null +++ b/src/com/engine/salary/report/entity/param/SubTableParam.java @@ -0,0 +1,25 @@ +package com.engine.salary.report.entity.param; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +//"报表查询入参") +public class SubTableParam { + // 报表id") + private Long id; + + //统计维度") + private String dimension; + + //报表名称") + private String subTableName; + + // 报表类型") + private Integer tableType; + + +} diff --git a/src/com/engine/salary/report/entity/param/SubTableSearchConditionParam.java b/src/com/engine/salary/report/entity/param/SubTableSearchConditionParam.java new file mode 100644 index 000000000..a4f4883fc --- /dev/null +++ b/src/com/engine/salary/report/entity/param/SubTableSearchConditionParam.java @@ -0,0 +1,59 @@ +package com.engine.salary.report.entity.param; + +import com.engine.salary.report.entity.po.SubTableItemPO; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; +import java.util.Map; + + +@Data +@NoArgsConstructor +@AllArgsConstructor +//"保存高级搜索配置") +public class SubTableSearchConditionParam { + + //报表id") + private Long id; + + //个税扣缴义务人配置") + private List> paymentOrganization; + + //缴纳组织配置") + private List> paymentAgency; + + //分部配置") + private List> subCompany; + + // 部门配置") + private List> department; + + // 职级配置") + private List> grade; + + //岗位配置") + private List> position; + + //人员状态配置") + private List> status; + + //人员类型配置") + private Integer type; + + //开始月") + private String startMonth; + + //终止月") + private String endMonth; + + //人员") + private List> employee; + + //缴纳类型") + private List> paymentType; + + //统计项列表") + private List items; +} diff --git a/src/com/engine/salary/report/entity/param/TaxAgentQueryParam.java b/src/com/engine/salary/report/entity/param/TaxAgentQueryParam.java new file mode 100644 index 000000000..3c75632a5 --- /dev/null +++ b/src/com/engine/salary/report/entity/param/TaxAgentQueryParam.java @@ -0,0 +1,30 @@ +package com.engine.salary.report.entity.param; + +import com.engine.salary.common.BaseQueryParam; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; + +/** + * 个税扣缴义务人查询参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//"个税扣缴义务人查询参数") +public class TaxAgentQueryParam extends BaseQueryParam { + + private Collection ids; + + //个税扣缴义务人名称") + private String name; +} diff --git a/src/com/engine/salary/report/entity/po/SalaryStatisticsDimensionPO.java b/src/com/engine/salary/report/entity/po/SalaryStatisticsDimensionPO.java new file mode 100644 index 000000000..16d7b5136 --- /dev/null +++ b/src/com/engine/salary/report/entity/po/SalaryStatisticsDimensionPO.java @@ -0,0 +1,95 @@ +package com.engine.salary.report.entity.po; + +import com.engine.salary.report.enums.SalaryStatisticsDimensionTypeEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.Collection; +import java.util.Date; + +/** + * 薪酬统计维度表 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//hrsa_salary_stats_dim") +public class SalaryStatisticsDimensionPO implements Serializable { + + private static final long serialVersionUID = 5180094786861638413L; + /** + * 主键id + */ + private Long id; + + /** + * 名称 + */ + private String dimName; + + /** + * 统计维度类型 + * @see SalaryStatisticsDimensionTypeEnum + */ + private String dimType; + + /** + * 备注 + */ + private String remark; + + /** + * 设置内容 + */ + private String setting; + + /** + * 是否默认:1代表默认 + */ + private Integer isDefault; + + /** + * 统计维度编码 + */ + private String dimCode; + + /** + * 租户key + */ + private String tenantKey; + + /** + * 创建人id + */ + private Long creator; + + private Long labelId; + + /** + * 是否删除 + */ + private Integer deleteType; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 更新时间 + */ + private Date updateTime; + + + private Collection ids; + private String dimNameLike; +} diff --git a/src/com/engine/salary/report/entity/po/SalaryStatisticsEChartsSettingPO.java b/src/com/engine/salary/report/entity/po/SalaryStatisticsEChartsSettingPO.java new file mode 100644 index 000000000..9a39e2771 --- /dev/null +++ b/src/com/engine/salary/report/entity/po/SalaryStatisticsEChartsSettingPO.java @@ -0,0 +1,83 @@ +package com.engine.salary.report.entity.po; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.Date; + +/** + * 薪酬统计图表 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//hrsa_salary_echarts_setting// +public class SalaryStatisticsEChartsSettingPO { + + //分析图配置表id + private Long id; + + //报表id + private Long reportId; + + //报表类型 + private Integer chartsType; + + //统计项目 + private String itemValues; + + //统计列 + private String itemColValue; + + //维度统计范围 + private Integer dimensionRange; + + //排序统计项目 + private String itemSortValue; + + //排序列 + private String itemColSortValue; + + //排序类型 + private Integer sortType; + + //排序取数值 + private Integer sortNum; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 更新时间 + */ + private Date updateTime; + + /** + * 创建人 + */ + private Long creator; + + /** + * 是否已删除。0:未删除、1:已删除 + */ + private Integer deleteType; + + /** + * 租户ID + */ + private String tenantKey; + + + private Collection ids; +} diff --git a/src/com/engine/salary/report/entity/po/SalaryStatisticsItemPO.java b/src/com/engine/salary/report/entity/po/SalaryStatisticsItemPO.java new file mode 100644 index 000000000..5c1b3bb52 --- /dev/null +++ b/src/com/engine/salary/report/entity/po/SalaryStatisticsItemPO.java @@ -0,0 +1,209 @@ +package com.engine.salary.report.entity.po; + +import com.engine.hrmelog.annotation.ElogTransform; +import com.engine.salary.report.enums.UnitTypeEnum; +import lombok.*; + +import java.io.Serializable; +import java.util.Collection; +import java.util.Date; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@ToString +//hrsa_salary_statistics_item +//薪酬报表统计子表自定义统计项 +@ElogTransform(name = "统计项目") +public class SalaryStatisticsItemPO implements Serializable { + + private static final long serialVersionUID = 5335849418826222822L; + + //主键id + @ElogTransform(name = "主键id") + private Long id; + + //统计报表id + @ElogTransform(name = "报表id") + private Long statReportId; + + //统计项名称 + @ElogTransform(name = "统计项名称") + private String itemName; + + //统计项集合 + @ElogTransform(name = "统计项集合") + private String itemValue; + + /** + * { + * "totalValue":"1", 是否有合计列 + * "ratioValue":"1",是否有占比列 + * "m2mValue":"1",是否有环比列 + * "y2yValue":"1",是否有同比列 + * "m2mUpperLimit:",合计环比上限 + * "m2mLowerLimit",合计环比下限 + * "y2yUpperLimit:",合计同比上限 + * "y2yLowerLimit",合计同比下限 + * } + * jsonToString + */ + //计数规则 + @ElogTransform(name = "计数规则") + private String countRule; + + /** + * { + * "totalValue":"1", 是否有合计列 + * "ratioValue":"1",是否有占比列 + * "m2mValue":"1",是否有环比列 + * "y2yValue":"1",是否有同比列 + * "m2mUpperLimit:",合计环比上限 + * "m2mLowerLimit",合计环比下限 + * "y2yUpperLimit:",合计同比上限 + * "y2yLowerLimit",合计同比下限 + * } + * jsonToString + */ + //求和规则 + @ElogTransform(name = "求和规则") + private String sumRule; + + /** + * { + * "totalValue":"1", 是否有合计列 + * "ratioValue":"1",是否有占比列 + * "m2mValue":"1",是否有环比列 + * "y2yValue":"1",是否有同比列 + * "m2mUpperLimit:",合计环比上限 + * "m2mLowerLimit",合计环比下限 + * "y2yUpperLimit:",合计同比上限 + * "y2yLowerLimit",合计同比下限 + * } + * jsonToString + */ + //平均值规则 + @ElogTransform(name = "平均值规则") + private String avgRule; + + /** + * { + * "totalValue":"1", 是否有合计列 + * "ratioValue":"1",是否有占比列 + * "m2mValue":"1",是否有环比列 + * "y2yValue":"1",是否有同比列 + * "m2mUpperLimit:",合计环比上限 + * "m2mLowerLimit",合计环比下限 + * "y2yUpperLimit:",合计同比上限 + * "y2yLowerLimit",合计同比下限 + * } + * jsonToString + */ + //最大值规则 + @ElogTransform(name = "最大值规则") + private String maxRule; + + /** + * { + * "totalValue":"1", 是否有合计列 + * "ratioValue":"1",是否有占比列 + * "m2mValue":"1",是否有环比列 + * "y2yValue":"1",是否有同比列 + * "m2mUpperLimit:",合计环比上限 + * "m2mLowerLimit",合计环比下限 + * "y2yUpperLimit:",合计同比上限 + * "y2yLowerLimit",合计同比下限 + * } + * jsonToString + */ + //最小值规则 + @ElogTransform(name = "最小值规则") + private String minRule; + + /** + * { + * "totalValue":"1", 是否有合计列 + * "ratioValue":"1",是否有占比列 + * "m2mValue":"1",是否有环比列 + * "y2yValue":"1",是否有同比列 + * "m2mUpperLimit:",合计环比上限 + * "m2mLowerLimit",合计环比下限 + * "y2yUpperLimit:",合计同比上限 + * "y2yLowerLimit",合计同比下限 + * } + * jsonToString + */ + //中位数规则 + @ElogTransform(name = "中位数规则") + private String medianRule; + + + /** + * 最近值 + *

+ * "totalValue":"1", 是否使用 + */ + @ElogTransform(name = "最近值是否使用") + private String lastRule; + + /** + * 最早值 + *

+ * { + * "totalValue":"1", 是否使用 + * } + */ + @ElogTransform(name = "最早值是否使用") + private String oldRule; + + /** + * 出现最多 + *

+ * { + * "totalValue":"1", 是否使用 + * } + */ + @ElogTransform(name = "出现最多是否使用") + private String frequentRule; + + /** + * 平铺 + *

+ * { + * "totalValue":"1", 是否使用 + * } + */ + @ElogTransform(name = "平铺是否使用") + private String tileRule; + + //顺序 + @ElogTransform(name = "顺序") + private Integer indexValue; + + /** + * 统计单位 + * + * @see UnitTypeEnum + */ + //统计单位 + @ElogTransform(name = "统计单位") + private Integer unitType; + + //创建时间 + private Date createTime; + + //更新时间 + private Date updateTime; + + //创建人 + private Long creator; + + //是否删除 + private Integer deleteType; + + //租户key + private String tenantKey; + + private Collection ids; +} diff --git a/src/com/engine/salary/report/entity/po/SalaryStatisticsPushDetailPO.java b/src/com/engine/salary/report/entity/po/SalaryStatisticsPushDetailPO.java new file mode 100644 index 000000000..a6c288da2 --- /dev/null +++ b/src/com/engine/salary/report/entity/po/SalaryStatisticsPushDetailPO.java @@ -0,0 +1,68 @@ +package com.engine.salary.report.entity.po; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.Date; +import java.util.List; + +/** + * @Description: + * @Author: zhangheng + * @CreateDate: 2023/5/17 + * @Version: v1.0 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//@TableName(value = "hrsa_report_push_detail", autoResultMap = true) +public class SalaryStatisticsPushDetailPO implements Serializable { + + // 主键id + private Long id; + + // 批次id + private Long batchId; + + // 消息id + private Long msgId; + + // 员工id + private Long employeeId; + + // 分享时间 + private String pushTime; + + // 分享状态 + private String pushStatus; + + // 撤回时间 + private String rebackTime; + + // 撤回状态 + private String rebackStatus; + + // 被分享人查看情况 + private String viewStatus; + + // 租户key + private String tenantKey; + + // 创建人id + private Long creator; + + // 是否删除 + private Integer deleteType; + + // 创建时间 + private Date createTime; + + // 更新时间 + private Date updateTime; + + private List ids; +} diff --git a/src/com/engine/salary/report/entity/po/SalaryStatisticsPushPO.java b/src/com/engine/salary/report/entity/po/SalaryStatisticsPushPO.java new file mode 100644 index 000000000..17cd860aa --- /dev/null +++ b/src/com/engine/salary/report/entity/po/SalaryStatisticsPushPO.java @@ -0,0 +1,71 @@ +package com.engine.salary.report.entity.po; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.Date; +import java.util.List; + +/** + * @Description: + * @Author: zhangheng + * @CreateDate: 2023/5/17 + * @Version: v1.0 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//@TableName(value = "hrsa_report_push", autoResultMap = true) +public class SalaryStatisticsPushPO implements Serializable { + + // 主键id + private Long id; + + // 报表id + private String reportIds; + + // 消息标题 + private String pushTitle; + + // 有效开始时间 + private String startTime; + + // 有效结束时间 + private String endTime; + + // 分享渠道 + private String pushChannel; + + // 邮件账号id + private Long emailAccountId; + + // 邮件账号 + private String emailAccount; + + // 分享说明 + private String mark; + + // 已查看提醒 + private Integer remind; + + // 租户key + private String tenantKey; + + // 创建人id + private Long creator; + + // 是否删除 + private Integer deleteType; + + // 创建时间 + private Date createTime; + + // 更新时间 + private Date updateTime; + + private List ids; +} diff --git a/src/com/engine/salary/report/entity/po/SalaryStatisticsReportPO.java b/src/com/engine/salary/report/entity/po/SalaryStatisticsReportPO.java new file mode 100644 index 000000000..08061bddd --- /dev/null +++ b/src/com/engine/salary/report/entity/po/SalaryStatisticsReportPO.java @@ -0,0 +1,132 @@ +package com.engine.salary.report.entity.po; + +import com.engine.hrmelog.annotation.ElogTransform; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.Collection; +import java.util.Date; + +/** + * 薪酬统计报表 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//hrsa_salary_stats_report +@ElogTransform(name = "薪酬统计报表") +public class SalaryStatisticsReportPO implements Serializable { + + private static final long serialVersionUID = 6526480959578343197L; + + //主键id + @ElogTransform(name = "主键id") + private Long id; + + //报表名称 + @ElogTransform(name = "报表名称") + private String reportName; + + @ElogTransform(name = "备注") + private String remark; + + @ElogTransform(name = "二级维度") + private String secondDimension; + + @ElogTransform(name = "排序列") + private String sortIndex; + + @ElogTransform(name = "排序方式") + private String sortType; + + //时间类型 + @ElogTransform(name = "时间类型") + private Integer timeType; + + //统计维度 + @ElogTransform(name = "统计维度") + private String dimension; + + //薪资所属月-起始 + @ElogTransform(name = "薪资所属月-起始") + private Date salaryStartMonth; + + //薪资所属月-截止 + @ElogTransform(name = "薪资所属月-截止") + private Date salaryEndMonth; + + //个税扣缴义务人配置 + @ElogTransform(name = "个税扣缴义务人配置") + private String taxAgentSetting; + + //薪资账套配置 + private String salarySobSetting; + + //收入所得项目配置 + @ElogTransform(name = "收入所得项目配置") + private String incomeCategorySetting; + + //分部配置 + @ElogTransform(name = "分部配置") + private String subCompanySetting; + + //部门配置 + @ElogTransform(name = "部门配置") + private String departSetting; + + //职级配置 + @ElogTransform(name = "职级配置") + private String gradeSetting; + + //岗位配置 + @ElogTransform(name = "岗位配置") + private String positionSetting; + + //人员状态配置 + @ElogTransform(name = "人员状态配置") + private String statusSetting; + + //人员配置 + @ElogTransform(name = "人员配置") + private String employeeSetting; + + //入职日期配置 + @ElogTransform(name = "入职日期配置") + private String hiredateSetting; + + //离职日期配置 + @ElogTransform(name = "离职日期配置") + private String leavedateSetting; + + //租户key + @ElogTransform(name = "租户key", ignore = true) + private String tenantKey; + + //创建人id + @ElogTransform(name = "创建人id", ignore = true) + private Long creator; + + //是否删除 + @ElogTransform(name = "是否删除", ignore = true) + private Integer deleteType; + + //创建时间 + @ElogTransform(name = "创建时间", ignore = true) + private Date createTime; + + //更新时间 + @ElogTransform(name = "更新时间", ignore = true) + private Date updateTime; + + + Collection ids; +} diff --git a/src/com/engine/salary/report/entity/po/SubTableItemPO.java b/src/com/engine/salary/report/entity/po/SubTableItemPO.java new file mode 100644 index 000000000..481816049 --- /dev/null +++ b/src/com/engine/salary/report/entity/po/SubTableItemPO.java @@ -0,0 +1,74 @@ +package com.engine.salary.report.entity.po; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.time.LocalDateTime; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//"hrsa_sub_table_item") +//社保福利统计子表统计项") +public class SubTableItemPO { + + //主键id") + private Long id; + + //创建时间") + private LocalDateTime createTime; + + //更新时间") + private LocalDateTime updateTime; + + //创建人") + private Long creator; + + //是否删除") + private Integer deleteType; + + //租户key") + private String tenantKey; + + //数据表id") + private Long tableId; + + //统计项名称") + private String itemName; + + //统计项集合") + private String itemValue; + + /** + * { + * "totalValue":"",是否有合计列 + * "m2mValue":,是否有合计环比列 + * "upperLimit:",合计环比上限 + * "lowerLimit",合计环比下限 + * } + * jsonToString + */ + //合计规则") + private String totalRule; + + /** + * { + * "totalValue":"",是否有合计列 + * "m2mValue":,是否有合计环比列 + * "upperLimit:",合计环比上限 + * "lowerLimit",合计环比下限 + * } + * jsonToString + */ + //计数规则") + private String countRule; + + //顺序") + private Integer indexValue; + + //统计单位") + private Integer unitType; +} diff --git a/src/com/engine/salary/report/enums/DataTypeEnum.java b/src/com/engine/salary/report/enums/DataTypeEnum.java new file mode 100644 index 000000000..f3b90c113 --- /dev/null +++ b/src/com/engine/salary/report/enums/DataTypeEnum.java @@ -0,0 +1,25 @@ +package com.engine.salary.report.enums; + +public enum DataTypeEnum { + + CUSTOM(0, "自定义"), + + SYSTEM(1, "系统"); + + private Integer value; + + private String desc; + + DataTypeEnum(Integer value, String desc) { + this.value = value; + this.desc = desc; + } + + public Integer getValue() { + return value; + } + + public String getDesc() { + return desc; + } +} diff --git a/src/com/engine/salary/report/enums/DimensionEnum.java b/src/com/engine/salary/report/enums/DimensionEnum.java new file mode 100644 index 000000000..ff09c474e --- /dev/null +++ b/src/com/engine/salary/report/enums/DimensionEnum.java @@ -0,0 +1,44 @@ +package com.engine.salary.report.enums; + +import com.engine.salary.enums.BaseEnum; + +public enum DimensionEnum implements BaseEnum { + BILL_MONTH("billMonth", 92146, "账单月份"), + PAYMENT_ORGANIZATION("paymentOrganization", 86184, "个税扣缴义务人"), + PAYMENT_AGENCY("paymentAgency", 93270, "缴纳组织"), + SUB_COMPANY("subCompany", 107369, "分部"), + DEPARTMENT("department", 86185, "部门"), + POSITION("position", 90633, "岗位"), + GRADE("grade", 98623, "职级"), + STATUS("status", 109332, "人事状态"), + TYPE("type", 151914, "人员类型"), + EMPLOYEE("employee", 100133, "人员"), + YEAR("year", 157163, "年度"), + QUARTER("quarter", 157162, "季度"); + + private String value; + private Integer labelId; + private String defaultValue; + + DimensionEnum(String value, Integer labelId, String defaultValue) { + this.value = value; + this.labelId = labelId; + this.defaultValue = defaultValue; + } + + + @Override + public Object getValue() { + return value; + } + + @Override + public Integer getLabelId() { + return labelId; + } + + @Override + public String getDefaultLabel() { + return defaultValue; + } +} diff --git a/src/com/engine/salary/report/enums/EmployeeTypeEnum.java b/src/com/engine/salary/report/enums/EmployeeTypeEnum.java new file mode 100644 index 000000000..4c5d0cb1b --- /dev/null +++ b/src/com/engine/salary/report/enums/EmployeeTypeEnum.java @@ -0,0 +1,52 @@ +package com.engine.salary.report.enums; + +import com.engine.salary.enums.BaseEnum; + +import java.util.Objects; + +/** + * 人员类型 + */ +public enum EmployeeTypeEnum implements BaseEnum { + + ORGANIZATION(0, "组织架构", 109125), + EXT_EMPLOYEE(1, "非系统人员", 119127), + NOT_MATCH(2, "无匹配人员类型", 0), + ; + + private final int value; + + private final String defaultLabel; + + private final int labelId; + + EmployeeTypeEnum(int value, String defaultLabel, int labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + @Override + public Integer getValue() { + return value; + } + + @Override + public Integer getLabelId() { + return labelId; + } + + @Override + public String getDefaultLabel() { + return defaultLabel; + } + + public static EmployeeTypeEnum parseByValue(Integer value) { + for (EmployeeTypeEnum typeEnum : EmployeeTypeEnum.values()) { + if (Objects.equals(typeEnum.getValue(), value)) { + return typeEnum; + } + } + return null; + } +} diff --git a/src/com/engine/salary/report/enums/ExtEmployeeTypeEnum.java b/src/com/engine/salary/report/enums/ExtEmployeeTypeEnum.java new file mode 100644 index 000000000..f19091be2 --- /dev/null +++ b/src/com/engine/salary/report/enums/ExtEmployeeTypeEnum.java @@ -0,0 +1,18 @@ +package com.engine.salary.report.enums; + +public enum ExtEmployeeTypeEnum { + NO(1, "不是挂靠人员"), + YES(2, "是挂靠人员"); + + private Integer value; + private String commit; + + ExtEmployeeTypeEnum(Integer value, String commit) { + this.value = value; + this.commit = commit; + } + + public Integer getValue() { + return value; + } +} diff --git a/src/com/engine/salary/report/enums/IncomeCategoryEnum.java b/src/com/engine/salary/report/enums/IncomeCategoryEnum.java new file mode 100644 index 000000000..8e47229eb --- /dev/null +++ b/src/com/engine/salary/report/enums/IncomeCategoryEnum.java @@ -0,0 +1,88 @@ +package com.engine.salary.report.enums; + +import com.engine.salary.enums.BaseEnum; +import com.google.common.collect.Lists; +import org.apache.commons.collections4.CollectionUtils; + +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Objects; + + +/** + * 应税项目 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public enum IncomeCategoryEnum implements BaseEnum { + + WAGES_AND_SALARIES(1, "正常工资薪金", 160487), + REMUNERATION_FOR_LABOR(4, "一般劳务报酬所得", 160488), + ONETIME_ANNUAL_BONUS(2,"全年一次性奖金收入", 160489), + COMPENSATION_FOR_RETIRE(107,"内退一次性补偿金",0), + COMPENSATION_FOR_DISMISS(108,"解除劳动合同一次性补偿金", 0), + INCOME_FOR_INDIVIDUAL_EQUITY_INCENTIVE(109,"个人股权激励收入",0), + ANNUITY_RECEIPT(110,"年金领取",0), + INCOME_FOR_INSURANCE_SALESMAN(402,"保险营销员佣金收入",0), + INCOME_FOR_SECURITIES_BROKER(403,"证券经纪人佣金收入",0), + REMUNERATION_FOR_OTHER_CONTINUOUS_LABOR(489,"其他连续劳务报酬所得",0), + REMUNERATION_FOR_OTHER_LABOR(499,"其他非连续劳务报酬所得",0), + REMUNERATION_FOR_AUTHOR(500,"稿酬所得",0), + ROYALTIES(600,"特许权使用费所得",0), + ; + + private int value; + + private String defaultLabel; + + private int labelId; + + IncomeCategoryEnum(int value, String defaultLabel, int labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + @Override + public Integer getValue() { + return value; + } + + @Override + public Integer getLabelId() { + return labelId; + } + + @Override + public String getDefaultLabel() { + return defaultLabel; + } + + public static IncomeCategoryEnum parseByValue(int value) { + for (IncomeCategoryEnum incomeCategoryEnum : IncomeCategoryEnum.values()) { + if (Objects.equals(incomeCategoryEnum.getValue(), value)) { + return incomeCategoryEnum; + } + } + return null; + } + + public static List parseByValue(Collection values) { + if (CollectionUtils.isEmpty(values)) { + return Collections.emptyList(); + } + List incomeCategoryEnums = Lists.newArrayListWithExpectedSize(values.size()); + for (Integer value : values) { + for (IncomeCategoryEnum incomeCategoryEnum : IncomeCategoryEnum.values()) { + if (Objects.equals(incomeCategoryEnum.getValue(), value)) { + incomeCategoryEnums.add(incomeCategoryEnum); + } + } + } + return incomeCategoryEnums; + } +} diff --git a/src/com/engine/salary/report/enums/OperateTypeEnum.java b/src/com/engine/salary/report/enums/OperateTypeEnum.java new file mode 100644 index 000000000..d8e14b304 --- /dev/null +++ b/src/com/engine/salary/report/enums/OperateTypeEnum.java @@ -0,0 +1,28 @@ +package com.engine.salary.report.enums; + +/** + * 操作类型 + */ +public enum OperateTypeEnum { + + ADD("1", "新增"), + UPDATE("2", "更新"), + DELETE("4", "删除"); + + private String value; + + private String label; + + OperateTypeEnum(String value, String label) { + this.value = value; + this.label = label; + } + + public String getValue() { + return value; + } + + public String getLabel() { + return label; + } +} diff --git a/src/com/engine/salary/report/enums/PaymentScopeEnum.java b/src/com/engine/salary/report/enums/PaymentScopeEnum.java new file mode 100644 index 000000000..1b86fc337 --- /dev/null +++ b/src/com/engine/salary/report/enums/PaymentScopeEnum.java @@ -0,0 +1,28 @@ +package com.engine.salary.report.enums; + +public enum PaymentScopeEnum { + SCOPE_COMPANY(1, "公司", 87158), + SCOPE_PERSON(2, "个人", 87159); + + private Integer value; + private String defaultLable; + private Integer labelId; + + PaymentScopeEnum(Integer value, String defaultLable, Integer labelId) { + this.value = value; + this.defaultLable = defaultLable; + this.labelId = labelId; + } + + public Integer getValue() { + return this.value; + } + + public Integer getLabelId() { + return this.labelId; + } + + public String getDefaultLabel() { + return this.defaultLable; + } +} diff --git a/src/com/engine/salary/report/enums/PaymentStatusEnum.java b/src/com/engine/salary/report/enums/PaymentStatusEnum.java new file mode 100644 index 000000000..75975a150 --- /dev/null +++ b/src/com/engine/salary/report/enums/PaymentStatusEnum.java @@ -0,0 +1,35 @@ +package com.engine.salary.report.enums; + + +public enum PaymentStatusEnum { + + COMMON(0, "正常缴纳", 92265), + REPAIR(1, "补缴", 92266), + PAYMENT(2, "代缴", 121755), + RECESSION(3, "退差", 134057), + BALANCE(4, "补差", 139823); + + private Integer value; + + private String defaultLable; + + private Integer labelId; + + PaymentStatusEnum(Integer value, String defaultLable, Integer labelId) { + this.value = value; + this.defaultLable = defaultLable; + this.labelId = labelId; + } + + public Integer getValue() { + return this.value; + } + + public Integer getLabelId() { + return this.labelId; + } + + public String getDefaultLabel() { + return this.defaultLable; + } +} diff --git a/src/com/engine/salary/report/enums/SalaryDataTypeEnum.java b/src/com/engine/salary/report/enums/SalaryDataTypeEnum.java new file mode 100644 index 000000000..db655d970 --- /dev/null +++ b/src/com/engine/salary/report/enums/SalaryDataTypeEnum.java @@ -0,0 +1,55 @@ +package com.engine.salary.report.enums; + +import com.engine.salary.enums.BaseEnum; + +import java.util.Objects; + +/** + * 薪资项目的字段类型 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public enum SalaryDataTypeEnum implements BaseEnum { + STRING("string", "字符", 105093), + NUMBER("number", "数值", 87625), + ; + + private String value; + + private String defaultLabel; + + private int labelId; + + SalaryDataTypeEnum(String value, String defaultLabel, int labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + @Override + public String getValue() { + return this.value; + } + + @Override + public Integer getLabelId() { + return this.labelId; + } + + @Override + public String getDefaultLabel() { + return this.defaultLabel; + } + + public static SalaryDataTypeEnum parseByValue(String value) { + for (SalaryDataTypeEnum salaryDataTypeEnum : SalaryDataTypeEnum.values()) { + if (Objects.equals(salaryDataTypeEnum.getValue(), value)) { + return salaryDataTypeEnum; + } + } + return null; + } +} diff --git a/src/com/engine/salary/report/enums/SalaryStatisticsDimensionTypeEnum.java b/src/com/engine/salary/report/enums/SalaryStatisticsDimensionTypeEnum.java new file mode 100644 index 000000000..93a6a0aba --- /dev/null +++ b/src/com/engine/salary/report/enums/SalaryStatisticsDimensionTypeEnum.java @@ -0,0 +1,50 @@ +package com.engine.salary.report.enums; + +import com.engine.salary.enums.BaseEnum; +import com.engine.salary.util.SalaryI18nUtil; + +import java.util.Arrays; +import java.util.Optional; + +/** + * 薪酬统计维度类型 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public enum SalaryStatisticsDimensionTypeEnum implements BaseEnum { + QUALITATIVE("QUALITATIVE", "定性", 161086), + RATION_GROUP_SPACING("RATION_GROUP_SPACING", "定量-组距式分组", 161087), + RATION_GROUP_INDIVIDUAL("RATION_GROUP_INDIVIDUAL", "定量-单项式分组", 161088); + + private String value; + + private String defaultLabel; + + private int labelId; + + SalaryStatisticsDimensionTypeEnum(String value, String defaultLabel, int labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + public String getValue() { + return value; + } + + public String getDefaultLabel() { + return defaultLabel; + } + + public Integer getLabelId() { + return labelId; + } + + public static String getDefaultLabelByValue(String value) { + Optional optionalDimensionType = Arrays.stream(SalaryStatisticsDimensionTypeEnum.values()).filter(r -> r.getValue().equals(value)).findFirst(); + return optionalDimensionType.isPresent() ? SalaryI18nUtil.getI18nLabel( optionalDimensionType.get().getLabelId(), optionalDimensionType.get().getDefaultLabel()) : ""; + } +} diff --git a/src/com/engine/salary/report/enums/SalaryStatisticsItemStringRuleEnum.java b/src/com/engine/salary/report/enums/SalaryStatisticsItemStringRuleEnum.java new file mode 100644 index 000000000..3ca0bdcff --- /dev/null +++ b/src/com/engine/salary/report/enums/SalaryStatisticsItemStringRuleEnum.java @@ -0,0 +1,52 @@ +package com.engine.salary.report.enums; + +import com.engine.salary.enums.BaseEnum; + +import java.util.Objects; + +public enum SalaryStatisticsItemStringRuleEnum implements BaseEnum { + + + LAST("last", "最近值", 83993), + OLD("old", "最早值", 83994), + FREQUENT("frequent", "最频繁", 83994), + TILE("tile", "平铺", 83994), + ; + + private String value; + + private String defaultLabel; + + private int labelId; + + SalaryStatisticsItemStringRuleEnum(String value, String defaultLabel, int labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + @Override + public String getValue() { + return value; + } + + @Override + public String getDefaultLabel() { + return defaultLabel; + } + + @Override + public Integer getLabelId() { + return labelId; + } + + public static SalaryStatisticsItemStringRuleEnum parseByValue(String value) { + for (SalaryStatisticsItemStringRuleEnum typeEnum : SalaryStatisticsItemStringRuleEnum.values()) { + if (Objects.equals(typeEnum.getValue(), value)) { + return typeEnum; + } + } + return null; + } + +} diff --git a/src/com/engine/salary/report/enums/SalarySystemTypeEnum.java b/src/com/engine/salary/report/enums/SalarySystemTypeEnum.java new file mode 100644 index 000000000..7ebb9c1a0 --- /dev/null +++ b/src/com/engine/salary/report/enums/SalarySystemTypeEnum.java @@ -0,0 +1,57 @@ +package com.engine.salary.report.enums; + + +import com.engine.salary.enums.BaseEnum; + +import java.util.Objects; + +/** + * 税率表表单类型 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public enum SalarySystemTypeEnum implements BaseEnum { + + CUSTOM(0, "自定义表单", 83993), + SYSTEM(1, "系统表单", 83994), + ; + + private int value; + + private String defaultLabel; + + private int labelId; + + SalarySystemTypeEnum(int value, String defaultLabel, int labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + @Override + public Integer getValue() { + return value; + } + + @Override + public String getDefaultLabel() { + return defaultLabel; + } + + @Override + public Integer getLabelId() { + return labelId; + } + + public static SalarySystemTypeEnum parseByValue(int value) { + for (SalarySystemTypeEnum typeEnum : SalarySystemTypeEnum.values()) { + if (Objects.equals(typeEnum.getValue(), value)) { + return typeEnum; + } + } + return null; + } +} diff --git a/src/com/engine/salary/report/enums/TableTypeEnum.java b/src/com/engine/salary/report/enums/TableTypeEnum.java new file mode 100644 index 000000000..f36dada57 --- /dev/null +++ b/src/com/engine/salary/report/enums/TableTypeEnum.java @@ -0,0 +1,18 @@ +package com.engine.salary.report.enums; + +public enum TableTypeEnum { + REPORT(0, "报表"), + OVERVIEW(1, "总览"); + + private Integer value; + private String desc; + + TableTypeEnum(Integer value, String desc) { + this.value = value; + this.desc = desc; + } + + public Integer getValue() { + return value; + } +} diff --git a/src/com/engine/salary/report/enums/TaxAgentPermissionConstant.java b/src/com/engine/salary/report/enums/TaxAgentPermissionConstant.java new file mode 100644 index 000000000..e997b63dc --- /dev/null +++ b/src/com/engine/salary/report/enums/TaxAgentPermissionConstant.java @@ -0,0 +1,22 @@ +package com.engine.salary.report.enums; + +/** + * 个税扣缴义务人分权 + */ +public class TaxAgentPermissionConstant { + + /** + * 菜单编码 + */ + public static final String MENU_CODE = "TaxAgent"; + + /** + * 权限编码-默认权限项 + */ + public static final String ITEM_CODE_DEFAULT = "TaxAgent.default"; + + /** + * 权限编码-分权开关 + */ + public static final String ITEM_CODE_DEVOLUTION = "TaxAgent.devolution"; +} diff --git a/src/com/engine/salary/report/enums/TaxAgentRoleTypeEnum.java b/src/com/engine/salary/report/enums/TaxAgentRoleTypeEnum.java new file mode 100644 index 000000000..db585ebc6 --- /dev/null +++ b/src/com/engine/salary/report/enums/TaxAgentRoleTypeEnum.java @@ -0,0 +1,34 @@ +package com.engine.salary.report.enums; + +/** + * 个税扣缴义务人角色类型 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public enum TaxAgentRoleTypeEnum { + + CHIEF(0, "总管理员"), + ADMIN(1, "管理员"), + SUBADMIN(2, "分管理员"), + NONE(3, "其他"); + + private int value; + + private String defaultLabel; + + TaxAgentRoleTypeEnum(int value, String defaultLabel) { + this.value = value; + this.defaultLabel = defaultLabel; + } + + public int getValue() { + return value; + } + + public String getDefaultLabel() { + return defaultLabel; + } +} diff --git a/src/com/engine/salary/report/enums/UnitTypeEnum.java b/src/com/engine/salary/report/enums/UnitTypeEnum.java new file mode 100644 index 000000000..35b1fc49b --- /dev/null +++ b/src/com/engine/salary/report/enums/UnitTypeEnum.java @@ -0,0 +1,45 @@ +package com.engine.salary.report.enums; + +import com.engine.salary.enums.BaseEnum; + +public enum UnitTypeEnum implements BaseEnum { + empty(0, 152745, ""), + REN(1, 157087, "人"), + YUAN(2, 152739, "元"), + QIAN(3, 157088, "千"), + WAN(5, 152745, "万"), + BAIWAN(4, 152745, "百万"), + day(6, 152745, "天"), + month(7, 152745, "月"), + year(8, 152745, "年"), + second(9, 152745, "秒"), + minute(10, 152745, "分钟"), + hour(11, 152745, "小时"); + + + private Integer value; + + private Integer labelId; + + private String defaultValue; + + UnitTypeEnum(Integer item, Integer labelId, String defaultValue) { + this.value = item; + this.labelId = labelId; + this.defaultValue = defaultValue; + } + + @Override + public Integer getValue() { + return value; + } + + public Integer getLabelId() { + return labelId; + } + + @Override + public String getDefaultLabel() { + return defaultValue; + } +} diff --git a/src/com/engine/salary/report/enums/WeaBrowserTypeEnum.java b/src/com/engine/salary/report/enums/WeaBrowserTypeEnum.java new file mode 100644 index 000000000..03aa61ae5 --- /dev/null +++ b/src/com/engine/salary/report/enums/WeaBrowserTypeEnum.java @@ -0,0 +1,37 @@ +package com.engine.salary.report.enums; + +public enum WeaBrowserTypeEnum { + + PAYMENT_ORGANIZATION("paymentOrganizationFieldBrowser", "个税扣缴义务人"), + PAYMENT_AGENCY("paymentAgencyFieldBrowser", "缴纳组织"), + SUB_COMPANY("subcompanyFieldBrowser", "分部"), + DEPARTMENT("departmentFieldBrowser", "部门"), + GRADE("gradeFieldBrowser", "职级"), + POSITION("positionFieldBrowser", "岗位"), + STATUS("statusFieldBrowser", "人事状态"), + + EMPLOYEE("employeeFieldBrowser", "人员"), + ITEM("subTableItemFieldBrowser", "统计项目"), + + TAX_AGENT("TaxAgentBrowser", "个税扣缴义务人"), + USER_STATUS("UserStatusBrowser", "人事状态"), + INCOME_CATEGORY("IncomeCategoryBrowser", "收入所得项目"), + SALARY_ITEM("salaryItemBrowser", "薪资项目"); + + WeaBrowserTypeEnum(String type, String desc) { + this.browserType = type; + this.desc = desc; + } + + private final String browserType; + private final String desc; + + + public String getBrowserType() { + return browserType; + } + + public String getDesc() { + return desc; + } +} diff --git a/src/com/engine/salary/report/service/SalaryStatisticsDimensionService.java b/src/com/engine/salary/report/service/SalaryStatisticsDimensionService.java new file mode 100644 index 000000000..e3a657209 --- /dev/null +++ b/src/com/engine/salary/report/service/SalaryStatisticsDimensionService.java @@ -0,0 +1,91 @@ +package com.engine.salary.report.service; + +import com.engine.salary.entity.hrm.dto.EmployeeInfoExpandDTO; +import com.engine.salary.report.entity.param.SalaryStatisticsDimensionQueryParam; +import com.engine.salary.report.entity.param.SalaryStatisticsDimensionSaveParam; +import com.engine.salary.report.entity.po.SalaryStatisticsDimensionPO; +import com.engine.salary.util.page.PageInfo; + +import java.util.Collection; +import java.util.List; +import java.util.Map; + + +/** + * 薪酬统计维度 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public interface SalaryStatisticsDimensionService { + + /** + * 初始化 + * + * @param currentEmployeeId + */ + void init(Long currentEmployeeId); + + /** + * 获取单个薪酬统计维度 + * + * @param id + * @return + */ + SalaryStatisticsDimensionPO getById(Long id); + + /** + * 获取租户下的所有统计维度 + * + * @return + */ + List listAll(); + + /** + * 获取薪酬统计维度分页列表 + * + * @param queryParam + * @return + */ + PageInfo listPage(SalaryStatisticsDimensionQueryParam queryParam); + + /** + * 保存薪酬统计维度 + * + * @param saveParam + * @return + */ + String save(SalaryStatisticsDimensionSaveParam saveParam); + + /** + * 保存字段扩展 + * @param saveParam + * @return + */ + void saveExpandFieldSettings(EmployeeInfoExpandDTO saveParam); + + /** + * 查询薪酬统计维度扩展字段设置 + * @param module + * @return + */ + EmployeeInfoExpandDTO getExpandFieldSettings(String module); + + /** + * 删除薪酬统计维度 + * + * @param ids + * @return + */ + Map delete(Collection ids); + + /** + * 获取默认薪酬统计维度 + * + * @return + */ + List listAllDefaultDimension(); + +} diff --git a/src/com/engine/salary/report/service/SalaryStatisticsEchartsService.java b/src/com/engine/salary/report/service/SalaryStatisticsEchartsService.java new file mode 100644 index 000000000..d819230b2 --- /dev/null +++ b/src/com/engine/salary/report/service/SalaryStatisticsEchartsService.java @@ -0,0 +1,37 @@ +package com.engine.salary.report.service; + +import com.engine.salary.report.entity.dto.SalaryStatisticsEchartsDTO; + +/** + * 薪酬统计图表 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public interface SalaryStatisticsEchartsService { + + /** + * 分析图数据展示范围设置保存 + * + * @param saveParam + * @return + */ + String saveRangeSetting(SalaryStatisticsEchartsDTO saveParam); + + /** + * 分析图数据展示范围设置删除 + * + * @param reportId + * @return + */ + String deleteRangeSetting(Long reportId); + + /** + * 分析图数据展示范围设置查询 + * + * @return + */ + SalaryStatisticsEchartsDTO queryRangeSetting(SalaryStatisticsEchartsDTO param); +} diff --git a/src/com/engine/salary/report/service/SalaryStatisticsEmployeeService.java b/src/com/engine/salary/report/service/SalaryStatisticsEmployeeService.java new file mode 100644 index 000000000..512e51d55 --- /dev/null +++ b/src/com/engine/salary/report/service/SalaryStatisticsEmployeeService.java @@ -0,0 +1,60 @@ +package com.engine.salary.report.service; + +import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO; +import com.engine.salary.report.entity.dto.SalaryStatisticsEmployeeDetailResultDTO; +import com.engine.salary.report.entity.dto.SalaryStatisticsEmployeeListDTO; +import com.engine.salary.report.entity.param.SalaryStatisticsEmployeeDetailQueryParam; +import com.engine.salary.report.entity.param.SalaryStatisticsEmployeeQueryParam; +import com.engine.salary.report.entity.param.SalaryStatisticsEmployeeSalaryQueryParam; +import com.engine.salary.util.page.PageInfo; + +import java.util.List; +import java.util.Map; + +/** + * 薪酬统计员工明细 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public interface SalaryStatisticsEmployeeService { + + /** + * 获取员工统计分页列表 + * + * @param queryParam + * @return + */ + PageInfo listPage(SalaryStatisticsEmployeeQueryParam queryParam); + + /** + * 获取员工明细结果数据 + * + * @param queryParam + * @return + */ + SalaryStatisticsEmployeeDetailResultDTO getDetailSalaryAcctResult(SalaryStatisticsEmployeeDetailQueryParam queryParam); + + /** + * 获取员工核算详情数据分页列表 + * + * @param salaryStatisticsEmployeeDetailResult + * @param queryParam + * @return + */ + List> listDetailPage(SalaryStatisticsEmployeeDetailResultDTO salaryStatisticsEmployeeDetailResult, SalaryStatisticsEmployeeDetailQueryParam queryParam); + + PageInfo listSalaryAcctEmp(SalaryStatisticsEmployeeSalaryQueryParam queryParam); + + SalaryStatisticsEmployeeDetailResultDTO getDetailSalaryAcctResultByAcctEmp(List salaryAcctEmployeeList); + + /** + * 导出员工详情列表 + * + * @param map + * @param queryParam + */ +// void exportDetailList(Map map, SalaryStatisticsEmployeeDetailQueryParam queryParam); +} diff --git a/src/com/engine/salary/report/service/SalaryStatisticsItemService.java b/src/com/engine/salary/report/service/SalaryStatisticsItemService.java new file mode 100644 index 000000000..52ab29e3f --- /dev/null +++ b/src/com/engine/salary/report/service/SalaryStatisticsItemService.java @@ -0,0 +1,62 @@ +package com.engine.salary.report.service; + +import com.engine.salary.report.entity.param.SalaryStatisticsItemSaveParam; +import com.engine.salary.report.entity.po.SalaryStatisticsItemPO; + +import java.util.Collection; +import java.util.List; + +/** + * 薪酬报表自定义统计项目 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public interface SalaryStatisticsItemService { + + /** + * 获取单个自定义统计项目 + * + * @param id + * @return + */ + SalaryStatisticsItemPO getById(Long id); + + /** + * 根据薪资报表id获取自定义统计项目 + * + * @param statisticsReportId + * @return + */ + List listByStatisticsReportId(Long statisticsReportId); + + /** + * 删除自定义统计项目 + * + * @param ids + * @return + */ + String delete(Collection ids); + + /** + * 保存自定义统计项目 + * + * @param param + * @return + */ + String save(SalaryStatisticsItemSaveParam param); + + /** + * 保存或更新 + * @param salaryStatisticsItemList + */ + void saveOrUpdateBatch(List salaryStatisticsItemList); + + /** + * 根据报表id删除 + * @param reportIds + */ + void deleteByReportIds(List reportIds); +} diff --git a/src/com/engine/salary/report/service/SalaryStatisticsPushDetailService.java b/src/com/engine/salary/report/service/SalaryStatisticsPushDetailService.java new file mode 100644 index 000000000..f9a39c44b --- /dev/null +++ b/src/com/engine/salary/report/service/SalaryStatisticsPushDetailService.java @@ -0,0 +1,85 @@ +package com.engine.salary.report.service; + +import com.engine.salary.report.entity.po.SalaryStatisticsPushDetailPO; + +import java.util.List; + +/** + * @author Harryxzy + * @ClassName SalaryStatisticsPushDetailService + * @date 2023/09/13 15:10 + * @description + */ +public interface SalaryStatisticsPushDetailService { + + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + List listSome(SalaryStatisticsPushDetailPO po); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + SalaryStatisticsPushDetailPO getById(Long id); + + + /** + * 新增,忽略null字段 + * + * @param po 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(SalaryStatisticsPushDetailPO po); + + /** + * 修改,修改所有字段 + * + * @param po 修改的记录 + * @return 返回影响行数 + */ + int update(SalaryStatisticsPushDetailPO po); + + /** + * 修改,忽略null字段 + * + * @param po 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(SalaryStatisticsPushDetailPO po); + + /** + * 删除记录 + * + * @param po 待删除的记录 + * @return 返回影响行数 + */ + int delete(SalaryStatisticsPushDetailPO po); + + /** + * 根据批次id查询 + * @param batchIds + */ + List queryPushDetailPOByBatchIds(List batchIds); + + /** + * 根据批次id、员工id查询 + * @param + */ + List queryPushDetailPOByBatchIdAndEmpIds(Long batchId, List sharedBy); + + /** + * 根据被分享人获取分享记录列表 + * @param uid + * @return + */ + List getSuccessPushDetailListByReceiver(Long uid); + +} diff --git a/src/com/engine/salary/report/service/SalaryStatisticsPushService.java b/src/com/engine/salary/report/service/SalaryStatisticsPushService.java new file mode 100644 index 000000000..39b87a212 --- /dev/null +++ b/src/com/engine/salary/report/service/SalaryStatisticsPushService.java @@ -0,0 +1,86 @@ +package com.engine.salary.report.service; + +import com.engine.salary.common.BaseQueryParam; +import com.engine.salary.report.entity.dto.SalaryStatisticsPushDetail; +import com.engine.salary.report.entity.dto.SalaryStatisticsPushTableDTO; +import com.engine.salary.report.entity.param.SalaryStatisticsPushDetailParam; +import com.engine.salary.report.entity.param.SalaryStatisticsPushParam; +import com.engine.salary.report.entity.po.SalaryStatisticsPushPO; +import com.engine.salary.util.page.PageInfo; + +import java.util.List; +import java.util.Map; + +/** + * @author Harryxzy + * @ClassName SalaryStatisticsPushService + * @date 2023/09/11 10:15 + * @description 薪酬统计报表消息推送 + */ +public interface SalaryStatisticsPushService { + Map getPushForm(); + + /** + * 获取分享记录列表 + * @param baseQueryParam + */ + PageInfo getPushTable(BaseQueryParam baseQueryParam); + + /** + * 获取发送消息记录详情 + * @param param + * @return + */ + SalaryStatisticsPushDetail getPushDetail(SalaryStatisticsPushDetailParam param); + + /** + * 分享报表 + * @param param + */ + void push(SalaryStatisticsPushParam param); + + void addSharedPush(SalaryStatisticsPushParam param); + + // void rePush(Long id, Long employeeId, String tenantKey); + + /** + * 撤回分享 + * @param id 分享明细id + */ + void cancel(Long id); + + /** + * 撤回该批次所有分享 + * @param id 分享批次id + */ + void cancelAll(Long id); + +// SalaryStatisticsPushPO getById(Long id, String tenantKey); + +// List getPushDetailsById(Long batchId, String tenantKey); + + void updateReportViewStatus(List batchId, Long uid); + +// void sendViewedMsg(Long batchId, Long reportId, Long employeeId, String tenantKey); + + /** + * 根据用户获取有效(没有过期、撤回)的分享记录 + * @param uid + * @return + */ + List getSuccessPushListByReceiver(Long uid); + + /** + * 根据报表id、分享批次id获取有效的分享记录 + * @param reportId + * @return + */ + List getPushListByReportIdAndIds(Long reportId, List ids); + + /** + * 校验当前登录人员是否有权查看被分享的报表 + * @param reportId + * @return + */ + List shareReportValid(Long reportId, Long uid); +} diff --git a/src/com/engine/salary/report/service/SalaryStatisticsReportService.java b/src/com/engine/salary/report/service/SalaryStatisticsReportService.java new file mode 100644 index 000000000..069793ecf --- /dev/null +++ b/src/com/engine/salary/report/service/SalaryStatisticsReportService.java @@ -0,0 +1,116 @@ +package com.engine.salary.report.service; + +import com.engine.salary.report.entity.param.SalaryStatisticsDataPerspectiveQueryParam; +import com.engine.salary.report.entity.param.SalaryStatisticsReportDataQueryParam; +import com.engine.salary.report.entity.param.SalaryStatisticsReportSaveParam; +import com.engine.salary.report.entity.param.SalaryStatisticsSearchConditionSaveParam; +import com.engine.salary.report.entity.po.SalaryStatisticsDimensionPO; +import com.engine.salary.report.entity.po.SalaryStatisticsItemPO; +import com.engine.salary.report.entity.po.SalaryStatisticsReportPO; +import com.engine.salary.util.page.PageInfo; + +import java.util.Collection; +import java.util.List; +import java.util.Map; + +/** + * 薪酬报表自定义统计项目 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public interface SalaryStatisticsReportService { + + /** + * 获取所有薪酬报表 + * + * @return + */ + List listAll(); + + /** + * 获取薪酬报表列表 + * + * @return + */ + List list(); + + /** + * 根据创建人获取薪酬报表列表 + * + * @return + */ + List listByCreator(Long uid); + + /** + * 获取单个薪酬统计报表 + * + * @param id + * @return + */ + SalaryStatisticsReportPO getById(Long id); + + List getByIds(List ids); + + /** + * 保存薪酬统计报表 + * + * @param saveParam + * @return + */ + String save(SalaryStatisticsReportSaveParam saveParam ); + + /** + * 删除薪酬统计报表 + * + * @param ids + * @return + */ + Map delete(Collection ids ); + + /** + * 复制 + * @param id + */ + void duplicate(Long id); + + + /** + * 保存统计范围 + * + * @param param + * @return + */ + String saveSearchCondition(SalaryStatisticsSearchConditionSaveParam param); + + /** + * 构建报表分页统计记录 + * + * + * @param dimension + * @param param + * @param salaryStatisticsItemList + * @return + */ + PageInfo> buildReportRecords(SalaryStatisticsDimensionPO dimension, SalaryStatisticsReportDataQueryParam param, List salaryStatisticsItemList); + + /** + * 构建数据透视记录 + * + * @param param + * @param reportPO 报表po + * @param dimension 维度po + * @param salaryStatisticsItemPOS 自定义统计项目List + * @return + */ + PageInfo> buildDataPerspectiveRecords(SalaryStatisticsDataPerspectiveQueryParam param, SalaryStatisticsReportPO reportPO, SalaryStatisticsDimensionPO dimension, List salaryStatisticsItemPOS); + + + /** + * 清除报表缓存 + */ + void removeReportCache(); + +} diff --git a/src/com/engine/salary/report/service/SubTableExportService.java b/src/com/engine/salary/report/service/SubTableExportService.java new file mode 100644 index 000000000..8d084998e --- /dev/null +++ b/src/com/engine/salary/report/service/SubTableExportService.java @@ -0,0 +1,7 @@ +package com.engine.salary.report.service; + +public interface SubTableExportService { + +// Map exportCommon(ExportCommonParam param, User currentUser, String tenantKey); + +} diff --git a/src/com/engine/salary/report/service/impl/SalaryStatisticsDimensionServiceImpl.java b/src/com/engine/salary/report/service/impl/SalaryStatisticsDimensionServiceImpl.java new file mode 100644 index 000000000..d62cdd1b3 --- /dev/null +++ b/src/com/engine/salary/report/service/impl/SalaryStatisticsDimensionServiceImpl.java @@ -0,0 +1,268 @@ +package com.engine.salary.report.service.impl; + +import com.alibaba.fastjson.JSON; +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.entity.hrm.dto.EmployeeInfoExpandDTO; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.mapper.report.SalaryStatisticsDimensionMapper; +import com.engine.salary.report.common.constant.SalaryStatisticsDimensionConstant; +import com.engine.salary.report.entity.param.SalaryStatisticsDimensionQueryParam; +import com.engine.salary.report.entity.param.SalaryStatisticsDimensionSaveParam; +import com.engine.salary.report.entity.po.SalaryStatisticsDimensionPO; +import com.engine.salary.report.entity.po.SalaryStatisticsReportPO; +import com.engine.salary.report.enums.SalaryStatisticsDimensionTypeEnum; +import com.engine.salary.report.service.SalaryStatisticsDimensionService; +import com.engine.salary.report.service.SalaryStatisticsReportService; +import com.engine.salary.service.SalaryEmployeeService; +import com.engine.salary.service.impl.SalaryEmployeeServiceImpl; +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.page.SalaryPageUtil; +import com.google.common.collect.Lists; +import com.engine.salary.util.db.IdGenerator; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.math.NumberUtils; +import org.springframework.beans.BeanUtils; +import weaver.hrm.User; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * 薪酬统计维度 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SalaryStatisticsDimensionServiceImpl extends Service implements SalaryStatisticsDimensionService { + + private SalaryStatisticsDimensionMapper getSalaryStatisticsDimensionMapper() { + return MapperProxyFactory.getProxy(SalaryStatisticsDimensionMapper.class); + } + + private SalaryStatisticsReportService salaryStatisticsReportService(User user) { + return ServiceUtil.getService(SalaryStatisticsReportServiceImpl.class, user); + } + + private SalaryEmployeeService getSalaryEmployeeService(User user) { + return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user); + } + + /** + * 初始化默认维度 + */ + @Override + public void init(Long currentEmployeeId) { + List defaultList = getSalaryStatisticsDimensionMapper().listSome(SalaryStatisticsDimensionPO.builder().isDefault(NumberUtils.INTEGER_ONE).build()); + + if (CollectionUtils.isEmpty(defaultList)) { + List defaultDimensionNames = Arrays.asList( + SalaryI18nUtil.getI18nLabel(87614, "薪资所属月"), + SalaryI18nUtil.getI18nLabel(86184, "个税扣缴义务人"), +// SalaryI18nUtil.getI18nLabel(145212, "收入所得类型"), + SalaryI18nUtil.getI18nLabel(107369, "分部"), + SalaryI18nUtil.getI18nLabel(86185, "部门"), +// SalaryI18nUtil.getI18nLabel(90633, "岗位"), +// SalaryI18nUtil.getI18nLabel(98623, "职级"), +// SalaryI18nUtil.getI18nLabel(109332, "人事状态"), +// SalaryI18nUtil.getI18nLabel(151914, "人员类型"), + SalaryI18nUtil.getI18nLabel(100133, "人员"), + SalaryI18nUtil.getI18nLabel(157163, "年度"), + SalaryI18nUtil.getI18nLabel(173199, "半年度"), + SalaryI18nUtil.getI18nLabel(157162, "季度") + ); + List defaultDimensionCodes = Arrays.asList( + SalaryStatisticsDimensionConstant.DM_SALARY_MONTH, + SalaryStatisticsDimensionConstant.DM_TAX_AGENT, +// SalaryStatisticsDimensionConstant.DM_INCOME_CATEGORY, + SalaryStatisticsDimensionConstant.DM_SUB_COMPANY, + SalaryStatisticsDimensionConstant.DM_DEPARTMENT, +// SalaryStatisticsDimensionConstant.DM_POSITION, +// SalaryStatisticsDimensionConstant.DM_GRADE, +// SalaryStatisticsDimensionConstant.DM_HRM_STATUS, +// SalaryStatisticsDimensionConstant.DM_EMPLOYEE_TYPE, + SalaryStatisticsDimensionConstant.DM_EMPLOYEE, + SalaryStatisticsDimensionConstant.DM_YEAR, + SalaryStatisticsDimensionConstant.DM_HALF_YEAR, + SalaryStatisticsDimensionConstant.DM_QUARTER + ); + + List dimensionDefaultNews = Lists.newArrayList(); + Date now = new Date(); + for (String dm : defaultDimensionNames) { + dimensionDefaultNews.add(SalaryStatisticsDimensionPO.builder() + .id(IdGenerator.generate()) + .dimName(dm) + .dimType(SalaryStatisticsDimensionTypeEnum.QUALITATIVE.getValue()) + .setting("") + .remark(dm) + .isDefault(NumberUtils.INTEGER_ONE) + .dimCode(defaultDimensionCodes.get(defaultDimensionNames.indexOf(dm))) + .createTime(now) + .creator(currentEmployeeId) + .updateTime(now) + .deleteType(0) + .tenantKey("") + .build()); + } + dimensionDefaultNews.forEach(getSalaryStatisticsDimensionMapper()::insertIgnoreNull); + } + } + + @Override + public SalaryStatisticsDimensionPO getById(Long id) { + return getSalaryStatisticsDimensionMapper().getById(id); + } + + @Override + public List listAll() { + return getSalaryStatisticsDimensionMapper().listAll(); + } + + @Override + public PageInfo listPage(SalaryStatisticsDimensionQueryParam queryParam) { + + // 查询 + List salaryStatisticsDimensionPOS = getSalaryStatisticsDimensionMapper().listSome(SalaryStatisticsDimensionPO.builder().dimName(queryParam.getDimName()).build()); + // 分页参数 + PageInfo page = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), salaryStatisticsDimensionPOS, SalaryStatisticsDimensionPO.class); + + return page; + } + + /** + * 根据名称模糊查询 + * + * @param fieldName + * @return + */ + private List listByName(String fieldName) { + return getSalaryStatisticsDimensionMapper().listSome(SalaryStatisticsDimensionPO.builder().dimName(fieldName).build()); + } + + @Override + public String save(SalaryStatisticsDimensionSaveParam saveParam) { + SalaryStatisticsDimensionSaveParam.checkParam(saveParam); + + String setting = ""; + String dimCode = ""; + if (SalaryStatisticsDimensionTypeEnum.QUALITATIVE.equals(saveParam.getDimType())) { + setting = JSON.toJSONString(saveParam.getSetting4Qualitative()); + dimCode = saveParam.getSetting4Qualitative().getId(); + } else if (SalaryStatisticsDimensionTypeEnum.RATION_GROUP_SPACING.equals(saveParam.getDimType())) { + setting = JSON.toJSONString(saveParam.getSetting4RationGroupSpacing()); + dimCode = saveParam.getDimCode(); + } else if (SalaryStatisticsDimensionTypeEnum.RATION_GROUP_INDIVIDUAL.equals(saveParam.getDimType())) { + setting = JSON.toJSONString(saveParam.getSetting4RationGroupIndividual()); + dimCode = saveParam.getDimCode(); + } + Date now = new Date(); + if (saveParam.getId() != null) { + SalaryStatisticsDimensionPO po = this.getById(saveParam.getId()); + if (po == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(161300, "统计维度不存在")); + } + List list = listByName(saveParam.getDimName()); + boolean nameExist = list.stream().anyMatch(e -> !Objects.equals(e.getId(), saveParam.getId())); + if (nameExist) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98080, "名称不允许重复")); + } + SalaryStatisticsDimensionPO poNew = new SalaryStatisticsDimensionPO(); + BeanUtils.copyProperties(po, poNew); + poNew.setDimName(saveParam.getDimName()); + poNew.setDimType(saveParam.getDimType().getValue()); + poNew.setDimCode(dimCode); + poNew.setSetting(setting); + poNew.setRemark(saveParam.getRemark()); + this.getSalaryStatisticsDimensionMapper().updateIgnoreNull(poNew); + } else { + List list = listByName(saveParam.getDimName()); + if (CollectionUtils.isNotEmpty(list)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98080, "名称不允许重复")); + } + Long id = IdGenerator.generate(); + SalaryStatisticsDimensionPO poNew = SalaryStatisticsDimensionPO.builder() + .id(id) + .dimName(saveParam.getDimName()) + .dimType(saveParam.getDimType().getValue()) + .dimCode(dimCode) + .setting(setting) + .remark(saveParam.getRemark()) + .createTime(now) + .creator((long) user.getUID()) + .updateTime(now) + .deleteType(0) + .tenantKey("") + .build(); + this.getSalaryStatisticsDimensionMapper().insertIgnoreNull(poNew); + } + return StringUtils.EMPTY; + } + + @Override + public void saveExpandFieldSettings(EmployeeInfoExpandDTO saveParam) { + getSalaryEmployeeService(user).saveEmployeeExpandFieldSettings(saveParam); + } + + @Override + public EmployeeInfoExpandDTO getExpandFieldSettings(String module) { + return getSalaryEmployeeService(user).getExpandFieldSettings(module); + } + + @Override + public Map delete(Collection ids) { + if (CollectionUtils.isEmpty(ids)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(84026, "参数错误")); + } + int total = ids.size(); + List list = getSalaryStatisticsDimensionMapper().listSome(SalaryStatisticsDimensionPO.builder().ids(ids).build()); + boolean isDefault = list.stream().anyMatch(s -> NumberUtils.INTEGER_ONE.equals(s.getIsDefault())); + if (CollectionUtils.isEmpty(list) || isDefault) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(84026, "默认统计维度不可删除!")); + } + + // 被薪酬报表引用 + List salaryStatisticsReports = salaryStatisticsReportService(user).listAll(); + if (CollectionUtils.isNotEmpty(salaryStatisticsReports)) { + list = list.stream() + .filter(dim -> salaryStatisticsReports.stream().noneMatch(rp -> StringUtils.isNotEmpty(rp.getDimension()) && Arrays.asList(rp.getDimension().split(",")).contains(dim.getId().toString()))) + .collect(Collectors.toList()); + } + + int success = list.size(); + if (success > 0) { + List deleteIds = list.stream().map(SalaryStatisticsDimensionPO::getId).collect(Collectors.toList()); + getSalaryStatisticsDimensionMapper().batDelete(deleteIds); + } + + Map resultMap = new HashMap<>(2); + String resultMsg = SalaryI18nUtil.getI18nLabel(94620, "操作成功"); + String resultType = "success"; + // 单个设为定薪提示 + if (total > 1) { + resultMsg = SalaryI18nUtil.getI18nLabel(134807, "成功条数") + ": " + (success) + "; " + + SalaryI18nUtil.getI18nLabel(134808, "失败条数") + ": " + (total - success) + + ((total - success) > 0 ? ", " + SalaryI18nUtil.getI18nLabel(176149, "被薪资统计报表引用的不能删除") : ""); + if ((total - success) > 0) { + resultType = "info"; + } + } else if (total == 1 && success < 1) { + resultMsg = SalaryI18nUtil.getI18nLabel(176149, "被薪资统计报表引用的不能删除"); + throw new SalaryRunTimeException(resultMsg); +// resultType = "info"; + } + resultMap.put("type", resultType); + resultMap.put("msg", resultMsg); + return resultMap; + } + + @Override + public List listAllDefaultDimension() { + return getSalaryStatisticsDimensionMapper().listSome(SalaryStatisticsDimensionPO.builder().isDefault(NumberUtils.INTEGER_ONE).build()); + } +} diff --git a/src/com/engine/salary/report/service/impl/SalaryStatisticsEchartsServiceImpl.java b/src/com/engine/salary/report/service/impl/SalaryStatisticsEchartsServiceImpl.java new file mode 100644 index 000000000..d09400752 --- /dev/null +++ b/src/com/engine/salary/report/service/impl/SalaryStatisticsEchartsServiceImpl.java @@ -0,0 +1,104 @@ +package com.engine.salary.report.service.impl; + +import com.alibaba.fastjson.JSONArray; +import com.engine.core.impl.Service; +import com.engine.salary.constant.SalaryDefaultTenantConstant; +import com.engine.salary.enums.sicategory.DeleteTypeEnum; +import com.engine.salary.mapper.report.SalaryStatisticsEChartsSettingMapper; +import com.engine.salary.report.entity.dto.SalaryStatisticsEchartsDTO; +import com.engine.salary.report.entity.po.SalaryStatisticsEChartsSettingPO; +import com.engine.salary.report.service.SalaryStatisticsEchartsService; +import com.engine.salary.util.SalaryAssert; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.db.MapperProxyFactory; +import com.engine.salary.util.db.IdGenerator; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; + +import java.util.Date; +import java.util.List; +import java.util.Objects; + +/** + * 薪酬统计图表 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SalaryStatisticsEchartsServiceImpl extends Service implements SalaryStatisticsEchartsService { + + private SalaryStatisticsEChartsSettingMapper getSalaryStatisticsDimensionMapper() { + return MapperProxyFactory.getProxy(SalaryStatisticsEChartsSettingMapper.class); + } + @Override + public String saveRangeSetting(SalaryStatisticsEchartsDTO saveParam) { + SalaryAssert.notNull(saveParam.getReportId(), SalaryI18nUtil.getI18nLabel( 152562, "报表id不能为空")); + SalaryAssert.notNull(saveParam.getChartsType(), SalaryI18nUtil.getI18nLabel( 177912, "报表类型不能为空")); + + SalaryStatisticsEChartsSettingPO salaryStatisticsEChartsSettingQue = null; + List pos = getSalaryStatisticsDimensionMapper().listSome(SalaryStatisticsEChartsSettingPO.builder().reportId(saveParam.getReportId()).chartsType(saveParam.getChartsType()).build()); + if(CollectionUtils.isNotEmpty(pos)){ + salaryStatisticsEChartsSettingQue = pos.get(0); + } + + if (salaryStatisticsEChartsSettingQue != null) { + getSalaryStatisticsDimensionMapper().delete(salaryStatisticsEChartsSettingQue); + } + Date now = new Date(); + SalaryStatisticsEChartsSettingPO salaryStatisticsEChartsSetting = SalaryStatisticsEChartsSettingPO.builder() + .id(IdGenerator.generate()) + .reportId(saveParam.getReportId()) + .chartsType(saveParam.getChartsType()) + .itemValues(JSONArray.toJSONString(saveParam.getItemValues())) + .itemColValue(saveParam.getItemColValue()) + .dimensionRange(Objects.isNull(saveParam.getDimensionRange()) ? 0 : saveParam.getDimensionRange()) + .itemSortValue(saveParam.getItemSortValue()) + .itemColSortValue(saveParam.getItemColSortValue()) + .sortType(saveParam.getSortType()) + .sortNum(saveParam.getSortNum()) + .createTime(now) + .updateTime(now) + .deleteType(DeleteTypeEnum.NOT_DELETED.getValue()) + .creator((long)user.getUID()) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .build(); + getSalaryStatisticsDimensionMapper().insertIgnoreNull(salaryStatisticsEChartsSetting); + return StringUtils.EMPTY; + } + + @Override + public String deleteRangeSetting(Long reportId) { + + getSalaryStatisticsDimensionMapper().deleteByReportId(reportId); + + return StringUtils.EMPTY; + } + + @Override + public SalaryStatisticsEchartsDTO queryRangeSetting(SalaryStatisticsEchartsDTO resp) { + + + SalaryStatisticsEChartsSettingPO salaryStatisticsEChartsSetting = null; + List pos = getSalaryStatisticsDimensionMapper().listSome(SalaryStatisticsEChartsSettingPO.builder().reportId(resp.getReportId()).chartsType(resp.getChartsType()).build()); + if(CollectionUtils.isNotEmpty(pos)){ + salaryStatisticsEChartsSetting = pos.get(0); + } + + if (salaryStatisticsEChartsSetting != null) { + resp.setId(salaryStatisticsEChartsSetting.getId()); + resp.setReportId(salaryStatisticsEChartsSetting.getReportId()); + resp.setChartsType(salaryStatisticsEChartsSetting.getChartsType()); + resp.setDimensionRange(salaryStatisticsEChartsSetting.getDimensionRange()); + resp.setItemValues(JSONArray.parseArray(salaryStatisticsEChartsSetting.getItemValues(), String.class)); + resp.setSortNum(salaryStatisticsEChartsSetting.getSortNum()); + resp.setSortType(salaryStatisticsEChartsSetting.getSortType()); + resp.setItemColValue(salaryStatisticsEChartsSetting.getItemColValue()); + resp.setItemSortValue(salaryStatisticsEChartsSetting.getItemSortValue()); + resp.setItemColSortValue(salaryStatisticsEChartsSetting.getItemColSortValue()); + return resp; + } + return resp; + } +} diff --git a/src/com/engine/salary/report/service/impl/SalaryStatisticsEmployeeServiceImpl.java b/src/com/engine/salary/report/service/impl/SalaryStatisticsEmployeeServiceImpl.java new file mode 100644 index 000000000..19d0147ed --- /dev/null +++ b/src/com/engine/salary/report/service/impl/SalaryStatisticsEmployeeServiceImpl.java @@ -0,0 +1,385 @@ +package com.engine.salary.report.service.impl; + +import cn.hutool.core.util.NumberUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.salaryacct.param.SalaryAcctEmployeeQueryParam; +import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO; +import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO; +import com.engine.salary.entity.salaryacct.po.SalaryAcctResultPO; +import com.engine.salary.entity.salaryitem.po.SalaryItemPO; +import com.engine.salary.entity.salarysob.po.SalarySobPO; +import com.engine.salary.entity.taxagent.param.TaxAgentQueryParam; +import com.engine.salary.entity.setting.param.PageListSettingQueryParam; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import com.engine.salary.enums.UserStatusEnum; +import com.engine.salary.enums.auth.AuthFilterTypeEnum; +import com.engine.salary.enums.datacollection.UseEmployeeTypeEnum; +import com.engine.salary.enums.salaryitem.SalaryDataTypeEnum; +import com.engine.salary.enums.salarysob.SalaryEmployeeStatusEnum; +import com.engine.salary.mapper.salaryacct.SalaryAcctEmployeeMapper; +import com.engine.salary.report.common.constant.SalaryConstant; +import com.engine.salary.report.entity.bo.SalaryStatisticsEmployeeBO; +import com.engine.salary.report.entity.dto.SalaryStatisticsEmployeeDetailResultDTO; +import com.engine.salary.report.entity.dto.SalaryStatisticsEmployeeListDTO; +import com.engine.salary.report.entity.param.SalaryStatisticsEmployeeDetailQueryParam; +import com.engine.salary.report.entity.param.SalaryStatisticsEmployeeQueryParam; +import com.engine.salary.report.entity.param.SalaryStatisticsEmployeeSalaryQueryParam; +import com.engine.salary.report.service.SalaryStatisticsEmployeeService; +import com.engine.salary.service.*; +import com.engine.salary.service.auth.AuthService; +import com.engine.salary.service.auth.AuthServiceImpl; +import com.engine.salary.service.impl.*; +import com.engine.salary.util.SalaryAssert; +import com.engine.salary.util.SalaryDateUtil; +import com.engine.salary.util.SalaryEntityUtil; +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.page.SalaryPageUtil; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.wbi.util.Util; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import weaver.hrm.User; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * 薪酬统计员工明细 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Slf4j +public class SalaryStatisticsEmployeeServiceImpl extends Service implements SalaryStatisticsEmployeeService { + + private SalaryAcctEmployeeMapper getSalaryAcctEmployeeMapper() { + return MapperProxyFactory.getProxy(SalaryAcctEmployeeMapper.class); + } + + private SalaryAcctEmployeeService getSalaryAcctEmployeeService(User user) { + return ServiceUtil.getService(SalaryAcctEmployeeServiceImpl.class, user); + } + + private SalaryAcctResultService getSalaryAcctResultService(User user) { + return ServiceUtil.getService(SalaryAcctResultServiceImpl.class, user); + } + + private SalaryItemService getSalaryItemService(User user) { + return ServiceUtil.getService(SalaryItemServiceImpl.class, user); + } + + private SalarySobService getSalarySobService(User user) { + return ServiceUtil.getService(SalarySobServiceImpl.class, user); + } + + private SalaryAcctRecordService getSalaryAcctRecordService(User user) { + return ServiceUtil.getService(SalaryAcctRecordServiceImpl.class, user); + } + + +// private ExtEmployeeMapper extEmployeeMapper; + + private TaxAgentService getTaxAgentService(User user) { + return ServiceUtil.getService(TaxAgentServiceImpl.class, user); + } + + private SalaryEmployeeService getSalaryEmployeeService(User user) { + return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user); + } + + public AuthService getAuthService(User user) { + return ServiceUtil.getService(AuthServiceImpl.class, user); + } + + private SettingService getSettingService(User user) { + return ServiceUtil.getService(SettingServiceImpl.class, user); + } + + @Override + public PageInfo listPage(SalaryStatisticsEmployeeQueryParam queryParam) { + List list = Collections.emptyList(); + PageInfo page = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), list, SalaryStatisticsEmployeeListDTO.class); + + // 1.分权处理, 首先获取个税扣缴义务人参数 + TaxAgentQueryParam taxAgentQueryParam = new TaxAgentQueryParam(); + taxAgentQueryParam.setFilterType(AuthFilterTypeEnum.QUERY_DATA); + Collection taxAgentViews = getTaxAgentService(user).listAuth(taxAgentQueryParam); + List taxAgentIds = Objects.isNull(taxAgentViews) ? Lists.newArrayList() : taxAgentViews.stream().map(TaxAgentPO::getId).collect(Collectors.toList()); + if (CollectionUtils.isEmpty(taxAgentIds)) { + return page; + } + + // 2.年月参数处理,注意:薪资所属月居然是用字符串存储的,无法通过sql between处理 + Set salaryMonths = SalaryStatisticsEmployeeBO.getSalaryMonths(queryParam.getYear(), queryParam.getSalaryMonth()) + .stream() + .map(SalaryDateUtil::dateStrToLocalYearMonth) + .collect(Collectors.toSet()); + + // 查询薪资核算人员 + SalaryAcctEmployeeQueryParam salaryAcctEmployeeQueryParam = SalaryAcctEmployeeQueryParam.builder().salaryMonths(salaryMonths).taxAgentIds(taxAgentIds).build(); + List salaryAcctEmployeeList = getSalaryAcctEmployeeService(user).listByParam(salaryAcctEmployeeQueryParam); + salaryAcctEmployeeList = getAuthService(user).auth(salaryAcctEmployeeList, AuthFilterTypeEnum.QUERY_DATA,SalaryAcctEmployeePO.class,"report"); + if (CollectionUtils.isEmpty(salaryAcctEmployeeList)) { + return page; + } + + // 内部人员id + Set innerEmployeeIds = salaryAcctEmployeeList.stream().map(SalaryAcctEmployeePO::getEmployeeId).collect(Collectors.toCollection(LinkedHashSet::new)); + + // 3.关键字搜索参数 + if (StringUtils.isNotEmpty(queryParam.getKeyword())) { + if (CollectionUtils.isNotEmpty(innerEmployeeIds)) { + List salaryEmployees = getSalaryEmployeeService(user).listAll(UseEmployeeTypeEnum.ALL); + Set finalInnerEmployeeIds = innerEmployeeIds; + innerEmployeeIds = salaryEmployees.stream() + .filter(e -> finalInnerEmployeeIds.contains(e.getEmployeeId()) && (e.getUsername().contains(queryParam.getKeyword()) || (StringUtils.isNotEmpty(e.getWorkcode()) && e.getWorkcode().contains(queryParam.getKeyword())))) + .map(DataCollectionEmployee::getEmployeeId) + .collect(Collectors.toSet()); + } + } + + list = innerEmployeeIds.stream().map(e -> SalaryStatisticsEmployeeListDTO.builder().id(e).build()).collect(Collectors.toList()); + + // 第一页数据显示处理 + page = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), list, SalaryStatisticsEmployeeListDTO.class); + List salaryStatisticsEmployeeListDTOs = page.getList(); + List employeeIds = salaryStatisticsEmployeeListDTOs.stream().map(SalaryStatisticsEmployeeListDTO::getId).collect(Collectors.toList()); + List simpleEmployeeList = getSalaryEmployeeService(user).getEmployeeByIdsAll(employeeIds); + Map innerEmployeeMap = simpleEmployeeList.stream().collect(Collectors.toMap(DataCollectionEmployee::getEmployeeId, v -> v)); + salaryStatisticsEmployeeListDTOs.forEach(e -> { + DataCollectionEmployee simpleEmployee = innerEmployeeMap.get(e.getId()); + e.setName(Objects.isNull(simpleEmployee) ? "" : simpleEmployee.getUsername()); + e.setSubCompany(simpleEmployee.getSubcompanyName()); + e.setDepartment(simpleEmployee.getDepartmentName()); + e.setPosition(simpleEmployee.getJobtitleName()); + e.setStatus(UserStatusEnum.getDefaultLabelByValue(Integer.parseInt(simpleEmployee.getStatus()))); + e.setJobNum(simpleEmployee.getWorkcode()); + e.setIdNo(simpleEmployee.getIdNo()); + }); + page.setList(salaryStatisticsEmployeeListDTOs); + return page; + } + + + @Override + public SalaryStatisticsEmployeeDetailResultDTO getDetailSalaryAcctResult(SalaryStatisticsEmployeeDetailQueryParam queryParam) { + SalaryAssert.notNull(queryParam.getEmployeeId(), SalaryI18nUtil.getI18nLabel(163974, "人员id不能为空")); + + // 薪资所属月参数,如果已经有年的就取交集 + Set salaryMonths = SalaryStatisticsEmployeeBO.getSalaryMonths(queryParam.getYear(), queryParam.getSalaryMonth()).stream().map(SalaryDateUtil::dateStrToLocalYearMonth).collect(Collectors.toSet()); + + // 1.获取该员工所有核算人员数据 + SalaryAcctEmployeePO build = SalaryAcctEmployeePO.builder().employeeId(queryParam.getEmployeeId()).build(); + if (CollectionUtils.isNotEmpty(queryParam.getIds())) { + build.setIds(queryParam.getIds()); + } + if (CollectionUtils.isNotEmpty(salaryMonths)) { + build.setSalaryMonths(salaryMonths); + } + if (Objects.nonNull(queryParam.getTaxAgentId())) { + build.setTaxAgentId(queryParam.getTaxAgentId()); + } + List salaryAcctEmployees = getSalaryAcctEmployeeMapper().listSome(build); + salaryAcctEmployees = salaryAcctEmployees.stream().sorted(Comparator.comparing(SalaryAcctEmployeePO::getSalaryMonth)).collect(Collectors.toList()); + Collections.reverse(salaryAcctEmployees); + + // 2.获取核算结果数据 + List salaryAcctEmployeeIds = salaryAcctEmployees.stream().map(SalaryAcctEmployeePO::getId).collect(Collectors.toList()); + List salaryAcctResultValues = getSalaryAcctResultService(user).listBySalaryAcctEmployeeIds(salaryAcctEmployeeIds); + + // 3.获取薪资项目 + Map resultMap = Maps.newHashMap(); + salaryAcctResultValues.forEach(sv -> { + resultMap.put(sv.getSalaryItemId() + "", sv.getResultValue()); + }); + List salaryItemIds = resultMap.keySet().stream().map(Long::valueOf).collect(Collectors.toList()); + List salaryItemList = CollectionUtils.isEmpty(salaryItemIds) ? Lists.newArrayList() : getSalaryItemService(user).listByIds(salaryItemIds); + + return SalaryStatisticsEmployeeDetailResultDTO.builder() + .salaryAcctEmployeeList(salaryAcctEmployees) + .salaryAcctResultValueList(salaryAcctResultValues) + .salaryItemList(salaryItemList) + .build(); + } + + @Override + public List> listDetailPage(SalaryStatisticsEmployeeDetailResultDTO salaryStatisticsEmployeeDetailResult, SalaryStatisticsEmployeeDetailQueryParam queryParam) { + + List taxAgentList = getTaxAgentService(user).listAll(); + Map taxAgentMap = SalaryEntityUtil.convert2Map(taxAgentList, TaxAgentPO::getId, TaxAgentPO::getName); + + List salarySobPOS = getSalarySobService(user).listAll(); + Map SalarySobMap = SalaryEntityUtil.convert2Map(salarySobPOS, SalarySobPO::getId, SalarySobPO::getName); + + List salaryAcctRecordPOS = getSalaryAcctRecordService(user).listAll(); + Map salaryAcctRecordMap = SalaryEntityUtil.convert2Map(salaryAcctRecordPOS, SalaryAcctRecordPO::getId, SalaryAcctRecordPO::getAcctTimes); + + List salaryItemPOList = getSalaryItemService(user).listAll(); + Map itemDataTypeMap = SalaryEntityUtil.convert2Map(salaryItemPOList, SalaryItemPO::getId, SalaryItemPO::getDataType); + + + Map> acctResultValueList = SalaryEntityUtil.group2Map(salaryStatisticsEmployeeDetailResult.getSalaryAcctResultValueList(), SalaryAcctResultPO::getSalaryAcctEmpId); + Map> acctResultValueMap = new HashMap<>(); + acctResultValueList.forEach((k, v) -> { + Map map = new HashMap(); + v.forEach(l -> { + String dataType = itemDataTypeMap.getOrDefault(l.getSalaryItemId(), "string"); + SalaryDataTypeEnum typeEnum = SalaryDataTypeEnum.parseByValue(dataType); + String resultValue = l.getResultValue(); + if (typeEnum == SalaryDataTypeEnum.NUMBER && NumberUtil.isNumber(resultValue)) { + map.put(l.getSalaryItemId() + "", Double.valueOf(resultValue)); + } else { + map.put(l.getSalaryItemId() + "", resultValue); + } + }); + acctResultValueMap.put(k, map); + }); + + // 获取人员信息 + List employeeList = getSalaryEmployeeService(user).listByIds(salaryStatisticsEmployeeDetailResult.getSalaryAcctEmployeeList().stream().map(SalaryAcctEmployeePO::getEmployeeId).distinct().collect(Collectors.toList())); + Map empMap = SalaryEntityUtil.convert2Map(employeeList, DataCollectionEmployee::getEmployeeId); + List> list = Lists.newArrayList(); + Map map; + for (SalaryAcctEmployeePO se : salaryStatisticsEmployeeDetailResult.getSalaryAcctEmployeeList()) { + map = Maps.newHashMap(); + Map resultValueMap = Optional.ofNullable(acctResultValueMap.get(se.getId())).orElse(Maps.newHashMap()); + Map finalMap = map; + resultValueMap.forEach((k, v) -> { + finalMap.put(k + SalaryConstant.DYNAMIC_SUFFIX, v); + }); + DataCollectionEmployee emp = empMap.getOrDefault(se.getEmployeeId(), DataCollectionEmployee.builder().build()); + map.put("id", se.getId().toString()); + map.put("salaryMonth", SalaryDateUtil.getFormatYearMonth(se.getSalaryMonth())); + map.put("taxAgent", taxAgentMap.get(se.getTaxAgentId())); + map.put("salarySob", SalarySobMap.get(se.getSalarySobId())); + map.put("acctTimes", salaryAcctRecordMap.get(se.getSalaryAcctRecordId())); + map.put("userName", Util.null2String(emp.getUsername())); + map.put("subCompany", Util.null2String(emp.getSubcompanyName())); + map.put("department", Util.null2String(emp.getDepartmentName())); + map.put("jobTitle", Util.null2String(emp.getJobtitleName())); + map.put("status", Util.null2String(NumberUtil.isNumber(emp.getStatus()) ? SalaryEmployeeStatusEnum.parseByValue(Integer.valueOf(emp.getStatus())).getDefaultLabel() : null)); + map.put("workCode", Util.null2String(emp.getWorkcode())); + map.put("idNo", Util.null2String(emp.getIdNo())); + map.put("companystartdate", Util.null2String(emp.getCompanystartdate())); + +// IncomeCategoryEnum incomeCategoryEnum = IncomeCategoryEnum.parseByValue(Integer.parseInt(se.getIncomeCategory())); +// map.put("incomeCategory", Objects.isNull(incomeCategoryEnum) ? "" : SalaryI18nUtil.getI18nLabel(incomeCategoryEnum.getLabelId(), incomeCategoryEnum.getDefaultLabel())); + list.add(map); + } + return list; + } + + @Override + public PageInfo listSalaryAcctEmp(SalaryStatisticsEmployeeSalaryQueryParam queryParam) { + // 1.分权处理, 首先获取个税扣缴义务人参数 + TaxAgentQueryParam param = TaxAgentQueryParam.builder().build(); + param.setFilterType(AuthFilterTypeEnum.QUERY_DATA); + Collection taxAgentViews = getTaxAgentService(user).listAuth(param); + List taxAgentIds = Objects.isNull(taxAgentViews) ? Lists.newArrayList() : taxAgentViews.stream().map(TaxAgentPO::getId).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(queryParam.getTaxAgentIds())) { + taxAgentIds = taxAgentIds.stream().filter(queryParam.getTaxAgentIds()::contains).collect(Collectors.toList()); + } + if (CollectionUtils.isEmpty(taxAgentIds)) { + return new PageInfo<>(); + } + + // 2.年月参数处理,注意:薪资所属月居然是用字符串存储的,无法通过sql between处理 + List dataParam = new ArrayList<>(); + if (StringUtils.isNotBlank(queryParam.getStartDateStr())) { + dataParam.add(SalaryDateUtil.dateStrToLocalTime(queryParam.getStartDateStr() + "-01 00:00:00")); + } + if (StringUtils.isNotBlank(queryParam.getEndDateStr())) { + dataParam.add(SalaryDateUtil.dateStrToLocalTime(queryParam.getEndDateStr() + "-01 00:00:00")); + } + Set salaryMonths = SalaryStatisticsEmployeeBO.getSalaryMonths(null, dataParam) + .stream() + .map(SalaryDateUtil::dateStrToLocalYearMonth) + .collect(Collectors.toSet()); + + // 查询薪资核算人员 + SalaryAcctEmployeeQueryParam salaryAcctEmployeeQueryParam = SalaryAcctEmployeeQueryParam.builder().salaryMonths(salaryMonths).taxAgentIds(taxAgentIds).build(); + List salaryAcctEmployeeList = getSalaryAcctEmployeeService(user).listByParam(salaryAcctEmployeeQueryParam); + salaryAcctEmployeeList = getAuthService(user).auth(salaryAcctEmployeeList, AuthFilterTypeEnum.QUERY_DATA,SalaryAcctEmployeePO.class,"report"); + + if (CollectionUtils.isNotEmpty(queryParam.getSubCompanyIds()) || CollectionUtils.isNotEmpty(queryParam.getDepartmentIds()) || StringUtils.isNotBlank(queryParam.getKeyword())) { + // 根据分部、部门筛选 + List employeeList = getSalaryEmployeeService(user).listBySubCompanyOrDepartment(queryParam.getSubCompanyIds(), queryParam.getDepartmentIds()); + // 根据关键词过滤 + if (StringUtils.isNotBlank(queryParam.getKeyword())) { + employeeList = employeeList.stream() + .filter(e -> (StringUtils.isNotEmpty(e.getUsername()) && e.getUsername().contains(queryParam.getKeyword()) || (StringUtils.isNotEmpty(e.getWorkcode()) && e.getWorkcode().contains(queryParam.getKeyword())))) + .collect(Collectors.toList()); + } + List employeeIds = employeeList.stream().map(DataCollectionEmployee::getEmployeeId).collect(Collectors.toList()); + salaryAcctEmployeeList = salaryAcctEmployeeList.stream().filter(acctEmp -> employeeIds.contains(acctEmp.getEmployeeId())).collect(Collectors.toList()); + } + + //人员浏览按钮筛选 + List employeeIds = queryParam.getEmployeeIds(); + if(CollectionUtils.isNotEmpty(employeeIds)){ + salaryAcctEmployeeList = salaryAcctEmployeeList.stream().filter(acctEmp -> employeeIds.contains(acctEmp.getEmployeeId())).collect(Collectors.toList()); + } + + if (CollectionUtils.isEmpty(salaryAcctEmployeeList)) { + return new PageInfo<>(); + } + + // 分页 + if (CollectionUtils.isNotEmpty(queryParam.getIds())) { + salaryAcctEmployeeList = salaryAcctEmployeeList.stream().filter(emp -> queryParam.getIds().contains(emp.getId())).collect(Collectors.toList()); + } + salaryAcctEmployeeList = salaryAcctEmployeeList.stream().sorted(Comparator.comparing(SalaryAcctEmployeePO::getSalaryMonth).reversed()).collect(Collectors.toList()); + PageInfo salaryAcctEmployeePageInfo = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), salaryAcctEmployeeList); + if (queryParam.isExport()) { + salaryAcctEmployeePageInfo.setList(salaryAcctEmployeeList); + } + return salaryAcctEmployeePageInfo; + } + + @Override + public SalaryStatisticsEmployeeDetailResultDTO getDetailSalaryAcctResultByAcctEmp(List salaryAcctEmployeeList) { + // 3.获取薪资项目 + List salaryItemList = getSalaryItemService(user).listAll(); + salaryItemList = salaryItemList.stream() + .sorted(new Comparator() { + @Override + public int compare(SalaryItemPO o1, SalaryItemPO o2) { + if (o1.getSortedIndex() == null && o2.getSortedIndex() == null) { + Integer systemType1 = o1.getSystemType() == null ? 0 : o1.getSystemType(); + Integer systemType2 = o2.getSystemType() == null ? 0 : o2.getSystemType(); + return systemType1.compareTo(systemType2); + } else { + Integer sortedIndex1 = o1.getSortedIndex() == null ? 0 : o1.getSortedIndex(); + Integer sortedIndex2 = o2.getSortedIndex() == null ? 0 : o2.getSortedIndex(); + return sortedIndex2.compareTo(sortedIndex1); + } + } + }) + .collect(Collectors.toList()); + if (CollectionUtils.isEmpty(salaryAcctEmployeeList)) { + return SalaryStatisticsEmployeeDetailResultDTO.builder() + .salaryAcctEmployeeList(Collections.emptyList()) + .salaryAcctResultValueList(Collections.emptyList()) + .salaryItemList(salaryItemList) + .build(); + } + + // 获取核算结果数据 + List salaryAcctEmployeeIds = salaryAcctEmployeeList.stream().map(SalaryAcctEmployeePO::getId).collect(Collectors.toList()); + List salaryAcctResultValues = getSalaryAcctResultService(user).listBySalaryAcctEmployeeIds(salaryAcctEmployeeIds); + + return SalaryStatisticsEmployeeDetailResultDTO.builder() + .salaryAcctEmployeeList(salaryAcctEmployeeList) + .salaryAcctResultValueList(salaryAcctResultValues) + .salaryItemList(salaryItemList) + .build(); + } +} diff --git a/src/com/engine/salary/report/service/impl/SalaryStatisticsItemServiceImpl.java b/src/com/engine/salary/report/service/impl/SalaryStatisticsItemServiceImpl.java new file mode 100644 index 000000000..e7eb0bcc5 --- /dev/null +++ b/src/com/engine/salary/report/service/impl/SalaryStatisticsItemServiceImpl.java @@ -0,0 +1,207 @@ +package com.engine.salary.report.service.impl; + +import com.engine.core.impl.Service; +import com.engine.salary.config.SalaryElogConfig; +import com.engine.salary.constant.SalaryDefaultTenantConstant; +import com.engine.hrmelog.entity.dto.LoggerContext; +import com.engine.salary.enums.OperateTypeEnum; +import com.engine.salary.enums.sicategory.DeleteTypeEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.mapper.report.SalaryStatisticsItemMapper; +import com.engine.salary.report.entity.param.SalaryStatisticsItemSaveParam; +import com.engine.salary.report.entity.po.SalaryStatisticsItemPO; +import com.engine.salary.report.enums.UnitTypeEnum; +import com.engine.salary.report.service.SalaryStatisticsItemService; +import com.engine.salary.util.SalaryAssert; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.db.IdGenerator; +import com.engine.salary.util.db.MapperProxyFactory; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang.StringUtils; +import org.springframework.beans.BeanUtils; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * 薪酬报表自定义统计项目 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SalaryStatisticsItemServiceImpl extends Service implements SalaryStatisticsItemService { + + + private SalaryStatisticsItemMapper getSalaryStatisticsItemMapper() { + return MapperProxyFactory.getProxy(SalaryStatisticsItemMapper.class); + } + + @Override + public SalaryStatisticsItemPO getById(Long id) { + if (id == null) { + return null; + } + return getSalaryStatisticsItemMapper().getById(id); + } + + @Override + public List listByStatisticsReportId(Long statisticsReportId) { + if (statisticsReportId == null) { + return new ArrayList<>(); + } + return getSalaryStatisticsItemMapper().listSome(SalaryStatisticsItemPO.builder().statReportId(statisticsReportId).build()); + } + + public List listByIds(Collection ids) { + + if (CollectionUtils.isEmpty(ids)) { + return new ArrayList<>(); + } + + return getSalaryStatisticsItemMapper().listSome(SalaryStatisticsItemPO.builder().ids(ids).build()); + } + + @Override + public String delete(Collection ids) { + SalaryAssert.notEmpty(ids, SalaryI18nUtil.getI18nLabel(152638, "id不可为空")); + List list = this.listByIds(ids); + if (CollectionUtils.isNotEmpty(list)) { + getSalaryStatisticsItemMapper().deleteByIds(ids); + list.forEach(po -> { + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(po.getId())); + loggerContext.setTargetName(po.getItemName()); + loggerContext.setOperateType(OperateTypeEnum.DELETE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "删除统计项目")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "删除统计项目")); + loggerContext.setOldValues(po); + SalaryElogConfig.salaryStatReportLoggerTemplate.write(loggerContext); + }); + } + return StringUtils.EMPTY; + } + + @Override + public String save(SalaryStatisticsItemSaveParam saveParam) { + // 新建 + if (Objects.isNull(saveParam.getId())) { + if (Objects.isNull(saveParam.getStatReportId())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(163034, "统计报表id不能为空")); + } + if (CollectionUtils.isEmpty(saveParam.getItemValue())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(152640, "统计项目必填")); + } + if (StringUtils.isEmpty(saveParam.getItemName())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(152641, "统计项名称必填")); + } + + List itemPOList = listByStatisticsReportId(saveParam.getStatReportId()); + boolean isRepeat = itemPOList.stream().anyMatch(po -> saveParam.getItemName().equals(po.getItemName())); + if (isRepeat) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(152642, "统计项目名称已经存在")); + } + + List indexValues = itemPOList.stream().map(SalaryStatisticsItemPO::getIndexValue).collect(Collectors.toList()); + Integer max = CollectionUtils.isEmpty(indexValues) ? 1 : Collections.max(indexValues); + + Date now = new Date(); + + SalaryStatisticsItemPO subTableItemPO = SalaryStatisticsItemPO.builder() + .id(IdGenerator.generate()) + .createTime(now) + .deleteType(DeleteTypeEnum.NOT_DELETED.getValue()) + .itemName(saveParam.getItemName()) + .itemValue(StringUtils.join(saveParam.getItemValue(), ",")) + .countRule(SalaryEntityUtil.toJSONString(saveParam.getCountRule())) + .sumRule(SalaryEntityUtil.toJSONString(saveParam.getSumRule())) + .avgRule(SalaryEntityUtil.toJSONString(saveParam.getAvgRule())) + .maxRule(SalaryEntityUtil.toJSONString(saveParam.getMaxRule())) + .minRule(SalaryEntityUtil.toJSONString(saveParam.getMinRule())) + .medianRule(SalaryEntityUtil.toJSONString(saveParam.getMedianRule())) + .lastRule(SalaryEntityUtil.toJSONString(saveParam.getLastRule())) + .oldRule(SalaryEntityUtil.toJSONString(saveParam.getOldRule())) + .frequentRule(SalaryEntityUtil.toJSONString(saveParam.getFrequentRule())) + .tileRule(SalaryEntityUtil.toJSONString(saveParam.getTileRule())) + .indexValue(max + 1) + .statReportId(saveParam.getStatReportId()) + .unitType(saveParam.getUnitType() == null ? UnitTypeEnum.YUAN.getValue() : saveParam.getUnitType()) + .creator((long) user.getUID()) + .updateTime(now) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .build(); + getSalaryStatisticsItemMapper().insertIgnoreNull(subTableItemPO); + + // 记录操作日志 + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(subTableItemPO.getId())); + loggerContext.setTargetName(subTableItemPO.getItemName()); + loggerContext.setOperateType(OperateTypeEnum.ADD.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "新增统计项目")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "新增统计项目")); + loggerContext.setNewValues(subTableItemPO); + SalaryElogConfig.salaryStatReportLoggerTemplate.write(loggerContext); + // 更新 + } else { + SalaryStatisticsItemPO itemPO = this.getById(saveParam.getId()); + SalaryAssert.notNull(itemPO, SalaryI18nUtil.getI18nLabel(152591, "统计项目不存在")); + Optional.ofNullable(saveParam.getItemName()).ifPresent(itemPO::setItemName); + + SalaryStatisticsItemPO oldPO = new SalaryStatisticsItemPO(); + BeanUtils.copyProperties(itemPO, oldPO); + + if (Objects.nonNull(saveParam.getUnitType())) { + itemPO.setUnitType(saveParam.getUnitType()); + } else { + itemPO.setItemValue(StringUtils.join(saveParam.getItemValue(), ",")); + itemPO.setCountRule(SalaryEntityUtil.toJSONString(saveParam.getCountRule())); + itemPO.setSumRule(SalaryEntityUtil.toJSONString(saveParam.getSumRule())); + itemPO.setAvgRule(SalaryEntityUtil.toJSONString(saveParam.getAvgRule())); + itemPO.setMaxRule(SalaryEntityUtil.toJSONString(saveParam.getMaxRule())); + itemPO.setMinRule(SalaryEntityUtil.toJSONString(saveParam.getMinRule())); + itemPO.setMedianRule(SalaryEntityUtil.toJSONString(saveParam.getMedianRule())); + itemPO.setLastRule(SalaryEntityUtil.toJSONString(saveParam.getLastRule())); + itemPO.setOldRule(SalaryEntityUtil.toJSONString(saveParam.getOldRule())); + itemPO.setFrequentRule(SalaryEntityUtil.toJSONString(saveParam.getFrequentRule())); + itemPO.setTileRule(SalaryEntityUtil.toJSONString(saveParam.getTileRule())); + } + + getSalaryStatisticsItemMapper().updateIgnoreNull(itemPO); + + // 记录操作日志 + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(itemPO.getId().toString()); + loggerContext.setTargetName(itemPO.getItemName()); + loggerContext.setOperateType(OperateTypeEnum.ADD.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "新增统计项目")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "新增统计项目")); + loggerContext.setOldValues(oldPO); + loggerContext.setNewValues(itemPO); + SalaryElogConfig.salaryStatReportLoggerTemplate.write(loggerContext); + } + return StringUtils.EMPTY; + } + + @Override + public void saveOrUpdateBatch(List salaryStatisticsItemList) { + salaryStatisticsItemList.forEach(po -> { + Long id = po.getId(); + SalaryStatisticsItemPO item = getSalaryStatisticsItemMapper().getById(id); + if (item == null) { + getSalaryStatisticsItemMapper().insertIgnoreNull(po); + } else { + getSalaryStatisticsItemMapper().update(po); + } + }); + } + + @Override + public void deleteByReportIds(List reportIds) { + getSalaryStatisticsItemMapper().deleteByReportIds(reportIds); + } +} diff --git a/src/com/engine/salary/report/service/impl/SalaryStatisticsPushDetailServiceImpl.java b/src/com/engine/salary/report/service/impl/SalaryStatisticsPushDetailServiceImpl.java new file mode 100644 index 000000000..2ad3fc866 --- /dev/null +++ b/src/com/engine/salary/report/service/impl/SalaryStatisticsPushDetailServiceImpl.java @@ -0,0 +1,107 @@ +package com.engine.salary.report.service.impl; + +import cn.hutool.core.util.ObjectUtil; +import com.engine.core.impl.Service; +import com.engine.salary.mapper.report.salaryStatisticsPushDetailMapper; +import com.engine.salary.report.entity.po.SalaryStatisticsPushDetailPO; +import com.engine.salary.report.service.SalaryStatisticsPushDetailService; +import com.engine.salary.util.db.MapperProxyFactory; +import com.google.common.collect.Lists; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang3.math.NumberUtils; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; + +/** + * @author Harryxzy + * @ClassName SalaryStatisticsPushDetailServiceImpl + * @date 2023/09/13 15:13 + * @description + */ +public class SalaryStatisticsPushDetailServiceImpl extends Service implements SalaryStatisticsPushDetailService { + + private salaryStatisticsPushDetailMapper getsalaryStatisticsPushDetailMapper() { + return MapperProxyFactory.getProxy(salaryStatisticsPushDetailMapper.class); + } + + @Override + public List listAll() { + return getsalaryStatisticsPushDetailMapper().listAll(); + } + + @Override + public List listSome(SalaryStatisticsPushDetailPO po) { + return getsalaryStatisticsPushDetailMapper().listSome(po); + } + + @Override + public SalaryStatisticsPushDetailPO getById(Long id) { + return getsalaryStatisticsPushDetailMapper().getById(id); + } + + @Override + public int insertIgnoreNull(SalaryStatisticsPushDetailPO po) { + return getsalaryStatisticsPushDetailMapper().insertIgnoreNull(po); + } + + @Override + public int update(SalaryStatisticsPushDetailPO po) { + return getsalaryStatisticsPushDetailMapper().update(po); + } + + @Override + public int updateIgnoreNull(SalaryStatisticsPushDetailPO po) { + return getsalaryStatisticsPushDetailMapper().updateIgnoreNull(po); + } + + @Override + public int delete(SalaryStatisticsPushDetailPO po) { + return getsalaryStatisticsPushDetailMapper().delete(po); + } + + /** + * 根据批次id查询 + * @param batchIds + */ + public List queryPushDetailPOByBatchIds(List batchIds) { + if (CollectionUtils.isEmpty(batchIds)) { + return Collections.emptyList(); + } + List> partition = Lists.partition(batchIds, 999); + List list = new ArrayList<>(); + partition.forEach(l -> { + list.addAll(getsalaryStatisticsPushDetailMapper().queryPushDetailPOByBatchId(l)); + }); + return list; + } + + /** + * 根据批次id、员工id查询 + * @param + */ + public List queryPushDetailPOByBatchIdAndEmpIds(Long batchId, List sharedBy) { + if (CollectionUtils.isEmpty(sharedBy) || ObjectUtil.isEmpty(batchId)) { + return Collections.emptyList(); + } + List> partition = Lists.partition(sharedBy, 999); + List list = new ArrayList<>(); + partition.forEach(l -> { + list.addAll(getsalaryStatisticsPushDetailMapper().queryPushDetailPOByBatchIdAndEmpIds(batchId, l)); + }); + return list; + } + + public List getSuccessPushDetailListByReceiver(Long uid) { + List detailList = listSome(SalaryStatisticsPushDetailPO.builder() + .employeeId(uid) + .pushStatus("true") + .deleteType(NumberUtils.INTEGER_ZERO) + .build()); + // 过滤已经撤回的 + return detailList.stream().filter(po -> !(Objects.equals(po.getRebackStatus(), "true"))).collect(Collectors.toList()); + } +} diff --git a/src/com/engine/salary/report/service/impl/SalaryStatisticsPushServiceImpl.java b/src/com/engine/salary/report/service/impl/SalaryStatisticsPushServiceImpl.java new file mode 100644 index 000000000..9f37a181f --- /dev/null +++ b/src/com/engine/salary/report/service/impl/SalaryStatisticsPushServiceImpl.java @@ -0,0 +1,771 @@ +package com.engine.salary.report.service.impl; + +import cn.hutool.core.util.ObjectUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.common.BaseQueryParam; +import com.engine.salary.constant.SalaryDefaultTenantConstant; +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.enums.sicategory.DeleteTypeEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.mapper.report.SalaryStatisticsPushMapper; +import com.engine.salary.report.entity.dto.SalaryStatisticsPushDetail; +import com.engine.salary.report.entity.dto.SalaryStatisticsPushDetailFormDTO; +import com.engine.salary.report.entity.dto.SalaryStatisticsPushDetailTableDTO; +import com.engine.salary.report.entity.dto.SalaryStatisticsPushTableDTO; +import com.engine.salary.report.entity.param.SalaryStatisticsPushDetailParam; +import com.engine.salary.report.entity.param.SalaryStatisticsPushParam; +import com.engine.salary.report.entity.po.SalaryStatisticsPushDetailPO; +import com.engine.salary.report.entity.po.SalaryStatisticsPushPO; +import com.engine.salary.report.entity.po.SalaryStatisticsReportPO; +import com.engine.salary.report.service.SalaryStatisticsPushDetailService; +import com.engine.salary.report.service.SalaryStatisticsPushService; +import com.engine.salary.report.service.SalaryStatisticsReportService; +import com.engine.salary.report.util.ReportTimeUtil; +import com.engine.salary.service.SalaryEmployeeService; +import com.engine.salary.service.TaxAgentService; +import com.engine.salary.service.impl.SalaryEmployeeServiceImpl; +import com.engine.salary.service.impl.TaxAgentServiceImpl; +import com.engine.salary.util.SalaryDateUtil; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.db.IdGenerator; +import com.engine.salary.util.db.MapperProxyFactory; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.util.page.SalaryPageUtil; +import com.google.common.collect.Lists; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import weaver.hrm.User; + +import java.time.LocalDateTime; +import java.util.*; +import java.util.stream.Collectors; + +/** + * @author Harryxzy + * @ClassName SalaryStatisticsPushServiceImpl + * @date 2023/09/11 10:15 + * @description 薪酬统计报表消息推送 + */ +public class SalaryStatisticsPushServiceImpl extends Service implements SalaryStatisticsPushService { + + private SalaryStatisticsPushMapper getSalaryStatisticsPushMapper() { + return MapperProxyFactory.getProxy(SalaryStatisticsPushMapper.class); + } + + private SalaryStatisticsPushDetailService getSalaryStatisticsPushDetailService(User user) { + return ServiceUtil.getService(SalaryStatisticsPushDetailServiceImpl.class, user); + } + + private SalaryEmployeeService getSalaryEmployeeService(User user) { + return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user); + } + + private SalaryStatisticsReportService getSalaryStatisticsReportService(User user) { + return ServiceUtil.getService(SalaryStatisticsReportServiceImpl.class, user); + } + + private TaxAgentService getTaxAgentService(User user) { + return (TaxAgentService) ServiceUtil.getService(TaxAgentServiceImpl.class, user); + } + + @Override + public Map getPushForm() { + Map resultMap = new HashMap<>(); + // items + // 分享报表item + List> reportOptions = buildReportIdsOptions(Long.valueOf(user.getUID())); + resultMap.put("reportOptions", reportOptions); + // data + resultMap.putAll(formData(Long.valueOf(user.getUID()))); + return resultMap; + } + + + private Map formData(Long employeeId) { + Map data = new HashMap<>(); + SalaryStatisticsPushPO pushPO = getListByEmployeeId(employeeId); + data.put("pushTitle", pushPO.getPushTitle()); + data.put("mark", pushPO.getMark()); + if (pushPO.getRemind() == null) { + data.put("remind", "1"); + } else { + data.put("remind", pushPO.getRemind().toString()); + } + return data; + } + + private SalaryStatisticsPushPO getListByEmployeeId(Long uid) { + List list = getSalaryStatisticsPushMapper().listLatestRecordByCreator(uid); + if (CollectionUtils.isEmpty(list)) { + return SalaryStatisticsPushPO.builder().build(); + } + return list.get(0); + } + + + private List> buildReportIdsOptions(Long employeeId) { + List> reportIdsOptions = new ArrayList<>(); + List reportPOS = getSalaryStatisticsReportService(user).listAll(); + // 只能够分享创建人是本人的报表 + reportPOS = reportPOS.stream().filter(po -> po.getCreator().compareTo(employeeId) == 0).collect(Collectors.toList()); + reportPOS.forEach(po -> { + Map option = new HashMap<>(); + option.put("id", po.getId().toString()); + option.put("reportName", po.getReportName()); + reportIdsOptions.add(option); + }); + + return reportIdsOptions; + } + + @Override + public SalaryStatisticsPushDetail getPushDetail(SalaryStatisticsPushDetailParam param) { + SalaryStatisticsPushPO salaryStatisticsPushPO = getSalaryStatisticsPushMapper().getById(param.getId()); + if (Objects.isNull(salaryStatisticsPushPO)) { + throw new SalaryRunTimeException("该分享记录不存在"); + } + SalaryStatisticsPushDetail result = new SalaryStatisticsPushDetail(); + result.setDetailForm(buildDetailForm(salaryStatisticsPushPO)); + result.setDetailTable(buildDetailTable(param)); + return result; + } + + @Override + public void push(SalaryStatisticsPushParam param) { + // 生成分享链接中的id参数 + param.setId(createAndGetBatchId(param)); + sendMsg(param); + } + +// public void configSave(SalaryStatisticsPushParam param, String tenantkey, Long employeeId) { +// if (StringUtils.isNotEmpty(param.getConfig())) { +// CreateRuleEntity createRule = new CreateRuleEntity() +// .setName(SalaryI18nUtil.getI18nLabel(tenantkey, employeeId, 220428, "分享报表")) +// .setUser(new UserEntity(employeeId, tenantkey)) +// .setModule(MessageModule.HRSA) +// .setEvent(MessageEvent.REPORT_SHARING) +// .setBusinessId(param.getBusinessId().toString()) +// .setConfig(param.getConfig()); +// log.info("RuleRest.createRuleV2 -> config ====== {}", param.getConfig()); +// WeaResult weaResult = ruleRest.createRuleV2(createRule); +// SalaryAssert.isTrue(weaResult.isStatus(), SalaryI18nUtil.getI18nLabel(184008, "RPC接口创建规则失败")); +// } +// } + + @Override + public void addSharedPush(SalaryStatisticsPushParam param) { + SalaryStatisticsPushPO pushPO = getSalaryStatisticsPushMapper().getById(param.getId()); + Collection sharedBy = sharedByValid(param.getSharedBy(), param.getId()); + if (CollectionUtils.isEmpty(sharedBy)) { + return; + } + SalaryStatisticsPushParam pushParam = new SalaryStatisticsPushParam(); + pushParam.setReportIds(Arrays.asList(pushPO.getReportIds().split(","))); + pushParam.setPushTitle(pushPO.getPushTitle()); +// pushParam.setEmailAccountId(pushPO.getEmailAccountId()); +// pushParam.setEmailAdress(pushParam.getEmailAdress()); + pushParam.setSharedBy((List) sharedBy); + pushParam.setStartTime(pushPO.getStartTime()); + pushParam.setEndTime(pushPO.getEndTime()); +// pushParam.setPushChannel(Arrays.stream(pushPO.getPushChannel().split(",")).map(Integer::valueOf).collect(Collectors.toList())); + pushParam.setMark(pushPO.getMark()); + pushParam.setId(pushPO.getId()); + sendMsg(pushParam); + } + + public Collection sharedByValid(List sharedBy, Long batchId) { + List list = getSalaryStatisticsPushDetailService(user).queryPushDetailPOByBatchIdAndEmpIds(batchId, sharedBy); + List finalList = list; + // 获取需要分享或重新分享的人 + sharedBy = sharedBy.stream().filter(shareId -> { + List collect = finalList.stream().filter(po -> Objects.equals(po.getEmployeeId(), shareId)).collect(Collectors.toList()); + if (CollectionUtils.isEmpty(collect)) { + return true; + } + boolean enabledSend = collect.stream().anyMatch(po -> Objects.equals(po.getPushStatus(), "true") && !Objects.equals(po.getRebackStatus(), "true")); + return !enabledSend; + + }).collect(Collectors.toList()); + return sharedBy; + } + + public void sendMsg(SalaryStatisticsPushParam param) { + // 获取被分享人 + List receivers = getSalaryEmployeeService(user).getEmployeeByIdsIncludeAccountType(param.getSharedBy()); + // 发送消息 + receivers.forEach(receiver -> { + // 发送消息... + // 发送成功 + doSuccess(receiver, param); + }); + } + + +// @Override +// public void rePush(Long id, Long employeeId, String tenantKey) { +// SalaryStatisticsPushDetailPO detailPO = salaryStatisticsPushDetailMapper.selectById(id); +// SalaryStatisticsPushPO pushPO = salaryStatisticsPushMapper.selectById(detailPO.getBatchId()); +// SalaryStatisticsPushParam param = new SalaryStatisticsPushParam(); +// param.setReportIds(Arrays.asList(pushPO.getReportIds().split(","))); +// param.setPushTitle(pushPO.getPushTitle()); +// param.setEmailAdress(pushPO.getEmailAccount()); +// param.setEmailAccountId(pushPO.getEmailAccountId()); +// param.setSharedBy(Collections.singletonList(detailPO.getEmployeeId())); +// param.setStartTime(pushPO.getStartTime()); +// param.setEndTime(pushPO.getEndTime()); +// param.setPushChannel(Arrays.stream(pushPO.getPushChannel().split(",")).map(Integer::valueOf).collect(Collectors.toList())); +// param.setMark(pushPO.getMark()); +// param.setId(pushPO.getId()); +// sendMsg(param, employeeId, tenantKey); +// } + + @Override + public void cancel(Long id) { + SalaryStatisticsPushDetailPO detailPO = getSalaryStatisticsPushDetailService(user).getById(id); + if (ObjectUtil.isEmpty(detailPO)) { + throw new SalaryRunTimeException("该明细不存在"); + } + cancelSingle(detailPO); + } + + public void cancelSingle(SalaryStatisticsPushDetailPO detailPO) { + // 撤回消息... + // 撤回分享记录 + doCancelResult(detailPO); + } + + @Override + public void cancelAll(Long id) { + // 根据分享批次id,获取所有的分享明细 + List salaryStatisticsPushDetailPOS = getSalaryStatisticsPushDetailService(user).queryPushDetailPOByBatchIds(Collections.singletonList(id)); + salaryStatisticsPushDetailPOS.forEach(po -> cancelSingle(po)); + } + +// public List getSalatyPushDetailPOSBybatchId(Long batchId, String tenantKey) { +// return new LambdaQueryChainWrapper<>(salaryStatisticsPushDetailMapper) +// .eq(SalaryStatisticsPushDetailPO::getTenantKey, tenantKey) +// .eq(SalaryStatisticsPushDetailPO::getBatchId, batchId) +// .eq(SalaryStatisticsPushDetailPO::getDeleteType, DeleteTypeEnum.NOT_DELETED.getValue()) +// .isNull(SalaryStatisticsPushDetailPO::getRebackStatus) +// .list(); +// } +// +// @Override +// public SalaryStatisticsPushPO getById(Long id, String tenantKey) { +// return salaryStatisticsPushMapper.selectById(id); +// } +// +// @Override +// public List getPushDetailsById(Long batchId, String tenantKey) { +// return new LambdaQueryChainWrapper<>(salaryStatisticsPushDetailMapper) +// .eq(SalaryStatisticsPushDetailPO::getTenantKey, tenantKey) +// .eq(SalaryStatisticsPushDetailPO::getDeleteType, DeleteTypeEnum.NOT_DELETED.getValue()) +// .eq(SalaryStatisticsPushDetailPO::getBatchId, batchId) +// .list(); +// } + + + @Override + public void updateReportViewStatus(List batchId, Long uid) { + List salaryStatisticsPushDetailPOS = getSalaryStatisticsPushDetailService(user).queryPushDetailPOByBatchIds(batchId); + salaryStatisticsPushDetailPOS.stream().filter(po -> Objects.equals(po.getPushStatus(), "true") && !(Objects.equals(po.getRebackStatus(), "true")) && Objects.equals(uid, po.getEmployeeId())) + .collect(Collectors.toList()).forEach(e -> { + e.setViewStatus("true"); + e.setUpdateTime(new Date()); + getSalaryStatisticsPushDetailService(user).updateIgnoreNull(e); + }); + } + +// @Override +// public void sendViewedMsg(Long batchId, Long reportId, Long employeeId, String tenantKey) { +// SalaryStatisticsPushPO pushPO = salaryStatisticsPushMapper.selectById(batchId); +// if (!Objects.equals(1, pushPO.getRemind())) { +// return; +// } +// List salaryStatisticsPushDetailPOS = queryPushDetailPOByBatchId(batchId, tenantKey); +// List detailPOList = salaryStatisticsPushDetailPOS.stream().filter(po -> Objects.equals(po.getPushStatus(), "true") && po.getRebackStatus() == null && Objects.equals(employeeId, po.getEmployeeId())).collect(Collectors.toList()); +// if (CollectionUtils.isEmpty(detailPOList)) { +// return; +// } +// SalaryStatisticsPushParam param = new SalaryStatisticsPushParam(); +// param.setPushTitle(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 227925, "报表已查看提醒")); +// param.setSharedBy(Collections.singletonList(pushPO.getCreator())); +// param.setPushChannel(Collections.singletonList(MessageChannelEnum.IM.getType())); +// param.setMark(buildViewMark(pushPO, detailPOList, employeeId, tenantKey)); +// SendMessageEntity entity = buildSendMessage(param, employeeId, tenantKey); +// entity.getEntity().setPcUrl(""); +// entity.getEntity().setH5Url(""); +// entity.getEntity().setPcLinkeType(0); +// entity.getEntity().setH5LinkeType(0); +// List receivers = buildReceivers(param, tenantKey); +// // 发送消息 +// receivers.forEach(receiver -> { +// entity.setReceivers(Collections.singletonList(receiver)); +// try { +// asyncSystemMessageRest.sendMsg(entity); +// } catch (Exception e) { +// log.error("查看消息发送失败", e); +// } +// }); +// } +// +// public String buildViewMark(SalaryStatisticsPushPO pushPO, List detailPOList, Long employeeId, String tenantkey) { +// SimpleEmployee employee = hrmCommonEmployeeService.getById(employeeId); +// if (employee == null) { +// return SalaryI18nUtil.getI18nLabel(tenantkey, employeeId, 227926, "消息创建人已不存在"); +// } +// return employee.getUsername() + +// SalaryI18nUtil.getI18nLabel(tenantkey, employeeId, 227927, "已查看您分享的报表。") + +// SalaryI18nUtil.getI18nLabel(tenantkey, employeeId, 227928, "分享主题:") + +// pushPO.getPushTitle() + "," + +// SalaryI18nUtil.getI18nLabel(tenantkey, employeeId, 233590, "分享时间:") + +// detailPOList.get(0).getPushTime() + +// "。"; +// } +// + + public void doCancelResult(SalaryStatisticsPushDetailPO detailPO) { + // 判断撤回消息是否成功... + // 消息撤回成功的话撤回分享记录 + detailPO.setRebackStatus("true"); + detailPO.setRebackTime(ReportTimeUtil.getFormatLocalDateTime(LocalDateTime.now())); + getSalaryStatisticsPushDetailService(user).updateIgnoreNull(detailPO); + } + + +// public CancleMessageEntity buildCancelMessageEntity(SalaryStatisticsPushDetailPO po, Long employeeId, String tenantKey) { +// SalaryStatisticsPushPO pushPO = salaryStatisticsPushMapper.selectById(po.getBatchId()); +// CancleMessageEntity cancleMessageEntity = new CancleMessageEntity(); +// cancleMessageEntity.setMsgId(po.getMsgId()); +// cancleMessageEntity.setModule(MessageModule.HRSA); +// cancleMessageEntity.setEvent(MessageEvent.REPORT_SHARING); +// cancleMessageEntity.setText(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 221630, "此消息已收回,如有问题,请联系管理员")); +// Entity entity = new Entity(); +// entity.setId(String.valueOf(IdGenerator.generate())); +// entity.setModule(EntityType.hrmsalary.name()); +// entity.setName(pushPO.getPushTitle()); +// cancleMessageEntity.setEntity(entity); +// UserEntity user = new UserEntity(employeeId, tenantKey); +// SimpleEmployee employeeById = hrmCommonEmployeeService.getEmployeeById(employeeId, tenantKey); +// user.setName(employeeById.getUsername()); +// cancleMessageEntity.setOperator(user); +// return cancleMessageEntity; +// } + + public void doSuccess(DataCollectionEmployee receiver, SalaryStatisticsPushParam param) { + List pushDetailByBatchIdAndEmpId = getSalaryStatisticsPushDetailService(user).listSome(SalaryStatisticsPushDetailPO.builder() + .batchId(param.getId()) + .employeeId(receiver.getEmployeeId()) + .build()); + Date now = new Date(); + if (CollectionUtils.isEmpty(pushDetailByBatchIdAndEmpId)) { + SalaryStatisticsPushDetailPO detailPO = SalaryStatisticsPushDetailPO.builder() + .id(IdGenerator.generate()) + .batchId(param.getId()) +// .msgId(result.getData()) + .pushStatus("true") + .pushTime(ReportTimeUtil.getFormatLocalDateTime(LocalDateTime.now())) + .deleteType(DeleteTypeEnum.NOT_DELETED.getValue()) + .employeeId(receiver.getEmployeeId()) + .updateTime(now) + .creator(Long.valueOf(user.getUID())) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .build(); + getSalaryStatisticsPushDetailService(user).insertIgnoreNull(detailPO); + } else { + SalaryStatisticsPushDetailPO PO = pushDetailByBatchIdAndEmpId.get(0); + PO.setPushStatus("true"); + PO.setRebackStatus(""); + PO.setRebackTime(""); + PO.setViewStatus("false"); +// PO.setMsgId(result.getData()); + PO.setPushTime(ReportTimeUtil.getFormatLocalDateTime(LocalDateTime.now())); + PO.setUpdateTime(now); + PO.setCreator(Long.valueOf(user.getUID())); + getSalaryStatisticsPushDetailService(user).updateIgnoreNull(PO); + } + } + +// public void delBatchId(Long id) { +// SalaryStatisticsPushPO pushPO = salaryStatisticsPushMapper.selectById(id); +// pushPO.setDeleteType(DeleteTypeEnum.PHYSICAL_DELETED.getValue()); +// salaryStatisticsPushMapper.updateById(pushPO); +// } +// +// public void paramValid(SalaryStatisticsPushParam param, Long employeeId, String tenantKey) { +// channelCheck(param, employeeId, tenantKey); +// emileCheck(param, employeeId, tenantKey); +// bridgeCheck(param, employeeId, tenantKey); +// } + + public Long createAndGetBatchId(SalaryStatisticsPushParam param) { + Date now = new Date(); + SalaryStatisticsPushPO pushPO = SalaryStatisticsPushPO.builder() + .id(IdGenerator.generate()) + .creator(Long.valueOf(user.getUID())) + .deleteType(DeleteTypeEnum.NOT_DELETED.getValue()) + .createTime(now) + .updateTime(now) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) +// .pushChannel(buildChannelString(param)) + .startTime(param.getStartTime()) + .endTime(param.getEndTime()) + .remind(param.getRemind()) +// .emailAccount(param.getEmailAdress()) +// .emailAccountId(param.getEmailAccountId()) + .mark(param.getMark()) +// .pushTitle(param.getPushTitle()) + .reportIds(String.join(",", param.getReportIds())) + .build(); + getSalaryStatisticsPushMapper().insertIgnoreNull(pushPO); + return pushPO.getId(); + } + +// public String buildChannelString(SalaryStatisticsPushParam param) { +// Set channelEnums = buildChannel(param); +// List channelType = channelEnums.stream().map(e -> String.valueOf(e.getType())).collect(Collectors.toList()); +// return String.join(",", channelType); +// } +// +// +// public void channelCheck(SalaryStatisticsPushParam param, Long employeeId, String tenantKey) { +// if (CollectionUtils.isEmpty(param.getPushChannel())) { +// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 221582, "至少有一个发送通道")); +// } +// } +// +// public void emileCheck(SalaryStatisticsPushParam param, Long employeeId, String tenantKey) { +// if (param.getPushChannel().contains(MessageChannelEnum.EMAIL.getType())) { +// if (!isEnableEmail(tenantKey)) { +// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 221580, "邮件模块未采购,不可使用邮件通道!")); +// } +// // 接收者邮箱校验 +// List employeeByIds = hrmCommonEmployeeService.getEmployeeByIds(param.getSharedBy(), tenantKey); +// List usernameList = new ArrayList<>(); +// employeeByIds.forEach(employee -> { +// if (StringUtils.isEmpty(employee.getEmail())) { +// usernameList.add(employee.getUsername()); +// } +// }); +// if (CollectionUtils.isNotEmpty(usernameList)) { +// throw new SalaryRunTimeException(String.join(",", usernameList) + SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 221578, "没有可用邮箱,请先配置再发送!")); +// } +// if (StringUtils.isEmpty(param.getEmailAdress())) { +// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 224278, "发送邮箱不可为空")); +// } +// } +// } +// +// public void bridgeCheck(SalaryStatisticsPushParam param, Long employeeId, String tenantKey) { +// if (param.getPushChannel().contains(MessageChannelEnum.CLOUD_BRIDGE.getType()) && !isEnableEbridge(tenantKey)) { +// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 221581, "云桥模块未采购,不可使用云桥通道!")); +// } +// } +// +// public SendMessageEntity buildSendMessage(SalaryStatisticsPushParam param, Long employeeId, String tenantKey) { +// // 域名 +// param.setDomain(weaverConfigUtils.getValueFromDataMap("primary.domain")); +// SendMessageEntity entity = new SendMessageEntity(); +// // 模块 +// entity.setModule(MessageModule.HRSA); +// // 消息事件 +// entity.setEvent(MessageEvent.REPORT_SHARING); +// // 消息通道 +// entity.setChannels(buildChannel(param)); +// // 主题 +// entity.setText(param.getPushTitle()); +// // 发送者信息 +// entity.setSender(buildSendEntity(employeeId, tenantKey)); +// // 接收者 +// entity.setReceivers(buildReceivers(param, tenantKey)); +// // emile消息体 +// entity.setEmailInfo(buildEmailEntity(param, employeeId, tenantKey)); +// // im消息体 +// entity.setEntity(buildImEntity(param)); +// // 消息内容 im和bridge公用 +// entity.setText(param.getMark()); +// // 云桥 +// entity.setTitle(param.getPushTitle()); +// return entity; +// } +// +// public UserEntity buildSendEntity(Long employeeId, String tenantKey) { +// SimpleEmployee employeeById = hrmCommonEmployeeService.getEmployeeById(employeeId, tenantKey); +// UserEntity userEntity = new UserEntity(); +// userEntity.setEmployeeId(employeeId); +// userEntity.setTenantKey(tenantKey); +// userEntity.setName(employeeById.getUsername()); +// return userEntity; +// } +// +// +// public List buildReceivers(SalaryStatisticsPushParam param, String tenantKey) { +// List simpleEmployeeList = hrmCommonEmployeeService.getEmployeeByIds(param.getSharedBy(), tenantKey); +// return simpleEmployeeList.stream().map(employee -> { +// UserEntity userEntity = new UserEntity(); +// userEntity.setEmployeeId(employee.getEmployeeId()); +// userEntity.setTenantKey(tenantKey); +// userEntity.setEmail(employee.getEmail()); +// return userEntity; +// }).collect(Collectors.toList()); +// } +// +// public Entity buildImEntity(SalaryStatisticsPushParam param) { +// Entity imEntity = new Entity(); +// imEntity.setId(IDGenerator.generateId()); +// imEntity.setName(param.getPushTitle()); +// imEntity.setModule("hrmsalary"); +// imEntity.setPcLinkeType(2); +// imEntity.setH5LinkeType(2); +// imEntity.setPcUrl(buildPcUrl(param)); +// imEntity.setH5Url(buildPcUrl(param)); +// return imEntity; +// } +// +// public String buildPcUrl(SalaryStatisticsPushParam param) { +// return param.getDomain() + String.format("/sp/ebdpage/view/828107636586323968?id=%s&share=true", param.getId()); +// } +// +// public EmailEntity buildEmailEntity(SalaryStatisticsPushParam param, Long employeeId, String tenantKey) { +// EmailEntity emailEntity = new EmailEntity(); +// if (param.getEmailAccountId() == null) { +// return emailEntity; +// } +// emailEntity.setEmailSubject(param.getPushTitle()); +// emailEntity.setEmailContent(buildEmailContent(param)); +// emailEntity.setMailUserAccountId(param.getEmailAccountId()); +// return emailEntity; +// } +// +// public String buildEmailContent(SalaryStatisticsPushParam param) { +// String emailContent = "
" + +// "
" + +// param.getMark() + +// "
" + +// "" + buildPcUrl(param) + "" + +// "
"; +// return emailContent; +// } +// +// public Set buildChannel(SalaryStatisticsPushParam param) { +// Set channelEnums = new HashSet<>(); +// if (param.getPushChannel().contains(MessageChannelEnum.EMAIL.getType())) { +// channelEnums.add(MessageChannelEnum.EMAIL); +// } +// if (param.getPushChannel().contains(MessageChannelEnum.CLOUD_BRIDGE.getType())) { +// channelEnums.add(MessageChannelEnum.CLOUD_BRIDGE); +// } +// if (param.getPushChannel().contains(MessageChannelEnum.IM.getType())) { +// channelEnums.add(MessageChannelEnum.IM); +// } +// return channelEnums; +// } +// +// public Boolean isEnableEmail(String tenantKey) { +//// boolean isPayModule = remoteTenantService.isPayModule(tenantKey, EntityType.email.name()); +//// boolean checkDisplayModule = CollectionUtils.emptyIfNull(baseEnvInfoService.listDisplayModules(tenantKey)).stream().anyMatch(m -> m.equals(EntityType.email.name())); +//// return isPayModule && checkDisplayModule; +// return CollectionUtils.emptyIfNull(baseEnvInfoService.listDisplayModules(tenantKey)).stream().anyMatch(m -> m.equals(EntityType.email.name())); +// } +// +// public Boolean isEnableEbridge(String tenantKey) { +// return CollectionUtils.emptyIfNull(baseEnvInfoService.listDisplayModules(tenantKey)).stream().anyMatch(m -> m.equals("wechatEnterprise")); +// } + + public SalaryStatisticsPushDetailFormDTO buildDetailForm(SalaryStatisticsPushPO salaryStatisticsPushPO) { + List reportIds = Arrays.stream(salaryStatisticsPushPO.getReportIds().split(",")).map(Long::valueOf).collect(Collectors.toList()); + List reportNames = getSalaryStatisticsReportService(user).getByIds(reportIds).stream().map(SalaryStatisticsReportPO::getReportName).collect(Collectors.toList()); + SalaryStatisticsPushDetailFormDTO formDTO = SalaryStatisticsPushDetailFormDTO.builder() + .remark(salaryStatisticsPushPO.getMark()) + .effectiveTime(salaryStatisticsPushPO.getStartTime() + "-" + salaryStatisticsPushPO.getEndTime()) + .reportName(String.join("、", reportNames)) + .build(); + return formDTO; + } + + public PageInfo buildDetailTable(SalaryStatisticsPushDetailParam param) { + List salaryStatisticsPushDetailPOS = getSalaryStatisticsPushDetailService(user).queryPushDetailPOByBatchIds(Arrays.asList(param.getId())); + PageInfo dtoPage = SalaryPageUtil.buildPage(param.getCurrent(), param.getPageSize(), SalaryStatisticsPushDetailTableDTO.class); + List records = salaryStatisticsPushDetailPOS.stream().map(po -> { + return SalaryStatisticsPushDetailTableDTO.builder() + .id(po.getId()) + .pushStatus(buildStatus(po.getPushStatus())) + .pushTime(po.getPushTime()) + .rebackStatus(buildStatus(po.getRebackStatus())) + .viewStatus(buildViewStatus(po.getViewStatus())) + .rebackTime(po.getRebackTime()) + .userName(buildUserName(po.getEmployeeId())) + .employeeId(po.getEmployeeId()) + .build(); + }).collect(Collectors.toList()); + if (StringUtils.isNotEmpty(param.getUserNameSearch())) { + records = records.stream().filter(record -> record.getUserName().contains(param.getUserNameSearch())).collect(Collectors.toList()); + } + dtoPage.setList(records); + dtoPage.setTotal(records.size()); + return dtoPage; + } + + public String buildUserName(Long employeeId) { + DataCollectionEmployee employeeById = getSalaryEmployeeService(user).getEmployeeById(employeeId); + if (employeeById != null) { + return employeeById.getUsername(); + } + return ""; + } + + public String buildViewStatus(String status) { + if (Objects.equals(status, "true")) { + return SalaryI18nUtil.getI18nLabel(0, "已查看"); + } else { + return SalaryI18nUtil.getI18nLabel(0, "未查看"); + } + } + + public String buildStatus(String status) { + if (StringUtils.isEmpty(status)) { + return ""; + } + if (Objects.equals("true", status)) { + return SalaryI18nUtil.getI18nLabel(0, "成功"); + } + if (Objects.equals("false", status)) { + return SalaryI18nUtil.getI18nLabel(0, "失败"); + } + return ""; + } + + @Override + public PageInfo getPushTable(BaseQueryParam param) { + Boolean needAuth = getTaxAgentService(user).isNeedAuth((long) user.getUID()); + List salaryStatisticsPushPOS; + if (needAuth) { + salaryStatisticsPushPOS = getSalaryStatisticsPushMapper().listSome(SalaryStatisticsPushPO.builder().creator((long) user.getUID()).build()); + } else { + salaryStatisticsPushPOS = getSalaryStatisticsPushMapper().listSome(SalaryStatisticsPushPO.builder().build()); + } + int total = salaryStatisticsPushPOS.size(); + salaryStatisticsPushPOS = SalaryPageUtil.subList(param.getCurrent(), param.getPageSize(), salaryStatisticsPushPOS); + PageInfo dtoPageInfo = SalaryPageUtil.buildPage(param.getCurrent(), param.getPageSize(), SalaryStatisticsPushTableDTO.class); + if (CollectionUtils.isNotEmpty(salaryStatisticsPushPOS)) { + // 获取报表名称 key:报表id; value:报表名称 + List reportIds = salaryStatisticsPushPOS.stream().map(po -> Arrays.asList(StringUtils.split(po.getReportIds(), ","))) + .flatMap(Collection::stream).distinct().map(Long::valueOf).collect(Collectors.toList()); + Map statisticsNameMap = SalaryEntityUtil.convert2Map(getSalaryStatisticsReportService(user).getByIds(reportIds), SalaryStatisticsReportPO::getId, SalaryStatisticsReportPO::getReportName); + + // 获取报表分享明细 key:批次id; value:分享明细列表 + List batchIds = salaryStatisticsPushPOS.stream().map(po -> Long.valueOf(po.getId())).collect(Collectors.toList()); + Map> groupByBatchId; + if (CollectionUtils.isNotEmpty(batchIds)) { + groupByBatchId = SalaryEntityUtil.group2Map( + getSalaryStatisticsPushDetailService(user).queryPushDetailPOByBatchIds(batchIds), + SalaryStatisticsPushDetailPO::getBatchId); + } else { + groupByBatchId = Collections.emptyMap(); + } + List dtoList = salaryStatisticsPushPOS.stream().map(po -> { + return SalaryStatisticsPushTableDTO.builder() + .reportName(buildReportName(po.getReportIds(), statisticsNameMap)) + .effectiveTime(StringUtils.isEmpty(po.getStartTime()) ? "" : po.getStartTime() + + "——" + (StringUtils.isEmpty(po.getEndTime()) ? "" : po.getEndTime())) + .id(po.getId()) + .successPush(buildSuccessPush(groupByBatchId.getOrDefault(po.getId(), Collections.emptyList()))) + .sharedView(buildSharedView(groupByBatchId.getOrDefault(po.getId(), Collections.emptyList()))) + .build(); + }).collect(Collectors.toList()); + dtoPageInfo.setList(dtoList); + dtoPageInfo.setTotal(total); + } + return dtoPageInfo; + } + + public String buildSharedView(List list) { + List successEmpIds = list.stream().filter(po -> Objects.equals(po.getPushStatus(), "true") && !(Objects.equals(po.getRebackStatus(), "true"))).map(SalaryStatisticsPushDetailPO::getEmployeeId).collect(Collectors.toList()); + if (CollectionUtils.isEmpty(successEmpIds)) { + return "0/0"; + } + List viewEmpIds = list.stream().filter(po -> Objects.equals(po.getViewStatus(), "true")).map(SalaryStatisticsPushDetailPO::getEmployeeId).collect(Collectors.toList()); + return viewEmpIds.size() + "/" + successEmpIds.size(); + } + + public String buildSuccessPush(List list) { + List employeeIds = list.stream() + .filter(po -> Objects.equals(po.getPushStatus(), "true") && !(Objects.equals(po.getRebackStatus(), "true"))) + .map(SalaryStatisticsPushDetailPO::getEmployeeId).collect(Collectors.toList()); + List employeeByIds = getSalaryEmployeeService(user).getEmployeeByIdsIncludeAccountType(employeeIds); + Set employeeName = employeeByIds.stream().map(DataCollectionEmployee::getUsername).collect(Collectors.toSet()); + return String.join("、", employeeName); + } + + public String buildReportName(String reportIds, Map statisticsNameMap) { + List ids = Arrays.asList(reportIds.split(",")); + List reportName = Lists.newArrayList(); + ids.forEach(id -> { + String name = statisticsNameMap.get(Long.valueOf(id)); + if (name != null) { + reportName.add(name); + } + + }); + return String.join("、", reportName); + } + + @Override + public List getSuccessPushListByReceiver(Long uid) { + List batchIds = getSalaryStatisticsPushDetailService(user).getSuccessPushDetailListByReceiver(uid) + .stream().map(SalaryStatisticsPushDetailPO::getBatchId).collect(Collectors.toList()); + // 根据batchId获取分享记录 + if (CollectionUtils.isEmpty(batchIds)) { + return Collections.emptyList(); + } + List pushList = new ArrayList<>(); + List> partition = Lists.partition((List) batchIds, 1000); + partition.forEach(ids -> { + pushList.addAll(getSalaryStatisticsPushMapper().listSome(SalaryStatisticsPushPO.builder().ids(ids).build())); + }); + return filterReportByTime(pushList); + } + + @Override + public List getPushListByReportIdAndIds(Long reportId, List ids) { + List pushList = getSalaryStatisticsPushMapper().listByReportIdAndIds(reportId.toString(), ids); + pushList = pushList.stream().filter(push -> { + return Arrays.asList(push.getReportIds().split(",")).contains(reportId.toString()); + }).collect(Collectors.toList()); + return pushList; + } + + List filterReportByTime(List pushList) { + // 报表分享时间校验 + String formatLocalDateTime = SalaryDateUtil.getFormatLocalDate(LocalDateTime.now()); + List result = pushList.stream().filter(pushPO -> { + if ((StringUtils.isNotBlank(pushPO.getStartTime()) && pushPO.getStartTime().compareTo(formatLocalDateTime) > 0) || (StringUtils.isNotEmpty(pushPO.getEndTime()) && pushPO.getEndTime().compareTo(formatLocalDateTime) < 0)) { + return false; + } + return true; + }).collect(Collectors.toList()); + return result; + } + + @Override + public List shareReportValid(Long reportId, Long uid) { + // 获取该员工所有被分享成功的明细 + List successPushDetailList = getSalaryStatisticsPushDetailService(user).getSuccessPushDetailListByReceiver(uid); + // 根据报表id,分享批次id查询分享批次信息 + List batchIds = successPushDetailList.stream().map(SalaryStatisticsPushDetailPO::getBatchId).collect(Collectors.toList()); + List pushList = getPushListByReportIdAndIds(reportId, batchIds); + if (CollectionUtils.isEmpty(pushList)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "暂无权限查看该报表")); + } + // 校验是否在分享的有效时间内 + pushList = filterReportByTime(pushList); + if (CollectionUtils.isEmpty(pushList)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "该报表的分享不在有效期内,无法查看")); + } + return pushList; + } +} + + diff --git a/src/com/engine/salary/report/service/impl/SalaryStatisticsReportServiceImpl.java b/src/com/engine/salary/report/service/impl/SalaryStatisticsReportServiceImpl.java new file mode 100644 index 000000000..c2d62d0a6 --- /dev/null +++ b/src/com/engine/salary/report/service/impl/SalaryStatisticsReportServiceImpl.java @@ -0,0 +1,2220 @@ +package com.engine.salary.report.service.impl; + +import com.alibaba.fastjson.JSON; +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.cache.SalaryCacheKey; +import com.engine.salary.config.SalaryElogConfig; +import com.engine.salary.constant.SalaryDefaultTenantConstant; +import com.engine.hrmelog.entity.dto.LoggerContext; +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.hrm.dto.EmployeeInfoExpandDTO; +import com.engine.salary.entity.hrm.dto.FieldSetting; +import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO; +import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO; +import com.engine.salary.entity.salaryacct.po.SalaryAcctResultPO; +import com.engine.salary.entity.salarysob.po.SalarySobPO; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import com.engine.salary.enums.OperateTypeEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.mapper.report.SalaryStatisticsReportMapper; +import com.engine.salary.report.common.constant.SalaryConstant; +import com.engine.salary.report.common.constant.SalaryStatisticsDimensionConstant; +import com.engine.salary.report.entity.bo.SalaryStatisticsReportBO; +import com.engine.salary.report.entity.dto.SalaryStatisticsReportDataDTO; +import com.engine.salary.report.entity.param.*; +import com.engine.salary.report.entity.po.SalaryStatisticsDimensionPO; +import com.engine.salary.report.entity.po.SalaryStatisticsItemPO; +import com.engine.salary.report.entity.po.SalaryStatisticsReportPO; +import com.engine.salary.report.enums.SalaryStatisticsDimensionTypeEnum; +import com.engine.salary.report.service.SalaryStatisticsDimensionService; +import com.engine.salary.report.service.SalaryStatisticsItemService; +import com.engine.salary.report.service.SalaryStatisticsReportService; +import com.engine.salary.report.util.ReportTimeUtil; +import com.engine.salary.service.*; +import com.engine.salary.service.impl.*; +import com.engine.salary.sys.service.SalarySysConfService; +import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl; +import com.engine.salary.util.*; +import com.engine.salary.util.db.IdGenerator; +import com.engine.salary.util.db.MapperProxyFactory; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.util.page.SalaryPageUtil; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.google.common.collect.Sets; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.math.NumberUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.BeanUtils; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.wechat.util.Utils; + +import java.util.*; +import java.util.stream.Collectors; + +import static com.engine.salary.sys.constant.SalarySysConstant.REPORT_ORGANIZATIN_TYPE; + +/** + * 薪酬统计报表 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SalaryStatisticsReportServiceImpl extends Service implements SalaryStatisticsReportService { + + private static final Logger log = LoggerFactory.getLogger(SalaryStatisticsReportServiceImpl.class); + + public static final String DM = "dimension"; + public static final String NOW_INFO = "nowInfoList"; + public static final String LAST_INFO = "lastInfoList"; + public static final String SAME_INFO = "sameInfoList"; + + private final boolean isRealOrg = "1".equals(getSalarySysConfService(user).getValueByCode(REPORT_ORGANIZATIN_TYPE)); + + private SalaryStatisticsReportMapper getSalaryStatisticsReportMapper() { + return MapperProxyFactory.getProxy(SalaryStatisticsReportMapper.class); + } + + private SalaryStatisticsDimensionService getSalaryStatisticsDimensionService(User user) { + return ServiceUtil.getService(SalaryStatisticsDimensionServiceImpl.class, user); + } + + private SalaryStatisticsItemService getSalaryStatisticsItemService(User user) { + return ServiceUtil.getService(SalaryStatisticsItemServiceImpl.class, user); + } + + private SalaryAcctEmployeeService getSalaryAcctEmployeeService(User user) { + return ServiceUtil.getService(SalaryAcctEmployeeServiceImpl.class, user); + } + + private SalaryAcctResultService getSalaryAcctResultService(User user) { + return ServiceUtil.getService(SalaryAcctResultServiceImpl.class, user); + } + + private TaxAgentService getTaxAgentService(User user) { + return ServiceUtil.getService(TaxAgentServiceImpl.class, user); + } + + private SalaryEmployeeService getSalaryEmployeeService(User user) { + return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user); + } + + private SalarySobService getSalarySobService(User user) { + return ServiceUtil.getService(SalarySobServiceImpl.class, user); + } + + private SalaryAcctRecordService getSalaryAcctRecordService(User user) { + return ServiceUtil.getService(SalaryAcctRecordServiceImpl.class, user); + } + + private SalaryCacheService getSalaryCacheService(User user) { + return ServiceUtil.getService(SalaryCacheServiceImpl.class, user); + } + + private SalarySysConfService getSalarySysConfService(User user) { + return ServiceUtil.getService(SalarySysConfServiceImpl.class, user); + } +// private ExtEmployeeService extEmployeeService; +// +// private HrmCommonEmployeeService hrmCommonEmployeeService; +// +// private HrmJobCallRemoteService hrmJobCallRemoteService; +// +// private RemoteUserInfoService remoteUserInfoService; +// +// private HrmCommonHrmStatusService hrmCommonHrmStatusService; +// (name = "salaryStatReportLoggerTemplate") +// private LoggerTemplate salaryStatReportLoggerTemplate; + + @Override + public List listAll() { + return getSalaryStatisticsReportMapper().listAll(); + } + + @Override + public List list() { + Boolean needAuth = getTaxAgentService(user).isNeedAuth((long) user.getUID()); + if (needAuth) { + Boolean adminEnable = getTaxAgentService(user).isAdminEnable((long) user.getUID()); + if (!adminEnable) { + return new ArrayList<>(); + } + } + + return getSalaryStatisticsReportMapper().listSome(SalaryStatisticsReportPO.builder().build()); + } + + @Override + public List listByCreator(Long uid) { + Boolean needAuth = getTaxAgentService(user).isNeedAuth((long) user.getUID()); + if (needAuth) { + return getSalaryStatisticsReportMapper().listSome(SalaryStatisticsReportPO.builder().creator(uid).build()); + } + + return getSalaryStatisticsReportMapper().listSome(SalaryStatisticsReportPO.builder().build()); + } + + @Override + public SalaryStatisticsReportPO getById(Long id) { + return getSalaryStatisticsReportMapper().getById(id); + } + + @Override + public List getByIds(List ids) { + if (CollectionUtils.isEmpty(ids)) { + return Collections.emptyList(); + } + return getSalaryStatisticsReportMapper().listSome(SalaryStatisticsReportPO.builder().ids(ids).build()); + } + + /** + * 根据名称模糊查询 + * + * @param fieldName + * @return + */ + private List listByName(String fieldName) { + return getSalaryStatisticsReportMapper().listSome(SalaryStatisticsReportPO.builder().reportName(fieldName).build()); + } + + @Override + public String save(SalaryStatisticsReportSaveParam saveParam) { + SalaryStatisticsReportSaveParam.checkParam(saveParam); + + Date now = new Date(); + if (saveParam.getId() != null) { + SalaryStatisticsReportPO po = this.getById(saveParam.getId()); + if (po == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(161845, "薪酬统计报表不存在")); + } + List list = listByName(saveParam.getReportName()); + boolean nameExist = list.stream().anyMatch(e -> !Objects.equals(e.getId(), saveParam.getId())); + if (nameExist) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98080, "名称不允许重复")); + } + SalaryStatisticsReportPO poNew = new SalaryStatisticsReportPO(); + BeanUtils.copyProperties(po, poNew); + poNew.setReportName(saveParam.getReportName()); + poNew.setDimension(StringUtils.join(saveParam.getDimensionIds(), ",")); + this.getSalaryStatisticsReportMapper().updateIgnoreNull(poNew); + + // 记录日志 + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(poNew.getId())); + loggerContext.setTargetName(poNew.getReportName()); + loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "更新报表")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "更新报表")); + loggerContext.setOldValues(po); + loggerContext.setNewValues(poNew); + SalaryElogConfig.salaryStatReportLoggerTemplate.write(loggerContext); + } else { + List list = listByName(saveParam.getReportName()); + if (CollectionUtils.isNotEmpty(list)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98080, "名称不允许重复")); + } + Long id = IdGenerator.generate(); + SalaryStatisticsReportPO poNew = SalaryStatisticsReportPO.builder().id(id).reportName(saveParam.getReportName()).dimension(StringUtils.join(saveParam.getDimensionIds(), ",")).createTime(now).creator((long) user.getUID()).updateTime(now).deleteType(0).tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY).salaryStartMonth(SalaryDateUtil.getFirstDayDateOfYear(new Date())).salaryEndMonth(SalaryDateUtil.getLastDayOfYear(new Date())).build(); + getSalaryStatisticsReportMapper().insertIgnoreNull(poNew); + + // 记录日志 + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(poNew.getId())); + loggerContext.setTargetName(poNew.getReportName()); + loggerContext.setOperateType(OperateTypeEnum.ADD.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "新增报表")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "新增报表")); + loggerContext.setNewValues(poNew); + SalaryElogConfig.salaryStatReportLoggerTemplate.write(loggerContext); + } + return StringUtils.EMPTY; + } + + @Override + public String saveSearchCondition(SalaryStatisticsSearchConditionSaveParam param) { + SalaryAssert.notNull(param.getId(), SalaryI18nUtil.getI18nLabel(152562, "报表id不能为空")); + if (Objects.isNull(param.getSalaryStartMonth()) || Objects.isNull(param.getSalaryEndMonth())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100294, "薪资所属月必传")); + } + if ((CollectionUtils.isNotEmpty(param.getTaxAgent()) && param.getTaxAgent().size() > 10) + || (CollectionUtils.isNotEmpty(param.getIncomeCategory()) && param.getIncomeCategory().size() > 10) + || (CollectionUtils.isNotEmpty(param.getSubCompany()) && param.getSubCompany().size() > 10) + || (CollectionUtils.isNotEmpty(param.getGrade()) && param.getGrade().size() > 10) + || (CollectionUtils.isNotEmpty(param.getPosition()) && param.getPosition().size() > 10) + || (CollectionUtils.isNotEmpty(param.getStatus()) && param.getStatus().size() > 10) + || (CollectionUtils.isNotEmpty(param.getEmployee()) && param.getEmployee().size() > 10)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(182014, "统计数据范围条件数量过多")); + } + + SalaryStatisticsReportPO po = getById(param.getId()); + SalaryStatisticsReportPO oldPO = new SalaryStatisticsReportPO(); + BeanUtils.copyProperties(po, oldPO); + SalaryAssert.notNull(po, SalaryI18nUtil.getI18nLabel(152563, "报表不存在")); + po.setSalaryStartMonth(param.getSalaryStartMonth()); + po.setSalaryEndMonth(param.getSalaryEndMonth()); + + if (param.getTaxAgent() != null) { + po.setTaxAgentSetting(JSON.toJSONString(param.getTaxAgent())); + } + if (param.getSalarySob() != null) { + po.setSalarySobSetting(JSON.toJSONString(param.getSalarySob())); + } + if (param.getIncomeCategory() != null) { + po.setIncomeCategorySetting(JSON.toJSONString(param.getIncomeCategory())); + } + if (param.getSubCompany() != null) { + po.setSubCompanySetting(JSON.toJSONString(param.getSubCompany())); + } + if (param.getDepartment() != null) { + po.setDepartSetting(JSON.toJSONString(param.getDepartment())); + } + if (param.getGrade() != null) { + po.setGradeSetting(JSON.toJSONString(param.getGrade())); + } + + if (param.getPosition() != null) { + po.setPositionSetting(JSON.toJSONString(param.getPosition())); + } + + if (param.getStatus() != null) { + po.setStatusSetting(JSON.toJSONString(param.getStatus())); + } + + if (param.getEmployee() != null) { + po.setEmployeeSetting(JSON.toJSONString(param.getEmployee())); + } + + if (param.getHiredate() != null) { + po.setHiredateSetting(JSON.toJSONString(param.getHiredate())); + } + if (param.getLeavedate() != null) { + po.setLeavedateSetting(JSON.toJSONString(param.getLeavedate())); + } + + po.setTimeType(param.getTimeType()); + + getSalaryStatisticsReportMapper().updateIgnoreNull(po); + + // 获取自定义统计项目 + List salaryStatisticsItemList = getSalaryStatisticsItemService(user).listByStatisticsReportId(po.getId()); + + salaryStatisticsItemList.forEach(e -> param.getItems().stream().filter(i -> i.getId().equals(e.getId())).findFirst().ifPresent(salaryStatisticsItem -> { + e.setUnitType(salaryStatisticsItem.getUnitType()); + e.setIndexValue(salaryStatisticsItem.getIndexValue()); + })); + getSalaryStatisticsItemService(user).saveOrUpdateBatch(salaryStatisticsItemList); + + //记录日志 + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(po.getId())); + loggerContext.setTargetName(po.getReportName()); + loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "更新报表")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "更新报表")); + loggerContext.setOldValues(oldPO); + loggerContext.setNewValues(po); + SalaryElogConfig.salaryStatReportLoggerTemplate.write(loggerContext); + return StringUtils.EMPTY; + } + + @Override + public Map delete(Collection ids) { + if (CollectionUtils.isEmpty(ids)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(84026, "参数错误")); + } + int total = ids.size(); + List list = getSalaryStatisticsReportMapper().listSome(SalaryStatisticsReportPO.builder().ids(ids).build()); + + int success = list.size(); + if (success > 0) { + List deleteIds = list.stream().map(SalaryStatisticsReportPO::getId).collect(Collectors.toList()); + //删除报表 + getSalaryStatisticsReportMapper().deleteByIds(deleteIds); + //删除薪资项 + getSalaryStatisticsItemService(user).deleteByReportIds(deleteIds); + list.forEach(e -> { + // 记录日志 + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(e.getId())); + loggerContext.setTargetName(e.getReportName()); + loggerContext.setOperateType(OperateTypeEnum.DELETE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "删除报表")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "删除报表") + e.getReportName()); + SalaryElogConfig.salaryStatReportLoggerTemplate.write(loggerContext); + }); + } + + Map resultMap = new HashMap<>(2); + String resultMsg = SalaryI18nUtil.getI18nLabel(94620, "操作成功"); + String resultType = "success"; + // 单个设为定薪提示 + if (total > 1) { + resultMsg = SalaryI18nUtil.getI18nLabel(134807, "成功条数") + ": " + (success) + "; " + SalaryI18nUtil.getI18nLabel(134808, "失败条数") + ": " + (total - success); + if ((total - success) > 0) { + resultType = "info"; + } + } else if (total == 1 && success < 1) { + resultType = "info"; + } + resultMap.put("type", resultType); + resultMap.put("msg", resultMsg); + return resultMap; + } + + @Override + public void duplicate(Long id) { + long uid = user.getUID(); + Date now = new Date(); + + SalaryStatisticsReportPO po = getById(id); + SalaryAssert.notNull(po, SalaryI18nUtil.getI18nLabel(152563, "报表不存在")); + + po.setId(IdGenerator.generate()); + po.setCreator(uid); + po.setCreateTime(now); + po.setUpdateTime(now); + po.setReportName(po.getReportName() + "_copy"); + + getSalaryStatisticsReportMapper().insertIgnoreNull(po); + + List itemPOS = getSalaryStatisticsItemService(user).listByStatisticsReportId(id); + List itemList = itemPOS.stream().map(item -> { + item.setId(IdGenerator.generate()); + item.setStatReportId(po.getId()); + item.setCreator(uid); + item.setCreateTime(now); + item.setUpdateTime(now); + return item; + }).collect(Collectors.toList()); + getSalaryStatisticsItemService(user).saveOrUpdateBatch(itemList); + + // 记录日志 + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(po.getId())); + loggerContext.setTargetName(po.getReportName()); + loggerContext.setOperateType(OperateTypeEnum.ADD.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "新增报表")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "新增报表")); + loggerContext.setNewValues(po); + SalaryElogConfig.salaryStatReportLoggerTemplate.write(loggerContext); + } + + @Override + public PageInfo> buildReportRecords(SalaryStatisticsDimensionPO dimension, SalaryStatisticsReportDataQueryParam param, List salaryStatisticsItemList) { + Map checkMap = SalaryStatisticsReportBO.checkLoad(salaryStatisticsItemList); + + // 获取本期报表分权后的核算人员 + List list = getSalaryAcctEmployeeService(user).listBySalaryStatisticsReportParam(param); + SalaryStatisticsReportDataQueryParam lastParam = SalaryStatisticsReportBO.lastParamConvert(param, dimension); + // 获取上期报表分权后的核算人员 + List lastList = checkMap.get("isLast") ? getSalaryAcctEmployeeService(user).listBySalaryStatisticsReportParam(lastParam) : Lists.newArrayList(); + SalaryStatisticsReportDataQueryParam sameParam = SalaryStatisticsReportBO.sameParamConvert(param); + // 获取去年同期报表分权后的核算人员 + List sameList = checkMap.get("isSame") ? getSalaryAcctEmployeeService(user).listBySalaryStatisticsReportParam(sameParam) : Lists.newArrayList(); + + SalaryStatisticsReportDataDTO salaryStatisticsReportData = SalaryStatisticsReportDataDTO.builder().list(list).lastList(lastList).sameList(sameList).salaryStatisticsItemList(salaryStatisticsItemList).employeeId((long) user.getUID()).tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY).build(); + + List allList = Lists.newArrayList(); + allList.addAll(list); + allList.addAll(lastList); + allList.addAll(sameList); + List salaryAcctEmployeeIds = allList.stream().map(SalaryAcctEmployeePO::getId).collect(Collectors.toList()); + List salaryAcctResultValues = getSalaryAcctResultService(user).listBySalaryAcctEmployeeIds(salaryAcctEmployeeIds); +// Map> salaryAcctResultValueMap = SalaryEntityUtil.convert2Map(); + Map> salaryAcctEmpResultMap = SalaryEntityUtil.group2Map(salaryAcctResultValues, SalaryAcctResultPO::getSalaryAcctEmpId); + Map> map = new HashMap<>(); + salaryAcctEmpResultMap.forEach((k, v) -> { + Map collect = v.stream().collect(Collectors.toMap(p -> Util.null2String(p.getSalaryItemId()), p -> Util.null2String(p.getResultValue()), (key1, key2) -> key2)); + map.put(k, collect); + }); + + // 根据统计维度进行计算 + return calculateReportRecordsByDimension(dimension, param, salaryStatisticsReportData, map); + } + + @Override + public PageInfo> buildDataPerspectiveRecords(SalaryStatisticsDataPerspectiveQueryParam param, SalaryStatisticsReportPO reportPO, SalaryStatisticsDimensionPO dimension, List salaryStatisticsItemPOS) { + // 获取报表统计薪资项目 + List salaryItemIds = salaryStatisticsItemPOS.stream().filter(item -> StringUtils.isNotBlank(item.getItemValue())).map(p -> p.getItemValue().split(",")).flatMap(Arrays::stream).map(Long::valueOf).collect(Collectors.toList()); + // 参数转换 + String salaryStartMonth = param.getSalaryStartMonth(); + if (salaryStartMonth == null) { + param.setSalaryStartMonth(SalaryDateUtil.getFormatYearMonth(reportPO.getSalaryStartMonth())); + } else { + param.setSalaryStartMonth(SalaryDateUtil.getFormatYearMonth(SalaryDateUtil.dateStrToLocalDate(salaryStartMonth))); + } + String salaryEndMonth = param.getSalaryEndMonth(); + if (salaryEndMonth == null) { + param.setSalaryEndMonth(SalaryDateUtil.getFormatYearMonth(reportPO.getSalaryEndMonth())); + } else { + param.setSalaryEndMonth(SalaryDateUtil.getFormatYearMonth(SalaryDateUtil.dateStrToLocalDate(salaryEndMonth))); + } + String key = "id"; + if (reportPO.getTaxAgentSetting() != null) { + param.setTaxAgent(((List) JSON.parseArray(reportPO.getTaxAgentSetting(), Map.class)).stream().map(m -> Long.valueOf(m.get(key).toString())).collect(Collectors.toList())); + } + if (reportPO.getSubCompanySetting() != null) { + param.setSubCompany(((List) JSON.parseArray(reportPO.getSubCompanySetting(), Map.class)).stream().map(m -> Long.valueOf(m.get(key).toString())).collect(Collectors.toList())); + } + if (reportPO.getDepartSetting() != null) { + param.setDepart(((List) JSON.parseArray(reportPO.getDepartSetting(), Map.class)).stream().map(m -> Long.valueOf(m.get(key).toString())).collect(Collectors.toList())); + } + if (reportPO.getEmployeeSetting() != null) { + param.setEmployee(((List) JSON.parseArray(reportPO.getEmployeeSetting(), Map.class)).stream().map(m -> Long.valueOf(m.get(key).toString())).collect(Collectors.toList())); + } + if (reportPO.getHiredateSetting() != null) { + param.setHiredate(JSON.parseArray(reportPO.getHiredateSetting(), Date.class)); + } + SalaryStatisticsReportDataQueryParam queryParam = new SalaryStatisticsReportDataQueryParam(); + com.mzlion.core.utils.BeanUtils.copyProperties(param, queryParam); + // 获取本期报表分权后的核算人员 + List salaryAcctEmployeeList = getSalaryAcctEmployeeService(user).listBySalaryStatisticsReportParam(queryParam); + + // 设置dimensionValue为维度值 + SalaryStatisticsReportDataDTO salaryStatisticsReportData = SalaryStatisticsReportDataDTO.builder() + .list(salaryAcctEmployeeList) + .lastList(Collections.emptyList()) + .sameList(Collections.emptyList()) + .salaryStatisticsItemList(salaryStatisticsItemPOS) + .employeeId((long) user.getUID()) + .dimensionValue(param.getDimensionValue()) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .build(); + + Map> resultMap = new HashMap<>(); + List salaryAcctEmployeeIds = salaryAcctEmployeeList.stream().map(SalaryAcctEmployeePO::getId).collect(Collectors.toList()); + if (NumberUtils.isCreatable(dimension.getDimCode())) { + List salaryAcctResultValues = getSalaryAcctResultService(user).listByAcctEmployeeIdsAndSalaryItemIds(salaryAcctEmployeeIds, Collections.singleton(Long.valueOf(dimension.getDimCode()))); + List finalSalaryAcctEmpIds = getSalaryAcctResultService(user).listAcctEmpIdByAcctEmpId(salaryAcctEmployeeIds); + Map> salaryAcctEmpResultMap = SalaryEntityUtil.group2Map(salaryAcctResultValues, SalaryAcctResultPO::getSalaryAcctEmpId); + salaryAcctEmpResultMap.forEach((k, v) -> { + Map collect = v.stream().collect(Collectors.toMap(p -> Util.null2String(p.getSalaryItemId()), SalaryAcctResultPO::getResultValue, (key1, key2) -> key2)); + resultMap.put(k, collect); + }); + salaryAcctEmployeeIds.stream().forEach(id -> { + if (!resultMap.containsKey(id) && finalSalaryAcctEmpIds.contains(id)) + resultMap.put(id, Collections.emptyMap()); + }); + } + + + // 获取根据维度值过滤出的本次核算人员信息 + calculateReportRecordsByDimension(dimension, SalaryStatisticsReportDataQueryParam.builder().build(), salaryStatisticsReportData, resultMap); + List listByDimensionValue = salaryStatisticsReportData.getListByDimensionValue(); + if (CollectionUtils.isEmpty(listByDimensionValue)) { + throw new SalaryRunTimeException("该维度值中无数据!"); + } + // 同一个人放在一起 + listByDimensionValue = listByDimensionValue.stream().sorted(Comparator.comparing(SalaryAcctEmployeePO::getEmployeeId)).collect(Collectors.toList()); + List salaryAcctEmployeePOList = SalaryPageUtil.subList(param.getCurrent(), param.getPageSize(), listByDimensionValue); + + // 获取此分页的核算人员 + List pageSalaryAcctEmployeeIds = salaryAcctEmployeePOList.stream().map(SalaryAcctEmployeePO::getId).collect(Collectors.toList()); + // 获取核算结果 + List salaryAcctResultValues = getSalaryAcctResultService(user).listByAcctEmployeeIdsAndSalaryItemIds(pageSalaryAcctEmployeeIds, salaryItemIds); + // 封装核算结果 + Map> salaryAcctEmpResultMap = SalaryEntityUtil.group2Map(salaryAcctResultValues, SalaryAcctResultPO::getSalaryAcctEmpId); + Map> map = new HashMap<>(); + salaryAcctEmpResultMap.forEach((k, v) -> { + Map collect = v.stream().collect(Collectors.toMap(p -> Util.null2String(p.getSalaryItemId()), p -> Util.null2String(p.getResultValue()), (key1, key2) -> key2)); + map.put(k, collect); + }); + + // 构建核算结果数据 + List> records = buildResultRecords(salaryAcctEmployeePOList, map); + PageInfo> pageInfo = SalaryPageUtil.buildPage(param.getCurrent(), param.getPageSize()); + pageInfo.setTotal(listByDimensionValue.size()); + pageInfo.setList(records); + return pageInfo; + } + + @Override + public void removeReportCache() { + //获取所有缓存报表的id + String salaryReportIds = Utils.null2String(getSalaryCacheService(user).get(SalaryCacheKey.SALARY_REPORT_IDS)); + if (StringUtils.isNotBlank(salaryReportIds)) { + Arrays.asList(salaryReportIds.split(",")).forEach(id -> { + if (StringUtils.isNotBlank(id)) { + //报表下条件id + String salaryReportConditions = getSalaryCacheService(user).get(SalaryCacheKey.SALARY_REPORT_CONDITIONS + id); + if (StringUtils.isNotBlank(salaryReportConditions)) { + Arrays.asList(salaryReportConditions.split(",")).forEach(paramMd5 -> { + if (StringUtils.isNotBlank(paramMd5)) { + //条件对应的结果 + getSalaryCacheService(user).remove(SalaryCacheKey.SALARY_REPORT_DATA + id + "_" + paramMd5); + } + }); + getSalaryCacheService(user).remove(SalaryCacheKey.SALARY_REPORT_CONDITIONS + id); + } + } + }); + getSalaryCacheService(user).remove(SalaryCacheKey.SALARY_REPORT_IDS); + } + + } + + public List getReportCache() { + List report = new ArrayList<>(); + + //获取所有缓存报表的id + String salaryReportIds = Utils.null2String(getSalaryCacheService(user).get(SalaryCacheKey.SALARY_REPORT_IDS)); + if (StringUtils.isNotBlank(salaryReportIds)) { + Arrays.asList(salaryReportIds.split(",")).forEach(id -> { + if (StringUtils.isNotBlank(id)) { + //报表下条件id + String salaryReportConditions = getSalaryCacheService(user).get(SalaryCacheKey.SALARY_REPORT_CONDITIONS + id); + List c = new ArrayList<>(); + if (StringUtils.isNotBlank(salaryReportConditions)) { + Arrays.asList(salaryReportConditions.split(",")).forEach(paramMd5 -> { + if (StringUtils.isNotBlank(paramMd5)) { + Map data = getSalaryCacheService(user).get(SalaryCacheKey.SALARY_REPORT_DATA + paramMd5); + Map kv = new HashMap<>(); + kv.put(paramMd5, data); + c.add(kv); + } + }); + report.add(c); + } + } + }); + } + + return report; + + } + + + /** + * 获取根据维度值过滤出的本次核算人员信息 + * + * @param listByDimensionValue 根据维度筛选后的薪资核算人员 + * @param map 薪资核算结果 + */ + private List> buildResultRecords(List listByDimensionValue, Map> map) { + // 获取人员信息 + Set employeeIds = listByDimensionValue.stream().map(SalaryAcctEmployeePO::getEmployeeId).collect(Collectors.toSet()); + List employeeList = getSalaryEmployeeService(user).listByIds(employeeIds.stream().collect(Collectors.toList())); + Map employeeMap = SalaryEntityUtil.convert2Map(employeeList, DataCollectionEmployee::getEmployeeId); + + List taxAgentList = getTaxAgentService(user).listAll(); + Map taxAgentMap = SalaryEntityUtil.convert2Map(taxAgentList, TaxAgentPO::getId, TaxAgentPO::getName); + + List salarySobPOS = getSalarySobService(user).listAll(); + Map SalarySobMap = SalaryEntityUtil.convert2Map(salarySobPOS, SalarySobPO::getId, SalarySobPO::getName); + + List salaryAcctRecordPOS = getSalaryAcctRecordService(user).listAll(); + Map salaryAcctRecordMap = SalaryEntityUtil.convert2Map(salaryAcctRecordPOS, SalaryAcctRecordPO::getId, SalaryAcctRecordPO::getAcctTimes); + List> resultList = Lists.newArrayList(); + Map resultMap; + for (SalaryAcctEmployeePO se : listByDimensionValue) { + resultMap = Maps.newHashMap(); + Map resultValueMap = Optional.ofNullable(map.get(se.getId())).orElse(Maps.newHashMap()); + Map finalMap = resultMap; + resultValueMap.forEach((k, v) -> { + finalMap.put(k + SalaryConstant.DYNAMIC_SUFFIX, v); + }); + DataCollectionEmployee emp = employeeMap.get(se.getEmployeeId()); + resultMap.put("id", se.getId().toString()); + resultMap.put("userName", emp == null ? "" : emp.getUsername()); + resultMap.put("departmentName", se.getDepartmentName()); + resultMap.put("salaryMonth", SalaryDateUtil.getFormatYearMonth(se.getSalaryMonth())); + resultMap.put("taxAgent", taxAgentMap.get(se.getTaxAgentId())); + resultMap.put("salarySob", SalarySobMap.get(se.getSalarySobId())); + resultMap.put("acctTimes", salaryAcctRecordMap.get(se.getSalaryAcctRecordId())); + resultList.add(resultMap); + } + return resultList; + } + + private PageInfo> calculateReportRecordsByDimension(SalaryStatisticsDimensionPO dimension, SalaryStatisticsReportDataQueryParam param, SalaryStatisticsReportDataDTO data, Map> salaryAcctResultValueMap) { + // 定性 + if (SalaryStatisticsDimensionTypeEnum.QUALITATIVE.getValue().equals(dimension.getDimType())) { + switch (dimension.getDimCode()) { + case SalaryStatisticsDimensionConstant.DM_SALARY_MONTH: + return buildSalaryMonthRecords(data, salaryAcctResultValueMap); + case SalaryStatisticsDimensionConstant.DM_TAX_AGENT: + return buildTaxAgentRecords(data, salaryAcctResultValueMap); +// case SalaryStatisticsDimensionConstant.DM_INCOME_CATEGORY: +// return buildIncomeCategoryRecords(data, salaryAcctResultValueMap); + case SalaryStatisticsDimensionConstant.DM_SUB_COMPANY: + return buildSubComRecords(data, salaryAcctResultValueMap); + case SalaryStatisticsDimensionConstant.DM_DEPARTMENT: + return buildDepartRecords(data, salaryAcctResultValueMap); +// case SalaryStatisticsDimensionConstant.DM_POSITION: +// return buildPositionRecords(data, salaryAcctResultValueMap); +// case SalaryStatisticsDimensionConstant.DM_GRADE: +// return buildGradeRecords(data, salaryAcctResultValueMap); +// case SalaryStatisticsDimensionConstant.DM_HRM_STATUS: +// return buildStatusRecords(data, salaryAcctResultValueMap); +// case SalaryStatisticsDimensionConstant.DM_EMPLOYEE_TYPE: +// return buildTypeRecords(data, salaryAcctResultValueMap); + case SalaryStatisticsDimensionConstant.DM_EMPLOYEE: + return buildEmployeeRecords(param, data, salaryAcctResultValueMap); + case SalaryStatisticsDimensionConstant.DM_QUARTER: + return buildQuarterRecords(data, salaryAcctResultValueMap); + case SalaryStatisticsDimensionConstant.DM_HALF_YEAR: + return buildHalfYearRecords(data, salaryAcctResultValueMap); + case SalaryStatisticsDimensionConstant.DM_YEAR: + return buildYearRecords(data, salaryAcctResultValueMap); +// case SalaryStatisticsDimensionConstant.DM_SEX: +// return buildSexRecords(data, salaryAcctResultValueMap); +// case SalaryStatisticsDimensionConstant.DM_JOB_CALL: +// return buildJobCallRecords(data, salaryAcctResultValueMap); +// case SalaryStatisticsDimensionConstant.DM_SUPERIOR: +// return buildSuperiorRecords(data, salaryAcctResultValueMap); +// case SalaryStatisticsDimensionConstant.DM_MARITAL_STATUS: +// return buildMaritalStatusRecords(data, salaryAcctResultValueMap); +// case SalaryStatisticsDimensionConstant.DM_EDUCATION: +// return buildEducationRecords(data, salaryAcctResultValueMap); +// case SalaryStatisticsDimensionConstant.DM_DEGREE: +// return buildDegreeRecords(data, salaryAcctResultValueMap); +// case SalaryStatisticsDimensionConstant.DM_NATION: +// return buildNationRecords(data, salaryAcctResultValueMap); +// case SalaryStatisticsDimensionConstant.DM_HOUSEHOLD_TYPE: +// return buildHouseholdTypeRecords(data, salaryAcctResultValueMap); +// case SalaryStatisticsDimensionConstant.DM_POLITICS_STATUS: +// return buildPoliticsStatusRecords(data, salaryAcctResultValueMap); +// case SalaryStatisticsDimensionConstant.DM_AGE: +// return buildAgeRecords(data, salaryAcctResultValueMap); + case SalaryStatisticsDimensionConstant.DM_WORK_YEAR: + return buildWorkYearRecords(data, salaryAcctResultValueMap); + case SalaryStatisticsDimensionConstant.DM_COMPANY_YEAR: + return buildCompanyYearRecords(data, salaryAcctResultValueMap); + default: + return buildSalaryItemRecords(dimension, data, salaryAcctResultValueMap); + } + // 定量-组距式分组 + } else if (SalaryStatisticsDimensionTypeEnum.RATION_GROUP_SPACING.getValue().equals(dimension.getDimType())) { + return buildRationGroupSpacing4Records(dimension, data, salaryAcctResultValueMap); + // 定量-单项式分组 + } else if (SalaryStatisticsDimensionTypeEnum.RATION_GROUP_INDIVIDUAL.getValue().equals(dimension.getDimType())) { + return buildRationGroupIndividual4Records(dimension, data, salaryAcctResultValueMap); + } + return new PageInfo<>(); + } + + private PageInfo> buildSalaryMonthRecords(SalaryStatisticsReportDataDTO data, Map> salaryAcctResultValueMap) { + PageInfo> result = new PageInfo<>(); + List> records = new ArrayList<>(); + Map> listMap = data.getList().stream().collect(Collectors.groupingBy(SalaryAcctEmployeePO::getSalaryMonth)); + Map> lastListMap = data.getLastList().stream().collect(Collectors.groupingBy(SalaryAcctEmployeePO::getSalaryMonth)); + Map> sameListMap = data.getSameList().stream().collect(Collectors.groupingBy(SalaryAcctEmployeePO::getSalaryMonth)); + List salaryMonthList = listMap.keySet().stream().sorted().collect(Collectors.toList()); + String dimensionValue = data.getDimensionValue(); + salaryMonthList.forEach(k -> { + if (dimensionValue == null) { + Map temp = new HashMap<>(); + temp.put(DM, SalaryDateUtil.getFormatYearMonth(k)); + temp.putAll(SalaryStatisticsReportBO.calculateItem(listMap.get(k), lastListMap.get(ReportTimeUtil.getLastYearMonth(k)), sameListMap.get(ReportTimeUtil.getSameYearMonth(k)), salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); + records.add(temp); + } else if (StringUtils.equals(dimensionValue, SalaryDateUtil.getFormatYearMonth(k))) { + data.setListByDimensionValue(listMap.get(k)); + } + }); + result.setList(records); + return result; + } + + private PageInfo> buildTaxAgentRecords(SalaryStatisticsReportDataDTO data, Map> salaryAcctResultValueMap) { + PageInfo> result = new PageInfo<>(); + List> records = new ArrayList<>(); + + Map> listMap = data.getList().stream().collect(Collectors.groupingBy(SalaryAcctEmployeePO::getTaxAgentId)); + Map> lastListMap = data.getLastList().stream().collect(Collectors.groupingBy(SalaryAcctEmployeePO::getTaxAgentId)); + Map> sameListMap = data.getSameList().stream().collect(Collectors.groupingBy(SalaryAcctEmployeePO::getTaxAgentId)); + + List taxAgentList = getTaxAgentService(user).listAll(); + Map taxAgentMap = SalaryEntityUtil.convert2Map(taxAgentList, TaxAgentPO::getId, TaxAgentPO::getName); + String dimensionValue = data.getDimensionValue(); + listMap.forEach((k, v) -> { + if (dimensionValue == null) { + Map temp = new HashMap<>(); + temp.put(DM, taxAgentMap.get(k)); + temp.putAll(SalaryStatisticsReportBO.calculateItem(v, lastListMap.get(k), sameListMap.get(k), salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); + records.add(temp); + } else if (StringUtils.equals(dimensionValue, taxAgentMap.get(k))) { + data.setListByDimensionValue(v); + } + }); + + result.setList(records); + return result; + } + + private PageInfo> buildIncomeCategoryRecords(SalaryStatisticsReportDataDTO data, Map> salaryAcctResultValueMap) { + PageInfo> result = new PageInfo<>(); +// List> records = new ArrayList<>(); +// +// Map> listMap = data.getList().stream().collect(Collectors.groupingBy(SalaryAcctEmployeePO::getIncomeCategory)); +// Map> lastListMap = data.getLastList().stream().collect(Collectors.groupingBy(SalaryAcctEmployeePO::getIncomeCategory)); +// Map> sameListMap = data.getSameList().stream().collect(Collectors.groupingBy(SalaryAcctEmployeePO::getIncomeCategory)); +// +// List incomeCategoryList = listMap.keySet().stream().sorted().collect(Collectors.toList()); +// incomeCategoryList.forEach(k -> { +// IncomeCategoryEnum incomeCategory = IncomeCategoryEnum.parseByValue(Integer.parseInt(k)); +// if (Objects.nonNull(incomeCategory)) { +// Map temp = new HashMap<>(); +// temp.put(DM, SalaryI18nUtil.getI18nLabel(incomeCategory.getLabelId(), incomeCategory.getDefaultLabel())); +// temp.putAll(SalaryStatisticsReportBO.calculateItem(listMap.get(k), lastListMap.get(k), sameListMap.get(k), salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); +// records.add(temp); +// } +// }); +// +// result.setList(records); + return result; + } + + private PageInfo> buildSubComRecords(SalaryStatisticsReportDataDTO data, Map> salaryAcctResultValueMap) { + PageInfo> result = new PageInfo<>(); + List> records = new ArrayList<>(); + + List employeeIds = data.getList().stream().map(SalaryAcctEmployeePO::getEmployeeId).distinct().collect(Collectors.toList()); + List lastEmployeeIds = data.getLastList().stream().map(SalaryAcctEmployeePO::getEmployeeId).distinct().collect(Collectors.toList()); + List sameEmployeeIds = data.getSameList().stream().map(SalaryAcctEmployeePO::getEmployeeId).distinct().collect(Collectors.toList()); + + + List comInfos = getSalaryEmployeeService(user).getEmployeeByIdsAll(employeeIds); + Map comInfoMap = SalaryEntityUtil.convert2Map(comInfos, DataCollectionEmployee::getEmployeeId); + List lastComInfos = getSalaryEmployeeService(user).getEmployeeByIdsAll(lastEmployeeIds); + Map lastComInfoMap = SalaryEntityUtil.convert2Map(lastComInfos, DataCollectionEmployee::getEmployeeId); + List sameComInfos = getSalaryEmployeeService(user).getEmployeeByIdsAll(sameEmployeeIds); + Map sameComInfoMap = SalaryEntityUtil.convert2Map(sameComInfos, DataCollectionEmployee::getEmployeeId); + + Set subComIds = new HashSet<>(); + Map empIdSubComMap = new HashMap<>(); + Map subComIdNameMap = new HashMap<>(); + Map lastEmpIdSubComMap = new HashMap<>(); + Map sameEmpIdSubComMap = new HashMap<>(); + + if (isRealOrg) { + comInfoMap.forEach((k, v) -> { + subComIdNameMap.put(v.getSubcompanyid(), v.getSubcompanyName()); + empIdSubComMap.put(k, v.getSubcompanyid()); + subComIds.add(v.getSubcompanyid()); + }); + lastComInfoMap.forEach((k, v) -> { + lastEmpIdSubComMap.put(k, v.getSubcompanyid()); + }); + sameComInfoMap.forEach((k, v) -> { + sameEmpIdSubComMap.put(k, v.getSubcompanyid()); + }); + } else { + data.getList().forEach(employee -> { + if (employee.getSubcompanyId() != null && employee.getSubcompanyId() != null) { + subComIdNameMap.put(employee.getSubcompanyId(), employee.getSubcompanyName()); + subComIds.add(employee.getSubcompanyId()); + empIdSubComMap.put(employee.getEmployeeId(), employee.getSubcompanyId()); + } + }); + data.getLastList().forEach(employee -> { + if (employee.getSubcompanyId() != null && employee.getSubcompanyId() != null) { + lastEmpIdSubComMap.put(employee.getEmployeeId(), employee.getSubcompanyId()); + } + }); + data.getSameList().forEach(employee -> { + if (employee.getSubcompanyId() != null && employee.getSubcompanyId() != null) { + sameEmpIdSubComMap.put(employee.getEmployeeId(), employee.getSubcompanyId()); + } + }); + } + + + String dimensionValue = data.getDimensionValue(); + subComIds.forEach(subComId -> { + if (dimensionValue == null) { + List subComEmployeePOS = data.getList().stream().filter(po -> Objects.equals(po.getSubcompanyId(), subComId)).collect(Collectors.toList()); + List lastSubComEmployeePOS = data.getLastList().stream().filter(po -> Objects.equals(po.getSubcompanyId(), subComId)).collect(Collectors.toList()); + List sameSubComEmployeePOS = data.getSameList().stream().filter(po -> Objects.equals(po.getSubcompanyId(), subComId)).collect(Collectors.toList()); + if (isRealOrg) { + subComEmployeePOS = data.getList().stream().filter(po -> Objects.equals(empIdSubComMap.get(po.getEmployeeId()), subComId)).collect(Collectors.toList()); + lastSubComEmployeePOS = data.getLastList().stream().filter(po -> Objects.equals(lastEmpIdSubComMap.get(po.getEmployeeId()), subComId)).collect(Collectors.toList()); + sameSubComEmployeePOS = data.getSameList().stream().filter(po -> Objects.equals(sameEmpIdSubComMap.get(po.getEmployeeId()), subComId)).collect(Collectors.toList()); + } + Map temp = new HashMap<>(); + temp.put(DM, subComIdNameMap.get(subComId)); + temp.putAll(SalaryStatisticsReportBO.calculateItem(subComEmployeePOS, lastSubComEmployeePOS, sameSubComEmployeePOS, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); + records.add(temp); + } else if (StringUtils.equals(dimensionValue, subComIdNameMap.get(subComId))) { + List subComEmployeePOS = data.getList().stream().filter(po -> Objects.equals(po.getSubcompanyId(), subComId)).collect(Collectors.toList()); + if (isRealOrg) { + subComEmployeePOS = data.getList().stream().filter(po -> Objects.equals(empIdSubComMap.get(po.getEmployeeId()), subComId)).collect(Collectors.toList()); + } + data.setListByDimensionValue(subComEmployeePOS); + } + }); + + if (dimensionValue == null) { + List noGroupingList = data.getList().stream().filter(po -> po.getSubcompanyId() == null).collect(Collectors.toList()); + List lastNoGroupingList = data.getLastList().stream().filter(po -> po.getSubcompanyId() == null).collect(Collectors.toList()); + List sameNoGroupingList = data.getSameList().stream().filter(po -> po.getSubcompanyId() == null).collect(Collectors.toList()); + if (isRealOrg) { + noGroupingList = data.getList().stream().filter(po -> empIdSubComMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); + lastNoGroupingList = data.getLastList().stream().filter(po -> lastEmpIdSubComMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); + sameNoGroupingList = data.getSameList().stream().filter(po -> sameEmpIdSubComMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); + } + + if (CollectionUtils.isNotEmpty(noGroupingList)) { + Map noGrouping = new HashMap<>(); + noGrouping.put(DM, SalaryI18nUtil.getI18nLabel(153462, "无分组")); + noGrouping.putAll(SalaryStatisticsReportBO.calculateItem(noGroupingList, lastNoGroupingList, sameNoGroupingList, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); + records.add(noGrouping); + } + } else if (StringUtils.equals(dimensionValue, "无分组")) { + List noGroupingList = data.getList().stream().filter(po -> empIdSubComMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); + if (isRealOrg) { + noGroupingList = data.getList().stream().filter(po -> po.getSubcompanyId() == null).collect(Collectors.toList()); + } + data.setListByDimensionValue(noGroupingList); + } + + result.setList(records); + return result; + } + + private PageInfo> buildDepartRecords(SalaryStatisticsReportDataDTO data, Map> salaryAcctResultValueMap) { + PageInfo> result = new PageInfo<>(); + List> records = new ArrayList<>(); + + List employeeIds = data.getList().stream().map(SalaryAcctEmployeePO::getEmployeeId).distinct().collect(Collectors.toList()); + List lastEmployeeIds = data.getLastList().stream().map(SalaryAcctEmployeePO::getEmployeeId).distinct().collect(Collectors.toList()); + List sameEmployeeIds = data.getSameList().stream().map(SalaryAcctEmployeePO::getEmployeeId).distinct().collect(Collectors.toList()); + List simpleEmployeeList = getSalaryEmployeeService(user).getEmployeeByIdsAll(employeeIds); + List lastSimpleEmployeeList = getSalaryEmployeeService(user).getEmployeeByIdsAll(lastEmployeeIds); + List sameSimpleEmployeeList = getSalaryEmployeeService(user).getEmployeeByIdsAll(sameEmployeeIds); + + Set departIds = new HashSet<>(); + Map empIdDepartIdMap = new HashMap<>(); + Map lastEmpIdDepartIdMap = new HashMap<>(); + Map sameEmpIdDepartIdMap = new HashMap<>(); + Map departIdNameMap = new HashMap<>(); + if (isRealOrg) { + simpleEmployeeList.forEach(employee -> { + if (employee.getDepartmentName() != null && employee.getDepartmentId() != null) { + departIdNameMap.put(employee.getDepartmentId(), employee.getDepartmentName()); + departIds.add(employee.getDepartmentId()); + empIdDepartIdMap.put(employee.getEmployeeId(), employee.getDepartmentId()); + } + }); + lastSimpleEmployeeList.forEach(employee -> { + if (employee.getDepartmentName() != null && employee.getDepartmentId() != null) { + lastEmpIdDepartIdMap.put(employee.getEmployeeId(), employee.getDepartmentId()); + } + }); + sameSimpleEmployeeList.forEach(employee -> { + if (employee.getDepartmentName() != null && employee.getDepartmentId() != null) { + sameEmpIdDepartIdMap.put(employee.getEmployeeId(), employee.getDepartmentId()); + } + }); + } else { + data.getList().forEach(employee -> { + if (employee.getDepartmentName() != null && employee.getDepartmentId() != null) { + departIdNameMap.put(employee.getDepartmentId(), employee.getDepartmentName()); + departIds.add(employee.getDepartmentId()); + empIdDepartIdMap.put(employee.getEmployeeId(), employee.getDepartmentId()); + } + }); + data.getLastList().forEach(employee -> { + if (employee.getDepartmentName() != null && employee.getDepartmentId() != null) { + lastEmpIdDepartIdMap.put(employee.getEmployeeId(), employee.getDepartmentId()); + } + }); + data.getSameList().forEach(employee -> { + if (employee.getDepartmentName() != null && employee.getDepartmentId() != null) { + sameEmpIdDepartIdMap.put(employee.getEmployeeId(), employee.getDepartmentId()); + } + }); + } + + String dimensionValue = data.getDimensionValue(); + departIds.forEach(departId -> { + if (dimensionValue == null) { + List departEmployeePOS = data.getList().stream().filter(po -> Objects.equals(po.getDepartmentId(), departId)).collect(Collectors.toList()); + List lastDepartEmployeePOS = data.getLastList().stream().filter(po -> Objects.equals(po.getDepartmentId(), departId)).collect(Collectors.toList()); + List sameDepartEmployeePOS = data.getSameList().stream().filter(po -> Objects.equals(po.getDepartmentId(), departId)).collect(Collectors.toList()); + if (isRealOrg) { + departEmployeePOS = data.getList().stream().filter(po -> Objects.equals(empIdDepartIdMap.get(po.getEmployeeId()), departId)).collect(Collectors.toList()); + lastDepartEmployeePOS = data.getLastList().stream().filter(po -> Objects.equals(lastEmpIdDepartIdMap.get(po.getEmployeeId()), departId)).collect(Collectors.toList()); + sameDepartEmployeePOS = data.getSameList().stream().filter(po -> Objects.equals(sameEmpIdDepartIdMap.get(po.getEmployeeId()), departId)).collect(Collectors.toList()); + } + Map temp = new HashMap<>(); + temp.put(DM, departIdNameMap.get(departId)); + temp.putAll(SalaryStatisticsReportBO.calculateItem(departEmployeePOS, lastDepartEmployeePOS, sameDepartEmployeePOS, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); + records.add(temp); + } else if (StringUtils.equals(dimensionValue, departIdNameMap.get(departId))) { + List departEmployeePOS = data.getList().stream().filter(po -> Objects.equals(po.getDepartmentId(), departId)).collect(Collectors.toList()); + if (isRealOrg) { + departEmployeePOS = data.getList().stream().filter(po -> Objects.equals(empIdDepartIdMap.get(po.getEmployeeId()), departId)).collect(Collectors.toList()); + } + data.setListByDimensionValue(departEmployeePOS); + } + }); + + if (dimensionValue == null) { + List noGroupingList = data.getList().stream().filter(po -> po.getDepartmentId() == null).collect(Collectors.toList()); + List lastNoGroupingList = data.getLastList().stream().filter(po -> po.getDepartmentId() == null).collect(Collectors.toList()); + List sameNoGroupingList = data.getSameList().stream().filter(po -> po.getDepartmentId() == null).collect(Collectors.toList()); + if (isRealOrg) { + noGroupingList = data.getList().stream().filter(po -> empIdDepartIdMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); + lastNoGroupingList = data.getLastList().stream().filter(po -> lastEmpIdDepartIdMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); + sameNoGroupingList = data.getSameList().stream().filter(po -> lastEmpIdDepartIdMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); + + } + if (CollectionUtils.isNotEmpty(noGroupingList)) { + Map noGrouping = new HashMap<>(); + noGrouping.put(DM, SalaryI18nUtil.getI18nLabel(153462, "无分组")); + noGrouping.putAll(SalaryStatisticsReportBO.calculateItem(noGroupingList, lastNoGroupingList, sameNoGroupingList, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); + records.add(noGrouping); + } + } else if (StringUtils.equals(dimensionValue, "无分组")) { + List noGroupingList = data.getList().stream().filter(po -> po.getDepartmentId() == null).collect(Collectors.toList()); + if (isRealOrg) { + noGroupingList = data.getList().stream().filter(po -> empIdDepartIdMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); + } + data.setListByDimensionValue(noGroupingList); + } + + result.setList(records); + return result; + } + + private PageInfo> buildPositionRecords(SalaryStatisticsReportDataDTO data, Map> salaryAcctResultValueMap) { + PageInfo> result = new PageInfo<>(); +// List> records = new ArrayList<>(); +// +// List employeeIds = data.getList().stream().map(SalaryAcctEmployeePO::getEmployeeId).distinct().collect(Collectors.toList()); +// List lastEmployeeIds = data.getLastList().stream().map(SalaryAcctEmployeePO::getEmployeeId).distinct().collect(Collectors.toList()); +// List sameEmployeeIds = data.getSameList().stream().map(SalaryAcctEmployeePO::getEmployeeId).distinct().collect(Collectors.toList()); +// List simpleEmployeeList = hrmCommonEmployeeService.getEmployeeByIds(employeeIds, data.getTenantKey()); +// List lastSimpleEmployeeList = hrmCommonEmployeeService.getEmployeeByIds(lastEmployeeIds, data.getTenantKey()); +// List sameSimpleEmployeeList = hrmCommonEmployeeService.getEmployeeByIds(sameEmployeeIds, data.getTenantKey()); +// +// Set positionIds = new HashSet<>(); +// Map empIdPositionIdMap = new HashMap<>(); +// Map lastEmpIdPositionIdMap = new HashMap<>(); +// Map sameEmpIdPositionIdMap = new HashMap<>(); +// Map positionIdNameMap = new HashMap<>(); +// simpleEmployeeList.forEach(employee -> { +// if (employee.getPosition() != null && employee.getPosition().getId() != null) { +// positionIdNameMap.put(employee.getPosition().getId(), employee.getPosition().getName()); +// positionIds.add(employee.getPosition().getId()); +// empIdPositionIdMap.put(employee.getId(), employee.getPosition().getId()); +// } +// }); +// lastSimpleEmployeeList.forEach(employee -> { +// if (employee.getPosition() != null && employee.getPosition().getId() != null) { +// lastEmpIdPositionIdMap.put(employee.getId(), employee.getPosition().getId()); +// } +// }); +// sameSimpleEmployeeList.forEach(employee -> { +// if (employee.getPosition() != null && employee.getPosition().getId() != null) { +// sameEmpIdPositionIdMap.put(employee.getId(), employee.getPosition().getId()); +// } +// }); +// +// positionIds.forEach(positionId -> { +// List positionEmployeePOS = data.getList().stream().filter(po -> Objects.equals(empIdPositionIdMap.get(po.getEmployeeId()), positionId)).collect(Collectors.toList()); +// List lastPositionEmployeePOS = data.getLastList().stream().filter(po -> Objects.equals(lastEmpIdPositionIdMap.get(po.getEmployeeId()), positionId)).collect(Collectors.toList()); +// List samePositionEmployeePOS = data.getSameList().stream().filter(po -> Objects.equals(sameEmpIdPositionIdMap.get(po.getEmployeeId()), positionId)).collect(Collectors.toList()); +// Map temp = new HashMap<>(); +// temp.put(DM, positionIdNameMap.get(positionId)); +// temp.putAll(SalaryStatisticsReportBO.calculateItem(positionEmployeePOS, lastPositionEmployeePOS, samePositionEmployeePOS, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); +// records.add(temp); +// }); +// +// List noGroupingList = data.getList().stream().filter(po -> empIdPositionIdMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); +// List lastNoGroupingList = data.getLastList().stream().filter(po -> lastEmpIdPositionIdMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); +// List sameNoGroupingList = data.getSameList().stream().filter(po -> sameEmpIdPositionIdMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); +// if (CollectionUtils.isNotEmpty(noGroupingList)) { +// Map noGrouping = new HashMap<>(); +// noGrouping.put(DM, SalaryI18nUtil.getI18nLabel( 153462, "无分组")); +// noGrouping.putAll(SalaryStatisticsReportBO.calculateItem(noGroupingList, lastNoGroupingList, sameNoGroupingList, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); +// records.add(noGrouping); +// } +// +// result.setList(records); + return result; + } + + private PageInfo> buildGradeRecords(SalaryStatisticsReportDataDTO data, Map> salaryAcctResultValueMap) { + PageInfo> result = new PageInfo<>(); +// List> records = new ArrayList<>(); +// +// List employeeIds = data.getList().stream().map(SalaryAcctEmployeePO::getEmployeeId).distinct().collect(Collectors.toList()); +// List lastEmployeeIds = data.getLastList().stream().map(SalaryAcctEmployeePO::getEmployeeId).distinct().collect(Collectors.toList()); +// List sameEmployeeIds = data.getSameList().stream().map(SalaryAcctEmployeePO::getEmployeeId).distinct().collect(Collectors.toList()); +// List simpleEmployeeList = hrmCommonEmployeeService.getEmployeeByIds(employeeIds, data.getTenantKey()); +// List lastSimpleEmployeeList = hrmCommonEmployeeService.getEmployeeByIds(lastEmployeeIds, data.getTenantKey()); +// List sameSimpleEmployeeList = hrmCommonEmployeeService.getEmployeeByIds(sameEmployeeIds, data.getTenantKey()); +// +// Set gradeIds = new HashSet<>(); +// Map empIdGradeIdMap = new HashMap<>(); +// Map lastEmpIdGradeIdMap = new HashMap<>(); +// Map sameEmpIdGradeIdMap = new HashMap<>(); +// Map gradeIdNameMap = new HashMap<>(); +// simpleEmployeeList.forEach(employee -> { +// if (employee.getGrade() != null && employee.getGrade().getId() != null) { +// gradeIdNameMap.put(employee.getGrade().getId(), employee.getGrade().getName()); +// gradeIds.add(employee.getGrade().getId()); +// empIdGradeIdMap.put(employee.getId(), employee.getGrade().getId()); +// } +// }); +// lastSimpleEmployeeList.forEach(employee -> { +// if (employee.getGrade() != null && employee.getGrade().getId() != null) { +// lastEmpIdGradeIdMap.put(employee.getId(), employee.getGrade().getId()); +// } +// }); +// sameSimpleEmployeeList.forEach(employee -> { +// if (employee.getGrade() != null && employee.getGrade().getId() != null) { +// sameEmpIdGradeIdMap.put(employee.getId(), employee.getGrade().getId()); +// } +// }); +// +// gradeIds.forEach(gradeId -> { +// List gradeEmployeePOS = data.getList().stream().filter(po -> Objects.equals(empIdGradeIdMap.get(po.getEmployeeId()), gradeId)).collect(Collectors.toList()); +// List lastGradeEmployeePos = data.getLastList().stream().filter(po -> Objects.equals(lastEmpIdGradeIdMap.get(po.getEmployeeId()), gradeId)).collect(Collectors.toList()); +// List sameGradeEmployeePos = data.getSameList().stream().filter(po -> Objects.equals(sameEmpIdGradeIdMap.get(po.getEmployeeId()), gradeId)).collect(Collectors.toList()); +// Map temp = new HashMap<>(); +// temp.put(DM, gradeIdNameMap.get(gradeId)); +// temp.putAll(SalaryStatisticsReportBO.calculateItem(gradeEmployeePOS, lastGradeEmployeePos, sameGradeEmployeePos, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); +// records.add(temp); +// }); +// +// List noGroupingList = data.getList().stream().filter(po -> empIdGradeIdMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); +// List lastNoGroupingList = data.getLastList().stream().filter(po -> lastEmpIdGradeIdMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); +// List sameNoGroupingList = data.getSameList().stream().filter(po -> sameEmpIdGradeIdMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); +// if (CollectionUtils.isNotEmpty(noGroupingList)) { +// Map noGrouping = new HashMap<>(); +// noGrouping.put(DM, SalaryI18nUtil.getI18nLabel( 153462, "无分组")); +// noGrouping.putAll(SalaryStatisticsReportBO.calculateItem(noGroupingList, lastNoGroupingList, sameNoGroupingList, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); +// records.add(noGrouping); +// } +// +// result.setList(records); + return result; + } + + private PageInfo> buildStatusRecords(SalaryStatisticsReportDataDTO data, Map> salaryAcctResultValueMap) { + PageInfo> result = new PageInfo<>(); +// List> records = new ArrayList<>(); +// +// List employeeIds = data.getList().stream().map(SalaryAcctEmployeePO::getEmployeeId).distinct().collect(Collectors.toList()); +// List lastEmployeeIds = data.getLastList().stream().map(SalaryAcctEmployeePO::getEmployeeId).distinct().collect(Collectors.toList()); +// List sameEmployeeIds = data.getSameList().stream().map(SalaryAcctEmployeePO::getEmployeeId).distinct().collect(Collectors.toList()); +// List simpleEmployeeList = hrmCommonEmployeeService.getEmployeeByIds(employeeIds, data.getTenantKey()); +// List lastSimpleEmployeeList = hrmCommonEmployeeService.getEmployeeByIds(lastEmployeeIds, data.getTenantKey()); +// List sameSimpleEmployeeList = hrmCommonEmployeeService.getEmployeeByIds(sameEmployeeIds, data.getTenantKey()); +// Map statusIdNameMap = hrmCommonHrmStatusService.list(data.getTenantKey()).stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(HrmStatus::getCodeId))), ArrayList::new)).stream().collect(Collectors.toMap(HrmStatus::getCodeId, HrmStatus::getName)); +// +// Set statusIds = new HashSet<>(); +// Map empIdStatusIdMap = new HashMap<>(); +// Map lastEmpIdStatusIdMap = new HashMap<>(); +// Map sameEmpIdStatusIdMap = new HashMap<>(); +// simpleEmployeeList.forEach(employee -> { +// if (StringUtils.isNotBlank(employee.getPersonnelStatus())) { +// statusIds.add(Long.valueOf(employee.getPersonnelStatus())); +// empIdStatusIdMap.put(employee.getId(), Long.valueOf(employee.getPersonnelStatus())); +// } +// }); +// lastSimpleEmployeeList.forEach(employee -> { +// if (StringUtils.isNotBlank(employee.getPersonnelStatus())) { +// lastEmpIdStatusIdMap.put(employee.getId(), Long.valueOf(employee.getPersonnelStatus())); +// } +// }); +// sameSimpleEmployeeList.forEach(employee -> { +// if (StringUtils.isNotBlank(employee.getPersonnelStatus())) { +// sameEmpIdStatusIdMap.put(employee.getId(), Long.valueOf(employee.getPersonnelStatus())); +// } +// }); +// +// statusIds.forEach(statusId -> { +// List statusEmployeePOS = data.getList().stream().filter(po -> com.google.common.base.Objects.equal(empIdStatusIdMap.get(po.getEmployeeId()), statusId)).collect(Collectors.toList()); +// List lastStatusEmployeePOS = data.getLastList().stream().filter(po -> com.google.common.base.Objects.equal(lastEmpIdStatusIdMap.get(po.getEmployeeId()), statusId)).collect(Collectors.toList()); +// List sameStatusEmployeePOS = data.getSameList().stream().filter(po -> com.google.common.base.Objects.equal(sameEmpIdStatusIdMap.get(po.getEmployeeId()), statusId)).collect(Collectors.toList()); +// Map temp = new HashMap<>(); +// temp.put(DM, statusIdNameMap.get(statusId)); +// temp.putAll(SalaryStatisticsReportBO.calculateItem(statusEmployeePOS, lastStatusEmployeePOS, sameStatusEmployeePOS, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); +// records.add(temp); +// }); +// +// List noGroupingList = data.getList().stream().filter(po -> empIdStatusIdMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); +// List lastNoGroupingList = data.getLastList().stream().filter(po -> lastEmpIdStatusIdMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); +// List sameNoGroupingList = data.getSameList().stream().filter(po -> sameEmpIdStatusIdMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); +// if (CollectionUtils.isNotEmpty(noGroupingList)) { +// Map noGrouping = new HashMap<>(); +// noGrouping.put(DM, SalaryI18nUtil.getI18nLabel( 153462, "无分组")); +// noGrouping.putAll(SalaryStatisticsReportBO.calculateItem(noGroupingList, lastNoGroupingList, sameNoGroupingList, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); +// records.add(noGrouping); +// } +// +// result.setList(records); + return result; + } + + private PageInfo> buildTypeRecords(SalaryStatisticsReportDataDTO data, Map> salaryAcctResultValueMap) { + PageInfo> result = new PageInfo<>(); +// List> records = new ArrayList<>(); +// +// Map> typeEmployeeListMap = data.getList().stream().collect(Collectors.groupingBy(SalaryAcctEmployeePO::getEmployeeType)); +// Map> lastTypeEmployeeListMap = data.getLastList().stream().collect(Collectors.groupingBy(SalaryAcctEmployeePO::getEmployeeType)); +// Map> sameTypeEmployeeListMap = data.getSameList().stream().collect(Collectors.groupingBy(SalaryAcctEmployeePO::getEmployeeType)); +// +// typeEmployeeListMap.forEach((k, v) -> { +// Map temp = new HashMap<>(); +// temp.put(DM, Objects.equals(k, EmployeeTypeEnum.ORGANIZATION.getValue()) ? SalaryI18nUtil.getI18nLabel( 110538, "内部人员") : SalaryI18nUtil.getI18nLabel( 119127, "非系统人员")); +// temp.putAll(SalaryStatisticsReportBO.calculateItem(v, lastTypeEmployeeListMap.get(k), sameTypeEmployeeListMap.get(k), salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); +// records.add(temp); +// }); +// +// result.setList(records); + return result; + } + + private PageInfo> buildEmployeeRecords(SalaryStatisticsReportDataQueryParam param, SalaryStatisticsReportDataDTO data, Map> salaryAcctResultValueMap) { +// List employeeIds = data.getList().stream().map(SalaryAcctEmployeePO::getEmployeeId).distinct().collect(Collectors.toList()); + +// List pageEmployeeIds = SalaryPageUtil.subList(param.getCurrent(), param.getPageSize(), employeeIds); +// List accountDetailPOList = data.getList().stream().filter(po -> pageEmployeeIds.contains(po.getEmployeeId())).collect(Collectors.toList()); + List> records = new ArrayList<>(); + List accountDetailPOList = data.getList(); + Map> employeeListMap = accountDetailPOList.stream().collect(Collectors.groupingBy(SalaryAcctEmployeePO::getEmployeeId, LinkedHashMap::new, Collectors.toList())); + Map> lastEmployeeListMap = data.getLastList().stream().collect(Collectors.groupingBy(SalaryAcctEmployeePO::getEmployeeId, LinkedHashMap::new, Collectors.toList())); + Map> sameEmployeeListMap = data.getSameList().stream().collect(Collectors.groupingBy(SalaryAcctEmployeePO::getEmployeeId, LinkedHashMap::new, Collectors.toList())); + + List empIds = accountDetailPOList.stream().map(SalaryAcctEmployeePO::getEmployeeId).distinct().collect(Collectors.toList()); + Map employeeByIdMap = getSalaryEmployeeService(user).getEmployeeByIdsAll(empIds).stream().collect(Collectors.toMap(DataCollectionEmployee::getEmployeeId, o -> o)); + + //人员维度扩展属性 + EmployeeInfoExpandDTO employeeInfoExpandDTO = getSalaryStatisticsDimensionService(user).getExpandFieldSettings("dim_employee"); + List fieldSettings = Optional.ofNullable(Optional.ofNullable(employeeInfoExpandDTO).orElse(new EmployeeInfoExpandDTO()).getFieldSettings()).orElse(new ArrayList<>()); + Map> expandEmployeeMap = getSalaryEmployeeService(user).expandEmployeeMap(empIds, employeeInfoExpandDTO); + +// List extEmployees = extEmployeeService.listByIdsWithDeleted(accountDetailPOList.stream().filter(e -> EmployeeTypeEnum.EXT_EMPLOYEE.getValue().equals(e.getEmployeeType())).map(SalaryAcctEmployeePO::getEmployeeId).distinct().collect(Collectors.toList()), data.getTenantKey()); +// Map employeeExtByIdMap = SalaryEntityUtil.convert2Map(extEmployees, ExtEmployeePO::getId, ExtEmployeePO::getUsername); + + String dimensionValue = data.getDimensionValue(); + employeeListMap.forEach((k, v) -> { + if (dimensionValue == null) { + Map temp = new HashMap<>(); +// temp.put(DM, Objects.nonNull(employeeByIdMap.get(k)) ? employeeByIdMap.get(k) : employeeExtByIdMap.get(k)); + temp.put(DM, employeeByIdMap.get(k).getUsername()); + fieldSettings.forEach(fieldSetting -> { + temp.put(fieldSetting.getField(), expandEmployeeMap.getOrDefault(k, new HashMap<>()).get(fieldSetting.getField())); + }); + temp.putAll(SalaryStatisticsReportBO.calculateItem(v, lastEmployeeListMap.get(k), sameEmployeeListMap.get(k), salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); + records.add(temp); + } else if (StringUtils.equals(dimensionValue, employeeByIdMap.get(k).getUsername())) { + data.setListByDimensionValue(v); + } + }); + + PageInfo> result = new PageInfo<>(); + result.setList(records); + return result; + } + + private PageInfo> buildQuarterRecords(SalaryStatisticsReportDataDTO data, Map> salaryAcctResultValueMap) { + PageInfo> result = new PageInfo<>(); + List> records = new ArrayList<>(); + + Set quarterSet = Sets.newHashSet(); + data.getList().forEach(sa -> quarterSet.add(ReportTimeUtil.getQuarter(SalaryDateUtil.getFormatYearMonth(sa.getSalaryMonth())))); + List quarters = quarterSet.stream().sorted().collect(Collectors.toList()); + Collections.reverse(quarters); + + String dimensionValue = data.getDimensionValue(); + quarters.forEach(k -> { + if (dimensionValue == null) { + List listYear = data.getList().stream().filter(sa -> Objects.equals(k, ReportTimeUtil.getQuarter(SalaryDateUtil.getFormatYearMonth(sa.getSalaryMonth())))).collect(Collectors.toList()); + List lastListYear = data.getLastList().stream().filter(sa -> Objects.equals(k, ReportTimeUtil.getQuarter(ReportTimeUtil.getPlusYearMonth(SalaryDateUtil.getFormatYearMonth(sa.getSalaryMonth()), 3)))).collect(Collectors.toList()); + List sameListYear = data.getSameList().stream().filter(sa -> Objects.equals(k, ReportTimeUtil.getQuarter(ReportTimeUtil.getPlusYearMonth(SalaryDateUtil.getFormatYearMonth(sa.getSalaryMonth()), 12)))).collect(Collectors.toList()); + Map temp = new HashMap<>(); + temp.put(DM, k); + temp.putAll(SalaryStatisticsReportBO.calculateItem(listYear, lastListYear, sameListYear, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); + records.add(temp); + } else if (StringUtils.equals(dimensionValue, k)) { + List listYear = data.getList().stream().filter(sa -> Objects.equals(k, ReportTimeUtil.getQuarter(SalaryDateUtil.getFormatYearMonth(sa.getSalaryMonth())))).collect(Collectors.toList()); + data.setListByDimensionValue(listYear); + } + }); + + result.setList(records); + return result; + } + + private PageInfo> buildHalfYearRecords(SalaryStatisticsReportDataDTO data, Map> salaryAcctResultValueMap) { + PageInfo> result = new PageInfo<>(); + List> records = new ArrayList<>(); + + Set halfYearSet = Sets.newHashSet(); + data.getList().forEach(sa -> halfYearSet.add(ReportTimeUtil.getHalfYear(SalaryDateUtil.getFormatYearMonth(sa.getSalaryMonth())))); + List halfYears = halfYearSet.stream().sorted().collect(Collectors.toList()); + Collections.reverse(halfYears); + + String dimensionValue = data.getDimensionValue(); + halfYears.forEach(k -> { + if (dimensionValue == null) { + List listHalfYear = data.getList().stream().filter(sa -> Objects.equals(k, ReportTimeUtil.getHalfYear(SalaryDateUtil.getFormatYearMonth(sa.getSalaryMonth())))).collect(Collectors.toList()); + List lastListHalfYear = data.getLastList().stream().filter(sa -> Objects.equals(k, ReportTimeUtil.getHalfYear(ReportTimeUtil.getPlusYearMonth(SalaryDateUtil.getFormatYearMonth(sa.getSalaryMonth()), 6)))).collect(Collectors.toList()); + List sameListHalfYear = data.getSameList().stream().filter(sa -> Objects.equals(k, ReportTimeUtil.getHalfYear(ReportTimeUtil.getPlusYearMonth(SalaryDateUtil.getFormatYearMonth(sa.getSalaryMonth()), 12)))).collect(Collectors.toList()); + Map temp = new HashMap<>(); + temp.put(DM, k); + temp.putAll(SalaryStatisticsReportBO.calculateItem(listHalfYear, lastListHalfYear, sameListHalfYear, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); + records.add(temp); + } else if (StringUtils.equals(dimensionValue, k)) { + List listHalfYear = data.getList().stream().filter(sa -> Objects.equals(k, ReportTimeUtil.getHalfYear(SalaryDateUtil.getFormatYearMonth(sa.getSalaryMonth())))).collect(Collectors.toList()); + data.setListByDimensionValue(listHalfYear); + } + }); + + result.setList(records); + return result; + } + + private PageInfo> buildYearRecords(SalaryStatisticsReportDataDTO data, Map> salaryAcctResultValueMap) { + PageInfo> result = new PageInfo<>(); + List> records = new ArrayList<>(); + + Set yearSet = Sets.newHashSet(); + data.getList().forEach(sa -> yearSet.add(ReportTimeUtil.getYear(SalaryDateUtil.getFormatYearMonth(sa.getSalaryMonth())))); + List years = yearSet.stream().sorted().collect(Collectors.toList()); + Collections.reverse(years); + + String dimensionValue = data.getDimensionValue(); + years.forEach(k -> { + if (dimensionValue == null) { + List listYear = data.getList().stream().filter(sa -> Objects.equals(k, ReportTimeUtil.getYear(SalaryDateUtil.getFormatYearMonth(sa.getSalaryMonth())))).collect(Collectors.toList()); + List lastListYear = data.getLastList().stream().filter(sa -> Objects.equals(ReportTimeUtil.getLastYear(k), ReportTimeUtil.getYear(SalaryDateUtil.getFormatYearMonth(sa.getSalaryMonth())))).collect(Collectors.toList()); + List sameListYear = data.getSameList().stream().filter(sa -> Objects.equals(ReportTimeUtil.getLastYear(k), ReportTimeUtil.getYear(SalaryDateUtil.getFormatYearMonth(sa.getSalaryMonth())))).collect(Collectors.toList()); + Map temp = new HashMap<>(); + temp.put(DM, k); + temp.putAll(SalaryStatisticsReportBO.calculateItem(listYear, lastListYear, sameListYear, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); + records.add(temp); + } else if (StringUtils.equals(dimensionValue, k)) { + List listYear = data.getList().stream().filter(sa -> Objects.equals(k, ReportTimeUtil.getYear(SalaryDateUtil.getFormatYearMonth(sa.getSalaryMonth())))).collect(Collectors.toList()); + data.setListByDimensionValue(listYear); + } + }); + + result.setList(records); + return result; + } + + private PageInfo> buildSexRecords(SalaryStatisticsReportDataDTO data, Map> salaryAcctResultValueMap) { + PageInfo> result = new PageInfo<>(); +// List> records = new ArrayList<>(); +// List employeeIds = data.getList().stream().map(SalaryAcctEmployeePO::getEmployeeId).distinct().collect(Collectors.toList()); +// List lastEmployeeIds = data.getLastList().stream().map(SalaryAcctEmployeePO::getEmployeeId).distinct().collect(Collectors.toList()); +// List simpleEmployeeList = hrmCommonEmployeeService.getEmployeeByIds(employeeIds, data.getTenantKey()); +// List lastSimpleEmployeeList = hrmCommonEmployeeService.getEmployeeByIds(lastEmployeeIds, data.getTenantKey()); +// List sameSimpleEmployeeList = hrmCommonEmployeeService.getEmployeeByIds(lastEmployeeIds, data.getTenantKey()); +// Map sexMap = Arrays.stream(Sex.values()).collect(Collectors.toMap(Sex::getName, Sex::getDescription)); +// +// Map empIdSexIdMap = new HashMap<>(); +// Map lastEmpIdSexIdMap = new HashMap<>(); +// Map sameEmpIdSexIdMap = new HashMap<>(); +// simpleEmployeeList.forEach(employee -> { +// if (employee.getSex() != null) { +// empIdSexIdMap.put(employee.getId(), employee.getSex().getName()); +// } +// }); +// lastSimpleEmployeeList.forEach(employee -> { +// if (employee.getSex() != null) { +// lastEmpIdSexIdMap.put(employee.getId(), employee.getSex().getName()); +// } +// }); +// sameSimpleEmployeeList.forEach(employee -> { +// if (employee.getSex() != null) { +// sameEmpIdSexIdMap.put(employee.getId(), employee.getSex().getName()); +// } +// }); +// +// sexMap.forEach((k, v) -> { +// List salaryAcctEmployees = data.getList().stream().filter(po -> Objects.equals(empIdSexIdMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); +// List lastSalaryAcctEmployees = data.getLastList().stream().filter(po -> Objects.equals(lastEmpIdSexIdMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); +// List sameSalaryAcctEmployees = data.getSameList().stream().filter(po -> Objects.equals(sameEmpIdSexIdMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); +// Map temp = new HashMap<>(); +// temp.put(DM, v); +// temp.putAll(SalaryStatisticsReportBO.calculateItem(salaryAcctEmployees, lastSalaryAcctEmployees, sameSalaryAcctEmployees, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); +// records.add(temp); +// }); +// +// List noGroupingList = data.getList().stream().filter(po -> empIdSexIdMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); +// List lastNoGroupingList = data.getLastList().stream().filter(po -> lastEmpIdSexIdMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); +// List sameNoGroupingList = data.getSameList().stream().filter(po -> sameEmpIdSexIdMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); +// if (CollectionUtils.isNotEmpty(noGroupingList)) { +// Map noGrouping = new HashMap<>(); +// noGrouping.put(DM, SalaryI18nUtil.getI18nLabel( 153462, "无分组")); +// noGrouping.putAll(SalaryStatisticsReportBO.calculateItem(noGroupingList, lastNoGroupingList, sameNoGroupingList, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); +// records.add(noGrouping); +// } +// +// result.setList(records); + return result; + } + + private PageInfo> buildJobCallRecords(SalaryStatisticsReportDataDTO data, Map> salaryAcctResultValueMap) { + PageInfo> result = new PageInfo<>(); +// List> records = new ArrayList<>(); +// +// List employeeIds = data.getList().stream().map(SalaryAcctEmployeePO::getEmployeeId).distinct().collect(Collectors.toList()); +// List lastEmployeeIds = data.getLastList().stream().map(SalaryAcctEmployeePO::getEmployeeId).distinct().collect(Collectors.toList()); +// List sameEmployeeIds = data.getSameList().stream().map(SalaryAcctEmployeePO::getEmployeeId).distinct().collect(Collectors.toList()); +// List simpleEmployeeList = hrmCommonEmployeeService.getEmployeeByIds(employeeIds, data.getTenantKey()); +// List lastSimpleEmployeeList = hrmCommonEmployeeService.getEmployeeByIds(lastEmployeeIds, data.getTenantKey()); +// List sameSimpleEmployeeList = hrmCommonEmployeeService.getEmployeeByIds(sameEmployeeIds, data.getTenantKey()); +// +// Set jobCallIds = Sets.newHashSet(); +// Map empIdJobCallIdMap = new HashMap<>(); +// Map lastEmpIdJobCallIdMap = new HashMap<>(); +// Map sameEmpIdJobCallIdMap = new HashMap<>(); +// simpleEmployeeList.forEach(employee -> { +// if (employee.getJobCall() != null) { +// empIdJobCallIdMap.put(employee.getId(), employee.getJobCall()); +// jobCallIds.add(employee.getJobCall()); +// } +// }); +// lastSimpleEmployeeList.forEach(employee -> { +// if (employee.getJobCall() != null) { +// lastEmpIdJobCallIdMap.put(employee.getId(), employee.getJobCall()); +// } +// }); +// sameSimpleEmployeeList.forEach(employee -> { +// if (employee.getJobCall() != null) { +// sameEmpIdJobCallIdMap.put(employee.getId(), employee.getJobCall()); +// } +// }); +// +// HrmJobCallParam jobCallParam = new HrmJobCallParam(); +// jobCallParam.setIds(Lists.newArrayList(jobCallIds)); +// jobCallParam.setEmployeeId(data.getEmployeeId()); +// jobCallParam.setTenantKey(data.getTenantKey()); +// List jobCallList = CollectionUtils.isEmpty(jobCallIds) ? Lists.newArrayList() : hrmJobCallRemoteService.getJobCallBrowserByIds(jobCallParam); +// Map jobCallIdMap = jobCallList.stream().collect(Collectors.toMap(BrowserDataDto::getId, BrowserDataDto::getName)); +// +// jobCallIds.forEach(k -> { +// List salaryAcctEmployees = data.getList().stream().filter(po -> Objects.equals(empIdJobCallIdMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); +// List lastSalaryAcctEmployees = data.getLastList().stream().filter(po -> Objects.equals(lastEmpIdJobCallIdMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); +// List sameSalaryAcctEmployees = data.getSameList().stream().filter(po -> Objects.equals(sameEmpIdJobCallIdMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); +// Map temp = new HashMap<>(); +// temp.put(DM, jobCallIdMap.get(k.toString())); +// temp.putAll(SalaryStatisticsReportBO.calculateItem(salaryAcctEmployees, lastSalaryAcctEmployees, sameSalaryAcctEmployees, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); +// records.add(temp); +// }); +// +// List noGroupingList = data.getList().stream().filter(po -> empIdJobCallIdMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); +// List lastNoGroupingList = data.getLastList().stream().filter(po -> lastEmpIdJobCallIdMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); +// List sameNoGroupingList = data.getSameList().stream().filter(po -> sameEmpIdJobCallIdMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); +// if (CollectionUtils.isNotEmpty(noGroupingList)) { +// Map noGrouping = new HashMap<>(); +// noGrouping.put(DM, SalaryI18nUtil.getI18nLabel( 153462, "无分组")); +// noGrouping.putAll(SalaryStatisticsReportBO.calculateItem(noGroupingList, lastNoGroupingList, sameNoGroupingList, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); +// records.add(noGrouping); +// } +// +// result.setList(records); + return result; + } + + private PageInfo> buildSuperiorRecords(SalaryStatisticsReportDataDTO data, Map> salaryAcctResultValueMap) { + PageInfo> result = new PageInfo<>(); +// List> records = new ArrayList<>(); +// +// List employeeIds = data.getList().stream().map(SalaryAcctEmployeePO::getEmployeeId).distinct().collect(Collectors.toList()); +// List lastEmployeeIds = data.getLastList().stream().map(SalaryAcctEmployeePO::getEmployeeId).distinct().collect(Collectors.toList()); +// List sameEmployeeIds = data.getSameList().stream().map(SalaryAcctEmployeePO::getEmployeeId).distinct().collect(Collectors.toList()); +// List simpleEmployeeList = hrmCommonEmployeeService.getEmployeeByIds(employeeIds, data.getTenantKey()); +// List lastSimpleEmployeeList = hrmCommonEmployeeService.getEmployeeByIds(lastEmployeeIds, data.getTenantKey()); +// List sameSimpleEmployeeList = hrmCommonEmployeeService.getEmployeeByIds(sameEmployeeIds, data.getTenantKey()); +// +// Set superiorIds = new HashSet<>(); +// Map empIdSuperiorIdMap = new HashMap<>(); +// Map lastEmpIdSuperiorIdMap = new HashMap<>(); +// Map sameEmpIdSuperiorIdMap = new HashMap<>(); +// simpleEmployeeList.forEach(employee -> { +// if (employee.getSuperior() != null && employee.getSuperior().getId() != null) { +// empIdSuperiorIdMap.put(employee.getId(), employee.getSuperior().getId()); +// superiorIds.add(employee.getSuperior().getId()); +// } +// }); +// lastSimpleEmployeeList.forEach(employee -> { +// if (employee.getSuperior() != null && employee.getSuperior().getId() != null) { +// lastEmpIdSuperiorIdMap.put(employee.getId(), employee.getSuperior().getId()); +// } +// }); +// sameSimpleEmployeeList.forEach(employee -> { +// if (employee.getSuperior() != null && employee.getSuperior().getId() != null) { +// sameEmpIdSuperiorIdMap.put(employee.getId(), employee.getSuperior().getId()); +// } +// }); +// +// List superiorList = CollectionUtils.isEmpty(superiorIds) ? Lists.newArrayList() : hrmCommonEmployeeService.getEmployeeByIds(Lists.newArrayList(superiorIds), data.getTenantKey()); +// Map superiorMap = superiorList.stream().collect(Collectors.toMap(SimpleEmployee::getId, SimpleEmployee::getUsername)); +// +// superiorIds.forEach(k -> { +// List salaryAcctEmployees = data.getList().stream().filter(po -> Objects.equals(empIdSuperiorIdMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); +// List lastSalaryAcctEmployees = data.getLastList().stream().filter(po -> Objects.equals(lastEmpIdSuperiorIdMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); +// List sameSalaryAcctEmployees = data.getSameList().stream().filter(po -> Objects.equals(sameEmpIdSuperiorIdMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); +// Map temp = new HashMap<>(); +// temp.put(DM, superiorMap.get(k)); +// temp.putAll(SalaryStatisticsReportBO.calculateItem(salaryAcctEmployees, lastSalaryAcctEmployees, sameSalaryAcctEmployees, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); +// records.add(temp); +// }); +// +// List noGroupingList = data.getList().stream().filter(po -> empIdSuperiorIdMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); +// List lastNoGroupingList = data.getLastList().stream().filter(po -> lastEmpIdSuperiorIdMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); +// List sameNoGroupingList = data.getSameList().stream().filter(po -> sameEmpIdSuperiorIdMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); +// if (CollectionUtils.isNotEmpty(noGroupingList)) { +// Map noGrouping = new HashMap<>(); +// noGrouping.put(DM, SalaryI18nUtil.getI18nLabel( 153462, "无分组")); +// noGrouping.putAll(SalaryStatisticsReportBO.calculateItem(noGroupingList, lastNoGroupingList, sameNoGroupingList, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); +// records.add(noGrouping); +// } +// +// result.setList(records); + return result; + } + + private PageInfo> buildMaritalStatusRecords(SalaryStatisticsReportDataDTO data, Map> salaryAcctResultValueMap) { + PageInfo> result = new PageInfo<>(); +// List> records = new ArrayList<>(); +// +// Map> simpleUserInfoMap = getSimpleUserInfoList(data); +// if (simpleUserInfoMap.isEmpty()) { +// return result; +// } +// +// Set maritalStatusIds = new HashSet<>(); +// +// Map empIdMaritalStatusMap = new HashMap<>(); +// Map lastEmpIdMaritalStatusMap = new HashMap<>(); +// Map sameEmpIdMaritalStatusMap = new HashMap<>(); +// simpleUserInfoMap.get(NOW_INFO).forEach(employee -> { +// if (StringUtils.isNotEmpty(employee.getMaritalStatus())) { +// maritalStatusIds.add(employee.getMaritalStatus()); +// empIdMaritalStatusMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getMaritalStatus()); +// } +// }); +// simpleUserInfoMap.get(LAST_INFO).forEach(employee -> { +// if (StringUtils.isNotEmpty(employee.getMaritalStatus())) { +// lastEmpIdMaritalStatusMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getMaritalStatus()); +// } +// }); +// simpleUserInfoMap.get(SAME_INFO).forEach(employee -> { +// if (StringUtils.isNotEmpty(employee.getMaritalStatus())) { +// sameEmpIdMaritalStatusMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getMaritalStatus()); +// } +// }); +// Map maritalStatusMap = Maps.newHashMap(); +// maritalStatusMap.put("married", SalaryI18nUtil.getI18nLabel( 174138, "已婚")); +// maritalStatusMap.put("unmarried", SalaryI18nUtil.getI18nLabel( 174139, "未婚")); +// maritalStatusMap.put("divorced", SalaryI18nUtil.getI18nLabel( 174140, "离异")); +// +// maritalStatusIds.forEach(k -> { +// List salaryAcctEmployees = data.getList().stream().filter(po -> Objects.equals(empIdMaritalStatusMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); +// List lastSalaryAcctEmployees = data.getLastList().stream().filter(po -> Objects.equals(lastEmpIdMaritalStatusMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); +// List sameSalaryAcctEmployees = data.getSameList().stream().filter(po -> Objects.equals(sameEmpIdMaritalStatusMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); +// Map temp = new HashMap<>(); +// temp.put(DM, maritalStatusMap.get(k)); +// temp.putAll(SalaryStatisticsReportBO.calculateItem(salaryAcctEmployees, lastSalaryAcctEmployees, sameSalaryAcctEmployees, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); +// records.add(temp); +// }); +// +// List noGroupingList = data.getList().stream().filter(po -> empIdMaritalStatusMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); +// List lastNoGroupingList = data.getLastList().stream().filter(po -> lastEmpIdMaritalStatusMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); +// List sameNoGroupingList = data.getSameList().stream().filter(po -> sameEmpIdMaritalStatusMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); +// if (CollectionUtils.isNotEmpty(noGroupingList)) { +// Map noGrouping = new HashMap<>(); +// noGrouping.put(DM, SalaryI18nUtil.getI18nLabel( 153462, "无分组")); +// noGrouping.putAll(SalaryStatisticsReportBO.calculateItem(noGroupingList, lastNoGroupingList, sameNoGroupingList, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); +// records.add(noGrouping); +// } +// +// result.setList(records); + return result; + } + + private Map> getSimpleUserInfoList(SalaryStatisticsReportDataDTO data) { + List employeeIds = data.getList().stream().map(SalaryAcctEmployeePO::getEmployeeId).distinct().collect(Collectors.toList()); + List lastEmployeeIds = data.getLastList().stream().map(SalaryAcctEmployeePO::getEmployeeId).distinct().collect(Collectors.toList()); + List sameEmployeeIds = data.getSameList().stream().map(SalaryAcctEmployeePO::getEmployeeId).distinct().collect(Collectors.toList()); + + List simpleUserInfoList; + List lastSimpleUserInfoList; + List sameSimpleUserInfoList; + Map> map = Maps.newHashMap(); + try { + simpleUserInfoList = CollectionUtils.isEmpty(employeeIds) ? Lists.newArrayList() : getSalaryEmployeeService(user).getEmployeeByIdsAll(employeeIds); + lastSimpleUserInfoList = CollectionUtils.isEmpty(lastEmployeeIds) ? Lists.newArrayList() : getSalaryEmployeeService(user).getEmployeeByIdsAll(lastEmployeeIds); + sameSimpleUserInfoList = CollectionUtils.isEmpty(sameEmployeeIds) ? Lists.newArrayList() : getSalaryEmployeeService(user).getEmployeeByIdsAll(sameEmployeeIds); + } catch (Exception e) { + log.info("获取员工个人信息失败: {}", e.getMessage()); + return map; + } + map.put(NOW_INFO, simpleUserInfoList); + map.put(LAST_INFO, lastSimpleUserInfoList); + map.put(SAME_INFO, sameSimpleUserInfoList); + return map; + } + +// private PageInfo> buildEducationRecords(SalaryStatisticsReportDataDTO data, Map> salaryAcctResultValueMap) { +// PageInfo> result = new PageInfo<>(); +// List> records = new ArrayList<>(); +// Map> simpleUserInfoMap = getSimpleUserInfoList(data); +// if (simpleUserInfoMap.isEmpty()) { +// return result; +// } +// +// Set educationIds = new HashSet<>(); +// Map educationMap = Maps.newHashMap(); +// +// Map empIdEducationMap = new HashMap<>(); +// Map lastEmpIdEducationMap = new HashMap<>(); +// Map sameEmpIdEducationMap = new HashMap<>(); +// simpleUserInfoMap.get(NOW_INFO).forEach(employee -> { +// if (employee.getEducation() != null && employee.getEducation().getId() != null) { +// educationIds.add(employee.getEducation().getId()); +// empIdEducationMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getEducation().getId()); +// educationMap.put(employee.getEducation().getId(), employee.getEducation().getName()); +// } +// }); +// simpleUserInfoMap.get(LAST_INFO).forEach(employee -> { +// if (employee.getEducation() != null && employee.getEducation().getId() != null) { +// lastEmpIdEducationMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getEducation().getId()); +// educationMap.put(employee.getEducation().getId(), employee.getEducation().getName()); +// } +// }); +// simpleUserInfoMap.get(SAME_INFO).forEach(employee -> { +// if (employee.getEducation() != null && employee.getEducation().getId() != null) { +// sameEmpIdEducationMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getEducation().getId()); +// educationMap.put(employee.getEducation().getId(), employee.getEducation().getName()); +// } +// }); +// +// educationIds.forEach(k -> { +// List salaryAcctEmployees = data.getList().stream().filter(po -> Objects.equals(empIdEducationMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); +// List lastSalaryAcctEmployees = data.getLastList().stream().filter(po -> Objects.equals(lastEmpIdEducationMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); +// List sameSalaryAcctEmployees = data.getSameList().stream().filter(po -> Objects.equals(sameEmpIdEducationMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); +// Map temp = new HashMap<>(); +// temp.put(DM, educationMap.get(k)); +// temp.putAll(SalaryStatisticsReportBO.calculateItem(salaryAcctEmployees, lastSalaryAcctEmployees, sameSalaryAcctEmployees, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); +// records.add(temp); +// }); +// +// List noGroupingList = data.getList().stream().filter(po -> empIdEducationMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); +// List lastNoGroupingList = data.getLastList().stream().filter(po -> lastEmpIdEducationMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); +// List sameNoGroupingList = data.getSameList().stream().filter(po -> sameEmpIdEducationMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); +// if (CollectionUtils.isNotEmpty(noGroupingList)) { +// Map noGrouping = new HashMap<>(); +// noGrouping.put(DM, SalaryI18nUtil.getI18nLabel(153462, "无分组")); +// noGrouping.putAll(SalaryStatisticsReportBO.calculateItem(noGroupingList, lastNoGroupingList, sameNoGroupingList, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); +// records.add(noGrouping); +// } +// +// result.setList(records); +// return result; +// } +// +// private PageInfo> buildDegreeRecords(SalaryStatisticsReportDataDTO data, Map> salaryAcctResultValueMap) { +// PageInfo> result = new PageInfo<>(); +// List> records = new ArrayList<>(); +// Map> simpleUserInfoMap = getSimpleUserInfoList(data); +// if (simpleUserInfoMap.isEmpty()) { +// return result; +// } +// +// Set degreeIds = new HashSet<>(); +// Map degreeMap = Maps.newHashMap(); +// +// Map empIdDegreeMap = new HashMap<>(); +// Map lastEmpIdDegreeMap = new HashMap<>(); +// Map sameEmpIdDegreeMap = new HashMap<>(); +// simpleUserInfoMap.get(NOW_INFO).forEach(employee -> { +// if (employee.getDegree() != null && employee.getDegree().getId() != null) { +// degreeIds.add(employee.getDegree().getId()); +// empIdDegreeMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getDegree().getId()); +// degreeMap.put(employee.getDegree().getId(), employee.getDegree().getName()); +// } +// }); +// simpleUserInfoMap.get(LAST_INFO).forEach(employee -> { +// if (employee.getDegree() != null && employee.getDegree().getId() != null) { +// lastEmpIdDegreeMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getDegree().getId()); +// degreeMap.put(employee.getDegree().getId(), employee.getDegree().getName()); +// } +// }); +// simpleUserInfoMap.get(SAME_INFO).forEach(employee -> { +// if (employee.getDegree() != null && employee.getDegree().getId() != null) { +// sameEmpIdDegreeMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getDegree().getId()); +// degreeMap.put(employee.getDegree().getId(), employee.getDegree().getName()); +// } +// }); +// +// degreeIds.forEach(k -> { +// List salaryAcctEmployees = data.getList().stream().filter(po -> Objects.equals(empIdDegreeMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); +// List lastSalaryAcctEmployees = data.getLastList().stream().filter(po -> Objects.equals(lastEmpIdDegreeMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); +// List sameSalaryAcctEmployees = data.getSameList().stream().filter(po -> Objects.equals(sameEmpIdDegreeMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); +// Map temp = new HashMap<>(); +// temp.put(DM, degreeMap.get(k)); +// temp.putAll(SalaryStatisticsReportBO.calculateItem(salaryAcctEmployees, lastSalaryAcctEmployees, sameSalaryAcctEmployees, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); +// records.add(temp); +// }); +// +// List noGroupingList = data.getList().stream().filter(po -> empIdDegreeMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); +// List lastNoGroupingList = data.getLastList().stream().filter(po -> lastEmpIdDegreeMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); +// List sameNoGroupingList = data.getSameList().stream().filter(po -> sameEmpIdDegreeMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); +// if (CollectionUtils.isNotEmpty(noGroupingList)) { +// Map noGrouping = new HashMap<>(); +// noGrouping.put(DM, SalaryI18nUtil.getI18nLabel(153462, "无分组")); +// noGrouping.putAll(SalaryStatisticsReportBO.calculateItem(noGroupingList, lastNoGroupingList, sameNoGroupingList, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); +// records.add(noGrouping); +// } +// +// result.setList(records); +// return result; +// } +// +// private PageInfo> buildNationRecords(SalaryStatisticsReportDataDTO data, Map> salaryAcctResultValueMap) { +// PageInfo> result = new PageInfo<>(); +// List> records = new ArrayList<>(); +// Map> simpleUserInfoMap = getSimpleUserInfoList(data); +// if (simpleUserInfoMap.isEmpty()) { +// return result; +// } +// +// Set nationIds = new HashSet<>(); +// Map nationMap = Maps.newHashMap(); +// +// Map empIdNationMap = new HashMap<>(); +// Map lastEmpIdNationMap = new HashMap<>(); +// Map sameEmpIdNationMap = new HashMap<>(); +// simpleUserInfoMap.get(NOW_INFO).forEach(employee -> { +// if (employee.getNation() != null && employee.getNation().getId() != null) { +// nationIds.add(employee.getNation().getId()); +// empIdNationMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getNation().getId()); +// nationMap.put(employee.getNation().getId(), employee.getNation().getName()); +// } +// }); +// simpleUserInfoMap.get(LAST_INFO).forEach(employee -> { +// if (employee.getNation() != null && employee.getNation().getId() != null) { +// lastEmpIdNationMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getNation().getId()); +// nationMap.put(employee.getNation().getId(), employee.getNation().getName()); +// } +// }); +// simpleUserInfoMap.get(SAME_INFO).forEach(employee -> { +// if (employee.getNation() != null && employee.getNation().getId() != null) { +// sameEmpIdNationMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getNation().getId()); +// nationMap.put(employee.getNation().getId(), employee.getNation().getName()); +// } +// }); +// +// nationIds.forEach(k -> { +// List salaryAcctEmployees = data.getList().stream().filter(po -> Objects.equals(empIdNationMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); +// List lastSalaryAcctEmployees = data.getLastList().stream().filter(po -> Objects.equals(lastEmpIdNationMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); +// List sameSalaryAcctEmployees = data.getSameList().stream().filter(po -> Objects.equals(sameEmpIdNationMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); +// Map temp = new HashMap<>(); +// temp.put(DM, nationMap.get(k)); +// temp.putAll(SalaryStatisticsReportBO.calculateItem(salaryAcctEmployees, lastSalaryAcctEmployees, sameSalaryAcctEmployees, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); +// records.add(temp); +// }); +// +// List noGroupingList = data.getList().stream().filter(po -> empIdNationMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); +// List lastNoGroupingList = data.getLastList().stream().filter(po -> lastEmpIdNationMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); +// List sameNoGroupingList = data.getSameList().stream().filter(po -> sameEmpIdNationMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); +// if (CollectionUtils.isNotEmpty(noGroupingList)) { +// Map noGrouping = new HashMap<>(); +// noGrouping.put(DM, SalaryI18nUtil.getI18nLabel(153462, "无分组")); +// noGrouping.putAll(SalaryStatisticsReportBO.calculateItem(noGroupingList, lastNoGroupingList, sameNoGroupingList, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); +// records.add(noGrouping); +// } +// +// result.setList(records); +// return result; +// } +// +// private PageInfo> buildHouseholdTypeRecords(SalaryStatisticsReportDataDTO data, Map> salaryAcctResultValueMap) { +// PageInfo> result = new PageInfo<>(); +// List> records = new ArrayList<>(); +// Map> simpleUserInfoMap = getSimpleUserInfoList(data); +// if (simpleUserInfoMap.isEmpty()) { +// return result; +// } +// +// Set householdTypeIds = new HashSet<>(); +// Map householdTypeMap = Maps.newHashMap(); +// +// Map empIdHouseholdTypeMap = new HashMap<>(); +// Map lastEmpIdHouseholdTypeMap = new HashMap<>(); +// Map sameEmpIdHouseholdTypeMap = new HashMap<>(); +// simpleUserInfoMap.get(NOW_INFO).forEach(employee -> { +// if (employee.getHouseholdType() != null && employee.getHouseholdType().getId() != null) { +// householdTypeIds.add(employee.getHouseholdType().getId()); +// empIdHouseholdTypeMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getHouseholdType().getId()); +// householdTypeMap.put(employee.getHouseholdType().getId(), employee.getHouseholdType().getName()); +// } +// }); +// simpleUserInfoMap.get(LAST_INFO).forEach(employee -> { +// if (employee.getHouseholdType() != null && employee.getHouseholdType().getId() != null) { +// lastEmpIdHouseholdTypeMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getHouseholdType().getId()); +// householdTypeMap.put(employee.getHouseholdType().getId(), employee.getHouseholdType().getName()); +// } +// }); +// simpleUserInfoMap.get(SAME_INFO).forEach(employee -> { +// if (employee.getHouseholdType() != null && employee.getHouseholdType().getId() != null) { +// sameEmpIdHouseholdTypeMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getHouseholdType().getId()); +// householdTypeMap.put(employee.getHouseholdType().getId(), employee.getHouseholdType().getName()); +// } +// }); +// +// householdTypeIds.forEach(k -> { +// List salaryAcctEmployees = data.getList().stream().filter(po -> Objects.equals(empIdHouseholdTypeMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); +// List lastSalaryAcctEmployees = data.getLastList().stream().filter(po -> Objects.equals(lastEmpIdHouseholdTypeMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); +// List sameSalaryAcctEmployees = data.getSameList().stream().filter(po -> Objects.equals(sameEmpIdHouseholdTypeMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); +// Map temp = new HashMap<>(); +// temp.put(DM, householdTypeMap.get(k)); +// temp.putAll(SalaryStatisticsReportBO.calculateItem(salaryAcctEmployees, lastSalaryAcctEmployees, sameSalaryAcctEmployees, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); +// records.add(temp); +// }); +// +// List noGroupingList = data.getList().stream().filter(po -> empIdHouseholdTypeMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); +// List lastNoGroupingList = data.getLastList().stream().filter(po -> lastEmpIdHouseholdTypeMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); +// List sameNoGroupingList = data.getSameList().stream().filter(po -> sameEmpIdHouseholdTypeMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); +// if (CollectionUtils.isNotEmpty(noGroupingList)) { +// Map noGrouping = new HashMap<>(); +// noGrouping.put(DM, SalaryI18nUtil.getI18nLabel(153462, "无分组")); +// noGrouping.putAll(SalaryStatisticsReportBO.calculateItem(noGroupingList, lastNoGroupingList, sameNoGroupingList, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); +// records.add(noGrouping); +// } +// +// result.setList(records); +// return result; +// } +// +// private PageInfo> buildPoliticsStatusRecords(SalaryStatisticsReportDataDTO data, Map> salaryAcctResultValueMap) { +// PageInfo> result = new PageInfo<>(); +// List> records = new ArrayList<>(); +// Map> simpleUserInfoMap = getSimpleUserInfoList(data); +// if (simpleUserInfoMap.isEmpty()) { +// return result; +// } +// +// Set politicsStatusIds = new HashSet<>(); +// Map politicsStatusMap = Maps.newHashMap(); +// +// Map empIdPoliticsStatusMap = new HashMap<>(); +// Map lastEmpIdPoliticsStatusMap = new HashMap<>(); +// Map sameEmpIdPoliticsStatusMap = new HashMap<>(); +// simpleUserInfoMap.get(NOW_INFO).forEach(employee -> { +// if (employee.getPoliticsStatus() != null && employee.getPoliticsStatus().getId() != null) { +// politicsStatusIds.add(employee.getPoliticsStatus().getId()); +// empIdPoliticsStatusMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getPoliticsStatus().getId()); +// politicsStatusMap.put(employee.getPoliticsStatus().getId(), employee.getPoliticsStatus().getName()); +// } +// }); +// simpleUserInfoMap.get(LAST_INFO).forEach(employee -> { +// if (employee.getPoliticsStatus() != null && employee.getPoliticsStatus().getId() != null) { +// lastEmpIdPoliticsStatusMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getPoliticsStatus().getId()); +// politicsStatusMap.put(employee.getPoliticsStatus().getId(), employee.getPoliticsStatus().getName()); +// } +// }); +// simpleUserInfoMap.get(SAME_INFO).forEach(employee -> { +// if (employee.getPoliticsStatus() != null && employee.getPoliticsStatus().getId() != null) { +// sameEmpIdPoliticsStatusMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getPoliticsStatus().getId()); +// politicsStatusMap.put(employee.getPoliticsStatus().getId(), employee.getPoliticsStatus().getName()); +// } +// }); +// +// politicsStatusIds.forEach(k -> { +// List salaryAcctEmployees = data.getList().stream().filter(po -> Objects.equals(empIdPoliticsStatusMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); +// List lastSalaryAcctEmployees = data.getLastList().stream().filter(po -> Objects.equals(lastEmpIdPoliticsStatusMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); +// List sameSalaryAcctEmployees = data.getSameList().stream().filter(po -> Objects.equals(sameEmpIdPoliticsStatusMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); +// Map temp = new HashMap<>(); +// temp.put(DM, politicsStatusMap.get(k)); +// temp.putAll(SalaryStatisticsReportBO.calculateItem(salaryAcctEmployees, lastSalaryAcctEmployees, sameSalaryAcctEmployees, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); +// records.add(temp); +// }); +// +// List noGroupingList = data.getList().stream().filter(po -> empIdPoliticsStatusMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); +// List lastNoGroupingList = data.getLastList().stream().filter(po -> lastEmpIdPoliticsStatusMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); +// List sameNoGroupingList = data.getSameList().stream().filter(po -> sameEmpIdPoliticsStatusMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); +// if (CollectionUtils.isNotEmpty(noGroupingList)) { +// Map noGrouping = new HashMap<>(); +// noGrouping.put(DM, SalaryI18nUtil.getI18nLabel(153462, "无分组")); +// noGrouping.putAll(SalaryStatisticsReportBO.calculateItem(noGroupingList, lastNoGroupingList, sameNoGroupingList, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); +// records.add(noGrouping); +// } +// +// result.setList(records); +// return result; +// } +// +// private PageInfo> buildAgeRecords(SalaryStatisticsReportDataDTO data, Map> salaryAcctResultValueMap) { +// PageInfo> result = new PageInfo<>(); +// List> records = new ArrayList<>(); +// Map> simpleUserInfoMap = getSimpleUserInfoList(data); +// if (simpleUserInfoMap.isEmpty()) { +// return result; +// } +// +// Set ageSet = new HashSet<>(); +// +// Map empIdAgeMap = new HashMap<>(); +// Map lastEmpIdAgeMap = new HashMap<>(); +// Map sameEmpIdAgeMap = new HashMap<>(); +// simpleUserInfoMap.get(NOW_INFO).forEach(employee -> { +// if (employee.getAge() != null) { +// ageSet.add(employee.getAge()); +// empIdAgeMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getAge()); +// } +// }); +// simpleUserInfoMap.get(LAST_INFO).forEach(employee -> { +// if (employee.getAge() != null) { +// lastEmpIdAgeMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getAge()); +// } +// }); +// simpleUserInfoMap.get(SAME_INFO).forEach(employee -> { +// if (employee.getAge() != null) { +// sameEmpIdAgeMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getAge()); +// } +// }); +// +// List ages = Lists.newArrayList(ageSet); +// ages = ages.stream().sorted().collect(Collectors.toList()); +// +// ages.forEach(k -> { +// List salaryAcctEmployees = data.getList().stream().filter(po -> Objects.equals(empIdAgeMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); +// List lastSalaryAcctEmployees = data.getLastList().stream().filter(po -> Objects.equals(lastEmpIdAgeMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); +// List sameSalaryAcctEmployees = data.getSameList().stream().filter(po -> Objects.equals(sameEmpIdAgeMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); +// Map temp = new HashMap<>(); +// temp.put(DM, k); +// temp.putAll(SalaryStatisticsReportBO.calculateItem(salaryAcctEmployees, lastSalaryAcctEmployees, sameSalaryAcctEmployees, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); +// records.add(temp); +// }); +// +// List noGroupingList = data.getList().stream().filter(po -> empIdAgeMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); +// List lastNoGroupingList = data.getLastList().stream().filter(po -> lastEmpIdAgeMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); +// List sameNoGroupingList = data.getSameList().stream().filter(po -> lastEmpIdAgeMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); +// if (CollectionUtils.isNotEmpty(noGroupingList)) { +// Map noGrouping = new HashMap<>(); +// noGrouping.put(DM, SalaryI18nUtil.getI18nLabel(153462, "无分组")); +// noGrouping.putAll(SalaryStatisticsReportBO.calculateItem(noGroupingList, lastNoGroupingList, sameNoGroupingList, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); +// records.add(noGrouping); +// } +// +// result.setList(records); +// return result; +// } + + private PageInfo> buildWorkYearRecords(SalaryStatisticsReportDataDTO data, Map> salaryAcctResultValueMap) { + PageInfo> result = new PageInfo<>(); + List> records = new ArrayList<>(); + Map> simpleUserInfoMap = getSimpleUserInfoList(data); + if (simpleUserInfoMap.isEmpty()) { + return result; + } + + Set workYearSet = new HashSet<>(); + + Map empIdWorkYearMap = new HashMap<>(); + Map lastEmpIdWorkYearMap = new HashMap<>(); + Map sameEmpIdWorkYearMap = new HashMap<>(); + simpleUserInfoMap.get(NOW_INFO).forEach(employee -> { + if (employee.getWorkYear() != null) { + workYearSet.add(employee.getWorkYear()); + empIdWorkYearMap.put(employee.getEmployeeId(), employee.getWorkYear()); + } + }); + simpleUserInfoMap.get(LAST_INFO).forEach(employee -> { + if (employee.getWorkYear() != null) { + lastEmpIdWorkYearMap.put(employee.getEmployeeId(), employee.getWorkYear()); + } + }); + simpleUserInfoMap.get(SAME_INFO).forEach(employee -> { + if (employee.getWorkYear() != null) { + sameEmpIdWorkYearMap.put(employee.getEmployeeId(), employee.getWorkYear()); + } + }); + List workYears = Lists.newArrayList(workYearSet); + workYears = workYears.stream().sorted().collect(Collectors.toList()); + + String dimensionValue = data.getDimensionValue(); + workYears.forEach(k -> { + if (dimensionValue == null) { + List salaryAcctEmployees = data.getList().stream().filter(po -> Objects.equals(empIdWorkYearMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); + List lastSalaryAcctEmployees = data.getLastList().stream().filter(po -> Objects.equals(lastEmpIdWorkYearMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); + List sameSalaryAcctEmployees = data.getSameList().stream().filter(po -> Objects.equals(sameEmpIdWorkYearMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); + Map temp = new HashMap<>(); + temp.put(DM, k); + temp.putAll(SalaryStatisticsReportBO.calculateItem(salaryAcctEmployees, lastSalaryAcctEmployees, sameSalaryAcctEmployees, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); + records.add(temp); + } else if (Double.compare(Double.valueOf(dimensionValue), k) == 0) { + List salaryAcctEmployees = data.getList().stream().filter(po -> Objects.equals(empIdWorkYearMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); + data.setListByDimensionValue(salaryAcctEmployees); + } + }); + + if (dimensionValue == null) { + List noGroupingList = data.getList().stream().filter(po -> empIdWorkYearMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); + List lastNoGroupingList = data.getLastList().stream().filter(po -> lastEmpIdWorkYearMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); + List sameNoGroupingList = data.getSameList().stream().filter(po -> lastEmpIdWorkYearMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(noGroupingList)) { + Map noGrouping = new HashMap<>(); + noGrouping.put(DM, SalaryI18nUtil.getI18nLabel(153462, "无分组")); + noGrouping.putAll(SalaryStatisticsReportBO.calculateItem(noGroupingList, lastNoGroupingList, sameNoGroupingList, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); + records.add(noGrouping); + } + } else if (StringUtils.equals(dimensionValue, "无分组")) { + List noGroupingList = data.getList().stream().filter(po -> empIdWorkYearMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); + data.setListByDimensionValue(noGroupingList); + } + + result.setList(records); + return result; + } + + private PageInfo> buildCompanyYearRecords(SalaryStatisticsReportDataDTO data, Map> salaryAcctResultValueMap) { + PageInfo> result = new PageInfo<>(); + List> records = new ArrayList<>(); + Map> simpleUserInfoMap = getSimpleUserInfoList(data); + if (simpleUserInfoMap.isEmpty()) { + return result; + } + + Set companyYearSet = new HashSet<>(); + + Map empIdCompanyYearMap = new HashMap<>(); + Map lastEmpIdCompanyYearMap = new HashMap<>(); + Map sameEmpIdCompanyYearMap = new HashMap<>(); + simpleUserInfoMap.get(NOW_INFO).forEach(employee -> { + if (employee.getCompanyWorkYear() != null) { + companyYearSet.add(Util.null2String(employee.getCompanyWorkYear())); + empIdCompanyYearMap.put(employee.getEmployeeId(), Util.null2String(employee.getCompanyWorkYear())); + } + }); + simpleUserInfoMap.get(LAST_INFO).forEach(employee -> { + if (employee.getCompanyWorkYear() != null) { + lastEmpIdCompanyYearMap.put(employee.getEmployeeId(), Util.null2String(employee.getCompanyWorkYear())); + } + }); + simpleUserInfoMap.get(SAME_INFO).forEach(employee -> { + if (employee.getCompanyWorkYear() != null) { + sameEmpIdCompanyYearMap.put(employee.getEmployeeId(), Util.null2String(employee.getCompanyWorkYear())); + } + }); + + List companyYears = Lists.newArrayList(companyYearSet); + companyYears = companyYears.stream().sorted().collect(Collectors.toList()); + + String dimensionValue = data.getDimensionValue(); + companyYears.forEach(k -> { + if (dimensionValue == null) { + List salaryAcctEmployees = data.getList().stream().filter(po -> Objects.equals(empIdCompanyYearMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); + List lastSalaryAcctEmployees = data.getLastList().stream().filter(po -> Objects.equals(lastEmpIdCompanyYearMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); + List sameSalaryAcctEmployees = data.getSameList().stream().filter(po -> Objects.equals(sameEmpIdCompanyYearMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); + Map temp = new HashMap<>(); + temp.put(DM, k); + temp.putAll(SalaryStatisticsReportBO.calculateItem(salaryAcctEmployees, lastSalaryAcctEmployees, sameSalaryAcctEmployees, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); + records.add(temp); + } else if (StringUtils.equals(dimensionValue, k)) { + List salaryAcctEmployees = data.getList().stream().filter(po -> Objects.equals(empIdCompanyYearMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); + data.setListByDimensionValue(salaryAcctEmployees); + } + }); + + if (dimensionValue == null) { + List noGroupingList = data.getList().stream().filter(po -> empIdCompanyYearMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); + List lastNoGroupingList = data.getLastList().stream().filter(po -> lastEmpIdCompanyYearMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); + List sameNoGroupingList = data.getSameList().stream().filter(po -> sameEmpIdCompanyYearMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(noGroupingList)) { + Map noGrouping = new HashMap<>(); + noGrouping.put(DM, SalaryI18nUtil.getI18nLabel(153462, "无分组")); + noGrouping.putAll(SalaryStatisticsReportBO.calculateItem(noGroupingList, lastNoGroupingList, sameNoGroupingList, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); + records.add(noGrouping); + } + } else if (StringUtils.equals(dimensionValue, "无分组")) { + List noGroupingList = data.getList().stream().filter(po -> empIdCompanyYearMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); + data.setListByDimensionValue(noGroupingList); + } + + result.setList(records); + return result; + } + + private PageInfo> buildSalaryItemRecords(SalaryStatisticsDimensionPO dimension, SalaryStatisticsReportDataDTO data, Map> salaryAcctResultValueMap) { + + //查询薪资项目存在的种类(维度) + Set dimensionSet = new HashSet<>(); + for (Long k : salaryAcctResultValueMap.keySet()) { + Map map = salaryAcctResultValueMap.get(k); + dimensionSet.add(map.getOrDefault(dimension.getDimCode(), "")); + } + + PageInfo> result = new PageInfo<>(); + List> records = new ArrayList<>(); + + Map empIdYearMap = new HashMap<>(); + Map lastEmpIdYearMap = new HashMap<>(); + Map sameEmpIdYearMap = new HashMap<>(); + + String dimensionValue = data.getDimensionValue(); + dimensionSet.stream().sorted((a, b) -> b.length() - a.length()).forEach(k -> { + if (dimensionValue == null) { + List salaryAcctEmployees = SalaryStatisticsReportBO.listAcctEmpByRationGroupIndividual(k, dimension.getDimCode(), data.getList(), empIdYearMap, salaryAcctResultValueMap, data.getSalaryStatisticsItemList()); + List lastSalaryAcctEmployees = SalaryStatisticsReportBO.listAcctEmpByRationGroupIndividual(k, dimension.getDimCode(), data.getLastList(), lastEmpIdYearMap, salaryAcctResultValueMap, data.getSalaryStatisticsItemList()); + List sameSalaryAcctEmployees = SalaryStatisticsReportBO.listAcctEmpByRationGroupIndividual(k, dimension.getDimCode(), data.getSameList(), sameEmpIdYearMap, salaryAcctResultValueMap, data.getSalaryStatisticsItemList()); + Map temp = new HashMap<>(); + temp.put(DM, k); + temp.putAll(SalaryStatisticsReportBO.calculateItem(salaryAcctEmployees, lastSalaryAcctEmployees, sameSalaryAcctEmployees, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); + records.add(temp); + } else if (StringUtils.equals(dimensionValue, k)) { + List salaryAcctEmployees = SalaryStatisticsReportBO.listAcctEmpByRationGroupIndividual(k, dimension.getDimCode(), data.getList(), empIdYearMap, salaryAcctResultValueMap, data.getSalaryStatisticsItemList()); + data.setListByDimensionValue(salaryAcctEmployees); + } + }); + result.setList(records); + return result; + } + +// private PageInfo> buildRationGroupSpacing4NoItemRecords(SalaryStatisticsDimensionPO dimension, SalaryStatisticsReportDataDTO data, Map> salaryAcctResultValueMap) { +// PageInfo> result = new PageInfo<>(); +// List> records = new ArrayList<>(); +// +// // 分组设置 +// List groups = JsonUtil.parseList(dimension.getSetting(), SalaryStatisticsDimensionSaveParam.Setting4RationGroupSpacing.class); +// +// +// result.setList(records); +// return result; +// } + + private PageInfo> buildRationGroupSpacing4Records(SalaryStatisticsDimensionPO dimension, SalaryStatisticsReportDataDTO data, Map> salaryAcctResultValueMap) { + PageInfo> result = new PageInfo<>(); + List> records = new ArrayList<>(); + + // 分组设置 + List groups = JsonUtil.parseList(dimension.getSetting(), SalaryStatisticsDimensionSaveParam.Setting4RationGroupSpacing.class); + + Map empIdYearMap = new HashMap<>(); + Map lastEmpIdYearMap = new HashMap<>(); + Map sameEmpIdYearMap = new HashMap<>(); + + String groupBelong; + if (StringUtils.isEmpty(dimension.getDimCode())) { + groupBelong = SalaryStatisticsReportBO.G_NO_ITEM; + } else if (dimension.getDimCode().equals(SalaryStatisticsDimensionConstant.DM_AGE) || dimension.getDimCode().equals(SalaryStatisticsDimensionConstant.DM_WORK_YEAR) || dimension.getDimCode().equals(SalaryStatisticsDimensionConstant.DM_COMPANY_YEAR)) { + groupBelong = SalaryStatisticsReportBO.G_YEAR; + // 年份数据 + handle4GroupYear(dimension, empIdYearMap, lastEmpIdYearMap, sameEmpIdYearMap, data); + } else { + groupBelong = SalaryStatisticsReportBO.G_ITEM; + } + String dimensionValue = data.getDimensionValue(); + groups.forEach(k -> { + if (dimensionValue == null) { + List salaryAcctEmployees = SalaryStatisticsReportBO.listAcctEmpByRationGroupSpacing(k, groupBelong, dimension.getDimCode(), data.getList(), empIdYearMap, salaryAcctResultValueMap, data.getSalaryStatisticsItemList()); + List lastSalaryAcctEmployees = SalaryStatisticsReportBO.listAcctEmpByRationGroupSpacing(k, groupBelong, dimension.getDimCode(), data.getLastList(), lastEmpIdYearMap, salaryAcctResultValueMap, data.getSalaryStatisticsItemList()); + List sameSalaryAcctEmployees = SalaryStatisticsReportBO.listAcctEmpByRationGroupSpacing(k, groupBelong, dimension.getDimCode(), data.getSameList(), sameEmpIdYearMap, salaryAcctResultValueMap, data.getSalaryStatisticsItemList()); + Map temp = new HashMap<>(); + temp.put(DM, k.getStartValue() + "-" + k.getEndValue()); + temp.putAll(SalaryStatisticsReportBO.calculateItem(salaryAcctEmployees, lastSalaryAcctEmployees, sameSalaryAcctEmployees, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); + records.add(temp); + } else if (StringUtils.equals(dimensionValue, k.getStartValue() + "-" + k.getEndValue())) { + List salaryAcctEmployees = SalaryStatisticsReportBO.listAcctEmpByRationGroupSpacing(k, groupBelong, dimension.getDimCode(), data.getList(), empIdYearMap, salaryAcctResultValueMap, data.getSalaryStatisticsItemList()); + data.setListByDimensionValue(salaryAcctEmployees); + } + }); + + result.setList(records); + return result; + } + + private void handle4GroupYear(SalaryStatisticsDimensionPO dimension, Map empIdYearMap, Map lastEmpIdYearMap, Map sameEmpIdYearMap, SalaryStatisticsReportDataDTO data) { + Map> simpleUserInfoMap = getSimpleUserInfoList(data); + if (simpleUserInfoMap.isEmpty()) { + return; + } + simpleUserInfoMap.get(NOW_INFO).forEach(employee -> { +// if (dimension.getDimCode().equals(SalaryStatisticsDimensionConstant.DM_AGE) && employee.getAge() != null) { +// empIdYearMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getAge().toString()); +// } else + + if (dimension.getDimCode().equals(SalaryStatisticsDimensionConstant.DM_WORK_YEAR) && employee.getWorkYear() != null) { + empIdYearMap.put(employee.getEmployeeId(), Util.null2String(employee.getWorkYear())); + } else if (dimension.getDimCode().equals(SalaryStatisticsDimensionConstant.DM_COMPANY_YEAR) && employee.getCompanyWorkYear() != null) { + empIdYearMap.put(employee.getEmployeeId(), Util.null2String(employee.getCompanyWorkYear())); + } + }); + simpleUserInfoMap.get(LAST_INFO).forEach(employee -> { +// if (dimension.getDimCode().equals(SalaryStatisticsDimensionConstant.DM_AGE) && employee.getAge() != null) { +// lastEmpIdYearMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getAge().toString()); +// } else + + if (dimension.getDimCode().equals(SalaryStatisticsDimensionConstant.DM_WORK_YEAR) && employee.getWorkYear() != null) { + lastEmpIdYearMap.put(employee.getEmployeeId(), Util.null2String(employee.getWorkYear())); + } else if (dimension.getDimCode().equals(SalaryStatisticsDimensionConstant.DM_COMPANY_YEAR) && employee.getCompanyWorkYear() != null) { + lastEmpIdYearMap.put(employee.getEmployeeId(), Util.null2String(employee.getCompanyWorkYear())); + } + }); + simpleUserInfoMap.get(SAME_INFO).forEach(employee -> { +// if (dimension.getDimCode().equals(SalaryStatisticsDimensionConstant.DM_AGE) && employee.getAge() != null) { +// sameEmpIdYearMap.put(Objects.isNull(employee.getUser()) ? null : employee.getUser().getId(), employee.getAge().toString()); +// } else + if (dimension.getDimCode().equals(SalaryStatisticsDimensionConstant.DM_WORK_YEAR) && employee.getWorkYear() != null) { + sameEmpIdYearMap.put(employee.getEmployeeId(), Util.null2String(employee.getWorkYear())); + } else if (dimension.getDimCode().equals(SalaryStatisticsDimensionConstant.DM_COMPANY_YEAR) && employee.getCompanyWorkYear() != null) { + sameEmpIdYearMap.put(employee.getEmployeeId(), Util.null2String(employee.getCompanyWorkYear())); + } + }); + } + + private PageInfo> buildRationGroupIndividual4Records(SalaryStatisticsDimensionPO dimension, SalaryStatisticsReportDataDTO data, Map> salaryAcctResultValueMap) { + PageInfo> result = new PageInfo<>(); + List> records = new ArrayList<>(); + + // 分组设置 + List groups = JsonUtil.parseList(dimension.getSetting(), SalaryStatisticsDimensionSaveParam.Setting4RationGroupIndividual.class); + Map empIdYearMap = new HashMap<>(); + Map lastEmpIdYearMap = new HashMap<>(); + Map sameEmpIdYearMap = new HashMap<>(); + + String groupBelong; + if (StringUtils.isEmpty(dimension.getDimCode())) { + groupBelong = SalaryStatisticsReportBO.G_NO_ITEM; + } else if (dimension.getDimCode().equals(SalaryStatisticsDimensionConstant.DM_AGE) || dimension.getDimCode().equals(SalaryStatisticsDimensionConstant.DM_WORK_YEAR) || dimension.getDimCode().equals(SalaryStatisticsDimensionConstant.DM_COMPANY_YEAR)) { + groupBelong = SalaryStatisticsReportBO.G_YEAR; + + // 年份数据 + handle4GroupYear(dimension, empIdYearMap, lastEmpIdYearMap, sameEmpIdYearMap, data); + } else { + groupBelong = SalaryStatisticsReportBO.G_ITEM; + } + + String dimensionValue = data.getDimensionValue(); + groups.forEach(k -> { + if (dimensionValue == null) { + List salaryAcctEmployees = SalaryStatisticsReportBO.listAcctEmpByRationGroupIndividual(k, groupBelong, dimension.getDimCode(), data.getList(), empIdYearMap, salaryAcctResultValueMap, data.getSalaryStatisticsItemList()); + List lastSalaryAcctEmployees = SalaryStatisticsReportBO.listAcctEmpByRationGroupIndividual(k, groupBelong, dimension.getDimCode(), data.getLastList(), lastEmpIdYearMap, salaryAcctResultValueMap, data.getSalaryStatisticsItemList()); + List sameSalaryAcctEmployees = SalaryStatisticsReportBO.listAcctEmpByRationGroupIndividual(k, groupBelong, dimension.getDimCode(), data.getSameList(), sameEmpIdYearMap, salaryAcctResultValueMap, data.getSalaryStatisticsItemList()); + Map temp = new HashMap<>(); + temp.put(DM, k.getValue()); + temp.putAll(SalaryStatisticsReportBO.calculateItem(salaryAcctEmployees, lastSalaryAcctEmployees, sameSalaryAcctEmployees, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); + records.add(temp); + } else if (StringUtils.equals(dimensionValue, k.getValue())) { + List salaryAcctEmployees = SalaryStatisticsReportBO.listAcctEmpByRationGroupIndividual(k, groupBelong, dimension.getDimCode(), data.getList(), empIdYearMap, salaryAcctResultValueMap, data.getSalaryStatisticsItemList()); + data.setListByDimensionValue(salaryAcctEmployees); + } + }); + + result.setList(records); + return result; + } +} diff --git a/src/com/engine/salary/report/service/impl/SubTableExportServiceImpl.java b/src/com/engine/salary/report/service/impl/SubTableExportServiceImpl.java new file mode 100644 index 000000000..18d601975 --- /dev/null +++ b/src/com/engine/salary/report/service/impl/SubTableExportServiceImpl.java @@ -0,0 +1,182 @@ +package com.engine.salary.report.service.impl; + +import com.engine.core.impl.Service; +import com.engine.salary.report.service.SubTableExportService; + + +public class SubTableExportServiceImpl extends Service implements SubTableExportService { + +// private Logger logger = LoggerFactory.getLogger(this.getClass()); +// +// +// private SalaryBatchService salaryBatchService; +// +// @Override +// public Map exportCommon(ExportCommonParam param, User currentUser, String tenantKey) { +// Map map = new HashMap<>(3); +// map.put("biz", String.valueOf(IdGenerator.generate())); +// map.put("module", EntityType.hrsa.name()); +// map.put("function", "welfareCommonExcel"); +// String eteamsId = TenantRpcContext.getEteamsId(); +// LocalRunnable localRunnable = new LocalRunnable() { +// @Override +// public void execute() { +// try { +// DSTenantKeyThreadVar.tenantKey.set(tenantKey); +// exportTask(param, map, eteamsId, currentUser.getUsername(), currentUser.getEmployeeId(), tenantKey); +// } finally { +// DSTenantKeyThreadVar.tenantKey.remove(); +// } +// } +// }; +// ThreadPoolUtil.execute(localRunnable); +// return map; +// } +// +// public Map exportTask(ExportCommonParam param, Map exportMap, String eteamsId, String operateName, Long employeeId, String tenantKey) { +// List sheetList = new LinkedList<>(); +// // 工作簿 +// ExcelSheetData excelSheetData = new ExcelSheetData(); +// // 工作簿名称 +// excelSheetData.setSheetName(param.getSheetName()); +// // 报表头 +// excelSheetData.setHeaders(buildHeader(param.getColumns(), new ArrayList<>(), param.getDimensionName())); +// // 报表数据 +// excelSheetData.setRows(buildCommonData(param)); +// // 报表表头合并 +// excelSheetData.setMergedRegions(buildMergedRegions(param.getColumns())); +// // 塞进工作簿list +// sheetList.add(excelSheetData); +// // 发送 +// Map map = salaryBatchService.simpleExportExcel(ExportExcelInfo.builder() +// .bizId(exportMap.get("biz")) +// .sharePassword(param.getSharePassword()) +// .flag(true) +// .module(exportMap.get("module")) +// .userId(employeeId) +// .eteamsId(eteamsId) +// .tenantKey(tenantKey) +// .operator(operateName) +// .fileName(param.getSheetName() + ReportTimeUtil.getFormatLocalDateTime(LocalDateTime.now())) +// .handlerName("welfareCommonExcelExportHandler") +// .dataType(param.getSheetName()) +// .function("welfareCommonExcel").build(), sheetList); +// return map; +// +// } +// +// @BatchExportHandler("welfareCommonExcelExportHandler") +// public void welfareCommonExcelExportHandler() { +// BatchCallbackMessage message = BatchExportContext.getBatchCallbackMessage(); +// logger.info(SalaryI18nUtil.getI18nLabel(100292, "接受到导出的结果") + JSONObject.toJSONString(message)); +// } +// +// public int getHigh(ExportColumn column) { +// int tempHign = 1; +// if (column.getChildren() != null) { +// tempHign++; +// List children = column.getChildren(); +// for (ExportColumn exportColumn : children) { +// getHigh(exportColumn); +// } +// } +// return tempHign; +// } +// +// public List buildMergedRegions(List columns) { +// List merges = new ArrayList<>(); +// if (CollectionUtils.isEmpty(columns)) { +// return merges; +// } +// int start = 0; +// int high = 0; +// for (int i = 0; i < columns.size(); i++) { +// int columnHigh = getHigh(columns.get(i)); +// high = Math.max(high, columnHigh); +// } +// if (high == 1) { +// return null; +// } +// +// for (int i = 0; i < columns.size(); i++) { +// if (columns.get(i).getChildren() == null) { +// merges.add(new Integer[]{start, 1, 0, 0}); +// start++; +// } else if (columns.get(i).getChildren().size() == 1) { +// start++; +// } else { +// int end = start + columns.get(i).getChildren().size() - 1; +// merges.add(new Integer[]{0, 0, start, end}); +// end++; +// start = end; +// } +// } +// return merges; +// } +// +// public List> buildCommonData(ExportCommonParam param) { +// List keyIndexOrder = new ArrayList<>(); +// buildCommonKeyIndex(param.getColumns(), keyIndexOrder); +// List> result = new ArrayList<>(); +// param.getData().forEach(dataMap -> { +// List temp = new ArrayList<>(); +// keyIndexOrder.forEach(key -> { +// temp.add(dataMap.get(key)); +// }); +// result.add(temp); +// }); +// return result; +// } +// +// public void buildCommonKeyIndex(List list, List keyIndexOrder) { +// List children = new ArrayList<>(); +// if (CollectionUtils.isEmpty(list)) { +// return; +// } +// list.forEach(column -> { +// if (column.getChildren() == null) { +// keyIndexOrder.add(column.getKeyIndex()); +// } else { +// children.addAll(column.getChildren()); +// } +// }); +// buildCommonKeyIndex(children, keyIndexOrder); +// } +// +// public List buildHeader(List list, List result, String dimensionName) { +// List headers = buildCommonHeader(list, result); +// int size = headers.size(); +// List header = new ArrayList<>(Arrays.asList(headers.get(size - 1))); +// header.add(0, dimensionName); +// result.set(size - 1, header.toArray(new String[0])); +// return result; +// } +// +// /** +// * 多层级表头 +// * +// * @param list +// * @param result +// * @return +// */ +// public List buildCommonHeader(List list, List result) { +// List childList = new ArrayList<>(); +// if (CollectionUtils.isEmpty(list)) { +// return result; +// } +// List temp = new ArrayList<>(); +// list.forEach(column -> { +// if (column.getChildren() != null) { +// childList.addAll(column.getChildren()); +// column.getChildren().forEach(x -> temp.add(column.getValue())); +// } else { +// temp.add(column.getValue()); +// } +// }); +// result.add(temp.toArray(new String[0])); +// if (CollectionUtils.isNotEmpty(childList)) { +// buildCommonHeader(childList, result); +// } +// return result; +// } +} diff --git a/src/com/engine/salary/report/util/ReportDataUtil.java b/src/com/engine/salary/report/util/ReportDataUtil.java new file mode 100644 index 000000000..16c8f56f4 --- /dev/null +++ b/src/com/engine/salary/report/util/ReportDataUtil.java @@ -0,0 +1,33 @@ +package com.engine.salary.report.util; + +import org.apache.commons.lang3.StringUtils; + +import java.math.BigDecimal; +import java.text.DecimalFormat; +import java.util.regex.Pattern; + +public class ReportDataUtil { + + private static final DecimalFormat decimalFormat = new DecimalFormat("#,##0.00"); + + private static final DecimalFormat decimalFormatSp = new DecimalFormat("#,##0.000"); + + public static String thousandthConvert(String originString) { + if (StringUtils.isNotEmpty(originString)) { + if (originString.contains(".") && (originString.split("\\.")[1]).length() == 3) { + return decimalFormatSp.format(Double.valueOf(originString)); + } + return decimalFormat.format(Double.valueOf(originString)); + } + return "0.00"; + } + + public static boolean zeroJudge(BigDecimal bigDecimal) { + return Pattern.compile("[0|.]*").matcher(bigDecimal.toPlainString()).matches(); + } + + public static boolean zeroJudge(String data) { + return Pattern.compile("[0|.]*").matcher(data).matches(); + } + +} diff --git a/src/com/engine/salary/report/util/ReportEnumUtil.java b/src/com/engine/salary/report/util/ReportEnumUtil.java new file mode 100644 index 000000000..5332c7d5e --- /dev/null +++ b/src/com/engine/salary/report/util/ReportEnumUtil.java @@ -0,0 +1,31 @@ +package com.engine.salary.report.util; + +import com.engine.salary.report.enums.DimensionEnum; +import com.engine.salary.report.enums.UnitTypeEnum; +import com.engine.salary.util.SalaryI18nUtil; + +import java.util.*; + + +public class ReportEnumUtil { + + public static Map unitTypeMap() { + Map unitTypeMap = new HashMap<>(); + Arrays.stream(UnitTypeEnum.values()).forEach(unitTypeEnum -> { + unitTypeMap.put(unitTypeEnum.getValue(), SalaryI18nUtil.getI18nLabel(unitTypeEnum.getLabelId(), unitTypeEnum.getDefaultLabel())); + }); + return unitTypeMap; + } + + public static List> dimensionMap() { + List> result = new ArrayList<>(); + Arrays.stream(DimensionEnum.values()).forEach(dimensionEnum -> { + Map dimensionMap = new HashMap<>(); + dimensionMap.put("id", dimensionEnum.getValue().toString()); + dimensionMap.put("content", SalaryI18nUtil.getI18nLabel(dimensionEnum.getLabelId(), dimensionEnum.getDefaultLabel())); + result.add(dimensionMap); + }); + return result; + } + +} diff --git a/src/com/engine/salary/report/util/ReportTimeUtil.java b/src/com/engine/salary/report/util/ReportTimeUtil.java new file mode 100644 index 000000000..7a3229f77 --- /dev/null +++ b/src/com/engine/salary/report/util/ReportTimeUtil.java @@ -0,0 +1,169 @@ +package com.engine.salary.report.util; + +import cn.hutool.core.date.DateField; +import cn.hutool.core.date.DateUtil; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; + +import java.time.*; +import java.time.format.DateTimeFormatter; +import java.time.temporal.ChronoUnit; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +@Slf4j +public class ReportTimeUtil { + private static final DateTimeFormatter YEAR_MONTH = DateTimeFormatter.ofPattern("yyyy-MM"); + + public static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + + public static Map getLastRange(String startMonth, String endMonth) { + LocalDate start = LocalDate.parse(startMonth + "-01"); + LocalDate end = LocalDate.parse(endMonth + "-01"); + long between = ChronoUnit.MONTHS.between(start, end); + LocalDate lastEndMonth = start.plusMonths(-1); + LocalDate lastStartMonth = lastEndMonth.plusMonths(-between); + Map result = new HashMap<>(); + result.put("startMonth", YEAR_MONTH.format(lastStartMonth)); + result.put("endMonth", YEAR_MONTH.format(lastEndMonth)); + return result; + } + + public static String getQuarter(String billMonth) { + if (StringUtils.isBlank(billMonth)) { + return ""; + } + String[] split = billMonth.split("-"); + String year = split[0] + "年"; + String quarter = ""; + int month = Integer.parseInt(split[1]); + if (1 <= month && month <= 3) { + quarter = "1季度"; + } + if (4 <= month && month <= 6) { + quarter = "2季度"; + } + if (7 <= month && month <= 9) { + quarter = "3季度"; + } + if (10 <= month && month <= 12) { + quarter = "4季度"; + } + return year + quarter; + } + + public static String getHalfYear(String salaryMonth) { + if (StringUtils.isBlank(salaryMonth)) { + return ""; + } + String[] split = salaryMonth.split("-"); + String year = split[0] + "年-"; + String halfYear = ""; + int month = Integer.parseInt(split[1]); + if (1 <= month && month <= 6) { + halfYear = "上半年"; + } + if (7 <= month && month <= 12) { + halfYear = "下半年"; + } + return year + halfYear; + } + + public static String getYear(String billMonth) { + if (StringUtils.isEmpty(billMonth)) { + return ""; + } + String[] split = billMonth.split("-"); + return split[0] + "年"; + } + + public static String getFormatYearMonth(LocalDate localDate) { + if (localDate == null) { + return StringUtils.EMPTY; + } + try { + return localDate.format(YEAR_MONTH); + } catch (Exception e) { + log.warn("格式化月份错误", e); + return StringUtils.EMPTY; + } + } + + public static String getLastYear(String year) { + if (StringUtils.isEmpty(year)) { + return ""; + } + return (Integer.parseInt(year.replace("年", "")) - 1) + "年"; + } + + public static String getLastYearMonth(String yearMonth) { + return YEAR_MONTH.format(LocalDate.parse(yearMonth + "-01").plusMonths(-1)); + } + + public static String getSameYearMonth(String yearMonth) { + return YEAR_MONTH.format(LocalDate.parse(yearMonth + "-01").plusYears(-1)); + } + + public static Date getLastYearMonth(Date yearMonth) { + return DateUtil.offsetMonth(yearMonth,-1); + } + + public static Date getSameYearMonth(Date yearMonth) { + return DateUtil.offset(yearMonth, DateField.YEAR,-1); + } + + public static String getPlusYearMonth(String yearMonth, long months) { + return YEAR_MONTH.format(LocalDate.parse(yearMonth + "-01").plusMonths(months)); + } + + public static String getLastQuarter(String quarter) { + if (StringUtils.isEmpty(quarter)) { + return ""; + } + String[] ym = quarter.split("年"); + String year = ym[0]; + String month = ym[1].split("季度")[0]; + if ("1".equals(month)) { + year = (Integer.parseInt(year) - 1) + ""; + return year + "年" + "4季度"; + } + return year + "年" + (Integer.parseInt(month) - 1) + "季度"; + } + + public static String[] getYearMonthRange(String startMonth, String endMonth) { + LocalDate start = LocalDate.parse(startMonth + "-01"); + LocalDate end = LocalDate.parse(endMonth + "-01"); + long between = ChronoUnit.MONTHS.between(start, end); + String[] result = new String[(int) between + 1]; + result[0] = startMonth; + for (int i = 1; i < between + 1; i++) { + start = start.plusMonths(1); + if (start.isBefore(end) || start.isEqual(end)) { + result[i] = YEAR_MONTH.format(start); + } + } + return result; + } + + public static String getFormatLocalDateTime(LocalDateTime localDateTime) { + if (localDateTime == null) { + return StringUtils.EMPTY; + } + try { + return localDateTime.format(DATE_TIME_FORMATTER); + } catch (Exception e) { + log.warn("格式化日期错误", e); + return StringUtils.EMPTY; + } + } + + public static LocalDate dateToLocalDate(Date date) { + if (date == null) { + return null; + } + Instant instant = date.toInstant(); + ZonedDateTime zone = instant.atZone(ZoneId.systemDefault()); + return zone.toLocalDate(); + } +} diff --git a/src/com/engine/salary/report/web/SalaryStatisticsDimensionController.java b/src/com/engine/salary/report/web/SalaryStatisticsDimensionController.java new file mode 100644 index 000000000..16c4a64d0 --- /dev/null +++ b/src/com/engine/salary/report/web/SalaryStatisticsDimensionController.java @@ -0,0 +1,136 @@ +package com.engine.salary.report.web; + +import com.engine.common.util.ServiceUtil; +import com.engine.salary.entity.hrm.dto.EmployeeInfoExpandDTO; +import com.engine.salary.report.entity.dto.SalaryStatisticsDimensionFormDTO; +import com.engine.salary.report.entity.dto.SalaryStatisticsDimensionListDTO; +import com.engine.salary.report.entity.param.SalaryStatisticsDimensionQueryParam; +import com.engine.salary.report.entity.param.SalaryStatisticsDimensionSaveParam; +import com.engine.salary.report.wrapper.SalaryStatisticsDimensionWrapper; +import com.engine.salary.util.ResponseResult; +import com.engine.salary.util.page.PageInfo; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import java.util.Collection; +import java.util.List; +import java.util.Map; + +/** + * 薪酬统计维度 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SalaryStatisticsDimensionController { + + private SalaryStatisticsDimensionWrapper getSalaryStatisticsDimensionWrapper(User user) { + return ServiceUtil.getService(SalaryStatisticsDimensionWrapper.class, user); + } + + + /** + * 薪酬统计维度列表 + * + * @param queryParam + * @return + */ + @POST + @Path("/list") + @Produces(MediaType.APPLICATION_JSON) + public String list(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryStatisticsDimensionQueryParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalaryStatisticsDimensionWrapper(user)::list, queryParam); + } + + /** + * 获取薪酬统计维度表单 + * + * @return + */ + @GET + @Path("/getForm") + @Produces(MediaType.APPLICATION_JSON) + public String getForm(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "id") Long id) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryStatisticsDimensionWrapper(user)::getFrom, id); + } + + + /** + * 保存薪酬统计维度 + * + * @param saveParam + * @return + */ + @POST + @Path("/save") + @Produces(MediaType.APPLICATION_JSON) + public String save(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryStatisticsDimensionSaveParam saveParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryStatisticsDimensionWrapper(user)::save, saveParam); + } + + /** + * 保存薪酬统计维度扩展字段设置 + * + * @param saveParam + * @return + */ + @POST + @Path("/saveExpandFieldSettings") + @Produces(MediaType.APPLICATION_JSON) + public String saveExpandFieldSettings(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody EmployeeInfoExpandDTO saveParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryStatisticsDimensionWrapper(user)::saveExpandFieldSettings, saveParam); + } + + /** + * 查询薪酬统计维度扩展字段设置 + * + * @return + */ + @GET + @Path("/getExpandFieldSettings") + @Produces(MediaType.APPLICATION_JSON) + public String getExpandFieldSettings(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "module") String module) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryStatisticsDimensionWrapper(user)::getExpandFieldSettings, module); + } + + /** + * 删除薪酬统计维度 + * + * @param ids + * @return + */ + @POST + @Path("/delete") + @Produces(MediaType.APPLICATION_JSON) + public String delete(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Collection ids) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult, Map>(user).run(getSalaryStatisticsDimensionWrapper(user)::delete, ids); + } + + /** + * 薪酬统计维度下拉列表 + * + * @return + */ + @GET + @Path("/selectList") + @Produces(MediaType.APPLICATION_JSON) + public String selectList(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult, List>>(user).run(getSalaryStatisticsDimensionWrapper(user)::selectList); + } + +} diff --git a/src/com/engine/salary/report/web/SalaryStatisticsEchartsController.java b/src/com/engine/salary/report/web/SalaryStatisticsEchartsController.java new file mode 100644 index 000000000..08bce611e --- /dev/null +++ b/src/com/engine/salary/report/web/SalaryStatisticsEchartsController.java @@ -0,0 +1,78 @@ +package com.engine.salary.report.web; + +import com.engine.common.util.ServiceUtil; +import com.engine.salary.report.entity.dto.SalaryStatisticsEchartsDTO; +import com.engine.salary.report.wrapper.SalaryStatisticsEchartsWrapper; +import com.engine.salary.util.ResponseResult; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; + +/** + * 薪酬统计图表 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SalaryStatisticsEchartsController { + + private SalaryStatisticsEchartsWrapper getSalaryStatisticsEchartsWrapper(User user) { + return ServiceUtil.getService(SalaryStatisticsEchartsWrapper.class, user); + } + /** + * 分析图数据展示范围设置保存 + * + * @param saveParam + * @return + */ + @POST + @Path("/saveRangeSetting") + @Produces(MediaType.APPLICATION_JSON) + public String saveRangeSetting(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryStatisticsEchartsDTO saveParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryStatisticsEchartsWrapper(user)::saveRangeSetting, saveParam); + } + + + /** + * 分析图数据展示范围设置删除 + * + * @param reportId + * @return + */ + @GET + @Path("/deleteRangeSetting") + @Produces(MediaType.APPLICATION_JSON) + public String deleteRangeSetting(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "reportId")Long reportId) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryStatisticsEchartsWrapper(user)::deleteRangeSetting, reportId); + } + + /** + * 分析图数据展示范围设置查询 + * + * @param reportId + * @param chartsType + * @return + */ + @GET + @Path("/queryRangeSetting") + @Produces(MediaType.APPLICATION_JSON) + public String deleteRangeSetting(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "reportId")Long reportId, @QueryParam(value = "chartsType")Integer chartsType) { + User user = HrmUserVarify.getUser(request, response); + SalaryStatisticsEchartsDTO resp = SalaryStatisticsEchartsDTO.builder() + .reportId(reportId) + .chartsType(chartsType) + .build(); + return new ResponseResult(user).run(getSalaryStatisticsEchartsWrapper(user)::queryRangeSetting, resp); + } + +} diff --git a/src/com/engine/salary/report/web/SalaryStatisticsEmployeeController.java b/src/com/engine/salary/report/web/SalaryStatisticsEmployeeController.java new file mode 100644 index 000000000..4fa4ae64a --- /dev/null +++ b/src/com/engine/salary/report/web/SalaryStatisticsEmployeeController.java @@ -0,0 +1,137 @@ +package com.engine.salary.report.web; + +import com.engine.common.util.ServiceUtil; +import com.engine.salary.report.entity.dto.SalaryStatisticsEmployeeListDTO; +import com.engine.salary.report.entity.param.SalaryStatisticsEmployeeDetailQueryParam; +import com.engine.salary.report.entity.param.SalaryStatisticsEmployeeQueryParam; +import com.engine.salary.report.entity.param.SalaryStatisticsEmployeeSalaryQueryParam; +import com.engine.salary.report.wrapper.SalaryStatisticsEmployeeWrapper; +import com.engine.salary.util.ResponseResult; +import com.engine.salary.util.page.PageInfo; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import lombok.extern.slf4j.Slf4j; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.StreamingOutput; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.time.LocalDate; +import java.util.Map; + + +/** + * 薪酬统计员工明细 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Slf4j +public class SalaryStatisticsEmployeeController { + + private SalaryStatisticsEmployeeWrapper getSalaryStatisticsEmployeeWrapper(User user) { + return ServiceUtil.getService(SalaryStatisticsEmployeeWrapper.class, user); + } + + /** + * 员工列表 + * + * @param queryParam + * @return + */ + @POST + @Path("/list") + @Produces(MediaType.APPLICATION_JSON) + public String list(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryStatisticsEmployeeQueryParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalaryStatisticsEmployeeWrapper(user)::list, queryParam); + } + + /** + * 员工详情列表 + * + * @param queryParam + * @return + */ + @POST + @Path("/detailList") + @Produces(MediaType.APPLICATION_JSON) + public String detailList(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryStatisticsEmployeeDetailQueryParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalaryStatisticsEmployeeWrapper(user)::detailList, queryParam); + } + + /** + * 薪资明细 + * + * @param queryParam + * @return + */ + @POST + @Path("/salaryList") + @Produces(MediaType.APPLICATION_JSON) + public String salaryList(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryStatisticsEmployeeSalaryQueryParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalaryStatisticsEmployeeWrapper(user)::salaryList, queryParam); + } + + /** + * 员工薪资列表合计行 + * + * @param queryParam + * @return + */ + @POST + @Path("/salaryListSum") + @Produces(MediaType.APPLICATION_JSON) + public String salaryListSum(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryStatisticsEmployeeSalaryQueryParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalaryStatisticsEmployeeWrapper(user)::salaryListSum, queryParam); + } + + /** + * 导出员工薪资列表 + * + * @param queryParam + * @return + */ + @POST + @Path("/exportSalaryList") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response exportSalaryList(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryStatisticsEmployeeSalaryQueryParam queryParam) { + try { + User user = HrmUserVarify.getUser(request, response); + XSSFWorkbook workbook = getSalaryStatisticsEmployeeWrapper(user).exportSalaryList(queryParam); + + String fileName = "薪资明细" + LocalDate.now(); + + try { + fileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8"); + } catch (UnsupportedEncodingException e) { + log.error(e.getMessage(), e); + } + + StreamingOutput output = outputStream -> { + workbook.write(outputStream); + outputStream.flush(); + }; + response.setContentType("application/octet-stream"); + return Response.ok(output).header("Content-disposition", "attachment;filename=" + fileName).header("Cache-Control", "no-cache").build(); + + } catch (Exception e) { + log.error("薪资明细导出异常", e); + throw e; + } + } +} diff --git a/src/com/engine/salary/report/web/SalaryStatisticsItemController.java b/src/com/engine/salary/report/web/SalaryStatisticsItemController.java new file mode 100644 index 000000000..c59c12b3b --- /dev/null +++ b/src/com/engine/salary/report/web/SalaryStatisticsItemController.java @@ -0,0 +1,107 @@ +package com.engine.salary.report.web; + +import com.engine.common.util.ServiceUtil; +import com.engine.salary.report.entity.dto.SalaryStatisticsItemFormDTO; +import com.engine.salary.report.entity.param.SalaryStatisticsItemSaveParam; +import com.engine.salary.report.wrapper.SalaryStatisticsItemWrapper; +import com.engine.salary.util.ResponseResult; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import java.util.Collection; +import java.util.List; +import java.util.Map; + +/** + * 薪酬报表统计项目 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SalaryStatisticsItemController { + + private SalaryStatisticsItemWrapper getSalaryStatisticsItemWrapper(User user) { + return ServiceUtil.getService(SalaryStatisticsItemWrapper.class, user); + } + + /** + * 获取自定义统计项目表单 + * + * @param id + * @return + */ + @GET + @Path("/getForm") + @Produces(MediaType.APPLICATION_JSON) + public String getForm(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "id") Long id) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryStatisticsItemWrapper(user)::getForm, id); + } + + /** + * 切换薪资项目 + * @param request + * @param response + * @param itemId + * @return + */ + @GET + @Path("/changeTab") + @Produces(MediaType.APPLICATION_JSON) + public String changeTab(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "itemId") Long itemId) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryStatisticsItemWrapper(user)::changeTab, itemId); + } + + + /** + * 自定义统计项目列表 + * + * @param statisticsReportId + * @return + */ + @GET + @Path("/list") + @Produces(MediaType.APPLICATION_JSON) + public String list(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "statisticsReportId") Long statisticsReportId) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>>(user).run(getSalaryStatisticsItemWrapper(user)::list, statisticsReportId); + } + + /** + * 删除自定义统计项目 + * + * @param ids + * @return + */ + @POST + @Path("/delete") + @Produces(MediaType.APPLICATION_JSON) + public String delete(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Collection ids) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult, String>(user).run(getSalaryStatisticsItemWrapper(user)::delete, ids); + } + + + /** + * 保存自定义统计项目 + * + * @param param + * @return + */ + @POST + @Path("/save") + @Produces(MediaType.APPLICATION_JSON) + public String save(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryStatisticsItemSaveParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryStatisticsItemWrapper(user)::save, param); + } +} diff --git a/src/com/engine/salary/report/web/SalaryStatisticsPushController.java b/src/com/engine/salary/report/web/SalaryStatisticsPushController.java new file mode 100644 index 000000000..64a11d5f9 --- /dev/null +++ b/src/com/engine/salary/report/web/SalaryStatisticsPushController.java @@ -0,0 +1,143 @@ +package com.engine.salary.report.web; + +import com.engine.common.util.ServiceUtil; +import com.engine.salary.common.BaseQueryParam; +import com.engine.salary.report.entity.dto.SalaryStatisticsPushDetail; +import com.engine.salary.report.entity.dto.SalaryStatisticsPushTableDTO; +import com.engine.salary.report.entity.param.SalaryStatisticsPushDetailParam; +import com.engine.salary.report.entity.param.SalaryStatisticsPushParam; +import com.engine.salary.report.service.SalaryStatisticsPushService; +import com.engine.salary.report.service.impl.SalaryStatisticsPushServiceImpl; +import com.engine.salary.util.ResponseResult; +import com.engine.salary.util.page.PageInfo; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import java.util.Map; + +/** + * @author Harryxzy + * @ClassName SalaryStatisticsPushController + * @date 2023/09/11 10:08 + * @description 薪酬统计报表消息推送 + */ +public class SalaryStatisticsPushController { + + + private SalaryStatisticsPushService getSalaryStatisticsPushService(User user) { + return ServiceUtil.getService(SalaryStatisticsPushServiceImpl.class, user); + } + + + /** + * 获取发送消息form + * + * @return obj + */ + @GET + @Path("/getForm") + @Produces(MediaType.APPLICATION_JSON) + public String getPushForm(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalaryStatisticsPushService(user)::getPushForm); + } + + /** + * 获取分享记录列表 + * + * @return obj + */ + @POST + @Path("/getTable") + @Produces(MediaType.APPLICATION_JSON) + public String getPushTable(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody BaseQueryParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalaryStatisticsPushService(user)::getPushTable, param); + } + + /** + * 获取发送消息记录详情 + * + * @return obj + */ + @POST + @Path("/getDetail") + @Produces(MediaType.APPLICATION_JSON) + public String getPushDetail(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryStatisticsPushDetailParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryStatisticsPushService(user)::getPushDetail, param); + } + + + /** + * 分享报表 + * + * @return obj + */ + @POST + @Path("/sendMsg") + @Produces(MediaType.APPLICATION_JSON) + public String push(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryStatisticsPushParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryStatisticsPushService(user)::push, param); + } + + /** + * 追加分享人发送消息 + * + * @return obj + */ + @POST + @Path("/addSharedSendMsg") + @Produces(MediaType.APPLICATION_JSON) + public String addSharePush(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryStatisticsPushParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryStatisticsPushService(user)::addSharedPush, param); + } + +// /** +// * 发送消息 +// * +// * @return obj +// */ +// @GetMapping("/reSendMsg") +// @ApiOperation("重新发送消息") +// @WeaPermission(publicPermission = true) +// public WeaResult push(@RequestParam Long id) { +// salaryStatisticsPushService.rePush(id, UserContext.getCurrentEmployeeId(), TenantContext.getCurrentTenantKey()); +// return WeaResult.success(""); +// } + + /** + * 撤回消息 + * + * @return obj + */ + @GET + @Path("/cancel") + @Produces(MediaType.APPLICATION_JSON) + public String cancel(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam("id") Long id) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryStatisticsPushService(user)::cancel, id); + } + + /** + * 撤回全部消息 + * + * @return obj + */ + @GET + @Path("/cancelAll") + @Produces(MediaType.APPLICATION_JSON) + public String cancelAll(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam("id") Long id) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryStatisticsPushService(user)::cancelAll, id); + } + +} diff --git a/src/com/engine/salary/report/web/SalaryStatisticsReportController.java b/src/com/engine/salary/report/web/SalaryStatisticsReportController.java new file mode 100644 index 000000000..219ee67a0 --- /dev/null +++ b/src/com/engine/salary/report/web/SalaryStatisticsReportController.java @@ -0,0 +1,226 @@ +package com.engine.salary.report.web; + +import com.engine.common.util.ServiceUtil; +import com.engine.salary.report.entity.param.*; +import com.engine.salary.report.wrapper.SalaryStatisticsReportWrapper; +import com.engine.salary.util.ResponseResult; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import lombok.extern.slf4j.Slf4j; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.StreamingOutput; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.time.LocalDate; +import java.util.Collection; +import java.util.List; +import java.util.Map; + +/** + * 薪酬统计报表 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Slf4j +public class SalaryStatisticsReportController { + + private SalaryStatisticsReportWrapper getSalaryStatisticsReportWrapper(User user) { + return ServiceUtil.getService(SalaryStatisticsReportWrapper.class, user); + } + + + /** + * 薪酬统计报表列表 + * + * @return + */ + @POST + @Path("/list") + @Produces(MediaType.APPLICATION_JSON) + public String list(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryStatisticsReportQueryParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>>(user).run(getSalaryStatisticsReportWrapper(user)::list, queryParam); + } + + /** + * 获取薪酬统计报表表单 + * + * @return + */ + @GET + @Path("/getForm") + @Produces(MediaType.APPLICATION_JSON) + public String getForm(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "id") Long id) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalaryStatisticsReportWrapper(user)::getFrom, id); + } + + /** + * 保存薪酬统计报表 + * + * @param param + * @return + */ + @POST + @Path("/save") + @Produces(MediaType.APPLICATION_JSON) + public String save(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryStatisticsReportSaveParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryStatisticsReportWrapper(user)::save, param); + } + + /** + * 删除薪酬统计报表 + * + * @param ids + * @return + */ + @POST + @Path("/delete") + @Produces(MediaType.APPLICATION_JSON) + public String delete(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Collection ids) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult, Map>(user).run(getSalaryStatisticsReportWrapper(user)::delete, ids); + } + + /** + * 复制薪酬统计报表 + * + * @param id + * @return + */ + @GET + @Path("/duplicate") + @Produces(MediaType.APPLICATION_JSON) + public String duplicate(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "id") Long id) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryStatisticsReportWrapper(user)::duplicate, id); + } + + /** + * 获取薪酬统计报表查询条件 + * + * @param request + * @param response + * @param id + * @return + */ + @GET + @Path("/getSearchCondition") + @Produces(MediaType.APPLICATION_JSON) + public String getSearchCondition(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "id") Long id) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalaryStatisticsReportWrapper(user)::getSearchCondition, id); + } + + /** + * 保存薪酬统计报表查询条件 + * + * @param param + * @return + */ + @POST + @Path("/saveSearchCondition") + @Produces(MediaType.APPLICATION_JSON) + public String saveSearchCondition(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryStatisticsSearchConditionSaveParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryStatisticsReportWrapper(user)::saveSearchCondition, param); + } + + /** + * 获取薪酬统计报表数据 + * + * @param param + * @return + */ + @POST + @Path("/getData") + @Produces(MediaType.APPLICATION_JSON) + public String getData(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryStatisticsReportDataQueryParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalaryStatisticsReportWrapper(user)::getData, param); + } + + /** + * 导出报表数据 + * + * @return + */ + @POST + @Path("/exportData") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response exportData(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryStatisticsReportDataQueryParam param) { + try { + User user = HrmUserVarify.getUser(request, response); + Map map = getSalaryStatisticsReportWrapper(user).exportData(param); + XSSFWorkbook workbook = (XSSFWorkbook) map.get("workbook"); + String time = LocalDate.now().toString(); + String fileName = map.get("fileName") + "-" + time; + try { + fileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + StreamingOutput output = outputStream -> { + workbook.write(outputStream); + outputStream.flush(); + }; + response.setContentType("application/octet-stream"); + return Response.ok(output).header("Content-disposition", "attachment;filename=" + fileName).header("Cache-Control", "no-cache").build(); + } catch (Exception e) { + log.error("核算人员范围导出异常", e); + throw e; + } + } + + /** + * 获取报表的透视数据信息 + * + * @return + */ + @POST + @Path("/getDataPerspective") + @Produces(MediaType.APPLICATION_JSON) + public String getDataPerspective(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryStatisticsDataPerspectiveQueryParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalaryStatisticsReportWrapper(user)::getDataPerspective, param); + } + + @POST + @Path("/exportDataPerspective") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response exportDataPerspective(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryStatisticsDataPerspectiveQueryParam param) { + try { + User user = HrmUserVarify.getUser(request, response); + Map map = getSalaryStatisticsReportWrapper(user).exportDataPerspective(param); + XSSFWorkbook workbook = (XSSFWorkbook) map.get("workbook"); + String time = LocalDate.now().toString(); + String fileName = map.get("fileName") + "-" + time; + try { + fileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + StreamingOutput output = outputStream -> { + workbook.write(outputStream); + outputStream.flush(); + }; + response.setContentType("application/octet-stream"); + return Response.ok(output).header("Content-disposition", "attachment;filename=" + fileName).header("Cache-Control", "no-cache").build(); + } catch (Exception e) { + log.error("报表明细内容导出异常", e); + throw e; + } + } +} diff --git a/src/com/engine/salary/report/wrapper/SalaryStatisticsDimensionWrapper.java b/src/com/engine/salary/report/wrapper/SalaryStatisticsDimensionWrapper.java new file mode 100644 index 000000000..70261fc4d --- /dev/null +++ b/src/com/engine/salary/report/wrapper/SalaryStatisticsDimensionWrapper.java @@ -0,0 +1,240 @@ +package com.engine.salary.report.wrapper; + +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.component.WeaFormOption; +import com.engine.salary.entity.hrm.dto.EmployeeInfoExpandDTO; +import com.engine.salary.entity.salaryitem.po.SalaryItemPO; +import com.engine.salary.enums.salaryitem.SalaryDataTypeEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.report.common.constant.SalaryStatisticsDimensionConstant; +import com.engine.salary.report.entity.dto.SalaryStatisticsDimensionFormDTO; +import com.engine.salary.report.entity.dto.SalaryStatisticsDimensionListDTO; +import com.engine.salary.report.entity.param.SalaryStatisticsDimensionQueryParam; +import com.engine.salary.report.entity.param.SalaryStatisticsDimensionSaveParam; +import com.engine.salary.report.entity.po.SalaryStatisticsDimensionPO; +import com.engine.salary.report.entity.po.SalaryStatisticsReportPO; +import com.engine.salary.report.enums.SalaryStatisticsDimensionTypeEnum; +import com.engine.salary.report.service.SalaryStatisticsDimensionService; +import com.engine.salary.report.service.SalaryStatisticsReportService; +import com.engine.salary.report.service.impl.SalaryStatisticsDimensionServiceImpl; +import com.engine.salary.report.service.impl.SalaryStatisticsReportServiceImpl; +import com.engine.salary.service.SalaryItemService; +import com.engine.salary.service.impl.SalaryItemServiceImpl; +import com.engine.salary.util.JsonUtil; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.util.page.SalaryPageUtil; +import com.engine.salary.util.valid.ValidUtil; +import com.google.common.collect.Lists; +import org.apache.commons.collections4.CollectionUtils; +import weaver.hrm.User; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * 薪酬统计维度 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SalaryStatisticsDimensionWrapper extends Service { + + + private SalaryStatisticsDimensionService salaryStatisticsDimensionService(User user) { + return ServiceUtil.getService(SalaryStatisticsDimensionServiceImpl.class, user); + } + + private SalaryItemService salaryItemService(User user) { + return ServiceUtil.getService(SalaryItemServiceImpl.class, user); + } + + private SalaryStatisticsDimensionService getSalaryStatisticsDimensionService(User user) { + return ServiceUtil.getService(SalaryStatisticsDimensionServiceImpl.class, user); + } + + private SalaryStatisticsReportService getSalaryStatisticsReportService(User user) { + return ServiceUtil.getService(SalaryStatisticsReportServiceImpl.class, user); + } + + /** + * 薪酬统计维度列表 + * + * @param queryParam + * @return + */ + public PageInfo list(SalaryStatisticsDimensionQueryParam queryParam) { + PageInfo page = salaryStatisticsDimensionService(user).listPage(queryParam); + List list = page.getList(); + List dtoList = new ArrayList<>(); + + // 获取默认维度统计 + List defaultSalaryStatisticsDimensions = getSalaryStatisticsDimensionService(user).listAllDefaultDimension(); + List defaultDimensionIds = defaultSalaryStatisticsDimensions.stream().map(SalaryStatisticsDimensionPO::getId).collect(Collectors.toList()); + // 获取有薪资统计报表引用的统计维度 + Set haveUsedDimIds = new HashSet<>(); + List salaryStatisticsReports = getSalaryStatisticsReportService(user).listAll(); + salaryStatisticsReports.stream().forEach(report -> Collections.addAll(haveUsedDimIds, report.getDimension().split(","))); + if (CollectionUtils.isNotEmpty(list)) { + list.stream().forEach(m -> { + SalaryStatisticsDimensionListDTO dto = SalaryStatisticsDimensionListDTO.builder() + .id(m.getId()) + .dimName(m.getDimName()) + .remark(m.getRemark()) + .dimType(SalaryStatisticsDimensionTypeEnum.getDefaultLabelByValue(m.getDimType())) + .isDefault(m.getIsDefault()) + .canEdit(true) + .canDelete(true) + .build(); + if (defaultDimensionIds.contains(dto.getId())) { + // 默认维度不允许修改、删除 + dto.setCanEdit(false); + dto.setCanDelete(false); + } else if (haveUsedDimIds.contains(dto.getId().toString())) { + // 被薪资统计报表引用的不能删除 + dto.setCanDelete(false); + } + dtoList.add(dto); + }); + } + + PageInfo salaryStatisticsDimensionListDTOPageInfo = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize()); + salaryStatisticsDimensionListDTOPageInfo.setList(dtoList); + salaryStatisticsDimensionListDTOPageInfo.setTotal(page.getTotal()); + return salaryStatisticsDimensionListDTOPageInfo; + } + + /** + * 获取薪酬统计维度表单 + * + * @param id + * @return + */ + public SalaryStatisticsDimensionFormDTO getFrom(Long id) { + List salaryItemList = salaryItemService(user).listAll(); + + List statsDimOptions = Lists.newArrayList(); +// statsDimOptions.add(new WeaFormOption(SalaryStatisticsDimensionConstant.DM_SEX, SalaryI18nUtil.getI18nLabel(98622, "性别"))); +// statsDimOptions.add(new WeaFormOption(SalaryStatisticsDimensionConstant.DM_JOB_CALL, SalaryI18nUtil.getI18nLabel(173995, "职称"))); +// statsDimOptions.add(new WeaFormOption("", SalaryI18nUtil.getI18nLabel(173996, "办公地点"))); +// statsDimOptions.add(new WeaFormOption(SalaryStatisticsDimensionConstant.DM_SUPERIOR, SalaryI18nUtil.getI18nLabel(173997, "上级"))); +// statsDimOptions.add(new WeaFormOption(SalaryStatisticsDimensionConstant.DM_MARITAL_STATUS, SalaryI18nUtil.getI18nLabel(174007, "婚姻状况"))); +// statsDimOptions.add(new WeaFormOption(SalaryStatisticsDimensionConstant.DM_EDUCATION, SalaryI18nUtil.getI18nLabel(174005, "学历"))); +// statsDimOptions.add(new WeaFormOption(SalaryStatisticsDimensionConstant.DM_DEGREE, SalaryI18nUtil.getI18nLabel(174004, "学位"))); +// statsDimOptions.add(new WeaFormOption(SalaryStatisticsDimensionConstant.DM_NATION, SalaryI18nUtil.getI18nLabel(174107, "民族"))); +// statsDimOptions.add(new WeaFormOption(SalaryStatisticsDimensionConstant.DM_HOUSEHOLD_TYPE, SalaryI18nUtil.getI18nLabel(174106, "户口类型"))); +// statsDimOptions.add(new WeaFormOption(SalaryStatisticsDimensionConstant.DM_POLITICS_STATUS, SalaryI18nUtil.getI18nLabel(174105, "政治面貌"))); +// statsDimOptions.add(new WeaFormOption(SalaryStatisticsDimensionConstant.DM_AGE, SalaryI18nUtil.getI18nLabel(174001, "年龄"))); + statsDimOptions.add(new WeaFormOption(SalaryStatisticsDimensionConstant.DM_WORK_YEAR, SalaryI18nUtil.getI18nLabel(174000, "工龄"))); + statsDimOptions.add(new WeaFormOption(SalaryStatisticsDimensionConstant.DM_COMPANY_YEAR, SalaryI18nUtil.getI18nLabel(174003, "司龄"))); + statsDimOptions.addAll(salaryItemList.stream().map(item -> new WeaFormOption(item.getId().toString(), item.getName())).collect(Collectors.toList())); + + List groupDimOptions = Lists.newArrayList(); +// groupDimOptions.add(new WeaFormOption(SalaryStatisticsDimensionConstant.DM_AGE, SalaryI18nUtil.getI18nLabel(174001, "年龄"))); + groupDimOptions.add(new WeaFormOption(SalaryStatisticsDimensionConstant.DM_WORK_YEAR, SalaryI18nUtil.getI18nLabel(174000, "工龄"))); + groupDimOptions.add(new WeaFormOption(SalaryStatisticsDimensionConstant.DM_COMPANY_YEAR, SalaryI18nUtil.getI18nLabel(174003, "司龄"))); + groupDimOptions.addAll(salaryItemList.stream() + .filter(item -> SalaryDataTypeEnum.NUMBER.getValue().equals(item.getDataType())) + .map(item -> new WeaFormOption(item.getId().toString(), item.getName())).collect(Collectors.toList())); + // 1.构建基础信息表单 + Map baseForm = new HashMap<>(); + baseForm.put("statsDimOptions", statsDimOptions); + baseForm.put("groupDimOptions", groupDimOptions); + // 2.分组设置 + String groupSetting = "[]"; + if (id != null) { + SalaryStatisticsDimensionPO po = this.salaryStatisticsDimensionService(user).getById(id); + if (po == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(161116, "薪酬统计维度不存在")); + } + groupSetting = po.getSetting(); + Map result = JsonUtil.parseMap(po, Object.class); + if (SalaryStatisticsDimensionTypeEnum.QUALITATIVE.getValue().equals(po.getDimType())) { + result.put("statsDim", po.getDimCode()); + } else { + result.put("groupDim", po.getDimCode()); + } + baseForm.put("data", result); + + /** + * 定量-组距式分组 + * [{"id":"1","includeStart":true,"startValue: "10086", "indludeEnd": true, "endValue:"19999"},{"id":"2","includeStart":true,"startValue":"10086","indludeEnd":true,"endValue":"19999"}] + * + * 定量-单项式分组 + * [{id:"3",value:"19999"},{id:"3",value:"19999"}] + */ + } else { + SalaryStatisticsDimensionPO po = SalaryStatisticsDimensionPO.builder() + .dimType(SalaryStatisticsDimensionTypeEnum.QUALITATIVE.getValue()) + .build(); + baseForm.put("data", JsonUtil.parseMap(po, Object.class)); + } + + return SalaryStatisticsDimensionFormDTO.builder() + .id(id) + .baseForm(baseForm) + .groupSetting(groupSetting) + .build(); + } + + /** + * 保存薪酬统计维度 + * + * @param saveParam + * @return + */ + public String save(SalaryStatisticsDimensionSaveParam saveParam) { + return salaryStatisticsDimensionService(user).save(saveParam); + } + + /** + * 保存薪酬统计维度扩展设置 + * + * @param saveParam + * @return + */ + public void saveExpandFieldSettings(EmployeeInfoExpandDTO saveParam) { + ValidUtil.modify(saveParam); +// Optional.ofNullable(saveParam.getFieldSettings()).orElse(new ArrayList<>()).forEach(fieldSetting -> fieldSetting.setField(fieldSetting.getField().trim())); + salaryStatisticsDimensionService(user).saveExpandFieldSettings(saveParam); + } + + + /** + * 查询薪酬统计维度扩展字段设置 + * + * @return + */ + public EmployeeInfoExpandDTO getExpandFieldSettings(String module) { + return salaryStatisticsDimensionService(user).getExpandFieldSettings(module); + } + + /** + * 删除薪酬统计维度 + * + * @param ids + * @return + */ + public Map delete(Collection ids) { + return salaryStatisticsDimensionService(user).delete(ids); + } + + /** + * 薪酬统计维度下拉列表 + * + * @return + */ + public List> selectList() { + List salaryStatisticsDimensions = salaryStatisticsDimensionService(user).listAll(); + return salaryStatisticsDimensions.stream().map(m -> { + Map map = new HashMap<>(2); + map.put("id", String.valueOf(m.getId())); + map.put("content", m.getDimName()); + return map; + }).collect(Collectors.toList()); + } + +} diff --git a/src/com/engine/salary/report/wrapper/SalaryStatisticsEchartsWrapper.java b/src/com/engine/salary/report/wrapper/SalaryStatisticsEchartsWrapper.java new file mode 100644 index 000000000..a29a26006 --- /dev/null +++ b/src/com/engine/salary/report/wrapper/SalaryStatisticsEchartsWrapper.java @@ -0,0 +1,51 @@ +package com.engine.salary.report.wrapper; + +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.report.entity.dto.SalaryStatisticsEchartsDTO; +import com.engine.salary.report.service.SalaryStatisticsEchartsService; +import com.engine.salary.report.service.impl.SalaryStatisticsEchartsServiceImpl; +import weaver.hrm.User; + +/** + * 薪酬统计图表 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SalaryStatisticsEchartsWrapper extends Service { + + private SalaryStatisticsEchartsService getSalaryStatisticsEchartsService(User user) { + return ServiceUtil.getService(SalaryStatisticsEchartsServiceImpl.class, user); + } + /** + * 分析图数据展示范围设置保存 + * + * @param saveParam + * @return + */ + public String saveRangeSetting(SalaryStatisticsEchartsDTO saveParam) { + return getSalaryStatisticsEchartsService(user).saveRangeSetting(saveParam); + } + + /** + * 分析图数据展示范围设置删除 + * + * @param reportId + * @return + */ + public String deleteRangeSetting(Long reportId) { + return getSalaryStatisticsEchartsService(user).deleteRangeSetting(reportId); + } + + /** + * 分析图数据展示范围设置查询 + * + * @return + */ + public SalaryStatisticsEchartsDTO queryRangeSetting(SalaryStatisticsEchartsDTO param) { + return getSalaryStatisticsEchartsService(user).queryRangeSetting(param); + } +} diff --git a/src/com/engine/salary/report/wrapper/SalaryStatisticsEmployeeWrapper.java b/src/com/engine/salary/report/wrapper/SalaryStatisticsEmployeeWrapper.java new file mode 100644 index 000000000..3a5efdb87 --- /dev/null +++ b/src/com/engine/salary/report/wrapper/SalaryStatisticsEmployeeWrapper.java @@ -0,0 +1,364 @@ +package com.engine.salary.report.wrapper; + +import com.cloudstore.eccom.constant.WeaBoolAttr; +import com.cloudstore.eccom.pc.table.WeaTableColumn; +import com.cloudstore.eccom.result.WeaResultMsg; +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.component.SalaryWeaTable; +import com.engine.salary.component.WeaTableColumnGroup; +import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO; +import com.engine.salary.entity.salaryarchive.dto.SalaryArchiveListDTO; +import com.engine.salary.entity.salaryitem.po.SalaryItemPO; +import com.engine.salary.entity.setting.param.PageListTemplateQueryParam; +import com.engine.salary.entity.setting.po.PageListTemplatePO; +import com.engine.salary.enums.salaryitem.SalaryDataTypeEnum; +import com.engine.salary.report.common.constant.SalaryConstant; +import com.engine.salary.report.entity.bo.SalaryStatisticsReportBO; +import com.engine.salary.report.entity.dto.SalaryStatisticsEmployeeDetailResultDTO; +import com.engine.salary.report.entity.dto.SalaryStatisticsEmployeeListDTO; +import com.engine.salary.report.entity.param.SalaryStatisticsEmployeeDetailQueryParam; +import com.engine.salary.report.entity.param.SalaryStatisticsEmployeeQueryParam; +import com.engine.salary.report.entity.param.SalaryStatisticsEmployeeSalaryQueryParam; +import com.engine.salary.report.service.SalaryStatisticsEmployeeService; +import com.engine.salary.report.service.impl.SalaryStatisticsEmployeeServiceImpl; +import com.engine.salary.report.util.ReportDataUtil; +import com.engine.salary.service.SalaryItemService; +import com.engine.salary.service.SettingService; +import com.engine.salary.service.impl.SalaryItemServiceImpl; +import com.engine.salary.service.impl.SettingServiceImpl; +import com.engine.salary.sys.service.SalarySysConfService; +import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.excel.ExcelFillUtils; +import com.engine.salary.util.excel.ExcelUtilPlus; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.util.page.SalaryPageUtil; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.math.NumberUtils; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import weaver.file.ImageFileManager; +import weaver.general.Util; +import weaver.hrm.User; + +import java.io.InputStream; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.stream.Collectors; + +import static com.engine.salary.enums.setting.PageListSettingPageEnum.SALARY_DETAILS_REPORT; +import static com.engine.salary.sys.constant.SalarySysConstant.SALARY_DETAILS_REPORT_SHOW_TYPE; + +/** + * 薪酬统计员工明细 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SalaryStatisticsEmployeeWrapper extends Service { + + private SalaryStatisticsEmployeeService getSalaryStatisticsEmployeeService(User user) { + return ServiceUtil.getService(SalaryStatisticsEmployeeServiceImpl.class, user); + } + + private SalaryItemService getSalaryItemService(User user) { + return ServiceUtil.getService(SalaryItemServiceImpl.class, user); + } + + private SettingService getSettingService(User user) { + return ServiceUtil.getService(SettingServiceImpl.class, user); + } + + private SalarySysConfService getSalarySysConfService(User user) { + return ServiceUtil.getService(SalarySysConfServiceImpl.class, user); + } + + //是否模板显示 + private final boolean templateShow = "1".equals(getSalarySysConfService(user).getValueByCode(SALARY_DETAILS_REPORT_SHOW_TYPE)); + + /** + * 员工列表 + * + * @param queryParam + * @return + */ + public PageInfo list(SalaryStatisticsEmployeeQueryParam queryParam) { + return getSalaryStatisticsEmployeeService(user).listPage(queryParam); + } + + /** + * 员工详情列表 + * + * @param queryParam + * @return + */ + public Map detailList(SalaryStatisticsEmployeeDetailQueryParam queryParam) { + // 获取核算数据 + SalaryStatisticsEmployeeDetailResultDTO salaryStatisticsEmployeeDetailResult = getSalaryStatisticsEmployeeService(user).getDetailSalaryAcctResult(queryParam); + List> records = getSalaryStatisticsEmployeeService(user).listDetailPage(salaryStatisticsEmployeeDetailResult, queryParam); + + Map countResultMap = Maps.newHashMap(); + if (CollectionUtils.isNotEmpty(records)) { + List salaryItems = salaryStatisticsEmployeeDetailResult.getSalaryItemList(); + for (SalaryItemPO item : salaryItems) { + BigDecimal sumBigDecimal = new BigDecimal(SalaryStatisticsReportBO.ZERO); + String itemKey = item.getId() + SalaryConstant.DYNAMIC_SUFFIX; + for (Map record : records) { + if (record.containsKey(itemKey)) { + if (Objects.nonNull(record.get(itemKey)) && StringUtils.isNotEmpty(record.get(itemKey).toString()) && NumberUtils.isCreatable(record.get(itemKey).toString())) { + sumBigDecimal = sumBigDecimal.add(new BigDecimal(record.get(itemKey).toString())); + record.put(itemKey, ReportDataUtil.thousandthConvert(record.get(itemKey).toString())); + } + } + } + countResultMap.put(itemKey, ReportDataUtil.thousandthConvert(sumBigDecimal.toString())); + } + } + PageInfo> pageInfo = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), records); + + // 列表columns + List weaTableColumns = buildDetailTableColumns(salaryStatisticsEmployeeDetailResult, false); + + SalaryWeaTable table = new SalaryWeaTable(user, SalaryStatisticsEmployeeDetailResultDTO.class); + table.setColumns(weaTableColumns); + + WeaResultMsg result = new WeaResultMsg(false); + result.putAll(table.makeDataResult()); + result.success(); + + // 结果 + Map resultMap = Maps.newHashMap(); +// resultMap.put("columns", weaTableColumns); + resultMap.put("dataKey", result.getResultMap()); + resultMap.put("pageInfo", pageInfo); + resultMap.put("countResult", countResultMap); + return resultMap; + } + + private List buildDetailTableColumns(SalaryStatisticsEmployeeDetailResultDTO salaryStatisticsEmployeeDetailResult, boolean isSalaryList) { + // 表格表头 + List columns = new ArrayList<>(); + columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(87614, "薪资所属月"), "salaryMonth")); + columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(86184, "个税扣缴义务人"), "taxAgent")); + columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(86184, "账套"), "salarySob")); + if (isSalaryList) { + columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(0, "姓名"), "userName")); + columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(0, "分部"), "subCompany")); + columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(0, "部门"), "department")); + columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(0, "岗位"), "jobTitle")); + columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(0, "员工状态"), "status")); + columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(0, "工号"), "workCode")); + columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(0, "入职日期"), "companystartdate")); + } + columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(86184, "次数"), "acctTimes").setDisplay(WeaBoolAttr.FALSE)); +// columns.add(new WeaTableColumn("100px",SalaryI18nUtil.getI18nLabel( 121908, "收入所得项目"), "incomeCategory")); + salaryStatisticsEmployeeDetailResult.getSalaryItemList().forEach(item -> { + columns.add(new WeaTableColumn("100px", item.getName(), item.getId() + SalaryConstant.DYNAMIC_SUFFIX)); + }); + return columns; + } + + /** + * 获取员工发薪明细列表 + * + * @param queryParam + */ + public Map salaryList(SalaryStatisticsEmployeeSalaryQueryParam queryParam) { + Map resultMap = Maps.newHashMap(); + if (StringUtils.isBlank(queryParam.getStartDateStr()) || StringUtils.isBlank(queryParam.getEndDateStr())) { + return resultMap; + } + // 获取发薪人员 + PageInfo salaryAcctEmployeePageInfo = getSalaryStatisticsEmployeeService(user).listSalaryAcctEmp(queryParam); + // 获取薪资核算结果 + SalaryStatisticsEmployeeDetailResultDTO salaryStatisticsEmployeeDetailResult = getSalaryStatisticsEmployeeService(user).getDetailSalaryAcctResultByAcctEmp(salaryAcctEmployeePageInfo.getList()); + List> records = getSalaryStatisticsEmployeeService(user).listDetailPage(salaryStatisticsEmployeeDetailResult, null); + + PageInfo> pageInfo = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize()); + pageInfo.setList(records); + pageInfo.setTotal(salaryAcctEmployeePageInfo.getTotal()); + + List weaTableColumns = getSettingService(user).getPageListColumns(SALARY_DETAILS_REPORT.getValue()); + List pageListTemplates = getSettingService(user).getPageListTemplates(PageListTemplateQueryParam.builder().page(SALARY_DETAILS_REPORT.getValue()).build()); + Integer fileId = pageListTemplates.stream().filter(PageListTemplatePO::getChecked).findFirst().map(PageListTemplatePO::getFileId).orElse(null); + // 结果 + resultMap.put("columns", weaTableColumns); + resultMap.put("pageInfo", pageInfo); + resultMap.put("fileId", fileId); + if (queryParam.isExport()) { + Map countResultMap = Maps.newHashMap(); + List salaryItems = salaryStatisticsEmployeeDetailResult.getSalaryItemList(); + if (CollectionUtils.isNotEmpty(records)) { + for (SalaryItemPO item : salaryItems) { + BigDecimal sumBigDecimal = new BigDecimal(SalaryStatisticsReportBO.ZERO); + String itemKey = item.getId() + SalaryConstant.DYNAMIC_SUFFIX; + for (Map record : records) { + if (Objects.nonNull(record.get(itemKey)) && NumberUtils.isCreatable(record.get(itemKey).toString())) { + sumBigDecimal = sumBigDecimal.add(new BigDecimal(record.get(itemKey).toString())); + } + } + countResultMap.put(itemKey, sumBigDecimal.toString()); + } + } + resultMap.put("salaryItems", salaryStatisticsEmployeeDetailResult.getSalaryItemList()); + resultMap.put("countResult", countResultMap); + } + return resultMap; + } + + /** + * 获取员工发薪明细列表 + * + * @param queryParam + */ + public Map salaryListSum(SalaryStatisticsEmployeeSalaryQueryParam queryParam) { + Map resultMap = Maps.newHashMap(); + Map sumResultMap = Maps.newHashMap(); + resultMap.put("sumRow", sumResultMap); + if (StringUtils.isBlank(queryParam.getStartDateStr()) || StringUtils.isBlank(queryParam.getEndDateStr())) { + return resultMap; + } + queryParam.setExport(true); + // 获取发薪人员 + PageInfo salaryAcctEmployeePageInfo = getSalaryStatisticsEmployeeService(user).listSalaryAcctEmp(queryParam); + List employeePOS = salaryAcctEmployeePageInfo.getList(); + if (CollectionUtils.isEmpty(employeePOS)) { + return resultMap; + } + + + List> empParts = Lists.partition(employeePOS, 500); + + for (int i = 0; i < empParts.size(); i++) { + // 获取薪资核算结果 + SalaryStatisticsEmployeeDetailResultDTO salaryStatisticsEmployeeDetailResult = getSalaryStatisticsEmployeeService(user).getDetailSalaryAcctResultByAcctEmp(empParts.get(i)); + List> records = getSalaryStatisticsEmployeeService(user).listDetailPage(salaryStatisticsEmployeeDetailResult, null); + + if (CollectionUtils.isNotEmpty(records)) { + List salaryItems = salaryStatisticsEmployeeDetailResult.getSalaryItemList(); + // 过滤只统计数值型薪资项目 + salaryItems = salaryItems.stream().filter(salaryItemPO -> salaryItemPO.getDataType().equals(SalaryDataTypeEnum.NUMBER.getValue())).collect(Collectors.toList()); + for (SalaryItemPO item : salaryItems) { + BigDecimal sumBigDecimal = new BigDecimal(SalaryStatisticsReportBO.ZERO); + String itemKey = item.getId() + SalaryConstant.DYNAMIC_SUFFIX; + for (Map record : records) { + if (record.containsKey(itemKey)) { + if (Objects.nonNull(record.get(itemKey)) && NumberUtils.isCreatable(record.get(itemKey).toString())) { + sumBigDecimal = sumBigDecimal.add(new BigDecimal(record.get(itemKey).toString())); + } + } + } + Object o = sumResultMap.get(itemKey + "_n"); + if (o != null) { + sumBigDecimal = sumBigDecimal.add((BigDecimal) o); + } + sumResultMap.put(itemKey + "_n", sumBigDecimal); + // 薪资项目合计 + sumResultMap.put(itemKey, ReportDataUtil.thousandthConvert(sumBigDecimal.toString())); + } + } + } + resultMap.put("sumRow", sumResultMap); + return resultMap; + } + + public XSSFWorkbook exportSalaryList(SalaryStatisticsEmployeeSalaryQueryParam queryParam) { + queryParam.setCurrent(1); + queryParam.setExport(true); + Map resultMap = salaryList(queryParam); + List columns = (List) resultMap.get("columns"); + List> resultList = ((PageInfo>) resultMap.get("pageInfo")).getList(); + + //根据上传的模板导出 + Object fileId = resultMap.get("fileId"); + if (fileId != null) { + InputStream inputStream = ImageFileManager.getInputStreamById((Integer) fileId); + XSSFWorkbook workbook = ExcelFillUtils.fillOneSheet(inputStream, 0, resultList); + return workbook; + } + + //根据显示列表导出 + Map countResult = (Map) resultMap.get("countResult"); + Map columnMap = SalaryEntityUtil.convert2Map(columns, WeaTableColumn::getColumn); + // 获取薪资项目保留小数位数 + List salaryItemPOList = getSalaryItemService(user).listAll(); + Map salaryItemMap = SalaryEntityUtil.convert2Map(salaryItemPOList, item -> item.getId() + "_salaryItem"); + List finalColumns = new ArrayList<>(); + queryParam.getColumns().forEach(col -> { + WeaTableColumn column = columnMap.get(col); + if (column != null) { + SalaryItemPO salaryItemPO = salaryItemMap.get(column.getColumn()); + Integer pattern = salaryItemPO == null ? 0 : salaryItemPO.getPattern(); + String dataType = salaryItemPO == null ? SalaryDataTypeEnum.STRING.getValue() : salaryItemPO.getDataType(); + finalColumns.add(new WeaTableColumnGroup("100px", Util.formatMultiLang(column.getText()), column.getColumn(), "false", pattern, dataType)); + } + }); + List> rowList = new ArrayList<>(); + // 表头 + rowList.add(finalColumns); + // 数据 + for (Map valueMap : resultList) { + List list = new ArrayList<>(); + for (Object column : finalColumns) { + WeaTableColumnGroup col = (WeaTableColumnGroup) column; + if (col.getDataType().equals(SalaryDataTypeEnum.NUMBER.getValue())) { + try { + list.add(new BigDecimal(Util.null2String(valueMap.get(col.getColumn())))); + } catch (Exception e) { + list.add(Util.null2String(valueMap.get(col.getColumn()))); + } + } else { + list.add(Util.null2String(valueMap.get(col.getColumn()))); + } + } + rowList.add(list); + } + // 合计 + List sumRow = new ArrayList<>(); + sumRow.add("总计"); + for (int i = 1; i < finalColumns.size(); i++) { + WeaTableColumnGroup weaTableColumnGroup = (WeaTableColumnGroup) finalColumns.get(i); + if (weaTableColumnGroup.getDataType().equals(SalaryDataTypeEnum.NUMBER.getValue())) { + try { + sumRow.add(new BigDecimal(Util.null2String(countResult.get(weaTableColumnGroup.getColumn())))); + } catch (Exception e) { + sumRow.add(Util.null2String(countResult.get(weaTableColumnGroup.getColumn()))); + } + } else { + sumRow.add(Util.null2String(countResult.get(weaTableColumnGroup.getColumn()))); + } + } + rowList.add(sumRow); + + return ExcelUtilPlus.genWorkbookV2WithPattern(rowList, "薪资明细", true); + } + +// public Map exportDetailList(SalaryStatisticsEmployeeDetailQueryParam queryParam) { +// SalaryAssert.notNull(queryParam.getEmployeeId(), SalaryI18nUtil.getI18nLabel(currentTenantKey, currentEmployeeId, 163974, "人员id不能为空")); +// // 构建异步导出参数 +// Map map = salaryBatchService.buildeExportParam("exportSalaryStatisticsEmployeeDetailList"); +// LocalRunnable localRunnable = new LocalRunnable() { +// @Override +// public void execute() { +// try { +// DSTenantKeyThreadVar.tenantKey.set(currentTenantKey); +// getSalaryStatisticsEmployeeService(user).exportDetailList(map, queryParam); +// } finally { +// DSTenantKeyThreadVar.tenantKey.remove(); +// } +// } +// }; +// ThreadPoolUtil.execute(localRunnable); +// +// return map; +// } +} diff --git a/src/com/engine/salary/report/wrapper/SalaryStatisticsItemWrapper.java b/src/com/engine/salary/report/wrapper/SalaryStatisticsItemWrapper.java new file mode 100644 index 000000000..9d3e66d2e --- /dev/null +++ b/src/com/engine/salary/report/wrapper/SalaryStatisticsItemWrapper.java @@ -0,0 +1,300 @@ +package com.engine.salary.report.wrapper; + +import com.alibaba.fastjson.JSON; +import com.cloudstore.eccom.pc.table.WeaTableColumn; +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.entity.salaryitem.po.SalaryItemPO; +import com.engine.salary.enums.salaryitem.SalaryDataTypeEnum; +import com.engine.salary.report.entity.dto.SalaryStatisticsItemFormDTO; +import com.engine.salary.report.entity.param.SalaryStatisticsItemSaveParam; +import com.engine.salary.report.entity.po.SalaryStatisticsItemPO; +import com.engine.salary.report.enums.SalaryStatisticsItemStringRuleEnum; +import com.engine.salary.report.enums.UnitTypeEnum; +import com.engine.salary.report.service.SalaryStatisticsItemService; +import com.engine.salary.report.service.impl.SalaryStatisticsItemServiceImpl; +import com.engine.salary.service.SalaryItemService; +import com.engine.salary.service.impl.SalaryItemServiceImpl; +import com.engine.salary.util.SalaryAssert; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.SalaryI18nUtil; +import org.apache.commons.lang3.StringUtils; +import weaver.hrm.User; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * 薪酬报表统计项目 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SalaryStatisticsItemWrapper extends Service { + + private SalaryStatisticsItemService getSalaryStatisticsItemService(User user) { + return ServiceUtil.getService(SalaryStatisticsItemServiceImpl.class, user); + } + + private SalaryItemService getSalaryItemService(User user) { + return ServiceUtil.getService(SalaryItemServiceImpl.class, user); + } + + /** + * 获取自定义统计项目表单 + * + * @param id + * @return + */ + public SalaryStatisticsItemFormDTO getForm(Long id) { + Map weaForm = new HashMap<>(); + Map ruleData = new HashMap<>(); + if (Objects.nonNull(id)) { + SalaryStatisticsItemPO salaryStatisticsItem = getSalaryStatisticsItemService(user).getById(id); + SalaryAssert.notNull(salaryStatisticsItem, SalaryI18nUtil.getI18nLabel(152591, "统计项目不存在")); + String itemValue = salaryStatisticsItem.getItemValue(); + if (StringUtils.isNotBlank(itemValue)) { + List salaryItems = getSalaryItemService(user).listAll(); + Map itemsMap = SalaryEntityUtil.convert2Map(salaryItems, k -> k.getId().toString()); + List> welfareItems = new ArrayList<>(); + Arrays.stream(itemValue.split(",")).forEach(value -> { + Map welfareItem = new HashMap<>(); + welfareItem.put("id", value); + welfareItem.put("name", itemsMap.get(value).getName()); + welfareItem.put("dataType", itemsMap.get(value).getDataType()); + welfareItems.add(welfareItem); + }); + Map map = new HashMap<>(); + //版本变更,由多选变成单选 + map.put("itemValue", welfareItems.get(0)); + map.put("itemName", salaryStatisticsItem.getItemName()); + weaForm.put("data", map); + ruleData = buildRule(SalaryDataTypeEnum.parseByValue(welfareItems.get(0).get("dataType")), salaryStatisticsItem); + } + } else { + ruleData = buildRule(null, null); + } + + return SalaryStatisticsItemFormDTO.builder() + .id(id) + .baseForm(weaForm) + .ruleData(ruleData) + .build(); + } + + public SalaryStatisticsItemFormDTO changeTab(Long itemId) { + SalaryItemPO po = getSalaryItemService(user).getById(itemId); + Map ruleData = buildRule(SalaryDataTypeEnum.parseByValue(po.getDataType()), null); + return SalaryStatisticsItemFormDTO.builder().ruleData(ruleData).build(); + + } + + public Map buildRule(SalaryDataTypeEnum dataType, SalaryStatisticsItemPO salaryStatisticsItem) { + Map weaTable; + if (dataType == null || dataType == SalaryDataTypeEnum.NUMBER) { + weaTable = buildNumberRule(salaryStatisticsItem); + } else { + weaTable = buildStringRule(salaryStatisticsItem); + } + return weaTable; + } + + /** + * 字符取值规则 + * + * @param salaryStatisticsItem 统计项 + * @return + */ + private Map buildStringRule(SalaryStatisticsItemPO salaryStatisticsItem) { + Map weaTable = new HashMap<>(); + + List list = new ArrayList<>(); + WeaTableColumn ruleName = new WeaTableColumn("20%", SalaryI18nUtil.getI18nLabel(157532, "字符取值规则"), "ruleName"); + list.add(ruleName); + weaTable.put("columns", list); + + List> result = new ArrayList<>(); + if (salaryStatisticsItem == null) { + for (SalaryStatisticsItemStringRuleEnum ruleEnum : SalaryStatisticsItemStringRuleEnum.values()) { + Map rule = new HashMap<>(); + rule.put("id", ruleEnum.getValue()); + rule.put("ruleName", ruleEnum.getDefaultLabel()); + rule.put("totalValue", 0); + result.add(rule); + } + } else { + for (SalaryStatisticsItemStringRuleEnum ruleEnum : SalaryStatisticsItemStringRuleEnum.values()) { + Map rule = new HashMap<>(); + switch (ruleEnum) { + case LAST: + rule = JSON.parseObject(salaryStatisticsItem.getLastRule(), HashMap.class); + break; + case OLD: + rule = JSON.parseObject(salaryStatisticsItem.getOldRule(), HashMap.class); + break; + case FREQUENT: + rule = JSON.parseObject(salaryStatisticsItem.getFrequentRule(), HashMap.class); + break; + case TILE: + rule = JSON.parseObject(salaryStatisticsItem.getTileRule(), HashMap.class); + break; + default: + break; + } + if (rule == null) { + rule = new HashMap<>(); + } + rule.put("id", ruleEnum.getValue()); + rule.put("ruleName", ruleEnum.getDefaultLabel()); + rule.put("totalValue", Optional.ofNullable(rule.get("totalValue")).orElse(0)); + result.add(rule); + } + } + weaTable.put("data", result); + + return weaTable; + } + + /** + * 数值取值规则 + * + * @param salaryStatisticsItem 统计项 + * @return + */ + private Map buildNumberRule(SalaryStatisticsItemPO salaryStatisticsItem) { + Map weaTable = new HashMap<>(); + List list = new ArrayList<>(); + WeaTableColumn ruleName = new WeaTableColumn("20%", SalaryI18nUtil.getI18nLabel(157532, "统计规则"), "ruleName"); + WeaTableColumn ratio = new WeaTableColumn("10%", SalaryI18nUtil.getI18nLabel(162990, "占比"), "ratio"); + WeaTableColumn m2m = new WeaTableColumn("10%", SalaryI18nUtil.getI18nLabel(157533, "环比"), "m2m"); + WeaTableColumn m2mLimit = new WeaTableColumn("25%", SalaryI18nUtil.getI18nLabel(157536, "环比增幅正常区间设置"), "m2mLimit"); + WeaTableColumn y2y = new WeaTableColumn("10%", SalaryI18nUtil.getI18nLabel(162991, "同比"), "y2y"); + WeaTableColumn y2yLimit = new WeaTableColumn("25%", SalaryI18nUtil.getI18nLabel(162992, "同比增幅正常区间设置"), "y2yLimit"); + list.add(ruleName); + list.add(ratio); + list.add(m2m); + list.add(m2mLimit); + list.add(y2y); + list.add(y2yLimit); + weaTable.put("columns", list); + + List> result = new ArrayList<>(); + List ruleList = Arrays.asList("count", "sum", "avg", "max", "min", "median"); + List ruleNameList = Arrays.asList( + SalaryI18nUtil.getI18nLabel(157268, "计数"), + SalaryI18nUtil.getI18nLabel(157266, "求和"), + SalaryI18nUtil.getI18nLabel(100132, "平均值"), + SalaryI18nUtil.getI18nLabel(163001, "最大值"), + SalaryI18nUtil.getI18nLabel(163002, "最小值"), + SalaryI18nUtil.getI18nLabel(163003, "中位数")); + if (salaryStatisticsItem == null) { + for (int i = 0; i < ruleList.size(); i++) { + Map rule = new HashMap<>(); + rule.put("id", ruleList.get(i)); + rule.put("ruleName", ruleNameList.get(i)); + rule.put("totalValue", 0); + rule.put("ratioValue", 0); + rule.put("m2mValue", 0); + rule.put("m2mUpperLimit", ""); + rule.put("m2mLowerLimit", ""); + rule.put("y2yValue", 0); + rule.put("y2yUpperLimit", ""); + rule.put("y2yLowerLimit", ""); + result.add(rule); + } + } else { + for (int i = 0; i < ruleList.size(); i++) { + Map rule = new HashMap<>(); + switch (ruleList.get(i)) { + case "count": + rule = JSON.parseObject(salaryStatisticsItem.getCountRule(), HashMap.class); + break; + case "sum": + rule = JSON.parseObject(salaryStatisticsItem.getSumRule(), HashMap.class); + break; + case "avg": + rule = JSON.parseObject(salaryStatisticsItem.getAvgRule(), HashMap.class); + break; + case "max": + rule = JSON.parseObject(salaryStatisticsItem.getMaxRule(), HashMap.class); + break; + case "min": + rule = JSON.parseObject(salaryStatisticsItem.getMinRule(), HashMap.class); + break; + case "median": + rule = JSON.parseObject(salaryStatisticsItem.getMedianRule(), HashMap.class); + break; + default: + break; + } + if (rule == null) { + rule = new HashMap<>(); + } + rule.put("id", ruleList.get(i)); + rule.put("ruleName", ruleNameList.get(i)); + rule.put("totalValue", Optional.ofNullable(rule.get("totalValue")).orElse(0)); + rule.put("ratioValue", Optional.ofNullable(rule.get("ratioValue")).orElse(0)); + rule.put("m2mValue", Optional.ofNullable(rule.get("m2mValue")).orElse(0)); + rule.put("m2mUpperLimit", Optional.ofNullable(rule.get("m2mUpperLimit")).orElse("")); + rule.put("m2mLowerLimit", Optional.ofNullable(rule.get("m2mLowerLimit")).orElse("")); + rule.put("y2yValue", Optional.ofNullable(rule.get("y2yValue")).orElse(0)); + rule.put("y2yUpperLimit", Optional.ofNullable(rule.get("y2yUpperLimit")).orElse("")); + rule.put("y2yLowerLimit", Optional.ofNullable(rule.get("y2yLowerLimit")).orElse("")); + result.add(rule); + } + } + weaTable.put("data", result); + return weaTable; + } + + /** + * 获取自定义统计项目列表 + * + * @param statisticsReportId + * @return + */ + public List> list(Long statisticsReportId) { + List salaryStatisticsItemList = getSalaryStatisticsItemService(user).listByStatisticsReportId(statisticsReportId); + salaryStatisticsItemList = salaryStatisticsItemList.stream().sorted(Comparator.comparing(SalaryStatisticsItemPO::getIndexValue)).collect(Collectors.toList()); + List> result = new ArrayList<>(); + salaryStatisticsItemList.forEach(po -> { + Map rule = new HashMap<>(); + rule.put("id", po.getId().toString()); + rule.put("itemName", po.getItemName()); + rule.put("unitType", po.getUnitType() == null ? UnitTypeEnum.YUAN.getValue() : po.getUnitType()); + rule.put("itemValue", po.getItemValue()); + rule.put("countRule", po.getCountRule()); + rule.put("sumRule", po.getSumRule()); + rule.put("avgRule", po.getAvgRule()); + rule.put("maxRule", po.getMaxRule()); + rule.put("minRule", po.getMinRule()); + rule.put("medianRule", po.getMedianRule()); + rule.put("indexValue", po.getIndexValue()); + result.add(rule); + }); + return result; + } + + /** + * 删除自定义统计项目 + * + * @param ids + * @return + */ + public String delete(Collection ids) { + return getSalaryStatisticsItemService(user).delete(ids); + } + + /** + * 保存自定义统计项目 + * + * @param saveParam + * @return + */ + public String save(SalaryStatisticsItemSaveParam saveParam) { + return getSalaryStatisticsItemService(user).save(saveParam); + } + +} diff --git a/src/com/engine/salary/report/wrapper/SalaryStatisticsReportWrapper.java b/src/com/engine/salary/report/wrapper/SalaryStatisticsReportWrapper.java new file mode 100644 index 000000000..7d0d48d53 --- /dev/null +++ b/src/com/engine/salary/report/wrapper/SalaryStatisticsReportWrapper.java @@ -0,0 +1,675 @@ +package com.engine.salary.report.wrapper; + +import cn.hutool.crypto.SecureUtil; +import com.alibaba.fastjson.JSONArray; +import com.cloudstore.eccom.pc.table.WeaTable; +import com.cloudstore.eccom.pc.table.WeaTableColumn; +import com.cloudstore.eccom.result.WeaResultMsg; +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.hrmelog.entity.dto.LoggerContext; +import com.engine.salary.cache.SalaryCacheKey; +import com.engine.salary.component.WeaFormOption; +import com.engine.salary.component.WeaTableColumnGroup; +import com.engine.salary.config.SalaryElogConfig; +import com.engine.salary.entity.salaryitem.po.SalaryItemPO; +import com.engine.salary.enums.OperateTypeEnum; +import com.engine.salary.enums.salaryitem.SalaryDataTypeEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.report.common.constant.SalaryConstant; +import com.engine.salary.report.entity.bo.SalaryStatisticsReportBO; +import com.engine.salary.report.entity.param.*; +import com.engine.salary.report.entity.po.SalaryStatisticsDimensionPO; +import com.engine.salary.report.entity.po.SalaryStatisticsItemPO; +import com.engine.salary.report.entity.po.SalaryStatisticsPushPO; +import com.engine.salary.report.entity.po.SalaryStatisticsReportPO; +import com.engine.salary.report.service.*; +import com.engine.salary.report.service.impl.*; +import com.engine.salary.service.*; +import com.engine.salary.service.impl.*; +import com.engine.salary.util.*; +import com.engine.salary.util.excel.ExcelUtilPlus; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.util.page.SalaryPageUtil; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.math.NumberUtils; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import weaver.general.PageIdConst; +import weaver.hrm.User; +import weaver.wechat.util.Utils; + +import java.math.BigDecimal; +import java.util.*; +import java.util.stream.Collectors; + + +/** + * 薪酬统计维度 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SalaryStatisticsReportWrapper extends Service { + + private static final String conditionId = "salaryStatisticsReportSearchCondition"; + + private SalaryStatisticsReportService getSalaryStatisticsReportService(User user) { + return ServiceUtil.getService(SalaryStatisticsReportServiceImpl.class, user); + } + + private SalaryStatisticsItemService getSalaryStatisticsItemService(User user) { + return ServiceUtil.getService(SalaryStatisticsItemServiceImpl.class, user); + } + + private SalaryStatisticsDimensionService getSalaryStatisticsDimensionService(User user) { + return ServiceUtil.getService(SalaryStatisticsDimensionServiceImpl.class, user); + } + + private SubTableExportService getSubTableExportService(User user) { + return ServiceUtil.getService(SubTableExportServiceImpl.class, user); + } + + private SalaryAcctEmployeeService getSalaryAcctEmployeeService(User user) { + return ServiceUtil.getService(SalaryAcctEmployeeServiceImpl.class, user); + } + + private SalaryAcctResultService getSalaryAcctResultService(User user) { + return ServiceUtil.getService(SalaryAcctResultServiceImpl.class, user); + } + + private SalaryItemService getSalaryItemService(User user) { + return ServiceUtil.getService(SalaryItemServiceImpl.class, user); + } + + private SalaryCacheService getSalaryCacheService(User user) { + return ServiceUtil.getService(SalaryCacheServiceImpl.class, user); + } + + private SalaryStatisticsPushService getSalaryStatisticsPushService(User user) { + return ServiceUtil.getService(SalaryStatisticsPushServiceImpl.class, user); + } + + private SalaryStatisticsPushDetailService getSalaryStatisticsPushDetailService(User user) { + return ServiceUtil.getService(SalaryStatisticsPushDetailServiceImpl.class, user); + } + + private TaxAgentService getTaxAgentService(User user) { + return ServiceUtil.getService(TaxAgentServiceImpl.class, user); + } + + + /** + * 报表列表 + * + * @param queryParam + * @return + */ + public List> list(SalaryStatisticsReportQueryParam queryParam) { + Long uid = Long.valueOf(user.getUID()); + // 初始化 + getSalaryStatisticsDimensionService(user).init(uid); + + // 所有人能够看到自己创建的报表,薪酬总管理员能够查看所有报表 + List reportList = getSalaryStatisticsReportService(user).listByCreator(uid); + List reportIds = reportList.stream().map(SalaryStatisticsReportPO::getId).collect(Collectors.toList()); + // 获取所有没有撤回没有过期的报表ID(不包含过期失效的) + List pushList = getSalaryStatisticsPushService(user).getSuccessPushListByReceiver(uid); + List sharedReportIds = pushList.stream().map(po -> Arrays.asList(StringUtils.split(po.getReportIds(), ","))) + .flatMap(Collection::stream).distinct().map(Long::valueOf).collect(Collectors.toList()); + sharedReportIds = sharedReportIds.stream().filter(id -> !reportIds.contains(id)).collect(Collectors.toList()); + reportList.addAll(getSalaryStatisticsReportService(user).getByIds(sharedReportIds)); + + if (StringUtils.isNotEmpty(queryParam.getReportName())) { + reportList = reportList.stream().filter(rp -> rp.getReportName().contains(queryParam.getReportName())).collect(Collectors.toList()); + } + List salaryStatisticsDimensionList = this.getSalaryStatisticsDimensionService(user).listAll(); + Map salaryStatisticsDimensionMap = SalaryEntityUtil.convert2Map(salaryStatisticsDimensionList, k -> k.getId().toString(), SalaryStatisticsDimensionPO::getDimName); + List> result = new ArrayList<>(); + List finalSharedReportIds = sharedReportIds; + reportList.forEach(po -> { + Map temp = new HashMap<>(); + temp.put("id", po.getId().toString()); + temp.put("reportName", po.getReportName()); + temp.put("timeType", po.getTimeType() == null ? 10 : po.getTimeType()); + temp.put("salaryStartMonth", SalaryDateUtil.getFormatYearMonth(po.getSalaryStartMonth())); + temp.put("salaryEndMonth", SalaryDateUtil.getFormatYearMonth(po.getSalaryEndMonth())); + List dimNames = Arrays.stream(po.getDimension().split(",")).map(dim -> Optional.ofNullable(salaryStatisticsDimensionMap.get(dim)).orElse("")).collect(Collectors.toList()); + temp.put("dimension", StringUtils.join(dimNames, ",")); + temp.put("dimensionId", po.getDimension()); + temp.put("isShare", finalSharedReportIds.contains(po.getId())); + result.add(temp); + }); + return result; + } + + /** + * 获取薪酬统计报表表单 + * + * @param id + * @param + * @return + */ + public Map getFrom(Long id) { + + List salaryStatisticsDimensions = getSalaryStatisticsDimensionService(user).listAll(); + + List statsDimOptions = salaryStatisticsDimensions.stream().map(sd -> new WeaFormOption(sd.getId().toString(), sd.getDimName())).collect(Collectors.toList()); + + // 获取默认维度统计 + List defaultSalaryStatisticsDimensions = getSalaryStatisticsDimensionService(user).listAllDefaultDimension(); + List defaultDimensionIds = defaultSalaryStatisticsDimensions.stream().map(SalaryStatisticsDimensionPO::getId).collect(Collectors.toList()); + // 获取有薪资统计报表引用的统计维度 + Set haveUsedDimIds = new HashSet<>(); + List salaryStatisticsReports = getSalaryStatisticsReportService(user).listAll(); + salaryStatisticsReports.stream().forEach(report -> Collections.addAll(haveUsedDimIds, report.getDimension().split(","))); + statsDimOptions.stream().forEach(option -> { + if (defaultDimensionIds.contains(Long.valueOf(option.getId()))) { + // 默认维度不允许修改、删除 + option.setCanDelete(false); + option.setCanEdit(false); + } else if (haveUsedDimIds.contains(option.getId())) { + // 被薪资统计报表引用的不能删除 + option.setCanEdit(true); + option.setCanDelete(false); + } + }); + + // 1.构建基础信息表单 + Map weaForm = new HashMap<>(); + weaForm.put("statsDimOptions", statsDimOptions); + + + if (id != null) { + SalaryStatisticsReportPO po = this.getSalaryStatisticsReportService(user).getById(id); + if (po == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(161845, "薪酬统计报表不存在")); + } + Map dataMap = JsonUtil.parseMap(po, Object.class); + dataMap.put("dimension", Arrays.asList(po.getDimension().split(","))); + weaForm.put("data", dataMap); + } + + return weaForm; + } + + /** + * 保存薪酬统计报表 + * + * @param saveParam + * @param + * @return + */ + public String save(SalaryStatisticsReportSaveParam saveParam) { + return getSalaryStatisticsReportService(user).save(saveParam); + } + + /** + * 删除薪酬统计报表 + * + * @param ids + * @param + * @return + */ + public Map delete(Collection ids) { + return getSalaryStatisticsReportService(user).delete(ids); + } + + /** + * 复制薪资账套 + * + * @param id + */ + public void duplicate(Long id) { + if (id == null) { + throw new SalaryRunTimeException("id为空"); + } + getSalaryStatisticsReportService(user).duplicate(id); + } + + /** + * 获取统计条件 + * + * @param id + * @return + */ + public Map getSearchCondition(Long id) { + // 高级搜索实例 + Map map = new HashMap<>(); + + if (id != null) { + SalaryStatisticsReportPO po = getSalaryStatisticsReportService(user).getById(id); + SalaryAssert.notNull(po, SalaryI18nUtil.getI18nLabel(152563, "报表不存在")); + + Map data = new HashMap<>(); + data.put("timeType", po.getTimeType() == null ? 10 : po.getTimeType()); + data.put("salaryStartMonth", SalaryDateUtil.getFormatYearMonth(po.getSalaryStartMonth())); + data.put("salaryEndMonth", SalaryDateUtil.getFormatYearMonth(po.getSalaryEndMonth())); + data.put("taxAgent", JSONArray.parseArray(po.getTaxAgentSetting())); + data.put("salarySob", JSONArray.parseArray(po.getSalarySobSetting())); + data.put("incomeCategory", JSONArray.parseArray(po.getIncomeCategorySetting())); + data.put("subCompany", JSONArray.parseArray(po.getSubCompanySetting())); + data.put("department", JSONArray.parseArray(po.getDepartSetting())); + data.put("grade", JSONArray.parseArray(po.getGradeSetting())); + data.put("position", JSONArray.parseArray(po.getPositionSetting())); + data.put("status", JSONArray.parseArray(po.getStatusSetting())); + data.put("employee", JSONArray.parseArray(po.getEmployeeSetting())); + data.put("hiredate", JSONArray.parseArray(po.getHiredateSetting())); +// data.put("leavedate", JSONArray.parseArray(po.getLeavedateSetting())); + + map.put("data", data); + } + + return map; + } + + + public String saveSearchCondition(SalaryStatisticsSearchConditionSaveParam param) { + return this.getSalaryStatisticsReportService(user).saveSearchCondition(param); + } + + /** + * 获取报表数据 + * + * @param param + * @return + */ + public Map getData(SalaryStatisticsReportDataQueryParam param) { + Long id = param.getId(); + if (id == null || param.getDimensionId() == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(84026, "参数错误")); + } + SalaryStatisticsDimensionPO dimension = getSalaryStatisticsDimensionService(user).getById(param.getDimensionId()); + if (dimension == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(161300, "统计维度不存在")); + } + // 查询报表配置 + SalaryStatisticsReportPO po = this.getSalaryStatisticsReportService(user).getById(id); + if (po == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(161845, "薪酬统计报表不存在")); + } + if (param.isShare()) { + // 是被分享的报表 + Long uid = Long.valueOf(user.getUID()); + // 校验查看权限,获取有效的分享记录 + List pushList = getSalaryStatisticsPushService(user).shareReportValid(param.getId(), uid); + List batchIds = pushList.stream().map(SalaryStatisticsPushPO::getId).collect(Collectors.toList()); + getSalaryStatisticsPushService(user).updateReportViewStatus(batchIds, uid); +// salaryStatisticsPushService.sendViewedMsg(param.getBatchId(), param.getId(), employeeId, tenantKey); + // 如果是被分享的报表,校验分享权限,通过后将user赋值为报表创建人 + User creator = new User(); + creator.setUid(po.getCreator().intValue()); + user = creator; + } else { + // 判断报表是否是登陆人创建的,或薪酬总管理员 + Boolean needAuth = getTaxAgentService(user).isNeedAuth((long) user.getUID()); + if (needAuth && NumberUtils.compare(po.getCreator().intValue(), user.getUID()) != 0) { + throw new SalaryRunTimeException("无权限查看该报表!"); + } + } + + // weaTable对象 + Map weaTable = new HashMap<>(); + + // 查询自定义统计项目 + List salaryStatisticsItemList = this.getSalaryStatisticsItemService(user).listByStatisticsReportId(po.getId()); + + // 参数转换 + SalaryStatisticsReportBO.poToQueryParam(param, po); + String paramMd5 = SecureUtil.md5(param + salaryStatisticsItemList.toString()); + + //已缓存的报表id + String salaryReportIds = Utils.null2String(getSalaryCacheService(user).get(SalaryCacheKey.SALARY_REPORT_IDS)); + String salaryReportConditions = ""; + // 获取人员维度id + Optional empDimensionOptional = getSalaryStatisticsDimensionService(user).listAllDefaultDimension().stream().filter(dim -> dim.getDimName().equals("人员")).map(SalaryStatisticsDimensionPO::getId).findFirst(); + Long empDimensionId = 0L; + if (empDimensionOptional.isPresent()) { + empDimensionId = empDimensionOptional.get(); + } +// if (StringUtils.isNotBlank(salaryReportIds) && salaryReportIds.contains(id + "")) { +// //报表中缓存的条件 +// salaryReportConditions = Utils.null2String(getSalaryCacheService(user).get(SalaryCacheKey.SALARY_REPORT_CONDITIONS + id)); +// if (StringUtils.isNotBlank(salaryReportConditions) && salaryReportConditions.contains(paramMd5)) { +// Map result = getSalaryCacheService(user).get(SalaryCacheKey.SALARY_REPORT_DATA + id + "_" + paramMd5); +// if (param.getDimensionId().equals(empDimensionId)) { +// // 人员维度需要分页 +// Map finalResultMap = new HashMap<>(); +// PageInfo> pageInfo = (PageInfo>) result.get("pageInfo"); +// PageInfo> finalPageInfo = SalaryPageUtil.buildPage(param.getCurrent(), param.getPageSize()); +// finalPageInfo.setTotal(pageInfo.getList().size()); +// finalPageInfo.setList(SalaryPageUtil.subList(param.getCurrent(), param.getPageSize(), pageInfo.getList())); +// finalResultMap.put("pageInfo", finalPageInfo); +// finalResultMap.put("columns", result.get("columns")); +// finalResultMap.put("countResult", result.get("countResult")); +// finalResultMap.put("reportId", id); +// return finalResultMap; +// } +// +// return result; +// } +// } + + + // 列表data + PageInfo> page = this.getSalaryStatisticsReportService(user).buildReportRecords(dimension, param, salaryStatisticsItemList); + + // 组装合计 + Map countResultMap = SalaryStatisticsReportBO.buildTotal(page, salaryStatisticsItemList, (long) user.getUID()); + + // 列表columns + List weaTableColumns = SalaryStatisticsReportBO.buildReportColumns(dimension, salaryStatisticsItemList); + + Map resultMap = Maps.newHashMap(); + resultMap.putAll(JsonUtil.parseMap(weaTable, Object.class)); + resultMap.put("columns", weaTableColumns); + resultMap.put("pageInfo", page); + resultMap.put("countResult", countResultMap); + resultMap.put("reportId", id); + + + //设置报表缓存 + getSalaryCacheService(user).set(SalaryCacheKey.SALARY_REPORT_IDS, salaryReportIds + "," + id); + getSalaryCacheService(user).set(SalaryCacheKey.SALARY_REPORT_CONDITIONS + id, salaryReportConditions + "," + paramMd5); + getSalaryCacheService(user).set(SalaryCacheKey.SALARY_REPORT_DATA + id + "_" + paramMd5, resultMap); + + Map finalResultMap = Maps.newHashMap(); + // 缓存完之后结果分页 + if (param.getDimensionId().equals(empDimensionId)) { + // 只有是人员维度才分页 + PageInfo> pageInfo = SalaryPageUtil.buildPage(param.getCurrent(), param.getPageSize()); + pageInfo.setTotal(page.getList().size()); + pageInfo.setList(SalaryPageUtil.subList(param.getCurrent(), param.getPageSize(), page.getList())); + finalResultMap.put("pageInfo", pageInfo); + finalResultMap.put("columns", weaTableColumns); + finalResultMap.put("countResult", countResultMap); + finalResultMap.put("reportId", id); + + return finalResultMap; + } + + return resultMap; + } + + + /** + * 导出报表数据 + * + * @param param + * @return + */ + public Map exportData(SalaryStatisticsReportDataQueryParam param) { + Long id = param.getId(); + if (id == null || param.getDimensionId() == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(84026, "参数错误")); + } + + SalaryStatisticsReportPO po = this.getSalaryStatisticsReportService(user).getById(id); + if (po == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(161845, "薪酬统计报表不存在")); + } + SalaryStatisticsDimensionPO dimension = getSalaryStatisticsDimensionService(user).getById(param.getDimensionId()); + if (dimension == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(161300, "统计维度不存在")); + } + sharedReportCheck(param.isShare(), po); + + // 查询自定义统计项目 + List salaryStatisticsItemList = this.getSalaryStatisticsItemService(user).listByStatisticsReportId(po.getId()); + // 参数转换 + SalaryStatisticsReportBO.poToQueryParam(param, po); + String paramMd5 = SecureUtil.md5(param + salaryStatisticsItemList.toString()); + + //已缓存的报表id + String salaryReportIds = Utils.null2String(getSalaryCacheService(user).get(SalaryCacheKey.SALARY_REPORT_IDS)); + String salaryReportConditions = ""; + + if (StringUtils.isNotBlank(salaryReportIds) && salaryReportIds.contains(id + "")) { + //报表中缓存的条件 + salaryReportConditions = Utils.null2String(getSalaryCacheService(user).get(SalaryCacheKey.SALARY_REPORT_CONDITIONS + id)); + if (StringUtils.isNotBlank(salaryReportConditions) && salaryReportConditions.contains(paramMd5)) { + Map result = getSalaryCacheService(user).get(SalaryCacheKey.SALARY_REPORT_DATA + id + "_" + paramMd5); + // 获取列头 + List weaTableColumns = (List) result.get("columns"); + PageInfo> page = (PageInfo>) result.get("pageInfo"); + Map countResultMap = (Map) result.get("countResult"); + List> list = page.getList(); + // 获取数据 + List> records = list.stream().map(m -> m.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue() == null ? "" : e.getValue()))).collect(Collectors.toList()); + records.add(countResultMap); + + List rows = new ArrayList<>(); + rows.add(weaTableColumns); + + List head = new ArrayList<>(); + weaTableColumns.forEach(weaTableColumn -> { + String column = weaTableColumn.getColumn(); + if (CollectionUtils.isEmpty(weaTableColumn.getChildren())) { + head.add(column); + } else { + weaTableColumn.getChildren().forEach(children -> { + head.add(children.getColumn()); + }); + } + }); + + List itemIds = salaryStatisticsItemList.stream().map(item -> item.getItemValue().split(",")).flatMap(Arrays::stream).filter(NumberUtils::isCreatable).map(Long::valueOf).collect(Collectors.toList()); + List salaryItemPOList = getSalaryItemService(user).listByIds(itemIds); + List numberItemIds = salaryItemPOList.stream().filter(item -> item.getDataType().equals(SalaryDataTypeEnum.NUMBER.getValue())).map(salaryItemPO -> salaryItemPO.getId().toString()).collect(Collectors.toList()); + Map salaryStatisticsItemMap = SalaryEntityUtil.convert2Map(salaryStatisticsItemList, statisticsItemPO -> statisticsItemPO.getId().toString()); + + for (Map map : records) { + List row = Lists.newArrayListWithExpectedSize(records.size()); + head.forEach(k -> { + // 获取是数值还是文本 + if (k.contains(SalaryStatisticsReportBO.UD)) { + String[] split = k.split(SalaryStatisticsReportBO.UD); + String salaryItemId = split[0]; + SalaryStatisticsItemPO salaryStatisticsItemPO = salaryStatisticsItemMap.get(salaryItemId); + if (salaryStatisticsItemPO != null) { + Optional textItemOptional = Arrays.stream(salaryStatisticsItemPO.getItemValue().split(",")).filter(itemId -> !numberItemIds.contains(itemId)).findFirst(); + row.add((!textItemOptional.isPresent() && NumberUtils.isCreatable(Utils.null2String(map.get(k)).replaceAll(",", ""))) ? new BigDecimal(Utils.null2String(map.get(k)).replaceAll(",", "")) : map.getOrDefault(k, StringUtils.EMPTY)); + } else { + row.add(map.getOrDefault(k, StringUtils.EMPTY)); + } + } else { + row.add(map.getOrDefault(k, StringUtils.EMPTY)); + } + }); + rows.add(row); + } + + String sheetName = SalaryI18nUtil.getI18nLabel(179263, "薪酬统计报表") + "-" + dimension.getDimName(); + XSSFWorkbook book = ExcelUtilPlus.genWorkbookWithChildTitleColumn(rows, sheetName, true); + + Map map = new HashMap<>(); + map.put("workbook", book); + map.put("fileName", sheetName); + + // 记录操作日志 + String name = SalaryI18nUtil.getI18nLabel(0, "导出"); + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setTargetId(po.getId().toString()); + loggerContext.setTargetName(po.getReportName()); + loggerContext.setOperateType(OperateTypeEnum.EXCEL_EXPORT.getValue()); + loggerContext.setOperateTypeName(name); + loggerContext.setOperatedesc(name + SalaryI18nUtil.getI18nLabel(0, "薪酬统计报表") + "-" + po.getReportName()); + loggerContext.setUser(user); + SalaryElogConfig.salaryStatReportLoggerTemplate.write(loggerContext); + + return map; + } + } + + throw new SalaryRunTimeException("未查询报表数据!"); + } + + /** + * 获取报表透视数据 + * + * @param param + * @return + */ + public Map getDataPerspective(SalaryStatisticsDataPerspectiveQueryParam param) { + if (param.getId() == null || param.getDimensionId() == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(84026, "参数错误")); + } + SalaryStatisticsReportPO po = this.getSalaryStatisticsReportService(user).getById(param.getId()); + if (po == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(161845, "薪酬统计报表不存在")); + } + SalaryStatisticsDimensionPO dimension = getSalaryStatisticsDimensionService(user).getById(param.getDimensionId()); + if (dimension == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(161300, "统计维度不存在")); + } + // 校验报表权限,如果是被分享报表修改User + sharedReportCheck(param.isShare(), po); + // 查询自定义统计项目中所有薪资项目id + List salaryStatisticsItemPOS = getSalaryStatisticsItemService(user).listByStatisticsReportId(param.getId()); + List salaryItemIds = salaryStatisticsItemPOS.stream().filter(item -> StringUtils.isNotBlank(item.getItemValue())).map(p -> p.getItemValue().split(",")) + .flatMap(Arrays::stream).map(Long::valueOf).collect(Collectors.toList()); + + PageInfo> pageInfo = getSalaryStatisticsReportService(user).buildDataPerspectiveRecords(param, po, dimension, salaryStatisticsItemPOS); + + List itemList = getSalaryItemService(user).listByIds(salaryItemIds); + // 列表columns + List weaTableColumns = buildDataPerspectiveTableColumns(itemList, salaryItemIds); + + WeaTable table = new WeaTable(); + String pageId = "a4f85an7-9576-4125-adn9-7d06e7sy69f2"; + table.setPageID(pageId); + table.setPageUID(pageId + user.getUID()); + table.setPagesize(PageIdConst.getPageSize(pageId, user.getUID())); + table.setBackfields(""); + + table.setColumns(weaTableColumns); + + WeaResultMsg result = new WeaResultMsg(false); + result.putAll(table.makeDataResult()); + result.success(); + + // 结果 + Map resultMap = Maps.newHashMap(); + resultMap.put("dataKey", result.getResultMap()); + resultMap.put("pageInfo", pageInfo); + return resultMap; + } + + /** + * 获取报表透视数据 + * + * @param param + * @return + */ + public Map exportDataPerspective(SalaryStatisticsDataPerspectiveQueryParam param) { + if (param.getId() == null || param.getDimensionId() == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(84026, "参数错误")); + } + SalaryStatisticsReportPO po = this.getSalaryStatisticsReportService(user).getById(param.getId()); + if (po == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(161845, "薪酬统计报表不存在")); + } + SalaryStatisticsDimensionPO dimension = getSalaryStatisticsDimensionService(user).getById(param.getDimensionId()); + if (dimension == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(161300, "统计维度不存在")); + } + // 校验报表权限,如果是被分享报表修改User + sharedReportCheck(param.isShare(), po); + // 查询自定义统计项目中所有薪资项目id + List salaryStatisticsItemPOS = getSalaryStatisticsItemService(user).listByStatisticsReportId(param.getId()); + List salaryItemIds = salaryStatisticsItemPOS.stream().filter(item -> StringUtils.isNotBlank(item.getItemValue())).map(p -> p.getItemValue().split(",")) + .flatMap(Arrays::stream).map(Long::valueOf).collect(Collectors.toList()); + + param.setCurrent(1); + param.setPageSize(1000000000); + PageInfo> pageInfo = getSalaryStatisticsReportService(user).buildDataPerspectiveRecords(param, po, dimension, salaryStatisticsItemPOS); + + + List> resultList = new ArrayList<>(); + + List itemList = getSalaryItemService(user).listByIds(salaryItemIds); + // 表格表头 + List weaTableColumns = buildDataPerspectiveTableColumns(itemList, salaryItemIds); + List columns = new ArrayList<>(); + for (WeaTableColumn column : weaTableColumns) { + columns.add(column.getText()); + } + resultList.add(columns); + + List> list = pageInfo.getList(); + for (Map resultMap : list) { + List row = new ArrayList<>(); + for (WeaTableColumn column : weaTableColumns) { + try { + if (StringUtils.isNotBlank(column.getOtherpara()) && column.getOtherpara().equals(SalaryDataTypeEnum.NUMBER.getValue())) { + // 数值 + row.add(new BigDecimal(resultMap.get(column.getColumn()).toString())); + } else { + row.add(Utils.null2String(resultMap.get(column.getColumn()))); + } + } catch (Exception e) { + row.add(Utils.null2String(resultMap.get(column.getColumn()))); + } + } + resultList.add(row); + } + + String sheetName = SalaryI18nUtil.getI18nLabel(179263, "薪酬统计报表明细") + "-" + dimension.getDimName(); + XSSFWorkbook book = ExcelUtilPlus.genWorkbookV2(resultList, sheetName); + + Map map = new HashMap<>(); + map.put("workbook", book); + map.put("fileName", sheetName); + return map; + } + + /** + * 权限校验 + * + * @param isShared 是否是被分享的报表 + * @param po 报表po + */ + private void sharedReportCheck(boolean isShared, SalaryStatisticsReportPO po) { + if (isShared) { + // 是被分享的报表 + Long uid = Long.valueOf(user.getUID()); + // 校验分享查看权限 + getSalaryStatisticsPushService(user).shareReportValid(po.getId(), uid); + // 如果是被分享的报表,校验分享权限,通过后将user赋值为报表创建人 + User creator = new User(); + creator.setUid(po.getCreator().intValue()); + user = creator; + } else { + // 判断报表是否是登陆人创建的,或薪酬总管理员 + Boolean needAuth = getTaxAgentService(user).isNeedAuth((long) user.getUID()); + if (needAuth && NumberUtils.compare(po.getCreator().intValue(), user.getUID()) != 0) { + throw new SalaryRunTimeException("无权限查看该报表!"); + } + } + } + + private List buildDataPerspectiveTableColumns(List salaryItems, List salaryItemIds) { + Map salaryItemMap = SalaryEntityUtil.convert2Map(salaryItems, SalaryItemPO::getId); + // 表格表头 + List columns = new ArrayList<>(); + columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(87614, "姓名"), "userName")); + columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(87614, "部门"), "departmentName")); + columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(87614, "薪资所属月"), "salaryMonth")); + columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(86184, "个税扣缴义务人"), "taxAgent")); + columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(86184, "账套"), "salarySob")); +// columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(86184, "次数"), "acctTimes").setDisplay(WeaBoolAttr.FALSE)); + salaryItemIds.forEach(itemId -> { + SalaryItemPO item = salaryItemMap.get(itemId); + if (item != null) { + WeaTableColumn weaTableColumn = new WeaTableColumn("100px", item.getName(), item.getId() + SalaryConstant.DYNAMIC_SUFFIX); + weaTableColumn.setOtherpara(item.getDataType()); + columns.add(weaTableColumn); + } + }); + return columns; + } +} diff --git a/src/com/engine/salary/service/AddUpDeductionService.java b/src/com/engine/salary/service/AddUpDeductionService.java new file mode 100644 index 000000000..514564b4b --- /dev/null +++ b/src/com/engine/salary/service/AddUpDeductionService.java @@ -0,0 +1,151 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.datacollection.AddUpDeduction; +import com.engine.salary.entity.datacollection.dto.AddUpDeductionDTO; +import com.engine.salary.entity.datacollection.dto.AddUpDeductionRecordDTO; +import com.engine.salary.entity.datacollection.param.AddUpDeductionImportParam; +import com.engine.salary.entity.datacollection.param.AddUpDeductionQueryParam; +import com.engine.salary.entity.datacollection.param.AddUpDeductionRecordDeleteParam; +import com.engine.salary.entity.datacollection.param.AddUpDeductionRecordParam; +import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO; +import com.engine.salary.util.page.PageInfo; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import java.time.YearMonth; +import java.util.Date; +import java.util.List; +import java.util.Map; + +public interface AddUpDeductionService { + + + /** + * 查询条件 + * @param params + * @return + */ + Map getSearchCondition(Map params); + + /** + * 导入 + * @param importParam + * @return + */ + Map importAddUpDeduction(AddUpDeductionImportParam importParam); + + + /** + * 预览 + * @param importParam + * @return + */ + Map preview(AddUpDeductionImportParam importParam ); + + + /** + * 下载模板 + * @param queryParam + * @return + */ + XSSFWorkbook downloadTemplate(AddUpDeductionQueryParam queryParam); + + + /** + * 通过id获取单条累计专项附加扣除记录 + * + * @param id + * @return + */ + AddUpDeduction getById(Long id); + + /** + * 数据采集-累计专项附加扣除列表(分页) + * + * @param queryParam + * @return + */ + PageInfo listPage(AddUpDeductionQueryParam queryParam); + + /** + * 获取数据采集-累计专项附加扣除详情列表(分页) + * + * @param queryParam + * @return + */ + PageInfo recordListPage(AddUpDeductionQueryParam queryParam); + + /** + * 导出 + * + * @param queryParam + */ + XSSFWorkbook export( AddUpDeductionQueryParam queryParam); + + /** + * 导出详情 + * + * @param beLongEmployeeId + * @param queryParam + */ + XSSFWorkbook exportDetail(Long beLongEmployeeId, AddUpDeductionQueryParam queryParam); + + /** + * 获取累计专项附加扣除数据 + * + * @param declareMonth + * @param employeeIds + * @return + */ + List getAddUpDeductionList(YearMonth declareMonth, List employeeIds, List taxAgentIds); + + List getAccountedEmployeeDataByTaxYearMonth(String yearMonth); + + /** + * @description 编辑累计专项附加扣除 + * @return void + * @author Harryxzy + * @date 2022/10/25 14:09 + */ + void editAddUpDeduction(AddUpDeductionRecordParam addUpDeduction); + + /** + * @description 累计专项附加扣除 + * @return void + * @author Harryxzy + * @date 2022/10/26 14:24 + */ + void createAddUpDeduction(AddUpDeductionRecordParam addUpDeductionRecordParam); + + /** + * @description 删除所选 + * @return void + * @author Harryxzy + * @date 2022/10/26 16:34 + */ + void deleteSelectAddUpDeduction(AddUpDeductionRecordDeleteParam deleteParam); + + /** + * @description 一键清空 + * @return void + * @author Harryxzy + * @date 2022/10/26 16:35 + */ + void deleteAllAddUpDeduction(AddUpDeductionRecordDeleteParam deleteParam); + + /** + * @description 获取累计专项附加扣除详情 + * @return void + * @author Harryxzy + * @date 2022/10/31 11:33 + */ + AddUpDeductionRecordDTO getAddUpDeduction(AddUpDeductionQueryParam id); + + /** + * 自动累计专项附加扣除 + * @return void + * @author lfc + */ + String autoAddAll(Date yearMonth, boolean isAdmin, List taxAgentIds); + + List listAuth(AddUpDeductionQueryParam param); +} diff --git a/src/com/engine/salary/service/AddUpSituationService.java b/src/com/engine/salary/service/AddUpSituationService.java new file mode 100644 index 000000000..2406e16be --- /dev/null +++ b/src/com/engine/salary/service/AddUpSituationService.java @@ -0,0 +1,115 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.datacollection.AddUpSituation; +import com.engine.salary.entity.datacollection.dto.AddUpSituationDTO; +import com.engine.salary.entity.datacollection.dto.AddUpSituationRecordDTO; +import com.engine.salary.entity.datacollection.param.*; +import com.engine.salary.util.page.PageInfo; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import java.time.YearMonth; +import java.util.Collection; +import java.util.Date; +import java.util.List; +import java.util.Map; + +public interface AddUpSituationService { + + Map getSearchCondition(); + + /** + * 通过id获取单个累计情况 + * + * @param id + * @return + */ + AddUpSituation getById(Long id); + + + /** + * 数据采集-累计情况列表 + * + * @param queryParam + * @return + */ + PageInfo listPage(AddUpSituationQueryParam queryParam); + + /** + * 获取数据采集-累计情况详情列表 + * + * @param queryParam + * @return + */ + PageInfo recordListPage(AddUpSituationQueryParam queryParam); + + /** + * 获取累计情况 + * + * @param taxYearMonth + * @param employeeIds + * @return + */ + List getAddUpSituationList(YearMonth taxYearMonth, List employeeIds); + + XSSFWorkbook export(AddUpSituationQueryParam queryParam); + + + XSSFWorkbook exportDetail(AddUpSituationQueryParam queryParam); + + Map preview(AddUpSituationImportParam importParam); + + Map importAddUpSituation(AddUpSituationImportParam importParam); + + /** + * 删除累计情况 + * + * @return + */ + boolean deleteAddUpSituationList(Date taxCycle,Long taxAgentId); + + XSSFWorkbook downloadTemplate(AddUpSituationQueryParam queryParam); + + boolean deleteByTaxYearMonthAndTaxAgentIds(YearMonth localDate2YearMonth, Collection taxAgentIds); + + void batchSave(List list); + + /** + * @description 编辑数据 + * @return void + * @author Harryxzy + * @date 2022/10/27 22:03 + */ + void editAddUpSituation(AddUpSituationParam addUpSituationParam); + + /** + * @description 新建数据 + * @return void + * @author Harryxzy + * @date 2022/10/27 22:03 + */ + void createAddUpSituation(AddUpSituationParam addUpSituationParam); + + /** + * @description 删除所选数据 + * @return void + * @author Harryxzy + * @date 2022/10/27 22:35 + */ + void deleteSelectAddUpSituation(AddUpSituationDeleteParam deleteParam); + + /** + * @description 一键清空所有数据 + * @return null + * @author Harryxzy + * @date 2022/10/27 22:35 + */ + void deleteAllAddUpSituation(AddUpSituationDeleteParam addUpSituationDeleteParam); + + /** + * @description 获取往期累计情况 + * @return void + * @author Harryxzy + * @date 2022/10/31 14:00 + */ + AddUpSituationRecordDTO getAddUpSituation(AddUpSituationParam addUpSituationParam); +} diff --git a/src/com/engine/salary/service/AttendQuoteDataService.java b/src/com/engine/salary/service/AttendQuoteDataService.java new file mode 100644 index 000000000..21609dd55 --- /dev/null +++ b/src/com/engine/salary/service/AttendQuoteDataService.java @@ -0,0 +1,95 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.datacollection.dto.AttendQuoteDataBaseDTO; +import com.engine.salary.entity.datacollection.dto.AttendQuoteDataDTO; +import com.engine.salary.entity.datacollection.param.*; +import com.engine.salary.util.page.PageInfo; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import java.time.YearMonth; +import java.util.List; +import java.util.Map; + +/** + * 数据采集-考勤引用数据 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public interface AttendQuoteDataService { + + /** + * 查看数据采集-考勤引用数据列表(分页) + * + * @param queryParam + * @return + */ + PageInfo listPage(AttendQuoteDataQueryParam queryParam); + + + /** + * 导出考勤数据 + * @param queryParam + * @return + */ + XSSFWorkbook export(AttendQuoteDataQueryParam queryParam); + + /** + * 同步引用考勤数据 + * @param syncParam + * @return + */ + String syncAttendQuoteData(AttendQuoteDataSyncParam syncParam); + + /** + * 获取考勤引用数据 + * @param salaryYearMonth + * @param salarySobId + * @param employeeIds + * @return + */ + List getAttendQuoteData(YearMonth salaryYearMonth, Long salarySobId, List employeeIds); + + /** + * 导出考勤数据作为模板 + * @param exportParam + * @return + */ + XSSFWorkbook downloadTemplate(AttendQuoteDataExportTemplateParam exportParam); + + /** + * 获取考勤数据最终结果 + * + * @param attendQuoteDataBases + * @return + */ + List> getListMaps(List attendQuoteDataBases); + + /** + * 预览 + * @param param + * @return + */ + Map preview(AttendQuoteDataImportParam param); + + /** + * 导入 + * @param param + * @return + */ + Map importAttendQuoteData(AttendQuoteDataImportParam param); + + /** + * 编辑数据 + * @param attendQuoteDataEditParam + */ + void editData(AttendQuoteDataEditParam attendQuoteDataEditParam); + + /** + * 获取数据 + * @param attendQuoteDataEditParam + */ + Map getData(AttendQuoteDataEditParam attendQuoteDataEditParam); +} diff --git a/src/com/engine/salary/service/AttendQuoteFieldService.java b/src/com/engine/salary/service/AttendQuoteFieldService.java new file mode 100644 index 000000000..cf24e61c6 --- /dev/null +++ b/src/com/engine/salary/service/AttendQuoteFieldService.java @@ -0,0 +1,111 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.datacollection.dto.AttendQuoteFieldListDTO; +import com.engine.salary.entity.datacollection.param.AttendQuoteFieldQueryParam; +import com.engine.salary.entity.datacollection.param.AttendQuoteFieldSaveParam; +import com.engine.salary.entity.datacollection.po.AttendQuoteFieldPO; +import com.engine.salary.util.page.PageInfo; + +import java.util.Collection; +import java.util.List; +import java.util.Map; + +/** + * 数据采集-考勤引用字段 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public interface AttendQuoteFieldService { + + + /** + * 获取所有考勤字段 + * + * @return + */ + List getAllAttendQuoteFields(); + + /** + * 数据采集-考勤引用字段列表(分页) + * + * @param queryParam + * @return + */ + PageInfo listPage(AttendQuoteFieldQueryParam queryParam); + + /** + * 获取单个考勤字段 + * + * @param id + * @return + */ + AttendQuoteFieldPO getById(Long id); + + + + /** + * 数据采集-考勤引用字段列表 + * + * @param queryParam + * @return + */ + Map list(AttendQuoteFieldQueryParam queryParam); + + /** + * 获取数据采集-考勤引用字段表单 + * + * @param id + * @return + */ + AttendQuoteFieldPO getFrom(Long id); + + /** + * 新建数据采集-考勤引用字段 + * + * @param saveParam + * @return + */ + String save(AttendQuoteFieldSaveParam saveParam); + + /** + * 编辑数据采集-考勤引用字段 + * + * @param param + * @return + */ + String update(AttendQuoteFieldSaveParam param); + + /** + * 删除数据采集-考勤引用字段 + * + * @param ids + * @return + */ + String delete(Collection ids); + + /** + * 启用/停用自定义字段 + * + * @param param + * @return + */ + String updateEnableStatus(AttendQuoteFieldSaveParam param); + + + /** + * 同步考勤模块字段 + * + * @return + */ + String syncAttendFields(); + + /** + * 获取当前租户下所有的考勤引用字段 + * + * @return + */ + List listAll(); +} diff --git a/src/com/engine/salary/service/AttendQuoteFieldSettingService.java b/src/com/engine/salary/service/AttendQuoteFieldSettingService.java new file mode 100644 index 000000000..2fe3cd3bb --- /dev/null +++ b/src/com/engine/salary/service/AttendQuoteFieldSettingService.java @@ -0,0 +1,60 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.datacollection.dto.AttendQuoteFieldSettingListDTO; +import com.engine.salary.entity.datacollection.param.AttendQuoteFieldSettingQueryParam; +import com.engine.salary.entity.datacollection.param.AttendQuoteFieldSettingRecoverParam; +import com.engine.salary.entity.datacollection.param.AttendQuoteFieldSettingSaveParam; + +import java.util.List; + +/** + * 数据采集-考勤引用字段设置 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public interface AttendQuoteFieldSettingService { + + /** + * 列表 + * + * @param queryParam + * @return + */ + List list(AttendQuoteFieldSettingQueryParam queryParam); + + /** + * 列表(无同步) + * + * @param queryParam + * @return + */ + List listNoSync(AttendQuoteFieldSettingQueryParam queryParam); + + /** + * 保存 + * + * @param saveParam + * @return + */ + String save(AttendQuoteFieldSettingSaveParam saveParam); + + /** + * 恢复默认设置 + * + * @param recoverParam + * @return + */ + List recoverAsDefault(AttendQuoteFieldSettingRecoverParam recoverParam); + + /** + * 设为默认设置 + * + * @param saveParam + */ + String saveAsDefault(AttendQuoteFieldSettingSaveParam saveParam); + + +} diff --git a/src/com/engine/salary/service/AttendQuoteService.java b/src/com/engine/salary/service/AttendQuoteService.java new file mode 100644 index 000000000..0e57a4513 --- /dev/null +++ b/src/com/engine/salary/service/AttendQuoteService.java @@ -0,0 +1,42 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.datacollection.dto.AttendQuoteListDTO; +import com.engine.salary.entity.datacollection.param.AttendQuoteQueryParam; +import com.engine.salary.entity.datacollection.po.AttendQuotePO; +import com.engine.salary.util.page.PageInfo; + +import java.time.YearMonth; +import java.util.Collection; +import java.util.List; + +public interface AttendQuoteService { + + /** + * 数据采集-考勤引用列表(分页) + * + * @param queryParam + * @return + */ + PageInfo listPage(AttendQuoteQueryParam queryParam); + + + /** + * 删除数据采集-考勤引用 + * + * @param ids + * @return + */ + String delete(Collection ids); + + /** + * 检查是否可以操作 + * + * @param salaryYearMonth + * @param salarySobIds + * @return + */ + Boolean checkOperation(YearMonth salaryYearMonth, List salarySobIds); + + AttendQuotePO getById(Long id); + +} diff --git a/src/com/engine/salary/service/AttendService.java b/src/com/engine/salary/service/AttendService.java new file mode 100644 index 000000000..f91bbca7c --- /dev/null +++ b/src/com/engine/salary/service/AttendService.java @@ -0,0 +1,12 @@ +package com.engine.salary.service; + +/** + * 考勤模块 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public interface AttendService { +} diff --git a/src/com/engine/salary/service/ColumnBuildService.java b/src/com/engine/salary/service/ColumnBuildService.java new file mode 100644 index 000000000..c1aec0b1b --- /dev/null +++ b/src/com/engine/salary/service/ColumnBuildService.java @@ -0,0 +1,36 @@ +package com.engine.salary.service; + +import com.cloudstore.eccom.pc.table.WeaTableColumn; +import com.engine.salary.entity.siaccount.po.InsuranceAccountDetailPO; +import com.engine.salary.entity.siaccount.po.InsuranceAccountInspectPO; +import com.engine.salary.entity.siaccount.po.InsuranceCompensationPO; + +import java.util.List; + +/** + * @Author weaver_cl + * + * @Date 2022/4/12 + * @Version V1.0 + **/ +public interface ColumnBuildService { + /** + * 核算详情表头元素 + * + * @param pos pos + * @param tenantKey 租户key + * @param paymentStatus 缴纳状态 + * @return + */ + List buildCommonColumnsWithStyle(List pos, Long employeeId, String tenantKey, Integer paymentStatus); + + List buildCommonColumns(List pos); + + List buildInspectColumns(List pos, Long paymentOrganization); + + /** + * 调差详情表头元素 + */ + List buildCompensationColumns(); +} + diff --git a/src/com/engine/salary/service/ExtEmpService.java b/src/com/engine/salary/service/ExtEmpService.java new file mode 100644 index 000000000..43ffacf58 --- /dev/null +++ b/src/com/engine/salary/service/ExtEmpService.java @@ -0,0 +1,60 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.extemp.dto.ExtEmpDTO; +import com.engine.salary.entity.extemp.param.ExtEmpImportParam; +import com.engine.salary.entity.extemp.param.ExtEmpQueryParam; +import com.engine.salary.entity.extemp.param.ExtEmpSaveParam; +import com.engine.salary.entity.extemp.po.ExtEmpPO; +import com.engine.salary.entity.salarysob.param.SalarySobRangeEmpQueryParam; +import com.engine.salary.util.page.PageInfo; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import java.util.Collection; +import java.util.List; +import java.util.Map; + +public interface ExtEmpService { + + List list(ExtEmpQueryParam param); + + PageInfo listPage (ExtEmpQueryParam param); + + void save(ExtEmpSaveParam po); + + void update(ExtEmpSaveParam po); + + void delete(Collection ids); + + DataCollectionEmployee getEmployeeById(Long id); + + /** + * 获取人员信息 + * @param ids + * @return + */ + List getEmployeeByIds(List ids); + + List listByParams(List includeQueryParams); + + /** + * 查询人员列表 + * + * @return + */ + List listEmployee(); + + Collection getEmployeeByIdsAll(List ids); + + Collection listAllForReport(); + + ExtEmpPO getById(Long id); + + XSSFWorkbook exportImportTemplate(); + + Map previewImportExtEmp(ExtEmpImportParam param); + + Map importExtEmp(ExtEmpImportParam param); + + List listBySubCompanyOrDepartment(List subCompanyIds, List departmentIds); +} \ No newline at end of file diff --git a/src/com/engine/salary/service/FormulaRunService.java b/src/com/engine/salary/service/FormulaRunService.java new file mode 100644 index 000000000..43fbc55df --- /dev/null +++ b/src/com/engine/salary/service/FormulaRunService.java @@ -0,0 +1,14 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.salaryformula.ExpressFormula; +import com.engine.salary.entity.salaryformula.po.FormulaVar; +import com.engine.salary.formlua.entity.standard.ExcelResult; + +import java.util.List; + +public interface FormulaRunService { + + ExcelResult run(ExpressFormula expressFormula, List formulaVars, DataCollectionEmployee simpleEmployee) ; + +} diff --git a/src/com/engine/salary/service/MySalaryShowSetService.java b/src/com/engine/salary/service/MySalaryShowSetService.java new file mode 100644 index 000000000..3bfea6d7b --- /dev/null +++ b/src/com/engine/salary/service/MySalaryShowSetService.java @@ -0,0 +1,19 @@ +package com.engine.salary.service; + + +import com.engine.salary.entity.salaryBill.dto.MySalaryShowSetDTO; + +/** + * @Description: 我的薪资福利显示设置 + * @Author: wangxiangzhong + * @Date: 2023/8/7 11:15 + */ +public interface MySalaryShowSetService { + + /** + * 获取显示设置 + * + * @return + */ + MySalaryShowSetDTO get(); +} diff --git a/src/com/engine/salary/service/OtherDeductionService.java b/src/com/engine/salary/service/OtherDeductionService.java new file mode 100644 index 000000000..18b743cda --- /dev/null +++ b/src/com/engine/salary/service/OtherDeductionService.java @@ -0,0 +1,117 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.datacollection.dto.OtherDeductionListDTO; +import com.engine.salary.entity.datacollection.dto.OtherDeductionRecordDTO; +import com.engine.salary.entity.datacollection.param.*; +import com.engine.salary.entity.datacollection.po.OtherDeductionPO; +import com.engine.salary.util.page.PageInfo; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import java.time.YearMonth; +import java.util.List; +import java.util.Map; + +/** + * 数据采集-其他免税扣除 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public interface OtherDeductionService { + + /** + * 通过id获取单条其他免税扣除记录 + * + * @param id + * @return + */ + OtherDeductionPO getById(Long id); + + /** + * 数据采集-其他免税扣除列表 + * + * @param queryParam + * @return + */ + PageInfo listPage(OtherDeductionQueryParam queryParam); + + /** + * 获取数据采集-其他免税扣除详情 + * + * @param queryParam + * @return + */ + PageInfo recordListPage(OtherDeductionQueryParam queryParam); + + /** + * 导出 + * + */ + XSSFWorkbook export(OtherDeductionQueryParam queryParam); + + /** + * 导出详情 + * + */ + XSSFWorkbook exportDetail( OtherDeductionQueryParam queryParam); + + /** + * 下载导入模板 + * + * @param param + * @return + */ + XSSFWorkbook downloadTemplate(OtherDeductionQueryParam param); + + /** + * 预览 + */ + Map preview(OtherDeductionImportParam importParam); + + /** + * 导入数据 + */ + Map importData(OtherDeductionImportParam importParam); + + + + /** + * 获取其他免税扣除数据 + * + * @param declareMonth + * @param employeeIds + * @return + */ + List getOtherDeductionList(YearMonth declareMonth, List employeeIds, List taxAgentIds); + + /** + * 编辑数据 + */ + void editData(OtherDeductionParam otherDeductionParam); + + /** + * 新增数据 + */ + void createData(OtherDeductionParam otherDeductionParam); + + /** + * 删除所选数据 + */ + void deleteSelectData(AddUpDeductionRecordDeleteParam deleteParam); + + /** + * 一键清空数据 + */ + void deleteAllData(AddUpDeductionRecordDeleteParam deleteParam); + + /** + * 获取数据 + */ + OtherDeductionRecordDTO getOtherDeduction(OtherDeductionParam otherDeductionParam); + + String extendToLastMonth(OtherDeductionExtendLastParam param); + + List listAuth(OtherDeductionQueryParam queryParam); +} diff --git a/src/com/engine/salary/service/ProgressService.java b/src/com/engine/salary/service/ProgressService.java new file mode 100644 index 000000000..210ec62dd --- /dev/null +++ b/src/com/engine/salary/service/ProgressService.java @@ -0,0 +1,86 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.progress.ProgressDTO; + +import java.math.BigDecimal; + +/** + * 进度条 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public interface ProgressService { + + /** + * 初始化核算进度条 + * + * @param salaryAcctProgress + * @return + */ + void initProgress(String cacheKey, ProgressDTO salaryAcctProgress); + + /** + * 更新进度条 + * + * @param calculatedQuantity + * @return + */ + void getAndAddCalculatedQty(String cacheKey, Integer calculatedQuantity); + + + /** + * 更新进度条 + * @param cacheKey + * @param calculatedQuantity + * @param message + */ + void getAndAddCalculatedQty(String cacheKey, Integer calculatedQuantity, String message); + + /** + * 计算失败 + * + * @param cacheKey + * @param message + * @return + */ + void fail(String cacheKey, String message); + + /** + * 完成 + * + * @param cacheKey + */ + void finish(String cacheKey, boolean checkStatus); + + /** + * 完成 + * @param cacheKey + * @param checkStatus + * @param message + */ + void finish(String cacheKey, boolean checkStatus,String message); + + /** + * 更新进度条 + * + * @param cacheKey + */ + void updateProgress(String cacheKey, BigDecimal progress, boolean checkStatus); + + /** + * 获取进度条 + * @return + */ + ProgressDTO getProgress(String cacheKey); + + /** + * 删除redis中的缓存 + * + * @param cacheKey + * @return + */ + ProgressDTO del(String cacheKey); +} diff --git a/src/com/engine/salary/service/PushService.java b/src/com/engine/salary/service/PushService.java new file mode 100644 index 000000000..59a6f311d --- /dev/null +++ b/src/com/engine/salary/service/PushService.java @@ -0,0 +1,75 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.push.dto.PushRecordDTO; +import com.engine.salary.entity.push.dto.PushRecordDetailDTO; +import com.engine.salary.entity.push.dto.PushSettingDTO; +import com.engine.salary.entity.push.dto.PushSettingItemDTO; +import com.engine.salary.entity.push.param.*; +import com.engine.salary.entity.push.po.PushSettingItemPO; +import com.engine.salary.entity.push.po.PushSettingPO; +import com.engine.salary.util.page.PageInfo; + +import java.util.List; + +public interface PushService { + + /** + * 推送任务列表 + * + * @param param + * @return + */ + PageInfo settingList(PushSettingQueryParam param); + + + /** + * 保存推送配置 + * + * @param param + */ + PushSettingPO save(PushSettingSaveParam param); + + /** + * 删除推送配置 + * + * @param id + */ + void delete(Long id); + + /** + * 推送明细列表 + * + * @param param + * @return + */ + PageInfo itemList(PushSettingItemQueryParam param); + + /** + * 保存明细配置 + * + * @param param + */ + PushSettingItemPO saveItem(PushSettingItemSaveParam param); + + /** + * 删除明细配置 + * + * @param id + */ + void deleteItem(Long id); + + void createPushRecord(Long salaryAcctRecordId); + + void withdrawPushRecord(Long salaryAcctRecordId); + + void push(Long id); + + void withdraw(Long id); + + void removeRecords(List records); + + PageInfo recordList(RecordListQueryParam param); + + PageInfo recordDetailList(RecordDetailListQueryParam param); + +} diff --git a/src/com/engine/salary/service/RecordsBuildService.java b/src/com/engine/salary/service/RecordsBuildService.java new file mode 100644 index 000000000..3edbecd45 --- /dev/null +++ b/src/com/engine/salary/service/RecordsBuildService.java @@ -0,0 +1,22 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.siaccount.po.InsuranceAccountDetailPO; +import com.engine.salary.entity.siaccount.po.InsuranceAccountInspectPO; + +import java.util.List; +import java.util.Map; + +/** + * @Author weaver_cl + * + * @Date 2022/4/11 + * @Version V1.0 + **/ +public interface RecordsBuildService { + + List> buildCommonRecords(List list, Long employeeId, boolean dynamicEmpInfo); + + List> buildCommonRecordsWithStyle(List list, Long employeeId); + + List> buildInspectRecords(List list, Long paymentOrganization); +} diff --git a/src/com/engine/salary/service/RemoteExcelService.java b/src/com/engine/salary/service/RemoteExcelService.java new file mode 100644 index 000000000..2d657dd8e --- /dev/null +++ b/src/com/engine/salary/service/RemoteExcelService.java @@ -0,0 +1,31 @@ +package com.engine.salary.service; + + +import com.engine.salary.entity.salaryformula.po.FormulaVar; +import com.engine.salary.enums.salaryformula.ReferenceTypeEnum; + +import java.util.List; +import java.util.Map; + +public interface RemoteExcelService { +// ExcelResult aggregation(AggFunc func, String sourceId, String fieldId, List filterFormDataList, Map extendParam, DataCollectionEmployee employee); +// +// ExcelPage categoryList(ExcelPage page, Map extendParam, DataCollectionEmployee employee); + + List fieldList(String sourceId, Map extendParam); + + List> fieldGroupList(Map extendParam); + + Map> allFieldList(ReferenceTypeEnum referenceTypeEnum); + + +// ExcelPage dataSourceList(String categoryId, ExcelPage page, Map extendParam, DataCollectionEmployee employee); +// +// List findProperData(String dataId, String fieldId, String fieldType, Map extendParam, DataCollectionEmployee employee); +// +// List choose(String sourceId, List filterFormDataList, Map extendParam, DataCollectionEmployee employee); +// +// List vlookups(String sourceId, List filterFormDataList, List returnFields, Map extendParam, DataCollectionEmployee employee); +// +// Map findSourceName(String Module, List idList, Map extendParam, DataCollectionEmployee employee); +} diff --git a/src/com/engine/salary/service/SIAComparisonResultService.java b/src/com/engine/salary/service/SIAComparisonResultService.java new file mode 100644 index 000000000..73e6d3b9c --- /dev/null +++ b/src/com/engine/salary/service/SIAComparisonResultService.java @@ -0,0 +1,30 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.salaryacct.param.SalaryComparisonResultQueryParam; +import com.engine.salary.entity.siaccount.dto.InsuranceComparisonResultListDTO; +import com.engine.salary.entity.siaccount.param.InsuranceComparisonResultQueryParam; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +/** + * @Author: sy + * @Description: 福利核算的线下对比结果 + * @Date: 2022/9/28 + **/ +public interface SIAComparisonResultService { + + /** + * 根据列表查询条件查询线下对比结果(分页) + */ + InsuranceComparisonResultListDTO listPageByParam(InsuranceComparisonResultQueryParam queryParam); + + + /** + * 根据列表查询条件查询线下对比结果 + */ + InsuranceComparisonResultListDTO listByParam(InsuranceComparisonResultQueryParam queryParam); + + /** + * 导出福利核算线下对比结果 + */ + XSSFWorkbook exportComparisonResult(InsuranceComparisonResultQueryParam queryParam); +} diff --git a/src/com/engine/salary/service/SIAccountService.java b/src/com/engine/salary/service/SIAccountService.java new file mode 100644 index 000000000..55a578556 --- /dev/null +++ b/src/com/engine/salary/service/SIAccountService.java @@ -0,0 +1,328 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.siaccount.dto.InsuranceAccountTabDTO; +import com.engine.salary.entity.siaccount.dto.InsuranceAccountViewListDTO; +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.taxagent.po.TaxAgentPO; +import com.engine.salary.util.page.PageInfo; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import java.util.Collection; +import java.util.List; +import java.util.Map; + +/** + * @Author weaver_cl + * + * @Date 2022/4/11 + * @Version V1.0 + **/ +public interface SIAccountService { + + /** + * 查询台账列表 + * @param insuranceAccountBatchParam + * @return + */ + Map listPage(InsuranceAccountBatchParam insuranceAccountBatchParam); + + /** + * 获取正常缴纳列表 + * @param insuranceAccountDetailParam + * @return + */ + Map listCommonPage(InsuranceAccountDetailParam insuranceAccountDetailParam); + + /** + * 根据姓名名获取正常缴纳列表 + * @param insuranceAccountDetailParam + * @return + */ + Map listCommonPageByName(InsuranceAccountDetailParam insuranceAccountDetailParam); + + /** + * 获取补缴缴纳列表 + * @param insuranceAccountDetailParam + * @return + */ + Map listSupplementaryPage(InsuranceAccountDetailParam insuranceAccountDetailParam); + + /** + * 获取退差列表 + * @param insuranceAccountDetailParam + * @return + */ + Map listRecessionPage(InsuranceAccountDetailParam insuranceAccountDetailParam); + + /** + * 获取补差列表 + * @param insuranceAccountDetailParam + * @return + */ + Map listBalancePage(InsuranceAccountDetailParam insuranceAccountDetailParam); + + /** + * 根据姓名获取补缴缴纳列表 + * @param insuranceAccountDetailParam + * @return + */ + Map supplementaryByNameList(InsuranceAccountDetailParam insuranceAccountDetailParam); + + /** + * 获取核算月份备注填写表单 + * @param params + * @return + */ + Map getForm(Map params); + + /** + * 保存并进入核算 + * @param param + */ + String save(AccountParam param); + + /** + * 新建核算并归档 + * @param param + * @return + */ + String saveAndFile(AccountParam param); + + /** + * 正常缴纳页核算 + * @param saveCommonAccountParam + */ + void commonAccount(SaveCommonAccountParam saveCommonAccountParam); + + /** + * 删除月份表单 + * @param accountParam + */ + void delete(AccountParam accountParam); + + /** + * 添加正常缴纳人员 + * @param accountParam + */ + void saveCommonAccount(SaveCommonAccountParam accountParam); + + /** + * 添加补缴人员 + * @param saveSupplementaryAccountParam + */ + void saveSupplementaryAccount(SaveSupplementaryAccountParam saveSupplementaryAccountParam); + + /** + * 删除正常缴纳人员 + * @param accountParam + */ + void deleteCommonAccount(SaveCommonAccountParam accountParam); + + /** + * 删除补缴人员 + * @param param + */ + void deleteSupplementaryAccount(SaveCommonAccountParam param); + + /** + * 台账归档 + * @param accountParam + */ + void file(AccountParam accountParam); + + /** + * 重置核算异常 + * @param ids + */ + void unconfirmed(Collection ids); + + + /** + * 获取核算异常列表页是否导出档案开关 + * @param billMonth + */ + Map buttonCheck(String billMonth); + + + /** + * 忽略核算异常 + * @param longs + */ + void ignore(Collection longs); + + /** + * tab信息 + */ + InsuranceAccountTabDTO tabList(AccountParam build); + + /** + * 人员异动 + * @param insuranceAccountDetailParam + */ + Map changeList(InsuranceAccountDetailParam insuranceAccountDetailParam); + + /** + * 核算核算异常,重新核算 + * @param inspectAccountParam + */ + void accountInspect(InspectAccountParam inspectAccountParam); + + /** + * 核算失败列表 + * @param param + */ + Map getInspectTable(InsuranceAccountDetailParam param); + + + + /** + * 正常缴纳添加缴纳人员表单 + * @param params + * @return + */ + Map getCommonForm(Map params); + + + /** + * 补缴添加缴纳人员表单 + * @param params + * @return + */ + Map getSupplementaryForm(Map params); + + /** + * 总览 + * @param param + * @return + */ + PageInfo overView(InsuranceAccountDetailParam param); + + /** + * 根据字段名提供对应的数据,给账套使用 + * + * @param billMonth + * @param employeeIds + * @return + */ + List> welfareData(String billMonth, List employeeIds,Long taxAgentId); + + /** + * 给套账提供字段名对应字段释义 + * + * @return + */ + Map welfareColumns(); + + /** + * 根据条件获取所有的核算异常明细 + * + * @param ids + * @return + */ + List allInspects(Collection ids, String billMonth); + + Collection getAdminTaxAgentList(); + + void socialSecurityBenefitsRecalculate(InsuranceAccountBatchPO param); + + + /** + * 导出“福利核算导入模板” + */ + XSSFWorkbook exportImportTemplate(InsuranceAcctDetailImportTemplateParam param); + + /** + * 将福利核算模板导入的数据更新到数据库 + */ + Map importInsuranceAcctDetail(InsuranceAcctImportParam insuranceAcctImportParam); + + /** + * 预览“福利核算导入”模板导入的数据 + */ + Map preview(InsuranceAcctImportParam insuranceAcctImportParam); + + /** + * 导出“福利核算-补缴导入模板” + */ + XSSFWorkbook exportSupplyImportTemplate(InsuranceAcctDetailImportTemplateParam param); + + /** + * 导出“福利核算-线下对比导入模板” + */ + XSSFWorkbook exportComparisonWelfareTemplate(InsuranceAccountDetailParam param); + + /** + * 将通过“福利核算-线下对比导入”模板导入的数据更新到hrsa_excel_bill_detail表中 + */ + Map importExcelInsuranceDetail(ExcelInsuranceImportParam excelInsuranceImportParam); + + /** + * 刷新_bill_batch表中的统计信息 + */ + void refreshBillBatch(Long paymentOrganization, String billMonth); + + /** + * 将通过id获取InsuranceAccountDetailPO中的社保、公积金、其他福利个人和公司缴纳数据 + */ + Map getPaymentById(Long id); + + /** + * 编辑InsuranceAccountDetailPO中的社保、公积金、其他福利个人和公司缴纳数据 + */ + void editAccount(EditAccountDetailParam param); + + /** + * 导出“福利核算-补差导入模板” + */ + XSSFWorkbook exportBalanceImportTemplate(InsuranceAcctDetailImportTemplateParam param); + + /** + * 将福利台账-补差模板导入的数据更新到数据库 + */ + Map importBalanceInsuranceDetail(InsuranceAcctImportParam importParam); + + + /** + * 正常缴纳合计行 + * + * @param queryParam + * @return + */ + Map listCommonSum(InsuranceAccountDetailParam queryParam); + + /** + * 补缴合计行 + * @param insuranceAccountDetailParam + */ + Map listSupplementarySum(InsuranceAccountDetailParam insuranceAccountDetailParam); + + /** + * 退差合计列 + * @param insuranceAccountDetailParam + */ + Map listRecessionSum(InsuranceAccountDetailParam insuranceAccountDetailParam); + + /** + * 补差合计列 + * @param insuranceAccountDetailParam + */ + Map listBalanceSum(InsuranceAccountDetailParam insuranceAccountDetailParam); + + boolean checkBalance(InsuranceAccountDetailPO po); + + boolean checkBalancePayInsurance(InsuranceAccountDetailPO po); + + List buildRecords(List list, Map paymentMap); + + void cacheWelfareField(List welfareNames); + + void cacheBalanceWelfareField(List welfareNames); + + void deleteSocialAcctEmp(SaveCommonAccountParam param); + + String addSocialAcctEmp(SaveCommonAccountParam param); +} + diff --git a/src/com/engine/salary/service/SIArchivesService.java b/src/com/engine/salary/service/SIArchivesService.java new file mode 100644 index 000000000..879ab655a --- /dev/null +++ b/src/com/engine/salary/service/SIArchivesService.java @@ -0,0 +1,165 @@ +package com.engine.salary.service; + +import com.cloudstore.eccom.pc.table.WeaTableColumn; +import com.engine.salary.entity.siarchives.dto.InsuranceArchivesBaseHistoryDTO; +import com.engine.salary.entity.siarchives.param.InsuranceArchivesListParam; +import com.engine.salary.entity.siarchives.param.InsuranceArchivesSaveParam; +import com.engine.salary.entity.siarchives.param.SIArchiveBaseHistoryListParam; +import com.engine.salary.entity.siarchives.po.*; +import com.engine.salary.util.page.PageInfo; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import java.util.Collection; +import java.util.List; +import java.util.Map; + +/** + * @Author weaver_cl + * + * @Date 2022/3/11 + * @Version V1.0 + **/ +public interface SIArchivesService { + + Map getTips(Map params); + + Map getBaseForm(Map params); + + Map getPaymentForm(Map params); + + String insert(InsuranceArchivesSaveParam param); + + Map listPage(InsuranceArchivesListParam insuranceArchivesListParam); + + Map getSearchCondition(Map stringObjectMap); + + /** + * 根据高级搜索框或者员工id集合导出档案 + * + * @param param 请求报文 + * @return map + */ + XSSFWorkbook export(InsuranceArchivesListParam param); + + + /** + * 获取员工的基本信息 + *

+ * 此处主要是一个公共接口,有多处引用。我们薪资系统只保存员工id(employeeId), + * 但是页面上需要展示员工的更多信息(姓名,部门,状态。。。), + * 所以这里主要是用于接收联表数据的一个接口 + * + * @param param 高级搜索条件,用于过滤数据 + * @return list + */ + List listPageEmployeePOS(InsuranceArchivesListParam param); + + /** + * 获取福利档案各tab总人数 + */ + Map queryInsuranceTabTotal(); + + /** + * 批量变更档案列表的runStatus + */ + void updateRunStatus(InsuranceArchivesBaseInfoPO po); + + /** + * 批量取消停缴 + */ + void cancelStopPayment(Collection ids); + + /** + * 批量减员 + */ + Map stayDelToStop(Collection ids); + + /** + * 批量减员,直接减员,并给予最后缴纳月 + */ + Map stopWithoutLimit(Collection ids, String yearMonth, String fundEndYearMonth, String otherEndYearMonth); + + /** + * 全量减员 + */ + Map allStayDelToStop(); + + /** + * 全量增员 + */ + Map allStayAddToPay(); + + /** + * 批量增员 + */ + Map stayAddToPay(Collection ids); + + /** + * 拷贝福利档案到新的个税扣缴义务人并置为在缴 + * @param toCopyTaxAgentId 被拷贝的福利档案所属个税扣缴义务人id + * @param toUpdateTaxAgentId 被更新的福利档案所属个税扣缴义务人id + * @param employeeId 福利档案所属人员id + * @return + */ + Map copyToPay(Long toCopyTaxAgentId, Long toUpdateTaxAgentId, Long employeeId, String payStartYearMonth); + + /** + * 待减员页面的删除待办 + */ + void cancelStayDel(InsuranceArchivesBaseInfoPO insuranceArchivesBaseInfoPO); + + /** + * 处理福利档案增量数据 + */ + void handleChangeData(long currentEmployeeId); + + /** + * 删除档案 + * @param longs + */ + void deleteArchive(Collection longs); + + void handleStayDelData(long currentEmployeeId); + + PageInfo historyListByEmployeeIdAndOperator(SIArchiveBaseHistoryListParam param); + + List> buildTableData(List insuranceArchivesEmployeePOS); + + List buildWeaTableColumns(List insuranceArchivesEmployeePOS); + + boolean isDiffWelBase(); + + List payInsuranceIds(Long socialSchemeId, Integer paymentScope); + + List payInsuranceIds(Long socialSchemeId); + + List getSocialByEmployeeIds(List employeeIds); + List getFundByEmployeeIds(List employeeIds); + List getOtherByEmployeeIds(List employeeIds); + + Map buildBatchAccount(List ids, Long paymentOrganization); + + Boolean checkWelBaseLimit(Long primaryId, String paymentBaseString, Integer paymentScope, StringBuilder errorMsg); + + String adaptWelBaseLimit(Long primaryId, String paymentBaseString, Integer paymentScope); + + String checkAndBuildWelBaseWithLimit(Long primaryId, String paymentBaseString, Integer paymentScope); + + List dealSocialBaseAdjustInfoList(List adjustList, Long creator); + List dealFundBaseAdjustInfoList(List adjustList, Long creator); + List dealOtherBaseAdjustInfoList(List adjustList, Long creator); + + void batchInsertAdjustHistory(List adjustHistoryList); + + List listEndDateIsNull(List employeeIds); + + List listStartDateIsNull(List employeeIds); + + List listInsuranceArchivesSocialSchemeByIds(List ids); + + List listInsuranceArchivesFundSchemeByIds(List ids); + + List listInsuranceArchivesOtherSchemeByIds(List ids); + + List listAll(); +} diff --git a/src/com/engine/salary/service/SIBalanceService.java b/src/com/engine/salary/service/SIBalanceService.java new file mode 100644 index 000000000..66dba0f98 --- /dev/null +++ b/src/com/engine/salary/service/SIBalanceService.java @@ -0,0 +1,20 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.siaccount.param.BalanceAccountBaseParam; +import com.engine.salary.entity.siaccount.param.InspectAccountParam; + +import java.util.List; +import java.util.Map; + + +public interface SIBalanceService { + + void del(InspectAccountParam param, Long employeeId); + + /** + * 获取待编辑的补差费用相关福利项 + */ + List> getPaymentGroup(BalanceAccountBaseParam param); + + void addNewBalance(BalanceAccountBaseParam param); +} diff --git a/src/com/engine/salary/service/SICategoryService.java b/src/com/engine/salary/service/SICategoryService.java new file mode 100644 index 000000000..b1c9b37f7 --- /dev/null +++ b/src/com/engine/salary/service/SICategoryService.java @@ -0,0 +1,74 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.sicategory.dto.ICategoryDTO; +import com.engine.salary.entity.sicategory.dto.ICategoryFormDTO; +import com.engine.salary.entity.sicategory.dto.ICategoryListDTO; +import com.engine.salary.entity.sicategory.po.ICategoryPO; +import com.engine.salary.entity.sischeme.param.InsuranceSchemeParam; +import com.engine.salary.enums.sicategory.WelfareTypeEnum; +import com.engine.salary.util.page.PageInfo; + +import java.util.List; +import java.util.Map; + +/** + * @Author weaver_cl + * @Date 2022/3/9 + * @Version V1.0 + **/ +public interface SICategoryService { + + Map getForm(Map params); + + Map insert(Map params); + + Map update(Map params); + + Map updateStatusById(Map params); + + PageInfo listPage(InsuranceSchemeParam queryParam); + + /** + * 查询自定义福利列表 + * + * @param welfareType 福利类型,用于页面右上角的筛选功能,不传则查询全部 + * @return 分页列表 + * @see WelfareTypeEnum + */ +// PageInfo listPage(WelfareTypeEnum welfareType); + + + /** + * 根据tenantKey获取name和id的map结构 + * + * @return map + */ + Map categoryIdNameMap(); + + /** + * @description 根据ID获取自定义福利 + * @return void + * @author Harryxzy + * @date 2022/10/14 11:40 + */ + ICategoryDTO getByID(Long customCategoryId); + + /*** + * @description 修改自定义福利 名称 + * @return void + * @author Harryxzy + * @date 2022/10/14 14:50 + */ + Map updateCategoryName(ICategoryFormDTO iCategoryFormDTO); + + /*** + * @description 修改自定义福利 名称、缴费对象 + */ + Map updateCategoryNameAndPayScope(ICategoryFormDTO iCategoryFormDTO); + + Map deleteCustomCategory(ICategoryFormDTO iCategoryFormDTO); + + ICategoryPO getICategoryPOByID(Long id); + + List listByName(String insuranceName); +} diff --git a/src/com/engine/salary/service/SICompensationService.java b/src/com/engine/salary/service/SICompensationService.java new file mode 100644 index 000000000..b79c29fc4 --- /dev/null +++ b/src/com/engine/salary/service/SICompensationService.java @@ -0,0 +1,36 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.hrm.dto.HrmInfoDTO; +import com.engine.salary.entity.hrm.param.HrmQueryParam; +import com.engine.salary.entity.siaccount.dto.InsuranceCompensationDTO; +import com.engine.salary.entity.siaccount.param.CompensationParam; +import com.engine.salary.util.page.PageInfo; + +import java.util.List; +import java.util.Map; + +public interface SICompensationService { + + List getEmployeeListToCompensation(HrmQueryParam param); + + List> compensationCategoryType(Long id); + + List> compensationComTotal(List paramList); + + Map compensationAccount(List list); + + /** + * 保存社保调差默认配置 + */ + String compensationConfigSave(List param); + + /** + * 社保调差撤回 + */ + String compensationRevert(InsuranceCompensationDTO param); + + /** + * 社保调差历史记录列表 + */ + Map compensationList(String billMonth, Long paymentOrganization); +} diff --git a/src/com/engine/salary/service/SIExportService.java b/src/com/engine/salary/service/SIExportService.java new file mode 100644 index 000000000..f9ee4608e --- /dev/null +++ b/src/com/engine/salary/service/SIExportService.java @@ -0,0 +1,34 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.siexport.param.InsuranceExportParam; +import com.engine.salary.entity.siexport.po.AccountExportPO; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import java.util.List; +import java.util.Map; + +/** + * @Author weaver_cl + * @Description: + * @Date 2022/4/18 + * @Version V1.0 + **/ +public interface SIExportService { + + /** + * 总览导出 + * @param param + * @return + */ + XSSFWorkbook exportOverView(InsuranceExportParam param); + + /** + * 福利核算导出 + * @param paymentStatus + * @param param + * @return + */ + XSSFWorkbook exportAccount(Integer paymentStatus, InsuranceExportParam param); + + List> buildCommonRecords(List list, boolean isImport); +} diff --git a/src/com/engine/salary/service/SIImportService.java b/src/com/engine/salary/service/SIImportService.java new file mode 100644 index 000000000..1dd78a85e --- /dev/null +++ b/src/com/engine/salary/service/SIImportService.java @@ -0,0 +1,20 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.siarchives.param.InsuranceArchivesListParam; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +/** + * @Author weaver_cl + * @Description: + * @Date 2022/4/20 + * @Version V1.0 + **/ +public interface SIImportService { + + /** + * 导出档案导入所需要的模板,可根据开关选择是否导出现有的档案数据 + * + * @param param 是否导出带档案数据的模板 + */ + XSSFWorkbook exportTemplate(InsuranceArchivesListParam param); +} diff --git a/src/com/engine/salary/service/SIRecessionService.java b/src/com/engine/salary/service/SIRecessionService.java new file mode 100644 index 000000000..71ba297e3 --- /dev/null +++ b/src/com/engine/salary/service/SIRecessionService.java @@ -0,0 +1,17 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.hrm.dto.HrmInfoDTO; +import com.engine.salary.entity.hrm.param.HrmQueryParam; +import com.engine.salary.entity.siaccount.param.RecessionParam; +import com.engine.salary.util.page.PageInfo; + +import java.util.Collection; + +public interface SIRecessionService { + + void save(RecessionParam param, Long employeeId); + + void del(Collection ids, Long employeeId); + + PageInfo getEmployeeListByTaxAgent(HrmQueryParam param); +} diff --git a/src/com/engine/salary/service/SIRepairService.java b/src/com/engine/salary/service/SIRepairService.java new file mode 100644 index 000000000..2b4dacc38 --- /dev/null +++ b/src/com/engine/salary/service/SIRepairService.java @@ -0,0 +1,16 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.siaccount.param.SupplementAccountBaseParam; + +import java.util.List; +import java.util.Map; + +public interface SIRepairService { + + List> getSupplementPaymentForm(SupplementAccountBaseParam param); + + /** + * 获取待编辑的补缴费用相关福利项 + */ + List> getPaymentGroup(SupplementAccountBaseParam param); +} diff --git a/src/com/engine/salary/service/SIReportService.java b/src/com/engine/salary/service/SIReportService.java new file mode 100644 index 000000000..21853c64e --- /dev/null +++ b/src/com/engine/salary/service/SIReportService.java @@ -0,0 +1,11 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.siaccount.param.QueryAccountDetailParam; +import com.engine.salary.entity.siaccount.po.InsuranceAccountDetailPO; +import com.engine.salary.util.page.PageInfo; + + +public interface SIReportService { + + PageInfo welfareList(QueryAccountDetailParam param); +} diff --git a/src/com/engine/salary/service/SISchemeService.java b/src/com/engine/salary/service/SISchemeService.java new file mode 100644 index 000000000..86eb024ee --- /dev/null +++ b/src/com/engine/salary/service/SISchemeService.java @@ -0,0 +1,86 @@ +package com.engine.salary.service; + +import com.cloudstore.eccom.pc.table.WeaTableColumn; +import com.engine.salary.entity.siarchives.param.InsuranceArchivesListParam; +import com.engine.salary.entity.siarchives.param.SIArchiveImportParam; +import com.engine.salary.entity.siarchives.po.InsuranceArchivesEmployeePO; +import com.engine.salary.entity.sischeme.dto.InsuranceSchemeListDTO; +import com.engine.salary.entity.sischeme.param.InsuranceSchemeDetailUpdateParam; +import com.engine.salary.entity.sischeme.param.InsuranceSchemeParam; +import com.engine.salary.entity.sischeme.po.InsuranceSchemeDetailPO; +import com.engine.salary.entity.sischeme.po.InsuranceSchemePO; +import com.engine.salary.util.page.PageInfo; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import java.util.List; +import java.util.Map; + +/** + * @Author weaver_cl + * @Description: + * @Date 2022/3/7 + * @Version V1.0 + **/ +public interface SISchemeService { + + Map getForm(Map params); + + Map insertScheme(Map params); + + String update(Map params); + + Map delete(Map params); + + Map copyScheme(Map params); + + List queryListByInsuranceIdIsPayment(Long insuranceId, Integer isPayment); + + Map listPage(Map params); + + /** + * 获取当前租户下所有的方案id和方案名称的map + * @return Map + */ + Map getSchemeIdNameMap(); + + /** + * 获取方案列表 + * @param param + * @return + */ + PageInfo list(InsuranceSchemeParam param); + + List listPageEmployeePOS(InsuranceArchivesListParam param); + + List> buildTableData(List insuranceArchivesEmployeePOS); + + XSSFWorkbook export(InsuranceArchivesListParam param); + + /** + * 获取方案名称 + * + * @param schemeId 方案主键id + * @return string + */ + String querySchemeName(Long schemeId); + + List buildWeaTableColumns(List insuranceArchivesEmployeePOS, Long employeeId); + + Map preview(SIArchiveImportParam param); + + Map batchImportEbatch(SIArchiveImportParam param); + + XSSFWorkbook exportTemplate(InsuranceArchivesListParam param); + + Map checkSIArchiveAdd(SIArchiveImportParam param); + + Map addSIArchive(SIArchiveImportParam param); + + /** + * 编辑方案明细表数据 + * @param schemeDetailList + */ + List updateSchemeDetail(List schemeDetailList); + + List listAll(); +} diff --git a/src/com/engine/salary/service/SalaryAcctCalculateService.java b/src/com/engine/salary/service/SalaryAcctCalculateService.java new file mode 100644 index 000000000..64066e2c7 --- /dev/null +++ b/src/com/engine/salary/service/SalaryAcctCalculateService.java @@ -0,0 +1,25 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.salaryacct.bo.SalaryAcctCalculateBO; +import com.engine.salary.entity.salarysob.po.SalarySobBackItemPO; + +import java.util.List; + +/** + * 薪资核算-核算 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public interface SalaryAcctCalculateService { + + /** + * 薪资核算 + * + * @param salaryAcctCalculateBO + */ + void calculate(SalaryAcctCalculateBO salaryAcctCalculateBO, DataCollectionEmployee simpleEmploye, List salarySobBackItems); +} diff --git a/src/com/engine/salary/service/SalaryAcctEmployeeService.java b/src/com/engine/salary/service/SalaryAcctEmployeeService.java new file mode 100644 index 000000000..2d858a9ab --- /dev/null +++ b/src/com/engine/salary/service/SalaryAcctEmployeeService.java @@ -0,0 +1,273 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.salaryacct.dto.SalaryAcctEmployeeCountDTO; +import com.engine.salary.entity.salaryacct.param.*; +import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO; +import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO; +import com.engine.salary.report.entity.param.SalaryStatisticsReportDataQueryParam; +import com.engine.salary.util.page.PageInfo; + +import java.util.Collection; +import java.util.Date; +import java.util.List; +import java.util.Set; + +/** + * 薪资核算人员 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public interface SalaryAcctEmployeeService { + + /** + * 根据薪资核算记录id统计薪资核算人员的数量 + * + * @param salaryAcctRecordIds 薪资核算记录的id + * @return + */ + List countBySalaryAcctRecordId(Collection salaryAcctRecordIds); + + /** + * 根据主键id获取单个薪资核算人员 + * + * @param id 主键id + * @return + */ + SalaryAcctEmployeePO getById(Long id); + + /** + * 根据主键id查询薪资核算人员 + * + * @param ids 主键id + * @return + */ + List listByIds(Collection ids); + + /** + * 根据薪资核算记录id查询薪资核算人员 + * + * @param salaryAcctRecordId 薪资核算记录id + * @return + */ + List listBySalaryAcctRecordId(Long salaryAcctRecordId); + + /** + * 根据薪资核算记录id查询薪资核算人员 + * + * @param salaryAcctRecordIds 薪资核算记录id + * @return + */ + List listBySalaryAcctRecordIds(Collection salaryAcctRecordIds); + + /** + * 根据薪资核算记录id、个税扣缴义务人id查询薪资核算人员 + * + * @param salaryAcctRecordId 薪资核算记录id + * @param taxAgentId 个税扣缴义务人id + * @return + */ + List listBySalaryAcctRecordIdAndTaxAgentId(Long salaryAcctRecordId, Long taxAgentId); + + /** + * 根据薪资核算记录id、主键id查询薪资核算人员 + * + * @param salaryAcctRecordId 薪资核算记录id + * @param ids 主键id + * @return + */ + List listBySalaryAcctRecordIdAndIds(Long salaryAcctRecordId, Collection ids); + + /** + * 根据薪资核算记录id、人员id查询薪资核算人员 + * + * @param salaryAcctRecordId 薪资核算记录id + * @param employeeIds 人员id + * @return + */ + List listBySalaryAcctRecordIdAndEmployeeIds(Long salaryAcctRecordId, Collection employeeIds); + + /** + * 根据薪资核算记录id、人员id查询薪资核算人员 + * + * @param salaryAcctRecordIds 薪资核算记录id + * @param employeeIds 人员id + * @return + */ + List listBySalaryAcctRecordIdsAndEmployeeIds(Collection salaryAcctRecordIds, Collection employeeIds); + + /** + * 根据薪资核算记录id、人员id、个税扣缴义务人id查询薪资核算人员 + * + * @param salaryAcctRecordIds 薪资核算记录id + * @param employeeId 人员id + * @param taxAgentId 个税扣缴义务人 + * @return + */ + List listByRecordIdsAndEmpIdAndTaxAgentId(Collection salaryAcctRecordIds, Long employeeId, Long taxAgentId); + + /** + * 根据列表查询条件查询薪资核算人员(分页) + * + * @param queryParam 列表查询条件 + * @return + */ + PageInfo listPageByParam(SalaryAcctEmployeeQueryParam queryParam); + + /** + * 根据列表查询条件查询薪资核算人员 + * + * @param queryParam 列表查询条件 + * @return + */ + List listByParam(SalaryAcctEmployeeQueryParam queryParam); + + /** + * 根据薪资核算结果列表的列表查询条件查询薪资核算人员(分页) + * + * @param queryParam 薪资核算结果列表的列表查询条件 + * @return + */ + PageInfo listPageByResultQueryParam(SalaryAcctResultQueryParam queryParam); + + /** + * 根据薪资核算结果列表的列表查询条件查询薪资核算人员 + * + * @param queryParam 薪资核算结果列表的列表查询条件 + * @return + */ + List listByResultQueryParam(SalaryAcctResultQueryParam queryParam); + + /** + * 根据列表查询条件查询同比减少的薪资核算人员(分页) + * + * @param queryParam 列表查询条件 + * @return + */ + PageInfo listPageByParam4Reduce(SalaryAcctEmployeeQueryParam queryParam); + + /** + * 根据列表查询条件查询同比增加的薪资核算人员(分页) + * + * @param queryParam 列表查询条件 + * @return + */ + PageInfo listPageByParam4Add(SalaryAcctEmployeeQueryParam queryParam); + + /** + * 根据列表查询条件查询同比减少的薪资核算人员 + * + * @param queryParam 列表查询条件 + * @return + */ + List listByParam4Reduce(SalaryAcctEmployeeQueryParam queryParam); + + /** + * 根据列表查询条件查询同比增加的薪资核算人员 + * + * @param queryParam 列表查询条件 + * @return + */ + List listByParam4Add(SalaryAcctEmployeeQueryParam queryParam); + + /** + * 根据列表查询条件查询合并计税的薪资核算人员(分页) + * + * @param queryParam 列表查询条件 + * @return + */ + PageInfo listPageByParam4ConsolidatedTax(SalaryAcctEmployeeQueryParam queryParam); + + /** + * 根据列表查询条件查询合并计税的薪资核算人员 + * + * @param queryParam 列表查询条件 + * @return + */ + List listByParam4ConsolidatedTax(SalaryAcctEmployeeQueryParam queryParam); + + /** + * 添加薪资核算人员 + * + * @param saveParam 保存参数 + */ + void save(SalaryAcctEmployeeSaveParam saveParam); + + /** + * 从环比上月减少添加薪资核算人员 + * + * @param param + */ + void addFromReduce(SalaryAcctEmployeeAddParam param); + + /** + * 批量保存 + * + * @param salaryAcctEmployeePOS 薪资核算人员 + */ + void batchSave(Collection salaryAcctEmployeePOS); + + /** + * 薪资核算记录(会删除薪资核算结果、校验异常明细、线下对比导入结果) + * + * @param ids + */ + void deleteByIds(Collection ids); + + /** + * 根据参数删除薪资核算人员 + * + * @param deleteParam 删除参数 + */ + void deleteByParam(SalaryAcctEmployeeDeleteParam deleteParam); + + /** + * 根据薪资核算记录id删除薪资核算人员 + * + * @param salaryAcctRecordIds 薪资核算记录id + */ + void deleteBySalaryAcctRecordIds(Collection salaryAcctRecordIds); + + /** + * 根据薪资核算记录id初始化薪资核算人员 + * + * @param salaryAcctRecordPO 薪资核算记录 + */ + void initBySalaryAcctRecord(SalaryAcctRecordPO salaryAcctRecordPO); + + /** + * 刷新薪资核算人员的个税扣缴义务人 + * + * @param salaryAcctRecordId 薪资核算记录 + */ + void refresh(Long salaryAcctRecordId); + + + List listBySalaryStatisticsReportParam(SalaryStatisticsReportDataQueryParam param); + + /** + * 根据个税扣缴义务人和薪资所属月获取列表 + * + * @param taxAgentIds + * @param salaryMonths + * @return + */ + List listByTaxAgentAndSalaryMonth(List taxAgentIds, Set salaryMonths); + List listBySobAndSalaryMonth(List salarySobIds, Set salaryMonths); + + /** + * 锁定人员 + * @param updateParam + */ + void lockEmp(SalaryAcctResultUpdateLockStatusParam updateParam); + + /** + * 更新 + * @param salaryAcctEmployeePO + */ + void updateIgnoreNull(SalaryAcctEmployeePO salaryAcctEmployeePO); + + void lock(SalaryAcctEmployeePO salaryAcctEmployeePO); +} diff --git a/src/com/engine/salary/service/SalaryAcctExcelService.java b/src/com/engine/salary/service/SalaryAcctExcelService.java new file mode 100644 index 000000000..e23815ba3 --- /dev/null +++ b/src/com/engine/salary/service/SalaryAcctExcelService.java @@ -0,0 +1,164 @@ +package com.engine.salary.service; + +import com.engine.salary.component.WeaTableColumnGroup; +import com.engine.salary.entity.salaryacct.dto.SalaryAcctImportFieldDTO; +import com.engine.salary.entity.salaryacct.param.*; +import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO; +import com.engine.salary.util.excel.ExcelPreviewDTO; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import java.util.List; +import java.util.Map; + +/** + * 薪资核算导入导出 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public interface SalaryAcctExcelService { + + /** + * 薪资核算人员导出 + * + * @param queryParam + * @return + */ + XSSFWorkbook exportSalaryAcctEmployee(SalaryAcctEmployeeQueryParam queryParam); + + /** + * 薪资核算环比减少人员导出 + * + * @param queryParam + * @return + */ + XSSFWorkbook exportReducedEmployee(SalaryAcctEmployeeQueryParam queryParam); + + /** + * 薪资核算环比增加人员导出 + * + * @param queryParam + * @return + */ + XSSFWorkbook exportAddedEmployee(SalaryAcctEmployeeQueryParam queryParam); + + /** + * 薪资核算结果导出 + * + * @param queryParam + * @return + */ + XSSFWorkbook exportSalaryAcctResult(SalaryAcctResultQueryParam queryParam); + + /** + * 表头 + * @param salaryAcctRecordPO + * @return + */ + List listWeaTableColumn(SalaryAcctRecordPO salaryAcctRecordPO); + + /** + * 报表表头 + * @param salaryAcctRecordPO + * @return + */ + Map listColumn(SalaryAcctRecordPO salaryAcctRecordPO); + + /** + * 薪资核算导入时候薪资项目按取值方式分组 + * + * @param salaryAcctId + * @return + */ + SalaryAcctImportFieldDTO getImportField(Long salaryAcctId); + + /** + * 薪资核算导出时候薪资项目按取值方式分组 + * + * @param salaryAcctId + * @return + */ + SalaryAcctImportFieldDTO getExportField(Long salaryAcctId); + + /** + * 下载薪资核算导入模板 + * + * @param param + * @return + */ + XSSFWorkbook exportImportTemplate(SalaryAcctImportTemplateParam param); + + /** + * 薪资核算线下对比结果导出 + * + * @param queryParam + * @return + */ + XSSFWorkbook exportComparisonResult(SalaryComparisonResultQueryParam queryParam); + + /** + * 薪资核算线下对比结果导入模板导出 + * + * @param exportParam + * @return + */ + XSSFWorkbook exportComparisonResultTemplate(SalaryComparisonResultExportParam exportParam); + + + Map importSalaryAcctResult(SalaryAcctImportParam param); + + + Map importExcelAcctResult(SalaryAcctImportParam param); + + Map preview(SalaryAcctImportParam param); + + ExcelPreviewDTO previewImportSalaryAcctResult(SalaryAcctImportParam param); + + + void cacheImportField(SalaryAcctResultTemplateSaveParam param); + + void cacheExportField(List salaryItems); + + /** + * 保存导出模板 + * @param saveParam + */ + void saveExportTemplate(SalaryAcctResultTemplateSaveParam saveParam); + + /** + * 删除导出模板 + * @param templateIds + */ + void deleteExportTemplate(List templateIds); + + /** + * 获取导出模板详细信息 + * @param templateId + */ + Map getExportTemplateForm(Long templateId); + + /** + * 根据账套id获取导出模板列表 + * @param param + */ + Map exportTemplateList(SalaryAcctResultTemplateSaveParam param); + +// +// /** +// * 薪资核算结果校验异常导出 +// * +// * @param exportParam +// * @return +// */ +// XSSFWorkbook exportCheckResult(SalaryCheckResultExportParam exportParam); +// +// /** +// * 薪资核算结果校验异常明细导出 +// * +// * @param checkResultId +// * @return +// */ +// XSSFWorkbook exportCheckResultDetail(Long checkResultId); +} diff --git a/src/com/engine/salary/service/SalaryAcctRecordService.java b/src/com/engine/salary/service/SalaryAcctRecordService.java new file mode 100644 index 000000000..fcf00580b --- /dev/null +++ b/src/com/engine/salary/service/SalaryAcctRecordService.java @@ -0,0 +1,213 @@ +package com.engine.salary.service; + +import com.engine.salary.common.LocalDateRange; +import com.engine.salary.entity.salaryacct.param.SalaryAcctRecordQueryParam; +import com.engine.salary.entity.salaryacct.param.SalaryAcctRecordSaveParam; +import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO; +import com.engine.salary.entity.salaryacct.po.SalaryAcctResultPO; +import com.engine.salary.entity.salarysob.dto.SalarySobCycleDTO; +import com.engine.salary.enums.salaryaccounting.SalaryAcctRecordStatusEnum; +import com.engine.salary.util.page.PageInfo; + +import java.util.Collection; +import java.util.Date; +import java.util.List; +import java.util.Set; + +/** + * 薪资核算记录 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public interface SalaryAcctRecordService { + + /** + * 根据主键id获取单条薪资核算记录 + * + * @param id 主键id + * @return + */ + SalaryAcctRecordPO getById(Long id); + + List listAll(); + + /** + * 根据主键id查询薪资核算记录 + * + * @param ids 主键id + * @return + */ + List listByIds(Collection ids); + + /** + * 根据薪资账套id、薪资所属月查询薪资核算记录 + * + * @param salarySobIds 薪资账套id + * @param salaryMonthDateRange 薪资所属月的时间范围 + * @return + */ + List listBySalarySobIdsAndSalaryMonth(Collection salarySobIds, LocalDateRange salaryMonthDateRange); + + /** + * 根据薪资账套id、税款所属期查询薪资核算记录 + * + * @param salarySobIds 薪资账套id + * @param taxCycleDateRange 税款所属期的时间范围 + * @return + */ + List listBySalarySobIdsAndTaxCycle(Collection salarySobIds, LocalDateRange taxCycleDateRange); + + /** + * 根据薪资所属月查询薪资核算记录 + * + * @param salaryMonthDateRange 薪资所属月的时间范围 + * @return + */ + List listBySalaryMonth(LocalDateRange salaryMonthDateRange); + + /** + * 根据税款周期查询薪资核算记录 + * + * @param salaryMonthDateRange + * @return + */ + List listByTaxCycle(LocalDateRange salaryMonthDateRange,Collection salarySobIds); + + /** + * 根据列表查询条件查询薪资核算记录(分页) + * + * @param queryParam 列表查询条件 + * @return + */ + PageInfo listPageByParam(SalaryAcctRecordQueryParam queryParam); + + /** + * 根据id查询同一个账套上一个月的薪资核算记录 + * + * @param id 薪资核算记录id + * @return + */ + List listById4LastSalaryMonth(Long id); + + /** + * 根据薪资账套ID查询薪资核算记录 + * + * @param salarySobIds 薪资账套id + * @return + */ + List listBySalarySobIds(Collection salarySobIds); + + /** + * 根据id查询其他合并计税的薪资核算记录 + * + * @param id 薪资核算记录的id + * @return + */ + List listById4OtherConsolidatedTax(Long id); + + /** + * 薪资核算记录所用的薪资账套薪资周期、考勤周期…… + * + * @param id 薪资核算记录的id + * @return + */ + SalarySobCycleDTO getSalarySobCycleById(Long id); + + /** + * 保存 + * + * @param saveParam 保存参数 + * @return + */ + Long save(SalaryAcctRecordSaveParam saveParam); + + /** + * 更新薪资核算记录的状态 + * + * @param ids 主键id + * @param status 薪资核算记录的状态 + */ + void updateStatusByIds(Collection ids, SalaryAcctRecordStatusEnum status); + + /** + * 根据主键id删除 + * + * @param ids 薪资核算记录的id + */ + void deleteByIds(Collection ids); + + /** + * 归档 + * + * @param id 薪资核算记录的id + */ + void file(Long id); + + /** + * 重新核算(并不是重新执行公式,而是变更薪资核算记录状态为未归档,并且撤回生成的工资单) + * + * @param id 薪资核算记录的id + */ + void reCalculate(Long id); + + /** + * 判断是否存在合并计税 + * + * @param id 薪资核算记录的id + * @return 0:不存在、1:存在 + */ + Integer hasConsolidatedTax(Long id); + + /** + * 查询操作日志中的操作对象名称 + * + * @param id 薪资核算记录的id + * @return + */ + String getLogTargetNameById(Long id); + + /** + * 根据状态查询薪资核算记录 + * + * @param status + * @return + */ + List listByStatus(SalaryAcctRecordStatusEnum status); + + /** + * 根据核算人和核算状态查询核算记录 + * + * @param status + * @param employeeId + * @return + */ + List listByStatusAndEmployeeId(SalaryAcctRecordStatusEnum status, Long employeeId); + + void updateLockSalaryItemIds(SalaryAcctRecordPO salaryAcctRecord); + + /** + * @description 回算 + * @return void + * @author Harryxzy + * @date 2022/11/24 16:09 + */ + void backCalculate(Long salaryAcctRecordId); + + /** + * @description 获取是回算的薪资核算 + * @return List + * @author Harryxzy + * @date 2022/12/19 9:05 + */ + List getBackCalcRecordByIds(Set salaryAcctIds); + + List listBySalaryAcctEmpId(Long salaryAcctEmpId); + + + List listSome(SalaryAcctRecordPO po); + + void updateDate(Long id, Date updateTime); +} diff --git a/src/com/engine/salary/service/SalaryAcctReportService.java b/src/com/engine/salary/service/SalaryAcctReportService.java new file mode 100644 index 000000000..c4c1636db --- /dev/null +++ b/src/com/engine/salary/service/SalaryAcctReportService.java @@ -0,0 +1,42 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.report.po.SalaryAcctResultReportPO; + +import java.util.Collection; +import java.util.List; + +/** + * 薪资报表 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public interface SalaryAcctReportService { + + /** + * 保存核算记录报表数据 + * @param pos + */ + void batchSave(Collection pos); + + /** + * 根据核算记录删除 + * @param salaryAcctRecordIds + */ + void deleteBySalaryAcctRecordIds(Collection salaryAcctRecordIds); + + void deleteBySalaryAcctRecordId(Long salaryAcctRecordId); + + void deleteBySalaryAcctEmpIds(Collection salaryAcctEmpIds); + + /** + * 根据薪资核算人员id、薪资项目id删除薪资核算结果 + * + * @param salaryAcctEmployeeIds 薪资核算人员id + * @param salaryItemIds 薪资项目id + */ + void deleteByAcctEmployeeIdsAndSalaryItemIds(List salaryAcctEmployeeIds, Collection salaryItemIds); + +} diff --git a/src/com/engine/salary/service/SalaryAcctResultLogService.java b/src/com/engine/salary/service/SalaryAcctResultLogService.java new file mode 100644 index 000000000..81fb3f350 --- /dev/null +++ b/src/com/engine/salary/service/SalaryAcctResultLogService.java @@ -0,0 +1,72 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.salaryacct.po.SalaryAcctResultLogPO; + +import java.util.Collection; +import java.util.List; + +/** + * @author Harryxzy + * @date 2023/05/12 15:27 + * @description 薪资核算结果数据来源 + */ +public interface SalaryAcctResultLogService { + + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + SalaryAcctResultLogPO getById(Long id); + + + /** + * 新增,忽略null字段 + * + * @param salaryAcctResultLog 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(SalaryAcctResultLogPO salaryAcctResultLog); + + /** + * 修改,修改所有字段 + * + * @param salaryAcctResultLog 修改的记录 + * @return 返回影响行数 + */ + int update(SalaryAcctResultLogPO salaryAcctResultLog); + + /** + * 修改,忽略null字段 + * + * @param salaryAcctResultLog 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(SalaryAcctResultLogPO salaryAcctResultLog); + + /** + * 删除记录 + * + * @param salaryAcctResultLog 待删除的记录 + * @return 返回影响行数 + */ + int delete(SalaryAcctResultLogPO salaryAcctResultLog); + + void batchInsert(List salaryAcctResultLogList); + + /** + * 根据薪资核算人员删除数据,除了已经锁定的值 + * @param salaryAcctEmployeeIds + * @param lockSalaryItemIds + */ + void deleteBySalaryAcctEmpIdExceptItemIds(List salaryAcctEmployeeIds, Collection lockSalaryItemIds); +} diff --git a/src/com/engine/salary/service/SalaryAcctResultService.java b/src/com/engine/salary/service/SalaryAcctResultService.java new file mode 100644 index 000000000..ac7309950 --- /dev/null +++ b/src/com/engine/salary/service/SalaryAcctResultService.java @@ -0,0 +1,234 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.salaryacct.dto.ConsolidatedTaxDetailDTO; +import com.engine.salary.entity.salaryacct.dto.SalaryAcctResultDetailDTO; +import com.engine.salary.entity.salaryacct.dto.SalaryAcctResultListColumnDTO; +import com.engine.salary.entity.salaryacct.param.*; +import com.engine.salary.entity.salaryacct.po.SalaryAcctResultPO; +import com.engine.salary.util.page.PageInfo; + +import java.util.Collection; +import java.util.Date; +import java.util.List; +import java.util.Map; + +/** + * 薪资核算结果 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public interface SalaryAcctResultService { + + /** + * 根据薪资核算记录的id查询薪资核算结果 + * + * @param salaryAcctRecordIds 薪资核算记录的id + * @return + */ + List listBySalaryAcctRecordIds(Collection salaryAcctRecordIds); + + /** + * 根据薪资核算人员的主键id查询薪资核算结果 + * + * @param salaryAcctEmployeeId 薪资核算人员的主键id + * @return + */ + List listBySalaryAcctEmployeeId(Long salaryAcctEmployeeId); + + /** + * 根据薪资核算人员的主键id查询薪资核算结果 + * + * @param salaryAcctEmployeeIds 薪资核算人员的主键id + * @return + */ + List listBySalaryAcctEmployeeIds(Collection salaryAcctEmployeeIds); + + /** + * 根据薪资核算id、人员id查询薪资核算结果 + * + * @param salaryAcctRecordIds 薪资核算记录id + * @param employeeIds 人员id + * @return + */ + List listBySalaryAcctRecordIdsAndEmployeeIds(Collection salaryAcctRecordIds, Collection employeeIds); + + /** + * 根据薪资核算人员的主键id查询薪资核算结果 + * + * @param salaryAcctEmployeeId 薪资核算人员的主键id + * @return + */ + SalaryAcctResultDetailDTO getBySalaryAcctEmployeeId(Long salaryAcctEmployeeId); + + /** + * 根据薪资核算结果列表查询条件查询薪资核算结果(分页) + * + * @param queryParam 列表查询条件 + * @return + */ + PageInfo> listPageByParam(SalaryAcctResultQueryParam queryParam); + + /** + * 合计行 + * + * @param queryParam + * @return + */ + Map sumRow(SalaryAcctResultQueryParam queryParam); + + /** + * 根据薪资核算结果列表查询条件查询薪资核算结果 + * + * @param queryParam 列表查询条件 + * @return + */ + List> listByParam(SalaryAcctResultQueryParam queryParam); + + /** + * 获取合并计税详情 + * + * @param salaryAcctEmployeeId 薪资核算人员 + * @return + */ + ConsolidatedTaxDetailDTO getConsolidatedTaxDetail(Long salaryAcctEmployeeId); + + /** + * 根据薪资核算记录id获取表头数据 + * + * @param salaryAcctRecordId + * @return + */ + Map getColumnBySalaryAcctRecordId(Long salaryAcctRecordId); + + /** + * 保存 + * + * @param saveParam 保存参数 + */ + void save(SalaryAcctResultSaveParam saveParam); + + /** + * 批量保存 + * + * @param salaryAcctResultPOS 薪资核算结果 + */ + void batchSave(List salaryAcctResultPOS); + + /** + * 根据薪资核算人员id删除薪资核算结果 + * + * @param salaryAcctEmployeeIds 薪资核算人员id + */ + void deleteBySalaryAcctEmployeeIds(Collection salaryAcctEmployeeIds); + + + /** + * 根据薪资核算人员id、薪资项目id删除薪资核算结果 + * + * @param salaryAcctEmployeeIds 薪资核算人员id + * @param salaryItemIds 薪资项目id + */ + void deleteByAcctEmployeeIdsAndSalaryItemIds(List salaryAcctEmployeeIds, Collection salaryItemIds); + + /** + * 根据薪资核算记录id删除薪资核算结果 + * + * @param salaryAcctRecordIds 薪资核算记录id + */ + void deleteBySalaryAcctRecordIds(Collection salaryAcctRecordIds); + + /** + * 薪资核算 + * + * @param calculateParam + * @param simpleEmployee + */ + void calculate(SalaryAcctCalculateParam calculateParam, DataCollectionEmployee simpleEmployee); + + /** + * 根据薪资核算记录的id、个税扣缴义务人查询薪资核算结果 + * + * @param salaryAcctRecordIds 薪资核算记录的id + * @param taxAgentIds 个税扣缴义务人id + * @return + */ + List listBySalaryAcctRecordIdsAndTaxAgentIds(Collection salaryAcctRecordIds, Collection taxAgentIds); + + /** + * 锁定单元格 + * + * @param param + */ + void lock(SalaryAcctResultLockParam param); + + + /** + * 锁定项目 + * + * @param updateParam + */ + void updateLockStatusByParam(SalaryAcctResultUpdateLockStatusParam updateParam); + + /** + * 批量更新 + * + * @param salaryAcctResultValues + */ + void batchUpdateOriginResultValue(List salaryAcctResultValues); + + /** + * @return void + * @description 薪资回算 + * @author Harryxzy + * @date 2022/11/24 20:26 + */ + void reCalc(Long id); + + /** + * 根据薪资核算记录的id、薪资项目id查询薪资核算结果 + * + * @param salaryAcctRecordIds 薪资核算记录的id + * @param salaryItemIds 薪资项目id + * @return + */ + List listBySalaryAcctRecordIdsAndSalaryItemIds(Collection salaryAcctRecordIds, Collection salaryItemIds); + + /** + * @return List + * @description 根据薪资核算人员id、薪资项目id获取薪资核算结果 + * @author Harryxzy + * @date 2022/12/26 22:24 + */ + List listByAcctEmployeeIdsAndSalaryItemIds(List salaryAcctEmpIds, Collection salaryItemIds); + + List listAcctEmpIdByAcctEmpId(List salaryAcctEmployeeIds); + + /** + * 检查当前用户是否有查看权限 + * + * @param salaryAcctRecordId + * @return + */ + Boolean checkAuth(Long salaryAcctRecordId); + + /** + * 薪资核算结果批量更新 + * + * @param param + */ + void batchUpdate(SalaryAcctResultBatchUpdateParam param); + + /** + * 查询指定账套月份的数据 + *

Copyright: Copyright (c) 2024

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ + List listBySobSalaryMonth(Date salaryMonth, Long salarySobId, List employeeIds); +} diff --git a/src/com/engine/salary/service/SalaryAcctResultTempService.java b/src/com/engine/salary/service/SalaryAcctResultTempService.java new file mode 100644 index 000000000..75c8bdc87 --- /dev/null +++ b/src/com/engine/salary/service/SalaryAcctResultTempService.java @@ -0,0 +1,39 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.salaryacct.po.SalaryAcctResultTempPO; + +import java.util.Collection; +import java.util.List; + +/** + * 薪资核算结果临时存储 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public interface SalaryAcctResultTempService { + + /** + * 根据key获取薪资核算结果临时存储 + * + * @param calculateKey + * @return + */ + List listByCalculateKey(String calculateKey); + + /** + * 批量保存 + * + * @param salaryAcctResultTempPOS + */ + void batchSave(Collection salaryAcctResultTempPOS); + + /** + * 根据key删除薪资核算结果临时存储 + * + * @param calculateKey + */ + void deleteByCalculateKey(String calculateKey); +} diff --git a/src/com/engine/salary/service/SalaryAcctResultTemplateService.java b/src/com/engine/salary/service/SalaryAcctResultTemplateService.java new file mode 100644 index 000000000..a2b4c9c4a --- /dev/null +++ b/src/com/engine/salary/service/SalaryAcctResultTemplateService.java @@ -0,0 +1,79 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.salaryacct.po.SalaryAcctResultTemplatePO; + +import java.util.List; + +/** + * @author Harryxzy + * @ClassName SalaryAcctResultTemplateService + * @date 2024/03/26 15:28 + * @description + */ +public interface SalaryAcctResultTemplateService { + + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + SalaryAcctResultTemplatePO getById(Long id); + + /** + * 新增,忽略null字段 + * + * @param salaryAcctResultTemplate 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(SalaryAcctResultTemplatePO salaryAcctResultTemplate); + + /** + * 修改,修改所有字段 + * + * @param salaryAcctResultTemplate 修改的记录 + * @return 返回影响行数 + */ + int update(SalaryAcctResultTemplatePO salaryAcctResultTemplate); + + /** + * 修改,忽略null字段 + * + * @param salaryAcctResultTemplate 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(SalaryAcctResultTemplatePO salaryAcctResultTemplate); + + /** + * 删除记录 + * + * @param id 待删除的记录 + * @return 返回影响行数 + */ + int deleteById(Long id); + + + /** + * 删除记录 + * + * @param ids 待删除的记录 + * @return 返回影响行数 + */ + int deleteByIds(List ids); + + /** + * 根据账套id获取 + * @param salarySobId + * @return + */ + List listBySalarySobId(Long salarySobId,List types); +} diff --git a/src/com/engine/salary/service/SalaryAcctSobConfigService.java b/src/com/engine/salary/service/SalaryAcctSobConfigService.java new file mode 100644 index 000000000..43f64aa8b --- /dev/null +++ b/src/com/engine/salary/service/SalaryAcctSobConfigService.java @@ -0,0 +1,86 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.salaryacct.bo.SalaryAcctConfig; +import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO; +import com.engine.salary.entity.salaryacct.po.SalaryAcctSobConfigPO; +import com.engine.salary.entity.salarysob.dto.SalarySobItemAggregateDTO; + +import java.util.Collection; + +/** + * 薪资核算的账套副本配置 + *

Copyright: Copyright (c) 2024

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public interface SalaryAcctSobConfigService{ + + /** + * 根据薪资核算记录id查询薪资核算的账套配置 + * + * @param salaryAcctRecordId + * @return + */ + SalaryAcctSobConfigPO getBySalaryAcctRecordId(Long salaryAcctRecordId); + + /** + * 获取账套快照 + * @param salaryAcctRecordId + * @return + */ + SalaryAcctConfig getSalaryAcctConfig(Long salaryAcctRecordId); + + /** + * 根据薪资核算记录id查询薪资核算的账套配置 + * + * @param needInit 倘若当前薪资核算还没有保存账套配置,是否需要初始化一个,此处初始化不会入库 + * @param salaryAcctRecordId + * @return + */ + SalaryAcctSobConfigPO getBySalaryAcctRecordId(boolean needInit, Long salaryAcctRecordId); + + /** + * 薪资核算的账套配置转换成薪资账套的聚合对象 + * + * @param salaryAcctRecordId + * @return + */ + SalarySobItemAggregateDTO getSalarySobItemAggregate(Long salaryAcctRecordId); + + /** + * 薪资核算的账套配置转换成薪资账套的聚合对象 + * + * @param salaryAcctRecordId + * @return + */ + SalarySobItemAggregateDTO getSalarySobItemAggregateNoFormula(Long salaryAcctRecordId); + + /** + * 初始化薪资核算的账套配置 + * + * @param salaryAcctRecord + */ + SalaryAcctSobConfigPO initBySalaryAcctRecord(SalaryAcctRecordPO salaryAcctRecord); + + /** + * + * @param salaryAcctSobConfig + */ + void save(SalaryAcctSobConfigPO salaryAcctSobConfig); + + /** + * 更新薪资核算的账套配置 + * + * @param salaryAcctRecordId + */ + void updateBySalaryAcctRecordId(Long salaryAcctRecordId); + + /** + * 删除薪资核算的账套配置 + * + * @param salaryAcctRecordIds + */ + void deleteBySalaryAcctRecordIds(Collection salaryAcctRecordIds); +} diff --git a/src/com/engine/salary/service/SalaryApprovalRuleService.java b/src/com/engine/salary/service/SalaryApprovalRuleService.java new file mode 100644 index 000000000..21caa1c1d --- /dev/null +++ b/src/com/engine/salary/service/SalaryApprovalRuleService.java @@ -0,0 +1,117 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO; +import com.engine.salary.entity.salaryitem.param.SalaryItemSearchParam; +import com.engine.salary.entity.salaryitem.po.SalaryItemPO; +import com.engine.salary.entity.salarysob.dto.SalaryApprovalDTO; +import com.engine.salary.entity.salarysob.param.ApprovalRequestSaveParam; +import com.engine.salary.entity.salarysob.param.SalaryApprovalQueryParam; +import com.engine.salary.entity.salarysob.po.SalaryApprovalRulePO; + +import java.util.Collection; +import java.util.List; + +/** + * @author Harryxzy + * @ClassName SalaryApprovalRuleService + * @date 2024/04/23 17:33 + * @description 薪资核算审批规则 + */ +public interface SalaryApprovalRuleService { + + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + SalaryApprovalRulePO getById(Long id); + + + /** + * 新增,忽略null字段 + * + * @param salaryApprovalRule 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(SalaryApprovalRulePO salaryApprovalRule); + + /** + * 修改,修改所有字段 + * + * @param salaryApprovalRule 修改的记录 + * @return 返回影响行数 + */ + int update(SalaryApprovalRulePO salaryApprovalRule); + + /** + * 修改,忽略null字段 + * + * @param salaryApprovalRule 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(SalaryApprovalRulePO salaryApprovalRule); + + /** + * 删除记录 + * + * @param salaryApprovalRule 待删除的记录 + * @return 返回影响行数 + */ + int delete(SalaryApprovalRulePO salaryApprovalRule); + + /** + * 根据账套id查询审批设置 + * @param salarySobId + * @return + */ + SalaryApprovalRulePO getBySalarySobId(Long salarySobId); + + /** + * 根据薪资账套id删除 + * @param salarySobId + */ + void deleteBySalarySobId(Long salarySobId); + + /** + * 薪资账套的薪资审批规则 + * @param queryParam + * @return + */ + SalaryApprovalDTO salaryApprovalForm(SalaryApprovalQueryParam queryParam); + + /** + * 保存薪资账套的薪资审批规则 + * @param salaryApprovalDTO + */ + void saveSalaryApprovalForm(SalaryApprovalDTO salaryApprovalDTO); + + List listSalaryApprovalItem(SalaryItemSearchParam queryParam); + + SalaryApprovalDTO getApprovalInfoByRecordId(Long salaryAcctRecordId); + + /** + * 获取该核算记录是否可以编辑、核算 + * @param salaryAcctRecordPO + * @return + */ + boolean getRecordIsCanEdit(SalaryAcctRecordPO salaryAcctRecordPO); + + /** + * 保存审批流程id + * @param saveParam + */ + void saveApprovalRequestId(ApprovalRequestSaveParam saveParam); + + void deleteBySalarySobIds(Collection ids); + + List listBySalarySobIds(Collection salarySobIds); +} diff --git a/src/com/engine/salary/service/SalaryArchiveExcelService.java b/src/com/engine/salary/service/SalaryArchiveExcelService.java new file mode 100644 index 000000000..4ca31f91c --- /dev/null +++ b/src/com/engine/salary/service/SalaryArchiveExcelService.java @@ -0,0 +1,50 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.salaryarchive.param.SalaryArchiveImportActionParam; +import com.engine.salary.entity.salaryarchive.param.SalaryArchiveImportHandleParam; +import com.engine.salary.entity.salaryarchive.param.SalaryArchiveQueryParam; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import java.util.Map; + +/** + * 薪资档案-导入导出 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public interface SalaryArchiveExcelService { + + /** + * 导出薪资档案列表 + * + * @param map + * @param queryParam + * @param employeeId + * @param tenantKey + */ +// XSSFWorkbook exportList(Map map, SalaryArchiveQueryParam queryParam, Long employeeId, String tenantKey); + + /** + * 下载导入模板 + * + * @param queryParam + */ + XSSFWorkbook downloadTemplate(SalaryArchiveQueryParam queryParam); + + /** + * 导入 + * @param param + * @return + */ + Map batchImportEbatch(SalaryArchiveImportHandleParam param); + + /** + * 流程初始化档案 + * @param param + * @return + */ + Map processInit(SalaryArchiveImportActionParam param); +} diff --git a/src/com/engine/salary/service/SalaryArchiveItemService.java b/src/com/engine/salary/service/SalaryArchiveItemService.java new file mode 100644 index 000000000..6e22d49ba --- /dev/null +++ b/src/com/engine/salary/service/SalaryArchiveItemService.java @@ -0,0 +1,176 @@ +package com.engine.salary.service; + +import com.engine.salary.common.LocalDateRange; +import com.engine.salary.entity.salaryarchive.config.ArchiveFieldConfig; +import com.engine.salary.entity.salaryarchive.dto.SalaryItemAdjustRecordListDTO; +import com.engine.salary.entity.salaryarchive.param.SalaryArchiveItemSaveParam; +import com.engine.salary.entity.salaryarchive.param.SalaryItemAdjustBeforeParam; +import com.engine.salary.entity.salaryarchive.param.SalaryItemAdjustRecordQueryParam; +import com.engine.salary.entity.salaryarchive.po.SalaryArchiveItemPO; +import com.engine.salary.entity.salaryitem.po.SalaryItemPO; +import com.engine.salary.sys.entity.vo.UploadConfigResponse; +import com.engine.salary.util.page.PageInfo; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import java.util.Collection; +import java.util.List; +import java.util.Map; + +/** + * 薪资档案-薪资项目 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public interface SalaryArchiveItemService { + + /** + * 获取单个薪资档案项目调整记录 + * + * @param salaryArchiveItemId + * @return + */ + SalaryArchiveItemPO getById(Long salaryArchiveItemId); + + /** + * 获取可以调整的薪资项目 + */ + List getCanAdjustSalaryItems(); + + /** + * 获取薪资项目调整前的值 + * + * @param adjustBeforeParam + */ + String getSalaryItemAdjustBeforeValue(SalaryItemAdjustBeforeParam adjustBeforeParam); + + + /** + * @description 根据薪资档案id和薪资项id获取薪资项目(生效+不生效) + * @return List + * @author Harryxzy + * @date 2022/11/14 17:07 + */ + List getSalaryItemsBySalaryArchiveIdAndItemIds(Long salaryArchiveId, List salaryItemPageIds); + + /** + * 获取当前已生效 + * + * @param salaryArchiveId + * @param salaryItemPageIds + */ + List getEffectiveSalaryItems(Long salaryArchiveId, List salaryItemPageIds); + + /** + * 调薪前置校验 + * @param saveParam + * @return + */ + String checkSaveSalaryItem(SalaryArchiveItemSaveParam saveParam); + + /** + * 保存薪资项目调整 + * + * @param saveParam + * @return + */ + String saveSalaryItem(SalaryArchiveItemSaveParam saveParam); + + /** + * 删除薪资项目调整 + * + * @param salaryArchiveItemId + * @return + */ + String deleteSalaryItem(Long salaryArchiveItemId); + + /** + * 薪资调整记录列表(分页) + * + * @param queryParam + * @param salaryItemIds + * @return + */ + PageInfo salaryItemAdjustRecordListPage(SalaryItemAdjustRecordQueryParam queryParam, List salaryItemIds); + + /** + * 薪资调整记录列表 + * + * @param queryParam + * @param salaryItemIds + * @return + */ + List salaryItemAdjustRecordList(SalaryItemAdjustRecordQueryParam queryParam, List salaryItemIds); + + /** + * 导出薪资项目的调整记录列表 + * + * @param queryParam + */ + XSSFWorkbook exportAdjustRecordList(SalaryItemAdjustRecordQueryParam queryParam); + + + + /** + * 获取薪资档案对应的当前生效的薪资项目 + * + * @param salaryArchivesIds + * @return + */ + List getCurrentEffectiveItemList(Collection salaryArchivesIds, Collection salaryItemIds); + + + /** + * 获取薪资档案对应的当前生效的薪资项目忽略值 + * + * @param salaryArchivesIds + * @param salaryItemIds + * @return + */ + List getCurrentEffectiveItemListIngoreValue(Collection salaryArchivesIds, List salaryItemIds); + + /** + * 获取当前已生效 + * + * @param salaryArchiveIds + * @param isNoNeedSalaryItem + * @param salaryItemIds + * @return + */ + Map> getEffectiveItemListMap(Collection salaryArchiveIds, boolean isNoNeedSalaryItem, Collection salaryItemIds); + + /** + * 获取当前未生效 + * + * @param salaryArchiveIds + * @param isNoNeedSalaryItem + * @param salaryItemIds + * @return + */ + Map> getIneffectiveItemListMap(Collection salaryArchiveIds, boolean isNoNeedSalaryItem, Collection salaryItemIds); + + + /** + * @description 单个档案的薪资项目调整的编辑 + * @return String + * @author Harryxzy + * @date 2022/11/14 13:38 + */ + String editSingleSalaryItem(SalaryArchiveItemSaveParam salaryArchiveItemSaveParam); + + + ArchiveFieldConfig getConfig(); + + UploadConfigResponse.Result parseConfig(ArchiveFieldConfig config); + + /** + * 根据薪资档案id和生效日期范围获取数据 + * + * @param salaryArchiveIds + * @param dateRange + * @return + */ + List listByArchiveIdAndEffectiveTime(List salaryArchiveIds, LocalDateRange dateRange); +} diff --git a/src/com/engine/salary/service/SalaryArchiveService.java b/src/com/engine/salary/service/SalaryArchiveService.java new file mode 100644 index 000000000..e86655fd6 --- /dev/null +++ b/src/com/engine/salary/service/SalaryArchiveService.java @@ -0,0 +1,259 @@ +package com.engine.salary.service; + +import com.engine.salary.common.LocalDateRange; +import com.engine.salary.entity.salaryarchive.dto.SalaryArchiveDataDTO; +import com.engine.salary.entity.salaryarchive.dto.SalaryArchiveListDTO; +import com.engine.salary.entity.salaryarchive.param.*; +import com.engine.salary.entity.salaryarchive.po.SalaryArchiveDimissionPO; +import com.engine.salary.entity.salaryarchive.po.SalaryArchiveItemPO; +import com.engine.salary.entity.salaryarchive.po.SalaryArchivePO; +import com.engine.salary.entity.salaryarchive.po.SalaryArchiveTaxAgentPO; +import com.engine.salary.entity.salaryitem.po.SalaryItemPO; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import com.engine.salary.enums.salaryarchive.SalaryArchiveImportTypeEnum; +import com.engine.salary.util.page.PageInfo; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import java.util.Collection; +import java.util.List; +import java.util.Map; + +/** + * 薪资档案 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public interface SalaryArchiveService { + + /** + * 获取薪资档案单条主记录 + * + * @param salaryArchiveId + * @return + */ + SalaryArchivePO getById(Long salaryArchiveId); + + List getSalaryArchiveList (SalaryArchiveQueryParam queryParam); + + List listSome(SalaryArchivePO po); + + /** + * 薪资档案列表(分页) + * + * @param queryParam + * @return + */ + PageInfo listPage(SalaryArchiveQueryParam queryParam); + + List list(SalaryArchiveQueryParam queryParam); + + /** + * 构建薪资档案数据 + * + * @param salaryArchives + * @param taxAgentLists + * @param salaryItems + * @param isPage + * @return + */ + List> buildSalaryArchiveData(Collection salaryArchives, Collection taxAgentLists, List salaryItems, Boolean isPage); + + /** + * 获取薪资档案对应的当前生效的薪资项目 + * + * @param salaryArchivesIds + * @return + */ + List getCurrentEffectiveItemList(Collection salaryArchivesIds, Collection salaryItemIds); + + /** + * 获取薪资档案对应的当前生效的个税扣缴义务人 + * + * @param salaryArchivesIds + * @return + */ + List getCurrentEffectiveTaxAgentList(Collection salaryArchivesIds); + + /** + * 导出薪资档案列表 + * + * @param queryParam + * @throws Exception + */ + XSSFWorkbook exportList(SalaryArchiveQueryParam queryParam); + + + /** + * 保存发薪设置 + * + * @param saveParam + * @return + */ + String savePaySet(SalaryArchiveSetPaySaveParam saveParam); + + /** + * 获取离职时段设置 + */ + List dimissionSets(); + + /** + * 保存离职时段设置 + * + * @param saveParam + * @return + */ + String saveDimissionSet(SalaryArchiveDimissionSaveParam saveParam); + + /** + * 根据日期范围与人员id获取薪资档案-薪资项目数据 + * + * @param localDateRange + * @param employeeIds 为空则返回所有人的 + * @return + */ + List getSalaryArchiveData(LocalDateRange localDateRange, Collection employeeIds, List taxAgentIds); + + /** + * 根据日期范围与人员id获取薪资档案-个税扣缴义务人数据 + * + * @param localDateRange + * @param employeeIds 为空则返回所有人的 + * @return + */ + List getSalaryArchiveTaxAgentData(LocalDateRange localDateRange, Collection employeeIds, List taxAgentIds); + + /** + * 预览 + * @param param + * @return + */ + Map preview(SalaryArchiveImportHandleParam param); + + /** + * 查询薪酬档案所有列名 + * @return + */ + Map selectSalaryArchiveColumns(SalaryArchiveImportTypeEnum salaryArchiveImportTypeEnum); + + /** + * 停薪 + * @param stopSalaryParam + */ + void stopSalary(SalaryArchiveStopParam stopSalaryParam); + + /** + * 获取各tab总人数 + * + * @return + */ + Map queryTabTotal(); + + + /** + * 删除待定薪待办 + * + * @param ids + * @return + */ + String deletePendingTodo(Collection ids); + + /** + * 设为定薪员工 + * + * @param ids + * @return + */ + Map gotoFixed(Collection ids); + + /** + * 一键全部定薪 + * + * @param queryParam + * @return + */ + Map allGotoFixed(SalaryArchiveQueryParam queryParam); + +// /** +// * 删除待定薪待办 +// * +// * @param ids +// * @return +// */ +// String deletePendingTodo(Collection ids); + + /** + * 停薪 + * + * @param ids + * @return + */ + Map gotoStop(Collection ids); + + /** + * 一键全部停薪 + * + * @param queryParam + * @return + */ + Map allGotoStop(SalaryArchiveQueryParam queryParam); + + /** + * 删除待停薪待办 + * + * @param ids + * @return + */ + String deleteSuspendTodo(Collection ids); + + /** + * 取消停薪 + * + * @param ids + * @return + */ + String cancelStop(Collection ids); + + + /** + * 处理异常数据 + */ + Map handleRepeatData(); + + /** + * 处理增量数据 + * @param currentEmployeeId + */ + void handleChangeData(Long currentEmployeeId); + + /** + * 删除薪资档案 + * @param salaryArchiveIds + */ + void deleteSalaryArchive(Collection salaryArchiveIds); + + /** + * 根据人员id查询薪资档案 + * @param employeeIds + * @return + */ + List listPayEndDateIsNull(List employeeIds); + + List listByRunStatus(List asList); + + /** + * 同步所有档案起始发薪日期变为入职日期 + * + * @return + */ + String syncPayStartDate(); + + /** + * 根据列表状态获取起始发薪日期为空的薪资档案 + * @param runStatus + * @return + */ + List listPayStartDateIsNull(String runStatus); +} diff --git a/src/com/engine/salary/service/SalaryArchiveTaxAgentService.java b/src/com/engine/salary/service/SalaryArchiveTaxAgentService.java new file mode 100644 index 000000000..ef1b72a5e --- /dev/null +++ b/src/com/engine/salary/service/SalaryArchiveTaxAgentService.java @@ -0,0 +1,84 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.salaryarchive.dto.TaxAgentAdjustRecordListDTO; +import com.engine.salary.entity.salaryarchive.param.SalaryArchiveTaxAgentSaveParam; +import com.engine.salary.entity.salaryarchive.param.TaxAgentAdjustRecordQueryParam; +import com.engine.salary.entity.salaryarchive.po.SalaryArchiveTaxAgentPO; +import com.engine.salary.util.page.PageInfo; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import java.util.List; + +/** + * 薪资档案-个税扣缴义务人 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public interface SalaryArchiveTaxAgentService { + + /** + * 获取已经生效的个税扣缴义务人 + * + * @param salaryArchiveId + * @return + */ + SalaryArchiveTaxAgentPO getEffectiveTaxAgent(Long salaryArchiveId); + + /** + * 获取单个薪资档案个税扣缴义务人记录 + * + * @param salaryArchiveTaxAgentId + * @return + */ + SalaryArchiveTaxAgentPO getById(Long salaryArchiveTaxAgentId); + + /** + * 获取调整前的个税扣缴义务人 + * + * @param salaryArchiveTaxAgent + * @return + */ + SalaryArchiveTaxAgentPO getAdjustBeforeTaxAgent(SalaryArchiveTaxAgentPO salaryArchiveTaxAgent); + + /** + * 个税扣缴义务人的调整记录(分页) + * + * @param queryParam + * @return + */ + PageInfo taxAgentAdjustRecordListPage(TaxAgentAdjustRecordQueryParam queryParam); + + /** + * 个税扣缴义务人的调整记录 + * + * @param queryParam + * @return + */ + List taxAgentAdjustRecordList(TaxAgentAdjustRecordQueryParam queryParam); + + /** + * 保存个税扣缴义务人调整 + * + * @param saveParam + * @return + */ + String saveTaxAgent(SalaryArchiveTaxAgentSaveParam saveParam); + + /** + * 删除个税扣缴义务人调整 + * + * @param salaryArchiveTaxAgentId + * @return + */ + String deleteTaxAgent(Long salaryArchiveTaxAgentId); + + /** + * 导出-个税扣缴义务人的调整记录列表 + * + * @param queryParam + */ + XSSFWorkbook exportAdjustRecordList(TaxAgentAdjustRecordQueryParam queryParam); +} diff --git a/src/com/engine/salary/service/SalaryBillBaseSetService.java b/src/com/engine/salary/service/SalaryBillBaseSetService.java new file mode 100644 index 000000000..700a10770 --- /dev/null +++ b/src/com/engine/salary/service/SalaryBillBaseSetService.java @@ -0,0 +1,66 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.salaryBill.dto.SalaryBillAckFeedbackDTO; +import com.engine.salary.entity.salaryBill.dto.salaryBillViewingLimitSetting; +import com.engine.salary.entity.salaryBill.dto.SalaryBillWatermarkDTO; +import com.engine.salary.entity.salaryBill.param.SalaryBaseSetSaveParam; + +import java.util.Map; + +/** + * @Description: 工资单水印 + * @Author: Harryxzy + * @Date: 2023/06/09 10:14 + */ +public interface SalaryBillBaseSetService { + + /** + * 获取工资单水印设置 + * + * @return + */ + SalaryBillWatermarkDTO getWatermarkSetting(); + + /** + * 获取工资单确认和反馈设置 + * + * @param currentTenantKey + * @return + */ +// SalaryBillAckFeedbackDTO getAckFeedbackSetting(); + + /** + * 保存工资单模板基础设置 + * + * @param saveParam + * @return + */ + String saveBaseSet(SalaryBaseSetSaveParam saveParam); + + /** + * 预览水印 + * @param wmSetting 水印设置 + * @return + */ + String previewWaterMark(Map wmSetting); + + /** + * 获取默认工资单确认反馈设置 + * @return + */ + SalaryBillAckFeedbackDTO getDefaultAckFeedbackSetting(); + + /** + * 获取工资单失效限制 + * @return + */ + salaryBillViewingLimitSetting getSalaryBillViewingLimitSetting(); + + /** + * 获取首次查看后多少分钟不能查看工资单(0代表一旦查看后无法再次查看) + * @return + */ + Integer getBurningAfterReadingMin(); + + +} diff --git a/src/com/engine/salary/service/SalaryBillItemNameService.java b/src/com/engine/salary/service/SalaryBillItemNameService.java new file mode 100644 index 000000000..5399e47f1 --- /dev/null +++ b/src/com/engine/salary/service/SalaryBillItemNameService.java @@ -0,0 +1,100 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.salaryBill.param.SalaryBillItemNameSaveParam; +import com.engine.salary.entity.salaryBill.po.SalaryBillItemNamePO; + +import java.util.Collection; +import java.util.List; + +/** + * @author Harryxzy + * @ClassName SalaryBillItemNameService + * @date 2023/07/18 16:15 + * @description 工资单薪资项目展示名称 + */ +public interface SalaryBillItemNameService { + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + SalaryBillItemNamePO getById(Long id); + + /** + * 新增,忽略null字段 + * + * @param salaryBillItemNamePO 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(SalaryBillItemNamePO salaryBillItemNamePO); + + /** + * 修改,修改所有字段 + * + * @param salaryBillItemNamePO 修改的记录 + * @return 返回影响行数 + */ + int update(SalaryBillItemNamePO salaryBillItemNamePO); + + /** + * 修改,忽略null字段 + * + * @param salaryBillItemNamePO 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(SalaryBillItemNamePO salaryBillItemNamePO); + + /** + * 删除记录 + * + * @param id 待删除的记录id + * @return 返回影响行数 + */ + int delete(Long id); + + /** + * 根据工资单模板id和工资单类型获取 设置的项目名称信息 + * @param build + * @return + */ + List ListByTemplateAndType(SalaryBillItemNamePO build); + + /** + * 设置工资单薪资项目显示名 + * @param saveList + */ + void saveItemShowName(List saveList); + + /** + * 批量更新 + * @param needUpdateList + */ + void batchUpdate(List needUpdateList); + + /** + * 批量插入 + * @param needInsertList + */ + void batchInsert(List needInsertList); + + /** + * 根据id批量删除 + * @param needDeleteIds + */ + void deleteByIds(List needDeleteIds); + + /** + * 根据工资单模板id删除 + * @param ids + */ + void deleteByTemplateIds(Collection ids); +} diff --git a/src/com/engine/salary/service/SalaryBillService.java b/src/com/engine/salary/service/SalaryBillService.java new file mode 100644 index 000000000..755d98542 --- /dev/null +++ b/src/com/engine/salary/service/SalaryBillService.java @@ -0,0 +1,96 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.salaryBill.dto.SalaryBillSendDTO; +import com.engine.salary.entity.salaryBill.param.SalaryExportPdfParam; +import com.engine.salary.entity.salaryBill.param.SalarySendGrantParam; +import com.engine.salary.entity.salaryBill.po.SalarySendPO; +import com.engine.salary.entity.salaryBill.po.SalaryTemplatePO; + +import java.util.List; +import java.util.Map; + +/** + * 工资单 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public interface SalaryBillService { + + /** + * 工资单发放 + * + * @param queryParam + */ + Map grant(SalarySendGrantParam queryParam); + + Map reGenPdf(SalarySendGrantParam queryParam); + + + + /** + * 获取内容 + * @param sendId + * @param ids + * @return + */ + List> getSendInfoList(Long sendId, List ids); + + /** + * 确认工资单 + * @param salaryInfoId + */ + void confirmSalaryBill(Long salaryInfoId); + + /** + * 工资单反馈 + * @param salaryInfoId + */ + void feedBackSalaryBill(Long salaryInfoId); + + + String exportPdf(SalaryExportPdfParam param); + + String genPdfBeforeExport(SalaryExportPdfParam salaryExportPdfParam); + + /** + * 构建发放参数 + * @param salarySend + * @param salaryTemplate + * @return + */ + SalaryBillSendDTO buildSendParams(SalarySendPO salarySend, SalaryTemplatePO salaryTemplate); + + /** + * 工资单撤回 + * + * @param queryParam + * @param isRange + * @param rangeIds + * @param currentEmployeeId + * @param currentTenantKey + */ +// void withdraw(SalarySendWithdrawParam queryParam, boolean isRange, List rangeIds); + + /** + * 我的工资单 + * + * @param salaryInfoId + * @param currentEmployeeId + * @param currentTenantKey + * @return + */ +// Map mySalaryBill(Long salaryInfoId); + + /** + * 我的工资单列表详情 + * + * @param page + * @param queryParam + * @param tenantKey + * @return + */ +// Page mySalaryBillListPage(Page page, SalaryBillQueryParam queryParam, String tenantKey); +} diff --git a/src/com/engine/salary/service/SalaryBillWatermarkService.java b/src/com/engine/salary/service/SalaryBillWatermarkService.java new file mode 100644 index 000000000..39c31a988 --- /dev/null +++ b/src/com/engine/salary/service/SalaryBillWatermarkService.java @@ -0,0 +1,64 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.salaryBill.po.SalaryBillWatermarkPO; + +import java.util.List; + +/** + * @author Harryxzy + * @ClassName SalaryBillWatermarkService + * @date 2023/06/09 11:09 + * @description + */ +public interface SalaryBillWatermarkService { + + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + List listSome(SalaryBillWatermarkPO po); + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + SalaryBillWatermarkPO getById(Long id); + + + /** + * 新增,忽略null字段 + * + * @param SalaryBillWatermarkPO 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(SalaryBillWatermarkPO SalaryBillWatermarkPO); + + + /** + * 修改,忽略null字段 + * + * @param SalaryBillWatermarkPO 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(SalaryBillWatermarkPO SalaryBillWatermarkPO); + + /** + * 删除记录 + * + * @param SalaryBillWatermarkPO 待删除的记录 + * @return 返回影响行数 + */ + int delete(SalaryBillWatermarkPO SalaryBillWatermarkPO); + + /** + * 删除所有生效记录 + * + * @return 返回影响行数 + */ + void deleteAll(); +} diff --git a/src/com/engine/salary/service/SalaryCacheService.java b/src/com/engine/salary/service/SalaryCacheService.java new file mode 100644 index 000000000..2c01c1466 --- /dev/null +++ b/src/com/engine/salary/service/SalaryCacheService.java @@ -0,0 +1,69 @@ +package com.engine.salary.service; + +public interface SalaryCacheService { + + /** + * 添加缓存 + * + * @param key + * @param value + * @param + * @return + */ + void set(String key, T value); + + /** + * 添加缓存,有过期时间 + * + * @param key + * @param value + * @param time + * @return + */ + void set(String key, T value, int time); + + /** + * 将对象转为json字符串缓存 + * @param key + * @param value + * @param + */ + void setJson(String key, T value); + + /** + * 将对象转为json字符串缓存,有过期时间 + * @param key + * @param value + * @param time + * @param + */ + void setJson(String key, T value, int time); + + + /** + * 获取缓存 + * @param key + * @param + * @return + */ + T get(String key); + + + /** + * 获取缓存对象 + * @param key + * @param clazz + * @param + * @return + */ + T getJson(String key, Class clazz); + + /** + * 清除缓存 + * + * @param key + */ + void remove(String key); + + +} diff --git a/src/com/engine/salary/service/SalaryCheckResultDetailService.java b/src/com/engine/salary/service/SalaryCheckResultDetailService.java new file mode 100644 index 000000000..073f2c964 --- /dev/null +++ b/src/com/engine/salary/service/SalaryCheckResultDetailService.java @@ -0,0 +1,80 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.salaryacct.dto.SalaryCheckResultRecordCountDTO; +import com.engine.salary.entity.salaryacct.param.SalaryCheckResultRecordQueryParam; +import com.engine.salary.entity.salaryacct.po.SalaryCheckResultRecordPO; +import com.engine.salary.util.page.PageInfo; + +import java.util.Collection; +import java.util.List; + +/** + * 薪资核算结果校验异常明细 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public interface SalaryCheckResultDetailService { + + /** + * 统计薪资核算结果校验异常的明细数量 + * + * @param checkResultId 薪资核算结果的校验异常id + * @return + */ + List countByCheckResultId(Collection checkResultId); + + /** + * 根据校验异常id查询校验异常明细 + * + * @param checkResultId 校验异常id + * @return + */ + List listByCheckResultId(Long checkResultId); + + /** + * 根据薪资核算记录id查询校验异常明细 + * + * @param salaryAcctRecordId + * @return + */ + List listBySalaryAcctRecordId(Long salaryAcctRecordId); + + /** + * 根据列表查询条件查询校验异常明细(分页) + * + * @param queryParam 列表查询条件 + * @return + */ + PageInfo listPageByParam(SalaryCheckResultRecordQueryParam queryParam); + + /** + * 批量保存 + * + * @param salaryCheckResultRecordPOS + */ + void batchSave(Collection salaryCheckResultRecordPOS); + + /** + * 根据主键id删除校验异常明细 + * + * @param ids 主键id + */ + void deleteByIds(Collection ids); + + /** + * 根据薪资核算人员id删除薪资核算结果的校验异常明细 + * + * @param salaryAcctEmployeeIds 薪资核算人员id + */ + void deleteBySalaryAcctEmployeeIds(Collection salaryAcctEmployeeIds); + + /** + * 根据薪资核算记录id删除薪资核算结果的校验异常明细 + * + * @param salaryAcctRecordIds 薪资核算记录id + */ + void deleteBySalaryAcctRecordIds(Collection salaryAcctRecordIds); +} diff --git a/src/com/engine/salary/service/SalaryCheckResultService.java b/src/com/engine/salary/service/SalaryCheckResultService.java new file mode 100644 index 000000000..a018310c8 --- /dev/null +++ b/src/com/engine/salary/service/SalaryCheckResultService.java @@ -0,0 +1,106 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.salaryacct.param.SalaryAcctCheckParam; +import com.engine.salary.entity.salaryacct.param.SalaryCheckResultQueryParam; +import com.engine.salary.entity.salaryacct.po.SalaryCheckResultPO; +import com.engine.salary.util.page.PageInfo; + +import java.util.Collection; +import java.util.List; + +/** + * 校验异常 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public interface SalaryCheckResultService { + + /** + * 按照薪资核算记录id统计薪资核算结果的校验异常数量 + * + * @param salaryAcctRecordId 薪资核算记录id + * @return + */ + Integer countBySalaryAcctRecordId(Long salaryAcctRecordId); + + /** + * 根据主键id获取单个校验异常 + * + * @param id 主键id + * @return + */ + SalaryCheckResultPO getById(Long id); + + /** + * 根据薪资核算记录id查询校验异常 + * + * @param salaryAcctRecordId 薪资核算记录id + * @return + */ + List listBySalaryAcctRecordId(Long salaryAcctRecordId); + + /** + * 根据薪资核算记录id、是否忽略查询校验异常 + * + * @param salaryAcctRecordId 薪资核算记录id + * @param ignoreType 是否忽略 + * @return + */ + List listBySalaryAcctRecordIdAndIgnoreType(Long salaryAcctRecordId, Integer ignoreType); + + /** + * 根据列表查询条件查询校验异常 + * + * @param queryParam 列表查询条件 + * @return + */ + PageInfo listPageByParam(SalaryCheckResultQueryParam queryParam); + + /** + * 批量保存 + * + * @param salaryCheckResultPOS + */ + void batchSave(Collection salaryCheckResultPOS); + + /** + * 更新是否忽略 + * + * @param id 校验异常的主键id + */ + void updateIgnoreTypeById(Long id); + + /** + * 更新是否忽略 + * + * @param salaryAcctRecordId 薪资核算记录id + */ + void updateIgnoreTypeBySalaryAcctRecordId(Long salaryAcctRecordId); + + /** + * 根据主键id删除校验异常 + * + * @param ids 主键id + */ + void deleteByIds(Collection ids); + + /** + * 根据薪资核算记录id删除校验异常 + * + * @param salaryAcctRecordIds 薪资核算记录id + */ + void deleteBySalaryAcctRecordIds(Collection salaryAcctRecordIds); + + /** + * 薪资核算-校验 + * + * @param checkParam + * @param fromCalculate + * @param simpleEmployee + */ + void check(SalaryAcctCheckParam checkParam, boolean fromCalculate, DataCollectionEmployee simpleEmployee); +} diff --git a/src/com/engine/salary/service/SalaryComparisonResultService.java b/src/com/engine/salary/service/SalaryComparisonResultService.java new file mode 100644 index 000000000..0dd6ef22f --- /dev/null +++ b/src/com/engine/salary/service/SalaryComparisonResultService.java @@ -0,0 +1,72 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.salaryacct.dto.SalaryComparisonResultListDTO; +import com.engine.salary.entity.salaryacct.param.SalaryComparisonResultQueryParam; +import com.engine.salary.entity.salaryacct.po.ExcelAcctResultPO; + +import java.util.Collection; +import java.util.List; + +/** + * 薪资核算的线下对比结果 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public interface SalaryComparisonResultService { + + /** + * 根据薪资核算记录id查询线下对比结果 + * + * @param salaryAcctRecordId 薪资核算记录id + * @return + */ + List listBySalaryAcctRecordId(Long salaryAcctRecordId); + + /** + * 根据薪资核算人员id查询线下对比结果 + * + * @param salaryAcctEmployeeIds 薪资核算人员 + * @return + */ + List listBySalaryAcctEmployeeIds(Collection salaryAcctEmployeeIds); + + /** + * 根据列表查询条件查询线下对比结果(分页) + * + * @param queryParam 列表查询条件 + * @return + */ + SalaryComparisonResultListDTO listPageByParam(SalaryComparisonResultQueryParam queryParam); + + /** + * 根据列表查询条件查询线下对比结果 + * + * @param queryParam 列表查询条件 + * @return + */ + SalaryComparisonResultListDTO listByParam(SalaryComparisonResultQueryParam queryParam); + + /** + * 批量保存 + * + * @param excelAcctResultPOS + */ + void batchSave(Collection excelAcctResultPOS); + + /** + * 根据薪资核算人员id删除薪资核算线下对比结果 + * + * @param salaryAcctEmployeeIds 薪资核算人员id + */ + void deleteBySalaryAcctEmployeeIds(Collection salaryAcctEmployeeIds); + + /** + * 根据薪资核算记录id删除薪资核算线下对比结果 + * + * @param salaryAcctRecordIds 薪资核算记录id + */ + void deleteBySalaryAcctRecordIds(Collection salaryAcctRecordIds); +} diff --git a/src/com/engine/salary/service/SalaryEmployeeService.java b/src/com/engine/salary/service/SalaryEmployeeService.java new file mode 100644 index 000000000..50cd67190 --- /dev/null +++ b/src/com/engine/salary/service/SalaryEmployeeService.java @@ -0,0 +1,197 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.hrm.DeptInfo; +import com.engine.salary.entity.hrm.JobCallInfo; +import com.engine.salary.entity.hrm.PositionInfo; +import com.engine.salary.entity.hrm.SubCompanyInfo; +import com.engine.salary.entity.hrm.dto.EmployeeInfoExpandDTO; +import com.engine.salary.entity.salarysob.param.SalarySobRangeEmpQueryParam; +import com.engine.salary.enums.datacollection.UseEmployeeTypeEnum; + +import java.util.Date; +import java.util.List; +import java.util.Map; + +/** + * 人员信息 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public interface SalaryEmployeeService { + + /** + * 获取租户下的所有人员 + * + * @return + */ + List listAll(UseEmployeeTypeEnum empType); + + /** + * 获取报表人员字段 + * + * @return + */ + List listAllForReport(); + + /** + * 根据薪资账套id查询人员 + * + * @param salarySobId 薪资账套id + * @param hasExtEmp 是否含非系统人员 + * @return + */ + List listBySalarySobId(Long salarySobId, boolean hasExtEmp); + + /** + * 获取人员信息 + * + * @param ids + * @return 全量 + */ + List getEmployeeByIdsAll(List ids); + + List listByIds(List ids); + + /** + * 获取人员信息 + * + * @param employeeId + * @return 全量 + */ + DataCollectionEmployee getEmployeeById(Long employeeId); + + /** + * 获取人员信息 + * + * @param simpleEmployeeIds + * @return 简单 + */ + List getEmployeeByIds(List simpleEmployeeIds); + + /** + * 获取人员信息 包括次账号 + * + * @param simpleEmployeeIds + * @return 简单 + */ + List getEmployeeByIdsIncludeAccountType(List simpleEmployeeIds); + + /** + * 获取当前登录人的信息 + * @param employeeId + * @return + */ +// DataCollectionEmployee getLoginEmployeeById(Long employeeId); + + /** + * 筛选导入人员信息可以在人力资源池中匹配到的人员信息 + * + * @param confValue 校验方式 + * @param employeeList 人力资源池 + * @param userName 姓名 + * @param deparmentName 部门 + * @param mobile 手机号 + * @param workcode 工号 + * @param idNo 身份证号 + * @param uid 人员id + */ + List matchImportEmployee(String confValue, List employeeList, String userName, String deparmentName, String mobile, String workcode, String idNo, Long uid); + + String empValidType(); + + List getDeptInfoList(List departmentIds); + + DeptInfo getDeptInfoById(Long departmentId); + + List getVirtualDeptInfoList(List virtualDepartmentIds); + + List getSubCompanyInfoList(List subDepartmentIds); + + SubCompanyInfo getSubCompanyInfoById(Long subDepartmentId); + + List getVirtualSubCompanyInfoList(List virtualSubDepartmentIds); + + List listPositionInfo(List positionIds); + + PositionInfo getPositionInfoById(Long positionId); + + List listEmployee(); + + List listByParams(List includeQueryParams); + + /** + * 根据离职日期获取离职信息 + * + * @param formatDate + */ + Map getResignationMapByDate(String formatDate); + + /** + * 扩展人员信息 + * + * @param ids + * @param param + * @return + */ + List expandEmployeeInfo(List ids, EmployeeInfoExpandDTO param); + + Map> expandEmployeeMap(List ids, EmployeeInfoExpandDTO param); + + + /** + * 保存扩展信息 + * + * @param param + */ + void saveEmployeeExpandFieldSettings(EmployeeInfoExpandDTO param); + + /** + * 获取扩展信息 + * + * @param module + * @return + */ + EmployeeInfoExpandDTO getExpandFieldSettings(String module); + + /** + * 根据虚拟部门获取人员信息 + * + * @param virtualDepartmentIds + */ + List getVirtualEmpByVirtualDepIds(List virtualDepartmentIds); + + /** + * 根据虚拟分部获取人员信息 + * + * @param virtualSubCompanyIds + */ + List getVirtualEmpByVirtualSubCompanyIds(List virtualSubCompanyIds); + + /** + * 根据部门或者分部查询人员 + * + * @param subCompanyIds + * @param departmentIds + * @return + */ + List listBySubCompanyOrDepartment(List subCompanyIds, List departmentIds); + + List listBySubCompany(List subCompanyIds); + + List listByDepartment(List departmentIds); + + List listByJob(List jobIds); + + /** + * 根据职称id获取职称信息 + * @param jobCallId + * @return + */ + JobCallInfo getJobCallInfoById(Long jobCallId); + + List snapshot(List employeeIds, Date snapshotTime); +} diff --git a/src/com/engine/salary/service/SalaryFormulaService.java b/src/com/engine/salary/service/SalaryFormulaService.java new file mode 100644 index 000000000..60142fd05 --- /dev/null +++ b/src/com/engine/salary/service/SalaryFormulaService.java @@ -0,0 +1,68 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.salaryformula.ExpressFormula; +import com.engine.salary.entity.salaryformula.config.FormluaConfig; +import com.engine.salary.entity.salaryformula.param.SalaryFormulaMockParam; +import com.engine.salary.entity.salaryformula.param.SalaryFormulaSaveParam; +import com.engine.salary.entity.salaryformula.po.FormulaPO; +import com.engine.salary.entity.salaryformula.po.FormulaVar; + +import java.util.Collection; +import java.util.List; + +/** + * 薪酬管理公式编辑器 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public interface SalaryFormulaService { + + /** + * 根据公式id获取公式内容 + * + * @param formulaIds + * @return + */ + List listExpressFormula(Collection formulaIds); + + /** + * 根据公式id获取公式内容 + * + * @param formulaId + * @return + */ + ExpressFormula getExpressFormula(Long formulaId); + + FormulaPO save(SalaryFormulaSaveParam salaryFormulaSaveParam); + + + Object mock(SalaryFormulaMockParam param); + + /** + * 初始化函数 + */ + void initFunction(); + + void deleteNotIn(List formulaIds); + + List listVarByFormulaIds(List effectiveFormulaIds); + + List listByCode(String code); + + void updateVar(FormulaVar formulaVar); + + List listByIds(List formulaIds); + + List listAll(); + + List listAllVar(); + + void update(FormulaPO formulaPO); + + FormluaConfig getConfig(); + + Long add(FormulaPO formula); +} diff --git a/src/com/engine/salary/service/SalaryItemService.java b/src/com/engine/salary/service/SalaryItemService.java new file mode 100644 index 000000000..3fa1409d6 --- /dev/null +++ b/src/com/engine/salary/service/SalaryItemService.java @@ -0,0 +1,173 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.salaryitem.config.SalaryItemAllConfig; +import com.engine.salary.entity.salaryitem.config.SalaryItemExcelConfig; +import com.engine.salary.entity.salaryitem.param.*; +import com.engine.salary.entity.salaryitem.po.SalaryItemPO; +import com.engine.salary.enums.SalarySystemTypeEnum; +import com.engine.salary.service.impl.SalaryItemServiceImpl; +import com.engine.salary.sys.entity.vo.UploadConfigResponse; +import com.engine.salary.util.excel.ImportExcelResponse; +import com.engine.salary.util.page.PageInfo; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * 薪资项目 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public interface SalaryItemService { + + /** + * 根据主键id获取薪资项目 + * + * @param id 主键id + * @return + */ + SalaryItemPO getById(Long id); + + /** + * 查询所有薪资项目 + * + * @return + */ + List listAll(); + + /** + * 根据主键id获取薪资项目 + * + * @param ids 主键id + * @return + */ + List listByIds(Collection ids); + + /** + * 根据系统薪资项目的id查询薪资项目 + * + * @param sysSalaryItemIds 关联的系统薪资项目id + * @return + */ + List listBySysSalaryItemIds(Collection sysSalaryItemIds); + + /** + * 根据名称精确匹配获取薪资项目 + * + * @param name 薪资项目名称 + * @return + */ + List listByName(String name); + SalaryItemPO getByName(String name); + + + /** + * 根据(自定义薪资项目/系统薪资项目)查询薪资项目 + * + * @param systemType 自定义薪资项目/系统薪资项目 + * @return + */ + List listBySystemType(SalarySystemTypeEnum systemType); + + /** + * 根据(自定义薪资项目/系统薪资项目)、是否默认使用 查询薪资项目 + * + * @param systemType 自定义薪资项目/系统薪资项目 + * @param useDefault 是否默认使用 + * @return + */ + List listBySystemTypeAndUseDefault(SalarySystemTypeEnum systemType, Integer useDefault); + + /** + * 根据查询参数获取薪资项目(分页) + * + * @param searchParam 查询参数 + * @return + */ + List listByParam(SalaryItemSearchParam searchParam); + + List listByParamOrderById(SalaryItemSearchParam searchParam); + + PageInfo listPageByParam(SalaryItemSearchParam searchParam); + + + boolean filterInRange(Set userTaxAgentIds, SalaryItemPO po); + + /** + * 保存 + * + * @param saveParam 保存参数 + */ + SalaryItemPO save(SalaryItemSaveParam saveParam); + + /** + * 批量保存 + * + * @param salaryItemPOS 薪资项目 + */ + void batchSave(Collection salaryItemPOS); + + /** + * 更新 + * + * @param saveParam 更新参数 + */ + SalaryItemPO update(SalaryItemSaveParam saveParam); + + /** + * 根据主键id删除薪资项目 + * + * @param ids 主键id + */ + void deleteByIds(Collection ids); + + /** + * 获取使用中的项目情况 + * + * @return + */ + SalaryItemServiceImpl.UsingItem getUsingItem(); + + /** + * 批量保存薪资项目顺序 + * @param values + */ + void batchUpdateSortedIndex(List values); + + /** + * 获取薪资项目在哪些账套中使用 + * @param salaryItemId + * @return + */ + List> getSalarySobBySalaryItem(Long salaryItemId); + + /** + * 将薪资项目管理中的信息同步至账套 + * @param syncSalaryItemParam + */ + void syncSalaryItemToSalarySobItem(SyncSalaryItemParam syncSalaryItemParam); + + SalaryItemAllConfig getConfig(); + + UploadConfigResponse.Result parseConfig(SalaryItemAllConfig salaryItemConfig); + + SalaryItemPO getItem(SalaryItemPO salaryItemPO); + + List getConfig(SalaryItemExportParam param); + + + Map preview(SalaryItemImportParam param); + + ImportExcelResponse importSalaryItem(SalaryItemImportParam param); + + XSSFWorkbook export(SalaryItemExportParam param); + + XSSFWorkbook downloadTemplate(SalaryItemDownloadTemplateParam param); + +} diff --git a/src/com/engine/salary/service/SalarySQLService.java b/src/com/engine/salary/service/SalarySQLService.java new file mode 100644 index 000000000..285bf68b6 --- /dev/null +++ b/src/com/engine/salary/service/SalarySQLService.java @@ -0,0 +1,42 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.salaryformula.ExpressFormula; +import com.engine.salary.entity.salaryformula.param.SalaryFormulaSaveParam; +import com.engine.salary.entity.salaryformula.po.FormulaPO; +import com.engine.salary.entity.salarysql.ExpressSQL; + +import java.util.Collection; +import java.util.List; + +/** + * 薪酬管理SQL编辑器 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public interface SalarySQLService { + + /** + * 根据公式id获取公式内容 + * + * @param formulaIds + * @return + */ + List listExpressFormula(Collection formulaIds); + + /** + * 根据公式id获取公式内容 + * + * @param formulaId + * @return + */ + ExpressFormula getExpressFormula(Long formulaId); + + FormulaPO save(SalaryFormulaSaveParam salaryFormulaSaveParam); + + FormulaPO update(SalaryFormulaSaveParam salaryFormulaSaveParam); + + Object run(ExpressSQL expresssql); +} diff --git a/src/com/engine/salary/service/SalarySendRangeObjService.java b/src/com/engine/salary/service/SalarySendRangeObjService.java new file mode 100644 index 000000000..dd3d5355c --- /dev/null +++ b/src/com/engine/salary/service/SalarySendRangeObjService.java @@ -0,0 +1,42 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.salaryBill.po.SalarySendRangeObj; + +import java.util.Collection; +import java.util.List; + +/** + * @Description: 工资单发放撤回筛选范围对象 + * @Author: LFC + */ +public interface SalarySendRangeObjService { + + /** + * 根据名称和工资单发放id获取列表 + * + * @param salarySendId + * @param rangeIds + * @return + */ + List listBySalarySendIdAndRangeIds(Long salarySendId, List rangeIds); + + /** + * 根据工资饭发放id删除 + * + * @param salarySendIds + */ + void deleteBySalarySendIds(Collection salarySendIds); + + void replaceAllByRangeIds(Long rangeIds, List rangeObjs); + + /** + * 根据发放id和范围id获取发放信息id + * + * @param salarySendId + * @param rangeIds + * @return + */ + List getSendInfoIdsBySalarySendIdAndRangeIds(Long salarySendId, List rangeIds); + + void deleteBySalarySendRangeIds(List salarySendRangeIds); +} \ No newline at end of file diff --git a/src/com/engine/salary/service/SalarySendRangeService.java b/src/com/engine/salary/service/SalarySendRangeService.java new file mode 100644 index 000000000..22e891383 --- /dev/null +++ b/src/com/engine/salary/service/SalarySendRangeService.java @@ -0,0 +1,25 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.salaryBill.dto.SalarySendRangeListDTO; +import com.engine.salary.entity.salaryBill.param.SalarySendRangeQueryParam; +import com.engine.salary.entity.salaryBill.param.SalarySendRangeSaveParam; +import com.engine.salary.enums.salarysend.SalarySendGrantTypeEnum; +import com.engine.salary.util.page.PageInfo; + +import java.util.Collection; +import java.util.List; + +/** + * @Description: 工资单发放范围 + */ +public interface SalarySendRangeService { + void save(SalarySendRangeSaveParam param); + + PageInfo listPage(SalarySendRangeQueryParam queryParam); + + void deleteBySalarySendIds(Collection sendIds); + + void deleteByIds(List sendRangeIds); + + List getSendInfoIdsBySendId(Long sendId, List sendRangeIds, SalarySendGrantTypeEnum grantType); +} diff --git a/src/com/engine/salary/service/SalarySendService.java b/src/com/engine/salary/service/SalarySendService.java new file mode 100644 index 000000000..15747572a --- /dev/null +++ b/src/com/engine/salary/service/SalarySendService.java @@ -0,0 +1,229 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.salaryBill.dto.*; +import com.engine.salary.entity.salaryBill.param.*; +import com.engine.salary.entity.salaryBill.po.SalarySendInfoPO; +import com.engine.salary.entity.salaryBill.po.SalarySendPO; +import com.engine.salary.entity.salaryBill.po.SalaryTemplatePO; +import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO; +import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO; +import com.engine.salary.entity.salaryacct.po.SalaryAcctResultPO; +import com.engine.salary.util.page.PageInfo; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * @Description: 工资单发放 + */ +public interface SalarySendService { + + /** + * 获取单个工资单发放 + * + * @param salarySendId + * @return + */ + SalarySendPO getById(Long salarySendId); + + List findReAccountingIdsByAcctIds(List salaryAccountingIds, String tenantKey); + + /** + * 薪资核算-归档生成工资单 + * @param salaryAccountingId + * @return + */ + String generateSalaryBill(Long salaryAccountingId); + + /** + * 薪资核算-归档撤销工资单 + * @param salaryAcctRecord + * @return + */ + void revokeSalaryBill(SalaryAcctRecordPO salaryAcctRecord); + + /** + * 工资单发放列表(分页) + * + * @param queryParam + * @return + */ + PageInfo listPage(SalarySendQueryParam queryParam); + List list(SalarySendQueryParam queryParam); + + /** + * 工资单发放 + * @param queryParam + * @return + */ + Map grant(SalarySendGrantParam queryParam); + + /** + * 工资单撤回 + * @param queryParam + * @return + */ + Map withdraw(SalarySendWithdrawParam queryParam); + + /** + * 工资单发放基本信息 + * @param id + * @return + */ + SalarySendBaseInfoDTO getBaseInfo(Long id); + + /** + * 我的工资单 + * @param salaryInfoId + * @param currentEmployeeId + * @return + */ + Map mySalaryBill(Long salaryInfoId, Long currentEmployeeId); + + + /** + * 工资单发放信息列表(分页) + * @param queryParam + * @return + */ + PageInfo salarySendInfoListPage(SalarySendInfoQueryParam queryParam); + + List salarySendInfoList(Long salarySendId); + /** + * 我的工资单列表详情 + * + * @param queryParam + * @return + */ + PageInfo mySalaryBillListPage(SalaryBillQueryParam queryParam); + + /** + * 工资单发放详情列表 + * @param queryParam + * @return + */ + PageInfo salarySendInfoDetailListPage(SalarySendDetailQueryParam queryParam); + + /** + * 获取薪资项目设置 + * + * @param salaryTemplatePO + * @return + */ + List getSalaryItemsSetting(SalaryTemplatePO salaryTemplatePO, boolean isReplenish); + + /** + * 构建详情列表 + * + * @param salaryItems + * @param records + * @param salaryAccountingId + * @return + */ + List> buildDetailList(List salaryItems, List records, Long salaryAccountingId); + + /** + * 构建详情列表 + * + * @param records + * @param salaryAcctResultValues + * @return + */ + List> buildDetailList(List records,List salaryAcctEmployees, List salaryAcctResultValues); + + /** + * 导出-工资单发放详情列表 + * + * @param queryParam + */ + XSSFWorkbook exportInfoList(SalarySendInfoQueryParam queryParam); + + /** + * 导出-工资单发放详情列表 + * @param salarySend + * @param queryParam + */ + XSSFWorkbook exportDetailList(SalarySendPO salarySend, SalarySendDetailQueryParam queryParam); + + /** + * 获取核算工资单发放结果 + * + * @param salaryAcctRecordIds + * @return + */ + List getSalarySendCheckResult(Set salaryAcctRecordIds); + + /** + * @description 处理历史数据 + * @return null + * @author Harryxzy + * @date 2022/11/25 10:45 + */ + void handleHistory(); + + /** + * 合计行 + * + * @param queryParam + * @return + */ + Map sumRow(SalarySendInfoQueryParam queryParam); + + /** + * 根据薪资核算id删除 工资单 + * @param ids + */ + void deleteBySalaryAcctRecordIds(Collection ids); + + /** + * 发送短信验证码 + * @param param + */ + void sendMobileCode(SMSCodeSendParam param); + + /** + * 校验验证码 + * @param param + */ + Boolean checkMobileCode(SMSCodeCheckParam param); + + /** + * 获取工资单id下需要发放的工资单明细 + * @return + */ + List getNeedSendInfoList(List salarySendIds); + + /** + * 获取这些模板下未发放完的工资单 + * @param salarySobIds + * @return + */ + List getNeedSendListBySalarySobIds(List salarySobIds); + + /** + * 获取所有为确认的工资单 + * @return + * @return + */ + List listUnConfirmedSendInfo(List salarySobIds); + + /** + * 自动确认工资单 + * @param needAutoIds + */ + void autoConfirmSalaryBill(List needAutoIds); + + List getByIds(List salarySendId); + + List listSome(SalarySendPO param); + + /** + * 工资单预览 + * @param param + * @return + */ + Map preview(SalaryPreviewParam param); +} diff --git a/src/com/engine/salary/service/SalarySobAdjustRuleService.java b/src/com/engine/salary/service/SalarySobAdjustRuleService.java new file mode 100644 index 000000000..18c326ebb --- /dev/null +++ b/src/com/engine/salary/service/SalarySobAdjustRuleService.java @@ -0,0 +1,47 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.salarysob.param.SalarySobAdjustRuleSaveParam; +import com.engine.salary.entity.salarysob.po.SalarySobAdjustRulePO; + +import java.util.Collection; +import java.util.List; + +/** + * 调薪计薪规则 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public interface SalarySobAdjustRuleService { + + /** + * 根据薪资账套id查询薪资账套的调薪计薪规则 + * + * @param salarySobId 薪资账套id + * @return + */ + List listBySalarySobId(Long salarySobId); + + /** + * 保存调薪计薪酬规则 + * + * @param saveParam + */ + void save(SalarySobAdjustRuleSaveParam saveParam); + + /** + * 批量保存 + * + * @param salarySobAdjustRulePOS 薪资账套的调薪计薪规则 + */ + void batchSave(Collection salarySobAdjustRulePOS); + + /** + * 根据薪资账套id删除调薪计薪酬规则 + * + * @param salarySobIds 薪资账套id + */ + void deleteBySalarySobIds(Collection salarySobIds); +} diff --git a/src/com/engine/salary/service/SalarySobBackItemService.java b/src/com/engine/salary/service/SalarySobBackItemService.java new file mode 100644 index 000000000..b596f7684 --- /dev/null +++ b/src/com/engine/salary/service/SalarySobBackItemService.java @@ -0,0 +1,72 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.salarysob.dto.SalarySobBackItemDTO; +import com.engine.salary.entity.salarysob.param.SalarySobBackItemSaveParam; +import com.engine.salary.entity.salarysob.po.SalarySobBackItemPO; + +import java.util.Collection; +import java.util.List; + +/** + * @author Harryxzy + * @date 2022/11/15 16:18 + * @description 薪资账套的回算项目 + */ +public interface SalarySobBackItemService { + + /** + * @description 根据薪资账套id查询回算项目 + * @return List + * @author Harryxzy + * @date 2022/11/15 16:20 + */ + List listBySalarySobId(Long salarySobId); + + /** + * @description 查询所有回算项目 + * @return List + * @author Harryxzy + * @date 2022/11/18 11:31 + */ + List listAll(); + + void batchInsert(List needInsertSalarySobBackItems); + + /** + * @description 获取薪资回算项目 + * @return SalarySobBackItemPO + * @author Harryxzy + * @date 2022/11/16 14:36 + */ + SalarySobBackItemPO getById(Long salarySobBackItemId); + + /** + * @description 保存薪资账套的回算项目 + * @return List + * @author Harryxzy + * @date 2022/11/18 10:43 + */ + List save(SalarySobBackItemSaveParam saveParam); + + + /** + * @description 获取回算薪资项目数 + * @return Integer + * @author Harryxzy + * @date 2022/11/18 11:39 + */ + Long getCountBySalarySobIdIn(Collection salarySobIds); + + /** + * @description 根据薪资账套id删除回算薪资项目 + * @return int + * @author Harryxzy + * @date 2022/12/13 16:35 + */ + int deleteBySalarySobIds(Collection salarySobIds); + + List listBySalaryItemIds(Collection salaryItemIds); + + List getConfig(Long salarySobId); + +} diff --git a/src/com/engine/salary/service/SalarySobCheckRuleService.java b/src/com/engine/salary/service/SalarySobCheckRuleService.java new file mode 100644 index 000000000..4fa08511d --- /dev/null +++ b/src/com/engine/salary/service/SalarySobCheckRuleService.java @@ -0,0 +1,106 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.salarysob.param.SalarySobCheckRuleQueryParam; +import com.engine.salary.entity.salarysob.param.SalarySobCheckRuleSaveParam; +import com.engine.salary.entity.salarysob.param.UpdateCheckRuleFormulaParam; +import com.engine.salary.entity.salarysob.po.SalarySobCheckRulePO; +import com.engine.salary.util.page.PageInfo; + +import java.util.Collection; +import java.util.List; + +/** + * 薪资账套的校验规则 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public interface SalarySobCheckRuleService { + + /** + * 根据主键id获取单个薪资账套的校验规则 + * + * @param id 主键id + * @return + */ + SalarySobCheckRulePO getById(Long id); + + /** + * 根据主键id查询薪资账套的校验规则 + * + * @param ids 主键id + * @return + */ + List listByIds(Collection ids); + + /** + * 根据薪资账套id查询薪资账套的校验规则 + * + * @param salarySobId 薪资账套的id + * @return + */ + List listBySalarySobId(Long salarySobId); + + /** + * 根据薪资账套id、名称(精确匹配)查询薪资账套的校验规则 + * + * @param salarySobId 薪资账套的id + * @param name 名称 + * @return + */ + List listBySalarySobIdAndName(Long salarySobId, String name); + + /** + * 根据列表搜索条件查询薪资账套的校验规则(分页) + * + * @param queryParam 搜索条件 + * @return + */ + PageInfo listPageByParam(SalarySobCheckRuleQueryParam queryParam); + + /** + * 保存 + * + * @param saveParam 保存 + */ + void save(SalarySobCheckRuleSaveParam saveParam); + + /** + * 批量保存 + * + * @param salarySobCheckRulePOS 薪资账套的校验规则 + */ + void batchSave(Collection salarySobCheckRulePOS); + + /** + * 更新 + * + * @param updateParam 更新参数 + */ + void update(SalarySobCheckRuleSaveParam updateParam); + + /** + * 更新校验规则的公式 + * + * @param updateParam 更新参数 + */ + void updateFormulaId(UpdateCheckRuleFormulaParam updateParam); + + /** + * 根据主键id删除薪资账套的校验规则 + * + * @param ids 主键id + */ + void deleteByIds(Collection ids); + + /** + * 根据薪资账套id删除薪资账套的校验规则 + * + * @param salarySobIds 薪资账套id + */ + void deleteBySalarySobIds(Collection salarySobIds); + + +} diff --git a/src/com/engine/salary/service/SalarySobDefaultEmpFieldService.java b/src/com/engine/salary/service/SalarySobDefaultEmpFieldService.java new file mode 100644 index 000000000..a221b9f3c --- /dev/null +++ b/src/com/engine/salary/service/SalarySobDefaultEmpFieldService.java @@ -0,0 +1,18 @@ +package com.engine.salary.service; + +/** + * @description: 薪资账套默认的员工信息字段 + * @author: xiajun + * @modified By: xiajun + * @date: Created in 1/13/22 9:52 AM + * @version:v1.0 + */ +public interface SalarySobDefaultEmpFieldService { + +// /** +// * 获取所有的薪资账套默认的员工信息字段 +// * +// * @return +// */ +// List list(); +} diff --git a/src/com/engine/salary/service/SalarySobDefaultItemService.java b/src/com/engine/salary/service/SalarySobDefaultItemService.java new file mode 100644 index 000000000..aceec3263 --- /dev/null +++ b/src/com/engine/salary/service/SalarySobDefaultItemService.java @@ -0,0 +1,24 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.salarysob.po.SalarySobDefaultItemPO; +import com.engine.salary.enums.salarysob.IncomeCategoryEnum; + +import java.util.List; + +/** + * 薪资账套默认的薪资项目 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public interface SalarySobDefaultItemService { + + /** + * 根据薪资类型查询默认的薪资项目 + * + * @return + */ + List listByIncomeCategory(IncomeCategoryEnum incomeCategory); +} diff --git a/src/com/engine/salary/service/SalarySobEmpFieldService.java b/src/com/engine/salary/service/SalarySobEmpFieldService.java new file mode 100644 index 000000000..c74b45b4c --- /dev/null +++ b/src/com/engine/salary/service/SalarySobEmpFieldService.java @@ -0,0 +1,41 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.salarysob.po.SalarySobEmpFieldPO; + +import java.util.Collection; +import java.util.List; + +/** + * 薪资账套的员工信息字段 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public interface SalarySobEmpFieldService { + + /** + * 根据薪资账套id查询薪资账套的员工信息字段 + * + * @param salarySobId 薪资账套id + * @return + */ + List listBySalarySobId(Long salarySobId); + + /** + * 批量保存 + * + * @param salarySobEmpFieldPOS 薪资账套的员工信息字段 + */ + void batchSave(Collection salarySobEmpFieldPOS); + + /** + * 根据薪资账套的id删除薪资账套的员工信息字段 + * + * @param salarySobIds 薪资账套id + */ + void deleteBySalarySobIds(Collection salarySobIds); + + void deleteByIds(Collection ids); +} diff --git a/src/com/engine/salary/service/SalarySobExtRangeService.java b/src/com/engine/salary/service/SalarySobExtRangeService.java new file mode 100644 index 000000000..0fd6d5bb1 --- /dev/null +++ b/src/com/engine/salary/service/SalarySobExtRangeService.java @@ -0,0 +1,54 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.SalarySobExtRangePO; +import com.engine.salary.entity.salarysob.param.SalarySobRangeExtSaveParam; +import com.engine.salary.entity.salarysob.param.SalarySobRangeQueryParam; +import com.engine.salary.util.page.PageInfo; + +import java.util.Collection; +import java.util.List; + +/** + * 薪资账套人员范围 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public interface SalarySobExtRangeService { + + /** + * 根据主键id查询薪资账套的人员范围 + * + * @param ids 薪资账套的人员范围的主键id + * @return + */ + List listByIds(Collection ids); + + /** + * 根据薪资账套ID和类型查询薪资账套的人员范围 + * + * @param salarySobId 薪资账套id + * @return + */ + List listBySalarySobId(Long salarySobId); + + + /** + * 保存外部人员 + * @param saveParam + */ + void saveExtRange(SalarySobRangeExtSaveParam saveParam); + + /** + * 外部人员列表 + * @param param + * @return + */ + PageInfo listPage4Ext(SalarySobRangeQueryParam param); + + + void deleteSalarySobExtRange(Collection ids); + +} diff --git a/src/com/engine/salary/service/SalarySobItemGroupService.java b/src/com/engine/salary/service/SalarySobItemGroupService.java new file mode 100644 index 000000000..ca689d9ef --- /dev/null +++ b/src/com/engine/salary/service/SalarySobItemGroupService.java @@ -0,0 +1,49 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.salarysob.po.SalarySobItemGroupPO; + +import java.util.Collection; +import java.util.List; + +/** + * 薪资账套的薪资项目分类 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public interface SalarySobItemGroupService { + + /** + * 根据主键id获取单个薪资账套的薪资项目分类 + * + * @param id 薪资账套的薪资项目分类的主键id + * @return + */ + SalarySobItemGroupPO getById(Long id); + + /** + * 根据薪资账套id查询薪资账套的薪资项目分类 + * + * @param salarySobId 薪资账套id + * @return + */ + List listBySalarySobId(Long salarySobId); + + /** + * 批量保存 + * + * @param salarySobItemGroupPOS 薪资账套的薪资项目分类po集合 + */ + void batchSave(Collection salarySobItemGroupPOS); + + /** + * 根据薪资账套id删除薪资账套的薪资项目分类 + * + * @param salarySobIds 薪资账套id + */ + void deleteBySalarySobIds(Collection salarySobIds); + + List getConfig(Long salarySobId); +} diff --git a/src/com/engine/salary/service/SalarySobItemHideService.java b/src/com/engine/salary/service/SalarySobItemHideService.java new file mode 100644 index 000000000..2e91facd9 --- /dev/null +++ b/src/com/engine/salary/service/SalarySobItemHideService.java @@ -0,0 +1,27 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.salarysob.po.SalarySobItemHidePO; + +import java.util.List; + +@Deprecated +public interface SalarySobItemHideService { + + /** + * 根据薪资账套id查询哪些字段关闭显示 + * + * @param salarySobId + * @return + */ + List listHideGroupBysalarySobId(SalarySobItemHidePO salarySobId); + + /** + * 根据薪资账套id查询哪些字段关闭显示 + * + * @param po + * @return + */ + List listSome(SalarySobItemHidePO po); + + void updateById(SalarySobItemHidePO salarySobItemHidePO); +} diff --git a/src/com/engine/salary/service/SalarySobItemService.java b/src/com/engine/salary/service/SalarySobItemService.java new file mode 100644 index 000000000..af509a042 --- /dev/null +++ b/src/com/engine/salary/service/SalarySobItemService.java @@ -0,0 +1,131 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.salaryitem.po.SalaryItemPO; +import com.engine.salary.entity.salarysob.dto.SalarySobItemAggregateDTO; +import com.engine.salary.entity.salarysob.dto.SalarySobItemFormDTO; +import com.engine.salary.entity.salarysob.param.SalarySobItemSaveParam; +import com.engine.salary.entity.salarysob.po.SalarySobItemPO; + +import java.util.Collection; +import java.util.List; + +/** + * @description: 薪资账套的薪资项目副本 + * @author: xiajun + * @modified By: xiajun + * @date: Created in 1/17/22 7:26 PM + * @version:v1.0 + */ +public interface SalarySobItemService { + + /** + * 查询所有薪资账套的薪资项目副本 + * + * @return + */ + List list(); + + /** + * 根据薪资账套id查询薪资账套的薪资项目副本 + * + * @param salarySobId 薪资账套的id + * @return + */ + List listBySalarySobId(Long salarySobId); + + /** + * 根据薪资账套id和薪资项目分类查询薪资账套的薪资项目副本 + * + */ + List listBySalarySobIdAndGroupId(Long salarySobId,Collection salarySobItemGroupIds); + + /** + * 根据薪资账套id查询薪资账套的薪资项目副本 + * + * @param salarySobIds 薪资账套的id + * @return + */ + List listBySalarySobIds(Collection salarySobIds); + + /** + * 根据薪资账套id、薪资项目id查询薪资账套的薪资项目副本 + * + * @param salarySobId 薪资账套id + * @param salaryItemIds 薪资项目id + * @return + */ + List listBySalarySobIdAndSalaryItemIdNotIn(Long salarySobId, Collection salaryItemIds); + + /** + * 根据薪资项目id查询薪资账套的薪资项目副本 + * + * @param salaryItemIds 薪资项目的主键id + * @return + */ + List listBySalaryItemIds(Collection salaryItemIds); + + /** + * 根据薪资账套id查询薪资账套的薪资项目副本所关联的薪资项目 + * + * @param salarySobId 薪资账套id + * @return + */ + List listBySalarySobId4SalaryItem(Long salarySobId); + + /** + * 根据薪资账套id获取薪资账套的薪资项目聚合(员工信息、薪资项目副本、薪资项目分类) + * + * @param salarySobId + * @return + */ + SalarySobItemAggregateDTO getAggregateBySalarySobId(Long salarySobId); + + /** + * 根据薪资核算id获取薪资账套的薪资项目聚合(员工信息、薪资项目副本、薪资项目分类) + * @param salaryAcctRecordId 核算记录id + * @param hideItem true过滤隐藏项目。false显示隐藏项目 + * @return + */ + SalarySobItemAggregateDTO getAggregateByRecordId(Long salaryAcctRecordId, boolean hideItem); + + /** + * 根据薪资账套id获取薪资账套的薪资项目聚合(员工信息、薪资项目副本、薪资项目分类)(不包含已设置为隐藏的) + * @return + */ + SalarySobItemAggregateDTO getAggregateWithItemHideBySalarySobId(Long salaryAcctRecordId,Long salarySobId, boolean isBackCalc); + + /** + * 保存 + * + * @param saveParam 保存参数 + */ + void save(SalarySobItemSaveParam saveParam); + + /** + * 批量保存 + * + * @param salarySobItemPOS 薪资账套的薪资项目副本 + */ + void batchSave(Collection salarySobItemPOS); + + /** + * 根据薪资账套id删除薪资账套的薪资项目副本 + * + */ + void deleteBySalarySobIds(Collection salarySobIds); + + /** + * 根据薪资账套id删除薪资项目是否显示 + * + */ + void deleteItemShowBySalarySobIds(Collection salarySobIds); + + /** + * 薪资项目的详情 + */ + SalarySobItemFormDTO getSalaryItemForm(SalarySobItemPO param); + + void update(SalarySobItemPO po); + + List getConfig(Long salarySobId); +} diff --git a/src/com/engine/salary/service/SalarySobRangeService.java b/src/com/engine/salary/service/SalarySobRangeService.java new file mode 100644 index 000000000..bf1f2848e --- /dev/null +++ b/src/com/engine/salary/service/SalarySobRangeService.java @@ -0,0 +1,110 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.salarysob.dto.SalarySobRangeListDTO; +import com.engine.salary.entity.salarysob.param.SalarySobRangeImportParam; +import com.engine.salary.entity.salarysob.param.SalarySobRangeQueryParam; +import com.engine.salary.entity.salarysob.param.SalarySobRangeSaveParam; +import com.engine.salary.entity.salarysob.po.SalarySobRangePO; +import com.engine.salary.util.page.PageInfo; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import java.util.Collection; +import java.util.List; +import java.util.Map; + +/** + * 薪资账套人员范围 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public interface SalarySobRangeService { + + /** + * 根据主键id查询薪资账套的人员范围 + * + * @param ids 薪资账套的人员范围的主键id + * @return + */ + List listByIds(Collection ids); + + /** + * 根据薪资账套ID和类型查询薪资账套的人员范围 + * + * @param salarySobId 薪资账套id + * @param includeType 0-从范围中排除/1-关联人员范围 + * @return + */ + List listBySalarySobIdAndIncludeType(Long salarySobId, Integer includeType); + + /*** + * @description 获取所有的薪资账套的人员范围 + * @return List + * @author Harryxzy + * @date 2022/10/8 16:12 + */ + List listAllSalarySobRange(); + + /** + * 根据查询条件查询薪资账套的人员范围 + * + * @param queryParam 查询条件 + * @param includeType 0-从范围中排除/1-关联人员范围 + * @return + */ + PageInfo listPageByParamAndIncludeType(SalarySobRangeQueryParam queryParam, Integer includeType); + + /** + * 保存 + * + * @param saveParam 保存参数 + */ + void save(SalarySobRangeSaveParam saveParam); + void edit(SalarySobRangeSaveParam param); + + /** + * 根据主键id删除薪资账套的人员范围 + * + * @param ids 主键id + */ + void deleteByIds(Collection ids); + + /** + * 根据薪资账套id删除薪资账套的人员范围 + * + * @param salarySobIds 薪资账套id + */ + void deleteBySalarySobIds(Collection salarySobIds); + + /** + * 更新人员状态从status中存到statuses中 + * @param item + */ + void updateEmployeeStatuses(SalarySobRangePO item); + + /*** + * @description 下载人员范围导入模板 + * @return XSSFWorkbook + * @author Harryxzy + * @date 2023/1/9 11:34 + */ + XSSFWorkbook downloadTemplateRange(); + + /*** + * @description 人员范围导入预览 + * @return Map + * @author Harryxzy + * @date 2023/1/9 13:39 + */ + Map preview(SalarySobRangeImportParam importParam); + + /** + * @description 导入薪资账套人员范围 + * @return Map + * @author Harryxzy + * @date 2023/1/9 14:10 + */ + Map importData(SalarySobRangeImportParam importParam); +} diff --git a/src/com/engine/salary/service/SalarySobService.java b/src/com/engine/salary/service/SalarySobService.java new file mode 100644 index 000000000..7d0596097 --- /dev/null +++ b/src/com/engine/salary/service/SalarySobService.java @@ -0,0 +1,158 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.salarysob.config.SalarySobConfig; +import com.engine.salary.entity.salarysob.dto.SalarySobCycleDTO; +import com.engine.salary.entity.salarysob.param.*; +import com.engine.salary.entity.salarysob.po.SalarySobPO; +import com.engine.salary.enums.salarysob.IncomeCategoryEnum; +import com.engine.salary.sys.entity.vo.UploadConfigResponse; +import com.engine.salary.util.page.PageInfo; + +import java.time.YearMonth; +import java.util.Collection; +import java.util.List; + +/** + * 薪资账套 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public interface SalarySobService { + + /** + * 根据主键id获取单个薪资账套 + * + * @param id 主键id + * @return + */ + SalarySobPO getById(Long id); + + /** + * 根据主键id查询薪资账套 + * + * @param ids 主键id + * @return + */ + List listByIds(Collection ids); + + /** + * 根据名称精确匹配查询薪资账套 + * + * @param name 薪资账套名称 + * @return + */ + List listByName(String name); + + /** + * 根据名称(模糊匹配)查询薪资账套 + * + * @param nameLike 薪资账套名称 + * @return + */ + List listByNameLike(String nameLike); + + /** + * 查询启用/禁用的薪资账套 + * + * @param disable 启用/禁用 + * @return + */ + List listByDisable(Integer disable); + + List listAll(); + + List listAuth(SalarySobQueryParam param); + + /** + * 获取拥有管理权限的账套 + * @return + */ + List listByAdmin(); + + List listByTaxAgentId(Long taxAgentId); + + /** + * 根据薪资类型查询薪资账套 + * + * @param incomeCategory 薪资类型 + * @return + */ + List listByIncomeCategory(IncomeCategoryEnum incomeCategory); + + /** + * 根据列表查询参数查询薪资账套(分页) + * + * @param queryParam 列表查询参数 + * @return + */ + PageInfo listPageByParam(SalarySobListQueryParam queryParam); + + List listByParam(SalarySobListQueryParam queryParam); + + /** + * 保存 + * + * @param saveParam 保存参数 + * @return + */ + Long save(SalarySobBasicSaveParam saveParam); + + void saveDefaultEmployeeRange(SalarySobPO salarySobPO); + + /** + * 编辑 + * + * @param saveParam 更新参数 + * @return + */ + Long update(SalarySobBasicSaveParam saveParam); + + /** + * 更新薪资账套的是否启用 + * + * @param disableParam 更新参数 + */ + void updateDisable(SalarySobDisableParam disableParam); + + /** + * 根据主键id删除 + * + * @param ids 薪资账套的主键id + */ + void deleteByIds(Collection ids); + + /** + * 复制 + * + * @param duplicateParam 复制参数 + */ + void duplicate(SalarySobDuplicateParam duplicateParam); + + /** + * 根据薪资所属月计算出薪资账套的薪资周期、考勤周期的具体日期范围以及税款所属期、福利台账月份的具体月份 + * + * @param id 薪资账套的id + * @param salaryMonth 薪资所属月 + * @return + */ + SalarySobCycleDTO getSalarySobCycle(Long id, YearMonth salaryMonth); + + /** + * 根据扣缴义务人查询 + * @param taxAgentIds + * @return + */ + List listByTaxAgentIds(List taxAgentIds); + + List getConfig(Long taxAgentId); + + List parseConfig(Long taxAgentId, List salarySobConfigs); + + List list(SalarySobQueryParam param); + + void handleHistory(); + +} diff --git a/src/com/engine/salary/service/SalaryTemplateService.java b/src/com/engine/salary/service/SalaryTemplateService.java new file mode 100644 index 000000000..29766417c --- /dev/null +++ b/src/com/engine/salary/service/SalaryTemplateService.java @@ -0,0 +1,134 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.salaryBill.dto.SalaryTemplateListDTO; +import com.engine.salary.entity.salaryBill.dto.SalaryTemplateSalaryItemSetListDTO; +import com.engine.salary.entity.salaryBill.param.SalaryTemplateCopyParam; +import com.engine.salary.entity.salaryBill.param.SalaryTemplateDefaultUseParam; +import com.engine.salary.entity.salaryBill.param.SalaryTemplateQueryParam; +import com.engine.salary.entity.salaryBill.param.SalaryTemplateSaveParam; +import com.engine.salary.entity.salaryBill.po.SalaryTemplatePO; +import com.engine.salary.util.page.PageInfo; + +import java.util.Collection; +import java.util.List; +import java.util.Map; + +/** + * @Description: 工资单模板 + * @Author: wangxiangzhong + * @Date: 2021-12-08 14:44 + */ +public interface SalaryTemplateService { + + /** + * 获取单个工资单模板记录 + * + * @param id + * @return + */ + SalaryTemplatePO getById(Long id); + + /** + * 工资单模板列表(分页) + * + * @param queryParam + * @return + */ +// Map listPage(SalaryTemplateQueryParam queryParam); + + /** + * 默认使用 + * + * @param defaultUseParamy + * @return + */ + String defaultUse(SalaryTemplateDefaultUseParam defaultUseParamy); + + /** + * 新建工资单模板 + * + * @param saveParam + * @return + */ + String save(SalaryTemplateSaveParam saveParam); + + /** + * 编辑工资单模板 + * + * @param saveParam + * @return + */ + String update(SalaryTemplateSaveParam saveParam); + + /** + * 复制工资单模板 + * + * @param copyParam + * @return + */ + String copy(SalaryTemplateCopyParam copyParam); + + /** + * 删除工资单模板 + * + * @param ids + * @return + */ + String delete(Collection ids); + + /** + * 获取薪资账套下拉列表 + * + * @return + */ + List> selectSalarySobList(); + + /** + * 获取薪资项目设置(不包含已隐藏的薪资项目、分类) + * + * @param salarySobId + * @return + */ + List getSalaryItemSet(Long salarySobId, boolean isReplenish); + + /** + * 获取薪资项目设置(包含已隐藏的薪资项目、分类) + * + * @param salarySobId + * @return + */ + List getSalaryItemSetContainHide(Long salarySobId, Long salaryTemplateId, boolean isReplenish); + + /** + * 获取默认工资单模板 + * + * @param salarySobIds + * @return + */ + List getDefaultTemplates(List salarySobIds); + + /** + * 根据薪资账套id获取工资单模板 + * @param ids + * @return + */ + List getBySalarySobIds(Collection ids); + + /** + * 工资单模板列表 + * @param queryParam + * @return + */ + PageInfo listPage(SalaryTemplateQueryParam queryParam); + + /** + * 获取所有设置了定时发送的默认工资单模板 + */ + List getAutoSendTemplate(); + + /** + * 获取所有开启了工资单确认反馈的默认工资单模板 + * @return + */ + List listNeedAckDefaultTemplate(); +} diff --git a/src/com/engine/salary/service/SettingService.java b/src/com/engine/salary/service/SettingService.java new file mode 100644 index 000000000..314a9cf43 --- /dev/null +++ b/src/com/engine/salary/service/SettingService.java @@ -0,0 +1,67 @@ +package com.engine.salary.service; + +import com.cloudstore.eccom.pc.table.WeaTableColumn; +import com.engine.salary.entity.setting.dto.PageListTemplateDTO; +import com.engine.salary.entity.setting.dto.PageListTemplateDetailDTO; +import com.engine.salary.entity.setting.param.*; +import com.engine.salary.entity.setting.po.PageListTemplatePO; +import com.engine.salary.util.page.PageInfo; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import java.util.List; + +public interface SettingService { + + @Deprecated + void savePageListSetting(PageListSettingSaveParam pageListSettingSaveParam); + + /** + * 获取原有显示列定制配置 + * @param param + * @return + */ + PageListTemplateDetailDTO getDefaultPageListSetting(PageListSettingQueryParam param); + + @Deprecated + void resetPageListSetting(PageListSettingResetParam param); + + /** + * 获取指定模板配置或者指定页面默认配置 + * @param param + * @return + */ + PageListTemplateDetailDTO getPageListTemplate(PageListTemplateQueryParam param); + + /** + * 获取可选模板列表 + * @param queryParam + * @return + */ + List getPageListTemplates(PageListTemplateQueryParam queryParam); + + /** + * 保存模板 + * @param param + * @return + */ + PageListTemplatePO savePageListTemplate(PageListTemplateSaveParam param); + + /** + * 下载导出模板文件 + * @param param + * @return + */ + XSSFWorkbook downloadPageExportTemplateFile(DownloadTemplateParam param); + + /** + * 更换模板 + * @param param + */ + void changePageListTemplate(PageListTemplateChangeParam param); + + List getPageListColumns(String page); + + PageInfo getTemplates(PageListTemplateQueryParam param); + + void deletePageListTemplate(PageListTemplateDeleteParam param); +} diff --git a/src/com/engine/salary/service/SpecialAddDeductionService.java b/src/com/engine/salary/service/SpecialAddDeductionService.java new file mode 100644 index 000000000..9879a6ab6 --- /dev/null +++ b/src/com/engine/salary/service/SpecialAddDeductionService.java @@ -0,0 +1,108 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.datacollection.dto.SpecialAddDeductionListDTO; +import com.engine.salary.entity.datacollection.dto.SpecialAddDeductionRecordDTO; +import com.engine.salary.entity.datacollection.param.SpecialAddDeductionImportParam; +import com.engine.salary.entity.datacollection.param.SpecialAddDeductionParam; +import com.engine.salary.entity.datacollection.param.SpecialAddDeductionQueryParam; +import com.engine.salary.entity.datacollection.param.SpecialAddDeductionRecordDeleteParam; +import com.engine.salary.entity.datacollection.po.SpecialAddDeductionPO; +import com.engine.salary.util.excel.ExcelPreviewDTO; +import com.engine.salary.util.page.PageInfo; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import java.time.YearMonth; +import java.util.List; +import java.util.Map; + +/** + * 数据采集-其他免税扣除 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author lfc + * @version 1.0 + **/ +public interface SpecialAddDeductionService { + + /** + * 通过id获取单条专项扣除记录 + * + * @param id + * @return + */ + SpecialAddDeductionPO getById(Long id); + + /** + * 数据采集-其他免税扣除列表 + * + * @param queryParam + * @return + */ + PageInfo listPage(SpecialAddDeductionQueryParam queryParam); + + /** + * 获取数据采集-其他免税扣除详情 + * + * @param queryParam + * @return + */ + PageInfo recordListPage(SpecialAddDeductionQueryParam queryParam); + + /** + * 导出 + * + */ + XSSFWorkbook export(SpecialAddDeductionQueryParam queryParam, boolean isTemplate); + + /** + * 导出详情 + * + */ + XSSFWorkbook exportDetail(SpecialAddDeductionQueryParam queryParam); + + /** + * 预览 + */ + ExcelPreviewDTO preview(SpecialAddDeductionImportParam importParam); + + /** + * 导入数据 + */ + Map importData(SpecialAddDeductionImportParam importParam); + + + + /** + * 获取其他免税扣除数据 + * + * @param declareMonth + * @param employeeIds + * @return + */ + List getSpecialAddDeductionList(YearMonth declareMonth, List employeeIds, Long taxAgentId); + + /** + * 编辑数据 + */ + void editData(SpecialAddDeductionParam SpecialAddDeductionParam); + + /** + * 新增数据 + */ + void createData(SpecialAddDeductionParam SpecialAddDeductionParam); + + /** + * 删除所选数据 + */ + void deleteSelectData(SpecialAddDeductionRecordDeleteParam deleteParam); + + /** + * 一键清空数据 + */ + void deleteAllData(SpecialAddDeductionRecordDeleteParam deleteParam); + + List getSpecialAddDeductionPOByEmployee(List employeeId, Long taxAgentId); + + SpecialAddDeductionRecordDTO getRecordById(Long id); +} diff --git a/src/com/engine/salary/service/SysSalaryItemService.java b/src/com/engine/salary/service/SysSalaryItemService.java new file mode 100644 index 000000000..f20e629cf --- /dev/null +++ b/src/com/engine/salary/service/SysSalaryItemService.java @@ -0,0 +1,62 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.salaryitem.po.SysSalaryItemPO; + +import java.util.Collection; +import java.util.List; + +/** + * 系统薪资项目 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public interface SysSalaryItemService { + + /** + * 根据主键id查询系统薪资项目 + * + * @param id + * @return + */ + SysSalaryItemPO getById(Long id); + + /** + * 根据主键id查询系统薪资项目 + * + * @param ids + * @return + */ + List listByIds(Collection ids); + + /** + * 根据名称精确匹配查询系统薪资项目 + * + * @param name 名称 + * @return + */ + List listByName(String name); + + /** + * 根据参数查询系统薪资项目(分页) + * + * @param searchParam 查询参数 + * @return + */ +// Page listPageByParam(SysSalaryItemSearchParam searchParam); + + /** + * 添加系统薪资项目到自定义薪资项目列表中 + * + * @param ids + */ + void add2SalaryItem(Collection ids); + + List listAll(); + + List listSome(SysSalaryItemPO po); + + List listLikeName(SysSalaryItemPO po); +} diff --git a/src/com/engine/salary/service/TaxAgentAdminService.java b/src/com/engine/salary/service/TaxAgentAdminService.java new file mode 100644 index 000000000..60ac4d451 --- /dev/null +++ b/src/com/engine/salary/service/TaxAgentAdminService.java @@ -0,0 +1,63 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.taxagent.po.TaxAgentAdminPO; + +import java.util.Collection; +import java.util.List; + +/** + * 个税扣缴义务人管理员 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public interface TaxAgentAdminService { + + /** + * 根据个税扣缴义务人id删除管理员 + * + * @param taxAgentIds + */ + void deleteByTaxAgentIds(Collection taxAgentIds); + + /** + * 批量新增管理员 + * + * @param taxAgentId + * @param admins + */ + void batchInsert(Long taxAgentId, Collection admins); + + /** + * 根据个税扣缴义务人id查询管理员 + * + * @param taxAgentIds + * @return + */ + List listByTaxAgentIds(Collection taxAgentIds); + + /** + * 根据个税扣缴义务人id查询管理员 + * + * @param taxAgentIds + * @return + */ + List listByTaxAgentIdsAndEmployeeId(Collection taxAgentIds, Long currentEmployeeId); + + /** + * 根据当前登录人查询管理员 + * + * @param currentEmployeeId + * @return + */ + List listByEmployeeId(Long currentEmployeeId); + + /** + * 获取管理的扣缴义务人id + * @param currentEmployeeId + * @return + */ + List getAdminTaxAgentIds(Long currentEmployeeId); +} diff --git a/src/com/engine/salary/service/TaxAgentBaseService.java b/src/com/engine/salary/service/TaxAgentBaseService.java new file mode 100644 index 000000000..de468d8df --- /dev/null +++ b/src/com/engine/salary/service/TaxAgentBaseService.java @@ -0,0 +1,42 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.taxagent.param.TaxAgentSaveBaseParam; +import com.engine.salary.entity.taxagent.po.TaxAgentBasePO; +import com.engine.salary.sys.entity.vo.UploadConfigResponse; + +/** + * 个税扣缴义务人基础信息 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public interface TaxAgentBaseService { + + /** + * 是否开启分权 + * + * @return + */ + Boolean isOpenDevolution(); + + /** + * 获取个税扣缴义务人基本信息 + * + * @return + */ + TaxAgentBasePO getBaseInfo(); + + /** + * 保存个税扣缴义务人信息 + * + * @param saveBaseParam + * @return + */ + String save(TaxAgentSaveBaseParam saveBaseParam); + + TaxAgentBasePO getConfig(); + + UploadConfigResponse.Result parseConfig(TaxAgentBasePO config); +} diff --git a/src/com/engine/salary/service/TaxAgentEmpChangeService.java b/src/com/engine/salary/service/TaxAgentEmpChangeService.java new file mode 100644 index 000000000..80a9f67c6 --- /dev/null +++ b/src/com/engine/salary/service/TaxAgentEmpChangeService.java @@ -0,0 +1,39 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.taxagent.po.TaxAgentEmpChangePO; +import com.engine.salary.enums.taxagent.TaxAgentEmpChangeModuleEnum; + +import java.util.Collection; +import java.util.List; + +/** + * 个税扣缴义务人管理范围的增量人员 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public interface TaxAgentEmpChangeService { + + /** + * 获取所有增量数据 + * + */ + List listAll(); + + /** + * 根据模块类型获取所有增量数据 + */ + List listAllByModule(TaxAgentEmpChangeModuleEnum moduleTypeEnum); + + /** + * 删除增量数据 + * + * @param ids + * @return + */ + boolean deleleByIds(Collection ids); + + void batchInsert(List taxAgentEmpChangeList); +} diff --git a/src/com/engine/salary/service/TaxAgentEmpService.java b/src/com/engine/salary/service/TaxAgentEmpService.java new file mode 100644 index 000000000..06cf297b3 --- /dev/null +++ b/src/com/engine/salary/service/TaxAgentEmpService.java @@ -0,0 +1,49 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.taxagent.param.TaxAgentEmpSaveParam; +import com.engine.salary.entity.taxagent.po.TaxAgentEmpPO; +import com.engine.salary.enums.datacollection.UseEmployeeTypeEnum; + +import java.util.Collection; +import java.util.List; + +/** + * 个税扣缴义务人管理范围的人员 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public interface TaxAgentEmpService{ + + /** + * 根据个税扣缴义务人id删除管理范围的人员 + * + * @param taxAgentIds + */ + void deleteByTaxAgentIds(Collection taxAgentIds); + + /** + * 根据个税扣缴义务人id获取管理范围中的人员 + * + * @param taxAgentIds + * @return + */ + List listByTaxAgentIds(List taxAgentIds, UseEmployeeTypeEnum type); + + /** + * 同步人员到本地关联表 + * + * @param taxAgentEmpSaveParamList + * @param currentEmployeeId + */ + void syncTaxAgentEmployee(List taxAgentEmpSaveParamList, Long currentEmployeeId); + + /** + * 同步外部人员 + * @param taxAgentEmpSaveParamList + * @param currentEmployeeId + */ + void syncTaxAgentExtEmployee(List taxAgentEmpSaveParamList, Long currentEmployeeId); +} diff --git a/src/com/engine/salary/service/TaxAgentExcelService.java b/src/com/engine/salary/service/TaxAgentExcelService.java new file mode 100644 index 000000000..ef1e5c55c --- /dev/null +++ b/src/com/engine/salary/service/TaxAgentExcelService.java @@ -0,0 +1,30 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.taxagent.param.TaxAgentImportParam; +import com.engine.salary.entity.taxagent.param.TaxAgentRangeDownloadTemplateParam; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import java.util.Map; + +/** + * @author Harryxzy + * @date 2023/01/05 15:10 + * @description + */ +public interface TaxAgentExcelService { + + /** + * 下载导入模板 + * + * @param downloadTemplateParam + * @param currentEmployeeId + */ + XSSFWorkbook downloadTemplateRange(TaxAgentRangeDownloadTemplateParam downloadTemplateParam, int currentEmployeeId); + + /** + * 预览 + * @param taxAgentImportParam + * @return + */ + Map preview(TaxAgentImportParam taxAgentImportParam); +} diff --git a/src/com/engine/salary/service/TaxAgentManageRangeService.java b/src/com/engine/salary/service/TaxAgentManageRangeService.java new file mode 100644 index 000000000..78b7a4f5c --- /dev/null +++ b/src/com/engine/salary/service/TaxAgentManageRangeService.java @@ -0,0 +1,91 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.taxagent.dto.TaxAgentManageRangeListDTO; +import com.engine.salary.entity.taxagent.param.*; +import com.engine.salary.entity.taxagent.po.TaxAgentExtRangePO; +import com.engine.salary.entity.taxagent.po.TaxAgentManageRangePO; +import com.engine.salary.util.page.PageInfo; + +import java.util.Collection; +import java.util.List; +import java.util.Map; + +/** + * 个税扣缴义务人的管理范围 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public interface TaxAgentManageRangeService { + + /** + * 根据查询条件查询分管理员的人员范围 + * + * @param queryParam 查询条件 + * @param includeType 0-从范围中排除/1-关联人员范围 + * @return + */ + PageInfo listPageByParamAndIncludeType(TaxAgentSubAdminRangeQueryParam queryParam, Integer includeType); + + /** + * 根据查询条件查询个税扣缴义务人的人员范围 + * + * @param queryParam 查询条件 + * @param includeType 0-从范围中排除/1-关联人员范围 + * @return + */ + PageInfo listPageByParamAndIncludeType(TaxAgentRangeQueryParam queryParam, Integer includeType); + + List listByTaxAgentIdAndIncludeType(Long taxAgentId, Integer includeType); + + /** + * 根据分管理员id集合查询范围列表 + * + * @param taxAgentSubAdminIds + * @return + */ + List listBySubAdminIds(Collection taxAgentSubAdminIds); + + /** + * 保存 + * + * @param saveParam 保存参数 + */ + void save(TaxAgentRangeSaveParam saveParam); + void edit(TaxAgentRangeSaveParam param); + + /** + * 根据主键id删除管理范围 + * + * @param ids + */ + void deleteByIds(Collection ids); + + PageInfo listExt(TaxAgentRangeExtQueryParam param); + + /** + * 保存外部人员范围 + * @param saveParam + */ + void saveExtRange(TaxAgentManageRangeExtSaveParam saveParam); + + void deleteExtRange(Collection ids); + + + /** + * 根据个税扣缴义务人的id删除管理范围 + * + * @param taxAgentIds 个税扣缴义务人的id + */ + void deleteByTaxAgentIds(Collection taxAgentIds); + + void syncManageRange(List taxAgentIds,String index); + + /** + * 人员范围导入 + * @param taxAgentImportParam + */ + Map importData(TaxAgentImportParam taxAgentImportParam); +} diff --git a/src/com/engine/salary/service/TaxAgentService.java b/src/com/engine/salary/service/TaxAgentService.java new file mode 100644 index 000000000..f6df75965 --- /dev/null +++ b/src/com/engine/salary/service/TaxAgentService.java @@ -0,0 +1,276 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.taxagent.config.TaxAgentConfig; +import com.engine.salary.entity.taxagent.dto.TaxAgentEmployeeDTO; +import com.engine.salary.entity.taxagent.dto.TaxAgentEmployeeTaxAgentDTO; +import com.engine.salary.entity.taxagent.dto.TaxAgentListDTO; +import com.engine.salary.entity.taxagent.dto.TaxAgentManageRangeEmployeeDTO; +import com.engine.salary.entity.taxagent.param.TaxAgentAdminChangeCheckParam; +import com.engine.salary.entity.taxagent.param.TaxAgentQueryParam; +import com.engine.salary.entity.taxagent.param.TaxAgentSaveParam; +import com.engine.salary.entity.taxagent.po.TaxAgentEmployeePO; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import com.engine.salary.enums.salarysob.SalaryEmployeeStatusEnum; +import com.engine.salary.enums.taxagent.TaxAgentRoleTypeEnum; +import com.engine.salary.sys.entity.vo.UploadConfigResponse; +import com.engine.salary.util.page.PageInfo; + +import java.util.Collection; +import java.util.List; +import java.util.Map; + +public interface TaxAgentService { + + /** + * 获取租户下所有人员的基本信息 + * + * @return + */ + List listEmployees(); + + /** + * 获取当前登录人角色(返回最大角色,优先级为:总管理员-》管理员-》分管理员) + * + * @param currentEmployeeId + * @return + */ + TaxAgentRoleTypeEnum getRoleType(Long currentEmployeeId); + + /** + * 是否需要分权 + * + * @param currentEmployeeId + * @return + */ + Boolean isNeedAuth(Long currentEmployeeId); + + /** + * 是否是薪酬模块总管理员 + * + * @param currentEmployeeId + * @return + */ + Boolean isChief(Long currentEmployeeId); + + /** + * 获取管理的扣缴义务人id + * @param currentEmployeeId + * @return + */ + List getAdminTaxAgentIds(Long currentEmployeeId); + + /** + * 默认权限是否开启 + * + * @param currentEmployeeId + * @return + */ + Boolean isDefaultOpen(Long currentEmployeeId); + + /** + * 管理员是否有权限 + * + * @param currentEmployeeId + * @return + */ + Boolean isAdminEnable(Long currentEmployeeId); + + /** + * 个税扣缴义务人列表(分页) + * + * @param queryParam + * @return + */ + PageInfo listPage(TaxAgentQueryParam queryParam); + + /** + * 个税扣缴义务人列表(不分页) + * + * @param queryParam + * @return + */ + List list(TaxAgentQueryParam queryParam); + + + /** + * 根据id查询个税扣缴义务人 + * + * @param ids + * @return + */ + List listByIds(Collection ids); + + /** + * 查询租户下的所有个税扣缴义务人 + * + * @return + */ + List listAll(); + + List listAuth(TaxAgentQueryParam taxAgentQueryParam); + + /** + * 根据id获取单个个税扣缴义务人 + * + * @param id + * @return + */ + TaxAgentPO getById(Long id); + + /** + * 获取所有个税扣缴义务人 + * + * @return + */ + Collection findAll(); + + /** + * 获取作为管理员或分管理员的个税扣缴义务人列表 + * + * @param currentEmployeeId 当前登录人id + * @return + */ + List listAllTaxAgents(Long currentEmployeeId); + + /** + * 获取作为管理员的所有个税扣缴义务人列表 + * + * @param currentEmployeeId 当前登录人id + * @return + */ + Collection listAllTaxAgentsAsAdmin(Long currentEmployeeId); + + /** + * 获取作为人员范围中的个税扣缴义务人列表 + * + * @param employeeIds 被管理的人员id + * @return + */ + Collection listAllTaxAgentsAsRange(List employeeIds); + + /** + * 新建个税扣缴义务人 + * + * @param saveParam + * @return + */ + String save(TaxAgentSaveParam saveParam); + + /** + * 更新代缴机构 + * + * @param taxAgentPO + * @return + */ + String paymentAgencyUpdate(TaxAgentPO taxAgentPO); + + /** + * 编辑个税扣缴义务人 + * + * @param saveParam + * @return + */ + String update(TaxAgentSaveParam saveParam); + + /** + * 删除个税扣缴义务人 + * + * @param ids + * @return + */ + String delete(List ids); + + /** + * 获取个税扣缴义务人下拉列表 + * + * @return + */ + List> selectList(boolean needAuth); + + /** + * 获取作为管理员的个税扣缴义务人的下拉列表 + * + * @param chiefCanSeeAll + * @return + */ + List> selectListAsAdmin(boolean chiefCanSeeAll); + + /** + * 是否开启分权 + * + * @return + */ + Boolean isOpenDevolution(); + + /** + * 获取个税扣缴义务人和可查看的人员列表(树型) + * + * @param employeeId + * @return + */ + List listTaxAgentAndEmployeeTree(Long employeeId); + + List listAllTaxAgentAndEmployeeTree(); + + /** + * 获取所有个税扣缴义务人和可查看的人员列表(树型) + * + * @return + */ + List listTaxAgentAndEmployeeTree(); + + /** + * 获取个税扣缴义务人和可查看的人员列表(扁平型) + * + * @param employeeId + * @return + */ + List listTaxAgentAndEmployee(Long employeeId); + + /** + * 获取个税扣缴义务人和可查看的人员列表(扁平型) + * + * @param + * @return + */ + List listAllTaxAgentAndEmployee(); + + /** + * 获取个税扣缴义务人和可查看的人员列表(树型) + * + * @param employeeStatus + * @param employeeId + * @return + */ + List listTaxAgentAndEmployeeTree(SalaryEmployeeStatusEnum employeeStatus, Long employeeId); + + /** + * 获取个税扣缴义务人和可查看的人员列表(扁平型) + * + * @param employeeStatus + * @param employeeId + * @return + */ + List listTaxAgentAndEmployee(SalaryEmployeeStatusEnum employeeStatus, Long employeeId); + + /** + * 更换管理员校验是否有核算数据 + * + * @param checkParam + * @return + */ + Boolean adminChangeCheck(TaxAgentAdminChangeCheckParam checkParam); + + + /** + * 获取个税扣缴义务人下的人员范围 + * + * @param taxAgentId + * @return + */ + Collection listEmployeeIdsInTaxAgent(Long taxAgentId); + + List getConfig(); + + List parseConfig(List configs); +} diff --git a/src/com/engine/salary/service/TaxAgentSubAdminEmpService.java b/src/com/engine/salary/service/TaxAgentSubAdminEmpService.java new file mode 100644 index 000000000..88bee1f51 --- /dev/null +++ b/src/com/engine/salary/service/TaxAgentSubAdminEmpService.java @@ -0,0 +1,49 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.taxagent.param.TaxAgentSubAdminEmpSaveParam; +import com.engine.salary.entity.taxagent.po.TaxAgentSubAdminEmpPO; + +import java.util.Collection; +import java.util.List; + +/** + * 个税扣缴义务人的分管理员的管理范围人员 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public interface TaxAgentSubAdminEmpService{ + + /** + * 同步分管理员的人员 + * + * @param subAdminEmpSaveParamList + * @param employeeId + */ + void syncTaxAgentSubAdminEmployee(List subAdminEmpSaveParamList, Long employeeId); + + /** + * 根据分管理员id获取人员 + * + * @param subAdminIds + * @return + */ + List listBySubAdminIds(List subAdminIds); + + /** + * 根据分管理员id删除人员 + * + * @param subAdminIds + */ + void deleteBySubAdminIds(Collection subAdminIds); + + /** + * 根据个税扣缴义务人id获取关联人员 + * + * @param noAdminTaxAgentIds + * @return + */ + List listByTaxAgentIds(List noAdminTaxAgentIds); +} diff --git a/src/com/engine/salary/service/TaxAgentSubAdminService.java b/src/com/engine/salary/service/TaxAgentSubAdminService.java new file mode 100644 index 000000000..4ec62274a --- /dev/null +++ b/src/com/engine/salary/service/TaxAgentSubAdminService.java @@ -0,0 +1,82 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.taxagent.param.TaxAgentSubAdminBaseSaveParam; +import com.engine.salary.entity.taxagent.po.TaxAgentSubAdminPO; + +import java.util.Collection; +import java.util.List; + +/** + * 个税扣缴义务人分管理员 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public interface TaxAgentSubAdminService { + + /** + * 根据个税扣缴义务人id删除分管理员 + * + * @param taxAgentIds + */ + void deleteByTaxAgentIds(Collection taxAgentIds); + + /** + * 根据id获取列表 + * + * @param ids + * @return + */ + List listByIds(Collection ids); + + /** + * 根据个税扣缴义务人id查询分管理员 + * + * @param taxAgentIds + * @return + */ + List listByTaxAgentIds(Collection taxAgentIds); + + /** + * 根据个税扣缴义务人id和人员id查询分管理员 + * + * @param taxAgentIds + * @param currentEmployeeId + * @return + */ + List listByTaxAgentIdsAndEmployeeId(List taxAgentIds, Long currentEmployeeId); + + /** + * 根据当前登录人id查询分管理员 + * + * @param currentEmployeeId + * @return + */ + List listByAndEmployeeId(Long currentEmployeeId); + + /** + * 根据id删除分管理员 + * + * @param ids + * @return + */ + String deleteByIds(Collection ids); + + /** + * 根据分管理员id和个税扣缴义务人id获取分管理员 + * + * @param id + * @return + */ + TaxAgentSubAdminPO getById(Long id); + + /** + * 保存基础设置 + * + * @param saveParam + * @return + */ + String saveBase(TaxAgentSubAdminBaseSaveParam saveParam); +} diff --git a/src/com/engine/salary/service/TaxDeclarationDetailService.java b/src/com/engine/salary/service/TaxDeclarationDetailService.java new file mode 100644 index 000000000..2889cf5d6 --- /dev/null +++ b/src/com/engine/salary/service/TaxDeclarationDetailService.java @@ -0,0 +1,87 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.taxdeclaration.dto.*; +import com.engine.salary.entity.taxdeclaration.param.TaxDeclarationDetailListQueryParam; +import com.engine.salary.entity.taxdeclaration.po.TaxDeclarationDetailPO; +import com.engine.salary.util.page.PageInfo; + +import java.util.Collection; +import java.util.List; + +/** + * 个税申报表明细 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public interface TaxDeclarationDetailService { + + /** + * 根据个税申报表id、人员id查询个税申报表明细 + * + * @param taxDeclarationId 个税申报表id + * @param employeeIds 人员id + * @return + */ + List listByTaxDeclarationIdAndEmployeeIds(Long taxDeclarationId, Collection employeeIds); + + /** + * 根据列表查询条件查询个税申报列表明细中的人员 + * + * @param queryParam 列表查询条件 + * @return + */ + PageInfo listPage4EmployeeIdByParam(TaxDeclarationDetailListQueryParam queryParam); + + /** + * 根据列表查询条件查询个税申报列表明细 + * + * @param queryParam 列表查询条件 + * @return + */ + PageInfo listDtoPageByParam(TaxDeclarationDetailListQueryParam queryParam); + + /** + * 根据列表查询条件查询个税申报列表明细(劳务报酬所得) + * + * @param queryParam 列表查询条件 + * @return + */ + PageInfo listDtoPageByParam4Labor(TaxDeclarationDetailListQueryParam queryParam); + + + PageInfo listDtoPageByParam4Annual(TaxDeclarationDetailListQueryParam queryParam); + + /** + * 查询个税申报列表明细(劳务报酬所得) + * + * @param taxDeclarationId + * @param taxDeclarationEmployees + * @return + */ + List listDto4Labor(Long taxDeclarationId, List taxDeclarationEmployees); + + /** + * 根据列表查询条件查询个税申报列表明细(正常工资薪金所得) + * + * @param queryParam 列表查询条件 + * @return + */ + PageInfo listDtoPageByParam4Wage(TaxDeclarationDetailListQueryParam queryParam); + + /** + * 批量保存 + * + * @param taxDeclarationDetailPOS 个税申报表明细po + */ + void batchSave(Collection taxDeclarationDetailPOS); + + /** + * 根据个税申报表id删除个税申报表详情 + * + * @param taxDeclarationIds 个税申报表id + */ + void deleteByTaxDeclarationIds(Collection taxDeclarationIds); +} diff --git a/src/com/engine/salary/service/TaxDeclarationExcelService.java b/src/com/engine/salary/service/TaxDeclarationExcelService.java new file mode 100644 index 000000000..fb95a6e5c --- /dev/null +++ b/src/com/engine/salary/service/TaxDeclarationExcelService.java @@ -0,0 +1,21 @@ +package com.engine.salary.service; + +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +/** + * 个税申报表导出 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public interface TaxDeclarationExcelService { + + /** + * 导出个税申报表 + * + * @param taxDeclarationId + */ + XSSFWorkbook exportTaxDeclaration(Long taxDeclarationId); +} diff --git a/src/com/engine/salary/service/TaxDeclarationService.java b/src/com/engine/salary/service/TaxDeclarationService.java new file mode 100644 index 000000000..7537c1c06 --- /dev/null +++ b/src/com/engine/salary/service/TaxDeclarationService.java @@ -0,0 +1,53 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import com.engine.salary.entity.taxdeclaration.param.TaxDeclarationListQueryParam; +import com.engine.salary.entity.taxdeclaration.param.TaxDeclarationSaveParam; +import com.engine.salary.entity.taxdeclaration.po.TaxDeclarationPO; +import com.engine.salary.util.page.PageInfo; + +import java.time.YearMonth; +import java.util.Collection; +import java.util.List; + +public interface TaxDeclarationService { + + /** + * 根据税款所属期、个税扣缴义务人查询个税申报表 + * + * @param salaryMonth 薪资所属月 + * @param taxAgentIds 个税扣缴义务人id + * @return + */ + List listByTaxCycleAndTaxAgentIds(YearMonth salaryMonth, Collection taxAgentIds); + + PageInfo listPageByParam(TaxDeclarationListQueryParam queryParam); + + List countByTaxDeclarationId(Collection taxAgentIds); + + TaxDeclarationPO getById(Long id); + + void save(TaxDeclarationSaveParam saveParam); + + /** + * 删除个税申报表 + * + */ + void delete(SalaryAcctRecordPO salaryAcctRecordPO); + + /** + * 判断是否有权限可查看个税申报表 + * + * @param taxDeclarationPO + * @param employeeId + * @return + */ + boolean checkByAuthority(TaxDeclarationPO taxDeclarationPO, Long employeeId); + + /** + * 撤回个税申报单 + * @param taxDeclarationId + */ + void withDrawTaxDeclaration(Long taxDeclarationId); +} diff --git a/src/com/engine/salary/service/TaxRateBaseService.java b/src/com/engine/salary/service/TaxRateBaseService.java new file mode 100644 index 000000000..526ab8a1a --- /dev/null +++ b/src/com/engine/salary/service/TaxRateBaseService.java @@ -0,0 +1,28 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.taxrate.TaxRateBase; + +import java.util.List; +import java.util.Map; + +public interface TaxRateBaseService { + /** + * 分页列表 + */ + Map listPage(Map params); + + Map delete(Map params); + + Map save(Map params); + + Map update(Map params); + + Map getForm(Map params); + + /** + * 获取所有的个税税率表 + * + * @return + */ + List list(); +} diff --git a/src/com/engine/salary/service/TaxRateDetailService.java b/src/com/engine/salary/service/TaxRateDetailService.java new file mode 100644 index 000000000..8789d6cb3 --- /dev/null +++ b/src/com/engine/salary/service/TaxRateDetailService.java @@ -0,0 +1,43 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.taxrate.TaxRateDetail; + +import java.util.Collection; +import java.util.List; + +/** + * 个税税率表明细表 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public interface TaxRateDetailService { + + /** + * 根据公式条件获取对应的税率 + * + * @param taxRateBaseId + * @param isOr + * @param formulaFilterDataList + * @param tenantKey + * @return + */ +// TaxRateDetail getByFormulaFilterData(Long taxRateBaseId, boolean isOr, Collection formulaFilterDataList); + + /** + * 根据主表id获取明细表 + * + * @param taxRateBaseId + * @return + */ + List listByBaseId(Long taxRateBaseId); + + /** + * 根据主表id批量删除明细表 + * + * @param taxRateBaseIds + */ + void deleteByBaseIds(Collection taxRateBaseIds); +} diff --git a/src/com/engine/salary/service/VariableArchiveItemService.java b/src/com/engine/salary/service/VariableArchiveItemService.java new file mode 100644 index 000000000..e5dd8644a --- /dev/null +++ b/src/com/engine/salary/service/VariableArchiveItemService.java @@ -0,0 +1,36 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.datacollection.po.VariableArchiveItemPO; + +import java.util.List; + +/** + * @author Harryxzy + * @ClassName VariableArchiveItemService + * @date 2024/08/07 9:29 + * @description 浮动薪资档案明细值 + */ +public interface VariableArchiveItemService { + + List listAll(); + /** + * 根据浮动薪资档案id获取 + * + * @param variableArchiveIds + * @return + */ + List listByVariableArchiveIds(List variableArchiveIds); + + /** + * 查询浮动薪酬档案中已使用的浮动薪资项目 + * + * @return + */ + List listUsingItems(); + + int batchInsert(List variableArchiveItemList); + + void deleteByIds(List variableArchiveItemIds); + + void deleteByArchiveIds(List variableArchiveIds); +} diff --git a/src/com/engine/salary/service/VariableArchiveService.java b/src/com/engine/salary/service/VariableArchiveService.java new file mode 100644 index 000000000..735c03a96 --- /dev/null +++ b/src/com/engine/salary/service/VariableArchiveService.java @@ -0,0 +1,75 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.datacollection.dto.VariableArchiveListDTO; +import com.engine.salary.entity.datacollection.dto.VariableItemListDTO; +import com.engine.salary.entity.datacollection.param.VariableArchiveImportHandleParam; +import com.engine.salary.entity.datacollection.param.VariableArchiveQueryParam; +import com.engine.salary.entity.datacollection.param.VariableArchiveSaveParam; +import com.engine.salary.util.excel.ExcelPreviewDTO; +import com.engine.salary.util.page.PageInfo; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import java.time.YearMonth; +import java.util.Collection; +import java.util.List; +import java.util.Map; + +/** + * 数据采集-浮动薪酬 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author xzy + * @version 1.0 + **/ +public interface VariableArchiveService { + + /** + * 查询浮动薪酬档案(分页) + * + * @param queryParam + * @return + */ + PageInfo listPage(VariableArchiveQueryParam queryParam); + + List list(VariableArchiveQueryParam queryParam); + + /** + * 构建浮动薪资档案数据 + * + * @param variableArchives + * @return + */ + List> buildVariableArchiveData(List variableArchives); + + /** + * 创建浮动薪酬档案 + * + * @param saveParam + */ + void createData(VariableArchiveSaveParam saveParam); + + /** + * 浮动薪资档案明细 + * + * @param queryParam + * @return + */ + Map getDetail(VariableArchiveQueryParam queryParam); + + List getCreateForm(); + + XSSFWorkbook downloadTemplate(VariableArchiveQueryParam param); + + ExcelPreviewDTO preview(VariableArchiveImportHandleParam importParam); + + Map importData(VariableArchiveImportHandleParam importParam); + + XSSFWorkbook export(VariableArchiveQueryParam param); + + void deleteSelectVariableArchive(Collection deleteIds); + + List> listBySalaryMonthAndEmployeeIds(YearMonth salaryMonth, List employeeIds, List taxAgentIds); + + void updateData(VariableArchiveSaveParam updateParam); +} diff --git a/src/com/engine/salary/service/VariableItemService.java b/src/com/engine/salary/service/VariableItemService.java new file mode 100644 index 000000000..ef2dade37 --- /dev/null +++ b/src/com/engine/salary/service/VariableItemService.java @@ -0,0 +1,66 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.datacollection.dto.VariableItemListDTO; +import com.engine.salary.entity.datacollection.param.VariableItemQueryParam; +import com.engine.salary.entity.datacollection.param.VariableItemSaveParam; +import com.engine.salary.entity.datacollection.po.VariableItemPO; +import com.engine.salary.util.page.PageInfo; + +import java.util.List; + +/** + * @author Harryxzy + * @ClassName VariableItemService + * @date 2024/08/07 9:30 + * @description 浮动薪酬项目 + */ +public interface VariableItemService { + + VariableItemPO getById(Long id); + + List listByIds(List ids); + + /** + * 获取所有的浮动薪酬项目 + * + * @return + */ + List listAll(); + + /** + * 获取浮动薪资项目列表(分页) + * + * @param queryParam + * @return + */ + PageInfo listPage(VariableItemQueryParam queryParam); + + /** + * 新建浮动薪酬项目 + * + * @param saveParam + */ + Integer save(VariableItemSaveParam saveParam); + + /** + * 更新浮动薪酬项目 + * + * @param saveParam + */ + VariableItemPO update(VariableItemSaveParam saveParam); + + /** + * 删除浮动薪资项目 + * + * @param itemIds + */ + void deleteItems(List itemIds); + + /** + * 浮动薪酬项目详细信息 + * + * @param id + * @return + */ + VariableItemListDTO getDetail(Long id); +} diff --git a/src/com/engine/salary/service/auth/AuthDataService.java b/src/com/engine/salary/service/auth/AuthDataService.java new file mode 100644 index 000000000..ca0848e60 --- /dev/null +++ b/src/com/engine/salary/service/auth/AuthDataService.java @@ -0,0 +1,50 @@ +package com.engine.salary.service.auth; + +import com.engine.salary.entity.auth.dto.AuthRoleDataDTO; +import com.engine.salary.entity.auth.param.AuthDataQueryParam; +import com.engine.salary.entity.auth.param.AuthDataSaveParam; +import com.engine.salary.entity.auth.param.AuthSyncParam; +import com.engine.salary.entity.auth.po.AuthDataPO; + +import java.util.List; + +/** + * 数据 + *

Copyright: Copyright (c) 2024

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public interface AuthDataService { + + /** + * 列表 + * @param roleId + * @return + */ + List list(Long roleId); + + /** + * 保存数据 + * @param params + * @return + */ + void save(List params); + + /** + * 删除 + * @param ids + */ + void delete(List ids); + + /** + * 同步 + * @param param + */ + void sync(AuthSyncParam param); + + void deleteByRoleId(Long roleId); + + List listRoleData( AuthDataQueryParam param); +} diff --git a/src/com/engine/salary/service/auth/AuthDataServiceImpl.java b/src/com/engine/salary/service/auth/AuthDataServiceImpl.java new file mode 100644 index 000000000..582887859 --- /dev/null +++ b/src/com/engine/salary/service/auth/AuthDataServiceImpl.java @@ -0,0 +1,163 @@ +package com.engine.salary.service.auth; + +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.util.StrUtil; +import com.engine.core.impl.Service; +import com.engine.salary.constant.SalaryDefaultTenantConstant; +import com.engine.salary.entity.auth.dto.AuthRoleDataDTO; +import com.engine.salary.entity.auth.param.AuthDataQueryParam; +import com.engine.salary.entity.auth.param.AuthDataSaveParam; +import com.engine.salary.entity.auth.param.AuthSyncParam; +import com.engine.salary.entity.auth.po.AuthDataPO; +import com.engine.salary.entity.auth.po.AuthRoleDataPO; +import com.engine.salary.entity.auth.po.AuthRolePO; +import com.engine.salary.enums.auth.DataLinkEnum; +import com.engine.salary.enums.auth.DataTargetTypeEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.mapper.auth.AuthDataMapper; +import com.engine.salary.mapper.auth.AuthRoleDataMapper; +import com.engine.salary.mapper.auth.AuthRoleEmpMapper; +import com.engine.salary.mapper.auth.AuthRoleMapper; +import com.engine.salary.util.db.IdGenerator; +import com.engine.salary.util.db.MapperProxyFactory; +import com.google.common.collect.Lists; + +import java.util.Date; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; + +public class AuthDataServiceImpl extends Service implements AuthDataService { + + + private AuthDataMapper getAuthDataMapper() { + return MapperProxyFactory.getProxy(AuthDataMapper.class); + } + + private AuthRoleMapper getAuthRoleMapper() { + return MapperProxyFactory.getProxy(AuthRoleMapper.class); + } + + private AuthRoleEmpMapper getAuthRoleEmpMapper() { + return MapperProxyFactory.getProxy(AuthRoleEmpMapper.class); + } + + private AuthRoleDataMapper getAuthRoleDataMapper() { + return MapperProxyFactory.getProxy(AuthRoleDataMapper.class); + } + + + @Override + public List list(Long roleId) { + AuthRolePO rolePO = getAuthRoleMapper().getById(roleId); + if (rolePO == null) { + throw new SalaryRunTimeException("角色不存在!"); + } + return getAuthDataMapper().listSome(AuthDataPO.builder().roleId(roleId).build()); + } + + @Override + public void save(List params) { + params.forEach(param -> { + Date now = new Date(); + Long roleId = param.getRoleId(); + AuthRolePO rolePO = getAuthRoleMapper().getById(roleId); + if (rolePO == null) { + throw new SalaryRunTimeException("角色不存在!"); + } + + if (param.getId() == null) { + AuthDataPO dataPO = AuthDataPO.builder() + .id(IdGenerator.generate()) + .roleId(param.getRoleId()) + .link(param.getLink().getValue()) + .targetType(param.getTargetType().getValue()) + .target(param.getTarget()) + .targetName(param.getTargetName()) + .sortedIndex(param.getSortedIndex() == null ? 0 : param.getSortedIndex()) + .creator((long) user.getUID()) + .createTime(now) + .updateTime(now) + .deleteType(0) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .build(); + getAuthDataMapper().insertIgnoreNull(dataPO); + } else { + getAuthDataMapper().getById(param.getId()); + AuthDataPO dataPO = AuthDataPO.builder() + .id(param.getId()) + .link(param.getLink().getValue()) + .targetType(param.getTargetType().getValue()) + .target(param.getTarget()) + .targetName(param.getTargetName()) + .sortedIndex(param.getSortedIndex() == null ? 0 : param.getSortedIndex()) + .creator((long) user.getUID()) + .updateTime(now) + .deleteType(0) + .build(); + getAuthDataMapper().updateIgnoreNull(dataPO); + } + }); + } + + @Override + public void delete(List ids) { + if (CollectionUtil.isNotEmpty(ids)) { + getAuthDataMapper().deleteByIds(ids); + } + } + + @Override + public void sync(AuthSyncParam param) { + Long roleId = param.getRoleId(); + Date now = new Date(); + List list = list(roleId); + + Set ids = new HashSet<>(); + for (int i = 0; i < list.size(); i++) { + AuthDataPO dataPO = list.get(i); + DataTargetTypeEnum dataTargetTypeEnum = DataTargetTypeEnum.parseByValue(dataPO.getTargetType()); + DataLinkEnum dataLinkEnum = DataLinkEnum.parseByValue(dataPO.getLink()); + Set empResult = dataTargetTypeEnum.getEmpIds(dataPO.getTarget()); + if (i == 0) { + ids = empResult; + } else { + ids = dataLinkEnum.calculation(ids, empResult); + } + } + + getAuthRoleDataMapper().deleteByRoleId(roleId); + + List collect = ids.stream().map(empId -> + AuthRoleDataPO.builder() + .id(IdGenerator.generate()) + .roleId(roleId) + .employeeId(empId) + .creator((long) user.getUID()) + .createTime(now) + .updateTime(now) + .deleteType(0) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .build()) + .collect(Collectors.toList()); + + List> partition = Lists.partition(collect, 100); + partition.forEach(pos -> getAuthRoleDataMapper().batchInsert(pos)); + } + + @Override + public void deleteByRoleId(Long roleId) { + getAuthDataMapper().deleteByRoleId(roleId); + getAuthRoleDataMapper().deleteByRoleId(roleId); + } + + @Override + public List listRoleData( AuthDataQueryParam param) { + List authRoleDataDTOS = getAuthRoleDataMapper().listRoleData(param.getRoleId()); + if (StrUtil.isNotEmpty(param.getUsername())){ + authRoleDataDTOS = authRoleDataDTOS.stream().filter(authRoleDataDTO -> authRoleDataDTO.getUsername().contains(param.getUsername())).collect(Collectors.toList()); + } + return authRoleDataDTOS; + } +} diff --git a/src/com/engine/salary/service/auth/AuthMemberService.java b/src/com/engine/salary/service/auth/AuthMemberService.java new file mode 100644 index 000000000..f977e131a --- /dev/null +++ b/src/com/engine/salary/service/auth/AuthMemberService.java @@ -0,0 +1,49 @@ +package com.engine.salary.service.auth; + +import com.engine.salary.entity.auth.dto.AuthRoleEmpDTO; +import com.engine.salary.entity.auth.param.AuthMemberQueryParam; +import com.engine.salary.entity.auth.param.AuthMemberSaveParam; +import com.engine.salary.entity.auth.param.AuthSyncParam; +import com.engine.salary.entity.auth.po.AuthMemberPO; + +import java.util.List; + +/** + * 成员 + *

Copyright: Copyright (c) 2024

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public interface AuthMemberService { + /** + * 成员列表 + * @param roleId + * @return + */ + List list(Long roleId); + + /** + * 添加成员 + * @param params + * @return + */ + void save(List params); + + /** + * 删除成员 + * @param ids + */ + void delete(List ids); + + /** + * 同步成员 + * @param param + */ + void sync(AuthSyncParam param); + + void deleteByRoleId(Long roleId); + + List listRoleEmp(AuthMemberQueryParam param); +} diff --git a/src/com/engine/salary/service/auth/AuthMemberServiceImpl.java b/src/com/engine/salary/service/auth/AuthMemberServiceImpl.java new file mode 100644 index 000000000..b3a5232b6 --- /dev/null +++ b/src/com/engine/salary/service/auth/AuthMemberServiceImpl.java @@ -0,0 +1,204 @@ +package com.engine.salary.service.auth; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.StrUtil; +import com.engine.core.impl.Service; +import com.engine.hrmelog.entity.dto.LoggerContext; +import com.engine.salary.config.SalaryElogConfig; +import com.engine.salary.constant.SalaryDefaultTenantConstant; +import com.engine.salary.entity.auth.dto.AuthRoleEmpDTO; +import com.engine.salary.entity.auth.param.AuthMemberQueryParam; +import com.engine.salary.entity.auth.param.AuthMemberSaveParam; +import com.engine.salary.entity.auth.param.AuthSyncParam; +import com.engine.salary.entity.auth.po.AuthMemberPO; +import com.engine.salary.entity.auth.po.AuthRoleEmpPO; +import com.engine.salary.entity.auth.po.AuthRolePO; +import com.engine.salary.enums.OperateTypeEnum; +import com.engine.salary.enums.auth.MemberTargetTypeEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.mapper.auth.AuthMemberMapper; +import com.engine.salary.mapper.auth.AuthRoleEmpMapper; +import com.engine.salary.mapper.auth.AuthRoleMapper; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.db.IdGenerator; +import com.engine.salary.util.db.MapperProxyFactory; +import com.google.common.collect.Lists; + +import java.util.*; +import java.util.stream.Collectors; + +public class AuthMemberServiceImpl extends Service implements AuthMemberService { + + + private AuthMemberMapper getAuthMemberMapper() { + return MapperProxyFactory.getProxy(AuthMemberMapper.class); + } + + private AuthRoleMapper getAuthRoleMapper() { + return MapperProxyFactory.getProxy(AuthRoleMapper.class); + } + + private AuthRoleEmpMapper getAuthRoleEmpMapper() { + return MapperProxyFactory.getProxy(AuthRoleEmpMapper.class); + } + + + @Override + public List list(Long roleId) { + return getAuthMemberMapper().listSome(AuthMemberPO.builder().roleId(roleId).build()); + } + + @Override + public void save(List params) { + params.forEach(param -> { + AuthRolePO rolePO = getAuthRoleMapper().getById(param.getRoleId()); + if (rolePO == null) { + throw new SalaryRunTimeException("角色不存在!"); + } + + Date now = new Date(); + if (param.getId() == null) { + AuthMemberPO po = AuthMemberPO.builder() + .id(IdGenerator.generate()) + .roleId(param.getRoleId()) + .target(param.getTarget()) + .targetType(param.getTargetType().getValue()) + .targetName(param.getTargetName()) + .creator((long) user.getUID()) + .createTime(now) + .updateTime(now) + .deleteType(0) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .build(); + getAuthMemberMapper().insertIgnoreNull(po); + + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(rolePO.getId() + ""); + loggerContext.setTargetName(rolePO.getName() + "成员:" + po.getId()); + loggerContext.setOperateType(OperateTypeEnum.ADD.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "新增成员")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "新增成员")); + loggerContext.setNewValues(po); + SalaryElogConfig.authLinkLoggerTemplate.write(loggerContext); + } else { + AuthMemberPO oldPO = getAuthMemberMapper().getById(param.getId()); + AuthMemberPO newPo = AuthMemberPO.builder() + .id(param.getId()) + .target(param.getTarget()) + .targetType(param.getTargetType().getValue()) + .targetName(param.getTargetName()) + .creator((long) user.getUID()) + .updateTime(now) + .deleteType(0) + .build(); + getAuthMemberMapper().updateIgnoreNull(newPo); + + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(rolePO.getId() + ""); + loggerContext.setTargetName(rolePO.getName() + "成员:" + newPo.getId()); + loggerContext.setOperateType(OperateTypeEnum.ADD.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "编辑成员")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "编辑成员")); + loggerContext.setOldValues(oldPO); + loggerContext.setNewValues(newPo); + SalaryElogConfig.authLinkLoggerTemplate.write(loggerContext); + } + + }); + } + + @Override + public void delete(List ids) { + + ids.forEach(id -> { + AuthMemberPO po = getAuthMemberMapper().getById(id); + if (po == null) { + throw new SalaryRunTimeException("成员不存在!"); + } + + getAuthMemberMapper().deleteByIds(Collections.singleton(id)); + + AuthRolePO rolePO = getAuthRoleMapper().getById(po.getRoleId()); + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(rolePO.getId() + ""); + loggerContext.setTargetName(rolePO.getName() + "成员:" + po.getId()); + loggerContext.setOperateType(OperateTypeEnum.DELETE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "删除成员")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "删除成员")); + loggerContext.setNewValues(po); + SalaryElogConfig.authLinkLoggerTemplate.write(loggerContext); + }); + + + } + + @Override + public void sync(AuthSyncParam param) { + Long roleId = param.getRoleId(); + AuthRolePO rolePO = getAuthRoleMapper().getById(roleId); + if (rolePO == null) { + throw new SalaryRunTimeException("角色不存在!"); + } + + //1、获取成员 + List members = getAuthMemberMapper().listSome(AuthMemberPO.builder().roleId(roleId).build()); + Map> targetTypeMap = SalaryEntityUtil.group2Map(members, AuthMemberPO::getTargetType, AuthMemberPO::getTarget); + + //2、获取人员 + Set empIds = new HashSet<>(); + for (Integer targetType : targetTypeMap.keySet()) { + Set targetIds = targetTypeMap.get(targetType); + List ids = MemberTargetTypeEnum.parseByValue(targetType).getEmpIds(targetIds); + empIds.addAll(ids); + } + + //3、更新成员关系 + getAuthRoleEmpMapper().deleteByRoleId(roleId); + Date now = new Date(); + List roleEmpPOS = empIds.stream() + .map(empId -> AuthRoleEmpPO.builder() + .id(IdGenerator.generate()) + .employeeId(empId) + .roleId(roleId) + .creator((long) user.getUID()) + .createTime(now) + .updateTime(now) + .deleteType(0) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .build()) + .collect(Collectors.toList()); + if (CollUtil.isNotEmpty(roleEmpPOS)) { + List> partition = Lists.partition(roleEmpPOS, 100); + partition.forEach(list -> getAuthRoleEmpMapper().batchInsert(list)); + } + + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(rolePO.getId() + ""); + loggerContext.setTargetName(rolePO.getName()); + loggerContext.setOperateType(OperateTypeEnum.DELETE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "同步成员")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "同步成员")); + SalaryElogConfig.authLinkLoggerTemplate.write(loggerContext); + } + + @Override + public void deleteByRoleId(Long roleId) { + getAuthMemberMapper().deleteByRoleId(roleId); + getAuthRoleEmpMapper().deleteByRoleId(roleId); + } + + @Override + public List listRoleEmp(AuthMemberQueryParam param) { + List empDTOS = getAuthRoleEmpMapper().getByRoleId(param.getRoleId()); + if(StrUtil.isNotEmpty(param.getUsername())){ + empDTOS = empDTOS.stream().filter(item -> item.getUsername().contains(param.getUsername())).collect(Collectors.toList()); + } + + return empDTOS; + } +} diff --git a/src/com/engine/salary/service/auth/AuthOptService.java b/src/com/engine/salary/service/auth/AuthOptService.java new file mode 100644 index 000000000..9a607c7f9 --- /dev/null +++ b/src/com/engine/salary/service/auth/AuthOptService.java @@ -0,0 +1,36 @@ +package com.engine.salary.service.auth; + +import com.engine.salary.entity.auth.dto.AuthOptDTO; +import com.engine.salary.entity.auth.param.AuthOptSaveParam; +import com.engine.salary.entity.auth.po.AuthOptPO; + +import java.util.List; + +/** + * 权限项 + *

Copyright: Copyright (c) 2024

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public interface AuthOptService { + /** + * 权限树 + * @param roleId + * @return + */ + AuthOptDTO optTree(Long roleId); + + /** + * 保存权限项 + * @param param + * @return + */ + void save(AuthOptSaveParam param); + + void deleteByRoleId(Long roleId); + + List listOpts(Long roleId); + +} diff --git a/src/com/engine/salary/service/auth/AuthOptServiceImpl.java b/src/com/engine/salary/service/auth/AuthOptServiceImpl.java new file mode 100644 index 000000000..f482a0096 --- /dev/null +++ b/src/com/engine/salary/service/auth/AuthOptServiceImpl.java @@ -0,0 +1,98 @@ +package com.engine.salary.service.auth; + +import com.engine.core.impl.Service; +import com.engine.salary.constant.SalaryDefaultTenantConstant; +import com.engine.salary.entity.auth.dto.AuthOptDTO; +import com.engine.salary.entity.auth.param.AuthOptSaveParam; +import com.engine.salary.entity.auth.po.AuthOptPO; +import com.engine.salary.entity.auth.po.AuthRolePO; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.mapper.auth.AuthOptMapper; +import com.engine.salary.mapper.auth.AuthRoleMapper; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.db.IdGenerator; +import com.engine.salary.util.db.MapperProxyFactory; +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.security.AnyTypePermission; +import weaver.general.GCONST; + +import java.io.File; +import java.util.*; + +public class AuthOptServiceImpl extends Service implements AuthOptService { + + + + private AuthOptMapper getAuthOptMapper() { + return MapperProxyFactory.getProxy(AuthOptMapper.class); + } + + private AuthRoleMapper getAuthRoleMapper() { + return MapperProxyFactory.getProxy(AuthRoleMapper.class); + } + + + @Override + public AuthOptDTO optTree(Long roleId) { + List authOptPOS = getAuthOptMapper().listSome(AuthOptPO.builder().roleId(roleId).build()); + Map> pageOpts = SalaryEntityUtil.group2Map(authOptPOS, AuthOptPO::getPage, AuthOptPO::getOpt); + XStream xStream = new XStream(); + String resource = GCONST.getRootPath() + "WEB-INF" + File.separatorChar + "salaryoptconfig.xml"; +// File file = new File("H:\\code\\salary\\resource\\WEB-INF\\salaryoptconfig.xml"); + File file = new File(resource); + + xStream.addPermission(AnyTypePermission.ANY); + xStream.processAnnotations(AuthOptDTO.class); + AuthOptDTO dto = (AuthOptDTO)xStream.fromXML(file); + + dto.getModules().forEach(module -> { + module.getPages().forEach(page -> { + Set opts = pageOpts.getOrDefault(page.getKey(),new HashSet<>()); + page.getOpts().forEach(opt -> { + if(opts.contains(opt.getKey())){ + opt.setAble(true); + } + }); + }); + }); + + return dto; + } + + @Override + public void save(AuthOptSaveParam param) { + Date now = new Date(); + Long roleId = param.getRoleId(); + AuthRolePO rolePO = getAuthRoleMapper().getById(roleId); + if (rolePO == null) { + throw new SalaryRunTimeException("角色不存在!"); + } + + getAuthOptMapper().deleteByRoleId(roleId); + + param.getOpts().forEach(opt -> { + AuthOptPO po = AuthOptPO.builder() + .id(IdGenerator.generate()) + .roleId(roleId) + .page(opt.getPage()) + .opt(opt.getOpt()) + .creator((long) user.getUID()) + .createTime(now) + .updateTime(now) + .deleteType(0) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .build(); + getAuthOptMapper().insertIgnoreNull(po); + }); + } + + @Override + public void deleteByRoleId(Long roleId) { + getAuthOptMapper().deleteByRoleId(roleId); + } + + @Override + public List listOpts(Long roleId) { + return getAuthOptMapper().listSome(AuthOptPO.builder().roleId(roleId).build()); + } +} diff --git a/src/com/engine/salary/service/auth/AuthRoleService.java b/src/com/engine/salary/service/auth/AuthRoleService.java new file mode 100644 index 000000000..32527ec54 --- /dev/null +++ b/src/com/engine/salary/service/auth/AuthRoleService.java @@ -0,0 +1,40 @@ +package com.engine.salary.service.auth; + +import com.engine.salary.entity.auth.dto.AuthRoleDTO; +import com.engine.salary.entity.auth.param.AuthRoleListQueryParam; +import com.engine.salary.entity.auth.param.AuthRoleSaveParam; +import com.engine.salary.entity.auth.po.AuthRolePO; +import com.engine.salary.util.page.PageInfo; + +import java.util.List; + +/** + * 角色 + *

Copyright: Copyright (c) 2024

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public interface AuthRoleService { + + PageInfo roleList(AuthRoleListQueryParam param); + + AuthRoleDTO getRole(Long id); + + /** + * 添加角色 + * @param param + * @return + */ + Long saveRole(AuthRoleSaveParam param); + + /** + * 删除角色 + * @param ids + */ + void deleteRole(List ids); + + List listAll(); + +} diff --git a/src/com/engine/salary/service/auth/AuthRoleServiceImpl.java b/src/com/engine/salary/service/auth/AuthRoleServiceImpl.java new file mode 100644 index 000000000..e305b6833 --- /dev/null +++ b/src/com/engine/salary/service/auth/AuthRoleServiceImpl.java @@ -0,0 +1,250 @@ +package com.engine.salary.service.auth; + +import cn.hutool.core.collection.CollectionUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.hrmelog.entity.dto.LoggerContext; +import com.engine.salary.config.SalaryElogConfig; +import com.engine.salary.constant.SalaryDefaultTenantConstant; +import com.engine.salary.entity.auth.dto.AuthRoleDTO; +import com.engine.salary.entity.auth.dto.AuthRoleDataDTO; +import com.engine.salary.entity.auth.dto.AuthRoleEmpDTO; +import com.engine.salary.entity.auth.param.AuthDataQueryParam; +import com.engine.salary.entity.auth.param.AuthMemberQueryParam; +import com.engine.salary.entity.auth.param.AuthRoleListQueryParam; +import com.engine.salary.entity.auth.param.AuthRoleSaveParam; +import com.engine.salary.entity.auth.po.AuthOptPO; +import com.engine.salary.entity.auth.po.AuthResourcePO; +import com.engine.salary.entity.auth.po.AuthRolePO; +import com.engine.salary.entity.salarysob.po.SalarySobPO; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import com.engine.salary.enums.OperateTypeEnum; +import com.engine.salary.enums.auth.ResourceTargetTypeEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.mapper.auth.AuthResourceMapper; +import com.engine.salary.mapper.auth.AuthRoleMapper; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.db.IdGenerator; +import com.engine.salary.util.db.MapperProxyFactory; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.util.page.SalaryPageUtil; +import weaver.hrm.User; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Date; +import java.util.List; +import java.util.stream.Collectors; + +public class AuthRoleServiceImpl extends Service implements AuthRoleService { + + private AuthRoleMapper getAuthRoleMapper() { + return MapperProxyFactory.getProxy(AuthRoleMapper.class); + } + + private AuthResourceMapper getAuthResourceMapper() { + return MapperProxyFactory.getProxy(AuthResourceMapper.class); + } + + private AuthMemberService getAuthMemberService(User user) { + return ServiceUtil.getService(AuthMemberServiceImpl.class, user); + } + + private AuthOptService getAuthOptService(User user) { + return ServiceUtil.getService(AuthOptServiceImpl.class, user); + } + + private AuthDataService getAuthDataService(User user) { + return ServiceUtil.getService(AuthDataServiceImpl.class, user); + } + + + @Override + public PageInfo roleList(AuthRoleListQueryParam param) { + + List authRolePOS = getAuthRoleMapper().list(param); + int total = authRolePOS.size(); + + List list = SalaryPageUtil.subList(param.getCurrent(), param.getPageSize(), authRolePOS) + .stream().map(po -> { + Long roleId = po.getId(); + AuthMemberQueryParam roleQueryParam = AuthMemberQueryParam.builder().roleId(roleId).build(); + List authRoleEmpDTOS = getAuthMemberService(user).listRoleEmp(roleQueryParam); + List authOptPOS = getAuthOptService(user).listOpts(roleId); + AuthDataQueryParam dataQueryParam = AuthDataQueryParam.builder().roleId(roleId).build(); + List authRoleDataDTOS = getAuthDataService(user).listRoleData(dataQueryParam); + List authResources = getAuthResourceMapper().listSome(AuthResourcePO.builder().roleId(roleId).build()); + + return AuthRoleDTO.builder().id(roleId) + .name(po.getName()) + .description(po.getDescription()) + .members(authRoleEmpDTOS.size()) + .opts(authOptPOS.size()) + .datas(authRoleDataDTOS.size()) + .resources(authResources.size()) + .build(); + }).collect(Collectors.toList()); + PageInfo pageInfo = SalaryPageUtil.buildPage(param.getCurrent(), param.getPageSize(), AuthRoleDTO.class); + pageInfo.setList(list); + pageInfo.setTotal(total); + return pageInfo; + } + + @Override + public AuthRoleDTO getRole(Long id) { + AuthRolePO po = getAuthRoleMapper().getById(id); + if (po == null) { + throw new SalaryRunTimeException("业务线不存在"); + } + Long roleId = po.getId(); + List authResources = getAuthResourceMapper().listSome(AuthResourcePO.builder().roleId(roleId).build()); + + List taxAgentIds = new ArrayList<>(); + List sobIds = new ArrayList<>(); + authResources.forEach(resource -> { + if (ResourceTargetTypeEnum.TAX_AGENT.getValue().equals(resource.getTargetType())) { + taxAgentIds.add(TaxAgentPO.builder().id(resource.getTarget()).name(resource.getTargetName()).build()); + } else if (ResourceTargetTypeEnum.SOB.getValue().equals(resource.getTargetType())) { + sobIds.add(SalarySobPO.builder().id(resource.getTarget()).name(resource.getTargetName()).build()); + } + }); + + return AuthRoleDTO.builder() + .id(roleId) + .name(po.getName()) + .description(po.getDescription()) + .taxAgentIds(taxAgentIds) + .sobIds(sobIds) + .build(); + } + + @Override + public Long saveRole(AuthRoleSaveParam param) { + Date now = new Date(); + Long id = param.getId(); + String name = param.getName(); + String description = param.getDescription(); + + AuthRolePO po; + if (id == null) { + po = AuthRolePO.builder() + .id(IdGenerator.generate()) + .name(name) + .description(description) + .creator((long) user.getUID()) + .createTime(now) + .updateTime(now) + .deleteType(0) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .build(); + getAuthRoleMapper().insertIgnoreNull(po); + + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(po.getId() + ""); + loggerContext.setTargetName("业务线:" + name); + loggerContext.setOperateType(OperateTypeEnum.ADD.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "新增业务线")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "新增业务线")); + loggerContext.setNewValues(po); + SalaryElogConfig.authLinkLoggerTemplate.write(loggerContext); + + } else { + po = getAuthRoleMapper().getById(id); + if (po == null) { + throw new SalaryRunTimeException("业务线不存在!"); + } + AuthRolePO newPo = AuthRolePO.builder() + .id(id) + .name(name) + .description(description) + .updateTime(now) + .build(); + getAuthRoleMapper().updateIgnoreNull(newPo); + + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(po.getId() + ""); + loggerContext.setTargetName("业务线:" + name); + loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "更新业务线")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "更新业务线")); + loggerContext.setOldValues(po); + loggerContext.setNewValues(newPo); + SalaryElogConfig.authLinkLoggerTemplate.write(loggerContext); + } + + getAuthResourceMapper().deleteByRoleId(po.getId()); + + List taxAgents = param.getTaxAgentIds(); + List sobs = param.getSobIds(); + if (CollectionUtil.isNotEmpty(taxAgents)) { + taxAgents.forEach(tax -> { + AuthResourcePO resourcePO = AuthResourcePO.builder() + .id(IdGenerator.generate()) + .roleId(po.getId()) + .target(tax.getId()) + .targetType(ResourceTargetTypeEnum.TAX_AGENT.getValue()) + .targetName(tax.getName()) + .creator((long) user.getUID()) + .createTime(now) + .updateTime(now) + .deleteType(0) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .build(); + getAuthResourceMapper().insertIgnoreNull(resourcePO); + }); + } + if (CollectionUtil.isNotEmpty(sobs)) { + sobs.forEach(sob -> { + AuthResourcePO resourcePO = AuthResourcePO.builder() + .id(IdGenerator.generate()) + .roleId(po.getId()) + .target(sob.getId()) + .targetType(ResourceTargetTypeEnum.SOB.getValue()) + .targetName(sob.getName()) + .creator((long) user.getUID()) + .createTime(now) + .updateTime(now) + .deleteType(0) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .build(); + getAuthResourceMapper().insertIgnoreNull(resourcePO); + }); + } + + return po.getId(); + } + + @Override + public void deleteRole(List ids) { + ids.forEach(roleId -> { + AuthRolePO po = getAuthRoleMapper().getById(roleId); + if (po == null) { + throw new SalaryRunTimeException("业务线不存在!"); + } + + getAuthResourceMapper().deleteByRoleId(roleId); + getAuthMemberService(user).deleteByRoleId(roleId); + getAuthOptService(user).deleteByRoleId(roleId); + getAuthDataService(user).deleteByRoleId(roleId); + getAuthRoleMapper().deleteByIds(Collections.singleton(roleId)); + + + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(po.getId() + ""); + loggerContext.setTargetName("业务线:" + po.getName()); + loggerContext.setOperateType(OperateTypeEnum.DELETE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "删除业务线")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "删除业务线")); + loggerContext.setNewValues(po); + SalaryElogConfig.authLinkLoggerTemplate.write(loggerContext); + }); + } + + @Override + public List listAll() { + return getAuthRoleMapper().listAll(); + } +} diff --git a/src/com/engine/salary/service/auth/AuthService.java b/src/com/engine/salary/service/auth/AuthService.java new file mode 100644 index 000000000..95d7e367c --- /dev/null +++ b/src/com/engine/salary/service/auth/AuthService.java @@ -0,0 +1,69 @@ +package com.engine.salary.service.auth; + +import com.engine.salary.entity.auth.dto.AuthTreeDTO; +import com.engine.salary.entity.auth.param.AuthTreeQueryParam; +import com.engine.salary.entity.auth.vo.Permission; +import com.engine.salary.enums.auth.AuthFilterTypeEnum; + +import java.util.List; + +/** + * 权限控制单元 + *

Copyright: Copyright (c) 2024

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public interface AuthService { + + /** + * 单一对象权限识别 + * + * @param t 对象实体 + * @param filterType 数据过滤方式,默认采用“数据&功能权限”方式过滤 + * @param clazz 反射类,需加@Auth注解定义权限项 + * @param 对象泛型 + * @return 是否有权限 + */ + boolean auth(T t, AuthFilterTypeEnum filterType, Class clazz); + + /** + * 对象权限识别 + * + * @param list 对象集合 + * @param filterType <>数据过滤方式,默认采用“数据&功能权限”方式过滤 + * @param clazz 反射类,需加@Auth注解定义权限项 + * @param 对象泛型 + * @return 有权限的对象集合 + */ + List auth(List list, AuthFilterTypeEnum filterType, Class clazz); + + /** + * 对象权限识别 + * + * @param list 对象集合 + * @param filterType 数据过滤方式,默认采用“数据&功能权限”方式过滤 + * @param clazz 反射类,需加@Auth注解定义权限项 + * @param page 页面标识,用于获取权限项 + * @param 对象泛型 + * @return 有权限的对象集合 + */ + List auth(List list, AuthFilterTypeEnum filterType, Class clazz, String page); + + /** + * 单页权限识别 + * + * @param page 页面标识,用于获取权限项 + * @return 权限树 + */ + Permission permission(String page); + + /** + * 权限树 + * + * @param param 查询参数 + * @return 权限树 + */ + AuthTreeDTO tree(AuthTreeQueryParam param); +} diff --git a/src/com/engine/salary/service/auth/AuthServiceImpl.java b/src/com/engine/salary/service/auth/AuthServiceImpl.java new file mode 100644 index 000000000..63277ae39 --- /dev/null +++ b/src/com/engine/salary/service/auth/AuthServiceImpl.java @@ -0,0 +1,362 @@ +package com.engine.salary.service.auth; + +import cn.hutool.core.collection.CollectionUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.annotation.Auth; +import com.engine.salary.entity.auth.dto.*; +import com.engine.salary.entity.auth.param.AuthTreeQueryParam; +import com.engine.salary.entity.auth.vo.Permission; +import com.engine.salary.entity.salarysob.po.SalarySobPO; +import com.engine.salary.enums.auth.AuthCheckTypeEnum; +import com.engine.salary.enums.auth.AuthFilterTypeEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.mapper.auth.AuthMapper; +import com.engine.salary.service.SalarySobService; +import com.engine.salary.service.TaxAgentService; +import com.engine.salary.service.impl.SalarySobServiceImpl; +import com.engine.salary.service.impl.TaxAgentServiceImpl; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.db.MapperProxyFactory; +import com.google.common.collect.Lists; +import weaver.hrm.User; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.*; + +public class AuthServiceImpl extends Service implements AuthService { + + private TaxAgentService getTaxAgentService(User user) { + return ServiceUtil.getService(TaxAgentServiceImpl.class, user); + } + + private SalarySobService getSalarySobService(User user) { + return ServiceUtil.getService(SalarySobServiceImpl.class, user); + } + + private AuthRoleService getAuthRoleService(User user) { + return ServiceUtil.getService(AuthRoleServiceImpl.class, user); + } + + private AuthMapper getAuthMapper() { + return MapperProxyFactory.getProxy(AuthMapper.class); + } + + @Override + public boolean auth(T t, AuthFilterTypeEnum filterType, Class clazz) { + List list = new ArrayList(); + list.add(t); + list = auth(list, filterType, clazz, null); + return list.size() > 0; + } + + @Override + public List auth(List list, AuthFilterTypeEnum filterType, Class clazz) { + return auth(list, filterType, clazz, null); + } + + @Override + public List auth(List list, AuthFilterTypeEnum filterType, Class clazz, String page) { + Boolean isOpenDevolution = getTaxAgentService(user).isOpenDevolution(); + boolean isAuth = clazz.isAnnotationPresent(Auth.class); + + Auth auth = clazz.getAnnotation(Auth.class); + String taxAgentIdField = auth.taxAgentIdField(); + String taxAgentIdFieldGetter = "get" + taxAgentIdField.substring(0, 1).toUpperCase() + taxAgentIdField.substring(1); + String employeeIdField = auth.employeeIdField(); + String employeeIdFieldGetter = "get" + employeeIdField.substring(0, 1).toUpperCase() + employeeIdField.substring(1); + String sobIdField = auth.sobIdField(); + String sobIdFieldGetter = "get" + sobIdField.substring(0, 1).toUpperCase() + sobIdField.substring(1); + String optsField = auth.optsField(); + String optsFieldGetter = "get" + optsField.substring(0, 1).toUpperCase() + optsField.substring(1); + String optsFieldSetter = "set" + optsField.substring(0, 1).toUpperCase() + optsField.substring(1); + + //不开启分权 + if (!isOpenDevolution) { + if (filterType == AuthFilterTypeEnum.DATA_OPT) { + list.forEach(t -> { + try { + Method optsFieldGetterMethod = t.getClass().getMethod(optsFieldGetter); + Set opts = (Set) optsFieldGetterMethod.invoke(t); + if (opts == null) { + opts = new HashSet<>(); + } + opts.add("query"); + opts.add("admin"); + + Method optsFieldSetterMethod = t.getClass().getMethod(optsFieldSetter, Set.class); + optsFieldSetterMethod.invoke(t, opts); + } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) { + throw new SalaryRunTimeException(e); + } + }); + } + return list; + } + + //未配置分权 + if (!isAuth) { + return list; + } + + //给总管理员赋值最大权限 + Boolean isChief = getTaxAgentService(user).isChief((long) user.getUID()); + if (isChief || filterType == AuthFilterTypeEnum.NO_AUTH) { + if (filterType == AuthFilterTypeEnum.DATA_OPT) { + list.forEach(t -> { + try { + Method optsFieldGetterMethod = t.getClass().getMethod(optsFieldGetter); + Set opts = (Set) optsFieldGetterMethod.invoke(t); + if (opts == null) { + opts = new HashSet<>(); + } + opts.add("query"); + opts.add("admin"); + + Method optsFieldSetterMethod = t.getClass().getMethod(optsFieldSetter, Set.class); + optsFieldSetterMethod.invoke(t, opts); + } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) { + throw new SalaryRunTimeException(e); + } + }); + } + return list; + } + + List resultList = new ArrayList<>(); + + page = page == null ? auth.page() : page; + AuthCheckTypeEnum checkType = auth.checkType(); + + //给各管理员赋值对应的扣缴义务人权限 + List adminTaxAgentIds = getTaxAgentService(user).getAdminTaxAgentIds((long) user.getUID()); + if (CollectionUtil.isNotEmpty(adminTaxAgentIds)) { + Iterator iterator = list.iterator(); + if (checkType == AuthCheckTypeEnum.TAX || checkType == AuthCheckTypeEnum.TAX_EMP) { + while (iterator.hasNext()) { + try { + T t = iterator.next(); + Method taxAgentIdFieldGetterMethod = t.getClass().getMethod(taxAgentIdFieldGetter); + Long taxAgentId = (Long) taxAgentIdFieldGetterMethod.invoke(t); + + if (adminTaxAgentIds.contains(taxAgentId)) { + if (filterType == AuthFilterTypeEnum.DATA_OPT) { + Method optsFieldGetterMethod = t.getClass().getMethod(optsFieldGetter); + Set opts = (Set) optsFieldGetterMethod.invoke(t); + if (opts == null) { + opts = new HashSet<>(); + } + opts.add("query"); + opts.add("admin"); + + Method optsFieldSetterMethod = t.getClass().getMethod(optsFieldSetter, Set.class); + optsFieldSetterMethod.invoke(t, opts); + } + resultList.add(t); + } + } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) { + throw new SalaryRunTimeException(e); + } + } + } else if (checkType == AuthCheckTypeEnum.SOB) { + List salarySobPOS = getSalarySobService(user).listByTaxAgentIds(adminTaxAgentIds); + Set adminSobIds = SalaryEntityUtil.properties(salarySobPOS, SalarySobPO::getId); + while (iterator.hasNext()) { + try { + T t = iterator.next(); + Method sobIdFieldGetterMethod = t.getClass().getMethod(sobIdFieldGetter); + Long sobId = (Long) sobIdFieldGetterMethod.invoke(t); + if (adminSobIds.contains(sobId)) { + if (filterType == AuthFilterTypeEnum.DATA_OPT) { + Method optsFieldGetterMethod = t.getClass().getMethod(optsFieldGetter); + Set opts = (Set) optsFieldGetterMethod.invoke(t); + if (opts == null) { + opts = new HashSet<>(); + } + opts.add("query"); + opts.add("admin"); + + Method optsFieldSetterMethod = t.getClass().getMethod(optsFieldSetter, Set.class); + optsFieldSetterMethod.invoke(t, opts); + } + resultList.add(t); + } + } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) { + throw new SalaryRunTimeException(e); + } + } + } + } + + list.removeAll(resultList); + + //给各角色赋权 + try { + Iterator iterator = list.iterator(); + if (checkType == AuthCheckTypeEnum.TAX_EMP) { + + List authDTOS = getAuthMapper().getTaxEmpOptAuth((long) user.getUID(), page); + Map> authMap = SalaryEntityUtil.convert2Map(authDTOS, TaxEmpOptAuth::getTaxAgentId, TaxEmpOptAuth::getEmps); + + while (iterator.hasNext()) { + T t = iterator.next(); + //混合验证 + Method taxAgentIdFieldGetterMethod = t.getClass().getMethod(taxAgentIdFieldGetter); + Long taxAgentId = (Long) taxAgentIdFieldGetterMethod.invoke(t); + Method employeeIdFieldGetterMethod = t.getClass().getMethod(employeeIdFieldGetter); + Long employeeId = (Long) employeeIdFieldGetterMethod.invoke(t); + + if (authMap.containsKey(taxAgentId)) { + List orDefault = authMap.getOrDefault(taxAgentId, new ArrayList<>()); + Map> optsMap = SalaryEntityUtil.convert2Map(orDefault, EmpOpt::getEmployeeId, EmpOpt::getOpts); + if (optsMap.containsKey(employeeId)) { + Set optSets = optsMap.getOrDefault(employeeId, new HashSet<>()); + if (filterType == AuthFilterTypeEnum.DATA_OPT) { + Method optsFieldGetterMethod = t.getClass().getMethod(optsFieldGetter); + Set opts = (Set) optsFieldGetterMethod.invoke(t); + if (opts == null) { + opts = new HashSet<>(); + } + opts.addAll(optSets); + + Method optsFieldSetterMethod = t.getClass().getMethod(optsFieldSetter, Set.class); + optsFieldSetterMethod.invoke(t, opts); + resultList.add(t); + } + if (filterType == AuthFilterTypeEnum.QUERY_DATA) { + resultList.add(t); + } + if (filterType == AuthFilterTypeEnum.ADMIN_DATA) { + if (optSets.contains("admin")) { + resultList.add(t); + } + } + } + } + } + } else if (checkType == AuthCheckTypeEnum.SOB) { + List sobOptAuth = getAuthMapper().getSobOptAuth((long) user.getUID(), page); + Map> sobOpts = SalaryEntityUtil.convert2Map(sobOptAuth, SobOptAuth::getSobId, SobOptAuth::getOpts); + while (iterator.hasNext()) { + T t = iterator.next(); + Method sobIdFieldGetterMethod = t.getClass().getMethod(sobIdFieldGetter); + Long sobId = (Long) sobIdFieldGetterMethod.invoke(t); + + if (sobOpts.containsKey(sobId)) { + Set optSets = sobOpts.getOrDefault(sobId, new HashSet<>()); + if (filterType == AuthFilterTypeEnum.DATA_OPT) { + Method optsFieldGetterMethod = t.getClass().getMethod(optsFieldGetter); + Set opts = (Set) optsFieldGetterMethod.invoke(t); + if (opts == null) { + opts = new HashSet<>(); + } + opts.addAll(optSets); + + Method optsFieldSetterMethod = t.getClass().getMethod(optsFieldSetter, Set.class); + optsFieldSetterMethod.invoke(t, opts); + resultList.add(t); + } + if (filterType == AuthFilterTypeEnum.QUERY_DATA) { + resultList.add(t); + } + if (filterType == AuthFilterTypeEnum.ADMIN_DATA) { + if (optSets.contains("admin")) { + resultList.add(t); + } + } + } + } + } else if (checkType == AuthCheckTypeEnum.TAX) { + List authDTOS = getAuthMapper().getTaxOptAuth((long) user.getUID(), page); + Map> taxOpts = SalaryEntityUtil.convert2Map(authDTOS, TaxOptAuth::getTaxAgentId, TaxOptAuth::getOpts); + + while (iterator.hasNext()) { + T t = iterator.next(); + Method taxAgentIdFieldGetterMethod = t.getClass().getMethod(taxAgentIdFieldGetter); + Long taxAgentId = (Long) taxAgentIdFieldGetterMethod.invoke(t); + + if (taxOpts.containsKey(taxAgentId)) { + Set optSets = taxOpts.getOrDefault(taxAgentId, new HashSet<>()); + if (filterType == AuthFilterTypeEnum.DATA_OPT) { + Method optsFieldGetterMethod = t.getClass().getMethod(optsFieldGetter); + Set opts = (Set) optsFieldGetterMethod.invoke(t); + if (opts == null) { + opts = new HashSet<>(); + } + opts.addAll(optSets); + + Method optsFieldSetterMethod = t.getClass().getMethod(optsFieldSetter, Set.class); + optsFieldSetterMethod.invoke(t, opts); + resultList.add(t); + } + if (filterType == AuthFilterTypeEnum.QUERY_DATA) { + resultList.add(t); + } + if (filterType == AuthFilterTypeEnum.ADMIN_DATA) { + if (optSets.contains("admin")) { + resultList.add(t); + } + } + } + } + } + } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) { + throw new SalaryRunTimeException(e); + } + return resultList; + } + + @Override + public Permission permission(String page) { + long uid = user.getUID(); + List opts = new ArrayList<>(); + + //获取是否开启分权模式 + Boolean isOpenDevolution = getTaxAgentService(user).isOpenDevolution(); + //给总管理员赋值最大权限 + Boolean isChief = getTaxAgentService(user).isChief(uid); + //给各管理员赋值对应的扣缴义务人权限 + Boolean isAdminEnable = getTaxAgentService(user).isAdminEnable(uid); + + boolean able = false; + + //不需要鉴权的页面 + List noAuthPage = Lists.newArrayList("myBill"); + + //只允许总管理进去的界面 + List chiefPage = Lists.newArrayList("auth"); + + if (noAuthPage.contains(page)) { + opts.add("admin"); + able = true; + } else if (chiefPage.contains(page)) { + opts.add("admin"); + able = isChief; + } else { + //如果是管理员,赋值管理权限返回 + if (isChief || isAdminEnable) { + opts.add("admin"); + able = true; + } else { + opts = getAuthMapper().getOptsByPage(uid, page); + able = CollectionUtil.isNotEmpty(opts); + } + } + + return Permission.builder() + .isOpenDevolution(isOpenDevolution) + .isChief(isChief) + .isAdminEnable(isAdminEnable) + .able(able) + .opts(opts) + .build(); + } + + @Override + public AuthTreeDTO tree(AuthTreeQueryParam param) { + AuthTreeDTO authTreeDTO = getAuthMapper().authTree(param); + return authTreeDTO; + } + +} diff --git a/src/com/engine/salary/service/impl/AddUpDeductionServiceImpl.java b/src/com/engine/salary/service/impl/AddUpDeductionServiceImpl.java new file mode 100644 index 000000000..2f79bb800 --- /dev/null +++ b/src/com/engine/salary/service/impl/AddUpDeductionServiceImpl.java @@ -0,0 +1,1166 @@ +package com.engine.salary.service.impl; + +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.NumberUtil; +import com.api.browser.bean.SearchConditionGroup; +import com.api.browser.bean.SearchConditionItem; +import com.api.browser.util.ConditionFactory; +import com.api.browser.util.ConditionType; +import com.api.formmode.mybatis.util.SqlProxyHandle; +import com.cloudstore.dev.api.util.Util_DataCache; +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.hrmelog.entity.dto.LoggerContext; +import com.engine.salary.biz.AddUpDeductionBiz; +import com.engine.salary.config.SalaryElogConfig; +import com.engine.salary.encrypt.EncryptUtil; +import com.engine.salary.entity.datacollection.AddUpDeduction; +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.datacollection.dto.AddUpDeductionDTO; +import com.engine.salary.entity.datacollection.dto.AddUpDeductionRecordDTO; +import com.engine.salary.entity.datacollection.param.AddUpDeductionImportParam; +import com.engine.salary.entity.datacollection.param.AddUpDeductionQueryParam; +import com.engine.salary.entity.datacollection.param.AddUpDeductionRecordDeleteParam; +import com.engine.salary.entity.datacollection.param.AddUpDeductionRecordParam; +import com.engine.salary.entity.datacollection.po.SpecialAddDeductionPO; +import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO; +import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO; +import com.engine.salary.entity.salarysob.po.SalarySobPO; +import com.engine.salary.entity.taxagent.dto.TaxAgentManageRangeEmployeeDTO; +import com.engine.salary.entity.taxagent.param.TaxAgentQueryParam; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import com.engine.salary.enums.OperateTypeEnum; +import com.engine.salary.enums.UserStatusEnum; +import com.engine.salary.enums.auth.AuthFilterTypeEnum; +import com.engine.salary.enums.salaryaccounting.SalaryAcctRecordStatusEnum; +import com.engine.salary.enums.salarysob.IncomeCategoryEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.mapper.datacollection.AddUpDeductionMapper; +import com.engine.salary.mapper.sys.SalarySysConfMapper; +import com.engine.salary.service.*; +import com.engine.salary.service.auth.AuthService; +import com.engine.salary.service.auth.AuthServiceImpl; +import com.engine.salary.sys.entity.po.SalarySysConfPO; +import com.engine.salary.sys.entity.vo.OrderRuleVO; +import com.engine.salary.sys.service.SalarySysConfService; +import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl; +import com.engine.salary.util.SalaryDateUtil; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.db.MapperProxyFactory; +import com.engine.salary.util.excel.ExcelComment; +import com.engine.salary.util.excel.ExcelParseHelper; +import com.engine.salary.util.excel.ExcelSupport; +import com.engine.salary.util.excel.ExcelUtil; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.util.page.SalaryPageUtil; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.Validate; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.util.IOUtils; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import weaver.file.ImageFileManager; +import weaver.general.Util; +import weaver.hrm.User; + +import java.io.InputStream; +import java.math.BigDecimal; +import java.text.SimpleDateFormat; +import java.time.*; +import java.util.*; +import java.util.stream.Collectors; + +import static com.engine.salary.constant.SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY; +import static com.engine.salary.util.excel.ExcelSupport.EXCEL_TYPE_XLSX; + +/** + * 累计专项 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class AddUpDeductionServiceImpl extends Service implements AddUpDeductionService { + private EncryptUtil encryptUtil = new EncryptUtil(); + + private AddUpDeductionMapper getAddUpDeductionMapper() { + return MapperProxyFactory.getProxy(AddUpDeductionMapper.class); + } + + private TaxAgentService getTaxAgentService(User user) { + return ServiceUtil.getService(TaxAgentServiceImpl.class, user); + } + + private SalaryAcctRecordService getSalaryAcctRecordService(User user) { + return ServiceUtil.getService(SalaryAcctRecordServiceImpl.class, user); + } + + private SalaryAcctEmployeeService getSalaryAcctEmployeeService(User user) { + return ServiceUtil.getService(SalaryAcctEmployeeServiceImpl.class, user); + } + + private SalaryEmployeeService getSalaryEmployeeService(User user) { + return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user); + } + + private SalarySysConfMapper getSalarySysConfMapper() { + return SqlProxyHandle.getProxy(SalarySysConfMapper.class); + } + + private SalarySysConfService getSalarySysConfService(User user) { + return ServiceUtil.getService(SalarySysConfServiceImpl.class, user); + } + + private SpecialAddDeductionService getSpecialAddDeductionService(User user) { + return ServiceUtil.getService(SpecialAddDeductionServiceImpl.class, user); + } + + public AuthService getAuthService(User user) { + return ServiceUtil.getService(AuthServiceImpl.class, user); + } + + + private SalarySobService getSalarySobService(User user) { + return ServiceUtil.getService(SalarySobServiceImpl.class, user); + } + + @Override + public Map getSearchCondition(Map params) { + Map apidatas = new HashMap(); + ConditionFactory conditionFactory = new ConditionFactory(user); + + //条件组 + List addGroups = new ArrayList(); + + List conditionItems = new ArrayList(); + + //文本输入框 + SearchConditionItem username = conditionFactory.createCondition(ConditionType.INPUT, 25034, "username"); + username.setInputType("input"); + username.setColSpan(2); + username.setFieldcol(16); + username.setLabelcol(8); + username.setViewAttr(2); + username.setLabel("姓名"); + conditionItems.add(username); + + + SearchConditionItem departmentName = conditionFactory.createCondition(ConditionType.BROWSER, 502227, "departmentIds", "57"); + departmentName.setInputType("browser"); + departmentName.setColSpan(2); + departmentName.setFieldcol(16); + departmentName.setLabelcol(8); + departmentName.setViewAttr(2); + departmentName.setIsQuickSearch(false); + departmentName.setLabel("部门"); + conditionItems.add(departmentName); + + + SearchConditionItem jobNum = conditionFactory.createCondition(ConditionType.INPUT, 25034, "jobNum"); + jobNum.setInputType("input"); + jobNum.setColSpan(2); + jobNum.setFieldcol(16); + jobNum.setLabelcol(8); + jobNum.setViewAttr(2); + jobNum.setLabel("工号"); + conditionItems.add(jobNum); + + addGroups.add(new SearchConditionGroup("常用条件", true, conditionItems)); + + apidatas.put("condition", addGroups); + return apidatas; + } + + + @Override + public Map importAddUpDeduction(AddUpDeductionImportParam importParam) { + long currentEmployeeId = user.getUID(); + Boolean openDevolution = getTaxAgentService(user).isOpenDevolution(); + + Map apidatas = new HashMap(); + AddUpDeductionBiz addUpDeductionBiz = new AddUpDeductionBiz(); + + //检验参数 + checkImportParam(importParam); + + //税款所属期 + String declareMonthStr = importParam.getDeclareMonth(); + //excel文件id + String imageId = Util.null2String(importParam.getImageId()); + Validate.notBlank(imageId, "imageId为空"); + // 获取所有个税扣缴义务人 + Collection taxAgentList = getTaxAgentService(user).listTaxAgentAndEmployeeTree(currentEmployeeId); + //个税扣缴义务人 + String taxAgentId = Util.null2String(importParam.getTaxAgentId()); + // 获取租户下所有的人员 + List employees = getSalaryEmployeeService(user).listEmployee(); + // 已经核算过的不可操作 + // 获取已经核算的数据 + List salaryAcctEmployees = getAccountedEmployeeDataByTaxYearMonth(declareMonthStr); + // 查询已有数据 + Date declareMonth = SalaryDateUtil.localDateToDate(LocalDate.parse(declareMonthStr + "-01", SalaryDateUtil.DATE_FORMATTER)); + List list = getAddUpDeductionMapper().listSome(AddUpDeduction.builder().declareMonth(declareMonth).build()); + + //查询对于人员信息导入筛选的全局配置 + SalarySysConfPO salarySysConfPO = getSalarySysConfMapper().getOneByCode("matchEmployeeMode"); + String confValue = (salarySysConfPO != null && salarySysConfPO.getConfValue() != null && !"".equals(salarySysConfPO.getConfValue())) ? salarySysConfPO.getConfValue() : "0"; + + InputStream fileInputStream = null; + try { + fileInputStream = ImageFileManager.getInputStreamById(Integer.parseInt(imageId)); + List addUpDeductions = ExcelParseHelper.parse2Map(fileInputStream, AddUpDeductionDTO.class, 0, 1, 14, "addUpDeductionTemplate.xlsx"); + + int total = addUpDeductions.size(); + int index = 0; + int successCount = 0; + int errorCount = 0; + + // 错误excel内容 + List errorData = new ArrayList<>(); + //合规数据 + List eligibleData = new ArrayList<>(); + + List taxAgentEmployees = Lists.newArrayList(); + for (int i = 0; i < addUpDeductions.size(); i++) { + + AddUpDeductionDTO dto = addUpDeductions.get(i); + + Date now = new Date(); + //待插入数据库对象 + AddUpDeduction addUpDeduction = AddUpDeduction.builder().tenantKey(DEFAULT_TENANT_KEY).createTime(now).updateTime(now).creator((long) user.getUID()).declareMonth(declareMonth).build(); + + //异常点数量 + int errorSum = 0; + + //行号 + String rowIndex = String.format("第%s行", i + 2); + + //相同的姓名 + String userName = dto.getUsername(); + String deparmentName = dto.getDepartmentName(); + String mobile = dto.getMobile(); + String workcode = dto.getJobNum(); + String idNo = dto.getIdNo(); + + //筛选导入人员信息可以在人力资源池中匹配到的人员信息 + List employeeSameIds = getSalaryEmployeeService(user).matchImportEmployee(confValue, employees, userName, deparmentName, mobile, workcode, idNo, null); + + if (StringUtils.isBlank(userName) && "0".equals(confValue)) { + //姓名 不能为空 + //错误消息对象 + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowIndex + "姓名不能为空"); + errorData.add(errorMessageMap); + errorSum += 1; + } else if (CollectionUtils.isEmpty(employeeSameIds)) { + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowIndex + "员工信息不存在"); + errorData.add(errorMessageMap); + errorSum += 1; + } else if (employeeSameIds.size() > 1) { + //存在离职和在职状态取在职状态 + employeeSameIds = employeeSameIds.stream().filter(e -> UserStatusEnum.getNormalStatus().contains(e.getStatus())).collect(Collectors.toList()); + if (employeeSameIds.size() != 1) { + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowIndex + "员工信息不存在或者存在多个员工"); + errorData.add(errorMessageMap); + errorSum += 1; + } else { + Long employeeId = CollectionUtils.isNotEmpty(employeeSameIds) && employeeSameIds.size() == 1 ? employeeSameIds.get(0).getEmployeeId() : null; + addUpDeduction.setEmployeeId(employeeId); + } + } else { + Long employeeId = CollectionUtils.isNotEmpty(employeeSameIds) && employeeSameIds.size() == 1 ? employeeSameIds.get(0).getEmployeeId() : null; + if (employeeId != null && employeeId > 0) { + addUpDeduction.setEmployeeId(employeeId); + } else { + //姓名错误,系统内不存在该姓名 + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowIndex + "姓名错误,系统内不存在该姓名"); + errorData.add(errorMessageMap); + errorSum += 1; + } + } + + + String taxAgentName = dto.getTaxAgentName(); + if (StringUtils.isBlank(taxAgentName)) { + //个税扣缴义务人不能为空 + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowIndex + "个税扣缴义务人不能为空"); + errorData.add(errorMessageMap); + errorSum += 1; + } else { + Optional optionalTemp = taxAgentList.stream().filter(m -> m.getTaxAgentName().equals(taxAgentName)).findFirst(); + if (optionalTemp.isPresent()) { + if (StringUtils.isNotEmpty(taxAgentId) && !optionalTemp.get().getTaxAgentId().equals(Long.valueOf(taxAgentId))) { + //个税扣缴义务人与导入时选择的不一致 + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowIndex + "个税扣缴义务人与导入时选择的不一致"); + errorData.add(errorMessageMap); + errorSum += 1; + } else { + addUpDeduction.setTaxAgentId(optionalTemp.get().getTaxAgentId()); + taxAgentEmployees = optionalTemp.get().getEmployeeList(); + } + } else { + //个税扣缴义务人不存在 + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowIndex + "个税扣缴义务人不存在或不在权限范围内"); + errorData.add(errorMessageMap); + errorSum += 1; + } + } + + + //fixme 分权判断 +// if (openDevolution) { +// Optional optionalTaxAgentEmp = taxAgentEmployees.stream().filter(f -> f.getEmployeeId().equals(addUpDeduction.getEmployeeId())).findFirst(); +// if (!optionalTaxAgentEmp.isPresent()) { +// Map errorMessageMap = Maps.newHashMap(); +// errorMessageMap.put("message", rowIndex + "该条数据不在个税扣缴义务人人员范围内,不可导入"); +// errorData.add(errorMessageMap); +// errorSum += 1; +// } +// } + + // 判断是否有核算过 + if (CollectionUtils.isNotEmpty(salaryAcctEmployees)) { + Optional optionalAcctEmp = salaryAcctEmployees.stream().filter(f -> f.getEmployeeId().equals(addUpDeduction.getEmployeeId()) && f.getTaxAgentId().equals(addUpDeduction.getTaxAgentId())).findFirst(); + boolean isExist = list.stream().anyMatch(f -> f.getEmployeeId().equals(addUpDeduction.getEmployeeId()) && f.getTaxAgentId().equals(addUpDeduction.getTaxAgentId())); + if (optionalAcctEmp.isPresent() && isExist) { + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowIndex + "该年月这条数据已经核算过,不可导入"); + errorData.add(errorMessageMap); + errorSum += 1; + } + } + //累计子女教育 + String addUpChildEducation = dto.getAddUpChildEducation(); + addUpDeduction.setAddUpChildEducation(Util.null2String(addUpChildEducation)); + //累计继续教育 + String addUpContinuingEducation = dto.getAddUpContinuingEducation(); + addUpDeduction.setAddUpContinuingEducation(Util.null2String(addUpContinuingEducation)); + //累计住房贷款利息 + String addUpHousingLoanInterest = dto.getAddUpHousingLoanInterest(); + addUpDeduction.setAddUpHousingLoanInterest(Util.null2String(addUpHousingLoanInterest)); + //累计住房租金 + String addUpHousingRent = dto.getAddUpHousingRent(); + addUpDeduction.setAddUpHousingRent(Util.null2String(addUpHousingRent)); + //累计赡养老人 + String addUpSupportElderly = dto.getAddUpSupportElderly(); + addUpDeduction.setAddUpSupportElderly(Util.null2String(addUpSupportElderly)); + addUpDeduction.setAddUpIllnessMedical(Util.null2String(dto.getAddUpIllnessMedical())); + addUpDeduction.setAddUpInfantCare(Util.null2String(dto.getAddUpInfantCare())); + if (errorSum == 0) { + successCount += 1; + // 合格数据 + eligibleData.add(addUpDeduction); + } else { + errorCount += 1; + // 添加错误数据 + } + } + //入库 + handleImportData(eligibleData); + apidatas.put("successCount", successCount); + apidatas.put("errorCount", errorCount); + apidatas.put("errorData", errorData); + } finally { + IOUtils.closeQuietly(fileInputStream); + } + return apidatas; + } + + public void handleImportData(List pos) { + if (CollectionUtils.isEmpty(pos)) { + return; + } + AddUpDeductionBiz addUpDeductionBiz = new AddUpDeductionBiz(); + AddUpDeduction po = pos.get(0); + // 多条相同人的则以第一条为准,如果逆序排列(用于重复的则以最后一条为准)Collections.reverse(pos); + // 去重(通过记录的唯一条件(申报月份,人员id,个税扣缴义务人id)拼接) + List finalPos = pos.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(f -> f.getEmployeeId() + "-" + f.getTaxAgentId()))), ArrayList::new)); + // 查询已有数据 + List list = addUpDeductionBiz.listSome(AddUpDeduction.builder().declareMonth(po.getDeclareMonth()).build()); + // 待修改的 本地已存在则更新【交集】 + List updateList = list.stream().map(m -> { + Optional optional = finalPos.stream().filter(p -> (p.getEmployeeId() + "-" + p.getTaxAgentId()).equals(m.getEmployeeId() + "-" + m.getTaxAgentId())).findFirst(); + AddUpDeduction temp = null; + if (optional.isPresent()) { + temp = optional.get(); + // 换成本地库的id + temp.setId(m.getId()); + } + return temp; + }).filter(Objects::nonNull).collect(Collectors.toList()); + // 待新增的 导入比本地多,则新增【差集(导入 - local)】 + List saveList = finalPos.stream().map(m -> { + Optional optional = list.stream().filter(p -> (p.getEmployeeId() + "-" + p.getTaxAgentId()).equals(m.getEmployeeId() + "-" + m.getTaxAgentId())).findFirst(); + AddUpDeduction temp = null; + if (!optional.isPresent()) { + temp = m; + } + return temp; + }).filter(Objects::nonNull).collect(Collectors.toList()); + + // 修改 + if (CollectionUtils.isNotEmpty(updateList)) { + addUpDeductionBiz.batchUpdate(updateList); + } + // 保存 + if (CollectionUtils.isNotEmpty(saveList)) { + addUpDeductionBiz.batchSave(saveList); + } + + // 记录操作日志 + // 根据月份、人员id查出保存的数据 + List empIds = saveList.stream().map(AddUpDeduction::getEmployeeId).collect(Collectors.toList()); + List insertList = addUpDeductionBiz.listSome(AddUpDeduction.builder().declareMonth(po.getDeclareMonth()).employeeIds(empIds).build()); + Map insertMap = SalaryEntityUtil.convert2Map(insertList, p -> p.getTaxAgentId() + "-" + SalaryDateUtil.getFormatYearMonth(p.getDeclareMonth()) + "-" + p.getEmployeeId()); + saveList.forEach(save -> { + AddUpDeduction addUpDeduction = insertMap.get(save.getTaxAgentId() + "-" + SalaryDateUtil.getFormatYearMonth(save.getDeclareMonth()) + "-" + save.getEmployeeId()); + if (addUpDeduction != null) { + updateList.add(addUpDeduction); + } + }); + + if (CollectionUtils.isNotEmpty(updateList)) { + String formatYearMonth = SalaryDateUtil.getFormatYearMonth(po.getDeclareMonth()); + LoggerContext loggerContext = new LoggerContext(); + loggerContext.setUser(user); + loggerContext.setTargetName(SalaryI18nUtil.getI18nLabel(0, "累计专项附加扣除 ") + formatYearMonth); + loggerContext.setOperateType(OperateTypeEnum.ADD.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "导入")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "导入累计专项附加扣除 ") + formatYearMonth); + loggerContext.setNewValueList(updateList); + SalaryElogConfig.addUpDeductionLoggerTemplate.write(loggerContext); + } + + } + + @Override + public void editAddUpDeduction(AddUpDeductionRecordParam addUpDeduction) { + AddUpDeductionBiz addUpDeductionBiz = new AddUpDeductionBiz(); + String declareMonthStr = addUpDeduction.getDeclareMonth(); + + AddUpDeduction po = addUpDeductionBiz.getById(addUpDeduction.getId()); + if (po == null) { + throw new SalaryRunTimeException("该数据不存在!"); + } + // 获取所有个税扣缴义务人 + TaxAgentQueryParam param = TaxAgentQueryParam.builder().build(); + param.setFilterType(AuthFilterTypeEnum.ADMIN_DATA); + Collection taxAgentList = getTaxAgentService(user).listAuth(param); + List taxAgentIds = SalaryEntityUtil.properties(taxAgentList, TaxAgentPO::getId, Collectors.toList()); + Long taxAgentId = po.getTaxAgentId(); + if (!taxAgentIds.contains(taxAgentId)) { + //没有编辑权限 + throw new SalaryRunTimeException("该个税扣缴义务人无权限编辑此数据!"); + } + + // 已经核算过的不可操作 + // 获取已经核算的数据 + List salaryAcctEmployees = getAccountedEmployeeDataByTaxYearMonth(declareMonthStr); + // 判断是否有核算过 + if (CollectionUtils.isNotEmpty(salaryAcctEmployees)) { + Optional optionalAcctEmp = salaryAcctEmployees.stream().filter(f -> f.getEmployeeId().equals(addUpDeduction.getEmployeeId()) && f.getTaxAgentId().equals(addUpDeduction.getTaxAgentId())).findFirst(); + if (optionalAcctEmp.isPresent()) { + throw new SalaryRunTimeException("该年月这条数据已经核算过,不可进行编辑!"); + } + } + ArrayList updateList = new ArrayList<>(); + AddUpDeduction build = AddUpDeduction.builder().id(addUpDeduction.getId()).addUpChildEducation(addUpDeduction.getAddUpChildEducation()).addUpContinuingEducation(addUpDeduction.getAddUpContinuingEducation()).addUpHousingLoanInterest(addUpDeduction.getAddUpHousingLoanInterest()).addUpHousingRent(addUpDeduction.getAddUpHousingRent()).addUpSupportElderly(addUpDeduction.getAddUpSupportElderly()).addUpIllnessMedical(addUpDeduction.getAddUpIllnessMedical()).addUpInfantCare(addUpDeduction.getAddUpInfantCare()).createTime(new Date()).build(); + updateList.add(build); + addUpDeductionBiz.batchUpdate(updateList); + + // 记录日志 + AddUpDeduction newValue = addUpDeductionBiz.getById(build.getId()); + String name = SalaryI18nUtil.getI18nLabel(0, "编辑"); + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setTargetId(addUpDeduction.getId().toString()); + loggerContext.setTargetName(SalaryI18nUtil.getI18nLabel(0, "累计专项附加扣除") + "-" + addUpDeduction.getId()); + loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue()); + loggerContext.setOperateTypeName(name); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "累计专项附加扣除") + "-" + SalaryI18nUtil.getI18nLabel(0, "编辑")); + loggerContext.setOldValues(po); + loggerContext.setNewValues(newValue); + loggerContext.setUser(user); + SalaryElogConfig.addUpDeductionLoggerTemplate.write(loggerContext); + } + + @Override + public void createAddUpDeduction(AddUpDeductionRecordParam addUpDeductionRecordParam) { + //税款所属期 + String declareMonthStr = addUpDeductionRecordParam.getDeclareMonth(); + if (declareMonthStr.equals("")) { + throw new SalaryRunTimeException("税款所属期不能为空!"); + } + // 获取所有个税扣缴义务人 + TaxAgentQueryParam param = TaxAgentQueryParam.builder().build(); + param.setFilterType(AuthFilterTypeEnum.ADMIN_DATA); + Collection taxAgentList = getTaxAgentService(user).listAuth(param); + // 获取租户下所有的人员 + List employees = getSalaryEmployeeService(user).listEmployee(); + // 已经核算过的不可操作 + // 获取已经核算的数据 + List salaryAcctEmployees = getAccountedEmployeeDataByTaxYearMonth(declareMonthStr); + // 查询已有数据 + Date declareMonth = SalaryDateUtil.localDateToDate(LocalDate.parse(declareMonthStr + "-01", SalaryDateUtil.DATE_FORMATTER)); + List list = getAddUpDeductionMapper().listSome(AddUpDeduction.builder().declareMonth(declareMonth).build()); + + //查询对于人员信息导入筛选的全局配置 + SalarySysConfPO salarySysConfPO = getSalarySysConfMapper().getOneByCode("matchEmployeeMode"); + List insertData = new ArrayList<>(); + Date now = new Date(); + //待插入数据库对象 + AddUpDeduction addUpDeduction = AddUpDeduction.builder().tenantKey(DEFAULT_TENANT_KEY).createTime(now).updateTime(now).creator((long) user.getUID()).declareMonth(declareMonth).build(); + boolean employeeSameId = employees.stream().anyMatch(e -> Objects.equals(e.getEmployeeId(), addUpDeductionRecordParam.getEmployeeId())); + if (!employeeSameId) { + throw new SalaryRunTimeException("员工信息不存在"); + } + addUpDeduction.setEmployeeId(addUpDeductionRecordParam.getEmployeeId()); + + String taxAgentName = addUpDeductionRecordParam.getTaxAgentName(); + if (StringUtils.isBlank(taxAgentName)) { + //个税扣缴义务人不能为空 + throw new SalaryRunTimeException("个税扣缴义务人不能为空"); + } else { + Optional optionalTemp = taxAgentList.stream().filter(m -> m.getName().equals(taxAgentName)).findFirst(); + if (optionalTemp.isPresent()) { + addUpDeduction.setTaxAgentId(optionalTemp.get().getId()); + } else { + //个税扣缴义务人不存在或不在权限范围内 + throw new SalaryRunTimeException("个税扣缴义务人不存在或不在权限范围内"); + } + } + + // 判断是否有核算过 + if (CollectionUtils.isNotEmpty(salaryAcctEmployees)) { + Optional optionalAcctEmp = salaryAcctEmployees.stream().filter(f -> f.getEmployeeId().equals(addUpDeduction.getEmployeeId()) && f.getTaxAgentId().equals(addUpDeduction.getTaxAgentId())).findFirst(); + boolean isExist = list.stream().anyMatch(f -> f.getEmployeeId().equals(addUpDeduction.getEmployeeId()) && f.getTaxAgentId().equals(addUpDeduction.getTaxAgentId())); + if (optionalAcctEmp.isPresent() && isExist) { + throw new SalaryRunTimeException("该年月这条数据已经核算过,不可导入"); + } + } + + //累计子女教育 + String addUpChildEducation = addUpDeductionRecordParam.getAddUpChildEducation(); + addUpDeduction.setAddUpChildEducation(Util.null2String(addUpChildEducation)); + //累计继续教育 + String addUpContinuingEducation = addUpDeductionRecordParam.getAddUpContinuingEducation(); + addUpDeduction.setAddUpContinuingEducation(Util.null2String(addUpContinuingEducation)); + //累计住房贷款利息 + String addUpHousingLoanInterest = addUpDeductionRecordParam.getAddUpHousingLoanInterest(); + addUpDeduction.setAddUpHousingLoanInterest(Util.null2String(addUpHousingLoanInterest)); + //累计住房租金 + String addUpHousingRent = addUpDeductionRecordParam.getAddUpHousingRent(); + addUpDeduction.setAddUpHousingRent(Util.null2String(addUpHousingRent)); + //累计赡养老人 + String addUpSupportElderly = addUpDeductionRecordParam.getAddUpSupportElderly(); + addUpDeduction.setAddUpSupportElderly(Util.null2String(addUpSupportElderly)); + + addUpDeduction.setAddUpIllnessMedical(Util.null2String(addUpDeductionRecordParam.getAddUpIllnessMedical())); + addUpDeduction.setAddUpInfantCare(Util.null2String(addUpDeductionRecordParam.getAddUpInfantCare())); + insertData.add(addUpDeduction); + //入库 + handleImportData(insertData); + } + + private void addLogger4Insert(Integer currentEmployeeId, AddUpDeduction addUpDeduction, String targetName) { + String name = SalaryI18nUtil.getI18nLabel(0, "新增") + SalaryI18nUtil.getI18nLabel(0, "累计专项附加扣除"); + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setTargetId(addUpDeduction.getId().toString()); + loggerContext.setTargetName(targetName); + loggerContext.setOperateType(OperateTypeEnum.ADD.getValue()); + loggerContext.setOperateTypeName(name); + loggerContext.setOperatedesc(name); + loggerContext.setNewValues(addUpDeduction); + loggerContext.setOperator(currentEmployeeId.toString()); + SalaryElogConfig.addUpDeductionLoggerTemplate.write(loggerContext); + } + + @Override + public void deleteSelectAddUpDeduction(AddUpDeductionRecordDeleteParam deleteParam) { + long currentEmployeeId = user.getUID(); + // 获取所有个税扣缴义务人 + Collection taxAgentList = getTaxAgentService(user).listTaxAgentAndEmployeeTree(currentEmployeeId); + AddUpDeductionBiz addUpDeductionBiz = new AddUpDeductionBiz(); + String declareMonthStr = deleteParam.getDeclareMonth(); + List deleteIds = deleteParam.getIds(); + // 已经核算过的不可操作 + // 获取已经核算的数据 + List salaryAcctEmployees = getAccountedEmployeeDataByTaxYearMonth(declareMonthStr); + // 判断是否有核算过 + List deleteList = new ArrayList<>(); + ArrayList oldAddUpDeductions = new ArrayList<>(); + for (int i = 0; i < deleteIds.size(); i++) { + Long id = deleteIds.get(i); + AddUpDeduction byId = addUpDeductionBiz.getById(id); + + if (byId == null) { + throw new SalaryRunTimeException("数据不存在或已被删除!"); + } + // 判断是否在个税扣缴义务人范围内 + Optional first = taxAgentList.stream().filter(m -> Objects.equals(m.getTaxAgentId(), byId.getTaxAgentId())).findFirst(); + if (!first.isPresent()) { + throw new SalaryRunTimeException("个税扣缴义务人不存在或不在权限范围内"); + } + // 判断用户是否存在 + if (CollectionUtils.isNotEmpty(salaryAcctEmployees)) { + Optional optionalAcctEmp = salaryAcctEmployees.stream().filter(f -> f.getEmployeeId().equals(byId.getEmployeeId()) && f.getTaxAgentId().equals(byId.getTaxAgentId())).findFirst(); + if (optionalAcctEmp.isPresent()) { + throw new SalaryRunTimeException("所选数据在该年月中已完成核算并归档,不可进行删除!"); + } + } + deleteList.add(byId.getId()); + oldAddUpDeductions.add(byId); + } + addUpDeductionBiz.batchDeleteByIDS(deleteList); + + //记录日志 + if (CollectionUtils.isNotEmpty(oldAddUpDeductions)) { + oldAddUpDeductions.stream().forEach(e -> { + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setTargetId(e.getId().toString()); + loggerContext.setTargetName(SalaryI18nUtil.getI18nLabel(0, "累计专项附加扣除") + "-" + e.getId()); + loggerContext.setOperateType(OperateTypeEnum.DELETE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "删除")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "累计专项附加扣除") + "-" + SalaryI18nUtil.getI18nLabel(0, "删除")); + loggerContext.setOldValues(e); + loggerContext.setUser(user); + SalaryElogConfig.addUpDeductionLoggerTemplate.write(loggerContext); + }); + } + } + + @Override + public void deleteAllAddUpDeduction(AddUpDeductionRecordDeleteParam deleteParam) { + String declareMonthStr = deleteParam.getDeclareMonth(); + long currentEmployeeId = user.getUID(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + // 获取所有个税扣缴义务人 + TaxAgentQueryParam param = TaxAgentQueryParam.builder().build(); + param.setFilterType(AuthFilterTypeEnum.ADMIN_DATA); + Collection taxAgentList = getTaxAgentService(user).listAuth(param); + List taxAgentIds = SalaryEntityUtil.properties(taxAgentList, TaxAgentPO::getId, Collectors.toList()); + AddUpDeductionBiz addUpDeductionBiz = new AddUpDeductionBiz(); + ArrayList declareMonthDate = new ArrayList<>(); + try { + declareMonthDate.add(sdf.parse(declareMonthStr + "-01")); + } catch (Exception e) { + throw new SalaryRunTimeException("日期异常"); + } + AddUpDeductionQueryParam queryParam = null; + if (deleteParam.getTaxAgentId() != null && (!deleteParam.getTaxAgentId().equals(""))) { + // 设置了个税扣缴义务人 + Long taxAgentId = SalaryEntityUtil.string2Long(deleteParam.getTaxAgentId()); + ArrayList tai = new ArrayList<>(); + tai.add(taxAgentId); + queryParam = AddUpDeductionQueryParam.builder().declareMonthDate(declareMonthDate).taxAgentIds(tai).build(); + } else { + queryParam = AddUpDeductionQueryParam.builder().declareMonthDate(declareMonthDate).taxAgentIds(taxAgentIds).build(); + } + // 获取所有想要删除的数据 + queryParam.setFilterType(AuthFilterTypeEnum.ADMIN_DATA); + List list = listAuth(queryParam); + + // 获取已经核算的数据 + List salaryAcctEmployees = getAccountedEmployeeDataByTaxYearMonth(declareMonthStr); + for (AddUpDeductionDTO item : list) { + if (CollectionUtils.isNotEmpty(salaryAcctEmployees)) { + Optional optionalAcctEmp = salaryAcctEmployees.stream().filter(f -> f.getEmployeeId().equals(item.getEmployeeId()) && f.getTaxAgentId().equals(item.getTaxAgentId())).findFirst(); + if (optionalAcctEmp.isPresent()) { + throw new SalaryRunTimeException("员工:" + item.getUsername() + ",在该年月中已完成核算并归档,不能进行一键清空!"); + } + } + } + List deleteIds = list.stream().map(AddUpDeductionDTO::getId).collect(Collectors.toList()); + addUpDeductionBiz.batchDeleteByIDS(deleteIds); + + // 记录日志 + Collection finalTaxAgentIds = queryParam.getTaxAgentIds(); + List taxAgentNames = taxAgentList.stream().filter(t -> finalTaxAgentIds.contains(t.getId())).map(TaxAgentPO::getName).collect(Collectors.toList()); + String name = declareMonthStr + " " + StringUtils.join(taxAgentNames, ","); + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetName(name); + loggerContext.setOperateType(OperateTypeEnum.CLEAR.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "一键清空")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "累计专项附加扣除") + "-" + SalaryI18nUtil.getI18nLabel(0, "一键清空:") + name); + SalaryElogConfig.addUpDeductionLoggerTemplate.write(loggerContext); + } + + @Override + public AddUpDeductionRecordDTO getAddUpDeduction(AddUpDeductionQueryParam param) { + ArrayList ids = new ArrayList<>(); + ids.add(param.getId()); + AddUpDeductionQueryParam build = AddUpDeductionQueryParam.builder().ids(ids).build(); + List addUpDeductionRecordDTOS = new AddUpDeductionBiz().recordList(build); + if (addUpDeductionRecordDTOS == null || addUpDeductionRecordDTOS.size() == 0) { + throw new SalaryRunTimeException("该数据不存在!"); + } + return addUpDeductionRecordDTOS.get(0); + } + + @Override + public String autoAddAll(Date yearMonth, boolean isAdmin, List taxAgentIds) { + String cacheKey = "addUpDeduction_autoAddAll_processing"; + Object objVal = Util_DataCache.getObjVal(cacheKey); + if (objVal != null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(135788, "一键累计过于频繁,请稍后再试 ")); + } + try { + Util_DataCache.setObjVal(cacheKey, true); + //如果是定时任务直接查询所有,isAdmin传true + Collection taxAgents; + if (isAdmin) { + taxAgents = getTaxAgentService(user).listAll(); + } else { + TaxAgentQueryParam param = TaxAgentQueryParam.builder().build(); + param.setFilterType(AuthFilterTypeEnum.ADMIN_DATA); + taxAgents = getTaxAgentService(user).listAuth(param); + } + // 过滤个税扣缴义务人选择框 + if (CollectionUtils.isNotEmpty(taxAgentIds)) { + taxAgents = taxAgents.stream().filter(taxAgent -> taxAgentIds.contains(taxAgent.getId())).collect(Collectors.toList()); + } + LocalDateTime yearMonthTime = DateUtil.toLocalDateTime(yearMonth); + //设置时间到下一年1月1号 + Instant instant = yearMonthTime.plusYears(1L).withMonth(1).withDayOfMonth(1).atZone(ZoneOffset.systemDefault()).toInstant(); + Date nextYearStart = Date.from(instant); + int countByDeclareAfter = getAddUpDeductionMapper().countByDeclareAfter(yearMonth, nextYearStart, taxAgents.stream().map(TaxAgentPO::getId).collect(Collectors.toList())); + if (countByDeclareAfter > 0) { + throw new SalaryRunTimeException("无法累计,请检查当前累计年度内该月后是否有累计专项附加扣除记录!"); + } + List updateList = new ArrayList<>(); + List insertList = new ArrayList<>(); + List errorMessages = new ArrayList<>(); + List accountedEmployeeData = getAccountedEmployeeDataByTaxYearMonth(DateUtil.format(yearMonth, "yyyy-MM")); + for (TaxAgentPO taxAgent : taxAgents) { + List employeePOs = getSpecialAddDeductionService(user).getSpecialAddDeductionPOByEmployee(null, taxAgent.getId()); + + + //获取上月员工数据,用于累加 + LocalDateTime lastMonthDateTime = yearMonthTime.minusMonths(1); + Map> lastEmpInfo; + if (lastMonthDateTime.getYear() == yearMonthTime.getYear()) { + YearMonth lastMonth = YearMonth.of(lastMonthDateTime.getYear(), lastMonthDateTime.getMonth()); + lastEmpInfo = getEmpInfoByYearMonth(taxAgent, employeePOs, lastMonth); + } else { + lastEmpInfo = new HashMap<>(0); + } + + //获取当月员工数据,用于更新 + YearMonth currentMonth = YearMonth.of(yearMonthTime.getYear(), yearMonthTime.getMonth()); + Map> currentEmpInfo = getEmpInfoByYearMonth(taxAgent, employeePOs, currentMonth); + + employeePOs.forEach(employeePO -> { + Long employeeId = employeePO.getEmployeeId(); + // 如果该员工当前月份已经核算,不做累计 + SalaryAcctEmployeePO anyAccountedEmployee = accountedEmployeeData.stream().filter(e -> e.getEmployeeId().equals(employeeId)).filter(e -> e.getTaxAgentId().equals(taxAgent.getId())).findAny().orElse(null); + if (anyAccountedEmployee != null) { + errorMessages.add(employeeId); + return; + } + AddUpDeduction addUpDeduction = Optional.ofNullable(lastEmpInfo.get(employeeId)).flatMap(list -> list.stream().findFirst()).orElseGet(AddUpDeduction::new); + this.combine(addUpDeduction, employeePO); + + addUpDeduction.setEmployeeId(employeeId); + addUpDeduction.setTaxAgentId(taxAgent.getId()); + addUpDeduction.setDeclareMonth(DateUtil.beginOfMonth(yearMonth)); + addUpDeduction.setCreator(user == null ? 0 : (long) user.getUID()); + addUpDeduction.setTenantKey(DEFAULT_TENANT_KEY); + + //确认当期是否有已经累计的记录 + AddUpDeduction oldInfo = Optional.ofNullable(currentEmpInfo.get(employeeId)).flatMap(c -> c.stream().findFirst()).orElse(null); + Date now = new Date(); + if (oldInfo == null) { + addUpDeduction.setCreateTime(now); + addUpDeduction.setUpdateTime(now); + insertList.add(encryptUtil.encrypt(addUpDeduction, AddUpDeduction.class)); + } else { + addUpDeduction.setId(oldInfo.getId()); + addUpDeduction.setCreateTime(oldInfo.getCreateTime()); + addUpDeduction.setUpdateTime(now); + updateList.add(encryptUtil.encrypt(addUpDeduction, AddUpDeduction.class)); + } + }); + } + Lists.partition(insertList, 100).forEach(l -> getAddUpDeductionMapper().insertData((List) l)); + Lists.partition(updateList, 100).forEach(l -> getAddUpDeductionMapper().updateDataAndDeclareMonth((List) l)); + + // 记录日志 + // 根据月份、人员id查出保存的数据 + List empIds = insertList.stream().map(AddUpDeduction::getEmployeeId).collect(Collectors.toList()); + List insertLogList = getAddUpDeductionMapper().listSome(AddUpDeduction.builder().declareMonth(yearMonth).employeeIds(empIds).build()); + Map insertMap = SalaryEntityUtil.convert2Map(insertLogList, p -> p.getTaxAgentId() + "-" + SalaryDateUtil.getFormatYearMonth(p.getDeclareMonth()) + "-" + p.getEmployeeId()); + insertList.forEach(save -> { + AddUpDeduction addUpDeduction = insertMap.get(save.getTaxAgentId() + "-" + SalaryDateUtil.getFormatYearMonth(save.getDeclareMonth()) + "-" + save.getEmployeeId()); + if (addUpDeduction != null) { + updateList.add(addUpDeduction); + } + }); + + if (CollectionUtils.isNotEmpty(updateList)) { + String yearMonthStr = SalaryDateUtil.getFormatYearMonth(yearMonth); + LoggerContext loggerContext = new LoggerContext(); + loggerContext.setUser(user); + loggerContext.setTargetName(SalaryI18nUtil.getI18nLabel(0, "一键累计 " + yearMonthStr)); + loggerContext.setOperateType(OperateTypeEnum.ADD.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "一键累计专项附加扣除")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "一键累计 " + yearMonthStr + " 专项附加扣除")); + loggerContext.setNewValueList(updateList); + SalaryElogConfig.addUpDeductionLoggerTemplate.write(loggerContext); + } + + if (!errorMessages.isEmpty()) { + String userNames = getSalaryEmployeeService(user).getEmployeeByIdsAll(errorMessages).stream().map(DataCollectionEmployee::getUsername).collect(Collectors.joining(",")); + return "一键累计完成!员工" + userNames + "在该年月已核算归档,跳过本次累计"; + } + return "一键累计完成!"; + } finally { + Util_DataCache.clearVal(cacheKey); + } + } + + @Override + public List listAuth(AddUpDeductionQueryParam param) { + List list = getAddUpDeductionMapper().list(param); + list = getAuthService(user).auth(list, param.getFilterType(), AddUpDeductionDTO.class); + return list; + } + + /** + * 对每个扣除项做加法 + * + * @param addUpDeduction 上次记录 + * @param employeePO 专项附加扣除值 + */ + private void combine(AddUpDeduction addUpDeduction, SpecialAddDeductionPO employeePO) { + final String zero = "0"; + String childEducation = Optional.ofNullable(addUpDeduction.getAddUpChildEducation()).orElse(zero); + addUpDeduction.setAddUpChildEducation(plus(childEducation, employeePO.getChildrenEducation())); + + String continuingEducation = Optional.ofNullable(addUpDeduction.getAddUpContinuingEducation()).orElse(zero); + addUpDeduction.setAddUpContinuingEducation(plus(continuingEducation, employeePO.getContinuingEducation())); + + String housingLoanInterest = Optional.ofNullable(addUpDeduction.getAddUpHousingLoanInterest()).orElse(zero); + addUpDeduction.setAddUpHousingLoanInterest(plus(housingLoanInterest, employeePO.getHousingLoanInterest())); + + String housingRent = Optional.ofNullable(addUpDeduction.getAddUpHousingRent()).orElse(zero); + addUpDeduction.setAddUpHousingRent(plus(housingRent, employeePO.getHousingRent())); + + String supportElderly = Optional.ofNullable(addUpDeduction.getAddUpSupportElderly()).orElse(zero); + addUpDeduction.setAddUpSupportElderly(plus(supportElderly, employeePO.getSupportingElder())); + + String illnessMedical = Optional.ofNullable(addUpDeduction.getAddUpIllnessMedical()).orElse(zero); + addUpDeduction.setAddUpIllnessMedical(plus(illnessMedical, employeePO.getSeriousIllnessTreatment())); + + String infantCare = Optional.ofNullable(addUpDeduction.getAddUpInfantCare()).orElse(zero); + addUpDeduction.setAddUpInfantCare(plus(infantCare, employeePO.getInfantCare())); + } + + private String plus(String var0, String var1) { + return SalaryEntityUtil.string2BigDecimalDefault0(var0).add(SalaryEntityUtil.string2BigDecimalDefault0(var1)).toString(); + } + + private Map> getEmpInfoByYearMonth(TaxAgentPO taxAgent, List employeePOs, YearMonth lastMonth) { + List addUpDeductionList = getAddUpDeductionList(lastMonth, employeePOs.stream().map(SpecialAddDeductionPO::getEmployeeId).collect(Collectors.toList()), Collections.singletonList(taxAgent.getId())); + return addUpDeductionList.stream().filter(addUpDeduction -> taxAgent.getId().equals(addUpDeduction.getTaxAgentId())).collect(Collectors.groupingBy(AddUpDeduction::getEmployeeId)); + } + + + private void checkImportParam(AddUpDeductionImportParam importParam) { + + + //excel文件id + String imageId = Util.null2String(importParam.getImageId()); + //税款所属期 + String declareMonthStr = Util.null2String(importParam.getDeclareMonth()); + //个税扣缴义务人 + String taxAgentId = Util.null2String(importParam.getTaxAgentId()); + + if (StringUtils.isBlank(imageId)) { + throw new SalaryRunTimeException("文件不存在"); + } + if (StringUtils.isBlank(declareMonthStr)) { + throw new SalaryRunTimeException("税款所属期为空"); + } + } + + + @Override + public Map preview(AddUpDeductionImportParam importParam) { + Map apidatas = new HashMap(); + //excel文件id + String imageId = Util.null2String(importParam.getImageId()); + Validate.notBlank(imageId, "imageId为空"); + + InputStream fileInputStream = null; + + try { + fileInputStream = ImageFileManager.getInputStreamById(Integer.parseInt(imageId)); + Sheet sheet = ExcelSupport.parseFile(fileInputStream, 0, EXCEL_TYPE_XLSX); + apidatas.put("headers", ExcelSupport.getSheetHeader(sheet, 0)); + apidatas.put("list", ExcelParseHelper.parse2List(sheet, 1, 0)); + return apidatas; + + } finally { + IOUtils.closeQuietly(fileInputStream); + } + } + + + @Override + public AddUpDeduction getById(Long id) { + return getAddUpDeductionMapper().getById(id); + } + + @Override + public PageInfo listPage(AddUpDeductionQueryParam queryParam) { + //申报月份 + List declareMonth = queryParam.getDeclareMonth(); + if (CollectionUtils.isNotEmpty(declareMonth)) { + queryParam.setDeclareMonth(declareMonth.stream().map(e -> e + "-01 00:00:00").collect(Collectors.toList())); + queryParam.setDeclareMonthDate(declareMonth.stream().map(e -> e + "-01 00:00:00").map(SalaryDateUtil::dateStrToLocalTime).collect(Collectors.toList())); + } + + //排序配置 + OrderRuleVO orderRule = getSalarySysConfService(user).orderRule(); + queryParam.setOrderRule(orderRule); + + queryParam.setFilterType(AuthFilterTypeEnum.DATA_OPT); + List list = listAuth(queryParam); + + PageInfo pageInfo = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), list, AddUpDeductionDTO.class); + encryptUtil.decryptList(pageInfo.getList(), AddUpDeductionDTO.class); + SalaryI18nUtil.i18nList(pageInfo.getList()); + return pageInfo; + } + + @Override + public PageInfo recordListPage(AddUpDeductionQueryParam queryParam) { + List list = getAddUpDeductionMapper().recordList(queryParam); + list = getAuthService(user).auth(list, AuthFilterTypeEnum.DATA_OPT, AddUpDeductionRecordDTO.class); + PageInfo page = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), list, AddUpDeductionRecordDTO.class); + encryptUtil.decryptList(page.getList(), AddUpDeductionRecordDTO.class); + return page; + } + + + /** + * 导出详情列表 + * + * @return + */ + @Override + public XSSFWorkbook exportDetail(Long beLongEmployeeId, AddUpDeductionQueryParam queryParam) { + queryParam.setEmployeeId(beLongEmployeeId); + AddUpDeductionBiz biz = new AddUpDeductionBiz(); + + Long id = queryParam.getAccumulatedSpecialAdditionalDeductionId(); + if (id == null) { + throw new SalaryRunTimeException("id不能为空"); + } + + AddUpDeduction po = biz.getById(id); + if (po == null) { + throw new SalaryRunTimeException(String.format("累计专项附加扣除不存在" + "[id:%s]", id)); + } + + List employeeList = getSalaryEmployeeService(user).getEmployeeByIds(Collections.singletonList(po.getEmployeeId())); + if (CollectionUtils.isEmpty(employeeList)) { + throw new SalaryRunTimeException("员工信息不存在"); + } + + //查询参数 + queryParam.setEmployeeId(po.getEmployeeId()); + //申报月份 + List declareMonth = queryParam.getDeclareMonth(); + if (CollectionUtils.isNotEmpty(declareMonth)) { + queryParam.setDeclareMonth(declareMonth.stream().map(e -> e + "-01 00:00:00").collect(Collectors.toList())); + queryParam.setDeclareMonthDate(declareMonth.stream().map(e -> e + "-01 00:00:00").map(SalaryDateUtil::dateStrToLocalTime).collect(Collectors.toList())); + } + + + //获取操作按钮资源 + List> rowList = getExcelRowDetailList(queryParam); + + + //获取excel + return ExcelUtil.genWorkbookWithDefaultPattern(rowList, "累计专项附加扣除明细", 2); + } + + + /** + * 导出详情 + * + * @param param + * @return + */ + private List> getExcelRowDetailList(AddUpDeductionQueryParam param) { + + //excel标题 + List title = Arrays.asList("姓名", "申报月份", "个税扣缴义务人", "部门", "工号", "累计子女教育", "累计继续教育", "累计住房贷款利息", "累计住房租金", "累计赡养老人", "累计大病医疗", "累计婴幼儿照护"); + + + SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM"); + //查询详细信息 + List list = new AddUpDeductionBiz().recordList(param); + final List> dataRowList = Optional.ofNullable(list).map(List::stream).map(operatorStream -> operatorStream.map(dto -> { + List cellList = new ArrayList<>(); + cellList.add(Util.null2String(dto.getUsername())); + cellList.add(Util.null2String(dto.getDeclareMonth() == null ? "" : formatter.format(dto.getDeclareMonth()))); + cellList.add(Util.null2String(dto.getTaxAgentName())); + cellList.add(Util.null2String(dto.getDepartmentName())); + cellList.add(Util.null2String(dto.getJobNum())); + cellList.add(NumberUtil.isNumber(dto.getAddUpChildEducation()) ? new BigDecimal(dto.getAddUpChildEducation()) : Util.null2String(dto.getAddUpChildEducation())); + cellList.add(NumberUtil.isNumber(dto.getAddUpContinuingEducation()) ? new BigDecimal(dto.getAddUpContinuingEducation()) : Util.null2String(dto.getAddUpContinuingEducation())); + cellList.add(NumberUtil.isNumber(dto.getAddUpHousingLoanInterest()) ? new BigDecimal(dto.getAddUpHousingLoanInterest()) : Util.null2String(dto.getAddUpHousingLoanInterest())); + cellList.add(NumberUtil.isNumber(dto.getAddUpHousingRent()) ? new BigDecimal(dto.getAddUpHousingRent()) : Util.null2String(dto.getAddUpHousingRent())); + cellList.add(NumberUtil.isNumber(dto.getAddUpSupportElderly()) ? new BigDecimal(dto.getAddUpSupportElderly()) : Util.null2String(dto.getAddUpSupportElderly())); + cellList.add(NumberUtil.isNumber(dto.getAddUpIllnessMedical()) ? new BigDecimal(dto.getAddUpIllnessMedical()) : Util.null2String(dto.getAddUpIllnessMedical())); + cellList.add(NumberUtil.isNumber(dto.getAddUpInfantCare()) ? new BigDecimal(dto.getAddUpInfantCare()) : Util.null2String(dto.getAddUpInfantCare())); + + return cellList; + }).collect(Collectors.toList())).orElse(Collections.emptyList()); + + + List> rowList = new ArrayList<>(); + rowList.add(title); + rowList.addAll(dataRowList); + return rowList; + } + + + @Override + public List getAddUpDeductionList(YearMonth declareMonth, List employeeIds, List taxAgentIds) { + AddUpDeductionBiz addUpDeductionBiz = new AddUpDeductionBiz(); + if (declareMonth == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100342, "参数有误:申报月份、租户key必传")); + } + return addUpDeductionBiz.listSome(AddUpDeduction.builder().declareMonth(SalaryDateUtil.toDateStartOfMonth(declareMonth)).employeeIds(employeeIds).taxAgentIds(taxAgentIds).build()); + } + + @Override + public XSSFWorkbook downloadTemplate(AddUpDeductionQueryParam queryParam) { + + String sheetName = SalaryI18nUtil.getI18nLabel(101603, "累计专项附加扣除导入模板"); + String[] header = {SalaryI18nUtil.getI18nLabel(85429, "姓名"), SalaryI18nUtil.getI18nLabel(86184, "个税扣缴义务人"), SalaryI18nUtil.getI18nLabel(86185, "部门"), SalaryI18nUtil.getI18nLabel(86186, "手机号"), SalaryI18nUtil.getI18nLabel(86317, "工号"), SalaryI18nUtil.getI18nLabel(86318, "证件号码"), SalaryI18nUtil.getI18nLabel(86319, "入职日期"), SalaryI18nUtil.getI18nLabel(86321, "累计子女教育"), SalaryI18nUtil.getI18nLabel(86323, "累计继续教育"), SalaryI18nUtil.getI18nLabel(86324, "累计住房贷款利息"), SalaryI18nUtil.getI18nLabel(86325, "累计住房租金"), SalaryI18nUtil.getI18nLabel(86326, "累计赡养老人"), SalaryI18nUtil.getI18nLabel(105142, "累计大病医疗"), SalaryI18nUtil.getI18nLabel(105142, "累计婴幼儿照护")}; + + List headerList = Arrays.asList(header); + + //查询当前申报月份和个税扣缴义务人的累计专项附加扣除表数据 + List> rows = new ArrayList<>(); + rows.add(headerList); + if (queryParam.isHasData()) { + queryParam.setFilterType(AuthFilterTypeEnum.ADMIN_DATA); + List> datas = getLists(queryParam); + rows.addAll(datas); + } + + // 4.注释 + List excelComments = Lists.newArrayList(); + excelComments.add(new ExcelComment(0, 0, 3, 2, SalaryI18nUtil.getI18nLabel(100344, "必填"))); + excelComments.add(new ExcelComment(1, 0, 4, 2, SalaryI18nUtil.getI18nLabel(100344, "必填"))); + excelComments.add(new ExcelComment(7, 0, 10, 2, SalaryI18nUtil.getI18nLabel(100344, "输入数字"))); + excelComments.add(new ExcelComment(8, 0, 11, 2, SalaryI18nUtil.getI18nLabel(100344, "输入数字"))); + excelComments.add(new ExcelComment(9, 0, 12, 2, SalaryI18nUtil.getI18nLabel(100344, "输入数字"))); + excelComments.add(new ExcelComment(10, 0, 13, 2, SalaryI18nUtil.getI18nLabel(100344, "输入数字"))); + excelComments.add(new ExcelComment(11, 0, 14, 2, SalaryI18nUtil.getI18nLabel(100344, "输入数字"))); + excelComments.add(new ExcelComment(12, 0, 15, 2, SalaryI18nUtil.getI18nLabel(100344, "输入数字"))); + excelComments.add(new ExcelComment(13, 0, 16, 2, SalaryI18nUtil.getI18nLabel(100344, "输入数字"))); + + XSSFWorkbook book = ExcelUtil.genWorkbookV2(rows, sheetName, excelComments); + + return book; + } + + + @Override + public XSSFWorkbook export(AddUpDeductionQueryParam queryParam) { + //excel标题 + List title = Arrays.asList("姓名", "个税扣缴义务人", "部门", "手机号", "工号", "证件号码", "入职日期", "累计子女教育", "累计继续教育", "累计住房贷款利息", "累计住房租金", "累计赡养老人", "累计大病医疗", "累计婴幼儿照护"); + + queryParam.setFilterType(AuthFilterTypeEnum.QUERY_DATA); + List> dataRowList = getLists(queryParam); + + List> rowList = new ArrayList<>(); + rowList.add(title); + + rowList.addAll(dataRowList); + + // 记录日志 + String name = SalaryI18nUtil.getI18nLabel(0, "导出"); + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setTargetName(SalaryI18nUtil.getI18nLabel(0, "累计专项附加扣除")); + loggerContext.setOperateType(OperateTypeEnum.EXCEL_EXPORT.getValue()); + loggerContext.setOperateTypeName(name); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "累计专项附加扣除") + "-" + name); + loggerContext.setUser(user); + SalaryElogConfig.addUpDeductionLoggerTemplate.write(loggerContext); + + //获取excel + return ExcelUtil.genWorkbookV2WithDefaultPattern(rowList, "累计专项附加扣除", 2); + } + + private List> getLists(AddUpDeductionQueryParam param) { + + //排序配置 + OrderRuleVO orderRule = getSalarySysConfService(user).orderRule(); + param.setOrderRule(orderRule); + + List list = listAuth(param); + encryptUtil.decryptList(list, AddUpDeductionDTO.class); + SalaryI18nUtil.i18nList(list); + + List> dataRowList = Optional.ofNullable(list).map(List::stream).map(operatorStream -> operatorStream.map(dto -> { + List cellList = new ArrayList<>(); + cellList.add(Util.null2String(dto.getUsername())); + cellList.add(Util.null2String(dto.getTaxAgentName())); + cellList.add(Util.null2String(dto.getDepartmentName())); + cellList.add(Util.null2String(dto.getMobile())); + cellList.add(Util.null2String(dto.getJobNum())); + cellList.add(Util.null2String(dto.getIdNo())); + cellList.add(Util.null2String(dto.getHiredate())); + cellList.add(NumberUtil.isNumber(dto.getAddUpChildEducation()) ? new BigDecimal(dto.getAddUpChildEducation()) : Util.null2String(dto.getAddUpChildEducation())); + cellList.add(NumberUtil.isNumber(dto.getAddUpContinuingEducation()) ? new BigDecimal(dto.getAddUpContinuingEducation()) : Util.null2String(dto.getAddUpContinuingEducation())); + cellList.add(NumberUtil.isNumber(dto.getAddUpHousingLoanInterest()) ? new BigDecimal(dto.getAddUpHousingLoanInterest()) : Util.null2String(dto.getAddUpHousingLoanInterest())); + cellList.add(NumberUtil.isNumber(dto.getAddUpHousingRent()) ? new BigDecimal(dto.getAddUpHousingRent()) : Util.null2String(dto.getAddUpHousingRent())); + cellList.add(NumberUtil.isNumber(dto.getAddUpSupportElderly()) ? new BigDecimal(dto.getAddUpSupportElderly()) : Util.null2String(dto.getAddUpSupportElderly())); + cellList.add(NumberUtil.isNumber(dto.getAddUpIllnessMedical()) ? new BigDecimal(dto.getAddUpIllnessMedical()) : Util.null2String(dto.getAddUpIllnessMedical())); + cellList.add(NumberUtil.isNumber(dto.getAddUpInfantCare()) ? new BigDecimal(dto.getAddUpInfantCare()) : Util.null2String(dto.getAddUpInfantCare())); + return cellList; + }).collect(Collectors.toList())).orElse(Collections.emptyList()); + return dataRowList; + } + + + @Override + public List getAccountedEmployeeDataByTaxYearMonth(String yearMonth) { + List list = Lists.newArrayList(); + YearMonth month = YearMonth.parse(yearMonth); + Date taxCycle = SalaryDateUtil.localDateToDate(month.atDay(1)); + + List salaryAcctRecords = getSalaryAcctRecordService(user).listSome(SalaryAcctRecordPO.builder().taxCycle(taxCycle).build()); + List salarySobPOS = getSalarySobService(user).listAll(); + List sobIds = salarySobPOS.stream() + .filter(e -> IncomeCategoryEnum.WAGES_AND_SALARIES.getValue().equals(e.getIncomeCategory())) + .map(SalarySobPO::getId) + .collect(Collectors.toList()); + salaryAcctRecords.stream() + .filter(e -> !SalaryAcctRecordStatusEnum.NOT_ARCHIVED.getValue().equals(e.getStatus())) + .filter(e -> sobIds.contains(e.getSalarySobId())) + .forEach(e -> { + list.addAll(getSalaryAcctEmployeeService(user).listBySalaryAcctRecordIds(Collections.singleton(e.getId()))); + }); + + return list; + } + +} diff --git a/src/com/engine/salary/service/impl/AddUpSituationServiceImpl.java b/src/com/engine/salary/service/impl/AddUpSituationServiceImpl.java new file mode 100644 index 000000000..04caffe35 --- /dev/null +++ b/src/com/engine/salary/service/impl/AddUpSituationServiceImpl.java @@ -0,0 +1,1156 @@ +package com.engine.salary.service.impl; + +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.util.NumberUtil; +import com.api.browser.bean.SearchConditionGroup; +import com.api.browser.bean.SearchConditionItem; +import com.api.browser.util.ConditionFactory; +import com.api.browser.util.ConditionType; +import com.api.formmode.mybatis.util.SqlProxyHandle; +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.hrmelog.entity.dto.LoggerContext; +import com.engine.salary.biz.AddUpSituationBiz; +import com.engine.salary.config.SalaryElogConfig; +import com.engine.salary.encrypt.EncryptUtil; +import com.engine.salary.entity.datacollection.AddUpSituation; +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.datacollection.dto.AddUpSituationDTO; +import com.engine.salary.entity.datacollection.dto.AddUpSituationRecordDTO; +import com.engine.salary.entity.datacollection.param.AddUpSituationDeleteParam; +import com.engine.salary.entity.datacollection.param.AddUpSituationImportParam; +import com.engine.salary.entity.datacollection.param.AddUpSituationParam; +import com.engine.salary.entity.datacollection.param.AddUpSituationQueryParam; +import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO; +import com.engine.salary.entity.taxagent.dto.TaxAgentManageRangeEmployeeDTO; +import com.engine.salary.entity.taxagent.param.TaxAgentQueryParam; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import com.engine.salary.enums.OperateTypeEnum; +import com.engine.salary.enums.UserStatusEnum; +import com.engine.salary.enums.auth.AuthFilterTypeEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.mapper.datacollection.AddUpSituationMapper; +import com.engine.salary.mapper.sys.SalarySysConfMapper; +import com.engine.salary.service.AddUpDeductionService; +import com.engine.salary.service.AddUpSituationService; +import com.engine.salary.service.SalaryEmployeeService; +import com.engine.salary.service.TaxAgentService; +import com.engine.salary.service.auth.AuthService; +import com.engine.salary.service.auth.AuthServiceImpl; +import com.engine.salary.sys.entity.po.SalarySysConfPO; +import com.engine.salary.sys.entity.vo.OrderRuleVO; +import com.engine.salary.sys.service.SalarySysConfService; +import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl; +import com.engine.salary.util.SalaryDateUtil; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.db.MapperProxyFactory; +import com.engine.salary.util.excel.ExcelComment; +import com.engine.salary.util.excel.ExcelParseHelper; +import com.engine.salary.util.excel.ExcelSupport; +import com.engine.salary.util.excel.ExcelUtil; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.util.page.SalaryPageUtil; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.util.IOUtils; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import weaver.file.ImageFileManager; +import weaver.general.Util; +import weaver.hrm.User; + +import java.io.InputStream; +import java.math.BigDecimal; +import java.text.SimpleDateFormat; +import java.time.LocalDate; +import java.time.YearMonth; +import java.time.format.DateTimeFormatter; +import java.util.*; +import java.util.stream.Collectors; + +import static com.engine.salary.constant.SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY; +import static com.engine.salary.util.excel.ExcelSupport.EXCEL_TYPE_XLSX; + +public class AddUpSituationServiceImpl extends Service implements AddUpSituationService { + private EncryptUtil encryptUtil = new EncryptUtil(); + + private AddUpSituationMapper getAddUpSituationMapper() { + return MapperProxyFactory.getProxy(AddUpSituationMapper.class); + } + + private AddUpDeductionService getAddUpDeductionService(User user) { + return ServiceUtil.getService(AddUpDeductionServiceImpl.class, user); + } + + private TaxAgentService getTaxAgentService(User user) { + return ServiceUtil.getService(TaxAgentServiceImpl.class, user); + } + + private SalaryEmployeeService getSalaryEmployeeService(User user) { + return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user); + } + + private SalarySysConfService getSalarySysConfService(User user) { + return ServiceUtil.getService(SalarySysConfServiceImpl.class, user); + } + + AddUpSituationBiz biz = new AddUpSituationBiz(); + + private SalarySysConfMapper getSalarySysConfMapper() { + return SqlProxyHandle.getProxy(SalarySysConfMapper.class); + } + + public AuthService getAuthService(User user) { + return ServiceUtil.getService(AuthServiceImpl.class, user); + } + + @Override + public Map getSearchCondition() { + Map apidatas = new HashMap(); + ConditionFactory conditionFactory = new ConditionFactory(user); + + //条件组 + List addGroups = new ArrayList(); + + List conditionItems = new ArrayList(); + + //文本输入框 + SearchConditionItem username = conditionFactory.createCondition(ConditionType.INPUT, 25034, "username"); + username.setInputType("input"); + username.setColSpan(2);//定义一行显示条件数,默认值为2,当值为1时标识该条件单独占一行 + username.setFieldcol(16); //条件输入框所占宽度,默认值18 + username.setLabelcol(8); + username.setViewAttr(2); // 编辑权限 1:只读,2:可编辑, 3:必填 默认2 + username.setLabel("姓名"); //设置文本值 这个将覆盖多语言标签的值 + conditionItems.add(username); + + + SearchConditionItem departmentName = conditionFactory.createCondition(ConditionType.BROWSER, 502227, "departmentIds", "57"); + departmentName.setInputType("browser"); + departmentName.setColSpan(2); + departmentName.setFieldcol(16); + departmentName.setLabelcol(8); + departmentName.setViewAttr(2); + departmentName.setIsQuickSearch(false); + departmentName.setLabel("部门"); + conditionItems.add(departmentName); + + + SearchConditionItem jobNum = conditionFactory.createCondition(ConditionType.INPUT, 25034, "jobNum"); + jobNum.setInputType("input"); + jobNum.setColSpan(2); + jobNum.setFieldcol(16); + jobNum.setLabelcol(8); + jobNum.setViewAttr(2); + jobNum.setLabel("工号"); + conditionItems.add(jobNum); + + +// SearchConditionItem idNo = conditionFactory.createCondition(ConditionType.INPUT, 25034, "idNo"); +// idNo.setInputType("input"); +// idNo.setColSpan(2); +// idNo.setFieldcol(16); +// idNo.setLabelcol(8); +// idNo.setViewAttr(2); +// idNo.setLabel("证件号码"); +// conditionItems.add(idNo); +// +// //日期范围选项 +// List dateOptions = new ArrayList(); +// dateOptions.add(new SearchConditionOption("6", SalaryI18nUtil.getI18nLabel(32530, user.getLanguage()), true));//指定日期范围(必须为6) +// SearchConditionItem hiredate = conditionFactory.createCondition(ConditionType.RANGEPICKER, 18648, new String[]{"hiredate", "hiredate"}); +// hiredate.setInputType("rangepicker"); +// hiredate.setFormat("yyyy-MM-dd"); +// hiredate.setFieldcol(16); +// hiredate.setLabelcol(8); +// hiredate.setViewAttr(2); +// hiredate.setLabel("入职日期"); +// hiredate.setOptions(dateOptions); +// conditionItems.add(hiredate); +// +// +// SearchConditionItem mobile = conditionFactory.createCondition(ConditionType.INPUT, 25034, "mobile"); +// mobile.setInputType("input"); +// mobile.setColSpan(2); +// mobile.setFieldcol(16); +// mobile.setLabelcol(8); +// mobile.setViewAttr(2); +// mobile.setLabel("手机号"); +// conditionItems.add(mobile); + + addGroups.add(new SearchConditionGroup("常用条件", true, conditionItems)); + + apidatas.put("condition", addGroups); + return apidatas; + } + + + @Override + public AddUpSituation getById(Long id) { + return getAddUpSituationMapper().getById(id); + } + + + @Override + public PageInfo listPage(AddUpSituationQueryParam queryParam) { + + List taxYearMonth = queryParam.getTaxYearMonth(); + if (CollectionUtils.isNotEmpty(taxYearMonth)) { + queryParam.setTaxYearMonth(taxYearMonth.stream().map(e -> e + "-01 00:00:00").collect(Collectors.toList())); + queryParam.setTaxYearMonthDate(taxYearMonth.stream().map(e -> e + "-01 00:00:00").map(SalaryDateUtil::dateStrToLocalTime).collect(Collectors.toList())); + } + //排序配置 + OrderRuleVO orderRule = getSalarySysConfService(user).orderRule(); + queryParam.setOrderRule(orderRule); + + List list = getAddUpSituationMapper().list(queryParam); + list = getAuthService(user).auth(list, AuthFilterTypeEnum.DATA_OPT, AddUpSituationDTO.class); + + PageInfo page = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), list, AddUpSituationDTO.class); + encryptUtil.decryptList(page.getList(), AddUpSituationDTO.class); + SalaryI18nUtil.i18nList(list); + return page; + + } + + @Override + public PageInfo recordListPage(AddUpSituationQueryParam queryParam) { + List list = getAddUpSituationMapper().recordList(queryParam); + + PageInfo page = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), + list, AddUpSituationRecordDTO.class); + encryptUtil.decryptList(page.getList(), AddUpSituationRecordDTO.class); + return page; + } + + @Override + public List getAddUpSituationList(YearMonth taxYearMonth, List employeeIds) { + if (taxYearMonth == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100353, "参数有误:税款所属期必传")); + } + AddUpSituationBiz biz = new AddUpSituationBiz(); + return biz.listSome(AddUpSituation.builder().taxYearMonth(SalaryDateUtil.toDateStartOfMonth(taxYearMonth)).employeeIds(employeeIds).build()); + } + + @Override + public boolean deleteAddUpSituationList(Date taxCycle, Long taxAgentId) { + if (taxCycle == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100353, "参数有误:税款所属期必传")); + } + + AddUpSituationBiz biz = new AddUpSituationBiz(); + List addUpSituations = biz.listSome(AddUpSituation.builder().taxAgentId(taxAgentId).taxYearMonth(taxCycle).build()); + List addUpSituationIds = SalaryEntityUtil.properties(addUpSituations, AddUpSituation::getId, Collectors.toList()); + if (CollectionUtils.isNotEmpty(addUpSituationIds)) { + List> partition = Lists.partition(addUpSituationIds, 100); + partition.forEach(getAddUpSituationMapper()::deleteByIds); + } + + return Boolean.TRUE; + } + + + @Override + public XSSFWorkbook export(AddUpSituationQueryParam queryParam) { + // 获取操作按钮资源 + queryParam.setFilterType(AuthFilterTypeEnum.QUERY_DATA); + List> rowList = getExcelRowList(queryParam, true); + + // 记录日志 + String name = SalaryI18nUtil.getI18nLabel(0, "导出"); + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setTargetName(SalaryI18nUtil.getI18nLabel(0, "往期累计情况")); + loggerContext.setOperateType(OperateTypeEnum.EXCEL_EXPORT.getValue()); + loggerContext.setOperateTypeName(name); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "往期累计情况") + "-" + name); + loggerContext.setUser(user); + SalaryElogConfig.addUpSituationLoggerTemplate.write(loggerContext); + + // 获取excel + return ExcelUtil.genWorkbookV2WithDefaultPattern(rowList, "累计情况", 2); + } + + + /** + * 获取excel数据行 + * + * @return 导出数据行集合 + */ + private List> getExcelRowList(AddUpSituationQueryParam param, boolean hasData) { + // excel标题 + final List title = Arrays.asList("姓名", "个税扣缴义务人", "部门", "手机号", "工号", "证件号码", "入职日期", "累计收入额", "累计减除费用", + "累计社保个人合计", "累计公积金个人合计", "累计子女教育", "累计继续教育", "累计住房贷款利息", "累计住房租金", "累计赡养老人", + "累计大病医疗", "累计企业(职业)年金及其他福利", "累计其他扣除", "累计免税收入", "累计准予扣除的捐赠额", "累计减免税额", "累计已预扣预缴税额", "累计婴幼儿照护", "累计个人养老金"); + + + List> rowList = new ArrayList<>(); + rowList.add(title); + + if (hasData) { + //排序配置 + OrderRuleVO orderRule = getSalarySysConfService(user).orderRule(); + param.setOrderRule(orderRule); + List list = listAuth(param); + + final List> dataRowList = Optional.ofNullable(list) + .map(List::stream) + .map(operatorStream -> operatorStream.map(dto -> { + List cellList = new ArrayList<>(); + cellList.add(Util.null2String(dto.getUsername())); + cellList.add(Util.null2String(dto.getTaxAgentName())); + cellList.add(Util.null2String(dto.getDepartmentName())); + cellList.add(Util.null2String(dto.getMobile())); + cellList.add(Util.null2String(dto.getJobNum())); + cellList.add(Util.null2String(dto.getIdNo())); + cellList.add(Util.null2String(dto.getHiredate())); + cellList.add(NumberUtil.isNumber(dto.getAddUpIncome()) ? new BigDecimal(dto.getAddUpIncome()) : Util.null2String(dto.getAddUpIncome())); + cellList.add(NumberUtil.isNumber(dto.getAddUpSubtraction()) ? new BigDecimal(dto.getAddUpSubtraction()) : Util.null2String(dto.getAddUpSubtraction())); + cellList.add(NumberUtil.isNumber(dto.getAddUpSocialSecurityTotal()) ? new BigDecimal(dto.getAddUpSocialSecurityTotal()) : Util.null2String(dto.getAddUpSocialSecurityTotal())); + cellList.add(NumberUtil.isNumber(dto.getAddUpAccumulationFundTotal()) ? new BigDecimal(dto.getAddUpAccumulationFundTotal()) : Util.null2String(dto.getAddUpAccumulationFundTotal())); + cellList.add(NumberUtil.isNumber(dto.getAddUpChildEducation()) ? new BigDecimal(dto.getAddUpChildEducation()) : Util.null2String(dto.getAddUpChildEducation())); + cellList.add(NumberUtil.isNumber(dto.getAddUpContinuingEducation()) ? new BigDecimal(dto.getAddUpContinuingEducation()) : Util.null2String(dto.getAddUpContinuingEducation())); + cellList.add(NumberUtil.isNumber(dto.getAddUpHousingLoanInterest()) ? new BigDecimal(dto.getAddUpHousingLoanInterest()) : Util.null2String(dto.getAddUpHousingLoanInterest())); + cellList.add(NumberUtil.isNumber(dto.getAddUpHousingRent()) ? new BigDecimal(dto.getAddUpHousingRent()) : Util.null2String(dto.getAddUpHousingRent())); + cellList.add(NumberUtil.isNumber(dto.getAddUpSupportElderly()) ? new BigDecimal(dto.getAddUpSupportElderly()) : Util.null2String(dto.getAddUpSupportElderly())); + cellList.add(NumberUtil.isNumber(dto.getAddUpIllnessMedical()) ? new BigDecimal(dto.getAddUpIllnessMedical()) : Util.null2String(dto.getAddUpIllnessMedical())); + cellList.add(NumberUtil.isNumber(dto.getAddUpEnterpriseAndOther()) ? new BigDecimal(dto.getAddUpEnterpriseAndOther()) : Util.null2String(dto.getAddUpEnterpriseAndOther())); + cellList.add(NumberUtil.isNumber(dto.getAddUpOtherDeduction()) ? new BigDecimal(dto.getAddUpOtherDeduction()) : Util.null2String(dto.getAddUpOtherDeduction())); + cellList.add(NumberUtil.isNumber(dto.getAddUpTaxExemptIncome()) ? new BigDecimal(dto.getAddUpTaxExemptIncome()) : Util.null2String(dto.getAddUpTaxExemptIncome())); + cellList.add(NumberUtil.isNumber(dto.getAddUpAllowedDonation()) ? new BigDecimal(dto.getAddUpAllowedDonation()) : Util.null2String(dto.getAddUpAllowedDonation())); + cellList.add(NumberUtil.isNumber(dto.getAddUpTaxSavings()) ? new BigDecimal(dto.getAddUpTaxSavings()) : Util.null2String(dto.getAddUpTaxSavings())); + cellList.add(NumberUtil.isNumber(dto.getAddUpAdvanceTax()) ? new BigDecimal(dto.getAddUpAdvanceTax()) : Util.null2String(dto.getAddUpAdvanceTax())); + cellList.add(NumberUtil.isNumber(dto.getAddUpInfantCare()) ? new BigDecimal(dto.getAddUpInfantCare()) : Util.null2String(dto.getAddUpInfantCare())); + cellList.add(NumberUtil.isNumber(dto.getAddUpPrivatePension()) ? new BigDecimal(dto.getAddUpPrivatePension()) : Util.null2String(dto.getAddUpPrivatePension())); + return cellList; + }).collect(Collectors.toList())) + .orElse(Collections.emptyList()); + + rowList.addAll(dataRowList); + } + return rowList; + } + + private List listAuth(AddUpSituationQueryParam param) { + List list = getAddUpSituationMapper().list(param); + list = getAuthService(user).auth(list, param.getFilterType(), AddUpSituationDTO.class); + encryptUtil.decryptList(list, AddUpSituationDTO.class); + SalaryI18nUtil.i18nList(list); + return list; + } + + + /** + * 导出详情 + * + * @param param + * @return + */ + private List> getExcelRowDetailList(AddUpSituationQueryParam param) { + //excel标题 + List title = Arrays.asList("姓名", "税款所属期", "个税扣缴义务人", "部门", "手机号", "工号", "累计收入额", "累计减除费用", "累计社保个人合计", + "累计公积金个人合计", "累计子女教育", "累计继续教育", "累计住房贷款利息", "累计住房租金", "累计赡养老人", "累计大病医疗", "累计企业(职业)年金及其他福利", + "累计其他扣除", "累计免税收入", "累计准予扣除的捐赠额", "累计减免税额", "累计已预扣预缴税额", "累计婴幼儿照护", "累计个人养老金"); + + SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM"); + //查询详细信息 + List list = biz.recordList(param); + list = getAuthService(user).auth(list, AuthFilterTypeEnum.QUERY_DATA, AddUpSituationRecordDTO.class); + + final List> dataRowList = Optional.ofNullable(list) + .map(List::stream) + .map(operatorStream -> operatorStream.map(dto -> { + List cellList = new ArrayList<>(); + cellList.add(Util.null2String(dto.getUsername())); + cellList.add(Util.null2String(dto.getTaxYearMonth() == null ? "" : formatter.format(dto.getTaxYearMonth()))); + cellList.add(Util.null2String(dto.getTaxAgentName())); + cellList.add(Util.null2String(dto.getDepartmentName())); + cellList.add(Util.null2String(dto.getMobile())); + cellList.add(Util.null2String(dto.getJobNum())); + cellList.add(NumberUtil.isNumber(dto.getAddUpIncome()) ? new BigDecimal(dto.getAddUpIncome()) : dto.getAddUpIncome()); + cellList.add(NumberUtil.isNumber(dto.getAddUpSubtraction()) ? new BigDecimal(dto.getAddUpSubtraction()) : dto.getAddUpSubtraction()); + cellList.add(NumberUtil.isNumber(dto.getAddUpSocialSecurityTotal()) ? new BigDecimal(dto.getAddUpSocialSecurityTotal()) : dto.getAddUpSocialSecurityTotal()); + cellList.add(NumberUtil.isNumber(dto.getAddUpAccumulationFundTotal()) ? new BigDecimal(dto.getAddUpAccumulationFundTotal()) : dto.getAddUpAccumulationFundTotal()); + cellList.add(NumberUtil.isNumber(dto.getAddUpChildEducation()) ? new BigDecimal(dto.getAddUpChildEducation()) : dto.getAddUpChildEducation()); + cellList.add(NumberUtil.isNumber(dto.getAddUpContinuingEducation()) ? new BigDecimal(dto.getAddUpContinuingEducation()) : dto.getAddUpContinuingEducation()); + cellList.add(NumberUtil.isNumber(dto.getAddUpHousingLoanInterest()) ? new BigDecimal(dto.getAddUpHousingLoanInterest()) : dto.getAddUpHousingLoanInterest()); + cellList.add(NumberUtil.isNumber(dto.getAddUpHousingRent()) ? new BigDecimal(dto.getAddUpHousingRent()) : dto.getAddUpHousingRent()); + cellList.add(NumberUtil.isNumber(dto.getAddUpSupportElderly()) ? new BigDecimal(dto.getAddUpSupportElderly()) : dto.getAddUpSupportElderly()); + cellList.add(NumberUtil.isNumber(dto.getAddUpIllnessMedical()) ? new BigDecimal(dto.getAddUpIllnessMedical()) : dto.getAddUpIllnessMedical()); + cellList.add(NumberUtil.isNumber(dto.getAddUpEnterpriseAndOther()) ? new BigDecimal(dto.getAddUpEnterpriseAndOther()) : dto.getAddUpEnterpriseAndOther()); + cellList.add(NumberUtil.isNumber(dto.getAddUpOtherDeduction()) ? new BigDecimal(dto.getAddUpOtherDeduction()) : dto.getAddUpOtherDeduction()); + cellList.add(NumberUtil.isNumber(dto.getAddUpTaxExemptIncome()) ? new BigDecimal(dto.getAddUpTaxExemptIncome()) : dto.getAddUpTaxExemptIncome()); + cellList.add(NumberUtil.isNumber(dto.getAddUpAllowedDonation()) ? new BigDecimal(dto.getAddUpAllowedDonation()) : dto.getAddUpAllowedDonation()); + cellList.add(NumberUtil.isNumber(dto.getAddUpTaxSavings()) ? new BigDecimal(dto.getAddUpTaxSavings()) : dto.getAddUpTaxSavings()); + cellList.add(NumberUtil.isNumber(dto.getAddUpAdvanceTax()) ? new BigDecimal(dto.getAddUpAdvanceTax()) : dto.getAddUpAdvanceTax()); + cellList.add(NumberUtil.isNumber(dto.getAddUpInfantCare()) ? new BigDecimal(dto.getAddUpInfantCare()) : dto.getAddUpInfantCare()); + cellList.add(NumberUtil.isNumber(dto.getAddUpPrivatePension()) ? new BigDecimal(dto.getAddUpPrivatePension()) : dto.getAddUpPrivatePension()); + return cellList; + }).collect(Collectors.toList())) + .orElse(Collections.emptyList()); + + List> rowList = new ArrayList<>(); + rowList.add(title); + rowList.addAll(dataRowList); + return rowList; + } + + + @Override + public XSSFWorkbook exportDetail(AddUpSituationQueryParam queryParam) { + AddUpSituationBiz biz = new AddUpSituationBiz(); + + Long id = queryParam.getAccumulatedSituationId(); + if (id == null) { + throw new SalaryRunTimeException("id不能为空"); + } + + AddUpSituation po = biz.getById(id); + if (po == null) { + throw new SalaryRunTimeException(String.format("累计情况不存在" + "[id:%s]", id)); + } + + List employeeList = getSalaryEmployeeService(user).getEmployeeByIds(Collections.singletonList(po.getEmployeeId())); + if (CollectionUtils.isEmpty(employeeList)) { + throw new SalaryRunTimeException("员工信息不存在"); + } + + //查询参数 + queryParam.setEmployeeId(po.getEmployeeId()); + //申报月份 + List taxYearMonths = queryParam.getTaxYearMonth(); + if (CollectionUtils.isNotEmpty(taxYearMonths)) { + queryParam.setTaxYearMonth(taxYearMonths.stream().map(e -> e + "-01 00:00:00").collect(Collectors.toList())); + queryParam.setTaxYearMonthDate(taxYearMonths.stream().map(e -> e + "-01 00:00:00").map(SalaryDateUtil::dateStrToLocalTime).collect(Collectors.toList())); + } + + //获取操作按钮资源 + List> rowList = getExcelRowDetailList(queryParam); + + //获取excel + return ExcelUtil.genWorkbookWithDefaultPattern(rowList, "累计情况明细", 2); + + } + + + @Override + public XSSFWorkbook downloadTemplate(AddUpSituationQueryParam queryParam) { + queryParam.setFilterType(AuthFilterTypeEnum.ADMIN_DATA); + String sheetName = SalaryI18nUtil.getI18nLabel(101605, "往期累计情况导入模板"); + // 获取操作按钮资源 + List> rowList = getExcelRowList(queryParam, queryParam.isHasData()); + // 4.注释 + List excelComments = Lists.newArrayList(); + excelComments.add(new ExcelComment(0, 0, 3, 2, SalaryI18nUtil.getI18nLabel(100344, "必填"))); + excelComments.add(new ExcelComment(1, 0, 4, 2, SalaryI18nUtil.getI18nLabel(100344, "必填"))); + excelComments.add(new ExcelComment(7, 0, 10, 2, SalaryI18nUtil.getI18nLabel(100344, "输入数字"))); + excelComments.add(new ExcelComment(8, 0, 11, 2, SalaryI18nUtil.getI18nLabel(100344, "输入数字"))); + excelComments.add(new ExcelComment(9, 0, 14, 2, SalaryI18nUtil.getI18nLabel(100344, "输入数字"))); + excelComments.add(new ExcelComment(10, 0, 15, 2, SalaryI18nUtil.getI18nLabel(100344, "输入数字"))); + excelComments.add(new ExcelComment(11, 0, 16, 2, SalaryI18nUtil.getI18nLabel(100344, "输入数字"))); + excelComments.add(new ExcelComment(12, 0, 17, 2, SalaryI18nUtil.getI18nLabel(100344, "输入数字"))); + excelComments.add(new ExcelComment(13, 0, 18, 2, SalaryI18nUtil.getI18nLabel(100344, "输入数字"))); + excelComments.add(new ExcelComment(14, 0, 19, 2, SalaryI18nUtil.getI18nLabel(100344, "输入数字"))); + excelComments.add(new ExcelComment(15, 0, 20, 2, SalaryI18nUtil.getI18nLabel(100344, "输入数字"))); + excelComments.add(new ExcelComment(16, 0, 21, 2, SalaryI18nUtil.getI18nLabel(100344, "输入数字"))); + excelComments.add(new ExcelComment(17, 0, 22, 2, SalaryI18nUtil.getI18nLabel(100344, "输入数字"))); + excelComments.add(new ExcelComment(18, 0, 23, 2, SalaryI18nUtil.getI18nLabel(100344, "输入数字"))); + excelComments.add(new ExcelComment(19, 0, 24, 2, SalaryI18nUtil.getI18nLabel(100344, "输入数字"))); + excelComments.add(new ExcelComment(20, 0, 25, 2, SalaryI18nUtil.getI18nLabel(100344, "输入数字"))); + excelComments.add(new ExcelComment(21, 0, 26, 2, SalaryI18nUtil.getI18nLabel(100344, "输入数字"))); + excelComments.add(new ExcelComment(22, 0, 27, 2, SalaryI18nUtil.getI18nLabel(100344, "输入数字"))); + excelComments.add(new ExcelComment(23, 0, 28, 2, SalaryI18nUtil.getI18nLabel(100344, "输入数字"))); + excelComments.add(new ExcelComment(24, 0, 29, 2, SalaryI18nUtil.getI18nLabel(100344, "输入数字"))); + + return ExcelUtil.genWorkbookV2(rowList, sheetName, excelComments); + } + + @Override + public boolean deleteByTaxYearMonthAndTaxAgentIds(YearMonth taxYearMonth, Collection taxAgentIds) { + if (taxYearMonth == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100353, "参数有误:税款所属期必传")); + } + + if (CollectionUtils.isEmpty(taxAgentIds)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100353, "参数有误:扣缴义务人为空")); + } + + Date date = SalaryDateUtil.localDateToDate(taxYearMonth.atDay(1)); + + getAddUpSituationMapper().deleteByTaxYearMonthAndTaxAgentIds(AddUpSituation.builder().taxYearMonth(date).taxAgentIds(taxAgentIds).build()); + + return Boolean.TRUE; + } + + @Override + public Map preview(AddUpSituationImportParam importParam) { + Map apidatas = new HashMap(); + + //检验参数 + checkImportParam(importParam); + + //excel文件id + String imageId = Util.null2String(importParam.getImageId()); + + InputStream fileInputStream = null; + try { + fileInputStream = ImageFileManager.getInputStreamById(Integer.valueOf(imageId)); + Sheet sheet = ExcelSupport.parseFile(fileInputStream, 0, EXCEL_TYPE_XLSX); + apidatas.put("headers", ExcelSupport.getSheetHeader(sheet, 0)); + apidatas.put("list", ExcelParseHelper.parse2List(sheet, 1, 0)); + return apidatas; + } finally { + IOUtils.closeQuietly(fileInputStream); + } + } + + + @Override + public Map importAddUpSituation(AddUpSituationImportParam importParam) { + + Map apidatas = new HashMap(); + + //查询对于人员信息导入筛选的全局配置 + SalarySysConfPO salarySysConfPO = getSalarySysConfMapper().getOneByCode("matchEmployeeMode"); + String confValue = (salarySysConfPO != null && salarySysConfPO.getConfValue() != null && !"".equals(salarySysConfPO.getConfValue())) ? salarySysConfPO.getConfValue() : "0"; + + //检验参数 + checkImportParam(importParam); + + //excel文件id + String imageId = Util.null2String(importParam.getImageId()); + //税款所属期 + String taxYearMonthStr = Util.null2String(importParam.getTaxYearMonth()); + + // 获取所有个税扣缴义务人 + TaxAgentQueryParam param = TaxAgentQueryParam.builder().build(); + param.setFilterType(AuthFilterTypeEnum.ADMIN_DATA); + List taxAgentList = getTaxAgentService(user).listAuth(param); + // 获取租户下所有的人员 + List employees = getSalaryEmployeeService(user).listEmployee(); + // 已经核算过的不可操作 + // 获取已经核算的数据(获取税款所属期下一个月的数据) + YearMonth nextTaxYearMonth = SalaryDateUtil.String2YearMonth(taxYearMonthStr); + String nextTaxYearMonthStr = taxYearMonthStr; + if (!Objects.equals(nextTaxYearMonth.getMonthValue(), 12)) { + nextTaxYearMonth = nextTaxYearMonth.plusMonths(1); + nextTaxYearMonthStr = nextTaxYearMonth.format(SalaryDateUtil.MONTH_FORMATTER); + } + List salaryAcctEmployees = getAddUpDeductionService(user).getAccountedEmployeeDataByTaxYearMonth(nextTaxYearMonthStr); + + //税款所属期 + Date taxYearMonth = SalaryDateUtil.localDateToDate(LocalDate.parse(taxYearMonthStr + "-01", SalaryDateUtil.DATE_FORMATTER)); + // 查询已有数据 + List list = getAddUpSituationMapper().listSome(AddUpSituation.builder().taxYearMonth(taxYearMonth).build()); + + + InputStream fileInputStream = null; + try { + fileInputStream = ImageFileManager.getInputStreamById(Integer.parseInt(imageId)); + + List excelDates = ExcelParseHelper.parse2Map(fileInputStream, AddUpSituationDTO.class, 0, 1, 25, "template.xlsx"); + + int total = excelDates.size(); + int index = 0; + int successCount = 0; + int errorCount = 0; + + + Date now = new Date(); + + + // 错误excel内容 + List errorData = new ArrayList<>(); + //合规数据 + List eligibleData = new ArrayList<>(); + + List taxAgentEmployees = Lists.newArrayList(); + for (int i = 0; i < excelDates.size(); i++) { + //excel中的数据 + AddUpSituationDTO dto = excelDates.get(i); + //待插入数据库对象 + AddUpSituation po = AddUpSituation.builder().tenantKey(DEFAULT_TENANT_KEY) + .createTime(now) + .updateTime(now) + .creator((long) user.getUID()) + .year(Integer.valueOf(taxYearMonthStr.split("-")[0])) + .taxYearMonth(taxYearMonth) + .build(); + + + //异常点数量 + int errorSum = 0; + + //行号 + String rowIndex = String.format("第%s行", i + 2); + + //相同的姓名 + String userName = dto.getUsername(); + String deparmentName = dto.getDepartmentName(); + String mobile = dto.getMobile(); + String workcode = dto.getJobNum(); + String idNo = dto.getIdNo(); + + //筛选导入人员信息可以在人力资源池中匹配到的人员信息 + List employeeSameIds = getSalaryEmployeeService(user).matchImportEmployee(confValue, employees, userName, deparmentName, mobile, workcode, idNo, null); + + //当人员信息导入筛选的全局配置为"0"时,姓名才是必填项 + if (StringUtils.isBlank(userName) && "0".equals(confValue)) { + //姓名 不能为空 + //错误消息对象 + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowIndex + "姓名不能为空"); + errorData.add(errorMessageMap); + errorSum += 1; + } else if (CollectionUtils.isEmpty(employeeSameIds)) { + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowIndex + "员工信息不存在"); + errorData.add(errorMessageMap); + errorSum += 1; + } else if (employeeSameIds.size() > 1) { + //存在离职和在职状态取在职状态 + employeeSameIds = employeeSameIds.stream() + .filter(e -> UserStatusEnum.getNormalStatus().contains(e.getStatus())) + .collect(Collectors.toList()); + if (employeeSameIds.size() != 1) { + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowIndex + "员工信息不存在或者存在多个员工"); + errorData.add(errorMessageMap); + errorSum += 1; + } else { + Long employeeId = CollectionUtils.isNotEmpty(employeeSameIds) && employeeSameIds.size() == 1 ? employeeSameIds.get(0).getEmployeeId() : null; + po.setEmployeeId(employeeId); + } + } else { + Long employeeId = CollectionUtils.isNotEmpty(employeeSameIds) && employeeSameIds.size() == 1 ? employeeSameIds.get(0).getEmployeeId() : null; + if (employeeId != null && employeeId > 0) { + po.setEmployeeId(employeeId); + } else { + //姓名错误,系统内不存在该姓名 + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowIndex + "姓名错误,系统内不存在该姓名"); + errorData.add(errorMessageMap); + errorSum += 1; + } + } + + + String taxAgentName = dto.getTaxAgentName(); + if (StringUtils.isBlank(taxAgentName)) { + //个税扣缴义务人不能为空 + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowIndex + "个税扣缴义务人不能为空"); + errorData.add(errorMessageMap); + errorSum += 1; + } else { + Optional optionalTemp = taxAgentList.stream().filter(m -> m.getName().equals(taxAgentName)).findFirst(); + if (optionalTemp.isPresent()) { + po.setTaxAgentId(optionalTemp.get().getId()); + } else { + //个税扣缴义务人不存在 + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowIndex + "个税扣缴义务人不存在或不在权限范围内"); + errorData.add(errorMessageMap); + errorSum += 1; + } + } + + // 判断是否有核算过 + if (CollectionUtils.isNotEmpty(salaryAcctEmployees) && !Objects.equals(taxYearMonthStr.split("-")[1], "12")) { + Optional optionalAcctEmp = salaryAcctEmployees.stream().filter(f -> f.getEmployeeId().equals(po.getEmployeeId()) && f.getTaxAgentId().equals(po.getTaxAgentId())).findFirst(); + boolean isExist = list.stream().anyMatch(f -> f.getEmployeeId().equals(po.getEmployeeId()) && f.getTaxAgentId().equals(po.getTaxAgentId())); + if (optionalAcctEmp.isPresent() && isExist) { + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowIndex + "该年月这条数据已经核算过,不可导入"); + errorData.add(errorMessageMap); + errorSum += 1; + } + } + + + //累计收入额 + String addUpIncome = dto.getAddUpIncome(); + po.setAddUpIncome(Util.null2String(addUpIncome)); + //累计减除费用 + String addUpSubtraction = dto.getAddUpSubtraction(); + po.setAddUpSubtraction(addUpSubtraction); + //累计社保个人合计 + String addUpSocialSecurityTotal = dto.getAddUpSocialSecurityTotal(); + po.setAddUpSocialSecurityTotal(addUpSocialSecurityTotal); + //累计公积金个人合计 + String addUpAccumulationFundTotal = dto.getAddUpAccumulationFundTotal(); + po.setAddUpAccumulationFundTotal(addUpAccumulationFundTotal); + //累计子女教育 + String addUpChildEducation = dto.getAddUpChildEducation(); + po.setAddUpChildEducation(Util.null2String(addUpChildEducation)); + //累计继续教育 + String addUpContinuingEducation = dto.getAddUpContinuingEducation(); + po.setAddUpContinuingEducation(Util.null2String(addUpContinuingEducation)); + //累计住房贷款利息 + String addUpHousingLoanInterest = dto.getAddUpHousingLoanInterest(); + po.setAddUpHousingLoanInterest(Util.null2String(addUpHousingLoanInterest)); + //累计住房租金 + String addUpHousingRent = dto.getAddUpHousingRent(); + po.setAddUpHousingRent(Util.null2String(addUpHousingRent)); + //累计赡养老人 + String addUpSupportElderly = dto.getAddUpSupportElderly(); + po.setAddUpSupportElderly(Util.null2String(addUpSupportElderly)); + //累计企业(职业)年金及其他福利 + String addUpEnterpriseAndOther = dto.getAddUpEnterpriseAndOther(); + po.setAddUpEnterpriseAndOther(addUpEnterpriseAndOther); + //累计其他扣除 + String addUpOtherDeduction = dto.getAddUpOtherDeduction(); + po.setAddUpOtherDeduction(addUpOtherDeduction); + //累计免税收入 + String addUpTaxExemptIncome = dto.getAddUpTaxExemptIncome(); + po.setAddUpTaxExemptIncome(addUpTaxExemptIncome); + //累计准予扣除的捐赠额 + String addUpAllowedDonation = dto.getAddUpAllowedDonation(); + po.setAddUpAllowedDonation(addUpAllowedDonation); + //累计已预扣预缴税额 + String addUpAdvanceTax = dto.getAddUpAdvanceTax(); + po.setAddUpAdvanceTax(addUpAdvanceTax); + + po.setAddUpIllnessMedical(dto.getAddUpIllnessMedical()); + po.setAddUpTaxSavings(dto.getAddUpTaxSavings()); + po.setAddUpInfantCare(dto.getAddUpInfantCare()); + po.setAddUpPrivatePension(dto.getAddUpPrivatePension()); + + if (errorSum == 0) { + successCount += 1; + // 合格数据 + eligibleData.add(po); + } else { + errorCount += 1; + // 添加错误数据 + } + } + + //入库 + handleImportData(eligibleData); + + apidatas.put("successCount", successCount); + apidatas.put("errorCount", errorCount); + apidatas.put("errorData", errorData); + + } finally { + IOUtils.closeQuietly(fileInputStream); + } + return apidatas; + } + + public void handleImportData(List pos) { + if (CollectionUtils.isEmpty(pos)) { + return; + } + AddUpSituationBiz biz = new AddUpSituationBiz(); + AddUpSituation po = pos.get(0); + // 多条相同人的则以第一条为准,如果逆序排列(用于重复的则以最后一条为准)Collections.reverse(pos); + // 去重(通过记录的唯一条件(申报月份,人员id,个税扣缴义务人id)拼接) + List finalPos = pos.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(f -> f.getEmployeeId() + "-" + f.getTaxAgentId()))), ArrayList::new)); + // 查询已有数据 + List list = biz.listSome(AddUpSituation.builder().taxYearMonth(po.getTaxYearMonth()).build()); + // 待修改的 本地已存在则更新【交集】 + List updateList = list.stream().map(m -> { + Optional optional = finalPos.stream().filter(p -> (p.getEmployeeId() + "-" + p.getTaxAgentId()).equals(m.getEmployeeId() + "-" + m.getTaxAgentId())).findFirst(); + AddUpSituation temp = null; + if (optional.isPresent()) { + temp = optional.get(); + // 换成本地库的id + temp.setId(m.getId()); + } + return temp; + }).filter(Objects::nonNull).collect(Collectors.toList()); + // 待新增的 导入比本地多,则新增【差集(导入 - local)】 + List saveList = finalPos.stream().map(m -> { + Optional optional = list.stream().filter(p -> (p.getEmployeeId() + "-" + p.getTaxAgentId()).equals(m.getEmployeeId() + "-" + m.getTaxAgentId())).findFirst(); + AddUpSituation temp = null; + if (!optional.isPresent()) { + temp = m; + } + return temp; + }).filter(Objects::nonNull).collect(Collectors.toList()); + + // 修改 + if (CollectionUtils.isNotEmpty(updateList)) { + biz.batchUpdate(updateList); + } + // 保存 + if (CollectionUtils.isNotEmpty(saveList)) { + batchSave(saveList); + } + + // 记录操作日志 + // 根据月份、人员id查出保存的数据 + List empIds = saveList.stream().map(AddUpSituation::getEmployeeId).collect(Collectors.toList()); + List insertList = biz.listSome(AddUpSituation.builder().taxYearMonth(po.getTaxYearMonth()).employeeIds(empIds).build()); + Map insertMap = SalaryEntityUtil.convert2Map(insertList, p -> p.getTaxAgentId() + "-" + SalaryDateUtil.getFormatYearMonth(p.getTaxYearMonth()) + "-" + p.getEmployeeId()); + saveList.forEach(save -> { + AddUpSituation addUpSituation = insertMap.get(save.getTaxAgentId() + "-" + SalaryDateUtil.getFormatYearMonth(save.getTaxYearMonth()) + "-" + save.getEmployeeId()); + if (addUpSituation != null) { + updateList.add(addUpSituation); + } + }); + + if (CollectionUtils.isNotEmpty(updateList)) { + LoggerContext loggerContext = new LoggerContext(); + loggerContext.setUser(user); + if (updateList.size() == 1) { + loggerContext.setTargetId(updateList.get(0).getId().toString()); + } + loggerContext.setTargetName(SalaryI18nUtil.getI18nLabel(0, "往期累计情况")); + loggerContext.setOperateType(OperateTypeEnum.ADD.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "导入")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "导入往期累计情况")); + loggerContext.setNewValueList(updateList); + SalaryElogConfig.addUpSituationLoggerTemplate.write(loggerContext); + } + } + + + private void checkImportParam(AddUpSituationImportParam importParam) { + + + //excel文件id + String imageId = Util.null2String(importParam.getImageId()); + //税款所属期 + String declareMonthStr = Util.null2String(importParam.getTaxYearMonth()); + + + if (StringUtils.isBlank(imageId)) { + throw new SalaryRunTimeException("文件不存在"); + } + if (StringUtils.isBlank(declareMonthStr)) { + throw new SalaryRunTimeException("税款所属期为空"); + } + } + + /** + * @return void + * @description 编辑数据 + * @author Harryxzy + * @date 2022/10/27 21:32 + */ + @Override + public void editAddUpSituation(AddUpSituationParam addUpSituationParam) { + AddUpSituationBiz biz = new AddUpSituationBiz(); + //税款所属期 + String taxYearMonthStr = addUpSituationParam.getTaxYearMonth(); + // 获取所有个税扣缴义务人 + TaxAgentQueryParam param = TaxAgentQueryParam.builder().build(); + param.setFilterType(AuthFilterTypeEnum.ADMIN_DATA); + List taxAgentList = getTaxAgentService(user).listAuth(param); + AddUpSituation byId = biz.getById(addUpSituationParam.getId()); + if (byId == null) { + throw new SalaryRunTimeException("该数据不存在!"); + } + Long taxAgentId = byId.getTaxAgentId(); + boolean canEdit = taxAgentList.stream().anyMatch(t -> Objects.equals(t.getId(), taxAgentId)); + if (!canEdit) { + //没有编辑权限 + throw new SalaryRunTimeException("该个税扣缴义务人无权限编辑此数据!"); + } + // 已经核算过的不可操作 + // 获取已经核算的数据(获取税款所属期下一个月的数据) + YearMonth nextTaxYearMonth = SalaryDateUtil.String2YearMonth(taxYearMonthStr); + String nextTaxYearMonthStr = taxYearMonthStr; + if (!Objects.equals(nextTaxYearMonth.getMonthValue(), 12)) { + nextTaxYearMonth = nextTaxYearMonth.plusMonths(1); + nextTaxYearMonthStr = nextTaxYearMonth.format(SalaryDateUtil.MONTH_FORMATTER); + } + List salaryAcctEmployees = getAddUpDeductionService(user).getAccountedEmployeeDataByTaxYearMonth(nextTaxYearMonthStr); + + // 判断是否有核算过 + if (CollectionUtils.isNotEmpty(salaryAcctEmployees) && !Objects.equals(taxYearMonthStr.split("-")[1], "12")) { + Optional optionalAcctEmp = salaryAcctEmployees.stream().filter(f -> f.getEmployeeId().equals(addUpSituationParam.getEmployeeId()) && f.getTaxAgentId().equals(addUpSituationParam.getTaxAgentId())).findFirst(); + if (optionalAcctEmp.isPresent()) { + throw new SalaryRunTimeException("该年月这条数据已经核算过,不可进行编辑!"); + } + } + ArrayList updateList = new ArrayList<>(); + AddUpSituation build = AddUpSituation.builder().id(addUpSituationParam.getId()).addUpIncome(addUpSituationParam.getAddUpIncome()).addUpSubtraction(addUpSituationParam.getAddUpSubtraction()) + .addUpSocialSecurityTotal(addUpSituationParam.getAddUpSocialSecurityTotal()).addUpAccumulationFundTotal(addUpSituationParam.getAddUpAccumulationFundTotal()) + .addUpChildEducation(addUpSituationParam.getAddUpChildEducation()).addUpContinuingEducation(addUpSituationParam.getAddUpContinuingEducation()) + .addUpHousingLoanInterest(addUpSituationParam.getAddUpHousingLoanInterest()).addUpHousingRent(addUpSituationParam.getAddUpHousingRent()) + .addUpSupportElderly(addUpSituationParam.getAddUpSupportElderly()).addUpIllnessMedical(addUpSituationParam.getAddUpIllnessMedical()) + .addUpEnterpriseAndOther(addUpSituationParam.getAddUpEnterpriseAndOther()).addUpOtherDeduction(addUpSituationParam.getAddUpOtherDeduction()) + .addUpTaxExemptIncome(addUpSituationParam.getAddUpTaxExemptIncome()).addUpAllowedDonation(addUpSituationParam.getAddUpAllowedDonation()) + .addUpTaxSavings(addUpSituationParam.getAddUpTaxSavings()).addUpAdvanceTax(addUpSituationParam.getAddUpAdvanceTax()) + .addUpInfantCare(addUpSituationParam.getAddUpInfantCare()) + .addUpPrivatePension(addUpSituationParam.getAddUpPrivatePension()) + .build(); + updateList.add(build); + biz.batchUpdate(updateList); + + // 记录日志 + AddUpSituation newValue = biz.getById(build.getId()); + String name = SalaryI18nUtil.getI18nLabel(0, "编辑"); + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setTargetId(newValue.getId().toString()); + loggerContext.setTargetName(SalaryI18nUtil.getI18nLabel(0, "往期累计情况") + "-" + newValue.getId()); + loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue()); + loggerContext.setOperateTypeName(name); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "往期累计情况") + "-" + SalaryI18nUtil + .getI18nLabel(0, "编辑")); + loggerContext.setOldValues(byId); + loggerContext.setNewValues(newValue); + loggerContext.setUser(user); + SalaryElogConfig.addUpSituationLoggerTemplate.write(loggerContext); + } + + /** + * @return void + * @description 新建数据 + * @author Harryxzy + * @date 2022/10/27 22:04 + */ + @Override + public void createAddUpSituation(AddUpSituationParam addUpSituationParam) { + + Long currentEmployeeId = (long) user.getUID(); + //税款所属期 + String taxYearMonthStr = Util.null2String(addUpSituationParam.getTaxYearMonth()); + // 获取所有个税扣缴义务人 + TaxAgentQueryParam param = TaxAgentQueryParam.builder().build(); + param.setFilterType(AuthFilterTypeEnum.ADMIN_DATA); + List taxAgentList = getTaxAgentService(user).listAuth(param); + // 获取租户下所有的人员 + List employees = getSalaryEmployeeService(user).listEmployee(); + // 已经核算过的不可操作 + // 获取已经核算的数据 + List salaryAcctEmployees = getAddUpDeductionService(user).getAccountedEmployeeDataByTaxYearMonth(taxYearMonthStr); + //税款所属期 + Date taxYearMonth = SalaryDateUtil.localDateToDate(LocalDate.parse(taxYearMonthStr + "-01", SalaryDateUtil.DATE_FORMATTER)); + // 查询已有数据 + List list = getAddUpSituationMapper().listSome(AddUpSituation.builder().taxYearMonth(taxYearMonth).build()); + Date now = new Date(); + //合规数据 + List insertList = new ArrayList<>(); + + //待插入数据库对象 + AddUpSituation po = AddUpSituation.builder().tenantKey(DEFAULT_TENANT_KEY) + .createTime(now) + .updateTime(now) + .creator((long) user.getUID()) + .year(Integer.valueOf(taxYearMonthStr.split("-")[0])) + .taxYearMonth(taxYearMonth) + .build(); + + + //筛选导入人员信息可以在人力资源池中匹配到的人员信息 + boolean employeeSameId = employees.stream().anyMatch(e -> Objects.equals(e.getEmployeeId(), addUpSituationParam.getEmployeeId())); + if (!employeeSameId) { + throw new SalaryRunTimeException("员工信息不存在"); + } + po.setEmployeeId(addUpSituationParam.getEmployeeId()); + String taxAgentName = addUpSituationParam.getTaxAgentName(); + if (StringUtils.isBlank(taxAgentName)) { + //个税扣缴义务人不能为空 + throw new SalaryRunTimeException("个税扣缴义务人不能为空"); + } else { + Optional optionalTemp = taxAgentList.stream().filter(m -> m.getName().equals(taxAgentName)).findFirst(); + if (optionalTemp.isPresent()) { + po.setTaxAgentId(optionalTemp.get().getId()); + } else { + //个税扣缴义务人不存在 + throw new SalaryRunTimeException("个税扣缴义务人不存在或不在权限范围内"); + } + } + + + // 判断是否有核算过 + if (CollectionUtils.isNotEmpty(salaryAcctEmployees)) { + Optional optionalAcctEmp = salaryAcctEmployees.stream().filter(f -> f.getEmployeeId().equals(po.getEmployeeId()) && f.getTaxAgentId().equals(po.getTaxAgentId())).findFirst(); + boolean isExist = list.stream().anyMatch(f -> f.getEmployeeId().equals(po.getEmployeeId()) && f.getTaxAgentId().equals(po.getTaxAgentId())); + if (optionalAcctEmp.isPresent() && isExist) { + throw new SalaryRunTimeException("该年月这条数据已经核算过,不可导入"); + } + } + + //累计收入额 + String addUpIncome = addUpSituationParam.getAddUpIncome(); + po.setAddUpIncome(Util.null2String(addUpIncome)); + //累计减除费用 + String addUpSubtraction = addUpSituationParam.getAddUpSubtraction(); + po.setAddUpSubtraction(addUpSubtraction); + //累计社保个人合计 + String addUpSocialSecurityTotal = addUpSituationParam.getAddUpSocialSecurityTotal(); + po.setAddUpSocialSecurityTotal(addUpSocialSecurityTotal); + //累计公积金个人合计 + String addUpAccumulationFundTotal = addUpSituationParam.getAddUpAccumulationFundTotal(); + po.setAddUpAccumulationFundTotal(addUpAccumulationFundTotal); + //累计子女教育 + String addUpChildEducation = addUpSituationParam.getAddUpChildEducation(); + po.setAddUpChildEducation(Util.null2String(addUpChildEducation)); + //累计继续教育 + String addUpContinuingEducation = addUpSituationParam.getAddUpContinuingEducation(); + po.setAddUpContinuingEducation(Util.null2String(addUpContinuingEducation)); + //累计住房贷款利息 + String addUpHousingLoanInterest = addUpSituationParam.getAddUpHousingLoanInterest(); + po.setAddUpHousingLoanInterest(Util.null2String(addUpHousingLoanInterest)); + //累计住房租金 + String addUpHousingRent = addUpSituationParam.getAddUpHousingRent(); + po.setAddUpHousingRent(Util.null2String(addUpHousingRent)); + //累计赡养老人 + String addUpSupportElderly = addUpSituationParam.getAddUpSupportElderly(); + po.setAddUpSupportElderly(Util.null2String(addUpSupportElderly)); + //累计企业(职业)年金及其他福利 + String addUpEnterpriseAndOther = addUpSituationParam.getAddUpEnterpriseAndOther(); + po.setAddUpEnterpriseAndOther(addUpEnterpriseAndOther); + //累计其他扣除 + String addUpOtherDeduction = addUpSituationParam.getAddUpOtherDeduction(); + po.setAddUpOtherDeduction(addUpOtherDeduction); + //累计免税收入 + String addUpTaxExemptIncome = addUpSituationParam.getAddUpTaxExemptIncome(); + po.setAddUpTaxExemptIncome(addUpTaxExemptIncome); + //累计准予扣除的捐赠额 + String addUpAllowedDonation = addUpSituationParam.getAddUpAllowedDonation(); + po.setAddUpAllowedDonation(addUpAllowedDonation); + //累计已预扣预缴税额 + String addUpAdvanceTax = addUpSituationParam.getAddUpAdvanceTax(); + po.setAddUpAdvanceTax(addUpAdvanceTax); + po.setAddUpIllnessMedical(addUpSituationParam.getAddUpIllnessMedical()); + po.setAddUpTaxSavings(addUpSituationParam.getAddUpTaxSavings()); + po.setAddUpInfantCare(addUpSituationParam.getAddUpInfantCare()); + po.setAddUpPrivatePension(addUpSituationParam.getAddUpPrivatePension()); + insertList.add(po); + + //入库 + handleImportData(insertList); + } + + @Override + public void deleteSelectAddUpSituation(AddUpSituationDeleteParam deleteParam) { + AddUpSituationBiz biz = new AddUpSituationBiz(); + String declareMonthStr = deleteParam.getTaxYearMonth(); + List deleteIds = deleteParam.getIds(); + // 已经核算过的不可操作 + // 获取已经核算的数据 + LocalDate salaryMonthDate = LocalDate.parse(declareMonthStr + "-01", SalaryDateUtil.DATE_FORMATTER); + salaryMonthDate = salaryMonthDate.plusMonths(1); + String format = salaryMonthDate.atStartOfDay().format(DateTimeFormatter.ofPattern("yyyy-MM")); + List salaryAcctEmployees = getAddUpDeductionService(user).getAccountedEmployeeDataByTaxYearMonth(format); + // 判断是否有核算过 + List deletePOList = new ArrayList<>(); + List deleteList = new ArrayList<>(); + + AddUpSituationQueryParam param = AddUpSituationQueryParam.builder().ids(deleteIds).build(); + param.setFilterType(AuthFilterTypeEnum.ADMIN_DATA); + List addUpSituationDTOS = listAuth(param); + if (CollectionUtil.isEmpty(addUpSituationDTOS)) { + throw new SalaryRunTimeException("无权限删除数据!"); + } + + deleteIds = SalaryEntityUtil.properties(addUpSituationDTOS, AddUpSituationDTO::getId, Collectors.toList()); + + + for (int i = 0; i < deleteIds.size(); i++) { + Long id = deleteIds.get(i); + AddUpSituation byId = biz.getById(id); + if (byId == null) { + throw new SalaryRunTimeException("数据不存在或已被删除!"); + } + + // 判断用户是否存在 + if (CollectionUtils.isNotEmpty(salaryAcctEmployees)) { + Optional optionalAcctEmp = salaryAcctEmployees.stream().filter(f -> f.getEmployeeId().equals(byId.getEmployeeId()) && f.getTaxAgentId().equals(byId.getTaxAgentId())).findFirst(); + if (optionalAcctEmp.isPresent()) { + throw new SalaryRunTimeException("所选数据在该年月中已经核算过并归档,不可进行删除!"); + } + } + deleteList.add(byId.getId()); + deletePOList.add(byId); + } + biz.batchDeleteByIDS(deleteList); + + // 记录日志 + deletePOList.stream().forEach(po -> { + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setTargetId(po.getId().toString()); + loggerContext.setTargetName(SalaryI18nUtil.getI18nLabel(0, "往期累计情况") + "-" + po.getId()); + loggerContext.setOperateType(OperateTypeEnum.DELETE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "删除")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "往期累计情况") + "-" + SalaryI18nUtil + .getI18nLabel(0, "删除")); + loggerContext.setOldValues(po); + loggerContext.setUser(user); + SalaryElogConfig.addUpSituationLoggerTemplate.write(loggerContext); + }); + } + + @Override + public void deleteAllAddUpSituation(AddUpSituationDeleteParam deleteParam) { + String declareMonthStr = deleteParam.getTaxYearMonth(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + AddUpSituationBiz biz = new AddUpSituationBiz(); + Date declareMonthDate = new Date(); + try { + declareMonthDate = (sdf.parse(declareMonthStr + "-01")); + } catch (Exception e) { + throw new SalaryRunTimeException("日期异常"); + } + AddUpSituation queryParam = AddUpSituation.builder().taxYearMonth(declareMonthDate).build(); + + if (deleteParam.getTaxAgentId() != null && !deleteParam.getTaxAgentId().isEmpty()) { + // 设置了个税扣缴义务人 + Long taxAgentId = SalaryEntityUtil.string2Long(deleteParam.getTaxAgentId()); + ArrayList tai = new ArrayList<>(); + tai.add(taxAgentId); + queryParam.setTaxAgentIds(tai); + } + + // 获取所有想要删除的数据 + List list = biz.listSome(queryParam); + list = getAuthService(user).auth(list, AuthFilterTypeEnum.ADMIN_DATA, AddUpSituation.class); + + LocalDate salaryMonthDate = LocalDate.parse(declareMonthStr + "-01", SalaryDateUtil.DATE_FORMATTER); + String format = salaryMonthDate.plusMonths(1).atStartOfDay().format(DateTimeFormatter.ofPattern("yyyy-MM")); + // 获取已经核算的数据 + List employees = getAddUpDeductionService(user).getAccountedEmployeeDataByTaxYearMonth(format); + for (AddUpSituation item : list) { + if (CollectionUtils.isNotEmpty(employees)) { + Optional optionalAcctEmp = employees.stream().filter(f -> f.getEmployeeId().equals(item.getEmployeeId()) && f.getTaxAgentId().equals(item.getTaxAgentId())).findFirst(); + if (optionalAcctEmp.isPresent()) { + throw new SalaryRunTimeException("有员工在该年月中已经完成核算并归档,不能进行一键清空!"); + } + } + } + List deleteIds = list.stream().map(AddUpSituation::getId).collect(Collectors.toList()); + biz.batchDeleteByIDS(deleteIds); + + // 记录日志 + String name = declareMonthStr +"-"+ deleteParam.getTaxAgentId(); + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setTargetName(name); + loggerContext.setOperateType(OperateTypeEnum.CLEAR.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "一键清空")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "往期累计情况") + "-" + SalaryI18nUtil + .getI18nLabel(0, "一键清空:") + name); + loggerContext.setUser(user); + SalaryElogConfig.addUpSituationLoggerTemplate.write(loggerContext); + } + + @Override + public AddUpSituationRecordDTO getAddUpSituation(AddUpSituationParam addUpSituationParam) { + ArrayList ids = new ArrayList<>(); + ids.add(addUpSituationParam.getId()); + AddUpSituationQueryParam build = AddUpSituationQueryParam.builder().ids(ids).build(); + List list = biz.recordList(build); + if (list == null || list.size() == 0) { + throw new SalaryRunTimeException("该数据不存在!"); + } + return list.get(0); + } + + @Override + public void batchSave(List list) { + if (CollectionUtils.isNotEmpty(list)) { + encryptUtil.encryptList(list, AddUpSituation.class); + List> partition = Lists.partition(list, 50); + partition.forEach(getAddUpSituationMapper()::insertData); + } + + } +} diff --git a/src/com/engine/salary/service/impl/AttendQuoteDataServiceImpl.java b/src/com/engine/salary/service/impl/AttendQuoteDataServiceImpl.java new file mode 100644 index 000000000..0ff7b6674 --- /dev/null +++ b/src/com/engine/salary/service/impl/AttendQuoteDataServiceImpl.java @@ -0,0 +1,1044 @@ +package com.engine.salary.service.impl; + +import cn.hutool.core.util.NumberUtil; +import com.alibaba.druid.support.json.JSONUtils; +import com.alibaba.fastjson.JSONObject; +import com.api.formmode.mybatis.util.SqlProxyHandle; +import com.cloudstore.eccom.pc.table.WeaTable; +import com.cloudstore.eccom.pc.table.WeaTableColumn; +import com.cloudstore.eccom.result.WeaResultMsg; +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.hrmelog.entity.dto.LoggerContext; +import com.engine.salary.biz.AttendQuoteBiz; +import com.engine.salary.biz.AttendQuoteDataBiz; +import com.engine.salary.biz.AttendQuoteDataValueBiz; +import com.engine.salary.biz.AttendQuoteFieldBiz; +import com.engine.salary.common.LocalDateRange; +import com.engine.salary.config.SalaryElogConfig; +import com.engine.salary.constant.SalaryDefaultTenantConstant; +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.datacollection.bo.AttendQuoteDataBO; +import com.engine.salary.entity.datacollection.dto.*; +import com.engine.salary.entity.datacollection.param.*; +import com.engine.salary.entity.datacollection.po.AttendQuoteDataPO; +import com.engine.salary.entity.datacollection.po.AttendQuoteDataValuePO; +import com.engine.salary.entity.datacollection.po.AttendQuoteFieldPO; +import com.engine.salary.entity.datacollection.po.AttendQuotePO; +import com.engine.salary.entity.salaryacct.bo.SalaryAcctEmployeeBO; +import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO; +import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO; +import com.engine.salary.entity.salaryarchive.dto.SalaryArchiveDataDTO; +import com.engine.salary.entity.salarysob.dto.SalarySobCycleDTO; +import com.engine.salary.entity.salarysob.po.SalarySobPO; +import com.engine.salary.enums.OperateTypeEnum; +import com.engine.salary.enums.UserStatusEnum; +import com.engine.salary.enums.datacollection.AttendQuoteSourceTypeEnum; +import com.engine.salary.enums.datacollection.UseEmployeeTypeEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.mapper.datacollection.AttendQuoteDataMapper; +import com.engine.salary.mapper.salarysob.SalarySobMapper; +import com.engine.salary.mapper.salarysob.SalarySobRangeMapper; +import com.engine.salary.mapper.sys.SalarySysConfMapper; +import com.engine.salary.remote.attend.entity.Attend4Salary; +import com.engine.salary.remote.attend.service.RemoteAttend4SalaryService; +import com.engine.salary.remote.attend.service.impl.RemoteAttend4SalaryServiceImpl; +import com.engine.salary.service.*; +import com.engine.salary.sys.entity.po.SalarySysConfPO; +import com.engine.salary.sys.entity.vo.OrderRuleVO; +import com.engine.salary.sys.service.SalarySysConfService; +import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl; +import com.engine.salary.util.SalaryDateUtil; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.db.IdGenerator; +import com.engine.salary.util.db.MapperProxyFactory; +import com.engine.salary.util.excel.ExcelParseHelper; +import com.engine.salary.util.excel.ExcelSupport; +import com.engine.salary.util.excel.ExcelUtil; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.util.page.SalaryPageUtil; +import com.engine.salary.util.valid.ValidUtil; +import com.google.common.base.Joiner; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.util.IOUtils; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import weaver.file.ImageFileManager; +import weaver.general.BaseBean; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.wechat.util.Utils; + +import java.io.InputStream; +import java.math.BigDecimal; +import java.time.YearMonth; +import java.util.*; +import java.util.stream.Collectors; + +import static com.engine.salary.util.excel.ExcelSupport.EXCEL_TYPE_XLSX; + +/** + * 数据采集-考勤引用数据 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Slf4j +public class AttendQuoteDataServiceImpl extends Service implements AttendQuoteDataService { + private final Boolean isLog = "true".equals(new BaseBean().getPropValue("hrmSalary", "log")); + + private AttendQuoteBiz quoteBiz = new AttendQuoteBiz(); + private AttendQuoteDataBiz dataBiz = new AttendQuoteDataBiz(); + private AttendQuoteDataValueBiz dataValueBiz = new AttendQuoteDataValueBiz(); + private AttendQuoteFieldBiz fieldBiz = new AttendQuoteFieldBiz(); + + private AttendQuoteFieldSettingService getFieldSettingService(User user) { + return ServiceUtil.getService(AttendQuoteFieldSettingServiceImpl.class, user); + } + + private SalarySysConfService getSalarySysConfService(User user) { + return ServiceUtil.getService(SalarySysConfServiceImpl.class, user); + } + + private SalarySobService getSalarySobService(User user) { + return ServiceUtil.getService(SalarySobServiceImpl.class, user); + } + + private AttendQuoteService getAttendQuoteService(User user) { + return ServiceUtil.getService(AttendQuoteServiceImpl.class, user); + } + + private AttendQuoteDataMapper getAttendQuoteDataMapper() { + return MapperProxyFactory.getProxy(AttendQuoteDataMapper.class); + } + + private SalarySobMapper getSalarySobMapper() { + return MapperProxyFactory.getProxy(SalarySobMapper.class); + } + + private SalarySobRangeMapper getSalarySobRangeMapper() { + return MapperProxyFactory.getProxy(SalarySobRangeMapper.class); + } + + private SalaryArchiveService getSalaryArchiveService(User user) { + return ServiceUtil.getService(SalaryArchiveServiceImpl.class, user); + } + + + private RemoteAttend4SalaryService getRemoteAttend4SalaryService(User user) { + return ServiceUtil.getService(RemoteAttend4SalaryServiceImpl.class, user); + } + + private SalaryEmployeeService getSalaryEmployeeService(User user) { + return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user); + } + + private SalarySysConfMapper getSalarySysConfMapper() { + return SqlProxyHandle.getProxy(SalarySysConfMapper.class); + } + + @Override + public PageInfo listPage(AttendQuoteDataQueryParam queryParam) { + //排序配置 + OrderRuleVO orderRule = getSalarySysConfService(user).orderRule(); + queryParam.setOrderRule(orderRule); + + List list = getAttendQuoteDataMapper().list(queryParam); + PageInfo page = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), list, AttendQuoteDataBaseDTO.class); + return page; + } + + /** + * 获取所有考勤字段 + * + * @return + */ + private List getAllAttendQuoteFields() { + return fieldBiz.listSome(AttendQuoteFieldPO.builder().build()); + } + + /** + * 获取考勤数据结果 + * + * @param attendQuoteDataBases + * @return + */ + public List> getListMaps(List attendQuoteDataBases) { + if (CollectionUtils.isEmpty(attendQuoteDataBases)) { + return new ArrayList<>(); + } + + // 考核数据值 + List attendQuoteDataValues = dataValueBiz.listSome(AttendQuoteDataValuePO.builder().attendQuoteId(attendQuoteDataBases.get(0).getAttendQuoteId()).build()); + + return attendQuoteDataBases.stream().map(m -> { + Map map = new LinkedHashMap<>(); + map.put("id", m.getId()); + map.put("username", m.getUsername()); + map.put("departmentName", m.getDepartmentName()); + map.put("mobile", m.getMobile()); + map.put("jobNum", m.getJobNum()); + map.put("idNo", m.getIdNo()); + // 考勤数据 + attendQuoteDataValues.stream().filter(a -> a.getAttendQuoteDataId().equals(m.getId())).collect(Collectors.toList()).forEach(e -> { + map.put(e.getAttendQuoteFieldId() + "_attendQuoteData", e.getDataValue()); + }); + return map; + }).collect(Collectors.toList()); + } + + + @Override + public List getAttendQuoteData(YearMonth salaryYearMonth, Long salarySobId, List employeeIds) { + if (salaryYearMonth == null || salarySobId == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100358, "参数有误:薪资所属月、薪资账套id")); + } + List list = new ArrayList<>(); + Date salaryYearMonthDay = SalaryDateUtil.localDateToDate(salaryYearMonth.atDay(1)); + //查询引用主表 + List attendQuotes = quoteBiz.listSome(AttendQuotePO.builder().salaryYearMonth(salaryYearMonthDay).salarySobId(salarySobId).build()); + + if (CollectionUtils.isEmpty(attendQuotes)) { + return Collections.emptyList(); + } + AttendQuotePO attendQuote = attendQuotes.get(0); + + //查询考勤数据值 + List attendQuoteDataValues = dataValueBiz.listSome(AttendQuoteDataValuePO.builder().attendQuoteId(attendQuote.getId()).employeeIds(employeeIds).build()); + + + if (CollectionUtils.isEmpty(employeeIds)) { + employeeIds = attendQuoteDataValues.stream().map(AttendQuoteDataValuePO::getEmployeeId) + .distinct().collect(Collectors.toList()); + } + + employeeIds.forEach(e -> { + AttendQuoteDataDTO attendQuoteData = new AttendQuoteDataDTO(); + attendQuoteData.setEmployeeId(e); + List dataValues = attendQuoteDataValues.stream().filter(v -> v.getEmployeeId().equals(e)).map(m -> + AttendQuoteDataValueDTO.builder() + .attendQuoteFieldId(m.getAttendQuoteFieldId()) + .dataValue(m.getDataValue()) + .build()).collect(Collectors.toList()); + attendQuoteData.setDataValues(dataValues); + list.add(attendQuoteData); + }); + return list; + } + + @Override + public XSSFWorkbook export(AttendQuoteDataQueryParam queryParam) { + if (queryParam.getAttendQuoteId() == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100253, "考勤引用id不能为空")); + } + + //排序配置 + OrderRuleVO orderRule = getSalarySysConfService(user).orderRule(); + queryParam.setOrderRule(orderRule); + + // 考勤数据分页主数据 + List attendQuoteDataBases = dataBiz.list(queryParam); + // 所有考勤字段 + List attendQuoteFields = getAllAttendQuoteFields(); + // 获取最终结果 + List> listMaps = getListMaps(attendQuoteDataBases); + + + //当前引用的值 + List effectiveColumns = listMaps.stream() + .map(Map::keySet) + .max(Comparator.comparingInt(Set::size)) + .orElse(new HashSet<>()) + .stream() + .map(key -> key.split("_")[0]) + .collect(Collectors.toList()); + + // 1.工作簿名称 + String sheetName = SalaryI18nUtil.getI18nLabel(93931, "考勤数据"); + List header = new ArrayList<>(); + header.add(SalaryI18nUtil.getI18nLabel(85429, "姓名")); + header.add(SalaryI18nUtil.getI18nLabel(86185, "部门")); + header.add(SalaryI18nUtil.getI18nLabel(86186, "手机号")); + header.add(SalaryI18nUtil.getI18nLabel(86317, "工号")); + // 动态列 + List effectiveFields = new ArrayList<>(); + if (CollectionUtils.isNotEmpty(listMaps)) { + effectiveFields = attendQuoteFields.stream() + .filter(attendQuoteField -> effectiveColumns.contains(Util.null2String(attendQuoteField.getId()))) + .collect(Collectors.toList()); + + effectiveFields.forEach(attendQuoteField -> { + header.add(attendQuoteField.getFieldName()); + } + ); + } + + List> rows = new ArrayList<>(); + // 2.表头 + rows.add(header); + // 3.表数据 + for (Map dto : listMaps) { + List row = new ArrayList<>(); + row.add(dto.get("username")); + row.add(dto.get("departmentName")); + row.add(dto.get("mobile")); + row.add(dto.get("jobNum")); + + // 动态列 + for (AttendQuoteFieldPO attendQuoteField : effectiveFields) { + Object o = dto.get(attendQuoteField.getId().toString() + "_attendQuoteData"); + try { + if (o != null && NumberUtil.isNumber(o.toString())) { + row.add(new BigDecimal(o.toString())); + } else { + row.add(o); + } + } catch (Exception e) { + row.add(o); + } + } + rows.add(row); + } + + // 记录日志 + AttendQuotePO attendQuotePO = getAttendQuoteService(user).getById(queryParam.getAttendQuoteId()); + SalarySobPO salarySob = getSalarySobService(user).getById(attendQuotePO.getSalarySobId()); + + LoggerContext loggerContext = new LoggerContext(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(attendQuotePO.getId())); + loggerContext.setTargetName(SalaryDateUtil.getFormatYearMonth(attendQuotePO.getSalaryYearMonth()) + " " + (salarySob != null ? salarySob.getName() : "")); + loggerContext.setOperateType(OperateTypeEnum.EXCEL_EXPORT.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "导出考勤数据")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "考勤数据")); + SalaryElogConfig.attendQuoteLoggerTemplate.write(loggerContext); + + return ExcelUtil.genWorkbookV2(rows, sheetName); + + } + + + /** + * 获取表头设置字段 + * + * @param sourceType + * @return + */ + private List getAttendQuoteSetFields(AttendQuoteSourceTypeEnum sourceType) { + List allAttendQuoteFields = getAllAttendQuoteFields(); + List attendQuoteFieldSettingList = getFieldSettingService(user).listNoSync(AttendQuoteFieldSettingQueryParam.builder().sourceType(sourceType).isViewChecked(Boolean.TRUE).build()); + List attendQuoteFields = new ArrayList<>(); + attendQuoteFieldSettingList.forEach(s -> { + List items = s.getItems(); + if (CollectionUtils.isNotEmpty(items)) { + items.forEach(i -> { + Optional optional = allAttendQuoteFields.stream().filter(f -> f.getId().equals(i.getId())).findFirst(); + optional.ifPresent(attendQuoteFields::add); + }); + } + }); + return attendQuoteFields; + } + + @Override + public String syncAttendQuoteData(AttendQuoteDataSyncParam syncParam) { + AttendQuoteDataSyncParam.checkParam(syncParam); + List salarySobIds = syncParam.getSalarySobIds(); + String salaryYearMonth = syncParam.getSalaryYearMonth(); + int year = Integer.parseInt(salaryYearMonth.split("-")[0]); + int month = Integer.parseInt(salaryYearMonth.split("-")[1]); + if (!SalaryDateUtil.checkYearMonth(salaryYearMonth)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100365, "薪资所属月格式有误,正确格式示例为'2021-01'")); + } + + // 1.获取已设置的可同步的考勤字段 + List attendQuoteFields = getAttendQuoteSetFields(AttendQuoteSourceTypeEnum.QUOTE); + if (CollectionUtils.isEmpty(attendQuoteFields)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100366, "请先设置同步字段")); + } + + String errorMsg = ""; + for (Long salarySobId : salarySobIds) { + // 获取薪资账套 + SalarySobCycleDTO salarySobCycleDTO = getSalarySobService(user).getSalarySobCycle(salarySobId, YearMonth.of(year, month)); + SalarySobPO salarySobPO = getSalarySobService(user).getById(salarySobId); + + // 根据薪资账套查询人员 + List salaryEmployees = getSalaryEmployeeService(user).listBySalarySobId(salarySobId,false); + if (CollectionUtils.isEmpty(salaryEmployees)) { + errorMsg = errorMsg + "【" + salarySobPO.getName() + "】薪资账套没有人员; "; + } else { + // 根据薪资账套查询薪资周期 + List taxAgentIds = salarySobPO.getTaxAgentIds(); + + // 查询薪资档案,获取人员的个税扣缴义务人 + List employeeIds = SalaryEntityUtil.properties(salaryEmployees, DataCollectionEmployee::getEmployeeId, Collectors.toList()); + List salaryArchiveDataDTOS = getSalaryArchiveService(user).getSalaryArchiveTaxAgentData(salarySobCycleDTO.getSalaryCycle(), employeeIds, taxAgentIds); + // 转换成薪资核算人员po + Date salaryDate = SalaryDateUtil.dateStrToLocalDate(salaryYearMonth + "-01"); + List salaryAcctEmployeePOS = SalaryAcctEmployeeBO.convert2Employee(salaryEmployees, SalaryAcctRecordPO.builder().salarySobId(salarySobId).salaryMonth(salaryDate).build(), salaryArchiveDataDTOS, (long) user.getUID()); + + //过滤掉不属于当前账套扣缴义务人的人员 + employeeIds = salaryAcctEmployeePOS.stream().filter(po -> taxAgentIds.contains(po.getTaxAgentId())).map(SalaryAcctEmployeePO::getEmployeeId).collect(Collectors.toList()); + + + // 4.获取考勤模块数据 + List> attendQuoteSyncData = getAttendQuoteDataFromRemoteAttend(salarySobCycleDTO.getAttendCycle(), employeeIds, attendQuoteFields); + List pos = new ArrayList<>(); + List values = new ArrayList<>(); + // 5.考勤引用数据处理 + Date now = new Date(); + if (CollectionUtils.isNotEmpty(attendQuoteSyncData)) { + + // 3.生成考勤引用 + AttendQuotePO attendQuote = getAttendQuote(AttendQuoteSourceTypeEnum.QUOTE, salarySobId, year, month, syncParam.getDescription()); + + for (Long employeeId : employeeIds) { + AttendQuoteDataPO po = new AttendQuoteDataPO(); + po.setId(IdGenerator.generate()); + po.setCreateTime(now); + po.setUpdateTime(now); + po.setCreator((long) user.getUID()); + po.setTenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY); + // 考勤引用表的主键id + po.setAttendQuoteId(attendQuote.getId()); + po.setEmployeeId(employeeId); + pos.add(po); + for (Map attendQuoteData : attendQuoteSyncData) { + if (!Objects.isNull(attendQuoteData.get("employeeId")) && + !Objects.isNull(employeeId) && + !Objects.isNull(attendQuoteData.get("attendQuoteFieldId")) && + attendQuoteData.get("employeeId").toString().equals(employeeId.toString())) { + values.add(AttendQuoteDataValuePO.builder() + .createTime(now) + .updateTime(now) + .creator((long) user.getUID()) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .employeeId(employeeId) + .attendQuoteId(attendQuote.getId()) + .attendQuoteDataId(po.getId()) + .attendQuoteFieldId(Long.valueOf(attendQuoteData.get("attendQuoteFieldId").toString())) + .dataValue(Utils.null2String(attendQuoteData.get("dataValue"))) + .build()); + } + } + } + + // 6.数据落库处理 + handleDataToDB(attendQuote.getId(), pos, values); + // 记录日志 + recordLog(attendQuote); + } else { + errorMsg = errorMsg + "【" + salarySobPO.getName() + "】" + "暂无考勤数据可以同步; "; + } + } + } + + if (StringUtils.isNotBlank(errorMsg)) { + throw new SalaryRunTimeException(errorMsg); + } + return null; + } + + private void recordLog(AttendQuotePO attendQuote) { + SalarySobPO salarySob = getSalarySobService(user).getById(attendQuote.getSalarySobId()); + String sourceType = AttendQuoteSourceTypeEnum.getDefaultLabelByValue(attendQuote.getSourceType()); + + LoggerContext loggerContext = new LoggerContext(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(attendQuote.getId())); + loggerContext.setTargetName(SalaryDateUtil.getFormatYearMonth(attendQuote.getSalaryYearMonth()) + " " + (salarySob != null ? salarySob.getName() : "")); + loggerContext.setOperateType(OperateTypeEnum.ADD.getValue()); + loggerContext.setOperateTypeName(sourceType + SalaryI18nUtil.getI18nLabel(0, "考勤数据")); + loggerContext.setOperatedesc(sourceType + SalaryI18nUtil.getI18nLabel(0, "考勤数据")); + loggerContext.setNewValues(attendQuote); + SalaryElogConfig.attendQuoteLoggerTemplate.write(loggerContext); + } + + + /** + * 获取考勤引用 + * + * @param salarySobId + * @param year + * @param month + * @return + */ + private AttendQuotePO getAttendQuote(AttendQuoteSourceTypeEnum sourceType, Long salarySobId, int year, int month, String description) { + SalarySobCycleDTO salarySobCycle = getSalarySobService(user).getSalarySobCycle(salarySobId, YearMonth.of(year, month)); + + Date salaryYearMonthDayDate = SalaryDateUtil.localDateToDate(YearMonth.of(year, month).atDay(1)); + List attendQuotes = quoteBiz.listSome(AttendQuotePO.builder().salarySobId(salarySobId).salaryYearMonth(salaryYearMonthDayDate).build()); + // 考勤引用 + AttendQuotePO attendQuote = new AttendQuotePO(); + if (CollectionUtils.isNotEmpty(attendQuotes)) { + attendQuote = attendQuotes.get(0); + } + attendQuote.setSalarySobId(salarySobCycle.getSalarySobId()); + LocalDateRange salaryCycleRange = salarySobCycle.getSalaryCycle(); + LocalDateRange attendCycleRange = salarySobCycle.getAttendCycle(); + // 考勤周期 + attendQuote.setAttendCycle(SalaryDateUtil.getFormatLocalDate(attendCycleRange.getFromDate()) + " ~ " + SalaryDateUtil.getFormatLocalDate(attendCycleRange.getEndDate())); + // 薪资周期 + attendQuote.setSalaryCycle(SalaryDateUtil.getFormatLocalDate(salaryCycleRange.getFromDate()) + " ~ " + SalaryDateUtil.getFormatLocalDate(salaryCycleRange.getEndDate())); + attendQuote.setSalaryYearMonth(salaryYearMonthDayDate); + // 来源:导入 + attendQuote.setSourceType(sourceType.getValue()); + attendQuote.setDescription(description); + Date now = new Date(); + attendQuote.setCreateTime(now); + attendQuote.setUpdateTime(now); + attendQuote.setCreator((long) user.getUID()); + attendQuote.setTenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY); + // 新增或修改考勤引用 + if (attendQuote.getId() != null) { + quoteBiz.updateById(attendQuote); + } else { + attendQuote.setId(IdGenerator.generate()); + quoteBiz.insert(attendQuote); + } + return attendQuote; + } + + /** + * 获取考勤模块数据 + * + * @param attendCycleRange + * @param employeeIds + * @param attendQuoteFields + * @return + */ + private List> getAttendQuoteDataFromRemoteAttend(LocalDateRange attendCycleRange, List employeeIds, List attendQuoteFields) { + List> attendQuoteSyncData = new ArrayList<>(); + Attend4Salary attend4Salary = new Attend4Salary(); + try { + int partSize = 500; + List> partition = Lists.partition(employeeIds, partSize); + for (List part : partition) { + attend4Salary.setBeginDate(attendCycleRange.getFromDate()); + attend4Salary.setEndDate(attendCycleRange.getEndDate()); + attend4Salary.setOnlyEmpIds(part); + //班次信息 + String attendanceSerial = attendQuoteFields.stream() + .filter(f -> f.getCode() != null && f.getCode().startsWith("attendanceSerial_")) + .map(f -> f.getCode().replace("attendanceSerial_", "")) + .collect(Collectors.joining(",")); + attend4Salary.setAttendanceSerial(attendanceSerial); + + List> attendResult = getRemoteAttend4SalaryService(user).getDatas(attend4Salary); + + AttendQuoteDataBO.buildAttendDataFromRemote(attendResult, attendQuoteFields, attendQuoteSyncData); + + } + } catch (Exception e) { + log.error("salaryAttend获取考勤数据错误失败:{}", String.format("参数:%s,错误信息:%s", JSONObject.toJSONString(attend4Salary), e.getMessage()), e); + return attendQuoteSyncData; + } + if (isLog) { + log.info("salaryAttend同步的考勤数据:{}", JSONUtils.toJSONString(attendQuoteSyncData)); + } + return attendQuoteSyncData; + } + + /** + * 引用同步或导入落库处理 + * + * @param attendQuoteId + * @param pos + * @param values + */ + private void handleDataToDB(Long attendQuoteId, List pos, List values) { + // 数据落库处理 + if (CollectionUtils.isEmpty(pos)) { + return; + } + // 多条相同人的则以第一条为准,如果逆序排列(用于重复的则以最后一条为准)Collections.reverse(pos); + pos = pos.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(f -> f.getEmployeeId()))), ArrayList::new)); + // 删除考勤数据 + ArrayList quoteIds = new ArrayList<>(); + quoteIds.add(attendQuoteId); + dataBiz.deleteByAttendQuoteIds(quoteIds); + // 新增考勤数据 + dataBiz.insertData(pos); + // 删除考勤值数据 +// dataValueBiz.deleteByAttendQuoteDataIds(pos.stream().map(AttendQuoteDataPO::getId).collect(Collectors.toList())); + dataValueBiz.deleteByAttendQuoteIds(quoteIds); + // 新增考勤值数据 + if (CollectionUtils.isNotEmpty(values)) { + //去除空值 + values = values.stream().filter(po -> StringUtils.isNotBlank(po.getDataValue())).collect(Collectors.toList()); + dataValueBiz.insertData(values); + } + } + + @Override + public XSSFWorkbook downloadTemplate(AttendQuoteDataExportTemplateParam exportParam) { + try { + // 考勤主数据 + Date salaryYearMonth = SalaryDateUtil.localDateToDate(exportParam.getSalaryYearMonth().atDay(1)); + List attendQuotePOS = quoteBiz.listSome(AttendQuotePO.builder() + .salarySobId(exportParam.getSalarySobId()) + .salaryYearMonth(salaryYearMonth) + .ids(exportParam.getIds()).build()); + AttendQuotePO po = CollectionUtils.isNotEmpty(attendQuotePOS) ? attendQuotePOS.get(0) : null; + AttendQuoteDataQueryParam queryParam = AttendQuoteDataQueryParam.builder().attendQuoteId(po == null ? 0L : po.getId()).build(); + List attendQuoteDataBases = dataBiz.list(queryParam); + + // 获取已设置的可同步的字段 + List attendQuoteFields = getAttendQuoteSetFields(AttendQuoteSourceTypeEnum.IMPORT); + // 获取最终结果 + List> listMaps = getListMaps(attendQuoteDataBases); + + // 1.工作簿名称 + String sheetName = SalaryI18nUtil.getI18nLabel(101606, "考勤引用导入模板"); + List header = new ArrayList<>(); + header.add(SalaryI18nUtil.getI18nLabel(85429, "姓名")); + header.add(SalaryI18nUtil.getI18nLabel(86185, "部门")); + header.add(SalaryI18nUtil.getI18nLabel(86186, "手机号")); + header.add(SalaryI18nUtil.getI18nLabel(86317, "工号")); + header.add(SalaryI18nUtil.getI18nLabel(86317, "证件号码")); + // 动态列 + for (AttendQuoteFieldPO attendQuoteField : attendQuoteFields) { + header.add(attendQuoteField.getFieldName()); + } + List> rows = new ArrayList<>(); + rows.add(header); + for (Map dto : listMaps) { + List row = new ArrayList<>(); + row.add(dto.get("username")); + row.add(dto.get("departmentName")); + row.add(dto.get("mobile")); + row.add(dto.get("jobNum")); + +// // 动态列 +// Map map = listMaps.get(0); +// for (AttendQuoteFieldPO attendQuoteField : attendQuoteFields) { +// row.add(map.containsKey(attendQuoteField.getId() + "_attendQuoteData") ? dto.get(attendQuoteField.getId() + "_attendQuoteData") : ""); +// } + rows.add(row); + } + + return ExcelUtil.genWorkbookV2(rows, sheetName); + } catch (Exception e) { + log.error("salaryAttend下载模板失败", e); + } + return null; + } + + /** + * 导入的数据插入到数据库中 + */ + public Map preview(AttendQuoteDataImportParam param) { + ValidUtil.doValidator(param); + Long salarySobId = param.getSalarySobId(); + SalarySobPO salarySobPO = getSalarySobService(user).getById(salarySobId); + if (salarySobPO == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100537, "薪资账套不存在")); + } + String salaryYearMonth = param.getSalaryYearMonth(); + if (!SalaryDateUtil.checkYearMonth(salaryYearMonth)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100365, "薪资所属月格式有误,正确格式示例为'2021-01'")); + } + + InputStream fileInputStream = null; + try { + fileInputStream = ImageFileManager.getInputStreamById(Integer.parseInt(param.getImageId())); + Sheet sheet = ExcelSupport.parseFile(fileInputStream, 0, EXCEL_TYPE_XLSX); + Map apidatas = new HashMap(); + apidatas.put("headers", ExcelSupport.getSheetHeader(sheet, 0)); + apidatas.put("list", ExcelParseHelper.parse2List(sheet, 1)); + return apidatas; + } finally { + IOUtils.closeQuietly(fileInputStream); + } + + } + + /** + * 导入的数据插入到数据库中 + */ + public Map importAttendQuoteData(AttendQuoteDataImportParam param) { + ValidUtil.doValidator(param); + Long salarySobId = param.getSalarySobId(); + SalarySobPO salarySobPO = getSalarySobService(user).getById(salarySobId); + if (salarySobPO == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100537, "薪资账套不存在")); + } + String salaryYearMonth = param.getSalaryYearMonth(); + if (!SalaryDateUtil.checkYearMonth(salaryYearMonth)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100365, "薪资所属月格式有误,正确格式示例为'2021-01'")); + } + int year = Integer.parseInt(salaryYearMonth.split("-")[0]); + int month = Integer.parseInt(salaryYearMonth.split("-")[1]); + + //查询对于人员信息导入筛选的全局配置 + SalarySysConfPO salarySysConfPO = getSalarySysConfMapper().getOneByCode("matchEmployeeMode"); + String confValue = (salarySysConfPO != null && salarySysConfPO.getConfValue() != null && !"".equals(salarySysConfPO.getConfValue())) ? salarySysConfPO.getConfValue() : "0"; + + // 获取租户下所有的人员 + List employees = getSalaryEmployeeService(user).listAll(UseEmployeeTypeEnum.ALL); + // 获取已设置的可同步的考勤字段 + List attendQuoteFields = getAttendQuoteSetFields(AttendQuoteSourceTypeEnum.IMPORT); + // 生成获取考勤引用 + AttendQuotePO attendQuote = getAttendQuote(AttendQuoteSourceTypeEnum.IMPORT, salarySobId, year, month, StringUtils.EMPTY); + + int total = 0; + + int index = 0; + int successCount = 0; + int errorCount = 0; + + // 待导入数据 + List pos = new ArrayList<>(); + List values = new ArrayList<>(); + String valI18n = SalaryI18nUtil.getI18nLabel(100581, "请输入数字"); + + InputStream fileInputStream = null; + try { + fileInputStream = ImageFileManager.getInputStreamById(Integer.parseInt(param.getImageId())); + Sheet sheet = ExcelSupport.parseFile(fileInputStream, 0, EXCEL_TYPE_XLSX); + // 表头 + List headers = ExcelSupport.getSheetHeader(sheet, 0); + + // 错误sheet数据 + List> errorData = new ArrayList<>(); + // 错误提示 + List> excelComments = new ArrayList<>(); + + //验证字段是否缺失 + String isValidHeader = checkHeaders(headers, attendQuoteFields); + if (StringUtils.isNotBlank(isValidHeader)) { + Map apidatas = new HashMap(); + apidatas.put("successCount", successCount); + apidatas.put("errorCount", errorCount); + + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", isValidHeader); + excelComments.add(errorMessageMap); + apidatas.put("errorData", excelComments); + return apidatas; + } + + + // 处理数值 + List> data = ExcelParseHelper.parse2Map(sheet, 1); + total = data.size(); + + Map map; + Date now = new Date(); + + AttendQuoteDataPO po; + for (int i = 0; i < data.size(); i++) { + index += 1; + String rowIndex = "第" + index + "行"; + map = data.get(i); + + po = new AttendQuoteDataPO(); + po.setId(IdGenerator.generate()); + po.setCreateTime(now); + po.setUpdateTime(now); + po.setCreator((long) user.getUID()); + po.setTenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY); + // 考勤引用表的主键id + po.setAttendQuoteId(attendQuote.getId()); + + int errorSum = 0; + + String userName = Optional.ofNullable(map.get(SalaryI18nUtil.getI18nLabel(85429, "姓名"))).orElse("").toString(); + String deparmentName = Optional.ofNullable(map.get(SalaryI18nUtil.getI18nLabel(86185, "部门"))).orElse("").toString(); + String mobile = Optional.ofNullable(map.get(SalaryI18nUtil.getI18nLabel(86186, "手机号"))).orElse("").toString(); + String workcode = Optional.ofNullable(map.get(SalaryI18nUtil.getI18nLabel(86317, "工号"))).orElse("").toString(); + String idNo = Optional.ofNullable(map.get(SalaryI18nUtil.getI18nLabel(86317, "证件号码"))).orElse("").toString(); + List employeeSameIds = new ArrayList<>(); + + //筛选导入人员信息可以在人力资源池中匹配到的人员信息 + List emps = getSalaryEmployeeService(user).matchImportEmployee(confValue, employees, userName, deparmentName, mobile, workcode, idNo, null); + //含在职和离职,选在职数据 + if (CollectionUtils.isNotEmpty(emps) && emps.size() > 1) { + employeeSameIds = emps.stream() + .filter(e -> UserStatusEnum.getNormalStatus().contains(e.getStatus())) + .map(DataCollectionEmployee::getEmployeeId) + .collect(Collectors.toList()); + } + if (CollectionUtils.isNotEmpty(emps) && emps.size() == 1) { + employeeSameIds = emps.stream() + .map(DataCollectionEmployee::getEmployeeId) + .collect(Collectors.toList()); + } + + + for (int j = 0; j < headers.size(); j++) { + String key = headers.get(j); + if (key == null) { + continue; + } + String cellVal = Optional.ofNullable(map.get(key.toString())).orElse("").toString(); + if (SalaryI18nUtil.getI18nLabel(85429, "姓名").equals(key.toString())) { + //当人员信息导入筛选的全局配置为"0"时,姓名才是必填项 + if (StringUtils.isEmpty(cellVal) && "0".equals(confValue)) { + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowIndex + SalaryI18nUtil.getI18nLabel(100579, "姓名不能为空")); + excelComments.add(errorMessageMap); + errorSum += 1; + } else if (CollectionUtils.isEmpty(employeeSameIds) || employeeSameIds.size() > 1) { + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowIndex + SalaryI18nUtil.getI18nLabel(100579, "员工信息不存在或者存在多个员工")); + excelComments.add(errorMessageMap); + errorSum += 1; + } else { + Long employeeId = CollectionUtils.isNotEmpty(employeeSameIds) && employeeSameIds.size() == 1 ? employeeSameIds.get(0) : null; + if (employeeId != null && employeeId > 0) { + po.setEmployeeId(employeeId); + } else { + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowIndex + SalaryI18nUtil.getI18nLabel(100579, "姓名错误,系统内不存在该姓名")); + excelComments.add(errorMessageMap); + errorSum += 1; + } + } + } + if (po.getEmployeeId() != null) { + String bigDecimalValue; + for (AttendQuoteFieldPO attendQuoteField : attendQuoteFields) { + if (attendQuoteField.getFieldName().equals(key)) { + if (1 == attendQuoteField.getFieldType()) { + bigDecimalValue = bigDecimalVal(cellVal, excelComments, valI18n, errorCount + 1, j); + errorSum += StringUtils.isEmpty(bigDecimalValue) ? 1 : 0; + if (StringUtils.isNotEmpty(bigDecimalValue)) { + values.add(AttendQuoteDataValuePO.builder() + .createTime(now) + .updateTime(now) + .creator((long) user.getUID()) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .employeeId(po.getEmployeeId()) + .attendQuoteId(attendQuote.getId()) + .attendQuoteDataId(po.getId()) + .attendQuoteFieldId(attendQuoteField.getId()) + .dataValue(Utils.null2String(bigDecimalValue)) + .build()); + } + } else { + values.add(AttendQuoteDataValuePO.builder() + .createTime(now) + .updateTime(now) + .creator((long) user.getUID()) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .employeeId(po.getEmployeeId()) + .attendQuoteId(attendQuote.getId()) + .attendQuoteDataId(po.getId()) + .attendQuoteFieldId(attendQuoteField.getId()) + .dataValue(Utils.null2String(cellVal)) + .build()); + } + } + } + } + } + + if (errorSum > 0) { + errorCount += 1; + // 添加错误数据 + errorData.add(map); + } else { + successCount += 1; + // 成功一条就添加一条记录 + pos.add(po); + } + // 导入进度 +// salaryBatchService.sendImportRate(message.getBizId(), total, index); + } + + // 数据入库处理 + handleDataToDB(attendQuote.getId(), pos, values); + + + // 记录日志 + recordLog(attendQuote); + + Map apidatas = new HashMap(); + apidatas.put("successCount", successCount); + apidatas.put("errorCount", errorCount); + apidatas.put("errorData", excelComments); + return apidatas; + } finally { + IOUtils.closeQuietly(fileInputStream); + } + + } + + /** + * @return null + * @description 编辑数据 + * @author Harryxzy + * @date 2022/10/28 14:40 + */ + @Override + public void editData(AttendQuoteDataEditParam attendQuoteDataEditParam) { + Map attendQuoteData = attendQuoteDataEditParam.getAttendQuoteData(); + AttendQuoteDataBiz dataBiz = new AttendQuoteDataBiz(); + AttendQuoteDataValueBiz attendQuoteDataValueBiz = new AttendQuoteDataValueBiz(); + ArrayList ids = new ArrayList<>(); + ids.add(attendQuoteDataEditParam.getId()); + AttendQuoteDataQueryParam build = AttendQuoteDataQueryParam.builder().ids(ids).build(); + List list = dataBiz.list(build); + if (list == null || list.size() == 0) { + throw new SalaryRunTimeException("该数据不存在!"); + } + Map attendQuoteFieldData = new HashMap<>(); + for (Map.Entry entrySet : attendQuoteData.entrySet()) { + String[] s = entrySet.getKey().split("_"); + attendQuoteFieldData.put(s[0], entrySet.getValue()); + } + for (Map.Entry entrySet : attendQuoteFieldData.entrySet()) { + AttendQuoteDataValuePO updatePO = AttendQuoteDataValuePO.builder().employeeId(list.get(0).getEmployeeId()).attendQuoteFieldId(SalaryEntityUtil.string2Long(entrySet.getKey())).dataValue(entrySet.getValue()).build(); + attendQuoteDataValueBiz.updateDataValue(updatePO); + } + } + + /** + * @return void + * @description 获取数据 + * @author Harryxzy + * @date 2022/10/31 14:12 + */ + @Override + public Map getData(AttendQuoteDataEditParam attendQuoteDataEditParam) { + ArrayList ids = new ArrayList<>(); + ids.add(attendQuoteDataEditParam.getId()); + AttendQuoteDataQueryParam build = AttendQuoteDataQueryParam.builder().ids(ids).build(); + List list = dataBiz.list(build); + if (list == null || list.size() == 0) { + throw new SalaryRunTimeException("该数据不存在!"); + } + // 所有考勤字段 + List attendQuoteFields = getAllAttendQuoteFields(); + // 获取最终结果 + List> listMaps = getListMaps(list); + List columns = new ArrayList<>(); + columns.add(new WeaTableColumn("150", SalaryI18nUtil.getI18nLabel(85429, "姓名"), "username")); + columns.add(new WeaTableColumn("150", SalaryI18nUtil.getI18nLabel(86185, "部门"), "departmentName")); + columns.add(new WeaTableColumn("150", SalaryI18nUtil.getI18nLabel(86186, "手机号"), "mobile")); + columns.add(new WeaTableColumn("150", SalaryI18nUtil.getI18nLabel(86317, "工号"), "jobNum")); + + // 动态列 + if (CollectionUtils.isNotEmpty(listMaps)) { + Map map = listMaps.stream().max(Comparator.comparingInt(m -> m.keySet().size())).get(); + for (AttendQuoteFieldPO attendQuoteField : attendQuoteFields) { + if (map.containsKey(attendQuoteField.getId() + "_attendQuoteData")) { + columns.add(new WeaTableColumn("150", attendQuoteField.getFieldName(), attendQuoteField.getId() + "_attendQuoteData")); + } + } + } + WeaTable weaTable = new WeaTable(); + weaTable.setColumns(columns); + WeaResultMsg result = new WeaResultMsg(false); + result.putAll(weaTable.makeDataResult()); + result.success(); + Map datas = new HashMap<>(); + datas.put("data", listMaps.get(0)); + datas.put("dataKey", result.getResultMap()); + return datas; + } + + /** + * 获取金额数字值 + * + * @param bigDecimalValStr + * @param excelComments + * @param i + * @param j + * @return + */ + private String bigDecimalVal(String bigDecimalValStr, List> excelComments, String valI18n, int i, int j) { + if (StringUtils.isBlank(bigDecimalValStr)) { + return BigDecimal.ZERO.toString(); + } + BigDecimal bigDecimalVal = null; + try { + bigDecimalVal = new BigDecimal(bigDecimalValStr); + } catch (Exception e) { + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", valI18n); + excelComments.add(errorMessageMap); +// salaryBatchService.createExcelComment(excelComments, valI18n, i, i, j, j); + } + return bigDecimalVal == null ? "" : bigDecimalVal.toString(); + } + + + /** + * 检查参数 + * + * @param message + * @param params + * @return + */ +// private boolean checkParams(BatchDocumentMessage message, Map params) { +// boolean isValid = true; +// String errorMsg = ""; +// if (params == null) { +// errorMsg = SalaryI18nUtil.getI18nLabel(message.getTenantKey(), message.getUserId(), 100582, "参数必传"); +// } else { +// if (!params.containsKey("salaryYearMonth") +// || !params.containsKey("salarySobId") +// || params.get("salaryYearMonth") == null +// || params.get("salarySobId") == null) { +// errorMsg = SalaryI18nUtil.getI18nLabel(message.getTenantKey(), message.getUserId(), 100588, "薪资所属月和薪资账套必传"); +// } else { +// String salaryYearMonth = params.get("salaryYearMonth").toString(); +// if (!SalaryDateUtil.checkYearMonth(salaryYearMonth)) { +// errorMsg = SalaryI18nUtil.getI18nLabel(message.getTenantKey(), message.getUserId(), 100365, "薪资所属月格式有误,正确格式示例为'2021-01'"); +// } else { +// List salarySobs = new LambdaQueryChainWrapper<>(getSalarySobMapper()) +// .eq(SalarySobPO::getTenantKey, message.getTenantKey()) +// .eq(SalarySobPO::getDeleteType, 0) +// .eq(SalarySobPO::getId, Long.valueOf(params.get("salarySobId").toString())) +// .list(); +// if (CollectionUtils.isEmpty(salarySobs)) { +// errorMsg = SalaryI18nUtil.getI18nLabel(message.getTenantKey(), message.getUserId(), 100537, "薪资账套不存在"); +// } +// } +// } +// } +// // 有错误信息发送 +// if (StringUtils.isNotEmpty(errorMsg)) { +// // 发送导入回调信息 +// salaryBatchService.sendImportCallBackInfo(message, errorMsg); +// isValid = false; +// } +// return isValid; +// } + + /** + * 检查列头 + * + * @return + */ + private String checkHeaders(List headerList, List attendQuoteFields) { + boolean isValid = true; + String userNameI18n = SalaryI18nUtil.getI18nLabel(85429, "姓名"); + + List mustHeaders = attendQuoteFields.stream().map(AttendQuoteFieldPO::getFieldName).collect(Collectors.toList()); + mustHeaders.add(userNameI18n); + + // 缺少的必须列 + List lackHeaders = mustHeaders.stream().filter(item -> !headerList.contains(item)).collect(Collectors.toList()); + + String errorMsg = ""; + String checkHeaderI18n = SalaryI18nUtil.getI18nLabel(101850, "缺少如下列,请检查:"); + if (CollectionUtils.isEmpty(attendQuoteFields)) { + errorMsg = SalaryI18nUtil.getI18nLabel(101849, "考勤字段列缺失,请补充"); + } else if (CollectionUtils.isNotEmpty(lackHeaders)) { + errorMsg = checkHeaderI18n + Joiner.on(",").join((Iterable) lackHeaders); + } + + return errorMsg; + } +} diff --git a/src/com/engine/salary/service/impl/AttendQuoteFieldServiceImpl.java b/src/com/engine/salary/service/impl/AttendQuoteFieldServiceImpl.java new file mode 100644 index 000000000..2448254f9 --- /dev/null +++ b/src/com/engine/salary/service/impl/AttendQuoteFieldServiceImpl.java @@ -0,0 +1,356 @@ +package com.engine.salary.service.impl; + +import com.cloudstore.eccom.result.WeaResultMsg; +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.biz.AttendQuoteFieldBiz; +import com.engine.salary.component.SalaryWeaTable; +import com.engine.salary.config.SalaryElogConfig; +import com.engine.hrmelog.entity.dto.LoggerContext; +import com.engine.salary.entity.datacollection.dto.AttendQuoteFieldListDTO; +import com.engine.salary.entity.datacollection.param.AttendQuoteFieldQueryParam; +import com.engine.salary.entity.datacollection.param.AttendQuoteFieldSaveParam; +import com.engine.salary.entity.datacollection.po.AttendQuoteFieldPO; +import com.engine.salary.enums.OperateTypeEnum; +import com.engine.salary.enums.datacollection.AttendQuoteFieldSourceTypeEnum; +import com.engine.salary.enums.datacollection.AttendQuoteFieldTypeEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.mapper.datacollection.AttendQuoteFieldMapper; +import com.engine.salary.remote.attend.service.RemoteAttend4SalaryService; +import com.engine.salary.remote.attend.service.impl.RemoteAttend4SalaryServiceImpl; +import com.engine.salary.service.AttendQuoteFieldService; +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.page.SalaryPageUtil; +import com.google.common.collect.Lists; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.springframework.beans.BeanUtils; +import weaver.hrm.User; + +import java.util.*; +import java.util.stream.Collectors; + +import static com.engine.salary.constant.SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY; + +/** + * 数据采集-考勤引用字段 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Slf4j +public class AttendQuoteFieldServiceImpl extends Service implements AttendQuoteFieldService { + + AttendQuoteFieldBiz biz = new AttendQuoteFieldBiz(); + + private AttendQuoteFieldMapper getAttendQuoteFieldMapper() { + return MapperProxyFactory.getProxy(AttendQuoteFieldMapper.class); + } + + private RemoteAttend4SalaryService getRemoteAttend4SalaryService(User user) { + return (RemoteAttend4SalaryService) ServiceUtil.getService(RemoteAttend4SalaryServiceImpl.class, user); + } + + +// +// private RemoteAttendInitVacationService remoteAttendInitVacationService; +// +// private LoggerTemplate attendQuoteFieldLoggerTemplate; + + + @Override + public List getAllAttendQuoteFields() { + return getAttendQuoteFieldMapper().listAll(); + } + + @Override + public PageInfo listPage(AttendQuoteFieldQueryParam queryParam) { + List list = getAttendQuoteFieldMapper().list(queryParam); + return SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), list, AttendQuoteFieldListDTO.class); + } + + + @Override + public AttendQuoteFieldPO getById(Long id) { + return getAttendQuoteFieldMapper().getById(id); + } + + + @Override + public Map list(AttendQuoteFieldQueryParam queryParam) { + syncAttendFields(); + + String fields = " t1.id," + + " t1.field_name as fieldName," + + " t1.source_type as sourceType," + + " t1.field_type as fieldType," + + " t1.enable_status as enableStatus," + + " t1.description"; + + String fromSql = " FROM" + + " hrsa_attend_quote_field t1 "; + + SalaryWeaTable table = new SalaryWeaTable(user, AttendQuoteFieldListDTO.class); + table.setBackfields(fields); + table.setSqlform(fromSql); + table.setSqlwhere(AttendQuoteFieldQueryParam.genWhereSql(queryParam)); + table.setSqlorderby("t1.source_type,t1.id DESC"); + table.setSqlprimarykey("t1.id"); + table.setSqlisdistinct("false"); + + WeaResultMsg result = new WeaResultMsg(false); + result.putAll(table.makeDataResult()); + result.success(); + return result.getResultMap(); + } + + + @Override + public AttendQuoteFieldPO getFrom(Long id) { + if (id != null) { + AttendQuoteFieldPO po = biz.getById(id); + if (po == null) { + throw new SalaryRunTimeException(String.format("字段不存在[id:%s]", id)); + } + return po; + } + return null; + } + + @Override + public String save(AttendQuoteFieldSaveParam saveParam) { + //参数校验 + AttendQuoteFieldSaveParam.checkParam(saveParam); + + List attendQuoteFields = biz.listSome(AttendQuoteFieldPO.builder().fieldName(saveParam.getFieldName()).build()); + if (CollectionUtils.isNotEmpty(attendQuoteFields)) { + throw new SalaryRunTimeException("字段名称不允许重复"); + } + + Date now = new Date(); + AttendQuoteFieldPO attendQuoteField = AttendQuoteFieldPO.builder() + .fieldName(saveParam.getFieldName()) + .sourceType(AttendQuoteFieldSourceTypeEnum.DEFAULT.getValue()) + .fieldType(saveParam.getFieldType().getValue()) + .enableStatus(saveParam.getEnableStatus() ? 1 : 0) + .description(saveParam.getDescription()) + .createTime(now) + .updateTime(now) + .creator((long) user.getUID()) + .tenantKey(DEFAULT_TENANT_KEY) + .build(); + // 保存 + biz.save(attendQuoteField); + + // 记录日志 + LoggerContext loggerContext = new LoggerContext(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(attendQuoteField.getId())); + loggerContext.setTargetName(attendQuoteField.getFieldName()); + loggerContext.setOperateType(OperateTypeEnum.ADD.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "新建自定义字段")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "新建自定义字段")); + loggerContext.setNewValues(attendQuoteField); + SalaryElogConfig.attendQuoteFieldLoggerTemplate.write(loggerContext); + + return null; + } + + @Override + public String update(AttendQuoteFieldSaveParam saveParam) { + // 校验是否可以编辑 + AttendQuoteFieldSaveParam.checkParam(saveParam); + if (saveParam.getId() == null) { + throw new SalaryRunTimeException("id为空"); + } + AttendQuoteFieldPO attendQuoteField = biz.getById(saveParam.getId()); + if (attendQuoteField == null) { + throw new SalaryRunTimeException("该字段不存在"); + } + if (!attendQuoteField.getSourceType().equals(AttendQuoteFieldSourceTypeEnum.DEFAULT.getValue())) { + throw new SalaryRunTimeException("来源只能为自定义"); + } + List attendQuoteFields = biz.listSome(AttendQuoteFieldPO.builder().fieldName(saveParam.getFieldName()).build()); + if (CollectionUtils.isNotEmpty(attendQuoteFields)) { + boolean fieldNameExist = attendQuoteFields.stream().anyMatch(e -> !Objects.equals(e.getId(), saveParam.getId())); + if (fieldNameExist) { + throw new SalaryRunTimeException("字段名称不允许重复"); + } + } + + AttendQuoteFieldPO newAttendQuoteField = new AttendQuoteFieldPO(); + BeanUtils.copyProperties(attendQuoteField, newAttendQuoteField); + newAttendQuoteField.setFieldName(saveParam.getFieldName()); + newAttendQuoteField.setFieldType(saveParam.getFieldType().getValue()); + newAttendQuoteField.setEnableStatus(saveParam.getEnableStatus() ? 1 : 0); + newAttendQuoteField.setDescription(saveParam.getDescription()); + newAttendQuoteField.setUpdateTime(new Date()); + // 更新 + biz.update(newAttendQuoteField); + + return null; + } + + @Override + public String delete(Collection ids) { + if (CollectionUtils.isEmpty(ids)) { + throw new SalaryRunTimeException("参数错误"); + } + List attendQuoteFields = biz.list(AttendQuoteFieldQueryParam.builder().ids(ids).build()); + if (CollectionUtils.isEmpty(attendQuoteFields)) { + throw new SalaryRunTimeException("要删除的数据在不存在或已删除"); + } + + List attendQuoteAttendFields = attendQuoteFields.stream().filter(e -> e.getSourceType().equals(String.valueOf(AttendQuoteFieldSourceTypeEnum.ATTEND.getValue()))).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(attendQuoteAttendFields)) { + throw new SalaryRunTimeException("考勤模块的字段不能删除"); + } + + // TODO 正在使用的记录不允许删除 + biz.deleteByIds(ids); + return null; + } + + @Override + public String updateEnableStatus(AttendQuoteFieldSaveParam param) { + // 校验是否可以编辑 + Long id = param.getId(); + Boolean enableStatus = param.getEnableStatus(); + if (id == null || enableStatus == null) { + throw new SalaryRunTimeException("参数错误"); + } + AttendQuoteFieldPO attendQuoteField = biz.getById(id); + if (attendQuoteField == null) { + throw new SalaryRunTimeException("该字段不存在"); + } + if (!attendQuoteField.getSourceType().equals(AttendQuoteFieldSourceTypeEnum.DEFAULT.getValue())) { + throw new SalaryRunTimeException("来源只能为自定义"); + } + + AttendQuoteFieldPO newAttendQuoteField = new AttendQuoteFieldPO(); + BeanUtils.copyProperties(attendQuoteField, newAttendQuoteField); + newAttendQuoteField.setEnableStatus(enableStatus ? 1 : 0); + newAttendQuoteField.setUpdateTime(new Date()); + // 更新 + biz.update(newAttendQuoteField); + + // 记录日志 + LoggerContext loggerContext = new LoggerContext(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(attendQuoteField.getId())); + loggerContext.setTargetName(attendQuoteField.getFieldName()); + loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "启用/停用自定义字段")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "启用/停用自定义字段")); + loggerContext.setOldValues(attendQuoteField); + loggerContext.setNewValues(newAttendQuoteField); + SalaryElogConfig.attendQuoteFieldLoggerTemplate.write(loggerContext); + return null; + } + + @Override + public String syncAttendFields() { + // 所有字段管理的考勤模块引用字段 + List attendQuoteFields = biz.listSome(AttendQuoteFieldPO.builder().sourceType(AttendQuoteFieldSourceTypeEnum.ATTEND.getValue()).build()); + // 1.本地字段 + List localFieldCodes = attendQuoteFields.stream().map(AttendQuoteFieldPO::getCode).collect(Collectors.toList()); + + // 2.考勤模块字段 + List> columns = new ArrayList<>(); + try { + columns = getRemoteAttend4SalaryService(user).getColumns(); + } catch (Exception e) { + log.error("同步考勤字段失败,RemoteAttend4SalaryService.getColumns:{}", e.getMessage()); + } + List attendFieldCodes = columns.stream().map(m -> m.get("code")).collect(Collectors.toList()); +// List attendLeaveFieldCodes = Lists.newArrayList(); +// attendLeaveFieldCodes.addAll(attendLeaveHourFieldCodes); + // 所有考勤模块字段编码 +// List attendFieldCodes = Lists.newArrayList(); +// attendFieldCodes.addAll(attendLeaveFieldCodes); + // 考勤模块固定字段 +// List> attendFixedFieldCodes = AttendQuoteFieldBO.buildAttendFixedFields(); +// attendFieldCodes.addAll(attendFixedFieldCodes.stream().map(m -> m.get("code")).collect(Collectors.toList())); + + // 本地已存在则更新【交集】 + List updateCodes = localFieldCodes.stream().filter(item -> attendFieldCodes.contains(item)).collect(Collectors.toList()); + // 本地比attend多,则删除【差集(local - attend)】 + Collection deleteCodes = localFieldCodes.stream().filter(item -> !attendFieldCodes.contains(item)).collect(Collectors.toList()); + // attend比本地多,则新增【差集(attend - local)】 + List saveCodes = attendFieldCodes.stream().filter(item -> !localFieldCodes.contains(item)).collect(Collectors.toList()); + + // 1.更新 == 目前除了请假类型其余都是固定,故只需更新请假类型部分 + List updates = Lists.newArrayList(); + Date now = new Date(); + for (String code : updateCodes) { + Optional> columnsOptional = columns.stream().filter(column -> code.equals(column.get("code"))).findFirst(); + if (columnsOptional.isPresent()) { + Map column = columnsOptional.get(); + updates.add(AttendQuoteFieldPO.builder() + .code(column.get("code")) + .fieldName(column.get("name")) + .updateTime(now) + .build()); + } + } + + if (CollectionUtils.isNotEmpty(updates)) { + getAttendQuoteFieldMapper().updateNameByCode(updates); + } + // 2.删除 +// if (CollectionUtils.isNotEmpty(deleteCodes)) { +// //根据考勤字段编码删除考勤模块字段 +// biz.deleteAttendByCode(AttendQuoteFieldQueryParam.builder().codes(deleteCodes).sourceType(AttendQuoteFieldSourceTypeEnum.ATTEND.getValue()).build()); +// } + // 3.新增 + List saves = new ArrayList<>(); + for (String code : saveCodes) { + Optional> columnsOptional = columns.stream().filter(column -> code.equals(column.get("code"))).findFirst(); + if (columnsOptional.isPresent()) { + Map column = columnsOptional.get(); + saves.add(buildAttendQuoteField(column.get("code"), column.get("name"))); + } + } + if (CollectionUtils.isNotEmpty(saves)) { + biz.saveBatch(saves); + } + + //假期余额 + + + + return null; + } + + /** + * 构建考勤字段 + * + * @param code + * @param name + * @return + */ + private AttendQuoteFieldPO buildAttendQuoteField(String code, String name) { + Date now = new Date(); + return AttendQuoteFieldPO.builder() + .code(code) + .fieldName(name) + .sourceType(AttendQuoteFieldSourceTypeEnum.ATTEND.getValue()) + .fieldType(AttendQuoteFieldTypeEnum.NUMBER.getValue()) + .enableStatus(1) + .description("") + .createTime(now) + .updateTime(now) + .creator((long)user.getUID()) + .tenantKey(DEFAULT_TENANT_KEY) + .build(); + } + + @Override + public List listAll() { + return biz.list(AttendQuoteFieldQueryParam.builder().build()); + } +} diff --git a/src/com/engine/salary/service/impl/AttendQuoteFieldSettingServiceImpl.java b/src/com/engine/salary/service/impl/AttendQuoteFieldSettingServiceImpl.java new file mode 100644 index 000000000..dd8eef639 --- /dev/null +++ b/src/com/engine/salary/service/impl/AttendQuoteFieldSettingServiceImpl.java @@ -0,0 +1,282 @@ +package com.engine.salary.service.impl; + +import com.alibaba.fastjson.JSON; +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.biz.AttendQuoteFieldBiz; +import com.engine.salary.biz.AttendQuoteFieldSettingBiz; +import com.engine.salary.constant.SalaryDefaultTenantConstant; +import com.engine.salary.entity.datacollection.dto.AttendQuoteFieldSettingFieldListDTO; +import com.engine.salary.entity.datacollection.dto.AttendQuoteFieldSettingListDTO; +import com.engine.salary.entity.datacollection.param.AttendModuleSettingFieldParam; +import com.engine.salary.entity.datacollection.param.AttendQuoteFieldSettingQueryParam; +import com.engine.salary.entity.datacollection.param.AttendQuoteFieldSettingRecoverParam; +import com.engine.salary.entity.datacollection.param.AttendQuoteFieldSettingSaveParam; +import com.engine.salary.entity.datacollection.po.AttendQuoteFieldPO; +import com.engine.salary.entity.datacollection.po.AttendQuoteFieldSettingPO; +import com.engine.salary.enums.datacollection.AttendQuoteFieldSourceTypeEnum; +import com.engine.salary.enums.datacollection.AttendQuoteSourceTypeEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.service.AttendQuoteFieldService; +import com.engine.salary.service.AttendQuoteFieldSettingService; +import com.engine.salary.util.valid.ValidUtil; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.BeanUtils; +import weaver.hrm.User; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; + +/** + * 数据采集-考勤引用字段设置 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class AttendQuoteFieldSettingServiceImpl extends Service implements AttendQuoteFieldSettingService { + + private AttendQuoteFieldSettingBiz biz = new AttendQuoteFieldSettingBiz(); + + private AttendQuoteFieldBiz fieldBiz = new AttendQuoteFieldBiz(); + + // +// private AttendQuoteFieldSettingMapper mapper; +// +// private AttendQuoteFieldMapper attendQuoteFieldMapper; +// +// private LoggerTemplate attendQuoteFieldSettingLoggerTemplate; + private AttendQuoteFieldService getAttendQuoteFieldService(User user) { + return (AttendQuoteFieldService) ServiceUtil.getService(AttendQuoteFieldServiceImpl.class, user); + } + @Override + public List list(AttendQuoteFieldSettingQueryParam queryParam) { + //同步字段 + getAttendQuoteFieldService(user).syncAttendFields(); + // 获取字段设置 + List list = biz.getAttendQuoteFieldSetting(queryParam.getSourceType()); + + List resultList = new ArrayList<>(); + // 考勤模块分组字段 + resultList.add(buildAttendQuoteFieldSetting(CollectionUtils.isEmpty(list) ? null : list.get(0), AttendQuoteFieldSourceTypeEnum.ATTEND, "", queryParam.getKeyword(), queryParam.getIsViewChecked())); + // 如果是导入还包含自定义分组 + if (queryParam.getSourceType().equals(AttendQuoteSourceTypeEnum.IMPORT)) { + resultList.add(buildAttendQuoteFieldSetting(CollectionUtils.isEmpty(list) ? null : list.get(0), AttendQuoteFieldSourceTypeEnum.DEFAULT, "", queryParam.getKeyword(), queryParam.getIsViewChecked())); + } + return resultList; + } + + + /** + * 获取所有字段 + */ + private List getAllAttendQuoteFields() { + return fieldBiz.listSome(AttendQuoteFieldPO.builder().build()); + } + + @Override + public List listNoSync(AttendQuoteFieldSettingQueryParam queryParam) { + // 获取字段设置 + List list = biz.getAttendQuoteFieldSetting(queryParam.getSourceType()); + + List resultList = new ArrayList<>(); + // 考勤模块分组字段 + resultList.add(buildAttendQuoteFieldSetting(CollectionUtils.isEmpty(list) ? null : list.get(0), AttendQuoteFieldSourceTypeEnum.ATTEND, "", queryParam.getKeyword(), queryParam.getIsViewChecked())); + // 如果是导入还包含自定义分组 + if (queryParam.getSourceType().equals(AttendQuoteSourceTypeEnum.IMPORT)) { + resultList.add(buildAttendQuoteFieldSetting(CollectionUtils.isEmpty(list) ? null : list.get(0), AttendQuoteFieldSourceTypeEnum.DEFAULT, "", queryParam.getKeyword(), queryParam.getIsViewChecked())); + } + + return resultList; + } + + + /** + * 构建字段组设置 + * + * @param po + * @param fieldSourceType + * @param keyword + * @param isViewChecked + * @return + */ + private AttendQuoteFieldSettingListDTO buildAttendQuoteFieldSetting(AttendQuoteFieldSettingPO po, AttendQuoteFieldSourceTypeEnum fieldSourceType, String type, String keyword, Boolean isViewChecked) { + // 根据来源获取字段 + List attendQuoteFields = getAllAttendQuoteFields(); + attendQuoteFields = attendQuoteFields.stream().filter(f -> f.getSourceType() == fieldSourceType.getValue()).collect(Collectors.toList()); + + List fieldList = new ArrayList<>(); + // 没有设置过 + if (po == null) { + fieldList = attendQuoteFields.stream().map(m -> + AttendQuoteFieldSettingFieldListDTO.builder() + .id(m.getId()) + .name(m.getFieldName()) + .checked(Boolean.FALSE) + .build() + ).collect(Collectors.toList()); + } else { + // 设置过,则解析 + List settingFields; + // 如果是恢复默认设置 + if ("recoverAsDefault".equals(type)) { + settingFields = JSON.parseArray(po.getDefaultSettingContent(), AttendQuoteFieldSettingFieldListDTO.class); + } else { + settingFields = JSON.parseArray(po.getCurrentSettingContent(), AttendQuoteFieldSettingFieldListDTO.class); + } + + for (AttendQuoteFieldPO attendQuoteField : attendQuoteFields) { + Optional optional = settingFields.stream().filter(e -> e.getId().equals(attendQuoteField.getId())).findFirst(); + if (optional.isPresent()) { + fieldList.add(AttendQuoteFieldSettingFieldListDTO.builder() + .id(attendQuoteField.getId()) + .name(attendQuoteField.getFieldName()) + .checked(optional.get().getChecked()) + .build()); + } else { + fieldList.add(AttendQuoteFieldSettingFieldListDTO.builder() + .id(attendQuoteField.getId()) + .name(attendQuoteField.getFieldName()) + .checked(Boolean.FALSE) + .build()); + } + } + } + // 关键字过滤 + if (StringUtils.isNotEmpty(keyword)) { + fieldList = fieldList.stream().filter(e -> e.getName().contains(keyword)).collect(Collectors.toList()); + } + // 是否只显示已选中字段 + if (isViewChecked != null && isViewChecked) { + fieldList = fieldList.stream().filter(AttendQuoteFieldSettingFieldListDTO::getChecked).collect(Collectors.toList()); + } + + return AttendQuoteFieldSettingListDTO.builder() + .groupId(fieldSourceType.name()) + .groupName(fieldSourceType.getDefaultLabel()) + .items(fieldList) + .build(); + } + + + @Override + public List recoverAsDefault(AttendQuoteFieldSettingRecoverParam recoverParam) { + + ValidUtil.doValidator(recoverParam); + + // 获取字段设置 + List list = biz.getAttendQuoteFieldSetting(recoverParam.getSourceType()); + List resultList = new ArrayList<>(); + // 考勤模块分组字段 + resultList.add(buildAttendQuoteFieldSetting(CollectionUtils.isEmpty(list) ? null : list.get(0), AttendQuoteFieldSourceTypeEnum.ATTEND, "recoverAsDefault", "", Boolean.FALSE)); + // 如果是导入还包含自定义分组 + if (recoverParam.getSourceType().equals(AttendQuoteSourceTypeEnum.IMPORT)) { + resultList.add(buildAttendQuoteFieldSetting(CollectionUtils.isEmpty(list) ? null : list.get(0), AttendQuoteFieldSourceTypeEnum.DEFAULT, "recoverAsDefault", "", Boolean.FALSE)); + } + return resultList; + } + + @Override + public String save(AttendQuoteFieldSettingSaveParam saveParam) { + + if (saveParam == null) { + throw new SalaryRunTimeException("参数异常"); + } + if (CollectionUtils.isEmpty(saveParam.getCurrentSettingFields())) { + throw new SalaryRunTimeException("字段不能为空"); + } + // 所有字段 + List allAttendFields = getAllAttendQuoteFields(); + + List attendFields = saveParam.getCurrentSettingFields(); + for (AttendModuleSettingFieldParam attendField : attendFields) { + Optional optional = allAttendFields.stream().filter(e -> e.getId().equals(attendField.getId())).findFirst(); + if (!optional.isPresent()) { + throw new SalaryRunTimeException(String.format("字段不存在[id:%s]", attendField.getId())); + } + } + String currentSettingContent = JSON.toJSONString(attendFields); + // 获取字段设置 + List list = biz.getAttendQuoteFieldSetting(saveParam.getSourceType()); + + String sourceTypeName = saveParam.getSourceType() == AttendQuoteSourceTypeEnum.QUOTE ? "引用考勤" : "导入数据"; + Date now = new Date(); + if (CollectionUtils.isEmpty(list)) { + AttendQuoteFieldSettingPO po = AttendQuoteFieldSettingPO.builder() + .sourceType(saveParam.getSourceType().getValue()) + .currentSettingContent(currentSettingContent) + .createTime(now) + .updateTime(now) + .creator((long) user.getUID()) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .build(); + // todo 记录日志 + biz.insert(po); + } else { + AttendQuoteFieldSettingPO oldObject = list.get(0); + AttendQuoteFieldSettingPO newObject = new AttendQuoteFieldSettingPO(); + BeanUtils.copyProperties(oldObject, newObject); + newObject.setCurrentSettingContent(currentSettingContent); + newObject.setUpdateTime(now); + // 更新 + biz.updateById(newObject); + // todo 记录日志 + + } + return null; + } + + @Override + public String saveAsDefault(AttendQuoteFieldSettingSaveParam saveParam) { + if (CollectionUtils.isEmpty(saveParam.getCurrentSettingFields())) { + throw new SalaryRunTimeException("字段不能为空"); + } + // 所有字段 + List allAttendFields = getAllAttendQuoteFields(); + + List attendFields = saveParam.getCurrentSettingFields(); + for (AttendModuleSettingFieldParam attendField : attendFields) { + Optional optional = allAttendFields.stream().filter(e -> e.getId().equals(attendField.getId())).findFirst(); + if (!optional.isPresent()) { + throw new SalaryRunTimeException(String.format("字段不存在[id:%s]", attendField.getId())); + } + } + + String currentSettingContent = JSON.toJSONString(attendFields); + Date now = new Date(); + // 获取字段设置 + List list = biz.getAttendQuoteFieldSetting(saveParam.getSourceType()); + String sourceTypeName = saveParam.getSourceType() == AttendQuoteSourceTypeEnum.QUOTE ? "引用考勤" : "导入数据"; + if (CollectionUtils.isEmpty(list)) { + AttendQuoteFieldSettingPO po = AttendQuoteFieldSettingPO.builder() + .sourceType(saveParam.getSourceType().getValue()) + .currentSettingContent(currentSettingContent) + .defaultSettingContent(currentSettingContent) + .createTime(now) + .updateTime(now) + .creator((long) user.getUID()) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .build(); + // todo 记录日志 + biz.insert(po); + } else { + AttendQuoteFieldSettingPO oldObject = list.get(0); + AttendQuoteFieldSettingPO newObject = new AttendQuoteFieldSettingPO(); + BeanUtils.copyProperties(oldObject, newObject); + newObject.setCurrentSettingContent(currentSettingContent); + newObject.setDefaultSettingContent(currentSettingContent); + newObject.setUpdateTime(now); + // 更新 + biz.updateById(newObject); + // todo 记录日志 + + } + + return null; + } +} diff --git a/src/com/engine/salary/service/impl/AttendQuoteServiceImpl.java b/src/com/engine/salary/service/impl/AttendQuoteServiceImpl.java new file mode 100644 index 000000000..5a0e2f28a --- /dev/null +++ b/src/com/engine/salary/service/impl/AttendQuoteServiceImpl.java @@ -0,0 +1,157 @@ +package com.engine.salary.service.impl; + +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.biz.AttendQuoteBiz; +import com.engine.salary.biz.AttendQuoteDataBiz; +import com.engine.salary.biz.AttendQuoteDataValueBiz; +import com.engine.salary.config.SalaryElogConfig; +import com.engine.salary.entity.datacollection.dto.AttendQuoteListDTO; +import com.engine.salary.entity.datacollection.param.AttendQuoteQueryParam; +import com.engine.salary.entity.datacollection.po.AttendQuotePO; +import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO; +import com.engine.salary.enums.auth.AuthFilterTypeEnum; +import com.engine.salary.enums.salaryaccounting.SalaryAcctRecordStatusEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.mapper.datacollection.AttendQuoteMapper; +import com.engine.salary.service.AttendQuoteService; +import com.engine.salary.service.SalaryAcctRecordService; +import com.engine.salary.service.SalarySobService; +import com.engine.salary.service.TaxAgentService; +import com.engine.salary.service.auth.AuthService; +import com.engine.salary.service.auth.AuthServiceImpl; +import com.engine.salary.util.SalaryDateUtil; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.SalaryLoggerUtil; +import com.engine.salary.util.db.MapperProxyFactory; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.util.page.SalaryPageUtil; +import org.apache.commons.collections4.CollectionUtils; +import weaver.hrm.User; + +import java.time.LocalDate; +import java.time.YearMonth; +import java.util.Collection; +import java.util.List; +import java.util.Optional; +import java.util.concurrent.atomic.AtomicReference; +import java.util.stream.Collectors; + +public class AttendQuoteServiceImpl extends Service implements AttendQuoteService { + + private AttendQuoteBiz biz = new AttendQuoteBiz(); + private AttendQuoteDataBiz dataBiz = new AttendQuoteDataBiz(); + private AttendQuoteDataValueBiz dataValueBiz = new AttendQuoteDataValueBiz(); + + private AttendQuoteMapper getAttendQuoteMapper() { + return MapperProxyFactory.getProxy(AttendQuoteMapper.class); + } + + private SalaryAcctRecordService getSalaryAcctRecordService(User user) { + return ServiceUtil.getService(SalaryAcctRecordServiceImpl.class, user); + } + + private SalarySobService getSalarySobService(User user) { + return ServiceUtil.getService(SalarySobServiceImpl.class, user); + } + + private TaxAgentService getTaxAgentService(User user) { + return ServiceUtil.getService(TaxAgentServiceImpl.class, user); + } + public AuthService getAuthService(User user) { + return ServiceUtil.getService(AuthServiceImpl.class, user); + } + + @Override + public PageInfo listPage(AttendQuoteQueryParam queryParam) { + + List declareMonth = queryParam.getSalaryYearMonth(); + if (CollectionUtils.isNotEmpty(declareMonth)) { + queryParam.setSalaryYearMonth(declareMonth.stream().map(e -> e + "-01 00:00:00").collect(Collectors.toList())); + queryParam.setSalaryYearMonthDate(declareMonth.stream().map(e -> e + "-01 00:00:00").map(SalaryDateUtil::dateStrToLocalTime).collect(Collectors.toList())); + } + + List list = getAttendQuoteMapper().list(queryParam); + list = getAuthService(user).auth(list, AuthFilterTypeEnum.DATA_OPT, AttendQuoteListDTO.class); + + return SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), + list, AttendQuoteListDTO.class); + } + + @Override + public String delete(Collection ids) { + if (CollectionUtils.isEmpty(ids)) { + throw new SalaryRunTimeException("参数错误"); + } + List attendQuotes = biz.list(AttendQuoteQueryParam.builder().ids(ids).build()); + attendQuotes = getAuthService(user).auth(attendQuotes, AuthFilterTypeEnum.ADMIN_DATA, AttendQuoteListDTO.class); + if (CollectionUtils.isEmpty(attendQuotes)) { + throw new SalaryRunTimeException("无权限删除数据!"); + } + + List accountingAttendQuotes = attendQuotes.stream().filter(e -> e.getSalaryAccountingStatus().equals(1)).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(accountingAttendQuotes)) { + throw new SalaryRunTimeException("已经核算完成的数据不能删除"); + } + + List salaryAcctRecordPOS = getSalaryAcctRecordService(user).listSome(SalaryAcctRecordPO.builder().salarySobId(attendQuotes.get(0).getSalarySobId()) + .salaryMonth(attendQuotes.get(0).getSalaryYearMonth()).build()); + Optional haveArchived = salaryAcctRecordPOS.stream().filter(PO -> PO.getStatus() > SalaryAcctRecordStatusEnum.NOT_ARCHIVED.getValue()).findFirst(); + if(haveArchived.isPresent()){ + throw new SalaryRunTimeException("已经核算完成的数据不能删除"); + } + List unAccountingIds = attendQuotes.stream().filter(e -> e.getSalaryAccountingStatus().equals(0)).map(AttendQuoteListDTO::getId).collect(Collectors.toList()); + // 1.删除未核算的考勤引用 + biz.deleteByIds(unAccountingIds); + + // List attendQuoteDatas = dataBiz.listSome(AttendQuoteDataQueryParam.builder().unAccountingIds(unAccountingIds).build()); + // 2.删除考核引用对应的考核数据 + dataBiz.deleteByAttendQuoteIds(unAccountingIds); + + // 3.删除考核数据对应的考核值 + dataValueBiz.deleteByAttendQuoteIds(unAccountingIds); + // List attendQuoteDataIds = attendQuoteDatas.stream().map(AttendQuoteDataPO::getId).collect(Collectors.toList()); + // if (CollectionUtils.isNotEmpty(attendQuoteDataIds)) { + // dataValueBiz.deleteByAttendQuoteDataIds(attendQuoteDataIds); + // } + + // 记录日志 + attendQuotes.forEach(e -> { + SalaryLoggerUtil.recordDeleteSingleLog(SalaryElogConfig.attendQuoteLoggerTemplate, + e.getId(), + SalaryI18nUtil.getI18nLabel(0, SalaryDateUtil.getFormatYearMonth(e.getSalaryYearMonth()) + " " + e.getSalarySobName()), + SalaryI18nUtil.getI18nLabel(0, "删除考勤引用"), + SalaryI18nUtil.getI18nLabel(0, "删除考勤引用") + + ":[" + SalaryI18nUtil.getI18nLabel(0, "薪资所属月") + ":" + e.getSalaryYearMonth() + "," + + SalaryI18nUtil.getI18nLabel(0, "关联账套") + ":" + e.getSalarySobName() + "]", + e, + user); + }); + + return null; + } + + + @Override + public Boolean checkOperation(YearMonth salaryYearMonth, List salarySobIds) { + // 已经核算过的不可操作 + List salaryAcctRecords = getSalaryAcctRecordService(user).listBySalarySobIds(salarySobIds); + AtomicReference isEnableOperation = new AtomicReference<>(Boolean.TRUE); + salaryAcctRecords.forEach(e -> { + boolean isAccounted = e.getSalaryMonth().equals(SalaryDateUtil.localDateToDate(LocalDate.of(salaryYearMonth.getYear(), salaryYearMonth.getMonth(), 1))) + && e.getStatus() > SalaryAcctRecordStatusEnum.NOT_ARCHIVED.getValue(); + if (isAccounted) { + isEnableOperation.set(Boolean.FALSE); + } + }); + return isEnableOperation.get(); + } + + @Override + public AttendQuotePO getById(Long id) { + if (id == null) { + return null; + } + return getAttendQuoteMapper().getById(id); + } +} diff --git a/src/com/engine/salary/service/impl/ColumnBuildServiceImpl.java b/src/com/engine/salary/service/impl/ColumnBuildServiceImpl.java new file mode 100644 index 000000000..d9edd129e --- /dev/null +++ b/src/com/engine/salary/service/impl/ColumnBuildServiceImpl.java @@ -0,0 +1,567 @@ +package com.engine.salary.service.impl; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.TypeReference; +import com.cloudstore.eccom.constant.WeaBoolAttr; +import com.cloudstore.eccom.pc.table.WeaTableColumn; +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.entity.siaccount.po.InsuranceAccountDetailPO; +import com.engine.salary.entity.siaccount.po.InsuranceAccountInspectPO; +import com.engine.salary.entity.siarchives.po.InsuranceArchivesAccountPO; +import com.engine.salary.entity.siarchives.po.InsuranceArchivesFundSchemePO; +import com.engine.salary.entity.siarchives.po.InsuranceArchivesOtherSchemePO; +import com.engine.salary.entity.siarchives.po.InsuranceArchivesSocialSchemePO; +import com.engine.salary.entity.sicategory.po.ICategoryPO; +import com.engine.salary.enums.siaccount.PaymentStatusEnum; +import com.engine.salary.enums.sicategory.WelfareTypeEnum; +import com.engine.salary.mapper.sicategory.ICategoryMapper; +import com.engine.salary.service.ColumnBuildService; +import com.engine.salary.service.SIArchivesService; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.db.MapperProxyFactory; +import org.apache.commons.lang3.StringUtils; +import weaver.hrm.User; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * @Author weaver_cl + * @Description: + * @Date 2022/4/12 + * @Version V1.0 + **/ +public class ColumnBuildServiceImpl extends Service implements ColumnBuildService { + +// private SIArchivesBiz siArchivesBiz = new SIArchivesBiz(); + + private ICategoryMapper getICategoryMapper() { + return MapperProxyFactory.getProxy(ICategoryMapper.class); + } + + public SIArchivesService getSIArchivesService(User user) { + return ServiceUtil.getService(SIArchivesServiceImpl.class, user); + } + + @Override + public List buildCommonColumnsWithStyle(List pos, Long employeeId, String tenantKey, Integer paymentStatus) { + List list = new ArrayList<>(); + Map categoryIdNameMap = getICategoryMapper().listAll().stream().collect(Collectors.toMap(ICategoryPO -> String.valueOf(ICategoryPO.getId()), ICategoryPO::getInsuranceName)); + Map> columns = buildPaymentTitle(pos, categoryIdNameMap, employeeId, tenantKey); + Map> personColumns = buildPersonalTitle(pos, categoryIdNameMap, employeeId, tenantKey); + Map> comColumns = buildComTitle(pos, categoryIdNameMap, employeeId, tenantKey); + WeaTableColumn weaTableNameColumn = new WeaTableColumn("150px",SalaryI18nUtil.getI18nLabel( 85429, "姓名"), "userName"); + weaTableNameColumn.setFixed("left"); + WeaTableColumn idColumn = new WeaTableColumn("150px", "id", "id"); + idColumn.setIsPrimarykey(WeaBoolAttr.TRUE); + idColumn.setDisplay(WeaBoolAttr.FALSE); + list.add(idColumn); + WeaTableColumn employeeIdColumn = new WeaTableColumn("150px", "人员信息表的主键id", "employeeId"); + employeeIdColumn.setDisplay(WeaBoolAttr.FALSE); + list.add(employeeIdColumn); + list.add(new WeaTableColumn("150px",SalaryI18nUtil.getI18nLabel( 86185, "部门"), "department")); + list.add(new WeaTableColumn("150px",SalaryI18nUtil.getI18nLabel( 86186, "手机号"), "mobile")); + list.add(new WeaTableColumn("150px",SalaryI18nUtil.getI18nLabel( 1933, "工号"), "workcode")); + list.add(new WeaTableColumn("150px",SalaryI18nUtil.getI18nLabel( 86187, "员工状态"), "employeeStatus")); + list.add(new WeaTableColumn("150px",SalaryI18nUtil.getI18nLabel( 86187, "证件号码"), "idNo")); + list.add(new WeaTableColumn("150px",SalaryI18nUtil.getI18nLabel( 100377, "数据来源"), "sourceFrom")); + if (paymentStatus.equals(PaymentStatusEnum.REPAIR.getValue())) { + list.add(new WeaTableColumn("150px",SalaryI18nUtil.getI18nLabel( 100379, "补缴月份"), "supplementaryMonth")); + } else if (paymentStatus.equals(PaymentStatusEnum.RECESSION.getValue())) { + list.add(new WeaTableColumn("150px",SalaryI18nUtil.getI18nLabel( 100379, "退差月份"), "supplementaryMonth")); + } + list.add(new WeaTableColumn("150px",SalaryI18nUtil.getI18nLabel( 91325, "个税扣缴义务人"), "socialPayOrg")); + if (!paymentStatus.equals(PaymentStatusEnum.BALANCE.getValue())) { + list.add(new WeaTableColumn("150px",SalaryI18nUtil.getI18nLabel( 91324, "社保账号"), "socialAccount")); + list.add(new WeaTableColumn("150px",SalaryI18nUtil.getI18nLabel( 91323, "社保方案名称"), "socialSchemeName")); + } + + //组装社保基数 + columns.get(WelfareTypeEnum.SOCIAL_SECURITY.getValue()).forEach((k, v) -> { + list.add(new WeaTableColumn("150px",k, v)); + }); + + if (!paymentStatus.equals(PaymentStatusEnum.BALANCE.getValue())) { + list.add(new WeaTableColumn("150px",SalaryI18nUtil.getI18nLabel( 91486, "公积金账号"), "fundAccount")); + list.add(new WeaTableColumn("150px",SalaryI18nUtil.getI18nLabel( 91485, "公积金方案名称"), "fundSchemeName")); + } + + //组装公积金基数 + columns.get(WelfareTypeEnum.ACCUMULATION_FUND.getValue()).forEach((k, v) -> { + list.add(new WeaTableColumn("150px",k, v)); + }); + if (!paymentStatus.equals(PaymentStatusEnum.BALANCE.getValue())) { + list.add(new WeaTableColumn("150px",SalaryI18nUtil.getI18nLabel( 91487, "补充公积金账号"), "supplementFundAccount")); + list.add(new WeaTableColumn("150px",SalaryI18nUtil.getI18nLabel(91496, "其他福利方案名称"), "otherSchemeName")); + } + + columns.get(WelfareTypeEnum.OTHER.getValue()).forEach((k, v) -> { + list.add(new WeaTableColumn("150px",k, v)); + }); + personColumns.get(WelfareTypeEnum.SOCIAL_SECURITY.getValue()).forEach((k, v) -> { + list.add(new WeaTableColumn("150px",k, v)); + }); + list.add(new WeaTableColumn("150px","" + SalaryI18nUtil.getI18nLabel( 100388, "社保个人合计") + "", "socialPerSum")); + personColumns.get(WelfareTypeEnum.ACCUMULATION_FUND.getValue()).forEach((k, v) -> { + list.add(new WeaTableColumn("150px",k, v)); + }); + list.add(new WeaTableColumn("150px","" + SalaryI18nUtil.getI18nLabel( 100390, "公积金个人合计") + "", "fundPerSum")); + personColumns.get(WelfareTypeEnum.OTHER.getValue()).forEach((k, v) -> { + list.add(new WeaTableColumn("150px",k, v)); + }); + list.add(new WeaTableColumn("150px","" + SalaryI18nUtil.getI18nLabel( 100392, "其他福利个人合计") + "", "otherPerSum")); + list.add(new WeaTableColumn("150px","" + SalaryI18nUtil.getI18nLabel( 100393, "个人合计") + "", "perSum")); + comColumns.get(WelfareTypeEnum.SOCIAL_SECURITY.getValue()).forEach((k, v) -> { + list.add(new WeaTableColumn("150px",k, v)); + }); + list.add(new WeaTableColumn("150px","" + SalaryI18nUtil.getI18nLabel( 100394, "社保单位合计") + "", "socialComSum")); + comColumns.get(WelfareTypeEnum.ACCUMULATION_FUND.getValue()).forEach((k, v) -> { + list.add(new WeaTableColumn("150px",k, v)); + }); + list.add(new WeaTableColumn("150px","" + SalaryI18nUtil.getI18nLabel( 100395, "公积金单位合计") + "", "fundComSum")); + comColumns.get(WelfareTypeEnum.OTHER.getValue()).forEach((k, v) -> { + list.add(new WeaTableColumn("150px",k, v)); + }); + list.add(new WeaTableColumn("150px","" + SalaryI18nUtil.getI18nLabel( 100396, "其他福利单位合计") + "", "otherComSum")); + list.add(new WeaTableColumn("150px","" + SalaryI18nUtil.getI18nLabel( 100397, "单位合计") + "", "comSum")); + list.add(new WeaTableColumn("150px","" + SalaryI18nUtil.getI18nLabel( 100398, "社保合计") + "", "socialSum")); + list.add(new WeaTableColumn("150px","" + SalaryI18nUtil.getI18nLabel( 100399, "公积金合计") + "", "fundSum")); + list.add(new WeaTableColumn("150px","" + SalaryI18nUtil.getI18nLabel( 100400, "其他福利合计") + "", "otherSum")); + list.add(new WeaTableColumn("150px","" + SalaryI18nUtil.getI18nLabel( 93278, "合计") + "", "total")); + return list; + } + + private Map> buildPaymentTitle(List pos, Map categoryIdNameMap, Long employeeId, String tenantKey) { +// boolean welBaseDiffSign = siArchivesBiz.isDiffWelBase(); + boolean welBaseDiffSign = getSIArchivesService(user).isDiffWelBase(); + Set socailIds = new HashSet<>(); + Set fundIds = new HashSet<>(); + Set otherIds = new HashSet<>(); + + Set socailComIds = new HashSet<>(); + Set fundComIds = new HashSet<>(); + Set otherComIds = new HashSet<>(); + + Map> result = new HashMap<>(); + + pos.stream().forEach(item -> { + if (StringUtils.isNotBlank(item.getSocialPaymentBaseString()) || StringUtils.isNotBlank(item.getSocialPaymentComBaseString())) { + Map socialJson = JSON.parseObject(item.getSocialPaymentBaseString(), new HashMap().getClass()); + if(socialJson!=null){ + socialJson.forEach((k, v) -> { + socailIds.add(k); + }); + } + //如果需要区分个人和公司福利基数 + if (welBaseDiffSign) { + Map socialComJson = JSON.parseObject(item.getSocialPaymentComBaseString(), new TypeReference>() { + }); + if (socialComJson != null) { + socialComJson.forEach((k, v) -> socailComIds.add(k)); + } + } + + } + if (StringUtils.isNotBlank(item.getFundPaymentBaseString()) || StringUtils.isNotBlank(item.getFundPaymentComBaseString())) { + Map fundJson = JSON.parseObject(item.getFundPaymentBaseString(), new HashMap().getClass()); + if(fundJson!=null){ + fundJson.forEach((k, v) -> { + fundIds.add(k); + }); + } + //如果需要区分个人和公司福利基数 + if (welBaseDiffSign) { + Map fundComJson = JSON.parseObject(item.getFundPaymentComBaseString(), new TypeReference>() { + }); + if (fundComJson != null) { + fundComJson.forEach((k, v) -> fundComIds.add(k)); + } + } + + } + if (StringUtils.isNotBlank(item.getOtherPaymentBaseString()) || StringUtils.isNotBlank(item.getOtherPaymentComBaseString())) { + Map otherJson = JSON.parseObject(item.getOtherPaymentBaseString(), new HashMap().getClass()); + if(otherJson!=null){ + otherJson.forEach((k, v) -> { + otherIds.add(k); + }); + } + //如果需要区分个人和公司福利基数 + if (welBaseDiffSign) { + Map otherComJson = JSON.parseObject(item.getOtherPaymentComBaseString(), new TypeReference>() { + }); + if (otherComJson != null) { + otherComJson.forEach((k, v) -> otherComIds.add(k)); + } + } + + } + }); + Map socialColumns = new HashMap<>(); + Map fundColumns = new HashMap<>(); + Map otherColumns = new HashMap<>(); + + Map socialComColumns = new HashMap<>(); + Map fundComColumns = new HashMap<>(); + Map otherComColumns = new HashMap<>(); + + if (welBaseDiffSign) { + socailIds.stream().forEach(social -> { + if (categoryIdNameMap.containsKey(social)) { + socialColumns.put(categoryIdNameMap.get(social) + SalaryI18nUtil.getI18nLabel(0, "申报基数") + SalaryI18nUtil.getI18nLabel( 0, "个人"), social + "socialPerBase"); + } + }); + fundIds.stream().forEach(social -> { + if (categoryIdNameMap.containsKey(social)) { + fundColumns.put(categoryIdNameMap.get(social) + SalaryI18nUtil.getI18nLabel( 0, "申报基数") + SalaryI18nUtil.getI18nLabel( 0, "个人"), social + "fundPerBase"); + } + }); + otherIds.stream().forEach(social -> { + if (categoryIdNameMap.containsKey(social)) { + otherColumns.put(categoryIdNameMap.get(social) + SalaryI18nUtil.getI18nLabel( 0, "申报基数") + SalaryI18nUtil.getI18nLabel( 0, "个人"), social + "otherPerBase"); + } + }); + + socailComIds.stream().forEach(social -> { + if (categoryIdNameMap.containsKey(social)) { + socialComColumns.put(categoryIdNameMap.get(social) + SalaryI18nUtil.getI18nLabel(0, "申报基数") + SalaryI18nUtil.getI18nLabel( 0, "单位"), social + "socialComBase"); + } + }); + fundComIds.stream().forEach(social -> { + if (categoryIdNameMap.containsKey(social)) { + fundComColumns.put(categoryIdNameMap.get(social) + SalaryI18nUtil.getI18nLabel( 0, "申报基数") + SalaryI18nUtil.getI18nLabel( 0, "单位"), social + "fundComBase"); + } + }); + otherComIds.stream().forEach(social -> { + if (categoryIdNameMap.containsKey(social)) { + otherComColumns.put(categoryIdNameMap.get(social) + SalaryI18nUtil.getI18nLabel( 0, "申报基数") + SalaryI18nUtil.getI18nLabel( 0, "单位"), social + "otherComBase"); + } + }); + } else { + socailIds.stream().forEach(social -> { + if (categoryIdNameMap.containsKey(social)) { + socialColumns.put(categoryIdNameMap.get(social) + SalaryI18nUtil.getI18nLabel(0, "申报基数"), social + "socialBase"); + } + }); + fundIds.stream().forEach(social -> { + if (categoryIdNameMap.containsKey(social)) { + fundColumns.put(categoryIdNameMap.get(social) + SalaryI18nUtil.getI18nLabel( 0, "申报基数"), social + "fundBase"); + } + }); + otherIds.stream().forEach(social -> { + if (categoryIdNameMap.containsKey(social)) { + otherColumns.put(categoryIdNameMap.get(social) + SalaryI18nUtil.getI18nLabel( 0, "申报基数"), social + "otherBase"); + } + }); + } + + // map根据value排序 + LinkedHashMap socialColumnsWithAscValue = socialColumns.entrySet().stream() + .sorted(Map.Entry.comparingByValue()) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (oldValue, newValue) -> oldValue, + LinkedHashMap::new)); + LinkedHashMap fundColumnsWithAscValue = fundColumns.entrySet().stream() + .sorted(Map.Entry.comparingByValue()) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (oldValue, newValue) -> oldValue, + LinkedHashMap::new)); + LinkedHashMap otherColumnsWithAscValue = otherColumns.entrySet().stream() + .sorted(Map.Entry.comparingByValue()) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (oldValue, newValue) -> oldValue, + LinkedHashMap::new)); + + if (welBaseDiffSign) { + LinkedHashMap socialComMapWithAscKey = socialComColumns.entrySet().stream() + .sorted(Map.Entry.comparingByKey()) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (oldValue, newValue) -> oldValue, + LinkedHashMap::new)); + LinkedHashMap fundComMapWithAscKey = fundComColumns.entrySet().stream() + .sorted(Map.Entry.comparingByKey()) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (oldValue, newValue) -> oldValue, + LinkedHashMap::new)); + LinkedHashMap otherComMapWithAscKey = otherComColumns.entrySet().stream() + .sorted(Map.Entry.comparingByKey()) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (oldValue, newValue) -> oldValue, + LinkedHashMap::new)); + socialColumnsWithAscValue.putAll(socialComMapWithAscKey); + fundColumnsWithAscValue.putAll(fundComMapWithAscKey); + otherColumnsWithAscValue.putAll(otherComMapWithAscKey); + } + + result.put(WelfareTypeEnum.SOCIAL_SECURITY.getValue(), socialColumnsWithAscValue); + result.put(WelfareTypeEnum.ACCUMULATION_FUND.getValue(), fundColumnsWithAscValue); + result.put(WelfareTypeEnum.OTHER.getValue(), otherColumnsWithAscValue); + return result; + } + + private Map> buildPersonalTitle(List pos, Map categoryIdNameMap, Long employeeId, String tenantKey) { + Set socailIds = new HashSet<>(); + Set fundIds = new HashSet<>(); + Set otherIds = new HashSet<>(); + Map> result = new HashMap<>(); + + pos.stream().forEach(item -> { + if (StringUtils.isNotBlank(item.getSocialPerJson())) { + Map socialJson = JSON.parseObject(item.getSocialPerJson(), new HashMap().getClass()); + if(socialJson!=null){ + socialJson.forEach((k, v) -> { + socailIds.add(k); + }); + } + + } + if (StringUtils.isNotBlank(item.getFundPerJson())) { + Map fundJson = JSON.parseObject(item.getFundPerJson(), new HashMap().getClass()); + if(fundJson!=null){ + fundJson.forEach((k, v) -> { + fundIds.add(k); + }); + } + + } + if (StringUtils.isNotBlank(item.getOtherPerJson())) { + Map otherJson = JSON.parseObject(item.getOtherPerJson(), new HashMap().getClass()); + if(otherJson!=null){ + otherJson.forEach((k, v) -> { + otherIds.add(k); + }); + } + + } + }); + Map socialColumns = new HashMap<>(); + Map fundColumns = new HashMap<>(); + Map otherColumns = new HashMap<>(); + socailIds.stream().forEach(social -> { + if (categoryIdNameMap.containsKey(social)) { + socialColumns.put(categoryIdNameMap.get(social) + SalaryI18nUtil.getI18nLabel( 87159, "个人"), social + "socialPer"); + } + }); + fundIds.stream().forEach(social -> { + if (categoryIdNameMap.containsKey(social)) { + fundColumns.put(categoryIdNameMap.get(social) + SalaryI18nUtil.getI18nLabel( 87159, "个人"), social + "fundPer"); + } + }); + otherIds.stream().forEach(social -> { + if (categoryIdNameMap.containsKey(social)) { + otherColumns.put(categoryIdNameMap.get(social) + SalaryI18nUtil.getI18nLabel( 87159, "个人"), social + "otherPer"); + } + }); + // map根据value排序 + LinkedHashMap socialColumnsWithAscValue = socialColumns.entrySet().stream() + .sorted(Map.Entry.comparingByValue()) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (oldValue, newValue) -> oldValue, + LinkedHashMap::new)); + LinkedHashMap fundColumnsWithAscValue = fundColumns.entrySet().stream() + .sorted(Map.Entry.comparingByValue()) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (oldValue, newValue) -> oldValue, + LinkedHashMap::new)); + LinkedHashMap otherColumnsWithAscValue = otherColumns.entrySet().stream() + .sorted(Map.Entry.comparingByValue()) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (oldValue, newValue) -> oldValue, + LinkedHashMap::new)); + + result.put(WelfareTypeEnum.SOCIAL_SECURITY.getValue(), socialColumnsWithAscValue); + result.put(WelfareTypeEnum.ACCUMULATION_FUND.getValue(), fundColumnsWithAscValue); + result.put(WelfareTypeEnum.OTHER.getValue(), otherColumnsWithAscValue); + return result; + } + + private Map> buildComTitle(List pos, Map categoryIdNameMap, Long employeeId, String tenantKey) { + Set socailIds = new HashSet<>(); + Set fundIds = new HashSet<>(); + Set otherIds = new HashSet<>(); + Map> result = new HashMap<>(); + + pos.stream().forEach(item -> { + if (StringUtils.isNotBlank(item.getSocialComJson())) { + Map socialJson = JSON.parseObject(item.getSocialComJson(), new HashMap().getClass()); + if(socialJson!=null){ + socialJson.forEach((k, v) -> { + socailIds.add(k); + }); + } + + } + if (StringUtils.isNotBlank(item.getFundComJson())) { + Map fundJson = JSON.parseObject(item.getFundComJson(), new HashMap().getClass()); + if(fundJson!=null){ + fundJson.forEach((k, v) -> { + fundIds.add(k); + }); + } + + } + if (StringUtils.isNotBlank(item.getOtherComJson())) { + Map otherJson = JSON.parseObject(item.getOtherComJson(), new HashMap().getClass()); + if(otherJson!=null){ + otherJson.forEach((k, v) -> { + otherIds.add(k); + }); + } + + } + }); + Map socialColumns = new HashMap<>(); + Map fundColumns = new HashMap<>(); + Map otherColumns = new HashMap<>(); + socailIds.stream().forEach(social -> { + if (categoryIdNameMap.containsKey(social)) { + socialColumns.put(categoryIdNameMap.get(social) + SalaryI18nUtil.getI18nLabel( 100289, "单位"), social + "socialCom"); + } + }); + fundIds.stream().forEach(social -> { + if (categoryIdNameMap.containsKey(social)) { + fundColumns.put(categoryIdNameMap.get(social) + SalaryI18nUtil.getI18nLabel( 100289, "单位"), social + "fundCom"); + } + }); + otherIds.stream().forEach(social -> { + if (categoryIdNameMap.containsKey(social)) { + otherColumns.put(categoryIdNameMap.get(social) + SalaryI18nUtil.getI18nLabel( 100289, "单位"), social + "otherCom"); + } + }); + // map根据value排序 + LinkedHashMap socialColumnsWithAscValue = socialColumns.entrySet().stream() + .sorted(Map.Entry.comparingByValue()) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (oldValue, newValue) -> oldValue, + LinkedHashMap::new)); + LinkedHashMap fundColumnsWithAscValue = fundColumns.entrySet().stream() + .sorted(Map.Entry.comparingByValue()) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (oldValue, newValue) -> oldValue, + LinkedHashMap::new)); + LinkedHashMap otherColumnsWithAscValue = otherColumns.entrySet().stream() + .sorted(Map.Entry.comparingByValue()) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (oldValue, newValue) -> oldValue, + LinkedHashMap::new)); + + result.put(WelfareTypeEnum.SOCIAL_SECURITY.getValue(), socialColumnsWithAscValue); + result.put(WelfareTypeEnum.ACCUMULATION_FUND.getValue(), fundColumnsWithAscValue); + result.put(WelfareTypeEnum.OTHER.getValue(), otherColumnsWithAscValue); + return result; + } + + + @Override + public List buildCommonColumns(List pos) { + return null; + } + + @Override + public List buildInspectColumns(List pos, Long paymentOrganization) { + List list = new ArrayList<>(); + + List employeeIds = pos.stream().map(InsuranceAccountInspectPO::getEmployeeId).collect(Collectors.toList()); +// Map insuranceArchivesAccountPOMap = siArchivesBiz.buildBatchAccount(employeeIds, paymentOrganization); + Map insuranceArchivesAccountPOMap = getSIArchivesService(user).buildBatchAccount(employeeIds, paymentOrganization); + Map categoryIdNameMap = getICategoryMapper().listAll().stream().collect(Collectors.toMap(ICategoryPO -> String.valueOf(ICategoryPO.getId()), ICategoryPO::getInsuranceName)); + Map> columns = buildInspectTableTitle(new ArrayList<>(insuranceArchivesAccountPOMap.values()), categoryIdNameMap); + WeaTableColumn weaTableNameColumn = new WeaTableColumn("150px",SalaryI18nUtil.getI18nLabel( 85429, "姓名"), "userName"); + weaTableNameColumn.setFixed("left"); + WeaTableColumn idColumn = new WeaTableColumn("150px", "id", "id"); + idColumn.setIsPrimarykey(WeaBoolAttr.TRUE); + idColumn.setDisplay(WeaBoolAttr.FALSE); + list.add(idColumn); + list.add(new WeaTableColumn("150px",SalaryI18nUtil.getI18nLabel( 86185, "部门"), "department")); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(86186, "手机号"), "mobile")); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(86187, "员工状态"), "employeeStatus")); + list.add(new WeaTableColumn("150px",SalaryI18nUtil.getI18nLabel( 100544, "缴纳情况"), "supplementaryMonth")); + list.add(new WeaTableColumn("150px",SalaryI18nUtil.getI18nLabel( 91323, "社保方案名称"), "socialSchemeName")); + //组装社保基数 + columns.get(WelfareTypeEnum.SOCIAL_SECURITY.getValue()).forEach((k, v) -> { + list.add(new WeaTableColumn("150px",k, v)); + }); + list.add(new WeaTableColumn("150px",SalaryI18nUtil.getI18nLabel( 91485, "公积金方案名称"), "fundSchemeName")); + //组装公积金基数 + columns.get(WelfareTypeEnum.ACCUMULATION_FUND.getValue()).forEach((k, v) -> { + list.add(new WeaTableColumn("150px",k, v)); + }); + list.add(new WeaTableColumn("150px",SalaryI18nUtil.getI18nLabel( 91496, "其他福利方案名称"), "otherSchemeName")); + columns.get(WelfareTypeEnum.OTHER.getValue()).forEach((k, v) -> { + list.add(new WeaTableColumn("150px",k, v)); + }); + return list; + } + + private Map> buildInspectTableTitle(List pos, Map categoryIdNameMap + ) { + Set socailIds = new HashSet<>(); + Set fundIds = new HashSet<>(); + Set otherIds = new HashSet<>(); + Map> result = new HashMap<>(); + + pos.stream().forEach(item -> { + InsuranceArchivesSocialSchemePO social = item.getSocial(); + if (social != null && StringUtils.isNotBlank(social.getSocialPaymentBaseString())) { + Map socialJson = JSON.parseObject(social.getSocialPaymentBaseString(), new HashMap().getClass()); + if(socialJson!=null){ + socialJson.forEach((k, v) -> { + socailIds.add(k); + }); + } + + } + InsuranceArchivesFundSchemePO fund = item.getFund(); + if (fund != null && StringUtils.isNotBlank(fund.getFundPaymentBaseString())) { + Map fundJson = JSON.parseObject(fund.getFundPaymentBaseString(), new HashMap().getClass()); + if(fundJson!=null){ + fundJson.forEach((k, v) -> { + fundIds.add(k); + }); + } + + } + InsuranceArchivesOtherSchemePO other = item.getOther(); + if (other != null && StringUtils.isNotBlank(other.getOtherPaymentBaseString())) { + Map otherJson = JSON.parseObject(other.getOtherPaymentBaseString(), new HashMap().getClass()); + if(otherJson!=null){ + otherJson.forEach((k, v) -> { + otherIds.add(k); + }); + } + + } + }); + Map socialColumns = new HashMap<>(); + Map fundColumns = new HashMap<>(); + Map otherColumns = new HashMap<>(); + socailIds.stream().forEach(social -> { + if (categoryIdNameMap.containsKey(social)) { + socialColumns.put(categoryIdNameMap.get(social) + SalaryI18nUtil.getI18nLabel( 100293, "申报基数"), social + "socialBase"); + } + }); + fundIds.stream().forEach(social -> { + if (categoryIdNameMap.containsKey(social)) { + fundColumns.put(categoryIdNameMap.get(social) + SalaryI18nUtil.getI18nLabel( 100293, "申报基数"), social + "fundBase"); + } + }); + otherIds.stream().forEach(social -> { + if (categoryIdNameMap.containsKey(social)) { + otherColumns.put(categoryIdNameMap.get(social) + SalaryI18nUtil.getI18nLabel( 100293, "申报基数"), social + "otherBase"); + } + }); + result.put(WelfareTypeEnum.SOCIAL_SECURITY.getValue(), socialColumns); + result.put(WelfareTypeEnum.ACCUMULATION_FUND.getValue(), fundColumns); + result.put(WelfareTypeEnum.OTHER.getValue(), otherColumns); + return result; + } + + @Override + public List buildCompensationColumns() { + List list = new ArrayList<>(); + + WeaTableColumn weaTableNameColumn = new WeaTableColumn("300px",SalaryI18nUtil.getI18nLabel( 87000, "调差对象"), "target"); + weaTableNameColumn.setFixed("left"); + list.add(weaTableNameColumn); + + list.add(new WeaTableColumn("100px",SalaryI18nUtil.getI18nLabel( 87001, "统计调差福利"), "welfareType")); + list.add(new WeaTableColumn("200px",SalaryI18nUtil.getI18nLabel( 87001, "统计调差福利类型(单位)"), "categoryType")); + list.add(new WeaTableColumn("200px",SalaryI18nUtil.getI18nLabel( 87002, "国家核算金额(单位)"), "countryTotal")); + list.add(new WeaTableColumn("200px",SalaryI18nUtil.getI18nLabel( 87003, "公司核算金额(单位)"), "companyTotal")); + list.add(new WeaTableColumn("100px",SalaryI18nUtil.getI18nLabel( 87004, "应调差金额"), "adjustmentTotal")); + list.add(new WeaTableColumn("200px",SalaryI18nUtil.getI18nLabel( 87005, "调差到(单位)"), "adjustTo")); + + + return list; + } + +} diff --git a/src/com/engine/salary/service/impl/ExtEmpServiceImpl.java b/src/com/engine/salary/service/impl/ExtEmpServiceImpl.java new file mode 100644 index 000000000..f2fbd1d89 --- /dev/null +++ b/src/com/engine/salary/service/impl/ExtEmpServiceImpl.java @@ -0,0 +1,638 @@ +package com.engine.salary.service.impl; + +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.config.SalaryElogConfig; +import com.engine.hrmelog.entity.dto.LoggerContext; +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.extemp.dto.ExtEmpDTO; +import com.engine.salary.entity.extemp.param.ExtEmpImportParam; +import com.engine.salary.entity.extemp.param.ExtEmpQueryParam; +import com.engine.salary.entity.extemp.param.ExtEmpSaveParam; +import com.engine.salary.entity.extemp.po.ExtEmpPO; +import com.engine.salary.entity.hrm.DeptInfo; +import com.engine.salary.entity.hrm.SubCompanyInfo; +import com.engine.salary.entity.salarysob.param.SalarySobRangeEmpQueryParam; +import com.engine.salary.enums.OperateTypeEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.mapper.datacollection.EmployMapper; +import com.engine.salary.mapper.extemp.ExternalEmployeeMapper; +import com.engine.salary.service.ExtEmpService; +import com.engine.salary.service.SalaryEmployeeService; +import com.engine.salary.util.SalaryDateUtil; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.db.IdGenerator; +import com.engine.salary.util.db.MapperProxyFactory; +import com.engine.salary.util.excel.ExcelComment; +import com.engine.salary.util.excel.ExcelParseHelper; +import com.engine.salary.util.excel.ExcelSupport; +import com.engine.salary.util.excel.ExcelUtilPlus; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.util.page.SalaryPageUtil; +import com.engine.salary.util.valid.ValidUtil; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.Validate; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.util.IOUtils; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.springframework.beans.BeanUtils; +import weaver.file.ImageFileManager; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.hrm.company.DepartmentComInfo; + +import java.io.InputStream; +import java.util.*; +import java.util.stream.Collectors; + +import static com.engine.salary.util.excel.ExcelSupport.EXCEL_TYPE_XLSX; + +/** + * 累计专项 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class ExtEmpServiceImpl extends Service implements ExtEmpService { + + + private ExternalEmployeeMapper getExternalEmployeeMapper() { + return MapperProxyFactory.getProxy(ExternalEmployeeMapper.class); + } + + private SalaryEmployeeService getSalaryEmployeeService(User user) { + return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user); + } + + private EmployMapper getEmployMapper() { + return MapperProxyFactory.getProxy(EmployMapper.class); + } + + @Override + public List list(ExtEmpQueryParam param) { + return getExternalEmployeeMapper().listSome(ExtEmpPO.builder().username(param.getUsername()).build()); + } + + @Override + public PageInfo listPage(ExtEmpQueryParam param) { + List extEmpPOS = list(param); + + List list = extEmpPOS.stream().map(po -> { + return ExtEmpDTO.builder() + .id(po.getId()) + .username(po.getUsername()) + .departmentName(po.getDepartmentName()) + .subcompanyName(po.getSubcompanyName()) + .companystartdate(po.getCompanystartdate()) + .workcode(po.getWorkcode()) + .build(); + }).collect(Collectors.toList()); + + return SalaryPageUtil.buildPage(param.getCurrent(), param.getPageSize(), list, ExtEmpDTO.class); + + } + + @Override + public void save(ExtEmpSaveParam param) { + + List extEmpPOS = getExternalEmployeeMapper().listSome(ExtEmpPO.builder().username(param.getUsername()).build()); + if (CollectionUtils.isNotEmpty(extEmpPOS)) { + throw new SalaryRunTimeException("姓名已存在!"); + } + + ExtEmpPO po = new ExtEmpPO(); + BeanUtils.copyProperties(param, po); + + po.setId(IdGenerator.generate()); + po.setStatus("2"); + po.setCreator((long) user.getUID()); + po.setModifier((long) user.getUID()); + Date now = new Date(); + po.setCreateTime(now); + po.setUpdateTime(now); + po.setDeleteType(0); + + getExternalEmployeeMapper().insertIgnoreNull(po); + + // 记录日志 + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(po.getId())); + loggerContext.setTargetName(po.getUsername()); + loggerContext.setOperateType(OperateTypeEnum.ADD.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "新增非系统人员")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "新增非系统人员") + ": " + po.getUsername()); + loggerContext.setNewValues(po); + SalaryElogConfig.extEmployeeLoggerTemplate.write(loggerContext); + } + + @Override + public void update(ExtEmpSaveParam param) { + + ExtEmpPO oldPO = getExternalEmployeeMapper().getById(param.getId()); + if (!StringUtils.equals(oldPO.getUsername(), param.getUsername())) { + List extEmpPOS = getExternalEmployeeMapper().listSome(ExtEmpPO.builder().username(param.getUsername()).build()); + if (CollectionUtils.isNotEmpty(extEmpPOS)) { + throw new SalaryRunTimeException("姓名已存在!"); + } + } + + ExtEmpPO po = new ExtEmpPO(); + BeanUtils.copyProperties(param, po); + + po.setModifier((long) user.getUID()); + Date now = new Date(); + po.setUpdateTime(now); + + getExternalEmployeeMapper().updateIgnoreNull(po); + ExtEmpPO byId = getExternalEmployeeMapper().getById(po.getId()); + + // 记录日志 + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(byId.getId())); + loggerContext.setTargetName(byId.getUsername()); + loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "编辑非系统人员")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "编辑非系统人员") + ": " + byId.getUsername()); + loggerContext.setOldValues(oldPO); + loggerContext.setNewValues(byId); + SalaryElogConfig.extEmployeeLoggerTemplate.write(loggerContext); + } + + @Override + public void delete(Collection ids) { + if (CollectionUtils.isNotEmpty(ids)) { + List extEmpPOS = getExternalEmployeeMapper().listSome(ExtEmpPO.builder().ids(ids).build()); + ids.forEach(getExternalEmployeeMapper()::delete); + // 记录日志 + extEmpPOS.forEach(extEmployeePO -> { + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(extEmployeePO.getId())); + loggerContext.setTargetName(extEmployeePO.getUsername()); + loggerContext.setOperateType(OperateTypeEnum.DELETE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "删除非系统人员")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "删除非系统人员") + ": " + extEmployeePO.getUsername()); + loggerContext.setOldValues(extEmployeePO); + SalaryElogConfig.extEmployeeLoggerTemplate.write(loggerContext); + }); + } + } + + @Override + public DataCollectionEmployee getEmployeeById(Long id) { + ExtEmpPO po = getExternalEmployeeMapper().getById(id); + return cover(po); + } + + @Override + public List getEmployeeByIds(List ids) { + if (CollectionUtils.isEmpty(ids)) { + return new ArrayList<>(); + } + List extEmpPOS = new ArrayList<>(); + List> partition = Lists.partition(ids, 500); + partition.forEach(list -> extEmpPOS.addAll(getExternalEmployeeMapper().listSome(ExtEmpPO.builder().ids(list).build()))); + return coverList(extEmpPOS); + + } + + @Override + public List listByParams(List includeQueryParams) { + List emps = new ArrayList<>(); + List> partition = Lists.partition(includeQueryParams, 100); + partition.forEach(list -> { + emps.addAll(getExternalEmployeeMapper().listByParams(list)); + }); + return emps; + } + + @Override + public List listEmployee() { + return getExternalEmployeeMapper().listEmployee(); + } + + @Override + public Collection getEmployeeByIdsAll(List ids) { + List employeeList = new ArrayList<>(); + List> partition = Lists.partition(ids, 1000); + partition.forEach(e -> { + List employeeByIdsAll = getExternalEmployeeMapper().getEmployeeByIdsAll(e); + employeeList.addAll(employeeByIdsAll); + }); + return employeeList; + } + + @Override + public Collection listAllForReport() { + return getExternalEmployeeMapper().listAllForReport(); + } + + @Override + public ExtEmpPO getById(Long id) { + ExtEmpPO po = getExternalEmployeeMapper().getById(id); + if (po != null) { + if (po.getDepartmentId() != null) { + List deptInfoList = getSalaryEmployeeService(user).getDeptInfoList(Collections.singletonList(po.getDepartmentId())); + if (CollectionUtils.isNotEmpty(deptInfoList)) { + po.setDepartmentOrgName(deptInfoList.get(0).getName()); + } + } + if (po.getSubcompanyId() != null) { + List subInfoList = getSalaryEmployeeService(user).getSubCompanyInfoList(Collections.singletonList(po.getSubcompanyId())); + if (CollectionUtils.isNotEmpty(subInfoList)) { + po.setSubcompanyOrgName(subInfoList.get(0).getName()); + } + } + } + return po; + } + + + public DataCollectionEmployee cover(ExtEmpPO extPo) { + if (extPo == null) { + return null; + } + DataCollectionEmployee employee = new DataCollectionEmployee(); + BeanUtils.copyProperties(extPo, employee); + employee.setEmployeeId(extPo.getId()); + employee.setExtEmp(true); + return employee; + } + + public List coverList(List extEmps) { + if (CollectionUtils.isEmpty(extEmps)) { + return new ArrayList<>(); + } + + return extEmps.stream().map(emp -> { + DataCollectionEmployee employee = new DataCollectionEmployee(); + BeanUtils.copyProperties(emp, employee); + employee.setEmployeeId(emp.getId()); + employee.setExtEmp(true); + return employee; + }).collect(Collectors.toList()); + } + + @Override + public XSSFWorkbook exportImportTemplate() { + + // 模板表头 + List headerList = Lists.newArrayList( + SalaryI18nUtil.getI18nLabel(25034, "姓名"), + SalaryI18nUtil.getI18nLabel(27511, "部门"), + SalaryI18nUtil.getI18nLabel(33553, "分部"), + SalaryI18nUtil.getI18nLabel(1516, "入职日期"), + SalaryI18nUtil.getI18nLabel(125238, "手机号"), + SalaryI18nUtil.getI18nLabel(1933, "工号"), + SalaryI18nUtil.getI18nLabel(1887, "身份证号码"), + SalaryI18nUtil.getI18nLabel(0, "本人开户的银行卡卡号"), + SalaryI18nUtil.getI18nLabel(0, "本人开户的银行卡开户支行全称")); + List dataIndexList = Lists.newArrayList("username", "departmentName", "subcompanyName", "companystartdate", "mobile", "workcode", "idNo", "bankCardNum", "bankName"); + + // excel导出的数据 + List> rows = new ArrayList<>(); + rows.add(headerList); + + // 注释 + List excelComments = Lists.newArrayList(); + excelComments.add(new ExcelComment(0, 0, 1, 2, SalaryI18nUtil.getI18nLabel(30036, "必填"))); + excelComments.add(new ExcelComment(3, 0, 4, 2, SalaryI18nUtil.getI18nLabel(542348, "格式样例为'2022-01-01'、'2022/1/1'"))); + + String sheetName = "非系统人员导入模板"; + return ExcelUtilPlus.genWorkbookV2(rows, sheetName, excelComments); + } + + @Override + public Map previewImportExtEmp(ExtEmpImportParam param) { + //参数校验 + ValidUtil.doValidator(param); + + Map map = new HashMap<>(); + + InputStream fileInputStream = null; + try { + fileInputStream = ImageFileManager.getInputStreamById(Integer.parseInt(param.getImageId())); + Sheet sheet = ExcelSupport.parseFile(fileInputStream, 0, EXCEL_TYPE_XLSX); + map.put("headers", ExcelSupport.getSheetHeader(sheet, 0)); + map.put("list", ExcelParseHelper.parse2List(sheet, 1)); + return map; + + } finally { + IOUtils.closeQuietly(fileInputStream); + } + } + + @Override + public Map importExtEmp(ExtEmpImportParam param){ + + Map apidatas = new HashMap(); + + //excel文件id + String imageId = Util.null2String(param.getImageId()); + Validate.notBlank(imageId, SalaryI18nUtil.getI18nLabel(542127, "imageId为空")); + + // 失败的数量 + int failCount = 0; + // 成功的数量 + int successCount = 0; + InputStream fileInputStream = null; + try { + fileInputStream = ImageFileManager.getInputStreamById(Integer.parseInt(param.getImageId())); + + Sheet sheet = ExcelSupport.parseFile(fileInputStream, 0, EXCEL_TYPE_XLSX); + //数据库中现有非系统人员集合 + List allExtEmpInfo= getExternalEmployeeMapper().listAll(); + + // 错误提示信息 + List excelComments = Lists.newArrayList(); + // 存在错误的那行数据 + List> errorDatas = Lists.newArrayList(); + // 表头 + List headers = ExcelSupport.getSheetHeader(sheet, 0); + // 处理数值 + List> data = ExcelParseHelper.parse2Map(sheet, 1); + if (CollectionUtils.isEmpty(headers)) { + throw new SalaryRunTimeException("表头为空"); + } + if (CollectionUtils.isEmpty(data)) { + throw new SalaryRunTimeException("无数据"); + } + //存储待新增和待更新的ExtEmpPO数据 + List updateExtEmpPOList = new ArrayList<>(); + List insertExtEmpPOList = new ArrayList<>(); + //遍历excel表具体数据 + for (int i = 0; i < data.size(); i++) { + + String row = "第" + (i + 1) + "行"; + + boolean isError = false; + Map map = data.get(i); + Long employeeId = 0L; + + String username = (String) map.getOrDefault(SalaryI18nUtil.getI18nLabel(25034, "姓名"), ""); + String departmentFullName = (String) map.getOrDefault(SalaryI18nUtil.getI18nLabel(27511, "部门"), ""); + String[] split = departmentFullName.split(">"); + String departmentName = split[split.length - 1]; + + String subcompanyName = (String) map.getOrDefault(SalaryI18nUtil.getI18nLabel(33553, "分部"), ""); + String companystartdate = (String) map.getOrDefault(SalaryI18nUtil.getI18nLabel(1516, "入职日期"), ""); + + //校验姓名 + if (StringUtils.isBlank(username)) { + //姓名是必填项 + isError = true; + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", row + SalaryI18nUtil.getI18nLabel(102838, "姓名不能为空")); + excelComments.add(errorMessageMap); + } + long usernameNum = updateExtEmpPOList.stream().filter(f -> f.getUsername().equals(username)).count() + insertExtEmpPOList.stream().filter(f -> f.getUsername().equals(username)).count(); + if (usernameNum > 0) { + //excel中姓名相同时,只会录入第一次出现的数据 + isError = true; + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", row + SalaryI18nUtil.getI18nLabel(102838, "本次excel文件中已存在该姓名相关数据,本行数据无法录入")); + excelComments.add(errorMessageMap); + } + //校验部门、分部 + List subCompanyInfos = new ArrayList<>(); + List deptInfos = new ArrayList<>(); + List targetDeptRange = new ArrayList<>(); + if (StringUtils.isNotBlank(subcompanyName)) { + subCompanyInfos = getEmployMapper().getSubCompanyInfosByName(subcompanyName); + if (subCompanyInfos.size() == 0) { + isError = true; + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", row + SalaryI18nUtil.getI18nLabel(0, "分部信息不存在,请检查分部数据是否正确")); + excelComments.add(errorMessageMap); + } + } + if (StringUtils.isNotBlank(departmentName)) { + List toDealDeptInfos = getEmployMapper().getDeptInfosByName(departmentName); + //筛选出匹配导入部门全路径的部门信息 + DepartmentComInfo dci = new DepartmentComInfo(); + deptInfos = toDealDeptInfos.stream().filter(f -> { + try { + String departmentRealPath = dci.getDepartmentRealPath(f.getId().toString()); + return departmentRealPath.contains(departmentFullName); + } catch (Exception e) { + throw new SalaryRunTimeException(e.getMessage()); + } + }).collect(Collectors.toList()); + + if (deptInfos.size() == 0) { + isError = true; + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", row + SalaryI18nUtil.getI18nLabel(0, "部门信息不存在,请检查部门数据是否正确")); + excelComments.add(errorMessageMap); + } + } + if (StringUtils.isNotBlank(companystartdate) && (companystartdate.length() < 10 || !SalaryDateUtil.checkDay(companystartdate.substring(0, 10)))) { + isError = true; + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", row + SalaryI18nUtil.getI18nLabel(0, "入职日期格式错误,正确格式为YYYY-MM或者yyyy-MM-dd")); + excelComments.add(errorMessageMap); + } + + if (!isError){ + //校验当前数据是否有相关数据(姓名相同)存在数据库中,有则更新,无则新建 + List targetExtEmpInfoList = allExtEmpInfo.stream().filter(f -> f.getUsername().equals(username)).collect(Collectors.toList()); + //校验部门和分部关系 + List targetDeptInfos = new ArrayList<>(); + List targetSubCompanyInfos = new ArrayList<>(); + if (targetExtEmpInfoList.size() == 1) { + ExtEmpPO targetExtEmpInfo = targetExtEmpInfoList.get(0); + //将库中已有的部门和分布信息取出(excel行未设置对应字段数据时) + if (targetExtEmpInfo.getSubcompanyId() != null && subCompanyInfos.size() == 0) { + subCompanyInfos.add(SubCompanyInfo.builder().id(targetExtEmpInfo.getSubcompanyId()).name(targetExtEmpInfo.getSubcompanyName()).build()); + } + if (targetExtEmpInfo.getDepartmentId() != null && deptInfos.size() == 0) { + DeptInfo oldDeptInfo = getEmployMapper().getDeptInfoById(targetExtEmpInfo.getDepartmentId()); + deptInfos.add(oldDeptInfo); + } + } + //分部结果数为0,部门结果数大于1,则无法匹配 + if(subCompanyInfos.size() == 0 && deptInfos.size() > 1) { + isError = true; + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", row + SalaryI18nUtil.getI18nLabel(0, "系统中存在重复部门信息,无法指定当前人员关联的唯一部门,请细化部门上级部门或填写部门所属的分部信息来缩小部门筛选范围")); + excelComments.add(errorMessageMap); + } else if (subCompanyInfos.size() > 1 && deptInfos.size() == 0) { + //部门结果数为0,分部结果数大于1,则无法匹配 + isError = true; + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", row + SalaryI18nUtil.getI18nLabel(0, "系统中存在重复分部信息,无法指定当前人员关联的唯一分部,请通过填写人员所属的部门信息来缩小分部筛选范围")); + excelComments.add(errorMessageMap); + } else if (subCompanyInfos.size() >= 1 && deptInfos.size() >= 1) { + //部门结果数大于等于1,分部结果数大于等于1,筛选出可配对的组合,根据部门的所属分部字段进行配对 + for (DeptInfo deptInfo : deptInfos) { + if (subCompanyInfos.stream().filter(g -> g.getId().equals(deptInfo.getSubcompanyid1())).count() > 0) { + targetDeptInfos.add(deptInfo); + } + } + if (targetDeptInfos.size() == 0) { + isError = true; + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", row + SalaryI18nUtil.getI18nLabel(0, "部门与分部无法匹配")); + excelComments.add(errorMessageMap); + } else if (targetDeptInfos.size() > 1) { + isError = true; + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", row + SalaryI18nUtil.getI18nLabel(0, "该组数据中的部门和分部信息在系统中出现多组匹配的部门和分部组合,无法指定唯一的部门和分部组合")); + excelComments.add(errorMessageMap); + } else { + targetSubCompanyInfos = subCompanyInfos.stream().filter(f -> f.getId().equals(targetDeptInfos.get(0).getSubcompanyid1())).collect(Collectors.toList()); + } + + } else if (subCompanyInfos.size() == 0 && deptInfos.size() == 1) { + //分部结果数为0,部门结果数为1,可以匹配 + targetDeptInfos.add(deptInfos.get(0)); + } else if (subCompanyInfos.size() == 1 && deptInfos.size() == 0) { + //部门结果数为0,分部结果数为1,可以匹配 + targetSubCompanyInfos.add(subCompanyInfos.get(0)); + } + //收集excel有效数据,并区分新增和更新 + DeptInfo finalDeptInfo = targetDeptInfos.size() > 0 ? targetDeptInfos.get(0) : null; + SubCompanyInfo finalSubCompanyInfo = targetSubCompanyInfos.size() > 0 ? targetSubCompanyInfos.get(0) : null; + if (targetExtEmpInfoList.isEmpty()) { + if (!isError) { + //添加一条新建数据 + insertExtEmpPOList.add(handleExtEmpInfo(null, map, finalDeptInfo, finalSubCompanyInfo)); + } + } else if (targetExtEmpInfoList.size() > 1) { + isError = true; + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", row + SalaryI18nUtil.getI18nLabel(0, "数据库中非系统人员信息存在姓名相同数据,请先确保姓名唯一")); + excelComments.add(errorMessageMap); + } else { + if (!isError) { + //添加一条更新数据 + updateExtEmpPOList.add(handleExtEmpInfo(targetExtEmpInfoList.get(0), map, finalDeptInfo, finalSubCompanyInfo)); + } + } + + } + + if (isError) { + failCount++; + errorDatas.add(map); + } else { + successCount++; + } + + } + //更新 + for(ExtEmpPO po : updateExtEmpPOList) { + getExternalEmployeeMapper().updateIgnoreNull(po); + + // 记录日志 + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(po.getId())); + loggerContext.setTargetName(po.getUsername()); + loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "导入-更新非系统人员")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "导入-更新非系统人员") + ": " + po.getUsername()); + loggerContext.setNewValues(po); + SalaryElogConfig.extEmployeeLoggerTemplate.write(loggerContext); + } + //新建 + for(ExtEmpPO po : insertExtEmpPOList) { + getExternalEmployeeMapper().insertIgnoreNull(po); + + // 记录日志 + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(po.getId())); + loggerContext.setTargetName(po.getUsername()); + loggerContext.setOperateType(OperateTypeEnum.ADD.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "导入-新增非系统人员")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "导入-新增非系统人员") + ": " + po.getUsername()); + loggerContext.setNewValues(po); + SalaryElogConfig.extEmployeeLoggerTemplate.write(loggerContext); + } + + + apidatas.put("successCount", successCount); + apidatas.put("errorCount", failCount); + apidatas.put("errorData", excelComments); + + } finally { + IOUtils.closeQuietly(fileInputStream); + } + return apidatas; + } + + public ExtEmpPO handleExtEmpInfo(ExtEmpPO po, Map map, DeptInfo deptInfo, SubCompanyInfo subCompanyInfo) { + ExtEmpPO resultPo = new ExtEmpPO(); + if (po == null) { + //新建 + resultPo.setId(IdGenerator.generate()); + resultPo.setStatus("2"); + resultPo.setCreateTime(new Date()); + resultPo.setUpdateTime(new Date()); + resultPo.setDeleteType(0); + resultPo.setCreator((long) user.getUID()); + } else { + //更新 + BeanUtils.copyProperties(po, resultPo); + resultPo.setUpdateTime(new Date()); + } + String username = (String) map.getOrDefault(SalaryI18nUtil.getI18nLabel(25034, "姓名"), ""); +// String departmentName = (String) map.getOrDefault(SalaryI18nUtil.getI18nLabel(27511, "部门"), ""); +// String subcompanyName = (String) map.getOrDefault(SalaryI18nUtil.getI18nLabel(33553, "分部"), ""); + String companystartdate = (String) map.getOrDefault(SalaryI18nUtil.getI18nLabel(1516, "入职日期"), ""); + String mobile = (String) map.getOrDefault(SalaryI18nUtil.getI18nLabel(125238, "手机号"), ""); + String workcode = (String) map.getOrDefault(SalaryI18nUtil.getI18nLabel(1933, "工号"), ""); + String idNo = (String) map.getOrDefault(SalaryI18nUtil.getI18nLabel(1887, "身份证号码"), ""); + String bankCardNum = (String) map.getOrDefault(SalaryI18nUtil.getI18nLabel(0, "本人开户的银行卡卡号"), ""); + String bankName = (String) map.getOrDefault(SalaryI18nUtil.getI18nLabel(0, "本人开户的银行卡开户支行全称"), ""); + + if (StringUtils.isNotBlank(companystartdate)) { + resultPo.setCompanystartdate(companystartdate.substring(0, 10)); + } + + if (StringUtils.isNotBlank(username)) { + resultPo.setUsername(username); + } + if (StringUtils.isNotBlank(mobile)) { + resultPo.setMobile(mobile); + } + if (StringUtils.isNotBlank(workcode)) { + resultPo.setWorkcode(workcode); + } + if (StringUtils.isNotBlank(idNo)) { + resultPo.setIdNo(idNo); + } + if (StringUtils.isNotBlank(bankCardNum)) { + resultPo.setBankCardNum(bankCardNum); + } + if (StringUtils.isNotBlank(bankName)) { + resultPo.setBankName(bankName); + } + if (deptInfo != null) { + resultPo.setDepartmentName(deptInfo.getName()); + resultPo.setDepartmentId(deptInfo.getId()); + } + if (subCompanyInfo != null) { + resultPo.setSubcompanyName(subCompanyInfo.getName()); + resultPo.setSubcompanyId(subCompanyInfo.getId()); + } + if (resultPo.getDepartmentName() == null) { + resultPo.setDepartmentName(""); + } + resultPo.setModifier((long) user.getUID()); + return resultPo; + } + + @Override + public List listBySubCompanyOrDepartment(List subCompanyIds, List departmentIds) { + return getExternalEmployeeMapper().listSomeDataCollectionEmployee(ExtEmpPO.builder().subcompanyIds(subCompanyIds).departmentIds(departmentIds).build()); + } +} diff --git a/src/com/engine/salary/service/impl/FormulaRunServiceImpl.java b/src/com/engine/salary/service/impl/FormulaRunServiceImpl.java new file mode 100644 index 000000000..07c5ae633 --- /dev/null +++ b/src/com/engine/salary/service/impl/FormulaRunServiceImpl.java @@ -0,0 +1,242 @@ +package com.engine.salary.service.impl; + +import com.engine.core.impl.Service; +import com.engine.salary.encrypt.AESEncryptUtil; +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.salaryformula.ExpressFormula; +import com.engine.salary.entity.salaryformula.po.FormulaVar; +import com.engine.salary.enums.salaryformula.ReferenceTypeEnum; +import com.engine.salary.formlua.core.QlExpress; +import com.engine.salary.formlua.entity.parameter.DataType; +import com.engine.salary.formlua.entity.standard.ExcelResult; +import com.engine.salary.mapper.SQLMapper; +import com.engine.salary.service.FormulaRunService; +import com.engine.salary.sys.enums.OpenEnum; +import com.engine.salary.util.JsonUtil; +import com.engine.salary.util.db.MapperProxyFactory; +import com.ql.util.express.DefaultContext; +import com.ql.util.express.ExpressRunner; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.math.NumberUtils; +import org.springframework.util.StopWatch; +import weaver.conn.RecordSet; +import weaver.conn.RecordSetDataSource; +import weaver.general.BaseBean; +import weaver.general.Util; + +import java.math.BigDecimal; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Slf4j +public class FormulaRunServiceImpl extends Service implements FormulaRunService { + + private static ExpressRunner runner = new ExpressRunner(true, false); + + private final BaseBean baseBean = new BaseBean(); + + private final Boolean isLog = "true".equals(baseBean.getPropValue("hrmSalary", "log")); + //超时提醒 + private final String formulaRunOvertimeThreshold = baseBean.getPropValue("hrmSalaryCustom", "formulaRunOvertimeThreshold"); + + QlExpress express = new QlExpress(); + + private SQLMapper getSQLMapper(){ + return MapperProxyFactory.getProxy(SQLMapper.class); + } + + @Override + public ExcelResult run(ExpressFormula expressFormula, List formulaVars, DataCollectionEmployee simpleEmployee) { + ExcelResult result = new ExcelResult(false, "", "公式类型异常!"); + if (StringUtils.isNotBlank(formulaRunOvertimeThreshold)) { + StopWatch stopWatch = new StopWatch(); + stopWatch.start("run " + expressFormula.getName()); + if (ReferenceTypeEnum.parseByValue(expressFormula.getReferenceType()) == ReferenceTypeEnum.FORMULA) { + result = runFormula(expressFormula, formulaVars); + } + if (ReferenceTypeEnum.parseByValue(expressFormula.getReferenceType()) == ReferenceTypeEnum.SQL) { + result = runSQL(expressFormula, formulaVars); + } + stopWatch.stop(); + long totalTimeMillis = stopWatch.getTotalTimeMillis(); + result.setRunTime(totalTimeMillis); + } else { + if (ReferenceTypeEnum.parseByValue(expressFormula.getReferenceType()) == ReferenceTypeEnum.FORMULA) { + result = runFormula(expressFormula, formulaVars); + } + if (ReferenceTypeEnum.parseByValue(expressFormula.getReferenceType()) == ReferenceTypeEnum.SQL) { + result = runSQL(expressFormula, formulaVars); + } + } + return result; + } + + private ExcelResult runSQL(ExpressFormula expressFormula, List formulaVars) { + if (isLog) { + log.info("SQL ExpressFormula {}", expressFormula); + } + ExcelResult excelResult = new ExcelResult(); + + //解析配置,获取返回值、数据源 + String extendParam = expressFormula.getExtendParam(); + String sqlReturnKey = ""; + String datasourceId = ""; + String openDecrypt = ""; + String result = ""; + try { + Map map = JsonUtil.parseMap(extendParam, String.class); + //返回值配置 + sqlReturnKey = map.getOrDefault("sqlReturnKey", ""); + if (StringUtils.isNotBlank(sqlReturnKey)) { + sqlReturnKey = sqlReturnKey.trim(); + } + //数据源配置 + String datasourceJson = map.getOrDefault("datasource", ""); + if (StringUtils.isNotBlank(datasourceJson)) { + Map datasourceIdMap = JsonUtil.parseMap(datasourceJson, String.class); + String datasourceIdNode = datasourceIdMap.getOrDefault("datasourceId", ""); + if (StringUtils.isNotBlank(datasourceIdNode)) { + datasourceId = datasourceIdNode; + } + } + //是否需要解密 + String decrypt = map.get("openDecrypt"); + if (StringUtils.isNotBlank(decrypt)) { + openDecrypt = decrypt.trim(); + } + + //解析sql + String sql = expressFormula.getFormulaRunScript(); + for (FormulaVar formulaVar : formulaVars) { + sql = sql.replaceAll(formulaVar.getFieldId(), "'" + formulaVar.getContent() + "'"); + } + if (isLog) { + log.info("ExpressFormula sql run {}", sql); + } + + excelResult.setExpress(sql); + + //外部数据源 + if (StringUtils.isNotBlank(datasourceId)) { + RecordSetDataSource rs = new RecordSetDataSource(datasourceId); + log.error("执行外部sql,{},datasourceId{}", sql, datasourceId); + if (rs.executeSql(sql)) { + if (rs.next()) { + result = rs.getString(sqlReturnKey); + } + } + } else { + +// List list = getSQLMapper().runSQL(sql); +// if(CollectionUtil.isNotEmpty(list)){ +// result = Util.null2String(list.get(0).get(sqlReturnKey)); +// } + + RecordSet rs = new RecordSet(); + if (rs.execute(sql)) { + if (rs.next()) { + result = rs.getString(sqlReturnKey); + } + } + } + + if (OpenEnum.OPEN.getValue().equals(openDecrypt)) { + result = AESEncryptUtil.decrypt(result); + } + + excelResult.setStatus(true); + excelResult.setData(Util.null2String(result)); + return excelResult; + + } catch (Throwable e) { + log.error("express run err sql", e); + while (e.getCause() != null) { + e = e.getCause(); + } + excelResult.setStatus(false); + excelResult.setErrorMsg(e.getMessage()); + return excelResult; + } + } + + private ExcelResult runFormula(ExpressFormula expressFormula, List formulaVars) { + + if (isLog) { + log.info("FORMULA ExpressFormula {} {}", expressFormula.getFormula(), expressFormula.getFormulaRunScript()); + } + + //是否是自定义函数 + boolean isCustomFunction = true; + + String extendParam = expressFormula.getExtendParam(); + try { + Map map = JsonUtil.parseMap(extendParam, String.class); + //返回值配置 + String isCustomFunctionNode = map.getOrDefault("isCustomFunction", ""); + if (StringUtils.isNotBlank(isCustomFunctionNode)) { + isCustomFunction = StringUtils.equals(isCustomFunctionNode.trim(), "1"); + } + } catch (Exception e) { + log.error("express execute fail, extendParam parse fail {}", extendParam, e); + } + + String formula = expressFormula.getFormulaRunScript(); + + ExcelResult execute = new ExcelResult(); + if (isCustomFunction) { + try { + execute.setExpress(formula); + DefaultContext context = new DefaultContext(); + formulaVars.forEach(v -> { + if (isLog) { + log.info("FORMULA formulaVar {} - {}", v.getFieldId(), v.getContent()); + } + if (DataType.NUMBER.equals(v.getFieldType()) && NumberUtils.isCreatable(v.getContent())) { + context.put(v.getFieldId(), new BigDecimal(v.getContent())); + } else { + context.put(v.getFieldId(), v.getContent()); + } + }); + execute.setExpressContext(context); + Object data = runner.execute(formula, context, null, true, false); + + if (data != null) { + execute.setData(data); + execute.setStatus(true); + } else { + execute.setStatus(false); + } + + } catch (Throwable e) { + log.error("express run err isCustomFunction", e); + while (e.getCause() != null) { + e = e.getCause(); + } + execute.setStatus(false); + execute.setErrorMsg(e.getMessage()); + } + + return execute; + } else { + Map context = new HashMap<>(); + formulaVars.forEach(v -> { + if (isLog) { + log.info("FORMULA formulaVar {} - {}", v.getFieldId(), v.getContent()); + } + if (DataType.NUMBER.equals(v.getFieldType()) && NumberUtils.isCreatable(v.getContent())) { + context.put(v.getFieldId(), new BigDecimal(v.getContent())); + } else if (v.getContent().startsWith("[") && v.getContent().endsWith("]")) { + String content = v.getContent().substring(1); + content = content.substring(0, content.length() - 1); + context.put(v.getFieldId(), content.split(",")); + } else { + context.put(v.getFieldId(), v.getContent()); + } + }); + execute = express.execute(formula, context); + return execute; + } + } +} diff --git a/src/com/engine/salary/service/impl/MySalaryShowSetServiceImpl.java b/src/com/engine/salary/service/impl/MySalaryShowSetServiceImpl.java new file mode 100644 index 000000000..57ec01bda --- /dev/null +++ b/src/com/engine/salary/service/impl/MySalaryShowSetServiceImpl.java @@ -0,0 +1,44 @@ +package com.engine.salary.service.impl; + + +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.entity.salaryBill.dto.MySalaryShowSetDTO; +import com.engine.salary.service.MySalaryShowSetService; +import com.engine.salary.sys.constant.SalarySysConstant; +import com.engine.salary.sys.entity.po.SalarySysConfPO; +import com.engine.salary.sys.service.SalarySysConfService; +import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.math.NumberUtils; +import weaver.hrm.User; + +/** + * @Description: 我的薪资福利显示设置 + * @Author: wangxiangzhong + * @Date: 2023/8/7 11:16 + */ +@Slf4j +public class MySalaryShowSetServiceImpl extends Service implements MySalaryShowSetService { + + private SalarySysConfService getSalarySysConfService(User user) { + return ServiceUtil.getService(SalarySysConfServiceImpl.class, user); + } + + /** + * 获取显示设置 + * + * @return + */ + @Override + public MySalaryShowSetDTO get() { + SalarySysConfPO salaryShowStatus = getSalarySysConfService(user).getOneByCode(SalarySysConstant.SALARY_SHOW_STATUS); + SalarySysConfPO adjustShowStatus = getSalarySysConfService(user).getOneByCode(SalarySysConstant.ADJUST_SHOW_STATUS); + + return MySalaryShowSetDTO.builder() + .salaryShowStatus(salaryShowStatus == null ? true : NumberUtils.INTEGER_ONE.equals(salaryShowStatus.getConfValue())) + .adjustShowStatus(adjustShowStatus == null ? true : NumberUtils.INTEGER_ONE.equals(adjustShowStatus.getConfValue())) + .build(); + } + +} diff --git a/src/com/engine/salary/service/impl/OtherDeductionServiceImpl.java b/src/com/engine/salary/service/impl/OtherDeductionServiceImpl.java new file mode 100644 index 000000000..a0fd93816 --- /dev/null +++ b/src/com/engine/salary/service/impl/OtherDeductionServiceImpl.java @@ -0,0 +1,1009 @@ +package com.engine.salary.service.impl; + +import cn.hutool.core.util.NumberUtil; +import com.alibaba.fastjson.JSONObject; +import com.api.formmode.mybatis.util.SqlProxyHandle; +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.hrmelog.entity.dto.LoggerContext; +import com.engine.salary.biz.OtherDeductionBiz; +import com.engine.salary.config.SalaryElogConfig; +import com.engine.salary.constant.SalaryDefaultTenantConstant; +import com.engine.salary.encrypt.EncryptUtil; +import com.engine.salary.entity.datacollection.AddUpDeduction; +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.datacollection.dto.OtherDeductionListDTO; +import com.engine.salary.entity.datacollection.dto.OtherDeductionRecordDTO; +import com.engine.salary.entity.datacollection.param.*; +import com.engine.salary.entity.datacollection.po.OtherDeductionPO; +import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO; +import com.engine.salary.entity.taxagent.dto.TaxAgentManageRangeEmployeeDTO; +import com.engine.salary.entity.taxagent.param.TaxAgentQueryParam; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import com.engine.salary.enums.OperateTypeEnum; +import com.engine.salary.enums.UserStatusEnum; +import com.engine.salary.enums.auth.AuthFilterTypeEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.mapper.datacollection.OtherDeductionMapper; +import com.engine.salary.mapper.sys.SalarySysConfMapper; +import com.engine.salary.service.AddUpDeductionService; +import com.engine.salary.service.OtherDeductionService; +import com.engine.salary.service.SalaryEmployeeService; +import com.engine.salary.service.TaxAgentService; +import com.engine.salary.service.auth.AuthService; +import com.engine.salary.service.auth.AuthServiceImpl; +import com.engine.salary.sys.entity.po.SalarySysConfPO; +import com.engine.salary.sys.entity.vo.OrderRuleVO; +import com.engine.salary.sys.service.SalarySysConfService; +import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl; +import com.engine.salary.util.SalaryDateUtil; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.db.MapperProxyFactory; +import com.engine.salary.util.excel.ExcelComment; +import com.engine.salary.util.excel.ExcelParseHelper; +import com.engine.salary.util.excel.ExcelSupport; +import com.engine.salary.util.excel.ExcelUtil; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.util.page.SalaryPageUtil; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.Validate; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.util.IOUtils; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import weaver.file.ImageFileManager; +import weaver.general.Util; +import weaver.hrm.User; + +import java.io.InputStream; +import java.math.BigDecimal; +import java.text.SimpleDateFormat; +import java.time.LocalDateTime; +import java.time.YearMonth; +import java.util.*; +import java.util.stream.Collectors; + +import static com.engine.salary.constant.SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY; +import static com.engine.salary.util.excel.ExcelSupport.EXCEL_TYPE_XLSX; + +public class OtherDeductionServiceImpl extends Service implements OtherDeductionService { + private EncryptUtil encryptUtil = new EncryptUtil(); + + private OtherDeductionMapper getOtherDeductionMapper() { + return MapperProxyFactory.getProxy(OtherDeductionMapper.class); + } + + private OtherDeductionBiz getOtherDeductionBiz() { + return new OtherDeductionBiz(); + } + + private TaxAgentService getTaxAgentService(User user) { + return ServiceUtil.getService(TaxAgentServiceImpl.class, user); + } + + private AddUpDeductionService getAddUpDeductionService(User user) { + return ServiceUtil.getService(AddUpDeductionServiceImpl.class, user); + } + + private SalaryEmployeeService getSalaryEmployeeService(User user) { + return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user); + } + + private SalarySysConfMapper getSalarySysConfMapper() { + return SqlProxyHandle.getProxy(SalarySysConfMapper.class); + } + + private SalarySysConfService getSalarySysConfService(User user) { + return ServiceUtil.getService(SalarySysConfServiceImpl.class, user); + } + + public AuthService getAuthService(User user) { + return ServiceUtil.getService(AuthServiceImpl.class, user); + } + + @Override + public OtherDeductionPO getById(Long id) { + return getOtherDeductionMapper().getById(id); + } + + + @Override + public PageInfo listPage(OtherDeductionQueryParam queryParam) { + //申报月份 + List declareMonth = queryParam.getDeclareMonth(); + if (CollectionUtils.isNotEmpty(declareMonth)) { + queryParam.setDeclareMonth(declareMonth.stream().filter(StringUtils::isNotBlank).map(e -> e + "-01 00:00:00").collect(Collectors.toList())); + queryParam.setDeclareMonthDate(declareMonth.stream().filter(StringUtils::isNotBlank).map(e -> e + "-01 00:00:00").map(SalaryDateUtil::dateStrToLocalTime).collect(Collectors.toList())); + } + + //排序配置 + OrderRuleVO orderRule = getSalarySysConfService(user).orderRule(); + queryParam.setOrderRule(orderRule); + + queryParam.setFilterType(AuthFilterTypeEnum.DATA_OPT); + List list = listAuth(queryParam); + + PageInfo page = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), + list, OtherDeductionListDTO.class); + encryptUtil.decryptList(page.getList(), OtherDeductionListDTO.class); + SalaryI18nUtil.i18nList(page.getList()); + return page; + } + + @Override + public PageInfo recordListPage(OtherDeductionQueryParam queryParam) { + //申报月份 + List declareMonth = queryParam.getDeclareMonth(); + if (CollectionUtils.isNotEmpty(declareMonth)) { + queryParam.setDeclareMonth(declareMonth.stream().map(e -> e + "-01 00:00:00").collect(Collectors.toList())); + queryParam.setDeclareMonthDate(declareMonth.stream().map(e -> e + "-01 00:00:00").map(SalaryDateUtil::dateStrToLocalTime).collect(Collectors.toList())); + } + + List list = getOtherDeductionMapper().recordList(queryParam); + PageInfo page = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), + list, OtherDeductionRecordDTO.class); + encryptUtil.decryptList(page.getList(), OtherDeductionRecordDTO.class); + SalaryI18nUtil.i18nList(page.getList()); + return page; + } + + + @Override + public Map preview(OtherDeductionImportParam importParam) { + Map apidatas = new HashMap(); + + //excel文件id + String imageId = Util.null2String(importParam.getImageId()); + Validate.notBlank(imageId, "imageId为空"); + + InputStream fileInputStream = null; + try { + fileInputStream = ImageFileManager.getInputStreamById(Integer.parseInt(imageId)); + Sheet sheet = ExcelSupport.parseFile(fileInputStream, 0, EXCEL_TYPE_XLSX); + apidatas.put("headers", ExcelSupport.getSheetHeader(sheet, 0)); + apidatas.put("list", ExcelParseHelper.parse2List(sheet, 1, 0)); + return apidatas; + } finally { + IOUtils.closeQuietly(fileInputStream); + } + } + + + public Map importData(OtherDeductionImportParam importParam) { + + Map apidatas = new HashMap(); + OtherDeductionBiz OtherDeductionBiz = new OtherDeductionBiz(); + + //查询对于人员信息导入筛选的全局配置 + SalarySysConfPO salarySysConfPO = getSalarySysConfMapper().getOneByCode("matchEmployeeMode"); + String confValue = (salarySysConfPO != null && salarySysConfPO.getConfValue() != null && !"".equals(salarySysConfPO.getConfValue())) ? salarySysConfPO.getConfValue() : "0"; + + //检验参数 + checkImportParam(importParam); + + //excel文件id + String imageId = Util.null2String(importParam.getImageId()); + Validate.notBlank(imageId, "imageId为空"); + //税款所属期 + String declareMonthStr = Util.null2String(importParam.getDeclareMonth()); + //个税扣缴义务人 + String taxAgentId = Util.null2String(importParam.getTaxAgentId()); + + InputStream fileInputStream = null; + try { + fileInputStream = ImageFileManager.getInputStreamById(Integer.parseInt(imageId)); + List OtherDeductions = ExcelParseHelper.parse2Map(fileInputStream, OtherDeductionListDTO.class, 0, 1, 12, "OtherDeductionTemplate.xlsx"); + + int total = OtherDeductions.size(); + int index = 0; + int successCount = 0; + int errorCount = 0; + + //人员信息 + List employees = getSalaryEmployeeService(user).listEmployee(); + // 获取所有个税扣缴义务人 + TaxAgentQueryParam param = TaxAgentQueryParam.builder().build(); + param.setFilterType(AuthFilterTypeEnum.ADMIN_DATA); + Collection taxAgentList = getTaxAgentService(user).listAuth(param); + //税款所属期 + Date declareMonth = SalaryDateUtil.stringToDate(declareMonthStr + "-01"); + // 获取已经核算的数据 + List salaryAcctEmployees = getAddUpDeductionService(user).getAccountedEmployeeDataByTaxYearMonth(declareMonthStr); + // 查询已有数据 + List list = getOtherDeductionMapper().listSome(OtherDeductionPO.builder().declareMonth(declareMonth).build()); + + // 错误excel内容 + List errorData = new ArrayList<>(); + //合规数据 + List eligibleData = new ArrayList<>(); + + for (int i = 0; i < OtherDeductions.size(); i++) { + OtherDeductionListDTO dto = OtherDeductions.get(i); + + Date now = new Date(); + //待插入数据库对象 + OtherDeductionPO po = OtherDeductionPO.builder() + .tenantKey(DEFAULT_TENANT_KEY) + .createTime(now) + .updateTime(now) + .creator((long) user.getUID()) + .declareMonth(declareMonth).build(); + + //异常点数量 + int errorSum = 0; + + //行号 + String rowIndex = String.format("第%s行", i + 2); + + //相同的姓名 + String userName = dto.getUsername(); + String deparmentName = dto.getDepartmentName(); + String mobile = dto.getMobile(); + String workcode = dto.getJobNum(); + String idNo = dto.getIdNo(); + List employeeSameIds = new ArrayList<>(); + + //筛选导入人员信息可以在人力资源池中匹配到的人员信息 + List emps = getSalaryEmployeeService(user).matchImportEmployee(confValue, employees, userName, deparmentName, mobile, workcode, idNo, null); + //含在职和离职,选在职数据 + if (CollectionUtils.isNotEmpty(emps) && emps.size() > 1) { + employeeSameIds = emps.stream() + .filter(e -> UserStatusEnum.getNormalStatus().contains(e.getStatus())) + .map(DataCollectionEmployee::getEmployeeId) + .collect(Collectors.toList()); + } + if (CollectionUtils.isNotEmpty(emps) && emps.size() == 1) { + employeeSameIds = emps.stream() + .map(DataCollectionEmployee::getEmployeeId) + .collect(Collectors.toList()); + } + + //当人员信息导入筛选的全局配置为"0"时,姓名才是必填项 + if (StringUtils.isBlank(userName) && "0".equals(confValue)) { + //姓名 不能为空 + //错误消息对象 + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowIndex + "姓名不能为空"); + errorData.add(errorMessageMap); + errorSum += 1; + } else if (CollectionUtils.isEmpty(employeeSameIds) || employeeSameIds.size() > 1) { + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowIndex + "员工信息不存在或者存在多个员工"); + errorData.add(errorMessageMap); + errorSum += 1; + } else { + Long employeeId = CollectionUtils.isNotEmpty(employeeSameIds) && employeeSameIds.size() == 1 ? employeeSameIds.get(0) : null; + if (employeeId != null && employeeId > 0) { + po.setEmployeeId(employeeId); + } else { + //姓名错误,系统内不存在该姓名 + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowIndex + "姓名错误,系统内不存在该姓名"); + errorData.add(errorMessageMap); + errorSum += 1; + } + } + + + String taxAgentName = dto.getTaxAgentName(); + if (StringUtils.isBlank(taxAgentName)) { + //个税扣缴义务人不能为空 + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowIndex + "个税扣缴义务人不能为空"); + errorData.add(errorMessageMap); + errorSum += 1; + } else { + Optional optionalTemp = taxAgentList.stream().filter(m -> m.getName().equals(taxAgentName)).findFirst(); + if (optionalTemp.isPresent()) { + if (StringUtils.isNotEmpty(taxAgentId) && !optionalTemp.get().getId().equals(Long.valueOf(taxAgentId))) { + //个税扣缴义务人与导入时选择的不一致 + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowIndex + "个税扣缴义务人与导入时选择的不一致"); + errorData.add(errorMessageMap); + errorSum += 1; + } else { + po.setTaxAgentId(optionalTemp.get().getId()); + } + } else { + //个税扣缴义务人不存在 + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowIndex + "个税扣缴义务人不存在或不在权限范围内"); + errorData.add(errorMessageMap); + errorSum += 1; + } + } + + //商业健康保险 + String businessHealthyInsurance = dto.getBusinessHealthyInsurance(); + po.setBusinessHealthyInsurance(businessHealthyInsurance); + //税延养老保险 + String taxDelayEndowmentInsurance = dto.getTaxDelayEndowmentInsurance(); + po.setTaxDelayEndowmentInsurance(taxDelayEndowmentInsurance); + //其他 + String otherDeduction = dto.getOtherDeduction(); + po.setOtherDeduction(otherDeduction); + //准予扣除的捐赠额 + String deductionAllowedDonation = dto.getDeductionAllowedDonation(); + po.setDeductionAllowedDonation(deductionAllowedDonation); + //个人养老金 + String privatePension = dto.getPrivatePension(); + po.setPrivatePension(privatePension); + + + // 判断是否有核算过 + if (CollectionUtils.isNotEmpty(salaryAcctEmployees)) { + OtherDeductionPO finalPo = po; + Optional optionalAcctEmp = salaryAcctEmployees.stream().filter(f -> f.getEmployeeId().equals(finalPo.getEmployeeId()) && f.getTaxAgentId().equals(finalPo.getTaxAgentId())).findFirst(); + boolean isExist = list.stream().anyMatch(f -> f.getEmployeeId().equals(finalPo.getEmployeeId()) && f.getTaxAgentId().equals(finalPo.getTaxAgentId())); + if (optionalAcctEmp.isPresent() && isExist) { + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowIndex + "该年月这条数据已经核算过,不可导入"); + errorData.add(errorMessageMap); + errorSum += 1; + } + } + + + if (errorSum == 0) { + successCount += 1; + // 合格数据 + eligibleData.add(po); + } else { + errorCount += 1; + // 添加错误数据 + } + } + + //入库 + OtherDeductionBiz.handleImportData(eligibleData, user); + + apidatas.put("successCount", successCount); + apidatas.put("errorCount", errorCount); + apidatas.put("errorData", errorData); + + } finally { + IOUtils.closeQuietly(fileInputStream); + } + return apidatas; + } + + /** + * 处理导入数据 + * + * @param pos + */ + public void handleImportData(List pos) { + if (CollectionUtils.isEmpty(pos)) { + return; + } + OtherDeductionBiz otherDeductionBiz = new OtherDeductionBiz(); + OtherDeductionPO po = pos.get(0); + // 多条相同人的则以第一条为准,如果逆序排列(用于重复的则以最后一条为准)Collections.reverse(pos); + // 去重(通过记录的唯一条件(申报月份,人员id,个税扣缴义务人id)拼接) + List finalPos = pos.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(f -> f.getEmployeeId() + "-" + f.getTaxAgentId()))), ArrayList::new)); + // 查询已有数据 + List list = otherDeductionBiz.listSome(OtherDeductionPO.builder().declareMonth(po.getDeclareMonth()).build()); + // 待修改的 本地已存在则更新【交集】 + List updateList = list.stream().map(m -> { + Optional optional = finalPos.stream().filter(p -> (p.getEmployeeId() + "-" + p.getTaxAgentId()).equals(m.getEmployeeId() + "-" + m.getTaxAgentId())).findFirst(); + OtherDeductionPO temp = null; + if (optional.isPresent()) { + temp = optional.get(); + // 换成本地库的id + temp.setId(m.getId()); + } + return temp; + }).filter(Objects::nonNull).collect(Collectors.toList()); + // 待新增的 导入比本地多,则新增【差集(导入 - local)】 + List saveList = finalPos.stream().map(m -> { + Optional optional = list.stream().filter(p -> (p.getEmployeeId() + "-" + p.getTaxAgentId()).equals(m.getEmployeeId() + "-" + m.getTaxAgentId())).findFirst(); + OtherDeductionPO temp = null; + if (!optional.isPresent()) { + temp = m; + } + return temp; + }).filter(Objects::nonNull).collect(Collectors.toList()); + + // 修改 + if (CollectionUtils.isNotEmpty(updateList)) { + otherDeductionBiz.batchUpdate(updateList); + } + // 保存 + if (CollectionUtils.isNotEmpty(saveList)) { + otherDeductionBiz.batchSave(saveList); + } + // 记录日志 + // 根据月份、人员id查出保存的数据 + List empIds = saveList.stream().map(OtherDeductionPO::getEmployeeId).collect(Collectors.toList()); + List insertList = otherDeductionBiz.listSome(OtherDeductionPO.builder().declareMonth(po.getDeclareMonth()).employeeIds(empIds).build()); + Map insertMap = SalaryEntityUtil.convert2Map(insertList, p -> p.getTaxAgentId() + "-" + SalaryDateUtil.getFormatYearMonth(p.getDeclareMonth()) + "-" + p.getEmployeeId()); + saveList.forEach(save -> { + OtherDeductionPO otherDeductionPO = insertMap.get(save.getTaxAgentId() + "-" + SalaryDateUtil.getFormatYearMonth(save.getDeclareMonth()) + "-" + save.getEmployeeId()); + if (otherDeductionPO != null) { + updateList.add(otherDeductionPO); + } + }); + + if (CollectionUtils.isNotEmpty(updateList)) { + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + if (updateList.size() == 1) { + loggerContext.setTargetId(updateList.get(0).getId().toString()); + } + loggerContext.setTargetName(SalaryI18nUtil.getI18nLabel(0, "其他免税扣除")); + loggerContext.setOperateType(OperateTypeEnum.ADD.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "新增")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "新增其他免税扣除")); + loggerContext.setNewValueList(updateList); + SalaryElogConfig.otherDeductionLoggerTemplate.write(loggerContext); + } + } + + private void checkImportParam(OtherDeductionImportParam importParam) { + //excel文件id + String imageId = Util.null2String(importParam.getImageId()); + //税款所属期 + String declareMonthStr = Util.null2String(importParam.getDeclareMonth()); + //个税扣缴义务人 + String taxAgentId = Util.null2String(importParam.getTaxAgentId()); + + if (StringUtils.isBlank(imageId)) { + throw new SalaryRunTimeException("文件不存在"); + } + if (StringUtils.isBlank(declareMonthStr)) { + throw new SalaryRunTimeException("税款所属期为空"); + } + } + + + /** + * 导出 + * + * @param param + * @return + */ + public XSSFWorkbook export(OtherDeductionQueryParam param) { + + //获取操作按钮资源 + List> rowList = getExcelRowList(param, true); + + // 记录日志 + String name = SalaryI18nUtil.getI18nLabel(0, "导出"); + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setTargetName(SalaryI18nUtil.getI18nLabel(0, "其他免税扣除")); + loggerContext.setOperateType(OperateTypeEnum.EXCEL_EXPORT.getValue()); + loggerContext.setOperateTypeName(name); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "其他免税扣除") + "-" + name); + loggerContext.setUser(user); + SalaryElogConfig.otherDeductionLoggerTemplate.write(loggerContext); + + //获取excel + return ExcelUtil.genWorkbookV2WithDefaultPattern(rowList, "其他免税扣除", 2); + } + + + /** + * 获取excel数据行 + * + * @return 导出数据行集合 + */ + private List> getExcelRowList(OtherDeductionQueryParam param, boolean hasData) { + //excel标题 + List title = Arrays.asList("姓名", "个税扣缴义务人", "部门", "手机号", "工号", "证件号码", "入职日期", "商业健康保险", "税延养老保险", "其他", "准予扣除的捐赠额", "个人养老金"); + List> rowList = new ArrayList<>(); + rowList.add(title); + + if (hasData) { + //排序配置 + OrderRuleVO orderRule = getSalarySysConfService(user).orderRule(); + param.setOrderRule(orderRule); + + param.setFilterType( AuthFilterTypeEnum.QUERY_DATA); + List list = listAuth(param); + encryptUtil.decryptList(list, OtherDeductionListDTO.class); + SalaryI18nUtil.i18nList(list); + + final List> dataRowList = Optional.ofNullable(list) + .map(List::stream) + .map(operatorStream -> operatorStream.map(dto -> { + List cellList = new ArrayList<>(); + cellList.add(Util.null2String(dto.getUsername())); + cellList.add(Util.null2String(dto.getTaxAgentName())); + cellList.add(Util.null2String(dto.getDepartmentName())); + cellList.add(Util.null2String(dto.getMobile())); + cellList.add(Util.null2String(dto.getJobNum())); + cellList.add(Util.null2String(dto.getIdNo())); + cellList.add(Util.null2String(dto.getHiredate())); + cellList.add(NumberUtil.isNumber(dto.getBusinessHealthyInsurance()) ? new BigDecimal(dto.getBusinessHealthyInsurance()) : Util.null2String(dto.getBusinessHealthyInsurance())); + cellList.add(NumberUtil.isNumber(dto.getTaxDelayEndowmentInsurance()) ? new BigDecimal(dto.getTaxDelayEndowmentInsurance()) : Util.null2String(dto.getTaxDelayEndowmentInsurance())); + cellList.add(NumberUtil.isNumber(dto.getOtherDeduction()) ? new BigDecimal(dto.getOtherDeduction()) : Util.null2String(dto.getOtherDeduction())); + cellList.add(NumberUtil.isNumber(dto.getDeductionAllowedDonation()) ? new BigDecimal(dto.getDeductionAllowedDonation()) : Util.null2String(dto.getDeductionAllowedDonation())); + cellList.add(NumberUtil.isNumber(dto.getPrivatePension()) ? new BigDecimal(dto.getPrivatePension()) : Util.null2String(dto.getPrivatePension())); + return cellList; + }).collect(Collectors.toList())) + .orElse(Collections.emptyList()); + + rowList.addAll(dataRowList); + } + + return rowList; + } + + + /** + * 导出详情列表 + * + * @param param + * @return + */ + public XSSFWorkbook exportDetail(OtherDeductionQueryParam param) { + + OtherDeductionBiz biz = new OtherDeductionBiz(); + + Long id = param.getOtherTaxExemptDeductionId(); + if (id == null) { + throw new SalaryRunTimeException("id不能为空"); + } + + OtherDeductionPO po = biz.getById(id); + if (po == null) { + throw new SalaryRunTimeException(String.format("其他免税扣除不存在" + "[id:%s]", id)); + } + + List employeeList = getSalaryEmployeeService(user).getEmployeeByIds(Collections.singletonList(po.getEmployeeId())); + if (CollectionUtils.isEmpty(employeeList)) { + throw new SalaryRunTimeException("员工信息不存在"); + } + + //构建参数 + param.setEmployeeId(po.getEmployeeId()); + //申报月份 + List declareMonth = param.getDeclareMonth(); + if (CollectionUtils.isNotEmpty(declareMonth)) { + param.setDeclareMonth(declareMonth.stream().map(e -> e + "-01 00:00:00").collect(Collectors.toList())); + param.setDeclareMonthDate(declareMonth.stream().map(e -> e + "-01 00:00:00").map(SalaryDateUtil::dateStrToLocalTime).collect(Collectors.toList())); + } + + + //获取操作按钮资源 + List> rowList = getExcelRowDetailList(param); + + //获取excel + return ExcelUtil.genWorkbookWithDefaultPattern(rowList, "其他免税扣除明细", 2); + } + + + /** + * 导出详情 + * + * @param param + * @return + */ + private List> getExcelRowDetailList(OtherDeductionQueryParam param) { + //excel标题 + List title = Arrays.asList("姓名", "申报月份", "个税扣缴义务人", "部门", "手机号", "工号", "商业健康保险", "税延养老保险", "其他", "准予扣除的捐赠额", "个人养老金"); + + SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM"); + //查询详细信息 + List list = getOtherDeductionMapper().recordList(param); + encryptUtil.decryptList(list, OtherDeductionRecordDTO.class); + SalaryI18nUtil.i18nList(list); + final List> dataRowList = Optional.ofNullable(list) + .map(List::stream) + .map(operatorStream -> operatorStream.map(dto -> { + List cellList = new ArrayList<>(); + cellList.add(Util.null2String(dto.getUsername())); + cellList.add(Util.null2String(dto.getDeclareMonth() == null ? "" : formatter.format(dto.getDeclareMonth()))); + cellList.add(Util.null2String(dto.getTaxAgentName())); + cellList.add(Util.null2String(dto.getDepartmentName())); + cellList.add(Util.null2String(dto.getMobile())); + cellList.add(Util.null2String(dto.getJobNum())); + cellList.add(NumberUtil.isNumber(dto.getBusinessHealthyInsurance()) ? new BigDecimal(dto.getBusinessHealthyInsurance()) : Util.null2String(dto.getBusinessHealthyInsurance())); + cellList.add(NumberUtil.isNumber(dto.getTaxDelayEndowmentInsurance()) ? new BigDecimal(dto.getTaxDelayEndowmentInsurance()) : Util.null2String(dto.getTaxDelayEndowmentInsurance())); + cellList.add(NumberUtil.isNumber(dto.getOtherDeduction()) ? new BigDecimal(dto.getOtherDeduction()) : Util.null2String(dto.getOtherDeduction())); + cellList.add(NumberUtil.isNumber(dto.getDeductionAllowedDonation()) ? new BigDecimal(dto.getDeductionAllowedDonation()) : Util.null2String(dto.getDeductionAllowedDonation())); + cellList.add(NumberUtil.isNumber(dto.getPrivatePension()) ? new BigDecimal(dto.getPrivatePension()) : Util.null2String(dto.getPrivatePension())); + return cellList; + }).collect(Collectors.toList())) + .orElse(Collections.emptyList()); + + List> rowList = new ArrayList<>(); + rowList.add(title); + rowList.addAll(dataRowList); + return rowList; + } + + + @Override + public List getOtherDeductionList(YearMonth declareMonth, List employeeIds, List taxAgentIds) { + if (declareMonth == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100342, "参数有误:申报月份必传")); + } + OtherDeductionBiz OtherDeductionBiz = new OtherDeductionBiz(); + return OtherDeductionBiz.listSome(OtherDeductionPO.builder().declareMonth(SalaryDateUtil.toDateStartOfMonth(declareMonth)).employeeIds(employeeIds).taxAgentIds(taxAgentIds).build()); + } + + @Override + public void editData(OtherDeductionParam otherDeductionParam) { + String declareMonthStr = otherDeductionParam.getDeclareMonth(); + OtherDeductionBiz OtherDeductionBiz = new OtherDeductionBiz(); + + // 获取所有个税扣缴义务人 + TaxAgentQueryParam param = TaxAgentQueryParam.builder().build(); + param.setFilterType(AuthFilterTypeEnum.ADMIN_DATA); + Collection taxAgentList = getTaxAgentService(user).listAuth(param); + OtherDeductionPO byId = OtherDeductionBiz.getById(otherDeductionParam.getId()); + if (byId == null) { + throw new SalaryRunTimeException("该数据不存在!"); + } + Long taxAgentId = byId.getTaxAgentId(); + boolean canEdit = taxAgentList.stream().anyMatch(t -> Objects.equals(t.getId(), taxAgentId)); + if (!canEdit) { + //没有编辑权限 + throw new SalaryRunTimeException("该个税扣缴义务人无权限编辑此数据!"); + } + // 获取已经核算的数据 + List salaryAcctEmployees = getAddUpDeductionService(user).getAccountedEmployeeDataByTaxYearMonth(declareMonthStr); + // 判断是否有核算过 + if (CollectionUtils.isNotEmpty(salaryAcctEmployees)) { + Optional optionalAcctEmp = salaryAcctEmployees.stream().filter(f -> f.getEmployeeId().equals(otherDeductionParam.getEmployeeId()) && f.getTaxAgentId().equals(otherDeductionParam.getTaxAgentId())).findFirst(); + if (optionalAcctEmp.isPresent()) { + throw new SalaryRunTimeException("该年月这条数据已经核算过,不可进行编辑!"); + } + } + ArrayList updateList = new ArrayList<>(); + OtherDeductionPO build = OtherDeductionPO.builder() + .id(otherDeductionParam.getId()) + .businessHealthyInsurance(otherDeductionParam.getBusinessHealthyInsurance()) + .taxDelayEndowmentInsurance(otherDeductionParam.getTaxDelayEndowmentInsurance()) + .otherDeduction(otherDeductionParam.getOtherDeduction()) + .deductionAllowedDonation(otherDeductionParam.getDeductionAllowedDonation()) + .privatePension(otherDeductionParam.getPrivatePension()) + .updateTime(new Date()) + .build(); + updateList.add(build); + OtherDeductionBiz.batchUpdate(updateList); + + // 记录日志 + OtherDeductionPO newValue = OtherDeductionBiz.getById(build.getId()); + String name = SalaryI18nUtil.getI18nLabel(0, "编辑"); + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setTargetId(newValue.getId().toString()); + loggerContext.setTargetName(SalaryI18nUtil.getI18nLabel(0, "其他免税扣除") + "-" + newValue.getId()); + loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue()); + loggerContext.setOperateTypeName(name); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "其他免税扣除") + "-" + SalaryI18nUtil + .getI18nLabel(0, "编辑")); + loggerContext.setOldValues(byId); + loggerContext.setNewValues(newValue); + loggerContext.setUser(user); + SalaryElogConfig.otherDeductionLoggerTemplate.write(loggerContext); + } + + @Override + public void createData(OtherDeductionParam otherDeductionParam) { + long currentEmployeeId = user.getUID(); + //查询对于人员信息导入筛选的全局配置 + SalarySysConfPO salarySysConfPO = getSalarySysConfMapper().getOneByCode("matchEmployeeMode"); + String confValue = (salarySysConfPO != null && salarySysConfPO.getConfValue() != null && !"".equals(salarySysConfPO.getConfValue())) ? salarySysConfPO.getConfValue() : "0"; + + //税款所属期 + String declareMonthStr = Util.null2String(otherDeductionParam.getDeclareMonth()); + //人员信息 + List employees = getSalaryEmployeeService(user).listEmployee(); + // 获取所有个税扣缴义务人 + TaxAgentQueryParam param = TaxAgentQueryParam.builder().build(); + param.setFilterType(AuthFilterTypeEnum.ADMIN_DATA); + Collection taxAgentList = getTaxAgentService(user).listAuth(param); + //税款所属期 + Date declareMonth = SalaryDateUtil.stringToDate(declareMonthStr + "-01"); + // 获取已经核算的数据 + List salaryAcctEmployees = getAddUpDeductionService(user).getAccountedEmployeeDataByTaxYearMonth(declareMonthStr); + // 查询已有数据 + List list = getOtherDeductionMapper().listSome(OtherDeductionPO.builder().declareMonth(declareMonth).build()); + //合规数据 + List insertData = new ArrayList<>(); + List taxAgentEmployees = Lists.newArrayList(); + Date now = new Date(); + //待插入数据库对象 + OtherDeductionPO po = OtherDeductionPO.builder() + .tenantKey(DEFAULT_TENANT_KEY) + .createTime(now) + .updateTime(now) + .creator((long) user.getUID()) + .declareMonth(declareMonth).build(); + + //筛选导入人员信息可以在人力资源池中匹配到的人员信息 + boolean employeeSameId = employees.stream().anyMatch(e -> Objects.equals(e.getEmployeeId(), otherDeductionParam.getEmployeeId())); + if (!employeeSameId) { + throw new SalaryRunTimeException("员工信息不存在"); + } + po.setEmployeeId(otherDeductionParam.getEmployeeId()); + String taxAgentName = otherDeductionParam.getTaxAgentName(); + if (StringUtils.isBlank(taxAgentName)) { + //个税扣缴义务人不能为空 + throw new SalaryRunTimeException("个税扣缴义务人不能为空"); + } else { + Optional optionalTemp = taxAgentList.stream().filter(m -> m.getName().equals(taxAgentName)).findFirst(); + if (optionalTemp.isPresent()) { + po.setTaxAgentId(optionalTemp.get().getId()); + } else { + //个税扣缴义务人不存在或不在权限范围内 + throw new SalaryRunTimeException("个税扣缴义务人不存在或不在权限范围内"); + } + } + + //商业健康保险 + String businessHealthyInsurance = otherDeductionParam.getBusinessHealthyInsurance(); + po.setBusinessHealthyInsurance(businessHealthyInsurance); + //税延养老保险 + String taxDelayEndowmentInsurance = otherDeductionParam.getTaxDelayEndowmentInsurance(); + po.setTaxDelayEndowmentInsurance(taxDelayEndowmentInsurance); + //其他 + String otherDeduction = otherDeductionParam.getOtherDeduction(); + po.setOtherDeduction(otherDeduction); + //准予扣除的捐赠额 + String deductionAllowedDonation = otherDeductionParam.getDeductionAllowedDonation(); + po.setDeductionAllowedDonation(deductionAllowedDonation); + //个人养老金 + String privatePension = otherDeductionParam.getPrivatePension(); + po.setPrivatePension(privatePension); + + + // 判断是否有核算过 + if (CollectionUtils.isNotEmpty(salaryAcctEmployees)) { + OtherDeductionPO finalPo = po; + Optional optionalAcctEmp = salaryAcctEmployees.stream().filter(f -> f.getEmployeeId().equals(finalPo.getEmployeeId()) && f.getTaxAgentId().equals(finalPo.getTaxAgentId())).findFirst(); + boolean isExist = list.stream().anyMatch(f -> f.getEmployeeId().equals(finalPo.getEmployeeId()) && f.getTaxAgentId().equals(finalPo.getTaxAgentId())); + if (optionalAcctEmp.isPresent() && isExist) { + throw new SalaryRunTimeException("该年月这条数据已经核算过,不可导入"); + } + } + insertData.add(po); + //入库 + handleImportData(insertData); + } + + @Override + public void deleteSelectData(AddUpDeductionRecordDeleteParam deleteParam) { + // 获取所有个税扣缴义务人 + TaxAgentQueryParam param = TaxAgentQueryParam.builder().build(); + param.setFilterType(AuthFilterTypeEnum.ADMIN_DATA); + Collection taxAgentList = getTaxAgentService(user).listAuth(param); + OtherDeductionBiz otherDeductionBiz = new OtherDeductionBiz(); + String declareMonthStr = deleteParam.getDeclareMonth(); + List deleteIds = deleteParam.getIds(); + // 已经核算过的不可操作 + // 获取已经核算的数据 + List salaryAcctEmployees = getAddUpDeductionService(user).getAccountedEmployeeDataByTaxYearMonth(declareMonthStr); + // 判断是否有核算过 + List deleteList = new ArrayList<>(); + List resultList = new ArrayList<>(); + for (int i = 0; i < deleteIds.size(); i++) { + Long id = deleteIds.get(i); + OtherDeductionPO byId = otherDeductionBiz.getById(id); + if (byId == null) { + throw new SalaryRunTimeException("数据不存在或已被删除!"); + } + // 判断是否在个税扣缴义务人范围内 + Optional first = taxAgentList.stream().filter(m -> Objects.equals(m.getId(), byId.getTaxAgentId())).findFirst(); + if (!first.isPresent()) { + throw new SalaryRunTimeException("个税扣缴义务人不存在或不在权限范围内"); + } + // 判断用户是否存在 + if (CollectionUtils.isNotEmpty(salaryAcctEmployees)) { + Optional optionalAcctEmp = salaryAcctEmployees.stream().filter(f -> f.getEmployeeId().equals(byId.getEmployeeId()) && f.getTaxAgentId().equals(byId.getTaxAgentId())).findFirst(); + if (optionalAcctEmp.isPresent()) { + throw new SalaryRunTimeException("所选数据在该年月中已经核算过并归档,不可进行删除!"); + } + } + deleteList.add(byId.getId()); + resultList.add(byId); + } + otherDeductionBiz.batchDeleteByIDS(deleteList); + // 记录日志 + resultList.stream().forEach(r -> { + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setTargetId(r.getId().toString()); + loggerContext.setTargetName(SalaryI18nUtil.getI18nLabel(0, "其他免税扣除") + "-" + r.getId()); + loggerContext.setOperateType(OperateTypeEnum.DELETE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "删除")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "其他免税扣除") + "-" + SalaryI18nUtil + .getI18nLabel(0, "删除")); + loggerContext.setOldValues(r); + loggerContext.setUser(user); + SalaryElogConfig.otherDeductionLoggerTemplate.write(loggerContext); + }); + } + + @Override + public void deleteAllData(AddUpDeductionRecordDeleteParam deleteParam) { + String declareMonthStr = deleteParam.getDeclareMonth(); + long currentEmployeeId = user.getUID(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + // 获取所有个税扣缴义务人 + TaxAgentQueryParam param = TaxAgentQueryParam.builder().build(); + param.setFilterType(AuthFilterTypeEnum.ADMIN_DATA); + Collection taxAgentList = getTaxAgentService(user).listAuth(param); + List taxAgentIds = taxAgentList.stream().map(TaxAgentPO::getId).collect(Collectors.toList()); + OtherDeductionBiz otherDeductionBiz = new OtherDeductionBiz(); + Date declareMonthDate = null; + try { + declareMonthDate = sdf.parse(declareMonthStr + "-01"); + } catch (Exception e) { + throw new SalaryRunTimeException("日期异常"); + } + + OtherDeductionPO queryParam = null; + if (deleteParam.getTaxAgentId() != null && (!deleteParam.getTaxAgentId().equals(""))) { + // 设置了个税扣缴义务人 + Long taxAgentId = SalaryEntityUtil.string2Long(deleteParam.getTaxAgentId()); + boolean canDelete = taxAgentIds.stream().anyMatch(t -> Objects.equals(t, taxAgentId)); + if (!canDelete) { + throw new SalaryRunTimeException("个税扣缴义务人不存在或不在权限范围内!"); + } + ArrayList tai = new ArrayList<>(); + tai.add(taxAgentId); + queryParam = OtherDeductionPO.builder().declareMonth(declareMonthDate).taxAgentIds(tai).build(); + } else { + queryParam = OtherDeductionPO.builder().declareMonth(declareMonthDate).taxAgentIds(taxAgentIds).build(); + } + // 获取所有想要删除的数据 + List list = otherDeductionBiz.listSome(queryParam); + list = getAuthService(user).auth(list, AuthFilterTypeEnum.ADMIN_DATA, OtherDeductionPO.class); + // 获取已经核算的数据 + List salaryAcctEmployees = getAddUpDeductionService(user).getAccountedEmployeeDataByTaxYearMonth(declareMonthStr); + for (OtherDeductionPO item : list) { + if (CollectionUtils.isNotEmpty(salaryAcctEmployees)) { + Optional optionalAcctEmp = salaryAcctEmployees.stream().filter(f -> f.getEmployeeId().equals(item.getEmployeeId()) && f.getTaxAgentId().equals(item.getTaxAgentId())).findFirst(); + if (optionalAcctEmp.isPresent()) { + throw new SalaryRunTimeException("有员工在该年月中已经完成核算并归档,不能进行一键清空!"); + } + } + } + List deleteIds = list.stream().map(OtherDeductionPO::getId).collect(Collectors.toList()); + otherDeductionBiz.batchDeleteByIDS(deleteIds); + + // 记录日志 + Collection finalTaxAgentIds = queryParam.getTaxAgentIds(); + List taxAgentNames = taxAgentList.stream().filter(t -> finalTaxAgentIds.contains(t.getId())) + .map(TaxAgentPO::getName).collect(Collectors.toList()); + String name = declareMonthStr + " " + StringUtils.join(taxAgentNames, ","); + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setTargetName(name); + loggerContext.setOperateType(OperateTypeEnum.CLEAR.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "一键清空")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "其他免税扣除") + "-" + SalaryI18nUtil + .getI18nLabel(0, "一键清空:") + name); + loggerContext.setUser(user); + SalaryElogConfig.otherDeductionLoggerTemplate.write(loggerContext); + } + + @Override + public OtherDeductionRecordDTO getOtherDeduction(OtherDeductionParam otherDeductionParam) { + ArrayList ids = new ArrayList<>(); + ids.add(otherDeductionParam.getId()); + OtherDeductionQueryParam build = OtherDeductionQueryParam.builder().ids(ids).build(); + List list = getOtherDeductionMapper().recordList(build); + encryptUtil.decryptList(list, OtherDeductionRecordDTO.class); + + if (list == null || list.size() == 0) { + throw new SalaryRunTimeException("该数据不存在!"); + } + return list.get(0); + } + + @Override + public String extendToLastMonth(OtherDeductionExtendLastParam param) { + //查询已经核算的数据 + List salaryAcctEmployees = getAddUpDeductionService(user).getAccountedEmployeeDataByTaxYearMonth(param.getDeclareMonth()); + Map> acctInfoMap = salaryAcctEmployees.stream() + .distinct().collect(Collectors.groupingBy( + i -> i.getTaxAgentId() + "" + i.getEmployeeId())); + + // 查找到所有个税扣缴义务人 + TaxAgentQueryParam taxAgentQueryParam = TaxAgentQueryParam.builder().build(); + taxAgentQueryParam.setFilterType(AuthFilterTypeEnum.ADMIN_DATA); + Collection taxAgentPOS = getTaxAgentService(user).listAuth(taxAgentQueryParam); + List taxAgentIds = taxAgentPOS.stream().map(TaxAgentPO::getId).collect(Collectors.toList()); + + //查询上月数据 + LocalDateTime lastMonth = param.getYearMonthTime().minusMonths(1); + OtherDeductionQueryParam queryParam = OtherDeductionQueryParam.builder() + .taxAgentIds(taxAgentIds) + .declareMonthDate(Collections.singletonList( + SalaryDateUtil.toDate(lastMonth)) + ).build(); + List lastMonthInfo = getOtherDeductionMapper().list(queryParam); + + // 查询当前月id + queryParam.setDeclareMonthDate(Collections.singletonList( + SalaryDateUtil.toDate(param.getYearMonthTime()) + )); + Map updateIdMap = getOtherDeductionMapper() + .list(queryParam).stream() + .collect(Collectors.toMap(i -> i.getEmployeeId() + "" + i.getTaxAgentId(), OtherDeductionListDTO::getId)); + + List insertInfo = new ArrayList<>(); + List updatetInfo = new ArrayList<>(); + for (OtherDeductionListDTO dto : lastMonthInfo) { + OtherDeductionPO po + = JSONObject.parseObject(JSONObject.toJSONString(dto), OtherDeductionPO.class); + po.setDeclareMonth(SalaryDateUtil.toDate(param.getYearMonthTime())); + po.setUpdateTime(new Date()); + po.setId(null); + po.setTenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY); + boolean hasOld = updateIdMap.containsKey(po.getEmployeeId() + "" + po.getTaxAgentId()); + if (hasOld && !acctInfoMap.containsKey(po.getTaxAgentId() + "" + po.getEmployeeId())) { + //核算过的数据直接跳过不做更改 + po.setId(updateIdMap.get(po.getEmployeeId() + "" + po.getTaxAgentId())); + updatetInfo.add(po); + } else if (!hasOld) { + po.setCreator((long) user.getUID()); + po.setCreateTime(new Date()); + insertInfo.add(po); + } + } + + getOtherDeductionBiz().batchSave(insertInfo); + getOtherDeductionBiz().batchUpdate(updatetInfo); + + //记录日志 + // 根据月份、人员id查出保存的数据 + List empIds = insertInfo.stream().map(OtherDeductionPO::getEmployeeId).collect(Collectors.toList()); + List insertList = getOtherDeductionBiz().listSome(OtherDeductionPO.builder().declareMonth(SalaryDateUtil.stringToDate(param.getDeclareMonth())).employeeIds(empIds).build()); + Map insertMap = SalaryEntityUtil.convert2Map(insertList, p -> p.getTaxAgentId() + "-" + SalaryDateUtil.getFormatYearMonth(p.getDeclareMonth()) + "-" + p.getEmployeeId()); + insertList.forEach(save -> { + OtherDeductionPO otherDeductionPO = insertMap.get(save.getTaxAgentId() + "-" + SalaryDateUtil.getFormatYearMonth(save.getDeclareMonth()) + "-" + save.getEmployeeId()); + if (otherDeductionPO != null) { + updatetInfo.add(otherDeductionPO); + } + }); + + if (CollectionUtils.isNotEmpty(updatetInfo)) { + String yearMonthStr = SalaryDateUtil.getFormatYearMonth(lastMonth.toLocalDate()); + LoggerContext loggerContext = new LoggerContext(); + loggerContext.setUser(user); + loggerContext.setTargetName(SalaryI18nUtil.getI18nLabel(0, "沿用上月 " + yearMonthStr)); + loggerContext.setOperateType(OperateTypeEnum.ADD.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "沿用上月其他免税扣除")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "沿用上月 " + yearMonthStr + " 其他免税扣除")); + loggerContext.setNewValueList(updatetInfo); + SalaryElogConfig.otherDeductionLoggerTemplate.write(loggerContext); + } + + return ""; + } + + @Override + public List listAuth(OtherDeductionQueryParam queryParam) { + List list = getOtherDeductionMapper().list(queryParam); + list = getAuthService(user).auth(list, queryParam.getFilterType(), OtherDeductionListDTO.class); + return list; + } + + @Override + public XSSFWorkbook downloadTemplate(OtherDeductionQueryParam param) { + // 1.工作簿名称 + String sheetName = SalaryI18nUtil.getI18nLabel(101604, "其他免税扣除导入模板"); + //获取操作按钮资源 + List> rowList = getExcelRowList(param, param.isHasData()); + + // 4.注释 + List excelComments = Lists.newArrayList(); + excelComments.add(new ExcelComment(0, 0, 3, 2, SalaryI18nUtil.getI18nLabel(100344, "必填"))); + excelComments.add(new ExcelComment(1, 0, 4, 2, SalaryI18nUtil.getI18nLabel(100344, "必填"))); + excelComments.add(new ExcelComment(7, 0, 10, 2, SalaryI18nUtil.getI18nLabel(100344, "输入数字"))); + excelComments.add(new ExcelComment(8, 0, 11, 2, SalaryI18nUtil.getI18nLabel(100344, "输入数字"))); + excelComments.add(new ExcelComment(9, 0, 12, 2, SalaryI18nUtil.getI18nLabel(100344, "输入数字"))); + excelComments.add(new ExcelComment(10, 0, 13, 2, SalaryI18nUtil.getI18nLabel(100344, "输入数字"))); + excelComments.add(new ExcelComment(11, 0, 14, 2, SalaryI18nUtil.getI18nLabel(100344, "输入数字"))); + + XSSFWorkbook book = ExcelUtil.genWorkbookV2(rowList, sheetName, excelComments); + return book; + } + +} diff --git a/src/com/engine/salary/service/impl/ProgressServiceImpl.java b/src/com/engine/salary/service/impl/ProgressServiceImpl.java new file mode 100644 index 000000000..f855c50be --- /dev/null +++ b/src/com/engine/salary/service/impl/ProgressServiceImpl.java @@ -0,0 +1,145 @@ +package com.engine.salary.service.impl; + +import com.cloudstore.dev.api.util.Util_DataCache; +import com.engine.core.impl.Service; +import com.engine.salary.entity.progress.ProgressDTO; +import com.engine.salary.service.ProgressService; +import com.engine.salary.util.JsonUtil; +import org.apache.commons.lang3.StringUtils; +import weaver.wechat.util.Utils; + +import java.math.BigDecimal; +import java.math.RoundingMode; + +/** + * 进度条 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class ProgressServiceImpl extends Service implements ProgressService { + + + @Override + public void initProgress(String cacheKey, ProgressDTO progressDTO) { + Util_DataCache.setObjVal(cacheKey, JsonUtil.toJsonString(progressDTO)); + } + + @Override + public synchronized void getAndAddCalculatedQty(String cacheKey, Integer calculatedQuantity) { + String resultStr = (String) Util_DataCache.getObjVal(cacheKey); + if (StringUtils.isNotEmpty(resultStr)) { + ProgressDTO progressDTO = JsonUtil.parseObject(resultStr, ProgressDTO.class); + if (progressDTO == null || !progressDTO.isStatus()) { + return; + } + Integer currentCalculatedQuantity = progressDTO.getCalculatedQuantity() + calculatedQuantity; + progressDTO.setCalculatedQuantity( + currentCalculatedQuantity > progressDTO.getTotalQuantity() ? progressDTO.getTotalQuantity() : currentCalculatedQuantity); + BigDecimal progress = BigDecimal.valueOf(progressDTO.getCalculatedQuantity()) + .divide(BigDecimal.valueOf(progressDTO.getTotalQuantity()), 4, RoundingMode.HALF_DOWN); + progressDTO.setProgress(progress.compareTo(BigDecimal.ONE) > 0 ? BigDecimal.ONE : progress); + Util_DataCache.setObjVal(cacheKey, JsonUtil.toJsonString(progressDTO)); + } + } + + @Override + public synchronized void getAndAddCalculatedQty(String cacheKey, Integer calculatedQuantity, String message) { + String resultStr = (String) Util_DataCache.getObjVal(cacheKey); + if (StringUtils.isNotEmpty(resultStr)) { + ProgressDTO progressDTO = JsonUtil.parseObject(resultStr, ProgressDTO.class); + if (progressDTO == null || !progressDTO.isStatus()) { + return; + } + Integer currentCalculatedQuantity = progressDTO.getCalculatedQuantity() + calculatedQuantity; + progressDTO.setCalculatedQuantity( + currentCalculatedQuantity > progressDTO.getTotalQuantity() ? progressDTO.getTotalQuantity() : currentCalculatedQuantity); + BigDecimal progress = BigDecimal.valueOf(progressDTO.getCalculatedQuantity()) + .divide(BigDecimal.valueOf(progressDTO.getTotalQuantity()), 4, RoundingMode.HALF_DOWN); + progressDTO.setProgress(progress.compareTo(BigDecimal.ONE) > 0 ? BigDecimal.ONE : progress); + + if (StringUtils.isNotBlank(message)) { + progressDTO.setMessage(Utils.null2String(progressDTO.getMessage()) + message); + } + Util_DataCache.setObjVal(cacheKey, JsonUtil.toJsonString(progressDTO)); + } + } + + @Override + public void fail(String cacheKey, String message) { + ProgressDTO progressDTO = new ProgressDTO(); + progressDTO.setStatus(false); + progressDTO.setMessage(message); + progressDTO.setCheckStatus(true); + Util_DataCache.setObjVal(cacheKey, JsonUtil.toJsonString(progressDTO)); + } + + @Override + public void finish(String cacheKey, boolean checkStatus) { + String resultStr = (String) Util_DataCache.getObjVal(cacheKey); + if (StringUtils.isNotEmpty(resultStr)) { + ProgressDTO progressDTO = JsonUtil.parseObject(resultStr, ProgressDTO.class); + if (progressDTO == null || !progressDTO.isStatus()) { + return; + } + progressDTO.setTitle("操作完成"); + progressDTO.setCalculatedQuantity(progressDTO.getTotalQuantity()); + progressDTO.setProgress(BigDecimal.ONE); + progressDTO.setCheckStatus(checkStatus); + Util_DataCache.setObjVal(cacheKey, JsonUtil.toJsonString(progressDTO)); + } + } + + @Override + public void finish(String cacheKey, boolean checkStatus, String message) { + String resultStr = (String) Util_DataCache.getObjVal(cacheKey); + if (StringUtils.isNotEmpty(resultStr)) { + ProgressDTO progressDTO = JsonUtil.parseObject(resultStr, ProgressDTO.class); + if (progressDTO == null || !progressDTO.isStatus()) { + return; + } + progressDTO.setTitle("操作完成"); + progressDTO.setCalculatedQuantity(progressDTO.getTotalQuantity()); + progressDTO.setProgress(BigDecimal.ONE); + progressDTO.setCheckStatus(checkStatus); + progressDTO.setMessage(message); + Util_DataCache.setObjVal(cacheKey, JsonUtil.toJsonString(progressDTO)); + } + } + + @Override + public void updateProgress(String cacheKey, BigDecimal progress, boolean checkStatus) { + String resultStr = (String) Util_DataCache.getObjVal(cacheKey); + if (StringUtils.isNotEmpty(resultStr)) { + ProgressDTO progressDTO = JsonUtil.parseObject(resultStr, ProgressDTO.class); + if (progressDTO == null || !progressDTO.isStatus()) { + return; + } + progressDTO.setTitle("处理中"); + progressDTO.setCalculatedQuantity(progressDTO.getTotalQuantity()); + progressDTO.setProgress(progress); + progressDTO.setCheckStatus(checkStatus); + Util_DataCache.setObjVal(cacheKey, JsonUtil.toJsonString(progressDTO)); + } + } + + @Override + public ProgressDTO getProgress(String cacheKey) { + String resultStr = (String) Util_DataCache.getObjVal(cacheKey); + if (StringUtils.isEmpty(resultStr)) { + return null; + } + return JsonUtil.parseObject(resultStr, ProgressDTO.class); + } + + @Override + public ProgressDTO del(String cacheKey) { + Util_DataCache.clearVal(cacheKey); + ProgressDTO salaryAcctProgressDTO = new ProgressDTO(); + salaryAcctProgressDTO.setMessage("操作失败"); + salaryAcctProgressDTO.setStatus(false); + return salaryAcctProgressDTO; + } +} diff --git a/src/com/engine/salary/service/impl/PushServiceImpl.java b/src/com/engine/salary/service/impl/PushServiceImpl.java new file mode 100644 index 000000000..cf01efde8 --- /dev/null +++ b/src/com/engine/salary/service/impl/PushServiceImpl.java @@ -0,0 +1,564 @@ +package com.engine.salary.service.impl; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.StrUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.constant.SalaryDefaultTenantConstant; +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.push.dto.PushRecordDTO; +import com.engine.salary.entity.push.dto.PushRecordDetailDTO; +import com.engine.salary.entity.push.dto.PushSettingDTO; +import com.engine.salary.entity.push.dto.PushSettingItemDTO; +import com.engine.salary.entity.push.param.*; +import com.engine.salary.entity.push.po.PushRecordDetailPO; +import com.engine.salary.entity.push.po.PushRecordPO; +import com.engine.salary.entity.push.po.PushSettingItemPO; +import com.engine.salary.entity.push.po.PushSettingPO; +import com.engine.salary.entity.salaryacct.bo.CalculateFormulaVarBO; +import com.engine.salary.entity.salaryacct.bo.SalaryAcctCalculateBO; +import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO; +import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO; +import com.engine.salary.entity.salaryacct.po.SalaryAcctResultPO; +import com.engine.salary.entity.salaryitem.po.SalaryItemPO; +import com.engine.salary.entity.salarysob.dto.SalarySobCycleDTO; +import com.engine.salary.entity.salarysob.po.SalarySobPO; +import com.engine.salary.enums.push.PushItemFieldEnum; +import com.engine.salary.enums.push.PushRecordDetailStatusEnum; +import com.engine.salary.enums.push.PushRecordStatusEnum; +import com.engine.salary.enums.push.PushRecordTypeEnum; +import com.engine.salary.enums.salaryformula.SalarySQLReferenceEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.mapper.push.PushRecordDetailMapper; +import com.engine.salary.mapper.push.PushRecordMapper; +import com.engine.salary.mapper.push.PushSettingItemMapper; +import com.engine.salary.mapper.push.PushSettingMapper; +import com.engine.salary.service.*; +import com.engine.salary.sys.enums.TaxDeclarationFunctionEnum; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.db.IdGenerator; +import com.engine.salary.util.db.MapperProxyFactory; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.util.page.SalaryPageUtil; +import com.engine.salary.util.valid.ValidUtil; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.math.NumberUtils; +import weaver.conn.RecordSet; +import weaver.formmode.setup.ModeRightInfo; +import weaver.general.TimeUtil; +import weaver.hrm.User; + +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.stream.Collectors; + +/** + * 推送服务 + *

Copyright: Copyright (c) 2024

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Slf4j +public class PushServiceImpl extends Service implements PushService { + + private PushSettingMapper getPushSettingMapper() { + return MapperProxyFactory.getProxy(PushSettingMapper.class); + } + + private PushSettingItemMapper getPushSettingItemMapper() { + return MapperProxyFactory.getProxy(PushSettingItemMapper.class); + } + + private PushRecordMapper getPushRecordMapper() { + return MapperProxyFactory.getProxy(PushRecordMapper.class); + } + + private PushRecordDetailMapper getPushRecordDetailMapper() { + return MapperProxyFactory.getProxy(PushRecordDetailMapper.class); + } + + private SalaryEmployeeService getSalaryEmployeeService(User user) { + return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user); + } + + private SalaryItemService getSalaryItemService(User user) { + return ServiceUtil.getService(SalaryItemServiceImpl.class, user); + } + + private SalaryAcctRecordService getSalaryAcctRecordService(User user) { + return ServiceUtil.getService(SalaryAcctRecordServiceImpl.class, user); + } + + private SalarySobService getSalarySobService(User user) { + return ServiceUtil.getService(SalarySobServiceImpl.class, user); + } + + private SalaryAcctEmployeeService getSalaryAcctEmployeeService(User user) { + return ServiceUtil.getService(SalaryAcctEmployeeServiceImpl.class, user); + } + + private SalaryAcctResultService getSalaryAcctResultService(User user) { + return ServiceUtil.getService(SalaryAcctResultServiceImpl.class, user); + } + + @Override + public PageInfo settingList(PushSettingQueryParam param) { + List pushSettingPOS = getPushSettingMapper().listAll(); + + List salarySobPOS = getSalarySobService(user).listAll(); + Map sobPOMap = SalaryEntityUtil.convert2Map(salarySobPOS, SalarySobPO::getId); + + List list = pushSettingPOS.stream() + .filter(po -> StrUtil.isBlank(param.getName()) || po.getName().contains(param.getName())).map( + po -> PushSettingDTO.builder() + .id(po.getId()) + .name(po.getName()) + .tableName(po.getTableName()) + .modeName(po.getModeName()) + .modeId(po.getModeId()) + .able(po.getAble()) + .salarySobs(po.getSalarySobIds().stream().map(sobPOMap::get).collect(Collectors.toList())) + .build()).collect(Collectors.toList()); + return SalaryPageUtil.buildPage(param.getCurrent(), param.getPageSize(), list, PushSettingDTO.class); + } + + @Override + public PushSettingPO save(PushSettingSaveParam param) { + ValidUtil.doValidator(param); + + Date now = new Date(); + + Long id = param.getId(); + PushSettingPO po; + if (id == null) { + po = PushSettingPO.builder() + .id(IdGenerator.generate()) + .able(param.getAble()) + .name(param.getName()) + .salarySobIds(param.getSalarySobIds()) + .modeId(param.getModeId()) + .modeName(param.getModeName()) + .tableName(param.getTableName()) + .creator((long) user.getUID()) + .createTime(now) + .updateTime(now) + .deleteType(0) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .build(); + + getPushSettingMapper().insertIgnoreNull(po); + + } else { + po = getPushSettingMapper().getById(id); + if (po == null) { + throw new SalaryRunTimeException("推送配置不存在!"); + } + po.setAble(param.getAble()); + po.setAble(param.getAble()); + po.setName(param.getName()); + po.setSalarySobIds(param.getSalarySobIds()); + po.setModeId(param.getModeId()); + po.setModeName(param.getModeName()); + po.setTableName(param.getTableName()); + po.setUpdateTime(now); + + getPushSettingMapper().update(po); + } + + return po; + } + + @Override + public void delete(Long id) { + getPushSettingMapper().delete(PushSettingPO.builder().id(id).build()); + getPushSettingItemMapper().delete(PushSettingItemPO.builder().settingId(id).build()); + } + + @Override + public PageInfo itemList(PushSettingItemQueryParam param) { + List pushSettingItemPOS = getPushSettingItemMapper().listSome(PushSettingItemPO.builder().settingId(param.getSettingId()).build()); + + List list = pushSettingItemPOS.stream().map(po -> PushSettingItemDTO.builder() + .id(po.getId()) + .settingId(po.getSettingId()) + .item(po.getItem()) + .itemName(po.getItemName()) + .source(po.getSource()) + .sourceName(SalarySQLReferenceEnum.parseByValue(po.getSource()).getDefaultLabel()) + .fieldName(po.getFieldName()) + .fieldType(PushItemFieldEnum.parseByValue(po.getFieldType())) + .fieldTypeName(PushItemFieldEnum.parseByValue(po.getFieldType()).getDefaultLabel()) + .sortedIndex(po.getSortedIndex()) + .build() + ).collect(Collectors.toList()); + + return new PageInfo<>(list, PushSettingItemDTO.class); + } + + @Override + public PushSettingItemPO saveItem(PushSettingItemSaveParam param) { + ValidUtil.doValidator(param); + Date now = new Date(); + Long id = param.getId(); + PushSettingItemPO po; + if (id == null) { + po = PushSettingItemPO.builder() + .id(IdGenerator.generate()) + .settingId(param.getSettingId()) + .item(param.getItem()) + .itemName(param.getItemName()) + .source(param.getSource()) + .fieldName(param.getFieldName()) + .fieldType(param.getFieldType().getValue()) + .sortedIndex(param.getSortedIndex()) + .creator((long) user.getUID()) + .createTime(now) + .updateTime(now) + .deleteType(0) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .build(); + + getPushSettingItemMapper().insertIgnoreNull(po); + + } else { + po = getPushSettingItemMapper().getById(id); + if (po == null) { + throw new SalaryRunTimeException("推送配置明细不存在!"); + } + po.setSettingId(param.getSettingId()); + po.setItem(param.getItem()); + po.setItemName(param.getItemName()); + po.setSource(param.getSource()); + po.setFieldName(param.getFieldName()); + po.setFieldType(param.getFieldType().getValue()); + po.setSortedIndex(param.getSortedIndex()); + po.setUpdateTime(now); + + getPushSettingItemMapper().update(po); + + } + + return po; + } + + @Override + public void deleteItem(Long id) { + getPushSettingItemMapper().delete(PushSettingItemPO.builder().id(id).build()); + } + + @Override + public void createPushRecord(Long salaryAcctRecordId) { + Date now = new Date(); + SalaryAcctRecordPO salaryAcctRecordPO = getSalaryAcctRecordService(user).getById(salaryAcctRecordId); + + if (salaryAcctRecordPO == null) { + throw new SalaryRunTimeException("核算记录不存在!"); + } + + //查询推送配置 + List pushSettingPOS = getPushSettingMapper().listSome(PushSettingPO.builder().able(1).build()); + if (CollUtil.isEmpty(pushSettingPOS)) { + return; + } + + //查询核算人员 + List salaryAcctEmployeePOS = getSalaryAcctEmployeeService(user).listBySalaryAcctRecordId(salaryAcctRecordPO.getId()); + + //薪资项目 + List salaryItemPOS = getSalaryItemService(user).listAll(); + //查询薪资核算记录的薪资周期、考勤周期等 + SalarySobCycleDTO salarySobCycleDTO = getSalaryAcctRecordService(user).getSalarySobCycleById(salaryAcctRecordPO.getId()); + + SalaryAcctCalculateBO salaryAcctCalculateBO = new SalaryAcctCalculateBO() + .setSalaryAcctRecordPO(salaryAcctRecordPO) + .setSalarySobPO(new SalarySobPO()) + .setSalarySobCycleDTO(salarySobCycleDTO) + .setOtherSalaryAcctRecordPOS(new ArrayList<>()) + .setSalarySobItemPOS(new ArrayList<>()) + .setSalaryItemIdWithPriorityList(new ArrayList<>()) + .setExpressFormulas(new ArrayList<>()) + .setSalaryItemPOS(salaryItemPOS) + .setSalarySobAdjustRulePOS(new ArrayList<>()) + .setWelfareColumns(new HashMap<>()) + .setAttendQuoteFieldListDTOS(new ArrayList<>()) + .setSalaryAcctEmployeePOS(salaryAcctEmployeePOS) + .setIssuedFieldIds(new HashSet<>()) + .setChildMonitor(null) + .setResults(null) + .setCalculateKey(null) + .setVariableItems(new ArrayList<>()) + .setTaxDeclarationFunction(TaxDeclarationFunctionEnum.OPEN); + + + List employeeIds = SalaryEntityUtil.properties(salaryAcctCalculateBO.getSalaryAcctEmployeePOS(), SalaryAcctEmployeePO::getEmployeeId, Collectors.toList()); + List simpleEmployees = getSalaryEmployeeService(user).getEmployeeByIdsAll(employeeIds); + + List salaryAcctEmployeeIds = SalaryEntityUtil.properties(salaryAcctCalculateBO.getSalaryAcctEmployeePOS(), SalaryAcctEmployeePO::getId, Collectors.toList()); + List salaryAcctResultPOS = getSalaryAcctResultService(user).listBySalaryAcctEmployeeIds(salaryAcctEmployeeIds); + + CalculateFormulaVarBO calculateFormulaVarBO = new CalculateFormulaVarBO(simpleEmployees, new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), salaryAcctResultPOS, new ArrayList<>(), new ArrayList<>()); + Map> formulaVarMap = calculateFormulaVarBO.convert2FormulaVar(salaryAcctCalculateBO); + + //推送记录id + List recordIds = new ArrayList<>(); + + try { + pushSettingPOS.stream() + .filter(setting -> setting.getSalarySobIds().contains(salaryAcctRecordPO.getSalarySobId())) + .forEach(setting -> { + long recordId = IdGenerator.generate(); + recordIds.add(recordId); + PushRecordPO record = PushRecordPO.builder() + .id(recordId) + .name(setting.getName()) + .settingId(setting.getId()) + .modeId(setting.getModeId()) + .tableName(setting.getTableName()) + .acctRecordId(salaryAcctRecordId) + .type(PushRecordTypeEnum.PUSH.getValue()) + .status(PushRecordStatusEnum.DATA_PREPARE.getValue()) + .createTime(now) + .updateTime(now) + .creator((long) user.getUID()) + .deleteType(NumberUtils.INTEGER_ZERO) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .build(); + + getPushRecordMapper().insertIgnoreNull(record); + + Long id = setting.getId(); + List pushSettingItemPOS = getPushSettingItemMapper().listSome(PushSettingItemPO.builder().settingId(id).build()); + + //构建数据,每个人员生成一天明细 + salaryAcctEmployeePOS.forEach(emp -> { + //1 获取当前薪资核算人员的公式中的变量的值 + List formulaVarValues = formulaVarMap.get(emp.getEmployeeId() + "_" + emp.getTaxAgentId()); + //2 人员信息 + List empInfo = formulaVarMap.get(emp.getEmployeeId() + ""); + formulaVarValues.addAll(empInfo); + Map formulaVarValueMap = SalaryEntityUtil.convert2Map(formulaVarValues, CalculateFormulaVarBO.FormulaVarValue::getFieldId, CalculateFormulaVarBO.FormulaVarValue::getFieldValue); + + Integer modeId = setting.getModeId(); + + List fields = new ArrayList() {{ + add("formmodeid"); + add("modedatacreater"); + add("modedatacreatertype"); + add("modedatacreatedate"); + add("modedatacreatetime"); + }}; + String currDate = TimeUtil.getCurrentDateString(); + SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss"); + String currTime = sdf.format(new Date()); + List values = new ArrayList() {{ + add(modeId); + add(1); + add(0); + add(String.format("'%s'", currDate)); + add(String.format("'%s'", currTime)); + }}; + for (PushSettingItemPO item : pushSettingItemPOS) { + //数据库字段 + String fieldName = item.getFieldName(); + fields.add(fieldName); + // 公式变量的值 + String field = item.getItem(); + String value = formulaVarValueMap.getOrDefault(field, StringUtils.EMPTY); + PushItemFieldEnum pushItemFieldEnum = PushItemFieldEnum.parseByValue(item.getFieldType()); + values.add(pushItemFieldEnum.convertValue(value)); + } + String tableName = setting.getTableName(); + String sql = String.format("insert into %s (%s) values (%s)", tableName, String.join(",", fields), values.stream().map(Object::toString).collect(Collectors.joining(","))); + + PushRecordDetailPO pushRecordDetailPO = PushRecordDetailPO.builder() + .id(IdGenerator.generate()) + .acctEmpId(emp.getId()) + .recordId(record.getId()) + .status(PushRecordDetailStatusEnum.PREPARE.getValue()) + .formula(sql) + .createTime(now) + .updateTime(now) + .creator((long) user.getUID()) + .deleteType(NumberUtils.INTEGER_ZERO) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .build(); + getPushRecordDetailMapper().insertIgnoreNull(pushRecordDetailPO); + }); + + //数据构建完毕 + record.setUpdateTime(new Date()); + record.setStatus(PushRecordStatusEnum.DATA_FINISH.getValue()); + getPushRecordMapper().updateIgnoreNull(record); + } + ); + } catch (Exception e) { + log.error("创建推送记录失败", e); + removeRecords(recordIds); + throw new SalaryRunTimeException("创建推送记录失败"); + } + + //开始 + recordIds.forEach(this::push); + + } + + @Override + public void withdrawPushRecord(Long salaryAcctRecordId) { + List pushRecordPOS = getPushRecordMapper().listSome(PushRecordPO.builder().acctRecordId(salaryAcctRecordId).status(PushRecordStatusEnum.RUN_SUCCESS.getValue()).build()); + if (CollUtil.isEmpty(pushRecordPOS)) { + return; + } + pushRecordPOS.stream().map(PushRecordPO::getId).forEach(this::withdraw); + } + + @Override + public void push(Long id) { + //待推送 + PushRecordPO pushRecordPO = getPushRecordMapper().getById(id); + + try { + pushRecordPO.setStartTime(new Date()); + pushRecordPO.setStatus(PushRecordStatusEnum.RUN_PROGRESS.getValue()); + getPushRecordMapper().updateIgnoreNull(pushRecordPO); + + List pushRecordDetailPOS = getPushRecordDetailMapper().listSome(PushRecordDetailPO.builder().recordId(pushRecordPO.getId()).build()); + pushRecordDetailPOS.forEach(pushRecordDetailPO -> { + + try { + String formula = pushRecordDetailPO.getFormula(); + RecordSet rs = new RecordSet(); + boolean success = rs.execute(formula); + if (success) { + //建模需要权限重构 + Integer modeId = pushRecordPO.getModeId(); + if (modeId != null) { + String tableName = pushRecordPO.getTableName(); + rs.executeQuery("select max(id) from " + tableName); + int mainId = 0; + if (rs.next()) { + mainId = rs.getInt(1); + } + ModeRightInfo ModeRightInfo = new ModeRightInfo(); + ModeRightInfo.setNewRight(true); + ModeRightInfo.editModeDataShare(1, modeId, mainId); + + //记录数据id + pushRecordDetailPO.setDataId((long) mainId); + } + pushRecordDetailPO.setStatus(PushRecordDetailStatusEnum.SUCCESS.getValue()); + } else { + pushRecordDetailPO.setFailReason("sql执行失败"); + pushRecordDetailPO.setStatus(PushRecordDetailStatusEnum.FAIL.getValue()); + } + } catch (Exception e) { + pushRecordDetailPO.setFailReason(e.getMessage()); + pushRecordDetailPO.setStatus(PushRecordDetailStatusEnum.FAIL.getValue()); + } + getPushRecordDetailMapper().updateIgnoreNull(pushRecordDetailPO); + }); + + pushRecordPO.setEndTime(new Date()); + pushRecordPO.setStatus(PushRecordStatusEnum.RUN_SUCCESS.getValue()); + } catch (Exception e) { + pushRecordPO.setFailReason(e.getMessage()); + pushRecordPO.setStatus(PushRecordStatusEnum.RUN_FAIL.getValue()); + } + getPushRecordMapper().updateIgnoreNull(pushRecordPO); + } + + @Override + public void withdraw(Long id) { + //待撤回 + PushRecordPO pushRecordPO = getPushRecordMapper().getById(id); + + try { + pushRecordPO.setStartTime(new Date()); + pushRecordPO.setStatus(PushRecordStatusEnum.WITHDRAW.getValue()); + getPushRecordMapper().updateIgnoreNull(pushRecordPO); + + PushSettingPO pushSettingPO = getPushSettingMapper().getById(pushRecordPO.getSettingId()); + String tableName = pushSettingPO.getTableName(); + + List pushRecordDetailPOS = getPushRecordDetailMapper().listSome(PushRecordDetailPO.builder().recordId(pushRecordPO.getId()).build()); + pushRecordDetailPOS.forEach(pushRecordDetailPO -> { + try { + RecordSet rs = new RecordSet(); + String sql = String.format("delete from %s where id = %s", tableName, pushRecordDetailPO.getDataId()); + boolean execute = rs.execute(sql); + if (execute) { + pushRecordDetailPO.setStatus(PushRecordDetailStatusEnum.WITHDRAW_SUCCESS.getValue()); + } else { + pushRecordDetailPO.setFailReason("sql执行失败"); + pushRecordDetailPO.setStatus(PushRecordDetailStatusEnum.WITHDRAW_FAIL.getValue()); + } + } catch (Exception e) { + pushRecordDetailPO.setFailReason(e.getMessage()); + pushRecordDetailPO.setStatus(PushRecordDetailStatusEnum.WITHDRAW_FAIL.getValue()); + } + getPushRecordDetailMapper().updateIgnoreNull(pushRecordDetailPO); + }); + + pushRecordPO.setEndTime(new Date()); + pushRecordPO.setStatus(PushRecordStatusEnum.WITHDRAW_SUCCESS.getValue()); + } catch (Exception e) { + pushRecordPO.setFailReason(e.getMessage()); + pushRecordPO.setStatus(PushRecordStatusEnum.WITHDRAW_FAIL.getValue()); + } + getPushRecordMapper().updateIgnoreNull(pushRecordPO); + } + + + @Override + public void removeRecords(List recordIds) { + recordIds.forEach(recordId -> { + PushRecordPO recordPO = getPushRecordMapper().getById(recordId); + if (recordPO != null) { + getPushRecordDetailMapper().deleteByRecordId(recordId); + getPushRecordMapper().delete(recordPO); + } + + }); + } + + @Override + public PageInfo recordList(RecordListQueryParam param) { + List pushRecordPOS = getPushRecordMapper().listAll(); + List listDTOS = SalaryPageUtil.subList(param.getCurrent(), param.getPageSize(), pushRecordPOS) + .stream() + .map(po -> PushRecordDTO.builder() + .id(po.getId()) + .name(po.getName()) + .settingId(po.getId()) + .modeId(po.getModeId()) + .tableName(po.getTableName()) + .acctRecordId(po.getAcctRecordId()) + .type(po.getType()) + .status(po.getStatus()) + .statusName(PushRecordStatusEnum.parseByValue(po.getStatus()).getDefaultLabel()) + .startTime(po.getStartTime()) + .endTime(po.getEndTime()) + .build()) + .collect(Collectors.toList()); + + PageInfo pageInfo = SalaryPageUtil.buildPage(param.getCurrent(), param.getPageSize(), listDTOS, PushRecordDTO.class); + pageInfo.setTotal(pushRecordPOS.size()); + return pageInfo; + } + + @Override + public PageInfo recordDetailList(RecordDetailListQueryParam param) { + ValidUtil.doValidator(param); + + List list = getPushRecordDetailMapper().listDTO(PushRecordDetailDTO.builder().recordId(param.getRecordId()).build()); + List listDTOS = SalaryPageUtil.subList(param.getCurrent(), param.getPageSize(), list); + listDTOS.forEach(dto -> dto.setStatusName(PushRecordDetailStatusEnum.parseByValue(dto.getStatus()).getDefaultLabel())); + + PageInfo pageInfo = SalaryPageUtil.buildPage(param.getCurrent(), param.getPageSize(), PushRecordDetailDTO.class); + pageInfo.setList(listDTOS); + pageInfo.setTotal(list.size()); + return pageInfo; + } +} diff --git a/src/com/engine/salary/service/impl/RecordsBuildServiceImpl.java b/src/com/engine/salary/service/impl/RecordsBuildServiceImpl.java new file mode 100644 index 000000000..29ee07ccc --- /dev/null +++ b/src/com/engine/salary/service/impl/RecordsBuildServiceImpl.java @@ -0,0 +1,421 @@ +package com.engine.salary.service.impl; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.TypeReference; +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.siaccount.po.InsuranceAccountDetailPO; +import com.engine.salary.entity.siaccount.po.InsuranceAccountInspectPO; +import com.engine.salary.entity.siarchives.po.InsuranceArchivesAccountPO; +import com.engine.salary.entity.siarchives.po.InsuranceArchivesFundSchemePO; +import com.engine.salary.entity.siarchives.po.InsuranceArchivesOtherSchemePO; +import com.engine.salary.entity.siarchives.po.InsuranceArchivesSocialSchemePO; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import com.engine.salary.enums.UserStatusEnum; +import com.engine.salary.enums.siaccount.BillStatusEnum; +import com.engine.salary.enums.siaccount.ResourceFromEnum; +import com.engine.salary.enums.sicategory.PaymentScopeEnum; +import com.engine.salary.mapper.datacollection.EmployMapper; +import com.engine.salary.mapper.sischeme.InsuranceSchemeMapper; +import com.engine.salary.mapper.taxagent.TaxAgentMapper; +import com.engine.salary.service.RecordsBuildService; +import com.engine.salary.service.SIArchivesService; +import com.engine.salary.service.SalaryEmployeeService; +import com.engine.salary.util.SalaryAssert; +import com.engine.salary.util.SalaryDateUtil; +import com.engine.salary.util.SalaryEnumUtil; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.db.MapperProxyFactory; +import com.google.common.collect.Lists; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import weaver.general.Util; +import weaver.hrm.User; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.function.Function; +import java.util.stream.Collectors; + +/** + * @Author weaver_cl + * @Description: + * @Date 2022/4/11 + * @Version V1.0 + **/ +public class RecordsBuildServiceImpl extends Service implements RecordsBuildService { + + private EmployMapper getEmployMapper() { + return MapperProxyFactory.getProxy(EmployMapper.class); + } + + private TaxAgentMapper getTaxAgentMapper() { + return MapperProxyFactory.getProxy(TaxAgentMapper.class); + } + + private InsuranceSchemeMapper getInsuranceSchemeMapper() { + return MapperProxyFactory.getProxy(InsuranceSchemeMapper.class); + } + + private SalaryEmployeeService getSalaryEmployeeService(User user) { + return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user); + } + +// private SIArchivesBiz siArchivesBiz = new SIArchivesBiz(); + + public SIArchivesService getSIArchivesService(User user) { + return ServiceUtil.getService(SIArchivesServiceImpl.class, user); + } + + @Override + public List> buildCommonRecords(List list, Long employeeId, boolean dynamicEmpInfo) { +// boolean welBaseDiffSign = siArchivesBiz.isDiffWelBase(); + boolean welBaseDiffSign = getSIArchivesService(user).isDiffWelBase(); + List> result = new ArrayList<>(); + if (CollectionUtils.isEmpty(list)) { + return result; + } + List employeeIds = list.stream().map(item -> item.getEmployeeId()).distinct().collect(Collectors.toList()); + List employeeByIds = new ArrayList<>(); + List> partition = Lists.partition(employeeIds, 1000); + for (List longs : partition) { + employeeByIds.addAll(getSalaryEmployeeService(user).getEmployeeByIdsAll(longs)); + } + if (CollectionUtils.isEmpty(employeeByIds)) { + return result; + } + List paymentList = getTaxAgentMapper().listAll(); + + SalaryAssert.notEmpty(paymentList, SalaryI18nUtil.getI18nLabel(100341, "暂无扣缴义务人")); + Map paymentMap = paymentList.stream().collect(Collectors.toMap(TaxAgentPO::getId, Function.identity())); + Map collect = employeeByIds.stream().collect(Collectors.toMap(DataCollectionEmployee::getEmployeeId, Function.identity())); + list.forEach(item -> { + Map record = new HashMap<>(); + DataCollectionEmployee simpleEmployee = collect.get(item.getEmployeeId()); + record.put("id", item.getId()); + record.put("employeeId", item.getEmployeeId()); + record.put("billMonth", item.getBillMonth()); + record.put("billStatus", SalaryEnumUtil.enumMatchByValue(item.getBillStatus(), BillStatusEnum.values(), BillStatusEnum.class)); + record.put("userName", simpleEmployee.getUsername()); + record.put("mobile", simpleEmployee.getMobile()); + if (!dynamicEmpInfo) { + record.put("department", item.getDepartmentName()); + record.put("departmentId", item.getDepartmentId()); + record.put("subcompany", item.getSubcompanyName()); + record.put("subcompanyId", item.getSubcompanyId()); + record.put("jobtitle", item.getJobtitleName()); + record.put("jobtitleId", item.getJobtitleId()); + record.put("jobcall", item.getJobcall()); + record.put("jobcallId", item.getJobcallId()); + record.put("employeeStatus", item.getStatus() != null ? UserStatusEnum.getDefaultLabelByValue(Integer.parseInt(item.getStatus())) : ""); + } else { + record.put("department", simpleEmployee.getDepartmentName()); + record.put("departmentId", simpleEmployee.getDepartmentId()); + record.put("employeeStatus", simpleEmployee.getStatus() != null ? UserStatusEnum.getDefaultLabelByValue(Integer.parseInt(simpleEmployee.getStatus())) : ""); + } + + record.put("supplementaryMonth", item.getSupplementaryMonth()); + ResourceFromEnum from = SalaryEnumUtil.enumMatchByValue(item.getResourceFrom(), ResourceFromEnum.values(), ResourceFromEnum.class); + record.put("workcode", StringUtils.isBlank(simpleEmployee.getWorkcode()) ? "" : simpleEmployee.getWorkcode()); + record.put("idNo", Util.null2String(simpleEmployee.getIdNo())); + record.put("sourceFrom", SalaryI18nUtil.getI18nLabel(from.getLabelId(), from.getDefaultLabel())); + record.put("socialPayOrg", paymentMap.get(item.getSocialPayOrg()) == null ? "" : paymentMap.get(item.getSocialPayOrg()).getName()); + record.put("socialAccount", item.getSocialAccount()); + + record.put("socialSchemeName", getInsuranceSchemeMapper().querySchemeName(item.getSocialSchemeId())); + if (StringUtils.isNotEmpty(item.getSocialPaymentBaseString()) || StringUtils.isNotEmpty(item.getSocialPaymentComBaseString())) { + Map socialJson = JSON.parseObject(item.getSocialPaymentBaseString(), new HashMap().getClass()); +// if(socialJson!=null){ +// socialJson.forEach((k, v) -> { +// record.put(k + "socialBase", (String) v); +// }); +// } + if (welBaseDiffSign) { + if (socialJson != null) { + //查询该福利方案下开启缴纳的福利项 +// List insuranceIdList = siArchivesBiz.payInsuranceIds(item.getSocialSchemeId(), PaymentScopeEnum.SCOPE_PERSON.getValue()); + List insuranceIdList = getSIArchivesService(user).payInsuranceIds(item.getSocialSchemeId(), PaymentScopeEnum.SCOPE_PERSON.getValue()); + socialJson.forEach((k, v) -> { + if (insuranceIdList.contains(Long.valueOf(k))) { + record.put(k + "socialPerBase", v); + } + }); + } + Map socialComJson = JSON.parseObject(item.getSocialPaymentComBaseString(), new TypeReference>() { + }); + if (socialComJson != null) { + //查询该福利方案下开启缴纳的福利项 +// List insuranceIdList = siArchivesBiz.payInsuranceIds(item.getSocialSchemeId(),PaymentScopeEnum.SCOPE_COMPANY.getValue()); + List insuranceIdList = getSIArchivesService(user).payInsuranceIds(item.getSocialSchemeId(),PaymentScopeEnum.SCOPE_COMPANY.getValue()); + socialComJson.forEach((k, v) -> { + if (insuranceIdList.contains(Long.valueOf(k))) { + record.put(k + "socialComBase", v); + } + }); + } + } else { + if (socialJson != null) { + //查询该福利方案下开启缴纳的福利项 +// List insuranceIdList = siArchivesBiz.payInsuranceIds(item.getSocialSchemeId()); + List insuranceIdList = getSIArchivesService(user).payInsuranceIds(item.getSocialSchemeId()); + socialJson.forEach((k, v) -> { + if (insuranceIdList.contains(Long.valueOf(k))) { + record.put(k + "socialBase", v); + } + }); + } + } + } + record.put("fundPayOrg", item.getFundPayOrg() == null ? "" : (paymentMap.getOrDefault(item.getFundPayOrg(),TaxAgentPO.builder().build())).getName()); + record.put("fundAccount", item.getFundAccount()); + record.put("fundSchemeName", getInsuranceSchemeMapper().querySchemeName(item.getFundSchemeId())); + record.put("supplementFundAccount", item.getSupplementFundAccount()); + if (StringUtils.isNotEmpty(item.getFundPaymentBaseString()) || StringUtils.isNotEmpty(item.getFundPaymentComBaseString())) { + Map fundJson = JSON.parseObject(item.getFundPaymentBaseString(), new HashMap().getClass()); +// if(fundJson!=null){ +// fundJson.forEach((k, v) -> { +// record.put(k + "fundBase", (String) v); +// }); +// } + if (welBaseDiffSign) { + if (fundJson != null) { + //查询该福利方案下开启缴纳的福利项 +// List insuranceIdList = siArchivesBiz.payInsuranceIds(item.getFundSchemeId(),PaymentScopeEnum.SCOPE_PERSON.getValue()); + List insuranceIdList = getSIArchivesService(user).payInsuranceIds(item.getFundSchemeId(),PaymentScopeEnum.SCOPE_PERSON.getValue()); + fundJson.forEach((k, v) -> { + if (insuranceIdList.contains(Long.valueOf(k))) { + record.put(k + "fundPerBase", v); + } + }); + } + Map fundComJson = JSON.parseObject(item.getFundPaymentComBaseString(), new TypeReference>() { + }); + if (fundComJson != null) { + //查询该福利方案下开启缴纳的福利项 +// List insuranceIdList = siArchivesBiz.payInsuranceIds(item.getFundSchemeId(),PaymentScopeEnum.SCOPE_COMPANY.getValue()); + List insuranceIdList = getSIArchivesService(user).payInsuranceIds(item.getFundSchemeId(),PaymentScopeEnum.SCOPE_COMPANY.getValue()); + fundComJson.forEach((k, v) -> { + if (insuranceIdList.contains(Long.valueOf(k))) { + record.put(k + "fundComBase", v); + } + }); + } + } else { + if (fundJson != null) { + //查询该福利方案下开启缴纳的福利项 +// List insuranceIdList = siArchivesBiz.payInsuranceIds(item.getFundSchemeId()); + List insuranceIdList = getSIArchivesService(user).payInsuranceIds(item.getFundSchemeId()); + fundJson.forEach((k, v) -> { + if (insuranceIdList.contains(Long.valueOf(k))) { + record.put(k + "fundBase", v); + } + }); + } + } + } + record.put("otherPayOrg", item.getOtherPayOrg() == null ? "" : (paymentMap.getOrDefault(item.getOtherPayOrg(),TaxAgentPO.builder().build())).getName()); + record.put("otherSchemeName", getInsuranceSchemeMapper().querySchemeName(item.getOtherSchemeId())); + if (StringUtils.isNotEmpty(item.getOtherPaymentBaseString()) || StringUtils.isNotEmpty(item.getOtherPaymentComBaseString())) { + Map otherJson = JSON.parseObject(item.getOtherPaymentBaseString(), new HashMap().getClass()); +// if(otherJson!=null){ +// otherJson.forEach((k, v) -> { +// record.put(k + "otherBase", (String) v); +// }); +// } + if (welBaseDiffSign) { + if (otherJson != null) { + //查询该福利方案下开启缴纳的福利项 +// List insuranceIdList = siArchivesBiz.payInsuranceIds(item.getOtherSchemeId(),PaymentScopeEnum.SCOPE_PERSON.getValue()); + List insuranceIdList = getSIArchivesService(user).payInsuranceIds(item.getOtherSchemeId(),PaymentScopeEnum.SCOPE_PERSON.getValue()); + otherJson.forEach((k, v) -> { + if (insuranceIdList.contains(Long.valueOf(k))) { + record.put(k + "otherPerBase", v); + } + }); + } + Map otherComJson = JSON.parseObject(item.getOtherPaymentComBaseString(), new TypeReference>() { + }); + if (otherComJson != null) { + //查询该福利方案下开启缴纳的福利项 +// List insuranceIdList = siArchivesBiz.payInsuranceIds(item.getOtherSchemeId(),PaymentScopeEnum.SCOPE_COMPANY.getValue()); + List insuranceIdList = getSIArchivesService(user).payInsuranceIds(item.getOtherSchemeId(),PaymentScopeEnum.SCOPE_COMPANY.getValue()); + otherComJson.forEach((k, v) -> { + if (insuranceIdList.contains(Long.valueOf(k))) { + record.put(k + "otherComBase", v); + } + }); + } + } else { + if (otherJson != null) { + //查询该福利方案下开启缴纳的福利项 +// List insuranceIdList = siArchivesBiz.payInsuranceIds(item.getOtherSchemeId()); + List insuranceIdList = getSIArchivesService(user).payInsuranceIds(item.getOtherSchemeId()); + otherJson.forEach((k, v) -> { + if (insuranceIdList.contains(Long.valueOf(k))) { + record.put(k + "otherBase", v); + } + }); + } + } + } + if (StringUtils.isNotEmpty(item.getSocialPerJson())) { + Map socialJson = JSON.parseObject(item.getSocialPerJson(), new HashMap().getClass()); + if(socialJson!=null){ + socialJson.forEach((k, v) -> { + record.put(k + "socialPer", (String) v); + }); + } + + } + record.put("socialPerSum", item.getSocialPerSum()); + if (StringUtils.isNotEmpty(item.getFundPerJson())) { + Map fundPerJson = JSON.parseObject(item.getFundPerJson(), new HashMap().getClass()); + if(fundPerJson!=null){ + fundPerJson.forEach((k, v) -> { + record.put(k + "fundPer", (String) v); + }); + } + + } + record.put("fundPerSum", item.getFundPerSum()); + if (StringUtils.isNotEmpty(item.getOtherPerJson())) { + Map fundPerJson = JSON.parseObject(item.getOtherPerJson(), new HashMap().getClass()); + if(fundPerJson!=null){ + fundPerJson.forEach((k, v) -> { + record.put(k + "otherPer", (String) v); + }); + } + + } + record.put("otherPerSum", item.getOtherPerSum()); + record.put("perSum", item.getPerSum()); + if (StringUtils.isNotEmpty(item.getSocialComJson())) { + Map fundPerJson = JSON.parseObject(item.getSocialComJson(), new HashMap().getClass()); + if(fundPerJson!=null){ + fundPerJson.forEach((k, v) -> { + record.put(k + "socialCom", (String) v); + }); + } + fundPerJson.forEach((k, v) -> { + record.put(k + "socialCom", (String) v); + }); + } + record.put("socialComSum", item.getSocialComSum()); + if (StringUtils.isNotEmpty(item.getFundComJson())) { + Map fundPerJson = JSON.parseObject(item.getFundComJson(), new HashMap().getClass()); + if(fundPerJson!=null){ + fundPerJson.forEach((k, v) -> { + record.put(k + "fundCom", (String) v); + }); + } + + } + record.put("fundComSum", item.getFundComSum()); + if (StringUtils.isNotEmpty(item.getOtherComJson())) { + Map fundPerJson = JSON.parseObject(item.getOtherComJson(), new HashMap().getClass()); + if(fundPerJson!=null){ + fundPerJson.forEach((k, v) -> { + record.put(k + "otherCom", (String) v); + }); + } + + } + record.put("otherComSum", item.getOtherComSum()); + record.put("comSum", item.getComSum()); + record.put("socialSum", item.getSocialSum()); + record.put("fundSum", item.getFundSum()); + record.put("otherSum", item.getOtherSum()); + record.put("total", item.getTotal()); + result.add(record); + }); + return result; + } + + @Override + public List> buildCommonRecordsWithStyle(List list, Long employeeId) { + return null; + } + + @Override + public List> buildInspectRecords(List list, Long paymentOrganization) { + List> result = new ArrayList<>(); + + if (CollectionUtils.isEmpty(list)) { + return result; + } + List employeeIds = list.stream().map(InsuranceAccountInspectPO::getEmployeeId).collect(Collectors.toList()); + List employeeByIds = new ArrayList<>(); + List> partition = Lists.partition(employeeIds, 1000); + for (List longs : partition) { + employeeByIds.addAll(getSalaryEmployeeService(user).getEmployeeByIdsAll(longs)); + } + if (CollectionUtils.isEmpty(employeeByIds)) { + return result; + } + Map collect = employeeByIds.stream().collect(Collectors.toMap(DataCollectionEmployee::getEmployeeId, Function.identity())); +// Map insuranceArchivesAccountPOMap = siArchivesBiz.buildBatchAccount(employeeIds, paymentOrganization); + Map insuranceArchivesAccountPOMap = getSIArchivesService(user).buildBatchAccount(employeeIds, paymentOrganization); + list.forEach(item -> { + Map record = new HashMap<>(); + DataCollectionEmployee simpleEmployee = collect.get(item.getEmployeeId()) == null ? new DataCollectionEmployee() : collect.get(item.getEmployeeId()); + InsuranceArchivesAccountPO insuranceAccountInspectPO = insuranceArchivesAccountPOMap.get(item.getEmployeeId()); + record.put("id", item.getId()); + record.put("employeeId", item.getEmployeeId()); + record.put("billMonth", item.getBillMonth()); + record.put("userName", simpleEmployee.getUsername()); + record.put("inspectStatus", item.getInspectStatus()); + record.put("department", simpleEmployee.getDepartmentName()); + record.put("supplementaryMonth", timeFormat(item.getSupplementaryMonth())); + record.put("mobile", simpleEmployee.getMobile()); + record.put("employeeStatus", simpleEmployee.getStatus()); + InsuranceArchivesSocialSchemePO social = insuranceAccountInspectPO.getSocial(); + if (social != null) { + record.put("socialSchemeName", getInsuranceSchemeMapper().querySchemeName(social.getSocialSchemeId())); + if (StringUtils.isNotEmpty(social.getSocialPaymentBaseString())) { + Map socialJson = JSON.parseObject(social.getSocialPaymentBaseString(), new HashMap().getClass()); + socialJson.forEach((k, v) -> { + record.put(k + "socialBase", (String) v); + }); + } + } + InsuranceArchivesFundSchemePO fund = insuranceAccountInspectPO.getFund(); + if (fund != null) { + record.put("fundSchemeName", getInsuranceSchemeMapper().querySchemeName(fund.getFundSchemeId())); + if (StringUtils.isNotEmpty(fund.getFundPaymentBaseString())) { + Map socialJson = JSON.parseObject(fund.getFundPaymentBaseString(), new HashMap().getClass()); + socialJson.forEach((k, v) -> { + record.put(k + "fundBase", (String) v); + }); + } + } + InsuranceArchivesOtherSchemePO other = insuranceAccountInspectPO.getOther(); + if (other != null) { + record.put("otherSchemeName", getInsuranceSchemeMapper().querySchemeName(other.getOtherSchemeId())); + if (StringUtils.isNotEmpty(other.getOtherPaymentBaseString())) { + Map socialJson = JSON.parseObject(other.getOtherPaymentBaseString(), new HashMap().getClass()); + socialJson.forEach((k, v) -> { + record.put(k + "otherBase", (String) v); + }); + } + } + result.add(record); + }); + return result; + } + + + public String timeFormat(String originTime) { + if (StringUtils.isBlank(originTime) || !SalaryDateUtil.checkYearMonth(originTime)) { + return null; + } + Date date = null; + try { + date = new SimpleDateFormat("yyyy-MM").parse(originTime); + } catch (ParseException e) { + //log.error("time format error", e); + } + return new SimpleDateFormat(SalaryI18nUtil.getI18nLabel(100519, "补缴yyyy年MM月")).format(date); + } +} \ No newline at end of file diff --git a/src/com/engine/salary/service/impl/RemoteExcelServiceImpl.java b/src/com/engine/salary/service/impl/RemoteExcelServiceImpl.java new file mode 100644 index 000000000..8a447abba --- /dev/null +++ b/src/com/engine/salary/service/impl/RemoteExcelServiceImpl.java @@ -0,0 +1,493 @@ +package com.engine.salary.service.impl; + +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.annotation.SalaryFormulaVar; +import com.engine.salary.constant.SalaryFormulaFieldConstant; +import com.engine.salary.entity.datacollection.AddUpDeduction; +import com.engine.salary.entity.datacollection.AddUpSituation; +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.datacollection.dto.AttendQuoteFieldListDTO; +import com.engine.salary.entity.datacollection.param.AttendQuoteFieldQueryParam; +import com.engine.salary.entity.datacollection.po.OtherDeductionPO; +import com.engine.salary.entity.datacollection.po.VariableItemPO; +import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO; +import com.engine.salary.entity.salaryformula.dto.SalaryFormulaTaxRateDTO; +import com.engine.salary.entity.salaryformula.po.FormulaVar; +import com.engine.salary.entity.salaryitem.po.SalaryItemPO; +import com.engine.salary.entity.salarysob.dto.SalarySobCycleDTO; +import com.engine.salary.entity.salarysob.po.SalarySobItemPO; +import com.engine.salary.entity.taxagent.param.TaxAgentQueryParam; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import com.engine.salary.entity.taxrate.TaxRateBase; +import com.engine.salary.enums.auth.AuthFilterTypeEnum; +import com.engine.salary.enums.salaryformula.ReferenceTypeEnum; +import com.engine.salary.enums.salaryformula.SalaryFormulaReferenceEnum; +import com.engine.salary.enums.salaryformula.SalarySQLReferenceEnum; +import com.engine.salary.formlua.entity.parameter.DataType; +import com.engine.salary.mapper.datacollection.AttendQuoteFieldMapper; +import com.engine.salary.service.*; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.db.MapperProxyFactory; +import com.google.common.collect.Lists; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.collections4.MapUtils; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import weaver.hrm.User; + +import java.lang.reflect.Field; +import java.util.*; +import java.util.stream.Collectors; + + +public class RemoteExcelServiceImpl extends Service implements RemoteExcelService { + + private static final Logger log = LoggerFactory.getLogger(RemoteExcelServiceImpl.class); + + + private SIAccountService getSIAccountService(User user) { + return (SIAccountService) ServiceUtil.getService(SIAccountServiceImpl.class, user); + } + + + private AttendQuoteFieldMapper getAttendQuoteFieldMapper() { + return MapperProxyFactory.getProxy(AttendQuoteFieldMapper.class); + } + + + private TaxRateBaseService getTaxRateBaseService(User user) { + return (TaxRateBaseService) ServiceUtil.getService(TaxRateBaseServiceImpl.class, user); + } + + + private TaxRateDetailService getTaxRateDetailService(User user) { + return (TaxRateDetailService) ServiceUtil.getService(TaxRateDetailServiceImpl.class, user); + } + + + private SalaryItemService getSalaryItemService(User user) { + return (SalaryItemService) ServiceUtil.getService(SalaryItemServiceImpl.class, user); + } + + private TaxAgentService getTaxAgentService(User user) { + return (TaxAgentService) ServiceUtil.getService(TaxAgentServiceImpl.class, user); + } + + private SalarySobItemService getSalarySobItemService(User user) { + return (SalarySobItemService) ServiceUtil.getService(SalarySobItemServiceImpl.class, user); + } + + private VariableItemService getVariableItemService(User user) { + return ServiceUtil.getService(VariableItemServiceImpl.class, user); + } + +// @Override +// public ExcelResult aggregation(AggFunc func, String sourceId, String fieldId, List filterFormDataList, Map extendParam, +// DataCollectionEmployee employee) { +// return null; +// } + +// @Override +// public ExcelPage categoryList(ExcelPage page, Map extendParam, DataCollectionEmployee employee) { +// log.info("page: {}", JsonUtil.toJsonString(page)); +// List categories = Lists.newArrayList(); +// FormulaCategory category = new FormulaCategory(); +// category.setId("TAX_RATE"); +// category.setName(SalaryI18nUtil.getI18nLabel(employee.getTenantKey(), employee.getEmployeeId(), 85370, "个税税率表")); +// category.setModule(SalaryFormulaFieldConstant.MODULE); +// category.setType(SalaryFormulaFieldConstant.MODULE); +// categories.add(category); +// page.setCount(1); +// page.setPageResult(categories); +// log.info("page: {}", JsonUtil.toJsonString(page)); +// return page; +// } + + @Override + public List fieldList(String sourceId, Map extendParam) { + + List vars = new ArrayList<>(); + + //sql + if (extendParam != null) { + String referenceType = extendParam.get("referenceType") == null ? "" : extendParam.get("referenceType").toString(); + if (ReferenceTypeEnum.SQL.getValue().equals(referenceType)) { + SalarySQLReferenceEnum referenceEnum = SalarySQLReferenceEnum.parseByValue(sourceId); + if (referenceEnum != null) { + switch (referenceEnum) { + case EMPLOYEE_INFO: + vars = convert2FormulaVar(DataCollectionEmployee.class, referenceEnum.getValue() + ""); + break; + case SALARY_ACCT_EMPLOYEE: + vars = convert2FormulaVar(SalaryAcctEmployeePO.class, referenceEnum.getValue() + ""); + break; + case SALARY_CYCLE: + vars = convert2FormulaVar(SalarySobCycleDTO.class, referenceEnum.getValue() + ""); + break; + case SALARY_ITEM: + vars = salaryItem2FormulaVar(SalaryFormulaReferenceEnum.SALARY_ITEM, extendParam); + break; + default: + break; + } + return vars; + } + } + } + + // 如果是其他数据源 + SalaryFormulaReferenceEnum referenceEnum = SalaryFormulaReferenceEnum.parseByValue(sourceId); + if (referenceEnum != null) { + switch (referenceEnum) { + case SALARY_ITEM: + case LAST_MONTH_CALC: + case ISSUED: + vars = salaryItem2FormulaVar(referenceEnum, extendParam); + break; + case SALARY_ARCHIVES: + vars = salaryArchives2FormulaVar(referenceEnum, extendParam); + break; + case ADD_UP_SITUATION: + vars = convert2FormulaVar(AddUpSituation.class, referenceEnum.getValue() + ""); + break; + case ADD_UP_DEDUCTIONS: + vars = convert2FormulaVar(AddUpDeduction.class, referenceEnum.getValue() + ""); + break; + case EMPLOYEE_INFO: + vars = convert2FormulaVar(DataCollectionEmployee.class, referenceEnum.getValue() + ""); + break; + case OTHER_DEDUCTION: + vars = convert2FormulaVar(OtherDeductionPO.class, referenceEnum.getValue() + ""); + break; + case WELFARE: + vars = welfare2FormulaVar(referenceEnum); + break; + case ATTEND: + vars = attendData2FormulaVar(referenceEnum); + break; + case SALARY_ACCT_EMPLOYEE: + vars = convert2FormulaVar(SalaryAcctEmployeePO.class, referenceEnum.getValue() + ""); + break; + case SALARY_CYCLE: + vars = convert2FormulaVar(SalarySobCycleDTO.class, referenceEnum.getValue() + ""); + break; + case VARIABLE_ITEM: + vars = variableArchives2FormulaVar(referenceEnum, extendParam); + break; + default: + break; + } + return vars; + } + // 如果是个税税率表的数据源 + List taxRateBatches = getTaxRateBaseService(user).list(); + boolean isTaxRate = taxRateBatches.stream().anyMatch(e -> StringUtils.equals(sourceId, e.getId() + "")); + if (isTaxRate) { + vars = convert2FormulaVar(SalaryFormulaTaxRateDTO.class, sourceId); + } + return vars; + } + + @Override + public List> fieldGroupList(Map extendParam) { + + if (ReferenceTypeEnum.SQL.getValue().equals(extendParam.get("referenceType"))) { + return Arrays.stream(SalarySQLReferenceEnum.values()).map(e -> { + Map map = new HashMap<>(); + map.put("key", e.getValue()); + map.put("value", SalaryI18nUtil.getI18nLabel(e.getLabelId(), e.getDefaultLabel())); + return map; + }).collect(Collectors.toList()); + } + // 回算已发 + if (ReferenceTypeEnum.BackCalc.getValue().equals(extendParam.get("referenceType"))) { + Map map = new HashMap<>(); + map.put("key", SalaryFormulaReferenceEnum.ISSUED.getValue()); + map.put("value", SalaryI18nUtil.getI18nLabel(SalaryFormulaReferenceEnum.ISSUED.getLabelId(), SalaryFormulaReferenceEnum.ISSUED.getDefaultLabel())); + List> result = new ArrayList<>(); + result.add(map); + return result; + } + + return Arrays.stream(SalaryFormulaReferenceEnum.values()).map(e -> { + Map map = new HashMap<>(); + map.put("key", e.getValue()); + map.put("value", SalaryI18nUtil.getI18nLabel(e.getLabelId(), e.getDefaultLabel())); + return map; + }).collect(Collectors.toList()); + } + + @Override + public Map> allFieldList(ReferenceTypeEnum referenceTypeEnum) { + + Map> result = new HashMap<>(); + + //sql + if (ReferenceTypeEnum.SQL.equals(referenceTypeEnum)) { + result.put(SalarySQLReferenceEnum.EMPLOYEE_INFO.getDefaultLabel(), + convert2FormulaVar(DataCollectionEmployee.class, SalarySQLReferenceEnum.EMPLOYEE_INFO.getValue() + "")); + result.put(SalarySQLReferenceEnum.SALARY_ACCT_EMPLOYEE.getDefaultLabel(), + convert2FormulaVar(SalaryAcctEmployeePO.class, SalarySQLReferenceEnum.SALARY_ACCT_EMPLOYEE.getValue() + "")); + result.put(SalarySQLReferenceEnum.SALARY_CYCLE.getDefaultLabel(), + convert2FormulaVar(SalarySobCycleDTO.class, SalarySQLReferenceEnum.SALARY_CYCLE.getValue() + "")); + result.put(SalarySQLReferenceEnum.SALARY_ITEM.getDefaultLabel(), + salaryItem2FormulaVar(SalaryFormulaReferenceEnum.SALARY_ITEM, null)); + return result; + } + + // 如果是其他数据源 + if (ReferenceTypeEnum.FORMULA.equals(referenceTypeEnum)) { + result.put(SalaryFormulaReferenceEnum.SALARY_ITEM.getDefaultLabel(), + salaryItem2FormulaVar(SalaryFormulaReferenceEnum.SALARY_ITEM, null)); + result.put(SalaryFormulaReferenceEnum.LAST_MONTH_CALC.getDefaultLabel(), + salaryItem2FormulaVar(SalaryFormulaReferenceEnum.LAST_MONTH_CALC, null)); + result.put(SalaryFormulaReferenceEnum.ISSUED.getDefaultLabel(), + salaryItem2FormulaVar(SalaryFormulaReferenceEnum.ISSUED, null)); + result.put(SalaryFormulaReferenceEnum.SALARY_ARCHIVES.getDefaultLabel(), + salaryArchives2FormulaVar(SalaryFormulaReferenceEnum.SALARY_ARCHIVES, null)); + result.put(SalaryFormulaReferenceEnum.ADD_UP_SITUATION.getDefaultLabel(), + convert2FormulaVar(AddUpSituation.class, SalaryFormulaReferenceEnum.ADD_UP_SITUATION.getValue() + "")); + result.put(SalaryFormulaReferenceEnum.ADD_UP_DEDUCTIONS.getDefaultLabel(), + convert2FormulaVar(AddUpDeduction.class, SalaryFormulaReferenceEnum.ADD_UP_DEDUCTIONS.getValue() + "")); + result.put(SalaryFormulaReferenceEnum.EMPLOYEE_INFO.getDefaultLabel(), + convert2FormulaVar(DataCollectionEmployee.class, SalaryFormulaReferenceEnum.EMPLOYEE_INFO.getValue() + "")); + result.put(SalaryFormulaReferenceEnum.OTHER_DEDUCTION.getDefaultLabel(), + convert2FormulaVar(OtherDeductionPO.class, SalaryFormulaReferenceEnum.OTHER_DEDUCTION.getValue() + "")); + result.put(SalaryFormulaReferenceEnum.WELFARE.getDefaultLabel(), + welfare2FormulaVar(SalaryFormulaReferenceEnum.WELFARE)); + result.put(SalaryFormulaReferenceEnum.ATTEND.getDefaultLabel(), + attendData2FormulaVar(SalaryFormulaReferenceEnum.ATTEND)); + result.put(SalarySQLReferenceEnum.SALARY_ACCT_EMPLOYEE.getDefaultLabel(), + convert2FormulaVar(SalaryAcctEmployeePO.class, SalarySQLReferenceEnum.SALARY_ACCT_EMPLOYEE.getValue() + "")); + result.put(SalarySQLReferenceEnum.SALARY_CYCLE.getDefaultLabel(), + convert2FormulaVar(SalarySobCycleDTO.class, SalarySQLReferenceEnum.SALARY_CYCLE.getValue() + "")); + result.put(SalaryFormulaReferenceEnum.VARIABLE_ITEM.getDefaultLabel(), + variableArchives2FormulaVar(SalaryFormulaReferenceEnum.VARIABLE_ITEM, null)); + return result; + } + return result; + } + +// @Override +// public ExcelPage dataSourceList(String categoryId, ExcelPage page, Map extendParam, DataCollectionEmployee employee) { +// log.info("categoryId: {}, page: {}", categoryId, JsonUtil.toJsonString(page)); +// if (StringUtils.equals("TAX_RATE", categoryId)) { +// taxRate2FormulaDataSource(page, employee.getTenantKey()); +// } +// log.info("page: {}", JsonUtil.toJsonString(page)); +// return page; +// } +// +// @Override +// public List findProperData(String dataId, String fieldId, String fieldType, Map extendParam, DataCollectionEmployee employee) { +// return null; +// } +// +// @Override +// public List choose(String sourceId, List filterFormDataList, Map extendParam, DataCollectionEmployee employee) { +// return null; +// } +// +//// @Override +// public List vlookups(String sourceId, List filterFormDataList, List returnFields, Map extendParam, +// DataCollectionEmployee employee) { +// log.info("sourceId: {}, filterFormDataList: {}, returnFields: {}", sourceId, JsonUtil.toJsonString(filterFormDataList), JsonUtil.toJsonString(returnFields)); +// Map columnMap = Maps.newHashMap(); +// for (Field declaredField : SalaryFormulaTaxRateDTO.class.getDeclaredFields()) { +// if (!declaredField.isAnnotationPresent(SalaryFormulaVar.class)) { +// continue; +// } +// SalaryFormulaVar annotation = declaredField.getAnnotation(SalaryFormulaVar.class); +// columnMap.put(annotation.fieldId(), declaredField.getName()); +// } +// List resultList = Lists.newArrayList(); +// Long taxRateBatchId = Long.valueOf(sourceId); +// boolean isOr = filterFormDataList.stream().anyMatch(e -> StringUtils.equals(e.getCondition(), FormulaFilterData.CONDITION_OR)); +// TaxRateDetailPO taxRateRecord = taxRateDetailService.getByFormulaFilterData(taxRateBatchId, isOr, filterFormDataList, employee.getTenantKey()); +// if (taxRateRecord == null) { +// return Collections.emptyList(); +// } +// Map valueMap = JsonUtil.parseMap(JsonUtil.toJsonString(taxRateRecord), String.class); +// for (String returnField : returnFields) { +// DataType dataType = new DataType(); +// dataType.setFieldId(returnField); +// dataType.setFormId(0L); +// dataType.setSubFormId(0L); +// dataType.setName(""); +// dataType.setContent(valueMap.getOrDefault(columnMap.get(returnField), "0")); +// dataType.setDataType(DataType.NUMBER); +// dataType.setComponentKey("NumberComponent"); +// dataType.setModule(SalaryFormulaFieldConstant.MODULE); +// resultList.add(dataType); +// } +// log.info("resultList: {}", JsonUtil.toJsonString(resultList)); +// return resultList; +// } +// +// @Override +// public Map findSourceName(String Module, List idList, Map extendParam, DataCollectionEmployee employee) { +// return null; +// } +// +//// @Override +//// public List getFieldData(String dataId, List fieldIds, DataCollectionEmployee employee) { +//// return null; +//// } +// +// private void taxRate2FormulaDataSource(ExcelPage resultPage, String tenantKey) { +// List taxRateBatches = taxRateBaseService.list(tenantKey); +// List subList = SalaryPageUtil.subList(resultPage.getPageNo(), resultPage.getPageSize(), taxRateBatches); +// if (CollectionUtils.isEmpty(subList)) { +// resultPage.setPageResult(Collections.emptyList()); +// return; +// } +// List formulaDataSources = subList.stream() +// .map(e -> { +// FormulaDataSource formulaDataSource = new FormulaDataSource(); +// formulaDataSource.setTitle(e.getName()); +// formulaDataSource.setDataId("" + e.getId()); +// formulaDataSource.setModule(SalaryFormulaFieldConstant.MODULE); +// return formulaDataSource; +// }) +// .collect(Collectors.toList()); +// resultPage.setCount(taxRateBatches.size()); +// resultPage.setPageResult(formulaDataSources); +// } + + private List salaryItem2FormulaVar(SalaryFormulaReferenceEnum referenceEnum, Map extendParam) { + Set salaryItemIds = Collections.emptySet(); + Object salarySobId = extendParam == null ? null : extendParam.get("salarySobId"); + if (Objects.nonNull(salarySobId)) { + List salarySobItems = getSalarySobItemService(user).listBySalarySobId(Long.valueOf(String.valueOf(salarySobId))); + salaryItemIds = SalaryEntityUtil.properties(salarySobItems, SalarySobItemPO::getSalaryItemId); + } + List salaryItems; + if (CollectionUtils.isEmpty(salaryItemIds)) { + salaryItems = getSalaryItemService(user).listAll(); + } else { + salaryItems = getSalaryItemService(user).listByIds(salaryItemIds); + } + TaxAgentQueryParam param = TaxAgentQueryParam.builder().build(); + param.setFilterType(AuthFilterTypeEnum.QUERY_DATA); + Set taxAgentIds = getTaxAgentService(user).listAuth(param).stream().map(TaxAgentPO::getId).collect(Collectors.toSet()); + return salaryItems.stream() + //薪资项目取消过滤档案,使得导入功能一页面为准 +// .filter(e -> e.getUseInEmployeeSalary() == 0) + .filter(e -> getSalaryItemService(user).filterInRange(taxAgentIds, e)) + .map(e -> { + FormulaVar formulaVar = new FormulaVar(); + formulaVar.setFieldId(referenceEnum.getValue() + SalaryFormulaFieldConstant.FIELD_ID_SEPARATOR + e.getCode()); + formulaVar.setName(e.getName()); + formulaVar.setSource("" + referenceEnum.getValue()); + formulaVar.setFieldType(e.getDataType()); + return formulaVar; + }).collect(Collectors.toList()); + + } + + + private List salaryArchives2FormulaVar(SalaryFormulaReferenceEnum referenceEnum, Map extendParam) { + Set salaryItemIds = Collections.emptySet(); + Object salarySobId = extendParam == null ? null : extendParam.get("salarySobId"); + if (Objects.nonNull(salarySobId)) { + List salarySobItems = getSalarySobItemService(user).listBySalarySobId(Long.valueOf(String.valueOf(salarySobId))); + salaryItemIds = SalaryEntityUtil.properties(salarySobItems, SalarySobItemPO::getSalaryItemId); + } + List salaryItems; + if (CollectionUtils.isEmpty(salaryItemIds)) { + salaryItems = getSalaryItemService(user).listAll(); + } else { + salaryItems = getSalaryItemService(user).listByIds(salaryItemIds); + } + + TaxAgentQueryParam param = TaxAgentQueryParam.builder().build(); + param.setFilterType(AuthFilterTypeEnum.QUERY_DATA); + Set taxAgentIds = getTaxAgentService(user).listAuth(param).stream().map(TaxAgentPO::getId).collect(Collectors.toSet()); + return salaryItems.stream() + .filter(e -> e.getUseInEmployeeSalary() == 1) + .filter(e-> getSalaryItemService(user).filterInRange(taxAgentIds, e)) + .map(e -> { + FormulaVar formulaVar = new FormulaVar(); + formulaVar.setFieldId(referenceEnum.getValue() + SalaryFormulaFieldConstant.FIELD_ID_SEPARATOR + e.getCode()); + formulaVar.setName(e.getName()); + formulaVar.setSource("" + referenceEnum.getValue()); + formulaVar.setFieldType(e.getDataType()); + return formulaVar; + }).collect(Collectors.toList()); + } + + private List variableArchives2FormulaVar(SalaryFormulaReferenceEnum referenceEnum, Map extendParam) { + List variableItems; + variableItems = getVariableItemService(user).listAll(); + return variableItems.stream() + .map(e -> { + FormulaVar formulaVar = new FormulaVar(); + formulaVar.setFieldId(referenceEnum.getValue() + SalaryFormulaFieldConstant.FIELD_ID_SEPARATOR + e.getCode()); + formulaVar.setName(e.getName()); + formulaVar.setSource("" + referenceEnum.getValue()); + formulaVar.setFieldType(e.getDataType()); + return formulaVar; + }).collect(Collectors.toList()); + } + + private List convert2FormulaVar(Class clazz, String formId) { + Field[] declaredFields = clazz.getDeclaredFields(); + List formulaVars = Lists.newArrayListWithExpectedSize(declaredFields.length); + for (Field declaredField : declaredFields) { + if (!declaredField.isAnnotationPresent(SalaryFormulaVar.class)) { + continue; + } + SalaryFormulaVar annotation = declaredField.getAnnotation(SalaryFormulaVar.class); + FormulaVar formulaVar = new FormulaVar(); + if (StringUtils.isEmpty(annotation.fieldId())) { + formulaVar.setFieldId(formId + SalaryFormulaFieldConstant.FIELD_ID_SEPARATOR + declaredField.getName()); + } else { + formulaVar.setFieldId(annotation.fieldId()); + } + formulaVar.setName(SalaryI18nUtil.getI18nLabel(annotation.labelId(), annotation.defaultLabel())); + formulaVar.setSource(formId); + formulaVar.setFieldType(annotation.dataType()); +// if (StringUtils.equals(formId, "" + SalaryFormulaReferenceEnum.EMPLOYEE_INFO.getValue())) { +// formulaVar.setSource(DataType.STRING); +// } + formulaVars.add(formulaVar); + } + return formulaVars; + } + + private List welfare2FormulaVar(SalaryFormulaReferenceEnum referenceEnum) { + Map welfareColumns = getSIAccountService(user).welfareColumns(); + if (MapUtils.isEmpty(welfareColumns)) { + return null; + } + List formulaVars = Lists.newArrayListWithExpectedSize(welfareColumns.size()); + welfareColumns.forEach((k, v) -> { + FormulaVar formulaVar = new FormulaVar(); + formulaVar.setFieldId(referenceEnum.getValue() + SalaryFormulaFieldConstant.FIELD_ID_SEPARATOR + v); + formulaVar.setName(k); + formulaVar.setSource("" + referenceEnum.getValue()); + formulaVar.setFieldType(DataType.NUMBER); + formulaVars.add(formulaVar); + }); + return formulaVars; + } + + private List attendData2FormulaVar(SalaryFormulaReferenceEnum referenceEnum) { + List fields = getAttendQuoteFieldMapper().list(AttendQuoteFieldQueryParam.builder().enableStatus(1).build()); + if (CollectionUtils.isEmpty(fields)) { + return null; + } + List formulaVars = fields.stream().map(e -> { + FormulaVar formulaVar = new FormulaVar(); + formulaVar.setFieldId(referenceEnum.getValue() + SalaryFormulaFieldConstant.FIELD_ID_SEPARATOR + e.getId()); + formulaVar.setName(e.getFieldName()); + formulaVar.setSource("" + referenceEnum.getValue()); + formulaVar.setFieldType(DataType.NUMBER); + return formulaVar; + }).collect(Collectors.toList()); + return formulaVars; + } +} diff --git a/src/com/engine/salary/service/impl/SIAComparisonResultServiceImpl.java b/src/com/engine/salary/service/impl/SIAComparisonResultServiceImpl.java new file mode 100644 index 000000000..79f3ee877 --- /dev/null +++ b/src/com/engine/salary/service/impl/SIAComparisonResultServiceImpl.java @@ -0,0 +1,337 @@ +package com.engine.salary.service.impl; + +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.encrypt.EncryptUtil; +import com.engine.salary.entity.siaccount.bo.InsuranceComparisonResultBO; +import com.engine.salary.entity.siaccount.dto.InsuranceComparisonResultListDTO; +import com.engine.salary.entity.siaccount.param.InsuranceComparisonResultQueryParam; +import com.engine.salary.entity.siarchives.po.InsuranceArchivesBaseInfoPO; +import com.engine.salary.entity.sicategory.po.ICategoryPO; +import com.engine.salary.entity.siexport.param.InsuranceExportParam; +import com.engine.salary.entity.siexport.po.AccountExportPO; +import com.engine.salary.entity.siexport.po.ExcelAccountExportPO; +import com.engine.salary.entity.sischeme.po.InsuranceSchemeDetailPO; +import com.engine.salary.enums.siaccount.EmployeeStatusEnum; +import com.engine.salary.mapper.InsuranceExportMapper; +import com.engine.salary.mapper.siarchives.InsuranceBaseInfoMapper; +import com.engine.salary.mapper.sicategory.ICategoryMapper; +import com.engine.salary.mapper.sischeme.InsuranceSchemeDetailMapper; +import com.engine.salary.service.SIAComparisonResultService; +import com.engine.salary.service.SIArchivesService; +import com.engine.salary.service.SISchemeService; +import com.engine.salary.sys.entity.vo.OrderRuleVO; +import com.engine.salary.sys.service.SalarySysConfService; +import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.db.MapperProxyFactory; +import com.engine.salary.util.excel.ExcelUtilPlus; +import com.engine.salary.util.page.Column; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.util.page.SalaryPageUtil; +import com.engine.salary.util.valid.ValidUtil; +import com.google.common.collect.Lists; +import org.apache.commons.lang3.BooleanUtils; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import weaver.hrm.User; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * @Author: sy + * @Description: 福利核算的线下对比结果 + * @Date: 2022/9/28 + **/ +public class SIAComparisonResultServiceImpl extends Service implements SIAComparisonResultService { + private EncryptUtil encryptUtil = new EncryptUtil(); + +// private SIArchivesBiz siArchivesBiz = new SIArchivesBiz(); + + private InsuranceExportMapper getInsuranceExportMapper() { + return MapperProxyFactory.getProxy(InsuranceExportMapper.class); + } + + private InsuranceBaseInfoMapper getInsuranceBaseInfoMapper() { + return MapperProxyFactory.getProxy(InsuranceBaseInfoMapper.class); + } + + private SalarySysConfService getSalarySysConfService(User user) { + return ServiceUtil.getService(SalarySysConfServiceImpl.class, user); + } + + private ICategoryMapper getICategoryMapper() { + return MapperProxyFactory.getProxy(ICategoryMapper.class); + } + + private InsuranceSchemeDetailMapper getInsuranceSchemeDetailMapper() { + return MapperProxyFactory.getProxy(InsuranceSchemeDetailMapper.class); + } + + private SISchemeService getSISchemeService(User user) { + return ServiceUtil.getService(SISchemeServiceImpl.class, user); + } + + public SIArchivesService getSIArchivesService(User user) { + return ServiceUtil.getService(SIArchivesServiceImpl.class, user); + } + + /** + * 根据列表查询条件查询线下对比结果(分页) + */ + @Override + public InsuranceComparisonResultListDTO listPageByParam(InsuranceComparisonResultQueryParam queryParam) { + return listByParam(true, queryParam); + } + + /** + * 根据列表查询条件查询线下对比结果 + */ + @Override + public InsuranceComparisonResultListDTO listByParam(InsuranceComparisonResultQueryParam queryParam) { + return listByParam(false, queryParam); + } + + @Override + public XSSFWorkbook exportComparisonResult(InsuranceComparisonResultQueryParam queryParam) { + ValidUtil.doValidator(queryParam); + + // 查询线下对比结果 + InsuranceComparisonResultListDTO insuranceComparisonResultListDTO = listByParam(queryParam); + // 薪资核算线下对比结果列表表头 + List headerList = Lists.newArrayList(); + + Set employeeInfo = employeeInfo(); + Set welfareInfo = welfareInfo(); + for (Column weaTableColumn : insuranceComparisonResultListDTO.getWeaTableColumns()) { + // 员工信息字段 + if (employeeInfo.contains(weaTableColumn.getKey())) { + headerList.add(weaTableColumn.getTitle()); + } + // 薪资项目的表头 + if (welfareInfo.contains(weaTableColumn.getKey())) { + headerList.add(weaTableColumn.getTitle() + " (线上值)"); + headerList.add(weaTableColumn.getTitle() + " (线下值)"); + } + } + + List> resultMapList = insuranceComparisonResultListDTO.getData().getList(); + // excel导出的数据 + List> rows = new ArrayList<>(); + rows.add(headerList); + for (Map map : resultMapList) { + List row = Lists.newArrayList(); + for (Column weaTableColumn : insuranceComparisonResultListDTO.getWeaTableColumns()) { + // 员工信息字段的值 + if (employeeInfo.contains(weaTableColumn.getKey())) { + row.add(map.get(weaTableColumn.getKey())); + } + // 福利项目的值 + if (welfareInfo.contains(weaTableColumn.getKey())) { + Map tempMap = (Map) map.getOrDefault(weaTableColumn.getKey(), Collections.emptyMap()); + row.add(tempMap.get("acctResultValue")); + row.add(tempMap.get("excelResultValue")); + } + } + rows.add(row); + } + + String sheetName = "线下对比结果"; + + return ExcelUtilPlus.genWorkbookV2(rows, sheetName); + } + + + /** + * 根据福利核算人员查询福利核算线下对比结果 + */ + private InsuranceComparisonResultListDTO listByParam(boolean needPage, InsuranceComparisonResultQueryParam queryParam) { + +// boolean welBaseDiffSign = siArchivesBiz.isDiffWelBase(); + boolean welBaseDiffSign = getSIArchivesService(user).isDiffWelBase(); + //排序配置 + OrderRuleVO orderRule = getSalarySysConfService(user).orderRule(); + + //1-查询线上福利核算记录 + InsuranceExportParam insuranceExportParam = new InsuranceExportParam(); + insuranceExportParam.setBillMonth(queryParam.getBillMonth()); + insuranceExportParam.setPaymentOrganization(queryParam.getPaymentOrganization()); + insuranceExportParam.setOrderRule(orderRule); + //系统人员核算明细 + List accountExportPOS = getInsuranceExportMapper().exportAccount(queryParam.getPaymentStatus(), insuranceExportParam); + //非系统人员核算明细 + List extAccountExportPOS = getInsuranceExportMapper().exportExtAccount(queryParam.getPaymentStatus(), insuranceExportParam); + accountExportPOS.addAll(extAccountExportPOS); + SalaryI18nUtil.i18nList(accountExportPOS); + //如果入参包含姓名信息 + if (queryParam.getUserName() != null) { + accountExportPOS = accountExportPOS.stream().filter(v -> v.getUserName().contains(queryParam.getUserName())).collect(Collectors.toList()); + } + + //过滤出福利档案基础信息表中runStatus为正在缴纳和待减员的人员 + List baseInfoPOList = getInsuranceBaseInfoMapper().listAll(); + List canAccountIds = baseInfoPOList.stream() + .filter(f->f.getPaymentOrganization().toString().equals(queryParam.getPaymentOrganization()) + && (f.getRunStatus().equals(EmployeeStatusEnum.PAYING.getValue()) || f.getRunStatus().equals(EmployeeStatusEnum.STAY_DEL.getValue()))) + .map(InsuranceArchivesBaseInfoPO::getEmployeeId) + .collect(Collectors.toList()); + accountExportPOS = accountExportPOS.stream().filter(v -> canAccountIds.contains(v.getEmployeeId())).collect(Collectors.toList()); + + encryptUtil.decryptList(accountExportPOS, AccountExportPO.class); + //2-查询线下对比数据 + //系统人员对比数据 + List excelAccountExportPOS = getInsuranceExportMapper().exportExcelAccount(queryParam); + //非系统人员对比数据 + List extExcelAccountExportPOS = getInsuranceExportMapper().exportExtExcelAccount(queryParam); + excelAccountExportPOS.addAll(extExcelAccountExportPOS); + encryptUtil.decryptList(excelAccountExportPOS, ExcelAccountExportPO.class); + + //整理线上核算记录相关的福利方案,并以此整理需要对比的福利项类别数据 + Set welfareSchemeIds = new HashSet<>(); + accountExportPOS.forEach(f -> { + welfareSchemeIds.add(f.getSocialSchemeId()); + welfareSchemeIds.add(f.getFundSchemeId()); + welfareSchemeIds.add(f.getOtherSchemeId()); + }); + List insuranceSchemeDetailPos = getInsuranceSchemeDetailMapper().listAll(); + List insuranceBaseIds = insuranceSchemeDetailPos.stream() + .filter(f -> welfareSchemeIds.contains(f.getPrimaryId()) && f.getIsPayment() == 1) + .map(InsuranceSchemeDetailPO::getInsuranceId) + .collect(Collectors.toList()); + List insurancePerPayIds = insuranceSchemeDetailPos.stream() + .filter(f -> welfareSchemeIds.contains(f.getPrimaryId()) && f.getIsPayment() == 1 && f.getPaymentScope() == 2) + .map(InsuranceSchemeDetailPO::getInsuranceId) + .collect(Collectors.toList()); + List insuranceComPayIds = insuranceSchemeDetailPos.stream() + .filter(f -> welfareSchemeIds.contains(f.getPrimaryId()) && f.getIsPayment() == 1 && f.getPaymentScope() == 1) + .map(InsuranceSchemeDetailPO::getInsuranceId) + .collect(Collectors.toList()); + Set insuranceBaseSet = new HashSet<>(insuranceBaseIds); + Set insurancePerPaySet = new HashSet<>(insurancePerPayIds); + Set insuranceComPaySet = new HashSet<>(insuranceComPayIds); + //3-构建福利核算对比结果列表表头 + List weaTableColumns = InsuranceComparisonResultBO.buildTableColumns4ComparisonResult(insuranceBaseSet, insurancePerPaySet, insuranceComPaySet, welBaseDiffSign); + //4-通过线上线下两份数据获得对比结果 + Map schemeIdNameMap = getSISchemeService(user).getSchemeIdNameMap(); + List> resultMapList = InsuranceComparisonResultBO.buildComparisonTableData(accountExportPOS, excelAccountExportPOS, schemeIdNameMap, welBaseDiffSign); + + // 系统值和线下值一致的人员 + if (queryParam.isOnlyDiffEmployee()) { + // 过滤系统值和线下值一致的薪资核算人员 + resultMapList = resultMapList.stream() + .filter(map -> BooleanUtils.toBoolean(String.valueOf(map.get("different")))) + .collect(Collectors.toList()); + } + // 分页 + PageInfo> dtoPage = new PageInfo<>(); + dtoPage.setTotal(resultMapList.size()); + if (needPage) { + dtoPage.setList(SalaryPageUtil.subList(queryParam.getCurrent(), queryParam.getPageSize(), resultMapList)); + dtoPage.setPageSize(queryParam.getPageSize()); + dtoPage.setPageNum(queryParam.getCurrent()); + } else { + dtoPage.setList(resultMapList); + } + // 返回结果 + return new InsuranceComparisonResultListDTO().setWeaTableColumns(weaTableColumns).setData(dtoPage); + } + + private Set welfareInfo() { +// boolean welBaseDiffSign = siArchivesBiz.isDiffWelBase(); + boolean welBaseDiffSign = getSIArchivesService(user).isDiffWelBase(); + Set info = new HashSet<>(); + + List listAll = getICategoryMapper().listAll(); + List socialWelfareList = listAll.stream().filter(e -> e.getWelfareType() == 1).collect(Collectors.toList()); + List fundWelfareList = listAll.stream().filter(e -> e.getWelfareType() == 2).collect(Collectors.toList()); + List otherWelfareList = listAll.stream().filter(e -> e.getWelfareType() == 3).collect(Collectors.toList()); + + if (welBaseDiffSign) { + //组装社保基数 + for (ICategoryPO po : socialWelfareList) { + info.add(po.getId() + "socialPerBase"); + info.add(po.getId() + "socialComBase"); + } + //组装公积金基数 + for (ICategoryPO po : fundWelfareList) { + info.add(po.getId() + "fundPerBase"); + info.add(po.getId() + "fundComBase"); + } + //组装其他福利基数 + for (ICategoryPO po : otherWelfareList) { + info.add(po.getId() + "otherPerBase"); + info.add(po.getId() + "otherComBase"); + } + } else { + //组装社保基数 + for (ICategoryPO po : socialWelfareList) { + info.add(po.getId() + "socialBase"); + } + //组装公积金基数 + for (ICategoryPO po : fundWelfareList) { + info.add(po.getId() + "fundBase"); + } + //组装其他福利基数 + for (ICategoryPO po : otherWelfareList) { + info.add(po.getId() + "otherBase"); + } + } + + //社保个人(生育保险个人、工伤保险个人、失业保险个人、养老保险个人、医疗保险个人) + for (ICategoryPO po : socialWelfareList) { + info.add(po.getId() + "socialPer"); + } + info.add("socialPerSum"); + + //住房公积金个人、补充住房公积金个人 + for (ICategoryPO po : fundWelfareList) { + info.add(po.getId() + "fundPer"); + } + info.add("fundPerSum"); + + //其他个人(比如企业年金个人) + for (ICategoryPO po : otherWelfareList) { + info.add(po.getId() + "otherPer"); + } + info.add("otherPerSum"); + info.add("perSum"); + + //社保单位(生育保险单位、工伤保险单位、失业保险单位、养老保险单位、医疗保险单位) + for (ICategoryPO po : socialWelfareList) { + info.add(po.getId() + "socialCom"); + } + info.add("socialComSum"); + + //住房公积金单位、补充住房公积金单位 + for (ICategoryPO po : fundWelfareList) { + info.add(po.getId() + "fundCom"); + } + info.add("fundComSum"); + + //其他单位(比如企业年金单位) + for (ICategoryPO po : otherWelfareList) { + info.add(po.getId() + "otherCom"); + } + info.add("otherComSum"); + info.add("comSum"); + + info.add("socialSum"); + info.add("fundSum"); + info.add("otherSum"); + info.add("total"); + + return info; + } + + private Set employeeInfo() { + Set info = new HashSet<>(); + + info.add("userName"); + info.add("department"); + info.add("mobile"); + info.add("workcode"); + info.add("socialPayOrg"); + + return info; + } +} diff --git a/src/com/engine/salary/service/impl/SIAccountServiceImpl.java b/src/com/engine/salary/service/impl/SIAccountServiceImpl.java new file mode 100644 index 000000000..01aec157f --- /dev/null +++ b/src/com/engine/salary/service/impl/SIAccountServiceImpl.java @@ -0,0 +1,6992 @@ +package com.engine.salary.service.impl; + +import cn.hutool.core.util.ObjectUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.TypeReference; +import com.api.browser.bean.SearchConditionGroup; +import com.api.browser.bean.SearchConditionItem; +import com.api.browser.bean.SearchConditionOption; +import com.api.formmode.mybatis.util.SqlProxyHandle; +import com.cloudstore.dev.api.util.Util_DataCache; +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.hrmelog.entity.dto.LoggerContext; +import com.engine.salary.biz.TaxAgentBiz; +import com.engine.salary.cache.SalaryCacheKey; +import com.engine.salary.component.SalaryWeaTable; +import com.engine.salary.config.SalaryElogConfig; +import com.engine.salary.constant.SalaryDefaultTenantConstant; +import com.engine.salary.constant.SalaryItemConstant; +import com.engine.salary.encrypt.EncryptUtil; +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.progress.ProgressDTO; +import com.engine.salary.entity.siaccount.bo.InsuranceAccountBO; +import com.engine.salary.entity.siaccount.dto.*; +import com.engine.salary.entity.siaccount.param.*; +import com.engine.salary.entity.siaccount.po.*; +import com.engine.salary.entity.siarchives.po.*; +import com.engine.salary.entity.sicategory.po.ICategoryPO; +import com.engine.salary.entity.siexport.param.InsuranceExportParam; +import com.engine.salary.entity.siexport.po.AccountExportPO; +import com.engine.salary.entity.sischeme.po.InsuranceSchemeDetailPO; +import com.engine.salary.entity.sischeme.po.InsuranceSchemePO; +import com.engine.salary.entity.taxagent.param.TaxAgentQueryParam; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import com.engine.salary.enums.OperateTypeEnum; +import com.engine.salary.enums.UserStatusEnum; +import com.engine.salary.enums.auth.AuthFilterTypeEnum; +import com.engine.salary.enums.datacollection.UseEmployeeTypeEnum; +import com.engine.salary.enums.siaccount.*; +import com.engine.salary.enums.sicategory.*; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.mapper.InsuranceExportMapper; +import com.engine.salary.mapper.datacollection.EmployMapper; +import com.engine.salary.mapper.siaccount.*; +import com.engine.salary.mapper.siarchives.FundSchemeMapper; +import com.engine.salary.mapper.siarchives.InsuranceBaseInfoMapper; +import com.engine.salary.mapper.siarchives.OtherSchemeMapper; +import com.engine.salary.mapper.siarchives.SocialSchemeMapper; +import com.engine.salary.mapper.sicategory.ICategoryMapper; +import com.engine.salary.mapper.sischeme.InsuranceSchemeDetailMapper; +import com.engine.salary.mapper.sischeme.InsuranceSchemeMapper; +import com.engine.salary.mapper.sys.SalarySysConfMapper; +import com.engine.salary.mapper.taxagent.TaxAgentMapper; +import com.engine.salary.service.*; +import com.engine.salary.service.auth.AuthService; +import com.engine.salary.service.auth.AuthServiceImpl; +import com.engine.salary.sys.constant.SalarySysConstant; +import com.engine.salary.sys.entity.po.SalarySysConfPO; +import com.engine.salary.sys.entity.vo.OrderRuleVO; +import com.engine.salary.sys.enums.SalaryAcctEmployeeRuleEnum; +import com.engine.salary.sys.service.SalarySysConfService; +import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl; +import com.engine.salary.util.*; +import com.engine.salary.util.db.IdGenerator; +import com.engine.salary.util.db.MapperProxyFactory; +import com.engine.salary.util.excel.ExcelParseHelper; +import com.engine.salary.util.excel.ExcelSupport; +import com.engine.salary.util.excel.ExcelUtil; +import com.engine.salary.util.excel.ExcelUtilPlus; +import com.engine.salary.util.page.Column; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.util.page.SalaryPageUtil; +import com.engine.salary.util.valid.ValidUtil; +import com.engine.salary.wrapper.SalaryFormulaWrapper; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.mzlion.core.utils.BeanUtils; +import com.wbi.util.StringUtil; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang.math.NumberUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.util.IOUtils; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import weaver.file.ImageFileManager; +import weaver.general.Util; +import weaver.hrm.User; + +import java.io.InputStream; +import java.math.BigDecimal; +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.function.Function; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import java.util.stream.Collectors; + +import static com.engine.salary.util.excel.ExcelSupport.EXCEL_TYPE_XLSX; + + +/** + * @Author weaver_cl + * @Description: + * @Date 2022/4/11 + * @Version V1.0 + **/ +@Slf4j +public class SIAccountServiceImpl extends Service implements SIAccountService { + + +// private SIArchivesBiz siArchivesBiz = new SIArchivesBiz(); + + private EncryptUtil encryptUtil = new EncryptUtil(); + + public RecordsBuildService getService(User user) { + return ServiceUtil.getService(RecordsBuildServiceImpl.class, user); + } + +// public SIAccountBiz getSiAccountBiz(User user) { +// return ServiceUtil.getService(SIAccountBiz.class, user); +// } + + public ColumnBuildService getColumnBuildService(User user) { + return ServiceUtil.getService(ColumnBuildServiceImpl.class, user); + } + + public SICategoryService getSICategoryService(User user) { + return ServiceUtil.getService(SICategoryServiceImpl.class, user); + } + + private TaxAgentService getTaxAgentService(User user) { + return ServiceUtil.getService(TaxAgentServiceImpl.class, user); + } + + private InsuranceAccountBatchMapper getInsuranceAccountBatchMapper() { + return MapperProxyFactory.getProxy(InsuranceAccountBatchMapper.class); + } + + private InsuranceAccountDetailMapper getInsuranceAccountDetailMapper() { + return MapperProxyFactory.getProxy(InsuranceAccountDetailMapper.class); + } + + private ExcelInsuranceDetailMapper getExcelInsuranceDetailMapper() { + return MapperProxyFactory.getProxy(ExcelInsuranceDetailMapper.class); + } + + private SalaryItemService getSalaryItemService(User user) { + return (SalaryItemService) ServiceUtil.getService(SalaryItemServiceImpl.class, user); + } + + private TaxAgentMapper getTaxAgentMapper() { + return MapperProxyFactory.getProxy(TaxAgentMapper.class); + } + +// SICategoryBiz siCategoryBiz = new SICategoryBiz(); + + private SalarySysConfMapper getSalarySysConfMapper() { + return SqlProxyHandle.getProxy(SalarySysConfMapper.class); + } + + private SalaryEmployeeService getSalaryEmployeeService(User user) { + return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user); + } + + private SalarySysConfService getSalarySysConfService(User user) { + return ServiceUtil.getService(SalarySysConfServiceImpl.class, user); + } + + private InsuranceSchemeMapper getInsuranceSchemeMapper() { + return MapperProxyFactory.getProxy(InsuranceSchemeMapper.class); + } + + private InsuranceBaseInfoMapper getInsuranceBaseInfoMapper() { + return MapperProxyFactory.getProxy(InsuranceBaseInfoMapper.class); + } + + private SocialSchemeMapper getSocialSchemeMapper() { + return MapperProxyFactory.getProxy(SocialSchemeMapper.class); + } + + private FundSchemeMapper getFundSchemeMapper() { + return MapperProxyFactory.getProxy(FundSchemeMapper.class); + } + + private OtherSchemeMapper getOtherSchemeMapper() { + return MapperProxyFactory.getProxy(OtherSchemeMapper.class); + } + + private TaxAgentBiz taxAgentBiz = new TaxAgentBiz(); + + private ICategoryMapper getICategoryMapper() { + return MapperProxyFactory.getProxy(ICategoryMapper.class); + } + + private InsuranceAccountInspectMapper getInsuranceAccountInspectMapper() { + return MapperProxyFactory.getProxy(InsuranceAccountInspectMapper.class); + } + + private InsuranceExportMapper getInsuranceExportMapper() { + return MapperProxyFactory.getProxy(InsuranceExportMapper.class); + } + + private InsuranceSchemeDetailMapper getInsuranceSchemeDetailMapper() { + return MapperProxyFactory.getProxy(InsuranceSchemeDetailMapper.class); + } + + private SalaryFormulaWrapper getSalaryFormulaWrapper(User user) { + return (SalaryFormulaWrapper) ServiceUtil.getService(SalaryFormulaWrapper.class, user); + } + + public SIExportService getSIExportService(User user) { + return ServiceUtil.getService(SIExportServiceImpl.class, user); + } + + private SIBalanceService getSIBalanceService(User user) { + return (SIBalanceService) ServiceUtil.getService(SIBalanceServiceImpl.class, user); + } + + private ProgressService getSalaryAcctProgressService(User user) { + return ServiceUtil.getService(ProgressServiceImpl.class, user); + } + + private SIAccountDetailTempMapper getSIAccountDetailTempMapper() { + return MapperProxyFactory.getProxy(SIAccountDetailTempMapper.class); + } + + private InsuranceCompensationMapper getInsuranceCompensationMapper() { + return MapperProxyFactory.getProxy(InsuranceCompensationMapper.class); + } + + private SIAccountUtilMapper getSIAccountUtilMapper() { + return MapperProxyFactory.getProxy(SIAccountUtilMapper.class); + } + + public SIArchivesService getSIArchivesService(User user) { + return ServiceUtil.getService(SIArchivesServiceImpl.class, user); + } + + private EmployMapper getEmployMapper() { + return MapperProxyFactory.getProxy(EmployMapper.class); + } + + public AuthService getAuthService(User user) { + return ServiceUtil.getService(AuthServiceImpl.class, user); + } + + @Override + public Map listPage(InsuranceAccountBatchParam queryParam) { + Map datas = new HashMap<>(); + + PageInfo pageInfo = siBatchListPage(queryParam); + Collection insuranceAccountBatchPOS = pageInfo.getList(); + + List insuranceAccountBatchListDTOS = InsuranceAccountBO.buildAccountBatchDTOList(insuranceAccountBatchPOS); + PageInfo pageInfos = new PageInfo<>(insuranceAccountBatchListDTOS, InsuranceAccountBatchListDTO.class); + pageInfos.setTotal(pageInfo.getTotal()); + pageInfos.setPageNum(queryParam.getCurrent()); + pageInfos.setPageSize(queryParam.getPageSize()); + + + List>> operatesPermission = new ArrayList<>(); + + SalaryWeaTable table = new SalaryWeaTable<>(user, InsuranceAccountBatchListDTO.class); + List columns = pageInfos.getColumns(); + List weaTableColumn = columns.stream().map(v -> new WeaTableColumn("100", v.getTitle(), v.getKey())).collect(Collectors.toList()); + + table.setColumns(weaTableColumn); + + 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; + } + + @Override + public Map listCommonPage(InsuranceAccountDetailParam queryParam) { + Long employeeId = (long) user.getUID(); + Map datas = new HashMap<>(); + + //正常缴纳列表 +// PageInfo pageInfo = getSiAccountBiz(user).listCommonPage(queryParam); + PageInfo pageInfo = siBatchListCommonPage(queryParam); + List insuranceAccountDetailPOS = pageInfo.getList(); + + //数据组装 + List> records = getService(user).buildCommonRecords(insuranceAccountDetailPOS, employeeId, false); + PageInfo> pageInfos = new PageInfo<>(records); + pageInfos.setTotal(pageInfo.getTotal()); + pageInfos.setPageNum(queryParam.getCurrent()); + pageInfos.setPageSize(queryParam.getPageSize()); + + + //动态列组装 + List weaTableColumn = getColumnBuildService(user).buildCommonColumnsWithStyle(insuranceAccountDetailPOS, employeeId, SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY, queryParam.getPaymentStatus()); + + WeaTable table = new WeaTable(); + table.setPageUID(UUID.randomUUID().toString()); + table.setColumns(weaTableColumn); + List columns = weaTableColumn.stream().map(v -> new Column(v.getText(), v.getColumn(), v.getColumn())).collect(Collectors.toList()); + pageInfos.setColumns(columns); + + + 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())) { + queryParam.setUserName(queryParam.getUserName()); + } + return listCommonPage(queryParam); + } + + @Override + public Map listSupplementaryPage(InsuranceAccountDetailParam queryParam) { + Long employeeId = (long) user.getUID(); + Map datas = new HashMap<>(); + +// //过滤出福利档案基础信息表中runStatus为正在缴纳和待减员的人员 +// List baseInfoPOList = getInsuranceBaseInfoMapper().listAll(); +// List canAccountIds = baseInfoPOList.stream() +// .filter(f->f.getPaymentOrganization().toString().equals(queryParam.getPaymentOrganization()) +// && (f.getRunStatus().equals(EmployeeStatusEnum.PAYING.getValue()) || f.getRunStatus().equals(EmployeeStatusEnum.STAY_DEL.getValue()))) +// .map(InsuranceArchivesBaseInfoPO::getEmployeeId) +// .collect(Collectors.toList()); +// queryParam.setEmployeeIds(canAccountIds); + + //补缴缴纳列表 + queryParam.setPaymentStatus(PaymentStatusEnum.REPAIR.getValue()); + + //排序配置 + OrderRuleVO orderRule = getSalarySysConfService(user).orderRule(); + queryParam.setOrderRule(orderRule); + + //系统人员核算明细 + List list = getInsuranceAccountDetailMapper().list(queryParam); + //非系统人员核算明细 + List extList = getInsuranceAccountDetailMapper().extList(queryParam); + list.addAll(extList); + PageInfo pageInfo = SalaryPageUtil.buildPage(queryParam.getCurrent(),queryParam.getPageSize(), + list, InsuranceAccountDetailPO.class); + List insuranceAccountDetailPOS = pageInfo.getList(); + encryptUtil.decryptList(insuranceAccountDetailPOS, InsuranceAccountDetailPO.class); + //数据组装 + List> records = getService(user).buildCommonRecords(insuranceAccountDetailPOS, employeeId, false); + PageInfo> pageInfos = new PageInfo<>(records); + pageInfos.setTotal(pageInfo.getTotal()); + pageInfos.setPageNum(queryParam.getCurrent()); + pageInfos.setPageSize(queryParam.getPageSize()); + + + //动态列组装 + List weaTableColumn = getColumnBuildService(user).buildCommonColumnsWithStyle(insuranceAccountDetailPOS, employeeId, SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY, queryParam.getPaymentStatus()); + + SalaryWeaTable table = new SalaryWeaTable<>(user, InsuranceAccountDetailPO.class); + table.setColumns(weaTableColumn); + List columns = weaTableColumn.stream().map(v -> new Column(v.getText(), v.getColumn(), v.getColumn())).collect(Collectors.toList()); + pageInfos.setColumns(columns); + + + 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())) { + queryParam.setUserName(queryParam.getUserName()); + } + return listSupplementaryPage(queryParam); + } + + @Override + public Map listRecessionPage(InsuranceAccountDetailParam queryParam) { + Long employeeId = (long) user.getUID(); + Map datas = new HashMap<>(); + + //退差列表 + queryParam.setPaymentStatus(PaymentStatusEnum.RECESSION.getValue()); + + //排序配置 + OrderRuleVO orderRule = getSalarySysConfService(user).orderRule(); + queryParam.setOrderRule(orderRule); + + //系统人员核算明细 + List list = getInsuranceAccountDetailMapper().list(queryParam); + //非系统人员核算明细 + List extList = getInsuranceAccountDetailMapper().extList(queryParam); + list.addAll(extList); + PageInfo pageInfo = SalaryPageUtil.buildPage(queryParam.getCurrent(),queryParam.getPageSize(), + list, InsuranceAccountDetailPO.class); + List insuranceAccountDetailPOS = pageInfo.getList(); + encryptUtil.decryptList(insuranceAccountDetailPOS, InsuranceAccountDetailPO.class); + //数据组装 + List> records = getService(user).buildCommonRecords(insuranceAccountDetailPOS, employeeId, false); + PageInfo> pageInfos = new PageInfo<>(records); + pageInfos.setTotal(pageInfo.getTotal()); + pageInfos.setPageNum(queryParam.getCurrent()); + pageInfos.setPageSize(queryParam.getPageSize()); + + + //动态列组装 + List weaTableColumn = getColumnBuildService(user).buildCommonColumnsWithStyle(insuranceAccountDetailPOS, employeeId, SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY, queryParam.getPaymentStatus()); + + SalaryWeaTable table = new SalaryWeaTable<>(user, InsuranceAccountDetailPO.class); + table.setColumns(weaTableColumn); + List columns = weaTableColumn.stream().map(v -> new Column(v.getText(), v.getColumn(), v.getColumn())).collect(Collectors.toList()); + pageInfos.setColumns(columns); + + + 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 listBalancePage(InsuranceAccountDetailParam queryParam) { + Long employeeId = (long) user.getUID(); + Map datas = new HashMap<>(); + + //补差列表 + queryParam.setPaymentStatus(PaymentStatusEnum.BALANCE.getValue()); + + //排序配置 + OrderRuleVO orderRule = getSalarySysConfService(user).orderRule(); + queryParam.setOrderRule(orderRule); + + //系统人员核算明细 + List list = getInsuranceAccountDetailMapper().list(queryParam); + //非系统人员核算明细 + List extList = getInsuranceAccountDetailMapper().extList(queryParam); + list.addAll(extList); + PageInfo pageInfo = new PageInfo<>(list, InsuranceAccountDetailPO.class); + List insuranceAccountDetailPOS = pageInfo.getList(); + encryptUtil.decryptList(insuranceAccountDetailPOS, InsuranceAccountDetailPO.class); + //数据组装 + List> records = getService(user).buildCommonRecords(insuranceAccountDetailPOS, employeeId, false); + PageInfo> pageInfos = new PageInfo<>(records); + pageInfos.setTotal(pageInfo.getTotal()); + pageInfos.setPageNum(queryParam.getCurrent()); + pageInfos.setPageSize(queryParam.getPageSize()); + + + //动态列组装 + List weaTableColumn = getColumnBuildService(user).buildCommonColumnsWithStyle(insuranceAccountDetailPOS, employeeId, SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY, queryParam.getPaymentStatus()); + + SalaryWeaTable table = new SalaryWeaTable<>(user, InsuranceAccountDetailPO.class); + table.setColumns(weaTableColumn); + List columns = weaTableColumn.stream().map(v -> new Column(v.getText(), v.getColumn(), v.getColumn())).collect(Collectors.toList()); + pageInfos.setColumns(columns); + + + 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 getForm(Map params) { + Map apidatas = new HashMap<>(); + + //条件组 + List addGroups = new ArrayList<>(); + List conditionItems = new ArrayList<>(); + SearchConditionItem datePickerItem = SalaryFormItemUtil.datePickerItem(user, 2, 16, true, 2, "账单月份", "billMonth"); + String minDate = SalaryDateUtil.getYearMonth(-1, 0); + String maxDate = SalaryDateUtil.getYearMonth(0, 6); + datePickerItem.setOtherParams(new HashMap<>()); + datePickerItem.getOtherParams().put("minDate", minDate); + datePickerItem.getOtherParams().put("maxDate", maxDate); + + List billMonthList = getInsuranceAccountBatchMapper().listByTimeRange(minDate, maxDate); + encryptUtil.decryptList(billMonthList, InsuranceAccountBatchPO.class); + 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, 2, 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 String save(AccountParam param) { +// ValidUtil.doValidator(param); +// +// Long employeeId = (long) user.getUID(); +// String lastName = user.getLastname(); +// return getSiAccountBiz(user).save(param.isFlag(), param, employeeId, lastName); + return saveAndFile(param); + } + + @Override + public void commonAccount(SaveCommonAccountParam param) { +// ValidUtil.doValidator(param); +// +// Long employeeId = (long) user.getUID(); +// String currentUserName = user.getLastname(); +// getSiAccountBiz(user).saveCommonAccount(param, employeeId, currentUserName); + siSaveCommonAccount(param); + } + + @Override + public void delete(AccountParam accountParam) { + Long employeeId = (long) user.getUID(); +// getSiAccountBiz(user).delete(accountParam, employeeId); + siDelete(accountParam); + } + + @Override + public void saveCommonAccount(SaveCommonAccountParam accountParam) { +// Long employeeId = (long) user.getUID(); +// String currentUserName = user.getLastname(); +// getSiAccountBiz(user).saveCommonAccount(accountParam, employeeId, currentUserName); + siSaveCommonAccount(accountParam); + } + + /** + * 福利台账正常缴纳页-核算 + */ + public void siSaveCommonAccount(SaveCommonAccountParam param) { + ValidUtil.doValidator(param); + + List collect; + SalaryAssert.notEmpty(param.getIncludes(), SalaryI18nUtil.getI18nLabel(100466, "参数为空")); + SalaryAssert.notNull(param.getBillMonth(), SalaryI18nUtil.getI18nLabel(100467, "账单月为空")); + if (CollectionUtils.isNotEmpty(param.getExcludes())) { + collect = param.getIncludes().stream().filter(item -> !param.getExcludes().contains(item)).collect(Collectors.toList()); + } else { + collect = param.getIncludes(); + } + SalaryAssert.notEmpty(collect, SalaryI18nUtil.getI18nLabel(99920, "无核算人员")); + AccountParam accountParam = new AccountParam(); + accountParam.setBillMonth(param.getBillMonth()); + accountParam.setIds(collect); + + //福利核算进度 + ProgressDTO salaryAcctProgressDTO = getSalaryAcctProgressService(user).getProgress(SalaryCacheKey.ACCT_PROGRESS + param.getBillMonth() + "_" + param.getPaymentOrganization()); + if (salaryAcctProgressDTO != null && salaryAcctProgressDTO.isStatus() && salaryAcctProgressDTO.getProgress().compareTo(BigDecimal.ONE) < 0) { + return; + } + // 初始化进度 + ProgressDTO initProgress = new ProgressDTO() + .setTitle(SalaryI18nUtil.getI18nLabel(0, "核算中")) + .setTitleLabelId(97515L) + .setTotalQuantity(2000) + .setCalculatedQuantity(NumberUtils.INTEGER_ZERO) + .setProgress(BigDecimal.ZERO) + .setStatus(true) + .setMessage(StringUtils.EMPTY); + getSalaryAcctProgressService(user).initProgress(SalaryCacheKey.ACCT_PROGRESS + param.getBillMonth() + "_" + param.getPaymentOrganization(), initProgress); + + siAccounting(accountParam); + } + + @Override + public void saveSupplementaryAccount(SaveSupplementaryAccountParam saveSupplementaryAccountParam) { + ValidUtil.doValidator(saveSupplementaryAccountParam); + +// Long employeeId = (long) user.getUID(); +// String currentUserName = user.getLastname(); +// getSiAccountBiz(user).saveSupplementaryAccount(saveSupplementaryAccountParam, employeeId, currentUserName); + siSaveSupplementaryAccount(saveSupplementaryAccountParam); + } + + @Override + public void deleteCommonAccount(SaveCommonAccountParam param) { + ValidUtil.doValidator(param); +// Long employeeId = (long) user.getUID(); +// String currentUserName = user.getLastname(); +// getSiAccountBiz(user).deleteCommonAccount(param, employeeId, currentUserName); + siDeleteCommonAccount(param); + } + + @Override + public void deleteSupplementaryAccount(SaveCommonAccountParam param) { +// Long employeeId = (long) user.getUID(); +// String currentUserName = user.getLastname(); +// getSiAccountBiz(user).deleteSupplementaryAccount(supplementAccountBaseParams, employeeId, currentUserName); + siDeleteSupplementaryAccount(param); + } + + @Override + public void file(AccountParam accountParam) { +// Long employeeId = (long) user.getUID(); +// String billMonth = accountParam.getBillMonth(); +// getSiAccountBiz(user).file(billMonth, employeeId, accountParam.getPaymentOrganization()); + siFile(accountParam.getBillMonth(), accountParam.getPaymentOrganization()); + } + + @Override + public void unconfirmed(Collection ids) { + List insuranceAccountInspectPOS = getInsuranceAccountInspectMapper().getByInspectStatusAndIds(InspectStatusEnum.COMFORED.getValue(), ids); + + if (CollectionUtils.isNotEmpty(insuranceAccountInspectPOS)) { + getInsuranceAccountDetailMapper().batchUnConfirmedInspectDetails(insuranceAccountInspectPOS.stream().map(InsuranceAccountInspectPO::getId).collect(Collectors.toList())); + } + } + + + @Override + public Map buttonCheck(String billMonth) { + Map result = new HashMap<>(); + List list = getInsuranceAccountInspectMapper().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 = getInsuranceAccountInspectMapper().getByInspectStatusAndIds(InspectStatusEnum.IGNORE.getValue(), ids); + + if (CollectionUtils.isNotEmpty(insuranceAccountInspectPOS)) { + getInsuranceAccountDetailMapper().batchIgnoreInspectDetails(insuranceAccountInspectPOS.stream().map(InsuranceAccountInspectPO::getId).collect(Collectors.toList())); + } + } + + @Override + public InsuranceAccountTabDTO tabList(AccountParam build) { + InsuranceAccountTabDTO insuranceAccountTabDTO = InsuranceAccountTabDTO.builder().build(); + InsuranceAccountBatchPO insuranceAccountBatchPO = getInsuranceAccountBatchMapper().getByBillMonth(build.getBillMonth(), build.getPaymentOrganization()); + insuranceAccountBatchPO = encryptUtil.decrypt(insuranceAccountBatchPO, InsuranceAccountBatchPO.class); + 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); + + Map recession = new HashMap<>(); + recession.put("id", "5"); + recession.put("content", SalaryI18nUtil.getI18nLabel(92270, "退差")); + tabList.add(recession); + + Map balance = new HashMap<>(); + balance.put("id", "6"); + balance.put("content", SalaryI18nUtil.getI18nLabel(92271, "补差")); + tabList.add(balance); + + insuranceAccountTabDTO.setTabList(tabList); + insuranceAccountTabDTO.setShow(isShow); + insuranceAccountTabDTO.setBillMonth(build.getBillMonth()); + return insuranceAccountTabDTO; + } + + @Override + public Map changeList(InsuranceAccountDetailParam param) { + Map datas = new HashMap<>(); + Long employeeId = (long) user.getUID(); + List insuranceArchivesEmployeePOS = getInsuranceAccountDetailMapper().changeList(param.getUserName()); + PageInfo pageInfo = SalaryPageUtil.buildPage(param.getCurrent(), param.getPageSize(), + insuranceArchivesEmployeePOS, InsuranceArchivesEmployeePO.class); + +// List> records = siArchivesBiz.buildTableData(insuranceArchivesEmployeePOS); + List> records = getSIArchivesService(user).buildTableData(insuranceArchivesEmployeePOS); + PageInfo> pageInfos = new PageInfo<>(records); + pageInfos.setTotal(pageInfo.getTotal()); + pageInfos.setPageNum(param.getCurrent()); + pageInfos.setPageSize(param.getPageSize()); + +// List weaTableColumns = siArchivesBiz.buildWeaTableColumns(insuranceArchivesEmployeePOS, employeeId); + List weaTableColumns = getSIArchivesService(user).buildWeaTableColumns(insuranceArchivesEmployeePOS); + + 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.getDefaultLabel().equals(records.get(i).get("status"))) { + permission.add(new Permission(true, false)); + permission.add(new Permission(false, false)); + permissions.add(permission); + } + if (UserStatusEnum.DEPARTURE.getDefaultLabel().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); +// String currentUserName = user.getLastname(); +// getSiAccountBiz(user).accountInspect(param.getIds(), param.getBillMonth(), employeeId, currentUserName, param.getPaymentOrganization()); + accountInspect(param.getIds(), param.getBillMonth(), param.getPaymentOrganization()); + } + + @Override + public Map getInspectTable(InsuranceAccountDetailParam param) { + Map datas = new HashMap<>(); + + List insuranceAccountInspectPOS = getInsuranceAccountInspectMapper().getByBillMonth(param.getBillMonth()); + List> records = getService(user).buildInspectRecords(insuranceAccountInspectPOS, Long.valueOf(param.getPaymentOrganization())); + List> paged = SalaryPageUtil.subList(param.getCurrent(), param.getPageSize(), records); + PageInfo> pageInfos = new PageInfo<>(paged); + pageInfos.setTotal(records.size()); + pageInfos.setPageNum(param.getCurrent()); + pageInfos.setPageSize(param.getPageSize()); + + List weaTableColumns = getColumnBuildService(user).buildInspectColumns(insuranceAccountInspectPOS, Long.valueOf(param.getPaymentOrganization())); + 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; + } + + @Override + public Map getCommonForm(Map params) { + Map apidatas = new HashMap<>(); + + //条件组 + List addGroups = new ArrayList<>(); + List conditionItems = new ArrayList<>(); + List conditionItem = new ArrayList<>(); + + SearchConditionItem includes = SalaryFormItemUtil.browserItem(user, 18, 12, 2, true, "对象", "required", "17", "includes"); + conditionItems.add(includes); + SearchConditionItem excludes = SalaryFormItemUtil.browserItem(user, 18, 12, 2, true, "选择人员", "required", "17", "excludes"); + conditionItem.add(excludes); + addGroups.add(new SearchConditionGroup("人员范围", true, conditionItems)); + addGroups.add(new SearchConditionGroup("人员范围排除", true, conditionItem)); + + apidatas.put("condition", addGroups); + return apidatas; + } + + @Override + public Map getSupplementaryForm(Map params) { + + + Map apidatas = new HashMap<>(); + + //条件组 + List addGroups = new ArrayList<>(); + List condition = new ArrayList<>(); + List conditionItems = new ArrayList<>(); + List conditionItem = new ArrayList<>(); + + SearchConditionItem billMonthList = SalaryFormItemUtil.datePickerItem(user, 2, 16, true, 2, "补缴月份", "billMonth"); + billMonthList.setMultiple(true); + billMonthList.setOtherParams(new HashMap<>()); + billMonthList.getOtherParams().put("type", "months"); + billMonthList.getOtherParams().put("format", "YYYY-MM"); + billMonthList.getOtherParams().put("showFormat", "YYYY-MM"); + billMonthList.setMultiple(true); + billMonthList.setViewAttr(3); + billMonthList.setRules("required"); + condition.add(billMonthList); + + SearchConditionItem billProjects = SalaryFormItemUtil.selectItem(user, buildBillProjectsOptions(), 2, 16, 6, true, "补缴项目", "projects"); + billProjects.setViewAttr(3); + billProjects.setDetailtype(2); + billProjects.setRules("required"); + condition.add(billProjects); + + SearchConditionItem includes = SalaryFormItemUtil.browserItem(user, 18, 6, 3, true, "对象", "required", "17", "includes"); + conditionItems.add(includes); +// SearchConditionItem excludes = SalaryFormItemUtil.browserItem(user, 18, 6, 2, true, "选择人员", "required", "17", "excludes"); +// excludes.setViewAttr(2); +// conditionItem.add(excludes); + addGroups.add(new SearchConditionGroup("基础信息", true, condition)); + addGroups.add(new SearchConditionGroup("人员范围", true, conditionItems)); +// addGroups.add(new SearchConditionGroup("人员范围排除",true,conditionItem)); + + apidatas.put("condition", addGroups); + return apidatas; + } + + @Override + public PageInfo overView(InsuranceAccountDetailParam queryParam) { +// PageInfo pageInfos = getSiAccountBiz(user).overView(queryParam); + PageInfo pageInfos = siOverView(queryParam); + return pageInfos; + } + + @Override + public List> welfareData(String billMonth, List employeeIds, Long taxAgentId) { + InsuranceAccountBatchPO insuranceAccountBatchPO = getInsuranceAccountBatchMapper().getByBillMonth(billMonth, taxAgentId); + insuranceAccountBatchPO = encryptUtil.decrypt(insuranceAccountBatchPO, InsuranceAccountBatchPO.class); + if (insuranceAccountBatchPO == null || Objects.equals(BillStatusEnum.NOT_ARCHIVED.getValue(), insuranceAccountBatchPO.getBillStatus())) { + return Lists.newArrayList(); + } + + //20230707增加福利核算明细中的缴纳状态+合计的数据项 +// List insuranceAccountDetailPOS = getInsuranceAccountDetailMapper().queryList(billMonth, taxAgentId, employeeIds); + + List insuranceAccountDetailPOS = new ArrayList<>(); + List> empIdsPart = Lists.partition((List) employeeIds, 500); + for (List part : empIdsPart) { + insuranceAccountDetailPOS.addAll( + getInsuranceAccountDetailMapper().queryList(billMonth, taxAgentId, part)); + } + + //退差数据不参与薪资核算 + insuranceAccountDetailPOS = insuranceAccountDetailPOS.stream() + .filter(f -> f.getPaymentStatus().equals(PaymentStatusEnum.COMMON.getValue()) + || f.getPaymentStatus().equals(PaymentStatusEnum.REPAIR.getValue()) + || f.getPaymentStatus().equals(PaymentStatusEnum.BALANCE.getValue()) ) + .collect(Collectors.toList()); + List list = buildNewInsuranceDetailPOS(insuranceAccountDetailPOS); + Map siAcctResultWithEmpAndPayStatus = insuranceAccountDetailPOS.stream() + .collect(Collectors.toMap(po -> po.getEmployeeId() + "_" + po.getPaymentStatus(), a -> a, (a, b) -> a)); + + + List> result = new ArrayList<>(); + list.stream().forEach(item -> { + Map record = new HashMap<>(); + record.put("employeeId", item.getEmployeeId()); + record.put("taxAgentId", taxAgentId); + if (StringUtils.isNotEmpty(item.getSocialPerJson())) { + Map socialJson = JSON.parseObject(item.getSocialPerJson(), new HashMap().getClass()); + socialJson.forEach((k, v) -> { + record.put(k + "socialPer", v); + }); + } + if (StringUtils.isNotEmpty(item.getSocialComJson())) { + Map socialJson = JSON.parseObject(item.getSocialComJson(), new HashMap().getClass()); + socialJson.forEach((k, v) -> { + record.put(k + "socialCom", v); + }); + } + record.put("socialPerSum", item.getSocialPerSum()); + record.put("socialComSum", item.getSocialComSum()); + if (StringUtils.isNotEmpty(item.getFundPerJson())) { + Map fundPerJson = JSON.parseObject(item.getFundPerJson(), new HashMap().getClass()); + fundPerJson.forEach((k, v) -> { + record.put(k + "fundPer", v); + }); + } + if (StringUtils.isNotEmpty(item.getFundComJson())) { + Map fundPerJson = JSON.parseObject(item.getFundComJson(), new HashMap().getClass()); + fundPerJson.forEach((k, v) -> { + record.put(k + "fundCom", v); + }); + } + record.put("fundPerSum", item.getFundPerSum()); + record.put("fundComSum", item.getFundComSum()); + if (StringUtils.isNotEmpty(item.getOtherPerJson())) { + Map fundPerJson = JSON.parseObject(item.getOtherPerJson(), new HashMap().getClass()); + fundPerJson.forEach((k, v) -> { + record.put(k + "otherPer", v); + }); + } + if (StringUtils.isNotEmpty(item.getOtherComJson())) { + Map fundComJson = JSON.parseObject(item.getOtherComJson(), new HashMap().getClass()); + if (fundComJson != null) { + + } + fundComJson.forEach((k, v) -> { + record.put(k + "otherCom", v); + }); + } + record.put("otherPerSum", item.getOtherPerSum()); + record.put("otherComSum", item.getOtherComSum()); + record.put("perSum", item.getPerSum()); + record.put("comSum", item.getComSum()); + + //20230707增加福利核算明细中的缴纳状态+合计的数据项、缴纳状态+福利项的数据项 + InsuranceAccountDetailPO commonSiAcct = siAcctResultWithEmpAndPayStatus.get(item.getEmployeeId() + "_" + PaymentStatusEnum.COMMON.getValue()); + InsuranceAccountDetailPO repairSiAcct = siAcctResultWithEmpAndPayStatus.get(item.getEmployeeId() + "_" + PaymentStatusEnum.REPAIR.getValue()); + InsuranceAccountDetailPO balanceSiAcct = siAcctResultWithEmpAndPayStatus.get(item.getEmployeeId() + "_" + PaymentStatusEnum.BALANCE.getValue()); + //取正常缴纳的福利基数信息 + if (commonSiAcct != null && StringUtils.isNotEmpty(commonSiAcct.getSocialPaymentBaseString())) { + Map socialBaseJson = JSON.parseObject(commonSiAcct.getSocialPaymentBaseString(), new HashMap().getClass()); + socialBaseJson.forEach((k, v) -> { + record.put(k + "socialBase", v); + }); + } + if (commonSiAcct != null && StringUtils.isNotEmpty(commonSiAcct.getFundPaymentBaseString())) { + Map fundBaseJson = JSON.parseObject(commonSiAcct.getFundPaymentBaseString(), new HashMap().getClass()); + fundBaseJson.forEach((k, v) -> { + record.put(k + "fundBase", v); + }); + } + if (commonSiAcct != null && StringUtils.isNotEmpty(commonSiAcct.getOtherPaymentBaseString())) { + Map otherBaseJson = JSON.parseObject(commonSiAcct.getOtherPaymentBaseString(), new HashMap().getClass()); + otherBaseJson.forEach((k, v) -> { + record.put(k + "otherBase", v); + }); + } + //社保-正常缴纳 + if (commonSiAcct != null && StringUtils.isNotEmpty(commonSiAcct.getSocialPerJson())) { + Map socialJson = JSON.parseObject(commonSiAcct.getSocialPerJson(), new HashMap().getClass()); + socialJson.forEach((k, v) -> { + record.put(k + "socialCommonPer", v); + }); + } + if (commonSiAcct != null && StringUtils.isNotEmpty(commonSiAcct.getSocialComJson())) { + Map socialJson = JSON.parseObject(commonSiAcct.getSocialComJson(), new HashMap().getClass()); + socialJson.forEach((k, v) -> { + record.put(k + "socialCommonCom", v); + }); + } + record.put("socialPerCommonSum", commonSiAcct != null ? commonSiAcct.getSocialPerSum() : new BigDecimal("0")); + record.put("socialComCommonSum", commonSiAcct != null ? commonSiAcct.getSocialComSum() : new BigDecimal("0")); + //社保-补缴 + if (repairSiAcct != null && StringUtils.isNotEmpty(repairSiAcct.getSocialPerJson())) { + Map socialJson = JSON.parseObject(repairSiAcct.getSocialPerJson(), new HashMap().getClass()); + socialJson.forEach((k, v) -> { + record.put(k + "socialRepairPer", v); + }); + } + if (repairSiAcct != null && StringUtils.isNotEmpty(repairSiAcct.getSocialComJson())) { + Map socialJson = JSON.parseObject(repairSiAcct.getSocialComJson(), new HashMap().getClass()); + socialJson.forEach((k, v) -> { + record.put(k + "socialRepairCom", v); + }); + } + record.put("socialPerRepairSum", repairSiAcct != null ? repairSiAcct.getSocialPerSum() : new BigDecimal("0")); + record.put("socialComRepairSum", repairSiAcct != null ? repairSiAcct.getSocialComSum() : new BigDecimal("0")); + //社保-补差 + if (balanceSiAcct != null && StringUtils.isNotEmpty(balanceSiAcct.getSocialPerJson())) { + Map socialJson = JSON.parseObject(balanceSiAcct.getSocialPerJson(), new HashMap().getClass()); + socialJson.forEach((k, v) -> { + record.put(k + "socialBalancePer", v); + }); + } + if (balanceSiAcct != null && StringUtils.isNotEmpty(balanceSiAcct.getSocialComJson())) { + Map socialJson = JSON.parseObject(balanceSiAcct.getSocialComJson(), new HashMap().getClass()); + socialJson.forEach((k, v) -> { + record.put(k + "socialBalanceCom", v); + }); + } + record.put("socialPerBalanceSum", balanceSiAcct != null ? balanceSiAcct.getSocialPerSum() : new BigDecimal("0")); + record.put("socialComBalanceSum", balanceSiAcct != null ? balanceSiAcct.getSocialComSum() : new BigDecimal("0")); + + //公积金-正常缴纳 + if (commonSiAcct != null && StringUtils.isNotEmpty(commonSiAcct.getFundPerJson())) { + Map socialJson = JSON.parseObject(commonSiAcct.getFundPerJson(), new HashMap().getClass()); + socialJson.forEach((k, v) -> { + record.put(k + "fundCommonPer", v); + }); + } + if (commonSiAcct != null && StringUtils.isNotEmpty(commonSiAcct.getFundComJson())) { + Map socialJson = JSON.parseObject(commonSiAcct.getFundComJson(), new HashMap().getClass()); + socialJson.forEach((k, v) -> { + record.put(k + "fundCommonCom", v); + }); + } + record.put("fundPerCommonSum", commonSiAcct != null ? commonSiAcct.getFundPerSum() : new BigDecimal("0")); + record.put("fundComCommonSum", commonSiAcct != null ? commonSiAcct.getFundComSum() : new BigDecimal("0")); + //公积金-补缴 + if (repairSiAcct != null && StringUtils.isNotEmpty(repairSiAcct.getFundPerJson())) { + Map fundJson = JSON.parseObject(repairSiAcct.getFundPerJson(), new HashMap().getClass()); + fundJson.forEach((k, v) -> { + record.put(k + "fundRepairPer", v); + }); + } + if (repairSiAcct != null && StringUtils.isNotEmpty(repairSiAcct.getFundComJson())) { + Map fundJson = JSON.parseObject(repairSiAcct.getFundComJson(), new HashMap().getClass()); + fundJson.forEach((k, v) -> { + record.put(k + "fundRepairCom", v); + }); + } + record.put("fundPerRepairSum", repairSiAcct != null ? repairSiAcct.getFundPerSum() : new BigDecimal("0")); + record.put("fundComRepairSum", repairSiAcct != null ? repairSiAcct.getFundComSum() : new BigDecimal("0")); + //公积金-补差 + if (balanceSiAcct != null && StringUtils.isNotEmpty(balanceSiAcct.getFundPerJson())) { + Map fundJson = JSON.parseObject(balanceSiAcct.getFundPerJson(), new HashMap().getClass()); + fundJson.forEach((k, v) -> { + record.put(k + "fundBalancePer", v); + }); + } + if (balanceSiAcct != null && StringUtils.isNotEmpty(balanceSiAcct.getFundComJson())) { + Map fundJson = JSON.parseObject(balanceSiAcct.getFundComJson(), new HashMap().getClass()); + fundJson.forEach((k, v) -> { + record.put(k + "fundBalanceCom", v); + }); + } + record.put("fundPerBalanceSum", balanceSiAcct != null ? balanceSiAcct.getFundPerSum() : new BigDecimal("0")); + record.put("fundComBalanceSum", balanceSiAcct != null ? balanceSiAcct.getFundComSum() : new BigDecimal("0")); + + //其他福利-正常缴纳 + if (commonSiAcct != null && StringUtils.isNotEmpty(commonSiAcct.getOtherPerJson())) { + Map otherJson = JSON.parseObject(commonSiAcct.getOtherPerJson(), new HashMap().getClass()); + otherJson.forEach((k, v) -> { + record.put(k + "otherCommonPer", v); + }); + } + if (commonSiAcct != null && StringUtils.isNotEmpty(commonSiAcct.getOtherComJson())) { + Map otherJson = JSON.parseObject(commonSiAcct.getOtherComJson(), new HashMap().getClass()); + otherJson.forEach((k, v) -> { + record.put(k + "otherCommonCom", v); + }); + } + record.put("otherPerCommonSum", commonSiAcct != null ? commonSiAcct.getOtherPerSum() : new BigDecimal("0")); + record.put("otherComCommonSum", commonSiAcct != null ? commonSiAcct.getOtherComSum() : new BigDecimal("0")); + //其他福利-补缴 + if (repairSiAcct != null && StringUtils.isNotEmpty(repairSiAcct.getOtherPerJson())) { + Map otherJson = JSON.parseObject(repairSiAcct.getOtherPerJson(), new HashMap().getClass()); + otherJson.forEach((k, v) -> { + record.put(k + "otherRepairPer", v); + }); + } + if (repairSiAcct != null && StringUtils.isNotEmpty(repairSiAcct.getOtherComJson())) { + Map otherJson = JSON.parseObject(repairSiAcct.getOtherComJson(), new HashMap().getClass()); + otherJson.forEach((k, v) -> { + record.put(k + "otherRepairCom", v); + }); + } + record.put("otherPerRepairSum", repairSiAcct != null ? repairSiAcct.getOtherPerSum() : new BigDecimal("0")); + record.put("otherComRepairSum", repairSiAcct != null ? repairSiAcct.getOtherComSum() : new BigDecimal("0")); + //其他福利-补差 + if (balanceSiAcct != null && StringUtils.isNotEmpty(balanceSiAcct.getOtherPerJson())) { + Map otherJson = JSON.parseObject(balanceSiAcct.getOtherPerJson(), new HashMap().getClass()); + otherJson.forEach((k, v) -> { + record.put(k + "otherBalancePer", v); + }); + } + if (balanceSiAcct != null && StringUtils.isNotEmpty(balanceSiAcct.getOtherComJson())) { + Map otherJson = JSON.parseObject(balanceSiAcct.getOtherComJson(), new HashMap().getClass()); + otherJson.forEach((k, v) -> { + record.put(k + "otherBalanceCom", v); + }); + } + record.put("otherPerBalanceSum", balanceSiAcct != null ? balanceSiAcct.getOtherPerSum() : new BigDecimal("0")); + record.put("otherComBalanceSum", balanceSiAcct != null ? balanceSiAcct.getOtherComSum() : new BigDecimal("0")); + + record.put("perCommonSum", commonSiAcct != null ? commonSiAcct.getPerSum() : new BigDecimal("0")); + record.put("comCommonSum", commonSiAcct != null ? commonSiAcct.getComSum() : new BigDecimal("0")); + record.put("perRepairSum", repairSiAcct != null ? repairSiAcct.getPerSum() : new BigDecimal("0")); + record.put("comRepairSum", repairSiAcct != null ? repairSiAcct.getComSum() : new BigDecimal("0")); + record.put("perBalanceSum", balanceSiAcct != null ? balanceSiAcct.getPerSum() : new BigDecimal("0")); + record.put("comBalanceSum", balanceSiAcct != null ? balanceSiAcct.getComSum() : new BigDecimal("0")); + + result.add(record); + }); + return result; + } + + @Override + public Map welfareColumns() { + List listAll = getICategoryMapper().listAll().stream().filter(f -> f.getIsUse().equals(IsUseEnum.START.getValue())).collect(Collectors.toList()); + List list = new ArrayList<>(); + if (CollectionUtils.isNotEmpty(listAll)) { + list.addAll(listAll); + } + + Map result = new LinkedHashMap<>(); + + Map commonResult = new LinkedHashMap<>(); + Map repairResult = new LinkedHashMap<>(); + Map balanceResult = new LinkedHashMap<>(); + Map baseResult = new LinkedHashMap<>(); + + result.put(SalaryI18nUtil.getI18nLabel(100393, "个人合计"), "perSum"); + result.put(SalaryI18nUtil.getI18nLabel(100388, "社保个人合计"), "socialPerSum"); + result.put(SalaryI18nUtil.getI18nLabel(100390, "公积金个人合计"), "fundPerSum"); + result.put(SalaryI18nUtil.getI18nLabel(100392, "其他福利个人合计"), "otherPerSum"); + + commonResult.put(SalaryI18nUtil.getI18nLabel(0, "个人正常缴纳合计"), "perCommonSum"); + commonResult.put(SalaryI18nUtil.getI18nLabel(0, "社保个人正常缴纳合计"), "socialPerCommonSum"); + commonResult.put(SalaryI18nUtil.getI18nLabel(0, "公积金个人正常缴纳合计"), "fundPerCommonSum"); + commonResult.put(SalaryI18nUtil.getI18nLabel(0, "其他福利个人正常缴纳合计"), "otherPerCommonSum"); + repairResult.put(SalaryI18nUtil.getI18nLabel(0, "个人补缴合计"), "perRepairSum"); + repairResult.put(SalaryI18nUtil.getI18nLabel(0, "社保个人补缴合计"), "socialPerRepairSum"); + repairResult.put(SalaryI18nUtil.getI18nLabel(0, "公积金个人补缴合计"), "fundPerRepairSum"); + repairResult.put(SalaryI18nUtil.getI18nLabel(0, "其他福利个人补缴合计"), "otherPerRepairSum"); + balanceResult.put(SalaryI18nUtil.getI18nLabel(0, "个人补差合计"), "perBalanceSum"); + balanceResult.put(SalaryI18nUtil.getI18nLabel(0, "社保个人补差合计"), "socialPerBalanceSum"); + balanceResult.put(SalaryI18nUtil.getI18nLabel(0, "公积金个人补差合计"), "fundPerBalanceSum"); + balanceResult.put(SalaryI18nUtil.getI18nLabel(0, "其他福利个人补差合计"), "otherPerBalanceSum"); + + Map categoryIdNameMap = getSICategoryService(user).categoryIdNameMap(); + list.stream().forEach(item -> { + if (Objects.equals(WelfareTypeEnum.SOCIAL_SECURITY.getValue(), item.getWelfareType())) { + if (Objects.equals(DataTypeEnum.SYSTEM.getValue(), item.getDataType())) { + baseResult.put(categoryIdNameMap.get(String.valueOf(item.getId())) + SalaryI18nUtil.getI18nLabel(0, "申报基数"), item.getId() + "socialBase"); + } + result.put(categoryIdNameMap.get(String.valueOf(item.getId())) + SalaryI18nUtil.getI18nLabel(87159, "个人"), item.getId() + "socialPer"); + commonResult.put(categoryIdNameMap.get(String.valueOf(item.getId())) + SalaryI18nUtil.getI18nLabel(0, "正常缴纳个人"), item.getId() + "socialCommonPer"); + repairResult.put(categoryIdNameMap.get(String.valueOf(item.getId())) + SalaryI18nUtil.getI18nLabel(0, "补缴个人"), item.getId() + "socialRepairPer"); + balanceResult.put(categoryIdNameMap.get(String.valueOf(item.getId())) + SalaryI18nUtil.getI18nLabel(0, "补差个人"), item.getId() + "socialBalancePer"); + } + if (Objects.equals(WelfareTypeEnum.ACCUMULATION_FUND.getValue(), item.getWelfareType())) { + if (Objects.equals(DataTypeEnum.SYSTEM.getValue(), item.getDataType())) { + baseResult.put(categoryIdNameMap.get(String.valueOf(item.getId())) + SalaryI18nUtil.getI18nLabel(0, "申报基数"), item.getId() + "fundBase"); + } + result.put(categoryIdNameMap.get(String.valueOf(item.getId())) + SalaryI18nUtil.getI18nLabel(87159, "个人"), item.getId() + "fundPer"); + commonResult.put(categoryIdNameMap.get(String.valueOf(item.getId())) + SalaryI18nUtil.getI18nLabel(0, "正常缴纳个人"), item.getId() + "fundCommonPer"); + repairResult.put(categoryIdNameMap.get(String.valueOf(item.getId())) + SalaryI18nUtil.getI18nLabel(0, "补缴个人"), item.getId() + "fundRepairPer"); + balanceResult.put(categoryIdNameMap.get(String.valueOf(item.getId())) + SalaryI18nUtil.getI18nLabel(0, "补差个人"), item.getId() + "fundBalancePer"); + } + if (Objects.equals(WelfareTypeEnum.OTHER.getValue(), item.getWelfareType())) { + if (Objects.equals(DataTypeEnum.SYSTEM.getValue(), item.getDataType())) { + baseResult.put(categoryIdNameMap.get(String.valueOf(item.getId())) + SalaryI18nUtil.getI18nLabel(0, "申报基数"), item.getId() + "otherBase"); + } + result.put(categoryIdNameMap.get(String.valueOf(item.getId())) + SalaryI18nUtil.getI18nLabel(87159, "个人"), item.getId() + "otherPer"); + commonResult.put(categoryIdNameMap.get(String.valueOf(item.getId())) + SalaryI18nUtil.getI18nLabel(0, "正常缴纳个人"), item.getId() + "otherCommonPer"); + repairResult.put(categoryIdNameMap.get(String.valueOf(item.getId())) + SalaryI18nUtil.getI18nLabel(0, "补缴个人"), item.getId() + "otherRepairPer"); + balanceResult.put(categoryIdNameMap.get(String.valueOf(item.getId())) + SalaryI18nUtil.getI18nLabel(0, "补差个人"), item.getId() + "otherBalancePer"); + } + + }); + result.put(SalaryI18nUtil.getI18nLabel(100397, "单位合计"), "comSum"); + result.put(SalaryI18nUtil.getI18nLabel(100394, "社保单位合计"), "socialComSum"); + result.put(SalaryI18nUtil.getI18nLabel(100395, "公积金单位合计"), "fundComSum"); + result.put(SalaryI18nUtil.getI18nLabel(100396, "其他福利单位合计"), "otherComSum"); + + commonResult.put(SalaryI18nUtil.getI18nLabel(0, "单位正常缴纳合计"), "comCommonSum"); + commonResult.put(SalaryI18nUtil.getI18nLabel(0, "社保单位正常缴纳合计"), "socialComCommonSum"); + commonResult.put(SalaryI18nUtil.getI18nLabel(0, "公积金单位正常缴纳合计"), "fundComCommonSum"); + commonResult.put(SalaryI18nUtil.getI18nLabel(0, "其他福利单位正常缴纳合计"), "otherComCommonSum"); + repairResult.put(SalaryI18nUtil.getI18nLabel(0, "单位补缴合计"), "comRepairSum"); + repairResult.put(SalaryI18nUtil.getI18nLabel(0, "社保单位补缴合计"), "socialComRepairSum"); + repairResult.put(SalaryI18nUtil.getI18nLabel(0, "公积金单位补缴合计"), "fundComRepairSum"); + repairResult.put(SalaryI18nUtil.getI18nLabel(0, "其他福利单位补缴合计"), "otherComRepairSum"); + balanceResult.put(SalaryI18nUtil.getI18nLabel(0, "单位补差合计"), "comBalanceSum"); + balanceResult.put(SalaryI18nUtil.getI18nLabel(0, "社保单位补差合计"), "socialComBalanceSum"); + balanceResult.put(SalaryI18nUtil.getI18nLabel(0, "公积金单位补差合计"), "fundComBalanceSum"); + balanceResult.put(SalaryI18nUtil.getI18nLabel(0, "其他福利单位补差合计"), "otherComBalanceSum"); + + list.stream().forEach(item -> { + if (Objects.equals(WelfareTypeEnum.SOCIAL_SECURITY.getValue(), item.getWelfareType())) { + result.put(categoryIdNameMap.get(String.valueOf(item.getId())) + SalaryI18nUtil.getI18nLabel(100289, "单位"), item.getId() + "socialCom"); + commonResult.put(categoryIdNameMap.get(String.valueOf(item.getId())) + SalaryI18nUtil.getI18nLabel(0, "正常缴纳单位"), item.getId() + "socialCommonCom"); + repairResult.put(categoryIdNameMap.get(String.valueOf(item.getId())) + SalaryI18nUtil.getI18nLabel(0, "补缴单位"), item.getId() + "socialRepairCom"); + balanceResult.put(categoryIdNameMap.get(String.valueOf(item.getId())) + SalaryI18nUtil.getI18nLabel(0, "补差单位"), item.getId() + "socialBalanceCom"); + } + if (Objects.equals(WelfareTypeEnum.ACCUMULATION_FUND.getValue(), item.getWelfareType())) { + result.put(categoryIdNameMap.get(String.valueOf(item.getId())) + SalaryI18nUtil.getI18nLabel(100289, "单位"), item.getId() + "fundCom"); + commonResult.put(categoryIdNameMap.get(String.valueOf(item.getId())) + SalaryI18nUtil.getI18nLabel(0, "正常缴纳单位"), item.getId() + "fundCommonCom"); + repairResult.put(categoryIdNameMap.get(String.valueOf(item.getId())) + SalaryI18nUtil.getI18nLabel(0, "补缴单位"), item.getId() + "fundRepairCom"); + balanceResult.put(categoryIdNameMap.get(String.valueOf(item.getId())) + SalaryI18nUtil.getI18nLabel(0, "补差单位"), item.getId() + "fundBalanceCom"); + } + if (Objects.equals(WelfareTypeEnum.OTHER.getValue(), item.getWelfareType())) { + result.put(categoryIdNameMap.get(String.valueOf(item.getId())) + SalaryI18nUtil.getI18nLabel(100289, "单位"), item.getId() + "otherCom"); + commonResult.put(categoryIdNameMap.get(String.valueOf(item.getId())) + SalaryI18nUtil.getI18nLabel(0, "正常缴纳单位"), item.getId() + "otherCommonCom"); + repairResult.put(categoryIdNameMap.get(String.valueOf(item.getId())) + SalaryI18nUtil.getI18nLabel(0, "补缴单位"), item.getId() + "otherRepairCom"); + balanceResult.put(categoryIdNameMap.get(String.valueOf(item.getId())) + SalaryI18nUtil.getI18nLabel(0, "补差单位"), item.getId() + "otherBalanceCom"); + } + }); + + result.putAll(baseResult); + result.putAll(commonResult); + result.putAll(repairResult); + result.putAll(balanceResult); + return result; + } + + + public List buildBillProjectsOptions() { + List options = new ArrayList<>(); + options.add(new SearchConditionOption(String.valueOf(ProjectTypeEnum.ALL.getValue()), + SalaryI18nUtil.getI18nLabel(ProjectTypeEnum.ALL.getLabelId(), ProjectTypeEnum.ALL.getDefaultLabel()))); + options.add(new SearchConditionOption(String.valueOf(ProjectTypeEnum.SOCIAL.getValue()), + SalaryI18nUtil.getI18nLabel(ProjectTypeEnum.SOCIAL.getLabelId(), ProjectTypeEnum.SOCIAL.getDefaultLabel()))); + options.add(new SearchConditionOption(String.valueOf(ProjectTypeEnum.FUND.getValue()), + SalaryI18nUtil.getI18nLabel(ProjectTypeEnum.FUND.getLabelId(), ProjectTypeEnum.FUND.getDefaultLabel()))); + options.add(new SearchConditionOption(String.valueOf(ProjectTypeEnum.OTHER.getValue()), + SalaryI18nUtil.getI18nLabel(ProjectTypeEnum.OTHER.getLabelId(), ProjectTypeEnum.OTHER.getDefaultLabel()))); + options.add(new SearchConditionOption(String.valueOf(ProjectTypeEnum.ENDOWMENT_INSURANCE.getValue()), + SalaryI18nUtil.getI18nLabel(ProjectTypeEnum.ENDOWMENT_INSURANCE.getLabelId(), ProjectTypeEnum.ENDOWMENT_INSURANCE.getDefaultLabel()))); + options.add(new SearchConditionOption(String.valueOf(ProjectTypeEnum.MEDICAL_INSURANCE.getValue()), + SalaryI18nUtil.getI18nLabel(ProjectTypeEnum.MEDICAL_INSURANCE.getLabelId(), ProjectTypeEnum.MEDICAL_INSURANCE.getDefaultLabel()))); + return options; + } + + + public List queryList(String billMonth, Long taxAgentId, List employeeIds) { + List insuranceAccountDetailPOS = getInsuranceAccountDetailMapper().queryList(billMonth, taxAgentId, employeeIds); + //退差数据不参与薪资核算 + insuranceAccountDetailPOS = insuranceAccountDetailPOS.stream() + .filter(f -> f.getPaymentStatus().equals(PaymentStatusEnum.COMMON.getValue()) + || f.getPaymentStatus().equals(PaymentStatusEnum.REPAIR.getValue()) + || f.getPaymentStatus().equals(PaymentStatusEnum.BALANCE.getValue()) ) + .collect(Collectors.toList()); + List list = buildNewInsuranceDetailPOS(insuranceAccountDetailPOS); +// InsuranceAccountDetailPOEncrypt.decryptInsuranceAccountDetailPOList(list); + return list; + } + + public List buildNewInsuranceDetailPOS(List list) { + List newList = new ArrayList<>(); + if (CollectionUtils.isEmpty(list)) { + return newList; + } + Map> employeeMap = list.stream().filter(item -> item.getEmployeeId() != null) + .collect(Collectors.groupingBy(InsuranceAccountDetailPO::getEmployeeId)); + for (Map.Entry> entry : employeeMap.entrySet()) { + Long k = entry.getKey(); + List v = entry.getValue(); + InsuranceAccountDetailPO insuranceAccountDetailPO = new InsuranceAccountDetailPO(); + insuranceAccountDetailPO.setEmployeeId(k); + Map socialPerMap = new HashMap<>(); + Map fundPerMap = new HashMap<>(); + Map otherPerMap = new HashMap<>(); + Map socialComMap = new HashMap<>(); + Map fundComMap = new HashMap<>(); + Map otherComMap = new HashMap<>(); + BigDecimal socialPer = new BigDecimal("0"); + BigDecimal socialCom = new BigDecimal("0"); + BigDecimal fundPer = new BigDecimal("0"); + BigDecimal fundCom = new BigDecimal("0"); + BigDecimal otherPer = new BigDecimal("0"); + BigDecimal otherCom = new BigDecimal("0"); + BigDecimal perSum = new BigDecimal("0"); + BigDecimal comSum = new BigDecimal("0"); + for (InsuranceAccountDetailPO item : v) { + encryptUtil.decrypt(item, InsuranceAccountDetailPO.class); + insuranceAccountDetailPO.setId(item.getId()); + insuranceAccountDetailPO.setSocialPaymentBaseString(item.getSocialPaymentBaseString()); + insuranceAccountDetailPO.setFundPaymentBaseString(item.getFundPaymentBaseString()); + insuranceAccountDetailPO.setOtherPaymentBaseString(item.getOtherPaymentBaseString()); + BigDecimal socialPerSum = StringUtils.isBlank(item.getSocialPerSum()) ? new BigDecimal("0") : new BigDecimal(item.getSocialPerSum()); + BigDecimal socialComSum = StringUtils.isBlank(item.getSocialComSum()) ? new BigDecimal("0") : new BigDecimal(item.getSocialComSum()); + BigDecimal fundPerSum = StringUtils.isBlank(item.getFundPerSum()) ? new BigDecimal("0") : new BigDecimal(item.getFundPerSum()); + BigDecimal fundComSum = StringUtils.isBlank(item.getFundComSum()) ? new BigDecimal("0") : new BigDecimal(item.getFundComSum()); + BigDecimal otherPerSum = StringUtils.isBlank(item.getOtherPerSum()) ? new BigDecimal("0") : new BigDecimal(item.getOtherPerSum()); + BigDecimal otherComSum = StringUtils.isBlank(item.getOtherComSum()) ? new BigDecimal("0") : new BigDecimal(item.getOtherComSum()); + BigDecimal perSumItem = StringUtils.isBlank(item.getPerSum()) ? new BigDecimal("0") : new BigDecimal(item.getPerSum()); + BigDecimal comSumItem = StringUtils.isBlank(item.getComSum()) ? new BigDecimal("0") : new BigDecimal(item.getComSum()); + socialPer = socialPer.add(socialPerSum); + socialCom = socialCom.add(socialComSum); + fundPer = fundPer.add(fundPerSum); + fundCom = fundCom.add(fundComSum); + otherPer = otherPer.add(otherPerSum); + otherCom = otherCom.add(otherComSum); + perSum = perSum.add(perSumItem); + comSum = comSum.add(comSumItem); + if (StringUtils.isNotBlank(item.getSocialPerJson())) { + Map socialJson = JSON.parseObject(item.getSocialPerJson(), new HashMap().getClass()); + if (socialJson != null) { + socialJson.forEach((insuranceId, num) -> { + if (socialPerMap.get(insuranceId) == null) { + socialPerMap.put(insuranceId, num); + } else { + String oldNum = socialPerMap.get(insuranceId); + BigDecimal insuanceNum = new BigDecimal("0"); + BigDecimal oldDecimal = new BigDecimal(oldNum); + BigDecimal numDecimal = num == null ? new BigDecimal("0") : new BigDecimal(num); + insuanceNum = insuanceNum.add(numDecimal).add(oldDecimal); + socialPerMap.put(insuranceId, insuanceNum.toPlainString()); + } + }); + } + + } + if (StringUtils.isNotBlank(item.getSocialComJson())) { + Map socialJson = JSON.parseObject(item.getSocialComJson(), new HashMap().getClass()); + if (socialJson != null) { + socialJson.forEach((insuranceId, num) -> { + if (socialComMap.get(insuranceId) == null) { + socialComMap.put(insuranceId, num); + } else { + String oldNum = socialComMap.get(insuranceId); + BigDecimal insuanceNum = new BigDecimal("0"); + BigDecimal oldDecimal = new BigDecimal(oldNum); + BigDecimal numDecimal = num == null ? new BigDecimal("0") : new BigDecimal(num); + insuanceNum = insuanceNum.add(numDecimal).add(oldDecimal); + socialComMap.put(insuranceId, insuanceNum.toPlainString()); + } + }); + } + + } + if (StringUtils.isNotBlank(item.getFundPerJson())) { + Map fundJson = JSON.parseObject(item.getFundPerJson(), new HashMap().getClass()); + if (fundJson != null) { + fundJson.forEach((insuranceId, num) -> { + if (fundPerMap.get(insuranceId) == null) { + fundPerMap.put(insuranceId, num); + } else { + String oldNum = fundPerMap.get(insuranceId); + BigDecimal insuanceNum = new BigDecimal("0"); + BigDecimal oldDecimal = new BigDecimal(oldNum); + BigDecimal numDecimal = num == null ? new BigDecimal("0") : new BigDecimal(num); + insuanceNum = insuanceNum.add(numDecimal).add(oldDecimal); + fundPerMap.put(insuranceId, insuanceNum.toPlainString()); + } + }); + } + + } + if (StringUtils.isNotBlank(item.getFundComJson())) { + Map fundJson = JSON.parseObject(item.getFundComJson(), new HashMap().getClass()); + if (fundJson != null) { + fundJson.forEach((insuranceId, num) -> { + if (fundComMap.get(insuranceId) == null) { + fundComMap.put(insuranceId, num); + } else { + String oldNum = fundComMap.get(insuranceId); + BigDecimal insuanceNum = new BigDecimal("0"); + BigDecimal oldDecimal = new BigDecimal(oldNum); + BigDecimal numDecimal = num == null ? new BigDecimal("0") : new BigDecimal(num); + insuanceNum = insuanceNum.add(numDecimal).add(oldDecimal); + fundComMap.put(insuranceId, insuanceNum.toPlainString()); + } + }); + } + + } + if (StringUtils.isNotBlank(item.getOtherPerJson())) { + Map otherJson = JSON.parseObject(item.getOtherPerJson(), new HashMap().getClass()); + if (otherJson != null) { + otherJson.forEach((insuranceId, num) -> { + if (otherPerMap.get(insuranceId) == null) { + otherPerMap.put(insuranceId, num); + } else { + String oldNum = otherPerMap.get(insuranceId); + BigDecimal insuanceNum = new BigDecimal("0"); + BigDecimal oldDecimal = new BigDecimal(oldNum); + BigDecimal numDecimal = num == null ? new BigDecimal("0") : new BigDecimal(num); + insuanceNum = insuanceNum.add(numDecimal).add(oldDecimal); + otherPerMap.put(insuranceId, insuanceNum.toPlainString()); + } + }); + } + + } + if (StringUtils.isNotBlank(item.getOtherComJson())) { + Map otherJson = JSON.parseObject(item.getOtherComJson(), new HashMap().getClass()); + if (otherJson != null) { + otherJson.forEach((insuranceId, num) -> { + if (otherComMap.get(insuranceId) == null) { + otherComMap.put(insuranceId, num); + } else { + String oldNum = otherComMap.get(insuranceId); + BigDecimal insuanceNum = new BigDecimal("0"); + BigDecimal oldDecimal = new BigDecimal(oldNum); + BigDecimal numDecimal = num == null ? new BigDecimal("0") : new BigDecimal(num); + insuanceNum = insuanceNum.add(numDecimal).add(oldDecimal); + otherComMap.put(insuranceId, insuanceNum.toPlainString()); + } + }); + } + + } + } + insuranceAccountDetailPO.setSocialPerJson(JSON.toJSONString(socialPerMap)); + insuranceAccountDetailPO.setSocialComJson(JSON.toJSONString(socialComMap)); + insuranceAccountDetailPO.setFundPerJson(JSON.toJSONString(fundPerMap)); + insuranceAccountDetailPO.setFundComJson(JSON.toJSONString(fundComMap)); + insuranceAccountDetailPO.setOtherPerJson(JSON.toJSONString(otherPerMap)); + insuranceAccountDetailPO.setOtherComJson(JSON.toJSONString(otherComMap)); + insuranceAccountDetailPO.setSocialPerSum(socialPer.toPlainString()); + insuranceAccountDetailPO.setSocialComSum(socialCom.toPlainString()); + insuranceAccountDetailPO.setFundPerSum(fundPer.toPlainString()); + insuranceAccountDetailPO.setFundComSum(fundCom.toPlainString()); + insuranceAccountDetailPO.setOtherPerSum(otherPer.toPlainString()); + insuranceAccountDetailPO.setOtherComSum(otherCom.toPlainString()); + insuranceAccountDetailPO.setPerSum(perSum.toPlainString()); + insuranceAccountDetailPO.setComSum(comSum.toPlainString()); + newList.add(insuranceAccountDetailPO); + } + return newList; + } + + + @Override + public List allInspects(Collection ids, String billMonth) { +// InsuranceAccountInspectMapper siAccountInspectMapper = MapperProxyFactory.getProxy(InsuranceAccountInspectMapper.class); + List list = getInsuranceAccountInspectMapper().getList(billMonth, InspectStatusEnum.IGNORE.getValue(), ids); + if (CollectionUtils.isNotEmpty(list)) { + return list; + } + return Collections.emptyList(); + } + + @Override + public Collection getAdminTaxAgentList() { + TaxAgentQueryParam param = TaxAgentQueryParam.builder().build(); + param.setFilterType(AuthFilterTypeEnum.ADMIN_DATA); + return getTaxAgentService(user).listAuth(param); + } + + @Override + public void socialSecurityBenefitsRecalculate(InsuranceAccountBatchPO param) { + //fixme 重新核算的校验逻辑 1、先取台账对应扣缴义务人下的所有账套 2、取账套下所有核算记录 3、判断核算记录有没有使用对应月份的福利台账 +// int num = getSiAccountBiz(user).checkIfBusinessaccounting(param); +// int num = checkIfBusinessAccounting(param); +// //表示已经被核算过不能重新核算 +// if (num > 0) { +// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "已被薪酬核算给核算过,无法重新核算!")); +// } + param.setBillStatus(0); +// getSiAccountBiz(user).updateById(param); + updateById(param); + //记录操作日志 + InsuranceAccountBatchPO targetPO = getInsuranceAccountBatchMapper().getById(param.getId()); + encryptUtil.decrypt(targetPO, InsuranceAccountBatchPO.class); + TaxAgentPO taxAgentInfo = getTaxAgentMapper().getById(targetPO.getPaymentOrganization()); + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId("" + targetPO.getId()); + loggerContext.setTargetName(taxAgentInfo.getName() + "-" + targetPO.getBillMonth()); + loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "福利台账-重新核算")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "福利台账-重新核算") + + ": " + taxAgentInfo.getName() + "-" + targetPO.getBillMonth()); + loggerContext.setNewValues(targetPO); + SalaryElogConfig.siAccountLoggerTemplate.write(loggerContext); + } + + /** + * 导出“福利核算导入模板” + */ + @Override + public XSSFWorkbook exportImportTemplate(InsuranceAcctDetailImportTemplateParam param) { + ValidUtil.doValidator(param); + Long employeeId = (long) user.getUID(); + // 必须选择导入模板所需的薪资项目(福利项) + if (CollectionUtils.isEmpty(param.getWelfareNames())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(99019, "参数错误,请选择导入模板所需的福利项目核算项")); + } + + // 模板表头(默认必带"个税扣缴义务人"、"姓名") + List headerList = Lists.newArrayList(SalaryI18nUtil.getI18nLabel(85429, "姓名"), + "部门", + SalaryI18nUtil.getI18nLabel(86186, "手机号"), + SalaryI18nUtil.getI18nLabel(86317, "工号"), + SalaryI18nUtil.getI18nLabel(86317, "证件号码"), + SalaryI18nUtil.getI18nLabel(86184, "个税扣缴义务人"), + "账单月份"); +// List dataIndexList = Lists.newArrayList("username", "departmentName", "mobile", "workcode", "taxAgentName", "billMonth"); + List dataIndexList = Lists.newArrayList("userName", "department", "mobile", "workcode","idNo", "socialPayOrg", "billMonth"); + // 查询福利核算项目 + List welfareNames = (List) param.getWelfareNames(); + headerList.addAll(welfareNames); + //匹配welfareName对应的id + List welfareList = getSalaryFormulaWrapper(user).welfareList(); + Map welfareNameMap = welfareList.stream().collect(Collectors.toMap(InsuranceAcctDetailImportFieldDTO::getSalaryItemName, InsuranceAcctDetailImportFieldDTO::getFieldId, (key1, key2) -> key2)); + welfareNames.forEach(f -> { + if (StringUtils.isNotBlank(welfareNameMap.get(f))) { + dataIndexList.add(welfareNameMap.get(f)); + } + }); + // excel导出的数据 +// //查询当前已有的正常缴纳数据 +// List> resultMapList = getNormalDataByBillMonth(param.getBillMonth(), param.getPaymentOrganization()); +// // excel导出的数据 +// List> rows = Lists.newArrayListWithExpectedSize(resultMapList.size()); +// rows.add(headerList); +// for (Map map : resultMapList) { +// List row = Lists.newArrayListWithExpectedSize(headerList.size()); +// for (String dataIndex : dataIndexList) { +// row.add(map.getOrDefault(dataIndex, StringUtils.EMPTY)); +// } +// rows.add(row); +// } + + InsuranceExportParam exportParam = new InsuranceExportParam(); + //排序配置 + OrderRuleVO orderRule = getSalarySysConfService(user).orderRule(); + exportParam.setOrderRule(orderRule); + exportParam.setBillMonth(param.getBillMonth()); + exportParam.setPaymentOrganization(param.getPaymentOrganization().toString()); + List accountExportPOS = new ArrayList<>(); + accountExportPOS = getInsuranceExportMapper().exportAccount(PaymentStatusEnum.COMMON.getValue(), exportParam); + //非系统人员核算明细 + List extAccountExportPOS = getInsuranceExportMapper().exportExtAccount(PaymentStatusEnum.COMMON.getValue(), exportParam); + accountExportPOS.addAll(extAccountExportPOS); + encryptUtil.decryptList(accountExportPOS, AccountExportPO.class); + SalaryI18nUtil.i18nList(accountExportPOS); + // 数据组装 + List> records = getSIExportService(user).buildCommonRecords(accountExportPOS, true); + + // excel导出的数据 + List> rows = Lists.newArrayListWithExpectedSize(records.size()); + rows.add(headerList); + for (Map map : records) { + List row = Lists.newArrayListWithExpectedSize(headerList.size()); + for (String dataIndex : dataIndexList) { + row.add(map.getOrDefault(dataIndex, StringUtils.EMPTY)); + } + rows.add(row); + } + + String sheetName = "福利核算导入模板"; + return ExcelUtil.genWorkbookV2(rows, sheetName); + } + + /** + * 将福利核算模板导入的数据更新到数据库 + */ + @Override + public Map importInsuranceAcctDetail(InsuranceAcctImportParam importParam) { +// long currentEmployeeId = user.getUID(); +// Boolean openDevolution = getTaxAgentService(user).isOpenDevolution(); + + Map apidatas = new HashMap(); + + //查询对于人员信息导入筛选的全局配置 + SalarySysConfPO salarySysConfPO = getSalarySysConfMapper().getOneByCode("matchEmployeeMode"); + String confValue = (salarySysConfPO != null && salarySysConfPO.getConfValue() != null && !"".equals(salarySysConfPO.getConfValue())) ? salarySysConfPO.getConfValue() : "0"; + //检验参数 + //excel文件id + String imageId = Util.null2String(importParam.getImageId()); + + if (StringUtils.isBlank(imageId)) { + throw new SalaryRunTimeException("文件不存在"); + } +// // 获取所有个税扣缴义务人 +// List taxAgents = getTaxAgentService(user).listAll(); +// Map taxAgentNameMap = SalaryEntityUtil.convert2Map(taxAgents, TaxAgentPO::getName, TaxAgentPO::getId); + + // 获取租户下所有的人员 + List salaryEmployees = getSalaryEmployeeService(user).listAll(UseEmployeeTypeEnum.ALL); + + // 失败的数量 + int failCount = 0; + // 成功的数量 + int successCount = 0; + InputStream fileInputStream = null; + try { + fileInputStream = ImageFileManager.getInputStreamById(Integer.parseInt(importParam.getImageId())); + + Sheet sheet = ExcelSupport.parseFile(fileInputStream, 0, EXCEL_TYPE_XLSX); + + // 错误提示信息 + List excelComments = Lists.newArrayList(); + // 存在错误的那行数据 + List> errorDatas = Lists.newArrayList(); + // 表头 + List headers = ExcelSupport.getSheetHeader(sheet, 0); + // 处理数值 + List> data = ExcelParseHelper.parse2Map(sheet, 1); + if (CollectionUtils.isEmpty(headers)) { + throw new SalaryRunTimeException("表头为空"); + } + if (CollectionUtils.isEmpty(data)) { + throw new SalaryRunTimeException("无数据"); + } + //存储待更新的InsuranceAccountDetailPO数据 + List updateInsuranceAccountDetailList = new ArrayList<>(); + //存储待新增的InsuranceAccountDetailPO数据 + List insertInsuranceAccountDetailList = new ArrayList<>(); + //遍历excel表具体数据 + for (int i = 0; i < data.size(); i++) { + + String row = "第" + (i + 2) + "行"; + + boolean isError = false; + Map map = data.get(i); + Long employeeId = 0L; +// Long taxAgentId = 0L; + + List list = new ArrayList<>(); + + String billMonth = (String) map.getOrDefault("账单月份", ""); + String taxAgentName = (String) map.getOrDefault("个税扣缴义务人", ""); + String supplementaryMonth = (String) map.getOrDefault("补缴月份", ""); + Long paymentOrganization = 0L; + List taxAgentPoList = getTaxAgentMapper().listByName(taxAgentName); + + if (taxAgentPoList.size() == 1) { + paymentOrganization = taxAgentPoList.get(0).getId(); + } else { + isError = true; + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", row + SalaryI18nUtil.getI18nLabel(100579, SalaryI18nUtil.getI18nLabel(102840, "个税扣缴义务人错误,系统内不存在该个税扣缴义务人"))); + excelComments.add(errorMessageMap); + } + + if (billMonth.length() < 7 || !SalaryDateUtil.checkYearMonth(billMonth.substring(0, 7))) { + isError = true; + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", row + SalaryI18nUtil.getI18nLabel(100579, "账单月份输入有误,请参照“2022-09”这种格式进行检查")); + excelComments.add(errorMessageMap); + } + if (headers.contains("补缴月份") && (supplementaryMonth.length() < 7 || !SalaryDateUtil.checkYearMonth(supplementaryMonth.substring(0, 7)))) { + isError = true; + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", row + SalaryI18nUtil.getI18nLabel(0, "补缴月份输入有误,请参照“2022-09”这种格式进行检查")); + excelComments.add(errorMessageMap); + } + + //遍历表头 + for (int j = 0; j < headers.size(); j++) { + String header = headers.get(j); + String dataKey = header; + if (dataKey == null) { + continue; + } + String dataValue = (String) map.getOrDefault(dataKey.toString(), ""); + String deparmentName = (String) map.getOrDefault("部门", ""); + String mobile = (String) map.getOrDefault("手机号", ""); + String workcode = (String) map.getOrDefault("工号", ""); + String idNo = (String) map.getOrDefault("证件号码", ""); + + + if (StringUtils.equals(SalaryI18nUtil.getI18nLabel(85429, "姓名"), dataKey.toString())) { + //当人员信息导入筛选的全局配置为"0"时,姓名才是必填项 + if (StringUtils.isEmpty(dataValue) && "0".equals(confValue)) { + isError = true; + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", row + SalaryI18nUtil.getI18nLabel(102838, "姓名不能为空")); + excelComments.add(errorMessageMap); + + } else { + //筛选导入人员信息可以在人力资源池中匹配到的人员信息 + List employeeSameIds = getSalaryEmployeeService(user).matchImportEmployee(confValue,salaryEmployees, dataValue, deparmentName, mobile, workcode,idNo, null); + + if (CollectionUtils.isEmpty(employeeSameIds)) { + isError = true; + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", row + SalaryI18nUtil.getI18nLabel(100579, "姓名错误,系统内不存在该姓名")); + excelComments.add(errorMessageMap); + + } else if (employeeSameIds.size() > 1) { + //存在离职和在职状态取在职状态 + employeeSameIds = employeeSameIds.stream() + .filter(e -> UserStatusEnum.getNormalStatus().contains(e.getStatus())) + .collect(Collectors.toList()); + if (employeeSameIds.size() != 1) { + isError = true; + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", row + "员工信息不存在或者存在多个员工"); + excelComments.add(errorMessageMap); + } else { + employeeId = CollectionUtils.isNotEmpty(employeeSameIds) && employeeSameIds.size() == 1 ? employeeSameIds.get(0).getEmployeeId() : null; + } + } else { + employeeId = employeeSameIds.get(0).getEmployeeId(); + } + } + } + + + } + + if (!isError){ + List employeeIds = new ArrayList<>(); + employeeIds.add(employeeId); + //如果福利核算信息查询不到唯一匹配数据,不支持导入 + //根据员工id、个税扣缴义务人id、账单月份查询 + //根据表头字段来区分正常缴纳和补缴两类数据 + if (!headers.contains("补缴月份")) { + list = getInsuranceAccountDetailMapper().queryNormalList(billMonth.substring(0, 7), paymentOrganization, employeeIds.get(0)); + } else { + list = getInsuranceAccountDetailMapper().querySupplementList(billMonth.substring(0, 7), paymentOrganization, employeeIds.get(0), supplementaryMonth.substring(0, 7)); + } + + if (list.isEmpty()) { + if (headers.contains("补缴月份")) { + // 如果是补缴列表没有,则新增 + if (supplementaryMonth.substring(0, 7).equals(billMonth.substring(0, 7))) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100481, "当前月走正常缴纳")); + } + //校验补缴人员是否存在福利档案基础信息,并且runStatus处于正在缴纳或者待减员 + InsuranceArchivesBaseInfoPO insuranceBaseInfo = getInsuranceBaseInfoMapper().getOneByEmployeeIdAndPayOrg(paymentOrganization, employeeId); + if (insuranceBaseInfo == null || !(insuranceBaseInfo.getRunStatus().equals(EmployeeStatusEnum.STAY_DEL.getValue()) || insuranceBaseInfo.getRunStatus().equals(EmployeeStatusEnum.PAYING.getValue())) ) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "补缴人员中存在未设置福利档案人员或相关人员不在福利在缴人员中,不可新建补缴信息!")); + } + List empIdsInPayMonthRange = listCanPayEmpIds(paymentOrganization, billMonth.substring(0, 7)); + if (!empIdsInPayMonthRange.contains(employeeId)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(99920, "无核算人员")); + } + DataCollectionEmployee employee = getSalaryEmployeeService(user).getEmployeeById(employeeId); + // 封装InsuranceAccountDetailPO + Date now = new Date(); + InsuranceAccountDetailPO insuranceAccountDetailPO = new InsuranceAccountDetailPO(); + insuranceAccountDetailPO.setBillStatus(0); + insuranceAccountDetailPO.setEmployeeId(employeeId); + if (employee != null) { + insuranceAccountDetailPO.setSubcompanyName(employee.getSubcompanyName()); + insuranceAccountDetailPO.setSubcompanyId(employee.getSubcompanyid()); + insuranceAccountDetailPO.setDepartmentName(employee.getDepartmentName()); + insuranceAccountDetailPO.setDepartmentId(employee.getDepartmentId()); + insuranceAccountDetailPO.setJobtitleName(employee.getJobtitleName()); + insuranceAccountDetailPO.setJobtitleId(employee.getJobtitleId()); + insuranceAccountDetailPO.setJobcall(employee.getJobcall()); + insuranceAccountDetailPO.setJobcallId(employee.getJobcallId()); + insuranceAccountDetailPO.setStatus(employee.getStatus()); + } + insuranceAccountDetailPO.setPaymentOrganization(paymentOrganization); + insuranceAccountDetailPO.setPaymentStatus(1); + insuranceAccountDetailPO.setResourceFrom(0); + insuranceAccountDetailPO.setSupplementaryProjects("0,1,2,3,4,5"); + insuranceAccountDetailPO.setSocialPayOrg(paymentOrganization); + insuranceAccountDetailPO.setFundPayOrg(paymentOrganization); + insuranceAccountDetailPO.setOtherPayOrg(paymentOrganization); + insuranceAccountDetailPO.setCreator(Long.valueOf(user.getUID())); + insuranceAccountDetailPO.setCreateTime(now); + insuranceAccountDetailPO.setUpdateTime(now); + insuranceAccountDetailPO.setTenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY); + insuranceAccountDetailPO.setDeleteType(0); + InsuranceAccountDetailPO insertPO = handleInsuranceAccountDetail4AddSupplementary(insuranceAccountDetailPO, map); + if(!checkBalancePayInsurance(insertPO)) { + isError = true; + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", row + SalaryI18nUtil.getI18nLabel(0, "导入数据中存在福利档案中未设置的福利项缴纳数值!")); + excelComments.add(errorMessageMap); + } else { + insertInsuranceAccountDetailList.add(insertPO); + } + } else { + isError = true; + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", row + SalaryI18nUtil.getI18nLabel(100579, "本次福利核算不包含该人员")); + excelComments.add(errorMessageMap); + } + } else if (list.size() > 1) { + isError = true; + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", row + SalaryI18nUtil.getI18nLabel(100579, "该人员本次核算出现多组数据,请删除数据库中多余核算项")); + excelComments.add(errorMessageMap); + } else { + //拼装待更新数据 + encryptUtil.decryptList(list, InsuranceAccountDetailPO.class); + InsuranceAccountDetailPO updatePO = handleInsuranceAccountDetail(list.get(0), map); + //判断导入福利项是否符合福利方案设置缴纳项 + if(!checkBalancePayInsurance(updatePO)) { + isError = true; + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", row + SalaryI18nUtil.getI18nLabel(0, "导入数据中存在福利档案中未设置的福利项缴纳数值!")); + excelComments.add(errorMessageMap); + } else { + updateInsuranceAccountDetailList.add(updatePO); + } + + } + + } + + if (isError) { + failCount++; + errorDatas.add(map); + } else { + successCount++; + } + + } + //将待更新列表加密 + encryptUtil.encryptList(updateInsuranceAccountDetailList, InsuranceAccountDetailPO.class); + // 将待插入列表加密 + encryptUtil.encryptList(insertInsuranceAccountDetailList, InsuranceAccountDetailPO.class); + //更新 + for(InsuranceAccountDetailPO po : updateInsuranceAccountDetailList) { +// getSiAccountBiz(user).updateByEmployeeIdAndBillMonth(po); + updateByEmployeeIdAndBillMonth(po); + } + // 插入 + if (CollectionUtils.isNotEmpty(insertInsuranceAccountDetailList)) { + batchSaveAccountDetails(insertInsuranceAccountDetailList); + } + + //刷新hrsa_bill_batch中数据统计信息 + updateInsuranceAccountDetailList.addAll(insertInsuranceAccountDetailList); + if (updateInsuranceAccountDetailList.size() > 0) { + refreshBillBatch(updateInsuranceAccountDetailList.get(0).getPaymentOrganization(), updateInsuranceAccountDetailList.get(0).getBillMonth()); + //记录操作日志 + PaymentStatusEnum targetEnum = SalaryEnumUtil.enumMatchByValue(updateInsuranceAccountDetailList.get(0).getPaymentStatus(), PaymentStatusEnum.values(), PaymentStatusEnum.class); + encryptUtil.decryptList(updateInsuranceAccountDetailList, InsuranceAccountDetailPO.class); + InsuranceAccountBatchPO targetPO = getInsuranceAccountBatchMapper().getByBillMonth(updateInsuranceAccountDetailList.get(0).getBillMonth(), updateInsuranceAccountDetailList.get(0).getPaymentOrganization()); + TaxAgentPO taxAgentInfo = getTaxAgentMapper().getById(targetPO.getPaymentOrganization()); + LoggerContext loggerContext = new LoggerContext(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(targetPO.getId())); + loggerContext.setTargetName(taxAgentInfo.getName() + "-" + targetPO.getBillMonth()); + loggerContext.setOperateType(OperateTypeEnum.EXCEL_IMPORT.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "福利台账明细表-导入") + + SalaryI18nUtil.getI18nLabel(targetEnum.getLabelId(), targetEnum.getDefaultLabel())); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "福利台账明细表-导入" + + SalaryI18nUtil.getI18nLabel(targetEnum.getLabelId(), targetEnum.getDefaultLabel())) + + ":" + taxAgentInfo.getName() + "-" + targetPO.getBillMonth()); + updateInsuranceAccountDetailList.forEach(loggerContext::setNewValues); + SalaryElogConfig.siAccountLoggerTemplate.write(loggerContext); + } + + apidatas.put("successCount", successCount); + apidatas.put("errorCount", failCount); + apidatas.put("errorData", excelComments); + + } finally { + IOUtils.closeQuietly(fileInputStream); + } + return apidatas; + } + + + public void batchSaveAccountDetails(List insertInsuranceAccountDetailList) { + List> partition = Lists.partition(insertInsuranceAccountDetailList, 20); + partition.forEach(part -> getInsuranceAccountDetailMapper().batchSaveAccountDetails(part)); + } + + /** + * 预览“福利核算导入”模板导入的数据 + */ + @Override + public Map preview(InsuranceAcctImportParam param) { + //1、参数校验 + String imageId = param.getImageId(); + if (StringUtils.isBlank(imageId)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100593, "文件id为空")); + } + + Map map = new HashMap<>(); + + InputStream fileInputStream = null; + try { + + fileInputStream = ImageFileManager.getInputStreamById(Integer.parseInt(imageId)); + + Sheet sheet = ExcelSupport.parseFile(fileInputStream, 0, EXCEL_TYPE_XLSX); + List headers = ExcelSupport.getSheetHeader(sheet, 0); + + map.put("headers", headers); + map.put("list", ExcelParseHelper.parse2List(sheet, 1)); + + return map; + + } finally { + IOUtils.closeQuietly(fileInputStream); + } + } + + /** + * 导出“福利核算-补缴导入”模板 + */ + @Override + public XSSFWorkbook exportSupplyImportTemplate(InsuranceAcctDetailImportTemplateParam param) { + ValidUtil.doValidator(param); + + // 必须选择导入模板所需的薪资项目(福利项) + if (CollectionUtils.isEmpty(param.getWelfareNames())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(99019, "参数错误,请选择导入模板所需的福利项目核算项")); + } + + // 模板表头(默认必带"个税扣缴义务人"、"姓名") + List headerList = Lists.newArrayList(SalaryI18nUtil.getI18nLabel(85429, "姓名"), + "部门", + SalaryI18nUtil.getI18nLabel(86186, "手机号"), + SalaryI18nUtil.getI18nLabel(86317, "工号"), + SalaryI18nUtil.getI18nLabel(86317, "证件号码"), + SalaryI18nUtil.getI18nLabel(86184, "个税扣缴义务人"), + "账单月份", + "补缴月份"); + List dataIndexList = Lists.newArrayList("username", "departmentName", "mobile", "workcode","idNo", "taxAgentName", "billMonth", "supplementaryMonth"); + // 查询福利核算项目 + List welfareNames = (List) param.getWelfareNames(); + headerList.addAll(welfareNames); + + //查询当前已有的补缴数据 + List> resultMapList = getSupplyDataByBillMonth(param.getBillMonth(), param.getPaymentOrganization()); + // excel导出的数据 + List> rows = Lists.newArrayListWithExpectedSize(resultMapList.size()); + rows.add(headerList); + for (Map map : resultMapList) { + List row = Lists.newArrayListWithExpectedSize(headerList.size()); + for (String dataIndex : dataIndexList) { + row.add(map.getOrDefault(dataIndex, StringUtils.EMPTY)); + } + rows.add(row); + } + + + String sheetName = "福利核算-补缴导入模板"; + return ExcelUtil.genWorkbookV2(rows, sheetName); + } + + /** + * 获取福利台账中的补缴数据 + * @param billMonth 账单月份 + * @param paymentOrganization 个税扣缴义务人id + * @return + */ + private List> getSupplyDataByBillMonth(String billMonth, Long paymentOrganization) { + + List> resultList = new ArrayList<>(); + + DataCollectionEmployee employee = new DataCollectionEmployee(); + + TaxAgentPO taxAgentPO = taxAgentBiz.getById(paymentOrganization); + + List supplyDataList = getInsuranceAccountDetailMapper().querySupplementListByBillMonth(billMonth, paymentOrganization); + + //过滤出福利档案基础信息表中runStatus为正在缴纳和待减员的人员 + List baseInfoPOList = getInsuranceBaseInfoMapper().listAll(); + List canAccountIds = baseInfoPOList.stream() + .filter(f->f.getPaymentOrganization().equals(paymentOrganization) + && (f.getRunStatus().equals(EmployeeStatusEnum.PAYING.getValue()) || f.getRunStatus().equals(EmployeeStatusEnum.STAY_DEL.getValue()))) + .map(InsuranceArchivesBaseInfoPO::getEmployeeId) + .collect(Collectors.toList()); + supplyDataList = supplyDataList.stream().filter(f -> canAccountIds.contains(f.getEmployeeId())).collect(Collectors.toList()); + + for(InsuranceAccountDetailPO po : supplyDataList) { + Map resultMap = new HashMap<>(); + employee = getSalaryEmployeeService(user).getEmployeeById(po.getEmployeeId()); + resultMap.put("username", employee.getUsername()); + resultMap.put("departmentName", employee.getDepartmentName()); + resultMap.put("mobile", employee.getMobile()); + resultMap.put("workcode", employee.getWorkcode()); + resultMap.put("idNo", employee.getIdNo()); + resultMap.put("taxAgentName", taxAgentPO.getName()); + resultMap.put("billMonth", billMonth); + resultMap.put("supplementaryMonth", po.getSupplementaryMonth()); + + resultList.add(resultMap); + } + return resultList; + } + + /** + * 获取福利台账中的补差数据 + * @param billMonth 账单月份 + * @param paymentOrganization 个税扣缴义务人id + * @return + */ + private List> getBalanceDataByBillMonth(String billMonth, Long paymentOrganization) { + + List> resultList = new ArrayList<>(); + + DataCollectionEmployee employee = new DataCollectionEmployee(); + + TaxAgentPO taxAgentPO = taxAgentBiz.getById(paymentOrganization); + + List balanceDataList = getInsuranceAccountDetailMapper().queryBalanceListByBillMonth(billMonth, paymentOrganization); + + + for(InsuranceAccountDetailPO po : balanceDataList) { + Map resultMap = new HashMap<>(); + employee = getSalaryEmployeeService(user).getEmployeeById(po.getEmployeeId()); + resultMap.put("username", employee.getUsername()); + resultMap.put("departmentName", employee.getDepartmentName()); + resultMap.put("mobile", employee.getMobile()); + resultMap.put("workcode", employee.getWorkcode()); + resultMap.put("idNo", employee.getIdNo()); + resultMap.put("taxAgentName", taxAgentPO.getName()); + resultMap.put("billMonth", billMonth); + resultMap.put("supplementaryMonth", po.getSupplementaryMonth()); + + resultList.add(resultMap); + } + return resultList; + } + + /** + * 获取福利台账中的正常缴纳数据 + * @param billMonth 账单月份 + * @param paymentOrganization 个税扣缴义务人id + * @return + */ + private List> getNormalDataByBillMonth(String billMonth, Long paymentOrganization) { + + List> resultList = new ArrayList<>(); + + DataCollectionEmployee employee = new DataCollectionEmployee(); + + TaxAgentPO taxAgentPO = taxAgentBiz.getById(paymentOrganization); + + List normalDataList = getInsuranceAccountDetailMapper().queryNormalListByBillMonth(billMonth, paymentOrganization); + //过滤出福利档案基础信息表中runStatus为正在缴纳和待减员的人员 + List baseInfoPOList = getInsuranceBaseInfoMapper().listAll(); + List canAccountIds = baseInfoPOList.stream() + .filter(f->f.getPaymentOrganization().equals(paymentOrganization) + && (f.getRunStatus().equals(EmployeeStatusEnum.PAYING.getValue()) || f.getRunStatus().equals(EmployeeStatusEnum.STAY_DEL.getValue()))) + .map(InsuranceArchivesBaseInfoPO::getEmployeeId) + .collect(Collectors.toList()); + normalDataList = normalDataList.stream().filter(f -> canAccountIds.contains(f.getEmployeeId())).collect(Collectors.toList()); + + for(InsuranceAccountDetailPO po : normalDataList) { + Map resultMap = new HashMap<>(); + employee = getSalaryEmployeeService(user).getEmployeeById(po.getEmployeeId()); + resultMap.put("username", employee.getUsername()); + resultMap.put("departmentName", employee.getDepartmentName()); + resultMap.put("mobile", employee.getMobile()); + resultMap.put("workcode", employee.getWorkcode()); + resultMap.put("taxAgentName", taxAgentPO.getName()); + resultMap.put("billMonth", billMonth); + + resultList.add(resultMap); + } + return resultList; + } + + /** + * 将更新的数据设置到老的insuranceAccountDetailPO对象中 + */ + private InsuranceAccountDetailPO handleInsuranceAccountDetail(InsuranceAccountDetailPO insuranceAccountDetailPO, Map baseMap) { + + //组装json数据,格式Map + Map socialPerMap = new HashMap<>(); + Map fundPerMap = new HashMap<>(); + Map otherPerMap = new HashMap<>(); + Map socialComMap = new HashMap<>(); + Map fundComMap = new HashMap<>(); + Map otherComMap = new HashMap<>(); + + //筛选出福利核算项 + Map toDealMap = + baseMap.entrySet().stream() + .filter(map -> !"姓名".equals(map.getKey()) + && !"部门".equals(map.getKey()) + && !"手机号".equals(map.getKey()) + && !"个税扣缴义务人".equals(map.getKey()) + && !"账单月份".equals(map.getKey())) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + + for(Map.Entry entry : toDealMap.entrySet()) { + //判断元素是否属于福利类 + String keyName = entry.getKey(); + //获取元素名后缀,方便之后判断“个人”或“单位” + String payScope = keyName.substring(keyName.length() - 2); + //获取福利类型 + Integer welfareType; +// List categoryPOList = siCategoryBiz.listByName(entry.getKey().substring(0, keyName.length() - 2)); + List categoryPOList = getSICategoryService(user).listByName(entry.getKey().substring(0, keyName.length() - 2)); + if (categoryPOList.size() == 1) { + ICategoryPO iCategoryPO = categoryPOList.get(0); + welfareType = iCategoryPO.getWelfareType(); + + if ("个人".equals(payScope)) { + switch (welfareType) { + case 1: + socialPerMap.put(iCategoryPO.getId().toString(), entry.getValue().toString()); + break; + case 2: + fundPerMap.put(iCategoryPO.getId().toString(), entry.getValue().toString()); + break; + case 3: + otherPerMap.put(iCategoryPO.getId().toString(), entry.getValue().toString()); + break; + default: + throw new SalaryRunTimeException("福利类型不存在"); + } + } else if ("单位".equals(payScope)) { + switch (welfareType) { + case 1: + socialComMap.put(iCategoryPO.getId().toString(), entry.getValue().toString()); + break; + case 2: + fundComMap.put(iCategoryPO.getId().toString(), entry.getValue().toString()); + break; + case 3: + otherComMap.put(iCategoryPO.getId().toString(), entry.getValue().toString()); + break; + default: + throw new SalaryRunTimeException("福利类型不存在"); + } + } + } + + } + + //组装新的insuranceAccountDetailPO对象数据 + if (!socialPerMap.isEmpty()) { + //对比新旧json中数据,并输出最终json + checkJsonMap(socialPerMap, insuranceAccountDetailPO.getSocialPerJson()); + insuranceAccountDetailPO.setSocialPerJson(JSON.toJSONString(socialPerMap)); + } + + if (!socialComMap.isEmpty()) { + checkJsonMap(socialComMap, insuranceAccountDetailPO.getSocialComJson()); + insuranceAccountDetailPO.setSocialComJson(JSON.toJSONString(socialComMap)); + } + + if (!fundPerMap.isEmpty()) { + checkJsonMap(fundPerMap, insuranceAccountDetailPO.getFundPerJson()); + insuranceAccountDetailPO.setFundPerJson(JSON.toJSONString(fundPerMap)); + } + + if (!fundComMap.isEmpty()) { + checkJsonMap(fundComMap, insuranceAccountDetailPO.getFundComJson()); + insuranceAccountDetailPO.setFundComJson(JSON.toJSONString(fundComMap)); + } + + if (!otherPerMap.isEmpty()) { + checkJsonMap(otherPerMap, insuranceAccountDetailPO.getOtherPerJson()); + insuranceAccountDetailPO.setOtherPerJson(JSON.toJSONString(otherPerMap)); + } + + if (!otherComMap.isEmpty()) { + checkJsonMap(otherComMap, insuranceAccountDetailPO.getOtherComJson()); + insuranceAccountDetailPO.setOtherComJson(JSON.toJSONString(otherComMap)); + } + + + if (!StringUtils.isEmpty(baseMap.getOrDefault("社保个人合计", "").toString())) { + insuranceAccountDetailPO.setSocialPerSum(baseMap.get("社保个人合计").toString()); + } else if (!socialPerMap.isEmpty()) { + insuranceAccountDetailPO.setSocialPerSum(sumOfMapValue(socialPerMap)); + } + + if (!StringUtils.isEmpty(baseMap.getOrDefault("公积金个人合计", "").toString())) { + insuranceAccountDetailPO.setFundPerSum(baseMap.get("公积金个人合计").toString()); + } else if (!fundPerMap.isEmpty()) { + insuranceAccountDetailPO.setFundPerSum(sumOfMapValue(fundPerMap)); + } + + if (!StringUtils.isEmpty(baseMap.getOrDefault("其他福利个人合计", "").toString())) { + insuranceAccountDetailPO.setOtherPerSum(baseMap.get("其他福利个人合计").toString()); + } else if (!otherPerMap.isEmpty()) { + insuranceAccountDetailPO.setOtherPerSum(sumOfMapValue(otherPerMap)); + } + + if (!StringUtils.isEmpty(baseMap.getOrDefault("个人合计", "").toString())) { + insuranceAccountDetailPO.setPerSum(baseMap.get("个人合计").toString()); + } else { + insuranceAccountDetailPO.setPerSum(new BigDecimal(insuranceAccountDetailPO.getSocialPerSum() == null ? "0" : insuranceAccountDetailPO.getSocialPerSum()) + .add(new BigDecimal(insuranceAccountDetailPO.getFundPerSum() == null ? "0" : insuranceAccountDetailPO.getFundPerSum())) + .add(new BigDecimal(insuranceAccountDetailPO.getOtherPerSum() == null ? "0" : insuranceAccountDetailPO.getOtherPerSum())).toString()); + } + + if (!StringUtils.isEmpty(baseMap.getOrDefault("社保单位合计", "").toString())) { + insuranceAccountDetailPO.setSocialComSum(baseMap.get("社保单位合计").toString()); + } else if (!socialComMap.isEmpty()) { + insuranceAccountDetailPO.setSocialComSum(sumOfMapValue(socialComMap)); + } + + if (!StringUtils.isEmpty(baseMap.getOrDefault("公积金单位合计", "").toString())) { + insuranceAccountDetailPO.setFundComSum(baseMap.get("公积金单位合计").toString()); + } else if (!fundComMap.isEmpty()) { + insuranceAccountDetailPO.setFundComSum(sumOfMapValue(fundComMap)); + } + + if (!StringUtils.isEmpty(baseMap.getOrDefault("其他福利单位合计", "").toString())) { + insuranceAccountDetailPO.setOtherComSum(baseMap.get("其他福利单位合计").toString()); + } else if (!otherComMap.isEmpty()) { + insuranceAccountDetailPO.setOtherComSum(sumOfMapValue(otherComMap)); + } + + + if (!StringUtils.isEmpty(baseMap.getOrDefault("单位合计", "").toString())) { + insuranceAccountDetailPO.setComSum(baseMap.get("单位合计").toString()); + } else { + insuranceAccountDetailPO.setComSum(new BigDecimal(insuranceAccountDetailPO.getSocialComSum() == null ? "0" : insuranceAccountDetailPO.getSocialComSum()) + .add(new BigDecimal(insuranceAccountDetailPO.getFundComSum() == null ? "0" : insuranceAccountDetailPO.getFundComSum())) + .add(new BigDecimal(insuranceAccountDetailPO.getOtherComSum() == null ? "0" : insuranceAccountDetailPO.getOtherComSum())).toString()); + } + + if (!StringUtils.isEmpty(baseMap.getOrDefault("账单月份", "").toString())) { + insuranceAccountDetailPO.setBillMonth(baseMap.get("账单月份").toString().substring(0, 7)); + } + + if (!StringUtils.isEmpty(baseMap.getOrDefault("社保合计", "").toString())) { + insuranceAccountDetailPO.setSocialSum(baseMap.get("社保合计").toString()); + } else { + insuranceAccountDetailPO.setSocialSum(new BigDecimal(insuranceAccountDetailPO.getSocialComSum() == null ? "0" : insuranceAccountDetailPO.getSocialComSum()) + .add(new BigDecimal(insuranceAccountDetailPO.getSocialPerSum() == null ? "0" : insuranceAccountDetailPO.getSocialPerSum())) + .toString()); + } + if (!StringUtils.isEmpty(baseMap.getOrDefault("公积金合计", "").toString())) { + insuranceAccountDetailPO.setFundSum(baseMap.get("公积金合计").toString()); + } else { + insuranceAccountDetailPO.setFundSum(new BigDecimal(insuranceAccountDetailPO.getFundComSum() == null ? "0" : insuranceAccountDetailPO.getFundComSum()) + .add(new BigDecimal(insuranceAccountDetailPO.getFundPerSum() == null ? "0" : insuranceAccountDetailPO.getFundPerSum())) + .toString()); + } + if (!StringUtils.isEmpty(baseMap.getOrDefault("其他福利合计", "").toString())) { + insuranceAccountDetailPO.setOtherSum(baseMap.get("其他福利合计").toString()); + } else { + insuranceAccountDetailPO.setOtherSum(new BigDecimal(insuranceAccountDetailPO.getOtherComSum() == null ? "0" : insuranceAccountDetailPO.getOtherComSum()) + .add(new BigDecimal(insuranceAccountDetailPO.getOtherPerSum() == null ? "0" : insuranceAccountDetailPO.getOtherPerSum())) + .toString()); + } + if (!StringUtils.isEmpty(baseMap.getOrDefault("合计", "").toString())) { + insuranceAccountDetailPO.setTotal(baseMap.get("合计").toString()); + } else { + insuranceAccountDetailPO.setTotal(new BigDecimal(insuranceAccountDetailPO.getPerSum() == null ? "0" : insuranceAccountDetailPO.getPerSum()) + .add(new BigDecimal(insuranceAccountDetailPO.getComSum() == null ? "0" : insuranceAccountDetailPO.getComSum())) + .toString()); + } + + //如果导入的时补缴数据,还会包含补缴月份 + if (!StringUtils.isEmpty(baseMap.getOrDefault("补缴月份", "").toString())) { + insuranceAccountDetailPO.setSupplementaryMonth(baseMap.get("补缴月份").toString().substring(0, 7)); + } + + insuranceAccountDetailPO.setUpdateTime(new Date()); + + return insuranceAccountDetailPO; + } + + private InsuranceAccountDetailPO handleInsuranceAccountDetail4AddSupplementary(InsuranceAccountDetailPO po, Map baseMap) { + + //组装json数据,格式Map + Map socialPerMap = new HashMap<>(); + Map fundPerMap = new HashMap<>(); + Map otherPerMap = new HashMap<>(); + Map socialComMap = new HashMap<>(); + Map fundComMap = new HashMap<>(); + Map otherComMap = new HashMap<>(); + + //筛选出福利核算项 + Map toDealMap = + baseMap.entrySet().stream() + .filter(map -> !"姓名".equals(map.getKey()) + && !"部门".equals(map.getKey()) + && !"手机号".equals(map.getKey()) + && !"个税扣缴义务人".equals(map.getKey()) + && !"账单月份".equals(map.getKey())) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + + for(Map.Entry entry : toDealMap.entrySet()) { + //判断元素是否属于福利类 + String keyName = entry.getKey(); + //获取元素名后缀,方便之后判断“个人”或“单位” + String payScope = keyName.substring(keyName.length() - 2); + //获取福利类型 + Integer welfareType; +// List categoryPOList = siCategoryBiz.listByName(entry.getKey().substring(0, keyName.length() - 2)); + List categoryPOList = getSICategoryService(user).listByName(entry.getKey().substring(0, keyName.length() - 2)); + if (categoryPOList.size() == 1) { + ICategoryPO iCategoryPO = categoryPOList.get(0); + welfareType = iCategoryPO.getWelfareType(); + + if ("个人".equals(payScope)) { + switch (welfareType) { + case 1: + socialPerMap.put(iCategoryPO.getId().toString(), entry.getValue().toString()); + break; + case 2: + fundPerMap.put(iCategoryPO.getId().toString(), entry.getValue().toString()); + break; + case 3: + otherPerMap.put(iCategoryPO.getId().toString(), entry.getValue().toString()); + break; + default: + throw new SalaryRunTimeException("福利类型不存在"); + } + } else if ("单位".equals(payScope)) { + switch (welfareType) { + case 1: + socialComMap.put(iCategoryPO.getId().toString(), entry.getValue().toString()); + break; + case 2: + fundComMap.put(iCategoryPO.getId().toString(), entry.getValue().toString()); + break; + case 3: + otherComMap.put(iCategoryPO.getId().toString(), entry.getValue().toString()); + break; + default: + throw new SalaryRunTimeException("福利类型不存在"); + } + } + } + + } + + //组装新的insuranceAccountDetailPO对象数据 + if (!socialPerMap.isEmpty()) { + //对比新旧json中数据,并输出最终json + checkJsonMap(socialPerMap, null); + po.setSocialPerJson(JSON.toJSONString(socialPerMap)); + } + + if (!socialComMap.isEmpty()) { + checkJsonMap(socialComMap, null); + po.setSocialComJson(JSON.toJSONString(socialComMap)); + } + + if (!fundPerMap.isEmpty()) { + checkJsonMap(fundPerMap, null); + po.setFundPerJson(JSON.toJSONString(fundPerMap)); + } + + if (!fundComMap.isEmpty()) { + checkJsonMap(fundComMap, null); + po.setFundComJson(JSON.toJSONString(fundComMap)); + } + + if (!otherPerMap.isEmpty()) { + checkJsonMap(otherPerMap, null); + po.setOtherPerJson(JSON.toJSONString(otherPerMap)); + } + + if (!otherComMap.isEmpty()) { + checkJsonMap(otherComMap, null); + po.setOtherComJson(JSON.toJSONString(otherComMap)); + } + + + if (!StringUtils.isEmpty(baseMap.getOrDefault("社保个人合计", "").toString())) { + po.setSocialPerSum(baseMap.get("社保个人合计").toString()); + } else if (!socialPerMap.isEmpty()) { + po.setSocialPerSum(sumOfMapValue(socialPerMap)); + } else { + po.setSocialPerSum("0"); + } + + if (!StringUtils.isEmpty(baseMap.getOrDefault("公积金个人合计", "").toString())) { + po.setFundPerSum(baseMap.get("公积金个人合计").toString()); + } else if (!fundPerMap.isEmpty()) { + po.setFundPerSum(sumOfMapValue(fundPerMap)); + } else { + po.setFundPerSum("0"); + } + + if (!StringUtils.isEmpty(baseMap.getOrDefault("其他福利个人合计", "").toString())) { + po.setOtherPerSum(baseMap.get("其他福利个人合计").toString()); + } else if (!otherPerMap.isEmpty()) { + po.setOtherPerSum(sumOfMapValue(otherPerMap)); + } else { + po.setOtherPerSum("0"); + } + + if (!StringUtils.isEmpty(baseMap.getOrDefault("个人合计", "").toString())) { + po.setPerSum(baseMap.get("个人合计").toString()); + } else { + po.setPerSum(new BigDecimal(po.getSocialPerSum() == null ? "0" : po.getSocialPerSum()) + .add(new BigDecimal(po.getFundPerSum() == null ? "0" : po.getFundPerSum())) + .add(new BigDecimal(po.getOtherPerSum() == null ? "0" : po.getOtherPerSum())).toString()); + } + + if (!StringUtils.isEmpty(baseMap.getOrDefault("社保单位合计", "").toString())) { + po.setSocialComSum(baseMap.get("社保单位合计").toString()); + } else if (!socialComMap.isEmpty()) { + po.setSocialComSum(sumOfMapValue(socialComMap)); + } else { + po.setSocialComSum("0"); + } + + if (!StringUtils.isEmpty(baseMap.getOrDefault("公积金单位合计", "").toString())) { + po.setFundComSum(baseMap.get("公积金单位合计").toString()); + } else if (!fundComMap.isEmpty()) { + po.setFundComSum(sumOfMapValue(fundComMap)); + } else { + po.setFundComSum("0"); + } + + if (!StringUtils.isEmpty(baseMap.getOrDefault("其他福利单位合计", "").toString())) { + po.setOtherComSum(baseMap.get("其他福利单位合计").toString()); + } else if (!otherComMap.isEmpty()) { + po.setOtherComSum(sumOfMapValue(otherComMap)); + } else { + po.setOtherComSum("0"); + } + + + if (!StringUtils.isEmpty(baseMap.getOrDefault("单位合计", "").toString())) { + po.setComSum(baseMap.get("单位合计").toString()); + } else { + po.setComSum(new BigDecimal(po.getSocialComSum() == null ? "0" : po.getSocialComSum()) + .add(new BigDecimal(po.getFundComSum() == null ? "0" : po.getFundComSum())) + .add(new BigDecimal(po.getOtherComSum() == null ? "0" : po.getOtherComSum())).toString()); + } + + if (!StringUtils.isEmpty(baseMap.getOrDefault("账单月份", "").toString())) { + po.setBillMonth(baseMap.get("账单月份").toString().substring(0, 7)); + } + + if (!StringUtils.isEmpty(baseMap.getOrDefault("社保合计", "").toString())) { + po.setSocialSum(baseMap.get("社保合计").toString()); + } else { + po.setSocialSum(new BigDecimal(po.getSocialComSum() == null ? "0" : po.getSocialComSum()) + .add(new BigDecimal(po.getSocialPerSum() == null ? "0" : po.getSocialPerSum())) + .toString()); + } + if (!StringUtils.isEmpty(baseMap.getOrDefault("公积金合计", "").toString())) { + po.setFundSum(baseMap.get("公积金合计").toString()); + } else { + po.setFundSum(new BigDecimal(po.getFundComSum() == null ? "0" : po.getFundComSum()) + .add(new BigDecimal(po.getFundPerSum() == null ? "0" : po.getFundPerSum())) + .toString()); + } + if (!StringUtils.isEmpty(baseMap.getOrDefault("其他福利合计", "").toString())) { + po.setOtherSum(baseMap.get("其他福利合计").toString()); + } else { + po.setOtherSum(new BigDecimal(po.getOtherComSum() == null ? "0" : po.getOtherComSum()) + .add(new BigDecimal(po.getOtherPerSum() == null ? "0" : po.getOtherPerSum())) + .toString()); + } + if (!StringUtils.isEmpty(baseMap.getOrDefault("合计", "").toString())) { + po.setTotal(baseMap.get("合计").toString()); + } else { + po.setTotal(new BigDecimal(po.getPerSum() == null ? "0" : po.getPerSum()) + .add(new BigDecimal(po.getComSum() == null ? "0" : po.getComSum())) + .toString()); + } + + //如果导入的时补缴数据,还会包含补缴月份 + if (!StringUtils.isEmpty(baseMap.getOrDefault("补缴月份", "").toString())) { + po.setSupplementaryMonth(baseMap.get("补缴月份").toString().substring(0, 7)); + } + + po.setUpdateTime(new Date()); + + return po; + } + + /** + * map中value值求和 + */ + public String sumOfMapValue(Map welfarePay){ + BigDecimal sum = new BigDecimal("0"); + for (String value : welfarePay.values()) { + sum = sum.add(new BigDecimal(value)); + } + return sum.toString(); + } + + /** + * 对比新旧两份数据,并更新数据 + */ + private Map checkJsonMap(Map newMap, String oldJson) { + Map oldMap = JSON.parseObject(oldJson, HashMap.class); + + Map toDelMap = new HashMap<>(); + //校验newMap中的value值是否为整数或者小数 + for(Map.Entry newEntry : newMap.entrySet()) { + String newValue = newEntry.getValue(); + int l = newValue.length(); + + if (newValue.length() > 0 && !isNumeric(newValue)) { + throw new SalaryRunTimeException("请检查导入Excel中个人或单位对应的福利项数值是否为整数或小数!"); + } + + if ("".equals(newEntry.getValue())) { + toDelMap.put(newEntry.getKey(), newEntry.getValue()); + } + } + if (toDelMap.size() > 0) { + for (Map.Entry delEntry : toDelMap.entrySet()) { + newMap.remove(delEntry.getKey()); + } + } + + + if (oldMap == null) { + return newMap; + } + //保留oldMap无变动数据,更新newMap已变动数据 + for (Map.Entry oldEntry : oldMap.entrySet()) { + if (!newMap.containsKey(oldEntry.getKey())) { + newMap.put(oldEntry.getKey(), oldEntry.getValue()); + } else if (newMap.containsKey(oldEntry.getKey()) && "".equals(newMap.get(oldEntry.getKey()))) { + newMap.put(oldEntry.getKey(), oldEntry.getValue()); + } + } + + return newMap; + } + + /** + * 判断字符串是否为整数或者小数或者负数 + */ + public static boolean isNumeric(String str){ + +// Pattern pattern = Pattern.compile("[0-9]*\\.?[0-9]+"); + Pattern pattern = Pattern.compile("^-?\\d+(\\.\\d+)?$"); + Matcher isNum = pattern.matcher(str); + if (!isNum.matches()) { + return false; + } + return true; + + + } + + /** + * 校验福利核算的账单月份输入格式是否正确 + */ + public boolean checkBillMonth(String billMonth) { + + //校验内容:billMonth的长度是否为7、年月连接符是否为“-” + String connector; + if(billMonth.length() == 7){ + connector = billMonth.substring(4,5); + return "-".equals(connector); + } else { + return false; + } + } + + /** + * 导出“福利核算-线下对比导入模板” + */ + @Override + public XSSFWorkbook exportComparisonWelfareTemplate(InsuranceAccountDetailParam param) { + Map> welColumnMap = createWelColumnMap(param); + + List headerList = Lists.newArrayList(SalaryI18nUtil.getI18nLabel(85429, "姓名"), + SalaryI18nUtil.getI18nLabel(86185, "部门"), + SalaryI18nUtil.getI18nLabel(86186, "手机号"), + SalaryI18nUtil.getI18nLabel(86317, "工号"), + SalaryI18nUtil.getI18nLabel(86187, "员工状态"), + SalaryI18nUtil.getI18nLabel(100377, "数据来源"), + SalaryI18nUtil.getI18nLabel(91325, "个税扣缴义务人")); + headerList.add(SalaryI18nUtil.getI18nLabel(91324, "社保账号")); + headerList.add(SalaryI18nUtil.getI18nLabel(91323, "社保方案名称")); + //组装社保基数 + if (welColumnMap.get("socialBase") != null) { + headerList.addAll(welColumnMap.get("socialBase")); + } + headerList.add(SalaryI18nUtil.getI18nLabel(91486, "公积金账号")); + headerList.add(SalaryI18nUtil.getI18nLabel(91485, "公积金方案名称")); + //组装公积金基数 + if (welColumnMap.get("fundBase") != null) { + headerList.addAll(welColumnMap.get("fundBase")); + } + headerList.add(SalaryI18nUtil.getI18nLabel(91487, "补充公积金账号")); + headerList.add(SalaryI18nUtil.getI18nLabel(91496, "其他福利方案名称")); + //组装其他福利基数 + if (welColumnMap.get("otherBase") != null) { + headerList.addAll(welColumnMap.get("otherBase")); + } + //社保个人(生育保险个人、工伤保险个人、失业保险个人、养老保险个人、医疗保险个人) + if (welColumnMap.get("socialPer") != null) { + headerList.addAll(welColumnMap.get("socialPer")); + } + headerList.add(SalaryI18nUtil.getI18nLabel(100388, "社保个人合计")); + //住房公积金个人、补充住房公积金个人 + if (welColumnMap.get("fundPer") != null) { + headerList.addAll(welColumnMap.get("fundPer")); + } + headerList.add(SalaryI18nUtil.getI18nLabel(100390, "公积金个人合计")); + //其他个人(比如企业年金个人) + if (welColumnMap.get("otherPer") != null) { + headerList.addAll(welColumnMap.get("otherPer")); + } + headerList.add(SalaryI18nUtil.getI18nLabel(100392, "其他福利个人合计")); + headerList.add(SalaryI18nUtil.getI18nLabel(100393, "个人合计")); + //社保单位(生育保险单位、工伤保险单位、失业保险单位、养老保险单位、医疗保险单位) + if (welColumnMap.get("socialCom") != null) { + headerList.addAll(welColumnMap.get("socialCom")); + } + headerList.add(SalaryI18nUtil.getI18nLabel(100394, "社保单位合计")); + //住房公积金单位、补充住房公积金单位 + if (welColumnMap.get("fundCom") != null) { + headerList.addAll(welColumnMap.get("fundCom")); + } + headerList.add(SalaryI18nUtil.getI18nLabel(100395, "公积金单位合计")); + //其他单位(比如企业年金单位) + if (welColumnMap.get("otherCom") != null) { + headerList.addAll(welColumnMap.get("otherCom")); + } + headerList.add(SalaryI18nUtil.getI18nLabel(100396, "其他福利单位合计")); + headerList.add(SalaryI18nUtil.getI18nLabel(100397, "单位合计")); + headerList.add(SalaryI18nUtil.getI18nLabel(100398, "社保合计")); + headerList.add(SalaryI18nUtil.getI18nLabel(100399, "公积金合计")); + headerList.add(SalaryI18nUtil.getI18nLabel(100400, "其他福利合计")); + headerList.add(SalaryI18nUtil.getI18nLabel(93278, "合计")); + + List> rows = new ArrayList<>(); + rows.add(headerList); + String sheetName = "福利核算-线下对比导入模板"; + + return ExcelUtilPlus.genWorkbookV2(rows, sheetName); + } + + public Map> createWelColumnMap(InsuranceAccountDetailParam param) { +// boolean welBaseDiffSign = siArchivesBiz.isDiffWelBase(); + boolean welBaseDiffSign = getSIArchivesService(user).isDiffWelBase(); + //查询线上福利核算记录 + InsuranceExportParam insuranceExportParam = new InsuranceExportParam(); + insuranceExportParam.setBillMonth(param.getBillMonth()); + insuranceExportParam.setPaymentOrganization(param.getPaymentOrganization()); + List accountExportPOS = getInsuranceExportMapper().exportAccount(param.getPaymentStatus(), insuranceExportParam); + + //整理线上核算记录相关的福利方案,并以此整理需要对比的福利项类别数据 + Set welfareSchemeIds = new HashSet<>(); + accountExportPOS.forEach(f -> { + welfareSchemeIds.add(f.getSocialSchemeId()); + welfareSchemeIds.add(f.getFundSchemeId()); + welfareSchemeIds.add(f.getOtherSchemeId()); + }); + List insuranceSchemeDetailPos = getInsuranceSchemeDetailMapper().listAll(); + List insuranceBaseIds = insuranceSchemeDetailPos.stream() + .filter(f -> welfareSchemeIds.contains(f.getPrimaryId()) && f.getIsPayment() == 1) + .map(InsuranceSchemeDetailPO::getInsuranceId) + .collect(Collectors.toList()); + List insurancePerPayIds = insuranceSchemeDetailPos.stream() + .filter(f -> welfareSchemeIds.contains(f.getPrimaryId()) && f.getIsPayment() == 1 && f.getPaymentScope() == 2) + .map(InsuranceSchemeDetailPO::getInsuranceId) + .collect(Collectors.toList()); + List insuranceComPayIds = insuranceSchemeDetailPos.stream() + .filter(f -> welfareSchemeIds.contains(f.getPrimaryId()) && f.getIsPayment() == 1 && f.getPaymentScope() == 1) + .map(InsuranceSchemeDetailPO::getInsuranceId) + .collect(Collectors.toList()); + Set insuranceBaseSet = new HashSet<>(insuranceBaseIds); + Set insurancePerPaySet = new HashSet<>(insurancePerPayIds); + Set insuranceComPaySet = new HashSet<>(insuranceComPayIds); + + List listAll = getICategoryMapper().listAll(); + List socialWelfareList = listAll.stream().filter(e -> e.getWelfareType() == 1 && e.getIsUse() == 1 && insuranceBaseSet.contains(e.getId())).collect(Collectors.toList()); + List fundWelfareList = listAll.stream().filter(e -> e.getWelfareType() == 2 && e.getIsUse() == 1 && insuranceBaseSet.contains(e.getId())).collect(Collectors.toList()); + List otherWelfareList = listAll.stream().filter(e -> e.getWelfareType() == 3 && e.getIsUse() == 1 && insuranceBaseSet.contains(e.getId())).collect(Collectors.toList()); + + List socialWelPerList = listAll.stream().filter(e -> e.getWelfareType() == 1 && e.getIsUse() == 1 && insurancePerPaySet.contains(e.getId())).collect(Collectors.toList()); + List fundWelPerList = listAll.stream().filter(e -> e.getWelfareType() == 2 && e.getIsUse() == 1 && insurancePerPaySet.contains(e.getId())).collect(Collectors.toList()); + List otherWelPerList = listAll.stream().filter(e -> e.getWelfareType() == 3 && e.getIsUse() == 1 && insurancePerPaySet.contains(e.getId())).collect(Collectors.toList()); + + List socialWelComList = listAll.stream().filter(e -> e.getWelfareType() == 1 && e.getIsUse() == 1 && insuranceComPaySet.contains(e.getId())).collect(Collectors.toList()); + List fundWelComList = listAll.stream().filter(e -> e.getWelfareType() == 2 && e.getIsUse() == 1 && insuranceComPaySet.contains(e.getId())).collect(Collectors.toList()); + List otherWelComList = listAll.stream().filter(e -> e.getWelfareType() == 3 && e.getIsUse() == 1 && insuranceComPaySet.contains(e.getId())).collect(Collectors.toList()); + + //组装社保基数 + List socialBaseColumns = new ArrayList<>(); + List socialPerBaseColumns = new ArrayList<>(); + List socialComBaseColumns = Lists.newArrayList(); + if (welBaseDiffSign) { + for (ICategoryPO po : socialWelfareList) { + socialPerBaseColumns.add(po.getInsuranceName() + SalaryI18nUtil.getI18nLabel(0, "申报基数") + SalaryI18nUtil.getI18nLabel(0,"个人")); + socialComBaseColumns.add(po.getInsuranceName() + SalaryI18nUtil.getI18nLabel(0, "申报基数") + SalaryI18nUtil.getI18nLabel(0,"单位")); + } + socialBaseColumns.addAll(socialPerBaseColumns); + socialBaseColumns.addAll(socialComBaseColumns); + } else { + for (ICategoryPO po : socialWelfareList) { + socialBaseColumns.add(po.getInsuranceName() + SalaryI18nUtil.getI18nLabel(0, "申报基数")); + } + } + + //组装公积金基数 + List fundBaseColumns = new ArrayList<>(); + List fundPerBaseColumns = Lists.newArrayList(); + List fundComBaseColumns = Lists.newArrayList(); + if (welBaseDiffSign) { + for (ICategoryPO po : fundWelfareList) { + fundPerBaseColumns.add(po.getInsuranceName() + SalaryI18nUtil.getI18nLabel(0, "申报基数") + SalaryI18nUtil.getI18nLabel(0,"个人")); + fundComBaseColumns.add(po.getInsuranceName() + SalaryI18nUtil.getI18nLabel(0, "申报基数") + SalaryI18nUtil.getI18nLabel(0,"单位")); + } + fundBaseColumns.addAll(fundPerBaseColumns); + fundBaseColumns.addAll(fundComBaseColumns); + } else { + for (ICategoryPO po : fundWelfareList) { + fundBaseColumns.add(po.getInsuranceName() + SalaryI18nUtil.getI18nLabel(0, "申报基数")); + } + } + + //组装其他福利基数 + List otherBaseColumns = new ArrayList<>(); + List otherPerBaseColumns = new ArrayList<>(); + List otherComBaseColumns = Lists.newArrayList(); + if (welBaseDiffSign) { + for (ICategoryPO po : otherWelfareList) { + otherPerBaseColumns.add(po.getInsuranceName() + SalaryI18nUtil.getI18nLabel(0, "申报基数") + SalaryI18nUtil.getI18nLabel(0,"个人")); + otherComBaseColumns.add(po.getInsuranceName() + SalaryI18nUtil.getI18nLabel(0, "申报基数") + SalaryI18nUtil.getI18nLabel(0,"单位")); + } + otherBaseColumns.addAll(otherPerBaseColumns); + otherBaseColumns.addAll(otherComBaseColumns); + } else { + for (ICategoryPO po : otherWelfareList) { + otherBaseColumns.add(po.getInsuranceName() + SalaryI18nUtil.getI18nLabel(0, "申报基数")); + } + } + + //社保个人(生育保险个人、工伤保险个人、失业保险个人、养老保险个人、医疗保险个人) + List socialPerColumns = new ArrayList<>(); + for (ICategoryPO po : socialWelPerList) { + socialPerColumns.add(po.getInsuranceName() + SalaryI18nUtil.getI18nLabel(0,"个人")); + } + //住房公积金个人、补充住房公积金个人 + List fundPerColumns = new ArrayList<>(); + for (ICategoryPO po : fundWelPerList) { + fundPerColumns.add(po.getInsuranceName() + SalaryI18nUtil.getI18nLabel(0,"个人")); + } + //其他个人(比如企业年金个人) + List otherPerColumns = new ArrayList<>(); + for (ICategoryPO po : otherWelPerList) { + otherPerColumns.add(po.getInsuranceName() + SalaryI18nUtil.getI18nLabel(0,"个人")); + } + //社保单位(生育保险单位、工伤保险单位、失业保险单位、养老保险单位、医疗保险单位) + List socialComColumns = new ArrayList<>(); + for (ICategoryPO po : socialWelComList) { + socialComColumns.add(po.getInsuranceName() + SalaryI18nUtil.getI18nLabel(0,"单位")); + } + //住房公积金单位、补充住房公积金单位 + List fundComColumns = new ArrayList<>(); + for (ICategoryPO po : fundWelComList) { + fundComColumns.add(po.getInsuranceName() + SalaryI18nUtil.getI18nLabel(0,"单位")); + } + + //其他单位(比如企业年金单位) + List otherComColumns = new ArrayList<>(); + for (ICategoryPO po : otherWelComList) { + otherComColumns.add(po.getInsuranceName() + SalaryI18nUtil.getI18nLabel(0,"单位")); + } + + Map> welColumnMap = new HashMap<>(); + welColumnMap.put("socialPerBase", socialPerBaseColumns); + welColumnMap.put("fundPerBase", fundPerBaseColumns); + welColumnMap.put("otherPerBase", otherPerBaseColumns); + welColumnMap.put("socialComBase", socialComBaseColumns); + welColumnMap.put("fundComBase", fundComBaseColumns); + welColumnMap.put("otherComBase", otherComBaseColumns); + welColumnMap.put("socialBase", socialBaseColumns); + welColumnMap.put("fundBase", fundBaseColumns); + welColumnMap.put("otherBase", otherBaseColumns); + welColumnMap.put("socialPer", socialPerColumns); + welColumnMap.put("fundPer", fundPerColumns); + welColumnMap.put("otherPer", otherPerColumns); + welColumnMap.put("socialCom", socialComColumns); + welColumnMap.put("fundCom", fundComColumns); + welColumnMap.put("otherCom", otherComColumns); + return welColumnMap; + } + + public Map welColumnNameCodeMap(InsuranceAccountDetailParam param) { +// boolean welBaseDiffSign = siArchivesBiz.isDiffWelBase(); + boolean welBaseDiffSign = getSIArchivesService(user).isDiffWelBase(); + //查询线上福利核算记录 + InsuranceExportParam insuranceExportParam = new InsuranceExportParam(); + insuranceExportParam.setBillMonth(param.getBillMonth()); + insuranceExportParam.setPaymentOrganization(param.getPaymentOrganization()); + List accountExportPOS = getInsuranceExportMapper().exportAccount(param.getPaymentStatus(), insuranceExportParam); + + //整理线上核算记录相关的福利方案,并以此整理需要对比的福利项类别数据 + Set welfareSchemeIds = new HashSet<>(); + accountExportPOS.forEach(f -> { + welfareSchemeIds.add(f.getSocialSchemeId()); + welfareSchemeIds.add(f.getFundSchemeId()); + welfareSchemeIds.add(f.getOtherSchemeId()); + }); + List insuranceSchemeDetailPos = getInsuranceSchemeDetailMapper().listAll(); + List insuranceBaseIds = insuranceSchemeDetailPos.stream() + .filter(f -> welfareSchemeIds.contains(f.getPrimaryId()) && f.getIsPayment() == 1) + .map(InsuranceSchemeDetailPO::getInsuranceId) + .collect(Collectors.toList()); + List insurancePerPayIds = insuranceSchemeDetailPos.stream() + .filter(f -> welfareSchemeIds.contains(f.getPrimaryId()) && f.getIsPayment() == 1 && f.getPaymentScope() == 2) + .map(InsuranceSchemeDetailPO::getInsuranceId) + .collect(Collectors.toList()); + List insuranceComPayIds = insuranceSchemeDetailPos.stream() + .filter(f -> welfareSchemeIds.contains(f.getPrimaryId()) && f.getIsPayment() == 1 && f.getPaymentScope() == 1) + .map(InsuranceSchemeDetailPO::getInsuranceId) + .collect(Collectors.toList()); + Set insuranceBaseSet = new HashSet<>(insuranceBaseIds); + Set insurancePerPaySet = new HashSet<>(insurancePerPayIds); + Set insuranceComPaySet = new HashSet<>(insuranceComPayIds); + + List listAll = getICategoryMapper().listAll(); + List socialWelfareList = listAll.stream().filter(e -> e.getWelfareType() == 1 && e.getIsUse() == 1 && insuranceBaseSet.contains(e.getId())).collect(Collectors.toList()); + List fundWelfareList = listAll.stream().filter(e -> e.getWelfareType() == 2 && e.getIsUse() == 1 && insuranceBaseSet.contains(e.getId())).collect(Collectors.toList()); + List otherWelfareList = listAll.stream().filter(e -> e.getWelfareType() == 3 && e.getIsUse() == 1 && insuranceBaseSet.contains(e.getId())).collect(Collectors.toList()); + + List socialWelPerList = listAll.stream().filter(e -> e.getWelfareType() == 1 && e.getIsUse() == 1 && insurancePerPaySet.contains(e.getId())).collect(Collectors.toList()); + List fundWelPerList = listAll.stream().filter(e -> e.getWelfareType() == 2 && e.getIsUse() == 1 && insurancePerPaySet.contains(e.getId())).collect(Collectors.toList()); + List otherWelPerList = listAll.stream().filter(e -> e.getWelfareType() == 3 && e.getIsUse() == 1 && insurancePerPaySet.contains(e.getId())).collect(Collectors.toList()); + + List socialWelComList = listAll.stream().filter(e -> e.getWelfareType() == 1 && e.getIsUse() == 1 && insuranceComPaySet.contains(e.getId())).collect(Collectors.toList()); + List fundWelComList = listAll.stream().filter(e -> e.getWelfareType() == 2 && e.getIsUse() == 1 && insuranceComPaySet.contains(e.getId())).collect(Collectors.toList()); + List otherWelComList = listAll.stream().filter(e -> e.getWelfareType() == 3 && e.getIsUse() == 1 && insuranceComPaySet.contains(e.getId())).collect(Collectors.toList()); + + //组装社保基数 + Map result = new HashMap<>(); + if (welBaseDiffSign) { + for (ICategoryPO po : socialWelfareList) { + result.put(Util.formatMultiLang(po.getInsuranceName(), String.valueOf(user.getLanguage())) + + SalaryI18nUtil.getI18nLabel(0, "申报基数") + + SalaryI18nUtil.getI18nLabel(0,"个人"), po.getId() + "socialPerBase"); + result.put(Util.formatMultiLang(po.getInsuranceName(), String.valueOf(user.getLanguage())) + + SalaryI18nUtil.getI18nLabel(0, "申报基数") + + SalaryI18nUtil.getI18nLabel(0,"单位"), po.getId() + "socialComBase"); + } + } else { + for (ICategoryPO po : socialWelfareList) { + result.put(Util.formatMultiLang(po.getInsuranceName(), String.valueOf(user.getLanguage())) + + SalaryI18nUtil.getI18nLabel(0, "申报基数"), po.getId() + "socialBase"); + } + } + + //组装公积金基数 + if (welBaseDiffSign) { + for (ICategoryPO po : fundWelfareList) { + result.put(Util.formatMultiLang(po.getInsuranceName(), String.valueOf(user.getLanguage())) + + SalaryI18nUtil.getI18nLabel(0, "申报基数") + + SalaryI18nUtil.getI18nLabel(0,"个人"), po.getId() + "fundPerBase"); + result.put(Util.formatMultiLang(po.getInsuranceName(), String.valueOf(user.getLanguage())) + + SalaryI18nUtil.getI18nLabel(0, "申报基数") + + SalaryI18nUtil.getI18nLabel(0,"单位"), po.getId() + "fundComBase"); + } + } else { + for (ICategoryPO po : fundWelfareList) { + result.put(Util.formatMultiLang(po.getInsuranceName(), String.valueOf(user.getLanguage())) + + SalaryI18nUtil.getI18nLabel(0, "申报基数"), po.getId() + "fundBase"); + } + } + + //组装其他福利基数 + if (welBaseDiffSign) { + for (ICategoryPO po : otherWelfareList) { + result.put(Util.formatMultiLang(po.getInsuranceName(), String.valueOf(user.getLanguage())) + + SalaryI18nUtil.getI18nLabel(0, "申报基数") + + SalaryI18nUtil.getI18nLabel(0,"个人"), po.getId() + "otherPerBase"); + result.put(Util.formatMultiLang(po.getInsuranceName(), String.valueOf(user.getLanguage())) + + SalaryI18nUtil.getI18nLabel(0, "申报基数") + + SalaryI18nUtil.getI18nLabel(0,"单位"), po.getId() + "otherComBase"); + } + } else { + for (ICategoryPO po : otherWelfareList) { + result.put(Util.formatMultiLang(po.getInsuranceName(), String.valueOf(user.getLanguage())) + + SalaryI18nUtil.getI18nLabel(0, "申报基数"), po.getId() + "otherBase"); + } + } + + //社保个人(生育保险个人、工伤保险个人、失业保险个人、养老保险个人、医疗保险个人) + for (ICategoryPO po : socialWelPerList) { + result.put(Util.formatMultiLang(po.getInsuranceName(), String.valueOf(user.getLanguage())) + + SalaryI18nUtil.getI18nLabel(0, "个人"), po.getId() + "socialPer"); + } + //住房公积金个人、补充住房公积金个人 + for (ICategoryPO po : fundWelPerList) { + result.put(Util.formatMultiLang(po.getInsuranceName(), String.valueOf(user.getLanguage())) + + SalaryI18nUtil.getI18nLabel(0, "个人"), po.getId() + "fundPer"); + } + //其他个人(比如企业年金个人) + for (ICategoryPO po : otherWelPerList) { + result.put(Util.formatMultiLang(po.getInsuranceName(), String.valueOf(user.getLanguage())) + + SalaryI18nUtil.getI18nLabel(0, "个人"), po.getId() + "otherPer"); + } + //社保单位(生育保险单位、工伤保险单位、失业保险单位、养老保险单位、医疗保险单位) + for (ICategoryPO po : socialWelComList) { + result.put(Util.formatMultiLang(po.getInsuranceName(), String.valueOf(user.getLanguage())) + + SalaryI18nUtil.getI18nLabel(0, "单位"), po.getId() + "socialCom"); + } + //住房公积金单位、补充住房公积金单位 + for (ICategoryPO po : fundWelComList) { + result.put(Util.formatMultiLang(po.getInsuranceName(), String.valueOf(user.getLanguage())) + + SalaryI18nUtil.getI18nLabel(0, "单位"), po.getId() + "fundCom"); + } + + //其他单位(比如企业年金单位) + for (ICategoryPO po : otherWelComList) { + result.put(Util.formatMultiLang(po.getInsuranceName(), String.valueOf(user.getLanguage())) + + SalaryI18nUtil.getI18nLabel(0, "单位"), po.getId() + "otherCom"); + } + + return result; + } + + /** + * 将通过“福利核算-线下对比导入”模板导入的数据更新到hrsa_excel_bill_detail表中 + */ + @Override + public Map importExcelInsuranceDetail(ExcelInsuranceImportParam importParam) { + + Map apidatas = new HashMap(); + + //查询对于人员信息导入筛选的全局配置 + SalarySysConfPO salarySysConfPO = getSalarySysConfMapper().getOneByCode("matchEmployeeMode"); + String confValue = (salarySysConfPO != null && salarySysConfPO.getConfValue() != null && !"".equals(salarySysConfPO.getConfValue())) ? salarySysConfPO.getConfValue() : "0"; + //检验参数 + //excel文件id + String imageId = Util.null2String(importParam.getImageId()); + + if (StringUtils.isBlank(imageId)) { + throw new SalaryRunTimeException("文件不存在"); + } + + // 获取租户下所有的人员 + List salaryEmployees = getSalaryEmployeeService(user).listAll(UseEmployeeTypeEnum.ALL); + + // 失败的数量 + int failCount = 0; + // 成功的数量 + int successCount = 0; + InputStream fileInputStream = null; + try { + fileInputStream = ImageFileManager.getInputStreamById(Integer.parseInt(importParam.getImageId())); + + Sheet sheet = ExcelSupport.parseFile(fileInputStream, 0, EXCEL_TYPE_XLSX); + + // 错误提示信息 + List excelComments = Lists.newArrayList(); + // 存在错误的那行数据 + List> errorDatas = Lists.newArrayList(); + // 表头 + List headers = ExcelSupport.getSheetHeader(sheet, 0); + // 处理数值 + List> data = ExcelParseHelper.parse2Map(sheet, 1); + if (CollectionUtils.isEmpty(headers)) { + throw new SalaryRunTimeException("表头为空"); + } + if (CollectionUtils.isEmpty(data)) { + throw new SalaryRunTimeException("无数据"); + } + + String billMonth = importParam.getBillMonth(); + +// Map welColumnNameCodeMap = welColumnNameCodeMap(InsuranceAccountDetailParam.builder() +// .billMonth(billMonth) +// .paymentOrganization(importParam.getPaymentOrganization()) +// .paymentStatus(PaymentStatusEnum.COMMON.getValue()) +// .build()); + Map welColumnNameCodeMap = new HashMap<>(); + //存储待更新的InsuranceAccountDetailPO数据 + List addCompareList = new ArrayList<>(); + //记录待删除hrsa_excel_bill_detail.id + List idList = new ArrayList<>(); + //遍历excel表具体数据 + for (int i = 0; i < data.size(); i++) { + + String row = "第" + (i + 2) + "行"; + + boolean isError = false; + Map map = data.get(i); + Long employeeId = 0L; + + List list = new ArrayList<>(); + + String taxAgentName = (String) map.getOrDefault("个税扣缴义务人", ""); + Long paymentOrganization = 0L; + List taxAgentPoList = getTaxAgentMapper().listByName(taxAgentName); + + if (taxAgentPoList.size() == 1) { + paymentOrganization = taxAgentPoList.get(0).getId(); + welColumnNameCodeMap = welColumnNameCodeMap(InsuranceAccountDetailParam.builder() + .billMonth(billMonth) + .paymentOrganization(paymentOrganization.toString()) + .paymentStatus(PaymentStatusEnum.COMMON.getValue()) + .build()); + } else { + isError = true; + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", row + SalaryI18nUtil.getI18nLabel(100579, SalaryI18nUtil.getI18nLabel(102840, "个税扣缴义务人错误,系统内不存在该个税扣缴义务人"))); + excelComments.add(errorMessageMap); + } + + //遍历表头 + for (int j = 0; j < headers.size(); j++) { + String header = headers.get(j); + String dataKey = header; + if (dataKey == null) { + continue; + } + String dataValue = (String) map.getOrDefault(dataKey.toString(), ""); + String deparmentName = (String) map.getOrDefault("部门", ""); + String mobile = (String) map.getOrDefault("手机号", ""); + String workcode = (String) map.getOrDefault("工号", ""); + String idNo = (String) map.getOrDefault("证件号码", ""); + + + if (StringUtils.equals(SalaryI18nUtil.getI18nLabel(85429, "姓名"), dataKey.toString())) { + //当人员信息导入筛选的全局配置为"0"时,姓名才是必填项 + if (StringUtils.isEmpty(dataValue) && "0".equals(confValue)) { + isError = true; + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", row + SalaryI18nUtil.getI18nLabel(102838, "姓名不能为空")); + excelComments.add(errorMessageMap); + + } else { + //筛选导入人员信息可以在人力资源池中匹配到的人员信息 + List employeeSameIds = getSalaryEmployeeService(user).matchImportEmployee(confValue,salaryEmployees, dataValue, deparmentName, mobile, workcode, idNo,null); + + if (CollectionUtils.isEmpty(employeeSameIds)) { + isError = true; + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", row + SalaryI18nUtil.getI18nLabel(100579, "姓名错误,系统内不存在该姓名")); + excelComments.add(errorMessageMap); + + } else if (employeeSameIds.size() > 1) { + //存在离职和在职状态取在职状态 + employeeSameIds = employeeSameIds.stream() + .filter(e -> UserStatusEnum.getNormalStatus().contains(e.getStatus())) + .collect(Collectors.toList()); + if (employeeSameIds.size() != 1) { + isError = true; + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", row + "员工信息不存在或者存在多个员工"); + excelComments.add(errorMessageMap); + } else { + employeeId = CollectionUtils.isNotEmpty(employeeSameIds) && employeeSameIds.size() == 1 ? employeeSameIds.get(0).getEmployeeId() : null; + } + } else { + employeeId = employeeSameIds.get(0).getEmployeeId(); + } + } + } + + + } + + if (!isError){ + List employeeIds = new ArrayList<>(); + employeeIds.add(employeeId); + //根据员工id、个税扣缴义务人id、账单月份查询,如果当前对比表中存在数据,则记录为待删除数据 + list = getExcelInsuranceDetailMapper().queryCompareList(billMonth, paymentOrganization, employeeIds.get(0)); + + if (!list.isEmpty()) { + List ids = list.stream().map(ExcelInsuranceDetailPO::getId) + .collect(Collectors.toList()); + + idList.addAll(ids); + } + //拼装待更新数据 + addCompareList.add(handleExcelInsuranceDetail(billMonth, employeeId, paymentOrganization, map, welColumnNameCodeMap)); + + } + + if (isError) { + failCount++; + errorDatas.add(map); + } else { + successCount++; + } + + } + //将待更新列表加密 + encryptUtil.encryptList(addCompareList, ExcelInsuranceDetailPO.class); + //删除 + if (idList.size() > 0) { + getExcelInsuranceDetailMapper().batchDelByIds(idList); + } + //新增 + List> partition = Lists.partition((List) addCompareList, 20); + partition.forEach(getExcelInsuranceDetailMapper()::batchSave); + +// getExcelInsuranceDetailMapper().batchSave(addCompareList); + + apidatas.put("successCount", successCount); + apidatas.put("errorCount", failCount); + apidatas.put("errorData", excelComments); + + } finally { + IOUtils.closeQuietly(fileInputStream); + } + return apidatas; + } + + /** + * 将excel导入的数据行组装成ExcelInsuranceDetailPO对象 + * @param billMonth 对比的账单月份 + * @param baseMap excel导入的对比数据 + */ + private ExcelInsuranceDetailPO handleExcelInsuranceDetail(String billMonth, Long employeeId, Long paymentOrganization, Map baseMap, Map welColumnNameCodeMap) { +// boolean welBaseDiffSign = siArchivesBiz.isDiffWelBase(); + boolean welBaseDiffSign = getSIArchivesService(user).isDiffWelBase(); + + ExcelInsuranceDetailPO excelInsuranceDetailPO = new ExcelInsuranceDetailPO(); + excelInsuranceDetailPO.setId(IdGenerator.generate()); + //组装json数据,格式Map + Map socialPerMap = new HashMap<>(); + Map fundPerMap = new HashMap<>(); + Map otherPerMap = new HashMap<>(); + Map socialComMap = new HashMap<>(); + Map fundComMap = new HashMap<>(); + Map otherComMap = new HashMap<>(); + //组装福利基数 + Map socialPaymentBaseMap = new HashMap<>(); + Map fundPaymentBaseMap = new HashMap<>(); + Map otherPaymentBaseMap = new HashMap<>(); + + Map socialPaymentComBaseMap = new HashMap<>(); + Map fundPaymentComBaseMap = new HashMap<>(); + Map otherPaymentComBaseMap = new HashMap<>(); + + //筛选出福利核算项 + Map toDealMap = + baseMap.entrySet().stream() + .filter(map -> !"姓名".equals(map.getKey()) + && !"部门".equals(map.getKey()) + && !"手机号".equals(map.getKey()) + && !"个税扣缴义务人".equals(map.getKey()) + && !"员工状态".equals(map.getKey()) + && !"数据来源".equals(map.getKey()) + && !"工号".equals(map.getKey())) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + + for(Map.Entry entry : toDealMap.entrySet()) { +// //判断元素是否属于福利类 +// String keyName = entry.getKey(); +// //获取元素名后缀,方便之后判断“个人”或“单位”或者“基数” +// String payScope = keyName.substring(keyName.length() - 2); +// //获取福利类型 +// Integer welfareType; +// //根据元素名后缀,区分截取内容 +// String targetWelfareName; +// if ("基数".equals(payScope)) { +// targetWelfareName = entry.getKey().substring(0, keyName.length() - 4); +// } else { +// targetWelfareName = entry.getKey().substring(0, keyName.length() - 2); +// } +// List categoryPOList = siCategoryBiz.listByName(targetWelfareName); +// if (categoryPOList.size() == 1) { +// ICategoryPO iCategoryPO = categoryPOList.get(0); +// welfareType = iCategoryPO.getWelfareType(); +// +// switch (payScope) { +// case "个人": +// switch (welfareType) { +// case 1: +// socialPerMap.put(iCategoryPO.getId().toString(), entry.getValue().toString()); +// break; +// case 2: +// fundPerMap.put(iCategoryPO.getId().toString(), entry.getValue().toString()); +// break; +// case 3: +// otherPerMap.put(iCategoryPO.getId().toString(), entry.getValue().toString()); +// break; +// default: +// throw new SalaryRunTimeException("福利类型不存在"); +// } +// break; +// case "单位": +// switch (welfareType) { +// case 1: +// socialComMap.put(iCategoryPO.getId().toString(), entry.getValue().toString()); +// break; +// case 2: +// fundComMap.put(iCategoryPO.getId().toString(), entry.getValue().toString()); +// break; +// case 3: +// otherComMap.put(iCategoryPO.getId().toString(), entry.getValue().toString()); +// break; +// default: +// throw new SalaryRunTimeException("福利类型不存在"); +// } +// break; +// case "基数": +// switch (welfareType) { +// case 1: +// socialPaymentBaseMap.put(iCategoryPO.getId().toString(), entry.getValue().toString()); +// break; +// case 2: +// fundPaymentBaseMap.put(iCategoryPO.getId().toString(), entry.getValue().toString()); +// break; +// case 3: +// otherPaymentBaseMap.put(iCategoryPO.getId().toString(), entry.getValue().toString()); +// break; +// default: +// throw new SalaryRunTimeException("福利类型不存在"); +// } +// break; +// } +// } + + if (welColumnNameCodeMap.get(entry.getKey()) != null) { + String code = welColumnNameCodeMap.get(entry.getKey()); + if (welBaseDiffSign) { + if (code.contains("socialPerBase")) { + code = code.replace("socialPerBase", ""); + socialPaymentBaseMap.put(code, entry.getValue().toString()); + continue; + } + if (code.contains("socialComBase")) { + code = code.replace("socialComBase", ""); + socialPaymentComBaseMap.put(code, entry.getValue().toString()); + continue; + } + if (code.contains("fundPerBase")) { + code = code.replace("fundPerBase", ""); + fundPaymentBaseMap.put(code, entry.getValue().toString()); + continue; + } + if (code.contains("fundComBase")) { + code = code.replace("fundComBase", ""); + fundPaymentComBaseMap.put(code, entry.getValue().toString()); + continue; + } + if (code.contains("otherPerBase")) { + code = code.replace("otherPerBase", ""); + otherPaymentBaseMap.put(code, entry.getValue().toString()); + continue; + } + if (code.contains("otherComBase")) { + code = code.replace("otherComBase", ""); + otherPaymentComBaseMap.put(code, entry.getValue().toString()); + continue; + } + } else { + if (code.contains("socialBase")) { + code = code.replace("socialBase", ""); + socialPaymentBaseMap.put(code, entry.getValue().toString()); + continue; + } + if (code.contains("fundBase")) { + code = code.replace("fundBase", ""); + fundPaymentBaseMap.put(code, entry.getValue().toString()); + continue; + } + if (code.contains("otherBase")) { + code = code.replace("otherBase", ""); + otherPaymentBaseMap.put(code, entry.getValue().toString()); + continue; + } + } + + + if (code.contains("socialPer") && !code.contains("socialPerBase")) { + code = code.replace("socialPer", ""); + socialPerMap.put(code, entry.getValue().toString()); + continue; + } + if (code.contains("fundPer") && !code.contains("fundPerBase")) { + code = code.replace("fundPer", ""); + fundPerMap.put(code, entry.getValue().toString()); + continue; + } + if (code.contains("otherPer") && !code.contains("otherPerBase")) { + code = code.replace("otherPer", ""); + otherPerMap.put(code, entry.getValue().toString()); + continue; + } + + if (code.contains("socialCom") && !code.contains("socialComBase")) { + code = code.replace("socialCom", ""); + socialComMap.put(code, entry.getValue().toString()); + continue; + } + if (code.contains("fundCom") && !code.contains("fundComBase")) { + code = code.replace("fundCom", ""); + fundComMap.put(code, entry.getValue().toString()); + continue; + } + if (code.contains("otherCom") && !code.contains("otherComBase")) { + code = code.replace("otherCom", ""); + otherComMap.put(code, entry.getValue().toString()); + continue; + } + } + } + + //设置社保个人和公司缴纳明细 + excelInsuranceDetailPO.setSocialPerJson(JSON.toJSONString(socialPerMap)); + excelInsuranceDetailPO.setSocialComJson(JSON.toJSONString(socialComMap)); + //设置公积金个人和公司缴纳明细 + excelInsuranceDetailPO.setFundPerJson(JSON.toJSONString(fundPerMap)); + excelInsuranceDetailPO.setFundComJson(JSON.toJSONString(fundComMap)); + //设置其他福利个人和公司缴纳明细 + excelInsuranceDetailPO.setOtherPerJson(JSON.toJSONString(otherPerMap)); + excelInsuranceDetailPO.setOtherComJson(JSON.toJSONString(otherComMap)); + //设置社保、公积金、其他福利缴纳基数 + excelInsuranceDetailPO.setSocialPaymentBaseString(JSON.toJSONString(socialPaymentBaseMap)); + excelInsuranceDetailPO.setFundPaymentBaseString(JSON.toJSONString(fundPaymentBaseMap)); + excelInsuranceDetailPO.setOtherPaymentBaseString(JSON.toJSONString(otherPaymentBaseMap)); + + excelInsuranceDetailPO.setSocialPaymentComBaseString(JSON.toJSONString(socialPaymentComBaseMap)); + excelInsuranceDetailPO.setFundPaymentComBaseString(JSON.toJSONString(fundPaymentComBaseMap)); + excelInsuranceDetailPO.setOtherPaymentComBaseString(JSON.toJSONString(otherPaymentComBaseMap)); + + //组装新的insuranceAccountDetailPO对象数据 + excelInsuranceDetailPO.setEmployeeId(employeeId); + excelInsuranceDetailPO.setBillMonth(billMonth); + excelInsuranceDetailPO.setBillStatus(1); + excelInsuranceDetailPO.setPaymentStatus(0); + excelInsuranceDetailPO.setResourceFrom(1); + excelInsuranceDetailPO.setSocialAccount(baseMap.getOrDefault("社保账号", "").toString()); + if (baseMap.getOrDefault("社保方案名称", "") != null) { + List socialSchemeList = getInsuranceSchemeMapper().listByName(baseMap.get("社保方案名称").toString()); + if (socialSchemeList.size() == 1) { + //设置社保方案id + excelInsuranceDetailPO.setSocialSchemeId(socialSchemeList.get(0).getId()); + } + } + excelInsuranceDetailPO.setFundAccount(baseMap.getOrDefault("公积金账号", "").toString()); + excelInsuranceDetailPO.setSupplementFundAccount(baseMap.getOrDefault("补充公积金账号", "").toString()); + if (baseMap.getOrDefault("公积金方案名称", "") != null) { + List fundSchemeList = getInsuranceSchemeMapper().listByName(baseMap.get("公积金方案名称").toString()); + if (fundSchemeList.size() == 1) { + //设置公积金方案id + excelInsuranceDetailPO.setFundSchemeId(fundSchemeList.get(0).getId()); + } + } + if (baseMap.getOrDefault("其他福利方案名称", "") != null) { + List otherSchemeList = getInsuranceSchemeMapper().listByName(baseMap.get("其他福利方案名称").toString()); + if (otherSchemeList.size() == 1) { + //其他福利方案id + excelInsuranceDetailPO.setOtherSchemeId(otherSchemeList.get(0).getId()); + } + } + + excelInsuranceDetailPO.setSocialPerSum(baseMap.getOrDefault("社保个人合计", "").toString()); + excelInsuranceDetailPO.setFundPerSum(baseMap.getOrDefault("公积金个人合计", "").toString()); + excelInsuranceDetailPO.setOtherPerSum(baseMap.getOrDefault("其他福利个人合计", "").toString()); + excelInsuranceDetailPO.setPerSum(baseMap.getOrDefault("个人合计", "").toString()); + + excelInsuranceDetailPO.setSocialComSum(baseMap.getOrDefault("社保单位合计", "").toString()); + excelInsuranceDetailPO.setFundComSum(baseMap.getOrDefault("公积金单位合计", "").toString()); + excelInsuranceDetailPO.setOtherComSum(baseMap.getOrDefault("其他福利单位合计", "").toString()); + excelInsuranceDetailPO.setComSum(baseMap.getOrDefault("单位合计", "").toString()); + + excelInsuranceDetailPO.setSocialSum(baseMap.getOrDefault("社保合计", "").toString()); + excelInsuranceDetailPO.setFundSum(baseMap.getOrDefault("公积金合计", "").toString()); + excelInsuranceDetailPO.setOtherSum(baseMap.getOrDefault("其他福利合计", "").toString()); + excelInsuranceDetailPO.setTotal(baseMap.getOrDefault("合计", "").toString()); + + excelInsuranceDetailPO.setCreator((long) user.getUID()); + excelInsuranceDetailPO.setCreateTime(new Date()); + excelInsuranceDetailPO.setUpdateTime(new Date()); + excelInsuranceDetailPO.setDeleteType(0); + excelInsuranceDetailPO.setTenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY); + excelInsuranceDetailPO.setPaymentOrganization(paymentOrganization); + + + return excelInsuranceDetailPO; + } + + /** + * 刷新_bill_batch表中的统计信息 + */ + @Override + public void refreshBillBatch(Long paymentOrganization, String billMonth) { + ExecutorService taskExecutor = Executors.newCachedThreadPool(); + taskExecutor.execute(() -> { + + if (paymentOrganization != null && billMonth != null) { + InsuranceAccountDetailParam refreshParam =new InsuranceAccountDetailParam(); + refreshParam.setBillMonth(billMonth); + refreshParam.setPaymentOrganization(paymentOrganization.toString()); + PageInfo pageInfos = overView(refreshParam); + TaxAgentPO taxAgentPo = getTaxAgentMapper().getById(paymentOrganization); + if (taxAgentPo != null) { + List viewListDTOList = pageInfos.getList(); + viewListDTOList.stream().filter(f -> f.getPayOrg().equals(taxAgentPo.getName())).collect(Collectors.toList()); + InsuranceAccountBatchPO batchPO = getInsuranceAccountBatchMapper().getByBillMonth(billMonth, paymentOrganization); + batchPO = encryptUtil.decrypt(batchPO, InsuranceAccountBatchPO.class); + //更新 + if (viewListDTOList.size() > 0 && batchPO != null) { + InsuranceAccountViewListDTO viewListDTO = viewListDTOList.get(0); + batchPO.setSocialNum(viewListDTO.getSocialNum()); + batchPO.setFundNum(viewListDTO.getFundNum()); + batchPO.setOtherNum(viewListDTO.getOtherNum()); + + batchPO.setSocialPay(viewListDTO.getSocialPaySum().replace(",", "")); + batchPO.setFundPay(viewListDTO.getFundPaySum().replace(",", "")); + batchPO.setOtherPay(viewListDTO.getOtherPaySum().replace(",", "")); + + batchPO.setUpdateTime(new Date()); + batchPO = encryptUtil.encrypt(batchPO, InsuranceAccountBatchPO.class); + getInsuranceAccountBatchMapper().updateById(batchPO); + } + } + + } + }); + } + /** + * 将通过id获取InsuranceAccountDetailPO中的社保、公积金、其他福利个人和公司缴纳数据 + */ + @Override + public Map getPaymentById(Long id) { + + InsuranceAccountDetailPO insuranceAccountDetailPO = getInsuranceAccountDetailMapper().getById(id); + if (insuranceAccountDetailPO == null) { + throw new SalaryRunTimeException("该条核算数据不存在!"); + } + encryptUtil.decrypt(insuranceAccountDetailPO, InsuranceAccountDetailPO.class); + String socialPerJson = insuranceAccountDetailPO.getSocialPerJson(); + String socialComJson = insuranceAccountDetailPO.getSocialComJson(); + String fundPerJson = insuranceAccountDetailPO.getFundPerJson(); + String fundComJson = insuranceAccountDetailPO.getFundComJson(); + String otherPerJson = insuranceAccountDetailPO.getOtherPerJson(); + String otherComJson = insuranceAccountDetailPO.getOtherComJson(); + + Map dataMap = new HashMap<>(); + List addGroups = new ArrayList<>(); + + getPaymentGroup(socialPerJson, "个人", "社保", dataMap, addGroups); + getPaymentGroup(socialComJson, "公司", "社保", dataMap, addGroups); + getPaymentGroup(fundPerJson, "个人", "公积金", dataMap, addGroups); + getPaymentGroup(fundComJson, "公司", "公积金", dataMap, addGroups); + getPaymentGroup(otherPerJson, "个人", "其他福利", dataMap, addGroups); + getPaymentGroup(otherComJson, "公司", "其他福利", dataMap, addGroups); + + Map resultMap = new HashMap<>(); +// resultMap.put("data", dataMap); +// resultMap.put("items", addGroups); + + // 获取当前放方案信息 + InsuranceArchivesSocialSchemePO socialSchemePO = new InsuranceArchivesSocialSchemePO(); + InsuranceArchivesFundSchemePO fundSchemePO = new InsuranceArchivesFundSchemePO(); + InsuranceArchivesOtherSchemePO otherSchemePO = new InsuranceArchivesOtherSchemePO(); + + List insuranceSchemeDetailPOS = new ArrayList<>(); + List schemeIdList = new ArrayList<>(); + if (insuranceAccountDetailPO.getSocialSchemeId() == null) { + List socialSchemePOList = getSocialSchemeMapper().getSocialByEmployeeIdAndPayOrg(InsuranceArchivesEmployeePO.builder() + .employeeId(insuranceAccountDetailPO.getEmployeeId()) + .paymentOrganization(insuranceAccountDetailPO.getPaymentOrganization()) + .build()); + if (socialSchemePOList.size() > 0) { + encryptUtil.decryptList(socialSchemePOList, InsuranceArchivesSocialSchemePO.class); + socialSchemePO = socialSchemePOList.get(0); + } + schemeIdList.add(socialSchemePO.getSocialSchemeId()); + } else { + schemeIdList.add(insuranceAccountDetailPO.getSocialSchemeId()); + } + + if (insuranceAccountDetailPO.getFundSchemeId() == null) { + List fundSchemePOList = getFundSchemeMapper().getFundByEmployeeIdAndPayOrg(InsuranceArchivesEmployeePO.builder() + .employeeId(insuranceAccountDetailPO.getEmployeeId()) + .paymentOrganization(insuranceAccountDetailPO.getPaymentOrganization()) + .build()); + if (fundSchemePOList.size() > 0) { + encryptUtil.decryptList(fundSchemePOList, InsuranceArchivesFundSchemePO.class); + fundSchemePO = fundSchemePOList.get(0); + } + schemeIdList.add(fundSchemePO.getFundSchemeId()); + } else { + schemeIdList.add(insuranceAccountDetailPO.getFundSchemeId()); + } + + if (insuranceAccountDetailPO.getOtherSchemeId() == null) { + List otherSchemePOList = getOtherSchemeMapper().getOtherByEmployeeIdAndPayOrg(InsuranceArchivesEmployeePO.builder() + .employeeId(insuranceAccountDetailPO.getEmployeeId()) + .paymentOrganization(insuranceAccountDetailPO.getPaymentOrganization()) + .build()); + if (otherSchemePOList.size() > 0) { + encryptUtil.decryptList(otherSchemePOList, InsuranceArchivesOtherSchemePO.class); + otherSchemePO = otherSchemePOList.get(0); + } + schemeIdList.add(otherSchemePO.getOtherSchemeId()); + } else { + schemeIdList.add(insuranceAccountDetailPO.getOtherSchemeId()); + } + + schemeIdList = schemeIdList.stream().filter(schemeId -> schemeId != null).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(schemeIdList)) { + insuranceSchemeDetailPOS = getInsuranceSchemeDetailMapper().listBySchemeIds(schemeIdList); + } + Map schemeValidNumMap = SalaryEntityUtil.convert2Map(insuranceSchemeDetailPOS, po -> po.getInsuranceId() + "-" + po.getPaymentScope(), InsuranceSchemeDetailPO::getValidNum); + + List> perList = new ArrayList<>(); + List> comList = new ArrayList<>(); + for (SearchConditionGroup group : addGroups) { + + if (group.getItems() != null && group.getItems().size() > 0) { + for (SearchConditionItem item : group.getItems()) { + Map map = new HashMap<>(); + + String[] domkey = item.getDomkey(); + String insuranceId = domkey[0].substring(3); + if (group.getTitle().contains("个人")) { + map.put("title", group.getTitle()); + map.put("titleSign", getTotalSign(group.getTitle())); + map.put("paymentScope", "个人"); + map.put("paymentScopeSign", "per"); + map.put("insuranceName", item.getLabel()); + map.put("insuranceId", insuranceId); + map.put("insuranceValue", dataMap.get(domkey[0])); + map.put("validNum", schemeValidNumMap.getOrDefault(insuranceId + "-2", 2).toString()); + if (map.get("insuranceValue") != null && !"".equals(map.get("insuranceValue"))) { + + perList.add(map); + } + + } else if (group.getTitle().contains("公司")) { + map.put("title", group.getTitle()); + map.put("titleSign", getTotalSign(group.getTitle())); + map.put("paymentScope", "公司"); + map.put("paymentScopeSign", "com"); + map.put("insuranceName", item.getLabel()); + map.put("insuranceId", insuranceId); + map.put("insuranceValue", dataMap.get(domkey[0])); + map.put("validNum", schemeValidNumMap.getOrDefault(insuranceId + "-1", 2).toString()); + if (map.get("insuranceValue") != null && !"".equals(map.get("insuranceValue"))) { + + comList.add(map); + } + + } + } + } + + } + + List> resultList = new ArrayList<>(); + resultList.addAll(perList); + resultList.addAll(comList); +// resultMap.put("data", resultList); + //20231123逻辑变更,对于补差的待编辑内容,扩充其人员档案设置的福利项内容 + if (insuranceAccountDetailPO.getPaymentStatus().equals(PaymentStatusEnum.BALANCE.getValue())) { + List> balancePaymentGroup = getSIBalanceService(user).getPaymentGroup(BalanceAccountBaseParam.builder() + .employeeId(insuranceAccountDetailPO.getEmployeeId()) + .paymentOrganization(insuranceAccountDetailPO.getPaymentOrganization()).build()); + if (balancePaymentGroup != null && balancePaymentGroup.size() > 0) { + //抽取已有福利项生成map + Map targetMap = new HashMap<>(); + for (Map resultItem : resultList) { + targetMap.put(resultItem.get("insuranceId") + "-" + resultItem.get("paymentScope"), resultItem); + } + //对比可进行缴纳福利项与上面的已有福利项生成map + for (Map balancePayItem : balancePaymentGroup) { + Map target = (Map)targetMap.get(balancePayItem.get("insuranceId") + "-" + balancePayItem.get("paymentScope")); + if (targetMap.get(balancePayItem.get("insuranceId") + "-" + balancePayItem.get("paymentScope")) == null) { + balancePayItem.put("insuranceValue", ""); + balancePayItem.put("validNum", balancePayItem.get("validNum")); + resultList.add(balancePayItem); + } else { + target.put("validNum", balancePayItem.get("validNum")); + } + + } + } + } + resultMap.put("data", resultList); + return resultMap; + } + + public String getTotalSign(String total) { + if (StringUtils.isNotBlank(total)) { + return total.contains(SalaryI18nUtil.getI18nLabel(0,"社保")) ? "social" : (total.contains(SalaryI18nUtil.getI18nLabel(0,"公积金")) ? "fund" : "other" ); + } else { + return ""; + } + } + public void getPaymentGroup(String baseJson, String groupType, String welfareType, Map dataMap, List addGroups) { + + if (StringUtils.isBlank(baseJson)) { + addGroups.add(new SearchConditionGroup(welfareType + groupType +"缴纳", true, null)); + return; + } + + String groupPrefix = "个人".equals(groupType) ? "per" : "com"; + + Map toDealMap = JSON.parseObject(baseJson, new HashMap().getClass()); + Map baseJsonMap = new HashMap<>(); + List inputItems = new ArrayList<>(); + + for (Map.Entry entry : toDealMap.entrySet()) { + //获取福利项信息 +// ICategoryPO iCategoryPO = siCategoryBiz.getByID(Long.valueOf(entry.getKey())); + ICategoryPO iCategoryPO = getSICategoryService(user).getICategoryPOByID(Long.valueOf(entry.getKey())); + if (iCategoryPO != null) { + String name = groupPrefix + iCategoryPO.getId().toString(); + String label = iCategoryPO.getInsuranceName(); + inputItems.add(SalaryFormItemUtil.inputNumberItem(user, "precision:2", 2, 12, 2, label, name)); + } + baseJsonMap.put(groupPrefix + entry.getKey(), entry.getValue()); + } + dataMap.putAll(baseJsonMap); + addGroups.add(new SearchConditionGroup(welfareType + groupType +"缴纳", true, inputItems)); + } + + /** + * 编辑InsuranceAccountDetailPO中的社保、公积金、其他福利个人和公司缴纳数据 + */ + @Override + public void editAccount(EditAccountDetailParam param) { + InsuranceAccountDetailPO insuranceAccountDetailPO = getInsuranceAccountDetailMapper().getById(param.getId()); + if (insuranceAccountDetailPO == null) { + throw new SalaryRunTimeException("该条核算数据不存在!"); + } + encryptUtil.decrypt(insuranceAccountDetailPO, InsuranceAccountDetailPO.class); + + InsuranceAccountDetailPO oldTargetPO = new InsuranceAccountDetailPO(); + BeanUtils.copyProperties(insuranceAccountDetailPO, oldTargetPO); + + accountSocialByData(insuranceAccountDetailPO, param); + accountFundByData(insuranceAccountDetailPO, param); + accountOtherByData(insuranceAccountDetailPO, param); + account(insuranceAccountDetailPO); + + encryptUtil.encrypt(insuranceAccountDetailPO, InsuranceAccountDetailPO.class); + getInsuranceAccountDetailMapper().updateById(insuranceAccountDetailPO); + + //刷新_bill_batch表中的统计信息 + refreshBillBatch(insuranceAccountDetailPO.getPaymentOrganization(), insuranceAccountDetailPO.getBillMonth()); + //记录操作日志 + PaymentStatusEnum targetEnum = SalaryEnumUtil.enumMatchByValue(insuranceAccountDetailPO.getPaymentStatus(), PaymentStatusEnum.values(), PaymentStatusEnum.class); + encryptUtil.decrypt(insuranceAccountDetailPO, InsuranceAccountDetailPO.class); + InsuranceAccountBatchPO targetPO = getInsuranceAccountBatchMapper().getByBillMonth(insuranceAccountDetailPO.getBillMonth(), insuranceAccountDetailPO.getPaymentOrganization()); + TaxAgentPO taxAgentInfo = getTaxAgentMapper().getById(targetPO.getPaymentOrganization()); + DataCollectionEmployee empInfo = getSalaryEmployeeService(user).getEmployeeById(insuranceAccountDetailPO.getEmployeeId()); + LoggerContext loggerContext = new LoggerContext(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(targetPO.getId())); + loggerContext.setTargetName(taxAgentInfo.getName() + "-" + targetPO.getBillMonth() + "-" + empInfo.getUsername()); + loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "福利台账明细表-编辑") + + SalaryI18nUtil.getI18nLabel(targetEnum.getLabelId(), targetEnum.getDefaultLabel())); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "福利台账明细表-编辑" + + SalaryI18nUtil.getI18nLabel(targetEnum.getLabelId(), targetEnum.getDefaultLabel())) + + ":" + taxAgentInfo.getName() + "-" + targetPO.getBillMonth() + "-" + empInfo.getUsername()); + loggerContext.setOldValues(oldTargetPO); + loggerContext.setNewValues(insuranceAccountDetailPO); + SalaryElogConfig.siAccountLoggerTemplate.write(loggerContext); + } + + public void accountFundByData(InsuranceAccountDetailPO insuranceAccountDetailPO, EditAccountDetailParam baseParam) { + //公积金个人 + if (StringUtils.isNotBlank(baseParam.getFundPerJson())) { + List fundPer = new ArrayList<>(); + HashMap fundPerson = JSON.parseObject(baseParam.getFundPerJson(), new HashMap().getClass()); + fundPerson.forEach((k, v) -> { + BigDecimal result = new BigDecimal(v); + fundPer.add(result); + }); + insuranceAccountDetailPO.setFundPerJson(baseParam.getFundPerJson()); + BigDecimal fundPerSum = new BigDecimal("0"); + for (BigDecimal bigDecimal : fundPer) { + fundPerSum = fundPerSum.add(bigDecimal); + } + insuranceAccountDetailPO.setFundPerSum(fundPerSum.toPlainString()); + } + //公积金单位 + if (StringUtils.isNotBlank(baseParam.getFundComJson())) { + List fundCom = new ArrayList<>(); + HashMap fundComMap = JSON.parseObject(baseParam.getFundComJson(), new HashMap().getClass()); + fundComMap.forEach((k, v) -> { + BigDecimal result = new BigDecimal(v); + fundCom.add(result); + }); + insuranceAccountDetailPO.setFundComJson(baseParam.getFundComJson()); + BigDecimal fundComSum = new BigDecimal("0"); + for (BigDecimal bigDecimal : fundCom) { + fundComSum = fundComSum.add(bigDecimal); + } + insuranceAccountDetailPO.setFundComSum(fundComSum.toPlainString()); + } + } + + public void accountOtherByData(InsuranceAccountDetailPO insuranceAccountDetailPO, EditAccountDetailParam baseParam) { + //其他福利个人 + if (StringUtils.isNotBlank(baseParam.getOtherPerJson())) { + List otherPer = new ArrayList<>(); + HashMap otherPerMap = JSON.parseObject(baseParam.getOtherPerJson(), new HashMap().getClass()); + otherPerMap.forEach((k, v) -> { + BigDecimal result = new BigDecimal(v); + otherPer.add(result); + }); + insuranceAccountDetailPO.setOtherPerJson(baseParam.getOtherPerJson()); + BigDecimal otherPerSum = new BigDecimal("0"); + for (BigDecimal bigDecimal : otherPer) { + otherPerSum = otherPerSum.add(bigDecimal); + } + insuranceAccountDetailPO.setOtherPerSum(otherPerSum.toPlainString()); + } + //其他福利单位 + if (StringUtils.isNotBlank(baseParam.getOtherComJson())) { + List otherCom = new ArrayList<>(); + HashMap otherComMap = JSON.parseObject(baseParam.getOtherComJson(), new HashMap().getClass()); + otherComMap.forEach((k, v) -> { + BigDecimal result = new BigDecimal(v); + otherCom.add(result); + }); + insuranceAccountDetailPO.setOtherComJson(baseParam.getOtherComJson()); + BigDecimal otherComSum = new BigDecimal("0"); + for (BigDecimal bigDecimal : otherCom) { + otherComSum = otherComSum.add(bigDecimal); + } + insuranceAccountDetailPO.setOtherComSum(otherComSum.toPlainString()); + } + } + + public void accountSocialByData(InsuranceAccountDetailPO insuranceAccountDetailPO, EditAccountDetailParam baseParam) { + //社保个人 + if (StringUtils.isNotBlank(baseParam.getSocialPerJson())) { + List socialPer = new ArrayList<>(); + HashMap archivesPerson = JSON.parseObject(baseParam.getSocialPerJson(), new HashMap().getClass()); + archivesPerson.forEach((k, v) -> { + BigDecimal result = new BigDecimal(v); + socialPer.add(result); + }); + insuranceAccountDetailPO.setSocialPerJson(baseParam.getSocialPerJson()); + BigDecimal socialPerSum = new BigDecimal("0"); + for (BigDecimal bigDecimal : socialPer) { + socialPerSum = socialPerSum.add(bigDecimal); + } + insuranceAccountDetailPO.setSocialPerSum(socialPerSum.toPlainString()); + } + //社保单位 + if (StringUtils.isNotBlank(baseParam.getSocialComJson())) { + List socialCom = new ArrayList<>(); + HashMap archivesCom = JSON.parseObject(baseParam.getSocialComJson(), new HashMap().getClass()); + archivesCom.forEach((k, v) -> { + BigDecimal result = new BigDecimal(v); + socialCom.add(result); + }); + insuranceAccountDetailPO.setSocialComJson(baseParam.getSocialComJson()); + BigDecimal socialComSum = new BigDecimal("0"); + for (BigDecimal bigDecimal : socialCom) { + socialComSum = socialComSum.add(bigDecimal); + } + insuranceAccountDetailPO.setSocialComSum(socialComSum.toPlainString()); + } + } + + public InsuranceAccountDetailPO account(InsuranceAccountDetailPO insuranceAccountDetailPO) { + //个人合计 + BigDecimal socialPerson = + StringUtils.isBlank(insuranceAccountDetailPO.getSocialPerSum()) ? new BigDecimal("0") : new BigDecimal(insuranceAccountDetailPO.getSocialPerSum()); + BigDecimal fundPerson = + StringUtils.isBlank(insuranceAccountDetailPO.getFundPerSum()) ? new BigDecimal("0") : new BigDecimal(insuranceAccountDetailPO.getFundPerSum()); + BigDecimal otherPerson = + StringUtils.isBlank(insuranceAccountDetailPO.getOtherPerSum()) ? new BigDecimal("0") : new BigDecimal(insuranceAccountDetailPO.getOtherPerSum()); + BigDecimal perSum = socialPerson.add(fundPerson).add(otherPerson); + insuranceAccountDetailPO.setPerSum(perSum.toPlainString()); + //单位合计 + BigDecimal socialCom = + StringUtils.isBlank(insuranceAccountDetailPO.getSocialComSum()) ? new BigDecimal("0") : new BigDecimal(insuranceAccountDetailPO.getSocialComSum()); + BigDecimal fundCom = StringUtils.isBlank(insuranceAccountDetailPO.getFundComSum()) ? new BigDecimal("0") : new BigDecimal(insuranceAccountDetailPO.getFundComSum()); + BigDecimal otherCom = + StringUtils.isBlank(insuranceAccountDetailPO.getOtherComSum()) ? new BigDecimal("0") : new BigDecimal(insuranceAccountDetailPO.getOtherComSum()); + BigDecimal comSum = socialCom.add(fundCom).add(otherCom); + insuranceAccountDetailPO.setComSum(comSum.toPlainString()); + //社保合计 + insuranceAccountDetailPO.setSocialSum(socialPerson.add(socialCom).toPlainString()); + //公积金合计 + insuranceAccountDetailPO.setFundSum(fundPerson.add(fundCom).toPlainString()); + //其他福利合计 + insuranceAccountDetailPO.setOtherSum(otherPerson.add(otherCom).toPlainString()); + //合计 + insuranceAccountDetailPO.setTotal(perSum.add(comSum).toPlainString()); + return insuranceAccountDetailPO; + } + + /** + * 导出“福利核算-补差导入”模板 + */ + @Override + public XSSFWorkbook exportBalanceImportTemplate(InsuranceAcctDetailImportTemplateParam param) { + ValidUtil.doValidator(param); + + // 必须选择导入模板所需的薪资项目(福利项) + if (CollectionUtils.isEmpty(param.getWelfareNames())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(99019, "参数错误,请选择导入模板所需的福利项目核算项")); + } + + // 模板表头(默认必带"个税扣缴义务人"、"姓名") + List headerList = Lists.newArrayList(SalaryI18nUtil.getI18nLabel(85429, "姓名"), + "部门", + SalaryI18nUtil.getI18nLabel(86186, "手机号"), + SalaryI18nUtil.getI18nLabel(86317, "工号"), + SalaryI18nUtil.getI18nLabel(86317, "证件号码"), + SalaryI18nUtil.getI18nLabel(86184, "个税扣缴义务人") + ); + List dataIndexList = Lists.newArrayList("username", "departmentName", "mobile", "workcode","idNo", "taxAgentName"); + // 查询福利核算项目 + List welfareNames = (List) param.getWelfareNames(); + headerList.addAll(welfareNames); + + List> rows = new ArrayList<>(); + //查询当前已有的补差数据 + List> resultMapList = getBalanceDataByBillMonth(param.getBillMonth(), param.getPaymentOrganization()); + // excel导出的数据 + rows.add(headerList); + for (Map map : resultMapList) { + List row = Lists.newArrayListWithExpectedSize(headerList.size()); + for (String dataIndex : dataIndexList) { + row.add(map.getOrDefault(dataIndex, StringUtils.EMPTY)); + } + rows.add(row); + } + + String sheetName = "福利核算-补差导入模板"; + return ExcelUtil.genWorkbookV2(rows, sheetName); + } + + /** + * 将福利台账-补差模板导入的数据更新到数据库 + */ + @Override + public Map importBalanceInsuranceDetail(InsuranceAcctImportParam importParam) { + long currentEmployeeId = user.getUID(); +// Boolean openDevolution = getTaxAgentService(user).isOpenDevolution(); + + Map apidatas = new HashMap(); + + //查询对于人员信息导入筛选的全局配置 + SalarySysConfPO salarySysConfPO = getSalarySysConfMapper().getOneByCode("matchEmployeeMode"); + String confValue = (salarySysConfPO != null && salarySysConfPO.getConfValue() != null && !"".equals(salarySysConfPO.getConfValue())) ? salarySysConfPO.getConfValue() : "0"; + //检验参数 + //excel文件id + String imageId = Util.null2String(importParam.getImageId()); + + if (StringUtils.isBlank(imageId)) { + throw new SalaryRunTimeException("文件不存在"); + } +// // 获取所有个税扣缴义务人 +// List taxAgents = getTaxAgentService(user).listAll(); +// Map taxAgentNameMap = SalaryEntityUtil.convert2Map(taxAgents, TaxAgentPO::getName, TaxAgentPO::getId); + + // 获取租户下所有的人员 + List salaryEmployees = getSalaryEmployeeService(user).listEmployee(); + + List insuranceCategoryPOS = getICategoryMapper().listAll(); + // 失败的数量 + int failCount = 0; + // 成功的数量 + int successCount = 0; + InputStream fileInputStream = null; + try { + fileInputStream = ImageFileManager.getInputStreamById(Integer.parseInt(importParam.getImageId())); + + Sheet sheet = ExcelSupport.parseFile(fileInputStream, 0, EXCEL_TYPE_XLSX); + + // 错误提示信息 + List excelComments = Lists.newArrayList(); + // 存在错误的那行数据 + List> errorDatas = Lists.newArrayList(); + // 表头 + List headers = ExcelSupport.getSheetHeader(sheet, 0); + // 处理数值 + List> data = ExcelParseHelper.parse2Map(sheet, 1); + if (CollectionUtils.isEmpty(headers)) { + throw new SalaryRunTimeException("表头为空"); + } + if (CollectionUtils.isEmpty(data)) { + throw new SalaryRunTimeException("无数据"); + } + //存储待更新的InsuranceAccountDetailPO数据 + List updateInsuranceAccountDetailList = new ArrayList<>(); + + //存储待新增的InsuranceAccountDetailPO数据 + List createInsuranceAccountDetailList = new ArrayList<>(); + + String billMonth = importParam.getBillMonth(); + //遍历excel表具体数据 + for (int i = 0; i < data.size(); i++) { + + String row = "第" + (i + 2) + "行"; + + boolean isError = false; + Map map = data.get(i); + Long employeeId = 0L; +// Long taxAgentId = 0L; + + List list = new ArrayList<>(); + + + String taxAgentName = (String) map.getOrDefault("个税扣缴义务人", ""); + + Long paymentOrganization = 0L; + List taxAgentPoList = getTaxAgentMapper().listByName(taxAgentName); + + if (taxAgentPoList.size() == 1) { + paymentOrganization = taxAgentPoList.get(0).getId(); + } else { + isError = true; + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", row + SalaryI18nUtil.getI18nLabel(100579, SalaryI18nUtil.getI18nLabel(102840, "个税扣缴义务人错误,系统内不存在该个税扣缴义务人"))); + excelComments.add(errorMessageMap); + } + + if (billMonth.length() < 7 || !SalaryDateUtil.checkYearMonth(billMonth.substring(0, 7))) { + isError = true; + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", row + SalaryI18nUtil.getI18nLabel(100579, "账单月份输入有误,请参照“2022-09”这种格式进行检查")); + excelComments.add(errorMessageMap); + } + + List> singleAccount = new ArrayList<>(); + + //遍历表头 + for (int j = 0; j < headers.size(); j++) { + String header = headers.get(j); + String dataKey = header; + if (dataKey == null) { + continue; + } + //组装单条数据基础数据 + Map cellData = new HashMap<>(); + cellData.put(dataKey, Optional.ofNullable(map.get(dataKey)).orElse("").toString()); + cellData.put("index", j); + singleAccount.add(cellData); + //抽取人员信息进行校验 + String name = (String) map.getOrDefault("姓名", ""); + String departmentName = (String) map.getOrDefault("部门", ""); + String mobile = (String) map.getOrDefault("手机号", ""); + String workcode = (String) map.getOrDefault("工号", ""); + String idNo = (String) map.getOrDefault("证件号码", ""); + + + if (StringUtils.equals(SalaryI18nUtil.getI18nLabel(85429, "姓名"), dataKey.toString())) { + //当人员信息导入筛选的全局配置为"0"时,姓名才是必填项 + if (StringUtils.isEmpty(name) && "0".equals(confValue)) { + isError = true; + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", row + SalaryI18nUtil.getI18nLabel(102838, "姓名不能为空")); + excelComments.add(errorMessageMap); + + } else { + //筛选导入人员信息可以在人力资源池中匹配到的人员信息 + List employeeSameIds = getSalaryEmployeeService(user).matchImportEmployee(confValue,salaryEmployees, name, departmentName, mobile, workcode,idNo, null); + + if (CollectionUtils.isEmpty(employeeSameIds)) { + isError = true; + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", row + SalaryI18nUtil.getI18nLabel(100579, "姓名错误,系统内不存在该姓名")); + excelComments.add(errorMessageMap); + + } else if (employeeSameIds.size() > 1) { + //存在离职和在职状态取在职状态 + employeeSameIds = employeeSameIds.stream() + .filter(e -> UserStatusEnum.getNormalStatus().contains(e.getStatus())) + .collect(Collectors.toList()); + if (employeeSameIds.size() != 1) { + isError = true; + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", row + "员工信息不存在或者存在多个员工"); + excelComments.add(errorMessageMap); + } else { + employeeId = CollectionUtils.isNotEmpty(employeeSameIds) && employeeSameIds.size() == 1 ? employeeSameIds.get(0).getEmployeeId() : null; + } + } else { + employeeId = employeeSameIds.get(0).getEmployeeId(); + } + } + } + + + } + + if (!isError){ + + //如果福利核算信息查询不到唯一匹配数据,不支持导入 + //根据员工id、个税扣缴义务人id、账单月份查询补差数据 + list = getInsuranceAccountDetailMapper().queryBalanceList(InsuranceAccountDetailPO.builder() + .employeeId(employeeId) + .paymentOrganization(paymentOrganization) + .billMonth(billMonth.substring(0, 7)) + .build()); + + if (list.isEmpty()) { + //新增数据情况 + InsuranceAccountDetailPO createPO = buildBalanceAccountDetail(paymentOrganization, insuranceCategoryPOS, singleAccount, billMonth, employeeId, currentEmployeeId); + + if(!checkBalancePayInsurance(createPO)) { + isError = true; + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", row + SalaryI18nUtil.getI18nLabel(0, "补差数据中存在福利档案中未设置的福利项缴纳数值,请检查补差缴纳信息!")); + excelComments.add(errorMessageMap); + } + + if(checkBalance(createPO) && !isError) { + createInsuranceAccountDetailList.add(createPO); + } else { + isError = true; + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", row + SalaryI18nUtil.getI18nLabel(100579, "该人员在当前账单月不存在补差数据中的福利类,请检查补差缴纳信息!")); + excelComments.add(errorMessageMap); + } + + } else if (list.size() > 1) { + isError = true; + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", row + SalaryI18nUtil.getI18nLabel(100579, "该人员在当前账单月已存在多组补差数据,请删除数据库中多余项")); + excelComments.add(errorMessageMap); + } else { + //更新数据情况 + //拼装待更新数据 + encryptUtil.decryptList(list, InsuranceAccountDetailPO.class); + InsuranceAccountDetailPO updatePO = handleInsuranceAccountDetail(list.get(0), map); + + if(!checkBalancePayInsurance(updatePO)) { + isError = true; + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", row + SalaryI18nUtil.getI18nLabel(0, "补差数据中存在福利档案中未设置的福利项缴纳数值,请检查补差缴纳信息!")); + excelComments.add(errorMessageMap); + } + + if(checkBalance(updatePO) && !isError) { + updateInsuranceAccountDetailList.add(updatePO); + } else { + isError = true; + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", row + SalaryI18nUtil.getI18nLabel(100579, "该人员在当前账单月不存在补差数据中的福利类,请检查补差缴纳信息!")); + excelComments.add(errorMessageMap); + } + + } + + } + + if (isError) { + failCount++; + errorDatas.add(map); + } else { + successCount++; + } + + } + Long paymentOrganization = null; + if (updateInsuranceAccountDetailList.size() > 0) { + paymentOrganization = updateInsuranceAccountDetailList.get(0).getPaymentOrganization(); + //将待更新列表加密 + encryptUtil.encryptList(updateInsuranceAccountDetailList, InsuranceAccountDetailPO.class); + //更新 + for(InsuranceAccountDetailPO po : updateInsuranceAccountDetailList) { +// getSiAccountBiz(user).updateByEmployeeIdAndBillMonth(po); + updateByEmployeeIdAndBillMonth(po); + } + //记录操作日志 + encryptUtil.decryptList(updateInsuranceAccountDetailList, InsuranceAccountDetailPO.class); + InsuranceAccountBatchPO targetPO = getInsuranceAccountBatchMapper().getByBillMonth(billMonth, paymentOrganization); + TaxAgentPO taxAgentInfo = getTaxAgentMapper().getById(targetPO.getPaymentOrganization()); + LoggerContext loggerContext = new LoggerContext(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(targetPO.getId())); + loggerContext.setTargetName(taxAgentInfo.getName() + "-" + targetPO.getBillMonth()); + loggerContext.setOperateType(OperateTypeEnum.EXCEL_IMPORT.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "福利台账明细表-补差导入更新")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "福利台账明细表-补差导入更新") + + ":" + taxAgentInfo.getName() + "-" + targetPO.getBillMonth()); + updateInsuranceAccountDetailList.forEach(loggerContext::setNewValues); + SalaryElogConfig.siAccountLoggerTemplate.write(loggerContext); + } + if (createInsuranceAccountDetailList.size() > 0) { + paymentOrganization = createInsuranceAccountDetailList.get(0).getPaymentOrganization(); + //去除员工id+个税扣缴义务人下重复的数据 + createInsuranceAccountDetailList = createInsuranceAccountDetailList.stream() + .collect(Collectors.collectingAndThen(Collectors.toCollection(() + -> new TreeSet<>(Comparator.comparing(f -> f.getPaymentOrganization() + "-" + f.getEmployeeId()))), ArrayList::new)); + //将待新增列表加密 + encryptUtil.encryptList(createInsuranceAccountDetailList, InsuranceAccountDetailPO.class); + //新增 + List> createPartition = Lists.partition((List) createInsuranceAccountDetailList, 20); + createPartition.forEach(getInsuranceAccountDetailMapper()::batchSaveAccountDetails); + //记录操作日志 + encryptUtil.decryptList(createInsuranceAccountDetailList, InsuranceAccountDetailPO.class); + InsuranceAccountBatchPO targetPO = getInsuranceAccountBatchMapper().getByBillMonth(billMonth, paymentOrganization); + TaxAgentPO taxAgentInfo = getTaxAgentMapper().getById(targetPO.getPaymentOrganization()); + LoggerContext loggerContext = new LoggerContext(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(targetPO.getId())); + loggerContext.setTargetName(taxAgentInfo.getName() + "-" + targetPO.getBillMonth()); + loggerContext.setOperateType(OperateTypeEnum.EXCEL_IMPORT.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "福利台账明细表-补差导入新增")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "福利台账明细表-补差导入新增") + + ":" + taxAgentInfo.getName() + "-" + targetPO.getBillMonth()); + createInsuranceAccountDetailList.forEach(loggerContext::setNewValues); + SalaryElogConfig.siAccountLoggerTemplate.write(loggerContext); + } + + //刷新bill_batch表中统计信息 + refreshBillBatch(paymentOrganization, importParam.getBillMonth()); + + apidatas.put("successCount", successCount); + apidatas.put("errorCount", failCount); + apidatas.put("errorData", excelComments); + + } finally { + IOUtils.closeQuietly(fileInputStream); + } + return apidatas; + } + + + @Override + public Map listCommonSum(InsuranceAccountDetailParam queryParam) { + + Long employeeId = (long) user.getUID(); + Map datas = new HashMap<>(); + + // 正常缴纳列表 + queryParam.setPageSize(10000000); +// PageInfo pageInfo = getSiAccountBiz(user).listCommonPage(queryParam); + PageInfo pageInfo = siBatchListCommonPage(queryParam); + List insuranceAccountDetailPOS = pageInfo.getList(); + // 数据组装 + List> records = getService(user).buildCommonRecords(insuranceAccountDetailPOS, employeeId, false); +// Map maxSizeRecord = records.stream().reduce(new HashMap<>(), (a, b) -> a.size() > b.size() ? a : b); + Map sumRow = countSum(records); + datas.put("sumRow", sumRow); + return datas; + } + + @Override + public Map listSupplementarySum(InsuranceAccountDetailParam queryParam) { + Long employeeId = (long) user.getUID(); + Map datas = new HashMap<>(); + queryParam.setPageSize(10000000); + +// //过滤出福利档案基础信息表中runStatus为正在缴纳和待减员的人员 +// List baseInfoPOList = getInsuranceBaseInfoMapper().listAll(); +// List canAccountIds = baseInfoPOList.stream() +// .filter(f->f.getPaymentOrganization().toString().equals(queryParam.getPaymentOrganization()) +// && (f.getRunStatus().equals(EmployeeStatusEnum.PAYING.getValue()) || f.getRunStatus().equals(EmployeeStatusEnum.STAY_DEL.getValue()))) +// .map(InsuranceArchivesBaseInfoPO::getEmployeeId) +// .collect(Collectors.toList()); +// queryParam.setEmployeeIds(canAccountIds); + + //补缴缴纳列表 + queryParam.setPaymentStatus(PaymentStatusEnum.REPAIR.getValue()); + + //排序配置 + OrderRuleVO orderRule = getSalarySysConfService(user).orderRule(); + queryParam.setOrderRule(orderRule); + + //系统人员核算明细 + List list = getInsuranceAccountDetailMapper().list(queryParam); + //非系统人员核算明细 + List extList = getInsuranceAccountDetailMapper().extList(queryParam); + list.addAll(extList); + encryptUtil.decryptList(list, InsuranceAccountDetailPO.class); + //数据组装 + List> records = getService(user).buildCommonRecords(list, employeeId, false); +// Map maxSizeRecord = records.stream().reduce(new HashMap<>(), (a, b) -> a.size() > b.size() ? a : b); + Map sumRow = countSum(records); + datas.put("sumRow", sumRow); + return datas; + } + + @Override + public Map listRecessionSum(InsuranceAccountDetailParam queryParam) { + Long employeeId = (long) user.getUID(); + Map datas = new HashMap<>(); + queryParam.setPageSize(10000000); + + //退差列表 + queryParam.setPaymentStatus(PaymentStatusEnum.RECESSION.getValue()); + + //排序配置 + OrderRuleVO orderRule = getSalarySysConfService(user).orderRule(); + queryParam.setOrderRule(orderRule); + + //系统人员核算明细 + List list = getInsuranceAccountDetailMapper().list(queryParam); + //非系统人员核算明细 + List extList = getInsuranceAccountDetailMapper().extList(queryParam); + list.addAll(extList); + encryptUtil.decryptList(list, InsuranceAccountDetailPO.class); + //数据组装 + List> records = getService(user).buildCommonRecords(list, employeeId, false); + Map sumRow = countSum(records); + datas.put("sumRow", sumRow); + return datas; + } + + @Override + public Map listBalanceSum(InsuranceAccountDetailParam queryParam) { + Long employeeId = (long) user.getUID(); + Map datas = new HashMap<>(); + queryParam.setPageSize(10000000); + + //补差列表 + queryParam.setPaymentStatus(PaymentStatusEnum.BALANCE.getValue()); + + //排序配置 + OrderRuleVO orderRule = getSalarySysConfService(user).orderRule(); + queryParam.setOrderRule(orderRule); + + //系统人员核算明细 + List list = getInsuranceAccountDetailMapper().list(queryParam); + //非系统人员核算明细 + List extList = getInsuranceAccountDetailMapper().extList(queryParam); + list.addAll(extList); + encryptUtil.decryptList(list, InsuranceAccountDetailPO.class); + //数据组装 + List> records = getService(user).buildCommonRecords(list, employeeId, false); + Map sumRow = countSum(records); + datas.put("sumRow", sumRow); + return datas; + } + + public Map countSum(List> records ){ + // 获取需要统计的列 + String[] keys = {"Base", "Com", "Sum", "Per", "total"}; + Set numKeys = new HashSet<>(); +// for(String key : maxSizeRecord.keySet()){ +// if(StringUtils.containsAny(key,keys)){ +// numKeys.add(key); +// } +// } + for(int i =0; i < records.size(); i++){ + Map record = records.get(i); + for(String key : record.keySet()){ + if(StringUtils.containsAny(key,keys)){ + numKeys.add(key); + } + } + } + Map sumRow = new HashMap<>(); + for(String numKey : numKeys){ + BigDecimal value = new BigDecimal(0); + for(Map record : records){ + BigDecimal addValue = null; + if(record.get(numKey) == null || StringUtils.isBlank(record.get(numKey).toString())){ + addValue = new BigDecimal(0); + }else{ + addValue = new BigDecimal(record.get(numKey).toString()); + } + value = value.add(addValue); + } +// sumRow.put(numKey,value); + sumRow.put(numKey,String.format("%.2f", value)); + + } + return sumRow; + } + + + /** + * 检查补差数据中的福利缴纳费用相关福利类别,是否在正常缴纳中有设置缴纳 + * @param po + * @return + */ + @Override + public boolean checkBalance(InsuranceAccountDetailPO po) { + InsuranceAccountDetailPO commonAccountPO = getInsuranceAccountDetailMapper().getOneByBpep(InsuranceAccountDetailPO.builder() + .billMonth(po.getBillMonth()) + .paymentStatus(PaymentStatusEnum.COMMON.getValue()) + .employeeId(po.getEmployeeId()) + .paymentOrganization(po.getPaymentOrganization()) + .build()); + if (commonAccountPO != null) { + + encryptUtil.decrypt(commonAccountPO, InsuranceAccountDetailPO.class); + boolean commonSocialNullFlag = (StringUtils.isBlank(commonAccountPO.getSocialSum()) || SalaryEntityUtil.StringEqZERO(commonAccountPO.getSocialSum())); + boolean commonFundNullFlag = (StringUtils.isBlank(commonAccountPO.getFundSum()) || SalaryEntityUtil.StringEqZERO(commonAccountPO.getFundSum())); + boolean commonOtherNullFlag = (StringUtils.isBlank(commonAccountPO.getOtherSum()) || SalaryEntityUtil.StringEqZERO(commonAccountPO.getOtherSum())); + + boolean balanceSocialNullFlag = (StringUtils.isBlank(po.getSocialSum()) || SalaryEntityUtil.StringEqZERO(po.getSocialSum())); + boolean balanceFundNullFlag = (StringUtils.isBlank(po.getFundSum()) || SalaryEntityUtil.StringEqZERO(po.getFundSum())); + boolean balanceOtherNullFlag = (StringUtils.isBlank(po.getOtherSum()) || SalaryEntityUtil.StringEqZERO(po.getOtherSum())); + //在正常缴纳数据中未设置的福利类别(社保、公积金、其他福利),不允许在补差数据中缴纳 + if ((commonSocialNullFlag && !balanceSocialNullFlag) || (commonFundNullFlag && !balanceFundNullFlag) || (commonOtherNullFlag && !balanceOtherNullFlag)) { + return false; + } else { + return true; + } + } else { + return false; + } + } + + /** + * 检查补差数据中的福利缴纳费用相关福利项,是否在正常缴纳中方案所设置可缴纳 + * @param po + * @return + */ + @Override + public boolean checkBalancePayInsurance(InsuranceAccountDetailPO po) { + InsuranceAccountDetailPO commonAccountPO = getInsuranceAccountDetailMapper().getOneByBpep(InsuranceAccountDetailPO.builder() + .billMonth(po.getBillMonth()) + .paymentStatus(PaymentStatusEnum.COMMON.getValue()) + .employeeId(po.getEmployeeId()) + .paymentOrganization(po.getPaymentOrganization()) + .build()); + if (commonAccountPO != null) { + encryptUtil.decrypt(commonAccountPO, InsuranceAccountDetailPO.class); + //判断社保缴纳福利项是否合规 + boolean socialPayFlag = true; + Map socialPerPayMap = JSON.parseObject(po.getSocialPerJson(), new HashMap().getClass()); + Map socialComPayMap = JSON.parseObject(po.getSocialComJson(), new HashMap().getClass()); + //目标员工设置了方案时,比较方案中缴纳的福利项和补差中设置(有效值)的福利项 + if (commonAccountPO.getSocialSchemeId() != null) { + List payInsuranceIdAndScopeList = payInsuranceIdAndScopeList(commonAccountPO.getSocialSchemeId()); + if (socialPerPayMap != null) { + for (Map.Entry entry : socialPerPayMap.entrySet()) { + if (!payInsuranceIdAndScopeList.contains(entry.getKey() + "-" + PaymentScopeEnum.SCOPE_PERSON.getValue()) + && StringUtils.isNotBlank(entry.getValue())) { + socialPayFlag = false; + break; + } + } + } + + if (socialPayFlag && socialComPayMap != null) { + for (Map.Entry entry : socialComPayMap.entrySet()) { + if (!payInsuranceIdAndScopeList.contains(entry.getKey() + "-" + PaymentScopeEnum.SCOPE_COMPANY.getValue()) + && StringUtils.isNotBlank(entry.getValue())) { + socialPayFlag = false; + break; + } + + } + } + + } else { + //目标员工未设置方案时,判断补差中是否设置(有效值)的福利项 + if (socialPerPayMap != null) { + for (Map.Entry entry : socialPerPayMap.entrySet()) { + if (StringUtils.isNotBlank(entry.getValue())) { + socialPayFlag = false; + break; + } + + } + } + + if (socialPayFlag && socialComPayMap != null) { + for (Map.Entry entry : socialComPayMap.entrySet()) { + if (StringUtils.isNotBlank(entry.getValue())) { + socialPayFlag = false; + break; + } + + } + } + } + + //判断公积金缴纳福利项是否合规 + boolean fundPayFlag = true; + Map fundPerPayMap = JSON.parseObject(po.getFundPerJson(), new HashMap().getClass()); + Map fundComPayMap = JSON.parseObject(po.getFundComJson(), new HashMap().getClass()); + //目标员工设置了方案时,比较方案中缴纳的福利项和补差中设置(有效值)的福利项 + if (commonAccountPO.getFundSchemeId() != null) { + List payInsuranceIdAndScopeList = payInsuranceIdAndScopeList(commonAccountPO.getFundSchemeId()); + if (fundPerPayMap != null) { + for (Map.Entry entry : fundPerPayMap.entrySet()) { + if (!payInsuranceIdAndScopeList.contains(entry.getKey() + "-" + PaymentScopeEnum.SCOPE_PERSON.getValue()) + && StringUtils.isNotBlank(entry.getValue())) { + fundPayFlag = false; + break; + } + + } + } + + if (fundPayFlag && fundComPayMap != null) { + for (Map.Entry entry : fundComPayMap.entrySet()) { + if (!payInsuranceIdAndScopeList.contains(entry.getKey() + "-" + PaymentScopeEnum.SCOPE_COMPANY.getValue()) + && StringUtils.isNotBlank(entry.getValue())) { + fundPayFlag = false; + break; + } + + } + } + + } else { + //目标员工未设置方案时,判断补差中是否设置(有效值)的福利项 + if (fundPerPayMap != null) { + for (Map.Entry entry : fundPerPayMap.entrySet()) { + if (StringUtils.isNotBlank(entry.getValue())) { + fundPayFlag = false; + break; + } + + } + } + + if (fundPayFlag && fundComPayMap != null) { + for (Map.Entry entry : fundComPayMap.entrySet()) { + if (StringUtils.isNotBlank(entry.getValue())) { + fundPayFlag = false; + break; + } + + } + } + } + + //判断其他福利缴纳福利项是否合规 + boolean otherPayFlag = true; + Map otherPerPayMap = JSON.parseObject(po.getOtherPerJson(), new HashMap().getClass()); + Map otherComPayMap = JSON.parseObject(po.getOtherComJson(), new HashMap().getClass()); + //目标员工设置了方案时,比较方案中缴纳的福利项和补差中设置(有效值)的福利项 + if (commonAccountPO.getOtherSchemeId() != null) { + List payInsuranceIdAndScopeList = payInsuranceIdAndScopeList(commonAccountPO.getOtherSchemeId()); + if (otherPerPayMap != null) { + for (Map.Entry entry : otherPerPayMap.entrySet()) { + if (!payInsuranceIdAndScopeList.contains(entry.getKey() + "-" + PaymentScopeEnum.SCOPE_PERSON.getValue()) + && StringUtils.isNotBlank(entry.getValue())) { + otherPayFlag = false; + break; + } + + } + } + + if (otherPayFlag && otherComPayMap != null) { + for (Map.Entry entry : otherComPayMap.entrySet()) { + if (!payInsuranceIdAndScopeList.contains(entry.getKey() + "-" + PaymentScopeEnum.SCOPE_COMPANY.getValue()) + && StringUtils.isNotBlank(entry.getValue())) { + otherPayFlag = false; + break; + } + + } + } + + } else { + //目标员工未设置方案时,判断补差中是否设置(有效值)的福利项 + if(otherPerPayMap != null) { + for (Map.Entry entry : otherPerPayMap.entrySet()) { + if (StringUtils.isNotBlank(entry.getValue())) { + otherPayFlag = false; + break; + } + + } + } + if (otherPayFlag && otherComPayMap != null) { + for (Map.Entry entry : otherComPayMap.entrySet()) { + if (StringUtils.isNotBlank(entry.getValue())) { + otherPayFlag = false; + break; + } + + } + } + } + + //在社保、公积金、其他福利档案中未设置的福利项被补差设置有效数值时,不允许更新 + if (socialPayFlag && fundPayFlag && otherPayFlag) { + return true; + } else { + return false; + } + } else { + return false; + } + } + + public List payInsuranceIdAndScopeList(Long schemeId) { + //查询该福利方案下开启缴纳的福利项 + List detailPOS = getInsuranceSchemeDetailMapper().queryListBySchemeId(schemeId); + List insuranceIdList = new ArrayList<>(); + if (detailPOS != null && detailPOS.size() > 0) { + //开启缴纳的 + insuranceIdList = detailPOS.stream().filter(f -> f.getIsPayment().equals(IsPaymentEnum.YES.getValue())).map(m -> { + return m.getInsuranceId() .toString() + "-" + m.getPaymentScope().toString(); + }).collect(Collectors.toList()); + } + return insuranceIdList; + } + + public InsuranceAccountDetailPO buildBalanceAccountDetail(Long paymentOrganization, List insuranceCategoryPOS, + List> singleAccount, String billMonth, Long employeeId, Long creator) { + InsuranceAccountDetailPO insuranceAccountDetailPO = new InsuranceAccountDetailPO(); + insuranceAccountDetailPO.setId(IdGenerator.generate()); + insuranceAccountDetailPO.setEmployeeId(employeeId); + DataCollectionEmployee employee = getSalaryEmployeeService(user).getEmployeeById(employeeId); + if (employee != null) { + insuranceAccountDetailPO.setSubcompanyName(employee.getSubcompanyName()); + insuranceAccountDetailPO.setSubcompanyId(employee.getSubcompanyid()); + insuranceAccountDetailPO.setDepartmentName(employee.getDepartmentName()); + insuranceAccountDetailPO.setDepartmentId(employee.getDepartmentId()); + insuranceAccountDetailPO.setJobtitleName(employee.getJobtitleName()); + insuranceAccountDetailPO.setJobtitleId(employee.getJobtitleId()); + insuranceAccountDetailPO.setJobcall(employee.getJobcall()); + insuranceAccountDetailPO.setJobcallId(employee.getJobcallId()); + insuranceAccountDetailPO.setStatus(employee.getStatus()); + } + + insuranceAccountDetailPO.setBillMonth(billMonth.substring(0, 7)); + insuranceAccountDetailPO.setBillStatus(BillStatusEnum.NOT_ARCHIVED.getValue()); + insuranceAccountDetailPO.setPaymentStatus(PaymentStatusEnum.BALANCE.getValue()); + insuranceAccountDetailPO.setResourceFrom(ResourceFromEnum.IMPORT.getValue()); + + insuranceAccountDetailPO.setCreator(creator); + insuranceAccountDetailPO.setDeleteType(DeleteTypeEnum.NOT_DELETED.getValue()); + insuranceAccountDetailPO.setCreateTime(new Date()); + insuranceAccountDetailPO.setUpdateTime(new Date()); + insuranceAccountDetailPO.setTenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY); + insuranceAccountDetailPO.setPaymentOrganization(paymentOrganization); + insuranceAccountDetailPO.setSocialPayOrg(paymentOrganization); + insuranceAccountDetailPO.setFundPayOrg(paymentOrganization); + insuranceAccountDetailPO.setOtherPayOrg(paymentOrganization); + + InsuranceArchivesBaseInfoPO baseInfoPO = getInsuranceBaseInfoMapper().getOneByEmployeeIdAndPayOrg(employeeId, paymentOrganization); + if (baseInfoPO != null) { + InsuranceArchivesSocialSchemePO socialSchemePO = getSocialSchemeMapper().getOneById(baseInfoPO.getSocialArchivesId()); + + InsuranceArchivesFundSchemePO fundSchemePO = getFundSchemeMapper().getOneById(baseInfoPO.getFundArchivesId()); + if (socialSchemePO != null) { + insuranceAccountDetailPO.setSocialAccount(socialSchemePO.getSocialAccount()); + } + if (fundSchemePO != null) { + insuranceAccountDetailPO.setFundAccount(fundSchemePO.getFundAccount()); + insuranceAccountDetailPO.setSupplementFundAccount(fundSchemePO.getSupplementFundAccount()); + } + } + + //获取改员工社保档案 + accountBalanceSocial(singleAccount, insuranceAccountDetailPO, insuranceCategoryPOS, creator); + accountBalanceFund(singleAccount, insuranceAccountDetailPO, insuranceCategoryPOS, creator); + // 其他福利档案 + accountBalanceOther(singleAccount, insuranceAccountDetailPO, insuranceCategoryPOS, creator); + account(insuranceAccountDetailPO); + if (insuranceAccountDetailPO.getOtherSchemeId() == null) { + insuranceAccountDetailPO.setOtherSchemeId(0L); + } + if (insuranceAccountDetailPO.getSocialSchemeId() == null) { + insuranceAccountDetailPO.setSocialSchemeId(0L); + } + if (insuranceAccountDetailPO.getFundSchemeId() == null) { + insuranceAccountDetailPO.setFundSchemeId(0L); + } + return insuranceAccountDetailPO; + } + + public InsuranceAccountDetailPO accountBalanceSocial(List> singleAccount, InsuranceAccountDetailPO insuranceAccountDetailPO, + List insuranceCategoryPOS, Long employeeId) { + //社保-个人 + List socialCategory = insuranceCategoryPOS.stream().filter(po -> po.getWelfareType().equals(WelfareTypeEnum.SOCIAL_SECURITY.getValue())) + .collect(Collectors.toList()); + List socialPer = new ArrayList<>(); + Map socialPerJsonMap = new HashMap<>(); + for (int i = 0; i < singleAccount.size(); i++) { + Map stringObjectMap = singleAccount.get(i); + Optional personalOptional = socialCategory.stream() + .filter(social -> stringObjectMap.containsKey(social.getInsuranceName() + SalaryI18nUtil.getI18nLabel(87159, "个人"))).findFirst(); + if (personalOptional.isPresent() && StringUtils + .isNotBlank((String) stringObjectMap.get(personalOptional.get().getInsuranceName() + SalaryI18nUtil.getI18nLabel(87159, "个人")))) { + String perNumString = (String) stringObjectMap.get(personalOptional.get().getInsuranceName() + SalaryI18nUtil.getI18nLabel(87159, "个人")); + if (perNumString.length() > 0 && !isNumeric(perNumString)) { + continue; + } + + perNumString = perNumString.replace(",", ""); + BigDecimal result = new BigDecimal(perNumString); + socialPerJsonMap.put(String.valueOf(personalOptional.get().getId()), result.toPlainString()); + socialPer.add(result); + } + } + insuranceAccountDetailPO.setSocialPerJson(JSON.toJSONString(socialPerJsonMap)); + BigDecimal socialPerSum = new BigDecimal("0"); + for (BigDecimal bigDecimal : socialPer) { + socialPerSum = socialPerSum.add(bigDecimal); + } + insuranceAccountDetailPO.setSocialPerSum(socialPerSum.toPlainString()); + + //社保-单位 + List socialCom = new ArrayList<>(); + Map sociaComJsonMap = new HashMap<>(); + for (int i = 0; i < singleAccount.size(); i++) { + Map stringObjectMap = singleAccount.get(i); + Optional personalOptional = socialCategory.stream() + .filter(social -> stringObjectMap.containsKey(social.getInsuranceName() + SalaryI18nUtil.getI18nLabel(100289, "单位"))).findFirst(); + if (personalOptional.isPresent() && StringUtils + .isNotBlank((String) stringObjectMap.get(personalOptional.get().getInsuranceName() + SalaryI18nUtil.getI18nLabel(100289, "单位")))) { + String perNumString = (String) stringObjectMap.get(personalOptional.get().getInsuranceName() + SalaryI18nUtil.getI18nLabel(100289, "单位")); + + if (perNumString.length() > 0 && !isNumeric(perNumString)) { + continue; + } + perNumString = perNumString.replace(",", ""); + BigDecimal result = new BigDecimal(perNumString); + sociaComJsonMap.put(String.valueOf(personalOptional.get().getId()), result.toPlainString()); + socialCom.add(result); + } + } + insuranceAccountDetailPO.setSocialComJson(JSON.toJSONString(sociaComJsonMap)); + BigDecimal socialComSum = new BigDecimal("0"); + for (BigDecimal decimal : socialCom) { + socialComSum = socialComSum.add(decimal); + } + insuranceAccountDetailPO.setSocialComSum(socialComSum.toPlainString()); + return insuranceAccountDetailPO; + } + + public InsuranceAccountDetailPO accountBalanceFund(List> singleAccount, InsuranceAccountDetailPO insuranceAccountDetailPO, + List insuranceCategoryPOS, Long employeeId) { + //公积金-个人 + List fundCategory = insuranceCategoryPOS.stream().filter(po -> po.getWelfareType().equals(WelfareTypeEnum.ACCUMULATION_FUND.getValue())) + .collect(Collectors.toList()); + List fundPer = new ArrayList<>(); + Map fundPerJsonMap = new HashMap<>(); + for (int i = 0; i < singleAccount.size(); i++) { + Map stringObjectMap = singleAccount.get(i); + Optional personalOptional = fundCategory.stream() + .filter(social -> stringObjectMap.containsKey(social.getInsuranceName() + SalaryI18nUtil.getI18nLabel(87159, "个人"))).findFirst(); + if (personalOptional.isPresent() && StringUtils + .isNotBlank((String) stringObjectMap.get(personalOptional.get().getInsuranceName() + SalaryI18nUtil.getI18nLabel(87159, "个人")))) { + String perNumString = (String) stringObjectMap.get(personalOptional.get().getInsuranceName() + SalaryI18nUtil.getI18nLabel(87159, "个人")); + if (perNumString.length() > 0 && !isNumeric(perNumString)) { + continue; + } + perNumString = perNumString.replace(",", ""); + BigDecimal result = new BigDecimal(perNumString); + fundPerJsonMap.put(String.valueOf(personalOptional.get().getId()), result.toPlainString()); + fundPer.add(result); + } + } + insuranceAccountDetailPO.setFundPerJson(JSON.toJSONString(fundPerJsonMap)); + BigDecimal funPerSum = new BigDecimal("0"); + for (BigDecimal bigDecimal : fundPer) { + funPerSum = funPerSum.add(bigDecimal); + } + insuranceAccountDetailPO.setFundPerSum(funPerSum.toPlainString()); + + //公积金-单位 + List fundComList = new ArrayList<>(); + Map fundComJsonMap = new HashMap<>(); + for (int i = 0; i < singleAccount.size(); i++) { + Map stringObjectMap = singleAccount.get(i); + Optional personalOptional = fundCategory.stream() + .filter(social -> stringObjectMap.containsKey(social.getInsuranceName() + SalaryI18nUtil.getI18nLabel(100289, "单位"))).findFirst(); + if (personalOptional.isPresent() && StringUtils + .isNotBlank((String) stringObjectMap.get(personalOptional.get().getInsuranceName() + SalaryI18nUtil.getI18nLabel(100289, "单位")))) { + String perNumString = (String) stringObjectMap.get(personalOptional.get().getInsuranceName() + SalaryI18nUtil.getI18nLabel(100289, "单位")); + if (perNumString.length() > 0 && !isNumeric(perNumString)) { + continue; + } + perNumString = perNumString.replace(",", ""); + BigDecimal result = new BigDecimal(perNumString); + fundComJsonMap.put(String.valueOf(personalOptional.get().getId()), result.toPlainString()); + fundComList.add(result); + } + } + insuranceAccountDetailPO.setFundComJson(JSON.toJSONString(fundComJsonMap)); + BigDecimal fundComSum = new BigDecimal("0"); + for (BigDecimal bigDecimal : fundComList) { + fundComSum = fundComSum.add(bigDecimal); + } + insuranceAccountDetailPO.setFundComSum(fundComSum.toPlainString()); + return insuranceAccountDetailPO; + } + + public InsuranceAccountDetailPO accountBalanceOther(List> singleAccount, InsuranceAccountDetailPO insuranceAccountDetailPO, + List insuranceCategoryPOS, Long employeeId) { + List otherCategory = insuranceCategoryPOS.stream().filter(po -> po.getWelfareType().equals(WelfareTypeEnum.OTHER.getValue())) + .collect(Collectors.toList()); + // 其他福利-个人 + List otherPer = new ArrayList<>(); + Map otherPerJsonMap = new HashMap<>(); + for (int i = 0; i < singleAccount.size(); i++) { + Map stringObjectMap = singleAccount.get(i); + Optional personalOptional = otherCategory.stream() + .filter(social -> stringObjectMap.containsKey(social.getInsuranceName() + SalaryI18nUtil.getI18nLabel(87159, "个人"))).findFirst(); + if (personalOptional.isPresent() && StringUtils + .isNotBlank((String) stringObjectMap.get(personalOptional.get().getInsuranceName() + SalaryI18nUtil.getI18nLabel(87159, "个人")))) { + String perNumString = (String) stringObjectMap.get(personalOptional.get().getInsuranceName() + SalaryI18nUtil.getI18nLabel(87159, "个人")); + if (perNumString.length() > 0 && !isNumeric(perNumString)) { + continue; + } + perNumString = perNumString.replace(",", ""); + BigDecimal result = new BigDecimal(perNumString); + otherPerJsonMap.put(String.valueOf(personalOptional.get().getId()), result.toPlainString()); + otherPer.add(result); + } + } + insuranceAccountDetailPO.setOtherPerJson(JSON.toJSONString(otherPerJsonMap)); + BigDecimal otherPerSum = new BigDecimal("0"); + for (BigDecimal bigDecimal : otherPer) { + otherPerSum = otherPerSum.add(bigDecimal); + } + insuranceAccountDetailPO.setOtherPerSum(otherPerSum.toPlainString()); + + // 其他福利-单位 + List otherComList = new ArrayList<>(); + Map otherComJsonMap = new HashMap<>(); + for (int i = 0; i < singleAccount.size(); i++) { + Map stringObjectMap = singleAccount.get(i); + Optional personalOptional = otherCategory.stream() + .filter(social -> stringObjectMap.containsKey(social.getInsuranceName() + SalaryI18nUtil.getI18nLabel(100289, "单位"))).findFirst(); + if (personalOptional.isPresent() && StringUtils + .isNotBlank((String) stringObjectMap.get(personalOptional.get().getInsuranceName() + SalaryI18nUtil.getI18nLabel(100289, "单位")))) { + String perNumString = (String) stringObjectMap.get(personalOptional.get().getInsuranceName() + SalaryI18nUtil.getI18nLabel(100289, "单位")); + if (perNumString.length() > 0 && !isNumeric(perNumString)) { + continue; + } + perNumString = perNumString.replace(",", ""); + BigDecimal result = new BigDecimal(perNumString); + otherComJsonMap.put(String.valueOf(personalOptional.get().getId()), result.toPlainString()); + otherComList.add(result); + } + } + insuranceAccountDetailPO.setOtherComJson(JSON.toJSONString(otherComJsonMap)); + BigDecimal otherComSum = new BigDecimal("0"); + for (BigDecimal bigDecimal : otherComList) { + otherComSum = otherComSum.add(bigDecimal); + } + insuranceAccountDetailPO.setOtherComSum(otherComSum.toPlainString()); + return insuranceAccountDetailPO; + } + /*****以下代码为SIAccountBiz中逻辑迁移,旨在减少Biz类的使用*****/ + + /** + * 新建核算并归档 + * @param param + * @return + */ + @Override + public String saveAndFile(AccountParam param) { + ValidUtil.doValidator(param); + if (param.isFlag()) { + InsuranceAccountBatchPO insuranceAccountBatchPO = getInsuranceAccountBatchMapper().getByBillMonth(param.getBillMonth(), param.getPaymentOrganization()); + insuranceAccountBatchPO = encryptUtil.decrypt(insuranceAccountBatchPO, InsuranceAccountBatchPO.class); + SalaryAssert.isNull(insuranceAccountBatchPO, SalaryI18nUtil.getI18nLabel(0, "所属月份存在核算数据")); + + InsuranceAccountBatchPO build = InsuranceAccountBatchPO.builder() + .paymentOrganization(param.getPaymentOrganization()) + .accountant(user.getLastname()) + .billMonth(param.getBillMonth()) + .billStatus(BillStatusEnum.NOT_ARCHIVED.getValue()) + .remarks(param.getRemarks()) + .creator((long) user.getUID()) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .createTime(new Date()) + .updateTime(new Date()) + .deleteType(DeleteTypeEnum.NOT_DELETED.getValue()) + .paymentOrganization(param.getPaymentOrganization()) + .socialPay("0") + .fundPay("0") + .otherPay("0") + .build(); + encryptUtil.encrypt(build, InsuranceAccountBatchPO.class); + getInsuranceAccountBatchMapper().insert(build); + //记录操作日志 + InsuranceAccountBatchPO targetPO = getInsuranceAccountBatchMapper().getByBillMonth(param.getBillMonth(), param.getPaymentOrganization()); + encryptUtil.decrypt(targetPO, InsuranceAccountBatchPO.class); + TaxAgentPO taxAgentInfo = getTaxAgentMapper().getById(targetPO.getPaymentOrganization()); + LoggerContext loggerContext = new LoggerContext(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(targetPO.getId())); + loggerContext.setTargetName(taxAgentInfo.getName() + "-" + targetPO.getBillMonth()); + loggerContext.setOperateType(OperateTypeEnum.ADD.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "新增福利台账")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "新增福利台账") + + ":" + taxAgentInfo.getName() + "-" + targetPO.getBillMonth()); + loggerContext.setNewValues(targetPO); + SalaryElogConfig.siAccountLoggerTemplate.write(loggerContext); + } + try { + List employeeIds = getInsuranceAccountDetailMapper().selectEmpByPaymentOrg(param.getPaymentOrganization()); + if (CollectionUtils.isEmpty(employeeIds)) { + List list = Lists.newArrayList(getInsuranceAccountDetailMapper().queryNormalListByBillMonth(param.getBillMonth(), param.getPaymentOrganization())); + encryptUtil.decryptList(list, InsuranceAccountDetailPO.class); + if (CollectionUtils.isNotEmpty(list)) { + list.stream().forEach(f -> { + getInsuranceAccountDetailMapper().deleteById(f.getId()); + }); + } + } + SalaryAssert.notEmpty(employeeIds, SalaryI18nUtil.getI18nLabel(0, "没有需要核算的人员")); +// AccountParam selectParam = new AccountParam(); +// selectParam.setBillMonth(param.getBillMonth()); +// selectParam.setPaymentOrganization(param.getPaymentOrganization()); + + //福利核算进度 + ProgressDTO salaryAcctProgressDTO = getSalaryAcctProgressService(user).getProgress(SalaryCacheKey.ACCT_PROGRESS + param.getBillMonth() + "_" + param.getPaymentOrganization()); + if (salaryAcctProgressDTO != null && salaryAcctProgressDTO.isStatus() && salaryAcctProgressDTO.getProgress().compareTo(BigDecimal.ONE) < 0) { + return String.valueOf(user.getUID()); + } + // 初始化进度 + ProgressDTO initProgress = new ProgressDTO() + .setTitle(SalaryI18nUtil.getI18nLabel(0, "核算中")) + .setTitleLabelId(97515L) + .setTotalQuantity(2000) + .setCalculatedQuantity(NumberUtils.INTEGER_ZERO) + .setProgress(BigDecimal.ZERO) + .setStatus(true) + .setMessage(StringUtils.EMPTY); + getSalaryAcctProgressService(user).initProgress(SalaryCacheKey.ACCT_PROGRESS + param.getBillMonth() + "_" + param.getPaymentOrganization(), initProgress); + + ExecutorService taskExecutor = Executors.newCachedThreadPool(); + taskExecutor.execute(() -> { + siAccounting(param); + if (param.isFileFlag()) { + siFile(param.getBillMonth(), param.getPaymentOrganization()); + } + }); + } catch (Exception e) { + // 回滚 + List list = Lists.newArrayList(getInsuranceAccountBatchMapper().getByBillMonth(param.getBillMonth(), param.getPaymentOrganization())); + list = encryptUtil.decryptList(list, InsuranceAccountBatchPO.class); + if (CollectionUtils.isNotEmpty(list)) { + list.stream().forEach(f -> { + getInsuranceAccountBatchMapper().deleteById(f.getId()); + }); + } + throw new SalaryRunTimeException(e.getMessage()); + } + return String.valueOf(user.getUID()); + } + + + public void siAccounting(AccountParam param) { + // //福利核算进度 + // ProgressDTO salaryAcctProgressDTO = getSalaryAcctProgressService(user).getProgress(SalaryCacheKey.ACCT_PROGRESS + param.getBillMonth() + "_" + param.getPaymentOrganization()); + // if (salaryAcctProgressDTO != null && salaryAcctProgressDTO.isStatus() && salaryAcctProgressDTO.getProgress().compareTo(BigDecimal.ONE) < 0) { + // return; + // } + + log.info("开始核算,当前操作人为:{}", user.getLastname()); + log.info("核算时间:{}, 核算月份:{}, 个税扣缴义务人:{}, 是否首次核算:{}", new Date(), param.getBillMonth(), param.getPaymentOrganization(), param.isFlag()); + try { + List ids; + List validIds = new ArrayList<>(); + if (CollectionUtils.isEmpty(param.getIds())) { + List empIds = getInsuranceAccountDetailMapper().selectEmpByPaymentOrg(param.getPaymentOrganization()); + // 获取薪资核算人员规则 + SalarySysConfPO salaryAcctEmployeeRule = getSalarySysConfService(user).getOneByCode(SalarySysConstant.SALARY_ACCT_EMPLOYEE_RULE); + List status = new ArrayList<>(); + if(Objects.isNull(salaryAcctEmployeeRule) || StringUtils.equals(salaryAcctEmployeeRule.getConfValue(), SalaryAcctEmployeeRuleEnum.BYPAYENDTIME.getValue()) ){ + // 包含停缴 + status = Arrays.asList(EmployeeStatusEnum.PAYING.getValue(),EmployeeStatusEnum.STAY_DEL.getValue(), + EmployeeStatusEnum.STOP_PAYMENT_FROM_DEL.getValue()); + }else{ + status = Arrays.asList(EmployeeStatusEnum.PAYING.getValue(),EmployeeStatusEnum.STAY_DEL.getValue()); + } + List finalStatus = status; + //过滤出需要核算的人员,即福利档案基础信息表中runStatus为正在缴纳和待减员的人员 + List baseInfoPOList = getInsuranceBaseInfoMapper().listAll(); + List canAccountIds = baseInfoPOList.stream() + .filter(f->f.getPaymentOrganization().equals(param.getPaymentOrganization()) + && (finalStatus.contains(f.getRunStatus()) )) + .map(InsuranceArchivesBaseInfoPO::getEmployeeId) + .collect(Collectors.toList()); + + //20231122逻辑优化,过滤出不在起始缴纳月和最后缴纳月区间的人员 + List empIdsInPayMonthRange = listCanPayEmpIds(param.getPaymentOrganization(), param.getBillMonth()); + empIds = empIds.stream().filter(f->canAccountIds.contains(f) && empIdsInPayMonthRange.contains(f)).collect(Collectors.toList()); + +// List socials = siArchivesBiz.getSocialByEmployeeIds(empIds); + List socials = getSIArchivesService(user).getSocialByEmployeeIds(empIds); + //过滤出目标个税扣缴义务人相关信息 + socials = socials.stream().filter(f -> f.getPaymentOrganization().equals(param.getPaymentOrganization())).collect(Collectors.toList()); + List emp1 = socials.stream() + .filter(s -> !(StringUtils.isBlank(s.getSocialEndTime()) && StringUtils.isBlank(s.getSocialStartTime())) && + (StringUtils.isBlank(s.getSocialEndTime()) || (SalaryDateUtil.stringToDate(s.getSocialEndTime() + "-01") != null && !SalaryDateUtil.stringToDate(param.getBillMonth() + "-01").after(SalaryDateUtil.stringToDate(s.getSocialEndTime() + "-01")))) ) + .map(InsuranceArchivesSocialSchemePO::getEmployeeId) + .collect(Collectors.toList()); + +// List funds = siArchivesBiz.getFundByEmployeeIds(empIds); + List funds = getSIArchivesService(user).getFundByEmployeeIds(empIds); + //过滤出目标个税扣缴义务人相关信息 + funds = funds.stream().filter(f -> f.getPaymentOrganization().equals(param.getPaymentOrganization())).collect(Collectors.toList()); + List emp2 = funds.stream() + .filter(s -> !(StringUtils.isBlank(s.getFundStartTime()) && StringUtils.isBlank(s.getFundEndTime())) && + (StringUtils.isBlank(s.getFundEndTime()) || (SalaryDateUtil.stringToDate(s.getFundEndTime() + "-01") != null && !SalaryDateUtil.stringToDate(param.getBillMonth() + "-01").after(SalaryDateUtil.stringToDate(s.getFundEndTime() + "-01"))))) + .map(InsuranceArchivesFundSchemePO::getEmployeeId) + .collect(Collectors.toList()); + +// List others = siArchivesBiz.getOtherByEmployeeIds(empIds); + List others = getSIArchivesService(user).getOtherByEmployeeIds(empIds); + //过滤出目标个税扣缴义务人相关信息 + others = others.stream().filter(f -> f.getPaymentOrganization().equals(param.getPaymentOrganization())).collect(Collectors.toList()); + List emp3 = others.stream() + .filter(s -> !(StringUtils.isBlank(s.getOtherStartTime()) && StringUtils.isBlank(s.getOtherEndTime())) && + (StringUtils.isBlank(s.getOtherEndTime()) || (SalaryDateUtil.stringToDate(s.getOtherEndTime() + "-01") != null && !SalaryDateUtil.stringToDate(param.getBillMonth() + "-01").after(SalaryDateUtil.stringToDate(s.getOtherEndTime() + "-01"))))) + .map(InsuranceArchivesOtherSchemePO::getEmployeeId) + .collect(Collectors.toList()); + validIds.addAll(emp1); + validIds.addAll(emp2); + validIds.addAll(emp3); + + if (!param.isFlag()) { + // 不是首次创建核算 还需要添加历史核算人员 + List insuranceAccountDetailPOS = getInsuranceAccountDetailMapper().selectList(param.getBillMonth(), param.getPaymentOrganization()); + List historyEmpIds = insuranceAccountDetailPOS.stream().filter(po -> po.getPaymentStatus().equals(PaymentStatusEnum.COMMON.getValue())).map(InsuranceAccountDetailPO::getEmployeeId).collect(Collectors.toList()); + validIds.addAll(historyEmpIds); + List finalEmpIds = empIds; + empIds.addAll(historyEmpIds.stream().filter(empId -> !finalEmpIds.contains(empId)).collect(Collectors.toList())); + } + + List finalValidIds = validIds.stream().distinct().collect(Collectors.toList()); + ids = empIds.stream().filter(finalValidIds::contains).collect(Collectors.toList()); + } else { + ids = param.getIds(); + } + + // 初始化进度 + ProgressDTO initProgress = new ProgressDTO() + .setTitle(SalaryI18nUtil.getI18nLabel(0, "核算中")) + .setTitleLabelId(97515L) + .setTotalQuantity(ids.size()) + .setCalculatedQuantity(NumberUtils.INTEGER_ZERO) + .setProgress(BigDecimal.ZERO) + .setStatus(true) + .setMessage(StringUtils.EMPTY); + getSalaryAcctProgressService(user).initProgress(SalaryCacheKey.ACCT_PROGRESS + param.getBillMonth() + "_" + param.getPaymentOrganization(), initProgress); + + if (CollectionUtils.isEmpty(ids)) { + getSalaryAcctProgressService(user).finish(SalaryCacheKey.ACCT_PROGRESS + param.getBillMonth() + "_" + param.getPaymentOrganization(), true); + return; + } + + log.info("开始生成福利核算数据,待处理人员数量:{}", ids.size()); + siCommonAccount(param.getBillMonth(), ids, param.getPaymentOrganization(), param.isFlag()); + log.info("福利核算数据生成完毕,开始数据处理"); + + handleData(ids, param); + log.info("福利核算数据处理完毕!"); + + List> partition = Lists.partition((List) ids, 100); + partition.forEach(part -> { + getSIAccountDetailTempMapper().batchDelByEmpIdsAndMonthAndPayOrg(part, param.getBillMonth(), param.getPaymentOrganization()); + }); + log.info("更新福利核算进度······"); + getSalaryAcctProgressService(user).finish(SalaryCacheKey.ACCT_PROGRESS + param.getBillMonth() + "_" + param.getPaymentOrganization(), true); + log.info("福利核算进度完成!"); + } catch (Exception e) { + log.error("account run fail", e); + getSalaryAcctProgressService(user).fail(SalaryCacheKey.ACCT_PROGRESS + param.getBillMonth() + "_" + param.getPaymentOrganization(), SalaryI18nUtil.getI18nLabel(0, "福利核算出错") + ": " + e.getMessage()); + + List list = Lists.newArrayList(getInsuranceAccountBatchMapper().getByBillMonth(param.getBillMonth(), param.getPaymentOrganization())); + if (CollectionUtils.isNotEmpty(list)) { + list.stream().forEach(f -> { + getInsuranceAccountBatchMapper().deleteById(f.getId()); + }); + } + + } + + } + + public void siCommonAccount(String billMonth, List ids, Long paymentOrganization, boolean isFirstFlag) { + +// Map insuranceArchivesAccountPOS = siArchivesBiz.buildBatchAccount(ids, paymentOrganization); + Map insuranceArchivesAccountPOS = getSIArchivesService(user).buildBatchAccount(ids, paymentOrganization); + List historyDetailData = new ArrayList<>(); + List employeeList = getSalaryEmployeeService(user).listByIds(ids); + List> partition = Lists.partition(ids, 100); + partition.forEach(part -> { + historyDetailData.addAll(getInsuranceAccountDetailMapper().list(InsuranceAccountDetailParam.builder().billMonth(billMonth).paymentOrganization(paymentOrganization.toString()).employeeIds(part).build())); + historyDetailData.addAll(getInsuranceAccountDetailMapper().extList(InsuranceAccountDetailParam.builder().billMonth(billMonth).paymentOrganization(paymentOrganization.toString()).employeeIds(part).build())); + }); + Map historyDetailDataMap = SalaryEntityUtil.convert2Map(historyDetailData, InsuranceAccountDetailPO::getEmployeeId); + Map employeeMap = SalaryEntityUtil.convert2Map(employeeList, DataCollectionEmployee::getEmployeeId); + + List list = new ArrayList<>(); + int count = 0; + for (Map.Entry entry : insuranceArchivesAccountPOS.entrySet()) { + Long k = entry.getKey(); + InsuranceArchivesAccountPO v = entry.getValue(); + InsuranceAccountDetailPO insuranceAccountDetailPO = new InsuranceAccountDetailPO(); + insuranceAccountDetailPO.setBillMonth(billMonth); + insuranceAccountDetailPO.setBillStatus(BillStatusEnum.NOT_ARCHIVED.getValue()); + insuranceAccountDetailPO.setCreator((long) user.getUID()); + insuranceAccountDetailPO.setCreateTime(new Date()); + insuranceAccountDetailPO.setDeleteType(DeleteTypeEnum.NOT_DELETED.getValue()); + insuranceAccountDetailPO.setEmployeeId(k); + insuranceAccountDetailPO.setUpdateTime(new Date()); + insuranceAccountDetailPO.setPaymentStatus(PaymentStatusEnum.COMMON.getValue()); + insuranceAccountDetailPO.setResourceFrom(ResourceFromEnum.SYSTEM.getValue()); + insuranceAccountDetailPO.setTenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY); + insuranceAccountDetailPO.setPaymentOrganization(paymentOrganization); + + InsuranceAccountDetailPO historyDetail = historyDetailDataMap.get(k); + if (isFirstFlag || historyDetail == null) { + // 初次核算 + DataCollectionEmployee employee = employeeMap.get(k); + if (employee != null) { + insuranceAccountDetailPO.setSubcompanyName(employee.getSubcompanyName()); + insuranceAccountDetailPO.setSubcompanyId(employee.getSubcompanyid()); + insuranceAccountDetailPO.setDepartmentName(employee.getDepartmentName()); + insuranceAccountDetailPO.setDepartmentId(employee.getDepartmentId()); + insuranceAccountDetailPO.setJobtitleName(employee.getJobtitleName()); + insuranceAccountDetailPO.setJobtitleId(employee.getJobtitleId()); + insuranceAccountDetailPO.setJobcall(employee.getJobcall()); + insuranceAccountDetailPO.setJobcallId(employee.getJobcallId()); + insuranceAccountDetailPO.setStatus(employee.getStatus()); + } + } else { + insuranceAccountDetailPO.setSubcompanyName(historyDetail.getSubcompanyName()); + insuranceAccountDetailPO.setSubcompanyId(historyDetail.getSubcompanyId()); + insuranceAccountDetailPO.setDepartmentName(historyDetail.getDepartmentName()); + insuranceAccountDetailPO.setDepartmentId(historyDetail.getDepartmentId()); + insuranceAccountDetailPO.setJobtitleName(historyDetail.getJobtitleName()); + insuranceAccountDetailPO.setJobtitleId(historyDetail.getJobtitleId()); + insuranceAccountDetailPO.setJobcall(historyDetail.getJobcall()); + insuranceAccountDetailPO.setJobcallId(historyDetail.getJobcallId()); + insuranceAccountDetailPO.setStatus(historyDetail.getStatus()); + } + + //核算社保 + accountSocial(insuranceAccountDetailPO, v, billMonth); + //核算公积金 + accountFund(insuranceAccountDetailPO, v, billMonth); + //核算其他福利 + accountOther(insuranceAccountDetailPO, v, billMonth); + //计算合计 + account(insuranceAccountDetailPO); + //临时表PO + InsuranceAccountDetailTempPO insuranceAccountDetailTempPO = new InsuranceAccountDetailTempPO(); + BeanUtils.copyProperties(insuranceAccountDetailPO, insuranceAccountDetailTempPO); + list.add(insuranceAccountDetailTempPO); + count++; + + if (count % 50 == 0 || count >= ids.size()) { + if (count >= ids.size()) { + getSalaryAcctProgressService(user).updateProgress(SalaryCacheKey.ACCT_PROGRESS + billMonth + "_" + paymentOrganization, BigDecimal.valueOf(0.99), false); + log.info("更新福利核算进度,当前进度为:{}", getSalaryAcctProgressService(user).getProgress(SalaryCacheKey.ACCT_PROGRESS + billMonth + "_" + paymentOrganization)); + } else { + getSalaryAcctProgressService(user).getAndAddCalculatedQty(SalaryCacheKey.ACCT_PROGRESS + billMonth + "_" + paymentOrganization, count >= ids.size() ? count % 50 : 50); + log.info("更新福利核算进度,当前进度为:{}", getSalaryAcctProgressService(user).getProgress(SalaryCacheKey.ACCT_PROGRESS + billMonth + "_" + paymentOrganization)); + } + + } + + } + //临时表入库前先对(可能存在的)历史数据进行删除 + partition.forEach(part -> { + getSIAccountDetailTempMapper().batchDelByEmpIdsAndMonthAndPayOrg(part, billMonth, paymentOrganization); + }); + // // 根据人员id删,会少删不再参与社保核算的人。 + // getSIAccountDetailTempMapper().batchDelByMonthAndPayOrg(billMonth, paymentOrganization); + //临时表数据入库 + if (CollectionUtils.isNotEmpty(list)) { + if (!isFirstFlag) { + // 点击台账内的核算按钮,核算人员不变(不增加人) + List existDataKey = historyDetailData.stream().map(po -> po.getPaymentOrganization() + "_" + po.getEmployeeId()).collect(Collectors.toList()); + list = list.stream().filter(po -> existDataKey.contains(po.getPaymentOrganization() + "_" + po.getEmployeeId())).collect(Collectors.toList()); + } + encryptUtil.encryptList(list, InsuranceAccountDetailTempPO.class); + List> lists = splitList(list, 20); + lists.forEach(subList -> { + getSIAccountDetailTempMapper().batchSaveAccountTempDetails(subList); + }); + } + + } + + public InsuranceAccountDetailPO accountOther(InsuranceAccountDetailPO insuranceAccountDetailPO, InsuranceArchivesAccountPO accountPO, String billMonth) { +// boolean welBaseDiffSign = siArchivesBiz.isDiffWelBase(); + boolean welBaseDiffSign = getSIArchivesService(user).isDiffWelBase(); + if (accountPO.getOther() != null) { + InsuranceArchivesOtherSchemePO otherPO = accountPO.getOther(); + insuranceAccountDetailPO.setOtherPayOrg(otherPO.getPaymentOrganization()); + insuranceAccountDetailPO.setOtherSchemeId(otherPO.getOtherSchemeId()); + insuranceAccountDetailPO.setOtherPaymentBaseString(otherPO.getOtherPaymentBaseString()); + insuranceAccountDetailPO.setOtherPaymentComBaseString(otherPO.getOtherPaymentComBaseString()); + //判断是否在起始缴纳月和最后缴纳月之间 + Boolean inDataRange = SalaryDateUtil.monthInRange(insuranceAccountDetailPO.getBillMonth(), otherPO.getOtherStartTime(), otherPO.getOtherEndTime()); + if ((Objects.equals(NonPaymentEnum.YES.getValue(), otherPO.getNonPayment()) || otherPO.getNonPayment() == null) && otherPO.getOtherSchemeId() != null && inDataRange) { + List detailPOS = getInsuranceSchemeDetailMapper().queryListBySchemeId(otherPO.getOtherSchemeId()); + encryptUtil.decryptList(detailPOS, InsuranceSchemeDetailPO.class); + //方案中包含的需要缴纳其他的个人福利 + int monthIndex = Integer.parseInt(billMonth.split("-")[1]) - 1; + Map otherPerson = detailPOS.stream() + .filter(item -> Objects.equals(IsPaymentEnum.YES.getValue(), item.getIsPayment()) && Objects.equals(item.getPaymentScope(), PaymentScopeEnum.SCOPE_PERSON.getValue()) + && (item.getPaymentCycle() == null || item.getPaymentCycle() == 0 || (item.getPaymentCycle() == 1 && String.valueOf(item.getCycleSetting().charAt(monthIndex)).equals("1")))) + .collect( + Collectors.toMap(InsuranceSchemeDetailPO::getInsuranceId, Function.identity())); + //档案中包含的基数信息 + HashMap archivesPerson = JSON.parseObject(otherPO.getOtherPaymentBaseString(), new HashMap().getClass()); + //需要核算其他的福利id 个人 + List needArchivesPerson = new ArrayList<>(); + if (archivesPerson != null) { + archivesPerson.forEach((id, value) -> { + if (otherPerson.containsKey(Long.valueOf(id))) { + needArchivesPerson.add(Long.valueOf(id)); + } + }); + } + //避免福利档案的方案未设置基数,导致核算时遗漏这些福利项的核算,遍历下方案相关福利项,并将遗漏的福利项id添加 + if(otherPerson.size() > 0) { + otherPerson.forEach((id, object) -> { + if (!needArchivesPerson.contains(id)) { + needArchivesPerson.add(id); + } + }); + } + //判断核算周期、核算月、福利起始缴纳月的关系 + checkCycleSettingWithStartMonth(otherPerson, billMonth, otherPO.getOtherStartTime()); + + List otherPer = new ArrayList<>(); + Map otherPerJsonMap = new HashMap<>(); + needArchivesPerson.stream().forEach(e -> { + InsuranceSchemeDetailPO po = otherPerson.get(e); + BigDecimal paymentProportion = new BigDecimal(StringUtils.isBlank(po.getPaymentProportion()) ? "0" : po.getPaymentProportion()).divide(new BigDecimal("100")); + BigDecimal paymentNum = new BigDecimal((ObjectUtil.isEmpty(archivesPerson) || StringUtils.isBlank(archivesPerson.get(String.valueOf(e)))) ? "0" : archivesPerson.get(String.valueOf(e))); + BigDecimal fixedCost = StringUtils.isBlank(po.getFixedCost()) ? new BigDecimal("0") : new BigDecimal(po.getFixedCost()); + Integer newScale = po.getValidNum() == null ? 0 : po.getValidNum(); + BigDecimal result = new BigDecimal("0"); + if (po.getPaymentCycle() != null && po.getPaymentCycle() == 1) { + int monthValue = 1; + for (int i = monthIndex - 1; i >= 0; i--) { + String cycleValue = po.getCycleSetting().charAt(i) + ""; + if (Integer.parseInt(cycleValue) == 1) { + break; + } + monthValue++; + } + if (po.getAccountType() == 1) { + paymentNum = paymentNum.multiply(new BigDecimal(monthValue)); + fixedCost = fixedCost.multiply(new BigDecimal(monthValue)); + result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost)); + } else { + for (int i = 0; i < monthValue; i++) { + result = result.add(SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost))); + } + } + } else { + result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost)); + } + otherPerJsonMap.put(String.valueOf(e), result.toPlainString()); + otherPer.add(result); + }); + insuranceAccountDetailPO.setOtherPerJson(JSON.toJSONString(otherPerJsonMap)); + BigDecimal otherPerSum = new BigDecimal("0"); + for (BigDecimal bigDecimal : otherPer) { + otherPerSum = otherPerSum.add(bigDecimal); + } + insuranceAccountDetailPO.setOtherPerSum(otherPerSum.toPlainString()); + + //方案中包含的需要缴纳公积金的单位福利 + Map otherCom = detailPOS.stream() + .filter( + item -> Objects.equals(IsPaymentEnum.YES.getValue(), item.getIsPayment()) && Objects.equals(item.getPaymentScope(), PaymentScopeEnum.SCOPE_COMPANY.getValue()) + && (item.getPaymentCycle() == null || item.getPaymentCycle() == 0 || (item.getPaymentCycle() == 1 && String.valueOf(item.getCycleSetting().charAt(monthIndex)).equals("1")))) + .collect( + Collectors.toMap(InsuranceSchemeDetailPO::getInsuranceId, Function.identity())); + //档案中包含的基数信息 + HashMap archivesCom = new HashMap<>(); + if (welBaseDiffSign) { + archivesCom = JSON.parseObject(otherPO.getOtherPaymentComBaseString(), new HashMap().getClass()); + } else { + archivesCom = JSON.parseObject(otherPO.getOtherPaymentBaseString(), new HashMap().getClass()); + } + //需要核算其他的福利id 单位 + List needArchivesCom = new ArrayList<>(); + if (archivesCom != null) { + archivesCom.forEach((id, value) -> { + if (otherCom.containsKey(Long.valueOf(id))) { + needArchivesCom.add(Long.valueOf(id)); + } + }); + } + //避免福利档案的方案未设置基数,导致核算时遗漏这些福利项的核算,遍历下方案相关福利项,并将遗漏的福利项id添加 + if(otherCom.size() > 0) { + otherCom.forEach((id, object) -> { + if (!needArchivesCom.contains(id)) { + needArchivesCom.add(id); + } + }); + } + //判断核算周期、核算月、福利起始缴纳月的关系 + checkCycleSettingWithStartMonth(otherCom, billMonth, otherPO.getOtherStartTime()); + + List otherComList = new ArrayList<>(); + Map otherComJsonMap = new HashMap<>(); + HashMap finalArchivesCom = archivesCom; + needArchivesCom.stream().forEach(e -> { + InsuranceSchemeDetailPO po = otherCom.get(e); + BigDecimal paymentProportion = new BigDecimal(StringUtils.isBlank(po.getPaymentProportion()) ? "0" : po.getPaymentProportion()).divide(new BigDecimal("100")); + BigDecimal paymentNum = new BigDecimal((ObjectUtil.isEmpty(finalArchivesCom) || StringUtils.isBlank(finalArchivesCom.get(String.valueOf(e)))) ? "0" : finalArchivesCom.get(String.valueOf(e))); + BigDecimal fixedCost = StringUtils.isBlank(po.getFixedCost()) ? new BigDecimal("0") : new BigDecimal(po.getFixedCost()); + Integer newScale = po.getValidNum() == null ? 0 : po.getValidNum(); + BigDecimal result = new BigDecimal("0"); + if (Objects.equals(po.getPaymentCycle(), 1)) { + int monthValue = 1; + for (int i = monthIndex - 1; i >= 0; i--) { + String cycleValue = po.getCycleSetting().charAt(i) + ""; + if (Integer.parseInt(cycleValue) == 1) { + break; + } + monthValue++; + } + if (po.getAccountType() == 1) { + paymentNum = paymentNum.multiply(new BigDecimal(monthValue)); + fixedCost = fixedCost.multiply(new BigDecimal(monthValue)); + result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost)); + } else { + for (int i = 0; i < monthValue; i++) { + result = result.add(SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost))); + } + } + } else { + result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost)); + } + otherComJsonMap.put(String.valueOf(e), result.toPlainString()); + otherComList.add(result); + }); + insuranceAccountDetailPO.setOtherComJson(JSON.toJSONString(otherComJsonMap)); + BigDecimal otherComSum = new BigDecimal("0"); + for (BigDecimal bigDecimal : otherComList) { + otherComSum = otherComSum.add(bigDecimal); + } + insuranceAccountDetailPO.setOtherComSum(otherComSum.toPlainString()); + } + } + return insuranceAccountDetailPO; + } + + + public InsuranceAccountDetailPO accountFund(InsuranceAccountDetailPO insuranceAccountDetailPO, InsuranceArchivesAccountPO accountPO, String billMonth) { +// boolean welBaseDiffSign = siArchivesBiz.isDiffWelBase(); + boolean welBaseDiffSign = getSIArchivesService(user).isDiffWelBase(); + if (accountPO.getFund() != null) { + InsuranceArchivesFundSchemePO fundPO = accountPO.getFund(); + insuranceAccountDetailPO.setFundPayOrg(fundPO.getPaymentOrganization()); + insuranceAccountDetailPO.setFundAccount(fundPO.getFundAccount()); + insuranceAccountDetailPO.setSupplementFundAccount(fundPO.getSupplementFundAccount()); + insuranceAccountDetailPO.setFundSchemeId(fundPO.getFundSchemeId()); + insuranceAccountDetailPO.setFundPaymentBaseString(fundPO.getFundPaymentBaseString()); + insuranceAccountDetailPO.setFundPaymentComBaseString(fundPO.getFundPaymentComBaseString()); + //判断是否在起始缴纳月和最后缴纳月之间 + Boolean inDataRange = SalaryDateUtil.monthInRange(insuranceAccountDetailPO.getBillMonth(), fundPO.getFundStartTime(), fundPO.getFundEndTime()); + if ((NonPaymentEnum.YES.getValue().equals(fundPO.getNonPayment()) || fundPO.getNonPayment() == null) && fundPO.getFundSchemeId() != null && inDataRange) { + List detailPOS = getInsuranceSchemeDetailMapper().queryListBySchemeId(fundPO.getFundSchemeId()); + encryptUtil.decryptList(detailPOS, InsuranceSchemeDetailPO.class); + //方案中包含的需要缴纳社保的个人福利 + int monthIndex = Integer.parseInt(billMonth.split("-")[1]) - 1; + Map fundperson = detailPOS.stream() + .filter(item -> Objects.equals(IsPaymentEnum.YES.getValue(), item.getIsPayment()) && Objects.equals(item.getPaymentScope(), PaymentScopeEnum.SCOPE_PERSON.getValue()) + && (item.getPaymentCycle() == null || item.getPaymentCycle() == 0 || (item.getPaymentCycle() == 1 && String.valueOf(item.getCycleSetting().charAt(monthIndex)).equals("1")))) + .collect( + Collectors.toMap(InsuranceSchemeDetailPO::getInsuranceId, Function.identity())); + //档案中包含的基数信息 + HashMap archivesPerson = JSON.parseObject(fundPO.getFundPaymentBaseString(), new HashMap().getClass()); + //需要核算公积金的福利id 个人 + List needArchivesPerson = new ArrayList<>(); + if (archivesPerson != null) { + archivesPerson.forEach((id, value) -> { + if (fundperson.containsKey(Long.valueOf(id))) { + needArchivesPerson.add(Long.valueOf(id)); + } + }); + } + //避免福利档案的方案未设置基数,导致核算时遗漏这些福利项的核算,遍历下方案相关福利项,并将遗漏的福利项id添加 + if(fundperson.size() > 0) { + fundperson.forEach((id, object) -> { + if (!needArchivesPerson.contains(id)) { + needArchivesPerson.add(id); + } + }); + } + //判断核算周期、核算月、福利起始缴纳月的关系 + checkCycleSettingWithStartMonth(fundperson, billMonth, fundPO.getFundStartTime()); + + List fundPer = new ArrayList<>(); + Map fundPerJsonMap = new HashMap<>(); + needArchivesPerson.stream().forEach(e -> { + InsuranceSchemeDetailPO po = fundperson.get(e); + BigDecimal paymentProportion = new BigDecimal(StringUtils.isBlank(po.getPaymentProportion()) ? "0" : po.getPaymentProportion()).divide(new BigDecimal("100")); + BigDecimal paymentNum = new BigDecimal((ObjectUtil.isEmpty(archivesPerson) || StringUtils.isBlank(archivesPerson.get(String.valueOf(e)))) ? "0" : archivesPerson.get(String.valueOf(e))); + BigDecimal fixedCost = StringUtils.isBlank(po.getFixedCost()) ? new BigDecimal("0") : new BigDecimal(po.getFixedCost()); + Integer newScale = po.getValidNum() == null ? 0 : po.getValidNum(); + BigDecimal result = new BigDecimal("0"); + if (Objects.equals(po.getPaymentCycle(), 1)) { + int monthValue = 1; + for (int i = monthIndex - 1; i >= 0; i--) { + String cycleValue = po.getCycleSetting().charAt(i) + ""; + if (Integer.parseInt(cycleValue) == 1) { + break; + } + monthValue++; + } + if (po.getAccountType() == 1) { + paymentNum = paymentNum.multiply(new BigDecimal(monthValue)); + fixedCost = fixedCost.multiply(new BigDecimal(monthValue)); + result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost)); + } else { + for (int i = 0; i < monthValue; i++) { + result = result.add(SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost))); + } + } + } else { + result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost)); + } + fundPerJsonMap.put(String.valueOf(e), result.toPlainString()); + fundPer.add(result); + }); + insuranceAccountDetailPO.setFundPerJson(JSON.toJSONString(fundPerJsonMap)); + BigDecimal funPerSum = new BigDecimal("0"); + for (BigDecimal bigDecimal : fundPer) { + funPerSum = funPerSum.add(bigDecimal); + } + insuranceAccountDetailPO.setFundPerSum(funPerSum.toPlainString()); + + //方案中包含的需要缴纳公积金的单位福利 + Map fundCom = detailPOS.stream() + .filter(item -> Objects.equals(IsPaymentEnum.YES.getValue(), item.getIsPayment()) && Objects.equals(item.getPaymentScope(), PaymentScopeEnum.SCOPE_COMPANY.getValue()) + && (item.getPaymentCycle() == null || item.getPaymentCycle() == 0 || (item.getPaymentCycle() == 1 && String.valueOf(item.getCycleSetting().charAt(monthIndex)).equals("1")))) + .collect( + Collectors.toMap(InsuranceSchemeDetailPO::getInsuranceId, Function.identity())); + //档案中包含的基数信息 + HashMap archivesCom = new HashMap<>(); + if (welBaseDiffSign) { + archivesCom = JSON.parseObject(fundPO.getFundPaymentComBaseString(), new HashMap().getClass()); + } else { + archivesCom = JSON.parseObject(fundPO.getFundPaymentBaseString(), new HashMap().getClass()); + } + //需要核算公积金的福利id 单位 + List needArchivesCom = new ArrayList<>(); + if (archivesCom != null) { + archivesCom.forEach((id, value) -> { + if (fundCom.containsKey(Long.valueOf(id))) { + needArchivesCom.add(Long.valueOf(id)); + } + }); + } + //避免福利档案的方案未设置基数,导致核算时遗漏这些福利项的核算,遍历下方案相关福利项,并将遗漏的福利项id添加 + if(fundCom.size() > 0) { + fundCom.forEach((id, object) -> { + if (!needArchivesCom.contains(id)) { + needArchivesCom.add(id); + } + }); + } + //判断核算周期、核算月、福利起始缴纳月的关系 + checkCycleSettingWithStartMonth(fundCom, billMonth, fundPO.getFundStartTime()); + + List fundComList = new ArrayList<>(); + Map fundComJsonMap = new HashMap<>(); + HashMap finalArchivesCom = archivesCom; + needArchivesCom.stream().forEach(e -> { + InsuranceSchemeDetailPO po = fundCom.get(e); + BigDecimal paymentProportion = new BigDecimal(StringUtils.isBlank(po.getPaymentProportion()) ? "0" : po.getPaymentProportion()).divide(new BigDecimal("100")); + BigDecimal paymentNum = new BigDecimal((ObjectUtil.isEmpty(finalArchivesCom) || StringUtils.isBlank(finalArchivesCom.get(String.valueOf(e)))) ? "0" : finalArchivesCom.get(String.valueOf(e))); + BigDecimal fixedCost = StringUtils.isBlank(po.getFixedCost()) ? new BigDecimal("0") : new BigDecimal(po.getFixedCost()); + Integer newScale = po.getValidNum() == null ? 0 : po.getValidNum(); + BigDecimal result = new BigDecimal("0"); + if (Objects.equals(po.getPaymentCycle(), 1)) { + int monthValue = 1; + for (int i = monthIndex - 1; i >= 0; i--) { + String cycleValue = po.getCycleSetting().charAt(i) + ""; + if (Integer.parseInt(cycleValue) == 1) { + break; + } + monthValue++; + } + if (po.getAccountType() == 1) { + paymentNum = paymentNum.multiply(new BigDecimal(monthValue)); + fixedCost = fixedCost.multiply(new BigDecimal(monthValue)); + result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost)); + } else { + for (int i = 0; i < monthValue; i++) { + result = result.add(SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost))); + } + } + } else { + result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost)); + } + fundComJsonMap.put(String.valueOf(e), result.toPlainString()); + fundComList.add(result); + }); + insuranceAccountDetailPO.setFundComJson(JSON.toJSONString(fundComJsonMap)); + BigDecimal fundComSum = new BigDecimal("0"); + for (BigDecimal bigDecimal : fundComList) { + fundComSum = fundComSum.add(bigDecimal); + } + insuranceAccountDetailPO.setFundComSum(fundComSum.toPlainString()); + } + } + return insuranceAccountDetailPO; + } + + + public InsuranceAccountDetailPO accountSocial(InsuranceAccountDetailPO insuranceAccountDetailPO, InsuranceArchivesAccountPO accountPO, String billMonth) { +// boolean welBaseDiffSign = siArchivesBiz.isDiffWelBase(); + boolean welBaseDiffSign = getSIArchivesService(user).isDiffWelBase(); + if (accountPO.getSocial() != null) { + InsuranceArchivesSocialSchemePO socialPO = accountPO.getSocial(); + insuranceAccountDetailPO.setSocialPayOrg(socialPO.getPaymentOrganization()); + insuranceAccountDetailPO.setSocialAccount(socialPO.getSocialAccount()); + insuranceAccountDetailPO.setSocialSchemeId(socialPO.getSocialSchemeId()); + insuranceAccountDetailPO.setSocialPaymentBaseString(socialPO.getSocialPaymentBaseString()); + insuranceAccountDetailPO.setSocialPaymentComBaseString(socialPO.getSocialPaymentComBaseString()); + //判断是否在起始缴纳月和最后缴纳月之间 + Boolean inDataRange = SalaryDateUtil.monthInRange(insuranceAccountDetailPO.getBillMonth(), socialPO.getSocialStartTime(), socialPO.getSocialEndTime()); + if ((NonPaymentEnum.YES.getValue().equals(socialPO.getNonPayment()) || socialPO.getNonPayment() == null) && socialPO.getSocialSchemeId() != null && inDataRange) { + List detailPOS = getInsuranceSchemeDetailMapper().queryListBySchemeId(socialPO.getSocialSchemeId()); + encryptUtil.decryptList(detailPOS, InsuranceSchemeDetailPO.class); + //方案中包含的需要缴纳社保的个人福利 + int monthIndex = Integer.parseInt(billMonth.split("-")[1]) - 1; + Map schemeperson = detailPOS.stream() + .filter(item -> + Objects.equals(IsPaymentEnum.YES.getValue(), item.getIsPayment()) && + Objects.equals(item.getPaymentScope(), PaymentScopeEnum.SCOPE_PERSON.getValue()) && + (item.getPaymentCycle() == null || item.getPaymentCycle() == 0 || (item.getPaymentCycle() == 1 && String.valueOf(item.getCycleSetting().charAt(monthIndex)).equals("1"))) + ) + .collect( + Collectors.toMap(InsuranceSchemeDetailPO::getInsuranceId, Function.identity())); + //档案中包含的基数信息 + HashMap archivesPerson = JSON.parseObject(socialPO.getSocialPaymentBaseString(), new HashMap().getClass()); + //需要核算社保的福利id 个人 + List needArchivesPerson = new ArrayList<>(); + if (archivesPerson != null) { + archivesPerson.forEach((id, value) -> { + if (schemeperson.containsKey(Long.valueOf(id))) { + needArchivesPerson.add(Long.valueOf(id)); + } + }); + } + //避免福利档案的方案未设置基数,导致核算时遗漏这些福利项的核算,遍历下方案相关福利项,并将遗漏的福利项id添加 + if(schemeperson.size() > 0) { + schemeperson.forEach((id, object) -> { + if (!needArchivesPerson.contains(id)) { + needArchivesPerson.add(id); + } + }); + } + //判断核算周期、核算月、福利起始缴纳月的关系 + checkCycleSettingWithStartMonth(schemeperson, billMonth, socialPO.getSocialStartTime()); + + List socialPer = new ArrayList<>(); + Map socialPerJsonMap = new HashMap<>(); + needArchivesPerson.forEach(e -> { + InsuranceSchemeDetailPO po = schemeperson.get(e); + BigDecimal paymentProportion = new BigDecimal(StringUtils.isBlank(po.getPaymentProportion()) ? "0" : po.getPaymentProportion()).divide(new BigDecimal("100")); + BigDecimal paymentNum = new BigDecimal((ObjectUtil.isEmpty(archivesPerson) || StringUtils.isBlank(archivesPerson.get(String.valueOf(e)))) ? "0" : archivesPerson.get(String.valueOf(e))); + BigDecimal fixedCost = StringUtils.isBlank(po.getFixedCost()) ? new BigDecimal("0") : new BigDecimal(po.getFixedCost()); + Integer newScale = po.getValidNum() == null ? 0 : po.getValidNum(); + BigDecimal result = new BigDecimal("0"); + if (Objects.equals(po.getPaymentCycle(), 1)) { + int monthValue = 1; + for (int i = monthIndex - 1; i >= 0; i--) { + String cycleValue = po.getCycleSetting().charAt(i) + ""; + if (Integer.parseInt(cycleValue) == 1) { + break; + } + monthValue++; + } + if (po.getAccountType() == 1) { + paymentNum = paymentNum.multiply(new BigDecimal(monthValue)); + fixedCost = fixedCost.multiply(new BigDecimal(monthValue)); + result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost)); + } else { + for (int i = 0; i < monthValue; i++) { + result = result.add(SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost))); + } + } + } else { + result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost)); + } + socialPerJsonMap.put(String.valueOf(e), result.toPlainString()); + socialPer.add(result); + }); + insuranceAccountDetailPO.setSocialPerJson(JSON.toJSONString(socialPerJsonMap)); + BigDecimal socialPerSum = new BigDecimal("0"); + for (BigDecimal bigDecimal : socialPer) { + socialPerSum = socialPerSum.add(bigDecimal); + } + insuranceAccountDetailPO.setSocialPerSum(socialPerSum.toPlainString()); + //方案中包含的需要缴纳社保的单位福利 + Map schemeCom = detailPOS.stream() + .filter(item -> Objects.equals(IsPaymentEnum.YES.getValue(), item.getIsPayment()) && Objects.equals(item.getPaymentScope(), PaymentScopeEnum.SCOPE_COMPANY.getValue()) && + (item.getPaymentCycle() == null || item.getPaymentCycle() == 0 || (item.getPaymentCycle() == 1 && String.valueOf(item.getCycleSetting().charAt(monthIndex)).equals("1")))) + .collect( + Collectors.toMap(InsuranceSchemeDetailPO::getInsuranceId, Function.identity())); + //档案中包含的基数信息 + HashMap archivesCom = new HashMap<>(); + if (welBaseDiffSign) { + archivesCom = JSON.parseObject(socialPO.getSocialPaymentComBaseString(), new HashMap().getClass()); + } else { + archivesCom = JSON.parseObject(socialPO.getSocialPaymentBaseString(), new HashMap().getClass()); + } + //需要核算社保的福利id 单位 + List needArchivesCom = new ArrayList<>(); + if (archivesCom != null) { + archivesCom.forEach((id, value) -> { + if (schemeCom.containsKey(Long.valueOf(id))) { + needArchivesCom.add(Long.valueOf(id)); + } + }); + } + //避免福利档案的方案未设置基数,导致核算时遗漏这些福利项的核算,遍历下方案相关福利项,并将遗漏的福利项id添加 + if(schemeCom.size() > 0) { + schemeCom.forEach((id, object) -> { + if (!needArchivesCom.contains(id)) { + needArchivesCom.add(id); + } + }); + } + //判断核算周期、核算月、福利起始缴纳月的关系 + checkCycleSettingWithStartMonth(schemeCom, billMonth, socialPO.getSocialStartTime()); + + List socialCom = new ArrayList<>(); + Map sociaComJsonMap = new HashMap<>(); + HashMap finalArchivesCom = archivesCom; + needArchivesCom.stream().forEach(e -> { + InsuranceSchemeDetailPO po = schemeCom.get(e); + BigDecimal paymentProportion = new BigDecimal(StringUtils.isBlank(po.getPaymentProportion()) ? "0" : po.getPaymentProportion()).divide(new BigDecimal("100")); + BigDecimal paymentNum = new BigDecimal((ObjectUtil.isEmpty(finalArchivesCom) || StringUtils.isBlank(finalArchivesCom.get(String.valueOf(e)))) ? "0" : finalArchivesCom.get(String.valueOf(e))); + BigDecimal fixedCost = StringUtils.isBlank(po.getFixedCost()) ? new BigDecimal("0") : new BigDecimal(po.getFixedCost()); + Integer newScale = po.getValidNum() == null ? 0 : po.getValidNum(); + BigDecimal result = new BigDecimal("0"); + if (Objects.equals(po.getPaymentCycle(), 1)) { + int monthValue = 1; + for (int i = monthIndex - 1; i >= 0; i--) { + String cycleValue = po.getCycleSetting().charAt(i) + ""; + if (Integer.parseInt(cycleValue) == 1) { + break; + } + monthValue++; + } + if (po.getAccountType() == 1) { + paymentNum = paymentNum.multiply(new BigDecimal(monthValue)); + fixedCost = fixedCost.multiply(new BigDecimal(monthValue)); + result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost)); + } else { + for (int i = 0; i < monthValue; i++) { + result = result.add(SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost))); + } + } + } else { + result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost)); + } + sociaComJsonMap.put(String.valueOf(e), result.toPlainString()); + socialCom.add(result); + + }); + insuranceAccountDetailPO.setSocialComJson(JSON.toJSONString(sociaComJsonMap)); + BigDecimal socialComSum = new BigDecimal("0"); + for (BigDecimal decimal : socialCom) { + socialComSum = socialComSum.add(decimal); + } + insuranceAccountDetailPO.setSocialComSum(socialComSum.toPlainString()); + } + + } + return insuranceAccountDetailPO; + } + + /** + * 对于核算月和福利起始缴纳月处于同年时,要避免根据周期缴纳福利费用时,可能出现的多余费用缴纳情况 + * @param schemeDetail 福利方案明细 + * @param billMonth 核算月 + * @param startMonth 福利起始缴纳月 + * @return + */ + public Map checkCycleSettingWithStartMonth(Map schemeDetail, String billMonth, String startMonth) { + String billYear = billMonth.substring(0,4); + if (StringUtils.isNotBlank(startMonth) && billYear.equals(startMonth.substring(0,4))) { + int startMonthIndex = Integer.parseInt(startMonth.split("-")[1]) - 1; + schemeDetail.forEach((k, v) -> { + if (v.getPaymentCycle() != null && v.getPaymentCycle().equals(1) && startMonthIndex != 0) { + StringBuilder newCycleSetting = new StringBuilder(v.getCycleSetting()); + newCycleSetting.setCharAt(startMonthIndex - 1, '1'); + v.setCycleSetting(newCycleSetting.toString()); + } + }); + + } + return schemeDetail; + } + + private List> splitList(List list, int groupSize) { + int length = list.size(); + // 计算可以分成多少组 + int num = (length + groupSize - 1) / groupSize; + List> newList = new ArrayList<>(num); + for (int i = 0; i < num; i++) { + // 开始位置 + int fromIndex = i * groupSize; + // 结束位置 + int toIndex = (i + 1) * groupSize < length ? (i + 1) * groupSize : length; + newList.add(list.subList(fromIndex, toIndex)); + } + return newList; + } + + /** + * 根据个税扣缴义务人和账单月,获取三类福利档案中符合缴纳开始结束月区间的人员id + * @param paymentOrganization + * @param billMonth + * @return + */ + public List listCanPayEmpIds(Long paymentOrganization, String billMonth) { + List listCanPayEmpIds = new ArrayList<>(); + //社保档案中可进行缴纳的人员 (未勾选暂不缴纳) + List socialCanPayEmpIds = getSocialSchemeMapper().listCanPayEmpIds(paymentOrganization, billMonth, 0); + //公积金档案中可进行缴纳的人员(未勾选暂不缴纳) + List fundCanPayEmpIds = getFundSchemeMapper().listCanPayEmpIds(paymentOrganization, billMonth, 0); + //其他福利档案中可进行缴纳的人员(未勾选暂不缴纳) + List otherCanPayEmpIds = getOtherSchemeMapper().listCanPayEmpIds(paymentOrganization, billMonth, 0); + if (socialCanPayEmpIds != null && socialCanPayEmpIds.size() > 0) { + listCanPayEmpIds.addAll(socialCanPayEmpIds); + } + if (fundCanPayEmpIds != null && fundCanPayEmpIds.size() > 0) { + listCanPayEmpIds.addAll(fundCanPayEmpIds); + } + if (otherCanPayEmpIds != null && otherCanPayEmpIds.size() > 0) { + listCanPayEmpIds.addAll(otherCanPayEmpIds); + } + //去重 + listCanPayEmpIds = listCanPayEmpIds.stream().distinct().collect(Collectors.toList()); + return listCanPayEmpIds; + } + + private void handleData(List ids, AccountParam param) { + String billMonth = param.getBillMonth(); + try { + List list = new ArrayList<>(); + List> partitionDetailTempInfo = Lists.partition((List) ids, 100); + partitionDetailTempInfo.forEach(part -> list.addAll( + getSIAccountDetailTempMapper().getListByEmployeeIdsAndBillMonth(part, billMonth, param.getPaymentOrganization()))); + + encryptUtil.decryptList(list, InsuranceAccountDetailTempPO.class); + Integer paymentStatus = 0; + log.info("核算明细临时表 hrsa_bill_detail_temp待处理数量:{}", list.size()); + List> partitionIds = Lists.partition((List) ids, 100); + log.info("bill_detail入库前删除数据数量:{}", ids.size()); + getInsuranceAccountDetailMapper().batchDelAccountDetails(Collections.emptyList(), billMonth, param.getPaymentOrganization(), paymentStatus); + + //删除账单月份+个税扣缴义务人+人员id下的调差数据 + getInsuranceCompensationMapper().deleteByBillMonthPayOrgEmpIds(InsuranceCompensationPO.builder() + .billMonth(billMonth) + .paymentOrganization(param.getPaymentOrganization()) + .build()); + // for (List part : partitionIds) { + // getInsuranceAccountDetailMapper().batchDelAccountDetails(part, billMonth, param.getPaymentOrganization(), paymentStatus); + // + // //删除账单月份+个税扣缴义务人+人员id下的调差数据 + // getInsuranceCompensationMapper().deleteByBillMonthPayOrgEmpIds(InsuranceCompensationPO.builder() + // .billMonth(billMonth) + // .paymentOrganization(param.getPaymentOrganization()) + // .employeeIds(part) + // .build()); + // } + + //生成bill_detail入库数据 + List collect = list.stream().map(item -> { + InsuranceAccountDetailPO insuranceAccountDetailPO = new InsuranceAccountDetailPO(); + BeanUtils.copyProperties(item, insuranceAccountDetailPO); + return insuranceAccountDetailPO; + }).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(collect)) { + log.info("bill_detail入库数据数量:{}", collect.size()); + batchSaveAccountInspectDetail(collect); + encryptUtil.encryptList(collect, InsuranceAccountDetailPO.class); + List> lists = splitDetailList(collect, 20); + lists.forEach(subList -> { + getInsuranceAccountDetailMapper().batchSaveAccountDetails(subList); + }); + updateBatchAccount(param); + } + } catch (Exception e) { + log.error("福利核算数据处理失败", e); + getSalaryAcctProgressService(user).fail(SalaryCacheKey.ACCT_PROGRESS + param.getBillMonth() + "_" + param.getPaymentOrganization(), SalaryI18nUtil.getI18nLabel(0, "福利核算出错") + ": " + e.getMessage()); + throw e; + } + } + + public void batchSaveAccountInspectDetail(List list) { + List insuranceAccountInspectAllPOS = accountInspect(list, true); + batchDelInspectDetail(insuranceAccountInspectAllPOS); + List insuranceAccountInspectPOS = accountInspect(list, false); + if (CollectionUtils.isNotEmpty(insuranceAccountInspectPOS)) { + batchSaveInspectDetail(insuranceAccountInspectPOS); + } + } + public void batchDelInspectDetail(List list) { + List> lists = Lists.partition(list, 100); + lists.forEach(getInsuranceAccountInspectMapper()::batchDelInspectDetails); + + } + + public void batchSaveInspectDetail(List list) { + List> lists = Lists.partition(list, 100); + lists.forEach(getInsuranceAccountInspectMapper()::batchSaveInspectDetails); + } + + public List accountInspect(List list, boolean isAll) { + List insuranceAccountInspectPOS = new ArrayList<>(); + for (InsuranceAccountDetailPO e : list) { + if (isAll || detailCheck(e.getSocialPerJson()) || detailCheck(e.getSocialComJson()) + || detailCheck(e.getFundPerJson()) || detailCheck(e.getFundComJson()) + || detailCheck(e.getOtherPerJson()) || detailCheck(e.getOtherComJson())) { + InsuranceAccountInspectPO insuranceAccountInspectPO = InsuranceAccountInspectPO.builder().build(); + insuranceAccountInspectPO.setSupplementaryProjects(e.getSupplementaryProjects()); + insuranceAccountInspectPO.setInspectStatus(InspectStatusEnum.IGNORE.getValue()); + insuranceAccountInspectPO.setBillMonth(e.getBillMonth()); + insuranceAccountInspectPO.setCreator(e.getCreator()); + insuranceAccountInspectPO.setCreateTime(new Date()); + insuranceAccountInspectPO.setDeleteType(DeleteTypeEnum.NOT_DELETED.getValue()); + insuranceAccountInspectPO.setEmployeeId(e.getEmployeeId()); + insuranceAccountInspectPO.setPaymentStatus(e.getPaymentStatus()); + insuranceAccountInspectPO.setSupplementaryMonth(e.getSupplementaryMonth()); + insuranceAccountInspectPO.setTenantKey(e.getTenantKey()); + insuranceAccountInspectPO.setUpdateTime(new Date()); + insuranceAccountInspectPOS.add(insuranceAccountInspectPO); + } + } + return insuranceAccountInspectPOS; + } + + public boolean detailCheck(String baseString) { + if (StringUtils.isEmpty(baseString)) { + return false; + } + Map baseStringMap = JSON.parseObject(baseString, new TypeReference>() { + }); + if (baseStringMap == null || baseStringMap.size() == 0) { + return false; + } + return baseStringMap.values().stream().anyMatch(item -> StringUtils.isEmpty(item) || Pattern.matches("^([0].?[0]*)$", item)); + + } + + private List> splitDetailList(List list, int groupSize) { + int length = list.size(); + // 计算可以分成多少组 + int num = (length + groupSize - 1) / groupSize; + List> newList = new ArrayList<>(num); + for (int i = 0; i < num; i++) { + // 开始位置 + int fromIndex = i * groupSize; + // 结束位置 + int toIndex = (i + 1) * groupSize < length ? (i + 1) * groupSize : length; + newList.add(list.subList(fromIndex, toIndex)); + } + return newList; + } + + /** + * 更新台账接口 + */ + public void updateBatchAccount(AccountParam param) { + String billMonth = param.getBillMonth(); + + List insuranceAccountDetailPOS = getInsuranceAccountDetailMapper().selectList(billMonth, param.getPaymentOrganization()); + Map> map = insuranceAccountDetailPOS.stream().filter(item -> item.getEmployeeId() != null) + .collect(Collectors.groupingBy(InsuranceAccountDetailPO::getEmployeeId)); + int socialAccountPerson = 0; + int funcAccountPerson = 0; + int otherAccountPerson = 0; + BigDecimal socialSum = new BigDecimal("0"); + BigDecimal fundSum = new BigDecimal("0"); + BigDecimal otherSum = new BigDecimal("0"); + for (Map.Entry> entry : map.entrySet()) { + List v = entry.getValue(); + BigDecimal socialTemp = new BigDecimal("0"); + BigDecimal fundTemp = new BigDecimal("0"); + BigDecimal otherTemp = new BigDecimal("0"); + encryptUtil.decryptList(v, InsuranceAccountDetailPO.class); + boolean socialPersonFlag = false; + boolean fundPersonFlag = false; + boolean otherPersonFlag = false; + for (InsuranceAccountDetailPO item : v) { + // 判断社保是否为0 + socialPersonFlag = (StringUtils.isBlank(item.getSocialSum()) || SalaryEntityUtil.StringEqZERO(item.getSocialSum())); + BigDecimal socialPerson = socialPersonFlag ? new BigDecimal("0") : new BigDecimal(item.getSocialSum()); + fundPersonFlag = (StringUtils.isBlank(item.getFundSum()) || SalaryEntityUtil.StringEqZERO(item.getFundSum())); + BigDecimal fundPerson = fundPersonFlag ? new BigDecimal("0") : new BigDecimal(item.getFundSum()); + otherPersonFlag = (StringUtils.isBlank(item.getOtherSum()) || SalaryEntityUtil.StringEqZERO(item.getOtherSum())); + BigDecimal otherPerson = otherPersonFlag ? new BigDecimal("0") : new BigDecimal(item.getOtherSum()); + socialTemp = socialTemp.add(socialPerson); + fundTemp = fundTemp.add(fundPerson); + otherTemp = otherTemp.add(otherPerson); + if (!socialPersonFlag && !item.getPaymentStatus().equals(PaymentStatusEnum.BALANCE.getValue())) { + socialAccountPerson += 1; + } + if (!fundPersonFlag && !item.getPaymentStatus().equals(PaymentStatusEnum.BALANCE.getValue())) { + funcAccountPerson += 1; + } + if (!otherPersonFlag && !item.getPaymentStatus().equals(PaymentStatusEnum.BALANCE.getValue())) { + otherAccountPerson += 1; + } + } + + if (!"0".equals(socialTemp.toPlainString())) { + socialSum = socialSum.add(socialTemp); + } + if (!"0".equals(fundTemp.toPlainString())) { + fundSum = fundSum.add(fundTemp); + } + if (!"0".equals(otherTemp.toPlainString())) { + otherSum = otherSum.add(otherTemp); + } + } + InsuranceAccountBatchPO insuranceAccountBatchPO = getInsuranceAccountBatchMapper().getByBillMonth(billMonth, param.getPaymentOrganization()); + encryptUtil.decrypt(insuranceAccountBatchPO, InsuranceAccountBatchPO.class); + + insuranceAccountBatchPO.setAccountant(user.getLastname()); + insuranceAccountBatchPO.setUpdateTime(new Date()); + insuranceAccountBatchPO.setSocialPay(socialSum.toPlainString()); + insuranceAccountBatchPO.setSocialNum(socialAccountPerson); + insuranceAccountBatchPO.setFundNum(funcAccountPerson); + insuranceAccountBatchPO.setFundPay(fundSum.toPlainString()); + insuranceAccountBatchPO.setOtherNum(otherAccountPerson); + insuranceAccountBatchPO.setOtherPay(otherSum.toPlainString()); + encryptUtil.encrypt(insuranceAccountBatchPO, InsuranceAccountBatchPO.class); + getInsuranceAccountBatchMapper().updateById(insuranceAccountBatchPO); + //记录操作日志 + encryptUtil.decrypt(insuranceAccountBatchPO, InsuranceAccountBatchPO.class); + TaxAgentPO taxAgentInfo = getTaxAgentMapper().getById(insuranceAccountBatchPO.getPaymentOrganization()); + LoggerContext loggerContext = new LoggerContext(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(insuranceAccountBatchPO.getId())); + loggerContext.setTargetName(taxAgentInfo.getName() + "-" + insuranceAccountBatchPO.getBillMonth()); + loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "更新福利台账")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "更新福利台账") + + ":" + taxAgentInfo.getName() + "-" + insuranceAccountBatchPO.getBillMonth()); + loggerContext.setNewValues(insuranceAccountBatchPO); + SalaryElogConfig.siAccountLoggerTemplate.write(loggerContext); + } + + public void siFile(String billMonth, Long paymentOrganization) { + + //开始归档数据 + InsuranceAccountBatchPO insuranceAccountBatchPO = getInsuranceAccountBatchMapper().getByBillStatus(billMonth, BillStatusEnum.NOT_ARCHIVED.getValue(), paymentOrganization); + encryptUtil.decrypt(insuranceAccountBatchPO, InsuranceAccountBatchPO.class); + SalaryAssert.notNull(insuranceAccountBatchPO, SalaryI18nUtil.getI18nLabel(0, "月份账单不存在")); + SalaryAssert.isFalse(Objects.equals(insuranceAccountBatchPO.getBillStatus(), BillStatusEnum.ARCHIVED.getValue()), SalaryI18nUtil.getI18nLabel(0, "月份账单已归档")); + insuranceAccountBatchPO.setBillStatus(BillStatusEnum.ARCHIVED.getValue()); + encryptUtil.encrypt(insuranceAccountBatchPO, InsuranceAccountBatchPO.class); + getInsuranceAccountBatchMapper().updateById(insuranceAccountBatchPO); + //记录操作日志 + encryptUtil.decrypt(insuranceAccountBatchPO, InsuranceAccountBatchPO.class); + TaxAgentPO taxAgentInfo = getTaxAgentMapper().getById(insuranceAccountBatchPO.getPaymentOrganization()); + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId("" + insuranceAccountBatchPO.getId()); + loggerContext.setTargetName(taxAgentInfo.getName() + "-" + insuranceAccountBatchPO.getBillMonth()); + loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "福利台账-归档")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "福利台账-归档") + + ": " + taxAgentInfo.getName() + "-" + insuranceAccountBatchPO.getBillMonth()); + loggerContext.setNewValues(insuranceAccountBatchPO); + SalaryElogConfig.siAccountLoggerTemplate.write(loggerContext); + } + + + public PageInfo siBatchListPage(InsuranceAccountBatchParam queryParam) { + List list = getInsuranceAccountBatchMapper().list(queryParam); + list = getAuthService(user).auth(list, AuthFilterTypeEnum.DATA_OPT, InsuranceAccountBatchPO.class); + PageInfo page = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), + list, InsuranceAccountBatchPO.class); + encryptUtil.decryptList(page.getList(), InsuranceAccountBatchPO.class); + return page; + } + + public PageInfo siBatchListCommonPage(InsuranceAccountDetailParam queryParam) { + queryParam.setPaymentStatus(PaymentStatusEnum.COMMON.getValue()); + //排序配置 + OrderRuleVO orderRule = getSalarySysConfService(user).orderRule(); + queryParam.setOrderRule(orderRule); + //系统人员福利台账明细 + List list = getInsuranceAccountDetailMapper().list(queryParam); + //非系统各人员台账明细 + List extList = getInsuranceAccountDetailMapper().extList(queryParam); + list.addAll(extList); + PageInfo pageInfo = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), + list, InsuranceAccountDetailPO.class); + encryptUtil.decryptList(pageInfo.getList(), InsuranceAccountDetailPO.class); + return pageInfo; + } + + public void siDelete(AccountParam param) { + InsuranceAccountBatchPO insuranceAccountBatchPO = getInsuranceAccountBatchMapper().getByBillMonth(param.getBillMonth(), param.getPaymentOrganization()); + encryptUtil.decrypt(insuranceAccountBatchPO, InsuranceAccountBatchPO.class); + SalaryAssert.notNull(insuranceAccountBatchPO, SalaryI18nUtil.getI18nLabel(0, "参数错误")); +// if (insuranceAccountBatchPO.getBillStatus().equals(BillStatusEnum.ARCHIVED.getValue())) { +// int num = checkIfBusinessAccounting(insuranceAccountBatchPO); +// //表示已经被核算过不能重新核算 +// if (num > 0) { +// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "已被薪酬核算给核算过,无法删除!")); +// } +// } + +// if(param.getPaymentOrganization()==null){ +// throw new SalaryRunTimeException("个税扣缴义务人为空"); +// } + getInsuranceAccountBatchMapper().deleteById(insuranceAccountBatchPO.getId()); + getInsuranceAccountDetailMapper().batchDeleteNotFile(param.getBillMonth(), param.getPaymentOrganization()); + //删除账单月份+个税扣缴义务人下的调差数据 + getInsuranceCompensationMapper().deleteByBillMonthAndPayOrg(param.getBillMonth(), param.getPaymentOrganization()); + //记录操作日志 + TaxAgentPO taxAgentInfo = getTaxAgentMapper().getById(insuranceAccountBatchPO.getPaymentOrganization()); + LoggerContext loggerContext = new LoggerContext(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(insuranceAccountBatchPO.getId())); + loggerContext.setTargetName(taxAgentInfo.getName() + "-" + insuranceAccountBatchPO.getBillMonth()); + loggerContext.setOperateType(OperateTypeEnum.DELETE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "删除福利台账")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "删除福利台账") + + ":" + taxAgentInfo.getName() + "-" + insuranceAccountBatchPO.getBillMonth()); + loggerContext.setNewValues(insuranceAccountBatchPO); + SalaryElogConfig.siAccountLoggerTemplate.write(loggerContext); + } + + public void siSaveSupplementaryAccount(SaveSupplementaryAccountParam param) { + if (StringUtils.isBlank(param.getBillMonth()) || CollectionUtils.isEmpty(param.getBillMonthList()) || CollectionUtils.isEmpty(param.getProjects()) + || CollectionUtils.isEmpty(param.getIncludes())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "参数错误")); + } + //需要补缴的月份 + if (param.getBillMonthList().contains(param.getBillMonth())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "当前月走正常缴纳")); + } + //需要补缴的员工id + List employeeIds = param.getIncludes(); + if (CollectionUtils.isNotEmpty(param.getExcludes())) { + employeeIds = employeeIds.stream().filter(item -> !param.getExcludes().contains(item)).collect(Collectors.toList()); + } + //校验补缴人员是否存在福利档案基础信息,并且runStatus处于正在缴纳或者待减员 + List insuranceBaseInfoList = getInsuranceBaseInfoMapper().getSocialByPaymentOrganization(param.getPaymentOrganization()); + List finalEmployeeIds = employeeIds; + List filterList = insuranceBaseInfoList.stream().filter(e -> { + for (Long uId : finalEmployeeIds) { + if (e.getEmployeeId().equals(uId) && (e.getRunStatus().equals(EmployeeStatusEnum.STAY_DEL.getValue()) || e.getRunStatus().equals(EmployeeStatusEnum.PAYING.getValue()))) { + return true; + } + } + return false; + }).collect(Collectors.toList()); + if (filterList.size() != employeeIds.size()) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "补缴人员中存在未设置福利档案人员或相关人员不在福利在缴人员中,不可新建补缴信息!")); + } + //20231122逻辑优化,过滤出不在起始缴纳月和最后缴纳月区间的人员 + List empIdsInPayMonthRange = listCanPayEmpIds(param.getPaymentOrganization(), param.getBillMonth()); + employeeIds = employeeIds.stream().filter(f -> empIdsInPayMonthRange.contains(f)).collect(Collectors.toList()); + + SalaryAssert.notEmpty(employeeIds, SalaryI18nUtil.getI18nLabel(0, "无核算人员")); + + // 获取员工信息 + List employeeList = getSalaryEmployeeService(user).listByIds(employeeIds); + Map empMap = SalaryEntityUtil.convert2Map(employeeList, DataCollectionEmployee::getEmployeeId); + + List baseList = new ArrayList<>(); + employeeIds.stream().forEach(id -> { + DataCollectionEmployee employee = empMap.get(id); + param.getBillMonthList().stream().forEach(month -> { + SupplementAccountBaseParam supplementAccountBaseParam = SupplementAccountBaseParam.builder() + .supplementaryMonth(month) + .employeeId(id) + .paymentOrganization(param.getPaymentOrganization()) + .projects(param.getProjects()) + .billMonth(param.getBillMonth()) + .supplementType(param.getSupplementType()) + .build(); + if (employee != null) { + supplementAccountBaseParam.setSubcompanyName(employee.getSubcompanyName()); + supplementAccountBaseParam.setSubcompanyId(employee.getSubcompanyid()); + supplementAccountBaseParam.setDepartmentName(employee.getDepartmentName()); + supplementAccountBaseParam.setDepartmentId(employee.getDepartmentId()); + supplementAccountBaseParam.setJobtitleName(employee.getJobtitleName()); + supplementAccountBaseParam.setJobtitleId(employee.getJobtitleId()); + supplementAccountBaseParam.setJobcall(employee.getJobcall()); + supplementAccountBaseParam.setJobcallId(employee.getJobcallId()); + supplementAccountBaseParam.setStatus(employee.getStatus()); + } + if ("2".equals(param.getSupplementType())) { + supplementAccountBaseParam.setSocialPaymentBaseString(param.getSocialPaymentBaseString()); + supplementAccountBaseParam.setFundPaymentBaseString(param.getFundPaymentBaseString()); + supplementAccountBaseParam.setOtherPaymentBaseString(param.getOtherPaymentBaseString()); + } else if("3".equals(param.getSupplementType())) { + supplementAccountBaseParam.setSocialPaymentPerString(param.getSocialPaymentPerString()); + supplementAccountBaseParam.setSocialPaymentComString(param.getSocialPaymentComString()); + supplementAccountBaseParam.setFundPaymentPerString(param.getFundPaymentPerString()); + supplementAccountBaseParam.setFundPaymentComString(param.getFundPaymentComString()); + supplementAccountBaseParam.setOtherPaymentPerString(param.getOtherPaymentPerString()); + supplementAccountBaseParam.setOtherPaymentComString(param.getOtherPaymentComString()); + } + baseList.add(supplementAccountBaseParam); + }); + }); + //核算开始 + accountSupplement(baseList, employeeIds, param.getPaymentOrganization()); + + updateBatchAccount(AccountParam.builder().billMonth(param.getBillMonth()).paymentOrganization(param.getPaymentOrganization()).build()); + } + + /** + * @param baseList 员工id-账单月份-补缴月份(单挑)-补缴项 集合 + * @param employeeIds 需要补缴的员工id + * @return + */ + public String accountSupplement(List baseList, List employeeIds, Long paymentOrganization) { + //(k,v) k-员工id v-员工对应的福利档案数据 +// Map longInsuranceArchivesAccountPOMap = siArchivesBiz.buildBatchAccount(employeeIds, paymentOrganization); + Map longInsuranceArchivesAccountPOMap = getSIArchivesService(user).buildBatchAccount(employeeIds, paymentOrganization); + //核算结果集 + List pos = new ArrayList<>(); + baseList.forEach(baseParam -> { + //判断人员id+账单月份+补缴月份在表中的唯一性 + List supplementList = getInsuranceAccountDetailMapper().querySupplementList(baseParam.getBillMonth(), baseParam.getPaymentOrganization(), baseParam.getEmployeeId(), baseParam.getSupplementaryMonth()); + if (supplementList.size() > 0) { + throw new SalaryRunTimeException("当前人员和账单月份已存在该补缴月份的数据!无法再次创建!"); + } + InsuranceAccountDetailPO insuranceAccountDetailPO = accountSingleEmployeeBill(baseParam, longInsuranceArchivesAccountPOMap.get(baseParam.getEmployeeId())); + pos.add(insuranceAccountDetailPO); + }); + batchSaveSupplementAccount(pos); + return SalaryI18nUtil.getI18nLabel(0, "核算完成,数据保存成功"); + } + + public InsuranceAccountDetailPO accountSingleEmployeeBill(SupplementAccountBaseParam baseParam, InsuranceArchivesAccountPO accountPO) { + InsuranceAccountDetailPO insuranceAccountDetailPO = new InsuranceAccountDetailPO(); + List projects = baseParam.getProjects(); + insuranceAccountDetailPO.setBillMonth(baseParam.getBillMonth()); + insuranceAccountDetailPO.setBillStatus(BillStatusEnum.NOT_ARCHIVED.getValue()); + insuranceAccountDetailPO.setCreator((long) user.getUID()); + insuranceAccountDetailPO.setCreateTime(new Date()); + insuranceAccountDetailPO.setUpdateTime(new Date()); + insuranceAccountDetailPO.setDeleteType(DeleteTypeEnum.NOT_DELETED.getValue()); + insuranceAccountDetailPO.setId(IdGenerator.generate()); + insuranceAccountDetailPO.setEmployeeId(baseParam.getEmployeeId()); + insuranceAccountDetailPO.setSubcompanyName(baseParam.getSubcompanyName()); + insuranceAccountDetailPO.setSubcompanyId(baseParam.getSubcompanyId()); + insuranceAccountDetailPO.setDepartmentName(baseParam.getDepartmentName()); + insuranceAccountDetailPO.setDepartmentId(baseParam.getDepartmentId()); + insuranceAccountDetailPO.setJobtitleName(baseParam.getJobtitleName()); + insuranceAccountDetailPO.setJobtitleId(baseParam.getJobtitleId()); + insuranceAccountDetailPO.setJobcall(baseParam.getJobcall()); + insuranceAccountDetailPO.setJobcallId(baseParam.getJobcallId()); + insuranceAccountDetailPO.setStatus(baseParam.getStatus()); + + insuranceAccountDetailPO.setPaymentStatus(PaymentStatusEnum.REPAIR.getValue()); + insuranceAccountDetailPO.setSupplementaryMonth(baseParam.getSupplementaryMonth()); + insuranceAccountDetailPO.setPaymentOrganization(baseParam.getPaymentOrganization()); + insuranceAccountDetailPO.setSupplementaryProjects( + String.join(",", + baseParam.getProjects() == null ? new ArrayList<>() : baseParam.getProjects().stream().map(String::valueOf).collect(Collectors.toList()))); + insuranceAccountDetailPO.setTenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY); + insuranceAccountDetailPO.setResourceFrom(ResourceFromEnum.SYSTEM.getValue()); + //缴纳组织=个税扣缴义务人 + insuranceAccountDetailPO.setSocialPayOrg(baseParam.getPaymentOrganization()); + if (projects.contains(ProjectTypeEnum.ALL.getValue())) { + if ("2".equals(baseParam.getSupplementType())) { + if (accountPO.getSocial() != null) { + accountPO.getSocial().setSocialPaymentBaseString(baseParam.getSocialPaymentBaseString()); + } + if (accountPO.getFund() != null) { + accountPO.getFund().setFundPaymentBaseString(baseParam.getFundPaymentBaseString()); + } + if (accountPO.getOther() != null) { + accountPO.getOther().setOtherPaymentBaseString(baseParam.getOtherPaymentBaseString()); + } + accountSocial(insuranceAccountDetailPO, accountPO, baseParam.getSupplementaryMonth()); + accountFund(insuranceAccountDetailPO, accountPO, baseParam.getSupplementaryMonth()); + accountOther(insuranceAccountDetailPO, accountPO, baseParam.getSupplementaryMonth()); + } else if ("3".equals(baseParam.getSupplementType())) { + accountSupSocialByData(insuranceAccountDetailPO, baseParam); + accountSupFundByData(insuranceAccountDetailPO, baseParam); + accountSupOtherByData(insuranceAccountDetailPO, baseParam); + } else { + accountSocial(insuranceAccountDetailPO, accountPO, baseParam.getSupplementaryMonth()); + accountFund(insuranceAccountDetailPO, accountPO, baseParam.getSupplementaryMonth()); + accountOther(insuranceAccountDetailPO, accountPO, baseParam.getSupplementaryMonth()); + } + + return account(insuranceAccountDetailPO); + } + if (projects.contains(ProjectTypeEnum.SOCIAL.getValue())) { + if ("2".equals(baseParam.getSupplementType())) { + if (accountPO.getSocial() != null) { + accountPO.getSocial().setSocialPaymentBaseString(baseParam.getSocialPaymentBaseString()); + } + accountSocial(insuranceAccountDetailPO, accountPO, baseParam.getSupplementaryMonth()); + } else if ("3".equals(baseParam.getSupplementType())) { + accountSupSocialByData(insuranceAccountDetailPO, baseParam); + } else { + accountSocial(insuranceAccountDetailPO, accountPO, baseParam.getSupplementaryMonth()); + } + + } + if (!projects.contains(ProjectTypeEnum.SOCIAL.getValue())) { + List ids = new ArrayList<>(); + List list = getICategoryMapper().listByDataType(DataTypeEnum.SYSTEM.getValue()); + + if (projects.contains(ProjectTypeEnum.ENDOWMENT_INSURANCE.getValue())) { + ICategoryPO insuranceCategoryPO = list.stream().filter(item -> SalaryI18nUtil.getI18nLabel(0, "养老保险").equals(item.getInsuranceName())).findFirst() + .get(); + ids.add(insuranceCategoryPO.getId()); + } + if (projects.contains(ProjectTypeEnum.MEDICAL_INSURANCE.getValue())) { + ICategoryPO insuranceCategoryPO = list.stream().filter(item -> SalaryI18nUtil.getI18nLabel(0, "医疗保险").equals(item.getInsuranceName())).findFirst() + .get(); + ids.add(insuranceCategoryPO.getId()); + } + if ("2".equals(baseParam.getSupplementType())) { + if (accountPO.getSocial() != null) { + accountPO.getSocial().setSocialPaymentBaseString(baseParam.getSocialPaymentBaseString()); + } + accountEndowmentInsurance(insuranceAccountDetailPO, accountPO, ids, baseParam.getSupplementaryMonth()); + } else if ("3".equals(baseParam.getSupplementType())) { + accountSupEndowmentInsuranceByData(insuranceAccountDetailPO, baseParam, ids); + } else { + accountEndowmentInsurance(insuranceAccountDetailPO, accountPO, ids, baseParam.getSupplementaryMonth()); + } + + } + if (projects.contains(ProjectTypeEnum.FUND.getValue())) { + if ("2".equals(baseParam.getSupplementType())) { + if (accountPO.getFund() != null) { + accountPO.getFund().setFundPaymentBaseString(baseParam.getFundPaymentBaseString()); + } + accountFund(insuranceAccountDetailPO, accountPO, baseParam.getSupplementaryMonth()); + } else if ("3".equals(baseParam.getSupplementType())) { + accountSupFundByData(insuranceAccountDetailPO, baseParam); + } else { + accountFund(insuranceAccountDetailPO, accountPO, baseParam.getSupplementaryMonth()); + } + } + if (projects.contains(ProjectTypeEnum.OTHER.getValue())) { + + if ("2".equals(baseParam.getSupplementType())) { + if (accountPO.getOther() != null) { + accountPO.getOther().setOtherPaymentBaseString(baseParam.getOtherPaymentBaseString()); + } + accountOther(insuranceAccountDetailPO, accountPO, baseParam.getSupplementaryMonth()); + } else if ("3".equals(baseParam.getSupplementType())) { + accountSupOtherByData(insuranceAccountDetailPO, baseParam); + } else { + accountOther(insuranceAccountDetailPO, accountPO, baseParam.getSupplementaryMonth()); + } + + } + + return account(insuranceAccountDetailPO); + } + + public void accountSupFundByData(InsuranceAccountDetailPO insuranceAccountDetailPO, SupplementAccountBaseParam baseParam) { + //公积金个人 + if (StringUtils.isNotBlank(baseParam.getFundPaymentPerString())) { + List fundPer = new ArrayList<>(); + HashMap fundPerson = JSON.parseObject(baseParam.getFundPaymentPerString(), new HashMap().getClass()); + fundPerson.forEach((k, v) -> { + BigDecimal result = new BigDecimal(v); + fundPer.add(result); + }); + insuranceAccountDetailPO.setFundPerJson(baseParam.getFundPaymentPerString()); + BigDecimal fundPerSum = new BigDecimal("0"); + for (BigDecimal bigDecimal : fundPer) { + fundPerSum = fundPerSum.add(bigDecimal); + } + insuranceAccountDetailPO.setFundPerSum(fundPerSum.toPlainString()); + } + //公积金单位 + if (StringUtils.isNotBlank(baseParam.getFundPaymentComString())) { + List fundCom = new ArrayList<>(); + HashMap fundComMap = JSON.parseObject(baseParam.getFundPaymentComString(), new HashMap().getClass()); + fundComMap.forEach((k, v) -> { + BigDecimal result = new BigDecimal(v); + fundCom.add(result); + }); + insuranceAccountDetailPO.setFundComJson(baseParam.getFundPaymentComString()); + BigDecimal fundComSum = new BigDecimal("0"); + for (BigDecimal bigDecimal : fundCom) { + fundComSum = fundComSum.add(bigDecimal); + } + insuranceAccountDetailPO.setFundComSum(fundComSum.toPlainString()); + } + } + + public void accountSupOtherByData(InsuranceAccountDetailPO insuranceAccountDetailPO, SupplementAccountBaseParam baseParam) { + //其他福利个人 + if (StringUtils.isNotBlank(baseParam.getOtherPaymentPerString())) { + List otherPer = new ArrayList<>(); + HashMap otherPerMap = JSON.parseObject(baseParam.getOtherPaymentPerString(), new HashMap().getClass()); + otherPerMap.forEach((k, v) -> { + BigDecimal result = new BigDecimal(v); + otherPer.add(result); + }); + insuranceAccountDetailPO.setOtherPerJson(baseParam.getOtherPaymentPerString()); + BigDecimal otherPerSum = new BigDecimal("0"); + for (BigDecimal bigDecimal : otherPer) { + otherPerSum = otherPerSum.add(bigDecimal); + } + insuranceAccountDetailPO.setOtherPerSum(otherPerSum.toPlainString()); + } + //其他福利单位 + if (StringUtils.isNotBlank(baseParam.getOtherPaymentComString())) { + List otherCom = new ArrayList<>(); + HashMap otherComMap = JSON.parseObject(baseParam.getOtherPaymentComString(), new HashMap().getClass()); + otherComMap.forEach((k, v) -> { + BigDecimal result = new BigDecimal(v); + otherCom.add(result); + }); + insuranceAccountDetailPO.setOtherComJson(baseParam.getOtherPaymentComString()); + BigDecimal otherComSum = new BigDecimal("0"); + for (BigDecimal bigDecimal : otherCom) { + otherComSum = otherComSum.add(bigDecimal); + } + insuranceAccountDetailPO.setOtherComSum(otherComSum.toPlainString()); + } + } + + public void accountSupSocialByData(InsuranceAccountDetailPO insuranceAccountDetailPO, SupplementAccountBaseParam baseParam) { + //社保个人 + if (StringUtils.isNotBlank(baseParam.getSocialPaymentPerString())) { + List socialPer = new ArrayList<>(); + HashMap archivesPerson = JSON.parseObject(baseParam.getSocialPaymentPerString(), new HashMap().getClass()); + archivesPerson.forEach((k, v) -> { + BigDecimal result = new BigDecimal(v); + socialPer.add(result); + }); + insuranceAccountDetailPO.setSocialPerJson(baseParam.getSocialPaymentPerString()); + BigDecimal socialPerSum = new BigDecimal("0"); + for (BigDecimal bigDecimal : socialPer) { + socialPerSum = socialPerSum.add(bigDecimal); + } + insuranceAccountDetailPO.setSocialPerSum(socialPerSum.toPlainString()); + } + //社保单位 + if (StringUtils.isNotBlank(baseParam.getSocialPaymentComString())) { + List socialCom = new ArrayList<>(); + HashMap archivesCom = JSON.parseObject(baseParam.getSocialPaymentComString(), new HashMap().getClass()); + archivesCom.forEach((k, v) -> { + BigDecimal result = new BigDecimal(v); + socialCom.add(result); + }); + insuranceAccountDetailPO.setSocialComJson(baseParam.getSocialPaymentComString()); + BigDecimal socialComSum = new BigDecimal("0"); + for (BigDecimal bigDecimal : socialCom) { + socialComSum = socialComSum.add(bigDecimal); + } + insuranceAccountDetailPO.setSocialComSum(socialComSum.toPlainString()); + } + } + + public InsuranceAccountDetailPO accountEndowmentInsurance(InsuranceAccountDetailPO insuranceAccountDetailPO, InsuranceArchivesAccountPO accountPO, List categoryIds, String billMonth) { + if (accountPO.getSocial() != null) { + InsuranceArchivesSocialSchemePO socialPO = accountPO.getSocial(); + insuranceAccountDetailPO.setSocialPayOrg(socialPO.getPaymentOrganization()); + insuranceAccountDetailPO.setSocialAccount(socialPO.getSocialAccount()); + insuranceAccountDetailPO.setSocialSchemeId(socialPO.getSocialSchemeId()); + insuranceAccountDetailPO.setSocialPaymentBaseString(socialPO.getSocialPaymentBaseString()); + insuranceAccountDetailPO.setSocialPaymentComBaseString(socialPO.getSocialPaymentComBaseString()); + //判断是否在起始缴纳月和最后缴纳月之间 + Boolean inDataRange = SalaryDateUtil.monthInRange(billMonth, socialPO.getSocialStartTime(), socialPO.getSocialEndTime()); + + if ((Objects.equals(NonPaymentEnum.YES.getValue(), socialPO.getNonPayment()) || socialPO.getNonPayment() == null) && socialPO.getSocialSchemeId() != null && inDataRange) { + List detailPOS = getInsuranceSchemeDetailMapper().queryListBySchemeId(socialPO.getSocialSchemeId()); + encryptUtil.decryptList(detailPOS, InsuranceSchemeDetailPO.class); + //方案中包含的需要缴纳社保的个人福利 + int monthIndex = Integer.parseInt(billMonth.split("-")[1]) - 1; + Map schemeperson = detailPOS.stream() + .filter(item -> Objects.equals(IsPaymentEnum.YES.getValue(), item.getIsPayment()) + && Objects.equals(item.getPaymentScope(), PaymentScopeEnum.SCOPE_PERSON.getValue()) + && (item.getPaymentCycle() == null || item.getPaymentCycle() == 0 || (item.getPaymentCycle() == 1 && String.valueOf(item.getCycleSetting().charAt(monthIndex)).equals("1")))) + .collect( + Collectors.toMap(InsuranceSchemeDetailPO::getInsuranceId, Function.identity())); + //档案中包含的基数信息 + HashMap archivesPerson = JSON.parseObject(socialPO.getSocialPaymentBaseString(), new HashMap().getClass()); + //需要核算社保的福利id 个人 + List needArchivesPerson = new ArrayList<>(); + if (archivesPerson != null) { + categoryIds.forEach(item -> { + if (archivesPerson.containsKey(String.valueOf(item)) && schemeperson.containsKey(item)) { + if (StringUtils.isNotBlank(archivesPerson.get(String.valueOf(item)))) { + needArchivesPerson.add(item); + } + } + }); + } + //判断核算周期、核算月、福利起始缴纳月的关系 + checkCycleSettingWithStartMonth(schemeperson, billMonth, socialPO.getSocialStartTime()); + + List socialPer = new ArrayList<>(); + Map socialPerJsonMap = new HashMap<>(); + needArchivesPerson.forEach(e -> { + InsuranceSchemeDetailPO po = schemeperson.get(e); + BigDecimal paymentProportion = new BigDecimal(po.getPaymentProportion()).divide(new BigDecimal("100")); + BigDecimal paymentNum = new BigDecimal((ObjectUtil.isEmpty(archivesPerson) || StringUtils.isBlank(archivesPerson.get(String.valueOf(e)))) ? "0" : archivesPerson.get(String.valueOf(e))); + BigDecimal fixedCost = StringUtils.isBlank(po.getFixedCost()) ? new BigDecimal("0") : new BigDecimal(po.getFixedCost()); + Integer newScale = po.getValidNum() == null ? 0 : po.getValidNum(); + BigDecimal result = new BigDecimal("0"); + if (Objects.equals(po.getPaymentCycle(), 1)) { + int monthValue = 1; + for (int i = monthIndex - 1; i >= 0; i--) { + String cycleValue = po.getCycleSetting().charAt(i) + ""; + if (Integer.parseInt(cycleValue) == 1) { + break; + } + monthValue++; + } + if (po.getAccountType() == 1) { + paymentNum = paymentNum.multiply(new BigDecimal(monthValue)); + fixedCost = fixedCost.multiply(new BigDecimal(monthValue)); + result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost)); + } else { + for (int i = 0; i < monthValue; i++) { + result = result.add(SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost))); + } + } + } else { + result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost)); + } + socialPerJsonMap.put(String.valueOf(e), result.toPlainString()); + socialPer.add(result); + }); + insuranceAccountDetailPO.setSocialPerJson(JSON.toJSONString(socialPerJsonMap)); + BigDecimal socialPerSum = new BigDecimal("0"); + for (BigDecimal bigDecimal : socialPer) { + socialPerSum = socialPerSum.add(bigDecimal); + } + insuranceAccountDetailPO.setSocialPerSum(socialPerSum.toPlainString()); + //方案中包含的需要缴纳社保的单位福利 + Map schemeCom = detailPOS.stream() + .filter(item -> Objects.equals(IsPaymentEnum.YES.getValue(), item.getIsPayment()) && Objects.equals(item.getPaymentScope(), PaymentScopeEnum.SCOPE_COMPANY.getValue()) && + (item.getPaymentCycle() == null || item.getPaymentCycle() == 0 || (item.getPaymentCycle() == 1 && String.valueOf(item.getCycleSetting().charAt(monthIndex)).equals("1")))) + .collect( + Collectors.toMap(InsuranceSchemeDetailPO::getInsuranceId, Function.identity())); + //档案中包含的基数信息 + HashMap archivesCom = JSON.parseObject(socialPO.getSocialPaymentBaseString(), new HashMap().getClass()); + //需要核算社保的福利id 单位 + List needArchivesCom = new ArrayList<>(); + if (archivesCom != null) { + categoryIds.forEach(item -> { + if (archivesCom.containsKey(String.valueOf(item)) && schemeCom.containsKey(item)) { + if (StringUtils.isNotBlank(archivesCom.get(String.valueOf(item)))) { + needArchivesCom.add(item); + } + } + }); + //判断核算周期、核算月、福利起始缴纳月的关系 + checkCycleSettingWithStartMonth(schemeCom, billMonth, socialPO.getSocialStartTime()); + } + List socialCom = new ArrayList<>(); + Map sociaComJsonMap = new HashMap<>(); + needArchivesCom.forEach(e -> { + InsuranceSchemeDetailPO po = schemeCom.get(e); + BigDecimal paymentProportion = new BigDecimal(po.getPaymentProportion()).divide(new BigDecimal("100")); + BigDecimal paymentNum = new BigDecimal((ObjectUtil.isEmpty(archivesCom) || StringUtils.isBlank(archivesCom.get(String.valueOf(e)))) ? "0" : archivesCom.get(String.valueOf(e))); + BigDecimal fixedCost = StringUtils.isBlank(po.getFixedCost()) ? new BigDecimal("0") : new BigDecimal(po.getFixedCost()); + Integer newScale = po.getValidNum() == null ? 0 : po.getValidNum(); + BigDecimal result = new BigDecimal("0"); + if (Objects.equals(po.getPaymentCycle(), 1)) { + int monthValue = 1; + for (int i = monthIndex - 1; i >= 0; i--) { + String cycleValue = po.getCycleSetting().charAt(i) + ""; + if (Integer.parseInt(cycleValue) == 1) { + break; + } + monthValue++; + } + if (po.getAccountType() == 1) { + paymentNum = paymentNum.multiply(new BigDecimal(monthValue)); + fixedCost = fixedCost.multiply(new BigDecimal(monthValue)); + result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost)); + } else { + for (int i = 0; i < monthValue; i++) { + result = result.add(SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost))); + } + } + } else { + result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost)); + } + + sociaComJsonMap.put(String.valueOf(e), result.toPlainString()); + socialCom.add(result); + + }); + insuranceAccountDetailPO.setSocialComJson(JSON.toJSONString(sociaComJsonMap)); + BigDecimal socialComSum = new BigDecimal("0"); + for (BigDecimal decimal : socialCom) { + socialComSum = socialComSum.add(decimal); + } + insuranceAccountDetailPO.setSocialComSum(socialComSum.toPlainString()); + } + } + return insuranceAccountDetailPO; + } + + public void accountSupEndowmentInsuranceByData(InsuranceAccountDetailPO insuranceAccountDetailPO, SupplementAccountBaseParam baseParam, List ids) { + //社保个人 + if (StringUtils.isNotBlank(baseParam.getSocialPaymentPerString())) { + List socialPer = new ArrayList<>(); + HashMap archivesPerson = JSON.parseObject(baseParam.getSocialPaymentPerString(), new HashMap().getClass()); + HashMap socialPerson = new HashMap<>(); + archivesPerson.forEach((k, v) -> { + if (ids.contains(Long.valueOf(k))) { + socialPerson.put(k, v); + BigDecimal result = new BigDecimal(v); + socialPer.add(result); + } + + }); + insuranceAccountDetailPO.setSocialPerJson(JSON.toJSONString(socialPerson)); + BigDecimal socialPerSum = new BigDecimal("0"); + for (BigDecimal bigDecimal : socialPer) { + socialPerSum = socialPerSum.add(bigDecimal); + } + insuranceAccountDetailPO.setSocialPerSum(socialPerSum.toPlainString()); + } + //社保单位 + if (StringUtils.isNotBlank(baseParam.getSocialPaymentComString())) { + List socialCom = new ArrayList<>(); + HashMap archivesCom = JSON.parseObject(baseParam.getSocialPaymentComString(), new HashMap().getClass()); + HashMap socialComMap = new HashMap<>(); + archivesCom.forEach((k, v) -> { + if (ids.contains(Long.valueOf(k))) { + socialComMap.put(k, v); + BigDecimal result = new BigDecimal(v); + socialCom.add(result); + } + }); + insuranceAccountDetailPO.setSocialComJson(JSON.toJSONString(socialComMap)); + BigDecimal socialComSum = new BigDecimal("0"); + for (BigDecimal bigDecimal : socialCom) { + socialComSum = socialComSum.add(bigDecimal); + } + insuranceAccountDetailPO.setSocialComSum(socialComSum.toPlainString()); + } + } + + public void batchSaveSupplementAccount(List pos) { + if (CollectionUtils.isEmpty(pos)) { + return; + } + batchSaveAccountInspectDetail(pos); + getInsuranceAccountDetailMapper().batchDelSupplementAccountDetails(pos); + encryptUtil.encryptList(pos, InsuranceAccountDetailPO.class); + List> lists = splitDetailList(pos, 20); + lists.forEach(subList -> { + getInsuranceAccountDetailMapper().batchSaveAccountDetails(subList); + }); + //删除日志 +// pos.stream().forEach(item -> { +// LoggerContext insuranceSchemeContext = new LoggerContext(); +// insuranceSchemeContext.setTargetId(String.valueOf(item.getId())); +// insuranceSchemeContext.setTargetName(String.valueOf(item.getEmployeeId())); +// insuranceSchemeContext.setOperateType(OperateTypeEnum.DELETE.getValue()); +// insuranceSchemeContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(100448, "删除核算记录")); +// insuranceSchemeContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(100448, "删除核算记录")); +// insuranceSchemeContext.setNewValues(item); +// siAccountLoggerTemplate.write(insuranceSchemeContext); +// }); + //插入日志 +// pos.stream().forEach(item -> { +// LoggerContext insuranceSchemeContext = new LoggerContext(); +// insuranceSchemeContext.setTargetId(String.valueOf(item.getId())); +// insuranceSchemeContext.setTargetName(String.valueOf(item.getEmployeeId())); +// insuranceSchemeContext.setOperateType(OperateTypeEnum.ADD.getValue()); +// insuranceSchemeContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(100494, "新建核算记录")); +// insuranceSchemeContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(100494, "新建核算记录")); +// insuranceSchemeContext.setNewValues(item); +// siAccountLoggerTemplate.write(insuranceSchemeContext); +// }); + //记录操作日志 + encryptUtil.decryptList(pos, InsuranceAccountDetailPO.class); + InsuranceAccountBatchPO targetPO = getInsuranceAccountBatchMapper().getByBillMonth(pos.get(0).getBillMonth(), pos.get(0).getPaymentOrganization()); + TaxAgentPO taxAgentInfo = getTaxAgentMapper().getById(targetPO.getPaymentOrganization()); + pos.forEach(targetDetailPO -> { + DataCollectionEmployee empInfo = getEmployMapper().getEmployeeById(targetDetailPO.getEmployeeId()); + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId("" + targetPO.getId()); + loggerContext.setTargetName(taxAgentInfo.getName() + "-" + targetPO.getBillMonth() + "-" + empInfo.getUsername()); + loggerContext.setOperateType(OperateTypeEnum.ADD.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "福利台账明细表-新增补缴")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "福利台账明细表-新增补缴") + + ": " + taxAgentInfo.getName() + "-" + targetPO.getBillMonth() + "-" + empInfo.getUsername()); + loggerContext.setNewValues(targetDetailPO); + SalaryElogConfig.siAccountLoggerTemplate.write(loggerContext); + }); + } + + public void siDeleteCommonAccount(SaveCommonAccountParam param) { + ValidUtil.doValidator(param); + //根据id批量删除 + if (param.getIds().size() > 0) { + getInsuranceAccountDetailMapper().batchDelAccountDetailsByIds(param.getIds()); + } else { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "请勾选需要删除的数据项!")); + } + //记录操作日志 + LoggerContext loggerContext = new LoggerContext(); + loggerContext.setUser(user); + loggerContext.setTargetId(param.getIds().stream().map(String::valueOf).collect(Collectors.joining(","))); + loggerContext.setTargetName(param.getIds().stream().map(String::valueOf).collect(Collectors.joining(","))); + loggerContext.setOperateType(OperateTypeEnum.DELETE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "福利台账明细表-删除正常缴纳核算记录")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "福利台账明细表-删除正常缴纳核算记录")); + SalaryElogConfig.siAccountLoggerTemplate.write(loggerContext); + + updateBatchAccount(AccountParam.builder().billMonth(param.getBillMonth()).paymentOrganization(param.getPaymentOrganization()).build()); + } + + public void siDeleteSupplementaryAccount(SaveCommonAccountParam param) { + ValidUtil.doValidator(param); + //根据id批量删除 + if (param.getIds().size() > 0) { + getInsuranceAccountDetailMapper().batchDelAccountDetailsByIds(param.getIds()); + } else { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "请勾选需要删除的数据项!")); + } + getInsuranceAccountDetailMapper().batchDelAccountDetailsByIds(param.getIds()); + //记录操作日志 + LoggerContext loggerContext = new LoggerContext(); + loggerContext.setUser(user); + loggerContext.setTargetId(param.getIds().stream().map(String::valueOf).collect(Collectors.joining(","))); + loggerContext.setTargetName(param.getIds().stream().map(String::valueOf).collect(Collectors.joining(","))); + loggerContext.setOperateType(OperateTypeEnum.DELETE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "福利台账明细表-删除补缴核算记录")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "福利台账明细表-删除补缴核算记录")); + SalaryElogConfig.siAccountLoggerTemplate.write(loggerContext); + + updateBatchAccount(AccountParam.builder().billMonth(param.getBillMonth()).paymentOrganization(param.getPaymentOrganization()).build()); + } + + public void accountInspect(Collection ids, String billMonth, Long paymentOrganization) { + List insuranceAccountInspectPOS = allInspects(ids, billMonth); + SalaryAssert.notEmpty(insuranceAccountInspectPOS, SalaryI18nUtil.getI18nLabel(0, "无核算数据")); + List commonInspects = insuranceAccountInspectPOS.stream() + .filter(e -> Objects.equals(e.getPaymentStatus(), PaymentStatusEnum.COMMON.getValue())) + .collect(Collectors.toList()); + List supplementInspects = insuranceAccountInspectPOS.stream() + .filter(e -> Objects.equals(e.getPaymentStatus(), PaymentStatusEnum.REPAIR.getValue())) + .collect(Collectors.toList()); + //核算正常缴纳 + if (CollectionUtils.isNotEmpty(commonInspects)) { + SaveCommonAccountParam param = new SaveCommonAccountParam(); + param.setBillMonth(billMonth); + param.setIncludes(commonInspects.stream().map(InsuranceAccountInspectPO::getEmployeeId).collect(Collectors.toList())); + siSaveCommonAccount(param); + } + //核算补缴 + if (CollectionUtils.isNotEmpty(supplementInspects)) { + List baseList = new ArrayList<>(); + supplementInspects.forEach(e -> { + SupplementAccountBaseParam base = new SupplementAccountBaseParam(); + base.setBillMonth(billMonth); + base.setProjects( + e.getSupplementaryProjects() == null ? null : Arrays.stream(e.getSupplementaryProjects().split(",")).map(Integer::valueOf).collect(Collectors.toList())); + base.setEmployeeId(e.getEmployeeId()); + base.setSupplementaryMonth(e.getSupplementaryMonth()); + baseList.add(base); + }); + accountSupplement(baseList, baseList.stream().map(SupplementAccountBaseParam::getEmployeeId).collect(Collectors.toList()), paymentOrganization); + } + } + + public PageInfo siOverView(InsuranceAccountDetailParam queryParam) { + + List insuranceAccountDetailPOS = getInsuranceAccountDetailMapper().selectList(queryParam.getBillMonth(), StringUtil.isBlank(queryParam.getPaymentOrganization()) ? null : Long.valueOf(queryParam.getPaymentOrganization())); + encryptUtil.decryptList(insuranceAccountDetailPOS, InsuranceAccountDetailPO.class); + //获取扣缴义务人信息 + List paymentList = getTaxAgentMapper().listAll(); + SalaryAssert.notEmpty(paymentList, SalaryI18nUtil.getI18nLabel(0, "该租户无扣缴义务人")); + Map paymentMap = paymentList.stream().collect(Collectors.toMap(TaxAgentPO::getId, Function.identity())); + List insuranceAccountViewListDTOS = buildRecords(insuranceAccountDetailPOS, paymentMap); + + PageInfo insuranceAccountViewListDTOPage = new PageInfo<>(insuranceAccountViewListDTOS, InsuranceAccountViewListDTO.class); + insuranceAccountViewListDTOPage.setTotal(insuranceAccountViewListDTOS.size()); + return insuranceAccountViewListDTOPage; + } + + @Override + public List buildRecords(List list, Map paymentMap) { + Map result = new HashMap<>(); + //根据组织分组,对社保进行统计 + Map> socialCollect = list.stream().filter(item -> item.getSocialPayOrg() != null) + .collect(Collectors.groupingBy(InsuranceAccountDetailPO::getSocialPayOrg)); + socialCollect.forEach((k, v) -> { + if (result.get(k) == null) { + InsuranceAccountViewListDTO temp = new InsuranceAccountViewListDTO(); + temp.setPayOrg(paymentMap.get(k).getName()); + result.put(k, temp); + } + InsuranceAccountViewListDTO insuranceAccountViewListDTO = result.get(k); + accountSocialView(insuranceAccountViewListDTO, v); + }); + //根据组织分组,对公积金进行统计 + Map> fundCollect = list.stream().filter(item -> item.getSocialPayOrg() != null) + .collect(Collectors.groupingBy(InsuranceAccountDetailPO::getSocialPayOrg)); + fundCollect.forEach((k, v) -> { + if (result.get(k) == null) { + InsuranceAccountViewListDTO temp = new InsuranceAccountViewListDTO(); + temp.setPayOrg(paymentMap.get(k).getName()); + result.put(k, temp); + } + InsuranceAccountViewListDTO insuranceAccountViewListDTO = result.get(k); + accountFundView(insuranceAccountViewListDTO, v); + }); + //根据组织分组,对其他福利进行统计 + Map> otherCollect = list.stream().filter(item -> item.getSocialPayOrg() != null) + .collect(Collectors.groupingBy(InsuranceAccountDetailPO::getSocialPayOrg)); + otherCollect.forEach((k, v) -> { + if (result.get(k) == null) { + InsuranceAccountViewListDTO temp = new InsuranceAccountViewListDTO(); + temp.setPayOrg(paymentMap.get(k).getName()); + result.put(k, temp); + } + InsuranceAccountViewListDTO insuranceAccountViewListDTO = result.get(k); + accountOtherView(insuranceAccountViewListDTO, v); + }); + //对各组织进行金额合计 + List viewDTOS = new ArrayList<>(); + result.forEach((k, v) -> { + BigDecimal socialPaySum = StringUtils.isBlank(v.getSocialPaySum()) ? new BigDecimal("0") : new BigDecimal(v.getSocialPaySum()); + BigDecimal fundPaySum = StringUtils.isBlank(v.getFundPaySum()) ? new BigDecimal("0") : new BigDecimal(v.getFundPaySum()); + BigDecimal otherPaySum = StringUtils.isBlank(v.getOtherPaySum()) ? new BigDecimal("0") : new BigDecimal(v.getOtherPaySum()); + v.setIndex(k); + BigDecimal sum = socialPaySum.add(fundPaySum).add(otherPaySum); + v.setSum(sum.toPlainString()); + viewDTOS.add(v); + }); + //合计 + InsuranceAccountViewListDTO insuranceAccountViewListDTO = new InsuranceAccountViewListDTO(); + int socialNum = 0; + int fundNum = 0; + int otherNum = 0; + BigDecimal socialSum = new BigDecimal("0"); + BigDecimal fundSum = new BigDecimal("0"); + BigDecimal otherSum = new BigDecimal("0"); + BigDecimal sum = new BigDecimal("0"); + for (InsuranceAccountViewListDTO item : viewDTOS) { + if (item.getSocialNum() != null) { + socialNum += item.getSocialNum(); + } + if (item.getFundNum() != null) { + fundNum += item.getFundNum(); + } + if (item.getOtherNum() != null) { + otherNum += item.getOtherNum(); + } + if (StringUtils.isNotBlank(item.getSocialPaySum())) { + socialSum = socialSum.add(new BigDecimal(item.getSocialPaySum())); + } + if (StringUtils.isNotBlank(item.getFundPaySum())) { + fundSum = fundSum.add(new BigDecimal(item.getFundPaySum())); + } + if (StringUtils.isNotBlank(item.getOtherPaySum())) { + otherSum = otherSum.add(new BigDecimal(item.getOtherPaySum())); + } + if (StringUtils.isNotBlank(item.getSum())) { + sum = sum.add(new BigDecimal(item.getSum())); + } + } + insuranceAccountViewListDTO.setSum(sum.toPlainString()); + insuranceAccountViewListDTO.setSocialPaySum(socialSum.toPlainString()); + insuranceAccountViewListDTO.setPayOrg(SalaryI18nUtil.getI18nLabel(0, "合计")); + insuranceAccountViewListDTO.setFundPaySum(fundSum.toPlainString()); + insuranceAccountViewListDTO.setOtherPaySum(otherSum.toPlainString()); + insuranceAccountViewListDTO.setSocialNum(socialNum); + insuranceAccountViewListDTO.setFundNum(fundNum); + insuranceAccountViewListDTO.setOtherNum(otherNum); + viewDTOS.add(insuranceAccountViewListDTO); + viewDTOS.forEach(e -> { + e.setSocialPaySum(StringUtils.isBlank(e.getSocialPaySum()) ? "0" : e.getSocialPaySum()); + e.setSocialNum(e.getSocialNum() == null ? 0 : e.getSocialNum()); + e.setFundNum(e.getFundNum() == null ? 0 : e.getFundNum()); + e.setFundPaySum(StringUtils.isBlank(e.getFundPaySum()) ? "0" : e.getFundPaySum()); + e.setOtherPaySum(StringUtils.isBlank(e.getOtherPaySum()) ? "0" : e.getOtherPaySum()); + e.setOtherNum(e.getOtherNum() == null ? 0 : e.getOtherNum()); + e.setSum(SalaryEntityUtil.thousandthConvert(e.getSum())); + e.setSocialPaySum(SalaryEntityUtil.thousandthConvert(e.getSocialPaySum())); + e.setOtherPaySum(SalaryEntityUtil.thousandthConvert(e.getOtherPaySum())); + e.setFundPaySum(SalaryEntityUtil.thousandthConvert(e.getFundPaySum())); + }); + return viewDTOS; + } + + @Override + public void cacheWelfareField(List welfareNames) { + String cacheKey = user.getUID() + SalaryItemConstant.SI_ACCOUNT_IMPORT_FIELD_SIGN; + Util_DataCache.setObjVal(cacheKey, JsonUtil.toJsonString(welfareNames)); + } + + @Override + public void cacheBalanceWelfareField(List welfareNames) { + String cacheKey = user.getUID() + SalaryItemConstant.SI_ACCOUNT_BALANCE_IMPORT_FIELD_SIGN; + Util_DataCache.setObjVal(cacheKey, JsonUtil.toJsonString(welfareNames)); + } + + public void accountOtherView(InsuranceAccountViewListDTO dto, List pos) { + int otherNum = 0; + BigDecimal otherPaySum = new BigDecimal("0"); + for (InsuranceAccountDetailPO item : pos) { + if (StringUtils.isNotBlank(item.getOtherSum()) && SalaryEntityUtil.string2DoubleDefault0(item.getOtherSum()) != 0.0) { + if (!PaymentStatusEnum.BALANCE.getValue().equals(item.getPaymentStatus())) { + otherNum += 1; + } + otherPaySum = otherPaySum.add(new BigDecimal(item.getOtherSum())); + } + } + dto.setOtherNum(otherNum); + dto.setOtherPaySum(otherPaySum.toPlainString()); + } + + public void accountFundView(InsuranceAccountViewListDTO dto, List pos) { + int fundNum = 0; + BigDecimal fundPaySum = new BigDecimal("0"); + for (InsuranceAccountDetailPO item : pos) { + if (StringUtils.isNotBlank(item.getFundSum()) && SalaryEntityUtil.string2DoubleDefault0(item.getFundSum()) != 0.0) { + if (!PaymentStatusEnum.BALANCE.getValue().equals(item.getPaymentStatus())) { + fundNum += 1; + } + fundPaySum = fundPaySum.add(new BigDecimal(item.getFundSum())); + } + } + dto.setFundNum(fundNum); + dto.setFundPaySum(fundPaySum.toPlainString()); + } + + public void accountSocialView(InsuranceAccountViewListDTO dto, List pos) { + int socialNum = 0; + BigDecimal socialPaySum = new BigDecimal("0"); + for (InsuranceAccountDetailPO item : pos) { + if (StringUtils.isNotBlank(item.getSocialSum()) && SalaryEntityUtil.string2DoubleDefault0(item.getSocialSum()) != 0.0 ) { + if (!PaymentStatusEnum.BALANCE.getValue().equals(item.getPaymentStatus())) { + socialNum += 1; + } + socialPaySum = socialPaySum.add(new BigDecimal(item.getSocialSum())); + } + } + dto.setSocialNum(socialNum); + dto.setSocialPaySum(socialPaySum.toPlainString()); + } + + /** + * 查询台账id是否已经薪资核算核算过 + * + * @param param + * @return + */ + public int checkIfBusinessAccounting(InsuranceAccountBatchPO param) { + List list = getSIAccountUtilMapper().checkIfBusinessaccounting(param.getId()); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM"); + return (int) list.stream().filter( f -> { + String billMonthBySob = sdf.format(convertSalaryMonthToBillMonth(f.getSalaryMonth(), f.getSocialSecurityCycleType())); + return f.getBillmonth().equals(billMonthBySob.substring(0, 7)); + }).count(); + } + + public Date convertSalaryMonthToBillMonth(Date salaryMonth, Integer socialSecurityCycleType) { + Calendar calendar = Calendar.getInstance(); + calendar.setTime(salaryMonth); + calendar.add(Calendar.MONTH, socialSecurityCycleType - 3); + return calendar.getTime(); + } + + /** + * 更新薪资台账 + * + * @param param + * @return + */ + public void updateById(InsuranceAccountBatchPO param) { + getInsuranceAccountBatchMapper().updateById(param); + } + + /** + * 更新福利台账 + */ + public void updateByEmployeeIdAndBillMonth(InsuranceAccountDetailPO insuranceAccountDetailPO) { + getInsuranceAccountDetailMapper().updateByEmployeeIdAndBillMonth(insuranceAccountDetailPO); + } + + /*****以上代码为SIAccountBiz中方法逻辑迁移,旨在减少Biz类的使用*****/ + + /** + * 正常缴纳页 删除社保核算人员 + * @param param + */ + @Override + public void deleteSocialAcctEmp(SaveCommonAccountParam param) { + if (StringUtils.isBlank(param.getBillMonth()) || param.getPaymentOrganization() == null) { + throw new SalaryRunTimeException("参数错误"); + } + if (CollectionUtils.isEmpty(param.getIds())) { + return; + } + List insuranceAccountDetailPOS = getInsuranceAccountDetailMapper().selectList(param.getBillMonth(), param.getPaymentOrganization()); + insuranceAccountDetailPOS = insuranceAccountDetailPOS.stream().filter(detailPO -> param.getIds().contains(detailPO.getId())).collect(Collectors.toList()); + List deleteEmployeeIds = insuranceAccountDetailPOS.stream().map(InsuranceAccountDetailPO::getEmployeeId).collect(Collectors.toList()); + deleteAccountDetailsByEmpIds(deleteEmployeeIds, param.getBillMonth(), param.getPaymentOrganization()); + if (CollectionUtils.isNotEmpty(deleteEmployeeIds)) { + // 重新计算合计值 + updateBatchAccount((AccountParam.builder().billMonth(param.getBillMonth()).paymentOrganization(param.getPaymentOrganization())).build()); + } + } + + public void deleteAccountDetailsByEmpIds(List deleteEmployeeIds, String billMonth, Long paymentOrganization) { + if (CollectionUtils.isNotEmpty(deleteEmployeeIds)) { + List> partition = Lists.partition(deleteEmployeeIds, 100); + partition.forEach(part -> { + // 删除该台账下,员工的所有数据 + getInsuranceAccountDetailMapper().deleteByEmpIds(part, billMonth, paymentOrganization); + }); + } + } + + /** + * 正常缴纳页 添加社保核算人员 + * @param param + */ + @Override + public String addSocialAcctEmp(SaveCommonAccountParam param) { + if (StringUtils.isBlank(param.getBillMonth()) || param.getPaymentOrganization() == null) { + throw new SalaryRunTimeException("参数错误"); + } + if (CollectionUtils.isEmpty(param.getIncludes())) { + return ""; + } + InsuranceAccountBatchPO insuranceAccountBatchPO = getInsuranceAccountBatchMapper().getByBillMonth(param.getBillMonth(), param.getPaymentOrganization()); + if (insuranceAccountBatchPO == null) { + throw new SalaryRunTimeException("台账不存在或已被删除"); + } + // 校验是否可以添加这些员工 + List empIds = param.getIncludes(); + List validIds = new ArrayList<>(); + + // 获取当前台账已经存在的人员 + List insuranceAccountDetailPOS = getInsuranceAccountDetailMapper().queryNormalListByBillMonth(param.getBillMonth(), param.getPaymentOrganization()); + List existEmpIds = insuranceAccountDetailPOS.stream().map(InsuranceAccountDetailPO::getEmployeeId).collect(Collectors.toList()); + Optional existOptional = empIds.stream().filter(existEmpIds::contains).findFirst(); + if (existOptional.isPresent()) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(101581, "人员已存在,请勿重复添加")); + } + + //过滤出需要核算的人员,即福利档案基础信息表中runStatus为正在缴纳和待减员的人员 + List baseInfoPOList = getInsuranceBaseInfoMapper().listByEmployeeIds(empIds); + List canAccountIds = baseInfoPOList.stream() + .filter(f->f.getPaymentOrganization().equals(param.getPaymentOrganization())) + .map(InsuranceArchivesBaseInfoPO::getEmployeeId) + .collect(Collectors.toList()); + + //20231122逻辑优化,过滤出不在起始缴纳月和最后缴纳月区间的人员 + List empIdsInPayMonthRange = listCanPayEmpIds(param.getPaymentOrganization(), param.getBillMonth()); + empIds = empIds.stream().filter(f->canAccountIds.contains(f) && empIdsInPayMonthRange.contains(f)).collect(Collectors.toList()); + + List socials = getSIArchivesService(user).getSocialByEmployeeIds(empIds); + //过滤出目标个税扣缴义务人相关信息 + socials = socials.stream().filter(f -> f.getPaymentOrganization().equals(param.getPaymentOrganization())).collect(Collectors.toList()); + List emp1 = socials.stream() + .filter(s -> !(StringUtils.isBlank(s.getSocialEndTime()) && StringUtils.isBlank(s.getSocialStartTime())) && + (StringUtils.isBlank(s.getSocialEndTime()) || (SalaryDateUtil.stringToDate(s.getSocialEndTime() + "-01") != null && !SalaryDateUtil.stringToDate(param.getBillMonth() + "-01").after(SalaryDateUtil.stringToDate(s.getSocialEndTime() + "-01")))) ) + .map(InsuranceArchivesSocialSchemePO::getEmployeeId) + .collect(Collectors.toList()); + + List funds = getSIArchivesService(user).getFundByEmployeeIds(empIds); + //过滤出目标个税扣缴义务人相关信息 + funds = funds.stream().filter(f -> f.getPaymentOrganization().equals(param.getPaymentOrganization())).collect(Collectors.toList()); + List emp2 = funds.stream() + .filter(s -> !(StringUtils.isBlank(s.getFundStartTime()) && StringUtils.isBlank(s.getFundEndTime())) && + (StringUtils.isBlank(s.getFundEndTime()) || (SalaryDateUtil.stringToDate(s.getFundEndTime() + "-01") != null && !SalaryDateUtil.stringToDate(param.getBillMonth() + "-01").after(SalaryDateUtil.stringToDate(s.getFundEndTime() + "-01"))))) + .map(InsuranceArchivesFundSchemePO::getEmployeeId) + .collect(Collectors.toList()); + + List others = getSIArchivesService(user).getOtherByEmployeeIds(empIds); + //过滤出目标个税扣缴义务人相关信息 + others = others.stream().filter(f -> f.getPaymentOrganization().equals(param.getPaymentOrganization())).collect(Collectors.toList()); + List emp3 = others.stream() + .filter(s -> !(StringUtils.isBlank(s.getOtherStartTime()) && StringUtils.isBlank(s.getOtherEndTime())) && + (StringUtils.isBlank(s.getOtherEndTime()) || (SalaryDateUtil.stringToDate(s.getOtherEndTime() + "-01") != null && !SalaryDateUtil.stringToDate(param.getBillMonth() + "-01").after(SalaryDateUtil.stringToDate(s.getOtherEndTime() + "-01"))))) + .map(InsuranceArchivesOtherSchemePO::getEmployeeId) + .collect(Collectors.toList()); + validIds.addAll(emp1); + validIds.addAll(emp2); + validIds.addAll(emp3); + List finalValidIds = validIds.stream().distinct().collect(Collectors.toList()); + List conNotAddEmpIds = param.getIncludes().stream().filter(empId -> !finalValidIds.contains(empId)).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(conNotAddEmpIds)) { + String canNotAddName = getSalaryEmployeeService(user).listByIds(conNotAddEmpIds).stream().map(DataCollectionEmployee::getUsername).collect(Collectors.joining(",")); + throw new SalaryRunTimeException("添加失败,员工:" +canNotAddName + ",社保、公积金、其他福利需至少有一种在当前账单月需缴纳,并且社保档案需为在缴员工"); + } + + addCommonEmpAndAccount(param.getBillMonth(), empIds, param.getPaymentOrganization()); + return "success"; + } + + /** + * 添加正常缴纳人员,并核算 + * @param billMonth + * @param ids + * @param paymentOrganization + */ + public void addCommonEmpAndAccount(String billMonth, List ids, Long paymentOrganization) { + Map insuranceArchivesAccountPOS = getSIArchivesService(user).buildBatchAccount(ids, paymentOrganization); + List employeeList = getSalaryEmployeeService(user).listByIds(ids); + Map employeeMap = SalaryEntityUtil.convert2Map(employeeList, DataCollectionEmployee::getEmployeeId); + + List list = new ArrayList<>(); + for (Map.Entry entry : insuranceArchivesAccountPOS.entrySet()) { + Long k = entry.getKey(); + InsuranceArchivesAccountPO v = entry.getValue(); + InsuranceAccountDetailPO insuranceAccountDetailPO = new InsuranceAccountDetailPO(); + insuranceAccountDetailPO.setBillMonth(billMonth); + insuranceAccountDetailPO.setBillStatus(BillStatusEnum.NOT_ARCHIVED.getValue()); + insuranceAccountDetailPO.setCreator((long) user.getUID()); + insuranceAccountDetailPO.setCreateTime(new Date()); + insuranceAccountDetailPO.setDeleteType(DeleteTypeEnum.NOT_DELETED.getValue()); + insuranceAccountDetailPO.setEmployeeId(k); + insuranceAccountDetailPO.setUpdateTime(new Date()); + insuranceAccountDetailPO.setPaymentStatus(PaymentStatusEnum.COMMON.getValue()); + insuranceAccountDetailPO.setResourceFrom(ResourceFromEnum.SYSTEM.getValue()); + insuranceAccountDetailPO.setTenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY); + insuranceAccountDetailPO.setPaymentOrganization(paymentOrganization); + + DataCollectionEmployee employee = employeeMap.get(k); + if (employee != null) { + insuranceAccountDetailPO.setSubcompanyName(employee.getSubcompanyName()); + insuranceAccountDetailPO.setSubcompanyId(employee.getSubcompanyid()); + insuranceAccountDetailPO.setDepartmentName(employee.getDepartmentName()); + insuranceAccountDetailPO.setDepartmentId(employee.getDepartmentId()); + insuranceAccountDetailPO.setJobtitleName(employee.getJobtitleName()); + insuranceAccountDetailPO.setJobtitleId(employee.getJobtitleId()); + insuranceAccountDetailPO.setJobcall(employee.getJobcall()); + insuranceAccountDetailPO.setJobcallId(employee.getJobcallId()); + insuranceAccountDetailPO.setStatus(employee.getStatus()); + } + + //核算社保 + accountSocial(insuranceAccountDetailPO, v, billMonth); + //核算公积金 + accountFund(insuranceAccountDetailPO, v, billMonth); + //核算其他福利 + accountOther(insuranceAccountDetailPO, v, billMonth); + //计算合计 + account(insuranceAccountDetailPO); + //临时表PO + InsuranceAccountDetailTempPO insuranceAccountDetailTempPO = new InsuranceAccountDetailTempPO(); + BeanUtils.copyProperties(insuranceAccountDetailPO, insuranceAccountDetailTempPO); + list.add(insuranceAccountDetailTempPO); + } + + // 入库 + //生成bill_detail入库数据 + List collect = list.stream().map(item -> { + InsuranceAccountDetailPO insuranceAccountDetailPO = new InsuranceAccountDetailPO(); + BeanUtils.copyProperties(item, insuranceAccountDetailPO); + return insuranceAccountDetailPO; + }).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(collect)) { + encryptUtil.encryptList(collect, InsuranceAccountDetailPO.class); + List> lists = splitDetailList(collect, 20); + lists.forEach(subList -> { + getInsuranceAccountDetailMapper().batchSaveAccountDetails(subList); + }); + updateBatchAccount((AccountParam.builder().billMonth(billMonth).paymentOrganization(paymentOrganization)).build()); + } + } + + +} diff --git a/src/com/engine/salary/service/impl/SIArchivesServiceImpl.java b/src/com/engine/salary/service/impl/SIArchivesServiceImpl.java new file mode 100644 index 000000000..c77ff7375 --- /dev/null +++ b/src/com/engine/salary/service/impl/SIArchivesServiceImpl.java @@ -0,0 +1,4082 @@ +package com.engine.salary.service.impl; + +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.TypeReference; +import com.api.browser.bean.SearchConditionGroup; +import com.api.browser.bean.SearchConditionItem; +import com.api.browser.bean.SearchConditionOption; +import com.api.browser.util.ConditionFactory; +import com.api.browser.util.ConditionType; +import com.cloudstore.dev.api.util.Util_DataCache; +import com.cloudstore.eccom.pc.table.WeaTable; +import com.cloudstore.eccom.pc.table.WeaTableCheckboxpopedom; +import com.cloudstore.eccom.pc.table.WeaTableColumn; +import com.cloudstore.eccom.result.WeaResultMsg; +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.hrmelog.entity.dto.LoggerContext; +import com.engine.salary.cmd.siarchives.SIArchivesTipsCmd; +import com.engine.salary.common.SalaryContext; +import com.engine.salary.config.SalaryElogConfig; +import com.engine.salary.constant.SalaryDefaultTenantConstant; +import com.engine.salary.encrypt.EncryptUtil; +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.siarchives.bo.InsuranceArchivesBO; +import com.engine.salary.entity.siarchives.bo.InsuranceArchivesBaseInfoBO; +import com.engine.salary.entity.siarchives.dto.*; +import com.engine.salary.entity.siarchives.param.*; +import com.engine.salary.entity.siarchives.po.*; +import com.engine.salary.entity.sicategory.po.ICategoryPO; +import com.engine.salary.entity.sischeme.po.InsuranceSchemeDetailPO; +import com.engine.salary.entity.sischeme.po.InsuranceSchemePO; +import com.engine.salary.entity.taxagent.param.TaxAgentQueryParam; +import com.engine.salary.entity.taxagent.po.TaxAgentEmpChangePO; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import com.engine.salary.enums.OperateTypeEnum; +import com.engine.salary.enums.UserStatusEnum; +import com.engine.salary.enums.auth.AuthFilterTypeEnum; +import com.engine.salary.enums.datacollection.DataCollectionEmployeeTypeEnum; +import com.engine.salary.enums.salaryaccounting.EmployeeTypeEnum; +import com.engine.salary.enums.siaccount.EmployeeStatusEnum; +import com.engine.salary.enums.sicategory.*; +import com.engine.salary.enums.taxagent.TaxAgentEmpChangeModuleEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.mapper.datacollection.EmployMapper; +import com.engine.salary.mapper.siarchives.*; +import com.engine.salary.mapper.sicategory.ICategoryMapper; +import com.engine.salary.mapper.sischeme.InsuranceSchemeDetailMapper; +import com.engine.salary.mapper.sischeme.InsuranceSchemeMapper; +import com.engine.salary.mapper.taxagent.TaxAgentMapper; +import com.engine.salary.service.*; +import com.engine.salary.service.auth.AuthService; +import com.engine.salary.service.auth.AuthServiceImpl; +import com.engine.salary.sys.constant.SalarySysConstant; +import com.engine.salary.sys.entity.po.SalarySysConfPO; +import com.engine.salary.sys.entity.vo.OrderRuleVO; +import com.engine.salary.sys.enums.OpenEnum; +import com.engine.salary.sys.service.SalarySysConfService; +import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl; +import com.engine.salary.util.*; +import com.engine.salary.util.db.IdGenerator; +import com.engine.salary.util.db.MapperProxyFactory; +import com.engine.salary.util.excel.ExcelUtil; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.util.page.SalaryPageUtil; +import com.engine.salary.wrapper.TaxAgentWrapper; +import com.google.common.collect.Lists; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.ibatis.session.SqlSession; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.springframework.beans.BeanUtils; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.StopWatch; +import weaver.conn.mybatis.MyBatisFactory; +import weaver.general.BaseBean; +import weaver.general.Util; +import weaver.hrm.User; + +import java.math.BigDecimal; +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.function.Function; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import java.util.stream.Collectors; + +import static com.engine.salary.sys.constant.SalarySysConstant.WEL_BASE_AUTO_ADJUST; +import static com.engine.salary.sys.constant.SalarySysConstant.WEL_BASE_DIFF_BY_PER_AND_COM; + +/** + * @Author weaver_cl + * @Description: + * @Date 2022/3/11 + * @Version V1.0 + **/ +@Slf4j +public class SIArchivesServiceImpl extends Service implements SIArchivesService { + private final BaseBean baseBean = new BaseBean(); + + private final Boolean isLog = "true".equals(baseBean.getPropValue("hrmSalary", "log")); + +// private SIArchivesBiz siArchivesBiz = new SIArchivesBiz(); + + private EncryptUtil encryptUtil = new EncryptUtil(); + + private TaxAgentService getTaxAgentService(User user) { + return ServiceUtil.getService(TaxAgentServiceImpl.class, user); + } + + private SalarySysConfService getSalarySysConfService(User user) { + return ServiceUtil.getService(SalarySysConfServiceImpl.class, user); + } + + private InsuranceBaseInfoMapper getInsuranceBaseInfoMapper() { + return MapperProxyFactory.getProxy(InsuranceBaseInfoMapper.class); + } + + private TaxAgentEmpChangeService getTaxAgentEmpChangeService(User user) { + return ServiceUtil.getService(TaxAgentEmpChangeServiceImpl.class, user); + } + + private SocialSchemeMapper getSocialSchemeMapper() { + return MapperProxyFactory.getProxy(SocialSchemeMapper.class); + } + + private FundSchemeMapper getFundSchemeMapper() { + return MapperProxyFactory.getProxy(FundSchemeMapper.class); + } + + private OtherSchemeMapper getOtherSchemeMapper() { + return MapperProxyFactory.getProxy(OtherSchemeMapper.class); + } + + private TaxAgentMapper getTaxAgentMapper() { + return MapperProxyFactory.getProxy(TaxAgentMapper.class); + } + + private InsuranceSchemeDetailMapper getInsuranceSchemeDetailMapper() { + return MapperProxyFactory.getProxy(InsuranceSchemeDetailMapper.class); + } + + private InsuranceSchemeMapper getInsuranceSchemeMapper() { + return MapperProxyFactory.getProxy(InsuranceSchemeMapper.class); + } + + private SalaryEmployeeService getSalaryEmployeeService(User user) { + return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user); + } + + private TaxAgentWrapper getTaxAgentWrapper(User user) { + return ServiceUtil.getService(TaxAgentWrapper.class, user); + } + + public SICategoryService getSICategoryService(User user) { + return ServiceUtil.getService(SICategoryServiceImpl.class, user); + } + + private SISchemeService getSISchemeService(User user) { + return ServiceUtil.getService(SISchemeServiceImpl.class,user); + } + + private EmployMapper getEmployMapper() { + return MapperProxyFactory.getProxy(EmployMapper.class); + } + + + private InsuranceBaseAdjustHistoryMapper getInsuranceBaseAdjustHistoryMapper() { + return MapperProxyFactory.getProxy(InsuranceBaseAdjustHistoryMapper.class); + } + + private ICategoryMapper getICategoryMapper() { + return MapperProxyFactory.getProxy(ICategoryMapper.class); + } + + + public AuthService getAuthService(User user) { + return ServiceUtil.getService(AuthServiceImpl.class, user); + } + + + @Override + public Map getTips(Map params) { + return commandExecutor.execute(new SIArchivesTipsCmd(params, user)); + } + + @Override + public Map getBaseForm(Map params) { + TaxAgentQueryParam param = TaxAgentQueryParam.builder().build(); + param.setFilterType(AuthFilterTypeEnum.ADMIN_DATA); + Collection taxAgentPOS = getTaxAgentService(user).listAuth(param); + + Map apidatas = new HashMap<>(16); + WelfareTypeEnum welfareTypeEnum = (WelfareTypeEnum) params.get("welfareTypeEnum"); + Long employeeId = Long.valueOf(Util.null2String(params.get("employeeId"))); + Long paymentOrganization = welfareTypeEnum != null ? Long.valueOf(Util.null2String(params.get("paymentOrganization"))) : null; + apidatas = getBaseForm(welfareTypeEnum, employeeId, paymentOrganization, taxAgentPOS); + return apidatas; + } + + @Override + public Map getPaymentForm(Map params) { + Map apidatas = new HashMap<>(16); + WelfareTypeEnum welfareTypeEnum = (WelfareTypeEnum) params.get("welfareTypeEnum"); + Long employeeId = Long.valueOf(Util.null2String(params.get("employeeId"))); + String schemeIdStr = Util.null2String(params.get("schemeId")); + Long paymentOrganization = Long.valueOf(Util.null2String(params.get("paymentOrganization"))); + Long schemeId = null; + if (StringUtils.isNotBlank(schemeIdStr)) { + schemeId = Long.valueOf(schemeIdStr); + } +// apidatas = siArchivesBiz.getPaymentForm(user, welfareTypeEnum, employeeId, (long) user.getUID(), schemeId, paymentOrganization); + apidatas = getPaymentForm(user, welfareTypeEnum, employeeId, schemeId, paymentOrganization); + return apidatas; + } + + + @Override + public String insert(InsuranceArchivesSaveParam param) { + SalaryAssert.notNull(param.getWelfareType(), "福利类型为空"); + //判断是否要区分个人和单位福利基数 + SalarySysConfPO welBaseDiff = getSalarySysConfService(user).getOneByCode(WEL_BASE_DIFF_BY_PER_AND_COM); + boolean welBaseDiffSign = welBaseDiff != null && welBaseDiff.getConfValue().equals(OpenEnum.OPEN.getValue()); + switch (param.getWelfareType()) { + case SOCIAL_SECURITY: + socialSave(param, user, welBaseDiffSign); + break; + case ACCUMULATION_FUND: + fundSave(param, user, welBaseDiffSign); + break; + case OTHER: + otherSave(param, user, welBaseDiffSign); + break; + default: + throw new SalaryRunTimeException("福利类型不存在"); + } + return null; + } + + @Override + public Map listPage(InsuranceArchivesListParam param) { + long currentEmployeeId = user.getUID(); + log.info("获取福利档案列表逻辑开始: {}", param); + StopWatch sw = new StopWatch(); + sw.start("福利档案-历史数据处理"); + // 1.历史数据处理 + handleHistoryData(currentEmployeeId); + sw.stop(); + + sw.start("福利档案-待减员自动处理"); + // 2.待减员自动处理 + handleStayDelData(currentEmployeeId); + sw.stop(); + +// sw.start("福利档案-增量数据处理"); +// // 3.增量数据处理 +// String welSign = (String) Util_DataCache.getObjVal("welfareChangeSign"); +// if (welSign == null || "0".equals(welSign)) { +// handleChangeData(currentEmployeeId); +// } +// sw.stop(); + + //排序配置 + OrderRuleVO orderRule = getSalarySysConfService(user).orderRule(); + param.setOrderRule(orderRule); + + Map apidatas = new HashMap<>(16); +// apidatas = siArchivesBiz.listPage(param, (long) user.getUID()); + apidatas = listPage(param, (long) user.getUID()); + + //记录操作日志 + List runStatuses = param.getRunStatuses() == null ? Collections.emptyList() : param.getRunStatuses().stream().map(s -> EmployeeStatusEnum.parseByValue(s).getDefaultLabel()).collect(Collectors.toList()); + String runStatusStr = CollectionUtils.isEmpty(runStatuses) ? "" : StringUtils.join(runStatuses, ""); + if (param.isExtWelArchiveList()) { + runStatusStr = "非系统人员"; + } + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetName(runStatusStr); + loggerContext.setOperateType(OperateTypeEnum.READ.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "查看福利档案列表")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "查看福利档案列表")); + SalaryElogConfig.siArchivesLoggerTemplate.write(loggerContext); + + log.info("各操作计时 {}", sw.prettyPrint()); + return apidatas; + } + + /** + * 福利档案中历史数据自动处理 + * @param currentEmployeeId + */ + private void handleHistoryData(long currentEmployeeId) { + //如果触发历史数据处理,则进行一次全量增员 + if (createOldInsuranceBaseInfo(currentEmployeeId)) { + //批量增员 + List allBaseInfoList = getInsuranceBaseInfoMapper().listAll(); + Collection stayAddIds = allBaseInfoList.stream().filter(f->f.getRunStatus().equals(EmployeeStatusEnum.STAY_ADD.getValue())) + .map(InsuranceArchivesBaseInfoPO::getId).collect(Collectors.toList()); + if (stayAddIds.size() > 0) { + stayAddToPay(stayAddIds); + } + } + + } + + /** + * 福利档案中待减员数据自动处理 + * @param currentEmployeeId + */ + @Override + @Transactional(rollbackFor = Exception.class) + public void handleStayDelData(long currentEmployeeId) { + log.info("福利档案中待减员数据自动处理逻辑开始:"); + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM"); + String today = simpleDateFormat.format(new Date()); + //part1,员工维护了社保/公积金/其他福利最后缴纳日,且任一类信息大于今天的,自动将待减员状态置为正在缴纳状态 + List rePayList = getInsuranceBaseInfoMapper().getRePayList(today); + updateInsuranceBaseInfoRunStatus(rePayList, EmployeeStatusEnum.PAYING.getValue()); + log.info("自动将待减员状态置为正在缴纳状态的档案数量 {}:", rePayList.size()); + //part2,员工维护了社保/公积金/其他福利最后缴纳日,且三类信息都小于今天的,自动置为待减员状态 + List reStayDelList = getInsuranceBaseInfoMapper().getReStayDelList(today); + updateInsuranceBaseInfoRunStatus(reStayDelList, EmployeeStatusEnum.STAY_DEL.getValue()); + log.info("自动置为待减员状态的档案数量 {}:", reStayDelList.size()); + //part3,非在职员工且处于正常缴纳的福利档案置为待减员状态 + //定义非在职的人事状态 + List personnelStatuses = new ArrayList() {{ + add("5"); + add("6"); + add("7"); + }}; + + if (CollectionUtils.isNotEmpty(personnelStatuses)) { + //获取非在职员工的福利档案基础信息 + InsuranceArchivesListParam insuranceArchivesListParam = new InsuranceArchivesListParam(); + insuranceArchivesListParam.setPersonnelStatuses(personnelStatuses); + insuranceArchivesListParam.setRunStatuses(Collections.singletonList(EmployeeStatusEnum.PAYING.getValue())); + + List noNormalList = getInsuranceBaseInfoMapper().getAbnormalList(insuranceArchivesListParam); + updateInsuranceBaseInfoRunStatus(noNormalList, EmployeeStatusEnum.STAY_DEL.getValue()); + log.info("自动处理非在职员工的档案数量 {}:", noNormalList.size()); + } + } + + /** + * 福利档案中增量数据处理 + * @param currentEmployeeId + */ + @Transactional(rollbackFor = Exception.class) + @Override + public void handleChangeData(long currentEmployeeId) { + try { + Util_DataCache.setObjVal("welfareChangeSign", "1"); + log.info("福利档案中增量数据处理逻辑开始:"); + // 所有增量人员列表 + List taxAgentEmpChangeList = getTaxAgentEmpChangeService(user).listAllByModule(TaxAgentEmpChangeModuleEnum.INSURANCE_ARCHIVE); + log.info("待处理的福利档案增量数据数量 {}:", taxAgentEmpChangeList.size()); + if (CollectionUtils.isEmpty(taxAgentEmpChangeList)) { + Util_DataCache.setObjVal("welfareChangeSign", "0"); + return; + } + + log.info("根据当前可以管辖的个税扣缴义务人筛选出的可处理增量数据数量 {}:", taxAgentEmpChangeList.size()); + // 所有福利档案基础信息数据 + List baseInfoPOList = getInsuranceBaseInfoMapper().listAll(); + log.info("当前数据库中所有福利档案基础信息数据数量 {}:", baseInfoPOList.size()); + StopWatch sw = new StopWatch(); + sw.start("将增量数据进一步处理为新增、更新两类数据"); + InsuranceArchivesBaseInfoBO.ChangeData changeData = InsuranceArchivesBaseInfoBO.buildChangeData(taxAgentEmpChangeList, baseInfoPOList, currentEmployeeId); + sw.stop(); + // 批量修改福利档案 + if (CollectionUtils.isNotEmpty(changeData.getBaseInfoUpdateTodoList())) { + log.info("增量数据中待更新的数据数量 {}:", changeData.getBaseInfoUpdateTodoList().size()); + //对于即将调整为“待减员”的数据,更新社保、公积金、其他福利档案的停止缴纳时间 + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM"); + String today = simpleDateFormat.format(new Date()); + sw.start("生成增量数据中即将置为“待减员”的数据"); + List toStayDelList = changeData.getBaseInfoUpdateTodoList().stream() + .filter(f -> f.getRunStatus().equals(EmployeeStatusEnum.STAY_DEL.getValue())) + .collect(Collectors.toList()); + if (isLog) { + log.info("福利档案-待减员明细:{}", toStayDelList); + } + if (toStayDelList.size() > 0) { + List> partitionUpdateEndTime = Lists.partition(toStayDelList, 100); + partitionUpdateEndTime.forEach(part->{ + List socialIds = part.stream().map(InsuranceArchivesBaseInfoPO::getSocialArchivesId).collect(Collectors.toList()); + List fundIds = part.stream().map(InsuranceArchivesBaseInfoPO::getFundArchivesId).collect(Collectors.toList()); + List otherIds = part.stream().map(InsuranceArchivesBaseInfoPO::getOtherArchivesId).collect(Collectors.toList()); + + getSocialSchemeMapper().batchUpdateEndTime(socialIds, today); + getFundSchemeMapper().batchUpdateEndTime(fundIds, today); + getOtherSchemeMapper().batchUpdateEndTime(otherIds, today); + }); + + } + sw.stop(); + + sw.start("生成增量数据中即将置为“逻辑删除”的数据"); + //对于逻辑删除的数据,同样逻辑删除相关的社保、公积金、其他福利档案 + List delList = changeData.getBaseInfoUpdateTodoList().stream() + .filter(f -> f.getDeleteType().equals(DeleteTypeEnum.DELETED.getValue())) + .collect(Collectors.toList()); + if (isLog) { + log.info("福利档案-逻辑删除明细:{}", delList); + } + if (delList.size() > 0) { + for (InsuranceArchivesBaseInfoPO po : delList) { + getSocialSchemeMapper().deleteByEmployeeIdAndPayOrg(InsuranceArchivesSocialSchemePO.builder() + .employeeId(po.getEmployeeId()) + .paymentOrganization(po.getPaymentOrganization()) + .build()); + getFundSchemeMapper().deleteByEmployeeIdAndPayOrg(InsuranceArchivesFundSchemePO.builder() + .employeeId(po.getEmployeeId()) + .paymentOrganization(po.getPaymentOrganization()) + .build()); + getOtherSchemeMapper().deleteByEmployeeIdAndPayOrg(InsuranceArchivesOtherSchemePO.builder() + .employeeId(po.getEmployeeId()) + .paymentOrganization(po.getPaymentOrganization()) + .build()); + } + } + sw.stop(); + //修改福利档案基础信息 + sw.start("增量数据中待更新数据入库"); + if (isLog) { + log.info("福利档案-增量数据中待更新数据入库明细:{}", changeData.getBaseInfoUpdateTodoList()); + } + List> partitionUpdateBase = Lists.partition(changeData.getBaseInfoUpdateTodoList(), 100); + partitionUpdateBase.forEach(part-> getInsuranceBaseInfoMapper().batchUpdate(part)); + sw.stop(); + log.info("增量数据中待更新的数据处理完成!"); + } + + sw.start("处理增量数据中待新增的数据"); + // 批量新增福利档案 + if (CollectionUtils.isNotEmpty(changeData.getBaseInfoAddTodoList())) { + log.info("增量数据中待新增的数据数量 {}:", changeData.getBaseInfoAddTodoList().size()); + //新增社保、公积金、其他福利档案、福利档案基础信息 + addNewInsuranceBaseInfo(changeData.getBaseInfoAddTodoList(), currentEmployeeId); + log.info("增量数据中待新增的数据处理完成!"); + } + sw.stop(); + + // 删除增量数据 + if (CollectionUtils.isNotEmpty(changeData.getChangeIds())) { + getTaxAgentEmpChangeService(user).deleleByIds(changeData.getChangeIds()); + } + log.info("各操作计时 {}", sw.prettyPrint()); + Util_DataCache.setObjVal("welfareChangeSign", "0"); + } catch (Exception e) { + log.info("福利档案-增量数据处理出错:{}", e.getMessage(), e); + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "福利档案-增量数据处理出错")); + } + } + + /** + * 删除档案 + * @param archiveIds + */ + @Override + public void deleteArchive(Collection archiveIds) { + if(CollectionUtils.isEmpty(archiveIds)){ + throw new SalaryRunTimeException("社保福利档案参数为空!"); + } + SalarySysConfPO canDelete = getSalarySysConfService(user).getOneByCode(SalarySysConstant.SALARY_ARCHIVE_DELETE); + if(Objects.isNull(canDelete) || StringUtils.equals(canDelete.getConfValue(),"0") ){ + throw new SalaryRunTimeException("不允许删除社保福利档案,请先开启删除档案规则配置!"); + } + List insuranceArchivesList = getInsuranceBaseInfoMapper().listByIds(archiveIds); + insuranceArchivesList = getAuthService(user).auth(insuranceArchivesList, AuthFilterTypeEnum.ADMIN_DATA, InsuranceArchivesBaseInfoPO.class); + + if (CollectionUtils.isEmpty(insuranceArchivesList)) { + throw new SalaryRunTimeException("社保档案不存在,或没有权限删除该社保案!"); + } + + Optional fixedList = insuranceArchivesList.stream().filter(archive -> !StringUtils.equals(archive.getRunStatus(), EmployeeStatusEnum.STAY_ADD.getValue()) + && !StringUtils.equals(archive.getRunStatus(), EmployeeStatusEnum.STOP_PAYMENT_FROM_ADD.getValue())).findFirst(); + if(fixedList.isPresent()){ + throw new SalaryRunTimeException("在缴员工、待减员、停止缴纳-来自待减员,无法删除薪资档案!"); + } + List archiveDelIds = insuranceArchivesList.stream().map(InsuranceArchivesBaseInfoPO::getId).collect(Collectors.toList()); + List socialArchiveDelIds = insuranceArchivesList.stream().map(InsuranceArchivesBaseInfoPO::getSocialArchivesId).collect(Collectors.toList()); + List fundArchiveDelIds = insuranceArchivesList.stream().map(InsuranceArchivesBaseInfoPO::getFundArchivesId).collect(Collectors.toList()); + List otherArchiveDelIds = insuranceArchivesList.stream().map(InsuranceArchivesBaseInfoPO::getOtherArchivesId).collect(Collectors.toList()); + //获取子表数据,方便记录操作日志 + List socialArchives = getSocialSchemeMapper().getSocialById(socialArchiveDelIds); + List fundArchives = getFundSchemeMapper().getFundById(fundArchiveDelIds); + List otherArchives = getOtherSchemeMapper().getOtherById(otherArchiveDelIds); + Map socialArchiveMap = SalaryEntityUtil.convert2Map(socialArchives, InsuranceArchivesSocialSchemePO::getId); + Map fundArchiveMap = SalaryEntityUtil.convert2Map(fundArchives, InsuranceArchivesFundSchemePO::getId); + Map otherArchiveMap = SalaryEntityUtil.convert2Map(otherArchives, InsuranceArchivesOtherSchemePO::getId); + // 删除社保档案主表及3张明细表数据 + if(CollectionUtils.isNotEmpty(archiveDelIds)){ + getInsuranceBaseInfoMapper().deleteByIds(archiveDelIds); + } + if(CollectionUtils.isNotEmpty(socialArchiveDelIds)){ + getSocialSchemeMapper().deleteByIds(socialArchiveDelIds); + } + if(CollectionUtils.isNotEmpty(fundArchiveDelIds)){ + getFundSchemeMapper().deleteByIds(fundArchiveDelIds); + } + if(CollectionUtils.isNotEmpty(otherArchiveDelIds)){ + getOtherSchemeMapper().deleteByIds(otherArchiveDelIds); + } + //记录操作日志 + List targetPOList = insuranceArchivesList.stream().filter(f -> archiveDelIds.contains(f.getId())).collect(Collectors.toList()); + if (targetPOList.size() > 0) { + targetPOList.forEach(targetPO -> { + DataCollectionEmployee empInfo = getEmployMapper().getEmployeeById(targetPO.getEmployeeId()); + TaxAgentPO taxAgentInfo = getTaxAgentMapper().getById(targetPO.getPaymentOrganization()); + targetPO.setDeleteType(DeleteTypeEnum.DELETED.getValue()); + //记录主表操作日志 + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(targetPO.getId())); + loggerContext.setTargetName(taxAgentInfo.getName() + "-" + empInfo.getUsername()); + loggerContext.setOperateType(OperateTypeEnum.DELETE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "删除福利档案主表")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "删除福利档案") + ": " + taxAgentInfo.getName() + "-" + empInfo.getUsername()); + loggerContext.setNewValues(targetPO); + SalaryElogConfig.siArchivesLoggerTemplate.write(loggerContext); + //记录明细表操作日志 + InsuranceArchivesSocialSchemePO socialTargetDetail = socialArchiveMap.get(targetPO.getSocialArchivesId()); + if (socialTargetDetail != null) { + socialTargetDetail.setDeleteType(DeleteTypeEnum.DELETED.getValue()); + LoggerContext detailLoggerContext = new LoggerContext<>(); + detailLoggerContext.setUser(user); + detailLoggerContext.setTargetId(String.valueOf(targetPO.getId())); + detailLoggerContext.setTargetName(taxAgentInfo.getName() + "-" + empInfo.getUsername()); + detailLoggerContext.setOperateType(OperateTypeEnum.DELETE.getValue()); + detailLoggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "删除福利档案-社保明细")); + detailLoggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "删除福利档案-社保明细") + ":" + taxAgentInfo.getName() + "-" + empInfo.getUsername()); + detailLoggerContext.setNewValues(socialTargetDetail); + SalaryElogConfig.siArchivesLoggerTemplate.write(detailLoggerContext); + } + InsuranceArchivesFundSchemePO fundTargetDetail = fundArchiveMap.get(targetPO.getFundArchivesId()); + if (fundTargetDetail != null) { + fundTargetDetail.setDeleteType(DeleteTypeEnum.DELETED.getValue()); + LoggerContext detailLoggerContext = new LoggerContext<>(); + detailLoggerContext.setUser(user); + detailLoggerContext.setTargetId(String.valueOf(targetPO.getId())); + detailLoggerContext.setTargetName(taxAgentInfo.getName() + "-" + empInfo.getUsername()); + detailLoggerContext.setOperateType(OperateTypeEnum.DELETE.getValue()); + detailLoggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "删除福利档案-公积金明细")); + detailLoggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "删除福利档案-公积金明细") + ":" + taxAgentInfo.getName() + "-" + empInfo.getUsername()); + detailLoggerContext.setNewValues(fundTargetDetail); + SalaryElogConfig.siArchivesLoggerTemplate.write(detailLoggerContext); + } + InsuranceArchivesOtherSchemePO otherTargetDetail = otherArchiveMap.get(targetPO.getOtherArchivesId()); + if (otherTargetDetail != null) { + otherTargetDetail.setDeleteType(DeleteTypeEnum.DELETED.getValue()); + LoggerContext detailLoggerContext = new LoggerContext<>(); + detailLoggerContext.setUser(user); + detailLoggerContext.setTargetId(String.valueOf(targetPO.getId())); + detailLoggerContext.setTargetName(taxAgentInfo.getName() + "-" + empInfo.getUsername()); + detailLoggerContext.setOperateType(OperateTypeEnum.DELETE.getValue()); + detailLoggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "删除福利档案-其他福利明细")); + detailLoggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "删除福利档案-其他福利明细") + ":" + taxAgentInfo.getName() + "-" + empInfo.getUsername()); + detailLoggerContext.setNewValues(otherTargetDetail); + SalaryElogConfig.siArchivesLoggerTemplate.write(detailLoggerContext); + } + }); + } + } + + //新增社保、公积金、其他福利档案、福利档案基础信息 + private List addNewInsuranceBaseInfo(List baseInfoPOList, Long currentEmployeeId) { + try { + List socialList = new ArrayList<>(); + List fundList = new ArrayList<>(); + List otherList = new ArrayList<>(); + for (InsuranceArchivesBaseInfoPO baseInfoPO : baseInfoPOList) { + InsuranceArchivesSocialSchemePO insuranceArchivesSocialSchemePO = new InsuranceArchivesSocialSchemePO(); + insuranceArchivesSocialSchemePO.setTenantKey(""); + insuranceArchivesSocialSchemePO.setWelfareType(WelfareTypeEnum.SOCIAL_SECURITY.getValue()); + insuranceArchivesSocialSchemePO.setPaymentOrganization(baseInfoPO.getPaymentOrganization()); + insuranceArchivesSocialSchemePO.setNonPayment(NonPaymentEnum.YES.getValue()); + insuranceArchivesSocialSchemePO.setCreator(currentEmployeeId); + insuranceArchivesSocialSchemePO.setCreateTime(new Date()); + insuranceArchivesSocialSchemePO.setUpdateTime(new Date()); + insuranceArchivesSocialSchemePO.setDeleteType(DeleteTypeEnum.NOT_DELETED.getValue()); + insuranceArchivesSocialSchemePO.setEmployeeId(baseInfoPO.getEmployeeId()); + socialList.add(insuranceArchivesSocialSchemePO); + + InsuranceArchivesFundSchemePO insuranceArchivesFundSchemePO = new InsuranceArchivesFundSchemePO(); + insuranceArchivesFundSchemePO.setTenantKey(""); + insuranceArchivesFundSchemePO.setWelfareType(WelfareTypeEnum.ACCUMULATION_FUND.getValue()); + insuranceArchivesFundSchemePO.setPaymentOrganization(baseInfoPO.getPaymentOrganization()); + insuranceArchivesFundSchemePO.setNonPayment(NonPaymentEnum.YES.getValue()); + insuranceArchivesFundSchemePO.setCreator(currentEmployeeId); + insuranceArchivesFundSchemePO.setCreateTime(new Date()); + insuranceArchivesFundSchemePO.setUpdateTime(new Date()); + insuranceArchivesFundSchemePO.setDeleteType(DeleteTypeEnum.NOT_DELETED.getValue()); + insuranceArchivesFundSchemePO.setEmployeeId(baseInfoPO.getEmployeeId()); + fundList.add(insuranceArchivesFundSchemePO); + + InsuranceArchivesOtherSchemePO insuranceArchivesOtherSchemePO = new InsuranceArchivesOtherSchemePO(); + insuranceArchivesOtherSchemePO.setTenantKey(""); + insuranceArchivesOtherSchemePO.setWelfareType(WelfareTypeEnum.OTHER.getValue()); + insuranceArchivesOtherSchemePO.setPaymentOrganization(baseInfoPO.getPaymentOrganization()); + insuranceArchivesOtherSchemePO.setNonPayment(NonPaymentEnum.YES.getValue()); + insuranceArchivesOtherSchemePO.setCreator(currentEmployeeId); + insuranceArchivesOtherSchemePO.setCreateTime(new Date()); + insuranceArchivesOtherSchemePO.setUpdateTime(new Date()); + insuranceArchivesOtherSchemePO.setDeleteType(DeleteTypeEnum.NOT_DELETED.getValue()); + insuranceArchivesOtherSchemePO.setEmployeeId(baseInfoPO.getEmployeeId()); + otherList.add(insuranceArchivesOtherSchemePO); + + } + //导入社保档案 + if (CollectionUtils.isNotEmpty(socialList)) { + log.info("新增社保档案数量:{}", socialList.size()); + //根据人员id和个税扣缴义务人id删除对应档案 + socialList.forEach(getSocialSchemeMapper()::deleteByEmployeeIdAndPayOrg); + log.info("删除历史社保档案"); + if (isLog) { + log.info("新增社保档案明细:{}", socialList); + } + List> partition = Lists.partition(socialList, 100); + partition.forEach(getSocialSchemeMapper()::batchSave); + log.info("新增社保档案成功"); + } + //导入公积金档案 + if (CollectionUtils.isNotEmpty(fundList)) { + log.info("新增公积金档案数量:{}", fundList.size()); + //根据人员id和个税扣缴义务人id删除对应档案 + fundList.forEach(getFundSchemeMapper()::deleteByEmployeeIdAndPayOrg); + log.info("删除历史公积金档案"); + if (isLog) { + log.info("新增公积金档案明细:{}", fundList); + } + List> partition = Lists.partition(fundList, 100); + partition.forEach(getFundSchemeMapper()::batchSave); + log.info("新增公积金档案成功"); + } + //导入其他福利档案 + if (CollectionUtils.isNotEmpty(otherList)) { + log.info("新增其他福利档案数量:{}", otherList.size()); + //根据人员id和个税扣缴义务人id删除对应档案 + otherList.forEach(getOtherSchemeMapper()::deleteByEmployeeIdAndPayOrg); + log.info("删除历史其他福利档案"); + if (isLog) { + log.info("新增其他福利档案明细:{}", otherList); + } + List> partition = Lists.partition(otherList, 100); + partition.forEach(getOtherSchemeMapper()::batchSave); + log.info("新增其他福利档案成功"); + } + //导入福利档案基础信息 + if (CollectionUtils.isNotEmpty(baseInfoPOList)) { + //根据人员id和个税扣缴义务人id删除对应档案 + baseInfoPOList.forEach(getInsuranceBaseInfoMapper()::deleteByEmployeeIdAndPayOrg); + log.info("删除历史福利档案基础信息"); + // //分批批量删除 + List baseInfoEmployeeIds = baseInfoPOList.stream().map(InsuranceArchivesBaseInfoPO::getEmployeeId).collect(Collectors.toList()); + + //查询目标人员的剩余的福利档案基础信息(社保、公积金、其他福利档案id) + List moreBaseInfoPOS = new ArrayList<>(); + log.info("查询目标人员的剩余的福利档案基础信息(社保、公积金、其他福利档案id)"); + List> partitionInfo = Lists.partition((List) baseInfoEmployeeIds, 1000); + partitionInfo.forEach(part -> moreBaseInfoPOS.addAll( + getInsuranceBaseInfoMapper().getInsuranceBaseInfoListByInsuranceDetail(part))); + + List newInsuranceArchivesBaseInfoList = new ArrayList<>(); + //设置社保、公积金、其他福利档案id + log.info("设置社保、公积金、其他福利档案id"); + for (InsuranceArchivesBaseInfoPO po : baseInfoPOList) { + InsuranceArchivesBaseInfoPO moreBaseInfo = moreBaseInfoPOS.stream().filter(s -> Objects.equals(s.getEmployeeId(), po.getEmployeeId()) && Objects.equals(s.getPaymentOrganization(), po.getPaymentOrganization())).findFirst().orElse(null); + po.setSocialArchivesId(moreBaseInfo.getSocialArchivesId()); + po.setFundArchivesId(moreBaseInfo.getFundArchivesId()); + po.setOtherArchivesId(moreBaseInfo.getOtherArchivesId()); + newInsuranceArchivesBaseInfoList.add(po); + } + log.info("福利档案基础信息分批批量入库,入库数量:{}", newInsuranceArchivesBaseInfoList.size()); + //分批批量入库 + if (isLog) { + log.info("新增福利档案基础信息明细:{}", newInsuranceArchivesBaseInfoList); + } + List> partition = Lists.partition(newInsuranceArchivesBaseInfoList, 100); + partition.forEach(getInsuranceBaseInfoMapper()::batchSave); + } + + return baseInfoPOList; + } catch (Exception e) { + log.info("新增福利档案出错:{}", e.getMessage(), e); + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "福利档案新增失败")); + } + } + /** + * 分批更新福利档案基础信息的runStatus + * @param baseInfoPOList + * @param runStatus + */ + private void updateInsuranceBaseInfoRunStatus(List baseInfoPOList, String runStatus) { + if (CollectionUtils.isNotEmpty(baseInfoPOList)) { + List idList = baseInfoPOList.stream().map(InsuranceArchivesBaseInfoPO::getId).collect(Collectors.toList()); + List> partition = Lists.partition(idList, 999); + partition.forEach( + part -> { + InsuranceArchivesBaseInfoPO baseInfoPO = new InsuranceArchivesBaseInfoPO(); + baseInfoPO.setIds(part); + baseInfoPO.setRunStatus(runStatus); + getInsuranceBaseInfoMapper().updateRunStatusByIds(baseInfoPO); + } + + ); + } + } + + @Override + public Map getSearchCondition(Map param) { + Map apidatas = new HashMap<>(16); +// apidatas = siArchivesBiz.getSearchCondition(user); + apidatas = getSearchCondition(); + return apidatas; + } + + @Override + public XSSFWorkbook export(InsuranceArchivesListParam param) { + InsuranceArchivesListParam request = InsuranceArchivesListParam.builder().build(); + if (param.getHireDate() != null && param.getHireDate().length == 2) { + param.setHiredateStart(param.getHireDate()[0]); + param.setHiredateEnd(param.getHireDate()[1]); + } + if (param.getDimissionDate() != null && param.getDimissionDate().length == 2) { + param.setDimissionDateStart(param.getDimissionDate()[0]); + param.setDimissionDateEnd(param.getDimissionDate()[1]); + } + if (Objects.equals("fromQuickSearch", param.getDataSource())) { +// request.setStatuses(param.getStatuses()); + if (StringUtils.isNotBlank(param.getStatusesStr())) { + request.setStatuses(Arrays.stream(param.getStatusesStr().split(",")).map(String::new).collect(Collectors.toList())); + } + request.setKeyword(param.getUserName()); + } else { + request = param; + } + request.setPageSize(null); + request.setStartNum(null); + request.setFilterType(AuthFilterTypeEnum.QUERY_DATA); + List insuranceArchivesEmployeePOS = listPageEmployeePOS(request); + if (insuranceArchivesEmployeePOS == null) { + insuranceArchivesEmployeePOS = new ArrayList<>(); + } + List> records = buildTableData(insuranceArchivesEmployeePOS); + List columns = buildWeaTableColumns(insuranceArchivesEmployeePOS); + + //工作簿list + List> excelSheetData = new ArrayList<>(); + + //工作簿名称 + String sheetName = SalaryI18nUtil.getI18nLabel(85368, "社保福利档案"); //表头 + //表头 + excelSheetData.add(Arrays.asList(columns.stream().map(WeaTableColumn::getText).toArray(String[]::new))); + //工作簿数据 + List> rows = new LinkedList<>(); + for (Map recordData : records) { + List row = new LinkedList<>(); + for (WeaTableColumn column : columns) { + row.add(recordData.get(column.getColumn())); + } + rows.add(row); + } + excelSheetData.addAll(rows); + return ExcelUtil.genWorkbookV2(excelSheetData, sheetName); + + } + + @Override + public List listPageEmployeePOS(InsuranceArchivesListParam param) { + List list = getSocialSchemeMapper().queryEmployeeList(param); + list = getAuthService(user).auth(list, param.getFilterType(), InsuranceArchivesEmployeePO.class); + return list; + } + + /** + * 获取福利档案各tab总人数 + */ + @Override + public Map queryInsuranceTabTotal() { + // tab页签数量 + Map result = new HashMap<>(); + + List list = getInsuranceBaseInfoMapper().listAll(); + list = getAuthService(user).auth(list, AuthFilterTypeEnum.QUERY_DATA, InsuranceArchivesBaseInfoPO.class); + + long stayAddTotal = 0L; + long payTotal = 0L; + long stayDelTotal = 0L; + long stopTotal = 0L; + long extTotal = 0L; + + for (InsuranceArchivesBaseInfoPO baseInfoPO : list) { + Integer employeeType = baseInfoPO.getEmployeeType(); + if (employeeType == null || employeeType == 0) { + if (baseInfoPO.getRunStatus().equals(EmployeeStatusEnum.STAY_ADD.getValue())) { + stayAddTotal += 1; + } else if (baseInfoPO.getRunStatus().equals(EmployeeStatusEnum.PAYING.getValue()) || baseInfoPO.getRunStatus().equals(EmployeeStatusEnum.STAY_DEL.getValue())) { + payTotal += 1; + if (baseInfoPO.getRunStatus().equals(EmployeeStatusEnum.STAY_DEL.getValue())) { + stayDelTotal += 1; + } + } else if (baseInfoPO.getRunStatus().equals(EmployeeStatusEnum.STOP_PAYMENT_FROM_ADD.getValue()) || baseInfoPO.getRunStatus().equals(EmployeeStatusEnum.STOP_PAYMENT_FROM_DEL.getValue())) { + stopTotal += 1; + } + } else { + extTotal += 1; + } + + } + + result.put("stayAdd", stayAddTotal); + result.put("paying", payTotal); + result.put("stayDel", stayDelTotal); + result.put("stopPay", stopTotal); + result.put("ext", extTotal); + return result; + } + + /** + * 批量变更档案列表的runStatus,目前仅在待增员tab中删除待办使用,后边其他方调用时需修改操作日志记录 + */ + @Override + public void updateRunStatus(InsuranceArchivesBaseInfoPO po) { + getInsuranceBaseInfoMapper().updateRunStatusByIds(po); + //记录操作日志 + List targetPOList = getInsuranceBaseInfoMapper().listByIds(po.getIds()); + if (targetPOList != null && targetPOList.size() > 0) { + targetPOList.forEach(targetPO -> { + DataCollectionEmployee empInfo = getEmployMapper().getEmployeeById(targetPO.getEmployeeId()); + TaxAgentPO taxAgentInfo = getTaxAgentMapper().getById(targetPO.getPaymentOrganization()); + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(targetPO.getId())); + loggerContext.setTargetName(taxAgentInfo.getName() + "-" + empInfo.getUsername()); + loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "待增员档案-删除待办")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "待增员档案-删除待办") + ": " + taxAgentInfo.getName() + "-" + empInfo.getUsername()); +// loggerContext.setNewValues(targetPO); + SalaryElogConfig.siArchivesLoggerTemplate.write(loggerContext); + }); + } + } + + @Override + public void cancelStopPayment(Collection ids) { + if (CollectionUtils.isEmpty(ids)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(145969, "没有可以操作的记录")); + } + List pos = getInsuranceBaseInfoMapper().listByIds(ids); + pos = pos.stream().filter(f -> f.getRunStatus().equals(EmployeeStatusEnum.STOP_PAYMENT_FROM_ADD.getValue()) + ||f.getRunStatus().equals(EmployeeStatusEnum.STOP_PAYMENT_FROM_DEL.getValue())).collect(Collectors.toList()); + pos = getAuthService(user).auth(pos, AuthFilterTypeEnum.ADMIN_DATA, InsuranceArchivesBaseInfoPO.class); + + if (CollectionUtil.isEmpty(pos)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(116196, "不在当前个税扣缴义人的人员范围中,不可取消停缴")); + } + + List stayAddIds = new ArrayList<>(); + List stayDelIds = new ArrayList<>(); + + for(InsuranceArchivesBaseInfoPO po : pos) { + if (po.getRunStatus().equals(EmployeeStatusEnum.STOP_PAYMENT_FROM_ADD.getValue())) { + //来自待增员的停缴->待增员 + stayAddIds.add(po.getId()); + } else if (po.getRunStatus().equals(EmployeeStatusEnum.STOP_PAYMENT_FROM_DEL.getValue())) { + //来自待减员的停缴->待减员 + stayDelIds.add(po.getId()); + } + } + + //更新调整为待增员的数据 + InsuranceArchivesBaseInfoPO stayAddPO = InsuranceArchivesBaseInfoPO.builder().ids(stayAddIds).runStatus(EmployeeStatusEnum.STAY_ADD.getValue()).build(); + if (stayAddPO.getIds().size() > 0) { + getInsuranceBaseInfoMapper().updateRunStatusByIds(stayAddPO); + } + //更新调整为待减员的数据 + InsuranceArchivesBaseInfoPO stayDelPO = InsuranceArchivesBaseInfoPO.builder().ids(stayDelIds).runStatus(EmployeeStatusEnum.STAY_DEL.getValue()).build(); + if (stayDelPO.getIds().size() > 0) { + getInsuranceBaseInfoMapper().updateRunStatusByIds(stayDelPO); + } + //记录操作日志 + Map oldBaseInfoMap = SalaryEntityUtil.convert2Map(pos, e -> e.getPaymentOrganization() + "-" + e.getEmployeeId()); + List newPos = getInsuranceBaseInfoMapper().listByIds(ids); + newPos.forEach(targetPO -> { + DataCollectionEmployee empInfo = getEmployMapper().getEmployeeById(targetPO.getEmployeeId()); + TaxAgentPO taxAgentInfo = getTaxAgentMapper().getById(targetPO.getPaymentOrganization()); + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(targetPO.getId())); + loggerContext.setTargetName(taxAgentInfo.getName() + "-" + empInfo.getUsername()); + loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "停缴档案-取消停缴")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "停缴档案-取消停缴") + ": " + taxAgentInfo.getName() + "-" + empInfo.getUsername()); + loggerContext.setOldValues(oldBaseInfoMap.get(targetPO.getPaymentOrganization() + "-" + targetPO.getEmployeeId())); + loggerContext.setNewValues(targetPO); + SalaryElogConfig.siArchivesLoggerTemplate.write(loggerContext); + }); + } + + /** + * 批量减员 + */ + @Override + public Map stayDelToStop(Collection ids) { + + if (CollectionUtils.isEmpty(ids)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(145969, "没有可以操作的记录")); + } + List baseInfoPOList = getInsuranceBaseInfoMapper().listByIds(ids); + //分别新建福利档案基础信息相关的社保、公积金、其他福利档案列表 + List socialList = new ArrayList<>(); + List fundList = new ArrayList<>(); + List otherList = new ArrayList<>(); + //新建最终可以进行减员的福利档案基础信息id列表 + List toStopBaseInfoIdList = new ArrayList<>(); + //新建最终不可以进行减员的福利档案基础信息id列表 + List noStopBaseInfoIds = new ArrayList<>(); + //获取待处理的福利档案基础信息id列表 + List baseInfoIds = baseInfoPOList.stream().map(InsuranceArchivesBaseInfoPO::getId).collect(Collectors.toList()); + //设置最后缴纳月的比较月份 + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM"); + String todayMonth = simpleDateFormat.format(new Date()); + //分别获取福利档案基础信息相关的社保、公积金、其他福利档案id列表 + List socialIds = baseInfoPOList.stream().map(InsuranceArchivesBaseInfoPO::getSocialArchivesId).collect(Collectors.toList()); + List fundIds = baseInfoPOList.stream().map(InsuranceArchivesBaseInfoPO::getFundArchivesId).collect(Collectors.toList()); + List otherIds = baseInfoPOList.stream().map(InsuranceArchivesBaseInfoPO::getOtherArchivesId).collect(Collectors.toList()); + + List toStopSocialIds = new ArrayList<>(); + List toStopFundIds = new ArrayList<>(); + List toStopOtherIds = new ArrayList<>(); + //获取可进行减员的社保档案相关人员数据 + if (socialIds.size() > 0) { + //获取社保档案 + socialList = getSocialSchemeMapper().getSocialById(socialIds); + //筛选可减员的社保档案相关信息 + toStopSocialIds = socialList.stream().filter(f-> f.getSocialSchemeId() == null || (f.getSocialEndTime() != null && f.getSocialEndTime().length() > 0)) + .map(InsuranceArchivesSocialSchemePO::getId).collect(Collectors.toList()); + + List finalToStopSocialIds = toStopSocialIds; + noStopBaseInfoIds = baseInfoPOList.stream().filter(f -> !finalToStopSocialIds.contains(f.getSocialArchivesId())).map(InsuranceArchivesBaseInfoPO::getId).collect(Collectors.toList()); + + } + if (fundIds.size() > 0) { + fundList = getFundSchemeMapper().getFundById(fundIds); + + toStopFundIds = fundList.stream().filter(f->f.getFundSchemeId() == null || (f.getFundEndTime() != null && f.getFundEndTime().length() > 0)) + .map(InsuranceArchivesFundSchemePO::getId).collect(Collectors.toList()); + List finalToStopFundIds = toStopFundIds; + noStopBaseInfoIds = (List) CollectionUtils.union(noStopBaseInfoIds, baseInfoPOList.stream().filter(f -> !finalToStopFundIds.contains(f.getFundArchivesId())).map(InsuranceArchivesBaseInfoPO::getId).collect(Collectors.toList())); + + } + if (otherIds.size() > 0) { + otherList = getOtherSchemeMapper().getOtherById(otherIds); + + toStopOtherIds= otherList.stream().filter(f->f.getOtherSchemeId() == null || (f.getOtherEndTime() != null && f.getOtherEndTime().length() > 0)) + .map(InsuranceArchivesOtherSchemePO::getId).collect(Collectors.toList()); + List finalToStopOtherIds = toStopOtherIds; + noStopBaseInfoIds = (List) CollectionUtils.union(noStopBaseInfoIds, baseInfoPOList.stream().filter(f -> !finalToStopOtherIds.contains(f.getOtherArchivesId())).map(InsuranceArchivesBaseInfoPO::getId).collect(Collectors.toList())); + + } + //获取最终基础信息表中的可减员数据 + if (noStopBaseInfoIds.size() == 0) { + //社保、公积金、其他福利档案的可减员的人员信息与入参中的人员信息一致时 + toStopBaseInfoIdList = baseInfoIds; + } else { + //与最终不可减员的baseInfoId信息做差集 + toStopBaseInfoIdList = (List) CollectionUtils.subtract(baseInfoIds, noStopBaseInfoIds); + } + //进行减员操作 + if (toStopBaseInfoIdList.size() > 0) { + getInsuranceBaseInfoMapper().updateRunStatusByIds(InsuranceArchivesBaseInfoPO.builder() + .ids(toStopBaseInfoIdList).runStatus(EmployeeStatusEnum.STOP_PAYMENT_FROM_DEL.getValue()).build()); + //记录操作日志 + toStopBaseInfoIdList.forEach(f -> { + InsuranceArchivesBaseInfoPO targetPO = getInsuranceBaseInfoMapper().getById(f); + if (targetPO != null) { + DataCollectionEmployee empInfo = getEmployMapper().getEmployeeById(targetPO.getEmployeeId()); + TaxAgentPO taxAgentInfo = getTaxAgentMapper().getById(targetPO.getPaymentOrganization()); + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(targetPO.getId())); + loggerContext.setTargetName(taxAgentInfo.getName() + "-" + empInfo.getUsername()); + loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "福利档案减员")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "停缴一名在缴员工") + ": " + taxAgentInfo.getName() + "-" + empInfo.getUsername()); + loggerContext.setNewValues(targetPO); + SalaryElogConfig.siArchivesLoggerTemplate.write(loggerContext); + } + }); + } + + Map resultMap = new HashMap<>(2); + String resultMsg = "操作成功"; + String resultType = "success"; + // 批量设为定薪提示 + + //输出结果,此处需区分单一减员和批量减员 + if (baseInfoPOList.size() == toStopBaseInfoIdList.size()) { + //减员成功 + if (baseInfoPOList.size() == 1) { + resultMsg = "减员成功"; + + } else { + resultMsg = "批量减员成功"; + + } + } else { + //减员失败 + resultType = "fail"; + if (baseInfoPOList.size() == 1) { + resultMsg = "减员失败,失败原因:最后缴纳月数据未正常维护"; + + } else { + resultMsg = "部分或全部失败:【共提交减员数据" + + baseInfoIds.size() + +"条,成功" + toStopBaseInfoIdList.size() + +"条,失败" + noStopBaseInfoIds.size() + +"条,失败原因:最后缴纳月数据未正常维护】"; + + } + } + resultMap.put("type", resultType); + resultMap.put("msg", resultMsg); + return resultMap; + } + + @Override + public Map stopWithoutLimit(Collection ids, String yearMonth, String fundEndYearMonth, String otherEndYearMonth) { + + if (CollectionUtils.isEmpty(ids)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(145969, "没有可以操作的记录")); + } + List baseInfoPOList = getInsuranceBaseInfoMapper().listByIds(ids); + + //分别新建福利档案基础信息相关的社保、公积金、其他福利档案列表 + List socialList = new ArrayList<>(); + List fundList = new ArrayList<>(); + List otherList = new ArrayList<>(); + //获取待处理的福利档案基础信息id列表 + List baseInfoIds = baseInfoPOList.stream().map(InsuranceArchivesBaseInfoPO::getId).collect(Collectors.toList()); + //分别获取福利档案基础信息相关的社保、公积金、其他福利档案id列表 + List socialIds = baseInfoPOList.stream().map(InsuranceArchivesBaseInfoPO::getSocialArchivesId).collect(Collectors.toList()); + List fundIds = baseInfoPOList.stream().map(InsuranceArchivesBaseInfoPO::getFundArchivesId).collect(Collectors.toList()); + List otherIds = baseInfoPOList.stream().map(InsuranceArchivesBaseInfoPO::getOtherArchivesId).collect(Collectors.toList()); + //进行减员操作 + if (baseInfoIds.size() > 0) { + getInsuranceBaseInfoMapper().updateRunStatusByIds(InsuranceArchivesBaseInfoPO.builder() + .ids(baseInfoIds).runStatus(EmployeeStatusEnum.STOP_PAYMENT_FROM_DEL.getValue()).build()); + String socialEndYearMonth = yearMonth; + fundEndYearMonth = StringUtils.isBlank(fundEndYearMonth) ? yearMonth : fundEndYearMonth; + otherEndYearMonth = StringUtils.isBlank(otherEndYearMonth) ? yearMonth : otherEndYearMonth; + + getSocialSchemeMapper().batchUpdateEndTime(socialIds, socialEndYearMonth); + getFundSchemeMapper().batchUpdateEndTime(fundIds, fundEndYearMonth); + getOtherSchemeMapper().batchUpdateEndTime(otherIds, otherEndYearMonth); + } + + + Map resultMap = new HashMap<>(2); + String resultMsg = "操作成功"; + String resultType = "success"; + + resultMap.put("type", resultType); + resultMap.put("msg", resultMsg); + return resultMap; + } + + /** + * 全量减员 + */ + @Override + public Map allStayDelToStop() { + List allBaseInfoList = getInsuranceBaseInfoMapper().listAll(); + allBaseInfoList = getAuthService(user).auth(allBaseInfoList, AuthFilterTypeEnum.ADMIN_DATA, InsuranceArchivesBaseInfoPO.class); + if (allBaseInfoList.size() > 0) { + Collection stayDelIds = allBaseInfoList.stream().filter(f->f.getRunStatus().equals(EmployeeStatusEnum.STAY_DEL.getValue()) + && (f.getEmployeeType() == null || Objects.equals(f.getEmployeeType(), EmployeeTypeEnum.ORGANIZATION.getValue()))) + .map(InsuranceArchivesBaseInfoPO::getId).collect(Collectors.toList()); + if (stayDelIds.size() > 0) { + return stayDelToStop(stayDelIds); + } else { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(145969, "没有可以操作的记录")); + } + } else { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(145969, "没有可以操作的记录")); + } + } + + /** + * 批量增员 + */ + @Override + public Map stayAddToPay(Collection ids) { + if (CollectionUtils.isEmpty(ids)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(145969, "没有可以操作的记录")); + } + List baseInfoPOList = new ArrayList<>(); + + List> partitionInfo = Lists.partition((List) ids, 100); + partitionInfo.forEach(part -> baseInfoPOList.addAll( + getInsuranceBaseInfoMapper().listByIds(part))); + //分别新建福利档案基础信息相关的社保、公积金、其他福利档案列表 + List socialList = new ArrayList<>(); + List fundList = new ArrayList<>(); + List otherList = new ArrayList<>(); + //新建最终可以进行增员的福利档案基础信息id列表 + List toPayBaseInfoIdList = new ArrayList<>(); + //新建最终不可以进行增员的福利档案基础信息id列表 + List noPayBaseInfoIds = new ArrayList<>(); + //获取待处理的福利档案基础信息id列表 + List baseInfoIds = baseInfoPOList.stream().map(InsuranceArchivesBaseInfoPO::getId).collect(Collectors.toList()); + //设置最后缴纳月的比较月份 + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM"); + String todayMonth = simpleDateFormat.format(new Date()); + //分别获取福利档案基础信息相关的社保、公积金、其他福利档案id列表 + List socialIds = baseInfoPOList.stream().map(InsuranceArchivesBaseInfoPO::getSocialArchivesId).collect(Collectors.toList()); + List fundIds = baseInfoPOList.stream().map(InsuranceArchivesBaseInfoPO::getFundArchivesId).collect(Collectors.toList()); + List otherIds = baseInfoPOList.stream().map(InsuranceArchivesBaseInfoPO::getOtherArchivesId).collect(Collectors.toList()); + + List toStopSocialIds = new ArrayList<>(); + List toStopFundIds = new ArrayList<>(); + List toStopOtherIds = new ArrayList<>(); + //获取可进行增员的社保档案相关人员数据 + if (socialIds.size() > 0) { + //获取社保档案 + List> partitionSocial = Lists.partition((List) socialIds, 100); + partitionSocial.forEach(part -> socialList.addAll( + getSocialSchemeMapper().getSocialById(part))); + + //筛选可增员的社保档案相关人员信息 + toStopSocialIds = socialList.stream().filter(f-> + { + boolean flag = true; + if (f.getSocialStartTime() == null || f.getSocialStartTime().length() == 0 || f.getSocialSchemeId() == null) { + flag = false; + } + if (f.getSocialEndTime() != null && f.getSocialEndTime().length() > 0 && (f.getSocialEndTime().compareTo(todayMonth)) <= 0) { + flag = false; + } + return flag; + }) + .map(InsuranceArchivesSocialSchemePO::getId).collect(Collectors.toList()); + List finalToStopSocialIds = toStopSocialIds; + toPayBaseInfoIdList = baseInfoPOList.stream().filter(f -> finalToStopSocialIds.contains(f.getSocialArchivesId())).map(InsuranceArchivesBaseInfoPO::getId).collect(Collectors.toList()); + + + } + if (fundIds.size() > 0) { + List> partitionFund = Lists.partition((List) fundIds, 100); + partitionFund.forEach(part -> fundList.addAll( + getFundSchemeMapper().getFundById(part))); + + toStopFundIds = fundList.stream().filter(f-> + { + boolean flag = true; + if (f.getFundStartTime() == null || f.getFundStartTime().length() == 0 || f.getFundSchemeId() == null) { + flag = false; + } + if (f.getFundEndTime() != null && f.getFundEndTime().length() > 0 && (f.getFundEndTime().compareTo(todayMonth)) <= 0) { + flag = false; + } + return flag; + }) + .map(InsuranceArchivesFundSchemePO::getId).collect(Collectors.toList()); + List finalToStopFundIds = toStopFundIds; + toPayBaseInfoIdList = (List) CollectionUtils.union(toPayBaseInfoIdList, baseInfoPOList.stream().filter(f -> finalToStopFundIds.contains(f.getFundArchivesId())).map(InsuranceArchivesBaseInfoPO::getId).collect(Collectors.toList())); + + } + if (otherIds.size() > 0) { + List> partitionOther = Lists.partition((List) otherIds, 100); + partitionOther.forEach(part -> otherList.addAll( + getOtherSchemeMapper().getOtherById(part))); + + toStopOtherIds = otherList.stream().filter(f-> + { + boolean flag = true; + if (f.getOtherStartTime() == null || f.getOtherStartTime().length() == 0 || f.getOtherSchemeId() == null) { + flag = false; + } + if (f.getOtherEndTime() != null && f.getOtherEndTime().length() > 0 && (f.getOtherEndTime().compareTo(todayMonth)) <= 0) { + flag = false; + } + return flag; + }) + .map(InsuranceArchivesOtherSchemePO::getId).collect(Collectors.toList()); + List finalToStopOtherIds = toStopOtherIds; + toPayBaseInfoIdList = (List) CollectionUtils.union(toPayBaseInfoIdList, baseInfoPOList.stream().filter(f -> finalToStopOtherIds.contains(f.getOtherArchivesId())).map(InsuranceArchivesBaseInfoPO::getId).collect(Collectors.toList())); + + } + //获取最终基础信息表中的不可增员数据 + noPayBaseInfoIds = (List) CollectionUtils.subtract(baseInfoIds, toPayBaseInfoIdList); + + //其他的个税扣缴义务人下的在缴员工中存在该员工,在缴员工未进入停缴员工时,不可进行增员 + + //进行增员操作 + if (toPayBaseInfoIdList.size() > 0) { + List> partitionToPay = Lists.partition((List) toPayBaseInfoIdList, 100); + partitionToPay.forEach(part -> { + getInsuranceBaseInfoMapper().updateRunStatusByIds(InsuranceArchivesBaseInfoPO.builder() + .ids(part).runStatus(EmployeeStatusEnum.PAYING.getValue()).build()); + }); + + //记录操作日志 + toPayBaseInfoIdList.forEach(f -> { + InsuranceArchivesBaseInfoPO targetPO = getInsuranceBaseInfoMapper().getById(f); + if (targetPO != null) { + DataCollectionEmployee empInfo = getEmployMapper().getEmployeeById(targetPO.getEmployeeId()); + TaxAgentPO taxAgentInfo = getTaxAgentMapper().getById(targetPO.getPaymentOrganization()); + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(targetPO.getId())); + loggerContext.setTargetName(taxAgentInfo.getName() + "-" + empInfo.getUsername()); + loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "福利档案增员")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "增加一名在缴员工") + ": " + taxAgentInfo.getName() + "-" + empInfo.getUsername()); + loggerContext.setNewValues(targetPO); + SalaryElogConfig.siArchivesLoggerTemplate.write(loggerContext); + } + }); + } + + Map resultMap = new HashMap<>(2); + String resultMsg = "操作成功"; + String resultType = "success"; + // 批量设为定薪提示 + + //输出结果,此处需区分单一增员和批量增员 + if (baseInfoPOList.size() == toPayBaseInfoIdList.size()) { + //增员成功 + if (baseInfoPOList.size() == 1) { + resultMsg = "增员成功"; + + } else { + resultMsg = "批量增员成功"; + } + } else { + //增员失败 + resultType = "fail"; + if (baseInfoPOList.size() == 1) { + resultMsg = "增员失败,失败原因:起始缴纳月/福利方案数据未正常维护"; + } else { + resultMsg = "部分或全部失败:【共提交增员数据" + + baseInfoIds.size() + +"条,成功" + toPayBaseInfoIdList.size() + +"条,失败" + noPayBaseInfoIds.size() + +"条,失败原因:起始缴纳月/福利方案数据未正常维护】"; + + } + } + resultMap.put("type", resultType); + resultMap.put("msg", resultMsg); + return resultMap; + } + + /** + * 全量增员 + */ + @Override + public Map allStayAddToPay() { + List allBaseInfoList = getInsuranceBaseInfoMapper().listAll(); + allBaseInfoList = getAuthService(user).auth(allBaseInfoList, AuthFilterTypeEnum.ADMIN_DATA, InsuranceArchivesBaseInfoPO.class); + if (allBaseInfoList.size() > 0) { + Collection stayAddIds = allBaseInfoList.stream().filter(f->f.getRunStatus().equals(EmployeeStatusEnum.STAY_ADD.getValue()) + && (f.getEmployeeType() == null || Objects.equals(f.getEmployeeType(), EmployeeTypeEnum.ORGANIZATION.getValue()))) + .map(InsuranceArchivesBaseInfoPO::getId).collect(Collectors.toList()); + if (stayAddIds.size() > 0) { + return stayAddToPay(stayAddIds); + } else { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(145969, "没有可以操作的记录")); + } + } else { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(145969, "没有可以操作的记录")); + } + } + + /** + * 待减员页面的删除待办 + */ + @Override + public void cancelStayDel(InsuranceArchivesBaseInfoPO insuranceArchivesBaseInfoPO) { + + if (insuranceArchivesBaseInfoPO.getIds() == null || StringUtils.isBlank(insuranceArchivesBaseInfoPO.getRunStatus())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(84026, "参数错误")); + } + if (insuranceArchivesBaseInfoPO.getRunStatus().equals(EmployeeStatusEnum.STAY_DEL.getValue())) { + List> baseInfoIdsPartition = Lists.partition((List) insuranceArchivesBaseInfoPO.getIds(), 100); + List nowList = new ArrayList<>(); + for (List part : baseInfoIdsPartition) { + nowList.addAll(getInsuranceBaseInfoMapper().listByIds(part)); + } + //判断当前被操作人员是否都在对应的个税扣缴义务人下 + nowList = getAuthService(user).auth(nowList, AuthFilterTypeEnum.ADMIN_DATA, InsuranceArchivesBaseInfoPO.class); + if (CollectionUtil.isEmpty(nowList)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(116196, "个税扣缴义务人不存在或不在权限范围内,删除失败!")); + } + //置空社保、公积金、其他福利档案的最后缴纳月信息,并将福利档案基础信息表的状态置为“正在缴纳” + List socialIds = nowList.stream() + .map(InsuranceArchivesBaseInfoPO::getSocialArchivesId).collect(Collectors.toList()); + List fundIds = nowList.stream() + .map(InsuranceArchivesBaseInfoPO::getFundArchivesId).collect(Collectors.toList()); + List otherIds = nowList.stream() + .map(InsuranceArchivesBaseInfoPO::getOtherArchivesId).collect(Collectors.toList()); + + List> socialIdsPartition = Lists.partition(socialIds, 100); + socialIdsPartition.forEach(getSocialSchemeMapper()::batchUpdateEndTimeToNull); + + List> fundIdsPartition = Lists.partition(fundIds, 100); + fundIdsPartition.forEach(getFundSchemeMapper()::batchUpdateEndTimeToNull); + + List> otherIdsPartition = Lists.partition(otherIds, 100); + otherIdsPartition.forEach(getOtherSchemeMapper()::batchUpdateEndTimeToNull); + + baseInfoIdsPartition.forEach(part -> { + getInsuranceBaseInfoMapper().updateRunStatusByIds(InsuranceArchivesBaseInfoPO.builder() + .ids(part) + .runStatus(EmployeeStatusEnum.PAYING.getValue()) + .build()); + }); + nowList.forEach(targetPO -> { + DataCollectionEmployee empInfo = getEmployMapper().getEmployeeById(targetPO.getEmployeeId()); + TaxAgentPO taxAgentInfo = getTaxAgentMapper().getById(targetPO.getPaymentOrganization()); + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(targetPO.getId())); + loggerContext.setTargetName(taxAgentInfo.getName() + "-" + empInfo.getUsername()); + loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "待减员档案-删除待办")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "待减员档案-删除待办") + ": " + taxAgentInfo.getName() + "-" + empInfo.getUsername()); + SalaryElogConfig.siArchivesLoggerTemplate.write(loggerContext); + }); + } + } + + @Override + public PageInfo historyListByEmployeeIdAndOperator(SIArchiveBaseHistoryListParam param) { + +// List adjustHistoryDTOS = siArchivesBiz.getBaseHistoryByEmployeeIdAndOperator(param.getOperator(), param.getEmployeeId()); + List adjustHistoryDTOS = getBaseHistoryByEmployeeIdAndOperator(param.getOperator(), param.getEmployeeId()); + // 分权逻辑 + adjustHistoryDTOS = getAuthService(user).auth(adjustHistoryDTOS, AuthFilterTypeEnum.QUERY_DATA, InsuranceArchivesBaseHistoryDTO.class); + + adjustHistoryDTOS.forEach(f -> { + if (StringUtils.isNotBlank(f.getPaymentScope())) { + if(f.getPaymentScope().equals(PaymentScopeEnum.SCOPE_PERSON.getValue().toString())) { + f.setPaymentScope(SalaryI18nUtil.getI18nLabel(0, "个人")); + } else if(f.getPaymentScope().equals(PaymentScopeEnum.SCOPE_COMPANY.getValue().toString())) { + f.setPaymentScope(SalaryI18nUtil.getI18nLabel(0, "公司")); + } else { + f.setPaymentScope(SalaryI18nUtil.getI18nLabel(0, "个人") + "," + SalaryI18nUtil.getI18nLabel(0, "公司")); + } + } else { + f.setPaymentScope(SalaryI18nUtil.getI18nLabel(0, "个人") + "," + SalaryI18nUtil.getI18nLabel(0, "公司")); + } + }); + + PageInfo listPage = SalaryPageUtil.buildPage(param.getCurrent(), param.getPageSize(), + adjustHistoryDTOS , InsuranceArchivesBaseHistoryDTO.class); + + return listPage; + } + + /** + * 拷贝福利档案到新的个税扣缴义务人并置为在缴 + */ + @Override + public Map copyToPay(Long toCopyTaxAgentId, Long toUpdateTaxAgentId, Long employeeId, String payStartYearMonth) { + if (toCopyTaxAgentId == null || toUpdateTaxAgentId == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "个税扣缴义务人不能为空")); + } + if (employeeId == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "人员id不能为空")); + } + //获取待拷贝的福利档案明细 + InsuranceArchivesBaseInfoPO toCopyBaseInfoPO = getInsuranceBaseInfoMapper().getOneByEmployeeIdAndPayOrg(toCopyTaxAgentId, employeeId); + if(toCopyBaseInfoPO == null){ + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "待复制个税扣缴义务人下该员工不存在福利档案,请检查后重试!")); + } + InsuranceArchivesSocialSchemePO toCopySocialInfo = getSocialSchemeMapper().getOneById(toCopyBaseInfoPO.getSocialArchivesId()); + InsuranceArchivesFundSchemePO toCopyFundInfo = getFundSchemeMapper().getOneById(toCopyBaseInfoPO.getFundArchivesId()); + InsuranceArchivesOtherSchemePO toCopyOtherInfo = getOtherSchemeMapper().getOneById(toCopyBaseInfoPO.getOtherArchivesId()); + //获取待更新的福利档案 + InsuranceArchivesBaseInfoPO toUpdateBaseInfoPO = getInsuranceBaseInfoMapper().getOneByEmployeeIdAndPayOrg(toUpdateTaxAgentId, employeeId); + if(toUpdateBaseInfoPO == null){ + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "待更新个税扣缴义务人下该员工不存在福利档案,请检查后重试!")); + } + InsuranceArchivesSocialSchemePO toUpdateSocialInfo = getSocialSchemeMapper().getOneById(toUpdateBaseInfoPO.getSocialArchivesId()); + InsuranceArchivesFundSchemePO toUpdateFundInfo = getFundSchemeMapper().getOneById(toUpdateBaseInfoPO.getFundArchivesId()); + InsuranceArchivesOtherSchemePO toUpdateOtherInfo = getOtherSchemeMapper().getOneById(toUpdateBaseInfoPO.getOtherArchivesId()); + //设置福利档案基数调整记录数据 + encryptUtil.decrypt(toCopySocialInfo, InsuranceArchivesSocialSchemePO.class); + encryptUtil.decrypt(toUpdateSocialInfo, InsuranceArchivesSocialSchemePO.class); + encryptUtil.decrypt(toCopyFundInfo, InsuranceArchivesFundSchemePO.class); + encryptUtil.decrypt(toUpdateFundInfo, InsuranceArchivesFundSchemePO.class); + encryptUtil.decrypt(toCopyOtherInfo, InsuranceArchivesOtherSchemePO.class); + encryptUtil.decrypt(toUpdateOtherInfo, InsuranceArchivesOtherSchemePO.class); + + InsuranceArchivesBaseHistoryDTO socialAdjustInfo = InsuranceArchivesBaseHistoryDTO.builder() + .adjustAfterSchemeId(toCopySocialInfo.getSocialSchemeId()) + .adjustAfterBaseJson(toCopySocialInfo.getSocialPaymentBaseString()) + .adjustAfterComBaseJson(toCopySocialInfo.getSocialPaymentComBaseString()) + .welfareType(toUpdateSocialInfo.getWelfareType()) + .employeeId(toUpdateSocialInfo.getEmployeeId()) + .paymentOrganization(toUpdateSocialInfo.getPaymentOrganization()) + .adjustBeforeSchemeId(toUpdateSocialInfo.getSocialSchemeId()) + .adjustBeforeBaseJson(toUpdateSocialInfo.getSocialPaymentBaseString()) + .adjustBeforeComBaseJson(toUpdateSocialInfo.getSocialPaymentComBaseString()) + .build(); + InsuranceArchivesBaseHistoryDTO fundAdjustInfo = InsuranceArchivesBaseHistoryDTO.builder() + .adjustAfterSchemeId(toCopyFundInfo.getFundSchemeId()) + .adjustAfterBaseJson(toCopyFundInfo.getFundPaymentBaseString()) + .adjustAfterComBaseJson(toCopyFundInfo.getFundPaymentComBaseString()) + .welfareType(toUpdateFundInfo.getWelfareType()) + .employeeId(toUpdateFundInfo.getEmployeeId()) + .paymentOrganization(toUpdateFundInfo.getPaymentOrganization()) + .adjustBeforeSchemeId(toUpdateFundInfo.getFundSchemeId()) + .adjustBeforeBaseJson(toUpdateFundInfo.getFundPaymentBaseString()) + .adjustBeforeComBaseJson(toUpdateFundInfo.getFundPaymentComBaseString()) + .build(); + InsuranceArchivesBaseHistoryDTO otherAdjustInfo = InsuranceArchivesBaseHistoryDTO.builder() + .adjustAfterSchemeId(toCopyOtherInfo.getOtherSchemeId()) + .adjustAfterBaseJson(toCopyOtherInfo.getOtherPaymentBaseString()) + .adjustAfterComBaseJson(toCopyOtherInfo.getOtherPaymentComBaseString()) + .welfareType(toUpdateOtherInfo.getWelfareType()) + .employeeId(toUpdateOtherInfo.getEmployeeId()) + .paymentOrganization(toUpdateOtherInfo.getPaymentOrganization()) + .adjustBeforeSchemeId(toUpdateOtherInfo.getOtherSchemeId()) + .adjustBeforeBaseJson(toUpdateOtherInfo.getOtherPaymentBaseString()) + .adjustBeforeComBaseJson(toUpdateOtherInfo.getOtherPaymentComBaseString()) + .build(); + List adjustHistoryList = new ArrayList<>(); + adjustHistoryList.addAll(createAdjustInfo(socialAdjustInfo, (long) user.getUID())); + adjustHistoryList.addAll(createAdjustInfo(fundAdjustInfo, (long) user.getUID())); + adjustHistoryList.addAll(createAdjustInfo(otherAdjustInfo, (long) user.getUID())); + //更新字段 + toUpdateBaseInfoPO.setRunStatus(EmployeeStatusEnum.PAYING.getValue()); + + toUpdateSocialInfo.setSocialAccount(toCopySocialInfo.getSocialAccount()); + toUpdateSocialInfo.setSocialSchemeId(toCopySocialInfo.getSocialSchemeId()); + toUpdateSocialInfo.setSocialPaymentBaseString(toCopySocialInfo.getSocialPaymentBaseString()); + toUpdateSocialInfo.setSocialPaymentComBaseString(toCopySocialInfo.getSocialPaymentComBaseString()); + toUpdateSocialInfo.setNonPayment(toCopySocialInfo.getNonPayment()); + toUpdateSocialInfo.setUnderTake(toCopySocialInfo.getUnderTake()); + toUpdateSocialInfo.setSocialStartTime(StringUtils.isNotBlank(payStartYearMonth) ? payStartYearMonth : toCopySocialInfo.getSocialStartTime()); + toUpdateSocialInfo.setUpdateTime(new Date()); + + toUpdateFundInfo.setFundAccount(toCopyFundInfo.getFundAccount()); + toUpdateFundInfo.setSupplementFundAccount(toCopyFundInfo.getSupplementFundAccount()); + toUpdateFundInfo.setFundSchemeId(toCopyFundInfo.getFundSchemeId()); + toUpdateFundInfo.setFundPaymentBaseString(toCopyFundInfo.getFundPaymentBaseString()); + toUpdateFundInfo.setFundPaymentComBaseString(toCopyFundInfo.getFundPaymentComBaseString()); + toUpdateFundInfo.setNonPayment(toCopyFundInfo.getNonPayment()); + toUpdateFundInfo.setUnderTake(toCopyFundInfo.getUnderTake()); + toUpdateFundInfo.setFundStartTime(StringUtils.isNotBlank(payStartYearMonth) ? payStartYearMonth : toCopyFundInfo.getFundStartTime()); + toUpdateFundInfo.setUpdateTime(new Date()); + + toUpdateOtherInfo.setOtherSchemeId(toCopyOtherInfo.getOtherSchemeId()); + toUpdateOtherInfo.setOtherPaymentBaseString(toCopyOtherInfo.getOtherPaymentBaseString()); + toUpdateOtherInfo.setOtherPaymentComBaseString(toCopyOtherInfo.getOtherPaymentComBaseString()); + toUpdateOtherInfo.setNonPayment(toCopyOtherInfo.getNonPayment()); + toUpdateOtherInfo.setUnderTake(toCopyOtherInfo.getUnderTake()); + toUpdateOtherInfo.setOtherStartTime(StringUtils.isNotBlank(payStartYearMonth) ? payStartYearMonth : toCopyOtherInfo.getOtherStartTime()); + toUpdateOtherInfo.setUpdateTime(new Date()); + //档案入库 + encryptUtil.encrypt(toUpdateSocialInfo, InsuranceArchivesSocialSchemePO.class); + encryptUtil.encrypt(toUpdateFundInfo, InsuranceArchivesFundSchemePO.class); + encryptUtil.encrypt(toUpdateOtherInfo, InsuranceArchivesOtherSchemePO.class); + + getInsuranceBaseInfoMapper().updateById(toUpdateBaseInfoPO); + getSocialSchemeMapper().updateById(toUpdateSocialInfo); + getFundSchemeMapper().updateById(toUpdateFundInfo); + getOtherSchemeMapper().updateById(toUpdateOtherInfo); + //基数调整记录入库 +// siArchivesBiz.batchInsertAdjustHistory(adjustHistoryList, (long) user.getUID()); + batchInsertAdjustHistory(adjustHistoryList); + + Map resultMap = new HashMap<>(2); + String resultMsg = "操作成功"; + String resultType = "success"; + + resultMap.put("type", resultType); + resultMap.put("msg", resultMsg); + return resultMap; + } + + /*****以下代码为SIArchivesBiz中逻辑迁移,旨在减少Biz类的使用*****/ + /** + * 判断是否需要生成历史福利档案基本信息 + */ + public Boolean createOldInsuranceBaseInfo(Long creator) { + log.info("判断是否需要生成历史数据"); + List nowBaseInfoList = getInsuranceBaseInfoMapper().getInsuranceBaseInfoList(); + if (nowBaseInfoList.size() == 0) { + StopWatch sw = new StopWatch(); + log.info("福利档案基础信息表为空,开始生成历史数据:"); + //处理公积金、其他福利档案中个税扣缴义务人为空的情况 + sw.start("处理公积金、其他福利档案中个税扣缴义务人为空的情况"); + List socialList = getSocialSchemeMapper().listAll(); + List fundList = getFundSchemeMapper().listAll(); + List otherList = getOtherSchemeMapper().listAll(); + + List updateFundList = new ArrayList<>(); + List updateOtherList = new ArrayList<>(); + for (InsuranceArchivesSocialSchemePO socialSchemePO : socialList) { + List toDealFundList = fundList.stream().filter(f -> f.getEmployeeId().equals(socialSchemePO.getEmployeeId()) && f.getPaymentOrganization() == null).collect(Collectors.toList()); + if (toDealFundList.size() > 0) { + InsuranceArchivesFundSchemePO toDealFundPO = toDealFundList.get(0); + toDealFundPO.setPaymentOrganization(socialSchemePO.getPaymentOrganization()); + updateFundList.add(toDealFundPO); + } + + List toDealOtherList = otherList.stream().filter(f -> f.getEmployeeId().equals(socialSchemePO.getEmployeeId()) && f.getPaymentOrganization() == null).collect(Collectors.toList()); + if (toDealOtherList.size() > 0) { + InsuranceArchivesOtherSchemePO toDealOtherPO = toDealOtherList.get(0); + toDealOtherPO.setPaymentOrganization(socialSchemePO.getPaymentOrganization()); + updateOtherList.add(toDealOtherPO); + } + + } + log.info("重置个税扣缴义务人id的公积金档案数:{}", updateFundList.size()); + log.info("重置个税扣缴义务人id的其他福利档案数:{}", updateOtherList.size()); + //更新公积金和其他福利档案 + updateFundList.forEach(getFundSchemeMapper()::updateById); + updateOtherList.forEach(getOtherSchemeMapper()::updateById); + sw.stop(); + + sw.start("处理待入库的历史福利档案基础信息并入库"); + List addBaseInfoList = new ArrayList<>(); + + List oldBaseInfoList = getInsuranceBaseInfoMapper().getInsuranceBaseInfoListByInsuranceDetail(null); + log.info("获取待生成的历史福利档案基础信息条数:{}", oldBaseInfoList.size()); + //去重 + oldBaseInfoList = oldBaseInfoList.stream() + .collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(f -> f.getPaymentOrganization() + "-" + f.getEmployeeId()))), ArrayList::new)); + log.info("去重后的待生成历史福利档案基础信息条数:{}", oldBaseInfoList.size()); + if (oldBaseInfoList.size() > 0) { + //设置基本信息表字段 + for (InsuranceArchivesBaseInfoPO po : oldBaseInfoList) { + po.setId(IdGenerator.generate()); + po.setCreateTime(new Date()); + po.setDeleteType(0); + po.setCreator(creator); + po.setRunStatus(EmployeeStatusEnum.STAY_ADD.getValue()); + po.setUpdateTime(new Date()); + po.setTenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY); + + addBaseInfoList.add(po); + } + //将历史基本信息入库 + List> partition = Lists.partition(addBaseInfoList, 50); + partition.forEach(getInsuranceBaseInfoMapper()::batchSave); + + sw.stop(); + log.info("各操作计时 {}", sw.prettyPrint()); + return true; + }else { + return false; + } + } else { + return false; + } + + } + @Override + public List> buildTableData(List insuranceArchivesEmployeePOS) { + return buildTableData(insuranceArchivesEmployeePOS, false); + } + + /** + * @param insuranceArchivesEmployeePOS + * @return + */ + public List> buildTableData(List insuranceArchivesEmployeePOS, boolean export) { + boolean welBaseDiffSign = isDiffWelBase(); + + List taxAgentPOS = getTaxAgentMapper().listAll(); + Map longTaxAgentPOMap = SalaryEntityUtil.convert2Map(taxAgentPOS, TaxAgentPO::getId); + + + List> records = new ArrayList<>(); + + Map socialSchemePOMap = encryptUtil.decryptList(this.getSocialByEmployeeIdAndPayOrg(insuranceArchivesEmployeePOS), InsuranceArchivesSocialSchemePO.class) + .stream().collect(Collectors.toMap(InsuranceArchivesSocialSchemePO::getId, Function.identity(), (a, b) -> a)); + + Map fundSchemePOMap = encryptUtil.decryptList(this.getFundByEmployeeIdAndPayOrg(insuranceArchivesEmployeePOS), InsuranceArchivesFundSchemePO.class) + .stream().collect(Collectors.toMap(InsuranceArchivesFundSchemePO::getId, Function.identity(), (a, b) -> a)); + List otherByEmployeeList = this.getOtherByEmployeeIdAndPayOrg(insuranceArchivesEmployeePOS); + encryptUtil.decryptList(otherByEmployeeList, InsuranceArchivesOtherSchemePO.class); + Map otherSchemePOMap = otherByEmployeeList + .stream().collect(Collectors.toMap(InsuranceArchivesOtherSchemePO::getId, Function.identity(), (a, b) -> a)); + insuranceArchivesEmployeePOS.forEach(item -> { + InsuranceArchivesSocialSchemePO socialItem = socialSchemePOMap.get(item.getSocialId()); + InsuranceArchivesFundSchemePO fundItem = fundSchemePOMap.get(item.getFundId()); + InsuranceArchivesOtherSchemePO otherItem = otherSchemePOMap.get(item.getOtherId()); + Map map = new HashMap<>(); + map.put("employeeName", item.getUserName()); + map.put("paymentOrganizationName", longTaxAgentPOMap.get(item.getPaymentOrganization()) != null ? longTaxAgentPOMap.get(item.getPaymentOrganization()).getName() : ""); + map.put("employeeId", item.getEmployeeId()); + map.put("departmentName", item.getDepartmentName()); + map.put("subcompanyName", item.getSubcompanyName()); + map.put("departmentId", item.getDepartmentId()); + map.put("jobNum", item.getJobNum()); + map.put("idNo", item.getIdNo()); + map.put("companystartdate", item.getCompanystartdate()); + map.put("dismissdate", item.getDimissionDate()); + map.put("mobile", item.getTelephone()); + map.put("siSchemeId", item.getSiSchemeId()); + map.put("fundSchemeId", item.getFundSchemeId()); + map.put("otherSchemeId", item.getOtherSchemeId()); + map.put("status", item.getUserStatus() != null ? UserStatusEnum.getDefaultLabelByValue(item.getUserStatus()) : ""); + map.put("baseInfoId", item.getBaseInfoId()); + map.put("paymentOrganization", item.getPaymentOrganization()); + map.put("opts", item.getOpts()); + if (socialItem != null) { + map.put("socialName", getInsuranceSchemeMapper().querySchemeName(socialItem.getSocialSchemeId())); + Map socialJson = JSON.parseObject(socialItem.getSocialPaymentBaseString(), new TypeReference>() { + }); + if (welBaseDiffSign) { + if (socialJson != null) { + //查询该福利方案下开启缴纳的福利项 + List insuranceIdList = payInsuranceIds(socialItem.getSocialSchemeId(), PaymentScopeEnum.SCOPE_PERSON.getValue()); + socialJson.forEach((k, v) -> { + if (insuranceIdList.contains(Long.valueOf(k))) { + map.put(k + "per", v); + } + }); + } + Map socialComJson = JSON.parseObject(socialItem.getSocialPaymentComBaseString(), new TypeReference>() { + }); + if (socialComJson != null) { + //查询该福利方案下开启缴纳的福利项 + List insuranceIdList = payInsuranceIds(socialItem.getSocialSchemeId(),PaymentScopeEnum.SCOPE_COMPANY.getValue()); + socialComJson.forEach((k, v) -> { + if (insuranceIdList.contains(Long.valueOf(k))) { + map.put(k + "com", v); + } + }); + } + } else { + if (socialJson != null) { + //查询该福利方案下开启缴纳的福利项 + List insuranceIdList = payInsuranceIds(socialItem.getSocialSchemeId()); + socialJson.forEach((k, v) -> { + if (insuranceIdList.contains(Long.valueOf(k))) { + map.put(k, v); + } + }); + } + } + + map.put("socialAccount", socialItem.getSocialAccount()); + map.put("socialStartTime", socialItem.getSocialStartTime()); + map.put("socialEndTime", socialItem.getSocialEndTime()); + } + if (fundItem != null) { + map.put("fundName", getInsuranceSchemeMapper().querySchemeName(fundItem.getFundSchemeId())); + map.put("fundAccount", fundItem.getFundAccount()); + Map fundJson = JSON.parseObject(fundItem.getFundPaymentBaseString(), new TypeReference>() { + }); + if (welBaseDiffSign) { + if (fundJson != null) { + //查询该福利方案下开启缴纳的福利项 + List insuranceIdList = payInsuranceIds(fundItem.getFundSchemeId(),PaymentScopeEnum.SCOPE_PERSON.getValue()); + fundJson.forEach((k, v) -> { + if (insuranceIdList.contains(Long.valueOf(k))) { + map.put(k + "per", v); + } + }); + } + Map fundComJson = JSON.parseObject(fundItem.getFundPaymentComBaseString(), new TypeReference>() { + }); + if (fundComJson != null) { + //查询该福利方案下开启缴纳的福利项 + List insuranceIdList = payInsuranceIds(fundItem.getFundSchemeId(),PaymentScopeEnum.SCOPE_COMPANY.getValue()); + fundComJson.forEach((k, v) -> { + if (insuranceIdList.contains(Long.valueOf(k))) { + map.put(k + "com", v); + } + }); + } + } else { + if (fundJson != null) { + //查询该福利方案下开启缴纳的福利项 + List insuranceIdList = payInsuranceIds(fundItem.getFundSchemeId()); + fundJson.forEach((k, v) -> { + if (insuranceIdList.contains(Long.valueOf(k))) { + map.put(k, v); + } + }); + } + } + + map.put("supplementFundAccount", fundItem.getSupplementFundAccount()); + map.put("fundStartTime", fundItem.getFundStartTime()); + map.put("fundEndTime", fundItem.getFundEndTime()); + + } + if (otherItem != null) { + map.put("otherName", getInsuranceSchemeMapper().querySchemeName(otherItem.getOtherSchemeId())); + Map otherJson = JSON.parseObject(otherItem.getOtherPaymentBaseString(), new TypeReference>() { + }); + if (welBaseDiffSign) { + if (otherJson != null) { + //查询该福利方案下开启缴纳的福利项 + List insuranceIdList = payInsuranceIds(otherItem.getOtherSchemeId(),PaymentScopeEnum.SCOPE_PERSON.getValue()); + otherJson.forEach((k, v) -> { + if (insuranceIdList.contains(Long.valueOf(k))) { + map.put(k + "per", v); + } + }); + } + Map otherComJson = JSON.parseObject(otherItem.getOtherPaymentComBaseString(), new TypeReference>() { + }); + if (otherComJson != null) { + //查询该福利方案下开启缴纳的福利项 + List insuranceIdList = payInsuranceIds(otherItem.getOtherSchemeId(),PaymentScopeEnum.SCOPE_COMPANY.getValue()); + otherComJson.forEach((k, v) -> { + if (insuranceIdList.contains(Long.valueOf(k))) { + map.put(k + "com", v); + } + }); + } + } else { + if (otherJson != null) { + //查询该福利方案下开启缴纳的福利项 + List insuranceIdList = payInsuranceIds(otherItem.getOtherSchemeId()); + otherJson.forEach((k, v) -> { + if (insuranceIdList.contains(Long.valueOf(k))) { + map.put(k, v); + } + }); + } + } + + map.put("otherStartTime", otherItem.getOtherStartTime()); + map.put("otherEndTime", otherItem.getOtherEndTime()); + } + records.add(map); + }); + return records; + + + } + + @Override + public boolean isDiffWelBase() { + User user = (User) SalaryContext.get().getValue("user"); + //判断是否要区分个人和单位福利基数 + SalarySysConfPO welBaseDiff = getSalarySysConfService(user).getOneByCode(WEL_BASE_DIFF_BY_PER_AND_COM); + + return welBaseDiff != null && welBaseDiff.getConfValue().equals(OpenEnum.OPEN.getValue()); + } + + /** + * 根据人员id和个税扣缴人id获取记录 + */ + public List getSocialByEmployeeIdAndPayOrg(List insuranceArchivesEmployeePOS) { + + List allList = new ArrayList<>(); + for (InsuranceArchivesEmployeePO po : insuranceArchivesEmployeePOS) { + List socialList = getSocialSchemeMapper().getSocialByEmployeeIdAndPayOrg(po); + if (socialList.size() > 0) { + allList.add(socialList.get(0)); + } + } + return allList; + } + + public List getFundByEmployeeIdAndPayOrg(List insuranceArchivesEmployeePOS) { + + List allList = new ArrayList<>(); + for (InsuranceArchivesEmployeePO po : insuranceArchivesEmployeePOS) { + List fundList = getFundSchemeMapper().getFundByEmployeeIdAndPayOrg(po); + if (fundList.size() > 0) { + allList.add(fundList.get(0)); + } + } + return allList; + } + + public List getOtherByEmployeeIdAndPayOrg(List insuranceArchivesEmployeePOS) { + + List allList = new ArrayList<>(); + for (InsuranceArchivesEmployeePO po : insuranceArchivesEmployeePOS) { + List otherList = getOtherSchemeMapper().getOtherByEmployeeIdAndPayOrg(po); + if (otherList.size() > 0) { + allList.add(otherList.get(0)); + } + } + return allList; + } + + @Override + public List payInsuranceIds(Long socialSchemeId, Integer paymentScope) { + //查询该福利方案下开启缴纳的福利项 + List detailPOS = getInsuranceSchemeDetailMapper().queryListBySchemeId(socialSchemeId); + List insuranceIdList = new ArrayList<>(); + if (detailPOS != null && detailPOS.size() > 0) { + //开启缴纳的 + insuranceIdList = detailPOS.stream().filter(f -> f.getIsPayment().equals(IsPaymentEnum.YES.getValue()) && f.getPaymentScope().equals(paymentScope)) + .map(InsuranceSchemeDetailPO::getInsuranceId).collect(Collectors.toList()); + } + return insuranceIdList; + } + + @Override + public List payInsuranceIds(Long socialSchemeId) { + //查询该福利方案下开启缴纳的福利项 + List detailPOS = getInsuranceSchemeDetailMapper().queryListBySchemeId(socialSchemeId); + List insuranceIdList = new ArrayList<>(); + if (detailPOS != null && detailPOS.size() > 0) { + //开启缴纳的 + insuranceIdList = detailPOS.stream().filter(f -> f.getIsPayment().equals(IsPaymentEnum.YES.getValue())).map(InsuranceSchemeDetailPO::getInsuranceId).collect(Collectors.toList()); + } + return insuranceIdList; + } + + @Override + public List buildWeaTableColumns(List insuranceArchivesEmployeePOS) { + + Map> titleMap = buildColumnTitle(insuranceArchivesEmployeePOS); + List list = new ArrayList<>(); + WeaTableColumn nameColumn = new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(0, "姓名"), "employeeName"); + nameColumn.setFixed("left"); + list.add(nameColumn); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(0, "个税扣缴义务人"), "paymentOrganizationName")); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(0, "分部"), "subcompanyName")); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(0, "部门"), "departmentName")); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(0, "手机号"), "mobile")); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(0, "员工状态"), "status")); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(0, "工号"), "jobNum")); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(0, "证件号码"), "idNo")); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(0, "入职日期"), "companystartdate")); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(0, "社保方案名称"), "socialName")); + titleMap.get(WelfareTypeEnum.SOCIAL_SECURITY.getValue()).forEach((k, v) -> list.add(new WeaTableColumn("150px", v, k))); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(0, "社保账号"), "socialAccount")); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(0, "社保起始缴纳月"), "socialStartTime")); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(0, "社保最后缴纳月"), "socialEndTime")); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(0, "公积金方案名称"), "fundName")); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(0, "公积金账号"), "fundAccount")); + titleMap.get(WelfareTypeEnum.ACCUMULATION_FUND.getValue()).forEach((k, v) -> list.add(new WeaTableColumn("150px", v, k))); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(0, "补充公积金账号"), "supplementFundAccount")); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(0, "公积金起始缴纳月"), "fundStartTime")); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(0, "公积金最后缴纳月"), "fundEndTime")); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(0, "其他福利方案名称"), "otherName")); + titleMap.get(WelfareTypeEnum.OTHER.getValue()).forEach((k, v) -> list.add(new WeaTableColumn("150px", v, k))); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(0, "其他福利起始缴纳月"), "otherStartTime")); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(0, "其他福利最后缴纳月"), "otherEndTime")); + return list; + } + + public Map> buildColumnTitle(List insuranceArchivesEmployeePOS) { + + boolean welBaseDiffSign = isDiffWelBase(); + + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + Map> result = new HashMap<>(); + + insuranceArchivesEmployeePOS = insuranceArchivesEmployeePOS.stream() + .filter(f -> f.getEmployeeId() != null) + .collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(InsuranceArchivesEmployeePO::getEmployeeId))), ArrayList::new)); + try { + + SocialSchemeMapper socialSchemeMapper = sqlSession.getMapper(SocialSchemeMapper.class); + FundSchemeMapper fundSchemeMapper = sqlSession.getMapper(FundSchemeMapper.class); + OtherSchemeMapper otherSchemeMapper = sqlSession.getMapper(OtherSchemeMapper.class); + ICategoryMapper iCategoryMapper = sqlSession.getMapper(ICategoryMapper.class); + + Set socialSet = new HashSet<>(); + Set fundSet = new HashSet<>(); + Set otherSet = new HashSet<>(); + + Set socialComSet = new HashSet<>(); + Set fundComSet = new HashSet<>(); + Set otherComSet = new HashSet<>(); + + insuranceArchivesEmployeePOS.forEach(item -> { + List socialList = socialSchemeMapper.getSocialByEmployeeId(Collections.singletonList(item.getEmployeeId())); + encryptUtil.decryptList(socialList, InsuranceArchivesSocialSchemePO.class); + List fundList = fundSchemeMapper.getFundByEmployeeId(Collections.singletonList(item.getEmployeeId())); + encryptUtil.decryptList(fundList, InsuranceArchivesFundSchemePO.class); + List otherList = otherSchemeMapper.getOtherByEmployeeId(Collections.singletonList(item.getEmployeeId())); + encryptUtil.decryptList(otherList, InsuranceArchivesOtherSchemePO.class); + if (socialList.size() > 0) { + for (InsuranceArchivesSocialSchemePO socialSchemePO : socialList) { + + Map socialJson = JSON.parseObject(socialSchemePO.getSocialPaymentBaseString(), new TypeReference>() { + }); + if (socialJson != null) { + socialJson.forEach((k, v) -> socialSet.add(k)); + } + //如果需要区分个人和公司福利基数 + if (welBaseDiffSign) { + Map socialComJson = JSON.parseObject(socialSchemePO.getSocialPaymentComBaseString(), new TypeReference>() { + }); + if (socialComJson != null) { + socialComJson.forEach((k, v) -> socialComSet.add(k)); + } + } + } + + } + if (fundList.size() > 0) { + for (InsuranceArchivesFundSchemePO fundSchemePO : fundList) { + Map fundJson = JSON.parseObject(fundSchemePO.getFundPaymentBaseString(), new TypeReference>() { + }); + if (fundJson != null) { + fundJson.forEach((k, v) -> fundSet.add(k)); + } + //如果需要区分个人和公司福利基数 + if (welBaseDiffSign) { + Map fundComJson = JSON.parseObject(fundSchemePO.getFundPaymentComBaseString(), new TypeReference>() { + }); + if (fundComJson != null) { + fundComJson.forEach((k, v) -> fundComSet.add(k)); + } + } + } + + } + if (otherList.size() > 0) { + for (InsuranceArchivesOtherSchemePO otherSchemePO : otherList) { + Map otherJson = JSON.parseObject(otherSchemePO.getOtherPaymentBaseString(), new TypeReference>() { + }); + if (otherJson != null) { + otherJson.forEach((k, v) -> otherSet.add(k)); + } + //如果需要区分个人和公司福利基数 + if (welBaseDiffSign) { + Map otherComJson = JSON.parseObject(otherSchemePO.getOtherPaymentComBaseString(), new TypeReference>() { + }); + if (otherComJson != null) { + otherComJson.forEach((k, v) -> otherComSet.add(k)); + } + } + } + + } + }); + Map socialMap = new HashMap<>(); + Map socialComMap = new HashMap<>(); + Map socialCollect = new HashMap<>(); + Map customSocial = iCategoryMapper.listByWelfareType(WelfareTypeEnum.SOCIAL_SECURITY.getValue(), null) + .stream().collect(Collectors.toMap(ICategoryPO::getId, Function.identity())); + + Map sysSocial = iCategoryMapper.listByWelfareType(WelfareTypeEnum.SOCIAL_SECURITY.getValue(), DataTypeEnum.SYSTEM.getValue()) + .stream().collect(Collectors.toMap(ICategoryPO::getId, Function.identity())); + + socialCollect.putAll(customSocial); + socialCollect.putAll(sysSocial); + + if (welBaseDiffSign) { + socialSet.forEach(item -> { + if (socialCollect.containsKey(Long.valueOf(item))) { + socialMap.put(item + "per", socialCollect.get(Long.valueOf(item)).getInsuranceName() + + SalaryI18nUtil.getI18nLabel(0, "申报基数") + + SalaryI18nUtil.getI18nLabel(0,"个人")); + } + }); + socialComSet.forEach(item -> { + if (socialCollect.containsKey(Long.valueOf(item))) { + socialComMap.put(item + "com", socialCollect.get(Long.valueOf(item)).getInsuranceName() + + SalaryI18nUtil.getI18nLabel(0, "申报基数") + + SalaryI18nUtil.getI18nLabel(0,"单位")); + } + }); + } else { + socialSet.forEach(item -> { + if (socialCollect.containsKey(Long.valueOf(item))) { + socialMap.put(item, socialCollect.get(Long.valueOf(item)).getInsuranceName() + SalaryI18nUtil.getI18nLabel(0, "申报基数")); + } + }); + } + Map fundMap = new HashMap<>(); + Map fundComMap = new HashMap<>(); + Map fundCollect = new HashMap<>(); + Map customFund = iCategoryMapper.listByWelfareType(WelfareTypeEnum.ACCUMULATION_FUND.getValue(), null).stream().collect(Collectors.toMap(ICategoryPO::getId, Function.identity())); + Map sysFund = iCategoryMapper.listByWelfareType(WelfareTypeEnum.ACCUMULATION_FUND.getValue(), DataTypeEnum.SYSTEM.getValue()).stream().collect(Collectors.toMap(ICategoryPO::getId, Function.identity())); + fundCollect.putAll(customFund); + fundCollect.putAll(sysFund); + if (welBaseDiffSign) { + fundSet.forEach(item -> { + if (fundCollect.containsKey(Long.valueOf(item))) { + fundMap.put(item + "per", fundCollect.get(Long.valueOf(item)).getInsuranceName() + + SalaryI18nUtil.getI18nLabel(0, "申报基数") + + SalaryI18nUtil.getI18nLabel(0,"个人")); + } + }); + fundComSet.forEach(item -> { + if (fundCollect.containsKey(Long.valueOf(item))) { + fundComMap.put(item + "com", fundCollect.get(Long.valueOf(item)).getInsuranceName() + + SalaryI18nUtil.getI18nLabel(0, "申报基数") + + SalaryI18nUtil.getI18nLabel(0,"单位")); + } + }); + } else { + fundSet.forEach(item -> { + if (fundCollect.containsKey(Long.valueOf(item))) { + fundMap.put(item, fundCollect.get(Long.valueOf(item)).getInsuranceName() + SalaryI18nUtil.getI18nLabel(0, "申报基数")); + } + }); + } + Map otherMap = new HashMap<>(); + Map otherComMap = new HashMap<>(); + Map otherCollect = new HashMap<>(); + Map customOther = iCategoryMapper.listByWelfareType(WelfareTypeEnum.OTHER.getValue(), null).stream().collect(Collectors.toMap(ICategoryPO::getId, Function.identity())); + Map sysOther = iCategoryMapper.listByWelfareType(WelfareTypeEnum.OTHER.getValue(), DataTypeEnum.SYSTEM.getValue()).stream().collect(Collectors.toMap(ICategoryPO::getId, Function.identity())); + otherCollect.putAll(customOther); + otherCollect.putAll(sysOther); + + if (welBaseDiffSign) { + otherSet.forEach(item -> { + if (otherCollect.containsKey(Long.valueOf(item))) { + otherMap.put(item + "per", otherCollect.get(Long.valueOf(item)).getInsuranceName() + + SalaryI18nUtil.getI18nLabel(0, "申报基数") + + SalaryI18nUtil.getI18nLabel(0,"个人")); + } + }); + otherComSet.forEach(item -> { + if (otherCollect.containsKey(Long.valueOf(item))) { + otherComMap.put(item + "com", otherCollect.get(Long.valueOf(item)).getInsuranceName() + + SalaryI18nUtil.getI18nLabel(0, "申报基数") + + SalaryI18nUtil.getI18nLabel(0,"单位")); + } + }); + } else { + otherSet.forEach(item -> { + if (otherCollect.containsKey(Long.valueOf(item))) { + otherMap.put(item, otherCollect.get(Long.valueOf(item)).getInsuranceName() + SalaryI18nUtil.getI18nLabel(0, "申报基数")); + } + }); + } + // map根据key排序 + LinkedHashMap socialMapWithAscKey = socialMap.entrySet().stream() + .sorted(Map.Entry.comparingByKey()) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (oldValue, newValue) -> oldValue, + LinkedHashMap::new)); + LinkedHashMap fundMapWithAscKey = fundMap.entrySet().stream() + .sorted(Map.Entry.comparingByKey()) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (oldValue, newValue) -> oldValue, + LinkedHashMap::new)); + LinkedHashMap otherMapWithAscKey = otherMap.entrySet().stream() + .sorted(Map.Entry.comparingByKey()) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (oldValue, newValue) -> oldValue, + LinkedHashMap::new)); + if (welBaseDiffSign) { + LinkedHashMap socialComMapWithAscKey = socialComMap.entrySet().stream() + .sorted(Map.Entry.comparingByKey()) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (oldValue, newValue) -> oldValue, + LinkedHashMap::new)); + LinkedHashMap fundComMapWithAscKey = fundComMap.entrySet().stream() + .sorted(Map.Entry.comparingByKey()) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (oldValue, newValue) -> oldValue, + LinkedHashMap::new)); + LinkedHashMap otherComMapWithAscKey = otherComMap.entrySet().stream() + .sorted(Map.Entry.comparingByKey()) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (oldValue, newValue) -> oldValue, + LinkedHashMap::new)); + socialMapWithAscKey.putAll(socialComMapWithAscKey); + fundMapWithAscKey.putAll(fundComMapWithAscKey); + otherMapWithAscKey.putAll(otherComMapWithAscKey); + } + + result.put(WelfareTypeEnum.SOCIAL_SECURITY.getValue(), socialMapWithAscKey); + result.put(WelfareTypeEnum.ACCUMULATION_FUND.getValue(), fundMapWithAscKey); + result.put(WelfareTypeEnum.OTHER.getValue(), otherMapWithAscKey); + return result; + } finally { + sqlSession.close(); + } + + + } + + /** + * 获取福利档案基数调整记录 + * + */ + public List getAdjustHistoryList(Long paymentOrganization, Long employeeId) { + + if (paymentOrganization == null && employeeId == null) { + return null; + } + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + InsuranceBaseAdjustHistoryMapper mapper = sqlSession.getMapper(InsuranceBaseAdjustHistoryMapper.class); + List list = mapper.listByEmployeeIdAndPayOrg(paymentOrganization, employeeId); + return list; + } finally { + sqlSession.close(); + } + } + + /** + * 获取福利档案基数调整记录 + * + */ + public List getBaseHistoryByEmployeeIdAndOperator(Long operator, Long employeeId) { + + List empList = getInsuranceBaseAdjustHistoryMapper().listByEmployeeIdAndOperator(operator, employeeId); + List extEmpList = getInsuranceBaseAdjustHistoryMapper().listByExtEmpIdAndOperator(operator, employeeId); + if (extEmpList != null) { + empList.addAll(extEmpList); + empList = empList.stream().filter(f -> org.apache.commons.lang.StringUtils.isNotBlank(f.getEmployeeName())) + .sorted(Comparator.comparing(InsuranceArchivesBaseHistoryDTO::getOperateTime).reversed()).collect(Collectors.toList()); + } + return empList; + } + + //生成基数调整记录(基数单元未变化则忽略) + public List createAdjustInfo(InsuranceArchivesBaseHistoryDTO adjustInfo, Long creator) { + Date now = new Date(); + boolean welBaseDiffSign = isDiffWelBase(); + + List toCreateAdjustHistoryList = new ArrayList<>(); + //旧档案不存在基数信息,则直接遍历新的基数数据,生成调整记录;旧档案存在基数信息,则合并新旧基数数据,遍历合并后的技术数据中的key,生成调整记录。 + if(org.apache.commons.lang.StringUtils.isNotBlank(adjustInfo.getAdjustAfterBaseJson()) && org.apache.commons.lang.StringUtils.isBlank(adjustInfo.getAdjustBeforeBaseJson())) { + Map adjustAfterBaseMap = JSON.parseObject(adjustInfo.getAdjustAfterBaseJson(), new TypeReference>() { + }); + for (String key : adjustAfterBaseMap.keySet()) { + InsuranceArchivesBaseHistoryPO adjustItem = new InsuranceArchivesBaseHistoryPO(); + BeanUtils.copyProperties(adjustInfo, adjustItem); + adjustItem.setAdjustWelfareItemId(Long.valueOf(key)); + adjustItem.setAdjustAfterBaseValue((String) adjustAfterBaseMap.get(key)); + adjustItem.setOperateTime(now); + adjustItem.setOperator(creator); + adjustItem.setCreator(creator); + adjustItem.setCreateTime(now); + adjustItem.setUpdateTime(now); + adjustItem.setDeleteType(DeleteTypeEnum.NOT_DELETED.getValue()); + adjustItem.setTenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY); + adjustItem.setId(IdGenerator.generate()); + adjustItem.setPaymentScope(welBaseDiffSign ? PaymentScopeEnum.SCOPE_PERSON.getValue().toString() : PaymentScopeEnum.SCOPE_PERSON.getValue().toString() + "," + PaymentScopeEnum.SCOPE_COMPANY.getValue().toString()); + toCreateAdjustHistoryList.add(adjustItem); + } + } else if (org.apache.commons.lang.StringUtils.isNotBlank(adjustInfo.getAdjustAfterBaseJson()) && org.apache.commons.lang.StringUtils.isNotBlank(adjustInfo.getAdjustBeforeBaseJson())) { + Map adjustAfterBaseMap = JSON.parseObject(adjustInfo.getAdjustAfterBaseJson(), new TypeReference>() { + }); + Map adjustBeforeBaseMap = JSON.parseObject(adjustInfo.getAdjustBeforeBaseJson(), new TypeReference>() { + }); + Map reDealMap = new HashMap<>(); + if (adjustAfterBaseMap != null) { + reDealMap.putAll(adjustAfterBaseMap); + } + if (adjustBeforeBaseMap != null) { + reDealMap.putAll(adjustBeforeBaseMap); + } + if (reDealMap.size() >0) { + for (String key : reDealMap.keySet()) { + String beforeValue = (String) adjustBeforeBaseMap.get(key); + String afterValue = (String) adjustAfterBaseMap.get(key); + if (SalaryEntityUtil.empty2Zero(beforeValue).compareTo(SalaryEntityUtil.empty2Zero(afterValue)) == 0) { + continue; + } + InsuranceArchivesBaseHistoryPO adjustItem = new InsuranceArchivesBaseHistoryPO(); + BeanUtils.copyProperties(adjustInfo, adjustItem); + adjustItem.setAdjustWelfareItemId(Long.valueOf(key)); + adjustItem.setAdjustBeforeBaseValue(beforeValue); + adjustItem.setAdjustAfterBaseValue(afterValue); + adjustItem.setOperateTime(now); + adjustItem.setOperator(creator); + adjustItem.setCreator(creator); + adjustItem.setCreateTime(now); + adjustItem.setUpdateTime(now); + adjustItem.setDeleteType(DeleteTypeEnum.NOT_DELETED.getValue()); + adjustItem.setTenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY); + adjustItem.setId(IdGenerator.generate()); + adjustItem.setPaymentScope(welBaseDiffSign ? PaymentScopeEnum.SCOPE_PERSON.getValue().toString() : PaymentScopeEnum.SCOPE_PERSON.getValue().toString() + "," + PaymentScopeEnum.SCOPE_COMPANY.getValue().toString()); + + toCreateAdjustHistoryList.add(adjustItem); + } + } + + } + //如果系统应用设置拆分了个人和公司福利基数,则对adjustBeforeComBaseJson,adjustAfterComBaseJson也进行处理 + if (welBaseDiffSign) { + //旧档案不存在基数信息,则直接遍历新的基数数据,生成调整记录;旧档案存在基数信息,则合并新旧基数数据,遍历合并后的技术数据中的key,生成调整记录。 + if(org.apache.commons.lang.StringUtils.isNotBlank(adjustInfo.getAdjustAfterComBaseJson()) && org.apache.commons.lang.StringUtils.isBlank(adjustInfo.getAdjustBeforeComBaseJson())) { + Map adjustAfterComBaseMap = JSON.parseObject(adjustInfo.getAdjustAfterComBaseJson(), new TypeReference>() { + }); + for (String key : adjustAfterComBaseMap.keySet()) { + InsuranceArchivesBaseHistoryPO adjustItem = new InsuranceArchivesBaseHistoryPO(); + BeanUtils.copyProperties(adjustInfo, adjustItem); + adjustItem.setAdjustWelfareItemId(Long.valueOf(key)); + adjustItem.setAdjustAfterBaseValue((String) adjustAfterComBaseMap.get(key)); + adjustItem.setOperateTime(now); + adjustItem.setOperator(creator); + adjustItem.setCreator(creator); + adjustItem.setCreateTime(now); + adjustItem.setUpdateTime(now); + adjustItem.setDeleteType(DeleteTypeEnum.NOT_DELETED.getValue()); + adjustItem.setTenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY); + adjustItem.setId(IdGenerator.generate()); + adjustItem.setPaymentScope(PaymentScopeEnum.SCOPE_COMPANY.getValue().toString()); + toCreateAdjustHistoryList.add(adjustItem); + } + } else if (org.apache.commons.lang.StringUtils.isNotBlank(adjustInfo.getAdjustAfterComBaseJson()) && org.apache.commons.lang.StringUtils.isNotBlank(adjustInfo.getAdjustBeforeComBaseJson())) { + Map adjustAfterComBaseMap = JSON.parseObject(adjustInfo.getAdjustAfterComBaseJson(), new TypeReference>() { + }); + Map adjustBeforeComBaseMap = JSON.parseObject(adjustInfo.getAdjustBeforeComBaseJson(), new TypeReference>() { + }); + Map reDealMap = new HashMap<>(); + if (adjustAfterComBaseMap != null) { + reDealMap.putAll(adjustAfterComBaseMap); + } + if (adjustBeforeComBaseMap != null) { + reDealMap.putAll(adjustBeforeComBaseMap); + } + if (reDealMap.size() >0) { + for (String key : reDealMap.keySet()) { + String beforeValue = (String) adjustBeforeComBaseMap.get(key); + String afterValue = (String) adjustAfterComBaseMap.get(key); + if (SalaryEntityUtil.empty2Zero(beforeValue).compareTo(SalaryEntityUtil.empty2Zero(afterValue)) == 0) { + continue; + } + InsuranceArchivesBaseHistoryPO adjustItem = new InsuranceArchivesBaseHistoryPO(); + BeanUtils.copyProperties(adjustInfo, adjustItem); + adjustItem.setAdjustWelfareItemId(Long.valueOf(key)); + adjustItem.setAdjustBeforeBaseValue(beforeValue); + adjustItem.setAdjustAfterBaseValue(afterValue); + adjustItem.setOperateTime(now); + adjustItem.setOperator(creator); + adjustItem.setCreator(creator); + adjustItem.setCreateTime(now); + adjustItem.setUpdateTime(now); + adjustItem.setDeleteType(DeleteTypeEnum.NOT_DELETED.getValue()); + adjustItem.setTenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY); + adjustItem.setId(IdGenerator.generate()); + adjustItem.setPaymentScope( PaymentScopeEnum.SCOPE_COMPANY.getValue().toString()); + + toCreateAdjustHistoryList.add(adjustItem); + } + } + + } + } + return toCreateAdjustHistoryList; + } + + /** + * 新增福利档案基数调整记录 + * + */ + @Override + public void batchInsertAdjustHistory(List adjustHistoryList) { + + if (org.apache.commons.collections.CollectionUtils.isEmpty(adjustHistoryList)) { + return; + } + List> partition = Lists.partition(adjustHistoryList, 100); + partition.forEach(getInsuranceBaseAdjustHistoryMapper()::batchSave); + } + + public Map getBaseForm(WelfareTypeEnum welfareType, Long employeeId, Long paymentOrganization, Collection taxAgentPOS) { + Map data = new HashMap<>(16); + SalaryAssert.notNull(employeeId, SalaryI18nUtil.getI18nLabel(0, "员工id不可为空")); + List employeeByIds = getSalaryEmployeeService(user).getEmployeeByIdsAll(Collections.singletonList(employeeId)); + SalaryAssert.notEmpty(employeeByIds, SalaryI18nUtil.getI18nLabel(0, "员工信息不存在")); + DataCollectionEmployee item = employeeByIds.get(0); + + if (welfareType == null) { + //基础信息表单 + InsuranceArchivesBaseDTO insuranceArchivesBaseDTO = InsuranceArchivesBaseDTO.builder().department(item.getDepartmentName()) + .hiredate(item.getCompanystartdate()) + .position(item.getJobtitleName()) + .username(item.getUsername()) + .telephone(item.getMobile()) + .dimissionDate(item.getDismissdate()) + .build(); + + data.put("data", insuranceArchivesBaseDTO); + return data; + } + + List list = listAuthScheme(); + List selectItems = new ArrayList<>(); + List addGroups = new ArrayList<>(); + List paymentOptions = paymentOrganizationOptions(taxAgentPOS); + List underTakeOptions = Arrays.stream(UndertakerEnum.values()) + .map(e -> new SearchConditionOption(e.getValue().toString(), e.getDefaultLabel())).collect(Collectors.toList()); + //返回数据 + switch (welfareType) { + case SOCIAL_SECURITY: + InsuranceArchivesSocialSchemeDTO insuranceArchivesSocialSchemeDTO = buildSocialForm(employeeId, paymentOrganization); + List socialList = list.stream().filter(e -> Objects.equals(e.getWelfareType(), WelfareTypeEnum.SOCIAL_SECURITY.getValue())).collect(Collectors.toList()); + List socialOptions = new ArrayList<>(); + socialList.forEach(social -> { + socialOptions.add(new SearchConditionOption(Util.null2String(social.getId()), social.getSchemeName())); + }); + SearchConditionItem socialName = SalaryFormItemUtil.selectItem(user, socialOptions, 2, 12, 6, false, SalaryI18nUtil.getI18nLabel(0, "社保方案名称"), "socialSchemeId"); + SearchConditionItem organizationName = SalaryFormItemUtil.selectItem(user, paymentOptions, 2, 12, 6, false, SalaryI18nUtil.getI18nLabel(0, "社保缴纳组织"), "paymentOrganization"); + SearchConditionItem underTakeName = SalaryFormItemUtil.selectItem(user, underTakeOptions, 2, 12, 6, false, SalaryI18nUtil.getI18nLabel(0, "社保个人实际承担方"), "underTake"); + + selectItems.add(socialName); + selectItems.add(organizationName); + selectItems.add(underTakeName); + + addGroups.add(new SearchConditionGroup(SalaryI18nUtil.getI18nLabel(0, "社保基础信息"), true, selectItems)); + data.put("data", insuranceArchivesSocialSchemeDTO); + data.put("items", addGroups); + break; + case ACCUMULATION_FUND: + InsuranceArchivesFundSchemeDTO insuranceArchivesFundSchemeDTO = buildFundForm(employeeId, paymentOrganization); + List fundList = list.stream().filter(e -> Objects.equals(e.getWelfareType(), WelfareTypeEnum.ACCUMULATION_FUND.getValue())).collect(Collectors.toList()); + List fundOptions = new ArrayList<>(); + fundList.forEach(social -> { + fundOptions.add(new SearchConditionOption(Util.null2String(social.getId()), social.getSchemeName())); + }); + SearchConditionItem fundName = SalaryFormItemUtil.selectItem(user, fundOptions, 2, 12, 6, false, SalaryI18nUtil.getI18nLabel(0, "公积金方案名称"), "fundSchemeId"); + SearchConditionItem organizationFundName = SalaryFormItemUtil.selectItem(user, paymentOptions, 2, 12, 6, false, SalaryI18nUtil.getI18nLabel(0, "公积金缴纳组织"), "paymentOrganization"); + SearchConditionItem underTakeFundName = SalaryFormItemUtil.selectItem(user, underTakeOptions, 2, 12, 6, false, SalaryI18nUtil.getI18nLabel(0, "公积金个人实际承担方"), "underTake"); + + selectItems.add(fundName); + selectItems.add(organizationFundName); + selectItems.add(underTakeFundName); + addGroups.add(new SearchConditionGroup(SalaryI18nUtil.getI18nLabel(0, "公积金基础信息"), true, selectItems)); + data.put("data", insuranceArchivesFundSchemeDTO); + data.put("items", addGroups); + break; + case OTHER: + InsuranceArchivesOtherSchemeDTO insuranceArchivesOtherSchemeDTO = buildOtherForm(employeeId, paymentOrganization); + List otherList = list.stream().filter(e -> Objects.equals(e.getWelfareType(), WelfareTypeEnum.OTHER.getValue())).collect(Collectors.toList()); + List otherOptions = new ArrayList<>(); + otherList.forEach(social -> { + otherOptions.add(new SearchConditionOption(Util.null2String(social.getId()), social.getSchemeName())); + }); + SearchConditionItem otherName = SalaryFormItemUtil.selectItem(user, otherOptions, 2, 12, 6, false, SalaryI18nUtil.getI18nLabel(0, "其他福利名称"), "otherSchemeId"); + SearchConditionItem organizationOtherName = SalaryFormItemUtil.selectItem(user, paymentOptions, 2, 12, 6, false, SalaryI18nUtil.getI18nLabel(0, "其他福利缴纳组织"), "paymentOrganization"); + SearchConditionItem underTakeOtherName = SalaryFormItemUtil.selectItem(user, underTakeOptions, 2, 12, 6, false, SalaryI18nUtil.getI18nLabel(0, "其他福利个人实际承担方"), "underTake"); + + selectItems.add(otherName); + selectItems.add(organizationOtherName); + selectItems.add(underTakeOtherName); + addGroups.add(new SearchConditionGroup(SalaryI18nUtil.getI18nLabel(0, "其他福利基础信息"), true, selectItems)); + data.put("data", insuranceArchivesOtherSchemeDTO); + data.put("items", addGroups); + break; + default: + } + return data; + } + + private List listAuthScheme() { + List list = getSISchemeService(user).listAll(); + TaxAgentQueryParam param = TaxAgentQueryParam.builder().build(); + param.setFilterType(AuthFilterTypeEnum.ADMIN_DATA); + Collection taxAgentList = getTaxAgentService(user).listAuth(param); + List authTaxAgentIds = SalaryEntityUtil.properties(taxAgentList, TaxAgentPO::getId, Collectors.toList()); + list = list.stream().filter(po -> { + String taxAgentIdsStr = po.getTaxAgentIds(); + List taxAgentIds = new ArrayList<>(); + if (StringUtils.isNotBlank(taxAgentIdsStr)) { + taxAgentIds = Arrays.stream(taxAgentIdsStr.split(",")).map(Long::valueOf).collect(Collectors.toList()); + } + return StringUtils.isBlank(po.getSharedType()) || SharedTypeEnum.PUBLIC.getValue().equals(po.getSharedType()) || (SharedTypeEnum.PRIVATE.getValue().equals(po.getSharedType()) && SalaryEntityUtil.judgeIntersection(authTaxAgentIds, taxAgentIds)); + }).collect(Collectors.toList()); + return list; + } + + /** + * 社保缴纳组织 + * + * @return + */ + public List paymentOrganizationOptions(Collection taxAgentPOS) { + Collection list = taxAgentPOS; + if (org.apache.commons.collections.CollectionUtils.isEmpty(list)) { + return new ArrayList<>(); + } + return list + .stream() + .map(item -> new SearchConditionOption(String.valueOf(item.getId()), item.getName())).collect(Collectors.toList()); + } + + /** + * 其它基础表单 + * + * @param employeeId + * @return + */ + public InsuranceArchivesOtherSchemeDTO buildOtherForm(Long employeeId, Long paymentOrganization) { + + List otherList = getOtherSchemeMapper().getOtherByEmployeeIdAndPayOrg(InsuranceArchivesEmployeePO.builder() + .employeeId(employeeId) + .paymentOrganization(paymentOrganization) + .build()); + encryptUtil.decryptList(otherList, InsuranceArchivesOtherSchemePO.class); + InsuranceArchivesOtherSchemePO insuranceArchivesOtherSchemePO = otherList.size() != 0 ? otherList.get(0) : null; + InsuranceArchivesOtherSchemeDTO data = InsuranceArchivesBO.convertOtherPOtoDTO(insuranceArchivesOtherSchemePO, employeeId); + if (insuranceArchivesOtherSchemePO == null) { + data.setEmployeeId(employeeId); + data.setUnderTake(UndertakerEnum.SCOPE_PERSON.getValue().toString()); + } + return data; + } + + /** + * 公积金基础表单 + * + * @param employeeId + * @return + */ + public InsuranceArchivesFundSchemeDTO buildFundForm(Long employeeId, Long paymentOrganization) { + + List fundList = getFundSchemeMapper().getFundByEmployeeIdAndPayOrg(InsuranceArchivesEmployeePO.builder() + .employeeId(employeeId) + .paymentOrganization(paymentOrganization) + .build()); + encryptUtil.decryptList(fundList, InsuranceArchivesFundSchemePO.class); + InsuranceArchivesFundSchemePO insuranceArchivesFundSchemePO = fundList.size() != 0 ? fundList.get(0) : null; + InsuranceArchivesFundSchemeDTO data = InsuranceArchivesBO.convertFundPOtoDTO(insuranceArchivesFundSchemePO, employeeId); + if (insuranceArchivesFundSchemePO == null) { + data.setEmployeeId(employeeId); + data.setUnderTake(UndertakerEnum.SCOPE_PERSON.getValue().toString()); + } + return data; + } + + /** + * 社保基础表单 + * + * @param employeeId + * @return + */ + public InsuranceArchivesSocialSchemeDTO buildSocialForm(Long employeeId, Long paymentOrganization) { + InsuranceArchivesSocialSchemePO insuranceArchivesSocialSchemePO = getSocialByEmployeeId(employeeId, paymentOrganization); + InsuranceArchivesSocialSchemeDTO data = InsuranceArchivesBO.convertSocialPOtoDTO(insuranceArchivesSocialSchemePO, employeeId); + if (insuranceArchivesSocialSchemePO == null) { + data.setEmployeeId(employeeId); + data.setUnderTake(UndertakerEnum.SCOPE_PERSON.getValue().toString()); + } + return data; + } + + /** + * 获取社保档案表 + * + * @param employeeId + * @return + */ + public InsuranceArchivesSocialSchemePO getSocialByEmployeeId(Long employeeId, Long paymentOrganization) { + + List socialList = getSocialSchemeMapper().getSocialByEmployeeIdAndPayOrg(InsuranceArchivesEmployeePO.builder() + .employeeId(employeeId) + .paymentOrganization(paymentOrganization) + .build()); + encryptUtil.decryptList(socialList, InsuranceArchivesSocialSchemePO.class); + return socialList.size() != 0 ? socialList.get(0) : null; + } + + /** + * 获取详细表单 + * + * @param user + * @param welfareType + * @param employeeId + * @param schemeId + * @return + */ + public Map getPaymentForm(User user, WelfareTypeEnum welfareType, Long employeeId, Long schemeId, Long paymentOrganization) { + Map data = new HashMap<>(16); + //判断是否要区分个人和单位福利基数 + SalarySysConfPO welBaseDiff = getSalarySysConfService(user).getOneByCode(WEL_BASE_DIFF_BY_PER_AND_COM); + boolean welBaseDiffSign = welBaseDiff != null && welBaseDiff.getConfValue().equals(OpenEnum.OPEN.getValue()); + //判断是否要自动调整基数 + SalarySysConfPO welBaseAutoAdjust = getSalarySysConfService(user).getOneByCode(WEL_BASE_AUTO_ADJUST); + boolean welBaseAutoAdjustSign = welBaseAutoAdjust != null && welBaseAutoAdjust.getConfValue().equals(OpenEnum.OPEN.getValue()); + + switch (welfareType) { + case SOCIAL_SECURITY: + data = buildSocialPaymentForm(user, employeeId, schemeId,welfareType.getValue(), paymentOrganization, welBaseDiffSign, welBaseAutoAdjustSign); + break; + case ACCUMULATION_FUND: + data = buildFundPaymentForm(user, employeeId, schemeId, welfareType.getValue(), paymentOrganization, welBaseDiffSign, welBaseAutoAdjustSign); + break; + case OTHER: + data = buildOtherPaymentForm(user, employeeId, schemeId, welfareType.getValue(), paymentOrganization, welBaseDiffSign, welBaseAutoAdjustSign); + break; + default: + } + return data; + } + + /** + * 其他payForm + * + * @param employeeId + * @param schemeId + * @return + */ + public Map buildOtherPaymentForm(User user, Long employeeId, Long schemeId, Integer welfareType, Long paymentOrganization, boolean welBaseDiffSign, boolean welBaseAutoAdjustSign) { + Map dataMap = new HashMap<>(); + InsuranceArchivesOtherSchemeDTO data = buildOtherForm(employeeId, paymentOrganization); + Map insuranceValueMap = new HashMap<>(); + Map insuranceComValueMap = new HashMap<>(); + if (data != null) { + insuranceValueMap = StrUtil.isNotBlank(data.getOtherPaymentBaseString()) + ? JSONObject.parseObject(data.getOtherPaymentBaseString(), new TypeReference>() {}) : new HashMap<>(); + if (welBaseDiffSign) { + insuranceComValueMap = StrUtil.isNotBlank(data.getOtherPaymentComBaseString()) + ? JSONObject.parseObject(data.getOtherPaymentComBaseString(), new TypeReference>() {}) : new HashMap<>(); + } + } + List addGroups = new ArrayList<>(); + List inputItems = buildPaymentBase(user, schemeId, welfareType, welBaseDiffSign); + //如果查询结果中存在 方案中缺失福利险种的值,设置初始值 + for (SearchConditionItem item : inputItems) { + String insuranceId = item.getDomkey().length > 0 ? item.getDomkey()[0] : null; + if (StrUtil.isNotBlank(insuranceId) && insuranceValueMap.get(insuranceId) == null) { + String basicValue = welBaseAutoAdjustSign ? ("0.000".equals(item.getMin()) ? "0" : item.getMin()) : "0"; + insuranceValueMap.put(insuranceId, basicValue); + } + } + dataMap.put("data", insuranceValueMap); + addGroups.add(new SearchConditionGroup(SalaryI18nUtil.getI18nLabel(0, "其他福利缴纳基数"), true, inputItems)); + dataMap.put("items", addGroups); + if (welBaseDiffSign) { + List addComGroups = new ArrayList<>(); + List inputComItems = buildPaymentComBase(user, schemeId, welfareType); + addComGroups.add(new SearchConditionGroup(SalaryI18nUtil.getI18nLabel(0, "其他福利缴纳基数"), true, inputComItems)); + dataMap.put("comItems", addComGroups); + + for (SearchConditionItem item : inputComItems) { + String insuranceId = item.getDomkey().length > 0 ? item.getDomkey()[0] : null; + if (StrUtil.isNotBlank(insuranceId) && insuranceComValueMap.get(insuranceId) == null) { + String basicValue = welBaseAutoAdjustSign ? ("0.000".equals(item.getMin()) ? "0" : item.getMin()) : "0"; + insuranceComValueMap.put(insuranceId, basicValue); + } + } + dataMap.put("comData", insuranceComValueMap); + } + return dataMap; + } + + /** + * 公积金payForm + * + * @param employeeId + * @param schemeId + * @return + */ + public Map buildFundPaymentForm(User user, Long employeeId, Long schemeId, Integer welfareType, Long paymentOrganization, boolean welBaseDiffSign, boolean welBaseAutoAdjustSign) { + + Map dataMap = new HashMap<>(); + InsuranceArchivesFundSchemeDTO data = buildFundForm(employeeId, paymentOrganization); + Map insuranceValueMap = new HashMap<>(); + Map insuranceComValueMap = new HashMap<>(); + if (data != null) { + insuranceValueMap = StrUtil.isNotBlank(data.getFundPaymentBaseString()) + ? JSONObject.parseObject(data.getFundPaymentBaseString(), new TypeReference>() {}) : new HashMap<>(); + if (welBaseDiffSign) { + insuranceComValueMap = StrUtil.isNotBlank(data.getFundPaymentComBaseString()) + ? JSONObject.parseObject(data.getFundPaymentComBaseString(), new TypeReference>() {}) : new HashMap<>(); + } + } + + List addGroups = new ArrayList<>(); + List inputItems = buildPaymentBase(user, schemeId, welfareType, welBaseDiffSign); + //如果查询结果中存在 方案中缺失福利险种的值,设置初始值 + for (SearchConditionItem item : inputItems) { + String insuranceId = item.getDomkey().length > 0 ? item.getDomkey()[0] : null; + if (StrUtil.isNotBlank(insuranceId) && insuranceValueMap.get(insuranceId) == null) { + String basicValue = welBaseAutoAdjustSign ? ("0.000".equals(item.getMin()) ? "0" : item.getMin()) : "0"; + insuranceValueMap.put(insuranceId, basicValue); + } + } + dataMap.put("data", insuranceValueMap); + addGroups.add(new SearchConditionGroup(SalaryI18nUtil.getI18nLabel(0, "公积金缴纳基数"), true, inputItems)); + dataMap.put("items", addGroups); + if (welBaseDiffSign) { + List addComGroups = new ArrayList<>(); + List inputComItems = buildPaymentComBase(user, schemeId, welfareType); + addComGroups.add(new SearchConditionGroup(SalaryI18nUtil.getI18nLabel(0, "公积金缴纳基数"), true, inputComItems)); + dataMap.put("comItems", addComGroups); + + for (SearchConditionItem item : inputComItems) { + String insuranceId = item.getDomkey().length > 0 ? item.getDomkey()[0] : null; + if (StrUtil.isNotBlank(insuranceId) && insuranceComValueMap.get(insuranceId) == null) { + String basicValue = welBaseAutoAdjustSign ? ("0.000".equals(item.getMin()) ? "0" : item.getMin()) : "0"; + insuranceComValueMap.put(insuranceId, basicValue); + } + } + dataMap.put("comData", insuranceComValueMap); + } + return dataMap; + } + + /** + * 社保payForm + * + * @param employeeId + * @param schemeId + * @return + */ + public Map buildSocialPaymentForm(User user, Long employeeId, Long schemeId, Integer welfareType, Long paymentOrganization, boolean welBaseDiffSign, boolean welBaseAutoAdjustSign) { + Map dataMap = new HashMap<>(); + InsuranceArchivesSocialSchemeDTO data = buildSocialForm(employeeId, paymentOrganization); + Map insuranceValueMap = new HashMap<>(); + Map insuranceComValueMap = new HashMap<>(); + if (data != null) { + insuranceValueMap = StrUtil.isNotBlank(data.getSchemePaymentBaseString()) + ? JSONObject.parseObject(data.getSchemePaymentBaseString(), new TypeReference>() {}) : new HashMap<>(); + if (welBaseDiffSign) { + insuranceComValueMap = StrUtil.isNotBlank(data.getSchemePaymentComBaseString()) + ? JSONObject.parseObject(data.getSchemePaymentComBaseString(), new TypeReference>() {}) : new HashMap<>(); + } + } + + List addGroups = new ArrayList<>(); + List inputItems = buildPaymentBase(user, schemeId, welfareType, welBaseDiffSign); + //如果查询结果中存在 方案中缺失福利险种的值,设置初始值 + for (SearchConditionItem item : inputItems) { + String insuranceId = item.getDomkey().length > 0 ? item.getDomkey()[0] : null; + if (StrUtil.isNotBlank(insuranceId) && insuranceValueMap.get(insuranceId) == null) { + String basicValue = welBaseAutoAdjustSign ? ("0.000".equals(item.getMin()) ? "0" : item.getMin()) : "0"; + insuranceValueMap.put(insuranceId, basicValue); + } + } + dataMap.put("data", insuranceValueMap); + addGroups.add(new SearchConditionGroup(SalaryI18nUtil.getI18nLabel(0, "社保缴纳基数"), true, inputItems)); + dataMap.put("items", addGroups); + if (welBaseDiffSign) { + List addComGroups = new ArrayList<>(); + List inputComItems = buildPaymentComBase(user, schemeId, welfareType); + addComGroups.add(new SearchConditionGroup(SalaryI18nUtil.getI18nLabel(0, "社保缴纳基数"), true, inputComItems)); + dataMap.put("comItems", addComGroups); + + for (SearchConditionItem item : inputComItems) { + String insuranceId = item.getDomkey().length > 0 ? item.getDomkey()[0] : null; + if (StrUtil.isNotBlank(insuranceId) && insuranceComValueMap.get(insuranceId) == null) { + String basicValue = welBaseAutoAdjustSign ? ("0.000".equals(item.getMin()) ? "0" : item.getMin()) : "0"; + insuranceComValueMap.put(insuranceId, basicValue); + } + } + dataMap.put("comData", insuranceComValueMap); + } + return dataMap; + + } + + /** + * 构造payment(items) + * + * @param schemeId + * @return + */ + public List buildPaymentBase(User user, Long schemeId, Integer welfareType, boolean welBaseDiffSign) { + List inputItems = new ArrayList<>(); + if (schemeId == null) { + return new ArrayList<>(); + } + List list = queryListByPrimaryIdIsPayment(schemeId, welfareType).stream() + .filter(f -> f.getPaymentScope().equals(PaymentScopeEnum.SCOPE_PERSON.getValue())).collect(Collectors.toList()); + if (!welBaseDiffSign) { + List perInsuranceIdList = list.stream().map(InsuranceSchemeDetailPO::getInsuranceId).collect(Collectors.toList()); + List moreComList = queryListByPrimaryIdIsPayment(schemeId, welfareType).stream() + .filter(f -> f.getPaymentScope().equals(PaymentScopeEnum.SCOPE_COMPANY.getValue()) && !perInsuranceIdList.contains(f.getInsuranceId())).collect(Collectors.toList()); + if (moreComList.size() > 0) { + list.addAll(moreComList); + } + } + + list.forEach(insuranceSchemeDetail -> { +// ICategoryPO iCategoryPO = siCategoryBiz.getByID(insuranceSchemeDetail.getInsuranceId()); + ICategoryPO iCategoryPO = getSICategoryService(user).getICategoryPOByID(insuranceSchemeDetail.getInsuranceId()); + if (iCategoryPO != null) { +// inputItems.add(SalaryFormItemUtil.inputNumberItem(user, "precision:2", 2, 12, 2, iCategoryPO.getInsuranceName(), String.valueOf(insuranceSchemeDetail.getInsuranceId()))); + inputItems.add(SalaryFormItemUtil.inputNumberItemWithMaxAndMin(user, "precision:2", 2, 12, 2, iCategoryPO.getInsuranceName(), String.valueOf(insuranceSchemeDetail.getInsuranceId()) + , insuranceSchemeDetail.getUpperLimit(), insuranceSchemeDetail.getLowerLimit())); + } + }); + return inputItems; + } + + public List buildPaymentComBase(User user, Long schemeId, Integer welfareType) { + List inputItems = new ArrayList<>(); + if (schemeId == null) { + return new ArrayList<>(); + } + List list = queryListByPrimaryIdIsPayment(schemeId, welfareType).stream() + .filter(f -> f.getPaymentScope().equals(PaymentScopeEnum.SCOPE_COMPANY.getValue())).collect(Collectors.toList()); + list.forEach(insuranceSchemeDetail -> { +// ICategoryPO iCategoryPO = siCategoryBiz.getByID(insuranceSchemeDetail.getInsuranceId()); + ICategoryPO iCategoryPO = getSICategoryService(user).getICategoryPOByID(insuranceSchemeDetail.getInsuranceId()); + if (iCategoryPO != null) { +// inputItems.add(SalaryFormItemUtil.inputNumberItem(user, "precision:2", 2, 12, 2, iCategoryPO.getInsuranceName(), String.valueOf(insuranceSchemeDetail.getInsuranceId()))); + inputItems.add(SalaryFormItemUtil.inputNumberItemWithMaxAndMin(user, "precision:2", 2, 12, 2, iCategoryPO.getInsuranceName(), String.valueOf(insuranceSchemeDetail.getInsuranceId()) + , insuranceSchemeDetail.getUpperLimit(), insuranceSchemeDetail.getLowerLimit())); + } + }); + return inputItems; + } + + /** + * 获取方案明细 + * + * @param schemeId + * @return + */ + public List queryListByPrimaryIdIsPayment(Long schemeId, Integer welfareType) { + + List insuranceSchemeDetailPOS = getInsuranceSchemeDetailMapper().queryListByPrimaryIdIsPayment(schemeId, IsPaymentEnum.YES.getValue(), welfareType); + encryptUtil.decryptList(insuranceSchemeDetailPOS, InsuranceSchemeDetailPO.class); + return insuranceSchemeDetailPOS; + } + + public void otherSave(InsuranceArchivesSaveParam paramReq, User user, boolean welBaseDiffSign) { + long employeeId = user.getUID(); + InsuranceArchivesOtherSaveParam param = JSONObject.parseObject(paramReq.getBaseForm(), InsuranceArchivesOtherSaveParam.class); + SalaryAssert.notNull(SalaryI18nUtil.getI18nLabel(0, "员工id为空"), param, param.getEmployeeId()); + + if (org.apache.commons.lang.StringUtils.isNotBlank(param.getOtherStartTime()) && !SalaryDateUtil.checkYearMonth(param.getOtherStartTime())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "其他福利起始缴纳时间格式错误,正确格式为YYYY-MM或者yyyy-MM-dd")); + } + if (org.apache.commons.lang.StringUtils.isNotBlank(param.getOtherEndTime()) && !SalaryDateUtil.checkYearMonth(param.getOtherEndTime())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "其他福利最后缴纳时间格式错误,正确格式为YYYY-MM或者yyyy-MM-dd")); + } + //创建操作日志记录对象 + InsuranceArchivesBaseInfoPO targetPO = new InsuranceArchivesBaseInfoPO(); + InsuranceArchivesOtherSchemePO targetDetailPO = new InsuranceArchivesOtherSchemePO(); + + List otherIds = new ArrayList(); + otherIds.add(param.getId()); + List oldOtherInfoList = getOtherSchemeMapper().getOtherById(otherIds); + //设置福利档案基数调整记录数据 + InsuranceArchivesBaseHistoryDTO adjustInfo = InsuranceArchivesBaseHistoryDTO.builder() + .adjustAfterSchemeId(param.getOtherSchemeId()) + .adjustAfterBaseJson(paramReq.getPaymentForm()) + .adjustAfterComBaseJson(paramReq.getPaymentComForm()) + .welfareType(paramReq.getWelfareType().getValue()) + .employeeId(param.getEmployeeId()) + .paymentOrganization(param.getPaymentOrganization()) + .build(); + + String combineErrorMsg = ""; + if (oldOtherInfoList.size() == 1) { + InsuranceArchivesOtherSchemePO oldOtherInfo = oldOtherInfoList.get(0); + //设置福利档案基数调整记录数据 + encryptUtil.decrypt(oldOtherInfo, InsuranceArchivesOtherSchemePO.class); + adjustInfo.setAdjustBeforeBaseJson(oldOtherInfo.getOtherPaymentBaseString()); + adjustInfo.setAdjustBeforeSchemeId(oldOtherInfo.getOtherSchemeId()); + adjustInfo.setAdjustBeforeComBaseJson(oldOtherInfo.getOtherPaymentComBaseString()); + //新数据 + InsuranceArchivesOtherSchemePO updateOtherInfo = + InsuranceArchivesOtherSchemePO.builder() + .id(oldOtherInfo.getId()) + .otherSchemeId(param.getOtherSchemeId()) + .otherStartTime(org.apache.commons.lang.StringUtils.isNotBlank(param.getOtherStartTime()) ? param.getOtherStartTime() : null) + .underTake(param.getUnderTake()) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .welfareType(paramReq.getWelfareType().getValue()) + .otherEndTime(org.apache.commons.lang.StringUtils.isNotBlank(param.getOtherEndTime()) ? param.getOtherEndTime() : null) + .employeeId(param.getEmployeeId()) + .deleteType(DeleteTypeEnum.NOT_DELETED.getValue()) + .createTime(oldOtherInfo.getCreateTime()) + .updateTime(new Date()) + .nonPayment(param.getNonPayment()) + .creator(employeeId) + .paymentOrganization(param.getPaymentOrganization()) + .otherPaymentBaseString(paramReq.getPaymentForm()) + .build(); + //校验福利基数是否符合上下限要求, + if (paramReq.getChangeData() != null && paramReq.getChangeData()) { + // 将不满足上下限基数修改为上限或下限 + String otherPaymentBaseString = adaptWelBaseLimit(updateOtherInfo.getOtherSchemeId(), updateOtherInfo.getOtherPaymentBaseString(), PaymentScopeEnum.SCOPE_PERSON.getValue()); + if (otherPaymentBaseString != null) { + updateOtherInfo.setOtherPaymentBaseString(otherPaymentBaseString); + } + } else { + StringBuilder errorMsg = new StringBuilder(""); + if (!checkWelBaseLimit(updateOtherInfo.getOtherSchemeId(),updateOtherInfo.getOtherPaymentBaseString(), PaymentScopeEnum.SCOPE_PERSON.getValue(), errorMsg)) { + // throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"其他福利明细中的基数更新内容不符合相关基数上下限要求,请检查后重试!")); + combineErrorMsg = "其他福利个人: " + errorMsg; + } + } + //需要拆分个人和公司福利基数时 + if (welBaseDiffSign) { + updateOtherInfo.setOtherPaymentComBaseString(paramReq.getPaymentComForm()); + //校验福利基数是否符合上下限要求 + if (paramReq.getChangeData() != null && paramReq.getChangeData()) { + // 将不满足上下限基数修改为上限或下限 + String otherPaymentComBaseString = adaptWelBaseLimit(updateOtherInfo.getOtherSchemeId(), updateOtherInfo.getOtherPaymentComBaseString(), PaymentScopeEnum.SCOPE_COMPANY.getValue()); + if (otherPaymentComBaseString != null) { + updateOtherInfo.setOtherPaymentComBaseString(otherPaymentComBaseString); + } + } else { + StringBuilder errorMsg = new StringBuilder(""); + if (!checkWelBaseLimit(updateOtherInfo.getOtherSchemeId(),updateOtherInfo.getOtherPaymentComBaseString(), PaymentScopeEnum.SCOPE_COMPANY.getValue(), errorMsg)) { + // throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"其他福利明细中的基数更新内容不符合相关基数上下限要求,请检查后重试!")); + combineErrorMsg += "其他福利公司:" + errorMsg; + } + } + } + if (StringUtils.isNotBlank(combineErrorMsg)) { + throw new SalaryRunTimeException(combineErrorMsg); + } + encryptUtil.encrypt(updateOtherInfo, InsuranceArchivesOtherSchemePO.class); + getOtherSchemeMapper().updateById(updateOtherInfo); + //更新base_info表状态 + InsuranceArchivesBaseInfoPO baseInfoPO = getInsuranceBaseInfoMapper().getOneByEmployeeIdAndPayOrg(param.getPaymentOrganization(), param.getEmployeeId()); + if(baseInfoPO != null && baseInfoPO.getEmployeeType() != null && baseInfoPO.getEmployeeType().equals(DataCollectionEmployeeTypeEnum.EXT_EMPLOYEE.getValue())) { + //对于非系统人员,编辑后状态切换为正在缴纳 + baseInfoPO.setRunStatus(EmployeeStatusEnum.PAYING.getValue()); + } + baseInfoPO.setOtherArchivesId(updateOtherInfo.getId()); + getInsuranceBaseInfoMapper().updateById(baseInfoPO); + + targetPO = baseInfoPO; + encryptUtil.decrypt(updateOtherInfo, InsuranceArchivesOtherSchemePO.class); + targetDetailPO = updateOtherInfo; + } else { + getOtherSchemeMapper().deleteByEmployeeIdAndPayOrg(InsuranceArchivesOtherSchemePO.builder() + .employeeId(param.getEmployeeId()) + .paymentOrganization(param.getPaymentOrganization()) + .build()); + //新建社保档案,并关联主表 + InsuranceArchivesOtherSchemePO insertOtherInfo = InsuranceArchivesOtherSchemePO.builder() + .otherSchemeId(param.getOtherSchemeId()) + .otherStartTime(org.apache.commons.lang.StringUtils.isNotBlank(param.getOtherStartTime()) ? param.getOtherStartTime() : null) + .underTake(param.getUnderTake()) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .welfareType(paramReq.getWelfareType().getValue()) + .otherEndTime(org.apache.commons.lang.StringUtils.isNotBlank(param.getOtherEndTime()) ? param.getOtherEndTime() : null) + .employeeId(param.getEmployeeId()) + .deleteType(DeleteTypeEnum.NOT_DELETED.getValue()) + .createTime(new Date()) + .updateTime(new Date()) + .nonPayment(param.getNonPayment()) + .creator(employeeId) + .paymentOrganization(param.getPaymentOrganization()) + .otherPaymentBaseString(paramReq.getPaymentForm()) + .build(); + //校验福利基数是否符合上下限要求, + if (paramReq.getChangeData() != null && paramReq.getChangeData()) { + // 将不满足上下限基数修改为上限或下限 + String otherPaymentBaseString = adaptWelBaseLimit(insertOtherInfo.getOtherSchemeId(), insertOtherInfo.getOtherPaymentBaseString(), PaymentScopeEnum.SCOPE_PERSON.getValue()); + if (otherPaymentBaseString != null) { + insertOtherInfo.setOtherPaymentBaseString(otherPaymentBaseString); + } + } else { + StringBuilder errorMsg = new StringBuilder(""); + if (!checkWelBaseLimit(insertOtherInfo.getOtherSchemeId(),insertOtherInfo.getOtherPaymentBaseString(), PaymentScopeEnum.SCOPE_PERSON.getValue(), errorMsg)) { + // throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"其他福利明细中的基数更新内容不符合相关基数上下限要求,请检查后重试!")); + combineErrorMsg = "其他福利个人:" + errorMsg; + } + } + //需要拆分个人和公司福利基数时 + if (welBaseDiffSign) { + insertOtherInfo.setOtherPaymentComBaseString(paramReq.getPaymentComForm()); + if (paramReq.getChangeData() != null && paramReq.getChangeData()) { + // 将不满足上下限基数修改为上限或下限 + String otherPaymentComBaseString = adaptWelBaseLimit(insertOtherInfo.getOtherSchemeId(), insertOtherInfo.getOtherPaymentComBaseString(), PaymentScopeEnum.SCOPE_COMPANY.getValue()); + if (otherPaymentComBaseString != null) { + insertOtherInfo.setOtherPaymentComBaseString(otherPaymentComBaseString); + } + } else { + StringBuilder errorMsg = new StringBuilder(""); + //校验福利基数是否符合上下限要求 + if (!checkWelBaseLimit(insertOtherInfo.getOtherSchemeId(),insertOtherInfo.getOtherPaymentComBaseString(), PaymentScopeEnum.SCOPE_COMPANY.getValue(), errorMsg)) { + // throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"其他福利明细中的基数更新内容不符合相关基数上下限要求,请检查后重试!")); + combineErrorMsg += "其他福利公司:" + errorMsg; + } + } + } + if (StringUtils.isNotBlank(combineErrorMsg)) { + throw new SalaryRunTimeException(combineErrorMsg); + } + encryptUtil.encrypt(insertOtherInfo, InsuranceArchivesOtherSchemePO.class); + getOtherSchemeMapper().insert(insertOtherInfo); + + InsuranceArchivesBaseInfoPO baseInfoPO = getInsuranceBaseInfoMapper().getOneByEmployeeIdAndPayOrg(param.getPaymentOrganization(), param.getEmployeeId()); + if(baseInfoPO != null) { + List otherInfos = getOtherSchemeMapper().getOtherByEmployeeIdAndPayOrg(InsuranceArchivesEmployeePO.builder() + .employeeId(param.getEmployeeId()) + .paymentOrganization(param.getPaymentOrganization()) + .build()); + baseInfoPO.setOtherArchivesId(otherInfos.get(0).getId()); + //对于非系统人员,编辑后状态切换为正在缴纳 + if (baseInfoPO.getEmployeeType() != null && baseInfoPO.getEmployeeType().equals(DataCollectionEmployeeTypeEnum.EXT_EMPLOYEE.getValue())) { + baseInfoPO.setRunStatus(EmployeeStatusEnum.PAYING.getValue()); + } + getInsuranceBaseInfoMapper().updateById(baseInfoPO); + + targetPO = baseInfoPO; + encryptUtil.decrypt(insertOtherInfo, InsuranceArchivesOtherSchemePO.class); + targetDetailPO = insertOtherInfo; + } else { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "档案不存在!")); + } + } + //记录操作日志 + DataCollectionEmployee empInfo = getSalaryEmployeeService(user).getEmployeeById(targetDetailPO.getEmployeeId()); + TaxAgentPO taxAgentInfo = getTaxAgentMapper().getById(targetPO.getPaymentOrganization()); + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(targetPO.getId())); + loggerContext.setTargetName(taxAgentInfo.getName() + "-" + empInfo.getUsername()); + loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "福利档案-其他福利明细保存")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "福利档案-其他福利明细保存") + ": " + taxAgentInfo.getName() + "-" + empInfo.getUsername()); + if (oldOtherInfoList.size() == 1) { + loggerContext.setOldValues(oldOtherInfoList.get(0)); + } + loggerContext.setNewValues(targetDetailPO); + SalaryElogConfig.siArchivesLoggerTemplate.write(loggerContext); + //生成福利档案基数调整记录数据 + List adjustHistoryList = createAdjustInfo(adjustInfo, employeeId); + //福利档案基数调整记录数据入库 + batchInsertAdjustHistory(adjustHistoryList); + + } + + /** + * @param paramReq + * @param + */ + public void fundSave(InsuranceArchivesSaveParam paramReq, User user, boolean welBaseDiffSign) { + long employeeId = user.getUID(); + InsuranceArchivesFundSaveParam param = JSONObject.parseObject(paramReq.getBaseForm(), InsuranceArchivesFundSaveParam.class); + SalaryAssert.notNull(SalaryI18nUtil.getI18nLabel(0,"员工id为空"), param, param.getEmployeeId()); + + if (org.apache.commons.lang.StringUtils.isNotBlank(param.getFundStartTime()) && !SalaryDateUtil.checkYearMonth(param.getFundStartTime())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "公积金起始缴纳时间格式错误,正确格式为YYYY-MM或者yyyy-MM-dd")); + } + if (org.apache.commons.lang.StringUtils.isNotBlank(param.getFundEndTime()) && !SalaryDateUtil.checkYearMonth(param.getFundEndTime())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "公积金最后缴纳时间格式错误,正确格式为YYYY-MM或者yyyy-MM-dd")); + } + //创建操作日志记录对象 + InsuranceArchivesBaseInfoPO targetPO = new InsuranceArchivesBaseInfoPO(); + InsuranceArchivesFundSchemePO targetDetailPO = new InsuranceArchivesFundSchemePO(); + + List fundIds = new ArrayList(); + fundIds.add(param.getId()); + List oldFundInfoList = getFundSchemeMapper().getFundById(fundIds); + //设置福利档案基数调整记录数据 + InsuranceArchivesBaseHistoryDTO adjustInfo = InsuranceArchivesBaseHistoryDTO.builder() + .adjustAfterSchemeId(param.getFundSchemeId()) + .adjustAfterBaseJson(paramReq.getPaymentForm()) + .adjustAfterComBaseJson(paramReq.getPaymentComForm()) + .welfareType(paramReq.getWelfareType().getValue()) + .employeeId(param.getEmployeeId()) + .paymentOrganization(param.getPaymentOrganization()) + .build(); + + String combineErrorMsg = ""; + if (oldFundInfoList.size() == 1) { + InsuranceArchivesFundSchemePO oldFundInfo = oldFundInfoList.get(0); + //设置福利档案基数调整记录数据 + encryptUtil.decrypt(oldFundInfo, InsuranceArchivesFundSchemePO.class); + adjustInfo.setAdjustBeforeBaseJson(oldFundInfo.getFundPaymentBaseString()); + adjustInfo.setAdjustBeforeSchemeId(oldFundInfo.getFundSchemeId()); + adjustInfo.setAdjustBeforeComBaseJson(oldFundInfo.getFundPaymentComBaseString()); + //新数据 + InsuranceArchivesFundSchemePO updateFundInfo = InsuranceArchivesFundSchemePO.builder() + .id(oldFundInfo.getId()) + .fundSchemeId(param.getFundSchemeId()) + .fundAccount(param.getFundAccount()) + .fundEndTime(org.apache.commons.lang.StringUtils.isNotBlank(param.getFundEndTime()) ? param.getFundEndTime() : null) + .fundStartTime(org.apache.commons.lang.StringUtils.isNotBlank(param.getFundStartTime()) ? param.getFundStartTime() : null) + .fundPaymentBaseString(paramReq.getPaymentForm()) + .supplementFundAccount(param.getSupplementFundAccount()) + .creator(employeeId) + .nonPayment(param.getNonPayment()) + .deleteType(DeleteTypeEnum.NOT_DELETED.getValue()) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .underTake(param.getUnderTake()) + .paymentOrganization(param.getPaymentOrganization()) + .createTime(oldFundInfo.getCreateTime()) + .updateTime(new Date()) + .welfareType(paramReq.getWelfareType().getValue()) + .employeeId(param.getEmployeeId()) + .build(); + //校验福利基数是否符合上下限要求, + if (paramReq.getChangeData() != null && paramReq.getChangeData()) { + // 将不满足上下限基数修改为上限或下限 + String fundPaymentBaseString = adaptWelBaseLimit(updateFundInfo.getFundSchemeId(), updateFundInfo.getFundPaymentBaseString(), PaymentScopeEnum.SCOPE_PERSON.getValue()); + if (fundPaymentBaseString != null) { + updateFundInfo.setFundPaymentBaseString(fundPaymentBaseString); + } + } else { + StringBuilder errorMsg = new StringBuilder(""); + if (!checkWelBaseLimit(updateFundInfo.getFundSchemeId(),updateFundInfo.getFundPaymentBaseString(), PaymentScopeEnum.SCOPE_PERSON.getValue(), errorMsg)) { + // throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"公积金福利明细中的基数更新内容不符合相关基数上下限要求,请检查后重试!")); + combineErrorMsg = "公积金个人" + errorMsg; + } + } + + //需要拆分个人和公司福利基数时 + if (welBaseDiffSign) { + updateFundInfo.setFundPaymentComBaseString(paramReq.getPaymentComForm()); + //校验福利基数是否符合上下限要求 + if (paramReq.getChangeData() != null && paramReq.getChangeData()) { + // 将不满足上下限基数修改为上限或下限 + String fundPaymentComBaseString = adaptWelBaseLimit(updateFundInfo.getFundSchemeId(), updateFundInfo.getFundPaymentComBaseString(), PaymentScopeEnum.SCOPE_COMPANY.getValue()); + if (fundPaymentComBaseString != null) { + updateFundInfo.setFundPaymentComBaseString(fundPaymentComBaseString); + } + } else { + StringBuilder errorMsg = new StringBuilder(""); + if (!checkWelBaseLimit(updateFundInfo.getFundSchemeId(),updateFundInfo.getFundPaymentComBaseString(), PaymentScopeEnum.SCOPE_COMPANY.getValue(), errorMsg)) { + // throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"公积金福利明细中的基数更新内容不符合相关基数上下限要求,请检查后重试!")); + combineErrorMsg += "公积金公司:" + errorMsg; + } + } + } + + if (StringUtils.isNotBlank(combineErrorMsg)) { + throw new SalaryRunTimeException(combineErrorMsg); + } + + encryptUtil.encrypt(updateFundInfo, InsuranceArchivesFundSchemePO.class); + getFundSchemeMapper().updateById(updateFundInfo); + //更新base_info表状态 + InsuranceArchivesBaseInfoPO baseInfoPO = getInsuranceBaseInfoMapper().getOneByEmployeeIdAndPayOrg(param.getPaymentOrganization(), param.getEmployeeId()); + if(baseInfoPO != null && baseInfoPO.getEmployeeType() != null && baseInfoPO.getEmployeeType().equals(DataCollectionEmployeeTypeEnum.EXT_EMPLOYEE.getValue())) { + //对于非系统人员,编辑后状态切换为正在缴纳 + baseInfoPO.setRunStatus(EmployeeStatusEnum.PAYING.getValue()); + } + baseInfoPO.setFundArchivesId(updateFundInfo.getId()); + getInsuranceBaseInfoMapper().updateById(baseInfoPO); + + targetPO = baseInfoPO; + encryptUtil.decrypt(updateFundInfo, InsuranceArchivesFundSchemePO.class); + targetDetailPO = updateFundInfo; + } else { + getFundSchemeMapper().deleteByEmployeeIdAndPayOrg(InsuranceArchivesFundSchemePO.builder() + .employeeId(param.getEmployeeId()) + .paymentOrganization(param.getPaymentOrganization()) + .build()); + //新建社保档案,并关联主表 + InsuranceArchivesFundSchemePO insertFundInfo = InsuranceArchivesFundSchemePO.builder() + .fundSchemeId(param.getFundSchemeId()) + .fundAccount(param.getFundAccount()) + .fundEndTime(org.apache.commons.lang.StringUtils.isNotBlank(param.getFundEndTime()) ? param.getFundEndTime() : null) + .fundStartTime(org.apache.commons.lang.StringUtils.isNotBlank(param.getFundStartTime()) ? param.getFundStartTime() : null) + .fundPaymentBaseString(paramReq.getPaymentForm()) + .supplementFundAccount(param.getSupplementFundAccount()) + .creator(employeeId) + .nonPayment(param.getNonPayment()) + .deleteType(DeleteTypeEnum.NOT_DELETED.getValue()) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .underTake(param.getUnderTake()) + .paymentOrganization(param.getPaymentOrganization()) + .createTime(new Date()) + .updateTime(new Date()) + .welfareType(paramReq.getWelfareType().getValue()) + .employeeId(param.getEmployeeId()) + .build(); + //校验福利基数是否符合上下限要求, + if (paramReq.getChangeData() != null && paramReq.getChangeData()) { + // 将不满足上下限基数修改为上限或下限 + String fundPaymentBaseString = adaptWelBaseLimit(insertFundInfo.getFundSchemeId(), insertFundInfo.getFundPaymentBaseString(), PaymentScopeEnum.SCOPE_PERSON.getValue()); + if (fundPaymentBaseString != null) { + insertFundInfo.setFundPaymentBaseString(fundPaymentBaseString); + } + } else { + StringBuilder errorMsg = new StringBuilder(""); + if (!checkWelBaseLimit(insertFundInfo.getFundSchemeId(),insertFundInfo.getFundPaymentBaseString(), PaymentScopeEnum.SCOPE_PERSON.getValue(), errorMsg)) { + // throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"公积金福利明细中的基数更新内容不符合相关基数上下限要求,请检查后重试!")); + combineErrorMsg = "公积金个人:" + errorMsg; + } + } + + //需要拆分个人和公司福利基数时 + if (welBaseDiffSign) { + insertFundInfo.setFundPaymentComBaseString(paramReq.getPaymentComForm()); + //校验福利基数是否符合上下限要求 + if (paramReq.getChangeData() != null && paramReq.getChangeData()) { + // 将不满足上下限基数修改为上限或下限 + String fundPaymentComBaseString = adaptWelBaseLimit(insertFundInfo.getFundSchemeId(), insertFundInfo.getFundPaymentComBaseString(), PaymentScopeEnum.SCOPE_COMPANY.getValue()); + if (fundPaymentComBaseString != null) { + insertFundInfo.setFundPaymentComBaseString(fundPaymentComBaseString); + } + } else { + StringBuilder errorMsg = new StringBuilder(""); + if (!checkWelBaseLimit(insertFundInfo.getFundSchemeId(),insertFundInfo.getFundPaymentComBaseString(), PaymentScopeEnum.SCOPE_COMPANY.getValue(), errorMsg)) { + // throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"公积金福利明细中的基数更新内容不符合相关基数上下限要求,请检查后重试!")); + combineErrorMsg += "公积金公司:" + errorMsg; + } + } + } + if (StringUtils.isNotBlank(combineErrorMsg)) { + throw new SalaryRunTimeException(combineErrorMsg); + } + encryptUtil.encrypt(insertFundInfo, InsuranceArchivesFundSchemePO.class); + getFundSchemeMapper().insert(insertFundInfo); + + InsuranceArchivesBaseInfoPO baseInfoPO = getInsuranceBaseInfoMapper().getOneByEmployeeIdAndPayOrg(param.getPaymentOrganization(), param.getEmployeeId()); + if(baseInfoPO != null) { + List fundInfos = getFundSchemeMapper().getFundByEmployeeIdAndPayOrg(InsuranceArchivesEmployeePO.builder() + .employeeId(param.getEmployeeId()) + .paymentOrganization(param.getPaymentOrganization()) + .build()); + baseInfoPO.setFundArchivesId(fundInfos.get(0).getId()); + //对于非系统人员,编辑后状态切换为正在缴纳 + if (baseInfoPO.getEmployeeType() != null && baseInfoPO.getEmployeeType().equals(DataCollectionEmployeeTypeEnum.EXT_EMPLOYEE.getValue())) { + baseInfoPO.setRunStatus(EmployeeStatusEnum.PAYING.getValue()); + } + getInsuranceBaseInfoMapper().updateById(baseInfoPO); + + targetPO = baseInfoPO; + encryptUtil.decrypt(insertFundInfo, InsuranceArchivesFundSchemePO.class); + targetDetailPO = insertFundInfo; + } else { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "档案不存在!")); + } + } + //记录操作日志 + DataCollectionEmployee empInfo = getSalaryEmployeeService(user).getEmployeeById(targetPO.getEmployeeId()); + TaxAgentPO taxAgentInfo = getTaxAgentMapper().getById(targetPO.getPaymentOrganization()); + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(targetPO.getId())); + loggerContext.setTargetName(taxAgentInfo.getName() + "-" + empInfo.getUsername()); + loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "福利档案-公积金明细保存")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "福利档案-公积金明细保存") + ": " + taxAgentInfo.getName() + "-" + empInfo.getUsername()); + if (oldFundInfoList.size() == 1) { + loggerContext.setOldValues(oldFundInfoList.get(0)); + } + loggerContext.setNewValues(targetDetailPO); + SalaryElogConfig.siArchivesLoggerTemplate.write(loggerContext); + //生成福利档案基数调整记录数据 + List adjustHistoryList = createAdjustInfo(adjustInfo, employeeId); + //福利档案基数调整记录数据入库 + batchInsertAdjustHistory(adjustHistoryList); + } + + /** + * @param paramReq + * @param + */ + public void socialSave(InsuranceArchivesSaveParam paramReq, User user, boolean welBaseDiffSign) { + long employeeId = user.getUID(); + InsuranceArchivesSocialSaveParam param = JSONObject.parseObject(paramReq.getBaseForm(), InsuranceArchivesSocialSaveParam.class); + SalaryAssert.notNull(SalaryI18nUtil.getI18nLabel(0,"员工id为空"), param, param.getEmployeeId()); + + if (org.apache.commons.lang.StringUtils.isNotBlank(param.getSocialStartTime()) && !SalaryDateUtil.checkYearMonth(param.getSocialStartTime())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "社保起始缴纳时间格式错误,正确格式为YYYY-MM或者yyyy-MM-dd")); + } + if (org.apache.commons.lang.StringUtils.isNotBlank(param.getSocialEndTime()) && !SalaryDateUtil.checkYearMonth(param.getSocialEndTime())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "社保最后缴纳时间格式错误,正确格式为YYYY-MM或者yyyy-MM-dd")); + } + +// //删除社保数据 +// socialSchemeMapper.batchDeleteByEmployeeIds(Collections.singletonList(param.getEmployeeId())); + + //创建操作日志记录对象 + InsuranceArchivesBaseInfoPO targetPO = new InsuranceArchivesBaseInfoPO(); + InsuranceArchivesSocialSchemePO targetDetailPO = new InsuranceArchivesSocialSchemePO(); + //查询已有数据 + List socialIds = new ArrayList(); + socialIds.add(param.getId()); + List oldSocialInfoList = getSocialSchemeMapper().getSocialById(socialIds); + //设置福利档案基数调整记录数据 + InsuranceArchivesBaseHistoryDTO adjustInfo = InsuranceArchivesBaseHistoryDTO.builder() + .adjustAfterSchemeId(param.getSocialSchemeId()) + .adjustAfterBaseJson(paramReq.getPaymentForm()) + .adjustAfterComBaseJson(paramReq.getPaymentComForm()) + .welfareType(paramReq.getWelfareType().getValue()) + .employeeId(param.getEmployeeId()) + .paymentOrganization(param.getPaymentOrganization()) + .build(); + + String combineErrorMsg = ""; + log.info("oldSocialInfoListSize:" + oldSocialInfoList.size()); + //组装新数据 + if (oldSocialInfoList.size() == 1) { + //老数据 + InsuranceArchivesSocialSchemePO oldSocialInfo = oldSocialInfoList.get(0); + //设置福利档案基数调整记录数据 + encryptUtil.decrypt(oldSocialInfo, InsuranceArchivesSocialSchemePO.class); + adjustInfo.setAdjustBeforeBaseJson(oldSocialInfo.getSocialPaymentBaseString()); + adjustInfo.setAdjustBeforeSchemeId(oldSocialInfo.getSocialSchemeId()); + adjustInfo.setAdjustBeforeComBaseJson(oldSocialInfo.getSocialPaymentComBaseString()); + //新数据 + InsuranceArchivesSocialSchemePO updateSocialInfo = + InsuranceArchivesSocialSchemePO.builder() + .id(oldSocialInfo.getId()) + .welfareType(paramReq.getWelfareType().getValue()) + .deleteType(DeleteTypeEnum.NOT_DELETED.getValue()) + .socialPaymentBaseString(paramReq.getPaymentForm()) + .socialSchemeId(param.getSocialSchemeId()) + .socialEndTime(org.apache.commons.lang.StringUtils.isNotBlank(param.getSocialEndTime()) ? param.getSocialEndTime() : null) + .socialStartTime(org.apache.commons.lang.StringUtils.isNotBlank(param.getSocialStartTime()) ? param.getSocialStartTime() : null) + .creator(employeeId) + .nonPayment(param.getNonPayment()) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .employeeId(param.getEmployeeId()) + .createTime(oldSocialInfo.getCreateTime()) + .updateTime(new Date()) + .underTake(param.getUnderTake()) + .socialAccount(param.getSchemeAccount()) + .paymentOrganization(param.getPaymentOrganization()) + .build(); + //校验福利基数是否符合上下限要求 + if (paramReq.getChangeData() != null && paramReq.getChangeData()) { + // 将不满足上下限基数修改为上限或下限 + String socialPaymentBaseString = adaptWelBaseLimit(updateSocialInfo.getSocialSchemeId(), updateSocialInfo.getSocialPaymentBaseString(), PaymentScopeEnum.SCOPE_PERSON.getValue()); + if (socialPaymentBaseString != null) { + updateSocialInfo.setSocialPaymentBaseString(socialPaymentBaseString); + } + } else { + StringBuilder errorMsg = new StringBuilder(""); + if (!checkWelBaseLimit(updateSocialInfo.getSocialSchemeId(),updateSocialInfo.getSocialPaymentBaseString(), PaymentScopeEnum.SCOPE_PERSON.getValue(), errorMsg)) { + // throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"社保福利明细中的基数更新内容不符合相关基数上下限要求,请检查后重试!")); + combineErrorMsg = "社保个人:" + errorMsg; + } + } + + //需要拆分个人和公司福利基数时 + if (welBaseDiffSign) { + updateSocialInfo.setSocialPaymentComBaseString(paramReq.getPaymentComForm()); + //校验福利基数是否符合上下限要求 + if (paramReq.getChangeData() != null && paramReq.getChangeData()) { + // 将不满足上下限基数修改为上限或下限 + String socialPaymentComBaseString = adaptWelBaseLimit(updateSocialInfo.getSocialSchemeId(), updateSocialInfo.getSocialPaymentComBaseString(), PaymentScopeEnum.SCOPE_COMPANY.getValue()); + if (socialPaymentComBaseString != null) { + updateSocialInfo.setSocialPaymentComBaseString(socialPaymentComBaseString); + } + } else { + StringBuilder errorMsg = new StringBuilder(""); + if (!checkWelBaseLimit(updateSocialInfo.getSocialSchemeId(),updateSocialInfo.getSocialPaymentComBaseString(), PaymentScopeEnum.SCOPE_COMPANY.getValue(), errorMsg)) { + // throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"社保福利明细中的基数更新内容不符合相关基数上下限要求,请检查后重试!")); + combineErrorMsg += "社保公司:" + errorMsg; + } + } + } + + if (StringUtils.isNotBlank(combineErrorMsg)) { + throw new SalaryRunTimeException(combineErrorMsg); + } + encryptUtil.encrypt(updateSocialInfo, InsuranceArchivesSocialSchemePO.class); + getSocialSchemeMapper().updateById(updateSocialInfo); + //更新base_info表状态 + InsuranceArchivesBaseInfoPO baseInfoPO = getInsuranceBaseInfoMapper().getOneByEmployeeIdAndPayOrg(param.getPaymentOrganization(), param.getEmployeeId()); + if(baseInfoPO != null && baseInfoPO.getEmployeeType() != null && baseInfoPO.getEmployeeType().equals(DataCollectionEmployeeTypeEnum.EXT_EMPLOYEE.getValue())) { + //对于非系统人员,编辑后状态切换为正在缴纳 + baseInfoPO.setRunStatus(EmployeeStatusEnum.PAYING.getValue()); + } + baseInfoPO.setSocialArchivesId(updateSocialInfo.getId()); + getInsuranceBaseInfoMapper().updateById(baseInfoPO); + + targetPO = baseInfoPO; + encryptUtil.decrypt(updateSocialInfo, InsuranceArchivesSocialSchemePO.class); + targetDetailPO = updateSocialInfo; + } else { + getSocialSchemeMapper().deleteByEmployeeIdAndPayOrg(InsuranceArchivesSocialSchemePO.builder() + .employeeId(param.getEmployeeId()) + .paymentOrganization(param.getPaymentOrganization()) + .build()); + //新建社保档案,并关联主表 + InsuranceArchivesSocialSchemePO insertSocialInfo = + InsuranceArchivesSocialSchemePO.builder() + .welfareType(paramReq.getWelfareType().getValue()) + .deleteType(DeleteTypeEnum.NOT_DELETED.getValue()) + .socialPaymentBaseString(paramReq.getPaymentForm()) + .socialSchemeId(param.getSocialSchemeId()) + .socialEndTime(org.apache.commons.lang.StringUtils.isNotBlank(param.getSocialEndTime()) ? param.getSocialEndTime() : null) + .socialStartTime(org.apache.commons.lang.StringUtils.isNotBlank(param.getSocialStartTime()) ? param.getSocialStartTime() : null) + .creator(employeeId) + .nonPayment(param.getNonPayment()) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .employeeId(param.getEmployeeId()) + .createTime(new Date()) + .updateTime(new Date()) + .underTake(param.getUnderTake()) + .socialAccount(param.getSchemeAccount()) + .paymentOrganization(param.getPaymentOrganization()) + .build(); + //校验福利基数是否符合上下限要求 + if (paramReq.getChangeData() != null && paramReq.getChangeData()) { + // 将不满足上下限基数修改为上限或下限 + String socialPaymentBaseString = adaptWelBaseLimit(insertSocialInfo.getSocialSchemeId(), insertSocialInfo.getSocialPaymentBaseString(), PaymentScopeEnum.SCOPE_PERSON.getValue()); + if (socialPaymentBaseString != null) { + insertSocialInfo.setSocialPaymentBaseString(socialPaymentBaseString); + } + } else { + StringBuilder errorMsg = new StringBuilder(""); + if (!checkWelBaseLimit(insertSocialInfo.getSocialSchemeId(),insertSocialInfo.getSocialPaymentBaseString(), PaymentScopeEnum.SCOPE_PERSON.getValue(), errorMsg)) { + // throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"社保福利明细中的基数更新内容不符合相关基数上下限要求,请检查后重试!")); + combineErrorMsg = "社保个人:" + errorMsg; + } + } + //需要拆分个人和公司福利基数时 + if (welBaseDiffSign) { + insertSocialInfo.setSocialPaymentComBaseString(paramReq.getPaymentComForm()); + //校验福利基数是否符合上下限要求 + if (paramReq.getChangeData() != null && paramReq.getChangeData()) { + // 将不满足上下限基数修改为上限或下限 + String socialPaymentComBaseString = adaptWelBaseLimit(insertSocialInfo.getSocialSchemeId(), insertSocialInfo.getSocialPaymentComBaseString(), PaymentScopeEnum.SCOPE_COMPANY.getValue()); + if (socialPaymentComBaseString != null) { + insertSocialInfo.setSocialPaymentComBaseString(socialPaymentComBaseString); + } + } else { + StringBuilder errorMsg = new StringBuilder(""); + if (!checkWelBaseLimit(insertSocialInfo.getSocialSchemeId(),insertSocialInfo.getSocialPaymentComBaseString(), PaymentScopeEnum.SCOPE_COMPANY.getValue(), errorMsg)) { + combineErrorMsg += "社保公司:" + errorMsg; + // throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"社保福利明细中的基数更新内容不符合相关基数上下限要求,请检查后重试!")); + } + } + } + if (StringUtils.isNotBlank(combineErrorMsg)) { + throw new SalaryRunTimeException(combineErrorMsg); + } + encryptUtil.encrypt(insertSocialInfo, InsuranceArchivesSocialSchemePO.class); + getSocialSchemeMapper().insert(insertSocialInfo); + + InsuranceArchivesBaseInfoPO baseInfoPO = getInsuranceBaseInfoMapper().getOneByEmployeeIdAndPayOrg(param.getPaymentOrganization(), param.getEmployeeId()); + if(baseInfoPO != null) { + List socialInfos = getSocialSchemeMapper().getSocialByEmployeeIdAndPayOrg(InsuranceArchivesEmployeePO.builder() + .employeeId(param.getEmployeeId()) + .paymentOrganization(param.getPaymentOrganization()) + .build()); + baseInfoPO.setSocialArchivesId(socialInfos.get(0).getId()); + //对于非系统人员,编辑后状态切换为正在缴纳 + if (baseInfoPO.getEmployeeType() != null && baseInfoPO.getEmployeeType().equals(DataCollectionEmployeeTypeEnum.EXT_EMPLOYEE.getValue())) { + baseInfoPO.setRunStatus(EmployeeStatusEnum.PAYING.getValue()); + } + getInsuranceBaseInfoMapper().updateById(baseInfoPO); + + targetPO = baseInfoPO; + encryptUtil.decrypt(insertSocialInfo, InsuranceArchivesSocialSchemePO.class); + targetDetailPO = insertSocialInfo; + } else { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "档案不存在!")); + } + } + //记录操作日志 + DataCollectionEmployee empInfo = getSalaryEmployeeService(user).getEmployeeById(targetPO.getEmployeeId()); + TaxAgentPO taxAgentInfo = getTaxAgentMapper().getById(targetPO.getPaymentOrganization()); + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(targetPO.getId())); + loggerContext.setTargetName(taxAgentInfo.getName() + "-" + empInfo.getUsername()); + loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "福利档案-社保明细保存")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "福利档案-社保明细保存") + ": " + taxAgentInfo.getName() + "-" + empInfo.getUsername()); + if (oldSocialInfoList.size() == 1) { + loggerContext.setOldValues(oldSocialInfoList.get(0)); + } + loggerContext.setNewValues(targetDetailPO); + SalaryElogConfig.siArchivesLoggerTemplate.write(loggerContext); + //生成福利档案基数调整记录数据 + List adjustHistoryList = createAdjustInfo(adjustInfo, employeeId); + //福利档案基数调整记录数据入库 + batchInsertAdjustHistory(adjustHistoryList); + } + + /** + * 校验福利基数是否符合上下限要求 + * @param primaryId + * @param paymentBaseString + * @return + */ + @Override + public Boolean checkWelBaseLimit(Long primaryId, String paymentBaseString, Integer paymentScope, StringBuilder errorMsg) { + + if (primaryId ==null || paymentBaseString == null) { + return true; + } + Map paymentBaseJson = JSON.parseObject(paymentBaseString, new HashMap().getClass()); + if (paymentBaseJson == null) { + return true; + } + List iCategoryPOS = getICategoryMapper().listAll(); + Map categoryMap = SalaryEntityUtil.convert2Map(iCategoryPOS, po -> po.getId().toString(), ICategoryPO::getInsuranceName); + + Boolean flag = true; + for (Map.Entry entry : paymentBaseJson.entrySet()) { + + //判断福利值是否为空/数字 + if (entry.getValue() == null || entry.getValue().length() == 0) { + continue; + } else if (!isNumeric(entry.getValue())) { + errorMsg.append("福利值非数字"); + log.info("福利值非数字!"); + flag = false; + } + + //根据福利方案id、险种id、缴纳对象、缴费状态查询明细 + List insuranceSchemeDetailPOList = getInsuranceSchemeDetailMapper().getByPI(primaryId, Long.valueOf(entry.getKey())); + log.info("福利方案id: {},, 福利明细项id:{}", primaryId, Long.valueOf(entry.getKey())); + if (insuranceSchemeDetailPOList.size() == 0) { + errorMsg.append("根据福利方案id、险种id、缴纳对象查询明细为null!福利方案id: " + primaryId + ", 福利明细项id:" + Long.valueOf(entry.getKey()) + ";"); + log.info("根据福利方案id、险种id、缴纳对象查询明细为null!福利方案id: {}, 福利明细项id:{}", primaryId, Long.valueOf(entry.getKey())); + flag = false; + } + List isPaymentList = insuranceSchemeDetailPOList.stream() + .filter(f -> f.getIsPayment().equals(IsPaymentEnum.YES.getValue()) && f.getPaymentScope().equals(paymentScope)).collect(Collectors.toList()); + if (isPaymentList.size() > 0) { + InsuranceSchemeDetailPO insuranceSchemeDetailPO = isPaymentList.get(0); + + encryptUtil.decrypt(insuranceSchemeDetailPO, InsuranceSchemeDetailPO.class); + String lowerLimit = "0.000".equals(insuranceSchemeDetailPO.getLowerLimit()) ? null : insuranceSchemeDetailPO.getLowerLimit(); + String upperLimit = "0.000".equals(insuranceSchemeDetailPO.getUpperLimit()) ? null : insuranceSchemeDetailPO.getUpperLimit(); + if (lowerLimit != null && lowerLimit.length() > 0 && Double.parseDouble(entry.getValue()) < Double.parseDouble(lowerLimit)) { + //数值低于对应福利明细下限 + errorMsg.append("【"+ categoryMap.getOrDefault(entry.getKey(), "") + "】数值: " + entry.getValue() +",低于对应福利明细下限: " + lowerLimit+ "\n"); + log.info("社保基数 {} 数值 {} 低于对应福利明细下限 {}!", entry.getKey(), entry.getValue(), lowerLimit); + flag = false; + } + if (upperLimit != null && upperLimit.length() > 0 && Double.parseDouble(entry.getValue()) > Double.parseDouble(upperLimit)) { + //数值高于对应福利明细上限 + errorMsg.append("【"+ categoryMap.getOrDefault(entry.getKey(), "") + "】数值: " + entry.getValue() +",高于对应福利明细上限: " + upperLimit+ "\n"); + log.info("社保基数 {} 数值 {} 高于对应福利明细上限 {} !", entry.getKey(), entry.getValue(), upperLimit); + flag = false; + } + } else { + log.info("福利明细项属于未缴费状态,不对上下限进行约束"); + } + + + } + return flag; + } + + /** + * 校验福利基数是否符合上下限要求 + * @param primaryId + * @param paymentBaseString + * @return + */ + @Override + public String adaptWelBaseLimit(Long primaryId, String paymentBaseString, Integer paymentScope) { + + if (primaryId ==null || paymentBaseString == null) { + return null; + } + Map paymentBaseJson = JSON.parseObject(paymentBaseString, new HashMap().getClass()); + if (paymentBaseJson == null) { + return null; + } + + log.info("自动调整前 基数信息{}", paymentBaseJson); + for (Map.Entry entry : paymentBaseJson.entrySet()) { + + //判断福利值是否为空/数字 + if (entry.getValue() == null || entry.getValue().length() == 0) { + continue; + } else if (!isNumeric(entry.getValue())) { + log.info("福利值非数字!"); + throw new SalaryRunTimeException("福利值非数字"); + } + + //根据福利方案id、险种id、缴纳对象、缴费状态查询明细 + List insuranceSchemeDetailPOList = getInsuranceSchemeDetailMapper().getByPI(primaryId, Long.valueOf(entry.getKey())); + log.info("自动调整 福利方案id: {},, 福利明细项id:{}", primaryId, Long.valueOf(entry.getKey())); + if (insuranceSchemeDetailPOList.size() == 0) { + log.info("自动调整 根据福利方案id、险种id、缴纳对象查询明细为null!福利方案id: {}, 福利明细项id:{}", primaryId, Long.valueOf(entry.getKey())); + throw new SalaryRunTimeException("根据福利方案id、险种id、缴纳对象查询明细为null!福利方案id: "+primaryId+", 福利明细项id:{}"+ Long.valueOf(entry.getKey())); + } + List isPaymentList = insuranceSchemeDetailPOList.stream() + .filter(f -> f.getIsPayment().equals(IsPaymentEnum.YES.getValue()) && f.getPaymentScope().equals(paymentScope)).collect(Collectors.toList()); + log.info("自动调整 isPaymentList: {}", isPaymentList.size()); + if (isPaymentList.size() > 0) { + InsuranceSchemeDetailPO insuranceSchemeDetailPO = isPaymentList.get(0); + + encryptUtil.decrypt(insuranceSchemeDetailPO, InsuranceSchemeDetailPO.class); + String lowerLimit = "0.000".equals(insuranceSchemeDetailPO.getLowerLimit()) ? null : insuranceSchemeDetailPO.getLowerLimit(); + String upperLimit = "0.000".equals(insuranceSchemeDetailPO.getUpperLimit()) ? null : insuranceSchemeDetailPO.getUpperLimit(); + if (lowerLimit != null && lowerLimit.length() > 0 && Double.parseDouble(entry.getValue()) < Double.parseDouble(lowerLimit)) { + //数值低于对应福利明细下限 + entry.setValue(lowerLimit); + log.info("自动调整 福利方案id: {},, 福利明细项id:{},数值{}低于对应福利明细下限{} ", primaryId, Long.valueOf(entry.getKey()), entry.getValue(), lowerLimit); + } + if (upperLimit != null && upperLimit.length() > 0 && Double.parseDouble(entry.getValue()) > Double.parseDouble(upperLimit)) { + //数值高于对应福利明细上限 + entry.setValue(upperLimit); + log.info("自动调整 福利方案id: {},, 福利明细项id:{},数值{}数值高于对应福利明细上限{} ", primaryId, Long.valueOf(entry.getKey()), entry.getValue(), upperLimit); + } + } else { + log.info("自动调整 福利明细项属于未缴费状态,不对上下限进行约束"); + } + } + log.info("自动调整后 基数信息{}", paymentBaseJson); + return JSON.toJSONString(paymentBaseJson); + } + + + /** + * 校验福利基数是否符合上下限要求,并返回符合要求的数据 + * @param primaryId + * @param paymentBaseString + * @return + */ + @Override + public String checkAndBuildWelBaseWithLimit(Long primaryId, String paymentBaseString, Integer paymentScope) { + + if (primaryId ==null || paymentBaseString == null) { + return paymentBaseString; + } + Map paymentBaseJson = JSON.parseObject(paymentBaseString, HashMap.class); + Map newPaymentBaseJson = JSON.parseObject(paymentBaseString, HashMap.class); + if (paymentBaseJson == null) { + return null; + } + + for (Map.Entry entry : paymentBaseJson.entrySet()) { + //判断福利值是否为空/数字 + if (entry.getValue() == null || entry.getValue().length() == 0) { + continue; + } else if (!isNumeric(entry.getValue())) { + log.info("福利值非数字!"); + newPaymentBaseJson.remove(entry.getKey()); + continue; + } + //根据福利方案id、险种id + List insuranceSchemeDetailPOList = getInsuranceSchemeDetailMapper().getByPI(primaryId, Long.valueOf(entry.getKey())); + log.info("福利方案id: {},, 福利明细项id:{}", primaryId, Long.valueOf(entry.getKey())); + if (insuranceSchemeDetailPOList.size() == 0) { + log.info("根据福利方案id、险种id、缴纳对象查询明细为null!福利方案id: {}, 福利明细项id:{}", primaryId, Long.valueOf(entry.getKey())); + newPaymentBaseJson.remove(entry.getKey()); + continue; + } + List checkList = insuranceSchemeDetailPOList.stream() + .filter(f -> f.getPaymentScope().equals(paymentScope)).collect(Collectors.toList()); + if (checkList.size() > 0) { + InsuranceSchemeDetailPO insuranceSchemeDetailPO = checkList.get(0); + encryptUtil.decrypt(insuranceSchemeDetailPO, InsuranceSchemeDetailPO.class); + String lowerLimit = "0.000".equals(insuranceSchemeDetailPO.getLowerLimit()) ? null : insuranceSchemeDetailPO.getLowerLimit(); + String upperLimit = "0.000".equals(insuranceSchemeDetailPO.getUpperLimit()) ? null : insuranceSchemeDetailPO.getUpperLimit(); + if (lowerLimit != null && lowerLimit.length() > 0 && Double.parseDouble(entry.getValue()) < Double.parseDouble(lowerLimit)) { + //数值低于对应福利明细下限 + log.info("社保基数 {} 数值 {} 低于对应福利明细下限 {}!", entry.getKey(), entry.getValue(), lowerLimit); + newPaymentBaseJson.put(entry.getKey(), lowerLimit); + } + if (upperLimit != null && upperLimit.length() > 0 && Double.parseDouble(entry.getValue()) > Double.parseDouble(upperLimit)) { + //数值高于对应福利明细上限 + log.info("社保基数 {} 数值 {} 高于对应福利明细上限 {} !", entry.getKey(), entry.getValue(), upperLimit); + newPaymentBaseJson.put(entry.getKey(), upperLimit); + } + } + } + return JSON.toJSONString(newPaymentBaseJson); + } + + /** + * 判断字符串是否为整数或者小数或者负数 + */ + public static boolean isNumeric(String str){ + + Pattern pattern = Pattern.compile("^-?\\d+(\\.\\d+)?$"); + Matcher isNum = pattern.matcher(str); + if (!isNum.matches()) { + return false; + } + return true; + + } + + /** + * 档案列表 + *

+ * 这里是一个含有比较多动态字段的列表,用的是手动拼装的方式 + * + * @param param 高级搜索条件 + * @param operateId 操作员id + * @return table + */ + public Map listPage(InsuranceArchivesListParam param, long operateId) { + Map apidatas = new HashMap<>(16); + InsuranceArchivesListParam request = InsuranceArchivesListParam.builder().build(); + if (param.getHireDate() != null && param.getHireDate().length == 2) { + param.setHiredateStart(param.getHireDate()[0]); + param.setHiredateEnd(param.getHireDate()[1]); + } + if (param.getDimissionDate() != null && param.getDimissionDate().length == 2) { + param.setDimissionDateStart(param.getDimissionDate()[0]); + param.setDimissionDateEnd(param.getDimissionDate()[1]); + } + + if (org.apache.commons.lang.StringUtils.isNotBlank(param.getDepartmentIdsStr())) { + request.setDepartmentIds(Arrays.stream(param.getDepartmentIdsStr().split(",")).map(BigDecimal::new).collect(Collectors.toList())); + } + + if (org.apache.commons.lang.StringUtils.isNotBlank(param.getSubcompanyIdsStr())) { + request.setSubcompanyIds(Arrays.stream(param.getSubcompanyIdsStr().split(",")).map(BigDecimal::new).collect(Collectors.toList())); + } + + + if (org.apache.commons.lang.StringUtils.isNotBlank(param.getPositionsStr())) { + request.setPositions(Arrays.stream(param.getPositionsStr().split(",")).map(BigDecimal::new).collect(Collectors.toList())); + } + + if (org.apache.commons.lang.StringUtils.isNotBlank(param.getStatusesStr())) { + request.setStatuses(Arrays.stream(param.getStatusesStr().split(",")).map(String::new).collect(Collectors.toList())); + } + + request.setNeedAuth(param.getNeedAuth()); + request.setTaxAgentEmployeeIds(param.getTaxAgentEmployeeIds()); + request.setTaxAgentIds(param.getTaxAgentIds()); + + Integer current = param.getCurrent() == null ? 1 : param.getCurrent(); + Integer pageSize = param.getPageSize() == null ? 10 : param.getPageSize(); + long startNum = (current - 1) * pageSize; + param.setStartNum(startNum); + param.setPageSize(pageSize); +// request.setStatuses(param.getStatuses()); + request.setKeyword(param.getUserName()); + + request.setSiSchemeId(param.getSiSchemeId()); + request.setFundSchemeId(param.getFundSchemeId()); + request.setOtherSchemeId(param.getOtherSchemeId()); + + request.setPageSize(param.getPageSize()); + request.setCurrent(param.getCurrent()); + + request.setJobNum(param.getJobNum()); + + request.setOrderRule(param.getOrderRule()); + + request.setRunStatuses(param.getRunStatuses()); + + request.setTaxAgentId(param.getTaxAgentId()); + + request.setExtWelArchiveList(param.isExtWelArchiveList()); + + apidatas = listPageEmployeePOS(request, operateId); + + return apidatas; + } + + /** + * 获取员工的基本信息 + *

+ * 此处主要是一个公共接口,有多处引用。我们薪资系统只保存员工id(employeeId), + * 但是页面上需要展示员工的更多信息(姓名,部门,状态。。。), + * 所以这里主要是用于接收联表数据的一个接口 + * + * @param param 高级搜索条件,用于过滤数据 + * @param operateId 操作员id + * @return list + */ + public Map listPageEmployeePOS(InsuranceArchivesListParam param, long operateId) { + Map datas = new HashMap<>(16); + + List page; + if (param.isExtWelArchiveList()) { + page = getSocialSchemeMapper().queryExtEmployeeList(param); + } else { + page = getSocialSchemeMapper().queryEmployeeList(param); + } + page = getAuthService(user).auth(page, AuthFilterTypeEnum.DATA_OPT, InsuranceArchivesEmployeePO.class); + + PageInfo pageInfo = SalaryPageUtil.buildPage(param.getCurrent(), param.getPageSize(), + page, InsuranceArchivesEmployeePO.class); + + SalaryI18nUtil.i18nList(pageInfo.getList()); + List> records = null; + if (param.getExportData() != null && param.getExportData()) { + records = buildTableData(pageInfo.getList(), true); + } else { + records = buildTableData(pageInfo.getList(), false); + } + List columns = buildWeaTableColumns(pageInfo.getList()); + + WeaTable table = new WeaTable(); + table.setColumns(columns); + //设置check是否可用 + List checkboxpopedomList = new ArrayList<>(); + WeaTableCheckboxpopedom checkboxpopedom = new WeaTableCheckboxpopedom(); + checkboxpopedom.setPopedompara("column:system_type"); + checkboxpopedom.setShowmethod("com.engine.salary.transmethod.TaxRateTransMethod.getCheckBoxPopedom"); + checkboxpopedomList.add(checkboxpopedom); + table.setCheckboxList(checkboxpopedomList); + table.setCheckboxpopedom(null); + + WeaResultMsg result = new WeaResultMsg(false); + result.putAll(table.makeDataResult()); + result.success(); + + datas.put("pageInfo", pageInfo); + datas.put("datas", records); + datas.put("columns", columns); + datas.put("dataKey", result.getResultMap()); + + return datas; + } + + /** + * 高级搜索 + * + * @return + */ + public Map getSearchCondition() { + + List userStatusOptions = Arrays.stream(UserStatusEnum.values()).map(e -> new SearchConditionOption(String.valueOf(e.getValue()), e.getDefaultLabel())).collect(Collectors.toList()); +// List list = new SISchemeBiz().listAll(); + List list = getSISchemeService(user).listAll(); + + List schemeOption = list.stream().filter(item -> Objects.equals(item.getWelfareType(), WelfareTypeEnum.SOCIAL_SECURITY.getValue())) + .collect(Collectors.toList()) + .stream().map(item -> new SearchConditionOption(item.getId().toString(), item.getSchemeName())).collect(Collectors.toList()); + + List fundOption = list.stream().filter(item -> Objects.equals(item.getWelfareType(), WelfareTypeEnum.ACCUMULATION_FUND.getValue())) + .collect(Collectors.toList()) + .stream().map(item -> new SearchConditionOption(item.getId().toString(), item.getSchemeName())).collect(Collectors.toList()); + + List otherOption = list.stream().filter(item -> Objects.equals(item.getWelfareType(), WelfareTypeEnum.OTHER.getValue())) + .collect(Collectors.toList()) + .stream().map(item -> new SearchConditionOption(item.getId().toString(), item.getSchemeName())).collect(Collectors.toList()); + + TaxAgentQueryParam param = TaxAgentQueryParam.builder().build(); + param.setFilterType(AuthFilterTypeEnum.QUERY_DATA); + List taxAgentList = getTaxAgentService(user).listAuth(param); + List taxAgentOption = taxAgentList.stream().map(item -> new SearchConditionOption(item.getId().toString(), item.getName())).collect(Collectors.toList()); + + Map apidatas = new HashMap(); + ConditionFactory conditionFactory = new ConditionFactory(user); + //条件组 + List addGroups = new ArrayList(); + List conditionItems = new ArrayList(); + //文本输入框 + SearchConditionItem username = conditionFactory.createCondition(ConditionType.INPUT, 25034, "username"); + username.setInputType("input"); + username.setColSpan(2);//定义一行显示条件数,默认值为2,当值为1时标识该条件单独占一行 + username.setFieldcol(16); //条件输入框所占宽度,默认值18 + username.setLabelcol(8); + username.setViewAttr(2); // 编辑权限 1:只读,2:可编辑, 3:必填 默认2 + username.setLabel(SalaryI18nUtil.getI18nLabel(0,"姓名")); //设置文本值 这个将覆盖多语言标签的值 + conditionItems.add(username); + //文本输入框 + SearchConditionItem jobNum = conditionFactory.createCondition(ConditionType.INPUT, 25034, "jobNum"); + jobNum.setInputType("input"); + jobNum.setColSpan(2);//定义一行显示条件数,默认值为2,当值为1时标识该条件单独占一行 + jobNum.setFieldcol(16); //条件输入框所占宽度,默认值18 + jobNum.setLabelcol(8); + jobNum.setViewAttr(2); // 编辑权限 1:只读,2:可编辑, 3:必填 默认2 + jobNum.setLabel(SalaryI18nUtil.getI18nLabel(0,"工号")); //设置文本值 这个将覆盖多语言标签的值 + conditionItems.add(jobNum); + + SearchConditionItem departmentIds = conditionFactory.createCondition(ConditionType.BROWSER, 502329, "departmentIdsStr", "57"); + departmentIds.setColSpan(2); + departmentIds.setFieldcol(16); + departmentIds.setLabelcol(8); + departmentIds.setLabel(SalaryI18nUtil.getI18nLabel(0,"部门")); + conditionItems.add(departmentIds); + + SearchConditionItem statuses = conditionFactory.createCondition(ConditionType.SELECT, 502327, "statusesStr"); + statuses.setInputType("select"); + statuses.setMultiple(true); + statuses.setOptions(userStatusOptions); + statuses.setColSpan(2); + statuses.setFieldcol(16); + statuses.setLabelcol(8); + statuses.setIsQuickSearch(true); + statuses.setLabel(SalaryI18nUtil.getI18nLabel(0,"状态")); + conditionItems.add(statuses); + + SearchConditionItem positions = conditionFactory.createCondition(ConditionType.BROWSER, 502327, "positionsStr", "278"); + positions.setInputType("browser"); + positions.setColSpan(2); + positions.setFieldcol(16); + positions.setLabelcol(8); + positions.setIsQuickSearch(true); + positions.setLabel(SalaryI18nUtil.getI18nLabel(0,"岗位")); + conditionItems.add(positions); + + SearchConditionItem subcompanyIds = conditionFactory.createCondition(ConditionType.BROWSER, 502327, "subcompanyIdsStr", "194"); + subcompanyIds.setInputType("browser"); + subcompanyIds.setColSpan(2); + subcompanyIds.setFieldcol(16); + subcompanyIds.setLabelcol(8); + subcompanyIds.setIsQuickSearch(true); + subcompanyIds.setLabel(SalaryI18nUtil.getI18nLabel(0,"分部")); + conditionItems.add(subcompanyIds); + +// SearchConditionItem hireDate = conditionFactory.createCondition(ConditionType.TIMEPICKER,502327,new String[]{"hireDate", "hireDate"}); +// hireDate.setInputType("timepicker"); +// hireDate.setColSpan(2); +// hireDate.setFieldcol(16); +// hireDate.setViewAttr(8); +// hireDate.setFormat("yyyy-MM-dd"); +// hireDate.setLabel(SalaryI18nUtil.getI18nLabel(0,"入职日期")); +// conditionItems.add(hireDate); +// +// +// SearchConditionItem dimissionDate = conditionFactory.createCondition(ConditionType.TIMEPICKER,502327,new String[]{"dimissionDate", "dimissionDate"}); +// dimissionDate.setInputType("timepicker"); +// dimissionDate.setColSpan(2); +// dimissionDate.setFieldcol(16); +// dimissionDate.setViewAttr(8); +// dimissionDate.setFormat("yyyy-MM-dd"); +// dimissionDate.setLabel(SalaryI18nUtil.getI18nLabel(0,"离职日期")); +// conditionItems.add(dimissionDate); + + + SearchConditionItem siSchemeId = conditionFactory.createCondition(ConditionType.SELECT, 502327, "siSchemeId"); + siSchemeId.setInputType("select"); + siSchemeId.setOptions(schemeOption); + siSchemeId.setColSpan(2); + siSchemeId.setFieldcol(16); + siSchemeId.setLabelcol(8); + siSchemeId.setIsQuickSearch(true); + siSchemeId.setLabel(SalaryI18nUtil.getI18nLabel(0,"社保方案")); + conditionItems.add(siSchemeId); + + SearchConditionItem fundSchemeId = conditionFactory.createCondition(ConditionType.SELECT, 502327, "fundSchemeId"); + fundSchemeId.setInputType("select"); + fundSchemeId.setOptions(fundOption); + fundSchemeId.setColSpan(2); + fundSchemeId.setFieldcol(16); + fundSchemeId.setLabelcol(8); + fundSchemeId.setIsQuickSearch(true); + fundSchemeId.setLabel(SalaryI18nUtil.getI18nLabel(0,"公积金方案")); + conditionItems.add(fundSchemeId); + + SearchConditionItem otherSchemeId = conditionFactory.createCondition(ConditionType.SELECT, 502327, "otherSchemeId"); + otherSchemeId.setInputType("select"); + otherSchemeId.setOptions(otherOption); + otherSchemeId.setColSpan(2); + otherSchemeId.setFieldcol(16); + otherSchemeId.setLabelcol(8); + otherSchemeId.setIsQuickSearch(true); + otherSchemeId.setLabel(SalaryI18nUtil.getI18nLabel(0,"其他福利方案")); + conditionItems.add(otherSchemeId); + + SearchConditionItem taxAgentId = conditionFactory.createCondition(ConditionType.SELECT, 502327, "taxAgentId"); + taxAgentId.setInputType("select"); + taxAgentId.setOptions(taxAgentOption); + taxAgentId.setColSpan(2); + taxAgentId.setFieldcol(16); + taxAgentId.setLabelcol(8); + taxAgentId.setIsQuickSearch(true); + taxAgentId.setLabel(SalaryI18nUtil.getI18nLabel(0,"个税扣缴义务人")); + conditionItems.add(taxAgentId); + + addGroups.add(new SearchConditionGroup(SalaryI18nUtil.getI18nLabel(0,"常用条件"), true, conditionItems)); + apidatas.put("condition", addGroups); + return apidatas; + } + + @Override + public List getSocialByEmployeeIds(List employeeIds) { + + List> partition = Lists.partition(employeeIds, 1000); + List allList = new ArrayList<>(); + for (List longs : partition) { + List socialList = getSocialSchemeMapper().getSocialByEmployeeId(longs); + allList.addAll(socialList); + } + return allList; + } + + @Override + public List getFundByEmployeeIds(List employeeIds) { + + List> partition = Lists.partition(employeeIds, 1000); + List allList = new ArrayList<>(); + for (List longs : partition) { + List fundList = getFundSchemeMapper().getFundByEmployeeId(longs); + allList.addAll(fundList); + } + return allList; + } + + @Override + public List getOtherByEmployeeIds(List employeeIds) { + + List> partition = Lists.partition(employeeIds, 1000); + List allList = new ArrayList<>(); + for (List longs : partition) { + List otherList = getOtherSchemeMapper().getOtherByEmployeeId(longs); + allList.addAll(otherList); + } + return allList; + } + + /** + * 组装员工的社保,公积金,其他福利数据 + * + * @param ids 员工id集合 + * @return map + */ + @Override + public Map buildBatchAccount(List ids, Long paymentOrganization) { + if (org.apache.commons.collections.CollectionUtils.isEmpty(ids)) { + return new HashMap<>(); + } + //设置获取社保/公积金/其他福利档案方法的入参 + List insuranceArchivesEmployeePOS = new ArrayList<>(); + for (Long employeeId : ids) { + insuranceArchivesEmployeePOS.add(InsuranceArchivesEmployeePO.builder() + .employeeId(employeeId) + .paymentOrganization(paymentOrganization) + .build()); + } + + Map result = new HashMap<>(); + Map socialMap = new HashMap<>(); + Map funMap = new HashMap<>(); + Map otherMap = new HashMap<>(); + List socialPOS = encryptUtil.decryptList(this.getSocialByEmployeeIdAndPayOrg(insuranceArchivesEmployeePOS), InsuranceArchivesSocialSchemePO.class); + if (org.apache.commons.collections.CollectionUtils.isNotEmpty(socialPOS)) { + socialMap = socialPOS.stream().collect(Collectors.toMap(InsuranceArchivesSocialSchemePO::getEmployeeId, Function.identity())); + } + List fundPOS = encryptUtil.decryptList(this.getFundByEmployeeIdAndPayOrg(insuranceArchivesEmployeePOS), InsuranceArchivesFundSchemePO.class); + if (org.apache.commons.collections.CollectionUtils.isNotEmpty(fundPOS)) { + funMap = fundPOS.stream().collect(Collectors.toMap(InsuranceArchivesFundSchemePO::getEmployeeId, Function.identity())); + } + List otherPOS = this.getOtherByEmployeeIdAndPayOrg(insuranceArchivesEmployeePOS); + encryptUtil.decryptList(otherPOS, InsuranceArchivesOtherSchemePO.class); + if (org.apache.commons.collections.CollectionUtils.isNotEmpty(otherPOS)) { + otherMap = otherPOS.stream().collect(Collectors.toMap(InsuranceArchivesOtherSchemePO::getEmployeeId, Function.identity())); + } + for (Long id : ids) { + InsuranceArchivesAccountPO po = new InsuranceArchivesAccountPO(); + po.setSocial(socialMap.get(id)); + po.setFund(funMap.get(id)); + po.setOther(otherMap.get(id)); + result.put(id, po); + } + return result; + } + + @Override + public List dealSocialBaseAdjustInfoList(List adjustList, Long creator) { + List adjustHistoryList = new ArrayList<>(); + if (adjustList.size() > 0) { + //遍历待更新的福利档案数据,对每组档案生成基数调整记录(基数单元未变化则忽略) + for (InsuranceArchivesSocialSchemePO po : adjustList) { + List oldBaseInfoList = getSocialSchemeMapper().getSocialByEmployeeIdAndPayOrg(InsuranceArchivesEmployeePO.builder() + .paymentOrganization(po.getPaymentOrganization()).employeeId(po.getEmployeeId()).build()); + + InsuranceArchivesBaseHistoryDTO adjustInfo = InsuranceArchivesBaseHistoryDTO.builder() + .adjustAfterSchemeId(po.getSocialSchemeId()) + .adjustAfterBaseJson(po.getSocialPaymentBaseString()) + .adjustAfterComBaseJson(po.getSocialPaymentComBaseString()) + .welfareType(po.getWelfareType()) + .employeeId(po.getEmployeeId()) + .paymentOrganization(po.getPaymentOrganization()) + .build(); + if (oldBaseInfoList.size() == 1) { + //新增调整记录,变更 + InsuranceArchivesSocialSchemePO oldBaseInfo = oldBaseInfoList.get(0); + encryptUtil.decrypt(oldBaseInfo, InsuranceArchivesSocialSchemePO.class); + adjustInfo.setAdjustBeforeBaseJson(oldBaseInfo.getSocialPaymentBaseString()); + adjustInfo.setAdjustBeforeComBaseJson(oldBaseInfo.getSocialPaymentComBaseString()); + adjustInfo.setAdjustBeforeSchemeId(oldBaseInfo.getSocialSchemeId()); + } else if (oldBaseInfoList.size() > 1) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"社保档案存在冗余数据!")); + } + adjustHistoryList.addAll(createAdjustInfo(adjustInfo, creator)); + } + } + return adjustHistoryList; + + } + + @Override + public List dealFundBaseAdjustInfoList(List adjustList, Long creator) { + List adjustHistoryList = new ArrayList<>(); + if (adjustList.size() > 0) { + //遍历待更新的福利档案数据,对每组档案生成基数调整记录(基数单元未变化则忽略) + for (InsuranceArchivesFundSchemePO po : adjustList) { + List oldBaseInfoList = getFundSchemeMapper().getFundByEmployeeIdAndPayOrg(InsuranceArchivesEmployeePO.builder() + .paymentOrganization(po.getPaymentOrganization()).employeeId(po.getEmployeeId()).build()); + + InsuranceArchivesBaseHistoryDTO adjustInfo = InsuranceArchivesBaseHistoryDTO.builder() + .adjustAfterSchemeId(po.getFundSchemeId()) + .adjustAfterBaseJson(po.getFundPaymentBaseString()) + .adjustAfterComBaseJson(po.getFundPaymentComBaseString()) + .welfareType(po.getWelfareType()) + .employeeId(po.getEmployeeId()) + .paymentOrganization(po.getPaymentOrganization()) + .build(); + if (oldBaseInfoList.size() == 1) { + //新增调整记录,变更 + InsuranceArchivesFundSchemePO oldBaseInfo = oldBaseInfoList.get(0); + encryptUtil.decrypt(oldBaseInfo, InsuranceArchivesFundSchemePO.class); + adjustInfo.setAdjustBeforeBaseJson(oldBaseInfo.getFundPaymentBaseString()); + adjustInfo.setAdjustBeforeComBaseJson(oldBaseInfo.getFundPaymentComBaseString()); + adjustInfo.setAdjustBeforeSchemeId(oldBaseInfo.getFundSchemeId()); + } else if (oldBaseInfoList.size() > 1) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"公积金档案存在冗余数据!")); + } + adjustHistoryList.addAll(createAdjustInfo(adjustInfo, creator)); + } + } + return adjustHistoryList; + } + + @Override + public List dealOtherBaseAdjustInfoList(List adjustList, Long creator) { + List adjustHistoryList = new ArrayList<>(); + if (adjustList.size() > 0) { + //遍历待更新的福利档案数据,对每组档案生成基数调整记录(基数单元未变化则忽略) + for (InsuranceArchivesOtherSchemePO po : adjustList) { + List oldBaseInfoList = getOtherSchemeMapper().getOtherByEmployeeIdAndPayOrg(InsuranceArchivesEmployeePO.builder() + .paymentOrganization(po.getPaymentOrganization()).employeeId(po.getEmployeeId()).build()); + + InsuranceArchivesBaseHistoryDTO adjustInfo = InsuranceArchivesBaseHistoryDTO.builder() + .adjustAfterSchemeId(po.getOtherSchemeId()) + .adjustAfterBaseJson(po.getOtherPaymentBaseString()) + .adjustAfterComBaseJson(po.getOtherPaymentComBaseString()) + .welfareType(po.getWelfareType()) + .employeeId(po.getEmployeeId()) + .paymentOrganization(po.getPaymentOrganization()) + .build(); + if (oldBaseInfoList.size() == 1) { + //新增调整记录,变更 + InsuranceArchivesOtherSchemePO oldBaseInfo = oldBaseInfoList.get(0); + encryptUtil.decrypt(oldBaseInfo, InsuranceArchivesOtherSchemePO.class); + adjustInfo.setAdjustBeforeBaseJson(oldBaseInfo.getOtherPaymentBaseString()); + adjustInfo.setAdjustBeforeComBaseJson(oldBaseInfo.getOtherPaymentComBaseString()); + adjustInfo.setAdjustBeforeSchemeId(oldBaseInfo.getOtherSchemeId()); + } else if (oldBaseInfoList.size() > 1) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"其他福利档案存在冗余数据!")); + } + adjustHistoryList.addAll(createAdjustInfo(adjustInfo, creator)); + } + } + return adjustHistoryList; + } + + /** + * 获取没有设置社保、公积金最后缴纳月的档案 + * @param employeeIds + * @return + */ + @Override + public List listEndDateIsNull(List employeeIds) { + if (org.apache.commons.collections.CollectionUtils.isEmpty(employeeIds)) { + return Collections.emptyList(); + } + return getInsuranceBaseInfoMapper().listEndDateIsNull(employeeIds); + } + + /** + * 获取没有设置社保、公积金最后缴纳月的档案 + * @param employeeIds + * @return + */ + @Override + public List listStartDateIsNull(List employeeIds) { + return getInsuranceBaseInfoMapper().listStartDateIsNull(employeeIds); + } + /*****以上代码为SIArchivesBiz中方法逻辑迁移,旨在减少Biz类的使用*****/ + + @Override + public List listInsuranceArchivesSocialSchemeByIds(List ids) { + if (CollectionUtils.isEmpty(ids)) { + return Collections.emptyList(); + } + List> partition = Lists.partition(ids, 1000); + ArrayList resultList = new ArrayList<>(); + partition.forEach(list -> resultList.addAll(getSocialSchemeMapper().getSocialById(list))); + return resultList; + } + + @Override + public List listInsuranceArchivesFundSchemeByIds(List ids) { + if (CollectionUtils.isEmpty(ids)) { + return Collections.emptyList(); + } + List> partition = Lists.partition(ids, 1000); + ArrayList resultList = new ArrayList<>(); + partition.forEach(list -> resultList.addAll(getFundSchemeMapper().getFundById(list))); + return resultList; + } + + @Override + public List listInsuranceArchivesOtherSchemeByIds(List ids) { + if (CollectionUtils.isEmpty(ids)) { + return Collections.emptyList(); + } + List> partition = Lists.partition(ids, 1000); + ArrayList resultList = new ArrayList<>(); + partition.forEach(list -> resultList.addAll(getOtherSchemeMapper().getOtherById(list))); + return resultList; + } + + @Override + public List listAll() { + return getInsuranceBaseInfoMapper().listAll(); + } +} diff --git a/src/com/engine/salary/service/impl/SIBalanceServiceImpl.java b/src/com/engine/salary/service/impl/SIBalanceServiceImpl.java new file mode 100644 index 000000000..bebb03851 --- /dev/null +++ b/src/com/engine/salary/service/impl/SIBalanceServiceImpl.java @@ -0,0 +1,563 @@ +package com.engine.salary.service.impl; + +import com.alibaba.fastjson.JSON; +import com.api.formmode.mybatis.util.SqlProxyHandle; +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.hrmelog.entity.dto.LoggerContext; +import com.engine.salary.config.SalaryElogConfig; +import com.engine.salary.constant.SalaryDefaultTenantConstant; +import com.engine.salary.encrypt.EncryptUtil; +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.siaccount.param.BalanceAccountBaseParam; +import com.engine.salary.entity.siaccount.param.InspectAccountParam; +import com.engine.salary.entity.siaccount.po.InsuranceAccountBatchPO; +import com.engine.salary.entity.siaccount.po.InsuranceAccountDetailPO; +import com.engine.salary.entity.siarchives.po.*; +import com.engine.salary.entity.sicategory.po.ICategoryPO; +import com.engine.salary.entity.sischeme.po.InsuranceSchemeDetailPO; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import com.engine.salary.enums.OperateTypeEnum; +import com.engine.salary.enums.siaccount.BillStatusEnum; +import com.engine.salary.enums.siaccount.PaymentStatusEnum; +import com.engine.salary.enums.siaccount.ResourceFromEnum; +import com.engine.salary.enums.sicategory.DeleteTypeEnum; +import com.engine.salary.enums.sicategory.IsPaymentEnum; +import com.engine.salary.enums.sicategory.PaymentScopeEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.mapper.siaccount.InsuranceAccountBatchMapper; +import com.engine.salary.mapper.siaccount.InsuranceAccountDetailMapper; +import com.engine.salary.mapper.siarchives.FundSchemeMapper; +import com.engine.salary.mapper.siarchives.InsuranceBaseInfoMapper; +import com.engine.salary.mapper.siarchives.OtherSchemeMapper; +import com.engine.salary.mapper.siarchives.SocialSchemeMapper; +import com.engine.salary.mapper.sicategory.ICategoryMapper; +import com.engine.salary.mapper.sischeme.InsuranceSchemeDetailMapper; +import com.engine.salary.mapper.taxagent.TaxAgentMapper; +import com.engine.salary.service.SIAccountService; +import com.engine.salary.service.SIBalanceService; +import com.engine.salary.service.SalaryEmployeeService; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.db.IdGenerator; +import com.engine.salary.util.db.MapperProxyFactory; +import com.google.common.collect.Lists; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import weaver.hrm.User; + +import java.math.BigDecimal; +import java.util.*; +import java.util.stream.Collectors; + + +/** + * @Author: sy + * @Description: 福利台账-补差实现类 + * @Date: 2022/12/8 + **/ +public class SIBalanceServiceImpl extends Service implements SIBalanceService { + + private InsuranceAccountDetailMapper getInsuranceAccountDetailMapper() { + return SqlProxyHandle.getProxy(InsuranceAccountDetailMapper.class); + } + + private SIAccountService getSIAccountService(User user) { + return ServiceUtil.getService(SIAccountServiceImpl.class, user); + } + + private SocialSchemeMapper getSocialSchemeMapper() { + return MapperProxyFactory.getProxy(SocialSchemeMapper.class); + } + + private FundSchemeMapper getFundSchemeMapper() { + return MapperProxyFactory.getProxy(FundSchemeMapper.class); + } + + private OtherSchemeMapper getOtherSchemeMapper() { + return MapperProxyFactory.getProxy(OtherSchemeMapper.class); + } + + private ICategoryMapper getICategoryMapper() { + return MapperProxyFactory.getProxy(ICategoryMapper.class); + } + + private InsuranceSchemeDetailMapper getInsuranceSchemeDetailMapper() { + return MapperProxyFactory.getProxy(InsuranceSchemeDetailMapper.class); + } + + private InsuranceBaseInfoMapper getInsuranceBaseInfoMapper() { + return MapperProxyFactory.getProxy(InsuranceBaseInfoMapper.class); + } + + private EncryptUtil encryptUtil = new EncryptUtil(); + + private InsuranceAccountBatchMapper getInsuranceAccountBatchMapper() { + return MapperProxyFactory.getProxy(InsuranceAccountBatchMapper.class); + } + + private TaxAgentMapper getTaxAgentMapper() { + return MapperProxyFactory.getProxy(TaxAgentMapper.class); + } + + private SalaryEmployeeService getSalaryEmployeeService(User user) { + return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user); + } + + @Override + public void del(InspectAccountParam param, Long employeeId) { + + //入参判断 + if (CollectionUtils.isEmpty(param.getIds()) || param.getPaymentOrganization() == null || param.getBillMonth() == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(84026, "参数错误")); + } + + //根据id删除 + List> partition = Lists.partition((List) param.getIds(), 100); + partition.forEach(getInsuranceAccountDetailMapper()::batchDelAccountDetailsByIds); + //记录操作日志 + LoggerContext loggerContext = new LoggerContext(); + loggerContext.setUser(user); + loggerContext.setTargetId(param.getIds().stream().map(String::valueOf).collect(Collectors.joining(","))); + loggerContext.setTargetName(param.getIds().stream().map(String::valueOf).collect(Collectors.joining(","))); + loggerContext.setOperateType(OperateTypeEnum.DELETE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "福利台账明细表-删除补差核算记录")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "福利台账明细表-删除补差核算记录")); + SalaryElogConfig.siAccountLoggerTemplate.write(loggerContext); + //刷新bill_batch表中统计信息 + getSIAccountService(user).refreshBillBatch(param.getPaymentOrganization(), param.getBillMonth()); + } + + /** + * 获取待编辑的补差费用相关福利项 + */ + @Override + public List> getPaymentGroup(BalanceAccountBaseParam param) { + + Long paymentOrganization = param.getPaymentOrganization(); + Long employeeId = param.getEmployeeId(); + InsuranceArchivesSocialSchemePO socialSchemePO = new InsuranceArchivesSocialSchemePO(); + InsuranceArchivesFundSchemePO fundSchemePO = new InsuranceArchivesFundSchemePO(); + InsuranceArchivesOtherSchemePO otherSchemePO = new InsuranceArchivesOtherSchemePO(); + + List socialSchemePOList = getSocialSchemeMapper().getSocialByEmployeeIdAndPayOrg(InsuranceArchivesEmployeePO.builder() + .employeeId(employeeId) + .paymentOrganization(paymentOrganization) + .build()); + if (socialSchemePOList.size() > 0) { + encryptUtil.decryptList(socialSchemePOList, InsuranceArchivesSocialSchemePO.class); + socialSchemePO = socialSchemePOList.get(0); + } + + List fundSchemePOList = getFundSchemeMapper().getFundByEmployeeIdAndPayOrg(InsuranceArchivesEmployeePO.builder() + .employeeId(employeeId) + .paymentOrganization(paymentOrganization) + .build()); + if (fundSchemePOList.size() > 0) { + encryptUtil.decryptList(fundSchemePOList, InsuranceArchivesFundSchemePO.class); + fundSchemePO = fundSchemePOList.get(0); + } + + List otherSchemePOList = getOtherSchemeMapper().getOtherByEmployeeIdAndPayOrg(InsuranceArchivesEmployeePO.builder() + .employeeId(employeeId) + .paymentOrganization(paymentOrganization) + .build()); + if (otherSchemePOList.size() > 0) { + encryptUtil.decryptList(otherSchemePOList, InsuranceArchivesOtherSchemePO.class); + otherSchemePO = otherSchemePOList.get(0); + } + + List allCategoryList = getICategoryMapper().listAll(); + Map categoryNameMap = SalaryEntityUtil.convert2Map(allCategoryList, ICategoryPO::getId, ICategoryPO::getInsuranceName); + Map welfareTypeMap = SalaryEntityUtil.convert2Map(allCategoryList, ICategoryPO::getId, ICategoryPO::getWelfareType); + + List> resultList = new ArrayList<>(); + + if (socialSchemePO != null && (StringUtils.isNotBlank(socialSchemePO.getSocialPaymentBaseString()) || StringUtils.isNotBlank(socialSchemePO.getSocialPaymentComBaseString()) )) { + Map socialMap = JSON.parseObject(socialSchemePO.getSocialPaymentBaseString(), new HashMap().getClass()); + Map socialComMap = JSON.parseObject(socialSchemePO.getSocialPaymentComBaseString(), new HashMap().getClass()); + List socialIds = new ArrayList<>(); + socialIds.addAll(socialMap.keySet()); + if (socialComMap != null) { + socialIds.addAll(socialComMap.keySet()); + } + socialIds = socialIds.stream().distinct().collect(Collectors.toList()); + //查询该福利方案下开启缴纳的福利项 + List insuranceIdAndScopeList = payInsuranceIdAndScopeList(socialSchemePO.getSocialSchemeId()); + List insuranceSchemeDetailPOS = getInsuranceSchemeDetailMapper().listBySchemeIds(Collections.singletonList(socialSchemePO.getSocialSchemeId())); + Map schemeValidNumMap = SalaryEntityUtil.convert2Map(insuranceSchemeDetailPOS, po -> po.getInsuranceId() + "-" + po.getPaymentScope(), InsuranceSchemeDetailPO::getValidNum); + socialIds.forEach(k -> { + String welfareTypeName = welfareTypeMap.get(Long.valueOf(k)) == 1 ? "社保" : (welfareTypeMap.get(Long.valueOf(k)) == 2 ? "公积金" : "企业年金及其它福利" ); + String welfareTypeSign = welfareTypeMap.get(Long.valueOf(k)) == 1 ? "social" : (welfareTypeMap.get(Long.valueOf(k)) == 2 ? "fund" : "other" ); + if (insuranceIdAndScopeList.contains(k + "-" + PaymentScopeEnum.SCOPE_COMPANY.getValue())) { + Map comMap = new HashMap<>(); +// comMap.put("title", welfareTypeName + "公司" + "缴纳"); + comMap.put("title", welfareTypeName); + comMap.put("titleSign", welfareTypeSign); + comMap.put("insuranceId", k); + comMap.put("insuranceName", categoryNameMap.get(Long.valueOf(k))); + comMap.put("paymentScope", "公司"); + comMap.put("paymentScopeSign", "com"); + comMap.put("validNum",schemeValidNumMap.getOrDefault(k + "-" + PaymentScopeEnum.SCOPE_COMPANY.getValue(), 2).toString()); + resultList.add(comMap); + } + if (insuranceIdAndScopeList.contains(k + "-" + PaymentScopeEnum.SCOPE_PERSON.getValue())) { + Map perMap = new HashMap<>(); +// perMap.put("title", welfareTypeName + "个人" + "缴纳"); + perMap.put("title", welfareTypeName); + perMap.put("titleSign", welfareTypeSign); + perMap.put("insuranceId", k); + perMap.put("insuranceName", categoryNameMap.get(Long.valueOf(k))); + perMap.put("paymentScope", "个人"); + perMap.put("paymentScopeSign", "per"); + perMap.put("validNum",schemeValidNumMap.getOrDefault(k + "-" + PaymentScopeEnum.SCOPE_PERSON.getValue(), 2).toString()); + resultList.add(perMap); + } + }); + + } + if (fundSchemePO != null && (StringUtils.isNotBlank(fundSchemePO.getFundPaymentBaseString()) || StringUtils.isNotBlank(fundSchemePO.getFundPaymentComBaseString()))) { + Map fundMap = JSON.parseObject(fundSchemePO.getFundPaymentBaseString(), new HashMap().getClass()); + Map fundComMap = JSON.parseObject(fundSchemePO.getFundPaymentComBaseString(), new HashMap().getClass()); + List fundIds = new ArrayList<>(); + fundIds.addAll(fundMap.keySet()); + if (fundComMap != null) { + fundIds.addAll(fundComMap.keySet()); + } + fundIds = fundIds.stream().distinct().collect(Collectors.toList()); + //查询该福利方案下开启缴纳的福利项 + List insuranceIdAndScopeList = payInsuranceIdAndScopeList(fundSchemePO.getFundSchemeId()); + List insuranceSchemeDetailPOS = getInsuranceSchemeDetailMapper().listBySchemeIds(Collections.singletonList(fundSchemePO.getFundSchemeId())); + Map schemeValidNumMap = SalaryEntityUtil.convert2Map(insuranceSchemeDetailPOS, po -> po.getInsuranceId() + "-" + po.getPaymentScope(), InsuranceSchemeDetailPO::getValidNum); + fundIds.forEach(k -> { + String welfareTypeName = welfareTypeMap.get(Long.valueOf(k)) == 1 ? "社保" : (welfareTypeMap.get(Long.valueOf(k)) == 2 ? "公积金" : "企业年金及其它福利" ); + String welfareTypeSign = welfareTypeMap.get(Long.valueOf(k)) == 1 ? "social" : (welfareTypeMap.get(Long.valueOf(k)) == 2 ? "fund" : "other" ); + if (insuranceIdAndScopeList.contains(k + "-" + PaymentScopeEnum.SCOPE_COMPANY.getValue())) { + Map comMap = new HashMap<>(); +// comMap.put("title", welfareTypeName + "公司" + "缴纳"); + comMap.put("title", welfareTypeName); + comMap.put("titleSign", welfareTypeSign); + comMap.put("insuranceId", k); + comMap.put("insuranceName", categoryNameMap.get(Long.valueOf(k))); + comMap.put("paymentScope", "公司"); + comMap.put("paymentScopeSign", "com"); + comMap.put("validNum",schemeValidNumMap.getOrDefault(k + "-" + PaymentScopeEnum.SCOPE_COMPANY.getValue(), 2).toString()); + resultList.add(comMap); + } + if (insuranceIdAndScopeList.contains(k + "-" + PaymentScopeEnum.SCOPE_PERSON.getValue())) { + Map perMap = new HashMap<>(); +// perMap.put("title", welfareTypeName + "个人" + "缴纳"); + perMap.put("title", welfareTypeName); + perMap.put("titleSign", welfareTypeSign); + perMap.put("insuranceId", k); + perMap.put("insuranceName", categoryNameMap.get(Long.valueOf(k))); + perMap.put("paymentScope", "个人"); + perMap.put("paymentScopeSign", "per"); + perMap.put("validNum",schemeValidNumMap.getOrDefault(k + "-" + PaymentScopeEnum.SCOPE_PERSON.getValue(), 2).toString()); + resultList.add(perMap); + } + }); + + } + if (otherSchemePO != null && (StringUtils.isNotBlank(otherSchemePO.getOtherPaymentBaseString()) || StringUtils.isNotBlank(otherSchemePO.getOtherPaymentComBaseString()))) { + Map otherMap = JSON.parseObject(otherSchemePO.getOtherPaymentBaseString(), new HashMap().getClass()); + Map otherComMap = JSON.parseObject(otherSchemePO.getOtherPaymentComBaseString(), new HashMap().getClass()); + List otherIds = new ArrayList<>(); + otherIds.addAll(otherMap.keySet()); + if (otherComMap != null) { + otherIds.addAll(otherComMap.keySet()); + } + otherIds = otherIds.stream().distinct().collect(Collectors.toList()); + //查询该福利方案下开启缴纳的福利项 + List insuranceIdAndScopeList = payInsuranceIdAndScopeList(otherSchemePO.getOtherSchemeId()); + List insuranceSchemeDetailPOS = getInsuranceSchemeDetailMapper().listBySchemeIds(Collections.singletonList(otherSchemePO.getOtherSchemeId())); + Map schemeValidNumMap = SalaryEntityUtil.convert2Map(insuranceSchemeDetailPOS, po -> po.getInsuranceId() + "-" + po.getPaymentScope(), InsuranceSchemeDetailPO::getValidNum); + + otherIds.forEach(k -> { + String welfareTypeName = welfareTypeMap.get(Long.valueOf(k)) == 1 ? "社保" : (welfareTypeMap.get(Long.valueOf(k)) == 2 ? "公积金" : "企业年金及其它福利" ); + String welfareTypeSign = welfareTypeMap.get(Long.valueOf(k)) == 1 ? "social" : (welfareTypeMap.get(Long.valueOf(k)) == 2 ? "fund" : "other" ); + if (insuranceIdAndScopeList.contains(k + "-" + PaymentScopeEnum.SCOPE_COMPANY.getValue())) { + Map comMap = new HashMap<>(); +// comMap.put("title", welfareTypeName + "公司" + "缴纳"); + comMap.put("title", welfareTypeName); + comMap.put("titleSign", welfareTypeSign); + comMap.put("insuranceId", k); + comMap.put("insuranceName", categoryNameMap.get(Long.valueOf(k))); + comMap.put("paymentScope", "公司"); + comMap.put("paymentScopeSign", "com"); + comMap.put("validNum",schemeValidNumMap.getOrDefault(k + "-" + PaymentScopeEnum.SCOPE_COMPANY.getValue(), 2).toString()); + resultList.add(comMap); + } + if (insuranceIdAndScopeList.contains(k + "-" + PaymentScopeEnum.SCOPE_PERSON.getValue())) { + Map perMap = new HashMap<>(); +// perMap.put("title", welfareTypeName + "个人" + "缴纳"); + perMap.put("title", welfareTypeName); + perMap.put("titleSign", welfareTypeSign); + perMap.put("insuranceId", k); + perMap.put("insuranceName", categoryNameMap.get(Long.valueOf(k))); + perMap.put("paymentScope", "个人"); + perMap.put("paymentScopeSign", "per"); + perMap.put("validNum",schemeValidNumMap.getOrDefault(k + "-" + PaymentScopeEnum.SCOPE_PERSON.getValue(), 2).toString()); + resultList.add(perMap); + } + }); + } + return resultList; + + } + + @Override + public void addNewBalance(BalanceAccountBaseParam param) { + + //入参判断 + if (param.getPaymentOrganization() == null || StringUtils.isBlank(param.getBillMonth()) || param.getEmployeeId() == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "参数错误")); + } + + Long employeeId = param.getEmployeeId(); + String billMonth = param.getBillMonth(); + Long creator = (long) user.getUID(); + Long paymentOrganization = param.getPaymentOrganization(); + + InsuranceAccountDetailPO balanceAccountPO = getInsuranceAccountDetailMapper().getOneByBpep(InsuranceAccountDetailPO.builder() + .billMonth(billMonth) + .paymentStatus(PaymentStatusEnum.BALANCE.getValue()) + .employeeId(employeeId) + .paymentOrganization(paymentOrganization) + .build()); + + if (balanceAccountPO != null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "补差数据已存在,不可重复新增!")); + } + DataCollectionEmployee employeeById = getSalaryEmployeeService(user).getEmployeeById(employeeId); + + InsuranceAccountDetailPO insuranceAccountDetailPO = new InsuranceAccountDetailPO(); + insuranceAccountDetailPO.setId(IdGenerator.generate()); + insuranceAccountDetailPO.setEmployeeId(employeeId); + if (employeeById != null) { + insuranceAccountDetailPO.setSubcompanyName(employeeById.getSubcompanyName()); + insuranceAccountDetailPO.setSubcompanyId(employeeById.getSubcompanyid()); + insuranceAccountDetailPO.setDepartmentName(employeeById.getDepartmentName()); + insuranceAccountDetailPO.setDepartmentId(employeeById.getDepartmentId()); + insuranceAccountDetailPO.setJobtitleName(employeeById.getJobtitleName()); + insuranceAccountDetailPO.setJobtitleId(employeeById.getJobtitleId()); + insuranceAccountDetailPO.setJobcall(employeeById.getJobcall()); + insuranceAccountDetailPO.setJobcallId(employeeById.getJobcallId()); + insuranceAccountDetailPO.setStatus(employeeById.getStatus()); + } + + + insuranceAccountDetailPO.setBillMonth(billMonth); + insuranceAccountDetailPO.setBillStatus(BillStatusEnum.NOT_ARCHIVED.getValue()); + insuranceAccountDetailPO.setPaymentStatus(PaymentStatusEnum.BALANCE.getValue()); + insuranceAccountDetailPO.setResourceFrom(ResourceFromEnum.IMPORT.getValue()); + + insuranceAccountDetailPO.setCreator(creator); + insuranceAccountDetailPO.setDeleteType(DeleteTypeEnum.NOT_DELETED.getValue()); + insuranceAccountDetailPO.setCreateTime(new Date()); + insuranceAccountDetailPO.setUpdateTime(new Date()); + insuranceAccountDetailPO.setTenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY); + insuranceAccountDetailPO.setPaymentOrganization(paymentOrganization); + insuranceAccountDetailPO.setSocialPayOrg(paymentOrganization); + insuranceAccountDetailPO.setFundPayOrg(paymentOrganization); + insuranceAccountDetailPO.setOtherPayOrg(paymentOrganization); + + InsuranceArchivesBaseInfoPO baseInfoPO = getInsuranceBaseInfoMapper().getOneByEmployeeIdAndPayOrg(employeeId, paymentOrganization); + if (baseInfoPO != null) { + InsuranceArchivesSocialSchemePO socialSchemePO = getSocialSchemeMapper().getOneById(baseInfoPO.getSocialArchivesId()); + + InsuranceArchivesFundSchemePO fundSchemePO = getFundSchemeMapper().getOneById(baseInfoPO.getFundArchivesId()); + if (socialSchemePO != null) { + insuranceAccountDetailPO.setSocialAccount(socialSchemePO.getSocialAccount()); + } + if (fundSchemePO != null) { + insuranceAccountDetailPO.setFundAccount(fundSchemePO.getFundAccount()); + insuranceAccountDetailPO.setSupplementFundAccount(fundSchemePO.getSupplementFundAccount()); + } + } + + insuranceAccountDetailPO.setSocialPerJson(param.getSocialPerJson()); + insuranceAccountDetailPO.setSocialComJson(param.getSocialComJson()); + insuranceAccountDetailPO.setFundPerJson(param.getFundPerJson()); + insuranceAccountDetailPO.setFundComJson(param.getFundComJson()); + insuranceAccountDetailPO.setOtherPerJson(param.getOtherPerJson()); + insuranceAccountDetailPO.setOtherComJson(param.getOtherComJson()); +// insuranceAccountDetailPO.setOtherSchemeId(0L); +// insuranceAccountDetailPO.setSocialSchemeId(0L); +// insuranceAccountDetailPO.setFundSchemeId(0L); + + if (getSIAccountService(user).checkBalance(insuranceAccountDetailPO) && getSIAccountService(user).checkBalancePayInsurance(insuranceAccountDetailPO)) { + accountSocialByData(insuranceAccountDetailPO, param); + accountFundByData(insuranceAccountDetailPO, param); + // 其他福利档案 + accountOtherByData(insuranceAccountDetailPO, param); + account(insuranceAccountDetailPO); + encryptUtil.encrypt(insuranceAccountDetailPO, InsuranceAccountDetailPO.class); + getInsuranceAccountDetailMapper().batchSaveAccountDetails(Collections.singletonList(insuranceAccountDetailPO)); + + //刷新bill_batch表中统计信息 + getSIAccountService(user).refreshBillBatch(paymentOrganization, billMonth); + //记录操作日志 + encryptUtil.decrypt(insuranceAccountDetailPO, InsuranceAccountDetailPO.class); + InsuranceAccountBatchPO targetPO = getInsuranceAccountBatchMapper().getByBillMonth(billMonth, paymentOrganization); + TaxAgentPO taxAgentInfo = getTaxAgentMapper().getById(targetPO.getPaymentOrganization()); + LoggerContext loggerContext = new LoggerContext(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(targetPO.getId())); + loggerContext.setTargetName(taxAgentInfo.getName() + "-" + targetPO.getBillMonth()); + loggerContext.setOperateType(OperateTypeEnum.ADD.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "福利台账明细表-新增补差")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "福利台账明细表-新增补差") + + ":" + taxAgentInfo.getName() + "-" + targetPO.getBillMonth()); + loggerContext.setNewValues(insuranceAccountDetailPO); + SalaryElogConfig.siAccountLoggerTemplate.write(loggerContext); + } else { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "补差数据中存在福利档案中未设置的福利项缴纳数值,请检查补差缴纳信息!")); + } + + } + + public List payInsuranceIdAndScopeList(Long socialSchemeId) { + //查询该福利方案下开启缴纳的福利项 + List detailPOS = getInsuranceSchemeDetailMapper().queryListBySchemeId(socialSchemeId); + List insuranceIdList = new ArrayList<>(); + if (detailPOS != null && detailPOS.size() > 0) { + //开启缴纳的 + insuranceIdList = detailPOS.stream().filter(f -> f.getIsPayment().equals(IsPaymentEnum.YES.getValue())).map(m -> { + return m.getInsuranceId() .toString() + "-" + m.getPaymentScope().toString(); + }).collect(Collectors.toList()); + } + return insuranceIdList; + } + + public InsuranceAccountDetailPO account(InsuranceAccountDetailPO insuranceAccountDetailPO) { + //个人合计 + BigDecimal socialPerson = + StringUtils.isBlank(insuranceAccountDetailPO.getSocialPerSum()) ? new BigDecimal("0") : new BigDecimal(insuranceAccountDetailPO.getSocialPerSum()); + BigDecimal fundPerson = + StringUtils.isBlank(insuranceAccountDetailPO.getFundPerSum()) ? new BigDecimal("0") : new BigDecimal(insuranceAccountDetailPO.getFundPerSum()); + BigDecimal otherPerson = + StringUtils.isBlank(insuranceAccountDetailPO.getOtherPerSum()) ? new BigDecimal("0") : new BigDecimal(insuranceAccountDetailPO.getOtherPerSum()); + BigDecimal perSum = socialPerson.add(fundPerson).add(otherPerson); + insuranceAccountDetailPO.setPerSum(perSum.toPlainString()); + //单位合计 + BigDecimal socialCom = + StringUtils.isBlank(insuranceAccountDetailPO.getSocialComSum()) ? new BigDecimal("0") : new BigDecimal(insuranceAccountDetailPO.getSocialComSum()); + BigDecimal fundCom = StringUtils.isBlank(insuranceAccountDetailPO.getFundComSum()) ? new BigDecimal("0") : new BigDecimal(insuranceAccountDetailPO.getFundComSum()); + BigDecimal otherCom = + StringUtils.isBlank(insuranceAccountDetailPO.getOtherComSum()) ? new BigDecimal("0") : new BigDecimal(insuranceAccountDetailPO.getOtherComSum()); + BigDecimal comSum = socialCom.add(fundCom).add(otherCom); + insuranceAccountDetailPO.setComSum(comSum.toPlainString()); + //社保合计 + insuranceAccountDetailPO.setSocialSum(socialPerson.add(socialCom).toPlainString()); + //公积金合计 + insuranceAccountDetailPO.setFundSum(fundPerson.add(fundCom).toPlainString()); + //其他福利合计 + insuranceAccountDetailPO.setOtherSum(otherPerson.add(otherCom).toPlainString()); + //合计 + insuranceAccountDetailPO.setTotal(perSum.add(comSum).toPlainString()); + return insuranceAccountDetailPO; + } + + public void accountFundByData(InsuranceAccountDetailPO insuranceAccountDetailPO, BalanceAccountBaseParam baseParam) { + //公积金个人 + if (StringUtils.isNotBlank(baseParam.getFundPerJson())) { + List fundPer = new ArrayList<>(); + HashMap fundPerson = JSON.parseObject(baseParam.getFundPerJson(), new HashMap().getClass()); + fundPerson.forEach((k, v) -> { + BigDecimal result = new BigDecimal(v); + fundPer.add(result); + }); + insuranceAccountDetailPO.setFundPerJson(baseParam.getFundPerJson()); + BigDecimal fundPerSum = new BigDecimal("0"); + for (BigDecimal bigDecimal : fundPer) { + fundPerSum = fundPerSum.add(bigDecimal); + } + insuranceAccountDetailPO.setFundPerSum(fundPerSum.toPlainString()); + } + //公积金单位 + if (StringUtils.isNotBlank(baseParam.getFundComJson())) { + List fundCom = new ArrayList<>(); + HashMap fundComMap = JSON.parseObject(baseParam.getFundComJson(), new HashMap().getClass()); + fundComMap.forEach((k, v) -> { + BigDecimal result = new BigDecimal(v); + fundCom.add(result); + }); + insuranceAccountDetailPO.setFundComJson(baseParam.getFundComJson()); + BigDecimal fundComSum = new BigDecimal("0"); + for (BigDecimal bigDecimal : fundCom) { + fundComSum = fundComSum.add(bigDecimal); + } + insuranceAccountDetailPO.setFundComSum(fundComSum.toPlainString()); + } + } + + public void accountOtherByData(InsuranceAccountDetailPO insuranceAccountDetailPO, BalanceAccountBaseParam baseParam) { + //其他福利个人 + if (StringUtils.isNotBlank(baseParam.getOtherPerJson())) { + List otherPer = new ArrayList<>(); + HashMap otherPerMap = JSON.parseObject(baseParam.getOtherPerJson(), new HashMap().getClass()); + otherPerMap.forEach((k, v) -> { + BigDecimal result = new BigDecimal(v); + otherPer.add(result); + }); + insuranceAccountDetailPO.setOtherPerJson(baseParam.getOtherPerJson()); + BigDecimal otherPerSum = new BigDecimal("0"); + for (BigDecimal bigDecimal : otherPer) { + otherPerSum = otherPerSum.add(bigDecimal); + } + insuranceAccountDetailPO.setOtherPerSum(otherPerSum.toPlainString()); + } + //其他福利单位 + if (StringUtils.isNotBlank(baseParam.getOtherComJson())) { + List otherCom = new ArrayList<>(); + HashMap otherComMap = JSON.parseObject(baseParam.getOtherComJson(), new HashMap().getClass()); + otherComMap.forEach((k, v) -> { + BigDecimal result = new BigDecimal(v); + otherCom.add(result); + }); + insuranceAccountDetailPO.setOtherComJson(baseParam.getOtherComJson()); + BigDecimal otherComSum = new BigDecimal("0"); + for (BigDecimal bigDecimal : otherCom) { + otherComSum = otherComSum.add(bigDecimal); + } + insuranceAccountDetailPO.setOtherComSum(otherComSum.toPlainString()); + } + } + + public void accountSocialByData(InsuranceAccountDetailPO insuranceAccountDetailPO, BalanceAccountBaseParam baseParam) { + //社保个人 + if (StringUtils.isNotBlank(baseParam.getSocialPerJson())) { + List socialPer = new ArrayList<>(); + HashMap archivesPerson = JSON.parseObject(baseParam.getSocialPerJson(), new HashMap().getClass()); + archivesPerson.forEach((k, v) -> { + BigDecimal result = new BigDecimal(v); + socialPer.add(result); + }); + insuranceAccountDetailPO.setSocialPerJson(baseParam.getSocialPerJson()); + BigDecimal socialPerSum = new BigDecimal("0"); + for (BigDecimal bigDecimal : socialPer) { + socialPerSum = socialPerSum.add(bigDecimal); + } + insuranceAccountDetailPO.setSocialPerSum(socialPerSum.toPlainString()); + } + //社保单位 + if (StringUtils.isNotBlank(baseParam.getSocialComJson())) { + List socialCom = new ArrayList<>(); + HashMap archivesCom = JSON.parseObject(baseParam.getSocialComJson(), new HashMap().getClass()); + archivesCom.forEach((k, v) -> { + BigDecimal result = new BigDecimal(v); + socialCom.add(result); + }); + insuranceAccountDetailPO.setSocialComJson(baseParam.getSocialComJson()); + BigDecimal socialComSum = new BigDecimal("0"); + for (BigDecimal bigDecimal : socialCom) { + socialComSum = socialComSum.add(bigDecimal); + } + insuranceAccountDetailPO.setSocialComSum(socialComSum.toPlainString()); + } + } + + + +} diff --git a/src/com/engine/salary/service/impl/SICategoryServiceImpl.java b/src/com/engine/salary/service/impl/SICategoryServiceImpl.java new file mode 100644 index 000000000..58f395dfb --- /dev/null +++ b/src/com/engine/salary/service/impl/SICategoryServiceImpl.java @@ -0,0 +1,485 @@ +package com.engine.salary.service.impl; + +import com.api.browser.bean.SearchConditionItem; +import com.api.browser.bean.SearchConditionOption; +import com.api.browser.util.ConditionFactory; +import com.api.browser.util.ConditionType; +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.config.SalaryElogConfig; +import com.engine.hrmelog.entity.dto.LoggerContext; +import com.engine.salary.encrypt.EncryptUtil; +import com.engine.salary.entity.siaccount.po.InsuranceAccountDetailPO; +import com.engine.salary.entity.sicategory.bo.ICategoryBO; +import com.engine.salary.entity.sicategory.dto.ICategoryDTO; +import com.engine.salary.entity.sicategory.dto.ICategoryFormDTO; +import com.engine.salary.entity.sicategory.dto.ICategoryListDTO; +import com.engine.salary.entity.sicategory.po.ICategoryPO; +import com.engine.salary.entity.sischeme.param.InsuranceSchemeParam; +import com.engine.salary.entity.sischeme.po.InsuranceSchemeDetailPO; +import com.engine.salary.enums.OperateTypeEnum; +import com.engine.salary.enums.sicategory.DataTypeEnum; +import com.engine.salary.enums.sicategory.IsPaymentEnum; +import com.engine.salary.enums.sicategory.PaymentScopeEnum; +import com.engine.salary.enums.sicategory.WelfareTypeEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.mapper.siaccount.InsuranceAccountDetailMapper; +import com.engine.salary.mapper.sicategory.ICategoryMapper; +import com.engine.salary.service.RecordsBuildService; +import com.engine.salary.service.SICategoryService; +import com.engine.salary.service.SISchemeService; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.SalaryEnumUtil; +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.page.SalaryPageUtil; +import com.mzlion.core.utils.BeanUtils; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.collections4.MapUtils; +import org.apache.commons.lang3.StringUtils; +import weaver.hrm.User; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * @Author weaver_cl + * @Description: + * @Date 2022/3/9 + * @Version V1.0 + **/ +public class SICategoryServiceImpl extends Service implements SICategoryService { + + private ICategoryMapper getICategoryMapper() { + return MapperProxyFactory.getProxy(ICategoryMapper.class); + } + + private InsuranceAccountDetailMapper getInsuranceAccountDetailMapper() { + return MapperProxyFactory.getProxy(InsuranceAccountDetailMapper.class); + } + + public RecordsBuildService getRecordsBuildService(User user) { + return ServiceUtil.getService(RecordsBuildServiceImpl.class, user); + } + + private EncryptUtil encryptUtil = new EncryptUtil(); + + private SISchemeService getSISchemeService(User user) { + return ServiceUtil.getService(SISchemeServiceImpl.class,user); + } + + @Override + public Map getForm(Map params) { +// return commandExecutor.execute(new SICategoryGetFormCmd(params,user)); + Map apidatas = new HashMap<>(16); + Long id = (Long) params.get("id"); +// ICategoryFormDTO form = siCategoryBiz.getForm(id); + ICategoryFormDTO form = getForm(id); + apidatas.put("form",form); + ConditionFactory conditionFactory = new ConditionFactory(user); + Map items = new HashMap<>(); + + SearchConditionItem input = conditionFactory.createCondition(ConditionType.INPUT,0, "insuranceName"); + input.setColSpan(2);//定义一行显示条件数,默认值为2,当值为1时标识该条件单独占一行 + input.setFieldcol(12); //条件输入框所占宽度,默认值18 + input.setViewAttr(3); // 编辑权限 1:只读,2:可编辑, 3:必填 默认2 + input.setLength(10); // 设置输入长度 + input.setLabel(SalaryI18nUtil.getI18nLabel(0,"福利名称")); //设置文本值 这个将覆盖多语言标签的值 + input.setRules("required"); //设置字段填入规则 + + items.put("insuranceName",input); + + SearchConditionItem radio = conditionFactory.createCondition(ConditionType.RADIO,0,"welfareType"); + List radioOptions = new ArrayList <>(); + radioOptions.add(new SearchConditionOption("SOCIAL_SECURITY",SalaryI18nUtil.getI18nLabel(0,"社保"),true)); + radioOptions.add(new SearchConditionOption("ACCUMULATION_FUND",SalaryI18nUtil.getI18nLabel(0,"公积金"))); + radioOptions.add(new SearchConditionOption("OTHER",SalaryI18nUtil.getI18nLabel(0,"企业年金及其他福利"))); + radio.setColSpan(2); + radio.setFieldcol(12); + radio.setLabelcol(6); + radio.setViewAttr(3); + radio.setIsQuickSearch(false); + radio.setOptions(radioOptions); + radio.setLabel(SalaryI18nUtil.getI18nLabel(0,"类型")); + radio.setRules("required"); + items.put("welfareType",radio); + + SearchConditionItem checkbox = conditionFactory.createCondition(ConditionType.CHECKBOX,0,"paymentScope"); + List checkOptions = new ArrayList <>(); + checkOptions.add(new SearchConditionOption("SCOPE_COMPANY",SalaryI18nUtil.getI18nLabel(0,"公司"))); + checkOptions.add(new SearchConditionOption("SCOPE_PERSON",SalaryI18nUtil.getI18nLabel(0,"个人"))); + checkbox.setColSpan(2); + checkbox.setFieldcol(12); + checkbox.setLabelcol(6); + checkbox.setViewAttr(3); + checkbox.setIsQuickSearch(false); + checkbox.setOptions(checkOptions); + checkbox.setLabel(SalaryI18nUtil.getI18nLabel(0,"缴纳对象")); + checkbox.setRules("required"); + items.put("paymentScope",checkbox); + + apidatas.put("item",items); + //记录操作日志 + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(form.getId())); + loggerContext.setTargetName(form.getInsuranceName()); + loggerContext.setOperateType(OperateTypeEnum.READ.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "查看自定义福利明细")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "查看自定义福利明细") + ": " + form.getInsuranceName()); + SalaryElogConfig.siSchemeLoggerTemplate.write(loggerContext); + return apidatas; + } + + @Override + public Map insert(Map params) { +// return commandExecutor.execute(new SICategoryInsertCmd(params,user)); + Map apidatas = new HashMap<>(16); + ICategoryFormDTO iCategoryFormDTO = (ICategoryFormDTO)params.get("iCategoryFormDTO"); +// siCategoryBiz.save(iCategoryFormDTO,(long) user.getUID()); + save(iCategoryFormDTO,(long) user.getUID()); + return apidatas; + } + + @Override + public Map update(Map params) { +// return commandExecutor.execute(new SICategoryUpdateCmd(params,user)); + Map apidatas = new HashMap(16); + ICategoryFormDTO iCategoryFormDTO = (ICategoryFormDTO) params.get("iCategoryFormDTO"); +// siCategoryBiz.update(iCategoryFormDTO, (long) user.getUID()); + update(iCategoryFormDTO); + return apidatas; + } + + @Override + public Map updateStatusById(Map params) { +// return commandExecutor.execute(new SICategoryUpdateStatusByIdCmd(params,user)); + Map apidatas = new HashMap(16); + Long id = (Long) params.get("id"); + Integer isUse = (Integer) params.get("isUse"); +// siCategoryBiz.updateStatusById(id, isUse,(long) user.getUID()); + updateStatusById(id, isUse); + return apidatas; + } + + @Override + public PageInfo listPage(InsuranceSchemeParam queryParam) { + Integer welfareType = null; + if(Objects.nonNull(queryParam.getWelfareTypeEnum())){ + welfareType = queryParam.getWelfareTypeEnum().getValue(); + } + List list = getICategoryMapper().listCustomInsurance(welfareType); + list.stream().forEach(DTO -> { + DTO.setWelfareTypeSpan( buildWelfareType(new Integer(DTO.getWelfareType())).getDefaultLabel() ); ; + DTO.setPaymentScopeSpan( buildPaymentScope( DTO.getPaymentScope())); + }); + PageInfo page = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), list, ICategoryListDTO.class); + return page; + } + + public WelfareTypeEnum buildWelfareType(Integer value) { + return SalaryEnumUtil.enumMatchByValue(value, WelfareTypeEnum.values(), WelfareTypeEnum.class); + } + + + +// @Override +// public PageInfo listPage(WelfareTypeEnum welfareType) { +// getICategoryMapper().listByWelfareType(welfareType.getValue(),0); +// Page insuranceCategoryListDTOPage = new Page<>(page.getCurrent(), page.getSize(), page.getTotal(), page.isSearchCount()); +// insuranceCategoryListDTOPage.setRecords(InsuranceCategoryBO.convertToCustomCategoryList(page.getRecords(), employeeId, tenantKey)); +// return insuranceCategoryListDTOPage; +// } + + @Override + public Map categoryIdNameMap() { + //系统福利类型 + Map systemAndCustomMap = getICategoryMapper().listAll().stream() + .collect(Collectors.toMap(ICategoryPO::getId, ICategoryPO::getInsuranceName)); + HashMap total = new HashMap<>(); + if (MapUtils.isNotEmpty(systemAndCustomMap)) { + total.putAll(systemAndCustomMap); + } + + HashMap result = new HashMap<>(); + total.forEach((k, v) -> { + result.put(String.valueOf(k), v); + }); + + return result; + } + + @Override + public ICategoryDTO getByID(Long customCategoryId) { + ICategoryPO categoryPO = getICategoryMapper().getByIdAndDataType(customCategoryId, DataTypeEnum.CUSTOM.getValue()); + ICategoryDTO categoryDTO = convertICategoryPO2DTO(categoryPO); + return categoryDTO; + } + + @Override + public Map updateCategoryName(ICategoryFormDTO iCategoryFormDTO) { + ICategoryPO categoryPO = getICategoryMapper().getByIdAndDataType(iCategoryFormDTO.getId(), DataTypeEnum.CUSTOM.getValue()); + if(categoryPO == null){ + throw new SalaryRunTimeException("自定义福利不存在"); + } + // 判断是否启用 + Integer isUse = categoryPO.getIsUse(); + if(isUse == 1){ + throw new SalaryRunTimeException("编辑失败,请先关闭启用按钮!"); + } + // 判断福利名称是否重复 + List iCategoryPOS = getICategoryMapper().listByName(iCategoryFormDTO.getInsuranceName()); + if(CollectionUtils.isNotEmpty(iCategoryPOS)){ + throw new SalaryRunTimeException("福利名称不能重复"); + } + ICategoryPO iCategoryPO = ICategoryPO.builder().id(iCategoryFormDTO.getId()).insuranceName(iCategoryFormDTO.getInsuranceName()).build(); + getICategoryMapper().updateNameById(iCategoryPO); + return null; + } + + @Override + public Map updateCategoryNameAndPayScope(ICategoryFormDTO iCategoryFormDTO) { + ICategoryPO categoryPO = getICategoryMapper().getByIdAndDataType(iCategoryFormDTO.getId(), DataTypeEnum.CUSTOM.getValue()); + if(categoryPO == null){ + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "自定义福利不存在")); + } + // 判断是否启用 + Integer isUse = categoryPO.getIsUse(); + if(isUse == 1){ + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "编辑失败,请先关闭启用按钮!")); + } + // 判断福利名称是否重复 + List iCategoryPOS = getICategoryMapper().listByName(iCategoryFormDTO.getInsuranceName()); + iCategoryPOS = iCategoryPOS.stream().filter(f -> !f.getId().equals(iCategoryFormDTO.getId())).collect(Collectors.toList()); + if(CollectionUtils.isNotEmpty(iCategoryPOS)){ + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "福利名称不能重复")); + } + ICategoryPO iCategoryPO = ICategoryPO.builder().id(iCategoryFormDTO.getId()).insuranceName(iCategoryFormDTO.getInsuranceName()) + .paymentScope(SalaryEnumUtil.enumArrToString(iCategoryFormDTO.getPaymentScope())) + .updateTime(new Date()) + .build(); + getICategoryMapper().updateNameAndPayScopeById(iCategoryPO); + //记录操作日志 + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(iCategoryPO.getId())); + loggerContext.setTargetName(iCategoryPO.getInsuranceName()); + loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "更新自定义福利信息")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "更新自定义福利信息")); + loggerContext.setNewValues(iCategoryPO); + SalaryElogConfig.siCategoryLoggerTemplate.write(loggerContext); + return null; + } + + @Override + public Map deleteCustomCategory(ICategoryFormDTO iCategoryFormDTO) { + ICategoryPO categoryPO = getICategoryMapper().getByIdAndDataType(iCategoryFormDTO.getId(), DataTypeEnum.CUSTOM.getValue()); + if(categoryPO == null){ + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "自定义福利不存在")); + } + // 判断是否启用 + Integer isUse = categoryPO.getIsUse(); + if(isUse == 1){ + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "删除失败,请先关闭启用按钮!")); + } + // 判断自定义福利项是否存在核算数据 + //获取所有福利核算数据 + List insuranceAccountDetailPOS = getInsuranceAccountDetailMapper().listAll(); + encryptUtil.decryptList(insuranceAccountDetailPOS, InsuranceAccountDetailPO.class); + //数据组装 + List> records = getRecordsBuildService(user).buildCommonRecords(insuranceAccountDetailPOS, null, false); + String welfareTypeName = ""; + switch (categoryPO.getWelfareType()) { + case 1: + welfareTypeName = "social"; + break; + case 2: + welfareTypeName = "fund"; + break; + case 3: + welfareTypeName = "other"; + break; + default: + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(542456, "福利类型不在")); + } + String welfareNameStart = categoryPO.getId() + welfareTypeName; + //校验福利项是否存在核算记录 + records.forEach(f -> { + if (!Objects.isNull(f.get(welfareNameStart + "Per")) + || !Objects.isNull(f.get(welfareNameStart + "Com")) + || !Objects.isNull(f.get(welfareNameStart + "Base"))) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "删除失败,已存在福利核算记录")); + } + }); + + //删除自定义福利项 + categoryPO.setUpdateTime(new Date()); + getICategoryMapper().deleteCustomCategoryById(categoryPO); + //记录操作日志 + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(categoryPO.getId())); + loggerContext.setTargetName(categoryPO.getInsuranceName()); + loggerContext.setOperateType(OperateTypeEnum.DELETE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "新建自定义福利项")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "新建自定义福利项")); +// loggerContext.setNewValues(categoryPO); + SalaryElogConfig.siCategoryLoggerTemplate.write(loggerContext); + return null; + } + + private ICategoryDTO convertICategoryPO2DTO(ICategoryPO iCategoryPO){ + return ICategoryDTO.builder().id(iCategoryPO.getId()).insuranceName(iCategoryPO.getInsuranceName()) + .welfareType(iCategoryPO.getWelfareType()) + .welfareTypeSpan(WelfareTypeEnum.getDefaultLabelByValue(iCategoryPO.getWelfareType())) + .paymentScope(iCategoryPO.getPaymentScope()) + .paymentScopeSpan(buildPaymentScope(iCategoryPO.getPaymentScope())) + .isUse(iCategoryPO.getIsUse()).build(); + } + + private String buildPaymentScope(String paymentScope) { + List paymentScopes = Arrays.asList(paymentScope.split(",")); + List collect = paymentScopes.stream().map(scope -> PaymentScopeEnum.getDefaultLabelByValue(SalaryEntityUtil.string2Integer(scope))).collect(Collectors.toList()); + return StringUtils.join(collect, ","); + } + /*****以下代码为SICategoryBiz中逻辑迁移,旨在减少Biz类的使用*****/ + + /** + * 自定义福利表单 + * id == null ? 新建表单 : 查看已有数据内容表单 + * @param id 自定义福利主键 + * @return 表单 + */ + public ICategoryFormDTO getForm(Long id) { + if (id != null) { + ICategoryPO iCategoryPO = getICategoryPOByID(id); + ICategoryFormDTO iCategoryFormDTO = new ICategoryFormDTO(); + if (Objects.isNull(iCategoryPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"数据不存在")); + } + BeanUtils.copyProperties(iCategoryPO,iCategoryFormDTO); + iCategoryFormDTO.setWelfareType(SalaryEnumUtil.enumMatchByValue(iCategoryPO.getWelfareType(), WelfareTypeEnum.values(), WelfareTypeEnum.class)); + iCategoryFormDTO.setPaymentScope(SalaryEnumUtil.stringToEnums(iCategoryPO.getPaymentScope(), ",")); + return iCategoryFormDTO; + } + + return ICategoryFormDTO.builder().welfareType(WelfareTypeEnum.SOCIAL_SECURITY).build(); + } + + /** + * 根据id获取 + * @param id + * @return + */ + @Override + public ICategoryPO getICategoryPOByID(Long id) { + + ICategoryPO iCategoryPO = getICategoryMapper().getById(id); + return iCategoryPO; + + } + + /** + * 根据名称获取 + * @param insuranceName + * @return + */ + @Override + public List listByName(String insuranceName) { + + List iCategoryPOS = getICategoryMapper().listByName(insuranceName); + return iCategoryPOS; + + } + + /** + * 保存 + * @param iCategoryFormDTO + * @param employeeId DataTypeEnum.SYSTEM.getValue() + */ + public void save(ICategoryFormDTO iCategoryFormDTO, long employeeId) { + iCategoryFormDTO.setInsuranceName(StringUtils.trim(iCategoryFormDTO.getInsuranceName())); + List iCategoryPOS = listByName(iCategoryFormDTO.getInsuranceName()); + if (CollectionUtils.isNotEmpty(iCategoryPOS)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"福利名称不允许重复")); + } + ICategoryPO iCategoryPO = ICategoryBO.convertToInsuranceCategoryPO(iCategoryFormDTO, employeeId); + getICategoryMapper().insert(iCategoryPO); + //记录操作日志 + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(iCategoryPO.getId())); + loggerContext.setTargetName(iCategoryPO.getInsuranceName()); + loggerContext.setOperateType(OperateTypeEnum.ADD.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "新建自定义福利项")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "新建自定义福利项")); + loggerContext.setNewValues(iCategoryPO); + SalaryElogConfig.siCategoryLoggerTemplate.write(loggerContext); + } + + /** + * 更新 + * @param iCategoryFormDTO + */ + public void update(ICategoryFormDTO iCategoryFormDTO) { + if (iCategoryFormDTO.getId() == null) { + throw new SalaryRunTimeException("id is required"); + } + ICategoryPO iCategoryPO = getICategoryPOByID(iCategoryFormDTO.getId()); + if (Objects.isNull(iCategoryPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"数据不存在")); + } + List iCategoryPOS = listByName(iCategoryFormDTO.getInsuranceName()); + if (CollectionUtils.isNotEmpty(iCategoryPOS)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"福利名称不允许重复")); + } + iCategoryPO.setInsuranceName(iCategoryFormDTO.getInsuranceName()); +// iCategoryPO.setWelfareType(iCategoryFormDTO.getWelfareType().getValue()); +// iCategoryPO.setPaymentScope(SalaryEnumUtil.enumArrToString(iCategoryFormDTO.getPaymentScope())); + iCategoryPO.setUpdateTime(new Date()); + + getICategoryMapper().update(iCategoryPO); + + } + + /** + * 更新状态 + * @param id + * @param isUse + */ + public void updateStatusById(Long id, Integer isUse) { + + if(id == null) { + throw new SalaryRunTimeException("id is required"); + } + if (isUse == null) { + throw new SalaryRunTimeException("isUse is required"); + } +// List insuranceSchemeDetailPOS = new SISchemeBiz().queryListByInsuranceIdIsPayment(id, IsPaymentEnum.YES.getValue()); + List insuranceSchemeDetailPOS = getSISchemeService(user).queryListByInsuranceIdIsPayment(id, IsPaymentEnum.YES.getValue()); + if(CollectionUtils.isNotEmpty(insuranceSchemeDetailPOS) && isUse == 0) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"该福利开启缴费,不可删除(或停用)")); + } + ICategoryPO iCategoryPO = getICategoryPOByID(id); + if (Objects.isNull(iCategoryPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"数据记录不存在")); + } + iCategoryPO.setIsUse(isUse); + getICategoryMapper().updateById(iCategoryPO); + //记录操作日志 + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(iCategoryPO.getId())); + loggerContext.setTargetName(iCategoryPO.getInsuranceName()); + loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "更新自定义福利状态")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "更新自定义福利状态")); + loggerContext.setNewValues(iCategoryPO); + SalaryElogConfig.siCategoryLoggerTemplate.write(loggerContext); + } + + /*****以上代码为SICategoryBiz中方法逻辑迁移,旨在减少Biz类的使用*****/ + +} diff --git a/src/com/engine/salary/service/impl/SICompensationServiceImpl.java b/src/com/engine/salary/service/impl/SICompensationServiceImpl.java new file mode 100644 index 000000000..a6c4cb5d8 --- /dev/null +++ b/src/com/engine/salary/service/impl/SICompensationServiceImpl.java @@ -0,0 +1,724 @@ +package com.engine.salary.service.impl; + +import com.alibaba.fastjson.JSON; +import com.alipay.oceanbase.jdbc.StringUtils; +import com.cloudstore.eccom.pc.table.WeaTable; +import com.cloudstore.eccom.pc.table.WeaTableColumn; +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.config.SalaryElogConfig; +import com.engine.salary.constant.SalaryDefaultTenantConstant; +import com.engine.hrmelog.entity.dto.LoggerContext; +import com.engine.salary.encrypt.EncryptUtil; +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.hrm.dto.HrmInfoDTO; +import com.engine.salary.entity.hrm.param.HrmQueryParam; +import com.engine.salary.entity.siaccount.dto.InsuranceCompensationDTO; +import com.engine.salary.entity.siaccount.param.CompensationParam; +import com.engine.salary.entity.siaccount.po.InsuranceAccountBatchPO; +import com.engine.salary.entity.siaccount.po.InsuranceAccountDetailPO; +import com.engine.salary.entity.siaccount.po.InsuranceCompensationConfigPO; +import com.engine.salary.entity.siaccount.po.InsuranceCompensationPO; +import com.engine.salary.entity.sicategory.po.ICategoryPO; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import com.engine.salary.enums.OperateTypeEnum; +import com.engine.salary.enums.datacollection.UseEmployeeTypeEnum; +import com.engine.salary.enums.siaccount.PaymentStatusEnum; +import com.engine.salary.enums.sicategory.DeleteTypeEnum; +import com.engine.salary.exception.SalaryRunTimeException; +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.InsuranceCompensationConfigMapper; +import com.engine.salary.mapper.siaccount.InsuranceCompensationMapper; +import com.engine.salary.mapper.sicategory.ICategoryMapper; +import com.engine.salary.mapper.taxagent.TaxAgentMapper; +import com.engine.salary.service.*; +import com.engine.salary.util.SalaryAssert; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.db.MapperProxyFactory; +import com.engine.salary.util.page.Column; +import com.google.common.collect.Lists; +import com.engine.salary.util.db.IdGenerator; +import org.springframework.beans.BeanUtils; +import weaver.hrm.User; + +import java.math.BigDecimal; +import java.util.*; +import java.util.function.Function; +import java.util.stream.Collectors; + +/** + * @Author: sy + * @Description: 福利台账-调差实现类 + * @Date: 2022/11/23 + **/ +public class SICompensationServiceImpl extends Service implements SICompensationService { + private EncryptUtil encryptUtil = new EncryptUtil(); + + private InsuranceAccountDetailMapper getInsuranceAccountDetailMapper() { + return MapperProxyFactory.getProxy(InsuranceAccountDetailMapper.class); + } + + private EmployMapper getEmployMapper() { + return MapperProxyFactory.getProxy(EmployMapper.class); + } + + public SICategoryService getSICategoryService(User user) { + return ServiceUtil.getService(SICategoryServiceImpl.class, user); + } + + private SIAccountService getSIAccountService(User user) { + return ServiceUtil.getService(SIAccountServiceImpl.class, user); + } + + private InsuranceCompensationMapper getInsuranceCompensationMapper() { + return MapperProxyFactory.getProxy(InsuranceCompensationMapper.class); + } + + private InsuranceCompensationConfigMapper getInsuranceCompensationConfigMapper() { + return MapperProxyFactory.getProxy(InsuranceCompensationConfigMapper.class); + } + + public ColumnBuildService getColumnBuildService(User user) { + return ServiceUtil.getService(ColumnBuildServiceImpl.class, user); + } + + private ICategoryMapper getICategoryMapper() { + return MapperProxyFactory.getProxy(ICategoryMapper.class); + } + + private SalaryEmployeeService getSalaryEmployeeService(User user) { + return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user); + } + + private InsuranceAccountBatchMapper getInsuranceAccountBatchMapper() { + return MapperProxyFactory.getProxy(InsuranceAccountBatchMapper.class); + } + + private TaxAgentMapper getTaxAgentMapper() { + return MapperProxyFactory.getProxy(TaxAgentMapper.class); + } + + /** + * 可调差人员 + */ + @Override + public List getEmployeeListToCompensation(HrmQueryParam param) { + // 当前登录人员 + Long currentEmployeeId = (long) user.getUID(); + + //查询账单月份+个税扣缴义务人下的社保福利正常缴纳人员列表 + List normalDataList = getInsuranceAccountDetailMapper().queryNormalListByBillMonth(param.getBillMonth(), param.getPaymentOrganization()); + List empIds = normalDataList.stream().map(InsuranceAccountDetailPO::getEmployeeId).collect(Collectors.toList()); + //生成人员id和bill_detail.id的对应map + Map empIdToTargetMap = SalaryEntityUtil.convert2Map(normalDataList, InsuranceAccountDetailPO::getEmployeeId, InsuranceAccountDetailPO::getId); + + List resultData = new ArrayList<>(); + if (empIds.size() > 0) { + List> partition = Lists.partition(empIds, 1000); + partition.forEach(p -> { + param.setIds(p); + resultData.addAll(getEmployMapper().listHrmInfoByIdAndName(param)); + resultData.addAll(getEmployMapper().listExtHrmInfoByIdAndName(param)); + }); + + } + List finalResultData = new ArrayList<>(); + for (HrmInfoDTO dto : resultData) { + dto.setTarget(empIdToTargetMap.get(dto.getEmployeeId())); + finalResultData.add(dto); + } + + return finalResultData; + } +// public PageInfo getEmployeeListToCompensation(HrmQueryParam param) { +// // 当前登录人员 +// Long currentEmployeeId = (long) user.getUID(); +// +// //查询账单月份+个税扣缴义务人下的社保福利正常缴纳人员列表 +// List normalDataList = getInsuranceAccountDetailMapper().queryNormalListByBillMonth(param.getBillMonth(), param.getPaymentOrganization()); +// List empIds = normalDataList.stream().map(InsuranceAccountDetailPO::getEmployeeId).collect(Collectors.toList()); +// +// List resultData = new ArrayList<>(); +// if (empIds.size() > 0) { +// List> partition = Lists.partition(empIds, 1000); +// partition.forEach(p -> { +// param.setIds(p); +// resultData.addAll(getEmployMapper().listHrmInfoByIdAndName(param)); +// }); +// +// } +// +// // 分页 +// PageInfo page = new PageInfo<>(); +// if (resultData.size() == 0) { +// return page; +// } +// page.setTotal(resultData.size()); +// +// page.setList(SalaryPageUtil.subList(param.getPageNum(), param.getPageSize(), resultData)); +// page.setPageSize(param.getPageSize()); +// page.setPageNum(param.getPageNum()); +// +// +// return page; +// } + + /** + * 调差福利项 + * @param id InsuranceAccountDetailPO.id + */ + @Override + public List> compensationCategoryType(Long id) { + SalaryAssert.notNull(id, SalaryI18nUtil.getI18nLabel(120999, "调差对象必选")); + InsuranceAccountDetailPO insuranceAccountDetailPO = getInsuranceAccountDetailMapper().getById(id); + if (insuranceAccountDetailPO == null) { + return Lists.newArrayList(); + } + encryptUtil.decrypt(insuranceAccountDetailPO, InsuranceAccountDetailPO.class); + List> result = new ArrayList<>(); + String socialComJson = insuranceAccountDetailPO.getSocialComJson(); + if (StringUtils.isNotBlank(socialComJson)) { + Map categoryIdNameMap = getSICategoryService(user).categoryIdNameMap(); + Map socialJson = JSON.parseObject(socialComJson, new HashMap().getClass()); + for (Map.Entry entry : socialJson.entrySet()) { + Map temp = new HashMap<>(); + String insuranceId = entry.getKey(); + if (StringUtils.isNotBlank(categoryIdNameMap.get(insuranceId))) { + temp.put("id", insuranceId); + temp.put("content", categoryIdNameMap.get(insuranceId)); + result.add(temp); + } + } + } + return result; + } + + /** + * 获取当前调差福利类型-公司方支出总计 + */ + @Override + public List> compensationComTotal(List paramList) { + List> resultList = new ArrayList<>(); + paramList.forEach(compensation -> { + Map temp = new HashMap<>(); + temp.put("employeeId", compensation.getEmployeeId()); + if (StringUtils.isBlank(compensation.getCategoryType()) || compensation.getTarget() == null) { + temp.put("error", SalaryI18nUtil.getI18nLabel(84026, "参数错误")); + temp.put("totalNum", "0"); + } else { + + InsuranceAccountDetailPO insuranceAccountDetailPO = getInsuranceAccountDetailMapper().getById(compensation.getTarget()); + if (insuranceAccountDetailPO == null) { + temp.put("error", SalaryI18nUtil.getI18nLabel(121038, "当前月在该缴纳组织下没有核算记录")); + temp.put("totalNum", "0"); + } else { + encryptUtil.decrypt(insuranceAccountDetailPO, InsuranceAccountDetailPO.class); + //判断是否已有调差数据(个税扣缴义务人+账单月份+人员id) +// InsuranceCompensationPO nowCompensation = getInsuranceCompensationMapper().getOneByBillMonthPayOrgEmpId(InsuranceCompensationPO.builder() +// .billMonth(insuranceAccountDetailPO.getBillMonth()) +// .paymentOrganization(insuranceAccountDetailPO.getPaymentOrganization()) +// .employeeId(insuranceAccountDetailPO.getEmployeeId()) +// .build()); +// +// if (nowCompensation != null) { +// temp.put("error", SalaryI18nUtil.getI18nLabel(121039, "当前月在该缴纳组织下已存在调差数据")); +// } + + //处理调差数据 + BigDecimal total = new BigDecimal("0"); + List categoryTypeList = Arrays.asList(compensation.getCategoryType().split(",")); + + if (StringUtils.isNotBlank(insuranceAccountDetailPO.getSocialComJson())) { + Map socialJson = JSON.parseObject(insuranceAccountDetailPO.getSocialComJson(), new HashMap().getClass()); + for (Map.Entry entry : socialJson.entrySet()) { + String insuranceId = entry.getKey(); + String num = entry.getValue(); + if (categoryTypeList.contains(insuranceId)) { + total = total.add(new BigDecimal(num)); + } + } + } + + temp.put("totalNum", total.toPlainString()); + } + + } + resultList.add(temp); + }); +// paramList.forEach((paymentOrganization, compensationList) -> { +// List> paymentList = new ArrayList<>(); +// compensationList.forEach(compensation -> { +// Map temp = new HashMap<>(); +// temp.put("employeeId", compensation.getEmployeeId()); +// if (StringUtils.isBlank(compensation.getCategoryType()) || compensation.getTarget() == null) { +// temp.put("error", SalaryI18nUtil.getI18nLabel(84026, "参数错误")); +// temp.put("totalNum", "0"); +// } else { +// +// InsuranceAccountDetailPO insuranceAccountDetailPO = getInsuranceAccountDetailMapper().getById(compensation.getTarget()); +// if (insuranceAccountDetailPO == null) { +// temp.put("error", SalaryI18nUtil.getI18nLabel(121038, "当前月在该缴纳组织下没有核算记录")); +// } +// InsuranceAccountDetailPOEncrypt.decryptItem(insuranceAccountDetailPO); +// BigDecimal total = new BigDecimal("0"); +// List categoryTypeList = Arrays.asList(compensation.getCategoryType().split(",")); +// +// if (StringUtils.isNotBlank(insuranceAccountDetailPO.getSocialComJson())) { +// Map socialJson = JSON.parseObject(insuranceAccountDetailPO.getSocialComJson(), new HashMap().getClass()); +// for (Map.Entry entry : socialJson.entrySet()) { +// String insuranceId = entry.getKey(); +// String num = entry.getValue(); +// if (categoryTypeList.contains(insuranceId)) { +// total = total.add(new BigDecimal(num)); +// } +// } +// } +// +// temp.put("totalNum", total.toPlainString()); +// } +// paymentList.add(temp); +// }); +// result.put(paymentOrganization, paymentList); +// }); + return resultList; + } + + @Override + public Map compensationAccount(List list) { + + long currentEmployeeId = user.getUID(); +// List allEmployees = getEmployMapper().listAll(); + List allEmployees = getSalaryEmployeeService(user).listAll(UseEmployeeTypeEnum.ALL); + Map usernameMap = SalaryEntityUtil.convert2Map(allEmployees, DataCollectionEmployee::getEmployeeId, DataCollectionEmployee::getUsername); + + Map result = new HashMap<>(); + List errorList = new ArrayList<>(); + List idList = new ArrayList<>(); + //过滤 + list = list.stream().collect(Collectors.collectingAndThen( + Collectors.toCollection(() -> + new TreeSet<>(Comparator.comparing((o -> o.getTarget() + ";" + o.getAdjustTo() + ";" + o.getCategoryType())))), ArrayList::new)); + + //根据target分组 + Map> compensationGroupInfoMap= list.stream().collect(Collectors.groupingBy(InsuranceCompensationDTO::getTarget)); + //取福利项id和name的关联map + List socialWelfareList = getICategoryMapper().listAll().stream().filter(e -> e.getWelfareType() == 1).collect(Collectors.toList()); + Map welfareNameMap = socialWelfareList.stream().collect(Collectors.toMap(ICategoryPO::getId, ICategoryPO::getInsuranceName, (key1, key2) -> key2)); + for (InsuranceCompensationDTO param : list) { + //判断“统计调差福利类型”即categoryType中,是否存在同保存批次重复福利项 + List waitJudgeCompensations = compensationGroupInfoMap.get(param.getTarget()).stream(). + filter(f -> !f.getTarget().equals(param.getTarget()) && !f.getAdjustTo().equals(param.getAdjustTo()) && !f.getCategoryType().equals(param.getCategoryType())).collect(Collectors.toList()); + if (waitJudgeCompensations.size() > 0) { + boolean judgeResult = true; + for (InsuranceCompensationDTO judgeParam : waitJudgeCompensations) { + List toDealWelfareTypeList = Arrays.asList(param.getCategoryType().split(",")); + List toJudgeWelfareTypeList = Arrays.asList(judgeParam.getCategoryType().split(",")); +// toDealWelfareTypeList.retainAll(toJudgeWelfareTypeList); + List intersectionList = (List) SalaryEntityUtil.intersectionForList(toDealWelfareTypeList, toJudgeWelfareTypeList); + if (intersectionList.size() > 0) { + StringBuilder toDealWelfareNames = new StringBuilder(); + StringBuilder sameWelfareNames = new StringBuilder(); + for(String str : toDealWelfareTypeList) { + if (welfareNameMap.get(Long.valueOf(str)) != null) { + toDealWelfareNames.append(welfareNameMap.get(Long.valueOf(str))).append("、"); + } + } + for(String str : intersectionList) { + if (welfareNameMap.get(Long.valueOf(str)) != null) { + sameWelfareNames.append(welfareNameMap.get(Long.valueOf(str))).append("、"); + } + } + errorList.add(usernameMap.get(param.getEmployeeId()) + "-" + toDealWelfareNames.deleteCharAt(toDealWelfareNames.length() - 1) + + "-调差失败:提交数据中,统计调差福利类型有重合部分!" + "重合福利部分为:" + sameWelfareNames.deleteCharAt(sameWelfareNames.length() - 1)); + judgeResult = false; + break; + } + } + if (!judgeResult) { + continue; + } + + } + + if (StringUtils.isBlank(param.getAdjustmentTotal()) || "0".equals(param.getAdjustmentTotal()) || "0.00".equals(param.getAdjustmentTotal())) { + errorList.add(usernameMap.get(param.getEmployeeId()) + "-调差失败:调差数额不正确!"); + continue; + } + if (StringUtils.isBlank(param.getCompanyTotal()) || "0".equals(param.getCompanyTotal()) || "0.00".equals(param.getCompanyTotal())) { + errorList.add(usernameMap.get(param.getEmployeeId()) + "-调差失败:公司核算金额为0,请检查数据是否属实或者当前人员已存在该月调差数据!"); + continue; + } + if (param.getAdjustTo() == null) { + errorList.add(usernameMap.get(param.getEmployeeId()) + "-调差失败:调差到的福利未设置!"); + continue; + } + InsuranceAccountDetailPO insuranceAccountDetailPO = getInsuranceAccountDetailMapper().getById(param.getTarget()); + if (insuranceAccountDetailPO == null) { + errorList.add(usernameMap.get(param.getEmployeeId()) + "-调差失败:调差对象不存在!"); + continue; + } + + if (!param.getCategoryType().contains(param.getAdjustTo().toString())) { + errorList.add(usernameMap.get(param.getEmployeeId()) + "-调差失败:调差到的福利未正确设置!"); + continue; + } + + //判断是否已有调差数据(个税扣缴义务人+账单月份+人员id) +// InsuranceCompensationPO nowCompensation = getInsuranceCompensationMapper().getOneByBillMonthPayOrgEmpId(InsuranceCompensationPO.builder() +// .billMonth(insuranceAccountDetailPO.getBillMonth()) +// .paymentOrganization(insuranceAccountDetailPO.getPaymentOrganization()) +// .employeeId(insuranceAccountDetailPO.getEmployeeId()) +// .build()); +// if (nowCompensation != null) { +// errorList.add(usernameMap.get(param.getEmployeeId()) + "-调差失败:调差对象在当前月该缴纳组织下已存在调差数据!"); +// continue; +// } + List nowCompensationList = getInsuranceCompensationMapper().getListByBillMonthPayOrgEmpId(InsuranceCompensationPO.builder() + .billMonth(insuranceAccountDetailPO.getBillMonth()) + .paymentOrganization(insuranceAccountDetailPO.getPaymentOrganization()) + .employeeId(insuranceAccountDetailPO.getEmployeeId()) + .build()); + if (nowCompensationList.size() > 0) { + boolean judgeResult = true; + for (InsuranceCompensationPO judgePO : nowCompensationList) { + List toDealWelfareTypeList = Arrays.asList(param.getCategoryType().split(",")); + List toJudgeWelfareTypeList = Arrays.asList(judgePO.getCategoryType().split(",")); + + List intersectionList = (List) SalaryEntityUtil.intersectionForList(toDealWelfareTypeList, toJudgeWelfareTypeList); + if (intersectionList.size() > 0) { + StringBuilder toDealWelfareNames = new StringBuilder(); + StringBuilder sameWelfareNames = new StringBuilder(); + for(String str : toDealWelfareTypeList) { + if (welfareNameMap.get(Long.valueOf(str)) != null) { + toDealWelfareNames.append(welfareNameMap.get(Long.valueOf(str))).append("、"); + } + } + for(String str : intersectionList) { + if (welfareNameMap.get(Long.valueOf(str)) != null) { + sameWelfareNames.append(welfareNameMap.get(Long.valueOf(str))).append("、"); + } + } + errorList.add(usernameMap.get(param.getEmployeeId()) + "-" + toDealWelfareNames.deleteCharAt(toDealWelfareNames.length() - 1) + + "-调差失败:相同福利不可以多次调差!" + "相同部分为:" + sameWelfareNames.deleteCharAt(sameWelfareNames.length() - 1)); + judgeResult = false; + break; + } + } + if (!judgeResult) { + continue; + } + } + + + encryptUtil.decrypt(insuranceAccountDetailPO, InsuranceAccountDetailPO.class); + if (StringUtils.isNotBlank(insuranceAccountDetailPO.getSocialComJson())) { + Map socialJson = JSON.parseObject(insuranceAccountDetailPO.getSocialComJson(), new HashMap().getClass()); + for (Map.Entry entry : socialJson.entrySet()) { + String insuranceId = entry.getKey(); + String num = entry.getValue(); + if (Objects.equals(String.valueOf(param.getAdjustTo()), insuranceId)) { + BigDecimal adjustmentTo = new BigDecimal(param.getAdjustmentTotal()); + // 调差单位缴纳明细 + BigDecimal insuranceNum = new BigDecimal(num); + insuranceNum = insuranceNum.add(adjustmentTo); + socialJson.replace(insuranceId, insuranceNum.toPlainString()); + insuranceAccountDetailPO.setSocialComJson(JSON.toJSONString(socialJson)); + // 调差单位合计 + BigDecimal comSum = new BigDecimal(insuranceAccountDetailPO.getComSum()); + comSum = comSum.add(adjustmentTo); + insuranceAccountDetailPO.setComSum(comSum.toPlainString()); + // 调差社保单位合计 + BigDecimal socialComSum = new BigDecimal(insuranceAccountDetailPO.getSocialComSum()); + socialComSum = socialComSum.add(adjustmentTo); + insuranceAccountDetailPO.setSocialComSum(socialComSum.toPlainString()); + // 调差社保合计 + BigDecimal socialSum = new BigDecimal(insuranceAccountDetailPO.getSocialSum()); + socialSum = socialSum.add(adjustmentTo); + insuranceAccountDetailPO.setSocialSum(socialSum.toPlainString()); + // 调差合计 + BigDecimal totalSum = new BigDecimal(insuranceAccountDetailPO.getTotal()); + totalSum = totalSum.add(adjustmentTo); + insuranceAccountDetailPO.setTotal(totalSum.toPlainString()); + //更新社保调差后的明细 + encryptUtil.encrypt(insuranceAccountDetailPO, InsuranceAccountDetailPO.class); + getInsuranceAccountDetailMapper().updateById(insuranceAccountDetailPO); + //新建调差记录 + InsuranceCompensationPO insuranceCompensationPO = new InsuranceCompensationPO(); + insuranceCompensationPO.setId(IdGenerator.generate()); + insuranceCompensationPO.setAdjustmentTotal(param.getAdjustmentTotal()); + insuranceCompensationPO.setAdjustTo(param.getAdjustTo()); + insuranceCompensationPO.setBillMonth(param.getBillMonth()); + insuranceCompensationPO.setCompanyTotal(param.getCompanyTotal()); + insuranceCompensationPO.setCreator(currentEmployeeId); + insuranceCompensationPO.setCategoryType(param.getCategoryType()); + insuranceCompensationPO.setCreateTime(new Date()); + insuranceCompensationPO.setDeleteType(DeleteTypeEnum.NOT_DELETED.getValue()); + insuranceCompensationPO.setCountryTotal(param.getCountryTotal()); + insuranceCompensationPO.setEmployeeId(insuranceAccountDetailPO.getEmployeeId()); + + insuranceCompensationPO.setPaymentOrganization(insuranceAccountDetailPO.getPaymentOrganization()); + insuranceCompensationPO.setTenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY); + insuranceCompensationPO.setWelfareType(param.getWelfareType()); + insuranceCompensationPO.setUpdateTime(new Date()); + getInsuranceCompensationMapper().insert(insuranceCompensationPO); + + idList.add(insuranceCompensationPO.getId()); +// result.put(param.getOriginId(), insuranceCompensationPO.getId().toString()); + //记录操作日志 + InsuranceAccountBatchPO targetPO = getInsuranceAccountBatchMapper().getByBillMonth(insuranceAccountDetailPO.getBillMonth(), insuranceAccountDetailPO.getPaymentOrganization()); + TaxAgentPO taxAgentInfo = getTaxAgentMapper().getById(insuranceAccountDetailPO.getPaymentOrganization()); + DataCollectionEmployee empInfo = getSalaryEmployeeService(user).getEmployeeById(insuranceAccountDetailPO.getEmployeeId()); + LoggerContext loggerContext = new LoggerContext(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(targetPO.getId())); + loggerContext.setTargetName(taxAgentInfo.getName() + "-" + insuranceAccountDetailPO.getBillMonth() + "-" + empInfo.getUsername()); + loggerContext.setOperateType(OperateTypeEnum.ADD.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "福利台账明细表-新增调差")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "福利台账明细表-新增调差") + + ":" + taxAgentInfo.getName() + "-" + insuranceAccountDetailPO.getBillMonth() + "-" + empInfo.getUsername()); + loggerContext.setNewValues(insuranceCompensationPO); + SalaryElogConfig.siAccountLoggerTemplate.write(loggerContext); + + } + } + } + } + //刷新bill_detail统计数据 + getSIAccountService(user).refreshBillBatch(list.get(0).getPaymentOrganization(), list.get(0).getBillMonth()); + if (errorList.size() == 0) { + result.put("data", "全部调差成功!"); + } else { + result.put("data", "存在调差失败项!" + "失败数量为:" + errorList.size() + "。具体有以下:"); + } + result.put("errorMessage", errorList); + result.put("successIds", idList); + return result; + } + + @Override + public String compensationConfigSave(List param) { + long currentEmployeeId = user.getUID(); + + SalaryAssert.notEmpty(param, SalaryI18nUtil.getI18nLabel(143746, "默认调差配置数据为空")); + // 清除历史默认配置 + getInsuranceCompensationConfigMapper().deleteByPayOrg(param.get(0).getPaymentOrganization()); + // 保存历史默认配置 + List configList = param.stream().map(config -> { + InsuranceAccountDetailPO insuranceAccountDetailPO = getInsuranceAccountDetailMapper().getById(config.getTarget()); + SalaryAssert.notNull(insuranceAccountDetailPO, SalaryI18nUtil.getI18nLabel(138849, "调差对象不存在")); + return InsuranceCompensationConfigPO.builder() + .id(IdGenerator.generate()) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .employeeId(insuranceAccountDetailPO.getEmployeeId()) + .adjustTo(config.getAdjustTo()) + .createTime(new Date()) + .updateTime(new Date()) + .categoryType(config.getCategoryType()) + .paymentOrganization(config.getPaymentOrganization()) + .welfareType(config.getWelfareType()) + .deleteType(DeleteTypeEnum.NOT_DELETED.getValue()) + .creator(currentEmployeeId).build(); + }).collect(Collectors.toList()); + configList.forEach(config -> getInsuranceCompensationConfigMapper().insert(config)); + //记录操作日志 + TaxAgentPO taxAgentInfo = getTaxAgentMapper().getById(param.get(0).getPaymentOrganization()); + LoggerContext loggerContext = new LoggerContext(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(param.get(0).getPaymentOrganization())); + loggerContext.setTargetName(taxAgentInfo.getName()); + loggerContext.setOperateType(OperateTypeEnum.ADD.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "福利台账明细表-保存社保调差默认配置")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "福利台账明细表-保存社保调差默认配置") + + ":" + taxAgentInfo.getName()); + configList.forEach(loggerContext::setNewValues); + SalaryElogConfig.siAccountLoggerTemplate.write(loggerContext); + + return "配置成功"; + } + + /** + * 社保调差撤回 + */ + @Override + public String compensationRevert(InsuranceCompensationDTO param) { + InsuranceCompensationPO insuranceCompensationPO = getInsuranceCompensationMapper().getById(param.getId()); + SalaryAssert.notNull(insuranceCompensationPO, SalaryI18nUtil.getI18nLabel(121112, "当前补差记录不存在")); + InsuranceAccountDetailPO insuranceAccountDetailPO = getInsuranceAccountDetailMapper().getOneByBpep(InsuranceAccountDetailPO.builder() + .billMonth(insuranceCompensationPO.getBillMonth()) + .paymentStatus(PaymentStatusEnum.COMMON.getValue()) + .employeeId(insuranceCompensationPO.getEmployeeId()) + .paymentOrganization(insuranceCompensationPO.getPaymentOrganization()) + .build()); + + SalaryAssert.notNull(insuranceAccountDetailPO, SalaryI18nUtil.getI18nLabel(121108, "补差对象不存在")); + encryptUtil.decrypt(insuranceAccountDetailPO, InsuranceAccountDetailPO.class); + if (StringUtils.isNotBlank(insuranceAccountDetailPO.getSocialComJson())) { + Map socialJson = JSON.parseObject(insuranceAccountDetailPO.getSocialComJson(), new HashMap().getClass()); + for (Map.Entry entry : socialJson.entrySet()) { + String insuranceId = entry.getKey(); + String num = entry.getValue(); + if (Objects.equals(String.valueOf(insuranceCompensationPO.getAdjustTo()), insuranceId)) { + BigDecimal adjustmentTo = new BigDecimal(insuranceCompensationPO.getAdjustmentTotal()); + //回退调差单位缴纳明细 + BigDecimal insuranceNum = new BigDecimal(num); + insuranceNum = insuranceNum.subtract(adjustmentTo); + socialJson.replace(insuranceId, insuranceNum.toPlainString()); + insuranceAccountDetailPO.setSocialComJson(JSON.toJSONString(socialJson)); + //回退调差单位合计 + BigDecimal comSum = new BigDecimal(insuranceAccountDetailPO.getComSum()); + comSum = comSum.subtract(adjustmentTo); + insuranceAccountDetailPO.setComSum(comSum.toPlainString()); + //回退调差社保单位合计 + BigDecimal socialComSum = new BigDecimal(insuranceAccountDetailPO.getSocialComSum()); + socialComSum = socialComSum.subtract(adjustmentTo); + insuranceAccountDetailPO.setSocialComSum(socialComSum.toPlainString()); + //回退调差社保合计 + BigDecimal socialSum = new BigDecimal(insuranceAccountDetailPO.getSocialSum()); + socialSum = socialSum.subtract(adjustmentTo); + insuranceAccountDetailPO.setSocialSum(socialSum.toPlainString()); + //回退调差合计 + BigDecimal totalSum = new BigDecimal(insuranceAccountDetailPO.getTotal()); + totalSum = totalSum.subtract(adjustmentTo); + insuranceAccountDetailPO.setTotal(totalSum.toPlainString()); + //更新社保调差后的明细 + encryptUtil.encrypt(insuranceAccountDetailPO, InsuranceAccountDetailPO.class); + getInsuranceAccountDetailMapper().updateById(insuranceAccountDetailPO); + //删除调差记录 + getInsuranceCompensationMapper().deleteById(param.getId()); + + } + } + //刷新bill_detail统计数据 + getSIAccountService(user).refreshBillBatch(param.getPaymentOrganization(), param.getBillMonth()); + + } + return "撤回成功"; + } + + @Override + public Map compensationList(String billMonth, Long paymentOrganization) { + + Map datas = new HashMap<>(); + + //入参判断 + if (paymentOrganization == null || StringUtils.isBlank(billMonth)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(84026, "参数错误")); + } + + //设置调差详情列表头 + List weaTableColumn = getColumnBuildService(user).buildCompensationColumns(); + WeaTable table = new WeaTable(); + table.setPageUID(UUID.randomUUID().toString()); + table.setColumns(weaTableColumn); + List columns = weaTableColumn.stream().map(v -> new Column(v.getText(), v.getColumn(), v.getColumn())).collect(Collectors.toList()); + + //处理调差数据 + List compensationDTOList = dealCompensationData(billMonth, paymentOrganization); + + datas.put("columns", columns); + datas.put("data", compensationDTOList); + + return datas; + } + + private List dealCompensationData(String billMonth, Long paymentOrganization) { + + //获取调差历史记录数据 + List compensationPOList = getInsuranceCompensationMapper().queryByBillMonthAndPayOrg(billMonth, paymentOrganization); + //获取调差配置数据 + List compensationConfigPOList = getInsuranceCompensationConfigMapper().queryByPayOrg(paymentOrganization); + + List compensationDTOList = new ArrayList<>(); + + List detailPOList = getInsuranceAccountDetailMapper().queryNormalListByBillMonth(billMonth, paymentOrganization); + Map detailPOMap = detailPOList.stream().collect(Collectors.toMap(InsuranceAccountDetailPO::getEmployeeId, Function.identity())); + + List allEmployees = getEmployMapper().listAll(); + Map usernameMap = SalaryEntityUtil.convert2Map(allEmployees, DataCollectionEmployee::getEmployeeId, DataCollectionEmployee::getUsername); + + List allCategoryList = getICategoryMapper().listAll(); + Map categoryNameMap = SalaryEntityUtil.convert2Map(allCategoryList, ICategoryPO::getId, ICategoryPO::getInsuranceName); + + boolean haveCompensation = compensationPOList != null && compensationPOList.size() > 0; + //存在调差历史记录时,输出记录数据 + if (haveCompensation) { + for (InsuranceCompensationPO po : compensationPOList) { + InsuranceCompensationDTO dto = new InsuranceCompensationDTO(); + BeanUtils.copyProperties(po, dto); + dto.setStatus(true); + //设置targetOptions + Map targetOptions = new HashMap<>(); + targetOptions.put("name", usernameMap.get(po.getEmployeeId())); + targetOptions.put("id", detailPOMap.get(po.getEmployeeId()).getId().toString()); + + dto.setTargetOptions(targetOptions); + + //设置categoryTypeOptions + List> categoryTypeOptions = new ArrayList<>(); + List categoryTypeList = Arrays.asList(po.getCategoryType().split(",")); + + for (String categoryType : categoryTypeList) { + Map categoryTypeMap = new HashMap<>(); + categoryTypeMap.put("id", categoryType); + categoryTypeMap.put("content", categoryNameMap.get(Long.valueOf(categoryType))); + categoryTypeOptions.add(categoryTypeMap); + } + dto.setCategoryTypeOptions(categoryTypeOptions); + + compensationDTOList.add(dto); + } + } + //不存在调差历史记录时,输出调差配置数据 + if (!haveCompensation && compensationConfigPOList.size() > 0) { + for (InsuranceCompensationConfigPO configPO : compensationConfigPOList) { + InsuranceCompensationDTO dto = new InsuranceCompensationDTO(); + BeanUtils.copyProperties(configPO, dto); + dto.setStatus(false); + //设置targetOptions + Map targetOptions = new HashMap<>(); + targetOptions.put("name", usernameMap.get(configPO.getEmployeeId())); +// String target = detailPOMap.get(configPO.getEmployeeId()).getId().toString(); + String target = detailPOMap.get(configPO.getEmployeeId()) == null ? null : detailPOMap.get(configPO.getEmployeeId()).getId().toString(); + if (target == null) { + continue; + } else { + targetOptions.put("id", detailPOMap.get(configPO.getEmployeeId()).getId().toString()); + } + + dto.setTargetOptions(targetOptions); + + //设置categoryTypeOptions + List> categoryTypeOptions = new ArrayList<>(); + List categoryTypeList = Arrays.asList(configPO.getCategoryType().split(",")); + + for (String categoryType : categoryTypeList) { + Map categoryTypeMap = new HashMap<>(); + categoryTypeMap.put("id", categoryType); + categoryTypeMap.put("content", categoryNameMap.get(Long.valueOf(categoryType))); + categoryTypeOptions.add(categoryTypeMap); + } + dto.setCategoryTypeOptions(categoryTypeOptions); + + //设置公司核算金额(单位) + CompensationParam compensationParam = CompensationParam.builder() + .categoryType(dto.getCategoryType()) + .employeeId(dto.getEmployeeId().toString()) + .paymentOrganization(dto.getPaymentOrganization()) + .target(Long.valueOf(dto.getTargetOptions().get("id"))) + .build(); + List paramList = new ArrayList<>(); + paramList.add(compensationParam); + List> comTotalList = compensationComTotal(paramList); + dto.setCompanyTotal(comTotalList.get(0).get("totalNum")); + + compensationDTOList.add(dto); + } + } + + return compensationDTOList; + } + +} diff --git a/src/com/engine/salary/service/impl/SIExportServiceImpl.java b/src/com/engine/salary/service/impl/SIExportServiceImpl.java new file mode 100644 index 000000000..27b51eb3f --- /dev/null +++ b/src/com/engine/salary/service/impl/SIExportServiceImpl.java @@ -0,0 +1,924 @@ +package com.engine.salary.service.impl; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.TypeReference; +import com.cloudstore.eccom.pc.table.WeaTableColumn; +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.hrmelog.entity.dto.LoggerContext; +import com.engine.salary.config.SalaryElogConfig; +import com.engine.salary.encrypt.EncryptUtil; +import com.engine.salary.entity.siaccount.dto.InsuranceAccountViewListDTO; +import com.engine.salary.entity.siaccount.param.InsuranceAccountDetailParam; +import com.engine.salary.entity.siaccount.po.InsuranceAccountDetailPO; +import com.engine.salary.entity.sicategory.po.ICategoryPO; +import com.engine.salary.entity.siexport.param.InsuranceExportParam; +import com.engine.salary.entity.siexport.po.AccountExportPO; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import com.engine.salary.enums.OperateTypeEnum; +import com.engine.salary.enums.siaccount.BillStatusEnum; +import com.engine.salary.enums.siaccount.PaymentStatusEnum; +import com.engine.salary.enums.siaccount.ResourceFromEnum; +import com.engine.salary.enums.sicategory.DataTypeEnum; +import com.engine.salary.enums.sicategory.PaymentScopeEnum; +import com.engine.salary.enums.sicategory.WelfareTypeEnum; +import com.engine.salary.mapper.InsuranceExportMapper; +import com.engine.salary.mapper.siaccount.InsuranceAccountDetailMapper; +import com.engine.salary.mapper.siarchives.InsuranceBaseInfoMapper; +import com.engine.salary.mapper.sicategory.ICategoryMapper; +import com.engine.salary.mapper.taxagent.TaxAgentMapper; +import com.engine.salary.service.*; +import com.engine.salary.sys.entity.po.SalarySysConfPO; +import com.engine.salary.sys.entity.vo.OrderRuleVO; +import com.engine.salary.sys.enums.OpenEnum; +import com.engine.salary.sys.service.SalarySysConfService; +import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl; +import com.engine.salary.util.SalaryAssert; +import com.engine.salary.util.SalaryEnumUtil; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.db.MapperProxyFactory; +import com.engine.salary.util.excel.ExcelUtil; +import com.engine.salary.util.excel.ExcelUtilPlus; +import org.apache.commons.collections4.MapUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.springframework.beans.BeanUtils; +import weaver.general.BaseBean; +import weaver.hrm.User; + +import java.math.BigDecimal; +import java.util.*; +import java.util.function.Function; +import java.util.stream.Collectors; + +import static com.engine.salary.enums.UserStatusEnum.getDefaultLabelByValue; +import static com.engine.salary.sys.constant.SalarySysConstant.OPEN_ACCT_RESULT_SUM; + +/** + * @Author weaver_cl + * @Description: + * @Date 2022/4/18 + * @Version V1.0 + **/ +public class SIExportServiceImpl extends Service implements SIExportService { + + BaseBean bs = new BaseBean(); + + private EncryptUtil encryptUtil = new EncryptUtil(); + +// private SIAccountBiz siAccountBiz = new SIAccountBiz(); + +// private SIArchivesBiz siArchivesBiz = new SIArchivesBiz(); + + private SISchemeService getSISchemeService(User user) { + return ServiceUtil.getService(SISchemeServiceImpl.class, user); + } + + private InsuranceAccountDetailMapper getInsuranceAccountDetailMapper() { + return MapperProxyFactory.getProxy(InsuranceAccountDetailMapper.class); + } + + private TaxAgentMapper getTaxAgentMapper() { + return MapperProxyFactory.getProxy(TaxAgentMapper.class); + } + + private InsuranceExportMapper getInsuranceExportMapper() { + return MapperProxyFactory.getProxy(InsuranceExportMapper.class); + } + + private SalarySysConfService getSalarySysConfService(User user) { + return ServiceUtil.getService(SalarySysConfServiceImpl.class, user); + } + + private InsuranceBaseInfoMapper getInsuranceBaseInfoMapper() { + return MapperProxyFactory.getProxy(InsuranceBaseInfoMapper.class); + } + + private TaxAgentService getTaxAgentService(User user) { + return ServiceUtil.getService(TaxAgentServiceImpl.class, user); + } + + private ICategoryMapper getICategoryMapper() { + return MapperProxyFactory.getProxy(ICategoryMapper.class); + } + + private SIAccountService getSIAccountService(User user) { + return ServiceUtil.getService(SIAccountServiceImpl.class, user); + } + + public SIArchivesService getSIArchivesService(User user) { + return ServiceUtil.getService(SIArchivesServiceImpl.class, user); + } + + @Override + public XSSFWorkbook exportOverView(InsuranceExportParam queryParam) { + List insuranceAccountDetailPOS = getInsuranceAccountDetailMapper().selectList(queryParam.getBillMonth(), StringUtils.isBlank(queryParam.getPaymentOrganization()) ? null : Long.valueOf(queryParam.getPaymentOrganization())); + encryptUtil.decryptList(insuranceAccountDetailPOS, InsuranceAccountDetailPO.class); + + //获取扣缴义务人信息 + List paymentList =getTaxAgentMapper().listAll(); + SalaryAssert.notEmpty(paymentList, SalaryI18nUtil.getI18nLabel(100341, "该租户无扣缴义务人")); + Map paymentMap = paymentList.stream().collect(Collectors.toMap(TaxAgentPO::getId, Function.identity())); +// List insuranceAccountViewListDTOS = siAccountBiz.buildRecords(insuranceAccountDetailPOS, paymentMap); + List insuranceAccountViewListDTOS = getSIAccountService(user).buildRecords(insuranceAccountDetailPOS, paymentMap); + + List> excelSheetData = new ArrayList<>(); + // 1.工作簿名称 + String sheetName = SalaryI18nUtil.getI18nLabel(85368, "社保福利档案"); + // 2.表头 + String[] header = { + SalaryI18nUtil.getI18nLabel(93270, "个税扣缴义务人"), + SalaryI18nUtil.getI18nLabel(93272, "社保人数"), + SalaryI18nUtil.getI18nLabel(93273, "公积金人数"), + SalaryI18nUtil.getI18nLabel(93274, "其他福利人数"), + SalaryI18nUtil.getI18nLabel(93275, "社保缴费合计"), + SalaryI18nUtil.getI18nLabel(93276, "公积金缴费合计"), + SalaryI18nUtil.getI18nLabel(93277, "其他福利缴费合计"), + SalaryI18nUtil.getI18nLabel(93278, "合计")}; + excelSheetData.add(Arrays.asList(header)); + + //工作簿数据 + List> rows = new LinkedList<>(); + for (InsuranceAccountViewListDTO dto : insuranceAccountViewListDTOS) { + List row = new LinkedList<>(); + row.add(dto.getPayOrg()); + row.add(dto.getSocialNum()); + row.add(dto.getFundNum()); + row.add(dto.getOtherNum()); + row.add(dto.getSocialPaySum()); + row.add(dto.getFundPaySum()); + row.add(dto.getOtherPaySum()); + row.add(dto.getSum()); + rows.add(row); + } + excelSheetData.addAll(rows); + //记录操作日志 + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setOperateType(OperateTypeEnum.EXCEL_EXPORT.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "福利台账-导出总览")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "福利台账-导出总览")); + SalaryElogConfig.siAccountLoggerTemplate.write(loggerContext); + return ExcelUtil.genWorkbookV2(excelSheetData, sheetName); + } + + @Override + public XSSFWorkbook exportAccount(Integer paymentStatus, InsuranceExportParam param) { + + //排序配置 + OrderRuleVO orderRule = getSalarySysConfService(user).orderRule(); + param.setOrderRule(orderRule); + + List accountExportPOS = new ArrayList<>(); + if (paymentStatus.equals(PaymentStatusEnum.RECESSION.getValue())) { + accountExportPOS = getInsuranceExportMapper().exportRecessionAccount(paymentStatus, param); + //非系统人员核算明细 + List extAccountExportPOS = getInsuranceExportMapper().exportExtAccount(paymentStatus, param); + accountExportPOS.addAll(extAccountExportPOS); + } else { + accountExportPOS = getInsuranceExportMapper().exportAccount(paymentStatus, param); + //非系统人员核算明细 + List extAccountExportPOS = getInsuranceExportMapper().exportExtAccount(paymentStatus, param); + accountExportPOS.addAll(extAccountExportPOS); + } + +// //过滤出福利档案基础信息表中runStatus为正在缴纳和待减员的人员 +// if (!paymentStatus.equals(PaymentStatusEnum.RECESSION.getValue())) { +// List baseInfoPOList = getInsuranceBaseInfoMapper().listAll(); +// List canAccountIds = baseInfoPOList.stream() +// .filter(f->f.getPaymentOrganization().toString().equals(param.getPaymentOrganization()) +// && (f.getRunStatus().equals(EmployeeStatusEnum.PAYING.getValue()) || f.getRunStatus().equals(EmployeeStatusEnum.STAY_DEL.getValue()))) +// .map(InsuranceArchivesBaseInfoPO::getEmployeeId) +// .collect(Collectors.toList()); +// accountExportPOS = accountExportPOS.stream().filter(f -> canAccountIds.contains(f.getEmployeeId())).collect(Collectors.toList()); +// } + + encryptUtil.decryptList(accountExportPOS, AccountExportPO.class); + SalaryI18nUtil.i18nList(accountExportPOS); + List columns = new ArrayList<>(); + List> records = new ArrayList<>(); +// if (Objects.equals(PaymentStatusEnum.COMMON.getValue(), paymentStatus)) { +// columns = buildCommonColumns(accountExportPOS, false); +// } +// if (Objects.equals(PaymentStatusEnum.REPAIR.getValue(), paymentStatus)) { +// columns = buildCommonColumns(accountExportPOS, true); +// } + columns = buildCommonColumns(accountExportPOS, paymentStatus); + + records = buildCommonRecords(accountExportPOS, false); + List> excelSheetData = new ArrayList<>(); + //工作簿名称 + String sheetName = SalaryI18nUtil.getI18nLabel(0, "社保福利台账"); + excelSheetData.add(Arrays.asList(columns.stream().map(WeaTableColumn::getText).toArray(String[]::new))); + //合计 + boolean total = false; + SalarySysConfPO openSum = getSalarySysConfService(user).getOneByCode(OPEN_ACCT_RESULT_SUM); + if (openSum != null && StringUtils.isNotBlank(openSum.getConfValue()) && OpenEnum.parseByValue(openSum.getConfValue()) == OpenEnum.OPEN) { + total = true; + InsuranceAccountDetailParam queryParam = new InsuranceAccountDetailParam(); + BeanUtils.copyProperties(param, queryParam); + Map sumRow = new HashMap<>(); + if (paymentStatus.equals(PaymentStatusEnum.COMMON.getValue())) { + sumRow = getSIAccountService(user).listCommonSum(queryParam); + } else if (paymentStatus.equals(PaymentStatusEnum.REPAIR.getValue())) { + sumRow = getSIAccountService(user).listSupplementarySum(queryParam); + } else if (paymentStatus.equals(PaymentStatusEnum.RECESSION.getValue())) { + sumRow = getSIAccountService(user).listRecessionSum(queryParam); + } else if (paymentStatus.equals(PaymentStatusEnum.BALANCE.getValue())) { + sumRow = getSIAccountService(user).listBalanceSum(queryParam); + } + Map sumMap = (Map) sumRow.get("sumRow"); + sumMap.put("department", "总计"); + + records.add(sumMap); + } + //工作簿数据 + List> rows = new LinkedList<>(); + for (Map recordData : records) { + List row = new LinkedList<>(); + for (WeaTableColumn column : columns) { + try { + if (column.getText().contains("个人") || column.getText().contains("单位") || column.getText().contains("合计")) { + row.add(new BigDecimal(recordData.get(column.getColumn()).toString())); + } else { + row.add(recordData.get(column.getColumn())); + } + } catch (Exception e) { + row.add(recordData.get(column.getColumn())); + } + } + rows.add(row); + } + + excelSheetData.addAll(rows); + //记录操作日志 + PaymentStatusEnum targetEnum = SalaryEnumUtil.enumMatchByValue(paymentStatus, PaymentStatusEnum.values(), PaymentStatusEnum.class); + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setOperateType(OperateTypeEnum.EXCEL_EXPORT.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "福利台账明细表-导出") + + SalaryI18nUtil.getI18nLabel(targetEnum.getLabelId(), targetEnum.getDefaultLabel())); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "福利台账明细表-导出") + + SalaryI18nUtil.getI18nLabel(targetEnum.getLabelId(), targetEnum.getDefaultLabel())); + SalaryElogConfig.siAccountLoggerTemplate.write(loggerContext); + return ExcelUtilPlus.genWorkbookV2(excelSheetData, sheetName, total); + } + + @Override + public List> buildCommonRecords(List list, boolean isExport) { +// boolean welBaseDiffSign = siArchivesBiz.isDiffWelBase(); + boolean welBaseDiffSign = getSIArchivesService(user).isDiffWelBase(); + List> result = new ArrayList<>(); + + List paymentList = getTaxAgentMapper().listAll(); + SalaryAssert.notEmpty(paymentList, SalaryI18nUtil.getI18nLabel(100341, "该租户无扣缴义务人")); + Map schemeIdNameMap = getSISchemeService(user).getSchemeIdNameMap(); + Map paymentMap = paymentList.stream().collect(Collectors.toMap(TaxAgentPO::getId, Function.identity())); + list.forEach(item -> { + Map record = new HashMap<>(); + record.put("billMonth", item.getBillMonth()); + record.put("billStatus", SalaryEnumUtil.enumMatchByValue(item.getBillStatus(), BillStatusEnum.values(), BillStatusEnum.class)); + record.put("userName", item.getUserName()); + if (isExport) { + record.put("department", item.getDepartmentName()); + record.put("employeeStatus", item.getUserStatus() == null ? "" : getDefaultLabelByValue(item.getUserStatus())); + } else { + record.put("department", item.getFixedDepartmentName()); + record.put("employeeStatus", item.getFixedUserStatus() == null ? "" : getDefaultLabelByValue(item.getFixedUserStatus())); + } + record.put("supplementaryMonth", item.getSupplementaryMonth()); + record.put("mobile", item.getTelephone()); + record.put("workcode", item.getWorkcode()); + record.put("idNo", item.getIdNo()); + ResourceFromEnum from = SalaryEnumUtil.enumMatchByValue(item.getResourceFrom(), ResourceFromEnum.values(), ResourceFromEnum.class); + record.put("sourceFrom", SalaryI18nUtil.getI18nLabel(from.getLabelId(), from.getDefaultLabel())); + + record.put("socialPayOrg", paymentMap.get(item.getPaymentOrganization()) == null ? "" : paymentMap.get(item.getPaymentOrganization()).getName()); + + record.put("socialAccount", item.getSocialAccount()); + record.put("socialSchemeName", schemeIdNameMap.get(item.getSocialSchemeId())); + if (StringUtils.isNotEmpty(item.getSocialPaymentBaseString())) { + Map socialJson = JSON.parseObject(item.getSocialPaymentBaseString(), new HashMap().getClass()); +// if (socialJson != null) { +// socialJson.forEach((k, v) -> { +// record.put(k + "socialBase", v); +// }); +// } + if (welBaseDiffSign) { + if (socialJson != null) { + //查询该福利方案下开启缴纳的福利项 +// List insuranceIdList = siArchivesBiz.payInsuranceIds(item.getSocialSchemeId(), PaymentScopeEnum.SCOPE_PERSON.getValue()); + List insuranceIdList = getSIArchivesService(user).payInsuranceIds(item.getSocialSchemeId(), PaymentScopeEnum.SCOPE_PERSON.getValue()); + socialJson.forEach((k, v) -> { + if (insuranceIdList.contains(Long.valueOf(k))) { + record.put(k + "socialPerBase", v); + } + }); + } + Map socialComJson = JSON.parseObject(item.getSocialPaymentComBaseString(), new TypeReference>() { + }); + if (socialComJson != null) { + //查询该福利方案下开启缴纳的福利项 +// List insuranceIdList = siArchivesBiz.payInsuranceIds(item.getSocialSchemeId(),PaymentScopeEnum.SCOPE_COMPANY.getValue()); + List insuranceIdList = getSIArchivesService(user).payInsuranceIds(item.getSocialSchemeId(),PaymentScopeEnum.SCOPE_COMPANY.getValue()); + socialComJson.forEach((k, v) -> { + if (insuranceIdList.contains(Long.valueOf(k))) { + record.put(k + "socialComBase", v); + } + }); + } + } else { + if (socialJson != null) { + //查询该福利方案下开启缴纳的福利项 +// List insuranceIdList = siArchivesBiz.payInsuranceIds(item.getSocialSchemeId()); + List insuranceIdList = getSIArchivesService(user).payInsuranceIds(item.getSocialSchemeId()); + socialJson.forEach((k, v) -> { + if (insuranceIdList.contains(Long.valueOf(k))) { + record.put(k + "socialBase", v); + } + }); + } + } + + } + record.put("fundPayOrg", paymentMap.get(item.getSocialPayOrg()) == null ? "" : paymentMap.get(item.getSocialPayOrg()).getName()); + record.put("fundAccount", item.getFundAccount()); + record.put("fundSchemeName", schemeIdNameMap.get(item.getFundSchemeId())); + record.put("supplementFundAccount", item.getSupplementFundAccount()); + if (StringUtils.isNotEmpty(item.getFundPaymentBaseString())) { + Map fundJson = JSON.parseObject(item.getFundPaymentBaseString(), new HashMap().getClass()); +// if (fundJson != null) { +// fundJson.forEach((k, v) -> { +// record.put(k + "fundBase", v); +// }); +// } + if (welBaseDiffSign) { + if (fundJson != null) { + //查询该福利方案下开启缴纳的福利项 +// List insuranceIdList = siArchivesBiz.payInsuranceIds(item.getFundSchemeId(),PaymentScopeEnum.SCOPE_PERSON.getValue()); + List insuranceIdList = getSIArchivesService(user).payInsuranceIds(item.getFundSchemeId(),PaymentScopeEnum.SCOPE_PERSON.getValue()); + fundJson.forEach((k, v) -> { + if (insuranceIdList.contains(Long.valueOf(k))) { + record.put(k + "fundPerBase", v); + } + }); + } + Map fundComJson = JSON.parseObject(item.getFundPaymentComBaseString(), new TypeReference>() { + }); + if (fundComJson != null) { + //查询该福利方案下开启缴纳的福利项 +// List insuranceIdList = siArchivesBiz.payInsuranceIds(item.getFundSchemeId(),PaymentScopeEnum.SCOPE_COMPANY.getValue()); + List insuranceIdList = getSIArchivesService(user).payInsuranceIds(item.getFundSchemeId(),PaymentScopeEnum.SCOPE_COMPANY.getValue()); + fundComJson.forEach((k, v) -> { + if (insuranceIdList.contains(Long.valueOf(k))) { + record.put(k + "fundComBase", v); + } + }); + } + } else { + if (fundJson != null) { + //查询该福利方案下开启缴纳的福利项 +// List insuranceIdList = siArchivesBiz.payInsuranceIds(item.getFundSchemeId()); + List insuranceIdList = getSIArchivesService(user).payInsuranceIds(item.getFundSchemeId()); + fundJson.forEach((k, v) -> { + if (insuranceIdList.contains(Long.valueOf(k))) { + record.put(k + "fundBase", v); + } + }); + } + } + + } + record.put("otherPayOrg", paymentMap.get(item.getOtherPayOrg()) == null ? "" : paymentMap.get(item.getOtherPayOrg()).getName()); + record.put("otherSchemeName", schemeIdNameMap.get(item.getOtherSchemeId())); + if (StringUtils.isNotEmpty(item.getOtherPaymentBaseString())) { + Map otherJson = JSON.parseObject(item.getOtherPaymentBaseString(), new HashMap().getClass()); +// if (otherJson != null) { +// otherJson.forEach((k, v) -> { +// record.put(k + "otherBase", v); +// }); +// } + if (welBaseDiffSign) { + if (otherJson != null) { + //查询该福利方案下开启缴纳的福利项 +// List insuranceIdList = siArchivesBiz.payInsuranceIds(item.getOtherSchemeId(),PaymentScopeEnum.SCOPE_PERSON.getValue()); + List insuranceIdList = getSIArchivesService(user).payInsuranceIds(item.getOtherSchemeId(),PaymentScopeEnum.SCOPE_PERSON.getValue()); + otherJson.forEach((k, v) -> { + if (insuranceIdList.contains(Long.valueOf(k))) { + record.put(k + "otherPerBase", v); + } + }); + } + Map otherComJson = JSON.parseObject(item.getOtherPaymentComBaseString(), new TypeReference>() { + }); + if (otherComJson != null) { + //查询该福利方案下开启缴纳的福利项 +// List insuranceIdList = siArchivesBiz.payInsuranceIds(item.getOtherSchemeId(),PaymentScopeEnum.SCOPE_COMPANY.getValue()); + List insuranceIdList = getSIArchivesService(user).payInsuranceIds(item.getOtherSchemeId(),PaymentScopeEnum.SCOPE_COMPANY.getValue()); + otherComJson.forEach((k, v) -> { + if (insuranceIdList.contains(Long.valueOf(k))) { + record.put(k + "otherComBase", v); + } + }); + } + } else { + if (otherJson != null) { + //查询该福利方案下开启缴纳的福利项 +// List insuranceIdList = siArchivesBiz.payInsuranceIds(item.getOtherSchemeId()); + List insuranceIdList = getSIArchivesService(user).payInsuranceIds(item.getOtherSchemeId()); + otherJson.forEach((k, v) -> { + if (insuranceIdList.contains(Long.valueOf(k))) { + record.put(k + "otherBase", v); + } + }); + } + } + + } + if (StringUtils.isNotEmpty(item.getSocialPerJson())) { + Map socialJson = JSON.parseObject(item.getSocialPerJson(), new HashMap().getClass()); + if (socialJson != null) { + socialJson.forEach((k, v) -> { + record.put(k + "socialPer", v); + }); + } + + } + record.put("socialPerSum", item.getSocialPerSum()); + if (StringUtils.isNotEmpty(item.getFundPerJson())) { + Map fundPerJson = JSON.parseObject(item.getFundPerJson(), new HashMap().getClass()); + if (fundPerJson != null) { + fundPerJson.forEach((k, v) -> { + record.put(k + "fundPer", v); + }); + } + + } + record.put("fundPerSum", item.getFundPerSum()); + if (StringUtils.isNotEmpty(item.getOtherPerJson())) { + Map fundPerJson = JSON.parseObject(item.getOtherPerJson(), new HashMap().getClass()); + if (fundPerJson != null) { + fundPerJson.forEach((k, v) -> { + record.put(k + "otherPer", v); + }); + } + + } + record.put("otherPerSum", item.getOtherPerSum()); + record.put("perSum", item.getPerSum()); + if (StringUtils.isNotEmpty(item.getSocialComJson())) { + Map fundPerJson = JSON.parseObject(item.getSocialComJson(), new HashMap().getClass()); + if (fundPerJson != null) { + fundPerJson.forEach((k, v) -> { + record.put(k + "socialCom", v); + }); + } + + } + record.put("socialComSum", item.getSocialComSum()); + if (StringUtils.isNotEmpty(item.getFundComJson())) { + Map fundPerJson = JSON.parseObject(item.getFundComJson(), new HashMap().getClass()); + if (fundPerJson != null) { + fundPerJson.forEach((k, v) -> { + record.put(k + "fundCom", v); + }); + } + + } + record.put("fundComSum", item.getFundComSum()); + if (StringUtils.isNotEmpty(item.getOtherPerJson())) { + Map fundPerJson = JSON.parseObject(item.getOtherComJson(), new HashMap().getClass()); + if (fundPerJson != null) { + fundPerJson.forEach((k, v) -> { + record.put(k + "otherCom", v); + }); + } + + } + record.put("otherComSum", item.getOtherComSum()); + record.put("comSum", item.getComSum()); + record.put("socialSum", item.getSocialSum()); + record.put("fundSum", item.getFundSum()); + record.put("otherSum", item.getOtherSum()); + record.put("total", item.getTotal()); + result.add(record); + }); + return result; + } + + private Map> buildComTitle(List pos, Map categoryIdNameMap) { + Set socailIds = new HashSet<>(); + Set fundIds = new HashSet<>(); + Set otherIds = new HashSet<>(); + Map> result = new HashMap<>(); + + pos.stream().forEach(item -> { + if (StringUtils.isNotBlank(item.getSocialComJson())) { + Map socialJson = JSON.parseObject(item.getSocialComJson(), new HashMap().getClass()); + if (socialJson != null) { + socialJson.forEach((k, v) -> { + socailIds.add(k); + }); + } + + } + if (StringUtils.isNotBlank(item.getFundComJson())) { + Map fundJson = JSON.parseObject(item.getFundComJson(), new HashMap().getClass()); + if (fundJson != null) { + fundJson.forEach((k, v) -> { + fundIds.add(k); + }); + } + + } + if (StringUtils.isNotBlank(item.getOtherComJson())) { + Map otherJson = JSON.parseObject(item.getOtherComJson(), new HashMap().getClass()); + if (otherJson != null) { + otherJson.forEach((k, v) -> { + otherIds.add(k); + }); + } + + } + }); + Map socialColumns = new HashMap<>(); + Map fundColumns = new HashMap<>(); + Map otherColumns = new HashMap<>(); + socailIds.stream().forEach(social -> { + if (categoryIdNameMap.containsKey(social)) { + socialColumns.put( + categoryIdNameMap.get(social) + SalaryI18nUtil.getI18nLabel(100289, "单位"), + social + "socialCom"); + } + }); + fundIds.stream().forEach(social -> { + if (categoryIdNameMap.containsKey(social)) { + fundColumns.put(categoryIdNameMap.get(social) + SalaryI18nUtil.getI18nLabel(100289, "单位"), + social + "fundCom"); + } + }); + otherIds.stream().forEach(social -> { + if (categoryIdNameMap.containsKey(social)) { + otherColumns.put(categoryIdNameMap.get(social) + SalaryI18nUtil.getI18nLabel(100289, "单位"), + social + "otherCom"); + } + }); + // map根据value排序 + LinkedHashMap socialColumnsWithAscValue = socialColumns.entrySet().stream() + .sorted(Map.Entry.comparingByValue()) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (oldValue, newValue) -> oldValue, + LinkedHashMap::new)); + LinkedHashMap fundColumnsWithAscValue = fundColumns.entrySet().stream() + .sorted(Map.Entry.comparingByValue()) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (oldValue, newValue) -> oldValue, + LinkedHashMap::new)); + LinkedHashMap otherColumnsWithAscValue = otherColumns.entrySet().stream() + .sorted(Map.Entry.comparingByValue()) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (oldValue, newValue) -> oldValue, + LinkedHashMap::new)); + + result.put(WelfareTypeEnum.SOCIAL_SECURITY.getValue(), socialColumnsWithAscValue); + result.put(WelfareTypeEnum.ACCUMULATION_FUND.getValue(), fundColumnsWithAscValue); + result.put(WelfareTypeEnum.OTHER.getValue(), otherColumnsWithAscValue); + return result; + } + + private Map> buildPersonalTitle(List pos, Map categoryIdNameMap) { + Set socailIds = new HashSet<>(); + Set fundIds = new HashSet<>(); + Set otherIds = new HashSet<>(); + Map> result = new HashMap<>(); + + pos.stream().forEach(item -> { + if (StringUtils.isNotBlank(item.getSocialPerJson())) { + Map socialJson = JSON.parseObject(item.getSocialPerJson(), new HashMap().getClass()); + if (socialJson != null) { + socialJson.forEach((k, v) -> { + socailIds.add(k); + }); + } + + } + if (StringUtils.isNotBlank(item.getFundPerJson())) { + Map fundJson = JSON.parseObject(item.getFundPerJson(), new HashMap().getClass()); + if (fundJson != null) { + fundJson.forEach((k, v) -> { + fundIds.add(k); + }); + } + + } + if (StringUtils.isNotBlank(item.getOtherPerJson())) { + Map otherJson = JSON.parseObject(item.getOtherPerJson(), new HashMap().getClass()); + if (otherJson != null) { + otherJson.forEach((k, v) -> { + otherIds.add(k); + }); + } + + } + }); + Map socialColumns = new HashMap<>(); + Map fundColumns = new HashMap<>(); + Map otherColumns = new HashMap<>(); + socailIds.stream().forEach(social -> { + if (categoryIdNameMap.containsKey(social)) { + socialColumns.put(categoryIdNameMap.get(social) + SalaryI18nUtil.getI18nLabel(87159, "个人"), + social + "socialPer"); + } + }); + fundIds.stream().forEach(social -> { + if (categoryIdNameMap.containsKey(social)) { + fundColumns.put(categoryIdNameMap.get(social) + SalaryI18nUtil.getI18nLabel(87159, "个人"), + social + "fundPer"); + } + }); + otherIds.stream().forEach(social -> { + if (categoryIdNameMap.containsKey(social)) { + otherColumns.put(categoryIdNameMap.get(social) + SalaryI18nUtil.getI18nLabel(87159, "个人"), + social + "otherPer"); + } + }); + // map根据value排序 + LinkedHashMap socialColumnsWithAscValue = socialColumns.entrySet().stream() + .sorted(Map.Entry.comparingByValue()) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (oldValue, newValue) -> oldValue, + LinkedHashMap::new)); + LinkedHashMap fundColumnsWithAscValue = fundColumns.entrySet().stream() + .sorted(Map.Entry.comparingByValue()) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (oldValue, newValue) -> oldValue, + LinkedHashMap::new)); + LinkedHashMap otherColumnsWithAscValue = otherColumns.entrySet().stream() + .sorted(Map.Entry.comparingByValue()) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (oldValue, newValue) -> oldValue, + LinkedHashMap::new)); + + result.put(WelfareTypeEnum.SOCIAL_SECURITY.getValue(), socialColumnsWithAscValue); + result.put(WelfareTypeEnum.ACCUMULATION_FUND.getValue(), fundColumnsWithAscValue); + result.put(WelfareTypeEnum.OTHER.getValue(), otherColumnsWithAscValue); + return result; + } + + + private List buildCommonColumns(List pos, Integer paymentStatus) { + List list = new ArrayList<>(); + Map categoryIdNameMap = categoryIdNameMap(); + Map> columns = buildPaymentTitle(pos, categoryIdNameMap); + Map> personColumns = buildPersonalTitle(pos, categoryIdNameMap); + Map> comColumns = buildComTitle(pos, categoryIdNameMap); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(85429, "姓名"), "userName")); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(86185, "部门"), "department")); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(86186, "手机号"), "mobile")); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(86317, "工号"), "workcode")); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(86187, "员工状态"), "employeeStatus")); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(86187, "证件号码"), "idNo")); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(100377, "数据来源"), "sourceFrom")); + if (paymentStatus.equals(PaymentStatusEnum.REPAIR.getValue())) { + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(100379, "补缴月份"), "supplementaryMonth")); + } else if (paymentStatus.equals(PaymentStatusEnum.RECESSION.getValue())) { + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(100379, "退差月份"), "supplementaryMonth")); + } + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(91325, "个税扣缴义务人"), "socialPayOrg")); + if (!paymentStatus.equals(PaymentStatusEnum.BALANCE.getValue())) { + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(91324, "社保账号"), "socialAccount")); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(91323, "社保方案名称"), "socialSchemeName")); + } + + //组装社保基数 + columns.get(WelfareTypeEnum.SOCIAL_SECURITY.getValue()).forEach((k, v) -> { + list.add(new WeaTableColumn("150px", k, v)); + }); + + if (!paymentStatus.equals(PaymentStatusEnum.BALANCE.getValue())) { + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(91486, "公积金账号"), "fundAccount")); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(91485, "公积金方案名称"), "fundSchemeName")); + } + + //组装公积金基数 + columns.get(WelfareTypeEnum.ACCUMULATION_FUND.getValue()).forEach((k, v) -> { + list.add(new WeaTableColumn("150px", k, v)); + }); + if (!paymentStatus.equals(PaymentStatusEnum.BALANCE.getValue())) { + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(91487, "补充公积金账号"), "supplementFundAccount")); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(91496, "其他福利方案名称"), "otherSchemeName")); + } + + columns.get(WelfareTypeEnum.OTHER.getValue()).forEach((k, v) -> { + list.add(new WeaTableColumn("150px", k, v)); + }); + personColumns.get(WelfareTypeEnum.SOCIAL_SECURITY.getValue()).forEach((k, v) -> { + list.add(new WeaTableColumn("150px", k, v)); + }); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(100388, "社保个人合计"), "socialPerSum")); + personColumns.get(WelfareTypeEnum.ACCUMULATION_FUND.getValue()).forEach((k, v) -> { + list.add(new WeaTableColumn("150px", k, v)); + }); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(100390, "公积金个人合计"), "fundPerSum")); + personColumns.get(WelfareTypeEnum.OTHER.getValue()).forEach((k, v) -> { + list.add(new WeaTableColumn("150px", k, v)); + }); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(100392, "其他福利个人合计"), "otherPerSum")); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(100393, "个人合计"), "perSum")); + comColumns.get(WelfareTypeEnum.SOCIAL_SECURITY.getValue()).forEach((k, v) -> { + list.add(new WeaTableColumn("150px", k, v)); + }); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(100394, "社保单位合计"), "socialComSum")); + comColumns.get(WelfareTypeEnum.ACCUMULATION_FUND.getValue()).forEach((k, v) -> { + list.add(new WeaTableColumn("150px", k, v)); + }); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(100395, "公积金单位合计"), "fundComSum")); + comColumns.get(WelfareTypeEnum.OTHER.getValue()).forEach((k, v) -> { + list.add(new WeaTableColumn("150px", k, v)); + }); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(100396, "其他福利单位合计"), "otherComSum")); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(100397, "单位合计"), "comSum")); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(100398, "社保合计"), "socialSum")); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(100399, "公积金合计"), "fundSum")); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(100400, "其他福利合计"), "otherSum")); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(93278, "合计"), "total")); + return list; + } + + private Map categoryIdNameMap() { + //系统福利类型 + Map systemMap = getICategoryMapper().listByDataType(DataTypeEnum.SYSTEM.getValue()).stream() + .collect(Collectors.toMap(ICategoryPO::getId, ICategoryPO::getInsuranceName)); + Map customMap = getICategoryMapper().listAll() + .stream().collect(Collectors.toMap(ICategoryPO::getId, ICategoryPO::getInsuranceName)); + HashMap total = new HashMap<>(); + if (MapUtils.isNotEmpty(systemMap)) { + total.putAll(systemMap); + } + if (MapUtils.isNotEmpty(customMap)) { + total.putAll(customMap); + } + HashMap result = new HashMap<>(); + total.forEach((k, v) -> { + result.put(String.valueOf(k), v); + }); + + return result; + } + + private Map> buildPaymentTitle(List pos, Map categoryIdNameMap) { +// boolean welBaseDiffSign = siArchivesBiz.isDiffWelBase(); + boolean welBaseDiffSign = getSIArchivesService(user).isDiffWelBase(); + Set socailIds = new HashSet<>(); + Set fundIds = new HashSet<>(); + Set otherIds = new HashSet<>(); + + Set socailComIds = new HashSet<>(); + Set fundComIds = new HashSet<>(); + Set otherComIds = new HashSet<>(); + + Map> result = new HashMap<>(); + + pos.stream().forEach(item -> { + if (StringUtils.isNotBlank(item.getSocialPaymentBaseString()) || StringUtils.isNotBlank(item.getSocialPaymentComBaseString())) { + Map socialJson = JSON.parseObject(item.getSocialPaymentBaseString(), new HashMap().getClass()); + if (socialJson != null) { + socialJson.forEach((k, v) -> { + socailIds.add(k); + }); + } + //如果需要区分个人和公司福利基数 + if (welBaseDiffSign) { + Map socialComJson = JSON.parseObject(item.getSocialPaymentComBaseString(), new TypeReference>() { + }); + if (socialComJson != null) { + socialComJson.forEach((k, v) -> socailComIds.add(k)); + } + } + + } + if (StringUtils.isNotBlank(item.getFundPaymentBaseString()) || StringUtils.isNotBlank(item.getFundPaymentComBaseString())) { + Map fundJson = JSON.parseObject(item.getFundPaymentBaseString(), new HashMap().getClass()); + if (fundJson != null) { + fundJson.forEach((k, v) -> { + fundIds.add(k); + }); + } + //如果需要区分个人和公司福利基数 + if (welBaseDiffSign) { + Map fundComJson = JSON.parseObject(item.getFundPaymentComBaseString(), new TypeReference>() { + }); + if (fundComJson != null) { + fundComJson.forEach((k, v) -> fundComIds.add(k)); + } + } + + } + if (StringUtils.isNotBlank(item.getOtherPaymentBaseString()) || StringUtils.isNotBlank(item.getOtherPaymentComBaseString())) { + Map otherJson = JSON.parseObject(item.getOtherPaymentBaseString(), new HashMap().getClass()); + if (otherJson != null) { + otherJson.forEach((k, v) -> { + otherIds.add(k); + }); + } + //如果需要区分个人和公司福利基数 + if (welBaseDiffSign) { + Map otherComJson = JSON.parseObject(item.getOtherPaymentComBaseString(), new TypeReference>() { + }); + if (otherComJson != null) { + otherComJson.forEach((k, v) -> otherComIds.add(k)); + } + } + + } + }); + Map socialColumns = new HashMap<>(); + Map fundColumns = new HashMap<>(); + Map otherColumns = new HashMap<>(); + + Map socialComColumns = new HashMap<>(); + Map fundComColumns = new HashMap<>(); + Map otherComColumns = new HashMap<>(); + + if (welBaseDiffSign) { + socailIds.stream().forEach(social -> { + if (categoryIdNameMap.containsKey(social)) { + socialColumns.put(categoryIdNameMap.get(social) + SalaryI18nUtil.getI18nLabel(0, "申报基数") + SalaryI18nUtil.getI18nLabel( 0, "个人"), social + "socialPerBase"); + } + }); + fundIds.stream().forEach(social -> { + if (categoryIdNameMap.containsKey(social)) { + fundColumns.put(categoryIdNameMap.get(social) + SalaryI18nUtil.getI18nLabel( 0, "申报基数") + SalaryI18nUtil.getI18nLabel( 0, "个人"), social + "fundPerBase"); + } + }); + otherIds.stream().forEach(social -> { + if (categoryIdNameMap.containsKey(social)) { + otherColumns.put(categoryIdNameMap.get(social) + SalaryI18nUtil.getI18nLabel( 0, "申报基数") + SalaryI18nUtil.getI18nLabel( 0, "个人"), social + "otherPerBase"); + } + }); + + socailComIds.stream().forEach(social -> { + if (categoryIdNameMap.containsKey(social)) { + socialComColumns.put(categoryIdNameMap.get(social) + SalaryI18nUtil.getI18nLabel(0, "申报基数") + SalaryI18nUtil.getI18nLabel( 0, "单位"), social + "socialComBase"); + } + }); + fundComIds.stream().forEach(social -> { + if (categoryIdNameMap.containsKey(social)) { + fundComColumns.put(categoryIdNameMap.get(social) + SalaryI18nUtil.getI18nLabel( 0, "申报基数") + SalaryI18nUtil.getI18nLabel( 0, "单位"), social + "fundComBase"); + } + }); + otherComIds.stream().forEach(social -> { + if (categoryIdNameMap.containsKey(social)) { + otherComColumns.put(categoryIdNameMap.get(social) + SalaryI18nUtil.getI18nLabel( 0, "申报基数") + SalaryI18nUtil.getI18nLabel( 0, "单位"), social + "otherComBase"); + } + }); + } else { + socailIds.stream().forEach(social -> { + if (categoryIdNameMap.containsKey(social)) { + socialColumns.put(categoryIdNameMap.get(social) + SalaryI18nUtil.getI18nLabel(0, "申报基数"), social + "socialBase"); + } + }); + fundIds.stream().forEach(social -> { + if (categoryIdNameMap.containsKey(social)) { + fundColumns.put(categoryIdNameMap.get(social) + SalaryI18nUtil.getI18nLabel( 0, "申报基数"), social + "fundBase"); + } + }); + otherIds.stream().forEach(social -> { + if (categoryIdNameMap.containsKey(social)) { + otherColumns.put(categoryIdNameMap.get(social) + SalaryI18nUtil.getI18nLabel( 0, "申报基数"), social + "otherBase"); + } + }); + } + // map根据value排序 + LinkedHashMap socialColumnsWithAscValue = socialColumns.entrySet().stream() + .sorted(Map.Entry.comparingByValue()) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (oldValue, newValue) -> oldValue, + LinkedHashMap::new)); + LinkedHashMap fundColumnsWithAscValue = fundColumns.entrySet().stream() + .sorted(Map.Entry.comparingByValue()) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (oldValue, newValue) -> oldValue, + LinkedHashMap::new)); + LinkedHashMap otherColumnsWithAscValue = otherColumns.entrySet().stream() + .sorted(Map.Entry.comparingByValue()) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (oldValue, newValue) -> oldValue, + LinkedHashMap::new)); + + if (welBaseDiffSign) { + LinkedHashMap socialComMapWithAscKey = socialComColumns.entrySet().stream() + .sorted(Map.Entry.comparingByKey()) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (oldValue, newValue) -> oldValue, + LinkedHashMap::new)); + LinkedHashMap fundComMapWithAscKey = fundComColumns.entrySet().stream() + .sorted(Map.Entry.comparingByKey()) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (oldValue, newValue) -> oldValue, + LinkedHashMap::new)); + LinkedHashMap otherComMapWithAscKey = otherComColumns.entrySet().stream() + .sorted(Map.Entry.comparingByKey()) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (oldValue, newValue) -> oldValue, + LinkedHashMap::new)); + socialColumnsWithAscValue.putAll(socialComMapWithAscKey); + fundColumnsWithAscValue.putAll(fundComMapWithAscKey); + otherColumnsWithAscValue.putAll(otherComMapWithAscKey); + } + + result.put(WelfareTypeEnum.SOCIAL_SECURITY.getValue(), socialColumnsWithAscValue); + result.put(WelfareTypeEnum.ACCUMULATION_FUND.getValue(), fundColumnsWithAscValue); + result.put(WelfareTypeEnum.OTHER.getValue(), otherColumnsWithAscValue); + return result; + } +} + diff --git a/src/com/engine/salary/service/impl/SIImportServiceImpl.java b/src/com/engine/salary/service/impl/SIImportServiceImpl.java new file mode 100644 index 000000000..553a6fba1 --- /dev/null +++ b/src/com/engine/salary/service/impl/SIImportServiceImpl.java @@ -0,0 +1,379 @@ +package com.engine.salary.service.impl; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.TypeReference; +import com.cloudstore.eccom.pc.table.WeaTableColumn; +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.encrypt.EncryptUtil; +import com.engine.salary.entity.siarchives.param.InsuranceArchivesListParam; +import com.engine.salary.entity.siarchives.po.InsuranceArchivesEmployeePO; +import com.engine.salary.entity.siarchives.po.InsuranceArchivesFundSchemePO; +import com.engine.salary.entity.siarchives.po.InsuranceArchivesOtherSchemePO; +import com.engine.salary.entity.siarchives.po.InsuranceArchivesSocialSchemePO; +import com.engine.salary.entity.sicategory.po.ICategoryPO; +import com.engine.salary.entity.sischeme.po.InsuranceSchemePO; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import com.engine.salary.enums.siaccount.EmployeeStatusEnum; +import com.engine.salary.enums.sicategory.WelfareTypeEnum; +import com.engine.salary.mapper.siarchives.SocialSchemeMapper; +import com.engine.salary.mapper.sicategory.ICategoryMapper; +import com.engine.salary.mapper.sischeme.InsuranceSchemeMapper; +import com.engine.salary.mapper.taxagent.TaxAgentMapper; +import com.engine.salary.service.SIArchivesService; +import com.engine.salary.service.SIImportService; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.db.MapperProxyFactory; +import com.engine.salary.util.excel.ExcelComment; +import com.engine.salary.util.excel.ExcelUtilPlus; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.util.page.SalaryPageUtil; +import com.google.common.collect.Lists; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang.StringUtils; +import org.apache.ibatis.session.SqlSession; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import weaver.conn.mybatis.MyBatisFactory; +import weaver.hrm.User; + +import java.util.*; +import java.util.function.Function; +import java.util.stream.Collectors; + +/** + * @Author weaver_cl + * @Description: + * @Date 2022/4/20 + * @Version V1.0 + **/ +public class SIImportServiceImpl extends Service implements SIImportService { + private EncryptUtil encryptUtil = new EncryptUtil(); + +// private SIArchivesBiz siArchivesBiz = new SIArchivesBiz(); + + public SIArchivesService getSIArchivesService(User user) { + return ServiceUtil.getService(SIArchivesServiceImpl.class,user); + } + + private ICategoryMapper getICategoryMapper() { + return MapperProxyFactory.getProxy(ICategoryMapper.class); + } + + private TaxAgentMapper getTaxAgentMapper() { + return MapperProxyFactory.getProxy(TaxAgentMapper.class); + } + + private InsuranceSchemeMapper getInsuranceSchemeMapper() { + return MapperProxyFactory.getProxy(InsuranceSchemeMapper.class); + } + + @Override + public XSSFWorkbook exportTemplate(InsuranceArchivesListParam param) { + //工作簿list + List> excelSheetData = new ArrayList<>(); + Boolean exportData = param.getExportData(); + + //工作簿名称 + String sheetName; + //表头 + if (param.isExtWelArchiveList()) { + sheetName = SalaryI18nUtil.getI18nLabel(542679, "非系统人员"); + } else if (param.getRunStatuses().size() > 0) { + if (param.getRunStatuses().contains(EmployeeStatusEnum.STAY_ADD.getValue()) && param.getRunStatuses().size() == 1) { + sheetName = SalaryI18nUtil.getI18nLabel(85368, "社保福利档案导入模板" + "-" + EmployeeStatusEnum.STAY_ADD.getDefaultLabel()); + } else if (param.getRunStatuses().contains(EmployeeStatusEnum.PAYING.getValue()) && param.getRunStatuses().contains(EmployeeStatusEnum.STAY_DEL.getValue()) && param.getRunStatuses().size() == 2) { + sheetName = SalaryI18nUtil.getI18nLabel(85368, "社保福利档案导入模板" + "-" + "在缴员工"); + } else if (param.getRunStatuses().contains(EmployeeStatusEnum.STAY_DEL.getValue()) && param.getRunStatuses().size() == 1) { + sheetName = SalaryI18nUtil.getI18nLabel(85368, "社保福利档案导入模板" + "-" + EmployeeStatusEnum.STAY_DEL.getDefaultLabel()); + } else if (param.getRunStatuses().contains(EmployeeStatusEnum.STOP_PAYMENT_FROM_ADD.getValue()) && param.getRunStatuses().contains(EmployeeStatusEnum.STOP_PAYMENT_FROM_DEL.getValue()) && param.getRunStatuses().size() == 2) { + sheetName = SalaryI18nUtil.getI18nLabel(85368, "社保福利档案导入模板" + "-" + "停缴员工"); + } else { + sheetName = SalaryI18nUtil.getI18nLabel(85368, "社保福利档案导入模板"); + } + } else { + sheetName = SalaryI18nUtil.getI18nLabel(85368, "社保福利档案导入模板"); + } + + + List headers = buildHeader(); + InsuranceArchivesListParam request = InsuranceArchivesListParam.builder().build(); + if (param.getHireDate() != null && param.getHireDate().length == 2) { + param.setHiredateStart(param.getHireDate()[0]); + param.setHiredateEnd(param.getHireDate()[1]); + } + if (param.getDimissionDate() != null && param.getDimissionDate().length == 2) { + param.setDimissionDateStart(param.getDimissionDate()[0]); + param.setDimissionDateEnd(param.getDimissionDate()[1]); + } + if (Objects.equals("fromQuickSearch", param.getDataSource())) { + if (StringUtils.isNotBlank(param.getStatusesStr())) { + request.setStatuses(Arrays.stream(param.getStatusesStr().split(",")).map(String::new).collect(Collectors.toList())); + } + request.setKeyword(param.getUserName()); + request.setStartNum(param.getStartNum()); + request.setPageSize(param.getPageSize()); + } else { + request = param; + } +// request.setPageSize(null); +// request.setStartNum(null); +// List insuranceArchivesEmployeePOS = getSIArchivesService(user).listPageEmployeePOS(request); +// if (insuranceArchivesEmployeePOS == null) { +// insuranceArchivesEmployeePOS = new ArrayList<>(); +// } +// List> datas = buildTableData(insuranceArchivesEmployeePOS); + //表头 + excelSheetData.add(Arrays.asList(headers.toArray(new String[0]))); + /** + * 导出数据 + */ + if (exportData != null && exportData){ + //查询总页数 + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + SocialSchemeMapper socialSchemeMapper = sqlSession.getMapper(SocialSchemeMapper.class); + List page = new ArrayList<>(); + if (param.isExtWelArchiveList()) { + page = socialSchemeMapper.queryExtEmployeeList(param); + } else { + page = socialSchemeMapper.queryEmployeeList(param); + } + PageInfo pageInfo = SalaryPageUtil.buildPage(param.getCurrent(), param.getPageSize(), + page, InsuranceArchivesEmployeePO.class); + int total = (int)pageInfo.getTotal(); + param.setPageSize(total); + param.setCurrent(1); + if (CollectionUtils.isNotEmpty(param.getDepartmentIds())) { + param.setDepartmentIdsStr(StringUtils.join(param.getDepartmentIds(), ",")); + } + if (CollectionUtils.isNotEmpty(param.getSubcompanyIds())) { + param.setSubcompanyIdsStr(StringUtils.join(param.getSubcompanyIds(), ",")); + } + if (CollectionUtils.isNotEmpty(param.getPositions())) { + param.setPositionsStr(StringUtils.join(param.getPositions(), ",")); + } + if (CollectionUtils.isNotEmpty(param.getStatuses())) { + param.setStatusesStr(StringUtils.join(param.getStatuses(), ",")); + } + + Map dataMap = getSIArchivesService(user).listPage(param); + List> records = (List>)dataMap.get("datas"); + List columns = (List)dataMap.get("columns"); + List rowCloumn = Lists.newArrayList(); + List names = columns.stream().map(WeaTableColumn::getText).collect(Collectors.toList()); + headers.forEach(header -> { + if (names.contains(header)){ + columns.forEach(column -> { + //用来判断columns中是否包含header + if (header.equals(column.getText())){ + rowCloumn.add(column.getColumn()); + } + }); + }else { + rowCloumn.add(""); + } + }); + records.forEach(record -> { + List row = Lists.newArrayList(); + rowCloumn.forEach(column -> { + if (record.get(column) == null){ + row.add(""); + }else { + row.add(record.get(column)); + } + }); + excelSheetData.add(row); + }); + } + + // 3.表数据 + + // 4.注释 + List excelComments = Lists.newArrayList(); + excelComments.add(new ExcelComment(0, 0, 1, 2, SalaryI18nUtil.getI18nLabel(100344, "必填"))); + excelComments.add(new ExcelComment(8, 0, 9, 2, SalaryI18nUtil.getI18nLabel(100344, "社保,公积金,其他福利方案名称不可同时为空"))); + + + //工作簿数据 + return ExcelUtilPlus.genWorkbookV2(excelSheetData, sheetName,excelComments); + } + + + /** + * 构建档案excel的表头 + * + * @return + */ + public List buildHeader() { +// boolean welBaseDiffSign = siArchivesBiz.isDiffWelBase(); + boolean welBaseDiffSign = getSIArchivesService(user).isDiffWelBase(); + List result = new ArrayList<>(); + result.add(SalaryI18nUtil.getI18nLabel( 85429, "姓名")); + result.add(SalaryI18nUtil.getI18nLabel( 86184, "个税扣缴义务人")); + result.add(SalaryI18nUtil.getI18nLabel( 0, "分部")); + result.add(SalaryI18nUtil.getI18nLabel( 86185, "部门")); + result.add(SalaryI18nUtil.getI18nLabel( 86186, "手机号")); + result.add(SalaryI18nUtil.getI18nLabel( 86187, "员工状态")); + result.add(SalaryI18nUtil.getI18nLabel(86317, "工号")); + result.add(SalaryI18nUtil.getI18nLabel(86317, "证件号码")); + result.add(SalaryI18nUtil.getI18nLabel( 91323, "社保方案名称")); + // result.add(SalaryI18nUtil.getI18nLabel( 91325, "社保缴纳组织")); + //社保福利基数 + Map socialMap = welfareNameIdMap( WelfareTypeEnum.SOCIAL_SECURITY); + if (welBaseDiffSign) { + socialMap.forEach((k, v) -> result.add(k + SalaryI18nUtil.getI18nLabel( 0, "申报基数") + SalaryI18nUtil.getI18nLabel( 0, "个人"))); + socialMap.forEach((k, v) -> result.add(k + SalaryI18nUtil.getI18nLabel( 0, "申报基数") + SalaryI18nUtil.getI18nLabel( 0, "单位"))); + } else { + socialMap.forEach((k, v) -> result.add(k + SalaryI18nUtil.getI18nLabel( 0, "申报基数"))); + } + + result.add(SalaryI18nUtil.getI18nLabel( 91324, "社保账号")); + result.add(SalaryI18nUtil.getI18nLabel( 91319, "社保起始缴纳月")); + result.add(SalaryI18nUtil.getI18nLabel( 91320, "社保最后缴纳月")); + result.add(SalaryI18nUtil.getI18nLabel( 91485, "公积金方案名称")); + // result.add(SalaryI18nUtil.getI18nLabel( 91488, "公积金缴纳组织")); + result.add(SalaryI18nUtil.getI18nLabel( 91486, "公积金账号")); + //公积金福利基数 + Map fundMap = welfareNameIdMap( WelfareTypeEnum.ACCUMULATION_FUND); + if (welBaseDiffSign) { + fundMap.forEach((k, v) -> result.add(k + SalaryI18nUtil.getI18nLabel( 0, "申报基数") + SalaryI18nUtil.getI18nLabel( 0, "个人"))); + fundMap.forEach((k, v) -> result.add(k + SalaryI18nUtil.getI18nLabel( 0, "申报基数") + SalaryI18nUtil.getI18nLabel( 0, "单位"))); + } else { + fundMap.forEach((k, v) -> result.add(k + SalaryI18nUtil.getI18nLabel( 0, "申报基数"))); + } + + result.add(SalaryI18nUtil.getI18nLabel( 91487, "补充公积金账号")); + result.add(SalaryI18nUtil.getI18nLabel( 91483, "公积金起始缴纳月")); + result.add(SalaryI18nUtil.getI18nLabel( 91484, "公积金最后缴纳月")); + result.add(SalaryI18nUtil.getI18nLabel( 91496, "其他福利方案名称")); + // result.add(SalaryI18nUtil.getI18nLabel( 91497, "其他福利缴纳组织")); + //其他福利基数 + Map otherMap = welfareNameIdMap( WelfareTypeEnum.OTHER); + if (welBaseDiffSign) { + otherMap.forEach((k, v) -> result.add(k + SalaryI18nUtil.getI18nLabel( 0, "申报基数") + SalaryI18nUtil.getI18nLabel( 0, "个人"))); + otherMap.forEach((k, v) -> result.add(k + SalaryI18nUtil.getI18nLabel( 0, "申报基数") + SalaryI18nUtil.getI18nLabel( 0, "单位"))); + } else { + otherMap.forEach((k, v) -> result.add(k + SalaryI18nUtil.getI18nLabel( 0, "申报基数"))); + } + + result.add(SalaryI18nUtil.getI18nLabel( 91490, "其他福利起始缴纳月")); + result.add(SalaryI18nUtil.getI18nLabel( 91494, "其他福利最后缴纳月")); + return result; + } + + /** + * 获取福利类型名称-id的map + * + * @param welfareTypeEnum + * @return + */ + public Map welfareNameIdMap(WelfareTypeEnum welfareTypeEnum) { +// return getICategoryMapper().listByWelfareType(welfareTypeEnum.getValue(),null).stream().collect(Collectors.toMap(ICategoryPO::getInsuranceName, ICategoryPO::getId)); + return getICategoryMapper().listByWelfareType(welfareTypeEnum.getValue(),null) + .stream() + .sorted(Comparator.comparing(ICategoryPO::getId)) + .collect(LinkedHashMap::new, (map, item) -> map.put(item.getInsuranceName(), item.getId()), LinkedHashMap::putAll); + } + + public Map welfareMap() { + return getICategoryMapper().listAll().stream().collect(Collectors.toMap(ICategoryPO::getId, ICategoryPO::getInsuranceName)); + } + + /** + * 获取缴纳组织id-名称集合 + * + * @return + */ + public Map paymentOrganizationIdNameMap() { + List list = getTaxAgentMapper().listAll(); + if (CollectionUtils.isEmpty(list)) { + return new HashMap<>(); + } + return list.stream().collect(Collectors.toMap(TaxAgentPO::getId, TaxAgentPO::getName)); + } + + public List> buildTableData(List insuranceArchivesEmployeePOS) { + List> records = new ArrayList<>(); + //获取id,福利名称的map,用于下面组装福利数据 + Map welfareMap = welfareMap(); + //获取缴纳组织id-name集合 + Map paymentMap = paymentOrganizationIdNameMap(); + //获取id,方案名称的map,用于下面组装福利数据 + Map schemeMap = new HashMap<>(); + List schemeList = getInsuranceSchemeMapper().listAll(); + if (CollectionUtils.isNotEmpty(schemeList)) { + schemeMap = schemeList.stream().collect(Collectors.toMap(InsuranceSchemePO::getId, InsuranceSchemePO::getSchemeName)); + } + List employeeIds = insuranceArchivesEmployeePOS.stream().map(InsuranceArchivesEmployeePO::getEmployeeId).collect(Collectors.toList()); + Map socialSchemePOMap = new HashMap<>(); +// List socialSchemePOList = siArchivesBiz.getSocialByEmployeeIds(employeeIds); + List socialSchemePOList = getSIArchivesService(user).getSocialByEmployeeIds(employeeIds); + encryptUtil.decryptList(socialSchemePOList, InsuranceArchivesSocialSchemePO.class); + if (CollectionUtils.isNotEmpty(socialSchemePOList)) { + socialSchemePOMap = socialSchemePOList.stream().collect(Collectors.toMap(InsuranceArchivesSocialSchemePO::getEmployeeId, Function.identity())); + } +// List fundSchemePOList = siArchivesBiz.getFundByEmployeeIds(employeeIds); + List fundSchemePOList = getSIArchivesService(user).getFundByEmployeeIds(employeeIds); + encryptUtil.encryptList(fundSchemePOList, InsuranceArchivesFundSchemePO.class); + Map fundSchemePOMap = new HashMap<>(); + if (CollectionUtils.isNotEmpty(fundSchemePOList)) { + fundSchemePOMap = fundSchemePOList.stream().collect(Collectors.toMap(InsuranceArchivesFundSchemePO::getEmployeeId, Function.identity())); + } + Map otherSchemePOMap = new HashMap<>(); +// List otherSchemePOList = siArchivesBiz.getOtherByEmployeeIds(employeeIds); + List otherSchemePOList = getSIArchivesService(user).getOtherByEmployeeIds(employeeIds); + encryptUtil.decryptList(otherSchemePOList, InsuranceArchivesOtherSchemePO.class); + if (CollectionUtils.isNotEmpty(otherSchemePOList)) { + otherSchemePOMap = otherSchemePOList.stream().collect(Collectors.toMap(InsuranceArchivesOtherSchemePO::getEmployeeId, Function.identity())); + } + for (InsuranceArchivesEmployeePO item : insuranceArchivesEmployeePOS) { + InsuranceArchivesSocialSchemePO socialItem = socialSchemePOMap.get(item.getEmployeeId()); + InsuranceArchivesFundSchemePO fundItem = fundSchemePOMap.get(item.getEmployeeId()); + InsuranceArchivesOtherSchemePO otherItem = otherSchemePOMap.get(item.getEmployeeId()); + Map map = new HashMap<>(); + map.put(SalaryI18nUtil.getI18nLabel( 85429, "姓名"), item.getUserName()); + map.put(SalaryI18nUtil.getI18nLabel( 86185, "部门"), item.getDepartmentName()); + map.put(SalaryI18nUtil.getI18nLabel( 86186, "手机号"), item.getTelephone()); + map.put(SalaryI18nUtil.getI18nLabel( 86187, "员工状态"), item.getUserStatusEnum() == null ? "" : item.getUserStatusEnum().getDefaultLabel()); + if (socialItem != null) { + map.put(SalaryI18nUtil.getI18nLabel( 91323, "社保方案名称"), schemeMap.get(socialItem.getSocialSchemeId())); + map.put(SalaryI18nUtil.getI18nLabel( 91325, "社保缴纳组织"), paymentMap.get(socialItem.getPaymentOrganization())); + Map socialJson = JSON.parseObject(socialItem.getSocialPaymentBaseString(), new TypeReference>() { + }); + if (socialJson != null) { + socialJson.forEach((k, v) -> map.put(welfareMap.get(Long.valueOf(k)) + SalaryI18nUtil.getI18nLabel( 100293, "申报基数"), v)); + } + map.put(SalaryI18nUtil.getI18nLabel( 91324, "社保账号"), socialItem.getSocialAccount()); + map.put(SalaryI18nUtil.getI18nLabel( 91319, "社保起始缴纳月"), socialItem.getSocialStartTime()); + map.put(SalaryI18nUtil.getI18nLabel( 91320, "社保最后缴纳月"), socialItem.getSocialEndTime()); + } + if (fundItem != null) { + map.put(SalaryI18nUtil.getI18nLabel( 91485, "公积金方案名称"), schemeMap.get(fundItem.getFundSchemeId())); + map.put(SalaryI18nUtil.getI18nLabel( 91488, "公积金缴纳组织"), paymentMap.get(fundItem.getPaymentOrganization())); + map.put(SalaryI18nUtil.getI18nLabel( 91486, "公积金账号"), fundItem.getFundAccount()); + Map fundJson = JSON.parseObject(fundItem.getFundPaymentBaseString(), new TypeReference>() { + }); + if (fundJson != null) { + fundJson.forEach((k, v) -> map.put(welfareMap.get(Long.valueOf(k)) + SalaryI18nUtil.getI18nLabel( 100293, "申报基数"), v)); + } + map.put(SalaryI18nUtil.getI18nLabel( 91487, "补充公积金账号"), fundItem.getSupplementFundAccount()); + map.put(SalaryI18nUtil.getI18nLabel( 91483, "公积金起始缴纳月"), fundItem.getFundStartTime()); + map.put(SalaryI18nUtil.getI18nLabel( 91484, "公积金最后缴纳月"), fundItem.getFundEndTime()); + + } + if (otherItem != null) { + map.put(SalaryI18nUtil.getI18nLabel( 91496, "其他福利方案名称"), schemeMap.get(otherItem.getOtherSchemeId())); + map.put(SalaryI18nUtil.getI18nLabel( 91497, "其他福利缴纳组织"), paymentMap.get(otherItem.getPaymentOrganization())); + Map otherJson = JSON.parseObject(otherItem.getOtherPaymentBaseString(), new TypeReference>() { + }); + if (otherJson != null) { + otherJson.forEach((k, v) -> map.put(welfareMap.get(Long.valueOf(k)) + SalaryI18nUtil.getI18nLabel( 100293, "申报基数"), v)); + } + map.put(SalaryI18nUtil.getI18nLabel( 91490, "其他福利起始缴纳月"), otherItem.getOtherStartTime()); + map.put(SalaryI18nUtil.getI18nLabel( 91494, "其他福利最后缴纳月"), otherItem.getOtherEndTime()); + } + records.add(map); + } + return records; + } + +} diff --git a/src/com/engine/salary/service/impl/SIRecessionServiceImpl.java b/src/com/engine/salary/service/impl/SIRecessionServiceImpl.java new file mode 100644 index 000000000..29d56344d --- /dev/null +++ b/src/com/engine/salary/service/impl/SIRecessionServiceImpl.java @@ -0,0 +1,439 @@ +package com.engine.salary.service.impl; + +import com.alibaba.fastjson.JSON; +import com.api.formmode.mybatis.util.SqlProxyHandle; +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.hrmelog.entity.dto.LoggerContext; +import com.engine.salary.config.SalaryElogConfig; +import com.engine.salary.encrypt.EncryptUtil; +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.hrm.dto.HrmInfoDTO; +import com.engine.salary.entity.hrm.param.HrmQueryParam; +import com.engine.salary.entity.siaccount.param.InsuranceAccountDetailParam; +import com.engine.salary.entity.siaccount.param.RecessionParam; +import com.engine.salary.entity.siaccount.po.InsuranceAccountBatchPO; +import com.engine.salary.entity.siaccount.po.InsuranceAccountDetailPO; +import com.engine.salary.entity.siarchives.po.InsuranceArchivesBaseInfoPO; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import com.engine.salary.enums.OperateTypeEnum; +import com.engine.salary.enums.auth.AuthFilterTypeEnum; +import com.engine.salary.enums.siaccount.BillStatusEnum; +import com.engine.salary.enums.siaccount.PaymentStatusEnum; +import com.engine.salary.enums.siaccount.ProjectTypeEnum; +import com.engine.salary.enums.sicategory.DeleteTypeEnum; +import com.engine.salary.exception.SalaryRunTimeException; +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.siarchives.InsuranceBaseInfoMapper; +import com.engine.salary.mapper.taxagent.TaxAgentMapper; +import com.engine.salary.service.SIAccountService; +import com.engine.salary.service.SIRecessionService; +import com.engine.salary.service.SalaryEmployeeService; +import com.engine.salary.service.TaxAgentService; +import com.engine.salary.service.auth.AuthService; +import com.engine.salary.service.auth.AuthServiceImpl; +import com.engine.salary.util.SalaryAssert; +import com.engine.salary.util.SalaryEntityUtil; +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.page.SalaryPageUtil; +import com.google.common.collect.Lists; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import weaver.hrm.User; + +import java.math.BigDecimal; +import java.util.*; +import java.util.stream.Collectors; + +/** + * @Author: sy + * @Description: 社保福利台账-退差实现类 + * @Date: 2022/11/15 + **/ +public class SIRecessionServiceImpl extends Service implements SIRecessionService { + + private EncryptUtil encryptUtil = new EncryptUtil(); + + private InsuranceAccountDetailMapper getInsuranceAccountDetailMapper() { + return SqlProxyHandle.getProxy(InsuranceAccountDetailMapper.class); + } + + private TaxAgentService getTaxAgentService(User user) { + return ServiceUtil.getService(TaxAgentServiceImpl.class, user); + } + + private EmployMapper getEmployMapper() { + return MapperProxyFactory.getProxy(EmployMapper.class); + } + + private SIAccountService getSIAccountService(User user) { + return ServiceUtil.getService(SIAccountServiceImpl.class, user); + } + + private InsuranceAccountBatchMapper getInsuranceAccountBatchMapper() { + return MapperProxyFactory.getProxy(InsuranceAccountBatchMapper.class); + } + + private TaxAgentMapper getTaxAgentMapper() { + return MapperProxyFactory.getProxy(TaxAgentMapper.class); + } + + private SalaryEmployeeService getSalaryEmployeeService(User user) { + return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user); + } + + private InsuranceBaseInfoMapper getInsuranceBaseInfoMapper() { + return MapperProxyFactory.getProxy(InsuranceBaseInfoMapper.class); + } + + public AuthService getAuthService(User user) { + return ServiceUtil.getService(AuthServiceImpl.class, user); + } + + @Override + public void save(RecessionParam param, Long employeeId) { + + //入参判断 + if (StringUtils.isBlank(param.getPaymentOrganization()) || StringUtils.isBlank(param.getBillMonth()) || CollectionUtils.isEmpty(param.getRecessionMonthList()) + || CollectionUtils.isEmpty(param.getIncludes()) || CollectionUtils.isEmpty(param.getProjects())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(84026, "参数错误")); + } + //需要退差的员工 + List employeeIds = param.getIncludes(); + if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(param.getExcludes())) { + employeeIds = employeeIds.stream().filter(item -> !param.getExcludes().contains(item)).collect(Collectors.toList()); + } + SalaryAssert.notEmpty(employeeIds, SalaryI18nUtil.getI18nLabel(133967, "无退差人员")); + + //查询退差员工对应的退差月份的正常缴纳的福利台账数据 + List detailPOS = new ArrayList<>(); + List> partitionEmpIds = Lists.partition((List) employeeIds, 100); + partitionEmpIds.forEach(p -> { + detailPOS.addAll( + getInsuranceAccountDetailMapper().list(InsuranceAccountDetailParam.builder() + .paymentStatus(PaymentStatusEnum.COMMON.getValue()) + .recessionMonthList(param.getRecessionMonthList()) + .employeeIds(p) + .paymentOrganization(param.getPaymentOrganization()) + .build()) + ); + }); + + encryptUtil.decryptList(detailPOS, InsuranceAccountDetailPO.class); + //处理数据 + List finalDetailPOS = detailPOS; + List finalRecessionDetails = new ArrayList<>(); + + // 获取员工信息 + List employeeList = getSalaryEmployeeService(user).listByIds(employeeIds); + Map employeeMap = SalaryEntityUtil.convert2Map(employeeList, DataCollectionEmployee::getEmployeeId); + employeeIds.forEach(id -> { + DataCollectionEmployee employee = employeeMap.getOrDefault(id, DataCollectionEmployee.builder().build()); + param.getRecessionMonthList().forEach(billMonth -> { + Optional detailPOOptional = finalDetailPOS.stream().filter( + detail -> Objects.equals(billMonth, detail.getBillMonth()) + && Objects.equals(id, detail.getEmployeeId())).findFirst(); + detailPOOptional.ifPresent(insuranceAccountDetailPO -> recessionAccount(param, insuranceAccountDetailPO, finalRecessionDetails, employee)); + }); + }); + //退差数据入库 + if (CollectionUtils.isNotEmpty(finalRecessionDetails)) { + encryptUtil.encryptList(finalRecessionDetails, InsuranceAccountDetailPO.class); + + //删除已有退差记录 + finalRecessionDetails.forEach(getInsuranceAccountDetailMapper()::deleteRecessionData); + //入库新数据 + List> partition = Lists.partition((List) finalRecessionDetails, 20); + partition.forEach(getInsuranceAccountDetailMapper()::batchSaveAccountDetails); + //刷新bill_batch表中统计信息 + getSIAccountService(user).refreshBillBatch(Long.valueOf(param.getPaymentOrganization()), param.getBillMonth()); + //记录操作日志 + encryptUtil.decryptList(finalRecessionDetails, InsuranceAccountDetailPO.class); + InsuranceAccountBatchPO targetPO = getInsuranceAccountBatchMapper().getByBillMonth(param.getBillMonth(), Long.valueOf(param.getPaymentOrganization())); + TaxAgentPO taxAgentInfo = getTaxAgentMapper().getById(targetPO.getPaymentOrganization()); + LoggerContext loggerContext = new LoggerContext(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(targetPO.getId())); + loggerContext.setTargetName(taxAgentInfo.getName() + "-" + targetPO.getBillMonth()); + loggerContext.setOperateType(OperateTypeEnum.ADD.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "福利台账明细表-新增退差")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "福利台账明细表-新增退差") + + ":" + taxAgentInfo.getName() + "-" + targetPO.getBillMonth()); + finalRecessionDetails.forEach(loggerContext::setNewValues); + SalaryElogConfig.siAccountLoggerTemplate.write(loggerContext); + } + } + + + @Override + public void del(Collection ids, Long employeeId) { + + //入参判断 + if (CollectionUtils.isEmpty(ids)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(84026, "参数错误")); + } + + InsuranceAccountDetailPO refreshTargetPO = getInsuranceAccountDetailMapper().getById(((List) ids).get(0)); + + + //根据id删除 + List> partition = Lists.partition((List) ids, 100); + partition.forEach(getInsuranceAccountDetailMapper()::batchDelAccountDetailsByIds); + //记录操作日志 + LoggerContext loggerContext = new LoggerContext(); + loggerContext.setUser(user); + loggerContext.setTargetId(ids.stream().map(String::valueOf).collect(Collectors.joining(","))); + loggerContext.setTargetName(ids.stream().map(String::valueOf).collect(Collectors.joining(","))); + loggerContext.setOperateType(OperateTypeEnum.DELETE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "福利台账明细表-删除退差核算记录")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "福利台账明细表-删除退差核算记录")); + SalaryElogConfig.siAccountLoggerTemplate.write(loggerContext); + //刷新bill_batch表中统计信息 + getSIAccountService(user).refreshBillBatch(refreshTargetPO.getPaymentOrganization(), refreshTargetPO.getBillMonth()); + } + + + private void recessionAccount(RecessionParam param, InsuranceAccountDetailPO insuranceAccountDetailPO, List recessionDetails, DataCollectionEmployee employee) { + List projects = param.getProjects(); + InsuranceAccountDetailPO temp = new InsuranceAccountDetailPO(); + recessionBaseBuild(param, temp, insuranceAccountDetailPO, employee); + if (projects.contains(ProjectTypeEnum.ALL.getValue())) { + recessionSocial(param, temp, insuranceAccountDetailPO); + recessionFund(param, temp, insuranceAccountDetailPO); + recessionOther(param, temp, insuranceAccountDetailPO); + } + if (projects.contains(ProjectTypeEnum.SOCIAL.getValue())) { + recessionSocial(param, temp, insuranceAccountDetailPO); + } + + if (projects.contains(ProjectTypeEnum.FUND.getValue())) { + recessionFund(param, temp, insuranceAccountDetailPO); + } + if (projects.contains(ProjectTypeEnum.OTHER.getValue())) { + recessionOther(param, temp, insuranceAccountDetailPO); + } + account(temp); + recessionDetails.add(temp); + } + + + private void recessionBaseBuild(RecessionParam param, InsuranceAccountDetailPO temp, InsuranceAccountDetailPO insuranceAccountDetailPO, DataCollectionEmployee employee) { + InsuranceAccountBatchPO insuranceAccountBatchPO = getInsuranceAccountBatchMapper().getByBillMonth(param.getBillMonth(), Long.valueOf(param.getPaymentOrganization())); + temp.setPaymentStatus(PaymentStatusEnum.RECESSION.getValue()); +// temp.setId(IdGenerator.generate()); + temp.setCreateTime(new Date()); + temp.setUpdateTime(new Date()); + temp.setCreator(insuranceAccountBatchPO.getCreator()); + temp.setSocialPayOrg(insuranceAccountDetailPO.getPaymentOrganization()); + temp.setDeleteType(DeleteTypeEnum.NOT_DELETED.getValue()); + temp.setTenantKey(insuranceAccountDetailPO.getTenantKey()); + temp.setEmployeeId(insuranceAccountDetailPO.getEmployeeId()); + temp.setSubcompanyName(employee.getSubcompanyName()); + temp.setSubcompanyId(employee.getSubcompanyid()); + temp.setDepartmentName(employee.getDepartmentName()); + temp.setDepartmentId(employee.getDepartmentId()); + temp.setJobtitleName(employee.getJobtitleName()); + temp.setJobtitleId(employee.getJobtitleId()); + temp.setJobcall(employee.getJobcall()); + temp.setJobcallId(employee.getJobcallId()); + temp.setStatus(employee.getStatus()); + temp.setBillMonth(param.getBillMonth()); + temp.setBillStatus(BillStatusEnum.NOT_ARCHIVED.getValue()); + temp.setBillMonth(param.getBillMonth()); + temp.setBillStatus(BillStatusEnum.NOT_ARCHIVED.getValue()); + temp.setSupplementaryMonth(insuranceAccountDetailPO.getBillMonth()); + temp.setSupplementaryProjects(String.join(",", + param.getProjects() == null ? new ArrayList<>() : param.getProjects().stream().map(String::valueOf).collect(Collectors.toList()))); + temp.setResourceFrom(insuranceAccountDetailPO.getResourceFrom()); + temp.setSocialAccount(insuranceAccountDetailPO.getSocialAccount()); + temp.setSocialSchemeId(insuranceAccountDetailPO.getSocialSchemeId()); + temp.setSocialPaymentBaseString(insuranceAccountDetailPO.getSocialPaymentBaseString()); + temp.setFundAccount(insuranceAccountDetailPO.getFundAccount()); + temp.setSupplementFundAccount(insuranceAccountDetailPO.getSupplementFundAccount()); + temp.setFundSchemeId(insuranceAccountDetailPO.getFundSchemeId()); + temp.setFundPaymentBaseString(insuranceAccountDetailPO.getFundPaymentBaseString()); + temp.setOtherSchemeId(insuranceAccountDetailPO.getOtherSchemeId()); + temp.setOtherPaymentBaseString(insuranceAccountDetailPO.getOtherPaymentBaseString()); +// temp.setExternalFlag(insuranceAccountDetailPO.getExternalFlag()); + temp.setPaymentOrganization(insuranceAccountDetailPO.getPaymentOrganization()); +// temp.setPaymentAgency(insuranceAccountDetailPO.getPaymentAgency()); + temp.setSocialPaymentComBaseString(insuranceAccountDetailPO.getSocialPaymentComBaseString()); + temp.setFundPaymentComBaseString(insuranceAccountDetailPO.getFundPaymentComBaseString()); + temp.setOtherPaymentComBaseString(insuranceAccountDetailPO.getOtherPaymentComBaseString()); + } + + private void recessionSocial(RecessionParam param, InsuranceAccountDetailPO temp, InsuranceAccountDetailPO insuranceAccountDetailPO) { + //退差社保个人缴费 + String socialPerJson = insuranceAccountDetailPO.getSocialPerJson(); + if (StringUtils.isNotBlank(socialPerJson)) { + HashMap jsonMap = new HashMap<>(); + HashMap hashMap = JSON.parseObject(socialPerJson, new HashMap().getClass()); + hashMap.forEach((k, v) -> { + if (StringUtils.isNotBlank(v)) { + v = new BigDecimal(v).negate().toPlainString(); + jsonMap.put(k, v); + } + }); + temp.setSocialPerJson(JSON.toJSONString(jsonMap)); + } + if (StringUtils.isNotBlank(insuranceAccountDetailPO.getSocialPerSum())) { + temp.setSocialPerSum(new BigDecimal(insuranceAccountDetailPO.getSocialPerSum()).negate().toPlainString()); + } + //退差社保单位缴费 + String socialComJson = insuranceAccountDetailPO.getSocialComJson(); + if (StringUtils.isNotBlank(socialComJson)) { + HashMap jsonMap = new HashMap<>(); + HashMap hashMap = JSON.parseObject(socialComJson, new HashMap().getClass()); + hashMap.forEach((k, v) -> { + if (StringUtils.isNotBlank(v)) { + v = new BigDecimal(v).negate().toPlainString(); + jsonMap.put(k, v); + } + }); + temp.setSocialComJson(JSON.toJSONString(jsonMap)); + } + if (StringUtils.isNotBlank(insuranceAccountDetailPO.getSocialComSum())) { + temp.setSocialComSum(new BigDecimal(insuranceAccountDetailPO.getSocialComSum()).negate().toPlainString()); + } + } + + private void recessionFund(RecessionParam param, InsuranceAccountDetailPO temp, InsuranceAccountDetailPO insuranceAccountDetailPO) { + //退差公积金个人缴费 + String fundPerJson = insuranceAccountDetailPO.getFundPerJson(); + if (StringUtils.isNotBlank(fundPerJson)) { + HashMap jsonMap = new HashMap<>(); + HashMap hashMap = JSON.parseObject(fundPerJson, new HashMap().getClass()); + hashMap.forEach((k, v) -> { + if (StringUtils.isNotBlank(v)) { + v = new BigDecimal(v).negate().toPlainString(); + jsonMap.put(k, v); + } + }); + temp.setFundPerJson(JSON.toJSONString(jsonMap)); + } + if (StringUtils.isNotBlank(insuranceAccountDetailPO.getFundPerSum())) { + temp.setFundPerSum(new BigDecimal(insuranceAccountDetailPO.getFundPerSum()).negate().toPlainString()); + } + //退差公积金单位缴费 + String fundComJson = insuranceAccountDetailPO.getFundComJson(); + if (StringUtils.isNotBlank(fundComJson)) { + HashMap jsonMap = new HashMap<>(); + HashMap hashMap = JSON.parseObject(fundComJson, new HashMap().getClass()); + hashMap.forEach((k, v) -> { + if (StringUtils.isNotBlank(v)) { + v = new BigDecimal(v).negate().toPlainString(); + jsonMap.put(k, v); + } + }); + temp.setFundComJson(JSON.toJSONString(jsonMap)); + } + if (StringUtils.isNotBlank(insuranceAccountDetailPO.getFundComSum())) { + temp.setFundComSum(new BigDecimal(insuranceAccountDetailPO.getFundComSum()).negate().toPlainString()); + } + } + + + private void recessionOther(RecessionParam param, InsuranceAccountDetailPO temp, InsuranceAccountDetailPO insuranceAccountDetailPO) { + //退差其他福利个人缴费 + String otherPerJson = insuranceAccountDetailPO.getOtherPerJson(); + if (StringUtils.isNotBlank(otherPerJson)) { + HashMap jsonMap = new HashMap<>(); + HashMap hashMap = JSON.parseObject(otherPerJson, new HashMap().getClass()); + hashMap.forEach((k, v) -> { + if (StringUtils.isNotBlank(v)) { + v = new BigDecimal(v).negate().toPlainString(); + jsonMap.put(k, v); + } + }); + temp.setOtherPerJson(JSON.toJSONString(jsonMap)); + } + if (StringUtils.isNotBlank(insuranceAccountDetailPO.getOtherPerSum())) { + temp.setOtherPerSum(new BigDecimal(insuranceAccountDetailPO.getOtherPerSum()).negate().toPlainString()); + } + //退差其他福利单位缴费 + String otherComJson = insuranceAccountDetailPO.getOtherComJson(); + if (StringUtils.isNotBlank(otherComJson)) { + HashMap jsonMap = new HashMap<>(); + HashMap hashMap = JSON.parseObject(otherComJson, new HashMap().getClass()); + hashMap.forEach((k, v) -> { + if (StringUtils.isNotBlank(v)) { + v = new BigDecimal(v).negate().toPlainString(); + jsonMap.put(k, v); + } + }); + temp.setOtherComJson(JSON.toJSONString(jsonMap)); + } + if (StringUtils.isNotBlank(insuranceAccountDetailPO.getOtherComSum())) { + temp.setOtherComSum(new BigDecimal(insuranceAccountDetailPO.getOtherComSum()).negate().toPlainString()); + } + } + + + private void account(InsuranceAccountDetailPO insuranceAccountDetailPO) { + + //个人合计 + BigDecimal socialPerson = + StringUtils.isBlank(insuranceAccountDetailPO.getSocialPerSum()) ? new BigDecimal("0") : new BigDecimal(insuranceAccountDetailPO.getSocialPerSum()); + BigDecimal fundPerson = + StringUtils.isBlank(insuranceAccountDetailPO.getFundPerSum()) ? new BigDecimal("0") : new BigDecimal(insuranceAccountDetailPO.getFundPerSum()); + BigDecimal otherPerson = + StringUtils.isBlank(insuranceAccountDetailPO.getOtherPerSum()) ? new BigDecimal("0") : new BigDecimal(insuranceAccountDetailPO.getOtherPerSum()); + BigDecimal perSum = socialPerson.add(fundPerson).add(otherPerson); + insuranceAccountDetailPO.setPerSum(perSum.toPlainString()); + //单位合计 + BigDecimal socialCom = + StringUtils.isBlank(insuranceAccountDetailPO.getSocialComSum()) ? new BigDecimal("0") : new BigDecimal(insuranceAccountDetailPO.getSocialComSum()); + BigDecimal fundCom = StringUtils.isBlank(insuranceAccountDetailPO.getFundComSum()) ? new BigDecimal("0") : new BigDecimal(insuranceAccountDetailPO.getFundComSum()); + BigDecimal otherCom = + StringUtils.isBlank(insuranceAccountDetailPO.getOtherComSum()) ? new BigDecimal("0") : new BigDecimal(insuranceAccountDetailPO.getOtherComSum()); + BigDecimal comSum = socialCom.add(fundCom).add(otherCom); + insuranceAccountDetailPO.setComSum(comSum.toPlainString()); + //社保合计 + insuranceAccountDetailPO.setSocialSum(socialPerson.add(socialCom).toPlainString()); + //公积金合计 + insuranceAccountDetailPO.setFundSum(fundPerson.add(fundCom).toPlainString()); + //其他福利合计 + insuranceAccountDetailPO.setOtherSum(otherPerson.add(otherCom).toPlainString()); + //合计 + insuranceAccountDetailPO.setTotal(perSum.add(comSum).toPlainString()); + } + + + /** + * 获取当前登录人所控制的个税扣缴义务人的人员范围 + */ + @Override + public PageInfo getEmployeeListByTaxAgent(HrmQueryParam param) { + + List list = getInsuranceBaseInfoMapper().listAll(); + list = getAuthService(user).auth(list, AuthFilterTypeEnum.ADMIN_DATA, InsuranceArchivesBaseInfoPO.class); + List employeeIds = SalaryEntityUtil.properties(list, InsuranceArchivesBaseInfoPO::getEmployeeId, Collectors.toList()); + List resultData = new ArrayList<>(); + if (employeeIds.size() > 0) { + List> partition = Lists.partition(employeeIds, 1000); + partition.forEach(p -> { + param.setIds(p); + resultData.addAll(getEmployMapper().listHrmInfoByIdAndName(param)); + }); + + } + + // 分页 + PageInfo page = new PageInfo<>(); + if (resultData.size() == 0) { + return page; + } + page.setTotal(resultData.size()); + + page.setList(SalaryPageUtil.subList(param.getPageNum(), param.getPageSize(), resultData)); + page.setPageSize(param.getPageSize()); + page.setPageNum(param.getPageNum()); + + + return page; + } +} diff --git a/src/com/engine/salary/service/impl/SIRepairServiceImpl.java b/src/com/engine/salary/service/impl/SIRepairServiceImpl.java new file mode 100644 index 000000000..64758d625 --- /dev/null +++ b/src/com/engine/salary/service/impl/SIRepairServiceImpl.java @@ -0,0 +1,627 @@ +package com.engine.salary.service.impl; + +import com.alibaba.fastjson.JSON; +import com.engine.core.impl.Service; +import com.engine.salary.encrypt.EncryptUtil; +import com.engine.salary.entity.siaccount.param.SupplementAccountBaseParam; +import com.engine.salary.entity.siaccount.po.InsuranceAccountDetailPO; +import com.engine.salary.entity.siarchives.po.InsuranceArchivesEmployeePO; +import com.engine.salary.entity.siarchives.po.InsuranceArchivesFundSchemePO; +import com.engine.salary.entity.siarchives.po.InsuranceArchivesOtherSchemePO; +import com.engine.salary.entity.siarchives.po.InsuranceArchivesSocialSchemePO; +import com.engine.salary.entity.sicategory.po.ICategoryPO; +import com.engine.salary.entity.sischeme.po.InsuranceSchemeDetailPO; +import com.engine.salary.enums.siaccount.ProjectTypeEnum; +import com.engine.salary.enums.sicategory.DataTypeEnum; +import com.engine.salary.enums.sicategory.IsPaymentEnum; +import com.engine.salary.enums.sicategory.PaymentScopeEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.mapper.siaccount.InsuranceAccountDetailMapper; +import com.engine.salary.mapper.siarchives.FundSchemeMapper; +import com.engine.salary.mapper.siarchives.OtherSchemeMapper; +import com.engine.salary.mapper.siarchives.SocialSchemeMapper; +import com.engine.salary.mapper.sicategory.ICategoryMapper; +import com.engine.salary.mapper.sischeme.InsuranceSchemeDetailMapper; +import com.engine.salary.service.SIRepairService; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.db.MapperProxyFactory; +import org.apache.commons.lang3.StringUtils; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * @Author: sy + * @Description: 福利台账-补缴实现类 + * @Date: 2022/12/27 + **/ +public class SIRepairServiceImpl extends Service implements SIRepairService { + + private EncryptUtil encryptUtil = new EncryptUtil(); + + private InsuranceAccountDetailMapper getInsuranceAccountDetailMapper() { + return MapperProxyFactory.getProxy(InsuranceAccountDetailMapper.class); + } + + private SocialSchemeMapper getSocialSchemeMapper() { + return MapperProxyFactory.getProxy(SocialSchemeMapper.class); + } + + private FundSchemeMapper getFundSchemeMapper() { + return MapperProxyFactory.getProxy(FundSchemeMapper.class); + } + + private OtherSchemeMapper getOtherSchemeMapper() { + return MapperProxyFactory.getProxy(OtherSchemeMapper.class); + } + + private ICategoryMapper getICategoryMapper() { + return MapperProxyFactory.getProxy(ICategoryMapper.class); + } + + private InsuranceSchemeDetailMapper getInsuranceSchemeDetailMapper() { + return MapperProxyFactory.getProxy(InsuranceSchemeDetailMapper.class); + } + + /** + * 获取指定月份的福利缴纳基数作为补缴基数 + * @param param + * @return + */ + @Override + public List> getSupplementPaymentForm(SupplementAccountBaseParam param) { + + Long paymentOrganization = param.getPaymentOrganization(); + String billMonth = param.getBillMonth(); + List projects = param.getProjects(); + Long employeeId = param.getEmployeeId(); + + List detailPOList = getInsuranceAccountDetailMapper().queryNormalList(billMonth, paymentOrganization, employeeId); + + if (detailPOList.size() > 1) { + throw new SalaryRunTimeException("该人员本次核算出现多组数据,请删除数据库中多余核算项"); + } else if (detailPOList.size() == 0) { + throw new SalaryRunTimeException("数据不存在"); + } else { + InsuranceAccountDetailPO targetDetailPO = detailPOList.get(0); + encryptUtil.decrypt(targetDetailPO, InsuranceAccountDetailPO.class); + + String socialBaseString = targetDetailPO.getSocialPaymentBaseString(); + String fundBaseString = targetDetailPO.getFundPaymentBaseString(); + String otherBaseString = targetDetailPO.getOtherPaymentBaseString(); + + Map socialBaseMap = JSON.parseObject(socialBaseString, HashMap.class); + Map fundBaseMap = JSON.parseObject(fundBaseString, HashMap.class); + Map otherBaseMap = JSON.parseObject(otherBaseString, HashMap.class); + + Map targetBaseMap = new HashMap<>(); + + List allCategoryList = getICategoryMapper().listAll(); + Map categoryNameMap = SalaryEntityUtil.convert2Map(allCategoryList, ICategoryPO::getId, ICategoryPO::getInsuranceName); + Map welfareTypeMap = SalaryEntityUtil.convert2Map(allCategoryList, ICategoryPO::getId, ICategoryPO::getWelfareType); + + if (projects.contains(ProjectTypeEnum.ALL.getValue())) { + if (socialBaseMap != null) { + targetBaseMap.putAll(socialBaseMap); + } + if (fundBaseMap != null) { + targetBaseMap.putAll(fundBaseMap); + } + if (otherBaseMap != null) { + targetBaseMap.putAll(otherBaseMap); + } + + } + if (projects.contains(ProjectTypeEnum.SOCIAL.getValue())) { + if (socialBaseMap != null) { + targetBaseMap.putAll(socialBaseMap); + } + } + if (!projects.contains(ProjectTypeEnum.SOCIAL.getValue())) { + + List list = getICategoryMapper().listByDataType(DataTypeEnum.SYSTEM.getValue()); + + if (projects.contains(ProjectTypeEnum.ENDOWMENT_INSURANCE.getValue())) { + ICategoryPO insuranceCategoryPO = list.stream().filter(item -> SalaryI18nUtil.getI18nLabel(93113, "养老保险").equals(item.getInsuranceName())).findFirst() + .get(); + + if (socialBaseMap != null && socialBaseMap.containsKey(insuranceCategoryPO.getId().toString())) { + targetBaseMap.put(insuranceCategoryPO.getId().toString(), socialBaseMap.get(insuranceCategoryPO.getId().toString())); + } + + } + if (projects.contains(ProjectTypeEnum.MEDICAL_INSURANCE.getValue())) { + ICategoryPO insuranceCategoryPO = list.stream().filter(item -> SalaryI18nUtil.getI18nLabel(93114, "医疗保险").equals(item.getInsuranceName())).findFirst() + .get(); + if (socialBaseMap != null && socialBaseMap.containsKey(insuranceCategoryPO.getId().toString())) { + targetBaseMap.put(insuranceCategoryPO.getId().toString(), socialBaseMap.get(insuranceCategoryPO.getId().toString())); + } + } + + + } + if (projects.contains(ProjectTypeEnum.FUND.getValue())) { + if (fundBaseMap != null) { + targetBaseMap.putAll(fundBaseMap); + } + + } + if (projects.contains(ProjectTypeEnum.OTHER.getValue())) { + + if (otherBaseMap != null) { + targetBaseMap.putAll(otherBaseMap); + } + } + + List> resulit = new ArrayList(); + if (targetBaseMap.size() > 0) { + for (Map.Entry entry : targetBaseMap.entrySet()) { + + Map map = new HashMap<>(); + map.put("insuranceId", entry.getKey()); + map.put("insuranceName", categoryNameMap.get(Long.valueOf(entry.getKey()))); + map.put("insuranceBase", entry.getValue()); + + String welfareTypeName = welfareTypeMap.get(Long.valueOf(entry.getKey())) == 1 ? "社保" : (welfareTypeMap.get(Long.valueOf(entry.getKey())) == 2 ? "公积金" : "企业年金及其它福利" ); + String welfareTypeSign = welfareTypeMap.get(Long.valueOf(entry.getKey())) == 1 ? "social" : (welfareTypeMap.get(Long.valueOf(entry.getKey())) == 2 ? "fund" : "other" ); + map.put("title", welfareTypeName); + map.put("titleSign", welfareTypeSign); + resulit.add(map); + } + } + return resulit; + + } + + + } + + /** + * 获取待编辑的补缴费用相关福利项 + */ + @Override + public List> getPaymentGroup(SupplementAccountBaseParam param) { + + Long paymentOrganization = param.getPaymentOrganization(); + List projects = param.getProjects(); + Long employeeId = param.getEmployeeId(); + InsuranceArchivesSocialSchemePO socialSchemePO = new InsuranceArchivesSocialSchemePO(); + InsuranceArchivesFundSchemePO fundSchemePO = new InsuranceArchivesFundSchemePO(); + InsuranceArchivesOtherSchemePO otherSchemePO = new InsuranceArchivesOtherSchemePO(); + + List socialSchemePOList = getSocialSchemeMapper().getSocialByEmployeeIdAndPayOrg(InsuranceArchivesEmployeePO.builder() + .employeeId(employeeId) + .paymentOrganization(paymentOrganization) + .build()); + if (socialSchemePOList.size() > 0) { + encryptUtil.decryptList(socialSchemePOList, InsuranceArchivesSocialSchemePO.class); + socialSchemePO = socialSchemePOList.get(0); + } + + List fundSchemePOList = getFundSchemeMapper().getFundByEmployeeIdAndPayOrg(InsuranceArchivesEmployeePO.builder() + .employeeId(employeeId) + .paymentOrganization(paymentOrganization) + .build()); + if (fundSchemePOList.size() > 0) { + encryptUtil.decryptList(fundSchemePOList, InsuranceArchivesFundSchemePO.class); + fundSchemePO = fundSchemePOList.get(0); + } + + List otherSchemePOList = getOtherSchemeMapper().getOtherByEmployeeIdAndPayOrg(InsuranceArchivesEmployeePO.builder() + .employeeId(employeeId) + .paymentOrganization(paymentOrganization) + .build()); + if (otherSchemePOList.size() > 0) { + encryptUtil.decryptList(otherSchemePOList, InsuranceArchivesOtherSchemePO.class); + otherSchemePO = otherSchemePOList.get(0); + } + + List allCategoryList = getICategoryMapper().listAll(); + Map categoryNameMap = SalaryEntityUtil.convert2Map(allCategoryList, ICategoryPO::getId, ICategoryPO::getInsuranceName); + Map welfareTypeMap = SalaryEntityUtil.convert2Map(allCategoryList, ICategoryPO::getId, ICategoryPO::getWelfareType); + + List> resultList = new ArrayList<>(); + if (projects.contains(ProjectTypeEnum.ALL.getValue())) { + if (socialSchemePO != null && (StringUtils.isNotBlank(socialSchemePO.getSocialPaymentBaseString()) || StringUtils.isNotBlank(socialSchemePO.getSocialPaymentComBaseString()))) { + Map socialMap = JSON.parseObject(socialSchemePO.getSocialPaymentBaseString(), new HashMap().getClass()); + Map socialComMap = JSON.parseObject(socialSchemePO.getSocialPaymentComBaseString(), new HashMap().getClass()); + List socialIds = new ArrayList<>(); + socialIds.addAll(socialMap == null ? Collections.emptyList() : socialMap.keySet()); + socialIds.addAll(socialComMap == null ? Collections.emptyList() : socialComMap.keySet()); + socialIds = socialIds.stream().distinct().collect(Collectors.toList()); + //查询该福利方案下开启缴纳的福利项 + List insuranceIdAndScopeList = payInsuranceIdAndScopeList(socialSchemePO.getSocialSchemeId()); + List insuranceSchemeDetailPOS = getInsuranceSchemeDetailMapper().listBySchemeIds(Collections.singletonList(socialSchemePO.getSocialSchemeId())); + Map schemeValidNumMap = SalaryEntityUtil.convert2Map(insuranceSchemeDetailPOS, po -> po.getInsuranceId() + "-" + po.getPaymentScope(), InsuranceSchemeDetailPO::getValidNum); + socialIds.forEach(k -> { + String welfareTypeName = welfareTypeMap.get(Long.valueOf(k)) != null && welfareTypeMap.get(Long.valueOf(k)) == 1 ? "社保" : (welfareTypeMap.get(Long.valueOf(k)) != null && welfareTypeMap.get(Long.valueOf(k)) == 2 ? "公积金" : "企业年金及其它福利" ); + String welfareTypeSign = welfareTypeMap.get(Long.valueOf(k)) != null && welfareTypeMap.get(Long.valueOf(k)) == 1 ? "social" : (welfareTypeMap.get(Long.valueOf(k)) != null && welfareTypeMap.get(Long.valueOf(k)) == 2 ? "fund" : "other" ); + if (insuranceIdAndScopeList.contains(k + "-" + PaymentScopeEnum.SCOPE_COMPANY.getValue())) { + Map comMap = new HashMap<>(); + comMap.put("title", welfareTypeName); + comMap.put("titleSign", welfareTypeSign); + comMap.put("insuranceId", k); + comMap.put("insuranceName", categoryNameMap.get(Long.valueOf(k))); + comMap.put("paymentScope", "公司"); + comMap.put("paymentScopeSign", "com"); + comMap.put("validNum",schemeValidNumMap.getOrDefault(k + "-" + PaymentScopeEnum.SCOPE_COMPANY.getValue(), 2).toString()); + resultList.add(comMap); + } + if (insuranceIdAndScopeList.contains(k + "-" + PaymentScopeEnum.SCOPE_PERSON.getValue())) { + Map perMap = new HashMap<>(); + perMap.put("title", welfareTypeName); + perMap.put("titleSign", welfareTypeSign); + perMap.put("insuranceId", k); + perMap.put("insuranceName", categoryNameMap.get(Long.valueOf(k))); + perMap.put("paymentScope", "个人"); + perMap.put("paymentScopeSign", "per"); + perMap.put("validNum",schemeValidNumMap.getOrDefault(k + "-" + PaymentScopeEnum.SCOPE_PERSON.getValue(), 2).toString()); + resultList.add(perMap); + } + }); + + } + if (fundSchemePO != null && (StringUtils.isNotBlank(fundSchemePO.getFundPaymentBaseString()) || StringUtils.isNotBlank(fundSchemePO.getFundPaymentComBaseString()))) { + Map fundMap = JSON.parseObject(fundSchemePO.getFundPaymentBaseString(), new HashMap().getClass()); + Map fundComMap = JSON.parseObject(fundSchemePO.getFundPaymentComBaseString(), new HashMap().getClass()); + List fundIds = new ArrayList<>(); + fundIds.addAll(fundMap == null ? Collections.emptyList() : fundMap.keySet()); + fundIds.addAll(fundComMap == null ? Collections.emptyList() : fundComMap.keySet()); + fundIds = fundIds.stream().distinct().collect(Collectors.toList()); + //查询该福利方案下开启缴纳的福利项 + List insuranceIdAndScopeList = payInsuranceIdAndScopeList(fundSchemePO.getFundSchemeId()); + List insuranceSchemeDetailPOS = getInsuranceSchemeDetailMapper().listBySchemeIds(Collections.singletonList(fundSchemePO.getFundSchemeId())); + Map schemeValidNumMap = SalaryEntityUtil.convert2Map(insuranceSchemeDetailPOS, po -> po.getInsuranceId() + "-" + po.getPaymentScope(), InsuranceSchemeDetailPO::getValidNum); + fundIds.forEach(k -> { + String welfareTypeName = welfareTypeMap.get(Long.valueOf(k)) != null && welfareTypeMap.get(Long.valueOf(k)) == 1 ? "社保" : (welfareTypeMap.get(Long.valueOf(k)) != null && welfareTypeMap.get(Long.valueOf(k)) == 2 ? "公积金" : "企业年金及其它福利" ); + String welfareTypeSign = welfareTypeMap.get(Long.valueOf(k)) != null && welfareTypeMap.get(Long.valueOf(k)) == 1 ? "social" : (welfareTypeMap.get(Long.valueOf(k)) != null && welfareTypeMap.get(Long.valueOf(k)) == 2 ? "fund" : "other" ); + if (insuranceIdAndScopeList.contains(k + "-" + PaymentScopeEnum.SCOPE_COMPANY.getValue())) { + Map comMap = new HashMap<>(); + comMap.put("title", welfareTypeName); + comMap.put("titleSign", welfareTypeSign); + comMap.put("insuranceId", k); + comMap.put("insuranceName", categoryNameMap.get(Long.valueOf(k))); + comMap.put("paymentScope", "公司"); + comMap.put("paymentScopeSign", "com"); + comMap.put("validNum",schemeValidNumMap.getOrDefault(k + "-" + PaymentScopeEnum.SCOPE_COMPANY.getValue(), 2).toString()); + resultList.add(comMap); + } + if (insuranceIdAndScopeList.contains(k + "-" + PaymentScopeEnum.SCOPE_PERSON.getValue())) { + Map perMap = new HashMap<>(); + perMap.put("title", welfareTypeName); + perMap.put("titleSign", welfareTypeSign); + perMap.put("insuranceId", k); + perMap.put("insuranceName", categoryNameMap.get(Long.valueOf(k))); + perMap.put("paymentScope", "个人"); + perMap.put("paymentScopeSign", "per"); + perMap.put("validNum",schemeValidNumMap.getOrDefault(k + "-" + PaymentScopeEnum.SCOPE_PERSON.getValue(), 2).toString()); + resultList.add(perMap); + } + }); + + } + if (otherSchemePO != null && (StringUtils.isNotBlank(otherSchemePO.getOtherPaymentBaseString()) || StringUtils.isNotBlank(otherSchemePO.getOtherPaymentComBaseString()))) { + Map otherMap = JSON.parseObject(otherSchemePO.getOtherPaymentBaseString(), new HashMap().getClass()); + Map otherComMap = JSON.parseObject(otherSchemePO.getOtherPaymentComBaseString(), new HashMap().getClass()); + List otherIds = new ArrayList<>(); + otherIds.addAll(otherMap == null ? Collections.emptyList() : otherMap.keySet()); + otherIds.addAll(otherComMap == null ? Collections.emptyList() : otherComMap.keySet()); + otherIds = otherIds.stream().distinct().collect(Collectors.toList()); + //查询该福利方案下开启缴纳的福利项 + List insuranceIdAndScopeList = payInsuranceIdAndScopeList(otherSchemePO.getOtherSchemeId()); + List insuranceSchemeDetailPOS = getInsuranceSchemeDetailMapper().listBySchemeIds(Collections.singletonList(otherSchemePO.getOtherSchemeId())); + Map schemeValidNumMap = SalaryEntityUtil.convert2Map(insuranceSchemeDetailPOS, po -> po.getInsuranceId() + "-" + po.getPaymentScope(), InsuranceSchemeDetailPO::getValidNum); + otherIds.forEach(k -> { + String welfareTypeName = welfareTypeMap.get(Long.valueOf(k)) == 1 ? "社保" : (welfareTypeMap.get(Long.valueOf(k)) == 2 ? "公积金" : "企业年金及其它福利" ); + String welfareTypeSign = welfareTypeMap.get(Long.valueOf(k)) == 1 ? "social" : (welfareTypeMap.get(Long.valueOf(k)) == 2 ? "fund" : "other" ); + if (insuranceIdAndScopeList.contains(k + "-" + PaymentScopeEnum.SCOPE_COMPANY.getValue())) { + Map comMap = new HashMap<>(); + comMap.put("title", welfareTypeName); + comMap.put("titleSign", welfareTypeSign); + comMap.put("insuranceId", k); + comMap.put("insuranceName", categoryNameMap.get(Long.valueOf(k))); + comMap.put("paymentScope", "公司"); + comMap.put("paymentScopeSign", "com"); + comMap.put("validNum",schemeValidNumMap.getOrDefault(k + "-" + PaymentScopeEnum.SCOPE_COMPANY.getValue(), 2).toString()); + resultList.add(comMap); + } + if (insuranceIdAndScopeList.contains(k + "-" + PaymentScopeEnum.SCOPE_PERSON.getValue())) { + Map perMap = new HashMap<>(); + perMap.put("title", welfareTypeName); + perMap.put("titleSign", welfareTypeSign); + perMap.put("insuranceId", k); + perMap.put("insuranceName", categoryNameMap.get(Long.valueOf(k))); + perMap.put("paymentScope", "个人"); + perMap.put("paymentScopeSign", "per"); + perMap.put("validNum",schemeValidNumMap.getOrDefault(k + "-" + PaymentScopeEnum.SCOPE_PERSON.getValue(), 2).toString()); + resultList.add(perMap); + } + }); + } + return resultList; + } + if (projects.contains(ProjectTypeEnum.SOCIAL.getValue())) { + if (socialSchemePO != null && (StringUtils.isNotBlank(socialSchemePO.getSocialPaymentBaseString()) || StringUtils.isNotBlank(socialSchemePO.getSocialPaymentComBaseString()))) { + Map socialMap = JSON.parseObject(socialSchemePO.getSocialPaymentBaseString(), new HashMap().getClass()); + Map socialComMap = JSON.parseObject(socialSchemePO.getSocialPaymentComBaseString(), new HashMap().getClass()); + List socialIds = new ArrayList<>(); + socialIds.addAll(socialMap == null ? Collections.emptyList() : socialMap.keySet()); + socialIds.addAll(socialComMap == null ? Collections.emptyList() : socialComMap.keySet()); + socialIds = socialIds.stream().distinct().collect(Collectors.toList()); + //查询该福利方案下开启缴纳的福利项 + List insuranceIdAndScopeList = payInsuranceIdAndScopeList(socialSchemePO.getSocialSchemeId()); + List insuranceSchemeDetailPOS = getInsuranceSchemeDetailMapper().listBySchemeIds(Collections.singletonList(socialSchemePO.getSocialSchemeId())); + Map schemeValidNumMap = SalaryEntityUtil.convert2Map(insuranceSchemeDetailPOS, po -> po.getInsuranceId() + "-" + po.getPaymentScope(), InsuranceSchemeDetailPO::getValidNum); + socialIds.forEach(k -> { + String welfareTypeName = welfareTypeMap.get(Long.valueOf(k)) != null && welfareTypeMap.get(Long.valueOf(k)) == 1 ? "社保" : (welfareTypeMap.get(Long.valueOf(k)) != null && welfareTypeMap.get(Long.valueOf(k)) == 2 ? "公积金" : "企业年金及其它福利" ); + String welfareTypeSign = welfareTypeMap.get(Long.valueOf(k)) != null && welfareTypeMap.get(Long.valueOf(k)) == 1 ? "social" : (welfareTypeMap.get(Long.valueOf(k)) != null && welfareTypeMap.get(Long.valueOf(k)) == 2 ? "fund" : "other" ); + if (insuranceIdAndScopeList.contains(k + "-" + PaymentScopeEnum.SCOPE_COMPANY.getValue())) { + Map comMap = new HashMap<>(); + comMap.put("title", welfareTypeName); + comMap.put("titleSign", welfareTypeSign); + comMap.put("insuranceId", k); + comMap.put("insuranceName", categoryNameMap.get(Long.valueOf(k))); + comMap.put("paymentScope", "公司"); + comMap.put("paymentScopeSign", "com"); + comMap.put("validNum",schemeValidNumMap.getOrDefault(k + "-" + PaymentScopeEnum.SCOPE_COMPANY.getValue(), 2).toString()); + resultList.add(comMap); + } + if (insuranceIdAndScopeList.contains(k + "-" + PaymentScopeEnum.SCOPE_PERSON.getValue())) { + Map perMap = new HashMap<>(); + perMap.put("title", welfareTypeName); + perMap.put("titleSign", welfareTypeSign); + perMap.put("insuranceId", k); + perMap.put("insuranceName", categoryNameMap.get(Long.valueOf(k))); + perMap.put("paymentScope", "个人"); + perMap.put("paymentScopeSign", "per"); + perMap.put("validNum",schemeValidNumMap.getOrDefault(k + "-" + PaymentScopeEnum.SCOPE_PERSON.getValue(), 2).toString()); + resultList.add(perMap); + } + }); + + } + } + if ((!projects.contains(ProjectTypeEnum.SOCIAL.getValue())) + && (projects.contains(ProjectTypeEnum.ENDOWMENT_INSURANCE.getValue())) + && (projects.contains(ProjectTypeEnum.MEDICAL_INSURANCE.getValue()))) { + if (socialSchemePO != null && (StringUtils.isNotBlank(socialSchemePO.getSocialPaymentBaseString()) || StringUtils.isNotBlank(socialSchemePO.getSocialPaymentComBaseString()))) { + Map socialMap = JSON.parseObject(socialSchemePO.getSocialPaymentBaseString(), new HashMap().getClass()); + socialMap = socialMap.entrySet().stream().filter(e -> "9001".equals(e.getKey()) || "9002".equals(e.getKey())) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + Map socialComMap = JSON.parseObject(socialSchemePO.getSocialPaymentComBaseString(), new HashMap().getClass()); + socialComMap = socialComMap.entrySet().stream().filter(e -> "9001".equals(e.getKey()) || "9002".equals(e.getKey())) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + List socialIds = new ArrayList<>(); + socialIds.addAll(socialMap == null ? Collections.emptyList() : socialMap.keySet()); + socialIds.addAll(socialComMap == null ? Collections.emptyList() : socialMap.keySet()); + socialIds = socialIds.stream().distinct().collect(Collectors.toList()); + //查询该福利方案下开启缴纳的福利项 + List insuranceIdAndScopeList = payInsuranceIdAndScopeList(socialSchemePO.getSocialSchemeId()); + List insuranceSchemeDetailPOS = getInsuranceSchemeDetailMapper().listBySchemeIds(Collections.singletonList(socialSchemePO.getSocialSchemeId())); + Map schemeValidNumMap = SalaryEntityUtil.convert2Map(insuranceSchemeDetailPOS, po -> po.getInsuranceId() + "-" + po.getPaymentScope(), InsuranceSchemeDetailPO::getValidNum); + socialIds.forEach( k -> { + String welfareTypeName = welfareTypeMap.get(Long.valueOf(k)) != null && welfareTypeMap.get(Long.valueOf(k)) == 1 ? "社保" : (welfareTypeMap.get(Long.valueOf(k)) != null && welfareTypeMap.get(Long.valueOf(k)) == 2 ? "公积金" : "企业年金及其它福利" ); + String welfareTypeSign = welfareTypeMap.get(Long.valueOf(k)) != null && welfareTypeMap.get(Long.valueOf(k)) == 1 ? "social" : (welfareTypeMap.get(Long.valueOf(k)) != null && welfareTypeMap.get(Long.valueOf(k)) == 2 ? "fund" : "other" ); + if (insuranceIdAndScopeList.contains(k + "-" + PaymentScopeEnum.SCOPE_COMPANY.getValue())) { + Map comMap = new HashMap<>(); + comMap.put("title", welfareTypeName); + comMap.put("titleSign", welfareTypeSign); + comMap.put("insuranceId", k); + comMap.put("insuranceName", categoryNameMap.get(Long.valueOf(k))); + comMap.put("paymentScope", "公司"); + comMap.put("paymentScopeSign", "com"); + comMap.put("validNum",schemeValidNumMap.getOrDefault(k + "-" + PaymentScopeEnum.SCOPE_COMPANY.getValue(), 2).toString()); + resultList.add(comMap); + } + if (insuranceIdAndScopeList.contains(k + "-" + PaymentScopeEnum.SCOPE_PERSON.getValue())) { + Map perMap = new HashMap<>(); + perMap.put("title", welfareTypeName); + perMap.put("titleSign", welfareTypeSign); + perMap.put("insuranceId", k); + perMap.put("insuranceName", categoryNameMap.get(Long.valueOf(k))); + perMap.put("paymentScope", "个人"); + perMap.put("paymentScopeSign", "per"); + perMap.put("validNum",schemeValidNumMap.getOrDefault(k + "-" + PaymentScopeEnum.SCOPE_PERSON.getValue(), 2).toString()); + resultList.add(perMap); + } + }); + + } + } + if ((!projects.contains(ProjectTypeEnum.SOCIAL.getValue())) + && (projects.contains(ProjectTypeEnum.ENDOWMENT_INSURANCE.getValue())) + && (!projects.contains(ProjectTypeEnum.MEDICAL_INSURANCE.getValue()))) { + if (socialSchemePO != null && (StringUtils.isNotBlank(socialSchemePO.getSocialPaymentBaseString()) || StringUtils.isNotBlank(socialSchemePO.getSocialPaymentComBaseString()))) { + Map socialMap = JSON.parseObject(socialSchemePO.getSocialPaymentBaseString(), new HashMap().getClass()); + socialMap = socialMap.entrySet().stream().filter(e -> "9001".equals(e.getKey())) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + + Map socialComMap = JSON.parseObject(socialSchemePO.getSocialPaymentComBaseString(), new HashMap().getClass()); + socialComMap = socialComMap.entrySet().stream().filter(e -> "9001".equals(e.getKey())) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + List socialIds = new ArrayList<>(); + socialIds.addAll(socialMap == null ? Collections.emptyList() : socialMap.keySet()); + socialIds.addAll(socialComMap == null ? Collections.emptyList() :socialComMap.keySet()); + socialIds = socialIds.stream().distinct().collect(Collectors.toList()); + //查询该福利方案下开启缴纳的福利项 + List insuranceIdAndScopeList = payInsuranceIdAndScopeList(socialSchemePO.getSocialSchemeId()); + List insuranceSchemeDetailPOS = getInsuranceSchemeDetailMapper().listBySchemeIds(Collections.singletonList(socialSchemePO.getSocialSchemeId())); + Map schemeValidNumMap = SalaryEntityUtil.convert2Map(insuranceSchemeDetailPOS, po -> po.getInsuranceId() + "-" + po.getPaymentScope(), InsuranceSchemeDetailPO::getValidNum); + socialIds.forEach(k -> { + String welfareTypeName = welfareTypeMap.get(Long.valueOf(k)) != null && welfareTypeMap.get(Long.valueOf(k)) == 1 ? "社保" : (welfareTypeMap.get(Long.valueOf(k)) != null && welfareTypeMap.get(Long.valueOf(k)) == 2 ? "公积金" : "企业年金及其它福利" ); + String welfareTypeSign = welfareTypeMap.get(Long.valueOf(k)) != null && welfareTypeMap.get(Long.valueOf(k)) == 1 ? "social" : (welfareTypeMap.get(Long.valueOf(k)) != null && welfareTypeMap.get(Long.valueOf(k)) == 2 ? "fund" : "other" ); + if (insuranceIdAndScopeList.contains(k + "-" + PaymentScopeEnum.SCOPE_COMPANY.getValue())) { + Map comMap = new HashMap<>(); + comMap.put("title", welfareTypeName); + comMap.put("titleSign", welfareTypeSign); + comMap.put("insuranceId", k); + comMap.put("insuranceName", categoryNameMap.get(Long.valueOf(k))); + comMap.put("paymentScope", "公司"); + comMap.put("paymentScopeSign", "com"); + comMap.put("validNum",schemeValidNumMap.getOrDefault(k + "-" + PaymentScopeEnum.SCOPE_COMPANY.getValue(), 2).toString()); + resultList.add(comMap); + } + if (insuranceIdAndScopeList.contains(k + "-" + PaymentScopeEnum.SCOPE_PERSON.getValue())) { + Map perMap = new HashMap<>(); + perMap.put("title", welfareTypeName); + perMap.put("titleSign", welfareTypeSign); + perMap.put("insuranceId", k); + perMap.put("insuranceName", categoryNameMap.get(Long.valueOf(k))); + perMap.put("paymentScope", "个人"); + perMap.put("paymentScopeSign", "per"); + perMap.put("validNum",schemeValidNumMap.getOrDefault(k + "-" + PaymentScopeEnum.SCOPE_PERSON.getValue(), 2).toString()); + resultList.add(perMap); + } + }); + + } + } + if ((!projects.contains(ProjectTypeEnum.SOCIAL.getValue())) + && (!projects.contains(ProjectTypeEnum.ENDOWMENT_INSURANCE.getValue())) + && (projects.contains(ProjectTypeEnum.MEDICAL_INSURANCE.getValue()))) { + if (socialSchemePO != null && (StringUtils.isNotBlank(socialSchemePO.getSocialPaymentBaseString()) || StringUtils.isNotBlank(socialSchemePO.getSocialPaymentComBaseString()))) { + Map socialMap = JSON.parseObject(socialSchemePO.getSocialPaymentBaseString(), new HashMap().getClass()); + socialMap = socialMap.entrySet().stream().filter(e -> "9002".equals(e.getKey())) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + Map socialComMap = JSON.parseObject(socialSchemePO.getSocialPaymentComBaseString(), new HashMap().getClass()); + socialComMap = socialComMap.entrySet().stream().filter(e -> "9002".equals(e.getKey())) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + List socialIds = new ArrayList<>(); + socialIds.addAll(socialMap == null ? Collections.emptyList() : socialMap.keySet()); + socialIds.addAll(socialComMap == null ? Collections.emptyList() : socialComMap.keySet()); + socialIds = socialIds.stream().distinct().collect(Collectors.toList()); + //查询该福利方案下开启缴纳的福利项 + List insuranceIdAndScopeList = payInsuranceIdAndScopeList(socialSchemePO.getSocialSchemeId()); + List insuranceSchemeDetailPOS = getInsuranceSchemeDetailMapper().listBySchemeIds(Collections.singletonList(socialSchemePO.getSocialSchemeId())); + Map schemeValidNumMap = SalaryEntityUtil.convert2Map(insuranceSchemeDetailPOS, po -> po.getInsuranceId() + "-" + po.getPaymentScope(), InsuranceSchemeDetailPO::getValidNum); + socialIds.forEach(k -> { + String welfareTypeName = welfareTypeMap.get(Long.valueOf(k)) != null && welfareTypeMap.get(Long.valueOf(k)) == 1 ? "社保" : (welfareTypeMap.get(Long.valueOf(k)) != null && welfareTypeMap.get(Long.valueOf(k)) == 2 ? "公积金" : "企业年金及其它福利" ); + String welfareTypeSign = welfareTypeMap.get(Long.valueOf(k)) != null && welfareTypeMap.get(Long.valueOf(k)) == 1 ? "social" : (welfareTypeMap.get(Long.valueOf(k)) != null && welfareTypeMap.get(Long.valueOf(k)) == 2 ? "fund" : "other" ); + if (insuranceIdAndScopeList.contains(k + "-" + PaymentScopeEnum.SCOPE_COMPANY.getValue())) { + Map comMap = new HashMap<>(); + comMap.put("title", welfareTypeName); + comMap.put("titleSign", welfareTypeSign); + comMap.put("insuranceId", k); + comMap.put("insuranceName", categoryNameMap.get(Long.valueOf(k))); + comMap.put("paymentScope", "公司"); + comMap.put("paymentScopeSign", "com"); + comMap.put("validNum",schemeValidNumMap.getOrDefault(k + "-" + PaymentScopeEnum.SCOPE_COMPANY.getValue(), 2).toString()); + resultList.add(comMap); + } + if (insuranceIdAndScopeList.contains(k + "-" + PaymentScopeEnum.SCOPE_PERSON.getValue())) { + Map perMap = new HashMap<>(); + perMap.put("title", welfareTypeName); + perMap.put("titleSign", welfareTypeSign); + perMap.put("insuranceId", k); + perMap.put("insuranceName", categoryNameMap.get(Long.valueOf(k))); + perMap.put("paymentScope", "个人"); + perMap.put("paymentScopeSign", "per"); + perMap.put("validNum",schemeValidNumMap.getOrDefault(k + "-" + PaymentScopeEnum.SCOPE_PERSON.getValue(), 2).toString()); + resultList.add(perMap); + } + }); + + } + } + if (projects.contains(ProjectTypeEnum.FUND.getValue())) { + if (fundSchemePO != null && (StringUtils.isNotBlank(fundSchemePO.getFundPaymentBaseString()) || StringUtils.isNotBlank(fundSchemePO.getFundPaymentComBaseString()))) { + Map fundMap = JSON.parseObject(fundSchemePO.getFundPaymentBaseString(), new HashMap().getClass()); + Map fundComMap = JSON.parseObject(fundSchemePO.getFundPaymentComBaseString(), new HashMap().getClass()); + List fundIds = new ArrayList<>(); + fundIds.addAll(fundMap == null ? Collections.emptyList() : fundMap.keySet()); + fundIds.addAll(fundComMap == null ? Collections.emptyList() : fundComMap.keySet()); + fundIds = fundIds.stream().distinct().collect(Collectors.toList()); + //查询该福利方案下开启缴纳的福利项 + List insuranceIdAndScopeList = payInsuranceIdAndScopeList(fundSchemePO.getFundSchemeId()); + List insuranceSchemeDetailPOS = getInsuranceSchemeDetailMapper().listBySchemeIds(Collections.singletonList(fundSchemePO.getFundSchemeId())); + Map schemeValidNumMap = SalaryEntityUtil.convert2Map(insuranceSchemeDetailPOS, po -> po.getInsuranceId() + "-" + po.getPaymentScope(), InsuranceSchemeDetailPO::getValidNum); + fundIds.forEach(k -> { + String welfareTypeName = welfareTypeMap.get(Long.valueOf(k)) != null && welfareTypeMap.get(Long.valueOf(k)) == 1 ? "社保" : (welfareTypeMap.get(Long.valueOf(k)) != null && welfareTypeMap.get(Long.valueOf(k)) == 2 ? "公积金" : "企业年金及其它福利" ); + String welfareTypeSign = welfareTypeMap.get(Long.valueOf(k)) != null && welfareTypeMap.get(Long.valueOf(k)) == 1 ? "social" : (welfareTypeMap.get(Long.valueOf(k)) != null && welfareTypeMap.get(Long.valueOf(k)) == 2 ? "fund" : "other" ); + if (insuranceIdAndScopeList.contains(k + "-" + PaymentScopeEnum.SCOPE_COMPANY.getValue())) { + Map comMap = new HashMap<>(); + comMap.put("title", welfareTypeName); + comMap.put("titleSign", welfareTypeSign); + comMap.put("insuranceId", k); + comMap.put("insuranceName", categoryNameMap.get(Long.valueOf(k))); + comMap.put("paymentScope", "公司"); + comMap.put("paymentScopeSign", "com"); + comMap.put("validNum",schemeValidNumMap.getOrDefault(k + "-" + PaymentScopeEnum.SCOPE_COMPANY.getValue(), 2).toString()); + resultList.add(comMap); + } + if (insuranceIdAndScopeList.contains(k + "-" + PaymentScopeEnum.SCOPE_PERSON.getValue())) { + Map perMap = new HashMap<>(); + perMap.put("title", welfareTypeName); + perMap.put("titleSign", welfareTypeSign); + perMap.put("insuranceId", k); + perMap.put("insuranceName", categoryNameMap.get(Long.valueOf(k))); + perMap.put("paymentScope", "个人"); + perMap.put("paymentScopeSign", "per"); + perMap.put("validNum",schemeValidNumMap.getOrDefault(k + "-" + PaymentScopeEnum.SCOPE_PERSON.getValue(), 2).toString()); + resultList.add(perMap); + } + }); + + } + } + if (projects.contains(ProjectTypeEnum.OTHER.getValue())) { + if (otherSchemePO != null && (StringUtils.isNotBlank(otherSchemePO.getOtherPaymentBaseString()) || StringUtils.isNotBlank(otherSchemePO.getOtherPaymentComBaseString()))) { + Map otherMap = JSON.parseObject(otherSchemePO.getOtherPaymentBaseString(), new HashMap().getClass()); + Map otherComMap = JSON.parseObject(otherSchemePO.getOtherPaymentComBaseString(), new HashMap().getClass()); + List otherIds = new ArrayList<>(); + otherIds.addAll(otherMap == null ? Collections.emptyList() : otherMap.keySet()); + otherIds.addAll(otherComMap == null ? Collections.emptyList() : otherComMap.keySet()); + otherIds = otherIds.stream().distinct().collect(Collectors.toList()); + //查询该福利方案下开启缴纳的福利项 + List insuranceIdAndScopeList = payInsuranceIdAndScopeList(otherSchemePO.getOtherSchemeId()); + List insuranceSchemeDetailPOS = getInsuranceSchemeDetailMapper().listBySchemeIds(Collections.singletonList(otherSchemePO.getOtherSchemeId())); + Map schemeValidNumMap = SalaryEntityUtil.convert2Map(insuranceSchemeDetailPOS, po -> po.getInsuranceId() + "-" + po.getPaymentScope(), InsuranceSchemeDetailPO::getValidNum); + otherIds.forEach(k -> { + String welfareTypeName = welfareTypeMap.get(Long.valueOf(k)) != null && welfareTypeMap.get(Long.valueOf(k)) == 1 ? "社保" : (welfareTypeMap.get(Long.valueOf(k)) != null && welfareTypeMap.get(Long.valueOf(k)) == 2 ? "公积金" : "企业年金及其它福利" ); + String welfareTypeSign = welfareTypeMap.get(Long.valueOf(k)) != null && welfareTypeMap.get(Long.valueOf(k)) == 1 ? "social" : (welfareTypeMap.get(Long.valueOf(k)) != null && welfareTypeMap.get(Long.valueOf(k)) == 2 ? "fund" : "other" ); + if (insuranceIdAndScopeList.contains(k + "-" + PaymentScopeEnum.SCOPE_COMPANY.getValue())) { + Map comMap = new HashMap<>(); + comMap.put("title", welfareTypeName); + comMap.put("titleSign", welfareTypeSign); + comMap.put("insuranceId", k); + comMap.put("insuranceName", categoryNameMap.get(Long.valueOf(k))); + comMap.put("paymentScope", "公司"); + comMap.put("paymentScopeSign", "com"); + comMap.put("validNum",schemeValidNumMap.getOrDefault(k + "-" + PaymentScopeEnum.SCOPE_COMPANY.getValue(), 2).toString()); + resultList.add(comMap); + } + if (insuranceIdAndScopeList.contains(k + "-" + PaymentScopeEnum.SCOPE_PERSON.getValue())) { + Map perMap = new HashMap<>(); + perMap.put("title", welfareTypeName); + perMap.put("titleSign", welfareTypeSign); + perMap.put("insuranceId", k); + perMap.put("insuranceName", categoryNameMap.get(Long.valueOf(k))); + perMap.put("paymentScope", "个人"); + perMap.put("paymentScopeSign", "per"); + perMap.put("validNum",schemeValidNumMap.getOrDefault(k + "-" + PaymentScopeEnum.SCOPE_PERSON.getValue(), 2).toString()); + resultList.add(perMap); + } + }); + + } + } + + return resultList; + } + + public List payInsuranceIdAndScopeList(Long socialSchemeId) { + //查询该福利方案下开启缴纳的福利项 + List detailPOS = getInsuranceSchemeDetailMapper().queryListBySchemeId(socialSchemeId); + List insuranceIdList = new ArrayList<>(); + if (detailPOS != null && detailPOS.size() > 0) { + //开启缴纳的 + insuranceIdList = detailPOS.stream().filter(f -> f.getIsPayment().equals(IsPaymentEnum.YES.getValue())).map(m -> { + return m.getInsuranceId() .toString() + "-" + m.getPaymentScope().toString(); + }).collect(Collectors.toList()); + } + return insuranceIdList; + } + + +} diff --git a/src/com/engine/salary/service/impl/SIReportServiceImpl.java b/src/com/engine/salary/service/impl/SIReportServiceImpl.java new file mode 100644 index 000000000..84da7db00 --- /dev/null +++ b/src/com/engine/salary/service/impl/SIReportServiceImpl.java @@ -0,0 +1,34 @@ +package com.engine.salary.service.impl; + +import com.engine.core.impl.Service; +import com.engine.salary.encrypt.EncryptUtil; +import com.engine.salary.entity.siaccount.param.QueryAccountDetailParam; +import com.engine.salary.entity.siaccount.po.InsuranceAccountDetailPO; +import com.engine.salary.mapper.siaccount.SIAccountDetailMapper; +import com.engine.salary.service.SIReportService; +import com.engine.salary.util.db.MapperProxyFactory; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.util.page.SalaryPageUtil; + +import java.util.List; + + +public class SIReportServiceImpl extends Service implements SIReportService { + + private EncryptUtil encryptUtil = new EncryptUtil(); + + private SIAccountDetailMapper getSIAccountDetailMapper(){ + return MapperProxyFactory.getProxy(SIAccountDetailMapper.class); + } + + @Override + public PageInfo welfareList(QueryAccountDetailParam param) { + List insuranceAccountDetailPOS = getSIAccountDetailMapper().listSome(param); + PageInfo page = SalaryPageUtil.buildPage(param.getCurrent(), param.getPageSize(), + insuranceAccountDetailPOS ,InsuranceAccountDetailPO.class); + List list = page.getList(); + encryptUtil.decryptList(list, InsuranceAccountDetailPO.class); + page.setList(list); + return page; + } +} diff --git a/src/com/engine/salary/service/impl/SISchemeServiceImpl.java b/src/com/engine/salary/service/impl/SISchemeServiceImpl.java new file mode 100644 index 000000000..cef8f80b8 --- /dev/null +++ b/src/com/engine/salary/service/impl/SISchemeServiceImpl.java @@ -0,0 +1,2933 @@ +package com.engine.salary.service.impl; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.TypeReference; +import com.api.formmode.mybatis.util.SqlProxyHandle; +import com.cloudstore.eccom.pc.table.WeaTableColumn; +import com.cloudstore.eccom.result.WeaResultMsg; +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.hrmelog.entity.dto.LoggerContext; +import com.engine.salary.component.SalaryWeaTable; +import com.engine.salary.config.SalaryElogConfig; +import com.engine.salary.constant.SalaryDefaultTenantConstant; +import com.engine.salary.encrypt.EncryptUtil; +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.siarchives.param.InsuranceArchivesListParam; +import com.engine.salary.entity.siarchives.param.SIArchiveImportParam; +import com.engine.salary.entity.siarchives.po.*; +import com.engine.salary.entity.sicategory.po.ICategoryPO; +import com.engine.salary.entity.sischeme.bo.InsuranceSchemeBO; +import com.engine.salary.entity.sischeme.dto.InsuranceSchemeDTO; +import com.engine.salary.entity.sischeme.dto.InsuranceSchemeDetailDTO; +import com.engine.salary.entity.sischeme.dto.InsuranceSchemeListDTO; +import com.engine.salary.entity.sischeme.param.InsuranceSchemeDetailUpdateParam; +import com.engine.salary.entity.sischeme.param.InsuranceSchemeParam; +import com.engine.salary.entity.sischeme.param.InsuranceSchemeReqParam; +import com.engine.salary.entity.sischeme.po.InsuranceSchemeDetailPO; +import com.engine.salary.entity.sischeme.po.InsuranceSchemePO; +import com.engine.salary.entity.sischeme.vo.InsuranceSchemeFormVO; +import com.engine.salary.entity.sischeme.vo.SISchemeTableVO; +import com.engine.salary.entity.taxagent.dto.TaxAgentManageRangeEmployeeDTO; +import com.engine.salary.entity.taxagent.param.TaxAgentManageRangeSaveParam; +import com.engine.salary.entity.taxagent.param.TaxAgentQueryParam; +import com.engine.salary.entity.taxagent.param.TaxAgentRangeSaveParam; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import com.engine.salary.enums.OperateTypeEnum; +import com.engine.salary.enums.SalaryRoundingModeEnum; +import com.engine.salary.enums.UserStatusEnum; +import com.engine.salary.enums.auth.AuthFilterTypeEnum; +import com.engine.salary.enums.salarysob.TargetTypeEnum; +import com.engine.salary.enums.siaccount.EmployeeStatusEnum; +import com.engine.salary.enums.sicategory.*; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.mapper.datacollection.EmployMapper; +import com.engine.salary.mapper.siaccount.SIAccountUtilMapper; +import com.engine.salary.mapper.siarchives.FundSchemeMapper; +import com.engine.salary.mapper.siarchives.InsuranceBaseInfoMapper; +import com.engine.salary.mapper.siarchives.OtherSchemeMapper; +import com.engine.salary.mapper.siarchives.SocialSchemeMapper; +import com.engine.salary.mapper.sicategory.ICategoryMapper; +import com.engine.salary.mapper.sischeme.InsuranceSchemeDetailMapper; +import com.engine.salary.mapper.sischeme.InsuranceSchemeMapper; +import com.engine.salary.mapper.sys.SalarySysConfMapper; +import com.engine.salary.mapper.taxagent.TaxAgentMapper; +import com.engine.salary.service.*; +import com.engine.salary.service.auth.AuthService; +import com.engine.salary.service.auth.AuthServiceImpl; +import com.engine.salary.sys.entity.po.SalarySysConfPO; +import com.engine.salary.sys.entity.vo.OrderRuleVO; +import com.engine.salary.sys.enums.OpenEnum; +import com.engine.salary.sys.service.SalarySysConfService; +import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl; +import com.engine.salary.util.*; +import com.engine.salary.util.db.IdGenerator; +import com.engine.salary.util.db.MapperProxyFactory; +import com.engine.salary.util.excel.ExcelParseHelper; +import com.engine.salary.util.excel.ExcelSupport; +import com.engine.salary.util.excel.ExcelUtilPlus; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.util.page.SalaryPageUtil; +import com.engine.salary.util.valid.ValidUtil; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.math.NumberUtils; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.util.IOUtils; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.springframework.beans.BeanUtils; +import weaver.file.ImageFileManager; +import weaver.general.Util; +import weaver.hrm.User; + +import java.io.InputStream; +import java.math.BigDecimal; +import java.util.*; +import java.util.function.Function; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import java.util.stream.Collectors; + +import static com.engine.salary.sys.constant.SalarySysConstant.WEL_BASE_AUTO_ADJUST; +import static com.engine.salary.util.excel.ExcelSupport.EXCEL_TYPE_XLSX; + +/** + * @Author weaver_cl + * @Description: + * @Date 2022/3/7 + * @Version V1.0 + **/ +@Slf4j +public class SISchemeServiceImpl extends Service implements SISchemeService { + private EncryptUtil encryptUtil = new EncryptUtil(); + + private SocialSchemeMapper getSocialSchemeMapper() { + return MapperProxyFactory.getProxy(SocialSchemeMapper.class); + } + + private FundSchemeMapper getFundSchemeMapper() { + return MapperProxyFactory.getProxy(FundSchemeMapper.class); + } + + private OtherSchemeMapper getOtherSchemeMapper() { + return MapperProxyFactory.getProxy(OtherSchemeMapper.class); + } + + private InsuranceSchemeMapper getInsuranceSchemeMapper() { + return MapperProxyFactory.getProxy(InsuranceSchemeMapper.class); + } + + private TaxAgentMapper getTaxAgentMapper() { + return MapperProxyFactory.getProxy(TaxAgentMapper.class); + } + + private ICategoryMapper getICategoryMapper() { + return MapperProxyFactory.getProxy(ICategoryMapper.class); + } + + private SISchemeService getSiSchemeService() { + return ServiceUtil.getService(SISchemeServiceImpl.class, user); + } + + + private TaxAgentService getTaxAgentService() { + return ServiceUtil.getService(TaxAgentServiceImpl.class, user); + } + + private InsuranceSchemeDetailMapper getInsuranceSchemeDetailMapper() { + return MapperProxyFactory.getProxy(InsuranceSchemeDetailMapper.class); + } + + private SIImportService getSIImportService() { + return ServiceUtil.getService(SIImportServiceImpl.class, user); + } + +// private SIArchivesBiz siArchivesBiz = new SIArchivesBiz(); +// private SISchemeBiz siSchemeBiz = new SISchemeBiz(); + + private SalaryEmployeeService getSalaryEmployeeService(User user) { + return (SalaryEmployeeService) ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user); + } + + private SalarySysConfMapper getSalarySysConfMapper() { + return SqlProxyHandle.getProxy(SalarySysConfMapper.class); + } + + private SalarySysConfService getSalarySysConfService(User user) { + return ServiceUtil.getService(SalarySysConfServiceImpl.class, user); + } + + private InsuranceBaseInfoMapper getInsuranceBaseInfoMapper() { + return MapperProxyFactory.getProxy(InsuranceBaseInfoMapper.class); + } + + public TaxAgentManageRangeService getTaxAgentManageRangeService(User user) { + return ServiceUtil.getService(TaxAgentManageRangeServiceImpl.class, user); + } + + public SIArchivesService getSIArchivesService(User user) { + return ServiceUtil.getService(SIArchivesServiceImpl.class,user); + } + + private SIAccountUtilMapper getSIAccountUtilMapper() { + return SqlProxyHandle.getProxy(SIAccountUtilMapper.class); + } + + private EmployMapper getEmployMapper() { + return MapperProxyFactory.getProxy(EmployMapper.class); + } + + public AuthService getAuthService(User user) { + return ServiceUtil.getService(AuthServiceImpl.class, user); + } + + @Override + public Map getForm(Map params) { + Map apidatas = new HashMap<>(16); + + Long id = null; + if (Objects.nonNull(params.get("id"))) { + id =Long.valueOf(Util.null2String(params.get("id"))); + } + WelfareTypeEnum welfareTypeEnum = (WelfareTypeEnum)params.get("welfareTypeEnum"); + InsuranceSchemeFormVO form = getForm(id, welfareTypeEnum); + apidatas.put("form",form); + //记录操作日志 + InsuranceSchemeDTO schemeBatch = form.getSchemeBatch(); + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(schemeBatch.getId())); + loggerContext.setTargetName(schemeBatch.getSchemeName()); + loggerContext.setOperateType(OperateTypeEnum.READ.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "查看福利方案明细")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "查看福利方案明细") + ": " + schemeBatch.getSchemeName()); + SalaryElogConfig.siSchemeLoggerTemplate.write(loggerContext); + return apidatas; + } + + @Override + public Map insertScheme(Map params) { +// return commandExecutor.execute(new SISchemeInsertCmd(params, user)); + Map apidatas = new HashMap(16); + InsuranceSchemeReqParam insuranceSchemeReqParam = (InsuranceSchemeReqParam) params.get("insuranceSchemeReqParam"); +// siSchemeBiz.save(insuranceSchemeReqParam, (long) user.getUID()); + save(insuranceSchemeReqParam, (long) user.getUID()); + return apidatas; + } + + @Override + public String update(Map params) { +// return commandExecutor.execute(new SISchemeUpdateCmd(params, user)); + Map apidatas = new HashMap(16); + InsuranceSchemeReqParam insuranceSchemeReqParam = (InsuranceSchemeReqParam) params.get("insuranceSchemeReqParam"); +// siSchemeBiz.update(insuranceSchemeReqParam, (long) user.getUID()); + return update(insuranceSchemeReqParam, (long) user.getUID()); + } + + @Override + public Map delete(Map params) { +// return commandExecutor.execute(new SISchemeDeleteCmd(params, user)); + Map apidatas = new HashMap(16); + Collection ids = (Collection)params.get("ids"); + if (CollectionUtils.isEmpty(ids)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"参数错误")); + } + //校验带上类型 + int welfareTypeId = (Integer) params.get("welfareTypeId"); + if(WelfareTypeEnum.SOCIAL_SECURITY.getValue() == welfareTypeId){ +// int num = siSchemeBiz.checkBeforeDeleteSocialscheme(params); + int num = checkBeforeDeleteSocialscheme(params); + if (num > 0){ + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"该社保方案已被使用")); + } + } + if(WelfareTypeEnum.ACCUMULATION_FUND.getValue() == welfareTypeId){ +// int accumulationfundNum = siSchemeBiz.checkBeforeDeleteAccumulationfund(params); + int accumulationfundNum = checkBeforeDeleteAccumulationfund(params); + if (accumulationfundNum > 0){ + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"该公积金方案已被使用")); + } + } + if(WelfareTypeEnum.OTHER.getValue() == welfareTypeId){ +// int otherschemeNum = siSchemeBiz.checkBeforeDeleteOtherscheme(params); + int otherschemeNum = checkBeforeDeleteOtherscheme(params); + if (otherschemeNum > 0){ + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"该其他福利方案已被使用")); + } + } + +// int billNum = siSchemeBiz.checkBeforeDeleteBill(params,welfareTypeId); + int billNum = checkBeforeDeleteBill(params,welfareTypeId); + if (billNum > 0){ + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"该福利方案已被核算")); + } +// siSchemeBiz.deleteSocialscheme(params); + deleteSocialscheme(params); + + return apidatas; + } + + @Override + public Map copyScheme(Map params) { +// return commandExecutor.execute(new SISchemeCopyCmd(params, user)); + Map apidatas = new HashMap(16); + Long id = (Long) params.get("id"); + String schemeName = Util.null2String(params.get("schemeName")); +// siSchemeBiz.copy(id,schemeName,(long) user.getUID()); + copy(id,schemeName,(long) user.getUID()); + return apidatas; + } + + @Override + public List queryListByInsuranceIdIsPayment(Long insuranceId, Integer isPayment) { +// return new SISchemeBiz().queryListByInsuranceIdIsPayment(insuranceId, isPayment); + + List insuranceSchemeDetailPOList = getInsuranceSchemeDetailMapper().queryListByInsuranceIdIsPayment(insuranceId, isPayment); + encryptUtil.decryptList(insuranceSchemeDetailPOList, InsuranceSchemeDetailPO.class); + return insuranceSchemeDetailPOList; + } + + @Override + public Map listPage(Map params) { +// return commandExecutor.execute(new SISchemeListCmd(params, user)); + SalaryWeaTable table = new SalaryWeaTable<>(user,SISchemeTableVO.class); + String sqlWhere = buildSqlWhere(params); + table.setSqlwhere(sqlWhere); + + WeaResultMsg result = new WeaResultMsg(false); + result.putAll(table.makeDataResult()); + result.success(); + return result.getResultMap(); + } + + private String buildSqlWhere(Map params) { + String sqlWhere = "where a.id = b.primary_id and b.insurance_id = c.id and a.delete_Type = 0"; + Integer welfareType = (Integer)params.get("welfareType"); + if (Objects.nonNull(welfareType)){ + sqlWhere += " and a.welfare_type ="+welfareType; + } + return sqlWhere; + } + + @Override + public Map getSchemeIdNameMap() { + Map result = new HashMap<>(); + List insuranceSchemePOS = getInsuranceSchemeMapper().listAll(); + if (CollectionUtils.isNotEmpty(insuranceSchemePOS)) { + result = insuranceSchemePOS.stream().collect(Collectors.toMap(InsuranceSchemePO::getId, InsuranceSchemePO::getSchemeName)); + } + return result; + } + + @Override + public PageInfo list(InsuranceSchemeParam queryParam) { + SalaryAssert.notNull(queryParam.getWelfareTypeEnum(), SalaryI18nUtil.getI18nLabel(84026, "参数错误")); + queryParam.setWelfareType(queryParam.getWelfareTypeEnum().getValue()); + if (queryParam.getPaymentTypeEnum() != null) { + queryParam.setPaymentType(queryParam.getPaymentTypeEnum().getValue()); + } + List insuranceSchemePOS = getInsuranceSchemeMapper().list(queryParam);; + TaxAgentQueryParam param = TaxAgentQueryParam.builder().build(); + param.setFilterType(AuthFilterTypeEnum.QUERY_DATA); + Collection taxAgentList = getTaxAgentService().listAuth(param); + List authTaxAgentIds = SalaryEntityUtil.properties(taxAgentList, TaxAgentPO::getId, Collectors.toList()); + insuranceSchemePOS = insuranceSchemePOS.stream().filter(po -> { + String taxAgentIdsStr = po.getTaxAgentIds(); + List taxAgentIds = new ArrayList<>(); + if (StringUtils.isNotBlank(taxAgentIdsStr)) { + taxAgentIds = Arrays.stream(taxAgentIdsStr.split(",")).map(Long::valueOf).collect(Collectors.toList()); + } + return StringUtils.isBlank(po.getSharedType()) || SharedTypeEnum.PUBLIC.getValue().equals(po.getSharedType()) || (SharedTypeEnum.PRIVATE.getValue().equals(po.getSharedType()) && SalaryEntityUtil.judgeIntersection(authTaxAgentIds, taxAgentIds)); + }).collect(Collectors.toList()); + + PageInfo dtoPage = new PageInfo<>(InsuranceSchemeListDTO.class); + dtoPage.setPageNum(queryParam.getCurrent()); + dtoPage.setPageSize(queryParam.getPageSize()); + dtoPage.setTotal(insuranceSchemePOS.size()); + //分页 + insuranceSchemePOS = SalaryPageUtil.subList(queryParam.getCurrent(), queryParam.getPageSize(), insuranceSchemePOS); + List collect = insuranceSchemePOS.stream().map(item -> InsuranceSchemeListDTO.builder().id(item.getId()).paymentType(SalaryI18nUtil.getI18nLabel(buildPaymentTypeEnum(item.getPaymentType()).getLabelId(), buildPaymentTypeEnum(item.getPaymentType()).getDefaultLabel())).schemeName(item.getSchemeName()).paymentArea(item.getPaymentArea()).paymentScope(buildPaymentScope(item.getId())).remarks(item.getRemarks()).build()).collect(Collectors.toList()); + dtoPage.setList(collect); + return dtoPage; + } + + @Override + public List listPageEmployeePOS(InsuranceArchivesListParam param) { + long currentEmployeeId = user.getUID(); + //排序配置 + OrderRuleVO orderRule = getSalarySysConfService(user).orderRule(); + param.setOrderRule(orderRule); + + List list = getSocialSchemeMapper().queryEmployeeList(param); + list = getAuthService(user).auth(list, AuthFilterTypeEnum.QUERY_DATA, InsuranceArchivesEmployeePO.class); + return list; + } + + @Override + public List> buildTableData(List insuranceArchivesEmployeePOS) { +// boolean welBaseDiffSign = siArchivesBiz.isDiffWelBase(); + boolean welBaseDiffSign = getSIArchivesService(user).isDiffWelBase(); + List> records = new ArrayList<>(); + List taxAgentPOS = getTaxAgentMapper().listAll(); + Map longTaxAgentPOMap = SalaryEntityUtil.convert2Map(taxAgentPOS, TaxAgentPO::getId); + List employeeIds = insuranceArchivesEmployeePOS.stream().map(InsuranceArchivesEmployeePO::getEmployeeId).collect(Collectors.toList()); + if (CollectionUtils.isEmpty(employeeIds)) { + return records; + } + List socialList = new ArrayList<>(); + List fundList = new ArrayList<>(); + List otherList = new ArrayList<>(); + + for (int i = 0; i < employeeIds.size(); i += 1000) { + int end = i + 1000; + if (i + 1000 >= employeeIds.size()) { + end = employeeIds.size(); + } + List ids = employeeIds.subList(i, end); + socialList.addAll(encryptUtil.decryptList(getSIArchivesService(user).getSocialByEmployeeIds(ids), InsuranceArchivesSocialSchemePO.class)); + fundList.addAll(encryptUtil.decryptList(getSIArchivesService(user).getFundByEmployeeIds(ids), InsuranceArchivesFundSchemePO.class)); + otherList.addAll(encryptUtil.decryptList(getSIArchivesService(user).getOtherByEmployeeIds(ids), InsuranceArchivesOtherSchemePO.class)); + } + Map socialSchemePOMap = SalaryEntityUtil.convert2Map(socialList, k -> k.getPaymentOrganization() + "-" + k.getEmployeeId()); + Map fundSchemePOMap = SalaryEntityUtil.convert2Map(fundList, k -> k.getPaymentOrganization() + "-" + k.getEmployeeId()); + Map otherSchemePOMap = SalaryEntityUtil.convert2Map(otherList, k -> k.getPaymentOrganization() + "-" + k.getEmployeeId()); + + insuranceArchivesEmployeePOS.forEach(item -> { + InsuranceArchivesSocialSchemePO socialItem = socialSchemePOMap.get(item.getPaymentOrganization() + "-" + item.getEmployeeId()); + InsuranceArchivesFundSchemePO fundItem = fundSchemePOMap.get(item.getPaymentOrganization() + "-" + item.getEmployeeId()); + InsuranceArchivesOtherSchemePO otherItem = otherSchemePOMap.get(item.getPaymentOrganization() + "-" + item.getEmployeeId()); + Map map = new HashMap<>(); + map.put("employeeName", item.getUserName()); + map.put("employeeId", item.getEmployeeId()); + map.put("subcompanyName", item.getSubcompanyName()); + map.put("departmentName", item.getDepartmentName()); + map.put("departmentId", item.getDepartmentId()); + map.put("jobNum", item.getJobNum()); + map.put("idNo", item.getIdNo()); + map.put("paymentOrganizationName", longTaxAgentPOMap.get(item.getPaymentOrganization()) != null ? longTaxAgentPOMap.get(item.getPaymentOrganization()).getName() : ""); + map.put("mobile", item.getTelephone()); + map.put("status", item.getUserStatus() == null ? "" : UserStatusEnum.getDefaultLabelByValue(item.getUserStatus())); + if (socialItem != null) { + map.put("socialName", getSiSchemeService().querySchemeName(socialItem.getSocialSchemeId())); + Map socialJson = JSON.parseObject(socialItem.getSocialPaymentBaseString(), new TypeReference>() { + }); + if (welBaseDiffSign) { + if (socialJson != null) { + //查询该福利方案下开启缴纳的福利项 +// List insuranceIdList = siArchivesBiz.payInsuranceIds(socialItem.getSocialSchemeId(), PaymentScopeEnum.SCOPE_PERSON.getValue()); + List insuranceIdList = getSIArchivesService(user).payInsuranceIds(socialItem.getSocialSchemeId(), PaymentScopeEnum.SCOPE_PERSON.getValue()); + socialJson.forEach((k, v) -> { + if (insuranceIdList.contains(Long.valueOf(k))) { + map.put(k + "per", v); + } + }); + } + Map socialComJson = JSON.parseObject(socialItem.getSocialPaymentComBaseString(), new TypeReference>() { + }); + if (socialComJson != null) { + //查询该福利方案下开启缴纳的福利项 +// List insuranceIdList = siArchivesBiz.payInsuranceIds(socialItem.getSocialSchemeId(),PaymentScopeEnum.SCOPE_COMPANY.getValue()); + List insuranceIdList = getSIArchivesService(user).payInsuranceIds(socialItem.getSocialSchemeId(),PaymentScopeEnum.SCOPE_COMPANY.getValue()); + socialComJson.forEach((k, v) -> { + if (insuranceIdList.contains(Long.valueOf(k))) { + map.put(k + "com", v); + } + }); + } + } else { + if (socialJson != null) { + //查询该福利方案下开启缴纳的福利项 + List insuranceIdList = payInsuranceIds(socialItem.getSocialSchemeId()); + socialJson.forEach((k, v) -> { + if (insuranceIdList.contains(Long.valueOf(k))) { + map.put(k, v); + } + }); + } + } + map.put("socialAccount", socialItem.getSocialAccount()); + map.put("socialStartTime", socialItem.getSocialStartTime()); + map.put("socialEndTime", socialItem.getSocialEndTime()); + } + if (fundItem != null) { + map.put("fundName", getSiSchemeService().querySchemeName(fundItem.getFundSchemeId())); + map.put("fundAccount", fundItem.getFundAccount()); + Map fundJson = JSON.parseObject(fundItem.getFundPaymentBaseString(), new TypeReference>() { + }); + if (welBaseDiffSign) { + if (fundJson != null) { + //查询该福利方案下开启缴纳的福利项 +// List insuranceIdList = siArchivesBiz.payInsuranceIds(fundItem.getFundSchemeId(),PaymentScopeEnum.SCOPE_PERSON.getValue()); + List insuranceIdList = getSIArchivesService(user).payInsuranceIds(fundItem.getFundSchemeId(),PaymentScopeEnum.SCOPE_PERSON.getValue()); + fundJson.forEach((k, v) -> { + if (insuranceIdList.contains(Long.valueOf(k))) { + map.put(k + "per", v); + } + }); + } + Map fundComJson = JSON.parseObject(fundItem.getFundPaymentComBaseString(), new TypeReference>() { + }); + if (fundComJson != null) { + //查询该福利方案下开启缴纳的福利项 +// List insuranceIdList = siArchivesBiz.payInsuranceIds(fundItem.getFundSchemeId(),PaymentScopeEnum.SCOPE_COMPANY.getValue()); + List insuranceIdList = getSIArchivesService(user).payInsuranceIds(fundItem.getFundSchemeId(),PaymentScopeEnum.SCOPE_COMPANY.getValue()); + fundComJson.forEach((k, v) -> { + if (insuranceIdList.contains(Long.valueOf(k))) { + map.put(k + "com", v); + } + }); + } + } else { + if (fundJson != null) { + //查询该福利方案下开启缴纳的福利项 + List insuranceIdList = payInsuranceIds(fundItem.getFundSchemeId()); + fundJson.forEach((k, v) -> { + if (insuranceIdList.contains(Long.valueOf(k))) { + map.put(k, v); + } + }); + } + } + map.put("supplementFundAccount", fundItem.getSupplementFundAccount()); + map.put("fundStartTime", fundItem.getFundStartTime()); + map.put("fundEndTime", fundItem.getFundEndTime()); + + } + if (otherItem != null) { + map.put("otherName", getSiSchemeService().querySchemeName(otherItem.getOtherSchemeId())); + Map otherJson = JSON.parseObject(otherItem.getOtherPaymentBaseString(), new TypeReference>() { + }); + if (welBaseDiffSign) { + if (otherJson != null) { + //查询该福利方案下开启缴纳的福利项 +// List insuranceIdList = siArchivesBiz.payInsuranceIds(otherItem.getOtherSchemeId(),PaymentScopeEnum.SCOPE_PERSON.getValue()); + List insuranceIdList = getSIArchivesService(user).payInsuranceIds(otherItem.getOtherSchemeId(),PaymentScopeEnum.SCOPE_PERSON.getValue()); + otherJson.forEach((k, v) -> { + if (insuranceIdList.contains(Long.valueOf(k))) { + map.put(k + "per", v); + } + }); + } + Map otherComJson = JSON.parseObject(otherItem.getOtherPaymentComBaseString(), new TypeReference>() { + }); + if (otherComJson != null) { + //查询该福利方案下开启缴纳的福利项 +// List insuranceIdList = siArchivesBiz.payInsuranceIds(otherItem.getOtherSchemeId(),PaymentScopeEnum.SCOPE_COMPANY.getValue()); + List insuranceIdList = getSIArchivesService(user).payInsuranceIds(otherItem.getOtherSchemeId(),PaymentScopeEnum.SCOPE_COMPANY.getValue()); + otherComJson.forEach((k, v) -> { + if (insuranceIdList.contains(Long.valueOf(k))) { + map.put(k + "com", v); + } + }); + } + } else { + if (otherJson != null) { + //查询该福利方案下开启缴纳的福利项 + List insuranceIdList = payInsuranceIds(otherItem.getOtherSchemeId()); + otherJson.forEach((k, v) -> { + if (insuranceIdList.contains(Long.valueOf(k))) { + map.put(k, v); + } + }); + } + } + map.put("otherStartTime", otherItem.getOtherStartTime()); + map.put("otherEndTime", otherItem.getOtherEndTime()); + } + records.add(map); + }); + return records; + } + + public List payInsuranceIds(Long socialSchemeId) { + //查询该福利方案下开启缴纳的福利项 + List detailPOS = getInsuranceSchemeDetailMapper().queryListBySchemeId(socialSchemeId); + List insuranceIdList = new ArrayList<>(); + if (detailPOS != null && detailPOS.size() > 0) { + //开启缴纳的 + insuranceIdList = detailPOS.stream().filter(f -> f.getIsPayment().equals(IsPaymentEnum.YES.getValue())).map(InsuranceSchemeDetailPO::getInsuranceId).collect(Collectors.toList()); + } + return insuranceIdList; + } + + @Override + public XSSFWorkbook export(InsuranceArchivesListParam param) { + InsuranceArchivesListParam request = InsuranceArchivesListParam.builder().build(); + if (param.getHireDate() != null && param.getHireDate().length == 2) { + param.setHiredateStart(param.getHireDate()[0]); + param.setHiredateEnd(param.getHireDate()[1]); + } + if (param.getDimissionDate() != null && param.getDimissionDate().length == 2) { + param.setDimissionDateStart(param.getDimissionDate()[0]); + param.setDimissionDateEnd(param.getDimissionDate()[1]); + } + if (Objects.equals("fromQuickSearch", param.getDataSource())) { + request.setStatuses(param.getStatuses()); + request.setKeyword(param.getUserName()); + } else { + request = param; + } + request.setPageSize(null); + request.setStartNum(null); + List insuranceArchivesEmployeePOS = listPageEmployeePOS(request); + if (insuranceArchivesEmployeePOS == null) { + insuranceArchivesEmployeePOS = new ArrayList<>(); + } + SalaryI18nUtil.i18nList(insuranceArchivesEmployeePOS); + List> records = buildTableData(insuranceArchivesEmployeePOS); + List columns = buildWeaTableColumns(insuranceArchivesEmployeePOS, (long) user.getUID()); + + //工作簿list + + + String sheetName; + //表头 + if (param.getRunStatuses().size() > 0) { + if (param.getRunStatuses().contains(EmployeeStatusEnum.STAY_ADD.getValue()) && param.getRunStatuses().size() == 1) { + sheetName = SalaryI18nUtil.getI18nLabel(85368, "社保福利档案导出" + "-" + EmployeeStatusEnum.STAY_ADD.getDefaultLabel()); + } else if (param.getRunStatuses().contains(EmployeeStatusEnum.PAYING.getValue()) && param.getRunStatuses().contains(EmployeeStatusEnum.STAY_DEL.getValue()) && param.getRunStatuses().size() == 2) { + sheetName = SalaryI18nUtil.getI18nLabel(85368, "社保福利档案导出" + "-" + "在缴员工"); + } else if (param.getRunStatuses().contains(EmployeeStatusEnum.STAY_DEL.getValue()) && param.getRunStatuses().size() == 1) { + sheetName = SalaryI18nUtil.getI18nLabel(85368, "社保福利档案导出" + "-" + EmployeeStatusEnum.STAY_DEL.getDefaultLabel()); + } else if (param.getRunStatuses().contains(EmployeeStatusEnum.STOP_PAYMENT_FROM_ADD.getValue()) && param.getRunStatuses().contains(EmployeeStatusEnum.STOP_PAYMENT_FROM_DEL.getValue()) && param.getRunStatuses().size() == 2) { + sheetName = SalaryI18nUtil.getI18nLabel(85368, "社保福利档案导出" + "-" + "停缴员工"); + } else { + sheetName = SalaryI18nUtil.getI18nLabel(85368, "社保福利档案导出"); + } + } else { + sheetName = SalaryI18nUtil.getI18nLabel(85368, "社保福利档案导出"); + } + + //工作簿数据 + List> rows = new LinkedList<>(); + List collect = columns.stream().map(WeaTableColumn::getText).collect(Collectors.toList()); + rows.add(collect); + for (Map recordData : records) { + List row = new LinkedList<>(); + for (WeaTableColumn column : columns) { + try { + Object o = recordData.get(column.getColumn()); + if (column.getText().contains("申报基数") && StringUtils.isNotBlank(o.toString())) { + row.add(new BigDecimal(o.toString())); + } else { + row.add(o.toString()); + } + } catch (Exception e) { + row.add(""); + } + } + rows.add(row); + } + //记录操作日志 + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setOperateType(OperateTypeEnum.EXCEL_EXPORT.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "福利档案导出")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "福利档案导出")); + SalaryElogConfig.siArchivesLoggerTemplate.write(loggerContext); + //获取excel + return ExcelUtilPlus.genWorkbookV2(rows, sheetName); + } + + + public PaymentTypeEnum buildPaymentTypeEnum(Integer value) { + return SalaryEnumUtil.enumMatchByValue(value, PaymentTypeEnum.values(), PaymentTypeEnum.class); + } + + + /** + * 组装社保福利方案列表页【缴纳范围】 + * 1、到福利方案明细表查询该方案id下面有哪些福利 + * 2、去重(福利是分个人和公司的,明细表中查询出来的福利id会重复) + * 3、根据查询出来的福利id,去福利表里面查询福利的名称 + * 4、组装,以“、”分割 + * + * @param id 福利方案主表id + * @return result + */ + public String buildPaymentScope(Long id) { + List collect = queryInsuranceSchemeDetailList(id).stream().map(InsuranceSchemeDetailPO::getInsuranceId).distinct().collect(Collectors.toList()).stream().map(this::queryInsuranceName).collect(Collectors.toList()); + return StringUtils.join(collect, "、"); + } + + public Collection queryInsuranceSchemeDetailList(Long id) { + List insuranceSchemeDetailPOS = getInsuranceSchemeDetailMapper().queryInsuranceSchemeDetailList(id, IsPaymentEnum.YES.getValue()); + return encryptUtil.decryptList(insuranceSchemeDetailPOS, InsuranceSchemeDetailPO.class); + } + + public String queryInsuranceName(Long id) { + ICategoryPO insuranceCategoryPO = getICategoryMapper().getById(id); + return insuranceCategoryPO == null ? "" : Objects.isNull(insuranceCategoryPO.getInsuranceName()) ? "" : insuranceCategoryPO.getInsuranceName(); + } + + + @Override + public String querySchemeName(Long schemeId) { + if (schemeId == null) { + return ""; + } + InsuranceSchemePO insuranceSchemePO = getInsuranceSchemeMapper().getById(schemeId); + if (insuranceSchemePO == null) { + return ""; + } else { + return insuranceSchemePO.getSchemeName(); + } + } + + + @Override + public List buildWeaTableColumns(List insuranceArchivesEmployeePOS, Long employeeId) { + Map> titleMap = buildColumnTitle(insuranceArchivesEmployeePOS, employeeId); + List list = new ArrayList<>(); + WeaTableColumn nameColumn = new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(85429, "姓名"), "employeeName"); + nameColumn.setFixed("left"); + list.add(nameColumn); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(93910, "个税扣缴义务人"), "paymentOrganizationName")); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(0, "分部"), "subcompanyName")); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(86185, "部门"), "departmentName")); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(86186, "手机号"), "mobile")); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(86187, "员工状态"), "status")); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(1933, "工号"), "jobNum")); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(1933, "证件号码"), "idNo")); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(91323, "社保方案名称"), "socialName")); + titleMap.get(WelfareTypeEnum.SOCIAL_SECURITY.getValue()).forEach((k, v) -> list.add(new WeaTableColumn("150px", v, k))); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(91324, "社保账号"), "socialAccount")); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(91319, "社保起始缴纳月"), "socialStartTime")); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(91320, "社保最后缴纳月"), "socialEndTime")); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(91485, "公积金方案名称"), "fundName")); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(91486, "公积金账号"), "fundAccount")); + titleMap.get(WelfareTypeEnum.ACCUMULATION_FUND.getValue()).forEach((k, v) -> list.add(new WeaTableColumn("150px", v, k))); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(91487, "补充公积金账号"), "supplementFundAccount")); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(91483, "公积金起始缴纳月"), "fundStartTime")); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(91484, "公积金最后缴纳月"), "fundEndTime")); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(91496, "其他福利方案名称"), "otherName")); + titleMap.get(WelfareTypeEnum.OTHER.getValue()).forEach((k, v) -> list.add(new WeaTableColumn("150px", v, k))); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(91490, "其他福利起始缴纳月"), "otherStartTime")); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(91494, "其他福利最后缴纳月"), "otherEndTime")); + return list; + } + + + public Map> buildColumnTitle(List insuranceArchivesEmployeePOS, Long employeeId) { +// boolean welBaseDiffSign = siArchivesBiz.isDiffWelBase(); + boolean welBaseDiffSign = getSIArchivesService(user).isDiffWelBase(); + + Map> result = new HashMap<>(); + Set socialSet = new HashSet<>(); + Set fundSet = new HashSet<>(); + Set otherSet = new HashSet<>(); + + Set socialComSet = new HashSet<>(); + Set fundComSet = new HashSet<>(); + Set otherComSet = new HashSet<>(); + + insuranceArchivesEmployeePOS.forEach(item -> { + List socialByEmployeeId = getSIArchivesService(user).getSocialByEmployeeIds(new ArrayList() {{ + add(item.getEmployeeId()); + }}); + // 过滤义务人 + socialByEmployeeId = socialByEmployeeId.stream().filter(s -> s.getPaymentOrganization().equals(item.getPaymentOrganization())).collect(Collectors.toList()); + encryptUtil.decryptList(socialByEmployeeId, InsuranceArchivesSocialSchemePO.class); + InsuranceArchivesSocialSchemePO socialItem = null; + if (socialByEmployeeId.size() > 0) { + socialItem = socialByEmployeeId.get(0); + } + InsuranceArchivesFundSchemePO fundItem = null; + + List fundByEmployeeId = getSIArchivesService(user).getFundByEmployeeIds(new ArrayList() {{ + add(item.getEmployeeId()); + }}); + // 过滤义务人 + fundByEmployeeId = fundByEmployeeId.stream().filter(f -> f.getPaymentOrganization().equals(item.getPaymentOrganization())).collect(Collectors.toList()); + encryptUtil.decryptList(fundByEmployeeId, InsuranceArchivesFundSchemePO.class); + + if (fundByEmployeeId.size() > 0) { + fundItem = fundByEmployeeId.get(0); + } + InsuranceArchivesOtherSchemePO otherItem = null; + + List otherByEmployeeId = getSIArchivesService(user).getOtherByEmployeeIds(new ArrayList() {{ + add(item.getEmployeeId()); + }}); + otherByEmployeeId = otherByEmployeeId.stream().filter(o -> o.getPaymentOrganization().equals(item.getPaymentOrganization())).collect(Collectors.toList()); + encryptUtil.decryptList(otherByEmployeeId, InsuranceArchivesOtherSchemePO.class); + if (otherByEmployeeId.size() > 0) { + otherItem = otherByEmployeeId.get(0); + } + + if (socialItem != null) { + Map socialJson = JSON.parseObject(socialItem.getSocialPaymentBaseString(), new TypeReference>() { + }); + if (socialJson != null) { + socialJson.forEach((k, v) -> socialSet.add(k)); + } + //如果需要区分个人和公司福利基数 + if (welBaseDiffSign) { + Map socialComJson = JSON.parseObject(socialItem.getSocialPaymentComBaseString(), new TypeReference>() { + }); + if (socialComJson != null) { + socialComJson.forEach((k, v) -> socialComSet.add(k)); + } + } + } + if (fundItem != null) { + Map fundJson = JSON.parseObject(fundItem.getFundPaymentBaseString(), new TypeReference>() { + }); + if (fundJson != null) { + fundJson.forEach((k, v) -> fundSet.add(k)); + } + //如果需要区分个人和公司福利基数 + if (welBaseDiffSign) { + Map fundComJson = JSON.parseObject(fundItem.getFundPaymentComBaseString(), new TypeReference>() { + }); + if (fundComJson != null) { + fundComJson.forEach((k, v) -> fundComSet.add(k)); + } + } + } + if (otherItem != null) { + Map otherJson = JSON.parseObject(otherItem.getOtherPaymentBaseString(), new TypeReference>() { + }); + if (otherJson != null) { + otherJson.forEach((k, v) -> otherSet.add(k)); + } + //如果需要区分个人和公司福利基数 + if (welBaseDiffSign) { + Map otherComJson = JSON.parseObject(otherItem.getOtherPaymentComBaseString(), new TypeReference>() { + }); + if (otherComJson != null) { + otherComJson.forEach((k, v) -> otherComSet.add(k)); + } + } + } + }); + Map socialMap = new HashMap<>(); + Map socialComMap = new HashMap<>(); + Map socialCollect = new HashMap<>(); + Map customSocial = getICategoryMapper().listByWelfareType(WelfareTypeEnum.SOCIAL_SECURITY.getValue(), null).stream().collect(Collectors.toMap(ICategoryPO::getId, Function.identity())); + + Map sysSocial = getICategoryMapper().listByWelfareType(WelfareTypeEnum.SOCIAL_SECURITY.getValue(), DataTypeEnum.SYSTEM.getValue()).stream().collect(Collectors.toMap(ICategoryPO::getId, Function.identity())); + socialCollect.putAll(customSocial); + socialCollect.putAll(sysSocial); + if (welBaseDiffSign) { + socialSet.forEach(item -> { + if (socialCollect.containsKey(Long.valueOf(item))) { + socialMap.put(item + "per", socialCollect.get(Long.valueOf(item)).getInsuranceName() + SalaryI18nUtil.getI18nLabel(0, "申报基数") + SalaryI18nUtil.getI18nLabel(0,"个人")); + } + }); + socialComSet.forEach(item -> { + if (socialCollect.containsKey(Long.valueOf(item))) { + socialComMap.put(item + "com", socialCollect.get(Long.valueOf(item)).getInsuranceName() + SalaryI18nUtil.getI18nLabel(0, "申报基数") + SalaryI18nUtil.getI18nLabel(0,"单位")); + } + }); + } else { + socialSet.forEach(item -> { + if (socialCollect.containsKey(Long.valueOf(item))) { + socialMap.put(item, socialCollect.get(Long.valueOf(item)).getInsuranceName() + SalaryI18nUtil.getI18nLabel(0, "申报基数")); + } + }); + } + Map fundMap = new HashMap<>(); + Map fundComMap = new HashMap<>(); + Map fundCollect = new HashMap<>(); + Map customFund = getICategoryMapper().listByWelfareType(WelfareTypeEnum.ACCUMULATION_FUND.getValue(), null).stream().collect(Collectors.toMap(ICategoryPO::getId, Function.identity())); + Map sysFund = getICategoryMapper().listByWelfareType(WelfareTypeEnum.ACCUMULATION_FUND.getValue(), DataTypeEnum.SYSTEM.getValue()).stream().collect(Collectors.toMap(ICategoryPO::getId, Function.identity())); + fundCollect.putAll(customFund); + fundCollect.putAll(sysFund); + if (welBaseDiffSign) { + fundSet.forEach(item -> { + if (fundCollect.containsKey(Long.valueOf(item))) { + fundMap.put(item + "per", fundCollect.get(Long.valueOf(item)).getInsuranceName() + SalaryI18nUtil.getI18nLabel(0, "申报基数") + SalaryI18nUtil.getI18nLabel(0,"个人")); + } + }); + fundComSet.forEach(item -> { + if (fundCollect.containsKey(Long.valueOf(item))) { + fundComMap.put(item + "com", fundCollect.get(Long.valueOf(item)).getInsuranceName() + SalaryI18nUtil.getI18nLabel(0, "申报基数") + SalaryI18nUtil.getI18nLabel(0,"单位")); + } + }); + } else { + fundSet.forEach(item -> { + if (fundCollect.containsKey(Long.valueOf(item))) { + fundMap.put(item, fundCollect.get(Long.valueOf(item)).getInsuranceName() + SalaryI18nUtil.getI18nLabel(0, "申报基数")); + } + }); + } + Map otherMap = new HashMap<>(); + Map otherComMap = new HashMap<>(); + Map otherCollect = new HashMap<>(); + Map customOther = getICategoryMapper().listByWelfareType(WelfareTypeEnum.OTHER.getValue(), null).stream().collect(Collectors.toMap(ICategoryPO::getId, Function.identity())); + Map sysOther = getICategoryMapper().listByWelfareType(WelfareTypeEnum.OTHER.getValue(), DataTypeEnum.SYSTEM.getValue()).stream().collect(Collectors.toMap(ICategoryPO::getId, Function.identity())); + otherCollect.putAll(customOther); + otherCollect.putAll(sysOther); + if (welBaseDiffSign) { + otherSet.forEach(item -> { + if (otherCollect.containsKey(Long.valueOf(item))) { + otherMap.put(item + "per", otherCollect.get(Long.valueOf(item)).getInsuranceName() + SalaryI18nUtil.getI18nLabel(0, "申报基数") + SalaryI18nUtil.getI18nLabel(0,"个人")); + } + }); + otherComSet.forEach(item -> { + if (otherCollect.containsKey(Long.valueOf(item))) { + otherComMap.put(item + "com", otherCollect.get(Long.valueOf(item)).getInsuranceName() + SalaryI18nUtil.getI18nLabel(0, "申报基数") + SalaryI18nUtil.getI18nLabel(0,"单位")); + } + }); + } else { + otherSet.forEach(item -> { + if (otherCollect.containsKey(Long.valueOf(item))) { + otherMap.put(item, otherCollect.get(Long.valueOf(item)).getInsuranceName() + SalaryI18nUtil.getI18nLabel(0, "申报基数")); + } + }); + } + + // map根据key排序 + LinkedHashMap socialMapWithAscKey = socialMap.entrySet().stream() + .sorted(Map.Entry.comparingByKey()) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (oldValue, newValue) -> oldValue, + LinkedHashMap::new)); + LinkedHashMap fundMapWithAscKey = fundMap.entrySet().stream() + .sorted(Map.Entry.comparingByKey()) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (oldValue, newValue) -> oldValue, + LinkedHashMap::new)); + LinkedHashMap otherMapWithAscKey = otherMap.entrySet().stream() + .sorted(Map.Entry.comparingByKey()) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (oldValue, newValue) -> oldValue, + LinkedHashMap::new)); + if (welBaseDiffSign) { + LinkedHashMap socialComMapWithAscKey = socialComMap.entrySet().stream() + .sorted(Map.Entry.comparingByKey()) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (oldValue, newValue) -> oldValue, + LinkedHashMap::new)); + LinkedHashMap fundComMapWithAscKey = fundComMap.entrySet().stream() + .sorted(Map.Entry.comparingByKey()) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (oldValue, newValue) -> oldValue, + LinkedHashMap::new)); + LinkedHashMap otherComMapWithAscKey = otherComMap.entrySet().stream() + .sorted(Map.Entry.comparingByKey()) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (oldValue, newValue) -> oldValue, + LinkedHashMap::new)); + socialMapWithAscKey.putAll(socialComMapWithAscKey); + fundMapWithAscKey.putAll(fundComMapWithAscKey); + otherMapWithAscKey.putAll(otherComMapWithAscKey); + } + + result.put(WelfareTypeEnum.SOCIAL_SECURITY.getValue(), socialMapWithAscKey); + result.put(WelfareTypeEnum.ACCUMULATION_FUND.getValue(), fundMapWithAscKey); + result.put(WelfareTypeEnum.OTHER.getValue(), otherMapWithAscKey); + return result; + } + + /** + * 导入的数据插入到数据库中 + */ + @Override + public Map preview(SIArchiveImportParam param) { + ValidUtil.doValidator(param); + InputStream fileInputStream = null; + try { + fileInputStream = ImageFileManager.getInputStreamById(Integer.parseInt(param.getImageId())); + Sheet sheet = ExcelSupport.parseFile(fileInputStream, 0, EXCEL_TYPE_XLSX); + Map apidatas = new HashMap(); + apidatas.put("headers", ExcelSupport.getSheetHeader(sheet, 0)); + apidatas.put("list", ExcelParseHelper.parse2List(sheet, 1)); + return apidatas; + } finally { + IOUtils.closeQuietly(fileInputStream); + } + } + + /** + * 导入的数据插入到数据库中 + */ + @Override + public Map batchImportEbatch(SIArchiveImportParam param) { + ValidUtil.doValidator(param); + param.setProcess(false); + + if (StringUtils.isBlank(param.getRunStatus())) { + throw new SalaryRunTimeException("福利档案执行状态未在导入条件设置中添加!"); + } +// List excelSheets = message.getBatchFile().getExcelSheets(); + // 租户key +// String tenantKey = message.getTenantKey().toLowerCase();EditSIArchiveAction + //操作员id + Long creator = (long) user.getUID(); + //获取所有福利类型的id-name结合 + Map schemeNameIdMap = schemeNameIdMap(); + Map welfareMap = welfareMap(); + //分权 + Boolean openDevolution = getTaxAgentService().isOpenDevolution(); + // 获取所有个税扣缴义务人的名称和id的map + TaxAgentQueryParam build = TaxAgentQueryParam.builder().build(); + build.setFilterType(AuthFilterTypeEnum.ADMIN_DATA); + Map paymentNameIdMap = getTaxAgentService().listAuth(build).stream().collect(Collectors.toMap(TaxAgentPO::getName, TaxAgentPO::getId));; + + //获取所以个税扣缴义务人树型 + List taxAgentManageRangeEmployeeTree = getTaxAgentService().listTaxAgentAndEmployeeTree(); + + // 获取所有人员信息 + List employeeByIds = getSalaryEmployeeService(user).listEmployee(); + int total = 0; + + int index = 0; + int successCount = 0; + int errorCount = 0; + + // 待导入数据 + List insuranceArchivesAccountPOS = new ArrayList<>(); + + // 待导入数据 + InputStream fileInputStream = null; + try { + fileInputStream = ImageFileManager.getInputStreamById(Integer.parseInt(param.getImageId())); + Sheet sheet = ExcelSupport.parseFile(fileInputStream, 0, EXCEL_TYPE_XLSX); + // 表头 + List headers = ExcelSupport.getSheetHeader(sheet, 0); + // 错误sheet数据 + List> errorData = new LinkedList<>(); + // 错误提示 + List> excelComments = new LinkedList<>(); + + // 处理数值 + List> data = ExcelParseHelper.parse2Map(sheet, 1); + total = data.size(); + + //当前sheel的单行记录 + Map map; + for (int i = 0; i < data.size(); i++) { + index += 1; + map = data.get(i); + boolean isError; + List> singleAccount = new ArrayList<>(); + for (int j = 0; j < headers.size(); j++) { + //组装单条数据基础数据 + String key = headers.get(j); + if (key == null) { + continue; + } + Map cellData = new HashMap<>(); + cellData.put(key.toString(), Optional.ofNullable(map.get(key.toString())).orElse("").toString()); + cellData.put("index", j); + singleAccount.add(cellData); + } + + isError = singleAccountCheck(singleAccount, welfareMap, insuranceArchivesAccountPOS, employeeByIds, excelComments, errorCount + 1, schemeNameIdMap, paymentNameIdMap, creator, i + 2, taxAgentManageRangeEmployeeTree, param); + if (isError) { + errorCount += 1; + // 添加错误数据 + errorData.add(map); + } else { + successCount += 1; + } +// salaryBatchService.sendImportRate(message.getBizId(), total, index); + } + + // 如果sheet包含错误数据 +// if (CollectionUtils.isNotEmpty(errorData)) { +// salaryBatchService.createErrorExcelSheet(headers, errorData, excelSheet.getName(), excelComments, errorExcelSheets); +// } + + // 数据入库处理 + handleImportData(insuranceArchivesAccountPOS, param); + + // 发送导入回调信息 +// salaryBatchService.sendImportCallBackInfo(message, successCount, errorCount, errorExcelSheets); + + Map apidatas = new HashMap(); + apidatas.put("successCount", successCount); + apidatas.put("errorCount", errorCount); + apidatas.put("errorData", excelComments); + return apidatas; + } finally { + IOUtils.closeQuietly(fileInputStream); + } + } + + + public Map schemeNameIdMap() { + Map schemeMap = new HashMap<>(); + List schemeList = getInsuranceSchemeMapper().listAll(); + if (CollectionUtils.isNotEmpty(schemeList)) { + schemeMap = schemeList.stream().collect(Collectors.toMap(InsuranceSchemePO::getSchemeName, InsuranceSchemePO::getId)); + } + return schemeMap; + } + + public Map welfareMap() { + return getICategoryMapper().listAll().stream().collect(Collectors.toMap(ICategoryPO::getId, ICategoryPO::getInsuranceName)); + } + + private String userStateExchange(String userState) { + UserStatusEnum[] values = UserStatusEnum.values(); + for (UserStatusEnum value : values) { + if (value.getValue().equals(Integer.valueOf(userState))) { + return value.getDefaultLabel() + ""; + } + } + return userState; + } + + public boolean singleAccountCheck(List> singleAccount, Map welfareMap, + List insuranceArchivesAccountPOS, List employeeByIds, + List> excelComments, int i, Map schemeNameIdMap, + Map paymentNameIdMap, Long creator, int index, + List taxAgentManageRangeEmployeeTree, SIArchiveImportParam param) { + boolean isError = false; + String runStatus = param.getRunStatus(); + +// String userName = (String) singleAccount.get(0).get(SalaryI18nUtil.getI18nLabel(85429, "姓名")); +// String deparmentName = (String) singleAccount.get(1).get(SalaryI18nUtil.getI18nLabel(86185, "部门")); +// String mobile = (String) singleAccount.get(2).get(SalaryI18nUtil.getI18nLabel(86186, "手机号")); +// String userStatus = (String) singleAccount.get(3).get(SalaryI18nUtil.getI18nLabel(86187, "员工状态")); +// String workcode = (String) singleAccount.get(4).get(SalaryI18nUtil.getI18nLabel(86317, "工号")); + + Map userNameMap = findElement(singleAccount, SalaryI18nUtil.getI18nLabel(85429, "姓名")); + Map deparmentNameMap = findElement(singleAccount, SalaryI18nUtil.getI18nLabel(86185, "部门")); + Map mobileMap = findElement(singleAccount, SalaryI18nUtil.getI18nLabel(86186, "手机号")); + Map userStatusMap = findElement(singleAccount, SalaryI18nUtil.getI18nLabel(86187, "员工状态")); + Map workcodeMap = findElement(singleAccount, SalaryI18nUtil.getI18nLabel(86317, "工号")); + Map idNoMap = findElement(singleAccount, SalaryI18nUtil.getI18nLabel(86317, "证件号码")); + Map employeeIdMap = findElement(singleAccount, SalaryI18nUtil.getI18nLabel(86187, "员工id")); + + + String userName = (String) userNameMap.get(SalaryI18nUtil.getI18nLabel(85429, "姓名")); + String deparmentName = (String) deparmentNameMap.get(SalaryI18nUtil.getI18nLabel(86185, "部门")); + String mobile = (String) mobileMap.get(SalaryI18nUtil.getI18nLabel(86186, "手机号")); + String userStatus = (String) userStatusMap.get(SalaryI18nUtil.getI18nLabel(86187, "员工状态")); + String workcode = (String) workcodeMap.get(SalaryI18nUtil.getI18nLabel(86317, "工号")); + String idNo = (String) idNoMap.get(SalaryI18nUtil.getI18nLabel(86317, "证件号码")); + String toAddEmployeeId; + if (employeeIdMap.isEmpty()) { + toAddEmployeeId = null; + } else { + toAddEmployeeId = employeeIdMap.get(SalaryI18nUtil.getI18nLabel(86187, "员工id")).toString(); + } + + Long addEmployeeId = StringUtils.isNotBlank(toAddEmployeeId) ? Long.valueOf(toAddEmployeeId) : null; + + //查询对于人员信息导入筛选的全局配置 + SalarySysConfPO salarySysConfPO = getSalarySysConfMapper().getOneByCode("matchEmployeeMode"); + String confValue = (salarySysConfPO != null && salarySysConfPO.getConfValue() != null && !"".equals(salarySysConfPO.getConfValue())) ? salarySysConfPO.getConfValue() : "0"; + + String rowIndex = "第" + index + "行"; + List employees = new ArrayList<>(); + //当新增数据中包含员工id信息时,直接根据员工id获取员工信息 + if (addEmployeeId == null) { + //仅在全局人员筛选配置为“0”时,才对用户名、部门名称、手机号有要求 + if (StringUtils.isBlank(userName) && StringUtils.isBlank(deparmentName) && StringUtils.isBlank(mobile) && "0".equals(confValue)) { + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowIndex + " 用户名、部门名称、手机号" + SalaryI18nUtil.getI18nLabel(100303, "不能同时为空")); + excelComments.add(errorMessageMap); + isError = true; + } + //筛选导入人员信息可以在人力资源池中匹配到的人员信息 + employees = getSalaryEmployeeService(user).matchImportEmployee(confValue,employeeByIds, userName, deparmentName, mobile, workcode,idNo, null); + } else { + employees = employeeByIds.stream().filter(f -> f.getEmployeeId().equals(addEmployeeId)).collect(Collectors.toList()); + } + + + if (CollectionUtils.isEmpty(employees)) { + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowIndex + "员工信息不存在"); + excelComments.add(errorMessageMap); + isError = true; + return isError; + } else { + //含在职和离职,选在职数据 + if (employees.size() > 1) { + employees = employees.stream() + .filter(e -> UserStatusEnum.getNormalStatus().contains(e.getStatus())) + .collect(Collectors.toList()); + if (employees.size() != 1) { + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowIndex + SalaryI18nUtil.getI18nLabel(100304, "员工信息不存在或者存在多个员工")); + excelComments.add(errorMessageMap); + isError = true; + return isError; + } + } + } + + Long employeeId = employees.get(0).getEmployeeId(); + InsuranceArchivesAccountPO insuranceArchivesAccountPO = new InsuranceArchivesAccountPO(); + InsuranceArchivesSocialSchemePO insuranceArchivesSocialSchemePO = null; + InsuranceArchivesFundSchemePO insuranceArchivesFundSchemePO = null; + InsuranceArchivesOtherSchemePO insuranceArchivesOtherSchemePO = null; + + Map socialMap = findElement(singleAccount, SalaryI18nUtil.getI18nLabel(91323, "社保方案名称")); + Map paymentMap = findElement(singleAccount, SalaryI18nUtil.getI18nLabel(86184, "个税扣缴义务人")); + Map fundMap = findElement(singleAccount, SalaryI18nUtil.getI18nLabel(91485, "公积金方案名称")); + Map otherMap = findElement(singleAccount, SalaryI18nUtil.getI18nLabel(91496, "其他福利方案名称")); + Map socialStartTimeMap = findElement(singleAccount, SalaryI18nUtil.getI18nLabel(91319, "社保起始缴纳月")); + Map socialEndTimeMap = findElement(singleAccount, SalaryI18nUtil.getI18nLabel(91320, "社保最后缴纳月")); + Map fundStartTimeMap = findElement(singleAccount, SalaryI18nUtil.getI18nLabel(91483, "公积金起始缴纳月")); + Map fundEndTimeMap = findElement(singleAccount, SalaryI18nUtil.getI18nLabel(91484, "公积金最后缴纳月")); + Map otherStartTimeMap = findElement(singleAccount, SalaryI18nUtil.getI18nLabel(91490, "其他福利起始缴纳月")); + Map otherEndTimeMap = findElement(singleAccount, SalaryI18nUtil.getI18nLabel(91494, "其他福利最后缴纳月")); + if (StringUtils.isBlank((String) socialMap.get(SalaryI18nUtil.getI18nLabel(91323, "社保方案名称"))) && StringUtils.isBlank((String) fundMap.get(SalaryI18nUtil.getI18nLabel(91485, "公积金方案名称"))) && StringUtils.isBlank((String) otherMap.get(SalaryI18nUtil.getI18nLabel(91496, "其他福利方案名称")))) { + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowIndex + SalaryI18nUtil.getI18nLabel(100312, "社保,公积金,其他福利方案名称不可同时为空")); + excelComments.add(errorMessageMap); + isError = true; + } + + //根据导入接口附带的runStatus来区分待增员导入和正在缴纳导入 + if (StringUtils.isNotBlank(runStatus) && runStatus.equals(EmployeeStatusEnum.PAYING.getValue())) { + if (StringUtils.isBlank((String) socialStartTimeMap.get(SalaryI18nUtil.getI18nLabel(91319, "社保起始缴纳月"))) + && StringUtils.isBlank((String) fundStartTimeMap.get(SalaryI18nUtil.getI18nLabel(91483, "公积金起始缴纳月"))) + && StringUtils.isBlank((String) otherStartTimeMap.get(SalaryI18nUtil.getI18nLabel(91490, "其他福利起始缴纳月"))) + ) { + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowIndex + SalaryI18nUtil.getI18nLabel(100312, "社保,公积金,其他福利方案起始缴纳月不可同时为空")); + excelComments.add(errorMessageMap); + isError = true; + } + } + //社保缴纳组织=个税扣缴义务人 + String paymentOrg = (String) paymentMap.get("个税扣缴义务人"); + if (StringUtils.isBlank(paymentOrg)) { + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowIndex + SalaryI18nUtil.getI18nLabel(100579, "个税扣缴义务人不允许为空")); + excelComments.add(errorMessageMap); + isError = true; + } else if (!paymentNameIdMap.containsKey(paymentOrg)) { + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowIndex + SalaryI18nUtil.getI18nLabel(100312, "社保缴纳组织应和个税扣缴义务人名称一致,社保缴纳组织不存在或不在权限范围内")); + excelComments.add(errorMessageMap); + isError = true; + } + + if (!isError) { + Long paymentOrgId = paymentNameIdMap.get(paymentOrg); + TaxAgentManageRangeEmployeeDTO taxAgentManageRangeEmployeeDTO = taxAgentManageRangeEmployeeTree.stream().filter(tax -> tax.getTaxAgentId().equals(paymentOrgId)).findFirst().get(); + Optional o = taxAgentManageRangeEmployeeDTO.getEmployeeList().stream().map(TaxAgentManageRangeEmployeeDTO.TaxAgentEmployee::getEmployeeId).filter(e -> e.equals(employeeId)).findFirst(); + if (!o.isPresent()) { + if (param.isProcess()) { + //流程中自动将人员添加进个税扣缴义务人中 + TaxAgentManageRangeSaveParam.TaxAgentSubAdminRangeTargetParam taxAgentSubAdminRangeTargetParam = new TaxAgentManageRangeSaveParam.TaxAgentSubAdminRangeTargetParam(); + taxAgentSubAdminRangeTargetParam.setTargetId(employeeId); + taxAgentSubAdminRangeTargetParam.setTargetType(TargetTypeEnum.EMPLOYEE); + + TaxAgentRangeSaveParam taxAgentRangeSaveParam = new TaxAgentRangeSaveParam(); + taxAgentRangeSaveParam.setTaxAgentId(paymentOrgId); + taxAgentRangeSaveParam.setIncludeType(1); + taxAgentRangeSaveParam.setEmployeeStatus(Arrays.asList("0", "1", "2", "3", "4", "5", "6")); + taxAgentRangeSaveParam.setTargetParams(Collections.singletonList(taxAgentSubAdminRangeTargetParam)); + taxAgentRangeSaveParam.setSync(true); + param.setTaxAgentRanges(Collections.singletonList(taxAgentRangeSaveParam)); + } + } + + } + + + String socialStartMonth = (String) socialStartTimeMap.get(SalaryI18nUtil.getI18nLabel(91319, "社保起始缴纳月")); + if (StringUtils.isNotBlank(socialStartMonth) && socialStartMonth.length() > 7) { + socialStartMonth = socialStartMonth.substring(0, 7); + } + if (StringUtils.isNotBlank(socialStartMonth) && !SalaryDateUtil.checkYearMonth(socialStartMonth.replace("/", "-"))) { + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowIndex + SalaryI18nUtil.getI18nLabel(100315, "社保起始缴纳时间格式错误,正确格式为YYYY-MM或者yyyy-MM-dd")); + excelComments.add(errorMessageMap); + isError = true; + } + + String socialEndMonth = (String) socialEndTimeMap.get(SalaryI18nUtil.getI18nLabel(91320, "社保最后缴纳月")); + if (StringUtils.isNotBlank(socialEndMonth) && socialEndMonth.length() > 7) { + socialEndMonth = socialEndMonth.substring(0, 7); + } + if (StringUtils.isNotBlank(socialEndMonth) && !SalaryDateUtil.checkYearMonth(socialEndMonth.replace("/", "-"))) { + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowIndex + SalaryI18nUtil.getI18nLabel(100316, "社保最后缴纳时间格式错误,正确格式为YYYY-MM或者yyyy-MM-dd")); + excelComments.add(errorMessageMap); + isError = true; + } + + String fundStartMonth = (String) fundStartTimeMap.get(SalaryI18nUtil.getI18nLabel(91483, "公积金起始缴纳月")); + if (StringUtils.isNotBlank(fundStartMonth) && fundStartMonth.length() > 7) { + fundStartMonth = fundStartMonth.substring(0, 7); + } + if (StringUtils.isNotBlank(fundStartMonth) && !SalaryDateUtil.checkYearMonth(fundStartMonth.replace("/", "-"))) { + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowIndex + SalaryI18nUtil.getI18nLabel(100317, "公积金起始缴纳时间格式错误,正确格式为YYYY-MM或者yyyy-MM-dd")); + excelComments.add(errorMessageMap); + isError = true; + } + + String fundEndMonth = (String) fundEndTimeMap.get(SalaryI18nUtil.getI18nLabel(91484, "公积金最后缴纳月")); + if (StringUtils.isNotBlank(fundEndMonth) && fundEndMonth.length() > 7) { + fundEndMonth = fundEndMonth.substring(0, 7); + } + if (StringUtils.isNotBlank(fundEndMonth) && !SalaryDateUtil.checkYearMonth(fundEndMonth.replace("/", "-"))) { + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowIndex + SalaryI18nUtil.getI18nLabel(100319, "公积金最后缴纳时间格式错误,正确格式为YYYY-MM或者yyyy-MM-dd")); + excelComments.add(errorMessageMap); + isError = true; + } + + String otherStartMonth = (String) otherStartTimeMap.get(SalaryI18nUtil.getI18nLabel(91490, "其他福利起始缴纳月")); + if (StringUtils.isNotBlank(otherStartMonth) && otherStartMonth.length() > 7) { + otherStartMonth = otherStartMonth.substring(0, 7); + } + if (StringUtils.isNotBlank(otherStartMonth) && !SalaryDateUtil.checkYearMonth(otherStartMonth.replace("/", "-"))) { + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowIndex + SalaryI18nUtil.getI18nLabel(100320, "其他福利起始缴纳时间格式错误,正确格式为YYYY-MM或者yyyy-MM-dd")); + excelComments.add(errorMessageMap); + isError = true; + } + + String otherEndMonth = (String) otherEndTimeMap.get(SalaryI18nUtil.getI18nLabel(91494, "其他福利最后缴纳月")); + if (StringUtils.isNotBlank(otherEndMonth) && otherEndMonth.length() > 7) { + otherEndMonth = otherEndMonth.substring(0, 7); + } + if (StringUtils.isNotBlank(otherEndMonth) && !SalaryDateUtil.checkYearMonth(otherEndMonth.replace("/", "-"))) { + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowIndex + SalaryI18nUtil.getI18nLabel(100321, "其他福利最后缴纳时间格式错误,正确格式为YYYY-MM或者yyyy-MM-dd")); + excelComments.add(errorMessageMap); + isError = true; + } + if (StringUtils.isNotBlank((String) socialMap.get(SalaryI18nUtil.getI18nLabel(91323, "社保方案名称"))) && schemeNameIdMap.get((String) socialMap.get(SalaryI18nUtil.getI18nLabel(91323, "社保方案名称"))) == null) { + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowIndex + SalaryI18nUtil.getI18nLabel(100322, "社保方案不存在")); + excelComments.add(errorMessageMap); + isError = true; + } else if (StringUtils.isNotBlank((String) socialMap.get(SalaryI18nUtil.getI18nLabel(91323, "社保方案名称"))) + && schemeNameIdMap.get((String) socialMap.get(SalaryI18nUtil.getI18nLabel(91323, "社保方案名称"))) != null + && !getInsuranceSchemeMapper().getById(schemeNameIdMap.get((String) socialMap.get(SalaryI18nUtil.getI18nLabel(91323, "社保方案名称")))).getWelfareType().equals(WelfareTypeEnum.SOCIAL_SECURITY.getValue())) { + + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowIndex + SalaryI18nUtil.getI18nLabel(100322, "社保方案不属于社保福利类型")); + excelComments.add(errorMessageMap); + isError = true; + + } else if (StringUtils.isNotBlank((String) socialMap.get(SalaryI18nUtil.getI18nLabel(91323, "社保方案名称"))) && StringUtils.isBlank(socialStartMonth)) { + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowIndex + SalaryI18nUtil.getI18nLabel(100322, "社保方案已设置,但未设置社保起始缴纳时间!")); + excelComments.add(errorMessageMap); + isError = true; + } else { + insuranceArchivesSocialSchemePO = buildSocialPO(employeeId, welfareMap, singleAccount, schemeNameIdMap, paymentNameIdMap, creator); + } + if (StringUtils.isNotBlank((String) fundMap.get(SalaryI18nUtil.getI18nLabel(91485, "公积金方案名称"))) && schemeNameIdMap.get((String) fundMap.get(SalaryI18nUtil.getI18nLabel(91485, "公积金方案名称"))) == null) { + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowIndex + SalaryI18nUtil.getI18nLabel(100323, "公积金方案不存在")); + excelComments.add(errorMessageMap); + isError = true; + } else if (StringUtils.isNotBlank((String) fundMap.get(SalaryI18nUtil.getI18nLabel(91485, "公积金方案名称"))) + && schemeNameIdMap.get((String) fundMap.get(SalaryI18nUtil.getI18nLabel(91485, "公积金方案名称"))) != null + && !getInsuranceSchemeMapper().getById(schemeNameIdMap.get((String) fundMap.get(SalaryI18nUtil.getI18nLabel(91485, "公积金方案名称")))).getWelfareType().equals(WelfareTypeEnum.ACCUMULATION_FUND.getValue())) { + + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowIndex + SalaryI18nUtil.getI18nLabel(100322, "公积金方案不属于公积金福利类型")); + excelComments.add(errorMessageMap); + isError = true; + + } else if (StringUtils.isNotBlank((String) fundMap.get(SalaryI18nUtil.getI18nLabel(91485, "公积金方案名称"))) && StringUtils.isBlank(fundStartMonth)) { + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowIndex + SalaryI18nUtil.getI18nLabel(100322, "公积金方案已设置,但未设置公积金起始缴纳时间!")); + excelComments.add(errorMessageMap); + isError = true; + } else { + insuranceArchivesFundSchemePO = buildFundPO(employeeId, welfareMap, singleAccount, schemeNameIdMap, paymentNameIdMap, creator); + } + if (StringUtils.isNotBlank((String) otherMap.get(SalaryI18nUtil.getI18nLabel(91496, "其他福利方案名称"))) && schemeNameIdMap.get((String) otherMap.get(SalaryI18nUtil.getI18nLabel(91496, "其他福利方案名称"))) == null) { + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowIndex + SalaryI18nUtil.getI18nLabel(100324, "其他福利方案不存在")); + excelComments.add(errorMessageMap); + isError = true; + } else if (StringUtils.isNotBlank((String) otherMap.get(SalaryI18nUtil.getI18nLabel(91496, "其他福利方案名称"))) + && schemeNameIdMap.get((String) otherMap.get(SalaryI18nUtil.getI18nLabel(91496, "其他福利方案名称"))) != null + && !getInsuranceSchemeMapper().getById(schemeNameIdMap.get((String) otherMap.get(SalaryI18nUtil.getI18nLabel(91496, "其他福利方案名称")))).getWelfareType().equals(WelfareTypeEnum.OTHER.getValue())) { + + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowIndex + SalaryI18nUtil.getI18nLabel(100322, "其他福利方案不属于其他福利类型")); + excelComments.add(errorMessageMap); + isError = true; + } else if (StringUtils.isNotBlank((String) otherMap.get(SalaryI18nUtil.getI18nLabel(91496, "其他福利方案名称"))) && StringUtils.isBlank(otherStartMonth)) { + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowIndex + SalaryI18nUtil.getI18nLabel(100322, "其他福利方案已设置,但未设置其他福利起始缴纳时间!")); + excelComments.add(errorMessageMap); + isError = true; + } else { + insuranceArchivesOtherSchemePO = buildOtherPO(employeeId, welfareMap, singleAccount, schemeNameIdMap, paymentNameIdMap, creator); + } + /**************校验申报基数**************/ +// boolean welBaseDiffSign = siArchivesBiz.isDiffWelBase(); + boolean welBaseDiffSign = getSIArchivesService(user).isDiffWelBase(); + if (welBaseDiffSign) { + for (Map.Entry entry : welfareMap.entrySet()) { + String keyPerName = entry.getValue() + SalaryI18nUtil.getI18nLabel(0, "申报基数") + SalaryI18nUtil.getI18nLabel(0, "个人"); + String keyComName = entry.getValue() + SalaryI18nUtil.getI18nLabel(0, "申报基数") + SalaryI18nUtil.getI18nLabel(0, "单位"); + String numberPerValue = findElement(singleAccount, keyPerName).get(keyPerName) == null ? "" : findElement(singleAccount, keyPerName).get(keyPerName).toString(); + String numberComValue = findElement(singleAccount, keyComName).get(keyComName) == null ? "" : findElement(singleAccount, keyComName).get(keyComName).toString(); + + if (!"".equals(numberPerValue) && !NumberUtils.isParsable(numberPerValue)) { + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowIndex + keyPerName + SalaryI18nUtil.getI18nLabel(0, "请输入数字")); + excelComments.add(errorMessageMap); + isError = true; + } + if (!"".equals(numberComValue) && !NumberUtils.isParsable(numberComValue)) { + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowIndex + keyComName + SalaryI18nUtil.getI18nLabel(0, "请输入数字")); + excelComments.add(errorMessageMap); + isError = true; + } + } + } else { + for (Map.Entry entry : welfareMap.entrySet()) { + String keyName = entry.getValue() + SalaryI18nUtil.getI18nLabel(0, "申报基数"); + String numberValue = findElement(singleAccount, keyName).get(keyName) == null ? "" : findElement(singleAccount, keyName).get(keyName).toString(); + if (!"".equals(numberValue) && !NumberUtils.isParsable(numberValue)) { + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowIndex + keyName + SalaryI18nUtil.getI18nLabel(0, "请输入数字")); + excelComments.add(errorMessageMap); + isError = true; + } + } + } + + //生成福利档案基础信息数据 + InsuranceArchivesBaseInfoPO insuranceArchivesBaseInfoPO = buildBaseInfoPO(employeeId, singleAccount, paymentNameIdMap, creator, runStatus, employees.get(0).isExtEmp()); + + //判断是否福利档案导入时,不符合上下限的基数调整为上限/下限 + SalarySysConfPO welBaseAutoAdjust = getSalarySysConfService(user).getOneByCode(WEL_BASE_AUTO_ADJUST); + boolean welBaseAutoAdjustSign = welBaseAutoAdjust != null && welBaseAutoAdjust.getConfValue().equals(OpenEnum.OPEN.getValue()); + + if (!isError && !welBaseAutoAdjustSign) { + StringBuilder errorMsg = new StringBuilder(""); + insuranceArchivesAccountPO.setSocial(insuranceArchivesSocialSchemePO); + insuranceArchivesAccountPO.setFund(insuranceArchivesFundSchemePO); + insuranceArchivesAccountPO.setOther(insuranceArchivesOtherSchemePO); + insuranceArchivesAccountPO.setBaseInfo(insuranceArchivesBaseInfoPO); + //校验福利基数是否符合上下限要求, + Boolean socialCheckBase = getSIArchivesService(user).checkWelBaseLimit(insuranceArchivesSocialSchemePO.getSocialSchemeId(), insuranceArchivesSocialSchemePO.getSocialPaymentBaseString(), PaymentScopeEnum.SCOPE_PERSON.getValue(), errorMsg); + + Boolean fundCheckBase = getSIArchivesService(user).checkWelBaseLimit(insuranceArchivesFundSchemePO.getFundSchemeId(), insuranceArchivesFundSchemePO.getFundPaymentBaseString(), PaymentScopeEnum.SCOPE_PERSON.getValue(), errorMsg); + + Boolean otherCheckBase = getSIArchivesService(user).checkWelBaseLimit(insuranceArchivesOtherSchemePO.getOtherSchemeId(), insuranceArchivesOtherSchemePO.getOtherPaymentBaseString(), PaymentScopeEnum.SCOPE_PERSON.getValue(), errorMsg); + + Boolean socialCheckComBase = true; + Boolean fundCheckComBase = true; + Boolean otherCheckComBase = true; + if (welBaseDiffSign) { + socialCheckComBase = getSIArchivesService(user).checkWelBaseLimit(insuranceArchivesSocialSchemePO.getSocialSchemeId(), insuranceArchivesSocialSchemePO.getSocialPaymentComBaseString(), PaymentScopeEnum.SCOPE_COMPANY.getValue(), errorMsg); + fundCheckComBase = getSIArchivesService(user).checkWelBaseLimit(insuranceArchivesFundSchemePO.getFundSchemeId(), insuranceArchivesFundSchemePO.getFundPaymentComBaseString(), PaymentScopeEnum.SCOPE_COMPANY.getValue(), errorMsg); + otherCheckComBase = getSIArchivesService(user).checkWelBaseLimit(insuranceArchivesOtherSchemePO.getOtherSchemeId(), insuranceArchivesOtherSchemePO.getOtherPaymentComBaseString(), PaymentScopeEnum.SCOPE_COMPANY.getValue(), errorMsg); + } + if (socialCheckBase && fundCheckBase && otherCheckBase && socialCheckComBase && fundCheckComBase && otherCheckComBase) { + insuranceArchivesAccountPOS.add(insuranceArchivesAccountPO); + } else { + String checkMessage = "该条数据中"; + if (!socialCheckBase || !socialCheckComBase) { + checkMessage = checkMessage + "社保福利基数、"; + } + if (!fundCheckBase || !fundCheckComBase) { + checkMessage = checkMessage + "公积金福利基数、"; + } + if (!otherCheckBase || !otherCheckComBase) { + checkMessage = checkMessage + "其他福利基数、"; + } + checkMessage = checkMessage.substring(0, checkMessage.length() - 1); + + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowIndex + SalaryI18nUtil.getI18nLabel(100312, checkMessage + "数值超出相关福利方案的基数上下限要求,不可导入!")); + excelComments.add(errorMessageMap); + isError = true; + } + + } else if (!isError) { + //校验福利基数是否符合上下限要求,不符合上下限的基数调整为上限 /下限 + String newSocialPaymentBaseString = getSIArchivesService(user).checkAndBuildWelBaseWithLimit(insuranceArchivesSocialSchemePO.getSocialSchemeId(), insuranceArchivesSocialSchemePO.getSocialPaymentBaseString(), PaymentScopeEnum.SCOPE_PERSON.getValue()); + String newFundPaymentBaseString = getSIArchivesService(user).checkAndBuildWelBaseWithLimit(insuranceArchivesFundSchemePO.getFundSchemeId(), insuranceArchivesFundSchemePO.getFundPaymentBaseString(), PaymentScopeEnum.SCOPE_PERSON.getValue()); + String newOtherPaymentBaseString = getSIArchivesService(user).checkAndBuildWelBaseWithLimit(insuranceArchivesOtherSchemePO.getOtherSchemeId(), insuranceArchivesOtherSchemePO.getOtherPaymentBaseString(), PaymentScopeEnum.SCOPE_PERSON.getValue()); + + insuranceArchivesSocialSchemePO.setSocialPaymentBaseString(newSocialPaymentBaseString); + insuranceArchivesFundSchemePO.setFundPaymentBaseString(newFundPaymentBaseString); + insuranceArchivesOtherSchemePO.setOtherPaymentBaseString(newOtherPaymentBaseString); + + if (welBaseDiffSign) { + String newSocialPaymentComBaseString = getSIArchivesService(user).checkAndBuildWelBaseWithLimit(insuranceArchivesSocialSchemePO.getSocialSchemeId(), insuranceArchivesSocialSchemePO.getSocialPaymentComBaseString(), PaymentScopeEnum.SCOPE_COMPANY.getValue()); + String newFundPaymentComBaseString = getSIArchivesService(user).checkAndBuildWelBaseWithLimit(insuranceArchivesFundSchemePO.getFundSchemeId(), insuranceArchivesFundSchemePO.getFundPaymentComBaseString(), PaymentScopeEnum.SCOPE_COMPANY.getValue()); + String newOtherPaymentComBaseString = getSIArchivesService(user).checkAndBuildWelBaseWithLimit(insuranceArchivesOtherSchemePO.getOtherSchemeId(), insuranceArchivesOtherSchemePO.getOtherPaymentComBaseString(), PaymentScopeEnum.SCOPE_COMPANY.getValue()); + + insuranceArchivesSocialSchemePO.setSocialPaymentComBaseString(newSocialPaymentComBaseString); + insuranceArchivesFundSchemePO.setFundPaymentComBaseString(newFundPaymentComBaseString); + insuranceArchivesOtherSchemePO.setOtherPaymentComBaseString(newOtherPaymentComBaseString); + } + + insuranceArchivesAccountPO.setSocial(insuranceArchivesSocialSchemePO); + insuranceArchivesAccountPO.setFund(insuranceArchivesFundSchemePO); + insuranceArchivesAccountPO.setOther(insuranceArchivesOtherSchemePO); + insuranceArchivesAccountPO.setBaseInfo(insuranceArchivesBaseInfoPO); + + insuranceArchivesAccountPOS.add(insuranceArchivesAccountPO); + } + return isError; + } + + + public Map findElement(List> singleAccount, String target) { + for (Map e : singleAccount) { + if (e.containsKey(target)) { + return e; + } + } + return new HashMap<>(); + } + + + public InsuranceArchivesSocialSchemePO buildSocialPO(Long employeeId, Map welfareMap, List> singleAccount, Map schemeNameIdMap, Map paymentNameIdMap, Long creator) { + + if (employeeId == null) { + return null; + } + Long paymentOrg = paymentNameIdMap.get((String) findElement(singleAccount, SalaryI18nUtil.getI18nLabel(91325, "个税扣缴义务人")).get(SalaryI18nUtil.getI18nLabel(91325, "个税扣缴义务人"))); + List oldSocialSchemeInfos = getSocialSchemeMapper().getSocialByEmployeeIdAndPayOrg(InsuranceArchivesEmployeePO + .builder() + .employeeId(employeeId) + .paymentOrganization(paymentOrg) + .build()); + InsuranceArchivesSocialSchemePO oldSocialSchemePO = new InsuranceArchivesSocialSchemePO(); + InsuranceArchivesSocialSchemePO insuranceArchivesSocialSchemePO = new InsuranceArchivesSocialSchemePO(); + + //设置社保账号、起始缴纳月、最后缴纳月 + String socialAccount = (String) findElement(singleAccount, SalaryI18nUtil.getI18nLabel(91324, "社保账号")).get(SalaryI18nUtil.getI18nLabel(91324, "社保账号")); + Long socialSchemeId = schemeNameIdMap.get((String) findElement(singleAccount, SalaryI18nUtil.getI18nLabel(91323, "社保方案名称")).get(SalaryI18nUtil.getI18nLabel(91323, "社保方案名称"))); + HashMap oldSocialBaseMap = new HashMap<>(); + HashMap oldSocialComBaseMap = new HashMap<>(); + if (oldSocialSchemeInfos.size() > 0) { + oldSocialSchemePO = oldSocialSchemeInfos.get(0); + encryptUtil.decrypt(oldSocialSchemePO, InsuranceArchivesSocialSchemePO.class); + BeanUtils.copyProperties(oldSocialSchemePO, insuranceArchivesSocialSchemePO); + //社保基数 + oldSocialBaseMap = JSON.parseObject(oldSocialSchemePO.getSocialPaymentBaseString(), new HashMap().getClass()); + oldSocialComBaseMap = JSON.parseObject(oldSocialSchemePO.getSocialPaymentComBaseString(), new HashMap().getClass()); + } + + insuranceArchivesSocialSchemePO.setId(IdGenerator.generate()); + if (StringUtils.isNotBlank(socialAccount)) { + insuranceArchivesSocialSchemePO.setSocialAccount(socialAccount); + } + if (socialSchemeId != null) { + insuranceArchivesSocialSchemePO.setSocialSchemeId(socialSchemeId); + } + String socialStartDate = (String) findElement(singleAccount, SalaryI18nUtil.getI18nLabel(91319, "社保起始缴纳月")).get(SalaryI18nUtil.getI18nLabel(91319, "社保起始缴纳月")); + if (StringUtils.isNotBlank(socialStartDate) && socialStartDate.length() >= 7) { + socialStartDate = socialStartDate.substring(0, 7).replace("/", "-"); + insuranceArchivesSocialSchemePO.setSocialStartTime(socialStartDate); + } + + String socialEndDate = (String) findElement(singleAccount, SalaryI18nUtil.getI18nLabel(91320, "社保最后缴纳月")).get(SalaryI18nUtil.getI18nLabel(91320, "社保最后缴纳月")); + if (StringUtils.isNotBlank(socialEndDate) && socialEndDate.length() >= 7) { + socialEndDate = socialEndDate.substring(0, 7).replace("/", "-"); + insuranceArchivesSocialSchemePO.setSocialEndTime(socialEndDate); + } + + insuranceArchivesSocialSchemePO.setTenantKey(""); + insuranceArchivesSocialSchemePO.setWelfareType(WelfareTypeEnum.SOCIAL_SECURITY.getValue()); + insuranceArchivesSocialSchemePO.setUpdateTime(new Date()); + insuranceArchivesSocialSchemePO.setPaymentOrganization(paymentOrg); + insuranceArchivesSocialSchemePO.setNonPayment(NonPaymentEnum.YES.getValue()); + insuranceArchivesSocialSchemePO.setCreator(creator); + insuranceArchivesSocialSchemePO.setCreateTime(new Date()); + insuranceArchivesSocialSchemePO.setUpdateTime(new Date()); + insuranceArchivesSocialSchemePO.setDeleteType(DeleteTypeEnum.NOT_DELETED.getValue()); + insuranceArchivesSocialSchemePO.setEmployeeId(employeeId); + insuranceArchivesSocialSchemePO.setUnderTake(UndertakerEnum.SCOPE_PERSON.getValue()); + List insuranceSchemeDetailPOS = getInsuranceSchemeDetailMapper().queryListBySchemeId(insuranceArchivesSocialSchemePO.getSocialSchemeId()); + encryptUtil.decryptList(insuranceSchemeDetailPOS, InsuranceSchemeDetailPO.class); + +// boolean welBaseDiffSign = siArchivesBiz.isDiffWelBase(); + boolean welBaseDiffSign = getSIArchivesService(user).isDiffWelBase(); + if (CollectionUtils.isNotEmpty(insuranceSchemeDetailPOS)) { + List insuranceIds = insuranceSchemeDetailPOS.stream().map(InsuranceSchemeDetailPO::getInsuranceId).collect(Collectors.toList()); + HashMap socialPaymentBase = new HashMap<>(); + HashMap socialPaymentComBase = new HashMap<>(); + for (Long insuranceId : insuranceIds) { + if (StringUtils.isBlank(welfareMap.get(insuranceId))) { + continue; + } + if (welBaseDiffSign) { + Map itemPerMap = findElement(singleAccount, welfareMap.get(insuranceId) + SalaryI18nUtil.getI18nLabel(0, "申报基数") + SalaryI18nUtil.getI18nLabel(0, "个人")); + if (itemPerMap != null) { + String itemValue = (String) itemPerMap.get(welfareMap.get(insuranceId) + SalaryI18nUtil.getI18nLabel(0, "申报基数") + SalaryI18nUtil.getI18nLabel(0, "个人")); + if (StringUtils.isNotBlank(itemValue)) { + socialPaymentBase.put(String.valueOf(insuranceId), itemValue); + } else if (oldSocialBaseMap != null && StringUtils.isNotBlank(oldSocialBaseMap.get(String.valueOf(insuranceId)))) { + socialPaymentBase.put(String.valueOf(insuranceId), oldSocialBaseMap.get(String.valueOf(insuranceId))); + } + } + Map itemComMap = findElement(singleAccount, welfareMap.get(insuranceId) + SalaryI18nUtil.getI18nLabel(0, "申报基数") + SalaryI18nUtil.getI18nLabel(0, "单位")); + if (itemComMap != null) { + String itemValue = (String) itemComMap.get(welfareMap.get(insuranceId) + SalaryI18nUtil.getI18nLabel(0, "申报基数") + SalaryI18nUtil.getI18nLabel(0, "单位")); + if (StringUtils.isNotBlank(itemValue)) { + socialPaymentComBase.put(String.valueOf(insuranceId), itemValue); + } else if (oldSocialComBaseMap != null && StringUtils.isNotBlank(oldSocialComBaseMap.get(String.valueOf(insuranceId)))) { + socialPaymentComBase.put(String.valueOf(insuranceId), oldSocialComBaseMap.get(String.valueOf(insuranceId))); + } + } + insuranceArchivesSocialSchemePO.setSocialPaymentComBaseString(JSON.toJSONString(socialPaymentComBase)); + } else { + Map itemMap = findElement(singleAccount, welfareMap.get(insuranceId) + SalaryI18nUtil.getI18nLabel(0, "申报基数")); + if (itemMap != null) { + String itemValue = (String) itemMap.get(welfareMap.get(insuranceId) + SalaryI18nUtil.getI18nLabel(0, "申报基数")); + if (StringUtils.isNotBlank(itemValue)) { + socialPaymentBase.put(String.valueOf(insuranceId), itemValue); + } else if (oldSocialBaseMap != null && StringUtils.isNotBlank(oldSocialBaseMap.get(String.valueOf(insuranceId)))) { + socialPaymentBase.put(String.valueOf(insuranceId), oldSocialBaseMap.get(String.valueOf(insuranceId))); + } + } + } + + } + insuranceArchivesSocialSchemePO.setSocialPaymentBaseString(JSON.toJSONString(socialPaymentBase)); + } + return insuranceArchivesSocialSchemePO; + } + + + public InsuranceArchivesFundSchemePO buildFundPO(Long employeeId, Map welfareMap, List> singleAccount, Map schemeNameIdMap, Map paymentNameIdMap, Long creator) { + + if (employeeId == null) { + return null; + } + Long paymentOrg = paymentNameIdMap.get((String) findElement(singleAccount, SalaryI18nUtil.getI18nLabel(91325, "个税扣缴义务人")).get(SalaryI18nUtil.getI18nLabel(91325, "个税扣缴义务人"))); + List oldFundSchemeInfos = getFundSchemeMapper().getFundByEmployeeIdAndPayOrg(InsuranceArchivesEmployeePO + .builder() + .employeeId(employeeId) + .paymentOrganization(paymentOrg) + .build()); + InsuranceArchivesFundSchemePO oldFundSchemePO = new InsuranceArchivesFundSchemePO(); + InsuranceArchivesFundSchemePO insuranceArchivesFundSchemePO = new InsuranceArchivesFundSchemePO(); + + //设置公积金账号、起始缴纳月、最后缴纳月 + String fundAccount = (String) findElement(singleAccount, SalaryI18nUtil.getI18nLabel(91486, "公积金账号")).get(SalaryI18nUtil.getI18nLabel(91486, "公积金账号")); + String supplementFundAccount = (String) findElement(singleAccount, SalaryI18nUtil.getI18nLabel(91487, "补充公积金账号")).get(SalaryI18nUtil.getI18nLabel(91487, "补充公积金账号")); + Long fundSchemeId = schemeNameIdMap.get((String) findElement(singleAccount, SalaryI18nUtil.getI18nLabel(91485, "公积金方案名称")).get(SalaryI18nUtil.getI18nLabel(91485, "公积金方案名称"))); + HashMap oldFundBaseMap = new HashMap<>(); + HashMap oldFundComBaseMap = new HashMap<>(); + if (oldFundSchemeInfos.size() > 0) { + oldFundSchemePO = oldFundSchemeInfos.get(0); + encryptUtil.decrypt(oldFundSchemePO, InsuranceArchivesFundSchemePO.class); + BeanUtils.copyProperties(oldFundSchemePO, insuranceArchivesFundSchemePO); + //社保基数 + oldFundBaseMap = JSON.parseObject(oldFundSchemePO.getFundPaymentBaseString(), new HashMap().getClass()); + oldFundComBaseMap = JSON.parseObject(oldFundSchemePO.getFundPaymentComBaseString(), new HashMap().getClass()); + } + + insuranceArchivesFundSchemePO.setId(IdGenerator.generate()); + insuranceArchivesFundSchemePO.setCreator(creator); + insuranceArchivesFundSchemePO.setTenantKey(""); + insuranceArchivesFundSchemePO.setCreateTime(new Date()); + insuranceArchivesFundSchemePO.setUpdateTime(new Date()); + if (fundSchemeId != null) { + insuranceArchivesFundSchemePO.setFundSchemeId(fundSchemeId); + } + if (StringUtils.isNotBlank(fundAccount)) { + insuranceArchivesFundSchemePO.setFundAccount(fundAccount); + } + if (StringUtils.isNotBlank(supplementFundAccount)) { + insuranceArchivesFundSchemePO.setSupplementFundAccount(supplementFundAccount); + } + String fundStartDate = (String) findElement(singleAccount, SalaryI18nUtil.getI18nLabel(91483, "公积金起始缴纳月")).get(SalaryI18nUtil.getI18nLabel(91483, "公积金起始缴纳月")); + if (StringUtils.isNotBlank(fundStartDate) && fundStartDate.length() >= 7) { + fundStartDate = fundStartDate.substring(0, 7).replace("/", "-"); + insuranceArchivesFundSchemePO.setFundStartTime(fundStartDate); + } + + String fundEndDate = (String) findElement(singleAccount, SalaryI18nUtil.getI18nLabel(91484, "公积金最后缴纳月")).get(SalaryI18nUtil.getI18nLabel(91484, "公积金最后缴纳月")); + if (StringUtils.isNotBlank(fundEndDate) && fundEndDate.length() >= 7) { + fundEndDate = fundEndDate.substring(0, 7).replace("/", "-"); + insuranceArchivesFundSchemePO.setFundEndTime(fundEndDate); + } + + insuranceArchivesFundSchemePO.setWelfareType(WelfareTypeEnum.ACCUMULATION_FUND.getValue()); + insuranceArchivesFundSchemePO.setPaymentOrganization(paymentOrg); + insuranceArchivesFundSchemePO.setNonPayment(NonPaymentEnum.YES.getValue()); + insuranceArchivesFundSchemePO.setDeleteType(DeleteTypeEnum.NOT_DELETED.getValue()); + insuranceArchivesFundSchemePO.setUnderTake(UndertakerEnum.SCOPE_PERSON.getValue()); + insuranceArchivesFundSchemePO.setEmployeeId(employeeId); + + List insuranceSchemeDetailPOS = getInsuranceSchemeDetailMapper().queryListBySchemeId(insuranceArchivesFundSchemePO.getFundSchemeId()); + encryptUtil.decryptList(insuranceSchemeDetailPOS, InsuranceSchemeDetailPO.class); +// boolean welBaseDiffSign = siArchivesBiz.isDiffWelBase(); + boolean welBaseDiffSign = getSIArchivesService(user).isDiffWelBase(); + if (CollectionUtils.isNotEmpty(insuranceSchemeDetailPOS)) { + List insuranceIds = insuranceSchemeDetailPOS.stream().map(InsuranceSchemeDetailPO::getInsuranceId).collect(Collectors.toList()); + HashMap fundPaymentBase = new HashMap<>(); + HashMap fundPaymentComBase = new HashMap<>(); + for (Long insuranceId : insuranceIds) { + if (StringUtils.isBlank(welfareMap.get(insuranceId))) { + continue; + } + if (welBaseDiffSign) { + Map itemPerMap = findElement(singleAccount, welfareMap.get(insuranceId) + SalaryI18nUtil.getI18nLabel(0, "申报基数") + SalaryI18nUtil.getI18nLabel(0, "个人")); + if (itemPerMap != null) { + String itemValue = (String) itemPerMap.get(welfareMap.get(insuranceId) + SalaryI18nUtil.getI18nLabel(0, "申报基数") + SalaryI18nUtil.getI18nLabel(0, "个人")); + if (StringUtils.isNotBlank(itemValue)) { + fundPaymentBase.put(String.valueOf(insuranceId), itemValue); + } else if (oldFundBaseMap != null && StringUtils.isNotBlank(oldFundBaseMap.get(String.valueOf(insuranceId)))) { + fundPaymentBase.put(String.valueOf(insuranceId), oldFundBaseMap.get(String.valueOf(insuranceId))); + } + } + Map itemComMap = findElement(singleAccount, welfareMap.get(insuranceId) + SalaryI18nUtil.getI18nLabel(0, "申报基数") + SalaryI18nUtil.getI18nLabel(0, "单位")); + if (itemComMap != null) { + String itemValue = (String) itemComMap.get(welfareMap.get(insuranceId) + SalaryI18nUtil.getI18nLabel(0, "申报基数") + SalaryI18nUtil.getI18nLabel(0, "单位")); + if (StringUtils.isNotBlank(itemValue)) { + fundPaymentComBase.put(String.valueOf(insuranceId), itemValue); + } else if (oldFundComBaseMap != null && StringUtils.isNotBlank(oldFundComBaseMap.get(String.valueOf(insuranceId)))) { + fundPaymentComBase.put(String.valueOf(insuranceId), oldFundComBaseMap.get(String.valueOf(insuranceId))); + } + } + insuranceArchivesFundSchemePO.setFundPaymentComBaseString(JSON.toJSONString(fundPaymentComBase)); + } else { + Map itemMap = findElement(singleAccount, welfareMap.get(insuranceId) + SalaryI18nUtil.getI18nLabel(0, "申报基数")); + if (itemMap != null) { + String itemValue = (String) itemMap.get(welfareMap.get(insuranceId) + SalaryI18nUtil.getI18nLabel(0, "申报基数")); + if (StringUtils.isNotBlank(itemValue)) { + fundPaymentBase.put(String.valueOf(insuranceId), itemValue); + } else if (oldFundBaseMap != null && StringUtils.isNotBlank(oldFundBaseMap.get(String.valueOf(insuranceId)))) { + fundPaymentBase.put(String.valueOf(insuranceId), oldFundBaseMap.get(String.valueOf(insuranceId))); + } + } + } + + } + insuranceArchivesFundSchemePO.setFundPaymentBaseString(JSON.toJSONString(fundPaymentBase)); + } + return insuranceArchivesFundSchemePO; + } + + + public InsuranceArchivesOtherSchemePO buildOtherPO(Long employeeId, Map welfareMap, List> singleAccount, Map schemeNameIdMap, Map paymentNameIdMap, Long creator) { + + if (employeeId == null) { + return null; + }Long paymentOrg = paymentNameIdMap.get((String) findElement(singleAccount, SalaryI18nUtil.getI18nLabel(91325, "个税扣缴义务人")).get(SalaryI18nUtil.getI18nLabel(91325, "个税扣缴义务人"))); + List oldOtherSchemeInfos = getOtherSchemeMapper().getOtherByEmployeeIdAndPayOrg(InsuranceArchivesEmployeePO + .builder() + .employeeId(employeeId) + .paymentOrganization(paymentOrg) + .build()); + InsuranceArchivesOtherSchemePO oldOtherSchemePO = new InsuranceArchivesOtherSchemePO(); + InsuranceArchivesOtherSchemePO insuranceArchivesOtherSchemePO = new InsuranceArchivesOtherSchemePO(); + + //设置其他福利方案、起始缴纳月、最后缴纳月 + Long otherSchemeId = schemeNameIdMap.get((String) findElement(singleAccount, SalaryI18nUtil.getI18nLabel(91496, "其他福利方案名称")).get(SalaryI18nUtil.getI18nLabel(91496, "其他福利方案名称"))); + HashMap oldOtherBaseMap = new HashMap<>(); + HashMap oldOtherComBaseMap = new HashMap<>(); + if (oldOtherSchemeInfos.size() > 0) { + oldOtherSchemePO = oldOtherSchemeInfos.get(0); + encryptUtil.decrypt(oldOtherSchemePO, InsuranceArchivesOtherSchemePO.class); + BeanUtils.copyProperties(oldOtherSchemePO, insuranceArchivesOtherSchemePO); + //社保基数 + oldOtherBaseMap = JSON.parseObject(oldOtherSchemePO.getOtherPaymentBaseString(), new HashMap().getClass()); + oldOtherComBaseMap = JSON.parseObject(oldOtherSchemePO.getOtherPaymentComBaseString(), new HashMap().getClass()); + } + + insuranceArchivesOtherSchemePO.setId(IdGenerator.generate()); + insuranceArchivesOtherSchemePO.setCreator(creator); + insuranceArchivesOtherSchemePO.setTenantKey(""); + insuranceArchivesOtherSchemePO.setCreateTime(new Date()); + insuranceArchivesOtherSchemePO.setUpdateTime(new Date()); + if (otherSchemeId != null) { + insuranceArchivesOtherSchemePO.setOtherSchemeId(otherSchemeId); + } + String otherStartDate = (String) findElement(singleAccount, SalaryI18nUtil.getI18nLabel(91490, "其他福利起始缴纳月")).get(SalaryI18nUtil.getI18nLabel(91490, "其他福利起始缴纳月")); + if (StringUtils.isNotBlank(otherStartDate) && otherStartDate.length() >= 7) { + otherStartDate = otherStartDate.substring(0, 7).replace("/", "-"); + insuranceArchivesOtherSchemePO.setOtherStartTime(otherStartDate); + } + + String otherEndDate = (String) findElement(singleAccount, SalaryI18nUtil.getI18nLabel(91494, "其他福利最后缴纳月")).get(SalaryI18nUtil.getI18nLabel(91494, "其他福利最后缴纳月")); + if (StringUtils.isNotBlank(otherEndDate) && otherEndDate.length() >= 7) { + otherEndDate = otherEndDate.substring(0, 7).replace("/", "-"); + insuranceArchivesOtherSchemePO.setOtherEndTime(otherEndDate); + } + + insuranceArchivesOtherSchemePO.setPaymentOrganization(paymentOrg); + insuranceArchivesOtherSchemePO.setWelfareType(WelfareTypeEnum.OTHER.getValue()); + insuranceArchivesOtherSchemePO.setNonPayment(NonPaymentEnum.YES.getValue()); + insuranceArchivesOtherSchemePO.setDeleteType(DeleteTypeEnum.NOT_DELETED.getValue()); + insuranceArchivesOtherSchemePO.setUnderTake(UndertakerEnum.SCOPE_PERSON.getValue()); + insuranceArchivesOtherSchemePO.setEmployeeId(employeeId); + List insuranceSchemeDetailPOS = getInsuranceSchemeDetailMapper().queryListBySchemeId(insuranceArchivesOtherSchemePO.getOtherSchemeId()); + encryptUtil.decryptList(insuranceSchemeDetailPOS, InsuranceSchemeDetailPO.class); +// boolean welBaseDiffSign = siArchivesBiz.isDiffWelBase(); + boolean welBaseDiffSign = getSIArchivesService(user).isDiffWelBase(); + if (CollectionUtils.isNotEmpty(insuranceSchemeDetailPOS)) { + List insuranceIds = insuranceSchemeDetailPOS.stream().map(InsuranceSchemeDetailPO::getInsuranceId).collect(Collectors.toList()); + HashMap otherPaymentBase = new HashMap<>(); + HashMap otherPaymentComBase = new HashMap<>(); + for (Long insuranceId : insuranceIds) { + if (StringUtils.isBlank(welfareMap.get(insuranceId))) { + continue; + } + if (welBaseDiffSign) { + Map itemPerMap = findElement(singleAccount, welfareMap.get(insuranceId) + SalaryI18nUtil.getI18nLabel(0, "申报基数") + SalaryI18nUtil.getI18nLabel(0, "个人")); + if (itemPerMap != null) { + String itemValue = (String) itemPerMap.get(welfareMap.get(insuranceId) + SalaryI18nUtil.getI18nLabel(0, "申报基数") + SalaryI18nUtil.getI18nLabel(0, "个人")); + if (StringUtils.isNotBlank(itemValue)) { + otherPaymentBase.put(String.valueOf(insuranceId), itemValue); + } else if (oldOtherBaseMap != null && StringUtils.isNotBlank(oldOtherBaseMap.get(String.valueOf(insuranceId)))) { + otherPaymentBase.put(String.valueOf(insuranceId), oldOtherBaseMap.get(String.valueOf(insuranceId))); + } + } + Map itemComMap = findElement(singleAccount, welfareMap.get(insuranceId) + SalaryI18nUtil.getI18nLabel(0, "申报基数") + SalaryI18nUtil.getI18nLabel(0, "单位")); + if (itemComMap != null) { + String itemValue = (String) itemComMap.get(welfareMap.get(insuranceId) + SalaryI18nUtil.getI18nLabel(0, "申报基数") + SalaryI18nUtil.getI18nLabel(0, "单位")); + if (StringUtils.isNotBlank(itemValue)) { + otherPaymentComBase.put(String.valueOf(insuranceId), itemValue); + } else if (oldOtherComBaseMap != null && StringUtils.isNotBlank(oldOtherComBaseMap.get(String.valueOf(insuranceId)))) { + otherPaymentComBase.put(String.valueOf(insuranceId), oldOtherComBaseMap.get(String.valueOf(insuranceId))); + } + } + insuranceArchivesOtherSchemePO.setOtherPaymentComBaseString(JSON.toJSONString(otherPaymentComBase)); + } else { + Map itemMap = findElement(singleAccount, welfareMap.get(insuranceId) + SalaryI18nUtil.getI18nLabel(0, "申报基数")); + if (itemMap != null) { + String itemValue = (String) itemMap.get(welfareMap.get(insuranceId) + SalaryI18nUtil.getI18nLabel(0, "申报基数")); + if (StringUtils.isNotBlank(itemValue)) { + otherPaymentBase.put(String.valueOf(insuranceId), itemValue); + } else if (oldOtherBaseMap != null && StringUtils.isNotBlank(oldOtherBaseMap.get(String.valueOf(insuranceId)))) { + otherPaymentBase.put(String.valueOf(insuranceId), oldOtherBaseMap.get(String.valueOf(insuranceId))); + } + } + } + + } + insuranceArchivesOtherSchemePO.setOtherPaymentBaseString(JSON.toJSONString(otherPaymentBase)); + } + return insuranceArchivesOtherSchemePO; + } + + public InsuranceArchivesBaseInfoPO buildBaseInfoPO(Long employeeId, List> singleAccount, Map paymentNameIdMap, Long creator, String runStatus, Boolean isExtEmp) { + if (employeeId == null) { + return null; + } + InsuranceArchivesBaseInfoPO insuranceArchivesBaseInfoPO = new InsuranceArchivesBaseInfoPO(); + insuranceArchivesBaseInfoPO.setEmployeeId(employeeId); + insuranceArchivesBaseInfoPO.setId(IdGenerator.generate()); + insuranceArchivesBaseInfoPO.setCreateTime(new Date()); + insuranceArchivesBaseInfoPO.setDeleteType(0); + insuranceArchivesBaseInfoPO.setCreator(creator); + insuranceArchivesBaseInfoPO.setRunStatus(runStatus); + insuranceArchivesBaseInfoPO.setUpdateTime(new Date()); + insuranceArchivesBaseInfoPO.setTenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY); + insuranceArchivesBaseInfoPO.setPaymentOrganization(paymentNameIdMap.get((String) findElement(singleAccount, SalaryI18nUtil.getI18nLabel(91497, "个税扣缴义务人")).get(SalaryI18nUtil.getI18nLabel(91497, "个税扣缴义务人")))); + if (isExtEmp) { + insuranceArchivesBaseInfoPO.setEmployeeType(1); + } + + return insuranceArchivesBaseInfoPO; + } + + public void handleImportData(List insuranceArchivesAccountPOS, SIArchiveImportParam param) { + List baseInfoPOS = insuranceArchivesAccountPOS.stream().filter(Objects::nonNull).map(InsuranceArchivesAccountPO::getBaseInfo).collect(Collectors.toList()); + //去除员工id+个税扣缴义务人下重复的数据 + baseInfoPOS = baseInfoPOS.stream() + .collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(f -> f.getPaymentOrganization() + "-" + f.getEmployeeId()))), ArrayList::new)); + //老数据map + Map oldSocialArchiveMap = getSocialArchiveMap(baseInfoPOS); + Map oldFundArchiveMap = getFundArchiveMap(baseInfoPOS); + Map oldOtherArchiveMap = getOtherArchiveMap(baseInfoPOS); + //导入社保档案 + List socialSchemePOS = insuranceArchivesAccountPOS.stream().filter(Objects::nonNull).map(InsuranceArchivesAccountPO::getSocial).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(socialSchemePOS)) { + //去除员工id+个税扣缴义务人下重复的数据 + socialSchemePOS = socialSchemePOS.stream() + .collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(f -> f.getPaymentOrganization() + "-" + f.getEmployeeId()))), ArrayList::new)); + + //生成福利档案基数调整历史记录 +// List adjustSocialHistoryPOList = siArchivesBiz.dealSocialBaseAdjustInfoList(socialSchemePOS, (long) user.getUID()); + List adjustSocialHistoryPOList = getSIArchivesService(user).dealSocialBaseAdjustInfoList(socialSchemePOS, (long) user.getUID()); + + //根据人员id和个税扣缴义务人id删除对应旧档案 + socialSchemePOS.forEach(getSocialSchemeMapper()::deleteByEmployeeIdAndPayOrg); + + //新建新档案 + List insuranceArchivesSocialSchemePOS = encryptUtil.encryptList(socialSchemePOS, InsuranceArchivesSocialSchemePO.class); + List> partition = Lists.partition(insuranceArchivesSocialSchemePOS, 100); + partition.forEach(getSocialSchemeMapper()::batchSave); + + //新建福利档案基数调整历史记录 +// siArchivesBiz.batchInsertAdjustHistory(adjustSocialHistoryPOList, user.getUID()); + getSIArchivesService(user).batchInsertAdjustHistory(adjustSocialHistoryPOList); + } + //导入公积金档案 + List fundSchemePOS = insuranceArchivesAccountPOS.stream().filter(Objects::nonNull).map(InsuranceArchivesAccountPO::getFund).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(fundSchemePOS)) { + //去除员工id+个税扣缴义务人下重复的数据 + fundSchemePOS = fundSchemePOS.stream() + .collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(f -> f.getPaymentOrganization() + "-" + f.getEmployeeId()))), ArrayList::new)); + + //生成福利档案基数调整历史记录 +// List adjustFundHistoryPOList = siArchivesBiz.dealFundBaseAdjustInfoList(fundSchemePOS, (long) user.getUID()); + List adjustFundHistoryPOList = getSIArchivesService(user).dealFundBaseAdjustInfoList(fundSchemePOS, (long) user.getUID()); + //根据人员id和个税扣缴义务人id删除对应档案 + fundSchemePOS.forEach(getFundSchemeMapper()::deleteByEmployeeIdAndPayOrg); + //新建新档案 + List insuranceArchivesFundSchemePOS = encryptUtil.encryptList(fundSchemePOS, InsuranceArchivesFundSchemePO.class); + List> partition = Lists.partition(insuranceArchivesFundSchemePOS, 100); + partition.forEach(getFundSchemeMapper()::batchSave); + //新建福利档案基数调整历史记录 +// siArchivesBiz.batchInsertAdjustHistory(adjustFundHistoryPOList, user.getUID()); + getSIArchivesService(user).batchInsertAdjustHistory(adjustFundHistoryPOList); + } + //导入其他福利档案 + List otherSchemePOS = insuranceArchivesAccountPOS.stream().filter(Objects::nonNull).map(InsuranceArchivesAccountPO::getOther).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(otherSchemePOS)) { + //去除员工id+个税扣缴义务人下重复的数据 + otherSchemePOS = otherSchemePOS.stream() + .collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(f -> f.getPaymentOrganization() + "-" + f.getEmployeeId()))), ArrayList::new)); + + //生成福利档案基数调整历史记录 +// List adjustOtherHistoryPOList = siArchivesBiz.dealOtherBaseAdjustInfoList(otherSchemePOS, (long) user.getUID()); + List adjustOtherHistoryPOList = getSIArchivesService(user).dealOtherBaseAdjustInfoList(otherSchemePOS, (long) user.getUID()); + + //根据人员id和个税扣缴义务人id删除对应档案 + otherSchemePOS.forEach(getOtherSchemeMapper()::deleteByEmployeeIdAndPayOrg); + //新建新档案 + List insuranceArchivesOtherSchemePOS = encryptUtil.encryptList(otherSchemePOS, InsuranceArchivesOtherSchemePO.class); + List> partition = Lists.partition(insuranceArchivesOtherSchemePOS, 100); + partition.forEach(getOtherSchemeMapper()::batchSave); + //新建福利档案基数调整历史记录 +// siArchivesBiz.batchInsertAdjustHistory(adjustOtherHistoryPOList, user.getUID()); + getSIArchivesService(user).batchInsertAdjustHistory(adjustOtherHistoryPOList); + } + //导入福利档案基础信息 +// List baseInfoPOS = insuranceArchivesAccountPOS.stream().filter(Objects::nonNull).map(InsuranceArchivesAccountPO::getBaseInfo).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(baseInfoPOS)) { +// baseInfoPOS = baseInfoPOS.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(InsuranceArchivesBaseInfoPO::getEmployeeId))), ArrayList::new)); +// //去除员工id+个税扣缴义务人下重复的数据 +// baseInfoPOS = baseInfoPOS.stream() +// .collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(f -> f.getPaymentOrganization() + "-" + f.getEmployeeId()))), ArrayList::new)); + //根据人员id和个税扣缴义务人id删除对应档案 + baseInfoPOS.forEach(getInsuranceBaseInfoMapper()::deleteByEmployeeIdAndPayOrg); + //分批批量删除 + List baseInfoEmployeeIds = baseInfoPOS.stream().map(InsuranceArchivesBaseInfoPO::getEmployeeId).collect(Collectors.toList()); +// List> employeeIdPartition = Lists.partition(baseInfoEmployeeIds, 100); +// employeeIdPartition.forEach(getInsuranceBaseInfoMapper()::batchDeleteByEmployeeIds); + //查询目标人员的剩余的福利档案基础信息(社保、公积金、其他福利档案id) +// List moreBaseInfoPOS = getInsuranceBaseInfoMapper().getInsuranceBaseInfoListByInsuranceDetail(baseInfoEmployeeIds); + List moreBaseInfoPOS = new ArrayList<>(); + List> partitionInfo = Lists.partition((List) baseInfoEmployeeIds, 1000); + partitionInfo.forEach(part -> moreBaseInfoPOS.addAll( + getInsuranceBaseInfoMapper().getInsuranceBaseInfoListByInsuranceDetail(part))); + List newInsuranceArchivesBaseInfoList = new ArrayList<>(); + //设置社保、公积金、其他福利档案id + for (InsuranceArchivesBaseInfoPO po : baseInfoPOS) { + InsuranceArchivesBaseInfoPO moreBaseInfo = moreBaseInfoPOS.stream().filter(s -> Objects.equals(s.getEmployeeId(), po.getEmployeeId()) && Objects.equals(s.getPaymentOrganization(), po.getPaymentOrganization())).findFirst().orElse(null); + po.setSocialArchivesId(moreBaseInfo.getSocialArchivesId()); + po.setFundArchivesId(moreBaseInfo.getFundArchivesId()); + po.setOtherArchivesId(moreBaseInfo.getOtherArchivesId()); + newInsuranceArchivesBaseInfoList.add(po); + } + //分批批量入库 + List> partition = Lists.partition(newInsuranceArchivesBaseInfoList, 100); + partition.forEach(getInsuranceBaseInfoMapper()::batchSave); + //记录操作日志 + //获取新数据map和老数据map + Map newSocialArchiveMap = getSocialArchiveMap(baseInfoPOS); + Map newFundArchiveMap = getFundArchiveMap(baseInfoPOS); + Map newOtherArchiveMap = getOtherArchiveMap(baseInfoPOS); + newInsuranceArchivesBaseInfoList.forEach(targetPO -> { + InsuranceArchivesSocialSchemePO targetSocialDetail = newSocialArchiveMap.get(targetPO.getPaymentOrganization() + "-" + targetPO.getEmployeeId()); + InsuranceArchivesFundSchemePO targetFundDetail = newFundArchiveMap.get(targetPO.getPaymentOrganization() + "-" + targetPO.getEmployeeId()); + InsuranceArchivesOtherSchemePO targetOtherDetail = newOtherArchiveMap.get(targetPO.getPaymentOrganization() + "-" + targetPO.getEmployeeId()); + DataCollectionEmployee empInfo = getSalaryEmployeeService(user).getEmployeeById(targetPO.getEmployeeId()); + TaxAgentPO taxAgentInfo = getTaxAgentMapper().getById(targetPO.getPaymentOrganization()); + if (targetSocialDetail != null) { + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(targetPO.getId())); + loggerContext.setTargetName(taxAgentInfo.getName() + "-" + empInfo.getUsername()); + loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "福利档案-社保明细导入")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "福利档案-社保明细导入") + ": " + taxAgentInfo.getName() + "-" + empInfo.getUsername()); + loggerContext.setOldValues(oldSocialArchiveMap.get(targetPO.getPaymentOrganization() + "-" + targetPO.getEmployeeId())); + loggerContext.setNewValues(targetSocialDetail); + SalaryElogConfig.siArchivesLoggerTemplate.write(loggerContext); + } + if (targetFundDetail != null) { + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(targetPO.getId())); + loggerContext.setTargetName(taxAgentInfo.getName() + "-" + empInfo.getUsername()); + loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "福利档案-公积金明细导入")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "福利档案-公积金明细导入") + ": " + taxAgentInfo.getName() + "-" + empInfo.getUsername()); + loggerContext.setOldValues(oldFundArchiveMap.get(targetPO.getPaymentOrganization() + "-" + targetPO.getEmployeeId())); + loggerContext.setNewValues(targetFundDetail); + SalaryElogConfig.siArchivesLoggerTemplate.write(loggerContext); + } + if (targetOtherDetail != null) { + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(targetPO.getId())); + loggerContext.setTargetName(taxAgentInfo.getName() + "-" + empInfo.getUsername()); + loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "福利档案-其他福利明细导入")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "福利档案-其他福利明细导入") + ": " + taxAgentInfo.getName() + "-" + empInfo.getUsername()); + loggerContext.setOldValues(oldOtherArchiveMap.get(targetPO.getPaymentOrganization() + "-" + targetPO.getEmployeeId())); + loggerContext.setNewValues(targetOtherDetail); + SalaryElogConfig.siArchivesLoggerTemplate.write(loggerContext); + } + }); + } + //新增人员范围(会自动生成人员档案) + if (CollectionUtils.isNotEmpty(param.getTaxAgentRanges())) { + param.getTaxAgentRanges().forEach(getTaxAgentManageRangeService(user)::save); + } + } + + private Map getSocialArchiveMap(List baseInfoPOS) { + Map map = new HashMap<>(); + if (baseInfoPOS.size() > 0) { + //遍历待更新的福利档案数据,对每组档案生成基数调整记录(基数单元未变化则忽略) + for (InsuranceArchivesBaseInfoPO po : baseInfoPOS) { + List archiveList = getSocialSchemeMapper().getSocialByEmployeeIdAndPayOrg(InsuranceArchivesEmployeePO.builder() + .paymentOrganization(po.getPaymentOrganization()).employeeId(po.getEmployeeId()).build()); + if (archiveList.size() == 1) { + //新增调整记录,变更 + encryptUtil.decryptList(archiveList, InsuranceArchivesSocialSchemePO.class); + map.put(po.getPaymentOrganization() + "-" + po.getEmployeeId(), archiveList.get(0)); + } else if (archiveList.size() > 1) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"社保档案存在冗余数据!")); + } + } + } + return map; + } + private Map getFundArchiveMap(List baseInfoPOS) { + Map map = new HashMap<>(); + if (baseInfoPOS.size() > 0) { + //遍历待更新的福利档案数据,对每组档案生成基数调整记录(基数单元未变化则忽略) + for (InsuranceArchivesBaseInfoPO po : baseInfoPOS) { + List archiveList = getFundSchemeMapper().getFundByEmployeeIdAndPayOrg(InsuranceArchivesEmployeePO.builder() + .paymentOrganization(po.getPaymentOrganization()).employeeId(po.getEmployeeId()).build()); + if (archiveList.size() == 1) { + //新增调整记录,变更 + encryptUtil.decryptList(archiveList, InsuranceArchivesFundSchemePO.class); + map.put(po.getPaymentOrganization() + "-" + po.getEmployeeId(), archiveList.get(0)); + } else if (archiveList.size() > 1) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"公积金档案存在冗余数据!")); + } + } + } + return map; + } + private Map getOtherArchiveMap(List baseInfoPOS) { + Map map = new HashMap<>(); + if (baseInfoPOS.size() > 0) { + //遍历待更新的福利档案数据,对每组档案生成基数调整记录(基数单元未变化则忽略) + for (InsuranceArchivesBaseInfoPO po : baseInfoPOS) { + List archiveList = getOtherSchemeMapper().getOtherByEmployeeIdAndPayOrg(InsuranceArchivesEmployeePO.builder() + .paymentOrganization(po.getPaymentOrganization()).employeeId(po.getEmployeeId()).build()); + if (archiveList.size() == 1) { + //新增调整记录,变更 + encryptUtil.decryptList(archiveList, InsuranceArchivesOtherSchemePO.class); + map.put(po.getPaymentOrganization() + "-" + po.getEmployeeId(), archiveList.get(0)); + } else if (archiveList.size() > 1) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"社保档案存在冗余数据!")); + } + } + } + return map; + } + + + /** + * 导出档案导入所需要的模板,可根据开关选择是否导出现有的档案数据 + * + * @param param 是否导出带档案数据的模板 + */ + @Override + public XSSFWorkbook exportTemplate(InsuranceArchivesListParam param) { + return getSIImportService().exportTemplate(param); + + } + + + /** + * 校验待新增的社保福利档案数据 + */ + @Override + public Map checkSIArchiveAdd(SIArchiveImportParam param) { + param.setAddData(false); + return processAddSIArchive(param); + } + + /** + * 新增社保福利档案 + */ + @Override + public Map addSIArchive(SIArchiveImportParam param) { + param.setAddData(true); + return processAddSIArchive(param); + } + + private Map processAddSIArchive(SIArchiveImportParam param) { + + ValidUtil.doValidator(param); + param.setProcess(true); + + if (StringUtils.isBlank(param.getRunStatus())) { + throw new SalaryRunTimeException("福利档案执行状态未在导入条件设置中添加!"); + } +// List excelSheets = message.getBatchFile().getExcelSheets(); + // 租户key +// String tenantKey = message.getTenantKey().toLowerCase(); + //操作员id + Long creator = (long) user.getUID(); + //获取所有福利类型的id-name结合 + Map schemeNameIdMap = schemeNameIdMap(); + Map welfareMap = welfareMap(); + + // 获取所有个税扣缴义务人的名称和id的map + Map paymentNameIdMap = getTaxAgentService().listAll().stream().collect(Collectors.toMap(TaxAgentPO::getName, TaxAgentPO::getId)); + + //获取所有个税扣缴义务人树型 + List taxAgentManageRangeEmployeeTree = getTaxAgentService().listTaxAgentAndEmployeeTree(); + + // 获取所有人员信息 + List employeeByIds = getSalaryEmployeeService(user).listEmployee(); + int total = 0; + + int index = 0; + int successCount = 0; + int errorCount = 0; + + // 待导入数据 + List insuranceArchivesAccountPOS = new ArrayList<>(); + + // 待导入数据 + InputStream fileInputStream = null; + try { + // 表头 + List headers = new ArrayList<>(); + if (param.getImportDatas().size() > 0) { + Map getHeadersMap = param.getImportDatas().get(0); + for (Map.Entry entry : getHeadersMap.entrySet()) { + headers.add(entry.getKey()); + } + } else { + throw new SalaryRunTimeException("新增福利档案数据为空!"); + } + + // 错误sheet数据 + List> errorData = new LinkedList<>(); + // 错误提示 + List> excelComments = new LinkedList<>(); + + // 处理数值 + List> data = param.getImportDatas(); + total = data.size(); + + //当前sheel的单行记录 + Map map; + for (int i = 0; i < data.size(); i++) { + index += 1; + map = data.get(i); + boolean isError; + List> singleAccount = new ArrayList<>(); + for (int j = 0; j < headers.size(); j++) { + //组装单条数据基础数据 + String key = headers.get(j); + if (key == null) { + continue; + } + Map cellData = new HashMap<>(); + cellData.put(key.toString(), Optional.ofNullable(map.get(key.toString())).orElse("").toString()); + cellData.put("index", j); + singleAccount.add(cellData); + } + + isError = singleAccountCheck(singleAccount, welfareMap, insuranceArchivesAccountPOS, employeeByIds, excelComments, errorCount + 1, schemeNameIdMap, paymentNameIdMap, creator, i + 2, taxAgentManageRangeEmployeeTree, param); + if (isError) { + errorCount += 1; + // 添加错误数据 + errorData.add(map); + } else { + successCount += 1; + } +// salaryBatchService.sendImportRate(message.getBizId(), total, index); + } + + // 如果sheet包含错误数据 +// if (CollectionUtils.isNotEmpty(errorData)) { +// salaryBatchService.createErrorExcelSheet(headers, errorData, excelSheet.getName(), excelComments, errorExcelSheets); +// } + + // 数据入库处理 + if (param.isAddData()) { + handleImportData(insuranceArchivesAccountPOS, param); + } + // 发送导入回调信息 +// salaryBatchService.sendImportCallBackInfo(message, successCount, errorCount, errorExcelSheets); + + Map apidatas = new HashMap(); + apidatas.put("successCount", successCount); + apidatas.put("errorCount", errorCount); + apidatas.put("errorData", excelComments); + return apidatas; + } finally { + IOUtils.closeQuietly(fileInputStream); + } + } + + @Override + public List updateSchemeDetail(List schemeDetailList) { + List errorInfo = new ArrayList<>(); + if (schemeDetailList.size() > 0) { + log.info("待处理方明明细数量:{}", schemeDetailList.size()); + List toDealSchemeDetailList = schemeDetailList.stream().filter(f -> f.getPrimaryId() != null).collect(Collectors.toList()); + log.info("未设置方案id的方明明细无法处理,数量:{}", schemeDetailList.size() - toDealSchemeDetailList.size()); + + //按照方案id分组 + Map> schemeDetailMap = toDealSchemeDetailList + .stream().collect(Collectors.groupingBy(InsuranceSchemeDetailUpdateParam::getPrimaryId)); + + schemeDetailMap.forEach((k, v) -> { + updateSchemeDetailByPrimaryId(k, v, errorInfo); + }); + + } + return errorInfo; + } + + public List updateSchemeDetailByPrimaryId(Long primaryId, List schemeDetailList, List errorInfo) { + try { + Map schemeDetailUpdateMap = new HashMap<>(); + schemeDetailList.forEach(f -> { + schemeDetailUpdateMap.put(f.getInsuranceId() + "-" + f.getPaymentScope(), f); + }); +// List schemeDetailPOS = siSchemeBiz.listByPrimaryId(primaryId); + List schemeDetailPOS = listByPrimaryId(primaryId); + //替换修改字段 + if (schemeDetailPOS.size() > 0) { + schemeDetailPOS.forEach(f -> { + if (schemeDetailUpdateMap.get(f.getInsuranceId() + "-" + f.getPaymentScope()) != null) { + InsuranceSchemeDetailUpdateParam schemeDetailUpdateParam = schemeDetailUpdateMap.get(f.getInsuranceId() + "-" + f.getPaymentScope()); + BeanUtils.copyProperties(schemeDetailUpdateParam, f); + f.setUpdateTime(new Date()); + } + }); + encryptUtil.encryptList(schemeDetailPOS, InsuranceSchemeDetailPO.class); + schemeDetailPOS.forEach(getInsuranceSchemeDetailMapper()::updateAll); + + } else { + errorInfo.add("方案id:" + primaryId + "," + "表中不存在方案明细数据"); + } + } catch (Exception e) { + errorInfo.add("方案id:" + primaryId + "," + e.getMessage()); + } + return errorInfo; + } + /*****以下代码为SISchemeBiz中逻辑迁移,旨在减少Biz类的使用*****/ + + /** + * 获取社保方案 + * + * @param id + * @param welfareTypeEnum + * @return + */ + public InsuranceSchemeFormVO getForm(Long id, WelfareTypeEnum welfareTypeEnum) { + InsuranceSchemeDTO insuranceSchemeDTO = getSchemeFormDTO(welfareTypeEnum, id); + List insuranceSchemeDetailDTOList = getSchemeDetailFormDTO(welfareTypeEnum, id); + return InsuranceSchemeFormVO.builder().schemeBatch(insuranceSchemeDTO).schemeDetailList(insuranceSchemeDetailDTOList).build(); + } + + /** + * 获取方案主表信息 新建|详情 + * + * @param welfareTypeEnum 福利类型 + * @param id 方案主键id + * @return form + */ + private InsuranceSchemeDTO getSchemeFormDTO(WelfareTypeEnum welfareTypeEnum, Long id) { + InsuranceSchemeDTO insuranceSchemeDTO = InsuranceSchemeDTO.builder().paymentType(PaymentTypeEnum.SCHEME_TOWN).welfareType(welfareTypeEnum).build(); + if (id != null) { + InsuranceSchemePO insuranceSchemePO = getById(id); + SalaryAssert.notNull(insuranceSchemePO, SalaryI18nUtil.getI18nLabel(0,"福利方案不存在")); + //BeanUtils.copyProperties(insuranceSchemePO, insuranceSchemeDTO); + insuranceSchemeDTO.setId(insuranceSchemePO.getId()); + insuranceSchemeDTO.setPaymentArea(insuranceSchemePO.getPaymentArea()); + insuranceSchemeDTO.setRemarks(insuranceSchemePO.getRemarks()); + insuranceSchemeDTO.setSchemeName(insuranceSchemePO.getSchemeName()); + insuranceSchemeDTO.setPaymentType(SalaryEnumUtil.enumMatchByValue(insuranceSchemePO.getPaymentType(), PaymentTypeEnum.values(), PaymentTypeEnum.class)); + insuranceSchemeDTO.setWelfareType(welfareTypeEnum); + insuranceSchemeDTO.setSharedType(StringUtils.isBlank(insuranceSchemePO.getSharedType()) ? "0" : insuranceSchemePO.getSharedType()); + insuranceSchemeDTO.setTaxAgentIds(insuranceSchemePO.getTaxAgentIds()); + } + return insuranceSchemeDTO; + } + + /** + * 获取方案明细表集合 新建|详情 + * + * @param welfareTypeEnum 福利类型 + * @param id 方案主键id + * @return form + */ + public List getSchemeDetailFormDTO(WelfareTypeEnum welfareTypeEnum, Long id) { + List insuranceCategoryPOS = listByWelfareType(welfareTypeEnum.getValue()); + List insuranceSchemeDetailDTOList = new ArrayList<>(); + insuranceCategoryPOS.forEach(item -> { + PaymentScopeEnum[] paymentScopeEnums = SalaryEnumUtil.stringToEnums(item.getPaymentScope(), ","); + Arrays.stream(paymentScopeEnums).forEach(e -> { + InsuranceSchemeDetailDTO insuranceSchemeDetailDTO = InsuranceSchemeDetailDTO.builder().build(); + InsuranceSchemeDetailPO insuranceSchemeDetailPO = getByPPI(id, e.getValue(), item.getId()); + if (insuranceSchemeDetailPO == null) { + insuranceSchemeDetailDTO = InsuranceSchemeDetailDTO.builder() + .id((long) (Math.random() * 10000)) + .insuranceId(item.getId()) + .insuranceName(item.getInsuranceName()) + .paymentScope(e.getDefaultLabel()) + .rententionRule(String.valueOf(SalaryRoundingModeEnum.ROUNDING.getValue())) + .validNum(2) + .cycleSetting("000000000000") + .paymentCycle("0") + .accountType("0") + .build(); + if (Objects.equals(item.getDataType(), DataTypeEnum.SYSTEM.getValue())) { + insuranceSchemeDetailDTO.setIsPayment(true); + } else { + insuranceSchemeDetailDTO.setIsPayment(false); + } + } else { + //BeanUtils.copyProperties(insuranceSchemeDetailPO, insuranceSchemeDetailDTO); + insuranceSchemeDetailDTO.setEffectiveTime(insuranceSchemeDetailPO.getEffectiveTime()); + insuranceSchemeDetailDTO.setExpirationTime(insuranceSchemeDetailPO.getExpirationTime()); + insuranceSchemeDetailDTO.setId(insuranceSchemeDetailPO.getId()); + insuranceSchemeDetailDTO.setInsuranceId(insuranceSchemeDetailPO.getInsuranceId()); + insuranceSchemeDetailDTO.setPaymentScopeValue(insuranceSchemeDetailPO.getPaymentScope()); + insuranceSchemeDetailDTO.setPrimaryId(insuranceSchemeDetailPO.getPrimaryId()); + insuranceSchemeDetailDTO.setValidNum(insuranceSchemeDetailPO.getValidNum() == null ? 2 : insuranceSchemeDetailPO.getValidNum()); + + if (insuranceSchemeDetailPO.getIsPayment() != null) { + insuranceSchemeDetailDTO.setIsPayment(Objects.equals(insuranceSchemeDetailPO.getIsPayment(), IsPaymentEnum.YES.getValue())); + } + if (insuranceSchemeDetailPO.getPaymentCycle() != null) { + insuranceSchemeDetailDTO.setPaymentCycle(insuranceSchemeDetailPO.getPaymentCycle() + ""); + } else { + insuranceSchemeDetailDTO.setPaymentCycle("0"); + } + if (insuranceSchemeDetailPO.getAccountType() != null) { + insuranceSchemeDetailDTO.setAccountType(insuranceSchemeDetailPO.getAccountType() + ""); + } else { + insuranceSchemeDetailDTO.setAccountType("0"); + } + if (insuranceSchemeDetailPO.getCycleSetting() == null) { + insuranceSchemeDetailDTO.setCycleSetting("000000000000"); + } else { + insuranceSchemeDetailDTO.setCycleSetting(insuranceSchemeDetailPO.getCycleSetting()); + } + if (StringUtils.isNotBlank(insuranceSchemeDetailPO.getUpperLimit())) { + BigDecimal bigDecimal = new BigDecimal(insuranceSchemeDetailPO.getUpperLimit()); + insuranceSchemeDetailDTO.setUpperLimit(numberCheck(bigDecimal.toPlainString()) ? null : bigDecimal); + } + if (StringUtils.isNotBlank(insuranceSchemeDetailPO.getLowerLimit())) { + BigDecimal bigDecimal = new BigDecimal(insuranceSchemeDetailPO.getLowerLimit()); + insuranceSchemeDetailDTO.setLowerLimit(numberCheck(bigDecimal.toPlainString()) ? null : bigDecimal); + } + if (StringUtils.isNotBlank(insuranceSchemeDetailPO.getPaymentProportion())) { + BigDecimal bigDecimal = new BigDecimal(insuranceSchemeDetailPO.getPaymentProportion()); + insuranceSchemeDetailDTO.setPaymentProportion(numberCheck(bigDecimal.toPlainString()) ? null : bigDecimal); + } + if (StringUtils.isNotBlank(insuranceSchemeDetailPO.getFixedCost())) { + BigDecimal bigDecimal = new BigDecimal(insuranceSchemeDetailPO.getFixedCost()); + insuranceSchemeDetailDTO.setFixedCost(numberCheck(bigDecimal.toPlainString()) ? null : bigDecimal); + } + insuranceSchemeDetailDTO.setInsuranceName(item.getInsuranceName()); + insuranceSchemeDetailDTO.setRententionRule(String.valueOf(insuranceSchemeDetailPO.getRententionRule())); + insuranceSchemeDetailDTO.setPaymentScope(e.getDefaultLabel()); + + } + insuranceSchemeDetailDTO.setPaymentScopeValue(e.getValue()); + insuranceSchemeDetailDTOList.add(insuranceSchemeDetailDTO); + }); + }); + return insuranceSchemeDetailDTOList; + } + + /** + * 社保方案基础信息主表 + * + * @param id + * @return + */ + public InsuranceSchemePO getById(Long id) { + + InsuranceSchemePO insuranceSchemePO = getInsuranceSchemeMapper().getById(id); + return insuranceSchemePO; + } + + /** + * 根据福利类型获取 + * + * @param welfareType + * @return + */ + public List listByWelfareType(Integer welfareType) { + + List insuranceCategoryPOS = getICategoryMapper().listByWelfareType(welfareType, null); + return insuranceCategoryPOS; + } + + public boolean numberCheck(String number) { + return Pattern.compile("^0\\.[0]*").matcher(number).matches(); + } + + private InsuranceSchemeDetailPO getByPPI(Long primaryId, Integer paymentScope, Long insuranceId) { + + InsuranceSchemeDetailPO insuranceSchemeDetailPO = getInsuranceSchemeDetailMapper().getByPPI(primaryId, paymentScope, insuranceId); + encryptUtil.decrypt(insuranceSchemeDetailPO, InsuranceSchemeDetailPO.class); + return insuranceSchemeDetailPO; + + } + + /** + * 新增 + * + * @param saveParam + * @param employeeId + */ + public void save(InsuranceSchemeReqParam saveParam, long employeeId) { + + //保存福利项目主表 + saveParam.getInsuranceScheme().setSchemeName(StringUtils.trim(saveParam.getInsuranceScheme().getSchemeName())); + List listResult = getInsuranceSchemeMapper().listByName(saveParam.getInsuranceScheme().getSchemeName()); + SalaryAssert.isEmpty(listResult, SalaryI18nUtil.getI18nLabel(0,"该福利名称已经存在,福利名称系统全局唯一")); + + InsuranceSchemePO insuranceSchemePO = InsuranceSchemeBO.convert2BatchPO(saveParam.getInsuranceScheme(), employeeId); + if (insuranceSchemePO.getSharedType() == null) { + insuranceSchemePO.setSharedType(SharedTypeEnum.PUBLIC.getValue()); + } else { + if (insuranceSchemePO.getSharedType().equals(SharedTypeEnum.PRIVATE.getValue()) && StringUtils.isBlank(insuranceSchemePO.getTaxAgentIds())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"方案可见性为私有时,未设置可见范围")); + } + } + getInsuranceSchemeMapper().insert(insuranceSchemePO); + //记录操作日志 + List schemePOList = getInsuranceSchemeMapper().listByName(insuranceSchemePO.getSchemeName()); + InsuranceSchemePO targetPO = new InsuranceSchemePO(); + if (schemePOList != null && schemePOList.size() > 0) { + targetPO = schemePOList.get(0); + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(targetPO.getId())); + loggerContext.setTargetName(targetPO.getSchemeName()); + loggerContext.setOperateType(OperateTypeEnum.ADD.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "新增福利方案主表")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "福利方案基础信息") + ": " + targetPO.getSchemeName()); + loggerContext.setNewValues(targetPO); + SalaryElogConfig.siSchemeLoggerTemplate.write(loggerContext); + } + //保存福利项目明细表 + List insuranceSchemeDetailPOS = InsuranceSchemeBO.convertToInsuranceSchemeDetailPoList(saveParam.getInsuranceSchemeDetailList(), employeeId, insuranceSchemePO.getId()); + //加密入库 + encryptUtil.encryptList(insuranceSchemeDetailPOS, InsuranceSchemeDetailPO.class); + insuranceSchemeDetailPOS.forEach(getInsuranceSchemeDetailMapper()::insert); + //记录明细表操作日志 + if (insuranceSchemeDetailPOS.size() > 0) { + encryptUtil.decryptList(insuranceSchemeDetailPOS, InsuranceSchemeDetailPO.class); + + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(targetPO.getId())); + loggerContext.setTargetName(targetPO.getSchemeName()); + loggerContext.setOperateType(OperateTypeEnum.ADD.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "新增福利方案明细表")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "福利方案明细")); + insuranceSchemeDetailPOS.forEach(loggerContext::setNewValues); + SalaryElogConfig.siSchemeLoggerTemplate.write(loggerContext); + } + + } + + /** + * 更新 + * + * @param updateParam + * @param employeeId + */ + public String update(InsuranceSchemeReqParam updateParam, long employeeId) { + //查询是否存在福利方案 + InsuranceSchemePO insuranceSchemePO = getById(updateParam.getInsuranceScheme().getId()); + if (Objects.isNull(insuranceSchemePO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"福利方案不存在")); + } + //去除入参中方案名称的空格 + updateParam.getInsuranceScheme().setSchemeName(StringUtils.trim(updateParam.getInsuranceScheme().getSchemeName())); + //福利方案名称重复 + List insuranceSchemePOList = getInsuranceSchemeMapper().listByName(updateParam.getInsuranceScheme().getSchemeName()); + if (CollectionUtils.isNotEmpty(insuranceSchemePOList)) { + boolean repeat = insuranceSchemePOList.stream().anyMatch(item -> !Objects.equals(item.getId(), updateParam.getInsuranceScheme().getId())); + SalaryAssert.isTrue(!repeat, SalaryI18nUtil.getI18nLabel(0,"福利方案名称重复")); + } + + if (insuranceSchemePO.getSharedType() == null) { + insuranceSchemePO.setSharedType(SharedTypeEnum.PUBLIC.getValue()); + } else { + if (insuranceSchemePO.getSharedType().equals(SharedTypeEnum.PRIVATE.getValue()) && StringUtils.isBlank(insuranceSchemePO.getTaxAgentIds())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"方案可见性为私有时,未设置可见范围")); + } + } + //记录主表操作日志 + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(insuranceSchemePO.getId().toString()); + loggerContext.setTargetName(insuranceSchemePO.getSchemeName()); + loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "修改福利方案主表")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "福利方案基础信息") + ": " + insuranceSchemePO.getSchemeName()); +// loggerContext.setOldValues(insuranceSchemePO); + //更新福利方案主表 + InsuranceSchemePO insuranceSchemePO1 = InsuranceSchemeBO.buildInsuranceSchemePO(insuranceSchemePO, updateParam.getInsuranceScheme()); + getInsuranceSchemeMapper().update(insuranceSchemePO1); + //记录主表操作日志 + loggerContext.setNewValues(insuranceSchemePO1); + SalaryElogConfig.siSchemeLoggerTemplate.write(loggerContext); + // 查询原本的福利明细信息 + List oldInsuranceSchemeDetails = getInsuranceSchemeDetailMapper().queryInsuranceSchemeDetailList(updateParam.getInsuranceScheme().getId(), IsPaymentEnum.YES.getValue()); + // 本次福利明细 + List insuranceSchemeDetailPOS = InsuranceSchemeBO.convertToInsuranceSchemeDetailPoList(updateParam.getInsuranceSchemeDetailList(), employeeId, insuranceSchemePO.getId()); + + StringBuilder baseLimitStrBuilder = new StringBuilder(); + if (updateParam.getValidate() || updateParam.getChangeData()) { + // 查询本次修改了哪些类型的上下限 + List schemeDetailChangeLimitList = getChanceLimitSchemeDetailList(oldInsuranceSchemeDetails, insuranceSchemeDetailPOS); + // 对于不满足上下限的基数进行自动调整 + autoAdjustBaseByLimit(updateParam, schemeDetailChangeLimitList, insuranceSchemePO, baseLimitStrBuilder); + if (updateParam.getValidate() && StringUtils.isNotBlank(baseLimitStrBuilder.toString())) { + // 是校验且存在校验不通过的档案,返回前端确认 + return baseLimitStrBuilder.toString(); + } + } + + //更新福利方案明细表 先删后插 + getInsuranceSchemeDetailMapper().batchDeleteByPrimaryIds(Collections.singleton(updateParam.getInsuranceScheme().getId())); + //更新明细表 + encryptUtil.encryptList(insuranceSchemeDetailPOS, InsuranceSchemeDetailPO.class); + insuranceSchemeDetailPOS.forEach(getInsuranceSchemeDetailMapper()::insert); + + //记录明细表操作日志 + encryptUtil.decryptList(insuranceSchemeDetailPOS, InsuranceSchemeDetailPO.class); + LoggerContext insuranceSchemeDetailContext = new LoggerContext<>(); + insuranceSchemeDetailContext.setUser(user); + insuranceSchemeDetailContext.setTargetId(String.valueOf(insuranceSchemePO.getId())); + insuranceSchemeDetailContext.setTargetName(insuranceSchemePO.getSchemeName()); + insuranceSchemeDetailContext.setOperateType(OperateTypeEnum.UPDATE.getValue()); + insuranceSchemeDetailContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "修改福利方案明细表")); + insuranceSchemeDetailContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "福利方案明细")); + insuranceSchemeDetailPOS.forEach(insuranceSchemeDetailContext::setNewValues); + SalaryElogConfig.siSchemeLoggerTemplate.write(insuranceSchemeDetailContext); + return "success"; + } + + /** + * 对于不满足上下限的基数进行自动调整 + * @param schemeDetailChangeLimitList + * @param insuranceSchemePO + */ + private void autoAdjustBaseByLimit(InsuranceSchemeReqParam updateParam, List schemeDetailChangeLimitList, InsuranceSchemePO insuranceSchemePO, StringBuilder baseLimitStrBuilder) { + Map> insuranceSchemeDetailMap = SalaryEntityUtil.group2Map(schemeDetailChangeLimitList, InsuranceSchemeDetailPO::getPaymentScope); + List personChangeDeatilList = insuranceSchemeDetailMap.getOrDefault(PaymentScopeEnum.SCOPE_PERSON.getValue(), Collections.emptyList()); + List companyChangeDetailList = insuranceSchemeDetailMap.getOrDefault(PaymentScopeEnum.SCOPE_COMPANY.getValue(), Collections.emptyList()); + List runStatus = Arrays.asList(EmployeeStatusEnum.STAY_DEL.getValue(), EmployeeStatusEnum.PAYING.getValue(), EmployeeStatusEnum.STAY_DEL.getValue()); + // 获取该方案下的社保福利档案 + Integer welfareType = insuranceSchemePO.getWelfareType(); + if (welfareType.equals(WelfareTypeEnum.SOCIAL_SECURITY.getValue())) { + List needUpdateSocialArchiveList = new ArrayList<>(); + List insuranceArchivesSocialSchemePOS = getSocialSchemeMapper().listBySchemeId(insuranceSchemePO.getId(), runStatus); + encryptUtil.decryptList(insuranceArchivesSocialSchemePOS, InsuranceArchivesSocialSchemePO.class); + // 获取人员信息 + List empIds = insuranceArchivesSocialSchemePOS.stream().map(InsuranceArchivesSocialSchemePO::getEmployeeId).collect(Collectors.toList()); + List employeeList = getSalaryEmployeeService(user).listByIds(empIds); + Map employeeMap = SalaryEntityUtil.convert2Map(employeeList, DataCollectionEmployee::getEmployeeId); + // 社保 + insuranceArchivesSocialSchemePOS.forEach(archive -> { + Boolean[] changeFlag = {false}; + // 个人调整 + String socialPaymentBaseString = archive.getSocialPaymentBaseString(); + if (CollectionUtils.isNotEmpty(personChangeDeatilList)) { + socialPaymentBaseString = adaptWelBaseLimit(socialPaymentBaseString, personChangeDeatilList, changeFlag); + } + // 公司调整 + String socialPaymentComBaseString = archive.getSocialPaymentComBaseString(); + if (CollectionUtils.isNotEmpty(companyChangeDetailList)) { + socialPaymentComBaseString = adaptWelBaseLimit(socialPaymentComBaseString, companyChangeDetailList, changeFlag); + } + if (changeFlag[0]) { + DataCollectionEmployee employee = employeeMap.get(archive.getEmployeeId()); + baseLimitStrBuilder.append(employee == null ? archive.getEmployeeId() : employee.getUsername() + "\n"); + archive.setSocialPaymentBaseString(socialPaymentBaseString); + archive.setSocialPaymentComBaseString(socialPaymentComBaseString); + needUpdateSocialArchiveList.add(archive); + if (updateParam.getChangeData() && CollectionUtils.isNotEmpty(needUpdateSocialArchiveList)) { + // 更新 + encryptUtil.encrypt(archive, InsuranceArchivesSocialSchemePO.class); + getSocialSchemeMapper().updateById(archive); + } + } + }); + } else if (welfareType.equals(WelfareTypeEnum.ACCUMULATION_FUND.getValue())) { + List needUpdateFundArchiveList = new ArrayList<>(); + List insuranceArchivesFundSchemePOS = getFundSchemeMapper().listBySchemeId(insuranceSchemePO.getId(), runStatus); + encryptUtil.decryptList(insuranceArchivesFundSchemePOS, InsuranceArchivesFundSchemePO.class); + // 获取人员信息 + List empIds = insuranceArchivesFundSchemePOS.stream().map(InsuranceArchivesFundSchemePO::getEmployeeId).collect(Collectors.toList()); + List employeeList = getSalaryEmployeeService(user).listByIds(empIds); + Map employeeMap = SalaryEntityUtil.convert2Map(employeeList, DataCollectionEmployee::getEmployeeId); + // 公积金 + insuranceArchivesFundSchemePOS.forEach(archive -> { + Boolean[] changeFlag = {false}; + // 个人调整 + String fundPaymentBaseString = archive.getFundPaymentBaseString(); + if (CollectionUtils.isNotEmpty(personChangeDeatilList)) { + fundPaymentBaseString = adaptWelBaseLimit(fundPaymentBaseString, personChangeDeatilList, changeFlag); + } + // 公司调整 + String fundPaymentComBaseString = archive.getFundPaymentComBaseString(); + if (CollectionUtils.isNotEmpty(companyChangeDetailList)) { + fundPaymentComBaseString = adaptWelBaseLimit(fundPaymentComBaseString, companyChangeDetailList, changeFlag); + } + if (changeFlag[0]) { + DataCollectionEmployee employee = employeeMap.get(archive.getEmployeeId()); + baseLimitStrBuilder.append(employee == null ? archive.getEmployeeId() : employee.getUsername() + "\n"); + archive.setFundPaymentBaseString(fundPaymentBaseString); + archive.setFundPaymentComBaseString(fundPaymentComBaseString); + needUpdateFundArchiveList.add(archive); + if (updateParam.getChangeData() && CollectionUtils.isNotEmpty(needUpdateFundArchiveList)) { + // 更新 + encryptUtil.encrypt(archive, InsuranceArchivesFundSchemePO.class); + getFundSchemeMapper().updateById(archive); + } + } + }); + } else if (welfareType.equals(WelfareTypeEnum.OTHER.getValue())) { + List insuranceArchivesOtherSchemePOS = getOtherSchemeMapper().listBySchemeId(insuranceSchemePO.getId(), runStatus); + encryptUtil.decryptList(insuranceArchivesOtherSchemePOS, InsuranceArchivesOtherSchemePO.class); + List needUpdateOtherArchiveList = new ArrayList<>(); + // 获取人员信息 + List empIds = insuranceArchivesOtherSchemePOS.stream().map(InsuranceArchivesOtherSchemePO::getEmployeeId).collect(Collectors.toList()); + List employeeList = getSalaryEmployeeService(user).listByIds(empIds); + Map employeeMap = SalaryEntityUtil.convert2Map(employeeList, DataCollectionEmployee::getEmployeeId); + // 企业年金或其他福利 + insuranceArchivesOtherSchemePOS.forEach(archive -> { + Boolean[] changeFlag = {false}; + // 个人调整 + String otherPaymentBaseString = archive.getOtherPaymentBaseString(); + if (CollectionUtils.isNotEmpty(personChangeDeatilList)) { + otherPaymentBaseString = adaptWelBaseLimit(otherPaymentBaseString, personChangeDeatilList, changeFlag); + } + // 公司调整的 + String otherPaymentComBaseString = archive.getOtherPaymentComBaseString(); + if (CollectionUtils.isNotEmpty(companyChangeDetailList)) { + otherPaymentComBaseString = adaptWelBaseLimit(otherPaymentComBaseString, companyChangeDetailList, changeFlag); + } + if (changeFlag[0]) { + DataCollectionEmployee employee = employeeMap.get(archive.getEmployeeId()); + baseLimitStrBuilder.append(employee == null ? archive.getEmployeeId() : employee.getUsername() + "\n"); + archive.setOtherPaymentBaseString(otherPaymentBaseString); + archive.setOtherPaymentComBaseString(otherPaymentComBaseString); + needUpdateOtherArchiveList.add(archive); + if (updateParam.getChangeData() && CollectionUtils.isNotEmpty(needUpdateOtherArchiveList)) { + // 更新 + encryptUtil.encrypt(archive, InsuranceArchivesOtherSchemePO.class); + getOtherSchemeMapper().updateById(archive); + } + } + }); + } + } + + public String adaptWelBaseLimit(String paymentBaseString, List insuranceSchemeDetailPOList, Boolean[] changeFlag) { + + if (paymentBaseString == null) { + return null; + } + Map paymentBaseJson = JSON.parseObject(paymentBaseString, new HashMap().getClass()); + if (paymentBaseJson == null) { + return null; + } + Map insuranceSchemeDetailPOMap = SalaryEntityUtil.convert2Map(insuranceSchemeDetailPOList, InsuranceSchemeDetailPO::getInsuranceId); + List insuranceIdList = insuranceSchemeDetailPOList.stream().map(po -> po.getInsuranceId().toString()).collect(Collectors.toList()); + + Set paymentInsuranceIdList = paymentBaseJson.keySet(); + List needAddInsuranceIds = insuranceIdList.stream().filter(insuranceId -> !paymentInsuranceIdList.contains(insuranceId)).collect(Collectors.toList()); + needAddInsuranceIds.stream().forEach(insuranceId -> { + paymentBaseJson.put(insuranceId, "0.00"); + }); + + for (Map.Entry entry : paymentBaseJson.entrySet()) { + + //判断福利值是否为空/数字 + if (entry.getValue() == null || entry.getValue().length() == 0) { + continue; + } else if (!isNumeric(entry.getValue())) { + log.info("福利值非数字!"); + continue; + // throw new SalaryRunTimeException("福利值非数字"); + } + + if (!insuranceIdList.contains(entry.getKey())) { + // 没有修改上下限 + continue; + } + InsuranceSchemeDetailPO insuranceSchemeDetailPO = insuranceSchemeDetailPOMap.get(Long.valueOf(entry.getKey())); + if (insuranceSchemeDetailPO != null) { + + encryptUtil.decrypt(insuranceSchemeDetailPO, InsuranceSchemeDetailPO.class); + String lowerLimit = "0.000".equals(insuranceSchemeDetailPO.getLowerLimit()) ? null : insuranceSchemeDetailPO.getLowerLimit(); + String upperLimit = "0.000".equals(insuranceSchemeDetailPO.getUpperLimit()) ? null : insuranceSchemeDetailPO.getUpperLimit(); + if (lowerLimit != null && lowerLimit.length() > 0 && Double.parseDouble(entry.getValue()) < Double.parseDouble(lowerLimit)) { + //数值低于对应福利明细下限 + entry.setValue(lowerLimit); + changeFlag[0] = true; + } + if (upperLimit != null && upperLimit.length() > 0 && Double.parseDouble(entry.getValue()) > Double.parseDouble(upperLimit)) { + //数值高于对应福利明细上限 + entry.setValue(upperLimit); + changeFlag[0] = true; + } + } + } + return JSON.toJSONString(paymentBaseJson); + } + + /** + * 判断字符串是否为整数或者小数或者负数 + */ + public static boolean isNumeric(String str){ + + Pattern pattern = Pattern.compile("^-?\\d+(\\.\\d+)?$"); + Matcher isNum = pattern.matcher(str); + if (!isNum.matches()) { + return false; + } + return true; + + } + + /** + * 获取修改了哪些明细项的上限和下限 + * @param oldInsuranceSchemeDetails + * @param newInsuranceSchemeDetails + * @return + */ + private List getChanceLimitSchemeDetailList(List oldInsuranceSchemeDetails, List newInsuranceSchemeDetails) { + List schemeDetailChangeLimitList = new ArrayList<>(); + // key: 福利项id-缴纳范围 + Map oldInsuranceSchemeDetailMap = SalaryEntityUtil.convert2Map(oldInsuranceSchemeDetails, d -> d.getInsuranceId() + "-" + d.getPaymentScope()); + newInsuranceSchemeDetails.stream() + .filter(detail -> detail.getIsPayment().equals(NumberUtils.INTEGER_ONE)) + .forEach(detail -> { + boolean changeFlag = false; + InsuranceSchemeDetailPO oldInsuranceSchemeDetailPO = oldInsuranceSchemeDetailMap.get(detail.getInsuranceId() + "-" + detail.getPaymentScope()); + if (oldInsuranceSchemeDetailPO == null) { + changeFlag = true; + } else { + if (!oldInsuranceSchemeDetailPO.getUpperLimit().equals(detail.getUpperLimit())) { + changeFlag = true; + } + if (!oldInsuranceSchemeDetailPO.getLowerLimit().equals(detail.getLowerLimit())) { + changeFlag = true; + } + } + if (changeFlag) { + schemeDetailChangeLimitList.add(detail); + } + }); + return schemeDetailChangeLimitList; + } + + public int checkBeforeDeleteSocialscheme(Map params) { + return getSIAccountUtilMapper().checkBeforeDeleteSocialscheme((Collection) params.get("ids")).get(0).getNum(); + } + + public int checkBeforeDeleteAccumulationfund(Map params) { + return getSIAccountUtilMapper().checkBeforeDeleteAccumulationfund((Collection) params.get("ids")).get(0).getNum(); + } + + public int checkBeforeDeleteOtherscheme(Map params) { + return getSIAccountUtilMapper().checkBeforeDeleteOtherscheme((Collection) params.get("ids")).get(0).getNum(); + } + + public int checkBeforeDeleteBill(Map params, Integer welfareTypeId) { + return getSIAccountUtilMapper().checkBeforeDeleteBill((Collection) params.get("ids"), welfareTypeId).get(0).getNum(); + } + + public void deleteSocialscheme(Map params) { + + Collection schemeIds = (Collection) params.get("ids"); + List targetPoList = getInsuranceSchemeMapper().listBySchemeIds(schemeIds); + List targetDetailPoList = getInsuranceSchemeDetailMapper().listBySchemeIds(schemeIds); + getInsuranceSchemeMapper().deleteByIds(schemeIds); + getInsuranceSchemeDetailMapper().deleteByIds(schemeIds); + + //记录操作日志 + Map> targetDetailMap = targetDetailPoList.stream() + .collect(Collectors.groupingBy(InsuranceSchemeDetailPO::getPrimaryId)); + if (targetPoList.size() > 0) { + targetPoList.forEach(targetPO -> { + //记录主表操作日志 + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(targetPO.getId())); + loggerContext.setTargetName(targetPO.getSchemeName()); + loggerContext.setOperateType(OperateTypeEnum.DELETE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "删除福利方案主表")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "删除福利方案") + ": " + targetPO.getSchemeName()); + loggerContext.setNewValues(targetPO); + SalaryElogConfig.siSchemeLoggerTemplate.write(loggerContext); + //记录明细表操作日志 + List targetDetails = targetDetailMap.get(targetPO.getId()); + encryptUtil.decryptList(targetDetails, InsuranceSchemeDetailPO.class); + if (targetDetails != null && targetDetails.size() > 0) { + LoggerContext detailLoggerContext = new LoggerContext<>(); + detailLoggerContext.setUser(user); + detailLoggerContext.setTargetId(String.valueOf(targetPO.getId())); + detailLoggerContext.setTargetName(targetPO.getSchemeName()); + detailLoggerContext.setOperateType(OperateTypeEnum.DELETE.getValue()); + detailLoggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "删除福利方案明细")); + detailLoggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "福利方案明细")); + targetDetails.forEach(detailLoggerContext::setNewValues); + SalaryElogConfig.siSchemeLoggerTemplate.write(detailLoggerContext); + } + }); + } + + } + + /** + * 复制方案 + * + * @param id + * @param schemeName + * @param employeeId + */ + public void copy(Long id, String schemeName, long employeeId) { + //去除入参中方案名称的空格 + schemeName = StringUtils.trim(schemeName); + List listResult = getInsuranceSchemeMapper().listByName(schemeName); + SalaryAssert.isEmpty(listResult, SalaryI18nUtil.getI18nLabel(0,"方案名称重复")); + if (Objects.isNull(id)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"方案id为空")); + } + if (Objects.isNull(schemeName)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"复制方案名为空")); + } + InsuranceSchemePO insuranceSchemePO = getById(id); + if (Objects.isNull(insuranceSchemePO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"方案不存在")); + } + if (insuranceSchemePO.getSchemeName().equals(schemeName)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"方案名称重复")); + } + InsuranceSchemePO batchPO = InsuranceSchemePO.builder() + .creator(employeeId) + .createTime(new Date()) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .schemeName(schemeName) + .paymentArea(insuranceSchemePO.getPaymentArea()) + .updateTime(new Date()) + .deleteType(DeleteTypeEnum.NOT_DELETED.getValue()) + .paymentType(insuranceSchemePO.getPaymentType()) + .remarks(insuranceSchemePO.getRemarks()) + .welfareType(insuranceSchemePO.getWelfareType()) + .isUse(insuranceSchemePO.getIsUse()) + .build(); + getInsuranceSchemeMapper().insert(batchPO); + //记录操作日志 + List schemePOList = getInsuranceSchemeMapper().listByName(insuranceSchemePO.getSchemeName()); + InsuranceSchemePO targetPO = new InsuranceSchemePO(); + if (schemePOList != null && schemePOList.size() > 0) { + targetPO = schemePOList.get(0); + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(targetPO.getId())); + loggerContext.setTargetName(targetPO.getSchemeName()); + loggerContext.setOperateType(OperateTypeEnum.ADD.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "复制新增福利方案主表")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "福利方案基础信息") + ": " + targetPO.getSchemeName()); + loggerContext.setNewValues(targetPO); + SalaryElogConfig.siSchemeLoggerTemplate.write(loggerContext); + } + List detailList = getInsuranceSchemeDetailMapper().queryListBySchemeId(id); + detailList = encryptUtil.decryptList(detailList,InsuranceSchemeDetailPO.class); + if (CollectionUtils.isNotEmpty(detailList)) { + List detailPOS = detailList.stream().map(item -> InsuranceSchemeDetailPO.builder() + .creator(employeeId) + .createTime(new Date()) + .deleteType(DeleteTypeEnum.NOT_DELETED.getValue()) + .effectiveTime(item.getEffectiveTime()) + .expirationTime(item.getExpirationTime()) + .fixedCost(item.getFixedCost()) + .insuranceId(item.getInsuranceId()) + .isPayment(item.getIsPayment()) + .lowerLimit(item.getLowerLimit()) + .paymentScope(item.getPaymentScope()) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .paymentProportion(item.getPaymentProportion()) + .updateTime(new Date()) + .primaryId(batchPO.getId()) + .rententionRule(item.getRententionRule()) + .upperLimit(item.getUpperLimit()) + .validNum(item.getValidNum()==null?2:item.getValidNum()) + .build() + ).collect(Collectors.toList()); + + //加密入库 + encryptUtil.encryptList(detailPOS, InsuranceSchemeDetailPO.class); + detailPOS.forEach(getInsuranceSchemeDetailMapper()::insert); + //记录明细表操作日志 + if (detailPOS.size() > 0) { + encryptUtil.decryptList(detailPOS, InsuranceSchemeDetailPO.class); + + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(targetPO.getId())); + loggerContext.setTargetName(targetPO.getSchemeName()); + loggerContext.setOperateType(OperateTypeEnum.ADD.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "复制新增福利方案明细表")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "福利方案明细")); + detailPOS.forEach(loggerContext::setNewValues); + SalaryElogConfig.siSchemeLoggerTemplate.write(loggerContext); + } + } + + } + + /** + * 社保方案基础信息明细表 + * + * @param primaryId + * @return + */ + public List listByPrimaryId(Long primaryId) { + + List insuranceSchemeDetailPOS = getInsuranceSchemeDetailMapper().queryListBySchemeId(primaryId); + encryptUtil.decryptList(insuranceSchemeDetailPOS, InsuranceSchemeDetailPO.class); + return insuranceSchemeDetailPOS; + } + + /** + * 获取所有方案 + * + * @return + */ + @Override + public List listAll(){ + + List insuranceSchemePOList = getInsuranceSchemeMapper().listAll(); + return insuranceSchemePOList; + } + + /*****以上代码为SISchemeBiz中方法逻辑迁移,旨在减少Biz类的使用*****/ +} diff --git a/src/com/engine/salary/service/impl/SalaryAcctCalcServiceImpl.java b/src/com/engine/salary/service/impl/SalaryAcctCalcServiceImpl.java new file mode 100644 index 000000000..c48450772 --- /dev/null +++ b/src/com/engine/salary/service/impl/SalaryAcctCalcServiceImpl.java @@ -0,0 +1,648 @@ +//package com.engine.salary.service.impl; +// +//import com.engine.salary.cache.SalaryCacheKey; +//import com.engine.salary.constant.SalaryDefaultTenantConstant; +//import com.engine.salary.entity.datacollection.DataCollectionEmployee; +//import com.engine.salary.entity.salaryacct.bo.*; +//import com.engine.salary.entity.salaryacct.dto.SalaryAcctRateDTO; +//import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO; +//import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO; +//import com.engine.salary.entity.salaryacct.po.SalaryAcctResultPO; +//import com.engine.salary.entity.salaryformula.ExpressFormula; +//import com.engine.salary.entity.salaryitem.po.SalaryItemPO; +//import com.engine.salary.service.*; +//import com.engine.salary.util.SalaryEntityUtil; +//import com.google.common.collect.Lists; +//import com.google.common.collect.Maps; +//import com.googlecode.aviator.Expression; +//import com.weaver.common.distribution.genid.IdGenerator; +//import com.weaver.common.elog.dto.LoggerContext; +//import com.weaver.common.elog.util.Util; +//import com.weaver.common.hrm.domain.employee.HrmStatus; +//import com.weaver.datasecurity.interceptor.DSTenantKeyThreadVar; +//import com.weaver.excel.formula.api.entity.FormulaVar; +//import com.weaver.excel.formula.entity.parameter.standard.ExcelResult; +//import com.weaver.framework.util.JsonUtil; +//import com.weaver.hrm.salary.common.LocalDateRange; +//import com.weaver.hrm.salary.constant.SalaryFormulaFieldConstant; +//import com.weaver.hrm.salary.entity.customdata.param.CustomDataEmployeeQueryParam; +//import com.weaver.hrm.salary.entity.customdata.po.CustomDataEmployeePO; +//import com.weaver.hrm.salary.entity.customdata.po.CustomDataRecordPO; +//import com.weaver.hrm.salary.entity.datacollection.dto.AttendQuoteDataDTO; +//import com.weaver.hrm.salary.entity.datacollection.po.AddUpDeductionPO; +//import com.weaver.hrm.salary.entity.datacollection.po.AddUpSituationPO; +//import com.weaver.hrm.salary.entity.datacollection.po.OtherDeductionPO; +//import com.weaver.hrm.salary.entity.extemployee.po.ExtEmployeePO; +//import com.weaver.hrm.salary.entity.salaryacct.bo.*; +//import com.weaver.hrm.salary.entity.salaryacct.po.*; +//import com.weaver.hrm.salary.entity.salaryarchive.dto.SalaryArchiveDataDTO; +//import com.weaver.hrm.salary.entity.salarysob.dto.SalarySobCycleDTO; +//import com.weaver.hrm.salary.entity.salarysob.po.SalarySobAdjustRulePO; +//import com.weaver.hrm.salary.entity.salarysob.po.SalarySobBackItemPO; +//import com.weaver.hrm.salary.entity.salarysob.po.SalarySobItemPO; +//import com.weaver.hrm.salary.entity.salarysob.po.SalarySobPO; +//import com.weaver.hrm.salary.enums.OperateTypeEnum; +//import com.weaver.hrm.salary.enums.salaryaccounting.EmployeeTypeEnum; +//import com.weaver.hrm.salary.enums.salaryaccounting.SalaryAcctRecordStatusEnum; +//import com.weaver.hrm.salary.enums.salaryitem.SalaryDataTypeEnum; +//import com.weaver.hrm.salary.enums.salaryitem.SalaryFormulaReferenceEnum; +//import com.weaver.hrm.salary.enums.salaryitem.SalaryRoundingModeEnum; +//import com.weaver.hrm.salary.enums.salarysob.IncomeCategoryEnum; +//import com.weaver.hrm.salary.enums.sicategory.DeleteTypeEnum; +//import com.weaver.hrm.salary.exception.SalaryRunTimeException; +//import com.weaver.hrm.salary.service.*; +//import com.weaver.hrm.salary.util.SalaryI18nUtil; +//import com.weaver.util.threadPool.ThreadPoolUtil; +//import com.weaver.util.threadPool.constant.ModulePoolEnum; +//import com.weaver.util.threadPool.entity.LocalRunnable; +//import lombok.extern.slf4j.Slf4j; +//import org.apache.commons.collections4.CollectionUtils; +//import org.apache.commons.collections4.MapUtils; +//import org.apache.commons.lang3.StringUtils; +//import org.apache.commons.lang3.math.NumberUtils; +//import org.springframework.transaction.annotation.Transactional; +// +//import java.math.BigDecimal; +//import java.math.RoundingMode; +//import java.time.LocalDateTime; +//import java.time.Month; +//import java.util.*; +//import java.util.concurrent.BlockingDeque; +//import java.util.concurrent.CountDownLatch; +//import java.util.concurrent.LinkedBlockingDeque; +//import java.util.stream.Collectors; +// +///** +// * 薪资核算 +// * +// *

Copyright: Copyright (c) 2022

+// *

Company: 泛微软件

+// * +// * @author qiantao +// * @version 1.0 +// **/ +//@Slf4j +//public class SalaryAcctCalcServiceImpl implements SalaryAcctCalcService { +// +// +// private SalaryAcctRecordService salaryAcctRecordService; +// +// private SalarySobItemService salarySobItemService; +// +//// private SalarySobBackItemService salarySobBackItemService; +// +// private SalarySobAdjustRuleService salarySobAdjustRuleService; +// +// private SalaryFormulaService salaryFormulaService; +// +// private SalaryItemService salaryItemService; +// +// private SalaryAcctEmployeeService salaryAcctEmployeeService; +// +// private SalaryArchiveService salaryArchiveService; +// +// private AddUpSituationService addUpSituationService; +// +// private AddUpDeductionService addUpDeductionService; +// +// private OtherDeductionService otherDeductionService; +// +// private AttendQuoteDataService attendQuoteDataService; +// +// private SIAccountService siAccountService; +// +// private SalaryCacheService salaryCacheService; +// +//// private CustomDataRecordService customDataRecordService; +// +//// private CustomDataEmployeeService customDataEmployeeService; +// +//// private HrmCommonEmployeeService hrmCommonEmployeeService; +// +//// private ExtEmployeeService extEmployeeService; +// +//// private SalaryAcctResultValueService salaryAcctResultValueService; +// +// +// private SalarySobService salarySobService; +// +//// private SalaryAcctSobConfigService salaryAcctSobConfigService; +// +// +// @Override +// public void calcByRecordId(Long salaryAcctRecordId, DataCollectionEmployee simpleEmployee) throws Exception { +// calcByEmployeeIds(salaryAcctRecordId, Collections.emptyList(), simpleEmployee); +// } +// +// @Override +// @Transactional(rollbackFor = Exception.class) +// public void calcByEmployeeIds(Long salaryAcctRecordId, Collection salaryAcctEmployeeIds, DataCollectionEmployee simpleEmployee) throws Exception { +// SalaryAcctRateDTO salaryAcctRate = new SalaryAcctRateDTO("" + salaryAcctRecordId); +// try { +// String tenantKey = SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY; +// // 查询本次核算的薪资核算人员 +// List salaryAcctEmployees; +// if (CollectionUtils.isEmpty(salaryAcctEmployeeIds)) { +// salaryAcctEmployees = salaryAcctEmployeeService.listBySalaryAcctRecordId(salaryAcctRecordId); +// } else { +// salaryAcctEmployees = salaryAcctEmployeeService.listByIds(salaryAcctEmployeeIds); +// } +// // 初始化核算进度(总数+1是因为所有人员核算完成后,数据保存入库还需要一定的时间) +// salaryAcctRate.setTotalQty(salaryAcctEmployees.size() + 1); +// salaryCacheService.set(SalaryCacheKey.ACCT_PROGRESS + salaryAcctRate.getIndex(), salaryAcctRate); +// // 查询薪资核算记录 +// SalaryAcctRecordPO salaryAcctRecord = salaryAcctRecordService.getById(salaryAcctRecordId); +// // 检查是否能够核算 +// checkBeforeCalc(salaryAcctRecord, salaryAcctEmployees); +// // 加载函数 +//// salaryFormulaService.initFunction(); +// // 构建核算上下文 +// SalaryCalcContext salaryCalcContext = loadContext(salaryAcctRecord, simpleEmployee); +// // 分批核算 +// List> salaryAcctEmployeePartition = SalaryAcctEmployeeBO.partitionByEmployeeId(salaryAcctEmployees); +// // 监控子线程的任务执行 +// CountDownLatch childMonitor = new CountDownLatch(salaryAcctEmployeePartition.size()); +// // 记录子线程的执行结果 +// BlockingDeque blockingDeque = new LinkedBlockingDeque<>(salaryAcctEmployeePartition.size()); +// for (List partSalaryAcctEmployees : salaryAcctEmployeePartition) { +// LocalRunnable localRunnable = new LocalRunnable() { +// @Override +// public void execute() { +// calc(salaryCalcContext, partSalaryAcctEmployees, childMonitor, blockingDeque, simpleEmployee); +// } +// }; +// ThreadPoolUtil.fixedPoolExecute(ModulePoolEnum.OTHER, "salaryAcctCalculate", localRunnable); +// } +// // 等待核算结束 +// childMonitor.await(); +// // 处理核算结果 +// handleCalcResult(blockingDeque, salaryAcctRecordId, salaryAcctEmployeeIds, tenantKey); +// // 记录日志 +// writeLog(salaryAcctRecordId, tenantKey); +// // 核算结束,更新进度 +// salaryAcctRate.setFinish(true).setCalcQty(salaryAcctEmployees.size()).setRate(BigDecimal.ONE); +// } finally { +// // 更新进度 +// salaryCacheService.set(SalaryCacheKey.ACCT_PROGRESS + salaryAcctRate.getIndex(), salaryAcctRate); +// } +// } +// +// private void calc(SalaryCalcContext salaryCalcContext, +// List salaryAcctEmployees, +// CountDownLatch childMonitor, +// BlockingDeque blockingDeque, +// DataCollectionEmployee simpleEmployee) { +// try { +// // 数据库字段加密用 +// LocalDateTime now = LocalDateTime.now(); +// // 加载公式计算时所需要的变量 +// SalaryCalcEmployeeContext salaryCalcEmployeeContext = loadEmployeeContext(salaryCalcContext, salaryAcctEmployees, simpleEmployee.getTenantKey()); +// // 对薪资核算人员进行分组,如果是合并计算(工资薪金、劳务一起计算)的话,会存在工资薪金和劳务费用的项目存在相互引用,所以相关联的人员要在同一组进行核算 +// Map> salaryAcctEmployeeMap = SalaryEntityUtil.group2Map(salaryAcctEmployees, SalaryAcctEmployeePO::getId); +//// if (salaryCalcContext.getSalarySobCycle().getIncomeCategories().size() > 1) { +//// salaryAcctEmployeeMap = SalaryEntityUtil.group2Map(salaryAcctEmployees, SalaryAcctEmployeePO::getEmployeeId); +//// } +// // 计算公式 +// int calcQty = 0; +// List newSalaryAcctResultValues = Lists.newArrayListWithExpectedSize(salaryAcctEmployees.size()); +// for (Map.Entry> entry : salaryAcctEmployeeMap.entrySet()) { +// // 获取锁定的薪资项目 +// Set lockSalaryItemIds = new HashSet<>(Collections.emptySet()); +// for (SalaryAcctEmployeePO salaryAcctEmployee : entry.getValue()) { +// SalaryAcctResultPO noDecryptSalaryAcctResultValue = salaryCalcEmployeeContext.getNoDecryptAcctResultValueMap().get(salaryAcctEmployee.getId()); +//// if (noDecryptSalaryAcctResultValue != null) { +//// lockSalaryItemIds.addAll(noDecryptSalaryAcctResultValue.getLockSalaryItemIds()); +//// } +// } +// Map> incomeCategoryResultValueMap = Maps.newHashMap(); +// Map incomeCategoryAcctEmployeeMap = SalaryEntityUtil.convert2Map(entry.getValue(), SalaryAcctEmployeePO::getIncomeCategory); +// // 根据解析好的公式计算优先级计算公式 +// for (List formulaPriority : salaryCalcContext.getSalaryCalcFormulaContext().getSalaryCalcFormulas()) { +// for (SalaryCalcFormula salaryCalcFormula : formulaPriority) { +// SalaryAcctEmployeePO salaryAcctEmployee; +// if (Objects.equals(salaryCalcFormula.getIncomeCategory(), "0")) { +// salaryAcctEmployee = SalaryEntityUtil.findFirst(entry.getValue()); +// } else { +// salaryAcctEmployee = incomeCategoryAcctEmployeeMap.get(salaryCalcFormula.getIncomeCategory()); +// } +// if (salaryAcctEmployee == null) { +// continue; +// } +// // 找出需要计算的公式 +// SalaryItemPO salaryItem = salaryCalcContext.getSalaryCalcFormulaContext().getSalaryItemMap().get(salaryCalcFormula.getSalaryItemId()); +// ExpressFormula expressFormula = salaryCalcContext.getSalaryCalcFormulaContext().getExpressFormulaMap().get(salaryCalcFormula.getFormulaId()); +// Expression expression = salaryCalcContext.getSalaryCalcFormulaContext().getExpressionMap().get(salaryCalcFormula.getFormulaId()); +// // 获取变量的值 +// Map formulaVarValueMap = salaryCalcEmployeeContext.getFormulaVarValueMap().computeIfAbsent(salaryAcctEmployee.getId(), k -> new HashMap<>()); +// // 运行公式获取结果 +// String resultValue = calcResultValue(salaryCalcFormula, expressFormula, expression, formulaVarValueMap, lockSalaryItemIds, salaryCalcContext.getSimpleEmployee()); +// // 处理合并计税 +// resultValue = handleConsolidatedTax(salaryCalcContext, salaryCalcEmployeeContext, salaryAcctEmployee, resultValue, salaryItem); +// // 处理小数位数 +// resultValue = roundResultValue(resultValue, salaryCalcFormula); +// // 将公式计算结果回填到变量map中 +// formulaVarValueMap.put(SalaryFormulaReferenceEnum.SALARY_ITEM.getValue() +// + SalaryFormulaFieldConstant.FIELD_ID_SEPARATOR + salaryItem.getCode(), resultValue); +// // 合并计算时工资薪金和劳务费用的项目存在相互引用,所以需要将公式计算结果回填到另一个相关联的薪资核算人员的变量map中 +// for (SalaryAcctEmployeePO relationSalaryAcctEmployee : entry.getValue()) { +// if (!Objects.equals(relationSalaryAcctEmployee.getId(), salaryAcctEmployee.getId())) { +// Map relationFormulaVarValueMap = salaryCalcEmployeeContext.getFormulaVarValueMap().computeIfAbsent(relationSalaryAcctEmployee.getId(), k -> new HashMap<>()); +// relationFormulaVarValueMap.put(SalaryFormulaReferenceEnum.SALARY_ITEM.getValue() +// + SalaryFormulaFieldConstant.FIELD_ID_SEPARATOR + salaryItem.getCode(), resultValue); +// } +// } +// // 计算结果 +// Map resultValueMap = incomeCategoryResultValueMap.computeIfAbsent(salaryCalcFormula.getIncomeCategory(), k -> Maps.newHashMap()); +// resultValueMap.put("" + salaryCalcFormula.getSalaryItemId(), resultValue); +// } +// } +// for (SalaryAcctEmployeePO salaryAcctEmployee : entry.getValue()) { +// Map resultValueMap = Maps.newHashMap(); +// // 根据薪资核算人员的收入所得项目(工资薪金或者劳务),获取对应的薪资核算结果 +// resultValueMap.putAll(incomeCategoryResultValueMap.getOrDefault(salaryAcctEmployee.getIncomeCategory(), Collections.emptyMap())); +// // 回算薪资项目既不属于工资薪金也不属于劳务,但是也要保存到人员的薪资核算结果中 +// resultValueMap.putAll(incomeCategoryResultValueMap.getOrDefault("0", Collections.emptyMap())); +// SalaryAcctResultValuePO noDecryptSalaryAcctResultValue = salaryCalcEmployeeContext.getNoDecryptAcctResultValueMap().get(salaryAcctEmployee.getId()); +// SalaryAcctResultValuePO newSalaryAcctResultValue = new SalaryAcctResultValuePO() +// .setId(IdGenerator.generate()) +// .setSalaryAcctRecordId(salaryAcctEmployee.getSalaryAcctRecordId()) +// .setSalaryAcctEmployeeId(salaryAcctEmployee.getId()) +// .setResultValue(resultValueMap) +// .setOriginResultValueJson(noDecryptSalaryAcctResultValue == null +// ? StringUtils.EMPTY : noDecryptSalaryAcctResultValue.getOriginResultValueJson()) +// .setLockSalaryItemIds(lockSalaryItemIds) +// .setDeleteType(DeleteTypeEnum.NOT_DELETED.getValue()) +// .setTenantKey(simpleEmployee.getTenantKey()) +// .setCreator(simpleEmployee.getEmployeeId()) +// .setCreateTime(now) +// .setUpdateTime(now); +// newSalaryAcctResultValues.add(newSalaryAcctResultValue); +// // 更新计算进度 +// updateRate(salaryCalcContext.getSalaryAcctRecord().getId(), ++calcQty, salaryAcctEmployees.size()); +// } +// } +// blockingDeque.add(new SalaryCalcResult(true, "", newSalaryAcctResultValues)); +// } catch (Exception e) { +// log.info("薪资核算失败:{}", e.getMessage(), e); +// blockingDeque.add(new SalaryCalcResult(false, e.getMessage(), Collections.emptyList())); +// } finally { +// // 子线程执行完毕 +// childMonitor.countDown(); +// // 数据库字段加密用 +// DSTenantKeyThreadVar.tenantKey.remove(); +// } +// } +// +// private void checkBeforeCalc(SalaryAcctRecordPO salaryAcctRecordPO, List salaryAcctEmployees) { +// if (Objects.isNull(salaryAcctRecordPO)) { +// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(145221, "薪资核算记录不存在或已被删除")); +// } +// // 归档状态或已申报状态下不能核算 +// if (!Objects.equals(salaryAcctRecordPO.getStatus(), SalaryAcctRecordStatusEnum.NOT_ARCHIVED.getValue())) { +// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(145222, "薪资核算记录已经归档,不能再核算")); +// } +// // 没有薪资核算人员不能核算 +// if (CollectionUtils.isEmpty(salaryAcctEmployees)) { +// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "当前核算人员为空,请先确认要核算的人员")); +// } +// } +// +// private SalaryCalcContext loadContext(SalaryAcctRecordPO salaryAcctRecord, DataCollectionEmployee simpleEmployee) { +// String tenantKey = simpleEmployee.getTenantKey(); +// // 查询考勤周期、薪资周期、税款所属期、社保福利台账月份 +// SalarySobCycleDTO salarySobCycle = salaryAcctRecordService.getSalarySobCycleById(salaryAcctRecord.getId(), tenantKey); +// // 查询薪资核算记录的账套配置 +// SalaryAcctSobConfigPO salaryAcctSobConfig = salaryAcctSobConfigService.getBySalaryAcctRecordId(salaryAcctRecord.getId(), tenantKey); +// // 薪资项目 +// List salarySobItems = JsonUtil.parseList(salaryAcctSobConfig.getItemConfig(), SalarySobItemPO.class); +// // 回算薪资项目 +// List salarySobBackItems = !Objects.equals(salaryAcctRecord.getBackCalcStatus(), 1) ? Collections.emptyList() +// : JsonUtil.parseList(salaryAcctSobConfig.getBackItemConfig(), SalarySobBackItemPO.class); +// // 查询薪资项目所用的公式id +// Set formulaIds = new HashSet<>(); +// formulaIds.addAll(SalaryEntityUtil.properties(salarySobItems, SalarySobItemPO::getFormulaId)); +// formulaIds.addAll(SalaryEntityUtil.properties(salarySobBackItems, SalarySobBackItemPO::getFormulaId)); +// List expressFormulas = salaryFormulaService.listOriginExpressFormula(formulaIds, tenantKey); +// // 查询薪资项目 +// Set salaryItemIds = new HashSet<>(); +// salaryItemIds.addAll(SalaryEntityUtil.properties(salarySobItems, SalarySobItemPO::getSalaryItemId)); +// salaryItemIds.addAll(SalaryEntityUtil.properties(salarySobBackItems, SalarySobBackItemPO::getSalaryItemId)); +// List salaryItems = salaryItemService.listByIds(salaryItemIds, tenantKey); +// // 计算薪资项目的计算优先级 +// SalaryCalcPriority salaryCalcPriority = new SalaryCalcPriority(salaryItems, salarySobItems, salarySobBackItems, expressFormulas); +// SalaryCalcFormulaContext salaryCalcFormulaContext = salaryCalcPriority.calc(); +// // 查询薪资核算所用的调薪计薪规则 +// List salarySobAdjustRules = salarySobAdjustRuleService.listBySalarySobId(salaryAcctRecord.getSalarySobId(), tenantKey); +// // 查询员工状态 +// List hrmStatusList = hrmCommonHrmStatusService.list(tenantKey); +// Map hrmStatusMap = SalaryEntityUtil.convert2Map(hrmStatusList, hrmStatus -> "" + hrmStatus.getCodeId(), HrmStatus::getName); +// +// // 构建上下文 +// SalaryCalcContext salaryCalcContext = new SalaryCalcContext(); +// salaryCalcContext.setSimpleEmployee(simpleEmployee); +// salaryCalcContext.setHrmStatusMap(hrmStatusMap); +// salaryCalcContext.setSalaryAcctRecord(salaryAcctRecord); +// salaryCalcContext.setSalarySobCycle(salarySobCycle); +// salaryCalcContext.setSalaryAdjustmentRules(salarySobAdjustRules); +// salaryCalcContext.setSalaryCalcFormulaContext(salaryCalcFormulaContext); +// return salaryCalcContext; +// } +// +// private SalaryCalcEmployeeContext loadEmployeeContext(SalaryCalcContext salaryCalcContext, List salaryAcctEmployees, String tenantKey) { +// // 查询合并计税的薪资核算记录 +// LocalDateRange localDateRange = LocalDateRange.builder() +// .fromDate(salaryCalcContext.getSalarySobCycle().getTaxCycle().atDay(1)) +// .endDate(salaryCalcContext.getSalarySobCycle().getTaxCycle().atEndOfMonth()) +// .build(); +// List salaryAcctRecords = salaryAcctRecordService.listByTaxCycle(localDateRange, tenantKey); +// Map salaryAcctRecordMap = SalaryEntityUtil.convert2Map(salaryAcctRecords, SalaryAcctRecordPO::getId); +// // 查询合并计税的薪资核算人员 +// List sameTaxCycleSalaryAcctEmployees = salaryAcctEmployeeService.listSameTaxCycle(salaryAcctEmployees, salaryCalcContext.getSalarySobCycle().getTaxCycle().toString(), tenantKey); +// Map> sameTaxCycleEmployeeMap = SalaryEntityUtil.group2Map(sameTaxCycleSalaryAcctEmployees, o -> o.getEmployeeId() + "-" + o.getTaxAgentId()); +// Set sameTaxCycleSalaryAcctEmployeeIds = SalaryEntityUtil.properties(sameTaxCycleSalaryAcctEmployees, SalaryAcctEmployeePO::getId); +// List sameTaxCycleResultValues = salaryAcctResultValueService +// .listBySalaryAcctEmployeeIds(sameTaxCycleSalaryAcctEmployeeIds, tenantKey); +// Map sameTaxCycleResultValueMap = SalaryEntityUtil.convert2Map(sameTaxCycleResultValues, SalaryAcctResultValuePO::getSalaryAcctEmployeeId); +// +// SalaryCalcEmployeeContext salaryCalcEmployeeContext = new SalaryCalcEmployeeContext(); +// salaryCalcEmployeeContext.setSameTaxCycleRecordMap(salaryAcctRecordMap); +// salaryCalcEmployeeContext.setSameTaxCycleEmployeeMap(sameTaxCycleEmployeeMap); +// salaryCalcEmployeeContext.setSameTaxCycleResultValueMap(sameTaxCycleResultValueMap); +// // 加载公式变量 +// loadFormulaVar(salaryCalcContext, salaryCalcEmployeeContext, salaryAcctEmployees); +// return salaryCalcEmployeeContext; +// } +// +// private void loadFormulaVar(SalaryCalcContext salaryCalcContext, SalaryCalcEmployeeContext salaryCalcEmployeeContext, List salaryAcctEmployees) { +// String tenantKey = salaryCalcContext.getSimpleEmployee().getTenantKey(); +// // 薪资核算人员中的组织架构人员 +// List employeeIds = SalaryEntityUtil.properties(salaryAcctEmployees, SalaryAcctEmployeePO::getEmployeeId, Collectors.toList()); +// // 查询薪资档案 +// List salaryArchiveDataList = Collections.emptyList(); +// if (CollectionUtils.isNotEmpty(salaryCalcContext.getSalaryCalcFormulaContext().getSalaryArchiveFieldIds()) +// && CollectionUtils.isNotEmpty(employeeIds)) { +// salaryArchiveDataList = salaryArchiveService.getSalaryArchiveData(salaryCalcContext.getSalarySobCycle().getSalaryCycle(), employeeIds, tenantKey); +// } +// // 查询往期累计情况 +// List addUpSituations = Collections.emptyList(); +// if (CollectionUtils.isNotEmpty(salaryCalcContext.getSalaryCalcFormulaContext().getAddUpSituationFieldIds()) +// && salaryCalcContext.getSalarySobCycle().getTaxCycle().getMonth() != Month.JANUARY +// && CollectionUtils.isNotEmpty(employeeIds)) { +// addUpSituations = addUpSituationService.getAddUpSituationList(salaryCalcContext.getSalarySobCycle().getTaxCycle().plusMonths(-1), employeeIds, tenantKey); +// } +// // 查询累计专项附加扣除 +// List addUpDeductions = Collections.emptyList(); +// if (CollectionUtils.isNotEmpty(salaryCalcContext.getSalaryCalcFormulaContext().getAddUpDeductionFieldIds()) +// && CollectionUtils.isNotEmpty(employeeIds)) { +// addUpDeductions = addUpDeductionService.getAddUpDeductionList(salaryCalcContext.getSalarySobCycle().getTaxCycle(), employeeIds, tenantKey); +// } +// // 查询其他扣除 +// List otherDeductions = Collections.emptyList(); +// if (CollectionUtils.isNotEmpty(salaryCalcContext.getSalaryCalcFormulaContext().getOtherDeductionFieldIds()) +// && CollectionUtils.isNotEmpty(employeeIds)) { +// otherDeductions = otherDeductionService.getOtherDeductionList(salaryCalcContext.getSalarySobCycle().getTaxCycle(), employeeIds, tenantKey); +// } +// // 查询考勤 +// List attendQuoteDataList = Collections.emptyList(); +// if (CollectionUtils.isNotEmpty(salaryCalcContext.getSalaryCalcFormulaContext().getAttendFieldIds()) +// && CollectionUtils.isNotEmpty(employeeIds)) { +// SalarySobPO salarySob = salarySobService.getById(salaryCalcContext.getSalaryAcctRecord().getSalarySobId(), tenantKey); +// attendQuoteDataList = attendQuoteDataService.getAttendQuoteData(salaryCalcContext.getSalarySobCycle().getSalaryMonth(), salarySob.getOriginSalarySobId(), employeeIds, tenantKey); +// } +// // 查询社保福利 +// List> welfareMapList = Collections.emptyList(); +// if (CollectionUtils.isNotEmpty(salaryCalcContext.getSalaryCalcFormulaContext().getWelfareFieldIds()) +// && CollectionUtils.isNotEmpty(employeeIds)) { +// welfareMapList = siAccountService.welfareData(salaryCalcContext.getSalarySobCycle().getSocialSecurityCycle().toString(), employeeIds, tenantKey); +// } +// // 查询自定义业务数据 +// List customDataEmployees = Collections.emptyList(); +// if (MapUtils.isNotEmpty(salaryCalcContext.getSalaryCalcFormulaContext().getCustomDataFieldIdMap()) +// && CollectionUtils.isNotEmpty(employeeIds)) { +// Set customFieldIds = salaryCalcContext.getSalaryCalcFormulaContext().getCustomDataFieldIdMap().values().stream() +// .flatMap(Collection::stream) +// .map(fieldId -> Util.getLongValue(fieldId, 0L)) +// .collect(Collectors.toSet()); +// List customDataRecords = customDataRecordService.listByCustomFormIdsAndSalaryMonth( +// salaryCalcContext.getSalaryCalcFormulaContext().getCustomDataFieldIdMap().keySet(), +// salaryCalcContext.getSalarySobCycle().getSalaryMonth(), +// salaryCalcContext.getSimpleEmployee().getEmployeeId(), tenantKey); +// CustomDataEmployeeQueryParam param = new CustomDataEmployeeQueryParam() +// .setCustomDataRecordIds(SalaryEntityUtil.properties(customDataRecords, CustomDataRecordPO::getId)) +// .setEmployeeIds(employeeIds) +// .setCustomFieldIds(customFieldIds); +// customDataEmployees = customDataEmployeeService.listByParam(param, tenantKey); +// } +// // 查询人员信息 +// List simpleEmployees = Collections.emptyList(); +// if (CollectionUtils.isNotEmpty(salaryCalcContext.getSalaryCalcFormulaContext().getEmployeeInfoFieldIds()) +// && CollectionUtils.isNotEmpty(employeeIds)) { +// simpleEmployees = hrmCommonEmployeeService.getEmployeeByIds(employeeIds, tenantKey); +// } +// // 查询外部人员 +// List extEmployeeIds = salaryAcctEmployees.stream() +// .filter(salaryAcctEmployee -> Objects.equals(salaryAcctEmployee.getEmployeeType(), EmployeeTypeEnum.EXT_EMPLOYEE.getValue())) +// .map(SalaryAcctEmployeePO::getEmployeeId) +// .distinct() +// .collect(Collectors.toList()); +// List extEmployees = Collections.emptyList(); +// if (CollectionUtils.isNotEmpty(salaryCalcContext.getSalaryCalcFormulaContext().getExtEmployeeFieldIds()) +// && CollectionUtils.isNotEmpty(extEmployeeIds)) { +// extEmployees = extEmployeeService.listByIdsWithDeleted(extEmployeeIds, tenantKey); +// } +// // 查询薪资核算结果(不解密) +// Set salaryAcctEmployeeIds = SalaryEntityUtil.properties(salaryAcctEmployees, SalaryAcctEmployeePO::getId); +// List noDecryptSalaryAcctResultValues = salaryAcctResultValueService.listNoDecryptBySalaryAcctEmployeeIds(salaryAcctEmployeeIds, tenantKey); +// Map noDecryptSalaryAcctResultValueMap = SalaryEntityUtil.convert2Map(noDecryptSalaryAcctResultValues, SalaryAcctResultValuePO::getSalaryAcctEmployeeId); +// salaryCalcEmployeeContext.setNoDecryptAcctResultValueMap(noDecryptSalaryAcctResultValueMap); +// // 查询薪资核算结果(解密) +// List salaryAcctResultValues = salaryAcctResultValueService.listBySalaryAcctEmployeeIds(salaryAcctEmployeeIds, tenantKey); +// +// SalaryCalcFormulaVar salaryCalcFormulaVar = new SalaryCalcFormulaVar(salaryArchiveDataList, addUpSituations, +// addUpDeductions, otherDeductions, attendQuoteDataList, welfareMapList, customDataEmployees, simpleEmployees, extEmployees, salaryAcctResultValues); +// Map> resultMap = salaryCalcFormulaVar.handleSalaryCalcFormulaVar(salaryCalcContext, salaryAcctEmployees); +// Map> formulaVarValueMap = Maps.newHashMapWithExpectedSize(resultMap.size()); +// resultMap.forEach((k, v) -> { +// Map map = SalaryEntityUtil.convert2Map(v, SalaryCalcFormulaVarValue::getFieldId, SalaryCalcFormulaVarValue::getFieldValue); +// formulaVarValueMap.put(k, map); +// }); +// salaryCalcEmployeeContext.setFormulaVarValueMap(formulaVarValueMap); +// } +// +// private String calcResultValue(SalaryCalcFormula salaryCalcFormula, +// ExpressFormula expressFormula, +// Expression expression, +// Map formulaVarValueMap, +// Set lockSalaryItemIds, +// DataCollectionEmployee simpleEmployee) { +// String originValue = formulaVarValueMap.getOrDefault(SalaryFormulaReferenceEnum.SALARY_ITEM.getValue() +// + SalaryFormulaFieldConstant.FIELD_ID_SEPARATOR + salaryCalcFormula.getSalaryItemCode(), ""); +// if (Objects.isNull(expressFormula) || lockSalaryItemIds.contains(salaryCalcFormula.getSalaryItemId())) { +// if (Objects.equals(salaryCalcFormula.getUseInEmployeeSalary(), NumberUtils.INTEGER_ONE) && !lockSalaryItemIds.contains(salaryCalcFormula.getSalaryItemId())) { +// return formulaVarValueMap.getOrDefault(SalaryFormulaReferenceEnum.SALARY_ARCHIVES.getValue() +// + SalaryFormulaFieldConstant.FIELD_ID_SEPARATOR + salaryCalcFormula.getSalaryItemId(), ""); +// } +// return originValue; +// } +// // 如果只包含了优化的函数,走本模块的计算,否则走公式模块提供的公共方法计算 +// if (expression != null) { +// try { +// // 填充变量的值 +// Map envMap = ExpressFormulaBO.fillExpressionEnvMap(expressFormula, formulaVarValueMap); +// // 运行公式 +// return Util.null2String(expression.execute(envMap)); +// } catch (Exception e) { +// log.info("公式计算错误:{}", expressFormula.getFormula(), e); +// return StringUtils.EMPTY; +// } +// } +// // 填充变量的值 +// List formulaVars = ExpressFormulaBO.fillFormulaVarContent(expressFormula, formulaVarValueMap); +// // 运行公式 +// ExcelResult excelResult = excelRunService.run(expressFormula, formulaVars, simpleEmployee); +// if (excelResult.isStatus()) { +// return excelResult.getStringData(); +// } else { +// log.info("公式计算错误:{}, 错误原因:{}", expressFormula.getFormula(), excelResult.getErrorMsg()); +// return StringUtils.EMPTY; +// } +// } +// +// private String handleConsolidatedTax(SalaryCalcContext salaryCalcContext, +// SalaryCalcEmployeeContext salaryCalcEmployeeContext, +// SalaryAcctEmployeePO salaryAcctEmployee, +// String resultValue, +// SalaryItemPO salaryItem) { +// // 只有正常工资薪金所得才需要合并计税处理 +// if (!Objects.equals(salaryAcctEmployee.getIncomeCategory(), "" + IncomeCategoryEnum.WAGES_AND_SALARIES.getValue())) { +// return resultValue; +// } +// List sameTaxCycleSalaryAcctEmployees = salaryCalcEmployeeContext.getSameTaxCycleEmployeeMap() +// .get(salaryAcctEmployee.getEmployeeId() + "-" + salaryAcctEmployee.getTaxAgentId()); +// if (CollectionUtils.isEmpty(sameTaxCycleSalaryAcctEmployees)) { +// return resultValue; +// } +// // 第一次计算时不需要合并计税处理 +// boolean needConsolidatedTax = needConsolidatedTax(salaryCalcEmployeeContext, salaryAcctEmployee, sameTaxCycleSalaryAcctEmployees); +// if (!needConsolidatedTax) { +// return resultValue; +// } +// List salaryAcctResultValues = Lists.newArrayList(); +// for (SalaryAcctEmployeePO sameTaxCycleSalaryAcctEmployee : sameTaxCycleSalaryAcctEmployees) { +// SalaryAcctResultValuePO salaryAcctResultValue = salaryCalcEmployeeContext.getSameTaxCycleResultValueMap().get(sameTaxCycleSalaryAcctEmployee.getId()); +// if (salaryAcctResultValue != null) { +// salaryAcctResultValues.add(salaryAcctResultValue); +// } +// } +// List salaryItems = Lists.newArrayList(salaryCalcContext.getSalaryCalcFormulaContext().getSalaryItemMap().values()); +// return SalaryAcctConsolidatedTax.handleConsolidatedTaxValue(resultValue, salaryItem, salaryItems, salaryAcctResultValues); +// } +// +// /** +// * 判断是否需要进行合并计税 +// * +// * @param salaryCalcEmployeeContext +// * @param salaryAcctEmployee +// * @param sameTaxCycleSalaryAcctEmployees +// * @return +// */ +// private boolean needConsolidatedTax(SalaryCalcEmployeeContext salaryCalcEmployeeContext, +// SalaryAcctEmployeePO salaryAcctEmployee, +// List sameTaxCycleSalaryAcctEmployees) { +// SalaryAcctRecordPO salaryAcctRecord = salaryCalcEmployeeContext.getSameTaxCycleRecordMap().get(salaryAcctEmployee.getSalaryAcctRecordId()); +// if (salaryAcctRecord == null) { +// return false; +// } +// for (SalaryAcctEmployeePO sameTaxCycleSalaryAcctEmployee : sameTaxCycleSalaryAcctEmployees) { +// SalaryAcctRecordPO otherSalaryAcctRecord = salaryCalcEmployeeContext.getSameTaxCycleRecordMap() +// .get(sameTaxCycleSalaryAcctEmployee.getSalaryAcctRecordId()); +// if (otherSalaryAcctRecord == null) { +// continue; +// } +// if (otherSalaryAcctRecord.getCreateTime().compareTo(salaryAcctRecord.getCreateTime()) < 0) { +// return true; +// } +// } +// return false; +// } +// +// private String roundResultValue(String resultValue, SalaryCalcFormula salaryCalcFormula) { +// // 值为空,不需要四舍五入 +// if (StringUtils.isEmpty(resultValue)) { +// return StringUtils.EMPTY; +// } +// // 薪资项目字段类型为string,无需四舍五入 +// SalaryDataTypeEnum dataTypeEnum = salaryCalcFormula.getDataType(); +// if (dataTypeEnum == SalaryDataTypeEnum.STRING) { +// return resultValue; +// } +// BigDecimal bigDecimalValue = SalaryEntityUtil.empty2Zero(resultValue); +// RoundingMode roundingMode = RoundingMode.HALF_UP; +// if (salaryCalcFormula.getRoundingMode() == SalaryRoundingModeEnum.ROUND_UP) { +// roundingMode = RoundingMode.UP; +// } +// if (salaryCalcFormula.getRoundingMode() == SalaryRoundingModeEnum.ROUND_DOWN) { +// roundingMode = RoundingMode.DOWN; +// } +// return bigDecimalValue.setScale(salaryCalcFormula.getPattern(), roundingMode).toPlainString(); +// } +// +// /** +// * 更新核算进度 +// * +// * @param salaryAcctRecordId +// * @param calcQty +// */ +// private synchronized void updateRate(Long salaryAcctRecordId, int calcQty, int salaryAcctEmployeeSize) { +// int addQty = 0; +// if (calcQty % 10 == 0) { +// addQty = 10; +// } else if (Objects.equals(calcQty, salaryAcctEmployeeSize)) { +// addQty = calcQty % 10; +// } +// if (addQty > 0) { +// SalaryAcctRateDTO salaryAcctRate = salaryCacheService +// .get(SalaryCacheKey.ACCT_PROGRESS, "" + salaryAcctRecordId, SalaryAcctRateDTO.class); +// salaryAcctRate.setCalcQty(salaryAcctRate.getCalcQty() + addQty); +// salaryCacheService.set(SalaryCacheKey.ACCT_PROGRESS, "" + salaryAcctRecordId, salaryAcctRate); +// } +// } +// +// private void handleCalcResult(BlockingDeque blockingDeque, +// Long salaryAcctRecordId, Collection salaryAcctEmployeeIds, +// String tenantKey) { +// boolean allSuccess = blockingDeque.stream().allMatch(SalaryCalcResult::isStatus); +// if (!allSuccess) { +// // 薪资核算实现的线程的错误信息 +// String errorMsg = blockingDeque.stream() +// .filter(result -> !result.isStatus()) +// .map(SalaryCalcResult::getErrMsg) +// .collect(Collectors.joining("|")); +// // 返回错误信息 +// throw new SalaryRunTimeException("薪资核算失败:" + errorMsg); +// } +// // 删除历史数据 +// if (CollectionUtils.isNotEmpty(salaryAcctEmployeeIds)) { +// salaryAcctResultValueService.deleteBySalaryAcctEmployeeIds(salaryAcctEmployeeIds, tenantKey); +// } else { +// salaryAcctResultValueService.deleteBySalaryAcctRecordIds(Collections.singleton(salaryAcctRecordId), tenantKey); +// } +// // 保存新数据 +// List salaryAcctResultValues = Lists.newArrayList(); +// for (SalaryCalcResult salaryCalcResult : blockingDeque) { +// salaryAcctResultValues.addAll(salaryCalcResult.getSalaryAcctResultValues()); +// } +// salaryAcctResultValueService.batchSave(salaryAcctResultValues, tenantKey); +// } +// +// private void writeLog(Long salaryAcctRecordId, String tenantKey) { +// String targetName = salaryAcctRecordService.getLogTargetNameById(salaryAcctRecordId, tenantKey); +// LoggerContext loggerContext = new LoggerContext<>(); +// loggerContext.setTargetId(String.valueOf(salaryAcctRecordId)); +// loggerContext.setTargetName(targetName); +// loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue()); +// loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(95783, "薪资核算")); +// loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(95783, "薪资核算")); +// salaryAcctRecordLoggerTemplate.write(loggerContext); +// } +//} diff --git a/src/com/engine/salary/service/impl/SalaryAcctCalculateServiceImpl.java b/src/com/engine/salary/service/impl/SalaryAcctCalculateServiceImpl.java new file mode 100644 index 000000000..81fae4808 --- /dev/null +++ b/src/com/engine/salary/service/impl/SalaryAcctCalculateServiceImpl.java @@ -0,0 +1,392 @@ +package com.engine.salary.service.impl; + +import cn.hutool.core.util.StrUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.cache.SalaryCacheKey; +import com.engine.salary.constant.SalaryDefaultTenantConstant; +import com.engine.salary.constant.SalaryFormulaFieldConstant; +import com.engine.salary.entity.datacollection.AddUpDeduction; +import com.engine.salary.entity.datacollection.AddUpSituation; +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.datacollection.dto.AttendQuoteDataDTO; +import com.engine.salary.entity.datacollection.po.OtherDeductionPO; +import com.engine.salary.entity.salaryacct.bo.*; +import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO; +import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO; +import com.engine.salary.entity.salaryacct.po.SalaryAcctResultPO; +import com.engine.salary.entity.salaryacct.po.SalaryAcctResultTempPO; +import com.engine.salary.entity.salaryarchive.dto.SalaryArchiveDataDTO; +import com.engine.salary.entity.salaryformula.ExpressFormula; +import com.engine.salary.entity.salaryformula.po.FormulaVar; +import com.engine.salary.entity.salaryitem.po.SalaryItemPO; +import com.engine.salary.entity.salarysob.dto.SalarySobCycleDTO; +import com.engine.salary.entity.salarysob.po.SalarySobBackItemPO; +import com.engine.salary.entity.salarysob.po.SalarySobItemPO; +import com.engine.salary.enums.salaryformula.SalaryFormulaReferenceEnum; +import com.engine.salary.formlua.entity.standard.ExcelResult; +import com.engine.salary.service.*; +import com.engine.salary.sys.enums.TaxDeclarationFunctionEnum; +import com.engine.salary.util.SalaryDateUtil; +import com.engine.salary.util.SalaryEntityUtil; +import com.google.common.collect.Lists; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.math.NumberUtils; +import org.springframework.util.StopWatch; +import weaver.general.BaseBean; +import weaver.general.Util; +import weaver.hrm.User; + +import java.time.Month; +import java.util.*; +import java.util.stream.Collectors; + +/** + * 薪资核算-核算 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Slf4j +public class SalaryAcctCalculateServiceImpl extends Service implements SalaryAcctCalculateService { + BaseBean bb = new BaseBean(); + //公式运行时间超时提醒阈值 + private final String formulaRunOvertimeThreshold = bb.getPropValue("hrmSalaryCustom", "formulaRunOvertimeThreshold"); + + private SalaryAcctResultService getSalaryAcctResultService(User user) { + return ServiceUtil.getService(SalaryAcctResultServiceImpl.class, user); + } + + private SalaryEmployeeService getSalaryEmployeeService(User user) { + return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user); + } + + + private SalaryArchiveService getSalaryArchiveService(User user) { + return ServiceUtil.getService(SalaryArchiveServiceImpl.class, user); + } + + + private AddUpSituationService getAddUpSituationService(User user) { + return ServiceUtil.getService(AddUpSituationServiceImpl.class, user); + } + + + private AddUpDeductionService getAddUpDeductionService(User user) { + return ServiceUtil.getService(AddUpDeductionServiceImpl.class, user); + } + + + private OtherDeductionService getOtherDeductionService(User user) { + return ServiceUtil.getService(OtherDeductionServiceImpl.class, user); + } + + private SIAccountService getSIAccountService(User user) { + return ServiceUtil.getService(SIAccountServiceImpl.class, user); + } + + private AttendQuoteDataService getAttendQuoteDataService(User user) { + return ServiceUtil.getService(AttendQuoteDataServiceImpl.class, user); + } + + private FormulaRunService getFormulaRunService(User user) { + return ServiceUtil.getService(FormulaRunServiceImpl.class, user); + } + + + private SalaryAcctResultTempService getSalaryAcctResultTempService(User user) { + return ServiceUtil.getService(SalaryAcctResultTempServiceImpl.class, user); + } + + private ProgressService getSalaryAcctProgressService(User user) { + return (ProgressService) ServiceUtil.getService(ProgressServiceImpl.class, user); + } + + private SalaryAcctEmployeeService getSalaryAcctEmployeeService(User user) { + return ServiceUtil.getService(SalaryAcctEmployeeServiceImpl.class, user); + } + + private VariableArchiveService getVariableArchiveService(User user) { + return ServiceUtil.getService(VariableArchiveServiceImpl.class, user); + } + + @Override + public void calculate(SalaryAcctCalculateBO salaryAcctCalculateBO, DataCollectionEmployee simpleEmployee, List salarySobBackItems) { + log.info("开始核算V3 {}", salaryAcctCalculateBO); + StopWatch sw = new StopWatch("核算耗时明细,id:" + salaryAcctCalculateBO.getSalaryAcctRecordPO().getId() + ""); + Date now = new Date(); + try { + // 数据库字段加密用 + // 1、查询人员信息 + sw.start("查询人员信息"); + List employeeIds = SalaryEntityUtil.properties(salaryAcctCalculateBO.getSalaryAcctEmployeePOS(), SalaryAcctEmployeePO::getEmployeeId, Collectors.toList()); + List simpleEmployees = getSalaryEmployeeService(user).getEmployeeByIdsAll(employeeIds); + SalarySobCycleDTO salarySobCycleDTO = salaryAcctCalculateBO.getSalarySobCycleDTO(); + List taxAgentIds = salaryAcctCalculateBO.getSalarySobPO().getTaxAgentIds(); + sw.stop(); + // 2、查询薪资档案的数据 + sw.start("查询薪资档案的数据"); + List salaryArchiveData = getSalaryArchiveService(user).getSalaryArchiveData(salarySobCycleDTO.getSalaryCycle(), employeeIds, taxAgentIds); + sw.stop(); + // 3、查询往期累计情况(查询的是上个税款所属期的的累计情况) + sw.start("查询往期累计情况"); + List addUpSituationPOS; + if (salarySobCycleDTO.getTaxCycle().getMonth() == Month.JANUARY) { + // 3.1、如果当前税款所属期是本年度第一个税款所属期,就不需要查询往期累计情况 + addUpSituationPOS = Collections.emptyList(); + } else { + addUpSituationPOS = getAddUpSituationService(user).getAddUpSituationList(salarySobCycleDTO.getTaxCycle().plusMonths(-1), employeeIds); + } + sw.stop(); + // 4、查询累计专项附加扣除 + sw.start("查询累计专项附加扣除"); + List addUpDeductionPOS = getAddUpDeductionService(user).getAddUpDeductionList(salarySobCycleDTO.getTaxCycle(), employeeIds, taxAgentIds); + sw.stop(); + // 5、查询其他免税扣除 + sw.start("查询其他免税扣除"); + List otherDeductionPOS = getOtherDeductionService(user).getOtherDeductionList(salarySobCycleDTO.getTaxCycle(), employeeIds, taxAgentIds); + sw.stop(); + //6、查询社保福利 + sw.start("查询社保福利"); + List> welfareData = new ArrayList<>(); + taxAgentIds.forEach(taxAgentId -> { + welfareData.addAll(getSIAccountService(user).welfareData(salarySobCycleDTO.getSocialSecurityCycle().toString(), employeeIds, taxAgentId)); + }); + sw.stop(); + // 7、查询考勤数据 + sw.start("查询考勤数据"); + List attendQuoteDataDTOS = getAttendQuoteDataService(user).getAttendQuoteData(salarySobCycleDTO.getSalaryMonth(), salarySobCycleDTO.getSalarySobId(), employeeIds); + sw.stop(); + // 8、查询薪资核算人员的薪资核算结果 + sw.start("查询薪资核算人员的薪资核算结果"); + List salaryAcctEmployeeIds = SalaryEntityUtil.properties(salaryAcctCalculateBO.getSalaryAcctEmployeePOS(), SalaryAcctEmployeePO::getId, Collectors.toList()); + List salaryAcctResultPOS = getSalaryAcctResultService(user).listBySalaryAcctEmployeeIds(salaryAcctEmployeeIds); + Map empItemValueMap = SalaryEntityUtil.convert2Map(salaryAcctResultPOS, p -> p.getSalaryAcctEmpId() + "_" + p.getSalaryItemId(), SalaryAcctResultPO::getResultValue); + sw.stop(); + // 查询浮动薪资 + sw.start("查询浮动薪资"); + List> variableArchiveList = getVariableArchiveService(user).listBySalaryMonthAndEmployeeIds(salarySobCycleDTO.getSalaryMonth(), employeeIds, taxAgentIds); + sw.stop(); + // 薪资回算时回算前的核算结果 (没有回算项) + sw.start("查询薪资回算时回算前的核算结果"); + Map> collect = salaryAcctResultPOS.stream().collect(Collectors.groupingBy(k -> k.getEmployeeId() + "-" + k.getTaxAgentId() + "-" + k.getSalaryItemId())); + Map salaryAcctResultPOMap = new HashMap<>(); + for (Map.Entry> et : collect.entrySet()) { + salaryAcctResultPOMap.put(et.getKey(), et.getValue().get(0).getOriginResultValue()); + } + sw.stop(); + // 9、查询相同税款所属期内涉及合并计税的其他薪资核算结果 + sw.start("查询相同税款所属期内涉及合并计税的其他薪资核算结果"); + Set otherSalaryAcctRecordIds = SalaryEntityUtil.properties(salaryAcctCalculateBO.getOtherSalaryAcctRecordPOS(), SalaryAcctRecordPO::getId); + List otherSalaryAcctResultPOS = getSalaryAcctResultService(user).listBySalaryAcctRecordIdsAndEmployeeIds(otherSalaryAcctRecordIds, employeeIds); + Map> otherSalaryAcctResultPOMap = SalaryEntityUtil.group2Map(otherSalaryAcctResultPOS, e -> e.getEmployeeId() + "_" + e.getTaxAgentId()); + sw.stop(); + // 9.1、查询相同税款所属期内设计合并计税的其他薪资核算人员 + sw.start("查询相同税款所属期内设计合并计税的其他薪资核算人员"); + List otherSalaryAcctEmployeePOS = getSalaryAcctEmployeeService(user).listBySalaryAcctRecordIdsAndEmployeeIds(otherSalaryAcctRecordIds, employeeIds); + Map> otherSalaryAcctEmployeePOMap = SalaryEntityUtil.group2Map(otherSalaryAcctEmployeePOS, salaryAcctEmployeePO -> salaryAcctEmployeePO.getEmployeeId() + "_" + salaryAcctEmployeePO.getTaxAgentId()); + sw.stop(); + // 查询上个薪资所属月核算人员薪资数据 + sw.start("查询上个薪资所属月核算人员薪资数据"); + List lastMonthResultPOS = getSalaryAcctResultService(user).listBySobSalaryMonth(SalaryDateUtil.toDate(salarySobCycleDTO.getSalaryMonth().minusMonths(1), 1), salaryAcctCalculateBO.getSalarySobPO().getId(), employeeIds); + sw.stop(); + // 10、转换成公式编辑器中的变量 + sw.start("转换成公式编辑器中的变量"); + CalculateFormulaVarBO calculateFormulaVarBO = new CalculateFormulaVarBO(simpleEmployees, salaryArchiveData, addUpSituationPOS, addUpDeductionPOS, otherDeductionPOS, welfareData, attendQuoteDataDTOS, salaryAcctResultPOS, variableArchiveList,lastMonthResultPOS); + Map> formulaVarMap = calculateFormulaVarBO.convert2FormulaVar(salaryAcctCalculateBO); + sw.stop(); + sw.start("数据结构准备"); + // 本次薪资核算所用的薪资账套下的薪资项目 + Map salaryItemIdKeySalarySobItemPOMap = SalaryEntityUtil.convert2Map(salaryAcctCalculateBO.getSalarySobItemPOS(), SalarySobItemPO::getSalaryItemId); + // 本次薪资核算所用的公式 + Map expressFormulaMap = SalaryEntityUtil.convert2Map(salaryAcctCalculateBO.getExpressFormulas(), ExpressFormula::getId); + // 系统内的薪资项目 + Map salaryItemMap = SalaryEntityUtil.convert2Map(salaryAcctCalculateBO.getSalaryItemPOS(), SalaryItemPO::getId); + // 获取薪资回算的薪资项目ID + Set salarySobBackItemIds = SalaryEntityUtil.properties(salarySobBackItems, SalarySobBackItemPO::getSalaryItemId); + Map salarySobBackItemMap = SalaryEntityUtil.convert2Map(salarySobBackItems, SalarySobBackItemPO::getSalaryItemId); + List salaryAcctResultTempPOS = Lists.newArrayList(); + sw.stop(); + // 开始核算 + sw.start("核算耗时"); + StringBuffer noticeMsg = new StringBuffer(); + for (SalaryAcctEmployeePO salaryAcctEmployeePO : salaryAcctCalculateBO.getSalaryAcctEmployeePOS()) { + Long salaryAcctEmployeePOId = salaryAcctEmployeePO.getId(); + List lockItems = salaryAcctEmployeePO.getLockItems(); + //1 获取当前薪资核算人员的公式中的变量的值 + List formulaVarValues = formulaVarMap.get(salaryAcctEmployeePO.getEmployeeId() + "_" + salaryAcctEmployeePO.getTaxAgentId()); + //2 人员信息 + List empInfo = formulaVarMap.get(salaryAcctEmployeePO.getEmployeeId() + ""); + formulaVarValues.addAll(empInfo); + Map formulaVarValueMap = SalaryEntityUtil.convert2Map(formulaVarValues, CalculateFormulaVarBO.FormulaVarValue::getFieldId, CalculateFormulaVarBO.FormulaVarValue::getFieldValue); + // 按照计算好的优先级计算薪资项目的值 + for (List salaryItemIds : salaryAcctCalculateBO.getSalaryItemIdWithPriorityList()) { + // 同一运算优先级下的薪资项目逐个独立运算 + for (Long salaryItemId : salaryItemIds) { + String resultValue; + SalaryItemPO salaryItemPO = salaryItemMap.get(salaryItemId); + ExpressFormula expressFormula; + String defaultValue; + if (salarySobBackItemMap.containsKey(salaryItemId)) { + // 如果薪资账套的回算项目中重新定义了回算项目公式,则使用薪资账套下的公式 + SalarySobBackItemPO salarySobBackItemPO = salarySobBackItemMap.get(salaryItemId); + expressFormula = expressFormulaMap.get(salarySobBackItemPO.getFormulaId()); + defaultValue = salarySobBackItemPO.getDefaultValue(); + } else if (salaryItemIdKeySalarySobItemPOMap.containsKey(salaryItemId)) { + // 如果薪资账套下重新定义了薪资项目的公式,则使用薪资账套下的公式,否则使用薪资项目本身的公式 + SalarySobItemPO salarySobItemPO = salaryItemIdKeySalarySobItemPOMap.get(salaryItemId); + expressFormula = expressFormulaMap.get(salarySobItemPO.getFormulaId()); + defaultValue = salarySobItemPO.getDefaultValue(); + } else { + expressFormula = expressFormulaMap.get(salaryItemPO.getFormulaId()); + defaultValue = salaryItemPO.getDefaultValue(); + } + if (Objects.nonNull(expressFormula)) { + // 运行公式 + ExcelResult result = runExpressFormula(expressFormula, formulaVarValueMap, simpleEmployee); + resultValue = result.getData2String(); + //公式异常信息 + if (!result.isStatus()) { + String username = empInfo.stream().filter(emp -> StringUtils.equals("employeeInfo_username", emp.getFieldId())).findFirst().map(CalculateFormulaVarBO.FormulaVarValue::getFieldValue).orElse(""); + String errorMsg = String.format("%s的%s核算异常,原因:%s \r\n", username, salaryItemPO.getName(), result.getErrorMsg()); + noticeMsg.append(errorMsg); + } + //提醒运行超时 + if (StringUtils.isNotBlank(formulaRunOvertimeThreshold) && result.getRunTime() > Long.parseLong(formulaRunOvertimeThreshold)) { + String username = empInfo.stream().filter(emp -> StringUtils.equals("employeeInfo_username", emp.getFieldId())).findFirst().map(CalculateFormulaVarBO.FormulaVarValue::getFieldValue).orElse(""); + String errorMsg = String.format("%s的%s核算超时,耗时:%s毫秒 \r\n", username, salaryItemPO.getName(), result.getRunTime()); + noticeMsg.append(errorMsg); + } + } else { + // 处理取值类型为“输入/导入”的薪资项目 + String key = SalaryFormulaReferenceEnum.SALARY_ITEM.getValue() + SalaryFormulaFieldConstant.FIELD_ID_SEPARATOR + salaryItemPO.getCode(); + resultValue = formulaVarValueMap.getOrDefault(key, StringUtils.EMPTY); + if (StrUtil.isBlank(resultValue)) { + resultValue = Util.null2String(defaultValue); + } + } + // 处理薪资档案 + if (Objects.equals(salaryItemPO.getUseInEmployeeSalary(), NumberUtils.INTEGER_ONE)) { + String key = SalaryFormulaReferenceEnum.SALARY_ARCHIVES.getValue() + SalaryFormulaFieldConstant.FIELD_ID_SEPARATOR + salaryItemPO.getCode(); + resultValue = formulaVarValueMap.getOrDefault(key, StringUtils.EMPTY); + } + // 处理合并计税 + resultValue = handleConsolidatedTax(resultValue, salaryItemPO, salaryAcctCalculateBO, otherSalaryAcctEmployeePOMap.get(salaryAcctEmployeePO.getEmployeeId() + "_" + salaryAcctEmployeePO.getTaxAgentId()), otherSalaryAcctResultPOMap.get(salaryAcctEmployeePO.getEmployeeId() + "_" + salaryAcctEmployeePO.getTaxAgentId())); + + // 处理小数点 + resultValue = SalaryAcctFormulaBO.roundResultValue(resultValue, salaryItemPO, salarySobBackItems, salarySobBackItemMap, salaryItemIdKeySalarySobItemPOMap); + + //是否锁定 + if (lockItems != null && lockItems.contains(salaryItemId)) { + resultValue = empItemValueMap.getOrDefault(salaryAcctEmployeePOId + "_" + salaryItemId, StringUtils.EMPTY); + } + // 将已经计算过的薪资项目的值转换成公式变量的值添加到集合中 + String key = SalaryFormulaReferenceEnum.SALARY_ITEM.getValue() + SalaryFormulaFieldConstant.FIELD_ID_SEPARATOR + salaryItemPO.getCode(); + formulaVarValueMap.put(key, resultValue); + // 值保存薪资账套下的薪资项目的核算结果 + if (salaryItemIdKeySalarySobItemPOMap.containsKey(salaryItemId) || salarySobBackItemIds.contains(salaryItemId)) { + // 转换成薪资核算结果po + SalaryAcctResultTempPO salaryAcctResultTempPO = new SalaryAcctResultTempPO() + .setSalaryAcctRecordId(salaryAcctEmployeePO.getSalaryAcctRecordId()) + .setSalaryAcctEmpId(salaryAcctEmployeePOId) + .setEmployeeId(salaryAcctEmployeePO.getEmployeeId()) + .setTaxAgentId(salaryAcctEmployeePO.getTaxAgentId()) + .setSalarySobId(salaryAcctEmployeePO.getSalarySobId()) + .setSalaryItemId(salaryItemPO.getId()) + .setResultValue(resultValue) + .setOriginResultValue(salaryAcctResultPOMap.get(salaryAcctEmployeePO.getEmployeeId() + "-" + salaryAcctEmployeePO.getTaxAgentId() + "-" + salaryItemId) == null + ? StringUtils.EMPTY : salaryAcctResultPOMap.get(salaryAcctEmployeePO.getEmployeeId() + "-" + salaryAcctEmployeePO.getTaxAgentId() + "-" + salaryItemId)) + .setCalculateKey(salaryAcctCalculateBO.getCalculateKey()) + .setCreator((long) user.getUID()) + .setCreateTime(now) + .setUpdateTime(now) + .setTenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .setDeleteType(0); + salaryAcctResultTempPOS.add(salaryAcctResultTempPO); + } + } + } + } + sw.stop(); + // 保存新的薪资核算结果(临时存储) + sw.start("保存新的薪资核算结果(临时存储)"); + getSalaryAcctResultTempService(user).batchSave(salaryAcctResultTempPOS); + sw.stop(); + // 更新薪资核算进度 + sw.start("更新薪资核算进度"); + getSalaryAcctProgressService(user).getAndAddCalculatedQty(SalaryCacheKey.ACCT_PROGRESS + salaryAcctCalculateBO.getSalaryAcctRecordPO().getId(), + salaryAcctCalculateBO.getSalaryAcctEmployeePOS().size(), + noticeMsg.toString() + ); + sw.stop(); + log.info(sw.prettyPrint()); + // 记录子线程执行结果 + salaryAcctCalculateBO.getResults().add(new SalaryAcctCalculateBO.Result(true, StringUtils.EMPTY)); + } catch (Exception e) { + log.error("薪资核算失败:{}", e.getMessage(), e); + salaryAcctCalculateBO.getResults().add(new SalaryAcctCalculateBO.Result(false, e.getMessage())); + } finally { + // 数据库字段加密用 +// DSTenantKeyThreadVar.tenantKey.remove(); + // 子线程执行完毕 + salaryAcctCalculateBO.getChildMonitor().countDown(); + } + } + + /** + * 运行公式 + * + * @param expressFormula + * @param formulaVarValueMap + * @return + */ + private ExcelResult runExpressFormula(ExpressFormula expressFormula, Map formulaVarValueMap, DataCollectionEmployee simpleEmployee) { + // 给公式中的变量填入值 + ExcelResult result = new ExcelResult(); + try { + List formulaVars = ExpressFormulaBO.buildFormulaVar4Accounting(expressFormula, formulaVarValueMap); + result = getFormulaRunService(user).run(expressFormula, formulaVars, simpleEmployee); + } catch (Exception e) { + log.error("express execute fail ", e); + result.setStatus(false); + result.setErrorMsg(e.getMessage()); + } + + //核算出错,给个默认值 + if (!result.isStatus() || result.getData() == null) { + if ("number".equals(expressFormula.getReturnType())) { + result.setData("0"); + } else { + result.setData(StringUtils.EMPTY); + } + } + return result; + } + + /** + * 处理合并计税 + * + * @return + */ + private String handleConsolidatedTax(String resultValue, SalaryItemPO salaryItemPO, SalaryAcctCalculateBO salaryAcctCalculateBO, List otherSalaryAcctEmployeePOS, List otherSalaryAcctResultPOS) { + // 如果相同税款所属期内没有其他薪资核算人员,就不存在合并计税 + if (salaryAcctCalculateBO.getTaxDeclarationFunction() == TaxDeclarationFunctionEnum.CLOSURE || CollectionUtils.isEmpty(otherSalaryAcctEmployeePOS) || CollectionUtils.isEmpty(otherSalaryAcctResultPOS)) { + return resultValue; + } + // 相同税款所属期内其他薪资核算记录 + Set otherSalaryAcctRecordIds = SalaryEntityUtil.properties(otherSalaryAcctEmployeePOS, SalaryAcctEmployeePO::getSalaryAcctRecordId); + List otherSalaryAcctRecordPOS = salaryAcctCalculateBO.getOtherSalaryAcctRecordPOS().stream().filter(e -> otherSalaryAcctRecordIds.contains(e.getId())).collect(Collectors.toList()); + // 相同税款所属期内,同一个个税扣缴义务人下的同一个人存在多次工资薪金类型的薪资核算记录,那么只有最早创建的薪资核算记录可以扣减如下数据:减除费用、专项扣除、专项附加扣除、其他扣除 + // 根据薪资核算记录的创建时间判断是否需要做合并计税处理 + boolean needConsolidatedTax = otherSalaryAcctRecordPOS.stream().anyMatch(salaryAcctRecordPO -> salaryAcctCalculateBO.getSalaryAcctRecordPO().getCreateTime().compareTo(salaryAcctRecordPO.getCreateTime()) > 0); + if (!needConsolidatedTax) { + return resultValue; + } + // 合并计税处理 + return SalaryAcctConsolidatedTaxBO.handleConsolidatedTaxValue(resultValue, salaryItemPO, salaryAcctCalculateBO.getSalaryItemPOS(), otherSalaryAcctResultPOS); + } +} diff --git a/src/com/engine/salary/service/impl/SalaryAcctEmployeeServiceImpl.java b/src/com/engine/salary/service/impl/SalaryAcctEmployeeServiceImpl.java new file mode 100644 index 000000000..1ad833b52 --- /dev/null +++ b/src/com/engine/salary/service/impl/SalaryAcctEmployeeServiceImpl.java @@ -0,0 +1,873 @@ +package com.engine.salary.service.impl; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.date.DateUtil; +import com.api.formmode.mybatis.util.SqlProxyHandle; +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.hrmelog.entity.dto.LoggerContext; +import com.engine.salary.config.SalaryElogConfig; +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.salaryacct.bo.SalaryAcctConfig; +import com.engine.salary.entity.salaryacct.bo.SalaryAcctEmployeeBO; +import com.engine.salary.entity.salaryacct.dto.SalaryAcctEmployeeCountDTO; +import com.engine.salary.entity.salaryacct.param.*; +import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO; +import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO; +import com.engine.salary.entity.salaryarchive.dto.SalaryArchiveDataDTO; +import com.engine.salary.entity.salarysob.dto.SalarySobCycleDTO; +import com.engine.salary.entity.salarysob.po.SalarySobItemPO; +import com.engine.salary.entity.salarysob.param.SalarySobQueryParam; +import com.engine.salary.entity.salarysob.po.SalarySobPO; +import com.engine.salary.entity.taxagent.param.TaxAgentQueryParam; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import com.engine.salary.enums.OperateTypeEnum; +import com.engine.salary.enums.auth.AuthFilterTypeEnum; +import com.engine.salary.enums.salaryaccounting.LockStatusEnum; +import com.engine.salary.enums.salaryaccounting.SalaryAcctRecordStatusEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.mapper.salaryacct.SalaryAcctEmployeeMapper; +import com.engine.salary.mapper.salarysob.SobTaxLinkMapper; +import com.engine.salary.mapper.sys.SalarySysConfMapper; +import com.engine.salary.report.entity.param.SalaryStatisticsReportDataQueryParam; +import com.engine.salary.service.*; +import com.engine.salary.sys.constant.SalarySysConstant; +import com.engine.salary.service.auth.AuthService; +import com.engine.salary.service.auth.AuthServiceImpl; +import com.engine.salary.sys.constant.SalarySysConstant; +import com.engine.salary.sys.entity.vo.OrderRuleVO; +import com.engine.salary.sys.service.SalarySysConfService; +import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl; +import com.engine.salary.util.SalaryDateUtil; +import com.engine.salary.util.SalaryEntityUtil; +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.page.SalaryPageUtil; +import com.engine.salary.util.valid.ValidUtil; +import com.google.common.collect.Lists; +import com.google.common.collect.Sets; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.BeanUtils; +import weaver.hrm.User; + +import java.util.*; +import java.util.stream.Collectors; + +import static com.engine.salary.sys.constant.SalarySysConstant.REPORT_ORGANIZATIN_TYPE; + +/** + * 薪资核算人员 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Slf4j +public class SalaryAcctEmployeeServiceImpl extends Service implements SalaryAcctEmployeeService { + + private SalaryAcctEmployeeMapper getSalaryAcctEmployeeMapper() { + return MapperProxyFactory.getProxy(SalaryAcctEmployeeMapper.class); + } + + private SobTaxLinkMapper getSobTaxLinkMapper() { + return MapperProxyFactory.getProxy(SobTaxLinkMapper.class); + } + + private SalaryAcctRecordService getSalaryAcctRecordService(User user) { + return ServiceUtil.getService(SalaryAcctRecordServiceImpl.class, user); + } + + private SalaryAcctResultService getSalaryAcctResultService(User user) { + return ServiceUtil.getService(SalaryAcctResultServiceImpl.class, user); + } + + private SalaryAcctReportServiceImpl getSalaryAcctReportService(User user) { + return ServiceUtil.getService(SalaryAcctReportServiceImpl.class, user); + } + + public AuthService getAuthService(User user) { + return ServiceUtil.getService(AuthServiceImpl.class, user); + } + +// private SalaryCheckResultDetailService salaryCheckResultDetailService; + +// private SalaryComparisonResultService salaryComparisonResultService; + + private SalarySobService getSalarySobService(User user) { + return ServiceUtil.getService(SalarySobServiceImpl.class, user); + } + + private SalaryEmployeeService getSalaryEmployeeService(User user) { + return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user); + } + + private SalaryArchiveService getSalaryArchiveService(User user) { + return ServiceUtil.getService(SalaryArchiveServiceImpl.class, user); + } + + private TaxAgentService getTaxAgentService(User user) { + return ServiceUtil.getService(TaxAgentServiceImpl.class, user); + } + + private SalarySysConfMapper getSalarySysConfMapper() { + return SqlProxyHandle.getProxy(SalarySysConfMapper.class); + } + + private SalarySysConfService getSalarySysConfService(User user) { + return ServiceUtil.getService(SalarySysConfServiceImpl.class, user); + } + + private SalaryCacheService getSalaryCacheService(User user) { + return ServiceUtil.getService(SalaryCacheServiceImpl.class, user); + } + + private SalaryAcctSobConfigService getSalaryAcctSobConfigService(User user) { + return ServiceUtil.getService(SalaryAcctSobConfigServiceImpl.class, user); + } + + + private boolean isRealOrg = "1".equals(getSalaryCacheService(user).get(REPORT_ORGANIZATIN_TYPE)); + + @Override + public List countBySalaryAcctRecordId(Collection salaryAcctRecordIds) { + if (CollectionUtils.isEmpty(salaryAcctRecordIds)) { + return Collections.emptyList(); + } + return getSalaryAcctEmployeeMapper().countGroupBySalaryAcctRecordId(salaryAcctRecordIds); + } + + @Override + public SalaryAcctEmployeePO getById(Long id) { + SalaryAcctEmployeePO po = getSalaryAcctEmployeeMapper().getById(id); + SalaryI18nUtil.i18n(po); + return po; + } + + @Override + public List listByIds(Collection ids) { + return getSalaryAcctEmployeeMapper().listSome(SalaryAcctEmployeePO.builder().ids(ids).build()); + } + + @Override + public List listBySalaryAcctRecordId(Long salaryAcctRecordId) { + return getSalaryAcctEmployeeMapper().listSome(SalaryAcctEmployeePO.builder().salaryAcctRecordId(salaryAcctRecordId).build()); + } + + @Override + public List listBySalaryAcctRecordIds(Collection salaryAcctRecordIds) { + return getSalaryAcctEmployeeMapper().listSome(SalaryAcctEmployeePO.builder().salaryAcctRecordIds(salaryAcctRecordIds).build()); + } + + @Override + public List listBySalaryAcctRecordIdAndTaxAgentId(Long salaryAcctRecordId, Long taxAgentId) { + return getSalaryAcctEmployeeMapper().listSome(SalaryAcctEmployeePO.builder().salaryAcctRecordId(salaryAcctRecordId).taxAgentId(taxAgentId).build()); + } + + @Override + public void addFromReduce(SalaryAcctEmployeeAddParam addParam) { +// ValidUtil.doValidator(addParam); +// // 查询薪资核算记录 +// SalaryAcctRecordPO salaryAcctRecordPO = getSalaryAcctRecordService(user).getById(addParam.getSalaryAcctRecordId()); +// if (Objects.isNull(salaryAcctRecordPO)) { +// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98747, "薪资核算记录不存在或已被删除")); +// } +// // 查询环比减少的薪资核算人员 +// List salaryAcctEmployeePOS = listByIds(addParam.getIds()); +// if (CollectionUtils.isEmpty(salaryAcctEmployeePOS)) { +// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98830, "薪资核算人员不存在或已被删除")); +// } +// // 添加薪资核算人员 +// Date now = new Date(); +// List newSalaryAcctEmployeePOS = salaryAcctEmployeePOS.stream().map(salaryAcctEmployeePO -> new SalaryAcctEmployeePO() +// .setSalaryAcctRecordId(salaryAcctRecordPO.getId()).setSalarySobId(salaryAcctRecordPO.getSalarySobId()).setSalaryMonth(salaryAcctRecordPO.getSalaryMonth()).setEmployeeId(salaryAcctEmployeePO.getEmployeeId()).setTaxAgentId(salaryAcctEmployeePO.getTaxAgentId()).setTenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY).setCreateTime(now).setUpdateTime(now).setCreator((long) user.getUID()).setDeleteType(0)).collect(Collectors.toList()); +// if (CollectionUtils.isNotEmpty(newSalaryAcctEmployeePOS)) { +// batchSave(newSalaryAcctEmployeePOS); +// } + } + + @Override + public List listBySalaryAcctRecordIdAndIds(Long salaryAcctRecordId, Collection ids) { + return getSalaryAcctEmployeeMapper().listSome(SalaryAcctEmployeePO.builder().salaryAcctRecordId(salaryAcctRecordId).ids(ids).build()); + } + + @Override + public List listBySalaryAcctRecordIdAndEmployeeIds(Long salaryAcctRecordId, Collection employeeIds) { + if (CollectionUtils.isEmpty(employeeIds)) { + return Collections.emptyList(); + } + return getSalaryAcctEmployeeMapper().listSome(SalaryAcctEmployeePO.builder().salaryAcctRecordId(salaryAcctRecordId).employeeIds(employeeIds).build()); + } + + @Override + public List listBySalaryAcctRecordIdsAndEmployeeIds(Collection salaryAcctRecordIds, Collection employeeIds) { + if (CollectionUtils.isEmpty(salaryAcctRecordIds) || CollectionUtils.isEmpty(employeeIds)) { + return Collections.emptyList(); + } + List> partition = Lists.partition((List) employeeIds, 500); + List list = new ArrayList<>(); + partition.forEach(l -> { + list.addAll(getSalaryAcctEmployeeMapper().listSome(SalaryAcctEmployeePO.builder().salaryAcctRecordIds(salaryAcctRecordIds).employeeIds(l).build())); + }); + + return list; + } + + @Override + public List listByRecordIdsAndEmpIdAndTaxAgentId(Collection salaryAcctRecordIds, Long employeeId, Long taxAgentId) { + if (CollectionUtils.isEmpty(salaryAcctRecordIds)) { + return Collections.emptyList(); + } + return getSalaryAcctEmployeeMapper().listSome(SalaryAcctEmployeePO.builder().salaryAcctRecordIds(salaryAcctRecordIds).employeeId(employeeId).taxAgentId(taxAgentId).build()); + } + + @Override + public PageInfo listPageByParam(SalaryAcctEmployeeQueryParam queryParam) { + ValidUtil.doValidator(queryParam); + + //排序配置 + OrderRuleVO orderRule = getSalarySysConfService(user).orderRule(); + queryParam.setOrderRule(orderRule); + + // 分页参数 + // 查询薪资核算人员 + List salaryAcctEmployeePOS = getSalaryAcctEmployeeMapper().listPage(queryParam); + return SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), + salaryAcctEmployeePOS, SalaryAcctEmployeePO.class); + } + + @Override + public List listByParam(SalaryAcctEmployeeQueryParam queryParam) { +// ValidUtil.doValidator(queryParam); + //排序配置 + OrderRuleVO orderRule = getSalarySysConfService(user).orderRule(); + queryParam.setOrderRule(orderRule); + return getSalaryAcctEmployeeMapper().list(queryParam); + } + + @Override + public PageInfo listPageByResultQueryParam(SalaryAcctResultQueryParam queryParam) { + ValidUtil.doValidator(queryParam); + // 薪资核算人员的查询参数 + SalaryAcctEmployeeQueryParam salaryAcctEmployeeQueryParam = new SalaryAcctEmployeeQueryParam(); + BeanUtils.copyProperties(queryParam, salaryAcctEmployeeQueryParam); + // 查询薪资核算人员(分页) + // 如果需要筛选是否合并计税 + if (StringUtils.isNotEmpty(queryParam.getConsolidatedTaxation()) && queryParam.getConsolidatedTaxation().equals("1")) { + return listPageByParam4ConsolidatedTax(salaryAcctEmployeeQueryParam); + } else { + return listPageByParam(salaryAcctEmployeeQueryParam); + } + } + + @Override + public List listByResultQueryParam(SalaryAcctResultQueryParam queryParam) { + // 薪资核算人员的查询参数 + SalaryAcctEmployeeQueryParam salaryAcctEmployeeQueryParam = new SalaryAcctEmployeeQueryParam(); + BeanUtils.copyProperties(queryParam, salaryAcctEmployeeQueryParam); + // 查询薪资核算人员 + List salaryAcctEmployeePOS; + // 如果需要筛选是否合并计税 + if (StringUtils.isNotEmpty(queryParam.getConsolidatedTaxation())) { + salaryAcctEmployeePOS = listByParam4ConsolidatedTax(salaryAcctEmployeeQueryParam); + } else { + salaryAcctEmployeePOS = listByParam(salaryAcctEmployeeQueryParam); + } + return salaryAcctEmployeePOS; + } + + + @Override + public PageInfo listPageByParam4Reduce(SalaryAcctEmployeeQueryParam queryParam) { + + // 查询薪资核算人员 + List salaryAcctEmployeePOS = listByParam4Reduce(queryParam); + PageInfo salaryAcctEmployeePOPageInfo = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), SalaryAcctEmployeePO.class); + // 分页参数 + salaryAcctEmployeePOPageInfo.setTotal(salaryAcctEmployeePOS.size()); + salaryAcctEmployeePOPageInfo.setList(SalaryPageUtil.subList(queryParam.getCurrent(), queryParam.getPageSize(), salaryAcctEmployeePOS)); + return salaryAcctEmployeePOPageInfo; + } + + @Override + public PageInfo listPageByParam4Add(SalaryAcctEmployeeQueryParam queryParam) { + // 查询薪资核算人员 + List salaryAcctEmployeePOS = listByParam4Add(queryParam); + PageInfo salaryAcctEmployeePOPageInfo = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), SalaryAcctEmployeePO.class); + // 分页参数 + salaryAcctEmployeePOPageInfo.setTotal(salaryAcctEmployeePOS.size()); + salaryAcctEmployeePOPageInfo.setList(SalaryPageUtil.subList(queryParam.getCurrent(), queryParam.getPageSize(), salaryAcctEmployeePOS)); + return salaryAcctEmployeePOPageInfo; + } + + + @Override + public List listByParam4Reduce(SalaryAcctEmployeeQueryParam queryParam) { + // 查询上个月的薪资核算记录(同一个薪资账套) + List salaryAcctRecordPOS = getSalaryAcctRecordService(user).listById4LastSalaryMonth(queryParam.getSalaryAcctRecordId()); + if (CollectionUtils.isEmpty(salaryAcctRecordPOS)) { + return Collections.emptyList(); + } + Set lastMonthSalaryAcctRecordIds = SalaryEntityUtil.properties(salaryAcctRecordPOS, SalaryAcctRecordPO::getId); + // 本月的核算人员 + List salaryAcctEmployeePOS = listBySalaryAcctRecordId(queryParam.getSalaryAcctRecordId()); + Set keySet = SalaryEntityUtil.properties(salaryAcctEmployeePOS, salaryAcctEmployeePO -> salaryAcctEmployeePO.getEmployeeId() + "-" + salaryAcctEmployeePO.getTaxAgentId()); + // 上个月的核算人员 + queryParam.setSalaryAcctRecordId(null); + queryParam.setSalaryAcctRecordIds(lastMonthSalaryAcctRecordIds); + List lastMonthSalaryAcctEmployeePOS = listByParam(queryParam); + Map lastMonthSalaryAcctEmployeePOMap = SalaryEntityUtil.convert2Map(lastMonthSalaryAcctEmployeePOS, salaryAcctEmployeePO -> salaryAcctEmployeePO.getEmployeeId() + "-" + salaryAcctEmployeePO.getTaxAgentId()); + + List resultList = Lists.newArrayList(); + if (CollectionUtils.isNotEmpty(keySet)) { + lastMonthSalaryAcctEmployeePOMap.forEach((k, v) -> { + if (!keySet.contains(k)) { + resultList.add(v); + } + }); + } + return resultList; + } + + @Override + public List listByParam4Add(SalaryAcctEmployeeQueryParam queryParam) { + // 查询上个月的薪资核算记录(同一个薪资账套) + List salaryAcctRecordPOS = getSalaryAcctRecordService(user).listById4LastSalaryMonth(queryParam.getSalaryAcctRecordId()); + if (CollectionUtils.isEmpty(salaryAcctRecordPOS)) { + return Collections.emptyList(); + } + Set lastMonthSalaryAcctRecordIds = SalaryEntityUtil.properties(salaryAcctRecordPOS, SalaryAcctRecordPO::getId); + // 上个月的核算人员 + List lastMonthSalaryAcctEmployeePOS = listBySalaryAcctRecordIds(lastMonthSalaryAcctRecordIds); + Map lastMonthSalaryAcctEmployeePOMap = SalaryEntityUtil.convert2Map(lastMonthSalaryAcctEmployeePOS, salaryAcctEmployeePO -> salaryAcctEmployeePO.getEmployeeId() + "-" + salaryAcctEmployeePO.getTaxAgentId()); + // 本月的核算人员 + List salaryAcctEmployeePOS = listByParam(queryParam); +// Set keySet = SalaryEntityUtil.properties(salaryAcctEmployeePOS, salaryAcctEmployeePO -> salaryAcctEmployeePO.getEmployeeId() + "-" + salaryAcctEmployeePO.getTaxAgentId()); + Map thisMonthSalaryAcctEmployeePOMap = SalaryEntityUtil.convert2Map(salaryAcctEmployeePOS, salaryAcctEmployeePO -> salaryAcctEmployeePO.getEmployeeId() + "-" + salaryAcctEmployeePO.getTaxAgentId()); + List resultList = Lists.newArrayList(); + thisMonthSalaryAcctEmployeePOMap.forEach((k, v) -> { + if (!lastMonthSalaryAcctEmployeePOMap.containsKey(k)) { + resultList.add(v); + } + }); + return resultList; + } + + + @Override + public PageInfo listPageByParam4ConsolidatedTax(SalaryAcctEmployeeQueryParam queryParam) { + //排序配置 + OrderRuleVO orderRule = getSalarySysConfService(user).orderRule(); + queryParam.setOrderRule(orderRule); + // 查询合并计税的其他薪资核算记录 + List otherSalaryAcctRecordPOS = getSalaryAcctRecordService(user).listById4OtherConsolidatedTax(queryParam.getSalaryAcctRecordId()); + if (CollectionUtils.isEmpty(otherSalaryAcctRecordPOS)) { + return new PageInfo<>(); + } + // 查询合并计税的薪资核算人员 + Set otherSalaryAcctRecordIds = SalaryEntityUtil.properties(otherSalaryAcctRecordPOS, SalaryAcctRecordPO::getId); + // 分页参数 + List salaryAcctEmployeePOS = new ArrayList<>(); + if (CollUtil.isNotEmpty(queryParam.getIds())) { + List list = new ArrayList<>(); + List> partition = Lists.partition(queryParam.getIds(), 500); + partition.forEach(ids -> { + queryParam.setIds(ids); + list.addAll(getSalaryAcctEmployeeMapper().list4ConsolidatedTax(otherSalaryAcctRecordIds, queryParam)); + }); + salaryAcctEmployeePOS = list; + } else { + salaryAcctEmployeePOS = getSalaryAcctEmployeeMapper().listPage4ConsolidatedTax(otherSalaryAcctRecordIds, queryParam); + } + return SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), + salaryAcctEmployeePOS, SalaryAcctEmployeePO.class); + } + + @Override + public List listByParam4ConsolidatedTax(SalaryAcctEmployeeQueryParam queryParam) { + //排序配置 + OrderRuleVO orderRule = getSalarySysConfService(user).orderRule(); + queryParam.setOrderRule(orderRule); + // 查询合并计税的其他薪资核算记录 + List otherSalaryAcctRecordPOS = getSalaryAcctRecordService(user).listById4OtherConsolidatedTax(queryParam.getSalaryAcctRecordId()); + if (CollectionUtils.isEmpty(otherSalaryAcctRecordPOS)) { + return Collections.emptyList(); + } + // 查询合并计税的薪资核算人员 + Set otherSalaryAcctRecordIds = SalaryEntityUtil.properties(otherSalaryAcctRecordPOS, SalaryAcctRecordPO::getId); + + List list = new ArrayList<>(); + if (CollUtil.isNotEmpty(queryParam.getIds())) { + List> partition = Lists.partition(queryParam.getIds(), 500); + partition.forEach(ids -> { + queryParam.setIds(ids); + list.addAll(getSalaryAcctEmployeeMapper().list4ConsolidatedTax(otherSalaryAcctRecordIds, queryParam)); + }); + return list; + } + + return getSalaryAcctEmployeeMapper().list4ConsolidatedTax(otherSalaryAcctRecordIds, queryParam); + } + + @Override + public void save(SalaryAcctEmployeeSaveParam saveParam) { + ValidUtil.doValidator(saveParam); + + // 查询薪资核算记录 + SalaryAcctRecordPO salaryAcctRecordPO = getSalaryAcctRecordService(user).getById(saveParam.getSalaryAcctRecordId()); + if (Objects.isNull(salaryAcctRecordPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98747, "薪资核算记录不存在或已被删除")); + } + // 查询薪资核算人员 + List existSalaryAcctEmployeePOS = listBySalaryAcctRecordIdAndEmployeeIds(saveParam.getSalaryAcctRecordId(), saveParam.getEmployeeIds()); + if (CollectionUtils.isNotEmpty(existSalaryAcctEmployeePOS)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(101581, "人员已存在,请勿重复添加")); + } + // 根据薪资账套查询薪资周期 + SalarySobCycleDTO salarySobCycleDTO = getSalarySobService(user).getSalarySobCycle(salaryAcctRecordPO.getSalarySobId(), SalaryDateUtil.localDate2YearMonth(salaryAcctRecordPO.getSalaryMonth())); + //获取核算的扣缴义务人 + SalarySobPO salarySobPO = getSalarySobService(user).getById(salaryAcctRecordPO.getSalarySobId()); + if (Objects.isNull(salarySobPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98769, "薪资账套不存在或已被删除")); + } + List taxAgentIds = salarySobPO.getTaxAgentIds(); + + List employees = getSalaryEmployeeService(user).getEmployeeByIdsAll((List) saveParam.getEmployeeIds()); + + // 查询薪资档案 + List salaryArchiveDataDTOS = getSalaryArchiveService(user).getSalaryArchiveTaxAgentData(salarySobCycleDTO.getSalaryCycle(), saveParam.getEmployeeIds(), taxAgentIds); + // 转换成薪资核算人员po + List salaryAcctEmployeePOS = SalaryAcctEmployeeBO.convert2Employee(employees, salaryAcctRecordPO, salaryArchiveDataDTOS, (long) user.getUID()); + + + //过滤不是扣缴义务人下的人员 + salaryAcctEmployeePOS = salaryAcctEmployeePOS.stream().filter(ps -> taxAgentIds.contains(ps.getTaxAgentId())).collect(Collectors.toList()); + // 保存薪资核算人员 + if (CollectionUtils.isEmpty(salaryAcctEmployeePOS)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98769, "个税扣缴义务人下无该人员档案信息或薪资缴纳日期不在薪资周期内")); + } + + //保存核算人员 + saveAcctEmployeePOS(salaryAcctEmployeePOS, salarySobCycleDTO); + + + // 记录日志 + String targetName = salarySobPO.getName() + ":" + SalaryDateUtil.localDate2YearMonth(salaryAcctRecordPO.getSalaryMonth()); + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId("" + salaryAcctRecordPO.getId()); + loggerContext.setTargetName(targetName); + loggerContext.setOperateType(OperateTypeEnum.ADD.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "添加薪资核算人员")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "添加薪资核算人员") + ":" + targetName); + loggerContext.setNewValueList(salaryAcctEmployeePOS); + SalaryElogConfig.salaryAcctRecordLoggerTemplate.write(loggerContext); + } + + private void saveAcctEmployeePOS(List salaryAcctEmployeePOS, SalarySobCycleDTO sobCycle) { + + boolean shotEmpBtn = "1".equals(getSalarySysConfService(user).getValueByCode(SalarySysConstant.SHOT_EMP_BTN)); + + //替换快照数据 + if (shotEmpBtn) { +// String valueByCode = getSalarySysConfService(user).getValueByCode(SalarySysConstant.SHOT_EMP_TIME_TYPE); + shotEmpData(salaryAcctEmployeePOS, sobCycle.getSalaryCycleFromDate()); + } + //保存 + batchSave(salaryAcctEmployeePOS); + } + + private void shotEmpData(List salaryAcctEmployeePOS, Date shotTime) { + List employees = SalaryEntityUtil.properties(salaryAcctEmployeePOS, SalaryAcctEmployeePO::getEmployeeId, Collectors.toList()); + List snapshot = getSalaryEmployeeService(user).snapshot(employees, shotTime); + Map shotEmpMap = SalaryEntityUtil.convert2Map(snapshot, DataCollectionEmployee::getEmployeeId); + salaryAcctEmployeePOS.forEach(salaryAcctEmployeePO -> { + DataCollectionEmployee shotEmp = shotEmpMap.getOrDefault(salaryAcctEmployeePO.getEmployeeId(), new DataCollectionEmployee()); + salaryAcctEmployeePO.setDepartmentId(shotEmp.getDepartmentId()); + salaryAcctEmployeePO.setDepartmentName(shotEmp.getDepartmentName()); + salaryAcctEmployeePO.setJobcall(shotEmp.getJobcall()); + salaryAcctEmployeePO.setJobcallId(shotEmp.getJobcallId()); + salaryAcctEmployeePO.setJobtitleId(shotEmp.getJobtitleId()); + salaryAcctEmployeePO.setJobtitleName(shotEmp.getJobtitleName()); + salaryAcctEmployeePO.setSubcompanyId(shotEmp.getSubcompanyid()); + salaryAcctEmployeePO.setSubcompanyName(shotEmp.getSubcompanyName()); + salaryAcctEmployeePO.setStatus(shotEmp.getStatus()); + salaryAcctEmployeePO.setAccountType(shotEmp.getAccountType()); + }); + } + + @Override + public void batchSave(Collection salaryAcctEmployeePOS) { + if (CollectionUtils.isEmpty(salaryAcctEmployeePOS)) { + return; + } + List> partition = Lists.partition((List) salaryAcctEmployeePOS, 50); + partition.forEach(getSalaryAcctEmployeeMapper()::batchInsert); + } + + @Override + public void deleteByIds(Collection ids) { + + if (CollectionUtils.isEmpty(ids)) { + return; + } + + // 删除薪资核算人员 + getSalaryAcctEmployeeMapper().deleteByIds(ids); + // 删除薪资核算人员对应的薪资核算结果 + getSalaryAcctResultService(user).deleteBySalaryAcctEmployeeIds(ids); + // 删除报表 + getSalaryAcctReportService(user).deleteBySalaryAcctEmpIds(ids); + + // 删除薪资核算人员对应的校验异常明细 +// salaryCheckResultDetailService.deleteBySalaryAcctEmployeeIds(ids); + // 删除薪资核算人员对应的线下对比结果 +// salaryComparisonResultService.deleteBySalaryAcctRecordIds(ids); + } + + @Override + public void deleteByParam(SalaryAcctEmployeeDeleteParam deleteParam) { + ValidUtil.doValidator(deleteParam); + // 查询薪资核算记录 + SalaryAcctRecordPO salaryAcctRecordPO = getSalaryAcctRecordService(user).getById(deleteParam.getSalaryAcctRecordId()); + if (Objects.isNull(salaryAcctRecordPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98747, "薪资核算记录不存在或已被删除")); + } + // 回算不允许删除薪资核算人员 + if (Objects.equals(salaryAcctRecordPO.getBackCalcStatus(), 1)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "正常薪资已经发放,薪资回算时,不允许再删除薪资核算人员")); + } + // 只有未归档时才能删除薪资核算人员 + if (!Objects.equals(salaryAcctRecordPO.getStatus(), SalaryAcctRecordStatusEnum.NOT_ARCHIVED.getValue())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98830, "薪资核算已归档或已申报,不允许再删除薪资核算人员")); + } + // 查询薪资核算人员 + List salaryAcctEmployeePOS = listBySalaryAcctRecordIdAndIds(deleteParam.getSalaryAcctRecordId(), deleteParam.getIds()); + if (CollectionUtils.isEmpty(salaryAcctEmployeePOS)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98830, "薪资核算人员不存在或已被删除")); + } + // 删除薪资核算人员 + Set ids = SalaryEntityUtil.properties(salaryAcctEmployeePOS, SalaryAcctEmployeePO::getId); + deleteByIds(ids); + + // 查询薪资账套(记录日志用) + SalarySobPO salarySobPO = getSalarySobService(user).getById(salaryAcctRecordPO.getSalarySobId()); + if (Objects.isNull(salarySobPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98769, "薪资账套不存在或已被删除")); + } + // 记录日志 + String targetName = salarySobPO.getName() + ":" + SalaryDateUtil.localDate2YearMonth(salaryAcctRecordPO.getSalaryMonth()); + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId("" + salaryAcctRecordPO.getId()); + loggerContext.setTargetName(targetName); + loggerContext.setOperateType(OperateTypeEnum.DELETE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "删除薪资核算人员")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "删除薪资核算人员") + ":" + targetName); + loggerContext.setOldValueList(salaryAcctEmployeePOS); + SalaryElogConfig.salaryAcctRecordLoggerTemplate.write(loggerContext); + } + + @Override + public void deleteBySalaryAcctRecordIds(Collection salaryAcctRecordIds) { + getSalaryAcctEmployeeMapper().deleteBySalaryAcctRecordIds(salaryAcctRecordIds); + } + + @Override + public void initBySalaryAcctRecord(SalaryAcctRecordPO salaryAcctRecordPO) { + // 根据薪资账套查询人员 + List salaryEmployees = getSalaryEmployeeService(user).listBySalarySobId(salaryAcctRecordPO.getSalarySobId(), true); + if (CollectionUtils.isEmpty(salaryEmployees)) { + return; + } + // 根据薪资账套查询薪资周期 + SalarySobCycleDTO salarySobCycleDTO = getSalarySobService(user).getSalarySobCycle(salaryAcctRecordPO.getSalarySobId(), SalaryDateUtil.localDate2YearMonth(salaryAcctRecordPO.getSalaryMonth())); + +// // 根据薪资账套的"核算人员范围"过滤入职日期大于薪资周期止的人员 +// salaryEmployees = salaryEmployees.stream().filter(salaryEmployee -> StringUtils.isBlank(salaryEmployee.getCompanystartdate()) || (SalaryDateUtil.stringToDate(salaryEmployee.getCompanystartdate()) != null && SalaryDateUtil.stringToDate(salaryEmployee.getCompanystartdate()).compareTo(salarySobCycleDTO.getSalaryCycle().getEndDate()) <= 0)).collect(Collectors.toList()); +// +// +// // 根据薪资账套的"核算人员范围"过滤离职日期小于薪资周期起的人员 +// salaryEmployees = salaryEmployees.stream().filter(salaryEmployee -> StringUtils.isBlank(salaryEmployee.getDismissdate()) || (SalaryDateUtil.stringToDate(salaryEmployee.getCompanystartdate()) != null && SalaryDateUtil.stringToDate(salaryEmployee.getDismissdate()).compareTo(salarySobCycleDTO.getSalaryCycle().getEndDate()) > 0)).collect(Collectors.toList()); + + + //查询账套对应的扣缴义务人 + SalarySobPO salarySobPO = getSalarySobService(user).getById(salaryAcctRecordPO.getSalarySobId()); + List taxAgentIds = salarySobPO.getTaxAgentIds(); + + // 查询薪资档案,获取人员的个税扣缴义务人 + List employeeIds = SalaryEntityUtil.properties(salaryEmployees, DataCollectionEmployee::getEmployeeId, Collectors.toList()); + List salaryArchiveDataDTOS = getSalaryArchiveService(user).getSalaryArchiveTaxAgentData(salarySobCycleDTO.getSalaryCycle(), employeeIds, taxAgentIds); + // 转换成薪资核算人员po + List salaryAcctEmployeePOS = SalaryAcctEmployeeBO.convert2Employee(salaryEmployees, salaryAcctRecordPO, salaryArchiveDataDTOS, (long) user.getUID()); + + //过滤掉不属于当前账套扣缴义务人的人员 + salaryAcctEmployeePOS = salaryAcctEmployeePOS.stream().filter(po -> taxAgentIds.contains(po.getTaxAgentId())).collect(Collectors.toList()); + + // 保存薪资核算人员 + if (CollectionUtils.isNotEmpty(salaryAcctEmployeePOS)) { + saveAcctEmployeePOS(salaryAcctEmployeePOS, salarySobCycleDTO); + } + } + + @Override + public void refresh(Long salaryAcctRecordId) { + // 查询薪资核算记录 + SalaryAcctRecordPO salaryAcctRecordPO = getSalaryAcctRecordService(user).getById(salaryAcctRecordId); + if (Objects.isNull(salaryAcctRecordPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98747, "薪资核算记录不存在或已被删除")); + } + + // 根据薪资账套查询人员 + List salaryEmployees = getSalaryEmployeeService(user).listBySalarySobId(salaryAcctRecordPO.getSalarySobId(), true); + if (CollectionUtils.isEmpty(salaryEmployees)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98747, "未查询到账套下关联人员")); + } + + // 根据薪资账套查询薪资周期 + SalarySobCycleDTO salarySobCycleDTO = getSalarySobService(user).getSalarySobCycle(salaryAcctRecordPO.getSalarySobId(), SalaryDateUtil.localDate2YearMonth(salaryAcctRecordPO.getSalaryMonth())); + + //查询账套对应的扣缴义务人 + SalarySobPO salarySobPO = getSalarySobService(user).getById(salaryAcctRecordPO.getSalarySobId()); + List taxAgentIds = salarySobPO.getTaxAgentIds(); + + // 查询薪资档案,获取人员的个税扣缴义务人 + List employeeIds = SalaryEntityUtil.properties(salaryEmployees, DataCollectionEmployee::getEmployeeId, Collectors.toList()); + List salaryArchiveDataDTOS = getSalaryArchiveService(user).getSalaryArchiveTaxAgentData(salarySobCycleDTO.getSalaryCycle(), employeeIds, taxAgentIds); + + // 转换成薪资核算人员po + List newEmps = SalaryAcctEmployeeBO.convert2Employee(salaryEmployees, salaryAcctRecordPO, salaryArchiveDataDTOS, (long) user.getUID()); + //过滤掉不属于当前账套扣缴义务人的人员 + newEmps = newEmps.stream().filter(po -> taxAgentIds.contains(po.getTaxAgentId())).collect(Collectors.toList()); + Map newEmpMap = SalaryEntityUtil.convert2Map(newEmps, e -> e.getTaxAgentId() + "_" + e.getEmployeeId()); + + + // 查询薪资核算人员 + List oldEmps = listBySalaryAcctRecordId(salaryAcctRecordId); + Map oldEmpMap = SalaryEntityUtil.convert2Map(oldEmps, e -> e.getTaxAgentId() + "_" + e.getEmployeeId()); + + //新增 + List addEmps = newEmps.stream().filter(po -> !oldEmpMap.containsKey(po.getTaxAgentId() + "_" + po.getEmployeeId())).collect(Collectors.toList()); + + //删除 + List delIds = oldEmps.stream().filter(po -> !newEmpMap.containsKey(po.getTaxAgentId() + "_" + po.getEmployeeId())).map(SalaryAcctEmployeePO::getId).collect(Collectors.toList()); + + deleteByIds(delIds); + + saveAcctEmployeePOS(addEmps, salarySobCycleDTO); + } + + + @Override + public List listBySalaryStatisticsReportParam(SalaryStatisticsReportDataQueryParam param) { + //排序配置 + OrderRuleVO orderRule = getSalarySysConfService(user).orderRule(); + SalaryAcctEmployeeQueryParam lambdaQueryChainWrapper = new SalaryAcctEmployeeQueryParam(); + lambdaQueryChainWrapper.setOrderRule(orderRule); + + // 个税扣缴义务人 +// Collection taxAgentList = getTaxAgentService(user).listAllTaxAgents((long) user.getUID()); +// if (CollectionUtils.isNotEmpty(taxAgentList)) { +// List taxAgentIds = taxAgentList.stream().map(TaxAgentPO::getId).collect(Collectors.toList()); +// // 有查询参数就取交集 +// if (CollectionUtils.isNotEmpty(param.getTaxAgent())) { +// List finalTaxAgentIds = taxAgentIds; +// taxAgentIds = param.getTaxAgent().stream().filter(finalTaxAgentIds::contains).collect(Collectors.toList()); +// lambdaQueryChainWrapper.setTaxAgentIds(CollectionUtils.isEmpty(taxAgentIds) ? Collections.singletonList(0L) : taxAgentIds); +// } else { +// lambdaQueryChainWrapper.setTaxAgentIds(taxAgentIds); +// } +// } else { +// lambdaQueryChainWrapper.setTaxAgentIds(Collections.singletonList(0L)); +// } + + if (CollectionUtils.isNotEmpty(param.getTaxAgent())) { + lambdaQueryChainWrapper.setTaxAgentIds(param.getTaxAgent()); + } else { + TaxAgentQueryParam taxAgentQueryParam = TaxAgentQueryParam.builder().build(); + taxAgentQueryParam.setFilterType(AuthFilterTypeEnum.QUERY_DATA); + Collection taxAgentPOS = getTaxAgentService(user).listAuth(taxAgentQueryParam); + List canManageTaxAgentIds = taxAgentPOS.stream().map(TaxAgentPO::getId).collect(Collectors.toList()); + // 分权 + if (CollectionUtils.isEmpty(canManageTaxAgentIds)) { + // 无权限 + return Collections.emptyList(); + } + lambdaQueryChainWrapper.setTaxAgentIds(canManageTaxAgentIds); + } + + if (CollectionUtils.isNotEmpty(param.getSalarySob())) { + lambdaQueryChainWrapper.setSalarySobIds(param.getSalarySob()); + } else { + // 分权 + SalarySobQueryParam salarySobQueryParam = new SalarySobQueryParam(); + salarySobQueryParam.setFilterType(AuthFilterTypeEnum.QUERY_DATA); + List salarySobPOS = getSalarySobService(user).listAuth(salarySobQueryParam); + if (CollectionUtils.isEmpty(salarySobPOS)) { + // 无权限 + return Collections.emptyList(); + } + lambdaQueryChainWrapper.setSalarySobIds(salarySobPOS.stream().map(SalarySobPO::getId).collect(Collectors.toList())); + } + + // 薪资所属月 + Date startYearMonth = SalaryDateUtil.dateStrToLocalYearMonth(param.getSalaryStartMonth()); + Date endYearMonth = SalaryDateUtil.dateStrToLocalYearMonth(param.getSalaryEndMonth()); + if (Objects.nonNull(startYearMonth) && Objects.nonNull(endYearMonth)) { + Set yearMonths = Sets.newHashSet(); + while (!startYearMonth.after(endYearMonth)) { + yearMonths.add(startYearMonth); + startYearMonth = DateUtil.offsetMonth(startYearMonth, 1); + } + lambdaQueryChainWrapper.setSalaryMonths(yearMonths); + } + + //排除未归档数据 + List salaryAcctRecordPOS = getSalaryAcctRecordService(user).listAll(); + List salaryAcctRecordIds = salaryAcctRecordPOS.stream() + .filter(po -> !Objects.equals(po.getStatus(), SalaryAcctRecordStatusEnum.NOT_ARCHIVED.getValue())) + .map(SalaryAcctRecordPO::getId) + .collect(Collectors.toList()); + + List list = new ArrayList<>(); + if (CollectionUtils.isNotEmpty(salaryAcctRecordIds)) { + //分片查询 + List> partition = Lists.partition(salaryAcctRecordIds, 500); + for (List part : partition) { + lambdaQueryChainWrapper.setSalaryAcctRecordIds(part); + List pos = getSalaryAcctEmployeeMapper().list(lambdaQueryChainWrapper); + list.addAll(pos); + } + } + + if (CollectionUtils.isEmpty(list)) { + return Lists.newArrayList(); + } + List employeeIds = list.stream().map(SalaryAcctEmployeePO::getEmployeeId).collect(Collectors.toList()); + + + List employeeList = getSalaryEmployeeService(user).listByIds(employeeIds); + // 获取分部信息 + List subCompanyIds = param.getSubCompany(); + if (CollectionUtils.isNotEmpty(subCompanyIds)) { + if (isRealOrg) { + employeeList = employeeList.stream().filter(emp -> subCompanyIds.contains(emp.getSubcompanyid())).collect(Collectors.toList()); + } else { + list = list.stream().filter(emp -> subCompanyIds.contains(emp.getSubcompanyId())).collect(Collectors.toList()); + } + } + + // 部门过滤 + List depart = param.getDepart(); + if (CollectionUtils.isNotEmpty(depart)) { + if (isRealOrg) { + employeeList = employeeList.stream().filter(emp -> depart.contains(emp.getDepartmentId())).collect(Collectors.toList()); + } else { + list = list.stream().filter(emp -> depart.contains(emp.getDepartmentId())).collect(Collectors.toList()); + } + } + // 岗位过滤 + List position = param.getPosition(); + if (CollectionUtils.isNotEmpty(position)) { + if (isRealOrg) { + employeeList = employeeList.stream().filter(emp -> position.contains(emp.getJobtitleId())).collect(Collectors.toList()); + } else { + list = list.stream().filter(emp -> position.contains(emp.getJobtitleId())).collect(Collectors.toList()); + } + } + // 人事状态过滤 + if (CollectionUtils.isNotEmpty(param.getStatus())) { + if (isRealOrg) { + Set employeeIdsByStatus = new HashSet<>(); + employeeList.forEach(simpleEmployee -> { + if (simpleEmployee.getStatus() != null && param.getStatus().contains(simpleEmployee.getStatus())) { + employeeIdsByStatus.add(simpleEmployee.getEmployeeId()); + } + }); + if (CollectionUtils.isEmpty(employeeIdsByStatus)) { + return Lists.newArrayList(); + } + list = list.stream().filter(po -> employeeIdsByStatus.contains(po.getEmployeeId())).collect(Collectors.toList()); + } else { + list = list.stream().filter(po -> po.getStatus() != null && param.getStatus().contains(po.getStatus())).collect(Collectors.toList()); + } + } + // 入职日期 + if (CollectionUtils.isNotEmpty(param.getHiredate())) { + Set employeeIdsByHiredate = new HashSet<>(); + employeeList.forEach(simpleEmployee -> { + Date hiredate = SalaryDateUtil.stringToDate(simpleEmployee.getCompanystartdate()); + if (hiredate != null && !hiredate.before(param.getHiredate().get(0)) && !hiredate.after(param.getHiredate().get(1))) { + employeeIdsByHiredate.add(simpleEmployee.getEmployeeId()); + } + }); + if (CollectionUtils.isEmpty(employeeIdsByHiredate)) { + return Lists.newArrayList(); + } + list = list.stream().filter(po -> employeeIdsByHiredate.contains(po.getEmployeeId())).collect(Collectors.toList()); + } + // 人员 + if (CollectionUtils.isNotEmpty(param.getEmployee())) { + list = list.stream().filter(po -> param.getEmployee().contains(po.getEmployeeId())).collect(Collectors.toList()); + } + + if (isRealOrg) { + Set empIds = SalaryEntityUtil.properties(employeeList, DataCollectionEmployee::getEmployeeId); + list = list.stream().filter(po -> empIds.contains(po.getEmployeeId())).collect(Collectors.toList()); + } + + return list; + } + + @Override + public List listByTaxAgentAndSalaryMonth(List taxAgentIds, Set salaryMonths) { + return getSalaryAcctEmployeeMapper().listSome(SalaryAcctEmployeePO.builder().taxAgentIds(taxAgentIds).salaryMonths(salaryMonths).build()); + } + + @Override + public List listBySobAndSalaryMonth(List salarySobIds, Set salaryMonths) { + return getSalaryAcctEmployeeMapper().listSome(SalaryAcctEmployeePO.builder().salarySobIds(salarySobIds).salaryMonths(salaryMonths).build()); + } + + @Override + public void lockEmp(SalaryAcctResultUpdateLockStatusParam updateParam) { + List salaryAcctEmployees = listByIds(updateParam.getAcctEmpIds()); + if (CollectionUtils.isEmpty(salaryAcctEmployees)) { + return; + } + + LockStatusEnum lockStatus = updateParam.getLockStatus(); + if (lockStatus == null) { + throw new SalaryRunTimeException("锁定状态异常!"); + } + + if (updateParam.getLockStatus() == LockStatusEnum.LOCK) { + SalaryAcctConfig salaryAcctSobConfig = getSalaryAcctSobConfigService(user).getSalaryAcctConfig(updateParam.getSalaryAcctRecordId()); + List salarySobItems = salaryAcctSobConfig.getSalarySobItems(); + List itemIds = SalaryEntityUtil.properties(salarySobItems, SalarySobItemPO::getSalaryItemId, Collectors.toList()); + + salaryAcctEmployees.forEach(salaryAcctEmployeePO -> { + salaryAcctEmployeePO.setLockItems(itemIds); + lock(salaryAcctEmployeePO); + }); + } else { + salaryAcctEmployees.forEach(salaryAcctEmployeePO -> { + salaryAcctEmployeePO.setLockItems(new ArrayList<>()); + lock(salaryAcctEmployeePO); + }); + } + } + + @Override + public void updateIgnoreNull(SalaryAcctEmployeePO salaryAcctEmployeePO) { + getSalaryAcctEmployeeMapper().updateIgnoreNull(salaryAcctEmployeePO); + } + + @Override + public void lock(SalaryAcctEmployeePO salaryAcctEmployeePO) { + getSalaryAcctEmployeeMapper().lock(salaryAcctEmployeePO); + } +} diff --git a/src/com/engine/salary/service/impl/SalaryAcctExcelServiceImpl.java b/src/com/engine/salary/service/impl/SalaryAcctExcelServiceImpl.java new file mode 100644 index 000000000..67aff3ecd --- /dev/null +++ b/src/com/engine/salary/service/impl/SalaryAcctExcelServiceImpl.java @@ -0,0 +1,1689 @@ +package com.engine.salary.service.impl; + +import cn.hutool.core.util.NumberUtil; +import cn.hutool.core.util.StrUtil; +import com.api.formmode.mybatis.util.SqlProxyHandle; +import com.cloudstore.dev.api.util.Util_DataCache; +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.hrmelog.entity.dto.LoggerContext; +import com.engine.salary.component.WeaTableColumnGroup; +import com.engine.salary.config.SalaryElogConfig; +import com.engine.salary.constant.SalaryDefaultTenantConstant; +import com.engine.salary.constant.SalaryItemConstant; +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.report.po.SalaryAcctResultReportPO; +import com.engine.salary.entity.salaryacct.bo.SalaryAcctConfig; +import com.engine.salary.entity.salaryacct.bo.SalaryAcctEmployeeBO; +import com.engine.salary.entity.salaryacct.bo.SalaryAcctResultBO; +import com.engine.salary.entity.salaryacct.bo.SalaryAcctResultLogBO; +import com.engine.salary.entity.salaryacct.dto.SalaryAccEmployeeListDTO; +import com.engine.salary.entity.salaryacct.dto.SalaryAcctImportFieldDTO; +import com.engine.salary.entity.salaryacct.dto.SalaryAcctResultTemplateDTO; +import com.engine.salary.entity.salaryacct.dto.SalaryComparisonResultListDTO; +import com.engine.salary.entity.salaryacct.param.*; +import com.engine.salary.entity.salaryacct.po.*; +import com.engine.salary.entity.salaryitem.po.SalaryItemPO; +import com.engine.salary.entity.salarysob.bo.SalarySobItemAggregateBO; +import com.engine.salary.entity.salarysob.dto.SalarySobEmpFieldDTO; +import com.engine.salary.entity.salarysob.dto.SalarySobItemAggregateDTO; +import com.engine.salary.entity.salarysob.po.SalarySobEmpFieldPO; +import com.engine.salary.entity.salarysob.po.SalarySobItemGroupPO; +import com.engine.salary.entity.salarysob.po.SalarySobItemPO; +import com.engine.salary.entity.salarysob.po.SalarySobPO; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import com.engine.salary.enums.OperateTypeEnum; +import com.engine.salary.enums.UserStatusEnum; +import com.engine.salary.enums.salaryaccounting.LockStatusEnum; +import com.engine.salary.enums.salaryaccounting.SalaryAcctResultDataSourceEnum; +import com.engine.salary.enums.salaryitem.SalaryDataTypeEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.mapper.sys.SalarySysConfMapper; +import com.engine.salary.service.*; +import com.engine.salary.sys.constant.SalarySysConstant; +import com.engine.salary.sys.entity.po.SalarySysConfPO; +import com.engine.salary.sys.enums.OpenEnum; +import com.engine.salary.sys.service.SalarySysConfService; +import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl; +import com.engine.salary.util.*; +import com.engine.salary.util.db.IdGenerator; +import com.engine.salary.util.excel.ExcelParseHelper; +import com.engine.salary.util.excel.ExcelPreviewDTO; +import com.engine.salary.util.excel.ExcelSupport; +import com.engine.salary.util.excel.ExcelUtilPlus; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.util.page.SalaryPageUtil; +import com.engine.salary.util.valid.ValidUtil; +import com.engine.salary.wrapper.SalarySobItemWrapper; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.google.common.collect.Sets; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.collections4.ListUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.math.NumberUtils; +import org.apache.poi.ss.usermodel.FormulaEvaluator; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.util.IOUtils; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.springframework.beans.BeanUtils; +import org.springframework.util.StopWatch; +import weaver.file.ImageFileManager; +import weaver.hrm.User; + +import java.io.InputStream; +import java.math.BigDecimal; +import java.util.*; +import java.util.stream.Collectors; + +import static com.engine.salary.sys.constant.SalarySysConstant.OPEN_ACCT_RESULT_SUM; +import static com.engine.salary.sys.constant.SalarySysConstant.SALARY_ACCT_FIXED_COLUMNS; +import static com.engine.salary.util.excel.ExcelSupport.EXCEL_TYPE_XLSX; + +/** + * 薪资核算导入导出 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Slf4j +public class SalaryAcctExcelServiceImpl extends Service implements SalaryAcctExcelService { + + private SalaryAcctRecordService getSalaryAcctRecordService(User user) { + return (SalaryAcctRecordService) ServiceUtil.getService(SalaryAcctRecordServiceImpl.class, user); + } + + private SalarySobService getSalarySobService(User user) { + return ServiceUtil.getService(SalarySobServiceImpl.class, user); + } + + private SalaryAcctEmployeeService getSalaryAcctEmployeeService(User user) { + return (SalaryAcctEmployeeService) ServiceUtil.getService(SalaryAcctEmployeeServiceImpl.class, user); + } + + private SalaryAcctResultService getSalaryAcctResultService(User user) { + return (SalaryAcctResultService) ServiceUtil.getService(SalaryAcctResultServiceImpl.class, user); + } + + private SalarySobEmpFieldService getSalarySobEmpFieldService(User user) { + return (SalarySobEmpFieldService) ServiceUtil.getService(SalarySobEmpFieldServiceImpl.class, user); + } + + private SalarySobItemService getSalarySobItemService(User user) { + return (SalarySobItemService) ServiceUtil.getService(SalarySobItemServiceImpl.class, user); + } + + private SalaryItemService getSalaryItemService(User user) { + return (SalaryItemService) ServiceUtil.getService(SalaryItemServiceImpl.class, user); + } + + private SalaryComparisonResultService getSalaryComparisonResultService(User user) { + return (SalaryComparisonResultService) ServiceUtil.getService(SalaryComparisonResultServiceImpl.class, user); + } + + private TaxAgentService getTaxAgentService(User user) { + return ServiceUtil.getService(TaxAgentServiceImpl.class, user); + } + + + private SalaryEmployeeService getSalaryEmployeeService(User user) { + return (SalaryEmployeeService) ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user); + } + + private SalarySobItemGroupService getSalarySobItemGroupService(User user) { + return ServiceUtil.getService(SalarySobItemGroupServiceImpl.class, user); + } + + private SalaryAcctReportService getSalaryAcctReportService(User user) { + return ServiceUtil.getService(SalaryAcctReportServiceImpl.class, user); + } + + private SalarySysConfMapper getSalarySysConfMapper() { + return SqlProxyHandle.getProxy(SalarySysConfMapper.class); + } + + private SalarySysConfService getSalarySysConfService(User user) { + return ServiceUtil.getService(SalarySysConfServiceImpl.class, user); + } + + private SalaryAcctResultLogService getSalaryAcctResultLogService(User user) { + return ServiceUtil.getService(SalaryAcctResultLogServiceImpl.class, user); + } + + private SalarySobItemWrapper getSalarySobItemWrapper(User user) { + return ServiceUtil.getService(SalarySobItemWrapper.class, user); + } + + private SalaryAcctResultTemplateService getSalaryAcctResultTemplateService(User user) { + return ServiceUtil.getService(SalaryAcctResultTemplateServiceImpl.class, user); + } + + private SalaryAcctSobConfigService getSalaryAcctSobConfigService(User user) { + return ServiceUtil.getService(SalaryAcctSobConfigServiceImpl.class, user); + } + + private SalaryApprovalRuleService getSalaryApprovalRuleService(User user) { + return ServiceUtil.getService(SalaryApprovalRuleServiceImpl.class, user); + } + + @Override + public XSSFWorkbook exportSalaryAcctEmployee(SalaryAcctEmployeeQueryParam queryParam) { + ValidUtil.doValidator(queryParam); + + SalaryAcctRecordPO salaryAcctRecordPO = getSalaryAcctRecordService(user).getById(queryParam.getSalaryAcctRecordId()); + if (salaryAcctRecordPO == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "薪资核算记录不存在或已被删除")); + } + // 1.工作簿名称 + String sheetName = SalaryI18nUtil.getI18nLabel(85368, "核算人员范围"); + // 2.表头 + String[] header = { + SalaryI18nUtil.getI18nLabel(85429, "姓名"), + SalaryI18nUtil.getI18nLabel(86184, "个税扣缴义务人"), + SalaryI18nUtil.getI18nLabel(86185, "部门"), + SalaryI18nUtil.getI18nLabel(86186, "手机号"), + SalaryI18nUtil.getI18nLabel(86186, "工号"), + SalaryI18nUtil.getI18nLabel(91075, "员工状态"), + SalaryI18nUtil.getI18nLabel(91075, "入职日期") +// SalaryI18nUtil.getI18nLabel(91075, "离职日期") + }; + List headerList = new ArrayList<>(Arrays.asList(header)); + // 查询薪资核算人员 + List salaryAcctEmployees = getSalaryAcctEmployeeService(user).listByParam(queryParam); + + // 组装数据 + List> rows = new ArrayList<>(); + rows.add(headerList); + + // 3.表数据 + List> lists = convert2ExcelRow(salaryAcctEmployees); + rows.addAll(lists); + + // 记录日志 + SalarySobPO salarySobPO = getSalarySobService(user).getById(salaryAcctRecordPO.getSalarySobId()); + String targetName = salarySobPO.getName() + ":" + SalaryDateUtil.localDate2YearMonth(salaryAcctRecordPO.getSalaryMonth()); + SalaryLoggerUtil.recordExportSingleLog(SalaryElogConfig.salaryAcctRecordLoggerTemplate, + queryParam.getSalaryAcctRecordId(), + targetName, + SalaryI18nUtil.getI18nLabel(0, "导出薪资核算人员"), + SalaryI18nUtil.getI18nLabel(0, "导出薪资核算人员") + ":" + targetName, + user + ); + +// return ExcelUtil.genWorkbookV2(rows, sheetName); + return ExcelUtilPlus.genWorkbookV2(rows, sheetName); + } + + + @Override + public XSSFWorkbook exportReducedEmployee(SalaryAcctEmployeeQueryParam queryParam) { + ValidUtil.doValidator(queryParam); + SalaryAcctRecordPO salaryAcctRecordPO = getSalaryAcctRecordService(user).getById(queryParam.getSalaryAcctRecordId()); + if (salaryAcctRecordPO == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "薪资核算记录不存在或已被删除")); + } + + // 1.工作簿名称 + String sheetName = SalaryI18nUtil.getI18nLabel(85368, "环比上月减少人员"); + // 2.表头 + String[] header = { + SalaryI18nUtil.getI18nLabel(85429, "姓名"), + SalaryI18nUtil.getI18nLabel(86184, "个税扣缴义务人"), + SalaryI18nUtil.getI18nLabel(86185, "部门"), + SalaryI18nUtil.getI18nLabel(86186, "手机号"), + SalaryI18nUtil.getI18nLabel(86186, "工号"), + SalaryI18nUtil.getI18nLabel(91075, "员工状态"), + SalaryI18nUtil.getI18nLabel(91075, "入职日期") +// SalaryI18nUtil.getI18nLabel(91075, "离职日期") + }; + List headerList = new ArrayList<>(Arrays.asList(header)); + // 查询薪资核算人员(环比上月减少) + List salaryAcctEmployees = getSalaryAcctEmployeeService(user).listByParam4Reduce(queryParam); + + // 组装数据 + List> rows = new ArrayList<>(); + rows.add(headerList); + + // 3.表数据 + List> lists = convert2ExcelRow(salaryAcctEmployees); + rows.addAll(lists); + + // 记录日志 + SalarySobPO salarySobPO = getSalarySobService(user).getById(salaryAcctRecordPO.getSalarySobId()); + String targetName = salarySobPO.getName() + ":" + SalaryDateUtil.localDate2YearMonth(salaryAcctRecordPO.getSalaryMonth()); + SalaryLoggerUtil.recordExportSingleLog(SalaryElogConfig.salaryAcctRecordLoggerTemplate, + queryParam.getSalaryAcctRecordId(), + targetName, + SalaryI18nUtil.getI18nLabel(0, "导出环比上月减少人员"), + SalaryI18nUtil.getI18nLabel(0, "导出环比上月减少人员") + ":" + targetName, + user + ); + +// return ExcelUtil.genWorkbookV2(rows, sheetName); + return ExcelUtilPlus.genWorkbookV2(rows, sheetName); + } + + @Override + public XSSFWorkbook exportAddedEmployee(SalaryAcctEmployeeQueryParam queryParam) { + ValidUtil.doValidator(queryParam); + + // 1.工作簿名称 + String sheetName = SalaryI18nUtil.getI18nLabel(85368, "环比上月增加人员"); + // 2.表头 + String[] header = { + SalaryI18nUtil.getI18nLabel(85429, "姓名"), + SalaryI18nUtil.getI18nLabel(86184, "个税扣缴义务人"), + SalaryI18nUtil.getI18nLabel(86185, "部门"), + SalaryI18nUtil.getI18nLabel(86186, "手机号"), + SalaryI18nUtil.getI18nLabel(86186, "工号"), + SalaryI18nUtil.getI18nLabel(91075, "员工状态"), + SalaryI18nUtil.getI18nLabel(91075, "入职日期") +// SalaryI18nUtil.getI18nLabel(91075, "离职日期") + }; + List headerList = new ArrayList<>(Arrays.asList(header)); + // 查询薪资核算人员(环比上月增加) + List salaryAcctEmployees = getSalaryAcctEmployeeService(user).listByParam4Add(queryParam); + + // 组装数据 + List> rows = new ArrayList<>(); + rows.add(headerList); + + // 3.表数据 + List> lists = convert2ExcelRow(salaryAcctEmployees); + rows.addAll(lists); + + // 记录日志 + SalaryAcctRecordPO salaryAcctRecordPO = getSalaryAcctRecordService(user).getById(queryParam.getSalaryAcctRecordId()); + SalarySobPO salarySobPO = getSalarySobService(user).getById(salaryAcctRecordPO.getSalarySobId()); + String targetName = salarySobPO.getName() + ":" + SalaryDateUtil.localDate2YearMonth(salaryAcctRecordPO.getSalaryMonth()); + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId("" + salaryAcctRecordPO.getId()); + loggerContext.setTargetName(targetName); + loggerContext.setOperateType(OperateTypeEnum.ADD.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "导出环比增加人员")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "导出环比增加人员") + ":" + targetName); + SalaryElogConfig.salaryAcctRecordLoggerTemplate.write(loggerContext); + + return ExcelUtilPlus.genWorkbookV2(rows, sheetName); + } + + private List> convert2ExcelRow(List salaryAcctEmployees) { + if (CollectionUtils.isEmpty(salaryAcctEmployees)) { + return Collections.emptyList(); + } + List salaryAccEmployeeListDTOS = new ArrayList<>(); + List> partition = Lists.partition(salaryAcctEmployees, 1000); + for (List tempList : partition) { + // 人员 + List employeeIds = tempList.stream().map(SalaryAcctEmployeePO::getEmployeeId).collect(Collectors.toList()); + List simpleEmployees = getSalaryEmployeeService(user).getEmployeeByIdsAll(employeeIds); + // 个税扣缴义务人 + List taxAgentIds = tempList.stream().map(SalaryAcctEmployeePO::getTaxAgentId).distinct().collect(Collectors.toList()); + List taxAgents = getTaxAgentService(user).listByIds(taxAgentIds); + // 转换成列表数据 + salaryAccEmployeeListDTOS.addAll(SalaryAcctEmployeeBO.convert2EmployeeListDTO(tempList, taxAgents, simpleEmployees)); + } + List> rows = Lists.newArrayListWithExpectedSize(salaryAccEmployeeListDTOS.size()); + for (SalaryAccEmployeeListDTO dto : salaryAccEmployeeListDTOS) { + List row = Lists.newArrayListWithExpectedSize(8); + row.add(dto.getEmployeeName()); + row.add(dto.getTaxAgentName()); + row.add(dto.getDepartmentName()); + row.add(dto.getMobile()); + row.add(dto.getJobNum()); + row.add(dto.getStatus()); + row.add(dto.getHireDate()); +// row.add(dto.getDismissDate()); + rows.add(row); + } + return rows; + } + + @Override + public XSSFWorkbook exportSalaryAcctResult(SalaryAcctResultQueryParam queryParam) { + ValidUtil.doValidator(queryParam); + + // 查询薪资核算记录 + SalaryAcctRecordPO salaryAcctRecordPO = getSalaryAcctRecordService(user).getById(queryParam.getSalaryAcctRecordId()); + if (Objects.isNull(salaryAcctRecordPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98747, "薪资核算记录不存在或已被删除")); + } + // excel导出的表头 + List headerColumnGroup = Lists.newArrayList(); + // 查询列表的表头 + List weaTableColumns = listWeaTableColumn(salaryAcctRecordPO); + + //判断是否按照自定义字段导出表头 + List finalWeaTableColumns = new ArrayList<>(); + if (queryParam.getSalaryItemIds() != null) { + //获取人员基本信息字段(汇总) + Collection> empFieldList = getSalarySobItemWrapper(user).empFieldList(); + List empFieldIdList = new ArrayList<>(); + empFieldList.forEach(f -> empFieldIdList.add(f.get("id"))); + // 必须选择导出所需的薪资项目 + if (CollectionUtils.isEmpty(queryParam.getSalaryItemIds())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(99019, "参数错误,请选择导入模板所需的薪资项目")); + } + List headerRangeList = new ArrayList<>(); + List salaryItemPOS = getSalaryItemService(user).listByIds(queryParam.getSalaryItemIds()); + for (SalaryItemPO salaryItemPO : salaryItemPOS) { + headerRangeList.add(salaryItemPO.getId().toString()); + } + for (WeaTableColumnGroup tableColumn : weaTableColumns) { + WeaTableColumnGroup columnGroupItem = (WeaTableColumnGroup) tableColumn; + if (columnGroupItem.getChildren() != null) { + List childrenColumns = columnGroupItem.getChildren().stream().filter(f -> headerRangeList.contains(f.getColumn())).collect(Collectors.toList()); + if (childrenColumns.size() > 0) { + columnGroupItem.setChildren(childrenColumns); + finalWeaTableColumns.add(columnGroupItem); + } + } else if (empFieldIdList.contains(tableColumn.getColumn()) || headerRangeList.contains(tableColumn.getColumn())) { + finalWeaTableColumns.add(columnGroupItem); + } + + } + } else { + finalWeaTableColumns = weaTableColumns; + } +// parseHeader(headerColumnGroup, weaTableColumns); + parseHeader(headerColumnGroup, finalWeaTableColumns); +// // excel导出的表头 +// List headerList = new ArrayList<>(weaTableColumns); + List headerList = new ArrayList<>(finalWeaTableColumns); + // 查询薪资核算结果 + List> resultMapList = getSalaryAcctResultService(user).listByParam(queryParam); + + + //合计 + boolean total = false; + SalarySysConfPO openSum = getSalarySysConfService(user).getOneByCode(OPEN_ACCT_RESULT_SUM); + if (openSum != null && StringUtils.isNotBlank(openSum.getConfValue()) && OpenEnum.parseByValue(openSum.getConfValue()) == OpenEnum.OPEN) { + total = true; + Map sumRow = getSalaryAcctResultService(user).sumRow(queryParam); + sumRow.forEach((k, v) -> { + if (NumberUtils.isCreatable(v.toString())) { + sumRow.put(k, new BigDecimal(v.toString())); + } + }); + if (sumRow != null) { + sumRow.put("taxAgentName", "总计"); + resultMapList.add(sumRow); + } + } + + // excel导出的数据 + String DATA_TYPE_SUFFIX = "_type"; + List> rows = new ArrayList<>(); + rows.add(headerList); + for (Map map : resultMapList) { + List row = Lists.newArrayListWithExpectedSize(headerColumnGroup.size()); + for (WeaTableColumnGroup weaTableColumn : headerColumnGroup) { + String fieldType = (String) map.getOrDefault(weaTableColumn.getColumn().toString() + DATA_TYPE_SUFFIX, StringUtils.EMPTY); + if (StringUtils.equals("number", fieldType) && map.get(weaTableColumn.getColumn()) != null && NumberUtil.isNumber(map.get(weaTableColumn.getColumn()).toString())) { + row.add(new BigDecimal(StringUtils.isBlank(map.get(weaTableColumn.getColumn()).toString()) ? "0" : map.get(weaTableColumn.getColumn()).toString())); + } else { + row.add(map.getOrDefault(weaTableColumn.getColumn(), StringUtils.EMPTY)); + } + + } + rows.add(row); + } + + // 记录日志 + SalarySobPO salarySobPO = getSalarySobService(user).getById(salaryAcctRecordPO.getSalarySobId()); + String targetName = salarySobPO.getName() + ":" + SalaryDateUtil.localDate2YearMonth(salaryAcctRecordPO.getSalaryMonth()); + SalaryLoggerUtil.recordExportSingleLog(SalaryElogConfig.salaryAcctRecordLoggerTemplate, + queryParam.getSalaryAcctRecordId(), + targetName, + SalaryI18nUtil.getI18nLabel(0, "导出薪资核算结果"), + SalaryI18nUtil.getI18nLabel(0, "导出薪资核算结果") + ":" + targetName, + user + ); + + + String sheetName = "薪资核算结果"; +// return ExcelUtil.genWorkbookV2(rows, sheetName, total); + return ExcelUtilPlus.genWorkbookWithChildTitleColumnWithExcelFormat(rows, sheetName, total); + } + + + /** + * 构建薪资核算结果列表的表头 + * + * @param salaryAcctRecordPO 薪资核算记录 + * @return + */ + public List listWeaTableColumn(SalaryAcctRecordPO salaryAcctRecordPO) { + // 是否是回算 + SalaryAcctRecordPO byId = getSalaryAcctRecordService(user).getById(salaryAcctRecordPO.getId()); + boolean isBackCalc = Objects.equals(byId.getBackCalcStatus(), 1); + // 查询薪资账套下的薪资项目+员工信息字段 + SalarySobItemAggregateDTO salarySobItemAggregateDTO = getSalarySobItemService(user).getAggregateWithItemHideBySalarySobId(salaryAcctRecordPO.getId(), salaryAcctRecordPO.getSalarySobId(), isBackCalc); + // 构建薪资核算结果列表表头 + List columnList = SalaryAcctResultBO.buildTableColumns(salarySobItemAggregateDTO, ListUtils.emptyIfNull(salaryAcctRecordPO.getLockSalaryItemIds())); + // 获取固定列头数 + SalarySysConfPO salaryAcctFixedColumns = getSalarySysConfMapper().getOneByCode(SALARY_ACCT_FIXED_COLUMNS); + if (salaryAcctFixedColumns != null) { + int fixedNum = NumberUtils.isCreatable(salaryAcctFixedColumns.getConfValue()) ? Integer.valueOf(salaryAcctFixedColumns.getConfValue()) : 3; + if (fixedNum == 0) { + fixedNum = 3; + } + for (int i = 0; i < fixedNum && i < columnList.size(); i++) { + columnList.get(i).setFixed("left"); + } + } + return columnList; + } + + /** + * 报表表头 + * + * @param salaryAcctRecordPO + * @return + */ + public Map listColumn(SalaryAcctRecordPO salaryAcctRecordPO) { + // 查询薪资账套下的薪资项目+员工信息字段 + SalarySobItemAggregateDTO salarySobItemAggregateDTO = getSalarySobItemService(user).getAggregateBySalarySobId(salaryAcctRecordPO.getSalarySobId()); + // 构建薪资核算结果列表表头 + return SalaryAcctResultBO.buildColumns(salarySobItemAggregateDTO); + } + + /** + * 解析表头 + * + * @param headerList + * @param weaTableColumns + */ + private void parseHeader(List headerList, List weaTableColumns) { + for (WeaTableColumnGroup weaTableColumnGroup : weaTableColumns) { + if (CollectionUtils.isEmpty(weaTableColumnGroup.getChildren())) { + headerList.add(weaTableColumnGroup); + continue; + } + parseHeader(headerList, weaTableColumnGroup.getChildren()); + } + } + + @Override + public SalaryAcctImportFieldDTO getImportField(Long salaryAcctRecordId) { + // 查询薪资核算记录 + SalaryAcctRecordPO salaryAcctRecordPO = getSalaryAcctRecordService(user).getById(salaryAcctRecordId); + if (Objects.isNull(salaryAcctRecordPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98747, "薪资核算记录不存在或已被删除")); + } + + SalaryAcctConfig config = getSalaryAcctSobConfigService(user).getSalaryAcctConfig(salaryAcctRecordId); + + // 查询薪资核算记录所用的薪资账套的薪资项目副本 + List salarySobItems = config.getSalarySobItems(); + salarySobItems = salarySobItems.stream().filter(salarySobItemPO -> salarySobItemPO.getItemHide() == null || salarySobItemPO.getItemHide() == 0).collect(Collectors.toList()); + Set salaryItemIds = SalaryEntityUtil.properties(salarySobItems, SalarySobItemPO::getSalaryItemId); + // 查询薪资项目 + List salaryItems = getSalaryItemService(user).listByIds(salaryItemIds); + Map salaryItemMap = SalaryEntityUtil.convert2Map(salaryItems, SalaryItemPO::getId); + + Map> salarySobItemPOMap = SalaryEntityUtil.group2Map(salarySobItems, SalarySobItemPO::getSalarySobItemGroupId); + + // 查询薪资账套的薪资项目分类 + List salarySobItemGroupPOS = config.getSalarySobItemGroups(); + // 对分组进行排序 + salarySobItemGroupPOS = SalaryAcctResultBO.sortGroup(salarySobItemGroupPOS); + // 对分组内薪资项目排序 + SalaryAcctResultBO.sortItem(salarySobItemPOMap); + // 根据账套分组封装薪资项目的值 + List itemsByGroup = new ArrayList<>(); + for (SalarySobItemGroupPO groupPO : salarySobItemGroupPOS) { + List groupItems = salarySobItemPOMap.getOrDefault(groupPO.getId(), Collections.emptyList()); + List items = groupItems.stream() + .map(salarySobItemPO -> SalaryAcctImportFieldDTO.ImportFieldDTO.builder() + .salaryItemId(salarySobItemPO.getSalaryItemId()) + .salaryItemName(Optional.ofNullable(salaryItemMap.get(salarySobItemPO.getSalaryItemId())).map(SalaryItemPO::getName).orElse(StringUtils.EMPTY)) + .dataType(Optional.ofNullable(salaryItemMap.get(salarySobItemPO.getSalaryItemId())).map(SalaryItemPO::getDataType).orElse(SalaryDataTypeEnum.NUMBER.getValue())) + .build()) + .collect(Collectors.toList()); + + itemsByGroup.add(SalaryAcctImportFieldDTO.ImportFieldByGroupDTO.builder() + .salarySobItemGroupId(groupPO.getId()) + .salarySobItemGroupName(groupPO.getName()) + .salaryItems(items) + .sortedIndex(groupPO.getSortedIndex()).build()); + } + // 未分类 + List noGroupItems = salarySobItemPOMap.getOrDefault(0L, Collections.emptyList()); + if (CollectionUtils.isNotEmpty(noGroupItems)) { + List items = noGroupItems.stream() + .map(salarySobItemPO -> SalaryAcctImportFieldDTO.ImportFieldDTO.builder() + .salaryItemId(salarySobItemPO.getSalaryItemId()) + .salaryItemName(Optional.ofNullable(salaryItemMap.get(salarySobItemPO.getSalaryItemId())).map(SalaryItemPO::getName).orElse(StringUtils.EMPTY)) + .dataType(Optional.ofNullable(salaryItemMap.get(salarySobItemPO.getSalaryItemId())).map(SalaryItemPO::getDataType).orElse(SalaryDataTypeEnum.NUMBER.getValue())) + .build()) + .collect(Collectors.toList()); + + itemsByGroup.add(SalaryAcctImportFieldDTO.ImportFieldByGroupDTO.builder() + .salarySobItemGroupId(0L) + .salarySobItemGroupName("未分类") + .salaryItems(items) + .sortedIndex(itemsByGroup.size()).build()); + } + +// // 薪资项目中的公式项 +// List formulaItems = salaryItems.stream() +// .filter(salaryItemPO -> Objects.equals(salaryItemPO.getValueType(), SalaryValueTypeEnum.FORMULA.getValue())) +// .map(salaryItemPO -> SalaryAcctImportFieldDTO.ImportFieldDTO.builder() +// .salaryItemId(salaryItemPO.getId()) +// .salaryItemName(salaryItemPO.getName()) +// .build()) +// .collect(Collectors.toList()); +// // 薪资项目中的SQl项 +// List sqlItems = salaryItems.stream() +// .filter(salaryItemPO -> Objects.equals(salaryItemPO.getValueType(), SalaryValueTypeEnum.SQL.getValue())) +// .map(salaryItemPO -> SalaryAcctImportFieldDTO.ImportFieldDTO.builder() +// .salaryItemId(salaryItemPO.getId()) +// .salaryItemName(salaryItemPO.getName()) +// .build()) +// .collect(Collectors.toList()); +// // 薪资项目中的输入项 +// List inputItems = salaryItems.stream() +// .filter(salaryItemPO -> Objects.equals(salaryItemPO.getValueType(), SalaryValueTypeEnum.INPUT.getValue())) +// .map(salaryItemPO -> SalaryAcctImportFieldDTO.ImportFieldDTO.builder() +// .salaryItemId(salaryItemPO.getId()) +// .salaryItemName(salaryItemPO.getName()) +// .build()) +// .collect(Collectors.toList()); + // 缓存勾选 + List checkItems = new ArrayList<>(); + List salaryAcctResultTemplatePOS = getSalaryAcctResultTemplateService(user).listBySalarySobId(salaryAcctRecordPO.getSalarySobId(), Arrays.asList(2)); + if (CollectionUtils.isNotEmpty(salaryAcctResultTemplatePOS)) { + String items = salaryAcctResultTemplatePOS.get(0).getSalaryItemIds(); + checkItems = StrUtil.isNotEmpty(items) ? Arrays.stream(items.split(",")).map(Long::valueOf).collect(Collectors.toList()) : new ArrayList<>(); + } + return SalaryAcctImportFieldDTO.builder().itemsByGroup(itemsByGroup).checkItems(checkItems).build(); + } + + @Override + public SalaryAcctImportFieldDTO getExportField(Long salaryAcctRecordId) { + // 查询薪资核算记录 + SalaryAcctRecordPO salaryAcctRecordPO = getSalaryAcctRecordService(user).getById(salaryAcctRecordId); + if (Objects.isNull(salaryAcctRecordPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98747, "薪资核算记录不存在或已被删除")); + } + SalaryAcctConfig salaryAcctConfig = getSalaryAcctSobConfigService(user).getSalaryAcctConfig(salaryAcctRecordId); + + // 查询薪资核算记录所用的薪资账套的薪资项目副本 + List salarySobItems = salaryAcctConfig.getSalarySobItems(); + salarySobItems = salarySobItems.stream().filter(salarySobItemPO -> salarySobItemPO.getItemHide() == null || salarySobItemPO.getItemHide() == 0).collect(Collectors.toList()); + Set salaryItemIds = SalaryEntityUtil.properties(salarySobItems, SalarySobItemPO::getSalaryItemId); + // 查询薪资项目 + List salaryItems = getSalaryItemService(user).listByIds(salaryItemIds); + Map salaryItemMap = SalaryEntityUtil.convert2Map(salaryItems, SalaryItemPO::getId); + + Map> salarySobItemPOMap = SalaryEntityUtil.group2Map(salarySobItems, SalarySobItemPO::getSalarySobItemGroupId); + + // 查询薪资账套的薪资项目分类 + List salarySobItemGroupPOS = salaryAcctConfig.getSalarySobItemGroups(); + // 对分组进行排序 + salarySobItemGroupPOS = SalaryAcctResultBO.sortGroup(salarySobItemGroupPOS); + // 对分组内薪资项目排序 + SalaryAcctResultBO.sortItem(salarySobItemPOMap); + // 根据账套分组封装薪资项目的值 + List itemsByGroup = new ArrayList<>(); + for (SalarySobItemGroupPO groupPO : salarySobItemGroupPOS) { + List groupItems = salarySobItemPOMap.getOrDefault(groupPO.getId(), Collections.emptyList()); + List items = groupItems.stream() + .map(salarySobItemPO -> SalaryAcctImportFieldDTO.ImportFieldDTO.builder() + .salaryItemId(salarySobItemPO.getSalaryItemId()) + .salaryItemName(Optional.ofNullable(salaryItemMap.get(salarySobItemPO.getSalaryItemId())).map(SalaryItemPO::getName).orElse(StringUtils.EMPTY)) + .build()) + .collect(Collectors.toList()); + + itemsByGroup.add(SalaryAcctImportFieldDTO.ImportFieldByGroupDTO.builder() + .salarySobItemGroupId(groupPO.getId()) + .salarySobItemGroupName(groupPO.getName()) + .salaryItems(items) + .sortedIndex(groupPO.getSortedIndex()).build()); + } + // 未分类 + List noGroupItems = salarySobItemPOMap.getOrDefault(0L, Collections.emptyList()); + if (CollectionUtils.isNotEmpty(noGroupItems)) { + List items = noGroupItems.stream() + .map(salarySobItemPO -> SalaryAcctImportFieldDTO.ImportFieldDTO.builder() + .salaryItemId(salarySobItemPO.getSalaryItemId()) + .salaryItemName(Optional.ofNullable(salaryItemMap.get(salarySobItemPO.getSalaryItemId())).map(SalaryItemPO::getName).orElse(StringUtils.EMPTY)) + .build()) + .collect(Collectors.toList()); + + itemsByGroup.add(SalaryAcctImportFieldDTO.ImportFieldByGroupDTO.builder() + .salarySobItemGroupId(0L) + .salarySobItemGroupName("未分类") + .salaryItems(items) + .sortedIndex(itemsByGroup.size()).build()); + } + // 缓存勾选 + String cacheKey = user.getUID() + SalaryItemConstant.RESULT_EXPORT_FIELD_SIGN; + String cacheValue = (String) Util_DataCache.getObjVal(cacheKey); + List checkItems = JsonUtil.parseList(cacheValue, Long.class) == null ? new ArrayList<>() : JsonUtil.parseList(cacheValue, Long.class); + // 转换成dto +// return SalaryAcctImportFieldDTO.builder().formulaItems(formulaItems).sqlItems(sqlItems).inputItems(inputItems).checkItems(checkItems).build(); + return SalaryAcctImportFieldDTO.builder().itemsByGroup(itemsByGroup).checkItems(checkItems).build(); + } + + @Override + public XSSFWorkbook exportImportTemplate(SalaryAcctImportTemplateParam param) { + + // 查询薪资核算记录 + SalaryAcctRecordPO salaryAcctRecordPO = getSalaryAcctRecordService(user).getById(param.getSalaryAcctRecordId()); + if (Objects.isNull(salaryAcctRecordPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98747, "薪资核算记录不存在或已被删除")); + } + + List checkItems = new ArrayList<>(); + List salaryAcctResultTemplatePOS = getSalaryAcctResultTemplateService(user).listBySalarySobId(salaryAcctRecordPO.getSalarySobId(), Arrays.asList(2)); + if (CollectionUtils.isNotEmpty(salaryAcctResultTemplatePOS)) { + String items = salaryAcctResultTemplatePOS.get(0).getSalaryItemIds(); + checkItems = StrUtil.isNotEmpty(items) ? Arrays.stream(items.split(",")).map(Long::valueOf).collect(Collectors.toList()) : new ArrayList<>(); + } + + // 必须选择导入模板所需的薪资项目 + if (CollectionUtils.isEmpty(checkItems)) { + // 查询薪资核算记录所用的薪资账套的薪资项目副本 + List salarySobItems = getSalarySobItemService(user).listBySalarySobId(salaryAcctRecordPO.getSalarySobId()); + List salaryItemIds = SalaryEntityUtil.properties(salarySobItems, SalarySobItemPO::getSalaryItemId, Collectors.toList()); + if (CollectionUtils.isEmpty(salaryItemIds)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "该核算记录不存在薪资项目")); + } + checkItems = salaryItemIds; + } + param.setSalaryItemIds(checkItems); + +// // 模板表头(默认必带"个税扣缴义务人"、"姓名") +// List headerList = Lists.newArrayList(SalaryI18nUtil.getI18nLabel(85429, "姓名"), +// "部门", +// SalaryI18nUtil.getI18nLabel(86186, "手机号"), +// SalaryI18nUtil.getI18nLabel(86317, "工号"), +// SalaryI18nUtil.getI18nLabel(86184, "个税扣缴义务人")); +// List dataIndexList = Lists.newArrayList("username", "departmentName", "mobile", "workcode", "taxAgentName"); +// // 查询薪资项目 +// List salaryItemPOS = getSalaryItemService(user).listByIds(param.getSalaryItemIds()); +// for (SalaryItemPO salaryItemPO : salaryItemPOS) { +// headerList.add(salaryItemPO.getName()); +// dataIndexList.add("" + salaryItemPO.getId()); +// } +// +// // 查询薪资核算结果 +// List> resultMapList = getSalaryAcctResultService(user).listByParam(param); +// // excel导出的数据 +// List> rows = Lists.newArrayListWithExpectedSize(resultMapList.size()); +// rows.add(headerList); +// for (Map map : resultMapList) { +// List row = Lists.newArrayListWithExpectedSize(headerList.size()); +// for (String dataIndex : dataIndexList) { +// row.add(map.getOrDefault(dataIndex, StringUtils.EMPTY)); +// } +// rows.add(row); +// } +// return ExcelUtil.genWorkbookV2(rows, sheetName); + + // 查询薪资项目 + List headerRangeList = new ArrayList<>(); + List salaryItemPOS = getSalaryItemService(user).listByIds(param.getSalaryItemIds()); + for (SalaryItemPO salaryItemPO : salaryItemPOS) { + headerRangeList.add(salaryItemPO.getId().toString()); + } + headerRangeList.add("username"); + headerRangeList.add("mobile"); + headerRangeList.add("workcode"); + headerRangeList.add("idNo"); + headerRangeList.add("taxAgentName"); + headerRangeList.add("departmentName"); + // 查询列表的表头 + List weaTableColumns = listWeaTableColumn(salaryAcctRecordPO); + List finalWeaTableColumns = new ArrayList<>(); + for (WeaTableColumnGroup tableColumn : weaTableColumns) { + WeaTableColumnGroup columnGroupItem = (WeaTableColumnGroup) tableColumn; + if (columnGroupItem.getChildren() != null) { + List childrenColumns = columnGroupItem.getChildren().stream().filter(f -> headerRangeList.contains(f.getColumn())).collect(Collectors.toList()); + if (childrenColumns.size() > 0) { + columnGroupItem.setChildren(childrenColumns); + finalWeaTableColumns.add(columnGroupItem); + } + } else if (headerRangeList.contains(columnGroupItem.getColumn())) { + finalWeaTableColumns.add(columnGroupItem); + } + + } + // excel导出的表头 + List headerColumnGroup = Lists.newArrayList(); + // 查询列表的表头 + parseHeader(headerColumnGroup, finalWeaTableColumns); + + List headerList = new ArrayList<>(finalWeaTableColumns); + // excel导出的数据 + List> rows = new ArrayList<>(); + rows.add(headerList); + if (param.getImportType() != null && param.getImportType().equals("true")) { + // 需要导出现有数据,查询薪资核算结果 + param.setDynamicEmpInfo(true); + List> resultMapList = getSalaryAcctResultService(user).listByParam(param); + for (Map map : resultMapList) { + List row = Lists.newArrayListWithExpectedSize(headerColumnGroup.size()); + for (WeaTableColumnGroup weaTableColumn : headerColumnGroup) { + row.add(map.getOrDefault(weaTableColumn.getColumn(), StringUtils.EMPTY)); + } + rows.add(row); + } + } + + + String sheetName = "薪资核算导入模板"; + return ExcelUtilPlus.genWorkbookWithChildTitleColumn(rows, sheetName, false); + } + + + @Override + public XSSFWorkbook exportComparisonResult(SalaryComparisonResultQueryParam queryParam) { + ValidUtil.doValidator(queryParam); + + // 查询薪资核算记录 + SalaryAcctRecordPO salaryAcctRecordPO = getSalaryAcctRecordService(user).getById(queryParam.getSalaryAcctRecordId()); + if (Objects.isNull(salaryAcctRecordPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98747, "薪资核算记录不存在或已被删除")); + } + // 查询线下对比结果 + SalaryComparisonResultListDTO salaryComparisonResultListDTO = getSalaryComparisonResultService(user).listByParam(queryParam); + // 薪资核算线下对比结果列表表头 + List headerList = Lists.newArrayList(); + // 查询薪资核算所用的薪资账套的员工信息字段 + List salarySobEmpFieldPOS = getSalarySobEmpFieldService(user).listBySalarySobId(salaryAcctRecordPO.getSalarySobId()); + Set employeeFieldCodeSet = SalaryEntityUtil.properties(salarySobEmpFieldPOS, SalarySobEmpFieldPO::getFieldCode); + // 查询薪资项目 + List salaryItemPOS = getSalarySobItemService(user).listBySalarySobId4SalaryItem(salaryAcctRecordPO.getSalarySobId()); + Set salaryItemIds = SalaryEntityUtil.properties(salaryItemPOS, salaryItemPO -> "" + salaryItemPO.getId()); + for (WeaTableColumnGroup weaTableColumnGroup : salaryComparisonResultListDTO.getWeaTableColumns()) { + // 员工信息字段 + if (employeeFieldCodeSet.contains(weaTableColumnGroup.getColumn())) { + headerList.add(weaTableColumnGroup.getText()); + } else { + // 薪资项目的表头 + List childrenList = weaTableColumnGroup.getChildren(); + if (CollectionUtils.isEmpty(childrenList)) { + // 是否是无分类 + if (salaryItemIds.contains(weaTableColumnGroup.getColumn())) { + headerList.add(weaTableColumnGroup.getText() + " (线上值)"); + headerList.add(weaTableColumnGroup.getText() + " (线下值)"); + } + } else { + for (WeaTableColumnGroup children : childrenList) { + if (salaryItemIds.contains(children.getColumn())) { + headerList.add(children.getText() + " (线上值)"); + headerList.add(children.getText() + " (线下值)"); + } + } + } + } + + + } + + List> resultMapList = salaryComparisonResultListDTO.getData().getList(); + // excel导出的数据 + List> rows = new ArrayList<>(); + rows.add(headerList); + for (Map map : resultMapList) { + List row = Lists.newArrayList(); + for (WeaTableColumnGroup weaTableColumnGroup : salaryComparisonResultListDTO.getWeaTableColumns()) { + // 员工信息字段的值 + if (employeeFieldCodeSet.contains(weaTableColumnGroup.getColumn())) { + row.add(map.get(weaTableColumnGroup.getColumn())); + } + // 薪资项目的值 + List childrenList = weaTableColumnGroup.getChildren(); + if (CollectionUtils.isEmpty(childrenList)) { + // 是否是无分类 + if (salaryItemIds.contains(weaTableColumnGroup.getColumn())) { + Map tempMap = (Map) map.getOrDefault(weaTableColumnGroup.getColumn(), Collections.emptyMap()); + row.add(tempMap.get("acctResultValue")); + row.add(tempMap.get("excelResultValue")); + } + } else { + for (WeaTableColumnGroup children : childrenList) { + if (salaryItemIds.contains(children.getColumn())) { + Map tempMap = (Map) map.getOrDefault(children.getColumn(), Collections.emptyMap()); + row.add(tempMap.get("acctResultValue")); + row.add(tempMap.get("excelResultValue")); + } + } + } + } + rows.add(row); + } + + // 记录日志 + SalarySobPO salarySobPO = getSalarySobService(user).getById(salaryAcctRecordPO.getSalarySobId()); + String targetName = salarySobPO.getName() + ":" + SalaryDateUtil.localDate2YearMonth(salaryAcctRecordPO.getSalaryMonth()); + SalaryLoggerUtil.recordExportSingleLog(SalaryElogConfig.salaryAcctRecordLoggerTemplate, + queryParam.getSalaryAcctRecordId(), + targetName, + SalaryI18nUtil.getI18nLabel(0, "导出线下对比结果"), + SalaryI18nUtil.getI18nLabel(0, "导出线下对比结果") + ":" + targetName, + user + ); + + String sheetName = "线下对比结果"; + +// return ExcelUtil.genWorkbookV2(rows, sheetName); + return ExcelUtilPlus.genWorkbookV2(rows, sheetName); + } + + + @Override + public XSSFWorkbook exportComparisonResultTemplate(SalaryComparisonResultExportParam exportParam) { + + ValidUtil.doValidator(exportParam); + + // 查询薪资核算记录 + SalaryAcctRecordPO salaryAcctRecordPO = getSalaryAcctRecordService(user).getById(exportParam.getSalaryAcctRecordId()); + if (Objects.isNull(salaryAcctRecordPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98747, "薪资核算记录不存在或已被删除")); + } + // // 模板表头(默认必带"个税扣缴义务人"、"姓名") + // List headerList = Lists.newArrayList(SalaryI18nUtil.getI18nLabel(85429, "姓名"), SalaryI18nUtil.getI18nLabel(86184, "个税扣缴义务人")); + // //定位人员带“部门”,“手机号”,“工号” + // headerList.add("部门"); + // headerList.add("手机号"); + // headerList.add("工号"); + // 查询薪资账套下的薪资项目 + SalarySobItemAggregateDTO salarySobItemAggregateDTO = getSalarySobItemService(user).getAggregateByRecordId(exportParam.getSalaryAcctRecordId(), true); + +// // 员工信息 +// for (SalarySobEmpFieldDTO item : salarySobItemAggregateDTO.getEmpFields()) { +// if (!"姓名".equals(item.getFieldName()) && !"个税扣缴义务人".equals(item.getFieldName())) { +// if ("手机".equals(item.getFieldName())) { +// headerList.add("手机号"); +// } else { +// headerList.add(item.getFieldName()); +// } +// } +// +// } +// // 薪资项目分类下的新资项目 +// for (SalarySobItemGroupDTO itemGroup : salarySobItemAggregateDTO.getItemGroups()) { +// for (SalarySobItemDTO item : itemGroup.getItems()) { +// headerList.add(item.getName()); +// } +// } +// // 没有分类的薪资项目 +// for (SalarySobItemDTO item : salarySobItemAggregateDTO.getItems()) { +// headerList.add(item.getName()); +// } + + + // 无分类薪资项目id + List noGroupItemIds = salarySobItemAggregateDTO.getItems().stream().map(dto -> String.valueOf(dto.getSalaryItemId())).collect(Collectors.toList()); + // 查询列表的表头 + List weaTableColumns = listWeaTableColumn(salaryAcctRecordPO); + List finalWeaTableColumns = new ArrayList<>(); + // 查询薪资核算所用的薪资账套的员工信息字段 + List salarySobEmpFieldPOS = getSalarySobEmpFieldService(user).listBySalarySobId(salaryAcctRecordPO.getSalarySobId()); + List salarySobEmpFieldDTOS = new SalarySobItemAggregateBO().buildEmpField(salarySobEmpFieldPOS); + salarySobEmpFieldDTOS.stream().forEach(empField -> finalWeaTableColumns.add(new WeaTableColumnGroup("150", SalaryI18nUtil.getI18nLabel(0, empField.getFieldName()), SalaryI18nUtil.getI18nLabel(0, empField.getFieldName())))); + for (WeaTableColumnGroup tableColumn : weaTableColumns) { + WeaTableColumnGroup columnGroupItem = (WeaTableColumnGroup) tableColumn; + if (columnGroupItem.getChildren() != null) { + columnGroupItem.setChildren(columnGroupItem.getChildren()); + finalWeaTableColumns.add(columnGroupItem); + } else if (noGroupItemIds.contains(columnGroupItem.getColumn())) { + // 无分类 + finalWeaTableColumns.add(columnGroupItem); + } + } + + + List> rows = new ArrayList<>(); + rows.add(finalWeaTableColumns); + String sheetName = "线下对比结果导入模板"; + +// return ExcelUtil.genWorkbookV2(rows, sheetName); +// return ExcelUtilPlus.genWorkbookV2(rows, sheetName); + return ExcelUtilPlus.genWorkbookWithChildTitleColumn(rows, sheetName, false); + } + + public Map importSalaryAcctResult(SalaryAcctImportParam param) { + return batchImport(param, "importSalaryAcctResult"); + } + + + public Map importExcelAcctResult(SalaryAcctImportParam param) { + return batchImport(param, "importExcelAcctResult"); + } + + @Override + public Map preview(SalaryAcctImportParam param) { + + //1、参数校验 + ValidUtil.doValidator(param); + + Map map = new HashMap<>(); + + InputStream fileInputStream = null; + try { + fileInputStream = ImageFileManager.getInputStreamById(Integer.parseInt(param.getImageId())); + Sheet sheet = ExcelSupport.parseFile(fileInputStream, 0, EXCEL_TYPE_XLSX); + map.put("headers", ExcelSupport.getSheetHeader(sheet, 1)); + map.put("list", ExcelParseHelper.parse2List(sheet, 2, 1)); + return map; + + } finally { + IOUtils.closeQuietly(fileInputStream); + } + } + + @Override + public void cacheImportField(SalaryAcctResultTemplateSaveParam saveParam) { + Long salaryAcctRecordId = saveParam.getSalaryAcctRecordId(); + SalaryAcctRecordPO salaryAcctRecordPO = getSalaryAcctRecordService(user).getById(salaryAcctRecordId); + if (salaryAcctRecordPO == null) { + throw new SalaryRunTimeException("薪资核算记录不存在"); + } + + List salaryAcctResultTemplatePOS = getSalaryAcctResultTemplateService(user).listBySalarySobId(salaryAcctRecordPO.getSalarySobId(), Collections.singletonList(2)); + if (CollectionUtils.isNotEmpty(salaryAcctResultTemplatePOS)) { + salaryAcctResultTemplatePOS.forEach(templatePO -> getSalaryAcctResultTemplateService(user).deleteById(templatePO.getId())); + } + + Date now = new Date(); + SalaryAcctResultTemplatePO templatePO = SalaryAcctResultTemplatePO.builder() + .id(IdGenerator.generate()) + .type(2) + .salarySobId(salaryAcctRecordPO.getSalarySobId()) + .salaryItemIds(StringUtils.join(saveParam.getSalaryItemIds(), ",")) + .templateName("") + .creator((long) user.getUID()) + .createTime(now) + .updateTime(now) + .deleteType(0) + .build(); + getSalaryAcctResultTemplateService(user).insertIgnoreNull(templatePO); + + } + + @Override + public void cacheExportField(List salaryItems) { + String cacheKey = user.getUID() + SalaryItemConstant.RESULT_EXPORT_FIELD_SIGN; + Util_DataCache.setObjVal(cacheKey, JsonUtil.toJsonString(salaryItems)); + } + + @Override + public ExcelPreviewDTO previewImportSalaryAcctResult(SalaryAcctImportParam param) { + + //1、参数校验 + ValidUtil.doValidator(param); + + Map map = new HashMap<>(); + + InputStream fileInputStream = null; + try { + fileInputStream = ImageFileManager.getInputStreamById(Integer.parseInt(param.getImageId())); + Workbook workbook = ExcelSupport.parseFile(fileInputStream, EXCEL_TYPE_XLSX); + // 创建一个公式求值器对象 + FormulaEvaluator evaluator = workbook.getCreationHelper().createFormulaEvaluator(); + Sheet sheet = workbook.getSheetAt(0); + return ExcelPreviewDTO.builder() + .headers(ExcelSupport.getSheetHeader(sheet, 1)) + .list(ExcelParseHelper.parse2List(sheet, evaluator, 2, 1)).build(); + } finally { + IOUtils.closeQuietly(fileInputStream); + } + } + + private Map batchImport(SalaryAcctImportParam param, String importType) { + StopWatch stopWatch = new StopWatch("导入核算数据"); + stopWatch.start("数据准备"); + Map apidatas = new HashMap(); + ValidUtil.doValidator(param); + Date now = new Date(); + + Long currentEmployeeId = (long) user.getUID(); + + //查询对于人员信息导入筛选的全局配置 + SalarySysConfPO salarySysConfPO = getSalarySysConfMapper().getOneByCode("matchEmployeeMode"); + String confValue = (salarySysConfPO != null && salarySysConfPO.getConfValue() != null && !"".equals(salarySysConfPO.getConfValue())) ? salarySysConfPO.getConfValue() : "0"; + + // 薪资核算记录的id + Long salaryAcctRecordId = param.getSalaryAcctRecordId(); + // 薪资核算记录 + SalaryAcctRecordPO salaryAcctRecordPO = getSalaryAcctRecordService(user).getById(salaryAcctRecordId); + if (salaryAcctRecordPO == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98747, "薪资核算记录不存在或已被删除")); + } + stopWatch.stop(); + + // 校验是否可以编辑 + boolean recordIsCanEdit = getSalaryApprovalRuleService(user).getRecordIsCanEdit(salaryAcctRecordPO); + if (StringUtils.equals("importSalaryAcctResult", importType) && !recordIsCanEdit) { + throw new SalaryRunTimeException("该核算记录已经发起审批,无法编辑或核算,请先删除审批流程"); + } + // 薪资账套下的薪资项目副本 + stopWatch.start("薪资账套下的薪资项目副本"); + List salarySobItemPOS = getSalarySobItemService(user).listBySalarySobId(salaryAcctRecordPO.getSalarySobId()); + // 薪资项目 + Set salaryItemIds = SalaryEntityUtil.properties(salarySobItemPOS, SalarySobItemPO::getSalaryItemId); + List salaryItems = getSalaryItemService(user).listByIds(salaryItemIds); + Map salaryItemMap = SalaryEntityUtil.convert2Map(salaryItems, SalaryItemPO::getName, SalaryItemPO::getId); + stopWatch.stop(); + // 薪资核算确认的人员 + stopWatch.start("薪资核算确认的人员"); + List salaryAcctEmployees = getSalaryAcctEmployeeService(user).listBySalaryAcctRecordId(salaryAcctRecordId); + Map salaryAcctEmployeeMap = SalaryEntityUtil.convert2Map(salaryAcctEmployees, e -> e.getEmployeeId() + "-" + e.getTaxAgentId()); + stopWatch.stop(); + // 租户下所有的人员 + stopWatch.start("薪资核算确认的人员"); + List employeeIds = SalaryEntityUtil.properties(salaryAcctEmployees, SalaryAcctEmployeePO::getEmployeeId, Collectors.toList()); + List salaryEmployees = getSalaryEmployeeService(user).getEmployeeByIdsAll(employeeIds); + stopWatch.stop(); + // 租户下所有的个税扣缴义务人 + stopWatch.start("租户下所有的个税扣缴义务人"); + List taxAgents = getTaxAgentService(user).listAll(); + Map taxAgentNameMap = SalaryEntityUtil.convert2Map(taxAgents, TaxAgentPO::getName, TaxAgentPO::getId); + stopWatch.stop(); + // 薪资核算人员信息字段 + stopWatch.start("薪资核算人员信息字段"); + List salarySobEmpFieldPOS = getSalarySobEmpFieldService(user).listBySalarySobId(salaryAcctRecordPO.getSalarySobId()); + List salarySobEmpFields = SalaryEntityUtil.properties(new SalarySobItemAggregateBO().buildEmpField(salarySobEmpFieldPOS), SalarySobEmpFieldDTO::getFieldName, Collectors.toList()); + List excludeFields = Arrays.asList("个税扣缴义务人", "部门", "姓名"); + salarySobEmpFields = salarySobEmpFields.stream().filter(field -> !excludeFields.contains(field)).collect(Collectors.toList()); + stopWatch.stop(); + // 索引(用于计算进度) + int index = 0; + // 失败的数量 + int failCount = 0; + // 成功的数量 + int successCount = 0; + // 总数 +// int total = message.getBatchFile().getExcelSheets().stream() +// .filter(e -> CollectionUtils.isNotEmpty(e.getHeader()) && CollectionUtils.isNotEmpty(e.getData())) +// .map(e -> BigDecimal.valueOf(e.getData().size())) +// .reduce(BigDecimal.ZERO, BigDecimal::add) +// .intValue(); + // 包含错误提示信息的sheet页 + List> errorExcelSheets = Lists.newArrayList(); + // 解析excel + List salaryAcctEmpIds = Lists.newArrayList(); + // excel导入了哪些薪资项目 + Set excelSalaryItemIds = Sets.newHashSet(); + List salaryAcctResults = Lists.newArrayList(); + List salaryAcctReports = Lists.newArrayList(); + List newSalaryAcctEmployees = Lists.newArrayList(); + + List excelAcctResults = Lists.newArrayList(); + + InputStream fileInputStream = null; + try { + + + fileInputStream = ImageFileManager.getInputStreamById(Integer.parseInt(param.getImageId())); + stopWatch.start("解析文件"); + Workbook workbook = ExcelSupport.parseFile(fileInputStream, EXCEL_TYPE_XLSX); + Sheet sheet = workbook.getSheetAt(0); + stopWatch.stop(); + + // 错误提示信息 + List excelComments = Lists.newArrayList(); + // 存在错误的那行数据 + List> errorDatas = Lists.newArrayList(); + // 表头 +// List headers = ExcelSupport.getSheetHeader(sheet, 0); + List headers; +// if (StringUtils.equals("importSalaryAcctResult", importType)) { + headers = ExcelSupport.getSheetHeader(sheet, 1); +// } else { +// headers = ExcelSupport.getSheetHeader(sheet, 0); +// } + + // 处理数值 +// List> data = ExcelParseHelper.parse2Map(sheet, 1); + List> data; +// if (StringUtils.equals("importSalaryAcctResult", importType)) { + data = ExcelParseHelper.parse2Map(sheet, 2, 1); +// } else { +// data = ExcelParseHelper.parse2Map(sheet, 1); +// } + + if (CollectionUtils.isEmpty(headers)) { + throw new RuntimeException("表头为空"); + } + if (CollectionUtils.isEmpty(data)) { + throw new RuntimeException("无数据"); + } + stopWatch.start("解析数据"); + for (int i = 0; i < data.size(); i++) { + + String row = "第" + (i + 3) + "行"; + + int usernameIndex = 0; + boolean isError = false; + Map map = data.get(i); + Long employeeId = 0L; + Long taxAgentId = 0L; + List salaryAcctResultsOfOneEmp = Lists.newArrayListWithExpectedSize(headers.size() - 1); + List salaryAcctResultReportOfOneEmp = Lists.newArrayListWithExpectedSize(headers.size() - 1); + List excelAcctResultsOfOneEmp = Lists.newArrayListWithExpectedSize(headers.size() - 1); + for (int j = 0; j < headers.size(); j++) { + String header = headers.get(j); + String dataKey = header; + if (dataKey == null) { + continue; + } + String dataValue = (String) map.getOrDefault(dataKey.toString(), ""); + String deparmentName = (String) map.getOrDefault("部门", ""); + String mobile = (String) map.getOrDefault("手机号", ""); + String workcode = (String) map.getOrDefault("工号", ""); + String idNo = (String) map.getOrDefault("证件号码", ""); + + if (StringUtils.equals(SalaryI18nUtil.getI18nLabel(85429, "姓名"), dataKey.toString())) { + usernameIndex = j; + if (StringUtils.isEmpty(dataValue) && "0".equals(confValue)) { + isError = true; + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", row + SalaryI18nUtil.getI18nLabel(102838, "姓名不能为空")); + excelComments.add(errorMessageMap); + //salaryBatchService.createExcelComment(excelComments, SalaryI18nUtil.getI18nLabel(102838, "姓名不能为空"), i, i, j, j); + } else { + //筛选导入人员信息可以在人力资源池中匹配到的人员信息 + List employeeSameIds = getSalaryEmployeeService(user).matchImportEmployee(confValue, salaryEmployees, dataValue, deparmentName, mobile, workcode, idNo, null); + + if (CollectionUtils.isEmpty(employeeSameIds)) { + isError = true; + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", row + SalaryI18nUtil.getI18nLabel(100579, "姓名错误,系统内不存在该姓名")); + excelComments.add(errorMessageMap); +// salaryBatchService.createExcelComment(excelComments, SalaryI18nUtil.getI18nLabel(100579, "姓名错误,系统内不存在该姓名"), i, i, j, j); + } else if (employeeSameIds.size() > 1) { + //存在离职和在职状态取在职状态 + employeeSameIds = employeeSameIds.stream() + .filter(e -> UserStatusEnum.getNormalStatus().contains(e.getStatus())) + .collect(Collectors.toList()); + if (employeeSameIds.size() != 1) { + isError = true; + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", row + "员工信息不存在或者存在多个员工"); + excelComments.add(errorMessageMap); + } else { + employeeId = CollectionUtils.isNotEmpty(employeeSameIds) && employeeSameIds.size() == 1 ? employeeSameIds.get(0).getEmployeeId() : null; + } + } else { + employeeId = employeeSameIds.get(0).getEmployeeId(); + } + } + } else if (StringUtils.equals(SalaryI18nUtil.getI18nLabel(86184, "部门"), dataKey.toString()) + || StringUtils.equals(SalaryI18nUtil.getI18nLabel(86186, "手机号"), dataKey.toString()) + || StringUtils.equals(SalaryI18nUtil.getI18nLabel(86186, "工号"), dataKey.toString()) + || salarySobEmpFields.contains(dataKey.toString()) + ) { + + } else if (StringUtils.equals(SalaryI18nUtil.getI18nLabel(86184, "个税扣缴义务人"), dataKey.toString())) { + if (StringUtils.isEmpty(dataValue)) { + isError = true; + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", row + SalaryI18nUtil.getI18nLabel(100579, SalaryI18nUtil.getI18nLabel(102839, "个税扣缴义务人不能为空"))); + excelComments.add(errorMessageMap); +// salaryBatchService.createExcelComment(excelComments, SalaryI18nUtil.getI18nLabel(102839, "个税扣缴义务人不能为空"), i, i, j, j); + } else { + taxAgentId = taxAgentNameMap.getOrDefault(dataValue, 0L); + if (taxAgentId == null || taxAgentId <= 0) { + isError = true; + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", row + SalaryI18nUtil.getI18nLabel(100579, SalaryI18nUtil.getI18nLabel(102840, "个税扣缴义务人错误,系统内不存在该个税扣缴义务人"))); + excelComments.add(errorMessageMap); +// salaryBatchService.createExcelComment(excelComments, SalaryI18nUtil.getI18nLabel(102840, "个税扣缴义务人错误,系统内不存在该个税扣缴义务人"), i, i, j, j); + } + } + } else { + Long salaryItemId = salaryItemMap.get(dataKey.toString()); + if (salaryItemId == null || salaryItemId <= 0) { + isError = true; + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", row + SalaryI18nUtil.getI18nLabel(100579, SalaryI18nUtil.getI18nLabel(102840, "本次核算所用账套不包含该薪资项目"))); + excelComments.add(errorMessageMap); +// salaryBatchService.createExcelComment(excelComments, SalaryI18nUtil.getI18nLabel(102841, "表头错误,本次核算所用账套不包含该薪资项目"), i, i, j, j); + } else { + excelSalaryItemIds.add(salaryItemId); + if (StringUtils.equals("importExcelAcctResult", importType)) { + ExcelAcctResultPO excelAcctResult = ExcelAcctResultPO.builder() + .salaryAcctRecordId(salaryAcctRecordPO.getId()) + .salarySobId(salaryAcctRecordPO.getSalarySobId()) + .salaryItemId(salaryItemId) + .resultValue(dataValue) + .creator(currentEmployeeId) + .createTime(now) + .updateTime(now) + .deleteType(0) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .build(); + excelAcctResultsOfOneEmp.add(excelAcctResult); + } + if (StringUtils.equals("importSalaryAcctResult", importType)) { + SalaryAcctResultPO salaryAcctResult = SalaryAcctResultPO.builder() + .salaryAcctRecordId(salaryAcctRecordPO.getId()) + .salarySobId(salaryAcctRecordPO.getSalarySobId()) + .salaryItemId(salaryItemId) + .resultValue(dataValue) + .creator(currentEmployeeId) + .createTime(now) + .updateTime(now) + .deleteType(0) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .build(); + salaryAcctResultsOfOneEmp.add(salaryAcctResult); + + +// SalaryAcctResultReportPO reportPO = SalaryAcctResultReportPO.builder() +// .id(IdGenerator.generate()) +// .salaryAcctRecordId(salaryAcctRecordPO.getId()) +// .salarySobId(salaryAcctRecordPO.getSalarySobId()) +// .salaryItemId(salaryItemId) +// .resultValue(dataValue) +// .creator(currentEmployeeId) +// .createTime(now) +// .updateTime(now) +// .deleteType(0) +// .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) +// .build(); +// salaryAcctResultReportOfOneEmp.add(reportPO); + } + } + } + // (如果是线下对比)如果个税扣缴义务人+人员目前不在核算人员里面,不支持导入 + if (StringUtils.equals("importExcelAcctResult", importType) + && (employeeId != null && employeeId > 0) + && (taxAgentId != null && taxAgentId > 0) + && j == headers.size() - 1 + && !salaryAcctEmployeeMap.containsKey(employeeId + "-" + taxAgentId)) { + isError = true; + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", row + SalaryI18nUtil.getI18nLabel(100579, SalaryI18nUtil.getI18nLabel(102840, "本次薪资核算不包含该人员"))); + excelComments.add(errorMessageMap); +// salaryBatchService.createExcelComment(excelComments, SalaryI18nUtil.getI18nLabel(102842, "本次薪资核算不包含该人员"), i, i, usernameIndex, usernameIndex); + } + + // 如果个税扣缴义务人+人员目前不在核算人员里面,不支持导入 + if (StringUtils.equals("importSalaryAcctResult", importType) + && (employeeId != null && employeeId > 0) + && (taxAgentId != null && taxAgentId > 0) + && j == headers.size() - 1 + && !salaryAcctEmployeeMap.containsKey(employeeId + "-" + taxAgentId)) { + isError = true; + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", row + SalaryI18nUtil.getI18nLabel(100579, SalaryI18nUtil.getI18nLabel(102840, "本次薪资核算不包含该人员"))); + excelComments.add(errorMessageMap); +// salaryBatchService.createExcelComment(excelComments, SalaryI18nUtil.getI18nLabel(102842, "本次薪资核算不包含该人员"), i, i, usernameIndex, usernameIndex); + } + } + // 每处理50个数据更新一次进度 + index++; +// if (index % 50 == 0 || index >= total) { +// salaryBatchService.sendImportRate(message.getBizId(), total, index); +// } + if (isError) { + failCount++; + errorDatas.add(map); + continue; + } + SalaryAcctEmployeePO salaryAcctEmployee = salaryAcctEmployeeMap.get(employeeId + "-" + taxAgentId); + //多余的人 + if (salaryAcctEmployee == null) { + continue; + } + Long salaryAcctEmpId = Optional.ofNullable(salaryAcctEmployee).map(SalaryAcctEmployeePO::getId).orElse(0L); + if (StringUtils.equals("importExcelAcctResult", importType)) { + for (ExcelAcctResultPO excelAcctResultPO : excelAcctResultsOfOneEmp) { + excelAcctResultPO.setEmployeeId(employeeId); + excelAcctResultPO.setTaxAgentId(taxAgentId); + excelAcctResultPO.setSalaryAcctEmpId(salaryAcctEmpId); + } + excelAcctResults.addAll(excelAcctResultsOfOneEmp); + } + if (StringUtils.equals("importSalaryAcctResult", importType)) { + if (salaryAcctEmpId <= 0) { + SalaryAcctEmployeePO acctEmployee = SalaryAcctEmployeePO.builder() + .employeeId(employeeId) + .salaryAcctRecordId(salaryAcctRecordId) + .salarySobId(salaryAcctRecordPO.getSalarySobId()) + .salaryMonth(salaryAcctRecordPO.getSalaryMonth()) + .taxAgentId(taxAgentId) + .creator(currentEmployeeId) + .createTime(now) + .updateTime(now) + .deleteType(0) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .build(); + newSalaryAcctEmployees.add(acctEmployee); + salaryAcctEmpId = acctEmployee.getId(); + } + for (SalaryAcctResultPO salaryAcctResultPO : salaryAcctResultsOfOneEmp) { + salaryAcctResultPO.setEmployeeId(employeeId); + salaryAcctResultPO.setTaxAgentId(taxAgentId); + salaryAcctResultPO.setSalaryAcctEmpId(salaryAcctEmpId); + } + +// for (SalaryAcctResultReportPO po : salaryAcctResultReportOfOneEmp) { +// po.setEmployeeId(Util.null2String(employeeId)); +// po.setTaxAgentId(taxAgentId); +// po.setSalaryAcctEmpId(Util.null2String(salaryAcctEmpId)); +// +// DataCollectionEmployee emp = emps.get(employeeId); +// po.setSubcompanyId(emp.getSubcompanyid()); +// po.setDepartmentId(emp.getDepartmentId()); +// po.setCostcenterId(emp.getCostcenterId()); +// po.setJobtitleId(emp.getJobtitleId()); +// po.setLocationId(emp.getLocationId()); +// +// } + salaryAcctEmpIds.add(salaryAcctEmpId); + salaryAcctResults.addAll(salaryAcctResultsOfOneEmp); +// salaryAcctReports.addAll(salaryAcctResultReportOfOneEmp); + } + successCount++; + } + stopWatch.stop(); + // 如果sheet包含错误数据 +// if (CollectionUtils.isNotEmpty(errorDatas)) { +// salaryBatchService.createErrorExcelSheet(headers, errorDatas, excelSheet.getName(), excelComments, errorExcelSheets); +// } + stopWatch.start("插入数据"); + if (StringUtils.equals("importExcelAcctResult", importType)) { + getSalaryComparisonResultService(user).deleteBySalaryAcctRecordIds(Collections.singleton(salaryAcctRecordId)); + if (CollectionUtils.isNotEmpty(excelAcctResults)) { + excelAcctResults.stream().forEach(result -> { + if (StringUtils.isEmpty(result.getResultValue())) { + result.setResultValue(" "); + } + }); + getSalaryComparisonResultService(user).batchSave(excelAcctResults); + } + } + if (StringUtils.equals("importSalaryAcctResult", importType)) { + List deleteResults = new ArrayList<>(); + if (CollectionUtils.isNotEmpty(salaryAcctEmpIds)) { + // 获取删除的核算结果 + deleteResults = getSalaryAcctResultService(user).listByAcctEmployeeIdsAndSalaryItemIds(salaryAcctEmpIds, excelSalaryItemIds); + getSalaryAcctResultService(user).deleteByAcctEmployeeIdsAndSalaryItemIds(salaryAcctEmpIds, excelSalaryItemIds); + //删除报表 +// getSalaryAcctReportService(user).deleteByAcctEmployeeIdsAndSalaryItemIds(salaryAcctEmpIds, excelSalaryItemIds); + } + if (CollectionUtils.isNotEmpty(salaryAcctResults)) { + // 处理导入薪资项的回算值 + handleOriginResultValue(deleteResults, salaryAcctResults); + // 备份一份加密前的值 + List list4log = new ArrayList<>(); + salaryAcctResults.forEach(source -> { + SalaryAcctResultPO target = new SalaryAcctResultPO(); + BeanUtils.copyProperties(source, target); + list4log.add(target); + }); + getSalaryAcctResultService(user).batchSave(salaryAcctResults); + + // 记录操作日志 + SalarySobPO salarySobPO = getSalarySobService(user).getById(salaryAcctRecordPO.getSalarySobId()); + String targetName = salarySobPO.getName() + ":" + SalaryDateUtil.localDate2YearMonth(salaryAcctRecordPO.getSalaryMonth()); + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(param.getSalaryAcctRecordId().toString()); + loggerContext.setTargetName(targetName); + loggerContext.setOperateType(OperateTypeEnum.EXCEL_IMPORT.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "导入薪资核算数据")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "导入薪资核算数据 ") + targetName); + loggerContext.setOldValueList(list4log); + SalaryElogConfig.salaryAcctRecordLoggerTemplate.write(loggerContext); + +// //报表 +// getSalaryAcctReportService(user).batchSave(salaryAcctReports); + } + if (CollectionUtils.isNotEmpty(newSalaryAcctEmployees)) { + getSalaryAcctEmployeeService(user).batchSave(newSalaryAcctEmployees); + } + } + stopWatch.stop(); + stopWatch.start("锁定数据"); + SalarySysConfPO autoLock = getSalarySysConfService(user).getOneByCode(SalarySysConstant.EDIT_IMPORT_AUTO_LOCK); + if (autoLock != null && StringUtils.equals(autoLock.getConfValue(), "1")) { + // 导入的列都自动锁定 + SalaryAcctResultUpdateLockStatusParam updateLockStatusParam = SalaryAcctResultUpdateLockStatusParam.builder() + .salaryItemIds(excelSalaryItemIds) + .salaryAcctRecordId(param.getSalaryAcctRecordId()) + .lockStatus(LockStatusEnum.LOCK).build(); + getSalaryAcctResultService(user).updateLockStatusByParam(updateLockStatusParam); + } + stopWatch.stop(); + log.info(stopWatch.prettyPrint()); + + apidatas.put("successCount", successCount); + apidatas.put("errorCount", failCount); + apidatas.put("errorData", excelComments); + + } finally { + IOUtils.closeQuietly(fileInputStream); + } + + // 发送导入回调信息 +// salaryBatchService.sendImportCallBackInfo(message, successCount, failCount, errorExcelSheets); + return apidatas; + } + + /** + * 存储薪资核算结果数据来源日志 + * + * @param salaryAcctResults + */ + private void handleSalaryAcctResultLog(List salaryAcctResults) { + List salaryAcctEmpIds = salaryAcctResults.stream().map(SalaryAcctResultPO::getSalaryAcctEmpId).distinct().collect(Collectors.toList()); + Set salaryItemIds = salaryAcctResults.stream().map(SalaryAcctResultPO::getSalaryItemId).collect(Collectors.toSet()); + // 查询导入的薪资核算结果 + List salaryAcctResultList = getSalaryAcctResultService(user).listByAcctEmployeeIdsAndSalaryItemIds(salaryAcctEmpIds, salaryItemIds); + Long uid = Long.valueOf(user.getUID()); + List needInsertList = SalaryAcctResultLogBO.buildSalaryAcctResultLog(salaryAcctResultList, uid, SalaryAcctResultDataSourceEnum.IMPORT); + if (CollectionUtils.isNotEmpty(needInsertList)) { + getSalaryAcctResultLogService(user).batchInsert(needInsertList); + } + } + + /** + * @return void + * @description + * @author Harryxzy + * @date 2022/12/26 22:36 + */ + private void handleOriginResultValue(List deleteResults, List salaryAcctResults) { + Map> deleteMap = SalaryEntityUtil.group2Map(deleteResults, po -> po.getSalaryAcctEmpId() + "-" + po.getSalaryItemId()); + salaryAcctResults.stream().forEach(result -> { + List salaryAcctResultPOS = deleteMap.get(result.getSalaryAcctEmpId() + "-" + result.getSalaryItemId()); + if (salaryAcctResultPOS != null && salaryAcctResultPOS.size() > 0) { + result.setOriginResultValue(salaryAcctResultPOS.get(0).getOriginResultValue()); + } + }); + + } + + /** + * 保存导出模板 + * + * @param saveParam + */ + @Override + public void saveExportTemplate(SalaryAcctResultTemplateSaveParam saveParam) { + ValidUtil.doValidator(saveParam); + Long salaryAcctRecordId = saveParam.getSalaryAcctRecordId(); + SalaryAcctRecordPO salaryAcctRecordPO = getSalaryAcctRecordService(user).getById(salaryAcctRecordId); + if (salaryAcctRecordPO == null) { + throw new SalaryRunTimeException("薪资核算记录不存在"); + } + saveParam.setSalarySobId(salaryAcctRecordPO.getSalarySobId()); + List templateBySobId = getSalaryAcctResultTemplateService(user).listBySalarySobId(saveParam.getSalarySobId(), Arrays.asList(0, 1)); + if (saveParam.getId() != null) { + Optional saveNameOptional = templateBySobId.stream().filter(po -> po.getTemplateName().equals(saveParam.getTemplateName()) && !po.getId().equals(saveParam.getId())).findFirst(); + if (saveNameOptional.isPresent()) { + throw new SalaryRunTimeException("该账套中已经存在同名模板,请重新设置后保存"); + } + // 更新 + SalaryAcctResultTemplatePO salaryAcctResultTemplatePO = getSalaryAcctResultTemplateService(user).getById(saveParam.getId()); + if (salaryAcctResultTemplatePO == null) { + throw new SalaryRunTimeException("模板不存在,或已被删除"); + } + salaryAcctResultTemplatePO.setSalaryItemIds(StringUtils.join(saveParam.getSalaryItemIds(), ",")); + salaryAcctResultTemplatePO.setTemplateName(saveParam.getTemplateName()); + salaryAcctResultTemplatePO.setType(0); + salaryAcctResultTemplatePO.setUpdateTime(new Date()); + getSalaryAcctResultTemplateService(user).update(salaryAcctResultTemplatePO); + } else { + Optional saveNameOptional = templateBySobId.stream().filter(po -> po.getTemplateName().equals(saveParam.getTemplateName())).findFirst(); + if (saveNameOptional.isPresent()) { + throw new SalaryRunTimeException("该账套中已经存在同名模板,请重新设置后保存"); + } + // 新建 + Date now = new Date(); + SalaryAcctResultTemplatePO templatePO = SalaryAcctResultTemplatePO.builder() + .id(IdGenerator.generate()) + .type(0) + .salarySobId(saveParam.getSalarySobId()) + .salaryItemIds(StringUtils.join(saveParam.getSalaryItemIds(), ",")) + .templateName(saveParam.getTemplateName()) + .creator((long) user.getUID()) + .createTime(now) + .updateTime(now) + .deleteType(0) + .build(); + getSalaryAcctResultTemplateService(user).insertIgnoreNull(templatePO); + } + + } + + @Override + public void deleteExportTemplate(List templateIds) { + getSalaryAcctResultTemplateService(user).deleteByIds(templateIds); + } + + @Override + public Map getExportTemplateForm(Long templateId) { + SalaryAcctResultTemplatePO salaryAcctResultTemplatePO = getSalaryAcctResultTemplateService(user).getById(templateId); + if (salaryAcctResultTemplatePO == null) { + throw new SalaryRunTimeException("模板不存在或已被删除"); + } + Map resultMap = new HashMap<>(); + resultMap.put("checkItems", StringUtils.split(salaryAcctResultTemplatePO.getSalaryItemIds(), ",")); + return resultMap; + } + + @Override + public Map exportTemplateList(SalaryAcctResultTemplateSaveParam param) { + SalaryAcctRecordPO salaryAcctRecordPO = getSalaryAcctRecordService(user).getById(param.getSalaryAcctRecordId()); + if (salaryAcctRecordPO == null) { + throw new SalaryRunTimeException("薪资核算记录为空"); + } + List salaryAcctResultTemplatePOS = getSalaryAcctResultTemplateService(user).listBySalarySobId(salaryAcctRecordPO.getSalarySobId(), Arrays.asList(0, 1)); + if (StringUtils.isNotBlank(param.getTemplateName())) { + salaryAcctResultTemplatePOS = salaryAcctResultTemplatePOS.stream().filter(po -> po.getTemplateName().contains(param.getTemplateName())).collect(Collectors.toList()); + } + List resultList = new ArrayList<>(); + salaryAcctResultTemplatePOS.stream().forEach(po -> resultList.add(SalaryAcctResultTemplateDTO.builder().id(po.getId()).templateName(po.getTemplateName()).createTime(SalaryDateUtil.getFormatLocalDateTime(po.getCreateTime())).build())); + PageInfo pageInfo = SalaryPageUtil.buildPage(param.getCurrent(), param.getPageSize(), resultList, SalaryAcctResultTemplateDTO.class); + + Map resultMap = new HashMap<>(); + resultMap.put("pageInfo", pageInfo); + + return resultMap; + } +// @Override +// public Map exportCheckResult( +// SalaryCheckResultExportParam exportParam, +// ) { +// // 查询薪资核算结果校验异常 +// List salaryCheckResults = salaryCheckResultService.listBySalaryAcctRecordId(exportParam.getSalaryAcctRecordId()); +// List excelSheetData = Lists.newArrayListWithExpectedSize(salaryCheckResults.size()); +// for (SalaryCheckResultPO salaryCheckResult : salaryCheckResults) { +// excelSheetData.add(buildDetailExcelSheetData(salaryCheckResult, simpleEmployee.getEmployeeId())); +// } +// ExportExcelInfo exportExcelInfo = ExportExcelInfo.builder() +// .fileName("校验异常") +// .dataType("校验异常") +// .function(excelExportParam.getFunction()) +// .handlerName("salaryCheckResultHandler") +// .flag(true) +// .bizId(String.valueOf(excelExportParam.getBiz())) +// .module(excelExportParam.getModule()) +// .userId(simpleEmployee.getEmployeeId()) +// .tenantKey(tenantKey) +// .operator(simpleEmployee.getUsername()) +// .eteamsId(eteamsId) +// .build(); +// return salaryBatchService.simpleExportExcel(exportExcelInfo, excelSheetData); +// } +// +// @BatchExportHandler("salaryCheckResultHandler") +// private void salaryCheckResultHandler() { +// BatchCallbackMessage message = BatchExportContext.getBatchCallbackMessage(); +// log.info("导出结束:{}", JsonUtil.toJsonString(message)); +// } +// +// @Override +// public Map exportCheckResultDetail( +// Long checkResultId, +// ) { +// // 查询校验异常 +// SalaryCheckResultPO checkResult = salaryCheckResultService.getById(checkResultId); +// // 查询校验异常明细 +// ExcelSheetData excelSheetData = buildDetailExcelSheetData(checkResult, simpleEmployee.getEmployeeId()); +// ExportExcelInfo exportExcelInfo = ExportExcelInfo.builder() +// .fileName("校验异常明细") +// .dataType("校验异常明细") +// .function(excelExportParam.getFunction()) +// .handlerName("salaryCheckResultDetailHandler") +// .flag(true) +// .bizId(String.valueOf(excelExportParam.getBiz())) +// .module(excelExportParam.getModule()) +// .userId(simpleEmployee.getEmployeeId()) +// .tenantKey(tenantKey) +// .operator(simpleEmployee.getUsername()) +// .eteamsId(eteamsId) +// .build(); +// return salaryBatchService.simpleExportExcel(exportExcelInfo, Collections.singletonList(excelSheetData)); +// } +// +// @BatchExportHandler("salaryCheckResultDetailHandler") +// private void salaryCheckResultDetailHandler() { +// BatchCallbackMessage message = BatchExportContext.getBatchCallbackMessage(); +// log.info("导出结束:{}", JsonUtil.toJsonString(message)); +// } +// +// private ExcelSheetData buildDetailExcelSheetData(SalaryCheckResultPO checkResult, Long employeeId) { +// // 查询校验异常中的校验规则 +// SalarySobCheckRulePO checkRule = salarySobCheckRuleService.getById(checkResult.getSalaryCheckRuleId()); +// // 查询校验异常明细 +// List salaryCheckResultRecords = salaryCheckResultDetailService.listByCheckResultId(checkResult.getId()); +// String[] headers = new String[]{"规则名称", "规则内容", "姓名"}; +// List> rows = Lists.newArrayList(); +// ExcelSheetData excelSheetData = new ExcelSheetData(); +// excelSheetData.setSheetName("校验异常"); +// excelSheetData.setHeaders(Collections.singletonList(headers)); +// excelSheetData.setRows(rows); +// if (CollectionUtils.isEmpty(salaryCheckResultRecords)) { +// return excelSheetData; +// } +// List employeeIds = SalaryEntityUtil.properties(salaryCheckResultRecords, SalaryCheckResultRecordPO::getEmployeeId, Collectors.toList()); +// List simpleEmployees = hrmCommonEmployeeService.getEmployeeByIds(employeeIds); +// Map simpleEmployeeMap = SalaryEntityUtil.convert2Map(simpleEmployees, DataCollectionEmployee::getEmployeeId, DataCollectionEmployee::getUsername); +// List expressFormulas = getSalaryFormulaService(user).listExpressFormula(Collections.singleton(checkResult.getFormulaId())); +// Map formulaMap = SalaryEntityUtil.convert2Map(expressFormulas, ExpressFormula::getId, ExpressFormula::getFormula); +// for (SalaryCheckResultRecordPO salaryCheckResultRecord : salaryCheckResultRecords) { +// List row = Lists.newArrayListWithExpectedSize(3); +// row.add(checkRule.getName()); +// row.add(formulaMap.getOrDefault(salaryCheckResultRecord.getFormulaId(), "")); +// row.add(simpleEmployeeMap.getOrDefault(salaryCheckResultRecord.getEmployeeId(), "")); +// rows.add(row); +// } +// return excelSheetData; +// } +} diff --git a/src/com/engine/salary/service/impl/SalaryAcctRecordServiceImpl.java b/src/com/engine/salary/service/impl/SalaryAcctRecordServiceImpl.java new file mode 100644 index 000000000..ffab3136b --- /dev/null +++ b/src/com/engine/salary/service/impl/SalaryAcctRecordServiceImpl.java @@ -0,0 +1,825 @@ +package com.engine.salary.service.impl; + +import cn.hutool.core.collection.CollUtil; +import com.api.formmode.mybatis.util.SqlProxyHandle; +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.hrmelog.entity.dto.LoggerContext; +import com.engine.salary.common.LocalDateRange; +import com.engine.salary.config.SalaryElogConfig; +import com.engine.salary.entity.salaryBill.po.SalarySendPO; +import com.engine.salary.entity.salaryacct.bo.SalaryAcctRecordBO; +import com.engine.salary.entity.salaryacct.param.SalaryAcctRecordQueryParam; +import com.engine.salary.entity.salaryacct.param.SalaryAcctRecordSaveParam; +import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO; +import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO; +import com.engine.salary.entity.salaryacct.po.SalaryAcctResultPO; +import com.engine.salary.entity.salarysob.dto.SalarySobCycleDTO; +import com.engine.salary.entity.salarysob.po.SalarySobPO; +import com.engine.salary.enums.OperateTypeEnum; +import com.engine.salary.enums.auth.AuthFilterTypeEnum; +import com.engine.salary.enums.salaryaccounting.SalaryAcctRecordStatusEnum; +import com.engine.salary.enums.salarysob.IncomeCategoryEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.mapper.salaryacct.SalaryAcctRecordMapper; +import com.engine.salary.mapper.salarybill.SalarySendMapper; +import com.engine.salary.report.service.SalaryStatisticsReportService; +import com.engine.salary.report.service.impl.SalaryStatisticsReportServiceImpl; +import com.engine.salary.service.*; +import com.engine.salary.service.auth.AuthService; +import com.engine.salary.service.auth.AuthServiceImpl; +import com.engine.salary.sys.enums.TaxDeclarationFunctionEnum; +import com.engine.salary.sys.service.SalarySysConfService; +import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl; +import com.engine.salary.util.SalaryDateUtil; +import com.engine.salary.util.SalaryEntityUtil; +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.page.SalaryPageUtil; +import com.engine.salary.util.valid.ValidUtil; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.math.NumberUtils; +import weaver.hrm.User; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * 薪资核算 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRecordService { + + private SalaryAcctRecordMapper getSalaryAcctRecordMapper() { + return MapperProxyFactory.getProxy(SalaryAcctRecordMapper.class); + } + + private SalarySobService getSalarySobService(User user) { + return ServiceUtil.getService(SalarySobServiceImpl.class, user); + } + + + private SalaryAcctEmployeeService getSalaryAcctEmployeeService(User user) { + return ServiceUtil.getService(SalaryAcctEmployeeServiceImpl.class, user); + } + + + private SalaryAcctResultService getSalaryAcctResultService(User user) { + return ServiceUtil.getService(SalaryAcctResultServiceImpl.class, user); + } + + + private SalarySendService getSalarySendService(User user) { + return ServiceUtil.getService(SalarySendServiceImpl.class, user); + } + + private SalarySysConfService getSalarySysConfService(User user) { + return ServiceUtil.getService(SalarySysConfServiceImpl.class, user); + } + + private SalarySobItemService getSalarySobItemService(User user) { + return ServiceUtil.getService(SalarySobItemServiceImpl.class, user); + } + + // private SalaryCheckResultService salaryCheckResultService; +// +// private SalaryCheckResultDetailService salaryCheckResultDetailService; +// + private SalaryComparisonResultService getSalaryComparisonResultService(User user) { + return ServiceUtil.getService(SalaryComparisonResultServiceImpl.class, user); + } + + private TaxDeclarationService getTaxDeclarationService(User user) { + return ServiceUtil.getService(TaxDeclarationServiceImpl.class, user); + } + + private TaxAgentService getTaxAgentService(User user) { + return ServiceUtil.getService(TaxAgentServiceImpl.class, user); + } + + + private SalaryAcctReportService getSalaryAcctReportService(User user) { + return ServiceUtil.getService(SalaryAcctReportServiceImpl.class, user); + } + + private SalaryStatisticsReportService getSalaryStatisticsReportService(User user) { + return ServiceUtil.getService(SalaryStatisticsReportServiceImpl.class, user); + } + + private SalaryEmployeeService getSalaryEmployeeService(User user) { + return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user); + } + + public AuthService getAuthService(User user) { + return ServiceUtil.getService(AuthServiceImpl.class, user); + } + + private PushService getPushService(User user) { + return ServiceUtil.getService(PushServiceImpl.class, user); + } + + + @Override + public SalaryAcctRecordPO getById(Long id) { + return getSalaryAcctRecordMapper().getById(id); + } + + @Override + public List listAll() { + return getSalaryAcctRecordMapper().listAll(); + } + + @Override + public List listByIds(Collection ids) { + if (CollectionUtils.isEmpty(ids)) { + return Collections.emptyList(); + } + return getSalaryAcctRecordMapper().listSome(SalaryAcctRecordPO.builder().ids(ids).build()); + } + + @Override + public List listBySalarySobIdsAndSalaryMonth(Collection salarySobIds, LocalDateRange salaryMonthDateRange) { + if (CollectionUtils.isEmpty(salarySobIds)) { + return Collections.emptyList(); + } + return getSalaryAcctRecordMapper().listSome(SalaryAcctRecordPO.builder().salarySobIds(salarySobIds).salaryMonths(salaryMonthDateRange).build()); + } + + @Override + public List listBySalarySobIdsAndTaxCycle(Collection salarySobIds, LocalDateRange taxCycleDateRange) { + if (CollectionUtils.isEmpty(salarySobIds)) { + return Collections.emptyList(); + } + return getSalaryAcctRecordMapper().listSome(SalaryAcctRecordPO.builder().salarySobIds(salarySobIds).taxCycleDateRange(taxCycleDateRange).build()); + } + + @Override + public List listBySalaryMonth(LocalDateRange salaryMonthDateRange) { + return getSalaryAcctRecordMapper().listSome(SalaryAcctRecordPO.builder().salaryMonths(salaryMonthDateRange).build()); + } + + @Override + public List listByTaxCycle(LocalDateRange taxCycleDateRange, Collection salarySobIds) { + return getSalaryAcctRecordMapper().listSome(SalaryAcctRecordPO.builder().taxCycleDateRange(taxCycleDateRange).salarySobIds(salarySobIds).build()); + } + + private SalarySendMapper getSalarySendMapper() { + return SqlProxyHandle.getProxy(SalarySendMapper.class); + } + + @Override + public PageInfo listPageByParam(SalaryAcctRecordQueryParam queryParam) { + // 参数 + SalaryAcctRecordPO po = SalaryAcctRecordPO.builder().build(); + PageInfo page = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize()); + if (StringUtils.isNotEmpty(queryParam.getName())) { + // 根据查询条件中的薪资账套名称查询薪资账套 + List salarySobPOS = getSalarySobService(user).listByNameLike(queryParam.getName()); + if (CollectionUtils.isEmpty(salarySobPOS)) { + return page; + } + // 过滤薪资账套 + Set salarySobIds = SalaryEntityUtil.properties(salarySobPOS, SalarySobPO::getId); + po.setSalarySobIds(salarySobIds); + } + if (CollUtil.isNotEmpty(queryParam.getTaxAgentIds())) { + List salarySobPOS = getSalarySobService(user).listByTaxAgentIds(queryParam.getTaxAgentIds()); + if (CollectionUtils.isEmpty(salarySobPOS)) { + return page; + } + Set salarySobIds = SalaryEntityUtil.properties(salarySobPOS, SalarySobPO::getId); + + Collection existIds = po.getSalarySobIds(); + if (CollectionUtils.isNotEmpty(existIds)) { + existIds = SalaryEntityUtil.intersectionForList(existIds, salarySobIds); + po.setSalarySobIds(existIds); + } else { + po.setSalarySobIds(salarySobIds); + } + } + LocalDateRange localDateRange = new LocalDateRange(); + if (Objects.nonNull(queryParam.getStartMonth())) { + localDateRange.setFromDate(SalaryDateUtil.localDateToDate(queryParam.getStartMonth().atDay(1))); + } + if (Objects.nonNull(queryParam.getEndMonth())) { + localDateRange.setEndDate(SalaryDateUtil.localDateToDate(queryParam.getEndMonth().atEndOfMonth())); + } + po.setSalaryMonths(localDateRange); + + // 查询薪资核算记录 + List salaryAcctRecordPOS = getSalaryAcctRecordMapper().listSome(po); + salaryAcctRecordPOS = getAuthService(user).auth(salaryAcctRecordPOS, AuthFilterTypeEnum.DATA_OPT, SalaryAcctRecordPO.class); + + + return SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), + salaryAcctRecordPOS, SalaryAcctRecordPO.class); + } + + @Override + public List listById4LastSalaryMonth(Long id) { + // 查询薪资核算记录 + SalaryAcctRecordPO salaryAcctRecordPO = getById(id); + if (Objects.isNull(salaryAcctRecordPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98747, "薪资核算记录不存在或已被删除")); + } + + //上个月日期 + Date salaryMonth = salaryAcctRecordPO.getSalaryMonth(); + Calendar prevMonth = Calendar.getInstance(); + prevMonth.setTime(salaryMonth); + prevMonth.set(Calendar.MONTH, prevMonth.get(Calendar.MONTH) - 1); + + // 查询上个月的核算记录 + LocalDateRange salaryMonthDateRange = SalaryDateUtil.localDate2Range(prevMonth.getTime()); + return listBySalarySobIdsAndSalaryMonth(Collections.singleton(salaryAcctRecordPO.getSalarySobId()), + salaryMonthDateRange); + } + + @Override + public List listBySalarySobIds(Collection salarySobIds) { + return getSalaryAcctRecordMapper().listSome(SalaryAcctRecordPO.builder().salarySobIds(salarySobIds).build()); + } + + @Override + public List listById4OtherConsolidatedTax(Long id) { + SalaryAcctRecordPO salaryAcctRecordPO = getById(id); + if (Objects.isNull(salaryAcctRecordPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98747, "薪资核算记录不存在或已被删除")); + } + // 查询所有薪资类型为工资薪金的账套 + List salarySobPOS = getSalarySobService(user).listByIncomeCategory(IncomeCategoryEnum.WAGES_AND_SALARIES); + // 如果薪资账套的薪资类型不是工资薪金的,代表不存在合并计税 + boolean isWageSalarySob = salarySobPOS.stream().anyMatch(salarySobPO -> Objects.equals(salarySobPO.getId(), salaryAcctRecordPO.getSalarySobId())); + if (!isWageSalarySob) { + return Collections.emptyList(); + } + // 查询相同税款所属期内的薪资类型为工资薪金的账套的所有核算记录 + Set salarySobIds = SalaryEntityUtil.properties(salarySobPOS, SalarySobPO::getId); + LocalDateRange taxCycleDateRange = SalaryDateUtil.localDate2Range(salaryAcctRecordPO.getTaxCycle()); + List salaryAcctRecordPOS = listByTaxCycle(taxCycleDateRange, salarySobIds); + // 除开本次薪资核算记录之外的其他薪资核算记录 + return salaryAcctRecordPOS.stream().filter(po -> !Objects.equals(po.getId(), salaryAcctRecordPO.getId())).collect(Collectors.toList()); + } + + @Override + public SalarySobCycleDTO getSalarySobCycleById(Long id) { + // 查询薪资核算 + SalaryAcctRecordPO salaryAcctRecordPO = getById(id); + if (Objects.isNull(salaryAcctRecordPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98747, "薪资核算记录不存在或已被删除")); + } + // 查询薪资核算所用薪资账套的薪资周期、考勤周期…… + return getSalarySobService(user).getSalarySobCycle(salaryAcctRecordPO.getSalarySobId(), SalaryDateUtil.localDate2YearMonth(salaryAcctRecordPO.getSalaryMonth())); + + } + + @Override + public Long save(SalaryAcctRecordSaveParam saveParam) { + ValidUtil.doValidator(saveParam); + //检查 + checkBeforeSave(saveParam); + + + // 查询税款所属期 + SalarySobCycleDTO salarySobCycleDTO = getSalarySobService(user).getSalarySobCycle(saveParam.getSalarySobId(), saveParam.getSalaryMonth()); + // 薪资所属月所在年的日期范围(第一天~最后一天) + LocalDateRange yearRange = SalaryDateUtil.localDate2YearRange(SalaryDateUtil.localDateToDate(salarySobCycleDTO.getTaxCycle().atDay(1))); + if (Objects.isNull(yearRange)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(84026, "参数错误")); + } + + // 查询税款所属期所在年的所有薪资核算记录 + List salaryAcctRecordPOS = listByTaxCycle(yearRange, Collections.singleton(saveParam.getSalarySobId())); + + // 计算当前所选的薪资账套是当前薪资所属月的核算次数 + long acctTimes = salaryAcctRecordPOS.stream() + .filter(salaryAcctRecordPO -> Objects.equals(salaryAcctRecordPO.getSalarySobId(), saveParam.getSalarySobId()) + && salaryAcctRecordPO.getTaxCycle().equals(SalaryDateUtil.localDateToDate(salarySobCycleDTO.getTaxCycle().atDay(1)))) + .count(); + + // 转换成po + SalaryAcctRecordPO salaryAcctRecordPO = SalaryAcctRecordBO.convert2PO(saveParam, salarySobCycleDTO, (int) acctTimes, (long) user.getUID()); + // 保存薪资核算记录 + getSalaryAcctRecordMapper().insertIgnoreNull(salaryAcctRecordPO); + // 初始化薪资核算人员 + getSalaryAcctEmployeeService(user).initBySalaryAcctRecord(salaryAcctRecordPO); + // 记录日志 + String targetName = getLogTargetNameById(salaryAcctRecordPO.getId()); + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId("" + salaryAcctRecordPO.getId()); + loggerContext.setTargetName(targetName); + loggerContext.setOperateType(OperateTypeEnum.ADD.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "新建薪资核算")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "新建薪资核算") + ": " + targetName); + loggerContext.setNewValues(salaryAcctRecordPO); + SalaryElogConfig.salaryAcctRecordLoggerTemplate.write(loggerContext); + // 返回薪资核算记录id + return salaryAcctRecordPO.getId(); + } + + + /** + * 保存之前检查一下是否可以新建核算 + * + * @param saveParam + */ + private void checkBeforeSave(SalaryAcctRecordSaveParam saveParam) { + + // 查询税款所属期 + SalarySobCycleDTO salarySobCycleDTO = getSalarySobService(user).getSalarySobCycle(saveParam.getSalarySobId(), saveParam.getSalaryMonth()); + // 薪资所属月所在年的日期范围(第一天~最后一天) + LocalDateRange taxCycleYearRange = SalaryDateUtil.localDate2YearRange(SalaryDateUtil.localDateToDate(salarySobCycleDTO.getTaxCycle().atDay(1))); + if (Objects.isNull(taxCycleYearRange)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(84026, "参数错误")); + } + + //获取账套所属个税扣缴义务人的核算记录 + SalarySobPO salarySobPO = getSalarySobService(user).getById(saveParam.getSalarySobId()); + List taxAgentIds = salarySobPO.getTaxAgentIds(); + taxAgentIds.forEach(taxAgentId->{ + //查询扣缴义务人下的所有账套 + List salarySobPOS = getSalarySobService(user).listByTaxAgentId(taxAgentId); + Set salarySobIds = SalaryEntityUtil.properties(salarySobPOS, SalarySobPO::getId); + //获取账套下的所有核算结果 + List salaryAcctRecords = listByTaxCycle(taxCycleYearRange, salarySobIds); + + // 获取个税申报功能状态 + TaxDeclarationFunctionEnum taxDeclarationFunctionEnum = getSalarySysConfService(user).getTaxDeclaration(); + + if (taxDeclarationFunctionEnum.getValue().equals(TaxDeclarationFunctionEnum.OPEN.getValue())) { + // 开启了个税申报功能 + // 如果某个月(税款所属期)已经归档了,不可以新建之前月份的薪资核算 + SalaryAcctRecordPO hasArchivedSalaryAcctRecordPO = salaryAcctRecords.stream() + .filter(e -> Objects.equals(e.getStatus(), SalaryAcctRecordStatusEnum.ARCHIVED.getValue()) + && e.getTaxCycle().after(SalaryDateUtil.localDateToDate(salarySobCycleDTO.getTaxCycle().atDay(1)))) + .findAny() + .orElse(null); + if (Objects.nonNull(hasArchivedSalaryAcctRecordPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98752, "税款所属期{0}的薪资核算结果已经归档,不能新建税款所属期{1}的薪资核算") + .replace("{0}", SalaryDateUtil.localDate2YearMonth(hasArchivedSalaryAcctRecordPO.getTaxCycle()).toString()) + .replace("{1}", salarySobCycleDTO.getTaxCycle().toString())); + } + // 如果某个月(税款所属期)还未申报,不可以新建之后月份的薪资核算 + SalaryAcctRecordPO notDeclaredSalaryAcctRecordPO = salaryAcctRecords.stream() + .filter(e -> !Objects.equals(e.getStatus(), SalaryAcctRecordStatusEnum.DECLARED.getValue()) + && e.getTaxCycle().before(SalaryDateUtil.localDateToDate(salarySobCycleDTO.getTaxCycle().atDay(1)))) + .findAny() + .orElse(null); + if (Objects.nonNull(notDeclaredSalaryAcctRecordPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98751, "税款所属期{0}的薪资核算结果还未申报,不能新建税款所属期{1}的薪资核算") + .replace("{0}", SalaryDateUtil.localDate2YearMonth(notDeclaredSalaryAcctRecordPO.getTaxCycle()).toString()) + .replace("{1}", salarySobCycleDTO.getTaxCycle().toString())); + } + // 如果某个月(税款所属期)已经申报了,不可以新建本月以及之前月份的薪资核算 + SalaryAcctRecordPO hasDeclaredSalaryAcctRecordPO = salaryAcctRecords.stream() + .filter(e -> Objects.equals(e.getStatus(), SalaryAcctRecordStatusEnum.DECLARED.getValue()) + && e.getTaxCycle().compareTo(SalaryDateUtil.localDateToDate(salarySobCycleDTO.getTaxCycle().atDay(1))) >= 0) + .findAny() + .orElse(null); + if (Objects.nonNull(hasDeclaredSalaryAcctRecordPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98753, "税款所属期{0}的薪资核算结果已经申报,不能新建税款所属期{1}的薪资核算") + .replace("{0}", SalaryDateUtil.localDate2YearMonth(hasDeclaredSalaryAcctRecordPO.getTaxCycle()).toString()) + .replace("{1}", salarySobCycleDTO.getTaxCycle().toString())); + } + } + if (taxDeclarationFunctionEnum.getValue().equals(TaxDeclarationFunctionEnum.REBOOT.getValue())) { + // 重启了个税申报功能(不去校验重启之前是否申报数据) + // 如果某个月(薪资所属期)还未归档,不可以新建之后月份的薪资核算 + SalaryAcctRecordPO notArchivedSalaryAcctRecordPO = salaryAcctRecords.stream() + .filter(e -> Objects.equals(e.getStatus(), SalaryAcctRecordStatusEnum.NOT_ARCHIVED.getValue()) + && e.getSalaryMonth().before(SalaryDateUtil.localDateToDate(salarySobCycleDTO.getSalaryMonth().atDay(1)))) + .findAny() + .orElse(null); + if (Objects.nonNull(notArchivedSalaryAcctRecordPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98754, "薪资所属期{0}的薪资核算结果还未归档,不能新建薪资所属期{1}的薪资核算") + .replace("{0}", SalaryDateUtil.localDate2YearMonth(notArchivedSalaryAcctRecordPO.getTaxCycle()).toString()) + .replace("{1}", salarySobCycleDTO.getTaxCycle().toString())); + } + // 如果某个月(税款所属期)已经归档了,不可以新建之前月份的薪资核算 + SalaryAcctRecordPO hasArchivedSalaryAcctRecordPO = salaryAcctRecords.stream() + .filter(e -> Objects.equals(e.getStatus(), SalaryAcctRecordStatusEnum.ARCHIVED.getValue()) + && e.getTaxCycle().after(SalaryDateUtil.localDateToDate(salarySobCycleDTO.getTaxCycle().atDay(1)))) + .findAny() + .orElse(null); + if (Objects.nonNull(hasArchivedSalaryAcctRecordPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98752, "税款所属期{0}的薪资核算结果已经归档,不能新建税款所属期{1}的薪资核算") + .replace("{0}", SalaryDateUtil.localDate2YearMonth(hasArchivedSalaryAcctRecordPO.getTaxCycle()).toString()) + .replace("{1}", salarySobCycleDTO.getTaxCycle().toString())); + } + // 如果某个月(税款所属期)还未申报,不可以新建之后月份的薪资核算 + //获取账套下从重启月至所在年的最后一天的所有核算结果 + Date taxDeclarationRebootDate = getSalarySysConfService(user).getTaxDeclarationRebootDate(); + if (taxDeclarationRebootDate == null) { + throw new SalaryRunTimeException("个税申报功能异常"); + } + + LocalDateRange taxCycleRebootYearRange = LocalDateRange.builder() + .fromDate(taxDeclarationRebootDate) + .endDate(SalaryDateUtil.getLastDayOfYear(taxDeclarationRebootDate)) + .build(); +// List salaryAcctRebootRecords = listByTaxCycle(taxCycleRebootYearRange,salarySobIds); + List salaryAcctRebootRecords = listByCreateDate(taxCycleRebootYearRange, salarySobIds); + SalaryAcctRecordPO notDeclaredSalaryAcctRecordPO = salaryAcctRebootRecords.stream() + .filter(e -> !Objects.equals(e.getStatus(), SalaryAcctRecordStatusEnum.DECLARED.getValue()) + && e.getTaxCycle().before(SalaryDateUtil.localDateToDate(salarySobCycleDTO.getTaxCycle().atDay(1)))) + .findAny() + .orElse(null); + if (Objects.nonNull(notDeclaredSalaryAcctRecordPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98751, "税款所属期{0}的薪资核算结果还未申报,不能新建税款所属期{1}的薪资核算") + .replace("{0}", SalaryDateUtil.localDate2YearMonth(notDeclaredSalaryAcctRecordPO.getTaxCycle()).toString()) + .replace("{1}", salarySobCycleDTO.getTaxCycle().toString())); + } + + // 如果某个月(税款所属期)已经申报了,不可以新建本月以及之前月份的薪资核算 + SalaryAcctRecordPO hasDeclaredSalaryAcctRecordPO = salaryAcctRecords.stream() + .filter(e -> Objects.equals(e.getStatus(), SalaryAcctRecordStatusEnum.DECLARED.getValue()) + && e.getTaxCycle().compareTo(SalaryDateUtil.localDateToDate(salarySobCycleDTO.getTaxCycle().atDay(1))) >= 0) + .findAny() + .orElse(null); + if (Objects.nonNull(hasDeclaredSalaryAcctRecordPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98753, "税款所属期{0}的薪资核算结果已经申报,不能新建税款所属期{1}的薪资核算") + .replace("{0}", SalaryDateUtil.localDate2YearMonth(hasDeclaredSalaryAcctRecordPO.getTaxCycle()).toString()) + .replace("{1}", salarySobCycleDTO.getTaxCycle().toString())); + } + } + }); + } + + private List listByCreateDate(LocalDateRange taxCycleRebootYearRange, Set salarySobIds) { + return getSalaryAcctRecordMapper().listByCreateDate(taxCycleRebootYearRange, salarySobIds); + } + + + @Override + public void updateStatusByIds(Collection ids, SalaryAcctRecordStatusEnum status) { + // 查询薪资核算记录 + List salaryAcctRecordPOS = listByIds(ids); + if (CollectionUtils.isEmpty(salaryAcctRecordPOS)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98747, "薪资核算记录不存在或已被删除")); + } + // 更新薪资核算记录的状态 + Date now = new Date(); + salaryAcctRecordPOS.forEach(salaryAcctRecordPO -> { + salaryAcctRecordPO.setStatus(status.getValue()); + salaryAcctRecordPO.setUpdateTime(now); + getSalaryAcctRecordMapper().updateIgnoreNull(salaryAcctRecordPO); + }); + } + + @Override + public void deleteByIds(Collection ids) { + // 查询薪资核算记录 + List salaryAcctRecordPOS = listByIds(ids); + if (CollectionUtils.isEmpty(salaryAcctRecordPOS)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98747, "薪资核算记录不存在或已被删除")); + } + ids = SalaryEntityUtil.properties(salaryAcctRecordPOS, SalaryAcctRecordPO::getId); + // 只有未归档的薪资核算记录才允许删除 + boolean hasArchived = salaryAcctRecordPOS.stream().anyMatch(salaryAcctRecordPO -> !Objects.equals(salaryAcctRecordPO.getStatus(), SalaryAcctRecordStatusEnum.NOT_ARCHIVED.getValue())); + if (hasArchived) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98748, "只有未归档的薪资核算记录才允许删除")); + } + // 查询账套(记录日志用) + Set salarySobIds = SalaryEntityUtil.properties(salaryAcctRecordPOS, SalaryAcctRecordPO::getSalarySobId); + List salarySobPOS = getSalarySobService(user).listByIds(salarySobIds); + Map salarySobPOMap = SalaryEntityUtil.convert2Map(salarySobPOS, SalarySobPO::getId); + // 删除薪资核算记录 + getSalaryAcctRecordMapper().deleteByIds(ids); + //删除薪资核算人员 + getSalaryAcctEmployeeService(user).deleteBySalaryAcctRecordIds(ids); + // 删除薪资核算结果 + getSalaryAcctResultService(user).deleteBySalaryAcctRecordIds(ids); + //报表 + getSalaryAcctReportService(user).deleteBySalaryAcctRecordIds(ids); + // 删除校验异常 +// salaryCheckResultService.deleteBySalaryAcctRecordIds(ids); + // 删除校验异常明细 +// salaryCheckResultDetailService.deleteBySalaryAcctRecordIds(ids); + // 删除线下导入结果 + getSalaryComparisonResultService(user).deleteBySalaryAcctRecordIds(ids); + // 删除回算前的工资单 +// getSalarySendService(user).deleteBySalaryAcctRecordIds(ids); + + + // 变更核算次数 + List toUpdateAcctTimesRecordPOS = listBySalarySobIds(salarySobIds); + toUpdateAcctTimesRecordPOS = SalaryAcctRecordBO.updateAcctTimes(salaryAcctRecordPOS, toUpdateAcctTimesRecordPOS); + for (SalaryAcctRecordPO salaryAcctRecordPO : toUpdateAcctTimesRecordPOS) { + getSalaryAcctRecordMapper().updateIgnoreNull(salaryAcctRecordPO); + } + + // 记录日志 + salaryAcctRecordPOS.forEach(salaryAcctRecordPO -> { + SalarySobPO salarySobPO = salarySobPOMap.get(salaryAcctRecordPO.getSalarySobId()); + String targetName = salarySobPO.getName() + SalaryDateUtil.localDate2YearMonth(salaryAcctRecordPO.getSalaryMonth()); + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId("" + salaryAcctRecordPO.getId()); + loggerContext.setTargetName(targetName); + loggerContext.setOperateType(OperateTypeEnum.DELETE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "删除薪资核算")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "删除薪资核算") + ":" + targetName); + loggerContext.setNewValues(salaryAcctRecordPO); + SalaryElogConfig.salaryAcctRecordLoggerTemplate.write(loggerContext); + }); + } + + @Override + public void file(Long salaryAcctRecordId) { + // 查询薪资核算记录 + SalaryAcctRecordPO salaryAcctRecordPO = getById(salaryAcctRecordId); + if (Objects.isNull(salaryAcctRecordPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98747, "薪资核算记录不存在或已被删除")); + } + //todo 如果存在未忽略的校验异常,不允许归档 +// List salaryCheckResultPOS = salaryCheckResultService.listBySalaryAcctRecordIdAndIgnoreType(salaryAcctRecordId, NumberUtils.INTEGER_ZERO); +// if (CollectionUtils.isNotEmpty(salaryCheckResultPOS)) { +// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98784, "核算结果尚未通过校验规则,请确认是否需要忽略校验异常后再归档")); +// } + List salaryAcctResultPOS = getSalaryAcctResultService(user).listBySalaryAcctRecordIds(Collections.singleton(salaryAcctRecordId)); + if (CollectionUtils.isEmpty(salaryAcctResultPOS)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(99691, "尚未核算,请先核算后再归档")); + } + // 更新薪资核算记录的状态 + salaryAcctRecordPO.setStatus(SalaryAcctRecordStatusEnum.ARCHIVED.getValue()); + salaryAcctRecordPO.setUpdateTime(new Date()); + getSalaryAcctRecordMapper().updateIgnoreNull(salaryAcctRecordPO); + + // 生成工资单 + getSalarySendService(user).generateSalaryBill(salaryAcctRecordId); + + //删除报表缓存 + getSalaryStatisticsReportService(user).removeReportCache(); + + + //开始推送数据 + getPushService(user).createPushRecord(salaryAcctRecordId); + + + // 记录日志 + String targetName = getLogTargetNameById(salaryAcctRecordId); + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId("" + salaryAcctRecordPO.getId()); + loggerContext.setTargetName(targetName); + loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "薪资核算归档")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "薪资核算归档") + ": " + targetName); + loggerContext.setNewValues(salaryAcctRecordPO); + SalaryElogConfig.salaryAcctRecordLoggerTemplate.write(loggerContext); + } + + @Override + public void reCalculate(Long salaryAcctRecordId) { + // 查询薪资核算记录 + SalaryAcctRecordPO salaryAcctRecordPO = getById(salaryAcctRecordId); + if (Objects.isNull(salaryAcctRecordPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98747, "薪资核算记录不存在或已被删除")); + } + // 重新核算 + reCalcOrBackCalc(salaryAcctRecordPO, true); + + //开始推送数据 + getPushService(user).withdrawPushRecord(salaryAcctRecordId); + + +// // 查询税款所在年的该个税扣缴义务人所有薪资核算记录 +// // 获取账套所属个税扣缴义务人的核算记录 +// SalarySobPO salarySobPO = getSalarySobService(user).getById(salaryAcctRecordPO.getSalarySobId()); +// Long taxAgentId = salarySobPO.getTaxAgentId(); +// //查询扣缴义务人下的所有账套 +// List salarySobPOS = getSalarySobService(user).listByTaxAgentId(taxAgentId); +// Set salarySobIds = SalaryEntityUtil.properties(salarySobPOS, SalarySobPO::getId); +// List salaryAcctRecordPOS = listByTaxCycle(yearRange,salarySobIds); +// List selfSalaryAcctRecordPOS = filterByAuthority(salaryAcctRecordPOS); +// // 如果已经存在之后月份的薪资核算记录了,就不允许重新核算本月了 +// SalaryAcctRecordPO afterSalaryAcctRecordPO = selfSalaryAcctRecordPOS.stream() +// .filter(po -> po.getSalaryMonth().compareTo(salaryAcctRecordPO.getSalaryMonth()) > 0) +// .findAny() +// .orElse(null); +// if (Objects.nonNull(afterSalaryAcctRecordPO)) { +// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(105826, "已经存在{0}的薪资核算记录了,不能重新核算{1}的薪资了") +// .replace("{0}", SalaryDateUtil.localDate2YearMonth(afterSalaryAcctRecordPO.getSalaryMonth()).toString()) +// .replace("{1}", SalaryDateUtil.localDate2YearMonth(salaryAcctRecordPO.getSalaryMonth()).toString())); +// } +// //撤回工资单 +// getSalarySendService(user).revokeSalaryBill(salaryAcctRecordId); +// getTaxDeclarationService(user).delete(salaryAcctRecordPO); +// // 更新薪资核算记录的状态 +// salaryAcctRecordPO.setStatus(SalaryAcctRecordStatusEnum.NOT_ARCHIVED.getValue()); +// salaryAcctRecordPO.setUpdateTime(new Date()); +// getSalaryAcctRecordMapper().updateIgnoreNull(salaryAcctRecordPO); +// 记录日志 + String targetName = getLogTargetNameById(salaryAcctRecordPO.getId()); + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId("" + salaryAcctRecordPO.getId()); + loggerContext.setTargetName(targetName); + loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "重新核算")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "重新核算") + ": " + targetName); + loggerContext.setNewValues(salaryAcctRecordPO); + SalaryElogConfig.salaryAcctRecordLoggerTemplate.write(loggerContext); + } + + + private void reCalcOrBackCalc(SalaryAcctRecordPO salaryAcctRecordPO, boolean isReCalc) { + // 如果薪资核算记录还未归档,不允许重新核算 + if (Objects.equals(salaryAcctRecordPO.getStatus(), SalaryAcctRecordStatusEnum.NOT_ARCHIVED.getValue())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98819, "薪资核算结果还未归档,可直接核算")); + } + // 税款所在年的日期范围(第一天~最后一天) + LocalDateRange yearRange = SalaryDateUtil.localDate2YearRange(salaryAcctRecordPO.getSalaryMonth()); + if (Objects.isNull(yearRange)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(84026, "薪资所属月为空")); + } + // 查询税款所在年的该个税扣缴义务人所有薪资核算记录 + // 获取账套所属个税扣缴义务人的核算记录 + SalarySobPO salarySobPO = getSalarySobService(user).getById(salaryAcctRecordPO.getSalarySobId()); + List taxAgentIds = salarySobPO.getTaxAgentIds(); + //查询扣缴义务人下的所有账套 + List salarySobPOS = getSalarySobService(user).listByTaxAgentIds(taxAgentIds); + Set salarySobIds = SalaryEntityUtil.properties(salarySobPOS, SalarySobPO::getId); + List salaryAcctRecordPOS = listByTaxCycle(yearRange, salarySobIds); + List selfSalaryAcctRecordPOS = filterByAuthority(salaryAcctRecordPOS); + + // 获取个税申报功能状态 + TaxDeclarationFunctionEnum taxDeclarationFunctionEnum = getSalarySysConfService(user).getTaxDeclaration(); + if (!taxDeclarationFunctionEnum.getValue().equals(TaxDeclarationFunctionEnum.CLOSURE.getValue())) { + // 如果已经存在之后月份的薪资核算记录了,就不允许重新核算本月了 + SalaryAcctRecordPO afterSalaryAcctRecordPO = selfSalaryAcctRecordPOS.stream() + .filter(po -> po.getSalaryMonth().compareTo(salaryAcctRecordPO.getSalaryMonth()) > 0) + .findAny() + .orElse(null); + if (Objects.nonNull(afterSalaryAcctRecordPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(105826, "已经存在{0}的薪资核算记录了,不能重新核算{1}的薪资了") + .replace("{0}", SalaryDateUtil.localDate2YearMonth(afterSalaryAcctRecordPO.getSalaryMonth()).toString()) + .replace("{1}", SalaryDateUtil.localDate2YearMonth(salaryAcctRecordPO.getSalaryMonth()).toString())); + } + } + + if (!isReCalc) { + salaryAcctRecordPO.setBackCalcStatus(1); +// salaryAcctRecordPO.setSuperId(salaryAcctRecordPO.getId()); +// salaryAcctRecordPO.setRootId(Objects.equals(salaryAcctRecordPO.getRootId(), 0L) ? salaryAcctRecordPO.getId() : salaryAcctRecordPO.getRootId()); + } + + // 保存回算前的薪资核算结果 + if (!isReCalc) { + getSalaryAcctResultService(user).reCalc(salaryAcctRecordPO.getId()); + } + // 撤回工资单 + getSalarySendService(user).revokeSalaryBill(salaryAcctRecordPO); + + // 重新核算或者回算时,若本次薪资核算记录已经申报了,则本次薪资核算记录下的所有个税扣缴义务人在相同税款所属期内的所有薪资核算记录的状态都应该从已申报变更为已归档 + // 过滤获取所在税款所属期内该个税扣缴义务人所有的薪资核算记录ID + List needUpdateSalaryAcctRecordIds = selfSalaryAcctRecordPOS.stream().filter(po -> po.getTaxCycle().equals(salaryAcctRecordPO.getTaxCycle())) + .map(SalaryAcctRecordPO::getId).collect(Collectors.toList()); + if (Objects.equals(salaryAcctRecordPO.getStatus(), SalaryAcctRecordStatusEnum.DECLARED.getValue())) { + if (needUpdateSalaryAcctRecordIds.size() > 0) { + // 更新薪资核算记录的状态 + updateStatusByIds(needUpdateSalaryAcctRecordIds, SalaryAcctRecordStatusEnum.ARCHIVED); + } + // 删除个税申报表及往期累计情况 + getTaxDeclarationService(user).delete(salaryAcctRecordPO); + } + + // 更新薪资核算记录的状态 + salaryAcctRecordPO.setStatus(SalaryAcctRecordStatusEnum.NOT_ARCHIVED.getValue()); + salaryAcctRecordPO.setUpdateTime(new Date()); + getSalaryAcctRecordMapper().updateIgnoreNull(salaryAcctRecordPO); + + //删除报表缓存 + getSalaryStatisticsReportService(user).removeReportCache(); + } + + + @Override + public Integer hasConsolidatedTax(Long id) { + // 查询合并计税的其他薪资核算记录 + List otherSalaryAcctRecordPOS = listById4OtherConsolidatedTax(id); + if (CollectionUtils.isEmpty(otherSalaryAcctRecordPOS)) { + return NumberUtils.INTEGER_ZERO; + } + // 查询本次核算的薪资核算人员 + List salaryAcctEmployeePOS = getSalaryAcctEmployeeService(user).listBySalaryAcctRecordId(id); + // 查询其他核算记录中的薪资核算人员 + Set otherSalaryAcctRecordIds = SalaryEntityUtil.properties(otherSalaryAcctRecordPOS, SalaryAcctRecordPO::getId); + List otherSalaryAcctEmployeePOS = getSalaryAcctEmployeeService(user).listBySalaryAcctRecordIds(otherSalaryAcctRecordIds); + // 有其他核算记录,需要进一步判断本次核算的人员中是否存在合并计税 + Set keySet = SalaryEntityUtil.properties(otherSalaryAcctEmployeePOS, salaryAcctEmployeePO -> salaryAcctEmployeePO.getEmployeeId() + "-" + salaryAcctEmployeePO.getTaxAgentId()); + boolean hasConsolidatedTax = salaryAcctEmployeePOS.stream().anyMatch(salaryAcctEmployeePO -> keySet.contains(salaryAcctEmployeePO.getEmployeeId() + "-" + salaryAcctEmployeePO.getTaxAgentId())); + if (hasConsolidatedTax) { + return NumberUtils.INTEGER_ONE; + } + return NumberUtils.INTEGER_ZERO; + } + + @Override + public String getLogTargetNameById(Long id) { + // 查询薪资核算记录 + SalaryAcctRecordPO salaryAcctRecordPO = getById(id); + if (Objects.isNull(salaryAcctRecordPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98747, "薪资核算记录不存在或已被删除")); + } + // 查询账套 + SalarySobPO salarySobPO = getSalarySobService(user).getById(salaryAcctRecordPO.getSalarySobId()); + if (Objects.isNull(salarySobPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98769, "薪资账套不存在或已被删除")); + } + return salarySobPO.getName() + SalaryDateUtil.localDate2YearMonth(salaryAcctRecordPO.getSalaryMonth()); + } + + @Override + public List listByStatus(SalaryAcctRecordStatusEnum status) { + return getSalaryAcctRecordMapper().listSome(SalaryAcctRecordPO.builder().status(status.getValue()).build()); + } + + @Override + public List listByStatusAndEmployeeId(SalaryAcctRecordStatusEnum status, Long employeeId) { + return getSalaryAcctRecordMapper().listSome(SalaryAcctRecordPO.builder().status(status.getValue()).creator(employeeId).build()); + } + + @Override + public void updateLockSalaryItemIds(SalaryAcctRecordPO salaryAcctRecord) { + getSalaryAcctRecordMapper().updateLockSalaryItemIds(salaryAcctRecord); + } + + @Override + public void backCalculate(Long salaryAcctRecordId) { + // 查询薪资核算记录 + SalaryAcctRecordPO salaryAcctRecordPO = getById(salaryAcctRecordId); + if (Objects.isNull(salaryAcctRecordPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98747, "薪资核算记录不存在或已被删除")); + } + // 获取该账套该月核算的所有记录 + List salaryAcctRecordPOS = getSalaryAcctRecordMapper().listSome(SalaryAcctRecordPO.builder().salaryMonth(salaryAcctRecordPO.getSalaryMonth()).salarySobId(salaryAcctRecordPO.getSalarySobId()).deleteType(0).build()); + // 只有该账套在此月的最后一次核算才能进行回算 + if (!salaryAcctRecordPO.getAcctTimes().equals(salaryAcctRecordPOS.size())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "只有核算次数为最后一次时,才能进行回算")); + } + // 只有正常核算全部发送完才能进行回算 + SalarySendPO build = SalarySendPO.builder().salaryAccountingId(salaryAcctRecordId).deleteType(0).build(); + List salarySends = getSalarySendMapper().listSome(build); + salarySends.stream().forEach(salarySend -> { + if (salarySend.getSendNum() < salarySend.getSendTotal()) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(139702, "正常核算工资单尚未全部发送完成,不能进行回算")); + } + }); + + // 回算 + reCalcOrBackCalc(salaryAcctRecordPO, false); + } + + @Override + public List getBackCalcRecordByIds(Set salaryAcctIds) { + if (CollectionUtils.isEmpty(salaryAcctIds)) { + return Collections.emptyList(); + } + return getSalaryAcctRecordMapper().getBackCalcRecordByIds(salaryAcctIds); + } + + + /** + * 开启分权后需要判断是否能查看对应的薪资核算记录 + * + * @param salaryAcctRecords + * @return + */ + private List filterByAuthority(List salaryAcctRecords) { + if (CollectionUtils.isEmpty(salaryAcctRecords)) { + return salaryAcctRecords; + } + Boolean openDevolution = getTaxAgentService(user).isOpenDevolution(); + //开启分权 + if (openDevolution) { + List salarySobPOS = getSalarySobService(user).listByAdmin(); + Set salarySobIds = SalaryEntityUtil.properties(salarySobPOS, SalarySobPO::getId); + return salaryAcctRecords.stream().filter(record -> salarySobIds.contains(record.getSalarySobId())).collect(Collectors.toList()); + } + + return salaryAcctRecords; + } + + @Override + public List listBySalaryAcctEmpId(Long salaryAcctEmpId) { + return getSalaryAcctResultService(user).listBySalaryAcctEmployeeId(salaryAcctEmpId); + } + + @Override + public List listSome(SalaryAcctRecordPO po) { + return getSalaryAcctRecordMapper().listSome(po); + } + + @Override + public void updateDate(Long id, Date updateTime) { + getSalaryAcctRecordMapper().updateDate(id, updateTime); + } +} diff --git a/src/com/engine/salary/service/impl/SalaryAcctReportServiceImpl.java b/src/com/engine/salary/service/impl/SalaryAcctReportServiceImpl.java new file mode 100644 index 000000000..8371241fb --- /dev/null +++ b/src/com/engine/salary/service/impl/SalaryAcctReportServiceImpl.java @@ -0,0 +1,93 @@ +package com.engine.salary.service.impl; + +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.encrypt.AESEncryptUtil; +import com.engine.salary.encrypt.EncryptUtil; +import com.engine.salary.entity.report.po.SalaryAcctResultReportPO; +import com.engine.salary.mapper.report.SalaryAcctResultReportMapper; +import com.engine.salary.service.SalaryAcctReportService; +import com.engine.salary.sys.entity.po.SalarySysConfPO; +import com.engine.salary.sys.enums.OpenEnum; +import com.engine.salary.sys.service.SalarySysConfService; +import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl; +import com.engine.salary.util.db.MapperProxyFactory; +import com.google.common.collect.Lists; +import org.apache.commons.collections4.CollectionUtils; +import weaver.hrm.User; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.stream.Collectors; + +import static com.engine.salary.sys.constant.SalarySysConstant.DISPLAY_EMP_INFO_REPORT; + +/** + * 薪资报表 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SalaryAcctReportServiceImpl extends Service implements SalaryAcctReportService { + private EncryptUtil encryptUtil = new EncryptUtil(); + private SalaryAcctResultReportMapper getSalaryAcctResultReportMapper() { + return MapperProxyFactory.getProxy(SalaryAcctResultReportMapper.class); + } + + + private SalarySysConfService getSalarySysConfService(User user) { + return ServiceUtil.getService(SalarySysConfServiceImpl.class, user); + } + + /** + * 保存核算报表数据 + * + * @param pos + */ + @Override + public void batchSave(Collection pos) { + if (CollectionUtils.isNotEmpty(pos)) { + SalarySysConfPO disPlay = getSalarySysConfService(user).getOneByCode(DISPLAY_EMP_INFO_REPORT); + //默认不显示,关闭状态 + if (disPlay == null || OpenEnum.OFF.getValue().equals(disPlay.getConfValue())) { + pos = encryptUtil.encryptList(new ArrayList<>(pos), SalaryAcctResultReportPO.class); + } +// List> partition = Lists.partition((List) pos, 100); +// partition.forEach(getSalaryAcctResultReportMapper()::batchInsert); + + pos.forEach(getSalaryAcctResultReportMapper()::insertIgnoreNull); + } + } + + @Override + public void deleteBySalaryAcctRecordIds(Collection salaryAcctRecordIds) { + if (CollectionUtils.isNotEmpty(salaryAcctRecordIds)) { + getSalaryAcctResultReportMapper().deleteBySalaryAcctRecordIds(salaryAcctRecordIds); + } + } + + @Override + public void deleteBySalaryAcctRecordId(Long salaryAcctRecordId) { + getSalaryAcctResultReportMapper().deleteBySalaryAcctRecordId(salaryAcctRecordId); + } + + @Override + public void deleteBySalaryAcctEmpIds(Collection salaryAcctEmpIds) { + if (CollectionUtils.isNotEmpty(salaryAcctEmpIds)) { + List collect = salaryAcctEmpIds.stream().map(e -> AESEncryptUtil.encrypt(e.toString())).collect(Collectors.toList()); + getSalaryAcctResultReportMapper().deleteBySalaryAcctEmpIds(collect); + } + } + + @Override + public void deleteByAcctEmployeeIdsAndSalaryItemIds(List salaryAcctEmployeeIds, Collection salaryItemIds) { + if (CollectionUtils.isNotEmpty(salaryAcctEmployeeIds) && CollectionUtils.isNotEmpty(salaryItemIds)) { + List salaryAcctEmployeeIdsStr = salaryAcctEmployeeIds.stream().map(e -> AESEncryptUtil.encrypt(e.toString())).collect(Collectors.toList()); + List> partition = Lists.partition(salaryAcctEmployeeIdsStr, 300); + partition.forEach(part -> getSalaryAcctResultReportMapper().deleteByAcctEmpIdsAndSalaryItemIds(part, salaryItemIds)); + } + } +} diff --git a/src/com/engine/salary/service/impl/SalaryAcctResultLogServiceImpl.java b/src/com/engine/salary/service/impl/SalaryAcctResultLogServiceImpl.java new file mode 100644 index 000000000..378920dbd --- /dev/null +++ b/src/com/engine/salary/service/impl/SalaryAcctResultLogServiceImpl.java @@ -0,0 +1,70 @@ +package com.engine.salary.service.impl; + +import com.engine.core.impl.Service; +import com.engine.salary.entity.salaryacct.po.SalaryAcctResultLogPO; +import com.engine.salary.mapper.salaryacct.SalaryAcctResultLogMapper; +import com.engine.salary.service.SalaryAcctResultLogService; +import com.engine.salary.util.db.MapperProxyFactory; +import com.google.common.collect.Lists; + +import java.util.Collection; +import java.util.Date; +import java.util.List; + +/** + * @author Harryxzy + * @date 2023/05/12 15:29 + * @description + */ +public class SalaryAcctResultLogServiceImpl extends Service implements SalaryAcctResultLogService { + + private SalaryAcctResultLogMapper getSalaryAcctResultLogMapper() { + return MapperProxyFactory.getProxy(SalaryAcctResultLogMapper.class); + } + + @Override + public List listAll() { + return getSalaryAcctResultLogMapper().listAll(); + } + + @Override + public SalaryAcctResultLogPO getById(Long id) { + return getSalaryAcctResultLogMapper().getById(id); + } + + @Override + public int insertIgnoreNull(SalaryAcctResultLogPO salaryAcctResultLog) { + return getSalaryAcctResultLogMapper().insertIgnoreNull(salaryAcctResultLog); + } + + + @Override + public int update(SalaryAcctResultLogPO salaryAcctResultLog) { + return getSalaryAcctResultLogMapper().update(salaryAcctResultLog); + } + + @Override + public int updateIgnoreNull(SalaryAcctResultLogPO salaryAcctResultLog) { + return getSalaryAcctResultLogMapper().updateIgnoreNull(salaryAcctResultLog); + } + + @Override + public int delete(SalaryAcctResultLogPO salaryAcctResultLog) { + return getSalaryAcctResultLogMapper().delete(salaryAcctResultLog); + } + + @Override + public void batchInsert(List salaryAcctResultLogList) { + List> partition = Lists.partition(salaryAcctResultLogList, 50); + partition.forEach(getSalaryAcctResultLogMapper()::batchInsert); + } + + @Override + public void deleteBySalaryAcctEmpIdExceptItemIds(List salaryAcctEmployeeIds, Collection lockSalaryItemIds) { + // 分片 + List> partition = Lists.partition(salaryAcctEmployeeIds, 50); + partition.forEach(part -> { + getSalaryAcctResultLogMapper().deleteBySalaryAcctEmpIdExceptItemIds(part,lockSalaryItemIds, new Date()); + }); + } +} diff --git a/src/com/engine/salary/service/impl/SalaryAcctResultServiceImpl.java b/src/com/engine/salary/service/impl/SalaryAcctResultServiceImpl.java new file mode 100644 index 000000000..0c093a6d1 --- /dev/null +++ b/src/com/engine/salary/service/impl/SalaryAcctResultServiceImpl.java @@ -0,0 +1,1286 @@ +package com.engine.salary.service.impl; + +import cn.hutool.core.collection.CollUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.hrmelog.entity.dto.LoggerContext; +import com.engine.salary.cache.SalaryCacheKey; +import com.engine.salary.common.LocalDateRange; +import com.engine.salary.config.SalaryElogConfig; +import com.engine.salary.constant.SalaryDefaultTenantConstant; +import com.engine.salary.encrypt.EncryptUtil; +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.datacollection.dto.AttendQuoteFieldListDTO; +import com.engine.salary.entity.datacollection.po.VariableItemPO; +import com.engine.salary.entity.hrm.DeptInfo; +import com.engine.salary.entity.hrm.JobCallInfo; +import com.engine.salary.entity.hrm.PositionInfo; +import com.engine.salary.entity.hrm.SubCompanyInfo; +import com.engine.salary.entity.progress.ProgressDTO; +import com.engine.salary.entity.report.po.SalaryAcctResultReportPO; +import com.engine.salary.entity.salaryacct.bo.*; +import com.engine.salary.entity.salaryacct.dto.ConsolidatedTaxDetailDTO; +import com.engine.salary.entity.salaryacct.dto.SalaryAcctResultDetailDTO; +import com.engine.salary.entity.salaryacct.dto.SalaryAcctResultListColumnDTO; +import com.engine.salary.entity.salaryacct.param.*; +import com.engine.salary.entity.salaryacct.po.*; +import com.engine.salary.entity.salaryformula.ExpressFormula; +import com.engine.salary.entity.salaryitem.po.SalaryItemPO; +import com.engine.salary.entity.salarysob.dto.*; +import com.engine.salary.entity.salarysob.po.*; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import com.engine.salary.enums.OperateTypeEnum; +import com.engine.salary.enums.UserStatusEnum; +import com.engine.salary.enums.common.FilterEnum; +import com.engine.salary.enums.salaryaccounting.LockStatusEnum; +import com.engine.salary.enums.salaryaccounting.SalaryAcctRecordStatusEnum; +import com.engine.salary.enums.salaryaccounting.SalaryAcctResultDataSourceEnum; +import com.engine.salary.enums.salaryitem.SalaryDataTypeEnum; +import com.engine.salary.enums.salarysob.IncomeCategoryEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.mapper.salaryacct.SalaryAcctResultMapper; +import com.engine.salary.report.service.SalaryStatisticsReportService; +import com.engine.salary.report.service.impl.SalaryStatisticsReportServiceImpl; +import com.engine.salary.service.*; +import com.engine.salary.sys.constant.SalarySysConstant; +import com.engine.salary.sys.entity.po.SalarySysConfPO; +import com.engine.salary.sys.enums.TaxDeclarationFunctionEnum; +import com.engine.salary.sys.service.SalarySysConfService; +import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl; +import com.engine.salary.util.SalaryDateUtil; +import com.engine.salary.util.SalaryEntityUtil; +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.page.SalaryPageUtil; +import com.engine.salary.util.valid.ValidUtil; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.weaver.util.threadPool.ThreadPoolUtil; +import com.weaver.util.threadPool.constant.ModulePoolEnum; +import com.weaver.util.threadPool.entity.LocalRunnable; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.collections4.MapUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.math.NumberUtils; +import org.springframework.jdbc.datasource.DataSourceTransactionManager; +import org.springframework.util.StopWatch; +import weaver.general.BaseBean; +import weaver.hrm.User; + +import java.math.BigDecimal; +import java.util.*; +import java.util.concurrent.BlockingDeque; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.LinkedBlockingDeque; +import java.util.stream.Collectors; + +import static com.engine.salary.sys.constant.SalarySysConstant.SALARY_ACCT_SYNC_TYPE; + +/** + * 薪资核算结果 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Slf4j +public class SalaryAcctResultServiceImpl extends Service implements SalaryAcctResultService { + private EncryptUtil encryptUtil = new EncryptUtil(); + + private SalaryAcctResultMapper getSalaryAcctResultMapper() { + return MapperProxyFactory.getProxy(SalaryAcctResultMapper.class); + } + + private SalaryAcctEmployeeService getSalaryAcctEmployeeService(User user) { + return ServiceUtil.getService(SalaryAcctEmployeeServiceImpl.class, user); + } + + private SalarySobItemService getSalarySobItemService(User user) { + return ServiceUtil.getService(SalarySobItemServiceImpl.class, user); + } + + private SalaryItemService getSalaryItemService(User user) { + return ServiceUtil.getService(SalaryItemServiceImpl.class, user); + } + + private SalarySobEmpFieldService getSalarySobEmpFieldService(User user) { + return ServiceUtil.getService(SalarySobEmpFieldServiceImpl.class, user); + } + + private SalarySobService getSalarySobService(User user) { + return ServiceUtil.getService(SalarySobServiceImpl.class, user); + } + + private SalaryAcctRecordService getSalaryAcctRecordService(User user) { + return ServiceUtil.getService(SalaryAcctRecordServiceImpl.class, user); + } + + private TaxAgentService getTaxAgentService(User user) { + return ServiceUtil.getService(TaxAgentServiceImpl.class, user); + } + + private SalaryEmployeeService getSalaryEmployeeService(User user) { + return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user); + } + + private SalaryFormulaService getSalaryFormulaService(User user) { + return ServiceUtil.getService(SalaryFormulaServiceImpl.class, user); + } + + private SalarySobAdjustRuleService getSalarySobAdjustRuleService(User user) { + return ServiceUtil.getService(SalarySobAdjustRuleServiceImpl.class, user); + } + + private SalarySobItemHideService getSalarySobItemHideService(User user) { + return (SalarySobItemHideService) ServiceUtil.getService(SalarySobItemHideServiceImpl.class, user); + } + + private SalaryAcctCalculateService getSalaryAcctCalculateService(User user) { + return ServiceUtil.getService(SalaryAcctCalculateServiceImpl.class, user); + } + + private ProgressService getSalaryAcctProgressService(User user) { + return ServiceUtil.getService(ProgressServiceImpl.class, user); + } + + private DataSourceTransactionManager dataSourceTransactionManager; + + private SalaryAcctResultTempService getSalaryAcctResultTempService(User user) { + return ServiceUtil.getService(SalaryAcctResultTempServiceImpl.class, user); + } + + private SIAccountService getSIAccountService(User user) { + return ServiceUtil.getService(SIAccountServiceImpl.class, user); + } + + private AttendQuoteFieldService getAttendQuoteFieldService(User user) { + return ServiceUtil.getService(AttendQuoteFieldServiceImpl.class, user); + } + + private SalaryAcctReportService getSalaryAcctReportService(User user) { + return ServiceUtil.getService(SalaryAcctReportServiceImpl.class, user); + } + + private SalarySobItemGroupService getSalarySobItemGroupService(User user) { + return (SalarySobItemGroupService) ServiceUtil.getService(SalarySobItemGroupServiceImpl.class, user); + } + + private SalarySobBackItemService getSalarySobBackItemService(User user) { + return ServiceUtil.getService(SalarySobBackItemServiceImpl.class, user); + } + + private SalaryAcctResultService getSalaryAcctResultService(User user) { + return (SalaryAcctResultService) ServiceUtil.getService(SalaryAcctResultServiceImpl.class, user); + } + + private SalaryAcctResultLogService getSalaryAcctResultLogService(User user) { + return ServiceUtil.getService(SalaryAcctResultLogServiceImpl.class, user); + } + + private SalarySysConfService getSalarySysConfService(User user) { + return ServiceUtil.getService(SalarySysConfServiceImpl.class, user); + } + + private SalaryStatisticsReportService getSalaryStatisticsReportService(User user) { + return ServiceUtil.getService(SalaryStatisticsReportServiceImpl.class, user); + } + + private TaxAgentAdminService getTaxAgentAdminService(User user) { + return ServiceUtil.getService(TaxAgentAdminServiceImpl.class, user); + } + + private VariableItemService getVariableItemService(User user) { + return ServiceUtil.getService(VariableItemServiceImpl.class, user); + } + + private SalaryApprovalRuleService getSalaryApprovalRuleService(User user) { + return ServiceUtil.getService(SalaryApprovalRuleServiceImpl.class, user); + } + + + private SalaryCheckResultService salaryCheckResultService; + + private SalaryAcctSobConfigService getSalaryAcctSobConfigService(User user) { + return ServiceUtil.getService(SalaryAcctSobConfigServiceImpl.class, user); + } + + @Override + public List listBySalaryAcctRecordIds(Collection salaryAcctRecordIds) { + if (CollectionUtils.isEmpty(salaryAcctRecordIds)) { + return Collections.emptyList(); + } + List salaryAcctResultPOS = getSalaryAcctResultMapper().listSome(SalaryAcctResultPO.builder().salaryAcctRecordIds(salaryAcctRecordIds).build()); + encryptUtil.decryptList(salaryAcctResultPOS, SalaryAcctResultPO.class); + return salaryAcctResultPOS; + } + + @Override + public List listBySalaryAcctEmployeeId(Long salaryAcctEmployeeId) { + List salaryAcctResultPOS = getSalaryAcctResultMapper().listSome(SalaryAcctResultPO.builder().salaryAcctEmpId(salaryAcctEmployeeId).build()); + encryptUtil.decryptList(salaryAcctResultPOS, SalaryAcctResultPO.class); + // 解密 + return salaryAcctResultPOS; + } + + @Override + public List listBySalaryAcctEmployeeIds(Collection salaryAcctEmployeeIds) { + if (CollectionUtils.isEmpty(salaryAcctEmployeeIds)) { + return Collections.emptyList(); + } + List> partition = Lists.partition((List) salaryAcctEmployeeIds, 500); + List salaryAcctResultPOS = new ArrayList<>(); + partition.forEach(empIds -> { + List resultPOS = getSalaryAcctResultMapper().listSome(SalaryAcctResultPO.builder().salaryAcctEmpIds(empIds).build()); + encryptUtil.decryptList(resultPOS, SalaryAcctResultPO.class); + salaryAcctResultPOS.addAll(resultPOS); + }); + // 解密 + return salaryAcctResultPOS; + } + + @Override + public List listBySalaryAcctRecordIdsAndEmployeeIds(Collection salaryAcctRecordIds, Collection employeeIds) { + if (CollectionUtils.isEmpty(salaryAcctRecordIds) || CollectionUtils.isEmpty(employeeIds)) { + return Collections.emptyList(); + } + List> partition = Lists.partition((List) employeeIds, 500); + List salaryAcctResultPOS = new ArrayList<>(); + partition.forEach(empIds -> { + salaryAcctResultPOS.addAll(getSalaryAcctResultMapper().listSome(SalaryAcctResultPO.builder().salaryAcctRecordIds(salaryAcctRecordIds).employeeIds(empIds).build())); + }); + encryptUtil.decryptList(salaryAcctResultPOS, SalaryAcctResultPO.class); + return salaryAcctResultPOS; + } + + @Override + public SalaryAcctResultDetailDTO getBySalaryAcctEmployeeId(Long salaryAcctEmployeeId) { + // 查询薪资核算人员 + SalaryAcctEmployeePO salaryAcctEmployeePO = getSalaryAcctEmployeeService(user).getById(salaryAcctEmployeeId); + if (Objects.isNull(salaryAcctEmployeePO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98831, "薪资核算人员不存在或已被删除")); + } + // 查询是否是回算 + SalaryAcctRecordPO salaryAcctRecordPO = getSalaryAcctRecordService(user).getById(salaryAcctEmployeePO.getSalaryAcctRecordId()); + boolean isBackCal = Objects.equals(salaryAcctRecordPO.getBackCalcStatus(), 1); + + SalaryAcctConfig salaryAcctConfig = getSalaryAcctSobConfigService(user).getSalaryAcctConfig(salaryAcctRecordPO.getId()); + // 查询薪资账套的薪资项目分类 + List salarySobItemGroupPOS = salaryAcctConfig.getSalarySobItemGroups(); + // 过滤关闭显示的薪资项目分类 + salarySobItemGroupPOS = salarySobItemGroupPOS.stream().filter(group -> group.getItemHide() == null || group.getItemHide().equals(0L)).collect(Collectors.toList()); + // 获取薪资项目分类ID + List salarySobItemGroupIds = salarySobItemGroupPOS.stream().map(SalarySobItemGroupPO::getId).collect(Collectors.toList()); + //加上未分类 + salarySobItemGroupIds.add(0L); + + // 查询薪资账套的薪资项目副本(已经过滤关闭分类显示按钮的薪资项目) + List salarySobItemPOS = salaryAcctConfig.getSalarySobItems(); + // 过滤薪资项目 + salarySobItemPOS = salarySobItemPOS.stream().filter(item -> item.getItemHide() == null || item.getItemHide().equals(0L)).collect(Collectors.toList()); + + // 查询已发补发薪资项目 + List salarySobBackItemPOList = Collections.emptyList(); + List salaryBackItemPOS = Collections.emptyList(); + // key:账套中回算薪资项目的薪资项目id value:账套中回算薪资项目所对应的公式内容 + Map salaryBackItemFormula = new HashMap<>(); + if (isBackCal) { + salarySobBackItemPOList = salaryAcctConfig.getSalarySobBackItems(); + Set salarySobBackItemIds = SalaryEntityUtil.properties(salarySobBackItemPOList, SalarySobBackItemPO::getSalaryItemId); + salaryBackItemPOS = getSalaryItemService(user).listByIds(salarySobBackItemIds); + // 查询薪资账套中已发补发的公式内容 + List expressFormulas = getSalaryFormulaService(user).listExpressFormula(SalaryEntityUtil.properties(salarySobBackItemPOList, SalarySobBackItemPO::getFormulaId)); + Map expressFormulaMap = SalaryEntityUtil.convert2Map(expressFormulas, ExpressFormula::getId, ExpressFormula::getFormula); + for (SalarySobBackItemPO salarySobBackItemPO : salarySobBackItemPOList) { + String exp = Objects.equals(expressFormulaMap.get(salarySobBackItemPO.getFormulaId()), 0) ? "输入" : expressFormulaMap.get(salarySobBackItemPO.getFormulaId()); + salaryBackItemFormula.put(salarySobBackItemPO.getSalaryItemId(), exp); + } + } + + // 查询薪资项目 + Set salaryItemIds = SalaryEntityUtil.properties(salarySobItemPOS, SalarySobItemPO::getSalaryItemId); + List salaryItemPOS = getSalaryItemService(user).listByIds(salaryItemIds); + // 查询薪资核算所用薪资账套的人员信息字段 + List salarySobEmpFieldPOS = salaryAcctConfig.getSalarySobEmpFields(); + // 查询人员信息 + DataCollectionEmployee simpleEmployee = getSalaryEmployeeService(user).getEmployeeById(salaryAcctEmployeePO.getEmployeeId()); + // 查询薪资核算结果 + List salaryAcctResultPOS = listBySalaryAcctEmployeeId(salaryAcctEmployeeId); + // 查询个税扣缴义务人 + TaxAgentPO taxAgent = getTaxAgentService(user).getById(salaryAcctEmployeePO.getTaxAgentId()); + // 查询公式 + Map formulaContentMap = getSalaryAcctResultService(user).getColumnBySalaryAcctRecordId(salaryAcctEmployeePO.getSalaryAcctRecordId()); + List lockItems = salaryAcctRecordPO.getLockSalaryItemIds() == null ? Collections.emptyList() : salaryAcctRecordPO.getLockSalaryItemIds(); + + // 转换成薪资核算结果详情dto + return SalaryAcctResultBO.convert2DetailDTO(simpleEmployee, taxAgent, salaryAcctEmployeePO, salarySobEmpFieldPOS, salarySobItemGroupPOS, salarySobItemPOS, salaryItemPOS, salaryAcctResultPOS, salarySobBackItemPOList, salaryBackItemPOS, salaryBackItemFormula, formulaContentMap, lockItems); + } + + @Override + public PageInfo> listPageByParam(SalaryAcctResultQueryParam queryParam) { + PageInfo page = null; + //其他条件 + List otherConditions = queryParam.getOtherConditions(); + if (CollectionUtils.isNotEmpty(otherConditions)) { + List items = SalaryEntityUtil.properties(otherConditions, SalaryAcctResultQueryParam.OtherCondition::getItemId, Collectors.toList()); + List list = listBySalaryAcctRecordIdsAndSalaryItemIds(Collections.singletonList(queryParam.getSalaryAcctRecordId()), items); + for (int i = 0; i < otherConditions.size(); i++) { + SalaryAcctResultQueryParam.OtherCondition otherCondition = otherConditions.get(i); + Long itemId = otherCondition.getItemId(); + FilterEnum filter = otherCondition.getFilter(); + List params = otherCondition.getParams(); + list = list.stream().filter(a -> Objects.equals(a.getSalaryItemId(), itemId)).filter(a -> filter.filter(params).test(a.getResultValue())).collect(Collectors.toList()); + } + List salaryAcctEmpId = SalaryEntityUtil.properties(list, SalaryAcctResultPO::getSalaryAcctEmpId, Collectors.toList()); + + if (CollectionUtils.isEmpty(salaryAcctEmpId)) { + //条件不满足直接返回空列表 + page = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), new ArrayList<>(), SalaryAcctEmployeePO.class); + } else { + queryParam.setIds(salaryAcctEmpId); + // 查询薪资核算人员(分页) + page = getSalaryAcctEmployeeService(user).listPageByResultQueryParam(queryParam); + } + } else { + // 查询薪资核算人员(分页) + page = getSalaryAcctEmployeeService(user).listPageByResultQueryParam(queryParam); + } + + + // 查询薪资核算结果 + List> data = listBySalaryAcctEmployees(page.getList(), queryParam); + // 薪资核算结果的分页结果 + PageInfo> resultPage = new PageInfo<>(); + resultPage.setList(data); + resultPage.setTotal(page.getTotal()); + resultPage.setPageNum(page.getPageNum()); + resultPage.setPageSize(page.getPageSize()); + return resultPage; + } + + @Override + public Map sumRow(SalaryAcctResultQueryParam queryParam) { + + //其他条件 + List otherConditions = queryParam.getOtherConditions(); + if (CollectionUtils.isNotEmpty(otherConditions)) { + List items = SalaryEntityUtil.properties(otherConditions, SalaryAcctResultQueryParam.OtherCondition::getItemId, Collectors.toList()); + List list = listBySalaryAcctRecordIdsAndSalaryItemIds(Collections.singletonList(queryParam.getSalaryAcctRecordId()), items); + for (int i = 0; i < otherConditions.size(); i++) { + SalaryAcctResultQueryParam.OtherCondition otherCondition = otherConditions.get(i); + Long itemId = otherCondition.getItemId(); + FilterEnum filter = otherCondition.getFilter(); + List params = otherCondition.getParams(); + list = list.stream().filter(a -> Objects.equals(a.getSalaryItemId(), itemId)).filter(a -> filter.filter(params).test(a.getResultValue())).collect(Collectors.toList()); + } + List salaryAcctEmpId = SalaryEntityUtil.properties(list, SalaryAcctResultPO::getSalaryAcctEmpId, Collectors.toList()); + if (CollectionUtils.isEmpty(salaryAcctEmpId)) { + //条件不满足直接返回空列表 + return new HashMap<>(); + } else { + queryParam.setIds(salaryAcctEmpId); + } + } + + + // 查询薪资核算人员 + List salaryAcctEmployeePOS = getSalaryAcctEmployeeService(user).listByResultQueryParam(queryParam); + + if (CollectionUtils.isEmpty(salaryAcctEmployeePOS)) { + return null; + } + // 查询薪资核算记录 + SalaryAcctRecordPO salaryAcctRecordPO = getSalaryAcctRecordService(user).getById(queryParam.getSalaryAcctRecordId()); + if (Objects.isNull(salaryAcctRecordPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98747, "薪资核算记录不存在或已被删除")); + } + // 查询薪资核算所用薪资账套的薪资项目 + List salarySobItemPOS = getSalarySobItemService(user).listBySalarySobId(salaryAcctRecordPO.getSalarySobId()); + Map salaryItemIdKeySalarySobItemPOMap = SalaryEntityUtil.convert2Map(salarySobItemPOS, SalarySobItemPO::getSalaryItemId); + Set salaryItemIds = SalaryEntityUtil.properties(salarySobItemPOS, SalarySobItemPO::getSalaryItemId); + if (Objects.equals(salaryAcctRecordPO.getBackCalcStatus(), NumberUtils.INTEGER_ONE)) { + // 是回算,获取回算项 + List salarySobBackItemPOS = getSalarySobBackItemService(user).listBySalarySobId(salaryAcctRecordPO.getSalarySobId()); + salaryItemIds.addAll(salarySobBackItemPOS.stream().map(SalarySobBackItemPO::getSalaryItemId).collect(Collectors.toList())); + } + List salaryItemPOS = getSalaryItemService(user).listByIds(salaryItemIds); + + // 查询薪资核算结果 + List salaryAcctEmployeeIds = SalaryEntityUtil.properties(salaryAcctEmployeePOS, SalaryAcctEmployeePO::getId, Collectors.toList()); + List salaryAcctResultPOS = listBySalaryAcctEmployeeIds(salaryAcctEmployeeIds); + + Map map = new HashMap<>(); + Map> acctResultMap = SalaryEntityUtil.group2Map(salaryAcctResultPOS, SalaryAcctResultPO::getSalaryItemId); + salaryItemPOS.stream().filter(item -> SalaryDataTypeEnum.NUMBER.getValue().equals(item.getDataType())).forEach(item -> { + BigDecimal sum = Optional.ofNullable(acctResultMap.get(item.getId())).orElse(new ArrayList<>()).stream().map(SalaryAcctResultPO::getResultValue).filter(NumberUtils::isCreatable).map(BigDecimal::new).reduce(BigDecimal.ZERO, BigDecimal::add); + map.put(item.getId().toString(), SalaryAcctFormulaBO.roundResultValue(sum.toString(), item, Collections.emptyList(), Collections.emptyMap(), salaryItemIdKeySalarySobItemPOMap)); + }); + return map; + } + + @Override + public List> listByParam(SalaryAcctResultQueryParam queryParam) { + // 查询薪资核算人员 + List salaryAcctEmployeePOS = getSalaryAcctEmployeeService(user).listByResultQueryParam(queryParam); + // 查询薪资核算结果 + return listBySalaryAcctEmployees(salaryAcctEmployeePOS, queryParam); + } + + /** + * 根据薪资核算人员查询薪资核算结果 + * + * @param salaryAcctEmployeePOS 薪资核算人员 + * @param queryParam 列表查询条件 + * @return + */ + private List> listBySalaryAcctEmployees(List salaryAcctEmployeePOS, SalaryAcctResultQueryParam queryParam) { + if (CollectionUtils.isEmpty(salaryAcctEmployeePOS)) { + return Collections.emptyList(); + } + // 查询薪资核算记录 + SalaryAcctRecordPO salaryAcctRecordPO = getSalaryAcctRecordService(user).getById(queryParam.getSalaryAcctRecordId()); + if (Objects.isNull(salaryAcctRecordPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98747, "薪资核算记录不存在或已被删除")); + } + boolean isBackCalc = Objects.equals(salaryAcctRecordPO.getBackCalcStatus(), 1); + + SalaryAcctConfig salaryAcctConfig = getSalaryAcctSobConfigService(user).getSalaryAcctConfig(queryParam.getSalaryAcctRecordId()); + + // 查询薪资核算所用的薪资账套的员工信息字段 + List salarySobEmpFieldPOS = salaryAcctConfig.getSalarySobEmpFields(); + // 查询薪资核算所用薪资账套的薪资项目 + List salarySobItemPOS = salaryAcctConfig.getSalarySobItems(); + Set salaryItemIds = SalaryEntityUtil.properties(salarySobItemPOS, SalarySobItemPO::getSalaryItemId); + // 是否是回算 + List salarySobBackItemPOList = Collections.emptyList(); + if (isBackCalc) { + // 根据薪资账套获取回算信息项 + salarySobBackItemPOList = getSalarySobBackItemService(user).listBySalarySobId(salaryAcctRecordPO.getSalarySobId()); + salaryItemIds.addAll(salarySobBackItemPOList.stream().map(SalarySobBackItemPO::getSalaryItemId).collect(Collectors.toList())); + } + List salaryItemPOS = getSalaryItemService(user).listByIds(salaryItemIds); + // 查询薪资核算结果 + List salaryAcctEmployeeIds = SalaryEntityUtil.properties(salaryAcctEmployeePOS, SalaryAcctEmployeePO::getId, Collectors.toList()); + List salaryAcctResultPOS = listBySalaryAcctEmployeeIds(salaryAcctEmployeeIds); + // 查询人员信息 + List employeeIds = SalaryEntityUtil.properties(salaryAcctEmployeePOS, SalaryAcctEmployeePO::getEmployeeId, Collectors.toList()); + List simpleEmployees = getSalaryEmployeeService(user).getEmployeeByIdsAll(employeeIds); + simpleEmployees.forEach(e -> { + UserStatusEnum userStatusEnum = UserStatusEnum.parseByValue(Integer.parseInt(e.getStatus())); + if (userStatusEnum != null) { + e.setStatusName(userStatusEnum.getDefaultLabel()); + } + }); + // 查询个税扣缴义务人 + Set taxAgentIds = SalaryEntityUtil.properties(salaryAcctEmployeePOS, SalaryAcctEmployeePO::getTaxAgentId); + List taxAgentPOS = getTaxAgentService(user).listByIds(taxAgentIds); + // 判断是否存在合并计税 + Set salaryAcctEmployeeIds4ConsolidatedTax; + if (StringUtils.isNotEmpty(queryParam.getConsolidatedTaxation())) { + // 如果查询条件中含有"合并计税",那么在入参中的salaryAcctEmployeePOS就已经全部都是存在合并计税的人员了(前面已经过滤了),无需再次查询合并计税的人员 + salaryAcctEmployeeIds4ConsolidatedTax = SalaryEntityUtil.properties(salaryAcctEmployeePOS, SalaryAcctEmployeePO::getId); + } else { + // 如果查询条件中没有包含"合并计税",那么就需要查询出存在合并计税的人,标记给前端 + SalaryAcctEmployeeQueryParam accEmployeeQueryParam = SalaryAcctEmployeeQueryParam.builder().salaryAcctRecordId(queryParam.getSalaryAcctRecordId()).ids(SalaryEntityUtil.properties(salaryAcctEmployeePOS, SalaryAcctEmployeePO::getId, Collectors.toList())).build(); + List salaryAcctEmployeePOS4ConsolidatedTax = getSalaryAcctEmployeeService(user).listByParam4ConsolidatedTax(accEmployeeQueryParam); + salaryAcctEmployeeIds4ConsolidatedTax = SalaryEntityUtil.properties(salaryAcctEmployeePOS4ConsolidatedTax, SalaryAcctEmployeePO::getId); + } + // 查询公式详情 + Set formulaIds = SalaryEntityUtil.properties(salarySobItemPOS, SalarySobItemPO::getFormulaId); + // 获取回算公式 + if (isBackCalc) { + formulaIds.addAll(salarySobBackItemPOList.stream().map(SalarySobBackItemPO::getFormulaId).collect(Collectors.toList())); + } + List expressFormulas = getSalaryFormulaService(user).listExpressFormula(formulaIds); + Map expressFormulaMap = SalaryEntityUtil.convert2Map(expressFormulas, ExpressFormula::getId, ExpressFormula::getFormula); + Map customParameters = SalaryEntityUtil.convert2Map(salarySobItemPOS, SalarySobItemPO::getSalaryItemId, salarySobItemPO -> { + if (salarySobItemPO.getFormulaId() <= 0) { + return SalaryI18nUtil.getI18nLabel(92004, "输入/导入"); + } + return expressFormulaMap.getOrDefault(salarySobItemPO.getFormulaId(), StringUtils.EMPTY); + }); + // 回算公式内容转换 + Map customBackCalcParameters = SalaryEntityUtil.convert2Map(salarySobBackItemPOList, SalarySobBackItemPO::getSalaryItemId, salarySobBackItemPO -> { + if (salarySobBackItemPO.getFormulaId() <= 0) { + return SalaryI18nUtil.getI18nLabel(92004, "输入/导入"); + } + return expressFormulaMap.getOrDefault(salarySobBackItemPO.getFormulaId(), StringUtils.EMPTY); + }); + + // 转换成薪资核算结果列表 + return SalaryAcctResultBO.buildTableData(salaryItemPOS, salarySobEmpFieldPOS, simpleEmployees, salaryAcctEmployeePOS, salaryAcctResultPOS, taxAgentPOS, salaryAcctEmployeeIds4ConsolidatedTax, customParameters, customBackCalcParameters, queryParam.isDynamicEmpInfo()); + + } + + @Override + public ConsolidatedTaxDetailDTO getConsolidatedTaxDetail(Long salaryAcctEmployeeId) { + // 查询当前的薪资核算人员 + SalaryAcctEmployeePO salaryAcctEmployeePO = getSalaryAcctEmployeeService(user).getById(salaryAcctEmployeeId); + if (Objects.isNull(salaryAcctEmployeePO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98831, "薪资核算人员不存在或已被删除")); + } + // 查询当前的薪资核算人员的个税扣缴义务人 + TaxAgentPO taxAgentPO = getTaxAgentService(user).getById(salaryAcctEmployeePO.getTaxAgentId()); + // 查询当前的薪资核算人员的人员信息 + DataCollectionEmployee simpleEmployee = getSalaryEmployeeService(user).getEmployeeById(salaryAcctEmployeePO.getEmployeeId()); + // 查询当前的薪资核算记录 + SalaryAcctRecordPO salaryAcctRecordPO = getSalaryAcctRecordService(user).getById(salaryAcctEmployeePO.getSalaryAcctRecordId()); + // 查询当前薪资核算记录所用的薪资账套 + SalarySobPO salarySobPO = getSalarySobService(user).getById(salaryAcctRecordPO.getSalarySobId()); + // 当前薪资核算记录所用的薪资账套的员工信息字段 + List salarySobEmpFieldPOS = getSalarySobEmpFieldService(user).listBySalarySobId(salarySobPO.getId()); + + List salaryAcctRecordPOS = Collections.singletonList(salaryAcctRecordPO); + List salaryAcctEmployeePOS = Collections.singletonList(salaryAcctEmployeePO); + + // 如果当前薪资核算记录所用的薪资账套的薪资类型是工资薪金,代表可能存在合并计税 + if (Objects.equals(salarySobPO.getIncomeCategory(), IncomeCategoryEnum.WAGES_AND_SALARIES.getValue())) { + // 查询所有薪资类型为工资薪金的账套 + List salarySobPOS = getSalarySobService(user).listByIncomeCategory(IncomeCategoryEnum.WAGES_AND_SALARIES); + // 查询相同税款所属期内的薪资类型为工资薪金的账套的所有核算记录 + Set salarySobIds = SalaryEntityUtil.properties(salarySobPOS, SalarySobPO::getId); + LocalDateRange taxCycleDateRange = SalaryDateUtil.localDate2Range(salaryAcctRecordPO.getTaxCycle()); + salaryAcctRecordPOS = getSalaryAcctRecordService(user).listBySalarySobIdsAndTaxCycle(salarySobIds, taxCycleDateRange); + // 查询当前薪资核算人员所涉及的合并计税的所有薪资核算人员 + Set salaryAcctRecordIds = SalaryEntityUtil.properties(salaryAcctRecordPOS, SalaryAcctRecordPO::getId); + salaryAcctEmployeePOS = getSalaryAcctEmployeeService(user).listByRecordIdsAndEmpIdAndTaxAgentId(salaryAcctRecordIds, salaryAcctEmployeePO.getEmployeeId(), salaryAcctEmployeePO.getTaxAgentId()); + } + // 查询薪资核算人员的薪资核算结果 + List salaryAcctEmployeeIds = SalaryEntityUtil.properties(salaryAcctEmployeePOS, SalaryAcctEmployeePO::getId, Collectors.toList()); + List salaryAcctResultPOS = listBySalaryAcctEmployeeIds(salaryAcctEmployeeIds); + // 查询薪资核算人员所有合并计税的薪资核算记录所用的账套 + Set salarySobIds = SalaryEntityUtil.properties(salaryAcctEmployeePOS, SalaryAcctEmployeePO::getSalarySobId); + List salarySobPOS = getSalarySobService(user).listByIds(salarySobIds); + // 查询薪资项目所引用的薪资项目 + List salarySobItemPOS = getSalarySobItemService(user).listBySalarySobIds(salarySobIds); + // 查询薪资项目 + Set salaryItemIds = SalaryEntityUtil.properties(salarySobItemPOS, SalarySobItemPO::getSalaryItemId); + List salaryItemPOS = getSalaryItemService(user).listByIds(salaryItemIds); + // 转换成合并计税详情dto + return SalaryAcctResultBO.convert2ConsolidatedTaxDetailDTO(simpleEmployee, taxAgentPO, salarySobEmpFieldPOS, salaryItemPOS, salaryAcctEmployeePOS, salarySobPOS, salaryAcctRecordPOS, salaryAcctResultPOS); + } + + @Override + public Map getColumnBySalaryAcctRecordId(Long salaryAcctRecordId) { + SalaryAcctRecordPO salaryAcctRecordPO = getSalaryAcctRecordService(user).getById(salaryAcctRecordId); + if (Objects.isNull(salaryAcctRecordPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98747, "薪资核算记录不存在或已被删除")); + } + Map resultMap = Maps.newHashMap(); + // 查询薪资核算使用的薪资账套下的薪资项目 + SalarySobItemAggregateDTO salarySobItemAggregateDTO = getSalarySobItemService(user).getAggregateByRecordId(salaryAcctRecordId, true); + for (SalarySobItemIncomeCategoryDTO incomeCategoryDTO : salarySobItemAggregateDTO.getIncomeCategories()) { + for (SalarySobItemGroupDTO salarySobItemGroupDTO : incomeCategoryDTO.getItemGroups()) { + for (SalarySobItemDTO salarySobItemDTO : salarySobItemGroupDTO.getItems()) { + SalaryAcctResultListColumnDTO salaryAcctResultListColumnDTO = new SalaryAcctResultListColumnDTO().setColumnName(salarySobItemDTO.getName()).setFormulaId(salarySobItemDTO.getFormulaId()).setFormulaContent(salarySobItemDTO.getFormulaContent()).setShowLock((!Objects.equals(salarySobItemDTO.getFormulaId(), NumberUtils.LONG_ZERO) && salarySobItemDTO.isCanEdit()) || Objects.equals(salarySobItemDTO.getUseInEmployeeSalary(), NumberUtils.INTEGER_ONE)); + resultMap.put("" + salarySobItemDTO.getSalaryItemId(), salaryAcctResultListColumnDTO); + } + } + for (SalarySobItemDTO salarySobItemDTO : incomeCategoryDTO.getItems()) { + SalaryAcctResultListColumnDTO salaryAcctResultListColumnDTO = new SalaryAcctResultListColumnDTO().setColumnName(salarySobItemDTO.getName()).setFormulaId(salarySobItemDTO.getFormulaId()).setFormulaContent(salarySobItemDTO.getFormulaContent()).setShowLock((!Objects.equals(salarySobItemDTO.getFormulaId(), NumberUtils.LONG_ZERO) && salarySobItemDTO.isCanEdit()) || Objects.equals(salarySobItemDTO.getUseInEmployeeSalary(), NumberUtils.INTEGER_ONE)); + resultMap.put("" + salarySobItemDTO.getSalaryItemId(), salaryAcctResultListColumnDTO); + } + } + // 查询回算薪资项目 + if (Objects.equals(salaryAcctRecordPO.getBackCalcStatus(), 1)) { + List backCalcItems = salarySobItemAggregateDTO.getBackCalcItems(); + for (SalarySobItemDTO backCalcItem : backCalcItems) { + SalaryAcctResultListColumnDTO salaryAcctResultListColumnDTO = new SalaryAcctResultListColumnDTO().setColumnName(backCalcItem.getName()).setFormulaId(backCalcItem.getFormulaId()).setFormulaContent(backCalcItem.getFormulaContent()).setShowLock(true); + resultMap.put("" + backCalcItem.getSalaryItemId(), salaryAcctResultListColumnDTO); + } + } + return resultMap; + } + + @Override + public void save(SalaryAcctResultSaveParam saveParam) { + + List dataCollectionEmployees = getSalaryEmployeeService(user).listAllForReport(); + Map emps = SalaryEntityUtil.convert2Map(dataCollectionEmployees, DataCollectionEmployee::getEmployeeId); + + // 查询薪资核算人员 + SalaryAcctEmployeePO salaryAcctEmployeePO = getSalaryAcctEmployeeService(user).getById(saveParam.getSalaryAcctEmpId()); + if (Objects.isNull(salaryAcctEmployeePO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98831, "薪资核算人员不存在或已被删除")); + } + // 更新员工基本信息值 + saveParam.getEmployeeInfos().stream().forEach(info -> { + if (info.getFieldValue() != null && StringUtils.isNotBlank(info.getFieldValue().toString())) { + if (info.getFieldCode().equals("departmentName") || info.getFieldCode().equals("departmentId")) { + // 修改部门信息 + DeptInfo deptInfo = getSalaryEmployeeService(user).getDeptInfoById(NumberUtils.isCreatable(info.getFieldValue().toString()) + ? Long.valueOf(info.getFieldValue().toString()) : 0L); + if (Objects.nonNull(deptInfo)) { + salaryAcctEmployeePO.setDepartmentName(deptInfo.getName()); + salaryAcctEmployeePO.setDepartmentId(deptInfo.getId()); + } + } else if (info.getFieldCode().equals("subcompanyName") || info.getFieldCode().equals("subcompanyId")) { + // 修改分部信息 + SubCompanyInfo subCompanyInfo = getSalaryEmployeeService(user).getSubCompanyInfoById(NumberUtils.isCreatable(info.getFieldValue().toString()) + ? Long.valueOf(info.getFieldValue().toString()) : 0L); + if (Objects.nonNull(subCompanyInfo)) { + salaryAcctEmployeePO.setSubcompanyName(subCompanyInfo.getName()); + salaryAcctEmployeePO.setSubcompanyId(subCompanyInfo.getId()); + } + } else if (info.getFieldCode().equals("jobtitleName") || info.getFieldCode().equals("jobtitleId")) { + // 修改岗位信息 + PositionInfo positionInfo = getSalaryEmployeeService(user).getPositionInfoById(NumberUtils.isCreatable(info.getFieldValue().toString()) + ? Long.valueOf(info.getFieldValue().toString()) : 0L); + if (Objects.nonNull(positionInfo)) { + salaryAcctEmployeePO.setJobtitleName(positionInfo.getName()); + salaryAcctEmployeePO.setJobtitleId(positionInfo.getId()); + } + } else if (info.getFieldCode().equals("jobcall") || info.getFieldCode().equals("jobcallId")) { + // 修改职称信息 + JobCallInfo jobCallInfo = getSalaryEmployeeService(user).getJobCallInfoById(NumberUtils.isCreatable(info.getFieldValue().toString()) + ? Long.valueOf(info.getFieldValue().toString()) : 0L); + if (Objects.nonNull(jobCallInfo)) { + salaryAcctEmployeePO.setJobcall(jobCallInfo.getName()); + salaryAcctEmployeePO.setJobcallId(jobCallInfo.getId()); + } + } + } + }); + getSalaryAcctEmployeeService(user).updateIgnoreNull(salaryAcctEmployeePO); + + // 校验是否可以编辑 + SalaryAcctRecordPO salaryAcctRecordPO = getSalaryAcctRecordService(user).getById(salaryAcctEmployeePO.getSalaryAcctRecordId()); + boolean recordIsCanEdit = getSalaryApprovalRuleService(user).getRecordIsCanEdit(salaryAcctRecordPO); + if (!recordIsCanEdit) { + throw new SalaryRunTimeException("该核算记录已经发起审批,无法编辑或核算,请先删除审批流程"); + } + // 查询原来的薪资核算结果 + List salaryAcctResultPOSOld = getSalaryAcctResultMapper().listSome(SalaryAcctResultPO.builder().salaryAcctEmpId(saveParam.getSalaryAcctEmpId()).build()); + // 解密 + encryptUtil.decryptList(salaryAcctResultPOSOld, SalaryAcctResultPO.class); + // 保存参数转换成薪资核算结果po + List salaryAcctResultPOS = SalaryAcctResultBO.convert2PO(salaryAcctResultPOSOld, saveParam, salaryAcctEmployeePO, (long) user.getUID()); + SalarySysConfPO autoLock = getSalarySysConfService(user).getOneByCode(SalarySysConstant.EDIT_IMPORT_AUTO_LOCK); + if (autoLock != null && StringUtils.equals(autoLock.getConfValue(), "1")) { + // 对比核算结果提取修改了哪些薪资项目 + Set needLockItems = new HashSet<>(); + Map oldResutMap = SalaryEntityUtil.convert2Map(salaryAcctResultPOSOld, SalaryAcctResultPO::getSalaryItemId); + salaryAcctResultPOS.stream().forEach(PO -> { + String oldValue = Optional.ofNullable(oldResutMap.get(PO.getSalaryItemId())).map(SalaryAcctResultPO::getResultValue).orElse(""); + if (!StringUtils.equals(oldValue, PO.getResultValue())) { + needLockItems.add(PO.getSalaryItemId()); + } + }); + + // 编辑的列都自动锁定 + SalaryAcctResultUpdateLockStatusParam updateLockStatusParam = SalaryAcctResultUpdateLockStatusParam.builder().salaryItemIds(needLockItems).salaryAcctRecordId(salaryAcctEmployeePO.getSalaryAcctRecordId()).lockStatus(LockStatusEnum.LOCK).build(); + getSalaryAcctResultService(user).updateLockStatusByParam(updateLockStatusParam); + } +// SalaryAcctRecordPO byId = getSalaryAcctRecordService(user).getById(salaryAcctEmployeePO.getSalaryAcctRecordId()); + // 若保存编辑时一同传已发补发,则删除以下代码 +// if(byId.getBackCalcStatus() != null && Objects.equals(byId.getBackCalcStatus(),1)){ +// // 是回算 +// List salarySobBackItemIds = getSalarySobBackItemService(user).listBySalarySobId(byId.getSalarySobId()).stream().map(SalarySobBackItemPO::getSalaryItemId).collect(Collectors.toList()); +// // 获取已发待发的薪资核算结果 +// List salarySobBackItemResultPO = salaryAcctResultPOSOld.stream().filter(po -> salarySobBackItemIds.contains(po.getSalaryItemId())).collect(Collectors.toList()); +// salaryAcctResultPOS.addAll(salarySobBackItemResultPO); +// } + // 删除原来的薪资核算结果 + List saveItemIds = saveParam.getItems().stream().map(SalaryAcctResultSaveParam.SalaryAcctResultDetailItemParam::getSalaryItemId).collect(Collectors.toList()); + deleteByAcctEmployeeIdsAndSalaryItemIds(Collections.singletonList(saveParam.getSalaryAcctEmpId()), saveItemIds); + // 保存薪资核算结果 + if (CollectionUtils.isNotEmpty(salaryAcctResultPOS)) { + // 加密 + encryptUtil.encryptList(salaryAcctResultPOS, SalaryAcctResultPO.class); + List> partition = Lists.partition(salaryAcctResultPOS, 100); + partition.forEach(getSalaryAcctResultMapper()::batchInsert); + } + //报表 +// getSalaryAcctReportService(user).deleteByAcctEmployeeIdsAndSalaryItemIds(Collections.singletonList(saveParam.getSalaryAcctEmpId()), saveItemIds); +// List salaryAcctResultReportPOS = SalaryAcctResultReportBO.convert2PO(saveParam, salaryAcctEmployeePO, (long) user.getUID(), emps); +// if (CollectionUtils.isNotEmpty(salaryAcctResultReportPOS)) { +// getSalaryAcctReportService(user).batchSave(salaryAcctResultReportPOS); +// } + + + // 存储薪资核算结果数据来源日志 + salaryAcctResultPOS = getSalaryAcctRecordService(user).listBySalaryAcctEmpId(saveParam.getSalaryAcctEmpId()); + + // 查询操作日志的targetName + String targetName = getSalaryAcctRecordService(user).getLogTargetNameById(salaryAcctEmployeePO.getSalaryAcctRecordId()); +// 查询人员信息 + DataCollectionEmployee simpleEmployee = getSalaryEmployeeService(user).getEmployeeById(salaryAcctEmployeePO.getEmployeeId()); +// 查询个税扣缴义务人 + TaxAgentPO taxAgentPO = getTaxAgentService(user).getById(salaryAcctEmployeePO.getTaxAgentId()); +// 记录日志 + String operateDesc = simpleEmployee.getUsername() + "(" + Optional.ofNullable(taxAgentPO).map(TaxAgentPO::getName).orElse(StringUtils.EMPTY) + ")"; + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(salaryAcctEmployeePO.getSalaryAcctRecordId())); + loggerContext.setTargetName(targetName); + loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "编辑薪资核算结果") + ": " + operateDesc); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "编辑薪资核算结果") + ": " + operateDesc); + loggerContext.setNewValueList(Lists.newArrayList(salaryAcctResultPOS)); + SalaryElogConfig.salaryAcctRecordLoggerTemplate.write(loggerContext); + } + + /** + * 存储薪资核算结果数据来源日志 + * + * @param salaryAcctResultPOSOld + * @param salaryAcctResultPOS + */ + private void saveSalaryAcctResultLog(List salaryAcctResultPOSOld, List salaryAcctResultPOS) { + // 对比核算结果提取修改了哪些薪资项目 + List editItems = new ArrayList<>(); + Map oldResutMap = SalaryEntityUtil.convert2Map(salaryAcctResultPOSOld, SalaryAcctResultPO::getSalaryItemId); + salaryAcctResultPOS.stream().forEach(PO -> { + if (oldResutMap.get(PO.getSalaryItemId()) == null) { + editItems.add(PO); + } else { + String oldValue = oldResutMap.get(PO.getSalaryItemId()).getResultValue(); + if (!StringUtils.equals(oldValue, PO.getResultValue())) { + editItems.add(PO); + } + } + }); + List needInsertList = SalaryAcctResultLogBO.buildSalaryAcctResultLog(editItems, Long.valueOf(user.getUID()), SalaryAcctResultDataSourceEnum.EDIT); + getSalaryAcctResultLogService(user).batchInsert(needInsertList); + } + + + @Override + public void batchSave(List salaryAcctResultPOS) { + if (CollectionUtils.isNotEmpty(salaryAcctResultPOS)) { + // 数据加密 + encryptUtil.encryptList(salaryAcctResultPOS, SalaryAcctResultPO.class); + List> partition = Lists.partition(salaryAcctResultPOS, 100); + partition.forEach(getSalaryAcctResultMapper()::batchInsert); + + } + } + + + @Override + public void deleteBySalaryAcctEmployeeIds(Collection salaryAcctEmployeeIds) { + getSalaryAcctResultMapper().deleteBySalaryAcctEmpIds(salaryAcctEmployeeIds); + } + + + @Override + public void deleteByAcctEmployeeIdsAndSalaryItemIds(List salaryAcctEmployeeIds, Collection salaryItemIds) { + List> partition = Lists.partition(salaryAcctEmployeeIds, 300); + partition.forEach(part -> getSalaryAcctResultMapper().deleteByAcctEmpIdsAndSalaryItemIds(part, salaryItemIds)); + } + + @Override + public void deleteBySalaryAcctRecordIds(Collection salaryAcctRecordIds) { + getSalaryAcctResultMapper().deleteBySalaryAcctRecordIds(salaryAcctRecordIds); + } + + @Override + public void calculate(SalaryAcctCalculateParam calculateParam, DataCollectionEmployee simpleEmployee) { + try { + log.info("开始核算V2 {}", calculateParam); + StopWatch stopWatch = new StopWatch("总核算耗时,id:" + calculateParam.getSalaryAcctRecordId()); + stopWatch.start("数据准备"); + // 1、查询薪资核算记录 + SalaryAcctRecordPO salaryAcctRecordPO = getSalaryAcctRecordService(user).getById(calculateParam.getSalaryAcctRecordId()); + if (Objects.isNull(salaryAcctRecordPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98747, "薪资核算记录不存在或已被删除")); + } + //查询对应账套 + SalarySobPO salarySobPO = getSalarySobService(user).getById(salaryAcctRecordPO.getSalarySobId()); + if (Objects.isNull(salarySobPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98747, "薪资账套不存在或已被删除")); + } + + // 不是查询薪资账套下实时的薪资项目,而是查询发起薪资核算时存储的薪资项目快照 + SalaryAcctConfig salaryAcctSobConfig = getSalaryAcctSobConfigService(user).getSalaryAcctConfig(calculateParam.getSalaryAcctRecordId()); + + // 1.1、如果薪资核算记录已经归档了,就不能继续核算 + if (!Objects.equals(salaryAcctRecordPO.getStatus(), SalaryAcctRecordStatusEnum.NOT_ARCHIVED.getValue())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(99148, "当前薪资核算记录已归档,请重新打开后再进行核算")); + } + // 2、查询薪资核算记录的薪资周期、考勤周期等 + SalarySobCycleDTO salarySobCycleDTO = getSalaryAcctRecordService(user).getSalarySobCycleById(calculateParam.getSalaryAcctRecordId()); + // 3、查询薪资核算记录所用薪资账套的薪资项目副本 + List salarySobItemPOS = salaryAcctSobConfig.getSalarySobItems(); + if (CollectionUtils.isEmpty(salarySobItemPOS)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(99151, "当前所用的薪资账套未选择任何薪资项目,无法核算")); + } + // 回算薪资项目 + List salarySobBackItems = Collections.emptyList(); + if (Objects.equals(salaryAcctRecordPO.getBackCalcStatus(), 1)) { + salarySobBackItems = salaryAcctSobConfig.getSalarySobBackItems(); + } + // 4、查询当前租户的所有薪资项目 + List salaryItemPOS = getSalaryItemService(user).listAll(); + // 5、查询薪资核算记录所用薪资账套的调薪计薪规则 + List salarySobAdjustRulePOS = getSalarySobAdjustRuleService(user).listBySalarySobId(salaryAcctRecordPO.getSalarySobId()); + // 6、查询社保福利的所有字段 + Map welfareColumns = getSIAccountService(user).welfareColumns(); + // 7、查询考勤引用的所有字段 + List attendQuoteFieldListDTOS = getAttendQuoteFieldService(user).listAll(); + List variableItemPOS = getVariableItemService(user).listAll(); + + // 8、查询公式详情 + Set formulaIds = SalaryEntityUtil.properties(salarySobItemPOS, SalarySobItemPO::getFormulaId); + formulaIds.addAll(SalaryEntityUtil.properties(salaryItemPOS, SalaryItemPO::getFormulaId)); + formulaIds.addAll(SalaryEntityUtil.properties(salarySobBackItems, SalarySobBackItemPO::getFormulaId)); + List expressFormulas = getSalaryFormulaService(user).listExpressFormula(formulaIds); + // 本次运算的回算薪资项目所涉及的变量 + Set issuedFieldIds = new HashSet<>(); + // 9、计算薪资项目的运算优先级 + List> salarySobItemsWithPriority = SalaryAcctCalculatePriorityBO.calculatePriority(salarySobItemPOS, salaryItemPOS, expressFormulas, salarySobBackItems, issuedFieldIds); + // 10、根据id查询其他合并计税的薪资核算记录 + List otherSalaryAcctRecordPOS = getSalaryAcctRecordService(user).listById4OtherConsolidatedTax(salaryAcctRecordPO.getId()); + // 11、查询本次核算人员 + List salaryAcctEmployeePOS; + if (CollectionUtils.isEmpty(calculateParam.getIds())) { + salaryAcctEmployeePOS = getSalaryAcctEmployeeService(user).listBySalaryAcctRecordId(salaryAcctRecordPO.getId()); + } else { + salaryAcctEmployeePOS = getSalaryAcctEmployeeService(user).listByIds(calculateParam.getIds()); + } + if (CollectionUtils.isEmpty(salaryAcctEmployeePOS)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(103378, "薪资核算人员不能为空")); + } + stopWatch.stop(); + stopWatch.start("核算耗时"); + + // 11.1、初始化进度 + ProgressDTO initProgress = new ProgressDTO().setTitle(SalaryI18nUtil.getI18nLabel(97515, "核算中")).setTitleLabelId(97515L).setTotalQuantity(salaryAcctEmployeePOS.size() * 2 + 1).setCalculatedQuantity(0).setProgress(BigDecimal.ZERO).setStatus(true).setMessage(StringUtils.EMPTY); + getSalaryAcctProgressService(user).initProgress(SalaryCacheKey.ACCT_PROGRESS + calculateParam.getSalaryAcctRecordId(), initProgress); + // 12、对薪资核算人员进行拆分 + String personNumberInOneThread = new BaseBean().getPropValue("hrmSalaryCustom", "personNumberInOneThread"); + int size = 100; + if (StringUtils.isNotBlank(personNumberInOneThread)) { + size = Integer.parseInt(personNumberInOneThread); + } + List> partition = Lists.partition(salaryAcctEmployeePOS, size); + // 12.1、监控子线程的任务执行 + CountDownLatch childMonitor = new CountDownLatch(partition.size()); + // 12.2、记录子线程的执行结果 + BlockingDeque calculateResults = new LinkedBlockingDeque<>(partition.size()); + // 12.3、生成本次运算的key + String calculateKey = UUID.randomUUID().toString(); + // 12.4、是否采用系统算税 + TaxDeclarationFunctionEnum taxDeclarationFunction = getSalarySysConfService(user).getTaxDeclaration(); + // 12.5、多线程运算,运算结果存放在临时表中 + //是否同步计算 + boolean isSync = "0".equals(getSalarySysConfService(user).getValueByCode(SALARY_ACCT_SYNC_TYPE)); + for (List acctEmployeePOS : partition) { + SalaryAcctCalculateBO salaryAcctCalculateBO = new SalaryAcctCalculateBO() + .setSalaryAcctRecordPO(salaryAcctRecordPO) + .setSalarySobPO(salarySobPO) + .setSalarySobCycleDTO(salarySobCycleDTO) + .setOtherSalaryAcctRecordPOS(otherSalaryAcctRecordPOS) + .setSalarySobItemPOS(salarySobItemPOS) + .setSalaryItemIdWithPriorityList(salarySobItemsWithPriority) + .setExpressFormulas(expressFormulas) + .setSalaryItemPOS(salaryItemPOS) + .setSalarySobAdjustRulePOS(salarySobAdjustRulePOS) + .setWelfareColumns(MapUtils.emptyIfNull(welfareColumns)) + .setAttendQuoteFieldListDTOS(attendQuoteFieldListDTOS) + .setSalaryAcctEmployeePOS(acctEmployeePOS) + .setIssuedFieldIds(issuedFieldIds) + .setChildMonitor(childMonitor) + .setResults(calculateResults) + .setCalculateKey(calculateKey) + .setVariableItems(variableItemPOS) + .setTaxDeclarationFunction(taxDeclarationFunction); + List finalSalarySobBackItems = salarySobBackItems; + if (isSync) { + getSalaryAcctCalculateService(user).calculate(salaryAcctCalculateBO, simpleEmployee, finalSalarySobBackItems); + } else { + LocalRunnable localRunnable = new LocalRunnable() { + @Override + public void execute() { + getSalaryAcctCalculateService(user).calculate(salaryAcctCalculateBO, simpleEmployee, finalSalarySobBackItems); + } + }; + ThreadPoolUtil.fixedPoolExecute(ModulePoolEnum.HRM, "salaryAcctCalculate", localRunnable); + } + } + // 13、等待所有子线程执行完毕 + childMonitor.await(); + + stopWatch.stop(); + stopWatch.start("数据写入耗时"); + + // 14、判断子线程执行结果 + boolean allSuccess = calculateResults.stream().allMatch(SalaryAcctCalculateBO.Result::isStatus); + if (!allSuccess) { + // 薪资核算实现的线程的错误信息 + String errorMsg = calculateResults.stream().filter(result -> !result.isStatus()).map(SalaryAcctCalculateBO.Result::getErrMsg).collect(Collectors.joining("|")); + getSalaryAcctProgressService(user).fail(SalaryCacheKey.ACCT_PROGRESS + calculateParam.getSalaryAcctRecordId(), errorMsg); + // 删除薪资核算临时存储表中的数据 + getSalaryAcctResultTempService(user).deleteByCalculateKey(calculateKey); + return; + } + // 15、处理核算结果临时表数据 + handleSalaryAcctResultTemp(calculateParam, calculateKey); + // 16、开始运行校验规则 +// SalaryAcctCheckParam salaryAcctCheckParam = new SalaryAcctCheckParam() +// .setSalaryAcctRecordId(calculateParam.getSalaryAcctRecordId()) +// .setIds(calculateParam.getIds()); +// salaryCheckResultService.check(salaryAcctCheckParam, true, simpleEmployee); +// Thread.sleep(10); + getSalaryAcctProgressService(user).finish(SalaryCacheKey.ACCT_PROGRESS + calculateParam.getSalaryAcctRecordId(), true); + + //更新薪资核算记录最后操作日期 + getSalaryAcctRecordService(user).updateDate(salaryAcctRecordPO.getId(), new Date()); + + stopWatch.stop(); + log.info(stopWatch.prettyPrint()); + + // 记录日志 + // 查询操作日志的targetName + String targetName = getSalaryAcctRecordService(user).getLogTargetNameById(calculateParam.getSalaryAcctRecordId()); + Collection ids = calculateParam.getIds(); + if (CollectionUtils.isNotEmpty(ids)) { + targetName += ids; + } + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(calculateParam.getSalaryAcctRecordId())); + loggerContext.setTargetName(targetName); + loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "薪资核算")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "薪资核算")); + SalaryElogConfig.salaryAcctRecordLoggerTemplate.write(loggerContext); + } catch (Exception e) { + log.info("薪资核算出错:{}", e.getMessage(), e); +// throw new SalaryRunTimeException(e); + getSalaryAcctProgressService(user).fail(SalaryCacheKey.ACCT_PROGRESS + calculateParam.getSalaryAcctRecordId(), SalaryI18nUtil.getI18nLabel(99642, "薪资核算出错") + ": " + e.getMessage()); + } finally { + // 数据库字段加密用 + } + } + + /** + * 处理薪资核算临时存储表中的数据 + * + * @param calculateParam + * @param calculateKey + */ + private void handleSalaryAcctResultTemp(SalaryAcctCalculateParam calculateParam, String calculateKey) { + StopWatch sw = new StopWatch(calculateParam.getSalaryAcctRecordId() + ""); + // 查询薪资核算结果的临时存储 + sw.start("处理核算数据,查询薪资核算结果的临时存储"); + List salaryAcctResultTempPOS = getSalaryAcctResultTempService(user).listByCalculateKey(calculateKey); + sw.stop(); + // 删除原来的薪资核算结果 + sw.start("处理核算数据,删除原来的薪资核算结果"); + if (CollectionUtils.isNotEmpty(calculateParam.getIds())) { + getSalaryAcctResultMapper().deleteBySalaryAcctEmpIds(calculateParam.getIds()); + } else { + getSalaryAcctResultMapper().deleteBySalaryAcctRecordIds(Collections.singleton(calculateParam.getSalaryAcctRecordId())); + getSalaryAcctReportService(user).deleteBySalaryAcctRecordId(calculateParam.getSalaryAcctRecordId()); + } + sw.stop(); + // 保存薪资的薪资核算结果 + sw.start("处理核算数据,保存薪资的薪资核算结果"); + List salaryAcctResultPOS = SalaryAcctResultBO.convert2ResultPO(salaryAcctResultTempPOS); + batchSave(salaryAcctResultPOS); + sw.stop(); + // 删除薪资核算临时存储表中的数据 + sw.start("处理核算数据,删除薪资核算临时存储表中的数据"); + getSalaryAcctResultTempService(user).deleteByCalculateKey(calculateKey); + sw.stop(); + log.info(sw.prettyPrint()); + } + + @Override + public List listBySalaryAcctRecordIdsAndTaxAgentIds(Collection salaryAcctRecordIds, Collection taxAgentIds) { + if (CollectionUtils.isEmpty(salaryAcctRecordIds)) { + return Collections.emptyList(); + } + return encryptUtil.decryptList(getSalaryAcctResultMapper().listSome(SalaryAcctResultPO.builder().salaryAcctRecordIds(salaryAcctRecordIds).taxAgentIds(taxAgentIds).build()), SalaryAcctResultPO.class); + } + + +// /** +// * 查询薪资核算人员 +// * +// * @param queryParam +// * @param salaryAcctRecord +// * @return +// */ +// private List querySalaryAcctEmployee(SalaryAcctResultListContext salaryAcctResultListContext, SalaryAcctResultQueryParam queryParam, SalaryAcctRecordPO salaryAcctRecord) { +// // 构建薪资核算人员的查询参数 +// SalaryAcctEmployeeQueryParam salaryAcctEmployeeListQueryParam = new SalaryAcctEmployeeQueryParam(); +// BeanUtils.copyProperties(queryParam, salaryAcctEmployeeListQueryParam); +// // 查询薪资核算人员 +// List salaryAcctEmployees = getSalaryAcctEmployeeService(user).listByParam(salaryAcctEmployeeListQueryParam); +// // 查询相同税款所属期内的薪资核算人员 +// List sameTaxCycleSalaryAcctEmployees = salaryAcctEmployeeService +// .listSameTaxCycle(salaryAcctEmployees, SalaryDateUtil.getFormatYearMonth(salaryAcctRecord.getTaxCycle())); +// Set sameTaxCycleKeySet = SalaryEntityUtil.properties(sameTaxCycleSalaryAcctEmployees, o -> o.getEmployeeId() + "-" + o.getTaxAgentId()); +// salaryAcctResultListContext.setSameTaxCycleKeySet(sameTaxCycleKeySet); +// // 过滤合并计税的人员 +// if (StringUtils.isNotEmpty(queryParam.getConsolidatedTaxation())) { +// salaryAcctEmployees = salaryAcctEmployees.stream() +// .filter(salaryAcctEmployeePO -> sameTaxCycleKeySet.contains(salaryAcctEmployeePO.getEmployeeId() + "-" + salaryAcctEmployeePO.getTaxAgentId())) +// .collect(Collectors.toList()); +// } +// // 根据权限过滤 +// return salaryAcctEmployeeService.filterByAuthority(salaryAcctEmployees, employeeId); +// } + + + @Override + public void lock(SalaryAcctResultLockParam param) { + ValidUtil.doValidator(param); + + SalaryAcctEmployeePO salaryAcctEmployeePO = getSalaryAcctEmployeeService(user).getById(param.getAcctEmpId()); + if (salaryAcctEmployeePO == null) { + return; + } + + List lockItemIds = salaryAcctEmployeePO.getLockItems() == null ? new ArrayList<>() : salaryAcctEmployeePO.getLockItems(); + Long salaryItemId = param.getSalaryItemId(); + + if (param.getLockStatus() == LockStatusEnum.LOCK) { + lockItemIds.add(salaryItemId); + } else { + lockItemIds.removeIf(salaryItemId::equals); + } + + salaryAcctEmployeePO.setLockItems(Lists.newArrayList(new HashSet(lockItemIds))); + + getSalaryAcctEmployeeService(user).lock(salaryAcctEmployeePO); + } + + @Override + public void updateLockStatusByParam(SalaryAcctResultUpdateLockStatusParam updateParam) { + List salaryAcctEmployees = getSalaryAcctEmployeeService(user).listBySalaryAcctRecordId(updateParam.getSalaryAcctRecordId()); + if (CollectionUtils.isEmpty(salaryAcctEmployees)) { + return; + } + + Set salaryItemIds; + if (CollectionUtils.isNotEmpty(updateParam.getSalaryItemIds())) { + salaryItemIds = updateParam.getSalaryItemIds(); + } else { + salaryItemIds = Collections.singleton(updateParam.getSalaryItemId()); + } + + salaryAcctEmployees.forEach(salaryAcctEmployeePO -> { + List lockItemIds = salaryAcctEmployeePO.getLockItems() == null ? new ArrayList<>() : salaryAcctEmployeePO.getLockItems(); + + if (updateParam.getLockStatus() == LockStatusEnum.LOCK) { + lockItemIds.addAll(salaryItemIds); + } else { + lockItemIds.removeAll(salaryItemIds); + } + salaryAcctEmployeePO.setLockItems(Lists.newArrayList(new HashSet(lockItemIds))); + getSalaryAcctEmployeeService(user).lock(salaryAcctEmployeePO); + }); + + } + + @Override + public void reCalc(Long id) { + // 无需解密 + SalaryAcctResultPO build = SalaryAcctResultPO.builder().salaryAcctRecordId(id).deleteType(0).build(); + List salaryAcctResultPOS = getSalaryAcctResultMapper().listSome(build); + // 回算前的薪资核算结果 + salaryAcctResultPOS.forEach(salaryAcctResult -> salaryAcctResult.setOriginResultValue(salaryAcctResult.getResultValue())); + // 批量更新 + batchUpdateOriginResultValue(salaryAcctResultPOS); + } + + @Override + public List listBySalaryAcctRecordIdsAndSalaryItemIds(Collection salaryAcctRecordIds, Collection salaryItemIds) { + if (CollectionUtils.isEmpty(salaryAcctRecordIds) || CollectionUtils.isEmpty(salaryItemIds)) { + return Collections.emptyList(); + } + List list = getSalaryAcctResultMapper().listSome(SalaryAcctResultPO.builder().salaryAcctRecordIds(salaryAcctRecordIds).salaryItemIds(salaryItemIds).build()); + return encryptUtil.decryptList(list, SalaryAcctResultPO.class); + + } + + @Override + public List listByAcctEmployeeIdsAndSalaryItemIds(List salaryAcctEmployeeIds, Collection salaryItemIds) { + if (CollectionUtils.isEmpty(salaryAcctEmployeeIds)) { + return Collections.emptyList(); + } + List> partition = Lists.partition(salaryAcctEmployeeIds, 200); + List result = new ArrayList<>(); + partition.forEach(empIds -> { + SalaryAcctResultPO build = SalaryAcctResultPO.builder().salaryAcctEmpIds(empIds).salaryItemIds(salaryItemIds).build(); + result.addAll(getSalaryAcctResultMapper().listSome(build)); + }); + + // 数据解密 + encryptUtil.decryptList(result, SalaryAcctResultPO.class); + return result; + } + + @Override + public void batchUpdateOriginResultValue(List salaryAcctResultValues) { + int batchSize = 500; + List> partition = Lists.partition(salaryAcctResultValues, batchSize); + for (List subSalaryAcctResultValues : partition) { + getSalaryAcctResultMapper().batchUpdateOriginResultValue(subSalaryAcctResultValues); + } + } + + @Override + public List listAcctEmpIdByAcctEmpId(List salaryAcctEmployeeIds) { + if (CollectionUtils.isEmpty(salaryAcctEmployeeIds)) { + return Collections.emptyList(); + } + List> partition = Lists.partition((List) salaryAcctEmployeeIds, 1000); + List result = new ArrayList<>(); + partition.forEach(empIds -> { + result.addAll(getSalaryAcctResultMapper().getAcctEmpIsExist(empIds)); + }); + return result; + } + + + @Override + public Boolean checkAuth(Long salaryAcctRecordId) { + // 获取该核算记录的个税扣缴义务 +// SalaryAcctRecordPO recordPO = getSalaryAcctRecordService(user).getById(salaryAcctRecordId); +// if (Objects.isNull(recordPO)) { +// return false; +// } +// SalarySobPO salarySobPO = getSalarySobService(user).getById(recordPO.getSalarySobId()); +// Long taxAgentId = salarySobPO.getTaxAgentId(); +// List adminTaxAgentList = getTaxAgentAdminService(user).listByEmployeeId((long) user.getUID()); +// Optional canOperate = adminTaxAgentList.stream().filter(po -> NumberUtils.compare(taxAgentId, po.getTaxAgentId()) == 0).findFirst(); +// if (!canOperate.isPresent()) { +// return false; +// } + return true; + } + + @Override + public void batchUpdate(SalaryAcctResultBatchUpdateParam param) { + ValidUtil.doValidator(param); + + SalaryAcctRecordPO salaryAcctRecordPO = getSalaryAcctRecordService(user).getById(param.getSalaryAcctRecordId()); + if (salaryAcctRecordPO == null) { + throw new SalaryRunTimeException("薪资核算记录不存在,或已被删除"); + } + List salarySobItemPOS = getSalarySobItemService(user).listBySalarySobId(salaryAcctRecordPO.getSalarySobId()); + // 薪资账套中包含的薪资项目 + List salarySobItemIds = salarySobItemPOS.stream().map(SalarySobItemPO::getSalaryItemId).collect(Collectors.toList()); + if (!salarySobItemIds.contains(param.getSalaryItemId())) { + throw new SalaryRunTimeException("该账套不包含该薪资项目或已被删除,请先检查账套"); + } + // 获取需要更新的核算人员信息 + List salaryAcctEmployeePOList = new ArrayList<>(); + if (CollectionUtils.isEmpty(param.getIdList())) { + // 没有选择核算人员,更新核算记录中所有人员 + salaryAcctEmployeePOList.addAll(getSalaryAcctEmployeeService(user).listBySalaryAcctRecordId(salaryAcctRecordPO.getId())); + } else { + salaryAcctEmployeePOList.addAll(getSalaryAcctEmployeeService(user).listByIds(param.getIdList())); + } + + if (CollectionUtils.isNotEmpty(salaryAcctEmployeePOList)) { + List salaryAcctEmployeeIdList = SalaryEntityUtil.properties(salaryAcctEmployeePOList, SalaryAcctEmployeePO::getId, Collectors.toList()); + // 查询薪资核算结果 + List resultPOS = listByAcctEmployeeIdsAndSalaryItemIds(salaryAcctEmployeeIdList, Collections.singleton(param.getSalaryItemId())); + Map salaryAcctResultPOMap = SalaryEntityUtil.convert2Map(resultPOS, SalaryAcctResultPO::getSalaryAcctEmpId); + List dataCollectionEmployees = getSalaryEmployeeService(user).listAllForReport(); + Map emps = SalaryEntityUtil.convert2Map(dataCollectionEmployees, DataCollectionEmployee::getEmployeeId); + List needUpdateList = new ArrayList<>(); + List needInsertList = new ArrayList<>(); + Date now = new Date(); + List salaryAcctResultReportPOS = new ArrayList<>(); + salaryAcctEmployeePOList.forEach(salaryAcctEmployeePO -> { + if (salaryAcctResultPOMap.containsKey(salaryAcctEmployeePO.getId())) { + // 更新 + SalaryAcctResultPO po = salaryAcctResultPOMap.get(salaryAcctEmployeePO.getId()); + po.setResultValue(param.getValue()); + po.setUpdateTime(now); + needUpdateList.add(po); + } else { + // 新增 + needInsertList.add(SalaryAcctResultPO.builder() + .salarySobId(salaryAcctRecordPO.getSalarySobId()) + .salaryItemId(param.getSalaryItemId()) + .salaryAcctRecordId(param.getSalaryAcctRecordId()) + .salaryAcctEmpId(salaryAcctEmployeePO.getId()) + .employeeId(salaryAcctEmployeePO.getEmployeeId()) + .taxAgentId(salaryAcctEmployeePO.getTaxAgentId()) + .resultValue(param.getValue()) + .originResultValue("") + .creator(Long.valueOf(user.getUID())) + .createTime(now) + .updateTime(now) + .deleteType(NumberUtils.INTEGER_ZERO) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .build()); + } + + // 报表 +// SalaryAcctResultReportPO po = SalaryAcctResultReportPO.builder() +// .id(IdGenerator.generate()) +// .salarySobId(salaryAcctRecordPO.getSalarySobId()) +// .salaryItemId(param.getSalaryItemId()) +// .salaryAcctRecordId(param.getSalaryAcctRecordId()) +// .salaryAcctEmpId(salaryAcctEmployeePO.getId().toString()) +// .employeeId(salaryAcctEmployeePO.getEmployeeId().toString()) +// .taxAgentId(salaryAcctEmployeePO.getTaxAgentId()) +// .resultValue(param.getValue()) +// .creator(Long.valueOf(user.getUID())) +// .createTime(now) +// .updateTime(now) +// .deleteType(NumberUtils.INTEGER_ZERO) +// .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) +// .build(); +// DataCollectionEmployee dataCollectionEmployee = emps.get(salaryAcctEmployeePO.getEmployeeId()); +// if (dataCollectionEmployee != null) { +// po.setDepartmentId(dataCollectionEmployee.getDepartmentId()); +// po.setSubcompanyId(dataCollectionEmployee.getSubcompanyid()); +// po.setCostcenterId(dataCollectionEmployee.getCostcenterId()); +// po.setJobtitleId(dataCollectionEmployee.getJobtitleId()); +// po.setLocationId(dataCollectionEmployee.getLocationId()); +// } +// salaryAcctResultReportPOS.add(po); + }); + + // 入库 + if (CollectionUtils.isNotEmpty(needUpdateList)) { + // 数据加密 + encryptUtil.encryptList(needUpdateList, SalaryAcctResultPO.class); + List> partition = Lists.partition(needUpdateList, 100); + partition.forEach(getSalaryAcctResultMapper()::batchUpdate); + } + batchSave(needInsertList); + + // 报表入库前先删除 +// getSalaryAcctReportService(user).deleteByAcctEmployeeIdsAndSalaryItemIds(param.getIdList(), Collections.singletonList(param.getSalaryItemId())); +// getSalaryAcctReportService(user).batchSave(salaryAcctResultReportPOS); + + } + } + + @Override + public List listBySobSalaryMonth(Date salaryMonth, Long salarySobId, List employeeIds) { + List salaryAcctRecordPOS = getSalaryAcctRecordService(user).listSome(SalaryAcctRecordPO.builder().salarySobId(salarySobId).salaryMonth(salaryMonth).build()); + List recordIds = SalaryEntityUtil.properties(salaryAcctRecordPOS, SalaryAcctRecordPO::getId, Collectors.toList()); + + if (CollUtil.isEmpty(recordIds)) { + return new ArrayList<>(); + } + List salaryAcctResultPOS = new ArrayList<>(); + SalaryAcctResultPO resultParam = SalaryAcctResultPO.builder().salaryAcctRecordIds(recordIds).build(); + if (CollUtil.isNotEmpty(employeeIds)) { + List> partition = Lists.partition(employeeIds, 500); + for (List ids : partition){ + resultParam.setEmployeeIds(ids); + List acctResultPOS = getSalaryAcctResultMapper().listSome(resultParam); + salaryAcctResultPOS.addAll(acctResultPOS); + } + } else { + salaryAcctResultPOS = getSalaryAcctResultMapper().listSome(resultParam); + } + + encryptUtil.decryptList(salaryAcctResultPOS, SalaryAcctResultPO.class); + return salaryAcctResultPOS; + } +} \ No newline at end of file diff --git a/src/com/engine/salary/service/impl/SalaryAcctResultTempServiceImpl.java b/src/com/engine/salary/service/impl/SalaryAcctResultTempServiceImpl.java new file mode 100644 index 000000000..def14c03e --- /dev/null +++ b/src/com/engine/salary/service/impl/SalaryAcctResultTempServiceImpl.java @@ -0,0 +1,52 @@ +package com.engine.salary.service.impl; + +import com.engine.core.impl.Service; +import com.engine.salary.entity.salaryacct.po.SalaryAcctResultTempPO; +import com.engine.salary.mapper.salaryacct.SalaryAcctResultTempMapper; +import com.engine.salary.service.SalaryAcctResultTempService; +import com.engine.salary.util.db.MapperProxyFactory; +import com.google.common.collect.Lists; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; + +import java.util.Collection; +import java.util.List; + +/** + * 薪资核算结果临时存储 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SalaryAcctResultTempServiceImpl extends Service implements SalaryAcctResultTempService { + private SalaryAcctResultTempMapper getSalaryAcctResultTempMapper() { + return MapperProxyFactory.getProxy(SalaryAcctResultTempMapper.class); + } + + + @Override + public List listByCalculateKey(String calculateKey) { + + if (StringUtils.isBlank(calculateKey)) { + return Lists.newArrayList(); + } + return getSalaryAcctResultTempMapper().listSome(SalaryAcctResultTempPO.builder().calculateKey(calculateKey).build()); + + + } + + @Override + public void batchSave(Collection salaryAcctResultTempPOS) { + if (CollectionUtils.isNotEmpty(salaryAcctResultTempPOS)) { + List> partition = Lists.partition((List) salaryAcctResultTempPOS, 100); + partition.forEach(p -> getSalaryAcctResultTempMapper().batchInsert(p)); + } + } + + @Override + public void deleteByCalculateKey(String calculateKey) { + getSalaryAcctResultTempMapper().deleteByCalculateKey(calculateKey); + } +} diff --git a/src/com/engine/salary/service/impl/SalaryAcctResultTemplateServiceImpl.java b/src/com/engine/salary/service/impl/SalaryAcctResultTemplateServiceImpl.java new file mode 100644 index 000000000..219d971f6 --- /dev/null +++ b/src/com/engine/salary/service/impl/SalaryAcctResultTemplateServiceImpl.java @@ -0,0 +1,72 @@ +package com.engine.salary.service.impl; + +import com.engine.core.impl.Service; +import com.engine.salary.entity.salaryacct.po.SalaryAcctResultTemplatePO; +import com.engine.salary.mapper.salaryacct.SalaryAcctResultTemplateMapper; +import com.engine.salary.service.SalaryAcctResultTemplateService; +import com.engine.salary.util.db.MapperProxyFactory; +import org.apache.commons.collections4.CollectionUtils; + +import java.util.Collections; +import java.util.List; + +/** + * @author Harryxzy + * @ClassName SalaryAcctResultTemplateServiceImpl + * @date 2024/03/26 15:30 + * @description + */ +public class SalaryAcctResultTemplateServiceImpl extends Service implements SalaryAcctResultTemplateService { + + private SalaryAcctResultTemplateMapper getSalaryAcctResultTemplateMapper() { + return MapperProxyFactory.getProxy(SalaryAcctResultTemplateMapper.class); + } + @Override + public List listAll() { + return getSalaryAcctResultTemplateMapper().listAll(); + } + + @Override + public SalaryAcctResultTemplatePO getById(Long id) { + return getSalaryAcctResultTemplateMapper().getById(id); + } + + @Override + public int insertIgnoreNull(SalaryAcctResultTemplatePO salaryAcctResultTemplate) { + return getSalaryAcctResultTemplateMapper().insertIgnoreNull(salaryAcctResultTemplate); + } + + @Override + public int update(SalaryAcctResultTemplatePO salaryAcctResultTemplate) { + return getSalaryAcctResultTemplateMapper().update(salaryAcctResultTemplate); + } + + @Override + public int updateIgnoreNull(SalaryAcctResultTemplatePO salaryAcctResultTemplate) { + return getSalaryAcctResultTemplateMapper().updateIgnoreNull(salaryAcctResultTemplate); + } + + @Override + public int deleteById(Long id) { + if (id == null) { + return 0; + } + return getSalaryAcctResultTemplateMapper().deleteById(id); + } + + @Override + public int deleteByIds(List ids) { + if (CollectionUtils.isEmpty(ids)) { + return 0; + } + return getSalaryAcctResultTemplateMapper().deleteByIds(ids); + } + + @Override + public List listBySalarySobId(Long salarySobId,List types) { + if (salarySobId == null) { + return Collections.emptyList(); + } + return getSalaryAcctResultTemplateMapper().listSome(SalaryAcctResultTemplatePO.builder().salarySobId(salarySobId).types(types).build()); + } +} diff --git a/src/com/engine/salary/service/impl/SalaryAcctSobConfigServiceImpl.java b/src/com/engine/salary/service/impl/SalaryAcctSobConfigServiceImpl.java new file mode 100644 index 000000000..e06e5d07d --- /dev/null +++ b/src/com/engine/salary/service/impl/SalaryAcctSobConfigServiceImpl.java @@ -0,0 +1,200 @@ +package com.engine.salary.service.impl; + +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.cache.SalaryCacheKey; +import com.engine.salary.entity.salaryacct.bo.SalaryAcctConfig; +import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO; +import com.engine.salary.entity.salaryacct.po.SalaryAcctSobConfigPO; +import com.engine.salary.entity.salaryformula.ExpressFormula; +import com.engine.salary.entity.salaryitem.po.SalaryItemPO; +import com.engine.salary.entity.salarysob.bo.SalarySobItemAggregateBO; +import com.engine.salary.entity.salarysob.dto.SalarySobItemAggregateDTO; +import com.engine.salary.entity.salarysob.po.*; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.mapper.salaryacct.SalaryAcctSobConfigMapper; +import com.engine.salary.service.*; +import com.engine.salary.util.JsonUtil; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.db.MapperProxyFactory; +import org.apache.commons.lang3.StringUtils; +import weaver.hrm.User; + +import java.util.*; + +/** + * 薪资核算的账套副本配置 + *

Copyright: Copyright (c) 2024

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SalaryAcctSobConfigServiceImpl extends Service implements SalaryAcctSobConfigService { + + private SalaryAcctSobConfigMapper getSalaryAcctSobConfigMapper() { + return MapperProxyFactory.getProxy(SalaryAcctSobConfigMapper.class); + } + + private SalaryFormulaService getSalaryFormulaService(User user) { + return ServiceUtil.getService(SalaryFormulaServiceImpl.class, user); + } + + private SalaryItemService getSalaryItemService(User user) { + return ServiceUtil.getService(SalaryItemServiceImpl.class, user); + } + + private SalaryAcctRecordService getSalaryAcctRecordService(User user) { + return ServiceUtil.getService(SalaryAcctRecordServiceImpl.class, user); + } + + private SalarySobService getSalarySobService(User user) { + return ServiceUtil.getService(SalarySobServiceImpl.class, user); + } + + private SalarySobEmpFieldService getSalarySobEmpFieldService(User user) { + return ServiceUtil.getService(SalarySobEmpFieldServiceImpl.class, user); + } + + private SalarySobItemGroupService getSalarySobItemGroupService(User user) { + return ServiceUtil.getService(SalarySobItemGroupServiceImpl.class, user); + } + + private SalarySobItemService getSalarySobItemService(User user) { + return ServiceUtil.getService(SalarySobItemServiceImpl.class, user); + } + + private SalarySobBackItemService getSalarySobBackItemService(User user) { + return ServiceUtil.getService(SalarySobBackItemServiceImpl.class, user); + } + + private SalarySobAdjustRuleService getSalarySobAdjustRuleService(User user) { + return ServiceUtil.getService(SalarySobAdjustRuleServiceImpl.class, user); + } + + private SalarySobCheckRuleService salarySobCheckRuleService; + + private SalaryCacheService getSalaryCacheService(User user) { + return ServiceUtil.getService(SalaryCacheServiceImpl.class, user); + } + + @Override + public SalaryAcctSobConfigPO getBySalaryAcctRecordId(Long salaryAcctRecordId) { + return getBySalaryAcctRecordId(true, salaryAcctRecordId); + } + + @Override + public SalaryAcctConfig getSalaryAcctConfig(Long salaryAcctRecordId) { + SalaryAcctSobConfigPO po = getBySalaryAcctRecordId(true, salaryAcctRecordId); + return SalaryAcctConfig.parse(po); + } + + @Override + public SalaryAcctSobConfigPO getBySalaryAcctRecordId(boolean needInit, Long salaryAcctRecordId) { + SalaryAcctSobConfigPO salaryAcctSobConfig = getSalaryAcctSobConfigMapper().getBySalaryAcctRecordId(salaryAcctRecordId); + if (Objects.nonNull(salaryAcctSobConfig)) { + return salaryAcctSobConfig; + } + // 查询薪资核算记录 + SalaryAcctRecordPO salaryAcctRecord = getSalaryAcctRecordService(user).getById(salaryAcctRecordId); + // 初始化薪资核算记录的列配置 + if (needInit) { + salaryAcctSobConfig = initBySalaryAcctRecord(salaryAcctRecord); + } + return salaryAcctSobConfig; + } + + @Override + public SalarySobItemAggregateDTO getSalarySobItemAggregate(Long salaryAcctRecordId) { + return getSalarySobItemAggregate(true, salaryAcctRecordId); + } + + @Override + public SalarySobItemAggregateDTO getSalarySobItemAggregateNoFormula(Long salaryAcctRecordId) { + return getSalarySobItemAggregate(false, salaryAcctRecordId); + } + + private SalarySobItemAggregateDTO getSalarySobItemAggregate(boolean needFormula, Long salaryAcctRecordId) { + // 查询薪资核算 + SalaryAcctSobConfigPO salaryAcctSobConfig = getBySalaryAcctRecordId(salaryAcctRecordId); + // 薪资账套的基本信息 + SalarySobPO salarySob = JsonUtil.parseObject(salaryAcctSobConfig.getBasicConfig(), SalarySobPO.class); + // 员工信息字段 + List salarySobEmpFields = JsonUtil.parseList(salaryAcctSobConfig.getEmployeeFieldConfig(), SalarySobEmpFieldPO.class); + // 薪资项目分类 + List salarySobItemGroups = JsonUtil.parseList(salaryAcctSobConfig.getItemGroupConfig(), SalarySobItemGroupPO.class); + // 薪资项目 + List salarySobItems = JsonUtil.parseList(salaryAcctSobConfig.getItemConfig(), SalarySobItemPO.class); + // 回算薪资项目 + List salarySobBackItems = JsonUtil.parseList(salaryAcctSobConfig.getBackItemConfig(), SalarySobBackItemPO.class); + // 查询薪资账套的薪资项目所关联的薪资项目 + Set salaryItemIds = SalaryEntityUtil.properties(salarySobItems, SalarySobItemPO::getSalaryItemId); + salaryItemIds.addAll(SalaryEntityUtil.properties(salarySobBackItems, SalarySobBackItemPO::getSalaryItemId)); + List salaryItems = getSalaryItemService(user).listByIds(salaryItemIds); + // 函数公式 + List expressFormulas = Collections.emptyList(); + if (needFormula) { + Set formulaIds = SalaryEntityUtil.properties(salarySobItems, SalarySobItemPO::getFormulaId); + formulaIds.addAll(SalaryEntityUtil.properties(salarySobBackItems, SalarySobBackItemPO::getFormulaId)); + expressFormulas = getSalaryFormulaService(user).listExpressFormula(formulaIds); + } + // 转换成聚合dto + SalarySobItemAggregateBO salarySobItemAggregateBO = new SalarySobItemAggregateBO(salarySob, salarySobEmpFields, + salarySobItemGroups, salarySobItems, expressFormulas, salaryItems, salarySobBackItems, Collections.emptyList()); + return salarySobItemAggregateBO.convert2AggregateDTO(); + } + + @Override + public SalaryAcctSobConfigPO initBySalaryAcctRecord(SalaryAcctRecordPO salaryAcctRecord) { + // 薪资账套的基本信息 + SalarySobPO salarySob = getSalarySobService(user).getById(salaryAcctRecord.getSalarySobId()); + // 薪资账套的员工信息字段 + List salarySobEmpFields = getSalarySobEmpFieldService(user).listBySalarySobId(salaryAcctRecord.getSalarySobId()); + // 薪资账套的薪资项目分类 + List salarySobItemGroups = getSalarySobItemGroupService(user).listBySalarySobId(salaryAcctRecord.getSalarySobId()); + // 薪资账套的薪资项目 + List salarySobItems = getSalarySobItemService(user).listBySalarySobId(salaryAcctRecord.getSalarySobId()); + // 薪资账套的回算薪资项目 + List salarySobBackItemPOS = getSalarySobBackItemService(user).listBySalarySobId(salaryAcctRecord.getSalarySobId()); + + SalaryAcctConfig salaryAcctConfig = new SalaryAcctConfig(salaryAcctRecord, salarySob, salarySobEmpFields, + salarySobItems, salarySobItemGroups, salarySobBackItemPOS, Collections.emptyList(), Collections.emptyList()); + return salaryAcctConfig.buildAcctSobConfig(); + } + + @Override + public synchronized void save(SalaryAcctSobConfigPO salaryAcctSobConfig) { + deleteBySalaryAcctRecordIds(Collections.singleton(salaryAcctSobConfig.getSalaryAcctRecordId())); + getSalaryAcctSobConfigMapper().insertIgnoreNull(salaryAcctSobConfig); + String cacheIndex = salaryAcctSobConfig.getSalaryAcctRecordId().toString(); + getSalaryCacheService(user).set(SalaryCacheKey.ACCT_SOB_CONFIG + cacheIndex, "FALSE"); + } + + @Override + public void updateBySalaryAcctRecordId(Long salaryAcctRecordId) { + SalaryAcctRecordPO salaryAcctRecord = getSalaryAcctRecordService(user).getById(salaryAcctRecordId); + if (salaryAcctRecord == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(156474, "参数错误,薪资核算记录不存在或已被删除")); + } + SalaryAcctSobConfigPO salaryAcctSobConfig = initBySalaryAcctRecord(salaryAcctRecord); + + String acctSobConfigFlag = getSalaryCacheService(user).get(SalaryCacheKey.ACCT_SOB_CONFIG + salaryAcctRecordId); + if (acctSobConfigFlag != null && StringUtils.equals(acctSobConfigFlag, "TRUE")) { + return; + } + getSalaryCacheService(user).set(SalaryCacheKey.ACCT_SOB_CONFIG + salaryAcctRecordId, "TRUE"); + + try { + deleteBySalaryAcctRecordIds(Collections.singleton(salaryAcctRecordId)); + getSalaryAcctSobConfigMapper().insertIgnoreNull(salaryAcctSobConfig); + } finally { + getSalaryCacheService(user).set(SalaryCacheKey.ACCT_SOB_CONFIG + salaryAcctRecordId, "FALSE"); + } + } + + @Override + public void deleteBySalaryAcctRecordIds(Collection salaryAcctRecordIds) { + getSalaryAcctSobConfigMapper().deleteBySalaryAcctRecordIds(salaryAcctRecordIds); + } +} diff --git a/src/com/engine/salary/service/impl/SalaryApprovalRuleServiceImpl.java b/src/com/engine/salary/service/impl/SalaryApprovalRuleServiceImpl.java new file mode 100644 index 000000000..648a08b79 --- /dev/null +++ b/src/com/engine/salary/service/impl/SalaryApprovalRuleServiceImpl.java @@ -0,0 +1,248 @@ +package com.engine.salary.service.impl; + +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO; +import com.engine.salary.entity.salaryitem.param.SalaryItemSearchParam; +import com.engine.salary.entity.salaryitem.po.SalaryItemPO; +import com.engine.salary.entity.salarysob.bo.SalaryApprovalBO; +import com.engine.salary.entity.salarysob.dto.SalaryApprovalDTO; +import com.engine.salary.entity.salarysob.dto.SalarySobItemAggregateDTO; +import com.engine.salary.entity.salarysob.param.ApprovalRequestSaveParam; +import com.engine.salary.entity.salarysob.param.SalaryApprovalQueryParam; +import com.engine.salary.entity.salarysob.po.SalaryApprovalRulePO; +import com.engine.salary.entity.salarysob.po.SalarySobItemPO; +import com.engine.salary.entity.salarysob.po.SalarySobPO; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.mapper.salaryacct.SalaryAcctRecordMapper; +import com.engine.salary.mapper.salarysob.SalaryApprovalRuleMapper; +import com.engine.salary.service.*; +import com.engine.salary.sys.constant.SalarySysConstant; +import com.engine.salary.sys.entity.po.SalarySysConfPO; +import com.engine.salary.sys.service.SalarySysConfService; +import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl; +import com.engine.salary.util.JsonUtil; +import com.engine.salary.util.db.IdGenerator; +import com.engine.salary.util.db.MapperProxyFactory; +import com.engine.salary.util.valid.ValidUtil; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import weaver.conn.RecordSet; +import weaver.hrm.User; + +import java.util.Collection; +import java.util.Collections; +import java.util.Date; +import java.util.List; +import java.util.stream.Collectors; + +/** + * @author Harryxzy + * @ClassName SalaryApprovalRuleServiceImpl + * @date 2024/04/23 17:35 + * @description + */ +public class SalaryApprovalRuleServiceImpl extends Service implements SalaryApprovalRuleService { + + private SalaryApprovalRuleMapper getSalaryApprovalRuleMapper() { + return MapperProxyFactory.getProxy(SalaryApprovalRuleMapper.class); + } + + private SalaryAcctRecordMapper getSalaryAcctRecordMapper() { + return MapperProxyFactory.getProxy(SalaryAcctRecordMapper.class); + } + + private SalaryItemService getSalaryItemService(User user) { + return ServiceUtil.getService(SalaryItemServiceImpl.class, user); + } + + private SalarySobItemService getSalarySobItemService(User user) { + return ServiceUtil.getService(SalarySobItemServiceImpl.class, user); + } + + private SalarySobService getSalarySobService(User user) { + return ServiceUtil.getService(SalarySobServiceImpl.class, user); + } + + private SalaryAcctRecordService getSalaryAcctRecordService(User user) { + return ServiceUtil.getService(SalaryAcctRecordServiceImpl.class, user); + } + + private SalarySysConfService getSalarySysConfService(User user) { + return ServiceUtil.getService(SalarySysConfServiceImpl.class, user); + } + + @Override + public List listAll() { + return getSalaryApprovalRuleMapper().listAll(); + } + + @Override + public SalaryApprovalRulePO getById(Long id) { + return getSalaryApprovalRuleMapper().getById(id); + } + + @Override + public int insertIgnoreNull(SalaryApprovalRulePO po) { + return getSalaryApprovalRuleMapper().insertIgnoreNull(po); + } + + @Override + public int update(SalaryApprovalRulePO salaryApprovalRule) { + return getSalaryApprovalRuleMapper().update(salaryApprovalRule); + } + + @Override + public int updateIgnoreNull(SalaryApprovalRulePO salaryApprovalRule) { + return getSalaryApprovalRuleMapper().updateIgnoreNull(salaryApprovalRule); + } + + @Override + public int delete(SalaryApprovalRulePO salaryApprovalRule) { + return getSalaryApprovalRuleMapper().delete(salaryApprovalRule); + } + + @Override + public SalaryApprovalRulePO getBySalarySobId(Long salarySobId) { + if(salarySobId == null) { + return null; + } + List salaryApprovalRulePOS = getSalaryApprovalRuleMapper().listSome(SalaryApprovalRulePO.builder().salarySobId(salarySobId).build()); + if (CollectionUtils.isNotEmpty(salaryApprovalRulePOS) && salaryApprovalRulePOS.size() == 1) { + return salaryApprovalRulePOS.get(0); + } + return null; + } + + @Override + public void deleteBySalarySobId(Long salarySobId) { + if (salarySobId == null) { + return; + } + getSalaryApprovalRuleMapper().deleteBySalarySobId(salarySobId); + } + + @Override + public SalaryApprovalDTO salaryApprovalForm(SalaryApprovalQueryParam queryParam) { + // 查询薪资审批设置 + SalaryApprovalRulePO approvalRulePO = getBySalarySobId(queryParam.getSalarySobId()); + if (approvalRulePO == null) { + // 没有审批设置信息,创建默认设置信息 + Date now = new Date(); + approvalRulePO = SalaryApprovalRulePO.builder() + .id(IdGenerator.generate()) + .salarySobId(queryParam.getSalarySobId()) + .openApproval(0) + .createTime(now) + .updateTime(now) + .creator(Long.valueOf(user.getUID())) + .deleteType(0) + .build(); + // 获取账套的薪资项目设置信息 + SalarySobItemAggregateDTO aggregateBySalarySobId = getSalarySobItemService(user).getAggregateBySalarySobId(queryParam.getSalarySobId()); + String setting = SalaryApprovalBO.sobItemAggregate2approvalGroupSetting(aggregateBySalarySobId); + approvalRulePO.setApprovalGroupSetting(setting); + insertIgnoreNull(approvalRulePO); + } + + List salaryItemList = getSalaryItemService(user).listAll(); + return SalaryApprovalBO.convert2DTO(approvalRulePO, salaryItemList); + } + + @Override + public void saveSalaryApprovalForm(SalaryApprovalDTO salaryApprovalDTO) { + SalarySobPO salarySobPO = getSalarySobService(user).getById(salaryApprovalDTO.getSalarySobId()); + if (salarySobPO == null) { + throw new RuntimeException("薪资账套不存在"); + } + // 删除原来的 + deleteBySalarySobId(salaryApprovalDTO.getSalarySobId()); + // 保存最新的 + Date now = new Date(); + SalaryApprovalRulePO po = SalaryApprovalRulePO.builder() + .id(IdGenerator.generate()) + .salarySobId(salaryApprovalDTO.getSalarySobId()) + .openApproval(salaryApprovalDTO.getIsOpenApproval() ? 1 : 0) + .approvalGroupSetting(JsonUtil.toJsonString(salaryApprovalDTO.getApprovalItemGroup())) + .workflowUrl(salaryApprovalDTO.getApprovalWorkflowUrl()) + .createTime(now) + .updateTime(now) + .creator(Long.valueOf(user.getUID())) + .deleteType(0) + .build(); + insertIgnoreNull(po); + } + + @Override + public List listSalaryApprovalItem(SalaryItemSearchParam queryParam) { + List salarySobItemPOS = getSalarySobItemService(user).listBySalarySobId(queryParam.getSalarySobId()); + List salaryItemIds = salarySobItemPOS.stream() + .filter(po -> !queryParam.getExcludeIds().contains(po.getSalaryItemId())) + .map(SalarySobItemPO::getSalaryItemId) + .collect(Collectors.toList()); + List salaryItemPOList = getSalaryItemService(user).listByIds(salaryItemIds); + return salaryItemPOList; + } + + @Override + public SalaryApprovalDTO getApprovalInfoByRecordId(Long salaryAcctRecordId) { + SalaryAcctRecordPO acctRecordPO = getSalaryAcctRecordService(user).getById(salaryAcctRecordId); + if (acctRecordPO == null) { + throw new SalaryRunTimeException("薪资核算记录不存在或已被删除"); + } + SalaryApprovalRulePO approvalRulePO = getBySalarySobId(acctRecordPO.getSalarySobId()); + + List salaryItemList = getSalaryItemService(user).listAll(); + SalaryApprovalDTO salaryApprovalDTO = SalaryApprovalBO.convert2DTO(approvalRulePO, salaryItemList); + // 查询是否可以核算、编辑(默认开启) + salaryApprovalDTO.setCanEdit(getRecordIsCanEdit(acctRecordPO)); + return salaryApprovalDTO; + } + + public boolean getRecordIsCanEdit(SalaryAcctRecordPO acctRecordPO) { + // 审批总开关,默认关闭 + SalarySysConfPO approvalStatus = getSalarySysConfService(user).getOneByCode(SalarySysConstant.SALARY_APPROVAL_STATUS); + if (approvalStatus == null || approvalStatus.getConfValue().equals("0")) { + return true; + } + // 查询是否可以核算、编辑(默认开启) + SalarySysConfPO canEdit = getSalarySysConfService(user).getOneByCode(SalarySysConstant.APPROVAL_CAN_EDIT_RESULT_STATUS); + if (canEdit == null || canEdit.getConfValue().equals("1")) { + return true; + } else { + // 发起审批后不能核损,判断流程id是否存在 + if (StringUtils.isBlank(acctRecordPO.getApprovalId())) { + return true; + } else { + RecordSet rs = new RecordSet(); + rs.execute("SELECT * FROM workflow_requestbase where REQUESTID =" + acctRecordPO.getApprovalId()); + return !rs.next(); + } + } + } + + @Override + public void saveApprovalRequestId(ApprovalRequestSaveParam saveParam) { + ValidUtil.doValidator(saveParam); + // 获取核算记录信息 + SalaryAcctRecordPO salaryAcctRecordPO = getSalaryAcctRecordService(user).getById(saveParam.getSalaryAcctRecordId()); + if (salaryAcctRecordPO == null) { + throw new SalaryRunTimeException("薪资核素记录不存在或已被删除"); + } + salaryAcctRecordPO.setApprovalId(saveParam.getRequestId()); + getSalaryAcctRecordMapper().updateIgnoreNull(salaryAcctRecordPO); + } + + @Override + public void deleteBySalarySobIds(Collection ids) { + ids.stream().forEach(this::deleteBySalarySobId); + } + + @Override + public List listBySalarySobIds(Collection salarySobIds) { + if (CollectionUtils.isEmpty(salarySobIds)) { + return Collections.emptyList(); + } + return getSalaryApprovalRuleMapper().listSome(SalaryApprovalRulePO.builder().salarySobIds(salarySobIds).build()); + } +} diff --git a/src/com/engine/salary/service/impl/SalaryArchiveExcelServiceImpl.java b/src/com/engine/salary/service/impl/SalaryArchiveExcelServiceImpl.java new file mode 100644 index 000000000..4db580e19 --- /dev/null +++ b/src/com/engine/salary/service/impl/SalaryArchiveExcelServiceImpl.java @@ -0,0 +1,870 @@ +package com.engine.salary.service.impl; + +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.biz.SalaryArchiveBiz; +import com.engine.salary.biz.SalaryArchiveItemBiz; +import com.engine.salary.config.SalaryElogConfig; +import com.engine.salary.constant.SalaryDefaultTenantConstant; +import com.engine.salary.constant.SalaryItemConstant; +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.salaryarchive.bo.SalaryArchiveExcelBO; +import com.engine.salary.entity.salaryarchive.dto.SalaryArchiveInitImportDTO; +import com.engine.salary.entity.salaryarchive.dto.SalaryArchiveListDTO; +import com.engine.salary.entity.salaryarchive.param.SalaryArchiveImportActionParam; +import com.engine.salary.entity.salaryarchive.param.SalaryArchiveImportHandleParam; +import com.engine.salary.entity.salaryarchive.param.SalaryArchiveQueryParam; +import com.engine.salary.entity.salaryarchive.po.SalaryArchiveItemPO; +import com.engine.salary.entity.salaryarchive.po.SalaryArchivePO; +import com.engine.salary.entity.salaryitem.po.SalaryItemPO; +import com.engine.salary.entity.salarysob.param.SalarySobRangeSaveParam; +import com.engine.salary.entity.taxagent.dto.TaxAgentManageRangeEmployeeDTO; +import com.engine.salary.entity.taxagent.param.TaxAgentRangeSaveParam; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import com.engine.salary.enums.auth.AuthFilterTypeEnum; +import com.engine.salary.enums.datacollection.UseEmployeeTypeEnum; +import com.engine.salary.enums.salaryarchive.SalaryArchiveImportTypeEnum; +import com.engine.salary.enums.salaryarchive.SalaryArchiveListTypeEnum; +import com.engine.salary.enums.salaryarchive.SalaryArchiveStatusEnum; +import com.engine.salary.service.*; +import com.engine.salary.service.auth.AuthService; +import com.engine.salary.service.auth.AuthServiceImpl; +import com.engine.salary.sys.entity.po.SalarySysConfPO; +import com.engine.salary.sys.service.SalarySysConfService; +import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.SalaryLoggerUtil; +import com.engine.salary.util.excel.ExcelComment; +import com.engine.salary.util.excel.ExcelParseHelper; +import com.engine.salary.util.excel.ExcelSupport; +import com.engine.salary.util.excel.ExcelUtilPlus; +import com.google.common.collect.Lists; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.util.IOUtils; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import weaver.file.ImageFileManager; +import weaver.general.Util; +import weaver.hrm.User; + +import java.io.InputStream; +import java.util.*; +import java.util.stream.Collectors; + +import static com.engine.salary.util.excel.ExcelSupport.EXCEL_TYPE_XLSX; + +/** + * @Description: 薪资档案 + * @Author: wangxiangzhong + * @Date: 2021-11-03 10:51 + */ +public class SalaryArchiveExcelServiceImpl extends Service implements SalaryArchiveExcelService { + + private SalaryArchiveItemService salaryArchiveItemService(User user) { + return ServiceUtil.getService(SalaryArchiveItemServiceImpl.class, user); + } + + + private SalaryArchiveService salaryArchiveService(User user) { + return ServiceUtil.getService(SalaryArchiveServiceImpl.class, user); + } + + + private TaxAgentService getTaxAgentService(User user) { + return ServiceUtil.getService(TaxAgentServiceImpl.class, user); + } + + private SalaryEmployeeService getSalaryEmployeeService(User user) { + return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user); + } + + public TaxAgentManageRangeService getTaxAgentManageRangeService(User user) { + return ServiceUtil.getService(TaxAgentManageRangeServiceImpl.class, user); + } + + private SalarySobRangeService getSalarySobRangeService(User user) { + return ServiceUtil.getService(SalarySobRangeServiceImpl.class, user); + } + + public SalarySysConfService getSalarySysConfService(User user) { + return ServiceUtil.getService(SalarySysConfServiceImpl.class, user); + } + + public AuthService getAuthService(User user) { + return ServiceUtil.getService(AuthServiceImpl.class, user); + } + + private SalaryArchiveBiz salaryArchiveMapper = new SalaryArchiveBiz(); + private SalaryArchiveItemBiz salaryArchiveItemMapper = new SalaryArchiveItemBiz(); + +// private SalaryArchiveSobService salaryArchiveSobService; +// +// private SalaryEmployeeService salaryEmployeeService; +// +// private HrmCommonHrmStatusService hrmCommonHrmStatusService; +// +// private BaseEnvInfoService baseEnvInfoService; + +// @Override +// public void exportList(Map map, SalaryArchiveQueryParam queryParam, Long employeeId, String tenantKey) { +// // 待定薪列表 +// boolean isPendingList = queryParam.getListType().equals(SalaryArchiveListTypeEnum.PENDING); +// // 定薪列表 +// boolean isFixedList = queryParam.getListType().equals(SalaryArchiveListTypeEnum.FIXED); +// // 待停薪列表 +// boolean isSuspendList = queryParam.getListType().equals(SalaryArchiveListTypeEnum.SUSPEND); +// // 停薪列表 +// boolean isStopList = queryParam.getListType().equals(SalaryArchiveListTypeEnum.STOP); +// if (isPendingList) { +// queryParam.setRunStatusList(Arrays.asList(SalaryArchiveStatusEnum.PENDING.getValue())); +// } else if (isFixedList) { +// queryParam.setRunStatusList(Arrays.asList(SalaryArchiveStatusEnum.FIXED.getValue(), SalaryArchiveStatusEnum.SUSPEND.getValue())); +// } else if (isSuspendList) { +// queryParam.setRunStatusList(Arrays.asList(SalaryArchiveStatusEnum.SUSPEND.getValue())); +// } else if (isStopList) { +// queryParam.setRunStatusList(Arrays.asList(SalaryArchiveStatusEnum.STOP_FROM_PENDING.getValue(), SalaryArchiveStatusEnum.STOP_FROM_SUSPEND.getValue())); +// } +// String nameI18n = SalaryI18nUtil.getI18nLabel(85368, "薪资档案") + +// SalaryI18nUtil.getI18nLabel(queryParam.getListType().getLabelId(), queryParam.getListType().getDefaultLabel()); +// String payStartDateI18n = SalaryI18nUtil.getI18nLabel(109527, "起始发薪日期"); +// String payEndDateI18n = SalaryI18nUtil.getI18nLabel(109329, "最后发薪日期"); +// String effectiveTimeI18n = SalaryI18nUtil.getI18nLabel(85904, "生效日期"); +// +// List sheetList = new ArrayList<>(); +// ExcelSheetData excelSheetData = new ExcelSheetData(); +// // 1.工作簿名称 +//// excelSheetData.setSheetName(nameI18n); +//// boolean enableHr = baseEnvInfoService.checkDisplayModule(HrmModuleConstancts.hr, tenantKey); +// List headerList = Lists.newArrayList(); +// headerList.add(SalaryI18nUtil.getI18nLabel(85429, "姓名")); +// headerList.add(SalaryI18nUtil.getI18nLabel(86184, "个税扣缴义务人")); +// headerList.add(SalaryI18nUtil.getI18nLabel(121908, "收入所得项目")); +// headerList.add(SalaryI18nUtil.getI18nLabel(87889, "薪资账套")); +// headerList.add(SalaryI18nUtil.getI18nLabel(86319, "入职日期")); +// headerList.add(SalaryI18nUtil.getI18nLabel(86185, "部门")); +// headerList.add(SalaryI18nUtil.getI18nLabel(86186, "手机号")); +// headerList.add(SalaryI18nUtil.getI18nLabel(86317, "工号")); +//// if (enableHr) { +//// headerList.add(SalaryI18nUtil.getI18nLabel(106277, "身份证号码")); +//// } +// headerList.add(SalaryI18nUtil.getI18nLabel(109332, "人事状态")); +// headerList.add(payStartDateI18n); +// headerList.add(payEndDateI18n); +// if (isFixedList) { +// headerList.add(effectiveTimeI18n); +// } +// // 获取所有可被引用的薪资项目 +// List salaryItems = salaryArchiveItemService.getCanAdjustSalaryItems(tenantKey); +// for (SalaryItemPO salaryItem : salaryItems) { +// headerList.add(salaryItem.getName()); +// } +// // 2.表头 +// excelSheetData.setHeaders(Collections.singletonList(headerList.toArray(new String[]{}))); +// // 获取所有个税扣缴义务人 +// Collection taxAgentList = getTaxAgentService().findAll(tenantKey); +// Collection salaryArchives = salaryArchiveMapper.list(queryParam, tenantKey); +// boolean isSearchIdNo = enableHr && StringUtils.isNotEmpty(queryParam.getIdNo()); +// if (isSearchIdNo) { +// Map idNoEmpMap = salaryEmployeeService +// .mapByEmployeeIds(salaryArchives.stream().map(SalaryArchiveListDTO::getEmployeeId).distinct().collect(Collectors.toList()), tenantKey); +// salaryArchives = salaryArchives.stream().filter(f -> Optional.ofNullable(idNoEmpMap.get(f.getEmployeeId())).orElse("").contains(queryParam.getIdNo())) +// .collect(Collectors.toList()); +// } +// // 开启分权并且不是薪酬模块总管理员 +// boolean isChief = getTaxAgentService().isChief(employeeId, tenantKey); +// if (getTaxAgentService().isOpenDevolution(tenantKey) && !isChief) { +// List taxAgentEmployees = getTaxAgentService().listTaxAgentAndEmployee(employeeId, tenantKey); +// List taxAgentIdsAsAdmin = getTaxAgentService().listAllTaxAgentsAsAdmin(employeeId, tenantKey).stream().map(TaxAgentPO::getId).collect(Collectors.toList()); +// salaryArchives = salaryArchives.stream().filter(f -> +// // 作为管理员 +// taxAgentIdsAsAdmin.contains(f.getTaxAgentId()) +// // 作为分管理员 +// || TaxAgentBO.checkTaxAgentAndEmployee(taxAgentEmployees, f.getTaxAgentId(), f.getEmployeeId()) +// || employeeId.equals(f.getModifier()) +// ).collect(Collectors.toList()); +// } +// Map idNoEmpMap = +// enableHr ? salaryEmployeeService.mapByEmployeeIds(salaryArchives.stream().map(SalaryArchiveListDTO::getEmployeeId).distinct().collect(Collectors.toList()), tenantKey) +// : new HashMap<>(); +// List> listMaps = salaryArchiveService +// .buildSalaryArchiveData(salaryArchives, taxAgentList, salaryItems, idNoEmpMap, employeeId, tenantKey, Boolean.FALSE); +// // 组装数据 +// List> rows = new ArrayList<>(); +// listMaps.forEach(e -> { +// List row = new ArrayList<>(); +// row.add(Optional.ofNullable(e.get("username")).orElse("").toString()); +// row.add(e.get("taxAgentName").toString()); +// row.add(e.get("incomeCategory").toString()); +// row.add(e.get("salarySob").toString()); +// row.add(Optional.ofNullable(e.get("hiredate")).orElse("").toString()); +// row.add(Optional.ofNullable(e.get("departmentName")).orElse("").toString()); +// row.add(Optional.ofNullable(e.get("mobile")).orElse("").toString()); +// row.add(Optional.ofNullable(e.get("jobNum")).orElse("").toString()); +// if (enableHr) { +// row.add(Optional.ofNullable(e.get("idNo")).orElse("").toString()); +// } +// row.add(e.get("employeeStatus").toString()); +// row.add(e.get("payStartDate").toString()); +// row.add(e.get("payEndDate").toString()); +// if (isFixedList) { +// row.add(Optional.ofNullable(e.get("effectiveTime")).orElse("").toString()); +// } +// // 薪资项目数据 +// for (SalaryItemPO salaryItem : salaryItems) { +// row.add(e.containsKey(salaryItem.getId() + SalaryItemConstant.DYNAMIC_SUFFIX) ? (e.get(salaryItem.getId() + SalaryItemConstant.DYNAMIC_SUFFIX) == null ? "" +// : e.get(salaryItem.getId() + SalaryItemConstant.DYNAMIC_SUFFIX).toString()) : ""); +// } +// rows.add(row); +// }); +// // 3.表数据 +// excelSheetData.setRows(rows); +// +// sheetList.add(excelSheetData); +// +// salaryBatchService.simpleExportExcel(ExportExcelInfo.builder() +// .bizId(map.get("biz").toString()) +// .flag(true) +// .userId(employeeId) +// .eteamsId(map.get("eteamsId").toString()) +// .tenantKey(tenantKey) +// .operator(map.get("username").toString()) +// .module(map.get("module").toString()) +// .fileName(nameI18n + SalaryDateUtil.getFormatLocalDateTime(LocalDateTime.now())) +// .handlerName("exportSalaryArchive") +// .dataType(nameI18n) +// .function("exportSalaryArchive").build(), sheetList); +// } + + + @Override + public XSSFWorkbook downloadTemplate(SalaryArchiveQueryParam queryParam) { + // 待定薪列表 + boolean isPendingList = queryParam.getListType().equals(SalaryArchiveListTypeEnum.PENDING); + // 定薪列表 + boolean isFixedList = queryParam.getListType().equals(SalaryArchiveListTypeEnum.FIXED); + // 待停薪列表 + boolean isSuspendList = queryParam.getListType().equals(SalaryArchiveListTypeEnum.SUSPEND); + if (isPendingList) { + queryParam.setRunStatusList(Arrays.asList(SalaryArchiveStatusEnum.PENDING.getValue())); + } else if (isFixedList) { + queryParam.setRunStatusList(Arrays.asList(SalaryArchiveStatusEnum.FIXED.getValue(), SalaryArchiveStatusEnum.SUSPEND.getValue())); + } else if (isSuspendList) { + queryParam.setRunStatusList(Arrays.asList(SalaryArchiveStatusEnum.SUSPEND.getValue())); + } + + boolean isInit = queryParam.getImportType().equals(SalaryArchiveImportTypeEnum.INIT.getValue()); + boolean isSalaryItemAdjust = queryParam.getImportType().equals(SalaryArchiveImportTypeEnum.SALARYITEMADJUST.getValue()); + // 名称 + String nameI18n = SalaryI18nUtil.getI18nLabel(101601, "薪资档案导入模板") + + SalaryI18nUtil.getI18nLabel(queryParam.getListType().getLabelId(), queryParam.getListType().getDefaultLabel()); + if (isFixedList) { + // 初始化 + if (isInit) { + nameI18n += + "-" + SalaryI18nUtil.getI18nLabel(SalaryArchiveImportTypeEnum.INIT.getLabelId(), SalaryArchiveImportTypeEnum.INIT.getDefaultLabel()); + // 调薪 + } else if (isSalaryItemAdjust) { + nameI18n += "-" + SalaryI18nUtil + .getI18nLabel(SalaryArchiveImportTypeEnum.SALARYITEMADJUST.getLabelId(), SalaryArchiveImportTypeEnum.SALARYITEMADJUST.getDefaultLabel()); + } + } + String finalNameI18n = nameI18n; + + // 获取所有可被引用的薪资项目 + List salaryItems = salaryArchiveItemService(user).getCanAdjustSalaryItems(); +// boolean enableHr = baseEnvInfoService.checkDisplayModule(HrmModuleConstancts.hr, tenantKey); + List header = Lists.newArrayList(); + header.add(SalaryI18nUtil.getI18nLabel(85429, "姓名")); + header.add(SalaryI18nUtil.getI18nLabel(86184, "个税扣缴义务人")); +// header.add(SalaryI18nUtil.getI18nLabel(121908, "收入所得项目")); +// header.add(SalaryI18nUtil.getI18nLabel(87889, "薪资账套")); +// header.add(SalaryI18nUtil.getI18nLabel(86319, "入职日期")); + header.add(SalaryI18nUtil.getI18nLabel(86185, "部门")); + header.add(SalaryI18nUtil.getI18nLabel(1933, "工号")); + header.add(SalaryI18nUtil.getI18nLabel(86186, "手机号")); + header.add(SalaryI18nUtil.getI18nLabel(86186, "证件号码")); + header.add(SalaryI18nUtil.getI18nLabel(15890, "员工状态")); +// if (enableHr) { +// header.add(SalaryI18nUtil.getI18nLabel(106277, "身份证号码")); +// } +// header.add(SalaryI18nUtil.getI18nLabel(109332, "人事状态")); + String payStartDateI18n = SalaryI18nUtil.getI18nLabel(109527, "起始发薪日期"); + String payEndDateI18n = SalaryI18nUtil.getI18nLabel(109329, "最后发薪日期"); + String adjustReasonI18n = SalaryI18nUtil.getI18nLabel(85431, "调整原因"); + String effectiveTimeI18n = SalaryI18nUtil.getI18nLabel(85904, "生效日期"); + if (isPendingList) { + header.add(payStartDateI18n); + header.add(payEndDateI18n); + } else if (isFixedList) { + if (isInit) { + header.add(payStartDateI18n); + header.add(payEndDateI18n); + header.add(effectiveTimeI18n); + } else if (isSalaryItemAdjust) { + header.add(adjustReasonI18n); + header.add(effectiveTimeI18n); + } + } else if (isSuspendList) { + header.add(payStartDateI18n); + header.add(payEndDateI18n); + } + for (SalaryItemPO salaryItem : salaryItems) { + header.add(salaryItem.getName()); + } + // 2.表头 + List> rows = new ArrayList<>(); + rows.add(header); + // 获取所有个税扣缴义务人 + Collection taxAgentList = getTaxAgentService(user).listAll(); + List salaryArchives = salaryArchiveService(user).getSalaryArchiveList(queryParam); + salaryArchives = getAuthService(user).auth(salaryArchives, AuthFilterTypeEnum.ADMIN_DATA, SalaryArchiveListDTO.class); + + if (queryParam.getHasData()) { + List> listMaps = salaryArchiveService(user) + .buildSalaryArchiveData(salaryArchives, taxAgentList, salaryItems, Boolean.FALSE); + // 组装数据 + listMaps.forEach(e -> { + List row = new ArrayList<>(); + row.add(e.get("username").toString()); + row.add(e.get("taxAgentName").toString()); +// row.add(e.get("incomeCategory").toString()); +// row.add(e.get("salarySob").toString()); +// row.add(e.get("hiredate")); + row.add(Optional.ofNullable(e.get("departmentName")).orElse("").toString()); + row.add(Optional.ofNullable(e.get("workcode")).orElse("").toString()); + row.add(e.get("mobile") == null ? "" : e.get("mobile").toString()); + row.add(Util.null2String(e.get("idNo"))); + row.add(Util.null2String(e.get("employeeStatus"))); +// if (enableHr) { +// row.add(Optional.ofNullable(e.get("idNo")).orElse("").toString()); +// } +// row.add(e.get("employeeStatus").toString()); + if (isPendingList) { + row.add(e.get("payStartDate").toString()); + row.add(e.get("payEndDate").toString()); + } else if (isFixedList) { + if (isInit) { + row.add(e.get("payStartDate").toString()); + row.add(e.get("payEndDate").toString()); + row.add(Optional.ofNullable(e.get("effectiveTime")).orElse("").toString()); + } else if (isSalaryItemAdjust) { + row.add(Optional.ofNullable(e.get("adjustReason")).orElse("").toString()); + row.add(Optional.ofNullable(e.get("effectiveTime")).orElse("").toString()); + } + } else if (isSuspendList) { + row.add(e.get("payStartDate").toString()); + row.add(e.get("payEndDate").toString()); + } + // 薪资项目数据 + for (SalaryItemPO salaryItem : salaryItems) { + row.add(e.containsKey(salaryItem.getId() + SalaryItemConstant.DYNAMIC_SUFFIX) ? (e.get(salaryItem.getId() + SalaryItemConstant.DYNAMIC_SUFFIX) == null ? "" + : e.get(salaryItem.getId() + SalaryItemConstant.DYNAMIC_SUFFIX).toString()) : ""); + } + rows.add(row); + }); + } + + + // 4.注释 + List excelComments = Lists.newArrayList(); + String requireI18n = SalaryI18nUtil.getI18nLabel(100344, "必填"); + excelComments.add(new ExcelComment(0, 0, 1, 2, requireI18n)); + excelComments.add(new ExcelComment(1, 0, 2, 2, requireI18n)); + //收入所得项目 +// List incomeCategoryOptions = Arrays.stream(IncomeCategoryEnum.values()).map(e -> +// SalaryI18nUtil.getI18nLabel(e.getLabelId(), e.getDefaultLabel()) +// ).collect(Collectors.toList()); +// SalaryArchiveExcelBO +// .createExcelComment(excelComments, SalaryI18nUtil.getI18nLabel(121922, "必填,可填写如:") + Joiner.on(",").join(incomeCategoryOptions), 0, 0, 2, 2); +// SalaryArchiveExcelBO.createExcelComment(excelComments, requireI18n + ',' + SalaryI18nUtil.getI18nLabel(127641, "多个账套之间用,分隔"), 0, 0, 3, 3); +// int i = enableHr ? 10 : 9; + if (isPendingList) { + excelComments.add(new ExcelComment(7, 0, 9, 2, SalaryI18nUtil.getI18nLabel(100458, "格式样例为'2022-01-01'、'2022/1/1'"))); +// excelComments.add(new ExcelComment(5, 0, 8, 2, SalaryI18nUtil.getI18nLabel(100458, "格式样例为'2022-01-01'、'2022/1/1'"))); + } else if (isFixedList) { + if (isInit) { + excelComments.add(new ExcelComment(7, 0, 9, 2, SalaryI18nUtil.getI18nLabel(100458, "必填,格式样例为'2022-01-01'、'2022/1/1'"))); + excelComments.add(new ExcelComment(8, 0, 10, 2, SalaryI18nUtil.getI18nLabel(100458, "格式样例为'2022-01-01'、'2022/1/1'"))); + excelComments.add(new ExcelComment(9, 0, 11, 2, SalaryI18nUtil.getI18nLabel(100458, "必填,格式样例为'2022-01-01'、'2022/1/1'"))); + } else if (isSalaryItemAdjust) { + excelComments.add(new ExcelComment(7, 0, 9, 2, SalaryI18nUtil.getI18nLabel(100458, "必填,可填写如:入职,转正,调薪,晋升,降职,调岗,调岗调薪,离职,其他,初始化"))); + excelComments.add(new ExcelComment(8, 0, 10, 2, SalaryI18nUtil.getI18nLabel(100458, "必填,格式样例为'2022-01-01'、'2022/1/1'"))); + } + } else if (isSuspendList) { +// SalaryArchiveExcelBO.createExcelComment(excelComments, SalaryI18nUtil.getI18nLabel(109736, "格式样例为'2022-01-01'、'2022/1/1'"), 0, 0, i + 1, i + 1); + } + +// return ExcelUtil.genWorkbookV2(rows, finalNameI18n, excelComments); + return ExcelUtilPlus.genWorkbookV2(rows, finalNameI18n, excelComments); + } + +// /** +// * 导入薪资档案 +// */ +// @BatchImportHandler("importSalaryArchive") +// @Transactional(rollbackFor = Exception.class) +// public void importSalaryArchive() { +// BatchDocumentMessage message = BatchImportContext.getBatchDocumentMessage(); +// log.info("【薪资档案】接收到上传的数据:{}", String.format("batchTaskId=%s, fileName=%s", message.getBatchTaskId(), message.getBatchFile().getName())); +// // 租户key +// String tenantKey = message.getTenantKey().toLowerCase(); +// try { +// // 加密用 +// DSTenantKeyThreadVar.tenantKey.set(tenantKey); +// // 接收到解析的数据 +// batchImportEbatch(message); +// } catch (Exception e) { +// log.error("【薪资档案】导入失败:{}", String.format("batchTaskId=%s,错误信息=%s", message.getBatchTaskId(), e.getMessage())); +// } finally { +// // 加密用 +// DSTenantKeyThreadVar.tenantKey.remove(); +// } +// } + + + public Map batchImportEbatch(SalaryArchiveImportHandleParam param) { + // 初始化国际化标签 + SalaryArchiveExcelBO.initI18n(); + + String imageId = param.getImageId(); + // 构建导入需要的数据 + SalaryArchiveImportHandleParam importHandleParam = buildImportHandleParam(param); + + InputStream fileInputStream = null; + try { + fileInputStream = ImageFileManager.getInputStreamById(Integer.parseInt(imageId)); + Sheet sheet = ExcelSupport.parseFile(fileInputStream, 0, EXCEL_TYPE_XLSX); + + + int total = 0; + //excel数据 + List> data = ExcelParseHelper.parse2Map(sheet, 1); + if (data != null) { + total += data.size(); + } + + int index = 0; + int successCount = 0; + int errorCount = 0; + // 错误excel内容 +// List errorExcelSheets = new ArrayList<>(); + // 用于(初始化导入)的相同employeeId时的处理 + List initImportData = Lists.newArrayList(); + // 用于(调薪和调整个税扣缴义务人)的相同employeeId时取第一条记录,如果是初始化导入则有重复 + List allTodoSalaryArchives = Lists.newArrayList(); +// if (excelSheet.getHeader().size() == 0) { +// continue; +// } + List headers = ExcelSupport.getSheetHeader(sheet, 0); + + // 错误提示 + List> excelComments = new ArrayList<>(); + HashMap message = new HashMap(); + boolean isValidHeader = checkHeaders(importHandleParam, message, headers); + if (!isValidHeader) { + excelComments.add(message); + Map apidatas = new HashMap<>(); + apidatas.put("successCount", successCount); + apidatas.put("errorCount", errorCount); + apidatas.put("errorNotice", excelComments); + return apidatas; + } + int effectiveTimeIndex = 0; + for (int j = 0; j < headers.size(); j++) { + String header = headers.get(j); + String key = header; + if (key.equals(SalaryI18nUtil.getI18nLabel(85904, "生效日期"))) { + effectiveTimeIndex = j; + } + } + // 错误sheet数据 + List> errorData = new ArrayList<>(); + // 获取匹配规则 + SalarySysConfPO salarySysConfPO = getSalarySysConfService(user).getOneByCode("matchEmployeeMode"); + String confValue = (salarySysConfPO != null && salarySysConfPO.getConfValue() != null && !"".equals(salarySysConfPO.getConfValue())) ? salarySysConfPO.getConfValue() : "0"; + + Map map; + for (int i = 0; i < data.size(); i++) { + index += 1; + map = data.get(i); + map.put("index", i + 2); + // 3.校验行内容 + boolean isError = SalaryArchiveExcelBO.singleRowCheck(allTodoSalaryArchives, map, headers, effectiveTimeIndex, excelComments, errorCount, importHandleParam, user); + if (isError) { + errorCount += 1; + // 添加错误数据 + errorData.add(map); + } else { + successCount += 1; + } + // 初始化导入对重复记录校验 + if (importHandleParam.isInit()) { + Map validMap = SalaryArchiveExcelBO + .validInitImportData(isError, i + 1, map, excelComments, errorCount, successCount, errorData, initImportData, importHandleParam); + errorCount = Integer.parseInt(validMap.getOrDefault("errorCount", errorCount).toString()); + successCount = Integer.parseInt(validMap.getOrDefault("successCount", successCount).toString()); + } + // 导入进度 +// if (index % 100 == 0 || index >= total) { +// salaryBatchService.sendImportRate(message.getBizId(), total, index); +// } + } + + // 如果sheet包含错误数据 + if (CollectionUtils.isNotEmpty(errorData)) { +// salaryBatchService.createErrorExcelSheet(headers, errorData, excelSheet.getName(), excelComments, errorExcelSheets); + } + + // 4.数据入库处理 + if (!param.isOnlyCheck()) { + handleImportData(importHandleParam); + } + + Map apidatas = new HashMap<>(); + + apidatas.put("successCount", successCount); + apidatas.put("errorCount", errorCount); + apidatas.put("errorNotice", excelComments); + return apidatas; + + // 发送导入回调信息 +// salaryBatchService.sendImportCallBackInfo(message, successCount, errorCount, errorExcelSheets); + + } finally { + IOUtils.closeQuietly(fileInputStream); + } + } + + + public Map processInit(SalaryArchiveImportActionParam param) { + // 初始化国际化标签 + SalaryArchiveExcelBO.initI18n(); + + + // 构建导入需要的数据 + SalaryArchiveImportHandleParam importHandleParam = buildImportHandleParam(SalaryArchiveImportHandleParam.builder().isProcess(true).listType(param.getListType()).importType(param.getImportType()).description(param.getDescription()).build()); + importHandleParam.setKeepStatus(param.getKeepStatus()); + + int total = 0; + //excel数据 + // 需要导入的数据 + List> data = param.getImportDatas(); + if (data != null) { + total += data.size(); + } + + int index = 0; + int successCount = 0; + int errorCount = 0; + // 错误excel内容 +// List errorExcelSheets = new ArrayList<>(); + // 用于(初始化导入)的相同employeeId时的处理 + List initImportData = Lists.newArrayList(); + // 用于(调薪和调整个税扣缴义务人)的相同employeeId时取第一条记录,如果是初始化导入则有重复 + List allTodoSalaryArchives = Lists.newArrayList(); + + + // 错误提示 + List> excelComments = new ArrayList<>(); + HashMap message = new HashMap(); + + // 错误sheet数据 + List> errorData = new ArrayList<>(); + + for (int i = 0; i < data.size(); i++) { + Map map = data.get(i); + List headers = Lists.newArrayList(); + map.keySet().forEach(headers::add); + int effectiveTimeIndex = 0; + for (int j = 0; j < headers.size(); j++) { + String header = headers.get(j); + String key = header; + if (key.equals(SalaryI18nUtil.getI18nLabel(85904, "生效日期"))) { + effectiveTimeIndex = j; + } + } + boolean isValidHeader = checkHeaders(importHandleParam, message, headers); + if (!isValidHeader) { + excelComments.add(message); + Map apidatas = new HashMap<>(); + apidatas.put("successCount", successCount); + apidatas.put("errorCount", errorCount); + apidatas.put("errorNotice", excelComments); + return apidatas; + } + + index += 1; + map = data.get(i); + map.put("index", i + 2); + // 3.校验行内容 + boolean isError = SalaryArchiveExcelBO.singleRowCheck(allTodoSalaryArchives, map, headers, effectiveTimeIndex, excelComments, errorCount, importHandleParam, user); + if (isError) { + errorCount += 1; + // 添加错误数据 + errorData.add(map); + } else { + successCount += 1; + } + // 初始化导入对重复记录校验 + if (importHandleParam.isInit()) { + Map validMap = SalaryArchiveExcelBO + .validInitImportData(isError, i, map, excelComments, errorCount, successCount, errorData, initImportData, importHandleParam); + errorCount = Integer.parseInt(validMap.getOrDefault("errorCount", errorCount).toString()); + successCount = Integer.parseInt(validMap.getOrDefault("successCount", successCount).toString()); + } + // 导入进度 +// if (index % 100 == 0 || index >= total) { +// salaryBatchService.sendImportRate(message.getBizId(), total, index); +// } + } + + // 如果sheet包含错误数据 + if (CollectionUtils.isNotEmpty(errorData)) { +// salaryBatchService.createErrorExcelSheet(headers, errorData, excelSheet.getName(), excelComments, errorExcelSheets); + } + + // 4.数据入库处理 + if (param.isAddData()) { + handleImportData(importHandleParam); + } + + Map apidatas = new HashMap<>(); + + apidatas.put("successCount", successCount); + apidatas.put("errorCount", errorCount); + apidatas.put("errorNotice", excelComments); + return apidatas; + + // 发送导入回调信息 +// salaryBatchService.sendImportCallBackInfo(message, successCount, errorCount, errorExcelSheets); + + } + + + /** + * 构建导入处理参数 + * + * @param param + * @return + */ + private SalaryArchiveImportHandleParam buildImportHandleParam(SalaryArchiveImportHandleParam param) { + + // 列表类型 + String listType = param.getListType(); + // 导入类型 + String importType = param.getImportType(); + + // 获取所有可被引用的薪资项目 + List salaryItems = salaryArchiveItemService(user).getCanAdjustSalaryItems(); + Collection salaryItemIds = salaryItems.stream().map(SalaryItemPO::getId).collect(Collectors.toList()); + Collection taxAgentList; + if (param.isProcess()) { + // 获取所有个税扣缴义务人 + taxAgentList = getTaxAgentService(user).listTaxAgentAndEmployeeTree(); + } else { + taxAgentList = getTaxAgentService(user).listTaxAgentAndEmployeeTree((long) user.getUID()); + } + + // 待定薪列表 + boolean isPendingList = listType.equals(SalaryArchiveListTypeEnum.PENDING.getValue()); + // 定薪列表 + boolean isFixedList = listType.equals(SalaryArchiveListTypeEnum.FIXED.getValue()); + // 待停薪列表 + boolean isSuspendList = listType.equals(SalaryArchiveListTypeEnum.SUSPEND.getValue()); + + boolean isInit = isFixedList && importType.equals(SalaryArchiveImportTypeEnum.INIT.getValue()); + boolean isSalaryItemAdjust = isFixedList && importType.equals(SalaryArchiveImportTypeEnum.SALARYITEMADJUST.getValue()); + // 初始化导入是先删除后增的,起始可以只加载非加密的列 + boolean isNoNeedSalaryItem = isPendingList || isInit; + + List runStatusList = Lists.newArrayList();// 初始化导入是全量 + if (isPendingList) { + runStatusList = Arrays.asList(SalaryArchiveStatusEnum.PENDING.getValue()); + } else if (isSalaryItemAdjust) { + runStatusList = Arrays.asList(SalaryArchiveStatusEnum.FIXED.getValue(), SalaryArchiveStatusEnum.SUSPEND.getValue()); + } else if (isSuspendList) { + runStatusList = Arrays.asList(SalaryArchiveStatusEnum.FIXED.getValue(), SalaryArchiveStatusEnum.SUSPEND.getValue()); + } + List salaryArchiveList = salaryArchiveService(user).listSome(SalaryArchivePO.builder().runStatusList(runStatusList).build()); + List salaryArchiveIds = salaryArchiveList.stream().map(SalaryArchivePO::getId).collect(Collectors.toList()); + Map salaryArchivesMap = SalaryEntityUtil.convert2Map(salaryArchiveList, k -> k.getEmployeeId() + "-" + k.getTaxAgentId()); + + UseEmployeeTypeEnum empType = UseEmployeeTypeEnum.ORG; + //外部人员导入 + if (param.isExtEmp()) { + empType = UseEmployeeTypeEnum.EXT; + } + return SalaryArchiveImportHandleParam.builder() + .isProcess(param.isProcess()) + .description(param.getDescription()) + .listType(listType) + .importType(importType) + .currentEmployeeId((long) user.getUID()) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + //人员定位方式 + .empValidType(getSalaryEmployeeService(user).empValidType()) + // 待定薪列表 + .isPendingList(isPendingList) + // 定薪列表 + .isFixedList(isFixedList) + // 待停薪列表 + .isSuspendList(isSuspendList) + //外部人员 + .isExtEmp(param.isExtEmp()) + // 初始化导入 + .isInit(isInit) + // 调薪导入 + .isSalaryItemAdjust(isSalaryItemAdjust) + // 获取租户下所有的人员 + .employees(getSalaryEmployeeService(user).listAll(empType)) +// .hrmStatusList(hrmStatusList) + // 获取所有个税扣缴义务人 + .taxAgentList(taxAgentList) + .salaryItems(salaryItems) + // 查询已有的薪资档案基本数据 + .salaryArchivesMap(salaryArchivesMap) + .salaryItemIds(salaryItemIds) + // 查询已生效的薪资项目数据 + .effectiveItemListMap( + isSuspendList ? Collections.emptyMap() : salaryArchiveItemService(user).getEffectiveItemListMap(salaryArchiveIds, isNoNeedSalaryItem, salaryItemIds)) + // 查询未生效的薪资项目数据 + .ineffectiveItemListMap( + isSuspendList ? Collections.emptyMap() : salaryArchiveItemService(user).getIneffectiveItemListMap(salaryArchiveIds, isNoNeedSalaryItem, salaryItemIds)) + // 当前时间 + .nowTime(new Date()) + // 当天 + .today(new Date()) + // 待保存薪资档案 + .salaryArchiveSaves(Lists.newArrayList()) + // 待保存薪资档案-薪资项目 + .salaryArchiveItemSaves(Lists.newArrayList()) + // 待修改薪资档案-薪资项目 + .salaryArchiveUpdates(Lists.newArrayList()) + // 待删除薪资档案-薪资项目 + .salaryArchiveItemDelSalaryItemIds(Lists.newArrayList()) + //人员范围 + .taxAgentRanges(Lists.newArrayList()) + // 薪资账套 +// .salarySobList(salaryArchiveService.getSalarySobList(employeeId, tenantKey)) + // 待保存薪资档案-薪资账套 +// .salaryArchiveSobSaves(Lists.newArrayList()) + .build(); + } + + /** + * 检查参数 + * + * @param message + * @param params + * @return + */ + private boolean checkParams(Map message, Map params) { + boolean isValid = true; + + String errorMsg = SalaryArchiveExcelBO.handleCheckParams(message, params); + // 有错误信息发送 + if (StringUtils.isNotEmpty(errorMsg)) { + // 发送导入回调信息 +// salaryBatchService.sendImportCallBackInfo(message, errorMsg); + isValid = false; + } + return isValid; + } + + /** + * 检查列头 + * + * @param importHandleParam + * @param message + * @param headers + * @return + */ + private boolean checkHeaders(SalaryArchiveImportHandleParam importHandleParam, Map message, List headers) { + boolean isValid = true; + + String errorMsg = SalaryArchiveExcelBO.handleCheckHeaders(importHandleParam, message, headers); + // 有错误信息发送 + if (StringUtils.isNotEmpty(errorMsg)) { + message.put("message", errorMsg); + // 发送导入回调信息 +// salaryBatchService.sendImportCallBackInfo(message, errorMsg); + isValid = false; + } + return isValid; + } + + /** + * 数据落库处理 + * + * @param importHandleParam + */ + private void handleImportData(SalaryArchiveImportHandleParam importHandleParam) { + List salaryArchiveSaves = importHandleParam.getSalaryArchiveSaves(); + List salaryArchiveUpdates = importHandleParam.getSalaryArchiveUpdates(); + List salaryArchiveItemSaves = importHandleParam.getSalaryArchiveItemSaves(); + List salaryArchiveItemDelSalaryItemIds = importHandleParam.getSalaryArchiveItemDelSalaryItemIds(); + List taxAgentRanges = importHandleParam.getTaxAgentRanges(); + List salaryArchiveSobSaves = importHandleParam.getSalaryArchiveSobSaves(); + + Map empMap = SalaryEntityUtil.convert2Map(importHandleParam.getEmployees(), DataCollectionEmployee::getEmployeeId, DataCollectionEmployee::getUsername); + Map taxAgentMap = SalaryEntityUtil.convert2Map(importHandleParam.getTaxAgentList(), TaxAgentManageRangeEmployeeDTO::getTaxAgentId, TaxAgentManageRangeEmployeeDTO::getTaxAgentName); + // 新增薪资档案 + if (CollectionUtils.isNotEmpty(salaryArchiveSaves)) { + // 去除已经存在的,避免重复 + if (CollectionUtils.isNotEmpty(salaryArchiveUpdates)) { + List salaryArchiveUpdateIds = salaryArchiveUpdates.stream().map(SalaryArchivePO::getId).distinct().collect(Collectors.toList()); + salaryArchiveSaves = salaryArchiveSaves.stream().filter(save -> !salaryArchiveUpdateIds.contains(save.getId())).collect(Collectors.toList()); + } + // 薪资档案 + salaryArchiveMapper.batchInsert(salaryArchiveSaves); + } + // 修改薪资档案 + if (CollectionUtils.isNotEmpty(salaryArchiveUpdates)) { + // 查询更新前档案信息 + List oldArchive = salaryArchiveService(user).listSome(SalaryArchivePO.builder().ids(salaryArchiveUpdates.stream().map(SalaryArchivePO::getId).collect(Collectors.toList())).build()); + Map oldArchiveMap = SalaryEntityUtil.convert2Map(oldArchive, SalaryArchivePO::getId); + // 薪资档案 + salaryArchiveMapper.batchUpdate(salaryArchiveUpdates); + // 记录日志 + salaryArchiveUpdates.stream().forEach(a -> { + SalaryArchivePO oldPO = oldArchiveMap.getOrDefault(a.getId(), SalaryArchivePO.builder().build()); + String name = taxAgentMap.getOrDefault(a.getTaxAgentId(), StringUtils.EMPTY) + "-" + empMap.getOrDefault(a.getEmployeeId(), StringUtils.EMPTY); + SalaryLoggerUtil.recordUpdateSingleLog(SalaryElogConfig.salaryArchiveLoggerTemplate, + a.getId(), + name, + SalaryI18nUtil.getI18nLabel(0, "薪资档案导入更新"), + SalaryI18nUtil.getI18nLabel(0, "薪资档案导入更新") + name, + oldPO, + a, + user); + }); + } + // 薪资档案-薪资项目 + if (CollectionUtils.isNotEmpty(salaryArchiveItemDelSalaryItemIds)) { + salaryArchiveItemMapper.deleteBatchIds(salaryArchiveItemDelSalaryItemIds); + } + // 薪资档案-薪资项目 + if (CollectionUtils.isNotEmpty(salaryArchiveItemSaves)) { + salaryArchiveItemMapper.batchInsert(salaryArchiveItemSaves, user); + } + + // 薪资档案-薪资账套 +// salaryArchiveSaves.addAll(salaryArchiveUpdates); +// List salaryArchiveIds = salaryArchiveSaves.stream().map(SalaryArchivePO::getId).distinct().collect(Collectors.toList()); +// if (CollectionUtils.isNotEmpty(salaryArchiveIds) && CollectionUtils.isNotEmpty(salaryArchiveSaves)) { +// this.salaryArchiveSobService.saveBatchBySalaryArchiveIdsAndSaves(salaryArchiveIds, salaryArchiveSobSaves, message.getTenantKey()); +// } + + + //新增人员范围(会自动生成人员档案) + if (CollectionUtils.isNotEmpty(taxAgentRanges)) { + taxAgentRanges.forEach(getTaxAgentManageRangeService(user)::save); + } + + if (CollectionUtils.isNotEmpty(salaryArchiveSobSaves)) { + salaryArchiveSobSaves.forEach(getSalarySobRangeService(user)::save); + } + } +} diff --git a/src/com/engine/salary/service/impl/SalaryArchiveItemServiceImpl.java b/src/com/engine/salary/service/impl/SalaryArchiveItemServiceImpl.java new file mode 100644 index 000000000..c5c9879e8 --- /dev/null +++ b/src/com/engine/salary/service/impl/SalaryArchiveItemServiceImpl.java @@ -0,0 +1,821 @@ +package com.engine.salary.service.impl; + +import cn.hutool.core.util.StrUtil; +import com.api.formmode.mybatis.util.SqlProxyHandle; +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.biz.SalaryArchiveBiz; +import com.engine.salary.biz.SalaryArchiveItemBiz; +import com.engine.salary.biz.SalaryItemBiz; +import com.engine.salary.common.LocalDateRange; +import com.engine.salary.config.SalaryElogConfig; +import com.engine.salary.constant.SalaryDefaultTenantConstant; +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.salaryarchive.config.ArchiveFieldConfig; +import com.engine.salary.entity.salaryarchive.dto.SalaryArchiveListDTO; +import com.engine.salary.entity.salaryarchive.dto.SalaryItemAdjustRecordListDTO; +import com.engine.salary.entity.salaryarchive.param.*; +import com.engine.salary.entity.salaryarchive.po.SalaryArchiveItemPO; +import com.engine.salary.entity.salaryarchive.po.SalaryArchivePO; +import com.engine.salary.entity.salaryitem.param.SalaryItemSearchParam; +import com.engine.salary.entity.salaryitem.po.SalaryItemPO; +import com.engine.salary.entity.taxagent.param.TaxAgentQueryParam; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import com.engine.salary.enums.UserStatusEnum; +import com.engine.salary.enums.auth.AuthFilterTypeEnum; +import com.engine.salary.enums.datacollection.UseEmployeeTypeEnum; +import com.engine.salary.enums.salaryarchive.SalaryArchiveFieldTypeEnum; +import com.engine.salary.enums.salaryarchive.SalaryArchiveItemAdjustReasonEnum; +import com.engine.salary.enums.salaryarchive.SalaryArchiveStatusEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.mapper.archive.SalaryArchiveItemMapper; +import com.engine.salary.mapper.salaryitem.SalaryItemMapper; +import com.engine.salary.service.*; +import com.engine.salary.sys.entity.vo.UploadConfigResponse; +import com.engine.salary.util.SalaryDateUtil; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.SalaryLoggerUtil; +import com.engine.salary.util.db.IdGenerator; +import com.engine.salary.util.db.MapperProxyFactory; +import com.engine.salary.util.excel.ExcelUtil; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.util.valid.ValidUtil; +import com.google.common.collect.Lists; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.math.NumberUtils; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import weaver.hrm.User; + +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.regex.Pattern; +import java.util.stream.Collectors; + +/** + * 薪资档案薪资项目 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Slf4j +public class SalaryArchiveItemServiceImpl extends Service implements SalaryArchiveItemService { + + private SalaryArchiveBiz salaryArchiveMapper = new SalaryArchiveBiz(); + private SalaryItemBiz salaryItemMapper = new SalaryItemBiz(); + private SalaryArchiveItemBiz salaryArchiveItemMapper = new SalaryArchiveItemBiz(); + + private SalaryArchiveItemMapper getSalaryArchiveItemMapper() { + return MapperProxyFactory.getProxy(SalaryArchiveItemMapper.class); + } + + private SalaryItemMapper getSalaryItemMapper() { + return SqlProxyHandle.getProxy(SalaryItemMapper.class); + } + + + @Override + public SalaryArchiveItemPO getById(Long salaryArchiveItemId) { + return salaryArchiveItemMapper.getById(salaryArchiveItemId); + } + + private SalaryArchiveItemService getSalaryArchiveItemService(User user) { + return ServiceUtil.getService(SalaryArchiveItemServiceImpl.class, user); + } + + private TaxAgentService getTaxAgentService(User user) { + return ServiceUtil.getService(TaxAgentServiceImpl.class, user); + } + + private SalaryItemService getSalaryItemService(User user) { + return ServiceUtil.getService(SalaryItemServiceImpl.class, user); + } + + private SalaryArchiveService getSalaryArchiveService(User user) { + return ServiceUtil.getService(SalaryArchiveServiceImpl.class, user); + } + + private SalaryEmployeeService getSalaryEmployeeService(User user) { + return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user); + } + + /** + * 获取未生效 lt + * + * @param salaryArchiveId + * @param salaryItemIds + * @return + */ + private List getIneffectiveSalaryItems(Long salaryArchiveId, List salaryItemIds) { + // 没有薪资项目时,给个不存在的,否则加载所有不合理 + salaryItemIds = CollectionUtils.isEmpty(salaryItemIds) ? Collections.singletonList(0L) : salaryItemIds; + ArrayList salaryArchiveIds = new ArrayList<>(); + salaryArchiveIds.add(salaryArchiveId); + return salaryArchiveItemMapper.getIneffectiveSalaryItems(SalaryArchiveItemQueryParam.builder() + .salaryArchiveId(salaryArchiveId) + .salaryArchivesIds(salaryArchiveIds) + .salaryItemIds(salaryItemIds) + .effectiveTime(new Date()).build()); + } + + private List getIneffectiveSalaryItems(Collection salaryArchivesIds, Collection salaryItemIds) { + // 薪资档案id + List salaryArchiveIds = CollectionUtils.isEmpty(salaryArchivesIds) ? Collections.singletonList(0L) : (List) salaryArchivesIds; + // 没有薪资项目时,给个不存在的,否则加载所有不合理 + salaryItemIds = CollectionUtils.isEmpty(salaryItemIds) ? Collections.singletonList(0L) : salaryItemIds; + return salaryArchiveItemMapper.getIneffectiveSalaryItems(SalaryArchiveItemQueryParam.builder() + .salaryArchivesIds(salaryArchiveIds) + .salaryItemIds(salaryItemIds) + .effectiveTime(new Date()).build()); + } + + + @Override + public List getSalaryItemsBySalaryArchiveIdAndItemIds(Long salaryArchiveId, List salaryItemIds) { + // 没有薪资项目时,给个不存在的,否则加载所有不合理 + salaryItemIds = CollectionUtils.isEmpty(salaryItemIds) ? Collections.singletonList(0L) : salaryItemIds; + return salaryArchiveItemMapper.getEffectiveSalaryItems(SalaryArchiveItemQueryParam.builder() + .salaryArchiveId(salaryArchiveId) + .salaryItemIds(salaryItemIds) + .build()); + } + + /** + * 获取当前已生效 gt + * + * @param salaryArchiveId + * @param salaryItemIds + * @return + */ + @Override + public List getEffectiveSalaryItems(Long salaryArchiveId, List salaryItemIds) { + // 没有薪资项目时,给个不存在的,否则加载所有不合理 + salaryItemIds = CollectionUtils.isEmpty(salaryItemIds) ? Collections.singletonList(0L) : salaryItemIds; + return salaryArchiveItemMapper.getEffectiveSalaryItems(SalaryArchiveItemQueryParam.builder() + .salaryArchiveId(salaryArchiveId) + .salaryItemIds(salaryItemIds) + .effectiveTime(new Date()).build()); + } + + /** + * 获取薪资档案对应的当前生效的薪资项目 + * + * @param salaryArchivesIds + * @return + */ + @Override + public List getCurrentEffectiveItemList(Collection salaryArchivesIds, Collection salaryItemIds) { + // 没有薪资项目时,给个不存在的,否则加载所有不合理 + salaryItemIds = CollectionUtils.isEmpty(salaryItemIds) ? Collections.singletonList(0L) : salaryItemIds; + // 薪资档案id + List salaryArchiveIds = CollectionUtils.isEmpty(salaryArchivesIds) ? Collections.singletonList(0L) : (List) salaryArchivesIds; + List salaryArchiveItems = this.getEffectiveItemList(salaryArchiveIds, salaryItemIds); + return salaryArchiveItems.stream() + .collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(f -> f.getSalaryArchiveId() + "-" + f.getSalaryItemId()))), ArrayList::new)); + } + + /** + * 获取当前已生效列表 + * + * @param salaryArchiveIds + * @param salaryItemIds + * @return + */ + private List getEffectiveItemList(Collection salaryArchiveIds, Collection salaryItemIds) { + List salaryArchiveItems = Lists.newArrayList(); + List> partition = Lists.partition(Lists.newArrayList(salaryArchiveIds), 999); + partition.forEach(part -> salaryArchiveItems.addAll( + salaryArchiveItemMapper.getEffectiveSalaryItems(SalaryArchiveItemQueryParam.builder() + .salaryArchivesIds(part) + .salaryItemIds(salaryItemIds) + .effectiveTime(new Date()).build())) + ); + // 解密 + return salaryArchiveItems; + } + + + @Override + public Map> getEffectiveItemListMap(Collection salaryArchiveIds, boolean isNoNeedSalaryItem, Collection salaryItemIds) { + // 没有薪资项目时,给个不存在的,否则加载所有不合理 + salaryItemIds = CollectionUtils.isEmpty(salaryItemIds) ? Collections.singletonList(0L) : salaryItemIds; + // 薪资档案id + List saIds = CollectionUtils.isEmpty(salaryArchiveIds) ? Collections.singletonList(0L) : (List) salaryArchiveIds; + + List salaryArchiveItems = Lists.newArrayList(); + + if (isNoNeedSalaryItem) { + salaryArchiveItems.addAll(getEffectiveItemList(saIds, salaryItemIds)); + } else { + salaryArchiveItems = this.getEffectiveItemList(saIds, salaryItemIds); + } + + return SalaryEntityUtil.group2Map(salaryArchiveItems, k -> k.getSalaryArchiveId() + "-" + k.getSalaryItemId()); + } + + @Override + public Map> getIneffectiveItemListMap(Collection salaryArchiveIds, boolean isNoNeedSalaryItem, Collection salaryItemIds) { + // 没有薪资项目时,给个不存在的,否则加载所有不合理 + salaryItemIds = CollectionUtils.isEmpty(salaryItemIds) ? Collections.singletonList(0L) : salaryItemIds; + // 薪资档案id + Collection saIds = CollectionUtils.isEmpty(salaryArchiveIds) ? Collections.singletonList(0L) : salaryArchiveIds; + List salaryArchiveItems = Lists.newArrayList(); + + if (isNoNeedSalaryItem) { + salaryArchiveItems.addAll(getIneffectiveSalaryItems(saIds, salaryItemIds)); + } else { + List> partition = Lists.partition((List) saIds, 1000); + Collection finalSalaryItemIds = salaryItemIds; + partition.forEach(part -> { + salaryArchiveItems.addAll(getIneffectiveSalaryItems(saIds, finalSalaryItemIds)); + }); + + } + + return SalaryEntityUtil.group2Map(salaryArchiveItems, k -> k.getSalaryArchiveId() + "-" + k.getSalaryItemId()); + } + + @Override + public String editSingleSalaryItem(SalaryArchiveItemSaveParam salaryArchiveItemSaveParam) { + // 检查参数 + SalaryArchiveItemSaveParam.checkParam(salaryArchiveItemSaveParam); + + Long salaryArchiveId = salaryArchiveItemSaveParam.getSalaryArchiveId(); + // 获取所有可被引用的薪资项目 + List salaryItems = getCanAdjustSalaryItems(); + Map salaryItemMap = SalaryEntityUtil.convert2Map(salaryItems, SalaryItemPO::getId); + // 待处理薪资项目 + List salaryArchiveItems = salaryArchiveItemSaveParam.getSalaryArchiveItems().stream() + .filter(e -> salaryItemMap.containsKey(e.getSalaryItemId())) + .collect(Collectors.toList()); + List salaryItemIds = salaryArchiveItems.stream().map(SalaryArchiveItemDetailSaveParam::getSalaryItemId).collect(Collectors.toList()); + // 薪资档案 + SalaryArchivePO salaryArchive = salaryArchiveMapper.getById(salaryArchiveId); + if (salaryArchive != null) { + // 停薪列表禁止操作 + boolean isDisabled = salaryArchive.getRunStatus().equals(SalaryArchiveStatusEnum.STOP_FROM_PENDING.getValue()) || + salaryArchive.getRunStatus().equals(SalaryArchiveStatusEnum.STOP_FROM_SUSPEND.getValue()); + if (isDisabled) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(115437, "停薪列表禁止操作")); + } + SalaryArchiveItemPO salaryArchiveItem = null; + if (salaryArchiveItemSaveParam.getSalaryArchiveItemId() != null) { + salaryArchiveItem = salaryArchiveItemMapper.getById(salaryArchiveItemSaveParam.getSalaryArchiveItemId()); + if (salaryArchiveItem == null || !salaryArchiveItem.getSalaryArchiveId().equals(salaryArchiveId)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100428, "该薪资档案的薪资项目的调整记录不存在")); + } + if (salaryArchiveItemSaveParam.getSalaryArchiveItems().size() > 1) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(149535, "单个调整不能处理多个薪资项目")); + } else if (!salaryArchiveItems.get(0).getSalaryItemId().equals(salaryArchiveItem.getSalaryItemId())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(149539, "单个调薪的目标项目和调整明细项目id不一致")); + } + } + // 构建更新PO + SalaryArchiveItemPO updateSalaryArchiveItemPO = buildUpdateSalaryArchiveItemPO(salaryArchiveItemSaveParam, salaryArchiveItems, salaryItemIds, salaryArchiveItem); + salaryArchiveItemMapper.updateIgnoreNull(updateSalaryArchiveItemPO); + + // 查询更新后的po + SalaryArchiveItemPO saiNew = salaryArchiveItemMapper.getById(updateSalaryArchiveItemPO.getId()); + // 记录操作日志 + String name = SalaryI18nUtil.getI18nLabel(0, "编辑调薪记录"); + SalaryLoggerUtil.recordUpdateSingleLog(SalaryElogConfig.salaryArchiveItemAdjustLoggerTemplate, + saiNew.getId(), + name + ":" + saiNew.getId(), + name, + name + ":" + saiNew.getId(), + salaryArchiveItem, + saiNew, + user + ); + } + return StringUtils.EMPTY; + } + + + /** + * @return null + * @description 构建薪资档案中调薪的更新PO + * @author Harryxzy + * @date 2022/11/14 14:24 + */ + private SalaryArchiveItemPO buildUpdateSalaryArchiveItemPO(SalaryArchiveItemSaveParam salaryArchiveItemSaveParam, List salaryArchiveItems, List salaryItemIds, SalaryArchiveItemPO salaryArchiveItem) { + // 获取所有可被引用的薪资项目 + List salaryItems = getSalaryArchiveItemService(user).getCanAdjustSalaryItems(); + // 获取生效+未生效的数据 + List salaryItemsBySalaryArchiveIdAndItemIds = getSalaryItemsBySalaryArchiveIdAndItemIds(salaryArchiveItemSaveParam.getSalaryArchiveId(), salaryItemIds); + // 获取当前已生效数据 +// List effectiveSalaryItems = getEffectiveSalaryItems(salaryArchiveItemSaveParam.getSalaryArchiveId(), salaryItemIds); + // 待保存生效时间 + Date saveEffectiveTime = salaryArchiveItemSaveParam.getEffectiveTime(); + salaryArchiveItems.forEach(e -> { + // 已生效 +// List effectiveList = effectiveSalaryItems.stream().filter(i -> i.getSalaryItemId().equals(e.getSalaryItemId())).collect(Collectors.toList()); + // 当前已生效 +// SalaryArchiveItemPO effectiveSalaryItem = CollectionUtils.isNotEmpty(effectiveList) && effectiveList.size() > 0 ? effectiveList.get(0) : null; + List list = salaryItemsBySalaryArchiveIdAndItemIds.stream().filter(i -> i.getSalaryItemId().equals(e.getSalaryItemId())).collect(Collectors.toList()); + // 判断该薪资项目是否是数字 + Optional optional = salaryItems.stream().filter(i -> i.getId().equals(e.getSalaryItemId())).findFirst(); + + if (optional.isPresent()) { + SalaryItemPO salaryItemPO = optional.get(); + boolean isNotNumber = salaryItemPO.getDataType().equals(SalaryArchiveFieldTypeEnum.NUMBER.getValue()) && StringUtils.isNotEmpty(e.getAdjustValue()) && !Pattern.matches(SalaryEntityUtil.NUMBER_REGEX, e.getAdjustValue()); + if (isNotNumber) { + throw new SalaryRunTimeException(salaryItemPO.getName() + ":" + SalaryI18nUtil.getI18nLabel(100581, "请输入数字")); + } + } + + // 修改了生效日期 + if (!salaryArchiveItemSaveParam.getEffectiveTime().equals(salaryArchiveItem.getEffectiveTime())) { + boolean isEffectiveTimeRepeat = list.stream().anyMatch(it -> it.getEffectiveTime().equals(saveEffectiveTime)); + if (isEffectiveTimeRepeat) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(153539, "已经存在该生效日期的调整记录,请修改生效日期")); + } + } + + // 1.检验是否可以调整 +// if (effectiveSalaryItem != null) { + // 当前已经生效的时间 +// Date effectiveTime = effectiveSalaryItem.getEffectiveTime(); + // 1.1 如果保存的生效日期早于<当前已生效 +// if (saveEffectiveTime.before(effectiveTime)) { +// if(salaryArchiveItemSaveParam.getCanOperator() == Boolean.TRUE){ +// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100429, "生效日期不可早于当前已生效的调整日期")); +// } +// // 仅可编辑说明 +// salaryArchiveItemMapper.updateIgnoreNull( SalaryArchiveItemPO.builder().id(salaryArchiveItemSaveParam.getSalaryArchiveItemId()) +// .description(salaryArchiveItemSaveParam.getDescription()).build()); +// } +// } + }); + return SalaryArchiveItemPO.builder().id(salaryArchiveItemSaveParam.getSalaryArchiveItemId()).effectiveTime(salaryArchiveItemSaveParam.getEffectiveTime()).adjustReason(salaryArchiveItemSaveParam.getAdjustReason()) + .description(salaryArchiveItemSaveParam.getDescription()).itemValue(salaryArchiveItemSaveParam.getSalaryArchiveItems().get(0).getAdjustValue()).build(); + } + + + @Override + public List getCurrentEffectiveItemListIngoreValue(Collection salaryArchivesIds, List salaryItemIds) { + // 没有薪资项目时,给个不存在的,否则加载所有不合理 + salaryItemIds = CollectionUtils.isEmpty(salaryItemIds) ? Collections.singletonList(0L) : salaryItemIds; + // 薪资档案id + List salaryArchiveIds = CollectionUtils.isEmpty(salaryArchivesIds) ? Collections.singletonList(0L) : (List) salaryArchivesIds; + + List salaryArchiveItems = Lists.newArrayList(); + List> partition = Lists.partition(Lists.newArrayList(salaryArchiveIds), 999); + List finalSalaryItemIds = salaryItemIds; + partition.forEach(part -> salaryArchiveItems.addAll(salaryArchiveItemMapper.getEffectiveSalaryItems(SalaryArchiveItemQueryParam.builder() + .salaryArchivesIds(finalSalaryItemIds) + .salaryItemIds(finalSalaryItemIds) + .effectiveTime(new Date()).build()))); + return salaryArchiveItems; + } + + @Override + public String getSalaryItemAdjustBeforeValue(SalaryItemAdjustBeforeParam adjustBeforeParam) { + + ValidUtil.doValidator(adjustBeforeParam); + + List archiveItemList; + if (adjustBeforeParam.getSalaryArchiveItemId() == null) { + archiveItemList = getEffectiveSalaryItems(adjustBeforeParam.getSalaryArchiveId(), Collections.singletonList(adjustBeforeParam.getSalaryItemId())); + } else { + SalaryArchiveItemPO salaryArchiveItem = salaryArchiveItemMapper.getById(adjustBeforeParam.getSalaryArchiveItemId()); + if (salaryArchiveItem == null) { + return ""; + } + // 如果不是当前记录的 + if (!salaryArchiveItem.getSalaryItemId().equals(adjustBeforeParam.getSalaryItemId())) { + archiveItemList = getEffectiveSalaryItems(adjustBeforeParam.getSalaryArchiveId(), Collections.singletonList(adjustBeforeParam.getSalaryItemId())); + } else { + archiveItemList = salaryArchiveItemMapper.getIneffectiveSalaryItems(SalaryArchiveItemQueryParam.builder() + .salaryArchiveId(adjustBeforeParam.getSalaryArchiveId()) + .salaryItemId(salaryArchiveItem.getSalaryItemId()) + .effectiveTime(salaryArchiveItem.getEffectiveTime()).build()); + } + } + + return CollectionUtils.isNotEmpty(archiveItemList) ? archiveItemList.get(0).getItemValue() : ""; + } + + @Override + public String saveSalaryItem(SalaryArchiveItemSaveParam saveParam) { + // 检查参数 + SalaryArchiveItemSaveParam.checkParam(saveParam); + + Long salaryArchiveId = saveParam.getSalaryArchiveId(); + // 获取所有可被引用的薪资项目 + List salaryItems = getCanAdjustSalaryItems(); + // 待处理薪资项目 + List salaryArchiveItems = saveParam.getSalaryArchiveItems().stream().filter(e -> { + Optional optional = salaryItems.stream().filter(i -> i.getId().equals(e.getSalaryItemId())).findFirst(); + return optional.isPresent(); + }).collect(Collectors.toList()); + List salaryItemIds = salaryArchiveItems.stream().map(SalaryArchiveItemDetailSaveParam::getSalaryItemId).collect(Collectors.toList()); + + // 薪资档案 + SalaryArchivePO salaryArchive = salaryArchiveMapper.getById(salaryArchiveId); + if (salaryArchive == null) { + throw new SalaryRunTimeException("薪资档案不存在!"); + } + + + // 获取当前已生效数据 + List effectiveSalaryItems = getEffectiveSalaryItems(salaryArchiveId, salaryItemIds); + + // 获取未生效数据 + List ineffectiveSalaryItems = getIneffectiveSalaryItems(salaryArchiveId, salaryItemIds); + // 待保存生效时间 + Date saveEffectiveTime = saveParam.getEffectiveTime(); + // 当天 + Date today = new Date(); + // 当前时间 + Date nowTime = new Date(); + + List effectiveSalaryItemDels = Lists.newArrayList(); + List salaryArchiveItemNews = Lists.newArrayList(); + salaryArchiveItems.forEach(e -> { + // 已生效 + List effectiveList = effectiveSalaryItems.stream().filter(i -> i.getSalaryItemId().equals(e.getSalaryItemId())).collect(Collectors.toList()); + // 当前已生效 + SalaryArchiveItemPO effectiveSalaryItem = CollectionUtils.isNotEmpty(effectiveList) && effectiveList.size() > 0 ? effectiveList.get(0) : null; + // 当前已生效的前一次调整 + SalaryArchiveItemPO effectiveBeforeSalaryItem = CollectionUtils.isNotEmpty(effectiveList) && effectiveList.size() > 1 ? effectiveList.get(1) : null; + // 未生效 + Optional optionalIneffective = ineffectiveSalaryItems.stream().filter(i -> i.getSalaryItemId().equals(e.getSalaryItemId())).findFirst(); + SalaryArchiveItemPO ineffectiveSalaryItem = optionalIneffective.orElse(null); + + // 1.检验是否可以调整 + if (effectiveSalaryItem != null) { + // 当前已经生效的时间 + Date effectiveTime = effectiveSalaryItem.getEffectiveTime(); + // 1.1 如果早于<当前已生效 + if (saveEffectiveTime.before(effectiveTime)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100429, "生效日期不可早于当前已生效的调整日期")); + // 1.2 如果等于当前已生效 fixme 日期比较可能有bug + } else if (saveEffectiveTime.equals(effectiveTime)) { + if (effectiveBeforeSalaryItem != null && effectiveBeforeSalaryItem.getItemValue().equals(e.getAdjustValue())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100432, "调整前后不可相同")); + } + if (ineffectiveSalaryItem != null && ineffectiveSalaryItem.getItemValue().equals(e.getAdjustValue())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100434, "与未生效的调整后不可相同")); + } + // 1.3 如果>已经生效且<=今天 + } else if (saveEffectiveTime.after(effectiveTime) && !saveEffectiveTime.after(today)) { + if (effectiveSalaryItem.getItemValue().equals(e.getAdjustValue())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100432, "调整前后不可相同")); + } + if (ineffectiveSalaryItem != null && ineffectiveSalaryItem.getItemValue().equals(e.getAdjustValue())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100434, "与未生效的调整后不可相同")); + } + // 1.4 如果>今天 + } else if (saveEffectiveTime.after(today) && effectiveSalaryItem.getItemValue().equals(e.getAdjustValue())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100432, "调整前后不可相同")); + } + } else if (ineffectiveSalaryItem != null && ineffectiveSalaryItem.getItemValue().equals(e.getAdjustValue())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100434, "与未生效的调整后不可相同")); + } + // 2.数据处理 + if (effectiveSalaryItem != null && saveEffectiveTime.equals(effectiveSalaryItem.getEffectiveTime())) { + effectiveSalaryItemDels.add(effectiveSalaryItem.getId()); + } + if (ineffectiveSalaryItem != null && saveEffectiveTime.after(today)) { + effectiveSalaryItemDels.add(ineffectiveSalaryItem.getId()); + } + salaryArchiveItemNews.add(buildInsert(salaryArchive, e.getSalaryItemId(), e.getAdjustValue(), saveParam, nowTime)); + }); + + // 落库处理 + if (CollectionUtils.isNotEmpty(effectiveSalaryItemDels)) { + salaryArchiveItemMapper.deleteBatchIds(effectiveSalaryItemDels); + } + if (CollectionUtils.isNotEmpty(salaryArchiveItemNews)) { + salaryArchiveItemMapper.batchInsert(salaryArchiveItemNews, user); + } + + return StringUtils.EMPTY; + } + + @Override + public String checkSaveSalaryItem(SalaryArchiveItemSaveParam saveParam) { + // 检查参数 + SalaryArchiveItemSaveParam.checkParam(saveParam); + + Long salaryArchiveId = saveParam.getSalaryArchiveId(); + // 获取所有可被引用的薪资项目 + List salaryItems = getCanAdjustSalaryItems(); + // 待处理薪资项目 + List salaryArchiveItems = saveParam.getSalaryArchiveItems().stream().filter(e -> { + Optional optional = salaryItems.stream().filter(i -> i.getId().equals(e.getSalaryItemId())).findFirst(); + return optional.isPresent(); + }).collect(Collectors.toList()); + List salaryItemIds = salaryArchiveItems.stream().map(SalaryArchiveItemDetailSaveParam::getSalaryItemId).collect(Collectors.toList()); + + // 薪资档案 + SalaryArchivePO salaryArchive = salaryArchiveMapper.getById(salaryArchiveId); + // 获取当前已生效数据 + List effectiveSalaryItems = getEffectiveSalaryItems(salaryArchiveId, salaryItemIds); + + // 获取未生效数据 + List ineffectiveSalaryItems = getIneffectiveSalaryItems(salaryArchiveId, salaryItemIds); + // 待保存生效时间 + Date saveEffectiveTime = saveParam.getEffectiveTime(); + // 当天 + Date today = new Date(); + // 当前时间 + Date nowTime = new Date(); + + List effectiveSalaryItemDels = Lists.newArrayList(); + List salaryArchiveItemNews = Lists.newArrayList(); + salaryArchiveItems.forEach(e -> { + // 已生效 + List effectiveList = effectiveSalaryItems.stream().filter(i -> i.getSalaryItemId().equals(e.getSalaryItemId())).collect(Collectors.toList()); + // 当前已生效 + SalaryArchiveItemPO effectiveSalaryItem = CollectionUtils.isNotEmpty(effectiveList) && effectiveList.size() > 0 ? effectiveList.get(0) : null; + // 当前已生效的前一次调整 + SalaryArchiveItemPO effectiveBeforeSalaryItem = CollectionUtils.isNotEmpty(effectiveList) && effectiveList.size() > 1 ? effectiveList.get(1) : null; + // 未生效 + Optional optionalIneffective = ineffectiveSalaryItems.stream().filter(i -> i.getSalaryItemId().equals(e.getSalaryItemId())).findFirst(); + SalaryArchiveItemPO ineffectiveSalaryItem = optionalIneffective.orElse(null); + + // 1.检验是否可以调整 + if (effectiveSalaryItem != null) { + // 当前已经生效的时间 + Date effectiveTime = effectiveSalaryItem.getEffectiveTime(); + // 1.1 如果早于<当前已生效 + if (saveEffectiveTime.before(effectiveTime)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100429, "生效日期不可早于当前已生效的调整日期")); + // 1.2 如果等于当前已生效 fixme 日期比较可能有bug + } else if (saveEffectiveTime.equals(effectiveTime)) { + if (effectiveBeforeSalaryItem != null && effectiveBeforeSalaryItem.getItemValue().equals(e.getAdjustValue())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100432, "调整前后不可相同")); + } + if (ineffectiveSalaryItem != null && ineffectiveSalaryItem.getItemValue().equals(e.getAdjustValue())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100434, "与未生效的调整后不可相同")); + } + // 1.3 如果>已经生效且<=今天 + } else if (saveEffectiveTime.after(effectiveTime) && !saveEffectiveTime.after(today)) { + if (effectiveSalaryItem.getItemValue().equals(e.getAdjustValue())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100432, "调整前后不可相同")); + } + if (ineffectiveSalaryItem != null && ineffectiveSalaryItem.getItemValue().equals(e.getAdjustValue())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100434, "与未生效的调整后不可相同")); + } + // 1.4 如果>今天 + } else if (saveEffectiveTime.after(today) && effectiveSalaryItem.getItemValue().equals(e.getAdjustValue())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100432, "调整前后不可相同")); + } + } else if (ineffectiveSalaryItem != null && ineffectiveSalaryItem.getItemValue().equals(e.getAdjustValue())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100434, "与未生效的调整后不可相同")); + } + }); + + return StringUtils.EMPTY; + } + + /** + * 插入 + * + * @param salaryArchive + * @param saveParam + */ + private SalaryArchiveItemPO buildInsert(SalaryArchivePO salaryArchive, Long salaryItemId, String adjustValue, SalaryArchiveItemSaveParam saveParam, Date now) { + return SalaryArchiveItemPO.builder() + .salaryArchiveId(saveParam.getSalaryArchiveId()) + .employeeId(salaryArchive.getEmployeeId()) + .effectiveTime(saveParam.getEffectiveTime()) + .adjustReason(saveParam.getAdjustReason()) + .description(saveParam.getDescription()) + .salaryItemId(salaryItemId) + // 调整后 + .itemValue(adjustValue) + .operator((long) user.getUID()) + .operateTime(now) + .createTime(now) + .updateTime(now) + .creator((long) user.getUID()) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .build(); + } + + @Override + public String deleteSalaryItem(Long salaryArchiveItemId) { + SalaryArchiveItemPO salaryArchiveItem = salaryArchiveItemMapper.getById(salaryArchiveItemId); + if (salaryArchiveItem == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98299, "参数错误,薪资项目不存在或已被删除")); + } +// if (salaryArchiveItem.getEffectiveTime().after(new Date())) { + salaryArchiveItem.setDeleteType(1); + // 删除未生效数据 + salaryArchiveItemMapper.updateById(salaryArchiveItem); + // 记录日志 + String operateName = SalaryI18nUtil.getI18nLabel(0, "删除调薪记录"); + SalaryLoggerUtil.recordDeleteSingleLog(SalaryElogConfig.salaryArchiveItemAdjustLoggerTemplate, + salaryArchiveItem.getId(), + operateName + ":" + salaryArchiveItem.getId(), + operateName, + operateName, + salaryArchiveItem, + user); +// } else { +// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98299, "该薪资项目已生效不可删除")); +// } + return StringUtils.EMPTY; + } + + /** + * 获取所有可被引用的薪资项目 + * + * @return + */ + @Override + public List getCanAdjustSalaryItems() { + + TaxAgentQueryParam param = TaxAgentQueryParam.builder().build(); + param.setFilterType(AuthFilterTypeEnum.QUERY_DATA); + Collection taxAgentList = getTaxAgentService(user).listAuth(param); + List taxAgentIds = SalaryEntityUtil.properties(taxAgentList, TaxAgentPO::getId, Collectors.toList()); + + List canAdjustSalaryItems = salaryItemMapper.getCanAdjustSalaryItems(); + canAdjustSalaryItems = canAdjustSalaryItems.stream() + .filter(item -> item.getSharedType() == null + || 0 == item.getSharedType() + || (StringUtils.isNotBlank(item.getTaxAgentIds()) && SalaryEntityUtil.judgeIntersection(taxAgentIds, Arrays.stream(item.getTaxAgentIds().split(",")).map(Long::valueOf).collect(Collectors.toList())))) + .collect(Collectors.toList()); + return canAdjustSalaryItems; + } + + + @Override + public PageInfo salaryItemAdjustRecordListPage(SalaryItemAdjustRecordQueryParam queryParam, List salaryItemIds) { + return salaryArchiveItemMapper.salaryItemAdjustRecordListPage(queryParam, salaryItemIds); + } + + @Override + public List salaryItemAdjustRecordList(SalaryItemAdjustRecordQueryParam queryParam, List salaryItemIds) { + return salaryArchiveItemMapper.salaryItemAdjustRecordList(queryParam, salaryItemIds); + } + + @Override + public XSSFWorkbook exportAdjustRecordList(SalaryItemAdjustRecordQueryParam queryParam) { + // 1.工作簿名称 + String sheetName = SalaryI18nUtil.getI18nLabel(85368, "薪资项目调整记录"); + // 获取所有可被引用的薪资项目 + List salaryItems = salaryItemMapper.getCanAdjustSalaryItems(); + String[] header = { + SalaryI18nUtil.getI18nLabel(85429, "姓名"), + SalaryI18nUtil.getI18nLabel(86187, "员工状态"), + SalaryI18nUtil.getI18nLabel(86185, "部门"), + SalaryI18nUtil.getI18nLabel(84960, "薪资项目"), + SalaryI18nUtil.getI18nLabel(85433, "调整前"), + SalaryI18nUtil.getI18nLabel(85434, "调整后"), + SalaryI18nUtil.getI18nLabel(85431, "调整原因"), + SalaryI18nUtil.getI18nLabel(85904, "生效日期"), + SalaryI18nUtil.getI18nLabel(85435, "操作人"), + SalaryI18nUtil.getI18nLabel(85436, "操作时间"), + SalaryI18nUtil.getI18nLabel(84961, "备注") + }; + // 2.表头 + List headerList = new ArrayList<>(Arrays.asList(header)); + + // 3.表数据 + // 获取所有可被引用的薪资项目 + List salaryItemList = getCanAdjustSalaryItems(); + List salaryItemIds = salaryItemList.stream().map(SalaryItemPO::getId).collect(Collectors.toList()); + //分权 + SalaryArchiveQueryParam archiveQueryParam = new SalaryArchiveQueryParam(); + archiveQueryParam.setFilterType(AuthFilterTypeEnum.QUERY_DATA); + List salaryArchiveIds = getSalaryArchiveService(user).list(archiveQueryParam).stream().map(SalaryArchiveListDTO::getId).collect(Collectors.toList()); + queryParam.setSalaryArchiveIds(salaryArchiveIds); + + List employeeList = getSalaryEmployeeService(user).listAll(UseEmployeeTypeEnum.ALL); + Map employeeMap = SalaryEntityUtil.convert2Map(employeeList, DataCollectionEmployee::getEmployeeId); + + List listResult = getSalaryArchiveItemService(user).salaryItemAdjustRecordList(queryParam, salaryItemIds); + listResult = listResult.stream() + .filter(r -> { + DataCollectionEmployee employee = employeeMap.getOrDefault(r.getEmployeeId(), new DataCollectionEmployee()); + String username = queryParam.getUsername(); + List departmentIds = queryParam.getDepartmentIds(); + List positionIds = queryParam.getPositionIds(); + String userstatus = queryParam.getUserstatus(); + r.setUsername(employee.getUsername()); + r.setDepartmentName(employee.getDepartmentName()); + r.setEmployeeStatus(UserStatusEnum.getDefaultLabelByValue(Integer.parseInt(NumberUtils.isCreatable(employee.getStatus()) ? employee.getStatus() : "-1"))); + r.setAdjustReason(SalaryArchiveItemAdjustReasonEnum.getDefaultLabelByValue(r.getAdjustReason())); + return (StringUtils.isBlank(username) || employee.getUsername().contains(username)) + && (CollectionUtils.isEmpty(departmentIds) || departmentIds.contains(employee.getDepartmentId())) + && (CollectionUtils.isEmpty(positionIds) || positionIds.contains(employee.getJobtitleId())) + && (StringUtils.isBlank(userstatus) || Objects.equals(employee.getStatus(), userstatus)) + && (CollectionUtils.isEmpty(positionIds) || positionIds.contains(employee.getJobtitleId())) + ; + }) + .collect(Collectors.toList()); + SalaryI18nUtil.i18nList(listResult); + + + List listAll = salaryArchiveItemMapper.salaryItemAdjustRecordList(SalaryItemAdjustRecordQueryParam.builder().build(), salaryItemIds); + // 人员信息赋值 + listResult.forEach(m -> { + if (!org.springframework.util.CollectionUtils.isEmpty(listAll)) { + listAll.removeIf(a -> a.getId().equals(m.getId())); + } + Optional optional = listAll.stream().filter(f -> f.getSalaryArchiveId().equals(m.getSalaryArchiveId()) && f.getSalaryItemId().equals(m.getSalaryItemId())).findFirst(); + m.setAdjustBefore(optional.isPresent() ? optional.get().getAdjustAfter() : ""); + }); + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + List> rows = new ArrayList<>(); + rows.add(headerList); + for (SalaryItemAdjustRecordListDTO dto : listResult) { + List row = new ArrayList<>(); + row.add(dto.getUsername()); + row.add(dto.getEmployeeStatus()); + row.add(dto.getDepartmentName()); + row.add(dto.getAdjustItem()); + row.add(dto.getAdjustBefore()); + row.add(dto.getAdjustAfter()); + row.add(dto.getAdjustReason()); + row.add(SalaryDateUtil.getFormatDate(dto.getEffectiveTime())); + row.add(dto.getOperator()); + row.add(format.format(dto.getOperateTime())); + row.add(dto.getDescription()); + rows.add(row); + } + + return ExcelUtil.genWorkbookV2(rows, sheetName); + } + + + @Override + public ArchiveFieldConfig getConfig() { + List salaryItemPOList = getSalaryItemService(user).listByParam(SalaryItemSearchParam.builder().useInEmployeeSalary(1).build()); + return ArchiveFieldConfig.builder().salaryItems(salaryItemPOList).build(); + } + + @Override + public UploadConfigResponse.Result parseConfig(ArchiveFieldConfig config) { + UploadConfigResponse.Result result = UploadConfigResponse.Result.builder() + .message("档案字段加载完毕") + .success(new ArrayList<>()) + .warning(new ArrayList<>()) + .error(new ArrayList<>()) + .build(); + long uid = user.getUID(); + List salaryItemPOList = getSalaryItemService(user).listAll(); + Map nameMap = SalaryEntityUtil.convert2Map(salaryItemPOList, SalaryItemPO::getName); + Map codeMap = SalaryEntityUtil.convert2Map(salaryItemPOList, SalaryItemPO::getCode); + Optional.ofNullable(config.getSalaryItems()) + .orElse(new ArrayList<>()) + .forEach(itemPO -> { + try { + + + if (nameMap.containsKey(itemPO.getName())) { + SalaryItemPO salaryItemPO = nameMap.get(itemPO.getName()); + if (!StrUtil.equals(salaryItemPO.getCode(), itemPO.getCode())) { + result.getWarning().add(String.format("警告,档案字段[%s]名称已存在,但项目code不一致,迁入code:%s,当前系统code:%s", itemPO.getName(), itemPO.getCode(), salaryItemPO.getCode())); + } + itemPO.setId(salaryItemPO.getId()); + //不许修改code + itemPO.setCode(null); + itemPO.setCreator(uid); + getSalaryItemMapper().updateIgnoreNull(itemPO); + } else if (codeMap.containsKey(itemPO.getCode())) { + SalaryItemPO salaryItemPO = codeMap.get(itemPO.getCode()); + if (!StrUtil.equals(salaryItemPO.getName(), itemPO.getName())) { + result.getWarning().add(String.format("警告,档案字段[%s]code已存在,但项目code不一致,迁入名称:%s,当前系统名称:%s", itemPO.getName(), itemPO.getName(), salaryItemPO.getName())); + } + itemPO.setId(salaryItemPO.getId()); + //不许修改名字 + itemPO.setName(null); + itemPO.setCreator(uid); + getSalaryItemMapper().updateIgnoreNull(itemPO); + } else { + itemPO.setId(IdGenerator.generate()); + getSalaryItemMapper().insertIgnoreNull(itemPO); + } + result.getSuccess().add(String.format("成功,薪资项目[%s]加载成功", itemPO.getName())); + } catch (Exception e) { + log.error("{}字段加载异常,", itemPO.getName(), e); + result.getError().add(String.format("错误,档案字段[%s]加载异常,%s", itemPO.getName(), e.getMessage())); + } + }); + + return result; + } + + @Override + public List listByArchiveIdAndEffectiveTime(List salaryArchiveIds, LocalDateRange dateRange) { + if (CollectionUtils.isEmpty(salaryArchiveIds)) { + return Collections.emptyList(); + } + List resultList = new ArrayList<>(); + List> partition = Lists.partition(salaryArchiveIds, 1000); + partition.forEach(part -> { + resultList.addAll(getSalaryArchiveItemMapper().listByArchiveIdAndEffectiveTime(part, dateRange)); + }); + return resultList; + } +} diff --git a/src/com/engine/salary/service/impl/SalaryArchiveServiceImpl.java b/src/com/engine/salary/service/impl/SalaryArchiveServiceImpl.java new file mode 100644 index 000000000..1c11ad7f4 --- /dev/null +++ b/src/com/engine/salary/service/impl/SalaryArchiveServiceImpl.java @@ -0,0 +1,1403 @@ +package com.engine.salary.service.impl; + +import com.cloudstore.dev.api.util.Util_DataCache; +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.hrmelog.entity.dto.LoggerContext; +import com.engine.salary.biz.*; +import com.engine.salary.common.LocalDateRange; +import com.engine.salary.component.WeaTableColumnGroup; +import com.engine.salary.config.SalaryElogConfig; +import com.engine.salary.constant.SalaryDefaultTenantConstant; +import com.engine.salary.constant.SalaryItemConstant; +import com.engine.salary.entity.datacollection.AddUpSituation; +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.salaryarchive.bo.SalaryArchiveBO; +import com.engine.salary.entity.salaryarchive.dto.SalaryArchiveDataDTO; +import com.engine.salary.entity.salaryarchive.dto.SalaryArchiveListDTO; +import com.engine.salary.entity.salaryarchive.param.*; +import com.engine.salary.entity.salaryarchive.po.SalaryArchiveDimissionPO; +import com.engine.salary.entity.salaryarchive.po.SalaryArchiveItemPO; +import com.engine.salary.entity.salaryarchive.po.SalaryArchivePO; +import com.engine.salary.entity.salaryarchive.po.SalaryArchiveTaxAgentPO; +import com.engine.salary.entity.salaryitem.po.SalaryItemPO; +import com.engine.salary.entity.taxagent.dto.TaxAgentManageRangeEmployeeDTO; +import com.engine.salary.entity.taxagent.param.TaxAgentQueryParam; +import com.engine.salary.entity.taxagent.po.TaxAgentEmpChangePO; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import com.engine.salary.enums.OperateTypeEnum; +import com.engine.salary.enums.UserStatusEnum; +import com.engine.salary.enums.auth.AuthFilterTypeEnum; +import com.engine.salary.enums.datacollection.UseEmployeeTypeEnum; +import com.engine.salary.enums.salaryarchive.*; +import com.engine.salary.enums.salaryitem.SalaryDataTypeEnum; +import com.engine.salary.enums.taxagent.TaxAgentEmpChangeModuleEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.mapper.archive.SalaryArchiveItemMapper; +import com.engine.salary.mapper.archive.SalaryArchiveMapper; +import com.engine.salary.service.*; +import com.engine.salary.service.auth.AuthService; +import com.engine.salary.service.auth.AuthServiceImpl; +import com.engine.salary.sys.constant.SalarySysConstant; +import com.engine.salary.sys.entity.po.SalarySysConfPO; +import com.engine.salary.sys.entity.vo.OrderRuleVO; +import com.engine.salary.sys.enums.OpenEnum; +import com.engine.salary.sys.enums.SalaryAcctEmployeeRuleEnum; +import com.engine.salary.sys.service.SalarySysConfService; +import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl; +import com.engine.salary.util.SalaryDateUtil; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.db.IdGenerator; +import com.engine.salary.util.db.MapperProxyFactory; +import com.engine.salary.util.excel.ExcelParseHelper; +import com.engine.salary.util.excel.ExcelSupport; +import com.engine.salary.util.excel.ExcelUtilPlus; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.util.page.SalaryPageUtil; +import com.engine.salary.util.valid.ValidUtil; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang.time.DateUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.math.NumberUtils; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.util.IOUtils; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.springframework.beans.BeanUtils; +import org.springframework.transaction.annotation.Transactional; +import weaver.file.ImageFileManager; +import weaver.general.Util; +import weaver.hrm.User; + +import java.io.InputStream; +import java.math.BigDecimal; +import java.util.*; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.regex.Pattern; +import java.util.stream.Collectors; + +import static com.engine.salary.sys.constant.SalarySysConstant.OPEN_SECONDARY_ACCOUNT; +import static com.engine.salary.util.excel.ExcelSupport.EXCEL_TYPE_XLSX; + +/** + * 薪资档案 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Slf4j +public class SalaryArchiveServiceImpl extends Service implements SalaryArchiveService { + + private SalaryArchiveBiz salaryArchiveMapper = new SalaryArchiveBiz(); + private SalaryArchiveItemBiz salaryArchiveItemMapper = new SalaryArchiveItemBiz(); + private SalaryArchiveTaxAgentBiz salaryArchiveTaxAgentMapper = new SalaryArchiveTaxAgentBiz(); + private SalaryArchiveDimissionBiz salaryArchiveDimissionMapper = new SalaryArchiveDimissionBiz(); + private SalaryItemBiz salaryItemMapper = new SalaryItemBiz(); + + + private TaxAgentService getTaxAgentService(User user) { + return ServiceUtil.getService(TaxAgentServiceImpl.class, user); + } + + private SalaryArchiveMapper getSalaryArchiveMapper() { + return MapperProxyFactory.getProxy(SalaryArchiveMapper.class); + } + + private SalaryArchiveItemMapper getSalaryArchiveItemMapper() { + return MapperProxyFactory.getProxy(SalaryArchiveItemMapper.class); + } + + private SalaryAcctEmployeeService getSalaryAcctEmployeeService(User user) { + return ServiceUtil.getService(SalaryAcctEmployeeServiceImpl.class, user); + } + + private SalarySysConfService getSalarySysConfService(User user) { + return ServiceUtil.getService(SalarySysConfServiceImpl.class, user); + } + + private SalaryEmployeeService getSalaryEmployeeService(User user) { + return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user); + } + + private TaxAgentEmpChangeService getTaxAgentEmpChangeService(User user) { + return ServiceUtil.getService(TaxAgentEmpChangeServiceImpl.class, user); + } + + private SalaryArchiveItemService getSalaryArchiveItemService(User user) { + return ServiceUtil.getService(SalaryArchiveItemServiceImpl.class, user); + } + + public SalarySobService getSalarySobService(User user) { + return ServiceUtil.getService(SalarySobServiceImpl.class, user); + } + + public AuthService getAuthService(User user) { + return ServiceUtil.getService(AuthServiceImpl.class, user); + } + + //主次账号是否开启 + boolean openSecondaryAccount = "1".equals(getSalarySysConfService(user).getValueByCode(OPEN_SECONDARY_ACCOUNT)); + + @Override + public SalaryArchivePO getById(Long salaryArchiveId) { + return salaryArchiveMapper.getById(salaryArchiveId); + } + + @Override + public List listSome(SalaryArchivePO po) { + Collection ids = po.getIds(); + if (CollectionUtils.isNotEmpty(ids)) { + List list = new ArrayList<>(); + List> partition = Lists.partition((List) ids, 1000); + partition.forEach(idss -> { + po.setIds(idss); + list.addAll(getSalaryArchiveMapper().listSome(po)); + }); + return list; + } + + Collection employeeIds = po.getEmployeeIds(); + if (CollectionUtils.isNotEmpty(employeeIds)) { + List list = new ArrayList<>(); + List> partition = Lists.partition((List) employeeIds, 1000); + partition.forEach(emps -> { + po.setEmployeeIds(emps); + list.addAll(getSalaryArchiveMapper().listSome(po)); + }); + return list; + } + + // 获取薪资档案数据 + return getSalaryArchiveMapper().listSome(po); + } + + @Override + public List getSalaryArchiveList(SalaryArchiveQueryParam queryParam) { + if (queryParam.isExtSalaryArchiveList()) { + return getSalaryArchiveMapper().listExtSalaryArchive(queryParam); + } + if (StringUtils.isNotBlank(queryParam.getPayStartDateStartDateStr())) { + queryParam.setPayStartDateStartDate(SalaryDateUtil.stringToDate(queryParam.getPayStartDateStartDateStr())); + } + if (Objects.nonNull(queryParam.getPayStartDateEndDateStr())) { + queryParam.setPayStartDateEndDate(SalaryDateUtil.stringToDate(queryParam.getPayStartDateEndDateStr())); + } + + if (StringUtils.isNotBlank(queryParam.getPayEndDateStartDateStr())) { + queryParam.setPayEndDateStartDate(SalaryDateUtil.stringToDate(queryParam.getPayEndDateStartDateStr())); + } + if (Objects.nonNull(queryParam.getPayEndDateEndDateStr())) { + queryParam.setPayEndDateEndDate(SalaryDateUtil.stringToDate(queryParam.getPayEndDateEndDateStr())); + } + List list = getSalaryArchiveMapper().list(queryParam); + + // 过滤调薪日期 + if (queryParam.getAdjustSalaryStartDate() != null || queryParam.getAdjustSalaryEndDate() != null) { + List salaryArchiveIds = list.stream().map(SalaryArchiveListDTO::getId).collect(Collectors.toList()); + LocalDateRange dateRange = LocalDateRange.builder().fromDate(queryParam.getAdjustSalaryStartDate()).endDate(queryParam.getAdjustSalaryEndDate()).build(); + List salaryArchiveItemPOList = getSalaryArchiveItemService(user).listByArchiveIdAndEffectiveTime(salaryArchiveIds, dateRange); + List archiveIds = salaryArchiveItemPOList.stream().map(SalaryArchiveItemPO::getSalaryArchiveId).distinct().collect(Collectors.toList()); + list = list.stream().filter(dto -> archiveIds.contains(dto.getId())).collect(Collectors.toList()); + } + + if (!openSecondaryAccount) { + list = list.stream().filter(e -> e.getAccountType() == null || e.getAccountType() == 0).collect(Collectors.toList()); + } + return SalaryI18nUtil.i18nList(list); + } + + @Override + public PageInfo listPage(SalaryArchiveQueryParam queryParam) { + long currentEmployeeId = user.getUID(); + + /** + * 异步处理档案数据 + */ + String handleable = Util.null2String(Util_DataCache.getObjVal("salaryArchiveHandleable")); + if ((StringUtils.isBlank(handleable) || OpenEnum.OPEN.getValue().equals(handleable)) && !queryParam.isExtSalaryArchiveList()) { + new Thread() { + public void run() { + Util_DataCache.setObjVal("salaryArchiveHandleable", "0"); + // 1.历史数据处理 + handleHistory(currentEmployeeId); + // 2.待停薪自动处理 + handleSuspendData(currentEmployeeId); + // 3.增量数据处理 +// handleChangeData(currentEmployeeId); + Util_DataCache.setObjVal("salaryArchiveHandleable", "1"); + } + }.start(); + } + + //排序配置 + OrderRuleVO orderRule = getSalarySysConfService(user).orderRule(); + queryParam.setOrderRule(orderRule); + List list = getSalaryArchiveList(queryParam); + list = list.stream() + //过滤档案状态 + .filter(dto -> { + if (StringUtils.isNotBlank(queryParam.getArchiveStatus())) { + return StringUtils.equals(queryParam.getArchiveStatus(), dto.getArchiveStatus()); + } + return true; + }) + .collect(Collectors.toList()); + + //能查看哪些档案 + list = getAuthService(user).auth(list, AuthFilterTypeEnum.DATA_OPT , SalaryArchiveListDTO.class); + + + PageInfo pageInfo = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), SalaryArchiveListDTO.class); + pageInfo.setTotal(list.size()); + pageInfo.setList(SalaryPageUtil.subList(queryParam.getCurrent(), queryParam.getPageSize(), list)); + return pageInfo; + } + + /** + * 1、员工的人事状态属性从在职变成非在职,且在【发薪员工】里,则自动进入【待停薪】; + * 2、若维护了最后发薪日大于当前日期,会自动清除该员工的待办数据; + * 3、个税扣缴义务人发生调整的发薪员工自动进入【待停薪】; + *

+ * 1.【发薪员工】中,员工的人事状态属性从在职变成非在职,则自动进入【待停薪】; + * 2.【定薪员工】中,如果维护了最后发薪日且大于今天的,自动清除待停薪,如果小于等于今天的则自动进入待停薪 + * + * @param currentEmployeeId + */ + @Transactional(rollbackFor = Exception.class) + public void handleSuspendData(Long currentEmployeeId) { + List personnelStatuss = new ArrayList() {{ + add("4"); + add("5"); + add("6"); + }}; + + // 1.定薪员工非在职 + if (CollectionUtils.isNotEmpty(personnelStatuss)) { + SalaryArchiveQueryParam queryParam = SalaryArchiveQueryParam.builder() + // 离职 + .personnelStatuss(personnelStatuss) + // 定薪列表 + .runStatusList(Collections.singletonList(SalaryArchiveStatusEnum.FIXED.getValue())) + .build(); + List noNormalList = getSalaryArchiveList(queryParam); + if (CollectionUtils.isNotEmpty(noNormalList)) { + List idList = noNormalList.stream().map(SalaryArchiveListDTO::getId).collect(Collectors.toList()); + List> partition = Lists.partition(idList, 999); + partition.forEach(part -> + getSalaryArchiveMapper().updateRunStatusByIdsAndPayEndDate(SalaryArchivePO.builder().ids(part).runStatus(SalaryArchiveStatusEnum.SUSPEND.getValue()).build()) + ); + } + } + Date today = new Date(); + // 2.定薪员工维护了最后发薪日,且大于今天的,自动清除待停薪 + getSalaryArchiveMapper().updateFixed(SalaryArchivePO.builder().payEndDate(today).build()); + // 3.定薪员工维护了最后发薪日,且小于等于今天的,自动进入待停薪 + getSalaryArchiveMapper().updateSuspend(SalaryArchivePO.builder().payEndDate(today).build()); + } + + + /** + * 处理增量数据 + * + * @param currentEmployeeId + */ + public void handleChangeData(Long currentEmployeeId) { + + // 所有增量人员列表 + List taxAgentEmpChangeList = getTaxAgentEmpChangeService(user).listAllByModule(TaxAgentEmpChangeModuleEnum.SALARY_ARCHIVE); + if (CollectionUtils.isEmpty(taxAgentEmpChangeList)) { + return; + } + // 当前可以管辖的人员 + if (currentEmployeeId != 1L) { + TaxAgentQueryParam param = TaxAgentQueryParam.builder().build(); + param.setFilterType(AuthFilterTypeEnum.ADMIN_DATA); + Collection taxAgentList =getTaxAgentService(user).listAuth(param); + taxAgentEmpChangeList = taxAgentEmpChangeList.stream().filter(f -> taxAgentList.stream().anyMatch(e -> e.getId().equals(f.getTaxAgentId()))).collect(Collectors.toList()); + if (CollectionUtils.isEmpty(taxAgentEmpChangeList)) { + return; + } + } + // 所有档案数据 + List salaryArchiveList = getSalaryArchiveMapper().listAll(); + // 获取所有可被引用的薪资项目 + List salaryItems = salaryItemMapper.getCanAdjustSalaryItems(); + Collection salaryItemIds = salaryItems.stream().map(SalaryItemPO::getId).collect(Collectors.toList()); + // 获取薪资档案所对应的当前生效的薪资项目数据 + List salaryArchiveItemList = getCurrentEffectiveItemList(Lists.newArrayList(), salaryItemIds); + /** 增量处理 start ***/ + SalaryArchiveBO.ChangeData changeData = SalaryArchiveBO.buildChangeData(taxAgentEmpChangeList, salaryArchiveList, salaryArchiveItemList, currentEmployeeId); + // 批量修改薪资档案 + if (CollectionUtils.isNotEmpty(changeData.getSalaryArchiveUpdateTodoList())) { + salaryArchiveMapper.batchUpdate(changeData.getSalaryArchiveUpdateTodoList()); + } + // 批量新增薪资档案 + if (CollectionUtils.isNotEmpty(changeData.getSalaryArchiveAddTodoList())) { + salaryArchiveMapper.batchInsert(changeData.getSalaryArchiveAddTodoList()); + } + // 落库处理薪资项目 + if (CollectionUtils.isNotEmpty(changeData.getSalaryArchiveItemAddTodos())) { + salaryArchiveItemMapper.batchInsert(changeData.getSalaryArchiveItemAddTodos(), user); + } + // 删除增量数据 + if (CollectionUtils.isNotEmpty(changeData.getChangeIds())) { + getTaxAgentEmpChangeService(user).deleleByIds(changeData.getChangeIds()); + } + /** 增量处理 end ***/ + + } + + @Override + public void deleteSalaryArchive(Collection salaryArchiveIds) { + if (CollectionUtils.isEmpty(salaryArchiveIds)) { + throw new SalaryRunTimeException("薪资档案参数为空!"); + } + SalarySysConfPO canDelete = getSalarySysConfService(user).getOneByCode(SalarySysConstant.SALARY_ARCHIVE_DELETE); + if (Objects.isNull(canDelete) || StringUtils.equals(canDelete.getConfValue(), "0")) { + throw new SalaryRunTimeException("不允许删除薪资档案,请先开启删除档案规则配置!"); + } + List salaryArchiveList = getSalaryArchiveMapper().listSome(SalaryArchivePO.builder().ids(salaryArchiveIds).build()); + if (CollectionUtils.isEmpty(salaryArchiveList)) { + throw new SalaryRunTimeException("薪资档案不存在"); + } + //权限,可操作的档案 + salaryArchiveList = getAuthService(user).auth(salaryArchiveList, AuthFilterTypeEnum.ADMIN_DATA, SalaryArchivePO.class); + if (CollectionUtils.isEmpty(salaryArchiveList)) { + throw new SalaryRunTimeException("没有权限删除该薪资档案!"); + } + Optional fixedList = salaryArchiveList.stream().filter(archive -> !StringUtils.equals(archive.getRunStatus(), SalaryArchiveStatusEnum.PENDING.getValue()) + && !StringUtils.equals(archive.getRunStatus(), SalaryArchiveStatusEnum.STOP_FROM_PENDING.getValue())).findFirst(); + if (fixedList.isPresent()) { + throw new SalaryRunTimeException("发薪员工、待停薪员工、停薪_来自待停薪,无法删除薪资档案!"); + } + List deleteIds = salaryArchiveList.stream().map(SalaryArchivePO::getId).collect(Collectors.toList()); + // 删除薪资档案及档案项目 + if (CollectionUtils.isNotEmpty(deleteIds)) { + getSalaryArchiveMapper().deleteByIds(deleteIds); + getSalaryArchiveItemMapper().deleteBySalaryArchiveId(deleteIds); + } + } + + + @Override + public List list(SalaryArchiveQueryParam queryParam) { + //排序配置 + OrderRuleVO orderRule = getSalarySysConfService(user).orderRule(); + queryParam.setOrderRule(orderRule); + + List list = getSalaryArchiveList(queryParam); + return getAuthService(user).auth(list, queryParam.getFilterType(), SalaryArchiveListDTO.class); + } + + /** + * 获取薪资档案对应的当前生效的薪资项目 + * + * @param salaryArchivesIds + * @return + */ + @Override + public List getCurrentEffectiveItemList(Collection salaryArchivesIds, Collection salaryItemIds) { + if (CollectionUtils.isEmpty(salaryItemIds)) { + return Collections.EMPTY_LIST; + } + List salaryArchiveItems = salaryArchiveItemMapper.getCurrentEffectiveItemList(SalaryArchiveItemQueryParam.builder().salaryArchivesIds(salaryArchivesIds).salaryItemIds(salaryItemIds).effectiveTime(new Date()).build()); + return salaryArchiveItems.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(f -> f.getSalaryArchiveId() + "-" + f.getSalaryItemId()))), ArrayList::new)); + } + + /** + * 获取薪资档案对应的当前生效的个税扣缴义务人 + * + * @param salaryArchivesIds + * @return + */ + @Override + public List getCurrentEffectiveTaxAgentList(Collection salaryArchivesIds) { + if (CollectionUtils.isEmpty(salaryArchivesIds)) { + return Collections.EMPTY_LIST; + } + List salaryArchiveTaxAgents = salaryArchiveTaxAgentMapper.listByParam(SalaryArchiveTaxAgentQueryParam.builder().salaryArchivesIds(salaryArchivesIds).effectiveTime(new Date()).build()); + + return salaryArchiveTaxAgents.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(SalaryArchiveTaxAgentPO::getSalaryArchiveId))), ArrayList::new)); + } + + /** + * 构建薪资档案数据 + * + * @param salaryArchives + * @param taxAgentLists + * @param salaryItems + * @param isPage + * @return + */ + @Override + public List> buildSalaryArchiveData(Collection salaryArchives, Collection taxAgentLists, List salaryItems, Boolean isPage) { + // 分页用于表格展示,否则用于导出 + Collection ids = isPage ? salaryArchives.stream().map(SalaryArchiveListDTO::getId).collect(Collectors.toList()) : CollectionUtils.emptyCollection(); + + List salaryItemIds = salaryItems.stream().map(SalaryItemPO::getId).collect(Collectors.toList()); + // 1.获取薪资档案所对应的当前生效的薪资项目数据 + List salaryArchiveItemList = Collections.emptyList(); + if (CollectionUtils.isNotEmpty(ids) && CollectionUtils.isNotEmpty(salaryItemIds) || !isPage) { + salaryArchiveItemList = getCurrentEffectiveItemList(ids, salaryItemIds); + } + List finalSalaryArchiveItemList = salaryArchiveItemList; + List> salaryArchiveItemData = salaryArchives.stream().map(m -> { + Map map = Maps.newHashMap(); + map.put("salaryArchiveId", m.getId()); + map.put("archiveStatus", m.getArchiveStatus()); + List salaryArchiveItemValuelList = finalSalaryArchiveItemList.stream().filter(i -> i.getSalaryArchiveId().equals(m.getId())).collect(Collectors.toList()); + salaryArchiveItemValuelList.forEach(i -> { + map.put(i.getSalaryItemId() + SalaryItemConstant.DYNAMIC_SUFFIX, i.getItemValue()); + }); + return map; + }).collect(Collectors.toList()); + //2.获取薪资档案所对应的当前生效的个税扣缴义务人列表 +// List taxAgentList = getCurrentEffectiveTaxAgentList(ids); +// List> taxAgentData = taxAgentList.stream().map(m -> { +// Map map = Maps.newHashMap(); +// map.put("salaryArchiveId", m.getSalaryArchiveId()); +// map.put("taxAgentId", m.getTaxAgentId()); +// Optional optional = taxAgentLists.stream().filter(f -> f.getId().equals(m.getTaxAgentId())).findFirst(); +// map.put("taxAgentName", optional.isPresent() ? optional.get().getName() : ""); +// map.put("taxAgentEffectiveTime", m.getEffectiveTime()); +// return map; +// }).collect(Collectors.toList()); + Map longTaxAgentPOMap = SalaryEntityUtil.convert2Map(taxAgentLists, TaxAgentPO::getId); + // 3.组装数据 + List> listMaps = new ArrayList<>(); + salaryArchives.forEach(e -> { + e.setEmployeeStatus(NumberUtils.isCreatable(e.getEmployeeStatus()) ? UserStatusEnum.getDefaultLabelByValue(Integer.parseInt(e.getEmployeeStatus())) : ""); + + Map map = new LinkedHashMap<>(); + map.put("id", e.getId()); + map.put("username", e.getUsername()); + map.put("employeeId", e.getEmployeeId()); + if (openSecondaryAccount) { + map.put("accountType", e.getAccountType() == null || e.getAccountType() == 0 ? "主账号" : "次账号"); + } + +// Optional> optionalTaxAgent = taxAgentData.stream().filter(f -> f.get("salaryArchiveId").toString().equals(e.getId().toString())).findFirst(); + TaxAgentPO taxAgentPO = longTaxAgentPOMap.get(e.getTaxAgentId()); + map.put("taxAgentName", Optional.ofNullable(taxAgentPO).map(TaxAgentPO::getName).orElse("")); + map.put("taxAgentId", Optional.ofNullable(taxAgentPO).map(TaxAgentPO::getId).orElse(0L)); +// map.put("taxAgentEffectiveTime", optionalTaxAgent.isPresent() ? optionalTaxAgent.get().get("taxAgentEffectiveTime") : ""); + + map.put("subcompanyName", e.getSubcompanyName()); + map.put("departmentName", e.getDepartmentName()); + map.put("mobile", e.getMobile()); + map.put("workcode", e.getWorkcode()); + map.put("idNo", e.getIdNo()); + map.put("employeeStatus", e.getEmployeeStatus()); + map.put("payStartDate", SalaryDateUtil.getFormatLocalDate(e.getPayStartDate())); + map.put("payEndDate", SalaryDateUtil.getFormatLocalDate(e.getPayEndDate())); + map.put("companystartdate", e.getCompanystartdate()); + map.put("dismissdate", e.getDismissdate()); + map.put("opts", e.getOpts()); + + // 薪资项目动态 + Optional> optionalItem = salaryArchiveItemData.stream().filter(f -> f.get("salaryArchiveId").toString().equals(e.getId().toString())).findFirst(); + optionalItem.ifPresent(map::putAll); + + listMaps.add(map); + }); + return listMaps; + } + + @Override + public XSSFWorkbook exportList(SalaryArchiveQueryParam queryParam) { + long employeeId = user.getUID(); + + // 1.工作簿名称 + String sheetName = SalaryI18nUtil.getI18nLabel(85368, "薪资档案"); + // 获取所有可被引用的薪资项目 + List salaryItems = salaryItemMapper.getCanAdjustSalaryItems(); + Object[] header = { + new WeaTableColumnGroup("150px", SalaryI18nUtil.getI18nLabel(85429, "姓名"), "", "", 0), + new WeaTableColumnGroup("150px", SalaryI18nUtil.getI18nLabel(86184, "个税扣缴义务人"), "", "", 0), + new WeaTableColumnGroup("150px", SalaryI18nUtil.getI18nLabel(86185, "部门"), "", "", 0), + new WeaTableColumnGroup("150px", SalaryI18nUtil.getI18nLabel(86176, "工号"), "", "", 0), + new WeaTableColumnGroup("150px", SalaryI18nUtil.getI18nLabel(86186, "手机号"), "", "", 0), + new WeaTableColumnGroup("150px", SalaryI18nUtil.getI18nLabel(86186, "证件号码"), "", "", 0), + new WeaTableColumnGroup("150px", SalaryI18nUtil.getI18nLabel(15890, "员工状态"), "", "", 0), + new WeaTableColumnGroup("150px", SalaryI18nUtil.getI18nLabel(91075, "起始发薪日期"), "", "", 0), + new WeaTableColumnGroup("150px", SalaryI18nUtil.getI18nLabel(91075, "最后发薪日期"), "", "", 0) + }; + // 2.表头 + List headerList = new ArrayList<>(Arrays.asList(header)); + for (SalaryItemPO salaryItem : salaryItems) { + headerList.add(new WeaTableColumnGroup("150px", salaryItem.getName(), "", "", salaryItem.getPattern())); + } + + // 获取所有个税扣缴义务人 + Collection taxAgentList = getTaxAgentService(user).listAll(); + //获取管理的人员范围 + List taxAgentEmployeeDTOS = getTaxAgentService(user).listTaxAgentAndEmployeeTree(employeeId); + Map> taxAgentEmployeesMap = SalaryEntityUtil.convert2Map(taxAgentEmployeeDTOS, TaxAgentManageRangeEmployeeDTO::getTaxAgentId, TaxAgentManageRangeEmployeeDTO::getEmployeeList); + + + //排序配置 + OrderRuleVO orderRule = getSalarySysConfService(user).orderRule(); + queryParam.setOrderRule(orderRule); + + List salaryArchives = getSalaryArchiveList(queryParam); + + //分权 + salaryArchives = getAuthService(user).auth(salaryArchives, AuthFilterTypeEnum.QUERY_DATA, SalaryArchiveListDTO.class); + + + List> listMaps = buildSalaryArchiveData(salaryArchives, taxAgentList, salaryItems, Boolean.FALSE); + // 组装数据 + List> rows = new ArrayList<>(); + rows.add(headerList); + listMaps.forEach(e -> { + List row = new ArrayList<>(); + row.add(Util.null2String(e.get("username"))); + row.add(Util.null2String(e.get("taxAgentName"))); + row.add(Util.null2String(e.get("departmentName"))); + row.add(Util.null2String(e.get("workcode"))); + row.add(Util.null2String(e.get("mobile"))); + row.add(Util.null2String(e.get("idNo"))); + row.add(Util.null2String(e.get("employeeStatus"))); + row.add(Util.null2String(e.get("payStartDate"))); + row.add(Util.null2String(e.get("payEndDate"))); + // 薪资项目数据 + for (SalaryItemPO salaryItem : salaryItems) { + try { + if (salaryItem.getDataType().equals(SalaryDataTypeEnum.NUMBER.getValue())) { + row.add(new BigDecimal(e.containsKey(salaryItem.getId() + SalaryItemConstant.DYNAMIC_SUFFIX) ? (e.get(salaryItem.getId() + SalaryItemConstant.DYNAMIC_SUFFIX) == null ? "" : e.get(salaryItem.getId() + SalaryItemConstant.DYNAMIC_SUFFIX).toString()) : "")); + } else { + row.add(e.containsKey(salaryItem.getId() + SalaryItemConstant.DYNAMIC_SUFFIX) ? (e.get(salaryItem.getId() + SalaryItemConstant.DYNAMIC_SUFFIX) == null ? "" : e.get(salaryItem.getId() + SalaryItemConstant.DYNAMIC_SUFFIX).toString()) : ""); + } + } catch (Exception ex) { + row.add(e.containsKey(salaryItem.getId() + SalaryItemConstant.DYNAMIC_SUFFIX) ? (e.get(salaryItem.getId() + SalaryItemConstant.DYNAMIC_SUFFIX) == null ? "" : e.get(salaryItem.getId() + SalaryItemConstant.DYNAMIC_SUFFIX).toString()) : ""); + } + } + rows.add(row); + }); + // 3.表数据 + +// return ExcelUtil.genWorkbookV2(rows, sheetName); + + // 记录日志 + String statusStr = StringUtils.join(queryParam.getRunStatusList().stream().map(status -> SalaryArchiveStatusEnum.parseByValue(status).getDefaultLabel()).collect(Collectors.toList()), ","); + String name = SalaryI18nUtil.getI18nLabel(0, "导出"); + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setTargetName(SalaryI18nUtil.getI18nLabel(0, "薪资档案 ") + statusStr); + loggerContext.setOperateType(OperateTypeEnum.EXCEL_EXPORT.getValue()); + loggerContext.setOperateTypeName(name); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "薪资档案") + "-" + name); + loggerContext.setUser(user); + SalaryElogConfig.salaryArchiveLoggerTemplate.write(loggerContext); + return ExcelUtilPlus.genWorkbookV2WithPattern(rows, sheetName, false); + } + + + @Override + public String savePaySet(SalaryArchiveSetPaySaveParam saveParam) { + long currentEmployeeId = user.getUID(); + if (saveParam.getStatus() == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(109201, "状态不能为空")); + } + Boolean enableStatus = saveParam.getStatus().equals(SalaryArchiveStatusEnum.PENDING) + || saveParam.getStatus().equals(SalaryArchiveStatusEnum.FIXED) + || saveParam.getStatus().equals(SalaryArchiveStatusEnum.SUSPEND); + if (!enableStatus) { + return StringUtils.EMPTY; + } + if (saveParam.getSalaryArchiveId() == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100425, "薪资档案id不能为空")); + } + SalaryArchivePO salaryArchive = getById(saveParam.getSalaryArchiveId()); + if (salaryArchive == null) { + throw new SalaryRunTimeException(String.format(SalaryI18nUtil.getI18nLabel(100463, "薪资档案不存在") + "[id:%s]", saveParam.getSalaryArchiveId())); + } + SalaryArchivePO oldSalaryArchive = new SalaryArchivePO(); + BeanUtils.copyProperties(salaryArchive, oldSalaryArchive); + List oldList = Collections.singletonList(oldSalaryArchive); + // 收入所得项目 +// boolean checkIncomeCategory = saveParam.getIncomeCategory() == null || StringUtils.isEmpty(SalaryArchiveBO.getIncomeCategoryByValue(saveParam.getIncomeCategory())); +// if (checkIncomeCategory) { +// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(122085, "收入所得项目不能为空或不存在")); +// } else { +// salaryArchive.setIncomeCategory(saveParam.getIncomeCategory()); +// } + // 薪资账套 +// if (CollectionUtils.isEmpty(saveParam.getSalarySobIds())) { +// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(122217, "薪资账套不能为空")); +// } + + // 待定薪 + if (saveParam.getStatus().equals(SalaryArchiveStatusEnum.PENDING)) { + if (saveParam.getPayStartDate() == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(109202, "起始发薪日期不能为空")); + } + // 起薪日期:新人入职默认为:入职日期;返聘人员默认为:返聘开始日期;调整个税扣缴义务人:不默认日期 + salaryArchive.setPayStartDate(saveParam.getPayStartDate()); + if (saveParam.getPayEndDate() != null) { + if (saveParam.getPayStartDate().after(saveParam.getPayEndDate())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(109214, "起始发薪日期不可晚于最后发薪日")); + } + } + salaryArchive.setPayEndDate(saveParam.getPayEndDate()); + // 处理薪资项目 + if (CollectionUtils.isNotEmpty(saveParam.getSalaryArchiveItems())) { + // 获取所有可被引用的薪资项目 + List salaryItems = getSalaryArchiveItemService(user).getCanAdjustSalaryItems(); + Collection salaryItemIds = salaryItems.stream().map(SalaryItemPO::getId).collect(Collectors.toList()); + // 待处理薪资项目 + List salaryArchiveItems = saveParam.getSalaryArchiveItems().stream().filter(e -> salaryItemIds.contains(e.getSalaryItemId())).collect(Collectors.toList()); + List salaryItemExistIds = salaryArchiveItems.stream().map(SalaryArchiveItemDetailSaveParam::getSalaryItemId).collect(Collectors.toList()); + // 获取薪资档案所对应的当前生效的薪资项目数据 + List salaryArchiveItemCurrentList = getSalaryArchiveItemService(user).getCurrentEffectiveItemList(Collections.singletonList(saveParam.getSalaryArchiveId()), salaryItemExistIds); + List salaryArchiveItemAddTodos = Lists.newArrayList(); + List salaryArchiveItemDelTodoIds = Lists.newArrayList(); + Date now = new Date(); + salaryArchiveItems.forEach(f -> { + Optional optional = salaryItems.stream().filter(i -> i.getId().equals(f.getSalaryItemId())).findFirst(); + if (optional.isPresent()) { + SalaryItemPO salaryItemPO = optional.get(); + boolean isNotNumber = salaryItemPO.getDataType().equals(SalaryArchiveFieldTypeEnum.NUMBER.getValue()) && StringUtils.isNotEmpty(f.getAdjustValue()) && !Pattern.matches(SalaryEntityUtil.NUMBER_REGEX, f.getAdjustValue()); + if (isNotNumber) { + throw new SalaryRunTimeException(salaryItemPO.getName() + ":" + SalaryI18nUtil.getI18nLabel(100581, "请输入数字")); + } + } + Optional optionalSAI = salaryArchiveItemCurrentList.stream().filter(c -> + c.getSalaryArchiveId().equals(saveParam.getSalaryArchiveId()) && c.getSalaryItemId().equals(f.getSalaryItemId()) + ).findFirst(); + if (StringUtils.isNotEmpty(f.getAdjustValue())) { + salaryArchiveItemAddTodos.add(SalaryArchiveItemPO.builder() + .id(IdGenerator.generate()) + .salaryArchiveId(salaryArchive.getId()) + .employeeId(salaryArchive.getEmployeeId()) + .effectiveTime(saveParam.getPayStartDate()) + .adjustReason(SalaryArchiveItemAdjustReasonEnum.INIT.getValue()) + .salaryItemId(f.getSalaryItemId()) + .itemValue(f.getAdjustValue()) + .description("") + .operator(currentEmployeeId) + .operateTime(now) + .createTime(now) + .updateTime(now) + .creator(currentEmployeeId) + .deleteType(NumberUtils.INTEGER_ZERO) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .build()); + } + optionalSAI.ifPresent(salaryArchiveItemPO -> salaryArchiveItemDelTodoIds.add(salaryArchiveItemPO.getId())); + }); + // 落库处理薪资档案项目数据 + if (CollectionUtils.isNotEmpty(salaryArchiveItemAddTodos)) { + salaryArchiveItemMapper.batchInsert(salaryArchiveItemAddTodos, user); + } + if (CollectionUtils.isNotEmpty(salaryArchiveItemDelTodoIds)) { + salaryArchiveItemMapper.deleteBatchIds(salaryArchiveItemDelTodoIds); + } + } + // 定薪 + } else if (saveParam.getStatus().equals(SalaryArchiveStatusEnum.FIXED)) { + if (saveParam.getPayStartDate() == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(109202, "起始发薪日期不能为空")); + } + salaryArchive.setPayStartDate(saveParam.getPayStartDate()); + if (saveParam.getPayEndDate() != null) { + if (saveParam.getPayStartDate().after(saveParam.getPayEndDate())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(109214, "起始发薪日期不可晚于最后发薪日")); + } + } + salaryArchive.setPayEndDate(saveParam.getPayEndDate()); + //如果是非系统人员,需要将起始发薪日期初始化 + if (Objects.equals(salaryArchive.getEmployeeType(), 1)) { + salaryArchive.setRunStatus(SalaryArchiveStatusEnum.FIXED.getValue()); + } + // 待停薪 + } else if (saveParam.getStatus().equals(SalaryArchiveStatusEnum.SUSPEND)) { + if (saveParam.getPayEndDate() == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(109203, "最后发薪日期不能为空")); + } + if (saveParam.getPayStartDate().after(saveParam.getPayEndDate())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(109214, "起始发薪日期不可晚于最后发薪日")); + } + salaryArchive.setPayEndDate(saveParam.getPayEndDate()); + } + salaryArchive.setUpdateTime(new Date()); + getSalaryArchiveMapper().update(salaryArchive); + +// List salarySobList = getSalarySobList(currentEmployeeId, currentTenantKey); +// List salarySobIds = salarySobList.stream().map(SalarySobPO::getId).filter(id -> saveParam.getSalarySobIds().contains(id)).collect(Collectors.toList()); +// List salaryArchiveSobSaveList = SalaryArchiveBO.buildSalaryArchiveSob(salaryArchive.getId(), salarySobIds, LocalDateTime.now()); +// this.salaryArchiveSobService.saveBatchBySalaryArchiveIdsAndSaves(Collections.singletonList(salaryArchive.getId()), salaryArchiveSobSaveList, currentTenantKey); + + // 记录日志 + List newList = Collections.singletonList(this.getById(salaryArchive.getId())); + String operatedesc = SalaryI18nUtil.getI18nLabel(0, "发薪设置"); + recordLog(oldList, newList, operatedesc); + + return StringUtils.EMPTY; + } + + /** + * 记录日志 + * + * @param oldSalaryArchiveList + * @param newSalaryArchiveList + * @param operatedesc + */ + private void recordLog(List oldSalaryArchiveList, List newSalaryArchiveList, String operatedesc) { + if (CollectionUtils.isEmpty(oldSalaryArchiveList) || CollectionUtils.isEmpty(oldSalaryArchiveList)) { + return; + } + List updateEmpIds = newSalaryArchiveList.stream().map(SalaryArchivePO::getEmployeeId).distinct().collect(Collectors.toList()); + List employeeList = getSalaryEmployeeService(user).listByIds(updateEmpIds); + Map empMap = SalaryEntityUtil.convert2Map(employeeList, DataCollectionEmployee::getEmployeeId, DataCollectionEmployee::getUsername); + + + // 获取所有个税扣缴义务人 + Collection taxAgents = getTaxAgentService(user).listAll(); + Map taxAgentMap = SalaryEntityUtil.convert2Map(taxAgents, TaxAgentPO::getId, TaxAgentPO::getName); + String bar = "-"; + oldSalaryArchiveList.forEach(e -> { + LoggerContext loggerContext = new LoggerContext(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(e.getId())); + loggerContext.setTargetName( Optional.ofNullable(taxAgentMap.get(e.getTaxAgentId())).orElse(StringUtils.EMPTY) + bar + Optional.ofNullable(empMap.get(e.getEmployeeId())).orElse(StringUtils.EMPTY) ); + loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue()); + loggerContext.setOperateTypeName(operatedesc); + loggerContext.setOperatedesc(operatedesc); + loggerContext.setOldValues(e); + Optional optionalNew = newSalaryArchiveList.stream().filter(n -> n.getId().equals(e.getId())).findFirst(); + loggerContext.setNewValues(optionalNew.isPresent() ? optionalNew.get() : null); + SalaryElogConfig.salaryArchiveLoggerTemplate.write(loggerContext); + }); + } + + + @Override + public List dimissionSets() { + return salaryArchiveDimissionMapper.dimissionSets(); + } + + @Override + public String saveDimissionSet(SalaryArchiveDimissionSaveParam saveParam) { + Date now = new Date(); + List dimissionSets = dimissionSets(); + if (CollectionUtils.isNotEmpty(dimissionSets)) { + SalaryArchiveDimissionPO po = dimissionSets.get(0); + po.setDimissionTimeInterval(saveParam.getDimissionTimeInterval().getValue()); + po.setUpdateTime(now); + salaryArchiveDimissionMapper.updateById(po); + } else { + salaryArchiveDimissionMapper.insert(SalaryArchiveDimissionPO.builder().dimissionTimeInterval(saveParam.getDimissionTimeInterval().getValue()).createTime(now).updateTime(now).creator((long) user.getUID()).tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY).build()); + } + return StringUtils.EMPTY; + } + + @Override + public List getSalaryArchiveData(LocalDateRange localDateRange, Collection employeeIds, List taxAgentIds) { + return getSalaryArchiveData(localDateRange, employeeIds, taxAgentIds, Boolean.FALSE); + } + + @Override + public List getSalaryArchiveTaxAgentData(LocalDateRange localDateRange, Collection employeeIds, List taxAgentIds) { + return getSalaryArchiveData(localDateRange, employeeIds, taxAgentIds, Boolean.TRUE); + } + + /** + * 根据日期范围和人员获取薪资档案数据 + * + * @param localDateRange + * @param employeeIds + * @param isOnlyTaxAgent + * @return + */ + private List getSalaryArchiveData(LocalDateRange localDateRange, Collection employeeIds, List taxAgentIds, boolean isOnlyTaxAgent) { + // 获取核算人员规则 + List statusList = Collections.emptyList(); + SalarySysConfPO employeeRule = getSalarySysConfService(user).getOneByCode(SalarySysConstant.SALARY_ACCT_EMPLOYEE_RULE); + if (Objects.isNull(employeeRule) || StringUtils.equals(employeeRule.getConfValue(), SalaryAcctEmployeeRuleEnum.BYPAYENDTIME.getValue())) { + // 默认包含停薪列表 + statusList = Arrays.asList(SalaryArchiveStatusEnum.FIXED.getValue(), SalaryArchiveStatusEnum.SUSPEND.getValue(), + SalaryArchiveStatusEnum.STOP_FROM_SUSPEND.getValue()); + } else { + // 仅包含发薪、待定薪 + statusList = Arrays.asList(SalaryArchiveStatusEnum.FIXED.getValue(), SalaryArchiveStatusEnum.SUSPEND.getValue()); + } + // 获取薪资档案数据 + List salaryArchiveList = listSome(SalaryArchivePO.builder().runStatusList(statusList).employeeIds(employeeIds).taxAgentIds(taxAgentIds).build()); + + List allEmployeeIds = salaryArchiveList.stream().map(SalaryArchivePO::getEmployeeId).distinct().collect(Collectors.toList()); + // 获取所有可被引用的薪资项目 + List salaryItems = salaryItemMapper.getCanAdjustSalaryItems(); + Collection salaryItemIds = salaryItems.stream().map(SalaryItemPO::getId).collect(Collectors.toList()); + // 获取薪资项目调整数据,isOnlyTaxAgent为true时不需要薪资项目数据 + List salaryArchiveItemDataList = isOnlyTaxAgent || CollectionUtils.isEmpty(salaryItemIds) ? Lists.newArrayList() : salaryArchiveItemMapper.listByParam(SalaryArchiveItemQueryParam.builder().salaryItemIds(salaryItemIds).employeeIds(employeeIds).effectiveTime(localDateRange.getEndDate()).build()); + + return SalaryArchiveBO.buildSalaryArchiveData(salaryArchiveList, salaryArchiveItemDataList, localDateRange, allEmployeeIds, isOnlyTaxAgent); + } + + + @Override + public void stopSalary(SalaryArchiveStopParam stopSalaryParam) { + ValidUtil.doValidator(stopSalaryParam); + stopSalaryParam.setPayEndDate(SalaryDateUtil.stringToDate(stopSalaryParam.getPayEndDateStr())); + + SalaryArchivePO po = getSalaryArchiveMapper().getById(stopSalaryParam.getSalaryArchiveId()); + + if (po == null) { + throw new SalaryRunTimeException("未找到薪资档案"); + } + Date payStartDate = po.getPayStartDate(); + Date payEndDate = stopSalaryParam.getPayEndDate(); + if (payEndDate.before(payStartDate)) { + throw new SalaryRunTimeException("最后缴纳日期应大于起始缴纳日期"); + } + + po.setPayEndDate(payEndDate); + po.setUpdateTime(new Date()); + getSalaryArchiveMapper().update(po); + + } + + + @Override + public Map preview(SalaryArchiveImportHandleParam param) { + //1、参数校验 + vaildImportParam(param); + + Map map = new HashMap<>(); + + InputStream fileInputStream = null; + try { + + fileInputStream = ImageFileManager.getInputStreamById(Integer.parseInt(param.getImageId())); + + Sheet sheet = ExcelSupport.parseFile(fileInputStream, 0, EXCEL_TYPE_XLSX); + List headers = ExcelSupport.getSheetHeader(sheet, 0); + + map.put("headers", headers); + map.put("list", ExcelParseHelper.parse2List(sheet, 1)); + + return map; + + } finally { + IOUtils.closeQuietly(fileInputStream); + } + } + + private void vaildImportParam(SalaryArchiveImportHandleParam param) { + String imageId = param.getImageId(); + if (StringUtils.isBlank(imageId)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100593, "文件id为空")); + } + if (param.getListType() == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(109712, "列表类型必传")); + } else { + // 定薪列表导入有调薪导入和初始化导入 + if (param.getListType().equals(SalaryArchiveListTypeEnum.FIXED.getValue())) { + Optional optional = Arrays.stream(SalaryArchiveImportTypeEnum.values()) + .filter(e -> StringUtils.isNotEmpty(param.getImportType()) && e.getValue().equals(param.getImportType())).findFirst(); + if (!optional.isPresent()) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100593, "导入类型不正确")); + } + } + } + } + + private List getEffectiveTaxAgentList() { + Date truncate = DateUtils.truncate(new Date(), Calendar.DATE); + return salaryArchiveTaxAgentMapper.getEffectiveTaxAgentList(SalaryArchiveTaxAgentQueryParam.builder().effectiveTime(truncate).build()); + } + + private List getIneffectiveTaxAgentList() { + Date truncate = DateUtils.truncate(new Date(), Calendar.DATE); + return salaryArchiveTaxAgentMapper.getIneffectiveTaxAgentList(SalaryArchiveTaxAgentQueryParam.builder().effectiveTime(truncate).build()); + } + + + /** + * 处理历史数据 + * 下回发版可删除 + */ + public void handleHistory(Long currentEmployeeId) { + // 待定薪没设置过的默认为正常工资薪金所得 +// new LambdaUpdateChainWrapper<>(salaryArchiveMapper) +// .eq(SalaryArchivePO::getDeleteType, 0) +// .eq(SalaryArchivePO::getTenantKey, tenantKey) +// .eq(SalaryArchivePO::getRunStatus, SalaryArchiveStatusEnum.PENDING.getValue()) +// .isNull(SalaryArchivePO::getIncomeCategory) +// .set(SalaryArchivePO::getIncomeCategory, IncomeCategoryEnum.WAGES_AND_SALARIES.getValue()) +// .update(); + + //历史档案默认为发薪员工 + List historyData = getSalaryArchiveMapper().getStatusIsNullData(); + List ids = SalaryEntityUtil.properties(historyData, SalaryArchivePO::getId, Collectors.toList()); + List> partIds = Lists.partition(ids, 999); + for (List part : partIds) { + getSalaryArchiveMapper().updateStatus(SalaryArchivePO.builder().ids(part).runStatus(SalaryArchiveStatusEnum.FIXED.getValue()).build()); + } + + //处理个税扣缴义务人为空 + List salaryArchives = getSalaryArchiveMapper().getHistoryData(); + if (CollectionUtils.isEmpty(salaryArchives)) { + return; + } + Date today = new Date(); + List salaryArchiveTaxAgents = getEffectiveTaxAgentList(); + + List salaryArchiveItems = salaryArchiveItemMapper.getEffectiveSalaryItems(SalaryArchiveItemQueryParam.builder().effectiveTime(today).build()); + + List salaryArchiveDelIds = salaryArchives.stream().map(SalaryArchivePO::getId).collect(Collectors.toList()); + List salaryArchiveTaxAgentDelIds = salaryArchiveTaxAgents.stream().map(SalaryArchiveTaxAgentPO::getId).collect(Collectors.toList()); + List salaryArchiveItemDelIds = salaryArchiveItems.stream().map(SalaryArchiveItemPO::getId).collect(Collectors.toList()); + + List salaryArchiveAddList = Lists.newArrayList(); + List salaryArchiveItemAddList = Lists.newArrayList(); + + + Date endDate = today; + for (SalaryArchivePO sa : salaryArchives) { + List saTaxAgents = salaryArchiveTaxAgents.stream().filter(t -> t.getSalaryArchiveId().equals(sa.getId())).collect(Collectors.toList()); + // 去重获取最新生效的个税口角义务人列表 + saTaxAgents = saTaxAgents.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(f -> f.getSalaryArchiveId() + "-" + f.getTaxAgentId()))), ArrayList::new)); + + List saItemList = salaryArchiveItems.stream().filter(i -> i.getSalaryArchiveId().equals(sa.getId())).collect(Collectors.toList()); + + for (SalaryArchiveTaxAgentPO st : saTaxAgents) { + Date finalEndDate = endDate; + List saItems = saItemList.stream().filter(si -> !si.getEffectiveTime().after(finalEndDate)).collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(f -> f.getSalaryArchiveId() + "-" + f.getSalaryItemId()))), ArrayList::new)); + + SalaryArchivePO newSA = SalaryArchivePO.builder().id(IdGenerator.generate()).employeeId(sa.getEmployeeId()).taxAgentId(st.getTaxAgentId()).payStartDate(st.getEffectiveTime()) +// .runStatus(SalaryArchiveStatusEnum.FIXED.getValue()) +// .modifier(0L) + .createTime(today).updateTime(today).creator(currentEmployeeId).deleteType(NumberUtils.INTEGER_ZERO).tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY).build(); + salaryArchiveAddList.add(newSA); + saItems.forEach(sf -> { + salaryArchiveItemAddList.add(SalaryArchiveItemPO.builder().salaryArchiveId(newSA.getId()).employeeId(newSA.getEmployeeId()).effectiveTime(sf.getEffectiveTime()).adjustReason(sf.getAdjustReason()).salaryItemId(sf.getSalaryItemId()).itemValue(sf.getItemValue()).description(sf.getDescription()) + // 不用设置操作人 + .operator(currentEmployeeId).operateTime(today).createTime(today).updateTime(today).creator(currentEmployeeId).deleteType(NumberUtils.INTEGER_ZERO).tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY).build()); + }); + +// endDate = st.getEffectiveTime(); + } + } + + // 逻辑删除历史数据 + List> partition = Lists.partition(salaryArchiveDelIds, 999); + for (List part : partition) { + salaryArchiveMapper.batchDeleteHistoryData(SalaryArchivePO.builder().ids(part).build()); + } + List> partitionTA = Lists.partition(salaryArchiveTaxAgentDelIds, 999); + for (List part : partitionTA) { + salaryArchiveTaxAgentMapper.batchDeleteHistoryData(SalaryArchiveTaxAgentPO.builder().ids(part).build()); + } + List> partitionItem = Lists.partition(salaryArchiveItemDelIds, 999); + for (List part : partitionItem) { + salaryArchiveItemMapper.batchDeleteHistoryData(SalaryArchiveItemPO.builder().ids(part).build()); + } + // 新增迁移数据 + if (CollectionUtils.isNotEmpty(salaryArchiveAddList)) { + this.salaryArchiveMapper.batchInsert(salaryArchiveAddList); + } + if (CollectionUtils.isNotEmpty(salaryArchiveItemAddList)) { + this.salaryArchiveItemMapper.batchInsert(salaryArchiveItemAddList, user); + } + log.info("处理历史数据结束==============="); + } + + @Override + public Map selectSalaryArchiveColumns(SalaryArchiveImportTypeEnum salaryArchiveImportTypeEnum) { + HashMap map = Maps.newHashMap(); + //类型为档案初始化 + boolean isInit = salaryArchiveImportTypeEnum.getValue().equals(SalaryArchiveImportTypeEnum.INIT.getValue()); + //类型为调整个税扣缴义务人 + boolean isTaxAgentAdjust = salaryArchiveImportTypeEnum.getValue().equals(SalaryArchiveImportTypeEnum.TAXAGENTADJUST.getValue()); + //类型为调薪 + boolean isSalaryItemAdjust = salaryArchiveImportTypeEnum.getValue().equals(SalaryArchiveImportTypeEnum.SALARYITEMADJUST.getValue()); + + //固定列 + map.put(SalaryI18nUtil.getI18nLabel(85429, "姓名"), "username"); + map.put(SalaryI18nUtil.getI18nLabel(86184, "个税扣缴义务人"), "taxAgentName"); + map.put(SalaryI18nUtil.getI18nLabel(85904, "生效日期"), "taxAgentEffectiveTime"); + map.put(SalaryI18nUtil.getI18nLabel(86185, "部门"), "departmentName"); + map.put(SalaryI18nUtil.getI18nLabel(86186, "手机号"), "mobile"); + map.put(SalaryI18nUtil.getI18nLabel(91075, "员工状态"), "employeeStatus"); + + List salaryItems = salaryItemMapper.getCanAdjustSalaryItems(); + + if (isTaxAgentAdjust || isSalaryItemAdjust) { + map.put(SalaryI18nUtil.getI18nLabel(85431, "调整原因"), "adjustReason"); + } + //动态列 + // 获取所有可被引用的薪资项目 + if (isInit || isSalaryItemAdjust) { + for (SalaryItemPO salaryItem : salaryItems) { + map.put(salaryItem.getName(), salaryItem.getCode()); + } + } + + return map; + } + + @Override + public Map queryTabTotal() { + // tab页签数量 + Map result = new HashMap<>(); + + List list = getSalaryArchiveMapper().listAll(); + + list = getAuthService(user).auth(list, AuthFilterTypeEnum.QUERY_DATA, SalaryArchivePO.class); + + long pendingTotal = 0L; + long fixedTotal = 0L; + long suspendTotal = 0L; + long stopTotal = 0L; + long extTotal = 0L; + + for (SalaryArchivePO sa : list) { + Integer employeeType = sa.getEmployeeType(); + if (employeeType == null || employeeType == 0) { + if (sa.getRunStatus().equals(SalaryArchiveStatusEnum.PENDING.getValue())) { + pendingTotal += 1; + } else if (sa.getRunStatus().equals(SalaryArchiveStatusEnum.FIXED.getValue()) || sa.getRunStatus().equals(SalaryArchiveStatusEnum.SUSPEND.getValue())) { + fixedTotal += 1; + if (sa.getRunStatus().equals(SalaryArchiveStatusEnum.SUSPEND.getValue())) { + suspendTotal += 1; + } + } else if (sa.getRunStatus().equals(SalaryArchiveStatusEnum.STOP_FROM_PENDING.getValue()) || sa.getRunStatus().equals(SalaryArchiveStatusEnum.STOP_FROM_SUSPEND.getValue())) { + stopTotal += 1; + } + } else { + extTotal += 1; + } + } + + result.put(SalaryArchiveListTypeEnum.PENDING.getValue(), pendingTotal); + result.put(SalaryArchiveListTypeEnum.FIXED.getValue(), fixedTotal); + result.put(SalaryArchiveListTypeEnum.SUSPEND.getValue(), suspendTotal); + result.put(SalaryArchiveListTypeEnum.STOP.getValue(), stopTotal); + result.put(SalaryArchiveListTypeEnum.EXT.getValue(), extTotal); + return result; + } + + @Override + public String deletePendingTodo(Collection ids) { + if (CollectionUtils.isEmpty(ids)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(84026, "参数错误")); + } + + List oldList = listSome(SalaryArchivePO.builder() + .ids(ids) + .runStatus(SalaryArchiveStatusEnum.PENDING.getValue()) + .build()); + + + if (CollectionUtils.isEmpty(oldList)) { + return StringUtils.EMPTY; + } + // 从待定薪到停薪 + List> partition = Lists.partition((List) ids, 800); + partition.forEach(getSalaryArchiveMapper()::deletePendingTodo); + // 记录日志 + List newList = new ArrayList<>(); + partition.forEach(part -> { + newList.addAll(getSalaryArchiveMapper().listSome(SalaryArchivePO.builder().ids(part).build())); + }); + String operatedesc = SalaryI18nUtil.getI18nLabel(0, "删除待办"); + recordLog(oldList, newList, operatedesc); + + return StringUtils.EMPTY; + } + + + @Override + public Map gotoFixed(Collection ids) { + if (CollectionUtils.isEmpty(ids)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(145969, "没有可以操作的记录")); + } + + List salaryArchiveList = listSome(SalaryArchivePO.builder().ids(ids).runStatus(SalaryArchiveStatusEnum.PENDING.getValue()).build()); + + if (CollectionUtils.isEmpty(salaryArchiveList)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(145969, "档案不存在!")); + } + + List unableList = salaryArchiveList.stream().filter(f -> f.getPayStartDate() == null).collect(Collectors.toList()); + + int total = ids.size(); + int errorCount = unableList.size(); + // 单个设为定薪的失败提示 + if (total == 1 && errorCount > 0) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(109197, "请先维护起始发薪日期")); + } + + // 从待定薪到定薪 + List> partition = Lists.partition((List) ids, 800); + partition.forEach(getSalaryArchiveMapper()::gotoFixed); + + // 记录日志 + List newList = new ArrayList<>(); + partition.forEach(part -> { + newList.addAll(getSalaryArchiveMapper().listSome(SalaryArchivePO.builder().ids(part).build())); + }); + String operateDesc = SalaryI18nUtil.getI18nLabel(0, "设为发薪员工"); + recordLog(salaryArchiveList, newList, operateDesc); + + // 获取所有可被引用的薪资项目 + List salaryItemIds = getSalaryArchiveItemService(user).getCanAdjustSalaryItems().stream().map(SalaryItemPO::getId).collect(Collectors.toList()); + List currentEffectiveItemList = getSalaryArchiveItemService(user).getCurrentEffectiveItemListIngoreValue(ids, salaryItemIds) + .stream() + .peek(e -> { + Optional salaryArchive = salaryArchiveList.stream().filter(sa -> sa.getId().equals(e.getSalaryArchiveId())).findFirst(); + if (salaryArchive.isPresent()) { + e.setAdjustReason(SalaryArchiveItemAdjustReasonEnum.INIT.getValue()); + e.setEffectiveTime(salaryArchive.get().getPayStartDate()); + } + }).collect(Collectors.toList()); + // 更新薪资项目的生效日期 + List> partitions = Lists.partition(currentEffectiveItemList, 100); + partitions.forEach(list -> getSalaryArchiveItemMapper().batchUpdate(list)); + + Map resultMap = new HashMap<>(2); + String resultMsg = SalaryI18nUtil.getI18nLabel(94620, "操作成功"); + String resultType = "success"; + // 批量设为定薪提示 + if (total > 1) { + resultMsg = SalaryI18nUtil.getI18nLabel(134807, "成功条数") + ": " + (total - errorCount) + "; " + + SalaryI18nUtil.getI18nLabel(134808, "失败条数") + ": " + (errorCount) + + (errorCount > 0 ? ", " + SalaryI18nUtil.getI18nLabel(109197, "请先维护起始发薪日期") : ""); + resultType = errorCount > 0 ? "info" : resultType; + } + resultMap.put("type", resultType); + resultMap.put("msg", resultMsg); + return resultMap; + } + + @Override + public Map allGotoFixed(SalaryArchiveQueryParam queryParam) { + queryParam.setRunStatusList(Arrays.asList(SalaryArchiveStatusEnum.PENDING.getValue())); + queryParam.setFilterType(AuthFilterTypeEnum.ADMIN_DATA); + List salaryArchiveIds = this.list(queryParam).stream().map(SalaryArchiveListDTO::getId).collect(Collectors.toList()); + return this.gotoFixed(salaryArchiveIds); + } + + + @Override + public Map gotoStop(Collection ids) { + if (CollectionUtils.isEmpty(ids)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(145969, "没有可以操作的记录")); + } + List oldList = listSome(SalaryArchivePO.builder() + .ids(ids) + .runStatus(SalaryArchiveStatusEnum.SUSPEND.getValue()) + .build()); + + if (CollectionUtils.isEmpty(oldList)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(145969, "档案不存在!")); + } + + List unableList = oldList.stream().filter(f -> f.getPayEndDate() == null).collect(Collectors.toList()); + int total = ids.size(); + int errorCount = unableList.size(); + // 单个设为定薪的失败提示 + if (total == 1 && errorCount > 0) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(109196, "请先维护最后发薪日期")); + } + + // 从待停薪到停薪 + List> partition = Lists.partition((List) ids, 800); + partition.forEach(getSalaryArchiveMapper()::gotoStop); + + // 记录日志 + List newList = new ArrayList<>(); + partition.forEach(part -> { + newList.addAll( getSalaryArchiveMapper().listSome(SalaryArchivePO.builder().ids(part).build())); + }); + String operatedesc = SalaryI18nUtil.getI18nLabel(0, "停薪"); + recordLog(oldList, newList, operatedesc); + + Map resultMap = new HashMap<>(2); + String resultMsg = SalaryI18nUtil.getI18nLabel(94620, "操作成功"); + String resultType = "success"; + // 批量设为定薪提示 + if (total > 1) { + resultMsg = SalaryI18nUtil.getI18nLabel(134807, "成功条数") + ": " + (total - errorCount) + "; " + + SalaryI18nUtil.getI18nLabel(134808, "失败条数") + ": " + (errorCount) + + (errorCount > 0 ? ", " + SalaryI18nUtil.getI18nLabel(109196, "请先维护最后发薪日期") : ""); + resultType = errorCount > 0 ? "info" : resultType; + } + resultMap.put("type", resultType); + resultMap.put("msg", resultMsg); + return resultMap; + } + + @Override + public Map allGotoStop(SalaryArchiveQueryParam queryParam) { + queryParam.setRunStatusList(Arrays.asList(SalaryArchiveStatusEnum.SUSPEND.getValue())); + queryParam.setFilterType(AuthFilterTypeEnum.ADMIN_DATA); + List salaryArchiveIds = this.list(queryParam) + .stream().map(SalaryArchiveListDTO::getId).collect(Collectors.toList()); + return this.gotoStop(salaryArchiveIds); + } + + @Override + public String deleteSuspendTodo(Collection ids) { + if (org.springframework.util.CollectionUtils.isEmpty(ids)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(84026, "参数错误")); + } + +// List oldList = listSome(SalaryArchivePO.builder() +// .ids(ids) +// .runStatus(SalaryArchiveStatusEnum.SUSPEND.getValue()) +// .build()); +// List unableList = oldList.stream().filter(f -> Objects.nonNull(f.getPayEndDate()) && !f.getPayEndDate().after(new Date())).collect(Collectors.toList()); +// if (CollectionUtils.isNotEmpty(unableList)) { +// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(115789, "最后发薪日必须晚于今天")); +// } +// +// // 从待停薪到定薪 +// getSalaryArchiveMapper().deleteSuspendTodo(ids); +// return StringUtils.EMPTY; + + // 获取所有个税扣缴义务人 +// Collection taxAgentList = getTaxAgentService(user).listTaxAgentAndEmployeeTree(Long.valueOf(user.getUID())); + Collection taxAgentList = getTaxAgentService(user).listTaxAgentAndEmployeeTree(); + // 获取删除待停薪信息 + List list = getSalaryArchiveMapper().list(SalaryArchiveQueryParam.builder().ids(ids).build()); + if (list.size() != ids.size()) { + throw new SalaryRunTimeException("薪资档案不存在,删除失败!"); + } + Set employeeStatus = list.stream().map(SalaryArchiveListDTO::getEmployeeStatus).collect(Collectors.toSet()); + if (employeeStatus.contains("5")) { + throw new SalaryRunTimeException("离职人员无法删除待办"); + } + Map taxAgentMap = SalaryEntityUtil.convert2Map(taxAgentList, TaxAgentManageRangeEmployeeDTO::getTaxAgentId); + // 判断删除待停薪代办的人是否在个税扣缴义务人的人员范围中 + for (SalaryArchiveListDTO dto : list) { + TaxAgentManageRangeEmployeeDTO taxAgentManageRangeEmployeeDTO = taxAgentMap.get(dto.getTaxAgentId()); + if (Objects.nonNull(taxAgentManageRangeEmployeeDTO)) { + boolean canDelete = taxAgentManageRangeEmployeeDTO.getEmployeeList().stream() + .map(TaxAgentManageRangeEmployeeDTO.TaxAgentEmployee::getEmployeeId) + .anyMatch(id -> Objects.equals(id, dto.getEmployeeId())); + if (!canDelete) { + throw new SalaryRunTimeException("个税扣缴义务人不存在或不在权限范围内,删除失败!"); + } + } else { + throw new SalaryRunTimeException("个税扣缴义务人不存在或不在权限范围内,删除失败!"); + } + } + // 删除最后发薪日期,设置状态为发薪 + if (CollectionUtils.isNotEmpty(list)) { + List salaryArchiveIds = list.stream().map(SalaryArchiveListDTO::getId).collect(Collectors.toList()); + getSalaryArchiveMapper().deleteSuspendTodo(salaryArchiveIds); + // 记录日志 + List oldList = getSalaryArchiveMapper().listSome(SalaryArchivePO.builder().ids(salaryArchiveIds).build()); + List newList = getSalaryArchiveMapper().listSome(SalaryArchivePO.builder().ids(ids).build()); + String operatedesc = SalaryI18nUtil.getI18nLabel(0, "删除待办"); + recordLog(oldList, newList, operatedesc); + } + return StringUtils.EMPTY; + } + + @Override + public String cancelStop(Collection ids) { + if (org.springframework.util.CollectionUtils.isEmpty(ids)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(84026, "参数错误")); + } + + SalaryArchivePO param = SalaryArchivePO.builder() + .ids(ids) + .runStatusList(Arrays.asList(SalaryArchiveStatusEnum.STOP_FROM_PENDING.getValue(), SalaryArchiveStatusEnum.STOP_FROM_SUSPEND.getValue())) + .build(); + List oldList = listSome(param); + oldList = getAuthService(user).auth(oldList, AuthFilterTypeEnum.ADMIN_DATA, SalaryArchivePO.class); + + ids = SalaryEntityUtil.properties(oldList, SalaryArchivePO::getId); + // 从停薪到待定薪 + getSalaryArchiveMapper().gotoPendingFromStop(ids); + // 从停薪到定薪 + getSalaryArchiveMapper().gotoFixedFromStop(ids); + + // 记录日志 + List newList = getSalaryArchiveMapper().listSome(SalaryArchivePO.builder().ids(ids).build()); + String operatedesc = SalaryI18nUtil.getI18nLabel(0, "取消停薪"); + recordLog(oldList, newList, operatedesc); + + return StringUtils.EMPTY; + } + + @Override + public Map handleRepeatData() { + Map result = new HashMap<>(); + + //获取所有薪资档案 + List list = getSalaryArchiveMapper().listSome(SalaryArchivePO.builder().runStatus(SalaryArchiveStatusEnum.PENDING.getValue()).build()); + AtomicInteger num = new AtomicInteger(); + if (CollectionUtils.isNotEmpty(list)) { + Map> maps = SalaryEntityUtil.group2Map(list, k -> k.getTaxAgentId() + "-" + k.getEmployeeId()); + maps.forEach((key, pos) -> { + if (pos.size() > 1) { + for (int i = 1; i < pos.size(); i++) { + SalaryArchivePO salaryArchivePO = pos.get(i); + getSalaryArchiveMapper().delete(salaryArchivePO); + num.getAndIncrement(); + } + } + }); + } + result.put("共处理", num.get()); + return result; + } + + @Override + public List listPayEndDateIsNull(List employeeIds) { + if (CollectionUtils.isEmpty(employeeIds)) { + return Collections.emptyList(); + } + List> partition = Lists.partition(employeeIds, 500); + List resultList = new ArrayList<>(); + partition.forEach(part -> { + resultList.addAll(getSalaryArchiveMapper().listPayEndDateIsNull(part)); + }); + return resultList; + } + + @Override + public List listByRunStatus(List list) { + return getSalaryArchiveMapper().listSome(SalaryArchivePO.builder().runStatusList(list).build()); + } + + /** + * 同步所有档案起始发薪日期变为入职日期 + * + * @return + */ + @Override + public String syncPayStartDate() { + List employeeList = getSalaryEmployeeService(user).listAll(UseEmployeeTypeEnum.ALL); + Map empPayStartDateMap = SalaryEntityUtil.convert2Map(employeeList, DataCollectionEmployee::getEmployeeId, DataCollectionEmployee::getCompanystartdate); + + List list = getSalaryArchiveMapper().listAll(); + List archives = list.stream() + .peek(archive -> { + String payStartDate = empPayStartDateMap.getOrDefault(archive.getEmployeeId(), ""); + if (SalaryDateUtil.checkDay(payStartDate)) { + archive.setPayStartDate(SalaryDateUtil.dateStrToLocalDate(payStartDate)); + } + }) + .collect(Collectors.toList()); + salaryArchiveMapper.batchUpdate(archives); + return "执行完毕"; + } + + @Override + public List listPayStartDateIsNull(String runStatus) { + if (StringUtils.isBlank(runStatus)) { + return Collections.emptyList(); + } + return getSalaryArchiveMapper().listPayStartDateIsNull(runStatus); + } +} diff --git a/src/com/engine/salary/service/impl/SalaryArchiveTaxAgentServiceImpl.java b/src/com/engine/salary/service/impl/SalaryArchiveTaxAgentServiceImpl.java new file mode 100644 index 000000000..eede97198 --- /dev/null +++ b/src/com/engine/salary/service/impl/SalaryArchiveTaxAgentServiceImpl.java @@ -0,0 +1,259 @@ +package com.engine.salary.service.impl; + +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.constant.SalaryDefaultTenantConstant; +import com.engine.salary.entity.salaryarchive.dto.TaxAgentAdjustRecordListDTO; +import com.engine.salary.entity.salaryarchive.param.SalaryArchiveTaxAgentQueryParam; +import com.engine.salary.entity.salaryarchive.param.SalaryArchiveTaxAgentSaveParam; +import com.engine.salary.entity.salaryarchive.param.TaxAgentAdjustRecordQueryParam; +import com.engine.salary.entity.salaryarchive.po.SalaryArchivePO; +import com.engine.salary.entity.salaryarchive.po.SalaryArchiveTaxAgentPO; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import com.engine.salary.enums.UserStatusEnum; +import com.engine.salary.enums.salaryarchive.SalaryArchiveTaxAgentAdjustReasonEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.mapper.archive.SalaryArchiveMapper; +import com.engine.salary.mapper.archive.SalaryArchiveTaxAgentMapper; +import com.engine.salary.service.SalaryArchiveTaxAgentService; +import com.engine.salary.service.TaxAgentService; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.db.MapperProxyFactory; +import com.engine.salary.util.excel.ExcelUtil; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.util.page.SalaryPageUtil; +import com.google.common.collect.Lists; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import weaver.hrm.User; + +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * 薪资档案-个税扣缴义务人 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SalaryArchiveTaxAgentServiceImpl extends Service implements SalaryArchiveTaxAgentService { + private static final Logger log = LoggerFactory.getLogger(SalaryArchiveTaxAgentServiceImpl.class); + + private SalaryArchiveTaxAgentMapper getSalaryArchiveTaxAgentMapper() { + return MapperProxyFactory.getProxy(SalaryArchiveTaxAgentMapper.class); + } + + private TaxAgentService getTaxAgentService(User user) { + return ServiceUtil.getService(TaxAgentServiceImpl.class, user); + } +// private SalaryBatchService salaryBatchService; + + @Override + public SalaryArchiveTaxAgentPO getById(Long salaryArchiveTaxAgentId) { + return getSalaryArchiveTaxAgentMapper().getById(salaryArchiveTaxAgentId); + } + + @Override + public PageInfo taxAgentAdjustRecordListPage(TaxAgentAdjustRecordQueryParam queryParam) { + List taxAgentAdjustRecordListDTOS = getSalaryArchiveTaxAgentMapper().taxAgentAdjustRecordList(queryParam); + return SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), + taxAgentAdjustRecordListDTOS, TaxAgentAdjustRecordListDTO.class); + } + + @Override + public List taxAgentAdjustRecordList(TaxAgentAdjustRecordQueryParam queryParam) { + return getSalaryArchiveTaxAgentMapper().taxAgentAdjustRecordList(queryParam); + } + + /** + * 获取未生效 + * + * @param salaryArchiveId + * @return + */ + private SalaryArchiveTaxAgentPO getIneffectiveTaxAgent(Long salaryArchiveId) { + List ineffectiveTaxAgentList = getSalaryArchiveTaxAgentMapper().getIneffectiveTaxAgentList(SalaryArchiveTaxAgentQueryParam.builder().salaryArchiveId(salaryArchiveId).effectiveTime(new Date()).build()); + return CollectionUtils.isNotEmpty(ineffectiveTaxAgentList) ? ineffectiveTaxAgentList.get(0) : null; + } + + /** + * 获取当前已生效 + * + * @param salaryArchiveId + * @return + */ + @Override + public SalaryArchiveTaxAgentPO getEffectiveTaxAgent(Long salaryArchiveId) { + List effectiveTaxAgentList = getSalaryArchiveTaxAgentMapper().getEffectiveTaxAgentList(SalaryArchiveTaxAgentQueryParam.builder().salaryArchiveId(salaryArchiveId).effectiveTime(new Date()).build()); + return CollectionUtils.isNotEmpty(effectiveTaxAgentList) ? effectiveTaxAgentList.get(0) : null; + } + + @Override + public String saveTaxAgent(SalaryArchiveTaxAgentSaveParam saveParam) { + + // 校验参数 + SalaryArchiveTaxAgentSaveParam.checkParam(saveParam); + + // 薪资档案 + SalaryArchiveMapper salaryArchiveMapper = MapperProxyFactory.getProxy(SalaryArchiveMapper.class); + SalaryArchivePO salaryArchive = salaryArchiveMapper.getById(saveParam.getSalaryArchiveId()); + // 获取当前已生效 + SalaryArchiveTaxAgentPO effectiveTaxAgent = getEffectiveTaxAgent(saveParam.getSalaryArchiveId()); + // 获取当前已生效之前的 + List salaryArchiveTaxAgents = Lists.newArrayList(); + if (effectiveTaxAgent != null) { + salaryArchiveTaxAgents = getSalaryArchiveTaxAgentMapper().getTaxAgentLtTimeBySalaryArchiveId(SalaryArchiveTaxAgentQueryParam.builder().salaryArchiveId(saveParam.getSalaryArchiveId()).effectiveTime(effectiveTaxAgent.getEffectiveTime()).build()); + } + // 获取未生效数据 + SalaryArchiveTaxAgentPO ineffectiveTaxAgent = getIneffectiveTaxAgent(saveParam.getSalaryArchiveId()); + + // 待保存生效时间 + Date saveEffectiveTime = saveParam.getEffectiveTime(); + // 当天 + Date today = new Date(); + + // 1.检验是否可以调整 + if (effectiveTaxAgent != null) { + // 当前已经生效的时间 + Date effectiveTime = effectiveTaxAgent.getEffectiveTime(); + // 1.1 如果早于<当前已生效 + if (saveEffectiveTime.before(effectiveTime)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100429, "生效日期不可早于当前已生效的调整日期")); + // 1.2 如果等于当前已生效 + } else if (saveEffectiveTime.equals(effectiveTime)) { + if (CollectionUtils.isNotEmpty(salaryArchiveTaxAgents) && salaryArchiveTaxAgents.get(0).getTaxAgentId().equals(saveParam.getTaxAgentId())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100432, "调整前后不可相同")); + } + if (ineffectiveTaxAgent != null && ineffectiveTaxAgent.getTaxAgentId().equals(saveParam.getTaxAgentId())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100434, "与未生效的调整后不可相同")); + } + // 1.3 如果>已经生效且<=今天 + } else if (saveEffectiveTime.after(effectiveTime) && !saveEffectiveTime.after(today)) { + if (effectiveTaxAgent.getTaxAgentId().equals(saveParam.getTaxAgentId())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100432, "调整前后不可相同")); + } + if (ineffectiveTaxAgent != null && ineffectiveTaxAgent.getTaxAgentId().equals(saveParam.getTaxAgentId())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100434, "与未生效的调整后不可相同")); + } + // 1.4 如果>今天 + } else if (saveEffectiveTime.after(today) && effectiveTaxAgent.getTaxAgentId().equals(saveParam.getTaxAgentId())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100432, "调整前后不可相同")); + } + } else if (ineffectiveTaxAgent != null && ineffectiveTaxAgent.getTaxAgentId().equals(saveParam.getTaxAgentId())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100434, "与未生效的调整后不可相同")); + } + // 2.数据处理 + // 2.数据处理,有的就先删后增 + if (effectiveTaxAgent != null && saveEffectiveTime.equals(effectiveTaxAgent.getEffectiveTime())) { + getSalaryArchiveTaxAgentMapper().delete(SalaryArchiveTaxAgentPO.builder().id(effectiveTaxAgent.getId()).build()); + } + if (ineffectiveTaxAgent != null && saveEffectiveTime.after(today)) { + getSalaryArchiveTaxAgentMapper().delete(SalaryArchiveTaxAgentPO.builder().id(ineffectiveTaxAgent.getId()).build()); + } + insertTaxAgent(salaryArchive, saveParam); + // 3.todo 日志处理 + + return StringUtils.EMPTY; + } + + /** + * 插入 + * + * @param salaryArchive + * @param saveParam + */ + private void insertTaxAgent(SalaryArchivePO salaryArchive, SalaryArchiveTaxAgentSaveParam saveParam) { + long employeeId = user.getUID(); + Date now = new Date(); + SalaryArchiveTaxAgentPO salaryArchiveTaxAgent = SalaryArchiveTaxAgentPO.builder() + .salaryArchiveId(saveParam.getSalaryArchiveId()).employeeId(salaryArchive.getEmployeeId()).effectiveTime(saveParam.getEffectiveTime()).adjustReason(saveParam.getAdjustReason()) + // 调整后 + .taxAgentId(saveParam.getTaxAgentId()).operator(employeeId).operateTime(now).createTime(now).updateTime(now).creator(employeeId).tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY).build(); + getSalaryArchiveTaxAgentMapper().insertIgnoreNull(salaryArchiveTaxAgent); + } + + @Override + public String deleteTaxAgent(Long salaryArchiveTaxAgentId) { + SalaryArchiveTaxAgentPO salaryArchiveTaxAgent = getSalaryArchiveTaxAgentMapper().getById(salaryArchiveTaxAgentId); + if (salaryArchiveTaxAgent == null) { + return StringUtils.EMPTY; + } + if (salaryArchiveTaxAgent.getEffectiveTime().after(new Date())) { + salaryArchiveTaxAgent.setDeleteType(1); + // 删除未生效数据 + getSalaryArchiveTaxAgentMapper().delete(salaryArchiveTaxAgent); + } + return StringUtils.EMPTY; + } + + @Override + public XSSFWorkbook exportAdjustRecordList(TaxAgentAdjustRecordQueryParam queryParam) { + // 1.工作簿名称 + String sheetName = SalaryI18nUtil.getI18nLabel(99978, "个税扣缴义务人调整记录"); + // 2.表头 + List header = new ArrayList<>(); + header.add(SalaryI18nUtil.getI18nLabel(85429, "姓名")); + header.add(SalaryI18nUtil.getI18nLabel(86187, "员工状态")); + header.add(SalaryI18nUtil.getI18nLabel(86185, "部门")); + header.add(SalaryI18nUtil.getI18nLabel(85433, "调整前")); + header.add(SalaryI18nUtil.getI18nLabel(85434, "调整后")); + header.add(SalaryI18nUtil.getI18nLabel(85431, "调整原因")); + header.add(SalaryI18nUtil.getI18nLabel(85904, "生效日期")); + header.add(SalaryI18nUtil.getI18nLabel(85435, "操作人")); + header.add(SalaryI18nUtil.getI18nLabel(85436, "操作时间")); + header.add(SalaryI18nUtil.getI18nLabel(84961, "备注")); + // 3.表数据 + // 获取记录 + List list = getSalaryArchiveTaxAgentMapper().taxAgentAdjustRecordList(queryParam); + List listAll = getSalaryArchiveTaxAgentMapper().taxAgentAdjustRecordList(TaxAgentAdjustRecordQueryParam.builder().build()); + // 个税扣缴义务人 + Collection taxAgentList = getTaxAgentService(user).listAll(); + // 人员信息赋值 + list.forEach(m -> { + if (!org.springframework.util.CollectionUtils.isEmpty(listAll)) { + listAll.removeIf(a -> a.getId().equals(m.getId())); + } + Optional optional = listAll.stream().filter(f -> f.getSalaryArchiveId().equals(m.getSalaryArchiveId())).findFirst(); + m.setAdjustBefore(optional.isPresent() ? optional.get().getAdjustAfter() : ""); + Optional optionalBefore = taxAgentList.stream().filter(t -> t.getId().toString().equals(m.getAdjustBefore())).findFirst(); + m.setAdjustBefore(optionalBefore.isPresent() ? optionalBefore.get().getName() : ""); + Optional optionalAfter = taxAgentList.stream().filter(t -> t.getId().toString().equals(m.getAdjustAfter())).findFirst(); + m.setAdjustAfter(optionalAfter.isPresent() ? optionalAfter.get().getName() : ""); + + m.setEmployeeStatus(UserStatusEnum.getDefaultLabelByValue(Integer.parseInt(m.getEmployeeStatus()))); + m.setAdjustReason(SalaryArchiveTaxAgentAdjustReasonEnum.getDefaultLabelByValue(m.getAdjustReason())); + }); + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + List> rows = new ArrayList<>(); + rows.add(header); + for (TaxAgentAdjustRecordListDTO dto : list) { + List row = new ArrayList<>(); + row.add(dto.getUsername()); + row.add(dto.getEmployeeStatus()); + row.add(dto.getDepartmentName()); + row.add(dto.getAdjustBefore()); + row.add(dto.getAdjustAfter()); + row.add(dto.getAdjustReason()); + row.add(dto.getEffectiveTime() + ""); + row.add(dto.getOperator()); + row.add(format.format(dto.getOperateTime())); + row.add(dto.getDescription()); + rows.add(row); + } + + return ExcelUtil.genWorkbookV2(rows, sheetName); + + } + + @Override + public SalaryArchiveTaxAgentPO getAdjustBeforeTaxAgent(SalaryArchiveTaxAgentPO salaryArchiveTaxAgent) { + List salaryArchiveTaxAgents = getSalaryArchiveTaxAgentMapper().getAdjustBeforeTaxAgent(SalaryArchiveTaxAgentPO.builder().salaryArchiveId(salaryArchiveTaxAgent.getSalaryArchiveId()).effectiveTime(salaryArchiveTaxAgent.getEffectiveTime()).build()); + return CollectionUtils.isNotEmpty(salaryArchiveTaxAgents) ? salaryArchiveTaxAgents.get(0) : null; + } + +} diff --git a/src/com/engine/salary/service/impl/SalaryBillBaseSetServiceImpl.java b/src/com/engine/salary/service/impl/SalaryBillBaseSetServiceImpl.java new file mode 100644 index 000000000..0a8220c6f --- /dev/null +++ b/src/com/engine/salary/service/impl/SalaryBillBaseSetServiceImpl.java @@ -0,0 +1,201 @@ +package com.engine.salary.service.impl; + + +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.constant.SalaryDefaultTenantConstant; +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.salaryBill.bo.SalaryBillBO; +import com.engine.salary.entity.salaryBill.dto.SalaryBillAckFeedbackDTO; +import com.engine.salary.entity.salaryBill.dto.salaryBillViewingLimitSetting; +import com.engine.salary.entity.salaryBill.dto.SalaryBillWatermarkDTO; +import com.engine.salary.entity.salaryBill.param.SalaryBaseSetSaveParam; +import com.engine.salary.entity.salaryBill.po.SalaryBillWatermarkPO; +import com.engine.salary.enums.salarybill.MonthTypeEnum; +import com.engine.salary.enums.salarybill.SalaryTemplateWatermarkTypeEnum; +import com.engine.salary.service.SalaryBillBaseSetService; +import com.engine.salary.service.SalaryBillWatermarkService; +import com.engine.salary.service.SalaryEmployeeService; +import com.engine.salary.sys.constant.SalarySysConstant; +import com.engine.salary.sys.entity.po.SalarySysConfPO; +import com.engine.salary.sys.service.SalarySysConfService; +import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl; +import com.engine.salary.util.JsonUtil; +import com.engine.salary.util.SalaryEntityUtil; +import com.google.common.collect.Lists; +import com.engine.salary.util.db.IdGenerator; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang.math.NumberUtils; +import org.apache.commons.lang3.StringUtils; +import weaver.general.Util; +import weaver.hrm.User; + +import java.util.*; + +import static com.engine.salary.enums.salarybill.MonthTypeEnum.SALARY_DATE; +import static com.engine.salary.sys.constant.SalarySysConstant.*; + +/** + * @Description: 工资单水印 + * @Author: wangxiangzhong + * @Date: 2023/5/16 11:10 + */ + +public class SalaryBillBaseSetServiceImpl extends Service implements SalaryBillBaseSetService { + + private SalaryBillWatermarkService getSalaryBillWatermarkService(User user) { + return ServiceUtil.getService(SalaryBillWatermarkServiceImpl.class, user); + } + + private SalaryEmployeeService getSalaryEmployeeService(User user) { + return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user); + } + + public SalarySysConfService getSalarySysConfService(User user) { + return ServiceUtil.getService(SalarySysConfServiceImpl.class, user); + } + + @Override + public SalaryBillWatermarkDTO getWatermarkSetting() { + List list = getSalaryBillWatermarkService(user).listAll(); + SalaryBillWatermarkPO watermarkPO = CollectionUtils.isNotEmpty(list) ? list.get(0) : null; + + if (Objects.isNull(watermarkPO)) { + return null; + } + return SalaryBillWatermarkDTO.builder().watermarkStatus(NumberUtils.INTEGER_ONE.equals(watermarkPO.getWatermarkStatus())).watermarkType(watermarkPO.getWatermarkType()).wmSetting(JsonUtil.parseMap(watermarkPO.getWatermarkSetting(), Object.class)).build(); + } + + @Override + public String saveBaseSet(SalaryBaseSetSaveParam saveParam) { + // 检查参数 + SalaryBaseSetSaveParam.checkParam(saveParam); + + Date now = new Date(); + // 工资单水印=========================================================== + Integer watermarkStatus = NumberUtils.INTEGER_ONE; + String watermark = null; + String wmSetting = StringUtils.EMPTY; + // 如果开启了 + if (saveParam.getWatermarkStatus()) { + if (SalaryTemplateWatermarkTypeEnum.CUSTOM.equals(saveParam.getWatermark())) { + wmSetting = JsonUtil.toJsonString(saveParam.getWmSetting()); + } else { + // 系统默认水印 给一个默认的json + wmSetting = "{\"wmWidth\":100,\"wmRotate\":30,\"wmSelectedFieldIds\":[\"HRM_Name\"],\"pureWmText\":\" 当前操作者姓名 \",\"wmText\":\"

 $HRM_Name 

\",\"wmClassify\":\"text\",\"wmHeight\":100,\"wmOriginText\":\"

 当前操作者姓名 

\",\"wmNoTransparent\":15}"; + } + watermark = saveParam.getWatermark().getValue(); + } else { + watermarkStatus = NumberUtils.INTEGER_ZERO; + } + + // 将当前生效的水印信息都删除 + getSalaryBillWatermarkService(user).deleteAll(); + // 保存最新的水印信息 + getSalaryBillWatermarkService(user).insertIgnoreNull(SalaryBillWatermarkPO.builder().id(IdGenerator.generate()).watermarkStatus(watermarkStatus).watermarkType(watermark).watermarkSetting(wmSetting).createTime(now).updateTime(now).creator(Long.valueOf(user.getUID())).deleteType(NumberUtils.INTEGER_ZERO).tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY).build()); + + + // 工资单确认和反馈 =========================================================== + SalaryBillAckFeedbackDTO ackFeedbackSetting = saveParam.getAckFeedbackSetting(); + // 1.保存确认反馈开关状态 + getSalarySysConfService(user).saveSettingByType(ackFeedbackSetting.getAckStatus(), SALARY_SEND_FEEDBACK, "工资单确认状态", "billSend"); + getSalarySysConfService(user).saveSettingByType(ackFeedbackSetting.getFeedbackStatus(), SALARY_SEND_FEEDBACK_FK, "工资单反馈状态", "billSend"); + if (StringUtils.equals(ackFeedbackSetting.getAckStatus(), "1")) { + // 保存自动确认时间 + getSalarySysConfService(user).saveSettingByType(ackFeedbackSetting.getAutoAckDays().toString(), SALARY_AUTO_ACK_DAYS, "工资单反馈自动确认", "billSend"); + } + + if (StringUtils.equals(ackFeedbackSetting.getFeedbackStatus(), "1")) { + // 保存反馈地址 + getSalarySysConfService(user).saveSettingByType(ackFeedbackSetting.getFeedBackUrl(), SALARY_FEEDBACK_URL, "工资单反馈地址", "billSend"); + getSalarySysConfService(user).saveSettingByType(ackFeedbackSetting.getMobileFeedbackUrl(), SALARY_FEEDBACK_URL_MOBILE, "移动端工资单反馈地址", "billSend"); + } + + // 工资单时效性设置 + salaryBillViewingLimitSetting salaryBillViewingLimitDTO = saveParam.getSalaryBillViewingLimitSetting(); + if (salaryBillViewingLimitDTO != null) { + getSalarySysConfService(user).saveSettingByType(Util.null2String(salaryBillViewingLimitDTO.getLimitMonth()), SALARY_BILL_VIEWING_LIMIT_MONTH, "工资单时效性设置", "billSend"); + getSalarySysConfService(user).saveSettingByType(salaryBillViewingLimitDTO.getMonthType()==null?"0":salaryBillViewingLimitDTO.getMonthType().getValue().toString(), SALARY_BILL_LIMIT_MONTH_TYPE, "工资单查询限制月份类型", "billSend"); + getSalarySysConfService(user).saveSettingByType(salaryBillViewingLimitDTO.getBurningAfterReadingMin() == null ? " " : salaryBillViewingLimitDTO.getBurningAfterReadingMin().toString(), SALARY_BILL_BURNING_AFTER_READING_MIN, "工资单查看后销毁设置", "billSend"); + } + return StringUtils.EMPTY; + } + + @Override + public String previewWaterMark(Map wmSetting) { + String wmText = wmSetting.getOrDefault("wmText", StringUtils.EMPTY).toString(); + List wmTextFieldIds = (List) wmSetting.getOrDefault("wmSelectedFieldIds", Lists.newArrayList()); + if (CollectionUtils.isEmpty(wmTextFieldIds) || StringUtils.isEmpty(wmText)) { + return wmText; + } + DataCollectionEmployee simpleEmployee = getSalaryEmployeeService(user).getEmployeeById(Long.valueOf(user.getUID())); + return SalaryBillBO.handleWmText(wmText, wmTextFieldIds, simpleEmployee); + } + + @Override + public SalaryBillAckFeedbackDTO getDefaultAckFeedbackSetting() { + // 获取反馈开启状态、自动确认时长、反馈地址 + List codes = Arrays.asList(SalarySysConstant.SALARY_SEND_FEEDBACK, SalarySysConstant.SALARY_SEND_FEEDBACK_FK ,SalarySysConstant.SALARY_AUTO_ACK_DAYS, SalarySysConstant.SALARY_FEEDBACK_URL, SALARY_FEEDBACK_URL_MOBILE); + List sysConfList = getSalarySysConfService(user).getListByCodes(codes); + Map sysConfMap = SalaryEntityUtil.convert2Map(sysConfList, SalarySysConfPO::getConfKey, SalarySysConfPO::getConfValue); + + SalaryBillAckFeedbackDTO defaultAckFeedBackDTO = SalaryBillAckFeedbackDTO.builder().build(); + String ackStatus = sysConfMap.getOrDefault(SalarySysConstant.SALARY_SEND_FEEDBACK, "0"); + // if (StringUtils.equals(ackStatus, "0")) { + // // 未开启工资单确认 + // defaultAckFeedBackDTO.setAckStatus("0"); + // defaultAckFeedBackDTO.setAutoAckDays(0); + // defaultAckFeedBackDTO.setFeedBackUrl("/"); + // defaultAckFeedBackDTO.setMobileFeedbackUrl("/"); + // return defaultAckFeedBackDTO; + // } + defaultAckFeedBackDTO.setAckStatus(ackStatus); + + + String feedbackStatus = sysConfMap.get(SALARY_SEND_FEEDBACK_FK); + if (feedbackStatus == null) { + // 处理历史数据 + feedbackStatus = ackStatus; + } + defaultAckFeedBackDTO.setFeedbackStatus(feedbackStatus); + + // 获取超时自动确认时间 + Integer autoAckDays = Integer.valueOf(sysConfMap.getOrDefault(SalarySysConstant.SALARY_AUTO_ACK_DAYS, "7")); + defaultAckFeedBackDTO.setAutoAckDays(autoAckDays); + // 反馈地址 + String feedbackUrl = sysConfMap.getOrDefault(SalarySysConstant.SALARY_FEEDBACK_URL, ""); + defaultAckFeedBackDTO.setFeedBackUrl(feedbackUrl); + + String mobileFeedbackUrl = sysConfMap.getOrDefault(SALARY_FEEDBACK_URL_MOBILE, ""); + defaultAckFeedBackDTO.setMobileFeedbackUrl(mobileFeedbackUrl); + return defaultAckFeedBackDTO; + } + + @Override + public salaryBillViewingLimitSetting getSalaryBillViewingLimitSetting() { + SalarySysConfPO limitMonthSetting = getSalarySysConfService(user).getOneByCode(SALARY_BILL_VIEWING_LIMIT_MONTH); + int limitMonth = 0; + if (limitMonthSetting != null && NumberUtils.isNumber(limitMonthSetting.getConfValue())) { + limitMonth = Integer.parseInt(limitMonthSetting.getConfValue()); + } + + SalarySysConfPO limitMonthType = getSalarySysConfService(user).getOneByCode(SALARY_BILL_LIMIT_MONTH_TYPE); + MonthTypeEnum monthType = SALARY_DATE; + if (limitMonthType != null && NumberUtils.isNumber(limitMonthType.getConfValue())) { + monthType = MonthTypeEnum.parseByValue(Integer.parseInt(limitMonthType.getConfValue())); + } + + return salaryBillViewingLimitSetting.builder().monthType(monthType).limitMonth(limitMonth).build(); + } + + @Override + public Integer getBurningAfterReadingMin() { + SalarySysConfPO ineffectiveMinSetting = getSalarySysConfService(user).getOneByCode(SALARY_BILL_BURNING_AFTER_READING_MIN); + if (ineffectiveMinSetting == null || StringUtils.isBlank(ineffectiveMinSetting.getConfValue()) || !NumberUtils.isNumber(ineffectiveMinSetting.getConfValue())) { + // 代表该设置不生效,即首次读后可以一直查看 + return null; + } else { + return Integer.parseInt(ineffectiveMinSetting.getConfValue()); + } + } +} diff --git a/src/com/engine/salary/service/impl/SalaryBillItemNameServiceImpl.java b/src/com/engine/salary/service/impl/SalaryBillItemNameServiceImpl.java new file mode 100644 index 000000000..65e7f0f83 --- /dev/null +++ b/src/com/engine/salary/service/impl/SalaryBillItemNameServiceImpl.java @@ -0,0 +1,182 @@ +package com.engine.salary.service.impl; + +import com.api.formmode.mybatis.util.SqlProxyHandle; +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.constant.SalaryDefaultTenantConstant; +import com.engine.salary.entity.salaryBill.param.SalaryBillItemNameSaveParam; +import com.engine.salary.entity.salaryBill.po.SalaryBillItemNamePO; +import com.engine.salary.entity.salaryBill.po.SalaryTemplatePO; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.mapper.salarybill.SalaryBillItemNameMapper; +import com.engine.salary.service.SalaryBillItemNameService; +import com.engine.salary.service.SalaryItemService; +import com.engine.salary.service.SalaryTemplateService; +import com.engine.salary.util.SalaryEntityUtil; +import com.google.common.collect.Lists; +import com.engine.salary.util.db.IdGenerator; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang.math.NumberUtils; +import org.apache.commons.lang3.StringUtils; +import weaver.hrm.User; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * @author Harryxzy + * @ClassName SalaryBillItemNameServiceImpl + * @date 2023/07/18 16:17 + * @description + */ +public class SalaryBillItemNameServiceImpl extends Service implements SalaryBillItemNameService { + + private SalaryBillItemNameMapper getSalaryBillItemNameMapper() { + return SqlProxyHandle.getProxy(SalaryBillItemNameMapper.class); + } + + private SalaryItemService getSalaryItemService(User user) { + return ServiceUtil.getService(SalaryItemServiceImpl.class, user); + } + + private SalaryTemplateService getSalaryTemplateService(User user) { + return ServiceUtil.getService(SalaryTemplateServiceImpl.class, user); + } + @Override + public List listAll() { + return getSalaryBillItemNameMapper().listAll(); + } + + @Override + public SalaryBillItemNamePO getById(Long id) { + return getSalaryBillItemNameMapper().getById(id); + } + + @Override + public int insertIgnoreNull(SalaryBillItemNamePO salaryBillItemNamePO) { + return getSalaryBillItemNameMapper().insertIgnoreNull(salaryBillItemNamePO); + } + + @Override + public int update(SalaryBillItemNamePO salaryBillItemNamePO) { + return getSalaryBillItemNameMapper().update(salaryBillItemNamePO); + } + + @Override + public int updateIgnoreNull(SalaryBillItemNamePO salaryBillItemNamePO) { + return getSalaryBillItemNameMapper().updateIgnoreNull(salaryBillItemNamePO); + } + + @Override + public int delete(Long id) { + return getSalaryBillItemNameMapper().delete(id); + } + + @Override + public List ListByTemplateAndType(SalaryBillItemNamePO param) { + return getSalaryBillItemNameMapper().listSome(param); + } + + @Override + public void saveItemShowName(List saveList) { + saveList= saveList.stream().filter(param -> !Objects.isNull(param.getSalaryTemplateId()) && CollectionUtils.isNotEmpty(param.getItemShowNameSetting())).collect(Collectors.toList()); + if(CollectionUtils.isEmpty(saveList)) + return; + List templateIdList = saveList.stream().map(SalaryBillItemNameSaveParam::getSalaryTemplateId).distinct().collect(Collectors.toList()); + if(CollectionUtils.isEmpty(templateIdList) || templateIdList.size()>1){ + throw new SalaryRunTimeException("工资单模板id为空,或存在多个工资单模板id"); + } + Long salaryTemplateId = templateIdList.get(0); + SalaryTemplatePO salaryTemplatePO = getSalaryTemplateService(user).getById(salaryTemplateId); + if(Objects.isNull(salaryTemplatePO)){ + throw new SalaryRunTimeException("工资单模板不存在或已被删除"); + } + List needInsertList = new ArrayList<>(); + List needUpdateList = new ArrayList<>(); + Date now = new Date(); + // 根据模板类型分组 + Map> saveMap = SalaryEntityUtil.convert2Map(saveList, SalaryBillItemNameSaveParam::getSalaryBillType, SalaryBillItemNameSaveParam::getItemShowNameSetting); + + for(Map.Entry> entry : saveMap.entrySet()){ + // 获取已经设置的展示名 + List billItemNameList = ListByTemplateAndType(SalaryBillItemNamePO.builder().salaryTemplateId(salaryTemplateId).salaryBillType(entry.getKey()).build()); + Map billItemNameMap = SalaryEntityUtil.convert2Map(billItemNameList, SalaryBillItemNamePO::getSalaryItemId); + List needDeleteItemIdList = new ArrayList<>(); + + entry.getValue().stream().forEach(setting -> { + if(StringUtils.isBlank(setting.getSalaryItemShowName())){ + // 显示名为空则删除设置 + needDeleteItemIdList.add(setting.getSalaryItemId()); + }else{ + if(billItemNameMap.containsKey(setting.getSalaryItemId())){ + // 更新 + SalaryBillItemNamePO po = billItemNameMap.get(setting.getSalaryItemId()); + po.setSalaryItemShowName(setting.getSalaryItemShowName()); + po.setUpdateTime(now); + needUpdateList.add(po); + }else{ + // 新增 + needInsertList.add(SalaryBillItemNamePO.builder() + .id(IdGenerator.generate()) + .salaryItemId(setting.getSalaryItemId()) + .salaryItemShowName(setting.getSalaryItemShowName()) + .salaryTemplateId(salaryTemplateId) + .salaryBillType(entry.getKey()) + .createTime(now) + .updateTime(now) + .creator(Long.valueOf(user.getUID())) + .deleteType(NumberUtils.INTEGER_ZERO) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .build()); + } + } + }); + // 删除 + batchDeleteByItemIdsAndTemplateId(needDeleteItemIdList, salaryTemplateId, entry.getKey()); + } + // 入库 + batchUpdate(needUpdateList); + batchInsert(needInsertList); + } + + @Override + public void batchUpdate(List needUpdateList) { + if(CollectionUtils.isEmpty(needUpdateList)){ + return; + } + List> partition = Lists.partition(needUpdateList, 500); + partition.forEach(getSalaryBillItemNameMapper()::batchUpdate); + } + + @Override + public void batchInsert(List needInsertList) { + if(CollectionUtils.isEmpty(needInsertList)){ + return; + } + List> partition = Lists.partition(needInsertList, 500); + partition.forEach(getSalaryBillItemNameMapper()::batchInsert); + } + + @Override + public void deleteByIds(List needDeleteIds) { + if(CollectionUtils.isEmpty(needDeleteIds)){ + return; + } + List> partition = Lists.partition(needDeleteIds, 1000); + partition.forEach(getSalaryBillItemNameMapper()::deleteByIds); + } + + public void batchDeleteByItemIdsAndTemplateId(List salaryItemIds, Long salaryTemplateId, Integer salaryBillType) { + if(CollectionUtils.isEmpty(salaryItemIds) || Objects.isNull(salaryTemplateId) || Objects.isNull(salaryBillType)) + return; + getSalaryBillItemNameMapper().deleteByItemIdsAndTemplateId(salaryItemIds, salaryTemplateId, salaryBillType); + } + + @Override + public void deleteByTemplateIds(Collection ids) { + if(CollectionUtils.isEmpty(ids)){ + return; + } + getSalaryBillItemNameMapper().deleteByTemplateIds(ids); + } +} diff --git a/src/com/engine/salary/service/impl/SalaryBillServiceImpl.java b/src/com/engine/salary/service/impl/SalaryBillServiceImpl.java new file mode 100644 index 000000000..e51b45513 --- /dev/null +++ b/src/com/engine/salary/service/impl/SalaryBillServiceImpl.java @@ -0,0 +1,1185 @@ +package com.engine.salary.service.impl; + +import cn.hutool.core.io.FileUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.api.formmode.mybatis.util.SqlProxyHandle; +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.hrmelog.entity.dto.LoggerContext; +import com.engine.salary.biz.SalarySendBiz; +import com.engine.salary.biz.SalarySendInfoBiz; +import com.engine.salary.cache.SalaryCacheKey; +import com.engine.salary.config.SalaryElogConfig; +import com.engine.salary.constant.HrmSalaryPayrollConf; +import com.engine.salary.entity.progress.ProgressDTO; +import com.engine.salary.entity.salaryBill.bo.SalaryBillBO; +import com.engine.salary.entity.salaryBill.bo.SalaryTemplateBO; +import com.engine.salary.entity.salaryBill.dto.*; +import com.engine.salary.entity.salaryBill.param.SalaryExportPdfParam; +import com.engine.salary.entity.salaryBill.param.SalarySendGrantParam; +import com.engine.salary.entity.salaryBill.param.SalarySendInfoQueryParam; +import com.engine.salary.entity.salaryBill.po.SalarySendInfoPO; +import com.engine.salary.entity.salaryBill.po.SalarySendPO; +import com.engine.salary.entity.salaryBill.po.SalaryTemplatePO; +import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO; +import com.engine.salary.entity.salaryacct.po.SalaryAcctResultPO; +import com.engine.salary.entity.salarysob.po.SalarySobPO; +import com.engine.salary.enums.OperateTypeEnum; +import com.engine.salary.enums.salarybill.*; +import com.engine.salary.enums.salarysend.SalarySendGrantTypeEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.mapper.salarybill.SalarySendInfoMapper; +import com.engine.salary.mapper.salarybill.SalarySendMapper; +import com.engine.salary.service.*; +import com.engine.salary.util.JsonUtil; +import com.engine.salary.util.SalaryDateUtil; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.pdf.HtmlToPdf; +import com.google.common.collect.Lists; +import com.weaver.util.threadPool.ThreadPoolUtil; +import com.weaver.util.threadPool.constant.ModulePoolEnum; +import com.weaver.util.threadPool.entity.LocalRunnable; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.beanutils.BeanUtils; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.math.NumberUtils; +import weaver.hrm.User; + +import java.io.File; +import java.lang.reflect.InvocationTargetException; +import java.math.BigDecimal; +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.stream.Collectors; + +import static com.engine.salary.constant.HrmSalaryPayrollConf.GEN_PDF; + +/** + * 工资单发放 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Slf4j +public class SalaryBillServiceImpl extends Service implements SalaryBillService { + + + private SalarySendMapper getSalarySendMapper() { + return SqlProxyHandle.getProxy(SalarySendMapper.class); + } + + private SalarySendInfoMapper getSalarySendInfoMapper() { + return SqlProxyHandle.getProxy(SalarySendInfoMapper.class); + } + + + private SalaryTemplateService getSalaryTemplateService(User user) { + return ServiceUtil.getService(SalaryTemplateServiceImpl.class, user); + } + + private SalarySendService getSalarySendService(User user) { + return ServiceUtil.getService(SalarySendServiceImpl.class, user); + } + + private SalarySobService getSalarySobService(User user) { + return ServiceUtil.getService(SalarySobServiceImpl.class, user); + } + + private SalaryAcctResultService getSalaryAcctResultService(User user) { + return ServiceUtil.getService(SalaryAcctResultServiceImpl.class, user); + } + + private SalaryAcctEmployeeService getSalaryAcctEmployeeService(User user) { + return ServiceUtil.getService(SalaryAcctEmployeeServiceImpl.class, user); + } + + private TaxAgentService getTaxAgentService(User user) { + return ServiceUtil.getService(TaxAgentServiceImpl.class, user); + } + + private SalarySendRangeService getSalarySendRangeService(User user) { + return ServiceUtil.getService(SalarySendRangeServiceImpl.class, user); + } + + private SalaryAcctRecordService getSalaryAcctRecordService(User user) { + return ServiceUtil.getService(SalaryAcctRecordServiceImpl.class, user); + } + + private SalaryEmployeeService getSalaryEmployeeService(User user) { + return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user); + } + + private SalaryBillBaseSetService getSalaryBillBaseSetService(User user) { + return ServiceUtil.getService(SalaryBillBaseSetServiceImpl.class, user); + } + + + private SalarySendInfoBiz salarySendInfoMapper = new SalarySendInfoBiz(); + private SalarySendBiz mapper = new SalarySendBiz(); + + private SalaryEmployeeService salaryEmployeeService; + + private SalarySobItemService salarySobItemService; + + + private ProgressService getProgressService(User user) { + return ServiceUtil.getService(ProgressServiceImpl.class, user); + } + + /** + * 工资单发放 start + **********************************************************************/ + @Override + public Map grant(SalarySendGrantParam param) { + // 1.检查和获取工资单发放 + SalarySendPO salarySend = checkAndGetSalarySend(param.getSalarySendId()); +// // 已经冻结不能操作 +// if (salarySend.getSendStatus().equals(NumberUtils.INTEGER_ONE)) { +// return; +// } + // 获取默认模板 + SalarySobPO salarySob = getSalarySobService(user).getById(salarySend.getSalarySobId()); + List salaryTemplates = salarySob == null ? Lists.newArrayList() : getSalaryTemplateService(user).getDefaultTemplates(Arrays.asList(salarySend.getSalarySobId(), salarySob.getId())); + if (CollectionUtils.isEmpty(salaryTemplates)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100518, "没有默认模板,无法发送")); + } + SalaryTemplatePO salaryTemplate = salaryTemplates.get(0); + + // 发送通道 + Set sendChannels = SalaryBillBO.buildSendChannels(salaryTemplate); + if (CollectionUtils.isEmpty(sendChannels)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(149767, "工资单模板至少开启一个发送通道")); + } + boolean isReplenish = NumberUtils.INTEGER_ONE.equals(salarySend.getSalaryAcctType()); + if (isReplenish && StringUtils.isEmpty(salaryTemplate.getReplenishName())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(204428, "请完善补发工资单模板设置")); + } + // 2.检查是否正在发送中 + ProgressDTO salaryBillProgress = getProgressService(user).getProgress(SalaryCacheKey.SALARY_GRANT_PROGRESS + "_" + param.getSalarySendId()); + if (Objects.nonNull(salaryBillProgress) && salaryBillProgress.isStatus() + && Optional.ofNullable(salaryBillProgress.getProgress()).orElse(BigDecimal.ZERO).compareTo(BigDecimal.ONE) < 0) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(136104, "有其他人员正在发送中,请等待其他人员发送结束后再操作")); + } + + List ids = param.getIds(); + + if (param.getSalarySendRangeIds() != null) { + //如果传了范围id,则使用范围id发放 + ids = getSalarySendRangeService(user) + .getSendInfoIdsBySendId(salarySend.getId(), param.getSalarySendRangeIds(), SalarySendGrantTypeEnum.GRANT); + if (ids.isEmpty()) {// 由于查出来是空的,会导致全部发放,在此进行拦截 + throw new SalaryRunTimeException("工资发放范围内没有匹配员工"); + } + } + // 初始化进度 + ProgressDTO initProgress = ProgressDTO.builder() + .title(SalaryI18nUtil.getI18nLabel(136097, "发送中")) + .totalQuantity(NumberUtils.INTEGER_ZERO) + .calculatedQuantity(NumberUtils.INTEGER_ZERO) + .progress(BigDecimal.ZERO) + .status(true) + .message("") + .build(); + getProgressService(user).initProgress(SalaryCacheKey.SALARY_GRANT_PROGRESS + "_" + salarySend.getId(), initProgress); + + // 异步执行 + List finalIds = ids; + LocalRunnable localRunnable = new LocalRunnable() { + @Override + public void execute() { + handleGrant(salarySend, finalIds, salarySob, salaryTemplate); + } + }; + ThreadPoolUtil.fixedPoolExecute(ModulePoolEnum.OTHER, "salaryBillGrant", localRunnable); + + return new HashMap<>(); + } + + /** + * 对于已经发送的工资单,重新生成pdf + * @param param + * @return + */ + @Override + public Map reGenPdf(SalarySendGrantParam param) { + // 1.检查和获取工资单发放 + SalarySendPO salarySend = checkAndGetSalarySend(param.getSalarySendId()); + // 获取默认模板 + SalarySobPO salarySob = getSalarySobService(user).getById(salarySend.getSalarySobId()); + List salaryTemplates = salarySob == null ? Lists.newArrayList() : getSalaryTemplateService(user).getDefaultTemplates(Arrays.asList(salarySend.getSalarySobId(), salarySob.getId())); + SalaryTemplatePO salaryTemplate = salaryTemplates.get(0); + List ids = param.getIds(); + if (param.getSalarySendRangeIds() != null) { + //如果传了范围id,则使用范围id发放 + ids = getSalarySendRangeService(user) + .getSendInfoIdsBySendId(salarySend.getId(), param.getSalarySendRangeIds(), SalarySendGrantTypeEnum.GRANT); + if (ids.isEmpty()) {// 由于查出来是空的,会导致全部发放,在此进行拦截 + throw new SalaryRunTimeException("工资发放范围内没有匹配员工"); + } + } + try { + // 1.构建发送参数 + SalaryBillSendDTO salaryBillSendParam = buildSendParams(salarySend, salaryTemplate); + // 2.获取可发送的列表,此步最耗时,需要解密核算数据 + List sendStatusList = Arrays.asList(SalarySendStatusEnum.UNSEND.getValue(), SalarySendStatusEnum.WITHDRAW.getValue(), SalarySendStatusEnum.ALREADYSEND.getValue()); + List> enableSendList = getEnableSendList(salarySend, ids, salaryBillSendParam, sendStatusList); + //生成pdf + genPdf(salaryBillSendParam, enableSendList, true); + getProgressService(user).finish(SalaryCacheKey.SALARY_GRANT_PROGRESS + "_" + salarySend.getId(), true); + } catch (Exception e) { + log.info("发送出错:{}", e.getMessage(), e); + } + return new HashMap<>(); + } + + + /** + * 处理发送 + * 注意: + * 1.IM和云桥通道是发送完成后,只需要在预览时获取核算数据,所以发送时可以忽略获取核算数据; + * 2.邮件通道需要在发送时获取,拼凑成html代码,有图片会转化为base64编码变慢,且图片越大越慢 + * + * @param salarySend + * @param ids + * @param salarySob + * @param salaryTemplate + */ + private void handleGrant(SalarySendPO salarySend, List ids, SalarySobPO salarySob, SalaryTemplatePO salaryTemplate) { + try { + + // 1.构建发送参数 + SalaryBillSendDTO salaryBillSendParam = buildSendParams(salarySend, salaryTemplate); + + // 2.获取可发送的列表,此步最耗时,需要解密核算数据 + List sendStatusList = Arrays.asList(SalarySendStatusEnum.UNSEND.getValue(), SalarySendStatusEnum.WITHDRAW.getValue()); + List> enableSendList = getEnableSendList(salarySend, ids, salaryBillSendParam, sendStatusList); + + // 3.发送消息:先修改数据再发消息,避免出错后无法撤回 + List successIds = sendMessage(enableSendList, salaryBillSendParam); + + //生成pdf + genPdf(salaryBillSendParam, enableSendList, false); + + // 4.发放 + grantSendInfo(successIds, salarySend, salaryTemplate, salaryBillSendParam); + + // 5.更新数量 + updateSendNum(salarySend, salarySob); + + int total = enableSendList.size(); + int successCount = successIds.size(); + String messsage = SalaryI18nUtil.getI18nLabel(139208, "发送完成") + ": " + + SalaryI18nUtil.getI18nLabel(134807, "成功条数") + "[" + (successCount) + "], " + + SalaryI18nUtil.getI18nLabel(134808, "失败条数") + "[" + (total - successCount) + "]"; + // 发送进度完成 + getProgressService(user).finish(SalaryCacheKey.SALARY_GRANT_PROGRESS + "_" + salarySend.getId(), true, messsage); + } catch (Exception e) { + log.info("发送出错:{}", e.getMessage(), e); + // 发送进度失败 + getProgressService(user).fail(SalaryCacheKey.SALARY_GRANT_PROGRESS + "_" + salarySend.getId(), SalaryI18nUtil.getI18nLabel(136118, "工资单发送出错") + ": " + e.getMessage()); + } finally { + } + } + + private void genPdf(SalaryBillSendDTO salaryBillSendParam, List> enableSendList, boolean isSync) { + if (GEN_PDF) { + if (isSync) { + genPdf(salaryBillSendParam, enableSendList); + } else { + LocalRunnable localRunnable = new LocalRunnable() { + @Override + public void execute() { + genPdf(salaryBillSendParam, enableSendList); + } + }; + ThreadPoolUtil.fixedPoolExecute(ModulePoolEnum.OTHER, "salaryBillGenPdf", localRunnable); + } + + } + } + + private void genPdf(SalaryBillSendDTO salaryBillSendParam, List> enableSendList) { + //生成工资单pdf + enableSendList.forEach(e -> { + // 构建人员信息 + SalaryBillBO.buildEmployeeInfo(salaryBillSendParam, e); + SalaryBillBO.genPdf(e, salaryBillSendParam); + }); + + //合并工资单pdf + //1、先获取所有工资单 + Long id = salaryBillSendParam.getSalarySend().getId(); + List salarySendInfos = getSalarySendInfoMapper().listSome(SalarySendInfoPO.builder().salarySendId(id).sendStatus(1).build()); + //2、工资单pdf转为路径 + String yyyyMM = SalaryDateUtil.getFormatYearMonth(salaryBillSendParam.getSalaryDate()); + List filesToMerge = salarySendInfos.stream().map(po -> HrmSalaryPayrollConf.GEN_PATH + yyyyMM + File.separator + id + File.separator + po.getId() + ".pdf").collect(Collectors.toList()); + String pdfPath = HrmSalaryPayrollConf.GEN_PATH + yyyyMM + File.separator + id + File.separator + id + ".pdf"; + SalaryBillBO.mergePdf(pdfPath, filesToMerge); + } + + /** + * 构建发送参数 + * + * @param salarySend + * @param salaryTemplate + * @return + */ + public SalaryBillSendDTO buildSendParams(SalarySendPO salarySend, SalaryTemplatePO salaryTemplate) { + // 发送通道 + Set sendChannels = SalaryBillBO.buildSendChannels(salaryTemplate); + if (CollectionUtils.isEmpty(sendChannels)) { + return null; + } + Date salaryMonth = salarySend.getSalaryMonth(); + + boolean isReplenish = NumberUtils.INTEGER_ONE.equals(salarySend.getSalaryAcctType()); +// SalaryTemplateBO.copyShowSet(isReplenish, salaryTemplate); + + // 消息标题 +// String title = SalaryBillBO.getBillTitle(salaryTemplate.getTheme(), salaryMonth, 0L); + + // 云桥企业微信消息图 + String domain = ""; + // todo 访问本项目中的图片需要登陆才能访问,且变成空白,所以还是得改成公网,或者后续鉴权忽略 + // StringUtils.isEmpty(server) || StringUtils.isEmpty(staticPathPattern) ? "https://wx.weaver.com.cn/main/salary/cover.png" : (server+staticPathPattern).replace("**", "salary_bill.png"); + String picUrl = domain + String.format("/papi/file/preview?type=imgs&fileId=%s&random=123456", salaryTemplate.getBackground()); // "https://wx.weaver.com.cn/main/salary/cover.png"; + String backgroundBase64 = ""; +// if (StringUtils.isNotBlank(salaryTemplate.getBackground()) && isEnableEmail) { + // 2.base64码的方式,这种方式可以不管图片地址是否是内外网,缺点是内容太长 +// FileData fileByte = fileDownloadClient.getFileByte(Long.valueOf(salaryTemplate.getBackground())); +// backgroundBase64 = Base64Encoder.encode(fileByte.getData()); + // 千万不要这样做,否则存入salaryTemplate字段会变的很大: salaryTemplate.setBackground(backgroundBase64); +// } + + // 工资单预览实体名 + String entityName = SalaryI18nUtil.getI18nLabel(94626, "工资单"); + + // 获取人员信息项目分类 + List salaryItemSetList = JSONArray.parseArray(isReplenish ? salaryTemplate.getReplenishSalaryItemSetting() : salaryTemplate.getSalaryItemSetting(), SalaryTemplateSalaryItemSetListDTO.class); + // 国际化处理 +// salaryItemSetList = SalaryTemplateBO.handleI18n(salaryItemSetList); + SalaryTemplateSalaryItemSetListDTO employeeInformation = SalaryTemplateBO.getEmployeeInformation(salaryItemSetList); + + Map employeeField = SalaryBillBO.buildEmployeeFieldName(); + + String remarkI18n = SalaryI18nUtil.getI18nLabel(140036, "发放说明"); + if (StringUtils.isNotEmpty(salaryTemplate.getTextContent())) { + salaryTemplate.setTextContent(salaryTemplate.getTextContent().replace("${salaryMonth}", new SimpleDateFormat("yyyy年MM月").format(salaryMonth))); + } + + // 工资单水印设置 + SalaryBillWatermarkDTO salaryBillWatermark = getSalaryBillBaseSetService(user).getWatermarkSetting(); + // 工资单水印文本动态变量 + List wmTextFieldIds = SalaryBillBO.getWmTextFieldIds(domain, salaryBillWatermark); + // 邮件水印模板 + boolean isEnableEmail = salaryTemplate.getEmailStatus().equals(SalaryTemplateWhetherEnum.TRUE.getValue()); + String emailWmContentTemplate = SalaryBillBO.buildEmailWmContentTemplate(isEnableEmail, salaryBillWatermark); + + return SalaryBillSendDTO.builder() + .salaryDate(salaryMonth) + // 消息标题 +// .title(title) + // 消息内容:目前跟title一样 +// .text(title) + // 工资单预览实体名 + .entityName(entityName) + // 发送通道 + .sendChannels(sendChannels) + // 发送者 + .sendUser(user) + // 工资单模板 + .salaryTemplate(salaryTemplate) + // 工资单背景图base64编码 + .backgroundBase64(backgroundBase64) + // 云桥工资单消息图 + .picUrl(picUrl) + // 工资单模板-薪资项目设置 + .salaryItemSetList(salaryItemSetList) + // 工资单模板-员工基本信息 + .employeeInformation(employeeInformation) + // 工资单模板-对应人员字段 + .employeeField(employeeField) + //短信模板 + .smsSetting(JSON.parseObject(salaryTemplate.getSmsSetting(), SalaryTemplateSMSSetDTO.class)) + // 工资单模板-发放说明标签国际化 + .remarkI18n(remarkI18n) + // 邮件是否可以发送邮件 +// .isEnableEmail(isEnableEmail) + // 工资单发放 + .salarySend(salarySend) + // 收入所得项目类型 +// .incomeCategorys(incomeCategorys) + //薪资项目收入所得类型 +// .salaryItemIncomeCategoryMap(salaryItemIncomeCategoryMap) + // 工资单水印设置 + .watermarkSetting(salaryBillWatermark) + // 工资单水印文本动态变量 + .wmTextFieldIds(wmTextFieldIds) + // 邮件水印模板 + .emailWmContentTemplate(emailWmContentTemplate) + .build(); + } + + /** + * 获取可发送数据 + * + * @param salarySend + * @param ids + * @return + */ + private List> getEnableSendList(SalarySendPO salarySend, List ids, SalaryBillSendDTO salaryBillSendParam, List sendStatus) { + SalarySendInfoQueryParam queryParam = new SalarySendInfoQueryParam(); + queryParam.setSalarySendId(salarySend.getId()); + // 空就是所有 + queryParam.setIds(ids); + queryParam.setSendStatuss(sendStatus); + // 2.获取基本数据 + List list = Lists.newArrayList(); + if (CollectionUtils.isEmpty(ids)) { + list = getSalarySendInfoMapper().list(queryParam); + } else { + List> partition = Lists.partition(ids, 500); + for (List idsPart : partition) { + queryParam.setIds(idsPart); + list.addAll(getSalarySendInfoMapper().list(queryParam)); + } + } + + List salaryAcctEmployeeList = this.getSalaryAcctEmployeeService(user).listBySalaryAcctRecordId(salarySend.getSalaryAccountingId()); + List acctEmployeeIds = salaryAcctEmployeeList.stream().map(SalaryAcctEmployeePO::getEmployeeId).distinct().collect(Collectors.toList()); + list = list.stream().filter(f -> acctEmployeeIds.contains(f.getEmployeeId())).collect(Collectors.toList()); + SalaryI18nUtil.i18nList(list); + + List employeeIds = list.stream().map(SalarySendInfoListDTO::getEmployeeId).collect(Collectors.toList()); + + // 初始化进度 + ProgressDTO initProgress = ProgressDTO.builder() + .title("发送中") + .totalQuantity(employeeIds.size() * 2 + 1) + .status(true) + .calculatedQuantity(NumberUtils.INTEGER_ZERO) + .progress(BigDecimal.ZERO) + .message("") + .build(); + getProgressService(user).initProgress(SalaryCacheKey.SALARY_GRANT_PROGRESS + "_" + salarySend.getId(), initProgress); + // 3.组装详情数据 + // 获取薪资项目数据 + List salaryAcctEmployees = Lists.newArrayList(); + List salaryAcctResultValues = Lists.newArrayList(); + + //是否需要发送邮件 + boolean isEnableEmail = salaryBillSendParam.getSendChannels().contains(MessageChannelEnum.EMAIL); + boolean isEnableSMS = salaryBillSendParam.getSendChannels().contains(MessageChannelEnum.SMS); + if (CollectionUtils.isNotEmpty(ids)) { + int partSize = 100;// 分片大小,越小进度条跑得越短平快,但是总体速度更慢 + List> partition = Lists.partition(employeeIds, partSize); + for (List part : partition) { + // 更新进度 + getProgressService(user).getAndAddCalculatedQty(SalaryCacheKey.SALARY_GRANT_PROGRESS + "_" + salarySend.getId(), part.size()); + /** 注意只有邮件或生成pdf才需要加密的核算数据 */ + if (isEnableEmail || isEnableSMS || GEN_PDF) { + List acctEmployees = getSalaryAcctEmployeeService(user).listBySalaryAcctRecordIdsAndEmployeeIds(Collections.singletonList(salarySend.getSalaryAccountingId()), part); + salaryAcctEmployees.addAll(acctEmployees); + salaryAcctResultValues.addAll(getSalaryAcctResultService(user).listBySalaryAcctEmployeeIds(SalaryEntityUtil.properties(acctEmployees, SalaryAcctEmployeePO::getId, Collectors.toList()))); + } + } + } else { + /** 注意只有邮件才需要加密的核算数据 */ + if (isEnableEmail || isEnableSMS || GEN_PDF) { + salaryAcctEmployees = getSalaryAcctEmployeeService(user).listBySalaryAcctRecordId(salarySend.getSalaryAccountingId()); + salaryAcctResultValues = getSalaryAcctResultService(user).listBySalaryAcctRecordIds(Collections.singletonList(salarySend.getSalaryAccountingId())); + } + } + // 外部人员 +// List extEmployeeList = extEmployeeService.listAllWithDeleted(currentTenantKey); + return getSalarySendService(user) + .buildDetailList(list, salaryAcctEmployees, salaryAcctResultValues); + } + + @Override + public void confirmSalaryBill(Long salaryInfoId) { + SalarySendInfoPO sendInfoPO = getSalarySendInfoMapper().getById(salaryInfoId); + if (sendInfoPO == null) { + throw new SalaryRunTimeException("工资单不存在或已被删除!"); + } + sendInfoPO.setBillConfirmStatus(BillConfimStatusEnum.CONFIRMED.getValue()); + sendInfoPO.setUpdateTime(new Date()); + getSalarySendInfoMapper().updateIgnoreNull(sendInfoPO); + } + + @Override + public void feedBackSalaryBill(Long salaryInfoId) { + SalarySendInfoPO sendInfoPO = getSalarySendInfoMapper().getById(salaryInfoId); + if (sendInfoPO == null) { + throw new SalaryRunTimeException("工资单不存在或已被删除!"); + } + sendInfoPO.setBillConfirmStatus(BillConfimStatusEnum.FEEDBACK.getValue()); + sendInfoPO.setUpdateTime(new Date()); + getSalarySendInfoMapper().updateIgnoreNull(sendInfoPO); + } + + @Override + public String exportPdf(SalaryExportPdfParam param) { + SalarySendPO salarySend = checkAndGetSalarySend(param.getSalarySendId()); + String yearMonth = SalaryDateUtil.getFormatYearMonth(salarySend.getSalaryMonth()); + String path = HrmSalaryPayrollConf.GEN_PATH + File.separator + yearMonth + File.separator + salarySend.getId() + File.separator + "%s" + ".pdf"; + Long id = param.getId(); + if (id == null) { + path = String.format(path, param.getSalarySendId()); + } else { + path = String.format(path, id); + } + return path; + } + + @Override + public String genPdfBeforeExport(SalaryExportPdfParam param) { + // 先判断对应路径下是否存在pdf + SalarySendPO salarySend = checkAndGetSalarySend(param.getSalarySendId()); + String yearMonth = SalaryDateUtil.getFormatYearMonth(salarySend.getSalaryMonth()); + String pdfPath = HrmSalaryPayrollConf.GEN_PATH + File.separator + yearMonth + File.separator + salarySend.getId() + File.separator + "%s" + ".pdf"; + Long id = param.getId(); + if (id == null) { + pdfPath = String.format(pdfPath, param.getSalarySendId()); + } else { + pdfPath = String.format(pdfPath, id); + } + File file = new File(pdfPath); + if (file.exists()) { + return "success"; + } + + // 判断对应路径下是否存在html + String htmlPath = HrmSalaryPayrollConf.GEN_PATH + File.separator + yearMonth + File.separator + salarySend.getId() + File.separator + "%s" + ".html"; + if (id == null) { + htmlPath = String.format(htmlPath, param.getSalarySendId()); + } else { + htmlPath = String.format(htmlPath, id); + } + file = new File(htmlPath); + if (file.exists()) { + // 将html转成pdf + FileUtil.del(pdfPath); + HtmlToPdf.convert(HrmSalaryPayrollConf.TO_PDF_TOOL_PATH, htmlPath, pdfPath); + mergePdf(param, yearMonth); + return "success"; + } + + // 先生成html再生成pdf + SalarySendGrantParam grantParam = SalarySendGrantParam.builder().salarySendId(param.getSalarySendId()).ids(Collections.singletonList(param.getId())).build(); + reGenPdf(grantParam); + return "success"; + + } + + private void mergePdf(SalaryExportPdfParam param, String yearMonth) { + //合并工资单pdf + //1、先获取所有工资单 + Long salarySendId = param.getSalarySendId(); + List salarySendInfos = getSalarySendInfoMapper().listSome(SalarySendInfoPO.builder().salarySendId(salarySendId).sendStatus(1).build()); + //2、工资单pdf转为路径 + List filesToMerge = salarySendInfos.stream().map(po -> HrmSalaryPayrollConf.GEN_PATH + yearMonth + File.separator + salarySendId + File.separator + po.getId() + ".pdf").collect(Collectors.toList()); + String pdfPath = HrmSalaryPayrollConf.GEN_PATH + yearMonth + File.separator + salarySendId + File.separator + salarySendId + ".pdf"; + SalaryBillBO.mergePdf(pdfPath, filesToMerge); + } + + public List> getSendInfoList(Long sendId, List ids) { + + SalarySendPO salarySend = getSalarySendMapper().getById(sendId); + SalarySendInfoQueryParam queryParam = new SalarySendInfoQueryParam(); + queryParam.setSalarySendId(salarySend.getId()); +// // 空就是所有 +// queryParam.setIds(ids); + queryParam.setSendStatuss(Arrays.asList(SalarySendStatusEnum.UNSEND.getValue(), SalarySendStatusEnum.WITHDRAW.getValue())); + // 2.获取基本数据 + List list = Lists.newArrayList(); + if (CollectionUtils.isEmpty(ids)) { + list = getSalarySendInfoMapper().list(queryParam); + } else { + List> partition = Lists.partition(ids, 500); + for (List idsPart : partition) { + queryParam.setIds(idsPart); + list.addAll(getSalarySendInfoMapper().list(queryParam)); + } + } + List salaryAcctEmployeeList = this.getSalaryAcctEmployeeService(user).listBySalaryAcctRecordId(salarySend.getSalaryAccountingId()); + List acctEmployeeIds = salaryAcctEmployeeList.stream().map(SalaryAcctEmployeePO::getEmployeeId).distinct().collect(Collectors.toList()); + list = list.stream().filter(f -> acctEmployeeIds.contains(f.getEmployeeId())).collect(Collectors.toList()); + + List employeeIds = list.stream().map(SalarySendInfoListDTO::getEmployeeId).collect(Collectors.toList()); + + // 3.组装详情数据 + // 获取薪资项目数据 + List salaryAcctEmployees = Lists.newArrayList(); + List salaryAcctResultValues = Lists.newArrayList(); + + //是否需要发送邮件 + if (CollectionUtils.isNotEmpty(ids)) { + int partSize = 100;// 分片大小,越小进度条跑得越短平快,但是总体速度更慢 + List> partition = Lists.partition(employeeIds, partSize); + for (List part : partition) { + // 更新进度 + List acctEmployees = getSalaryAcctEmployeeService(user).listBySalaryAcctRecordIdsAndEmployeeIds(Collections.singletonList(salarySend.getSalaryAccountingId()), part); + salaryAcctEmployees.addAll(acctEmployees); + salaryAcctResultValues.addAll(getSalaryAcctResultService(user).listBySalaryAcctEmployeeIds(SalaryEntityUtil.properties(acctEmployees, SalaryAcctEmployeePO::getId, Collectors.toList()))); + } + } else { + salaryAcctEmployees = getSalaryAcctEmployeeService(user).listBySalaryAcctRecordId(salarySend.getSalaryAccountingId()); + salaryAcctResultValues = getSalaryAcctResultService(user).listBySalaryAcctRecordIds(Collections.singletonList(salarySend.getSalaryAccountingId())); + } + return getSalarySendService(user) + .buildDetailList(list, salaryAcctEmployees, salaryAcctResultValues); + } + + /** + * 发送消息 + * + * @param enableSendList + * @param salaryBillSendParam + */ + private List sendMessage(List> enableSendList, SalaryBillSendDTO salaryBillSendParam) { + + if (CollectionUtils.isEmpty(enableSendList)) { + return Collections.emptyList(); + } + if (salaryBillSendParam == null) { + return enableSendList.stream().map(e -> Long.valueOf(e.get("id").toString())).collect(Collectors.toList()); + } + + Set sendChannels = salaryBillSendParam.getSendChannels(); + + List sendInfoUpdateList = Lists.newArrayList(); + AtomicInteger index = new AtomicInteger(0); + AtomicInteger part = new AtomicInteger(0); + int total = enableSendList.size(); + enableSendList.forEach(e -> { + + if (sendChannels.contains(MessageChannelEnum.MSG)) { + SalaryBillBO.sendMsg(salaryBillSendParam, Long.valueOf(e.get("id").toString()), Long.valueOf(e.get("employeeId").toString())); + } + + if (sendChannels.contains(MessageChannelEnum.EMAIL) || sendChannels.contains(MessageChannelEnum.SMS)) { + // 构建人员信息 + SalaryBillBO.buildEmployeeInfo(salaryBillSendParam, e); + + //发送邮件 + if (sendChannels.contains(MessageChannelEnum.EMAIL)) { + SalaryBillBO.sendEmail(e, salaryBillSendParam); + } + + //发送短信 + if (sendChannels.contains(MessageChannelEnum.SMS)) { + SalaryBillBO.sendSMS(e, salaryBillSendParam); + } + } + + /** 发送工资单 **********************************************************/ + sendInfoUpdateList.add(SalarySendInfoPO.builder() + .id(Long.valueOf(e.get("id").toString())) + .build()); + // 更新发送进度 + index.addAndGet(1); + part.addAndGet(1); + if (index.get() % 100 == 0 || index.get() >= total) { + getProgressService(user).getAndAddCalculatedQty(SalaryCacheKey.SALARY_GRANT_PROGRESS + "_" + salaryBillSendParam.getSalarySend().getId(), part.get()); + part.set(0); + } + }); + // 批量修改发送消息id + if (CollectionUtils.isNotEmpty(sendInfoUpdateList)) { + // sqlserver数据库处理,每个分片数量约=2100/插入字段数 + List> partition = Lists.partition(sendInfoUpdateList, 500); +// partition.forEach(updatePart -> getSalarySendInfoMapper().batchUpdateMsgId(updatePart)); + } + return sendInfoUpdateList.stream().map(SalarySendInfoPO::getId).collect(Collectors.toList()); + } + +// /** 工资单发放 end **********************************************************************/ + + /** + * 检查和获取工资单发放信息 + * + * @param salarySendId + * @return + */ + private SalarySendPO checkAndGetSalarySend(Long salarySendId) { + if (salarySendId == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100327, "工资单发放Id必传")); + } + + SalarySendPO salarySend = this.getSalarySendService(user).getById(salarySendId); + if (salarySend == null) { + throw new SalaryRunTimeException(String.format(SalaryI18nUtil.getI18nLabel(100512, "工资单发放不存在") + "[id:%s]", salarySendId)); + } + return salarySend; + } + +// /** +// * 分权处理 +// * +// * @param salarySend +// * @param ids +// * @param currentEmployeeId +// * @param currentTenantKey +// * @return +// */ +// private List getIdsForDevolution(SalarySendPO salarySend, List ids) { +// // 开启分权或且是非薪酬模块总管理员且发送全部 +// if (getTaxAgentService(user).isOpenDevolution(currentTenantKey) && !getTaxAgentService(user).isChief(currentEmployeeId) && CollectionUtils.isEmpty(ids)) { +// List salaryAcctEmployees = getSalaryAcctEmployeeService(user) +// .listByRecordIds(Collections.singletonList(salarySend.getSalaryAccountingId())); +// +// List taxAgentIdsAsAdmin = getTaxAgentService(user).listAllTaxAgentsAsAdmin(currentEmployeeId).stream().map(TaxAgentPO::getId) +// .collect(Collectors.toList()); +// List taxAgentEmployees = getTaxAgentService(user).listTaxAgentAndEmployeeTree(currentEmployeeId).stream() +// .filter(t -> !taxAgentIdsAsAdmin.contains(t.getTaxAgentId())).collect(Collectors.toList()); +// Map> taxAgentEmployeesMap = SalaryEntityUtil.convert2Map(taxAgentEmployees, TaxAgentManageRangeEmployeeDTO::getTaxAgentId, +// v -> v.getEmployeeList().stream().map(TaxAgentManageRangeEmployeeDTO.TaxAgentEmployee::getEmployeeId).collect(Collectors.toList())); +// +// List extEmployeeList = extEmployeeService.listCanUse(currentEmployeeId); +// // 工资单发放信息过滤 +// List salarySendInfos = new LambdaQueryChainWrapper<>(getSalarySendInfoMapper()) +// /** 注意:需要啥就加载啥,避免加载大字段salaryTemplate */ +// .select(SalarySendInfoPO::getId, SalarySendInfoPO::getEmployeeId, SalarySendInfoPO::getCreator) +// .eq(SalarySendInfoPO::getDeleteType, 0) +// .eq(SalarySendInfoPO::getTenantKey) +// .eq(SalarySendInfoPO::getSalarySendId, salarySend.getId()) +// .list(); +// +// List acctEmployeeIds = salaryAcctEmployees.stream().filter(f -> +// // 作为管理员 +// taxAgentIdsAsAdmin.contains(f.getTaxAgentId()) +// // 作为分管理员 +// || TaxAgentBO.checkTaxAgentAndEmployee(taxAgentEmployeesMap, f.getTaxAgentId(), f.getEmployeeId()) +// // 外部人员 +// || extEmployeeList.stream().anyMatch(t -> t.getTaxAgentId().equals(f.getTaxAgentId()) && t.getId().equals(f.getEmployeeId())) +// ).map(SalaryAcctEmployeePO::getEmployeeId).collect(Collectors.toList()); +// +// ids = salarySendInfos.stream().filter(f -> acctEmployeeIds.contains(f.getEmployeeId()) || currentEmployeeId.equals(f.getCreator())).map(SalarySendInfoPO::getId) +// .distinct().collect(Collectors.toList()); +// } +// return ids; +// } + + /** + * 发放工资单更新信息 + * + * @param ids + * @param salarySend + * @param salaryTemplate + */ + private void grantSendInfo(List ids, SalarySendPO salarySend, SalaryTemplatePO salaryTemplate, SalaryBillSendDTO salaryBillSendDTO) { + String waterMarkJson = salaryBillSendDTO.getWatermarkSetting() == null ? "" : JsonUtil.toJsonString(salaryBillSendDTO.getWatermarkSetting()); + // 水印设置 + salaryTemplate.setSalaryWatermark(waterMarkJson); + + List> partition = Lists.partition(ids, 500); + Date sendTime = new Date(); + SalarySendInfoPO po = new SalarySendInfoPO(); + po.setSendStatus(SalarySendStatusEnum.ALREADYSEND.getValue()); + po.setSendTime(sendTime); + po.setSalaryTemplate(JsonUtil.toJsonString(salaryTemplate)); + po.setBillReadStatus(BillReadStatusEnum.UNREAD.getValue()); + po.setBillConfirmStatus(BillConfimStatusEnum.UNCONFIRMED.getValue()); + po.setSendEmployeeId(Long.valueOf(user.getUID())); + partition.forEach(idsp -> { + salarySendInfoMapper.updateGrantWithdraw(po, salarySend.getId(), Arrays.asList(SalarySendStatusEnum.UNSEND.getValue(), SalarySendStatusEnum.WITHDRAW.getValue()), idsp); + }); + } + +// /** +// * 撤回工资单更新信息 +// * +// * @param ids +// * @param salarySend +// * @param currentTenantKey +// */ +// private void withdrawSendInfo(List ids, SalarySendPO salarySend) { +// List> partition = Lists.partition(ids, DbCrudConstant.DEF_PART_SIZE); +// partition.forEach(part -> new LambdaUpdateChainWrapper<>(getSalarySendInfoMapper()) +// .eq(SalarySendInfoPO::getDeleteType, 0) +// .eq(SalarySendInfoPO::getTenantKey) +// .eq(SalarySendInfoPO::getSalarySendId, salarySend.getId()) +// .eq(SalarySendInfoPO::getSendStatus, SalarySendStatusEnum.ALREADYSEND.getValue()) +// .in(SalarySendInfoPO::getId, part) +// .set(SalarySendInfoPO::getSendStatus, SalarySendStatusEnum.WITHDRAW.getValue()) +// .update()); +// } +// + + /** + * 更新发送数量 + * + * @param salarySend + * @param salarySob + */ + private void updateSendNum(SalarySendPO salarySend, SalarySobPO salarySob) { + List list = salarySendInfoMapper.listSome(SalarySendInfoPO.builder().salarySendId(salarySend.getId()).build()); + List sendList = list.stream().filter(e -> e.getSendStatus().equals(SalarySendStatusEnum.ALREADYSEND.getValue())).collect(Collectors.toList()); + int sendNum = sendList.size(); + int sendTotal = list.size(); + SalarySendPO salarySendNew = new SalarySendPO(); + try { + BeanUtils.copyProperties(salarySendNew, salarySend); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } catch (InvocationTargetException e) { + e.printStackTrace(); + } + salarySendNew.setSendNum(sendNum); + salarySendNew.setSendTotal(sendTotal); + salarySendNew.setLastSendTime(new Date()); + + mapper.updateById(salarySendNew); + + // 记录日志 + LoggerContext loggerContext = new LoggerContext(); + loggerContext.setTargetId(String.valueOf(salarySend.getId())); + loggerContext.setTargetName(SalaryDateUtil.getFormatYearMonth(salarySend.getSalaryMonth()) + "-" + (salarySob == null ? "" : salarySob.getName())); + loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "工资单发放")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "工资单发放")); + loggerContext.setOldValues(salarySend); + loggerContext.setNewValues(salarySendNew); + loggerContext.setOperator(user.getUID() + StringUtils.EMPTY); + loggerContext.setOperatorName(Objects.isNull(user) ? StringUtils.EMPTY : user.getUsername()); + SalaryElogConfig.salarySendLoggerTemplate.write(loggerContext); + } + +// /** +// * 工资单撤回 start +// **********************************************************************/ +// @Override +// @Transactional(rollbackFor = Exception.class) +// public void withdraw(SalarySendWithdrawParam param, boolean isRange, List rangeIds) { +// // 1.检查和获取工资单发放 +// SalarySendPO salarySend = checkAngGetSalarySend(param.getSalarySendId()); +//// // 已经冻结不能操作 +//// if (salarySend.getSendStatus().equals(NumberUtils.INTEGER_ONE)) { +//// return; +//// } +// +// // 检查是否正在撤回中 +// SalaryBillProgressDTO salaryBillProgress = getProgressService(user) +// .getProgress(SalaryCacheKey.SALARY_WITHDRAW_PROGRESS, "" + salarySend.getId()); +// if (Objects.nonNull(salaryBillProgress) && salaryBillProgress.isStatus() +// && Optional.ofNullable(salaryBillProgress.getProgress()).orElse(BigDecimal.ZERO).compareTo(BigDecimal.ONE) < 0) { +// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(136105, "有其他人员正在撤回中,请等待其他人员撤回结束后再操作")); +// } +// +// // 初始化进度 +// SalaryBillProgressDTO initProgress = getProgressService(user) +// .buildInitProgress("撤回中", 136106, NumberUtils.INTEGER_ONE, NumberUtils.INTEGER_ZERO, BigDecimal.ZERO); +// getProgressService(user).initProgress(SalaryCacheKey.SALARY_WITHDRAW_PROGRESS, "" + salarySend.getId(), initProgress); +// +// List ids = isRange ? getSalarySendRangeService(user).getSendInfoIdsBySalarySendIdAndOperateType(salarySend.getId(), rangeIds, SalarySendOperateTypeEnum.WITHDRAW) : param.getIds(); +// // 异步执行撤回 +// LocalRunnable localRunnable = new LocalRunnable() { +// @Override +// public void execute() { +// handleWithdraw(salarySend, ids); +// } +// }; +// ThreadPoolUtil.fixedPoolExecute(ModulePoolEnum.OTHER, "salaryBillWithdraw", localRunnable); +// } +// +// /** +// * 处理撤回 +// * +// * @param salarySend +// * @param ids +// * @param currentEmployeeId +// * @param currentTenantKey +// */ +// private void handleWithdraw(SalarySendPO salarySend, List ids) { +// try { +// DSTenantKeyThreadVar.tenantKey.set(currentTenantKey); +// +// // 开启分权或且是非薪酬模块总管理员且发送全部,谁能进来就是能看全部 +// // ids = getIdsForDevolution(salarySend, ids); +// +// // 获取可撤回的工资单 +// List enableWithdrawList = Lists.newArrayList(); +// if (CollectionUtils.isEmpty(ids)) { +// List salaryAcctEmployees = this.getSalarySendService(user).getSalaryAcctEmployees(salarySend.getSalaryAccountingId(), null); +// List acctEmployeeIds = salaryAcctEmployees.stream().map(SalaryAcctEmployeePO::getEmployeeId).distinct().collect(Collectors.toList()); +// List> partition = Lists.partition(acctEmployeeIds, DbCrudConstant.DEF_PART_SIZE); +// for (List part : partition) { +// enableWithdrawList.addAll(new LambdaQueryChainWrapper<>(getSalarySendInfoMapper()) +// /** 注意:需要啥就加载啥,避免加载大字段salaryTemplate */ +// .select(SalarySendInfoPO::getId, SalarySendInfoPO::getSendMsgId) +// .eq(SalarySendInfoPO::getDeleteType, 0) +// .eq(SalarySendInfoPO::getTenantKey) +// .eq(SalarySendInfoPO::getSalarySendId, salarySend.getId()) +// .eq(SalarySendInfoPO::getSendStatus, SalarySendStatusEnum.ALREADYSEND.getValue()) +// .in(SalarySendInfoPO::getEmployeeId, part) +// .list()); +// } +// } else { +// List> partition = Lists.partition(ids, DbCrudConstant.DEF_PART_SIZE); +// for (List part : partition) { +// enableWithdrawList.addAll(new LambdaQueryChainWrapper<>(getSalarySendInfoMapper()) +// /** 注意:需要啥就加载啥,避免加载大字段salaryTemplate */ +// .select(SalarySendInfoPO::getId, SalarySendInfoPO::getSendMsgId) +// .eq(SalarySendInfoPO::getDeleteType, 0) +// .eq(SalarySendInfoPO::getTenantKey) +// .eq(SalarySendInfoPO::getSalarySendId, salarySend.getId()) +// .eq(SalarySendInfoPO::getSendStatus, SalarySendStatusEnum.ALREADYSEND.getValue()) +// .in(SalarySendInfoPO::getId, part) +// .list()); +// } +// } +// +// // 初始化进度 +// SalaryBillProgressDTO initProgress = getProgressService(user) +// .buildInitProgress("撤回中", 136106, enableWithdrawList.size() * 2 + 1, enableWithdrawList.size(), new BigDecimal("0.5")); +// getProgressService(user).initProgress(SalaryCacheKey.SALARY_WITHDRAW_PROGRESS, "" + salarySend.getId(), initProgress); +// +// // 1.撤回消息:先修改数据再发消息,避免出错后无法撤回 +// String text = SalaryI18nUtil.getI18nLabel(184533, "此工资单已被撤回,如有问题,请联系管理员"); +// String title = SalaryI18nUtil.getI18nLabel(94626, "工资单"); +// List sendInfoUpdateIds = Lists.newArrayList(); +// +// AtomicInteger index = new AtomicInteger(0); +// AtomicInteger part = new AtomicInteger(0); +// int total = enableWithdrawList.size(); +// enableWithdrawList.forEach(e -> { +// if (!e.getSendMsgId().equals(0L)) { +// CancleMessageEntity cme = SalaryBillBO.buildCancleMessageEntity(e.getSendMsgId(), text, title); +// /** 撤回工资单 **********************************************************/ +// WeaResult cancelResult = asyncSystemMessageRest.cancleMsg(cme); +// if (cancelResult.isStatus()) { +// sendInfoUpdateIds.add(e.getId()); +// } +// } else { +// sendInfoUpdateIds.add(e.getId()); +// } +// // 更新撤回进度 +// index.addAndGet(1); +// part.addAndGet(1); +// if (index.get() % 100 == 0 || index.get() >= total) { +// getProgressService(user).getAndAddCalculatedQty(SalaryCacheKey.SALARY_WITHDRAW_PROGRESS, "" + salarySend.getId(), part.get()); +// part.set(0); +// } +// }); +// if (CollectionUtils.isNotEmpty(sendInfoUpdateIds)) { +// List> partition = Lists.partition(sendInfoUpdateIds, DbCrudConstant.DEF_PART_SIZE); +// partition.forEach(idsPart -> new LambdaUpdateChainWrapper<>(getSalarySendInfoMapper()) +// .eq(SalarySendInfoPO::getDeleteType, 0) +// .eq(SalarySendInfoPO::getTenantKey) +// .in(SalarySendInfoPO::getId, idsPart) +// .set(SalarySendInfoPO::getSendMsgId, 0) +// .update()); +// } +// // 2.撤回 +// withdrawSendInfo(sendInfoUpdateIds, salarySend); +// // 3.更新数量 +// updateSendNum(salarySend, getSalarySobService(user).getById(salarySend.getSalarySobId()), null, +// SalaryI18nUtil.getI18nLabel(100521, "撤回工资单发放")); +// +// int successCount = sendInfoUpdateIds.size(); +// String messsage = SalaryI18nUtil.getI18nLabel(139211, "撤回完成") + ": " +// + SalaryI18nUtil.getI18nLabel(134807, "成功条数") + "[" + (successCount) + "], " +// + SalaryI18nUtil.getI18nLabel(134808, "失败条数") + "[" + (total - successCount) + "]"; +// // 撤回进度完成 +// getProgressService(user).finish(SalaryCacheKey.SALARY_WITHDRAW_PROGRESS, "" + salarySend.getId(), messsage, true); +// } catch (Exception e) { +// log.info("撤回出错:{}", e.getMessage(), e); +// // 发送进度失败 +// getProgressService(user) +// .fail(SalaryCacheKey.SALARY_WITHDRAW_PROGRESS, "" + salarySend.getId(), SalaryI18nUtil.getI18nLabel(136142, "工资单撤回出错") + ": " + e.getMessage()); +// } finally { +// DSTenantKeyThreadVar.tenantKey.remove(); +// } +// } +// /** 工资单撤回 end **********************************************************************/ +// +// /** +// * 我的工资单 start +// **********************************************************************/ +// @Override +// public Map mySalaryBill(Long salaryInfoId) { +// // 企业微信端示例数据 +// if (salaryInfoId.equals(1234567890L)) { +// return handle4WeChartDemo(salaryInfoId); +// } +// +// SalarySendInfoPO salarySendInfo = new LambdaQueryChainWrapper<>(getSalarySendInfoMapper()) +// .eq(SalarySendInfoPO::getDeleteType, 0) +// .eq(SalarySendInfoPO::getTenantKey) +// .eq(SalarySendInfoPO::getId, salaryInfoId).one(); +// if (salarySendInfo == null) { +// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100511, "工资单信息不存在")); +// } +// // 获取模板 +// String salaryTemplateContent = salarySendInfo.getSalaryTemplate(); +// if (StringUtils.isBlank(salaryTemplateContent)) { +// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100513, "没有默认模板,无法查看")); +// } +// SalaryTemplatePO salaryTemplate = SalaryBillBO.buildSalaryTemplateContent(salaryTemplateContent); +// +// // 判断是否是补发 +// boolean isReplenish = NumberUtils.INTEGER_ONE.equals(salarySendInfo.getSalaryAcctType()); +// SalaryTemplateBO.copyShowSet(isReplenish, salaryTemplate); +// +// // 获取人员信息项目分类 +// List listDTOS = JSONArray.parseArray(isReplenish ? salaryTemplate.getReplenishSalaryItemSetting() : salaryTemplate.getSalaryItemSetting(), SalaryTemplateSalaryItemSetListDTO.class); +// // 国际化处理 +// listDTOS = SalaryTemplateBO.handleI18n(listDTOS); +// // 获取人员信息项目分类 +// SalaryTemplateSalaryItemSetListDTO employeeInformation = SalaryTemplateBO.getEmployeeInformation(listDTOS); +// // 1.薪资项目赋值 +// List itemSetListDTOS = listDTOS.stream() +// .filter(e -> !SalaryTemplateSalaryItemSetGroupConstant.EMPLOYEE_INFO_GROUP_ID.equals(e.getGroupId())).collect(Collectors.toList()); +// // 获取薪资核算数据 +// List salaryAcctEmployees = getSalaryAcctEmployeeService(user) +// .listByRecordIdAndEmployeeIds(salarySendInfo.getSalaryAcctRecordId(), Collections.singletonList(salarySendInfo.getEmployeeId())); +// Set salaryAcctEmployeeIds = SalaryEntityUtil.properties(salaryAcctEmployees, SalaryAcctEmployeePO::getId); +// List salaryAcctResultValues = getSalaryAcctResultService(user).listBySalaryAcctEmployeeIds(salaryAcctEmployeeIds); +//// List salaryAcctResultList = getSalaryAcctResultService(user).listBySalaryAcctRecordIdsAndEmployeeIds(Collections.singletonList(salarySendInfo.getSalaryAcctRecordId()), Collections.singletonList(currentEmployeeId)); +// if (CollectionUtils.isNotEmpty(salaryAcctResultValues)) { +// SalaryAcctRecordPO salaryAcctRecord = getSalaryAcctRecordService(user).getById(salarySendInfo.getSalaryAcctRecordId()); +// // 当前查询核算记录是回算,但是发放不是回算的,那么就取源头核算结果 +// boolean isOrigin = salaryAcctRecord != null && !isReplenish && salaryAcctRecord.getBackCalcStatus().equals(NumberUtils.INTEGER_ONE); +// Map map = Maps.newHashMap(); +// if (salarySendInfo.getTaxAgentId().equals(0L)) { +// for (SalaryAcctResultValuePO salaryAcctResultValue : salaryAcctResultValues) { +// if (isOrigin) { +// if (salaryAcctResultValue.getOriginResultValue() != null && !salaryAcctResultValue.getOriginResultValue().isEmpty()) { +// map.putAll(salaryAcctResultValue.getOriginResultValue()); +// } +// } else { +// map.putAll(salaryAcctResultValue.getResultValue()); +// } +// } +// } else { +// Map salaryAcctEmployeeMap = SalaryEntityUtil +// .convert2Map(salaryAcctEmployees, salaryAcctEmployee -> salaryAcctEmployee.getEmployeeId() + "-" + salaryAcctEmployee.getTaxAgentId()); +// Map singleEmpAcctMap = SalaryEntityUtil.convert2Map(salaryAcctResultValues, SalaryAcctResultValuePO::getSalaryAcctEmployeeId); +// SalaryAcctEmployeePO salaryAcctEmployee = salaryAcctEmployeeMap.get(salarySendInfo.getEmployeeId() + "-" + salarySendInfo.getTaxAgentId()); +// if (salaryAcctEmployee != null && singleEmpAcctMap.containsKey(salaryAcctEmployee.getId())) { +// SalaryAcctResultValuePO salaryAcctResultValue = singleEmpAcctMap.get(salaryAcctEmployee.getId()); +// if (Objects.nonNull(salaryAcctResultValue)) { +// if (isOrigin) { +// if (salaryAcctResultValue.getOriginResultValue() != null && !salaryAcctResultValue.getOriginResultValue().isEmpty()) { +// map.putAll(salaryAcctResultValue.getOriginResultValue()); +// } +// } else { +// map.putAll(salaryAcctResultValue.getResultValue()); +// } +// } +// } +// } +// org.apache.commons.collections4.CollectionUtils.emptyIfNull(itemSetListDTOS) +// .forEach(item -> item.getItems().forEach(e -> e.setSalaryItemValue(Optional.ofNullable(map.get("" + e.getId())).orElse("")))); +// } else { +// org.apache.commons.collections4.CollectionUtils.emptyIfNull(itemSetListDTOS) +// .forEach(item -> item.getItems().forEach(e -> e.setSalaryItemValue(""))); +// } +// // 2.人员信息赋值 +// if (employeeInformation != null && CollectionUtils.isNotEmpty(employeeInformation.getItems())) { +// // 如果是外部人员 +// if (salarySendInfo.getEmployeeType().equals(SalarySendEmployeeTypeEnum.EXT_EMPLOYEE.getValue())) { +// ExtEmployeePO extEmployeePO = extEmployeeService.getByIdWithDeleted(salarySendInfo.getEmployeeId()); +// if (extEmployeePO != null) { +// SimpleEmployee simpleEmployee = new SimpleEmployee(); +// simpleEmployee.setId(extEmployeePO.getId()); +// simpleEmployee.setUsername(extEmployeePO.getUsername()); +// simpleEmployee.setMobile(extEmployeePO.getUsername()); +// SalaryBillBO.buildEmployeeInfo(employeeInformation, simpleEmployee, SalaryBillBO.buildEmployeeFieldName()); +// } +// } else { +// SimpleEmployee simpleEmployee = hrmCommonEmployeeService.getEmployeeById(salarySendInfo.getEmployeeId()); +// if (simpleEmployee != null) { +// // 查询人员状态 +// HrmStatus hrmStatusDb = hrmCommonHrmStatusService.getHrmStatusByCodeId(simpleEmployee.getPersonnelStatus()); +// simpleEmployee.setPersonnelStatus(hrmStatusDb == null ? "" : hrmStatusDb.getName()); +// } +// SalaryBillBO.buildEmployeeInfo(employeeInformation, simpleEmployee, SalaryBillBO.buildEmployeeFieldName()); +// } +// } +// // 主题设置 +// salaryTemplate.setTheme(SalaryBillBO +// .getBillTitle(salaryTemplate.getTheme(), salarySendInfo.getSalaryMonth(), TenantContext.getCurrentTenant().getTenantName())); +// // 背景图 +// if (StringUtils.isNotBlank(salaryTemplate.getBackground())) { +// salaryTemplate.setBackground(String.format("/papi/file/preview?type=imgs&fileId=%s&random=123456", salaryTemplate.getBackground())); +// } +// +// Map resultMap = new LinkedHashMap<>(); +// resultMap.put("tenantName", TenantContext.getCurrentTenant().getTenantName()); +// resultMap.put("sendTime", SalaryDateUtil.getFormatLocalDateTime(salarySendInfo.getSendTime())); +// resultMap.put("employeeInformation", employeeInformation); +// resultMap.put("salaryGroups", itemSetListDTOS); +// resultMap.put("salaryTemplate", salaryTemplate); +// return resultMap; +// } +// +// /** +// * 企业微信端示例数据 +// * +// * @param salaryInfoId +// * @return +// */ +// private Map handle4WeChartDemo(Long salaryInfoId) { +// Map resultMap = new LinkedHashMap<>(); +// if (salaryInfoId.equals(1234567890L)) { +// List itemSetListDTOS = Lists.newArrayList(); +// List items = Lists.newArrayList(); +// items.add(SalaryTemplateSalaryItemListDTO.builder().id("735706397435338782").salaryItemValue("5000.00").name(SalaryI18nUtil.getI18nLabel(184508, "基本工资")).sortedIndex(0).build()); +// items.add(SalaryTemplateSalaryItemListDTO.builder().id("735706397435338783").salaryItemValue("2000.00").name(SalaryI18nUtil.getI18nLabel(184537, "岗位工资")).sortedIndex(1).build()); +// items.add(SalaryTemplateSalaryItemListDTO.builder().id("739465941241856001").salaryItemValue("100.00").name(SalaryI18nUtil.getI18nLabel(184538, "其他补贴")).sortedIndex(2).build()); +// items.add(SalaryTemplateSalaryItemListDTO.builder().id("739466138709688320").salaryItemValue("3.00").name(SalaryI18nUtil.getI18nLabel(184539, "绩效分值")).sortedIndex(3).build()); +// items.add(SalaryTemplateSalaryItemListDTO.builder().id("739505579468095489").salaryItemValue("600.00").name(SalaryI18nUtil.getI18nLabel(184540, "工时奖金")).sortedIndex(4).build()); +// items.add(SalaryTemplateSalaryItemListDTO.builder().id("739505652314767360").salaryItemValue("500.00").name(SalaryI18nUtil.getI18nLabel(184544, "成果奖金")).sortedIndex(5).build()); +// items.add(SalaryTemplateSalaryItemListDTO.builder().id("739506094797062145").salaryItemValue("200.00").name(SalaryI18nUtil.getI18nLabel(184545, "考勤扣款")).sortedIndex(6).build()); +// items.add(SalaryTemplateSalaryItemListDTO.builder().id("739506691648290816").salaryItemValue("800.00").name(SalaryI18nUtil.getI18nLabel(184546, "餐补")).sortedIndex(7).build()); +// items.add(SalaryTemplateSalaryItemListDTO.builder().id("739516333975699456").salaryItemValue("1").name(SalaryI18nUtil.getI18nLabel(184547, "当月缺勤")).sortedIndex(8).build()); +// items.add(SalaryTemplateSalaryItemListDTO.builder().id("739516913670455296").salaryItemValue("200.00").name(SalaryI18nUtil.getI18nLabel(184549, "缺勤扣款")).sortedIndex(9).build()); +// items.add(SalaryTemplateSalaryItemListDTO.builder().id("735706397435338798").salaryItemValue("200.00").name(SalaryI18nUtil.getI18nLabel(184550, "社保代扣")).sortedIndex(10).build()); +// items.add(SalaryTemplateSalaryItemListDTO.builder().id("735706397435338799").salaryItemValue("200.00").name(SalaryI18nUtil.getI18nLabel(184551, "公积金代扣")).sortedIndex(11).build()); +// items.add(SalaryTemplateSalaryItemListDTO.builder().id("741652500368097281").salaryItemValue("8800.00").name(SalaryI18nUtil.getI18nLabel(184553, "当月计税收入")).sortedIndex(12).build()); +// items.add(SalaryTemplateSalaryItemListDTO.builder().id("735706397435338770").salaryItemValue("0").name(SalaryI18nUtil.getI18nLabel(184555, "当前累计专项附加扣除合计")).sortedIndex(13).build()); +// items.add(SalaryTemplateSalaryItemListDTO.builder().id("735706397435338780").salaryItemValue("1000.00").name(SalaryI18nUtil.getI18nLabel(184556, "当月预扣个税")).sortedIndex(14).build()); +// items.add(SalaryTemplateSalaryItemListDTO.builder().id("735706397435338800").salaryItemValue("8700.00").name(SalaryI18nUtil.getI18nLabel(184557, "当月实发现金")).sortedIndex(15).build()); +// items.add(SalaryTemplateSalaryItemListDTO.builder().id("735706397435338802").salaryItemValue("").name(SalaryI18nUtil.getI18nLabel(84961, "备注")).sortedIndex(16).build()); +// itemSetListDTOS.add(SalaryTemplateSalaryItemSetListDTO.builder() +// .groupId("custom_144") +// .groupName(SalaryI18nUtil.getI18nLabel(184561, "工资薪金项目")) +// .sortedIndex(0) +// .items(items) +// .build()); +// SalaryTemplatePO salaryTemplate = SalaryTemplatePO.builder() +// .id(759519856313417728L) +// .name(SalaryI18nUtil.getI18nLabel(184563, "测试模板")) +// .description("") +// .theme(SalaryI18nUtil.getI18nLabel(184565, "(示例)工资单明细")) +// .background("") +// .textContent(SalaryI18nUtil.getI18nLabel(184590, "(示例)本数据仅为您收入预发金额,考勤、绩效及各类专项奖励的差异值将根据实际数据后续在下次发薪时统一予以调整,如有异议,请联系****。")) +// .textContentPosition(2) +// .salaryItemNullStatus(0) +// .salaryItemZeroStatus(0) +// .salaryItemSetting(JSON.toJSONString(itemSetListDTOS)) +// .build(); +// resultMap.put("tenantName", TenantContext.getCurrentTenant().getTenantName()); +// resultMap.put("sendTime", SalaryDateUtil.getFormatLocalDateTime(LocalDateTime.now())); +// resultMap.put("employeeInformation", null); +// resultMap.put("salaryGroups", itemSetListDTOS); +// resultMap.put("salaryTemplate", salaryTemplate); +// } +// return resultMap; +// } +// +// @Override +// public Page mySalaryBillListPage(Page page, SalaryBillQueryParam queryParam, String tenantKey) { +// getSalarySendInfoMapper().mySalaryBillList(page, queryParam, tenantKey); +// return page; +// } + /** 我的工资单 end **********************************************************************/ +} diff --git a/src/com/engine/salary/service/impl/SalaryBillWatermarkServiceImpl.java b/src/com/engine/salary/service/impl/SalaryBillWatermarkServiceImpl.java new file mode 100644 index 000000000..dfb5d0350 --- /dev/null +++ b/src/com/engine/salary/service/impl/SalaryBillWatermarkServiceImpl.java @@ -0,0 +1,57 @@ +package com.engine.salary.service.impl; + +import com.api.formmode.mybatis.util.SqlProxyHandle; +import com.engine.core.impl.Service; +import com.engine.salary.entity.salaryBill.po.SalaryBillWatermarkPO; +import com.engine.salary.mapper.salarybill.SalaryBillWatermarkMapper; +import com.engine.salary.service.SalaryBillWatermarkService; + +import java.util.List; + +/** + * @author Harryxzy + * @ClassName SalaryBillWatermarkServiceImpl + * @date 2023/06/09 11:12 + * @description + */ +public class SalaryBillWatermarkServiceImpl extends Service implements SalaryBillWatermarkService { + + private SalaryBillWatermarkMapper getSalaryBillWatermarkMapper() { + return SqlProxyHandle.getProxy(SalaryBillWatermarkMapper.class); + } + + @Override + public List listAll() { + return getSalaryBillWatermarkMapper().listAll(); + } + + @Override + public List listSome(SalaryBillWatermarkPO po) { + return getSalaryBillWatermarkMapper().listSome(po); + } + + @Override + public SalaryBillWatermarkPO getById(Long id) { + return getSalaryBillWatermarkMapper().getById(id); + } + + @Override + public int insertIgnoreNull(SalaryBillWatermarkPO SalaryBillWatermarkPO) { + return getSalaryBillWatermarkMapper().insertIgnoreNull(SalaryBillWatermarkPO); + } + + @Override + public int updateIgnoreNull(SalaryBillWatermarkPO SalaryBillWatermarkPO) { + return getSalaryBillWatermarkMapper().updateIgnoreNull(SalaryBillWatermarkPO); + } + + @Override + public int delete(SalaryBillWatermarkPO SalaryBillWatermarkPO) { + return getSalaryBillWatermarkMapper().delete(SalaryBillWatermarkPO); + } + + @Override + public void deleteAll() { + getSalaryBillWatermarkMapper().deleteAll(); + } +} diff --git a/src/com/engine/salary/service/impl/SalaryCacheServiceImpl.java b/src/com/engine/salary/service/impl/SalaryCacheServiceImpl.java new file mode 100644 index 000000000..1242a0b95 --- /dev/null +++ b/src/com/engine/salary/service/impl/SalaryCacheServiceImpl.java @@ -0,0 +1,51 @@ +package com.engine.salary.service.impl; + +import com.cloudstore.dev.api.util.Util_DataCache; +import com.engine.core.impl.Service; +import com.engine.salary.service.SalaryCacheService; +import com.engine.salary.util.JsonUtil; +import org.apache.commons.lang3.StringUtils; +import weaver.general.Util; + +public class SalaryCacheServiceImpl extends Service implements SalaryCacheService { + + + @Override + public void set(String key, T value) { + Util_DataCache.setObjVal(key, value); + } + + @Override + public void set(String key, T value, int time) { + Util_DataCache.setObjVal(key, value, time); + } + + @Override + public void setJson(String key, T value) { + Util_DataCache.setObjVal(key, JsonUtil.toJsonString(value)); + } + + @Override + public void setJson(String key, T value, int time) { + Util_DataCache.setObjVal(key, JsonUtil.toJsonString(value), time); + } + + @Override + public T get(String key) { + return (T) Util_DataCache.getObjVal(key); + } + + @Override + public T getJson(String key, Class clazz) { + String value = Util.null2String(Util_DataCache.getObjVal(key)); + if (StringUtils.isEmpty(value)) { + return null; + } + return JsonUtil.parseObject(value, clazz); + } + + @Override + public void remove(String key) { + Util_DataCache.clearVal(key); + } +} diff --git a/src/com/engine/salary/service/impl/SalaryComparisonResultServiceImpl.java b/src/com/engine/salary/service/impl/SalaryComparisonResultServiceImpl.java new file mode 100644 index 000000000..2fd26a4b3 --- /dev/null +++ b/src/com/engine/salary/service/impl/SalaryComparisonResultServiceImpl.java @@ -0,0 +1,284 @@ +package com.engine.salary.service.impl; + +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.component.WeaTableColumnGroup; +import com.engine.salary.encrypt.EncryptUtil; +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.salaryacct.bo.SalaryAcctConfig; +import com.engine.salary.entity.salaryacct.bo.SalaryAcctResultBO; +import com.engine.salary.entity.salaryacct.dto.SalaryComparisonResultListDTO; +import com.engine.salary.entity.salaryacct.param.SalaryAcctEmployeeQueryParam; +import com.engine.salary.entity.salaryacct.param.SalaryComparisonResultQueryParam; +import com.engine.salary.entity.salaryacct.po.ExcelAcctResultPO; +import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO; +import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO; +import com.engine.salary.entity.salaryacct.po.SalaryAcctResultPO; +import com.engine.salary.entity.salaryformula.ExpressFormula; +import com.engine.salary.entity.salaryitem.po.SalaryItemPO; +import com.engine.salary.entity.salarysob.bo.SalarySobItemAggregateBO; +import com.engine.salary.entity.salarysob.dto.SalarySobItemAggregateDTO; +import com.engine.salary.entity.salarysob.po.*; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.mapper.salaryacct.ExcelAcctResultMapper; +import com.engine.salary.service.*; +import com.engine.salary.util.SalaryEntityUtil; +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.page.SalaryPageUtil; +import com.google.common.collect.Lists; +import com.google.common.collect.Sets; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.BooleanUtils; +import org.apache.commons.lang3.StringUtils; +import weaver.hrm.User; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * 薪资核算的线下对比结果 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SalaryComparisonResultServiceImpl extends Service implements SalaryComparisonResultService { + private EncryptUtil encryptUtil = new EncryptUtil(); + + private ExcelAcctResultMapper getExcelAcctResultMapper() { + return MapperProxyFactory.getProxy(ExcelAcctResultMapper.class); + } + + private SalaryAcctResultService getSalaryAcctResultService(User user) { + return ServiceUtil.getService(SalaryAcctResultServiceImpl.class, user); + } + + private SalaryAcctEmployeeService getSalaryAcctEmployeeService(User user) { + return ServiceUtil.getService(SalaryAcctEmployeeServiceImpl.class, user); + } + + private SalarySobItemService getSalarySobItemService(User user) { + return ServiceUtil.getService(SalarySobItemServiceImpl.class, user); + } + + private SalaryAcctRecordService getSalaryAcctRecordService(User user) { + return ServiceUtil.getService(SalaryAcctRecordServiceImpl.class, user); + } + + private SalarySobEmpFieldService getSalarySobEmpFieldService(User user) { + return ServiceUtil.getService(SalarySobEmpFieldServiceImpl.class, user); + } + + private SalaryEmployeeService getSalaryEmployeeService(User user) { + return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user); + } + + + private TaxAgentService getTaxAgentService(User user) { + return ServiceUtil.getService(TaxAgentServiceImpl.class, user); + } + + private SalaryFormulaService getSalaryFormulaService(User user) { + return ServiceUtil.getService(SalaryFormulaServiceImpl.class, user); + } + + private SalaryItemService getSalaryItemService(User user) { + return ServiceUtil.getService(SalaryItemServiceImpl.class, user); + } + + private SalarySobService getSalarySobService(User user) { + return ServiceUtil.getService(SalarySobServiceImpl.class, user); + } + + private SalarySobItemGroupService getSalarySobItemGroupService(User user) { + return ServiceUtil.getService(SalarySobItemGroupServiceImpl.class, user); + } + + private SalarySobItemHideService getSalarySobItemHideService(User user) { + return ServiceUtil.getService(SalarySobItemHideServiceImpl.class, user); + } + + private SalaryAcctSobConfigService getSalaryAcctSobConfigService(User user) { + return ServiceUtil.getService(SalaryAcctSobConfigServiceImpl.class, user); + } + + @Override + public List listBySalaryAcctRecordId(Long salaryAcctRecordId) { + List excelAcctResultPOS = getExcelAcctResultMapper().listSome(ExcelAcctResultPO.builder().salaryAcctRecordId(salaryAcctRecordId).build()); + return encryptUtil.decryptList(excelAcctResultPOS, ExcelAcctResultPO.class); + } + + @Override + public List listBySalaryAcctEmployeeIds(Collection salaryAcctEmployeeIds) { + if (CollectionUtils.isEmpty(salaryAcctEmployeeIds)) { + return Collections.emptyList(); + } + + List excelAcctResultPOS = new ArrayList<>(); + List> partition = Lists.partition((List) salaryAcctEmployeeIds, 2000); + partition.forEach(empIds -> { + excelAcctResultPOS.addAll(getExcelAcctResultMapper().listSome(ExcelAcctResultPO.builder().salaryAcctEmpIds(empIds).build())); + }); + return encryptUtil.decryptList(excelAcctResultPOS, ExcelAcctResultPO.class); + } + + @Override + public SalaryComparisonResultListDTO listPageByParam(SalaryComparisonResultQueryParam queryParam) { + return listByParam(true, queryParam); + } + + @Override + public SalaryComparisonResultListDTO listByParam(SalaryComparisonResultQueryParam queryParam) { + return listByParam(false, queryParam); + } + + /** + * 根据薪资核算人员查询薪资核算线下对比结果 + * + * @param queryParam 列表查询条件 + * @return + */ + private SalaryComparisonResultListDTO listByParam(boolean needPage, SalaryComparisonResultQueryParam queryParam) { + // 查询薪资核算记录 + SalaryAcctRecordPO salaryAcctRecordPO = getSalaryAcctRecordService(user).getById(queryParam.getSalaryAcctRecordId()); + if (Objects.isNull(salaryAcctRecordPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98747, "薪资核算记录不存在或已被删除")); + } + + SalaryAcctConfig salaryAcctConfig = getSalaryAcctSobConfigService(user).getSalaryAcctConfig(queryParam.getSalaryAcctRecordId()); + + // 查询薪资核算所用薪资账套 + SalarySobPO salarySobPO = getSalarySobService(user).getById(salaryAcctRecordPO.getSalarySobId()); + // 查询薪资核算所用的薪资账套的员工信息字段 + List salarySobEmpFieldPOS = salaryAcctConfig.getSalarySobEmpFields(); + // 查询薪资账套的薪资项目分类 + List salarySobItemGroupPOS = salaryAcctConfig.getSalarySobItemGroups(); + // 查询薪资核算所用薪资账套的薪资项目副本 + List salarySobItemPOS = salaryAcctConfig.getSalarySobItems(); + // 过滤在账套中隐藏的薪资项目 + salarySobItemPOS = salarySobItemPOS.stream().filter(po -> po.getItemHide() == null || po.getItemHide() == 0).collect(Collectors.toList()); + // 查询公式详情 + Set formulaIds = SalaryEntityUtil.properties(salarySobItemPOS, SalarySobItemPO::getFormulaId); + List expressFormulas = getSalaryFormulaService(user).listExpressFormula(formulaIds); + // 转换成 + Map expressFormulaMap = SalaryEntityUtil.convert2Map(expressFormulas, ExpressFormula::getId, ExpressFormula::getFormula); + Map customParameters = SalaryEntityUtil.convert2Map(salarySobItemPOS, SalarySobItemPO::getSalaryItemId, salarySobItemPO -> { + if (salarySobItemPO.getFormulaId() <= 0) { + return SalaryI18nUtil.getI18nLabel(92004, "输入/导入"); + } + return expressFormulaMap.getOrDefault(salarySobItemPO.getFormulaId(), StringUtils.EMPTY); + }); + // 查询薪资项目 + Set salaryItemIds = SalaryEntityUtil.properties(salarySobItemPOS, SalarySobItemPO::getSalaryItemId); + List salaryItemPOS = getSalaryItemService(user).listByIds(salaryItemIds); + // 转换成聚合dto + SalarySobItemAggregateBO salarySobItemAggregateBO = new SalarySobItemAggregateBO(salarySobPO, salarySobEmpFieldPOS, + salarySobItemGroupPOS, salarySobItemPOS, expressFormulas, salaryItemPOS, Collections.emptyList(), Collections.emptyList()); + SalarySobItemAggregateDTO salarySobItemAggregateDTO = salarySobItemAggregateBO.convert2AggregateDTO(); + + // 薪资核算人员 + List salaryAcctEmployeePOS = getSalaryAcctEmployeeService(user).listByResultQueryParam(queryParam); + if (CollectionUtils.isEmpty(salaryAcctEmployeePOS)) { + // 构建薪资核算结果列表表头 + List weaTableColumns = SalaryAcctResultBO.buildTableColumns4ComparisonResultByGroup(salarySobItemAggregateDTO, Collections.emptySet()); + // 构建列表数据 + // 返回结果 + return new SalaryComparisonResultListDTO().setWeaTableColumns(weaTableColumns).setData(new PageInfo<>()); + } + // 薪资核算结果 + List salaryAcctResultPOS; + // 线下导入结果 + List excelAcctResultPOS; + // 如果薪资核算人员太多,利用薪资核算人员id查询薪资核算结果的效率就不太好,改为直接用薪资核算记录id查询 + if (salaryAcctEmployeePOS.size() > 1000) { + // 查询薪资核算结果 + salaryAcctResultPOS = getSalaryAcctResultService(user).listBySalaryAcctRecordIds(Collections.singleton(queryParam.getSalaryAcctRecordId())); + // 查询线下导入结果 + excelAcctResultPOS = listBySalaryAcctRecordId(queryParam.getSalaryAcctRecordId()); + } else { + // 薪资核算人员id + List salaryAcctEmployeeIds = SalaryEntityUtil.properties(salaryAcctEmployeePOS, SalaryAcctEmployeePO::getId, Collectors.toList()); + // 查询薪资核算结果 + salaryAcctResultPOS = getSalaryAcctResultService(user).listBySalaryAcctEmployeeIds(salaryAcctEmployeeIds); + // 查询线下导入结果 + excelAcctResultPOS = listBySalaryAcctEmployeeIds(salaryAcctEmployeeIds); + } + + // 查询个税扣缴义务人 + Set taxAgentIds = SalaryEntityUtil.properties(salaryAcctEmployeePOS, SalaryAcctEmployeePO::getTaxAgentId); + List taxAgentPOS = getTaxAgentService(user).listByIds(taxAgentIds); + // 查询人员信息 + List employeeIds = SalaryEntityUtil.properties(salaryAcctEmployeePOS, SalaryAcctEmployeePO::getEmployeeId, Collectors.toList()); + List simpleEmployees = getSalaryEmployeeService(user).getEmployeeByIdsAll(employeeIds); + // 判断是否存在合并计税 + Set salaryAcctEmployeeIds4ConsolidatedTax; + if (StringUtils.isEmpty(queryParam.getConsolidatedTaxation())) { + salaryAcctEmployeeIds4ConsolidatedTax = SalaryEntityUtil.properties(salaryAcctEmployeePOS, SalaryAcctEmployeePO::getId); + } else { + SalaryAcctEmployeeQueryParam accEmployeeQueryParam = SalaryAcctEmployeeQueryParam.builder() + .salaryAcctRecordId(queryParam.getSalaryAcctRecordId()) + .ids(SalaryEntityUtil.properties(salaryAcctEmployeePOS, SalaryAcctEmployeePO::getId, Collectors.toList())) + .build(); + List salaryAcctEmployeePOS4ConsolidatedTax = getSalaryAcctEmployeeService(user).listByParam4ConsolidatedTax(accEmployeeQueryParam); + salaryAcctEmployeeIds4ConsolidatedTax = SalaryEntityUtil.properties(salaryAcctEmployeePOS4ConsolidatedTax, SalaryAcctEmployeePO::getId); + } + // 系统值和线下值不一致的薪资项目id + Set includeSalaryItemIds = Sets.newHashSetWithExpectedSize(salaryItemPOS.size()); + // 转换成薪资核算线下对比结果 + List> resultMapList = SalaryAcctResultBO.buildComparisonTableData(salaryItemPOS, salarySobEmpFieldPOS, simpleEmployees, + salaryAcctEmployeePOS, salaryAcctResultPOS, excelAcctResultPOS, taxAgentPOS, customParameters, salaryAcctEmployeeIds4ConsolidatedTax, includeSalaryItemIds, queryParam.isDynamicEmpInfo()); + // 系统值和线下值一致的人员 + if (queryParam.isOnlyDiffEmployee()) { + // 过滤系统值和线下值一致的薪资核算人员 + resultMapList = resultMapList.stream() + .filter(map -> BooleanUtils.toBoolean(String.valueOf(map.get("different")))) + .collect(Collectors.toList()); + } + // 分页 + PageInfo> dtoPage = new PageInfo<>(); + dtoPage.setTotal(resultMapList.size()); + if (needPage) { + dtoPage.setList(SalaryPageUtil.subList(queryParam.getCurrent(), queryParam.getPageSize(), resultMapList)); + dtoPage.setPageSize(queryParam.getPageSize()); + dtoPage.setPageNum(queryParam.getCurrent()); + } else { + dtoPage.setList(resultMapList); + } + Set excludeSalaryItemIds = Sets.newHashSet(); + if (queryParam.isOnlyDiffSalaryItem()) { + // 过滤系统值和线下值一致的薪资项目 + excludeSalaryItemIds = salaryItemPOS.stream() + .filter(salaryItemPO -> !includeSalaryItemIds.contains(salaryItemPO.getId())) + .map(SalaryItemPO::getId) + .collect(Collectors.toSet()); + } + // 构建薪资核算结果列表表头 + List weaTableColumns = SalaryAcctResultBO.buildTableColumns4ComparisonResultByGroup(salarySobItemAggregateDTO, excludeSalaryItemIds); + // 返回结果 + return new SalaryComparisonResultListDTO().setWeaTableColumns(weaTableColumns).setData(dtoPage); + } + + @Override + public void batchSave(Collection excelAcctResultPOS) { + if (CollectionUtils.isEmpty(excelAcctResultPOS)) { + return; + } + excelAcctResultPOS = encryptUtil.encryptList(new ArrayList<>(excelAcctResultPOS), ExcelAcctResultPO.class); + List> partition = Lists.partition((List) excelAcctResultPOS, 100); + partition.forEach(getExcelAcctResultMapper()::batchInsert); + } + + @Override + public void deleteBySalaryAcctEmployeeIds(Collection salaryAcctEmployeeIds) { + getExcelAcctResultMapper().deleteBySalaryAcctEmployeeIds(salaryAcctEmployeeIds); + } + + @Override + public void deleteBySalaryAcctRecordIds(Collection salaryAcctRecordIds) { + getExcelAcctResultMapper().deleteBySalaryAcctRecordIds(salaryAcctRecordIds); + } +} diff --git a/src/com/engine/salary/service/impl/SalaryEmployeeServiceImpl.java b/src/com/engine/salary/service/impl/SalaryEmployeeServiceImpl.java new file mode 100644 index 000000000..349a28d42 --- /dev/null +++ b/src/com/engine/salary/service/impl/SalaryEmployeeServiceImpl.java @@ -0,0 +1,684 @@ +package com.engine.salary.service.impl; + +import cn.hutool.core.util.NumberUtil; +import com.alibaba.fastjson.JSON; +import com.api.formmode.mybatis.util.SqlProxyHandle; +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.biz.EmployBiz; +import com.engine.salary.constant.SalaryDefaultTenantConstant; +import com.engine.salary.entity.SalarySobExtRangePO; +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.hrm.DeptInfo; +import com.engine.salary.entity.hrm.JobCallInfo; +import com.engine.salary.entity.hrm.PositionInfo; +import com.engine.salary.entity.hrm.SubCompanyInfo; +import com.engine.salary.entity.hrm.dto.EmployeeInfoExpandDTO; +import com.engine.salary.entity.hrm.dto.FieldSetting; +import com.engine.salary.entity.hrm.po.ExpandFieldSettingsPO; +import com.engine.salary.entity.hrm.po.HrmSnapshotPO; +import com.engine.salary.entity.salarysob.bo.SalarySobRangeBO; +import com.engine.salary.entity.salarysob.param.SalarySobRangeEmpQueryParam; +import com.engine.salary.entity.salarysob.po.SalarySobRangePO; +import com.engine.salary.enums.AccountTypeEnum; +import com.engine.salary.enums.UserStatusEnum; +import com.engine.salary.enums.datacollection.UseEmployeeTypeEnum; +import com.engine.salary.enums.salarysob.TargetTypeEnum; +import com.engine.salary.mapper.datacollection.EmployMapper; +import com.engine.salary.mapper.hrm.ExpandFieldSettingsMapper; +import com.engine.salary.mapper.hrm.HrmSnapshotMapper; +import com.engine.salary.service.ExtEmpService; +import com.engine.salary.service.SalaryEmployeeService; +import com.engine.salary.service.SalarySobExtRangeService; +import com.engine.salary.service.SalarySobRangeService; +import com.engine.salary.sys.entity.po.SalarySysConfPO; +import com.engine.salary.sys.service.SalarySysConfService; +import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.db.IdGenerator; +import com.engine.salary.util.db.MapperProxyFactory; +import com.google.common.collect.Lists; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.math.NumberUtils; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; + +import java.util.*; +import java.util.stream.Collectors; + +import static com.engine.salary.sys.constant.SalarySysConstant.OPEN_SECONDARY_ACCOUNT; + +/** + * 人员信息 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Slf4j +public class SalaryEmployeeServiceImpl extends Service implements SalaryEmployeeService { + + private EmployBiz employBiz = new EmployBiz(); + + private HrmSnapshotMapper getHrmSnapshotMapper() { + return MapperProxyFactory.getProxy(HrmSnapshotMapper.class); + } + + private EmployMapper getEmployMapper() { + return SqlProxyHandle.getProxy(EmployMapper.class); + } + + private SalarySobRangeService getSalarySobRangeService(User user) { + return ServiceUtil.getService(SalarySobRangeServiceImpl.class, user); + } + + private SalaryEmployeeService getSalaryEmployeeService(User user) { + return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user); + } + + private SalarySysConfService getSalarySysConfService(User user) { + return ServiceUtil.getService(SalarySysConfServiceImpl.class, user); + } + + + private ExpandFieldSettingsMapper getExpandFieldSettingsMapper() { + return SqlProxyHandle.getProxy(ExpandFieldSettingsMapper.class); + } + + + private ExtEmpService getExtEmpService(User user) { + return ServiceUtil.getService(ExtEmpServiceImpl.class, user); + } + + + private SalarySobExtRangeService getSalarySobExtRangeService(User user) { + return ServiceUtil.getService(SalarySobExtRangeServiceImpl.class, user); + } + + boolean openExtEmp = true; + + //主次账号是否开启 + boolean openSecondaryAccount = "1".equals(getSalarySysConfService(user).getValueByCode(OPEN_SECONDARY_ACCOUNT)); + + @Override + public List listAll(UseEmployeeTypeEnum empType) { + List result = new ArrayList<>(); + if (empType == UseEmployeeTypeEnum.ORG) { + result = employBiz.listAll(); + } + if (empType == UseEmployeeTypeEnum.EXT) { + result = getExtEmpService(user).listEmployee(); + } + if (empType == UseEmployeeTypeEnum.ALL) { + result.addAll(employBiz.listAll()); + result.addAll(getExtEmpService(user).listEmployee()); + } + + if (!openSecondaryAccount) { + result = result.stream().filter(e -> e.getAccountType() == null || e.getAccountType() == 0).collect(Collectors.toList()); + } + + SalaryI18nUtil.i18nList(result); + return result; + } + + @Override + public List listAllForReport() { + List result = employBiz.listAllForReport(); + if (openExtEmp) { + result.addAll(getExtEmpService(user).listAllForReport()); + } + if (!openSecondaryAccount) { + result = result.stream().filter(e -> e.getAccountType() == null || e.getAccountType() == 0).collect(Collectors.toList()); + } + SalaryI18nUtil.i18nList(result); + return result; + } + + @Override + public List listBySalarySobId(Long salarySobId, boolean hasExtEmp) { + + List includeSalaryEmployees = new ArrayList<>(); + + // 查询薪资账套的人员范围 + List includeSalarySobRangePOS = getSalarySobRangeService(user).listBySalarySobIdAndIncludeType(salarySobId, NumberUtils.INTEGER_ONE); + if (CollectionUtils.isNotEmpty(includeSalarySobRangePOS)) { + // 将薪资账套的人员范围转换成人员查询参数 + List includeQueryParams = SalarySobRangeBO.convert2EmployeeQueryParam(includeSalarySobRangePOS); + // 根据上一步的查询参数查询人员 + includeSalaryEmployees = listByParams(includeQueryParams); + if (CollectionUtils.isEmpty(includeSalaryEmployees)) { + return Collections.emptyList(); + } + //去重 + includeSalaryEmployees = includeSalaryEmployees.stream().distinct().collect(Collectors.toList()); + // 查询薪资账套的人员范围(从范围中排除) + List excludeSalarySobRangePOS = getSalarySobRangeService(user).listBySalarySobIdAndIncludeType(salarySobId, NumberUtils.INTEGER_ZERO); + if (CollectionUtils.isNotEmpty(excludeSalarySobRangePOS)) { + // 将薪资账套的人员范围转换成人员查询参数 + List excludeQueryParams = SalarySobRangeBO.convert2EmployeeQueryParam(excludeSalarySobRangePOS); + // 根据上一步的查询参数查询人员 + List excludeSalaryEmployees = listByParams(excludeQueryParams); + // 需要排除的人员范围 + Set excludeEmployeeIds = SalaryEntityUtil.properties(excludeSalaryEmployees, DataCollectionEmployee::getEmployeeId); + // 过滤人员 + includeSalaryEmployees = includeSalaryEmployees.stream() + .filter(salaryEmployee -> !excludeEmployeeIds.contains(salaryEmployee.getEmployeeId())) + .collect(Collectors.toList()); + } + } + + //外部人员 + if(hasExtEmp){ + List salarySobExtRangePOS = getSalarySobExtRangeService(user).listBySalarySobId(salarySobId); + if (CollectionUtils.isNotEmpty(salarySobExtRangePOS)) { + List ids = SalaryEntityUtil.properties(salarySobExtRangePOS, SalarySobExtRangePO::getTargetId, Collectors.toList()); + List extEmps = getExtEmpService(user).getEmployeeByIds(ids); + extEmps = extEmps.stream().distinct().collect(Collectors.toList()); + + includeSalaryEmployees.addAll(extEmps); + } + } + + if (!openSecondaryAccount) { + includeSalaryEmployees = includeSalaryEmployees.stream().filter(e -> e.getAccountType() == null || e.getAccountType() == 0).collect(Collectors.toList()); + } + SalaryI18nUtil.i18nList(includeSalaryEmployees); + return includeSalaryEmployees; + } + + @Override + public List getEmployeeByIdsAll(List ids) { + if (CollectionUtils.isEmpty(ids)) { + return new ArrayList<>(); + } + List employeeList = employBiz.getEmployeeByIdsAll(ids); + if (openExtEmp) { + employeeList.addAll(getExtEmpService(user).getEmployeeByIds(ids)); + } + + if (!openSecondaryAccount) { + employeeList = employeeList.stream().filter(e -> e.getAccountType() == null || e.getAccountType() == 0).collect(Collectors.toList()); + } + + SalaryI18nUtil.i18nList(employeeList); + return employeeList; + } + + @Override + public List listByIds(List ids) { + if (CollectionUtils.isEmpty(ids)) { + return Collections.emptyList(); + } + List result = new ArrayList<>(); + if (openExtEmp) { + result.addAll(getExtEmpService(user).getEmployeeByIds(ids)); + } + result.addAll(employBiz.getEmployeeByIdsAll(ids)); + if (!openSecondaryAccount) { + result = result.stream().filter(e -> e.getAccountType() == null || e.getAccountType() == 0).collect(Collectors.toList()); + } + SalaryI18nUtil.i18nList(result); + return result; + } + + @Override + public DataCollectionEmployee getEmployeeById(Long employeeId) { + if (openExtEmp) { + DataCollectionEmployee employee = getExtEmpService(user).getEmployeeById(employeeId); + if (Objects.nonNull(employee)) { + return SalaryI18nUtil.i18n(employee); + } + } + DataCollectionEmployee employee = employBiz.getEmployeeById(employeeId); + return SalaryI18nUtil.i18n(employee); + } + + @Override + public List getEmployeeByIds(List simpleEmployeeIds) { + if (CollectionUtils.isEmpty(simpleEmployeeIds)) { + return new ArrayList<>(); + } + List employeeList = new ArrayList<>(); + List> partition = Lists.partition(simpleEmployeeIds, 1000); + for (List longs : partition) { + employeeList.addAll(employBiz.getEmployeeByIds(longs)); + if (openExtEmp) { + employeeList.addAll(getExtEmpService(user).getEmployeeByIds(longs)); + } + } + + if (!openSecondaryAccount) { + employeeList = employeeList.stream().filter(e -> e.getAccountType() == null || e.getAccountType() == 0).collect(Collectors.toList()); + } + return SalaryI18nUtil.i18nList(employeeList); + + } + + @Override + public List getEmployeeByIdsIncludeAccountType(List simpleEmployeeIds) { + if (CollectionUtils.isEmpty(simpleEmployeeIds)) { + return new ArrayList<>(); + } + List employeeList = new ArrayList<>(); + List> partition = Lists.partition(simpleEmployeeIds, 1000); + for (List longs : partition) { + employeeList.addAll(employBiz.getEmployeeByIdsIncludeAccountType(longs)); + if (openExtEmp) { + employeeList.addAll(getExtEmpService(user).getEmployeeByIds(longs)); + } + } + + if (!openSecondaryAccount) { + employeeList = employeeList.stream().filter(e -> e.getAccountType() == null || e.getAccountType() == 0).collect(Collectors.toList()); + } + return SalaryI18nUtil.i18nList(employeeList); + + } + + + public List filterEmployees(List employees, String userName, String deparmentName, String mobile) { + List employeeSameIds = employees.stream().filter(e -> (StringUtils.isBlank(userName) || Objects.equals(e.getUsername(), userName)) + && (StringUtils.isBlank(deparmentName) || Objects.equals(e.getDepartmentName(), deparmentName)) + && (StringUtils.isBlank(mobile) || Objects.equals(e.getMobile(), mobile))) + .collect(Collectors.toList()); + //存在离职和在职状态取在职状态 + employeeSameIds = employeeSameIds.stream() + .filter(e -> UserStatusEnum.getNormalStatus().contains(e.getStatus())) + .collect(Collectors.toList()); + if (!openSecondaryAccount) { + employeeSameIds = employeeSameIds.stream().filter(e -> e.getAccountType() == null || e.getAccountType() == 0).collect(Collectors.toList()); + } + return SalaryI18nUtil.i18nList(employeeSameIds); + } + + @Override + public List matchImportEmployee(String confValue, List employeeList, String userName, String deparmentName, String mobile, String workcode, String idNo, Long uid) { + if (uid != null) { + return employeeList.stream() + .filter(e -> Objects.equals(e.getEmployeeId(), uid)) + .collect(Collectors.toList()); + } + + List employees = new ArrayList<>(); + //“0”代表姓名+部门+手机号的匹配原则,“1”代表工号为唯一匹配原则 + if ("0".equals(confValue)) { + employees = employeeList.stream().filter(e -> (StringUtils.isBlank(userName) || Objects.equals(e.getUsername(), userName)) + && (StringUtils.isBlank(deparmentName) || Objects.equals(e.getDepartmentName(), deparmentName)) + && (StringUtils.isBlank(mobile) || Objects.equals(e.getMobile(), mobile))) + .collect(Collectors.toList()); + } else if ("1".equals(confValue)) { + employees = employeeList.stream().filter(e -> (StringUtils.isBlank(workcode) || Objects.equals(e.getWorkcode(), workcode))) + .collect(Collectors.toList()); + } else if ("2".equals(confValue)) { + employees = employeeList.stream().filter(e -> (StringUtils.isBlank(idNo) || Objects.equals(e.getIdNo(), idNo))) + .collect(Collectors.toList()); + } + if (!openSecondaryAccount) { + employees = employees.stream().filter(e -> e.getAccountType() == null || e.getAccountType() == 0).collect(Collectors.toList()); + } + return SalaryI18nUtil.i18nList(employees); + + } + + /** + * 人员定位方式 + * “0”代表姓名+部门+手机号的匹配原则,“1”代表工号为唯一匹配原则 + * + * @return + */ + @Override + public String empValidType() { + SalarySysConfPO salarySysConfPO = getSalarySysConfService(user).getOneByCode("matchEmployeeMode"); + return (salarySysConfPO != null && salarySysConfPO.getConfValue() != null && !"".equals(salarySysConfPO.getConfValue())) ? salarySysConfPO.getConfValue() : "0"; + } + + @Override + public List getDeptInfoList(List departmentIds) { + return SalaryI18nUtil.i18nList(employBiz.getDeptInfoList(departmentIds)); + } + + @Override + public DeptInfo getDeptInfoById(Long departmentId) { + if (departmentId == null) { + return null; + } + return SalaryI18nUtil.i18n(employBiz.getDeptInfoById(departmentId)); + } + + @Override + public List getVirtualDeptInfoList(List virtualDepartmentIds) { + if (CollectionUtils.isEmpty(virtualDepartmentIds)) { + return Collections.emptyList(); + } + return SalaryI18nUtil.i18nList(getEmployMapper().getVirtualDeptInfoList(virtualDepartmentIds)); + } + + + @Override + public List getSubCompanyInfoList(List subDepartmentIds) { + return SalaryI18nUtil.i18nList(employBiz.getSubCompanyInfoList(subDepartmentIds)); + } + + @Override + public SubCompanyInfo getSubCompanyInfoById(Long subDepartmentId) { + return SalaryI18nUtil.i18n(employBiz.getSubCompanyInfoById(subDepartmentId)); + } + + @Override + public List getVirtualSubCompanyInfoList(List virtualSubDepartmentIds) { + if (CollectionUtils.isEmpty(virtualSubDepartmentIds)) { + return Collections.emptyList(); + } + return SalaryI18nUtil.i18nList(getEmployMapper().getVirtualSubCompanyInfoList(virtualSubDepartmentIds)); + } + + + @Override + public List listPositionInfo(List positionIds) { + return SalaryI18nUtil.i18nList(employBiz.listPositionInfo(positionIds)); + } + + @Override + public PositionInfo getPositionInfoById(Long positionId) { + return SalaryI18nUtil.i18n(employBiz.getPositionInfoById(positionId)); + } + + @Override + public List listEmployee() { + List result = employBiz.listEmployee(); + if (openExtEmp) { + result.addAll(getExtEmpService(user).listEmployee()); + } + if (!openSecondaryAccount) { + result = result.stream().filter(e -> e.getAccountType() == null || e.getAccountType() == 0).collect(Collectors.toList()); + } + return SalaryI18nUtil.i18nList(result); + } + + @Override + public List listByParams(List includeQueryParams) { + if (CollectionUtils.isEmpty(includeQueryParams)) { + return Collections.emptyList(); + } + List queryParams = includeQueryParams.stream().filter(param -> !param.getTargetType().equals(TargetTypeEnum.SQL.name())).collect(Collectors.toList()); + List result = employBiz.listByParams(queryParams); + if (openExtEmp) { + result.addAll(getExtEmpService(user).listByParams(queryParams)); + } + // 查询虚拟部门、分部人员信息 + List virtualParams = queryParams.stream().filter(param -> + (param.getTargetType().equals(TargetTypeEnum.SUBCOMPANY.name()) || param.getTargetType().equals(TargetTypeEnum.DEPT.name())) && ((List) param.getTargetIds()).get(0).compareTo(0L) < 0 + ).collect(Collectors.toList()); + + result.addAll(employBiz.listByVirtualParams(virtualParams)); + + List empIds = new ArrayList<>(); + includeQueryParams.stream() + .filter(param -> param.getTargetType().equals(TargetTypeEnum.SQL.name())) + .forEach(param -> { + String sql = param.getTarget(); + RecordSet rs = new RecordSet(); + if (rs.execute(sql)) { + while (rs.next()) { + empIds.add((long) rs.getInt("id")); + } + } + }); + List employees = getSalaryEmployeeService(user).getEmployeeByIdsAll(empIds); + result.addAll(employees); + + // 从hrmresource和hrmresourcevirtual可能获取到重复人员数据,需要根据人员id去重 + result = result.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparingLong(DataCollectionEmployee::getEmployeeId))), ArrayList::new)); + if (!openSecondaryAccount) { + result = result.stream().filter(e -> e.getAccountType() == null || e.getAccountType() == 0).collect(Collectors.toList()); + } + return result; + } + + /** + * 根据离职日期获取离职信息 + * + * @param dismissDate + * @return + */ + @Override + public Map getResignationMapByDate(String dismissDate) { + if (StringUtils.isBlank(dismissDate)) { + return Collections.emptyMap(); + } + List employeeList = employBiz.listByDismissDate(dismissDate); + return SalaryEntityUtil.convert2Map(employeeList, DataCollectionEmployee::getEmployeeId, DataCollectionEmployee::getDismissdate); + } + + @Override + public List expandEmployeeInfo(List ids, EmployeeInfoExpandDTO param) { + + List employees = getEmployeeByIdsAll(ids); + + if (param != null) { + RecordSet rs = new RecordSet(); + String sql = param.getExpandSql().replace("=$人员id$", "in (" + StringUtils.join(ids, ",") + ")") + .replace("in($人员id$)", "in (" + StringUtils.join(ids, ",") + ")"); + String primaryKey = param.getPk(); + rs.executeQuery(sql); + while (rs.next()) { + Map extendData = new HashMap<>(); + param.getFieldSettings().forEach(setting -> { + String field = setting.getField(); + String value = rs.getString(field); + setting.setValue(value); + extendData.put(field, value); + }); + + String id = rs.getString(primaryKey); + employees.stream() + .filter(e -> id.equals(e.getEmployeeId().toString())) + .forEach(e -> e.setExtendData(extendData)); + } + } + if (!openSecondaryAccount) { + employees = employees.stream().filter(e -> e.getAccountType() == null || e.getAccountType() == 0).collect(Collectors.toList()); + } + return SalaryI18nUtil.i18nList(employees); + } + + @Override + public Map> expandEmployeeMap(List ids, EmployeeInfoExpandDTO param) { + if (CollectionUtils.isNotEmpty(ids) && param != null) { + Map> map = new HashMap<>(); + + List> partition = Lists.partition(ids, 5); + for (int i = 0; i < partition.size(); i++) { + List idList = partition.get(i); + RecordSet rs = new RecordSet(); + String sql = param.getExpandSql().replace("=$人员id$", " in (" + StringUtils.join(idList, ",") + ")") + .replace("in($人员id$)", " in (" + StringUtils.join(idList, ",") + ")"); + String primaryKey = param.getPk(); + rs.executeQuery(sql); + + log.info("扩展属性sql" + sql); + + while (rs.next()) { + Map extendData = new HashMap<>(); + param.getFieldSettings().forEach(setting -> { + String field = setting.getField(); + String value = rs.getString(field); + setting.setValue(value); + extendData.put(field, Util.formatMultiLang(value)); + }); + + String id = rs.getString(primaryKey); + map.put(Long.valueOf(id), extendData); + } + } + + return map; + } + return new HashMap<>(); + } + + @Override + public void saveEmployeeExpandFieldSettings(EmployeeInfoExpandDTO param) { + String settings = JSON.toJSONString(param.getFieldSettings()); + + Date now = new Date(); + + if (Objects.nonNull(param.getId())) { + ExpandFieldSettingsPO po = getExpandFieldSettingsMapper().getById(param.getId()); + if (po == null) { + throw new RuntimeException("配置不存在!"); + } + + po.setPk(param.getPk()); + po.setExpandSql(param.getExpandSql()); + po.setFieldSetting(settings); + po.setCreator((long) user.getUID()); + po.setUpdateTime(now); + getExpandFieldSettingsMapper().update(po); + + } else { + ExpandFieldSettingsPO po = ExpandFieldSettingsPO.builder() + .id(IdGenerator.generate()) + .module(param.getModule()) + .moduleInfo(param.getModuleInfo()) + .pk(param.getPk()) + .fieldSetting(settings) + .expandSql(param.getExpandSql()) + .deleteType(0) + .creator((long) user.getUID()) + .createTime(now) + .updateTime(now) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .build(); + getExpandFieldSettingsMapper().insertIgnoreNull(po); + } + + } + + + @Override + public EmployeeInfoExpandDTO getExpandFieldSettings(String module) { + + ExpandFieldSettingsPO po = getExpandFieldSettingsMapper().getByModule(module); + + if (po != null) { + List list = JSON.parseArray(po.getFieldSetting(), FieldSetting.class); + return EmployeeInfoExpandDTO.builder() + .id(po.getId()) + .module(po.getModule()) + .moduleInfo(po.getModuleInfo()) + .pk(po.getPk()) + .expandSql(po.getExpandSql()) + .fieldSettings(list) + .build(); + + } + + return null; + } + + @Override + public List getVirtualEmpByVirtualDepIds(List virtualDepartmentIds) { + if (CollectionUtils.isEmpty(virtualDepartmentIds)) { + return Collections.emptyList(); + } + List employees = getEmployMapper().listVirtualEmpByVirtualDepIds(virtualDepartmentIds); + if (!openSecondaryAccount) { + employees = employees.stream().filter(e -> e.getAccountType() == null || e.getAccountType() == 0).collect(Collectors.toList()); + } + return employees; + } + + @Override + public List getVirtualEmpByVirtualSubCompanyIds(List virtualSubCompanyIds) { + if (CollectionUtils.isEmpty(virtualSubCompanyIds)) { + return Collections.emptyList(); + } + return getEmployMapper().listVirtualEmpByVirtualSubCompanyIds(virtualSubCompanyIds); + } + + @Override + public List listBySubCompanyOrDepartment(List subCompanyIds, List departmentIds) { + List employeeList = new ArrayList<>(); + employeeList.addAll(getEmployMapper().listBySubCompanyOrDepartment(subCompanyIds, departmentIds)); + if (openExtEmp) { + employeeList.addAll(getExtEmpService(user).listBySubCompanyOrDepartment(subCompanyIds, departmentIds)); + } + if (!openSecondaryAccount) { + employeeList = employeeList.stream().filter(e -> e.getAccountType() == null || e.getAccountType() == 0).collect(Collectors.toList()); + } + return SalaryI18nUtil.i18nList(employeeList); + } + @Override + public List listBySubCompany(List subCompanyIds) { + return getEmployMapper().listBySubCompany(subCompanyIds); + } + @Override + public List listByDepartment(List departmentIds) { + return getEmployMapper().listByDepartment(departmentIds); + } + @Override + public List listByJob(List jobIds) { + return getEmployMapper().listByJob(jobIds); + } + + @Override + public JobCallInfo getJobCallInfoById(Long jobCallId) { + if (jobCallId == null) { + return null; + } + return SalaryI18nUtil.i18n(getEmployMapper().getJobCallInfoById(jobCallId)); + } + + public List snapshot(List employeeIds, Date snapshotTime) { + + List currentEmployees = getEmployeeByIdsAll(employeeIds); + Map currentEmployeeMap = SalaryEntityUtil.convert2Map(currentEmployees, DataCollectionEmployee::getEmployeeId); + + List employees = employeeIds.stream() + .map(employeeId -> { + + List snapshot = getHrmSnapshotMapper().snapshot(employeeId, snapshotTime); + + return snapshot.stream().findFirst().map(hrmSnapshotPO -> DataCollectionEmployee. + builder() + .employeeId(employeeId) + .username(hrmSnapshotPO.getLastname()) + .departmentName(hrmSnapshotPO.getDepartmentname()) + .departmentId(hrmSnapshotPO.getDepartmentid() == null ? null : NumberUtil.parseLong(Util.null2String(hrmSnapshotPO.getDepartmentid()))) + .subcompanyName(hrmSnapshotPO.getSubcompanyname()) + .subcompanyid(hrmSnapshotPO.getSubcompanyid1() == null ? null : NumberUtil.parseLong(Util.null2String(hrmSnapshotPO.getSubcompanyid1()))) + .costcenterId(hrmSnapshotPO.getCostcenterid() == null ? null : NumberUtil.parseLong(Util.null2String(hrmSnapshotPO.getCostcenterid()))) + .locationId(hrmSnapshotPO.getLocationid() == null ? null : NumberUtil.parseLong(Util.null2String(hrmSnapshotPO.getLocationid()))) + .jobtitleName(hrmSnapshotPO.getJobtitlename()) + .jobtitleId(hrmSnapshotPO.getJobtitle() == null ? null : NumberUtil.parseLong(Util.null2String(hrmSnapshotPO.getJobtitle()))) + .companystartdate(hrmSnapshotPO.getCompanystartdate()) + .mobile(hrmSnapshotPO.getMobile()) +// .dismissdate() + .status(Util.null2String(hrmSnapshotPO.getStatus())) + .statusName(UserStatusEnum.getDefaultLabelByValue(NumberUtils.toInt(Util.null2String(hrmSnapshotPO.getStatus()), 1))) + .workcode(hrmSnapshotPO.getWorkcode()) + .sex(hrmSnapshotPO.getSex()) + .email(hrmSnapshotPO.getEmail()) + .telephone(hrmSnapshotPO.getTelephone()) + .jobcall(hrmSnapshotPO.getJobcallname()) + .jobcallId(hrmSnapshotPO.getJobcall() == null ? null : NumberUtil.parseLong(Util.null2String(hrmSnapshotPO.getJobcall()))) + .birthday(hrmSnapshotPO.getBirthday()) + .workYear(hrmSnapshotPO.getWorkyear() == null ? null : hrmSnapshotPO.getWorkyear().doubleValue()) + .companyWorkYear(hrmSnapshotPO.getCompanyworkyear() == null ? null : hrmSnapshotPO.getCompanyworkyear().doubleValue()) + .idNo(hrmSnapshotPO.getCertificatenum()) + .accountTypeName(AccountTypeEnum.getDefaultLabelByValue(hrmSnapshotPO.getAccounttype())) + .accountType(hrmSnapshotPO.getAccounttype()) + .build()) + .orElse(currentEmployeeMap.get(employeeId)); + }).collect(Collectors.toList()); + + return SalaryI18nUtil.i18nList(employees); + } +} diff --git a/src/com/engine/salary/service/impl/SalaryFormulaServiceImpl.java b/src/com/engine/salary/service/impl/SalaryFormulaServiceImpl.java new file mode 100644 index 000000000..f6b895a9b --- /dev/null +++ b/src/com/engine/salary/service/impl/SalaryFormulaServiceImpl.java @@ -0,0 +1,450 @@ +package com.engine.salary.service.impl; + +import cn.hutool.core.collection.CollectionUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.salaryformula.ExpressFormula; +import com.engine.salary.entity.salaryformula.config.FormluaConfig; +import com.engine.salary.entity.salaryformula.param.SalaryFormulaMockParam; +import com.engine.salary.entity.salaryformula.param.SalaryFormulaSaveParam; +import com.engine.salary.entity.salaryformula.po.FormulaPO; +import com.engine.salary.entity.salaryformula.po.FormulaVar; +import com.engine.salary.enums.salaryformula.ReferenceTypeEnum; +import com.engine.salary.enums.salaryformula.ReturnTypeEnum; +import com.engine.salary.enums.salaryformula.ValidateTypeEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.formlua.entity.standard.ExcelResult; +import com.engine.salary.mapper.formula.FormulaMapper; +import com.engine.salary.mapper.formula.FormulaVarMapper; +import com.engine.salary.service.FormulaRunService; +import com.engine.salary.service.RemoteExcelService; +import com.engine.salary.service.SalaryFormulaService; +import com.engine.salary.util.JsonUtil; +import com.engine.salary.util.db.IdGenerator; +import com.engine.salary.util.db.MapperProxyFactory; +import com.engine.salary.util.valid.ValidUtil; +import com.google.common.collect.Lists; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.math.NumberUtils; +import org.springframework.beans.BeanUtils; +import weaver.hrm.User; + +import java.util.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import java.util.stream.Collectors; + +/** + * 薪酬管理公式编辑器 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Slf4j +public class SalaryFormulaServiceImpl extends Service implements SalaryFormulaService { + + private FormulaMapper getFormulaMapper() { + return MapperProxyFactory.getProxy(FormulaMapper.class); + } + + private FormulaVarMapper getFormulaVarMapper() { + return MapperProxyFactory.getProxy(FormulaVarMapper.class); + } + + private FormulaRunService getFormulaRunService(User user) { + return ServiceUtil.getService(FormulaRunServiceImpl.class, user); + } + + private RemoteExcelService getRemoteExcelService(User user) { + return ServiceUtil.getService(RemoteExcelServiceImpl.class, user); + } + + @Override + public List listExpressFormula(Collection formulaIds) { + formulaIds = formulaIds.stream().filter(id -> id != null && id > 0).collect(Collectors.toList()); + if (CollectionUtils.isEmpty(formulaIds)) { + return Collections.emptyList(); + } + try { + // 当前租户自己新建的公式 + List expressFormulas = getFormulaMapper().listByIds(Lists.newArrayList(formulaIds)); + + return expressFormulas.stream().filter(Objects::nonNull).map(m -> { + ExpressFormula expressFormula = new ExpressFormula(); + BeanUtils.copyProperties(m, expressFormula); + List formulaVarPOS = getFormulaVarMapper().listSome(FormulaVar.builder().formulaId(m.getId()).build()); + expressFormula.setParameters(formulaVarPOS); + return expressFormula; + }).collect(Collectors.toList()); + } catch (Exception e) { + log.info("获取公示详情失败", e); + throw new SalaryRunTimeException("获取公示详情失败"); + } + } + + @Override + public ExpressFormula getExpressFormula(Long formulaId) { + if (formulaId == null || formulaId <= 0) { + return null; + } + try { + // 当前租户自己新建的公式 + FormulaPO formulaPO = getFormulaMapper().getById(formulaId); + ExpressFormula expressFormula = new ExpressFormula(); + BeanUtils.copyProperties(formulaPO, expressFormula); + List formulaVarPOS = getFormulaVarMapper().listSome(FormulaVar.builder().formulaId(formulaId).build()); + expressFormula.setParameters(formulaVarPOS); + + return expressFormula; + } catch (Exception e) { + log.info("获取公示详情失败", e); + throw new SalaryRunTimeException("获取公示详情失败"); + } + } + + @Override + public FormulaPO save(SalaryFormulaSaveParam param) { + ValidUtil.doValidator(param); + if (ReferenceTypeEnum.parseByValue(param.getReferenceType()) == null) { + throw new SalaryRunTimeException("引用类型异常"); + } + if (ReturnTypeEnum.parseByValue(param.getReturnType()) == null) { + throw new SalaryRunTimeException("返回类型异常"); + } + if (ValidateTypeEnum.parseByValue(param.getValidateType()) == null) { + throw new SalaryRunTimeException("校验类型异常"); + } + + //将select因XSS过滤造成的异常字符转换回来 + ValidUtil.modify(param); + + // 解析公式中的参数 + if (ReferenceTypeEnum.parseByValue(param.getReferenceType()) == ReferenceTypeEnum.FORMULA) { + List parameterList = parseFormulaParameters(param.getFormula(), ReferenceTypeEnum.FORMULA); + param.setParameters(parameterList); + } else if (ReferenceTypeEnum.parseByValue(param.getReferenceType()) == ReferenceTypeEnum.SQL) { + List parameterList = parseFormulaParameters(param.getFormula(), ReferenceTypeEnum.SQL); + param.setParameters(parameterList); + } + int orderIndex = 0; + for (FormulaVar parameter : param.getParameters()) { + parameter.setOrderIndex(orderIndex++); + } + + List parameters = param.getParameters(); + //防止参数名和字段名呈现一对多的问题 + if (CollectionUtils.isNotEmpty(parameters)) { + List notRepeatingNameSize = parameters.stream().map(FormulaVar::getFieldName).distinct().collect(Collectors.toList()); + if (notRepeatingNameSize.size() < parameters.size()) { + throw new SalaryRunTimeException("公式参数配置异常!参数名称重复,请清空公式内容后,再重新打开编辑"); + } + } + + String extendParam = param.getExtendParam(); + if (ReferenceTypeEnum.parseByValue(param.getReferenceType()) == ReferenceTypeEnum.SQL) { + if (extendParam == null) { + throw new SalaryRunTimeException("未设置SQL返回值"); + } + + String sqlReturnKey = ""; + try { + Map map = JsonUtil.parseMap(extendParam, String.class); + sqlReturnKey = map.getOrDefault("sqlReturnKey", ""); + } catch (Exception e) { + log.error("express execute fail, sql extendParam parse fail", e); + } + + if (StringUtils.isBlank(sqlReturnKey)) { + throw new SalaryRunTimeException("未设置SQL返回值"); + } + } + + //试运行公式 + checkRun(param); + + FormulaPO formulaPO = new FormulaPO(); + String formula = param.getFormula(); + long formulaId = IdGenerator.generate(); + formulaPO.setId(formulaId); + formulaPO.setName(param.getName()); + formulaPO.setDescription(param.getDescription()); + formulaPO.setModule(param.getModule()); + formulaPO.setUseFor(param.getUseFor()); + formulaPO.setReferenceType(param.getReferenceType()); + formulaPO.setReturnType(param.getReturnType()); + formulaPO.setValidateType(param.getValidateType()); + formulaPO.setExtendParam(extendParam); + formulaPO.setFormula(formula); + formulaPO.setDeleteType(NumberUtils.INTEGER_ZERO); + + Date now = new Date(); + formulaPO.setCreateTime(now); + formulaPO.setUpdateTime(now); + formulaPO.setCreator((long) user.getUID()); + + /* + 公式内容以如下显示方式存储 + {薪资项目.输入项1}+{薪资项目.输入项2} + 转换为实际的运行脚本 + */ + String formulaRunScript = formula; + for (FormulaVar po : parameters) { + formulaRunScript = formulaRunScript.replace(po.getFieldName(), po.getFieldId()); + } + formulaPO.setFormulaRunScript(formulaRunScript); + + getFormulaMapper().insertIgnoreNull(formulaPO); + + for (FormulaVar po : parameters) { + po.setId(IdGenerator.generate()); + po.setFormulaId(formulaId); + po.setDeleteType(NumberUtils.INTEGER_ZERO); + po.setCreator((long) user.getUID()); + po.setCreateTime(now); + po.setUpdateTime(now); + getFormulaVarMapper().insertIgnoreNull(po); + } + return formulaPO; + } + + public List parseFormulaParameters(String formula, ReferenceTypeEnum referenceTypeEnum) { + List parameters = new ArrayList<>(); + // 获取公式中所有可选的变量项目 + Map> allParameters = getRemoteExcelService(user).allFieldList(referenceTypeEnum); + List groups = new ArrayList<>(allParameters.keySet()); + StringBuilder reg = new StringBuilder("("); + for (int i = 0; i < groups.size(); i++) { + reg.append("\\{" + groups.get(i) + "\\."); + if (i + 1 != groups.size()) { + reg.append("|"); + } + } + reg.append(").*?}"); + // 提取公式中所有的变量 + Pattern pattern = Pattern.compile(reg.toString()); + Matcher matcher = pattern.matcher(formula); + List vars = new ArrayList<>(); + while (matcher.find()) { + String var = matcher.group(0).replaceAll("\\{", "").replaceAll("}", ""); + if (StringUtils.isNotBlank(var)) { + vars.add(var); + } + } + // 去重 + vars = vars.stream().distinct().collect(Collectors.toList()); + for (String var : vars) { + String[] split = var.split("\\."); + if (split.length == 2) { + List formulaVars = allParameters.get(split[0]); + if (formulaVars == null) { + throw new SalaryRunTimeException("保存失败,公式变量" + split[0] + "输入有误!"); + } + Optional field = formulaVars.stream().filter(v -> Objects.equals(v.getName(), split[1])).findFirst(); + if (field.isPresent()) { + FormulaVar formulaVar = field.get(); + String fieldName = "{" + split[0] + "." + split[1] + "}"; + formulaVar.setFieldName(fieldName); + parameters.add(formulaVar); + } else { + throw new SalaryRunTimeException("保存失败,公式变量" + split[0] + split[1] + "输入有误!"); + } + } else if (split.length > 2) { + // 变量名称中包含. + List formulaVars = allParameters.get(split[0]); + if (formulaVars == null) { + throw new SalaryRunTimeException("保存失败,公式变量" + split[0] + "输入有误!"); + } + StringBuilder field = new StringBuilder(""); + for (int i = 1; i < split.length; i++) { + if (i != 1) { + field.append("."); + } + field = field.append(split[i]); + } + String finalField = field.toString(); + Optional optional = formulaVars.stream().filter(v -> Objects.equals(v.getName(), finalField)).findFirst(); + if (optional.isPresent()) { + FormulaVar formulaVar = optional.get(); + String fieldName = "{" + split[0] + "." + field + "}"; + formulaVar.setFieldName(fieldName); + parameters.add(optional.get()); + } else { + throw new SalaryRunTimeException("保存失败,公式变量" + split[0] + split[1] + "输入有误!"); + } + } + } + return parameters; + } + + /** + * 模拟运行公式 + * + * @param param + */ + private void checkRun(SalaryFormulaSaveParam param) { + //返回类型 + String returnType = param.getReturnType(); + ReturnTypeEnum returnTypeEnum = ReturnTypeEnum.parseByValue(returnType); + + /* + 公式内容以如下显示方式存储 + {薪资项目.输入项1}+{薪资项目.输入项2} + 转换为实际的运行脚本 + */ + String formulaRunScript = param.getFormula(); +// +// List parameters = param.getParameters(); +// for (int i = 0; i < parameters.size(); i++) { +// FormulaVar po = parameters.get(i); +// formulaRunScript = formulaRunScript.replace(po.getFieldName(), po.getFieldId()); +// po.setContent(String.valueOf(i + 1)); +// } +// //验证公式是否可运行 +// if (ReferenceTypeEnum.parseByValue(param.getReferenceType()) == ReferenceTypeEnum.FORMULA) { +// ExpressFormula test = ExpressFormula.builder().formulaRunScript(formulaRunScript).extendParam(param.getExtendParam()).referenceType(param.getReferenceType()).build(); +// ExcelResult run = getFormulaRunService(user).run(test, parameters, DataCollectionEmployee.builder().employeeId((long) user.getUID()).build()); +// +// if (run.isStatus()) { +// //返回结果不是数字 +// if (returnTypeEnum == ReturnTypeEnum.NUMBER && !NumberUtils.isCreatable(String.valueOf(run))) { +// throw new SalaryRunTimeException("返回结果不是数值"); +// } +// }else { +// throw new SalaryRunTimeException("公式配置异常"); +// } +// } + + if (ReferenceTypeEnum.parseByValue(param.getReferenceType()) == ReferenceTypeEnum.SQL) { + if (formulaRunScript.contains(";") || formulaRunScript.contains("--")) { + throw new SalaryRunTimeException("SQL配置异常,请去除';'或者'--'"); + } + } + } + + + @Override + public Object mock(SalaryFormulaMockParam param) { + + ValidUtil.doValidator(param); + + FormulaPO po = getFormulaMapper().getById(param.getId()); + + //验证公式是否可运行 + ExpressFormula test = ExpressFormula.builder().formulaRunScript(po.getFormulaRunScript()).extendParam(po.getExtendParam()).referenceType(po.getReferenceType()).build(); + ExcelResult run = getFormulaRunService(user).run(test, param.getParameters(), DataCollectionEmployee.builder().employeeId((long) user.getUID()).build()); + if (run.isStatus()) { + return run.getData(); + } else { + return run.getErrorMsg(); + } + } + + @Override + public void initFunction() { + + } + + @Override + public void deleteNotIn(List formulaIds) { + Date today = new Date(); + Calendar c = Calendar.getInstance(); + c.setTime(today); + c.add(Calendar.DAY_OF_MONTH, -1); + Date yesterday = c.getTime(); + if (CollectionUtils.isNotEmpty(formulaIds)) { + List allFormula = getFormulaMapper().listAll(); + //待删除的公式 + List needDeleteIds = allFormula.stream().map(FormulaPO::getId).filter(id -> !formulaIds.contains(id)).collect(Collectors.toList()); + List> partition = Lists.partition(needDeleteIds, 1000); + partition.forEach(list -> { + getFormulaMapper().deleteIn(list, yesterday); + getFormulaVarMapper().deleteInFormulaIds(list, yesterday); + }); + } + } + + @Override + public List listVarByFormulaIds(List effectiveFormulaIds) { + List vars = new ArrayList<>(); + if (CollectionUtils.isNotEmpty(effectiveFormulaIds)) { + List> partition = Lists.partition(effectiveFormulaIds, 999); + partition.forEach(list -> { + vars.addAll(getFormulaVarMapper().listSome(FormulaVar.builder().formulaIds(list).build())); + }); + } + return vars; + } + + @Override + public List listByCode(String code) { + return getFormulaVarMapper().listSome(FormulaVar.builder().fieldId(code).build()); + } + + @Override + public void updateVar(FormulaVar formulaVar) { + getFormulaVarMapper().updateIgnoreNull(formulaVar); + } + + @Override + public List listByIds(List formulaIds) { + if (CollectionUtils.isEmpty(formulaIds)) { + return new ArrayList<>(); + } + return getFormulaMapper().listByIds(formulaIds); + } + + @Override + public List listAll() { + return getFormulaMapper().listAll(); + } + + @Override + public List listAllVar() { + return getFormulaVarMapper().listAll(); + } + + @Override + public void update(FormulaPO formulaPO) { + getFormulaMapper().updateIgnoreNull(formulaPO); + } + + @Override + public FormluaConfig getConfig() { + List formulaPOS = getFormulaMapper().listAll(); + List formulaVars = getFormulaVarMapper().listAll(); + return FormluaConfig.builder().formulas(formulaPOS).formulaVars(formulaVars).build(); + } + + @Override + public Long add(FormulaPO formula) { + if (formula == null) { + return 0L; + } + + long uid = user.getUID(); + Date now = new Date(); + long formulaId = IdGenerator.generate(); + formula.setId(formulaId); + formula.setCreator(uid); + formula.setCreateTime(now); + + getFormulaMapper().insertIgnoreNull(formula); + + List formulaVars = formula.getFormulaVars(); + if (CollectionUtil.isNotEmpty(formulaVars)) { + formulaVars.forEach(v -> { + v.setId(IdGenerator.generate()); + v.setFormulaId(formulaId); + v.setCreator(uid); + v.setCreateTime(now); + getFormulaVarMapper().insertIgnoreNull(v); + }); + } + return formulaId; + } +} diff --git a/src/com/engine/salary/service/impl/SalaryItemServiceImpl.java b/src/com/engine/salary/service/impl/SalaryItemServiceImpl.java new file mode 100644 index 000000000..bbcbb459e --- /dev/null +++ b/src/com/engine/salary/service/impl/SalaryItemServiceImpl.java @@ -0,0 +1,866 @@ +package com.engine.salary.service.impl; + +import cn.hutool.core.util.NumberUtil; +import cn.hutool.core.util.StrUtil; +import com.api.formmode.mybatis.util.SqlProxyHandle; +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.hrmelog.entity.dto.LoggerContext; +import com.engine.salary.biz.SalaryItemBiz; +import com.engine.salary.biz.SysSalaryItemBiz; +import com.engine.salary.config.SalaryElogConfig; +import com.engine.salary.constant.SalaryDefaultTenantConstant; +import com.engine.salary.entity.salaryformula.param.SalaryFormulaSaveParam; +import com.engine.salary.entity.salaryformula.po.FormulaPO; +import com.engine.salary.entity.salaryformula.po.FormulaVar; +import com.engine.salary.entity.salaryitem.bo.SalaryItemBO; +import com.engine.salary.entity.salaryitem.config.SalaryItemAllConfig; +import com.engine.salary.entity.salaryitem.config.SalaryItemExcelConfig; +import com.engine.salary.entity.salaryitem.param.*; +import com.engine.salary.entity.salaryitem.po.SalaryItemPO; +import com.engine.salary.entity.salaryitem.po.SysSalaryItemPO; +import com.engine.salary.entity.salarysob.param.SalarySobQueryParam; +import com.engine.salary.entity.salarysob.po.SalarySobBackItemPO; +import com.engine.salary.entity.salarysob.po.SalarySobItemPO; +import com.engine.salary.entity.salarysob.po.SalarySobPO; +import com.engine.salary.entity.taxagent.param.TaxAgentQueryParam; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import com.engine.salary.enums.*; +import com.engine.salary.enums.auth.AuthFilterTypeEnum; +import com.engine.salary.enums.salaryformula.ReferenceTypeEnum; +import com.engine.salary.enums.salaryformula.ReturnTypeEnum; +import com.engine.salary.enums.salaryitem.SalaryDataTypeEnum; +import com.engine.salary.enums.sicategory.SharedTypeEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.mapper.salaryitem.SalaryItemMapper; +import com.engine.salary.service.*; +import com.engine.salary.service.auth.AuthService; +import com.engine.salary.service.auth.AuthServiceImpl; +import com.engine.salary.sys.entity.vo.UploadConfigResponse; +import com.engine.salary.util.JsonUtil; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.db.IdGenerator; +import com.engine.salary.util.excel.ExcelParseHelper; +import com.engine.salary.util.excel.ExcelSupport; +import com.engine.salary.util.excel.ExcelUtil; +import com.engine.salary.util.excel.ImportExcelResponse; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.util.page.SalaryPageUtil; +import com.engine.salary.util.valid.ValidUtil; +import com.google.common.collect.Lists; +import com.weaver.general.Util; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.util.IOUtils; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.springframework.beans.BeanUtils; +import weaver.file.ImageFileManager; +import weaver.hrm.User; + +import java.io.InputStream; +import java.util.*; +import java.util.stream.Collectors; + +import static com.engine.salary.util.excel.ExcelSupport.EXCEL_TYPE_XLSX; + +/** + * 薪资项目 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Slf4j +public class SalaryItemServiceImpl extends Service implements SalaryItemService { + + private SalaryItemBiz salaryItemBiz = new SalaryItemBiz(); + + private SalarySobItemService getSalarySobItemService(User user) { + return ServiceUtil.getService(SalarySobItemServiceImpl.class, user); + } + + private TaxAgentService getTaxAgentService(User user) { + return ServiceUtil.getService(TaxAgentServiceImpl.class, user); + } + + private SysSalaryItemService getSysSalaryItemService(User user) { + return ServiceUtil.getService(SysSalaryItemServiceImpl.class, user); + } + + private SalaryFormulaService getSalaryFormulaService(User user) { + return ServiceUtil.getService(SalaryFormulaServiceImpl.class, user); + } + + + private SalarySobBackItemService getSalarySobBackItemService(User user) { + return ServiceUtil.getService(SalarySobBackItemServiceImpl.class, user); + } + + public SalarySobService getSalarySobService(User user) { + return ServiceUtil.getService(SalarySobServiceImpl.class, user); + } + + private SysSalaryItemBiz sysSalaryItemBiz = new SysSalaryItemBiz(); + + private SalaryItemMapper getSalaryItemMapper() { + return SqlProxyHandle.getProxy(SalaryItemMapper.class); + } + + public AuthService getAuthService(User user) { + return ServiceUtil.getService(AuthServiceImpl.class, user); + } + + @Override + public SalaryItemPO getById(Long id) { + return salaryItemBiz.getById(id); + } + + @Override + public List listAll() { + return salaryItemBiz.listAll(); + } + + @Override + public List listByIds(Collection ids) { + if (CollectionUtils.isEmpty(ids)) { + return Collections.emptyList(); + } + return salaryItemBiz.listSome(SalaryItemPO.builder().ids(ids).build()); + } + + @Override + public List listBySysSalaryItemIds(Collection sysSalaryItemIds) { + if (CollectionUtils.isEmpty(sysSalaryItemIds)) { + return Collections.emptyList(); + } + return salaryItemBiz.listSome(SalaryItemPO.builder().sysSalaryItemIds(sysSalaryItemIds).build()); + } + + @Override + public List listByName(String name) { + return salaryItemBiz.listSome(SalaryItemPO.builder().name(name).build()); + } + + @Override + public SalaryItemPO getByName(String name) { + return getSalaryItemMapper().getByName(name); + } + + + @Override + public List listBySystemType(SalarySystemTypeEnum systemType) { + return salaryItemBiz.listSome(SalaryItemPO.builder().systemType(systemType.getValue()).build()); + } + + @Override + public List listBySystemTypeAndUseDefault(SalarySystemTypeEnum systemType, Integer useDefault) { + return salaryItemBiz.listSome(SalaryItemPO.builder().systemType(systemType.getValue()).useDefault(useDefault).build()); + } + + @Override + public List listByParam(SalaryItemSearchParam searchParam) { + return salaryItemBiz.listByParam(searchParam); + } + + @Override + public List listByParamOrderById(SalaryItemSearchParam searchParam) { + return salaryItemBiz.listByParamOrderById(searchParam); + } + + @Override + public PageInfo listPageByParam(SalaryItemSearchParam searchParam) { + List salaryItemPOS = salaryItemBiz.listByParam(searchParam); + + TaxAgentQueryParam param = TaxAgentQueryParam.builder().build(); + param.setFilterType(AuthFilterTypeEnum.ADMIN_DATA); + List taxAgentPOS = getTaxAgentService(user).listAuth(param); + Set userTaxAgentIds = SalaryEntityUtil.properties(taxAgentPOS,TaxAgentPO::getId); + salaryItemPOS = salaryItemPOS.stream() + .filter(po -> filterInRange(userTaxAgentIds, po)) + .sorted((o1, o2) -> { + if (o1.getSortedIndex() == null && o2.getSortedIndex() == null) { + Integer systemType1 = o1.getSystemType() == null ? 0 : o1.getSystemType(); + Integer systemType2 = o2.getSystemType() == null ? 0 : o2.getSystemType(); + return systemType1.compareTo(systemType2); + } else { + Integer sortedIndex1 = o1.getSortedIndex() == null ? 0 : o1.getSortedIndex(); + Integer sortedIndex2 = o2.getSortedIndex() == null ? 0 : o2.getSortedIndex(); + return sortedIndex2.compareTo(sortedIndex1); + } + }) + .collect(Collectors.toList()); + return SalaryPageUtil.buildPage(searchParam.getCurrent(), searchParam.getPageSize(), salaryItemPOS); + } + + + @Override + public boolean filterInRange(Set userTaxAgentIds, SalaryItemPO po) { + return null == po.getSharedType() + || SharedTypeEnum.PUBLIC.getValue().equals(po.getSharedType().toString()) + || (StrUtil.isNotBlank(po.getTaxAgentIds()) + && Arrays.stream(po.getTaxAgentIds().split(",")) + .map(Long::valueOf) + .anyMatch(userTaxAgentIds::contains)); + } + +// @Override +// public Page listPageByParam(SalaryItemSearchParam searchParam, String tenantKey) { +// // 分页参数 +// Page page = SalaryPageUtil.buildPage(searchParam.getCurrent(), searchParam.getPageSize()); +// // 构建查询参数 +// Wrapper queryWrapper = SalaryItemBO.buildQueryWrapper(searchParam, tenantKey); +// // 返回查询结果 +// return SalaryItemBiz.selectPage(page, queryWrapper); +// } + + @Override + public SalaryItemPO save(SalaryItemSaveParam saveParam) { + // 名称不能和已有的自定义薪资项目重名 + List salaryItemPOS = listByName(saveParam.getName()); + if (CollectionUtils.isNotEmpty(salaryItemPOS)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98326, "薪资项目名称已存在,请重新命名")); + } + // 名称不能和已有的系统薪资项目重名 + SysSalaryItemPO sysSalaryItem = sysSalaryItemBiz.selectOneByName(saveParam.getName()); + if (sysSalaryItem != null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98328, "自定义薪资项目的名称不能和系统薪资项目的名称重名")); + } + SalaryItemPO salaryItemPO = SalaryItemBO.convert2SalaryItemPO(saveParam, (long) user.getUID()); + salaryItemBiz.insert(salaryItemPO); + return salaryItemPO; + } + + @Override + public void batchSave(Collection salaryItemPOS) { + salaryItemBiz.batchSave(salaryItemPOS); + } + + @Override + public SalaryItemPO update(SalaryItemSaveParam saveParam) { + // 查询薪资项目,判断薪资项目是否存在 + SalaryItemPO salaryItemPO = getById(saveParam.getId()); + if (Objects.isNull(salaryItemPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98299, "参数错误,薪资项目不存在或已被删除")); + } + // 名称不能和已有的自定义薪资项目重名 + List salaryItemPOS = listByName(saveParam.getName()); + boolean nameExist = salaryItemPOS.stream().anyMatch(e -> !Objects.equals(salaryItemPO.getId(), e.getId())); + if (nameExist) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98326, "薪资项目名称已存在,请重新命名")); + } + // 名称不能和已有的系统薪资项目重名 + List sysSalaryItemPOS = sysSalaryItemBiz.listSome(SysSalaryItemPO.builder().name(saveParam.getName()).build()); + boolean sysNameExist = sysSalaryItemPOS.stream().anyMatch(e -> !Objects.equals(salaryItemPO.getSysSalaryItemId(), e.getId())); + if (sysNameExist) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98328, "自定义薪资项目的名称不能和系统薪资项目的名称重名")); + } + // 更新薪资项目 + SalaryItemPO newSalaryItemPO = new SalaryItemPO(); + BeanUtils.copyProperties(salaryItemPO, newSalaryItemPO); + newSalaryItemPO.setName(saveParam.getName()); + newSalaryItemPO.setUseDefault(saveParam.getUseDefault()); + newSalaryItemPO.setUseInEmployeeSalary(saveParam.getUseInEmployeeSalary()); + newSalaryItemPO.setHideDefault(saveParam.getHideDefault()); + newSalaryItemPO.setRoundingMode(saveParam.getRoundingMode()); + newSalaryItemPO.setPattern(saveParam.getPattern()); + newSalaryItemPO.setValueType(saveParam.getValueType()); + newSalaryItemPO.setDataType(saveParam.getDataType()); + newSalaryItemPO.setFormulaId(Objects.equals(saveParam.getValueType(), SalaryValueTypeEnum.INPUT.getValue()) ? 0L : saveParam.getFormulaId()); + newSalaryItemPO.setDescription(saveParam.getDescription()); + newSalaryItemPO.setUpdateTime(new Date()); + newSalaryItemPO.setSharedType(saveParam.getSharedType()); + newSalaryItemPO.setTaxAgentIds(saveParam.getTaxAgentIds()); + newSalaryItemPO.setSortedIndex(saveParam.getSortedIndex()); + newSalaryItemPO.setWidth(saveParam.getWidth()); + newSalaryItemPO.setDefaultValue(saveParam.getDefaultValue()); + salaryItemBiz.updateById(newSalaryItemPO); + + //改名后更新公式 + String oldName = salaryItemPO.getName(); + String newName = saveParam.getName(); + if (!StringUtils.equals(oldName, newName)) { + + //薪资项目 + + if (newSalaryItemPO.getUseInEmployeeSalary() == 0) { + String itemPrefix = "salaryItem_"; + String fieldNamePrefix = "{薪资项目.%s}"; + changeName(salaryItemPO, oldName, newName, itemPrefix, fieldNamePrefix); + } + + if (newSalaryItemPO.getUseInEmployeeSalary() == 1) { + //引用档案 + String itemPrefix = "salaryArchives_"; + String fieldNamePrefix = "{薪资档案.%s}"; + changeName(salaryItemPO, oldName, newName, itemPrefix, fieldNamePrefix); + + //引用项目 + itemPrefix = "salaryItem_"; + fieldNamePrefix = "{薪资项目.%s}"; + changeName(salaryItemPO, oldName, newName, itemPrefix, fieldNamePrefix); + } + } + + return salaryItemPO; + } + + private void changeName(SalaryItemPO salaryItemPO, String oldName, String newName, String itemPrefix, String fieldNamePrefix) { + String code = itemPrefix + salaryItemPO.getCode(); + Date now = new Date(); + List formulaVars = getSalaryFormulaService(user).listByCode(code); + formulaVars.forEach(v -> { + FormulaVar formulaVar = FormulaVar.builder() + .id(v.getId()) + .name(newName) + .fieldName(String.format(fieldNamePrefix, newName)) + .updateTime(now) + .build(); + getSalaryFormulaService(user).updateVar(formulaVar); + }); + + List formulaIds = SalaryEntityUtil.properties(formulaVars, FormulaVar::getFormulaId, Collectors.toList()); + List formulaPOS = getSalaryFormulaService(user).listByIds(formulaIds); + formulaPOS.forEach(f -> { + String formula = f.getFormula(); + formula = formula.replace(String.format(fieldNamePrefix, oldName), String.format(fieldNamePrefix, newName)); + FormulaPO formulaPO = FormulaPO.builder() + .id(f.getId()) + .formula(formula) + .updateTime(now) + .build(); + getSalaryFormulaService(user).update(formulaPO); + }); + } + + @Override + public void deleteByIds(Collection ids) { + SalaryItemServiceImpl.UsingItem usingItem = getUsingItem(); + List usingItemIds = usingItem.getUsingItemIds(); + List usingCodes = usingItem.getUsingCodes(); + + // 查询薪资项目 + List salaryItemPOS = listByIds(ids); + if (CollectionUtils.isEmpty(salaryItemPOS)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98299, "参数错误,薪资项目不存在或已被删除")); + } + if (CollectionUtils.containsAny(usingItemIds, ids)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98322, "薪资账套正在使用该薪资项目,不允许删除")); + } + List codes = SalaryEntityUtil.properties(salaryItemPOS, SalaryItemPO::getCode, Collectors.toList()); + if (CollectionUtils.containsAny(usingCodes, codes)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98322, "公式正在使用该薪资项目,不允许删除")); + } + + + // 删除薪资项目 + ids = SalaryEntityUtil.properties(salaryItemPOS, SalaryItemPO::getId); + salaryItemBiz.deleteByIds(ids); + Integer useInEmployeeSalary = salaryItemPOS.get(0).getUseInEmployeeSalary(); + // 记录删除日志 + if (useInEmployeeSalary == 0) { + // 薪资项目 + salaryItemPOS.forEach(salaryItemPO -> { + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(salaryItemPO.getId())); + loggerContext.setTargetName(salaryItemPO.getName()); + loggerContext.setOperateType(OperateTypeEnum.DELETE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "删除薪资项目")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "删除薪资项目") + ": " + salaryItemPO.getName()); + loggerContext.setOldValues(salaryItemPO); + SalaryElogConfig.salaryItemLoggerTemplate.write(loggerContext); + }); + } else { + // 字段管理 + salaryItemPOS.forEach(salaryItemPO -> { + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(salaryItemPO.getId())); + loggerContext.setTargetName(salaryItemPO.getName()); + loggerContext.setOperateType(OperateTypeEnum.DELETE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "删除字段")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "删除字段") + ": " + salaryItemPO.getName()); + loggerContext.setOldValues(salaryItemPO); + SalaryElogConfig.salaryArchiveFieldLoggerTemplate.write(loggerContext); + }); + } + + } + + + /** + * 获取使用中的项目id、项目编码、公式id + * + * @return 项目id、项目编码、公式id + */ + @Override + public UsingItem getUsingItem() { + + //系统项目 + List sysItems = getSysSalaryItemService(user).listAll(); + List sysItemFormulaIds = SalaryEntityUtil.properties(sysItems, SysSalaryItemPO::getFormulaId, Collectors.toList()); + + //薪资项目 + List items = listAll(); + List itemFormulaIds = SalaryEntityUtil.properties(items, SalaryItemPO::getFormulaId, Collectors.toList()); + + //账套项目 + List sobItems = getSalarySobItemService(user).list(); + List sobItemFormulaIds = SalaryEntityUtil.properties(sobItems, SalarySobItemPO::getFormulaId, Collectors.toList()); + + //回算项目 + List backItems = getSalarySobBackItemService(user).listAll(); + List backItemFormulaIds = SalaryEntityUtil.properties(backItems, SalarySobBackItemPO::getFormulaId, Collectors.toList()); + + List usingFormulaIds = new ArrayList<>(); + usingFormulaIds.addAll(sysItemFormulaIds); + usingFormulaIds.addAll(itemFormulaIds); + usingFormulaIds.addAll(sobItemFormulaIds); + usingFormulaIds.addAll(backItemFormulaIds); + + + //账套里的项目,项目里的项目 + List sobItemIds = SalaryEntityUtil.properties(sobItems, SalarySobItemPO::getSalaryItemId, Collectors.toList()); + List backItemIds = SalaryEntityUtil.properties(backItems, SalarySobBackItemPO::getSalaryItemId, Collectors.toList()); + List usingItemIds = new ArrayList<>(); + usingItemIds.addAll(sobItemIds); + usingItemIds.addAll(backItemIds); + + //使用中的code + List formulaVars = getSalaryFormulaService(user).listVarByFormulaIds(usingFormulaIds); + List itemCode = formulaVars.stream() + .map(FormulaVar::getFieldId) + .map(v -> v.replaceAll("variableItem_", "")) + .map(v -> v.replaceAll("salaryItem_", "")) + .map(v -> v.replaceAll("salaryArchives_", "")) + .map(v -> v.replaceAll("ISSUED_", "")) + .collect(Collectors.toList()); + + return UsingItem.builder().usingFormulaIds(usingFormulaIds).usingItemIds(usingItemIds).usingCodes(itemCode).build(); + } + + @Override + public void batchUpdateSortedIndex(List values) { + salaryItemBiz.batchUpdateSortedIndex(values); + } + + @Override + public List> getSalarySobBySalaryItem(Long salaryItemId) { + // 查询所有管理的薪资账套 + SalarySobQueryParam salarySobQueryParam = new SalarySobQueryParam(); + salarySobQueryParam.setFilterType(AuthFilterTypeEnum.ADMIN_DATA); + List salarySobs = getSalarySobService(user).listAuth(salarySobQueryParam); + return salarySobs.stream().map(m -> { + Map map = new HashMap<>(); + map.put("id", String.valueOf(m.getId())); + map.put("content", m.getName()); + return map; + }).collect(Collectors.toList()); + } + + @Override + public void syncSalaryItemToSalarySobItem(SyncSalaryItemParam param) { + ValidUtil.doValidator(param); + // 获取薪资项目信息 + SalaryItemPO salaryItemPO = salaryItemBiz.getById(param.getSalaryItemId()); + if (salaryItemPO == null) { + throw new SalaryRunTimeException("薪资项目不存在或已被删除"); + } + // 获取薪资账套中薪资项目信息 + List salarySobItemPOS = getSalarySobItemService(user).listBySalaryItemIds(Collections.singleton(param.getSalaryItemId())); + salarySobItemPOS = salarySobItemPOS.stream().filter(po -> param.getSalarySobIds().contains(po.getSalarySobId())).collect(Collectors.toList()); + // 更新薪资账套中的薪资项目信息 + Date now = new Date(); + for (SalarySobItemPO sobItem : salarySobItemPOS) { + sobItem.setFormulaId(salaryItemPO.getFormulaId()); + sobItem.setRoundingMode(salaryItemPO.getRoundingMode()); + sobItem.setPattern(salaryItemPO.getPattern()); + sobItem.setValueType(salaryItemPO.getValueType()); + sobItem.setDescription(salaryItemPO.getDescription()); + sobItem.setUpdateTime(now); + sobItem.setDefaultValue(salaryItemPO.getDefaultValue() == null ? "" : salaryItemPO.getDefaultValue()); + getSalarySobItemService(user).update(sobItem); + } + } + + + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + public static class UsingItem { + private List usingFormulaIds; + + private List usingItemIds; + + private List usingCodes; + + } + + + public UsingItem getUsingItem(Long id) { + + //薪资项目 + SalaryItemPO items = getById(id); + + //账套项目 + List sobItems = getSalarySobItemService(user).listBySalaryItemIds(Collections.singleton(id)); + + //回算项目 + List backItems = getSalarySobBackItemService(user).listBySalaryItemIds(Collections.singleton(id)); + + +// //账套里的项目,项目里的项目 +// List sobItemIds = SalaryEntityUtil.properties(sobItems, SalarySobItemPO::getSalaryItemId, Collectors.toList()); +// List backItemIds = SalaryEntityUtil.properties(backItems, SalarySobBackItemPO::getSalaryItemId, Collectors.toList()); +// List usingItemIds = new ArrayList<>(); +// usingItemIds.addAll(sobItemIds); +// usingItemIds.addAll(backItemIds); +// +// //使用中的code +// List formulaVars = getSalaryFormulaService(user).listVarByFormulaIds(usingFormulaIds); +// List itemCode = formulaVars.stream().map(FormulaVar::getFieldId).map(v -> v.replaceAll("salaryItem_", "")).collect(Collectors.toList()); + + return UsingItem.builder().build(); + } + + + @Override + public List getConfig(SalaryItemExportParam param) { + return getSalaryItemMapper().getConfig(param.getIds()); + } + + + @Override + public Map preview(SalaryItemImportParam param) { + InputStream fileInputStream = null; + try { + fileInputStream = ImageFileManager.getInputStreamById(Integer.parseInt(param.getImageId())); + Sheet sheet = ExcelSupport.parseFile(fileInputStream, 0, EXCEL_TYPE_XLSX); + Map apidatas = new HashMap(); + apidatas.put("headers", ExcelSupport.getSheetHeader(sheet, 0)); + apidatas.put("list", ExcelParseHelper.parse2List(sheet, 1)); + return apidatas; + } finally { + IOUtils.closeQuietly(fileInputStream); + } + } + + @Override + public ImportExcelResponse importSalaryItem(SalaryItemImportParam param) { + + Date now = new Date(); + InputStream fileInputStream = null; + try { + fileInputStream = ImageFileManager.getInputStreamById(Integer.parseInt(param.getImageId())); + List configs = ExcelParseHelper.parse2Map(fileInputStream, SalaryItemExcelConfig.class, 0, 1, 13, EXCEL_TYPE_XLSX); + + // 错误excel内容 + ImportExcelResponse response = ImportExcelResponse.builder().totalCount(configs.size()).successCount(configs.size()).errorCount(0).errorData(new ArrayList<>()).build(); + + List sysSalaryItemPOS = sysSalaryItemBiz.listAll(); + Set sysItems = SalaryEntityUtil.properties(sysSalaryItemPOS, SysSalaryItemPO::getName); + + List adds = new ArrayList<>(); + List updates = new ArrayList<>(); + Map> formulaItems = new HashMap<>(); + for (int i = 0; i < configs.size(); i++) { + String rowIndex = String.format("第%s行", i + 2); + SalaryItemExcelConfig config = configs.get(i); + String name = config.getName(); + SalaryValueTypeEnum salaryValueTypeEnum = SalaryValueTypeEnum.parseByDefaultLabel(config.getValueType()); + SalaryDataTypeEnum salaryDataTypeEnum = SalaryDataTypeEnum.parseByDefaultLabel(config.getDataType()); + SalaryItemPO itemPO = getByName(name); + if (itemPO == null) { + + if (sysItems.contains(name)) { + ImportExcelResponse.Error error = ImportExcelResponse.Error.builder().message(String.format("%s“%s”的名称与系统名称冲突", rowIndex, name)).build(); + response.setSuccessCount(response.getSuccessCount() - 1); + response.setErrorCount(response.getErrorCount() + 1); + response.getErrorData().add(error); + continue; + } + + itemPO = SalaryItemPO.builder() + .id(IdGenerator.generate()) + .code(IdGenerator.getUUID()) + .name(name) + .systemType(SalarySystemTypeEnum.CUSTOM.getValue()) + .sysSalaryItemId(org.apache.commons.lang3.math.NumberUtils.LONG_ZERO) + .useDefault(SalaryOnOffEnum.parseByDefaultLabel(config.getUseDefault()).getValue()) + .useInEmployeeSalary(SalaryOnOffEnum.OFF.getValue()) + .hideDefault(SalaryOnOffEnum.parseByDefaultLabel(config.getHideDefault()).getValue()) + .roundingMode(SalaryRoundingModeEnum.parseByDefaultLabel(config.getRoundingMode()).getValue()) + .pattern(NumberUtil.isNumber(config.getPattern()) ? Integer.parseInt(config.getPattern()) : 2) + .valueType(salaryValueTypeEnum.getValue()) + .dataType(salaryDataTypeEnum.getValue()) + //后补 + .formulaId(0L) + .description(config.getDescription()) + .canEdit(org.apache.commons.lang3.math.NumberUtils.INTEGER_ONE) + .creator((long) user.getUID()) + .deleteType(0) + .createTime(now) + .updateTime(now) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .sharedType(0) + .taxAgentIds("") + .sortedIndex(NumberUtil.isNumber(config.getSortedIndex()) ? Integer.parseInt(config.getSortedIndex()) : null) + .width(NumberUtil.isNumber(config.getWidth()) ? Integer.parseInt(config.getWidth()) : null) + .defaultValue(config.getDefaultValue()) + .build(); + adds.add(itemPO); + } else { + + if (SalarySystemTypeEnum.parseByValue(itemPO.getSystemType()) == SalarySystemTypeEnum.SYSTEM) { + ImportExcelResponse.Error error = ImportExcelResponse.Error.builder().message(String.format("%s“%s”是系统薪资项目不支持修改", rowIndex, name)).build(); + response.setSuccessCount(response.getSuccessCount() - 1); + response.setErrorCount(response.getErrorCount() + 1); + response.getErrorData().add(error); + continue; + } + + itemPO.setUseDefault(SalaryOnOffEnum.parseByDefaultLabel(config.getUseDefault()).getValue()); + itemPO.setHideDefault(SalaryOnOffEnum.parseByDefaultLabel(config.getHideDefault()).getValue()); + itemPO.setRoundingMode(SalaryRoundingModeEnum.parseByDefaultLabel(config.getRoundingMode()).getValue()); + itemPO.setPattern(NumberUtil.isNumber(config.getPattern()) ? Integer.parseInt(config.getPattern()) : 2); + itemPO.setValueType(salaryValueTypeEnum.getValue()); + itemPO.setDataType(salaryDataTypeEnum.getValue()); + //后补 + itemPO.setFormulaId(0L); + itemPO.setDescription(config.getDescription()); + itemPO.setUpdateTime(now); + itemPO.setSortedIndex(NumberUtil.isNumber(config.getSortedIndex()) ? Integer.parseInt(config.getSortedIndex()) : null); + itemPO.setWidth(NumberUtil.isNumber(config.getWidth()) ? Integer.parseInt(config.getWidth()) : null); + itemPO.setDefaultValue(config.getDefaultValue()); + updates.add(itemPO); + } + + //解析公式 + if (salaryValueTypeEnum == SalaryValueTypeEnum.FORMULA || salaryValueTypeEnum == SalaryValueTypeEnum.SQL) { + Long id = itemPO.getId(); + String formula = config.getFormula(); + String sqlReturnKey = config.getExtendParam(); + Map map = new HashMap<>(); + map.put("rowIndex", rowIndex); + map.put("formula", formula); + map.put("sqlReturnKey", sqlReturnKey); + formulaItems.put(id, map); + } + } + + adds.forEach(getSalaryItemMapper()::insertIgnoreNull); + updates.forEach(getSalaryItemMapper()::updateIgnoreNull); + + for (Long id : formulaItems.keySet()) { + SalaryItemPO itemPO = getById(id); + Map map = formulaItems.get(id); + String rowIndex = map.get("rowIndex"); + String formula = map.get("formula"); + String sqlReturnKey = map.get("sqlReturnKey"); + SalaryValueTypeEnum salaryValueTypeEnum = SalaryValueTypeEnum.parseByValue(itemPO.getValueType()); + SalaryDataTypeEnum salaryDataTypeEnum = SalaryDataTypeEnum.parseByValue(itemPO.getDataType()); + SalaryFormulaSaveParam saveParam = SalaryFormulaSaveParam.builder() + .name(itemPO.getName()) + .module("salary") + .useFor("salaryitem") + .referenceType(salaryValueTypeEnum == SalaryValueTypeEnum.FORMULA ? ReferenceTypeEnum.FORMULA.getValue() : ReferenceTypeEnum.SQL.getValue()) + .returnType(salaryDataTypeEnum == SalaryDataTypeEnum.STRING ? ReturnTypeEnum.STRING.getValue() : ReturnTypeEnum.NUMBER.getValue()) + .validateType(salaryDataTypeEnum == SalaryDataTypeEnum.STRING ? ReturnTypeEnum.STRING.getValue() : ReturnTypeEnum.NUMBER.getValue()) + .extendParam("{\"isCustomFunction\":\"0\",\"sqlReturnKey\":\"" + sqlReturnKey + "\",\"openDecrypt\":\"0\",\"datasource\":{\"datasourceId\":\"\"}}") + .formula(formula) + .build(); + + try { + FormulaPO formulaPO = getSalaryFormulaService(user).save(saveParam); + itemPO.setFormulaId(formulaPO.getId()); + getSalaryItemMapper().updateIgnoreNull(itemPO); + } catch (Exception e) { + ImportExcelResponse.Error error = ImportExcelResponse.Error.builder().message(String.format("%s“%s”的公式设置有误:%s", rowIndex, itemPO.getName(), e.getMessage())).build(); + response.setSuccessCount(response.getSuccessCount() - 1); + response.setErrorCount(response.getErrorCount() + 1); + response.getErrorData().add(error); + } + } + return response; + } finally { + IOUtils.closeQuietly(fileInputStream); + } + } + + @Override + public XSSFWorkbook export(SalaryItemExportParam param) { + + List titles = Lists.newArrayList(); + List dataIndexList = Lists.newArrayList(); + ExcelUtil.parseHeader(SalaryItemExcelConfig.class, titles, dataIndexList); + + List configs = getConfig(param); + + List> rows = new ArrayList<>(); + rows.add(titles); + configs.forEach(e -> { + List row = new ArrayList<>(); + row.add(e.getName()); + row.add(e.getUseDefault() == null ? "否" : SalaryOnOffEnum.parseByValue(Integer.parseInt(e.getUseDefault())).getDefaultLabel()); + row.add(e.getHideDefault() == null ? "否" : SalaryOnOffEnum.parseByValue(Integer.parseInt(e.getHideDefault())).getDefaultLabel()); + row.add(SalaryDataTypeEnum.parseByValue(Util.null2String(e.getDataType())).getDefaultLabel()); + row.add(e.getRoundingMode() == null ? "四舍五入" : SalaryRoundingModeEnum.parseByValue(Integer.parseInt(e.getRoundingMode())).getDefaultLabel()); + row.add(e.getPattern() == null ? "2" : e.getPattern()); + row.add(e.getValueType() == null ? "输入" : SalaryValueTypeEnum.parseByValue(Integer.parseInt(e.getValueType())).getDefaultLabel()); + row.add(e.getFormula() == null ? "" : e.getFormula()); + String sqlReturnKey = ""; + if (e.getExtendParam() != null) { + sqlReturnKey = JsonUtil.parseMap(Util.null2String(e.getExtendParam()), String.class).getOrDefault("sqlReturnKey", ""); + if ("null".equals(sqlReturnKey)) { + sqlReturnKey = ""; + } + } + row.add(sqlReturnKey); + row.add(e.getSortedIndex() == null ? "" : e.getSortedIndex()); + row.add(e.getWidth() == null ? "" : e.getWidth()); + row.add(e.getDefaultValue() == null ? "" : e.getDefaultValue()); + row.add(e.getDescription() == null ? "" : e.getDescription()); + rows.add(row); + }); + + return ExcelUtil.genWorkbookV2(rows, "薪资项目"); + } + + @Override + public XSSFWorkbook downloadTemplate(SalaryItemDownloadTemplateParam param) { + List titles = Lists.newArrayList(); + List dataIndexList = Lists.newArrayList(); + ExcelUtil.parseHeader(SalaryItemExcelConfig.class, titles, dataIndexList); + + + List> rows = new ArrayList<>(); + rows.add(titles); + if (param.isHasData()) { + List configs = getConfig(SalaryItemExportParam.builder().build()); + configs.forEach(e -> { + List row = new ArrayList<>(); + row.add(e.getName()); + row.add(e.getUseDefault() == null ? "否" : SalaryOnOffEnum.parseByValue(Integer.parseInt(e.getUseDefault())).getDefaultLabel()); + row.add(e.getHideDefault() == null ? "否" : SalaryOnOffEnum.parseByValue(Integer.parseInt(e.getHideDefault())).getDefaultLabel()); + row.add(SalaryDataTypeEnum.parseByValue(Util.null2String(e.getDataType())).getDefaultLabel()); + row.add(e.getRoundingMode() == null ? "四舍五入" : SalaryRoundingModeEnum.parseByValue(Integer.parseInt(e.getRoundingMode())).getDefaultLabel()); + row.add(e.getPattern() == null ? "2" : e.getPattern()); + row.add(e.getValueType() == null ? "输入" : SalaryValueTypeEnum.parseByValue(Integer.parseInt(e.getValueType())).getDefaultLabel()); + row.add(e.getFormula() == null ? "" : e.getFormula()); + String sqlReturnKey = ""; + if (e.getExtendParam() != null) { + sqlReturnKey = JsonUtil.parseMap(Util.null2String(e.getExtendParam()), String.class).getOrDefault("sqlReturnKey", ""); + if ("null".equals(sqlReturnKey)) { + sqlReturnKey = ""; + } + } + row.add(sqlReturnKey); + row.add(e.getSortedIndex() == null ? "" : e.getSortedIndex()); + row.add(e.getWidth() == null ? "" : e.getWidth()); + row.add(e.getDefaultValue() == null ? "" : e.getDefaultValue()); + row.add(e.getDescription() == null ? "" : e.getDescription()); + rows.add(row); + }); + } + return ExcelUtil.genWorkbookV2(rows, "薪资项目"); + } + + @Override + public SalaryItemAllConfig getConfig() { + List salaryItemPOList = listByParam(SalaryItemSearchParam.builder().useInEmployeeSalary(0).build()); + List formulaPOS = getSalaryFormulaService(user).listAll(); + Map formulaMap = SalaryEntityUtil.convert2Map(formulaPOS, FormulaPO::getId); + List formulaVars = getSalaryFormulaService(user).listAllVar(); + Map> varListMap = SalaryEntityUtil.group2Map(formulaVars, FormulaVar::getFormulaId); + + salaryItemPOList.forEach(itemPO -> { + if (itemPO.getFormulaId() != null) { + FormulaPO formulaPO = formulaMap.get(itemPO.getFormulaId()); + if (formulaPO != null) { + formulaPO.setFormulaVars(varListMap.get(itemPO.getFormulaId())); + itemPO.setFormula(formulaPO); + } + } + }); + + return SalaryItemAllConfig.builder().salaryItems(salaryItemPOList).build(); + } + + @Override + public UploadConfigResponse.Result parseConfig(SalaryItemAllConfig salaryItemConfig) { + UploadConfigResponse.Result result = UploadConfigResponse.Result.builder() + .message("薪资项目加载完毕") + .success(new ArrayList<>()) + .warning(new ArrayList<>()) + .error(new ArrayList<>()) + .build(); + List salaryItemPOList = listAll(); + Map nameMap = SalaryEntityUtil.convert2Map(salaryItemPOList, SalaryItemPO::getName); + Map codeMap = SalaryEntityUtil.convert2Map(salaryItemPOList, SalaryItemPO::getCode); + + Optional.ofNullable(salaryItemConfig.getSalaryItems()) + .orElse(new ArrayList<>()) + .forEach(itemPO -> { + try { + add(itemPO, nameMap, codeMap, result); + } catch (Exception e) { + log.error("{}项目加载异常,", itemPO.getName(), e); + result.getError().add(String.format("错误,薪资项目[%s]加载异常,%s", itemPO.getName(), e.getMessage())); + } + }); + return result; + } + + @Override + public SalaryItemPO getItem(SalaryItemPO salaryItemPO) { + SalaryItemPO po = getByName(salaryItemPO.getName()); + if (po == null) { + po = getSalaryItemMapper().getByCode(salaryItemPO.getCode()); + } + return po; + } + + + private Long add(SalaryItemPO itemPO, Map nameMap, Map codeMap, UploadConfigResponse.Result result) { + long uid = user.getUID(); + Long formulaId = getSalaryFormulaService(user).add(itemPO.getFormula()); + itemPO.setFormulaId(formulaId); + + if (nameMap.containsKey(itemPO.getName())) { + SalaryItemPO salaryItemPO = nameMap.get(itemPO.getName()); + if (!StrUtil.equals(salaryItemPO.getCode(), itemPO.getCode())) { + result.getWarning().add(String.format("警告,薪资项目[%s]名称已存在,但项目code不一致,迁入code:%s,当前系统code:%s", itemPO.getName(), itemPO.getCode(), salaryItemPO.getCode())); + } + itemPO.setId(salaryItemPO.getId()); + //不许修改code + itemPO.setCode(null); + itemPO.setCreator(uid); + getSalaryItemMapper().updateIgnoreNull(itemPO); + } else if (codeMap.containsKey(itemPO.getCode())) { + SalaryItemPO salaryItemPO = codeMap.get(itemPO.getCode()); + if (!StrUtil.equals(salaryItemPO.getName(), itemPO.getName())) { + result.getWarning().add(String.format("警告,薪资项目[%s]code已存在,但项目code不一致,迁入名称:%s,当前系统名称:%s", itemPO.getName(), itemPO.getName(), salaryItemPO.getName())); + } + itemPO.setId(salaryItemPO.getId()); + //不许修改名字 + itemPO.setName(null); + itemPO.setCreator(uid); + getSalaryItemMapper().updateIgnoreNull(itemPO); + } else { + itemPO.setId(IdGenerator.generate()); + getSalaryItemMapper().insertIgnoreNull(itemPO); + } + result.getSuccess().add(String.format("成功,薪资项目[%s]加载成功", itemPO.getName())); + + return itemPO.getId(); + } +} diff --git a/src/com/engine/salary/service/impl/SalarySendRangeObjServiceImpl.java b/src/com/engine/salary/service/impl/SalarySendRangeObjServiceImpl.java new file mode 100644 index 000000000..0bb50b5be --- /dev/null +++ b/src/com/engine/salary/service/impl/SalarySendRangeObjServiceImpl.java @@ -0,0 +1,106 @@ +package com.engine.salary.service.impl; + +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.hrm.service.RolesMembersService; +import com.engine.hrm.service.impl.RolesMembersServiceImpl; +import com.engine.salary.biz.SalarySendRangeObjBiz; +import com.engine.salary.entity.salaryBill.bo.SalarySendRangeBO; +import com.engine.salary.entity.salaryBill.dto.SalarySendInfoListDTO; +import com.engine.salary.entity.salaryBill.dto.SalarySendUserInfoDTO; +import com.engine.salary.entity.salaryBill.po.SalarySendRangeObj; +import com.engine.salary.enums.salarysend.SalarySendRangeTargetTypeEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.service.SalarySendRangeObjService; +import com.engine.salary.service.SalarySendService; +import com.engine.salary.service.SalarySobService; +import org.apache.commons.collections4.CollectionUtils; + +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; + +import static com.engine.salary.constant.SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY; + +public class SalarySendRangeObjServiceImpl extends Service implements SalarySendRangeObjService { + + private SalarySendService getSalarySendService() { + return ServiceUtil.getService(SalarySendServiceImpl.class, user); + } + + private RolesMembersService getRolesMembersService() { + return ServiceUtil.getService(RolesMembersServiceImpl.class, user); + } + + private SalarySobService getSalarySobService() { + return ServiceUtil.getService(SalarySobServiceImpl.class, user); + } + + private final SalarySendRangeObjBiz salarySendRangeObjBiz = new SalarySendRangeObjBiz(); + + @Override + public List listBySalarySendIdAndRangeIds(Long salarySendId, List rangeIds) { + if (salarySendId == null || CollectionUtils.isEmpty(rangeIds)) { + return Collections.emptyList(); + } + return salarySendRangeObjBiz.applyMapper(mapper -> + mapper.listBySalarySendIdAndRangeIds(salarySendId, rangeIds, DEFAULT_TENANT_KEY) + ); + } + + @Override + public void deleteBySalarySendIds(Collection salarySendIds) { + salarySendRangeObjBiz.runMapper(mapper -> mapper.deleteBySalarySendIds(salarySendIds)); + } + + @Override + public void replaceAllByRangeIds(Long rangeIds, List rangeObjs) { + for (SalarySendRangeObj rangeObj : rangeObjs) { + SalarySendRangeTargetTypeEnum targetEnum = SalarySendRangeTargetTypeEnum.fromValue(rangeObj.getTargetType()); + if (targetEnum == null) { + throw new SalaryRunTimeException("传入范围类型非法"); + } + if (rangeObj.getTargetType().equals(SalarySendRangeTargetTypeEnum.ALL.getValue())) { + rangeObj.setTargetId(0L); + } + } + salarySendRangeObjBiz.replaceAllByRangeId(rangeIds, rangeObjs); + } + + @Override + public List getSendInfoIdsBySalarySendIdAndRangeIds(Long salarySendId, List rangeIds) { + // 获取范围 + List rangeList = + salarySendRangeObjBiz.applyMapper(mapper -> mapper.listBySalarySendIdAndRangeIds(salarySendId, rangeIds, DEFAULT_TENANT_KEY)); + + // 初始化范围操作类 + SalarySendRangeBO rangeBO = new SalarySendRangeBO(); + for (SalarySendRangeObj rangeObj : rangeList) { + rangeBO.putNew(rangeObj); + } + // 获取当前发放单人员详情 + List sendInfoList = getSalarySendService().salarySendInfoList(salarySendId); + // 获取全部人员id + List employeeIds = sendInfoList.stream().map(SalarySendInfoListDTO::getEmployeeId) + .distinct().collect(Collectors.toList()); + // 查找人员的多维度关联id + List userInfos = + salarySendRangeObjBiz.getSalarySendUserInfoDTOs(employeeIds); + // 筛选在范围中的人员id + Set empIds = userInfos.stream() + .filter(rangeBO::judgeInRange) + .map(SalarySendUserInfoDTO::getResourceId) + .distinct().collect(Collectors.toSet()); + // 返回发放详情的id + return sendInfoList.stream().filter(s -> empIds.contains(s.getEmployeeId())) + .map(SalarySendInfoListDTO::getId) + .collect(Collectors.toList()); + } + + @Override + public void deleteBySalarySendRangeIds(List salarySendRangeIds) { + salarySendRangeObjBiz.runMapper(mapper -> mapper.deleteByRangeIds(salarySendRangeIds, DEFAULT_TENANT_KEY)); + } +} diff --git a/src/com/engine/salary/service/impl/SalarySendRangeServiceImpl.java b/src/com/engine/salary/service/impl/SalarySendRangeServiceImpl.java new file mode 100644 index 000000000..040792296 --- /dev/null +++ b/src/com/engine/salary/service/impl/SalarySendRangeServiceImpl.java @@ -0,0 +1,193 @@ +package com.engine.salary.service.impl; + +import cn.hutool.core.util.StrUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.hrm.DeptInfo; +import com.engine.salary.entity.hrm.PositionInfo; +import com.engine.salary.entity.hrm.SubCompanyInfo; +import com.engine.salary.entity.salaryBill.dto.SalarySendRangeListDTO; +import com.engine.salary.entity.salaryBill.dto.SalarySendRangeObjDTO; +import com.engine.salary.entity.salaryBill.param.SalarySendRangeQueryParam; +import com.engine.salary.entity.salaryBill.param.SalarySendRangeSaveParam; +import com.engine.salary.entity.salaryBill.po.SalarySendRangeObj; +import com.engine.salary.entity.salaryBill.po.SalarySendRangePO; +import com.engine.salary.enums.salarysend.SalarySendGrantTypeEnum; +import com.engine.salary.enums.salarysend.SalarySendRangeTargetTypeEnum; +import com.engine.salary.enums.salarysend.SalarySendRangeTypeEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.mapper.salarybill.SalarySendRangeMapper; +import com.engine.salary.service.SalaryEmployeeService; +import com.engine.salary.service.SalarySendRangeObjService; +import com.engine.salary.service.SalarySendRangeService; +import com.engine.salary.service.TaxAgentService; +import com.engine.salary.util.db.MapperProxyFactory; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.util.page.SalaryPageUtil; +import org.apache.ibatis.session.SqlSession; +import weaver.conn.mybatis.MyBatisFactory; + +import java.util.*; +import java.util.function.Consumer; +import java.util.function.Function; +import java.util.stream.Collectors; + +import static com.engine.salary.constant.SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY; + +public class SalarySendRangeServiceImpl extends Service implements SalarySendRangeService { + private SalaryEmployeeService getSalaryEmployeeService() { + return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user); + } + + private TaxAgentService getTaxAgentService() { + return ServiceUtil.getService(TaxAgentServiceImpl.class, user); + } + + + private R applyMapper(Function mapper) { + try (SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession()) { + final SalarySendRangeMapper salarySendRangeMapper = sqlSession.getMapper(SalarySendRangeMapper.class); + R apply = mapper.apply(salarySendRangeMapper); + sqlSession.commit(); + return apply; + } + } + + private void runMapper(Consumer mapper) { + try (SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession()) { + final SalarySendRangeMapper salarySendRangeMapper = sqlSession.getMapper(SalarySendRangeMapper.class); + mapper.accept(salarySendRangeMapper); + sqlSession.commit(); + } + } + + private SalarySendRangeObjService getSalarySendRangeObjService() { + return ServiceUtil.getService(SalarySendRangeObjServiceImpl.class, user); + } + + @Override + public void save(SalarySendRangeSaveParam param) { + if (user == null) { + throw new SalaryRunTimeException("您没有此操作的权限"); + } + SalarySendRangeSaveParam.checkParam(param, (long) user.getUID(), DEFAULT_TENANT_KEY); + SalarySendRangePO salarySendRangePO = param.toSalarySendRangePO(user); + + // 如果传入id, 则做查询后更新 + if (salarySendRangePO.getId() != null) { + SalarySendRangePO oldInfo = applyMapper(mapper -> mapper.selectByPrimaryKey(salarySendRangePO.getId())); + if (oldInfo == null) { + throw new SalaryRunTimeException("传入发放范围不存在"); + } + runMapper(mapper -> mapper.updateByPrimaryKeySelective(salarySendRangePO)); + } else { + runMapper(mapper -> mapper.insertSelective(salarySendRangePO)); + } + param.setSalarySendRangeId(salarySendRangePO.getId()); + + List rangeObjs = param.toSalarySendRangeObj(user); + getSalarySendRangeObjService().replaceAllByRangeIds(salarySendRangePO.getId(), rangeObjs); + } + + @Override + public PageInfo listPage(SalarySendRangeQueryParam queryParam) { + SalarySendRangeMapper mapper = MapperProxyFactory.getProxy(SalarySendRangeMapper.class); + List listDTOs = mapper.selectByParam(queryParam); + PageInfo page = new PageInfo<>(listDTOs, SalarySendRangeListDTO.class); + listDTOs = listDTOs.stream().map(s -> { + List rangeObjs = getSalarySendRangeObjService().listBySalarySendIdAndRangeIds(queryParam.getSalarySendId(), + Collections.singletonList(s.getId())); + Map> groupedMap = rangeObjs.stream() + .map(rangeObj -> { + SalarySendRangeTargetTypeEnum typeEnum = SalarySendRangeTargetTypeEnum.fromValue(rangeObj.getTargetType()); + if (typeEnum == null) { + return null; + } + String targetName = null; + switch (typeEnum) { + case USER: + DataCollectionEmployee employee = + getSalaryEmployeeService().getEmployeeById(rangeObj.getTargetId()); + targetName = Optional.ofNullable(employee) + .map(DataCollectionEmployee::getUsername) + .orElse(null); + break; + case DEPT: + targetName = getSalaryEmployeeService().getDeptInfoList(Collections.singletonList(rangeObj.getTargetId())) + .stream().findFirst() + .map(DeptInfo::getName).orElse(null); + break; + case SUB_COMPANY: + targetName = getSalaryEmployeeService().getSubCompanyInfoList(Collections.singletonList(rangeObj.getTargetId())) + .stream().findFirst() + .map(SubCompanyInfo::getName).orElse(null); + break; + case POSITION: + targetName = getSalaryEmployeeService().listPositionInfo(Collections.singletonList(rangeObj.getTargetId())) + .stream().findFirst() + .map(PositionInfo::getName).orElse(null); + break; +// case TAX_AGENT: +// targetName = Optional.ofNullable(getTaxAgentService().getById(rangeObj.getTargetId())) +// .map(TaxAgentPO::getName).orElse(null); +// break; + } + return SalarySendRangeObjDTO.builder() + .targetType(rangeObj.getTargetType()) + .targetTypeName(typeEnum.getDefaultLabel()) + .targetName(targetName) + .rangeType(rangeObj.getRangeType()) + .targetId(rangeObj.getTargetId()) + .build(); + }).filter(Objects::nonNull) + .collect(Collectors.groupingBy(SalarySendRangeObjDTO::getRangeType)); + //如果有查询,则做筛选 + if (StrUtil.isNotEmpty(queryParam.getTargetName())) { + boolean nameLike = false; + for (List value : groupedMap.values()) { + nameLike |= value.stream() + .anyMatch(item -> Optional.ofNullable(item.getTargetName()).orElse("") + .contains(queryParam.getTargetName())); + } + if (!nameLike) { + return null; + } + } + s.setIncludeObj(groupedMap.getOrDefault(SalarySendRangeTypeEnum.INCLUDE_OBJ.getValue(), Collections.emptyList())); + s.setExcludeObj(groupedMap.getOrDefault(SalarySendRangeTypeEnum.EXCLUDE_OBJ.getValue(), Collections.emptyList())); + return s; + }).filter(Objects::nonNull) + .collect(Collectors.toList()); + page.setTotal(listDTOs.size()); + List list = SalaryPageUtil.subList(queryParam.getCurrent(), queryParam.getPageSize(), listDTOs); + page.setList(list); + return page; + } + + @Override + public void deleteBySalarySendIds(Collection sendIds) { + + } + + @Override + public void deleteByIds(List sendRangeIds) { + runMapper(mapper -> { + for (Long sendRangeId : sendRangeIds) { + mapper.deleteByPrimaryKey(sendRangeId); + } + }); + getSalarySendRangeObjService().deleteBySalarySendRangeIds(sendRangeIds); + } + + @Override + public List getSendInfoIdsBySendId(Long sendId, List sendRangeIds, SalarySendGrantTypeEnum grantType) { + List rangeIdList = + applyMapper(mapper -> mapper.selectIdsBySendIdAndGrantType(sendId, grantType.getValue())); + + rangeIdList = rangeIdList.stream() + .filter(sendRangeIds::contains) + .collect(Collectors.toList()); + return getSalarySendRangeObjService().getSendInfoIdsBySalarySendIdAndRangeIds(sendId, rangeIdList); + } +} diff --git a/src/com/engine/salary/service/impl/SalarySendServiceImpl.java b/src/com/engine/salary/service/impl/SalarySendServiceImpl.java new file mode 100644 index 000000000..36865119c --- /dev/null +++ b/src/com/engine/salary/service/impl/SalarySendServiceImpl.java @@ -0,0 +1,2008 @@ +package com.engine.salary.service.impl; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.lang.Validator; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.api.formmode.mybatis.util.SqlProxyHandle; +import com.cloudstore.dev.api.bean.MessageBean; +import com.cloudstore.dev.api.bean.MessageType; +import com.cloudstore.dev.api.util.Util_Message; +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.hrmelog.entity.dto.LoggerContext; +import com.engine.salary.biz.SalarySendBiz; +import com.engine.salary.biz.SalarySendInfoBiz; +import com.engine.salary.config.SalaryElogConfig; +import com.engine.salary.constant.SalaryArchiveConstant; +import com.engine.salary.constant.SalaryItemConstant; +import com.engine.salary.constant.SalaryTemplateSalaryItemSetGroupConstant; +import com.engine.salary.encrypt.AESEncryptUtil; +import com.engine.salary.encrypt.EncryptUtil; +import com.engine.salary.entity.datacollection.AddUpSituation; +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.salaryBill.bo.SalaryBillBO; +import com.engine.salary.entity.salaryBill.dto.*; +import com.engine.salary.entity.salaryBill.param.*; +import com.engine.salary.entity.salaryBill.po.SalarySendInfoPO; +import com.engine.salary.entity.salaryBill.po.SalarySendPO; +import com.engine.salary.entity.salaryBill.po.SalaryTemplatePO; +import com.engine.salary.entity.salaryacct.bo.SalaryAcctEmployeeBO; +import com.engine.salary.entity.salaryacct.bo.SalaryAcctFormulaBO; +import com.engine.salary.entity.salaryacct.bo.SalaryAcctResultBO; +import com.engine.salary.entity.salaryacct.param.SalaryAcctResultQueryParam; +import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO; +import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO; +import com.engine.salary.entity.salaryacct.po.SalaryAcctResultPO; +import com.engine.salary.entity.salaryformula.dto.SalaryFormulaEmployeeDTO; +import com.engine.salary.entity.salaryitem.po.SalaryItemPO; +import com.engine.salary.entity.salarysob.dto.SalarySobCycleDTO; +import com.engine.salary.entity.salarysob.po.SalarySobBackItemPO; +import com.engine.salary.entity.salarysob.po.SalarySobItemPO; +import com.engine.salary.entity.salarysob.po.SalarySobPO; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import com.engine.salary.enums.AccountTypeEnum; +import com.engine.salary.enums.OperateTypeEnum; +import com.engine.salary.enums.UserStatusEnum; +import com.engine.salary.enums.salaryaccounting.SalaryAcctRecordStatusEnum; +import com.engine.salary.enums.salaryarchive.SalaryArchiveFieldTypeEnum; +import com.engine.salary.enums.salarybill.*; +import com.engine.salary.enums.salaryitem.SalaryDataTypeEnum; +import com.engine.salary.enums.salarysend.SalarySendGrantTypeEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.mapper.SQLMapper; +import com.engine.salary.mapper.salaryacct.SalaryAcctEmployeeMapper; +import com.engine.salary.mapper.salaryacct.SalaryAcctRecordMapper; +import com.engine.salary.mapper.salaryacct.SalaryAcctResultMapper; +import com.engine.salary.mapper.salarybill.SalarySendInfoMapper; +import com.engine.salary.mapper.salarybill.SalarySendMapper; +import com.engine.salary.report.common.constant.SalaryConstant; +import com.engine.salary.service.*; +import com.engine.salary.service.auth.AuthService; +import com.engine.salary.service.auth.AuthServiceImpl; +import com.engine.salary.sys.entity.vo.OrderRuleVO; +import com.engine.salary.sys.service.SalarySysConfService; +import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl; +import com.engine.salary.util.JsonUtil; +import com.engine.salary.util.SalaryDateUtil; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.db.IdGenerator; +import com.engine.salary.util.db.MapperProxyFactory; +import com.engine.salary.util.excel.ExcelUtil; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.util.page.SalaryPageUtil; +import com.google.common.collect.Lists; +import org.apache.commons.beanutils.BeanUtils; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.math.NumberUtils; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import weaver.common.MessageUtil; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.hrm.company.SubCompanyComInfo; +import weaver.hrm.resource.ResourceComInfo; + +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.math.BigDecimal; +import java.text.SimpleDateFormat; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.ZoneOffset; +import java.util.*; +import java.util.stream.Collectors; + +import static com.engine.salary.cache.SalaryCacheKey.SALARY_CACHE_SMS_CODE; +import static com.engine.salary.constant.HrmSalaryPayrollConf.GEN_PDF; + +/** + * @Description: 工资单发放 + * @Author: wangxiangzhong + * @Date: 2021-12-11 11:28 + */ +public class SalarySendServiceImpl extends Service implements SalarySendService { + + private static final Logger log = LoggerFactory.getLogger(SalarySendServiceImpl.class); + + private EncryptUtil encryptUtil = new EncryptUtil(); + + private SalarySendBiz mapper = new SalarySendBiz(); + private SalarySendInfoBiz salarySendInfoMapper = new SalarySendInfoBiz(); + + private SalarySendRangeService getSalarySendRangeService(User user) { + return ServiceUtil.getService(SalarySendRangeServiceImpl.class, user); + } + + private ExtEmpService getExtEmpService(User user) { + return ServiceUtil.getService(ExtEmpServiceImpl.class, user); + } + + + private SalaryTemplateService getSalaryTemplateService(User user) { + return ServiceUtil.getService(SalaryTemplateServiceImpl.class, user); + } + + private SalarySendMapper getSalarySendMapper() { + return SqlProxyHandle.getProxy(SalarySendMapper.class); + } + + + private SalaryAcctRecordService getSalaryAcctRecordService(User user) { + return ServiceUtil.getService(SalaryAcctRecordServiceImpl.class, user); + } + + private SalaryAcctRecordMapper getSalaryAcctRecordMapper() { + return SqlProxyHandle.getProxy(SalaryAcctRecordMapper.class); + } + + private SalaryAcctEmployeeMapper getSalaryAcctEmployeeMapper() { + return SqlProxyHandle.getProxy(SalaryAcctEmployeeMapper.class); + } + + // + private SalaryAcctResultMapper getSalaryAcctResultMapper() { + return SqlProxyHandle.getProxy(SalaryAcctResultMapper.class); + } + + private TaxAgentService getTaxAgentService(User user) { + return ServiceUtil.getService(TaxAgentServiceImpl.class, user); + } + + private SalaryEmployeeService getSalaryEmployeeService(User user) { + return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user); + } + + private SalarySendInfoMapper getSalarySendInfoMapper() { + return SqlProxyHandle.getProxy(SalarySendInfoMapper.class); + } + + private SalarySysConfService getSalarySysConfService(User user) { + return ServiceUtil.getService(SalarySysConfServiceImpl.class, user); + } + + private SalarySobService getSalarySobService(User user) { + return ServiceUtil.getService(SalarySobServiceImpl.class, user); + } + + private SalaryItemService getSalaryItemService(User user) { + return ServiceUtil.getService(SalaryItemServiceImpl.class, user); + } + + private SalaryAcctEmployeeService getSalaryAcctEmployeeService(User user) { + return ServiceUtil.getService(SalaryAcctEmployeeServiceImpl.class, user); + } + + private SalaryAcctResultService getSalaryAcctResultService(User user) { + return ServiceUtil.getService(SalaryAcctResultServiceImpl.class, user); + } + + private SalarySobItemService getSalarySobItemService(User user) { + return ServiceUtil.getService(SalarySobItemServiceImpl.class, user); + } + + private SalarySobBackItemService getSalarySobBackItemService(User user) { + return ServiceUtil.getService(SalarySobBackItemServiceImpl.class, user); + } + + + private SalaryBillService getSalaryBillService(User user) { + return ServiceUtil.getService(SalaryBillServiceImpl.class, user); + } + + private SalaryCacheService getSalaryCacheService(User user) { + return ServiceUtil.getService(SalaryCacheServiceImpl.class, user); + } + + private SalaryBillBaseSetService getSalaryBillBaseSetService(User user) { + return ServiceUtil.getService(SalaryBillBaseSetServiceImpl.class, user); + } + + public AuthService getAuthService(User user) { + return ServiceUtil.getService(AuthServiceImpl.class, user); + } + + private SQLMapper getSQLMapper() { + return MapperProxyFactory.getProxy(SQLMapper.class); + } + + @Override + public SalarySendPO getById(Long salarySendId) { + return mapper.getById(salarySendId); + } + + @Override + public List findReAccountingIdsByAcctIds(List salaryAccountingIds, String tenantKey) { + // 校验salaryAccountingId + if (CollectionUtils.isEmpty(salaryAccountingIds)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100497, "核算id必传")); + } + +// List salarySends = new LambdaQueryChainWrapper<>(mapper) +// .eq(SalarySendPO::getDeleteType, 0) +// .eq(SalarySendPO::getSendNum, 0) +// .in(SalarySendPO::getSalaryAccountingId, salaryAccountingIds) +// .list(); + + Map condition = new HashMap<>(); + condition.put("deleteType", 0); + condition.put("sendNum", 0); + condition.put("salaryAccountingIds", salaryAccountingIds); + List salarySends = mapper.listSomeWithCondition(condition); + + return salarySends.stream().map(SalarySendPO::getSalaryAccountingId).collect(Collectors.toList()); + } + + @Override + public String generateSalaryBill(Long salaryAccountingId) { + // 校验salaryAccountingId + if (salaryAccountingId == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100497, "核算id必传")); + } + + SalaryAcctRecordPO recordPo = new SalaryAcctRecordPO(); + recordPo.setDeleteType(0); + recordPo.setId(salaryAccountingId); + recordPo.setStatus(SalaryAcctRecordStatusEnum.ARCHIVED.getValue()); + List acctRecords = getSalaryAcctRecordMapper().listSome(recordPo); + // 检查核算的归档记录 + if (CollectionUtils.isEmpty(acctRecords)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100498, "核算记录不存在")); + } + + + List salaryAcctEmployees = getSalaryAcctEmployeeService(user).listBySalaryAcctRecordIds(Collections.singletonList(salaryAccountingId)); +// // 根据人员id去重 +// salaryAcctEmployees = salaryAcctEmployees.stream() +// .collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(SalaryAcctEmployeePO::getEmployeeId))), ArrayList::new)); + + // 1.回算:如果是回算,todo 要等原始核算发完或者上一个回算记录发完才行,目前最多只有一个回算记录 + if (Objects.equals(acctRecords.get(0).getBackCalcStatus(), (NumberUtils.INTEGER_ONE))) { + SalarySendPO sendPO = new SalarySendPO(); + sendPO.setDeleteType(0); + sendPO.setSalaryAccountingId(salaryAccountingId); + List salarySends = mapper.listSome(sendPO); + if (CollectionUtils.isEmpty(salarySends)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(139700, "还没有正常核算,不能进行回算")); + } + // todo 一般只有一个未冻结,同一个原始核算id,后面如果有多级回算,就会换成不同核算id + SalarySendPO salarySend = salarySends.stream().filter(s -> s.getSendStatus().equals(NumberUtils.INTEGER_ZERO)).findFirst().orElse(null); + + // 根据工资单补发模板规则过滤人员,已发补发的合计项目不等于0的进行过滤 + SalarySobPO salarySob = getSalarySobService(user).getById(acctRecords.get(0).getSalarySobId()); + List salaryTemplates = getSalaryTemplateService(user) + .getDefaultTemplates(Arrays.asList(acctRecords.get(0).getSalarySobId(), salarySob == null ? 0L : salarySob.getId())); + // 如果有默认模板,且规则不是全部 + if (CollectionUtils.isNotEmpty(salaryTemplates) && StringUtils.isEmpty(salaryTemplates.get(0).getReplenishRule())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(140649, "请维护补发工资单模板信息")); + } + Long backCalcItemId = + CollectionUtils.isNotEmpty(salaryTemplates) && !SalaryTemplateReplenishRuleEnum.ALL.getValue().equals(salaryTemplates.get(0).getReplenishRule()) ? Long + .parseLong(salaryTemplates.get(0).getReplenishRule()) : 0L; + SalaryItemPO salaryItem = getSalaryItemService(user).getById(backCalcItemId); + if (salaryItem != null && salaryItem.getDataType().equals(SalaryArchiveFieldTypeEnum.NUMBER.getValue())) { + // 目前是单个薪资项目 + List salaryAcctResultValues = getSalaryAcctResultService(user).listBySalaryAcctRecordIdsAndSalaryItemIds(Collections.singleton(salaryAccountingId), Collections.singleton(backCalcItemId)); + Set salaryAcctEmployeeIds = salaryAcctResultValues.stream() + .filter(salaryAcctResultPO -> SalaryEntityUtil.empty2Zero(salaryAcctResultPO.getResultValue()).compareTo(BigDecimal.ZERO) + != 0) + .map(SalaryAcctResultPO::getSalaryAcctEmpId) + .collect(Collectors.toSet()); + salaryAcctEmployees = salaryAcctEmployees.stream().filter(se -> salaryAcctEmployeeIds.contains(se.getId())).collect(Collectors.toList()); + } + + // 将未冻结的给冻结掉 + if (salarySend != null) { + salarySend.setSendStatus(NumberUtils.INTEGER_ONE); + mapper.updateById(salarySend); + } + // 2.正常核算 + } else { + SalarySendPO sendPO = new SalarySendPO(); + sendPO.setDeleteType(0); + sendPO.setSalaryAccountingId(salaryAccountingId); + List salarySends = mapper.listSome(sendPO); + if (CollectionUtils.isNotEmpty(salarySends)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100499, "工资单已生成过,不可再重复生成")); + } + } + + + Long salarySendId = IdGenerator.generate(); + SalaryAcctRecordPO salaryAcctRecord = acctRecords.get(0); + // 工资单模板类型:0,正常核算,1是回算,todo 后续可能还有别的算,需要改这里 + Integer templateType = salaryAcctRecord.getBackCalcStatus(); + + // 构建工资单发放数据 + List salarySendInfos = salaryAcctEmployees.stream().map(m -> + SalarySendInfoPO.builder() + .id(IdGenerator.generate()) + .salarySendId(salarySendId) + .employeeId(m.getEmployeeId()) + .employeeType(m.getEmployeeType()) + .salaryMonth(m.getSalaryMonth()) + .taxAgentId(m.getTaxAgentId()) + .salaryAcctRecordId(m.getSalaryAcctRecordId()) + .sendStatus(SalarySendStatusEnum.UNSEND.getValue()) + .salaryTemplate("") + .salaryAcctType(templateType) + .creator((long) user.getUID()) + .createTime(new Date()) + .updateTime(new Date()) + .build() + ).collect(Collectors.toList()); + + SalarySendPO salarySend = SalarySendPO.builder() + .id(salarySendId) + .salaryMonth(salaryAcctRecord.getSalaryMonth()) + .salaryAccountingId(salaryAccountingId) + .salarySobId(salaryAcctRecord.getSalarySobId()) + .sendNum(0) + .sendTotal(salarySendInfos.size()) + .sendStatus(NumberUtils.INTEGER_ZERO) // 未冻结 + .salaryAcctType(templateType) + .lastSendTime(new Date()) + .creator((long) user.getUID()) + .createTime(new Date()) + .updateTime(new Date()) + .build(); + // 插入工资单发放记录 + mapper.insert(salarySend); + // 插入工资单人员记录 + salarySendInfoMapper.batchInsert(salarySendInfos); + + return ""; + } + + @Override + public void revokeSalaryBill(SalaryAcctRecordPO salaryAcctRecord) { + // 校验salaryAccountingId +// if (salaryAcctRecord == null) { +// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100497, "核算id必传")); +// } +// +// SalaryAcctRecordPO po = SalaryAcctRecordPO.builder().id(salaryAccountingId).build(); +// List acctRecords = getSalaryAcctRecordMapper().listSome(po); + // 检查核算的归档记录 + if (salaryAcctRecord == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100498, "核算记录不存在")); + } + + SalarySendPO build = SalarySendPO.builder().salaryAccountingId(salaryAcctRecord.getId()).deleteType(0).build(); + List salarySends = getSalarySendMapper().listSome(build); + if (CollectionUtils.isEmpty(salarySends)) { + return; +// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100505, "工资单不存在")); + } + + SalarySendPO salarySend; + if (salaryAcctRecord.getBackCalcStatus() != null && salaryAcctRecord.getBackCalcStatus().equals(NumberUtils.INTEGER_ONE)) { + // todo 一般只有一个未冻结,同一个原始核算id,后面如果有多级回算,就会换成不同核算id + salarySend = salarySends.stream().filter(s -> s.getSendStatus().equals(NumberUtils.INTEGER_ZERO)).findFirst().orElse(null); +// if (salarySend != null && salarySend.getSendNum() < salarySend.getSendTotal()) { +// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(139702, "正常原始核算或上一个回算尚未全部发送完成,不能进行撤回")); +// } + if (salarySend != null) { + // 将上一版本未冻结的给冻结掉 + salarySend.setSendStatus(NumberUtils.INTEGER_ONE); + getSalarySendMapper().updateIgnoreNull(salarySend); + } + // 已经回算的删除 todo 以后多级回算注意要修改 + salarySend = salarySends.stream().filter(s -> s.getSalaryAcctType() != null && s.getSalaryAcctType().equals(NumberUtils.INTEGER_ONE)).findFirst().orElse(null); + handleDelSalaryBill(salarySend); + // 2.正常核算处理 + } else { + salarySend = salarySends.stream().filter(s -> s.getSendStatus().equals(NumberUtils.INTEGER_ZERO)).findFirst().orElse(null); + handleDelSalaryBill(salarySend); + } + } + + + private void handleDelSalaryBill(SalarySendPO salarySend) { + if (salarySend == null) { + return; + } + // 已发送工资单 + SalarySendInfoPO sendInfo = SalarySendInfoPO.builder() + .deleteType(0) + .salarySendId(salarySend.getId()) + .sendStatus(SalarySendStatusEnum.ALREADYSEND.getValue()) + .salaryAcctType(NumberUtils.INTEGER_ZERO).build(); + List salarySendInfos = getSalarySendInfoMapper().listSome(sendInfo); + if ((salarySend.getSendNum() > 0 || CollectionUtils.isNotEmpty(salarySendInfos)) && Objects.equals(salarySend.getSalaryAcctType(), NumberUtils.INTEGER_ONE)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100507, "补发工资单已经发放,不可进行回算")); + } else if (salarySend.getSendNum() > 0 || CollectionUtils.isNotEmpty(salarySendInfos)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100507, "工资单已经发放,不可撤销,可以进行回算")); + } + // 删除工资单 + SalarySendPO salarySendPO = SalarySendPO.builder() + .id(salarySend.getId()) + .sendNum(0) + .deleteType(1) + .build(); + getSalarySendMapper().updateIgnoreNull(salarySendPO); + // 删除工资单发放 + SalarySendInfoPO infoPO = SalarySendInfoPO.builder() + .salarySendId(salarySend.getId()) + .deleteType(1) + .build(); + getSalarySendInfoMapper().updateGrantWithdraw(infoPO, salarySend.getId(), null, null); + + } + + @Override + public PageInfo listPage(SalarySendQueryParam queryParam) { + List list = mapper.list(queryParam); + PageInfo pageInfo = new PageInfo<>(list, SalarySendListDTO.class); + return pageInfo; + } + + @Override + public List list(SalarySendQueryParam queryParam) { + List list = mapper.list(queryParam); + return getAuthService(user).auth(list, queryParam.getFilterType(), SalarySendListDTO.class); + } + + @Override + public SalarySendBaseInfoDTO getBaseInfo(Long id) { + SalarySendPO salarySend = mapper.getById(id); + if (salarySend == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100512, "工资单发放不存在")); + } + Long salaryAcctId = salarySend.getSalaryAccountingId(); + SalarySobCycleDTO salarySobCycleDTO = getSalaryAcctRecordService(user).getSalarySobCycleById(salaryAcctId); + String template = ""; + // 获取默认模板 + List salaryTemplates = getSalaryTemplateService(user).getDefaultTemplates(Collections.singletonList(salarySend.getSalarySobId())); + if (CollectionUtils.isNotEmpty(salaryTemplates)) { + // 是否是回算 + if (Objects.equals(salarySend.getSalaryAcctType(), NumberUtils.INTEGER_ONE)) { + template = salaryTemplates.get(0).getReplenishName(); + } else { + template = salaryTemplates.get(0).getName(); + } + } + + Boolean canSend = true; + SalaryAcctRecordPO acctRecord = getSalaryAcctRecordService(user).getById(salaryAcctId); + // 回算过,但是查看的是普通工资单(不能发);回算过,但是查看的是回算工资单(可以发);记录没回算过(可以发) + if (Objects.equals(acctRecord.getBackCalcStatus(), NumberUtils.INTEGER_ONE) && Objects.equals(salarySend.getSalaryAcctType(), NumberUtils.INTEGER_ZERO)) { + canSend = false; + } + + return SalarySendBaseInfoDTO.builder() + .salaryMonth(salarySobCycleDTO.getSalaryMonth()) + .template(template) + .salarySobCycle(salarySobCycleDTO) + .sendNum(salarySend.getSendNum()) + .sendTotal(salarySend.getSendTotal()) + .canSend(canSend) + .showPdfBtn(GEN_PDF) +// .salaryAcctType(salarySend.getSalaryAcctType().toString()) +// .haveBackCalc(haveBackCalc ? NumberUtils.INTEGER_ONE : NumberUtils.INTEGER_ZERO) + .build(); + } + + @Override + public Map mySalaryBill(Long salaryInfoId, Long currentEmployeeId) { + if (salaryInfoId == null) { + throw new SalaryRunTimeException("工资单id为空!"); + } + + SalarySendInfoPO salarySendInfo = getSalarySendInfoMapper().getById(salaryInfoId); + if (salarySendInfo == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100511, "工资单信息不存在")); + } + Long employeeId = salarySendInfo.getEmployeeId(); + if (currentEmployeeId.compareTo(employeeId) != 0) { + + //主账号可以查看次账号工资单 + String sql = "select id from Hrmresource a where belongto= " + currentEmployeeId; + List belongtoIds = getSQLMapper().listLong(sql); + if (CollUtil.isNotEmpty(belongtoIds) && belongtoIds.contains(employeeId)) { + //切换user +// this.user = new User(new Integer(employeeId + "")); + } else { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100511, "当前账号无法查看此工资单")); + } + } + + // 获取默认模板信息 + SalarySendPO salarySendPO = getSalarySendMapper().getById(salarySendInfo.getSalarySendId()); + if (salarySendPO == null) { + throw new SalaryRunTimeException("工资单记录不存在"); + } + + //工资单查看时效性 + salaryBillViewingLimitSetting salaryBillViewingLimitSetting = getSalaryBillBaseSetService(user).getSalaryBillViewingLimitSetting(); + Date limitMonth = getLimitMonth(salaryBillViewingLimitSetting); + if (limitMonth != null) { + if (salaryBillViewingLimitSetting.getMonthType() == MonthTypeEnum.SALARY_DATE) { + if (limitMonth.after(salarySendInfo.getSalaryMonth())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100511, "仅能查看" + salaryBillViewingLimitSetting.getLimitMonth() + "月内的工资单")); + } + } else { + if (limitMonth.after(salarySendInfo.getSendTime())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100511, "仅能查看" + salaryBillViewingLimitSetting.getLimitMonth() + "月内的工资单")); + } + } + } + + // 获取、记录首次查看时间 + Date firstReadingTime = new Date(); + if (salarySendInfo.getFirstReadingTime() == null) { + salarySendInfo.setFirstReadingTime(firstReadingTime); + getSalarySendInfoMapper().updateIgnoreNull(salarySendInfo); + } else { + // 不是首次查看 + firstReadingTime = salarySendInfo.getFirstReadingTime(); + // 获取首次查看后多少分钟不能查看工资单(0代表一旦查看后无法再次查看,null代表不限制) + Integer burningAfterReadingMin = getSalaryBillBaseSetService(user).getBurningAfterReadingMin(); + if (burningAfterReadingMin != null) { + LocalDateTime limitTime = SalaryDateUtil.dateToLocalDateTime(firstReadingTime).plusMinutes(burningAfterReadingMin); + LocalDateTime now = SalaryDateUtil.dateToLocalDateTime(new Date()); + if (burningAfterReadingMin == 0) { + throw new SalaryRunTimeException("无法查看工资单,该工资单仅供查看一次。首次查看时间为:" + SalaryDateUtil.getFormatLocalDateTime(firstReadingTime)); + } else if (limitTime.isBefore(now)) { + throw new SalaryRunTimeException("首次查看工资单" + burningAfterReadingMin + "分钟后,无法查看工资单。首次查看时间为:" + SalaryDateUtil.getFormatLocalDateTime(firstReadingTime)); + } + } + } + + // 更新查看状态 + if (salarySendInfo.getBillReadStatus() == null || NumberUtils.compare(salarySendInfo.getBillReadStatus(), BillReadStatusEnum.UNREAD.getValue()) == 0) { + salarySendInfo.setBillReadStatus(BillReadStatusEnum.READED.getValue()); + salarySendInfo.setUpdateTime(new Date()); + getSalarySendInfoMapper().updateIgnoreNull(salarySendInfo); + } + + List salarySends = mapper.listSome(SalarySendPO.builder().id(salarySendInfo.getSalarySendId()).build()); + if (CollectionUtils.isEmpty(salarySends)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100512, "工资单发放不存在")); + } + SalarySendPO salarySend = salarySends.get(0); + Date salaryMonth = salarySend.getSalaryMonth(); + // 获取模板 + String salaryTemplateContent = salarySendInfo.getSalaryTemplate(); + if (StringUtils.isBlank(salaryTemplateContent)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100513, "没有默认模板,无法查看")); + } + + SalaryTemplatePO salaryTemplate = buildSalaryTemplateContent(salaryTemplateContent); + if (StringUtils.isNotBlank(salaryTemplate.getFeedbackUrl()) && StringUtils.isBlank(salaryTemplate.getMobileFeedbackUrl())) { + // 如果设置了pc反馈地址,没有设置移动端反馈地址,则移动端反馈地址默认等于pc反馈地址 + salaryTemplate.setMobileFeedbackUrl(salaryTemplate.getFeedbackUrl()); + } + // 判断是否是补发 + boolean isReplenish = NumberUtils.INTEGER_ONE.equals(salarySendInfo.getSalaryAcctType()); + +// if (StringUtils.isNotBlank(salaryTemplate.getBackground())) { +// FileData fileByte = fileDownloadClient.getFileByte(Long.valueOf(salaryTemplate.getBackground()), currentTenantKey); +// String encode = Base64Encoder.encode(fileByte.getData()); +// salaryTemplate.setBackground(encode); +// } + +// 获取薪资项目数据 + + Long salaryAcctRecordId = salarySendInfo.getSalaryAcctRecordId(); + SalaryAcctResultPO build = SalaryAcctResultPO.builder() + .salaryAcctRecordId(salaryAcctRecordId) + .taxAgentId(salarySendInfo.getTaxAgentId()) + .employeeId(employeeId) + .build(); + List salaryAcctResultPOS = getSalaryAcctResultMapper().listSome(build); + if (CollUtil.isEmpty(salaryAcctResultPOS)) { + throw new SalaryRunTimeException("薪资核算结果不存在!"); + } + encryptUtil.decryptList(salaryAcctResultPOS, SalaryAcctResultPO.class); + + SalaryAcctRecordPO salaryAcctRecordPO = getSalaryAcctRecordService(user).getById(salaryAcctRecordId); + if (salaryAcctRecordPO == null) { + throw new SalaryRunTimeException("薪资核算记录不存在!"); + } + List> salaryAcctResultS = null; + if (Objects.equals(salaryAcctRecordPO.getBackCalcStatus(), NumberUtils.INTEGER_ONE) && !isReplenish) { + // 该记录回算过,并且获取的不是回算后的工资单 + salaryAcctResultS = salaryAcctResultPOS.stream().map(m -> { + Map map = new LinkedHashMap<>(); + map.put("salaryItemId", m.getSalaryItemId()); + map.put("resultValue", m.getOriginResultValue()); + return map; + }).collect(Collectors.toList()); + } else { + salaryAcctResultS = salaryAcctResultPOS.stream().map(m -> { + Map map = new LinkedHashMap<>(); + map.put("salaryItemId", m.getSalaryItemId()); + map.put("resultValue", m.getResultValue()); + return map; + }).collect(Collectors.toList()); + } + + + Map map = new LinkedHashMap<>(); + map.put("tenantName", ""); + map.put("sendTime", SalaryDateUtil.getFormatLocalDateTime(salarySendInfo.getSendTime())); + List listDTOS = JSONArray.parseArray(isReplenish ? salaryTemplate.getReplenishSalaryItemSetting() : salaryTemplate.getSalaryItemSetting(), SalaryTemplateSalaryItemSetListDTO.class); + Optional optionalEmployeeInformation = listDTOS.stream().filter(e -> SalaryTemplateSalaryItemSetGroupConstant.EMPLOYEE_INFO_GROUP_ID.equals(e.getGroupId())).findFirst(); + SalaryTemplateSalaryItemSetListDTO employeeInformation = optionalEmployeeInformation.orElse(null); + List itemSetListDTOS = listDTOS.stream().filter(e -> !SalaryTemplateSalaryItemSetGroupConstant.EMPLOYEE_INFO_GROUP_ID.equals(e.getGroupId())).collect(Collectors.toList()); + List> finalSalaryAcctResultS = salaryAcctResultS; + itemSetListDTOS.stream().forEach(item -> { + item.getItems() + .forEach(e -> { + if (CollectionUtils.isEmpty(finalSalaryAcctResultS)) { + e.setSalaryItemValue(""); + } else { + Object o = finalSalaryAcctResultS.stream() + .filter(f -> f.get("salaryItemId") != null && String.valueOf(f.get("salaryItemId")).equals(e.getSalaryItemId())).findFirst() + .orElse(new HashMap<>()) + .get("resultValue"); + e.setSalaryItemValue(o == null ? "" : (String) o); + } + }); + }); + + + /** + * 过滤空 + */ + if (Objects.equals(1, salaryTemplate.getSalaryItemNullStatus())) { + for (SalaryTemplateSalaryItemSetListDTO itemSetListDTO : itemSetListDTOS) { + List items = itemSetListDTO.getItems(); + List collect = items.stream().filter(item -> StringUtils.isNotBlank(item.getSalaryItemValue())).collect(Collectors.toList()); + itemSetListDTO.setItems(collect); + } + } + + /** + * 过滤0 + */ + if (Objects.equals(1, salaryTemplate.getSalaryItemZeroStatus())) { + for (SalaryTemplateSalaryItemSetListDTO itemSetListDTO : itemSetListDTOS) { + List items = itemSetListDTO.getItems(); + List collect = items.stream() + .filter(item -> SalaryEntityUtil.string2BigDecimal(item.getSalaryItemValue()) == null + || BigDecimal.ZERO.compareTo(SalaryEntityUtil.string2BigDecimal(item.getSalaryItemValue())) != 0) + .collect(Collectors.toList()); + itemSetListDTO.setItems(collect); + } + } + + DataCollectionEmployee simpleEmployee = getSalaryEmployeeService(user).getEmployeeById(employeeId); + SalaryAcctEmployeePO acctEmployeePO = getSalaryAcctEmployeeService(user).getById(salaryAcctResultPOS.get(0).getSalaryAcctEmpId()); + SalaryAcctEmployeeBO.copyAcctEmp(simpleEmployee, acctEmployeePO); + TaxAgentPO taxAgentPO = getTaxAgentService(user).getById(acctEmployeePO.getTaxAgentId()); + buildEmployeeInfo(employeeInformation, simpleEmployee, taxAgentPO.getName(), SalaryAcctResultBO.buildEmployeeFieldName()); + map.put("employeeInformation", employeeInformation); + map.put("salaryGroups", itemSetListDTOS); + + salaryTemplate.setTheme(getBillTitle(salaryTemplate.getTheme(), salaryMonth, employeeId)); + // 工资单水印文本型动态变量 == 处理 + handleSalaryWatermark(salaryTemplate, salarySendInfo, employeeId); + map.put("salaryTemplate", salaryTemplate); + map.put("salaryAcctResult", salaryAcctResultS); + + // 工资单确认按钮 + if (NumberUtils.compare(salaryTemplate.getAckFeedbackStatus(), 1) == 0) { + // 开启了工资单确认 + Integer ackStatus = salarySendInfo.getBillConfirmStatus(); + if (ackStatus == null || ackStatus != BillConfimStatusEnum.CONFIRMED.getValue()) { + map.put("showAck", "1"); + } else { + map.put("showAck", "0"); + } + map.put("sendEmployeeId", salarySendInfo.getSendEmployeeId()); + } else { + map.put("showAck", "0"); + } + + + // 工资单反馈 + if (NumberUtils.compare(salaryTemplate.getFeedbackStatus(), 1) == 0) { + // 开启了工资单反馈按钮 + Integer confirmStatus = salarySendInfo.getBillConfirmStatus(); + map.put("showFeedback", "1"); + // 除非确认状态为已确认否则可以一直反馈 + if (NumberUtils.compare(salaryTemplate.getAckFeedbackStatus(), 1) == 0 && confirmStatus != null && confirmStatus == BillConfimStatusEnum.CONFIRMED.getValue()) { + map.put("showFeedback", "0"); + } + map.put("sendEmployeeId", salarySendInfo.getSendEmployeeId()); + } else { + map.put("showFeedback", "0"); + } + + + // 记录查看日志 + String targetName = taxAgentPO.getName() + "-" + SalaryDateUtil.getFormatYearMonth(salarySendInfo.getSalaryMonth()); + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(salarySendInfo.getId())); + loggerContext.setTargetName(targetName); + loggerContext.setOperateType(OperateTypeEnum.READ.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "查看工资单") + ": " + targetName + " " + salaryInfoId); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "查看工资单") + ": " + targetName); + SalaryElogConfig.mySalaryBillLoggerTemplate.write(loggerContext); + return map; + } + + + //工资单时效性 + private Date getLimitMonth(salaryBillViewingLimitSetting salaryBillViewingLimitSetting) { + if (salaryBillViewingLimitSetting.getLimitMonth() != 0) { + MonthTypeEnum monthType = salaryBillViewingLimitSetting.getMonthType(); + LocalDate localDate; + if (monthType == MonthTypeEnum.SALARY_DATE) { + localDate = LocalDate.now().plusMonths(-salaryBillViewingLimitSetting.getLimitMonth() + 1).withDayOfMonth(1); + } else { + localDate = LocalDate.now().plusMonths(-salaryBillViewingLimitSetting.getLimitMonth()); + } + return SalaryDateUtil.localDateToDate(localDate); + } + return null; + } + + + /** + * 工资单水印文本型动态变量 == 处理 + * + * @param salaryTemplate + * @param salarySendInfo + */ + private void handleSalaryWatermark(SalaryTemplatePO salaryTemplate, SalarySendInfoPO salarySendInfo, Long employeeId) { + SalaryBillWatermarkDTO salaryBillWatermark = JsonUtil.parseObject(salaryTemplate.getSalaryWatermark(), SalaryBillWatermarkDTO.class); + if (Objects.isNull(salaryBillWatermark) || Boolean.FALSE.equals(salaryBillWatermark.getWatermarkStatus())) { + return; + } + // 发送时已经处理好变量字段,可直接获取判断 + List wmTextFieldIds = (List) salaryBillWatermark.getWmSetting().getOrDefault("wmSelectedFieldIds", Lists.newArrayList()); + if (CollectionUtils.isEmpty(wmTextFieldIds)) { + return; + } + + boolean needQueryEmp = (boolean) salaryBillWatermark.getWmSetting().getOrDefault("needQueryEmp", false); + DataCollectionEmployee simpleEmployee = null; + if (needQueryEmp) { + simpleEmployee = getSalaryEmployeeService(user).getEmployeeById(employeeId); + } + + String wmText = salaryBillWatermark.getWmSetting().getOrDefault("wmText", StringUtils.EMPTY).toString(); + wmText = SalaryBillBO.handleWmText(wmText, wmTextFieldIds, simpleEmployee); + + // 重新设回水印 + salaryBillWatermark.getWmSetting().put("wmText", wmText); + salaryTemplate.setSalaryWatermark(JSON.toJSONString(salaryBillWatermark)); + } + + + @Override + public PageInfo salarySendInfoListPage(SalarySendInfoQueryParam queryParam) { + + //排序配置 + OrderRuleVO orderRule = getSalarySysConfService(user).orderRule(); + queryParam.setOrderRule(orderRule); + + List page = salarySendInfoMapper.list(queryParam); + PageInfo pageInfo = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), + page, SalarySendInfoListDTO.class); + SalarySendPO salarySendPO = getSalarySendMapper().getById(queryParam.getSalarySendId()); + if (salarySendPO == null) { + throw new SalaryRunTimeException("工资单不存在或已被删除"); + } + List salaryTemplates = getSalaryTemplateService(user).getDefaultTemplates(Collections.singletonList(salarySendPO.getSalarySobId())); + if (CollectionUtils.isEmpty(salaryTemplates)) { + throw new SalaryRunTimeException("请先设置工资单模板"); + } + Integer ackFeedbackStatus = salaryTemplates.get(0).getAckFeedbackStatus(); + Integer feedbackStatus = salaryTemplates.get(0).getFeedbackStatus(); + if ((ackFeedbackStatus != null && NumberUtils.compare(ackFeedbackStatus, 1) == 0) + || (feedbackStatus != null && NumberUtils.compare(feedbackStatus, 1) == 0)) { + // 默认为空时,未读未确认 + pageInfo.getList().stream().forEach(obj -> { + SalarySendInfoListDTO dto = (SalarySendInfoListDTO) obj; + if (StringUtils.isBlank(dto.getBillReadStatus())) { + dto.setBillReadStatus(BillReadStatusEnum.UNREAD.getDefaultLabel()); + } else { + dto.setBillReadStatus(BillReadStatusEnum.getDefaultLabelByValue(Integer.valueOf(dto.getBillReadStatus()))); + } + if (StringUtils.isBlank(dto.getBillConfirmStatus())) { + dto.setBillConfirmStatus(BillConfimStatusEnum.UNCONFIRMED.getDefaultLabel()); + } else { + dto.setBillConfirmStatus(BillConfimStatusEnum.getDefaultLabelByValue(Integer.valueOf(dto.getBillConfirmStatus()))); + } + }); + } + List list = pageInfo.getList(); + + List employeeList = getExtEmpService(user).listEmployee(); + Map employeeMap = SalaryEntityUtil.convert2Map(employeeList, DataCollectionEmployee::getEmployeeId); + list.forEach(dto -> { + if (dto.getEmployeeType() != null && Objects.equals(dto.getEmployeeType(), 1)) { + DataCollectionEmployee employee = employeeMap.get(dto.getEmployeeId()); + dto.setUsername(employee.getUsername()); + dto.setDepartment(employee.getDepartmentName()); + dto.setMobile(employee.getMobile()); + dto.setJobNum(employee.getWorkcode()); + } + }); + pageInfo.setList(list); + return pageInfo; + } + + @Override + public List salarySendInfoList(Long salarySendId) { + return salarySendInfoMapper.list(SalarySendInfoQueryParam.builder().salarySendId(salarySendId).build()); + } + + @Override + public PageInfo mySalaryBillListPage(SalaryBillQueryParam queryParam) { + List list = salarySendInfoMapper.mySalaryBillList(queryParam); + + //工资单时效 + salaryBillViewingLimitSetting salaryBillViewingLimitSetting = getSalaryBillBaseSetService(user).getSalaryBillViewingLimitSetting(); + Date limitMonth = getLimitMonth(salaryBillViewingLimitSetting); + list = list.stream() + .filter(dto -> { + if (limitMonth != null) { + if (salaryBillViewingLimitSetting.getMonthType() == MonthTypeEnum.SALARY_DATE) { + return !limitMonth.after(dto.getSalaryYearMonth()); + } else { + return !limitMonth.after(dto.getSendTime()); + } + } + return true; + }) + .peek(dto -> { + dto.setEmployeeId((long) user.getUID()); + dto.setSalaryCode(AESEncryptUtil.encrypt4SalaryBill(String.valueOf(user.getUID()))); + }) + .collect(Collectors.toList()); + + PageInfo pageInfo = new PageInfo<>(list, SalaryMySalaryBillListDTO.class); + pageInfo.setTotal(list.size()); + pageInfo.setPageNum(queryParam.getCurrent()); + pageInfo.setPageSize(queryParam.getPageSize()); + return pageInfo; + } + + @Override + public PageInfo salarySendInfoDetailListPage(SalarySendDetailQueryParam queryParam) { + //排序配置 + OrderRuleVO orderRule = getSalarySysConfService(user).orderRule(); + queryParam.setOrderRule(orderRule); + Set otherSalaryAcctRecordIds = null; + if (queryParam.getMergeCountTax() != null && queryParam.getMergeCountTax()) { + //查询关联的核酸id,这里认为一次发放只对应一条核算记录 + Long salaryAccRecordId = salarySendInfoMapper.listSalaryAccRecordIds(queryParam).stream().findFirst().orElse(null); + // 查询合并计税的其他薪资核算记录 + List otherSalaryAcctRecordPOS = getSalaryAcctRecordService(user).listById4OtherConsolidatedTax(salaryAccRecordId); + if (CollectionUtils.isEmpty(otherSalaryAcctRecordPOS)) { + return new PageInfo<>(); + } + // 查询合并计税的薪资核算人员 + otherSalaryAcctRecordIds = SalaryEntityUtil.properties(otherSalaryAcctRecordPOS, SalaryAcctRecordPO::getId); + if (otherSalaryAcctRecordIds.isEmpty()) { + return new PageInfo<>(); + } + } + List list = getSalarySendInfoMapper().detailList(queryParam, otherSalaryAcctRecordIds); + return SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), list, SalarySendDetailListDTO.class); + } + + /** + * 获取工资单标题 + * + * @param theme + * @param salaryMonth + * @param employeeId + * @return + */ + private String getBillTitle(String theme, Date salaryMonth, Long employeeId) { + String companyName = ""; + if (employeeId != null) { + ResourceComInfo resourceComInfo = null; + SubCompanyComInfo subCompanyComInfo = new SubCompanyComInfo(); + try { + resourceComInfo = new ResourceComInfo(); + subCompanyComInfo = new SubCompanyComInfo(); + } catch (Exception e) { + log.error("资源异常", e); + } + companyName = subCompanyComInfo.getSubCompanyname(resourceComInfo.getSubCompanyID(employeeId + "")); + } + return theme.replace("${companyName}", companyName) + .replace("${salaryMonth}", new SimpleDateFormat("yyyy年MM月").format(salaryMonth)) + .replace("${salaryYear}", new SimpleDateFormat("yyyy年").format(salaryMonth)); + } + + /** + * 根据模板内容转为工资单模板对象 + * 注意:不要通过反序列化,可能会因为历史原因修改字段名称而无法序列化 + * + * @param salaryTemplateContent + * @return + */ + private SalaryTemplatePO buildSalaryTemplateContent(String salaryTemplateContent) { + Map map = JsonUtil.parseMap(salaryTemplateContent, Object.class); + SalaryTemplatePO build = SalaryTemplatePO.builder() + .id(Long.valueOf(map.getOrDefault("id", "0").toString())) + .ackFeedbackStatus(Integer.valueOf(map.getOrDefault("ackFeedbackStatus", "0").toString())) + .autoAckDays(Integer.valueOf(map.getOrDefault("autoAckDays", "0").toString())) + .feedbackUrl(map.getOrDefault("feedbackUrl", "").toString()) + .mobileFeedbackUrl(map.getOrDefault("mobileFeedbackUrl", "").toString()) + .name(map.getOrDefault("name", "").toString()) + .salarySobId(Long.valueOf(map.getOrDefault("salarySobId", "0").toString())) + .useType(Integer.valueOf(map.getOrDefault("useType", "0").toString())) + .description(map.getOrDefault("description", "").toString()) + .emailStatus(Integer.valueOf(map.getOrDefault("emailStatus", "0").toString())) + .sendEmailId(Long.valueOf(map.getOrDefault("sendEmailId", "0").toString())) + .msgStatus(Integer.valueOf(map.getOrDefault("msgStatus", "0").toString())) + .salaryWatermark(map.getOrDefault("salaryWatermark", StringUtils.EMPTY).toString()) + .theme(map.getOrDefault("theme", "").toString()) + .background(map.getOrDefault("background", "").toString()) + .textContent(map.getOrDefault("textContent", "").toString()) + .textContentPosition(Integer.valueOf(map.getOrDefault("textContentPosition", "0").toString())) + .salaryItemNullStatus(Integer.valueOf(map.getOrDefault("salaryItemNullStatus", "0").toString())) + .salaryItemZeroStatus(Integer.valueOf(map.getOrDefault("salaryItemZeroStatus", "0").toString())) + .salaryItemSetting(map.getOrDefault("salaryItemSetting", "").toString()) + .replenishName(map.getOrDefault("replenishName", "").toString()) + .replenishSalaryItemSetting(map.getOrDefault("replenishSalaryItemSetting", "").toString()) + .build(); + Object feedbackStatus = map.get("feedbackStatus"); + if (feedbackStatus == null || StringUtils.isBlank(feedbackStatus.toString())) { + build.setFeedbackStatus(build.getAckFeedbackStatus()); + } else { + build.setFeedbackStatus(Integer.valueOf(feedbackStatus.toString())); + } + return build; + } + + /** + * 构建工资单中的人员信息 + * + * @param employeeInformation + * @param simpleEmployee + * @param taxAgentName + * @param employeeField + */ + private void buildEmployeeInfo(SalaryTemplateSalaryItemSetListDTO employeeInformation, DataCollectionEmployee simpleEmployee, String taxAgentName, Map employeeField) { + if (employeeInformation == null) { + return; + } + if (CollectionUtils.isNotEmpty(employeeInformation.getItems())) { + //获取员工信息的字段名和中文描述的map关系 + SalaryFormulaEmployeeDTO salaryFormulaEmployeeDTO = SalaryFormulaEmployeeDTO.builder().employeeId(simpleEmployee.getEmployeeId()) + .birthday(simpleEmployee.getBirthday()) + .departmentId(simpleEmployee.getDepartmentId()) + .departmentName(simpleEmployee.getDepartmentName()) + .subcompanyId(simpleEmployee.getSubcompanyid()) + .subcompanyName(simpleEmployee.getSubcompanyName()) + .email(StringUtils.isEmpty(simpleEmployee.getEmail()) ? "" : simpleEmployee.getEmail()) + .jobcall(simpleEmployee.getJobcall()) + .jobcallId(simpleEmployee.getJobcallId()) + .companystartdate(simpleEmployee.getCompanystartdate()) + .sex("0".equals(simpleEmployee.getSex()) ? "男" : "女") + .mobile(StringUtils.isEmpty(simpleEmployee.getMobile()) ? "" : simpleEmployee.getMobile()) + .jobtitleName(simpleEmployee.getJobtitleName()) + .jobtitleId(simpleEmployee.getJobtitleId()) + .status(simpleEmployee.getStatus() == null ? "" : simpleEmployee.getStatus()) + .statusName(simpleEmployee.getStatus() == null ? "" : UserStatusEnum.parseByValue(new Integer(Util.null2s(simpleEmployee.getStatus(), "1"))).getDefaultLabel()) + .accountTypeName(simpleEmployee.getAccountType() == null ? "" : AccountTypeEnum.parseByValue(simpleEmployee.getAccountType()).getDefaultLabel()) + .telephone(StringUtils.isEmpty(simpleEmployee.getTelephone()) ? "" : simpleEmployee.getTelephone()) + .username(StringUtils.isEmpty(simpleEmployee.getUsername()) ? "" : simpleEmployee.getUsername()) + .workcode(StringUtils.isEmpty(simpleEmployee.getWorkcode()) ? "" : simpleEmployee.getWorkcode()) + .idNo(Util.null2String(simpleEmployee.getIdNo())) + .taxAgentName(taxAgentName) + .build(); + List items = employeeInformation.getItems(); + Set> entries = employeeField.entrySet(); + for (SalaryTemplateSalaryItemListDTO e : items) { + Optional> entry = entries.stream().filter(f -> Objects.equals(e.getName(), f.getValue())).findFirst(); + if (entry.isPresent()) { + String key = entry.get().getKey(); + if (StringUtils.isNotBlank(key)) { + String getter = "get" + key.substring(0, 1).toUpperCase() + key.substring(1); + try { + Method method = salaryFormulaEmployeeDTO.getClass().getMethod(getter); + Object invoke = method.invoke(salaryFormulaEmployeeDTO); + e.setSalaryItemValue(Util.null2String(invoke)); + } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) { + log.error("no such method", e); + } + } + } + } + } + } + + /** + * 组装详情数据 + * + * @param salaryItems + * @param list + * @param salaryAccountingId + */ + @Override + public List> buildDetailList(List salaryItems, List list, Long salaryAccountingId) { + List> listMaps = new ArrayList<>(); + if (CollectionUtils.isEmpty(list)) { + return listMaps; + } + + SalaryAcctResultPO build = SalaryAcctResultPO.builder() + .salaryAcctRecordId(salaryAccountingId) + .employeeIds(list.stream().map(SalarySendDetailListDTO::getEmployeeId).collect(Collectors.toList())) + .build(); + List salaryAccountingResults = getSalaryAcctResultMapper().listSome(build); + encryptUtil.decryptList(salaryAccountingResults, SalaryAcctResultPO.class); + // 动态列 + List employeeList = getExtEmpService(user).listEmployee(); + Map> idEmpMap = SalaryEntityUtil.group2Map(employeeList, DataCollectionEmployee::getEmployeeId); + list.forEach(e -> { + //是否外部人员 + Integer employeeType = e.getEmployeeType(); + DataCollectionEmployee extEmp = new DataCollectionEmployee(); + if (Objects.equals(employeeType, 1)) { + List employees = idEmpMap.getOrDefault(e.getEmployeeId(), new ArrayList<>()); + if (CollectionUtils.isNotEmpty(employees) && employees.size() == 1) { + extEmp = employees.get(0); + } + } + Map map = new LinkedHashMap<>(); + map.put("id", e.getId()); + map.put("employeeId", e.getEmployeeId()); + map.put("username", Objects.equals(employeeType, 1) ? extEmp.getUsername() : e.getUsername()); + map.put("taxAgent", e.getTaxAgent()); + map.put("department", Objects.equals(employeeType, 1) ? extEmp.getDepartmentName() : e.getDepartment()); + map.put("mobile", Objects.equals(employeeType, 1) ? extEmp.getMobile() : e.getMobile()); + map.put("jobNum", Objects.equals(employeeType, 1) ? extEmp.getWorkcode() : e.getJobNum()); + map.put("email", Objects.equals(employeeType, 1) ? extEmp.getEmail() : e.getEmail()); + salaryItems.forEach(i -> { + Optional optional = salaryAccountingResults.stream() + .filter(r -> r.getTaxAgentId().equals(e.getTaxAgentId()) + && r.getEmployeeId().equals(e.getEmployeeId()) + && r.getSalaryItemId().equals(Long.valueOf(i.getSalaryItemId()))) + .findFirst(); + map.put(i.getSalaryItemId() + SalaryItemConstant.DYNAMIC_SUFFIX, optional.isPresent() ? optional.get().getResultValue() : ""); + }); + + listMaps.add(map); + }); + return listMaps; + } + + /** + * 组装详情数据 + * + * @param list + * @param salaryAcctResultValues + * @return + */ + @Override + public List> buildDetailList(List list, List salaryAcctEmployees, List salaryAcctResultValues) { + List> listMaps = new ArrayList<>(); + if (CollectionUtils.isEmpty(list)) { + return listMaps; + } + // 所有个税扣缴义务人 + Map taxAgentMap = SalaryEntityUtil.convert2Map(getTaxAgentService(user).listAll(), TaxAgentPO::getId, TaxAgentPO::getName); + // 按人员分组核算数据 +// Map> relationSalaryAcctEmployeeMap = SalaryEntityUtil.group2Map(salaryAcctEmployees, SalaryAcctEmployeePO::getEmployeeId); + Map salaryAcctEmployeeMap = SalaryEntityUtil.convert2Map(salaryAcctEmployees, salaryAcctEmployee -> salaryAcctEmployee.getEmployeeId() + "-" + salaryAcctEmployee.getTaxAgentId()); + Map> singleEmpAcctMap = SalaryEntityUtil.group2Map(salaryAcctResultValues, SalaryAcctResultPO::getSalaryAcctEmpId); + List employeeIds = list.stream().map(SalarySendInfoListDTO::getEmployeeId).distinct().collect(Collectors.toList()); + // 查询分部 查询部门 + List comInfos = getSalaryEmployeeService(user).getEmployeeByIdsAll(employeeIds); + Map empComMap = SalaryEntityUtil.convert2Map(comInfos, DataCollectionEmployee::getEmployeeId); + + // 当前查询核算记录是回算,但是发放不是回算的,那么就取源头核算结果 + boolean isOrigin = false; + SalaryAcctRecordPO salaryAcctRecord = CollectionUtils.isEmpty(list) ? null : getSalaryAcctRecordService(user).getById(list.get(0).getSalaryAcctRecordId()); + if (Objects.nonNull(salaryAcctRecord) && Objects.nonNull(salaryAcctRecord.getBackCalcStatus())) { + isOrigin = !NumberUtils.INTEGER_ONE.equals(list.get(0).getSalaryAcctType()) && salaryAcctRecord.getBackCalcStatus().equals(NumberUtils.INTEGER_ONE); + } + + // 动态列 + long l = System.currentTimeMillis(); + Map finalEmpSubComMap = empComMap; + boolean finalIsOrigin = isOrigin; + list.forEach(e -> { + + SalaryAcctEmployeePO salaryAcctEmployee = salaryAcctEmployeeMap.getOrDefault(e.getEmployeeId() + "-" + e.getTaxAgentId(), new SalaryAcctEmployeePO()); + DataCollectionEmployee hrmDepartmentComInfo = finalEmpSubComMap.getOrDefault(e.getEmployeeId(), new DataCollectionEmployee()); + Map map = new LinkedHashMap<>(); + map.put("id", e.getId()); + map.put("employeeId", e.getEmployeeId()); + map.put("taxAgentName", taxAgentMap.getOrDefault(salaryAcctEmployee.getTaxAgentId(), "")); + map.put("taxAgentId", salaryAcctEmployee.getTaxAgentId()); + map.put("username", hrmDepartmentComInfo.getUsername()); + + map.put("departmentName", salaryAcctEmployee.getDepartmentName()); + map.put("departmentId", salaryAcctEmployee.getDepartmentId()); + + map.put("subcompanyName", salaryAcctEmployee.getSubcompanyName()); + map.put("subcompanyId", salaryAcctEmployee.getSubcompanyId()); + map.put("jobtitleName", salaryAcctEmployee.getJobtitleName()); + map.put("jobtitleId", salaryAcctEmployee.getJobtitleId()); + map.put("companystartdate", hrmDepartmentComInfo.getCompanystartdate()); + map.put("mobile", e.getMobile()); + map.put("dissmissdate", hrmDepartmentComInfo.getDismissdate()); + map.put("status", salaryAcctEmployee.getStatus()); + map.put("statusName", UserStatusEnum.getDefaultLabelByValue(NumberUtils.toInt(salaryAcctEmployee.getStatus(), 1))); + map.put("workcode", hrmDepartmentComInfo.getWorkcode()); + map.put("sex", "0".equals(hrmDepartmentComInfo.getSex()) ? "男" : "女"); + map.put("idNo", hrmDepartmentComInfo.getIdNo()); + map.put("email", hrmDepartmentComInfo.getEmail()); + map.put("telephone", hrmDepartmentComInfo.getTelephone()); + map.put("jobcall", hrmDepartmentComInfo.getJobcall()); + map.put("jobcallId", hrmDepartmentComInfo.getJobcallId()); + map.put("birthday", hrmDepartmentComInfo.getBirthday()); + + map.put("accountType", hrmDepartmentComInfo.getAccountType()); + map.put("accountTypeName", hrmDepartmentComInfo.getAccountTypeName()); + +// map.put("employeeType", SalarySendEmployeeTypeEnum.getNameByValue(e.getEmployeeType())); + // 单个人的核算数据 + List resultValues = Lists.newArrayList(); + + if (singleEmpAcctMap.containsKey(salaryAcctEmployee.getId())) { + resultValues.addAll(singleEmpAcctMap.get(salaryAcctEmployee.getId())); + } + // 薪资项目 +// singleEmpAcctResultList.forEach(i-> map.put(i.getSalaryItemId() + SalaryArchiveConstant.DYNAMIC_SUFFIX, i.getResultValue())); + for (SalaryAcctResultPO salaryAcctResultValue : resultValues) { + if (finalIsOrigin) { + map.put(salaryAcctResultValue.getSalaryItemId() + SalaryArchiveConstant.DYNAMIC_SUFFIX, salaryAcctResultValue.getResultValue()); + } else { + map.put(salaryAcctResultValue.getSalaryItemId() + SalaryArchiveConstant.DYNAMIC_SUFFIX, salaryAcctResultValue.getResultValue()); + } + } + + listMaps.add(map); + }); + log.info("工资单详情构建总耗时:{}毫秒", System.currentTimeMillis() - l); + return listMaps; + } + + /** + * 通过薪资账套获取模板的薪资项目 + * + * @param salaryTemplate + * @return + */ + @Override + public List getSalaryItemsSetting(SalaryTemplatePO salaryTemplate, boolean isReplenish) { + List salaryItems = new ArrayList<>(); + + if (salaryTemplate == null) { + return salaryItems; + } + // 正常模板 + if (!isReplenish && StringUtils.isNotEmpty(salaryTemplate.getSalaryItemSetting())) { + List salaryTemplateShowSetData = JsonUtil.parseList(salaryTemplate.getSalaryItemSetting(), SalaryTemplateSalaryItemSetListDTO.class); + salaryTemplateShowSetData.stream().filter(f -> !f.getGroupId().equals(SalaryTemplateSalaryItemSetGroupConstant.EMPLOYEE_INFO_GROUP_ID)).forEach(e -> { + salaryItems.addAll(e.getItems()); + }); + } + // 补发模板 + if (isReplenish && StringUtils.isNotEmpty(salaryTemplate.getReplenishSalaryItemSetting())) { + List salaryTemplateShowSetData = JsonUtil.parseList(salaryTemplate.getReplenishSalaryItemSetting(), SalaryTemplateSalaryItemSetListDTO.class); + salaryTemplateShowSetData.stream().filter(f -> !f.getGroupId().equals(SalaryTemplateSalaryItemSetGroupConstant.EMPLOYEE_INFO_GROUP_ID)).forEach(e -> salaryItems.addAll(e.getItems())); + } + return salaryItems; + } + + @Override + public Map grant(SalarySendGrantParam param) { + if (param.getSalarySendId() == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100327, "工资单发放Id必传")); + } + + Long salarySendId = param.getSalarySendId(); + Collection ids = param.getIds(); + + if (param.getSalarySendRangeIds() != null) { + //如果传了范围id,则使用范围id发放 + ids = getSalarySendRangeService(user).getSendInfoIdsBySendId(salarySendId, param.getSalarySendRangeIds(), SalarySendGrantTypeEnum.GRANT); + if (ids.isEmpty()) {// 由于查出来是空的,会导致全部发放,在此进行拦截 + throw new SalaryRunTimeException("工资发放范围内没有匹配员工"); + } + } + + SalarySendPO salarySend = mapper.getById(salarySendId); + if (salarySend == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100512, "工资单发放不存在")); + } + // 已经冻结不能操作 + if (Objects.equals(salarySend.getSendStatus(), NumberUtils.INTEGER_ONE)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "工资单已冻结")); + } + // 获取默认模板 + List salaryTemplates = getSalaryTemplateService(user).getDefaultTemplates(Collections.singletonList(salarySend.getSalarySobId())); + if (CollectionUtils.isEmpty(salaryTemplates)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100518, "没有默认模板,无法发送")); + } + SalaryTemplatePO templatePO = salaryTemplates.get(0); + Date sendTime = new Date(); + // 获取可发送的列表 + List> enableSendList = getEnableSendList(salarySend, ids, templatePO); + // 1.发放 + + SalarySendInfoPO po = new SalarySendInfoPO(); + po.setSendStatus(SalarySendStatusEnum.ALREADYSEND.getValue()); + po.setSendTime(sendTime); + po.setSalaryTemplate(JsonUtil.toJsonString(templatePO)); + po.setBillReadStatus(BillReadStatusEnum.UNREAD.getValue()); + po.setBillConfirmStatus(BillConfimStatusEnum.UNCONFIRMED.getValue()); + po.setSendEmployeeId(Long.valueOf(user.getUID())); + salarySendInfoMapper.updateGrantWithdraw(po, salarySendId, Arrays.asList(SalarySendStatusEnum.UNSEND.getValue(), SalarySendStatusEnum.WITHDRAW.getValue()), ids); + + + List list = salarySendInfoMapper.listSome(SalarySendInfoPO.builder().salarySendId(salarySendId).build()); + //需要发送工资的人 + + List sendList = list.stream().filter(e -> e.getSendStatus().equals(SalarySendStatusEnum.ALREADYSEND.getValue())).collect(Collectors.toList()); + int sendNum = sendList.size(); + int sendTotal = list.size(); + SalarySendPO salarySendNew = new SalarySendPO(); + try { + BeanUtils.copyProperties(salarySendNew, salarySend); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } catch (InvocationTargetException e) { + e.printStackTrace(); + } + salarySendNew.setSendNum(sendNum); + salarySendNew.setSendTotal(sendTotal); + salarySendNew.setLastSendTime(sendTime); + + mapper.updateById(salarySendNew); + + List needSendList = Lists.newArrayList(); + enableSendList.forEach(map -> { + sendList.forEach(item -> { + if (item.getId() == Long.valueOf(map.get("id").toString()).longValue()) { + needSendList.add(item); + } + }); + }); + + // 发送消息 + param.setTemplate(templatePO); + sendMessage(true, needSendList, param, salarySend); + + Map map = new HashMap<>(2); + map.put("sendNum", sendNum); + map.put("sendTotal", sendTotal); + + return map; + } + + /** + * 发送消息 + * + * @param sendFlag true 发送 false 撤回 + * @param list + * @param param + * @param salarySend + */ + private void sendMessage(boolean sendFlag, List list, SalarySendGrantParam param, SalarySendPO salarySend) { + new Thread() { + public void run() { + List pos = list; + if (CollectionUtils.isNotEmpty(param.getIds())) { + pos = list.stream().filter(f -> param.getIds().contains(f.getId())).collect(Collectors.toList()); + } + pos.stream().filter(po -> !Objects.equals(po.getEmployeeType(), 1)).forEach(po -> { + Long employeeId = po.getEmployeeId(); + if (sendFlag) { + sendPayRollEMMessage(po, param.getTemplate(), employeeId); + } else { + withdrawPayrollEMMessage(po, employeeId); + } + }); + } + }.start(); + } + + /** + * 发送Em消息 + */ + private void sendPayRollEMMessage(SalarySendInfoPO po, SalaryTemplatePO template, Long employeeId) { + +// try { +// MessageUtil.sendSMS(mobile, content); +// } catch (Exception e) { +// kqLog.info("SendSMS error.resourceId:" + resourceId + ">>>>>>mobile>>>>>>" + mobile); +// log.writeLog(e); +// } + + + Long id = po.getId(); + String background = template.getBackground(); + String billTitle = getBillTitle(template.getTheme(), po.getSalaryMonth(), employeeId); + MessageType messageType = MessageType.newInstance(499); // 消息来源(见文档第四点补充 必填) + Set userIdList = new HashSet<>(); // 接收人id 必填 + userIdList.add(employeeId.toString()); + String title = billTitle; // 标题 + String context = "点击查看详情"; // 内容 + // PC端链接 + String linkUrl = weaver.general.GCONST.getContextPath() + "/spa/hrmSalary/static/index.html#/main/hrmSalary/mobilepayroll?id=" + id + "&recipient=" + employeeId; + // 移动端链接 + String linkMobileUrl = weaver.general.GCONST.getContextPath() + "/spa/hrmSalary/static/index.html#/main/hrmSalary/mobilepayroll?type=phone&id=" + id + "&recipient=" + employeeId; + try { + MessageBean messageBean = Util_Message.createMessage(messageType, userIdList, title, context, linkUrl, linkMobileUrl); + messageBean.setCreater(user.getUID());// 创建人id + messageBean.setBizState("0");// 需要修改消息为已处理等状态时传入,表示消息最初状态为待处理 + messageBean.setTargetId("499|" + id); //消息来源code +“|”+业务id需要修改消息为已处理等状态时传入 + + if (StringUtils.isNotBlank(background)) { + messageBean.setPictureUrl(background); + } else { + messageBean.setPictureUrl("/hrm/hrm_e9/images/payroll.jpg?pictype=jpg"); + } + Util_Message.store(messageBean); + } catch (IOException e) { + e.printStackTrace(); + } + } + + /** + * 撤回EM消息 + * + * @param po + */ + private void withdrawPayrollEMMessage(SalarySendInfoPO po, Long employeeId) { + try { + MessageBean messageBean = Util_Message.createMessage(); + messageBean.setUserList(new HashSet<>());//接收人id + messageBean.setUserId(employeeId.intValue()); + messageBean.setTargetId("499|" + po.getId()); //code + “|” + 业务id + //messageBean.setMessageType(MessageType.newInstance(121));//消息来源code(传了代表code也做为删除时的条件,默认不传) + Util_Message.delMessageTargetid(messageBean); + } catch (Exception e) { + e.printStackTrace(); + } + } + + private List> getEnableSendList(SalarySendPO salarySend, Collection ids, SalaryTemplatePO salaryTemplate) { + // 1.根据模板获取薪资项目设置 + SalaryAcctRecordPO salaryAcctRecord = getSalaryAcctRecordService(user).getById(salarySend.getSalaryAccountingId()); + boolean isReplenish = salaryAcctRecord != null && Objects.equals(salaryAcctRecord.getBackCalcStatus(), (NumberUtils.INTEGER_ONE)); + List salaryItems = getSalaryItemsSetting(salaryTemplate, isReplenish); + SalarySendDetailQueryParam queryParam = new SalarySendDetailQueryParam(); + queryParam.setSalarySendId(salarySend.getId()); + // 空就是所有 + queryParam.setIds(ids); + queryParam.setSendStatuss(Arrays.asList(SalarySendStatusEnum.UNSEND.getValue(), SalarySendStatusEnum.WITHDRAW.getValue())); + // 2.获取基本数据 + List list = salarySendInfoMapper.detailList(queryParam, null); + // 3.组装详情数据 + List> listMaps = buildDetailList(salaryItems, list, salarySend.getSalaryAccountingId()); + return listMaps; + } + + + @Override + public Map withdraw(SalarySendWithdrawParam param) { + if (param.getSalarySendId() == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100327, "工资单发放Id必传")); + } + + Long salarySendId = param.getSalarySendId(); + Collection ids = param.getIds(); + + // 获取可撤回的工资单 + if (param.getSalarySendRangeIds() != null) { + //如果传了范围id,则使用范围id撤回 + ids = getSalarySendRangeService(user).getSendInfoIdsBySendId(salarySendId, param.getSalarySendRangeIds(), SalarySendGrantTypeEnum.WITHDRAW); + if (ids.isEmpty()) {// 由于查出来是空的,会导致全部发放,在此进行拦截 + throw new SalaryRunTimeException("工资撤回范围内没有匹配的员工"); + } + } + + SalarySendPO salarySend = mapper.getById(salarySendId); + if (salarySend == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100512, "工资单发放不存在")); + } + + // 撤回 + SalarySendInfoPO po = new SalarySendInfoPO(); + po.setSendStatus(SalarySendStatusEnum.WITHDRAW.getValue()); + po.setBillReadStatus(BillReadStatusEnum.UNREAD.getValue()); + po.setBillConfirmStatus(BillConfimStatusEnum.UNCONFIRMED.getValue()); + List statusList = new ArrayList<>(); + statusList.add(SalarySendStatusEnum.ALREADYSEND.getValue()); + salarySendInfoMapper.updateGrantWithdraw(po, salarySendId, statusList, ids); + + + po = new SalarySendInfoPO(); + po.setDeleteType(0); + po.setSalarySendId(salarySendId); + List list = salarySendInfoMapper.listSome(po); + + int sendNum = (int) list.stream().filter(e -> e.getSendStatus().equals(SalarySendStatusEnum.ALREADYSEND.getValue())).count(); + int sendTotal = list.size(); + + SalarySendPO salarySendNew = new SalarySendPO(); + try { + BeanUtils.copyProperties(salarySendNew, salarySend); + } catch (Exception e) { + throw new SalaryRunTimeException("数据转换异常, " + e.getMessage()); + } + salarySendNew.setSendNum(sendNum); + salarySendNew.setSendTotal(sendTotal); + mapper.updateById(salarySendNew); + + SalarySobPO salarySob = getSalarySobService(user).getById(salarySend.getSalarySobId()); + // 记录日志 + LoggerContext loggerContext = new LoggerContext(); + loggerContext.setTargetId(String.valueOf(salarySend.getId())); + loggerContext.setTargetName(SalaryDateUtil.getFormatYearMonth(salarySend.getSalaryMonth()) + "-" + (salarySob == null ? "" : salarySob.getName())); + loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "撤回工资单")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "撤回工资单")); + loggerContext.setOldValues(salarySend); + loggerContext.setNewValues(salarySendNew); + loggerContext.setOperator(user.getUID() + StringUtils.EMPTY); + loggerContext.setOperatorName(Objects.isNull(user) ? StringUtils.EMPTY : user.getUsername()); + SalaryElogConfig.salarySendLoggerTemplate.write(loggerContext); + + + SalarySendGrantParam grantParam = SalarySendGrantParam.builder().ids(param.getIds()).salarySendId(param.getSalarySendId()).build(); + + // 异步发送消息:先修改数据再发消息,避免出错后无法撤回撤回消息 + sendMessage(false, list, grantParam, salarySend); + + + Map map = new HashMap<>(2); + map.put("sendNum", sendNum); + map.put("sendTotal", sendTotal); + return map; + } + + + @Override + public XSSFWorkbook exportInfoList(SalarySendInfoQueryParam queryParam) { + // 校验 + SalarySendInfoQueryParam.checkParam(queryParam); + + // 1.工作簿名称 + String sheetName = SalaryI18nUtil.getI18nLabel(100528, "工资单发放信息"); + List header = new ArrayList<>(); + header.add(SalaryI18nUtil.getI18nLabel(85429, "姓名")); + header.add(SalaryI18nUtil.getI18nLabel(86184, "个税扣缴义务人")); + header.add(SalaryI18nUtil.getI18nLabel(86185, "部门")); + header.add(SalaryI18nUtil.getI18nLabel(86186, "手机号")); + header.add(SalaryI18nUtil.getI18nLabel(86317, "工号")); + header.add(SalaryI18nUtil.getI18nLabel(86317, "发送状态")); + SalarySendPO salarySendPO = getById(queryParam.getSalarySendId()); + if (salarySendPO == null) { + throw new SalaryRunTimeException("工资单不存在"); + } + List salaryTemplates = getSalaryTemplateService(user).getDefaultTemplates(Collections.singletonList(salarySendPO.getSalarySobId())); + if (CollectionUtils.isEmpty(salaryTemplates)) { + throw new SalaryRunTimeException("请先设置工资单模板"); + } + Integer ackFeedbackStatus = salaryTemplates.get(0).getAckFeedbackStatus(); + Integer feedbackStatus = salaryTemplates.get(0).getFeedbackStatus(); + if ((ackFeedbackStatus != null && NumberUtils.compare(ackFeedbackStatus, 1) == 0) + || (feedbackStatus != null && NumberUtils.compare(feedbackStatus, 1) == 0)) { + header.add(SalaryI18nUtil.getI18nLabel(0, "查看状态")); + header.add(SalaryI18nUtil.getI18nLabel(0, "确认状态")); + } + List> rows = new ArrayList<>(); + // 2.表头 + rows.add(header); + // 获取行数据 + //排序配置 + OrderRuleVO orderRule = getSalarySysConfService(user).orderRule(); + queryParam.setOrderRule(orderRule); + List list = salarySendInfoMapper.list(queryParam); + List employeeList = getExtEmpService(user).listEmployee(); + Map> idEmpMap = SalaryEntityUtil.group2Map(employeeList, DataCollectionEmployee::getEmployeeId); + list.forEach(e -> { + // 发放状态 + e.setSendStatus(SalarySendStatusEnum.getDefaultLabelByValue(Integer.valueOf(e.getSendStatus()))); + // 查看状态 + e.setBillReadStatus(NumberUtils.isCreatable(e.getBillReadStatus()) ? BillReadStatusEnum.getDefaultLabelByValue(Integer.valueOf(e.getBillReadStatus())) : ""); + // 确认状态 + e.setBillConfirmStatus(NumberUtils.isCreatable(e.getBillConfirmStatus()) ? BillConfimStatusEnum.getDefaultLabelByValue(Integer.valueOf(e.getBillConfirmStatus())) : ""); + //外部人员 + if (Objects.equals(e.getEmployeeType(), 1)) { + List employees = idEmpMap.getOrDefault(e.getEmployeeId(), new ArrayList<>()); + if (CollectionUtils.isNotEmpty(employees) && employees.size() == 1) { + DataCollectionEmployee employee = employees.get(0); + e.setUsername(employee.getUsername()); + e.setDepartment(employee.getDepartmentName()); + e.setMobile(employee.getMobile()); + e.setJobNum(employee.getWorkcode()); + } + } + }); + + // 3.添加行记录 + // 3.表数据 + for (SalarySendInfoListDTO dto : list) { + List row = new ArrayList<>(); + row.add(dto.getUsername()); + row.add(dto.getTaxAgent()); + row.add(dto.getDepartment()); + row.add(dto.getMobile()); + row.add(dto.getJobNum()); + row.add(dto.getSendStatus()); + if ((ackFeedbackStatus != null && NumberUtils.compare(ackFeedbackStatus, 1) == 0) + || (feedbackStatus != null && NumberUtils.compare(feedbackStatus, 1) == 0)) { + row.add(dto.getBillReadStatus()); + row.add(dto.getBillConfirmStatus()); + } + rows.add(row); + } + + // 记录操作日志 + SalarySendPO salarySend = mapper.getById(queryParam.getSalarySendId()); + SalarySobPO salarySob = getSalarySobService(user).getById(salarySend.getSalarySobId()); + + String name = SalaryDateUtil.getFormatYearMonth(salarySend.getSalaryMonth()) + "-" + (salarySob == null ? "" : salarySob.getName()); + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setTargetName(name); + loggerContext.setOperateType(OperateTypeEnum.EXCEL_EXPORT.getValue()); + loggerContext.setOperateTypeName(name); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "工资单发放") + ":" + name + SalaryI18nUtil.getI18nLabel(0, " 导出")); + loggerContext.setUser(user); + SalaryElogConfig.salarySendLoggerTemplate.write(loggerContext); + return ExcelUtil.genWorkbookV2(rows, sheetName); + } + +// @BatchExportHandler("exportSalarySendInfo") +// public void salarySendInfoExportHandler() { +// BatchCallbackMessage message = BatchExportContext.getBatchCallbackMessage(); +// System.out.println("接受到导出的结果" + JSONObject.toJSONString(message)); +// } + + @Override + public XSSFWorkbook exportDetailList(SalarySendPO salarySend, SalarySendDetailQueryParam queryParam) { + + // 1.根据模板获取薪资项目设置 + SalaryAcctRecordPO salaryAcctRecord = getSalaryAcctRecordService(user).getById(salarySend.getSalaryAccountingId()); + boolean isReplenish = salaryAcctRecord != null && Objects.equals(salaryAcctRecord.getBackCalcStatus(), (NumberUtils.INTEGER_ONE)); + List salaryTemplates = getSalaryTemplateService(user).getDefaultTemplates(Collections.singletonList(salarySend.getSalarySobId())); + List salaryItems = getSalaryItemsSetting(CollectionUtils.isNotEmpty(salaryTemplates) ? salaryTemplates.get(0) : null, isReplenish); + + // 2.获取基本数据 + //排序配置 + OrderRuleVO orderRule = getSalarySysConfService(user).orderRule(); + queryParam.setOrderRule(orderRule); + + List list = salarySendInfoMapper.detailList(queryParam, null); + + // 3.组装详情数据 + List> listMaps = buildDetailList(salaryItems, list, salarySend.getSalaryAccountingId()); + + // 1.工作簿名称 + String sheetName = SalaryI18nUtil.getI18nLabel(97036, "工资单发放详情"); + List header = new ArrayList<>(); + // 员工信息字段 + header.add(SalaryI18nUtil.getI18nLabel(85429, "姓名")); + header.add(SalaryI18nUtil.getI18nLabel(86185, "部门")); + header.add(SalaryI18nUtil.getI18nLabel(86186, "手机号")); + header.add(SalaryI18nUtil.getI18nLabel(86317, "工号")); + Map salaryItemMap = SalaryEntityUtil.convert2Map(salaryItems, dto -> dto.getSalaryItemId() + SalaryConstant.DYNAMIC_SUFFIX); + List sortedSalaryItems = new ArrayList<>(); + for (String column : queryParam.getColumns()) { + if (column.contains(SalaryConstant.DYNAMIC_SUFFIX)) { + SalaryTemplateSalaryItemListDTO salaryTemplateSalaryItemListDTO = salaryItemMap.get(column); + if (salaryTemplateSalaryItemListDTO != null) { + sortedSalaryItems.add(salaryTemplateSalaryItemListDTO); + } + } + } + + // 动态列 + if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(sortedSalaryItems)) { + for (SalaryTemplateSalaryItemListDTO salaryItem : sortedSalaryItems) { + header.add(salaryItem.getName()); + } + } + List> rows = new ArrayList<>(); + + // 2.表头 + rows.add(header); + + // 3.表数据 + for (Map dto : listMaps) { + List row = new ArrayList<>(); + row.add(dto.get("username")); + row.add(dto.get("department")); + row.add(dto.get("mobile")); + row.add(dto.get("jobNum")); + + // 动态列 + Map mapColumn = listMaps.get(0); + for (SalaryTemplateSalaryItemListDTO salaryItem : sortedSalaryItems) { + if (mapColumn.containsKey(salaryItem.getId() + SalaryItemConstant.DYNAMIC_SUFFIX)) { + row.add(dto.get(salaryItem.getId() + SalaryItemConstant.DYNAMIC_SUFFIX)); + } + } + + rows.add(row); + } + + // 记录日志 + SalarySobPO salarySob = getSalarySobService(user).getById(salaryAcctRecord.getSalarySobId()); + LoggerContext loggerContext = new LoggerContext(); + loggerContext.setTargetId(String.valueOf(salarySend.getId())); + loggerContext.setTargetName(SalaryDateUtil.getFormatYearMonth(salarySend.getSalaryMonth()) + "-" + (salarySob == null ? "" : salarySob.getName())); + loggerContext.setOperateType(OperateTypeEnum.EXCEL_EXPORT.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "导出工资单")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "导出工资单")); + loggerContext.setOperator(user.getUID() + StringUtils.EMPTY); + loggerContext.setOperatorName(Objects.isNull(user) ? StringUtils.EMPTY : user.getUsername()); + SalaryElogConfig.salarySendLoggerTemplate.write(loggerContext); + + return ExcelUtil.genWorkbookV2(rows, sheetName); + } + + @Override + public List getSalarySendCheckResult(Set salaryAcctRecordIds) { + if (CollectionUtils.isEmpty(salaryAcctRecordIds)) { + return Collections.emptyList(); + } + Map condition = new HashMap<>(); + condition.put("salaryAccountingIds", salaryAcctRecordIds); + List salarySendPOS = getSalarySendMapper().listSomeWithCondition(condition); + Map map = SalaryEntityUtil.convert2Map(salarySendPOS, SalarySendPO::getSalaryAccountingId); + + return salaryAcctRecordIds.stream().map(m -> { + SalarySendPO salarySend = map.get(m); + SalarySendCheckDTO salarySendCheck = new SalarySendCheckDTO(); + salarySendCheck.setSalaryAcctId(m); + // 是否存在已经发送 + salarySendCheck.setAlreadySend(salarySend != null && salarySend.getSendNum() > 0); + // 是否已经发送完成 + salarySendCheck.setSendFinished(salarySend != null && Objects.equals(salarySend.getSendNum(), salarySend.getSendTotal())); + return salarySendCheck; + }).collect(Collectors.toList()); + } + + @Override + public void handleHistory() { + mapper.batchHandleSendStatusHistory(); + mapper.batchHandleSalaryAcctTypeHistory(); + } + + + @Override + public Map sumRow(SalarySendInfoQueryParam param) { + Long salarySendId = param.getSalarySendId(); + // 获取薪资核算ID + SalarySendPO salarySendPO = getById(salarySendId); + if (Objects.isNull(salarySendPO)) { + throw new SalaryRunTimeException("工资发放记录不存在或已被删除"); + } + + SalaryAcctResultQueryParam queryParam = SalaryAcctResultQueryParam.builder().salaryAcctRecordId(salarySendPO.getSalaryAccountingId()).build(); + // 查询薪资核算人员 + List salaryAcctEmployeePOS = getSalaryAcctEmployeeService(user).listByResultQueryParam(queryParam); + + if (org.apache.commons.collections4.CollectionUtils.isEmpty(salaryAcctEmployeePOS)) { + return Collections.emptyMap(); + } + // 查询薪资核算记录 + SalaryAcctRecordPO salaryAcctRecordPO = getSalaryAcctRecordService(user).getById(queryParam.getSalaryAcctRecordId()); + if (Objects.isNull(salaryAcctRecordPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98747, "薪资核算记录不存在或已被删除")); + } + // 查询薪资核算所用薪资账套的薪资项目 + List salarySobItemPOS = getSalarySobItemService(user).listBySalarySobId(salaryAcctRecordPO.getSalarySobId()); + Map salaryItemIdKeySalarySobItemPOMap = SalaryEntityUtil.convert2Map(salarySobItemPOS, SalarySobItemPO::getId); + Set salaryItemIds = SalaryEntityUtil.properties(salarySobItemPOS, SalarySobItemPO::getSalaryItemId); + if (Objects.equals(salaryAcctRecordPO.getBackCalcStatus(), NumberUtils.INTEGER_ONE)) { + // 是回算,获取回算项 + List salarySobBackItemPOS = getSalarySobBackItemService(user).listBySalarySobId(salaryAcctRecordPO.getSalarySobId()); + salaryItemIds.addAll(salarySobBackItemPOS.stream().map(SalarySobBackItemPO::getSalaryItemId).collect(Collectors.toList())); + } + List salaryItemPOS = getSalaryItemService(user).listByIds(salaryItemIds); + + // 查询薪资核算结果 + List salaryAcctEmployeeIds = SalaryEntityUtil.properties(salaryAcctEmployeePOS, SalaryAcctEmployeePO::getId, Collectors.toList()); + List salaryAcctResultPOS = getSalaryAcctResultService(user).listBySalaryAcctEmployeeIds(salaryAcctEmployeeIds); + // 是否是补发工资单 + List salarySendInfoPOS = getSalarySendInfoMapper().listSome(SalarySendInfoPO.builder().salarySendId(salarySendId).build()); + List sendEmployeeIds = salarySendInfoPOS.stream().map(SalarySendInfoPO::getEmployeeId).collect(Collectors.toList()); + salaryAcctResultPOS = salaryAcctResultPOS.stream().filter(po -> sendEmployeeIds.contains(po.getEmployeeId())).collect(Collectors.toList()); + + Map map = new HashMap<>(); + Map> acctResultMap = SalaryEntityUtil.group2Map(salaryAcctResultPOS, SalaryAcctResultPO::getSalaryItemId); + salaryItemPOS.stream().filter(item -> SalaryDataTypeEnum.NUMBER.getValue().equals(item.getDataType())).forEach(item -> { + BigDecimal sum = Optional.ofNullable(acctResultMap.get(item.getId())).orElse(new ArrayList<>()).stream().map(SalaryAcctResultPO::getResultValue).filter(NumberUtils::isCreatable).map(BigDecimal::new).reduce(BigDecimal.ZERO, BigDecimal::add); + map.put(item.getId() + SalaryItemConstant.DYNAMIC_SUFFIX, SalaryAcctFormulaBO.roundResultValue(sum.toString(), item, Collections.emptyList(), Collections.emptyMap(), salaryItemIdKeySalarySobItemPOMap)); + }); + return map; + } + + @Override + public void deleteBySalaryAcctRecordIds(Collection ids) { + if (CollectionUtils.isNotEmpty(ids)) { + getSalarySendMapper().deleteBySalaryAcctRecordIds(ids); + getSalarySendInfoMapper().deleteBySalaryAcctRecordIds(ids); + } + } + + @Override + public void sendMobileCode(SMSCodeSendParam param) { + Long id = param.getId(); + SalarySendInfoPO po = getSalarySendInfoMapper().getById(id); + if (po == null) { + throw new SalaryRunTimeException("未获取工资单发放信息"); + } + + Long employeeId = po.getEmployeeId(); + DataCollectionEmployee employee = getSalaryEmployeeService(user).getEmployeeById(employeeId); + if (employee == null) { + throw new SalaryRunTimeException("未获取人员信息"); + } + + String mobile = employee.getMobile(); + if (Validator.isMobile(mobile)) { + throw new SalaryRunTimeException("手机号信息有误"); + } + + boolean checkSendSMS = MessageUtil.checkSendSMS(); + if (!checkSendSMS) { + throw new SalaryRunTimeException("短信服务异常"); + } + + //1、生成6位验证码 + String mobileCode = (int) ((Math.random() * 9 + 1) * 100000) + ""; + //失效时间 + long expirationTime = LocalDateTime.now().plusMinutes(10L).toInstant(ZoneOffset.ofHours(8)).toEpochMilli(); + String cacheValue = mobileCode + "_" + expirationTime; + + //2、验证码缓存,10分钟失效 + getSalaryCacheService(user).set(SALARY_CACHE_SMS_CODE + "_" + id, cacheValue); + + //3、发送短信 + MessageUtil.sendSMS(mobile, "验证码:" + mobileCode + "有效时间10分钟,用于查看工资单,请不要告诉他人。"); + } + + @Override + public Boolean checkMobileCode(SMSCodeCheckParam param) { + Long id = param.getId(); + + String mobileCode = param.getMobileCode(); + + //取出验证码 + String cacheValue = getSalaryCacheService(user).get(SALARY_CACHE_SMS_CODE + "_" + id); + String[] cache = cacheValue.split("_"); + String code = cache[0]; + //失效时间 + long expirationTime = Long.parseLong(cache[1]); + + long nowTime = LocalDateTime.now().toInstant(ZoneOffset.ofHours(8)).toEpochMilli(); + if (nowTime > expirationTime) { + throw new SalaryRunTimeException("验证码已失效,请重新发送"); + } + + if (!StringUtils.equals(code, mobileCode)) { + throw new SalaryRunTimeException("验证码错误"); + } + + return true; + } + + @Override + public List getNeedSendInfoList(List salarySendIds) { + if (CollectionUtils.isEmpty(salarySendIds)) { + return Collections.emptyList(); + } + return getSalarySendInfoMapper().getNeedSendInfoList(salarySendIds); + } + + @Override + public List getNeedSendListBySalarySobIds(List salarySobIds) { + if (CollectionUtils.isEmpty(salarySobIds)) { + return Collections.emptyList(); + } + return getSalarySendMapper().getNeedSendListBySalarySobIds(salarySobIds); + } + + @Override + public List listUnConfirmedSendInfo(List salarySobIds) { + if (CollectionUtils.isEmpty(salarySobIds)) return Collections.emptyList(); + return getSalarySendInfoMapper().listUnConfirmedSendInfo(salarySobIds); + } + + @Override + public void autoConfirmSalaryBill(List needAutoSendIds) { + if (CollectionUtils.isEmpty(needAutoSendIds)) { + return; + } + List> partition = Lists.partition((List) needAutoSendIds, 500); + partition.forEach(getSalarySendInfoMapper()::autoConfirmSalaryBill); + } + + @Override + public List getByIds(List salarySendId) { + if (CollectionUtils.isEmpty(salarySendId)) { + return Collections.emptyList(); + } + return getSalarySendMapper().getByIds(salarySendId); + } + + @Override + public List listSome(SalarySendPO param) { + return getSalarySendMapper().listSome(param); + } + + @Override + public Map preview(SalaryPreviewParam param) { + Long salaryInfoId = param.getSalaryInfoId(); + Long recipient = param.getRecipient(); + + if (salaryInfoId == null) { + throw new SalaryRunTimeException("工资单id为空!"); + } + + SalarySendInfoPO salarySendInfo = getSalarySendInfoMapper().getById(salaryInfoId); + if (salarySendInfo == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100511, "工资单信息不存在")); + } + + // 获取默认模板信息 + SalarySendPO salarySendPO = getSalarySendMapper().getById(salarySendInfo.getSalarySendId()); + if (salarySendPO == null) { + throw new SalaryRunTimeException("工资单记录不存在"); + } + + // 获取模板 + SalarySobPO salarySob = getSalarySobService(user).getById(salarySendPO.getSalarySobId()); + TaxAgentPO taxAgentPO = getTaxAgentService(user).getById(salarySendInfo.getTaxAgentId()); + List salaryTemplates = getSalaryTemplateService(user).getDefaultTemplates(Arrays.asList(salarySendPO.getSalarySobId(), salarySob.getId())); + if (CollectionUtils.isEmpty(salaryTemplates)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100518, "没有默认模板,无法发送")); + } + SalaryBillSendDTO salaryBillSendDTO = getSalaryBillService(user).buildSendParams(salarySendPO, salaryTemplates.get(0)); + + SalaryTemplatePO salaryTemplate = salaryBillSendDTO.getSalaryTemplate(); + if (salaryTemplate == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100513, "没有默认模板,无法查看")); + } + + // 判断是否是补发 + boolean isReplenish = NumberUtils.INTEGER_ONE.equals(salarySendInfo.getSalaryAcctType()); + + SalaryAcctResultPO build = SalaryAcctResultPO.builder() + .salaryAcctRecordId(salarySendInfo.getSalaryAcctRecordId()) + .taxAgentId(salarySendInfo.getTaxAgentId()) + .employeeId(recipient) + .build(); + List salaryAcctResultPOS = getSalaryAcctResultMapper().listSome(build); + if (CollUtil.isEmpty(salaryAcctResultPOS)) { + throw new SalaryRunTimeException("薪资核算结果不存在!"); + } + encryptUtil.decryptList(salaryAcctResultPOS, SalaryAcctResultPO.class); + + SalaryAcctRecordPO salaryAcctRecordPO = getSalaryAcctRecordService(user).getById(salarySendInfo.getSalaryAcctRecordId()); + if (salaryAcctRecordPO == null) { + throw new SalaryRunTimeException("薪资核算记录不存在!"); + } + List> salaryAcctResultS = null; + if (Objects.equals(salaryAcctRecordPO.getBackCalcStatus(), NumberUtils.INTEGER_ONE) && !isReplenish) { + // 该记录回算过,并且获取的不是回算后的工资单 + salaryAcctResultS = salaryAcctResultPOS.stream().map(m -> { + Map map = new LinkedHashMap<>(); + map.put("salaryItemId", m.getSalaryItemId()); + map.put("resultValue", m.getOriginResultValue()); + return map; + }).collect(Collectors.toList()); + } else { + salaryAcctResultS = salaryAcctResultPOS.stream().map(m -> { + Map map = new LinkedHashMap<>(); + map.put("salaryItemId", m.getSalaryItemId()); + map.put("resultValue", m.getResultValue()); + return map; + }).collect(Collectors.toList()); + } + + + Map map = new LinkedHashMap<>(); + map.put("tenantName", ""); + map.put("sendTime", SalaryDateUtil.getFormatLocalDateTime(salarySendInfo.getSendTime())); + List listDTOS = JSONArray.parseArray(isReplenish ? salaryTemplate.getReplenishSalaryItemSetting() : salaryTemplate.getSalaryItemSetting(), SalaryTemplateSalaryItemSetListDTO.class); + Optional optionalEmployeeInformation = listDTOS.stream().filter(e -> SalaryTemplateSalaryItemSetGroupConstant.EMPLOYEE_INFO_GROUP_ID.equals(e.getGroupId())).findFirst(); + SalaryTemplateSalaryItemSetListDTO employeeInformation = optionalEmployeeInformation.orElse(null); + List itemSetListDTOS = listDTOS.stream().filter(e -> !SalaryTemplateSalaryItemSetGroupConstant.EMPLOYEE_INFO_GROUP_ID.equals(e.getGroupId())).collect(Collectors.toList()); + List> finalSalaryAcctResultS = salaryAcctResultS; + itemSetListDTOS.stream().forEach(item -> { + item.getItems().forEach(e -> { + if (CollectionUtils.isEmpty(finalSalaryAcctResultS)) { + e.setSalaryItemValue(""); + } else { + Object o = finalSalaryAcctResultS.stream().filter(f -> f.get("salaryItemId") != null && String.valueOf(f.get("salaryItemId")).equals(e.getSalaryItemId())).findFirst().orElse(new HashMap<>()).get("resultValue"); + e.setSalaryItemValue(o == null ? "" : (String) o); + } + }); + }); + + + /** + * 过滤空 + */ + if (Objects.equals(1, salaryTemplate.getSalaryItemNullStatus())) { + for (SalaryTemplateSalaryItemSetListDTO itemSetListDTO : itemSetListDTOS) { + List items = itemSetListDTO.getItems(); + List collect = items.stream().filter(item -> StringUtils.isNotBlank(item.getSalaryItemValue())).collect(Collectors.toList()); + itemSetListDTO.setItems(collect); + } + } + + /** + * 过滤0 + */ + if (Objects.equals(1, salaryTemplate.getSalaryItemZeroStatus())) { + for (SalaryTemplateSalaryItemSetListDTO itemSetListDTO : itemSetListDTOS) { + List items = itemSetListDTO.getItems(); + List collect = items.stream().filter(item -> SalaryEntityUtil.string2BigDecimal(item.getSalaryItemValue()) == null || BigDecimal.ZERO.compareTo(SalaryEntityUtil.string2BigDecimal(item.getSalaryItemValue())) != 0).collect(Collectors.toList()); + itemSetListDTO.setItems(collect); + } + } + + DataCollectionEmployee simpleEmployee = getSalaryEmployeeService(user).getEmployeeById(salarySendInfo.getEmployeeId()); + SalaryAcctEmployeePO acctEmployeePO = getSalaryAcctEmployeeService(user).getById(salaryAcctResultPOS.get(0).getSalaryAcctEmpId()); + SalaryAcctEmployeeBO.copyAcctEmp(simpleEmployee, acctEmployeePO); + buildEmployeeInfo(employeeInformation, simpleEmployee, taxAgentPO.getName(), SalaryAcctResultBO.buildEmployeeFieldName()); + map.put("employeeInformation", employeeInformation); + map.put("salaryGroups", itemSetListDTOS); + + salaryTemplate.setTheme(getBillTitle(salaryTemplate.getTheme(), salarySendPO.getSalaryMonth(), recipient)); + // 工资单水印文本型动态变量 == 处理 + handleSalaryWatermark(salaryTemplate, salarySendInfo, recipient); + map.put("salaryTemplate", salaryTemplate); + map.put("salaryAcctResult", salaryAcctResultS); + + // 工资单确认按钮 + if (salaryTemplate.getAckFeedbackStatus() != null && NumberUtils.compare(salaryTemplate.getAckFeedbackStatus(), 1) == 0) { + // 开启了工资单确认 + Integer ackStatus = salarySendInfo.getBillConfirmStatus(); + if (ackStatus == null || ackStatus != BillConfimStatusEnum.CONFIRMED.getValue()) { + map.put("showAck", "1"); + } else { + map.put("showAck", "0"); + } + map.put("sendEmployeeId", salarySendInfo.getSendEmployeeId()); + } else { + map.put("showAck", "0"); + } + + + // 工资单反馈 + if (salaryTemplate.getFeedbackStatus() != null && NumberUtils.compare(salaryTemplate.getFeedbackStatus(), 1) == 0) { + // 开启了工资单反馈按钮 + Integer confirmStatus = salarySendInfo.getBillConfirmStatus(); + map.put("showFeedback", "1"); + // 除非确认状态为已确认否则可以一直反馈 + if (NumberUtils.compare(salaryTemplate.getAckFeedbackStatus(), 1) == 0 && confirmStatus != null && confirmStatus == BillConfimStatusEnum.CONFIRMED.getValue()) { + map.put("showFeedback", "0"); + } + map.put("sendEmployeeId", salarySendInfo.getSendEmployeeId()); + } else { + map.put("showFeedback", "0"); + } + + // 记录查看日志 + String targetName = taxAgentPO.getName() + "-" + SalaryDateUtil.getFormatYearMonth(salarySendInfo.getSalaryMonth()); + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(salarySendInfo.getId())); + loggerContext.setTargetName(targetName); + loggerContext.setOperateType(OperateTypeEnum.READ.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "预览工资单") + ": " + targetName + " " + salaryInfoId); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "预览工资单") + ": " + targetName); + SalaryElogConfig.mySalaryBillLoggerTemplate.write(loggerContext); + return map; + } +} diff --git a/src/com/engine/salary/service/impl/SalarySobAdjustRuleServiceImpl.java b/src/com/engine/salary/service/impl/SalarySobAdjustRuleServiceImpl.java new file mode 100644 index 000000000..4da850226 --- /dev/null +++ b/src/com/engine/salary/service/impl/SalarySobAdjustRuleServiceImpl.java @@ -0,0 +1,100 @@ +package com.engine.salary.service.impl; + +import com.engine.core.impl.Service; +import com.engine.salary.biz.SalarySobAdjustRuleBiz; +import com.engine.salary.config.SalaryElogConfig; +import com.engine.hrmelog.entity.dto.LoggerContext; +import com.engine.salary.entity.salarysob.bo.SalarySobAdjustRuleBO; +import com.engine.salary.entity.salarysob.param.SalarySobAdjustRuleSaveParam; +import com.engine.salary.entity.salarysob.po.SalarySobAdjustRulePO; +import com.engine.salary.entity.salarysob.po.SalarySobPO; +import com.engine.salary.enums.OperateTypeEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.mapper.salarysob.SalarySobAdjustRuleMapper; +import com.engine.salary.mapper.salarysob.SalarySobMapper; +import com.engine.salary.service.SalarySobAdjustRuleService; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.db.MapperProxyFactory; +import com.engine.salary.util.valid.ValidUtil; +import org.apache.commons.collections4.CollectionUtils; + +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Objects; + +/** + * 调薪计薪规则 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SalarySobAdjustRuleServiceImpl extends Service implements SalarySobAdjustRuleService { + + private SalarySobAdjustRuleBiz salarySobAdjustRuleMapper = new SalarySobAdjustRuleBiz(); + + SalarySobMapper getSalarySobMapper(){ + return MapperProxyFactory.getProxy(SalarySobMapper.class); + } + + SalarySobAdjustRuleMapper getSalarySobAdjustRuleMapper(){ + return MapperProxyFactory.getProxy(SalarySobAdjustRuleMapper.class); + } + + + @Override + public List listBySalarySobId(Long salarySobId) { + + if (salarySobId == null) { + return Collections.emptyList(); + } + + return salarySobAdjustRuleMapper.listBySalarySobId(salarySobId); + + } + + @Override + public void save(SalarySobAdjustRuleSaveParam saveParam) { + + ValidUtil.doValidator(saveParam); + + //开启事务 +// SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); +// try { + + // 查询薪资账套 + SalarySobPO salarySobPO = getSalarySobMapper().getById(saveParam.getSalarySobId()); + if (Objects.isNull(salarySobPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98379, "参数错误,薪资账套不存在或者已被删除")); + } + // 删除之前的调薪计薪规则 + getSalarySobAdjustRuleMapper().deleteBySalarySobIds(Collections.singleton(saveParam.getSalarySobId())); + // 保存参数转换成薪资账套的调薪计薪规则po + List salarySobAdjustRulePOS = SalarySobAdjustRuleBO.convert2PO(saveParam, (long) user.getUID()); + // 保存 + if (CollectionUtils.isNotEmpty(salarySobAdjustRulePOS)) { + salarySobAdjustRuleMapper.batchInsert(salarySobAdjustRulePOS); + } + // 记录日志 + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(salarySobPO.getId())); + loggerContext.setTargetName(salarySobPO.getName()); + loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "保存调薪计薪规则")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "保存调薪计薪规则")); + SalaryElogConfig.salarySobLoggerTemplate.write(loggerContext); + } + + @Override + public void batchSave(Collection salarySobAdjustRulePOS) { + salarySobAdjustRuleMapper.batchInsert(salarySobAdjustRulePOS); + } + + @Override + public void deleteBySalarySobIds(Collection salarySobIds) { + salarySobAdjustRuleMapper.deleteBySalarySobIds(salarySobIds); + } +} diff --git a/src/com/engine/salary/service/impl/SalarySobBackItemServiceImpl.java b/src/com/engine/salary/service/impl/SalarySobBackItemServiceImpl.java new file mode 100644 index 000000000..6c59271e9 --- /dev/null +++ b/src/com/engine/salary/service/impl/SalarySobBackItemServiceImpl.java @@ -0,0 +1,154 @@ +package com.engine.salary.service.impl; + +import cn.hutool.core.collection.CollectionUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.entity.salaryformula.ExpressFormula; +import com.engine.salary.entity.salaryformula.config.FormluaConfig; +import com.engine.salary.entity.salaryformula.po.FormulaPO; +import com.engine.salary.entity.salaryformula.po.FormulaVar; +import com.engine.salary.entity.salaryitem.po.SalaryItemPO; +import com.engine.salary.entity.salarysob.bo.SalarySobBackItemBO; +import com.engine.salary.entity.salarysob.dto.SalarySobBackItemDTO; +import com.engine.salary.entity.salarysob.param.SalarySobBackItemSaveParam; +import com.engine.salary.entity.salarysob.po.SalarySobBackItemPO; +import com.engine.salary.entity.salarysob.po.SalarySobPO; +import com.engine.salary.enums.SalaryValueTypeEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.mapper.salarysob.SalarySobBackItemMapper; +import com.engine.salary.service.SalaryFormulaService; +import com.engine.salary.service.SalaryItemService; +import com.engine.salary.service.SalarySobBackItemService; +import com.engine.salary.service.SalarySobService; +import com.engine.salary.util.SalaryDateUtil; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.db.MapperProxyFactory; +import com.google.common.collect.Lists; +import org.apache.commons.lang3.math.NumberUtils; +import weaver.hrm.User; + +import java.time.LocalDateTime; +import java.util.*; + +/** + * @author Harryxzy + * @date 2022/11/15 16:19 + * @description 薪资账套的回算项目 + */ +public class SalarySobBackItemServiceImpl extends Service implements SalarySobBackItemService { + + private SalarySobBackItemMapper getSalarySobBackItemMapper() { + return MapperProxyFactory.getProxy(SalarySobBackItemMapper.class); + } + + private SalarySobService getSalarySobService(User user) { + return ServiceUtil.getService(SalarySobServiceImpl.class, user); + } + + private SalaryItemService getSalaryItemService(User user) { + return ServiceUtil.getService(SalaryItemServiceImpl.class, user); + } + + private SalaryFormulaService getSalaryFormulaService(User user) { + return ServiceUtil.getService(SalaryFormulaServiceImpl.class, user); + } + + @Override + public List listBySalarySobId(Long salarySobId) { + return getSalarySobBackItemMapper().listSome(SalarySobBackItemPO.builder().salarySobId(salarySobId).build()); + } + + @Override + public List listAll() { + return getSalarySobBackItemMapper().listAll(); + } + + @Override + public void batchInsert(List needInsertSalarySobBackItems) { + List> partition = Lists.partition(needInsertSalarySobBackItems, 100); + partition.forEach(getSalarySobBackItemMapper()::batchInsert); + } + + @Override + public SalarySobBackItemPO getById(Long salarySobBackItemId) { + return getSalarySobBackItemMapper().getById(salarySobBackItemId); + } + + @Override + public List save(SalarySobBackItemSaveParam saveParam) { + // 查询薪资账套是否存在 + SalarySobPO salarySobPO = getSalarySobService(user).getById(saveParam.getSalarySobId()); + if (Objects.isNull(salarySobPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98769, "薪资账套不存在或已被删除")); + } + // 查询薪资账套下的回算薪资项目 + SalarySobBackItemPO salarySobBackItem = getById(saveParam.getId()); + if (Objects.isNull(salarySobBackItem)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "回算薪资项目不存在或已被删除")); + } + // 查询薪资项目 + SalaryItemPO salaryItem = getSalaryItemService(user).getById(saveParam.getSalaryItemId()); + if (salaryItem == null) { + throw new SalaryRunTimeException("参数错误,项目不存在或已被删除"); + } + salarySobBackItem.setRoundingMode(saveParam.getRoundingMode().getValue()); + salarySobBackItem.setPattern(saveParam.getPattern()); + salarySobBackItem.setValueType(saveParam.getValueType().getValue()); + salarySobBackItem.setFormulaId(saveParam.getValueType() == SalaryValueTypeEnum.INPUT ? NumberUtils.LONG_ZERO : saveParam.getFormulaId()); + salarySobBackItem.setUpdateTime(SalaryDateUtil.localDateTimeToDate(LocalDateTime.now())); + getSalarySobBackItemMapper().updateIgnoreNull(salarySobBackItem); + + // 查询公式 + List expressFormulas = getSalaryFormulaService(user).listExpressFormula(Collections.singleton(salarySobBackItem.getFormulaId())); + return SalarySobBackItemBO.convert2DTO(Collections.singletonList(salarySobBackItem), Collections.singletonList(salaryItem), expressFormulas); + } + + @Override + public Long getCountBySalarySobIdIn(Collection salarySobIds) { + return getSalarySobBackItemMapper().countBySalarySobIdIn(salarySobIds); + } + + @Override + public int deleteBySalarySobIds(Collection salarySobIds) { + return getSalarySobBackItemMapper().deleteBySalarySobIds(salarySobIds); + } + + @Override + public List listBySalaryItemIds(Collection salaryItemIds) { + return getSalarySobBackItemMapper().listSome(SalarySobBackItemPO.builder().salaryItemIds(salaryItemIds).build()); + } + + @Override + public List getConfig(Long salarySobId) { + List salarySobBackItemPOS = listBySalarySobId(salarySobId); + if (CollectionUtil.isNotEmpty(salarySobBackItemPOS)) { + FormluaConfig config = getSalaryFormulaService(user).getConfig(); + List formulaPOS = config.getFormulas(); + Map formulaMap = SalaryEntityUtil.convert2Map(formulaPOS, FormulaPO::getId); + List formulaVars = config.getFormulaVars(); + Map> varListMap = SalaryEntityUtil.group2Map(formulaVars, FormulaVar::getFormulaId); + + List salaryItems = getSalaryItemService(user).listAll(); + Map itemIdMap = SalaryEntityUtil.convert2Map(salaryItems, SalaryItemPO::getId); + + salarySobBackItemPOS.forEach(po -> { + if (SalaryEntityUtil.isNotNullOrEmpty(po.getFormulaId())) { + FormulaPO formulaPO = formulaMap.get(po.getFormulaId()); + if (SalaryEntityUtil.isNotNullOrEmpty(formulaPO)) { + List formulaVarList = varListMap.getOrDefault(formulaPO.getId(), new ArrayList<>()); + formulaPO.setFormulaVars(formulaVarList); + } + po.setFormula(formulaPO); + } + if(SalaryEntityUtil.isNotNullOrEmpty(po.getSalaryItemId())){ + SalaryItemPO salaryItemPO = itemIdMap.get(po.getSalaryItemId()); + po.setSalaryItem(salaryItemPO); + } + + }); + } + return salarySobBackItemPOS; + } + +} diff --git a/src/com/engine/salary/service/impl/SalarySobCheckRuleServiceImpl.java b/src/com/engine/salary/service/impl/SalarySobCheckRuleServiceImpl.java new file mode 100644 index 000000000..0489b8ab9 --- /dev/null +++ b/src/com/engine/salary/service/impl/SalarySobCheckRuleServiceImpl.java @@ -0,0 +1,199 @@ +package com.engine.salary.service.impl; + +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.biz.SalarySobCheckRuleBiz; +import com.engine.salary.config.SalaryElogConfig; +import com.engine.hrmelog.entity.dto.LoggerContext; +import com.engine.salary.entity.salarysob.bo.SalarySobCheckRuleBO; +import com.engine.salary.entity.salarysob.param.SalarySobCheckRuleQueryParam; +import com.engine.salary.entity.salarysob.param.SalarySobCheckRuleSaveParam; +import com.engine.salary.entity.salarysob.param.UpdateCheckRuleFormulaParam; +import com.engine.salary.entity.salarysob.po.SalarySobCheckRulePO; +import com.engine.salary.entity.salarysob.po.SalarySobPO; +import com.engine.salary.enums.OperateTypeEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.service.SalarySobCheckRuleService; +import com.engine.salary.service.SalarySobService; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.util.valid.RuntimeTypeEnum; +import com.engine.salary.util.valid.ValidUtil; +import org.apache.commons.collections4.CollectionUtils; +import org.springframework.beans.BeanUtils; +import weaver.hrm.User; + +import java.util.*; + +/** + * 薪资账套的校验规则 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SalarySobCheckRuleServiceImpl extends Service implements SalarySobCheckRuleService { + + private SalarySobCheckRuleBiz salarySobCheckRuleMapper = new SalarySobCheckRuleBiz(); + private SalarySobService getSalarySobService(User user) { + return (SalarySobService) ServiceUtil.getService(SalarySobServiceImpl.class, user); + } + + @Override + public SalarySobCheckRulePO getById(Long id) { + return salarySobCheckRuleMapper.getById(id); + } + + @Override + public List listByIds(Collection ids) { + return salarySobCheckRuleMapper.listSome(SalarySobCheckRulePO.builder().ids(ids).build()); + } + + @Override + public List listBySalarySobId(Long salarySobId) { + return salarySobCheckRuleMapper.listSome(SalarySobCheckRulePO.builder().salarySobId(salarySobId).build()); + } + + @Override + public List listBySalarySobIdAndName(Long salarySobId, String name) { + return salarySobCheckRuleMapper.listSome(SalarySobCheckRulePO.builder().salarySobId(salarySobId).name(name).build()); + } + + @Override + public PageInfo listPageByParam(SalarySobCheckRuleQueryParam queryParam) { + + return salarySobCheckRuleMapper.listPageByParam(queryParam); + + } + + @Override + public void save(SalarySobCheckRuleSaveParam saveParam) { + ValidUtil.doValidator(saveParam); + + // 查询薪资账套的校验规则 + List salarySobCheckRulePOS = listBySalarySobIdAndName(saveParam.getSalarySobId(), saveParam.getName()); + if (CollectionUtils.isNotEmpty(salarySobCheckRulePOS)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98629, "名称已经存在")); + } + // 查询薪资账套 + SalarySobPO salarySobPO = getSalarySobService(user).getById(saveParam.getSalarySobId()); + if (Objects.isNull(salarySobPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98379, "参数错误,薪资账套不存在或者已被删除")); + } + // 保存参数转换成薪资账套的校验规则po + SalarySobCheckRulePO salarySobCheckRulePO = SalarySobCheckRuleBO.convert2PO(saveParam, (long) user.getUID()); + // 保存 + salarySobCheckRuleMapper.insert(salarySobCheckRulePO); + //记录日志 + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setTargetId("" + salarySobPO.getId()); + loggerContext.setTargetName(salarySobPO.getName()); + loggerContext.setOperateType(OperateTypeEnum.ADD.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(93872, "添加校验规则")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(93872, "添加校验规则") + ": " + salarySobCheckRulePO.getName()); + loggerContext.setNewValues(salarySobCheckRulePO); + SalaryElogConfig.salarySobLoggerTemplate.write(loggerContext); + } + + @Override + public void batchSave(Collection salarySobCheckRulePOS) { + salarySobCheckRuleMapper.batchInsert(salarySobCheckRulePOS); + } + + @Override + public void update(SalarySobCheckRuleSaveParam updateParam) { + + ValidUtil.doValidator(updateParam, RuntimeTypeEnum.UPDATE); + + // 名称不允许重复 + List salarySobCheckRulePOS = listBySalarySobIdAndName(updateParam.getSalarySobId(), updateParam.getName()); + boolean nameExist = salarySobCheckRulePOS.stream().anyMatch(salarySobCheckRulePO -> !Objects.equals(salarySobCheckRulePO.getId(), updateParam.getId())); + if (nameExist) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98629, "名称已经存在")); + } + // 查询薪资账套的校验规则 + SalarySobCheckRulePO salarySobCheckRulePO = getById(updateParam.getId()); + if (Objects.isNull(salarySobCheckRulePO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98636, "校验规则不存在或者已被删除")); + } + // 查询薪资账套 + SalarySobPO salarySobPO = getSalarySobService(user).getById(updateParam.getSalarySobId()); + if (Objects.isNull(salarySobPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98379, "参数错误,薪资账套不存在或者已被删除")); + } + // 更新 + SalarySobCheckRulePO newSalarySobCheckRulePO = new SalarySobCheckRulePO(); + BeanUtils.copyProperties(salarySobCheckRulePO, newSalarySobCheckRulePO); + newSalarySobCheckRulePO.setName(updateParam.getName()); + newSalarySobCheckRulePO.setFormulaId(updateParam.getFormulaId()); + newSalarySobCheckRulePO.setUpdateTime(new Date()); + salarySobCheckRuleMapper.updateById(newSalarySobCheckRulePO); + //todo 记录日志 + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId("" + salarySobPO.getId()); + loggerContext.setTargetName(salarySobPO.getName()); + loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "编辑校验规则")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "编辑校验规则") + ": " + newSalarySobCheckRulePO.getName()); + loggerContext.setOldValues(salarySobCheckRulePO); + loggerContext.setNewValues(newSalarySobCheckRulePO); + SalaryElogConfig.salarySobLoggerTemplate.write(loggerContext); + } + + @Override + public void updateFormulaId(UpdateCheckRuleFormulaParam updateParam) { + ValidUtil.doValidator(updateParam); + + // 查询薪资账套的校验规则 + SalarySobCheckRulePO salarySobCheckRulePO = getById(updateParam.getId()); + if (Objects.isNull(salarySobCheckRulePO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98636, "校验规则不存在或者已被删除")); + } + // 更新 + SalarySobCheckRuleSaveParam salarySobCheckRuleSaveParam = new SalarySobCheckRuleSaveParam() + .setId(updateParam.getId()) + .setName(salarySobCheckRulePO.getName()) + .setSalarySobId(salarySobCheckRulePO.getSalarySobId()) + .setFormulaId(updateParam.getFormulaId()) + .setDescription(salarySobCheckRulePO.getDescription()); + update(salarySobCheckRuleSaveParam); + } + + @Override + public void deleteByIds(Collection ids) { + // 查询薪资账套的校验规则 + List salarySobCheckRulePOS = listByIds(ids); + if (CollectionUtils.isEmpty(salarySobCheckRulePOS)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98636, "校验规则不存在或者已被删除")); + } + // 删除薪资账套的考验规则 + ids = SalaryEntityUtil.properties(salarySobCheckRulePOS, SalarySobCheckRulePO::getId); + salarySobCheckRuleMapper.deleteByIds(ids); + // 查询薪资账套 + Set salarySobIds = SalaryEntityUtil.properties(salarySobCheckRulePOS, SalarySobCheckRulePO::getSalarySobId); + List salarySobPOS = getSalarySobService(user).listByIds(salarySobIds); + // 将薪资账套list转换成map + Map salarySobPOMap = SalaryEntityUtil.convert2Map(salarySobPOS, SalarySobPO::getId); + //todo 记录日志 + salarySobCheckRulePOS.forEach(salarySobCheckRulePO -> { + SalarySobPO salarySobPO = salarySobPOMap.get(salarySobCheckRulePO.getSalarySobId()); + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId("" + salarySobPO.getId()); + loggerContext.setTargetName(salarySobPO.getName()); + loggerContext.setOperateType(OperateTypeEnum.DELETE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "删除校验规则")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "删除校验规则") + ": " + salarySobCheckRulePO.getName()); + loggerContext.setOldValues(salarySobCheckRulePO); + SalaryElogConfig.salarySobLoggerTemplate.write(loggerContext); + }); + } + + @Override + public void deleteBySalarySobIds(Collection salarySobIds) { + salarySobCheckRuleMapper.deleteBySalarySobIds(salarySobIds); + } +} diff --git a/src/com/engine/salary/service/impl/SalarySobDefaultEmpFieldServiceImpl.java b/src/com/engine/salary/service/impl/SalarySobDefaultEmpFieldServiceImpl.java new file mode 100644 index 000000000..aa63617a8 --- /dev/null +++ b/src/com/engine/salary/service/impl/SalarySobDefaultEmpFieldServiceImpl.java @@ -0,0 +1,26 @@ +package com.engine.salary.service.impl; + +import com.engine.salary.service.SalarySobDefaultEmpFieldService; + +/** + * 薪资账套默认的员工信息字段 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SalarySobDefaultEmpFieldServiceImpl implements SalarySobDefaultEmpFieldService { + +// +// private SalarySobDefaultEmpFieldMapper salarySobDefaultEmpFieldMapper; +// +// @Override +// public List list() { +// +// return new LambdaQueryChainWrapper<>(salarySobDefaultEmpFieldMapper) +// .eq(SalarySobDefaultEmpFieldPO::getTenantKey, SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) +// .eq(SalarySobDefaultEmpFieldPO::getDeleteType, 0) +// .list(); +// } +} diff --git a/src/com/engine/salary/service/impl/SalarySobDefaultItemServiceImpl.java b/src/com/engine/salary/service/impl/SalarySobDefaultItemServiceImpl.java new file mode 100644 index 000000000..a08123118 --- /dev/null +++ b/src/com/engine/salary/service/impl/SalarySobDefaultItemServiceImpl.java @@ -0,0 +1,29 @@ +package com.engine.salary.service.impl; + +import com.engine.core.impl.Service; +import com.engine.salary.biz.SalarySobDefaultItemBiz; +import com.engine.salary.entity.salarysob.po.SalarySobDefaultItemPO; +import com.engine.salary.enums.salarysob.IncomeCategoryEnum; +import com.engine.salary.service.SalarySobDefaultItemService; + +import java.util.List; + +/** + * 薪资账套默认的薪资项目 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SalarySobDefaultItemServiceImpl extends Service implements SalarySobDefaultItemService { + + private SalarySobDefaultItemBiz salarySobDefaultItemMapper = new SalarySobDefaultItemBiz(); + + @Override + public List listByIncomeCategory(IncomeCategoryEnum incomeCategory) { + + return salarySobDefaultItemMapper.listByIncomeCategory(SalarySobDefaultItemPO.builder().incomeCategory(incomeCategory.getValue()).build()); + + } +} diff --git a/src/com/engine/salary/service/impl/SalarySobEmpFieldServiceImpl.java b/src/com/engine/salary/service/impl/SalarySobEmpFieldServiceImpl.java new file mode 100644 index 000000000..aafdcce7a --- /dev/null +++ b/src/com/engine/salary/service/impl/SalarySobEmpFieldServiceImpl.java @@ -0,0 +1,42 @@ +package com.engine.salary.service.impl; + +import com.engine.core.impl.Service; +import com.engine.salary.biz.SalarySobEmpFieldBiz; +import com.engine.salary.entity.salarysob.po.SalarySobEmpFieldPO; +import com.engine.salary.service.SalarySobEmpFieldService; + +import java.util.Collection; +import java.util.List; + +/** + * 薪资账套的员工信息字段 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SalarySobEmpFieldServiceImpl extends Service implements SalarySobEmpFieldService { + + private SalarySobEmpFieldBiz salarySobEmpFieldMapper = new SalarySobEmpFieldBiz(); + + @Override + public List listBySalarySobId(Long salarySobId) { + return salarySobEmpFieldMapper.listSome(SalarySobEmpFieldPO.builder().salarySobId(salarySobId).build()); + } + + @Override + public void batchSave(Collection salarySobEmpFieldPOS) { + salarySobEmpFieldMapper.batchInsert(salarySobEmpFieldPOS); + } + + @Override + public void deleteBySalarySobIds(Collection salarySobIds) { + salarySobEmpFieldMapper.deleteBySalarySobIds(salarySobIds); + } + + @Override + public void deleteByIds(Collection ids) { + salarySobEmpFieldMapper.deleteByIds(ids); + } +} diff --git a/src/com/engine/salary/service/impl/SalarySobExtRangeServiceImpl.java b/src/com/engine/salary/service/impl/SalarySobExtRangeServiceImpl.java new file mode 100644 index 000000000..e959b3fd6 --- /dev/null +++ b/src/com/engine/salary/service/impl/SalarySobExtRangeServiceImpl.java @@ -0,0 +1,129 @@ +package com.engine.salary.service.impl; + +import com.api.formmode.mybatis.util.SqlProxyHandle; +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.constant.SalaryDefaultTenantConstant; +import com.engine.salary.entity.SalarySobExtRangePO; +import com.engine.salary.entity.salarysob.param.SalarySobRangeExtSaveParam; +import com.engine.salary.entity.salarysob.param.SalarySobRangeQueryParam; +import com.engine.salary.entity.salarysob.po.SalarySobPO; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.mapper.salarysob.SalarySobExtRangeMapper; +import com.engine.salary.mapper.sys.SalarySysConfMapper; +import com.engine.salary.service.SalaryEmployeeService; +import com.engine.salary.service.SalarySobExtRangeService; +import com.engine.salary.service.SalarySobService; +import com.engine.salary.service.TaxAgentService; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.util.page.SalaryPageUtil; +import com.engine.salary.util.valid.ValidUtil; +import com.engine.salary.util.db.IdGenerator; +import org.apache.commons.collections4.CollectionUtils; +import weaver.hrm.User; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * 薪资账套人员范围 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SalarySobExtRangeServiceImpl extends Service implements SalarySobExtRangeService { + + + + private SalarySobService getSalarySobService(User user) { + return ServiceUtil.getService(SalarySobServiceImpl.class, user); + } + + private TaxAgentService getTaxAgentService(User user) { + return ServiceUtil.getService(TaxAgentServiceImpl.class, user); + } + + private SalaryEmployeeService getSalaryEmployeeService(User user) { + return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user); + } + + private SalarySysConfMapper getSalarySysConfMapper() { + return SqlProxyHandle.getProxy(SalarySysConfMapper.class); + } + + private SalarySobExtRangeMapper getSalarySobExtRangeMapper() { + return SqlProxyHandle.getProxy(SalarySobExtRangeMapper.class); + } + + + @Override + public List listByIds(Collection ids) { + if (CollectionUtils.isEmpty(ids)) { + return Collections.emptyList(); + } + return getSalarySobExtRangeMapper().listSome(SalarySobExtRangePO.builder().ids(ids).build()); + } + + @Override + public List listBySalarySobId(Long salarySobId) { + if (salarySobId ==null) { + return Collections.emptyList(); + } + return getSalarySobExtRangeMapper().listSome(SalarySobExtRangePO.builder().salarySobId(salarySobId).build()); + } + + + @Override + public void saveExtRange(SalarySobRangeExtSaveParam saveParam) { + ValidUtil.doValidator(saveParam); + + // 查询薪资账套 + SalarySobPO salarySobPO = getSalarySobService(user).getById(saveParam.getSalarySobId()); + if (Objects.isNull(salarySobPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98379, "参数错误,薪资账套不存在或者已被删除")); + } + // 查询已有的人员范围 + List salarySobRangePOS = getSalarySobExtRangeMapper().listSome(SalarySobExtRangePO.builder().salarySobId(saveParam.getSalarySobId()).build()); + // 处理一下本次的保存参数(如果原来添加过对应的人员(/部门/岗位),那么本次不需要新增,只需要更新) + List oldTargetIds = SalaryEntityUtil.properties(salarySobRangePOS, SalarySobExtRangePO::getTargetId, Collectors.toList()); + + List targetIds = saveParam.getTargetIds(); + Date date = new Date(); + if (CollectionUtils.isNotEmpty(targetIds)) { + targetIds.stream().filter(targetId -> !oldTargetIds.contains(targetId)).forEach(targetId -> { + SalarySobExtRangePO po = SalarySobExtRangePO.builder() + .id(IdGenerator.generate()) + .targetType(1) + .salarySobId(saveParam.getSalarySobId()) + .targetId(targetId) + .createTime(date) + .updateTime(date) + .creator((long) user.getUID()) + .deleteType(0) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .build(); + getSalarySobExtRangeMapper().insertIgnoreNull(po); + }); + } + } + + @Override + public PageInfo listPage4Ext(SalarySobRangeQueryParam param) { + List salarySobRangePOS = getSalarySobExtRangeMapper().listPage4Ext(SalarySobExtRangePO.builder().salarySobId(param.getSalarySobId()).build()); + return SalaryPageUtil.buildPage(param.getCurrent(), param.getPageSize(), salarySobRangePOS, SalarySobExtRangePO.class); + } + + + @Override + public void deleteSalarySobExtRange(Collection ids) { + if(CollectionUtils.isEmpty(ids)){ + return; + } + getSalarySobExtRangeMapper().deleteByIds(ids); + } + +} diff --git a/src/com/engine/salary/service/impl/SalarySobItemGroupServiceImpl.java b/src/com/engine/salary/service/impl/SalarySobItemGroupServiceImpl.java new file mode 100644 index 000000000..f5c81e08a --- /dev/null +++ b/src/com/engine/salary/service/impl/SalarySobItemGroupServiceImpl.java @@ -0,0 +1,109 @@ +package com.engine.salary.service.impl; + +import cn.hutool.core.collection.CollectionUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.biz.SalarySobItemGroupBiz; +import com.engine.salary.entity.salaryformula.config.FormluaConfig; +import com.engine.salary.entity.salaryformula.po.FormulaPO; +import com.engine.salary.entity.salaryformula.po.FormulaVar; +import com.engine.salary.entity.salaryitem.po.SalaryItemPO; +import com.engine.salary.entity.salarysob.po.SalarySobItemGroupPO; +import com.engine.salary.entity.salarysob.po.SalarySobItemPO; +import com.engine.salary.service.SalaryFormulaService; +import com.engine.salary.service.SalaryItemService; +import com.engine.salary.service.SalarySobItemGroupService; +import com.engine.salary.service.SalarySobItemService; +import com.engine.salary.util.SalaryEntityUtil; +import weaver.hrm.User; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Map; + +/** + * 薪资账套中的薪资项目分类 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SalarySobItemGroupServiceImpl extends Service implements SalarySobItemGroupService { + + private SalarySobItemGroupBiz salarySobItemGroupMapper = new SalarySobItemGroupBiz(); + + private SalarySobItemService getSalarySobItemService(User user) { + return ServiceUtil.getService(SalarySobItemServiceImpl.class, user); + } + + private SalaryFormulaService getSalaryFormulaService(User user) { + return ServiceUtil.getService(SalaryFormulaServiceImpl.class, user); + } + + private SalaryItemService getSalaryItemService(User user) { + return ServiceUtil.getService(SalaryItemServiceImpl.class, user); + } + + + @Override + public SalarySobItemGroupPO getById(Long id) { + return salarySobItemGroupMapper.getById(id); + } + + @Override + public List listBySalarySobId(Long salarySobId) { + return salarySobItemGroupMapper.listSome(SalarySobItemGroupPO.builder().salarySobId(salarySobId).build()); + } + + @Override + public void batchSave(Collection salarySobItemGroupPOS) { + salarySobItemGroupMapper.batchInsert(salarySobItemGroupPOS); + } + + @Override + public void deleteBySalarySobIds(Collection salarySobIds) { + salarySobItemGroupMapper.deleteBySalarySobIds(salarySobIds); + } + + @Override + public List getConfig(Long salarySobId) { + List salarySobItemGroupPOS = salarySobItemGroupMapper.listSome(SalarySobItemGroupPO.builder().salarySobId(salarySobId).build()); + if (CollectionUtil.isNotEmpty(salarySobItemGroupPOS)) { + List sobItemPOS = getSalarySobItemService(user).listBySalarySobId(salarySobId); + Map> itemListMap = SalaryEntityUtil.group2Map(sobItemPOS, SalarySobItemPO::getSalarySobItemGroupId); + + FormluaConfig config = getSalaryFormulaService(user).getConfig(); + List formulaPOS = config.getFormulas(); + Map formulaMap = SalaryEntityUtil.convert2Map(formulaPOS, FormulaPO::getId); + List formulaVars = config.getFormulaVars(); + Map> varListMap = SalaryEntityUtil.group2Map(formulaVars, FormulaVar::getFormulaId); + + List salaryItems = getSalaryItemService(user).listAll(); + Map itemIdMap = SalaryEntityUtil.convert2Map(salaryItems, SalaryItemPO::getId); + + + salarySobItemGroupPOS.forEach(salarySobItemGroupPO -> { + List salarySobItemPOS = itemListMap.getOrDefault(salarySobItemGroupPO.getId(), new ArrayList<>()); + salarySobItemPOS.forEach(po -> { + if (SalaryEntityUtil.isNotNullOrEmpty(po.getFormulaId())) { + FormulaPO formulaPO = formulaMap.get(po.getFormulaId()); + if (SalaryEntityUtil.isNotNullOrEmpty(formulaPO)) { + List formulaVarList = varListMap.getOrDefault(formulaPO.getId(), new ArrayList<>()); + formulaPO.setFormulaVars(formulaVarList); + } + po.setFormula(formulaPO); + } + if(SalaryEntityUtil.isNotNullOrEmpty(po.getSalaryItemId())){ + SalaryItemPO salaryItemPO = itemIdMap.get(po.getSalaryItemId()); + po.setSalaryItem(salaryItemPO); + } + }); + salarySobItemGroupPO.setSalarySobItems(salarySobItemPOS); + }); + } + + return salarySobItemGroupPOS; + } +} diff --git a/src/com/engine/salary/service/impl/SalarySobItemHideServiceImpl.java b/src/com/engine/salary/service/impl/SalarySobItemHideServiceImpl.java new file mode 100644 index 000000000..f4e6895d2 --- /dev/null +++ b/src/com/engine/salary/service/impl/SalarySobItemHideServiceImpl.java @@ -0,0 +1,28 @@ +package com.engine.salary.service.impl; + +import com.engine.core.impl.Service; +import com.engine.salary.biz.SalarySobItemHideBiz; +import com.engine.salary.entity.salarysob.po.SalarySobItemHidePO; +import com.engine.salary.service.SalarySobItemHideService; + +import java.util.List; + +public class SalarySobItemHideServiceImpl extends Service implements SalarySobItemHideService { + + private SalarySobItemHideBiz salarySobItemHideMapper = new SalarySobItemHideBiz(); + + @Override + public List listHideGroupBysalarySobId(SalarySobItemHidePO salarySobPO) { + return salarySobItemHideMapper.listHideItemIds(salarySobPO); + } + + @Override + public List listSome(SalarySobItemHidePO po) { + return salarySobItemHideMapper.listSome(po); + } + + @Override + public void updateById(SalarySobItemHidePO salarySobItemHidePO) { + salarySobItemHideMapper.update(salarySobItemHidePO); + } +} diff --git a/src/com/engine/salary/service/impl/SalarySobItemServiceImpl.java b/src/com/engine/salary/service/impl/SalarySobItemServiceImpl.java new file mode 100644 index 000000000..9f68de3ae --- /dev/null +++ b/src/com/engine/salary/service/impl/SalarySobItemServiceImpl.java @@ -0,0 +1,617 @@ +package com.engine.salary.service.impl; + +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.hrmelog.entity.dto.LoggerContext; +import com.engine.salary.biz.SalarySobBiz; +import com.engine.salary.biz.SalarySobItemBiz; +import com.engine.salary.biz.SalarySobItemGroupBiz; +import com.engine.salary.biz.SalarySobItemHideBiz; +import com.engine.salary.config.SalaryElogConfig; +import com.engine.salary.constant.SalaryDefaultTenantConstant; +import com.engine.salary.entity.salaryacct.bo.SalaryAcctConfig; +import com.engine.salary.entity.salaryformula.ExpressFormula; +import com.engine.salary.entity.salaryformula.config.FormluaConfig; +import com.engine.salary.entity.salaryformula.po.FormulaPO; +import com.engine.salary.entity.salaryformula.po.FormulaVar; +import com.engine.salary.entity.salaryitem.po.SalaryItemPO; +import com.engine.salary.entity.salarysob.bo.SalarySobItemAggregateBO; +import com.engine.salary.entity.salarysob.dto.SalarySobItemAggregateDTO; +import com.engine.salary.entity.salarysob.dto.SalarySobItemFormDTO; +import com.engine.salary.entity.salarysob.param.SalarySobItemSaveParam; +import com.engine.salary.entity.salarysob.po.*; +import com.engine.salary.entity.taxagent.param.TaxAgentQueryParam; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import com.engine.salary.enums.OperateTypeEnum; +import com.engine.salary.enums.SalaryValueTypeEnum; +import com.engine.salary.enums.auth.AuthFilterTypeEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.mapper.salarysob.SalarySobDefaultItemMapper; +import com.engine.salary.mapper.salarysob.SalarySobEmpFieldMapper; +import com.engine.salary.mapper.salarysob.SalarySobItemMapper; +import com.engine.salary.service.*; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.db.IdGenerator; +import com.engine.salary.util.db.MapperProxyFactory; +import com.engine.salary.util.valid.ValidUtil; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.math.NumberUtils; +import weaver.general.BaseBean; +import weaver.hrm.User; + +import java.util.*; +import java.util.function.Function; +import java.util.stream.Collectors; + +/** + * 薪资账套的薪资项目副本 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Slf4j +public class SalarySobItemServiceImpl extends Service implements SalarySobItemService { + + private SalarySobItemBiz salarySobItemMapper = new SalarySobItemBiz(); + private SalarySobBiz salarySobBiz = new SalarySobBiz(); + + private SalarySobItemGroupBiz salarySobItemGroupBiz = new SalarySobItemGroupBiz(); + private SalarySobItemHideBiz salarySobItemHideBiz = new SalarySobItemHideBiz(); + + private SalarySobEmpFieldMapper getSalarySobEmpFieldMapper() { + return MapperProxyFactory.getProxy(SalarySobEmpFieldMapper.class); + } + + private SalarySobItemMapper getSalarySobItemMapper() { + return MapperProxyFactory.getProxy(SalarySobItemMapper.class); + } + + private SalarySobEmpFieldService getSalarySobEmpFieldService(User user) { + return (SalarySobEmpFieldService) ServiceUtil.getService(SalarySobEmpFieldServiceImpl.class, user); + } + + private TaxAgentService getTaxAgentService(User user) { + return (TaxAgentService) ServiceUtil.getService(TaxAgentServiceImpl.class, user); + } + + private SalarySobItemGroupService getSalarySobItemGroupService(User user) { + return (SalarySobItemGroupService) ServiceUtil.getService(SalarySobItemGroupServiceImpl.class, user); + } + + private SalarySobItemHideService getSalarySobItemHideService(User user) { + return (SalarySobItemHideService) ServiceUtil.getService(SalarySobItemHideServiceImpl.class, user); + } + + private SalaryFormulaService getSalaryFormulaService(User user) { + return (SalaryFormulaService) ServiceUtil.getService(SalaryFormulaServiceImpl.class, user); + } + + private SalaryItemService getSalaryItemService(User user) { + return (SalaryItemService) ServiceUtil.getService(SalaryItemServiceImpl.class, user); + } + + private SalarySobBackItemService getSalarySobBackItemService(User user) { + return (SalarySobBackItemService) ServiceUtil.getService(SalarySobBackItemServiceImpl.class, user); + } + + private SalarySobDefaultItemMapper getSalarySobDefaultItemMapper() { + return MapperProxyFactory.getProxy(SalarySobDefaultItemMapper.class); + } + + private SalaryAcctSobConfigService getSalaryAcctSobConfigService(User user) { + return ServiceUtil.getService(SalaryAcctSobConfigServiceImpl.class, user); + } + + @Override + public List list() { + return salarySobItemMapper.listAll(); + } + + @Override + public List listBySalarySobId(Long salarySobId) { + return salarySobItemMapper.listSome(SalarySobItemPO.builder().salarySobId(salarySobId).build()); + } + + @Override + public List listBySalarySobIdAndGroupId(Long salarySobId, Collection salarySobItemGroupIds) { + return salarySobItemMapper.listBySalarySobIdAndGroupId(salarySobId, salarySobItemGroupIds); + } + + @Override + public List listBySalarySobIds(Collection salarySobIds) { + return salarySobItemMapper.listSome(SalarySobItemPO.builder().salarySobIds(salarySobIds).build()); + } + + @Override + public List listBySalarySobIdAndSalaryItemIdNotIn(Long salarySobId, Collection salaryItemIds) { + return salarySobItemMapper.listSome(SalarySobItemPO.builder().salarySobId(salarySobId).notInSalaryItemIds(salaryItemIds).build()); + } + + @Override + public List listBySalaryItemIds(Collection salaryItemIds) { + if (CollectionUtils.isEmpty(salaryItemIds)) { + return Collections.emptyList(); + } + return salarySobItemMapper.listSome(SalarySobItemPO.builder().salaryItemIds(salaryItemIds).build()); + } + + @Override + public List listBySalarySobId4SalaryItem(Long salarySobId) { + // 查询薪资项目副本 + List salarySobItemPOS = listBySalarySobId(salarySobId); + if (CollectionUtils.isEmpty(salarySobItemPOS)) { + return Collections.emptyList(); + } + // 查询薪资项目 + Set salaryItemIds = SalaryEntityUtil.properties(salarySobItemPOS, SalarySobItemPO::getSalaryItemId); + return getSalaryItemService(user).listByIds(salaryItemIds); + } + + @Override + public SalarySobItemAggregateDTO getAggregateBySalarySobId(Long salarySobId) { + // 查询薪资账套 + SalarySobPO salarySobPO = salarySobBiz.getById(salarySobId); + if (Objects.isNull(salarySobPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98379, "参数错误,薪资账套不存在或者已被删除")); + } + // 查询薪资账套的员工信息字段 + List salarySobEmpFieldPOS = getSalarySobEmpFieldService(user).listBySalarySobId(salarySobId); + // 查询薪资账套的薪资项目分类 + List salarySobItemGroupPOS = getSalarySobItemGroupService(user).listBySalarySobId(salarySobId); + // 查询薪资账套的薪资项目副本 + List salarySobItemPOS = listBySalarySobId(salarySobId); + // 薪资项目副本去重 + salarySobItemPOS = salarySobItemPOS.stream().filter(SalaryEntityUtil.distinctByKey(PO -> PO.getSalarySobId() + "-" + PO.getSalaryItemId())).collect(Collectors.toList()); + // 回算薪资项目 + List salarySobBackItems = getSalarySobBackItemService(user).listBySalarySobId(salarySobId); + // 薪资账套的薪资项目副本所用的公式id + Set formulaIds = SalaryEntityUtil.properties(salarySobItemPOS, SalarySobItemPO::getFormulaId); + // 添加薪资回算项目的公式id + formulaIds.addAll(SalaryEntityUtil.properties(salarySobBackItems, SalarySobBackItemPO::getFormulaId)); + // 查询公式详情 + List expressFormulas = getSalaryFormulaService(user).listExpressFormula(formulaIds); + // 查询薪资账套的薪资项目副本+回算的薪资项目所关联的薪资项目 + Set salaryItemIds = SalaryEntityUtil.properties(salarySobItemPOS, SalarySobItemPO::getSalaryItemId); + Set backCalcItemIds = SalaryEntityUtil.properties(salarySobBackItems, SalarySobBackItemPO::getSalaryItemId); + salaryItemIds.addAll(backCalcItemIds); + + //账套项目分权 + TaxAgentQueryParam param = TaxAgentQueryParam.builder().build(); + param.setFilterType(AuthFilterTypeEnum.QUERY_DATA); + Set ids = getTaxAgentService(user).listAuth(param).stream().map(TaxAgentPO::getId).collect(Collectors.toSet()); + List salaryItemPOS = getSalaryItemService(user).listByIds(salaryItemIds).stream() + .filter(po -> getSalaryItemService(user).filterInRange(ids, po)) + .collect(Collectors.toList()); + + //获取系统值 + List salarySobDefaultItemPOS = getSalarySobDefaultItemMapper().listAll(); + + // 转换成聚合dto + SalarySobItemAggregateBO salarySobItemAggregateBO = new SalarySobItemAggregateBO(salarySobPO, salarySobEmpFieldPOS, + salarySobItemGroupPOS, salarySobItemPOS, expressFormulas, salaryItemPOS, salarySobBackItems, salarySobDefaultItemPOS); + return salarySobItemAggregateBO.convert2AggregateDTO(); + } + + @Override + public SalarySobItemAggregateDTO getAggregateByRecordId(Long salaryAcctRecordId, boolean hideItem) { + SalaryAcctConfig salaryAcctConfig = getSalaryAcctSobConfigService(user).getSalaryAcctConfig(salaryAcctRecordId); + // 查询薪资账套 + SalarySobPO salarySobPO = salaryAcctConfig.getSalarySob(); + if (Objects.isNull(salarySobPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98379, "参数错误,薪资账套不存在或者已被删除")); + } + // 查询薪资账套的员工信息字段 + List salarySobEmpFieldPOS = salaryAcctConfig.getSalarySobEmpFields(); + // 查询薪资账套的薪资项目分类 + List salarySobItemGroupPOS = salaryAcctConfig.getSalarySobItemGroups(); + if (hideItem) { + salarySobItemGroupPOS = salarySobItemGroupPOS.stream().filter(po -> po.getItemHide() == null || po.getItemHide().equals(0L)).collect(Collectors.toList()); + } + // 查询薪资账套的薪资项目副本(已经过滤关闭分类显示按钮的薪资项目) + List salarySobItemPOS = salaryAcctConfig.getSalarySobItems(); + if (hideItem) { + salarySobItemPOS = salarySobItemPOS.stream().filter(po -> po.getItemHide() == null || po.getItemHide().equals(0L)).collect(Collectors.toList()); + } + // 回算薪资项目 + List salarySobBackItems = salaryAcctConfig.getSalarySobBackItems(); + // 薪资账套的薪资项目副本所用的公式id + Set formulaIds = SalaryEntityUtil.properties(salarySobItemPOS, SalarySobItemPO::getFormulaId); + // 添加薪资回算项目的公式id + formulaIds.addAll(SalaryEntityUtil.properties(salarySobBackItems, SalarySobBackItemPO::getFormulaId)); + // 查询公式详情 + List expressFormulas = getSalaryFormulaService(user).listExpressFormula(formulaIds); + // 查询薪资账套的薪资项目副本+回算的薪资项目所关联的薪资项目 + Set salaryItemIds = SalaryEntityUtil.properties(salarySobItemPOS, SalarySobItemPO::getSalaryItemId); + Set backCalcItemIds = SalaryEntityUtil.properties(salarySobBackItems, SalarySobBackItemPO::getSalaryItemId); + salaryItemIds.addAll(backCalcItemIds); + + TaxAgentQueryParam param = TaxAgentQueryParam.builder().build(); + param.setFilterType(AuthFilterTypeEnum.QUERY_DATA); + Set ids = getTaxAgentService(user).listAuth(param).stream().map(TaxAgentPO::getId).collect(Collectors.toSet()); + List salaryItemPOS = getSalaryItemService(user).listByIds(salaryItemIds).stream().filter(po -> getSalaryItemService(user).filterInRange(ids, po)).collect(Collectors.toList()); + + //获取系统值 + List salarySobDefaultItemPOS = getSalarySobDefaultItemMapper().listAll(); + + // 转换成聚合dto + SalarySobItemAggregateBO salarySobItemAggregateBO = new SalarySobItemAggregateBO(salarySobPO, salarySobEmpFieldPOS, salarySobItemGroupPOS, salarySobItemPOS, expressFormulas, salaryItemPOS, salarySobBackItems, salarySobDefaultItemPOS); + return salarySobItemAggregateBO.convert2AggregateDTO(); + } + + @Override + public SalarySobItemAggregateDTO getAggregateWithItemHideBySalarySobId(Long salaryAcctRecordId, Long salarySobId, boolean isBackCalc) { + + SalaryAcctConfig salaryAcctConfig = getSalaryAcctSobConfigService(user).getSalaryAcctConfig(salaryAcctRecordId); + + // 查询薪资账套 + SalarySobPO salarySobPO = salaryAcctConfig.getSalarySob(); + if (Objects.isNull(salarySobPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98379, "参数错误,薪资账套不存在或者已被删除")); + } + // 查询薪资账套的员工信息字段 + List salarySobEmpFieldPOS = salaryAcctConfig.getSalarySobEmpFields(); + + // 查询薪资账套的薪资项目分类 + List salarySobItemGroupPOS = salaryAcctConfig.getSalarySobItemGroups(); + salarySobItemGroupPOS = salarySobItemGroupPOS.stream().filter(po -> po.getItemHide() == null || po.getItemHide().equals(0L)).collect(Collectors.toList()); + + // 查询薪资账套的薪资项目副本(已经过滤关闭分类显示按钮的薪资项目) + List salarySobItemPOS = salaryAcctConfig.getSalarySobItems(); + salarySobItemPOS = salarySobItemPOS.stream().filter(po -> po.getItemHide() == null || po.getItemHide().equals(0L)).collect(Collectors.toList()); + + // 回算薪资项目 + List salarySobBackItems = Collections.emptyList(); + if (isBackCalc) { + salarySobBackItems = salaryAcctConfig.getSalarySobBackItems(); + } + + // 薪资账套的薪资项目副本所用的公式id + Set formulaIds = SalaryEntityUtil.properties(salarySobItemPOS, SalarySobItemPO::getFormulaId); + formulaIds.addAll(salarySobBackItems.stream().map(SalarySobBackItemPO::getFormulaId).collect(Collectors.toList())); + // 查询公式详情 + List expressFormulas = getSalaryFormulaService(user).listExpressFormula(formulaIds); + // 查询薪资账套的薪资项目副本所关联的薪资项目 + Set salaryItemIds = SalaryEntityUtil.properties(salarySobItemPOS, SalarySobItemPO::getSalaryItemId); + Set backCalcItemIds = SalaryEntityUtil.properties(salarySobBackItems, SalarySobBackItemPO::getSalaryItemId); + salaryItemIds.addAll(backCalcItemIds); + List salaryItemPOS = getSalaryItemService(user).listByIds(salaryItemIds); + + + // 转换成聚合dto + SalarySobItemAggregateBO salarySobItemAggregateBO = new SalarySobItemAggregateBO(salarySobPO, salarySobEmpFieldPOS, + salarySobItemGroupPOS, salarySobItemPOS, expressFormulas, salaryItemPOS, salarySobBackItems, Collections.emptyList()); + return salarySobItemAggregateBO.convert2AggregateDTO(); + } + + @Override + public void save(SalarySobItemSaveParam saveParam) { + + Long salarySobId = saveParam.getSalarySobId(); + + // 校验 + validSaveParam(saveParam); + + //保存 + saveSobItem(saveParam); + + SalarySobPO salarySob = salarySobBiz.getById(salarySobId); + + // 记录日志 + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId("" + salarySob.getId()); + loggerContext.setTargetName(salarySob.getName()); + loggerContext.setOperateType(OperateTypeEnum.ADD.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "编辑薪资账套薪资项目")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "编辑薪资账套薪资项目")); + SalaryElogConfig.salarySobLoggerTemplate.write(loggerContext); + } + + /** + * 校验 + */ + private void validSaveParam(SalarySobItemSaveParam saveParam) { + + ValidUtil.doValidator(saveParam); + + //账套存在 + Long salarySobId = saveParam.getSalarySobId(); + SalarySobPO salarySobPO = salarySobBiz.getById(salarySobId); + if (Objects.isNull(salarySobPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98379, "参数错误,薪资账套不存在或者已被删除")); + } + + //员工信息字段不可重复 + List empFields = saveParam.getEmpFields(); + if (CollectionUtils.isNotEmpty(empFields)) { + int count = (int) SalaryEntityUtil.properties(empFields, SalarySobItemSaveParam.SalarySobEmpFieldParam::getFieldId).stream().distinct().count(); + if (count < empFields.size()) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98379, "分类名称重复!")); + } + } else { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98379, "员工信息不能为空!")); + } + + //分类名称唯一 + List itemGroups = saveParam.getItemGroups(); + if (CollectionUtils.isNotEmpty(itemGroups)) { + int count = (int) SalaryEntityUtil.properties(itemGroups, SalarySobItemSaveParam.SalarySobItemGroupParam::getName).stream().distinct().count(); + if (count < itemGroups.size()) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98379, "分类名称重复!")); + } + } + } + + + /** + * 保存项目信息 + * + * @param saveParam + */ + private void saveSobItem(SalarySobItemSaveParam saveParam) { + //分组和薪资项 + handleGroupAndItem(saveParam); + + //处理人员信息字段 + handleEmpField(saveParam); + } + + private void handleGroupAndItem(SalarySobItemSaveParam saveParam) { + long employeeId = (long) user.getUID(); + Date now = new Date(); + Long salarySobId = saveParam.getSalarySobId(); + + List itemGroups = saveParam.getItemGroups(); + List newGroupIds = SalaryEntityUtil.properties(itemGroups, SalarySobItemSaveParam.SalarySobItemGroupParam::getId, Collectors.toList()); + List salarySobItemGroupPOS = getSalarySobItemGroupService(user).listBySalarySobId(salarySobId); + List oldGroupIds = SalaryEntityUtil.properties(salarySobItemGroupPOS, SalarySobItemGroupPO::getId, Collectors.toList()); + List needAddGroup = itemGroups.stream().filter(f -> f.getId() == null).collect(Collectors.toList()); + List needUpdateGroup = itemGroups.stream().filter(f -> f.getId() != null && oldGroupIds.contains(f.getId())).collect(Collectors.toList()); + List needDeleteGroupIds = oldGroupIds.stream().filter(f -> !newGroupIds.contains(f)).collect(Collectors.toList()); + + // 获取所有薪资项目 + List allSalaryItemList = getSalaryItemService(user).listAll(); + Map salaryItemsMap = SalaryEntityUtil.convert2Map(allSalaryItemList, SalaryItemPO::getId); + + //先保存项目分类获,取分类id + Collection salarySobItems = new ArrayList<>(); + for (SalarySobItemSaveParam.SalarySobItemGroupParam itemGroupParam : needAddGroup) { + Long salarySobItemGroupId = IdGenerator.generate(); + SalarySobItemGroupPO salarySobItemGroupPO = SalarySobItemGroupPO.builder().id(salarySobItemGroupId).salarySobId(salarySobId).name(itemGroupParam.getName()).sortedIndex(itemGroupParam.getSortedIndex()).itemHide(itemGroupParam.getItemHide()).description(StringUtils.EMPTY).creator(employeeId).createTime(now).updateTime(now).deleteType(NumberUtils.INTEGER_ZERO).tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY).build(); + //保存分类 + salarySobItemGroupBiz.insert(salarySobItemGroupPO); + + + for (SalarySobItemSaveParam.SalarySobItemParam itemParam : itemGroupParam.getItems()) { + SalaryItemPO salaryItemPO = checkItemExists(itemParam.getSalaryItemId(), salaryItemsMap); + SalarySobItemPO salarySobItemPO = SalarySobItemPO.builder().salarySobId(salarySobId).salaryItemId(itemParam.getSalaryItemId()).salarySobItemGroupId(salarySobItemGroupId).formulaId(Optional.ofNullable(itemParam.getFormulaId()).orElse(NumberUtils.LONG_ZERO)).sortedIndex(itemParam.getSortedIndex()).description(StringUtils.EMPTY).creator(employeeId).createTime(now).updateTime(now).deleteType(NumberUtils.INTEGER_ZERO).tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY).canDelete(itemParam.getCanDelete() == null ? NumberUtils.INTEGER_ONE : (itemParam.getCanDelete() ? NumberUtils.INTEGER_ONE : NumberUtils.INTEGER_ZERO)).roundingMode(itemParam.getRoundingMode() == null ? salaryItemPO.getRoundingMode() : itemParam.getRoundingMode()).pattern(itemParam.getPattern() == null ? salaryItemPO.getPattern() : itemParam.getPattern()).valueType(itemParam.getValueType() == null ? salaryItemPO.getValueType() : itemParam.getValueType()).itemHide(itemParam.getItemHide()).defaultValue(itemParam.getDefaultValue()).build(); + salarySobItems.add(salarySobItemPO); + } + } + + + //更新分组 + for (SalarySobItemSaveParam.SalarySobItemGroupParam itemGroupParam : needUpdateGroup) { + Long groupId = itemGroupParam.getId(); + SalarySobItemGroupPO salarySobItemGroupPO = SalarySobItemGroupPO.builder().id(groupId).name(itemGroupParam.getName()).sortedIndex(itemGroupParam.getSortedIndex()).itemHide(itemGroupParam.getItemHide()).build(); + //更新分类 + salarySobItemGroupBiz.update(salarySobItemGroupPO); + + List items = itemGroupParam.getItems(); + List itemIds = SalaryEntityUtil.properties(items, SalarySobItemSaveParam.SalarySobItemParam::getId, Collectors.toList()); + List oldItems = salarySobItemMapper.listBySalarySobIdAndGroupId(salarySobId, Collections.singleton(groupId)); + List oldItemIds = SalaryEntityUtil.properties(oldItems, SalarySobItemPO::getId, Collectors.toList()); + List needAddItems = items.stream().filter(f -> f.getId() == null).collect(Collectors.toList()); + List needDeleteItemIds = oldItems.stream().filter(f -> !itemIds.contains(f.getId())).map(SalarySobItemPO::getId).collect(Collectors.toList()); + List needUpdateItems = items.stream().filter(f -> f.getId() != null && oldItemIds.contains(f.getId())).collect(Collectors.toList()); + + //新增 + for (SalarySobItemSaveParam.SalarySobItemParam itemParam : needAddItems) { + SalaryItemPO salaryItemPO = checkItemExists(itemParam.getSalaryItemId(), salaryItemsMap); + SalarySobItemPO salarySobItemPO = SalarySobItemPO.builder().salarySobId(salarySobId).salaryItemId(itemParam.getSalaryItemId()).salarySobItemGroupId(groupId).formulaId(Optional.ofNullable(itemParam.getFormulaId()).orElse(NumberUtils.LONG_ZERO)).canDelete(itemParam.getCanDelete() == null ? NumberUtils.INTEGER_ONE : (itemParam.getCanDelete() ? NumberUtils.INTEGER_ONE : NumberUtils.INTEGER_ZERO)).sortedIndex(itemParam.getSortedIndex()).description(StringUtils.EMPTY).creator(employeeId).createTime(now).updateTime(now).tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY).deleteType(NumberUtils.INTEGER_ZERO).roundingMode(itemParam.getRoundingMode() == null ? salaryItemPO.getRoundingMode() : itemParam.getRoundingMode()).pattern(itemParam.getPattern() == null ? salaryItemPO.getPattern() : itemParam.getPattern()).valueType(itemParam.getValueType() == null ? salaryItemPO.getValueType() : itemParam.getValueType()).itemHide(itemParam.getItemHide()).defaultValue(itemParam.getDefaultValue()).build(); + salarySobItems.add(salarySobItemPO); + } + //更新 + for (SalarySobItemSaveParam.SalarySobItemParam itemParam : needUpdateItems) { + SalaryItemPO salaryItemPO = checkItemExists(itemParam.getSalaryItemId(), salaryItemsMap); + SalarySobItemPO salarySobItemPO = SalarySobItemPO.builder().id(itemParam.getId()).salaryItemId(itemParam.getSalaryItemId()).salarySobItemGroupId(groupId).formulaId(Optional.ofNullable(itemParam.getFormulaId()).orElse(NumberUtils.LONG_ZERO)).sortedIndex(itemParam.getSortedIndex()).canDelete(itemParam.getCanDelete() == null ? NumberUtils.INTEGER_ONE : (itemParam.getCanDelete() ? NumberUtils.INTEGER_ONE : NumberUtils.INTEGER_ZERO)).updateTime(now).deleteType(NumberUtils.INTEGER_ZERO).roundingMode(itemParam.getRoundingMode() == null ? salaryItemPO.getRoundingMode() : itemParam.getRoundingMode()).pattern(itemParam.getPattern() == null ? salaryItemPO.getPattern() : itemParam.getPattern()).valueType(itemParam.getValueType() == null ? salaryItemPO.getValueType() : itemParam.getValueType()).itemHide(itemParam.getItemHide()).defaultValue(itemParam.getDefaultValue()).build(); + getSalarySobItemMapper().updateIgnoreNull(salarySobItemPO); + + } + + + //删除 + salarySobItemMapper.deleteByIds(needDeleteItemIds); + + } + + //删除分组 + salarySobItemGroupBiz.deleteByIds(needDeleteGroupIds); + salarySobItemMapper.deleteByGroupIds(needDeleteGroupIds); + + + //未分类 + List items = saveParam.getItems(); + List itemIds = SalaryEntityUtil.properties(items, SalarySobItemSaveParam.SalarySobItemParam::getId, Collectors.toList()); + List oldItems = salarySobItemMapper.listBySalarySobIdAndGroupId(salarySobId, Collections.singleton(0L)); + List oldItemIds = SalaryEntityUtil.properties(oldItems, SalarySobItemPO::getId, Collectors.toList()); + List needAddItems = items.stream().filter(f -> f.getId() == null).collect(Collectors.toList()); + List needDeleteItemIds = oldItems.stream().filter(f -> !itemIds.contains(f.getId())).map(SalarySobItemPO::getId).collect(Collectors.toList()); + List needUpdateItems = items.stream().filter(f -> f.getId() != null && oldItemIds.contains(f.getId())).collect(Collectors.toList()); + + for (SalarySobItemSaveParam.SalarySobItemParam itemParam : needAddItems) { + SalaryItemPO salaryItemPO = checkItemExists(itemParam.getSalaryItemId(), salaryItemsMap); + SalarySobItemPO salarySobItemPO = SalarySobItemPO.builder().salarySobId(salarySobId).salaryItemId(itemParam.getSalaryItemId()).salarySobItemGroupId(NumberUtils.LONG_ZERO).formulaId(Optional.ofNullable(itemParam.getFormulaId()).orElse(NumberUtils.LONG_ZERO)).sortedIndex(itemParam.getSortedIndex()).description(StringUtils.EMPTY).creator(employeeId).createTime(now).updateTime(now).deleteType(NumberUtils.INTEGER_ZERO).tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY).canDelete(itemParam.getCanDelete() == null ? NumberUtils.INTEGER_ONE : (itemParam.getCanDelete() ? NumberUtils.INTEGER_ONE : NumberUtils.INTEGER_ZERO)).roundingMode(itemParam.getRoundingMode() == null ? salaryItemPO.getRoundingMode() : itemParam.getRoundingMode()).pattern(itemParam.getPattern() == null ? salaryItemPO.getPattern() : itemParam.getPattern()).valueType(itemParam.getValueType() == null ? salaryItemPO.getValueType() : itemParam.getValueType()).itemHide(itemParam.getItemHide()).defaultValue(itemParam.getDefaultValue()).build(); + salarySobItems.add(salarySobItemPO); + } + + for (SalarySobItemSaveParam.SalarySobItemParam itemParam : needUpdateItems) { + SalaryItemPO salaryItemPO = checkItemExists(itemParam.getSalaryItemId(), salaryItemsMap); + SalarySobItemPO salarySobItemPO = SalarySobItemPO.builder().id(itemParam.getId()).formulaId(Optional.ofNullable(itemParam.getFormulaId()).orElse(NumberUtils.LONG_ZERO)).sortedIndex(itemParam.getSortedIndex()).updateTime(now).canDelete(itemParam.getCanDelete() == null ? NumberUtils.INTEGER_ONE : (itemParam.getCanDelete() ? NumberUtils.INTEGER_ONE : NumberUtils.INTEGER_ZERO)).roundingMode(itemParam.getRoundingMode() == null ? salaryItemPO.getRoundingMode() : itemParam.getRoundingMode()).pattern(itemParam.getPattern() == null ? salaryItemPO.getPattern() : itemParam.getPattern()).valueType(itemParam.getValueType() == null ? salaryItemPO.getValueType() : itemParam.getValueType()).itemHide(itemParam.getItemHide()).defaultValue(itemParam.getDefaultValue()).build(); + getSalarySobItemMapper().updateIgnoreNull(salarySobItemPO); + } + + if (CollectionUtils.isNotEmpty(needDeleteItemIds)) { + getSalarySobItemMapper().deleteByIds(needDeleteItemIds); + } + + // 保存薪资账套的薪资项目副本 + batchSave(salarySobItems); + + // 删除原薪资项目是否显示 + deleteItemShowBySalarySobIds(Collections.singleton(salarySobId)); + } + + private SalaryItemPO checkItemExists(Long salaryItemId, Map salaryItemsMap) { + SalaryItemPO salaryItemPO = salaryItemsMap.get(salaryItemId); + if (salaryItemPO == null) { + log.error("薪资项目:{}不存在", salaryItemId); + throw new SalaryRunTimeException("保存失败!存在薪资项目不存在或已被删除"); + } + return salaryItemPO; + } + + + private void handleEmpField(SalarySobItemSaveParam saveParam) { + long employeeId = (long) user.getUID(); + Date now = new Date(); + Long salarySobId = saveParam.getSalarySobId(); + + List empFields = saveParam.getEmpFields(); + List newEmpIds = SalaryEntityUtil.properties(empFields, SalarySobItemSaveParam.SalarySobEmpFieldParam::getId, Collectors.toList()); + List salarySobEmpFieldPOS = getSalarySobEmpFieldService(user).listBySalarySobId(salarySobId); + List needDeleteEmpIds = salarySobEmpFieldPOS.stream().filter(f -> !newEmpIds.contains(f.getId())).map(SalarySobEmpFieldPO::getId).collect(Collectors.toList()); + + // 保存薪资账套的员工信息字段 + Collection needInsertSalarySobEmpFields = new ArrayList<>(); + for (SalarySobItemSaveParam.SalarySobEmpFieldParam salarySobEmpFieldParam : empFields) { + if (salarySobEmpFieldParam.getId() == null) { + SalarySobEmpFieldPO salarySobEmpFieldPO = SalarySobEmpFieldPO.builder().salarySobId(saveParam.getSalarySobId()).fieldCode(salarySobEmpFieldParam.getFieldId()).sortedIndex(salarySobEmpFieldParam.getSortedIndex()).canDelete(salarySobEmpFieldParam.getCanDelete() ? NumberUtils.INTEGER_ONE : NumberUtils.INTEGER_ZERO).creator(employeeId).createTime(now).updateTime(now).deleteType(NumberUtils.INTEGER_ZERO).tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY).build(); + needInsertSalarySobEmpFields.add(salarySobEmpFieldPO); + } else { + SalarySobEmpFieldPO salarySobEmpFieldPO = SalarySobEmpFieldPO.builder().id(salarySobEmpFieldParam.getId()).sortedIndex(salarySobEmpFieldParam.getSortedIndex()).updateTime(now).build(); + getSalarySobEmpFieldMapper().updateIgnoreNull(salarySobEmpFieldPO); + } + + } + getSalarySobEmpFieldService(user).batchSave(needInsertSalarySobEmpFields); + //删除字段 + getSalarySobEmpFieldService(user).deleteByIds(needDeleteEmpIds); + } + + @Override + public void batchSave(Collection salarySobItemPOS) { + if (CollectionUtils.isEmpty(salarySobItemPOS)) { + return; + } + //前端可能传重复数据,去重 + List list = new ArrayList<>(salarySobItemPOS.stream().collect(Collectors.toMap(SalarySobItemPO::getSalaryItemId, Function.identity(), (oldValue, newValue) -> oldValue)).values()); + salarySobItemMapper.batchInsert(list); + } + + @Override + public void deleteBySalarySobIds(Collection salarySobIds) { + salarySobItemMapper.deleteBySalarySobIds(salarySobIds); + } + + @Override + public void deleteItemShowBySalarySobIds(Collection salarySobIds) { + salarySobItemMapper.deleteItemShowBySalarySobId(salarySobIds); + } + + @Override + public void update(SalarySobItemPO po) { + salarySobItemMapper.update(po); + } + + @Override + public List getConfig(Long salarySobId) { + List salarySobItemPOS = salarySobItemMapper.listSome(SalarySobItemPO.builder().salarySobId(salarySobId).salarySobItemGroupId(0L).build()); + if (CollectionUtils.isNotEmpty(salarySobItemPOS)) { + FormluaConfig config = getSalaryFormulaService(user).getConfig(); + List formulaPOS = config.getFormulas(); + Map formulaMap = SalaryEntityUtil.convert2Map(formulaPOS, FormulaPO::getId); + List formulaVars = config.getFormulaVars(); + Map> varListMap = SalaryEntityUtil.group2Map(formulaVars, FormulaVar::getFormulaId); + + List salaryItems = getSalaryItemService(user).listAll(); + Map itemIdMap = SalaryEntityUtil.convert2Map(salaryItems, SalaryItemPO::getId); + + salarySobItemPOS.forEach(salarySobItemPO -> { + if (SalaryEntityUtil.isNotNullOrEmpty(salarySobItemPO.getFormulaId())) { + FormulaPO formulaPO = formulaMap.get(salarySobItemPO.getFormulaId()); + if (SalaryEntityUtil.isNotNullOrEmpty(formulaPO)) { + List formulaVarList = varListMap.getOrDefault(formulaPO.getId(), new ArrayList<>()); + formulaPO.setFormulaVars(formulaVarList); + } + salarySobItemPO.setFormula(formulaPO); + } + if(SalaryEntityUtil.isNotNullOrEmpty(salarySobItemPO.getSalaryItemId())){ + SalaryItemPO salaryItemPO = itemIdMap.get(salarySobItemPO.getSalaryItemId()); + salarySobItemPO.setSalaryItem(salaryItemPO); + } + }); + } + return salarySobItemPOS; + } + + @Override + public SalarySobItemFormDTO getSalaryItemForm(SalarySobItemPO param) { + SalarySobItemFormDTO salarySobItemFormDTO = new SalarySobItemFormDTO(); + salarySobItemFormDTO.setCanEdit(1); + // 默认可以编辑 + if (param.getSalarySobId() != null && param.getSalaryItemId() != null) { + // 查询薪资账套 + SalarySobPO salarySobPO = salarySobBiz.getById(param.getSalarySobId()); + if (Objects.isNull(salarySobPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98379, "参数错误,薪资账套不存在或者已被删除")); + } + // 查询薪资项目 + List salarySobItemPOS = getSalarySobItemMapper().listSome(SalarySobItemPO.builder().salarySobId(param.getSalarySobId()).salaryItemId(param.getSalaryItemId()).build()); + if (CollectionUtils.isEmpty(salarySobItemPOS)) { + throw new SalaryRunTimeException("账套中薪资项目不存在"); + } + SalarySobItemPO salarySobItemPO = salarySobItemPOS.get(0); + SalaryItemPO salaryItemPO = getSalaryItemService(user).getById(salarySobItemPO.getSalaryItemId()); + if (salaryItemPO == null) { + throw new SalaryRunTimeException("薪资项目不存在或已被删除"); + } + //获取系统值 + List salarySobDefaultItemPOS = getSalarySobDefaultItemMapper().listAll(); + salarySobDefaultItemPOS = salarySobDefaultItemPOS.stream().filter(po -> po.getSysSalaryItemId() != 0).collect(Collectors.toList()); + Map longIntegerMap = SalaryEntityUtil.convert2Map(salarySobDefaultItemPOS, SalarySobDefaultItemPO::getSysSalaryItemId, SalarySobDefaultItemPO::getCanDelete); + if (salaryItemPO.getSysSalaryItemId() != null) { + salarySobItemPO.setCanDelete(longIntegerMap.getOrDefault(salaryItemPO.getSysSalaryItemId(), 1)); + } + // 获取薪资项目公式 + List expressFormulas = getSalaryFormulaService(user).listExpressFormula(Collections.singleton(salarySobItemPO.getFormulaId())); + // 强制开启账套的公式配置 + BaseBean baseBean = new BaseBean(); + final Boolean openFormulaForcedEditing = "true".equals(baseBean.getPropValue("hrmSalary", "openFormulaForcedEditing")); + + String formulaContent = CollectionUtils.isEmpty(expressFormulas) ? "" : expressFormulas.get(0).getFormula(); + Integer valueType = salarySobItemPO.getValueType() == null ? salaryItemPO.getValueType() : salarySobItemPO.getValueType(); + salarySobItemFormDTO + .setId(salarySobItemPO.getId()) + .setName(salaryItemPO.getName()) + .setItemHide(salarySobItemPO.getItemHide()==null?0:Integer.parseInt(salarySobItemPO.getItemHide().toString())) + .setDataType(salaryItemPO.getDataType()) + .setRoundingMode(salarySobItemPO.getRoundingMode() == null ? salaryItemPO.getRoundingMode() : salarySobItemPO.getRoundingMode()) + .setPattern(salarySobItemPO.getPattern() == null ? salaryItemPO.getPattern() : salarySobItemPO.getPattern()) + .setValueType(valueType).setFormulaId(salarySobItemPO.getFormulaId()) + .setFormulaContent(CollectionUtils.isNotEmpty(expressFormulas) ? formulaContent : "") + .setOriginFormulaContent(valueType.equals(SalaryValueTypeEnum.FORMULA.getValue()) ? formulaContent : "") + .setOriginSqlContent(valueType.equals(SalaryValueTypeEnum.SQL.getValue()) ? formulaContent : "") + .setUseInEmployeeSalary(salaryItemPO.getUseInEmployeeSalary()) + .setDescription(salarySobItemPO.getDescription()) + .setCanEdit((openFormulaForcedEditing || salaryItemPO.getCanEdit().equals(1)) ? 1 : 0) + .setDefaultValue(salarySobItemPO.getDefaultValue()); + } + return salarySobItemFormDTO; + } +} diff --git a/src/com/engine/salary/service/impl/SalarySobRangeServiceImpl.java b/src/com/engine/salary/service/impl/SalarySobRangeServiceImpl.java new file mode 100644 index 000000000..185964526 --- /dev/null +++ b/src/com/engine/salary/service/impl/SalarySobRangeServiceImpl.java @@ -0,0 +1,548 @@ +package com.engine.salary.service.impl; + +import com.api.formmode.mybatis.util.SqlProxyHandle; +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.hrm.biz.OrganizationShowSetBiz; +import com.engine.hrmelog.entity.dto.LoggerContext; +import com.engine.salary.biz.SalarySobRangeBiz; +import com.engine.salary.biz.SpecialAddDeductionBiz; +import com.engine.salary.config.SalaryElogConfig; +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.hrm.DeptInfo; +import com.engine.salary.entity.hrm.PositionInfo; +import com.engine.salary.entity.hrm.SubCompanyInfo; +import com.engine.salary.entity.salarysob.bo.SalarySobRangeBO; +import com.engine.salary.entity.salarysob.bo.SalarySobRangeSaveBO; +import com.engine.salary.entity.salarysob.dto.SalarySobRangeImportListDTO; +import com.engine.salary.entity.salarysob.dto.SalarySobRangeListDTO; +import com.engine.salary.entity.salarysob.param.SalarySobRangeImportParam; +import com.engine.salary.entity.salarysob.param.SalarySobRangeQueryParam; +import com.engine.salary.entity.salarysob.param.SalarySobRangeSaveParam; +import com.engine.salary.entity.salarysob.po.SalarySobPO; +import com.engine.salary.entity.salarysob.po.SalarySobRangePO; +import com.engine.salary.entity.taxagent.dto.TaxAgentManageRangeEmployeeDTO; +import com.engine.salary.enums.OperateTypeEnum; +import com.engine.salary.enums.UserStatusEnum; +import com.engine.salary.enums.salarysob.SalaryEmployeeStatusEnum; +import com.engine.salary.enums.salarysob.TargetTypeEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.mapper.salarysob.SalarySobExtRangeMapper; +import com.engine.salary.mapper.sys.SalarySysConfMapper; +import com.engine.salary.service.SalaryEmployeeService; +import com.engine.salary.service.SalarySobRangeService; +import com.engine.salary.service.SalarySobService; +import com.engine.salary.service.TaxAgentService; +import com.engine.salary.sys.entity.po.SalarySysConfPO; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.excel.ExcelComment; +import com.engine.salary.util.excel.ExcelParseHelper; +import com.engine.salary.util.excel.ExcelUtil; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.util.page.SalaryPageUtil; +import com.engine.salary.util.valid.RuntimeTypeEnum; +import com.engine.salary.util.valid.ValidUtil; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.Validate; +import org.apache.poi.util.IOUtils; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import weaver.file.ImageFileManager; +import weaver.general.Util; +import weaver.hrm.User; + +import java.io.InputStream; +import java.util.*; +import java.util.stream.Collectors; + +/** + * 薪资账套人员范围 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SalarySobRangeServiceImpl extends Service implements SalarySobRangeService { + + private SalarySobRangeBiz salarySobRangeBiz = new SalarySobRangeBiz(); + private OrganizationShowSetBiz orgBiz = new OrganizationShowSetBiz(); + + + private SalarySobService getSalarySobService(User user) { + return (SalarySobService) ServiceUtil.getService(SalarySobServiceImpl.class, user); + } + + private TaxAgentService getTaxAgentService(User user) { + return ServiceUtil.getService(TaxAgentServiceImpl.class, user); + } + + private SalaryEmployeeService getSalaryEmployeeService(User user) { + return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user); + } + + private SalarySysConfMapper getSalarySysConfMapper() { + return SqlProxyHandle.getProxy(SalarySysConfMapper.class); + } + + private SalarySobExtRangeMapper getSalarySobExtRangeMapper() { + return SqlProxyHandle.getProxy(SalarySobExtRangeMapper.class); + } + @Override + public List listByIds(Collection ids) { + if (CollectionUtils.isEmpty(ids)) { + return Collections.emptyList(); + } + return salarySobRangeBiz.listSome(SalarySobRangePO.builder().ids(ids).build()); + } + + @Override + public List listBySalarySobIdAndIncludeType(Long salarySobId, Integer includeType) { + return salarySobRangeBiz.listSome(SalarySobRangePO.builder().salarySobId(salarySobId).includeType(includeType).build()); + } + + @Override + public List listAllSalarySobRange() { + return salarySobRangeBiz.listSome(SalarySobRangePO.builder().build()); + } + + @Override + public PageInfo listPageByParamAndIncludeType(SalarySobRangeQueryParam queryParam, Integer includeType) { + // 查询人员范围 + List salarySobRangePOS = listBySalarySobIdAndIncludeType(queryParam.getSalarySobId(), includeType); + // 查询人员信息 + List employeeIds = salarySobRangePOS.stream() + .filter(e -> Objects.equals(e.getTargetType(), TargetTypeEnum.EMPLOYEE.getValue())) + .map(SalarySobRangePO::getTargetId) + .collect(Collectors.toList()); + List empInfos = getSalaryEmployeeService(user).getEmployeeByIds(employeeIds); + + + // 查询部门信息 + List deptInfos = salarySobRangePOS.stream() + .filter(e -> Objects.equals(e.getTargetType(), TargetTypeEnum.DEPT.getValue())) + .map(SalarySobRangePO::getTargetId) + .map(id -> { + return DeptInfo.builder().id(id).name(orgBiz.getDepartmentShow(String.valueOf(id), "0", "-")).build(); + }) + .collect(Collectors.toList()); + + // 查询分部信息 + List subCompanyInfos = salarySobRangePOS.stream() + .filter(e -> Objects.equals(e.getTargetType(), TargetTypeEnum.SUBCOMPANY.getValue())) + .map(SalarySobRangePO::getTargetId) + .map(id -> { + return SubCompanyInfo.builder().id(id).name(orgBiz.getSubcompanyShow(String.valueOf(id), "0", "-")).build(); + }) + .collect(Collectors.toList()); + + + // 查询岗位信息 + List positionIds = salarySobRangePOS.stream() + .filter(e -> Objects.equals(e.getTargetType(), TargetTypeEnum.POSITION.getValue())) + .map(SalarySobRangePO::getTargetId) + .collect(Collectors.toList()); + List positionInfos = getSalaryEmployeeService(user).listPositionInfo(positionIds); + + // 薪资账套的人员范围po转换成列表dto + List salarySobRangeListDTOS = SalarySobRangeBO.convert2ListDTO(salarySobRangePOS, empInfos, deptInfos, subCompanyInfos, positionInfos); + // 根据对象名称过滤 + if (StringUtils.isNotEmpty(queryParam.getTargetName())) { + salarySobRangeListDTOS = salarySobRangeListDTOS.stream() + .filter(salarySobRangeListDTO -> salarySobRangeListDTO.getTargetName().contains(queryParam.getTargetName())) + .collect(Collectors.toList()); + } + // 填充总数和当页数据 + PageInfo pageInfo = new PageInfo(salarySobRangeListDTOS, SalarySobRangeListDTO.class); + pageInfo.setTotal(salarySobRangeListDTOS.size()); + pageInfo.setList(SalaryPageUtil.subList(queryParam.getCurrent(), queryParam.getPageSize(), salarySobRangeListDTOS)); + pageInfo.setPageNum(queryParam.getCurrent()); + pageInfo.setPageSize(queryParam.getPageSize()); + return pageInfo; + } + + @Override + public void save(SalarySobRangeSaveParam saveParam) { + + ValidUtil.doValidator(saveParam); + + // 查询薪资账套 + SalarySobPO salarySobPO = getSalarySobService(user).getById(saveParam.getSalarySobId()); + if (Objects.isNull(salarySobPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98379, "参数错误,薪资账套不存在或者已被删除")); + } + // 查询已有的人员范围 + List salarySobRangePOS = listBySalarySobIdAndIncludeType(saveParam.getSalarySobId(), saveParam.getIncludeType()); + // 处理一下本次的保存参数(如果原来添加过对应的人员(/部门/岗位),那么本次不需要新增,只需要更新) + SalarySobRangeSaveBO.Result result = SalarySobRangeSaveBO.handle(salarySobRangePOS, saveParam, (long) user.getUID(), false); + // 保存 + if (CollectionUtils.isNotEmpty(result.getNeedInsertSalarySobRanges())) { + salarySobRangeBiz.batchInsert(result.getNeedInsertSalarySobRanges()); + } + if (CollectionUtils.isNotEmpty(result.getNeedUpdateSalarySobRanges())) { + result.getNeedUpdateSalarySobRanges().forEach(e -> salarySobRangeBiz.updateById(e)); + } + //记录日志 + String operateTypeName = Objects.equals(saveParam.getIncludeType(), 1) ? + SalaryI18nUtil.getI18nLabel(0, "关联人员范围新增对象") : SalaryI18nUtil.getI18nLabel(0, "从范围中排除新增对象"); + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId("" + salarySobPO.getId()); + loggerContext.setTargetName(salarySobPO.getName()); + loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue()); + loggerContext.setOperateTypeName(operateTypeName); + loggerContext.setOperatedesc(operateTypeName); + loggerContext.setNewValues(saveParam); + SalaryElogConfig.salarySobLoggerTemplate.write(loggerContext); + } + + @Override + public void edit(SalarySobRangeSaveParam param) { + ValidUtil.doValidator(param, RuntimeTypeEnum.UPDATE); + + // 查询薪资账套 + SalarySobPO salarySobPO = getSalarySobService(user).getById(param.getSalarySobId()); + if (Objects.isNull(salarySobPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98379, "参数错误,薪资账套不存在或者已被删除")); + } + + deleteByIds(Collections.singleton(param.getId())); + + // 查询已有的人员范围 + List salarySobRangePOS = listBySalarySobIdAndIncludeType(param.getSalarySobId(), param.getIncludeType()); + // 处理一下本次的保存参数(如果原来添加过对应的人员(/部门/岗位),那么本次不需要新增,只需要更新) + SalarySobRangeSaveBO.Result result = SalarySobRangeSaveBO.handle(salarySobRangePOS, param, (long) user.getUID(), false); + // 保存 + if (CollectionUtils.isNotEmpty(result.getNeedInsertSalarySobRanges())) { + salarySobRangeBiz.batchInsert(result.getNeedInsertSalarySobRanges()); + } + if (CollectionUtils.isNotEmpty(result.getNeedUpdateSalarySobRanges())) { + result.getNeedUpdateSalarySobRanges().forEach(e -> salarySobRangeBiz.updateById(e)); + } + //记录日志 + String operateTypeName = Objects.equals(param.getIncludeType(), 1) ? + SalaryI18nUtil.getI18nLabel(0, "关联人员范围新增对象") : SalaryI18nUtil.getI18nLabel(0, "从范围中排除新增对象"); + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId("" + salarySobPO.getId()); + loggerContext.setTargetName(salarySobPO.getName()); + loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue()); + loggerContext.setOperateTypeName(operateTypeName); + loggerContext.setOperatedesc(operateTypeName); + loggerContext.setNewValues(param); + SalaryElogConfig.salarySobLoggerTemplate.write(loggerContext); + } + + @Override + public void deleteByIds(Collection ids) { + // 查询薪资账套的人员范围 + List salarySobRangePOS = listByIds(ids); + Map> rangeMap = SalaryEntityUtil.group2Map(salarySobRangePOS, SalarySobRangePO::getSalarySobId); + if (CollectionUtils.isEmpty(salarySobRangePOS)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98604, "数据不存在或已被删除")); + } + ids = SalaryEntityUtil.properties(salarySobRangePOS, SalarySobRangePO::getId); + // 删除薪资账套的人员范围 + salarySobRangeBiz.deleteByIds(ids); + // 查询薪资账套 + Set salarySobIds = SalaryEntityUtil.properties(salarySobRangePOS, SalarySobRangePO::getSalarySobId); + List salarySobPOS = getSalarySobService(user).listByIds(salarySobIds); + // 是"关联人员范围"还是"从范围中排除" + Integer includeType = salarySobRangePOS.get(0).getIncludeType(); + //记录日志 + String operateTypeName = Objects.equals(includeType, 1) ? + SalaryI18nUtil.getI18nLabel(0, "关联人员范围删除对象") : SalaryI18nUtil.getI18nLabel(0, "从范围中排除删除对象"); + salarySobPOS.forEach(salarySobPO -> { + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId("" + salarySobPO.getId()); + loggerContext.setTargetName(salarySobPO.getName()); + loggerContext.setOperateType(OperateTypeEnum.DELETE.getValue()); + loggerContext.setOperateTypeName(operateTypeName); + loggerContext.setOperatedesc(operateTypeName); + loggerContext.setOldValueList(rangeMap.getOrDefault(salarySobPO.getId(), Collections.emptyList())); + SalaryElogConfig.salarySobLoggerTemplate.write(loggerContext); + }); + } + + @Override + public void deleteBySalarySobIds(Collection salarySobIds) { + salarySobRangeBiz.deleteBySalarySobIds(salarySobIds); + } + + @Override + public void updateEmployeeStatuses(SalarySobRangePO item) { + salarySobRangeBiz.updateEmployeeStatuses(item); + } + + @Override + public XSSFWorkbook downloadTemplateRange() { + //获取操作按钮资源 + List> rowList = getExcelRowList(); + //查询对于人员信息导入筛选的全局配置 + SalarySysConfPO salarySysConfPO = getSalarySysConfMapper().getOneByCode("matchEmployeeMode"); + String confValue = (salarySysConfPO != null && salarySysConfPO.getConfValue() != null && !"".equals(salarySysConfPO.getConfValue())) ? salarySysConfPO.getConfValue() : "0"; + // 注释 + List excelComments = Lists.newArrayList(); + if (confValue.equals("0")) { + excelComments.add(new ExcelComment(0, 0, 1, 2, SalaryI18nUtil.getI18nLabel(100344, "必填"))); + } else if(confValue.equals("1")){ + excelComments.add(new ExcelComment(3, 0, 4, 2, SalaryI18nUtil.getI18nLabel(100344, "必填"))); + } else if(confValue.equals("2")){ + excelComments.add(new ExcelComment(4, 0, 5, 2, SalaryI18nUtil.getI18nLabel(100344, "必填"))); + } + excelComments.add(new ExcelComment(5, 0, 7, 3, SalaryI18nUtil.getI18nLabel(100344, "若不填,默认全部员工状态。指定员工状态格式:试用、正式、临时、试用延期"))); + + + //获取excel + return ExcelUtil.genWorkbookV2(rowList, "薪资账套人员范围", excelComments); + } + + @Override + public Map importData(SalarySobRangeImportParam importParam) { + Boolean openDevolution = getTaxAgentService(user).isOpenDevolution(); + + long currentEmployeeId = user.getUID(); + Map apidatas = new HashMap(); + SpecialAddDeductionBiz SpecialAddDeductionBiz = new SpecialAddDeductionBiz(); + + //查询对于人员信息导入筛选的全局配置 + SalarySysConfPO salarySysConfPO = getSalarySysConfMapper().getOneByCode("matchEmployeeMode"); + String confValue = (salarySysConfPO != null && salarySysConfPO.getConfValue() != null && !"".equals(salarySysConfPO.getConfValue())) ? salarySysConfPO.getConfValue() : "0"; + + //检验参数 + checkImportParam(importParam); + + //excel文件id + String imageId = Util.null2String(importParam.getImageId()); + //薪资账套ID + String salarySobIdStr = Util.null2String(importParam.getSalarySobId()); + Long salarySobId = SalaryEntityUtil.string2Long(salarySobIdStr); + + // 查询薪资账套 + SalarySobPO salarySobPO = getSalarySobService(user).getById(salarySobId); + if (Objects.isNull(salarySobPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98379, "参数错误,薪资账套不存在或者已被删除")); + } + + InputStream fileInputStream = null; + try { + fileInputStream = ImageFileManager.getInputStreamById(Integer.parseInt(imageId)); + List salarySobRangeImportLists = ExcelParseHelper.parse2Map(fileInputStream, SalarySobRangeImportListDTO.class, 0, 1, 6, "SpecialAddDeductionTemplate.xlsx"); + + int total = salarySobRangeImportLists.size(); + int index = 0; + int successCount = 0; + int errorCount = 0; + + //人员信息 + List employees = getSalaryEmployeeService(user).listEmployee(); + // 获取所有个税扣缴义务人 + Collection taxAgentList = getTaxAgentService(user).listTaxAgentAndEmployeeTree(currentEmployeeId); + // 错误excel内容 + List errorData = new ArrayList<>(); + //合规数据 + List eligibleData = new ArrayList<>(); + for (int i = 0; i < salarySobRangeImportLists.size(); i++) { + SalarySobRangeImportListDTO dto = salarySobRangeImportLists.get(i); + + //待插入数据库对象 + SalarySobRangeSaveParam.SalarySobRangeTargetParam po = new SalarySobRangeSaveParam.SalarySobRangeTargetParam(); + po.setTargetType(TargetTypeEnum.EMPLOYEE); + + //异常点数量 + int errorSum = 0; + + //行号 + String rowIndex = String.format("第%s行", i + 2); + + //相同的姓名 + String userName = dto.getUsername(); + String deparmentName = dto.getDepartmentName(); + String mobile = dto.getMobile(); + String workcode = dto.getJobNum(); + String idNo = dto.getIdNo(); + String employeeStatusStr = dto.getEmployeeStatus(); + List employeeSameIds = new ArrayList<>(); + + //筛选导入人员信息可以在人力资源池中匹配到的人员信息 + List emps = getSalaryEmployeeService(user) + .matchImportEmployee(confValue,employees, userName, deparmentName, mobile, workcode, idNo,null); + //含在职和离职,选在职数据 + if (CollectionUtils.isNotEmpty(emps) && emps.size() > 1) { + employeeSameIds = emps.stream() + .filter(e -> UserStatusEnum.getNormalStatus().contains(e.getStatus())) + .map(DataCollectionEmployee::getEmployeeId) + .collect(Collectors.toList()); + } + if (CollectionUtils.isNotEmpty(emps) && emps.size() == 1) { + employeeSameIds = emps.stream() + .map(DataCollectionEmployee::getEmployeeId) + .collect(Collectors.toList()); + } + + //当人员信息导入筛选的全局配置为"0"时,姓名才是必填项 + if (StringUtils.isBlank(userName) && "0".equals(confValue)) { + //姓名 不能为空 + //错误消息对象 + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowIndex + "姓名不能为空"); + errorData.add(errorMessageMap); + errorSum += 1; + } else if (CollectionUtils.isEmpty(employeeSameIds) || employeeSameIds.size() > 1) { + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowIndex + "员工信息不存在或者存在多个员工"); + errorData.add(errorMessageMap); + errorSum += 1; + } else { + Long employeeId = CollectionUtils.isNotEmpty(employeeSameIds) && employeeSameIds.size() == 1 ? employeeSameIds.get(0) : null; + if (employeeId != null && employeeId > 0) { + po.setTargetId(employeeId); + } else { + //姓名错误,系统内不存在该姓名 + Map errorMessageMap = new HashMap<>(); + errorMessageMap.put("message", rowIndex + "姓名错误,系统内不存在该姓名"); + errorData.add(errorMessageMap); + errorSum += 1; + } + } + + // 设置员工状态 + if (StringUtils.isEmpty(employeeStatusStr)) { + SalaryEmployeeStatusEnum[] values = SalaryEmployeeStatusEnum.values(); + po.setEmployeeStatus(SalaryEmployeeStatusEnum.values()); + } else { + Boolean[] haveError = {false}; + // 人员状态字符串转换为对应的value + SalaryEmployeeStatusEnum[] status = SalaryEmployeeStatusEnum.getEnumsParseByFormatStr(employeeStatusStr, haveError); + if (haveError[0]) { + Map errorMessageMap = new HashMap<>(); + errorMessageMap.put("message", rowIndex + "员工状态不存在,或格式有误。格式为:试用、正式、临时、试用延期"); + errorData.add(errorMessageMap); + errorSum += 1; + } else { + po.setEmployeeStatus(status); + } + } + + //fixme 分权判断 + if (errorSum == 0) { + successCount += 1; + // 合格数据 + eligibleData.add(po); + } else { + errorCount += 1; + // 添加错误数据 + } + } + + // 入库 + eligibleData = handleImportData(eligibleData); + // 查询已有的人员范围 + List salarySobRangePOS = listBySalarySobIdAndIncludeType(salarySobId, 1); + SalarySobRangeSaveParam saveParam = new SalarySobRangeSaveParam(); + saveParam.setTargetParams(eligibleData); +// saveParam.setEmployeeStatus( SalaryEmployeeStatusEnum.values()); + saveParam.setIncludeType(1); + saveParam.setSalarySobId(salarySobId); + // 处理一下本次的保存参数(如果原来添加过对应的人员(/部门/岗位),那么本次不需要新增,只需要更新) + SalarySobRangeSaveBO.Result result = SalarySobRangeSaveBO.handle(salarySobRangePOS, saveParam, (long) user.getUID(), true); + // 保存 + if (CollectionUtils.isNotEmpty(result.getNeedInsertSalarySobRanges())) { + salarySobRangeBiz.batchInsert(result.getNeedInsertSalarySobRanges()); + } + if (CollectionUtils.isNotEmpty(result.getNeedUpdateSalarySobRanges())) { + result.getNeedUpdateSalarySobRanges().forEach(e -> salarySobRangeBiz.updateById(e)); + } + List logList = new ArrayList<>(); + logList.addAll(result.getNeedInsertSalarySobRanges()); + logList.addAll(result.getNeedUpdateSalarySobRanges()); + //记录日志 + if (CollectionUtils.isNotEmpty(logList)) { + String operateTypeName = SalaryI18nUtil.getI18nLabel(0, "关联人员范围导入"); + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId("" + salarySobPO.getId()); + loggerContext.setTargetName(salarySobPO.getName()); + loggerContext.setOperateType(OperateTypeEnum.EXCEL_IMPORT.getValue()); + loggerContext.setOperateTypeName(operateTypeName); + loggerContext.setOperatedesc(operateTypeName); + loggerContext.setNewValueList(logList); + SalaryElogConfig.salarySobLoggerTemplate.write(loggerContext); + } + apidatas.put("successCount", successCount); + apidatas.put("errorCount", errorCount); + apidatas.put("errorData", errorData); + + } finally { + IOUtils.closeQuietly(fileInputStream); + } + return apidatas; + } + + // 处理导入数据 + private List handleImportData(List pos) { + if (CollectionUtils.isEmpty(pos)) { + return Collections.emptyList(); + } + // 多条相同人的则以第一条为准,如果逆序排列(用于重复的则以最后一条为准)Collections.reverse(pos); + // 去重(通过记录的唯一条件(人员id) + List finalPos = pos.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(f -> f.getTargetId()))), ArrayList::new)); + return finalPos; + } + + private void checkImportParam(SalarySobRangeImportParam importParam) { + //excel文件id + String imageId = Util.null2String(importParam.getImageId()); + + if (StringUtils.isBlank(imageId)) { + throw new SalaryRunTimeException("文件不存在"); + } + if (StringUtils.isBlank(importParam.getSalarySobId())) { + throw new SalaryRunTimeException("薪资账套ID为空"); + } + } + + @Override + public Map preview(SalarySobRangeImportParam importParam) { + Map apidatas = new HashMap(); + + //excel文件id + String imageId = Util.null2String(importParam.getImageId()); + Validate.notBlank(imageId, "imageId为空"); + + InputStream fileInputStream = null; + try { + fileInputStream = ImageFileManager.getInputStreamById(Integer.parseInt(imageId)); + List salarySobRangeImportList = ExcelParseHelper.parse2Map(fileInputStream, SalarySobRangeImportListDTO.class, 0, 1, 6, "TaxAgentEmployee.xlsx"); + apidatas.put("preview", salarySobRangeImportList); + } finally { + IOUtils.closeQuietly(fileInputStream); + } + return apidatas; + } + + + /** + * @return List> + * @description 获取excel数据行 + * @author Harryxzy + * @date 2023/1/9 11:37 + */ + private List> getExcelRowList() { + // 表头 + List headers = Lists.newArrayList(); + headers.add(SalaryI18nUtil.getI18nLabel(85429, "姓名")); + headers.add(SalaryI18nUtil.getI18nLabel(86185, "部门")); + headers.add(SalaryI18nUtil.getI18nLabel(86186, "手机号")); + headers.add(SalaryI18nUtil.getI18nLabel(86317, "工号")); + headers.add(SalaryI18nUtil.getI18nLabel(86317, "证件号码")); + headers.add(SalaryI18nUtil.getI18nLabel(86318, "员工状态")); + List> rowList = new ArrayList<>(); + rowList.add(headers); + return rowList; + } +} diff --git a/src/com/engine/salary/service/impl/SalarySobServiceImpl.java b/src/com/engine/salary/service/impl/SalarySobServiceImpl.java new file mode 100644 index 000000000..e25f15343 --- /dev/null +++ b/src/com/engine/salary/service/impl/SalarySobServiceImpl.java @@ -0,0 +1,1014 @@ +package com.engine.salary.service.impl; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.util.StrUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.hrmelog.entity.dto.LoggerContext; +import com.engine.salary.biz.*; +import com.engine.salary.config.SalaryElogConfig; +import com.engine.salary.constant.SalaryDefaultTenantConstant; +import com.engine.salary.entity.salaryBill.po.SalaryTemplatePO; +import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO; +import com.engine.salary.entity.salaryitem.bo.SysSalaryItemBO; +import com.engine.salary.entity.salaryitem.po.SalaryItemPO; +import com.engine.salary.entity.salaryitem.po.SysSalaryItemPO; +import com.engine.salary.entity.salarysob.bo.*; +import com.engine.salary.entity.salarysob.config.SalarySobConfig; +import com.engine.salary.entity.salarysob.dto.SalarySobCycleDTO; +import com.engine.salary.entity.salarysob.param.*; +import com.engine.salary.entity.salarysob.po.*; +import com.engine.salary.entity.taxagent.po.TaxAgentExtRangePO; +import com.engine.salary.entity.taxagent.po.TaxAgentManageRangePO; +import com.engine.salary.enums.OperateTypeEnum; +import com.engine.salary.enums.SalarySystemTypeEnum; +import com.engine.salary.enums.auth.AuthFilterTypeEnum; +import com.engine.salary.enums.salarysob.IncomeCategoryEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.mapper.salarysob.SalarySobMapper; +import com.engine.salary.mapper.salarysob.SobTaxLinkMapper; +import com.engine.salary.mapper.taxagent.TaxAgentExtRangeMapper; +import com.engine.salary.service.*; +import com.engine.salary.service.auth.AuthService; +import com.engine.salary.service.auth.AuthServiceImpl; +import com.engine.salary.sys.entity.vo.UploadConfigResponse; +import com.engine.salary.sys.enums.TaxDeclarationFunctionEnum; +import com.engine.salary.sys.service.SalarySysConfService; +import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.db.IdGenerator; +import com.engine.salary.util.db.MapperProxyFactory; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.util.page.SalaryPageUtil; +import com.engine.salary.util.valid.RuntimeTypeEnum; +import com.engine.salary.util.valid.ValidUtil; +import com.google.common.collect.Lists; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.math.NumberUtils; +import org.springframework.beans.BeanUtils; +import weaver.hrm.User; + +import java.time.YearMonth; +import java.util.*; +import java.util.function.Function; +import java.util.stream.Collectors; + +/** + * 薪资账套 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Slf4j +public class SalarySobServiceImpl extends Service implements SalarySobService { + + + private SalarySobBiz salarySobMapper = new SalarySobBiz(); + private SalarySobRangeBiz salarySobRangeService = new SalarySobRangeBiz(); + private SalarySobEmpFieldBiz empFieldBiz = new SalarySobEmpFieldBiz(); + private SalarySobDefaultItemGroupBiz defaultItemGroupBiz = new SalarySobDefaultItemGroupBiz(); + private SalarySobEmpFieldBiz salarySobEmpFieldService = new SalarySobEmpFieldBiz(); + private SalarySobDefaultItemBiz salarySobDefaultItemService = new SalarySobDefaultItemBiz(); + private SalarySobItemBiz salarySobItemService = new SalarySobItemBiz(); + private SalarySobItemGroupBiz salarySobItemGroupService = new SalarySobItemGroupBiz(); + + private SalarySobItemHideBiz salarySobItemHideService = new SalarySobItemHideBiz(); + + private SalarySobRangeBiz salarySobRangeBiz = new SalarySobRangeBiz(); + +// private SalarySobBackItemMapper getSalarySobBackItemMapper() { +// return MapperProxyFactory.getProxy(SalarySobBackItemMapper.class); +// } + + private SalarySobItemService getSalarySobItemService(User user) { + return ServiceUtil.getService(SalarySobItemServiceImpl.class, user); + } + + private SalarySobItemGroupService getSalarySobItemGroupService(User user) { + return ServiceUtil.getService(SalarySobItemGroupServiceImpl.class, user); + } + + private SalarySobEmpFieldService getSalarySobEmpFieldService(User user) { + return ServiceUtil.getService(SalarySobEmpFieldServiceImpl.class, user); + } + + private SalarySobAdjustRuleService getSalarySobAdjustRuleService(User user) { + return ServiceUtil.getService(SalarySobAdjustRuleServiceImpl.class, user); + } + + private SalaryFormulaService getSalaryFormulaService(User user) { + return ServiceUtil.getService(SalaryFormulaServiceImpl.class, user); + } + + + private SalarySobMapper getSalarySobMapper() { + return MapperProxyFactory.getProxy(SalarySobMapper.class); + } + + private TaxAgentExtRangeMapper getTaxAgentExtRangeMapper() { + return MapperProxyFactory.getProxy(TaxAgentExtRangeMapper.class); + } + + private SobTaxLinkMapper getSobTaxLinkMapper() { + return MapperProxyFactory.getProxy(SobTaxLinkMapper.class); + } + + + private SalarySobExtRangeService getSalarySobExtRangeService(User user) { + return ServiceUtil.getService(SalarySobExtRangeServiceImpl.class, user); + } + + private SalaryItemService getSalaryItemService(User user) { + return ServiceUtil.getService(SalaryItemServiceImpl.class, user); + } + + private SysSalaryItemService getSysSalaryItemService(User user) { + return ServiceUtil.getService(SysSalaryItemServiceImpl.class, user); + } + + private SalarySobAdjustRuleBiz salarySobAdjustRuleService = new SalarySobAdjustRuleBiz(); + + private SalarySobCheckRuleService getSalarySobCheckRuleService(User user) { + return ServiceUtil.getService(SalarySobCheckRuleServiceImpl.class, user); + } + + private SalaryAcctRecordService getSalaryAcctRecordService(User user) { + return ServiceUtil.getService(SalaryAcctRecordServiceImpl.class, user); + } + + private TaxAgentService getTaxAgentService(User user) { + return ServiceUtil.getService(TaxAgentServiceImpl.class, user); + } + + private TaxAgentAdminService getTaxAgentAdminService(User user) { + return ServiceUtil.getService(TaxAgentAdminServiceImpl.class, user); + } + + private TaxAgentManageRangeService getTaxAgentManageRangeService(User user) { + return ServiceUtil.getService(TaxAgentManageRangeServiceImpl.class, user); + } + + private SalarySobBackItemService getSalarySobBackItemService(User user) { + return ServiceUtil.getService(SalarySobBackItemServiceImpl.class, user); + } + + private SalaryTemplateService getSalaryTemplateService(User user) { + return ServiceUtil.getService(SalaryTemplateServiceImpl.class, user); + } + + private SalarySysConfService getSalarySysConfService(User user) { + return ServiceUtil.getService(SalarySysConfServiceImpl.class, user); + } + + public AuthService getAuthService(User user) { + return ServiceUtil.getService(AuthServiceImpl.class, user); + } + + private SalaryApprovalRuleService getSalaryApprovalRuleService(User user) { + return ServiceUtil.getService(SalaryApprovalRuleServiceImpl.class, user); + } + + @Override + public SalarySobPO getById(Long id) { + handleHistory(); + return getSalarySobMapper().getById(id); + } + + + @Override + public List listByIds(Collection ids) { + if (CollectionUtils.isEmpty(ids)) { + return Collections.emptyList(); + } + return getSalarySobMapper().listSome(SalarySobPO.builder().ids(ids).build()); + } + + @Override + public List listByName(String name) { + if (StringUtils.isEmpty(name)) { + return Collections.emptyList(); + } + List salarySobPOS = salarySobMapper.listByName(SalarySobPO.builder().name(name).build()); + return salarySobPOS; + } + + @Override + public List listByNameLike(String nameLike) { + if (StringUtils.isEmpty(nameLike)) { + return Collections.emptyList(); + } + List salarySobPOS = salarySobMapper.listByParam(SalarySobPO.builder().name(nameLike).build()); + return getAuthService(user).auth(salarySobPOS, AuthFilterTypeEnum.DATA_OPT, SalarySobPO.class); + } + + @Override + public List listByDisable(Integer disable) { + List salarySobPOS = salarySobMapper.listSome(SalarySobPO.builder().disable(disable).build()); + return getAuthService(user).auth(salarySobPOS, AuthFilterTypeEnum.DATA_OPT, SalarySobPO.class); + } + + @Override + public List listAll() { + return salarySobMapper.listSome(SalarySobPO.builder().build()); + } + + @Override + public List listAuth(SalarySobQueryParam param) { + // 开启分权后需要过滤薪资账套 + String name = param.getName(); + // 查询所有的薪资账套 + SalarySobPO build = SalarySobPO.builder().build(); + if (StringUtils.isNotBlank(name)) { + build.setName(name); + } + if (param.getTaxAgentId() != null) { + List sobTaxLinkPOS = getSobTaxLinkMapper().listSome(SobTaxLinkPO.builder().taxAgentId(param.getTaxAgentId()).build()); + build.setIds(sobTaxLinkPOS.stream().map(SobTaxLinkPO::getTaxAgentId).collect(Collectors.toList())); + } + + if(CollectionUtil.isNotEmpty(param.getTaxAgentIds())){ + List sobTaxLinkPOS = getSobTaxLinkMapper().listSome(SobTaxLinkPO.builder().taxAgentIds(param.getTaxAgentIds()).build()); + build.setIds(sobTaxLinkPOS.stream().map(SobTaxLinkPO::getTaxAgentId).collect(Collectors.toList())); + } + + List list = getSalarySobMapper().listSome(build); + return getAuthService(user).auth(list, param.getFilterType(), SalarySobPO.class); + } + + @Override + public List listByAdmin() { + List salarySobPOS = salarySobMapper.listSome(SalarySobPO.builder().build()); + return getAuthService(user).auth(salarySobPOS, AuthFilterTypeEnum.QUERY_DATA, SalarySobPO.class); + } + + @Override + public List listByTaxAgentId(Long taxAgentId) { + return getSalarySobMapper().listByTaxAgentId(taxAgentId); + } + + @Override + public List listByIncomeCategory(IncomeCategoryEnum incomeCategory) { + return salarySobMapper.listSome(SalarySobPO.builder().incomeCategory(incomeCategory.getValue()).build()); + } + + @Override + public PageInfo listPageByParam(SalarySobListQueryParam queryParam) { + // 开启分权后需要过滤薪资账套 + String name = queryParam.getName(); + // 查询所有的薪资账套 + SalarySobPO build = SalarySobPO.builder().build(); + if (StringUtils.isNotBlank(name)) { + build.setName(name); + } + if (queryParam.getTaxAgentId() != null) { + List sobTaxLinkPOS = getSobTaxLinkMapper().listSome(SobTaxLinkPO.builder().taxAgentId(queryParam.getTaxAgentId()).build()); + build.setIds(sobTaxLinkPOS.stream().map(SobTaxLinkPO::getSobId).collect(Collectors.toList())); + } + + List list = getSalarySobMapper().listSome(build); + + list = getAuthService(user).auth(list, AuthFilterTypeEnum.DATA_OPT, SalarySobPO.class); + + return SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), list, SalarySobPO.class); + } + + @Override + public List listByParam(SalarySobListQueryParam queryParam) { + + String name = queryParam.getName(); + // 查询所有的薪资账套 + SalarySobPO build = SalarySobPO.builder().build(); + if (StringUtils.isNotBlank(name)) { + build.setName(name); + } + if (queryParam.getTaxAgentId() != null) { + List sobTaxLinkPOS = getSobTaxLinkMapper().listSome(SobTaxLinkPO.builder().taxAgentId(queryParam.getTaxAgentId()).build()); + build.setIds(sobTaxLinkPOS.stream().map(SobTaxLinkPO::getTaxAgentId).collect(Collectors.toList())); + } + + List list = salarySobMapper.listSome(build); + + return getAuthService(user).auth(list, AuthFilterTypeEnum.DATA_OPT, SalarySobPO.class); + } + + @Override + public Long save(SalarySobBasicSaveParam saveParam) { + + ValidUtil.doValidator(saveParam); + + // 薪资账套的名称不能重复 + List salarySobPOS = listByName(saveParam.getName()); + if (CollectionUtils.isNotEmpty(salarySobPOS)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98403, "薪资账套名称已存在")); + } + + // 保存参数转换成薪资账套po + SalarySobPO salarySobPO = SalarySobBO.convert2PO(saveParam, (long) user.getUID()); + // 保存薪资账套 + salarySobMapper.insert(salarySobPO); + // 记录日志 + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(salarySobPO.getId())); + loggerContext.setTargetName(salarySobPO.getName()); + loggerContext.setOperateType(OperateTypeEnum.ADD.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "新建薪资账套")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "新建薪资账套") + ": " + salarySobPO.getName()); + loggerContext.setNewValues(salarySobPO); + SalaryElogConfig.salarySobLoggerTemplate.write(loggerContext); + + //保存个税扣缴义务人联系 + saveSobTaxLink(saveParam.getTaxAgentIds(), salarySobPO); + // 新建薪资账套时,保存默认的员工信息字段 + saveDefaultEmpField(salarySobPO); + // 新建薪资账套时,保存默认的薪资项目 + saveDefaultItem(salarySobPO); + // 新建薪资账套时,保存默认的关联人员范围及从范围中排除 + saveDefaultEmployeeRange(salarySobPO); + // 返回薪资账套的主键id + return salarySobPO.getId(); + } + + private void saveSobTaxLink(List taxAgentIds, SalarySobPO salarySobPO) { + getSobTaxLinkMapper().deleteBySobId(salarySobPO.getId()); + for (Long taxAgentId : taxAgentIds) { + SobTaxLinkPO taxLinkPO = SobTaxLinkPO.builder() + .id(IdGenerator.generate()) + .taxAgentId(taxAgentId) + .sobId(salarySobPO.getId()) + .creator((long) user.getUID()) + .createTime(new Date()) + .updateTime(new Date()) + .deleteType(0) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .build(); + getSobTaxLinkMapper().insertIgnoreNull(taxLinkPO); + } + } + + + /** + * 新建薪资账套时,保存默认的员工信息字段 + * + * @param salarySobPO 薪资账套 + */ + private void saveDefaultEmpField(SalarySobPO salarySobPO) { + // 查询薪资账套默认的员工信息字段 + List salarySobDefaultEmpFieldPOS = empFieldBiz.listDefaultEmpField(); + // 转换成薪资账套员工信息字段po + List salarySobEmpFieldPOS = SalarySobItemBO.convert2EmpFieldPO(salarySobPO.getId(), salarySobDefaultEmpFieldPOS, (long) user.getUID()); + // 保存 + empFieldBiz.batchInsert(salarySobEmpFieldPOS); + } + + /** + * 新建薪资账套时,保存默认的薪资项目 + * 1、薪资账套默认引用的系统薪资项目 + * 2、自定义薪资项目中开启了"默认使用"的薪资项目 + * + * @param salarySobPO 薪资账套 + */ + private void saveDefaultItem(SalarySobPO salarySobPO) { + // 1、根据薪资类型查询薪资账套默认使用的薪资项目分类以及薪资项目 + IncomeCategoryEnum incomeCategoryEnum = IncomeCategoryEnum.parseByValue(salarySobPO.getIncomeCategory()); + List salarySobDefaultItemGroupPOS = defaultItemGroupBiz.listByIncomeCategory(incomeCategoryEnum); + List salarySobDefaultItemPOS = salarySobDefaultItemService.listByIncomeCategory(SalarySobDefaultItemPO.builder().incomeCategory(incomeCategoryEnum.getValue()).build()); + + //是否需要系统算税,不需要则去除系统项目 + TaxDeclarationFunctionEnum taxDeclarationFunctionEnum = getSalarySysConfService(user).getTaxDeclaration(); + if (taxDeclarationFunctionEnum == TaxDeclarationFunctionEnum.CLOSURE) { + salarySobDefaultItemGroupPOS = new ArrayList<>(); + salarySobDefaultItemPOS = new ArrayList<>(); + } + + // 2、薪资账套默认引用的系统薪资项目如果没有添加到薪资项目中,这里要给添加保存 + // 2.1、查询已经添加到薪资项目中的系统薪资项目 + Set defaultSysSalaryItemIds = SalaryEntityUtil.properties(salarySobDefaultItemPOS, SalarySobDefaultItemPO::getSysSalaryItemId); + // 薪资账套的默认的回算薪资项目 + Set SalarySobBackItemIds = SalaryEntityUtil.properties(SalarySobBackItemBO.getDefault(), SalarySobDefaultBackItemPO::getSysSalaryItemId); + defaultSysSalaryItemIds.addAll(SalarySobBackItemIds); + + List salaryItemPOS = getSalaryItemService(user).listBySysSalaryItemIds(defaultSysSalaryItemIds); + Set sysSalaryItemIds = SalaryEntityUtil.properties(salaryItemPOS, SalaryItemPO::getSysSalaryItemId); + // 2.2、需要添加进薪资项目中的系统薪资项目id + Set needAddSysSalaryItemIds = salarySobDefaultItemPOS.stream() + .map(SalarySobDefaultItemPO::getSysSalaryItemId) + .filter(sysSalaryItemId -> !sysSalaryItemIds.contains(sysSalaryItemId)) + .collect(Collectors.toSet()); + // 需要添加进薪资项目中的回算薪资项目 + needAddSysSalaryItemIds.addAll(SalarySobBackItemIds.stream().filter(salarySobBackItemId -> !sysSalaryItemIds.contains(salarySobBackItemId)).collect(Collectors.toList())); + List needAddSysSalaryItemPOS = getSysSalaryItemService(user).listByIds(needAddSysSalaryItemIds); + // 2.3、需要保存的薪资项目 + List needInsertSalaryItemPOS = SysSalaryItemBO.convert2SalaryItemPO(needAddSysSalaryItemPOS, (long) user.getUID()); + if (CollectionUtils.isNotEmpty(needInsertSalaryItemPOS)) { + getSalaryItemService(user).batchSave(needInsertSalaryItemPOS); + } + + // 3、查询开启了"默认使用"的自定义薪资项目 + List useDefaultSalaryItemPOS = getSalaryItemService(user).listBySystemTypeAndUseDefault(SalarySystemTypeEnum.CUSTOM, NumberUtils.INTEGER_ONE); + + // 4、默认引用的薪资项目(=薪资账套默认引用的系统薪资项目(已添加进薪资项目中的) + 薪资账套默认引用的系统薪资项目(待添加进薪资项目中的) + 自定义薪资项目中开启了"默认使用"的薪资项目) + List defaultSalaryItemPOS = Lists.newArrayListWithExpectedSize(salaryItemPOS.size() + needInsertSalaryItemPOS.size() + useDefaultSalaryItemPOS.size()); + defaultSalaryItemPOS.addAll(salaryItemPOS); + defaultSalaryItemPOS.addAll(needInsertSalaryItemPOS); + defaultSalaryItemPOS.addAll(useDefaultSalaryItemPOS); + + // 5、保存 + SalarySobItemBO.Result result = SalarySobItemBO.initSalarySobItem(salarySobPO.getId(), salarySobDefaultItemGroupPOS, salarySobDefaultItemPOS, defaultSalaryItemPOS, (long) user.getUID(), SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY); + if (CollectionUtils.isNotEmpty(result.getNeedInsertSalarySobItems())) { + + List list = new ArrayList<>(result.getNeedInsertSalarySobItems().stream().collect(Collectors.toMap(SalarySobItemPO::getSalaryItemId, Function.identity(), (oldValue, newValue) -> oldValue)).values()); + + salarySobItemService.batchInsert(list); + } + if (CollectionUtils.isNotEmpty(result.getNeedInsertSalarySobItemGroups())) { + salarySobItemGroupService.batchInsert(result.getNeedInsertSalarySobItemGroups()); + } + if (CollectionUtils.isNotEmpty(result.getNeedInsertSalarySobBackItems())) { + getSalarySobBackItemService(user).batchInsert(result.getNeedInsertSalarySobBackItems()); + } + } + + /** + * @return void + * @description 新建薪资账套时,保存默认的关联人员范围及从范围中排除 + * @author Harryxzy + * @date 2022/10/9 15:30 + */ + public void saveDefaultEmployeeRange(SalarySobPO salarySobPO) { + Long sobId = salarySobPO.getId(); + salarySobPO = getById(sobId); + + salarySobPO.getTaxAgentIds().forEach(taxAgentId -> { + // 获取人员范围列表 + List includeList = getTaxAgentManageRangeService(user).listByTaxAgentIdAndIncludeType(taxAgentId, NumberUtils.INTEGER_ONE); + includeList.forEach(item -> { + item.setEmployeeStatus(parseJson2ValueStr(item.getEmployeeStatus())); + }); + // 获取从范围中排除 + List excludeList = getTaxAgentManageRangeService(user).listByTaxAgentIdAndIncludeType(taxAgentId, NumberUtils.INTEGER_ZERO); + excludeList.forEach(item -> { + item.setEmployeeStatus(parseJson2ValueStr(item.getEmployeeStatus())); + }); + // 将TaxAgentManageRangeListDTO转换为SalarySobRangePO + List rangeList = convert2SalarySobRangePO(sobId, includeList, excludeList); + // 保存SalarySobRangePO + if (CollectionUtils.isNotEmpty(rangeList)) { + salarySobRangeBiz.batchInsert(rangeList); + } + + //非系统人员 + List taxAgentExtRangePOS = getTaxAgentExtRangeMapper().listSome(TaxAgentExtRangePO.builder().taxAgentId(taxAgentId).build()); + taxAgentExtRangePOS.forEach(po -> { + SalarySobRangeExtSaveParam build = SalarySobRangeExtSaveParam.builder().salarySobId(sobId).targetIds(Collections.singletonList(po.getTargetId())).targetType(1L).build(); + getSalarySobExtRangeService(user).saveExtRange(build); + }); + }); + + + } + + + /** + * @return List + * @description 将TaxAgentManageRangeListDTO转换为SalarySobRangePO + * @author Harryxzy + * @date 2022/10/9 16:06 + */ + private List convert2SalarySobRangePO(Long salarySobID, List includeList, List excludeList) { + Date now = new Date(); + ArrayList result = new ArrayList(); + // 关联人员范围 + includeList.stream().forEach(item -> { + SalarySobRangePO salarySobRangePO = SalarySobRangePO.builder() + .salarySobId(salarySobID) + .targetType(item.getTargetType()) + .targetId(item.getTargetId()) + .target(item.getTarget()) + .employeeStatuses(item.getEmployeeStatus()) + .includeType(1) + .creator(Long.valueOf(user.getUID())) + .createTime(now) + .updateTime(now) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .deleteType(0) + .build(); + result.add(salarySobRangePO); + }); + // 从范围中排除 + excludeList.stream().forEach(item -> { + SalarySobRangePO salarySobRangePO = SalarySobRangePO.builder() + .salarySobId(salarySobID) + .targetType(item.getTargetType()) + .targetId(item.getTargetId()) + .target(item.getTarget()) + .employeeStatuses(item.getEmployeeStatus()) + .includeType(0) + .creator(Long.valueOf(user.getUID())) + .createTime(now) + .updateTime(now) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .deleteType(0) + .build(); + result.add(salarySobRangePO); + }); + return result; + } + + + /** + * ["0","1","2","3","4","5","6"] -> 0,1,2,3,4,5,6 + * @param employeeStatus + * @return + */ + private String parseJson2ValueStr(String employeeStatus) { + return employeeStatus.replace("[","").replace("]","").replaceAll("\"", ""); + } + + + @Override + public Long update(SalarySobBasicSaveParam saveParam) { + + ValidUtil.doValidator(saveParam, RuntimeTypeEnum.UPDATE); + + // 查询薪资账套 + SalarySobPO salarySobPO = getById(saveParam.getId()); + if (Objects.isNull(salarySobPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98379, "参数错误,薪资账套不存在或者已被删除")); + } + // 薪资账套的名称不能重复 + List salarySobPOS = listByName(saveParam.getName()); + boolean duplicateName = salarySobPOS.stream().anyMatch(e -> !Objects.equals(e.getId(), saveParam.getId())); + if (duplicateName) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98403, "薪资账套名称已存在")); + } + // 更新薪资账套 + SalarySobPO newSalarySobPO = new SalarySobPO(); + BeanUtils.copyProperties(salarySobPO, newSalarySobPO); + newSalarySobPO.setId(saveParam.getId()) + .setName(saveParam.getName()) + .setTaxAgentId(saveParam.getTaxAgentIds().get(0)) + .setIncomeCategory(saveParam.getTaxableItems()) + .setSalaryCycleType(saveParam.getSalaryCycleType()) + .setSalaryCycleFromDay(saveParam.getSalaryCycleFromDay()) + .setTaxCycleType(saveParam.getTaxCycleType()) + .setAttendCycleType(saveParam.getAttendCycleType()) + .setAttendCycleFromDay(saveParam.getAttendCycleFromDay()) + .setSocialSecurityCycleType(saveParam.getSocialSecurityCycleType()) + .setDescription(saveParam.getDescription()) + .setUpdateTime(new Date()); + salarySobMapper.updateById(newSalarySobPO); + + //保存个税扣缴义务人联系 + saveSobTaxLink(saveParam.getTaxAgentIds(), salarySobPO); + + // 记录日志 + SalarySobPO salarySobPO4log = getSalarySobMapper().getById(newSalarySobPO.getId()); + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(newSalarySobPO.getId())); + loggerContext.setTargetName(newSalarySobPO.getName()); + loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "编辑薪资账套基础设置")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "编辑薪资账套基础设置")); + loggerContext.setOldValues(salarySobPO); + loggerContext.setNewValues(salarySobPO4log); + SalaryElogConfig.salarySobLoggerTemplate.write(loggerContext); + // 返回薪资账套的主键id + return salarySobPO.getId(); + } + + @Override + public void updateDisable(SalarySobDisableParam disableParam) { + // 查询薪资账套 + SalarySobPO salarySobPO = getById(disableParam.getId()); + SalarySobPO oldSalarySobPO = new SalarySobPO(); + BeanUtils.copyProperties(salarySobPO, oldSalarySobPO); + if (Objects.isNull(salarySobPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98379, "参数错误,薪资账套不存在或者已被删除")); + } + // 启用/禁用 薪资账套 + salarySobPO.setDisable(disableParam.getDisable()); + salarySobPO.setUpdateTime(new Date()); + salarySobMapper.updateById(salarySobPO); + // 记录日志 + String operateTypeName = Objects.equals(disableParam.getDisable(), NumberUtils.INTEGER_ONE) ? + SalaryI18nUtil.getI18nLabel(0, "禁用薪资账套") : SalaryI18nUtil.getI18nLabel(0, "启用薪资账套"); + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId("" + salarySobPO.getId()); + loggerContext.setTargetName(salarySobPO.getName()); + loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue()); + loggerContext.setOperateTypeName(operateTypeName); + loggerContext.setOperatedesc(operateTypeName + ": " + salarySobPO.getName()); + loggerContext.setOldValues(oldSalarySobPO); + loggerContext.setNewValues(salarySobPO); + SalaryElogConfig.salarySobLoggerTemplate.write(loggerContext); + } + + @Override + public void deleteByIds(Collection ids) { + + //分权 + Boolean isOpenDevolution = getTaxAgentService(user).isOpenDevolution(); + if (isOpenDevolution) { + List salarySobPOS = listByAdmin(); + Set salarySobIds = SalaryEntityUtil.properties(salarySobPOS, SalarySobPO::getId); + Optional first = ids.stream().filter(f -> !salarySobIds.contains(f)).findFirst(); + if (first.isPresent()) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98379, "无权限删除")); + } + } + + + // 查询薪资账套 + List salarySobPOS = listByIds(ids); + if (CollectionUtils.isEmpty(salarySobPOS)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98379, "参数错误,薪资账套不存在或者已被删除")); + } + ids = SalaryEntityUtil.properties(salarySobPOS, SalarySobPO::getId); + // 根据薪资账套id查询薪资核算记录,存在薪资核算记录就不能删除账套了 + List salaryAcctRecordPOS = getSalaryAcctRecordService(user).listBySalarySobIds(ids); + if (CollectionUtils.isNotEmpty(salaryAcctRecordPOS)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(99713, "账套已用于薪资核算,不能删除")); + } + + // 根据薪资账套id查询工资单模板,存在该账套下的工资单模板就不能删除账套了 + List salaryTemplatePOS = getSalaryTemplateService(user).getBySalarySobIds(ids); + if (CollectionUtils.isNotEmpty(salaryTemplatePOS)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(99713, "账套存在工资单模板,不能删除,请先删除该账套所对应的工资单模板")); + } + + //关联其他的删除 + // 删除薪资账套 + salarySobMapper.deleteByIds(ids); + // 删除薪资账套的人员范围 + salarySobRangeService.deleteBySalarySobIds(ids); + // 删除薪资账套的人员信息字段 + salarySobEmpFieldService.deleteBySalarySobIds(ids); + // 删除薪资账套的薪资项目 + salarySobItemService.deleteBySalarySobIds(ids); + // 删除薪资账套的薪资项目分类 + salarySobItemGroupService.deleteBySalarySobIds(ids); + // 删除薪资账套的薪资项目隐藏信息 + salarySobItemHideService.deleteBySalarySobIds(ids); + // 删除薪资账套的调薪计薪规则 + salarySobAdjustRuleService.deleteBySalarySobIds(ids); + // 删除薪资账套的回算薪资项目 + getSalarySobBackItemService(user).deleteBySalarySobIds(ids); + // 删除薪资账套的校验规则 + getSalarySobCheckRuleService(user).deleteBySalarySobIds(ids); + // 删除薪资审批规则 + getSalaryApprovalRuleService(user).deleteBySalarySobIds(ids); + // 记录日志 + salarySobPOS.forEach(salarySobPO -> { + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId("" + salarySobPO.getId()); + loggerContext.setTargetName(salarySobPO.getName()); + loggerContext.setOperateType(OperateTypeEnum.DELETE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "删除薪资账套")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "删除薪资账套")); + loggerContext.setOldValues(salarySobPO); + SalaryElogConfig.salarySobLoggerTemplate.write(loggerContext); + }); + } + + @Override + public void duplicate(SalarySobDuplicateParam duplicateParam) { + ValidUtil.doValidator(duplicateParam); + + // 查询薪资账套 + SalarySobPO salarySobPO = getById(duplicateParam.getId()); + if (Objects.isNull(salarySobPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98379, "参数错误,薪资账套不存在或者已被删除")); + } + // 薪资账套名称不能重复 + List salarySobPOS = listByName(duplicateParam.getName()); + if (CollectionUtils.isNotEmpty(salarySobPOS)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98403, "薪资账套名称已存在")); + } + + // 查询薪资账套的员工信息字段 + List salarySobEmpFieldPOS = salarySobEmpFieldService.listSome(SalarySobEmpFieldPO.builder().salarySobId(duplicateParam.getId()).build()); + // 查询薪资账套的薪资项目副本 + List salarySobItemPOS = salarySobItemService.listSome(SalarySobItemPO.builder().salarySobId(duplicateParam.getId()).build()); + // 薪资项目副本去重 + salarySobItemPOS = salarySobItemPOS.stream().filter(SalaryEntityUtil.distinctByKey(PO -> PO.getSalarySobId() + "-" + PO.getSalaryItemId())).collect(Collectors.toList()); + // 查询薪资账套的薪资项目分类 + List salarySobItemGroupPOS = salarySobItemGroupService.listSome(SalarySobItemGroupPO.builder().salarySobId(duplicateParam.getId()).build()); + // 查询薪资账套的调薪计薪规则 + List salarySobAdjustRulePOS = salarySobAdjustRuleService.listBySalarySobId(duplicateParam.getId()); + // 查询薪资账套的校验规则 + List salarySobCheckRulePOS = getSalarySobCheckRuleService(user).listBySalarySobId(duplicateParam.getId()); + // 查询薪资账套的回算薪资项目 + List salarySobBackItemPOS = getSalarySobBackItemService(user).listBySalarySobId(duplicateParam.getId()); + + + // 复制薪资账套的基础设置 + SalarySobPO newSalarySob = SalarySobPO.builder() + .name(duplicateParam.getName()) + .taxAgentId(duplicateParam.getTaxAgentIds().get(0)) + .incomeCategory(salarySobPO.getIncomeCategory()) + .salaryCycleType(salarySobPO.getSalaryCycleType()) + .salaryCycleFromDay(salarySobPO.getSalaryCycleFromDay()) + .taxCycleType(salarySobPO.getTaxCycleType()) + .attendCycleType(salarySobPO.getAttendCycleType()) + .attendCycleFromDay(salarySobPO.getAttendCycleFromDay()) + .socialSecurityCycleType(salarySobPO.getSocialSecurityCycleType()) + .disable(salarySobPO.getDisable()) + .creator((long) user.getUID()) + .createTime(new Date()) + .updateTime(new Date()) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .deleteType(NumberUtils.INTEGER_ZERO) + .build(); + salarySobMapper.insert(newSalarySob); + + + saveSobTaxLink(duplicateParam.getTaxAgentIds(), newSalarySob); + // 复制 + SalarySobDuplicateBO salarySobDuplicateBO = new SalarySobDuplicateBO(newSalarySob, salarySobEmpFieldPOS, salarySobItemPOS, + salarySobItemGroupPOS, salarySobAdjustRulePOS, salarySobCheckRulePOS, salarySobBackItemPOS); + SalarySobDuplicateBO.Result result = salarySobDuplicateBO.duplicate((long) user.getUID()); + // 复制薪资账套的员工信息字段 + if (CollectionUtils.isNotEmpty(result.getSalarySobEmpFields())) { + salarySobEmpFieldService.batchInsert(result.getSalarySobEmpFields()); + } + // 复制薪资账套的薪资项目副本 + if (CollectionUtils.isNotEmpty(result.getSalarySobItems())) { + salarySobItemService.batchInsert(result.getSalarySobItems()); + } + + // 复制薪资账套的回算薪资项目 + if (CollectionUtils.isNotEmpty(result.getSalarySobBackItems())) { + getSalarySobBackItemService(user).batchInsert(result.getSalarySobBackItems()); + } + + + // 复制薪资账套的薪资项目分类 + if (CollectionUtils.isNotEmpty(result.getSalarySobItemGroups())) { + salarySobItemGroupService.batchInsert(result.getSalarySobItemGroups()); + } + + + // 复制薪资账套的调薪计薪规则 + if (CollectionUtils.isNotEmpty(result.getSalaryAdjustmentRules())) { + salarySobAdjustRuleService.batchInsert(result.getSalaryAdjustmentRules()); + } + // 复制薪资账套的校验规则 + if (CollectionUtils.isNotEmpty(result.getSalarySobCheckRules())) { + getSalarySobCheckRuleService(user).batchSave(result.getSalarySobCheckRules()); + } + // 记录日志 + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId("" + result.getSalarySob().getId()); + loggerContext.setTargetName(result.getSalarySob().getName()); + loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(98570, "复制薪资账套")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(98570, "复制薪资账套") + ": " + salarySobPO.getName()); + SalaryElogConfig.salarySobLoggerTemplate.write(loggerContext); + } + + @Override + public SalarySobCycleDTO getSalarySobCycle(Long id, YearMonth salaryMonth) { + // 查询薪资账套 + SalarySobPO salarySobPO = getById(id); + if (Objects.isNull(salarySobPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98379, "参数错误,薪资账套不存在或者已被删除")); + } + return SalarySobCycleBO.buildSalarySobCycle(salarySobPO, salaryMonth); + } + + @Override + public List listByTaxAgentIds(List taxAgentIds) { + if (CollectionUtils.isEmpty(taxAgentIds)) { + return new ArrayList<>(); + } + return getSalarySobMapper().listByTaxAgentIds(taxAgentIds); + } + + @Override + public List getConfig(Long taxAgentId) { + List salarySobPOS = getSalarySobMapper().listSome(SalarySobPO.builder().taxAgentId(taxAgentId).build()); + return salarySobPOS.stream().map(salarySobPO -> { + Long salarySobId = salarySobPO.getId(); + List salarySobEmpFieldPOS = getSalarySobEmpFieldService(user).listBySalarySobId(salarySobId); + List salarySobItemGroupPOS = getSalarySobItemGroupService(user).getConfig(salarySobId); + List salarySobItemPOS = getSalarySobItemService(user).getConfig(salarySobId); + List salarySobBackItemPOS = getSalarySobBackItemService(user).getConfig(salarySobId); + List salarySobAdjustRulePOS = getSalarySobAdjustRuleService(user).listBySalarySobId(salarySobId); + return SalarySobConfig.builder().salarySob(salarySobPO).salarySobEmpFields(salarySobEmpFieldPOS).salarySobItemGroups(salarySobItemGroupPOS).salarySobItems(salarySobItemPOS).salarySobBackItems(salarySobBackItemPOS).salarySobAdjustRules(salarySobAdjustRulePOS).build(); + }).collect(Collectors.toList()); + } + + @Override + public List parseConfig(Long taxAgentId, List salarySobConfigs) { + List results = new ArrayList<>(); + long uid = user.getUID(); + List salarySobPOS = listByTaxAgentId(taxAgentId); + Map sobPOMap = SalaryEntityUtil.convert2Map(salarySobPOS, SalarySobPO::getName); + + List salaryItemPOList = getSalaryItemService(user).listAll(); + Map salaryItemNameMap = SalaryEntityUtil.convert2Map(salaryItemPOList, SalaryItemPO::getName); + + Optional.ofNullable(salarySobConfigs).orElse(new ArrayList<>()).forEach(salarySobConfig -> { + SalarySobPO salarySobPO = salarySobConfig.getSalarySob(); + String sobPOName = salarySobPO.getName(); + + UploadConfigResponse.Result result = UploadConfigResponse.Result.builder() + .message(String.format("账套:%s基础信息加载完毕", sobPOName)) + .success(new ArrayList<>()) + .warning(new ArrayList<>()) + .error(new ArrayList<>()) + .build(); + + if (sobPOMap.containsKey(sobPOName)) { + SalarySobPO oldSob = sobPOMap.get(sobPOName); + salarySobPO.setId(oldSob.getId()); + salarySobPO.setCreator(uid); + salarySobPO.setTaxAgentId(oldSob.getTaxAgentId()); + getSalarySobMapper().updateIgnoreNull(salarySobPO); + } else { + salarySobPO.setCreator(uid); + salarySobPO.setTaxAgentId(taxAgentId); + getSalarySobMapper().insertIgnoreNull(salarySobPO); + } + + result.getSuccess().add(String.format("账套:%s基础信息加载成功", sobPOName)); + + Long sobId = salarySobPO.getId(); + getSalarySobEmpFieldService(user).deleteBySalarySobIds(Collections.singletonList(sobId)); + List salarySobEmpFields = salarySobConfig.getSalarySobEmpFields(); + if (CollectionUtil.isNotEmpty(salarySobEmpFields)) { + for (SalarySobEmpFieldPO salarySobEmpField : salarySobEmpFields) { + salarySobEmpField.setSalarySobId(sobId); + salarySobEmpField.setCreator(uid); + } + getSalarySobEmpFieldService(user).batchSave(salarySobEmpFields); + } + result.getSuccess().add(String.format("账套:%s人员字段加载成功", sobPOName)); + + getSalarySobItemService(user).deleteBySalarySobIds(Collections.singletonList(sobId)); + List salarySobItems = salarySobConfig.getSalarySobItems(); + if (CollectionUtil.isNotEmpty(salarySobItems)) { + salarySobItems.forEach(sobItem -> { + sobItem.setId(IdGenerator.generate()); + sobItem.setSalarySobId(sobId); + sobItem.setCreator(uid); + Long formulaId = getSalaryFormulaService(user).add(sobItem.getFormula()); + sobItem.setFormulaId(formulaId); + + SalaryItemPO salaryItem = sobItem.getSalaryItem(); + if (salaryItem != null) { + SalaryItemPO salaryItemPO = salaryItemNameMap.get(salaryItem.getName()); + if (salaryItemPO != null) { + sobItem.setSalaryItemId(salaryItemPO.getId()); + } else { + SalaryItemPO itemPO = getSalaryItemService(user).getItem(salaryItem); + if (itemPO != null) { + sobItem.setSalaryItemId(itemPO.getId()); + } else { + result.getError().add(String.format("错误,账套:%s,薪资项目:%s,未找到对应薪资项目id", sobPOName, salaryItem.getName())); + log.error("item not found:{}", salaryItem); + } + } + } + + }); + getSalarySobItemService(user).batchSave(salarySobItems); + } + + getSalarySobItemGroupService(user).deleteBySalarySobIds(Collections.singletonList(sobId)); + List salarySobItemGroups = salarySobConfig.getSalarySobItemGroups(); + if (CollectionUtil.isNotEmpty(salarySobItemGroups)) { + for (SalarySobItemGroupPO salarySobItemGroup : salarySobItemGroups) { + long groupId = IdGenerator.generate(); + salarySobItemGroup.setId(groupId); + salarySobItemGroup.setSalarySobId(sobId); + salarySobItemGroup.setCreator(uid); + + List sobItems = salarySobItemGroup.getSalarySobItems(); + if (CollectionUtil.isNotEmpty(sobItems)) { + sobItems.forEach(sobItem -> { + sobItem.setId(IdGenerator.generate()); + sobItem.setSalarySobId(sobId); + sobItem.setSalarySobItemGroupId(groupId); + sobItem.setCreator(uid); + Long formulaId = getSalaryFormulaService(user).add(sobItem.getFormula()); + sobItem.setFormulaId(formulaId); + + SalaryItemPO salaryItem = sobItem.getSalaryItem(); + if (salaryItem != null) { + SalaryItemPO salaryItemPO = salaryItemNameMap.get(salaryItem.getName()); + if (salaryItemPO != null) { + sobItem.setSalaryItemId(salaryItemPO.getId()); + } else { + SalaryItemPO itemPO = getSalaryItemService(user).getItem(salaryItem); + if (itemPO != null) { + sobItem.setSalaryItemId(itemPO.getId()); + } else { + result.getError().add(String.format("错误,账套:%s,薪资项目:%s,未找到对应薪资项目id", sobPOName, salaryItem.getName())); + log.error("item not found:{}", salaryItem); + } + } + } + }); + getSalarySobItemService(user).batchSave(sobItems); + } + } + getSalarySobItemGroupService(user).batchSave(salarySobItemGroups); + } + result.getSuccess().add(String.format("账套:%s薪资项目加载成功", sobPOName)); + + getSalarySobBackItemService(user).deleteBySalarySobIds(Collections.singletonList(sobId)); + List salarySobBackItems = salarySobConfig.getSalarySobBackItems(); + if (CollectionUtil.isNotEmpty(salarySobBackItems)) { + for (SalarySobBackItemPO salarySobBackItem : salarySobBackItems) { + salarySobBackItem.setId(IdGenerator.generate()); + salarySobBackItem.setSalarySobId(sobId); + salarySobBackItem.setCreator(uid); + + Long formulaId = getSalaryFormulaService(user).add(salarySobBackItem.getFormula()); + salarySobBackItem.setFormulaId(formulaId); + + SalaryItemPO salaryItem = salarySobBackItem.getSalaryItem(); + if (salaryItem != null) { + SalaryItemPO salaryItemPO = salaryItemNameMap.get(salaryItem.getName()); + if (salaryItemPO != null) { + salarySobBackItem.setSalaryItemId(salaryItemPO.getId()); + } else { + SalaryItemPO itemPO = getSalaryItemService(user).getItem(salaryItem); + if (itemPO != null) { + salarySobBackItem.setSalaryItemId(itemPO.getId()); + } else { + result.getError().add(String.format("错误,账套:%s,薪资项目:%s,未找到对应薪资项目id", sobPOName, salaryItem.getName())); + log.error("item not found:{}", salaryItem); + } + } + } + } + getSalarySobBackItemService(user).batchInsert(salarySobBackItems); + } + result.getSuccess().add(String.format("账套:%s回算加载成功", sobPOName)); + + getSalarySobAdjustRuleService(user).deleteBySalarySobIds(Collections.singletonList(sobId)); + List salarySobAdjustRules = salarySobConfig.getSalarySobAdjustRules(); + if (CollectionUtil.isNotEmpty(salarySobAdjustRules)) { + for (SalarySobAdjustRulePO salarySobAdjustRule : salarySobAdjustRules) { + salarySobAdjustRule.setId(IdGenerator.generate()); + salarySobAdjustRule.setSalarySobId(sobId); + salarySobAdjustRule.setCreator(uid); + } + getSalarySobAdjustRuleService(user).batchSave(salarySobAdjustRules); + } + result.getSuccess().add(String.format("账套:%s调薪计薪规则加载成功", sobPOName)); + + results.add(result); + }); + + return results; + } + + @Override + public List list(SalarySobQueryParam param) { + SalarySobPO sobPO = SalarySobPO.builder().build(); + if (StrUtil.isNotBlank(param.getName())) { + sobPO.setName(param.getName()); + } + + if (param.getTaxAgentId() != null) { + List sobTaxLinkPOS = getSobTaxLinkMapper().listSome(SobTaxLinkPO.builder().taxAgentId(param.getTaxAgentId()).build()); + sobPO.setIds(SalaryEntityUtil.properties(sobTaxLinkPOS, SobTaxLinkPO::getSobId)); + } + return getSalarySobMapper().listSome(sobPO); + } + + @Override + public void handleHistory() { + List salarySobPOS = getSalarySobMapper().listAll(); + salarySobPOS.forEach(sobPO -> { + List sobTaxLinkPOS = getSobTaxLinkMapper().listSome(SobTaxLinkPO.builder().sobId(sobPO.getId()).build()); + if(CollUtil.isEmpty(sobTaxLinkPOS)){ + SobTaxLinkPO taxLinkPO = SobTaxLinkPO.builder() + .id(IdGenerator.generate()) + .taxAgentId(sobPO.getTaxAgentId()) + .sobId(sobPO.getId()) + .creator((long) user.getUID()) + .createTime(new Date()) + .updateTime(new Date()) + .deleteType(0) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .build(); + getSobTaxLinkMapper().insertIgnoreNull(taxLinkPO); + } + }); + } +} diff --git a/src/com/engine/salary/service/impl/SalaryTemplateServiceImpl.java b/src/com/engine/salary/service/impl/SalaryTemplateServiceImpl.java new file mode 100644 index 000000000..aaa2dfcde --- /dev/null +++ b/src/com/engine/salary/service/impl/SalaryTemplateServiceImpl.java @@ -0,0 +1,517 @@ +package com.engine.salary.service.impl; + +import cn.hutool.core.util.StrUtil; +import cn.hutool.json.JSONUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.hrmelog.entity.dto.LoggerContext; +import com.engine.salary.biz.SalarySobBiz; +import com.engine.salary.biz.SalaryTemplateBiz; +import com.engine.salary.config.SalaryElogConfig; +import com.engine.salary.entity.salaryBill.bo.SalaryTemplateBO; +import com.engine.salary.entity.salaryBill.dto.SalaryTemplateListDTO; +import com.engine.salary.entity.salaryBill.dto.SalaryTemplateSalaryItemListDTO; +import com.engine.salary.entity.salaryBill.dto.SalaryTemplateSalaryItemSetListDTO; +import com.engine.salary.entity.salaryBill.param.SalaryTemplateCopyParam; +import com.engine.salary.entity.salaryBill.param.SalaryTemplateDefaultUseParam; +import com.engine.salary.entity.salaryBill.param.SalaryTemplateQueryParam; +import com.engine.salary.entity.salaryBill.param.SalaryTemplateSaveParam; +import com.engine.salary.entity.salaryBill.po.SalaryBillItemNamePO; +import com.engine.salary.entity.salaryBill.po.SalaryTemplatePO; +import com.engine.salary.entity.salarysob.dto.SalarySobItemAggregateDTO; +import com.engine.salary.entity.salarysob.dto.SalarySobItemDTO; +import com.engine.salary.entity.salarysob.dto.SalarySobItemGroupDTO; +import com.engine.salary.entity.salarysob.po.SalarySobEmpFieldPO; +import com.engine.salary.entity.salarysob.po.SalarySobItemPO; +import com.engine.salary.entity.salarysob.po.SalarySobPO; +import com.engine.salary.enums.OperateTypeEnum; +import com.engine.salary.enums.auth.AuthFilterTypeEnum; +import com.engine.salary.enums.salarybill.SalaryTemplateWhetherEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.mapper.salarysob.SalarySobEmpFieldMapper; +import com.engine.salary.report.entity.po.SalaryStatisticsReportPO; +import com.engine.salary.service.*; +import com.engine.salary.service.auth.AuthService; +import com.engine.salary.service.auth.AuthServiceImpl; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.db.IdGenerator; +import com.engine.salary.util.db.MapperProxyFactory; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.util.page.SalaryPageUtil; +import com.mzlion.core.utils.BeanUtils; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.math.NumberUtils; +import weaver.hrm.User; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * @Description: 工资单模板 + * @Author: wangxiangzhong + * @Date: 2021-12-08 14:44 + */ +public class SalaryTemplateServiceImpl extends Service implements SalaryTemplateService { + + private SalaryTemplateBiz mapper = new SalaryTemplateBiz(); + + private SalarySobBiz salarySobMapper = new SalarySobBiz(); + + private SalarySobItemService getSalarySobItemService(User user) { + return ServiceUtil.getService(SalarySobItemServiceImpl.class, user); + } + + private SalarySobService getSalarySobService(User user) { + return ServiceUtil.getService(SalarySobServiceImpl.class, user); + } + + private TaxAgentService getTaxAgentService(User user) { + return ServiceUtil.getService(TaxAgentServiceImpl.class, user); + } + + private SalarySobItemHideService getSalarySobItemHideService(User user) { + return ServiceUtil.getService(SalarySobItemHideServiceImpl.class, user); + } + + private SalaryBillItemNameService getSalaryBillItemNameService(User user) { + return ServiceUtil.getService(SalaryBillItemNameServiceImpl.class, user); + } + + private SalarySobEmpFieldService getSalarySobEmpFieldService(User user) { + return (SalarySobEmpFieldService) ServiceUtil.getService(SalarySobEmpFieldServiceImpl.class, user); + } + + private SalarySobEmpFieldMapper getSalarySobEmpFieldMapper() { + return MapperProxyFactory.getProxy(SalarySobEmpFieldMapper.class); + } + + public AuthService getAuthService(User user) { + return ServiceUtil.getService(AuthServiceImpl.class, user); + } + + @Override + public SalaryTemplatePO getById(Long id) { + return mapper.getById(id); + } + +// @Override +// public Map listPage(SalaryTemplateQueryParam queryParam) { +// mapper.list(queryParam); +// return page; +// } + + @Override + public String defaultUse(SalaryTemplateDefaultUseParam defaultUseParamy) { + // 校验参数 + SalaryTemplateDefaultUseParam.checkParam(defaultUseParamy); + + SalaryTemplatePO salaryTemplate = getById(defaultUseParamy.getId()); + + if (salaryTemplate == null) { + throw new SalaryRunTimeException("工资单模板不存在"); + } + + // 选中默认使用 + SalaryTemplatePO po = new SalaryTemplatePO(); + po.setDeleteType(0); + po.setSalarySobId(salaryTemplate.getSalarySobId()); + po.setUseType(SalaryTemplateWhetherEnum.FALSE.getValue()); + mapper.updateBySalarySobId(po); + + SalaryTemplatePO salaryTemplateNew = new SalaryTemplatePO(); + BeanUtils.copyProperties(salaryTemplate, salaryTemplateNew); + salaryTemplateNew.setUseType(SalaryTemplateWhetherEnum.TRUE.getValue()); + mapper.updateById(salaryTemplateNew); + + // 记录日志 + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(salaryTemplateNew.getId())); + loggerContext.setTargetName(salaryTemplateNew.getName()); + loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "设为默认使用")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "设为默认使用")); + SalaryElogConfig.salaryTemplateLoggerTemplate.write(loggerContext); + return ""; + } + + @Override + public String save(SalaryTemplateSaveParam saveParam) { + // 校验参数 + SalaryTemplateSaveParam.checkParam(saveParam); + + SalaryTemplatePO po = new SalaryTemplatePO(); + po.setDeleteType(0); + po.setName(saveParam.getName()); + List salaryTemplates = mapper.listSome(po); + + if (CollectionUtils.isNotEmpty(salaryTemplates)) { + throw new SalaryRunTimeException("工资单模板名称不允许重复"); + } + + SalarySobPO salarySobPO = new SalarySobPO(); + po.setDeleteType(0); + po.setId(saveParam.getSalarySobId()); + List salarySobs = salarySobMapper.listSome(salarySobPO); + + if (CollectionUtils.isEmpty(salarySobs)) { + throw new SalaryRunTimeException("薪资账套不存在"); + } + // todo 薪资项目设置检查校验 + // 保存 + SalaryTemplatePO salaryTemplate = SalaryTemplateBO.convertToPO(saveParam, (long) user.getUID()); +// salaryTemplate.setSendEmailId(saveParam.getSendEmail()); + salaryTemplate.setEmailStatus(saveParam.getEmailStatus() ? 1 : 0); + salaryTemplate.setMsgStatus(saveParam.getMsgStatus() ? 1 : 0); + salaryTemplate.setSmsStatus(saveParam.getSmsStatus() != null && saveParam.getSmsStatus() ? 1 : 0); + salaryTemplate.setSmsSetting(saveParam.getSmsSetting() == null ? "" : JSON.toJSONString(saveParam.getSmsSetting())); + salaryTemplate.setTextContentPosition(saveParam.getTextContentPosition()); + salaryTemplate.setSalaryItemNullStatus(saveParam.getSalaryItemNullStatus() ? 1 : 0); + salaryTemplate.setSalaryItemZeroStatus(saveParam.getSalaryItemZeroStatus() ? 1 : 0); + salaryTemplate.setAutoSendCycleType(saveParam.getAutoSendCycleType()); + mapper.insert(salaryTemplate); + + // 存储工资单项目自定义名称信息 + saveParam.getSalaryBillItemNameSetting().stream().forEach(set -> set.setSalaryTemplateId(salaryTemplate.getId())); + getSalaryBillItemNameService(user).saveItemShowName(saveParam.getSalaryBillItemNameSetting()); + // 记录日志 + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(salaryTemplate.getId())); + loggerContext.setTargetName(salaryTemplate.getName()); + loggerContext.setOperateType(OperateTypeEnum.ADD.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "新增工资单模板")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "新增工资单模板")); + loggerContext.setNewValues(salaryTemplate); + SalaryElogConfig.salaryTemplateLoggerTemplate.write(loggerContext); + + return ""; + } + + @Override + public String update(SalaryTemplateSaveParam saveParam) { + // 校验参数 + SalaryTemplateSaveParam.checkParam(saveParam); + // 校验是否可以编辑 + if (saveParam.getId() == null) { + throw new SalaryRunTimeException("参数错误"); + } + SalaryTemplatePO salaryTemplate = getById(saveParam.getId()); + if (salaryTemplate == null) { + throw new SalaryRunTimeException("工资单模板不存在"); + } + + // 工资单模板编辑时不允许调整账套 + if (!salaryTemplate.getSalarySobId().equals(saveParam.getSalarySobId())) { + throw new SalaryRunTimeException("工资单模板编辑时不允许调整账套"); + } + + SalaryTemplatePO po = new SalaryTemplatePO(); + po.setDeleteType(0); + po.setName(saveParam.getName()); + List salaryTemplates = mapper.listSome(po); + + boolean nameExist = salaryTemplates.stream().anyMatch(e -> !Objects.equals(e.getId(), saveParam.getId())); + if (nameExist) { + throw new SalaryRunTimeException("工资单模板名称不允许重复"); + } + SalarySobPO salarySobPO = new SalarySobPO(); + po.setDeleteType(0); + po.setId(saveParam.getSalarySobId()); + List salarySobs = salarySobMapper.listSome(salarySobPO); + + if (CollectionUtils.isEmpty(salarySobs)) { + throw new SalaryRunTimeException("薪资账套不存在"); + } + // 更新工资单 + SalaryTemplatePO salaryTemplateNew = new SalaryTemplatePO(); + BeanUtils.copyProperties(salaryTemplate, salaryTemplateNew); + BeanUtils.copyProperties(saveParam, salaryTemplateNew); + salaryTemplateNew.setUpdateTime(new Date()); + salaryTemplateNew.setSendEmailId(0L); + salaryTemplateNew.setEmailStatus(saveParam.getEmailStatus() ? 1 : 0); + salaryTemplateNew.setMsgStatus(saveParam.getMsgStatus() ? 1 : 0); + salaryTemplateNew.setSmsStatus(saveParam.getSmsStatus() != null && saveParam.getSmsStatus() ? 1 : 0); + salaryTemplateNew.setSmsSetting(saveParam.getSmsSetting() == null ? "" : JSON.toJSONString(saveParam.getSmsSetting())); + salaryTemplateNew.setTextContentPosition(saveParam.getTextContentPosition()); + salaryTemplateNew.setSalaryItemNullStatus(saveParam.getSalaryItemNullStatus() ? 1 : 0); + salaryTemplateNew.setSalaryItemZeroStatus(saveParam.getSalaryItemZeroStatus() ? 1 : 0); + salaryTemplateNew.setAutoSendStatus(saveParam.getAutoSendStatus() ? 1 : 0); + salaryTemplateNew.setAutoSendCycleType(saveParam.getAutoSendCycleType()); + salaryTemplateNew.setAckFeedbackStatus(saveParam.getAckFeedbackStatus() ? 1 : 0); + salaryTemplateNew.setFeedbackStatus(saveParam.getFeedbackStatus() ? 1 : 0); + salaryTemplateNew.setAutoAckDays(saveParam.getAutoAckDays()); + salaryTemplateNew.setFeedbackUrl(saveParam.getFeedbackUrl()); + salaryTemplateNew.setMobileFeedbackUrl(saveParam.getMobileFeedbackUrl()); + // todo 薪资项目设置检查校验 + salaryTemplateNew.setSalaryItemSetting(saveParam.getSalaryItemSetting() != null ? JSONUtil.toJsonStr(saveParam.getSalaryItemSetting()) : ""); + salaryTemplateNew.setReplenishSalaryItemSetting(saveParam.getReplenishSalaryItemSetting() != null ? JSONUtil.toJsonStr(saveParam.getReplenishSalaryItemSetting()) : ""); + mapper.updateById(salaryTemplateNew); + + // 保存自定义工资单项目名称信息 + getSalaryBillItemNameService(user).saveItemShowName(saveParam.getSalaryBillItemNameSetting()); + // 模板中没有的薪资项目需要同步删除显示名称表 + List billItemNameList = getSalaryBillItemNameService(user).ListByTemplateAndType(SalaryBillItemNamePO.builder().salaryTemplateId(saveParam.getId()).build()); + Map> billItemNameMap = SalaryEntityUtil.group2Map(billItemNameList, SalaryBillItemNamePO::getSalaryBillType); + List saveItemList = saveParam.getSalaryItemSetting().stream().map(SalaryTemplateSalaryItemSetListDTO::getItems).flatMap(Collection::stream).collect(Collectors.toList()); + Set saveItemIdList = SalaryEntityUtil.properties(saveItemList, SalaryTemplateSalaryItemListDTO::getSalaryItemId); + // 正常工资单模板中删除的薪资项目 + List needDeleteIds = billItemNameMap.getOrDefault(NumberUtils.INTEGER_ZERO, Collections.emptyList()).stream().filter(salaryBillItemNamepo -> !saveItemIdList.contains(salaryBillItemNamepo.getSalaryItemId().toString())) + .map(SalaryBillItemNamePO::getId).collect(Collectors.toList()); + // 补发工资单模板中删除的薪资项目 + List replenishItemList = saveParam.getReplenishSalaryItemSetting().stream().map(SalaryTemplateSalaryItemSetListDTO::getItems).flatMap(Collection::stream).collect(Collectors.toList()); + Set saveReplenishItemIdList = SalaryEntityUtil.properties(replenishItemList, SalaryTemplateSalaryItemListDTO::getSalaryItemId); + needDeleteIds.addAll(billItemNameMap.getOrDefault(NumberUtils.INTEGER_ONE, Collections.emptyList()).stream().filter(salaryBillItemNamepo -> !saveReplenishItemIdList.contains(salaryBillItemNamepo.getSalaryItemId().toString())) + .map(SalaryBillItemNamePO::getId).collect(Collectors.toList())); + getSalaryBillItemNameService(user).deleteByIds(needDeleteIds); + + // 记录日志 + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(salaryTemplateNew.getId())); + loggerContext.setTargetName(salaryTemplateNew.getName()); + loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "编辑工资单模板")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "编辑工资单模板")); + loggerContext.setOldValues(salaryTemplate); + loggerContext.setNewValues(salaryTemplateNew); + SalaryElogConfig.salaryTemplateLoggerTemplate.write(loggerContext); + + return ""; + } + + @Override + public String copy(SalaryTemplateCopyParam copyParam) { + // 校验参数 + SalaryTemplateCopyParam.checkParam(copyParam); + + SalaryTemplatePO salaryTemplate = getById(copyParam.getId()); + if (salaryTemplate == null) { + throw new SalaryRunTimeException("被复制的工资单不存在"); + } + + List salaryTemplates = mapper.list(SalaryTemplateQueryParam.builder().name(copyParam.getName()).build()); + + if (CollectionUtils.isNotEmpty(salaryTemplates)) { + throw new SalaryRunTimeException("工资单模板名称不允许重复"); + } + + SalaryTemplatePO salaryTemplateNew = new SalaryTemplatePO(); + BeanUtils.copyProperties(salaryTemplate, salaryTemplateNew); + salaryTemplateNew.setId(null); + salaryTemplateNew.setName(copyParam.getName()); + salaryTemplateNew.setReplenishName(copyParam.getName() + "-" + SalaryI18nUtil.getI18nLabel(0, "补发工资单")); + salaryTemplateNew.setUseType(SalaryTemplateWhetherEnum.FALSE.getValue()); + + //20240122逻辑变更,拷贝工资单模板时,可变更薪资账套 + if (copyParam.getSalarySobId() != null && !copyParam.getSalarySobId().equals(salaryTemplate.getSalarySobId())) { + // 查询薪资账套的员工信息字段 + List salarySobEmpFieldPOS = getSalarySobEmpFieldService(user).listBySalarySobId(copyParam.getSalarySobId()); + List empFieldCodeList = salarySobEmpFieldPOS.stream().map(SalarySobEmpFieldPO::getFieldCode).collect(Collectors.toList()); + Map empFieldCodeWithIdMap = SalaryEntityUtil.convert2Map(salarySobEmpFieldPOS, SalarySobEmpFieldPO::getFieldCode, SalarySobEmpFieldPO::getId); + // 查询薪资账套的薪资项目副本 + List salarySobItemPOS = getSalarySobItemService(user).listBySalarySobId(copyParam.getSalarySobId()); + List salaryItemIdList = salarySobItemPOS.stream().map(SalarySobItemPO::getSalaryItemId).collect(Collectors.toList()); + //拷贝数据中的薪资项目 + List salaryItemSettingList = StrUtil.isNotBlank(salaryTemplate.getSalaryItemSetting()) + ? JSONArray.parseArray(salaryTemplate.getSalaryItemSetting(), SalaryTemplateSalaryItemSetListDTO.class) : new ArrayList<>(); + for (SalaryTemplateSalaryItemSetListDTO salaryItemSetting : salaryItemSettingList) { + if ("111111111111111111".equals(salaryItemSetting.getGroupId()) && salaryItemSetting.getItems() != null) { + List newItems = new ArrayList<>(); + for (SalaryTemplateSalaryItemListDTO templateItem : salaryItemSetting.getItems()) { + SalarySobEmpFieldPO empFieldPO = getSalarySobEmpFieldMapper().getById(Long.valueOf(templateItem.getSalaryItemId())); + if (empFieldPO != null && empFieldCodeList.contains(empFieldPO.getFieldCode()) && empFieldCodeWithIdMap.get(empFieldPO.getFieldCode()) != null) { + templateItem.setId(empFieldCodeWithIdMap.get(empFieldPO.getFieldCode()).toString()); + templateItem.setSalaryItemId(empFieldCodeWithIdMap.get(empFieldPO.getFieldCode()).toString()); + newItems.add(templateItem); + } + } + salaryItemSetting.setItems(newItems); + } else if (salaryItemSetting.getItems() != null) { + List newItems = new ArrayList<>(); + for (SalaryTemplateSalaryItemListDTO templateItem : salaryItemSetting.getItems()) { + if (salaryItemIdList.contains(Long.valueOf(templateItem.getSalaryItemId()))) { + newItems.add(templateItem); + } + } + salaryItemSetting.setItems(newItems); + } + } + List replenishSalaryItemSettingList = StrUtil.isNotBlank(salaryTemplate.getReplenishSalaryItemSetting()) + ? JSONArray.parseArray(salaryTemplate.getReplenishSalaryItemSetting(), SalaryTemplateSalaryItemSetListDTO.class) : new ArrayList<>(); + for (SalaryTemplateSalaryItemSetListDTO salaryItemSetting : replenishSalaryItemSettingList) { + if ("111111111111111111".equals(salaryItemSetting.getGroupId()) && salaryItemSetting.getItems() != null) { + List newItems = new ArrayList<>(); + for (SalaryTemplateSalaryItemListDTO templateItem : salaryItemSetting.getItems()) { + SalarySobEmpFieldPO empFieldPO = getSalarySobEmpFieldMapper().getById(Long.valueOf(templateItem.getSalaryItemId())); + if (empFieldPO != null && empFieldCodeList.contains(empFieldPO.getFieldCode()) && empFieldCodeWithIdMap.get(empFieldPO.getFieldCode()) != null) { + templateItem.setId(empFieldCodeWithIdMap.get(empFieldPO.getFieldCode()).toString()); + templateItem.setSalaryItemId(empFieldCodeWithIdMap.get(empFieldPO.getFieldCode()).toString()); + newItems.add(templateItem); + } + } + salaryItemSetting.setItems(newItems); + } else if (!"333333333333333333".equals(salaryItemSetting.getGroupId()) && salaryItemSetting.getItems() != null) { + List newItems = new ArrayList<>(); + for (SalaryTemplateSalaryItemListDTO templateItem : salaryItemSetting.getItems()) { + if (salaryItemIdList.contains(Long.valueOf(templateItem.getSalaryItemId()))) { + newItems.add(templateItem); + } + } + salaryItemSetting.setItems(newItems); + } + } + salaryTemplateNew.setSalaryItemSetting(salaryItemSettingList.size() > 0 ? JSONUtil.toJsonStr(salaryItemSettingList) : ""); + salaryTemplateNew.setReplenishSalaryItemSetting(replenishSalaryItemSettingList.size() > 0 ? JSONUtil.toJsonStr(replenishSalaryItemSettingList) : ""); + salaryTemplateNew.setSalarySobId(copyParam.getSalarySobId()); + } + + mapper.insert(salaryTemplateNew); + + // 复制工资单自定义名称信息 + List billItemNamePOList = getSalaryBillItemNameService(user).ListByTemplateAndType(SalaryBillItemNamePO.builder().salaryTemplateId(copyParam.getId()).build()); + if (CollectionUtils.isNotEmpty(billItemNamePOList)) { + Date now = new Date(); + List needInsertList = billItemNamePOList.stream().map(po -> { + SalaryBillItemNamePO newSalaryBillItemNamePO = new SalaryBillItemNamePO(); + BeanUtils.copyProperties(po, newSalaryBillItemNamePO); + newSalaryBillItemNamePO.setId(IdGenerator.generate()); + newSalaryBillItemNamePO.setUpdateTime(now); + newSalaryBillItemNamePO.setSalaryTemplateId(salaryTemplateNew.getId()); + return newSalaryBillItemNamePO; + }).collect(Collectors.toList()); + getSalaryBillItemNameService(user).batchInsert(needInsertList); + } + // 记录日志 + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(salaryTemplateNew.getId())); + loggerContext.setTargetName(salaryTemplateNew.getName()); + loggerContext.setOperateType(OperateTypeEnum.ADD.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "复制工资单模板")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "复制工资单模板")); + loggerContext.setNewValues(salaryTemplateNew); + SalaryElogConfig.salaryTemplateLoggerTemplate.write(loggerContext); + + return ""; + } + + @Override + public String delete(Collection ids) { + if (CollectionUtils.isEmpty(ids)) { + throw new SalaryRunTimeException("参数错误"); + } + List salaryTemplates = mapper.list(SalaryTemplateQueryParam.builder().ids(ids).build()); + if (CollectionUtils.isEmpty(salaryTemplates)) { + throw new SalaryRunTimeException("要删除的工资单在不存在或已删除"); + } + // TODO 正在使用的记录不允许删除 + mapper.deleteByIds(ids); + // 删除工资单重命名表 + getSalaryBillItemNameService(user).deleteByTemplateIds(ids); + // 记录日志 + salaryTemplates.stream().forEach(template -> { + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(template.getId())); + loggerContext.setTargetName(template.getName() + ":" + template.getId()); + loggerContext.setOperateType(OperateTypeEnum.DELETE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "删除工资单模板")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "删除工资单模板")); + SalaryElogConfig.salaryTemplateLoggerTemplate.write(loggerContext); + }); + return ""; + } + + @Override + public List> selectSalarySobList() { + List salarySobs = getSalarySobService(user).listByDisable(NumberUtils.INTEGER_ZERO); + + return salarySobs.stream().map(m -> { + Map map = new HashMap<>(2); + map.put("id", String.valueOf(m.getId())); + map.put("content", m.getName()); + return map; + }).collect(Collectors.toList()); + } + + @Override + public List getSalaryItemSet(Long salarySobId, boolean isReplenish) { + SalarySobItemAggregateDTO salarySobItemAggregate = getSalarySobItemService(user).getAggregateBySalarySobId(salarySobId); + // 处理薪资账套中隐藏的分类和项目 + List itemGroupDTOS = salarySobItemAggregate.getItemGroups().stream().filter(group -> group.getItemHide() == null || group.getItemHide().equals(0L)).collect(Collectors.toList()); + // 获取关闭显示的薪资项目 + for (SalarySobItemGroupDTO DTO : itemGroupDTOS) { + List items = DTO.getItems(); + DTO.setItems(items.stream().filter(item -> item.getItemHide() == null || item.getItemHide().equals(0L)).collect(Collectors.toList())); + } + itemGroupDTOS = itemGroupDTOS.stream().filter(DTO -> CollectionUtils.isNotEmpty(DTO.getItems())).collect(Collectors.toList()); + salarySobItemAggregate.setItemGroups(itemGroupDTOS); + salarySobItemAggregate.setItems(salarySobItemAggregate.getItems().stream().filter(item -> item.getItemHide() == null || item.getItemHide().equals(0L)).collect(Collectors.toList())); + return SalaryTemplateBO.convertSalarySobItemAggregateToSalaryItemSet(salarySobItemAggregate, isReplenish); + } + + @Override + public List getSalaryItemSetContainHide(Long salarySobId, Long salaryTemplateId, boolean isReplenish) { + SalarySobItemAggregateDTO salarySobItemAggregate = getSalarySobItemService(user).getAggregateBySalarySobId(salarySobId); + // 获取工资单薪资项目展示名信息 + List billItemNameList = Collections.emptyList(); + if (salaryTemplateId != null) { + billItemNameList = getSalaryBillItemNameService(user).ListByTemplateAndType( + SalaryBillItemNamePO.builder().salaryTemplateId(salaryTemplateId) + .salaryBillType(isReplenish ? 1 : 0) + .build()); + } + + Map itemShowNameMap = SalaryEntityUtil.convert2Map(billItemNameList, SalaryBillItemNamePO::getSalaryItemId, SalaryBillItemNamePO::getSalaryItemShowName); + + List salaryTemplateSalaryItemSetListDTOS = SalaryTemplateBO.convertSalarySobItemAggregateToSalaryItemSet(salarySobItemAggregate, isReplenish); + salaryTemplateSalaryItemSetListDTOS.stream() + .filter(data -> !StringUtils.equals(data.getGroupId(), "111111111111111111")) + .forEach(data -> { + data.getItems().forEach(item -> { + Long salaryItemId = Long.valueOf(item.getSalaryItemId()); + if (itemShowNameMap.containsKey(salaryItemId)) { + item.setSalaryItemShowName(itemShowNameMap.get(salaryItemId)); + item.setName(itemShowNameMap.get(salaryItemId) + "(" + item.getOriginName() + ")"); + } else { + item.setSalaryItemShowName(item.getOriginName()); + item.setName(item.getOriginName()); + } + }); + }); + return salaryTemplateSalaryItemSetListDTOS; + } + + @Override + public List getDefaultTemplates(List salarySobIds) { + return mapper.listDefaultTemplates(salarySobIds); + } + + @Override + public List getBySalarySobIds(Collection ids) { + return mapper.listSome(SalaryTemplatePO.builder().salarySobIds(ids).build()); + } + + @Override + public PageInfo listPage(SalaryTemplateQueryParam queryParam) { + List salaryTemplateDTOList = mapper.listDTO(SalaryTemplatePO.builder().salarySobId(queryParam.getSalarySobId()).name(queryParam.getName()).build()); + salaryTemplateDTOList = getAuthService(user).auth(salaryTemplateDTOList, AuthFilterTypeEnum.DATA_OPT, SalaryTemplateListDTO.class); + + return SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), salaryTemplateDTOList, SalaryTemplateListDTO.class); + } + + @Override + public List getAutoSendTemplate() { + return mapper.listSome(SalaryTemplatePO.builder().autoSendStatus(NumberUtils.INTEGER_ONE).useType(NumberUtils.INTEGER_ONE).deleteType(NumberUtils.INTEGER_ZERO).build()); + } + + @Override + public List listNeedAckDefaultTemplate() { + return mapper.listSome(SalaryTemplatePO.builder().useType(NumberUtils.INTEGER_ONE).ackFeedbackStatus(NumberUtils.INTEGER_ONE).build()); + } +} diff --git a/src/com/engine/salary/service/impl/SettingServiceImpl.java b/src/com/engine/salary/service/impl/SettingServiceImpl.java new file mode 100644 index 000000000..0ff8a7fe6 --- /dev/null +++ b/src/com/engine/salary/service/impl/SettingServiceImpl.java @@ -0,0 +1,487 @@ +package com.engine.salary.service.impl; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.util.StrUtil; +import com.cloudstore.eccom.constant.WeaBoolAttr; +import com.cloudstore.eccom.pc.table.WeaTableColumn; +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.entity.salaryitem.po.SalaryItemPO; +import com.engine.salary.entity.setting.dto.PageListTemplateDTO; +import com.engine.salary.entity.setting.dto.PageListTemplateDetailDTO; +import com.engine.salary.entity.setting.param.*; +import com.engine.salary.entity.setting.po.PageLinkPO; +import com.engine.salary.entity.setting.po.PageListSettingPO; +import com.engine.salary.entity.setting.po.PageListTemplatePO; +import com.engine.salary.entity.taxagent.param.TaxAgentQueryParam; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import com.engine.salary.enums.SalaryOnOffEnum; +import com.engine.salary.enums.auth.AuthFilterTypeEnum; +import com.engine.salary.enums.common.SharedTypeEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.mapper.setting.PageLinkMapper; +import com.engine.salary.mapper.setting.PageListSettingMapper; +import com.engine.salary.mapper.setting.PageListTemplateMapper; +import com.engine.salary.report.common.constant.SalaryConstant; +import com.engine.salary.service.SalaryItemService; +import com.engine.salary.service.SettingService; +import com.engine.salary.service.TaxAgentService; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.db.IdGenerator; +import com.engine.salary.util.db.MapperProxyFactory; +import com.engine.salary.util.excel.ExcelUtilPlus; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.util.page.SalaryPageUtil; +import com.engine.salary.util.valid.ValidUtil; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import weaver.file.ImageFileManager; +import weaver.hrm.User; + +import java.util.*; +import java.util.stream.Collectors; + +import static com.engine.salary.constant.SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY; +import static com.engine.salary.enums.setting.PageListSettingPageEnum.SALARY_DETAILS_REPORT; + +/** + * 页面显示 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SettingServiceImpl extends Service implements SettingService { + + private PageListSettingMapper getPageListSettingMapper() { + return MapperProxyFactory.getProxy(PageListSettingMapper.class); + } + + private PageListTemplateMapper getPageListTemplateMapper() { + return MapperProxyFactory.getProxy(PageListTemplateMapper.class); + } + + private PageLinkMapper getPageLinkMapper() { + return MapperProxyFactory.getProxy(PageLinkMapper.class); + } + + private SalaryItemService getSalaryItemService(User user) { + return ServiceUtil.getService(SalaryItemServiceImpl.class, user); + } + + private TaxAgentService getTaxAgentService() { + return ServiceUtil.getService(TaxAgentServiceImpl.class, user); + } + + @Override + public void savePageListSetting(PageListSettingSaveParam pageListSettingSaveParam) { + ValidUtil.doValidator(pageListSettingSaveParam); + + Date now = new Date(); + + //是否保存默认设置 + Integer defaultSetting = pageListSettingSaveParam.getDefaultSetting(); + PageListSettingPO pageListSettingPO; + if (defaultSetting == 0) { + pageListSettingPO = getPageListSettingMapper().getByPage(pageListSettingSaveParam.getPage(), defaultSetting, (long) user.getUID()); + } else { + pageListSettingPO = getPageListSettingMapper().getByPage(pageListSettingSaveParam.getPage(), defaultSetting, null); + } + + List checked = pageListSettingSaveParam.getSetting().stream().distinct().collect(Collectors.toList()); + if (pageListSettingPO != null) { + pageListSettingPO.setSetting(checked); + pageListSettingPO.setUpdateTime(now); + getPageListSettingMapper().updateIgnoreNull(pageListSettingPO); + } else { + pageListSettingPO = PageListSettingPO.builder().id(IdGenerator.generate()).page(pageListSettingSaveParam.getPage()).setting(checked).defaultSetting(defaultSetting).creator((long) user.getUID()).createTime(now).updateTime(now).deleteType(0).tenantKey(DEFAULT_TENANT_KEY).build(); + getPageListSettingMapper().insertIgnoreNull(pageListSettingPO); + } + } + + @Override + public PageListTemplateDetailDTO getDefaultPageListSetting(PageListSettingQueryParam param) { + String page = param.getPage(); + if (SALARY_DETAILS_REPORT.getValue().equals(page)) { + List columns = new ArrayList<>(); + columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(87614, "薪资所属月"), "salaryMonth")); + columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(86184, "个税扣缴义务人"), "taxAgent")); + columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(86184, "账套"), "salarySob")); + columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(0, "姓名"), "userName")); + columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(0, "分部"), "subCompany")); + columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(0, "部门"), "department")); + columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(0, "岗位"), "jobTitle")); + columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(0, "员工状态"), "status")); + columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(0, "工号"), "workCode")); + columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(0, "入职日期"), "companystartdate")); + columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(86184, "次数"), "acctTimes").setDisplay(WeaBoolAttr.FALSE)); + if (StrUtil.isNotBlank(param.getName())) { + columns = columns.stream().filter(column -> column.getText().contains(param.getName())).collect(Collectors.toList()); + } + + List salaryItemList = getSalaryItemService(user).listAll(); + List collect = salaryItemList.stream().filter(po -> { + String name = param.getName(); + if (StrUtil.isNotEmpty(name)) { + return po.getName() != null && po.getName().contains(name); + } + return true; + }).sorted((o1, o2) -> { + if (o1.getSortedIndex() == null && o2.getSortedIndex() == null) { + Integer systemType1 = o1.getSystemType() == null ? 0 : o1.getSystemType(); + Integer systemType2 = o2.getSystemType() == null ? 0 : o2.getSystemType(); + return systemType1.compareTo(systemType2); + } else { + Integer sortedIndex1 = o1.getSortedIndex() == null ? 0 : o1.getSortedIndex(); + Integer sortedIndex2 = o2.getSortedIndex() == null ? 0 : o2.getSortedIndex(); + return sortedIndex2.compareTo(sortedIndex1); + } + }).map(item -> new WeaTableColumn("100px", item.getName(), item.getId() + SalaryConstant.DYNAMIC_SUFFIX)).collect(Collectors.toList()); + + columns.addAll(collect); + + Map columnMap = SalaryEntityUtil.convert2Map(columns, WeaTableColumn::getColumn); + + //默认设置 + PageListSettingPO pageListSettingPO = getPageListSettingMapper().getByPage(page, 1, null); + + //查询选中的项目 + List checkedList = new ArrayList<>(); + if (pageListSettingPO != null) { + checkedList = Optional.ofNullable(pageListSettingPO.getSetting()).orElse(new ArrayList<>()).stream().map(s -> columnMap.getOrDefault(s, new WeaTableColumn())).collect(Collectors.toList()); + } else { + checkedList = columns; + } + return PageListTemplateDetailDTO.builder().setting(columns).checked(checkedList).build(); + } + + return PageListTemplateDetailDTO.builder().setting(new ArrayList<>()).checked(new ArrayList<>()).build(); + } + + @Override + public void resetPageListSetting(PageListSettingResetParam param) { + ValidUtil.doValidator(param); + + String page = param.getPage(); + + //个人设置 + PageListSettingPO selfSetting = getPageListSettingMapper().getByPage(page, 0, (long) user.getUID()); + + if (selfSetting != null) { + getPageListSettingMapper().delete(selfSetting); + } + } + + @Override + public PageListTemplateDetailDTO getPageListTemplate(PageListTemplateQueryParam param) { + String page = param.getPage(); + if (SALARY_DETAILS_REPORT.getValue().equals(page)) { + List columns = new ArrayList<>(); + columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(87614, "薪资所属月"), "salaryMonth")); + columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(86184, "个税扣缴义务人"), "taxAgent")); + columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(86184, "账套"), "salarySob")); + columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(0, "姓名"), "userName")); + columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(0, "分部"), "subCompany")); + columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(0, "部门"), "department")); + columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(0, "岗位"), "jobTitle")); + columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(0, "员工状态"), "status")); + columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(0, "工号"), "workCode")); + columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(0, "证件号码"), "idNo")); + columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(0, "入职日期"), "companystartdate")); + columns.add(new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(86184, "次数"), "acctTimes").setDisplay(WeaBoolAttr.FALSE)); + if (StrUtil.isNotBlank(param.getName())) { + columns = columns.stream().filter(column -> column.getText().contains(param.getName())).collect(Collectors.toList()); + } + + List salaryItemList = getSalaryItemService(user).listAll(); + List salaryItemCols = salaryItemList.stream().filter(po -> { + String name = param.getName(); + if (StrUtil.isNotEmpty(name)) { + return po.getName() != null && po.getName().contains(name); + } + return true; + }).sorted((o1, o2) -> { + if (o1.getSortedIndex() == null && o2.getSortedIndex() == null) { + Integer systemType1 = o1.getSystemType() == null ? 0 : o1.getSystemType(); + Integer systemType2 = o2.getSystemType() == null ? 0 : o2.getSystemType(); + return systemType1.compareTo(systemType2); + } else { + Integer sortedIndex1 = o1.getSortedIndex() == null ? 0 : o1.getSortedIndex(); + Integer sortedIndex2 = o2.getSortedIndex() == null ? 0 : o2.getSortedIndex(); + return sortedIndex2.compareTo(sortedIndex1); + } + }).map(item -> new WeaTableColumn("100px", item.getName(), item.getId() + SalaryConstant.DYNAMIC_SUFFIX)).collect(Collectors.toList()); + + columns.addAll(salaryItemCols); + + Map columnMap = SalaryEntityUtil.convert2Map(columns, WeaTableColumn::getColumn); + List checkedList = columns; + Long id = param.getId(); + if (id != null) { + //编辑模板,指定模板id + PageListTemplatePO po = getPageListTemplateMapper().getById(id); + if (po != null) { + checkedList = Optional.ofNullable(po.getSetting()).orElse(new ArrayList<>()).stream().map(s -> columnMap.getOrDefault(s, new WeaTableColumn())).collect(Collectors.toList()); + } + } else { + //打开选中的模板 + List pageListTemplates = getPageListTemplates(PageListTemplateQueryParam.builder().page(page).build()); + List columnList = pageListTemplates.stream() + .filter(PageListTemplatePO::getChecked).map(PageListTemplatePO::getSetting).findFirst().orElse(new ArrayList<>()) + .stream().map(s -> columnMap.getOrDefault(s, new WeaTableColumn())).collect(Collectors.toList()); + if (CollectionUtil.isNotEmpty(columnList)) { + checkedList = columnList; + } + } + return PageListTemplateDetailDTO.builder().setting(columns).checked(checkedList).build(); + } + + return PageListTemplateDetailDTO.builder().build(); + } + + @Override + public List getPageListTemplates(PageListTemplateQueryParam param) { + + ValidUtil.doValidator(param); + + Date now = new Date(); + String page = param.getPage(); + + //个人配置模板 + PageListTemplatePO build = PageListTemplatePO.builder().page(page).build(); + List pos = getPageListTemplateMapper().listSome(build); + + //如果查不到不到系统模板,创建系统模板 + PageListTemplatePO systemTemplate = pos.stream().filter(po -> po.getSystemType() != null && po.getSystemType() == 1).findFirst().orElse(null); + if (systemTemplate == null) { + //查询系统默认配置 + PageListTemplateDetailDTO pageListSetting = getDefaultPageListSetting(PageListSettingQueryParam.builder().page(SALARY_DETAILS_REPORT.getValue()).build()); + + systemTemplate = PageListTemplatePO.builder() + .id(IdGenerator.generate()) + .page(param.getPage()) + .name("系统模板") + .sharedType(SharedTypeEnum.PUBLIC.getValue()) + .systemType(SalaryOnOffEnum.ON.getValue()) + .setting(pageListSetting.getChecked().stream().map(WeaTableColumn::getColumn).collect(Collectors.toList())) + .creator((long) user.getUID()) + .createTime(now) + .updateTime(now) + .deleteType(0) + .tenantKey(DEFAULT_TENANT_KEY).build(); + getPageListTemplateMapper().insertIgnoreNull(systemTemplate); + pos.add(systemTemplate); + } + + //获取当前选择的模板 + PageLinkPO link = getPageLinkMapper().listSome(PageLinkPO.builder().employeeId((long) user.getUID()).page(SALARY_DETAILS_REPORT.getValue()).build()).stream().findFirst().orElse(null); + if (link == null) { + link = PageLinkPO.builder() + .id(IdGenerator.generate()) + .employeeId((long) user.getUID()) + .page(param.getPage()) + .templateId(systemTemplate.getId()) + .tenantKey(DEFAULT_TENANT_KEY) + .createTime(new Date()) + .updateTime(new Date()) + .creator((long) user.getUID()) + .deleteType(0).build(); + getPageLinkMapper().insertIgnoreNull(link); + } + Long templateId = link.getTemplateId(); + + //权限控制 + TaxAgentQueryParam taxAgentQueryParam = TaxAgentQueryParam.builder().build(); + taxAgentQueryParam.setFilterType(AuthFilterTypeEnum.QUERY_DATA); + Collection taxAgentPOS = getTaxAgentService().listAuth(taxAgentQueryParam); + List taxIds = SalaryEntityUtil.properties(taxAgentPOS, TaxAgentPO::getId, Collectors.toList()); + Boolean chief = getTaxAgentService().isChief((long) user.getUID()); + pos = pos.stream().filter(po -> { + SharedTypeEnum sharedTypeEnum = SharedTypeEnum.parseByValue(po.getSharedType()); + //系统模板直接可见 + if (chief || po.getSystemType() == 1) { + return true; + } + //私有,只能自己看到 + if (sharedTypeEnum == SharedTypeEnum.PRIVATE) { + return Objects.equals((long) user.getUID(), po.getCreator()); + } + //共享 + if (sharedTypeEnum == SharedTypeEnum.PUBLIC) { + List limitIds = po.getLimitIds(); + return CollectionUtil.isEmpty(limitIds) || CollectionUtil.intersection(limitIds, taxIds).size() != 0; + } + return true; + }).peek(po -> { + po.setChecked(po.getId().equals(templateId)); + }).collect(Collectors.toList()); + return pos; + } + + @Override + public PageListTemplatePO savePageListTemplate(PageListTemplateSaveParam param) { + ValidUtil.doValidator(param); + Date now = new Date(); + Long id = param.getId(); + + PageListTemplatePO po; + if (id == null) { + po = PageListTemplatePO.builder() + .id(IdGenerator.generate()) + .page(param.getPage()) + .name(param.getName()) + .sharedType(param.getSharedType()) + .systemType(0) + .limitIds(param.getLimitIds()) + .setting(param.getSetting()) + .fileId(param.getFileId()) + .creator((long) user.getUID()) + .createTime(now) + .updateTime(now) + .deleteType(0) + .tenantKey(DEFAULT_TENANT_KEY).build(); + getPageListTemplateMapper().insertIgnoreNull(po); + } else { + po = getPageListTemplateMapper().getById(id); + if (po == null) { + throw new SalaryRunTimeException("模板不存在!"); + } + po.setName(param.getName()); + po.setSharedType(param.getSharedType()); + po.setLimitIds(param.getLimitIds()); + po.setSetting(param.getSetting()); + po.setFileId(param.getFileId()); + po.setUpdateTime(now); + getPageListTemplateMapper().updateIgnoreNull(po); + } + + return po; + } + + @Override + public XSSFWorkbook downloadPageExportTemplateFile(DownloadTemplateParam param) { + List> rowList = new ArrayList<>(); + List heads = param.getHeads(); + List setting = param.getSetting(); + if (CollUtil.isEmpty(heads)||CollUtil.isEmpty(setting)||!Objects.equals(heads.size(), setting.size())){ + throw new SalaryRunTimeException("未选择字段"); + } + setting = setting.stream().map(s -> String.format("{.%s}", s)).collect(Collectors.toList()); + rowList.add(heads); + rowList.add(setting); + + return ExcelUtilPlus.genWorkbook(rowList, "薪资明细"); + } + + @Override + public void changePageListTemplate(PageListTemplateChangeParam param) { + + ValidUtil.doValidator(param); + + List pageLinkPOS = getPageLinkMapper().listSome(PageLinkPO.builder().employeeId((long) user.getUID()).page(param.getPage()).build()); + if (CollUtil.isNotEmpty(pageLinkPOS)) { + Set ids = SalaryEntityUtil.properties(pageLinkPOS, PageLinkPO::getId); + getPageLinkMapper().deleteByIds(ids); + } + PageLinkPO pageLinkPO = PageLinkPO.builder().id(IdGenerator.generate()).employeeId((long) user.getUID()).page(param.getPage()).templateId(param.getTemplateId()).tenantKey(DEFAULT_TENANT_KEY).createTime(new Date()).updateTime(new Date()).creator((long) user.getUID()).deleteType(0).build(); + + getPageLinkMapper().insertIgnoreNull(pageLinkPO); + } + + @Override + public List getPageListColumns(String page) { + PageListTemplateDetailDTO pageListTemplate = getPageListTemplate((PageListTemplateQueryParam.builder().page(page).build())); + return pageListTemplate.getChecked(); + } + + @Override + public PageInfo getTemplates(PageListTemplateQueryParam param) { + PageListTemplatePO build = PageListTemplatePO.builder().page(param.getPage()).build(); + List pos = getPageListTemplateMapper().listSome(build); + + //权限控制 + List agentPOList = getTaxAgentService().listAll(); + Map idNameMap = SalaryEntityUtil.convert2Map(agentPOList, TaxAgentPO::getId, TaxAgentPO::getName); + //权限控制 + TaxAgentQueryParam taxAgentQueryParam = TaxAgentQueryParam.builder().build(); + taxAgentQueryParam.setFilterType(AuthFilterTypeEnum.QUERY_DATA); + Collection taxAgentPOS = getTaxAgentService().listAuth(taxAgentQueryParam); + Boolean chief = getTaxAgentService().isChief((long) user.getUID()); + List taxIds = SalaryEntityUtil.properties(taxAgentPOS, TaxAgentPO::getId, Collectors.toList()); + List templateDTOS = pos.stream() + .filter(po -> { + SharedTypeEnum sharedTypeEnum = SharedTypeEnum.parseByValue(po.getSharedType()); + //系统模板直接可见 + if (chief || po.getSystemType() == 1) { + return true; + } + //私有,只能自己看到 + if (sharedTypeEnum == SharedTypeEnum.PRIVATE) { + return Objects.equals((long) user.getUID(), po.getCreator()); + } + //共享 + if (sharedTypeEnum == SharedTypeEnum.PUBLIC) { + List limitIds = po.getLimitIds(); + return CollectionUtil.isEmpty(limitIds) || CollectionUtil.intersection(limitIds, taxIds).size() != 0; + } + return true; + }).map(po -> { + Integer fileId = po.getFileId(); + String fileName = ""; + if (fileId != null) { + ImageFileManager imageFileManager = new ImageFileManager(); + imageFileManager.getImageFileInfoById(fileId); + fileName = imageFileManager.getImageFileName(); + } + + return PageListTemplateDTO.builder() + .id(po.getId()) + .page(po.getPage()) + .name(po.getName()) + .sharedType(po.getSharedType()) + .systemType(po.getSystemType()) + .sharedTypeName(SharedTypeEnum.parseByValue(po.getSharedType()).getDefaultLabel()) + .systemTypeName(po.getSystemType() == 1 ? "系统模板" : "自定义") + .limits(CollUtil.isEmpty(po.getLimitIds()) ? "所有" : Optional.ofNullable(po.getLimitIds()).orElse(new ArrayList<>()).stream().map(id -> idNameMap.getOrDefault(id, "")).collect(Collectors.joining(","))) + .limitIds(CollUtil.isEmpty(po.getLimitIds()) ? new ArrayList<>() : po.getLimitIds()) + .setting(po.getSetting()) + .canEdit(chief || (Objects.equals((long) user.getUID(), po.getCreator()) && po.getSystemType() == 0)) + .fileId(fileId) + .fileName(fileName) + .build(); + }) + .collect(Collectors.toList()); + + return SalaryPageUtil.buildPage(param.getCurrent(), param.getPageSize(), templateDTOS, PageListTemplateDTO.class); + } + + @Override + public void deletePageListTemplate(PageListTemplateDeleteParam param) { + List ids = param.getIds(); + + if (CollUtil.isEmpty(ids)) { + throw new SalaryRunTimeException("未选择模板!"); + } + + ids.forEach(id -> { + PageListTemplatePO pageListTemplatePO = getPageListTemplateMapper().getById(id); + if (pageListTemplatePO == null) { + throw new SalaryRunTimeException("模板不存在!"); + } + if (pageListTemplatePO.getSystemType() == 1) { + throw new SalaryRunTimeException("系统模板不允许删除!"); + } + if (!Objects.equals((long) user.getUID(), pageListTemplatePO.getCreator())) { + throw new SalaryRunTimeException(pageListTemplatePO.getName() + "模板无权限删除!"); + } + List pageLinkPOS = getPageLinkMapper().listSome(PageLinkPO.builder().templateId(id).build()); + if (CollUtil.isNotEmpty(pageLinkPOS)) { + throw new SalaryRunTimeException(pageListTemplatePO.getName() + "模板正被使用!不允许删除"); + } + }); + + getPageListTemplateMapper().deleteByIds(ids); + } +} diff --git a/src/com/engine/salary/service/impl/SpecialAddDeductionServiceImpl.java b/src/com/engine/salary/service/impl/SpecialAddDeductionServiceImpl.java new file mode 100644 index 000000000..ed7102c46 --- /dev/null +++ b/src/com/engine/salary/service/impl/SpecialAddDeductionServiceImpl.java @@ -0,0 +1,702 @@ +package com.engine.salary.service.impl; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.NumberUtil; +import com.api.formmode.mybatis.util.SqlProxyHandle; +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.hrmelog.entity.dto.LoggerContext; +import com.engine.salary.biz.SpecialAddDeductionBiz; +import com.engine.salary.config.SalaryElogConfig; +import com.engine.salary.encrypt.EncryptUtil; +import com.engine.salary.entity.datacollection.AddUpDeduction; +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.datacollection.dto.SpecialAddDeductionListDTO; +import com.engine.salary.entity.datacollection.dto.SpecialAddDeductionRecordDTO; +import com.engine.salary.entity.datacollection.param.SpecialAddDeductionImportParam; +import com.engine.salary.entity.datacollection.param.SpecialAddDeductionParam; +import com.engine.salary.entity.datacollection.param.SpecialAddDeductionQueryParam; +import com.engine.salary.entity.datacollection.param.SpecialAddDeductionRecordDeleteParam; +import com.engine.salary.entity.datacollection.po.SpecialAddDeductionPO; +import com.engine.salary.entity.taxagent.dto.TaxAgentManageRangeEmployeeDTO; +import com.engine.salary.entity.taxagent.param.TaxAgentQueryParam; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import com.engine.salary.enums.OperateTypeEnum; +import com.engine.salary.enums.UserStatusEnum; +import com.engine.salary.enums.auth.AuthFilterTypeEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.mapper.datacollection.SpecialAddDeductionMapper; +import com.engine.salary.mapper.sys.SalarySysConfMapper; +import com.engine.salary.service.AddUpDeductionService; +import com.engine.salary.service.SalaryEmployeeService; +import com.engine.salary.service.SpecialAddDeductionService; +import com.engine.salary.service.TaxAgentService; +import com.engine.salary.service.auth.AuthService; +import com.engine.salary.service.auth.AuthServiceImpl; +import com.engine.salary.sys.entity.po.SalarySysConfPO; +import com.engine.salary.sys.entity.vo.OrderRuleVO; +import com.engine.salary.sys.service.SalarySysConfService; +import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.db.MapperProxyFactory; +import com.engine.salary.util.excel.ExcelParseHelper; +import com.engine.salary.util.excel.ExcelPreviewDTO; +import com.engine.salary.util.excel.ExcelUtil; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.util.page.SalaryPageUtil; +import com.google.common.collect.Maps; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.Validate; +import org.apache.poi.util.IOUtils; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import weaver.file.ImageFileManager; +import weaver.general.Util; +import weaver.hrm.User; + +import java.io.InputStream; +import java.math.BigDecimal; +import java.text.SimpleDateFormat; +import java.time.YearMonth; +import java.util.*; +import java.util.stream.Collectors; + +import static com.engine.salary.constant.SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY; +import static com.engine.salary.util.excel.ExcelSupport.EXCEL_TYPE_XLSX; + +public class SpecialAddDeductionServiceImpl extends Service implements SpecialAddDeductionService { + private EncryptUtil encryptUtil = new EncryptUtil(); + + private SpecialAddDeductionBiz getSpecialAddDeductionBiz() { + return new SpecialAddDeductionBiz(); + } + + private SpecialAddDeductionMapper getSpecialAddDeductionMapper() { + return MapperProxyFactory.getProxy(SpecialAddDeductionMapper.class); + } + + private TaxAgentService getTaxAgentService(User user) { + return ServiceUtil.getService(TaxAgentServiceImpl.class, user); + } + + private AddUpDeductionService getAddUpDeductionService(User user) { + return ServiceUtil.getService(AddUpDeductionServiceImpl.class, user); + } + + private SalaryEmployeeService getSalaryEmployeeService(User user) { + return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user); + } + + private SalarySysConfMapper getSalarySysConfMapper() { + return SqlProxyHandle.getProxy(SalarySysConfMapper.class); + } + + private SalarySysConfService getSalarySysConfService(User user) { + return ServiceUtil.getService(SalarySysConfServiceImpl.class, user); + } + + public AuthService getAuthService(User user) { + return ServiceUtil.getService(AuthServiceImpl.class, user); + } + + @Override + public SpecialAddDeductionPO getById(Long id) { + return getSpecialAddDeductionBiz().getById(id); + } + + + @Override + public PageInfo listPage(SpecialAddDeductionQueryParam queryParam) { + //排序配置 + OrderRuleVO orderRule = getSalarySysConfService(user).orderRule(); + queryParam.setOrderRule(orderRule); + List list = getSpecialAddDeductionMapper().listByParam(queryParam); + list = getAuthService(user).auth(list, AuthFilterTypeEnum.DATA_OPT, SpecialAddDeductionListDTO.class); + + PageInfo page = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), + list, SpecialAddDeductionListDTO.class); + encryptUtil.decryptList(page.getList(), SpecialAddDeductionListDTO.class); + return page; + } + + @Override + public PageInfo recordListPage(SpecialAddDeductionQueryParam queryParam) { + List list = getSpecialAddDeductionMapper().listDtoByParam(queryParam); + PageInfo page = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), + list, SpecialAddDeductionRecordDTO.class); + encryptUtil.decryptList(page.getList(), SpecialAddDeductionRecordDTO.class); + return page; + } + + + + @Override + public ExcelPreviewDTO preview(SpecialAddDeductionImportParam importParam) { + + //excel文件id + String imageId = Util.null2String(importParam.getImageId()); + Validate.notBlank(imageId, "imageId为空"); + + InputStream fileInputStream = null; + try { + fileInputStream = ImageFileManager.getInputStreamById(Integer.parseInt(imageId)); + return ExcelParseHelper.preview(fileInputStream, 0, EXCEL_TYPE_XLSX); + } finally { + IOUtils.closeQuietly(fileInputStream); + } + } + + + public Map importData(SpecialAddDeductionImportParam importParam) { + + long currentEmployeeId = user.getUID(); + Map apidatas = new HashMap(); + SpecialAddDeductionBiz SpecialAddDeductionBiz = new SpecialAddDeductionBiz(); + + //查询对于人员信息导入筛选的全局配置 + SalarySysConfPO salarySysConfPO = getSalarySysConfMapper().getOneByCode("matchEmployeeMode"); + String confValue = (salarySysConfPO != null && salarySysConfPO.getConfValue() != null && !"".equals(salarySysConfPO.getConfValue())) ? salarySysConfPO.getConfValue() : "0"; + + //检验参数 + checkImportParam(importParam); + + //excel文件id + String imageId = Util.null2String(importParam.getImageId()); + Validate.notBlank(imageId, "imageId为空"); + //个税扣缴义务人 + String taxAgentId = Util.null2String(importParam.getTaxAgentId()); + + InputStream fileInputStream = null; + try { + fileInputStream = ImageFileManager.getInputStreamById(Integer.parseInt(imageId)); + List SpecialAddDeductions = ExcelParseHelper.parse2Map(fileInputStream, SpecialAddDeductionListDTO.class, 0, 1, 14, "SpecialAddDeductionTemplate.xlsx"); + + int total = SpecialAddDeductions.size(); + int index = 0; + int successCount = 0; + int errorCount = 0; + + //人员信息 + List employees = getSalaryEmployeeService(user).listEmployee(); + // 获取个税扣缴义务人 + TaxAgentQueryParam param = TaxAgentQueryParam.builder().build(); + param.setFilterType(AuthFilterTypeEnum.ADMIN_DATA); + List taxAgentList = getTaxAgentService(user).listAuth(param); + + // 错误excel内容 + List errorData = new ArrayList<>(); + //合规数据 + List eligibleData = new ArrayList<>(); + + for (int i = 0; i < SpecialAddDeductions.size(); i++) { + SpecialAddDeductionListDTO dto = SpecialAddDeductions.get(i); + + Date now = new Date(); + //待插入数据库对象 + SpecialAddDeductionPO po = SpecialAddDeductionPO.builder() + .tenantKey(DEFAULT_TENANT_KEY) + .createTime(now) + .updateTime(now) + .creator((long) user.getUID()) + .build(); + + //异常点数量 + int errorSum = 0; + + //行号 + String rowIndex = String.format("第%s行", i + 2); + + //相同的姓名 + String userName = dto.getUsername(); + String deparmentName = dto.getDepartmentName(); + String mobile = dto.getMobile(); + String workcode = dto.getJobNum(); + String idNo = dto.getIdNo(); + List employeeSameIds = new ArrayList<>(); + + //筛选导入人员信息可以在人力资源池中匹配到的人员信息 + List emps = getSalaryEmployeeService(user) + .matchImportEmployee(confValue, employees, userName, deparmentName, mobile, workcode, idNo, null); + //含在职和离职,选在职数据 + if (CollectionUtils.isNotEmpty(emps) && emps.size() > 1) { + employeeSameIds = emps.stream() + .filter(e -> UserStatusEnum.getNormalStatus().contains(e.getStatus())) + .map(DataCollectionEmployee::getEmployeeId) + .collect(Collectors.toList()); + } + if (CollectionUtils.isNotEmpty(emps) && emps.size() == 1) { + employeeSameIds = emps.stream() + .map(DataCollectionEmployee::getEmployeeId) + .collect(Collectors.toList()); + } + + //当人员信息导入筛选的全局配置为"0"时,姓名才是必填项 + if (StringUtils.isBlank(userName) && "0".equals(confValue)) { + //姓名 不能为空 + //错误消息对象 + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowIndex + "姓名不能为空"); + errorData.add(errorMessageMap); + errorSum += 1; + } else if (CollectionUtils.isEmpty(employeeSameIds) || employeeSameIds.size() > 1) { + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowIndex + "员工信息不存在或者存在多个员工"); + errorData.add(errorMessageMap); + errorSum += 1; + } else { + Long employeeId = CollectionUtils.isNotEmpty(employeeSameIds) && employeeSameIds.size() == 1 ? employeeSameIds.get(0) : null; + if (employeeId != null && employeeId > 0) { + po.setEmployeeId(employeeId); + } else { + //姓名错误,系统内不存在该姓名 + Map errorMessageMap = new HashMap<>(); + errorMessageMap.put("message", rowIndex + "姓名错误,系统内不存在该姓名"); + errorData.add(errorMessageMap); + errorSum += 1; + } + } + + + String taxAgentName = dto.getTaxAgentName(); + if (StringUtils.isBlank(taxAgentName)) { + //个税扣缴义务人不能为空 + Map errorMessageMap = new HashMap<>(); + errorMessageMap.put("message", rowIndex + "个税扣缴义务人不能为空"); + errorData.add(errorMessageMap); + errorSum += 1; + } else { + Optional optionalTemp = taxAgentList.stream().filter(m -> m.getName().equals(taxAgentName)).findFirst(); + if (optionalTemp.isPresent()) { + if (StringUtils.isNotEmpty(taxAgentId) && !optionalTemp.get().getId().equals(Long.valueOf(taxAgentId))) { + //个税扣缴义务人与导入时选择的不一致 + Map errorMessageMap = new HashMap<>(); + errorMessageMap.put("message", rowIndex + "个税扣缴义务人与导入时选择的不一致"); + errorData.add(errorMessageMap); + errorSum += 1; + } else { + po.setTaxAgentId(optionalTemp.get().getId()); + } + } else { + //个税扣缴义务人不存在 + Map errorMessageMap = new HashMap<>(); + errorMessageMap.put("message", rowIndex + "个税扣缴义务人不存在或不在权限范围内"); + errorData.add(errorMessageMap); + errorSum += 1; + } + } + + // 核心字段, 前端没有传入的项目用空值覆盖 + po.setInfantCare(dto.getInfantCare() == null ? "" : dto.getInfantCare()) + .setSeriousIllnessTreatment(dto.getSeriousIllnessTreatment() == null ? "" : dto.getSeriousIllnessTreatment()) + .setSupportingElder(dto.getSupportingElder() == null ? "" : dto.getSupportingElder()) + .setHousingRent(dto.getHousingRent() == null ? "" : dto.getHousingRent()) + .setHousingLoanInterest(dto.getHousingLoanInterest() == null ? "" : dto.getHousingLoanInterest()) + .setContinuingEducation(dto.getContinuingEducation() == null ? "" : dto.getContinuingEducation()) + .setChildrenEducation(dto.getChildrenEducation() == null ? "" : dto.getChildrenEducation()); + + + //fixme 分权判断 + if (errorSum == 0) { + successCount += 1; + // 合格数据 + eligibleData.add(po); + } else { + errorCount += 1; + // 添加错误数据 + } + } + + //入库 + SpecialAddDeductionBiz.handleImportData(eligibleData, user); + + apidatas.put("successCount", successCount); + apidatas.put("errorCount", errorCount); + apidatas.put("errorData", errorData); + + } finally { + IOUtils.closeQuietly(fileInputStream); + } + return apidatas; + } + + private void checkImportParam(SpecialAddDeductionImportParam importParam) { + //excel文件id + String imageId = Util.null2String(importParam.getImageId()); + //个税扣缴义务人 + String taxAgentId = Util.null2String(importParam.getTaxAgentId()); + + if (StringUtils.isBlank(imageId)) { + throw new SalaryRunTimeException("文件不存在"); + } + } + + /** + * 导出 + * + * @param param + * @param isTemplate + * @return + */ + public XSSFWorkbook export(SpecialAddDeductionQueryParam param, boolean isTemplate) { + + //获取操作按钮资源 + List> rowList = getExcelRowList(param, isTemplate); + + // 记录操作日志 + String name = SalaryI18nUtil.getI18nLabel(0, "导出"); + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setTargetName(SalaryI18nUtil.getI18nLabel(0, "专项附加扣除")); + loggerContext.setOperateType(OperateTypeEnum.EXCEL_EXPORT.getValue()); + loggerContext.setOperateTypeName(name); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "专项附加扣除") + "-" + name); + loggerContext.setUser(user); + SalaryElogConfig.specialAddDeductionLoggerTemplate.write(loggerContext); + + //获取excel + return ExcelUtil.genWorkbookWithDefaultPattern(rowList, "专项附加免税扣除", 2); + } + + + /** + * 获取excel数据行 + * + * @return 导出数据行集合 + */ + private List> getExcelRowList(SpecialAddDeductionQueryParam param, boolean isTemplate) { + long employeeId = user.getUID(); + //excel标题 + List title = Arrays.asList("姓名", "个税扣缴义务人", "部门", "手机号", "工号", "证件号码", "入职日期", "子女教育", "继续教育", "住房贷款利息", "住房租金", "赡养老人", "大病医疗", "婴幼儿照护"); + + List> rowList = new ArrayList<>(); + rowList.add(title); + if (!isTemplate || param.isHasData()) { + // 非下载导入模版,查询数据填充 + List> dataRowList = queryInfoForExcel(param, rowList); + rowList.addAll(dataRowList); + } + return rowList; + } + + + /** + * 导出详情列表 + * + * @param param + * @return + */ + public XSSFWorkbook exportDetail(SpecialAddDeductionQueryParam param) { + + SpecialAddDeductionBiz biz = new SpecialAddDeductionBiz(); + + Long id = param.getSpecialAddDeductionId(); + if (id == null) { + throw new SalaryRunTimeException("id不能为空"); + } + + SpecialAddDeductionPO po = biz.getById(id); + if (po == null) { + throw new SalaryRunTimeException(String.format("专项附加扣除不存在" + "[id:%s]", id)); + } + + List employeeList = getSalaryEmployeeService(user).getEmployeeByIds(Collections.singletonList(po.getEmployeeId())); + if (CollectionUtils.isEmpty(employeeList)) { + throw new SalaryRunTimeException("员工信息不存在"); + } + + //构建参数 + param.setEmployeeId(po.getEmployeeId()); + + + //获取操作按钮资源 + List> rowList = getExcelRowDetailList(param); + + //获取excel + return ExcelUtil.genWorkbookWithDefaultPattern(rowList, "专项附加扣除明细", 2); + } + + + /** + * 导出详情 + * + * @param param + * @return + */ + private List> getExcelRowDetailList(SpecialAddDeductionQueryParam param) { + //excel标题 + List title = Arrays.asList("姓名", "个税扣缴义务人", "部门", "手机号", "工号", "子女教育", "继续教育", "住房贷款利息", "住房租金", "赡养老人", "大病医疗", "婴幼儿照护"); + + SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM"); + //查询详细信息 + List list = getSpecialAddDeductionBiz().listDTOByParam(param); + encryptUtil.decryptList(list, SpecialAddDeductionRecordDTO.class); + final List> dataRowList = Optional.ofNullable(list) + .map(List::stream) + .map(operatorStream -> operatorStream.map(dto -> { + List cellList = new ArrayList<>(); + cellList.add(Util.null2String(dto.getUsername())); + cellList.add(Util.null2String(dto.getTaxAgentName())); + cellList.add(Util.null2String(dto.getDepartmentName())); + cellList.add(Util.null2String(dto.getMobile())); + cellList.add(Util.null2String(dto.getJobNum())); + cellList.add(NumberUtil.isNumber(dto.getChildrenEducation()) ? new BigDecimal(dto.getChildrenEducation()) : Util.null2String(dto.getChildrenEducation())); + cellList.add(NumberUtil.isNumber(dto.getContinuingEducation()) ? new BigDecimal(dto.getContinuingEducation()) : Util.null2String(dto.getContinuingEducation())); + cellList.add(NumberUtil.isNumber(dto.getHousingLoanInterest()) ? new BigDecimal(dto.getHousingLoanInterest()) : Util.null2String(dto.getHousingLoanInterest())); + cellList.add(NumberUtil.isNumber(dto.getHousingRent()) ? new BigDecimal(dto.getHousingRent()) : Util.null2String(dto.getHousingRent())); + cellList.add(NumberUtil.isNumber(dto.getSupportingElder()) ? new BigDecimal(dto.getSupportingElder()) : Util.null2String(dto.getSupportingElder())); + cellList.add(NumberUtil.isNumber(dto.getSeriousIllnessTreatment()) ? new BigDecimal(dto.getSeriousIllnessTreatment()) : Util.null2String(dto.getSeriousIllnessTreatment())); + cellList.add(NumberUtil.isNumber(dto.getInfantCare()) ? new BigDecimal(dto.getInfantCare()) : Util.null2String(dto.getInfantCare())); + return cellList; + }).collect(Collectors.toList())) + .orElse(Collections.emptyList()); + + List> rowList = new ArrayList<>(); + rowList.add(title); + rowList.addAll(dataRowList); + return rowList; + } + + + @Override + public List getSpecialAddDeductionList(YearMonth declareMonth, List employeeIds, Long taxAgentId) { + if (declareMonth == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100342, "参数有误:申报月份必传")); + } + SpecialAddDeductionBiz SpecialAddDeductionBiz = new SpecialAddDeductionBiz(); + return SpecialAddDeductionBiz.listByTaxAgentIds(null); + } + + @Override + public void editData(SpecialAddDeductionParam specialAddDeductionParam) { + SpecialAddDeductionBiz SpecialAddDeductionBiz = new SpecialAddDeductionBiz(); + Long currentEmployeeId = (long) user.getUID(); + // 获取所有个税扣缴义务人 + Collection taxAgentList = + getTaxAgentService(user).listTaxAgentAndEmployeeTree(currentEmployeeId); + SpecialAddDeductionPO byId = SpecialAddDeductionBiz.getById(specialAddDeductionParam.getId()); + if (byId == null) { + throw new SalaryRunTimeException("该数据不存在!"); + } + //管理员可以编辑该扣缴义务人数据,其他人可以编辑本人数据 + boolean canEdit = byId.getEmployeeId().equals((long) user.getUID()) + || taxAgentList.stream().anyMatch(t -> Objects.equals(t.getTaxAgentId(), byId.getTaxAgentId())); + if (!canEdit) { + //没有编辑权限 + throw new SalaryRunTimeException("该个税扣缴义务人无权限编辑此数据!"); + } + ArrayList updateList = new ArrayList<>(); + SpecialAddDeductionPO build = SpecialAddDeductionPO.builder() + .id(specialAddDeductionParam.getId()) + .childrenEducation(specialAddDeductionParam.getChildrenEducation()) + .continuingEducation(specialAddDeductionParam.getContinuingEducation()) + .housingLoanInterest(specialAddDeductionParam.getHousingLoanInterest()) + .housingRent(specialAddDeductionParam.getHousingRent()) + .infantCare(specialAddDeductionParam.getInfantCare()) + .supportingElder(specialAddDeductionParam.getSupportingElder()) + .seriousIllnessTreatment(specialAddDeductionParam.getSeriousIllnessTreatment()) + .build(); + updateList.add(build); + SpecialAddDeductionBiz.batchUpdate(updateList); + + // 记录操作日志 + SpecialAddDeductionPO newValue = SpecialAddDeductionBiz.getById(build.getId()); + String name = SalaryI18nUtil.getI18nLabel(0, "编辑"); + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setTargetId(newValue.getId().toString()); + loggerContext.setTargetName(SalaryI18nUtil.getI18nLabel(0, "专项附加扣除") + "-" + newValue.getId()); + loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue()); + loggerContext.setOperateTypeName(name); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "专项附加扣除") + "-" + SalaryI18nUtil + .getI18nLabel(0, "编辑")); + loggerContext.setOldValues(byId); + loggerContext.setNewValues(newValue); + loggerContext.setUser(user); + SalaryElogConfig.specialAddDeductionLoggerTemplate.write(loggerContext); + } + + @Override + public void createData(SpecialAddDeductionParam specialAddDeductionParam) { + long currentEmployeeId = user.getUID(); + Boolean openDevolution = getTaxAgentService(user).isOpenDevolution(); + SpecialAddDeductionBiz SpecialAddDeductionBiz = new SpecialAddDeductionBiz(); + //查询对于人员信息导入筛选的全局配置 + SalarySysConfPO salarySysConfPO = getSalarySysConfMapper().getOneByCode("matchEmployeeMode"); + String confValue = (salarySysConfPO != null && salarySysConfPO.getConfValue() != null && !"".equals(salarySysConfPO.getConfValue())) ? salarySysConfPO.getConfValue() : "0"; + + //人员信息 + List employees = getSalaryEmployeeService(user).listEmployee(); + // 获取所有个税扣缴义务人 + Collection taxAgentList = getTaxAgentService(user).listTaxAgentAndEmployeeTree(currentEmployeeId); + // 查询已有数据 + List list = getSpecialAddDeductionBiz().listByTaxAgentIds(null); + //合规数据 + List insertData = new ArrayList<>(); + Date now = new Date(); + //待插入数据库对象 + SpecialAddDeductionPO po = SpecialAddDeductionPO.builder() + .tenantKey(DEFAULT_TENANT_KEY) + .createTime(now) + .updateTime(now) + .creator((long) user.getUID()) + .build(); + + //筛选导入人员信息可以在人力资源池中匹配到的人员信息 + boolean employeeSameId = employees.stream() + .anyMatch(e -> Objects.equals(e.getEmployeeId(), specialAddDeductionParam.getEmployeeId())); + if (!employeeSameId) { + throw new SalaryRunTimeException("员工信息不存在"); + } + po.setEmployeeId(specialAddDeductionParam.getEmployeeId()); + String taxAgentName = specialAddDeductionParam.getTaxAgentName(); + if (StringUtils.isBlank(taxAgentName)) { + //个税扣缴义务人不能为空 + throw new SalaryRunTimeException("个税扣缴义务人不能为空"); + } else { + Optional optionalTemp = taxAgentList.stream().filter(m -> m.getTaxAgentName().equals(taxAgentName)).findFirst(); + if (optionalTemp.isPresent()) { + po.setTaxAgentId(optionalTemp.get().getTaxAgentId()); + } else { + //个税扣缴义务人不存在或不在权限范围内 + throw new SalaryRunTimeException("个税扣缴义务人不存在或不在权限范围内"); + } + } + //数据填充 + po.setContinuingEducation(specialAddDeductionParam.getContinuingEducation()) + .setChildrenEducation(specialAddDeductionParam.getChildrenEducation()) + .setHousingLoanInterest(specialAddDeductionParam.getHousingLoanInterest()) + .setHousingRent(specialAddDeductionParam.getHousingRent()) + .setSupportingElder(specialAddDeductionParam.getSupportingElder()) + .setSeriousIllnessTreatment(specialAddDeductionParam.getSeriousIllnessTreatment()) + .setInfantCare(specialAddDeductionParam.getInfantCare()); + //fixme 分权判断 + insertData.add(po); + //入库 + SpecialAddDeductionBiz.handleImportData(insertData, user); + } + + @Override + public void deleteSelectData(SpecialAddDeductionRecordDeleteParam deleteParam) { + long currentEmployeeId = user.getUID(); + // 获取所有个税扣缴义务人 + Collection taxAgentList = + getTaxAgentService(user).listTaxAgentAndEmployeeTree(currentEmployeeId); + SpecialAddDeductionBiz SpecialAddDeductionBiz = new SpecialAddDeductionBiz(); + List deleteIds = deleteParam.getIds(); + List deleteList = new ArrayList<>(); + List oldSpecialAddDeductionList = new ArrayList<>(); + for (Long id : deleteIds) { + SpecialAddDeductionPO byId = SpecialAddDeductionBiz.getById(id); + if (byId == null) { + throw new SalaryRunTimeException("数据不存在或已被删除!"); + } + // 判断是否在个税扣缴义务人范围内 + boolean isNotInRegion = + taxAgentList.stream() + .noneMatch(m -> Objects.equals(m.getTaxAgentId(), byId.getTaxAgentId())); + if (isNotInRegion) { + throw new SalaryRunTimeException("个税扣缴义务人不存在或不在权限范围内"); + } + deleteList.add(byId.getId()); + oldSpecialAddDeductionList.add(byId); + } + SpecialAddDeductionBiz.batchDeleteByIds(deleteList); + + // 记录操作日志 + if (CollectionUtils.isNotEmpty(oldSpecialAddDeductionList)) { + oldSpecialAddDeductionList.stream().forEach(e -> { + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setTargetId(e.getId().toString()); + loggerContext.setTargetName(SalaryI18nUtil.getI18nLabel(0, "专项附加扣除") + "-" + e.getId()); + loggerContext.setOperateType(OperateTypeEnum.DELETE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "删除")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "专项附加扣除") + "-" + SalaryI18nUtil + .getI18nLabel(0, "删除")); + loggerContext.setOldValues(e); + loggerContext.setUser(user); + SalaryElogConfig.specialAddDeductionLoggerTemplate.write(loggerContext); + }); + } + } + + @Override + public void deleteAllData(SpecialAddDeductionRecordDeleteParam deleteParam) { + // 获取所有个税扣缴义务人 + Collection taxAgentList = + getTaxAgentService(user).listTaxAgentAndEmployeeTree((long) user.getUID()); + List taxAgentIds = taxAgentList.stream() + .map(TaxAgentManageRangeEmployeeDTO::getTaxAgentId) + .collect(Collectors.toList()); + SpecialAddDeductionBiz specialAddDeductionBiz = new SpecialAddDeductionBiz(); + + if (deleteParam.getTaxAgentId() != null && (!deleteParam.getTaxAgentId().equals(""))) { + // 设置了个税扣缴义务人 + Long taxAgentId = SalaryEntityUtil.string2Long(deleteParam.getTaxAgentId()); + boolean canDelete = taxAgentIds.stream().anyMatch(t -> Objects.equals(t, taxAgentId)); + if (!canDelete) { + throw new SalaryRunTimeException("个税扣缴义务人不存在或不在权限范围内!"); + } + ArrayList tai = new ArrayList<>(); + tai.add(taxAgentId); + taxAgentIds = tai; + } + // 获取所有想要删除的数据 + List list = specialAddDeductionBiz.listByTaxAgentIds(taxAgentIds); + List deleteIds = list.stream().map(SpecialAddDeductionPO::getId).collect(Collectors.toList()); + specialAddDeductionBiz.batchDeleteByIds(deleteIds); + + // 记录操作日志 + Collection finalTaxAgentIds = taxAgentIds; + List taxAgentNames = taxAgentList.stream().filter(t -> finalTaxAgentIds.contains(t.getTaxAgentId())) + .map(TaxAgentManageRangeEmployeeDTO::getTaxAgentName).collect(Collectors.toList()); + String name = StringUtils.join(taxAgentNames, ","); + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setTargetName(name); + loggerContext.setOperateType(OperateTypeEnum.CLEAR.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "一键清空")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "专项附加扣除") + "-" + SalaryI18nUtil + .getI18nLabel(0, "一键清空:") + name); + loggerContext.setUser(user); + SalaryElogConfig.specialAddDeductionLoggerTemplate.write(loggerContext); + } + + @Override + public List getSpecialAddDeductionPOByEmployee(List employeeId, Long taxAgentId) { + return getSpecialAddDeductionBiz().getByEmployeeId(employeeId, taxAgentId); + } + + @Override + public SpecialAddDeductionRecordDTO getRecordById(Long id) { + List specialAddDeductionRecordDTOList = getSpecialAddDeductionBiz().listDTOByParam(SpecialAddDeductionQueryParam.builder().specialAddDeductionId(id).build()); + return CollUtil.isNotEmpty(specialAddDeductionRecordDTOList) ? specialAddDeductionRecordDTOList.get(0) : null; + } + + private List> queryInfoForExcel(SpecialAddDeductionQueryParam param, List> rowList) { + //排序配置 + OrderRuleVO orderRule = getSalarySysConfService(user).orderRule(); + param.setOrderRule(orderRule); + List list = getSpecialAddDeductionBiz().listByParam(param); + list = getAuthService(user).auth(list, AuthFilterTypeEnum.QUERY_DATA, SpecialAddDeductionListDTO.class); + final List> dataRowList = Optional.ofNullable(list) + .map(List::stream) + .map(operatorStream -> operatorStream.map(dto -> { + List cellList = new ArrayList<>(); + cellList.add(Util.null2String(dto.getUsername())); + cellList.add(Util.null2String(dto.getTaxAgentName())); + cellList.add(Util.null2String(dto.getDepartmentName())); + cellList.add(Util.null2String(dto.getMobile())); + cellList.add(Util.null2String(dto.getJobNum())); + cellList.add(Util.null2String(dto.getIdNo())); + cellList.add(Util.null2String(dto.getHiredate())); + cellList.add(NumberUtil.isNumber(dto.getChildrenEducation()) ? new BigDecimal(dto.getChildrenEducation()) : Util.null2String(dto.getChildrenEducation())); + cellList.add(NumberUtil.isNumber(dto.getContinuingEducation()) ? new BigDecimal(dto.getContinuingEducation()) : Util.null2String(dto.getContinuingEducation())); + cellList.add(NumberUtil.isNumber(dto.getHousingLoanInterest()) ? new BigDecimal(dto.getHousingLoanInterest()) : Util.null2String(dto.getHousingLoanInterest())); + cellList.add(NumberUtil.isNumber(dto.getHousingRent()) ? new BigDecimal(dto.getHousingRent()) : Util.null2String(dto.getHousingRent())); + cellList.add(NumberUtil.isNumber(dto.getSupportingElder()) ? new BigDecimal(dto.getSupportingElder()) : Util.null2String(dto.getSupportingElder())); + cellList.add(NumberUtil.isNumber(dto.getSeriousIllnessTreatment()) ? new BigDecimal(dto.getSeriousIllnessTreatment()) : Util.null2String(dto.getSeriousIllnessTreatment())); + cellList.add(NumberUtil.isNumber(dto.getInfantCare()) ? new BigDecimal(dto.getInfantCare()) : Util.null2String(dto.getInfantCare())); + return cellList; + }).collect(Collectors.toList())) + .orElse(Collections.emptyList()); + return dataRowList; + } +} diff --git a/src/com/engine/salary/service/impl/SysSalaryItemServiceImpl.java b/src/com/engine/salary/service/impl/SysSalaryItemServiceImpl.java new file mode 100644 index 000000000..e5c894fe9 --- /dev/null +++ b/src/com/engine/salary/service/impl/SysSalaryItemServiceImpl.java @@ -0,0 +1,122 @@ +package com.engine.salary.service.impl; + +import com.engine.core.impl.Service; +import com.engine.salary.biz.SalaryItemBiz; +import com.engine.salary.biz.SysSalaryItemBiz; +import com.engine.salary.config.SalaryElogConfig; +import com.engine.hrmelog.entity.dto.LoggerContext; +import com.engine.salary.entity.salaryitem.bo.SysSalaryItemBO; +import com.engine.salary.entity.salaryitem.po.SalaryItemPO; +import com.engine.salary.entity.salaryitem.po.SysSalaryItemPO; +import com.engine.salary.enums.OperateTypeEnum; +import com.engine.salary.enums.SalarySystemTypeEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.mapper.salaryitem.SysSalaryItemMapper; +import com.engine.salary.service.SysSalaryItemService; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.db.MapperProxyFactory; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; + +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Set; + +/** + * 系统薪资项目 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SysSalaryItemServiceImpl extends Service implements SysSalaryItemService { + private SysSalaryItemBiz sysSalaryItemMapper = new SysSalaryItemBiz(); + private SalaryItemBiz salaryItemService = new SalaryItemBiz(); + + private SysSalaryItemMapper getSysSalaryItemMapper() { + return MapperProxyFactory.getProxy(SysSalaryItemMapper.class); + } +// +// private LoggerTemplate salaryItemLoggerTemplate; + + @Override + public SysSalaryItemPO getById(Long id) { + return sysSalaryItemMapper.getById(id); + } + + @Override + public List listByIds(Collection ids) { + if (CollectionUtils.isEmpty(ids)) { + return Collections.emptyList(); + } + return sysSalaryItemMapper.listSome(SysSalaryItemPO.builder().ids(ids).build()); + } + + @Override + public List listByName(String name) { + if (StringUtils.isBlank(name)) { + return Collections.emptyList(); + } + return sysSalaryItemMapper.listSome(SysSalaryItemPO.builder().name(name).build()); + } + +// @Override +// public Page listPageByParam(SysSalaryItemSearchParam searchParam) { +// // 分页参数 +// Page page = SalaryPageUtil.buildPage(searchParam.getCurrent(), searchParam.getPageSize()); +// // 查询参数构建queryWrapper +// Wrapper queryWrapper = SysSalaryItemBO.buildQueryWrapper(searchParam); +// // 查询系统薪资项目 +// return sysSalaryItemMapper.selectPage(page, queryWrapper); +// } + + @Override + public void add2SalaryItem(Collection ids) { + // 查询系统薪资项目 + List sysSalaryItemPOS = listByIds(ids); + if (CollectionUtils.isEmpty(sysSalaryItemPOS)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98349, "参数错误,系统薪资项目不存在")); + } + // 查询已经添加过的系统薪资项目 + List salaryItemPOS = salaryItemService.listSome(SalaryItemPO.builder().systemType(SalarySystemTypeEnum.SYSTEM.getValue()).build()); + Set sysSalaryItemIds = SalaryEntityUtil.properties(salaryItemPOS, SalaryItemPO::getSysSalaryItemId); + // 已经添加过的系统薪资项目不能重复添加 + boolean exist = sysSalaryItemPOS.stream().anyMatch(sysSalaryItemPO -> sysSalaryItemIds.contains(sysSalaryItemPO.getId())); + if (exist) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98350, "已经添加过的系统薪资项目不能重复添加")); + } + // 保存 + List salaryItems = SysSalaryItemBO.convert2SalaryItemPO(sysSalaryItemPOS, (long) user.getUID()); + salaryItemService.batchSave(salaryItems); + // 记录日志 + sysSalaryItemPOS.forEach(sysSalaryItemPO -> { + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(sysSalaryItemPO.getId())); + loggerContext.setTargetName(sysSalaryItemPO.getName()); + loggerContext.setOperateType(OperateTypeEnum.ADD.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "添加系统薪资项目")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "添加系统薪资项目") + ": " + sysSalaryItemPO.getName()); + loggerContext.setNewValues(sysSalaryItemPO); + SalaryElogConfig.salaryItemLoggerTemplate.write(loggerContext); + }); + } + + @Override + public List listAll() { + return getSysSalaryItemMapper().listAll(); + } + + @Override + public List listSome(SysSalaryItemPO po) { + return getSysSalaryItemMapper().listSome(po); + } + + @Override + public List listLikeName(SysSalaryItemPO po) { + return getSysSalaryItemMapper().listLikeName(po); + } +} diff --git a/src/com/engine/salary/service/impl/TaxAgentAdminServiceImpl.java b/src/com/engine/salary/service/impl/TaxAgentAdminServiceImpl.java new file mode 100644 index 000000000..171bd953a --- /dev/null +++ b/src/com/engine/salary/service/impl/TaxAgentAdminServiceImpl.java @@ -0,0 +1,88 @@ +package com.engine.salary.service.impl; + +import com.engine.core.impl.Service; +import com.engine.salary.constant.SalaryDefaultTenantConstant; +import com.engine.salary.entity.taxagent.po.TaxAgentAdminPO; +import com.engine.salary.mapper.taxagent.TaxAgentAdminMapper; +import com.engine.salary.service.TaxAgentAdminService; +import com.engine.salary.util.db.MapperProxyFactory; +import com.google.common.collect.Lists; +import com.engine.salary.util.db.IdGenerator; +import org.apache.commons.collections4.CollectionUtils; + +import java.util.Collection; +import java.util.Date; +import java.util.List; +import java.util.stream.Collectors; + +/** + * 个税扣缴义务人管理员 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class TaxAgentAdminServiceImpl extends Service implements TaxAgentAdminService { + + private TaxAgentAdminMapper getTaxAgentAdminMapper() { + return MapperProxyFactory.getProxy(TaxAgentAdminMapper.class); + } + + @Override + public void deleteByTaxAgentIds(Collection taxAgentIds) { + if (CollectionUtils.isEmpty(taxAgentIds)) { + return; + } + getTaxAgentAdminMapper().deleteByTaxAgentIds(taxAgentIds); + } + + @Override + public void batchInsert(Long taxAgentId, Collection admins) { + if (taxAgentId == null || CollectionUtils.isEmpty(admins)) { + return; + } + Date now = new Date(); + admins.stream() + .map(e -> TaxAgentAdminPO.builder() + .id(IdGenerator.generate()) + .taxAgentId(taxAgentId) + .employeeId(e) + .createTime(now) + .updateTime(now) + .deleteType(0) + .creator((long) user.getUID()) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .build()) + .forEach(getTaxAgentAdminMapper()::insertIgnoreNull); + } + + @Override + public List listByTaxAgentIds(Collection taxAgentIds) { + List list = Lists.newArrayList(); + if (CollectionUtils.isEmpty(taxAgentIds)) { + return list; + } + return getTaxAgentAdminMapper().listSome(TaxAgentAdminPO.builder().taxAgentIds(taxAgentIds).build()); + + } + + @Override + public List listByTaxAgentIdsAndEmployeeId(Collection taxAgentIds, Long currentEmployeeId) { + List list = Lists.newArrayList(); + if (CollectionUtils.isEmpty(taxAgentIds) || currentEmployeeId == null) { + return list; + } + return getTaxAgentAdminMapper().listSome(TaxAgentAdminPO.builder().taxAgentIds(taxAgentIds).employeeId(currentEmployeeId).build()); + } + + @Override + public List listByEmployeeId(Long currentEmployeeId) { + return getTaxAgentAdminMapper().listSome(TaxAgentAdminPO.builder().employeeId(currentEmployeeId).build()); + } + + @Override + public List getAdminTaxAgentIds(Long currentEmployeeId) { + return listByEmployeeId(currentEmployeeId).stream().map(TaxAgentAdminPO::getTaxAgentId).collect(Collectors.toList()); + } +} diff --git a/src/com/engine/salary/service/impl/TaxAgentBaseServiceImpl.java b/src/com/engine/salary/service/impl/TaxAgentBaseServiceImpl.java new file mode 100644 index 000000000..9294c5b9d --- /dev/null +++ b/src/com/engine/salary/service/impl/TaxAgentBaseServiceImpl.java @@ -0,0 +1,152 @@ +package com.engine.salary.service.impl; + +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.constant.SalaryDefaultTenantConstant; +import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO; +import com.engine.salary.entity.taxagent.param.TaxAgentSaveBaseParam; +import com.engine.salary.entity.taxagent.po.TaxAgentBasePO; +import com.engine.salary.enums.SalaryOnOffEnum; +import com.engine.salary.enums.salaryaccounting.SalaryAcctRecordStatusEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.mapper.taxagent.TaxAgentBaseMapper; +import com.engine.salary.service.SIAccountService; +import com.engine.salary.service.SalaryAcctRecordService; +import com.engine.salary.service.TaxAgentBaseService; +import com.engine.salary.sys.entity.vo.UploadConfigResponse; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.db.MapperProxyFactory; +import com.engine.salary.util.db.IdGenerator; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang.StringUtils; +import weaver.hrm.User; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +/** + * 个税扣缴义务人基本信息 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class TaxAgentBaseServiceImpl extends Service implements TaxAgentBaseService { + + private TaxAgentBaseMapper getTaxAgentBaseMapper() { + return MapperProxyFactory.getProxy(TaxAgentBaseMapper.class); + } + + private SalaryAcctRecordService getSalaryAcctRecordService(User user) { + return ServiceUtil.getService(SalaryAcctRecordServiceImpl.class, user); + } + + private SIAccountService getSIAccountService(User user) { + return ServiceUtil.getService(SIAccountServiceImpl.class, user); + } + + public TaxAgentBaseServiceImpl() { + } + + @Override + public Boolean isOpenDevolution() { + TaxAgentBasePO base = getBaseInfo(); + return (base != null && base.getDevolutionStatus() == 1) ? Boolean.TRUE : Boolean.FALSE; + } + + @Override + public TaxAgentBasePO getBaseInfo() { + List list = getTaxAgentBaseMapper().listAll(); + return CollectionUtils.isEmpty(list) ? null : list.get(0); + } + + @Override + public String save(TaxAgentSaveBaseParam saveBaseParam) { + if (saveBaseParam.getDevolutionStatus() == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(84026, "参数错误")); + } + // 检查使用中的数据 + boolean isUnable = checkUsedData(); + if (isUnable) { + if (saveBaseParam.getDevolutionStatus()) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(117395, "当前有未归档的核算数据,全部归档后才可以启用分权")); + } else { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(117396, "当前有未归档的核算数据,全部归档后才可以停用分权")); + } + } + TaxAgentBasePO base = getBaseInfo(); + Date now = new Date(); + Integer devolutionStatus = saveBaseParam.getDevolutionStatus() ? SalaryOnOffEnum.ON.getValue() : SalaryOnOffEnum.OFF.getValue(); + if (base == null) { + getTaxAgentBaseMapper().insertIgnoreNull( + TaxAgentBasePO.builder() + .id(IdGenerator.generate()) + .devolutionStatus(devolutionStatus) + .createTime(now) + .updateTime(now) + .creator((long) user.getUID()) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .build()); + } else { + base.setUpdateTime(now); + base.setDevolutionStatus(devolutionStatus); + getTaxAgentBaseMapper().updateIgnoreNull(base); + } + return StringUtils.EMPTY; + } + + @Override + public TaxAgentBasePO getConfig() { + Date now = new Date(); + TaxAgentBasePO baseInfo = getBaseInfo(); + if (baseInfo == null) { + baseInfo = TaxAgentBasePO.builder() + .id(IdGenerator.generate()) + .devolutionStatus(0) + .createTime(now) + .updateTime(now) + .creator((long) user.getUID()) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .build(); + } + return baseInfo; + } + + @Override + public UploadConfigResponse.Result parseConfig(TaxAgentBasePO config) { + UploadConfigResponse.Result result = UploadConfigResponse.Result.builder().message("分权配置加载完毕") + .success(new ArrayList<>()) + .warning(new ArrayList<>()) + .error(new ArrayList<>()) + .build(); + TaxAgentBasePO baseInfo = getBaseInfo(); + if (baseInfo == null) { + config.setCreator((long) user.getUID()); + getTaxAgentBaseMapper().insertIgnoreNull(config); + } else { + baseInfo.setDevolutionStatus(config.getDevolutionStatus()); + getTaxAgentBaseMapper().updateIgnoreNull(baseInfo); + } + result.getSuccess().add("分权加载完毕,分权" + (config.getDevolutionStatus() == 1 ? "开启" : "关闭 ")); + return result; + } + + /** + * 检查是否有未归档数据 + * + * @return + */ + private boolean checkUsedData() { + // 检查是否核算 + // todo 1.社保福利档案是否有核算未归档 + Boolean checkedValue = false;//= getSIAccountService(user).changeAdminUnfiledCheck(); + // todo 2.薪资核算是否有核算未归档 + List salaryAcctRecords = getSalaryAcctRecordService(user).listByStatus(SalaryAcctRecordStatusEnum.NOT_ARCHIVED);// getSalaryAcctRecordService(user).listByStatusAndEmployeeId(SalaryAcctRecordStatusEnum.NOT_ARCHIVED, currentTenantKey); + if (CollectionUtils.isNotEmpty(salaryAcctRecords) || checkedValue) { + return Boolean.TRUE; + } + return Boolean.FALSE; + } +} diff --git a/src/com/engine/salary/service/impl/TaxAgentEmpChangeServiceImpl.java b/src/com/engine/salary/service/impl/TaxAgentEmpChangeServiceImpl.java new file mode 100644 index 000000000..e6ca19274 --- /dev/null +++ b/src/com/engine/salary/service/impl/TaxAgentEmpChangeServiceImpl.java @@ -0,0 +1,55 @@ +package com.engine.salary.service.impl; + +import com.engine.core.impl.Service; +import com.engine.salary.entity.taxagent.po.TaxAgentEmpChangePO; +import com.engine.salary.enums.taxagent.TaxAgentEmpChangeModuleEnum; +import com.engine.salary.mapper.taxagent.TaxAgentEmpChangeMapper; +import com.engine.salary.service.TaxAgentEmpChangeService; +import com.engine.salary.util.db.MapperProxyFactory; +import com.google.common.collect.Lists; +import org.apache.commons.collections4.CollectionUtils; + +import java.util.Collection; +import java.util.List; + +/** + * 个税扣缴义务人管理范围的增量人员 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class TaxAgentEmpChangeServiceImpl extends Service implements TaxAgentEmpChangeService { + + private TaxAgentEmpChangeMapper getTaxAgentEmpChangeMapper() { + return MapperProxyFactory.getProxy(TaxAgentEmpChangeMapper.class); + } + + + @Override + public List listAll() { + return getTaxAgentEmpChangeMapper().listAll(); + } + + @Override + public List listAllByModule(TaxAgentEmpChangeModuleEnum moduleTypeEnum) { + return getTaxAgentEmpChangeMapper().listSome(TaxAgentEmpChangePO.builder().moduleType(moduleTypeEnum.getValue()).build()); + } + + @Override + public boolean deleleByIds(Collection ids) { + if (CollectionUtils.isEmpty(ids)) { + return Boolean.FALSE; + } + List> partition = Lists.partition((List) ids, 1000); + partition.forEach(getTaxAgentEmpChangeMapper()::deleteByIds); + return Boolean.TRUE; + } + + @Override + public void batchInsert(List taxAgentEmpChangeList) { + List> partition = Lists.partition(taxAgentEmpChangeList, 100); + partition.forEach(getTaxAgentEmpChangeMapper()::batchInsert); + } +} diff --git a/src/com/engine/salary/service/impl/TaxAgentEmpServiceImpl.java b/src/com/engine/salary/service/impl/TaxAgentEmpServiceImpl.java new file mode 100644 index 000000000..4c7796174 --- /dev/null +++ b/src/com/engine/salary/service/impl/TaxAgentEmpServiceImpl.java @@ -0,0 +1,267 @@ +package com.engine.salary.service.impl; + +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.constant.SalaryDefaultTenantConstant; +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.taxagent.param.TaxAgentEmpSaveParam; +import com.engine.salary.entity.taxagent.po.TaxAgentEmpChangePO; +import com.engine.salary.entity.taxagent.po.TaxAgentEmpPO; +import com.engine.salary.enums.datacollection.DataCollectionEmployeeTypeEnum; +import com.engine.salary.enums.datacollection.UseEmployeeTypeEnum; +import com.engine.salary.enums.taxagent.TaxAgentEmpChangeModuleEnum; +import com.engine.salary.enums.taxagent.TaxAgentEmpChangeTypeEnum; +import com.engine.salary.mapper.taxagent.TaxAgentEmpMapper; +import com.engine.salary.service.TaxAgentEmpChangeService; +import com.engine.salary.service.TaxAgentEmpService; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.db.MapperProxyFactory; +import com.google.common.collect.Lists; +import com.engine.salary.util.db.IdGenerator; +import org.apache.commons.collections4.CollectionUtils; +import weaver.hrm.User; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * 个税扣缴义务人管理范围的人员 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class TaxAgentEmpServiceImpl extends Service implements TaxAgentEmpService { + + + private TaxAgentEmpMapper getTaxAgentEmpMapper() { + return MapperProxyFactory.getProxy(TaxAgentEmpMapper.class); + } + + public TaxAgentEmpChangeService getTaxAgentEmpChangeService(User user) { + return ServiceUtil.getService(TaxAgentEmpChangeServiceImpl.class, user); + } + + @Override + public void deleteByTaxAgentIds(Collection taxAgentIds) { + if (CollectionUtils.isEmpty(taxAgentIds)) { + return; + } + List taxAgentEmpList = getTaxAgentEmpMapper().listSome(TaxAgentEmpPO.builder().taxAgentIds(taxAgentIds).build()); + if (CollectionUtils.isEmpty(taxAgentEmpList)) { + return; + } + List idList = taxAgentEmpList.stream().map(TaxAgentEmpPO::getId).collect(Collectors.toList()); + + List> partition = Lists.partition(idList, 500); + partition.forEach(getTaxAgentEmpMapper()::deleteByIds); + } + + @Override + public List listByTaxAgentIds(List taxAgentIds, UseEmployeeTypeEnum type) { + if (CollectionUtils.isEmpty(taxAgentIds)) { + return Lists.newArrayList(); + } + TaxAgentEmpPO param = TaxAgentEmpPO.builder().taxAgentIds(taxAgentIds).build(); + if (type == UseEmployeeTypeEnum.ORG) { + param.setEmployeeType(DataCollectionEmployeeTypeEnum.ORGANIZATION.getValue()); + } + + if (type == UseEmployeeTypeEnum.EXT) { + param.setEmployeeType(DataCollectionEmployeeTypeEnum.EXT_EMPLOYEE.getValue()); + } + + return getTaxAgentEmpMapper().listSome(param); + } + + @Override + public void syncTaxAgentEmployee(List taxAgentEmpSaveParamList, Long currentEmployeeId) { + if (CollectionUtils.isEmpty(taxAgentEmpSaveParamList)) { + return; + } + List taxAgentIds = taxAgentEmpSaveParamList.stream().map(TaxAgentEmpSaveParam::getTaxAgentId).collect(Collectors.toList()); + List taxAgentEmployeeExistList = this.listByTaxAgentIds(taxAgentIds, UseEmployeeTypeEnum.ORG); + Date now = new Date(); + // 关联表 + List taxAgentEmployeeAddList = Lists.newArrayList(); + List taxAgentEmployeeDelIds = Lists.newArrayList(); + // 增量表 + List taxAgentEmpChangeList = Lists.newArrayList(); + + taxAgentEmpSaveParamList.forEach(saveParam -> { + List existList = taxAgentEmployeeExistList.stream().filter(f -> f.getTaxAgentId().equals(saveParam.getTaxAgentId())).collect(Collectors.toList()); + Map taxAgentEmployeeMap = SalaryEntityUtil.convert2Map(existList, e -> e.getTaxAgentId() + "-" + e.getEmployeeId()); + for (DataCollectionEmployee se : saveParam.getSalaryEmployeeList()) { + String key = saveParam.getTaxAgentId() + "-" + se.getEmployeeId(); + // 本地有的不动 + if (taxAgentEmployeeMap.containsKey(key)) { + taxAgentEmployeeMap.remove(key); + continue; + } + taxAgentEmployeeAddList.add(TaxAgentEmpPO.builder() + .id(IdGenerator.generate()) + .taxAgentId(saveParam.getTaxAgentId()) + .employeeId(se.getEmployeeId()) + .employeeName(se.getUsername()) + .creator(currentEmployeeId) + .createTime(now) + .updateTime(now) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .deleteType(0) + .build()); + + Arrays.stream(TaxAgentEmpChangeModuleEnum.values()).forEach(e -> { + taxAgentEmpChangeList.add(TaxAgentEmpChangePO.builder() + .id(IdGenerator.generate()) + .taxAgentId(saveParam.getTaxAgentId()) + .employeeId(se.getEmployeeId()) + .employeeName(se.getUsername()) + .changeType(TaxAgentEmpChangeTypeEnum.ADD.getValue()) + .moduleType(e.getValue()) + .creator(currentEmployeeId) + .createTime(now) + .updateTime(now) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .deleteType(0) + .build()); + }); + + } + //遍历剩余的就是删除的 + for (String key : taxAgentEmployeeMap.keySet()) { + TaxAgentEmpPO value = taxAgentEmployeeMap.get(key); + taxAgentEmployeeDelIds.add(value.getId()); + + Arrays.stream(TaxAgentEmpChangeModuleEnum.values()).forEach(e -> { + taxAgentEmpChangeList.add(TaxAgentEmpChangePO.builder() + .id(IdGenerator.generate()) + .taxAgentId(saveParam.getTaxAgentId()) + .employeeId(value.getEmployeeId()) + .employeeName(value.getEmployeeName()) + .changeType(TaxAgentEmpChangeTypeEnum.DEL.getValue()) + .moduleType(e.getValue()) + .creator(currentEmployeeId) + .createTime(now) + .updateTime(now) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .deleteType(0) + .build()); + }); + } + }); + + // 关联表==================================================== + // 新增 + if (CollectionUtils.isNotEmpty(taxAgentEmployeeAddList)) { + List> partition = Lists.partition(taxAgentEmployeeAddList, 50); + partition.forEach(getTaxAgentEmpMapper()::batchInsert); + } + // 删除 + if (CollectionUtils.isNotEmpty(taxAgentEmployeeDelIds)) { + List> partition = Lists.partition(taxAgentEmployeeDelIds, 100); + partition.forEach(getTaxAgentEmpMapper()::deleteByIds); + } + // 增量表==================================================== + if (CollectionUtils.isNotEmpty(taxAgentEmpChangeList)) { + getTaxAgentEmpChangeService(user).batchInsert(taxAgentEmpChangeList); + } + } + + @Override + public void syncTaxAgentExtEmployee(List taxAgentEmpSaveParamList, Long currentEmployeeId) { + if (CollectionUtils.isEmpty(taxAgentEmpSaveParamList)) { + return; + } + List taxAgentIds = taxAgentEmpSaveParamList.stream().map(TaxAgentEmpSaveParam::getTaxAgentId).collect(Collectors.toList()); + List taxAgentEmployeeExistList = this.listByTaxAgentIds(taxAgentIds, UseEmployeeTypeEnum.EXT); + Date now = new Date(); + // 关联表 + List taxAgentEmployeeAddList = Lists.newArrayList(); + List taxAgentEmployeeDelIds = Lists.newArrayList(); + // 增量表 + List taxAgentEmpChangeList = Lists.newArrayList(); + + taxAgentEmpSaveParamList.forEach(saveParam -> { + List existList = taxAgentEmployeeExistList.stream().filter(f -> f.getTaxAgentId().equals(saveParam.getTaxAgentId())).collect(Collectors.toList()); + Map taxAgentEmployeeMap = SalaryEntityUtil.convert2Map(existList, e -> e.getTaxAgentId() + "-" + e.getEmployeeId()); + for (DataCollectionEmployee se : saveParam.getSalaryEmployeeList()) { + String key = saveParam.getTaxAgentId() + "-" + se.getEmployeeId(); + // 本地有的不动 + if (taxAgentEmployeeMap.containsKey(key)) { + taxAgentEmployeeMap.remove(key); + continue; + } + taxAgentEmployeeAddList.add(TaxAgentEmpPO.builder() + .id(IdGenerator.generate()) + .taxAgentId(saveParam.getTaxAgentId()) + .employeeId(se.getEmployeeId()) + .employeeName(se.getUsername()) + .employeeType(DataCollectionEmployeeTypeEnum.EXT_EMPLOYEE.getValue()) + .creator(currentEmployeeId) + .createTime(now) + .updateTime(now) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .deleteType(0) + .build()); + + Arrays.stream(TaxAgentEmpChangeModuleEnum.values()).forEach(e -> { + taxAgentEmpChangeList.add(TaxAgentEmpChangePO.builder() + .id(IdGenerator.generate()) + .taxAgentId(saveParam.getTaxAgentId()) + .employeeId(se.getEmployeeId()) + .employeeName(se.getUsername()) + .changeType(TaxAgentEmpChangeTypeEnum.ADD.getValue()) + .moduleType(e.getValue()) + .employeeType(DataCollectionEmployeeTypeEnum.EXT_EMPLOYEE.getValue()) + .creator(currentEmployeeId) + .createTime(now) + .updateTime(now) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .deleteType(0) + .build()); + }); + + } + //遍历剩余的就是删除的 + for (String key : taxAgentEmployeeMap.keySet()) { + TaxAgentEmpPO value = taxAgentEmployeeMap.get(key); + taxAgentEmployeeDelIds.add(value.getId()); + + Arrays.stream(TaxAgentEmpChangeModuleEnum.values()).forEach(e -> { + taxAgentEmpChangeList.add(TaxAgentEmpChangePO.builder() + .id(IdGenerator.generate()) + .taxAgentId(saveParam.getTaxAgentId()) + .employeeId(value.getEmployeeId()) + .employeeName(value.getEmployeeName()) + .changeType(TaxAgentEmpChangeTypeEnum.DEL.getValue()) + .moduleType(e.getValue()) + .employeeType(DataCollectionEmployeeTypeEnum.EXT_EMPLOYEE.getValue()) + .creator(currentEmployeeId) + .createTime(now) + .updateTime(now) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .deleteType(0) + .build()); + }); + } + }); + + // 关联表==================================================== + // 新增 + if (CollectionUtils.isNotEmpty(taxAgentEmployeeAddList)) { + List> partition = Lists.partition(taxAgentEmployeeAddList, 50); + partition.forEach(getTaxAgentEmpMapper()::batchInsert); + } + // 删除 + if (CollectionUtils.isNotEmpty(taxAgentEmployeeDelIds)) { + List> partition = Lists.partition(taxAgentEmployeeDelIds, 100); + partition.forEach(getTaxAgentEmpMapper()::deleteByIds); + } + // 增量表==================================================== + if (CollectionUtils.isNotEmpty(taxAgentEmpChangeList)) { + getTaxAgentEmpChangeService(user).batchInsert(taxAgentEmpChangeList); + } + } + +} diff --git a/src/com/engine/salary/service/impl/TaxAgentExcelServiceImpl.java b/src/com/engine/salary/service/impl/TaxAgentExcelServiceImpl.java new file mode 100644 index 000000000..636c65c4c --- /dev/null +++ b/src/com/engine/salary/service/impl/TaxAgentExcelServiceImpl.java @@ -0,0 +1,95 @@ +package com.engine.salary.service.impl; + +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.entity.taxagent.dto.TaxAgentManageRangeEmployeeListDTO; +import com.engine.salary.entity.taxagent.param.TaxAgentImportParam; +import com.engine.salary.entity.taxagent.param.TaxAgentRangeDownloadTemplateParam; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import com.engine.salary.service.TaxAgentExcelService; +import com.engine.salary.service.TaxAgentService; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.excel.ExcelComment; +import com.engine.salary.util.excel.ExcelParseHelper; +import com.engine.salary.util.excel.ExcelUtil; +import com.google.common.collect.Lists; +import org.apache.commons.lang3.Validate; +import org.apache.poi.util.IOUtils; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import weaver.file.ImageFileManager; +import weaver.general.Util; +import weaver.hrm.User; + +import java.io.InputStream; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @author Harryxzy + * @date 2023/01/05 15:11 + * @description + */ +public class TaxAgentExcelServiceImpl extends Service implements TaxAgentExcelService { + + public TaxAgentService getTaxAgentService(User user) { + return ServiceUtil.getService(TaxAgentServiceImpl.class, user); + } + + @Override + public XSSFWorkbook downloadTemplateRange(TaxAgentRangeDownloadTemplateParam downloadTemplateParam, int currentEmployeeId) { + // 没有传递TaxAgentId就是当前登录人能够导入自己所能管理的个税扣缴义务人 + TaxAgentPO taxAgent = downloadTemplateParam.getTaxAgentId() == null ? null : getTaxAgentService(user).getById(downloadTemplateParam.getTaxAgentId()); + //获取操作按钮资源 + List> rowList = getExcelRowList(taxAgent); + // 注释 + List excelComments = Lists.newArrayList(); + excelComments.add(new ExcelComment(0, 0, 1, 2, SalaryI18nUtil.getI18nLabel(100344, "必填"))); + excelComments.add(new ExcelComment(5, 0, 7, 3, SalaryI18nUtil.getI18nLabel(100344, "若不填,默认全部员工状态。指定员工状态格式:试用、正式、临时、试用延期"))); + //获取excel + return ExcelUtil.genWorkbookV2(rowList, "个税扣缴义务人人员范围", excelComments); + } + + @Override + public Map preview(TaxAgentImportParam importParam) { + Map apidatas = new HashMap(); + + //excel文件id + String imageId = Util.null2String(importParam.getImageId()); + Validate.notBlank(imageId, "imageId为空"); + + InputStream fileInputStream = null; + try { + fileInputStream = ImageFileManager.getInputStreamById(Integer.parseInt(imageId)); + List taxAgentManageRangeEmployees = ExcelParseHelper.parse2Map(fileInputStream, TaxAgentManageRangeEmployeeListDTO.class, 0, 1, 6, "TaxAgentEmployee.xlsx"); + apidatas.put("preview", taxAgentManageRangeEmployees); + } finally { + IOUtils.closeQuietly(fileInputStream); + } + return apidatas; + } + + /** + * @description 获取excel数据行 + * @return List> + * @author Harryxzy + * @date 2023/1/5 15:47 + */ + private List> getExcelRowList(TaxAgentPO taxAgent) { + // 表头 + List headers = Lists.newArrayList(); + if (taxAgent == null) { + headers.add(SalaryI18nUtil.getI18nLabel( 86184, "个税扣缴义务人")); + } + headers.add(SalaryI18nUtil.getI18nLabel( 85429, "姓名")); + headers.add(SalaryI18nUtil.getI18nLabel( 86185, "部门")); + headers.add(SalaryI18nUtil.getI18nLabel(86186, "手机号")); + headers.add(SalaryI18nUtil.getI18nLabel(86317, "工号")); + headers.add(SalaryI18nUtil.getI18nLabel(86317, "证件号码")); + headers.add(SalaryI18nUtil.getI18nLabel(86318, "员工状态")); + List> rowList = new ArrayList<>(); + rowList.add(headers); + return rowList; + } +} diff --git a/src/com/engine/salary/service/impl/TaxAgentManageRangeServiceImpl.java b/src/com/engine/salary/service/impl/TaxAgentManageRangeServiceImpl.java new file mode 100644 index 000000000..8c00eb402 --- /dev/null +++ b/src/com/engine/salary/service/impl/TaxAgentManageRangeServiceImpl.java @@ -0,0 +1,1094 @@ +package com.engine.salary.service.impl; + +import com.api.formmode.mybatis.util.SqlProxyHandle; +import com.cloudstore.dev.api.util.Util_DataCache; +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.config.SalaryElogConfig; +import com.engine.salary.constant.SalaryDefaultTenantConstant; +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.hrm.DeptInfo; +import com.engine.salary.entity.hrm.HrmStatus; +import com.engine.salary.entity.hrm.PositionInfo; +import com.engine.salary.entity.hrm.SubCompanyInfo; +import com.engine.salary.entity.taxagent.bo.TaxAgentBO; +import com.engine.salary.entity.taxagent.dto.TaxAgentManageRangeEmployeeListDTO; +import com.engine.salary.entity.taxagent.dto.TaxAgentManageRangeListDTO; +import com.engine.salary.entity.taxagent.param.*; +import com.engine.salary.entity.taxagent.po.TaxAgentExtRangePO; +import com.engine.salary.entity.taxagent.po.TaxAgentManageRangePO; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import com.engine.salary.enums.UserStatusEnum; +import com.engine.salary.enums.datacollection.UseEmployeeTypeEnum; +import com.engine.salary.enums.salarysob.SalaryEmployeeStatusEnum; +import com.engine.salary.enums.salarysob.TargetTypeEnum; +import com.engine.salary.enums.taxagent.TaxAgentRangeTypeEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.mapper.sys.SalarySysConfMapper; +import com.engine.salary.mapper.taxagent.TaxAgentExtRangeMapper; +import com.engine.salary.mapper.taxagent.TaxAgentManageRangeMapper; +import com.engine.salary.service.*; +import com.engine.salary.sys.entity.po.SalarySysConfPO; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.SalaryLoggerUtil; +import com.engine.salary.util.db.IdGenerator; +import com.engine.salary.util.db.MapperProxyFactory; +import com.engine.salary.util.excel.ExcelParseHelper; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.util.page.SalaryPageUtil; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.weaver.util.threadPool.ThreadPoolUtil; +import com.weaver.util.threadPool.entity.LocalRunnable; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.Validate; +import org.apache.commons.lang3.math.NumberUtils; +import org.apache.poi.util.IOUtils; +import org.springframework.beans.BeanUtils; +import weaver.conn.RecordSet; +import weaver.file.ImageFileManager; +import weaver.general.Util; +import weaver.hrm.User; + +import java.io.InputStream; +import java.util.*; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.stream.Collectors; + +/** + * 个税扣缴义务人的管理范围 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Slf4j +public class TaxAgentManageRangeServiceImpl extends Service implements TaxAgentManageRangeService { + + private static final ExecutorService taskExecutor = Executors.newFixedThreadPool(5); + + + private TaxAgentManageRangeMapper getTaxAgentManageRangeMapper() { + return MapperProxyFactory.getProxy(TaxAgentManageRangeMapper.class); + } + + private TaxAgentExtRangeMapper getTaxAgentExtRangeMapper() { + return MapperProxyFactory.getProxy(TaxAgentExtRangeMapper.class); + } + + private TaxAgentService getTaxAgentService(User user) { + return ServiceUtil.getService(TaxAgentServiceImpl.class, user); + } + + private TaxAgentEmpService getTaxAgentEmpService(User user) { + return ServiceUtil.getService(TaxAgentEmpServiceImpl.class, user); + } + + private SalaryArchiveService getSalaryArchiveService(User user) { + return ServiceUtil.getService(SalaryArchiveServiceImpl.class, user); + } + + private SalaryEmployeeService getSalaryEmployeeService(User user) { + return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user); + } + + private ExtEmpService getExtEmpService(User user) { + return ServiceUtil.getService(ExtEmpServiceImpl.class, user); + } + + + private SalarySysConfMapper getSalarySysConfMapper() { + return SqlProxyHandle.getProxy(SalarySysConfMapper.class); + } + + private SalaryEmployeeService getSalaryEmployeeService() { + return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user); + } + + public SIArchivesService getSIArchivesService(User user) { + return ServiceUtil.getService(SIArchivesServiceImpl.class, user); + } + + private List listByTaxAgentIds(List taxAgentIds) { + if (CollectionUtils.isEmpty(taxAgentIds)) { + return Lists.newArrayList(); + } + return getTaxAgentManageRangeMapper().listSome(TaxAgentManageRangePO.builder().rangeType(TaxAgentRangeTypeEnum.TAXAGENT.getValue()).taxAgentIds(taxAgentIds).build()); + } + + @Override + public List listBySubAdminIds(Collection taxAgentSubAdminIds) { + if (CollectionUtils.isEmpty(taxAgentSubAdminIds)) { + return Lists.newArrayList(); + } + return getTaxAgentManageRangeMapper().listSome(TaxAgentManageRangePO.builder().rangeType(TaxAgentRangeTypeEnum.SUBADMIN.getValue()).taxAgentSubAdminIds(taxAgentSubAdminIds).build()); + } + + /** + * 获取范围下的人员 + * + * @param taxAgentId + * @param allTaxAgentManageRanges + * @param salaryEmployees + * @return + */ + private List getManageRangeSalaryEmployees(Long taxAgentId, List allTaxAgentManageRanges, List salaryEmployees) { + List includeAllTaxAgentManageRanges = allTaxAgentManageRanges.stream().filter(f -> f.getIncludeType().equals(NumberUtils.INTEGER_ONE)).collect(Collectors.toList()); + if (CollectionUtils.isEmpty(includeAllTaxAgentManageRanges)) { + return Collections.emptyList(); + } + List excludeAllTaxAgentManageRanges = allTaxAgentManageRanges.stream().filter(f -> f.getIncludeType().equals(NumberUtils.INTEGER_ZERO)).collect(Collectors.toList()); + + List includeSalaryEmployees = Lists.newArrayList(); + List includeTaxAgentManageRanges = includeAllTaxAgentManageRanges.stream().filter(f -> f.getTaxAgentId().equals(taxAgentId)).collect(Collectors.toList()); + if (CollectionUtils.isEmpty(includeTaxAgentManageRanges)) { + return includeSalaryEmployees; + } + // 根据上一步的查询参数查询人员 + includeSalaryEmployees = listSalaryEmployeeByManageRange(includeTaxAgentManageRanges, salaryEmployees); + if (CollectionUtils.isEmpty(includeSalaryEmployees)) { + return includeSalaryEmployees; + } + // 查询管理范围(从范围中排除) + List excludeTaxAgentManageRanges = excludeAllTaxAgentManageRanges.stream().filter(f -> f.getTaxAgentId().equals(taxAgentId)).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(excludeTaxAgentManageRanges)) { + // 根据上一步的查询参数查询人员 + List excludeSalaryEmployees = listSalaryEmployeeByManageRange(excludeTaxAgentManageRanges, salaryEmployees); + // 需要排除的人员范围 + Set excludeEmployeeIds = SalaryEntityUtil.properties(excludeSalaryEmployees, DataCollectionEmployee::getEmployeeId); + // 过滤人员 + includeSalaryEmployees = includeSalaryEmployees.stream().filter(salaryEmployee -> !excludeEmployeeIds.contains(salaryEmployee.getEmployeeId())).collect(Collectors.toList()); + } + return includeSalaryEmployees; + } + + /** + * 根据范围加载人员 + * + * @param taxAgentManageRanges + * @return + */ + private List listSalaryEmployeeByManageRange(List taxAgentManageRanges, List salaryEmployees) { + if (CollectionUtils.isEmpty(taxAgentManageRanges) || CollectionUtils.isEmpty(salaryEmployees)) { + return Collections.emptyList(); + } + // 获取虚拟部门下人员信息 + List virtualDepartmentIds = taxAgentManageRanges.stream().filter(manageRange -> manageRange.getTargetType().equals(TargetTypeEnum.DEPT.getValue()) && manageRange.getTargetId().compareTo(0L) < 0).map(TaxAgentManageRangePO::getTargetId).collect(Collectors.toList()); + List virtualEmpListByDep = getSalaryEmployeeService(user).getVirtualEmpByVirtualDepIds(virtualDepartmentIds); + Map> virtualDepMap = SalaryEntityUtil.group2Map(virtualEmpListByDep, DataCollectionEmployee::getDepartmentId, DataCollectionEmployee::getEmployeeId); + + // 获取虚拟分部下人员信息 + List virtualSubCompanyIds = taxAgentManageRanges.stream().filter(manageRange -> manageRange.getTargetType().equals(TargetTypeEnum.SUBCOMPANY.getValue()) && manageRange.getTargetId().compareTo(0L) < 0).map(TaxAgentManageRangePO::getTargetId).collect(Collectors.toList()); + List virtualEmpListBySubCom = getSalaryEmployeeService(user).getVirtualEmpByVirtualSubCompanyIds(virtualSubCompanyIds); + Map> virtualSubCompanyMap = SalaryEntityUtil.group2Map(virtualEmpListBySubCom, DataCollectionEmployee::getSubcompanyid, DataCollectionEmployee::getEmployeeId); + + List salaryEmployeeList = Lists.newArrayList(); + for (TaxAgentManageRangePO manageRange : taxAgentManageRanges) { + if (!TargetTypeEnum.SQL.getValue().equals(manageRange.getTargetType())) { + boolean isVirtual = manageRange.getTargetId().compareTo(0L) < 0 ? true : false; + List employees = salaryEmployees.stream().filter(salaryEmployee -> { + if (StringUtils.isEmpty(manageRange.getEmployeeStatus()) || !manageRange.getEmployeeStatus().contains("\"" + salaryEmployee.getStatus() + "\"")) { + return false; + } + if (Objects.equals(manageRange.getTargetType(), TargetTypeEnum.ALL.getValue())) { + return true; + } + if (Objects.equals(manageRange.getTargetType(), TargetTypeEnum.EMPLOYEE.getValue()) && Objects.equals(manageRange.getTargetId(), salaryEmployee.getEmployeeId())) { + return true; + } + if (isVirtual) { + if (Objects.equals(manageRange.getTargetType(), TargetTypeEnum.DEPT.getValue())) { + Set empIds = virtualDepMap.get(manageRange.getTargetId()); + if (CollectionUtils.isNotEmpty(empIds) && empIds.contains(salaryEmployee.getEmployeeId())) { + return true; + } + } + if (Objects.equals(manageRange.getTargetType(), TargetTypeEnum.SUBCOMPANY.getValue())) { + Set empIds = virtualSubCompanyMap.get(manageRange.getTargetId()); + if (CollectionUtils.isNotEmpty(empIds) && empIds.contains(salaryEmployee.getEmployeeId())) { + return true; + } + } + } else { + if (Objects.equals(manageRange.getTargetType(), TargetTypeEnum.DEPT.getValue()) && Objects.equals(manageRange.getTargetId(), salaryEmployee.getDepartmentId())) { + return true; + } + if (Objects.equals(manageRange.getTargetType(), TargetTypeEnum.SUBCOMPANY.getValue()) && Objects.equals(manageRange.getTargetId(), salaryEmployee.getSubcompanyid())) { + return true; + } + } + if (Objects.equals(manageRange.getTargetType(), TargetTypeEnum.POSITION.getValue()) && Objects.equals(manageRange.getTargetId(), salaryEmployee.getJobtitleId())) { + return true; + } + return false; + }).collect(Collectors.toList()); + salaryEmployeeList.addAll(employees); + } + } + + for (TaxAgentManageRangePO manageRange : taxAgentManageRanges) { + if (TargetTypeEnum.SQL.getValue().equals(manageRange.getTargetType())) { + String sql = manageRange.getTarget(); + List empIds = new ArrayList<>(); + RecordSet rs = new RecordSet(); + if (rs.execute(sql)) { + while (rs.next()) { + empIds.add((long) rs.getInt("id")); + } + } + List employees = getSalaryEmployeeService(user).getEmployeeByIds(empIds); + if (StringUtils.isNotBlank(manageRange.getEmployeeStatus())) { + employees = employees.stream().filter(salaryEmployee -> manageRange.getEmployeeStatus().contains("\"" + salaryEmployee.getStatus() + "\"")).collect(Collectors.toList()); + } + salaryEmployeeList.addAll(employees); + } + } + + // 去重 + salaryEmployeeList = salaryEmployeeList.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(DataCollectionEmployee::getEmployeeId))), ArrayList::new)); + return salaryEmployeeList; + } + + /** + * 根据分管理员id获取管理范围列表 + * + * @param subAdminId + * @param includeType + * @return + */ + private List listBySubAdminIdAndIncludeType(Long subAdminId, Integer includeType) { + return getTaxAgentManageRangeMapper().listSome(TaxAgentManageRangePO.builder().taxAgentSubAdminId(subAdminId).rangeType(TaxAgentRangeTypeEnum.SUBADMIN.getValue()).includeType(includeType).build()); + } + + /** + * 获取个税口角义务人的管理范围 + * + * @param taxAgentId + * @param includeType + * @return + */ + @Override + public List listByTaxAgentIdAndIncludeType(Long taxAgentId, Integer includeType) { + return getTaxAgentManageRangeMapper().listSome(TaxAgentManageRangePO.builder().taxAgentId(taxAgentId).rangeType(TaxAgentRangeTypeEnum.TAXAGENT.getValue()).includeType(includeType).build()); + } + + @Override + public PageInfo listPageByParamAndIncludeType(TaxAgentSubAdminRangeQueryParam queryParam, Integer includeType) { + // 查询已有的管理范围 + List taxAgentManageRanges = listBySubAdminIdAndIncludeType(queryParam.getSubAdminId(), includeType); + return listPageByParamAndIncludeType(taxAgentManageRanges, queryParam, includeType); + } + + @Override + public PageInfo listPageByParamAndIncludeType(TaxAgentRangeQueryParam queryParam, Integer includeType) { + // 查询已有的管理范围 + List taxAgentManageRanges = listByTaxAgentIdAndIncludeType(queryParam.getTaxAgentId(), includeType); + return listPageByParamAndIncludeType(taxAgentManageRanges, queryParam, includeType); + } + + private PageInfo listPageByParamAndIncludeType(List taxAgentManageRanges, TaxAgentManageRangeQueryParam queryParam, Integer includeType) { + + // 查询人员信息 + List employeeIds = taxAgentManageRanges.stream().filter(e -> Objects.equals(e.getTargetType(), TargetTypeEnum.EMPLOYEE.getValue())).map(TaxAgentManageRangePO::getTargetId).collect(Collectors.toList()); +// List employeeComInfos = comInfoCache.getCacheList(HrmEmployeeComInfo.class, employeeIds); + List employeeComInfos = getSalaryEmployeeService().getEmployeeByIdsAll(employeeIds); + // 查询部门信息 + List departmentIds = taxAgentManageRanges.stream().filter(e -> Objects.equals(e.getTargetType(), TargetTypeEnum.DEPT.getValue())).map(TaxAgentManageRangePO::getTargetId).collect(Collectors.toList()); + List departmentComInfos = getSalaryEmployeeService().getDeptInfoList(departmentIds); + // 虚拟部门 + List virtualDepIds = departmentIds.stream().filter(id -> id.compareTo(0L) < 0).collect(Collectors.toList()); + departmentComInfos.addAll(getSalaryEmployeeService().getVirtualDeptInfoList(virtualDepIds)); + + // 查询分部信息 + List subDepartmentIds = taxAgentManageRanges.stream().filter(e -> Objects.equals(e.getTargetType(), TargetTypeEnum.SUBCOMPANY.getValue())).map(TaxAgentManageRangePO::getTargetId).collect(Collectors.toList()); + List subDepartmentComInfos = getSalaryEmployeeService().getSubCompanyInfoList(subDepartmentIds); + // 虚拟分部 + List virtualSubCompanyIds = subDepartmentIds.stream().filter(id -> id.compareTo(0L) < 0).collect(Collectors.toList()); + subDepartmentComInfos.addAll(getSalaryEmployeeService().getVirtualSubCompanyInfoList(virtualSubCompanyIds)); + + // 查询岗位信息 + List positionIds = taxAgentManageRanges.stream().filter(e -> Objects.equals(e.getTargetType(), TargetTypeEnum.POSITION.getValue())).map(TaxAgentManageRangePO::getTargetId).collect(Collectors.toList()); + List positionComInfos = getSalaryEmployeeService().listPositionInfo(positionIds); + // 分页参数 + PageInfo dtoPage = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), TaxAgentManageRangeListDTO.class); + // 查询人员状态 +// List hrmStatusList = hrmCommonHrmStatusService.list(); + List hrmStatusList = UserStatusEnum.getHrmStatusList(); + // 薪资账套的人员范围po转换成列表dto + List taxAgentManageRangeList = TaxAgentBO.convert2ListDTO(taxAgentManageRanges, employeeComInfos, departmentComInfos, subDepartmentComInfos, positionComInfos, hrmStatusList); + // 根据对象名称过滤 + if (StringUtils.isNotEmpty(queryParam.getTargetName())) { + taxAgentManageRangeList = taxAgentManageRangeList.stream().filter(f -> f.getTargetName().contains(queryParam.getTargetName())).collect(Collectors.toList()); + } + // 填充总数和当页数据 + dtoPage.setTotal(taxAgentManageRangeList.size()); + dtoPage.setList(SalaryPageUtil.subList(dtoPage.getPageNum(), dtoPage.getPageSize(), taxAgentManageRangeList)); + return dtoPage; + } + + /** + * 根据个税口角义务人id保存管理范围 + * + * @param saveParam 保存参数 + */ + @Override + public void save(TaxAgentRangeSaveParam saveParam) { + + checkParam(saveParam); + + // 查询个税扣缴义务人 + TaxAgentPO taxAgent = getTaxAgentService(user).getById(saveParam.getTaxAgentId()); + if (Objects.isNull(taxAgent)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(108605, "参数错误,个税扣缴义务人不存在或不在权限范围内")); + } + // 查询已有的管理范围 + List taxAgentManageAllRanges = listByTaxAgentId(saveParam.getTaxAgentId()); + + List taxAgentManageRanges = taxAgentManageAllRanges.stream().filter(f -> f.getIncludeType().equals(saveParam.getIncludeType())).collect(Collectors.toList()); + List oldManageList = new ArrayList<>(); + taxAgentManageRanges.stream().forEach(p -> { + TaxAgentManageRangePO target = new TaxAgentManageRangePO(); + BeanUtils.copyProperties(p, target); + oldManageList.add(target); + }); + // 处理一下本次的保存参数(如果原来添加过对应的人员(/部门/岗位),那么本次不需要新增,只需要更新) + TaxAgentBO.Result result = TaxAgentBO.handleTaxAgentRange(taxAgentManageRanges, saveParam, taxAgent.getId(), (long) user.getUID(), false); + + /* 检查当前个税扣缴义务人的所有人员范围与所有分管理员的管理范围===========================start */ + List allRanges = Lists.newArrayList(taxAgentManageAllRanges); + allRanges.addAll(result.getNeedInsertTaxAgentManageRanges()); + allRanges.addAll(result.getNeedUpdateTaxAgentManageRanges()); + // 去重 + allRanges = allRanges.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(f -> f.getTaxAgentId() + "." + f.getRangeType() + "." + f.getTargetType() + "." + f.getTargetId() + "." + f.getEmployeeStatus() + "." + f.getIncludeType()))), ArrayList::new)); + + List salaryEmployees = getSalaryEmployeeService().listAll(UseEmployeeTypeEnum.ALL); + List allSalaryEmployees = this.getManageRangeSalaryEmployees(saveParam.getTaxAgentId(), allRanges, salaryEmployees); + + /* 检查当前个税扣缴义务人的所有人员范围与所有分管理员的管理范围===========================end */ + if (CollectionUtils.isNotEmpty(result.getNeedInsertTaxAgentManageRanges())) { + result.getNeedInsertTaxAgentManageRanges().forEach(range -> { + getTaxAgentManageRangeMapper().insertIgnoreNull(range); + // 记录操作日志 + String name = taxAgent.getName() + "_" + TargetTypeEnum.parseByValue(range.getTargetType()).getDefaultLabel() + "_" + range.getTargetId(); + SalaryLoggerUtil.recordAddSingleLog(SalaryElogConfig.taxAgentLoggerTemplate, range.getTaxAgentId(), name, SalaryI18nUtil.getI18nLabel(0, "新增人员范围"), SalaryI18nUtil.getI18nLabel(0, "新增人员范围") + name, range, user); + }); + + } + if (CollectionUtils.isNotEmpty(result.getNeedUpdateTaxAgentManageRanges())) { + Map oldMap = SalaryEntityUtil.convert2Map(oldManageList, TaxAgentManageRangePO::getId); + result.getNeedUpdateTaxAgentManageRanges().forEach(range -> { + getTaxAgentManageRangeMapper().updateIgnoreNull(range); + // 记录操作日志 + TaxAgentManageRangePO oldPO = oldMap.getOrDefault(range.getId(), TaxAgentManageRangePO.builder().build()); + String name = taxAgent.getName() + "_" + TargetTypeEnum.parseByValue(range.getTargetType()).getDefaultLabel() + "_" + range.getTargetId(); + SalaryLoggerUtil.recordUpdateSingleLog(SalaryElogConfig.taxAgentLoggerTemplate, range.getTaxAgentId(), name, SalaryI18nUtil.getI18nLabel(0, "更新人员范围"), SalaryI18nUtil.getI18nLabel(0, "更新人员范围") + name, oldPO, range, user); + }); + + } + + /* 同步本地人员范围的关联人员=========================== */ + syncLocalEmp(saveParam.getTaxAgentId(), allSalaryEmployees, saveParam.isSync()); + + } + + private void checkParam(TaxAgentRangeSaveParam saveParam) { + if (saveParam == null) { + throw new SalaryRunTimeException("参数错误"); + } + + if (Objects.isNull(saveParam.getTaxAgentId())) { + throw new SalaryRunTimeException("个税扣缴义务人的id不允许为空"); + } + + if (saveParam.getIncludeType() != 0 && saveParam.getIncludeType() != 1) { + throw new SalaryRunTimeException("只能选择 关联人员范围/从范围中排除"); + } + + if (CollectionUtils.isEmpty(saveParam.getEmployeeStatus())) { + throw new SalaryRunTimeException("员工状态不允许为空"); + } + + if (CollectionUtils.isNotEmpty(saveParam.getTargetParams())) { + saveParam.getTargetParams().forEach(target -> { + if (target.getTargetType() == null) { + throw new SalaryRunTimeException("对象类型不能为空"); + } + if (target.getTargetType() == TargetTypeEnum.SQL) { + if (target.getTarget() == null) { + throw new SalaryRunTimeException("sql不能为空"); + } + target.setTargetId(0L); + } else { + if (target.getTargetId() == null) { + throw new SalaryRunTimeException("对象不能为空"); + } + } + }); + } + } + + @Override + public void edit(TaxAgentRangeSaveParam param) { + checkParam(param); + + if (param.getId() == null) { + throw new SalaryRunTimeException("id不能为空"); + } + + // 查询个税扣缴义务人 + TaxAgentPO taxAgent = getTaxAgentService(user).getById(param.getTaxAgentId()); + if (Objects.isNull(taxAgent)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(108605, "参数错误,个税扣缴义务人不存在或不在权限范围内")); + } + + //删除原有的管理范围 + getTaxAgentManageRangeMapper().deleteByIds(Collections.singleton(param.getId())); + + // 查询已有的管理范围 + List taxAgentManageAllRanges = listByTaxAgentId(param.getTaxAgentId()); + + List taxAgentManageRanges = taxAgentManageAllRanges.stream().filter(f -> f.getIncludeType().equals(param.getIncludeType())).collect(Collectors.toList()); + List oldManageList = new ArrayList<>(); + taxAgentManageRanges.stream().forEach(p -> { + TaxAgentManageRangePO target = new TaxAgentManageRangePO(); + BeanUtils.copyProperties(p, target); + oldManageList.add(target); + }); + // 处理一下本次的保存参数(如果原来添加过对应的人员(/部门/岗位),那么本次不需要新增,只需要更新) + TaxAgentBO.Result result = TaxAgentBO.handleTaxAgentRange(taxAgentManageRanges, param, taxAgent.getId(), (long) user.getUID(), false); + + /* 检查当前个税扣缴义务人的所有人员范围与所有分管理员的管理范围===========================start */ + List allRanges = Lists.newArrayList(taxAgentManageAllRanges); + allRanges.addAll(result.getNeedInsertTaxAgentManageRanges()); + allRanges.addAll(result.getNeedUpdateTaxAgentManageRanges()); + // 去重 + allRanges = allRanges.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(f -> f.getTaxAgentId() + "." + f.getRangeType() + "." + f.getTargetType() + "." + f.getTargetId() + "." + f.getEmployeeStatus() + "." + f.getIncludeType()))), ArrayList::new)); + + List salaryEmployees = getSalaryEmployeeService().listAll(UseEmployeeTypeEnum.ALL); + List allSalaryEmployees = this.getManageRangeSalaryEmployees(param.getTaxAgentId(), allRanges, salaryEmployees); + + /* 检查当前个税扣缴义务人的所有人员范围与所有分管理员的管理范围===========================end */ + if (CollectionUtils.isNotEmpty(result.getNeedInsertTaxAgentManageRanges())) { + result.getNeedInsertTaxAgentManageRanges().forEach(range -> { + getTaxAgentManageRangeMapper().insertIgnoreNull(range); + // 记录操作日志 + String name = taxAgent.getName() + "_" + TargetTypeEnum.parseByValue(range.getTargetType()).getDefaultLabel() + "_" + range.getTargetId(); + SalaryLoggerUtil.recordAddSingleLog(SalaryElogConfig.taxAgentLoggerTemplate, range.getTaxAgentId(), name, SalaryI18nUtil.getI18nLabel(0, "新增人员范围"), SalaryI18nUtil.getI18nLabel(0, "新增人员范围") + name, range, user); + }); + + } + if (CollectionUtils.isNotEmpty(result.getNeedUpdateTaxAgentManageRanges())) { + Map oldMap = SalaryEntityUtil.convert2Map(oldManageList, TaxAgentManageRangePO::getId); + result.getNeedUpdateTaxAgentManageRanges().forEach(range -> { + getTaxAgentManageRangeMapper().updateIgnoreNull(range); + // 记录操作日志 + TaxAgentManageRangePO oldPO = oldMap.getOrDefault(range.getId(), TaxAgentManageRangePO.builder().build()); + String name = taxAgent.getName() + "_" + TargetTypeEnum.parseByValue(range.getTargetType()).getDefaultLabel() + "_" + range.getTargetId(); + SalaryLoggerUtil.recordUpdateSingleLog(SalaryElogConfig.taxAgentLoggerTemplate, range.getTaxAgentId(), name, SalaryI18nUtil.getI18nLabel(0, "更新人员范围"), SalaryI18nUtil.getI18nLabel(0, "更新人员范围") + name, oldPO, range, user); + }); + + } + + /* 同步本地人员范围的关联人员=========================== */ + syncLocalEmp(param.getTaxAgentId(), allSalaryEmployees, param.isSync()); + } + + private void syncLocalEmp(Long taxAgentId, List allSalaryEmployees, boolean isSync) { + if (isSync) { + syncLocalEmpRange(taxAgentId, allSalaryEmployees, (long) user.getUID()); + //生成档案 + generateArchive(); + } else { + taskExecutor.execute(() -> { + syncLocalEmpRange(taxAgentId, allSalaryEmployees, (long) user.getUID()); + //生成档案 + generateArchive(); + }); + } + + } + + /** + * 生成档案 + */ + private void generateArchive() { + //生成薪资档案 + String salaryArchiveChangeSign = (String) Util_DataCache.getObjVal("salaryArchiveChangeSign"); + if (salaryArchiveChangeSign == null || "0".equals(salaryArchiveChangeSign)) { + try { + //开始同步中.... + Util_DataCache.setObjVal("salaryArchiveChangeSign", "1"); + getSalaryArchiveService(user).handleChangeData(1L); + } finally { + //同步结束.... + Util_DataCache.setObjVal("salaryArchiveChangeSign", "0"); + } + + } + //生成社保福利档案 + String welSign = (String) Util_DataCache.getObjVal("welfareChangeSign"); + if (welSign == null || "0".equals(welSign)) { + getSIArchivesService(user).handleChangeData(1L); + } + } + + + /** + * 根据个税口角义务人id保存管理范围 + * + * @param saveParam 保存参数 + */ + @Override + public void saveExtRange(TaxAgentManageRangeExtSaveParam saveParam) { + + if (saveParam == null) { + throw new SalaryRunTimeException("参数错误"); + } + Long taxAgentId = saveParam.getTaxAgentId(); + if (Objects.isNull(taxAgentId)) { + throw new SalaryRunTimeException("个税扣缴义务人的id不允许为空"); + } + + + // 查询个税扣缴义务人 + TaxAgentPO taxAgent = getTaxAgentService(user).getById(taxAgentId); + if (Objects.isNull(taxAgent)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(108605, "参数错误,个税扣缴义务人不存在或不在权限范围内")); + } + + List targetIds = saveParam.getTargetIds(); + List employees = getExtEmpService(user).getEmployeeByIds(targetIds); + if (Objects.isNull(employees)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(108605, "参数错误,无此外部人员")); + } + + Date now = new Date(); + List oldPO = listAllExtBytaxAgentId(taxAgentId); + List oldIds = SalaryEntityUtil.properties(oldPO, TaxAgentExtRangePO::getTargetId, Collectors.toList()); + targetIds.stream().filter(targetId -> !oldIds.contains(targetId)).forEach(targetId -> { + TaxAgentExtRangePO po = TaxAgentExtRangePO.builder().id(IdGenerator.generate()).taxAgentId(taxAgentId).targetId(targetId).creator((long) user.getUID()).createTime(now).updateTime(now).deleteType(0).targetType(1).tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY).build(); + + getTaxAgentExtRangeMapper().insertIgnoreNull(po); + // 记录日志 + String name = taxAgent.getName() + "_" + saveParam.getTaxAgentId(); + SalaryLoggerUtil.recordAddSingleLog(SalaryElogConfig.taxAgentLoggerTemplate, taxAgent.getId(), name, SalaryI18nUtil.getI18nLabel(0, "新增非系统人员范围"), SalaryI18nUtil.getI18nLabel(0, "新增非系统人员范围") + name, po, user); + }); + List oldEmpList = getExtEmpService(user).getEmployeeByIds(oldIds); + employees.addAll(oldEmpList); + // 去重 + employees = employees.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(e -> e.getEmployeeId()))), ArrayList::new)); + + + /* 同步本地人员范围的关联人员=========================== */ + if (saveParam.isSync()) { + //同步执行 + syncLocalExtEmp(taxAgentId, employees); + } else { + List finalEmployees = employees; + taskExecutor.execute(() -> { + syncLocalExtEmp(taxAgentId, finalEmployees); + }); + } + + } + + private List listAllExtBytaxAgentId(Long taxAgentId) { + if (taxAgentId == null) { + return new ArrayList<>(); + } + return getTaxAgentExtRangeMapper().listSome(TaxAgentExtRangePO.builder().taxAgentId(taxAgentId).build()); + } + + private List listExtByIds(Collection targetIds) { + if (CollectionUtils.isEmpty(targetIds)) { + return new ArrayList<>(); + } + return getTaxAgentExtRangeMapper().listSome(TaxAgentExtRangePO.builder().ids(targetIds).build()); + } + + @Override + public void deleteExtRange(Collection ids) { + // 查询管理范围 + List taxAgentManageRanges = listExtByIds(ids); + if (CollectionUtils.isEmpty(taxAgentManageRanges)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98604, "数据不存在或已被删除")); + } + List taxAgentIds = taxAgentManageRanges.stream().map(TaxAgentExtRangePO::getTaxAgentId).distinct().collect(Collectors.toList()); + if (taxAgentIds.size() > 1) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(110159, "一次只能删一个个税个税扣缴义务人的范围")); + } + // 删除管理范围 + getTaxAgentExtRangeMapper().deleteByIds(ids); + // 记录日志 + SalaryLoggerUtil.recordDeleteSingleLog(SalaryElogConfig.taxAgentLoggerTemplate, taxAgentManageRanges.get(0).getTaxAgentId(), ids.toString(), SalaryI18nUtil.getI18nLabel(0, "删除非系统人员范围"), SalaryI18nUtil.getI18nLabel(0, "删除非系统人员范围") + ids.toString(), null, user); + } + + private void syncLocalExtEmp(Long taxAgentId, List allSalaryEmployees) { + + List taxAgentEmpSaveParamList = Collections.singletonList(getTaxAgentEmpSyncParam(taxAgentId, allSalaryEmployees)); + // 同步个税扣缴义务人的人员 + getTaxAgentEmpService(user).syncTaxAgentExtEmployee(taxAgentEmpSaveParamList, (long) user.getUID()); + +// //生成档案 + getSalaryArchiveService(user).handleChangeData(1L); +// //生成社保福利档案 + String welSign = (String) Util_DataCache.getObjVal("welfareChangeSign"); + if (welSign == null || "0".equals(welSign)) { + getSIArchivesService(user).handleChangeData(1L); + } + } + + + /** + * 获取个税口角义务人的管理范围 + * + * @param taxAgentId + * @return + */ + private List listByTaxAgentId(Long taxAgentId) { + return getTaxAgentManageRangeMapper().listSome(TaxAgentManageRangePO.builder().taxAgentId(taxAgentId).rangeType(TaxAgentRangeTypeEnum.TAXAGENT.getValue()).build()); + } + + private List listSunAdminRangeByTaxAgentId(Long taxAgentId) { + return getTaxAgentManageRangeMapper().listSome(TaxAgentManageRangePO.builder().taxAgentId(taxAgentId).rangeType(TaxAgentRangeTypeEnum.SUBADMIN.getValue()).build()); + } + + + /** + * 根据分管理员id获取管理范围列表 + * + * @param subAdminId + * @return + */ + private List listBySubAdminId(Long subAdminId) { + return getTaxAgentManageRangeMapper().listSome(TaxAgentManageRangePO.builder().taxAgentSubAdminId(subAdminId).rangeType(TaxAgentRangeTypeEnum.SUBADMIN.getValue()).build()); + } + + private List listByIds(Collection ids) { + if (CollectionUtils.isEmpty(ids)) { + return Collections.emptyList(); + } + return getTaxAgentManageRangeMapper().listSome(TaxAgentManageRangePO.builder().ids(ids).build()); + } + + @Override + public void deleteByIds(Collection ids) { + // 查询管理范围 + List taxAgentManageRangeList = listByIds(ids); + + if (CollectionUtils.isEmpty(taxAgentManageRangeList)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98604, "数据不存在或已被删除")); + } + List taxAgentIds = taxAgentManageRangeList.stream().map(TaxAgentManageRangePO::getTaxAgentId).distinct().collect(Collectors.toList()); + if (taxAgentIds.size() > 1) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(110159, "一次只能删一个个税个税扣缴义务人的范围")); + } + List taxAgentManageRanges = this.listByTaxAgentIds(taxAgentIds); + List allManageRanges = taxAgentManageRanges.stream().filter(f -> !ids.contains(f.getId())).collect(Collectors.toList()); + List allRanges = allManageRanges.stream().filter(f -> f.getRangeType().equals(TaxAgentRangeTypeEnum.TAXAGENT.getValue())).collect(Collectors.toList()); +// List allSubAdminRanges = allManageRanges.stream().filter(f -> f.getRangeType().equals(TaxAgentRangeTypeEnum.SUBADMIN.getValue())).collect(Collectors.toList()); + Long taxAgentId = taxAgentIds.get(0); + TaxAgentPO taxAgentPO = getTaxAgentService(user).getById(taxAgentId); + + List salaryEmployees = getSalaryEmployeeService(user).listAll(UseEmployeeTypeEnum.ORG); + List allSalaryEmployees = this.getManageRangeSalaryEmployees(taxAgentId, allRanges, salaryEmployees); + +// List allSubAdminSalaryEmployees = this.getManageRangeSalaryEmployees(taxAgentId, allSubAdminRanges, salaryEmployees); +// allSalaryEmployees.forEach(f -> { +// allSubAdminSalaryEmployees.removeIf(a -> a.getEmployeeId().equals(f.getEmployeeId())); +// }); +// if (CollectionUtils.isNotEmpty(allSubAdminSalaryEmployees)) { +// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(110160, "分管理员存在超出整体人员范围以外的人员,不可删除")); +// } + // 删除管理范围 + getTaxAgentManageRangeMapper().deleteByIds(ids); + + // 记录操作日志 + taxAgentManageRangeList.stream().forEach(range -> { + String name = taxAgentPO.getName() + "_" + TargetTypeEnum.parseByValue(range.getTargetType()).getDefaultLabel() + "_" + range.getTargetId(); + SalaryLoggerUtil.recordDeleteSingleLog(SalaryElogConfig.taxAgentLoggerTemplate, range.getTaxAgentId(), name, SalaryI18nUtil.getI18nLabel(0, "删除人员范围"), SalaryI18nUtil.getI18nLabel(0, "删除人员范围") + name, range, user); + }); + + + /** 同步本地人员范围的关联人员=========================== */ + syncLocalEmp(taxAgentId, allSalaryEmployees, false); + } + + @Override + public PageInfo listExt(TaxAgentRangeExtQueryParam param) { + if (param.getTaxAgentId() == null) { + throw new SalaryRunTimeException("扣缴义务人id为空"); + } + + List taxAgentExtRangePOS = getTaxAgentExtRangeMapper().list(TaxAgentExtRangePO.builder().taxAgentId(param.getTaxAgentId()).build()); + if (StringUtils.isNotBlank(param.getTargetName())) { + taxAgentExtRangePOS = taxAgentExtRangePOS.stream().filter(po -> po.getTargetName().contains(param.getTargetName())).collect(Collectors.toList()); + } + return SalaryPageUtil.buildPage(param.getCurrent(), param.getPageSize(), taxAgentExtRangePOS, TaxAgentExtRangePO.class); + } + + @Override + public void deleteByTaxAgentIds(Collection taxAgentIds) { + getTaxAgentManageRangeMapper().deleteByTaxAgentIds(taxAgentIds); + // 删除管理范围下的所有人员 + getTaxAgentEmpService(user).deleteByTaxAgentIds(taxAgentIds); + } + + + /** + * 同步处理所有人员范围 + * + * @param taxAgentIds 为空代表所有个税扣缴义务人 + */ + private void handleSyncTaxAgentEmpData(List taxAgentIds) { + + List allManageRanges = getTaxAgentManageRangeMapper().listSome(TaxAgentManageRangePO.builder().taxAgentIds(taxAgentIds).build()); + + if (CollectionUtils.isEmpty(allManageRanges)) { + return; + } + taxAgentIds = allManageRanges.stream().map(TaxAgentManageRangePO::getTaxAgentId).distinct().collect(Collectors.toList()); + // 获取所有人员 + List salaryEmployees = getSalaryEmployeeService(user).listAll(UseEmployeeTypeEnum.ORG); + + List taxAgentEmpSaveParamList = Lists.newArrayList(); + List subAdminEmpSaveParamList = Lists.newArrayList(); + + Map> allRangeMap = SalaryEntityUtil.group2Map(allManageRanges, k -> k.getTaxAgentId() + "-" + k.getRangeType()); + taxAgentIds.forEach(taxAgentId -> { + // 当前个税扣缴义务人的所有范围 + List allRanges = Optional.ofNullable(allRangeMap.get(taxAgentId + "-" + TaxAgentRangeTypeEnum.TAXAGENT.getValue())).orElse(Collections.emptyList()); + List allSalaryEmployees = this.getManageRangeSalaryEmployees(taxAgentId, allRanges, salaryEmployees); + taxAgentEmpSaveParamList.add(getTaxAgentEmpSyncParam(taxAgentId, allSalaryEmployees)); + +// List allSubAdminRanges = Optional.ofNullable(allRangeMap.get(taxAgentId + "-" + TaxAgentRangeTypeEnum.SUBADMIN.getValue())).orElse(Collections.emptyList()); +// subAdminEmpSaveParamList.addAll(getTaxAgentSubAdminEmpSyncParam(taxAgentId, allSubAdminRanges, salaryEmployees)); + }); + Long employeeId = 0L; + // 同步管理员的人员 + getTaxAgentEmpService(user).syncTaxAgentEmployee(taxAgentEmpSaveParamList, employeeId); + // 同步分管理员的人员 +// taxAgentSubAdminEmployeeService.syncTaxAgentSubAdminEmployee(subAdminEmpSaveParamList, employeeId, tenantKey); + + //生成档案 + generateArchive(); + } + + /** + * 获取个税扣缴义务人的同步参数 + * + * @param taxAgentId + * @param allSalaryEmployees + * @return + */ + private TaxAgentEmpSaveParam getTaxAgentEmpSyncParam(Long taxAgentId, List allSalaryEmployees) { + return TaxAgentEmpSaveParam.builder().taxAgentId(taxAgentId).salaryEmployeeList(allSalaryEmployees).build(); + } + + /** + * 获取分管理员的同步参数 + * + * @param taxAgentId + * @param allSubAdminRanges + * @param salaryEmployees + * @return + */ + private List getTaxAgentSubAdminEmpSyncParam(Long taxAgentId, List allSubAdminRanges, List salaryEmployees) { + List allSubAdminIds = allSubAdminRanges.stream().map(TaxAgentManageRangePO::getTaxAgentSubAdminId).distinct().collect(Collectors.toList()); + List subAdminEmpSaveParamList = Lists.newArrayList(); + allSubAdminIds.forEach(e -> { + List singSubAdminRanges = allSubAdminRanges.stream().filter(r -> e.equals(r.getTaxAgentSubAdminId())).collect(Collectors.toList()); + List subAdminSalaryEmployees = this.getManageRangeSalaryEmployees(taxAgentId, singSubAdminRanges, salaryEmployees); + + subAdminEmpSaveParamList.add(TaxAgentSubAdminEmpSaveParam.builder().taxAgentId(taxAgentId).subAdminId(e).salaryEmployeeList(subAdminSalaryEmployees).build()); + }); + return subAdminEmpSaveParamList; + } + + /** + * 同步本地范围关联人员 + * + * @param taxAgentId + * @param allSalaryEmployees 个税扣缴义务人下的所有人员 + * @param employeeId + */ + private void syncLocalEmpRange(Long taxAgentId, List allSalaryEmployees, Long employeeId) { + log.info("同步个税扣缴人员范围"); + try { + List taxAgentEmpSaveParamList = Collections.singletonList(getTaxAgentEmpSyncParam(taxAgentId, allSalaryEmployees)); + // 同步个税扣缴义务人的人员 + getTaxAgentEmpService(user).syncTaxAgentEmployee(taxAgentEmpSaveParamList, employeeId); + +// List subAdminEmpSaveParamList = getTaxAgentSubAdminEmpSyncParam(taxAgentId, allSubAdminRanges); + // 同步分管理员的人员 +// taxAgentSubAdminEmployeeService.syncTaxAgentSubAdminEmployee(subAdminEmpSaveParamList, employeeId); + } catch (Exception e) { + log.error("同步个税扣缴人员范围异常", e); + } + } + + + /** + * 同步人员范围 + * + * @param taxAgentIds + */ + @Override + public void syncManageRange(List taxAgentIds, String index) { + // 开始同步 + LocalRunnable localRunnable = new LocalRunnable() { + @Override + public void execute() { + try { + Util_DataCache.setObjVal(index, "1"); + handleSyncTaxAgentEmpData(taxAgentIds); + } finally { + Util_DataCache.clearVal(index); + } + } + }; + ThreadPoolUtil.execute(localRunnable); + } + + /** + * 导入数据 + * + * @param taxAgentImportParam + * @return + */ + @Override + public Map importData(TaxAgentImportParam taxAgentImportParam) { + Boolean openDevolution = getTaxAgentService(user).isOpenDevolution(); + long currentEmployeeId = user.getUID(); + Map apidatas = new HashMap(); + + //查询对于人员信息导入筛选的全局配置 + SalarySysConfPO salarySysConfPO = getSalarySysConfMapper().getOneByCode("matchEmployeeMode"); + String confValue = (salarySysConfPO != null && salarySysConfPO.getConfValue() != null && !"".equals(salarySysConfPO.getConfValue())) ? salarySysConfPO.getConfValue() : "0"; + + //检验参数 + checkImportParam(taxAgentImportParam); + + //excel文件id + String imageId = Util.null2String(taxAgentImportParam.getImageId()); + Validate.notBlank(imageId, "imageId为空"); + //个税扣缴义务人 + Long taxAgentId = taxAgentImportParam.getTaxAgentId(); + TaxAgentPO taxAgent = getTaxAgentService(user).getById(taxAgentId); + InputStream fileInputStream = null; + try { + fileInputStream = ImageFileManager.getInputStreamById(Integer.parseInt(imageId)); + List rangeEmployees = ExcelParseHelper.parse2Map(fileInputStream, TaxAgentManageRangeEmployeeListDTO.class, 0, 1, 6, "TaxAgentEmployee.xlsx"); + + int total = rangeEmployees.size(); + int index = 0; + int successCount = 0; + int errorCount = 0; + + //人员信息 + List employees = getSalaryEmployeeService().listEmployee(); + + // 错误excel内容 + List errorData = new ArrayList<>(); + //合规数据 + List eligibleData = new ArrayList<>(); + // 全部员工状态 + Set allEmployeeStatuses = new HashSet<>(); + allEmployeeStatuses.addAll(SalaryEmployeeStatusEnum.getAllSalaryEmployeeStatusValues()); + + TaxAgentRangeSaveParam taxAgentRangeSaveParam = new TaxAgentRangeSaveParam(); + taxAgentRangeSaveParam.setTaxAgentId(taxAgentId); + taxAgentRangeSaveParam.setIncludeType(1); + taxAgentRangeSaveParam.setSync(true); +// taxAgentRangeSaveParam.setEmployeeStatus(allEmployeeStatuses); + + for (int i = 0; i < rangeEmployees.size(); i++) { + TaxAgentManageRangeEmployeeListDTO dto = rangeEmployees.get(i); + //待插入数据库对象 + TaxAgentManageRangeSaveParam.TaxAgentSubAdminRangeTargetParam po = new TaxAgentManageRangeSaveParam.TaxAgentSubAdminRangeTargetParam(); + po.setTargetType(TargetTypeEnum.EMPLOYEE); + + //异常点数量 + int errorSum = 0; + + //行号 + String rowIndex = String.format("第%s行", i + 2); + + //相同的姓名 + String userName = dto.getUsername(); + String deparmentName = dto.getDepartmentName(); + String mobile = dto.getMobile(); + String workcode = dto.getJobNum(); + String idNo = dto.getIdNo(); + + String employeeStatusStr = dto.getEmployeeStatus(); + List employeeSameIds = new ArrayList<>(); + + //筛选导入人员信息可以在人力资源池中匹配到的人员信息 + List emps = getSalaryEmployeeService().matchImportEmployee(confValue, employees, userName, deparmentName, mobile, workcode, idNo, null); + if (CollectionUtils.isNotEmpty(emps)) { + employeeSameIds = emps.stream().map(DataCollectionEmployee::getEmployeeId).collect(Collectors.toList()); + } + + //含在职和离职,选在职数据 + if (CollectionUtils.isNotEmpty(emps) && emps.size() > 1) { + employeeSameIds = emps.stream().filter(e -> UserStatusEnum.getNormalStatus().contains(e.getStatus())).map(DataCollectionEmployee::getEmployeeId).collect(Collectors.toList()); + } + if (CollectionUtils.isNotEmpty(emps) && emps.size() == 1) { + employeeSameIds = emps.stream().map(DataCollectionEmployee::getEmployeeId).collect(Collectors.toList()); + } + + //当人员信息导入筛选的全局配置为"0"时,姓名才是必填项 + if (StringUtils.isBlank(userName) && "0".equals(confValue)) { + //姓名 不能为空 + //错误消息对象 + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowIndex + "姓名不能为空"); + errorData.add(errorMessageMap); + errorSum += 1; + } else if (CollectionUtils.isEmpty(employeeSameIds) || employeeSameIds.size() > 1) { + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowIndex + "员工信息不存在或者存在多个员工"); + errorData.add(errorMessageMap); + errorSum += 1; + } else { + Long employeeId = CollectionUtils.isNotEmpty(employeeSameIds) && employeeSameIds.size() == 1 ? employeeSameIds.get(0) : null; + if (employeeId != null && employeeId > 0) { + po.setTargetId(employeeId); + } else { + //姓名错误,系统内不存在该姓名 + Map errorMessageMap = new HashMap<>(); + errorMessageMap.put("message", rowIndex + "姓名错误,系统内不存在该姓名"); + errorData.add(errorMessageMap); + errorSum += 1; + } + } + + // 设置员工状态 + if (StringUtils.isEmpty(employeeStatusStr)) { + po.setEmployeeStatus(allEmployeeStatuses); + } else { + Boolean[] haveError = {false}; + // 人员状态字符串转换为对应的value + List status = SalaryEmployeeStatusEnum.parseByFormatStr(employeeStatusStr, haveError); + if (haveError[0]) { + Map errorMessageMap = new HashMap<>(); + errorMessageMap.put("message", rowIndex + "员工状态不存在,或格式有误。格式为:试用、正式、临时、试用延期"); + errorData.add(errorMessageMap); + errorSum += 1; + } else { + po.setEmployeeStatus(status); + } + } + + + if (Objects.isNull(taxAgent)) { + //个税扣缴义务人不存在 + Map errorMessageMap = new HashMap<>(); + errorMessageMap.put("message", "个税扣缴义务人不存在或不在权限范围内"); + errorData.add(errorMessageMap); + errorSum += 1; + } + + //fixme 分权判断 + if (errorSum == 0) { + successCount += 1; + // 合格数据 + eligibleData.add(po); + } else { + errorCount += 1; + // 添加错误数据 + } + } + + //入库-----------------start + eligibleData = handleImportData(eligibleData); + taxAgentRangeSaveParam.setTargetParams(eligibleData); + // 查询已有的管理范围 + List taxAgentManageAllRanges = listByTaxAgentId(taxAgentId); + List taxAgentManageRanges = taxAgentManageAllRanges.stream().filter(f -> f.getIncludeType().equals(taxAgentRangeSaveParam.getIncludeType())).collect(Collectors.toList()); + List oldManageList = new ArrayList<>(); + taxAgentManageRanges.stream().forEach(p -> { + TaxAgentManageRangePO target = new TaxAgentManageRangePO(); + BeanUtils.copyProperties(p, target); + oldManageList.add(target); + }); + + // 处理一下本次的保存参数(如果原来添加过对应的人员(/部门/岗位),那么本次不需要新增,只需要更新) + TaxAgentBO.Result result = TaxAgentBO.handleTaxAgentRange(taxAgentManageRanges, taxAgentRangeSaveParam, taxAgent.getId(), (long) user.getUID(), true); + + /* 检查当前个税扣缴义务人的所有人员范围与所有分管理员的管理范围===========================start */ + List allRanges = Lists.newArrayList(taxAgentManageAllRanges); + allRanges.addAll(result.getNeedInsertTaxAgentManageRanges()); + allRanges.addAll(result.getNeedUpdateTaxAgentManageRanges()); + // 去重 + allRanges = allRanges.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(f -> f.getTaxAgentId() + "." + f.getRangeType() + "." + f.getTargetType() + "." + f.getTargetId() + "." + f.getEmployeeStatus() + "." + f.getIncludeType()))), ArrayList::new)); + + List salaryEmployees = getSalaryEmployeeService().listAll(UseEmployeeTypeEnum.ALL); + List allSalaryEmployees = this.getManageRangeSalaryEmployees(taxAgentId, allRanges, salaryEmployees); + + /* 检查当前个税扣缴义务人的所有人员范围与所有分管理员的管理范围===========================end */ + if (CollectionUtils.isNotEmpty(result.getNeedInsertTaxAgentManageRanges())) { + result.getNeedInsertTaxAgentManageRanges().forEach(range -> { + getTaxAgentManageRangeMapper().insertIgnoreNull(range); + // 记录操作日志 + String name = taxAgent.getName() + "_" + TargetTypeEnum.parseByValue(range.getTargetType()).getDefaultLabel() + "_" + range.getTargetId(); + SalaryLoggerUtil.recordAddSingleLog(SalaryElogConfig.taxAgentLoggerTemplate, range.getTaxAgentId(), name, SalaryI18nUtil.getI18nLabel(0, "新增人员范围"), SalaryI18nUtil.getI18nLabel(0, "新增人员范围") + name, range, user); + }); + } + if (CollectionUtils.isNotEmpty(result.getNeedUpdateTaxAgentManageRanges())) { + Map oldMap = SalaryEntityUtil.convert2Map(oldManageList, TaxAgentManageRangePO::getId); + result.getNeedUpdateTaxAgentManageRanges().forEach(range -> { + getTaxAgentManageRangeMapper().updateIgnoreNull(range); + // 记录操作日志 + TaxAgentManageRangePO oldPO = oldMap.getOrDefault(range.getId(), TaxAgentManageRangePO.builder().build()); + String name = taxAgent.getName() + "_" + TargetTypeEnum.parseByValue(range.getTargetType()).getDefaultLabel() + "_" + range.getTargetId(); + SalaryLoggerUtil.recordUpdateSingleLog(SalaryElogConfig.taxAgentLoggerTemplate, range.getTaxAgentId(), name, SalaryI18nUtil.getI18nLabel(0, "更新人员范围"), SalaryI18nUtil.getI18nLabel(0, "更新人员范围") + name, oldPO, range, user); + }); + + } + + /* 同步本地人员范围的关联人员=========================== */ + syncLocalEmp(taxAgentId, allSalaryEmployees, taxAgentRangeSaveParam.isSync()); + //-----------------end + + apidatas.put("successCount", successCount); + apidatas.put("errorCount", errorCount); + apidatas.put("errorData", errorData); + + } finally { + IOUtils.closeQuietly(fileInputStream); + } + return apidatas; + } + + // 处理导入数据 + private List handleImportData(List pos) { + if (CollectionUtils.isEmpty(pos)) { + return Collections.emptyList(); + } + // 多条相同人的则以第一条为准,如果逆序排列(用于重复的则以最后一条为准)Collections.reverse(pos); + // 去重(通过记录的唯一条件(人员id) + List finalPos = pos.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(f -> f.getTargetId()))), ArrayList::new)); + return finalPos; + } + + private void checkImportParam(TaxAgentImportParam importParam) { + //excel文件id + String imageId = Util.null2String(importParam.getImageId()); + + if (StringUtils.isBlank(imageId)) { + throw new SalaryRunTimeException("文件不存在"); + } + Long taxAgentId = importParam.getTaxAgentId(); + if (Objects.isNull(taxAgentId)) { + throw new SalaryRunTimeException("个税扣缴义务人为空"); + } + } + +} diff --git a/src/com/engine/salary/service/impl/TaxAgentServiceImpl.java b/src/com/engine/salary/service/impl/TaxAgentServiceImpl.java new file mode 100644 index 000000000..0051bd7b8 --- /dev/null +++ b/src/com/engine/salary/service/impl/TaxAgentServiceImpl.java @@ -0,0 +1,868 @@ +package com.engine.salary.service.impl; + +import com.engine.common.service.HrmCommonService; +import com.engine.common.service.impl.HrmCommonServiceImpl; +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.hrmelog.entity.dto.LoggerContext; +import com.engine.salary.config.SalaryElogConfig; +import com.engine.salary.constant.SalaryAuthConstant; +import com.engine.salary.entity.datacollection.AddUpDeduction; +import com.engine.salary.entity.datacollection.AddUpSituation; +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.datacollection.po.OtherDeductionPO; +import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO; +import com.engine.salary.entity.salaryarchive.po.SalaryArchivePO; +import com.engine.salary.entity.salarysob.config.SalarySobConfig; +import com.engine.salary.entity.salarysob.po.SobTaxLinkPO; +import com.engine.salary.entity.siaccount.param.InsuranceAccountBatchParam; +import com.engine.salary.entity.siaccount.po.InsuranceAccountBatchPO; +import com.engine.salary.entity.siarchives.po.InsuranceArchivesBaseInfoPO; +import com.engine.salary.entity.taxagent.bo.TaxAgentBO; +import com.engine.salary.entity.taxagent.config.TaxAgentConfig; +import com.engine.salary.entity.taxagent.dto.TaxAgentEmployeeDTO; +import com.engine.salary.entity.taxagent.dto.TaxAgentEmployeeTaxAgentDTO; +import com.engine.salary.entity.taxagent.dto.TaxAgentListDTO; +import com.engine.salary.entity.taxagent.dto.TaxAgentManageRangeEmployeeDTO; +import com.engine.salary.entity.taxagent.param.TaxAgentAdminChangeCheckParam; +import com.engine.salary.entity.taxagent.param.TaxAgentQueryParam; +import com.engine.salary.entity.taxagent.param.TaxAgentSaveParam; +import com.engine.salary.entity.taxagent.po.*; +import com.engine.salary.enums.OperateTypeEnum; +import com.engine.salary.enums.auth.AuthFilterTypeEnum; +import com.engine.salary.enums.datacollection.UseEmployeeTypeEnum; +import com.engine.salary.enums.salaryaccounting.SalaryAcctRecordStatusEnum; +import com.engine.salary.enums.salarysob.SalaryEmployeeStatusEnum; +import com.engine.salary.enums.taxagent.TaxAgentRoleTypeEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.mapper.archive.SalaryArchiveMapper; +import com.engine.salary.mapper.datacollection.AddUpDeductionMapper; +import com.engine.salary.mapper.datacollection.AddUpSituationMapper; +import com.engine.salary.mapper.datacollection.OtherDeductionMapper; +import com.engine.salary.mapper.salarysob.SalarySobMapper; +import com.engine.salary.mapper.salarysob.SobTaxLinkMapper; +import com.engine.salary.mapper.siaccount.InsuranceAccountBatchMapper; +import com.engine.salary.mapper.siarchives.InsuranceBaseInfoMapper; +import com.engine.salary.mapper.taxagent.TaxAgentMapper; +import com.engine.salary.service.*; +import com.engine.salary.service.auth.AuthService; +import com.engine.salary.service.auth.AuthServiceImpl; +import com.engine.salary.sys.entity.vo.UploadConfigResponse; +import com.engine.salary.util.SalaryEntityUtil; +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.page.SalaryPageUtil; +import com.engine.salary.util.valid.RuntimeTypeEnum; +import com.engine.salary.util.valid.ValidUtil; +import com.google.common.collect.Lists; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.BeanUtils; +import weaver.hrm.User; +import weaver.systeminfo.setting.HrmUserSettingComInfo; +import weaver.systeminfo.systemright.CheckUserRight; + +import java.util.*; +import java.util.stream.Collectors; + +@Slf4j +public class TaxAgentServiceImpl extends Service implements TaxAgentService { + + + private TaxAgentBaseService getTaxAgentBaseService(User user) { + return ServiceUtil.getService(TaxAgentBaseServiceImpl.class, user); + } + + private TaxAgentAdminService getTaxAgentAdminService(User user) { + return ServiceUtil.getService(TaxAgentAdminServiceImpl.class, user); + } + + private TaxAgentSubAdminService taxAgentSubAdminService; + + private TaxAgentManageRangeService getTaxAgentManageRangeService(User user) { + return ServiceUtil.getService(TaxAgentManageRangeServiceImpl.class, user); + } + + private TaxAgentEmpService getTaxAgentEmpService(User user) { + return ServiceUtil.getService(TaxAgentEmpServiceImpl.class, user); + } + + private TaxAgentSubAdminEmpService taxAgentSubAdminEmpService; + + private HrmCommonService getHrmCommonService(User user) { + return ServiceUtil.getService(HrmCommonServiceImpl.class, user); + } + + + private SalarySobService getSalarySobService(User user) { + return ServiceUtil.getService(SalarySobServiceImpl.class, user); + } + + + private SalaryAcctRecordService getSalaryAcctRecordService(User user) { + return ServiceUtil.getService(SalaryAcctRecordServiceImpl.class, user); + } + + private SIAccountService getSIAccountService(User user) { + return ServiceUtil.getService(SIAccountServiceImpl.class, user); + } + + private SalaryArchiveMapper getSalaryArchiveMapper() { + return MapperProxyFactory.getProxy(SalaryArchiveMapper.class); + } + + private AddUpDeductionMapper getAddUpDeductionMapper() { + return MapperProxyFactory.getProxy(AddUpDeductionMapper.class); + } + + private OtherDeductionMapper getOtherDeductionMapper() { + return MapperProxyFactory.getProxy(OtherDeductionMapper.class); + } + + private AddUpSituationMapper getAddUpSituationMapper() { + return MapperProxyFactory.getProxy(AddUpSituationMapper.class); + } + + private SalarySobMapper getSalarySobMapper() { + return MapperProxyFactory.getProxy(SalarySobMapper.class); + } + + private SobTaxLinkMapper getSobTaxLinkMapper() { + return MapperProxyFactory.getProxy(SobTaxLinkMapper.class); + } + + private TaxAgentMapper getTaxAgentMapper() { + return MapperProxyFactory.getProxy(TaxAgentMapper.class); + } + + private SalaryEmployeeService getSalaryEmployeeService(User user) { + return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user); + } + + private InsuranceBaseInfoMapper getInsuranceBaseInfoMapper() { + return MapperProxyFactory.getProxy(InsuranceBaseInfoMapper.class); + } + + private InsuranceAccountBatchMapper getInsuranceAccountBatchMapper() { + return MapperProxyFactory.getProxy(InsuranceAccountBatchMapper.class); + } + + public AuthService getAuthService(User user) { + return ServiceUtil.getService(AuthServiceImpl.class, user); + } + + +// private PaymentAgencyMapper paymentAgencyMapper; + +// private SIArchivesSocialMapper siArchivesSocialMapper; + +// private SIArchivesFundMapper siArchivesFundMapper; + +// private SIArchivesOtherMapper siArchivesOtherMapper; + +// private AuthorityService authorityService; + + +// private HrmCommonHrmStatusService hrmCommonHrmStatusService; + + + @Override + public List listEmployees() { + List employees = getSalaryEmployeeService(user).listEmployee(); + return convert2TaxAgentEmployeePO(employees); + } + + public List convert2TaxAgentEmployeePO(List dataCollectionEmployees) { + List result = new ArrayList<>(); + dataCollectionEmployees.stream().forEach(PO -> { + TaxAgentEmployeePO taxAgentEmployeePO = new TaxAgentEmployeePO(); + BeanUtils.copyProperties(PO, taxAgentEmployeePO); + result.add(taxAgentEmployeePO); + }); + return result; + } + + @Override + public TaxAgentRoleTypeEnum getRoleType(Long currentEmployeeId) { + TaxAgentRoleTypeEnum roleType = TaxAgentRoleTypeEnum.NONE; + if (isChief(currentEmployeeId)) { + return TaxAgentRoleTypeEnum.CHIEF; + } + // 是否开启分权 + boolean isOpenDevolution = getTaxAgentBaseService(user).isOpenDevolution(); + if (!isOpenDevolution) { + List taxAgentAdmins = getTaxAgentAdminService(user).listByEmployeeId(currentEmployeeId); + if (CollectionUtils.isNotEmpty(taxAgentAdmins)) { + return TaxAgentRoleTypeEnum.ADMIN; + } + List taxAgentSubAdmins = taxAgentSubAdminService.listByAndEmployeeId(currentEmployeeId); + if (CollectionUtils.isNotEmpty(taxAgentSubAdmins)) { + return TaxAgentRoleTypeEnum.SUBADMIN; + } + } + return roleType; + } + + + @Override + public Boolean isNeedAuth(Long currentEmployeeId) { + return isOpenDevolution() && !isChief(currentEmployeeId); + } + + + @Override + public Boolean isChief(Long currentEmployeeId) { + if (user == null) { + return false; + } + CheckUserRight ck = new CheckUserRight(); + boolean hasRight = ck.checkUserRight(SalaryAuthConstant.SALARY_CHIEF, user); + + if (!hasRight) { + String belongtoshow = "";// 是否启用多账号数据显示 + try { + HrmUserSettingComInfo HrmUserSettingComInfo = new HrmUserSettingComInfo(); + belongtoshow = HrmUserSettingComInfo.getBelongtoshowByUserId("" + user.getUID()); + } catch (Exception e) { + log.error("获取权限异常", e); + } + + if (belongtoshow.equals("1")) { + List lsUser = User.getBelongtoUsersByUserId(user.getUID());// 所有此账号 + if (lsUser != null) { + for (Object tmpUser : lsUser) { + hasRight = ck.checkUserRight(SalaryAuthConstant.SALARY_CHIEF, (User) tmpUser); + if (hasRight) { + break; + } + } + } + } + } + + return hasRight; + } + + @Override + public List getAdminTaxAgentIds(Long currentEmployeeId) { + return getTaxAgentAdminService(user).getAdminTaxAgentIds(currentEmployeeId); + } + + @Override + public Boolean isDefaultOpen(Long currentEmployeeId) { + return getTaxAgentBaseService(user).isOpenDevolution(); + } + + @Override + public Boolean isAdminEnable(Long currentEmployeeId) { + //是管理员 + List taxAgentAdminList = getTaxAgentAdminService(user).listByEmployeeId(currentEmployeeId); + return CollectionUtils.isNotEmpty(taxAgentAdminList); + } + + + @Override + public PageInfo listPage(TaxAgentQueryParam queryParam) { + queryParam.setFilterType(AuthFilterTypeEnum.QUERY_DATA); + List taxAgentPOS = listAuth(queryParam); + return SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), + taxAgentPOS, TaxAgentPO.class); + } + + @Override + public List list(TaxAgentQueryParam queryParam) { + return getTaxAgentMapper().listBySome(queryParam); + } + + + @Override + public List listByIds(Collection ids) { + return getTaxAgentMapper().listBySome(TaxAgentQueryParam.builder().ids(ids).build()); + } + + @Override + public List listAll() { + return getTaxAgentMapper().listAll(); + } + + @Override + public List listAuth(TaxAgentQueryParam queryParam) { + List taxAgents = getTaxAgentMapper().listBySome(queryParam); + AuthFilterTypeEnum filterType = queryParam.getFilterType(); + return getAuthService(user).auth(taxAgents, filterType, TaxAgentPO.class); + } + + @Override + public TaxAgentPO getById(Long id) { + return getTaxAgentMapper().getById(id); + } + + @Override + public Collection findAll() { + List taxAgents = getTaxAgentMapper().listAll(); + return TaxAgentBO.convertToListDTO(taxAgents); + } + + @Override + public List listAllTaxAgents(Long employeeId) { + List taxAgents = getTaxAgentMapper().listAll(); + return handleForDevolution(taxAgents, employeeId, true); + } + + @Override + public Collection listAllTaxAgentsAsAdmin(Long employeeId) { + TaxAgentQueryParam param = TaxAgentQueryParam.builder().build(); + param.setFilterType(AuthFilterTypeEnum.ADMIN_DATA); + return listAuth(param); + } + + @Override + public Collection listAllTaxAgentsAsRange(List employeeIds) { + List taxAgents = getTaxAgentMapper().listAll(); + List taxAgentIds = taxAgents.stream().map(TaxAgentPO::getId).collect(Collectors.toList()); + + List taxAgentEmployees = getTaxAgentEmpService(user).listByTaxAgentIds(taxAgentIds, UseEmployeeTypeEnum.ORG); + + if (CollectionUtils.isEmpty(taxAgentEmployees)) { + return Lists.newArrayList(); + } + + // 转换数据结构 + List allemployeeIds = taxAgentEmployees.stream().map(TaxAgentEmpPO::getEmployeeId).distinct().collect(Collectors.toList()); + + return allemployeeIds.stream().map(m -> { + List enableTaxAgentIds = taxAgentEmployees.stream().filter(f -> f.getEmployeeId().equals(m)).map(TaxAgentEmpPO::getTaxAgentId).distinct() + .collect(Collectors.toList()); + return TaxAgentEmployeeTaxAgentDTO.builder() + .employeeId(m) + .taxAgentIds(enableTaxAgentIds) + .build(); + }).collect(Collectors.toList()); + } + + @Override + public String save(TaxAgentSaveParam saveParam) { + ValidUtil.doValidator(saveParam); + saveParam.setName(StringUtils.trim(saveParam.getName())); + + // 是否开启分权 + boolean isOpenDevolution = getTaxAgentBaseService(user).isOpenDevolution(); + if (isOpenDevolution && CollectionUtils.isEmpty(saveParam.getAdminUserIds())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(106271, "请选择管理员")); + } + List taxAgents = getTaxAgentMapper().listByName(saveParam.getName()); + if (CollectionUtils.isNotEmpty(taxAgents)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98080, "名称不允许重复")); + } +// PaymentAgencyPO paymentAgencyPO = new LambdaQueryChainWrapper<>(paymentAgencyMapper) +// .eq(PaymentAgencyPO::getTenantKey) +// .eq(PaymentAgencyPO::getDeleteType, DeleteTypeEnum.NOT_DELETED.getValue()) +// .eq(PaymentAgencyPO::getAgencyName, saveParam.getName()) +// .one(); +// if (paymentAgencyPO != null) { +// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(115130, "名称不允许与社保福利代缴机构名称重复")); +// } + // 保存 + TaxAgentPO taxAgent = TaxAgentBO.convertToPO(saveParam, (long) user.getUID()); + getTaxAgentMapper().insertIgnoreNull(taxAgent); + if (isOpenDevolution) { + getTaxAgentAdminService(user).batchInsert(taxAgent.getId(), saveParam.getAdminUserIds()); + } + // 记录日志 + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(taxAgent.getId().toString()); + loggerContext.setTargetName(taxAgent.getName()); + loggerContext.setOperateType(OperateTypeEnum.ADD.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "新增个税扣缴义务人")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "新增个税扣缴义务人")); + loggerContext.setNewValues(taxAgent); + SalaryElogConfig.taxAgentLoggerTemplate.write(loggerContext); + return StringUtils.EMPTY + taxAgent.getId(); + } + + @Override + public String paymentAgencyUpdate(TaxAgentPO taxAgentPO) { + getTaxAgentMapper().update(taxAgentPO); + return ""; + } + + @Override + public String update(TaxAgentSaveParam saveParam) { + ValidUtil.doValidator(saveParam, RuntimeTypeEnum.UPDATE); + saveParam.setName(StringUtils.trim(saveParam.getName())); + + TaxAgentPO taxAgent = getById(saveParam.getId()); + if (taxAgent == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100545, "个税扣缴义务人不存在或不在权限范围内")); + } + // 是否开启分权 + boolean isOpenDevolution = getTaxAgentBaseService(user).isOpenDevolution(); + if (isOpenDevolution && CollectionUtils.isEmpty(saveParam.getAdminUserIds())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(106271, "请选择管理员")); + } + + List individualTaxWithholdingAgents = getTaxAgentMapper().listByName(saveParam.getName()); + boolean nameExist = individualTaxWithholdingAgents.stream().anyMatch(e -> !Objects.equals(e.getId(), saveParam.getId())); + if (nameExist) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98080, "名称不允许重复")); + } + TaxAgentPO taxAgentNew = new TaxAgentPO(); + BeanUtils.copyProperties(taxAgent, taxAgentNew); + BeanUtils.copyProperties(saveParam, taxAgentNew); + taxAgentNew.setUpdateTime(new Date()); + getTaxAgentMapper().update(taxAgentNew); + if (isOpenDevolution) { +// Boolean isUnEnableChange = adminChangeCheck(TaxAgentAdminChangeCheckParam.builder() +// .taxAgentId(saveParam.getId()) +// .adminUserId(saveParam.getAdminUserIds()) +// .build()); +// if (isUnEnableChange) { +// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(115937, "该管理员有未归档核算数据,不可更换管理员")); +// } + // 删除管理员 + getTaxAgentAdminService(user).deleteByTaxAgentIds(Collections.singletonList(taxAgent.getId())); + // 新增管理员 + getTaxAgentAdminService(user).batchInsert(saveParam.getId(), saveParam.getAdminUserIds()); + } + // 记录日志 + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(taxAgentNew.getId().toString()); + loggerContext.setTargetName(taxAgentNew.getName()); + loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "编辑个税扣缴义务人")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "编辑个税扣缴义务人")); + loggerContext.setOldValues(taxAgent); + loggerContext.setNewValues(taxAgentNew); + SalaryElogConfig.taxAgentLoggerTemplate.write(loggerContext); + + return StringUtils.EMPTY; + } + + @Override + public Boolean adminChangeCheck(TaxAgentAdminChangeCheckParam checkParam) { + ValidUtil.doValidator(checkParam); + List taxAgentAdminList = getTaxAgentAdminService(user).listByTaxAgentIds(Collections.singletonList(checkParam.getTaxAgentId())); + Long adminUserId = CollectionUtils.isNotEmpty(taxAgentAdminList) ? taxAgentAdminList.get(0).getEmployeeId() : 0L; + boolean isChanged = checkParam.getAdminUserId() != null && !adminUserId.equals(checkParam.getAdminUserId()); + // 更换了管理员 + if (isChanged) { + // 检查是否核算 + //todo 1.社保福利档案是否有核算未归档 + Boolean checkedValue = false;// getSIAccountService(user).changeAdminUnfiledCheck(adminUserId); + // 2.薪资核算是否有核算未归档 + List salaryAcctRecords = getSalaryAcctRecordService(user).listByStatusAndEmployeeId(SalaryAcctRecordStatusEnum.NOT_ARCHIVED, adminUserId); + if (CollectionUtils.isNotEmpty(salaryAcctRecords) || checkedValue) { + return Boolean.TRUE; + } + } + return Boolean.FALSE; + } + + + @Override + public String delete(List ids) { + + if (org.springframework.util.CollectionUtils.isEmpty(ids)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(84026, "参数错误")); + } + + List taxAgents = getTaxAgentMapper().listBySome(TaxAgentQueryParam.builder().ids(ids).build()); + if (CollectionUtils.isEmpty(taxAgents)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(85382, "要删除的个税扣缴义务人在不存在或已删除")); + } + // 正在使用的记录不允许删除 + boolean checkUsed = checkUsed(ids.get(0)); + if (checkUsed) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100570, "正在使用的记录不允许删除")); + } + // 删除管理员 + getTaxAgentAdminService(user).deleteByTaxAgentIds(ids); + // 删除人员范围 + getTaxAgentManageRangeService(user).deleteByTaxAgentIds(ids); + + getTaxAgentMapper().deleteByIds(ids); + + // 记录日志 + taxAgents.forEach(e -> { + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(e.getId().toString()); + loggerContext.setTargetName(e.getName()); + loggerContext.setOperateType(OperateTypeEnum.DELETE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "删除个税扣缴义务人")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "删除个税扣缴义务人")); + loggerContext.setOldValues(e); + SalaryElogConfig.taxAgentLoggerTemplate.write(loggerContext); + + }); + return StringUtils.EMPTY; + } + + /** + * 检查正在被使用的记录 + * + * @param id + * @return + */ + private boolean checkUsed(Long id) { + //被薪资档案引用 + List salaryArchiveList = getSalaryArchiveMapper().listSome(SalaryArchivePO.builder().taxAgentId(id).build()); + if (CollectionUtils.isNotEmpty(salaryArchiveList)) { + throw new SalaryRunTimeException("存在薪资档案引用"); + } + // 被社保福利档案引用 + List socialByPaymentOrganization = getInsuranceBaseInfoMapper().getSocialByPaymentOrganization(id); + if (CollectionUtils.isNotEmpty(socialByPaymentOrganization)) { + throw new SalaryRunTimeException("存在社保福利档案引用"); + } + // 被社保福利台账引用 + List insuranceArchiveList = getInsuranceAccountBatchMapper().list(InsuranceAccountBatchParam.builder().taxAgents(Collections.singletonList(id)).build()); + if (CollectionUtils.isNotEmpty(insuranceArchiveList)) { + throw new SalaryRunTimeException("存在社保福利台账引用"); + } + //被社保福利档案引用 +// List socialSchemePOList = new LambdaQueryChainWrapper<>(siArchivesSocialMapper) +// .eq(InsuranceArchivesSocialSchemePO::getTenantKey) +// .eq(InsuranceArchivesSocialSchemePO::getDeleteType, DeleteTypeEnum.NOT_DELETED.getValue()) +// .in(InsuranceArchivesSocialSchemePO::getPaymentOrganization, ids) +// .list(); +// if (CollectionUtils.isNotEmpty(socialSchemePOList)) { +// return Boolean.TRUE; +// } +// List fundSchemePOList = new LambdaQueryChainWrapper<>(siArchivesFundMapper) +// .eq(InsuranceArchivesFundSchemePO::getTenantKey) +// .eq(InsuranceArchivesFundSchemePO::getDeleteType, DeleteTypeEnum.NOT_DELETED.getValue()) +// .in(InsuranceArchivesFundSchemePO::getPaymentOrganization, ids) +// .list(); +// if (CollectionUtils.isNotEmpty(fundSchemePOList)) { +// return Boolean.TRUE; +// } +// List otherSchemePOList = new LambdaQueryChainWrapper<>(siArchivesOtherMapper) +// .eq(InsuranceArchivesOtherSchemePO::getTenantKey) +// .eq(InsuranceArchivesOtherSchemePO::getDeleteType, DeleteTypeEnum.NOT_DELETED.getValue()) +// .in(InsuranceArchivesOtherSchemePO::getPaymentOrganization, ids) +// .list(); +// if (CollectionUtils.isNotEmpty(otherSchemePOList)) { +// return Boolean.TRUE; +// } + + // 被外部人员引用 +// List extEmployeeList = extEmployeeService.listAll(tenantKey); +// List extTaxAgentIds = extEmployeeList.stream().map(ExtEmployeePO::getTaxAgentId).distinct().collect(Collectors.toList()); +// if (CollectionUtils.isNotEmpty(extTaxAgentIds)) { +// return ids.stream().anyMatch(e -> extTaxAgentIds.stream().anyMatch(f -> f.equals(e))); +// } + + // 被累计专项附加扣除引用 + List addUpDeductionList = getAddUpDeductionMapper().listSome(AddUpDeduction.builder().taxAgentIds(Collections.singleton(id)).build()); + if (CollectionUtils.isNotEmpty(addUpDeductionList)) { + throw new SalaryRunTimeException("存在累计专项附加扣除引用"); + } + // 被其他免税扣除引用 + List otherDeductionList = getOtherDeductionMapper().listSome(OtherDeductionPO.builder().taxAgentIds(Collections.singleton(id)).build()); + if (CollectionUtils.isNotEmpty(otherDeductionList)) { + throw new SalaryRunTimeException("存在其他免税扣除引用"); + } + // 被往期累计情况引用 + List addUpSituationList = getAddUpSituationMapper().listSome(AddUpSituation.builder().taxAgentIds(Collections.singleton(id)).build()); + if (CollectionUtils.isNotEmpty(addUpSituationList)) { + throw new SalaryRunTimeException("存在往期累计情况引用"); + } + + //账套 + List sobTaxLinkPOS = getSobTaxLinkMapper().listSome(SobTaxLinkPO.builder().taxAgentId(id).build()); + if (CollectionUtils.isNotEmpty(sobTaxLinkPOS)) { + throw new SalaryRunTimeException("存在账套引用"); + } + + return Boolean.FALSE; + } + + @Override + public List> selectList(boolean needAuth) { + List taxAgents = getTaxAgentMapper().listAll(); + if (needAuth) { + taxAgents = handleForDevolution(taxAgents, (long) user.getUID(), true); + } + return taxAgents.stream().map(m -> { + Map map = new HashMap<>(2); + map.put("id", String.valueOf(m.getId())); + map.put("content", m.getName()); + return map; + }).collect(Collectors.toList()); + } + + @Override + public List> selectListAsAdmin(boolean chiefCanSeeAll) { + List taxAgents = getTaxAgentMapper().listAll(); + taxAgents = handleForDevolution(taxAgents, (long) user.getUID(), false); + return taxAgents.stream().map(m -> { + Map map = new HashMap<>(2); + map.put("id", String.valueOf(m.getId())); + map.put("content", m.getName()); + return map; + }).collect(Collectors.toList()); + } + + /** + * 分权处理(总管理员可见所有) + * + * @param taxAgents + * @param currentEmployeeId + * @param chiefCanSeeAll 总管理员是否可见所有 + * @return + */ + private List handleForDevolution(List taxAgents, Long currentEmployeeId, boolean chiefCanSeeAll) { + // 是否开启分权 + boolean isOpenDevolution = getTaxAgentBaseService(user).isOpenDevolution(); + if (!isOpenDevolution || (chiefCanSeeAll && isChief(currentEmployeeId))) { + return taxAgents; + } + List taxAgentIds = taxAgents.stream().map(TaxAgentPO::getId).collect(Collectors.toList()); + List enableTaxAgentIds = Lists.newArrayList(); + // 1.判断自己是否是管理员, 如果是管理员,就是能够查看所属个税扣缴义务人 + List taxAgentAdminList = getTaxAgentAdminService(user).listByTaxAgentIdsAndEmployeeId(taxAgentIds, currentEmployeeId); + // 是管理员的列表 + List adminTaxAgentIds = taxAgentAdminList.stream().map(TaxAgentAdminPO::getTaxAgentId).collect(Collectors.toList()); + + enableTaxAgentIds.addAll(adminTaxAgentIds); + + return taxAgents.stream().filter(f -> enableTaxAgentIds.contains(f.getId())).collect(Collectors.toList()); + } + + + @Override + public Boolean isOpenDevolution() { + return getTaxAgentBaseService(user).isOpenDevolution(); + } + + @Override + public List listTaxAgentAndEmployeeTree(Long employeeId) { + return listTaxAgentAndEmployeeTree(null, employeeId); + } + + + @Override + public List listTaxAgentAndEmployee(Long employeeId) { + return listTaxAgentAndEmployee(null, employeeId); + } + + @Override + public List listAllTaxAgentAndEmployee() { + List taxAgentEmployeeList = Lists.newArrayList(); + + List taxAgentManageRangeEmployeeList = listTaxAgentAndEmployeeTree(); + taxAgentManageRangeEmployeeList.forEach(m -> { + List employeeList = m.getEmployeeList(); + if (CollectionUtils.isEmpty(employeeList)) { + taxAgentEmployeeList.add(TaxAgentEmployeeDTO.builder() + .taxAgentId(m.getTaxAgentId()) + .taxAgentName(m.getTaxAgentName()) + .employeeId(null) + .username(null) + .build()); + } else { + employeeList.forEach(f -> taxAgentEmployeeList.add(TaxAgentEmployeeDTO.builder() + .taxAgentId(m.getTaxAgentId()) + .taxAgentName(m.getTaxAgentName()) + .employeeId(f.getEmployeeId()) + .username(f.getUsername()) + .build())); + } + }); + + return taxAgentEmployeeList; + } + + @Override + public List listTaxAgentAndEmployeeTree(SalaryEmployeeStatusEnum employeeStatus, Long employeeId) { + List taxAgentManageRangeEmployeeList = Lists.newArrayList(); + // 所有个税扣缴义务人 + List allTaxAgents = listAll(); + if (CollectionUtils.isEmpty(allTaxAgents)) { + return taxAgentManageRangeEmployeeList; + } + + List taxAgentIds = allTaxAgents.stream().map(TaxAgentPO::getId).collect(Collectors.toList()); + if (employeeStatus != null) { + List personnelStatusList; + // 查询人员状态 +// if (employeeStatus.equals(SalaryEmployeeStatusEnum.NORMAL)) { +// allEmployees = allEmployees.stream().filter(f -> UserStatusEnum.getNormalStatus().contains(f.getStatus())).collect(Collectors.toList()); +// } else if (employeeStatus.equals(SalaryEmployeeStatusEnum.UNAVAILABLE)) { +// allEmployees = allEmployees.stream().filter(f -> UserStatusEnum.getUnavailableStatus().contains(f.getStatus())).collect(Collectors.toList()); +// } + } + + // 是否开启分权 + if (!isOpenDevolution() || isChief(employeeId)) { + return getTaxAgentEmp(allTaxAgents, taxAgentIds); + } + + // 1.判断自己是否是管理员, 如果是管理员,就是能够操作所属个税扣缴义务人下的所有人的数据 + List taxAgentAdminList = getTaxAgentAdminService(user).listByTaxAgentIdsAndEmployeeId(taxAgentIds, (long) user.getUID()); + // 是管理员的列表 + List adminTaxAgentIds = taxAgentAdminList.stream().map(TaxAgentAdminPO::getTaxAgentId).collect(Collectors.toList()); + + if (CollectionUtils.isNotEmpty(adminTaxAgentIds)) { + taxAgentManageRangeEmployeeList.addAll(getTaxAgentEmp(allTaxAgents, adminTaxAgentIds)); + } + + return taxAgentManageRangeEmployeeList; + } + + + @Override + public List listTaxAgentAndEmployeeTree() { + List taxAgentManageRangeEmployeeList = Lists.newArrayList(); + // 所有个税扣缴义务人 + List allTaxAgents = listAll(); + if (CollectionUtils.isEmpty(allTaxAgents)) { + return taxAgentManageRangeEmployeeList; + } + List taxAgentIds = allTaxAgents.stream().map(TaxAgentPO::getId).collect(Collectors.toList()); + taxAgentManageRangeEmployeeList.addAll(getTaxAgentEmp(allTaxAgents, taxAgentIds)); + return taxAgentManageRangeEmployeeList; + } + + @Override + public List listAllTaxAgentAndEmployeeTree() { + List taxAgentManageRangeEmployeeList = Lists.newArrayList(); + // 所有个税扣缴义务人 + List allTaxAgents = listAll(); + if (CollectionUtils.isEmpty(allTaxAgents)) { + return taxAgentManageRangeEmployeeList; + } + + List taxAgentIds = allTaxAgents.stream().map(TaxAgentPO::getId).collect(Collectors.toList()); + + // 1.判断自己是否是管理员, 如果是管理员,就是能够操作所属个税扣缴义务人下的所有人的数据 + List taxAgentAdminList = getTaxAgentAdminService(user).listByTaxAgentIdsAndEmployeeId(taxAgentIds, (long) user.getUID()); + // 是管理员的列表 + List adminTaxAgentIds = taxAgentAdminList.stream().map(TaxAgentAdminPO::getTaxAgentId).collect(Collectors.toList()); + taxAgentManageRangeEmployeeList.addAll(getTaxAgentEmp(allTaxAgents, adminTaxAgentIds)); + taxAgentManageRangeEmployeeList = taxAgentManageRangeEmployeeList.stream().distinct().collect(Collectors.toList()); + return taxAgentManageRangeEmployeeList; + } + + + /** + * 获取个税口角义务人的关联人员 + * + * @param allTaxAgents + * @param taxAgentIds + * @return + */ + private List getTaxAgentEmp(List allTaxAgents, List taxAgentIds) { + List taxAgentManageRangeEmployeeList = Lists.newArrayList(); + List taxAgentEmps = getTaxAgentEmpService(user).listByTaxAgentIds(taxAgentIds, UseEmployeeTypeEnum.ALL); + taxAgentIds.forEach(e -> { + Optional optionalTaxAgent = allTaxAgents.stream().filter(t -> t.getId().equals(e)).findFirst(); + String taxAgentName = (optionalTaxAgent.isPresent() ? optionalTaxAgent.get().getName() : ""); + List taxAgentEmployees = taxAgentEmps.stream().filter(f -> f.getTaxAgentId().equals(e)).map(m -> { + TaxAgentManageRangeEmployeeDTO.TaxAgentEmployee taxAgentEmployee = new TaxAgentManageRangeEmployeeDTO.TaxAgentEmployee(); + taxAgentEmployee.setEmployeeId(m.getEmployeeId()); + taxAgentEmployee.setUsername(m.getEmployeeName()); + return taxAgentEmployee; + }).collect(Collectors.toList()); + taxAgentManageRangeEmployeeList.add( + TaxAgentManageRangeEmployeeDTO.builder() + .taxAgentId(e) + .taxAgentName(taxAgentName) + .employeeList(taxAgentEmployees) + .build() + ); + }); + return taxAgentManageRangeEmployeeList; + } + + @Override + public List listTaxAgentAndEmployee(SalaryEmployeeStatusEnum employeeStatus, Long employeeId) { + List taxAgentEmployeeList = Lists.newArrayList(); + + List taxAgentManageRangeEmployeeList = listTaxAgentAndEmployeeTree(employeeStatus, employeeId); + taxAgentManageRangeEmployeeList.forEach(m -> { + List employeeList = m.getEmployeeList(); + if (CollectionUtils.isEmpty(employeeList)) { + taxAgentEmployeeList.add(TaxAgentEmployeeDTO.builder() + .taxAgentId(m.getTaxAgentId()) + .taxAgentName(m.getTaxAgentName()) + .employeeId(null) + .username(null) + .build()); + } else { + employeeList.forEach(f -> taxAgentEmployeeList.add(TaxAgentEmployeeDTO.builder() + .taxAgentId(m.getTaxAgentId()) + .taxAgentName(m.getTaxAgentName()) + .employeeId(f.getEmployeeId()) + .username(f.getUsername()) + .build())); + } + }); + + return taxAgentEmployeeList; + } + + + @Override + public Collection listEmployeeIdsInTaxAgent(Long taxAgentId) { + List taxAgentEmpPOS = getTaxAgentEmpService(user).listByTaxAgentIds(Collections.singletonList(taxAgentId), UseEmployeeTypeEnum.ALL); + + return SalaryEntityUtil.properties(taxAgentEmpPOS, TaxAgentEmpPO::getEmployeeId); + } + + @Override + public List getConfig() { + List taxAgentPOS = getTaxAgentMapper().listAll(); + return taxAgentPOS.stream() + .map(taxAgentPO -> { + List sobConfigs = getSalarySobService(user).getConfig(taxAgentPO.getId()); + return TaxAgentConfig.builder().taxAgent(taxAgentPO).salarySobConfigs(sobConfigs).build(); + }) + .collect(Collectors.toList()); + } + + @Override + public List parseConfig(List configs) { + List results = new ArrayList<>(); + + List taxAgentPOS = listAll(); + Map agentPOMap = SalaryEntityUtil.convert2Map(taxAgentPOS, TaxAgentPO::getName); + + Optional.ofNullable(configs) + .orElse(new ArrayList<>()) + .forEach(config -> { + TaxAgentPO taxAgent = config.getTaxAgent(); + String name = taxAgent.getName(); + + UploadConfigResponse.Result taxResult = UploadConfigResponse.Result.builder() + .message(String.format("扣缴义务人%s加载完毕", name)) + .success(new ArrayList<>()) + .warning(new ArrayList<>()) + .error(new ArrayList<>()) + .build(); + + if (agentPOMap.containsKey(name)) { + //存在扣缴义务人 + taxAgent = agentPOMap.get(name); + } else { + //新增扣缴义务人 + taxAgent.setCreator((long) user.getUID()); + getTaxAgentMapper().insertIgnoreNull(taxAgent); + } + taxResult.getSuccess().add(String.format("%s加载成功", name)); + results.add(taxResult); + + List sobResults = getSalarySobService(user).parseConfig(taxAgent.getId(), config.getSalarySobConfigs()); + results.addAll(sobResults); + + }); + return results; + } + + +} diff --git a/src/com/engine/salary/service/impl/TaxDeclarationDetailServiceImpl.java b/src/com/engine/salary/service/impl/TaxDeclarationDetailServiceImpl.java new file mode 100644 index 000000000..d0937e392 --- /dev/null +++ b/src/com/engine/salary/service/impl/TaxDeclarationDetailServiceImpl.java @@ -0,0 +1,257 @@ +package com.engine.salary.service.impl; + +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.encrypt.EncryptUtil; +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.taxdeclaration.bo.TaxDeclarationBO; +import com.engine.salary.entity.taxdeclaration.bo.TaxDeclarationDetailBO; +import com.engine.salary.entity.taxdeclaration.dto.*; +import com.engine.salary.entity.taxdeclaration.param.TaxDeclarationDetailListQueryParam; +import com.engine.salary.entity.taxdeclaration.po.TaxDeclarationDetailPO; +import com.engine.salary.entity.taxdeclaration.po.TaxDeclarationPO; +import com.engine.salary.enums.salaryaccounting.EmployeeTypeEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.mapper.taxdeclaration.TaxDeclarationDetailMapper; +import com.engine.salary.service.SalaryEmployeeService; +import com.engine.salary.service.TaxAgentService; +import com.engine.salary.service.TaxDeclarationDetailService; +import com.engine.salary.service.TaxDeclarationService; +import com.engine.salary.sys.entity.vo.OrderRuleVO; +import com.engine.salary.sys.service.SalarySysConfService; +import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.db.MapperProxyFactory; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.util.page.SalaryPageUtil; +import com.google.common.collect.Lists; +import org.apache.commons.collections4.CollectionUtils; +import weaver.hrm.User; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * 个税申报表明细 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class TaxDeclarationDetailServiceImpl extends Service implements TaxDeclarationDetailService { + + private EncryptUtil encryptUtil = new EncryptUtil(); + + private TaxDeclarationDetailMapper getTaxDeclarationDetailMapper() { + return MapperProxyFactory.getProxy(TaxDeclarationDetailMapper.class); + } + + private SalaryEmployeeService getSalaryEmployeeService() { + return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user); + } + + private TaxDeclarationService getTaxDeclarationService(User user) { + return ServiceUtil.getService(TaxDeclarationServiceImpl.class, user); + } + + private TaxAgentService getTaxAgentService(User user) { + return ServiceUtil.getService(TaxAgentServiceImpl.class, user); + } + + private SalaryEmployeeService getSalaryEmployeeService(User user) { + return (SalaryEmployeeService) ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user); + } + + private SalarySysConfService getSalarySysConfService(User user) { + return ServiceUtil.getService(SalarySysConfServiceImpl.class, user); + } + + @Override + public List listByTaxDeclarationIdAndEmployeeIds(Long taxDeclarationId, Collection employeeIds) { + if (CollectionUtils.isEmpty(employeeIds)) { + return Collections.emptyList(); + } + + return getTaxDeclarationDetailMapper().listByTaxDeclarationIdAndEmployeeIds(taxDeclarationId, employeeIds); + } + + @Override + public PageInfo listPage4EmployeeIdByParam(TaxDeclarationDetailListQueryParam queryParam) { + //排序配置 + OrderRuleVO orderRule = getSalarySysConfService(user).orderRule(); + queryParam.setOrderRule(orderRule); + +// SalaryPageUtil.start(queryParam.getCurrent(), queryParam.getPageSize()); + List taxDeclarationEmployeeDTOS = getTaxDeclarationDetailMapper().listPage4EmployeeId(queryParam); + taxDeclarationEmployeeDTOS = taxDeclarationEmployeeDTOS.stream().filter(SalaryEntityUtil.distinctByKey(TaxDeclarationEmployeeDTO::getEmployeeId)).collect(Collectors.toList()); + + List list = SalaryPageUtil.subList(queryParam.getCurrent(), queryParam.getPageSize(), taxDeclarationEmployeeDTOS); + PageInfo pageInfo = new PageInfo<>(list, TaxDeclarationEmployeeDTO.class); + pageInfo.setPageNum(queryParam.getCurrent()); + pageInfo.setPageSize(queryParam.getPageSize()); + pageInfo.setTotal(taxDeclarationEmployeeDTOS.size()); + return pageInfo; + } + + @Override + public PageInfo listDtoPageByParam(TaxDeclarationDetailListQueryParam queryParam) { + // 查询个税申报表明细的人员 + List employeeIdPage = getTaxDeclarationDetailMapper().listEmployeeId(queryParam.getTaxDeclarationId()); + PageInfo dtoPage = new PageInfo(TaxDeclarationDetailListDTO.class); + dtoPage.setPageNum(queryParam.getCurrent()); + dtoPage.setPageSize(queryParam.getPageSize()); + if (null == employeeIdPage) { + return dtoPage; + } + if (CollectionUtils.isNotEmpty(employeeIdPage)) { + // 查询个税申报表明细 + List taxDeclarationDetailPOS = listByTaxDeclarationIdAndEmployeeIds(queryParam.getTaxDeclarationId(), employeeIdPage); + // 查询人员 + List simpleEmployees = getSalaryEmployeeService().getEmployeeByIdsAll(employeeIdPage); + // List simpleEmployees = hrmCommonEmployeeService.getEmployeeByIds(employeeIdPage.getRecords(), tenantKey); + // 转换成列表dto + TaxDeclarationBO.buildDetailListDTO(queryParam.getTaxDeclarationId(), dtoPage, taxDeclarationDetailPOS, simpleEmployees); + } + return dtoPage; + } + + @Override + public PageInfo listDtoPageByParam4Labor(TaxDeclarationDetailListQueryParam queryParam) { + + // 查询个税申报主表 + TaxDeclarationPO taxDeclarationPO = getTaxDeclarationService(user).getById(queryParam.getTaxDeclarationId()); + // 判断是否有权限查看 + boolean canSee = getTaxDeclarationService(user).checkByAuthority(taxDeclarationPO, (long) user.getUID()); + if (!canSee) { + throw new SalaryRunTimeException("对不起,您暂时没有权限查看"); + } + // 查询个税申报表明细的人员 + PageInfo employeeIdPage = listPage4EmployeeIdByParam(queryParam); + PageInfo dtoPage = new PageInfo<>(TaxDeclarationLaborListDTO.class); + dtoPage.setPageSize(employeeIdPage.getPageSize()); + dtoPage.setPageNum(employeeIdPage.getPageNum()); + dtoPage.setTotal(employeeIdPage.getTotal()); + List list = employeeIdPage.getList(); + if (CollectionUtils.isNotEmpty(list)) { + // 转换成列表dto + List taxDeclarationLaborListDTOS = listDto4Labor(queryParam.getTaxDeclarationId(), list); + dtoPage.setList(taxDeclarationLaborListDTOS); + } + return dtoPage; + } + + @Override + public PageInfo listDtoPageByParam4Annual(TaxDeclarationDetailListQueryParam queryParam) { + // 查询个税申报主表 + TaxDeclarationPO taxDeclarationPO = getTaxDeclarationService(user).getById(queryParam.getTaxDeclarationId()); + // 判断是否有权限查看 + boolean canSee = getTaxDeclarationService(user).checkByAuthority(taxDeclarationPO, (long) user.getUID()); + if (!canSee) { + throw new SalaryRunTimeException("对不起,您暂时没有权限查看"); + } + // 查询个税申报表明细的人员 + PageInfo employeeIdPage = listPage4EmployeeIdByParam(queryParam); + PageInfo dtoPage = new PageInfo<>(TaxDeclarationAnnualListDTO.class); + dtoPage.setPageSize(employeeIdPage.getPageSize()); + dtoPage.setPageNum(employeeIdPage.getPageNum()); + dtoPage.setTotal(employeeIdPage.getTotal()); + List list = employeeIdPage.getList(); + if (CollectionUtils.isNotEmpty(list)) { + // 转换成列表dto + List taxDeclarationLaborListDTOS = listDto4Annual(queryParam.getTaxDeclarationId(), list); + dtoPage.setList(taxDeclarationLaborListDTOS); + } + return dtoPage; + } + + @Override + public List listDto4Labor(Long taxDeclarationId, List taxDeclarationEmployees) { + long employeeId = (long) user.getUID(); + // 查询个税申报主表 + TaxDeclarationPO taxDeclarationPO = getTaxDeclarationService(user).getById(taxDeclarationId); + // 判断是否有权限查看 + boolean canSee = getTaxDeclarationService(user).checkByAuthority(taxDeclarationPO, employeeId); + if (!canSee) { + throw new SalaryRunTimeException("对不起,您暂时没有权限查看"); + } + // 查询个税申报表明细 + List employeeIds = taxDeclarationEmployees.stream().map(TaxDeclarationEmployeeDTO::getEmployeeId).collect(Collectors.toList()); + List taxDeclarationDetailPOS = listByTaxDeclarationIdAndEmployeeIds(taxDeclarationId, employeeIds); + // 查询人员信息 + List simpleEmployees = getSalaryEmployeeService().getEmployeeByIdsAll(employeeIds); + // 转换成列表dto + return TaxDeclarationDetailBO.convert2ListDTO4Labor(taxDeclarationDetailPOS, taxDeclarationEmployees, simpleEmployees); + } + + public List listDto4Annual(Long taxDeclarationId, List taxDeclarationEmployees) { + long employeeId = (long) user.getUID(); + // 查询个税申报主表 + TaxDeclarationPO taxDeclarationPO = getTaxDeclarationService(user).getById(taxDeclarationId); + // 判断是否有权限查看 + boolean canSee = getTaxDeclarationService(user).checkByAuthority(taxDeclarationPO, employeeId); + if (!canSee) { + throw new SalaryRunTimeException("对不起,您暂时没有权限查看"); + } + // 查询个税申报表明细 + List employeeIds = taxDeclarationEmployees.stream().map(TaxDeclarationEmployeeDTO::getEmployeeId).collect(Collectors.toList()); + List taxDeclarationDetailPOS = listByTaxDeclarationIdAndEmployeeIds(taxDeclarationId, employeeIds); + // 查询人员信息 + List simpleEmployees = getSalaryEmployeeService().getEmployeeByIdsAll(employeeIds); + // 转换成列表dto + return TaxDeclarationDetailBO.convert2ListDTO4Annual(taxDeclarationDetailPOS, taxDeclarationEmployees, simpleEmployees); + } + + + @Override + public PageInfo listDtoPageByParam4Wage(TaxDeclarationDetailListQueryParam queryParam) { + + // 查询个税申报表明细的人员 + PageInfo employeeIdPage = listPage4EmployeeIdByParam(queryParam); + + PageInfo dtoPage = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), TaxDeclarationWageListDTO.class); + dtoPage.setTotal(employeeIdPage.getTotal()); + if (CollectionUtils.isNotEmpty(employeeIdPage.getList())) { + List list = employeeIdPage.getList(); + // 查询个税申报表明细 + Set employeeIds = SalaryEntityUtil.properties(list, TaxDeclarationEmployeeDTO::getEmployeeId); + List taxDeclarationDetailPOS = listByTaxDeclarationIdAndEmployeeIds(queryParam.getTaxDeclarationId(), + employeeIds); + encryptUtil.decryptList(taxDeclarationDetailPOS, TaxDeclarationDetailPO.class); + // 查询人员信息 + List simpleEmployeeIds = list.stream() + .filter(taxDeclarationEmployeeDTO -> Objects.equals(taxDeclarationEmployeeDTO.getEmployeeType(), EmployeeTypeEnum.ORGANIZATION.getValue())) + .map(TaxDeclarationEmployeeDTO::getEmployeeId) + .collect(Collectors.toList()); + List simpleEmployees = getSalaryEmployeeService(user).getEmployeeByIds(simpleEmployeeIds); + List taxDeclarationWageListDTOS = TaxDeclarationDetailBO.convert2ListDTO4Wage(taxDeclarationDetailPOS, + employeeIdPage.getList(), simpleEmployees); + dtoPage.setList(taxDeclarationWageListDTOS); + } + return dtoPage; + + } + + @Override + public void batchSave(Collection taxDeclarationDetailPOS) { + if (CollectionUtils.isNotEmpty(taxDeclarationDetailPOS)) { + taxDeclarationDetailPOS = encryptUtil.encryptList(new ArrayList<>(taxDeclarationDetailPOS), TaxDeclarationDetailPO.class); + List> partition = Lists.partition((List) taxDeclarationDetailPOS, 100); + partition.forEach(getTaxDeclarationDetailMapper()::batchInsert); + } + } + + public List listByTaxDeclarationIdAndEmployeeIds(Long taxDeclarationId, List employeeIds) { + if (CollectionUtils.isEmpty(employeeIds)) { + return Collections.emptyList(); + } + + List taxDeclarationDetailPOS = getTaxDeclarationDetailMapper().listByTaxDeclarationIdAndEmployeeIds(taxDeclarationId, employeeIds); + return encryptUtil.decryptList(taxDeclarationDetailPOS, TaxDeclarationDetailPO.class); + } + + @Override + public void deleteByTaxDeclarationIds(Collection taxDeclarationIds) { + getTaxDeclarationDetailMapper().deleteByTaxDeclarationIds(taxDeclarationIds); + } +} diff --git a/src/com/engine/salary/service/impl/TaxDeclarationExcelServiceImpl.java b/src/com/engine/salary/service/impl/TaxDeclarationExcelServiceImpl.java new file mode 100644 index 000000000..16b4c3006 --- /dev/null +++ b/src/com/engine/salary/service/impl/TaxDeclarationExcelServiceImpl.java @@ -0,0 +1,192 @@ +package com.engine.salary.service.impl; + +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.config.SalaryElogConfig; +import com.engine.hrmelog.entity.dto.LoggerContext; +import com.engine.salary.constant.TaxDeclarationDataIndexConstant; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationAnnualListDTO; +import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationLaborListDTO; +import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationWageListDTO; +import com.engine.salary.entity.taxdeclaration.param.TaxDeclarationDetailListQueryParam; +import com.engine.salary.entity.taxdeclaration.po.TaxDeclarationPO; +import com.engine.salary.enums.OperateTypeEnum; +import com.engine.salary.enums.salarysob.IncomeCategoryEnum; +import com.engine.salary.mapper.taxdeclaration.TaxDeclarationDetailMapper; +import com.engine.salary.service.TaxAgentService; +import com.engine.salary.service.TaxDeclarationDetailService; +import com.engine.salary.service.TaxDeclarationExcelService; +import com.engine.salary.service.TaxDeclarationService; +import com.engine.salary.util.JsonUtil; +import com.engine.salary.util.SalaryDateUtil; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.db.MapperProxyFactory; +import com.engine.salary.util.excel.ExcelUtil; +import com.engine.salary.util.page.PageInfo; +import com.google.common.collect.Lists; +import lombok.extern.slf4j.Slf4j; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import weaver.hrm.User; + +import java.math.BigDecimal; +import java.util.*; + +/** + * 个税申报表导出 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Slf4j +public class TaxDeclarationExcelServiceImpl extends Service implements TaxDeclarationExcelService { + + private TaxDeclarationDetailService getTaxDeclarationDetailService(User user) { + return ServiceUtil.getService(TaxDeclarationDetailServiceImpl.class, user); + } + private TaxDeclarationDetailMapper getTaxDeclarationDetailMapper() { + return MapperProxyFactory.getProxy(TaxDeclarationDetailMapper.class); + } + private TaxDeclarationService getTaxDeclarationService(User user) { + return ServiceUtil.getService(TaxDeclarationServiceImpl.class, user); + } + + private TaxAgentService getTaxAgentService(User user) { + return ServiceUtil.getService(TaxAgentServiceImpl.class, user); + } + + + + @Override + public XSSFWorkbook exportTaxDeclaration(Long taxDeclarationId) { + // 1.工作簿名称 + String sheetName = SalaryI18nUtil.getI18nLabel(85368, "个税申报表"); + + + TaxDeclarationPO taxDeclarationPO = getTaxDeclarationService(user).getById(taxDeclarationId); + // 查询当前个税申报表一共有多少人员 + int count = getTaxDeclarationDetailMapper().countEmployeeId(taxDeclarationId); + // 以1000个人员一页,一共有多少页 + int totalPages = (count % 1000 == 0) ? (count / 1000) : (count / 1000 + 1); //总页数 + // excel导出的数据 + List> rows = Lists.newArrayListWithExpectedSize(count); + List headerList = Lists.newArrayList(); + List dataIndexList = Lists.newArrayList(); + List NumberCode = Arrays.asList(TaxDeclarationDataIndexConstant.INCOME, TaxDeclarationDataIndexConstant.TAX_FREE_INCOME, + TaxDeclarationDataIndexConstant.ENDOWMENT_INSURANCE, TaxDeclarationDataIndexConstant.MEDICAL_INSURANCE, TaxDeclarationDataIndexConstant.UNEMPLOYMENT_INSURANCE, + TaxDeclarationDataIndexConstant.HOUSING_PROVIDENT_FUND, TaxDeclarationDataIndexConstant.ADD_UP_CHILD_EDUCATION, TaxDeclarationDataIndexConstant.ADD_UP_CONTINUING_EDUCATION, + TaxDeclarationDataIndexConstant.ADD_UP_HOUSING_LOAN_INTEREST, TaxDeclarationDataIndexConstant.ADD_UP_HOUSING_RENT, TaxDeclarationDataIndexConstant.ADD_UP_SUPPORT_ELDERLY, + TaxDeclarationDataIndexConstant.ADD_UP_ILLNESS_MEDICAL, TaxDeclarationDataIndexConstant.ADD_UP_INFANT_CARE, TaxDeclarationDataIndexConstant.ADD_UP_PRIVATE_PENSION, + TaxDeclarationDataIndexConstant.ANNUITY, TaxDeclarationDataIndexConstant.COMMERCIAL_HEALTH_INSURANCE, TaxDeclarationDataIndexConstant.TAX_DEFERRED_ENDOWMENT_INSURANCE, + TaxDeclarationDataIndexConstant.OTHER, TaxDeclarationDataIndexConstant.ALLOWED_DONATION, TaxDeclarationDataIndexConstant.TAX_DEDUCTION, + TaxDeclarationDataIndexConstant.LABOR_INCOME, TaxDeclarationDataIndexConstant.LABOR_TAX_FREE_INCOME, TaxDeclarationDataIndexConstant.ANNUAL_INCOME, + TaxDeclarationDataIndexConstant.ANNUAL_TAX_FREE_INCOME, TaxDeclarationDataIndexConstant.ANNUAL_OTHER, TaxDeclarationDataIndexConstant.ANNUAL_DONATE_TAX, + TaxDeclarationDataIndexConstant.ANNUAL_TAX_SAVINGS); + if (Objects.equals(taxDeclarationPO.getIncomeCategory(), IncomeCategoryEnum.WAGES_AND_SALARIES.getValue())) { + // 解析表头 + ExcelUtil.parseHeader(TaxDeclarationWageListDTO.class, headerList, dataIndexList); + rows.add(headerList); + for (int i = 0; i < totalPages; i++) { + TaxDeclarationDetailListQueryParam queryParam = new TaxDeclarationDetailListQueryParam(); + queryParam.setTaxDeclarationId(taxDeclarationId); + queryParam.setCurrent(i+1); + queryParam.setPageSize(1000); + PageInfo dtoPage = getTaxDeclarationDetailService(user).listDtoPageByParam4Wage(queryParam); + List list = dtoPage.getList(); + for (TaxDeclarationWageListDTO taxDeclarationWageListDTO : list) { + List row = Lists.newArrayListWithExpectedSize(dataIndexList.size()); + Map map = JsonUtil.parseMap(taxDeclarationWageListDTO, Object.class); + for (String dataIndex : dataIndexList) { + try { + if (NumberCode.contains(dataIndex)) { + row.add(new BigDecimal(map.get(dataIndex).toString())); + } else { + row.add(map.get(dataIndex)); + } + } catch (Exception e) { + row.add(map.get(dataIndex)); + } + } + rows.add(row); + } + } + } + if (Objects.equals(taxDeclarationPO.getIncomeCategory(), IncomeCategoryEnum.REMUNERATION_FOR_LABOR.getValue())) { + // 解析表头 + ExcelUtil.parseHeader(TaxDeclarationLaborListDTO.class, headerList, dataIndexList); + rows.add(headerList); + for (int i = 0; i < totalPages; i++) { + TaxDeclarationDetailListQueryParam queryParam = new TaxDeclarationDetailListQueryParam(); + queryParam.setTaxDeclarationId(taxDeclarationId); + queryParam.setCurrent(i); + queryParam.setPageSize(1000); + PageInfo dtoPage = getTaxDeclarationDetailService(user).listDtoPageByParam4Labor(queryParam); + List list = dtoPage.getList(); + for (TaxDeclarationLaborListDTO taxDeclarationLaborListDTO : list) { + List row = Lists.newArrayListWithExpectedSize(dataIndexList.size()); + Map map = JsonUtil.parseMap(taxDeclarationLaborListDTO, Object.class); + for (String dataIndex : dataIndexList) { + try { + if (NumberCode.contains(dataIndex)) { + row.add(new BigDecimal(map.get(dataIndex).toString())); + } else { + row.add(map.get(dataIndex)); + } + } catch (Exception e) { + row.add(map.get(dataIndex)); + } + } + rows.add(row); + } + } + } + + if (Objects.equals(taxDeclarationPO.getIncomeCategory(), IncomeCategoryEnum.ONETIME_ANNUAL_BONUS.getValue())) { + // 解析表头 + ExcelUtil.parseHeader(TaxDeclarationAnnualListDTO.class, headerList, dataIndexList); + rows.add(headerList); + for (int i = 0; i < totalPages; i++) { + TaxDeclarationDetailListQueryParam queryParam = new TaxDeclarationDetailListQueryParam(); + queryParam.setTaxDeclarationId(taxDeclarationId); + queryParam.setCurrent(i); + queryParam.setPageSize(1000); + PageInfo dtoPage = getTaxDeclarationDetailService(user).listDtoPageByParam4Annual(queryParam); + List list = dtoPage.getList(); + for (TaxDeclarationAnnualListDTO taxDeclarationLaborListDTO : list) { + List row = Lists.newArrayListWithExpectedSize(dataIndexList.size()); + Map map = JsonUtil.parseMap(taxDeclarationLaborListDTO, Object.class); + for (String dataIndex : dataIndexList) { + try { + if (NumberCode.contains(dataIndex)) { + row.add(new BigDecimal(map.get(dataIndex).toString())); + } else { + row.add(map.get(dataIndex)); + } + } catch (Exception e) { + row.add(map.get(dataIndex)); + } + } + rows.add(row); + } + } + } + + // 查询个税扣缴义务人名称 + String bar = "_"; + TaxAgentPO taxAgentPO = getTaxAgentService(user).getById(taxDeclarationPO.getTaxAgentId()); + String targetName = SalaryDateUtil.getFormatYearMonth(taxDeclarationPO.getSalaryMonth()) + bar + taxAgentPO.getName() + bar + IncomeCategoryEnum.parseByValue(taxDeclarationPO.getIncomeCategory()).getDefaultLabel(); + // 记录日志 + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(taxDeclarationId.toString()); + loggerContext.setTargetName(targetName); + loggerContext.setOperateType(OperateTypeEnum.EXCEL_EXPORT.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel( 0, "导出个税申报表")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel( 0, "导出个税申报表")); + SalaryElogConfig.taxDeclarationLoggerTemplate.write(loggerContext); + return ExcelUtil.genWorkbookV2(rows, sheetName); + } + +} diff --git a/src/com/engine/salary/service/impl/TaxDeclarationServiceImpl.java b/src/com/engine/salary/service/impl/TaxDeclarationServiceImpl.java new file mode 100644 index 000000000..62a3df5a8 --- /dev/null +++ b/src/com/engine/salary/service/impl/TaxDeclarationServiceImpl.java @@ -0,0 +1,399 @@ +package com.engine.salary.service.impl; + +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.hrmelog.entity.dto.LoggerContext; +import com.engine.salary.common.LocalDateRange; +import com.engine.salary.config.SalaryElogConfig; +import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO; +import com.engine.salary.entity.salaryacct.po.SalaryAcctResultPO; +import com.engine.salary.entity.salaryitem.po.SalaryItemPO; +import com.engine.salary.entity.salarysob.po.SalarySobPO; +import com.engine.salary.entity.taxagent.param.TaxAgentQueryParam; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import com.engine.salary.entity.taxdeclaration.bo.TaxDeclarationBO; +import com.engine.salary.entity.taxdeclaration.param.TaxDeclarationListQueryParam; +import com.engine.salary.entity.taxdeclaration.param.TaxDeclarationSaveParam; +import com.engine.salary.entity.taxdeclaration.po.TaxDeclarationPO; +import com.engine.salary.enums.OperateTypeEnum; +import com.engine.salary.enums.auth.AuthFilterTypeEnum; +import com.engine.salary.enums.salaryaccounting.SalaryAcctRecordStatusEnum; +import com.engine.salary.enums.salarysob.IncomeCategoryEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.mapper.datacollection.AddUpSituationMapper; +import com.engine.salary.mapper.salaryacct.SalaryAcctRecordMapper; +import com.engine.salary.mapper.taxdeclaration.TaxDeclarationMapper; +import com.engine.salary.service.*; +import com.engine.salary.service.auth.AuthService; +import com.engine.salary.service.auth.AuthServiceImpl; +import com.engine.salary.sys.service.SalarySysConfService; +import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl; +import com.engine.salary.util.SalaryDateUtil; +import com.engine.salary.util.SalaryEntityUtil; +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.page.SalaryPageUtil; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import weaver.general.BaseBean; +import weaver.hrm.User; + +import java.time.YearMonth; +import java.util.*; +import java.util.stream.Collectors; + +import static com.engine.salary.sys.constant.SalarySysConstant.TAX_DECLARATION_DATE_TYPE; + +@Slf4j +public class TaxDeclarationServiceImpl extends Service implements TaxDeclarationService { + + private final Boolean isLog = "true".equals(new BaseBean().getPropValue("hrmSalary", "log")); + + private TaxDeclarationMapper getTaxDeclarationMapper() { + return MapperProxyFactory.getProxy(TaxDeclarationMapper.class); + } + + private SalaryAcctRecordMapper getSalaryAcctRecordMapper() { + return MapperProxyFactory.getProxy(SalaryAcctRecordMapper.class); + } + + private AddUpSituationMapper getAddUpSituationMapper() { + return MapperProxyFactory.getProxy(AddUpSituationMapper.class); + } + + private TaxDeclarationDetailService getTaxDeclarationDetailService(User user) { + return ServiceUtil.getService(TaxDeclarationDetailServiceImpl.class, user); + } + + private AddUpSituationService getAddUpSituationService(User user) { + return ServiceUtil.getService(AddUpSituationServiceImpl.class, user); + } + + private TaxAgentService getTaxAgentService(User user) { + return ServiceUtil.getService(TaxAgentServiceImpl.class, user); + } + + private SalarySobService getSalarySobService(User user) { + return ServiceUtil.getService(SalarySobServiceImpl.class, user); + } + + private SalaryAcctResultService getSalaryAcctResultService(User user) { + return ServiceUtil.getService(SalaryAcctResultServiceImpl.class, user); + } + + private SalaryItemService getSalaryItemService(User user) { + return ServiceUtil.getService(SalaryItemServiceImpl.class, user); + } + + private SalaryAcctRecordService getSalaryAcctRecordService(User user) { + return ServiceUtil.getService(SalaryAcctRecordServiceImpl.class, user); + } + + private SalaryAcctEmployeeService getSalaryAcctEmployeeService(User user) { + return ServiceUtil.getService(SalaryAcctEmployeeServiceImpl.class, user); + } + + public AuthService getAuthService(User user) { + return ServiceUtil.getService(AuthServiceImpl.class, user); + } + + private SalarySysConfService getSalarySysConfService(User user) { + return ServiceUtil.getService(SalarySysConfServiceImpl.class, user); + } + + //是否根据税款所属期进行申报 + private final boolean isTaxDeclarationByTaxCycle = "1".equals(getSalarySysConfService(user).getValueByCode(TAX_DECLARATION_DATE_TYPE)); + + @Override + public List listByTaxCycleAndTaxAgentIds(YearMonth taxCycle, Collection taxAgentIds) { + if (Objects.isNull(taxCycle) || CollectionUtils.isEmpty(taxAgentIds)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(84026, "参数错误")); + } + TaxDeclarationPO po = TaxDeclarationPO.builder().taxCycle(SalaryDateUtil.toDate(taxCycle, 1)).taxAgentIds(taxAgentIds).build(); + List taxDeclarationPOS = getTaxDeclarationMapper().listSome(po); + return taxDeclarationPOS; + } + + @Override + public PageInfo listPageByParam(TaxDeclarationListQueryParam queryParam) { + // 分页参数 + TaxDeclarationPO po = TaxDeclarationPO.builder().build(); + LocalDateRange localDateRange = new LocalDateRange(); + if (Objects.nonNull(queryParam.getFromSalaryMonth())) { + localDateRange.setFromDate(SalaryDateUtil.localDateToDate(queryParam.getFromSalaryMonth().atDay(1))); + } + if (Objects.nonNull(queryParam.getEndSalaryMonth())) { + localDateRange.setEndDate(SalaryDateUtil.localDateToDate(queryParam.getEndSalaryMonth().atEndOfMonth())); + } + po.setSalaryMonths(localDateRange); + + // 查询个税申报表 + List taxDeclarationPOS = getTaxDeclarationMapper().listSome(po); + + taxDeclarationPOS = getAuthService(user).auth(taxDeclarationPOS, AuthFilterTypeEnum.DATA_OPT, TaxDeclarationPO.class); + + return SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), + taxDeclarationPOS, TaxDeclarationPO.class); + + } + + //根据id查询taxAgents + @Override + public List countByTaxDeclarationId(Collection taxAgentIds) { + if (CollectionUtils.isEmpty(taxAgentIds)) { + return Collections.emptyList(); + } + return getTaxAgentService(user).listByIds(taxAgentIds); + } + + //根据id获取TaxDeclaration + @Override + public TaxDeclarationPO getById(Long id) { + return getTaxDeclarationMapper().getById(id); + } + + @Override + public void save(TaxDeclarationSaveParam saveParam) { + Long taxAgentId = saveParam.getTaxAgentId(); + + if (taxAgentId == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "请选择要申报的扣缴义务人!")); + } + + // 个税扣缴义务人id + Set taxAgentIds = Collections.singleton(taxAgentId); + + + // 查询个税扣缴义务人 + List taxAgentPOS = getTaxAgentService(user).listByIds(taxAgentIds); + Map taxAgentNameMap = SalaryEntityUtil.convert2Map(taxAgentPOS, TaxAgentPO::getId, TaxAgentPO::getName); + List salaryAcctRecordPOS; + Date taxCycle; + //根据税款所属期申报 + if (isTaxDeclarationByTaxCycle) { + taxCycle = saveParam.getTaxCycle(); + if (Objects.isNull(taxCycle)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(84026, "税款所属期参数错误")); + } + + // 查询税款所属期个税扣缴义务人已经生成过的个税申报表 + List taxDeclarationPOS = listByTaxCycle(TaxDeclarationPO.builder().taxCycle(taxCycle).taxAgentIds(taxAgentNameMap.keySet()).build()); + // 已经生成过个税申报表,不允许再次生成个税申报表 + if (CollectionUtils.isNotEmpty(taxDeclarationPOS)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(107986, "{0}在{1}已经生成过个税申报表,不允许再次生成") + .replace("{0}", taxAgentNameMap.get(taxDeclarationPOS.get(0).getTaxAgentId())) + .replace("{1}", SalaryDateUtil.getFormatYearMonth(taxCycle))); + } + // 查询薪资所属月的薪资核算记录 + salaryAcctRecordPOS = listByTaxCycle(SalaryAcctRecordPO.builder().taxCycle(taxCycle).build()); + + } else { + //根据薪资所属月申报 + // 薪资所属月的日期范围 + LocalDateRange salaryMonthDateRange = SalaryDateUtil.localDate2Range(SalaryDateUtil.localDateToDate(saveParam.getSalaryMonth().atDay(1))); + if (Objects.isNull(salaryMonthDateRange)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(84026, "薪资所属月参数错误")); + } + + // 查询薪资所属月个税扣缴义务人已经生成过的个税申报表 + List taxDeclarationPOS = listBySalaryMonthTax(TaxDeclarationPO.builder().salaryMonths(salaryMonthDateRange).taxAgentIds(taxAgentNameMap.keySet()).build()); + // 已经生成过个税申报表,不允许再次生成个税申报表 + if (CollectionUtils.isNotEmpty(taxDeclarationPOS)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(107986, "{0}在{1}已经生成过个税申报表,不允许再次生成") + .replace("{0}", taxAgentNameMap.get(taxDeclarationPOS.get(0).getTaxAgentId())) + .replace("{1}", SalaryDateUtil.getFormatYearMonth(saveParam.getSalaryMonth()))); + } + // 查询薪资所属月的薪资核算记录 + salaryAcctRecordPOS = listBySalaryMonth(SalaryAcctRecordPO.builder().salaryMonths(salaryMonthDateRange).taxAgentId(taxAgentId).build()); + + // 无薪资核算记录,不允许生成个税申报表 + if (CollectionUtils.isEmpty(salaryAcctRecordPOS)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98874, "{0}无申报数据").replace("{0}", saveParam.getSalaryMonth().toString())); + } + + // 如果当前薪资所属月下存在不同的税款所属期,属于异常业务场景,不允许生成个税申报表 + taxCycle = salaryAcctRecordPOS.get(0).getTaxCycle(); + boolean differentTaxCycle = salaryAcctRecordPOS.stream().anyMatch(salaryAcctRecordPO -> salaryAcctRecordPO.getTaxCycle().compareTo(taxCycle) != 0); + if (differentTaxCycle) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98876, "{0}存在不同的税款所属期,无法正常生成个税申报表,请调整账套设置,重新核算后再生成个税申报表") + .replace("{0}", SalaryDateUtil.getFormatYearMonth(saveParam.getSalaryMonth()))); + } + } + + // 无薪资核算记录,不允许生成个税申报表 + if (CollectionUtils.isEmpty(salaryAcctRecordPOS)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98874, "{0}无申报数据").replace("{0}", saveParam.getSalaryMonth().toString())); + } + + // 查询薪资核算结果 + List salaryAcctResultPOS = getSalaryAcctResultService(user) + .listBySalaryAcctRecordIdsAndTaxAgentIds(SalaryEntityUtil.properties(salaryAcctRecordPOS, SalaryAcctRecordPO::getId), taxAgentIds); + + // 无薪资核算结果,不允许生成个税申报表 + if (CollectionUtils.isEmpty(salaryAcctResultPOS)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(110093, "{0}无可申报数据") + .replace("{0}", SalaryDateUtil.getFormatYearMonth(saveParam.getSalaryMonth()))); + } + + // 查询薪资账套 + Set salarySobIds = SalaryEntityUtil.properties(salaryAcctRecordPOS, SalaryAcctRecordPO::getSalarySobId); + List salarySobPOS = getSalarySobService(user).listByIds(salarySobIds); + Map salarySobNameMap = SalaryEntityUtil.convert2Map(salarySobPOS, SalarySobPO::getId, SalarySobPO::getName); + Set salaryAcctRecordIds = SalaryEntityUtil.properties(salaryAcctResultPOS, SalaryAcctResultPO::getSalaryAcctRecordId); + salaryAcctRecordPOS = salaryAcctRecordPOS.stream().filter(salaryAcctRecordPO -> salaryAcctRecordIds.contains(salaryAcctRecordPO.getId())).collect(Collectors.toList()); + // 如果存在未归档的,也不允许生成个税申报表 + salaryAcctRecordPOS.forEach(salaryAcctRecordPO -> { + if (Objects.equals(salaryAcctRecordPO.getStatus(), SalaryAcctRecordStatusEnum.NOT_ARCHIVED.getValue())){ + throw new SalaryRunTimeException( + String.format("%s%s账套有未归档数据,请全部归档后再申报" + ,SalaryDateUtil.getFormatYearMonth(saveParam.getSalaryMonth()) + ,salarySobNameMap.getOrDefault(salaryAcctRecordPO.getSalarySobId(),"") + ) + ); + } + }); + + // 查询所有薪资项目 + List salaryItemPOS = getSalaryItemService(user).listAll(); + + + // 处理要保存的数据 + TaxDeclarationBO.Result result = TaxDeclarationBO.handle(saveParam, taxCycle, user, salaryItemPOS, salarySobPOS, salaryAcctResultPOS); + // 保存个税申报表 + if (CollectionUtils.isNotEmpty(result.getNeedInsertTaxDeclarations())) { + if (isLog) { + log.info("salary TaxDeclaration step1 save {}", result.getNeedInsertTaxDeclarations().size()); + } + getTaxDeclarationMapper().batchInsert(result.getNeedInsertTaxDeclarations()); + } + // 保存个税申报表明细 + if (CollectionUtils.isNotEmpty(result.getNeedInsertTaxDeclarationDetails())) { + if (isLog) { + log.info("salary TaxDeclaration step2 detail save {}", result.getNeedInsertTaxDeclarationDetails().size()); + } + getTaxDeclarationDetailService(user).batchSave(result.getNeedInsertTaxDeclarationDetails()); + } + // 保存累计情况 + if (CollectionUtils.isNotEmpty(result.getNeedInsertAddUpSituations())) { + if (isLog) { + log.info("salary TaxDeclaration step3 AddUpSituations save {}", result.getNeedInsertAddUpSituations().size()); + } + getAddUpSituationService(user).deleteByTaxYearMonthAndTaxAgentIds(SalaryDateUtil.localDate2YearMonth(taxCycle), taxAgentIds); + getAddUpSituationService(user).batchSave((List) result.getNeedInsertAddUpSituations()); + } + // 更新薪资核算记录的状态 + if (isLog) { + log.info("salary TaxDeclaration step4 AcctRecordStatus save {}", salaryAcctRecordIds.size()); + } + getSalaryAcctRecordService(user).updateStatusByIds(salaryAcctRecordIds, SalaryAcctRecordStatusEnum.DECLARED); + + // 记录日志 + result.getNeedInsertTaxDeclarations().stream().forEach(declare -> { + String taxAgentName = taxAgentNameMap.getOrDefault(declare.getTaxAgentId(), ""); + String targetName = SalaryDateUtil.getFormatYearMonth(declare.getSalaryMonth()) + " " + taxAgentName + " " + IncomeCategoryEnum.parseByValue(declare.getIncomeCategory()).getDefaultLabel(); + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(declare.getId().toString()); + loggerContext.setTargetName(targetName); + loggerContext.setOperateType(OperateTypeEnum.ADD.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "生成个税申报表")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "生成个税申报表")); + loggerContext.setNewValues(declare); + SalaryElogConfig.taxDeclarationLoggerTemplate.write(loggerContext); + }); + } + + @Override + public void delete(SalaryAcctRecordPO salaryAcctRecordPO) { + SalarySobPO sobPO = getSalarySobService(user).getById(salaryAcctRecordPO.getSalarySobId()); + if (sobPO == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(84026, "账套信息异常")); + } + + // 薪资所属月的日期范围 + LocalDateRange taxCycleDateRange = SalaryDateUtil.localDate2Range(salaryAcctRecordPO.getTaxCycle()); + if (Objects.isNull(taxCycleDateRange)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(84026, "参数错误")); + } + sobPO.getTaxAgentIds().forEach(taxAgentId -> { + List taxDeclarationPOS = listByTaxCycleAndTaxAgentIds(SalaryDateUtil.localDate2YearMonth(salaryAcctRecordPO.getTaxCycle()), Collections.singleton(taxAgentId)); + + Set taxDeclarationIds = SalaryEntityUtil.properties(taxDeclarationPOS, TaxDeclarationPO::getId); + if (CollectionUtils.isNotEmpty(taxDeclarationIds)) { + // 删除个税申报表 + getTaxDeclarationMapper().deleteByIds(taxDeclarationIds); + // 删除个税申报表详情 + getTaxDeclarationDetailService(user).deleteByTaxDeclarationIds(taxDeclarationIds); + } + + // 删除往期累计情况 + getAddUpSituationService(user).deleteAddUpSituationList(salaryAcctRecordPO.getTaxCycle(), taxAgentId); + }); + } + + + public List listBySalaryMonthTax(TaxDeclarationPO build) { + return getTaxDeclarationMapper().listSome(build); + } + + public List listBySalaryMonth(SalaryAcctRecordPO po) { + return getSalaryAcctRecordMapper().listSome(po); + } + + public List listByTaxCycle(TaxDeclarationPO build) { + return getTaxDeclarationMapper().listSome(build); + } + + public List listByTaxCycle(SalaryAcctRecordPO po) { + return getSalaryAcctRecordMapper().listSome(po); + } + + @Override + public boolean checkByAuthority(TaxDeclarationPO taxDeclarationPO, Long employeeId) { + // 判断是否开启了分权 + Boolean openDevolution = getTaxAgentService(user).isOpenDevolution(); + // 获取所有个税扣缴义务人 + TaxAgentQueryParam param = TaxAgentQueryParam.builder().build(); + param.setFilterType(AuthFilterTypeEnum.ADMIN_DATA); + Collection taxAgentList = getTaxAgentService(user).listAuth(param); + + Set taxAgentIds = SalaryEntityUtil.properties(taxAgentList, TaxAgentPO::getId); + return taxAgentIds.contains(taxDeclarationPO.getTaxAgentId()); + } + + @Override + public void withDrawTaxDeclaration(Long taxDeclarationId) { + TaxDeclarationPO po = getTaxDeclarationMapper().getById(taxDeclarationId); + if (Objects.isNull(po)) { + throw new SalaryRunTimeException("个税申报表不存在"); + } + // 获取当前个税扣缴义务人下的薪资账套 + List salarySobPOS = getSalarySobService(user).listByTaxAgentId(po.getTaxAgentId()); + List salarySobIds = salarySobPOS.stream().map(SalarySobPO::getId).collect(Collectors.toList()); + // 获取记录 + LocalDateRange dateRange = new LocalDateRange(po.getSalaryMonth(), po.getSalaryMonth()); + List salaryAcctRecords = getSalaryAcctRecordService(user).listBySalarySobIdsAndSalaryMonth(salarySobIds, dateRange); + List salaryAcctRecordIds = salaryAcctRecords.stream().map(SalaryAcctRecordPO::getId).collect(Collectors.toList()); + // 删除个税申报表 + getTaxDeclarationMapper().deleteByIdZj(po.getId()); + // 修改薪资核算记录状态为已归档 + if (CollectionUtils.isNotEmpty(salaryAcctRecordIds)) { + getSalaryAcctRecordService(user).updateStatusByIds(salaryAcctRecordIds, SalaryAcctRecordStatusEnum.ARCHIVED); + } + + // 查询个税扣缴义务人名称 + String bar = "_"; + TaxAgentPO taxAgentPO = getTaxAgentService(user).getById(po.getTaxAgentId()); + String targetName = SalaryDateUtil.getFormatYearMonth(po.getSalaryMonth()) + bar + taxAgentPO.getName() + bar + IncomeCategoryEnum.parseByValue(po.getIncomeCategory()).getDefaultLabel(); + // 记录日志 + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(taxDeclarationId.toString()); + loggerContext.setTargetName(targetName); + loggerContext.setOperateType(OperateTypeEnum.DELETE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "撤回个税申报表")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "撤回个税申报表")); + SalaryElogConfig.taxDeclarationLoggerTemplate.write(loggerContext); + } +} diff --git a/src/com/engine/salary/service/impl/TaxRateBaseServiceImpl.java b/src/com/engine/salary/service/impl/TaxRateBaseServiceImpl.java new file mode 100644 index 000000000..86379c60f --- /dev/null +++ b/src/com/engine/salary/service/impl/TaxRateBaseServiceImpl.java @@ -0,0 +1,78 @@ +package com.engine.salary.service.impl; + +import com.engine.core.impl.Service; +import com.engine.salary.cmd.TaxRate.*; +import com.engine.salary.entity.taxrate.SysTaxRateBase; +import com.engine.salary.entity.taxrate.TaxRateBase; +import com.engine.salary.mapper.SysTaxRateBaseMapper; +import com.engine.salary.mapper.TaxRateBaseMapper; +import com.engine.salary.service.TaxRateBaseService; +import com.engine.salary.util.db.MapperProxyFactory; +import com.google.common.collect.Lists; +import org.springframework.beans.BeanUtils; + +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + + +public class TaxRateBaseServiceImpl extends Service implements TaxRateBaseService { + + + private SysTaxRateBaseMapper getSysTaxRateBaseMapper(){ + return MapperProxyFactory.getProxy(SysTaxRateBaseMapper.class); + } + + + private TaxRateBaseMapper getTaxRateBaseMapper(){ + return MapperProxyFactory.getProxy(TaxRateBaseMapper.class); + } + + @Override + public Map listPage(Map params) { + return commandExecutor.execute(new TaxRateListCmd(params, user)); + } + + + @Override + public Map save(Map params) { + return commandExecutor.execute(new TaxRateSaveCmd(params, user)); + } + + @Override + public Map update(Map params) { + return commandExecutor.execute(new TaxRateUpdateCmd(params, user)); + } + + @Override + public Map getForm(Map params) { + return commandExecutor.execute(new TaxRateGetFormCmd(params, user)); + } + + + @Override + public Map delete(Map params) { + return commandExecutor.execute(new TaxRateDeleteCmd(params, user)); + } + + @Override + public List list() { + List resultList = Lists.newArrayList(); + // 查询系统默认的税率表 + List sysTaxRateBasePOS = getSysTaxRateBaseMapper().listAll(); + + List taxRateBasePOS4Sys = sysTaxRateBasePOS.stream() + .map(sysTaxRateBasePO -> { + TaxRateBase taxRateBasePO = new TaxRateBase(); + BeanUtils.copyProperties(sysTaxRateBasePO, taxRateBasePO); + return taxRateBasePO; + }) + .collect(Collectors.toList()); + resultList.addAll(taxRateBasePOS4Sys); + // 查询自定义税率表 + List taxRateBasePOS = getTaxRateBaseMapper().listAll(); + resultList.addAll(taxRateBasePOS); + return resultList; + } + +} diff --git a/src/com/engine/salary/service/impl/TaxRateDetailServiceImpl.java b/src/com/engine/salary/service/impl/TaxRateDetailServiceImpl.java new file mode 100644 index 000000000..ba99f7960 --- /dev/null +++ b/src/com/engine/salary/service/impl/TaxRateDetailServiceImpl.java @@ -0,0 +1,67 @@ +package com.engine.salary.service.impl; + +import com.engine.core.impl.Service; +import com.engine.salary.entity.taxrate.SysTaxRateDetailPO; +import com.engine.salary.entity.taxrate.TaxRateDetail; +import com.engine.salary.mapper.SysTaxRateDetailMapper; +import com.engine.salary.mapper.TaxRateDetailMapper; +import com.engine.salary.service.TaxRateDetailService; +import com.engine.salary.util.db.MapperProxyFactory; +import org.apache.commons.collections4.CollectionUtils; +import org.springframework.beans.BeanUtils; + +import java.util.Collection; +import java.util.List; +import java.util.stream.Collectors; + +/** + * 个税税率表明细表 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class TaxRateDetailServiceImpl extends Service implements TaxRateDetailService { + + private TaxRateDetailMapper getTaxRateDetailMapper(){ + return MapperProxyFactory.getProxy(TaxRateDetailMapper.class); + } + + private SysTaxRateDetailMapper getSysTaxRateDetailMapper(){ + return MapperProxyFactory.getProxy(SysTaxRateDetailMapper.class); + } + + +// @Override +// public TaxRateDetail getByFormulaFilterData(Long taxRateBaseId, boolean isOr, Collection formulaFilterDataList, String tenantKey) { +// List taxRateDetailPOS = listByBaseId(taxRateBaseId); +// if (CollectionUtils.isEmpty(taxRateDetailPOS)) { +// return null; +// } +// // 根据公式中的条件过滤出个税税率表明细 +// return TaxRateDetailBO.filter(taxRateDetailPOS, isOr, formulaFilterDataList); +// } + + @Override + public List listByBaseId(Long taxRateBaseId) { + // 查询系统默认税率表的明细 + List sysTaxRateDetailPOS = getSysTaxRateDetailMapper().listByBaseId(taxRateBaseId); + if (CollectionUtils.isNotEmpty(sysTaxRateDetailPOS)) { + return sysTaxRateDetailPOS.stream() + .map(sysTaxRateDetailPO -> { + TaxRateDetail taxRateDetailPO = new TaxRateDetail(); + BeanUtils.copyProperties(sysTaxRateDetailPO, taxRateDetailPO); + return taxRateDetailPO; + }).collect(Collectors.toList()); + } + + // 查询自定义税率表的明细 + return getTaxRateDetailMapper().listByBaseId(taxRateBaseId); + } + + @Override + public void deleteByBaseIds(Collection taxRateBaseIds) { + getTaxRateDetailMapper().deleteByBatchIds(taxRateBaseIds); + } +} diff --git a/src/com/engine/salary/service/impl/VariableArchiveItemServiceImpl.java b/src/com/engine/salary/service/impl/VariableArchiveItemServiceImpl.java new file mode 100644 index 000000000..b7aff7cae --- /dev/null +++ b/src/com/engine/salary/service/impl/VariableArchiveItemServiceImpl.java @@ -0,0 +1,87 @@ +package com.engine.salary.service.impl; + +import com.engine.core.impl.Service; +import com.engine.salary.encrypt.EncryptUtil; +import com.engine.salary.entity.datacollection.po.VariableArchiveItemPO; +import com.engine.salary.mapper.datacollection.VariableArchiveItemMapper; +import com.engine.salary.service.VariableArchiveItemService; +import com.engine.salary.util.db.MapperProxyFactory; +import com.google.common.collect.Lists; +import org.apache.commons.collections4.CollectionUtils; + +import java.util.Collections; +import java.util.List; + +/** + * @author Harryxzy + * @ClassName VariableArchiveItemServiceImpl + * @date 2024/08/07 9:29 + * @description 浮动薪酬档案明细 + */ +public class VariableArchiveItemServiceImpl extends Service implements VariableArchiveItemService { + private EncryptUtil encryptUtil = new EncryptUtil(); + + private VariableArchiveItemMapper getVariableArchiveItemMapper(){ + return MapperProxyFactory.getProxy(VariableArchiveItemMapper.class); + } + + @Override + public List listAll() { + return getVariableArchiveItemMapper().listAll(); + } + + /** + * 根据浮动薪资档案id获取 + * + * @param variableArchiveIds + * @return + */ + @Override + public List listByVariableArchiveIds(List variableArchiveIds) { + if (CollectionUtils.isEmpty(variableArchiveIds)) { + return Collections.emptyList(); + } + List variableArchiveItemPOS = getVariableArchiveItemMapper().listSome(VariableArchiveItemPO.builder().variableArchiveIds(variableArchiveIds).build()); + return encryptUtil.decryptList(variableArchiveItemPOS, VariableArchiveItemPO.class); + } + + /** + * 查询浮动薪酬档案中已使用的浮动薪资项目 + * + * @return + */ + @Override + public List listUsingItems() { + return getVariableArchiveItemMapper().listUsingItems(); + } + + @Override + public int batchInsert(List insertList) { + if (CollectionUtils.isEmpty(insertList)) { + return 0; + } + encryptUtil.encryptList(insertList, VariableArchiveItemPO.class); + List> partition = Lists.partition(insertList, 50); + partition.forEach(part -> getVariableArchiveItemMapper().batchInsert(part)); + return 0; + } + + @Override + public void deleteByArchiveIds(List variableArchiveIds) { + if (CollectionUtils.isEmpty(variableArchiveIds)) { + return; + } + List> partition = Lists.partition(variableArchiveIds, 500); + partition.forEach(part -> getVariableArchiveItemMapper().deleteByArchiveIds(part)); + } + + @Override + public void deleteByIds(List variableArchiveItemIds) { + if (CollectionUtils.isEmpty(variableArchiveItemIds)) { + return; + } + List> partition = Lists.partition(variableArchiveItemIds, 500); + partition.forEach(part -> getVariableArchiveItemMapper().deleteByIds(part)); + + } +} diff --git a/src/com/engine/salary/service/impl/VariableArchiveServiceImpl.java b/src/com/engine/salary/service/impl/VariableArchiveServiceImpl.java new file mode 100644 index 000000000..d06b252f1 --- /dev/null +++ b/src/com/engine/salary/service/impl/VariableArchiveServiceImpl.java @@ -0,0 +1,633 @@ +package com.engine.salary.service.impl; + +import cn.hutool.core.collection.CollectionUtil; +import com.cloudstore.eccom.pc.table.WeaTableColumn; +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.constant.SalaryDefaultTenantConstant; +import com.engine.salary.constant.SalaryItemConstant; +import com.engine.salary.entity.datacollection.bo.VariableArchiveBO; +import com.engine.salary.entity.datacollection.bo.VariableArchiveExcelBO; +import com.engine.salary.entity.datacollection.dto.VariableArchiveListDTO; +import com.engine.salary.entity.datacollection.dto.VariableItemListDTO; +import com.engine.salary.entity.datacollection.param.VariableArchiveImportHandleParam; +import com.engine.salary.entity.datacollection.param.VariableArchiveQueryParam; +import com.engine.salary.entity.datacollection.param.VariableArchiveSaveParam; +import com.engine.salary.entity.datacollection.po.VariableArchiveItemPO; +import com.engine.salary.entity.datacollection.po.VariableArchivePO; +import com.engine.salary.entity.datacollection.po.VariableItemPO; +import com.engine.salary.entity.salaryarchive.dto.SalaryArchiveInitImportDTO; +import com.engine.salary.entity.taxagent.param.TaxAgentQueryParam; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import com.engine.salary.enums.auth.AuthFilterTypeEnum; +import com.engine.salary.enums.datacollection.UseEmployeeTypeEnum; +import com.engine.salary.enums.salaryitem.SalaryDataTypeEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.mapper.datacollection.VariableArchiveMapper; +import com.engine.salary.service.*; +import com.engine.salary.service.auth.AuthService; +import com.engine.salary.service.auth.AuthServiceImpl; +import com.engine.salary.sys.entity.vo.OrderRuleVO; +import com.engine.salary.sys.service.SalarySysConfService; +import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl; +import com.engine.salary.util.SalaryDateUtil; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.db.IdGenerator; +import com.engine.salary.util.db.MapperProxyFactory; +import com.engine.salary.util.excel.*; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.util.page.SalaryPageUtil; +import com.engine.salary.util.valid.ValidUtil; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.math.NumberUtils; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.util.IOUtils; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import weaver.file.ImageFileManager; +import weaver.general.Util; +import weaver.hrm.User; + +import java.io.InputStream; +import java.time.YearMonth; +import java.util.*; +import java.util.stream.Collectors; + +import static com.engine.salary.util.excel.ExcelSupport.EXCEL_TYPE_XLSX; + +/** + * @author Harryxzy + * @ClassName VariableArchiveServiceImpl + * @date 2024/08/06 17:40 + * @description 浮动薪酬档案 + */ +public class VariableArchiveServiceImpl extends Service implements VariableArchiveService { + + private VariableArchiveMapper getVariableArchiveMapper() { + return MapperProxyFactory.getProxy(VariableArchiveMapper.class); + } + + private TaxAgentService getTaxAgentService(User user) { + return ServiceUtil.getService(TaxAgentServiceImpl.class, user); + } + + public SalarySysConfService getSalarySysConfService(User user) { + return ServiceUtil.getService(SalarySysConfServiceImpl.class, user); + } + + private VariableArchiveItemService getVariableArchiveItemService(User user) { + return ServiceUtil.getService(VariableArchiveItemServiceImpl.class, user); + } + + private VariableItemService getVariableItemService(User user) { + return ServiceUtil.getService(VariableItemServiceImpl.class, user); + } + + private SalaryEmployeeService getSalaryEmployeeService(User user) { + return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user); + } + + public AuthService getAuthService(User user) { + return ServiceUtil.getService(AuthServiceImpl.class, user); + } + + private int deleteByIds(List deleteIds) { + if (CollectionUtils.isEmpty(deleteIds)) { + return 0; + } + return getVariableArchiveMapper().deleteByIds(deleteIds); + } + + /** + * 浮动薪酬档案列表 + * + * @param queryParam + * @return + */ + @Override + public PageInfo listPage(VariableArchiveQueryParam queryParam) { + queryParam.setFilterType(AuthFilterTypeEnum.DATA_OPT); + List variableArchiveList = list(queryParam); + return SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), variableArchiveList, VariableArchiveListDTO.class); + } + + @Override + public List list(VariableArchiveQueryParam queryParam) { + ValidUtil.doValidator(queryParam); + // 浮动薪酬档案列表 + if (Objects.nonNull(queryParam.getSalaryMonth())) { + queryParam.setSalaryMonthDate(SalaryDateUtil.dateStrToLocalYearMonth(queryParam.getSalaryMonth())); + } + //排序配置 + OrderRuleVO orderRule = getSalarySysConfService(user).orderRule(); + queryParam.setOrderRule(orderRule); + List list = listDTO(queryParam); + return getAuthService(user).auth(list, queryParam.getFilterType(), VariableArchiveListDTO.class); + } + + public List listDTO(VariableArchiveQueryParam queryParam) { + List list = getVariableArchiveMapper().list(queryParam); + SalaryI18nUtil.i18nList(list); + return list; + } + + /** + * 构建浮动薪资档案数据 + * + * @param variableArchives + * @return + */ + @Override + public List> buildVariableArchiveData(List variableArchives) { + List variableArchiveIds = variableArchives.stream().map(VariableArchiveListDTO::getId).collect(Collectors.toList()); + // 获取浮动薪资档案所对应的浮动薪资项目数据 + List variableArchiveItemList = getVariableArchiveItemService(user).listByVariableArchiveIds(variableArchiveIds); + Map> variableArchiveItemMap = SalaryEntityUtil.group2Map(variableArchiveItemList, VariableArchiveItemPO::getVariableArchiveId); + List> variableArchiveItemData = variableArchives.stream().map(m -> { + Map map = Maps.newHashMap(); + map.put("variableArchiveId", m.getId()); + List variableArchiveItemValuelList = variableArchiveItemMap.getOrDefault(m.getId(), Collections.emptyList()); + variableArchiveItemValuelList.forEach(i -> { + map.put(i.getVariableItemId() + SalaryItemConstant.VARIABLE_ITEM_DYNAMIC_SUFFIX, i.getItemValue()); + }); + return map; + }).collect(Collectors.toList()); + + + // 组装数据 + List> listMaps = new ArrayList<>(); + variableArchives.forEach(e -> { + Map map = new LinkedHashMap<>(); + map.put("id", e.getId()); + map.put("taxAgentName", e.getTaxAgentName()); + map.put("taxAgentIds", e.getTaxAgentId()); + map.put("username", e.getUsername()); + map.put("salaryMonth", SalaryDateUtil.getFormatYearMonth(e.getSalaryMonth())); + map.put("employeeId", e.getEmployeeId()); + map.put("subcompanyName", e.getSubcompanyName()); + map.put("departmentName", e.getDepartmentName()); + map.put("mobile", e.getMobile()); + map.put("workcode", e.getWorkcode()); + map.put("idNo", e.getIdNo()); + map.put("companystartdate", e.getCompanystartdate()); + map.put("dismissdate", e.getDismissdate()); + map.put("opts", e.getOpts()); + + // 浮动薪资项目动态 + Optional> optionalItem = variableArchiveItemData.stream().filter(f -> f.get("variableArchiveId").toString().equals(e.getId().toString())).findFirst(); + optionalItem.ifPresent(map::putAll); + + listMaps.add(map); + }); + return listMaps; + } + + /** + * 创建浮动薪酬档案 + * + * @param saveParam + */ + @Override + public void createData(VariableArchiveSaveParam saveParam) { + ValidUtil.doValidator(saveParam); + saveParam.setSalaryMonthDate(SalaryDateUtil.dateStrToLocalYearMonth(saveParam.getSalaryMonth())); + + List variableArchivePOList = getVariableArchiveMapper().listSome(VariableArchivePO.builder().salaryMonth(saveParam.getSalaryMonthDate()).taxAgentId(saveParam.getTaxAgentIds()).employeeId(saveParam.getEmployeeId()).build()); + if (CollectionUtils.isNotEmpty(variableArchivePOList)) { + throw new SalaryRunTimeException("已存在浮动薪酬数据"); + } + + // 保存浮动薪资档案信息 + Date now = new Date(); + VariableArchivePO variableArchivePO = VariableArchivePO.builder() + .id(IdGenerator.generate()) + .employeeId(saveParam.getEmployeeId()) + .taxAgentId(saveParam.getTaxAgentIds()) + .salaryMonth(saveParam.getSalaryMonthDate()) + .creator((long) user.getUID()) + .createTime(now) + .updateTime(now) + .deleteType(NumberUtils.INTEGER_ZERO) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .build(); + getVariableArchiveMapper().insertIgnoreNull(variableArchivePO); + + // 保存浮动薪资档案详细信息 + List variableArchiveItemList = new ArrayList<>(); + if(CollectionUtil.isNotEmpty(saveParam.getItemValueList())){ + saveParam.getItemValueList().forEach(e -> { + variableArchiveItemList.add(VariableArchiveItemPO.builder() + .id(IdGenerator.generate()) + .employeeId(saveParam.getEmployeeId()) + .variableArchiveId(variableArchivePO.getId()) + .variableItemId(e.getVariableItemId()) + .itemValue(e.getItemValue()) + .creator((long) user.getUID()) + .createTime(now) + .updateTime(now) + .deleteType(NumberUtils.INTEGER_ZERO) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .build()); + }); + } + + if (CollectionUtils.isNotEmpty(variableArchiveItemList)) { + getVariableArchiveItemService(user).batchInsert(variableArchiveItemList); + } + } + + /** + * 浮动薪资档案明细 + * + * @param queryParam + * @return + */ + @Override + public Map getDetail(VariableArchiveQueryParam queryParam) { + if (queryParam.getId() == null) { + return Collections.emptyMap(); + } + + List variableArchiveList = listDTO(queryParam); + + // 获取所有浮动薪酬项目 + List variableItems = getVariableItemService(user).listAll(); + + //整合所有的显示列(固定列+薪资项目动态列) + List> listMaps = buildVariableArchiveData(variableArchiveList); + Map resultMap = listMaps.get(0); + + //动态列组装 + List columns = VariableArchiveBO.buildVariableArchiveTable(variableItems); + + Map datas = new HashMap<>(); + datas.put("data", resultMap); + datas.put("column", columns); + return datas; + } + + @Override + public List getCreateForm() { + List variableItemPOS = getVariableItemService(user).listAll(); + List variableItemDTOList = variableItemPOS.stream() + .map(po -> VariableItemListDTO.builder() + .id(po.getId()) + .name(po.getName()) + .dataType(SalaryDataTypeEnum.parseByValue(po.getDataType()).getValue()) + .build()) + .collect(Collectors.toList()); + return variableItemDTOList; + } + + @Override + public XSSFWorkbook downloadTemplate(VariableArchiveQueryParam param) { + // 名称 + String nameI18n = SalaryI18nUtil.getI18nLabel(0, "浮动薪酬导入模板"); + + // 获取所有可被引用的薪资项目 + List variableItems = getVariableItemService(user).listAll(); + List header = Lists.newArrayList(); + header.add(SalaryI18nUtil.getI18nLabel(0, "个税扣缴义务人")); + header.add(SalaryI18nUtil.getI18nLabel(85429, "姓名")); + header.add(SalaryI18nUtil.getI18nLabel(86185, "部门")); + header.add(SalaryI18nUtil.getI18nLabel(86186, "手机号")); + header.add(SalaryI18nUtil.getI18nLabel(1933, "工号")); + header.add(SalaryI18nUtil.getI18nLabel(86186, "证件号码")); + header.add(SalaryI18nUtil.getI18nLabel(86187, "入职日期")); + for (VariableItemPO variableItem : variableItems) { + header.add(variableItem.getName()); + } + + // 2.表头 + List> rows = new ArrayList<>(); + rows.add(header); + + if (param.isHasData()) { + // 获取档案信息 + param.setFilterType(AuthFilterTypeEnum.ADMIN_DATA); + List variableArchiveList = list(param); + List> listMaps = buildVariableArchiveData(variableArchiveList); + // 组装数据 + listMaps.forEach(e -> { + List row = new ArrayList<>(); + row.add(e.get("taxAgentName").toString()); + row.add(e.get("username").toString()); + row.add(Optional.ofNullable(e.get("departmentName")).orElse("").toString()); + row.add(e.get("mobile") == null ? "" : e.get("mobile").toString()); + row.add(Optional.ofNullable(e.get("workcode")).orElse("").toString()); + row.add(Util.null2String(e.get("idNo"))); + row.add(Util.null2String(e.get("companystartdate"))); + + // 薪资项目数据 + for (VariableItemPO variableItem : variableItems) { + row.add(e.containsKey(variableItem.getId() + SalaryItemConstant.VARIABLE_ITEM_DYNAMIC_SUFFIX) ? (e.get(variableItem.getId() + SalaryItemConstant.VARIABLE_ITEM_DYNAMIC_SUFFIX) == null ? "" + : e.get(variableItem.getId() + SalaryItemConstant.VARIABLE_ITEM_DYNAMIC_SUFFIX).toString()) : ""); + } + rows.add(row); + }); + } + + + // 4.注释 + List excelComments = Lists.newArrayList(); + + return ExcelUtilPlus.genWorkbookV2(rows, nameI18n, excelComments); + } + + @Override + public ExcelPreviewDTO preview(VariableArchiveImportHandleParam importParam) { + + //excel文件id + String imageId = Util.null2String(importParam.getImageId()); + + InputStream fileInputStream = null; + try { + fileInputStream = ImageFileManager.getInputStreamById(Integer.parseInt(imageId)); + return ExcelParseHelper.preview(fileInputStream, 0, EXCEL_TYPE_XLSX); + } finally { + IOUtils.closeQuietly(fileInputStream); + } + } + + @Override + public Map importData(VariableArchiveImportHandleParam importParam) { + // 初始化国际化标签 + VariableArchiveExcelBO.initI18n(); + // 校验参数 + checkImportParam(importParam); + String imageId = importParam.getImageId(); + // 构建导入处理参数 + importParam = buildImportHandleParam(importParam); + // 导入有重复 + List allTodoVariableArchives = Lists.newArrayList(); + + InputStream fileInputStream = null; + try { + fileInputStream = ImageFileManager.getInputStreamById(Integer.parseInt(imageId)); + Workbook workbook = ExcelSupport.parseFile(fileInputStream, EXCEL_TYPE_XLSX); + Sheet sheet = workbook.getSheetAt(0); + List headers = ExcelSupport.getSheetHeader(sheet, 0); + + int total = 0; + //excel数据 + List> data = ExcelParseHelper.parse2Map(workbook, 0, 1); + if (data != null) { + total += data.size(); + } + + int index = 0; + int successCount = 0; + int errorCount = 0; + // 用于(初始化导入)的相同employeeId时的处理 + List initImportData = Lists.newArrayList(); + + + // 错误提示 + List> excelComments = new ArrayList<>(); + // 错误sheet数据 + List> errorData = new ArrayList<>(); + + Map map; + for (int i = 0; i < data.size(); i++) { + index += 1; + map = data.get(i); + map.put("index", i + 2); + // 3.校验行内容 + boolean isError = VariableArchiveExcelBO.singleRowCheck(allTodoVariableArchives, map, headers, excelComments, errorCount, importParam, user); + if (isError) { + errorCount += 1; + // 添加错误数据 + errorData.add(map); + } else { + successCount += 1; + } + } + + // 4.数据入库处理 + handleImportData(importParam); + + Map apidatas = new HashMap<>(); + + apidatas.put("successCount", successCount); + apidatas.put("errorCount", errorCount); + apidatas.put("errorNotice", excelComments); + return apidatas; + } finally { + IOUtils.closeQuietly(fileInputStream); + } + } + + private void checkImportParam(VariableArchiveImportHandleParam importParam) { + //excel文件id + String imageId = Util.null2String(importParam.getImageId()); + //税款所属期 + String salaryMonthStr = Util.null2String(importParam.getSalaryMonth()); + if (StringUtils.isBlank(imageId)) { + throw new SalaryRunTimeException("文件不存在"); + } + if (StringUtils.isBlank(salaryMonthStr)) { + throw new SalaryRunTimeException("薪资所属月为空"); + } + } + + /** + * 构建导入处理参数 + * + * @param param + * @return + */ + private VariableArchiveImportHandleParam buildImportHandleParam(VariableArchiveImportHandleParam param) { + // 获取所有可被引用的浮动薪资项目 + List variableItems = getVariableItemService(user).listAll(); + Collection variableItemIds = variableItems.stream().map(VariableItemPO::getId).collect(Collectors.toList()); + List variableArchiveList = getVariableArchiveMapper().listSome(VariableArchivePO.builder().salaryMonth(SalaryDateUtil.dateStrToLocalYearMonth(param.getSalaryMonth())).build()); + + List variableArchiveIds = variableArchiveList.stream().map(VariableArchivePO::getId).collect(Collectors.toList()); + Map variableArchivesMap = SalaryEntityUtil.convert2Map(variableArchiveList, k -> k.getTaxAgentId() + "-" + k.getEmployeeId()); + + // 获取浮动薪资档案明细数据 + List variableArchiveItemPOS = getVariableArchiveItemService(user).listByVariableArchiveIds(variableArchiveIds); + Map> variableArchiveItemMap = SalaryEntityUtil.group2Map(variableArchiveItemPOS, k -> k.getVariableArchiveId() + "-" + k.getVariableItemId()); + + // 获取个税扣缴义务人 + TaxAgentQueryParam queryParam = TaxAgentQueryParam.builder().build(); + queryParam.setFilterType(AuthFilterTypeEnum.ADMIN_DATA); + List taxAgentList = getTaxAgentService(user).listAuth(queryParam); + + + return VariableArchiveImportHandleParam.builder() + .imageId(param.getImageId()) + .salaryMonth(param.getSalaryMonth()) + .salaryMonthDate(SalaryDateUtil.dateStrToLocalYearMonth(param.getSalaryMonth())) + .currentEmployeeId((long) user.getUID()) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + //人员定位方式 + .empValidType(getSalaryEmployeeService(user).empValidType()) + // 获取租户下所有的人员 + .employees(getSalaryEmployeeService(user).listAll(UseEmployeeTypeEnum.ORG)) + // 浮动薪资项目 + .variableItems(variableItems) + // 查询已有的浮动薪资档案基本数据 + .variableArchivesMap(variableArchivesMap) + // 浮动薪资项目id + .variableItemIds(variableItemIds) + // 查询已生效的浮动薪资项目数据 + .effectiveItemListMap(variableArchiveItemMap) + // 可以管理的义务人 + .taxAgentList(taxAgentList) + // 当前时间 + .nowTime(new Date()) + // 当天 + .today(new Date()) + // 待保存浮动薪资档案 + .variableArchiveSaves(Lists.newArrayList()) + // 待保存浮动薪资档案-浮动薪资项目 + .variableArchiveItemSaves(Lists.newArrayList()) + // 待删除浮动薪资档案-浮动薪资项目 + .variableArchiveItemDelSalaryItemIds(Lists.newArrayList()) + .build(); + } + + + private void handleImportData(VariableArchiveImportHandleParam importHandleParam) { + List variableArchiveSaves = importHandleParam.getVariableArchiveSaves(); + List variableArchiveItemSaves = importHandleParam.getVariableArchiveItemSaves(); + List variableArchiveItemDelSalaryItemIds = importHandleParam.getVariableArchiveItemDelSalaryItemIds(); + + // 新增档案 + if (CollectionUtils.isNotEmpty(variableArchiveSaves)) { + variableArchiveSaves.stream().forEach(getVariableArchiveMapper()::insertIgnoreNull); + } + // 薪资档案-薪资项目 + if (CollectionUtils.isNotEmpty(variableArchiveItemDelSalaryItemIds)) { + getVariableArchiveItemService(user).deleteByIds(variableArchiveItemDelSalaryItemIds); + } + // 薪资档案-薪资项目 + if (CollectionUtils.isNotEmpty(variableArchiveItemSaves)) { + getVariableArchiveItemService(user).batchInsert(variableArchiveItemSaves); + } + } + + @Override + public XSSFWorkbook export(VariableArchiveQueryParam param) { + // 名称 + String nameI18n = SalaryI18nUtil.getI18nLabel(0, "浮动薪酬"); + + // 获取所有可被引用的薪资项目 + List variableItems = getVariableItemService(user).listAll(); + List header = VariableArchiveBO.buildVariableArchiveTable(variableItems); + Map columnMap = SalaryEntityUtil.convert2Map(header, WeaTableColumn::getColumn); + + List finalColumns = new ArrayList<>(); + param.getColumns().forEach(col -> { + WeaTableColumn column = columnMap.get(col); + if (column != null) { + finalColumns.add(column); + } + }); + header = finalColumns; + + // 2.表头 + List> rows = new ArrayList<>(); + rows.add(header.stream().map(WeaTableColumn::getText).collect(Collectors.toList())); + // 获取档案信息 + param.setFilterType(AuthFilterTypeEnum.QUERY_DATA); + List variableArchiveList = list(param); + List> listMaps = buildVariableArchiveData(variableArchiveList); + // 组装数据 + List finalHeader = header; + listMaps.forEach(e -> { + List row = new ArrayList<>(); + for (WeaTableColumn column : finalHeader) { + row.add(Util.null2String(e.get(column.getColumn()))); + } + // row.add(e.get("salaryMonth").toString()); + // row.add(e.get("taxAgentName").toString()); + // row.add(e.get("username").toString()); + // row.add(Optional.ofNullable(e.get("departmentName")).orElse("").toString()); + // row.add(e.get("mobile") == null ? "" : e.get("mobile").toString()); + // row.add(Optional.ofNullable(e.get("workcode")).orElse("").toString()); + // row.add(Util.null2String(e.get("idNo"))); + // row.add(Util.null2String(e.get("companystartdate"))); + // + // // 薪资项目数据 + // for (VariableItemPO variableItem : variableItems) { + // row.add(e.containsKey(variableItem.getId() + SalaryItemConstant.VARIABLE_ITEM_DYNAMIC_SUFFIX) ? (e.get(variableItem.getId() + SalaryItemConstant.VARIABLE_ITEM_DYNAMIC_SUFFIX) == null ? "" + // : e.get(variableItem.getId() + SalaryItemConstant.VARIABLE_ITEM_DYNAMIC_SUFFIX).toString()) : ""); + // } + rows.add(row); + }); + + // 4.注释 + List excelComments = Lists.newArrayList(); + + return ExcelUtilPlus.genWorkbookV2(rows, nameI18n, excelComments); + } + + @Override + public void deleteSelectVariableArchive(Collection deleteIds) { + if (CollectionUtils.isEmpty(deleteIds)) { + return; + } + List variableArchivePOList = getVariableArchiveMapper().listSome(VariableArchivePO.builder().ids(deleteIds).build()); + List archiveIds = variableArchivePOList.stream().map(VariableArchivePO::getId).collect(Collectors.toList()); + deleteByIds(archiveIds); + // 删除明细 + getVariableArchiveItemService(user).deleteByArchiveIds(archiveIds); + + } + + @Override + public List> listBySalaryMonthAndEmployeeIds(YearMonth salaryMonth, List employeeIds, List taxAgentIds) { + VariableArchiveQueryParam queryParam = VariableArchiveQueryParam.builder() + .employeeIds(employeeIds) + .salaryMonth(SalaryDateUtil.getFormatYearMonth(salaryMonth)) + .salaryMonthDate(SalaryDateUtil.toDate(salaryMonth, 1)) + .taxAgentIds(taxAgentIds) + .build(); + queryParam.setFilterType(AuthFilterTypeEnum.NO_AUTH); + List variableArchiveListDTO = list(queryParam); + return buildVariableArchiveData(variableArchiveListDTO); + } + + @Override + public void updateData(VariableArchiveSaveParam updateParam) { + if (updateParam.getId() == null) { + throw new SalaryRunTimeException("参数错误"); + } + // 获取浮动薪酬档案 + VariableArchivePO variableArchivePO = getVariableArchiveMapper().getById(updateParam.getId()); + if (variableArchivePO == null) { + throw new SalaryRunTimeException("浮动薪酬档案不存在或已被删除"); + } + + // 删除原有的浮动薪酬档案明细 + getVariableArchiveItemService(user).deleteByArchiveIds(Collections.singletonList(updateParam.getId())); + + // 保存浮动薪资档案详细信息 + List variableArchiveItemList = new ArrayList<>(); + Date now = new Date(); + updateParam.getItemValueList().forEach(e -> { + variableArchiveItemList.add(VariableArchiveItemPO.builder() + .id(IdGenerator.generate()) + .employeeId(updateParam.getEmployeeId()) + .variableArchiveId(variableArchivePO.getId()) + .variableItemId(e.getVariableItemId()) + .itemValue(e.getItemValue()) + .creator(Long.valueOf(user.getUID())) + .createTime(now) + .updateTime(now) + .deleteType(NumberUtils.INTEGER_ZERO) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .build()); + }); + + if (CollectionUtils.isNotEmpty(variableArchiveItemList)) { + getVariableArchiveItemService(user).batchInsert(variableArchiveItemList); + } + } +} diff --git a/src/com/engine/salary/service/impl/VariableItemServiceImpl.java b/src/com/engine/salary/service/impl/VariableItemServiceImpl.java new file mode 100644 index 000000000..41d30ea0d --- /dev/null +++ b/src/com/engine/salary/service/impl/VariableItemServiceImpl.java @@ -0,0 +1,246 @@ +package com.engine.salary.service.impl; + +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.constant.SalaryDefaultTenantConstant; +import com.engine.salary.entity.datacollection.dto.VariableItemListDTO; +import com.engine.salary.entity.datacollection.param.VariableItemQueryParam; +import com.engine.salary.entity.datacollection.param.VariableItemSaveParam; +import com.engine.salary.entity.datacollection.po.VariableItemPO; +import com.engine.salary.entity.salaryformula.po.FormulaPO; +import com.engine.salary.entity.salaryformula.po.FormulaVar; +import com.engine.salary.enums.salaryitem.SalaryDataTypeEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.mapper.datacollection.VariableItemMapper; +import com.engine.salary.service.*; +import com.engine.salary.util.SalaryEntityUtil; +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.page.SalaryPageUtil; +import com.engine.salary.util.valid.RuntimeTypeEnum; +import com.engine.salary.util.valid.ValidUtil; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.math.NumberUtils; +import org.springframework.beans.BeanUtils; +import weaver.conn.util.IdGenerator; +import weaver.hrm.User; + +import java.util.Collections; +import java.util.Date; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; + +/** + * @author Harryxzy + * @ClassName VariableItemServiceImpl + * @date 2024/08/07 9:31 + * @description 浮动薪酬项目 + */ +public class VariableItemServiceImpl extends Service implements VariableItemService { + + private VariableItemMapper getVariableItemMapper(){ + return MapperProxyFactory.getProxy(VariableItemMapper.class); + } + + private SalaryFormulaService getSalaryFormulaService(User user) { + return ServiceUtil.getService(SalaryFormulaServiceImpl.class, user); + } + + private SalaryItemService getSalaryItemService(User user) { + return ServiceUtil.getService(SalaryItemServiceImpl.class, user); + } + + private VariableArchiveItemService getVariableArchiveItemService(User user) { + return ServiceUtil.getService(VariableArchiveItemServiceImpl.class, user); + } + + private TaxAgentService getTaxAgentService(User user) { + return ServiceUtil.getService(TaxAgentServiceImpl.class, user); + } + + + @Override + public VariableItemPO getById(Long id) { + if (id == null) { + return null; + } + return getVariableItemMapper().getById(id); + } + + @Override + public List listByIds(List ids) { + if (CollectionUtils.isEmpty(ids)) { + return Collections.emptyList(); + } + return getVariableItemMapper().listSome(VariableItemPO.builder().ids(ids).build()); + } + + /** + * 获取浮动薪酬项目 + * @return + */ + @Override + public List listAll() { + return getVariableItemMapper().listAll(); + } + + /** + * 获取浮动薪资项目列表(分页) + * + * @param queryParam + * @return + */ + @Override + public PageInfo listPage(VariableItemQueryParam queryParam) { + List variableItemPOS = listAll(); + if (StringUtils.isNotBlank(queryParam.getItemName())) { + variableItemPOS = variableItemPOS.stream().filter(po -> po.getName().contains(queryParam.getItemName())).collect(Collectors.toList()); + } + // 查询不可删除的code、id + SalaryItemServiceImpl.UsingItem usingItem = getSalaryItemService(user).getUsingItem(); + List usingCodes = usingItem.getUsingCodes(); + List usingVariableItemIds = getVariableArchiveItemService(user).listUsingItems(); + + List variableItemDTOList = variableItemPOS.stream() + .map(po -> VariableItemListDTO.builder() + .id(po.getId()) + .name(po.getName()) + .dataType(SalaryDataTypeEnum.parseByValue(po.getDataType()).getDefaultLabel()) + .canDelete( !(usingCodes.contains(po.getCode()) || usingVariableItemIds.contains(po.getId())) ) + .build()) + .collect(Collectors.toList()); + return SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), variableItemDTOList, VariableItemListDTO.class); + } + + private List listByName(String name) { + return getVariableItemMapper().listSome(VariableItemPO.builder().name(name).build()); + } + + @Override + public Integer save(VariableItemSaveParam saveParam) { + // 名称不能和已有的自定义薪资项目重名 + List variableItemPOS = listByName(saveParam.getName()); + if (CollectionUtils.isNotEmpty(variableItemPOS)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "项目名称已存在,请重新命名")); + } + Date now = new Date(); + long id = com.engine.salary.util.db.IdGenerator.generate(); + VariableItemPO variableItemPO = VariableItemPO.builder() + .id(id) + .name(saveParam.getName()) + .code(IdGenerator.getUUID()) + .dataType(saveParam.getDataType()) + .creator((long) user.getUID()) + .deleteType(NumberUtils.INTEGER_ZERO) + .createTime(now) + .updateTime(now) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .build(); + return getVariableItemMapper().insertIgnoreNull(variableItemPO); + + } + + @Override + public VariableItemPO update(VariableItemSaveParam saveParam) { + ValidUtil.doValidator(saveParam, RuntimeTypeEnum.UPDATE); + // 查询薪资项目,判断薪资项目是否存在 + VariableItemPO variableItemPO = getById(saveParam.getId()); + if (Objects.isNull(variableItemPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "参数错误,项目不存在或已被删除")); + } + // 名称不能和已有的自定义薪资项目重名 + List variableItemPOS = listByName(saveParam.getName()); + boolean nameExist = variableItemPOS.stream().anyMatch(e -> !Objects.equals(saveParam.getId(), e.getId())); + if (nameExist) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98326, "项目名称已存在,请重新命名")); + } + + // 更新薪资项目 + VariableItemPO newVariableItemPO = new VariableItemPO(); + BeanUtils.copyProperties(variableItemPO, newVariableItemPO); + newVariableItemPO.setName(saveParam.getName()); + newVariableItemPO.setDataType(saveParam.getDataType()); + newVariableItemPO.setUpdateTime(new Date()); + getVariableItemMapper().update(newVariableItemPO); + + //改名后更新公式 + String oldName = variableItemPO.getName(); + String newName = saveParam.getName(); + if (!StringUtils.equals(oldName, newName)) { + String itemPrefix = "variableItem_"; + String fieldNamePrefix = "{浮动薪资项目.%s}"; + changeName(variableItemPO, oldName, newName, itemPrefix, fieldNamePrefix); + } + return variableItemPO; + } + + private void changeName(VariableItemPO variableItemPO, String oldName, String newName, String itemPrefix, String fieldNamePrefix) { + String code = itemPrefix + variableItemPO.getCode(); + Date now = new Date(); + List formulaVars = getSalaryFormulaService(user).listByCode(code); + formulaVars.forEach(v -> { + FormulaVar formulaVar = FormulaVar.builder() + .id(v.getId()) + .name(newName) + .fieldName(String.format(fieldNamePrefix, newName)) + .updateTime(now) + .build(); + getSalaryFormulaService(user).updateVar(formulaVar); + }); + + List formulaIds = SalaryEntityUtil.properties(formulaVars, FormulaVar::getFormulaId, Collectors.toList()); + List formulaPOS = getSalaryFormulaService(user).listByIds(formulaIds); + formulaPOS.forEach(f -> { + String formula = f.getFormula(); + formula = formula.replace(String.format(fieldNamePrefix, oldName), String.format(fieldNamePrefix, newName)); + FormulaPO formulaPO = FormulaPO.builder() + .id(f.getId()) + .formula(formula) + .updateTime(now) + .build(); + getSalaryFormulaService(user).update(formulaPO); + }); + } + + @Override + public void deleteItems(List itemIds) { + if (CollectionUtils.isEmpty(itemIds)) { + return; + } + + SalaryItemServiceImpl.UsingItem usingItem = getSalaryItemService(user).getUsingItem(); + List usingCodes = usingItem.getUsingCodes(); + + // 查询薪资项目 + List variableItemPOS = listByIds(itemIds); + if (CollectionUtils.isEmpty(variableItemPOS)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "参数错误,浮动薪资项目不存在或已被删除")); + } + List codes = SalaryEntityUtil.properties(variableItemPOS, VariableItemPO::getCode, Collectors.toList()); + if (CollectionUtils.containsAny(usingCodes, codes)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "公式正在使用该浮动薪资项目,不允许删除")); + } + // 查询浮动薪酬档案中已使用的浮动薪资项目 + List usingVariableItemIds = getVariableArchiveItemService(user).listUsingItems(); + if (CollectionUtils.containsAny(usingVariableItemIds, itemIds)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "浮动薪资档案中正在使用该薪资项目,不允许删除")); + } + itemIds.forEach(id -> getVariableItemMapper().delete(VariableItemPO.builder().id(id).build())); + } + + @Override + public VariableItemListDTO getDetail(Long id) { + if (id == null) { + return null; + } + VariableItemPO variableItemPO = getVariableItemMapper().getById(id); + return VariableItemListDTO.builder() + .id(variableItemPO.getId()) + .name(variableItemPO.getName()) + .dataType(variableItemPO.getDataType()) + .build(); + } +} diff --git a/src/com/engine/salary/sys/config/SysConfig.java b/src/com/engine/salary/sys/config/SysConfig.java new file mode 100644 index 000000000..3da7f8818 --- /dev/null +++ b/src/com/engine/salary/sys/config/SysConfig.java @@ -0,0 +1,23 @@ +package com.engine.salary.sys.config; + +import com.engine.salary.sys.entity.po.SalarySysConfPO; +import com.thoughtworks.xstream.annotations.XStreamAlias; +import com.thoughtworks.xstream.annotations.XStreamImplicit; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@XStreamAlias("SysConfig") +public class SysConfig { + + @XStreamImplicit + private List salarySysConfs; + +} diff --git a/src/com/engine/salary/sys/constant/SalarySysConstant.java b/src/com/engine/salary/sys/constant/SalarySysConstant.java new file mode 100644 index 000000000..311476ea3 --- /dev/null +++ b/src/com/engine/salary/sys/constant/SalarySysConstant.java @@ -0,0 +1,234 @@ +package com.engine.salary.sys.constant; + +/** + * 系统常量 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SalarySysConstant { + /** + * 自定义配置 + */ + public static final String CUSTOM_CODE = "custom"; + /** + * 排序规则标识 + */ + public static final String ORDER_RULE_CODE = "orderRule"; + /** + * 顺序标识 + */ + public static final String ASCORDESC_CODE = "ascOrDesc"; + + /** + * 定位人员规则标识 + */ + public static final String MATCH_EMPLOYEE_MODE = "matchEmployeeMode"; + + /** + * 核算合计功能开启标识 + */ + public static final String OPEN_ACCT_RESULT_SUM = "OPEN_ACCT_RESULT_SUM"; + + /** + * 是否显示脱敏表人员信息 + */ + public static final String DISPLAY_EMP_INFO_REPORT = "DISPLAY_EMP_INFO_REPORT"; + + /** + * 应用设置是否开启加密 + */ + public static final String OPEN_APPLICATION_ENCRYPT = "OPEN_APPLICATION_ENCRYPT"; + /** + * 加密后前缀 + */ + public static final String PRE_SIGN_ENCRYPT = "AES_"; + + /** + * 工资单员工加密后前缀 + */ + public static final String SALARY_BILL_PRE_SIGN_ENCRYPT = "HSE_"; + /** + * 锁的key + */ + public static final String AES_ENCRYPT_IN_PROGRESS = "AES_ENCRYPT_IN_PROGRESS"; + public static final String ENCRYPT_IN_PROGRESS = "ENCRYPT_PROGRESS_"; + + /** + * 需要申报功能 + */ + public static final String TAX_DECLARATION_FUNCTION = "taxDeclarationFunction"; + + /** + * 是否需要导入、编辑项目自动锁定conf_key + */ + public static final String EDIT_IMPORT_AUTO_LOCK = "EditImportAutoLock"; + + /** + * 薪资核算、社保福利核算人员规则 + */ + public static final String SALARY_ACCT_EMPLOYEE_RULE = "salaryAcctEmployeeRule"; + + /** + * 是否采用线程池,同步异步。空/1异步, 0同步 + */ + public static final String SALARY_ACCT_SYNC_TYPE = "SALARY_ACCT_SYNC_TYPE"; + + /** + * 工资单二次验证方式 + */ + public static final String SALARY_PAYROLL_CHECK_TYPE = "SALARY_PAYROLL_CHECK_TYPE"; + + /** + * 个税申报撤回 + */ + public static final String WITHDRAW_TAX_DECLARATION = "WITHDRAW_TAX_DECLARATION"; + + /** + * 删除薪资档案 + */ + public static final String SALARY_ARCHIVE_DELETE = "salaryArchiveDelete"; + + /** + * 工资单确认状态 + */ + public static final String SALARY_SEND_FEEDBACK = "SALARY_SEND_FEEDBACK"; + + /** + * 工资单反馈状态 + */ + public static final String SALARY_SEND_FEEDBACK_FK = "SALARY_SEND_FEEDBACK_FK"; + + /** + * 工资单反馈自动确认 + */ + public static final String SALARY_AUTO_ACK_DAYS = "SALARY_AUTO_ACK_DAYS"; + + /** + * 工资单反馈地址 + */ + public static final String SALARY_FEEDBACK_URL = "SALARY_FEEDBACK_URL"; + + /** + * 工资单反馈地址-移动端 + */ + public static final String SALARY_FEEDBACK_URL_MOBILE = "SALARY_FEEDBACK_URL_MOBILE"; + + /** + * 工资单查询限制 + */ + public static final String SALARY_BILL_VIEWING_LIMIT_MONTH = "SALARY_BILL_VIEWING_LIMIT_MONTH"; + + /** + * 工资单查询限制月份类型 + */ + public static final String SALARY_BILL_LIMIT_MONTH_TYPE = "SALARY_BILL_LIMIT_MONTH_TYPE"; + + /** + * 首次查看后多少分钟不能查看工资单 + */ + public static final String SALARY_BILL_BURNING_AFTER_READING_MIN = "SALARY_BILL_BURNING_AFTER_READING_MIN"; + + /** + * 核算固定列头数 + */ + public static final String SALARY_ACCT_FIXED_COLUMNS = "salaryAcctFixedColumns"; + + /** + * 应用设置是否福利档案基数区分个人和单位 + */ + public static final String WEL_BASE_DIFF_BY_PER_AND_COM = "welBaseDiffByPerAndCom"; + + /** + * 应用设置是否福利档案导入时,不符合上下限的基数调整为上限 /下限 + */ + public static final String WEL_BASE_AUTO_ADJUST = "welBaseAutoAdjust"; + + /** + * 我的薪资福利工资单显示状态 + */ + public static final String SALARY_SHOW_STATUS = "salaryShowStatus"; + + /** + * 我的薪资福利调薪记录显示状态 + */ + public static final String ADJUST_SHOW_STATUS = "adjustShowStatus"; + + /** + * 我的薪资福利工资单个税扣缴义务人显示状态 + */ + public static final String TAX_AGENT_SHOW_STATUS = "taxAgentShowStatus"; + + + /** + * 报表是否开启缓存,0:关闭 1:开启 + */ + public static final String REPORT_CACHE = "REPORT_CACHE"; + + /** + * 报表组织类型,null/0 :核算时组织信息 1:实时组织信息 + */ + public static final String REPORT_ORGANIZATIN_TYPE = "REPORT_ORGANIZATIN_TYPE"; + + /** + * 薪资明细页面显示类型 + */ + public static final String SALARY_DETAILS_REPORT_SHOW_TYPE = "SALARY_DETAILS_REPORT_SHOW_TYPE"; + + /** + * 主次账号开启标识 1开启 + */ + public static final String OPEN_SECONDARY_ACCOUNT = "openSecondaryAccount"; + + + /** + * 展示薪资核算审批设置按钮 + */ + public static final String SHOW_SALARY_ACCT_APPROVAL = "SHOW_SALARY_ACCT_APPROVAL"; + + /** + * 开启核算记录审批功能 + */ + public static final String SALARY_APPROVAL_STATUS = "SALARY_APPROVAL_STATUS"; + + /** + * 开启审批的核算记录允许手动归档 + */ + public static final String APPROVAL_CAN_MANUAL_FILE_STATUS = "APPROVAL_CAN_MANUAL_FILE_STATUS"; + + + /** + * 开启审批的核算记录允许重新核算 + */ + public static final String APPROVAL_CAN_RE_CALC_STATUS = "APPROVAL_CAN_RE_CALC_STATUS"; + + + /** + * 审批流程发起后允许修改核算数据 + */ + public static final String APPROVAL_CAN_EDIT_RESULT_STATUS = "APPROVAL_CAN_EDIT_RESULT_STATUS"; + + /** + * 是否采用组织快照,0:关闭 1:开启 + */ + public static final String SHOT_EMP_BTN = "SHOT_EMP_BTN"; + + /** + * 快照时间点 + */ + public static final String SHOT_EMP_TIME_TYPE = "SHOT_EMP_TIME_TYPE"; + + /** + * 是否采集考勤班次数据,0:关闭 1:开启 + */ + public static final String ATTENDANCE_SERIAL_COLLECTION_BTN = "ATTENDANCE_SERIAL_COLLECTION_BTN"; + + /** + * 报税日期类型,薪资所属月/税款所属期 + * 0:薪资所属月 1:税款所属期 + * 默认薪资所属月 + */ + public static final String TAX_DECLARATION_DATE_TYPE = "TAX_DECLARATION_DATE_TYPE"; +} diff --git a/src/com/engine/salary/sys/entity/param/AppSettingSaveParam.java b/src/com/engine/salary/sys/entity/param/AppSettingSaveParam.java new file mode 100644 index 000000000..c62cb40a7 --- /dev/null +++ b/src/com/engine/salary/sys/entity/param/AppSettingSaveParam.java @@ -0,0 +1,56 @@ +package com.engine.salary.sys.entity.param; + +import com.engine.salary.sys.enums.OpenEnum; +import com.engine.salary.util.valid.DataCheck; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 保存应用设置参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class AppSettingSaveParam { + + /** + * 是否打印日志 + * + * @see OpenEnum + */ + private String isLog; + + /** + * 是否开启核算结果合计列 + * + * @see OpenEnum + */ + @DataCheck(require = true,message = "是否开启核算结果合计列?") + private String openAcctResultSum; + + /** + * 是否开启加密设置 + */ + private String isOpenEncrypt; + + /** + * 是否关闭个税申报 + */ + private String operateTaxDeclaration; + + /** + * 是否显示脱敏表人员信息 + * @see OpenEnum + */ + @DataCheck(require = true,message = "是否显示脱敏表人员信息?") + private String displayEmpInfoReport; + +} diff --git a/src/com/engine/salary/sys/entity/param/MatchEmployeeModeSaveParam.java b/src/com/engine/salary/sys/entity/param/MatchEmployeeModeSaveParam.java new file mode 100644 index 000000000..76d478fda --- /dev/null +++ b/src/com/engine/salary/sys/entity/param/MatchEmployeeModeSaveParam.java @@ -0,0 +1,25 @@ +package com.engine.salary.sys.entity.param; + +import com.engine.salary.util.valid.DataCheck; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 保存人员定位规则参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class MatchEmployeeModeSaveParam { + + @DataCheck(require = true,message = "规则为空") + private String rule; +} diff --git a/src/com/engine/salary/sys/entity/param/OrderRuleParam.java b/src/com/engine/salary/sys/entity/param/OrderRuleParam.java new file mode 100644 index 000000000..c310ba043 --- /dev/null +++ b/src/com/engine/salary/sys/entity/param/OrderRuleParam.java @@ -0,0 +1,30 @@ +package com.engine.salary.sys.entity.param; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 保存排序规则参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class OrderRuleParam { + /** + * 排序规则 + */ + private String orderRule; + + /** + * 正序或者倒序 + */ + private String ascOrDesc; +} diff --git a/src/com/engine/salary/sys/entity/param/SalarySysConfQueryParam.java b/src/com/engine/salary/sys/entity/param/SalarySysConfQueryParam.java new file mode 100644 index 000000000..79501579b --- /dev/null +++ b/src/com/engine/salary/sys/entity/param/SalarySysConfQueryParam.java @@ -0,0 +1,29 @@ +package com.engine.salary.sys.entity.param; + +import com.engine.salary.common.BaseQueryParam; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SalarySysConfQueryParam extends BaseQueryParam { + + /** + * 标识 + */ + private String confKey; + + /** + * 值 + */ + private String confValue; + + /** + * 所属模块 + */ + private String module; +} diff --git a/src/com/engine/salary/sys/entity/param/UploadConfigParam.java b/src/com/engine/salary/sys/entity/param/UploadConfigParam.java new file mode 100644 index 000000000..6e104addc --- /dev/null +++ b/src/com/engine/salary/sys/entity/param/UploadConfigParam.java @@ -0,0 +1,25 @@ +package com.engine.salary.sys.entity.param; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 初始化薪酬配置 + *

Copyright: Copyright (c) 2024

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class UploadConfigParam { + + //上传文件id + String imageId; + +} diff --git a/src/com/engine/salary/sys/entity/po/SalarySysConfPO.java b/src/com/engine/salary/sys/entity/po/SalarySysConfPO.java new file mode 100644 index 000000000..bc75d7a95 --- /dev/null +++ b/src/com/engine/salary/sys/entity/po/SalarySysConfPO.java @@ -0,0 +1,91 @@ +package com.engine.salary.sys.entity.po; + + +import com.engine.salary.annotation.TableTitle; +import com.engine.salary.util.valid.DataCheck; +import com.engine.salary.util.valid.RuntimeTypeEnum; +import com.thoughtworks.xstream.annotations.XStreamAlias; +import com.thoughtworks.xstream.annotations.XStreamAsAttribute; +import com.thoughtworks.xstream.annotations.XStreamOmitField; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@XStreamAlias("SalarySysConf") +public class SalarySysConfPO { + + @DataCheck(require = true, runtime = RuntimeTypeEnum.UPDATE, message = "id为空") + @XStreamOmitField + private Long id; + /** + * 标识 + */ + @TableTitle(title = "标识", dataIndex = "confKey", key = "confKey") + @DataCheck(require = true, message = "标识为空") + @XStreamAlias("confKey") + @XStreamAsAttribute + private String confKey; + /** + * 值 + */ + @TableTitle(title = "值", dataIndex = "confValue", key = "confValue") + @DataCheck(require = true, message = "标识为空") + @XStreamAlias("confValue") + @XStreamAsAttribute + private String confValue; + /** + * 标题 + */ + @TableTitle(title = "标题", dataIndex = "title", key = "title") + @DataCheck(require = true, message = "标题为空") + @XStreamAlias("title") + @XStreamAsAttribute + private String title; + /** + * 所属模块 + */ + @TableTitle(title = "所属模块", dataIndex = "module", key = "module") + @XStreamAlias("module") + @XStreamAsAttribute + private String module; + /** + * 排序权重 + */ + @TableTitle(title = "排序权重", dataIndex = "orderWeight", key = "orderWeight") + @XStreamAlias("orderWeight") + @XStreamAsAttribute + private Integer orderWeight; + /** + * 描述 + */ + @TableTitle(title = "描述", dataIndex = "description", key = "description") + @XStreamAlias("description") + @XStreamAsAttribute + private String description; + /** + * 是否已删除,0否,1是 + */ + @XStreamAlias("deleteType") + @XStreamAsAttribute + private Integer deleteType; + + /** + * 创建时间 + */ + @XStreamAlias("createTime") + @XStreamAsAttribute + private Date createTime; + /** + * 修改时间 + */ + @XStreamAlias("updateTime") + @XStreamAsAttribute + private Date updateTime; +} \ No newline at end of file diff --git a/src/com/engine/salary/sys/entity/vo/AppSettingVO.java b/src/com/engine/salary/sys/entity/vo/AppSettingVO.java new file mode 100644 index 000000000..f4b9ac890 --- /dev/null +++ b/src/com/engine/salary/sys/entity/vo/AppSettingVO.java @@ -0,0 +1,88 @@ +package com.engine.salary.sys.entity.vo; + +import com.engine.salary.sys.enums.OpenEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 保存应用设置参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class AppSettingVO { + + /** + * 版本号 + */ + private String version; + + /** + * 是否打印日志 + * + * @see OpenEnum + */ + private String isLog; + + /** + * 是否开启核算结果合计列 + * + * @see OpenEnum + */ + private String openAcctResultSum; + + /** + * 是否开启加密设置 + */ + private String isOpenEncrypt; + + /** + * 是否开启个税申报功能 + */ + private String isOpenTaxDeclaration; + + /** + * 是否显示脱敏表人员信息 + * @see OpenEnum + */ + private String displayEmpInfoReport; + + /** + * 打开修改系统公式 + */ + private String openFormulaForcedEditing; + + /** + * 是否显示加密操作按钮 + */ + private String showEncryptOperationButton; + + /** + * 薪资核算、社保福利核算人员规则 + */ + private String salaryAcctEmployeeRule; + + /** + * 撤回个税申报表 + */ + private String withDrawTaxDeclaration; + + /** + * 薪资档案删除 + */ + private String salaryArchiveDelete; + + /** + * 工资单反馈 + */ + private String salarySendFeedback; + +} diff --git a/src/com/engine/salary/sys/entity/vo/OrderRuleVO.java b/src/com/engine/salary/sys/entity/vo/OrderRuleVO.java new file mode 100644 index 000000000..ea4a1deea --- /dev/null +++ b/src/com/engine/salary/sys/entity/vo/OrderRuleVO.java @@ -0,0 +1,22 @@ +package com.engine.salary.sys.entity.vo; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class OrderRuleVO { + /** + * 排序规则 + */ + private String orderRule = "dspOrder"; + + /** + * 正序或者倒序 + */ + private String ascOrDesc ="asc"; +} diff --git a/src/com/engine/salary/sys/entity/vo/UploadConfigResponse.java b/src/com/engine/salary/sys/entity/vo/UploadConfigResponse.java new file mode 100644 index 000000000..f15dda773 --- /dev/null +++ b/src/com/engine/salary/sys/entity/vo/UploadConfigResponse.java @@ -0,0 +1,30 @@ +package com.engine.salary.sys.entity.vo; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class UploadConfigResponse { + + private boolean finish; + + private List results; + + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + public static class Result { + String message; + List success; + List warning; + List error; + } +} diff --git a/src/com/engine/salary/sys/enums/AscOrDescEnum.java b/src/com/engine/salary/sys/enums/AscOrDescEnum.java new file mode 100644 index 000000000..0973a1a78 --- /dev/null +++ b/src/com/engine/salary/sys/enums/AscOrDescEnum.java @@ -0,0 +1,55 @@ +package com.engine.salary.sys.enums; + +import com.engine.salary.enums.BaseEnum; +import org.apache.commons.lang3.StringUtils; + +/** + * 排序枚举 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public enum AscOrDescEnum implements BaseEnum { + + ASC("asc", "正序", 1), + DESC("desc", "倒序", 1); + + private String value; + + private String defaultLabel; + + private int labelId; + + + AscOrDescEnum(String value, String defaultLabel, int labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + @Override + public String getValue() { + return value; + } + + @Override + public String getDefaultLabel() { + return defaultLabel; + } + + @Override + public Integer getLabelId() { + return labelId; + } + + public static AscOrDescEnum parseByValue(String value) { + for (AscOrDescEnum taxDeclarationFunctionEnum : AscOrDescEnum.values()) { + if (StringUtils.equals(taxDeclarationFunctionEnum.getValue(), value)) { + return taxDeclarationFunctionEnum; + } + } + return ASC; + } +} diff --git a/src/com/engine/salary/sys/enums/MatchEmployeeModeEnum.java b/src/com/engine/salary/sys/enums/MatchEmployeeModeEnum.java new file mode 100644 index 000000000..1536718cb --- /dev/null +++ b/src/com/engine/salary/sys/enums/MatchEmployeeModeEnum.java @@ -0,0 +1,53 @@ +package com.engine.salary.sys.enums; + +import com.engine.salary.enums.BaseEnum; +import org.apache.commons.lang3.StringUtils; + +/** + * 人员匹配规则枚举 + * @author songyang + **/ +public enum MatchEmployeeModeEnum implements BaseEnum { + + //"0"代表按照姓名+部门+手机号为条件的人员匹配方式,"1"代表按照工号为条件的人员匹配方式 + NAMEDEPMOBILEMATCH("0", "姓名-部门-手机号", 1), + WORKCODEMATCH("1", "工号", 1), + IDNO("2", "证件号码", 1); + + private String value; + + private String defaultLabel; + + private int labelId; + + + MatchEmployeeModeEnum(String value, String defaultLabel, int labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + @Override + public String getValue() { + return value; + } + + @Override + public String getDefaultLabel() { + return defaultLabel; + } + + @Override + public Integer getLabelId() { + return labelId; + } + + public static MatchEmployeeModeEnum parseByValue(String value) { + for (MatchEmployeeModeEnum matchEmployeeModeEnum : MatchEmployeeModeEnum.values()) { + if (StringUtils.equals(matchEmployeeModeEnum.getValue(), value)) { + return matchEmployeeModeEnum; + } + } + return NAMEDEPMOBILEMATCH; + } +} diff --git a/src/com/engine/salary/sys/enums/OpenEnum.java b/src/com/engine/salary/sys/enums/OpenEnum.java new file mode 100644 index 000000000..1707e2cc1 --- /dev/null +++ b/src/com/engine/salary/sys/enums/OpenEnum.java @@ -0,0 +1,55 @@ +package com.engine.salary.sys.enums; + +import com.engine.salary.enums.BaseEnum; +import org.apache.commons.lang3.StringUtils; + +/** + * 排序枚举 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public enum OpenEnum implements BaseEnum { + + OFF("0", "关闭", 1), + OPEN("1", "开启", 1); + + private String value; + + private String defaultLabel; + + private int labelId; + + + OpenEnum(String value, String defaultLabel, int labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + @Override + public String getValue() { + return value; + } + + @Override + public String getDefaultLabel() { + return defaultLabel; + } + + @Override + public Integer getLabelId() { + return labelId; + } + + public static OpenEnum parseByValue(String value) { + for (OpenEnum openEnum : OpenEnum.values()) { + if (StringUtils.equals(openEnum.getValue(), value)) { + return openEnum; + } + } + return OFF; + } +} diff --git a/src/com/engine/salary/sys/enums/OrderRuleEnum.java b/src/com/engine/salary/sys/enums/OrderRuleEnum.java new file mode 100644 index 000000000..2d60f13bf --- /dev/null +++ b/src/com/engine/salary/sys/enums/OrderRuleEnum.java @@ -0,0 +1,60 @@ +package com.engine.salary.sys.enums; + +import com.engine.salary.enums.BaseEnum; +import org.apache.commons.lang3.StringUtils; + +/** + * 排序规则枚举 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public enum OrderRuleEnum implements BaseEnum { + DSPORDER("e.dspOrder", "人员显示顺序", 1), + DEPTSHOWORDER("d.ShowOrder", "部门显示顺序", 1), + SUBCOMSHOWORDER("c.ShowOrder", "分部显示顺序", 1), + LASTNAME("e.lastName", "人员名称", 1), + DEPTNAME("d.departmentname", "部门名称", 1), + SUBCOMNAME("c.subcompanyname", "分部名称", 1), + SHOWORDEROFDEPTTREE("d.showOrderOfTree", "组织", 1), + WORKCODE("e.workcode", "工号", 1); + + private String value; + + private String defaultLabel; + + private int labelId; + + + OrderRuleEnum(String value, String defaultLabel, int labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + @Override + public String getValue() { + return value; + } + + @Override + public String getDefaultLabel() { + return defaultLabel; + } + + @Override + public Integer getLabelId() { + return labelId; + } + + public static OrderRuleEnum parseByValue(String value) { + for (OrderRuleEnum taxDeclarationFunctionEnum : OrderRuleEnum.values()) { + if (StringUtils.equals(taxDeclarationFunctionEnum.getValue(), value)) { + return taxDeclarationFunctionEnum; + } + } + return DSPORDER; + } +} diff --git a/src/com/engine/salary/sys/enums/PayrollCheckTypeEnum.java b/src/com/engine/salary/sys/enums/PayrollCheckTypeEnum.java new file mode 100644 index 000000000..266424adb --- /dev/null +++ b/src/com/engine/salary/sys/enums/PayrollCheckTypeEnum.java @@ -0,0 +1,55 @@ +package com.engine.salary.sys.enums; + +import com.engine.salary.enums.BaseEnum; +import org.apache.commons.lang3.StringUtils; + +/** + * 排序枚举 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public enum PayrollCheckTypeEnum implements BaseEnum { + + PWD("PWD", "密码验证", 1), + SMS("SMS", "短信验证", 1); + + private String value; + + private String defaultLabel; + + private int labelId; + + + PayrollCheckTypeEnum(String value, String defaultLabel, int labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + @Override + public String getValue() { + return value; + } + + @Override + public String getDefaultLabel() { + return defaultLabel; + } + + @Override + public Integer getLabelId() { + return labelId; + } + + public static PayrollCheckTypeEnum parseByValue(String value) { + for (PayrollCheckTypeEnum payrollCheckTypeEnum : PayrollCheckTypeEnum.values()) { + if (StringUtils.equals(payrollCheckTypeEnum.getValue(), value)) { + return payrollCheckTypeEnum; + } + } + return PWD; + } +} diff --git a/src/com/engine/salary/sys/enums/SalaryAcctEmployeeRuleEnum.java b/src/com/engine/salary/sys/enums/SalaryAcctEmployeeRuleEnum.java new file mode 100644 index 000000000..8f5120f9e --- /dev/null +++ b/src/com/engine/salary/sys/enums/SalaryAcctEmployeeRuleEnum.java @@ -0,0 +1,52 @@ +package com.engine.salary.sys.enums; + +import com.engine.salary.enums.BaseEnum; +import org.apache.commons.lang3.StringUtils; + +/** + * 薪资核算、社保福利核算人员匹配规则 + * @author songyang + **/ +public enum SalaryAcctEmployeeRuleEnum implements BaseEnum { + + //"0"代表根据最后缴纳日期判断(包含停薪(停缴)列表),"1"代表根据最后缴纳日期判断(不包含停薪(停缴)列表) + BYPAYENDTIME("0", "发薪员工(在缴员工)、从发薪(在缴)至停缴(停薪)列表员工", 1), + BYSTATUS("1", "发薪员工(在缴员工)列表" , 1); + + private String value; + + private String defaultLabel; + + private int labelId; + + + SalaryAcctEmployeeRuleEnum(String value, String defaultLabel, int labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + @Override + public String getValue() { + return value; + } + + @Override + public String getDefaultLabel() { + return defaultLabel; + } + + @Override + public Integer getLabelId() { + return labelId; + } + + public static SalaryAcctEmployeeRuleEnum parseByValue(String value) { + for (SalaryAcctEmployeeRuleEnum salaryAcctEmployeeRuleEnum : SalaryAcctEmployeeRuleEnum.values()) { + if (StringUtils.equals(salaryAcctEmployeeRuleEnum.getValue(), value)) { + return salaryAcctEmployeeRuleEnum; + } + } + return BYPAYENDTIME; + } +} diff --git a/src/com/engine/salary/sys/enums/ShotTimeTypeEnum.java b/src/com/engine/salary/sys/enums/ShotTimeTypeEnum.java new file mode 100644 index 000000000..a375c2314 --- /dev/null +++ b/src/com/engine/salary/sys/enums/ShotTimeTypeEnum.java @@ -0,0 +1,57 @@ +package com.engine.salary.sys.enums; + +import com.engine.salary.enums.BaseEnum; +import org.apache.commons.lang3.StringUtils; + +/** + * 快照时间点类型 + *

Copyright: Copyright (c) 2024

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public enum ShotTimeTypeEnum implements BaseEnum { + + salaryFirstDate("salaryFirstDate", "薪资所属月第一天", 1), + salaryLastDate("salaryLastDate", "薪资所属月最后一天", 1), + salaryCycleFromDate("salaryCycleFromDate", "薪资周期起始日期", 1), + salaryCycleEndDate("salaryCycleEndDate", "薪资周期结束日期", 1); + + private String value; + + private String defaultLabel; + + private int labelId; + + + ShotTimeTypeEnum(String value, String defaultLabel, int labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + @Override + public String getValue() { + return value; + } + + @Override + public String getDefaultLabel() { + return defaultLabel; + } + + @Override + public Integer getLabelId() { + return labelId; + } + + public static ShotTimeTypeEnum parseByValue(String value) { + for (ShotTimeTypeEnum e : ShotTimeTypeEnum.values()) { + if (StringUtils.equals(e.getValue(), value)) { + return e; + } + } + return salaryCycleFromDate; + } +} diff --git a/src/com/engine/salary/sys/enums/TaxDeclarationFunctionEnum.java b/src/com/engine/salary/sys/enums/TaxDeclarationFunctionEnum.java new file mode 100644 index 000000000..9ab77c7fd --- /dev/null +++ b/src/com/engine/salary/sys/enums/TaxDeclarationFunctionEnum.java @@ -0,0 +1,55 @@ +package com.engine.salary.sys.enums; + +import com.engine.salary.enums.BaseEnum; +import org.apache.commons.lang3.StringUtils; + +/** + * 个税计算启用状态 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public enum TaxDeclarationFunctionEnum implements BaseEnum { + OPEN("1", "开启", 1), + CLOSURE("0", "关闭", 1), + REBOOT("2", "重启", 1); + + private String value; + + private String defaultLabel; + + private int labelId; + + + TaxDeclarationFunctionEnum(String value, String defaultLabel, int labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + @Override + public String getValue() { + return value; + } + + @Override + public String getDefaultLabel() { + return defaultLabel; + } + + @Override + public Integer getLabelId() { + return labelId; + } + + public static TaxDeclarationFunctionEnum parseByValue(String value) { + for (TaxDeclarationFunctionEnum taxDeclarationFunctionEnum : TaxDeclarationFunctionEnum.values()) { + if (StringUtils.equals(taxDeclarationFunctionEnum.getValue(), value)) { + return taxDeclarationFunctionEnum; + } + } + return null; + } +} diff --git a/src/com/engine/salary/sys/service/SalarySysConfService.java b/src/com/engine/salary/sys/service/SalarySysConfService.java new file mode 100644 index 000000000..6b78ceca2 --- /dev/null +++ b/src/com/engine/salary/sys/service/SalarySysConfService.java @@ -0,0 +1,148 @@ +package com.engine.salary.sys.service; + +import com.engine.salary.sys.config.SysConfig; +import com.engine.salary.sys.entity.param.AppSettingSaveParam; +import com.engine.salary.sys.entity.param.OrderRuleParam; +import com.engine.salary.sys.entity.po.SalarySysConfPO; +import com.engine.salary.sys.entity.vo.AppSettingVO; +import com.engine.salary.sys.entity.vo.OrderRuleVO; +import com.engine.salary.sys.entity.vo.UploadConfigResponse; +import com.engine.salary.sys.enums.TaxDeclarationFunctionEnum; + +import java.util.Date; +import java.util.List; +import java.util.Map; + +/** + * 薪酬系统配置类 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public interface SalarySysConfService { + + + /** + * 操作是否需要申报功能 + * + * @param flag 开启 0/关闭 1/重新开启 2 + * @return 执行结果 + */ + boolean operateTaxDeclarationFunction(TaxDeclarationFunctionEnum flag); + + /** + * 是否关闭了个税申报功能 + * @return BOOLEAN + */ + TaxDeclarationFunctionEnum getTaxDeclaration(); + + SalarySysConfPO getOneByCode(String code); + + String getValueByCode(String code); + + List listSome(SalarySysConfPO build); + + void save(SalarySysConfPO salarySysConfPO); + + void update(SalarySysConfPO salarySysConfPO); + + SalarySysConfPO getById(Long id); + + void updateByCode(SalarySysConfPO salarySysConfPO); + + OrderRuleVO orderRule(); + + void updateOrderRule(OrderRuleParam param); + + void saveMatchEmployeeModeRule(String rule); + + + /** + * 保存应用设置 + * @param param + */ + void saveAppSetting(AppSettingSaveParam param); + + /** + * 应用设置 + * @return + */ + AppSettingVO appSetting(); + + /** + * 保存加密设置 + * @param appSettingSaveParam + * @return + */ + Map saveEncryptSetting(AppSettingSaveParam appSettingSaveParam); + + /** + * 加密进度 + * @param progressId + * @return + */ + Map getEncryptProgress(String progressId); + + boolean encryptIsOpen(); + void cleanEncryptStatus(); + + /** + * @description 获取个税申报功能重启日期 + * @return Date + * @author Harryxzy + * @date 2022/11/9 21:07 + */ + Date getTaxDeclarationRebootDate(); + + /** + * 保存薪资核算、社保福利核算人员规则 + * @param rule + */ + void saveSalaryAcctEmployeeRule(String rule); + + /** + * 个税申报撤回开关 + * @param param + */ + void saveWithDrawTaxDeclaration(SalarySysConfPO param); + + /** + * 保存档案删除规则 + * @param setting + */ + void saveArchiveDelete(String setting); + + /** + * 保存或者更新 + * @param salarySysConfPO + */ + void operate(SalarySysConfPO salarySysConfPO); + + /** + * 保存工资单反馈 + * @param param + */ + void saveSalarySendFeedback(SalarySysConfPO param); + + /** + * 根据code返回list + * @param codes + * @return + */ + List getListByCodes(List codes); + + /** + * 保存或者修改应用设置 + * @param confValue + * @param confKey + * @param title + * @param app + */ + void saveSettingByType(String confValue, String confKey, String title, String app); + + SysConfig getConfig(); + + UploadConfigResponse.Result parseConfig(SysConfig config); +} diff --git a/src/com/engine/salary/sys/service/impl/SalarySysConfServiceImpl.java b/src/com/engine/salary/sys/service/impl/SalarySysConfServiceImpl.java new file mode 100644 index 000000000..b4aa8e526 --- /dev/null +++ b/src/com/engine/salary/sys/service/impl/SalarySysConfServiceImpl.java @@ -0,0 +1,1285 @@ +package com.engine.salary.sys.service.impl; + +import cn.hutool.core.collection.CollectionUtil; +import com.api.formmode.mybatis.util.SqlProxyHandle; +import com.cloudstore.dev.api.util.Util_DataCache; +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.encrypt.AESEncryptUtil; +import com.engine.salary.encrypt.EncryptUtil; +import com.engine.salary.entity.datacollection.AddUpDeduction; +import com.engine.salary.entity.datacollection.AddUpSituation; +import com.engine.salary.entity.datacollection.po.OtherDeductionPO; +import com.engine.salary.entity.datacollection.po.SpecialAddDeductionPO; +import com.engine.salary.entity.datacollection.po.VariableArchiveItemPO; +import com.engine.salary.entity.salaryacct.po.ExcelAcctResultPO; +import com.engine.salary.entity.salaryacct.po.SalaryAcctResultPO; +import com.engine.salary.entity.salaryarchive.po.SalaryArchiveItemPO; +import com.engine.salary.entity.siaccount.po.ExcelInsuranceDetailPO; +import com.engine.salary.entity.siaccount.po.InsuranceAccountBatchPO; +import com.engine.salary.entity.siaccount.po.InsuranceAccountDetailPO; +import com.engine.salary.entity.siarchives.po.InsuranceArchivesFundSchemePO; +import com.engine.salary.entity.siarchives.po.InsuranceArchivesOtherSchemePO; +import com.engine.salary.entity.siarchives.po.InsuranceArchivesSocialSchemePO; +import com.engine.salary.entity.sischeme.po.InsuranceSchemeDetailPO; +import com.engine.salary.entity.taxdeclaration.po.TaxDeclarationDetailPO; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.mapper.archive.SalaryArchiveItemMapper; +import com.engine.salary.mapper.datacollection.*; +import com.engine.salary.mapper.salaryacct.ExcelAcctResultMapper; +import com.engine.salary.mapper.salaryacct.SalaryAcctResultMapper; +import com.engine.salary.mapper.siaccount.ExcelInsuranceDetailMapper; +import com.engine.salary.mapper.siaccount.InsuranceAccountBatchMapper; +import com.engine.salary.mapper.siaccount.InsuranceAccountDetailMapper; +import com.engine.salary.mapper.siarchives.FundSchemeMapper; +import com.engine.salary.mapper.siarchives.OtherSchemeMapper; +import com.engine.salary.mapper.siarchives.SocialSchemeMapper; +import com.engine.salary.mapper.sischeme.InsuranceSchemeDetailMapper; +import com.engine.salary.mapper.sys.SalarySysConfMapper; +import com.engine.salary.mapper.taxdeclaration.TaxDeclarationDetailMapper; +import com.engine.salary.service.VariableArchiveItemService; +import com.engine.salary.service.impl.VariableArchiveItemServiceImpl; +import com.engine.salary.sys.config.SysConfig; +import com.engine.salary.sys.constant.SalarySysConstant; +import com.engine.salary.sys.entity.param.AppSettingSaveParam; +import com.engine.salary.sys.entity.param.OrderRuleParam; +import com.engine.salary.sys.entity.po.SalarySysConfPO; +import com.engine.salary.sys.entity.vo.AppSettingVO; +import com.engine.salary.sys.entity.vo.OrderRuleVO; +import com.engine.salary.sys.entity.vo.UploadConfigResponse; +import com.engine.salary.sys.enums.*; +import com.engine.salary.sys.service.SalarySysConfService; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.db.IdGenerator; +import com.engine.salary.util.db.MapperProxyFactory; +import com.google.common.collect.Lists; +import com.weaver.util.threadPool.ThreadPoolUtil; +import com.weaver.util.threadPool.constant.ModulePoolEnum; +import com.weaver.util.threadPool.entity.LocalRunnable; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.ibatis.session.SqlSession; +import weaver.conn.mybatis.MyBatisFactory; +import weaver.general.BaseBean; +import weaver.hrm.User; + +import java.util.*; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Future; +import java.util.stream.Collectors; + +import static com.engine.salary.sys.constant.SalarySysConstant.*; +import static java.util.concurrent.Executors.newFixedThreadPool; + +/** + * 薪酬系统配置类 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Slf4j +public class SalarySysConfServiceImpl extends Service implements SalarySysConfService { + + private static volatile Boolean encryptStatus = null; + + private EncryptUtil encryptUtil = new EncryptUtil(); + + private SalarySysConfMapper getSalarySysConfMapper() { + return SqlProxyHandle.getProxy(SalarySysConfMapper.class); + } + + private static final ExecutorService fixedThreadPool = newFixedThreadPool(3); + + private SalaryAcctResultMapper getSalaryAcctResultMapper() { + return MapperProxyFactory.getProxy(SalaryAcctResultMapper.class); + } + + private ExcelAcctResultMapper getExcelAcctResultMapper() { + return MapperProxyFactory.getProxy(ExcelAcctResultMapper.class); + } + + private TaxDeclarationDetailMapper getTaxDeclarationDetailMapper() { + return MapperProxyFactory.getProxy(TaxDeclarationDetailMapper.class); + } + + private InsuranceSchemeDetailMapper getInsuranceSchemeDetailMapper() { + return MapperProxyFactory.getProxy(InsuranceSchemeDetailMapper.class); + } + + private SocialSchemeMapper getSocialSchemeMapper() { + return MapperProxyFactory.getProxy(SocialSchemeMapper.class); + } + + private FundSchemeMapper getFundSchemeMapper() { + return MapperProxyFactory.getProxy(FundSchemeMapper.class); + } + + private OtherSchemeMapper getOtherSchemeMapper() { + return MapperProxyFactory.getProxy(OtherSchemeMapper.class); + } + + private InsuranceAccountBatchMapper getInsuranceAccountBatchMapper() { + return MapperProxyFactory.getProxy(InsuranceAccountBatchMapper.class); + } + + private InsuranceAccountDetailMapper getInsuranceAccountDetailMapper() { + return MapperProxyFactory.getProxy(InsuranceAccountDetailMapper.class); + } + + private SalaryArchiveItemMapper getSalaryArchiveItemMapper() { + return MapperProxyFactory.getProxy(SalaryArchiveItemMapper.class); + } + + private AddUpDeductionMapper getAddUpDeductionMapper() { + return MapperProxyFactory.getProxy(AddUpDeductionMapper.class); + } + + private OtherDeductionMapper getOtherDeductionMapper() { + return MapperProxyFactory.getProxy(OtherDeductionMapper.class); + } + + private AddUpSituationMapper getAddUpSituationMapper() { + return MapperProxyFactory.getProxy(AddUpSituationMapper.class); + } + + private SpecialAddDeductionMapper getSpecialAddDeductionMapper() { + return MapperProxyFactory.getProxy(SpecialAddDeductionMapper.class); + } + + private ExcelInsuranceDetailMapper getExcelInsuranceDetailMapper() { + return MapperProxyFactory.getProxy(ExcelInsuranceDetailMapper.class); + } + + private SalarySysConfService getSalarySysConfService(User user) { + return ServiceUtil.getService(SalarySysConfServiceImpl.class, user); + } + + private VariableArchiveItemService getVariableArchiveItemService(User user) { + return ServiceUtil.getService(VariableArchiveItemServiceImpl.class, user); + } + + /** + * 操作是否需要申报功能 + * + * @param flag 开启 0/关闭 1/重新开启 2 + * @return 执行结果 + */ + @Override + public boolean operateTaxDeclarationFunction(TaxDeclarationFunctionEnum flag) { + Date date = new Date(); + SalarySysConfPO taxDeclarationFunction = getSalarySysConfMapper().getOneByCode(TAX_DECLARATION_FUNCTION); + if (taxDeclarationFunction == null) { + taxDeclarationFunction = SalarySysConfPO.builder().id(IdGenerator.generate()).confKey(TAX_DECLARATION_FUNCTION).confValue(flag.getValue()).title(flag.getDefaultLabel()).module("taxDeclaration").orderWeight(0).createTime(date).updateTime(date).deleteType(0).build(); + getSalarySysConfMapper().insertIgnoreNull(taxDeclarationFunction); + } else { + TaxDeclarationFunctionEnum oldFunctionEnum = TaxDeclarationFunctionEnum.parseByValue(taxDeclarationFunction.getConfValue()); + //不改变 + if (flag == oldFunctionEnum) { + return true; + } + //关闭 + if (flag == TaxDeclarationFunctionEnum.CLOSURE) { + taxDeclarationFunction.setConfValue(flag.getValue()); + taxDeclarationFunction.setTitle(flag.getDefaultLabel()); + taxDeclarationFunction.setUpdateTime(new Date()); + } + //重启 (从关闭到开启) + if (flag == TaxDeclarationFunctionEnum.OPEN && oldFunctionEnum == TaxDeclarationFunctionEnum.CLOSURE) { + taxDeclarationFunction.setConfValue(TaxDeclarationFunctionEnum.REBOOT.getValue()); + taxDeclarationFunction.setTitle(TaxDeclarationFunctionEnum.REBOOT.getDefaultLabel()); + taxDeclarationFunction.setUpdateTime(new Date()); + } + getSalarySysConfMapper().updateIgnoreNull(taxDeclarationFunction); + } + return true; + } + + /** + * @return Boolean + * @description 获取申报功能状态 + * @author Harryxzy + * @date 2022/11/7 17:05 + */ + public TaxDeclarationFunctionEnum getTaxDeclaration() { + SalarySysConfPO taxDeclarationFunction = getOneByCode(TAX_DECLARATION_FUNCTION); + if (taxDeclarationFunction == null) { + // 默认开启 + return TaxDeclarationFunctionEnum.OPEN; + } + TaxDeclarationFunctionEnum taxDeclarationFunctionEnum = TaxDeclarationFunctionEnum.parseByValue(taxDeclarationFunction.getConfValue()); + return taxDeclarationFunctionEnum; + } + + + @Override + public SalarySysConfPO getOneByCode(String code) { + return getSalarySysConfMapper().getOneByCode(code); + } + + @Override + public String getValueByCode(String code) { + SalarySysConfPO confPO = getSalarySysConfMapper().getOneByCode(code); + return confPO == null ? "" : confPO.getConfValue(); + } + + @Override + public List listSome(SalarySysConfPO po) { + return getSalarySysConfMapper().listSome(po); + } + + @Override + public void save(SalarySysConfPO salarySysConfPO) { + salarySysConfPO.setId(IdGenerator.generate()); + salarySysConfPO.setUpdateTime(new Date()); + salarySysConfPO.setCreateTime(new Date()); + salarySysConfPO.setDeleteType(0); + salarySysConfPO.setOrderWeight(0); + salarySysConfPO.setModule(CUSTOM_CODE); + + getSalarySysConfMapper().insertIgnoreNull(salarySysConfPO); + } + + @Override + public void update(SalarySysConfPO salarySysConfPO) { + SalarySysConfPO po = getSalarySysConfMapper().getById(salarySysConfPO.getId()); + if (po == null) { + throw new SalaryRunTimeException("系统配置不存在"); + } + salarySysConfPO.setUpdateTime(new Date()); + getSalarySysConfMapper().updateIgnoreNull(salarySysConfPO); + } + + @Override + public SalarySysConfPO getById(Long id) { + SalarySysConfPO po = getSalarySysConfMapper().getById(id); + if (po == null) { + throw new SalaryRunTimeException("系统配置不存在"); + } + return po; + } + + @Override + public void updateByCode(SalarySysConfPO po) { + SalarySysConfPO sysConfPO = getSalarySysConfMapper().getOneByCode(po.getConfKey()); + if (sysConfPO == null) { + throw new SalaryRunTimeException("系统配置不存在"); + } + sysConfPO.setConfValue(po.getConfValue()); + sysConfPO.setUpdateTime(new Date()); + getSalarySysConfMapper().updateIgnoreNull(sysConfPO); + + } + + @Override + public OrderRuleVO orderRule() { + SalarySysConfPO rulePO = getSalarySysConfMapper().getOneByCode(ORDER_RULE_CODE); + SalarySysConfPO orderPO = getSalarySysConfMapper().getOneByCode(ASCORDESC_CODE); + OrderRuleVO orderRuleVO = OrderRuleVO.builder().build(); + if (rulePO == null) { + orderRuleVO.setOrderRule(OrderRuleEnum.DSPORDER.getValue()); + } else { + orderRuleVO.setOrderRule(OrderRuleEnum.parseByValue(rulePO.getConfValue()).getValue()); + } + if (orderPO == null) { + orderRuleVO.setAscOrDesc(AscOrDescEnum.ASC.getValue()); + } else { + orderRuleVO.setAscOrDesc(AscOrDescEnum.parseByValue(orderPO.getConfValue()).getValue()); + } + return orderRuleVO; + } + + @Override + public void updateOrderRule(OrderRuleParam param) { + if (param == null || OrderRuleEnum.parseByValue(param.getOrderRule()) == null || AscOrDescEnum.parseByValue(param.getAscOrDesc()) == null) { + throw new SalaryRunTimeException("配置内容异常!"); + } + + //更新排序规则 + SalarySysConfPO orderRulePo = getSalarySysConfMapper().getOneByCode(ORDER_RULE_CODE); + if (orderRulePo == null) { + SalarySysConfPO build = SalarySysConfPO.builder() + .id(IdGenerator.generate()) + .confKey(ORDER_RULE_CODE) + .confValue(param.getOrderRule()) + .title("排序规则") + .orderWeight(0) + .module("basic") + .updateTime(new Date()) + .createTime(new Date()) + .deleteType(0) + .build(); + getSalarySysConfMapper().insertIgnoreNull(build); + } else { + orderRulePo.setConfValue(param.getOrderRule()); + orderRulePo.setUpdateTime(new Date()); + getSalarySysConfMapper().updateIgnoreNull(orderRulePo); + } + + //更新顺序配置 + SalarySysConfPO ascOrDescPo = getSalarySysConfMapper().getOneByCode(ASCORDESC_CODE); + if (ascOrDescPo == null) { + SalarySysConfPO build = SalarySysConfPO.builder() + .id(IdGenerator.generate()) + .confKey(ASCORDESC_CODE) + .confValue(param.getAscOrDesc()) + .title("排序顺序") + .orderWeight(0) + .module("basic") + .updateTime(new Date()) + .createTime(new Date()) + .deleteType(0) + .build(); + getSalarySysConfMapper().insertIgnoreNull(build); + } else { + ascOrDescPo.setConfValue(param.getAscOrDesc()); + ascOrDescPo.setUpdateTime(new Date()); + getSalarySysConfMapper().updateIgnoreNull(ascOrDescPo); + } + } + + @Override + public void saveMatchEmployeeModeRule(String rule) { + if (MatchEmployeeModeEnum.parseByValue(rule) == null) { + throw new SalaryRunTimeException("无效规则!"); + } + + saveSettingByType(rule, MATCH_EMPLOYEE_MODE, "定位人员规则", "basic"); + } + + @Override + public void saveAppSetting(AppSettingSaveParam param) { + String openAcctResultSum = param.getOpenAcctResultSum(); + saveSettingByType(openAcctResultSum, OPEN_ACCT_RESULT_SUM, "开启核算结果合并", "app"); + saveSettingByType(param.getDisplayEmpInfoReport(), DISPLAY_EMP_INFO_REPORT, "是否显示脱敏表人员信息", "app"); + } + + @Override + public Map saveEncryptSetting(AppSettingSaveParam param) { + Map resultMap = new HashMap<>(); + resultMap.put("isSuccess", true); + String progressId = UUID.randomUUID().toString(); + resultMap.put("progressId", progressId); + SalarySysConfPO sysConfPo = getOneByCode(SalarySysConstant.OPEN_APPLICATION_ENCRYPT); + if (sysConfPo != null && sysConfPo.getConfValue().equals(param.getIsOpenEncrypt())) { + return resultMap; + } else if (sysConfPo == null && OpenEnum.OPEN.getValue().equals(param.getIsOpenEncrypt())) { + return resultMap; + } + try { + if (Util_DataCache.getObjVal(AES_ENCRYPT_IN_PROGRESS) != null) { + resultMap.put("msg", "数据库处理上次操作中,请稍后操作。"); + return resultMap; + } + Util_DataCache.setObjVal(AES_ENCRYPT_IN_PROGRESS, 1); + Util_DataCache.setObjVal(ENCRYPT_IN_PROGRESS + progressId, "in_progress"); + String isOpenEncrypt = param.getIsOpenEncrypt(); + if (StringUtils.isNotEmpty(isOpenEncrypt)) { + if (isOpenEncrypt.equals(OpenEnum.OPEN.getValue())) { + //对数据库数据加解密 + ThreadPoolUtil.fixedPoolExecute(ModulePoolEnum.erkai, "saveEncryptSetting", new LocalRunnable() { + @Override + public void execute() { + updateEncrypt(isOpenEncrypt); + Boolean aBoolean = encryptOrDecryptDbWithAsync(isOpenEncrypt, progressId); + } + }); + } else if (isOpenEncrypt.equals(OpenEnum.OFF.getValue())) { + ThreadPoolUtil.fixedPoolExecute(ModulePoolEnum.erkai, "saveEncryptSetting", new LocalRunnable() { + @Override + public void execute() { + Boolean aBoolean = encryptOrDecryptDbWithAsync(isOpenEncrypt, progressId); + updateEncrypt(isOpenEncrypt); + } + }); + //不要调换方法的位置 + } + } + Util_DataCache.clearVal(AES_ENCRYPT_IN_PROGRESS); + resultMap.put("isSuccess", true); + return resultMap; + } catch (Exception e) { + Util_DataCache.clearVal(AES_ENCRYPT_IN_PROGRESS); + resultMap.put("isSuccess", false); + resultMap.put("msg", "系统异常请联系管理员"); + return resultMap; + } + } + + @Override + public boolean encryptIsOpen() { + if (encryptStatus == null) { + SalarySysConfPO sysConfPo = getOneByCode(SalarySysConstant.OPEN_APPLICATION_ENCRYPT); + if (sysConfPo != null && sysConfPo.getConfValue().equals(OpenEnum.OFF.getValue())) { + encryptStatus = false; + } else { + encryptStatus = true; + } + } + return encryptStatus; + } + + @Override + public void cleanEncryptStatus() { + encryptStatus = null; + } + + + @Override + public Map getEncryptProgress(String progressId) { + Map resultMap = new HashMap<>(); + String progressStatue = (String) Util_DataCache.getObjVal(ENCRYPT_IN_PROGRESS + progressId); + if (StringUtils.isNotEmpty(progressStatue)) { + resultMap.put("progress_statue", progressStatue); + } else { + resultMap.put("progress_statue", "success"); + } + return resultMap; + } + + @Override + public Date getTaxDeclarationRebootDate() { + Date date = getSalarySysConfMapper().getTaxDeclarationRebootDate(); + return date; + } + + @Override + public void saveSalaryAcctEmployeeRule(String rule) { + if (MatchEmployeeModeEnum.parseByValue(rule) == null) { + throw new SalaryRunTimeException("无效规则!"); + } + + saveSettingByType(rule, SALARY_ACCT_EMPLOYEE_RULE, "薪资、社保福利核算包含人员规则", "basic"); + } + + @Override + public void saveWithDrawTaxDeclaration(SalarySysConfPO param) { + if (StringUtils.isBlank(param.getConfValue())) { + throw new SalaryRunTimeException("无效规则!"); + } + saveSettingByType(param.getConfValue(), WITHDRAW_TAX_DECLARATION, "个税申报撤回", "basic"); + } + + @Override + public void saveArchiveDelete(String setting) { + if (StringUtils.isBlank(setting)) { + throw new SalaryRunTimeException("无效规则!"); + } + saveSettingByType(setting, SALARY_ARCHIVE_DELETE, "薪资、社保福利档案删除规则", "basic"); + } + + @Override + public void operate(SalarySysConfPO salarySysConfPO) { + saveSettingByType(salarySysConfPO.getConfValue(), salarySysConfPO.getConfKey(), salarySysConfPO.getTitle(), salarySysConfPO.getModule()); + } + + @Override + public void saveSalarySendFeedback(SalarySysConfPO param) { + if (StringUtils.isBlank(param.getConfValue())) { + throw new SalaryRunTimeException("无效规则!"); + } + saveSettingByType(param.getConfValue(), SALARY_SEND_FEEDBACK, "工资单反馈", "basic"); + } + + @Override + public List getListByCodes(List codes) { + if (CollectionUtils.isEmpty(codes)) { + return Collections.emptyList(); + } + return getSalarySysConfMapper().getListByCodes(codes); + } + + /** + * 保存或者修改应用设置 + * + * @param confValue + * @param confKey + * @param title + * @param app + */ + @Override + public void saveSettingByType(String confValue, String confKey, String title, String app) { + SalarySysConfPO po = getOneByCode(confKey); + if (po == null) { + SalarySysConfPO build = SalarySysConfPO.builder() + .id(IdGenerator.generate()) + .confKey(confKey) + .confValue(confValue) + .title(title) + .orderWeight(0) + .module(app) + .updateTime(new Date()) + .createTime(new Date()) + .deleteType(0) + .build(); + getSalarySysConfMapper().insertIgnoreNull(build); + } else { + po.setConfValue(confValue); + po.setUpdateTime(new Date()); + getSalarySysConfMapper().updateIgnoreNull(po); + } + } + + @Override + public SysConfig getConfig() { + SysConfig sysConfig = new SysConfig(); + List salarySysConfPOS = getSalarySysConfMapper().listAll(); + //去除加密配置 + salarySysConfPOS = salarySysConfPOS.stream().filter(po -> !po.getConfKey().equals(OPEN_APPLICATION_ENCRYPT)).collect(Collectors.toList()); + sysConfig.setSalarySysConfs(salarySysConfPOS); + return sysConfig; + } + + @Override + public UploadConfigResponse.Result parseConfig(SysConfig config) { + UploadConfigResponse.Result result = UploadConfigResponse.Result.builder() + .message("系统配置加载完毕") + .success(new ArrayList<>()) + .warning(new ArrayList<>()) + .error(new ArrayList<>()) + .build(); + + List salarySysConfs = config.getSalarySysConfs(); + if (CollectionUtil.isNotEmpty((salarySysConfs))) { + + salarySysConfs.forEach(po -> { + try { + SalarySysConfPO sysConfPO = getSalarySysConfMapper().getOneByCode(po.getConfKey()); + if (sysConfPO == null) { + po.setId(IdGenerator.generate()); + getSalarySysConfMapper().insertIgnoreNull(po); + } else { + sysConfPO.setConfValue(po.getConfValue()); + getSalarySysConfMapper().updateIgnoreNull(sysConfPO); + } + result.getSuccess().add(String.format("[%s]配置,key:[%s],value:[%s]", po.getTitle(), po.getConfKey(), po.getConfValue())); + } catch (Exception e) { + log.error(String.format("错误,[%s]配置加载异常,key:[%s],value:[%s]", po.getTitle(), po.getConfKey(), po.getConfValue()), e); + result.getError().add(String.format("错误,[%s]配置加载异常,key:[%s],value:[%s],原因:%s", po.getTitle(), po.getConfKey(), po.getConfValue(), e.getMessage())); + } + }); + } + + return result; + } + + /** + * 开启/关闭加解密 + * + * @param confValue + */ + public void updateEncrypt(String confValue) { + SalarySysConfPO po = getOneByCode(OPEN_APPLICATION_ENCRYPT); + String title = "1".equals(confValue) ? "开启加密设置" : "关闭加密设置"; + if (po == null) { + SalarySysConfPO build = SalarySysConfPO.builder() + .id(IdGenerator.generate()) + .confKey(OPEN_APPLICATION_ENCRYPT) + .confValue(confValue) + .title(title) + .orderWeight(0) + .module("app") + .updateTime(new Date()) + .createTime(new Date()) + .deleteType(0) + .build(); + getSalarySysConfMapper().insertIgnoreNull(build); + } else { + po.setConfValue(confValue); + po.setTitle(title); + po.setUpdateTime(new Date()); + getSalarySysConfMapper().updateIgnoreNull(po); + } + //重新获取加解密 + cleanEncryptStatus(); + } + + @Override + public AppSettingVO appSetting() { + AppSettingVO appSettingVO = AppSettingVO.builder().build(); + //返回按钮状态 + SalarySysConfPO condition = new SalarySysConfPO(); + condition.setDeleteType(0); + List salarySysConfPOS = getSalarySysConfMapper().listSome(condition); + if (CollectionUtils.isNotEmpty(salarySysConfPOS)) { + salarySysConfPOS.forEach(salarySysConfPO -> { + switch (salarySysConfPO.getConfKey()) { + case OPEN_ACCT_RESULT_SUM: + appSettingVO.setOpenAcctResultSum(salarySysConfPO.getConfValue()); + break; + case OPEN_APPLICATION_ENCRYPT: + appSettingVO.setIsOpenEncrypt(salarySysConfPO.getConfValue()); + break; + case DISPLAY_EMP_INFO_REPORT: + appSettingVO.setDisplayEmpInfoReport(salarySysConfPO.getConfValue()); + break; + default: + break; + } + }); + } + + Map salarySysConfMap = SalaryEntityUtil.convert2Map(salarySysConfPOS, SalarySysConfPO::getConfKey); + SalarySysConfPO taxDeclarationFunction = salarySysConfMap.get(TAX_DECLARATION_FUNCTION); + if (taxDeclarationFunction == null || (taxDeclarationFunction.getConfValue().equals(TaxDeclarationFunctionEnum.REBOOT.getValue()))) { + // 默认开启报税功能 或者重启状态时前端展示开启 + appSettingVO.setIsOpenTaxDeclaration("1"); + } else { + appSettingVO.setIsOpenTaxDeclaration(taxDeclarationFunction.getConfValue()); + } + + SalarySysConfPO salaryAcctEmployeeRule = salarySysConfMap.get(SALARY_ACCT_EMPLOYEE_RULE); + if (salaryAcctEmployeeRule == null) { + // 薪资核算人员匹配规则 + appSettingVO.setSalaryAcctEmployeeRule(SalaryAcctEmployeeRuleEnum.BYPAYENDTIME.getValue()); + } else { + appSettingVO.setSalaryAcctEmployeeRule(SalaryAcctEmployeeRuleEnum.parseByValue(salaryAcctEmployeeRule.getConfValue()).getValue()); + } + + SalarySysConfPO withDrawRule = salarySysConfMap.get(WITHDRAW_TAX_DECLARATION); + if (withDrawRule == null) { + // 个税申报撤回 + appSettingVO.setWithDrawTaxDeclaration("0"); + } else { + appSettingVO.setWithDrawTaxDeclaration(withDrawRule.getConfValue()); + } + + SalarySysConfPO salaryArchiveDeletePO = salarySysConfMap.get(SALARY_ARCHIVE_DELETE); + if (salaryArchiveDeletePO == null) { + // 是否允许删除薪资、社保档案,默认不允许删除 + appSettingVO.setSalaryArchiveDelete("0"); + } else { + appSettingVO.setSalaryArchiveDelete(salaryArchiveDeletePO.getConfValue()); + } + + + SalarySysConfPO salarySendFeedbackPO = salarySysConfMap.get(SALARY_SEND_FEEDBACK); + if (salarySendFeedbackPO == null) { + // 是否开启工资单反馈,默认不开启 + appSettingVO.setSalarySendFeedback("0"); + } else { + appSettingVO.setSalarySendFeedback(salarySendFeedbackPO.getConfValue()); + } + + //默认加密开启 + if (StringUtils.isEmpty(appSettingVO.getIsOpenEncrypt())) { + appSettingVO.setIsOpenEncrypt(OpenEnum.OPEN.getValue()); + } + + //是否显示脱敏表人员信息 + if (StringUtils.isEmpty(appSettingVO.getDisplayEmpInfoReport())) { + appSettingVO.setDisplayEmpInfoReport(OpenEnum.OFF.getValue()); + } + + BaseBean baseBean = new BaseBean(); + //是否打印 + String log = baseBean.getPropValue("hrmSalary", "log"); + appSettingVO.setIsLog(log); + //当前版本号 + String version = baseBean.getPropValue("hrmSalary", "version"); + appSettingVO.setVersion(version); + //是否开启了强制修改公式 + String openFormulaForcedEditing = baseBean.getPropValue("hrmSalary", "openFormulaForcedEditing"); + appSettingVO.setOpenFormulaForcedEditing(openFormulaForcedEditing); + //是否显示加解密操作按钮 + String showEncryptOperationButton = baseBean.getPropValue("hrmSalary", "showEncryptOperationButton"); + appSettingVO.setShowEncryptOperationButton(showEncryptOperationButton); + + return appSettingVO; + } + + private Boolean encryptOrDecryptDbWithAsync(String isOpenEncrypt, String progressId) { + log.info("应用设置加解密数据开始"); + Util_DataCache.setObjVal(ENCRYPT_IN_PROGRESS + progressId, "in_progress"); + //多线程批量更新需要加密的表 + try { + SalarySysConfPO sysConfPo = getSalarySysConfService(user).getOneByCode(SalarySysConstant.OPEN_APPLICATION_ENCRYPT); + Future submit = fixedThreadPool.submit(() -> { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + List salaryAcctResultPos = getSalaryAcctResultMapper().listAll(); + if (CollectionUtils.isNotEmpty(salaryAcctResultPos)) { + salaryAcctResultPos.forEach(po -> { + if (OpenEnum.OFF.getValue().equals(isOpenEncrypt)) { + po.setResultValue(AESEncryptUtil.closeEncryptSetting(po.getResultValue(), sysConfPo)); + po.setOriginResultValue(AESEncryptUtil.closeEncryptSetting(po.getOriginResultValue(), sysConfPo)); + } else { + po.setResultValue(AESEncryptUtil.encrypt(po.getResultValue())); + po.setOriginResultValue(AESEncryptUtil.encrypt(po.getOriginResultValue())); + } + }); + List> partition = Lists.partition(salaryAcctResultPos, 50); + SalaryAcctResultMapper mapper = sqlSession.getMapper(SalaryAcctResultMapper.class); + partition.forEach(mapper::batchUpdate); + sqlSession.commit(); + log.info("finish hrsa_salary_acct_result"); + } + } catch (Exception e) { + sqlSession.rollback(); + log.error("fail hrsa_salary_acct_result", e); + return 0; + } finally { + sqlSession.close(); + } + return 1; + }); + Future submit1 = fixedThreadPool.submit(() -> { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + List excelAcctResultPos = getExcelAcctResultMapper().listSome(new ExcelAcctResultPO()); + if (CollectionUtils.isNotEmpty(excelAcctResultPos)) { + excelAcctResultPos.forEach(po -> { + if (OpenEnum.OFF.getValue().equals(isOpenEncrypt)) { + po.setResultValue(AESEncryptUtil.closeEncryptSetting(po.getResultValue(), sysConfPo)); + } else { + po.setResultValue(AESEncryptUtil.encrypt(po.getResultValue())); + } + }); + List> partition = Lists.partition(excelAcctResultPos, 50); + ExcelAcctResultMapper mapper = sqlSession.getMapper(ExcelAcctResultMapper.class); + partition.forEach(mapper::batchUpdate); + log.info("finish hrsa_excel_acct_result"); + sqlSession.commit(); + } + } catch (Exception e) { + sqlSession.rollback(); + log.error("fail hrsa_excel_acct_result", e); + return 0; + } finally { + sqlSession.close(); + } + return 1; + }); + Future submit2 = fixedThreadPool.submit(() -> { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + List taxDeclarationDetailPos = getTaxDeclarationDetailMapper().listAll(); + if (CollectionUtils.isNotEmpty(taxDeclarationDetailPos)) { + taxDeclarationDetailPos.forEach(po -> { + if (OpenEnum.OFF.getValue().equals(isOpenEncrypt)) { + po.setFieldValue(AESEncryptUtil.closeEncryptSetting(po.getFieldValue(), sysConfPo)); + } else { + po.setFieldValue(AESEncryptUtil.encrypt(po.getFieldValue())); + } + }); + List> partition = Lists.partition(taxDeclarationDetailPos, 50); + TaxDeclarationDetailMapper mapper = sqlSession.getMapper(TaxDeclarationDetailMapper.class); + partition.forEach(mapper::batchUpdate); + sqlSession.commit(); + log.info("finish hrsa_tax_declaration_detail"); + } + } catch (Exception e) { + sqlSession.rollback(); + log.error("fail hrsa_tax_declaration_detail", e); + return 0; + } finally { + sqlSession.close(); + } + return 1; + }); + Future submit3 = fixedThreadPool.submit(() -> { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + List insuranceSchemeDetailPos = getInsuranceSchemeDetailMapper().listAll(); + if (CollectionUtils.isNotEmpty(insuranceSchemeDetailPos)) { + insuranceSchemeDetailPos.forEach(po -> { + if (OpenEnum.OFF.getValue().equals(isOpenEncrypt)) { + po.setUpperLimit(AESEncryptUtil.closeEncryptSetting(po.getUpperLimit(), sysConfPo)); + po.setFixedCost(AESEncryptUtil.closeEncryptSetting(po.getFixedCost(), sysConfPo)); + po.setLowerLimit(AESEncryptUtil.closeEncryptSetting(po.getLowerLimit(), sysConfPo)); + } else { + po.setUpperLimit(AESEncryptUtil.encrypt(po.getUpperLimit())); + po.setFixedCost(AESEncryptUtil.encrypt(po.getFixedCost())); + po.setLowerLimit(AESEncryptUtil.encrypt(po.getLowerLimit())); + } + }); + List> partition = Lists.partition(insuranceSchemeDetailPos, 50); + InsuranceSchemeDetailMapper mapper = sqlSession.getMapper(InsuranceSchemeDetailMapper.class); + partition.forEach(mapper::batchUpdate); + sqlSession.commit(); + log.info("finish hrsa_scheme_detail"); + } + } catch (Exception e) { + sqlSession.rollback(); + log.error("fail hrsa_scheme_detail", e); + return 0; + } finally { + sqlSession.close(); + } + return 1; + }); + Future submit4 = fixedThreadPool.submit(() -> { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + List insuranceArchivesSocialSchemePos = getSocialSchemeMapper().listAll(); + if (CollectionUtils.isNotEmpty(insuranceArchivesSocialSchemePos)) { + insuranceArchivesSocialSchemePos.forEach(po -> { + if (OpenEnum.OFF.getValue().equals(isOpenEncrypt)) { + po.setSocialPaymentBaseString(AESEncryptUtil.closeEncryptSetting(po.getSocialPaymentBaseString(), sysConfPo)); + po.setSocialPaymentComBaseString(AESEncryptUtil.closeEncryptSetting(po.getSocialPaymentComBaseString(), sysConfPo)); + } else { + po.setSocialPaymentBaseString(AESEncryptUtil.encrypt(po.getSocialPaymentBaseString())); + po.setSocialPaymentComBaseString(AESEncryptUtil.encrypt(po.getSocialPaymentComBaseString())); + } + }); + List> partition = Lists.partition(insuranceArchivesSocialSchemePos, 50); + SocialSchemeMapper mapper = sqlSession.getMapper(SocialSchemeMapper.class); + partition.forEach(mapper::batchUpdate); + sqlSession.commit(); + log.info("finish hrsa_social_archives"); + } + } catch (Exception e) { + sqlSession.rollback(); + log.error("fail hrsa_social_archives", e); + return 0; + } finally { + sqlSession.close(); + } + return 1; + }); + Future submit5 = fixedThreadPool.submit(() -> { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + List insuranceArchivesFundSchemePos = getFundSchemeMapper().listAll(); + if (CollectionUtils.isNotEmpty(insuranceArchivesFundSchemePos)) { + insuranceArchivesFundSchemePos.forEach(po -> { + if (OpenEnum.OFF.getValue().equals(isOpenEncrypt)) { + po.setFundPaymentBaseString(AESEncryptUtil.closeEncryptSetting(po.getFundPaymentBaseString(), sysConfPo)); + po.setFundPaymentComBaseString(AESEncryptUtil.closeEncryptSetting(po.getFundPaymentComBaseString(), sysConfPo)); + } else { + po.setFundPaymentBaseString(AESEncryptUtil.encrypt(po.getFundPaymentBaseString())); + po.setFundPaymentComBaseString(AESEncryptUtil.encrypt(po.getFundPaymentComBaseString())); + } + }); + List> partition = Lists.partition(insuranceArchivesFundSchemePos, 50); + FundSchemeMapper mapper = sqlSession.getMapper(FundSchemeMapper.class); + partition.forEach(mapper::batchUpdate); + sqlSession.commit(); + log.info("finish hrsa_fund_archives"); + } + } catch (Exception e) { + sqlSession.rollback(); + log.error("fail hrsa_fund_archives", e); + return 0; + } finally { + sqlSession.close(); + } + return 1; + }); + Future submit6 = fixedThreadPool.submit(() -> { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + List insuranceArchivesOtherSchemePos = getOtherSchemeMapper().listAll(); + if (CollectionUtils.isNotEmpty(insuranceArchivesOtherSchemePos)) { + insuranceArchivesOtherSchemePos.forEach(po -> { + if (OpenEnum.OFF.getValue().equals(isOpenEncrypt)) { + po.setOtherPaymentBaseString(AESEncryptUtil.closeEncryptSetting(po.getOtherPaymentBaseString(), sysConfPo)); + po.setOtherPaymentComBaseString(AESEncryptUtil.closeEncryptSetting(po.getOtherPaymentComBaseString(), sysConfPo)); + } else { + po.setOtherPaymentBaseString(AESEncryptUtil.encrypt(po.getOtherPaymentBaseString())); + po.setOtherPaymentComBaseString(AESEncryptUtil.encrypt(po.getOtherPaymentComBaseString())); + } + }); + List> partition = Lists.partition(insuranceArchivesOtherSchemePos, 50); + OtherSchemeMapper mapper = sqlSession.getMapper(OtherSchemeMapper.class); + partition.forEach(mapper::batchUpdate); + sqlSession.commit(); + log.info("finish hrsa_other_archives"); + } + } catch (Exception e) { + sqlSession.rollback(); + log.error("fail hrsa_other_archives", e); + return 0; + } finally { + sqlSession.close(); + } + return 1; + }); + Future submit7 = fixedThreadPool.submit(() -> { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + List insuranceAccountBatchPos = getInsuranceAccountBatchMapper().listAll(); + if (CollectionUtils.isNotEmpty(insuranceAccountBatchPos)) { + insuranceAccountBatchPos.forEach(po -> { + if (OpenEnum.OFF.getValue().equals(isOpenEncrypt)) { + po.setOtherPay(AESEncryptUtil.closeEncryptSetting(po.getOtherPay(), sysConfPo)); + po.setSocialPay(AESEncryptUtil.closeEncryptSetting(po.getSocialPay(), sysConfPo)); + po.setFundPay(AESEncryptUtil.closeEncryptSetting(po.getFundPay(), sysConfPo)); + } else { + po.setOtherPay(AESEncryptUtil.encrypt(po.getOtherPay())); + po.setSocialPay(AESEncryptUtil.encrypt(po.getSocialPay())); + po.setFundPay(AESEncryptUtil.encrypt(po.getFundPay())); + } + }); + List> partition = Lists.partition(insuranceAccountBatchPos, 50); + InsuranceAccountBatchMapper mapper = sqlSession.getMapper(InsuranceAccountBatchMapper.class); + partition.forEach(mapper::batchUpdate); + sqlSession.commit(); + log.info("finish hrsa_bill_batch"); + } + } catch (Exception e) { + sqlSession.rollback(); + log.error("fail hrsa_bill_batch", e); + return 0; + } finally { + sqlSession.close(); + } + return 1; + }); + Future submit8 = fixedThreadPool.submit(() -> { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + List insuranceAccountDetailPos = getInsuranceAccountDetailMapper().listAll(); + if (CollectionUtils.isNotEmpty(insuranceAccountDetailPos)) { + insuranceAccountDetailPos.forEach(po -> { + if (OpenEnum.OFF.getValue().equals(isOpenEncrypt)) { + po.setSocialPaymentBaseString(AESEncryptUtil.closeEncryptSetting(po.getSocialPaymentBaseString(), sysConfPo)); + po.setFundPaymentBaseString(AESEncryptUtil.closeEncryptSetting(po.getFundPaymentBaseString(), sysConfPo)); + po.setOtherPaymentBaseString(AESEncryptUtil.closeEncryptSetting(po.getOtherPaymentBaseString(), sysConfPo)); + po.setSocialPaymentComBaseString(AESEncryptUtil.closeEncryptSetting(po.getSocialPaymentComBaseString(), sysConfPo)); + po.setFundPaymentComBaseString(AESEncryptUtil.closeEncryptSetting(po.getFundPaymentComBaseString(), sysConfPo)); + po.setOtherPaymentComBaseString(AESEncryptUtil.closeEncryptSetting(po.getOtherPaymentComBaseString(), sysConfPo)); + po.setSocialPerJson(AESEncryptUtil.closeEncryptSetting(po.getSocialPerJson(), sysConfPo)); + po.setSocialPerSum(AESEncryptUtil.closeEncryptSetting(po.getSocialPerSum(), sysConfPo)); + po.setFundPerJson(AESEncryptUtil.closeEncryptSetting(po.getFundPerJson(), sysConfPo)); + po.setFundPerSum(AESEncryptUtil.closeEncryptSetting(po.getFundPerSum(), sysConfPo)); + po.setOtherPerJson(AESEncryptUtil.closeEncryptSetting(po.getOtherPerJson(), sysConfPo)); + po.setOtherPerSum(AESEncryptUtil.closeEncryptSetting(po.getOtherPerSum(), sysConfPo)); + po.setPerSum(AESEncryptUtil.closeEncryptSetting(po.getPerSum(), sysConfPo)); + po.setSocialComJson(AESEncryptUtil.closeEncryptSetting(po.getSocialComJson(), sysConfPo)); + po.setSocialComSum(AESEncryptUtil.closeEncryptSetting(po.getSocialComSum(), sysConfPo)); + po.setComSum(AESEncryptUtil.closeEncryptSetting(po.getComSum(), sysConfPo)); + po.setSocialSum(AESEncryptUtil.closeEncryptSetting(po.getSocialSum(), sysConfPo)); + po.setFundSum(AESEncryptUtil.closeEncryptSetting(po.getFundSum(), sysConfPo)); + po.setOtherSum(AESEncryptUtil.closeEncryptSetting(po.getOtherSum(), sysConfPo)); + po.setTotal(AESEncryptUtil.closeEncryptSetting(po.getTotal(), sysConfPo)); + } else { + po.setSocialPaymentBaseString(AESEncryptUtil.encrypt(po.getSocialPaymentBaseString())); + po.setFundPaymentBaseString(AESEncryptUtil.encrypt(po.getFundPaymentBaseString())); + po.setOtherPaymentBaseString(AESEncryptUtil.encrypt(po.getOtherPaymentBaseString())); + po.setSocialPaymentComBaseString(AESEncryptUtil.encrypt(po.getSocialPaymentComBaseString())); + po.setFundPaymentComBaseString(AESEncryptUtil.encrypt(po.getFundPaymentComBaseString())); + po.setOtherPaymentComBaseString(AESEncryptUtil.encrypt(po.getOtherPaymentComBaseString())); + po.setSocialPerJson(AESEncryptUtil.encrypt(po.getSocialPerJson())); + po.setSocialPerSum(AESEncryptUtil.encrypt(po.getSocialPerSum())); + po.setFundPerJson(AESEncryptUtil.encrypt(po.getFundPerJson())); + po.setFundPerSum(AESEncryptUtil.encrypt(po.getFundPerSum())); + po.setOtherPerJson(AESEncryptUtil.encrypt(po.getOtherPerJson())); + po.setOtherPerSum(AESEncryptUtil.encrypt(po.getOtherPerSum())); + po.setPerSum(AESEncryptUtil.encrypt(po.getPerSum())); + po.setSocialComJson(AESEncryptUtil.encrypt(po.getSocialComJson())); + po.setSocialComSum(AESEncryptUtil.encrypt(po.getSocialComSum())); + po.setComSum(AESEncryptUtil.encrypt(po.getComSum())); + po.setSocialSum(AESEncryptUtil.encrypt(po.getSocialSum())); + po.setFundSum(AESEncryptUtil.encrypt(po.getFundSum())); + po.setOtherSum(AESEncryptUtil.encrypt(po.getOtherSum())); + po.setTotal(AESEncryptUtil.encrypt(po.getTotal())); + } + }); + List> partition = Lists.partition(insuranceAccountDetailPos, 20); + InsuranceAccountDetailMapper mapper = sqlSession.getMapper(InsuranceAccountDetailMapper.class); + partition.forEach(mapper::batchUpdate); + sqlSession.commit(); + log.info("finish hrsa_bill_detail"); + } + } catch (Exception e) { + sqlSession.rollback(); + log.error("fail hrsa_bill_detail", e); + return 0; + } finally { + sqlSession.close(); + } + return 1; + }); + Future submit9 = fixedThreadPool.submit(() -> { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + List salaryArchiveItemPos = getSalaryArchiveItemMapper().listAll(); + if (CollectionUtils.isNotEmpty(salaryArchiveItemPos)) { + salaryArchiveItemPos.forEach(po -> { + if (OpenEnum.OFF.getValue().equals(isOpenEncrypt)) { + po.setItemValue(AESEncryptUtil.closeEncryptSetting(po.getItemValue(), sysConfPo)); + } else { + po.setItemValue(AESEncryptUtil.encrypt(po.getItemValue())); + } + }); + List> partition = Lists.partition(salaryArchiveItemPos, 50); + SalaryArchiveItemMapper mapper = sqlSession.getMapper(SalaryArchiveItemMapper.class); + partition.forEach(mapper::batchUpdate); + sqlSession.commit(); + log.info("finish hrsa_salary_archive_item"); + } + } catch (Exception e) { + sqlSession.rollback(); + log.error("fail hrsa_salary_archive_item", e); + return 0; + } finally { + sqlSession.close(); + } + return 1; + }); + Future submit10 = fixedThreadPool.submit(() -> { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + List addUpDeductions = getAddUpDeductionMapper().listAll(); + if (CollectionUtils.isNotEmpty(addUpDeductions)) { + addUpDeductions.forEach(po -> { + if (OpenEnum.OFF.getValue().equals(isOpenEncrypt)) { + encryptUtil.decrypt(po, AddUpDeduction.class); + } else { + encryptUtil.encrypt(po, AddUpDeduction.class); + } + }); + List> partition = Lists.partition(addUpDeductions, 50); + AddUpDeductionMapper mapper = sqlSession.getMapper(AddUpDeductionMapper.class); + partition.forEach(mapper::updateData); + sqlSession.commit(); + log.info("finish hrsa_add_up_deduction"); + } + } catch (Exception e) { + sqlSession.rollback(); + log.error("fail hrsa_add_up_deduction", e); + return 0; + } finally { + sqlSession.close(); + } + return 1; + }); + Future submit11 = fixedThreadPool.submit(() -> { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + List otherDeductionPos = getOtherDeductionMapper().listSome(new OtherDeductionPO()); + if (CollectionUtils.isNotEmpty(otherDeductionPos)) { + otherDeductionPos.forEach(po -> { + if (OpenEnum.OFF.getValue().equals(isOpenEncrypt)) { + po.setBusinessHealthyInsurance(AESEncryptUtil.closeEncryptSetting(po.getBusinessHealthyInsurance(), sysConfPo)); + po.setTaxDelayEndowmentInsurance(AESEncryptUtil.closeEncryptSetting(po.getTaxDelayEndowmentInsurance(), sysConfPo)); + po.setOtherDeduction(AESEncryptUtil.closeEncryptSetting(po.getOtherDeduction(), sysConfPo)); + po.setDeductionAllowedDonation(AESEncryptUtil.closeEncryptSetting(po.getDeductionAllowedDonation(), sysConfPo)); + po.setPrivatePension(AESEncryptUtil.closeEncryptSetting(po.getPrivatePension(), sysConfPo)); + } else { + po.setBusinessHealthyInsurance(AESEncryptUtil.encrypt(po.getBusinessHealthyInsurance())); + po.setTaxDelayEndowmentInsurance(AESEncryptUtil.encrypt(po.getTaxDelayEndowmentInsurance())); + po.setOtherDeduction(AESEncryptUtil.encrypt(po.getOtherDeduction())); + po.setDeductionAllowedDonation(AESEncryptUtil.encrypt(po.getDeductionAllowedDonation())); + po.setPrivatePension(AESEncryptUtil.encrypt(po.getPrivatePension())); + } + }); + List> partition = Lists.partition(otherDeductionPos, 50); + OtherDeductionMapper mapper = sqlSession.getMapper(OtherDeductionMapper.class); + partition.forEach(mapper::updateData); + sqlSession.commit(); + log.info("finish hrsa_other_deduction"); + } + } catch (Exception e) { + sqlSession.rollback(); + log.error("fail hrsa_other_deduction", e); + return 0; + } finally { + sqlSession.close(); + } + return 1; + }); + Future submit12 = fixedThreadPool.submit(() -> { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + List addUpSituations = getAddUpSituationMapper().listAll(); + if (CollectionUtils.isNotEmpty(addUpSituations)) { + addUpSituations.forEach(po -> { + if (OpenEnum.OFF.getValue().equals(isOpenEncrypt)) { + po.setAddUpIncome(AESEncryptUtil.closeEncryptSetting(po.getAddUpIncome(), sysConfPo)); + po.setAddUpSubtraction(AESEncryptUtil.closeEncryptSetting(po.getAddUpSubtraction(), sysConfPo)); + po.setAddUpSocialSecurityTotal(AESEncryptUtil.closeEncryptSetting(po.getAddUpSocialSecurityTotal(), sysConfPo)); + po.setAddUpAccumulationFundTotal(AESEncryptUtil.closeEncryptSetting(po.getAddUpAccumulationFundTotal(), sysConfPo)); + po.setAddUpChildEducation(AESEncryptUtil.closeEncryptSetting(po.getAddUpChildEducation(), sysConfPo)); + po.setAddUpContinuingEducation(AESEncryptUtil.closeEncryptSetting(po.getAddUpContinuingEducation(), sysConfPo)); + po.setAddUpHousingLoanInterest(AESEncryptUtil.closeEncryptSetting(po.getAddUpHousingLoanInterest(), sysConfPo)); + po.setAddUpHousingRent(AESEncryptUtil.closeEncryptSetting(po.getAddUpHousingRent(), sysConfPo)); + po.setAddUpSupportElderly(AESEncryptUtil.closeEncryptSetting(po.getAddUpSupportElderly(), sysConfPo)); + po.setAddUpEnterpriseAndOther(AESEncryptUtil.closeEncryptSetting(po.getAddUpEnterpriseAndOther(), sysConfPo)); + po.setAddUpOtherDeduction(AESEncryptUtil.closeEncryptSetting(po.getAddUpOtherDeduction(), sysConfPo)); + po.setAddUpTaxExemptIncome(AESEncryptUtil.closeEncryptSetting(po.getAddUpTaxExemptIncome(), sysConfPo)); + po.setAddUpAllowedDonation(AESEncryptUtil.closeEncryptSetting(po.getAddUpAllowedDonation(), sysConfPo)); + po.setAddUpAdvanceTax(AESEncryptUtil.closeEncryptSetting(po.getAddUpAdvanceTax(), sysConfPo)); + po.setAddUpIllnessMedical(AESEncryptUtil.closeEncryptSetting(po.getAddUpIllnessMedical(), sysConfPo)); + po.setAddUpTaxSavings(AESEncryptUtil.closeEncryptSetting(po.getAddUpTaxSavings(), sysConfPo)); + po.setAddUpInfantCare(AESEncryptUtil.closeEncryptSetting(po.getAddUpInfantCare(), sysConfPo)); + po.setAddUpPrivatePension(AESEncryptUtil.closeEncryptSetting(po.getAddUpPrivatePension(), sysConfPo)); + } else { + po.setAddUpIncome(AESEncryptUtil.encrypt(po.getAddUpIncome())); + po.setAddUpSubtraction(AESEncryptUtil.encrypt(po.getAddUpSubtraction())); + po.setAddUpSocialSecurityTotal(AESEncryptUtil.encrypt(po.getAddUpSocialSecurityTotal())); + po.setAddUpAccumulationFundTotal(AESEncryptUtil.encrypt(po.getAddUpAccumulationFundTotal())); + po.setAddUpChildEducation(AESEncryptUtil.encrypt(po.getAddUpChildEducation())); + po.setAddUpContinuingEducation(AESEncryptUtil.encrypt(po.getAddUpContinuingEducation())); + po.setAddUpHousingLoanInterest(AESEncryptUtil.encrypt(po.getAddUpHousingLoanInterest())); + po.setAddUpHousingRent(AESEncryptUtil.encrypt(po.getAddUpHousingRent())); + po.setAddUpSupportElderly(AESEncryptUtil.encrypt(po.getAddUpSupportElderly())); + po.setAddUpEnterpriseAndOther(AESEncryptUtil.encrypt(po.getAddUpEnterpriseAndOther())); + po.setAddUpOtherDeduction(AESEncryptUtil.encrypt(po.getAddUpOtherDeduction())); + po.setAddUpTaxExemptIncome(AESEncryptUtil.encrypt(po.getAddUpTaxExemptIncome())); + po.setAddUpAllowedDonation(AESEncryptUtil.encrypt(po.getAddUpAllowedDonation())); + po.setAddUpAdvanceTax(AESEncryptUtil.encrypt(po.getAddUpAdvanceTax())); + po.setAddUpIllnessMedical(AESEncryptUtil.encrypt(po.getAddUpIllnessMedical())); + po.setAddUpTaxSavings(AESEncryptUtil.encrypt(po.getAddUpTaxSavings())); + po.setAddUpInfantCare(AESEncryptUtil.encrypt(po.getAddUpInfantCare())); + po.setAddUpPrivatePension(AESEncryptUtil.encrypt(po.getAddUpPrivatePension())); + } + }); + List> partition = Lists.partition(addUpSituations, 50); + AddUpSituationMapper mapper = sqlSession.getMapper(AddUpSituationMapper.class); + partition.forEach(mapper::updateData); + sqlSession.commit(); + log.info("finish hrsa_add_up_situation"); + } + } catch (Exception e) { + sqlSession.rollback(); + log.error("fail hrsa_add_up_situation", e); + return 0; + } finally { + sqlSession.close(); + } + return 1; + }); + Future submit13 = fixedThreadPool.submit(() -> { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + List addUpSituations = getSpecialAddDeductionMapper().listAll(); + if (CollectionUtils.isNotEmpty(addUpSituations)) { + addUpSituations.forEach(po -> { + if (OpenEnum.OFF.getValue().equals(isOpenEncrypt)) { + encryptUtil.decrypt(po, SpecialAddDeductionPO.class); + } else { + encryptUtil.encrypt(po, SpecialAddDeductionPO.class); + } + }); + List> partition = Lists.partition(addUpSituations, 50); + SpecialAddDeductionMapper mapper = sqlSession.getMapper(SpecialAddDeductionMapper.class); + partition.forEach(mapper::updateBatchSelective); + sqlSession.commit(); + log.info("finish hrsa_special_add_deduction"); + } + } catch (Exception e) { + sqlSession.rollback(); + log.error("fail hrsa_special_add_deduction", e); + return 0; + } finally { + sqlSession.close(); + } + return 1; + }); + + Future submit14 = fixedThreadPool.submit(() -> { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + List excelInsuranceDetailPOS = getExcelInsuranceDetailMapper().listAll(); + if (CollectionUtils.isNotEmpty(excelInsuranceDetailPOS)) { + excelInsuranceDetailPOS.forEach(po -> { + if (OpenEnum.OFF.getValue().equals(isOpenEncrypt)) { + po.setSocialPaymentBaseString(AESEncryptUtil.closeEncryptSetting(po.getSocialPaymentBaseString(), sysConfPo)); + po.setSocialPaymentComBaseString(AESEncryptUtil.closeEncryptSetting(po.getSocialPaymentComBaseString(), sysConfPo)); + po.setFundPaymentBaseString(AESEncryptUtil.closeEncryptSetting(po.getFundPaymentBaseString(), sysConfPo)); + po.setFundPaymentComBaseString(AESEncryptUtil.closeEncryptSetting(po.getFundPaymentComBaseString(), sysConfPo)); + po.setOtherPaymentBaseString(AESEncryptUtil.closeEncryptSetting(po.getOtherPaymentBaseString(), sysConfPo)); + po.setOtherPaymentComBaseString(AESEncryptUtil.closeEncryptSetting(po.getOtherPaymentComBaseString(), sysConfPo)); + po.setSocialPerJson(AESEncryptUtil.closeEncryptSetting(po.getSocialPerJson(), sysConfPo)); + po.setSocialPerSum(AESEncryptUtil.closeEncryptSetting(po.getSocialPerSum(), sysConfPo)); + po.setFundPerJson(AESEncryptUtil.closeEncryptSetting(po.getFundPerJson(), sysConfPo)); + po.setFundPerSum(AESEncryptUtil.closeEncryptSetting(po.getFundPerSum(), sysConfPo)); + po.setOtherPerJson(AESEncryptUtil.closeEncryptSetting(po.getOtherPerJson(), sysConfPo)); + po.setOtherPerSum(AESEncryptUtil.closeEncryptSetting(po.getOtherPerSum(), sysConfPo)); + po.setPerSum(AESEncryptUtil.closeEncryptSetting(po.getPerSum(), sysConfPo)); + po.setSocialComJson(AESEncryptUtil.closeEncryptSetting(po.getSocialComJson(), sysConfPo)); + po.setSocialComSum(AESEncryptUtil.closeEncryptSetting(po.getSocialComSum(), sysConfPo)); + po.setComSum(AESEncryptUtil.closeEncryptSetting(po.getComSum(), sysConfPo)); + po.setSocialSum(AESEncryptUtil.closeEncryptSetting(po.getSocialSum(), sysConfPo)); + po.setFundSum(AESEncryptUtil.closeEncryptSetting(po.getFundSum(), sysConfPo)); + po.setOtherSum(AESEncryptUtil.closeEncryptSetting(po.getOtherSum(), sysConfPo)); + po.setTotal(AESEncryptUtil.closeEncryptSetting(po.getTotal(), sysConfPo)); + } else { + po.setSocialPaymentBaseString(AESEncryptUtil.encrypt(po.getSocialPaymentBaseString())); + po.setSocialPaymentComBaseString(AESEncryptUtil.encrypt(po.getSocialPaymentComBaseString())); + po.setFundPaymentBaseString(AESEncryptUtil.encrypt(po.getFundPaymentBaseString())); + po.setFundPaymentComBaseString(AESEncryptUtil.encrypt(po.getFundPaymentComBaseString())); + po.setOtherPaymentBaseString(AESEncryptUtil.encrypt(po.getOtherPaymentBaseString())); + po.setOtherPaymentComBaseString(AESEncryptUtil.encrypt(po.getOtherPaymentComBaseString())); + po.setSocialPerJson(AESEncryptUtil.encrypt(po.getSocialPerJson())); + po.setSocialPerSum(AESEncryptUtil.encrypt(po.getSocialPerSum())); + po.setFundPerJson(AESEncryptUtil.encrypt(po.getFundPerJson())); + po.setFundPerSum(AESEncryptUtil.encrypt(po.getFundPerSum())); + po.setOtherPerJson(AESEncryptUtil.encrypt(po.getOtherPerJson())); + po.setOtherPerSum(AESEncryptUtil.encrypt(po.getOtherPerSum())); + po.setPerSum(AESEncryptUtil.encrypt(po.getPerSum())); + po.setSocialComJson(AESEncryptUtil.encrypt(po.getSocialComJson())); + po.setSocialComSum(AESEncryptUtil.encrypt(po.getSocialComSum())); + po.setComSum(AESEncryptUtil.encrypt(po.getComSum())); + po.setSocialSum(AESEncryptUtil.encrypt(po.getSocialSum())); + po.setFundSum(AESEncryptUtil.encrypt(po.getFundSum())); + po.setOtherSum(AESEncryptUtil.encrypt(po.getOtherSum())); + po.setTotal(AESEncryptUtil.encrypt(po.getTotal())); + } + }); + List> partition = Lists.partition(excelInsuranceDetailPOS, 10); + ExcelInsuranceDetailMapper mapper = sqlSession.getMapper(ExcelInsuranceDetailMapper.class); + partition.forEach(mapper::updateBatchSelective); + sqlSession.commit(); + log.info("finish hrsa_excel_bill_detail"); + } + } catch (Exception e) { + sqlSession.rollback(); + log.error("fail hrsa_excel_bill_detail", e); + return 0; + } finally { + sqlSession.close(); + } + return 1; + }); + + Future submit15 = fixedThreadPool.submit(() -> { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + List variableArchiveItemPOS = getVariableArchiveItemService(user).listAll(); + if (CollectionUtils.isNotEmpty(variableArchiveItemPOS)) { + variableArchiveItemPOS.forEach(po -> { + if (OpenEnum.OFF.getValue().equals(isOpenEncrypt)) { + po.setItemValue(AESEncryptUtil.closeEncryptSetting(po.getItemValue(), sysConfPo)); + } else { + po.setItemValue(AESEncryptUtil.encrypt(po.getItemValue())); + } + }); + List> partition = Lists.partition(variableArchiveItemPOS, 10); + VariableArchiveItemMapper mapper = sqlSession.getMapper(VariableArchiveItemMapper.class); + partition.forEach(mapper::updateBatchSelective); + sqlSession.commit(); + log.info("finish hrsa_variable_archive_item"); + } + } catch (Exception e) { + sqlSession.rollback(); + log.error("fail hrsa_variable_archive_item", e); + return 0; + } finally { + sqlSession.close(); + } + return 1; + }); + + int flag = submit.get() + submit1.get() + submit2.get() + submit3.get() + submit4.get() + submit5.get() + submit6.get() + submit7.get() + submit8.get() + submit9.get() + submit10.get() + submit11.get() + submit12.get() + submit13.get() + submit14.get() + submit15.get(); + if (flag == 16) { + Util_DataCache.setObjVal(ENCRYPT_IN_PROGRESS + progressId, "success", 30); + } else { + Util_DataCache.setObjVal(ENCRYPT_IN_PROGRESS + progressId, "fail", 30); + } + Util_DataCache.clearVal(AES_ENCRYPT_IN_PROGRESS); + return flag == 16; + } catch (Exception e) { + Util_DataCache.setObjVal(ENCRYPT_IN_PROGRESS + progressId, "fail", 30); + Util_DataCache.clearVal(AES_ENCRYPT_IN_PROGRESS); + log.error("应用设置加解密数据异常", e); + return false; + } finally { + Util_DataCache.clearVal(AES_ENCRYPT_IN_PROGRESS); + } + } +} diff --git a/src/com/engine/salary/timer/AutoAddAllSpecialAddDeductionJob.java b/src/com/engine/salary/timer/AutoAddAllSpecialAddDeductionJob.java new file mode 100644 index 000000000..694660651 --- /dev/null +++ b/src/com/engine/salary/timer/AutoAddAllSpecialAddDeductionJob.java @@ -0,0 +1,37 @@ +package com.engine.salary.timer; + +import cn.hutool.core.date.DateUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.salary.service.AddUpDeductionService; +import com.engine.salary.service.impl.AddUpDeductionServiceImpl; +import com.engine.salary.util.SalaryDateUtil; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import weaver.hrm.User; +import weaver.interfaces.schedule.BaseCronJob; + +import java.time.LocalDate; +import java.util.Collections; +import java.util.Date; + +/** + * 定时自动累计专项附加扣除 + */ +@Slf4j +public class AutoAddAllSpecialAddDeductionJob extends BaseCronJob { + + private AddUpDeductionService getAddUpDeductionService(User user) { + return ServiceUtil.getService(AddUpDeductionServiceImpl.class, user); + } + + private String salaryTaxMonth; + + @Override + public void execute() { + LocalDate localDate = SalaryDateUtil.dateToLocalDate(new Date()); + if(StringUtils.isNotBlank(salaryTaxMonth)){ + localDate = localDate.plusMonths(Integer.valueOf(salaryTaxMonth.trim())); + } + getAddUpDeductionService(null).autoAddAll(DateUtil.beginOfMonth(SalaryDateUtil.localDateToDate(localDate)), Boolean.TRUE, Collections.emptyList()); + } +} diff --git a/src/com/engine/salary/timer/AutoConfirmSalaryBillCronJob.java b/src/com/engine/salary/timer/AutoConfirmSalaryBillCronJob.java new file mode 100644 index 000000000..3441a1dd8 --- /dev/null +++ b/src/com/engine/salary/timer/AutoConfirmSalaryBillCronJob.java @@ -0,0 +1,72 @@ +package com.engine.salary.timer; + +import com.engine.common.util.ServiceUtil; +import com.engine.salary.entity.salaryBill.po.SalarySendInfoPO; +import com.engine.salary.entity.salaryBill.po.SalarySendPO; +import com.engine.salary.entity.salaryBill.po.SalaryTemplatePO; +import com.engine.salary.service.SalarySendService; +import com.engine.salary.service.SalaryTemplateService; +import com.engine.salary.service.impl.SalarySendServiceImpl; +import com.engine.salary.service.impl.SalaryTemplateServiceImpl; +import com.engine.salary.util.SalaryDateUtil; +import com.engine.salary.util.SalaryEntityUtil; + +import weaver.hrm.User; +import weaver.interfaces.schedule.BaseCronJob; + +import java.time.LocalDateTime; +import java.time.temporal.ChronoUnit; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * @author Harryxzy + * @ClassName AutoConfirmSalaryBill + * @date 2023/07/11 15:50 + * @description 自动确认工资单 + */ +public class AutoConfirmSalaryBillCronJob extends BaseCronJob { + private SalarySendService getSalarySendService(User user) { + return ServiceUtil.getService(SalarySendServiceImpl.class, user); + } + + private SalaryTemplateService getSalaryTemplateService(User user) { + return ServiceUtil.getService(SalaryTemplateServiceImpl.class, user); + } + + @Override + public void execute() { + User user = new User(); + user.setUid(1); + user.setLoginid("sysadmin"); + // 获取所有需要确认反馈的默认工资单模板 + List templates = getSalaryTemplateService(user).listNeedAckDefaultTemplate(); + // key:薪资账套id,value:对应的自动确认天数 + Map salarySobAckDaysMap = SalaryEntityUtil.convert2Map(templates, SalaryTemplatePO::getSalarySobId, SalaryTemplatePO::getAutoAckDays); + // 根据薪资账套id获取已发送,确认状态为未确认的工资单 + List unConfirmedList = getSalarySendService(user).listUnConfirmedSendInfo(new ArrayList<>(salarySobAckDaysMap.keySet())); + List sendList = getSalarySendService(user).getByIds(unConfirmedList.stream().map(SalarySendInfoPO::getSalarySendId).distinct().collect(Collectors.toList())); + // key:工资单发放id,value:自动确认超时天数 + HashMap autoAckDaysMap = new HashMap<>(); + sendList.stream().forEach(send -> { + Integer autoAckDays = salarySobAckDaysMap.getOrDefault(send.getSalarySobId(), 7); + autoAckDaysMap.put(send.getId(), autoAckDays); + }); + LocalDateTime now = LocalDateTime.now(); + List needAutoIds = unConfirmedList.stream().filter(po -> { + LocalDateTime sendDateTime = SalaryDateUtil.dateToLocalDateTime(po.getSendTime()); + Integer autoDays = autoAckDaysMap.get(po.getSalarySendId()); + if (autoDays == null) { + return false; + } + LocalDateTime autoDateTime = sendDateTime.plus(autoDays, ChronoUnit.DAYS); + return !autoDateTime.isAfter(now); + }).map(SalarySendInfoPO::getId).collect(Collectors.toList()); + // 自动确认 + getSalarySendService(user).autoConfirmSalaryBill(needAutoIds); + } + +} diff --git a/src/com/engine/salary/timer/AutoSendSalaryJob.java b/src/com/engine/salary/timer/AutoSendSalaryJob.java new file mode 100644 index 000000000..30777f606 --- /dev/null +++ b/src/com/engine/salary/timer/AutoSendSalaryJob.java @@ -0,0 +1,101 @@ +package com.engine.salary.timer; + +import com.engine.common.util.ServiceUtil; +import com.engine.salary.entity.salaryBill.param.SalarySendGrantParam; +import com.engine.salary.entity.salaryBill.po.SalarySendInfoPO; +import com.engine.salary.entity.salaryBill.po.SalarySendPO; +import com.engine.salary.entity.salaryBill.po.SalaryTemplatePO; +import com.engine.salary.service.SalaryBillService; +import com.engine.salary.service.SalarySendService; +import com.engine.salary.service.SalaryTemplateService; +import com.engine.salary.service.impl.SalaryBillServiceImpl; +import com.engine.salary.service.impl.SalarySendServiceImpl; +import com.engine.salary.service.impl.SalaryTemplateServiceImpl; +import com.engine.salary.util.SalaryDateUtil; +import com.engine.salary.util.SalaryEntityUtil; +import weaver.hrm.User; +import weaver.interfaces.schedule.BaseCronJob; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.util.*; +import java.util.stream.Collectors; + +/** + * @author Harryxzy + * @ClassName AutoSendSalaryJob + * @date 2023/07/03 10:39 + * @description 自动发送工资单 + */ +public class AutoSendSalaryJob extends BaseCronJob { + + private SalarySendService getSalarySendService(User user) { + return ServiceUtil.getService(SalarySendServiceImpl.class, user); + } + + private SalaryTemplateService getSalaryTemplateService(User user) { + return ServiceUtil.getService(SalaryTemplateServiceImpl.class, user); + } + + private SalaryBillService getSalaryBillService(User user) { + return ServiceUtil.getService(SalaryBillServiceImpl.class, user); + } + + @Override + public void execute() { + User tempUser = new User(); + tempUser.setUid(1); + tempUser.setLoginid("sysadmin"); + // 获取所有设置了定时发送的默认工资单模板 + List autoSendTemplate = getSalaryTemplateService(tempUser).getAutoSendTemplate(); + Map autoSendTypeMap = SalaryEntityUtil.convert2Map(autoSendTemplate, SalaryTemplatePO::getSalarySobId); + List salarySobIds = autoSendTemplate.stream().map(SalaryTemplatePO::getSalarySobId).collect(Collectors.toList()); + // 获取这些模板下未发放完的正常(非补发、非冻结)工资单 + List salarySendList = getSalarySendService(tempUser).getNeedSendListBySalarySobIds(salarySobIds); + + LocalDateTime nowLocalDateTime = SalaryDateUtil.dateToLocalDateTime(new Date()); + SimpleDateFormat timeFormat = new SimpleDateFormat("HH:mm"); + List needSendIds = salarySendList.stream().filter(sendPO -> { + SalaryTemplatePO templatePO = autoSendTypeMap.get(sendPO.getSalarySobId()); + if (templatePO == null) { + return false; + } + LocalDate autoSendDate = null; + if (templatePO.getAutoSendCycleType() == 1) { + // 薪资所属月当月 + autoSendDate = SalaryDateUtil.dateToLocalDate(sendPO.getSalaryMonth()); + } else { + // 薪资所属月下月 + autoSendDate = SalaryDateUtil.dateToLocalDate(sendPO.getSalaryMonth()).plusMonths(1); + } + int maxDays = autoSendDate.lengthOfMonth(); + Integer sendDays = Integer.valueOf(templatePO.getAutoSendDayOfMonth()); + if (sendDays.intValue() > maxDays) { + sendDays = maxDays; + } + autoSendDate = autoSendDate.withDayOfMonth(sendDays); + LocalDateTime autoSendDateTime = null; + try { + // 加上时间 + autoSendDateTime = autoSendDate.atTime(SalaryDateUtil.dateToLocalDateTime(timeFormat.parse(templatePO.getAutoSendTimeOfDay())).toLocalTime()); + } catch (ParseException e) { + throw new RuntimeException(e); + } + if (!autoSendDateTime.isAfter(nowLocalDateTime)) { + // 自动发放时间早于或等于现在的发放记录 + return true; + } + return false; + }).map(SalarySendPO::getId).collect(Collectors.toList()); + + // 获取工资单发放记录下需要发放的工资单明细 + List needSendInfoList = getSalarySendService(tempUser).getNeedSendInfoList(needSendIds); + Map> sendMap = SalaryEntityUtil.group2Map(needSendInfoList, SalarySendInfoPO::getSalarySendId, SalarySendInfoPO::getId); + for(Map.Entry> entry : sendMap.entrySet()){ + // 发放 + getSalaryBillService(tempUser).grant(SalarySendGrantParam.builder().salarySendId(entry.getKey()).ids(new ArrayList(entry.getValue())).build()); + } + } +} diff --git a/src/com/engine/salary/timer/AutoSiAccountAndFileJob.java b/src/com/engine/salary/timer/AutoSiAccountAndFileJob.java new file mode 100644 index 000000000..47dd04994 --- /dev/null +++ b/src/com/engine/salary/timer/AutoSiAccountAndFileJob.java @@ -0,0 +1,106 @@ +package com.engine.salary.timer; + +import cn.hutool.core.util.StrUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.salary.common.SalaryContext; +import com.engine.salary.entity.siaccount.param.AccountParam; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import com.engine.salary.formlua.util.RegularUtil; +import com.engine.salary.service.SIAccountService; +import com.engine.salary.service.TaxAgentService; +import com.engine.salary.service.impl.SIAccountServiceImpl; +import com.engine.salary.service.impl.TaxAgentServiceImpl; +import lombok.extern.slf4j.Slf4j; +import weaver.hrm.User; +import weaver.interfaces.schedule.BaseCronJob; + +import java.text.SimpleDateFormat; +import java.util.Arrays; +import java.util.Calendar; +import java.util.List; +import java.util.stream.Collectors; + +/** + * @Author: sy + * @Description: 福利台账核算并归档任务 + * @Date: 2024/1/15 + **/ +@Slf4j +public class AutoSiAccountAndFileJob extends BaseCronJob { + + private String diffToCurrentMonth; + + public String getDiffToCurrentMonth() { + return diffToCurrentMonth; + } + + public void setDiffToCurrentMonth(String diffToCurrentMonth) { + this.diffToCurrentMonth = diffToCurrentMonth; + } + + private String taxAgentNames; + + public String getTaxAgentNames() { + return taxAgentNames; + } + + public void setTaxAgentNames(String taxAgentNames) { + this.taxAgentNames = taxAgentNames; + } + + private String fileFlag; + + public String getFileFlag() { + return fileFlag; + } + + public void setFileFlag(String fileFlag) { + this.fileFlag = fileFlag; + } + + private TaxAgentService getTaxAgentService(User user) { + SalaryContext.get().setValue("user",user); + return ServiceUtil.getService(TaxAgentServiceImpl.class, user); + } + + public SIAccountService getSIAccountService(User user) { + SalaryContext.get().setValue("user",user); + return ServiceUtil.getService(SIAccountServiceImpl.class, user); + } + + @Override + public void execute() { + if (StrUtil.isNotBlank(diffToCurrentMonth) && (RegularUtil.isInteger(diffToCurrentMonth) || "0".equals(diffToCurrentMonth))) { + User user = new User(); + user.setUid(1); + user.setLoginid("sysadmin"); + user.setLastname("sysadmin"); + + Calendar accountTime= Calendar.getInstance(); + accountTime.set(Calendar.MONTH, accountTime.get(Calendar.MONTH) + Integer.parseInt(diffToCurrentMonth)); + SimpleDateFormat s=new SimpleDateFormat("yyyy-MM"); + + String accountMonth = s.format(accountTime.getTime()); + boolean isFile = false; + if (StrUtil.isNotBlank(fileFlag) && "true".equals(fileFlag)) { + isFile = true; + } + //核算并归档 + List taxAgentList = getTaxAgentService(user).listAll(); + //判断是否过滤个税扣缴义务人 + if (StrUtil.isNotBlank(taxAgentNames)) { + List taxAgentNameList = Arrays.stream(taxAgentNames.split(",")).map(String::new).collect(Collectors.toList()); + taxAgentList = taxAgentList.stream().filter(f -> taxAgentNameList.contains(f.getName())).collect(Collectors.toList()); + } + for (TaxAgentPO po : taxAgentList) { + try { + getSIAccountService(user).saveAndFile(AccountParam.builder().paymentOrganization(po.getId()).billMonth(accountMonth).flag(true).fileFlag(isFile).build()); + } catch (Exception e) { + log.info("个税扣缴义务人-" + po.getName() + ",新建账单月份" + accountMonth + "的福利核算(并归档)过程失败,原因:" + e.getMessage()); + } + } + + } + + } +} diff --git a/src/com/engine/salary/timer/AutoSyncAttendQuoteJob.java b/src/com/engine/salary/timer/AutoSyncAttendQuoteJob.java new file mode 100644 index 000000000..085c8ff29 --- /dev/null +++ b/src/com/engine/salary/timer/AutoSyncAttendQuoteJob.java @@ -0,0 +1,82 @@ +package com.engine.salary.timer; + +import com.engine.common.util.ServiceUtil; +import com.engine.salary.entity.datacollection.param.AttendQuoteCheckOperationParam; +import com.engine.salary.entity.datacollection.param.AttendQuoteDataSyncParam; +import com.engine.salary.entity.salarysob.po.SalarySobPO; +import com.engine.salary.service.SalarySobService; +import com.engine.salary.service.impl.SalarySobServiceImpl; +import com.engine.salary.util.SalaryDateUtil; +import com.engine.salary.wrapper.AttendQuoteDataWrapper; +import com.engine.salary.wrapper.AttendQuoteWrapper; +import org.apache.commons.lang3.math.NumberUtils; +import weaver.general.BaseBean; +import weaver.hrm.User; +import weaver.interfaces.schedule.BaseCronJob; + +import java.time.LocalDate; +import java.util.Collections; +import java.util.Date; +import java.util.List; + +/** + * @author Harryxzy + * @ClassName AutoSyncAttendQuoteData + * @date 2023/08/11 9:53 + * @description 自动同步所有薪资账套的考勤引用 + */ +public class AutoSyncAttendQuoteJob extends BaseCronJob { + + private String preMonth; + + private SalarySobService getSalarySobService(User user) { + return ServiceUtil.getService(SalarySobServiceImpl.class, user); + } + + private AttendQuoteWrapper getAttendQuoteWrapper(User user) { + return ServiceUtil.getService(AttendQuoteWrapper.class, user); + } + private AttendQuoteDataWrapper getAttendQuoteDataWrapper(User user) { + return ServiceUtil.getService(AttendQuoteDataWrapper.class, user); + } + + @Override + public void execute() { + User tempUser = new User(); + tempUser.setUid(1); + tempUser.setLoginid("sysadmin"); + // 获取所有的薪资账套 + List salarySobList = getSalarySobService(tempUser).listAll(); + LocalDate localDate = SalaryDateUtil.dateToLocalDate(new Date()); + + int preMonthValue = -1; + if (preMonth != null && NumberUtils.isCreatable(preMonth)) { + preMonthValue = -1 * Integer.valueOf(preMonth); + } + localDate = localDate.plusMonths(preMonthValue); + + String dateStr = SalaryDateUtil.getFormatYearMonth(localDate); + BaseBean baseBean = new BaseBean(); + // 循环所有的账套 + salarySobList.stream().forEach(sob -> { + // 校验是否可以操作 + Boolean canSync = getAttendQuoteWrapper(tempUser).checkOperation(AttendQuoteCheckOperationParam.builder() + .salarySobIds(Collections.singletonList(sob.getId())) + .salaryYearMonthStr(dateStr) + .build()); + if (canSync) { + // 同步数据 + try { + baseBean.writeLog("自动同步考勤数据开始:"+ sob.getId()+","+dateStr); + getAttendQuoteDataWrapper(tempUser).syncAttendQuoteData(AttendQuoteDataSyncParam.builder() + .salarySobIds(Collections.singletonList(sob.getId())) + .salaryYearMonth(dateStr) + .build()); + baseBean.writeLog("自动同步考勤数据结束:"+ sob.getId()+","+dateStr); + } catch (Exception e) { + baseBean.writeLog("自动同步考勤数据出错:"+ e); + } + } + }); + } +} diff --git a/src/com/engine/salary/timer/AutoSyncEmpArchiveStartDateJob.java b/src/com/engine/salary/timer/AutoSyncEmpArchiveStartDateJob.java new file mode 100644 index 000000000..683d1ddd0 --- /dev/null +++ b/src/com/engine/salary/timer/AutoSyncEmpArchiveStartDateJob.java @@ -0,0 +1,182 @@ +package com.engine.salary.timer; + +import com.engine.common.util.ServiceUtil; +import com.engine.salary.biz.SalaryArchiveBiz; +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.salaryarchive.dto.SalaryArchiveListDTO; +import com.engine.salary.entity.salaryarchive.param.SalaryArchiveQueryParam; +import com.engine.salary.entity.salaryarchive.po.SalaryArchivePO; +import com.engine.salary.entity.siarchives.po.InsuranceArchivesBaseInfoPO; +import com.engine.salary.entity.siarchives.po.InsuranceArchivesFundSchemePO; +import com.engine.salary.entity.siarchives.po.InsuranceArchivesOtherSchemePO; +import com.engine.salary.entity.siarchives.po.InsuranceArchivesSocialSchemePO; +import com.engine.salary.enums.salaryarchive.SalaryArchiveListTypeEnum; +import com.engine.salary.enums.salaryarchive.SalaryArchiveStatusEnum; +import com.engine.salary.enums.siaccount.EmployeeStatusEnum; +import com.engine.salary.mapper.siarchives.FundSchemeMapper; +import com.engine.salary.mapper.siarchives.OtherSchemeMapper; +import com.engine.salary.mapper.siarchives.SocialSchemeMapper; +import com.engine.salary.service.SIArchivesService; +import com.engine.salary.service.SalaryArchiveService; +import com.engine.salary.service.SalaryEmployeeService; +import com.engine.salary.service.impl.SIArchivesServiceImpl; +import com.engine.salary.service.impl.SalaryArchiveServiceImpl; +import com.engine.salary.service.impl.SalaryEmployeeServiceImpl; +import com.engine.salary.util.SalaryDateUtil; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.db.MapperProxyFactory; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import weaver.hrm.User; +import weaver.interfaces.schedule.BaseCronJob; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * @author Harryxzy + * @ClassName AutoSyncInsuranceArchiveJob + * @date 2023/08/14 9:30 + * @description 自动同步人员社保福利档案、薪资档案为公司开始日期字段(companystartdate) + */ +@Slf4j +public class AutoSyncEmpArchiveStartDateJob extends BaseCronJob { + + private String syncInsuranceArchive; + private String syncSalaryArchive; + + private String allStayAddToPay; + private String allGotoFixed; + private SalaryArchiveService getSalaryArchiveService(User user) { + return ServiceUtil.getService(SalaryArchiveServiceImpl.class, user); + } + + private SalaryEmployeeService getSalaryEmployeeService(User user) { + return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user); + } + + + private SIArchivesService getSIArchivesService(User user) { + return ServiceUtil.getService(SIArchivesServiceImpl.class, user); + } + + private SalaryArchiveBiz getSalaryArchiveMapper = new SalaryArchiveBiz(); + + private SocialSchemeMapper getSocialSchemeMapper() { + return MapperProxyFactory.getProxy(SocialSchemeMapper.class); + } + + private FundSchemeMapper getFundSchemeMapper() { + return MapperProxyFactory.getProxy(FundSchemeMapper.class); + } + + private OtherSchemeMapper getOtherSchemeMapper() { + return MapperProxyFactory.getProxy(OtherSchemeMapper.class); + } + + + @Override + public void execute() { + User user = new User(); + user.setUid(1); + user.setLoginid("sysadmin"); + + if (StringUtils.isBlank(syncInsuranceArchive) || !StringUtils.equals(syncInsuranceArchive, "false")) { + // 同步社保福利档案 + // 获取社保、公积金、其他福利中起始缴纳月任意一个为空的社保档案主表po + List needSyncInsuranceBaseInfoList = getSIArchivesService(user).listStartDateIsNull(Collections.emptyList()); + // 过滤出档案状态为待增员的 + needSyncInsuranceBaseInfoList = needSyncInsuranceBaseInfoList.stream().filter(po -> po.getRunStatus().equals(EmployeeStatusEnum.STAY_ADD.getValue())).collect(Collectors.toList()); + // 获取同步人员的公司开始日期 + List employeeList = getSalaryEmployeeService(user).listByIds(SalaryEntityUtil.properties(needSyncInsuranceBaseInfoList, InsuranceArchivesBaseInfoPO::getEmployeeId, Collectors.toList())); + Map empInfoMap = SalaryEntityUtil.convert2Map(employeeList, DataCollectionEmployee::getEmployeeId, emp -> { + if (StringUtils.isBlank(emp.getCompanystartdate()) || !SalaryDateUtil.checkDay(emp.getCompanystartdate())) { + return ""; + } else { + return StringUtils.substring(emp.getCompanystartdate(), 0, 7); + } + }); + // 设置社保起始缴纳月信息 + List needSyncSocialArchiveIds = SalaryEntityUtil.properties(needSyncInsuranceBaseInfoList, InsuranceArchivesBaseInfoPO::getSocialArchivesId, Collectors.toList()); + List insuranceArchivesSocialSchemePOS = getSIArchivesService(user).listInsuranceArchivesSocialSchemeByIds(needSyncSocialArchiveIds); + insuranceArchivesSocialSchemePOS.stream().forEach(po -> { + if (StringUtils.isBlank(po.getSocialStartTime()) && StringUtils.isNotBlank(empInfoMap.get(po.getEmployeeId()))) { + po.setSocialStartTime(empInfoMap.get(po.getEmployeeId())); + getSocialSchemeMapper().updateById(po); + } + }); + + // 设置公积金起始缴纳月信息 + List needSyncFundArchiveIds = SalaryEntityUtil.properties(needSyncInsuranceBaseInfoList, InsuranceArchivesBaseInfoPO::getFundArchivesId, Collectors.toList()); + List insuranceArchivesFundSchemePOS = getSIArchivesService(user).listInsuranceArchivesFundSchemeByIds(needSyncFundArchiveIds); + insuranceArchivesFundSchemePOS.stream().forEach(po -> { + if (StringUtils.isBlank(po.getFundStartTime()) && StringUtils.isNotBlank(empInfoMap.get(po.getEmployeeId()))) { + po.setFundStartTime(empInfoMap.get(po.getEmployeeId())); + getFundSchemeMapper().updateById(po); + } + }); + + // 设置其他福利起始缴纳月信息 + List needSyncOtherArchiveIds = SalaryEntityUtil.properties(needSyncInsuranceBaseInfoList, InsuranceArchivesBaseInfoPO::getOtherArchivesId, Collectors.toList()); + List insuranceArchivesOtherSchemePOS = getSIArchivesService(user).listInsuranceArchivesOtherSchemeByIds(needSyncOtherArchiveIds); + insuranceArchivesOtherSchemePOS.stream().forEach(po -> { + if (StringUtils.isBlank(po.getOtherStartTime()) && StringUtils.isNotBlank(empInfoMap.get(po.getEmployeeId()))) { + po.setOtherStartTime(empInfoMap.get(po.getEmployeeId())); + getOtherSchemeMapper().updateById(po); + } + }); + } + + if (StringUtils.isBlank(syncSalaryArchive) || !StringUtils.equals(syncSalaryArchive, "false")) { + // 同步薪资档案 + // 获取薪资档案起始发薪日为空且是待定薪资的档案 + List salaryArchiveList = getSalaryArchiveService(user).listPayStartDateIsNull(SalaryArchiveListTypeEnum.PENDING.getValue()); + List empIds = SalaryEntityUtil.properties(salaryArchiveList, SalaryArchivePO::getEmployeeId, Collectors.toList()); + List employeeList = getSalaryEmployeeService(user).listByIds(empIds); + Map empMap = SalaryEntityUtil.convert2Map(employeeList, DataCollectionEmployee::getEmployeeId, emp -> { + if (StringUtils.isBlank(emp.getCompanystartdate()) || !SalaryDateUtil.checkDay(emp.getCompanystartdate())) { + return null; + } else { + return SalaryDateUtil.stringToDate(StringUtils.substring(emp.getCompanystartdate(), 0, 10)); + } + }); + List needUpdateArchiveList = salaryArchiveList.stream().filter(archive -> { + if (archive.getPayStartDate() == null) { + Date startDate = empMap.get(archive.getEmployeeId()); + if (startDate != null) { + archive.setPayStartDate(startDate); + return true; + } else { + return false; + } + } else { + return false; + } + }).collect(Collectors.toList()); + getSalaryArchiveMapper.batchUpdate(needUpdateArchiveList); + } + + + //一键定薪 + if (StringUtils.isNotBlank(allStayAddToPay) && !StringUtils.equals(allStayAddToPay, "false")) { + List allBaseInfoList = getSIArchivesService(user).listAll(); + List ids = allBaseInfoList.stream() + .filter(f -> f.getRunStatus().equals(EmployeeStatusEnum.STAY_ADD.getValue())) + .map(InsuranceArchivesBaseInfoPO::getId) + .collect(Collectors.toList()); + Map map = getSIArchivesService(user).stayAddToPay(ids); + log.info("社保一键定薪结果:" + map); + } + + if (StringUtils.isNotBlank(allGotoFixed) && !StringUtils.equals(allGotoFixed, "false")) { + SalaryArchiveQueryParam queryParam = SalaryArchiveQueryParam.builder().build(); + queryParam.setRunStatusList(Arrays.asList(SalaryArchiveStatusEnum.PENDING.getValue())); + List salaryArchiveList = getSalaryArchiveService(user).getSalaryArchiveList(queryParam); + List ids = SalaryEntityUtil.properties(salaryArchiveList, SalaryArchiveListDTO::getId, Collectors.toList()); + Map map = getSalaryArchiveService(user).gotoFixed(ids); + log.info("薪资一键定薪结果:" + map); + } + + } + +} diff --git a/src/com/engine/salary/timer/AutoSyncResignationEmpArchiveJob.java b/src/com/engine/salary/timer/AutoSyncResignationEmpArchiveJob.java new file mode 100644 index 000000000..0d9e978c3 --- /dev/null +++ b/src/com/engine/salary/timer/AutoSyncResignationEmpArchiveJob.java @@ -0,0 +1,124 @@ +package com.engine.salary.timer; + +import com.engine.common.util.ServiceUtil; +import com.engine.salary.biz.SalaryArchiveBiz; +import com.engine.salary.entity.salaryarchive.po.SalaryArchivePO; +import com.engine.salary.entity.siarchives.po.InsuranceArchivesBaseInfoPO; +import com.engine.salary.mapper.siarchives.FundSchemeMapper; +import com.engine.salary.mapper.siarchives.OtherSchemeMapper; +import com.engine.salary.mapper.siarchives.SocialSchemeMapper; +import com.engine.salary.service.SIArchivesService; +import com.engine.salary.service.SalaryArchiveService; +import com.engine.salary.service.SalaryEmployeeService; +import com.engine.salary.service.impl.SIArchivesServiceImpl; +import com.engine.salary.service.impl.SalaryArchiveServiceImpl; +import com.engine.salary.service.impl.SalaryEmployeeServiceImpl; +import com.engine.salary.util.SalaryDateUtil; +import com.engine.salary.util.db.MapperProxyFactory; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.math.NumberUtils; +import weaver.hrm.User; +import weaver.interfaces.schedule.BaseCronJob; + +import java.util.*; + +/** + * @author Harryxzy + * @ClassName AutoSyncInsuranceArchiveJob + * @date 2023/08/14 9:30 + * @description 自动同步离职人员社保福利档案内容 + */ +public class AutoSyncResignationEmpArchiveJob extends BaseCronJob { + + private String syncInsuranceArchive; + private String syncSalaryArchive; + + private String allStayAddToPay; + private String allGotoFixed; + + + private SalaryArchiveService getSalaryArchiveService(User user) { + return ServiceUtil.getService(SalaryArchiveServiceImpl.class,user); + } + + private SalaryEmployeeService getSalaryEmployeeService(User user) { + return ServiceUtil.getService(SalaryEmployeeServiceImpl.class,user); + } + + private SalaryArchiveBiz getSalaryArchiveMapper = new SalaryArchiveBiz(); + + private SocialSchemeMapper getSocialSchemeMapper() { + return MapperProxyFactory.getProxy(SocialSchemeMapper.class); + } + + private FundSchemeMapper getFundSchemeMapper() { + return MapperProxyFactory.getProxy(FundSchemeMapper.class); + } + + private OtherSchemeMapper getOtherSchemeMapper() { + return MapperProxyFactory.getProxy(OtherSchemeMapper.class); + } + + private String preMonth; + + public SIArchivesService getSIArchivesService(User user) { + return ServiceUtil.getService(SIArchivesServiceImpl.class,user); + } + + @Override + public void execute() { + User user = new User(); + user.setUid(1); + user.setLoginid("sysadmin"); + // 获取当前日到前3个月期间离职的人员id + Calendar cal = Calendar.getInstance(); + cal.setTime(new Date()); + int preMonthValue = -2; + if (preMonth != null && NumberUtils.isCreatable(preMonth)) { + preMonthValue = -1 * Integer.valueOf(preMonth); + } + cal.add(Calendar.MONTH, preMonthValue); + Map resignationMap = getSalaryEmployeeService(user).getResignationMapByDate(SalaryDateUtil.getFormatDate(cal.getTime())); + + if (StringUtils.isBlank(syncSalaryArchive) || !StringUtils.equals(syncSalaryArchive, "false")) { + // 获取离职人员中没有设置最后发薪日期的薪资档案 + List salaryArchivePOS = getSalaryArchiveService(user).listPayEndDateIsNull(new ArrayList<>(resignationMap.keySet())); + Date now = new Date(); + List needUpdateSalaryArchiveList = new ArrayList<>(); + for(SalaryArchivePO archive : salaryArchivePOS){ + String dismissDate = resignationMap.get(archive.getEmployeeId()); + if (StringUtils.isNotBlank(dismissDate)) { + archive.setPayEndDate(SalaryDateUtil.dateStrToLocalDate(dismissDate)); + archive.setUpdateTime(now); + needUpdateSalaryArchiveList.add(archive); + } + } + if (CollectionUtils.isNotEmpty(needUpdateSalaryArchiveList)) { + getSalaryArchiveMapper.batchUpdate(needUpdateSalaryArchiveList); + } + } + if (StringUtils.isBlank(syncInsuranceArchive) || !StringUtils.equals(syncInsuranceArchive, "false")) { + // 获取离职人员中没有设置最后缴纳月的社保福利档案 +// List needSyncList = siArchivesBiz.listEndDateIsNull(new ArrayList<>(resignationMap.keySet())); + List needSyncList = getSIArchivesService(user).listEndDateIsNull(new ArrayList<>(resignationMap.keySet())); + // 设置社保、公积金最后缴纳月 + for(InsuranceArchivesBaseInfoPO po : needSyncList){ + String dismissDate = resignationMap.get(po.getEmployeeId()); + if (StringUtils.isNotEmpty(dismissDate)) { + dismissDate = StringUtils.substring(dismissDate,0,7); + // 更新社保最后缴纳月 + Long socialArchivesId = po.getSocialArchivesId(); + getSocialSchemeMapper().updateEndTime(socialArchivesId, dismissDate); + // 更新公积金最后缴纳月 + Long fundArchivesId = po.getFundArchivesId(); + getFundSchemeMapper().updateEndTime(fundArchivesId, dismissDate); + // 更新企业年金及其他福利最后缴纳月 + Long otherArchivesId = po.getOtherArchivesId(); + getOtherSchemeMapper().updateEndTime(otherArchivesId, dismissDate); + } + } + } + } + +} diff --git a/src/com/engine/salary/timer/HrmSnapshotJob.java b/src/com/engine/salary/timer/HrmSnapshotJob.java new file mode 100644 index 000000000..ac0a7a091 --- /dev/null +++ b/src/com/engine/salary/timer/HrmSnapshotJob.java @@ -0,0 +1,54 @@ +package com.engine.salary.timer; + +import cn.hutool.core.util.StrUtil; +import com.engine.salary.entity.hrm.po.HrmSnapshotPO; +import com.engine.salary.mapper.hrm.HrmSnapshotMapper; +import com.engine.salary.util.SalaryDateUtil; +import com.engine.salary.util.db.IdGenerator; +import com.engine.salary.util.db.MapperProxyFactory; +import lombok.extern.slf4j.Slf4j; +import weaver.hrm.User; +import weaver.interfaces.schedule.BaseCronJob; + +import java.time.LocalDate; +import java.util.Date; +import java.util.List; + +@Slf4j +public class HrmSnapshotJob extends BaseCronJob { + + //指定筷子时间 + private String appointSnapshotTime; + + private HrmSnapshotMapper getHrmSnapshotMapper() { + return MapperProxyFactory.getProxy(HrmSnapshotMapper.class); + } + + @Override + public void execute() { + User user = new User(); + user.setUid(1); + user.setLoginid("sysadmin"); + + try { + List hrmSnapshotPOS = getHrmSnapshotMapper().currentEmpData(); + + Date snapshotTime = StrUtil.isNotBlank(appointSnapshotTime) && SalaryDateUtil.checkDay(appointSnapshotTime) ? SalaryDateUtil.dateStrToLocalDate(appointSnapshotTime) : SalaryDateUtil.localDateToDate(LocalDate.now()); + + //先删除当日快照 + getHrmSnapshotMapper().deleteBySnapshotTime(snapshotTime); + + hrmSnapshotPOS.forEach(hrmSnapshotPO -> { + + hrmSnapshotPO.setId(IdGenerator.generate()); + hrmSnapshotPO.setSnapshotTime(snapshotTime); + + getHrmSnapshotMapper().insertIgnoreNull(hrmSnapshotPO); + + }); + }catch (Exception e){ + log.error("生成快照失败", e); + } + } + +} diff --git a/src/com/engine/salary/timer/SyncTaxAgentEmp2SobEmpJob.java b/src/com/engine/salary/timer/SyncTaxAgentEmp2SobEmpJob.java new file mode 100644 index 000000000..d1a823059 --- /dev/null +++ b/src/com/engine/salary/timer/SyncTaxAgentEmp2SobEmpJob.java @@ -0,0 +1,79 @@ +package com.engine.salary.timer; + +import com.engine.common.util.ServiceUtil; +import com.engine.salary.biz.SalarySobRangeBiz; +import com.engine.salary.entity.salarysob.po.SalarySobPO; +import com.engine.salary.entity.salarysob.po.SalarySobRangePO; +import com.engine.salary.service.SalarySobRangeService; +import com.engine.salary.service.SalarySobService; +import com.engine.salary.service.impl.SalarySobRangeServiceImpl; +import com.engine.salary.service.impl.SalarySobServiceImpl; +import com.engine.salary.util.db.IdGenerator; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import weaver.general.BaseBean; +import weaver.hrm.User; +import weaver.interfaces.schedule.BaseCronJob; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; + +/** + * 自动同步个税扣缴以为人人员范围至,账套人员范围 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Slf4j +public class SyncTaxAgentEmp2SobEmpJob extends BaseCronJob { + + private SalarySobService getSalarySobService(User user) { + return ServiceUtil.getService(SalarySobServiceImpl.class, user); + } + + private SalarySobRangeService getSalarySobRangeService(User user) { + return ServiceUtil.getService(SalarySobRangeServiceImpl.class, user); + } + + private String salarySobIds; + + + + @Override + public void execute() { + User user = new User(); + user.setUid(1); + user.setLoginid("sysadmin"); + List salarySobPOS; + if (StringUtils.isNotEmpty(salarySobIds)) { + // 只同步指定的账套 + List salarySobIdList = Arrays.asList(StringUtils.split(salarySobIds, ",")).stream().map(Long::valueOf).collect(Collectors.toList()); + salarySobPOS = getSalarySobService(user).listByIds(salarySobIdList); + } else { + salarySobPOS = getSalarySobService(user).listAll(); + } + BaseBean baseBean = new BaseBean(); + SalarySobRangeBiz salarySobRangeBiz = new SalarySobRangeBiz(); + for (SalarySobPO po : salarySobPOS) { + List salarySobRangePOS = new ArrayList<>(); + try { + baseBean.writeLog("开始同步人员范围至账套账套:{}",po.getId()); + // 保存前先删除 + salarySobRangePOS = salarySobRangeBiz.listSome(SalarySobRangePO.builder().salarySobId(po.getId()).build()); + getSalarySobRangeService(user).deleteBySalarySobIds(Collections.singletonList(po.getId())); + getSalarySobService(user).saveDefaultEmployeeRange(po); + } catch (Exception e) { + baseBean.writeLog("同步人员范围至账套账套出错:" + e.getMessage()); + salarySobRangePOS.stream().forEach(p -> p.setId(IdGenerator.generate())); + salarySobRangeBiz.batchInsert(salarySobRangePOS); + } + } + } + + +} diff --git a/src/com/engine/salary/timer/SyncTaxAgentEmpJob.java b/src/com/engine/salary/timer/SyncTaxAgentEmpJob.java new file mode 100644 index 000000000..f4e3df83a --- /dev/null +++ b/src/com/engine/salary/timer/SyncTaxAgentEmpJob.java @@ -0,0 +1,56 @@ +package com.engine.salary.timer; + +import com.engine.common.util.ServiceUtil; +import com.engine.salary.wrapper.AuthWrapper; +import com.engine.salary.wrapper.TaxAgentWrapper; +import lombok.extern.slf4j.Slf4j; +import org.springframework.util.StopWatch; +import weaver.hrm.User; +import weaver.interfaces.schedule.BaseCronJob; + +/** + * 自动同步人员 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Slf4j +public class SyncTaxAgentEmpJob extends BaseCronJob { + + private TaxAgentWrapper getTaxAgentWrapper(User user) { + return ServiceUtil.getService(TaxAgentWrapper.class, user); + } + + private AuthWrapper getAuthWrapper(User user) { + return ServiceUtil.getService(AuthWrapper.class, user); + } + + + @Override + public void execute() { + StopWatch stopWatch = new StopWatch(); + stopWatch.start("计划任务【SyncTaxAgentEmpJob】"); + start(); + stopWatch.stop(); + log.info(stopWatch.prettyPrint()); + } + + + /** + * 代码执行逻辑方法 + */ + private void start() { + try { + User user = new User(); + user.setUid(1); + getTaxAgentWrapper(null).syncAllRange(); + + //同步业务线 + getAuthWrapper(user).sync(); + } catch (Exception e) { + log.error("计划任务【SyncTaxAgentEmpJob】执行异常:" + e); + } + } +} diff --git a/src/com/engine/salary/transmethod/EncryptTransMethod.java b/src/com/engine/salary/transmethod/EncryptTransMethod.java new file mode 100644 index 000000000..8dddf382e --- /dev/null +++ b/src/com/engine/salary/transmethod/EncryptTransMethod.java @@ -0,0 +1,7 @@ +package com.engine.salary.transmethod; + +public class EncryptTransMethod { +// public static String decrypt(String source) { +// return AESEncryptUtil.decrypt(source); +// } +} diff --git a/src/com/engine/salary/transmethod/ICategoryTransMethod.java b/src/com/engine/salary/transmethod/ICategoryTransMethod.java new file mode 100644 index 000000000..b5ed6a34e --- /dev/null +++ b/src/com/engine/salary/transmethod/ICategoryTransMethod.java @@ -0,0 +1,38 @@ +package com.engine.salary.transmethod; + +/** + * @Author weaver_cl + * @Description: + * @Date 2022/3/11 + * @Version V1.0 + **/ +public class ICategoryTransMethod { + + public static String getWelfareTypeName(String type) { + switch (type) { + case "1": + return "社保"; + case "2": + return "公积金"; + case "3": + return "企业年金及其它福利"; + default: + return ""; + } + } + + + public static String getPaymentcopeTypeName(String type) { + switch (type) { + case "1": + return "公司"; + case "2": + return "个人"; + case "1,2": + case "2,1": + return "公司,个人"; + default: + return ""; + } + } +} diff --git a/src/com/engine/salary/transmethod/SISchemeTransMethod.java b/src/com/engine/salary/transmethod/SISchemeTransMethod.java new file mode 100644 index 000000000..634cc132a --- /dev/null +++ b/src/com/engine/salary/transmethod/SISchemeTransMethod.java @@ -0,0 +1,17 @@ +package com.engine.salary.transmethod; + +/** + * 社保福利转换 + */ +public class SISchemeTransMethod { + public static String getPaymentType(String type) { + switch (type) { + case "1": + return "城镇"; + case "2": + return "农村"; + default: + return ""; + } + } +} diff --git a/src/com/engine/salary/transmethod/TaxRateTransMethod.java b/src/com/engine/salary/transmethod/TaxRateTransMethod.java new file mode 100644 index 000000000..f9c8144a0 --- /dev/null +++ b/src/com/engine/salary/transmethod/TaxRateTransMethod.java @@ -0,0 +1,45 @@ +package com.engine.salary.transmethod; + +import org.apache.commons.lang.StringUtils; + +import java.util.ArrayList; + +public class TaxRateTransMethod { + public static String getSystemTypeName(String type) { + switch (type) { + case "1": + return "系统表单"; + case "0": + return "自定义表单"; + default: + return "自定义表单"; + } + } + + public static String getCheckBoxPopedom(String type) { + if ("1".equals(type)) + return "false"; + else + return "true"; + } + + /** + * @description :操作的显示隐藏 + */ + public static ArrayList getOpratePopedomWithType(String type) { + ArrayList returnList = new ArrayList(); + String edit = "true"; + String delete = "true"; + String log = "true"; + + + if(StringUtils.equals(type, "1")){ + edit = "false";//启用状态显示禁用 + delete = "false"; + } + returnList.add(edit); + returnList.add(delete); + returnList.add(log); + return returnList; + } +} diff --git a/src/com/engine/salary/transmethod/TransMethod.java b/src/com/engine/salary/transmethod/TransMethod.java new file mode 100644 index 000000000..1344fe6be --- /dev/null +++ b/src/com/engine/salary/transmethod/TransMethod.java @@ -0,0 +1,141 @@ +package com.engine.salary.transmethod; + +import com.engine.salary.enums.SalaryCycleTypeEnum; +import com.engine.salary.enums.SalaryRoundingModeEnum; +import com.engine.salary.enums.SalaryValueTypeEnum; +import com.engine.salary.enums.datacollection.AttendQuoteFieldSourceTypeEnum; +import com.engine.salary.enums.datacollection.AttendQuoteFieldTypeEnum; +import com.engine.salary.enums.datacollection.AttendQuoteSourceTypeEnum; +import com.engine.salary.enums.salaryitem.SalaryDataTypeEnum; +import com.engine.salary.util.SalaryI18nUtil; +import org.apache.commons.lang3.StringUtils; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Objects; + +public class TransMethod { + + public static String timeToDate(String time) { + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); + SimpleDateFormat timeFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String format = ""; + try { + Date parse = timeFormat.parse(time); + format = dateFormat.format(parse); + } catch (ParseException e) { + e.printStackTrace(); + } + return format; + } + + public static String timeToMoth(String time) { + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM"); + SimpleDateFormat timeFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String format = ""; + try { + Date parse = timeFormat.parse(time); + format = dateFormat.format(parse); + } catch (ParseException e) { + e.printStackTrace(); + } + return format; + } + + + /** + * 字段来源类型 + * + * @param sourceType + * @return + */ + public static String fieldSourceType(String sourceType) { + return AttendQuoteFieldSourceTypeEnum.getDefaultLabelByValue(Integer.valueOf(sourceType)); + } + + /** + * 字段类型 + * + * @param sourceType + * @return + */ + public static String fieldType(String sourceType) { + return AttendQuoteFieldTypeEnum.getDefaultLabelByValue(Integer.valueOf(sourceType)); + } + + /** + * 考勤来源类型 + * + * @param sourceType + * @return + */ + public static String sourceType(String sourceType) { + return AttendQuoteSourceTypeEnum.getDefaultLabelByValue(Integer.valueOf(sourceType)); + } + + /** + * 薪资项目进位规则 + * + * @param roundingMode + * @return + */ + public static String roundingMode(String roundingMode) { + return SalaryRoundingModeEnum.getDefaultLabelByValue(Integer.valueOf(roundingMode)); + } + + /** + * 取值方式 + * @param datasource + * @return + */ + public static String datasource(String datasource) { + return SalaryValueTypeEnum.getDefaultLabelByValue(Integer.valueOf(datasource)); + } + + /** + * 字段类型 + * @return + */ + public static String dataType(String dataType) { + return SalaryDataTypeEnum.getDefaultLabelByValue(dataType); + } + + public static String buildSalaryCycle(String salaryCycle,String salaryCycleFromDay) { + String salaryCycleStr; + SalaryCycleTypeEnum salaryCycleTypeEnum = SalaryCycleTypeEnum.parseByValue(Integer.parseInt(salaryCycle)); + if (salaryCycleTypeEnum == null) { + return StringUtils.EMPTY; + } + switch (salaryCycleTypeEnum) { + case BEFORE_LAST_MONTH: + salaryCycleStr = Objects.equals(salaryCycleFromDay, "1") ? SalaryI18nUtil.getI18nLabel(98395, "上上月1号——上上月最后一天") + : SalaryI18nUtil.getI18nLabel(98399, "上上月{0}号——上月{1}号") + .replace("{0}", "" + salaryCycleFromDay) + .replace("{1}", "" + (Integer.parseInt(salaryCycleFromDay) - 1)); + break; + case LAST_MONTH: + salaryCycleStr = Objects.equals(salaryCycleFromDay, "1") ? SalaryI18nUtil.getI18nLabel(98396, "上月1号——上月最后一天") + : SalaryI18nUtil.getI18nLabel(98400, "上月{0}号——本月{1}号") + .replace("{0}", "" + salaryCycleFromDay) + .replace("{1}", "" + (Integer.parseInt(salaryCycleFromDay) - 1)); + break; + case THIS_MONTH: + salaryCycleStr = Objects.equals(salaryCycleFromDay, "1") ? SalaryI18nUtil.getI18nLabel(98397, "本月1号——本月最后一天") + : SalaryI18nUtil.getI18nLabel(98401, "本月{0}号——下月{1}号") + .replace("{0}", "" + salaryCycleFromDay) + .replace("{1}", "" + (Integer.parseInt(salaryCycleFromDay) - 1)); + break; + case NEXT_MONTH: + salaryCycleStr = Objects.equals(salaryCycleFromDay, "1") ? SalaryI18nUtil.getI18nLabel(98398, "下月1号——下月最后一天") + : SalaryI18nUtil.getI18nLabel(98402, "下月{0}号——下下月{1}号") + .replace("{0}", "" + salaryCycleFromDay) + .replace("{1}", "" + (Integer.parseInt(salaryCycleFromDay) - 1)); + break; + default: + salaryCycleStr = ""; + } + return salaryCycleStr; + } + +} diff --git a/src/com/engine/salary/util/DataUtil.java b/src/com/engine/salary/util/DataUtil.java new file mode 100644 index 000000000..055177182 --- /dev/null +++ b/src/com/engine/salary/util/DataUtil.java @@ -0,0 +1,26 @@ +package com.engine.salary.util; + +import java.lang.reflect.Array; +import java.util.ArrayList; +import java.util.List; + +public class DataUtil { + + public static List castList(Object obj, Class clazz) { + + List result = new ArrayList(); + if (obj.getClass().isArray()) { + int len = Array.getLength(obj); + for (int i = 0; i < len; i++) { + Object o = Array.get(obj, i); + result.add(clazz.cast(o)); + } + } else if (obj instanceof List) { + for (Object o : (List) obj) { + result.add(clazz.cast(o)); + } + } + return result; + } + +} diff --git a/src/com/engine/salary/util/EnumUtil.java b/src/com/engine/salary/util/EnumUtil.java new file mode 100644 index 000000000..aad5269e0 --- /dev/null +++ b/src/com/engine/salary/util/EnumUtil.java @@ -0,0 +1,357 @@ +package com.engine.salary.util; + + +import lombok.extern.slf4j.Slf4j; +import sun.reflect.ConstructorAccessor; +import sun.reflect.FieldAccessor; +import sun.reflect.MethodAccessor; +import sun.reflect.ReflectionFactory; + +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +@Slf4j +public class EnumUtil { + + /** + * 扩展枚举(把新枚举的值加入旧枚举里,从旧枚举里删除不要的枚举值) + * @param oldEnumClass 旧枚举类 + * @param newEnumClass 需要扩展的枚举类 + * @param removeOldEnums 需要删除的旧枚举值 + * @param + * @param + * @throws Exception + */ + public static void extendEnum(Class oldEnumClass,Class newEnumClass,O... removeOldEnums) throws Exception { + boolean needToRemoveOldEnum = removeOldEnums!=null&&removeOldEnums.length>0; + if(needToRemoveOldEnum){ + removeEnum(oldEnumClass,removeOldEnums); + } + List newEnums = values(newEnumClass); + Field[] fields = getFields(newEnumClass); + for (Object newEnumObject : newEnums) { + Enum newEnum = Enum.class.cast(newEnumObject); + + List fieldTypeList = new ArrayList<>(); + //枚举名称的类型:String.class + fieldTypeList.add(String.class); + for (Field field : fields) { + fieldTypeList.add(field.getType()); + } + List fieldValueList = new ArrayList<>(); + //枚举名称 + fieldValueList.add(newEnum.name()); + for (Field field : fields) { + Object value = field.get(newEnum); + fieldValueList.add(value); + } + + Class[] fieldTypes = fieldTypeList.toArray(new Class[]{}); + String[] fieldValues = fieldValueList.toArray(new String[]{}); + addEnum(oldEnumClass,fieldTypes,fieldValues); + } + } + + /** + * 新增枚举值 + * @param enumClass 枚举类型 + * @param fieldTypes 字段的类型,第一个是枚举名类型String + * @param fieldValues 字段的值,第一个是枚举名称 + * @throws Exception + */ + public static > T addEnum(Class enumClass, Class[] fieldTypes, Object[] fieldValues) throws Exception { + if(fieldTypes==null||fieldTypes.length==0){ + throw new RuntimeException("参数fieldTypes为空"); + } + if(fieldValues==null||fieldValues.length==0){ + throw new RuntimeException("参数fieldValues为空"); + } + if(fieldTypes[0]!=String.class){ + throw new RuntimeException("参数fieldTypes[0]不是String.class"); + } + if(!(fieldValues[0] instanceof String)){ + throw new RuntimeException("参数fieldValues[0]不是字符串"); + } + if(fieldTypes.length!=fieldValues.length){ + throw new RuntimeException("参数fieldTypes和参数fieldValues的长度不一致"); + } + ReflectionFactory reflectionFactory = ReflectionFactory.getReflectionFactory(); + String enumName = fieldValues[0].toString(); + synchronized (enumClass){ + //判断name是否已经添加过了 + if(hasEnumName(enumClass,enumName)){ + log.info("枚举类{}中已存在该枚举名:{}",enumClass.getSimpleName(),enumName); + return getEnum(enumClass,enumName); + } + //name,ordinal,其他自定义字段 + List allFieldClass = new ArrayList<>(fieldTypes.length + 1); + allFieldClass.add(String.class); + allFieldClass.add(int.class); + for (int i = 1; i < fieldTypes.length; i++) { + allFieldClass.add(fieldTypes[i]); + } + Class[] classes = allFieldClass.toArray(new Class[]{}); + Constructor constructor = enumClass.getDeclaredConstructor(classes); + ConstructorAccessor constructorAccessor = reflectionFactory.newConstructorAccessor(constructor); + List allFields = new ArrayList<>(fieldValues.length + 1); + allFields.add(enumName); + int maxOrdinal = getMaxOrdinal(enumClass); + allFields.add(maxOrdinal+1); + for (int i = 1; i < fieldValues.length; i++) { + allFields.add(fieldValues[i]); + } + //调用枚举的构造方法,创建新的枚举值 + T newEnum = (T) constructorAccessor.newInstance(allFields.toArray()); + log.info("新增枚举:{}" , newEnum); + Field valuesField = enumClass.getDeclaredField("$VALUES"); + valuesField.setAccessible(true); + + //解除values属性的final限制 + Field modifiersField = Field.class.getDeclaredField("modifiers"); + modifiersField.setAccessible(true); + int modifiers = modifiersField.getInt(valuesField); + modifiers &= ~Modifier.FINAL; + modifiersField.setInt(valuesField, modifiers); + + //将新增的枚举值加入values属性里 + FieldAccessor fieldAccessor = reflectionFactory.newFieldAccessor(valuesField, false); + T[] ts = (T[]) fieldAccessor.get(enumClass); + List list = new ArrayList<>(Arrays.asList(ts)); + list.add(newEnum); + fieldAccessor.set(enumClass, list.toArray(ts)); + + //将Class对象的enumConstants和enumConstantDirectory清空(Enum.valueOf()方法会给它们赋值) + /** + * Enum.valueOf()逻辑: + * 1.取enumConstantDirectory + * 1.1如果有值则直接返回 + * 1.2如果没值,则取enumConstants,并拷贝到enumConstantDirectory,下次可直接返回 + * 1.2.1如果enumConstants有值,则返回 + * 1.2.2如果enumConstants没值,则取枚举的values属性,并拷贝到enumConstants,下次可直接返回 + * 2.enumConstantDirectory.get(name)返回 + */ + Field enumConstantDirectoryField = enumClass.getClass().getDeclaredField("enumConstantDirectory"); + enumConstantDirectoryField.setAccessible(true); + FieldAccessor enumConstantDirectoryFieldAccessor = reflectionFactory.newFieldAccessor(enumConstantDirectoryField, false); + enumConstantDirectoryFieldAccessor.set(enumClass,null); + Field enumConstantsField = enumClass.getClass().getDeclaredField("enumConstants"); + enumConstantsField.setAccessible(true); + FieldAccessor enumConstantsFieldAccessor = reflectionFactory.newFieldAccessor(enumConstantsField, false); + enumConstantsFieldAccessor.set(enumClass,null); + return newEnum; + } + } + + /** + * 获取枚举类当前最大序号 + * @param enumClass 枚举类型 + * @param + * @return + * @throws Exception + */ + public static > int getMaxOrdinal(Class enumClass) throws Exception { + List values = values(enumClass); + if(values==null||values.size()==0){ + return 0; + } + int maxOrdinal = 0; + for (T value : values) { + if(maxOrdinal + */ + public static > void removeEnum(Class enumClass, Enum... removeOldEnums) throws Exception { + if(removeOldEnums==null||removeOldEnums.length==0){ + log.warn("removeOldEnums为空"); + return; + } + ReflectionFactory reflectionFactory = ReflectionFactory.getReflectionFactory(); + synchronized (enumClass){ + Field valuesField = enumClass.getDeclaredField("$VALUES"); + valuesField.setAccessible(true); + + //解除values属性的final限制 + Field modifiersField = Field.class.getDeclaredField("modifiers"); + modifiersField.setAccessible(true); + int modifiers = modifiersField.getInt(valuesField); + modifiers &= ~Modifier.FINAL; + modifiersField.setInt(valuesField, modifiers); + + FieldAccessor fieldAccessor = reflectionFactory.newFieldAccessor(valuesField, false); + T[] oldEnumArray = (T[]) fieldAccessor.get(enumClass); + List enumList = new ArrayList<>(Arrays.asList(oldEnumArray)); + for (Enum removeOldEnum : removeOldEnums) { + //将指定的枚举值从values属性里删除 + enumList.remove(removeOldEnum); + log.info("删除枚举值:{}",removeOldEnum); + } + //把List转成数组 + T[] newEnumArray = (T[]) Arrays.copyOf(enumList.toArray(), enumList.size(), oldEnumArray.getClass()); + fieldAccessor.set(enumClass, newEnumArray); + } + } + /** + * 修改枚举属性 + * @param enumClass 枚举类型 + * @param enumName 枚举名称 + * @param attributeName 属性名 + * @param attributeValue 属性值 + * @param + * @throws Exception + */ + public static > void setAttribute(Class enumClass,String enumName,String attributeName,Object attributeValue) throws Exception { + List values = values(enumClass); + T target = null; + for (T t:values){ + if(t.name().equals(enumName)){ + target = t; + break; + } + } + if(target==null){ + throw new RuntimeException("该枚举类没有枚举名:"+enumName); + } + Field declaredField = target.getClass().getDeclaredField(attributeName); + declaredField.setAccessible(true); + declaredField.set(target,attributeValue); + } + + /** + * 修改枚举属性 + * @param targetEnum 枚举值 + * @param attributeName 属性名 + * @param attributeValue 属性值 + * @param + * @throws Exception + */ + public static > void setAttribute(T targetEnum,String attributeName,Object attributeValue) throws Exception { + Field declaredField = targetEnum.getClass().getDeclaredField(attributeName); + declaredField.setAccessible(true); + declaredField.set(targetEnum,attributeValue); + } + + /** + * 判断枚举类是否包含了指定枚举名 + * @param clazz + * @param enumName + * @param + * @return + */ + public static > boolean hasEnumName(Class clazz, String enumName) throws Exception { +// 不要用valueOf方法,因为它会初始化enumConstantDirectory使得后续调用valueOf方法后拿不到后面加入的枚举值 +// try{ +// T t = Enum.valueOf(clazz, enumName); +// if(t!=null){ +// return true; +// } +// }catch (Exception e){ +// e.printStackTrace(); +// System.err.println(e.getMessage()); +// } + List values = values(clazz); + for (T t:values){ + if(t.name().equals(enumName)){ + return true; + } + } + return false; + } + + /** + * 根据枚举类型和枚举名获取枚举值 + * @param clazz 枚举类型 + * @param enumName 枚举名称 + * @param + * @return + * @throws Exception + */ + public static > T getEnum(Class clazz, String enumName) throws Exception { + List values = values(clazz); + for (T t:values){ + if(t.name().equals(enumName)){ + return t; + } + } + return null; + } + + /** + * 获取枚举类的所有枚举值 + * @param clazz 枚举类型 + * @param + * @return + * @throws Exception + */ + public static > List values(Class clazz) throws Exception { + ReflectionFactory reflectionFactory = ReflectionFactory.getReflectionFactory(); + Field valuesField = clazz.getDeclaredField("$VALUES"); + valuesField.setAccessible(true); + FieldAccessor fieldAccessor = reflectionFactory.newFieldAccessor(valuesField, false); + T[] ts = (T[]) fieldAccessor.get(clazz); + List list = new ArrayList<>(Arrays.asList(ts)); + return list; + } + + /** + * 获取枚举类的所有枚举值 + * @param clazz 枚举类型 + * @param + * @return + * @throws Exception + */ + public static > List values2(Class clazz) throws Exception { + ReflectionFactory reflectionFactory = ReflectionFactory.getReflectionFactory(); + Method valuesMethod = clazz.getDeclaredMethod("values"); + valuesMethod.setAccessible(true); + MethodAccessor methodAccessor = reflectionFactory.newMethodAccessor(valuesMethod); + T[] ts = (T[]) methodAccessor.invoke(clazz, null); + List list = new ArrayList<>(Arrays.asList(ts)); + return list; + } + + /** + * 获取枚举的字段(排除数组类型、枚举类型) + * @param enumClass + * @return + */ + public static Field[] getFields(Class enumClass){ + List result = new ArrayList<>(); + Field[] declaredFields = enumClass.getDeclaredFields(); + for (Field field : declaredFields) { + Class type = field.getType(); + //排除数组类型(values)、枚举类型(枚举值) + if(type!=enumClass && !type.isArray()){ + field.setAccessible(true); + result.add(field); + } + } + return result.toArray(new Field[]{}); + } + + /** + * 打印枚举值 + * @param enumClass 枚举类型 + * @throws Exception + */ + public static void printEnum(Class enumClass) throws Exception { + System.out.println("+++++++++++++++++++++++"); + List values = values(enumClass); + values.stream().forEach(System.out::println); + System.out.println("+++++++++++++++++++++++"); + } + +} diff --git a/src/com/engine/salary/util/FileUtils.java b/src/com/engine/salary/util/FileUtils.java new file mode 100644 index 000000000..fe44a9192 --- /dev/null +++ b/src/com/engine/salary/util/FileUtils.java @@ -0,0 +1,88 @@ +package com.engine.salary.util; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.InputStream; +import java.util.HashSet; +import java.util.Objects; +import java.util.Set; + +public class FileUtils { + private static final String COPY_FILE_SUFFIX = "_副本"; + + /** + * 将输入流写入文件 + * @param in 输入流 + * @param path 输出文件的路径 + * @param fileName 输出文件的名称 + * + * */ + public static void writeFile(InputStream in , String path , String fileName) throws FileNotFoundException { + + FileOutputStream outputStream = new FileOutputStream(""); + + } + + + /** + * 给定一个目录和文件,若该目录存在名称相同的文件,则返回一个可用的副本文件名,否则直接返回输入的文件名。 + * @param path 文件的目录 + * @param fileName 文件名 + * @return 可用的文件名 + * */ + public static String getAvailableName(String path ,String fileName){ + + File filePath = new File(path); + + String suffix = fileName.substring(fileName.lastIndexOf(".")); + File[] files = filePath.listFiles( f -> f.getName().endsWith(suffix) ); + if ( Objects.isNull(files) ) return fileName; + + Set fileNameSet = new HashSet<>(); + for (File file: files ) { + fileNameSet.add(file.getName().substring(0 , file.getName().lastIndexOf("."))); + } + + boolean isExist = true; + int count = 1; + String tempFileName = fileName.substring(0,fileName.lastIndexOf(".")); + String tempFileName1 = tempFileName; + while(isExist){ + + if (fileNameSet.contains(tempFileName)){ + tempFileName = tempFileName1 + COPY_FILE_SUFFIX + count++; + }else{ + isExist = false; + } + + } + + return tempFileName + suffix; + } + + + /** + * 给定一个文件的完整路径,若该文件已经存在,则返回一个可用的副本文件名,否则直接返回输入的文件名。 + * @param fullPath 文件的完整路径 + * @return 可用的文件名 + * */ + public static String getAvailableName( String fullPath ){ + File file = new File(fullPath); + if ( !file.isFile() ) throw new RuntimeException( String.format("not a file [%s].",fullPath)); + + return getAvailableName( file.getParent() ,file.getName() ); + } + + /** + * 给定一个文件的完整路径,若该文件已经存在,则返回一个完整可用的副本文件名,否则直接返回输入的文件名。 + * @param fullPath 文件的完整路径 + * @return 完整可用的文件名 + * */ + public static String getAvailableFullName( String fullPath ){ + File file = new File(fullPath); + if ( !file.isFile() ) throw new RuntimeException( String.format("not a file [%s].",fullPath)); + + return file.getParent() + File.separator + getAvailableName(fullPath); + } +} diff --git a/src/com/engine/salary/util/JsonUtil.java b/src/com/engine/salary/util/JsonUtil.java new file mode 100644 index 000000000..1e6ce59ff --- /dev/null +++ b/src/com/engine/salary/util/JsonUtil.java @@ -0,0 +1,97 @@ +package com.engine.salary.util; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.parser.Feature; +import com.alibaba.fastjson.serializer.SerializerFeature; +import com.alibaba.fastjson.util.TypeUtils; + +import java.lang.reflect.Type; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +public class JsonUtil { + private static final SerializerFeature[] DEFAULT_S_FEATURES; + private static final SerializerFeature[] PRETTY_S_FEATURES; + private static final Feature[] DEFAULT_P_FEATURES; + + public JsonUtil() { + } + + public static String toJsonString(Object obj) { + return JSON.toJSONString(obj, DEFAULT_S_FEATURES); + } + + public static String toJsonString(Object obj, SerializerFeature... features) { + return JSON.toJSONString(obj, features); + } + + public static String toPrettyJson(Object object) { + return JSON.toJSONString(object, PRETTY_S_FEATURES); + } + + public static JSONObject parseJsonObject(String jsonStr) { + return JSON.parseObject(jsonStr, DEFAULT_P_FEATURES); + } + + public static T parseValue(JSONObject jsonObject, String key, Class clazz) { + if (jsonObject != null) { + T value = jsonObject.getObject(key, (Type) clazz); + return value; + } else { + return null; + } + } + + public static T parseObject(String jsonStr, Class clazz) { + return JSON.parseObject(jsonStr, (Type) clazz, DEFAULT_P_FEATURES); + } + + public static List parseList(String jsonStr, Class clazz) { + return JSON.parseArray(jsonStr, clazz); + } + + public static List parseList(Object jsonObject, Class clazz) { + String jsonStr = toJsonString(jsonObject); + return parseList(jsonStr, clazz); + } + + public static Map parseMap(String jsonStr, Class valueCls) { + Map result = new LinkedHashMap(); + Map map = JSON.parseObject(jsonStr, DEFAULT_P_FEATURES); + if (map != null && map.size() > 0) { + Iterator var4 = map.entrySet().iterator(); + + while (var4.hasNext()) { + Entry entry = (Entry) var4.next(); + Object obj = entry.getValue(); + V value = JSON.parseObject(JSON.toJSONString(obj), valueCls); + result.put(entry.getKey(), value); + } + } + + return result; + } + + public static Map parseMap(Object jsonObject, Class valueCls) { + String jsonStr = toJsonString(jsonObject); + return parseMap(jsonStr, valueCls); + } + + public static T parseBean(String jsonString, Class beanClazz) { + return parseBean(parseJsonObject(jsonString), beanClazz); + } + + public static T parseBean(JSONObject jsonObject, Class beanClazz) { + return TypeUtils.castToJavaBean(jsonObject, beanClazz); + } + + static { + DEFAULT_S_FEATURES = new SerializerFeature[]{SerializerFeature.WriteDateUseDateFormat, SerializerFeature.SortField}; + PRETTY_S_FEATURES = new SerializerFeature[]{SerializerFeature.WriteDateUseDateFormat, SerializerFeature.SortField, SerializerFeature.PrettyFormat}; + DEFAULT_P_FEATURES = new Feature[]{Feature.OrderedField}; + } +} diff --git a/src/com/engine/salary/util/ResponseResult.java b/src/com/engine/salary/util/ResponseResult.java new file mode 100644 index 000000000..2036fd1a2 --- /dev/null +++ b/src/com/engine/salary/util/ResponseResult.java @@ -0,0 +1,184 @@ +package com.engine.salary.util; + + +import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.serializer.SerializerFeature; +import com.engine.core.exception.ECException; +import com.engine.salary.common.SalaryContext; +import com.engine.salary.exception.ExceptionUtil; +import com.engine.salary.exception.SalaryRunTimeException; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import lombok.extern.slf4j.Slf4j; +import weaver.general.BaseBean; +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.HashMap; +import java.util.Map; +import java.util.function.Consumer; +import java.util.function.Function; +import java.util.function.Supplier; + +/** + * 请求执行器 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Slf4j +public class ResponseResult { + + private static final long serialVersionUID = 1L; + + private final User user; + + private final BaseBean baseBean = new BaseBean(); + + private final Boolean isLog = "true".equals(baseBean.getPropValue("hrmSalary", "log")); + + public ResponseResult(User user) { + this.user = user; + SalaryContext.get().setValue("user", user); + } + + public ResponseResult(HttpServletRequest request, HttpServletResponse response, User user) { + this.user = user; + SalaryContext.get().setValue("user", user); + SalaryContext.get().setValue("request", request); + SalaryContext.get().setValue("response", response); + } + + + /** + * 统一返回方法 + */ + public String run(Function f, T t) { + try { + if (isLog) { + log.info("run salary api , param {}", t); + } + return Ok(f.apply(t)); + } catch (SalaryRunTimeException e) { + log.error("salary api run fail , param {}", t, e); + return Error(e.getMessage()); + } catch (ECException e) { + log.error("salary api run fail , param {}", t, e); + Throwable cause = e.getCause(); + String message = ""; + while (cause != null) { + Throwable causeTmp = cause.getCause(); + if (causeTmp == null) { + message = cause.getMessage(); + } + cause = causeTmp; + } + return Error(message); + } catch (Exception e) { + log.error("salary api run fail , param {}", t, e); + return Error("系统异常!"); + } + } + + /** + * 统一返回方法(有参无返回) + */ + public String run(Consumer f, T t) { + try { + if (isLog) { + log.info("run salary api , param {}", t); + } + f.accept(t); + return Ok(); + } catch (SalaryRunTimeException e) { + log.error("salary api run fail , param {}", t, e); + return Error(e.getMessage()); + } catch (ECException e) { + log.error("salary api run fail , param {}", t, e); + return Error(ExceptionUtil.getRealMessage(e)); + } catch (Exception e) { + log.error("salary api run fail , param {}", t, e); + return Error("系统异常!", e); + } + } + + + /** + * 统一返回方法(无参有返回) + */ + public String run(Supplier f) { + try { + if (isLog) { + log.info("run salary api"); + } + return Ok(f.get()); + } catch (SalaryRunTimeException e) { + log.error("salary api run fail", e); + return Error(e.getMessage()); + } catch (ECException e) { + log.error("salary api run fail", e); + Throwable cause = e.getCause(); + return Error(cause.getMessage()); + } catch (Exception e) { + log.error("salary api run fail", e); + return Error("系统异常!", e); + } + } + + + private static String getJsonString(Object apidatas) throws JsonProcessingException { + ObjectMapper mapper = new ObjectMapper(); + return mapper.writeValueAsString(apidatas); + } + + /** + * 成功返回 + */ + private String Ok() { + Map apidatas = new HashMap<>(); + apidatas.put("status", true); + return JSONObject.toJSONString(apidatas, SerializerFeature.DisableCircularReferenceDetect); + } + + + /** + * 成功返回 + */ + private String Ok(R r) throws JsonProcessingException { + Map apidatas = new HashMap<>(); + apidatas.put("status", true); + apidatas.put("data", r); + String success = getJsonString(apidatas); + if (isLog) { + log.info("run salary api success return {}", success); + } + return success; + } + + + /** + * 失败返回 + */ + private static String Error(String message) { + Map apidatas = new HashMap<>(); + apidatas.put("status", false); + apidatas.put("errormsg", message); + return JSONObject.toJSONString(apidatas, SerializerFeature.DisableCircularReferenceDetect); + } + + + /** + * 系统异常失败返回 + */ + private static String Error(String message, Exception e) { + Map apidatas = new HashMap<>(); + apidatas.put("status", false); + apidatas.put("errormsg", message); + apidatas.put("error", e.getMessage()); + return JSONObject.toJSONString(apidatas, SerializerFeature.DisableCircularReferenceDetect); + } + +} diff --git a/src/com/engine/salary/util/SalaryAssert.java b/src/com/engine/salary/util/SalaryAssert.java new file mode 100644 index 000000000..85f701fa3 --- /dev/null +++ b/src/com/engine/salary/util/SalaryAssert.java @@ -0,0 +1,163 @@ +package com.engine.salary.util; + +import com.engine.salary.exception.SalaryRunTimeException; +import org.springframework.util.CollectionUtils; +import org.springframework.util.ObjectUtils; + +import java.util.Collection; +import java.util.Map; + +/** + * @Description: 空指针判断工具类 + * @Author: zhangheng + * @CreateDate: 2022/1/17 11:36 + * @Version: v1.0 + */ +public abstract class SalaryAssert { + + /** + * 判断入参不为null + * + * @param object 待检查参数 + * @param message 检查失败返回的异常信息 + */ + public static void notNull(Object object, String message) { + if (object == null) { + throw new SalaryRunTimeException(message); + } + } + + /** + * 判断多个入参不为null + * + * @param message 检查失败返回的异常信息 + * @param objects 待检查参数 + */ + public static void notNull(String message, Object... objects) { + for (Object obj : objects) { + if (obj == null) { + throw new SalaryRunTimeException(message); + } + } + } + + /** + * 判断入参为null + * + * @param object 待检查参数 + * @param message 检查失败返回的异常信息 + */ + public static void isNull(Object object, String message) { + if (object != null) { + throw new SalaryRunTimeException(message); + } + } + + /** + * 判断集合是否为空 + * + * @param collection 待检查参数 + * @param message 检查失败返回的异常信息 + */ + public static void isEmpty(Collection collection, String message) { + if (!CollectionUtils.isEmpty(collection)) { + throw new SalaryRunTimeException(message); + } + } + + /** + * 判断集合不为空 + * + * @param collection 待检查参数 + * @param message 检查失败返回的异常信息 + */ + public static void notEmpty(Collection collection, String message) { + if (CollectionUtils.isEmpty(collection)) { + throw new SalaryRunTimeException(message); + } + } + + /** + * 判断数组是否为空 + * + * @param arr 待检查参数 + * @param message 检查失败返回的异常信息 + */ + public static void notEmpty(Object[] arr, String message) { + if (ObjectUtils.isEmpty(arr)) { + throw new SalaryRunTimeException(message); + } + } + + /** + * 判断map是否为空 + * + * @param map 待检查参数 + * @param message 检查失败返回的异常信息 + */ + public static void notEmpty(Map map, String message) { + if (CollectionUtils.isEmpty(map)) { + throw new SalaryRunTimeException(message); + } + } + + /** + * 判断数组元素是否为空 + * + * @param arr 待检查参数 + * @param message 检查失败返回的异常信息 + */ + public static void notNullElement(Object[] arr, String message) { + if (arr != null) { + for (Object obj : arr) { + if (obj == null) { + throw new SalaryRunTimeException(message); + } + } + } + } + + /** + * 判断boolean + * + * @param expression 待检查参数 + * @param message 检查失败返回的异常信息 + */ + public static void isTrue(boolean expression, String message) { + if (!expression) { + throw new SalaryRunTimeException(message); + } + } + + public static void isFalse(boolean expression, String message) { + if (expression) { + throw new SalaryRunTimeException(message); + } + } + + public static void isBlank(CharSequence cs, String message) { + int strLen; + if (cs != null && (strLen = cs.length()) != 0) { + for (int i = 0; i < strLen; ++i) { + if (!Character.isWhitespace(cs.charAt(i))) { + throw new SalaryRunTimeException(message); + } + } + } + } + + public static void notBlank(CharSequence cs, String message) { + int strLen; + if (cs != null && (strLen = cs.length()) != 0) { + for (int i = 0; i < strLen; ++i) { + if (Character.isWhitespace(cs.charAt(i))) { + throw new SalaryRunTimeException(message); + } + } + } + if (cs == null || cs.length() == 0) { + throw new SalaryRunTimeException(message); + } + + } +} diff --git a/src/com/engine/salary/util/SalaryDateUtil.java b/src/com/engine/salary/util/SalaryDateUtil.java new file mode 100644 index 000000000..09983dd1f --- /dev/null +++ b/src/com/engine/salary/util/SalaryDateUtil.java @@ -0,0 +1,609 @@ +package com.engine.salary.util; + +import cn.hutool.core.util.StrUtil; +import com.engine.salary.common.LocalDateRange; +import com.engine.salary.exception.SalaryRunTimeException; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.math.NumberUtils; +import org.apache.commons.lang3.time.FastDateFormat; +import org.jetbrains.annotations.NotNull; +import weaver.general.BaseBean; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.time.*; +import java.time.format.DateTimeFormatter; +import java.util.Calendar; +import java.util.Date; +import java.util.Objects; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * @description: 时间工具类 + * @author: xiajun + * @modified By: xiajun + * @date: Created in 10/19/21 4:23 PM + * @version:v1.0 + */ +@Slf4j +public class SalaryDateUtil { + + public static final ZoneId CTT = ZoneId.of(ZoneId.SHORT_IDS.get("CTT")); + public static final ZoneOffset SHANGHAI_ZONE_OFF_SET = ZoneOffset.ofHours(8); + + public static final FastDateFormat DATE_FORMAT = FastDateFormat.getInstance("yyyy-MM-dd"); + public static final FastDateFormat DATETIME_FORMAT = FastDateFormat.getInstance("yyyy-MM-dd HH:mm:ss"); + + public static final DateTimeFormatter YEAR_FORMATTER = DateTimeFormatter.ofPattern("yyyy"); + public static final DateTimeFormatter MONTH_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM"); + public static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + public static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + + public static final String MONTH_FORMATTER_PATTERN = "yyyy-MM"; + public static final String DATE_FORMATTER_PATTERN = "yyyy-MM-dd"; + public static final String DATE_TIME_FORMATTER_PATTERN = "yyyy-MM-dd HH:mm:ss"; + /** + * yyyy-MM + **/ + private static final String MONTH_REGEX = "^([1-9]\\d{3})-(([0][1-9])|([1][0-2]))$"; + /** + * yyyy-MM-dd + **/ + private static final String DAY_REGEX = "^[1-9]\\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$"; + /** + * 含斜杠日期格式 + */ + private static final String DAY_BAR_REGEX = "^[1-9]\\d{3}/([1-9]|1[0-2])/([1-9]|[1-2][0-9]|3[0-1])$"; + + public static Long localDate2EpochMilli(LocalDate localDate) { + if (localDate == null) { + return NumberUtils.LONG_ZERO; + } + return localDate.atStartOfDay(ZoneId.systemDefault()).toInstant().toEpochMilli(); + } + + public static Long localDateTime2EpochMilli(LocalDateTime localDateTime) { + if (localDateTime == null) { + return NumberUtils.LONG_ZERO; + } + return localDateTime.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli(); + } + + public static Long localDateTime2EpochMilli(Date localDateTime) { + if (localDateTime == null) { + return NumberUtils.LONG_ZERO; + } + return localDateTime.getTime(); + } + + public static String getFormatYearMonth(LocalDate localDate) { + if (localDate == null) { + return StringUtils.EMPTY; + } + try { + return localDate.format(MONTH_FORMATTER); + } catch (Exception e) { + log.warn("格式化月份错误", e); + return StringUtils.EMPTY; + } + } + + + public static String getFormatYearMonth(Date localDate) { + if (localDate == null) { + return StringUtils.EMPTY; + } + try { + SimpleDateFormat simpleDateFormat = new SimpleDateFormat(MONTH_FORMATTER_PATTERN); + return simpleDateFormat.format(localDate); + } catch (Exception e) { + log.warn("格式化月份错误", e); + return StringUtils.EMPTY; + } + } + + public static String getFormatYearMonth(YearMonth localDate) { + if (localDate == null) { + return StringUtils.EMPTY; + } + return localDate.format(DateTimeFormatter.ofPattern("yyyy-MM")); + + } + + public static String getFormatLocalDate(LocalDate localDate) { + if (localDate == null) { + return StringUtils.EMPTY; + } + try { + return localDate.format(DATE_FORMATTER); + } catch (Exception e) { + log.warn("格式化日期错误", e); + return StringUtils.EMPTY; + } + } + + public static String getFormatDate(Date localDate) { + if (localDate == null) { + return StringUtils.EMPTY; + } + try { + SimpleDateFormat simpleDateFormat = new SimpleDateFormat(DATE_FORMATTER_PATTERN); + return simpleDateFormat.format(localDate); + } catch (Exception e) { + log.warn("格式化日期错误", e); + return StringUtils.EMPTY; + } + } + + public static String getFormatLocalDate(LocalDateTime localDateTime) { + if (localDateTime == null) { + return StringUtils.EMPTY; + } + try { + return localDateTime.format(DATE_FORMATTER); + } catch (Exception e) { + log.warn("格式化日期错误", e); + return StringUtils.EMPTY; + } + } + + public static String getFormatLocalDateTime(LocalDateTime localDateTime) { + if (localDateTime == null) { + return StringUtils.EMPTY; + } + try { + return localDateTime.format(DATE_TIME_FORMATTER); + } catch (Exception e) { + log.warn("格式化日期错误", e); + return StringUtils.EMPTY; + } + } + + public static String getFormatLocalDateTime(Date localDateTime) { + if (localDateTime == null) { + return StringUtils.EMPTY; + } + try { + SimpleDateFormat simpleDateFormat = new SimpleDateFormat(DATE_TIME_FORMATTER_PATTERN); + return simpleDateFormat.format(localDateTime); + } catch (Exception e) { + log.warn("格式化日期错误", e); + return StringUtils.EMPTY; + } + } + + public static LocalDateTime dateToLocalDateTime(Date date) { + Instant instant = date.toInstant(); + ZoneId zone = ZoneId.systemDefault(); + return LocalDateTime.ofInstant(instant, zone); + } + + public static LocalDate dateToLocalDate(Date date) { + return date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); + } + + public static Date localDateToDate(LocalDate localDate) { + if (null == localDate) { + return null; + } + ZonedDateTime zonedDateTime = localDate.atStartOfDay(ZoneId.systemDefault()); + return Date.from(zonedDateTime.toInstant()); + } + + public static Date localDateTimeToDate(LocalDateTime localDateTime) { + if (null == localDateTime) { + return null; + } + return Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant()); + } + + public static String getFormatLocalDate(Date date) { + if (date == null) { + return StringUtils.EMPTY; + } + LocalDateTime localDateTime = dateToLocalDateTime(date); + return getFormatLocalDate(localDateTime); + } + + public static YearMonth localDate2YearMonth(Date localDate) { + if (localDate == null) { + return null; + } + Calendar c = Calendar.getInstance(); + c.setTime(localDate); + int year = c.get(Calendar.YEAR); + int month = c.get(Calendar.MONTH) + 1; + return YearMonth.of(year, month); + } + + public static YearMonth String2YearMonth(String localDate) { + if (checkDay(localDate)) { + return null; + } + + return YearMonth.parse(localDate); + } + + public static Integer date2Year(Date localDate) { + if (localDate == null) { + return null; + } + Calendar c = Calendar.getInstance(); + c.setTime(localDate); + int year = c.get(Calendar.YEAR); + return year; + } + + public static LocalDateRange localDate2Range(Date localDate) { + if (localDate == null) { + return null; + } + return LocalDateRange.builder() + .fromDate(getFirstDayDateOfMonth(localDate)) + .endDate(getLastDayOfMonth(localDate)) + .build(); + } + + public static LocalDateRange localDate2YearRange(Date localDate) { + if (localDate == null) { + return null; + } + return LocalDateRange.builder() + .fromDate(getFirstDayDateOfYear(localDate)) + .endDate(getLastDayOfYear(localDate)) + .build(); + } + + public static Date getFirstDayDateOfMonth(final Date date) { + final Calendar cal = Calendar.getInstance(); + cal.setTime(date); + final int last = cal.getActualMinimum(Calendar.DAY_OF_MONTH); + cal.set(Calendar.DAY_OF_MONTH, last); + return cal.getTime(); + } + + public static Date getFirstDayDateOfMonthWithMinutesAndSeconds(final Date date) { + final Calendar cal = Calendar.getInstance(); + cal.setTime(date); + final int last = cal.getActualMinimum(Calendar.DAY_OF_MONTH); + cal.set(Calendar.DAY_OF_MONTH, last); + cal.set(Calendar.HOUR_OF_DAY, 0); + cal.set(Calendar.MINUTE, 0); + cal.set(Calendar.SECOND, 0); + cal.set(Calendar.MILLISECOND, 0); + return cal.getTime(); + } + + public static Date getLastDayOfMonth(final Date date) { + final Calendar cal = Calendar.getInstance(); + cal.setTime(date); + final int last = cal.getActualMaximum(Calendar.DAY_OF_MONTH); + cal.set(Calendar.DAY_OF_MONTH, last); + return cal.getTime(); + } + + public static Date getFirstDayDateOfYear(final Date date) { + final Calendar cal = Calendar.getInstance(); + cal.setTime(date); + final int last = cal.getActualMinimum(Calendar.DAY_OF_YEAR); + cal.set(Calendar.DAY_OF_YEAR, last); + return cal.getTime(); + } + + public static Date getLastDayOfYear(final Date date) { + final Calendar cal = Calendar.getInstance(); + cal.setTime(date); + final int last = cal.getActualMaximum(Calendar.DAY_OF_YEAR); + cal.set(Calendar.DAY_OF_YEAR, last); + return cal.getTime(); + } + + + public static String getMonthBegin(String specifiedDay) { + int year; + int month; + Pattern pattern = Pattern.compile("\\d+-\\d+"); + Matcher matcher = pattern.matcher(specifiedDay); + if (StringUtils.isEmpty(specifiedDay) || !matcher.matches()) { + return null; + } else { + year = Integer.parseInt(specifiedDay.split("-")[0]); + month = Integer.parseInt(specifiedDay.split("-")[1]); + } + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + Calendar calendar = Calendar.getInstance(); + calendar.set(Calendar.YEAR, year); + calendar.set(Calendar.MONTH, month - 1); + calendar.set(Calendar.DAY_OF_MONTH, 1); + calendar.set(Calendar.HOUR_OF_DAY, 0); + calendar.set(Calendar.MINUTE, 0); + calendar.set(Calendar.SECOND, 0); + calendar.set(Calendar.MILLISECOND, 0); + Date startDate = calendar.getTime(); + return sdf.format(startDate); + } + + public static String getYearMonth(int yearNum, int monthNum) { + LocalDateTime dateTime = LocalDateTime.now(); + int year = dateTime.getYear() + yearNum; + int month = dateTime.getMonthValue() + monthNum; + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM"); + Calendar calendar = Calendar.getInstance(); + calendar.set(Calendar.YEAR, year); + calendar.set(Calendar.MONTH, month - 1); + calendar.set(Calendar.DAY_OF_MONTH, 1); + calendar.set(Calendar.HOUR_OF_DAY, 0); + calendar.set(Calendar.MINUTE, 0); + calendar.set(Calendar.SECOND, 0); + calendar.set(Calendar.MILLISECOND, 0); + Date startDate = calendar.getTime(); + return sdf.format(startDate); + } + + /** + * 检查年月格式 + * + * @param yearMonth + * @return + */ + public static boolean checkYearMonth(String yearMonth) { + return Pattern.matches(MONTH_REGEX, yearMonth); + } + + /** + * 检查日期格式 + * + * @param day + * @return + */ + public static boolean checkDay(String day) { + return Pattern.matches(DAY_REGEX, day) || Pattern.matches(DAY_BAR_REGEX, day); + } + + public static Date parse(String date, String pattern) { + SimpleDateFormat format = new SimpleDateFormat(pattern); + try { + return format.parse(date); + } catch (ParseException e) { + new BaseBean().writeLog(String.format("日期解析异常: %s, %s", date, pattern)); + } + return null; + } + + + /** + * LocalDate转YearMonth + * + * @param localDate + * @return + */ + public static YearMonth toYearMonth(LocalDate localDate) { + Objects.requireNonNull(localDate, "localDate"); + return YearMonth.of(localDate.getYear(), localDate.getMonthValue()); + } + + + /** + * YearMonth转Date + * 注意dayOfMonth范围:1到31之间,最大值根据月份确定特殊情况,如2月闰年29,非闰年28 + * 如果要转换为当月最后一天,可以使用下面方法:toDateEndOfMonth(YearMonth) + * + * @param yearMonth + * @param dayOfMonth + * @return + */ + public static Date toDate(YearMonth yearMonth, int dayOfMonth) { + Objects.requireNonNull(yearMonth, "yearMonth"); + return localDateToDate(yearMonth.atDay(dayOfMonth)); + } + + /** + * YearMonth转Date,转换为当月第一天 + * + * @param yearMonth + * @return + */ + public static Date toDateStartOfMonth(YearMonth yearMonth) { + return toDate(yearMonth, 1); + } + + /** + * YearMonth转Date,转换为当月最后一天 + * + * @param yearMonth + * @return + */ + public static Date toDateEndOfMonth(YearMonth yearMonth) { + Objects.requireNonNull(yearMonth, "yearMonth"); + return localDateToDate(yearMonth.atEndOfMonth()); + } + + + /** + * YearMonth转LocalDate + * 注意dayOfMonth范围:1到31之间,最大值根据月份确定特殊情况,如2月闰年29,非闰年28 + * 如果要转换为当月最后一天,可以使用下面方法:toLocalDateEndOfMonth(YearMonth) + * + * @param yearMonth + * @param dayOfMonth + * @return + */ + public static LocalDate toLocalDate(YearMonth yearMonth, int dayOfMonth) { + Objects.requireNonNull(yearMonth, "yearMonth"); + return yearMonth.atDay(dayOfMonth); + } + + /** + * YearMonth转LocalDate,转换为当月第一天 + * + * @param yearMonth + * @return + */ + public static LocalDate toLocalDateStartOfMonth(YearMonth yearMonth) { + return toLocalDate(yearMonth, 1); + } + + /** + * YearMonth转LocalDate,转换为当月最后一天 + * + * @param yearMonth + * @return + */ + public static LocalDate toLocalDateEndOfMonth(YearMonth yearMonth) { + Objects.requireNonNull(yearMonth, "yearMonth"); + return yearMonth.atEndOfMonth(); + } + + /** + * String转Date + * + * @param date + * @return + */ + public static Date stringToDateTime(String date) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); + Date parse = null; + if (date != null) { + try { + parse = sdf.parse(date); + } catch (ParseException e) { + throw new RuntimeException(e); + } + } + return parse; + } + + public static Date stringToDate(String date) { + return dateStrToLocalDate(date); + } + + //格式化日期 + public static String strToDateLong(String strDate) { + Date date = new Date(); + try { + date = new SimpleDateFormat("yyyyMMddHHmmss").parse(strDate + "000000");//先按照原格式转换为时间 + } catch (ParseException e) { + e.printStackTrace(); + } + String str = new SimpleDateFormat("yyyy-MM").format(date);//再将时间转换为对应格式字符串 + return str; + } + + public static Date dateStrToLocalYearMonth(String date) { + Date localDate = null; + try { + date = date.substring(0, 7); + if (date.contains("/")) { + SimpleDateFormat format = new SimpleDateFormat("yyyy/MM"); + localDate = format.parse(date); + } else if (date.contains("-")) { + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM"); + localDate = format.parse(date); + } + } catch (Exception e) { + log.error("日期解析异常,{}", date); + localDate = null; + } + + return localDate; + } + + public static Date dateStrToLocalDate(String date) { + Date localDate = null; + try { + date = date.substring(0, 10); + if (date.contains("/")) { + SimpleDateFormat format = new SimpleDateFormat("yyyy/MM/dd"); + localDate = format.parse(date); + } else if (date.contains("-")) { + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + localDate = format.parse(date); + } + } catch (Exception e) { + log.error("日期解析异常,{}", date); + localDate = null; + } + + return localDate; + } + + public static Date dateStrToLocalTime(String date) { + Date localDate = null; + try { + if (date.contains("/")) { + SimpleDateFormat format = new SimpleDateFormat("yyyy/MM/dd hh:mm:ss"); + localDate = format.parse(date); + } else if (date.contains("-")) { + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); + localDate = format.parse(date); + } + } catch (Exception e) { + log.error("日期解析异常,{}", date); + localDate = null; + } + + return localDate; + } + + @NotNull + public static Boolean monthInRange(String billMonth, String startMonth, String endMonth) { + billMonth = billMonth + "-01"; + Date billMonthDate = SalaryDateUtil.dateStrToLocalDate(billMonth); + Boolean inDataRange = true; + if (StringUtils.isNotBlank(startMonth)) { + startMonth = startMonth + "-01"; + Date socialStartDate = SalaryDateUtil.dateStrToLocalDate(startMonth); + if(socialStartDate == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "年月解析异常,请检查档案中相关数据设置") + ":" + startMonth.substring(0, startMonth.length() - 3)); + } else if (billMonthDate.before(socialStartDate)) { + inDataRange = false; + } + } + if (StringUtils.isNotBlank(endMonth)) { + endMonth = endMonth + "-01"; + Date socialEndDate = SalaryDateUtil.dateStrToLocalDate(endMonth); + if(socialEndDate == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "年月解析异常,请检查档案中相关数据设置") + ":" + endMonth.substring(0, endMonth.length() - 3)); + } else if (billMonthDate.after(socialEndDate)) { + inDataRange = false; + } + } + return inDataRange; + } + + /** + * 转换时间对象 + * + * @param dateTime LocalDateTime + * @return Date + * @see SalaryDateUtil#toDate(LocalDateTime, String) + */ + public static Date toDate(LocalDateTime dateTime) { + return toDate(dateTime, null); + } + + + /** + * 转换时间对象 + * + * @param dateTime LocalDateTime + * @param offset 时区,e.g. +8 + * @return Date + */ + public static Date toDate(LocalDateTime dateTime, String offset) { + if (dateTime == null) { + return null; + } + ZoneId zoneOffset = StrUtil.isNotEmpty(offset) ? ZoneOffset.of(offset) : ZoneOffset.systemDefault(); + return Date.from(dateTime.atZone(zoneOffset).toInstant()); + } + + public static Date plusMonths(Date date, int i) { + LocalDate localDate = SalaryDateUtil.dateToLocalDate(date).plusMonths(i); + return SalaryDateUtil.localDateToDate(localDate); + } +} + + diff --git a/src/com/engine/salary/util/SalaryEntityUtil.java b/src/com/engine/salary/util/SalaryEntityUtil.java new file mode 100644 index 000000000..0b2a6d474 --- /dev/null +++ b/src/com/engine/salary/util/SalaryEntityUtil.java @@ -0,0 +1,376 @@ +package com.engine.salary.util; + +import com.alibaba.fastjson.JSON; +import com.engine.salary.enums.SalaryRoundingModeEnum; +import com.google.common.collect.Maps; +import com.google.common.collect.Sets; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.collections4.MapUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.math.NumberUtils; + +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.text.DecimalFormat; +import java.util.*; +import java.util.concurrent.ConcurrentHashMap; +import java.util.function.Function; +import java.util.function.Predicate; +import java.util.stream.Collector; +import java.util.stream.Collectors; + +/** + * 实体类相关 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SalaryEntityUtil { + + private static final DecimalFormat decimalFormat = new DecimalFormat("#,##0.00"); + + /** + * 数字正则表达式 + * 包含负数、正数、小数、0、0.00000等 + */ + public static final String NUMBER_REGEX = "(-?[1-9]\\d*\\.?\\d+)|(-?0\\.\\d*[0-9])|(\\d+)"; + + /** + * 千分位格式化 + * + * @param originMap 原始map + * @param targetMap 目标map + */ + public static void thousandthConvert(Map originMap, Map targetMap) { + + if (MapUtils.isNotEmpty(originMap)) { + originMap.forEach((k, v) -> { + if (StringUtils.isNotBlank(String.valueOf(v))) { + targetMap.put(k, decimalFormat.format(Double.valueOf(String.valueOf(v)))); + } + }); + } + } + + /** + * 千分位格式化 + * + * @param originString 原始字符串 + * @return 格式化后的字符串 + */ + public static String thousandthConvert(String originString) { + if (StringUtils.isNotBlank(originString)) { + return decimalFormat.format(Double.valueOf(originString)); + } + return "0.00"; + } + + /** + * 判断对象或对象数组中每一个对象是否为空: 对象为null,字符序列长度为0,集合类、Map为empty + * + * @param obj + * @return + */ + public static boolean isNullOrEmpty(Object obj) { + if (obj == null) { + return true; + } + if (obj instanceof CharSequence) { + return ((CharSequence) obj).length() == 0; + } + if (obj instanceof Collection) { + return ((Collection) obj).isEmpty(); + } + if (obj instanceof Map) { + return ((Map) obj).isEmpty(); + } + if (obj instanceof Object[]) { + Object[] object = (Object[]) obj; + if (object.length == 0) { + return true; + } + boolean empty = true; + for (int i = 0; i < object.length; i++) { + if (!isNullOrEmpty(object[i])) { + empty = false; + break; + } + } + return empty; + } + + return false; + } + + public static boolean isNotNullOrEmpty(Object obj) { + return !isNullOrEmpty(obj); + } + + public static A properties(Collection objs, Function function, Collector collectors) { + return objs.stream().map(function).collect(collectors); + } + + public static Set properties(Collection objs, Function function) { + if (CollectionUtils.isEmpty(objs)) { + return Sets.newHashSet(); + } + return properties(objs, function, Collectors.toSet()); + } + + public static Map convert2Map(Collection objs, Function function) { + if (CollectionUtils.isEmpty(objs)) { + return Maps.newHashMap(); + } + return objs.stream().collect(Collectors.toMap(function, Function.identity(), (a, b) -> a)); + } + + public static Map convert2Map(Collection objs, Function keyMapper, Function valueMapper) { + if (CollectionUtils.isEmpty(objs)) { + return Maps.newHashMap(); + } + return objs.stream() + .filter(e -> valueMapper.apply(e) != null && keyMapper.apply(e) != null) + .collect(Collectors.toMap(keyMapper, valueMapper, (a, b) -> a)); + } + + public static Map> group2Map(Collection objs, Function function) { + if (CollectionUtils.isEmpty(objs)) { + return Maps.newHashMap(); + } + return objs.stream().collect(Collectors.groupingBy(function)); + } + + public static Map> group2Map(Collection objs, Function keyMapper, Function valueMapper) { + if (CollectionUtils.isEmpty(objs)) { + return Maps.newHashMap(); + } + return objs.stream() + .filter(e -> keyMapper.apply(e) != null && valueMapper.apply(e) != null) + .collect(Collectors.groupingBy(keyMapper, + Collectors.collectingAndThen(Collectors.toList(), e -> e.stream().map(valueMapper).collect(Collectors.toSet())))); + } + + public static Map> group2ListMap(Collection objs, Function keyMapper, Function valueMapper) { + if (CollectionUtils.isEmpty(objs)) { + return Maps.newHashMap(); + } + return objs.stream() + .filter(e -> keyMapper.apply(e) != null && valueMapper.apply(e) != null) + .collect(Collectors.groupingBy(keyMapper, + Collectors.collectingAndThen(Collectors.toList(), e -> e.stream().map(valueMapper).collect(Collectors.toList())))); + } + + /** + * LinkedHashMap有序去重 + * + * @param keyExtractor + * @param + * @return + */ + public static Predicate distinctByKey(Function keyExtractor) { + LinkedHashMap map = new LinkedHashMap<>(); + return t -> map.putIfAbsent(keyExtractor.apply(t), Boolean.TRUE) == null; + } + + /** + * ConcurrentHashMap无序去重 + * + * @param keyExtractor + * @param + * @return + */ + public static Predicate distinctByKeyMap(Function keyExtractor) { + ConcurrentHashMap map = new ConcurrentHashMap<>(); + return t -> map.putIfAbsent(keyExtractor.apply(t), Boolean.TRUE) == null; + } + + public static BigDecimal reduce(Collection objs, Function function) { + if (CollectionUtils.isEmpty(objs)) { + return BigDecimal.ZERO; + } + return objs.stream() + .filter(e -> function.apply(e) != null) + .map(function) + .reduce(BigDecimal.ZERO, BigDecimal::add); + } + + public static BigDecimal empty2Zero(String value) { + if (StringUtils.isEmpty(value)) { + return BigDecimal.ZERO; + } + try { + return new BigDecimal(value); + } catch (Exception e) { + return BigDecimal.ZERO; + } + } + + + /** + * 进位规则 + * @param newScale 小数位 + * @param rententionRule 进位规则 + * @param value 值 + * @return + */ + public static BigDecimal carryRule(Integer newScale, Integer rententionRule, BigDecimal value) { + RoundingMode roundingMode = RoundingMode.HALF_UP; + //原始数据 + if (Objects.equals(rententionRule, SalaryRoundingModeEnum.RAW_DATA.getValue())) { + roundingMode = RoundingMode.DOWN; + } + //四舍五入 + if (Objects.equals(rententionRule, SalaryRoundingModeEnum.ROUNDING.getValue())) { + roundingMode = RoundingMode.HALF_UP; + } + //向上舍入 + if (Objects.equals(rententionRule, SalaryRoundingModeEnum.ROUND_UP.getValue())) { + roundingMode = RoundingMode.UP; + } + //向下舍入 + if (Objects.equals(rententionRule, SalaryRoundingModeEnum.ROUND_DOWN.getValue())) { + roundingMode = RoundingMode.DOWN; + } + //见分取角(只取保留小数后一位向上舍入) + if (Objects.equals(rententionRule, SalaryRoundingModeEnum.CEILING.getValue())) { + value = value.setScale(newScale + 1, RoundingMode.FLOOR); + roundingMode = RoundingMode.UP; + } + //向上取偶 + if (Objects.equals(rententionRule, SalaryRoundingModeEnum.UP_EVEN.getValue())) { + value = value.setScale(newScale, RoundingMode.UP); + + int number = value.intValue(); + if (number % 2 != 0) { + value = value.add(BigDecimal.valueOf(1)); + } + } + + return value.setScale(newScale, roundingMode); + } + + /** + * 两个集合是否有交集 + * + * @param list1 + * @param list2 + * @param + * @return + */ + public static boolean judgeIntersection(List list1, List list2) { + boolean flag = false; + List origin = new ArrayList<>(); + origin.addAll(list1); + origin.retainAll(list2); + if (origin.size() > 0) { + flag = true; + } + return flag; + } + + /** + * String转Long + * + * @param obj + * @return + */ + public static Long string2Long(String obj) { + if (NumberUtils.isCreatable(obj)) { + return Long.valueOf(obj); + } + return null; + } + + /** + * String转Integer + * + * @param obj + * @return + */ + public static Integer string2Integer(String obj) { + if (NumberUtils.isCreatable(obj)) { + return Integer.valueOf(obj); + } + return null; + } + + /** + * String转BigDecimal + * + * @param obj + * @return + */ + public static BigDecimal string2BigDecimal(String obj) { + if (NumberUtils.isCreatable(obj)) { + return new BigDecimal(obj); + } + return null; + } + + /** + * String转BigDecimal + * + * @param obj + * @return + */ + public static BigDecimal string2BigDecimalDefault0(String obj) { + if (NumberUtils.isCreatable(obj)) { + return new BigDecimal(obj); + } + return BigDecimal.ZERO; + } + + /** + * 判断字符串是否等于0 + * + * @param obj + * @return + */ + public static boolean StringEqZERO(String obj) { + if (NumberUtils.isCreatable(obj)) { + return BigDecimal.ZERO.compareTo(new BigDecimal(obj)) == 0; + } + return false; + } + + + public static Double string2DoubleDefault0(String obj) { + if (NumberUtils.isCreatable(obj)) { + return new Double(obj); + } + return new Double("0.0"); + } + + /** + * 两个集合交集,(forEasy) + * + * @param arr1 + * @param arr2 + * @return + */ + public static Collection intersectionForList(Collection arr1, Collection arr2) { + + Collection resultList = new ArrayList<>(); + + if (CollectionUtils.isEmpty(arr1) || CollectionUtils.isEmpty(arr1)) { + return resultList; + } + arr1.forEach(a1 -> { + if (arr2.contains(a1)) { + resultList.add(a1); + } + }); + return resultList; + } + + public static String toJSONString(Object obj) { + if (obj != null) { + return JSON.toJSONString(obj); + } + return ""; + } + + +} diff --git a/src/com/engine/salary/util/SalaryEnumUtil.java b/src/com/engine/salary/util/SalaryEnumUtil.java new file mode 100644 index 000000000..5e1eb1954 --- /dev/null +++ b/src/com/engine/salary/util/SalaryEnumUtil.java @@ -0,0 +1,111 @@ +package com.engine.salary.util; + +import com.engine.salary.enums.BaseEnum; +import com.engine.salary.enums.sicategory.PaymentScopeEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang.StringUtils; + +import java.lang.reflect.Method; +import java.util.*; +import java.util.stream.Collectors; + +/** + * 枚举工具类 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Slf4j +public class SalaryEnumUtil { + + /** + * 根据枚举的value获取枚举对象 + * + * @param value 枚举中的value + * @param list + * @param T + * @param + * @return + */ + @SuppressWarnings("unchecked") + public static T enumMatchByValue(Integer value, BaseEnum[] list, Class> T) { + return (T) Arrays.stream(list).filter(item -> Objects.equals(item.getValue(), value)).findFirst().get(); + } + + /** + * 根据枚举的value获取枚举对象 + * + * @param value + * @param clazz + * @param + * @param + * @return + */ + public static , R> T enumMatchByValue(R value, Class clazz) { + T[] enumConstants = clazz.getEnumConstants(); + for (T enumConstant : enumConstants) { + if (Objects.equals(enumConstant.getValue(), value)) { + return enumConstant; + } + } + return null; + } + + /** + * 枚举数组转字符串 + * + * @param list + * @return + */ + public static String enumArrToString(BaseEnum[] list) { + List collect = Arrays.stream(list).map(item -> String.valueOf(item.getValue())).collect(Collectors.toList()); + return StringUtils.join(collect, ","); + } + + public static PaymentScopeEnum[] stringToEnums(String values, String charSequence) { + String[] arr = values.split(charSequence); + PaymentScopeEnum[] enumConstants = PaymentScopeEnum.values(); + List collect = Arrays.stream(arr) + .map(item -> Arrays.stream(enumConstants).filter(s -> Objects.equals(String.valueOf(s.getValue()), item)).findFirst().get()).collect(Collectors.toList()); + return collect.toArray(new PaymentScopeEnum[collect.size()]); + } + + + /** + * 获取枚举下拉列表 + * @param enumName 枚举路径,列如:com.engine.salary.enums.salaryarchive.SalaryArchiveStatusEnum + * @return + */ + public static List> enumSelectList(String enumName) { + + try { + List> keyValueList = new ArrayList>(); + + Class cls = Class.forName(enumName); + + Method method = cls.getMethod("values"); + + BaseEnum enums[] = (BaseEnum[]) method.invoke(null, null); + + for (BaseEnum enumMessage : enums) { + Map hashMap = new HashMap(); + hashMap.put("enum", enumMessage); + hashMap.put("value", enumMessage.getValue()); + hashMap.put("defaultLabel", enumMessage.getDefaultLabel()); + hashMap.put("labelId", enumMessage.getLabelId()); + keyValueList.add(hashMap); + + } + return keyValueList; + + } catch (Exception e) { + log.error("获取枚举下拉列表异常", e); + throw new SalaryRunTimeException("指定类型未找到"); + } + + + } +} diff --git a/src/com/engine/salary/util/SalaryFormItemUtil.java b/src/com/engine/salary/util/SalaryFormItemUtil.java new file mode 100644 index 000000000..9b0fe365d --- /dev/null +++ b/src/com/engine/salary/util/SalaryFormItemUtil.java @@ -0,0 +1,236 @@ +package com.engine.salary.util; + +import com.api.browser.bean.SearchConditionItem; +import com.api.browser.bean.SearchConditionOption; +import com.api.browser.util.ConditionFactory; +import com.api.browser.util.ConditionType; +import weaver.hrm.User; + +import java.util.List; + + + +/** + * @Author weaver_cl + * @Description: + * @Version V1.0 + **/ +public class SalaryFormItemUtil { + + /** + * 下拉框 + * @param user + * @param selectOptions + * @param colSpan + * @param fieldcol + * @param labelcol + * @param isQuickSearch + * @param label + * @return + */ + public static SearchConditionItem selectItem(User user, List selectOptions, int colSpan, int fieldcol, + int labelcol, boolean isQuickSearch, String label,String name) { + ConditionFactory conditionFactory = new ConditionFactory(user); + SearchConditionItem select = conditionFactory.createCondition(ConditionType.SELECT,502327,name); + select.setOptions(selectOptions); + select.setColSpan(colSpan); + select.setFieldcol(fieldcol); + select.setLabelcol(labelcol); + select.setIsQuickSearch(isQuickSearch); + select.setLabel(label); + return select; + } + + + /** + * checkbox + * @param user + * @param colSpan + * @param fieldcol + * @param viewAttr + * @param isQuickSearch + * @param label + * @param name + * @return + */ + public static SearchConditionItem checkboxItem(User user, int colSpan, int fieldcol, + int viewAttr, boolean isQuickSearch, String label,String name) { + ConditionFactory conditionFactory = new ConditionFactory(user); + SearchConditionItem checkbox = conditionFactory.createCondition(ConditionType.CHECKBOX,502327,name); + checkbox.setColSpan(colSpan); + checkbox.setFieldcol(fieldcol); + checkbox.setViewAttr(viewAttr); + checkbox.setIsQuickSearch(isQuickSearch); + checkbox.setLabel(label); + return checkbox; + } + + + /** + * 输入框数字 + * @param user + * @param rules + * @param colSpan + * @param fieldcol + * @param viewAttr + * @param label + * @return + */ + public static SearchConditionItem inputNumberItem(User user,String rules,int colSpan, int fieldcol, + int viewAttr, String label,String name) { + ConditionFactory conditionFactory = new ConditionFactory(user); + SearchConditionItem inputnumber = conditionFactory.createCondition(ConditionType.INPUTNUMBER,502327, name); + inputnumber.setColSpan(colSpan); + inputnumber.setFieldcol(fieldcol); + inputnumber.setViewAttr(viewAttr); + inputnumber.setLabel(label); + inputnumber.setRules(rules); + + return inputnumber; + } + + public static SearchConditionItem inputNumberItemWithMaxAndMin(User user,String rules,int colSpan, int fieldcol, + int viewAttr, String label, String name, String max, String min) { + ConditionFactory conditionFactory = new ConditionFactory(user); + SearchConditionItem inputnumber = conditionFactory.createCondition(ConditionType.INPUTNUMBER,502327, name); + inputnumber.setColSpan(colSpan); + inputnumber.setFieldcol(fieldcol); + inputnumber.setViewAttr(viewAttr); + inputnumber.setLabel(label); + inputnumber.setRules(rules); + inputnumber.setMax(max); + inputnumber.setMin(min); + + return inputnumber; + } + + + /** + * 输入框文本 + * @param user + * @param rules + * @param colSpan + * @param fieldcol + * @param viewAttr + * @param length + * @param label + * @return + */ + public static SearchConditionItem inputItem(User user,String rules,int colSpan, int fieldcol, + int viewAttr,int length, String label,String name) { + ConditionFactory conditionFactory = new ConditionFactory(user); + SearchConditionItem input = conditionFactory.createCondition(ConditionType.INPUT,25034, name); + input.setColSpan(colSpan); + input.setFieldcol(fieldcol); + input.setViewAttr(viewAttr); + input.setLength(length); + input.setLabel(label); + input.setRules(rules); + return input; + } + + /** + * 浏览按钮 + * @param user + * @param colSpan + * @param fieldcol + * @param viewAttr + * @param isQuickSearch + * @param label + * @param rules + * @param type + * @return + */ + public static SearchConditionItem browserItem(User user,int colSpan, int fieldcol, + int viewAttr,boolean isQuickSearch,String label,String rules,String type,String name) { + ConditionFactory conditionFactory = new ConditionFactory(user); + SearchConditionItem browser = conditionFactory.createCondition(ConditionType.BROWSER,502327,name,type); + browser.setColSpan(colSpan); + browser.setFieldcol(fieldcol); + browser.setViewAttr(viewAttr); + browser.setIsQuickSearch(isQuickSearch); + browser.setLabel(label); + browser.setRules(rules); + return browser; + } + + + /** + * 日期区间 + * @param user + * @param colSpan + * @param fieldcol + * @param viewAttr + * @param label + * @param rules + * @return + */ + public static SearchConditionItem rangeDateItem(User user,int colSpan, int fieldcol,int viewAttr + ,String label,String rules,String name1,String name2) { + ConditionFactory conditionFactory = new ConditionFactory(user); + SearchConditionItem rangeDate = conditionFactory.createCondition(ConditionType.TIMEPICKER,502327,new String[]{name1,name2}); + rangeDate.setColSpan(colSpan); + rangeDate.setFieldcol(fieldcol); + rangeDate.setViewAttr(viewAttr); + rangeDate.setLabel(label); + rangeDate.setRules(rules); + return rangeDate; + } + + + /** + * 多行文本框 + * @param user + * @param colSpan + * @param fieldcol + * @param isQuickSearch + * @param viewAttr + * @param length + * @param label + * @param name + * @return + */ + public static SearchConditionItem textareaItem(User user,int colSpan, int fieldcol,boolean isQuickSearch, + int viewAttr,int length, String label,String name) { + ConditionFactory conditionFactory = new ConditionFactory(user); + SearchConditionItem textarea = conditionFactory.createCondition(ConditionType.TEXTAREA,502227, name); + textarea.setColSpan(colSpan); + textarea.setFieldcol(fieldcol); + textarea.setIsQuickSearch(isQuickSearch); + textarea.setViewAttr(viewAttr); + textarea.setLength(length); + textarea.setLabel(label); + + return textarea; + } + + + /** + * 日期 + * @param user + * @param colSpan + * @param fieldcol + * @param isQuickSearch + * @param viewAttr + * @param label + * @param name + * @return + */ + public static SearchConditionItem datePickerItem(User user,int colSpan, int fieldcol,boolean isQuickSearch, + int viewAttr,String label,String name) { + ConditionFactory conditionFactory = new ConditionFactory(user); + SearchConditionItem datePicker = conditionFactory.createCondition(ConditionType.DATEPICKER,502227, name); + datePicker.setColSpan(colSpan); + datePicker.setFieldcol(fieldcol); + datePicker.setIsQuickSearch(isQuickSearch); + datePicker.setViewAttr(viewAttr); + datePicker.setLabel(label); + return datePicker; + } + + + + + + +} diff --git a/src/com/engine/salary/util/SalaryI18nUtil.java b/src/com/engine/salary/util/SalaryI18nUtil.java new file mode 100644 index 000000000..14dc4644a --- /dev/null +++ b/src/com/engine/salary/util/SalaryI18nUtil.java @@ -0,0 +1,125 @@ +package com.engine.salary.util; + +import com.engine.salary.annotation.I18n; +import com.engine.salary.exception.SalaryRunTimeException; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.jetbrains.annotations.NotNull; +import weaver.general.Util; + +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +/** + * 多语言工具类 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SalaryI18nUtil { + + + public static T i18n(T data) { + if (data == null ) { + return data; + } + try { + List fieldList = getFields(data.getClass()); + if (CollectionUtils.isNotEmpty(fieldList)) { + for (Field field : fieldList) { + field.setAccessible(true); + String fieldValue = (String) field.get(data); + if (StringUtils.isNotBlank(fieldValue)) { + String encryptValue = Util.formatMultiLang(fieldValue); + field.set(data, encryptValue); + } + } + } + return data; + } catch (Exception e) { + throw new SalaryRunTimeException("国际化解析异常"); + } + } + + public static List i18nList(List dataList) { + if (CollectionUtils.isEmpty(dataList) ) { + return dataList; + } + try { + List fieldList = getFields(dataList.get(0).getClass()); + if (CollectionUtils.isNotEmpty(fieldList)) { + for (T data : dataList) { + for (Field field : fieldList) { + field.setAccessible(true); + String fieldValue = (String) field.get(data); + if (StringUtils.isNotBlank(fieldValue)) { + String encryptValue = Util.formatMultiLang(fieldValue); + field.set(data, encryptValue); + } + } + } + + } + return dataList; + } catch (Exception e) { + throw new SalaryRunTimeException("国际化批量解析异常"); + } + } + + @NotNull + private static List getFields(Class clazz) { + List> allClasses = new ArrayList>(); + for (Class superClass = clazz; superClass != null; superClass = superClass.getSuperclass()) { + if (superClass != Object.class) { + allClasses.add(superClass); + } + } + return allClasses.stream() + .map(Class::getDeclaredFields) + .flatMap(Arrays::stream) + .filter(field -> field.isAnnotationPresent(I18n.class)).collect(Collectors.toList()); + } + + /** + * 获取多语言信息 + * + * @param labelId 多语言对应的labelId + * @param defaultLabel 默认中文 + * @return + */ + public static String getI18nLabel(int labelId, String defaultLabel) { + return defaultLabel; + } +// +// /** +// * 获取多语言信息 +// * +// * @param tenantKey 租户key +// * @param employeeId 人员id +// * @param labelId 多语言对应的labelId +// * @param defaultLabel 默认中文 +// * @return +// */ +// public static String getI18nLabel(String tenantKey, Long employeeId, int labelId, String defaultLabel) { +// int languageId = I18nLanguageUtil.getLangId(employeeId); +// return SalaryI18nUtil.getI18nLabel(labelId, languageId, tenantKey, defaultLabel); +// } +// +// /** +// * 获取多语言信息 +// * +// * @param simpleEmployee 租户信息 +// * @param labelId 多语言对应的labelId +// * @param defaultLabel 默认中文 +// * @return +// */ +// public static String getI18nLabel(DataCollectionEmployee simpleEmployee, int labelId, String defaultLabel) { +// int languageId = I18nLanguageUtil.getLangId(simpleEmployee.getEmployeeId()); +// return SalaryI18nUtil.getI18nLabel(labelId, languageId, simpleEmployee.getTenantKey(), defaultLabel); +// } +} diff --git a/src/com/engine/salary/util/SalaryLoggerUtil.java b/src/com/engine/salary/util/SalaryLoggerUtil.java new file mode 100644 index 000000000..72d7aae28 --- /dev/null +++ b/src/com/engine/salary/util/SalaryLoggerUtil.java @@ -0,0 +1,98 @@ +package com.engine.salary.util; + + +import com.engine.hrmelog.entity.dto.LoggerContext; +import com.engine.hrmelog.util.LoggerTemplate; +import com.engine.salary.enums.OperateTypeEnum; +import weaver.hrm.User; + +/** + * 操作日志工具类 + *

Copyright: Copyright (c) 2023

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SalaryLoggerUtil { + + /** + * 记录单个对象新增操作日志 + * @param loggerTemplate + * @param targetId + * @param targetName + * @param operateTypeName + * @param operatedesc + * @param newValues + * @param user + */ + public static void recordAddSingleLog(LoggerTemplate loggerTemplate, Long targetId, String targetName, String operateTypeName, String operatedesc, Object newValues, User user) { + recoreSingleLog(loggerTemplate, targetId, targetName, OperateTypeEnum.ADD.getValue(), operateTypeName, operatedesc, null, newValues, user); + } + + /** + * 记录单个对象修改操作日志 + * @param loggerTemplate + * @param targetId + * @param targetName + * @param operateTypeName + * @param operatedesc + * @param oldValues + * @param newValues + * @param user + */ + public static void recordUpdateSingleLog(LoggerTemplate loggerTemplate, Long targetId, String targetName, String operateTypeName, String operatedesc, Object oldValues, Object newValues, User user) { + recoreSingleLog(loggerTemplate, targetId, targetName, OperateTypeEnum.UPDATE.getValue(), operateTypeName, operatedesc, oldValues, newValues, user); + } + + /** + * 记录单个对象删除操作日志 + * @param loggerTemplate + * @param targetId + * @param targetName + * @param operateTypeName + * @param operatedesc + * @param oldValues + * @param user + */ + public static void recordDeleteSingleLog(LoggerTemplate loggerTemplate, Long targetId, String targetName, String operateTypeName, String operatedesc, Object oldValues, User user) { + recoreSingleLog(loggerTemplate, targetId, targetName, OperateTypeEnum.DELETE.getValue(), operateTypeName, operatedesc, oldValues, null, user); + } + + /** + * 记录单个对象导出操作日志 + * @param loggerTemplate + * @param targetId + * @param targetName + * @param operateTypeName + * @param operatedesc + * @param user + */ + public static void recordExportSingleLog(LoggerTemplate loggerTemplate, Long targetId, String targetName, String operateTypeName, String operatedesc, User user) { + recoreSingleLog(loggerTemplate, targetId, targetName, OperateTypeEnum.EXCEL_EXPORT.getValue(), operateTypeName, operatedesc, null, null, user); + } + + /** + * 记录单个对象日志 + * @param loggerTemplate + * @param targetId + * @param targetName + * @param operateType + * @param operateTypeName + * @param operatedesc + * @param oldValues + * @param newValues + */ + private static void recoreSingleLog(LoggerTemplate loggerTemplate, Long targetId, String targetName, String operateType, String operateTypeName, String operatedesc, Object oldValues, Object newValues, User user) { + LoggerContext loggerContext = new LoggerContext(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(targetId)); + loggerContext.setTargetName(targetName); + loggerContext.setOperateType(operateType); + loggerContext.setOperateTypeName(operateTypeName); + loggerContext.setOperatedesc(operatedesc); + loggerContext.setOldValues(oldValues); + loggerContext.setNewValues(newValues); + loggerTemplate.write(loggerContext); + } +} diff --git a/src/com/engine/salary/util/SalarySobUtil.java b/src/com/engine/salary/util/SalarySobUtil.java new file mode 100644 index 000000000..17ea5bde5 --- /dev/null +++ b/src/com/engine/salary/util/SalarySobUtil.java @@ -0,0 +1,57 @@ +package com.engine.salary.util; + +import com.engine.salary.entity.salarysob.po.SalarySobRangePO; +import com.engine.salary.enums.UserStatusEnum; +import com.engine.salary.service.impl.SalarySobRangeServiceImpl; +import org.apache.commons.collections4.CollectionUtils; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author Harryxzy + * @date 2022/10/08 16:06 + * @description 薪资账套工具 + */ +public class SalarySobUtil { + + // 处理历史数据将薪资账套中将关联人员状态转换为List + public static void handleEmployeeStatusHistory(){ + // 根据薪资账套查询人员 + SalarySobRangeServiceImpl salarySobRangeService = new SalarySobRangeServiceImpl(); + List salarySobRangePOS = salarySobRangeService.listAllSalarySobRange(); + if(CollectionUtils.isNotEmpty(salarySobRangePOS)){ + // 判断是否已经转换过 + SalarySobRangePO salarySobRangePO = salarySobRangePOS.get(0); + if(salarySobRangePO.getEmployeeStatuses() == null || salarySobRangePO.getEmployeeStatuses().equals("")){ + salarySobRangePOS.stream().forEach(item ->{ + List employeeStatus = new ArrayList<>(); + if(item.getEmployeeStatus() == 0){ + // 全部 + employeeStatus.addAll(UserStatusEnum.getAllStatus()); + }else if(item.getEmployeeStatus() == 1){ + // 在职 + employeeStatus.addAll(UserStatusEnum.getNormalStatus()); + }else if(item.getEmployeeStatus() == 2){ + // 离职 + employeeStatus.addAll(UserStatusEnum.getUnavailableStatus()); + } + StringBuilder sb = new StringBuilder(); + for(int i=0; i +// * 线程池最大并发线程数默认为10,核心线程数为0
+// * 并发量、延时要求较低的功能,建议优先选用此方法,避免线程资源浪费
+// * +// * @param LocalRunnable 异步任务
+// */ +// public static void execute(LocalRunnable LocalRunnable) { +// execute(ModulePoolEnum.OTHER, "default", ModulePoolEnum.OTHER.getMaxThread(), LocalRunnable); +// } +// +// /** +// * 使用指定名称的线程池执行异步任务(线程池名称为module+function拼接生成)
+// * FixedThreadPool 线程池最大并发线程数为maximunPoolSize,核心线程数与maximunPoolSize相同
+// * 并发量、延时要求高的功能,选用此方法,会保持一定的线程资源占用
+// * 也可以使用重载方法,指定corePoolSize +// * +// * @param module 模块名称
+// * @param function 功能描述
+// * @param LocalRunnable 异步任务
+// */ +// public static void fixedPoolExecute(ModulePoolEnum module, String function, LocalRunnable LocalRunnable) { +// execute(module, function, module.getMaxThread(), LocalRunnable); +// } +// +// /** +// * 使用指定名称的线程池执行异步任务(线程池名称为module+function拼接生成)
+// * 线程池最大并发线程数为maximunPoolSize
+// * +// * @param module 模块名称
+// * @param function 功能描述
+// * @param maximunPoolSize 最大线程数
+// * @param LocalRunnable 异步任务
+// */ +// private static void execute(ModulePoolEnum module, String function, int maximunPoolSize, LocalRunnable LocalRunnable) { +// execute(module, function, maximunPoolSize, maximunPoolSize, LocalRunnable); +// } +// +// /** +// * 使用指定名称的线程池执行异步任务(线程池名称为module+function拼接生成)
+// * 线程池最大并发线程数为maximunPoolSize
+// * +// * @param module 模块名称
+// * @param function 功能描述
+// * @param corePoolSize 核心线程数(即线程池空闲时,仍保留的线程数)
+// * @param maximunPoolSize 最大线程数
+// * @param LocalRunnable 异步任务
+// */ +// private static void execute(ModulePoolEnum module, String function, int corePoolSize, int maximunPoolSize, LocalRunnable LocalRunnable) { +// if (StringUtils.isEmpty(function)) { +// function = "default"; +// } +// LocalRunnable.setFunctiondesc(function); +// LocalRunnable.setModule(module.name()); +// ThreadPoolFactory.getExecutor(module, corePoolSize, maximunPoolSize).execute(LocalRunnable); +// } +// +// /** +// * 关闭指定的连接池,一般情况下不会使用,请勿随意调用
+// * +// * @param module 模块名称
+// */ +// private void shutdown(ModulePoolEnum module) { +// ThreadPoolFactory.shutdownExecutor(module); +// } +} diff --git a/src/com/engine/salary/util/SalaryTokenUtil.java b/src/com/engine/salary/util/SalaryTokenUtil.java new file mode 100644 index 000000000..653a0a821 --- /dev/null +++ b/src/com/engine/salary/util/SalaryTokenUtil.java @@ -0,0 +1,258 @@ +package com.engine.salary.util; + +import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.TypeReference; +import com.engine.salary.encrypt.AESEncryptUtil; +import com.engine.salary.entity.salaryBill.param.SalaryBillGetTokenParam; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.util.db.IdGenerator; +import org.apache.commons.lang3.StringUtils; +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.rsa.security.RSA; + +import java.io.BufferedReader; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; +import java.net.HttpURLConnection; +import java.net.URL; +import java.security.KeyManagementException; +import java.security.NoSuchAlgorithmException; +import java.time.LocalDateTime; +import java.util.HashMap; +import java.util.Map; + +public class SalaryTokenUtil { + + /** + * 通过注册返回的OA系统公钥和秘钥获取token + * + * @param address OA地址 + * @return + * @throws NoSuchAlgorithmException + * @throws KeyManagementException + */ +// public static Map testGetoken(String address) throws NoSuchAlgorithmException, KeyManagementException { +// Map heads = new HashMap<>(); +// Map datas = testRegist(address); // 注册接口返回的secrit私钥和spk公钥可以在第一次调用后,第三方系统保存起来,之后调用可以不用再调用这个注册接口 +// //ECOLOGY返回的系统公钥 +// String spk = (String) (datas.get("spk")); +// RSA rsa = new RSA(); +// //对秘钥进行加密传输,防止篡改数据 +// String secret = rsa.encrypt(null, (String) (datas.get("secrit")), null, "utf-8", spk, false); +// //封装参数到请求头 +// heads.put("appid", APPID); +// heads.put("secret", secret); +// //调用ECOLOGY系统接口进行注册 +// String data = post(address + "/api/ec/dev/auth/applytoken", null, heads); +// System.out.println("=====testGetoken=====" + data); +// return JSONObject.parseObject(data, new TypeReference>() { +// }); +// } + + /** + * 注册第三方系统到OA系统,第一次用APPID获取到公钥spk和私钥secret,第三方系统可以保存,下次不用在请求注册接口 + * + * @param address OA地址 + * @return + * @throws NoSuchAlgorithmException + * @throws KeyManagementException + */ +// public static Map testRegist(String address) throws NoSuchAlgorithmException, KeyManagementException { +// Map heads = new HashMap<>(); +// //获取当前异构系统RSA加密的公钥 +// String cpk = new RSA().getRSA_PUB(); +// //封装参数到请求头 +// heads.put("appid", APPID); +// heads.put("cpk", cpk); +// //调用ECOLOGY系统接口进行注册 +// String data = post(address + "/api/ec/dev/auth/regist", null, heads); +// System.out.println("=====testRegist=====" + data); +// return JSONObject.parseObject(data, new TypeReference>() { +// }); +// } + + /** + * 第一次获取Token,需要先注册 + * + * @return + */ + public static Map GetToken(SalaryBillGetTokenParam param) { + String uid = ""; + if (StringUtils.isNotBlank(param.getSalaryCode())) { + uid = AESEncryptUtil.decrypt4SalaryBill(param.getSalaryCode()); + } else { + uid = param.getRecipient(); + } + Map heads = new HashMap<>(); + if (StringUtils.isBlank(uid)) { + return heads; + } + BaseBean baseBean = new BaseBean(); + // 获取是否是https + String isHttps = baseBean.getPropValue("hrmSalaryBillToken", "is_https"); + String httpKey = (StringUtils.isNotBlank(isHttps) && isHttps.equals("true")) ? "https://" : "http://"; + RecordSet rs = new RecordSet(); + Map resultMap = new HashMap<>(); + + // 获取appid的id + String appidId = baseBean.getPropValue("hrmSalaryBillToken", "appid_id"); + if (StringUtils.isBlank(appidId)) { + return resultMap; + } + String ip = baseBean.getPropValue("hrmSalaryBillToken", "ip"); + rs.execute("select APPID from ECOLOGY_BIZ_EC where id =" + appidId); + // 获取appid + String appid =""; + if (rs.next() && StringUtils.isNotEmpty(rs.getString("APPID"))) { + appid = rs.getString("APPID"); + } else { + return resultMap; + } + String sql= " SELECT conf_value FROM hrsa_salary_sys_conf t WHERE delete_type = 0 AND conf_key = 'SALARY_TOKEN_SECRET'"; + rs.execute(sql); + String secret = ""; + if (rs.next() && StringUtils.isNotBlank(rs.getString("conf_value"))) { + // 从数据库中拿secret + secret = rs.getString("conf_value"); + } else { + sql= " update hrsa_salary_sys_conf set delete_type=1 WHERE delete_type = 0 AND conf_key in( 'SALARY_TOKEN_SECRET', 'SALARY_TOKEN_SPK')"; + rs.execute(sql); + // 注册获取secret + // 获取当前异构系统RSA加密的公钥 + String cpk = new RSA().getRSA_PUB(); + //封装参数到请求头 + heads.put("appid", appid); + heads.put("cpk", cpk); + // 调用ECOLOGY系统接口进行注册 + String data = post(httpKey + ip + "/api/ec/dev/auth/regist", null, heads); + Map datas = JSONObject.parseObject(data, new TypeReference>() {}); + // ECOLOGY返回的系统公钥 + String spk = (String) (datas.get("spk")); + RSA rsa = new RSA(); + // 对秘钥进行加密传输,防止篡改数据 + secret = rsa.encrypt(null, (String) (datas.get("secrit")), null, "utf-8", spk, false); + // secret存库 + String date = SalaryDateUtil.getFormatLocalDateTime(LocalDateTime.now()); + sql = String.format("insert into hrsa_salary_sys_conf(id, conf_key, conf_value, title, module, order_weight, delete_type, create_time, update_time) values (%s,'%s','%s','%s','%s',%s,%s,'%s','%s')", + IdGenerator.generate(), "SALARY_TOKEN_SECRET", secret, "token", "basic",0,0,date,date); + rs.execute(sql); + // 保存spk + sql = String.format("insert into hrsa_salary_sys_conf(id, conf_key, conf_value, title, module, order_weight, delete_type, create_time, update_time) values (%s,'%s','%s','%s','%s',%s,%s,'%s','%s')", + IdGenerator.generate(), "SALARY_TOKEN_SPK", spk, "spk", "basic",0,0,date,date); + rs.execute(sql); + } + //封装参数到请求头 + heads.put("appid", appid); + heads.put("secret", secret); + //调用ECOLOGY系统接口进行注册 + String data2 = post(httpKey + ip + "/api/ec/dev/auth/applytoken", null, heads); + // 通过第一步注册许可时返回spk公钥对userid进行加密生成的密文 + sql= " SELECT conf_value FROM hrsa_salary_sys_conf t WHERE delete_type = 0 AND conf_key = 'SALARY_TOKEN_SPK'"; + rs.execute(sql); + if (rs.next()){ + String spk = rs.getString("conf_value"); + // 对uid进行加密 + RSA rsa = new RSA(); + String encryptUid = rsa.encrypt(null, uid.toString(), null, "utf-8", spk, false); + String token = (String)JSONObject.parseObject(data2, new TypeReference>() {}).get("token"); + resultMap.put("userid", encryptUid); + resultMap.put("token", token); + resultMap.put("appid",appid); + return resultMap; + } else { + throw new SalaryRunTimeException("spk不存在"); + } + } + + + /** + * 此方法仅供参考,第三方系统可采用自己的方式调用http接口 + * + * @param path 请求路径 + * @param data 请求参数 + * @return + */ + public static String post(String path, Map params, Map data) { + try { + String str = ""; +// if (params != null) { +// StringBuilder stringBuilder = new StringBuilder("?"); +// for (Map.Entry entry : params.entrySet()) { +// stringBuilder.append(entry.getKey()).append("=").append(entry.getValue()).append("&"); +// } +// if (stringBuilder.length() > 1) +// path += stringBuilder.substring(0, stringBuilder.length() - 1); +// } + URL url = new URL(path); + //打开和url之间的连接 + HttpURLConnection conn = (HttpURLConnection) url.openConnection(); +// PrintWriter out = null; + // 请求参数 编码为 utf-8 + //请求方式 + conn.setRequestMethod("POST"); + //设置通用的请求属性 + conn.setRequestProperty("accept", "*/*"); + conn.setRequestProperty("connection", "Keep-Alive"); + conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)"); + if (data != null) { + for (Map.Entry entry : data.entrySet()) { + conn.setRequestProperty(entry.getKey(), entry.getValue()); + } + } + //设置是否向httpUrlConnection输出,设置是否从httpUrlConnection读入,此外发送post请求必须设置这两个 + //最常用的Http请求无非是get和post,get请求可以获取静态页面,也可以把参数放在URL字串后面,传递给servlet, + //post与get的 不同之处在于post的参数不是放在URL字串里面,而是放在http请求的正文内。 + conn.setDoOutput(true); + conn.setDoInput(true); + OutputStreamWriter out = new OutputStreamWriter(conn.getOutputStream(), "utf-8"); + if (params != null) { + out.write(mapToStr(params)); + } + //缓冲数据 + out.flush(); + out.close(); + //获取URLConnection对象对应的输入流 + InputStream is = conn.getInputStream(); + //构造一个字符流缓存 + BufferedReader br = new BufferedReader(new InputStreamReader(is, "utf-8")); + String result = ""; + while ((str = br.readLine()) != null) { + result = str; + } + //关闭流 + is.close(); + //断开连接,最好写上,disconnect是在底层tcp socket链接空闲时才切断。如果正在被其他线程使用就不切断。 + //固定多线程的话,如果不disconnect,链接会增多,直到收发不出信息。写上disconnect后正常一些。 + conn.disconnect(); + return result; + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + /** + * 将Map转换成字符串参数,用于POST GET 请求 + * + * @param map + * @return + */ + public static String mapToStr(Map map) { + StringBuilder stringBuilder = new StringBuilder(); + if (map != null) { + for (Map.Entry entry : map.entrySet()) { + stringBuilder.append(entry.getKey()); + if (entry.getValue() != null) { + stringBuilder.append("=").append(entry.getValue()); + } + stringBuilder.append("&"); + } + } + if (stringBuilder.length() > 0) { + return stringBuilder.substring(0, stringBuilder.length() - 1); + } + return null; + } +} diff --git a/src/com/engine/salary/util/aes/AESUtils.java b/src/com/engine/salary/util/aes/AESUtils.java new file mode 100644 index 000000000..f36ddc001 --- /dev/null +++ b/src/com/engine/salary/util/aes/AESUtils.java @@ -0,0 +1,198 @@ +package com.engine.salary.util.aes; + +import com.weaver.formmodel.util.StringHelper; +import org.apache.commons.codec.binary.Base64; +import org.apache.commons.lang3.StringUtils; +import sun.misc.BASE64Decoder; +import weaver.general.Util; + +import javax.crypto.Cipher; +import javax.crypto.KeyGenerator; +import javax.crypto.spec.SecretKeySpec; +import java.io.UnsupportedEncodingException; +import java.math.BigInteger; + + +public class AESUtils { + + /** + * 密钥 + */ + public static String KEY = "123"; + + /** + * 算法 + */ + private static final String ALGORITHMSTR = "AES/ECB/PKCS5Padding"; + + public static void main(String[] args) throws Exception { + String content = " {&} bt1|17379|1|1|1=";//啊啊 + //System.out.println("加密前:" + content); + + String encrypt = aesEncrypt(content); + //System.out.println("加密后:" + encrypt); + + String decrypt = aesDecrypt(encrypt); + //System.out.println("解密后===>" + decrypt+"<==="); + } + + /** + * aes解密 + * @param encrypt 内容 + * @return + * @throws Exception + */ + public static String aesDecrypt(String encrypt) throws Exception { + if(StringHelper.isEmpty(encrypt)){ + return ""; + } + + encrypt = encrypt.replace("_ADD_","+"); + encrypt = encrypt.replace("_EQU_","="); + encrypt = encrypt.replace("_SEP_","/"); + return aesDecrypt(encrypt, KEY); + } + + /** + * aes加密 + * @param content + * @return + * @throws Exception + */ + public static String aesEncrypt(String content) throws Exception { + if(StringHelper.isEmpty(content)){ + return ""; + } + + String str = aesEncrypt(content, KEY); + str = str.replace("+", "_ADD_"); + str = str.replace("=", "_EQU_"); + str = str.replace("/", "_SEP_"); + return str; + } + + /** + * 将byte[]转为各种进制的字符串 + * @param bytes byte[] + * @param radix 可以转换进制的范围,从Character.MIN_RADIX到Character.MAX_RADIX,超出范围后变为10进制 + * @return 转换后的字符串 + */ + public static String binary(byte[] bytes, int radix){ + return new BigInteger(1, bytes).toString(radix);// 这里的1代表正数 + } + + /** + * base 64 encode + * @param bytes 待编码的byte[] + * @return 编码后的base 64 code + */ + public static String base64Encode(byte[] bytes){ + byte[] b = Base64.encodeBase64(bytes); + String str = ""; + try { + str = new String(b,"UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + return str; + } + + /** + * base 64 decode + * @param base64Code 待解码的base 64 code + * @return 解码后的byte[] + * @throws Exception + */ + public static byte[] base64Decode(String base64Code) throws Exception{ + return StringUtils.isEmpty(base64Code) ? null : new BASE64Decoder().decodeBuffer(base64Code); + } + + + /** + * 将base64_编码解密 + * @param s + * @return + */ + public static String base64DecodeForMultilang(String s) { + if (s == null) { + return s; + } + if(Util.isEnableMultiLang()){ + try { + BASE64Decoder base64Decoder = new BASE64Decoder(); + return new String(base64Decoder.decodeBuffer(s.replaceAll("base64_", "")),"utf-8"); + } catch (Exception e) { + e.printStackTrace(); + return s; + } + }else{ + return s; + } + + } + + /** + * AES加密 + * @param content 待加密的内容 + * @param encryptKey 加密密钥 + * @return 加密后的byte[] + * @throws Exception + */ + public static byte[] aesEncryptToBytes(String content, String encryptKey) throws Exception { + KeyGenerator kgen = KeyGenerator.getInstance("AES"); + kgen.init(128); + Cipher cipher = Cipher.getInstance(ALGORITHMSTR); + cipher.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(encryptKey.getBytes(), "AES")); + + return cipher.doFinal(content.getBytes("utf-8")); + } + + + /** + * AES加密为base 64 code + * @param content 待加密的内容 + * @param encryptKey 加密密钥 + * @return 加密后的base 64 code + * @throws Exception + */ + public static String aesEncrypt(String content, String encryptKey) throws Exception { + if(StringHelper.isEmpty(content)){ + return ""; + } + return base64Encode(aesEncryptToBytes(content, encryptKey)); + } + + /** + * AES解密 + * @param encryptBytes 待解密的byte[] + * @param decryptKey 解密密钥 + * @return 解密后的String + * @throws Exception + */ + public static String aesDecryptByBytes(byte[] encryptBytes, String decryptKey) throws Exception { + KeyGenerator kgen = KeyGenerator.getInstance("AES"); + kgen.init(128); + + Cipher cipher = Cipher.getInstance(ALGORITHMSTR); + cipher.init(Cipher.DECRYPT_MODE, new SecretKeySpec(decryptKey.getBytes(), "AES")); + byte[] decryptBytes = cipher.doFinal(encryptBytes); + + return new String(decryptBytes,"UTF-8"); + } + + + /** + * 将base 64 code AES解密 + * @param encryptStr 待解密的base 64 code + * @param decryptKey 解密密钥 + * @return 解密后的string + * @throws Exception + */ + public static String aesDecrypt(String encryptStr, String decryptKey) throws Exception { + if(StringHelper.isEmpty(encryptStr)){ + return ""; + } + return StringHelper.isEmpty(encryptStr) ? "" : aesDecryptByBytes(base64Decode(encryptStr), decryptKey); + } + +} diff --git a/src/com/engine/salary/util/db/DBOperateAdapter.java b/src/com/engine/salary/util/db/DBOperateAdapter.java new file mode 100644 index 000000000..7eedbac4a --- /dev/null +++ b/src/com/engine/salary/util/db/DBOperateAdapter.java @@ -0,0 +1,5 @@ +package com.engine.salary.util.db; + +public interface DBOperateAdapter { + String like(String some); +} diff --git a/src/com/engine/salary/util/db/DBType.java b/src/com/engine/salary/util/db/DBType.java new file mode 100644 index 000000000..329c2e66f --- /dev/null +++ b/src/com/engine/salary/util/db/DBType.java @@ -0,0 +1,41 @@ +package com.engine.salary.util.db; + +import com.engine.salary.exception.SalaryRunTimeException; + +public enum DBType implements DBOperateAdapter { + MYSQL("mysql") { + @Override + public String like(String some) { + return "like '%" + some + "%'"; + } + }, + SQLSERVER("sqlserver") { + @Override + public String like(String some) { + return "like '%" + some + "%'"; + } + }, + ORACLE("oracle") { + @Override + public String like(String some) { + return "like '%" + some + "%'"; + } + }; + + private String dbtype; + + DBType(String dbtype) { + this.dbtype = dbtype; + } + + public static DBType get(String dbtype) { + for (DBType t : DBType.values()) { + if (t.dbtype.equalsIgnoreCase(dbtype)) { + return t; + } + } + throw new SalaryRunTimeException("不支持的数据库类型"); + } + + +} diff --git a/src/com/engine/salary/util/db/IdGenerator.java b/src/com/engine/salary/util/db/IdGenerator.java new file mode 100644 index 000000000..e93e72e6f --- /dev/null +++ b/src/com/engine/salary/util/db/IdGenerator.java @@ -0,0 +1,51 @@ +package com.engine.salary.util.db; + +import java.util.UUID; +import java.util.concurrent.atomic.AtomicLong; + +public class IdGenerator { + private static AtomicLong next = new AtomicLong(1L); + public static final int ID_LENGTH_36 = 36; + + public IdGenerator() { + } + + public static long generate() { + return System.currentTimeMillis() + next.getAndIncrement(); + } + + public static String generateId() { + return System.currentTimeMillis() + String.valueOf(next.getAndIncrement()); + } + + public static String generateStrId() { + return System.currentTimeMillis() + generateStrId(36); + } + + public static String generateStrId(int idLength) { + if (idLength >= 1 && idLength <= 36) { + char[] srcChars = new char[]{'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'g', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'}; + char[] chars = new char[idLength]; + + for(int i = 0; i < idLength; ++i) { + if (i != 8 && i != 13 && i != 18 && i != 23) { + if (i == 0) { + chars[i] = srcChars[(int)(Math.random() * 26.0D) % 26]; + } else { + chars[i] = srcChars[(int)(Math.random() * 36.0D) % 36]; + } + } else { + chars[i] = '_'; + } + } + + return new String(chars); + } else { + return ""; + } + } + + public static String getUUID() { + return UUID.randomUUID().toString().replaceAll("-", ""); + } +} diff --git a/src/com/engine/salary/util/db/MapperProxyFactory.java b/src/com/engine/salary/util/db/MapperProxyFactory.java new file mode 100644 index 000000000..cd532c5ff --- /dev/null +++ b/src/com/engine/salary/util/db/MapperProxyFactory.java @@ -0,0 +1,79 @@ +/** + * + */ +package com.engine.salary.util.db; + +import org.apache.ibatis.session.SqlSession; +import weaver.conn.mybatis.MyBatisFactory; + +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.Method; +import java.lang.reflect.Proxy; + +/** + * mapper代理工厂 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class MapperProxyFactory implements InvocationHandler { + private Class clazz; + private boolean enableTransactions = false; + private SqlSession session; + + public MapperProxyFactory(Class clazz) { + this.clazz = clazz; + } + + @Override + public Object invoke(Object proxy, Method method, Object[] args) throws Exception { + this.session = MyBatisFactory.sqlSessionFactory.openSession(); + try { + Object target = session.getMapper(clazz); + return method.invoke(target, args); + } finally { + if (!enableTransactions) { + session.commit(); + session.close(); + } + } + } + + public Object getProxy() { + ClassLoader loader = Thread.currentThread().getContextClassLoader(); + Class[] interfaces = new Class[1]; + interfaces[0] = this.clazz; + return Proxy.newProxyInstance(loader, interfaces, this); + } + + public Object getProxy(boolean enableTransactions) { + this.enableTransactions = enableTransactions; + return this.getProxy(); + } + + public void commit() { + if (this.session != null) { + this.session.commit(); + this.session.close(); + } + } + + public void rollback() { + if (this.session != null) { + this.session.rollback(); + this.session.close(); + } + } + + public static T getProxy(Class clazz) { + MapperProxyFactory handle = new MapperProxyFactory(clazz); + return (T) handle.getProxy(); + } + + public static T getProxy(Class clazz, boolean enableTransactions) { + MapperProxyFactory handle = new MapperProxyFactory(clazz); + return (T) handle.getProxy(enableTransactions); + } +} diff --git a/src/com/engine/salary/util/excel/BooleanEnum.java b/src/com/engine/salary/util/excel/BooleanEnum.java new file mode 100644 index 000000000..8c4438435 --- /dev/null +++ b/src/com/engine/salary/util/excel/BooleanEnum.java @@ -0,0 +1,41 @@ +package com.engine.salary.util.excel; + +public enum BooleanEnum { + + True0("是", Boolean.TRUE), + True1("Y", Boolean.TRUE), + True2("TRUE", Boolean.TRUE), + True3("1", Boolean.TRUE), + True4("YES", Boolean.TRUE), + True5("T", Boolean.TRUE), + False0("否", Boolean.FALSE), + False1("N", Boolean.FALSE), + False2("FALSE", Boolean.FALSE), + False3("0", Boolean.FALSE), + False4("NO", Boolean.FALSE), + False5("F", Boolean.FALSE); + + private String name; + private Boolean value; + + private BooleanEnum(String name, Boolean value) { + this.name = name; + this.value = value; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Boolean getValue() { + return value; + } + + public void setValue(Boolean value) { + this.value = value; + } +} diff --git a/src/com/engine/salary/util/excel/ExcelComment.java b/src/com/engine/salary/util/excel/ExcelComment.java new file mode 100644 index 000000000..f0159f06a --- /dev/null +++ b/src/com/engine/salary/util/excel/ExcelComment.java @@ -0,0 +1,111 @@ +package com.engine.salary.util.excel; + +/** + * 注释 + */ +public class ExcelComment { + int dx1 = 0; + int dy1 = 0; + int dx2 = 0; + int dy2 = 0; + int col1 = 0; + int row1 = 0; + int col2 = 0; + int row2 = 0; + String content; + + public int getDx1() { + return dx1; + } + + public void setDx1(int dx1) { + this.dx1 = dx1; + } + + public int getDy1() { + return dy1; + } + + public void setDy1(int dy1) { + this.dy1 = dy1; + } + + public int getDx2() { + return dx2; + } + + public void setDx2(int dx2) { + this.dx2 = dx2; + } + + public int getDy2() { + return dy2; + } + + public void setDy2(int dy2) { + this.dy2 = dy2; + } + + public int getCol1() { + return col1; + } + + public void setCol1(int col1) { + this.col1 = col1; + } + + public int getRow1() { + return row1; + } + + public void setRow1(int row1) { + this.row1 = row1; + } + + public int getCol2() { + return col2; + } + + public void setCol2(int col2) { + this.col2 = col2; + } + + public int getRow2() { + return row2; + } + + public void setRow2(int row2) { + this.row2 = row2; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public ExcelComment(int dx1, int dy1, int dx2, int dy2, int col1, int row1, int col2, int row2, String content) { + this.dx1 = dx1; + this.dy1 = dy1; + this.dx2 = dx2; + this.dy2 = dy2; + this.col1 = col1; + this.row1 = row1; + this.col2 = col2; + this.row2 = row2; + this.content = content; + } + + public ExcelComment(int col1, int row1, int col2, int row2, String content) { + this.col1 = col1; + this.row1 = row1; + this.col2 = col2; + this.row2 = row2; + this.content = content; + } + + public ExcelComment() { + } +} diff --git a/src/com/engine/salary/util/excel/ExcelFillUtils.java b/src/com/engine/salary/util/excel/ExcelFillUtils.java new file mode 100644 index 000000000..df3d1a507 --- /dev/null +++ b/src/com/engine/salary/util/excel/ExcelFillUtils.java @@ -0,0 +1,204 @@ +package com.engine.salary.util.excel; + +import cn.hutool.core.util.StrUtil; +import com.engine.salary.util.FileUtils; +import org.apache.poi.ss.usermodel.*; +import org.apache.poi.ss.util.CellUtil; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.regex.Pattern; + +public class ExcelFillUtils { + + // public static final String FILL_EXPRESSION_REGEX = "\\{\\.\\w+\\}"; + private static final String FILL_EXPRESSION_REGEX = "\\{\\.[\\p{L}\\p{M}\\S]+\\}"; + + + /** + * 给定模板,指定某个页签,将数据填充到模板中的指定页签,并将数据导入到指定文件上。 + * + * @param template 模板文件地址 + * @param sheetIndex 页签下标 + * @param data 待填充的数据,数据格式如下 + * [ + * {"colName1":v1 ,"colName2":v2...}, + * {"colName1":v1 ,"colName2":v2...} + * ,... + * ] + * @return 新生成的副本文件 + */ + public static XSSFWorkbook fillOneSheet(String template, Integer sheetIndex, List> data) { + + try { + XSSFWorkbook workbook = new XSSFWorkbook(new FileInputStream(template)); + fill(workbook, sheetIndex, data);//填充数据 + return workbook; + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + /** + * 给定模板,指定某个页签,将数据填充到模板中的指定页签,并将数据导入到指定文件上。 + * + * @param template 模板文件流 + * @param sheetIndex 页签名称 + * @param data 待填充的数据,数据格式如下 + * [ + * {"colName1":v1 ,"colName2":v2...}, + * {"colName1":v1 ,"colName2":v2...} + * ,... + * ] + * @return 新生成的副本文件 + */ + public static XSSFWorkbook fillOneSheet(InputStream template, Integer sheetIndex, List> data) { + + try{ + XSSFWorkbook workbook = new XSSFWorkbook(template); + fill(workbook, sheetIndex, data);//填充数据 + return workbook; + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + /** + * 给定模板,将数据填充到模板中的多个页签,并在模板所在目录生成新的副本文件。 + * + * @param template 模板文件地址 + * @param datas 待填充的数据集,数据格式如下 + * { + * "SheetName1":[ + * {"colName1":v1 ,"colName2":v2...}, + * {"colName1":v1 ,"colName2":v2...} + * ,... + * ], + * "SheetName2":[ + * {"colName1":v1 ,"colName2":v2...} + * {"colName1":v1 ,"colName2":v2...} + * ,... + * ], + * ... + * } + */ + public static String fillMultipleSheet(String template, Map>> datas) { + return fillMultipleSheet(template, FileUtils.getAvailableFullName(template), datas); + } + + /** + * 给定模板,将数据填充到模板中的多个页签,并将数据导入到指定文件上。 + * + * @param template 模板文件地址 + * @param datas 待填充的数据集,数据格式如下 + * { + * "SheetName1":[ + * {"colName1":v1 ,"colName2":v2...}, + * {"colName1":v1 ,"colName2":v2...} + * ,... + * ], + * "SheetName2":[ + * {"colName1":v1 ,"colName2":v2...} + * {"colName1":v1 ,"colName2":v2...} + * ,... + * ], + * ... + * } + */ + public static String fillMultipleSheet(String template, String outputFile, Map>> datas) { + + try (Workbook workbook = new XSSFWorkbook(new FileInputStream(template))) { + + datas.forEach((sheetIndex, data) -> fill(workbook, sheetIndex, data));//填充数据 + refreshFormula(workbook);//刷新公式 + + try (FileOutputStream outputStream = new FileOutputStream(outputFile)) { + workbook.write(outputStream); + } catch (Exception e) { + throw new RuntimeException(e); + } + + } catch (IOException e) { + throw new RuntimeException(e); + } + + return outputFile; + } + + private static Workbook fill(Workbook workbook, int sheetIndex, List> data) { + + Sheet sheet = workbook.getSheetAt(sheetIndex); + if (sheet == null) { + throw new RuntimeException(String.format("sheet [%s] does not exist.", sheetIndex)); + } + + //找到所有的表达式单元格 + Map expressionCellMap = new HashMap<>(); + for (int i = 0; i < sheet.getPhysicalNumberOfRows(); i++) { + Row row = sheet.getRow(i); + for (int j = 0; j < row.getPhysicalNumberOfCells(); j++) { + Cell cell = row.getCell(j); + if (!Objects.isNull(cell) && isFillExpression(cell.getStringCellValue())) {//判断该单元格是否是填充公式 + expressionCellMap.put(getColNameFromEx(cell.getStringCellValue()), cell); + } + } + } + + //填充数据 + for (int i = 0; i < data.size(); i++) { + Map dataRow = data.get(i); + for (Map.Entry entry : dataRow.entrySet()) { + String colName = entry.getKey(); + Object value = entry.getValue(); + if (expressionCellMap.containsKey(colName)) { + + Cell cell = expressionCellMap.get(colName);//公式所在的单元格 + int rowID = cell.getRowIndex() + i; + int colId = cell.getColumnIndex(); + + Row fillRow = sheet.getRow(rowID); + fillRow = Objects.isNull(fillRow) ? sheet.createRow(rowID) : fillRow; + Cell fillCell = fillRow.getCell(colId); + //创建的新单元格需要复制公式单元格的格式 + fillCell = Objects.isNull(fillCell) ? CellUtil.createCell(fillRow, colId, "", cell.getCellStyle()) : fillCell; + + if (value instanceof String) { + fillCell.setCellValue(String.valueOf(value)); + } else if (value instanceof Number) { + fillCell.setCellValue(((Number) value).doubleValue()); + } else { + throw new RuntimeException(String.format("Unsupported data type [%s].", value.getClass().toString())); + } + + } + } + } + + return workbook; + } + + private static void refreshFormula(Workbook workbook) { + FormulaEvaluator evaluator = workbook.getCreationHelper().createFormulaEvaluator(); + evaluator.evaluateAll(); + } + + private static boolean isFillExpression(String ex) { + if (StrUtil.isBlank(ex)) { + return false; + } + ; + return Pattern.matches(FILL_EXPRESSION_REGEX, ex); + } + + private static String getColNameFromEx(String ex) { + if (!isFillExpression(ex)) throw new RuntimeException("Illegal expression " + ex); + return ex.substring(2, ex.length() - 1); + } +} diff --git a/src/com/engine/salary/util/excel/ExcelParseException.java b/src/com/engine/salary/util/excel/ExcelParseException.java new file mode 100644 index 000000000..432347858 --- /dev/null +++ b/src/com/engine/salary/util/excel/ExcelParseException.java @@ -0,0 +1,36 @@ +package com.engine.salary.util.excel; +import org.apache.commons.lang3.exception.ContextedRuntimeException; + +public class ExcelParseException extends ContextedRuntimeException{ + + private static final long serialVersionUID = -8696742623977630854L; + + public ExcelParseException(String message) { + super(message); + this.msgCode = DEFAULT_CODE; + } + + public ExcelParseException(String message, Throwable cause) { + super(message, cause); + this.msgCode = DEFAULT_CODE; + } + + /** + * 默认异常编码 + */ + private static final String DEFAULT_CODE = "EXCP0000"; + + /** + * 异常编码 + */ + private String msgCode; + + public String getMsgCode() { + return msgCode; + } + + public void setMsgCode(String msgCode) { + this.msgCode = msgCode; + } + +} diff --git a/src/com/engine/salary/util/excel/ExcelParseHelper.java b/src/com/engine/salary/util/excel/ExcelParseHelper.java new file mode 100644 index 000000000..9da6eb545 --- /dev/null +++ b/src/com/engine/salary/util/excel/ExcelParseHelper.java @@ -0,0 +1,397 @@ +package com.engine.salary.util.excel; + +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.Validate; +import org.apache.commons.lang3.exception.ContextedRuntimeException; +import org.apache.poi.ss.usermodel.FormulaEvaluator; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; +import org.springframework.web.multipart.MultipartFile; + +import java.io.InputStream; +import java.lang.reflect.Field; +import java.math.BigDecimal; +import java.util.*; + +import static com.engine.salary.util.excel.ExcelSupport.EXCEL_TYPE_XLSX; + +/** + * Excel 解析工具类 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class ExcelParseHelper { + + //待校验的行号 + private static final int PARSE_EXCEL_ROW_VALID_CELL_INDEX = 0; + //字符开始下标 + private static final int CHARACTER_FIRST_INDEX = 0; + + /** + * 将 Excel 解析为 JavaBean 对象 + * + * @param file excel文件 + * @param clazz 解析bean的类 + * @param sheetIndex excel中第几个sheet,从0开始 + * @param rowIndex 从第几行开始解析,第一行是0 + * @param standardCellNum 模板验证,该sheet应有多少列 + * @return + */ + public static List parse2Map(MultipartFile file, Class clazz, int sheetIndex, int rowIndex, int standardCellNum) { + List> result = parse2Map(file, sheetIndex, rowIndex, standardCellNum); + List list = new ArrayList(); + for (List rowDatas : result) { + T t = setField(clazz, rowDatas); + list.add(t); + } + return list; + } + + /** + * 将 Excel 解析为 JavaBean 对象 + * + * @param file excel文件 + * @param clazz 解析bean的类 + * @param sheetIndex excel中第几个sheet,从0开始 + * @param rowIndex 从第几行开始解析,第一行是0 + * @param standardCellNum 模板验证,该sheet应有多少列 + * @param fileName 文件名 + * @return + */ + public static List parse2Map(InputStream file, Class clazz, int sheetIndex, int rowIndex, int standardCellNum, String fileName) { + List> result = parse2Map(file, sheetIndex, rowIndex, standardCellNum, fileName); + List list = new ArrayList(); + for (List rowDatas : result) { + T t = setField(clazz, rowDatas); + list.add(t); + } + return list; + } + + /** + * 获取excel数据。 + * + * @param file 文件 + * @param sheetIndex 解析第几个sheet + * @param rowIndex 从第几行开始解析,第一行为 0,依次类推 + * @return 二维数据集合 + */ + private static List> parse2Map(MultipartFile file, int sheetIndex, int rowIndex, int standardCellNum) { + Sheet sheet = ExcelSupport.parseFile(file, sheetIndex); + int rowCount = sheet.getPhysicalNumberOfRows(); // 总行数 + int cellCount = sheet.getRow(PARSE_EXCEL_ROW_VALID_CELL_INDEX).getPhysicalNumberOfCells(); // 总列数 + + Validate.isTrue(standardCellNum == cellCount, "Error in excel template! Page %s sheet should have %s column data, existing in %s column , please check the template!", sheetIndex, standardCellNum, cellCount); + + List> result = new ArrayList>(); + for (; rowIndex < rowCount; rowIndex++) { + List cellResult = new ArrayList(); + for (int j = 0; j < cellCount; j++) { + cellResult.add(ExcelSupport.getCellValue(sheet, null, rowIndex, j)); + } + result.add(cellResult); + } + return result; + } + + /** + * 获取excel数据。 + * + * @param file 文件 + * @param sheetIndex 解析第几个sheet + * @param rowIndex 从第几行开始解析,第一行为 0,依次类推 + * @return 二维数据集合 + */ + private static List> parse2Map(InputStream file, int sheetIndex, int rowIndex, int standardCellNum, String fileName) { + Workbook workbook = ExcelSupport.parseFile(file, fileName); + Sheet sheet = workbook.getSheetAt(sheetIndex); + int rowCount = sheet.getPhysicalNumberOfRows(); // 总行数 + int cellCount = sheet.getRow(PARSE_EXCEL_ROW_VALID_CELL_INDEX).getPhysicalNumberOfCells(); // 总列数 + + Validate.isTrue(standardCellNum == cellCount, "Error in excel template! Page %s sheet should have %s column data, existing in %s column , please check the template!", sheetIndex, standardCellNum, cellCount); + + // 创建一个公式求值器对象 + FormulaEvaluator evaluator = workbook.getCreationHelper().createFormulaEvaluator(); + + List> result = new ArrayList>(); + for (; rowIndex < rowCount; rowIndex++) { + List cellResult = new ArrayList(); + for (int j = 0; j < cellCount; j++) { + cellResult.add(ExcelSupport.getCellValue(sheet, evaluator, rowIndex, j)); + } + result.add(cellResult); + } + return result; + } + + + /** + * 将sheet数据转为map + * + * @param file + * @param sheetIndex sheet下标 + * @param rowIndex 从哪行开始解析 + * @return + */ + public static List> parse2Map(InputStream file, int sheetIndex, int rowIndex) { + Workbook workbook = ExcelSupport.parseFile(file, EXCEL_TYPE_XLSX); + // 创建一个公式求值器对象 + FormulaEvaluator evaluator = workbook.getCreationHelper().createFormulaEvaluator(); + Sheet sheet = workbook.getSheetAt(sheetIndex); + int rowCount = sheet.getPhysicalNumberOfRows(); // 总行数 + int cellCount = sheet.getRow(PARSE_EXCEL_ROW_VALID_CELL_INDEX).getPhysicalNumberOfCells(); // 总列数 + + List sheetHeader = ExcelSupport.getSheetHeader(sheet, PARSE_EXCEL_ROW_VALID_CELL_INDEX); + + List> result = new ArrayList<>(); + for (; rowIndex < rowCount; rowIndex++) { + Map cellResult = new HashMap<>(); + for (int j = 0; j < cellCount; j++) { + String key = sheetHeader.get(j); + cellResult.put(key, ExcelSupport.getCellValue(sheet, evaluator, rowIndex, j)); + } + result.add(cellResult); + } + return result; + } + + + /** + * 将sheet数据转为map + * + * @param rowIndex 从哪行开始解析 + * @return + */ + public static List> parse2Map(Sheet sheet, int rowIndex) { + int rowCount = sheet.getPhysicalNumberOfRows(); // 总行数 + int cellCount = sheet.getRow(PARSE_EXCEL_ROW_VALID_CELL_INDEX).getPhysicalNumberOfCells(); // 总列数 + + List sheetHeader = ExcelSupport.getSheetHeader(sheet, PARSE_EXCEL_ROW_VALID_CELL_INDEX); + + List> result = new ArrayList<>(); + for (; rowIndex < rowCount; rowIndex++) { + Map cellResult = new HashMap<>(); + for (int j = 0; j < cellCount; j++) { + String key = sheetHeader.get(j); + cellResult.put(key, ExcelSupport.getCellValue(sheet, null, rowIndex, j)); + } + result.add(cellResult); + } + return result; + } + + public static List> parse2Map(Workbook workbook, int sheetIndex, int rowIndex) { + // 创建一个公式求值器对象 + FormulaEvaluator evaluator = workbook.getCreationHelper().createFormulaEvaluator(); + Sheet sheet = workbook.getSheetAt(sheetIndex); + int rowCount = sheet.getPhysicalNumberOfRows(); // 总行数 + int cellCount = sheet.getRow(PARSE_EXCEL_ROW_VALID_CELL_INDEX).getPhysicalNumberOfCells(); // 总列数 + + List sheetHeader = ExcelSupport.getSheetHeader(sheet, PARSE_EXCEL_ROW_VALID_CELL_INDEX); + + List> result = new ArrayList<>(); + for (; rowIndex < rowCount; rowIndex++) { + Map cellResult = new HashMap<>(); + for (int j = 0; j < cellCount; j++) { + String key = sheetHeader.get(j); + cellResult.put(key, ExcelSupport.getCellValue(sheet, evaluator, rowIndex, j)); + } + result.add(cellResult); + } + return result; + } + + public static List> parse2Map(Workbook workbook, int sheetIndex, int rowIndex, int headerRowIndex) { + // 创建一个公式求值器对象 + FormulaEvaluator evaluator = workbook.getCreationHelper().createFormulaEvaluator(); + Sheet sheet = workbook.getSheetAt(sheetIndex); + int rowCount = sheet.getPhysicalNumberOfRows(); // 总行数 + int cellCount = sheet.getRow(headerRowIndex).getPhysicalNumberOfCells(); // 总列数 + + List sheetHeader = ExcelSupport.getSheetHeader(sheet, headerRowIndex); + + List> result = new ArrayList<>(); + for (; rowIndex < rowCount; rowIndex++) { + Map cellResult = new HashMap<>(); + for (int j = 0; j < cellCount; j++) { + String key = sheetHeader.get(j); + cellResult.put(key, ExcelSupport.getCellValue(sheet, evaluator, rowIndex, j)); + } + result.add(cellResult); + } + return result; + } + + /** + * 将sheet数据转为map + * + * @param rowIndex 从哪行开始解析 + * @param headerRowIndex 抽取列数的参考行 + * @return + */ + public static List> parse2Map(Sheet sheet, int rowIndex, int headerRowIndex) { + int rowCount = sheet.getPhysicalNumberOfRows(); // 总行数 + int cellCount = sheet.getRow(headerRowIndex).getPhysicalNumberOfCells(); // 总列数 + + List sheetHeader = ExcelSupport.getSheetHeader(sheet, headerRowIndex); + + List> result = new ArrayList<>(); + for (; rowIndex < rowCount; rowIndex++) { + Map cellResult = new HashMap<>(); + for (int j = 0; j < cellCount; j++) { + String key = sheetHeader.get(j); + cellResult.put(key, ExcelSupport.getCellValue(sheet, null, rowIndex, j)); + } + result.add(cellResult); + } + return result; + } + + /** + * 将sheet数据转为List + * + * @param rowIndex 从哪行开始解析 + * @return + */ + public static List> parse2List(Sheet sheet, int rowIndex) { + int rowCount = sheet.getPhysicalNumberOfRows(); // 总行数 + int cellCount = sheet.getRow(PARSE_EXCEL_ROW_VALID_CELL_INDEX).getPhysicalNumberOfCells(); // 总列数 + + List> result = new ArrayList>(); + for (; rowIndex < rowCount; rowIndex++) { + List cellResult = new ArrayList(); + for (int j = 0; j < cellCount; j++) { + cellResult.add(ExcelSupport.getCellValue(sheet, null, rowIndex, j)); + } + result.add(cellResult); + } + return result; + } + + /** + * 将sheet数据转为List + * + * @param rowIndex 从哪行开始解析 + * @param headerRowIndex 抽取列数的参考行 + * @return + */ + public static List> parse2List(Sheet sheet, int rowIndex, int headerRowIndex) { + int rowCount = sheet.getPhysicalNumberOfRows(); // 总行数 + int cellCount = sheet.getRow(headerRowIndex).getPhysicalNumberOfCells(); // 总列数 + + List> result = new ArrayList>(); + for (; rowIndex < rowCount; rowIndex++) { + List cellResult = new ArrayList(); + for (int j = 0; j < cellCount; j++) { + cellResult.add(ExcelSupport.getCellValue(sheet, null, rowIndex, j)); + } + result.add(cellResult); + } + return result; + } + + /** + * 将sheet数据转为List + * + * @param rowIndex 从哪行开始解析 + * @param headerRowIndex 抽取列数的参考行 + * @return + */ + public static List> parse2List(Sheet sheet, FormulaEvaluator evaluator, int rowIndex, int headerRowIndex) { + int rowCount = sheet.getPhysicalNumberOfRows(); // 总行数 + int cellCount = sheet.getRow(headerRowIndex).getPhysicalNumberOfCells(); // 总列数 + + List> result = new ArrayList>(); + for (; rowIndex < rowCount; rowIndex++) { + List cellResult = new ArrayList(); + for (int j = 0; j < cellCount; j++) { + cellResult.add(ExcelSupport.getCellValue(sheet, evaluator, rowIndex, j)); + } + result.add(cellResult); + } + return result; + } + + + /** + * 为对象的每一个属性赋值 + * + * @param clazz + * @param rowDatas + * @param + * @return + */ + private static T setField(Class clazz, List rowDatas) { + try { + T obj = clazz.newInstance(); + Field[] fields = clazz.getDeclaredFields(); + for (Field field : fields) { + ExcelProperty excelProperty = field.getAnnotation(ExcelProperty.class); + if (excelProperty == null) { + continue; + } + int index = excelProperty.index(); + Object value = getFieldValue(field, rowDatas.get(index), excelProperty); + field.setAccessible(true); + field.set(obj, value); + } + return obj; + } catch (Exception e) { + throw new ExcelParseException(e.getMessage(), e); + } + } + + /** + * 获取javaBean属性值 + * + * @param field javaBean的对象属性 + * @param value excel中对应的值 + * @param excelProperty javaBean中解析excel注解,包含日期格式、错误提示信息 + * @return + */ + @SuppressWarnings("rawtypes") + private static Object getFieldValue(Field field, String value, ExcelProperty excelProperty) { + if (StringUtils.isEmpty(value)) { + return null; + } + Object val = null; + try { + Class typeClass = field.getType(); + if (typeClass == Integer.class) { + val = Integer.valueOf(value); + } else if (typeClass == Long.class) { + val = Long.valueOf(value); + } else if (typeClass == Float.class) { + val = Float.valueOf(value); + } else if (typeClass == Double.class) { + val = Double.valueOf(value); + } else if (typeClass == Date.class) { + val = ExcelSupport.getDate(value, excelProperty.format()); + } else if (typeClass == Short.class) { + val = Short.valueOf(value); + } else if (typeClass == Character.class) { + val = value.charAt(CHARACTER_FIRST_INDEX); + } else if (typeClass == BigDecimal.class) { + val = new BigDecimal(value); + } else { + val = value; + } + } catch (Exception e) { + throw new ContextedRuntimeException(excelProperty.msg(), e); + } + return val; + } + + public static ExcelPreviewDTO preview(InputStream fileInputStream, int i, String excelTypeXlsx) { + Workbook workbook = ExcelSupport.parseFile(fileInputStream, EXCEL_TYPE_XLSX); + // 创建一个公式求值器对象 + FormulaEvaluator evaluator = workbook.getCreationHelper().createFormulaEvaluator(); + Sheet sheet = workbook.getSheetAt(i); + return ExcelPreviewDTO.builder() + .headers(ExcelSupport.getSheetHeader(sheet, 0)) + .list(ExcelParseHelper.parse2List(sheet, evaluator, 1, 0)).build(); + } +} diff --git a/src/com/engine/salary/util/excel/ExcelPreviewDTO.java b/src/com/engine/salary/util/excel/ExcelPreviewDTO.java new file mode 100644 index 000000000..69135fbf0 --- /dev/null +++ b/src/com/engine/salary/util/excel/ExcelPreviewDTO.java @@ -0,0 +1,18 @@ +package com.engine.salary.util.excel; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class ExcelPreviewDTO { + private List headers; + + private List> list; +} diff --git a/src/com/engine/salary/util/excel/ExcelProperty.java b/src/com/engine/salary/util/excel/ExcelProperty.java new file mode 100644 index 000000000..e2dd66f3a --- /dev/null +++ b/src/com/engine/salary/util/excel/ExcelProperty.java @@ -0,0 +1,15 @@ +package com.engine.salary.util.excel; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + + +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.FIELD) +public @interface ExcelProperty { + public int index(); // 指定 JavaBean 的属性对应 excel 的第几列 + public String format() default "yyyy-MM-dd"; // 当 JavaBean 的属性为 Date 类型时,指定 Date 的格式化模式 + public String msg() default "解析错误";//当因excel中数据格式错误而造成的解析异常时,提示的错误信息 +} diff --git a/src/com/engine/salary/util/excel/ExcelSupport.java b/src/com/engine/salary/util/excel/ExcelSupport.java new file mode 100644 index 000000000..212905a93 --- /dev/null +++ b/src/com/engine/salary/util/excel/ExcelSupport.java @@ -0,0 +1,189 @@ +package com.engine.salary.util.excel; + +import org.apache.commons.lang3.Validate; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.*; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.springframework.web.multipart.MultipartFile; + +import java.io.BufferedInputStream; +import java.io.InputStream; +import java.text.DecimalFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.Iterator; +import java.util.List; + + +public class ExcelSupport { + + private static final String pattern = "yyyy-MM-dd HH:mm:ss"; + + //excel类型 + public static final String EXCEL_TYPE_XLSX = "xlsx"; + public static final String EXCEL_TYPE_XLS = "xls"; + + + /** + * 解析文件,获取单个sheet + * + * @param file 文件 + * @param sheetIndex sheet下标,从0开始 + * @return sheet + */ + public static Sheet parseFile(MultipartFile file, int sheetIndex) { + Workbook workBook = null; + try (InputStream ins = file.getInputStream();) { + String fileName = file.getOriginalFilename(); + if (fileName.endsWith(EXCEL_TYPE_XLSX)) { + workBook = new XSSFWorkbook(ins); + } else if (fileName.endsWith(EXCEL_TYPE_XLS)) { + workBook = new HSSFWorkbook(ins); + } else { + throw new IllegalArgumentException("File format error! Only xlsx and xls types are supported"); + } + return workBook.getSheetAt(sheetIndex); + } catch (Exception e) { + throw new IllegalArgumentException(e); + } + } + + /** + * 解析文件,获取单个sheet + * + * @return sheet + */ + public static Workbook parseFile(InputStream ins, String fileName) { + Workbook workBook = null; + try { + if (fileName.endsWith(EXCEL_TYPE_XLSX)) { + workBook = new XSSFWorkbook(new BufferedInputStream(ins)); + } else if (fileName.endsWith(EXCEL_TYPE_XLS)) { + workBook = new HSSFWorkbook(new BufferedInputStream(ins)); + } else { + throw new IllegalArgumentException("File format error! Only xlsx and xls types are supported"); + } + return workBook; + } catch (Exception e) { + throw new IllegalArgumentException(e); + } + } + + /** + * 解析文件,获取单个sheet + * + * @param sheetIndex sheet下标,从0开始 + * @return sheet + */ + public static Sheet parseFile(InputStream ins, int sheetIndex, String fileName) { + Workbook workBook = null; + try { + if (fileName.endsWith(EXCEL_TYPE_XLSX)) { + workBook = new XSSFWorkbook(new BufferedInputStream(ins)); + } else if (fileName.endsWith(EXCEL_TYPE_XLS)) { + workBook = new HSSFWorkbook(new BufferedInputStream(ins)); + } else { + throw new IllegalArgumentException("File format error! Only xlsx and xls types are supported"); + } + return workBook.getSheetAt(sheetIndex); + } catch (Exception e) { + throw new IllegalArgumentException(e); + } + } + + /** + * 获取sheet的头列 + * + * @param sheet + * @param headerIndex 头下标 + * @return + */ + public static List getSheetHeader(Sheet sheet, int headerIndex) { + List headers = new ArrayList<>(); + Row headerRow = sheet.getRow(headerIndex); + Iterator cellIterator = headerRow.cellIterator(); + while (cellIterator.hasNext()) { + Cell cell = (Cell) cellIterator.next(); + String stringCellValue = cell.getStringCellValue(); + headers.add(stringCellValue); + } + return headers; + } + + + /** + * 返回指定单元格的数据,支持Vlookup + * + * @param sheet 指定sheet + * @param rowIndex 第几行,从0开始 + * @param cellIndex 第几列,从0开始 + * @return 值 + */ + public static String getCellValue(Sheet sheet, FormulaEvaluator evaluator, int rowIndex, int cellIndex) { + Validate.notNull(sheet.getRow(rowIndex), "Line %s is empty and cannot be resolved", rowIndex); + return getCellValue(sheet.getRow(rowIndex).getCell(cellIndex), evaluator); + } + + + private static final DecimalFormat decimalFormat = new DecimalFormat("####################.###########"); + + /** + * 格式化解析的数据 + */ + public static String getCellValue(Cell cell, FormulaEvaluator evaluator) { + String cellValue = ""; + if (cell != null) { + switch (cell.getCellType()) { + case NUMERIC: // 数值类型 + if (DateUtil.isCellDateFormatted(cell)) { + cellValue = getDateStr(cell.getDateCellValue(), pattern); + } else { + cellValue = decimalFormat.format(cell.getNumericCellValue()); + } + break; + case STRING: // 字符串类型 + cellValue = cell.getStringCellValue(); + break; + case BOOLEAN: // 布尔类型 + cellValue = String.valueOf(cell.getBooleanCellValue()); + break; + case FORMULA: // 公式类型 + if (evaluator != null) { + // 计算公式的值 + CellType cellType = evaluator.evaluateFormulaCell(cell); + // 获取公式计算后的值 + cell.setCellType(cellType); + cellValue =getCellValue(cell, evaluator); + } else { + cellValue = String.valueOf(cell.getCellFormula()); + } + + break; + case BLANK: // 空白类型 + cellValue = ""; + break; + case ERROR: + cellValue = ""; + break; + default: + cellValue = cell.toString().trim(); + break; + } + } + return cellValue.trim(); + } + + public static Date getDate(String dateStr, String pattern) { + try { + return new SimpleDateFormat(pattern).parse(dateStr); + } catch (ParseException e) { + throw new IllegalArgumentException(e); + } + } + + private static String getDateStr(Date date, String pattern) { + return new SimpleDateFormat(pattern).format(date); + } +} diff --git a/src/com/engine/salary/util/excel/ExcelUtil.java b/src/com/engine/salary/util/excel/ExcelUtil.java new file mode 100644 index 000000000..5b7410994 --- /dev/null +++ b/src/com/engine/salary/util/excel/ExcelUtil.java @@ -0,0 +1,497 @@ +package com.engine.salary.util.excel; + +import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationLaborListDTO; +import com.engine.salary.util.SalaryDateUtil; +import com.engine.salary.util.SalaryI18nUtil; +import com.google.common.collect.Lists; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.poi.ss.usermodel.CellType; +import org.apache.poi.ss.usermodel.FillPatternType; +import org.apache.poi.ss.usermodel.HorizontalAlignment; +import org.apache.poi.ss.usermodel.IndexedColors; +import org.apache.poi.xssf.usermodel.*; +import org.springframework.beans.BeanUtils; + +import java.awt.*; +import java.beans.BeanInfo; +import java.beans.Introspector; +import java.beans.PropertyDescriptor; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +public class ExcelUtil { + + /** + * 生成excel + * + * @param rowList + * @return + */ + public static XSSFWorkbook genWorkbook(List> rowList, String sheetName) { + XSSFWorkbook workbook = new XSSFWorkbook(); + + // 设置title样式 + XSSFCellStyle titleCellStyle = workbook.createCellStyle(); + XSSFFont titleFont = workbook.createFont(); + titleFont.setFontName("仿宋"); + titleFont.setFontHeightInPoints((short) 15); + titleCellStyle.setFont(titleFont); + titleCellStyle.setAlignment(HorizontalAlignment.CENTER); + titleCellStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());//背景色 + titleCellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); + + + // 设置主体样式 + XSSFCellStyle cellStyle = workbook.createCellStyle(); + XSSFFont font = workbook.createFont(); + font.setFontName("宋体"); + font.setFontHeightInPoints((short) 10);// 设置字体大小 + cellStyle.setFont(font);// 选择需要用到的字体格式 + cellStyle.setWrapText(true); + + XSSFSheet sheet = workbook.createSheet(sheetName); + //自适应宽度 + sheet.autoSizeColumn(0, true); + //默认列宽 + sheet.setDefaultColumnWidth(20); + //默认行高 + sheet.setDefaultRowHeightInPoints(18); + + for (int rowIndex = 0; rowIndex < rowList.size(); rowIndex++) { + List infoList = rowList.get(rowIndex); + XSSFRow row = sheet.createRow(rowIndex); + for (int cellIndex = 0; cellIndex < infoList.size(); cellIndex++) { + XSSFCell cell = row.createCell(cellIndex); + cell.setCellType(CellType.STRING); + if (rowIndex == 0) { + cell.setCellStyle(titleCellStyle); + } else { + cell.setCellStyle(cellStyle); + } + cell.setCellValue(infoList.get(cellIndex)); +// sheet.setColumnWidth(cellIndex, 35 * 256); + } + } + return workbook; + } + + // 设置默认舍入位数,可设为null + public static XSSFWorkbook genWorkbookWithDefaultPattern(List> rowList, String sheetName, Integer defaultPattern) { + XSSFWorkbook workbook = new XSSFWorkbook(); + + // 设置title样式 + XSSFCellStyle titleCellStyle = workbook.createCellStyle(); + XSSFFont titleFont = workbook.createFont(); + titleFont.setFontName("仿宋"); + titleFont.setFontHeightInPoints((short) 15); + titleCellStyle.setFont(titleFont); + titleCellStyle.setAlignment(HorizontalAlignment.CENTER); + titleCellStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());//背景色 + titleCellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); + + + // 设置主体样式 + XSSFCellStyle cellStyle = workbook.createCellStyle(); + XSSFFont font = workbook.createFont(); + font.setFontName("宋体"); + font.setFontHeightInPoints((short) 10);// 设置字体大小 + cellStyle.setFont(font);// 选择需要用到的字体格式 + cellStyle.setWrapText(true); + + XSSFSheet sheet = workbook.createSheet(sheetName); + //自适应宽度 + sheet.autoSizeColumn(0, true); + //默认列宽 + sheet.setDefaultColumnWidth(20); + //默认行高 + sheet.setDefaultRowHeightInPoints(18); + + + XSSFCellStyle numberCellStyle = null; + if (defaultPattern != null) { + XSSFDataFormat df = workbook.createDataFormat(); + String start = "0."; + if (defaultPattern.equals(0)) { + start = "0"; + } + short format = df.getFormat(start + Stream.generate(() -> "0").limit(defaultPattern).collect(Collectors.joining()) + "_ "); + numberCellStyle = workbook.createCellStyle(); + BeanUtils.copyProperties(cellStyle, numberCellStyle); + numberCellStyle.setDataFormat(format); + } + + for (int rowIndex = 0; rowIndex < rowList.size(); rowIndex++) { + List infoList = rowList.get(rowIndex); + XSSFRow row = sheet.createRow(rowIndex); + for (int cellIndex = 0; cellIndex < infoList.size(); cellIndex++) { + XSSFCell cell = row.createCell(cellIndex); + cell.setCellType(CellType.STRING); + if (rowIndex == 0) { + cell.setCellStyle(titleCellStyle); + } else { + cell.setCellStyle(cellStyle); + } + Object o = infoList.get(cellIndex); + if (o instanceof String) { + cell.setCellType(CellType.STRING); + cell.setCellValue(String.valueOf(o)); + } else if (o instanceof BigDecimal) { + cell.setCellType(CellType.NUMERIC); + cell.setCellValue(o == null ? 0 : ((BigDecimal) o).doubleValue()); + if (defaultPattern != null) { + cell.setCellStyle(numberCellStyle); + } + } else { + cell.setCellType(CellType.STRING); + cell.setCellValue(o == null ? "" : o.toString()); + } +// sheet.setColumnWidth(cellIndex, 35 * 256); + } + } + return workbook; + } + + public static XSSFWorkbook genWorkbook(String sheetName, List rowList) { + List headerList = Lists.newArrayList(); + List dataIndexList = Lists.newArrayList(); + // 解析表头 + ExcelUtil.parseHeader(TaxDeclarationLaborListDTO.class, headerList, dataIndexList); + + List> rows = new ArrayList<>(); + rows.add(headerList); + for (int i = 0; i < rowList.size(); i++) { + List row = Lists.newArrayListWithExpectedSize(dataIndexList.size()); + for (int j = 0; j < dataIndexList.size(); j++) { + Object value = getValue(rowList.get(i), dataIndexList.get(j)); + row.add(value); + } + rows.add(row); + } + return genWorkbookV2(rows, sheetName); + } + + private static Object getValue(T t, String fieldName) { + Object value = null; + try { + BeanInfo beanInfo = Introspector.getBeanInfo(t.getClass()); + PropertyDescriptor[] props = beanInfo.getPropertyDescriptors(); + for (PropertyDescriptor property : props) { + if (fieldName.equals(property.getName())) { + Method method = property.getReadMethod(); + value = method.invoke(t, new Object[]{}); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + return value; + } + + public static XSSFWorkbook genWorkbookV2(List> rowList, String sheetName) { + XSSFWorkbook workbook = new XSSFWorkbook(); + + // 设置title样式 + XSSFCellStyle titleCellStyle = workbook.createCellStyle(); + XSSFFont titleFont = workbook.createFont(); + titleFont.setFontName("仿宋"); + titleFont.setFontHeightInPoints((short) 15); + titleCellStyle.setFont(titleFont); + titleCellStyle.setAlignment(HorizontalAlignment.CENTER); + titleCellStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());//背景色 + titleCellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); + + + // 设置主体样式 + XSSFCellStyle cellStyle = workbook.createCellStyle(); + XSSFFont font = workbook.createFont(); + font.setFontName("宋体"); + font.setFontHeightInPoints((short) 10);// 设置字体大小 + cellStyle.setFont(font);// 选择需要用到的字体格式 + cellStyle.setWrapText(true); + + XSSFSheet sheet = workbook.createSheet(sheetName); + //自适应宽度 + sheet.autoSizeColumn(0, true); + //默认列宽 + sheet.setDefaultColumnWidth(20); + //默认行高 + sheet.setDefaultRowHeightInPoints(18); + + for (int rowIndex = 0; rowIndex < rowList.size(); rowIndex++) { + List infoList = rowList.get(rowIndex); + XSSFRow row = sheet.createRow(rowIndex); + for (int cellIndex = 0; cellIndex < infoList.size(); cellIndex++) { + XSSFCell cell = row.createCell(cellIndex); + if (rowIndex == 0) { + cell.setCellStyle(titleCellStyle); + } else { + cell.setCellStyle(cellStyle); + } + Object o = infoList.get(cellIndex); + if (o instanceof String) { + cell.setCellType(CellType.STRING); + cell.setCellValue(String.valueOf(o)); + } else if (o instanceof BigDecimal) { + cell.setCellType(CellType.NUMERIC); + cell.setCellValue(o == null ? 0 : ((BigDecimal) o).doubleValue()); + } else if (o instanceof Boolean) { + cell.setCellType(CellType.BOOLEAN); + cell.setCellValue(String.valueOf(o)); + } else if (o instanceof Date) { + cell.setCellType(CellType.STRING); + cell.setCellValue(SalaryDateUtil.getFormatLocalDate((Date) o)); + } else { + cell.setCellType(CellType.STRING); + cell.setCellValue(o == null ? "" : o.toString()); + } + } + } + return workbook; + } + + // 设置默认舍入位数,可传null + public static XSSFWorkbook genWorkbookV2WithDefaultPattern(List> rowList, String sheetName, Integer defaultPattern) { + XSSFWorkbook workbook = new XSSFWorkbook(); + + // 设置title样式 + XSSFCellStyle titleCellStyle = workbook.createCellStyle(); + XSSFFont titleFont = workbook.createFont(); + titleFont.setFontName("仿宋"); + titleFont.setFontHeightInPoints((short) 15); + titleCellStyle.setFont(titleFont); + titleCellStyle.setAlignment(HorizontalAlignment.CENTER); + titleCellStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());//背景色 + titleCellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); + + + // 设置主体样式 + XSSFCellStyle cellStyle = workbook.createCellStyle(); + XSSFFont font = workbook.createFont(); + font.setFontName("宋体"); + font.setFontHeightInPoints((short) 10);// 设置字体大小 + cellStyle.setFont(font);// 选择需要用到的字体格式 + cellStyle.setWrapText(true); + + XSSFSheet sheet = workbook.createSheet(sheetName); + //自适应宽度 + sheet.autoSizeColumn(0, true); + //默认列宽 + sheet.setDefaultColumnWidth(20); + //默认行高 + sheet.setDefaultRowHeightInPoints(18); + + XSSFCellStyle numberCellStyle = null; + if (defaultPattern != null) { + XSSFDataFormat df = workbook.createDataFormat(); + String start = "0."; + if (defaultPattern.equals(0)) { + start = "0"; + } + short format = df.getFormat(start + Stream.generate(() -> "0").limit(defaultPattern).collect(Collectors.joining()) + "_ "); + numberCellStyle = workbook.createCellStyle(); + BeanUtils.copyProperties(cellStyle, numberCellStyle); + numberCellStyle.setDataFormat(format); + } + + for (int rowIndex = 0; rowIndex < rowList.size(); rowIndex++) { + List infoList = rowList.get(rowIndex); + XSSFRow row = sheet.createRow(rowIndex); + for (int cellIndex = 0; cellIndex < infoList.size(); cellIndex++) { + XSSFCell cell = row.createCell(cellIndex); + if (rowIndex == 0) { + cell.setCellStyle(titleCellStyle); + } else { + cell.setCellStyle(cellStyle); + } + Object o = infoList.get(cellIndex); + if (o instanceof String) { + cell.setCellType(CellType.STRING); + cell.setCellValue(String.valueOf(o)); + } else if (o instanceof BigDecimal) { + cell.setCellType(CellType.NUMERIC); + cell.setCellValue(o == null ? 0 : ((BigDecimal) o).doubleValue()); + if (defaultPattern != null) { + cell.setCellStyle(numberCellStyle); + } + } else if (o instanceof Boolean) { + cell.setCellType(CellType.BOOLEAN); + cell.setCellValue(String.valueOf(o)); + } else if (o instanceof Date) { + cell.setCellType(CellType.STRING); + cell.setCellValue(SalaryDateUtil.getFormatLocalDate((Date) o)); + } else { + cell.setCellType(CellType.STRING); + cell.setCellValue(o == null ? "" : o.toString()); + } + } + } + return workbook; + } + + + public static XSSFWorkbook genWorkbookV2(List> rowList, String sheetName, List comments) { + XSSFWorkbook workbook = new XSSFWorkbook(); + + // 设置title样式 + XSSFCellStyle titleCellStyle = workbook.createCellStyle(); + XSSFFont titleFont = workbook.createFont(); + titleFont.setFontName("仿宋"); + titleFont.setFontHeightInPoints((short) 15); + titleCellStyle.setFont(titleFont); + titleCellStyle.setAlignment(HorizontalAlignment.CENTER); + titleCellStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());//背景色 + titleCellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); + + + // 设置主体样式 + XSSFCellStyle cellStyle = workbook.createCellStyle(); + XSSFFont font = workbook.createFont(); + font.setFontName("宋体"); + font.setFontHeightInPoints((short) 10);// 设置字体大小 + cellStyle.setFont(font);// 选择需要用到的字体格式 + cellStyle.setWrapText(true); + + XSSFSheet sheet = workbook.createSheet(sheetName); + //自适应宽度 + sheet.autoSizeColumn(0, true); + //默认列宽 + sheet.setDefaultColumnWidth(20); + //默认行高 + sheet.setDefaultRowHeightInPoints(18); + + for (int rowIndex = 0; rowIndex < rowList.size(); rowIndex++) { + List infoList = rowList.get(rowIndex); + XSSFRow row = sheet.createRow(rowIndex); + for (int cellIndex = 0; cellIndex < infoList.size(); cellIndex++) { + XSSFCell cell = row.createCell(cellIndex); + if (rowIndex == 0) { + cell.setCellStyle(titleCellStyle); + } else { + cell.setCellStyle(cellStyle); + } + Object o = infoList.get(cellIndex); + if (o instanceof String) { + cell.setCellType(CellType.STRING); + cell.setCellValue(String.valueOf(o)); + } else if (o instanceof Boolean) { + cell.setCellType(CellType.BOOLEAN); + cell.setCellValue(String.valueOf(o)); + } else if (o instanceof Date) { + cell.setCellType(CellType.STRING); + cell.setCellValue(SalaryDateUtil.getFormatLocalDate((Date) o)); + } else { + cell.setCellType(CellType.STRING); + cell.setCellValue(String.valueOf(o)); + } + } + } + + if (CollectionUtils.isNotEmpty(comments)) { + for (ExcelComment c : comments) { + XSSFDrawing patr = sheet.createDrawingPatriarch(); + XSSFComment cellComment = patr.createCellComment(new XSSFClientAnchor(c.dx1, c.dy1, c.dx2, c.dy2, c.col1, c.row1, c.col2, c.row2)); + cellComment.setString(c.content); + } + } + return workbook; + } + + + public static XSSFWorkbook genWorkbookV2(List> rowList, String sheetName, boolean lastRowRed) { + XSSFWorkbook workbook = new XSSFWorkbook(); + + // 设置title样式 + XSSFCellStyle titleCellStyle = workbook.createCellStyle(); + XSSFFont titleFont = workbook.createFont(); + titleFont.setFontName("仿宋"); + titleFont.setFontHeightInPoints((short) 15); + titleCellStyle.setFont(titleFont); + titleCellStyle.setAlignment(HorizontalAlignment.CENTER); + titleCellStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());//背景色 + titleCellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); + + + // 设置主体样式 + XSSFCellStyle cellStyle = workbook.createCellStyle(); + XSSFFont font = workbook.createFont(); + font.setFontName("宋体"); + font.setFontHeightInPoints((short) 10);// 设置字体大小 + cellStyle.setFont(font);// 选择需要用到的字体格式 + cellStyle.setWrapText(true); + + XSSFCellStyle redCellStyle = workbook.createCellStyle(); + XSSFFont redFont = workbook.createFont(); + redFont.setFontName("宋体"); + redFont.setFontHeightInPoints((short) 10);// 设置字体大小 + redFont.setColor(new XSSFColor(new Color(0xFF3333), null)); + redFont.setBold(true); + redCellStyle.setWrapText(true); + redCellStyle.setFont(redFont);// 选择需要用到的字体格式 + + XSSFSheet sheet = workbook.createSheet(sheetName); + //自适应宽度 + sheet.autoSizeColumn(0, true); + //默认列宽 + sheet.setDefaultColumnWidth(20); + //默认行高 + sheet.setDefaultRowHeightInPoints(18); + + for (int rowIndex = 0; rowIndex < rowList.size(); rowIndex++) { + List infoList = rowList.get(rowIndex); + XSSFRow row = sheet.createRow(rowIndex); + for (int cellIndex = 0; cellIndex < infoList.size(); cellIndex++) { + XSSFCell cell = row.createCell(cellIndex); + if (rowIndex == 0) { + cell.setCellStyle(titleCellStyle); + } else { + if (lastRowRed && rowIndex == rowList.size() - 1) { + cell.setCellStyle(redCellStyle); + } else { + cell.setCellStyle(cellStyle); + } + } + Object o = infoList.get(cellIndex); + if (o instanceof String) { + cell.setCellType(CellType.STRING); + cell.setCellValue(String.valueOf(o)); + } else if (o instanceof Boolean) { + cell.setCellType(CellType.BOOLEAN); + cell.setCellValue(String.valueOf(o)); + } else if (o instanceof Date) { + cell.setCellType(CellType.STRING); + cell.setCellValue(SalaryDateUtil.getFormatLocalDate((Date) o)); + } else { + cell.setCellType(CellType.STRING); + cell.setCellValue(o == null ? "" : o.toString()); + } + } + } + return workbook; + } + + /** + * 解析表头 + * + * @param clazz + * @param headerList + * @param dataIndexList + * @param + */ + public static void parseHeader(Class clazz, List headerList, List dataIndexList) { + Field[] declaredFields = clazz.getDeclaredFields(); + for (Field declaredField : declaredFields) { + if (!declaredField.isAnnotationPresent(ExcelHead.class)) { + continue; + } + ExcelHead annotation = declaredField.getAnnotation(ExcelHead.class); + headerList.add(SalaryI18nUtil.getI18nLabel(annotation.labelId(), annotation.title())); + dataIndexList.add(declaredField.getName()); + } + } +} diff --git a/src/com/engine/salary/util/excel/ExcelUtilPlus.java b/src/com/engine/salary/util/excel/ExcelUtilPlus.java new file mode 100644 index 000000000..9da402ce7 --- /dev/null +++ b/src/com/engine/salary/util/excel/ExcelUtilPlus.java @@ -0,0 +1,897 @@ +package com.engine.salary.util.excel; + +import com.engine.salary.component.WeaTableColumnGroup; +import com.engine.salary.util.SalaryDateUtil; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.poi.ss.usermodel.*; +import org.apache.poi.ss.util.CellRangeAddress; +import org.apache.poi.xssf.usermodel.*; + +import java.awt.Color; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +public class ExcelUtilPlus { + /** + * 生成excel + * + * @param rowList + * @return + */ + public static XSSFWorkbook genWorkbook(List> rowList, String sheetName) { + XSSFWorkbook workbook = new XSSFWorkbook(); + + // 设置title样式 + XSSFCellStyle titleCellStyle = workbook.createCellStyle(); + XSSFFont titleFont = workbook.createFont(); + titleFont.setFontName("仿宋"); + titleFont.setFontHeightInPoints((short) 15); + titleCellStyle.setFont(titleFont); + titleCellStyle.setAlignment(HorizontalAlignment.CENTER); + titleCellStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());//背景色 + titleCellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); + + + // 设置主体样式 + XSSFCellStyle cellStyle = workbook.createCellStyle(); + XSSFFont font = workbook.createFont(); + font.setFontName("宋体"); + font.setFontHeightInPoints((short) 10);// 设置字体大小 + cellStyle.setFont(font);// 选择需要用到的字体格式 + cellStyle.setWrapText(true); + + XSSFSheet sheet = workbook.createSheet(sheetName); + //自适应宽度 + sheet.autoSizeColumn(0, true); + //默认列宽 + sheet.setDefaultColumnWidth(20); + //默认行高 + sheet.setDefaultRowHeightInPoints(18); + + for (int rowIndex = 0; rowIndex < rowList.size(); rowIndex++) { + List infoList = rowList.get(rowIndex); + XSSFRow row = sheet.createRow(rowIndex); + for (int cellIndex = 0; cellIndex < infoList.size(); cellIndex++) { + XSSFCell cell = row.createCell(cellIndex); + cell.setCellType(CellType.STRING); + if (rowIndex == 0) { + cell.setCellStyle(titleCellStyle); + } else { + cell.setCellStyle(cellStyle); + } + cell.setCellValue(infoList.get(cellIndex)); +// sheet.setColumnWidth(cellIndex, 35 * 256); + } + } + return workbook; + } + + + public static XSSFWorkbook genWorkbookV2WithPattern(List> rowList, String sheetName, boolean lastRowRed) { + XSSFWorkbook workbook = new XSSFWorkbook(); + + // 设置title样式 + XSSFCellStyle titleCellStyle = workbook.createCellStyle(); + XSSFFont titleFont = workbook.createFont(); + titleFont.setBold(true); + titleFont.setFontName("仿宋"); + titleFont.setFontHeightInPoints((short) 15); + titleCellStyle.setFont(titleFont); + titleCellStyle.setAlignment(HorizontalAlignment.CENTER); + titleCellStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());//背景色 + titleCellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); + titleCellStyle.setVerticalAlignment(VerticalAlignment.CENTER); + titleCellStyle.setBorderLeft(BorderStyle.THIN); + titleCellStyle.setBorderRight(BorderStyle.THIN); + titleCellStyle.setBorderTop(BorderStyle.THIN); + titleCellStyle.setBorderBottom(BorderStyle.THIN); + + + // 设置主体样式 + XSSFCellStyle cellStyle = workbook.createCellStyle(); + XSSFFont font = workbook.createFont(); + font.setFontName("宋体"); + font.setFontHeightInPoints((short) 10);// 设置字体大小 + cellStyle.setFont(font);// 选择需要用到的字体格式 + cellStyle.setWrapText(true); + cellStyle.setBorderLeft(BorderStyle.THIN); + cellStyle.setBorderRight(BorderStyle.THIN); + cellStyle.setBorderTop(BorderStyle.THIN); + cellStyle.setBorderBottom(BorderStyle.THIN); + + XSSFCellStyle redCellStyle = workbook.createCellStyle(); + XSSFFont redFont = workbook.createFont(); + redFont.setFontName("宋体"); + redFont.setFontHeightInPoints((short) 10);// 设置字体大小 + redFont.setColor(new XSSFColor(new Color(0xFF3333), null)); + redFont.setBold(true); + redCellStyle.setWrapText(true); + redCellStyle.setFont(redFont);// 选择需要用到的字体格式 + redCellStyle.setBorderLeft(BorderStyle.THIN); + redCellStyle.setBorderRight(BorderStyle.THIN); + redCellStyle.setBorderTop(BorderStyle.THIN); + redCellStyle.setBorderBottom(BorderStyle.THIN); + + XSSFSheet sheet = workbook.createSheet(sheetName); + //自适应宽度 + sheet.autoSizeColumn(0, true); + //默认列宽 + sheet.setDefaultColumnWidth(20); + //默认行高 + sheet.setDefaultRowHeightInPoints(18); + //遍历设置列宽 + List header = rowList.get(0); + List patternList = new ArrayList<>(); + XSSFRow row0 = sheet.createRow(0); + for (int i = 0; i < header.size(); i++) { + WeaTableColumnGroup columnGroupItem = (WeaTableColumnGroup) header.get(i); + XSSFCell rowZeroCell = row0.createCell(i, CellType.STRING); + rowZeroCell.setCellValue(columnGroupItem.getText().toString()); + rowZeroCell.setCellStyle(titleCellStyle); + //设置列宽 + sheet.setColumnWidth(i, Math.min(255, Math.max(12, columnGroupItem.getText().length() * 4)) * 256); + patternList.add(columnGroupItem.getPattern()); + } + + HashMap numberCellStyleMap = new HashMap(); + HashMap numberRedCellStyleMap = new HashMap(); + XSSFDataFormat df = workbook.createDataFormat(); + patternList.stream().distinct().filter(a -> a != null).forEach(p -> { + String start = "0."; + if (p == 0) { + start = "0"; + } + + XSSFCellStyle numberRedCellStyle = workbook.createCellStyle(); + // 不能copy,在excel里编辑时背景变成了黑色 + // BeanUtils.copyProperties(redCellStyle, numberRedCellStyle); + numberRedCellStyle.setWrapText(true); + numberRedCellStyle.setBorderLeft(BorderStyle.THIN); + numberRedCellStyle.setBorderRight(BorderStyle.THIN); + numberRedCellStyle.setBorderTop(BorderStyle.THIN); + numberRedCellStyle.setBorderBottom(BorderStyle.THIN); + numberRedCellStyle.setFont(redFont); + short format = df.getFormat(start + Stream.generate(() -> "0").limit(p).collect(Collectors.joining()) + "_ "); + numberRedCellStyle.setDataFormat(format); + numberRedCellStyleMap.put(p, numberRedCellStyle); + XSSFCellStyle numberCellStyle = workbook.createCellStyle(); + // BeanUtils.copyProperties(cellStyle, numberCellStyle); + numberCellStyle.setFont(font);// 选择需要用到的字体格式 + numberCellStyle.setWrapText(true); + numberCellStyle.setBorderLeft(BorderStyle.THIN); + numberCellStyle.setBorderRight(BorderStyle.THIN); + numberCellStyle.setBorderTop(BorderStyle.THIN); + numberCellStyle.setBorderBottom(BorderStyle.THIN); + numberCellStyle.setDataFormat(format); + numberCellStyleMap.put(p, numberCellStyle); + }); + + for (int rowIndex = 1; rowIndex < rowList.size(); rowIndex++) { + List infoList = rowList.get(rowIndex); + XSSFRow row = sheet.createRow(rowIndex); + float height = 18; + float finalHeight = 18; + + for (int cellIndex = 0; cellIndex < infoList.size(); cellIndex++) { + XSSFCell cell = row.createCell(cellIndex); + if (rowIndex == 0) { + cell.setCellStyle(titleCellStyle); + } else { + if (lastRowRed && rowIndex == rowList.size() - 1) { + cell.setCellStyle(redCellStyle); + } else { + cell.setCellStyle(cellStyle); + } + } + Object o = infoList.get(cellIndex); + if (o instanceof String) { + cell.setCellType(CellType.STRING); + cell.setCellValue(String.valueOf(o)); + } else if (o instanceof BigDecimal) { + if (lastRowRed && rowIndex == rowList.size() - 1) { + cell.setCellStyle(numberRedCellStyleMap.get(patternList.get(cellIndex))); + } else { + cell.setCellStyle(numberCellStyleMap.get(patternList.get(cellIndex))); + } + cell.setCellType(CellType.NUMERIC); + double value = o == null ? 0 : ((BigDecimal) o).doubleValue(); + cell.setCellValue(o == null ? 0 : ((BigDecimal) o).doubleValue()); + } else if (o instanceof Boolean) { + cell.setCellType(CellType.BOOLEAN); + cell.setCellValue(String.valueOf(o)); + } else if (o instanceof Date) { + cell.setCellType(CellType.STRING); + cell.setCellValue(SalaryDateUtil.getFormatLocalDate((Date) o)); + } else { + cell.setCellType(CellType.STRING); + cell.setCellValue(o == null ? "" : o.toString()); + } + + //判断是否要调整高度 + int width = sheet.getColumnWidth(cellIndex) / 256; + finalHeight = getFinalHeight(o, width, finalHeight, height); + } + row.setHeightInPoints(finalHeight); + } + return workbook; + } + public static XSSFWorkbook genWorkbookV2(List> rowList, String sheetName) { + XSSFWorkbook workbook = new XSSFWorkbook(); + + // 设置title样式 + XSSFCellStyle titleCellStyle = workbook.createCellStyle(); + XSSFFont titleFont = workbook.createFont(); + titleFont.setBold(true); + titleFont.setFontName("仿宋"); + titleFont.setFontHeightInPoints((short) 15); + titleCellStyle.setFont(titleFont); + titleCellStyle.setAlignment(HorizontalAlignment.CENTER); + titleCellStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());//背景色 + titleCellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); + titleCellStyle.setVerticalAlignment(VerticalAlignment.CENTER); + titleCellStyle.setBorderLeft(BorderStyle.THIN); + titleCellStyle.setBorderRight(BorderStyle.THIN); + titleCellStyle.setBorderTop(BorderStyle.THIN); + titleCellStyle.setBorderBottom(BorderStyle.THIN); + + + // 设置主体样式 + XSSFCellStyle cellStyle = workbook.createCellStyle(); + XSSFFont font = workbook.createFont(); + font.setFontName("宋体"); + font.setFontHeightInPoints((short) 10);// 设置字体大小 + cellStyle.setFont(font);// 选择需要用到的字体格式 + cellStyle.setWrapText(true); + cellStyle.setBorderLeft(BorderStyle.THIN); + cellStyle.setBorderRight(BorderStyle.THIN); + cellStyle.setBorderTop(BorderStyle.THIN); + cellStyle.setBorderBottom(BorderStyle.THIN); + + XSSFSheet sheet = workbook.createSheet(sheetName); + //自适应宽度 + sheet.autoSizeColumn(0, true); + //默认列宽 + sheet.setDefaultColumnWidth(20); + //默认行高 + sheet.setDefaultRowHeightInPoints(18); + //遍历设置列宽 + List header = rowList.get(0); + for (int i = 0; i < header.size(); i++) { + sheet.setColumnWidth(i, Math.min(255, Math.max(12, header.get(i).toString().length() * 4)) * 256); + } + + for (int rowIndex = 0; rowIndex < rowList.size(); rowIndex++) { + List infoList = rowList.get(rowIndex); + XSSFRow row = sheet.createRow(rowIndex); + float height = 18; + float finalHeight = 18; + + for (int cellIndex = 0; cellIndex < infoList.size(); cellIndex++) { + XSSFCell cell = row.createCell(cellIndex); + if (rowIndex == 0) { + cell.setCellStyle(titleCellStyle); + } else { + cell.setCellStyle(cellStyle); + } + Object o = infoList.get(cellIndex); + if (o instanceof String) { + cell.setCellType(CellType.STRING); + cell.setCellValue(String.valueOf(o)); + } else if (o instanceof BigDecimal) { + cell.setCellType(CellType.NUMERIC); + cell.setCellValue(o == null ? 0 : ((BigDecimal) o).doubleValue()); + } else if (o instanceof Boolean) { + cell.setCellType(CellType.BOOLEAN); + cell.setCellValue(String.valueOf(o)); + } else if (o instanceof Date) { + cell.setCellType(CellType.STRING); + cell.setCellValue(SalaryDateUtil.getFormatLocalDate((Date) o)); + } else { + cell.setCellType(CellType.STRING); + cell.setCellValue(o == null ? "" : o.toString()); + } + + //判断是否要调整高度 + int width = sheet.getColumnWidth(cellIndex) / 256; + finalHeight = getFinalHeight(o, width, finalHeight, height); + } + row.setHeightInPoints(finalHeight); + } + return workbook; + } + + + public static XSSFWorkbook genWorkbookV2(List> rowList, String sheetName, List comments) { + XSSFWorkbook workbook = new XSSFWorkbook(); + + // 设置title样式 + XSSFCellStyle titleCellStyle = workbook.createCellStyle(); + XSSFFont titleFont = workbook.createFont(); + titleFont.setBold(true); + titleFont.setFontName("仿宋"); + titleFont.setFontHeightInPoints((short) 15); + titleCellStyle.setFont(titleFont); + titleCellStyle.setAlignment(HorizontalAlignment.CENTER); + titleCellStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());//背景色 + titleCellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); + titleCellStyle.setVerticalAlignment(VerticalAlignment.CENTER); + titleCellStyle.setBorderLeft(BorderStyle.THIN); + titleCellStyle.setBorderRight(BorderStyle.THIN); + titleCellStyle.setBorderTop(BorderStyle.THIN); + titleCellStyle.setBorderBottom(BorderStyle.THIN); + + + // 设置主体样式 + XSSFCellStyle cellStyle = workbook.createCellStyle(); + XSSFFont font = workbook.createFont(); + font.setFontName("宋体"); + font.setFontHeightInPoints((short) 10);// 设置字体大小 + cellStyle.setFont(font);// 选择需要用到的字体格式 + cellStyle.setWrapText(true); + cellStyle.setBorderLeft(BorderStyle.THIN); + cellStyle.setBorderRight(BorderStyle.THIN); + cellStyle.setBorderTop(BorderStyle.THIN); + cellStyle.setBorderBottom(BorderStyle.THIN); + + XSSFSheet sheet = workbook.createSheet(sheetName); + //自适应宽度 + sheet.autoSizeColumn(0, true); + //默认列宽 + sheet.setDefaultColumnWidth(20); + //默认行高 + sheet.setDefaultRowHeightInPoints(18); + + //遍历设置列宽 + List header = rowList.get(0); + for (int i = 0; i < header.size(); i++) { + sheet.setColumnWidth(i, Math.min(255, Math.max(12, header.get(i).toString().length() * 4)) * 256); + } + + for (int rowIndex = 0; rowIndex < rowList.size(); rowIndex++) { + List infoList = rowList.get(rowIndex); + XSSFRow row = sheet.createRow(rowIndex); + float height = 18; + float finalHeight = 18; + + for (int cellIndex = 0; cellIndex < infoList.size(); cellIndex++) { + XSSFCell cell = row.createCell(cellIndex); + if (rowIndex == 0) { + cell.setCellStyle(titleCellStyle); + } else { + cell.setCellStyle(cellStyle); + } + Object o = infoList.get(cellIndex); + if (o instanceof String) { + cell.setCellType(CellType.STRING); + cell.setCellValue(String.valueOf(o)); + } else if (o instanceof Boolean) { + cell.setCellType(CellType.BOOLEAN); + cell.setCellValue(String.valueOf(o)); + } else if (o instanceof Date) { + cell.setCellType(CellType.STRING); + cell.setCellValue(SalaryDateUtil.getFormatLocalDate((Date) o)); + } else { + cell.setCellType(CellType.STRING); + cell.setCellValue(String.valueOf(o)); + } + + //判断是否要调整高度 + int width = sheet.getColumnWidth(cellIndex) / 256; + finalHeight = getFinalHeight(o, width, finalHeight, height); + } + row.setHeightInPoints(finalHeight); + } + + if (CollectionUtils.isNotEmpty(comments)) { + for (ExcelComment c : comments) { + XSSFDrawing patr = sheet.createDrawingPatriarch(); + XSSFComment cellComment = patr.createCellComment(new XSSFClientAnchor(c.dx1, c.dy1, c.dx2, c.dy2, c.col1, c.row1, c.col2, c.row2)); + cellComment.setString(c.content); + } + } + return workbook; + } + + public static XSSFWorkbook genWorkbookV2(List> rowList, String sheetName, boolean lastRowRed) { + XSSFWorkbook workbook = new XSSFWorkbook(); + + // 设置title样式 + XSSFCellStyle titleCellStyle = workbook.createCellStyle(); + XSSFFont titleFont = workbook.createFont(); + titleFont.setBold(true); + titleFont.setFontName("仿宋"); + titleFont.setFontHeightInPoints((short) 15); + titleCellStyle.setFont(titleFont); + titleCellStyle.setAlignment(HorizontalAlignment.CENTER); + titleCellStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());//背景色 + titleCellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); + titleCellStyle.setVerticalAlignment(VerticalAlignment.CENTER); + titleCellStyle.setBorderLeft(BorderStyle.THIN); + titleCellStyle.setBorderRight(BorderStyle.THIN); + titleCellStyle.setBorderTop(BorderStyle.THIN); + titleCellStyle.setBorderBottom(BorderStyle.THIN); + + // 设置主体样式 + XSSFCellStyle cellStyle = workbook.createCellStyle(); + XSSFFont font = workbook.createFont(); + font.setFontName("宋体"); + font.setFontHeightInPoints((short) 10);// 设置字体大小 + cellStyle.setFont(font);// 选择需要用到的字体格式 + cellStyle.setWrapText(true); + + cellStyle.setBorderLeft(BorderStyle.THIN); + cellStyle.setBorderRight(BorderStyle.THIN); + cellStyle.setBorderTop(BorderStyle.THIN); + cellStyle.setBorderBottom(BorderStyle.THIN); + + XSSFCellStyle redCellStyle = workbook.createCellStyle(); + XSSFFont redFont = workbook.createFont(); + redFont.setFontName("宋体"); + redFont.setFontHeightInPoints((short) 10);// 设置字体大小 + redFont.setColor(new XSSFColor(new Color(0xFF3333), null)); + redFont.setBold(true); + redCellStyle.setWrapText(true); + redCellStyle.setFont(redFont);// 选择需要用到的字体格式 + + redCellStyle.setBorderLeft(BorderStyle.THIN); + redCellStyle.setBorderRight(BorderStyle.THIN); + redCellStyle.setBorderTop(BorderStyle.THIN); + redCellStyle.setBorderBottom(BorderStyle.THIN); + + XSSFSheet sheet = workbook.createSheet(sheetName); + //自适应宽度 + sheet.autoSizeColumn(0, true); + //默认列宽 + sheet.setDefaultColumnWidth(20); + //默认行高 + sheet.setDefaultRowHeightInPoints(18); + + //遍历设置列宽 + List header = rowList.get(0); + for (int i = 0; i < header.size(); i++) { + sheet.setColumnWidth(i, Math.min(255, Math.max(12, header.get(i).toString().length() * 4)) * 256); + } + + for (int rowIndex = 0; rowIndex < rowList.size(); rowIndex++) { + List infoList = rowList.get(rowIndex); + XSSFRow row = sheet.createRow(rowIndex); + float height = 18; + float finalHeight = 18; + + for (int cellIndex = 0; cellIndex < infoList.size(); cellIndex++) { + XSSFCell cell = row.createCell(cellIndex); + if (rowIndex == 0) { + cell.setCellStyle(titleCellStyle); + } else { + if (lastRowRed && rowIndex == rowList.size() - 1) { + cell.setCellStyle(redCellStyle); + } else { + cell.setCellStyle(cellStyle); + } + } + Object o = infoList.get(cellIndex); + if (o instanceof String) { + cell.setCellType(CellType.STRING); + cell.setCellValue(String.valueOf(o)); + } else if (o instanceof BigDecimal) { + cell.setCellType(CellType.NUMERIC); + cell.setCellValue(o == null ? 0 : ((BigDecimal) o).doubleValue()); + } else if (o instanceof Boolean) { + cell.setCellType(CellType.BOOLEAN); + cell.setCellValue(String.valueOf(o)); + } else if (o instanceof Date) { + cell.setCellType(CellType.STRING); + cell.setCellValue(SalaryDateUtil.getFormatLocalDate((Date) o)); + } else { + cell.setCellType(CellType.STRING); + cell.setCellValue(o == null ? "" : o.toString()); + } + + //判断是否要调整高度 + int width = sheet.getColumnWidth(cellIndex) / 256; + finalHeight = getFinalHeight(o, width, finalHeight, height); + } + row.setHeightInPoints(finalHeight); + } + return workbook; + } + + // 数值项目修改excel单元格格式为数值 + public static XSSFWorkbook genWorkbookWithChildTitleColumnWithExcelFormat(List> rowList, String sheetName, boolean lastRowRed) { + XSSFWorkbook workbook = new XSSFWorkbook(); + + // 设置title样式 + XSSFCellStyle titleCellStyle = workbook.createCellStyle(); + XSSFFont titleFont = workbook.createFont(); + titleFont.setBold(true); + titleFont.setFontName("仿宋"); + titleFont.setFontHeightInPoints((short) 15); + titleCellStyle.setFont(titleFont); + titleCellStyle.setAlignment(HorizontalAlignment.CENTER); + titleCellStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());//背景色 + titleCellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); + titleCellStyle.setVerticalAlignment(VerticalAlignment.CENTER); + titleCellStyle.setBorderLeft(BorderStyle.THIN); + titleCellStyle.setBorderRight(BorderStyle.THIN); + titleCellStyle.setBorderTop(BorderStyle.THIN); + titleCellStyle.setBorderBottom(BorderStyle.THIN); + + XSSFCellStyle childTitleCellStyle = workbook.createCellStyle(); + childTitleCellStyle.setFont(titleFont); + childTitleCellStyle.setAlignment(HorizontalAlignment.LEFT); + childTitleCellStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());//背景色 + childTitleCellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); + childTitleCellStyle.setVerticalAlignment(VerticalAlignment.CENTER); + childTitleCellStyle.setBorderLeft(BorderStyle.THIN); + childTitleCellStyle.setBorderRight(BorderStyle.THIN); + childTitleCellStyle.setBorderTop(BorderStyle.THIN); + childTitleCellStyle.setBorderBottom(BorderStyle.THIN); + + + // 设置主体样式 + XSSFCellStyle cellStyle = workbook.createCellStyle(); + XSSFFont font = workbook.createFont(); + font.setFontName("宋体"); + font.setFontHeightInPoints((short) 10);// 设置字体大小 + cellStyle.setFont(font);// 选择需要用到的字体格式 + cellStyle.setWrapText(true); + + cellStyle.setBorderLeft(BorderStyle.THIN); + cellStyle.setBorderRight(BorderStyle.THIN); + cellStyle.setBorderTop(BorderStyle.THIN); + cellStyle.setBorderBottom(BorderStyle.THIN); + + XSSFCellStyle redCellStyle = workbook.createCellStyle(); + XSSFFont redFont = workbook.createFont(); + redFont.setFontName("宋体"); + redFont.setFontHeightInPoints((short) 10);// 设置字体大小 + redFont.setColor(new XSSFColor(new Color(0xFF3333), null)); + redFont.setBold(true); + redCellStyle.setWrapText(true); + redCellStyle.setFont(redFont);// 选择需要用到的字体格式 + + redCellStyle.setBorderLeft(BorderStyle.THIN); + redCellStyle.setBorderRight(BorderStyle.THIN); + redCellStyle.setBorderTop(BorderStyle.THIN); + redCellStyle.setBorderBottom(BorderStyle.THIN); + + XSSFSheet sheet = workbook.createSheet(sheetName); + //自适应宽度 + sheet.autoSizeColumn(0, true); + //默认列宽 + sheet.setDefaultColumnWidth(20); + //默认行高 + sheet.setDefaultRowHeightInPoints(18); + + //处理合并单元格 + XSSFRow row0 = sheet.createRow(0); + XSSFRow row1 = sheet.createRow(1); + + // 保留小数位数 + List patternList = new ArrayList<>(); + List header = rowList.get(0); + int startIndex = 0; + for (int i = 0; i < header.size(); i++) { + WeaTableColumnGroup columnGroupItem = (WeaTableColumnGroup) header.get(i); + if (columnGroupItem.getChildren() == null) { + sheet.addMergedRegion(new CellRangeAddress(0, 1, startIndex, startIndex)); + + XSSFCell rowZeroCell = row0.createCell(startIndex, CellType.STRING); + rowZeroCell.setCellValue(columnGroupItem.getText().toString()); + rowZeroCell.setCellStyle(titleCellStyle); + XSSFCell rowOneCell = row1.createCell(startIndex, CellType.STRING); + rowOneCell.setCellValue(columnGroupItem.getText().toString()); + rowOneCell.setCellStyle(titleCellStyle); + //设置列宽 + sheet.setColumnWidth(startIndex, Math.min(255, Math.max(12, columnGroupItem.getText().length() * 4)) * 256); + startIndex++; + patternList.add(columnGroupItem.getPattern()); + } else { + List childrenList = columnGroupItem.getChildren(); + int endIndex = startIndex + childrenList.size() - 1; + + if (endIndex > startIndex) { + sheet.addMergedRegion(new CellRangeAddress(0, 0, startIndex, endIndex)); + } + + XSSFCell cell = row0.createCell(startIndex, CellType.STRING); + cell.setCellValue(columnGroupItem.getText().toString()); + cell.setCellStyle(childTitleCellStyle); + + for (int j = 0; j < childrenList.size(); j++) { + WeaTableColumnGroup childrenItem = (WeaTableColumnGroup) childrenList.get(j); + + XSSFCell subHeader = row1.createCell(startIndex + j, CellType.STRING); + subHeader.setCellValue(childrenItem.getText().toString()); + subHeader.setCellStyle(titleCellStyle); + //设置列宽 + sheet.setColumnWidth(startIndex + j, Math.min(255, Math.max(12, childrenItem.getText().length() * 4)) * 256); + patternList.add(childrenItem.getPattern()); + } + + startIndex += childrenList.size(); + + } + + } + + HashMap numberCellStyleMap = new HashMap(); + HashMap numberRedCellStyleMap = new HashMap(); + XSSFDataFormat df = workbook.createDataFormat(); + patternList.stream().distinct().filter(a -> a != null).forEach(p -> { + String start = "0."; + if (p == 0) { + start = "0"; + } + XSSFCellStyle numberRedCellStyle = workbook.createCellStyle(); + // 不能copy,在excel里编辑时背景变成了黑色 + // BeanUtils.copyProperties(redCellStyle, numberRedCellStyle); + numberRedCellStyle.setWrapText(true); + numberRedCellStyle.setBorderLeft(BorderStyle.THIN); + numberRedCellStyle.setBorderRight(BorderStyle.THIN); + numberRedCellStyle.setBorderTop(BorderStyle.THIN); + numberRedCellStyle.setBorderBottom(BorderStyle.THIN); + numberRedCellStyle.setFont(redFont); + short format = df.getFormat(start + Stream.generate(() -> "0").limit(p).collect(Collectors.joining()) + "_ "); + numberRedCellStyle.setDataFormat(format); + // 最后一行红色 + numberRedCellStyleMap.put(p, numberRedCellStyle); + XSSFCellStyle numberCellStyle = workbook.createCellStyle(); + // BeanUtils.copyProperties(cellStyle, numberCellStyle); + numberCellStyle.setFont(font);// 选择需要用到的字体格式 + numberCellStyle.setWrapText(true); + numberCellStyle.setBorderLeft(BorderStyle.THIN); + numberCellStyle.setBorderRight(BorderStyle.THIN); + numberCellStyle.setBorderTop(BorderStyle.THIN); + numberCellStyle.setBorderBottom(BorderStyle.THIN); + + numberCellStyle.setDataFormat(format); + numberCellStyleMap.put(p, numberCellStyle); + }); + + for (int rowIndex = 1; rowIndex < rowList.size(); rowIndex++) { + List infoList = rowList.get(rowIndex); + XSSFRow row = sheet.createRow(rowIndex + 1); + float height = 18; + float finalHeight = 18; + + for (int cellIndex = 0; cellIndex < infoList.size(); cellIndex++) { + XSSFCell cell = row.createCell(cellIndex); + + if (rowIndex == 0) { + cell.setCellStyle(titleCellStyle); + } else { + if (lastRowRed && rowIndex == rowList.size() - 1) { + cell.setCellStyle(redCellStyle); + } else { + cell.setCellStyle(cellStyle); + } + } + Object o = infoList.get(cellIndex); + if (o instanceof String) { + cell.setCellType(CellType.STRING); + cell.setCellValue(String.valueOf(o)); + } else if (o instanceof BigDecimal) { + if (lastRowRed && rowIndex == rowList.size() - 1) { + cell.setCellStyle(numberRedCellStyleMap.get(patternList.get(cellIndex))); + } else { + cell.setCellStyle(numberCellStyleMap.get(patternList.get(cellIndex))); + } + cell.setCellType(CellType.NUMERIC); + double value = o == null ? 0 : ((BigDecimal) o).doubleValue(); + cell.setCellValue(value); + } else if (o instanceof Boolean) { + cell.setCellType(CellType.BOOLEAN); + cell.setCellValue(String.valueOf(o)); + } else if (o instanceof Date) { + cell.setCellType(CellType.STRING); + cell.setCellValue(SalaryDateUtil.getFormatLocalDate((Date) o)); + } else { + cell.setCellType(CellType.STRING); + cell.setCellValue(o == null ? "" : o.toString()); + } + + //判断是否要调整高度 + int width = sheet.getColumnWidth(cellIndex) / 256; + finalHeight = getFinalHeight(o, width, finalHeight, height); + } + row.setHeightInPoints(finalHeight); + } + return workbook; + } + + public static XSSFWorkbook genWorkbookWithChildTitleColumn(List> rowList, String sheetName, boolean lastRowRed) { + XSSFWorkbook workbook = new XSSFWorkbook(); + + // 设置title样式 + XSSFCellStyle titleCellStyle = workbook.createCellStyle(); + XSSFFont titleFont = workbook.createFont(); + titleFont.setBold(true); + titleFont.setFontName("仿宋"); + titleFont.setFontHeightInPoints((short) 15); + titleCellStyle.setFont(titleFont); + titleCellStyle.setAlignment(HorizontalAlignment.CENTER); + titleCellStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());//背景色 + titleCellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); + titleCellStyle.setVerticalAlignment(VerticalAlignment.CENTER); + titleCellStyle.setBorderLeft(BorderStyle.THIN); + titleCellStyle.setBorderRight(BorderStyle.THIN); + titleCellStyle.setBorderTop(BorderStyle.THIN); + titleCellStyle.setBorderBottom(BorderStyle.THIN); + + XSSFCellStyle childTitleCellStyle = workbook.createCellStyle(); + childTitleCellStyle.setFont(titleFont); + childTitleCellStyle.setAlignment(HorizontalAlignment.LEFT); + childTitleCellStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());//背景色 + childTitleCellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); + childTitleCellStyle.setVerticalAlignment(VerticalAlignment.CENTER); + childTitleCellStyle.setBorderLeft(BorderStyle.THIN); + childTitleCellStyle.setBorderRight(BorderStyle.THIN); + childTitleCellStyle.setBorderTop(BorderStyle.THIN); + childTitleCellStyle.setBorderBottom(BorderStyle.THIN); + + + // 设置主体样式 + XSSFCellStyle cellStyle = workbook.createCellStyle(); + XSSFFont font = workbook.createFont(); + font.setFontName("宋体"); + font.setFontHeightInPoints((short) 10);// 设置字体大小 + cellStyle.setFont(font);// 选择需要用到的字体格式 + cellStyle.setWrapText(true); + + cellStyle.setBorderLeft(BorderStyle.THIN); + cellStyle.setBorderRight(BorderStyle.THIN); + cellStyle.setBorderTop(BorderStyle.THIN); + cellStyle.setBorderBottom(BorderStyle.THIN); + cellStyle.setFillPattern(FillPatternType.NO_FILL); + + XSSFCellStyle redCellStyle = workbook.createCellStyle(); + XSSFFont redFont = workbook.createFont(); + redFont.setFontName("宋体"); + redFont.setFontHeightInPoints((short) 10);// 设置字体大小 + redFont.setColor(new XSSFColor(new Color(0xFF3333), null)); + redFont.setBold(true); + redCellStyle.setWrapText(true); + redCellStyle.setFont(redFont);// 选择需要用到的字体格式 + + redCellStyle.setBorderLeft(BorderStyle.THIN); + redCellStyle.setBorderRight(BorderStyle.THIN); + redCellStyle.setBorderTop(BorderStyle.THIN); + redCellStyle.setBorderBottom(BorderStyle.THIN); + + XSSFSheet sheet = workbook.createSheet(sheetName); + //自适应宽度 + sheet.autoSizeColumn(0, true); + //默认列宽 + sheet.setDefaultColumnWidth(20); + //默认行高 + sheet.setDefaultRowHeightInPoints(18); + + //处理合并单元格 + XSSFRow row0 = sheet.createRow(0); + XSSFRow row1 = sheet.createRow(1); + List header = rowList.get(0); + int startIndex = 0; + for (int i = 0; i < header.size(); i++) { + WeaTableColumnGroup columnGroupItem = (WeaTableColumnGroup) header.get(i); + if (columnGroupItem.getChildren() == null) { + sheet.addMergedRegion(new CellRangeAddress(0, 1, startIndex, startIndex)); + + XSSFCell rowZeroCell = row0.createCell(startIndex, CellType.STRING); + rowZeroCell.setCellValue(columnGroupItem.getText().toString()); + rowZeroCell.setCellStyle(titleCellStyle); + XSSFCell rowOneCell = row1.createCell(startIndex, CellType.STRING); + rowOneCell.setCellValue(columnGroupItem.getText().toString()); + rowOneCell.setCellStyle(titleCellStyle); + //设置列宽 + sheet.setColumnWidth(startIndex, Math.min(255, Math.max(12, columnGroupItem.getText().length() * 4)) * 256); + startIndex++; + } else { + List childrenList = columnGroupItem.getChildren(); + int endIndex = startIndex + childrenList.size() - 1; + + if (endIndex > startIndex) { + sheet.addMergedRegion(new CellRangeAddress(0, 0, startIndex, endIndex)); + } + + XSSFCell cell = row0.createCell(startIndex, CellType.STRING); + cell.setCellValue(columnGroupItem.getText().toString()); + cell.setCellStyle(childTitleCellStyle); + + for (int j = 0; j < childrenList.size(); j++) { + WeaTableColumnGroup childrenItem = (WeaTableColumnGroup) childrenList.get(j); + + XSSFCell subHeader = row1.createCell(startIndex + j, CellType.STRING); + subHeader.setCellValue(childrenItem.getText().toString()); + subHeader.setCellStyle(titleCellStyle); + //设置列宽 + sheet.setColumnWidth(startIndex + j, Math.min(255, Math.max(12, childrenItem.getText().length() * 4)) * 256); + } + + startIndex += childrenList.size(); + + } + + } + + for (int rowIndex = 1; rowIndex < rowList.size(); rowIndex++) { + List infoList = rowList.get(rowIndex); + XSSFRow row = sheet.createRow(rowIndex + 1); + float height = 18; + float finalHeight = 18; + + for (int cellIndex = 0; cellIndex < infoList.size(); cellIndex++) { + XSSFCell cell = row.createCell(cellIndex); + + if (rowIndex == 0) { + cell.setCellStyle(titleCellStyle); + } else { + if (lastRowRed && rowIndex == rowList.size() - 1) { + cell.setCellStyle(redCellStyle); + } else { + cell.setCellStyle(cellStyle); + } + } + Object o = infoList.get(cellIndex); + if (o instanceof String) { + cell.setCellType(CellType.STRING); + cell.setCellValue(String.valueOf(o)); + } else if (o instanceof BigDecimal) { + cell.setCellType(CellType.NUMERIC); + cell.setCellValue(o == null ? 0 : ((BigDecimal) o).doubleValue()); + } else if (o instanceof Boolean) { + cell.setCellType(CellType.BOOLEAN); + cell.setCellValue(String.valueOf(o)); + } else if (o instanceof Date) { + cell.setCellType(CellType.STRING); + cell.setCellValue(SalaryDateUtil.getFormatLocalDate((Date) o)); + } else { + cell.setCellType(CellType.STRING); + cell.setCellValue(o == null ? "" : o.toString()); + } + + //判断是否要调整高度 + int width = sheet.getColumnWidth(cellIndex) / 256; + finalHeight = getFinalHeight(o, width, finalHeight, height); + } + row.setHeightInPoints(finalHeight); + } + return workbook; + } + + public static float getFinalHeight(Object o, int width, float finalHeight, float height) { + if (o != null && getStrlength(o.toString()) > width) { + float remainder = getStrlength(o.toString()) % width; + int multiple = getStrlength(o.toString()) / width; + int finalMultiple = remainder > 0 ? (multiple + 1) : multiple; + float compareHeight = height * finalMultiple; + finalHeight = Math.max(finalHeight, compareHeight); + } + return finalHeight; + } + + public static int getStrlength(String str) { + int strLength = 0; + String chinese = "[\u0391-\uFFE5]"; + /* 获取字段值的长度,如果含中文字符,则每个中文字符长度为2,否则为1 */ + for (int i = 0; i < str.length(); i++) { + /* 从字符串中获取一个字符 */ + String temp = str.substring(i, i + 1); + /* 判断是否为中文字符 */ + if (temp.matches(chinese)) { + /* 中文字符长度为2 */ + strLength += 2; + } else { + /* 其他字符长度为1 */ + strLength += 1; + } + } + return strLength; + } + +} diff --git a/src/com/engine/salary/util/excel/ImportExcelResponse.java b/src/com/engine/salary/util/excel/ImportExcelResponse.java new file mode 100644 index 000000000..eac7409c7 --- /dev/null +++ b/src/com/engine/salary/util/excel/ImportExcelResponse.java @@ -0,0 +1,27 @@ +package com.engine.salary.util.excel; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class ImportExcelResponse { + private Integer totalCount; + private Integer successCount; + private Integer errorCount; + private List errorData; + + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + public static class Error { + String message; + } +} diff --git a/src/com/engine/salary/util/page/Column.java b/src/com/engine/salary/util/page/Column.java new file mode 100644 index 000000000..31c046a42 --- /dev/null +++ b/src/com/engine/salary/util/page/Column.java @@ -0,0 +1,23 @@ +package com.engine.salary.util.page; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class Column { + String title; + String dataIndex; + String key; + boolean display; + + public Column(String title, String dataIndex, String key) { + this.title = title; + this.dataIndex = dataIndex; + this.key = key; + } +} diff --git a/src/com/engine/salary/util/page/DataSource.java b/src/com/engine/salary/util/page/DataSource.java new file mode 100644 index 000000000..379b99023 --- /dev/null +++ b/src/com/engine/salary/util/page/DataSource.java @@ -0,0 +1,9 @@ +package com.engine.salary.util.page; + +import lombok.Data; + +@Data +public class DataSource { + String key; + String title; +} diff --git a/src/com/engine/salary/util/page/PageInfo.java b/src/com/engine/salary/util/page/PageInfo.java new file mode 100644 index 000000000..9547fb686 --- /dev/null +++ b/src/com/engine/salary/util/page/PageInfo.java @@ -0,0 +1,66 @@ +package com.engine.salary.util.page; + +import com.engine.salary.annotation.TableTitle; +import lombok.Data; +import lombok.ToString; + +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.List; + +@Data +@ToString +public class PageInfo extends com.engine.salary.component.PageInfo { + Class clazz; + + public void setColumns(List columns) { + this.columns.addAll(columns); + } + + public void clearAndSetColumns(List columns) { + this.columns.clear(); + this.columns.addAll(columns); + } + + List columns = new ArrayList<>(); + List dataSource = new ArrayList<>(); + + public PageInfo() { + } + + public PageInfo(Class clazz) { + this.clazz = clazz; + this.columns = buildColumns(); + } + + public PageInfo(List list) { + super(list); + } + + public PageInfo(List list, Class clazz) { + super(list); + this.clazz = clazz; + this.columns = buildColumns(); + } + + + public List buildColumns() { + if(clazz==null){ + return this.columns; + } + Field[] fields = clazz.getDeclaredFields(); + for (Field f : fields) { + boolean isanno = f.isAnnotationPresent(TableTitle.class); + if (isanno) { + TableTitle annotation = f.getAnnotation(TableTitle.class); + String title = annotation.title(); + String dataIndex = annotation.dataIndex(); + String key = annotation.key(); + boolean display = annotation.display(); + Column column = Column.builder().title(title).dataIndex(dataIndex).key(key).display(display).build(); + columns.add(column); + } + } + return columns; + } +} diff --git a/src/com/engine/salary/util/page/SalaryPageUtil.java b/src/com/engine/salary/util/page/SalaryPageUtil.java new file mode 100644 index 000000000..bf118b462 --- /dev/null +++ b/src/com/engine/salary/util/page/SalaryPageUtil.java @@ -0,0 +1,109 @@ +package com.engine.salary.util.page; + +import org.apache.commons.collections4.CollectionUtils; + +import java.awt.*; +import java.awt.font.FontRenderContext; +import java.awt.geom.Rectangle2D; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + + +public class SalaryPageUtil { + + public static PageInfo buildPage(Integer pageNo, Integer pageSize) { + pageNo = pageNo == null || pageNo <= 0 ? 1 : pageNo; + pageSize = pageSize == null || pageSize <= 0 ? 10 : pageSize; + PageInfo pageInfo = new PageInfo<>(); + pageInfo.setPageNum(pageNo); + pageInfo.setPageSize(pageSize); + pageInfo.setList(new ArrayList<>()); + return pageInfo; + } + + public static PageInfo buildPage(Integer pageNo, Integer pageSize, Class clazz) { + pageNo = pageNo == null || pageNo <= 0 ? 1 : pageNo; + pageSize = pageSize == null || pageSize <= 0 ? 10 : pageSize; + PageInfo pageInfo = new PageInfo<>(clazz); + pageInfo.setPageNum(pageNo); + pageInfo.setPageSize(pageSize); + pageInfo.setList(new ArrayList<>()); + return pageInfo; + } + + public static PageInfo buildPage(Integer pageNo, Integer pageSize, List totalCollection) { + PageInfo pageInfo = new PageInfo<>(); + pageInfo.setTotal(totalCollection.size()); + totalCollection = subList(pageNo, pageSize, totalCollection); + pageInfo.setPageNum(pageNo); + pageInfo.setPageSize(pageSize); + pageInfo.setList(totalCollection); + return pageInfo; + } + + /** + * 内存分页 + * + * @param pageNo + * @param pageSize + * @param source + * @param clazz + * @param + * @return + */ + public static PageInfo buildPage(Integer pageNo, Integer pageSize, List source, Class clazz) { + pageNo = pageNo == null || pageNo <= 0 ? 1 : pageNo; + pageSize = pageSize == null || pageSize <= 0 ? 10 : pageSize; + PageInfo pageInfo = new PageInfo<>(clazz); + pageInfo.setPageNum(pageNo); + pageInfo.setPageSize(pageSize); + pageInfo.setTotal(source == null ? 0 : source.size()); + pageInfo.setList(subList(pageNo, pageSize, source)); + return pageInfo; + } + + + /** + * 分页 + * + * @param pageNo 页码(从1开始) + * @param pageSize 每页条数 + * @param source 待分页的数据 + * @param 范型制定类 + * @return + */ + public static List subList(Integer pageNo, Integer pageSize, List source) { + if (CollectionUtils.isEmpty(source)) { + return Collections.emptyList(); + } + pageNo = pageNo == null || pageNo <= 0 ? 1 : pageNo; + pageSize = pageSize == null || pageSize <= 0 ? 10 : pageSize; + int endIndex = pageNo * pageSize; + int startIndex = (pageNo - 1) * pageSize; + startIndex = startIndex < 0 ? 0 : startIndex; + return source.subList(startIndex > source.size() ? source.size() : startIndex, + endIndex > source.size() ? source.size() : endIndex); + } + + + static Font font = new Font("Arial", Font.PLAIN, 12); // 设置字体样式、大小等属性 + static FontRenderContext frc = new FontRenderContext(null, true, false); +// GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); + + /** + * 自适应文字长度 + * + * @param chars + * @param width + * @return + */ + public static String selfAdaption(String chars, Integer width) { + if (width != null && width != 0) { + return width + ""; + } + Rectangle2D bounds = font.getStringBounds(chars, frc); + int pxLength = (int) Math.ceil(bounds.getWidth()) + 55; + return pxLength < 90 ? 90+"" : pxLength+""; + } +} diff --git a/src/com/engine/salary/util/pdf/HtmlToPdf.java b/src/com/engine/salary/util/pdf/HtmlToPdf.java new file mode 100644 index 000000000..c0a52c5b7 --- /dev/null +++ b/src/com/engine/salary/util/pdf/HtmlToPdf.java @@ -0,0 +1,78 @@ +package com.engine.salary.util.pdf; + +import com.engine.workflow.biz.requestForm.HtmlToPdfInterceptor; +import lombok.extern.slf4j.Slf4j; + +import java.io.BufferedInputStream; +import java.io.BufferedReader; +import java.io.File; +import java.io.InputStreamReader; + +@Slf4j +public class HtmlToPdf { + + /** + * html转pdf + * + * @param toPdfTool 工具路径 + * @param srcPath html路径,可以是硬盘上的路径,也可以是网络路径 + * @param destPath pdf保存路径 + * @return 转换成功返回true + */ + public static boolean convert(String toPdfTool, String srcPath, String destPath) { + File file = new File(destPath); + File parent = file.getParentFile(); + //如果pdf保存路径不存在,则创建路径 + if (!parent.exists()) { + parent.mkdirs(); + } + StringBuilder cmd = new StringBuilder(); + cmd.append(toPdfTool); + cmd.append(" "); + cmd.append(" --header-line");//页眉下面的线 + cmd.append(" --margin-top 3cm ");//设置页面上边距 (default 10mm) + // cmd.append(" --header-html file:///"+WebUtil.getServletContext().getRealPath("")+FileUtil.convertSystemFilePath("\\style\\pdf\\head.html"));// (添加一个HTML页眉,后面是网址) + cmd.append(" --header-spacing 5 --orientation Portrait ");// (设置页眉和内容的距离,默认0) + //cmd.append(" --footer-center (设置在中心位置的页脚内容)");//设置在中心位置的页脚内容 + //cmd.append(" --footer-html file:///"+WebUtil.getServletContext().getRealPath("")+FileUtil.convertSystemFilePath("\\style\\pdf\\foter.html"));// (添加一个HTML页脚,后面是网址) + cmd.append(" --footer-line");//* 显示一条线在页脚内容上) + cmd.append(" --footer-spacing 5 ");// (设置页脚和内容的距离) + //--orientation Portrait --footer-center [page]/[topage] --footer-line + cmd.append(srcPath); + cmd.append(" "); + cmd.append(destPath); + boolean result = true; + try { + Process proc = Runtime.getRuntime().exec(cmd.toString()); + HtmlToPdfInterceptor error = new HtmlToPdfInterceptor(proc.getErrorStream()); + HtmlToPdfInterceptor output = new HtmlToPdfInterceptor(proc.getInputStream()); + error.start(); + output.start(); + + BufferedInputStream err = new BufferedInputStream(proc.getErrorStream()); + BufferedReader errBr = new BufferedReader(new InputStreamReader(err)); + String lineStr = ""; + while ((lineStr = errBr.readLine()) != null) { + //检查命令是否执行失败。 + log.info("pdf转换执行中! {}", lineStr); + } + if (proc.waitFor() != 0) { + //p.exitValue()==0表示正常结束,1:非正常结束 + if (proc.exitValue() == 1) { + log.error("pdf转换命令执行失败!"); + } + } + } catch (InterruptedException e) { + log.error("pdf转换出错!", e); + e.printStackTrace(); + result = false; + } catch (Exception e) { + log.error("pdf转换出错!", e); + result = false; + e.printStackTrace(); + } + + return result; + } + +} diff --git a/src/com/engine/salary/util/report/SalaryReportUtil.java b/src/com/engine/salary/util/report/SalaryReportUtil.java new file mode 100644 index 000000000..400c554e3 --- /dev/null +++ b/src/com/engine/salary/util/report/SalaryReportUtil.java @@ -0,0 +1,34 @@ +package com.engine.salary.util.report; + +import com.engine.salary.encrypt.AESEncryptUtil; + +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +public class SalaryReportUtil { + + /** + * 薪酬解密方法 + * + * @param s 待解密字符串集合 + * @return 解密字符集合 + */ + public static List decrypt(List s) { + if (s != null) { + return s.stream().map(AESEncryptUtil::decrypt).collect(Collectors.toList()); + } + return new ArrayList<>(); + } + + /** + * 薪酬解密方法 + * + * @param s 待解密字符串 + * @return 解密字符 + */ + public static String decrypt(String s) { + return AESEncryptUtil.decrypt(s); + } + +} diff --git a/src/com/engine/salary/util/valid/Compare.java b/src/com/engine/salary/util/valid/Compare.java new file mode 100644 index 000000000..35ff51b40 --- /dev/null +++ b/src/com/engine/salary/util/valid/Compare.java @@ -0,0 +1,40 @@ +package com.engine.salary.util.valid; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * 比较,判断两个实体字段是否改变 + *

Copyright: Copyright (c) 2024

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Target(ElementType.FIELD) +@Retention(RetentionPolicy.RUNTIME) +public @interface Compare { + + /** + * 是否提示错误 + * + * @return + */ + boolean reportError() default false; + + /** + * 提示信息 + * @return + */ + String message() default ""; + + /** + * 值类型 + * + * @return + */ + ValueTypeEnum type() default ValueTypeEnum.STRING; + +} diff --git a/src/com/engine/salary/util/valid/DataCheck.java b/src/com/engine/salary/util/valid/DataCheck.java new file mode 100644 index 000000000..886763ae2 --- /dev/null +++ b/src/com/engine/salary/util/valid/DataCheck.java @@ -0,0 +1,60 @@ +package com.engine.salary.util.valid; + +import java.lang.annotation.*; + +/** + * 数据参数合法性注解 + */ +@Target(ElementType.FIELD) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface DataCheck { + + /** + * 运行期(区分同一个参数在各个时期是否校验。例如id在更新接口里必填,保存接口不需要) + * + * @return + */ + RuntimeTypeEnum[] runtime() default RuntimeTypeEnum.AUTO; + + /** + * 是否必填 + * + * @return + */ + boolean require() default false; + + /** + * 参数类型 + * + * @return + */ + ValidTypeEnum type() default ValidTypeEnum.STRING; + + /** + * 日期格式(校验String格式的字符是否为日期格式) + * + * @return + */ + String pattern() default "yyyy-MM-dd"; + + /** + * 最大(String字段验证文本长度,int字段验证大小) + * + * @return + */ + int max() default -1; + + /** + * 最小(String字段验证文本长度,int字段验证大小) + * + * @return + */ + int min() default -1; + + //错误信息 + int labelId() default -1; + + String message(); + +} \ No newline at end of file diff --git a/src/com/engine/salary/util/valid/Modify.java b/src/com/engine/salary/util/valid/Modify.java new file mode 100644 index 000000000..bf61ec974 --- /dev/null +++ b/src/com/engine/salary/util/valid/Modify.java @@ -0,0 +1,15 @@ +package com.engine.salary.util.valid; + +import java.lang.annotation.*; + +/** + * 数据参数合法性注解 + */ +@Target(ElementType.FIELD) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface Modify { + ModifyTypeEnum[] modifyType() default ModifyTypeEnum.TRIM; + + ValueTypeEnum valueType() default ValueTypeEnum.STRING; +} \ No newline at end of file diff --git a/src/com/engine/salary/util/valid/ModifyTypeEnum.java b/src/com/engine/salary/util/valid/ModifyTypeEnum.java new file mode 100644 index 000000000..e40ea143d --- /dev/null +++ b/src/com/engine/salary/util/valid/ModifyTypeEnum.java @@ -0,0 +1,13 @@ +package com.engine.salary.util.valid; + +/** + * 修改参数值 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public enum ModifyTypeEnum { + TRIM, RESTORE_SQL +} diff --git a/src/com/engine/salary/util/valid/RuntimeTypeEnum.java b/src/com/engine/salary/util/valid/RuntimeTypeEnum.java new file mode 100644 index 000000000..1a8135438 --- /dev/null +++ b/src/com/engine/salary/util/valid/RuntimeTypeEnum.java @@ -0,0 +1,5 @@ +package com.engine.salary.util.valid; + +public enum RuntimeTypeEnum { + QUERY, SAVE, UPDATE, DELETE, AUTO; +} diff --git a/src/com/engine/salary/util/valid/ValidTypeEnum.java b/src/com/engine/salary/util/valid/ValidTypeEnum.java new file mode 100644 index 000000000..ab3b8452c --- /dev/null +++ b/src/com/engine/salary/util/valid/ValidTypeEnum.java @@ -0,0 +1,13 @@ +package com.engine.salary.util.valid; + +/** + * 可验证的字段枚举 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public enum ValidTypeEnum { + STRING, DATE, NUMBER +} diff --git a/src/com/engine/salary/util/valid/ValidUtil.java b/src/com/engine/salary/util/valid/ValidUtil.java new file mode 100644 index 000000000..906718077 --- /dev/null +++ b/src/com/engine/salary/util/valid/ValidUtil.java @@ -0,0 +1,308 @@ +package com.engine.salary.util.valid; + +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.StrUtil; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.util.SalaryI18nUtil; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import weaver.general.Util; + +import java.beans.BeanInfo; +import java.beans.Introspector; +import java.beans.PropertyDescriptor; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * 参数校验 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Slf4j +public class ValidUtil { + + /** + * 通过反射来获取javaBean上的注解信息,判断属性值信息,然后通过注解元数据 + * 来返回 + * + * @param t + */ + public static void doValidator(T t, RuntimeTypeEnum... runtime) { + Class clazz = t.getClass(); + Field[] fields = clazz.getDeclaredFields(); + for (Field field : fields) { + DataCheck rule = field.getDeclaredAnnotation(DataCheck.class); + + if (null == rule) { + continue; + } + + boolean needValid = false; + RuntimeTypeEnum[] runtimeTypeEnums = rule.runtime(); + if (Arrays.stream(runtimeTypeEnums).anyMatch(r -> r == RuntimeTypeEnum.AUTO)) { + needValid = true; + } else { + //传了运行类型,校验字段上运行类型和传入的是否有交集 + needValid = hasSameEM(runtimeTypeEnums, runtime); + } + + if (!needValid) { + continue; + } + + //字段值 + Object value = getValue(t, field.getName()); + ValidTypeEnum type = rule.type(); + int labelId = rule.labelId(); + String message = rule.message(); + boolean require = rule.require(); + int max = rule.max(); + int min = rule.min(); + String pattern = rule.pattern(); + + if (require) { + if (!notNull(value)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(labelId, message)); + } + } + + if (ValidTypeEnum.STRING == type) { + //区间值 + if (value != null && max != -1) { + String s = String.valueOf(value); + if (s.length() > max) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(labelId, message)); + } + } + + if (value != null && min != -1) { + String s = String.valueOf(value); + if (s.length() < min) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(labelId, message)); + } + } + } + + if (ValidTypeEnum.DATE == type) { + if (value != null && StringUtils.isNotBlank(value.toString()) && isValidDate(value.toString(), pattern)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(labelId, message)); + } + } + + + if (ValidTypeEnum.NUMBER == type) { + if (value instanceof Integer) { + int v = (Integer) value; + if (max != -1) { + if (v > max) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(labelId, message)); + } + } + if (min != -1) { + if (v < min) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(labelId, message)); + } + } + } + + } + + + } + } + + private static boolean hasSameEM(RuntimeTypeEnum[] runtimeTypeEnums, RuntimeTypeEnum[] runtime) { + boolean needValid = false; + HashSet set = new HashSet<>(Arrays.asList(runtimeTypeEnums)); + set.retainAll(Arrays.asList(runtime)); + if (set.size() > 0) { + needValid = true; + } + return needValid; + } + + private static Object getValue(T t, String fieldName) { + Object value = null; + try { + BeanInfo beanInfo = Introspector.getBeanInfo(t.getClass()); + PropertyDescriptor[] props = beanInfo.getPropertyDescriptors(); + for (PropertyDescriptor property : props) { + if (fieldName.equals(property.getName())) { + Method method = property.getReadMethod(); + value = method.invoke(t, new Object[]{}); + } + } + } catch (Exception e) { + e.printStackTrace(); + log.error("获取属性值失败", e); + } + return value; + } + + private static void setValue(T t, String fieldName, Object value) { + try { + BeanInfo beanInfo = Introspector.getBeanInfo(t.getClass()); + PropertyDescriptor[] props = beanInfo.getPropertyDescriptors(); + for (PropertyDescriptor property : props) { + if (fieldName.equals(property.getName())) { + Method method = property.getWriteMethod(); + method.invoke(t, value); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + private static boolean notNull(Object value) { + if (null == value) { + return false; + } + if (value instanceof String && isEmpty((String) value)) { + return false; + } + if (value instanceof List && isEmpty((Collection) value)) { + return false; + } + return true; + } + + private static boolean isEmpty(String str) { + return null == str || str.isEmpty(); + } + + private static boolean isEmpty(Collection list) { + return null == list || list.isEmpty(); + } + + + /** + * 校验日期 + */ + private static boolean isValidDate(String str, String pattern) { + boolean convertSuccess = true; + if (str != null && str.length() == pattern.length()) { + // 指定日期格式为四位年/两位月份/两位日期,注意yyyy/MM/dd区分大小写; + SimpleDateFormat format = new SimpleDateFormat(pattern); + try { + // 设置lenient为false. + // 否则SimpleDateFormat会比较宽松地验证日期,比如2007/02/29会被接受,并转换成2007/03/01 + format.setLenient(false); + Date dateStr = format.parse(str); + } catch (Exception e) { + // 如果throw java.text.ParseException或者NullPointerException,就说明格式不对 + convertSuccess = false; + } + } else { + convertSuccess = false; + } + return convertSuccess; + } + + /** + * 处理参数值,trim,xss + * + * @param t + * @param + */ + public static void modify(T t) { + Class clazz = t.getClass(); + Field[] fields = clazz.getDeclaredFields(); + for (Field field : fields) { + Modify rule = field.getDeclaredAnnotation(Modify.class); + + if (null == rule) { + continue; + } + + ModifyTypeEnum[] modifyTypeEnums = rule.modifyType(); + ValueTypeEnum valueTypeEnum = rule.valueType(); + for (int i = 0; i < modifyTypeEnums.length; i++) { + Object value = getValue(t, field.getName()); + if (valueTypeEnum == ValueTypeEnum.STRING) { + String result = value.toString(); + + if (modifyTypeEnums[i] == ModifyTypeEnum.TRIM) { + result = result.trim(); + } + + if (modifyTypeEnums[i] == ModifyTypeEnum.RESTORE_SQL) { + result = result.replace("select", "select") + .replace("SELECT", "SELECT") + .replace("join", "join") + .replace("JOIN", "JOIN") + .replace("and", "and") + .replace("AND", "AND") + .replace("or", "or") + .replace("OR", "OR") + .replace("in", "in") + .replace("IN", "IN") + .replace("like", "like") + .replace("LIKE", "LIKE") + .replace("exists", "exists") + .replace("EXISTS", "EXISTS") + .replace("between", "between") + .replace("BETWEEN", "BETWEEN") + .replace("union", "union") + .replace("UNION", "UNION"); + } + setValue(t, field.getName(), result); + } else if (valueTypeEnum == ValueTypeEnum.OBJECT) { + modify(value); + } else if (valueTypeEnum == ValueTypeEnum.ARRAY) { + Collection list = (Collection) value; + list.forEach(l -> modify(l)); + } + } + } + } + + /** + * 比较两个对象,如果值不相等,则抛出异常 + *

+ * true代表相等,false代表不相等 + * + * @param o + * @param n + * @param + */ + public static boolean compare(T o, T n) { + Class clazz = o.getClass(); + Field[] fields = clazz.getDeclaredFields(); + boolean result = true; + for (Field field : fields) { + Compare rule = field.getDeclaredAnnotation(Compare.class); + if (null == rule) { + continue; + } + boolean reportError = rule.reportError(); + String message = rule.message(); + + ValueTypeEnum valueTypeEnum = rule.type(); + Object oValue = getValue(o, field.getName()); + Object nValue = getValue(n, field.getName()); + if (valueTypeEnum == ValueTypeEnum.STRING) { + result = result && StrUtil.equals(Util.null2String(oValue), Util.null2String(nValue)); + if (!result && reportError) { + throw new RuntimeException(message); + } + } else if (valueTypeEnum == ValueTypeEnum.DATE) { + result = result && DateUtil.compare((Date) o, (Date) n) == 0; + if (!result && reportError) { + throw new RuntimeException(message); + } + } else if (valueTypeEnum == ValueTypeEnum.OBJECT) { + result = result && compare(oValue, nValue); + } + } + return result; + } + + +} diff --git a/src/com/engine/salary/util/valid/ValueTypeEnum.java b/src/com/engine/salary/util/valid/ValueTypeEnum.java new file mode 100644 index 000000000..12bd9fc2d --- /dev/null +++ b/src/com/engine/salary/util/valid/ValueTypeEnum.java @@ -0,0 +1,13 @@ +package com.engine.salary.util.valid; + +/** + * 值类型 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public enum ValueTypeEnum { + STRING, DATE, OBJECT, ARRAY +} diff --git a/src/com/engine/salary/util/xml/XStreamUtil.java b/src/com/engine/salary/util/xml/XStreamUtil.java new file mode 100644 index 000000000..d0a30e215 --- /dev/null +++ b/src/com/engine/salary/util/xml/XStreamUtil.java @@ -0,0 +1,68 @@ +package com.engine.salary.util.xml; + +import cn.hutool.core.util.StrUtil; +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.io.HierarchicalStreamDriver; +import com.thoughtworks.xstream.io.naming.NoNameCoder; +import com.thoughtworks.xstream.io.xml.DomDriver; +import com.thoughtworks.xstream.security.AnyTypePermission; + +import java.util.Objects; + +public class XStreamUtil { + //new NoNameCoder() 解决 _ 被序列化成 __ 的问题 + private static final NoNameCoder noNameCoder = new NoNameCoder(); + + private static XStream xStream = new XStream(new DomDriver("UTF-8", noNameCoder)); + + private static XStream getxStream(HierarchicalStreamDriver driver){ + if(Objects.isNull(driver)){ + return xStream; + } + return new XStream(driver); + } + + public static T unmarshal(String pkgName, Class cla, String xmlStr, HierarchicalStreamDriver driver) { + xStream = getxStream(driver); + + if (StrUtil.isEmpty(pkgName)) { + //高版本为了解决安全漏洞,增加了白名单机制, 如果不设置这个权限可能会报错 + xStream.addPermission(AnyTypePermission.ANY); + } else { + //设置允许解析的包,如果不想设置可以用 addPermission(AnyTypePermission.ANY) 代替 + xStream.allowTypesByWildcard(new String[]{pkgName}); + } + + //支持注解,不然使用的XStream注解不会生效且不报错 + xStream.autodetectAnnotations(true); + xStream.processAnnotations(cla); + + //忽略未知属性, 如果不添加这个,当Xml报文中出现实体中没有的属性时会报错 No such field + xStream.ignoreUnknownElements(); + + return (T) xStream.fromXML(xmlStr); + } + + public static T unmarshal(String pkgName, Class cla, String xmlStr) { + return unmarshal(pkgName, cla, xmlStr, null); + } + + public static T unmarshal(Class cla, String xmlStr) { + return unmarshal(null, cla, xmlStr, null); + } + + public static String marshal(Object o, DomDriver driver) { + xStream = getxStream(driver); + + //支持注解,不然使用的 @XStreamAlias() 注解不会生效而且不会报错 + xStream.autodetectAnnotations(true); + + //注册自定义时间转换器,使得XStream全局支持LocalDateTime, 或者不在这里注册,使用@XStreamConverter(LocalDateTimeConverter.class)注解在单一字段上 +// xStream.registerConverter(new LocalDateTimeConverter()); + return xStream.toXML(o); + } + + public static String marshal(Object o){ + return marshal(o, null); + } +} diff --git a/src/com/engine/salary/web/AddUpDeductionController.java b/src/com/engine/salary/web/AddUpDeductionController.java new file mode 100644 index 000000000..74d934add --- /dev/null +++ b/src/com/engine/salary/web/AddUpDeductionController.java @@ -0,0 +1,382 @@ +package com.engine.salary.web; + +import cn.hutool.core.date.DateTime; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.StrUtil; +import com.engine.common.util.ParamUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.salary.entity.datacollection.dto.AddUpDeductionDTO; +import com.engine.salary.entity.datacollection.dto.AddUpDeductionRecordDTO; +import com.engine.salary.entity.datacollection.param.*; +import com.engine.salary.util.ResponseResult; +import com.engine.salary.util.SalaryDateUtil; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.wrapper.AddUpDeductionWrapper; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.jetbrains.annotations.Nullable; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.StreamingOutput; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.time.LocalDate; +import java.util.Arrays; +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * 累计专项附加扣除 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Slf4j +public class AddUpDeductionController { + + private AddUpDeductionWrapper getAddUpDeductionWrapper(User user) { + return ServiceUtil.getService(AddUpDeductionWrapper.class, user); + } + + /** + * 数据采集-累计专项附加扣除列表的高级搜索 + * + * @return + */ + @GET + @Path("/getSearchCondition") + @Produces(MediaType.APPLICATION_JSON) + public String getSearchCondition(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult, Map>(user).run(getAddUpDeductionWrapper(user)::getSearchCondition, ParamUtil.request2Map(request)); + } + + + @POST + @Path("/list") + @Produces(MediaType.APPLICATION_JSON) + public String list(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody AddUpDeductionQueryParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getAddUpDeductionWrapper(user)::list, queryParam); + } + + + @GET + @Path("/downloadTemplate") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response getAll(@Context HttpServletRequest request, @Context HttpServletResponse response) { + try { + User user = HrmUserVarify.getUser(request, response); + AddUpDeductionQueryParam queryParam = buildParam(request); + XSSFWorkbook workbook = getAddUpDeductionWrapper(user).downloadTemplate(queryParam); + String fileName = "累计专项附加扣除导入模板" + LocalDate.now(); + try { + fileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + + StreamingOutput output = outputStream -> { + workbook.write(outputStream); + outputStream.flush(); + }; + response.setContentType("application/octet-stream"); + return Response.ok(output).header("Content-disposition", "attachment;filename=" + fileName).header("Cache-Control", "no-cache").build(); + } catch (Exception e) { + log.error("累计专项附加扣除导入模板异常", e); + throw e; + } + + } + + + /** + * 导出 + * + * @param + * @return + */ + @GET + @Path("/export") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response export(@Context HttpServletRequest request, @Context HttpServletResponse response) { + try { + User user = HrmUserVarify.getUser(request, response); + + AddUpDeductionQueryParam param = buildParam(request); + + XSSFWorkbook workbook = getAddUpDeductionWrapper(user).export(param); + + String fileName = "累计专项附加扣除" + LocalDate.now(); + try { + fileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + + StreamingOutput output = outputStream -> { + workbook.write(outputStream); + outputStream.flush(); + }; + + response.setContentType("application/octet-stream"); + return Response.ok(output) + .header("Content-disposition", "attachment;filename=" + fileName) + .header("Cache-Control", "no-cache").build(); + } catch (Exception e) { + log.error("累计专项附加扣除导出异常", e); + throw e; + } + + } + + + @GET + @Path("/exportDetail") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response exportDetail(@Context HttpServletRequest request, @Context HttpServletResponse response) { + try { + User user = HrmUserVarify.getUser(request, response); + + AddUpDeductionQueryParam param = buildParam(request); + + XSSFWorkbook workbook = getAddUpDeductionWrapper(user).exportDetail(param); + + String fileName = "累计专项附加扣除明细" + LocalDate.now(); + try { + fileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + + StreamingOutput output = outputStream -> { + workbook.write(outputStream); + outputStream.flush(); + }; + + response.setContentType("application/octet-stream"); + return Response.ok(output) + .header("Content-disposition", "attachment;filename=" + fileName) + .header("Cache-Control", "no-cache").build(); + } catch (Exception e) { + log.error("累计专项附加扣除明细导出异常", e); + throw e; + } + + + } + + @Nullable + private AddUpDeductionQueryParam buildParam(HttpServletRequest request) { + AddUpDeductionQueryParam param = new AddUpDeductionQueryParam(); + String ids = request.getParameter("ids"); + if (StringUtils.isNotBlank(ids)) { + param.setIds(Arrays.stream(ids.split(",")).map(Long::valueOf).collect(Collectors.toList())); + } + String keyword = request.getParameter("keyword"); + if (StringUtils.isNotBlank(keyword)) { + param.setKeyword(keyword); + } + String id = request.getParameter("id"); + if (StringUtils.isNotBlank(id)) { + param.setId(Long.valueOf(id)); + } + + String declareMonth = request.getParameter("declareMonth"); + if (StringUtils.isNotBlank(declareMonth)) { + param.setDeclareMonth(Arrays.stream(declareMonth.split(",")).map(e -> e + "-01 00:00:00").collect(Collectors.toList())); + param.setDeclareMonthDate(Arrays.stream(declareMonth.split(",")).map(e -> e + "-01 00:00:00").map(SalaryDateUtil::dateStrToLocalTime).collect(Collectors.toList())); + } + + String username = request.getParameter("username"); + if (StringUtils.isNotBlank(username)) { + param.setUsername(username); + } + String employeeId = request.getParameter("employeeId"); + if (StringUtils.isNotBlank(employeeId)) { + param.setEmployeeId(Long.valueOf(employeeId)); + } + String taxAgentId = request.getParameter("taxAgentId"); + if (StringUtils.isNotBlank(taxAgentId)) { + param.setTaxAgentId(Long.valueOf(taxAgentId)); + } + String departmentIds = request.getParameter("departmentIds"); + if (StringUtils.isNotBlank(departmentIds)) { + param.setDepartmentIds(Arrays.stream(departmentIds.split(",")).map(Long::valueOf).collect(Collectors.toList())); + } + String jobNum = request.getParameter("jobNum"); + if (StringUtils.isNotBlank(jobNum)) { + param.setJobNum(jobNum); + } + String idNo = request.getParameter("idNo"); + if (StringUtils.isNotBlank(idNo)) { + param.setIdNo(idNo); + } + String hiredate = request.getParameter("hiredate"); + if (StringUtils.isNotBlank(hiredate)) { + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + List dates = Arrays.stream(hiredate.split(",")).map(d -> { + try { + return format.parse(d); + } catch (ParseException e) { + e.printStackTrace(); + } + return null; + }).collect(Collectors.toList()); + param.setHiredate(dates); + } + String mobile = request.getParameter("mobile"); + if (StringUtils.isNotBlank(mobile)) { + param.setMobile(mobile); + } + String accumulatedSpecialAdditionalDeductionId = request.getParameter("accumulatedSpecialAdditionalDeductionId"); + if (StringUtils.isNotBlank(accumulatedSpecialAdditionalDeductionId)) { + param.setAccumulatedSpecialAdditionalDeductionId(Long.valueOf(accumulatedSpecialAdditionalDeductionId)); + } + String hasData = request.getParameter("hasData"); + if (StringUtils.isNotBlank(hasData)) { + param.setHasData("true".equals(hasData)); + } + return param; + } + + @POST + @Path("/preview") + @Produces(MediaType.APPLICATION_JSON) + public String preview(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody AddUpDeductionImportParam importParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getAddUpDeductionWrapper(user)::preview, importParam); + } + + @POST + @Path("/importAddUpDeduction") + @Produces(MediaType.APPLICATION_JSON) + public String importAddUpDeduction(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody AddUpDeductionImportParam importParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getAddUpDeductionWrapper(user)::importAddUpDeduction, importParam); + } + + /** + * @description 新建累计专项附加扣除 + * @return String + * @author Harryxzy + * @date 2022/10/26 14:23 + */ + @POST + @Path("/createAddUpDeduction") + @Produces(MediaType.APPLICATION_JSON) + public String createAddUpDeduction(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody AddUpDeductionRecordParam addUpDeduction) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getAddUpDeductionWrapper(user)::createAddUpDeduction, addUpDeduction); + } + + /** + * @description 获取累计专项附加扣除信息 + * @return String + * @author Harryxzy + * @date 2022/10/31 11:23 + */ + @POST + @Path("/getAddUpDeduction") + @Produces(MediaType.APPLICATION_JSON) + public String getAddUpDeduction(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody AddUpDeductionQueryParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getAddUpDeductionWrapper(user)::getAddUpDeduction, param); + } + + + /** + * @description 编辑累计专项附加扣除 + * @return String + * @author Harryxzy + * @date 2022/10/25 14:08 + */ + @POST + @Path("/editAddUpDeduction") + @Produces(MediaType.APPLICATION_JSON) + public String editAddUpDeduction(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody AddUpDeductionRecordParam addUpDeduction) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getAddUpDeductionWrapper(user)::editAddUpDeduction, addUpDeduction); + } + + /** + * @description 累计专项附加扣除-删除所选 + * @return String + * @author Harryxzy + * @date 2022/10/27 14:08 + */ + @POST + @Path("/deleteSelectAddUpDeduction") + @Produces(MediaType.APPLICATION_JSON) + public String deleteSelectAddUpDeduction(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody AddUpDeductionRecordDeleteParam deleteParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getAddUpDeductionWrapper(user)::deleteSelectAddUpDeduction, deleteParam); + } + + /** + * @description 累计专项附加扣除-一键清空 + * @return String + * @author Harryxzy + * @date 2022/10/27 14:08 + */ + @POST + @Path("/deleteAllAddUpDeduction") + @Produces(MediaType.APPLICATION_JSON) + public String deleteAllAddUpDeduction(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody AddUpDeductionRecordDeleteParam deleteParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getAddUpDeductionWrapper(user)::deleteAllAddUpDeduction, deleteParam); + } + + + @POST + @Path("/getDetailList") + @Produces(MediaType.APPLICATION_JSON) + public String getDetailList(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody AddUpDeductionQueryParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getAddUpDeductionWrapper(user)::getDetailList, queryParam); + } + + + /** + * 一键自动累计 + * @return + */ + @POST + @Path("/autoAddAll") + @Produces(MediaType.APPLICATION_JSON) + public String autoAddAll(@Context HttpServletRequest request, @Context HttpServletResponse response, + @RequestBody AddDeductionAutoAddParam param) { + DateTime date = null; + if (StrUtil.isNotEmpty(param.getYearMonth())) { + try { + date = DateUtil.parse(param.getYearMonth(), "yyyy-MM"); + } catch (Exception e) { + //ignore + // 放在service中处理,这里处理了页面上收不到 + } + } else { + date = DateUtil.beginOfMonth(new Date()); + } + param.setYearMonthDate(date); + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getAddUpDeductionWrapper(user)::autoAddAll, param); + } +} diff --git a/src/com/engine/salary/web/AddUpSituationController.java b/src/com/engine/salary/web/AddUpSituationController.java new file mode 100644 index 000000000..c10443a88 --- /dev/null +++ b/src/com/engine/salary/web/AddUpSituationController.java @@ -0,0 +1,361 @@ +package com.engine.salary.web; + +import com.engine.common.util.ParamUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.salary.entity.datacollection.dto.AddUpSituationDTO; +import com.engine.salary.entity.datacollection.dto.AddUpSituationRecordDTO; +import com.engine.salary.entity.datacollection.param.*; +import com.engine.salary.util.ResponseResult; +import com.engine.salary.util.SalaryDateUtil; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.wrapper.AddUpSituationWrapper; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.jetbrains.annotations.Nullable; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.StreamingOutput; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.time.LocalDate; +import java.util.Arrays; +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * 往期累计 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Slf4j +public class AddUpSituationController { + private AddUpSituationWrapper getAddUpSituationWrapper(User user) { + return ServiceUtil.getService(AddUpSituationWrapper.class, user); + } + + @GET + @Path("/getSearchCondition") + @Produces(MediaType.APPLICATION_JSON) + public String getSearchCondition(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult, Map>(user).run(getAddUpSituationWrapper(user)::getSearchCondition); + } + + + @POST + @Path("/list") + @Produces(MediaType.APPLICATION_JSON) + public String list(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody AddUpSituationQueryParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getAddUpSituationWrapper(user)::list, queryParam); + } + + @POST + @Path("/getDetailList") + @Produces(MediaType.APPLICATION_JSON) + public String getDetailList(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody AddUpSituationQueryParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getAddUpSituationWrapper(user)::getDetailList, queryParam); + } + + + @GET + @Path("/downloadTemplate") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response getAll(@Context HttpServletRequest request, @Context HttpServletResponse response) { + try { + User user = HrmUserVarify.getUser(request, response); + + AddUpSituationQueryParam queryParam = buildParam(request); + + XSSFWorkbook workbook = getAddUpSituationWrapper(user).downloadTemplate(queryParam); + + String fileName = "往期累计情况导入模板" + LocalDate.now(); + + try { + fileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8"); + } catch (UnsupportedEncodingException e) { + log.error(e.getMessage(), e); + } + + StreamingOutput output = outputStream -> { + workbook.write(outputStream); + outputStream.flush(); + }; + response.setContentType("application/octet-stream"); + return Response.ok(output).header("Content-disposition", "attachment;filename=" + fileName).header("Cache-Control", "no-cache").build(); + + } catch (Exception e) { + log.error("往期累计情况导入模板导出异常", e); + throw e; + } + } + + + /** + * 导出 + * + * @param + * @return + */ + @GET + @Path("/export") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response export(@Context HttpServletRequest request, @Context HttpServletResponse response) { + try { + User user = HrmUserVarify.getUser(request, response); + + AddUpSituationQueryParam queryParam = buildParam(request); + + XSSFWorkbook workbook = getAddUpSituationWrapper(user).export(queryParam); + + String fileName = "往期累计情况" + LocalDate.now(); + try { + fileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + + StreamingOutput output = outputStream -> { + workbook.write(outputStream); + outputStream.flush(); + }; + + response.setContentType("application/octet-stream"); + return Response.ok(output) + .header("Content-disposition", "attachment;filename=" + fileName) + .header("Cache-Control", "no-cache").build(); + } catch (Exception e) { + log.error("往期累计情况导出异常", e); + throw e; + } + } + + + /** + * 导出明细 + * + * @param + * @return + */ + @GET + @Path("/exportDetail") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response exportDetail(@Context HttpServletRequest request, @Context HttpServletResponse response) { + try { + User user = HrmUserVarify.getUser(request, response); + + AddUpSituationQueryParam queryParam = buildParam(request); + + XSSFWorkbook workbook = getAddUpSituationWrapper(user).exportDetail(queryParam); + + String fileName = "累计情况明细" + LocalDate.now(); + try { + fileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + + StreamingOutput output = outputStream -> { + workbook.write(outputStream); + outputStream.flush(); + }; + + response.setContentType("application/octet-stream"); + return Response.ok(output) + .header("Content-disposition", "attachment;filename=" + fileName) + .header("Cache-Control", "no-cache").build(); + } catch (Exception e) { + log.error("累计情况明细导出异常", e); + throw e; + } + } + + @Nullable + private AddUpSituationQueryParam buildParam(HttpServletRequest request) { + AddUpSituationQueryParam param = new AddUpSituationQueryParam(); + String ids = request.getParameter("ids"); + if (StringUtils.isNotBlank(ids)) { + param.setIds(Arrays.stream(ids.split(",")).map(Long::valueOf).collect(Collectors.toList())); + } + String keyword = request.getParameter("keyword"); + if (StringUtils.isNotBlank(keyword)) { + param.setKeyword(keyword); + } + String id = request.getParameter("id"); + if (StringUtils.isNotBlank(id)) { + param.setId(Long.valueOf(id)); + } + String year = request.getParameter("year"); + if (StringUtils.isNotBlank(year)) { + param.setYear(Integer.valueOf(year)); + } + + String taxYearMonth = request.getParameter("taxYearMonth"); + if (StringUtils.isNotBlank(taxYearMonth)) { + param.setTaxYearMonth(Arrays.asList(taxYearMonth.split(","))); + param.setTaxYearMonthDate(Arrays.stream(taxYearMonth.split(",")).map(e -> e + "-01 00:00:00").map(SalaryDateUtil::dateStrToLocalTime).collect(Collectors.toList())); + } + + String username = request.getParameter("username"); + if (StringUtils.isNotBlank(username)) { + param.setUsername(username); + } + String employeeId = request.getParameter("employeeId"); + if (StringUtils.isNotBlank(employeeId)) { + param.setEmployeeId(Long.valueOf(employeeId)); + } + String taxAgentId = request.getParameter("taxAgentId"); + if (StringUtils.isNotBlank(taxAgentId)) { + param.setTaxAgentId(Long.valueOf(taxAgentId)); + } + String departmentIds = request.getParameter("departmentIds"); + if (StringUtils.isNotBlank(departmentIds)) { + param.setDepartmentIds(Arrays.stream(departmentIds.split(",")).map(Long::valueOf).collect(Collectors.toList())); + } + String jobNum = request.getParameter("jobNum"); + if (StringUtils.isNotBlank(jobNum)) { + param.setJobNum(jobNum); + } + String idNo = request.getParameter("idNo"); + if (StringUtils.isNotBlank(idNo)) { + param.setIdNo(idNo); + } + String hiredate = request.getParameter("hiredate"); + if (StringUtils.isNotBlank(hiredate)) { + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + List dates = Arrays.stream(hiredate.split(",")).map(d -> { + try { + return format.parse(d); + } catch (ParseException e) { + e.printStackTrace(); + } + return null; + }).collect(Collectors.toList()); + param.setHiredate(dates); + } + String mobile = request.getParameter("mobile"); + if (StringUtils.isNotBlank(mobile)) { + param.setMobile(mobile); + } + String accumulatedSituationId = request.getParameter("accumulatedSituationId"); + if (StringUtils.isNotBlank(accumulatedSituationId)) { + param.setAccumulatedSituationId(Long.valueOf(accumulatedSituationId)); + } + String hasData = request.getParameter("hasData"); + if (StringUtils.isNotBlank(hasData)) { + param.setHasData("true".equals(hasData)); + } + return param; + } + + //导入 + @POST + @Path("/importAddUpSituation") + @Produces(MediaType.APPLICATION_JSON) + public String importAddUpSituation(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody AddUpSituationImportParam importParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getAddUpSituationWrapper(user)::importAddUpSituation, importParam); + } + + /** + * @description 编辑数据 + * @return String + * @author Harryxzy + * @date 2022/10/27 21:10 + */ + @POST + @Path("/editAddUpSituation") + @Produces(MediaType.APPLICATION_JSON) + public String editAddUpSituation(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody AddUpSituationParam addUpSituation) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getAddUpSituationWrapper(user)::editAddUpSituation, addUpSituation); + } + + /** + * @description 获取往期累计情况 + * @return String + * @author Harryxzy + * @date 2022/10/31 13:59 + */ + @POST + @Path("/getAddUpSituation") + @Produces(MediaType.APPLICATION_JSON) + public String getAddUpSituation(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody AddUpSituationParam addUpSituation) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getAddUpSituationWrapper(user)::getAddUpSituation, addUpSituation); + } + + /** + * @description 新建数据 + * @return String + * @author Harryxzy + * @date 2022/10/27 21:10 + */ + @POST + @Path("/createAddUpSituation") + @Produces(MediaType.APPLICATION_JSON) + public String createAddUpSituation(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody AddUpSituationParam addUpSituation) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getAddUpSituationWrapper(user)::createAddUpSituation, addUpSituation); + } + + /** + * @description 删除所选数据 + * @return String + * @author Harryxzy + * @date 2022/10/27 21:10 + */ + @POST + @Path("/deleteSelectAddUpSituation") + @Produces(MediaType.APPLICATION_JSON) + public String deleteSelectAddUpSituation(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody AddUpSituationDeleteParam addUpSituationDeleteParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getAddUpSituationWrapper(user)::deleteSelectAddUpSituation, addUpSituationDeleteParam); + } + + /** + * @description 一键清空 + * @return String + * @author Harryxzy + * @date 2022/10/27 21:10 + */ + @POST + @Path("/deleteAllAddUpSituation") + @Produces(MediaType.APPLICATION_JSON) + public String deleteAllAddUpSituation(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody AddUpSituationDeleteParam addUpSituationDeleteParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getAddUpSituationWrapper(user)::deleteAllAddUpSituation, addUpSituationDeleteParam); + } + + @POST + @Path("/preview") + @Produces(MediaType.APPLICATION_JSON) + public String preview(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody AddUpSituationImportParam importParam) { + User user = HrmUserVarify.getUser(request, response); + Map map = ParamUtil.request2Map(request); + map.put("importParam", importParam); + return new ResponseResult>(user).run(getAddUpSituationWrapper(user)::preview, importParam); + } + + +} diff --git a/src/com/engine/salary/web/AttendQuoteController.java b/src/com/engine/salary/web/AttendQuoteController.java new file mode 100644 index 000000000..5e0f1464c --- /dev/null +++ b/src/com/engine/salary/web/AttendQuoteController.java @@ -0,0 +1,444 @@ +package com.engine.salary.web; + +import com.engine.common.util.ParamUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.salary.entity.datacollection.dto.AttendQuoteFieldFormDTO; +import com.engine.salary.entity.datacollection.dto.AttendQuoteFieldSettingListDTO; +import com.engine.salary.entity.datacollection.dto.AttendQuoteListDTO; +import com.engine.salary.entity.datacollection.param.*; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.util.ResponseResult; +import com.engine.salary.util.SalaryDateUtil; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.wrapper.AttendQuoteDataWrapper; +import com.engine.salary.wrapper.AttendQuoteFieldSettingWrapper; +import com.engine.salary.wrapper.AttendQuoteFieldWrapper; +import com.engine.salary.wrapper.AttendQuoteWrapper; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.StreamingOutput; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.time.LocalDate; +import java.time.YearMonth; +import java.util.Collection; +import java.util.List; +import java.util.Map; + +@Slf4j +public class AttendQuoteController { + + private AttendQuoteWrapper getAttendQuoteWrapper(User user) { + return ServiceUtil.getService(AttendQuoteWrapper.class, user); + } + + private AttendQuoteDataWrapper getAttendQuoteDataWrapper(User user) { + return ServiceUtil.getService(AttendQuoteDataWrapper.class, user); + } + + private AttendQuoteFieldWrapper getAttendQuoteFieldWrapper(User user) { + return ServiceUtil.getService(AttendQuoteFieldWrapper.class, user); + } + + private AttendQuoteFieldSettingWrapper getAttendQuoteFieldSettingWrapper(User user) { + return ServiceUtil.getService(AttendQuoteFieldSettingWrapper.class, user); + } + + /** + * 考勤数据列表 + */ + @POST + @Path("/list") + @Produces(MediaType.APPLICATION_JSON) + public String list(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody AttendQuoteQueryParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getAttendQuoteWrapper(user)::list, queryParam); + } + + +// @GET +// @Path("/getSyncForm") +// @Produces(MediaType.APPLICATION_JSON) +// public String getSyncForm(@Context HttpServletRequest request, @Context HttpServletResponse response) { +// User user = HrmUserVarify.getUser(request, response); +// return new ResponseResult>(user).run(getService(user)::getSyncForm, (long)user.getUID()); +// } + + + /** + * 检查是否可以操作 + * 说明:已经核算过的不能再操作 + * + * @param checkOperationParam + * @return + */ + @POST + @Path("/checkOperation") + @Produces(MediaType.APPLICATION_JSON) + public String checkOperation(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody AttendQuoteCheckOperationParam checkOperationParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getAttendQuoteWrapper(user)::checkOperation, checkOperationParam); + } + + /** + * 获取薪资周期和考勤周期 + * + * @return + */ + @GET + @Path("/getSalaryCycleAndAttendCycle") + @Produces(MediaType.APPLICATION_JSON) + public String getSalaryCycleAndAttendCycle(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "salaryYearMonthStr") String salaryYearMonthStr, @QueryParam(value = "salarySobId") Long salarySobId) { + User user = HrmUserVarify.getUser(request, response); + + QuerySalaryCycleAndAttendCycleParam param = QuerySalaryCycleAndAttendCycleParam.builder().salarySobId(salarySobId).salaryYearMonth(SalaryDateUtil.String2YearMonth(salaryYearMonthStr)).build(); + return new ResponseResult>(user).run(getAttendQuoteWrapper(user)::getSalaryCycleAndAttendCycle, param); + } + + + /** + * 同步引用考勤数据 + * + * @return + */ + @POST + @Path("/syncAttendQuoteData") + @Produces(MediaType.APPLICATION_JSON) + public String syncAttendQuoteData(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody AttendQuoteDataSyncParam syncParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getAttendQuoteDataWrapper(user)::syncAttendQuoteData, syncParam); + } + + + /** + * 下载导入模板 + */ + @GET + @Path("/downloadTemplate") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response downloadTemplate(@Context HttpServletRequest request, @Context HttpServletResponse response) { + try { + User user = HrmUserVarify.getUser(request, response); + String salaryYearMonth = request.getParameter("salaryYearMonth"); + String salarySobId = request.getParameter("salarySobId"); + AttendQuoteDataExportTemplateParam param = AttendQuoteDataExportTemplateParam.builder() + .salarySobId(Long.valueOf(salarySobId)) + .salaryYearMonth(YearMonth.parse(salaryYearMonth)) + .build(); + if (param.getSalaryYearMonth() == null || param.getSalarySobId() == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100250, "薪资所属月和薪资账套id不能为空")); + } + XSSFWorkbook workbook = getAttendQuoteDataWrapper(user).downloadTemplate(param); + String fileName = "考勤引用导入模板" + LocalDate.now(); + try { + fileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + + StreamingOutput output = outputStream -> { + workbook.write(outputStream); + outputStream.flush(); + }; + + response.setContentType("application/octet-stream"); + return Response.ok(output) + .header("Content-disposition", "attachment;filename=" + fileName) + .header("Cache-Control", "no-cache").build(); + } catch (Exception e) { + log.error("考勤引用导入模板导出异常", e); + throw e; + } + + } + + /** + * 预览 + * + * @param queryParam + * @return + */ + @POST + @Path("/preview") + @Produces(MediaType.APPLICATION_JSON) + public String preview(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody AttendQuoteDataImportParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getAttendQuoteDataWrapper(user)::preview, queryParam); + } + + + /** + * 导入考勤数据 + * + * @param queryParam + * @return + */ + @POST + @Path("/importAttendQuoteData") + @Produces(MediaType.APPLICATION_JSON) + public String importAttendQuoteData(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody AttendQuoteDataImportParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getAttendQuoteDataWrapper(user)::importAttendQuoteData, queryParam); + } + + + /** + * 查看考勤数据 + * + * @param queryParam + * @return + */ + @POST + @Path("/view") + @Produces(MediaType.APPLICATION_JSON) + public String view(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody AttendQuoteDataQueryParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getAttendQuoteDataWrapper(user)::view, queryParam); + } + + + @POST + @Path("/getData") + @Produces(MediaType.APPLICATION_JSON) + public String getData(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody AttendQuoteDataEditParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getAttendQuoteDataWrapper(user)::getData, queryParam); + } + + /** + * 编辑考勤数据 + * + * @param queryParam + * @return + */ + @POST + @Path("/editData") + @Produces(MediaType.APPLICATION_JSON) + public String editData(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody AttendQuoteDataEditParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getAttendQuoteDataWrapper(user)::editData, queryParam); + } + + @GET + @Path("/selectSalarySobList") + @Produces(MediaType.APPLICATION_JSON) + public String selectSalarySobList(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>>(user).run(getAttendQuoteWrapper(user)::selectSalarySobList); + } + + + /** + * 删除考勤数据 + * + * @param ids + * @return + */ + @POST + @Path("/delete") + @Produces(MediaType.APPLICATION_JSON) + public String delete(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Collection ids) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult, String>(user).run(getAttendQuoteWrapper(user)::delete, ids); + } + + /** + * 导出考勤数据 + * + * @return + */ + @GET + @Path("/export") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response export(@Context HttpServletRequest request, @Context HttpServletResponse response) { + try { + User user = HrmUserVarify.getUser(request, response); + String attendQuoteId = request.getParameter("attendQuoteId"); + AttendQuoteDataQueryParam param = AttendQuoteDataQueryParam.builder().attendQuoteId(Long.valueOf(attendQuoteId)).build(); + XSSFWorkbook workbook = getAttendQuoteDataWrapper(user).export(param); + String fileName = "考勤导出" + LocalDate.now(); + try { + fileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + + StreamingOutput output = outputStream -> { + workbook.write(outputStream); + outputStream.flush(); + }; + + response.setContentType("application/octet-stream"); + return Response.ok(output) + .header("Content-disposition", "attachment;filename=" + fileName) + .header("Cache-Control", "no-cache").build(); + } catch (Exception e) { + log.error("考勤导出异常", e); + throw e; + } + + + } + + + /** + * 考勤字段管理列表 + * + * @param queryParam + * @return + */ + @POST + @Path("/fieldList") + @Produces(MediaType.APPLICATION_JSON) + public String fieldList(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody AttendQuoteFieldQueryParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + Map map = ParamUtil.request2Map(request); + map.put("queryParam", queryParam); + return new ResponseResult>(user).run(getAttendQuoteFieldWrapper(user)::list, queryParam); + } + + /** + * 同步考勤模块字段 + * + * @return + */ + @POST + @Path("/syncAttendFields") + @Produces(MediaType.APPLICATION_JSON) + public String syncAttendFields(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getAttendQuoteFieldWrapper(user)::syncAttendFields); + } + + /** + * 获取考勤字段表单 + * + * @return + */ + @GET + @Path("/getFieldForm") + @Produces(MediaType.APPLICATION_JSON) + public String getFieldForm(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + String idStr = request.getParameter("id"); + Long id = null; + if (StringUtils.isNotBlank(idStr)) { + id = Long.parseLong(request.getParameter("id")); + } + return new ResponseResult(user).run(getAttendQuoteFieldWrapper(user)::getFrom, id); + } + + + /** + * 新建考勤字段 + */ + @POST + @Path("/saveField") + @Produces(MediaType.APPLICATION_JSON) + public String saveField(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody AttendQuoteFieldSaveParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getAttendQuoteFieldWrapper(user)::save, param); + } + + + + /** + * 修改考勤字段 + */ + @POST + @Path("/updateField") + @Produces(MediaType.APPLICATION_JSON) + public String updateField(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody AttendQuoteFieldSaveParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getAttendQuoteFieldWrapper(user)::update, param); + } + + + /** + * 删除考勤字段 + * + * @param ids + * @return + */ + @POST + @Path("/deleteField") + @Produces(MediaType.APPLICATION_JSON) + public String deleteField(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Collection ids) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult, String>(user).run(getAttendQuoteFieldWrapper(user)::delete, ids); + } + + + /** + * 启用/停用自定义字段 + */ + @POST + @Path("/updateEnableStatus") + @Produces(MediaType.APPLICATION_JSON) + public String updateEnableStatus(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody AttendQuoteFieldSaveParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getAttendQuoteFieldWrapper(user)::updateEnableStatus, param); + } + + + /** + * 数据采集-考勤引用字段设置列表 + */ + @POST + @Path("/fieldSetting/list") + @Produces(MediaType.APPLICATION_JSON) + public String fieldSettingList(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody AttendQuoteFieldSettingQueryParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getAttendQuoteFieldSettingWrapper(user)::list, param); + } + + /** + * 数据采集-考勤引用字段设置保存 + * + * @return + */ + @POST + @Path("/fieldSetting/save") + @Produces(MediaType.APPLICATION_JSON) + public String fieldSettingSave(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody AttendQuoteFieldSettingSaveParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getAttendQuoteFieldSettingWrapper(user)::save, param); + } + + /** + * 数据采集-考勤引用字段设置-恢复默认设置 + */ + @POST + @Path("/fieldSetting/recoverAsDefault") + @Produces(MediaType.APPLICATION_JSON) + public String fieldSettingRecoverAsDefault(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody AttendQuoteFieldSettingRecoverParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getAttendQuoteFieldSettingWrapper(user)::recoverAsDefault, param); + } + + /** + * 数据采集-考勤引用字段设置-设为默认设置 + * + * @return + */ + @POST + @Path("/fieldSetting/saveAsDefault") + @Produces(MediaType.APPLICATION_JSON) + public String fieldSettingSaveAsDefault(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody AttendQuoteFieldSettingSaveParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getAttendQuoteFieldSettingWrapper(user)::saveAsDefault, param); + } + +} diff --git a/src/com/engine/salary/web/AuthController.java b/src/com/engine/salary/web/AuthController.java new file mode 100644 index 000000000..c16e5ab52 --- /dev/null +++ b/src/com/engine/salary/web/AuthController.java @@ -0,0 +1,218 @@ +package com.engine.salary.web; + +import com.engine.common.util.ServiceUtil; +import com.engine.salary.entity.auth.dto.*; +import com.engine.salary.entity.auth.param.*; +import com.engine.salary.entity.auth.vo.Permission; +import com.engine.salary.util.ResponseResult; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.wrapper.AuthWrapper; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import lombok.extern.slf4j.Slf4j; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import java.util.List; + +/** + * 权限 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Slf4j +public class AuthController { + + private AuthWrapper getAuthWrapper(User user) { + return ServiceUtil.getService(AuthWrapper.class, user); + } + + @POST + @Path("/role/list") + @Produces(MediaType.APPLICATION_JSON) + public String roleList(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody AuthRoleListQueryParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getAuthWrapper(user)::roleList, param); + } + + @GET + @Path("/role/getRole") + @Produces(MediaType.APPLICATION_JSON) + public String getRole(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody @QueryParam(value = "id") Long id) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getAuthWrapper(user)::getRole, id); + } + + @POST + @Path("/role/save") + @Produces(MediaType.APPLICATION_JSON) + public String saveRole(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody AuthRoleSaveParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getAuthWrapper(user)::saveRole, param); + } + + @POST + @Path("/role/delete") + @Produces(MediaType.APPLICATION_JSON) + public String deleteRole(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody List ids) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult, Long>(user).run(getAuthWrapper(user)::deleteRole, ids); + } + + @POST + @Path("/member/list") + @Produces(MediaType.APPLICATION_JSON) + public String memberList(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody AuthMemberQueryParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getAuthWrapper(user)::memberList, param); + } + + @POST + @Path("/member/detail") + @Produces(MediaType.APPLICATION_JSON) + public String memberDetail(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody AuthMemberQueryParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getAuthWrapper(user)::memberDetail, param); + } + + @POST + @Path("/member/save") + @Produces(MediaType.APPLICATION_JSON) + public String saveMember(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody List param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult, Long>(user).run(getAuthWrapper(user)::saveMember, param); + } + + @POST + @Path("/member/delete") + @Produces(MediaType.APPLICATION_JSON) + public String deleteMember(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody List ids) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult, Long>(user).run(getAuthWrapper(user)::deleteMember, ids); + } + + @POST + @Path("/member/sync") + @Produces(MediaType.APPLICATION_JSON) + public String syncMember(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody AuthSyncParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getAuthWrapper(user)::syncMember, param); + } + + + @GET + @Path("/opt/tree") + @Produces(MediaType.APPLICATION_JSON) + public String optTree(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "roleId") Long roleId) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getAuthWrapper(user)::optTree, roleId); + } + + @POST + @Path("/opt/save") + @Produces(MediaType.APPLICATION_JSON) + public String saveOpt(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody AuthOptSaveParam opt) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getAuthWrapper(user)::saveOpt, opt); + } + + @POST + @Path("/data/list") + @Produces(MediaType.APPLICATION_JSON) + public String dataList(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody AuthDataQueryParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getAuthWrapper(user)::dataList, param); + } + + @POST + @Path("/data/detail") + @Produces(MediaType.APPLICATION_JSON) + public String dataDetail(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody AuthDataQueryParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getAuthWrapper(user)::dataDetail, param); + } + + @POST + @Path("/data/save") + @Produces(MediaType.APPLICATION_JSON) + public String saveData(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody List params) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult, Long>(user).run(getAuthWrapper(user)::saveData, params); + } + + @POST + @Path("/data/delete") + @Produces(MediaType.APPLICATION_JSON) + public String deleteData(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody List ids) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult, Long>(user).run(getAuthWrapper(user)::deleteData, ids); + } + + @POST + @Path("/data/sync") + @Produces(MediaType.APPLICATION_JSON) + public String syncData(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody AuthSyncParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getAuthWrapper(user)::syncData, param); + } + + @GET + @Path("/data/auth") + @Produces(MediaType.APPLICATION_JSON) + public String auth(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "page") String page) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getAuthWrapper(user)::auth, page); + } + + + /** + * 权限信息 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/permission") + @Produces(MediaType.APPLICATION_JSON) + public String permission(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "page") String page) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getAuthWrapper(user)::permission, page); + } + + + /** + * 查询 + * + * @param request + * @param response + * @return + */ + @POST + @Path("/tree") + @Produces(MediaType.APPLICATION_JSON) + public String tree(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody AuthTreeQueryParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getAuthWrapper(user)::tree,param); + } + + + /** + * 同步 + */ + @POST + @Path("/sync") + @Produces(MediaType.APPLICATION_JSON) + public String sync(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getAuthWrapper(user)::sync); + } + +} diff --git a/src/com/engine/salary/web/ExtEmpController.java b/src/com/engine/salary/web/ExtEmpController.java new file mode 100644 index 000000000..3ee37f187 --- /dev/null +++ b/src/com/engine/salary/web/ExtEmpController.java @@ -0,0 +1,133 @@ +package com.engine.salary.web; + +import com.engine.common.util.ServiceUtil; +import com.engine.salary.entity.extemp.dto.ExtEmpDTO; +import com.engine.salary.entity.extemp.param.ExtEmpImportParam; +import com.engine.salary.entity.extemp.param.ExtEmpQueryParam; +import com.engine.salary.entity.extemp.param.ExtEmpSaveParam; +import com.engine.salary.entity.extemp.po.ExtEmpPO; +import com.engine.salary.util.ResponseResult; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.wrapper.ExtEmpWrapper; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import lombok.extern.slf4j.Slf4j; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.StreamingOutput; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.time.LocalDate; +import java.util.Collection; +import java.util.Map; + +/** + * 外部人员 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Slf4j +public class ExtEmpController { + + private ExtEmpWrapper getExtEmpWrapper(User user) { + return ServiceUtil.getService(ExtEmpWrapper.class, user); + } + + @POST + @Path("/listPage") + @Produces(MediaType.APPLICATION_JSON) + public String list(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody ExtEmpQueryParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getExtEmpWrapper(user)::listPage, param); + } + + @POST + @Path("/save") + @Produces(MediaType.APPLICATION_JSON) + public String save(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody ExtEmpSaveParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getExtEmpWrapper(user)::save, param); + } + + @POST + @Path("/update") + @Produces(MediaType.APPLICATION_JSON) + public String update(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody ExtEmpSaveParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getExtEmpWrapper(user)::update, param); + } + + @POST + @Path("/delete") + @Produces(MediaType.APPLICATION_JSON) + public String delete(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Collection ids) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult, String>(user).run(getExtEmpWrapper(user)::delete, ids); + } + + @GET + @Path("/detail") + @Produces(MediaType.APPLICATION_JSON) + public String save(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "id") Long id) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getExtEmpWrapper(user)::detail, id); + } + + // **********************************非系统人员导入 start*********************************/ + //导出导入模板 + @GET + @Path("/importtemplate/export") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response exportImportTemplate(@Context HttpServletRequest request, @Context HttpServletResponse response) { + try { + User user = HrmUserVarify.getUser(request, response); + XSSFWorkbook workbook = getExtEmpWrapper(user).exportImportTemplate(); + String time = LocalDate.now().toString(); + String fileName = SalaryI18nUtil.getI18nLabel(0, "非系统人员导入模板") + time; + try { + fileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8").replaceAll("\\+", "%20"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + StreamingOutput output = outputStream -> { + workbook.write(outputStream); + outputStream.flush(); + }; + response.setContentType("application/octet-stream"); + return Response.ok(output).header("Content-disposition", "attachment;filename=" + fileName).header("Cache-Control", "no-cache").build(); + } catch (Exception e) { + log.error("非系统人员导入模板导出异常", e); + throw e; + } + + } + + //导入非系统人员 + @POST + @Path("/importExtEmp") + @Produces(MediaType.APPLICATION_JSON) + public String importExtEmp(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody ExtEmpImportParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getExtEmpWrapper(user)::importExtEmp, param); + } + + @POST + @Path("/preview") + @Produces(MediaType.APPLICATION_JSON) + public String previewImportExtEmp(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody ExtEmpImportParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getExtEmpWrapper(user)::previewImportExtEmp, param); + } + // **********************************非系统人员导入 end*********************************/ +} diff --git a/src/com/engine/salary/web/MySalaryShowSetController.java b/src/com/engine/salary/web/MySalaryShowSetController.java new file mode 100644 index 000000000..538d951ae --- /dev/null +++ b/src/com/engine/salary/web/MySalaryShowSetController.java @@ -0,0 +1,45 @@ +package com.engine.salary.web; + +import com.engine.common.util.ServiceUtil; +import com.engine.salary.entity.salaryBill.dto.MySalaryShowSetDTO; +import com.engine.salary.util.ResponseResult; +import com.engine.salary.wrapper.MySalaryShowSetWrapper; +import lombok.extern.slf4j.Slf4j; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; + +/** + * @Description: 我的薪资福利显示设置 + * @Author: wangxiangzhong + * @Date: 2021-12-08 14:44 + */ +@Slf4j +public class MySalaryShowSetController { + + private MySalaryShowSetWrapper getMySalaryShowSetWrapper(User user) { + return ServiceUtil.getService(MySalaryShowSetWrapper.class, user); + } + + /** + * 我的薪资福利页签显隐控制 + * + * @return + */ + @GET + @Path("/get") + @Produces(MediaType.APPLICATION_JSON) + public String mySalaryShowSet(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getMySalaryShowSetWrapper(user)::mySalaryShowSet); + } + + /******** 工资单 end ***********************************************************************************************/ +} diff --git a/src/com/engine/salary/web/OtherDeductionController.java b/src/com/engine/salary/web/OtherDeductionController.java new file mode 100644 index 000000000..251507f68 --- /dev/null +++ b/src/com/engine/salary/web/OtherDeductionController.java @@ -0,0 +1,359 @@ +package com.engine.salary.web; + +import com.engine.common.util.ServiceUtil; +import com.engine.salary.entity.datacollection.dto.OtherDeductionListDTO; +import com.engine.salary.entity.datacollection.dto.OtherDeductionRecordDTO; +import com.engine.salary.entity.datacollection.param.*; +import com.engine.salary.util.ResponseResult; +import com.engine.salary.util.SalaryDateUtil; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.wrapper.OtherDeductionWrapper; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.jetbrains.annotations.Nullable; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.StreamingOutput; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.time.LocalDate; +import java.util.Arrays; +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * 数据采集-其他免税扣除 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Slf4j +public class OtherDeductionController { + + private OtherDeductionWrapper getOtherDeductionWrapper(User user) { + return ServiceUtil.getService(OtherDeductionWrapper.class, user); + } + + /** + * 数据采集-累计专项附加扣除列表的高级搜索 + * + * @return + */ + @GET + @Path("/getSearchCondition") + @Produces(MediaType.APPLICATION_JSON) + public String getSearchCondition(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult, Map>(user).run(getOtherDeductionWrapper(user)::getSearchCondition); + } + + + @POST + @Path("/list") + @Produces(MediaType.APPLICATION_JSON) + public String list(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody OtherDeductionQueryParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getOtherDeductionWrapper(user)::list, queryParam); + } + + + @POST + @Path("/getDetailList") + @Produces(MediaType.APPLICATION_JSON) + public String getDetailList(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody OtherDeductionQueryParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getOtherDeductionWrapper(user)::getDetailList, queryParam); + } + + + @GET + @Path("/downloadTemplate") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response getAll(@Context HttpServletRequest request, @Context HttpServletResponse response) { + try { + User user = HrmUserVarify.getUser(request, response); + OtherDeductionQueryParam param = buildParam(request); + + XSSFWorkbook workbook = getOtherDeductionWrapper(user).downloadTemplate(param); + String fileName = "其他免税扣除导入模板" + LocalDate.now(); + try { + fileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + + StreamingOutput output = outputStream -> { + workbook.write(outputStream); + outputStream.flush(); + }; + response.setContentType("application/octet-stream"); + return Response.ok(output).header("Content-disposition", "attachment;filename=" + fileName).header("Cache-Control", "no-cache").build(); + + } catch (Exception e) { + log.error("其他免税扣除导入模板异常", e); + throw e; + } + } + + + /** + * 导出 + * + * @param + * @return + */ + @GET + @Path("/export") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response export(@Context HttpServletRequest request, @Context HttpServletResponse response) { + try { + User user = HrmUserVarify.getUser(request, response); + + OtherDeductionQueryParam param = buildParam(request); + + XSSFWorkbook workbook = getOtherDeductionWrapper(user).export(param); + + String fileName = null; + try { + fileName = URLEncoder.encode("其他免税扣除" + LocalDate.now() + ".xlsx", "UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + + StreamingOutput output = outputStream -> { + workbook.write(outputStream); + outputStream.flush(); + }; + + response.setContentType("application/octet-stream"); + return Response.ok(output) + .header("Content-disposition", "attachment;filename=" + fileName) + .header("Cache-Control", "no-cache").build(); + } catch (Exception e) { + log.error("其他免税扣除导出异常", e); + throw e; + } + } + + + @GET + @Path("/exportDetail") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response exportDetail(@Context HttpServletRequest request, @Context HttpServletResponse response) { + try { + User user = HrmUserVarify.getUser(request, response); + + OtherDeductionQueryParam param = buildParam(request); + + XSSFWorkbook workbook = getOtherDeductionWrapper(user).exportDetail(param); + + String fileName = "其他免税扣除明细" + LocalDate.now(); + try { + fileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + + StreamingOutput output = outputStream -> { + workbook.write(outputStream); + outputStream.flush(); + }; + + response.setContentType("application/octet-stream"); + return Response.ok(output) + .header("Content-disposition", "attachment;filename=" + fileName) + .header("Cache-Control", "no-cache").build(); + } catch (Exception e) { + log.error("其他免税扣除明细导出异常", e); + throw e; + } + + } + + @Nullable + private OtherDeductionQueryParam buildParam(HttpServletRequest request) { + OtherDeductionQueryParam param = new OtherDeductionQueryParam(); + String ids = request.getParameter("ids"); + if (StringUtils.isNotBlank(ids)) { + param.setIds(Arrays.stream(ids.split(",")).map(Long::valueOf).collect(Collectors.toList())); + } + String keyword = request.getParameter("keyword"); + if (StringUtils.isNotBlank(keyword)) { + param.setKeyword(keyword); + } + String id = request.getParameter("id"); + if (StringUtils.isNotBlank(id)) { + param.setId(Long.valueOf(id)); + } + String declareMonth = request.getParameter("declareMonth"); + if (StringUtils.isNotBlank(declareMonth)) { + param.setDeclareMonth(Arrays.stream(declareMonth.split(",")).map(e -> e + "-01 00:00:00").collect(Collectors.toList())); + param.setDeclareMonthDate(Arrays.stream(declareMonth.split(",")).map(e -> e + "-01 00:00:00").map(SalaryDateUtil::dateStrToLocalTime).collect(Collectors.toList())); + } + + String username = request.getParameter("username"); + if (StringUtils.isNotBlank(username)) { + param.setUsername(username); + } + String employeeId = request.getParameter("employeeId"); + if (StringUtils.isNotBlank(employeeId)) { + param.setEmployeeId(Long.valueOf(employeeId)); + } + String taxAgentId = request.getParameter("taxAgentId"); + if (StringUtils.isNotBlank(taxAgentId)) { + param.setTaxAgentId(Long.valueOf(taxAgentId)); + } + String departmentIds = request.getParameter("departmentIds"); + if (StringUtils.isNotBlank(departmentIds)) { + param.setDepartmentIds(Arrays.stream(departmentIds.split(",")).map(Long::valueOf).collect(Collectors.toList())); + } + String jobNum = request.getParameter("jobNum"); + if (StringUtils.isNotBlank(jobNum)) { + param.setJobNum(jobNum); + } + String idNo = request.getParameter("idNo"); + if (StringUtils.isNotBlank(idNo)) { + param.setIdNo(idNo); + } + String hiredate = request.getParameter("hiredate"); + if (StringUtils.isNotBlank(hiredate)) { + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + List dates = Arrays.stream(hiredate.split(",")).map(d -> { + try { + return format.parse(d); + } catch (ParseException e) { + e.printStackTrace(); + } + return null; + }).collect(Collectors.toList()); + param.setHiredate(dates); + } + String mobile = request.getParameter("mobile"); + if (StringUtils.isNotBlank(mobile)) { + param.setMobile(mobile); + } + String otherTaxExemptDeductionId = request.getParameter("otherTaxExemptDeductionId"); + if (StringUtils.isNotBlank(otherTaxExemptDeductionId)) { + param.setOtherTaxExemptDeductionId(Long.valueOf(otherTaxExemptDeductionId)); + } + + String hasData = request.getParameter("hasData"); + if (StringUtils.isNotBlank(hasData)) { + param.setHasData("true".equals(hasData)); + } + return param; + } + + @POST + @Path("/preview") + @Produces(MediaType.APPLICATION_JSON) + public String preview(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody OtherDeductionImportParam importParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getOtherDeductionWrapper(user)::preview, importParam); + } + + @POST + @Path("/importData") + @Produces(MediaType.APPLICATION_JSON) + public String importAddUpDeduction(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody OtherDeductionImportParam importParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getOtherDeductionWrapper(user)::importData, importParam); + } + + /** + * @description 编辑其他免税扣除 + * @return String + * @author Harryxzy + * @date 2022/10/26 9:41 + */ + @POST + @Path("/editData") + @Produces(MediaType.APPLICATION_JSON) + public String editOtherDeduction(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody OtherDeductionParam otherDeductionParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getOtherDeductionWrapper(user)::editData, otherDeductionParam); + } + + /** + * @description 获取其他免税扣除数据 + * @return String + * @author Harryxzy + * @date 2022/10/31 13:42 + */ + @POST + @Path("/getData") + @Produces(MediaType.APPLICATION_JSON) + public String getOtherDeduction(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody OtherDeductionParam otherDeductionParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getOtherDeductionWrapper(user)::getOtherDeduction, otherDeductionParam); + } + + /** + * @description 新建其他免税扣除 + * @return String + * @author Harryxzy + * @date 2022/10/27 14:41 + */ + @POST + @Path("/createData") + @Produces(MediaType.APPLICATION_JSON) + public String createOtherDeduction(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody OtherDeductionParam otherDeductionParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getOtherDeductionWrapper(user)::createData, otherDeductionParam); + } + + /** + * @description 删除所选其他免税扣除 + * @return String + * @author Harryxzy + * @date 2022/10/27 14:41 + */ + @POST + @Path("/deleteSelectData") + @Produces(MediaType.APPLICATION_JSON) + public String deleteSelectOtherDeduction(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody AddUpDeductionRecordDeleteParam otherDeductionDeleteParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getOtherDeductionWrapper(user)::deleteSelectData, otherDeductionDeleteParam); + } + + /** + * @description 一键清空其他免税扣除 + * @return null + * @author Harryxzy + * @date 2022/10/27 15:15 + */ + @POST + @Path("/deleteAllData") + @Produces(MediaType.APPLICATION_JSON) + public String deleteAllOtherDeduction(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody AddUpDeductionRecordDeleteParam otherDeductionDeleteParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getOtherDeductionWrapper(user)::deleteAllData, otherDeductionDeleteParam); + } + + @POST + @Path("/extendToLastMonth") + @Produces(MediaType.APPLICATION_JSON) + public String extendToLastMonth(@Context HttpServletRequest request, @Context HttpServletResponse response, + @RequestBody OtherDeductionExtendLastParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getOtherDeductionWrapper(user)::extendToLastMonth, param); + } +} diff --git a/src/com/engine/salary/web/ProcessController.java b/src/com/engine/salary/web/ProcessController.java new file mode 100644 index 000000000..91852b9f5 --- /dev/null +++ b/src/com/engine/salary/web/ProcessController.java @@ -0,0 +1,48 @@ +package com.engine.salary.web; + +import com.engine.common.util.ServiceUtil; +import com.engine.salary.entity.process.dto.SalaryAdjustmentDTO; +import com.engine.salary.util.ResponseResult; +import com.engine.salary.wrapper.ProcessWrapper; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import java.util.Map; + +/** + * 流程相关 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class ProcessController { + + private ProcessWrapper getProcessWrapper(User user) { + return ServiceUtil.getService(ProcessWrapper.class, user); + } + + /** + * 发起调薪流程信息 + * @param request + * @param response + * @return + */ + @GET + @Path("/salaryAdjustmentInfo") + @Produces(MediaType.APPLICATION_JSON) + public String getSearchCondition(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult, SalaryAdjustmentDTO>(user).run(getProcessWrapper(user)::salaryAdjustment); + } + + +} diff --git a/src/com/engine/salary/web/PushController.java b/src/com/engine/salary/web/PushController.java new file mode 100644 index 000000000..1b3340469 --- /dev/null +++ b/src/com/engine/salary/web/PushController.java @@ -0,0 +1,134 @@ +package com.engine.salary.web; + +import com.engine.common.util.ServiceUtil; +import com.engine.salary.entity.push.dto.PushRecordDTO; +import com.engine.salary.entity.push.dto.PushRecordDetailDTO; +import com.engine.salary.entity.push.dto.PushSettingDTO; +import com.engine.salary.entity.push.dto.PushSettingItemDTO; +import com.engine.salary.entity.push.param.*; +import com.engine.salary.entity.push.po.PushSettingItemPO; +import com.engine.salary.entity.push.po.PushSettingPO; +import com.engine.salary.util.ResponseResult; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.wrapper.PushWrapper; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; + +/** + * 数据推送 + *

Copyright: Copyright (c) 2024

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class PushController { + + private PushWrapper getPushWrapper(User user) { + return ServiceUtil.getService(PushWrapper.class, user); + } + + @POST + @Path("/setting/list") + @Produces(MediaType.APPLICATION_JSON) + public String settingList(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody PushSettingQueryParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getPushWrapper(user)::settingList, param); + } + + @POST + @Path("/mode/list") + @Produces(MediaType.APPLICATION_JSON) + public String modeList(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getPushWrapper(user)::modeList); + } + + @POST + @Path("/setting/save") + @Produces(MediaType.APPLICATION_JSON) + public String saveSetting(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody PushSettingSaveParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getPushWrapper(user)::save, param); + } + + @GET + @Path("/setting/delete") + @Produces(MediaType.APPLICATION_JSON) + public String deleteSetting(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "id") Long id) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getPushWrapper(user)::delete, id); + } + + @POST + @Path("/item/list") + @Produces(MediaType.APPLICATION_JSON) + public String itemList(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody PushSettingItemQueryParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getPushWrapper(user)::itemList, param); + } + + + @POST + @Path("/item/save") + @Produces(MediaType.APPLICATION_JSON) + public String saveItem(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody PushSettingItemSaveParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getPushWrapper(user)::saveItem, param); + } + + @GET + @Path("/item/delete") + @Produces(MediaType.APPLICATION_JSON) + public String deleteItem(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "id") Long id) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getPushWrapper(user)::deleteItem, id); + } + + @POST + @Path("/record/list") + @Produces(MediaType.APPLICATION_JSON) + public String recordList(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody RecordListQueryParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getPushWrapper(user)::recordList, param); + } + + @POST + @Path("/record/detail") + @Produces(MediaType.APPLICATION_JSON) + public String recordDetail(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody RecordDetailListQueryParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getPushWrapper(user)::recordDetailList, param); + } + + @POST + @Path("/record/create") + @Produces(MediaType.APPLICATION_JSON) + public String createPushRecord(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody CreatePushParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getPushWrapper(user)::createPushRecord, param); + } + + @POST + @Path("/record/push") + @Produces(MediaType.APPLICATION_JSON) + public String push(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody PushParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getPushWrapper(user)::push, param); + } + + @POST + @Path("/record/withdraw") + @Produces(MediaType.APPLICATION_JSON) + public String push(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody WithdrawParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getPushWrapper(user)::withdraw, param); + } +} diff --git a/src/com/engine/salary/web/SIAccountController.java b/src/com/engine/salary/web/SIAccountController.java new file mode 100644 index 000000000..73a01b5e6 --- /dev/null +++ b/src/com/engine/salary/web/SIAccountController.java @@ -0,0 +1,1191 @@ +package com.engine.salary.web; + +import com.engine.common.util.ParamUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.salary.common.SalaryContext; +import com.engine.salary.entity.hrm.dto.HrmInfoDTO; +import com.engine.salary.entity.hrm.param.HrmQueryParam; +import com.engine.salary.entity.siaccount.dto.InsuranceAccountTabDTO; +import com.engine.salary.entity.siaccount.dto.InsuranceAccountViewListDTO; +import com.engine.salary.entity.siaccount.dto.InsuranceAcctDetailImportFieldDTO; +import com.engine.salary.entity.siaccount.dto.InsuranceCompensationDTO; +import com.engine.salary.entity.siaccount.param.*; +import com.engine.salary.entity.siaccount.po.InsuranceAccountBatchPO; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import com.engine.salary.service.SIAccountService; +import com.engine.salary.service.impl.SIAccountServiceImpl; +import com.engine.salary.util.ResponseResult; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.wrapper.SIAComparisonResultWrapper; +import com.engine.salary.wrapper.SIAccountWrapper; +import com.engine.salary.wrapper.SalaryFormulaWrapper; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.StreamingOutput; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.time.LocalDate; +import java.util.Collection; +import java.util.List; +import java.util.Map; + +/** + * 福利核算控制器 + */ +@Slf4j +public class SIAccountController { + + public SIAccountService getService(User user) { + SalaryContext.get().setValue("user",user); + return ServiceUtil.getService(SIAccountServiceImpl.class, user); + } + + public SIAccountWrapper getSIAccountWrapper(User user) { + return ServiceUtil.getService(SIAccountWrapper.class,user); + } + + private SalaryFormulaWrapper getSalaryFormulaWrapper(User user) { + return (SalaryFormulaWrapper) ServiceUtil.getService(SalaryFormulaWrapper.class, user); + } + + private SIAComparisonResultWrapper getSIAComparisonResultWrapper(User user) { + return (SIAComparisonResultWrapper) ServiceUtil.getService(SIAComparisonResultWrapper.class, user); + } + + /** + * 获取台账列表页 + * + * @param request + * @param response + * @return + */ + @POST + @Path("/batch/list") + @Produces(MediaType.APPLICATION_JSON) + public String list(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody InsuranceAccountBatchParam insuranceAccountBatchParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getService(user)::listPage, insuranceAccountBatchParam); + } + + /** + * 获取正常缴纳列表 + * + * @param request + * @param response + * @param insuranceAccountDetailParam + * @return + */ + @POST + @Path("/detail/common/list") + @Produces(MediaType.APPLICATION_JSON) + public String commonList(@Context HttpServletRequest request, @Context HttpServletResponse response, + @RequestBody InsuranceAccountDetailParam insuranceAccountDetailParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getService(user)::listCommonPage, insuranceAccountDetailParam); + } + + + /** + * 获取正常缴纳列表合计行 + * + * @param request + * @param response + * @param insuranceAccountDetailParam + * @return + */ + @POST + @Path("/detail/common/list/sum") + @Produces(MediaType.APPLICATION_JSON) + public String commonListSum(@Context HttpServletRequest request, @Context HttpServletResponse response, + @RequestBody InsuranceAccountDetailParam insuranceAccountDetailParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getService(user)::listCommonSum, insuranceAccountDetailParam); + } + + + /** + * 根据姓名获取正常缴纳列表 + * + * @param request + * @param response + * @param insuranceAccountDetailParam + * @return + */ + @POST + @Path("/detail/common/search") + @Produces(MediaType.APPLICATION_JSON) + public String commonByNameList(@Context HttpServletRequest request, @Context HttpServletResponse response, + @RequestBody InsuranceAccountDetailParam insuranceAccountDetailParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getService(user)::listCommonPageByName, insuranceAccountDetailParam); + } + + /** + * 获取补缴缴纳列表 + * + * @param request + * @param response + * @param insuranceAccountDetailParam + * @return + */ + @POST + @Path("/detail/supplementary/list") + @Produces(MediaType.APPLICATION_JSON) + public String listSupplementaryPage(@Context HttpServletRequest request, @Context HttpServletResponse response, + @RequestBody InsuranceAccountDetailParam insuranceAccountDetailParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getService(user)::listSupplementaryPage, insuranceAccountDetailParam); + } + + /** + * 获取补缴缴纳列表合计行 + * + * @param request + * @param response + * @param insuranceAccountDetailParam + * @return + */ + @POST + @Path("/detail/supplementary/list/sum") + @Produces(MediaType.APPLICATION_JSON) + public String listSupplementarySum(@Context HttpServletRequest request, @Context HttpServletResponse response, + @RequestBody InsuranceAccountDetailParam insuranceAccountDetailParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getService(user)::listSupplementarySum, insuranceAccountDetailParam); + } + + /** + * 根据姓名获取补缴缴纳列表 + * + * @param request + * @param response + * @param insuranceAccountDetailParam + * @return + */ + @POST + @Path("/detail/supplementary/search") + @Produces(MediaType.APPLICATION_JSON) + public String supplementaryByNameList(@Context HttpServletRequest request, @Context HttpServletResponse response, + @RequestBody InsuranceAccountDetailParam insuranceAccountDetailParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getService(user)::supplementaryByNameList, insuranceAccountDetailParam); + } + + + /** + * 获取核算月份备注填写表单 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/accountForm") + @Produces(MediaType.APPLICATION_JSON) + public String getBaseForm(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult< Map, Map>(user).run(getService(user)::getForm, ParamUtil.request2Map(request)); + } + + + /** + * 保存并进入核算 + * + * @param request + * @param response + * @param param + * @return + */ + @POST + @Path("/save") + @Produces(MediaType.APPLICATION_JSON) + public String save(@Context HttpServletRequest request, @Context HttpServletResponse response, + @RequestBody AccountParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getService(user)::save, param); + } + + + /** + * 正常缴纳页核算 + * + * @param request + * @param response + * @param param + * @return + */ + @POST + @Path("/commonAccount") + @Produces(MediaType.APPLICATION_JSON) + public String commonAccount(@Context HttpServletRequest request, @Context HttpServletResponse response, + @RequestBody SaveCommonAccountParam param) { + User user = HrmUserVarify.getUser(request, response); + if (CollectionUtils.isNotEmpty(param.getIncludes())) { + return new ResponseResult(user).run(getService(user)::commonAccount, param); + } else { + AccountParam reqParam = new AccountParam(); + reqParam.setBillMonth(param.getBillMonth()); + reqParam.setFlag(false); + reqParam.setPaymentOrganization(param.getPaymentOrganization()); + return new ResponseResult(user).run(getService(user)::save, reqParam); + } + } + + /** + * 正常缴纳页 删除社保核算人员 + * @param request + * @param response + * @param param + * @return + */ + @POST + @Path("/deleteSocialAcctEmp") + @Produces(MediaType.APPLICATION_JSON) + public String deleteSocialAcctEmp(@Context HttpServletRequest request, @Context HttpServletResponse response, + @RequestBody SaveCommonAccountParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getService(user)::deleteSocialAcctEmp, param); + } + + /** + * 正常缴纳页 添加社保核算人员 + * @param request + * @param response + * @param param + * @return + */ + @POST + @Path("/addSocialAcctEmp") + @Produces(MediaType.APPLICATION_JSON) + public String addSocialAcctEmp(@Context HttpServletRequest request, @Context HttpServletResponse response, + @RequestBody SaveCommonAccountParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getService(user)::addSocialAcctEmp, param); + } + + + /** + * 删除月份表单 + * + * @param request + * @param response + * @param param + * @return + */ + @POST + @Path("/delete") + @Produces(MediaType.APPLICATION_JSON) + public String delete(@Context HttpServletRequest request, @Context HttpServletResponse response, + @RequestBody AccountParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getService(user)::delete, param); + } + + + + @GET + @Path("/commonForm") + @Produces(MediaType.APPLICATION_JSON) + public String queryCommonForm(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult< Map, Map>(user).run(getService(user)::getCommonForm, ParamUtil.request2Map(request)); + } + + @POST + @Path("/common/save") + @Produces(MediaType.APPLICATION_JSON) + public String save(@Context HttpServletRequest request, @Context HttpServletResponse response, + @RequestBody SaveCommonAccountParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getService(user)::saveCommonAccount, param); + } + + + @GET + @Path("/querySupplementaryForm") + @Produces(MediaType.APPLICATION_JSON) + public String querySupplementaryForm(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult< Map, Map>(user).run(getService(user)::getSupplementaryForm, ParamUtil.request2Map(request)); + } + + + @POST + @Path("/supplementary/save") + @Produces(MediaType.APPLICATION_JSON) + public String saveSummplementaryAccount(@Context HttpServletRequest request, @Context HttpServletResponse response, + @RequestBody SaveSupplementaryAccountParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getService(user)::saveSupplementaryAccount, param); + } + + + @POST + @Path("/common/delete") + @Produces(MediaType.APPLICATION_JSON) + public String deleteCommon(@Context HttpServletRequest request, @Context HttpServletResponse response, + @RequestBody SaveCommonAccountParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getService(user)::deleteCommonAccount, param); + } + + + @POST + @Path("/supplementary/delete") + @Produces(MediaType.APPLICATION_JSON) + public String deleteSummplementaryAccount(@Context HttpServletRequest request, @Context HttpServletResponse response, + @RequestBody SaveCommonAccountParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getService(user)::deleteSupplementaryAccount, param); + } + + + @POST + @Path("/file") + @Produces(MediaType.APPLICATION_JSON) + public String file(@Context HttpServletRequest request, @Context HttpServletResponse response, + @RequestBody AccountParam accountParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getService(user)::file, accountParam); + } + + @POST + @Path("/changeList") + @Produces(MediaType.APPLICATION_JSON) + public String changeList(@Context HttpServletRequest request, @Context HttpServletResponse response, + @RequestBody InsuranceAccountDetailParam insuranceAccountDetailParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getService(user)::changeList, insuranceAccountDetailParam); + } + + + + @POST + @Path("/overView") + @Produces(MediaType.APPLICATION_JSON) + public String overView(@Context HttpServletRequest request, @Context HttpServletResponse response, + @RequestBody InsuranceAccountDetailParam insuranceAccountDetailParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getService(user)::overView, insuranceAccountDetailParam); + } + + @GET + @Path("/tabList") + @Produces(MediaType.APPLICATION_JSON) + public String tabList(@Context HttpServletRequest request, @Context HttpServletResponse response, + @QueryParam("billMonth") String billMonth,@QueryParam("paymentOrganization") Long paymentOrganization) { + User user = HrmUserVarify.getUser(request, response); + AccountParam build = AccountParam.builder().billMonth(billMonth).paymentOrganization(paymentOrganization).build(); + return new ResponseResult(user).run(getService(user)::tabList, build); + } + + @POST + @Path("/inspectList") + @Produces(MediaType.APPLICATION_JSON) + public String getInspectTable(@Context HttpServletRequest request, @Context HttpServletResponse response, + @RequestBody InsuranceAccountDetailParam insuranceAccountDetailParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getService(user)::getInspectTable, insuranceAccountDetailParam); + } + + + + @POST + @Path("/inspectAccount") + @Produces(MediaType.APPLICATION_JSON) + public String accountInspect(@Context HttpServletRequest request, @Context HttpServletResponse response, + @RequestBody InspectAccountParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getService(user)::accountInspect, param); + } + + + @POST + @Path("/ignore") + @Produces(MediaType.APPLICATION_JSON) + public String ignore(@Context HttpServletRequest request, @Context HttpServletResponse response, + @RequestBody Collection ids) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult, String>(user).run(getService(user)::ignore, ids); + } + + + @POST + @Path("/unconfirmed") + @Produces(MediaType.APPLICATION_JSON) + public String unconfirmed(@Context HttpServletRequest request, @Context HttpServletResponse response, + @RequestBody Collection ids) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult, String>(user).run(getService(user)::unconfirmed, ids); + } + + + @GET + @Path("/getDisplayFlag") + @Produces(MediaType.APPLICATION_JSON) + public String buttonCheck(@Context HttpServletRequest request, @Context HttpServletResponse response, + @QueryParam("billMonth") String billMonth) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getService(user)::buttonCheck, billMonth); + } + + @GET + @Path("/getAdminTaxAgentList") + @Produces(MediaType.APPLICATION_JSON) + public String getAdminTaxAgentList(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getService(user)::getAdminTaxAgentList); + } + + /** + * 社保福利台账重新核算 + * @param request + * @param response + * @param insuranceAccountDetailParam 台账id + * @return + */ + @POST + @Path("/socialSecurityBenefitsRecalculate") + @Produces(MediaType.APPLICATION_JSON) + public String socialSecurityBenefitsRecalculate(@Context HttpServletRequest request, @Context HttpServletResponse response,@RequestBody InsuranceAccountBatchPO insuranceAccountDetailParam ){ + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getService(user)::socialSecurityBenefitsRecalculate,insuranceAccountDetailParam); + } + + /** + * 社保福利(核算)项列表 + */ + @GET + @Path("/getWelfareList") + @Produces(MediaType.APPLICATION_JSON) + public String getWelfareList(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalaryFormulaWrapper(user)::welfareList); + } + + /** + * 社保福利(核算)项列表缓存(正常缴纳、补缴) + * @param request + * @param response + * @param param + * @return + */ + @POST + @Path("/cacheWelfareList") + @Produces(MediaType.APPLICATION_JSON) + public String cacheWelfareList(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody InsuranceAcctDetailImportTemplateParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult, Void>(user).run(getService(user)::cacheWelfareField, param.getWelfareNames()); + } + + /** + * 社保福利(核算)项列表缓存(正常缴纳、补缴) + * @param request + * @param response + * @param param + * @return + */ + @POST + @Path("/cacheBalanceWelfareList") + @Produces(MediaType.APPLICATION_JSON) + public String cacheBalanceWelfareList(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody InsuranceAcctDetailImportTemplateParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult, Void>(user).run(getService(user)::cacheBalanceWelfareField, param.getWelfareNames()); + } + +// /** +// * 导出“福利核算导入”模板 +// */ +// @GET +// @Path("/welfare/importtemplate/export") +// @Produces(MediaType.APPLICATION_OCTET_STREAM) +// public Response exportImportTemplate(@Context HttpServletRequest request, @Context HttpServletResponse response) { +// try { +// InsuranceAcctDetailImportTemplateParam param = new InsuranceAcctDetailImportTemplateParam(); +// +// param.setPaymentOrganization(Long.valueOf(request.getParameter("paymentOrganization"))); +// param.setBillMonth(request.getParameter("billMonth")); +// String welfareNames = request.getParameter("welfareNames"); +// if (StringUtils.isNotBlank(welfareNames)) { +// param.setWelfareNames(Arrays.stream(welfareNames.split(",")).map(String::valueOf).collect(Collectors.toList())); +// } +// +// User user = HrmUserVarify.getUser(request, response); +// XSSFWorkbook workbook = getService(user).exportImportTemplate(param); +// String time = LocalDate.now().toString(); +// String fileName = "福利核算导入模板" + time; +// try { +// fileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8"); +// } catch (UnsupportedEncodingException e) { +// e.printStackTrace(); +// } +// StreamingOutput output = outputStream -> { +// workbook.write(outputStream); +// outputStream.flush(); +// }; +// response.setContentType("application/octet-stream"); +// return Response.ok(output).header("Content-disposition", "attachment;filename=" + fileName).header("Cache-Control", "no-cache").build(); +// } catch (Exception e) { +// log.error("福利核算导入模板导出异常", e); +// throw e; +// } +// +// } + + /** + * 导出“福利核算导入”模板 + */ + @POST + @Path("/welfare/importtemplate/export") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response exportImportTemplate(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody InsuranceAcctDetailImportTemplateParam param) { + try { +// InsuranceAcctDetailImportTemplateParam param = new InsuranceAcctDetailImportTemplateParam(); +// +// param.setPaymentOrganization(Long.valueOf(request.getParameter("paymentOrganization"))); +// param.setBillMonth(request.getParameter("billMonth")); +// String welfareNames = request.getParameter("welfareNames"); +// if (StringUtils.isNotBlank(welfareNames)) { +// param.setWelfareNames(Arrays.stream(welfareNames.split(",")).map(String::valueOf).collect(Collectors.toList())); +// } + + User user = HrmUserVarify.getUser(request, response); + XSSFWorkbook workbook = getService(user).exportImportTemplate(param); + String time = LocalDate.now().toString(); + String fileName = "福利核算导入模板" + time; + try { + fileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + StreamingOutput output = outputStream -> { + workbook.write(outputStream); + outputStream.flush(); + }; + response.setContentType("application/octet-stream"); + return Response.ok(output).header("Content-disposition", "attachment;filename=" + fileName).header("Cache-Control", "no-cache").build(); + } catch (Exception e) { + log.error("福利核算导入模板导出异常", e); + throw e; + } + + } + + /** + * 将通过“福利核算导入”模板导入的数据更新到hrsa_bill_detail表中 + */ + @POST + @Path("/welfare/importInsuranceAcctDetail") + @Produces(MediaType.APPLICATION_JSON) + public String importInsuranceAcctDetail(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody InsuranceAcctImportParam insuranceAcctImportParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getService(user)::importInsuranceAcctDetail, insuranceAcctImportParam); + } + + /** + * 预览“福利核算导入”模板导入的数据 + */ + @POST + @Path("/welfare/preview") + @Produces(MediaType.APPLICATION_JSON) + public String preview(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody InsuranceAcctImportParam insuranceAcctImportParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getService(user)::preview, insuranceAcctImportParam); + } + +// /** +// * 导出“福利核算-补缴导入”模板 +// */ +// @GET +// @Path("/welfare/supplyimporttemplate/export") +// @Produces(MediaType.APPLICATION_OCTET_STREAM) +// public Response exportSupplyImportTemplate(@Context HttpServletRequest request, @Context HttpServletResponse response) { +// try { +// InsuranceAcctDetailImportTemplateParam param = new InsuranceAcctDetailImportTemplateParam(); +// +// String welfareNames = request.getParameter("welfareNames"); +// String billMonth = request.getParameter("billMonth"); +// Long paymentOrganization = Long.valueOf(request.getParameter("paymentOrganization")); +// if (StringUtils.isNotBlank(welfareNames)) { +// param.setWelfareNames(Arrays.stream(welfareNames.split(",")).map(String::valueOf).collect(Collectors.toList())); +// } +// if (StringUtils.isNotBlank(billMonth)) { +// param.setBillMonth(billMonth); +// } +// if (paymentOrganization > 0) { +// param.setPaymentOrganization(paymentOrganization); +// } +// +// User user = HrmUserVarify.getUser(request, response); +// XSSFWorkbook workbook = getService(user).exportSupplyImportTemplate(param); +// String time = LocalDate.now().toString(); +// String fileName = "福利核算-补缴导入模板" + time; +// try { +// fileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8"); +// } catch (UnsupportedEncodingException e) { +// e.printStackTrace(); +// } +// StreamingOutput output = outputStream -> { +// workbook.write(outputStream); +// outputStream.flush(); +// }; +// response.setContentType("application/octet-stream"); +// return Response.ok(output).header("Content-disposition", "attachment;filename=" + fileName).header("Cache-Control", "no-cache").build(); +// } catch (Exception e) { +// log.error("福利核算-补缴导入模板导出异常", e); +// throw e; +// } +// +// } + + /** + * 导出“福利核算-补缴导入”模板 + */ + @POST + @Path("/welfare/supplyimporttemplate/export") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response exportSupplyImportTemplate(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody InsuranceAcctDetailImportTemplateParam param) { + try { +// InsuranceAcctDetailImportTemplateParam param = new InsuranceAcctDetailImportTemplateParam(); +// +// String welfareNames = request.getParameter("welfareNames"); +// String billMonth = request.getParameter("billMonth"); +// Long paymentOrganization = Long.valueOf(request.getParameter("paymentOrganization")); +// if (StringUtils.isNotBlank(welfareNames)) { +// param.setWelfareNames(Arrays.stream(welfareNames.split(",")).map(String::valueOf).collect(Collectors.toList())); +// } +// if (StringUtils.isNotBlank(billMonth)) { +// param.setBillMonth(billMonth); +// } +// if (paymentOrganization > 0) { +// param.setPaymentOrganization(paymentOrganization); +// } + + User user = HrmUserVarify.getUser(request, response); + XSSFWorkbook workbook = getService(user).exportSupplyImportTemplate(param); + String time = LocalDate.now().toString(); + String fileName = "福利核算-补缴导入模板" + time; + try { + fileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + StreamingOutput output = outputStream -> { + workbook.write(outputStream); + outputStream.flush(); + }; + response.setContentType("application/octet-stream"); + return Response.ok(output).header("Content-disposition", "attachment;filename=" + fileName).header("Cache-Control", "no-cache").build(); + } catch (Exception e) { + log.error("福利核算-补缴导入模板导出异常", e); + throw e; + } + + } + // **********************************线下对比 start*********************************/ + /** + * 导出“福利核算导入”模板 + */ + @GET + @Path("/comparisonwelfare/importtemplate/export") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response exportComparisonWelfareTemplate(@Context HttpServletRequest request, @Context HttpServletResponse response) { + try { + InsuranceAccountDetailParam param = new InsuranceAccountDetailParam(); + + String billMonth = request.getParameter("billMonth"); + if (StringUtils.isNotBlank(billMonth)) { + param.setBillMonth(billMonth); + } + String paymentOrganization = request.getParameter("paymentOrganization"); + if (StringUtils.isNotBlank(paymentOrganization)) { + param.setPaymentOrganization(paymentOrganization); + } + + String paymentStatus = request.getParameter("paymentStatus"); + if (StringUtils.isNotBlank(paymentStatus)) { + param.setPaymentStatus(Integer.valueOf(paymentStatus)); + } + + User user = HrmUserVarify.getUser(request, response); + XSSFWorkbook workbook = getService(user).exportComparisonWelfareTemplate(param); + String time = LocalDate.now().toString(); + String fileName = "福利核算-线下对比导入模板" + time; + try { + fileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + StreamingOutput output = outputStream -> { + workbook.write(outputStream); + outputStream.flush(); + }; + response.setContentType("application/octet-stream"); + return Response.ok(output).header("Content-disposition", "attachment;filename=" + fileName).header("Cache-Control", "no-cache").build(); + } catch (Exception e) { + log.error("福利核算-线下对比导入模板导出异常", e); + throw e; + } + + } + + /** + * 将通过“福利核算-线下对比导入”模板导入的数据更新到hrsa_excel_bill_detail表中 + */ + @POST + @Path("/comparisonwelfare/importExcelInsuranceDetail") + @Produces(MediaType.APPLICATION_JSON) + public String importExcelInsuranceDetail(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody ExcelInsuranceImportParam excelInsuranceImportParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getService(user)::importExcelInsuranceDetail, excelInsuranceImportParam); + } + + + //福利核算-线上线下对比结果列表 + @POST + @Path("/comparisonwelfare/list") + @Produces(MediaType.APPLICATION_JSON) + public String listComparisonResult(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody InsuranceComparisonResultQueryParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>>(user).run(getSIAComparisonResultWrapper(user)::listPage, param); + } + + //导出福利核算-线上线下对比结果 + @GET + @Path("/comparisonresult/export") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response exportComparisonResult(@Context HttpServletRequest request, @Context HttpServletResponse response) { + try { + InsuranceComparisonResultQueryParam param = new InsuranceComparisonResultQueryParam(); + + param.setPaymentStatus(Integer.valueOf(request.getParameter("paymentStatus"))); + param.setBillMonth(request.getParameter("billMonth")); + param.setPaymentOrganization(request.getParameter("paymentOrganization")); + String onlyDiffEmployee = request.getParameter("onlyDiffEmployee"); + if (StringUtils.isNotBlank(onlyDiffEmployee)) { + param.setOnlyDiffEmployee(Boolean.parseBoolean(onlyDiffEmployee)); + } + String userName = request.getParameter("userName"); + if (StringUtils.isNotBlank(userName)) { + param.setUserName(userName); + } + + User user = HrmUserVarify.getUser(request, response); + XSSFWorkbook workbook = getSIAComparisonResultWrapper(user).exportComparisonResult(param); + String time = LocalDate.now().toString(); + String fileName = "福利核算-线下对比结果" + time; + try { + fileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + StreamingOutput output = outputStream -> { + workbook.write(outputStream); + outputStream.flush(); + }; + response.setContentType("application/octet-stream"); + return Response.ok(output).header("Content-disposition", "attachment;filename=" + fileName).header("Cache-Control", "no-cache").build(); + } catch (Exception e) { + log.error("福利核算-线下对比结果导出异常", e); + throw e; + } + } + + // **********************************线下对比 end*********************************/ + + // **********************************退差 start*********************************/ + /** + * 保存退差(新增) + */ + @POST + @Path("/saveRecession") + @Produces(MediaType.APPLICATION_JSON) + public String saveRecession(@Context HttpServletRequest request, @Context HttpServletResponse response, + @RequestBody RecessionParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSIAccountWrapper(user)::saveRecession, param); + } + + /** + * 删除退差 + */ + @POST + @Path("/delRecession") + @Produces(MediaType.APPLICATION_JSON) + public String delRecession(@Context HttpServletRequest request, @Context HttpServletResponse response, + @RequestBody Collection ids) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult, String>(user).run(getSIAccountWrapper(user)::delRecession, ids); + } + + /** + * 获取退差列表 + * + * @param request + * @param response + * @param insuranceAccountDetailParam + * @return + */ + @POST + @Path("/detail/recession/list") + @Produces(MediaType.APPLICATION_JSON) + public String listRecessionPage(@Context HttpServletRequest request, @Context HttpServletResponse response, + @RequestBody InsuranceAccountDetailParam insuranceAccountDetailParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getService(user)::listRecessionPage, insuranceAccountDetailParam); + } + + + /** + * 获取退差列表合计列 + * + * @param request + * @param response + * @param insuranceAccountDetailParam + * @return + */ + @POST + @Path("/detail/recession/list/sum") + @Produces(MediaType.APPLICATION_JSON) + public String listRecessionSum(@Context HttpServletRequest request, @Context HttpServletResponse response, + @RequestBody InsuranceAccountDetailParam insuranceAccountDetailParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getService(user)::listRecessionSum, insuranceAccountDetailParam); + } + + /** + * 通过id获取InsuranceAccountDetailPO中的社保、公积金、其他福利个人和公司缴纳数据 + * @param request + * @param response + * @param id + * @return + */ + @GET + @Path("/getPaymentById") + @Produces(MediaType.APPLICATION_JSON) + public String getPaymentById(@Context HttpServletRequest request, @Context HttpServletResponse response, + @QueryParam("id") Long id) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getService(user)::getPaymentById, id); + } + + /** + * 编辑InsuranceAccountDetailPO中的社保、公积金、其他福利个人和公司缴纳数据 + */ + @POST + @Path("/editAccount") + @Produces(MediaType.APPLICATION_JSON) + public String editAccount(@Context HttpServletRequest request, @Context HttpServletResponse response, + @RequestBody EditAccountDetailParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getService(user)::editAccount, param); + } + + /** + * 获取当前登录人所控制的人员范围 + */ + @POST + @Path("/getEmployeeListByTaxAgent") + @Produces(MediaType.APPLICATION_JSON) + public String getEmployeeListByTaxAgent(@Context HttpServletRequest request, @Context HttpServletResponse response, + @RequestBody HrmQueryParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSIAccountWrapper(user)::getEmployeeListByTaxAgent, param); + } + + // **********************************退差 end*********************************/ + + // **********************************调差 start*********************************/ + /** + * 获取当前登录人所控制的人员范围 + */ + @POST + @Path("/getEmployeeListToCompensation") + @Produces(MediaType.APPLICATION_JSON) + public String getEmployeeListToCompensation(@Context HttpServletRequest request, @Context HttpServletResponse response, + @RequestBody HrmQueryParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSIAccountWrapper(user)::getEmployeeListToCompensation, param); + } + + /** + * 通过id获取InsuranceAccountDetailPO中的社保福利项 + */ + @GET + @Path("/compensationCategoryType") + @Produces(MediaType.APPLICATION_JSON) + public String compensationCategoryType(@Context HttpServletRequest request, @Context HttpServletResponse response, + @QueryParam("id") Long id) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>>(user).run(getSIAccountWrapper(user)::compensationCategoryType, id); + } + + /** + * 获取当前调差福利类型-公司方支出总计 + */ + @POST + @Path("/compensationComTotal") + @Produces(MediaType.APPLICATION_JSON) + public String compensationComTotal(@Context HttpServletRequest request, @Context HttpServletResponse response, + @RequestBody List paramList) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult, List>>(user).run(getSIAccountWrapper(user)::compensationComTotal, paramList); + } + + /** + * 社保调差保存 + */ + @POST + @Path("/compensationSave") + @Produces(MediaType.APPLICATION_JSON) + public String compensationSave(@Context HttpServletRequest request, @Context HttpServletResponse response, + @RequestBody List param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult, Map>(user).run(getSIAccountWrapper(user)::compensationSave, param); + } + + /** + * 社保调差默认配置保存 + */ + @POST + @Path("/compensationConfigSave") + @Produces(MediaType.APPLICATION_JSON) + public String compensationConfigSave(@Context HttpServletRequest request, @Context HttpServletResponse response, + @RequestBody List param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult, String>(user).run(getSIAccountWrapper(user)::compensationConfigSave, param); + } + + /** + * 社保调差撤回 + */ + @POST + @Path("/compensationBack") + @Produces(MediaType.APPLICATION_JSON) + public String compensationBack(@Context HttpServletRequest request, @Context HttpServletResponse response, + @RequestBody InsuranceCompensationDTO param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSIAccountWrapper(user)::compensationBack, param); + } + + /** + * 社保调差列表 + */ + @POST + @Path("/compensationList") + @Produces(MediaType.APPLICATION_JSON) + public String compensationList(@Context HttpServletRequest request, @Context HttpServletResponse response, + @RequestBody InsuranceCompensationDTO param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSIAccountWrapper(user)::compensationList, param); + } + + // **********************************调差 end*********************************/ + + // **********************************补差 start*********************************/ + /** + * 福利台账-补差福利项列表 + */ + @GET + @Path("/getBalanceWelfareList") + @Produces(MediaType.APPLICATION_JSON) + public String getBalanceWelfareList(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalaryFormulaWrapper(user)::balanceWelfareList); + } + +// /** +// * 导出“福利核算-补差导入”模板 +// */ +// @GET +// @Path("/welfare/balanceimporttemplate/export") +// @Produces(MediaType.APPLICATION_OCTET_STREAM) +// public Response exportBalanceImportTemplate(@Context HttpServletRequest request, @Context HttpServletResponse response) { +// try { +// InsuranceAcctDetailImportTemplateParam param = new InsuranceAcctDetailImportTemplateParam(); +// +// param.setPaymentOrganization(Long.valueOf(request.getParameter("paymentOrganization"))); +// param.setBillMonth(request.getParameter("billMonth")); +// String welfareNames = request.getParameter("welfareNames"); +// if (StringUtils.isNotBlank(welfareNames)) { +// param.setWelfareNames(Arrays.stream(welfareNames.split(",")).map(String::valueOf).collect(Collectors.toList())); +// } +// +// User user = HrmUserVarify.getUser(request, response); +// XSSFWorkbook workbook = getService(user).exportBalanceImportTemplate(param); +// String time = LocalDate.now().toString(); +// String fileName = "福利台账-补差导入模板" + time; +// try { +// fileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8"); +// } catch (UnsupportedEncodingException e) { +// e.printStackTrace(); +// } +// StreamingOutput output = outputStream -> { +// workbook.write(outputStream); +// outputStream.flush(); +// }; +// response.setContentType("application/octet-stream"); +// return Response.ok(output).header("Content-disposition", "attachment;filename=" + fileName).header("Cache-Control", "no-cache").build(); +// } catch (Exception e) { +// log.error("福利台账-补差导入模板导出异常", e); +// throw e; +// } +// +// } + + /** + * 导出“福利核算-补差导入”模板 + */ + @POST + @Path("/welfare/balanceimporttemplate/export") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response exportBalanceImportTemplate(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody InsuranceAcctDetailImportTemplateParam param) { + try { +// InsuranceAcctDetailImportTemplateParam param = new InsuranceAcctDetailImportTemplateParam(); +// +// param.setPaymentOrganization(Long.valueOf(request.getParameter("paymentOrganization"))); +// param.setBillMonth(request.getParameter("billMonth")); +// String welfareNames = request.getParameter("welfareNames"); +// if (StringUtils.isNotBlank(welfareNames)) { +// param.setWelfareNames(Arrays.stream(welfareNames.split(",")).map(String::valueOf).collect(Collectors.toList())); +// } + + User user = HrmUserVarify.getUser(request, response); + XSSFWorkbook workbook = getService(user).exportBalanceImportTemplate(param); + String time = LocalDate.now().toString(); + String fileName = "福利台账-补差导入模板" + time; + try { + fileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + StreamingOutput output = outputStream -> { + workbook.write(outputStream); + outputStream.flush(); + }; + response.setContentType("application/octet-stream"); + return Response.ok(output).header("Content-disposition", "attachment;filename=" + fileName).header("Cache-Control", "no-cache").build(); + } catch (Exception e) { + log.error("福利台账-补差导入模板导出异常", e); + throw e; + } + + } + /** + * 将通过“福利台账-补差导入”模板导入的数据更新到hrsa_bill_detail表中 + */ + @POST + @Path("/welfare/importBalanceInsuranceDetail") + @Produces(MediaType.APPLICATION_JSON) + public String importBalanceInsuranceDetail(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody InsuranceAcctImportParam insuranceAcctImportParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getService(user)::importBalanceInsuranceDetail, insuranceAcctImportParam); + } + + /** + * 删除补差 + */ + @POST + @Path("/delBalance") + @Produces(MediaType.APPLICATION_JSON) + public String delBalance(@Context HttpServletRequest request, @Context HttpServletResponse response, + @RequestBody InspectAccountParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSIAccountWrapper(user)::delBalance, param); + } + + /** + * 获取补差列表 + * + * @param request + * @param response + * @param insuranceAccountDetailParam + * @return + */ + @POST + @Path("/detail/balance/list") + @Produces(MediaType.APPLICATION_JSON) + public String listBalancePage(@Context HttpServletRequest request, @Context HttpServletResponse response, + @RequestBody InsuranceAccountDetailParam insuranceAccountDetailParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getService(user)::listBalancePage, insuranceAccountDetailParam); + } + + /** + * 获取补差列表合计列 + * + * @param request + * @param response + * @param insuranceAccountDetailParam + * @return + */ + @POST + @Path("/detail/balance/list/sum") + @Produces(MediaType.APPLICATION_JSON) + public String listBalanceSum(@Context HttpServletRequest request, @Context HttpServletResponse response, + @RequestBody InsuranceAccountDetailParam insuranceAccountDetailParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getService(user)::listBalanceSum, insuranceAccountDetailParam); + } + // **********************************补差 end*********************************/ + + /** + * 取指定月份的福利缴纳基数作为补缴基数 + */ + @POST + @Path("/detail/getSupplementPaymentForm") + @Produces(MediaType.APPLICATION_JSON) + public String getSupplementPaymentForm(@Context HttpServletRequest request, @Context HttpServletResponse response, + @RequestBody SupplementAccountBaseParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>>(user).run(getSIAccountWrapper(user)::getSupplementPaymentForm, param); + } + + /** + * 获取待编辑的补缴费用相关福利项 + */ + @POST + @Path("/detail/getPaymentGroup") + @Produces(MediaType.APPLICATION_JSON) + public String getPaymentGroup(@Context HttpServletRequest request, @Context HttpServletResponse response, + @RequestBody SupplementAccountBaseParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>>(user).run(getSIAccountWrapper(user)::getPaymentGroup, param); + } + + /** + * 获取待编辑的补差费用相关福利项 + */ + @POST + @Path("/detail/getBalancePaymentGroup") + @Produces(MediaType.APPLICATION_JSON) + public String getBalancePaymentGroup(@Context HttpServletRequest request, @Context HttpServletResponse response, + @RequestBody BalanceAccountBaseParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>>(user).run(getSIAccountWrapper(user)::getBalancePaymentGroup, param); + } + + /** + * 新增补差数据 + */ + @POST + @Path("/detail/addNewBalance") + @Produces(MediaType.APPLICATION_JSON) + public String addNewBalance(@Context HttpServletRequest request, @Context HttpServletResponse response, + @RequestBody BalanceAccountBaseParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSIAccountWrapper(user)::addNewBalance, param); + } +} diff --git a/src/com/engine/salary/web/SIArchivesController.java b/src/com/engine/salary/web/SIArchivesController.java new file mode 100644 index 000000000..e0b3bfe89 --- /dev/null +++ b/src/com/engine/salary/web/SIArchivesController.java @@ -0,0 +1,268 @@ +package com.engine.salary.web; + +import com.engine.common.util.ParamUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.salary.common.SalaryContext; +import com.engine.salary.entity.siarchives.dto.InsuranceArchivesBaseHistoryDTO; +import com.engine.salary.entity.siarchives.param.InsuranceArchivesListParam; +import com.engine.salary.entity.siarchives.param.InsuranceArchivesSaveParam; +import com.engine.salary.entity.siarchives.param.SIArchiveBaseHistoryListParam; +import com.engine.salary.entity.siarchives.po.InsuranceArchivesBaseInfoPO; +import com.engine.salary.enums.sicategory.WelfareTypeEnum; +import com.engine.salary.service.SIArchivesService; +import com.engine.salary.service.impl.SIArchivesServiceImpl; +import com.engine.salary.util.ResponseResult; +import com.engine.salary.util.page.PageInfo; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import java.util.Collection; +import java.util.Map; + +/** + * @Author weaver_cl + * @Description: + * @Date 2022/3/11 + * @Version V1.0 + **/ +public class SIArchivesController { + + private SIArchivesService getService(User user) { + SalaryContext.get().setValue("user",user); + return ServiceUtil.getService(SIArchivesServiceImpl.class,user); + } + + + /** + * 提示信息 + * @param request + * @param response + * @return + */ + @GET + @Path("/tips") + @Produces(MediaType.APPLICATION_JSON) + public String tips(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult< Map, Map>(user).run(getService(user)::getTips, ParamUtil.request2Map(request)); + } + + + /** + * 高级搜索 + * @param request + * @param response + * @return + */ + @GET + @Path("/getSearchCondition") + @Produces(MediaType.APPLICATION_JSON) + public String getSearchCondition(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult< Map, Map>(user).run(getService(user)::getSearchCondition, ParamUtil.request2Map(request)); + + } + + + + /** + * 查询档案基本信息表单 + * @param request + * @param response + * @return + */ + @GET + @Path("/getBaseForm") + @Produces(MediaType.APPLICATION_JSON) + public String getBaseForm(@Context HttpServletRequest request, @Context HttpServletResponse response, + @DefaultValue("") @QueryParam(value = "welfareTypeEnum") WelfareTypeEnum welfareTypeEnum) { + User user = HrmUserVarify.getUser(request, response); + Map map = ParamUtil.request2Map(request); + map.put("welfareTypeEnum",welfareTypeEnum); + return new ResponseResult< Map, Map>(user).run(getService(user)::getBaseForm, map); + } + + /** + * 查询档案缴纳基数表单 + * @param request + * @param response + * @param welfareTypeEnum + * @return + */ + @GET + @Path("/getPaymentForm") + @Produces(MediaType.APPLICATION_JSON) + public String getPaymentForm(@Context HttpServletRequest request, @Context HttpServletResponse response, + @DefaultValue("") @QueryParam(value = "welfareTypeEnum") WelfareTypeEnum welfareTypeEnum) { + User user = HrmUserVarify.getUser(request, response); + Map map = ParamUtil.request2Map(request); + map.put("welfareTypeEnum",welfareTypeEnum); + return new ResponseResult< Map, Map>(user).run(getService(user)::getPaymentForm, map); + } + + /** + * 保存档案 + * @param request + * @param response + * @param param + * @return + */ + @POST + @Path("/save") + @Produces(MediaType.APPLICATION_JSON) + public String insert(@Context HttpServletRequest request, @Context HttpServletResponse response,@RequestBody InsuranceArchivesSaveParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getService(user)::insert, param); + } + + /** + * 查询档案列表 + * @param request + * @param response + * @param param + * @return + */ + @POST + @Path("/getTable") + @Produces(MediaType.APPLICATION_JSON) + public String getTable(@Context HttpServletRequest request, @Context HttpServletResponse response,@RequestBody InsuranceArchivesListParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getService(user)::listPage, param); + } + + /** + * 获取福利档案各tab总人数 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/queryInsuranceTabTotal") + @Produces(MediaType.APPLICATION_JSON) + public String queryInsuranceTabTotal(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getService(user)::queryInsuranceTabTotal); + } + + /** + * 待减员页面的删除待办 + */ + @POST + @Path("/cancelStayDel") + @Produces(MediaType.APPLICATION_JSON) + public String cancelStayDel(@Context HttpServletRequest request, @Context HttpServletResponse response,@RequestBody InsuranceArchivesBaseInfoPO po) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getService(user)::cancelStayDel, po); + } + + /** + * 待增员页面的删除待办 + */ + @POST + @Path("/updateRunStatus") + @Produces(MediaType.APPLICATION_JSON) + public String updateRunStatus(@Context HttpServletRequest request, @Context HttpServletResponse response,@RequestBody InsuranceArchivesBaseInfoPO po) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getService(user)::updateRunStatus, po); + } + + /** + * 批量取消停缴 + */ + @POST + @Path("/cancelStopPayment") + @Produces(MediaType.APPLICATION_JSON) + public String cancelStopPayment(@Context HttpServletRequest request, @Context HttpServletResponse response,@RequestBody Collection ids) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult , String>(user).run(getService(user)::cancelStopPayment, ids); + } + + /** + * 批量减员 + */ + @POST + @Path("/stayDelToStop") + @Produces(MediaType.APPLICATION_JSON) + public String stayDelToStop(@Context HttpServletRequest request, @Context HttpServletResponse response,@RequestBody Collection ids) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult, Map>(user).run(getService(user)::stayDelToStop, ids); + } + + /** + * 全量减员 + */ + @GET + @Path("/allStayDelToStop") + @Produces(MediaType.APPLICATION_JSON) + public String allStayDelToStop(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getService(user)::allStayDelToStop); + } + + /** + * 批量增员 + */ + @POST + @Path("/stayAddToPay") + @Produces(MediaType.APPLICATION_JSON) + public String stayAddToPay(@Context HttpServletRequest request, @Context HttpServletResponse response,@RequestBody Collection ids) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult, Map>(user).run(getService(user)::stayAddToPay, ids); + } + + /** + * 全量增员 + */ + @GET + @Path("/allStayAddToPay") + @Produces(MediaType.APPLICATION_JSON) + public String allStayAddToPay(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getService(user)::allStayAddToPay); + } + + /** + * 删除档案 + */ + @POST + @Path("/deleteArchive") + @Produces(MediaType.APPLICATION_JSON) + public String deleteArchive(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Collection ids) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult, Map>(user).run(getService(user)::deleteArchive, ids); + } + + /** + * 查询非系统人员福利档案列表 + * @param request + * @param response + * @param param + * @return + */ + @POST + @Path("/getExtTable") + @Produces(MediaType.APPLICATION_JSON) + public String getExtTable(@Context HttpServletRequest request, @Context HttpServletResponse response,@RequestBody InsuranceArchivesListParam param) { + User user = HrmUserVarify.getUser(request, response); + param.setExtWelArchiveList(true); + return new ResponseResult>(user).run(getService(user)::listPage, param); + } + + /** + * 查询档案基数调整记录列表 + */ + @POST + @Path("/getAdjustHistoryList") + @Produces(MediaType.APPLICATION_JSON) + public String getAdjustHistoryList(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SIArchiveBaseHistoryListParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getService(user)::historyListByEmployeeIdAndOperator, param); + } +} diff --git a/src/com/engine/salary/web/SICategoryController.java b/src/com/engine/salary/web/SICategoryController.java new file mode 100644 index 000000000..0cbb6216b --- /dev/null +++ b/src/com/engine/salary/web/SICategoryController.java @@ -0,0 +1,163 @@ +package com.engine.salary.web; + +import com.engine.common.util.ParamUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.salary.entity.sicategory.dto.ICategoryDTO; +import com.engine.salary.entity.sicategory.dto.ICategoryFormDTO; +import com.engine.salary.entity.sicategory.dto.ICategoryListDTO; +import com.engine.salary.entity.sicategory.param.UpdateStatusParam; +import com.engine.salary.entity.sischeme.param.InsuranceSchemeParam; +import com.engine.salary.service.SICategoryService; +import com.engine.salary.service.impl.SICategoryServiceImpl; +import com.engine.salary.util.ResponseResult; +import com.engine.salary.util.page.PageInfo; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import java.util.Map; + +/** + * @Author weaver_cl + * @Description: 社保自定义福利控制器 + * @Date 2022/3/9 + * @Version V1.0 + **/ +public class SICategoryController { + + private SICategoryService getService (User user) { + return ServiceUtil.getService(SICategoryServiceImpl.class,user); + } + + + /** + * 福利表单 + * @param request + * @param response + * @return + */ + @GET + @Path("/customCategoryForm") + @Produces(MediaType.APPLICATION_JSON) + public String getForm(@Context HttpServletRequest request, @Context HttpServletResponse response, + @QueryParam(value = "id") Long id) { + User user = HrmUserVarify.getUser(request, response); + Map map = ParamUtil.request2Map(request); + map.put("id",id); + return new ResponseResult< Map, Map>(user).run(getService(user)::getForm, map); + } + + /** + * 查询自定义福利列表 + */ + @POST + @Path("/customCategoryList") + @Produces(MediaType.APPLICATION_JSON) + public String listPage(@Context HttpServletRequest request, @Context HttpServletResponse response, + @RequestBody InsuranceSchemeParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult< InsuranceSchemeParam, PageInfo>(user).run(getService(user)::listPage, queryParam); + } + + + /** + * 新增 + * @param request + * @param response + * @return + */ + @POST + @Path("/createSICategory") + @Produces(MediaType.APPLICATION_JSON) + public String insert(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody ICategoryFormDTO iCategoryFormDTO) { + User user = HrmUserVarify.getUser(request, response); + Map map = ParamUtil.request2Map(request); + map.put("iCategoryFormDTO",iCategoryFormDTO); + return new ResponseResult< Map, Map>(user).run(getService(user)::insert, map); + } + + + + /** + * @description 获取指定自定义福利信息 + * @return String + * @author Harryxzy + * @date 2022/10/14 11:34 + */ + @POST + @Path("/getCustomCategoryByID") + @Produces(MediaType.APPLICATION_JSON) + public String getCustomCategoryByID(@Context HttpServletRequest request, @Context HttpServletResponse response,@RequestBody ICategoryFormDTO iCategoryFormDTO) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult< Long, ICategoryDTO>(user).run(getService(user)::getByID, iCategoryFormDTO.getId()); + } + + + /** + * @description 编辑自定义福利名称 + * @return String + * @author Harryxzy + * @date 2022/10/14 11:37 + */ + @POST + @Path("/updateCustomCategoryName") + @Produces(MediaType.APPLICATION_JSON) + public String updateCustomCategoryName(@Context HttpServletRequest request, @Context HttpServletResponse response,@RequestBody ICategoryFormDTO iCategoryFormDTO) { + User user = HrmUserVarify.getUser(request, response); + Map map = ParamUtil.request2Map(request); +// return new ResponseResult< ICategoryFormDTO, Map>(user).run(getService(user)::updateCategoryName, iCategoryFormDTO); + return new ResponseResult< ICategoryFormDTO, Map>(user).run(getService(user)::updateCategoryNameAndPayScope, iCategoryFormDTO); + } + + +// @POST +// @Path("/updateCustomCategory") +// @Produces(MediaType.APPLICATION_JSON) +// public String update(@Context HttpServletRequest request, @Context HttpServletResponse response,@RequestBody ICategoryFormDTO iCategoryFormDTO) { +// User user = HrmUserVarify.getUser(request, response); +// Map map = ParamUtil.request2Map(request); +// map.put("iCategoryFormDTO",iCategoryFormDTO); +// return new ResponseResult< Map, Map>(user).run(getService(user)::update, map); +// } + + + /** + * 删除自定义福利项 + * 必要条件: + * 1-福利项未启用, + * 2-福利核算数据中不能存在该福利项的核算数据 + */ + + @POST + @Path("/deleteCustomCategory") + @Produces(MediaType.APPLICATION_JSON) + public String deleteCustomCategory(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody ICategoryFormDTO iCategoryFormDTO) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult< ICategoryFormDTO, Map>(user).run(getService(user)::deleteCustomCategory, iCategoryFormDTO); + } + + + /** + * 更新自定义福利的启用停用状态 + * @param request + * @param response + * @param updateStatusParam + * @return + */ + @POST + @Path("/updateCustomCategoryStatus") + @Produces(MediaType.APPLICATION_JSON) + public String updateStatusById(@Context HttpServletRequest request, @Context HttpServletResponse response,@RequestBody UpdateStatusParam updateStatusParam) { + User user = HrmUserVarify.getUser(request, response); + Map map = ParamUtil.request2Map(request); + map.put("id",updateStatusParam.getId()); + map.put("isUse",updateStatusParam.getIsUse()); + return new ResponseResult< Map, Map>(user).run(getService(user)::updateStatusById, map); + } + +} diff --git a/src/com/engine/salary/web/SIExportController.java b/src/com/engine/salary/web/SIExportController.java new file mode 100644 index 000000000..f3636c8dd --- /dev/null +++ b/src/com/engine/salary/web/SIExportController.java @@ -0,0 +1,367 @@ +package com.engine.salary.web; + +import cn.hutool.core.util.BooleanUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.salary.entity.siaccount.param.InspectAccountParam; +import com.engine.salary.entity.siaccount.po.InsuranceAccountInspectPO; +import com.engine.salary.entity.siarchives.param.InsuranceArchivesListParam; +import com.engine.salary.entity.siexport.param.InsuranceExportParam; +import com.engine.salary.enums.siaccount.PaymentStatusEnum; +import com.engine.salary.service.SIAccountService; +import com.engine.salary.service.impl.SIAccountServiceImpl; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.wrapper.SIExportWrapper; +import com.engine.salary.wrapper.SIImportWrapper; +import org.apache.commons.lang3.StringUtils; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.jetbrains.annotations.Nullable; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.StreamingOutput; +import java.io.UnsupportedEncodingException; +import java.math.BigDecimal; +import java.net.URLEncoder; +import java.time.LocalDate; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +/** + * @Author weaver_cl + * @Description: + * @Date 2022/4/18 + * @Version V1.0 + **/ +public class SIExportController { + + public SIAccountService getService(User user) { + return ServiceUtil.getService(SIAccountServiceImpl.class, user); + } + + public SIExportWrapper getSIExportWrapper(User user) { + return ServiceUtil.getService(SIExportWrapper.class,user); + } + + public SIImportWrapper getSIImportWrapper(User user) { + return ServiceUtil.getService(SIImportWrapper.class,user); + } + + @GET + @Path("/archives/export") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response export(@Context HttpServletRequest request, @Context HttpServletResponse response) { + InsuranceArchivesListParam param = buildParam(request); + User user = HrmUserVarify.getUser(request, response); + XSSFWorkbook workbook = getSIExportWrapper(user).export(param); + String time = LocalDate.now().toString(); + String fileName = "福利档案报表" + time; + try { + fileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + StreamingOutput output = outputStream -> { + workbook.write(outputStream); + outputStream.flush(); + }; + response.setContentType("application/octet-stream"); + return Response.ok(output).header("Content-disposition", "attachment;filename=" + fileName).header("Cache-Control", "no-cache").build(); + } + + + + @GET + @Path("/archives/exportInspect") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response exportInspect(@Context HttpServletRequest request, @Context HttpServletResponse response, + @QueryParam("ids")List ids,@QueryParam("billMonth") String billMonth) { + InspectAccountParam param = InspectAccountParam.builder().ids(ids).billMonth(billMonth).build(); + User user = HrmUserVarify.getUser(request, response); +// SIAccountBiz siAccountBiz = new SIAccountBiz(); +// List insuranceAccountInspectPOS = siAccountBiz.allInspects(param.getIds(), param.getBillMonth()); + List insuranceAccountInspectPOS = getService(user).allInspects(param.getIds(), param.getBillMonth()); + InsuranceArchivesListParam req = new InsuranceArchivesListParam(); + req.setEmployeeIds(insuranceAccountInspectPOS.stream().map(InsuranceAccountInspectPO::getEmployeeId).distinct().collect(Collectors.toList())); + XSSFWorkbook workbook = getSIExportWrapper(user).export(req); + String time = LocalDate.now().toString(); + String fileName = "核算异常人员档案报表" + time; + try { + fileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + StreamingOutput output = outputStream -> { + workbook.write(outputStream); + outputStream.flush(); + }; + response.setContentType("application/octet-stream"); + return Response.ok(output).header("Content-disposition", "attachment;filename=" + fileName).header("Cache-Control", "no-cache").build(); + } + + + + + @GET + @Path("/common/export") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response exportAccount(@Context HttpServletRequest request, @Context HttpServletResponse response, + @QueryParam("billMonth") String billMonth,@QueryParam("paymentOrganization") String paymentOrganization) { + InsuranceExportParam param = InsuranceExportParam.builder().billMonth(billMonth).paymentOrganization(paymentOrganization).build(); + User user = HrmUserVarify.getUser(request, response); + XSSFWorkbook workbook = getSIExportWrapper(user).exportAccount(PaymentStatusEnum.COMMON.getValue(),param); + String time = LocalDate.now().toString(); + String fileName = "正常缴纳核算报表" + time; + try { + fileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + StreamingOutput output = outputStream -> { + workbook.write(outputStream); + outputStream.flush(); + }; + response.setContentType("application/octet-stream"); + return Response.ok(output).header("Content-disposition", "attachment;filename=" + fileName).header("Cache-Control", "no-cache").build(); + } + + + @GET + @Path("/supplementary/export") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response exportSupplementary(@Context HttpServletRequest request, @Context HttpServletResponse response, + @QueryParam("billMonth") String billMonth,@QueryParam("paymentOrganization") String paymentOrganization) { + InsuranceExportParam param = InsuranceExportParam.builder().billMonth(billMonth).paymentOrganization(paymentOrganization).build(); + User user = HrmUserVarify.getUser(request, response); + XSSFWorkbook workbook = getSIExportWrapper(user).exportAccount(PaymentStatusEnum.REPAIR.getValue(),param); + String time = LocalDate.now().toString(); + String fileName = "补缴核算报表" + time; + try { + fileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + StreamingOutput output = outputStream -> { + workbook.write(outputStream); + outputStream.flush(); + }; + response.setContentType("application/octet-stream"); + return Response.ok(output).header("Content-disposition", "attachment;filename=" + fileName).header("Cache-Control", "no-cache").build(); + } + + /** + * 福利台账-退差核算数据导出 + */ + @GET + @Path("/recession/export") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response exportRecession(@Context HttpServletRequest request, @Context HttpServletResponse response, + @QueryParam("billMonth") String billMonth,@QueryParam("creator") Long creator,@QueryParam("paymentOrganization") String paymentOrganization) { + InsuranceExportParam param = InsuranceExportParam.builder().billMonth(billMonth).creator(creator).paymentOrganization(paymentOrganization).build(); + User user = HrmUserVarify.getUser(request, response); + XSSFWorkbook workbook = getSIExportWrapper(user).exportAccount(PaymentStatusEnum.RECESSION.getValue(),param); + String time = LocalDate.now().toString(); + String fileName = "退差核算报表" + time; + try { + fileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + StreamingOutput output = outputStream -> { + workbook.write(outputStream); + outputStream.flush(); + }; + response.setContentType("application/octet-stream"); + return Response.ok(output).header("Content-disposition", "attachment;filename=" + fileName).header("Cache-Control", "no-cache").build(); + } + + + /** + * 福利台账-补差核算数据导出 + */ + @GET + @Path("/balance/export") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response exportBalance(@Context HttpServletRequest request, @Context HttpServletResponse response, + @QueryParam("billMonth") String billMonth, @QueryParam("paymentOrganization") String paymentOrganization) { + InsuranceExportParam param = InsuranceExportParam.builder().billMonth(billMonth).paymentOrganization(paymentOrganization).build(); + User user = HrmUserVarify.getUser(request, response); + XSSFWorkbook workbook = getSIExportWrapper(user).exportAccount(PaymentStatusEnum.BALANCE.getValue(),param); + String time = LocalDate.now().toString(); + String fileName = "补差核算报表" + time; + try { + fileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + StreamingOutput output = outputStream -> { + workbook.write(outputStream); + outputStream.flush(); + }; + response.setContentType("application/octet-stream"); + return Response.ok(output).header("Content-disposition", "attachment;filename=" + fileName).header("Cache-Control", "no-cache").build(); + } + + @GET + @Path("/overView/export") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response exportOverView(@Context HttpServletRequest request, @Context HttpServletResponse response, + @QueryParam("billMonth") String billMonth,@QueryParam("paymentOrganization") String paymentOrganization) { + InsuranceExportParam param = InsuranceExportParam.builder().billMonth(billMonth).paymentOrganization(paymentOrganization).build(); + User user = HrmUserVarify.getUser(request, response); + XSSFWorkbook workbook = getSIExportWrapper(user).exportOverView(param); + String time = LocalDate.now().toString(); + String fileName = "总览报表" + time; + try { + fileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + StreamingOutput output = outputStream -> { + workbook.write(outputStream); + outputStream.flush(); + }; + response.setContentType("application/octet-stream"); + return Response.ok(output).header("Content-disposition", "attachment;filename=" + fileName).header("Cache-Control", "no-cache").build(); + } + + @GET + @Path("/exportCurrentData") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response exportTemplate(@Context HttpServletRequest request, @Context HttpServletResponse response) { + InsuranceArchivesListParam param = buildParam(request); + User user = HrmUserVarify.getUser(request, response); +// SIAccountBiz siAccountBiz = new SIAccountBiz(); + if (param.getInspectAll() != null && param.getInspectAll()) { +// List insuranceAccountInspectPOS = siAccountBiz.allInspects(param.getIds(), param.getBillMonth()); + List insuranceAccountInspectPOS = getService(user).allInspects(param.getIds(), param.getBillMonth()); + param.setEmployeeIds(insuranceAccountInspectPOS.stream().map(InsuranceAccountInspectPO::getEmployeeId).distinct().collect(Collectors.toList())); + } + XSSFWorkbook workbook = getSIImportWrapper(user).exportTemplate(param); + String time = LocalDate.now().toString(); + String fileName = ""; + if (BooleanUtil.isTrue(param.getTemplateFlag())) { + fileName = SalaryI18nUtil.getI18nLabel( 100571, "社保福利档案模板"); + } else { + fileName = SalaryI18nUtil.getI18nLabel( 94629, "社保福利档案"); + } + fileName = fileName + time; + try { + fileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + StreamingOutput output = outputStream -> { + workbook.write(outputStream); + outputStream.flush(); + }; + response.setContentType("application/octet-stream"); + return Response.ok(output).header("Content-disposition", "attachment;filename=" + fileName).header("Cache-Control", "no-cache").build(); + } + + @Nullable + private InsuranceArchivesListParam buildParam(HttpServletRequest request) { + InsuranceArchivesListParam param = new InsuranceArchivesListParam(); + String userName = request.getParameter("userName"); + if (StringUtils.isNotBlank(userName)) { + param.setUserName(userName); + } + String jobNum = request.getParameter("jobNum"); + if (StringUtils.isNotBlank(jobNum)) { + param.setUserName(jobNum); + } + String departmentIds = request.getParameter("departmentIds"); + if (StringUtils.isNotBlank(departmentIds)) { + param.setDepartmentIds(Arrays.stream(departmentIds.split(",")).map(BigDecimal::new).collect(Collectors.toList())); + } + String statuses = request.getParameter("statuses"); + if (StringUtils.isNotBlank(statuses)) { + param.setStatuses(Arrays.stream(statuses.split(",")).map(String::valueOf).collect(Collectors.toList())); + } + String positions = request.getParameter("positions"); + if (StringUtils.isNotBlank(positions)) { + param.setPositions(Arrays.stream(positions.split(",")).map(BigDecimal::new).collect(Collectors.toList())); + } + //SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + String hiredate = request.getParameter("hiredate"); + if (StringUtils.isNotBlank(hiredate)) { + param.setHireDate(hiredate.split(",")); + } + String dimissionDate = request.getParameter("dimissionDate"); + if (StringUtils.isNotBlank(dimissionDate)) { + param.setDimissionDate(dimissionDate.split(",")); + } + String hiredateStart = request.getParameter("hiredateStart"); + if (StringUtils.isNotBlank(hiredateStart)) { + param.setHiredateStart(hiredateStart); + } + String hiredateEnd = request.getParameter("hiredateEnd"); + if (StringUtils.isNotBlank(hiredateEnd)) { + param.setHiredateEnd(hiredateEnd); + } + String dimissionDateStart = request.getParameter("dimissionDateStart"); + if (StringUtils.isNotBlank(dimissionDateStart)) { + param.setDimissionDateStart(dimissionDateStart); + } + String dimissionDateEnd = request.getParameter("dimissionDateEnd"); + if (StringUtils.isNotBlank(dimissionDateEnd)) { + param.setDimissionDateEnd(dimissionDateEnd); + } + String siSchemeId = request.getParameter("siSchemeId"); + if (StringUtils.isNotBlank(siSchemeId)) { + param.setSiSchemeId(Long.valueOf(siSchemeId)); + } + String fundSchemeId = request.getParameter("fundSchemeId"); + if (StringUtils.isNotBlank(fundSchemeId)) { + param.setFundSchemeId(Long.valueOf(fundSchemeId)); + } + String otherSchemeId = request.getParameter("otherSchemeId"); + if (StringUtils.isNotBlank(otherSchemeId)) { + param.setOtherSchemeId(Long.valueOf(otherSchemeId)); + } + String employeeIds = request.getParameter("employeeIds"); + if (StringUtils.isNotBlank(employeeIds)) { + param.setEmployeeIds(Arrays.stream(employeeIds.split(",")).map(Long::valueOf).collect(Collectors.toList())); + } + String keyword = request.getParameter("keyword"); + if (StringUtils.isNotBlank(keyword)) { + param.setKeyword(keyword); + } + String dataSource = request.getParameter("dataSource"); + if (StringUtils.isNotBlank(dataSource)) { + param.setDataSource(dataSource); + } + + String exportData = request.getParameter("exportData"); + if (StringUtils.isNotBlank(exportData)) { + param.setExportData(Boolean.valueOf(exportData)); + } + String inspectAll = request.getParameter("inspectAll"); + if (StringUtils.isNotBlank(inspectAll)) { + param.setInspectAll(Boolean.valueOf(inspectAll)); + } + + String ids = request.getParameter("ids"); + if (StringUtils.isNotBlank(ids)) { + param.setIds(Arrays.stream(ids.split(",")).map(Long::valueOf).collect(Collectors.toList())); + } + + String billMonth = request.getParameter("billMonth"); + if (StringUtils.isNotBlank(billMonth)) { + param.setBillMonth(billMonth); + } + String templateFlag = request.getParameter("templateFlag"); + if (StringUtils.isNotBlank(templateFlag)) { + param.setTemplateFlag(Boolean.valueOf(templateFlag)); + } + + return param; + } + +} diff --git a/src/com/engine/salary/web/SIReportController.java b/src/com/engine/salary/web/SIReportController.java new file mode 100644 index 000000000..041deabfd --- /dev/null +++ b/src/com/engine/salary/web/SIReportController.java @@ -0,0 +1,68 @@ +package com.engine.salary.web; + +import com.engine.common.util.ServiceUtil; +import com.engine.salary.entity.salaryarchive.dto.SalaryItemAdjustRecordListDTO; +import com.engine.salary.entity.salaryarchive.param.SalaryItemAdjustRecordQueryParam; +import com.engine.salary.entity.siaccount.param.QueryAccountDetailParam; +import com.engine.salary.util.ResponseResult; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.wrapper.SIReportWrapper; +import com.engine.salary.wrapper.SalaryArchiveItemWrapper; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import java.util.Map; +import java.util.Optional; + +/** + * 福利报表 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SIReportController { + + private SalaryArchiveItemWrapper salaryArchiveItemWrapper; + + private SalaryArchiveItemWrapper getSalaryArchiveItemWrapper(User user) { + return (SalaryArchiveItemWrapper) ServiceUtil.getService(SalaryArchiveItemWrapper.class, user); + } + + private SIReportWrapper getSIReportWrapper(User user) { + return (SIReportWrapper) ServiceUtil.getService(SIReportWrapper.class, user); + } + + @POST + @Path("welfare/list") + @Produces(MediaType.APPLICATION_JSON) + public String list(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody QueryAccountDetailParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSIReportWrapper(user)::welfareList, queryParam); + } + + + @GET + @Path("record/list") + @Produces(MediaType.APPLICATION_JSON) + public String recordList(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + SalaryItemAdjustRecordQueryParam salaryItemAdjustRecordQueryParam = new SalaryItemAdjustRecordQueryParam(); + salaryItemAdjustRecordQueryParam.setEmployeeId((long)user.getUID()); + String current = Optional.ofNullable(request.getParameter("current")).orElse("1"); + String pageSize = Optional.ofNullable(request.getParameter("pageSize")).orElse("10"); + salaryItemAdjustRecordQueryParam.setCurrent(Integer.valueOf(current)); + salaryItemAdjustRecordQueryParam.setPageSize(Integer.valueOf(pageSize)); + return new ResponseResult>(user).run(getSalaryArchiveItemWrapper(user)::myAdjustRecordList, salaryItemAdjustRecordQueryParam); + } +} diff --git a/src/com/engine/salary/web/SISchemeController.java b/src/com/engine/salary/web/SISchemeController.java new file mode 100644 index 000000000..89772a896 --- /dev/null +++ b/src/com/engine/salary/web/SISchemeController.java @@ -0,0 +1,385 @@ +package com.engine.salary.web; + +import com.engine.common.util.ParamUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.salary.entity.siaccount.po.InsuranceAccountInspectPO; +import com.engine.salary.entity.siarchives.param.InsuranceArchivesListParam; +import com.engine.salary.entity.siarchives.param.SIArchiveImportParam; +import com.engine.salary.entity.sischeme.dto.InsuranceSchemeListDTO; +import com.engine.salary.entity.sischeme.param.InsuranceSchemeDetailUpdateParam; +import com.engine.salary.entity.sischeme.param.InsuranceSchemeParam; +import com.engine.salary.entity.sischeme.param.InsuranceSchemeReqParam; +import com.engine.salary.enums.siaccount.EmployeeStatusEnum; +import com.engine.salary.enums.sicategory.WelfareTypeEnum; +import com.engine.salary.service.SIAccountService; +import com.engine.salary.service.SISchemeService; +import com.engine.salary.service.impl.SIAccountServiceImpl; +import com.engine.salary.service.impl.SISchemeServiceImpl; +import com.engine.salary.util.ResponseResult; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.wrapper.SISchemeWrapper; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.jetbrains.annotations.NotNull; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.StreamingOutput; +import java.io.UnsupportedEncodingException; +import java.math.BigDecimal; +import java.net.URLEncoder; +import java.time.LocalDate; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * @Author weaver_cl + * @Description: 社保方案控制器 + * @Date 2022/3/7 + * @Version V1.0 + **/ +@Slf4j +public class SISchemeController { + + private SISchemeService getService(User user) { + return ServiceUtil.getService(SISchemeServiceImpl.class, user); + } + + private SISchemeWrapper getSISchemeWrapper(User user) { + + return ServiceUtil.getService(SISchemeWrapper.class, user); + } + + private SIAccountService getSIAccountService(User user) { + return ServiceUtil.getService(SIAccountServiceImpl.class, user); + } + + /** + * 查询福利方案表单 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/getForm") + @Produces(MediaType.APPLICATION_JSON) + public String getForm(@Context HttpServletRequest request, @Context HttpServletResponse response, + @DefaultValue("SOCIAL_SECURITY") @QueryParam(value = "welfareTypeEnum") WelfareTypeEnum welfareTypeEnum) { + User user = HrmUserVarify.getUser(request, response); + Map map = ParamUtil.request2Map(request); + //InsuranceSchemeDTO insuranceSchemeDTO = InsuranceSchemeDTO.builder().welfareType(welfareTypeEnum).build(); + map.put("welfareTypeEnum", welfareTypeEnum); + return new ResponseResult, Map>(user).run(getService(user)::getForm, map); + } + + + /** + * 查询福利方案列表 + * + * @param request + * @param response + * @return + */ + @POST + @Path("/getTable") + @Produces(MediaType.APPLICATION_JSON) + public String list(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody InsuranceSchemeParam insuranceSchemeParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSISchemeWrapper(user)::listPage, insuranceSchemeParam); + } + + + /** + * 新增 + * + * @param request + * @param response + * @return + */ + @POST + @Path("/insert") + @Produces(MediaType.APPLICATION_JSON) + public String insertScheme(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody InsuranceSchemeReqParam insuranceSchemeReqParam) { + User user = HrmUserVarify.getUser(request, response); + Map map = ParamUtil.request2Map(request); + map.put("insuranceSchemeReqParam", insuranceSchemeReqParam); + return new ResponseResult, Map>(user).run(getService(user)::insertScheme, map); + } + + /** + * 编辑方案主表和明细表数据 + * + * @param request + * @param response + * @param insuranceSchemeReqParam + * @return + */ + @POST + @Path("/update") + @Produces(MediaType.APPLICATION_JSON) + public String update(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody InsuranceSchemeReqParam insuranceSchemeReqParam) { + User user = HrmUserVarify.getUser(request, response); + Map map = ParamUtil.request2Map(request); + map.put("insuranceSchemeReqParam", insuranceSchemeReqParam); + return new ResponseResult,String>(user).run(getService(user)::update, map); + } + + /** + * 编辑方案明细表数据 + * + * @param request + * @param response + * @param schemeDetailList + * @return + */ + @POST + @Path("/updateSchemeDetail") + @Produces(MediaType.APPLICATION_JSON) + public String updateSchemeDetail(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody List schemeDetailList) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult, List>(user).run(getService(user)::updateSchemeDetail, schemeDetailList); + } + + /** + * 删除(接口中暂无) + * + * @param request + * @param response + * @param insuranceSchemeReqParam + * @return + */ + @POST + @Path("/delete") + @Produces(MediaType.APPLICATION_JSON) + public String deleteTaxRate(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody InsuranceSchemeReqParam insuranceSchemeReqParam) { + User user = HrmUserVarify.getUser(request, response); + Map map = ParamUtil.request2Map(request); + map.put("ids", insuranceSchemeReqParam.getIds()); + map.put("welfareTypeId", insuranceSchemeReqParam.getWelfareTypeEnum().getValue()); + return new ResponseResult, Map>(user).run(getService(user)::delete, map); + } + + /** + * 复制福利方案表单 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/copyScheme") + @Produces(MediaType.APPLICATION_JSON) + public String copyScheme(@Context HttpServletRequest request, @Context HttpServletResponse response, + @QueryParam("id") Long id, @QueryParam("schemeName") String schemeName) { + User user = HrmUserVarify.getUser(request, response); + Map map = ParamUtil.request2Map(request); + map.put("id", id); + map.put("schemeName", schemeName); + return new ResponseResult, Map>(user).run(getService(user)::copyScheme, map); + } + + + /** + * 导出档案 + * + * @return + */ + @GET + @Path("/export") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response export(@Context HttpServletRequest request, @Context HttpServletResponse response) { + try { + InsuranceArchivesListParam param = buildInsuranceArchivesListParam(request); + User user = HrmUserVarify.getUser(request, response); + XSSFWorkbook workbook = getService(user).export(param); + String fileName; + //表头 + if (param.getRunStatuses().size() > 0) { + if (param.getRunStatuses().contains(EmployeeStatusEnum.STAY_ADD.getValue()) && param.getRunStatuses().size() == 1) { + fileName = SalaryI18nUtil.getI18nLabel(85368, "社保福利档案导出" + "-" + EmployeeStatusEnum.STAY_ADD.getDefaultLabel()); + } else if (param.getRunStatuses().contains(EmployeeStatusEnum.PAYING.getValue()) && param.getRunStatuses().contains(EmployeeStatusEnum.STAY_DEL.getValue()) && param.getRunStatuses().size() == 2) { + fileName = SalaryI18nUtil.getI18nLabel(85368, "社保福利档案导出" + "-" + "在缴员工"); + } else if (param.getRunStatuses().contains(EmployeeStatusEnum.STAY_DEL.getValue()) && param.getRunStatuses().size() == 1) { + fileName = SalaryI18nUtil.getI18nLabel(85368, "社保福利档案导出" + "-" + EmployeeStatusEnum.STAY_DEL.getDefaultLabel()); + } else if (param.getRunStatuses().contains(EmployeeStatusEnum.STOP_PAYMENT_FROM_ADD.getValue()) && param.getRunStatuses().contains(EmployeeStatusEnum.STOP_PAYMENT_FROM_DEL.getValue()) && param.getRunStatuses().size() == 2) { + fileName = SalaryI18nUtil.getI18nLabel(85368, "社保福利档案导出" + "-" + "停缴员工"); + } else { + fileName = SalaryI18nUtil.getI18nLabel(85368, "社保福利档案导出"); + } + } else { + fileName = SalaryI18nUtil.getI18nLabel(85368, "社保福利档案导出"); + } + + fileName = fileName + LocalDate.now(); + try { + fileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + + StreamingOutput output = outputStream -> { + workbook.write(outputStream); + outputStream.flush(); + }; + response.setContentType("application/octet-stream"); + return Response.ok(output) + .header("Content-disposition", "attachment;filename=" + fileName) + .header("Cache-Control", "no-cache").build(); + } catch (Exception e) { + log.error("社保福利档案导出异常", e); + throw e; + } + } + + + @POST + @Path("/preview") + @Produces(MediaType.APPLICATION_JSON) + public String preview(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SIArchiveImportParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getService(user)::preview, queryParam); + } + + + @POST + @Path("/importBatch") + @Produces(MediaType.APPLICATION_JSON) + public String batchImportEbatch(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SIArchiveImportParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getService(user)::batchImportEbatch, queryParam); + } + + + /** + * 导出档案和档案模板 + * + * @return + */ + @GET + @Path("/template/export") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response exportTemplate(@Context HttpServletRequest request, @Context HttpServletResponse response) { + try { + InsuranceArchivesListParam param = buildInsuranceArchivesListParam(request); + + param.setExportData(Boolean.valueOf(request.getParameter("exportData"))); + param.setExtWelArchiveList(Boolean.valueOf(request.getParameter("extWelArchiveList"))); + User user = HrmUserVarify.getUser(request, response); + if (param.getInspectAll() != null && param.getInspectAll()) { + List insuranceAccountInspectPOS = getSIAccountService(user).allInspects(param.getIds(), param.getBillMonth()); + param.setEmployeeIds(insuranceAccountInspectPOS.stream().map(InsuranceAccountInspectPO::getEmployeeId).distinct().collect(Collectors.toList())); + } + XSSFWorkbook workbook = getService(user).exportTemplate(param); + String fileName; + //表头 + if (param.isExtWelArchiveList()) { + fileName = SalaryI18nUtil.getI18nLabel(0, "社保福利档案导入模板") + "-" + SalaryI18nUtil.getI18nLabel(542679, "非系统人员"); + } else if (param.getRunStatuses().size() > 0) { + if (param.getRunStatuses().contains(EmployeeStatusEnum.STAY_ADD.getValue()) && param.getRunStatuses().size() == 1) { + fileName = SalaryI18nUtil.getI18nLabel(85368, "社保福利档案导入模板" + "-" + EmployeeStatusEnum.STAY_ADD.getDefaultLabel()); + } else if (param.getRunStatuses().contains(EmployeeStatusEnum.PAYING.getValue()) && param.getRunStatuses().contains(EmployeeStatusEnum.STAY_DEL.getValue()) && param.getRunStatuses().size() == 2) { + fileName = SalaryI18nUtil.getI18nLabel(85368, "社保福利档案导入模板" + "-" + "在缴员工"); + } else if (param.getRunStatuses().contains(EmployeeStatusEnum.STAY_DEL.getValue()) && param.getRunStatuses().size() == 1) { + fileName = SalaryI18nUtil.getI18nLabel(85368, "社保福利档案导入模板" + "-" + EmployeeStatusEnum.STAY_DEL.getDefaultLabel()); + } else if (param.getRunStatuses().contains(EmployeeStatusEnum.STOP_PAYMENT_FROM_ADD.getValue()) && param.getRunStatuses().contains(EmployeeStatusEnum.STOP_PAYMENT_FROM_DEL.getValue()) && param.getRunStatuses().size() == 2) { + fileName = SalaryI18nUtil.getI18nLabel(85368, "社保福利档案导入模板" + "-" + "停缴员工"); + } else { + fileName = SalaryI18nUtil.getI18nLabel(85368, "社保福利档案导入模板"); + } + } else { + fileName = SalaryI18nUtil.getI18nLabel(85368, "社保福利档案导入模板"); + } + + + fileName = fileName + LocalDate.now(); + try { + fileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + + StreamingOutput output = outputStream -> { + workbook.write(outputStream); + outputStream.flush(); + }; + response.setContentType("application/octet-stream"); + return Response.ok(output) + .header("Content-disposition", "attachment;filename=" + fileName) + .header("Cache-Control", "no-cache").build(); + } catch (Exception e) { + log.error("社保福利档案模板导出异常", e); + throw e; + } + } + + @NotNull + private InsuranceArchivesListParam buildInsuranceArchivesListParam(HttpServletRequest request) { + InsuranceArchivesListParam param = new InsuranceArchivesListParam(); + + String ids = request.getParameter("ids"); + if (StringUtils.isNotBlank(ids)) { + param.setIds(Arrays.stream(ids.split(",")).map(Long::valueOf).collect(Collectors.toList())); + } + + String runStatuses = request.getParameter("runStatuses"); + if (StringUtils.isNotBlank(runStatuses)) { + param.setRunStatuses(Arrays.stream(runStatuses.split(",")).map(String::valueOf).collect(Collectors.toList())); + } + + String statusesStr = request.getParameter("statusesStr"); + if (StringUtils.isNotBlank(statusesStr)) { + param.setStatuses(Arrays.stream(statusesStr.split(",")).map(String::new).collect(Collectors.toList())); + } + String userName = request.getParameter("username"); + if (StringUtils.isNotBlank(userName)) { + param.setUserName(userName); + } + String jobNum = request.getParameter("jobNum"); + if (StringUtils.isNotBlank(jobNum)) { + param.setJobNum(jobNum); + } + String taxAgentId = request.getParameter("taxAgentId"); + if (StringUtils.isNotBlank(taxAgentId)) { + param.setTaxAgentId(Long.parseLong(taxAgentId)); + } + String departmentIds = request.getParameter("departmentIdsStr"); + if (StringUtils.isNotBlank(departmentIds)) { + param.setDepartmentIds(Arrays.stream(departmentIds.split(",")).map(BigDecimal::new).collect(Collectors.toList())); + } + String subcompanyIds = request.getParameter("subcompanyIdsStr"); + if (StringUtils.isNotBlank(subcompanyIds)) { + param.setSubcompanyIds(Arrays.stream(subcompanyIds.split(",")).map(BigDecimal::new).collect(Collectors.toList())); + } + String positions = request.getParameter("positionsStr"); + if (StringUtils.isNotBlank(positions)) { + param.setPositions(Arrays.stream(positions.split(",")).map(BigDecimal::new).collect(Collectors.toList())); + } + String siSchemeId = request.getParameter("siSchemeId"); + if (StringUtils.isNotBlank(siSchemeId)) { + param.setSiSchemeId(Long.valueOf(siSchemeId)); + } + String fundSchemeId = request.getParameter("fundSchemeId"); + if (StringUtils.isNotBlank(fundSchemeId)) { + param.setFundSchemeId(Long.valueOf(fundSchemeId)); + } + String otherSchemeId = request.getParameter("otherSchemeId"); + if (StringUtils.isNotBlank(otherSchemeId)) { + param.setOtherSchemeId(Long.valueOf(otherSchemeId)); + } + return param; + } + + +} diff --git a/src/com/engine/salary/web/SalaryAcctController.java b/src/com/engine/salary/web/SalaryAcctController.java new file mode 100644 index 000000000..a196d53ef --- /dev/null +++ b/src/com/engine/salary/web/SalaryAcctController.java @@ -0,0 +1,931 @@ +package com.engine.salary.web; + +import com.engine.common.util.ServiceUtil; +import com.engine.salary.entity.salaryacct.dto.*; +import com.engine.salary.entity.salaryacct.param.*; +import com.engine.salary.entity.salarysob.dto.SalarySobCycleDTO; +import com.engine.salary.enums.salarysob.SalaryEmployeeStatusEnum; +import com.engine.salary.service.SalaryAcctExcelService; +import com.engine.salary.service.impl.SalaryAcctExcelServiceImpl; +import com.engine.salary.util.ResponseResult; +import com.engine.salary.util.SalaryDateUtil; +import com.engine.salary.util.excel.ExcelPreviewDTO; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.wrapper.*; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.jetbrains.annotations.NotNull; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.StreamingOutput; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.time.LocalDate; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * 薪资核算 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Slf4j +public class SalaryAcctController { + + private SalaryAcctRecordWrapper getSalaryAcctRecordWrapper(User user) { + return ServiceUtil.getService(SalaryAcctRecordWrapper.class, user); + } + + private SalaryAcctEmployeeWrapper getSalaryAcctEmployeeWrapper(User user) { + return ServiceUtil.getService(SalaryAcctEmployeeWrapper.class, user); + } + + private SalaryAcctResultWrapper getSalaryAcctResultWrapper(User user) { + return ServiceUtil.getService(SalaryAcctResultWrapper.class, user); + } + + // private SalaryAcctCheckResultWrapper salaryAcctCheckResultWrapper; + private SalaryComparisonResultWrapper getSalaryComparisonResultWrapper(User user) { + return ServiceUtil.getService(SalaryComparisonResultWrapper.class, user); + } + + private SalaryAcctExcelWrapper getSalaryAcctExcelWrapper(User user) { + return ServiceUtil.getService(SalaryAcctExcelWrapper.class, user); + } + + private SalaryAcctExcelService getSalaryAcctExcelService(User user) { + return ServiceUtil.getService(SalaryAcctExcelServiceImpl.class, user); + } + +// /**********************************薪资核算记录相关 start*********************************/ + + //薪资核算列表 + @POST + @Path("/list") + @Produces(MediaType.APPLICATION_JSON) + public String list(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryAcctRecordQueryParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + queryParam.setStartMonth(SalaryDateUtil.String2YearMonth(queryParam.getStartMonthStr())); + queryParam.setEndMonth(SalaryDateUtil.String2YearMonth(queryParam.getEndMonthStr())); + return new ResponseResult(user).run(getSalaryAcctRecordWrapper(user)::listPage, queryParam); + } + + //薪资核算详情 + @GET + @Path("/getForm") + @Produces(MediaType.APPLICATION_JSON) + public String getForm(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "id") Long id) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalaryAcctRecordWrapper(user)::getForm, id); + } + + //获取薪资核算的薪资周期、考勤周期等 + @GET + @Path("/getSalarySobCycle") + @Produces(MediaType.APPLICATION_JSON) + public String getSalarySobCycle(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "salaryAcctRecordId") Long salaryAcctRecordId) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryAcctRecordWrapper(user)::getSalarySobCycleById, salaryAcctRecordId); + } + + //保存薪资核算的基本信息 + @POST + @Path("/basic/save") + @Produces(MediaType.APPLICATION_JSON) + public String save(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryAcctRecordSaveParam param) { + User user = HrmUserVarify.getUser(request, response); + param.setSalaryMonth(SalaryDateUtil.String2YearMonth(param.getSalaryMonthStr())); + return new ResponseResult(user).run(getSalaryAcctRecordWrapper(user)::save, param); + } + + //删除薪资核算记录 + @POST + @Path("/delete") + @Produces(MediaType.APPLICATION_JSON) + public String deleteSalaryAcctRecord(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Collection ids) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult, Long>(user).run(getSalaryAcctRecordWrapper(user)::delete, ids); + } + + + //归档薪资核算记录 + @GET + @Path("/file") + @Produces(MediaType.APPLICATION_JSON) + public String fileSalaryAcctRecord(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "id") Long id) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryAcctRecordWrapper(user)::file, id); + } + + //重新核算 + @POST + @Path("/reAccounting") + @Produces(MediaType.APPLICATION_JSON) + public String reAccounting(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryAcctRecordReAccountParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryAcctRecordWrapper(user)::reCalculate, param.getSalaryAcctRecordId()); + } + + //判断是否存在合并计税 + @GET + @Path("/hasConsolidatedTax") + @Produces(MediaType.APPLICATION_JSON) + public String hasConsolidatedTax(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "id") Long id) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryAcctRecordWrapper(user)::hasConsolidatedTax, id); + } + + // 回算 + @POST + @Path("/backCalculate") + public String backCalculate(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryAcctRecordReAccountParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryAcctRecordWrapper(user)::backCalculate, param.getSalaryAcctRecordId()); + } + + /** + * 检查薪资核算的账套配置是否发生变更 + * + * @param id 薪资核算记录id + * @return + */ + @GET + @Path("/compareSobConfig") + @Produces(MediaType.APPLICATION_JSON) + public String compareSobConfig(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "id") Long id) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryAcctRecordWrapper(user)::compareSobConfig, id); + } + + /** + * 更新薪资核算的账套配置 + * + * @param id 薪资核算记录id + * @return + */ + @GET + @Path("/updateSobConfig") + @Produces(MediaType.APPLICATION_JSON) + public String updateSobConfig(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "id") Long id) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryAcctRecordWrapper(user)::updateSobConfig, id); + } + + + /* ********************************薪资核算记录相关 end*********************************/ + + + /**********************************薪资核算人员相关 start*********************************/ + + //薪资核算人员确认列表 + @POST + @Path("/acctemployee/list") + @Produces(MediaType.APPLICATION_JSON) + public String listSalaryAccountingEmployee(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryAcctEmployeeQueryParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalaryAcctEmployeeWrapper(user)::listPage, param); + } + + //薪资核算环比上期减少人员列表 + @POST + @Path("/reducedemployee/list") + @Produces(MediaType.APPLICATION_JSON) + public String listReducedEmployee(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryAcctEmployeeQueryParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalaryAcctEmployeeWrapper(user)::listPage4Reduce, param); + } + + //薪资核算环比上期添加人员列表 + @POST + @Path("/addedemployee/list") + @Produces(MediaType.APPLICATION_JSON) + public String listAddEmployee(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryAcctEmployeeQueryParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalaryAcctEmployeeWrapper(user)::listPage4Add, param); + } + + + //添加薪资核算人员 + @POST + @Path("/acctemployee/save") + @Produces(MediaType.APPLICATION_JSON) + public String saveSalaryAcctEmployee(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryAcctEmployeeSaveParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryAcctEmployeeWrapper(user)::save, param); + } + + //删除薪资核算人员 + @POST + @Path("/acctemployee/delete") + @Produces(MediaType.APPLICATION_JSON) + public String deleteSalaryAcctEmployee(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryAcctEmployeeDeleteParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryAcctEmployeeWrapper(user)::delete, param); + } + + //检查薪资核算人员的个税扣缴义务人 + @POST + @Path("/acctemployee/checkTaxAgent") + @Produces(MediaType.APPLICATION_JSON) + public String checkTaxAgent(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryAcctEmpCheckTaxAgentParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryAcctEmployeeWrapper(user)::checkTaxAgent, param.getSalaryAcctRecordId()); + } + + //刷新薪资核算人员 + @POST + @Path("/acctemployee/refresh") + @Produces(MediaType.APPLICATION_JSON) + public String refreshTaxAgent(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryAcctEmpRefreshTaxAgentParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryAcctEmployeeWrapper(user)::refresh, param.getSalaryAcctRecordId()); + } + + //从环比上月减少添加薪资核算人员 + @POST + @Path("/acctemployee/addFromReduce") + @Produces(MediaType.APPLICATION_JSON) + public String addFromReduce(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryAcctEmployeeAddParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryAcctEmployeeWrapper(user)::addFromReduce, param); + } + + /** + * 导出人员范围 + */ + @GET + @Path("/acctemployee/export") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response exportSalaryAcctEmployee(@Context HttpServletRequest request, @Context HttpServletResponse response) { + try { + SalaryAcctEmployeeQueryParam param = buildSalaryAcctEmployeeQueryParam(request); + + User user = HrmUserVarify.getUser(request, response); + XSSFWorkbook workbook = getSalaryAcctExcelWrapper(user).exportSalaryAcctEmployee(param); + String time = LocalDate.now().toString(); + String fileName = "核算人员范围" + time; + try { + fileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + StreamingOutput output = outputStream -> { + workbook.write(outputStream); + outputStream.flush(); + }; + response.setContentType("application/octet-stream"); + return Response.ok(output).header("Content-disposition", "attachment;filename=" + fileName).header("Cache-Control", "no-cache").build(); + } catch (Exception e) { + log.error("核算人员范围导出异常", e); + throw e; + } + + + } + + @NotNull + private SalaryAcctEmployeeQueryParam buildSalaryAcctEmployeeQueryParam(HttpServletRequest request) { + SalaryAcctEmployeeQueryParam param = new SalaryAcctEmployeeQueryParam(); + + String salaryAcctRecordId = request.getParameter("salaryAcctRecordId"); + if (StringUtils.isNotBlank(salaryAcctRecordId)) { + param.setSalaryAcctRecordId(Long.parseLong(salaryAcctRecordId)); + } + String employeeName = request.getParameter("employeeName"); + if (StringUtils.isNotBlank(employeeName)) { + param.setEmployeeName(employeeName); + } + String taxAgentId = request.getParameter("taxAgentId"); + if (StringUtils.isNotBlank(taxAgentId)) { + param.setTaxAgentId(Long.parseLong(taxAgentId)); + } + String departmentIds = request.getParameter("departmentIds"); + if (StringUtils.isNotBlank(departmentIds)) { + param.setDepartmentIds(Arrays.stream(departmentIds.split(",")).map(Long::valueOf).collect(Collectors.toList())); + } + String positionIds = request.getParameter("positionIds"); + if (StringUtils.isNotBlank(positionIds)) { + param.setPositionIds(Arrays.stream(positionIds.split(",")).map(Long::valueOf).collect(Collectors.toList())); + } + String statuses = request.getParameter("statuses"); + if (StringUtils.isNotBlank(statuses)) { + param.setStatuses(Arrays.stream(statuses.split(",")).map(String::valueOf).collect(Collectors.toList())); + } + //fixme 日期 + request.getParameter("dismissDate"); + String ids = request.getParameter("ids"); + if (StringUtils.isNotBlank(ids)) { + param.setIds(Arrays.stream(ids.split(",")).map(Long::valueOf).collect(Collectors.toList())); + } + return param; + } + + /** + * 导出环比减少人员 + */ + @GET + @Path("/reducedemployee/export") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response exportReducedEmployee(@Context HttpServletRequest request, @Context HttpServletResponse response) { + try { + SalaryAcctEmployeeQueryParam param = buildSalaryAcctEmployeeQueryParam(request); + User user = HrmUserVarify.getUser(request, response); + XSSFWorkbook workbook = getSalaryAcctExcelWrapper(user).exportReducedEmployee(param); + String time = LocalDate.now().toString(); + String fileName = "环比上月减少人员" + time; + try { + fileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + StreamingOutput output = outputStream -> { + workbook.write(outputStream); + outputStream.flush(); + }; + response.setContentType("application/octet-stream"); + return Response.ok(output).header("Content-disposition", "attachment;filename=" + fileName).header("Cache-Control", "no-cache").build(); + } catch (Exception e) { + log.error("环比上月减少人员导出异常", e); + throw e; + } + } + + + /** + * 导出环比增加人员 + */ + @GET + @Path("/addedemployee/export") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response exportAddedEmployee(@Context HttpServletRequest request, @Context HttpServletResponse response) { + try { + SalaryAcctEmployeeQueryParam param = buildSalaryAcctEmployeeQueryParam(request); + User user = HrmUserVarify.getUser(request, response); + XSSFWorkbook workbook = getSalaryAcctExcelWrapper(user).exportAddedEmployee(param); + String time = LocalDate.now().toString(); + String fileName = "环比上月增加人员" + time; + try { + fileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + StreamingOutput output = outputStream -> { + workbook.write(outputStream); + outputStream.flush(); + }; + response.setContentType("application/octet-stream"); + return Response.ok(output).header("Content-disposition", "attachment;filename=" + fileName).header("Cache-Control", "no-cache").build(); + } catch (Exception e) { + log.error("环比上月增加人员导出异常", e); + throw e; + } + } + + + // **********************************薪资核算人员相关 end*********************************/ + + // **********************************薪资核算结果 start*********************************/ + @GET + @Path("/acctresult/checkAuth") + @Produces(MediaType.APPLICATION_JSON) + public String checkAuth(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam("salaryAcctRecordId") Long salaryAcctRecordId) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryAcctResultWrapper(user)::checkAuth, salaryAcctRecordId); + } + + //薪资核算结果列表 + @POST + @Path("/acctresult/list") + @Produces(MediaType.APPLICATION_JSON) + public String listSalaryAcctResult(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryAcctResultQueryParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalaryAcctResultWrapper(user)::listPage, param); + } + + //合计行 + @POST + @Path("/acctresult/sum") + @Produces(MediaType.APPLICATION_JSON) + public String sumSalaryAcctResult(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryAcctResultQueryParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalaryAcctResultWrapper(user)::sumSalaryAcctResult, param); + } + + + //薪资核算结果详情 + @GET + @Path("/acctresult/detail") + @Produces(MediaType.APPLICATION_JSON) + public String getSalaryAcctResultDetail(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "id") Long id) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryAcctResultWrapper(user)::getForm, id); + } + + //薪资核算结果详情 + @GET + @Path("/acctresult/getConsolidatedTaxDetail") + @Produces(MediaType.APPLICATION_JSON) + public String getConsolidatedTaxDetail(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "salaryAcctEmpId") Long salaryAcctEmpId) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryAcctResultWrapper(user)::getConsolidatedTaxDetail, salaryAcctEmpId); + } + + //根据薪资核算记录id获取表头数据 + @GET + @Path("/acctresult/getColumnDesc") + @Produces(MediaType.APPLICATION_JSON) + public String getColumnDesc(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "salaryAcctRecordId") Long salaryAcctRecordId) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalaryAcctResultWrapper(user)::getColumnBySalaryAcctRecordId, salaryAcctRecordId); + } + + //编辑薪资核算结果 + @POST + @Path("/acctresult/save") + @Produces(MediaType.APPLICATION_JSON) + public String saveSalaryAcctResult(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryAcctResultSaveParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryAcctResultWrapper(user)::save, param); + } + + + @POST + @Path("/acctresult/lock") + @Produces(MediaType.APPLICATION_JSON) + public String lock(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryAcctResultLockParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryAcctResultWrapper(user)::lock, param); + } + + //更新薪资项目锁定状态 + @POST + @Path("/acctresult/updateLockStatus") + @Produces(MediaType.APPLICATION_JSON) + public String updateLockStatus(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryAcctResultUpdateLockStatusParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryAcctResultWrapper(user)::updateLockStatusByParam, param); + } + + @POST + @Path("/acctresult/lockEmp") + @Produces(MediaType.APPLICATION_JSON) + public String lock(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryAcctResultUpdateLockStatusParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryAcctEmployeeWrapper(user)::lockEmp, param); + } + + //批量更新 + @POST + @Path("/acctresult/batchUpdate") + @Produces(MediaType.APPLICATION_JSON) + public String batchUpdate(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryAcctResultBatchUpdateParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryAcctResultWrapper(user)::batchUpdate, param); + } + + //薪资核算 + @POST + @Path("/acctresult/accounting") + @Produces(MediaType.APPLICATION_JSON) + public String accounting(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryAcctCalculateParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryAcctResultWrapper(user)::calculate, param); + } + + //导出核算结果 + @GET + @Path("/acctresult/export") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response exportSalaryAcctResult(@Context HttpServletRequest request, @Context HttpServletResponse response) { + try { + SalaryAcctResultQueryParam param = new SalaryAcctResultQueryParam(); + setSalaryAcctResultQueryParam(request, param); + User user = HrmUserVarify.getUser(request, response); + XSSFWorkbook workbook = getSalaryAcctExcelWrapper(user).exportSalaryAcctResult(param); + String fileName = "薪资核算结果" + LocalDate.now(); + try { + fileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + StreamingOutput output = outputStream -> { + workbook.write(outputStream); + outputStream.flush(); + }; + response.setContentType("application/octet-stream"); + return Response.ok(output).header("Content-disposition", "attachment;filename=" + fileName).header("Cache-Control", "no-cache").build(); + } catch (Exception e) { + log.error("薪资核算结果导出异常", e); + throw e; + } + } + + //导出核算结果(自定义导出字段) + @GET + @Path("/acctresult/exportWithCustomFields") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response exportSalaryAcctResultWithCustomFields(@Context HttpServletRequest request, @Context HttpServletResponse response) { + try { + SalaryAcctResultQueryParam param = new SalaryAcctResultQueryParam(); + setSalaryAcctResultQueryParam(request, param); + //设置自定义导出字段 + String salaryItemIds = request.getParameter("salaryItemIds"); + if (StringUtils.isNotBlank(salaryItemIds)) { + param.setSalaryItemIds(Arrays.stream(salaryItemIds.split(",")).map(Long::valueOf).collect(Collectors.toList())); + } + User user = HrmUserVarify.getUser(request, response); + XSSFWorkbook workbook = getSalaryAcctExcelWrapper(user).exportSalaryAcctResult(param); + String fileName = "薪资核算结果" + LocalDate.now(); + try { + fileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + StreamingOutput output = outputStream -> { + workbook.write(outputStream); + outputStream.flush(); + }; + response.setContentType("application/octet-stream"); + return Response.ok(output).header("Content-disposition", "attachment;filename=" + fileName).header("Cache-Control", "no-cache").build(); + } catch (Exception e) { + log.error("薪资核算结果导出异常", e); + throw e; + } + } + + + //导入核算结果前生成导入模板时可选的薪资项目 + @GET + @Path("/acctresult/importField") + @Produces(MediaType.APPLICATION_JSON) + public String accounting(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "salaryAcctRecordId") Long salaryAcctRecordId) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryAcctExcelService(user)::getImportField, salaryAcctRecordId); + } + + //导出核算结果前生成可选的薪资项目 + @GET + @Path("/acctresult/exportField") + @Produces(MediaType.APPLICATION_JSON) + public String exportField(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "salaryAcctRecordId") Long salaryAcctRecordId) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryAcctExcelService(user)::getExportField, salaryAcctRecordId); + } + + // 薪资核算导入字段缓存 + @POST + @Path("/acctresult/cacheImportField") + @Produces(MediaType.APPLICATION_JSON) + public String cacheImportField(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryAcctResultTemplateSaveParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryAcctExcelService(user)::cacheImportField, param); + } + + // 薪资核算导出字段缓存 + @POST + @Path("/acctresult/cacheExportField") + @Produces(MediaType.APPLICATION_JSON) + public String cacheExportField(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryAcctImportParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult, String>(user).run(getSalaryAcctExcelService(user)::cacheExportField, param.getSalaryItems()); + } + + // 保存导出模板 + @POST + @Path("/acctresult/saveExportTemplate") + @Produces(MediaType.APPLICATION_JSON) + public String saveExportTemplate(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryAcctResultTemplateSaveParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryAcctExcelService(user)::saveExportTemplate, param); + } + + // 删除导出模板 + @POST + @Path("/acctresult/deleteExportTemplate") + @Produces(MediaType.APPLICATION_JSON) + public String deleteExportTemplate(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryAcctResultTemplateSaveParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult, String>(user).run(getSalaryAcctExcelService(user)::deleteExportTemplate, param.getIds()); + } + + // 获取导出模板详细信息 + @POST + @Path("/acctresult/getExportTemplateForm") + @Produces(MediaType.APPLICATION_JSON) + public String getExportTemplateForm(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryAcctResultTemplateSaveParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalaryAcctExcelService(user)::getExportTemplateForm, param.getId()); + } + + // 获取导出模列表 + @POST + @Path("/acctresult/exportTemplateList") + @Produces(MediaType.APPLICATION_JSON) + public String exportTemplateList(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryAcctResultTemplateSaveParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalaryAcctExcelService(user)::exportTemplateList, param); + } + + + //导出导入模板 + @GET + @Path("/acctresult/importtemplate/export") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response exportImportTemplate(@Context HttpServletRequest request, @Context HttpServletResponse response) { + try { + SalaryAcctImportTemplateParam param = new SalaryAcctImportTemplateParam(); + setSalaryAcctResultQueryParam(request, param); + + String importType = request.getParameter("importType"); + if (StringUtils.isNotBlank(importType)) { + param.setImportType(importType); + } + String salaryItemIds = request.getParameter("salaryItemIds"); + if (StringUtils.isNotBlank(salaryItemIds)) { + param.setSalaryItemIds(Arrays.stream(salaryItemIds.split(",")).map(Long::valueOf).collect(Collectors.toList())); + } + + User user = HrmUserVarify.getUser(request, response); + XSSFWorkbook workbook = getSalaryAcctExcelWrapper(user).exportImportTemplate(param); + String time = LocalDate.now().toString(); + String fileName = "薪资核算导入模板" + time; + try { + fileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + StreamingOutput output = outputStream -> { + workbook.write(outputStream); + outputStream.flush(); + }; + response.setContentType("application/octet-stream"); + return Response.ok(output).header("Content-disposition", "attachment;filename=" + fileName).header("Cache-Control", "no-cache").build(); + } catch (Exception e) { + log.error("薪资核算导入模板导出异常", e); + throw e; + } + + } + + //导入核算结果 + @POST + @Path("/acctresult/importSalaryAcctResult") + @Produces(MediaType.APPLICATION_JSON) + public String importSalaryAcctResult(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryAcctImportParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalaryAcctExcelService(user)::importSalaryAcctResult, param); + } + + @POST + @Path("/acctresult/preview") + @Produces(MediaType.APPLICATION_JSON) + public String importSalaryAcctResultPreview(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryAcctImportParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryAcctExcelService(user)::previewImportSalaryAcctResult, param); + } + + // **********************************薪资核算结果 end*********************************/ + + // **********************************检验异常 start*********************************/ + +// @GetMapping("/checkresult/getCount") +// @ApiOperation(("获取校验结果(异常)总数")) +// @WeaPermission +// public WeaResult getCheckResultCount(@RequestParam(value = "salaryAcctRecordId") Long salaryAcctRecordId) { +// Integer salaryCheckResultCount = salaryAcctCheckResultWrapper.countBySalaryAcctRecordId(salaryAcctRecordId, TenantContext.getCurrentTenantKey()); +// return WeaResult.success(salaryCheckResultCount); +// } +// +// @PostMapping("/checkresult/list") +// @ApiOperation("校验结果列表") +// @WeaPermission +// public WeaResult> listCheckResult(@RequestBody @Validated SalaryCheckResultQueryParam queryParam) { +// WeaTable weaTable = salaryAcctCheckResultWrapper.listPage(queryParam, TenantContext.getCurrentTenantKey()); +// return WeaResult.success(weaTable); +// } +// +// @PostMapping("/checkresultdetail/list") +// @ApiOperation("校验结果明细列表") +// @WeaPermission +// public WeaResult> listCheckResultRecord(@RequestBody @Validated SalaryCheckResultRecordQueryParam queryParam) { +// WeaTable weaTable = salaryAcctCheckResultWrapper.listPage4CheckResultRecord(queryParam, TenantContext.getCurrentTenantKey()); +// return WeaResult.success(weaTable); +// } +// +// @PostMapping("/checkresult/ignore") +// @ApiOperation("校验结果列表") +// @WeaPermission +// public WeaResult ignoreCheckResult(@RequestParam(value = "id") Long id) { +// salaryAcctCheckResultWrapper.ignoreById(id, TenantContext.getCurrentTenantKey()); +// return WeaResult.success(null); +// } +// +// @PostMapping("/checkresult/ignoreAll") +// @ApiOperation("校验结果列表") +// @WeaPermission +// public WeaResult ignoreAllCheckResult(@RequestParam(value = "salaryAcctRecordId") Long salaryAcctRecordId) { +// salaryAcctCheckResultWrapper.ignoreBySalaryAcctRecordId(salaryAcctRecordId, TenantContext.getCurrentTenantKey()); +// return WeaResult.success(null); +// } +// +// @PostMapping("/acctresult/check") +// @ApiOperation(("薪资核算结果校验")) +// @WeaPermission +// public WeaResult check(@RequestBody @Validated SalaryAcctCheckParam checkParam) { +// salaryAcctResultWrapper.check(checkParam, UserContext.getCurrentUser(), TenantContext.getCurrentTenantKey()); +// return WeaResult.success(null); +// } +// +// @PostMapping("/checkresult/export") +// @ApiOperation("校验异常导出") +// @WeaPermission +// public WeaResult> exportCheckResult(@RequestBody @Validated SalaryCheckResultExportParam exportParam) { +// DataCollectionEmployee simpleEmployee = UserContext.getCurrentUser(); +// String tenantKey = TenantContext.getCurrentTenantKey(); +// String eteamsId = TenantRpcContext.getEteamsId(); +// Map map = salaryAcctExcelWrapper.exportCheckResult(exportParam, simpleEmployee, tenantKey, eteamsId); +// return WeaResult.success(map); +// } +// +// @PostMapping("/checkresultRecord/export") +// @ApiOperation("校验异常明细导出") +// @WeaPermission +// public WeaResult> exportCheckResultDetail(@RequestParam(value = "checkResultId") Long checkResultId) { +// DataCollectionEmployee simpleEmployee = UserContext.getCurrentUser(); +// String tenantKey = TenantContext.getCurrentTenantKey(); +// String eteamsId = TenantRpcContext.getEteamsId(); +// Map map = salaryAcctExcelWrapper.exportCheckResultDetail(checkResultId, simpleEmployee, tenantKey, eteamsId); +// return WeaResult.success(map); +// } +// + // **********************************检验异常 end*********************************/ + + // **********************************线下对比 start*********************************/ + + //线上线下对比结果列表 + @POST + @Path("/comparisonresult/list") + @Produces(MediaType.APPLICATION_JSON) + public String listComparisonResult(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryComparisonResultQueryParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalaryComparisonResultWrapper(user)::listPage, param); + } + + + //导出线上线下对比结果 + @GET + @Path("/comparisonresult/export") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response exportComparisonResult(@Context HttpServletRequest request, @Context HttpServletResponse response) { + try { + SalaryComparisonResultQueryParam param = new SalaryComparisonResultQueryParam(); + + setSalaryAcctResultQueryParam(request, param); + String onlyDiffEmployee = request.getParameter("onlyDiffEmployee"); + if (StringUtils.isNotBlank(onlyDiffEmployee)) { + param.setOnlyDiffEmployee(Boolean.parseBoolean(onlyDiffEmployee)); + } + String onlyDiffSalaryItem = request.getParameter("onlyDiffSalaryItem"); + if (StringUtils.isNotBlank(onlyDiffSalaryItem)) { + param.setOnlyDiffSalaryItem(Boolean.parseBoolean(onlyDiffSalaryItem)); + } + + User user = HrmUserVarify.getUser(request, response); + XSSFWorkbook workbook = getSalaryAcctExcelWrapper(user).exportComparisonResult(param); + String time = LocalDate.now().toString(); + String fileName = "线下对比结果" + time; + try { + fileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + StreamingOutput output = outputStream -> { + workbook.write(outputStream); + outputStream.flush(); + }; + response.setContentType("application/octet-stream"); + return Response.ok(output).header("Content-disposition", "attachment;filename=" + fileName).header("Cache-Control", "no-cache").build(); + } catch (Exception e) { + log.error("线下对比结果导出异常", e); + throw e; + } + } + + private void setSalaryAcctResultQueryParam(HttpServletRequest request, SalaryAcctResultQueryParam param) { + String salaryAcctRecordId = request.getParameter("salaryAcctRecordId"); + if (StringUtils.isNotBlank(salaryAcctRecordId)) { + param.setSalaryAcctRecordId(Long.parseLong(salaryAcctRecordId)); + } + String employeeName = request.getParameter("employeeName"); + if (StringUtils.isNotBlank(employeeName)) { + param.setEmployeeName(employeeName); + } + String taxAgentId = request.getParameter("taxAgentId"); + if (StringUtils.isNotBlank(taxAgentId)) { + param.setTaxAgentId(Long.parseLong(taxAgentId)); + } + String departmentIds = request.getParameter("departmentIds"); + if (StringUtils.isNotBlank(departmentIds)) { + param.setDepartmentIds(Arrays.stream(departmentIds.split(",")).map(Long::valueOf).collect(Collectors.toList())); + } + String positionIds = request.getParameter("positionIds"); + if (StringUtils.isNotBlank(positionIds)) { + param.setPositionIds(Arrays.stream(positionIds.split(",")).map(Long::valueOf).collect(Collectors.toList())); + } + String status = request.getParameter("status"); + if (StringUtils.isNotBlank(status)) { + param.setStatus(SalaryEmployeeStatusEnum.parseByValue(Integer.parseInt(status))); + } + String statuses = request.getParameter("statuses"); + if (StringUtils.isNotBlank(statuses)) { + param.setStatuses(Arrays.stream(statuses.split(",")).map(String::valueOf).collect(Collectors.toList())); + } + //fixme 日期 + request.getParameter("dismissDate"); + String consolidatedTaxation = request.getParameter("consolidatedTaxation"); + if (StringUtils.isNotBlank(consolidatedTaxation)) { + param.setConsolidatedTaxation(consolidatedTaxation); + } + String ids = request.getParameter("ids"); + if (StringUtils.isNotBlank(ids)) { + param.setIds(Arrays.stream(ids.split(",")).map(Long::valueOf).collect(Collectors.toList())); + } + String workcode = request.getParameter("workcode"); + if (StringUtils.isNotBlank(workcode)) { + param.setWorkcode(workcode); + } + String subcompanyIds = request.getParameter("subcompanyIds"); + if (StringUtils.isNotBlank(subcompanyIds)) { + param.setSubcompanyIds(Arrays.stream(subcompanyIds.split(",")).map(Long::valueOf).collect(Collectors.toList())); + } + } + + + //线下对比结果导入模板导出 + @GET + @Path("/comparisonresult/importtemplate/export") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response exportComparisonResultTemplate(@Context HttpServletRequest request, @Context HttpServletResponse response) { + + try { + SalaryComparisonResultExportParam param = new SalaryComparisonResultExportParam(); + String salaryAcctRecordId = request.getParameter("salaryAcctRecordId"); + if (StringUtils.isNotBlank(salaryAcctRecordId)) { + param.setSalaryAcctRecordId(Long.parseLong(salaryAcctRecordId)); + } + + User user = HrmUserVarify.getUser(request, response); + XSSFWorkbook workbook = getSalaryAcctExcelWrapper(user).exportComparisonResultTemplate(param); + String time = LocalDate.now().toString(); + String fileName = "线下对比结果导入模板" + time; + try { + fileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + StreamingOutput output = outputStream -> { + workbook.write(outputStream); + outputStream.flush(); + }; + response.setContentType("application/octet-stream"); + return Response.ok(output).header("Content-disposition", "attachment;filename=" + fileName).header("Cache-Control", "no-cache").build(); + } catch (Exception e) { + log.error("线下对比结果导入模板导出异常", e); + throw e; + } + } + + //导入线下核算结果 + @POST + @Path("/comparisonresult/importExcelAcctResult") + @Produces(MediaType.APPLICATION_JSON) + public String importExcelAcctResult(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryAcctImportParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalaryAcctExcelService(user)::importExcelAcctResult, param); + } + + @POST + @Path("/comparisonresult/preview") + @Produces(MediaType.APPLICATION_JSON) + public String importExcelAcctResultPreview(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryAcctImportParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalaryAcctExcelService(user)::preview, param); + } + + /**********************************线下对比 end*********************************/ +} diff --git a/src/com/engine/salary/web/SalaryArchiveController.java b/src/com/engine/salary/web/SalaryArchiveController.java new file mode 100644 index 000000000..8bb205be2 --- /dev/null +++ b/src/com/engine/salary/web/SalaryArchiveController.java @@ -0,0 +1,1035 @@ +package com.engine.salary.web; + +import com.engine.common.util.ServiceUtil; +import com.engine.salary.entity.salaryarchive.dto.*; +import com.engine.salary.entity.salaryarchive.param.*; +import com.engine.salary.enums.salaryarchive.SalaryArchiveImportTypeEnum; +import com.engine.salary.enums.salaryarchive.SalaryArchiveListTypeEnum; +import com.engine.salary.enums.salaryarchive.SalaryArchiveStatusEnum; +import com.engine.salary.util.ResponseResult; +import com.engine.salary.util.SalaryDateUtil; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.wrapper.SalaryArchiveItemWrapper; +import com.engine.salary.wrapper.SalaryArchiveTaxAgentWrapper; +import com.engine.salary.wrapper.SalaryArchiveWrapper; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.math.NumberUtils; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.StreamingOutput; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.time.LocalDate; +import java.util.*; +import java.util.stream.Collectors; + +/** + * 薪资档案 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Slf4j +public class SalaryArchiveController { + private SalaryArchiveWrapper getSalaryArchiveWrapper(User user) { + return ServiceUtil.getService(SalaryArchiveWrapper.class, user); + } + + private SalaryArchiveItemWrapper getSalaryArchiveItemWrapper(User user) { + return ServiceUtil.getService(SalaryArchiveItemWrapper.class, user); + } + + private SalaryArchiveTaxAgentWrapper getSalaryArchiveTaxAgentWrapper(User user) { + return ServiceUtil.getService(SalaryArchiveTaxAgentWrapper.class, user); + } + + +// /******** 薪资档案主表 start ***********************************************************************************************/ + + + /** + * 获取各tab总人数 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/queryTabTotal") + @Produces(MediaType.APPLICATION_JSON) + public String queryTabTotal(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalaryArchiveWrapper(user)::queryTabTotal); + } + + + /** + * 待定薪列表 + * + * @return + */ + @POST + @Path("/pendingList") + @Produces(MediaType.APPLICATION_JSON) + public String pendingList(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryArchiveQueryParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalaryArchiveWrapper(user)::pendingList, queryParam); + } + + + /** + * 设为定薪员工 + * + * @param ids + * @return + */ + @POST + @Path("/gotoFixed") + @Produces(MediaType.APPLICATION_JSON) + public String gotoFixed(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Collection ids) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult, Map>(user).run(getSalaryArchiveWrapper(user)::gotoFixed, ids); + } + + + /** + * 一键全部设为定薪员工 + * + * @param queryParam + * @return + */ + @POST + @Path("/allGotoFixed") + @Produces(MediaType.APPLICATION_JSON) + public String allGotoFixed(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryArchiveQueryParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalaryArchiveWrapper(user)::allGotoFixed, queryParam); + } + + + /** + * 删除待定薪待办 + * + * @param ids + * @return + */ + @POST + @Path("/deletePendingTodo") + @Produces(MediaType.APPLICATION_JSON) + public String deletePendingTodo(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Collection ids) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult, String>(user).run(getSalaryArchiveWrapper(user)::deletePendingTodo, ids); + } + + /** + * 删除薪资档案(待定薪、停薪来自待定薪) + * + * @param ids + * @return + */ + @POST + @Path("/deleteSalaryArchive") + @Produces(MediaType.APPLICATION_JSON) + public String deleteSalaryArchive(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Collection ids) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult, String>(user).run(getSalaryArchiveWrapper(user)::deleteSalaryArchive, ids); + } + + + /** + * 发薪列表 + * + * @param queryParam + * @return + */ + @POST + @Path("/fixedList") + @Produces(MediaType.APPLICATION_JSON) + public String fixedList(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryArchiveQueryParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalaryArchiveWrapper(user)::fixedList, queryParam); + } + + + /** + * 待停薪列表 + * + * @param queryParam + * @return + */ + @POST + @Path("/suspendList") + @Produces(MediaType.APPLICATION_JSON) + public String suspendList(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryArchiveQueryParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalaryArchiveWrapper(user)::suspendList, queryParam); + } + + /** + * 停薪 + * + * @param ids + * @return + */ + @POST + @Path("/gotoStop") + @Produces(MediaType.APPLICATION_JSON) + public String gotoStop(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Collection ids) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult, Map>(user).run(getSalaryArchiveWrapper(user)::gotoStop, ids); + } + + + /** + * 一键全部停薪 + * + * @param queryParam + * @return + */ + @POST + @Path("/allGotoStop") + @Produces(MediaType.APPLICATION_JSON) + public String allGotoStop(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryArchiveQueryParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalaryArchiveWrapper(user)::allGotoStop, queryParam); + } + + + /** + * 删除待停薪待办 + * + * @param ids + * @return + */ + @POST + @Path("/deleteSuspendTodo") + @Produces(MediaType.APPLICATION_JSON) + public String stopList(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Collection ids) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult, String>(user).run(getSalaryArchiveWrapper(user)::deleteSuspendTodo, ids); + } + + /** + * 停薪列表 + * + * @param queryParam + * @return + */ + @POST + @Path("/stopList") + @Produces(MediaType.APPLICATION_JSON) + public String stopList(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryArchiveQueryParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalaryArchiveWrapper(user)::stopList, queryParam); + } + + /** + * 外部人员列表 + * + * @param request + * @param response + * @param queryParam + * @return + */ + @POST + @Path("/extList") + @Produces(MediaType.APPLICATION_JSON) + public String extList(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryArchiveQueryParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalaryArchiveWrapper(user)::extList, queryParam); + } + + + /** + * 取消停薪 + * + * @param ids + * @return + */ + @POST + @Path("/cancelStop") + @Produces(MediaType.APPLICATION_JSON) + public String cancelStop(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Collection ids) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult, String>(user).run(getSalaryArchiveWrapper(user)::cancelStop, ids); + } + + + /** + * 薪资档案列表 + * + * @param queryParam + * @return + */ + @POST + @Path("/list") + @Produces(MediaType.APPLICATION_JSON) + public String list(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryArchiveQueryParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalaryArchiveWrapper(user)::listPage, queryParam); + } + + /** + * 导出薪资档案 + * + * @return + */ + @GET + @Path("/exportList") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response exportList(@Context HttpServletRequest request, @Context HttpServletResponse response) { + try { + User user = HrmUserVarify.getUser(request, response); + SalaryArchiveQueryParam queryParam = buildParam(request); + + XSSFWorkbook workbook = getSalaryArchiveWrapper(user).exportList(queryParam); + + String fileName = "薪资档案" + LocalDate.now(); + try { + fileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + + StreamingOutput output = outputStream -> { + workbook.write(outputStream); + outputStream.flush(); + }; + + response.setContentType("application/octet-stream"); + return Response.ok(output).header("Content-disposition", "attachment;filename=" + fileName).header("Cache-Control", "no-cache").build(); + } catch (Exception e) { + log.error("薪资档案导出异常", e); + throw e; + } + + } + + /** + * 获取薪资档案详情表单 + * + * @return + */ + @GET + @Path("/getForm") + @Produces(MediaType.APPLICATION_JSON) + public String getFrom(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + String salaryArchiveIdStr = request.getParameter("salaryArchiveId"); + Long salaryArchiveId = null; + if (StringUtils.isNotBlank(salaryArchiveIdStr)) { + salaryArchiveId = Long.valueOf(salaryArchiveIdStr); + } + return new ResponseResult(user).run(getSalaryArchiveWrapper(user)::getFrom, salaryArchiveId); + } + + + /** + * 保存发薪设置 + * + * @param saveParam + * @return + */ + @POST + @Path("/savePaySet") + @Produces(MediaType.APPLICATION_JSON) + public String savePaySet(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryArchiveSetPaySaveParam saveParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryArchiveWrapper(user)::savePaySet, saveParam); + } + + + /** + * 获取离职时段设置表单 + * + * @return + */ + @GET + @Path("/getDimissionSetForm") + @Produces(MediaType.APPLICATION_JSON) + public String getDimissionSetForm(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalaryArchiveWrapper(user)::getDimissionSetForm); + } + + /** + * 保存离职时段设置 + * + * @return + */ + @POST + @Path("/saveDimissionSet") + @Produces(MediaType.APPLICATION_JSON) + public String saveDimissionSet(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryArchiveDimissionSaveParam saveParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryArchiveWrapper(user)::saveDimissionSet, saveParam); + } + + /** + * 获取导入类型 + * + * @return + */ + @GET + @Path("/getImportTypes") + @Produces(MediaType.APPLICATION_JSON) + public String getImportTypes(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>>(user).run(getSalaryArchiveWrapper(user)::getImportTypes); + } + + /** + * 下载导入模板 + * + * @return + */ + @GET + @Path("/downloadTemplate") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response downloadTemplate(@Context HttpServletRequest request, @Context HttpServletResponse response) { + try { + User user = HrmUserVarify.getUser(request, response); + SalaryArchiveQueryParam queryParam = buildParam(request); + + XSSFWorkbook workbook = getSalaryArchiveWrapper(user).downloadTemplate(queryParam); + + SalaryArchiveListTypeEnum listTypeEnum = queryParam.getListType(); + + // 待定薪列表 + boolean isPendingList = listTypeEnum == SalaryArchiveListTypeEnum.PENDING; + // 定薪列表 + boolean isFixedList = listTypeEnum == SalaryArchiveListTypeEnum.FIXED; + // 待停薪列表 + boolean isSuspendList = listTypeEnum == SalaryArchiveListTypeEnum.SUSPEND; + if (isPendingList) { + queryParam.setRunStatusList(Arrays.asList(SalaryArchiveStatusEnum.PENDING.getValue())); + } else if (isFixedList) { + queryParam.setRunStatusList(Arrays.asList(SalaryArchiveStatusEnum.FIXED.getValue(), SalaryArchiveStatusEnum.SUSPEND.getValue())); + } else if (isSuspendList) { + queryParam.setRunStatusList(Arrays.asList(SalaryArchiveStatusEnum.SUSPEND.getValue())); + } + + boolean isInit = SalaryArchiveImportTypeEnum.INIT.getValue().equals(queryParam.getImportType()); + boolean isSalaryItemAdjust = SalaryArchiveImportTypeEnum.SALARYITEMADJUST.getValue().equals(queryParam.getImportType()); + boolean isExtEmp = queryParam.isExtSalaryArchiveList(); + + // 名称 + String finalNameI18n = SalaryI18nUtil.getI18nLabel(101601, "薪资档案导入模板-") + + SalaryI18nUtil.getI18nLabel(listTypeEnum.getLabelId(), listTypeEnum.getDefaultLabel()); + if (isExtEmp) { + finalNameI18n += "-非系统人员"; + } + + if (isFixedList) { + // 初始化 + if (isInit) { + finalNameI18n += + "-" + SalaryI18nUtil.getI18nLabel(SalaryArchiveImportTypeEnum.INIT.getLabelId(), SalaryArchiveImportTypeEnum.INIT.getDefaultLabel()); + // 调薪 + } else if (isSalaryItemAdjust) { + finalNameI18n += "-" + SalaryI18nUtil + .getI18nLabel(SalaryArchiveImportTypeEnum.SALARYITEMADJUST.getLabelId(), SalaryArchiveImportTypeEnum.SALARYITEMADJUST.getDefaultLabel()); + } + } + + String fileName = finalNameI18n + LocalDate.now(); + + try { + fileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + + StreamingOutput output = outputStream -> { + workbook.write(outputStream); + outputStream.flush(); + }; + + response.setContentType("application/octet-stream"); + return Response.ok(output).header("Content-disposition", "attachment;filename=" + fileName).header("Cache-Control", "no-cache").build(); + } catch (Exception e) { + log.error("薪资档案导入模板导出异常", e); + throw e; + } + } + + @Nullable + private SalaryArchiveQueryParam buildParam(HttpServletRequest request) { + SalaryArchiveQueryParam param = new SalaryArchiveQueryParam(); + String ids = request.getParameter("ids"); + if (StringUtils.isNotBlank(ids)) { + param.setIds(Arrays.stream(ids.split(",")).map(Long::valueOf).collect(Collectors.toList())); + } + String username = request.getParameter("username"); + if (StringUtils.isNotBlank(username)) { + param.setUsername(username); + } + String workcode = request.getParameter("workcode"); + if (StringUtils.isNotBlank(workcode)) { + param.setWorkcode(workcode); + } + String taxAgentId = request.getParameter("taxAgentId"); + if (StringUtils.isNotBlank(taxAgentId)) { + param.setTaxAgentId(Long.valueOf(taxAgentId)); + } + String taxAgentIdsStr = request.getParameter("taxAgentIds"); + if (StringUtils.isNotBlank(taxAgentIdsStr)) { + List taxAgentIds = Arrays.stream(taxAgentIdsStr.split(",")).filter(NumberUtils::isCreatable).map(Long::valueOf).collect(Collectors.toList()); + param.setTaxAgentIds(taxAgentIds); + } + String departmentIds = request.getParameter("departmentIds"); + if (StringUtils.isNotBlank(departmentIds)) { + param.setDepartmentIds(Arrays.stream(departmentIds.split(",")).map(Long::valueOf).collect(Collectors.toList())); + } + String subcompanyIds = request.getParameter("subcompanyIds"); + if (StringUtils.isNotBlank(subcompanyIds)) { + param.setSubcompanyIds(Arrays.stream(subcompanyIds.split(",")).map(Long::valueOf).collect(Collectors.toList())); + } + String positionIds = request.getParameter("positionIds"); + if (StringUtils.isNotBlank(positionIds)) { + param.setPositionIds(Arrays.stream(positionIds.split(",")).map(Long::valueOf).collect(Collectors.toList())); + } + String userstatus = request.getParameter("userstatus"); + if (StringUtils.isNotBlank(userstatus)) { + param.setUserstatus(userstatus); + } + String statuses = request.getParameter("statuses"); + if (StringUtils.isNotBlank(statuses)) { + param.setStatuses(Arrays.stream(statuses.split(",")).map(String::valueOf).collect(Collectors.toList())); + } + String hiredate = request.getParameter("hiredate"); + if (StringUtils.isNotBlank(hiredate)) { + param.setHiredate(Arrays.asList(hiredate.split(","))); + } + String importType = request.getParameter("importType"); + param.setImportType(importType); + String hasData = request.getParameter("hasData"); + if (StringUtils.isNotBlank(hasData)) { + param.setHasData(Boolean.valueOf(hasData)); + } + String archiveStatus = request.getParameter("archiveStatus"); + if (StringUtils.isNotBlank(archiveStatus)) { + param.setArchiveStatus(archiveStatus); + } + String runStatusLists = request.getParameter("runStatusList"); + if (StringUtils.isNotBlank(runStatusLists)) { + param.setRunStatusList(Arrays.stream(runStatusLists.split(",")).collect(Collectors.toList())); + } + String listType = request.getParameter("listType"); + if (StringUtils.isNotBlank(listType)) { + param.setListType(SalaryArchiveListTypeEnum.parseByValue(listType)); + } + //1标识外部人员 + String extSalaryArchiveList = request.getParameter("extSalaryArchiveList"); + if (StringUtils.isNotBlank(extSalaryArchiveList)) { + param.setExtSalaryArchiveList("true".equals(extSalaryArchiveList)); + } + String payStartDateStartDateStr = request.getParameter("payStartDateStartDateStr"); + if (StringUtils.isNotBlank(payStartDateStartDateStr) && SalaryDateUtil.checkDay(payStartDateStartDateStr)) { + param.setPayStartDateStartDate(SalaryDateUtil.stringToDate(payStartDateStartDateStr)); + } + String payStartDateEndDateStr = request.getParameter("payStartDateEndDateStr"); + if (StringUtils.isNotBlank(payStartDateEndDateStr) && SalaryDateUtil.checkDay(payStartDateEndDateStr)) { + param.setPayStartDateEndDate(SalaryDateUtil.stringToDate(payStartDateEndDateStr)); + } + String payEndDateStartDateStr = request.getParameter("payEndDateStartDateStr"); + if (StringUtils.isNotBlank(payEndDateStartDateStr) && SalaryDateUtil.checkDay(payEndDateStartDateStr)) { + param.setPayEndDateStartDate(SalaryDateUtil.stringToDate(payEndDateStartDateStr)); + } + String payEndDateEndDateStr = request.getParameter("payEndDateEndDateStr"); + if (StringUtils.isNotBlank(payEndDateEndDateStr) && SalaryDateUtil.checkDay(payEndDateEndDateStr)) { + param.setPayEndDateEndDate(SalaryDateUtil.stringToDate(payEndDateEndDateStr)); + } + String adjustSalaryStartDateStr = request.getParameter("adjustSalaryStartDate"); + if (StringUtils.isNotBlank(adjustSalaryStartDateStr) && SalaryDateUtil.checkDay(adjustSalaryStartDateStr)) { + param.setAdjustSalaryStartDate(SalaryDateUtil.stringToDate(adjustSalaryStartDateStr)); + } + String adjustSalaryEndDate = request.getParameter("adjustSalaryEndDate"); + if (StringUtils.isNotBlank(adjustSalaryEndDate) && SalaryDateUtil.checkDay(adjustSalaryEndDate)) { + param.setAdjustSalaryEndDate(SalaryDateUtil.stringToDate(adjustSalaryEndDate)); + } + return param; + } + + + @POST + @Path("/preview") + @Produces(MediaType.APPLICATION_JSON) + public String preview(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryArchiveImportHandleParam importParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalaryArchiveWrapper(user)::preview, importParam); + } + + /** + * 导入薪资档案附件上传前置校验 + * + * @param importParam + * @return + */ + @POST + @Path("/checkImportSalaryArchive") + @Produces(MediaType.APPLICATION_JSON) + public String checkImportSalaryArchive(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryArchiveImportHandleParam importParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalaryArchiveWrapper(user)::checkImportSalaryArchiveParam, importParam); + } + + //导入 + @POST + @Path("/importSalaryArchive") + @Produces(MediaType.APPLICATION_JSON) + public String importSalaryArchive(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryArchiveImportHandleParam importParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalaryArchiveWrapper(user)::importSalaryArchive, importParam); + } + + //人员状态列表 + @GET + @Path("/searchCondition") + @Produces(MediaType.APPLICATION_JSON) + public String searchCondition(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalaryArchiveWrapper(user)::searchCondition); + } + + //停薪 + @POST + @Path("/stopSalary") + @Produces(MediaType.APPLICATION_JSON) + public String stopSalary(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryArchiveStopParam stopSalaryParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryArchiveWrapper(user)::stopSalary, stopSalaryParam); + } + + /** + * 同步所有档案起始发薪日期变为入职日期 + * + * @return + */ + @GET + @Path("/syncPayStartDate") + @Produces(MediaType.APPLICATION_JSON) + public String syncPayStartDate(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryArchiveWrapper(user)::syncPayStartDate); + } + + // ******** 薪资档案主表 end ***********************************************************************************************/ + + // ******** 薪资项目调整 start ***********************************************************************************************/ + + /** + * 获取薪资项目调整表单 + * + * @return + */ + @GET + @Path("/getSalaryItemForm") + @Produces(MediaType.APPLICATION_JSON) + public String getSalaryItemForm(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + String salaryArchiveIdStr = request.getParameter("salaryArchiveId"); + Long salaryArchiveId = null; + if (StringUtils.isNotBlank(salaryArchiveIdStr)) { + salaryArchiveId = Long.valueOf(salaryArchiveIdStr); + } + return new ResponseResult(user).run(getSalaryArchiveItemWrapper(user)::getSalaryItemForm, salaryArchiveId); + } + + + /** + * 获取薪资项目调整前的值 + * + * @param adjustBeforeParam + * @return + */ + @POST + @Path("/getSalaryItemAdjustBeforeValue") + @Produces(MediaType.APPLICATION_JSON) + public String getSalaryItemAdjustBeforeValue(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryItemAdjustBeforeParam adjustBeforeParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryArchiveItemWrapper(user)::getSalaryItemAdjustBeforeValue, adjustBeforeParam); + } + + /** + * 通过薪资档案的薪资项目id获取薪资项目调整表单 + * + * @return + */ + @GET + @Path("/getSalaryItemFormBySalaryArchiveItemId") + @Produces(MediaType.APPLICATION_JSON) + public String getSalaryItemFormBySalaryArchiveItemId(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + String salaryArchiveItemIdStr = request.getParameter("salaryArchiveItemId"); + Long salaryArchiveItemId = null; + if (StringUtils.isNotBlank(salaryArchiveItemIdStr)) { + salaryArchiveItemId = Long.valueOf(salaryArchiveItemIdStr); + } + return new ResponseResult(user).run(getSalaryArchiveItemWrapper(user)::getSalaryItemFormBySalaryArchiveItemId, salaryArchiveItemId); + } + + /** + * 保存薪资项目调整前校验 + */ + @POST + @Path("/checkSaveSalaryItem") + @Produces(MediaType.APPLICATION_JSON) + public String checkSaveSalaryItem(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryArchiveItemSaveParam saveParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryArchiveItemWrapper(user)::checkSaveSalaryItem, saveParam); + } + + + /** + * 保存薪资项目调整 + */ + @POST + @Path("/saveSalaryItem") + @Produces(MediaType.APPLICATION_JSON) + public String saveSalaryItem(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryArchiveItemSaveParam saveParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryArchiveItemWrapper(user)::saveSalaryItem, saveParam); + } + + + /** + * 删除薪资项目调整 + */ + @GET + @Path("/deleteSalaryItem") + @Produces(MediaType.APPLICATION_JSON) + public String deleteSalaryItem(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "salaryArchiveItemId") Long salaryArchiveItemId) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryArchiveItemWrapper(user)::deleteSalaryItem, salaryArchiveItemId); + } + + // ******** 薪资项目调整 end ***********************************************************************************************/ + + // ******** 个税扣缴义务人调整 start ***********************************************************************************************/ + + /** + * 获取个税扣缴义务人调整表单 + * + * @param salaryArchiveId + * @return + */ + @GET + @Path("/getTaxAgentForm") + @Produces(MediaType.APPLICATION_JSON) + public String getTaxAgentForm(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "salaryArchiveId") Long salaryArchiveId) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryArchiveTaxAgentWrapper(user)::getTaxAgentForm, salaryArchiveId); + } + + /** + * 通过薪资档案的个税扣缴义务人id获取个税扣缴义务人调整表单` + * + * @param salaryArchiveTaxAgentId + * @return + */ + @GET + @Path("/getTaxAgentFormBySalaryArchiveTaxAgentId") + @Produces(MediaType.APPLICATION_JSON) + public String getTaxAgentFormBySalaryArchiveTaxAgentId(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "salaryArchiveTaxAgentId") Long salaryArchiveTaxAgentId) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryArchiveTaxAgentWrapper(user)::getTaxAgentFormBySalaryArchiveTaxAgentId, salaryArchiveTaxAgentId); + } + + + /** + * 保存个税扣缴义务人调整 + * + * @param saveParam + * @return + */ + @POST + @Path("/saveTaxAgent") + @Produces(MediaType.APPLICATION_JSON) + public String saveTaxAgent(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryArchiveTaxAgentSaveParam saveParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryArchiveTaxAgentWrapper(user)::saveTaxAgent, saveParam); + } + + + /** + * 删除个税扣缴义务人调整 + * + * @param salaryArchiveTaxAgentId + * @return + */ + @GET + @Path("/deleteTaxAgent") + @Produces(MediaType.APPLICATION_JSON) + public String deleteTaxAgent(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "salaryArchiveTaxAgentId") Long salaryArchiveTaxAgentId) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryArchiveTaxAgentWrapper(user)::deleteTaxAgent, salaryArchiveTaxAgentId); + } + + // ******** 薪资项目调整 end ***********************************************************************************************/ + + // ******** 薪资项目调整记录 start ***********************************************************************************************/ + + + /** + * 薪资项目调整记录列表 + * + * @param queryParam + * @return + */ + @POST + @Path("/adjustRecord/salaryItemList") + @Produces(MediaType.APPLICATION_JSON) + public String adjustRecordList(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryItemAdjustRecordQueryParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalaryArchiveItemWrapper(user)::adjustRecordList, queryParam); + } + + /** + * 单个档案的薪资项目调整记录列表 + * + * @param queryParam + * @return + */ + @POST + @Path("/adjustRecord/singleSalaryItemList") + @Produces(MediaType.APPLICATION_JSON) + public String singleSalaryItemAdjustRecordList(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SingleSalaryItemAdjustRecordQueryParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalaryArchiveItemWrapper(user)::singleSalaryItemAdjustRecordList, queryParam); + } + + + /** + * @return String + * @description 编辑前获取薪资项目调整信息 + * @author Harryxzy + * @date 2022/11/15 9:25 + */ + @POST + @Path("/adjustRecord/getSingleSalaryItemInfo") + @Produces(MediaType.APPLICATION_JSON) + public String getSingleSalaryItemInfo(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SingleSalaryItemAdjustRecordListDTO queryParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryArchiveItemWrapper(user)::getSingleSalaryItemInfo, queryParam); + } + + /** + * @return String + * @description 单个档案的薪资项目调整的编辑 + * @author Harryxzy + * @date 2022/11/11 13:50 + */ + @POST + @Path("/adjustRecord/editSingleSalaryItem") + @Produces(MediaType.APPLICATION_JSON) + public String editSingleSalaryItem(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryArchiveItemSaveParam updateParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryArchiveItemWrapper(user)::editSingleSalaryItem, updateParam); + } + + + /** + * 导出薪资项目调整记录列表 + */ + @GET + @Path("/adjustRecord/exportSalaryItemList") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response exportSalaryItemList(@Context HttpServletRequest request, @Context HttpServletResponse response) { + try { + User user = HrmUserVarify.getUser(request, response); + + SalaryItemAdjustRecordQueryParam param = getSalaryItemAdjustRecordQueryParam(request); + + XSSFWorkbook workbook = getSalaryArchiveItemWrapper(user).exportAdjustRecordList(param); + + String fileName = "薪资项目调整记录" + LocalDate.now(); + + try { + fileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + + StreamingOutput output = outputStream -> { + workbook.write(outputStream); + outputStream.flush(); + }; + + response.setContentType("application/octet-stream"); + return Response.ok(output).header("Content-disposition", "attachment;filename=" + fileName).header("Cache-Control", "no-cache").build(); + + } catch (Exception e) { + log.error("薪资项目调整记录导出异常", e); + throw e; + } + + } + + @NotNull + private SalaryItemAdjustRecordQueryParam getSalaryItemAdjustRecordQueryParam(HttpServletRequest request) { + SalaryItemAdjustRecordQueryParam param = new SalaryItemAdjustRecordQueryParam(); + String ids = request.getParameter("ids"); + if (StringUtils.isNotBlank(ids)) { + param.setIds(Arrays.stream(ids.split(",")).map(Long::valueOf).collect(Collectors.toList())); + } + String salaryArchiveId = request.getParameter("salaryArchiveId"); + if (StringUtils.isNotBlank(salaryArchiveId)) { + param.setSalaryArchiveId(Long.parseLong(salaryArchiveId)); + } + String keyword = request.getParameter("keyword"); + if (StringUtils.isNotBlank(keyword)) { + param.setKeyword(keyword); + } + String username = request.getParameter("username"); + if (StringUtils.isNotBlank(username)) { + param.setUsername(username); + } + String employeeId = request.getParameter("employeeId"); + if (StringUtils.isNotBlank(employeeId)) { + param.setSalaryArchiveId(Long.parseLong(employeeId)); + } + String departmentIds = request.getParameter("departmentIds"); + if (StringUtils.isNotBlank(departmentIds)) { + param.setDepartmentIds(Arrays.stream(departmentIds.split(",")).map(Long::valueOf).collect(Collectors.toList())); + } + String positionIds = request.getParameter("positionIds"); + if (StringUtils.isNotBlank(positionIds)) { + param.setPositionIds(Arrays.stream(positionIds.split(",")).map(Long::valueOf).collect(Collectors.toList())); + } + String userstatus = request.getParameter("userstatus"); + if (StringUtils.isNotBlank(userstatus)) { + param.setUserstatus(userstatus); + } + String adjustItem = request.getParameter("adjustItem"); + if (StringUtils.isNotBlank(adjustItem)) { + param.setAdjustItem(adjustItem); + } + String adjustReason = request.getParameter("adjustReason"); + if (StringUtils.isNotBlank(adjustReason)) { + param.setAdjustReason(adjustReason); + } + + String effectiveTime = request.getParameter("effectiveTime"); + if (StringUtils.isNotBlank(effectiveTime)) { + List collect = Arrays.stream(effectiveTime.split(",")).map(time -> SalaryDateUtil.parse(time, SalaryDateUtil.DATE_FORMATTER_PATTERN)).collect(Collectors.toList()); + param.setEffectiveTime(collect); + } + + String operateTime = request.getParameter("operateTime"); + if (StringUtils.isNotBlank(operateTime)) { + List collect = Arrays.stream(operateTime.split(",")).map(time -> SalaryDateUtil.parse(time, SalaryDateUtil.DATE_FORMATTER_PATTERN)).collect(Collectors.toList()); + param.setOperateTime(collect); + } + + String operatorIds = request.getParameter("operatorIds"); + if (StringUtils.isNotBlank(operatorIds)) { + param.setOperatorIds(Arrays.stream(operatorIds.split(",")).map(Long::valueOf).collect(Collectors.toList())); + } + + String description = request.getParameter("description"); + if (StringUtils.isNotBlank(description)) { + param.setUserstatus(description); + } + return param; + } + + /******** 薪资项目调整记录 end ***********************************************************************************************/ + + /******** 个税扣缴义务人调整记录 start ***********************************************************************************************/ + + /** + * 个税扣缴义务人调整记录列表 + * + * @param queryParam + * @return + */ + @POST + @Path("/adjustRecord/taxAgentList") + @Produces(MediaType.APPLICATION_JSON) + public String taxAgentList(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody TaxAgentAdjustRecordQueryParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalaryArchiveTaxAgentWrapper(user)::adjustRecordList, queryParam); + } + + /** + * 单个档案的个税扣缴义务人调整记录列表 + * + * @param queryParam + * @return + */ + @POST + @Path("/adjustRecord/singleTaxAgentList") + @Produces(MediaType.APPLICATION_JSON) + public String SingleTaxAgentAdjustRecordList(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SingleTaxAgentAdjustRecordQueryParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalaryArchiveTaxAgentWrapper(user)::singleTaxAgentAdjustRecordList, queryParam); + } + + /** + * 导出个税扣缴义务人调整记录列表 + * + * @return + */ + @GET + @Path("/adjustRecord/exportTaxAgentList") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response exportTaxAgentList(@Context HttpServletRequest request, @Context HttpServletResponse response) { + try { + User user = HrmUserVarify.getUser(request, response); + + TaxAgentAdjustRecordQueryParam param = new TaxAgentAdjustRecordQueryParam(); + + XSSFWorkbook workbook = getSalaryArchiveTaxAgentWrapper(user).exportAdjustRecordList(param); + + String fileName = "个税扣缴义务人调整记录" + LocalDate.now(); + + try { + fileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + + StreamingOutput output = outputStream -> { + workbook.write(outputStream); + outputStream.flush(); + }; + + response.setContentType("application/octet-stream"); + return Response.ok(output).header("Content-disposition", "attachment;filename=" + fileName).header("Cache-Control", "no-cache").build(); + + } catch (Exception e) { + log.error("个税扣缴义务人调整记录导出异常", e); + throw e; + } + + } + + + /******** 个税扣缴义务人调整记录 end ***********************************************************************************************/ + + + @GET + @Path("/handleRepeatData") + @Produces(MediaType.APPLICATION_JSON) + public String SingleTaxAgentAdjustRecordList(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalaryArchiveWrapper(user)::handleRepeatData); + } + +} diff --git a/src/com/engine/salary/web/SalaryBillController.java b/src/com/engine/salary/web/SalaryBillController.java new file mode 100644 index 000000000..64437a579 --- /dev/null +++ b/src/com/engine/salary/web/SalaryBillController.java @@ -0,0 +1,820 @@ +package com.engine.salary.web; + +import com.engine.common.util.ServiceUtil; +import com.engine.salary.entity.salaryBill.dto.*; +import com.engine.salary.entity.salaryBill.param.*; +import com.engine.salary.enums.salarybill.SalarySendStatusEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.sys.enums.PayrollCheckTypeEnum; +import com.engine.salary.util.ResponseResult; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.wrapper.SalaryBillBaseSetWrapper; +import com.engine.salary.wrapper.SalarySendWrapper; +import com.engine.salary.wrapper.SalaryTemplateWrapper; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.math.NumberUtils; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import weaver.general.BaseBean; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.StreamingOutput; +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.time.LocalDate; +import java.util.*; +import java.util.stream.Collectors; + +/** + * @Description: 工资单 + */ +@Slf4j +public class SalaryBillController { + private final Boolean isLog = "true".equals(new BaseBean().getPropValue("hrmSalary", "log")); + + private SalaryTemplateWrapper getSalaryTemplateWrapper(User user) { + return ServiceUtil.getService(SalaryTemplateWrapper.class, user); + } + + private SalarySendWrapper getSalarySendWrapper(User user) { + return ServiceUtil.getService(SalarySendWrapper.class, user); + } + + private SalaryBillBaseSetWrapper getSalaryBillBaseSetWrapper(User user) { + return ServiceUtil.getService(SalaryBillBaseSetWrapper.class, user); + } + + + /******** 工资单模板 start ***********************************************************************************************/ + /** + * 工资单模板列表 + * + * @param queryParam + * @return + */ + @POST + @Path("/template/list") + @Produces(MediaType.APPLICATION_JSON) + public String templateList(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryTemplateQueryParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalaryTemplateWrapper(user)::list, queryParam); + } + + /** + * 获取工资单模板基础设置表单 + * + * @param id + * @return + */ + @GET + @Path("/template/getBaseForm") + @Produces(MediaType.APPLICATION_JSON) + public String getBaseForm(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam("id") Long id) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryTemplateWrapper(user)::getBaseForm, id); + } + + /** + * 获取工资单模板显示设置表单 + * + * @param id + * @return + */ + @GET + @Path("/template/getShowForm") + @Produces(MediaType.APPLICATION_JSON) + public String getShowForm(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam("id") Long id) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryTemplateWrapper(user)::getShowForm, id); + } + + /** + * 设置工资单模板薪资项显示名称 + * + * @return + */ + @POST + @Path("/template/saveItemShowName") + @Produces(MediaType.APPLICATION_JSON) + public String saveItemShowName(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody List param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult, String>(user).run(getSalaryTemplateWrapper(user)::saveItemShowName, param); + } + + /** + * 获取薪资项目设置 + * + * @param salarySobId + * @return + */ + @GET + @Path("/template/getSalaryItemSet") + @Produces(MediaType.APPLICATION_JSON) + public String getSalaryItemSet(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam("salarySobId") Long salarySobId) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalaryTemplateWrapper(user)::getSalaryItemSet, salarySobId); + } + + /** + * 获取短信薪资项目设置 + * + * @param salarySobId + * @return + */ + @GET + @Path("/template/getSmsSalaryItemSet") + @Produces(MediaType.APPLICATION_JSON) + public String getSmsSalaryItemSet(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam("salarySobId") Long salarySobId) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalaryTemplateWrapper(user)::getSmsSalaryItemSet, salarySobId); + } + + /** + * 获取可用的薪资项目 + */ + @POST + @Path("/template/getAvailableSalaryGroupSet") + @Produces(MediaType.APPLICATION_JSON) + public String getAvailableSalaryGroupSet(@Context HttpServletRequest request, @Context HttpServletResponse response, + @RequestBody SalaryBillSalaryGroupQueryParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user) + .run(getSalaryTemplateWrapper(user)::getSalaryGroupSet, param); + } + + /** + * 获取可用的薪资项目 + */ + @POST + @Path("/template/getAvailableSalaryItemSet") + @Produces(MediaType.APPLICATION_JSON) + public String getAvailableSalaryItemSet(@Context HttpServletRequest request, @Context HttpServletResponse response, + @RequestBody SalaryBillSalaryItemQueryParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user) + .run(getSalaryTemplateWrapper(user)::getSalaryItemSetGrouped, param); + } + + /** + * 获取工资单模板补发设置表单 + * + * @return + */ + @POST + @Path("/template/getReplenishForm") + @Produces(MediaType.APPLICATION_JSON) + public String getReplenishForm(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody ReplenishFormQueryParam replenishFormQueryParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryTemplateWrapper(user)::getReplenishForm, replenishFormQueryParam); + } + + + /** + * 工资单模板默认使用 + * + * @param defaultUseParam + * @return + */ + @POST + @Path("/template/defaultUse") + @Produces(MediaType.APPLICATION_JSON) + public String defaultUse(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryTemplateDefaultUseParam defaultUseParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalaryTemplateWrapper(user)::defaultUse, defaultUseParam); + } + + /** + * 新建工资单模板 + * + * @param saveParam + * @return + */ + @POST + @Path("/template/save") + @Produces(MediaType.APPLICATION_JSON) + public String save(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryTemplateSaveParam saveParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryTemplateWrapper(user)::save, saveParam); + } + + /** + * 编辑工资单模板 + * + * @param saveParam + * @return + */ + @POST + @Path("/template/update") + @Produces(MediaType.APPLICATION_JSON) + public String update(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryTemplateSaveParam saveParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryTemplateWrapper(user)::update, saveParam); + } + + /** + * 复制工资单模板 + * + * @param copyParam + * @return + */ + @POST + @Path("/template/copy") + @Produces(MediaType.APPLICATION_JSON) + public String copy(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryTemplateCopyParam copyParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryTemplateWrapper(user)::copy, copyParam); + } + + /** + * 删除工资单模板 + * + * @param ids + * @return + */ + @POST + @Path("/template/delete") + @Produces(MediaType.APPLICATION_JSON) + public String delete(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Collection ids) { + if (CollectionUtils.isEmpty(ids)) { + throw new SalaryRunTimeException("参数错误"); + } + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult, String>(user).run(getSalaryTemplateWrapper(user)::delete, ids); + } + + /** + * 获取薪资账套下拉列表 + * + * @return + */ + @POST + @Path("/template/selectSalarySobList") + @Produces(MediaType.APPLICATION_JSON) + public String selectSalarySobList(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult<>(user).run(getSalaryTemplateWrapper(user)::selectSalarySobList); + } + + /** + * 获取补发规则设置下拉列表 + * + * @return + */ + @GET + @Path("/template/getReplenishRuleSetOptions") + @Produces(MediaType.APPLICATION_JSON) + public String getReplenishRuleSetOptions(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam("salarySobId") Long salarySobId) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>>(user).run(getSalaryTemplateWrapper(user)::getReplenishRuleSetOptions, salarySobId); + } + + + /** + * 获取租户名 + * + * @return + */ +// @POST +// @Path("/template/getTenantName") +// @Produces(MediaType.APPLICATION_JSON) +// public String getTenantName(@Context HttpServletRequest request, @Context HttpServletResponse response) { +// return WeaResult.success(TenantContext.getCurrentTenant().getTenantName()); +// } + /******** 工资单模板 end ***********************************************************************************************/ + + /******** 工资单发放 start ***********************************************************************************************/ + /** + * 工资单发放列表 + * + * @param queryParam + * @return + */ + @POST + @Path("/send/list") + @Produces(MediaType.APPLICATION_JSON) + public String list(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalarySendQueryParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalarySendWrapper(user)::list, queryParam); + } + + /** + * 工资单发放基本信息 + * + * @return + */ + @GET + @Path("/send/getBaseInfo") + @Produces(MediaType.APPLICATION_JSON) + public String getBaseInfo(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "id") Long id) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalarySendWrapper(user)::getBaseInfo, id); + } + + /** + * 预览工资单 + * + * @param param + * @return + */ + @POST + @Path("/preview") + @Produces(MediaType.APPLICATION_JSON) + public String preview(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryPreviewParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalarySendWrapper(user)::preview, param); + } + + /** + * 工资单发放信息列表的高级搜索 + * + * @return + */ + @GET + @Path("/send/getInfoSearchCondition") + @Produces(MediaType.APPLICATION_JSON) + public String getInfoSearchCondition(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult<>(user).run(getSalarySendWrapper(user)::getInfoSearchCondition); + } + + /** + * 工资单发放信息列表 + * + * @param queryParam + * @return + */ + @POST + @Path("/send/infoList") + @Produces(MediaType.APPLICATION_JSON) + public String infoList(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalarySendInfoQueryParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + if (StringUtils.isNotBlank(queryParam.getDepartmentIdStr())) { + queryParam.setDepartmentIds(Arrays.stream(StringUtils.split(queryParam.getDepartmentIdStr(), ",")).map(Long::valueOf).collect(Collectors.toList())); + } + if (StringUtils.isNotBlank(queryParam.getSubCompanyIdStr())) { + queryParam.setSubCompanyIds(Arrays.stream(StringUtils.split(queryParam.getSubCompanyIdStr(), ",")).map(Long::valueOf).collect(Collectors.toList())); + } + return new ResponseResult>(user).run(getSalarySendWrapper(user)::infoList, queryParam); + } + + /** + * 工资单发放信息合计行 + * + * @param queryParam + * @return + */ + @POST + @Path("/send/sum") + @Produces(MediaType.APPLICATION_JSON) + public String sumSendResult(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalarySendInfoQueryParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalarySendWrapper(user)::sumSendResult, queryParam); + } + + /** + * 导出-工资单发放信息列表 + * + * @return + */ + @POST + @Path("/send/exportInfoList") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response exportInfoList(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalarySendInfoQueryParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + + XSSFWorkbook workbook = getSalarySendWrapper(user).exportInfoList(queryParam); + + String fileName = "工资单发放信息" + LocalDate.now(); + try { + fileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + + StreamingOutput output = outputStream -> { + workbook.write(outputStream); + outputStream.flush(); + }; + + response.setContentType("application/octet-stream"); + return Response.ok(output).header("Content-disposition", "attachment;filename=" + fileName).header("Cache-Control", "no-cache").build(); + } + + + /** + * 工资单批量发放信息列表 + * + * @param queryParam + * @return + */ + @POST + @Path("/send/batchSendInfoList") + @Produces(MediaType.APPLICATION_JSON) + public String batchSendInfoList(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalarySendInfoQueryParam queryParam) { + // 包含未发送、已撤回 + queryParam.setSendStatuss(Arrays.asList(SalarySendStatusEnum.UNSEND.getValue(), SalarySendStatusEnum.WITHDRAW.getValue())); + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalarySendWrapper(user)::infoList, queryParam); + +// WeaTable weaTable = salarySendWrapper.infoList(queryParam, UserContext.getCurrentEmployeeId(), TenantContext.getCurrentTenantKey()); +// weaTable.setOperatesPermission(new LinkedList<>()); +// weaTable.setOperates(new LinkedList<>()); +// return WeaResult.success(weaTable); + } + + /** + * 工资单批量撤回信息列表 + * + * @param queryParam + * @return + */ + @POST + @Path("/send/batchWithdrawInfoList") + @Produces(MediaType.APPLICATION_JSON) + public String batchWithdrawInfoList(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalarySendInfoQueryParam queryParam) { + // 包含已发送 + queryParam.setSendStatuss(Arrays.asList(SalarySendStatusEnum.ALREADYSEND.getValue())); + User user = HrmUserVarify.getUser(request, response); + + return new ResponseResult>(user).run(getSalarySendWrapper(user)::infoList, queryParam); + } + + /** + * 工资单发放 + * + * @param queryParam + * @return + */ + @POST + @Path("/send/grant") + @Produces(MediaType.APPLICATION_JSON) + public String grant(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalarySendGrantParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalarySendWrapper(user)::grant, queryParam); + } + + /** + * 工资单撤回 + * + * @param queryParam + * @return + */ + @POST + @Path("/send/withdraw") + @Produces(MediaType.APPLICATION_JSON) + public String withdraw(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalarySendWithdrawParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalarySendWrapper(user)::withdraw, queryParam); + } + + /** + * 工资单发放详情列表的高级搜索 + * + * @return + */ + @POST + @Path("/send/getDetailSearchCondition") + @Produces(MediaType.APPLICATION_JSON) + public String getDetailSearchCondition(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalarySendWrapper(user)::getDetailSearchCondition); + } + + /** + * 工资单发放详情列表 + * + * @param queryParam + * @return + */ + @POST + @Path("/send/detailList") + @Produces(MediaType.APPLICATION_JSON) + public String detailList(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalarySendDetailListQueryParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + // 处理入参复用方法 + SalarySendDetailQueryParam detailQueryParam = SalarySendDetailQueryParam.builder() + .userId(queryParam.getUserId()) + .departmentIds(CollectionUtils.isEmpty(queryParam.getDepartmentIds()) ? null : queryParam.getDepartmentIds()) + .salarySendId(queryParam.getSalarySendId()) + .mergeCountTax(queryParam.getMergeCountTax()) + .positionIds(SalaryEntityUtil.isNullOrEmpty(queryParam.getPosition()) ? null : Collections.singletonList(queryParam.getPosition())) + .taxAgentId(queryParam.getTaxAgent()) + .username(queryParam.getUsername()) + .userstatus(queryParam.getUserstatus()).build(); + detailQueryParam.setCurrent(queryParam.getCurrent()); + detailQueryParam.setPageSize(queryParam.getPageSize()); + + if (StringUtils.isNotBlank(queryParam.getSubCompanyIdStr())) { + detailQueryParam.setSubCompanyIds(Arrays.asList(StringUtils.split(queryParam.getSubCompanyIdStr(), ",")).stream().map(Long::new).collect(Collectors.toList())); + } + if (StringUtils.isNotBlank(queryParam.getDepartmentIdStr())) { + detailQueryParam.setDepartmentIds(Arrays.asList(StringUtils.split(queryParam.getDepartmentIdStr(), ",")).stream().map(Long::new).collect(Collectors.toList())); + } + return new ResponseResult>(user).run(getSalarySendWrapper(user)::detailList, detailQueryParam); + } + + /** + * 导出-工资单发放详情列表 + * + * @return + */ + @POST + @Path("/send/exportDetailList") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response exportDetailList(@Context HttpServletRequest request, @Context HttpServletResponse response,@RequestBody SalarySendDetailQueryParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + + // SalarySendDetailQueryParam queryParam = new SalarySendDetailQueryParam(); + // String salarySendId = request.getParameter("salarySendId"); + // String ids = request.getParameter("ids"); + // if (StringUtils.isNotBlank(ids)) { + // queryParam.setIds(Arrays.asList(ids.split(",")).stream().map(Long::new).collect(Collectors.toList())); + // } + // if (StringUtils.isNotBlank(salarySendId)) { + // queryParam.setSalarySendId(Long.parseLong(salarySendId)); + // } + XSSFWorkbook workbook = getSalarySendWrapper(user).exportDetailList(queryParam); + + String fileName = "工资单发放详情列表" + LocalDate.now(); + try { + fileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + + StreamingOutput output = outputStream -> { + workbook.write(outputStream); + outputStream.flush(); + }; + + response.setContentType("application/octet-stream"); + return Response.ok(output).header("Content-disposition", "attachment;filename=" + fileName).header("Cache-Control", "no-cache").build(); + } + +// @GET +// @Path("/exportPdf") +// @Produces({"application/pdf"}) +// public Response getPDF(@Context HttpServletRequest request, @Context HttpServletResponse response) { +// +// File f = new File("D:\\gzd\\2023-02\\1695104948592.pdf"); +// return Response.ok(f, "application/pdf").build(); +// +// } + + + /** + * 下载pdf前先进行校验 生成 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/genPdfBeforeExport") + @Produces(MediaType.APPLICATION_JSON) + public String genPdfBeforeExport(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + SalaryExportPdfParam salaryExportPdfParam = new SalaryExportPdfParam(); + String id = request.getParameter("id"); + if (StringUtils.isNotBlank(id)) { + salaryExportPdfParam.setId(Long.valueOf(id)); + } + String salarySendId = request.getParameter("salarySendId"); + if (StringUtils.isNotBlank(salarySendId)) { + salaryExportPdfParam.setSalarySendId(Long.valueOf(salarySendId)); + } + return new ResponseResult(user).run(getSalarySendWrapper(user)::genPdfBeforeExport, salaryExportPdfParam); + } + + @GET + @Path("/exportPdf") + public Response downloadPdfFile(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + SalaryExportPdfParam salaryExportPdfParam = new SalaryExportPdfParam(); + String id = request.getParameter("id"); + if (StringUtils.isNotBlank(id)) { + salaryExportPdfParam.setId(Long.valueOf(id)); + } + String salarySendId = request.getParameter("salarySendId"); + if (StringUtils.isNotBlank(salarySendId)) { + salaryExportPdfParam.setSalarySendId(Long.valueOf(salarySendId)); + } + + StreamingOutput fileStream = new StreamingOutput() { + @Override + public void write(java.io.OutputStream output) throws IOException, WebApplicationException { + String pdfPath = getSalarySendWrapper(user).exportPdf(salaryExportPdfParam); + java.nio.file.Path path = Paths.get(pdfPath); + byte[] data = Files.readAllBytes(path); + output.write(data); + output.flush(); + } + }; + + String fileName = "工资单"; + try { + fileName = URLEncoder.encode(fileName + ".pdf", "UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + return Response + .ok(fileStream, MediaType.APPLICATION_OCTET_STREAM) + .header("content-disposition", "attachment; filename =" + fileName) + .build(); + } + + /** + * 我的工资单列表 + * + * @param + * @return + */ + @POST + @Path("/getToken") + @Produces(MediaType.APPLICATION_JSON) + public String getToken(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryBillGetTokenParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalarySendWrapper(user)::getToken, param); + } + + /** + * 我的工资单列表 + * + * @param queryParam + * @return + */ + @POST + @Path("/mySalaryBillList") + @Produces(MediaType.APPLICATION_JSON) + public String mySalaryBillList(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryBillQueryParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalarySendWrapper(user)::mySalaryBillList, queryParam); + } + + /** + * 我的工资单 + * + * @param salaryInfoId + * @return + */ + @GET + @Path("/mySalaryBill") + @Produces(MediaType.APPLICATION_JSON) + public String mySalaryBill(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "salaryInfoId") Long salaryInfoId) { + User user = null; + user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalarySendWrapper(user)::mySalaryBill, salaryInfoId); + } + + /** + * 确认工资单 + * + * @param salaryInfoId + * @return + */ + @GET + @Path("/confirmSalaryBill") + @Produces(MediaType.APPLICATION_JSON) + public String confirmSalaryBill(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "salaryInfoId") Long salaryInfoId) { + User user = null; + String recipient = request.getParameter("recipient"); + String em_auth_userid = request.getParameter("em_auth_userid"); + log.info("salary recipient: {} em_auth_userid: {}", recipient, em_auth_userid); + if (StringUtils.isNotBlank(recipient) && NumberUtils.isCreatable(recipient)) { + user = new User(Integer.parseInt(recipient)); + } else if (StringUtils.isNotBlank(em_auth_userid) && NumberUtils.isCreatable(em_auth_userid)) { + user = new User(Integer.parseInt(em_auth_userid)); + } else { + user = HrmUserVarify.getUser(request, response); + } + return new ResponseResult>(user).run(getSalarySendWrapper(user)::confirmSalaryBill, salaryInfoId); + } + + /** + * 工资单反馈 + * + * @param salaryInfoId + * @return + */ + @GET + @Path("/feedBackSalaryBill") + @Produces(MediaType.APPLICATION_JSON) + public String feedBackSalaryBill(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "salaryInfoId") Long salaryInfoId) { + User user = null; + String recipient = request.getParameter("recipient"); + String em_auth_userid = request.getParameter("em_auth_userid"); + log.info("salary recipient: {} em_auth_userid: {}", recipient, em_auth_userid); + if (StringUtils.isNotBlank(recipient) && NumberUtils.isCreatable(recipient)) { + user = new User(Integer.parseInt(recipient)); + } else if (StringUtils.isNotBlank(em_auth_userid) && NumberUtils.isCreatable(em_auth_userid)) { + user = new User(Integer.parseInt(em_auth_userid)); + } else { + user = HrmUserVarify.getUser(request, response); + } + return new ResponseResult>(user).run(getSalarySendWrapper(user)::feedBackSalaryBill, salaryInfoId); + } + /******** 工资单发放 end ***********************************************************************************************/ + + /** + * 获取验证方式 + * + * @return + */ + @GET + @Path("/payrollCheckType") + @Produces(MediaType.APPLICATION_JSON) + public String payrollCheckType(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalarySendWrapper(user)::payrollCheckType); + } + + /** + * 短信验证码 + * + * @param param + * @return + */ + @POST + @Path("/sendMobileCode") + @Produces(MediaType.APPLICATION_JSON) + public String sendSMSCode(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SMSCodeSendParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalarySendWrapper(user)::sendMobileCode, param); + } + + /** + * 校验验证码 + * + * @param request + * @param response + * @param param + * @return + */ + @POST + @Path("/checkMobileCode") + @Produces(MediaType.APPLICATION_JSON) + public String checkMobileCode(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SMSCodeCheckParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalarySendWrapper(user)::checkMobileCode, param); + } + + /******** 工资单基础设置 start ***********************************************************************************************/ + + /** + * 获取工资单基础设置表单 + * + * @return + */ + @GET + @Path("/baseSet/getForm") + @Produces(MediaType.APPLICATION_JSON) +// @ApiOperation("获取工资单基础设置表单") + public String getBaseSetForm(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryBillBaseSetWrapper(user)::getBaseSetForm); + } + + /** + * 预览水印 + * + * @return + */ + @POST + @Path("/baseSet/previewWaterMark") + @Produces(MediaType.APPLICATION_JSON) + public String getBaseSetForm(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryBaseSetSaveParam saveParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryBillBaseSetWrapper(user)::previewWaterMark, saveParam); + } + + /** + * 保存工资单基础设置 + * + * @param saveParam 保存参数 + * @return + */ + @POST + @Path("/baseSet/save") + @Produces(MediaType.APPLICATION_JSON) +// @ApiOperation("保存工资单基础设置") + public String saveBaseSet(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryBaseSetSaveParam saveParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryBillBaseSetWrapper(user)::saveBaseSet, saveParam); + } + /******** 工资单基础设置 end ***********************************************************************************************/ + + +} diff --git a/src/com/engine/salary/web/SalaryCommonController.java b/src/com/engine/salary/web/SalaryCommonController.java new file mode 100644 index 000000000..8e47a22d6 --- /dev/null +++ b/src/com/engine/salary/web/SalaryCommonController.java @@ -0,0 +1,207 @@ +package com.engine.salary.web; + +import com.engine.common.util.ServiceUtil; +import com.engine.salary.entity.setting.dto.PageListTemplateDTO; +import com.engine.salary.entity.setting.dto.PageListTemplateDetailDTO; +import com.engine.salary.entity.setting.param.*; +import com.engine.salary.entity.setting.po.PageListSettingPO; +import com.engine.salary.entity.setting.po.PageListTemplatePO; +import com.engine.salary.util.ResponseResult; +import com.engine.salary.util.SalaryEnumUtil; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.wrapper.SalaryCommonWrapper; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import lombok.extern.slf4j.Slf4j; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.StreamingOutput; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.time.LocalDate; +import java.util.List; +import java.util.Map; + +@Slf4j +public class SalaryCommonController { + + private SalaryCommonWrapper getSalaryCommonWrapper(User user) { + return ServiceUtil.getService(SalaryCommonWrapper.class, user); + } + + @GET + @Path("/enum/list") + @Produces(MediaType.APPLICATION_JSON) + public String getSearchCondition(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "enumClass") String enumClass) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>>(user).run(SalaryEnumUtil::enumSelectList, enumClass); + } + + + @GET + @Path("/cache/info") + @Produces(MediaType.APPLICATION_JSON) + public String getCacheInfo(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "key") String key) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryCommonWrapper(user)::getCacheInfo, key); + } + + @GET + @Path("/cache/remove") + @Produces(MediaType.APPLICATION_JSON) + public String removeCache(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "key") String key) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryCommonWrapper(user)::removeCache, key); + } + + + /** + * 页面模板设置 + * + * @param param + * @return + */ + @POST + @Path("/pageList/save/setting") + @Produces(MediaType.APPLICATION_JSON) + public String savePageListSetting(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody PageListSettingSaveParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryCommonWrapper(user)::savePageListSetting, param); + } + + @POST + @Path("/pageList/reset/setting") + @Produces(MediaType.APPLICATION_JSON) + public String resetPageListSetting(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody PageListSettingResetParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryCommonWrapper(user)::resetPageListSetting, param); + } + + /** + * 页面默认值 + * @param request + * @param response + * @param param + * @return + */ + @POST + @Path("/pageList/get/setting") + @Produces(MediaType.APPLICATION_JSON) + public String getPageListSetting(@Context HttpServletRequest request, @Context HttpServletResponse response,@RequestBody PageListSettingQueryParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryCommonWrapper(user)::getPageListSetting, param); + } + + /** + * 页面模板表单 + * @param request + * @param response + * @param param + * @return + */ + @POST + @Path("/pageList/template/get") + @Produces(MediaType.APPLICATION_JSON) + public String getPageListTemplate(@Context HttpServletRequest request, @Context HttpServletResponse response,@RequestBody PageListTemplateQueryParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryCommonWrapper(user)::getPageListTemplate, param); + } + + /** + * 页面模板列表 + * @param request + * @param response + * @param param + * @return + */ + @POST + @Path("/pageList/template/list") + @Produces(MediaType.APPLICATION_JSON) + public String getPageListTemplates(@Context HttpServletRequest request, @Context HttpServletResponse response,@RequestBody PageListTemplateQueryParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalaryCommonWrapper(user)::getPageListTemplates, param); + } + + @POST + @Path("/pageList/template/pageList") + @Produces(MediaType.APPLICATION_JSON) + public String getTemplates(@Context HttpServletRequest request, @Context HttpServletResponse response,@RequestBody PageListTemplateQueryParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalaryCommonWrapper(user)::getTemplates, param); + } + + /** + * 页面模板列表 + * @param request + * @param response + * @param param + * @return + */ + @POST + @Path("/pageList/template/save") + @Produces(MediaType.APPLICATION_JSON) + public String savePageListTemplate(@Context HttpServletRequest request, @Context HttpServletResponse response,@RequestBody PageListTemplateSaveParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryCommonWrapper(user)::savePageListTemplate, param); + } + + @POST + @Path("/pageList/template/file/download") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response downloadPageExportTemplateFile(@Context HttpServletRequest request, @Context HttpServletResponse response,@RequestBody DownloadTemplateParam param) { + try { + User user = HrmUserVarify.getUser(request, response); + + XSSFWorkbook workbook = getSalaryCommonWrapper(user).downloadPageExportTemplateFile(param); + + String fileName = "薪资明细模板示例" + LocalDate.now(); + try { + fileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + + StreamingOutput output = outputStream -> { + workbook.write(outputStream); + outputStream.flush(); + }; + + response.setContentType("application/octet-stream"); + return Response.ok(output).header("Content-disposition", "attachment;filename=" + fileName).header("Cache-Control", "no-cache").build(); + } catch (Exception e) { + log.error("导出薪资明细模板异常", e); + throw e; + } + } + + @POST + @Path("/pageList/template/delete") + @Produces(MediaType.APPLICATION_JSON) + public String savePageListTemplate(@Context HttpServletRequest request, @Context HttpServletResponse response,@RequestBody PageListTemplateDeleteParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryCommonWrapper(user)::deletePageListTemplate, param); + } + + + /** + * 页面模板列表 + * @param request + * @param response + * @param param + * @return + */ + @POST + @Path("/pageList/template/change") + @Produces(MediaType.APPLICATION_JSON) + public String changeTemplate(@Context HttpServletRequest request, @Context HttpServletResponse response,@RequestBody PageListTemplateChangeParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryCommonWrapper(user)::changePageListTemplate, param); + } +} diff --git a/src/com/engine/salary/web/SalaryFieldController.java b/src/com/engine/salary/web/SalaryFieldController.java new file mode 100644 index 000000000..43c8bfbed --- /dev/null +++ b/src/com/engine/salary/web/SalaryFieldController.java @@ -0,0 +1,102 @@ +package com.engine.salary.web; + +import com.engine.common.util.ServiceUtil; +import com.engine.salary.entity.salaryitem.dto.SalaryItemFormDTO; +import com.engine.salary.entity.salaryitem.dto.SalaryItemListDTO; +import com.engine.salary.entity.salaryitem.param.SalaryItemSaveParam; +import com.engine.salary.entity.salaryitem.param.SalaryItemSearchParam; +import com.engine.salary.entity.salaryitem.po.SalaryItemPO; +import com.engine.salary.util.ResponseResult; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.wrapper.SalaryFieldWrapper; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import java.util.Collection; +import java.util.List; + +/** + * 薪资字段管理 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SalaryFieldController { + + private SalaryFieldWrapper getSalaryFieldWrapper(User user) { + return ServiceUtil.getService(SalaryFieldWrapper.class, user); + } + + /** + * 字段管理列表 + * @see + */ + @POST + @Path("/list") + @Produces(MediaType.APPLICATION_JSON) + public String listSalaryItem(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryItemSearchParam searchParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalaryFieldWrapper(user)::listPage, searchParam); + } + + /** + * 字段管理列表保存顺序 + * @see + */ + @POST + @Path("/saveSortedIndex") + @Produces(MediaType.APPLICATION_JSON) + public String saveSortedIndex(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody List saveList) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult, String>(user).run(getSalaryFieldWrapper(user)::saveSortedIndex, saveList); + } + + + /** + * 字段管理详情 + * @see + */ + @GET + @Path("/getSalaryForm") + @Produces(MediaType.APPLICATION_JSON) + public String getSalaryItemForm(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "id") Long id) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryFieldWrapper(user)::getForm, id); + } + + /** + * 删除 + * @see + */ + @POST + @Path("/delete") + @Produces(MediaType.APPLICATION_JSON) + public String deleteSalaryItem(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Collection ids) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult, String>(user).run(getSalaryFieldWrapper(user)::delete, ids); + } + + /** + * 保存字段管理 + * @see + */ + @POST + @Path("/save") + @Produces(MediaType.APPLICATION_JSON) + public String saveSalaryItem(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryItemSaveParam saveParam) { + User user = HrmUserVarify.getUser(request, response); + if (saveParam.getId() == null || saveParam.getId() <= 0) { + return new ResponseResult(user).run(getSalaryFieldWrapper(user)::save, saveParam); + } else { + return new ResponseResult(user).run(getSalaryFieldWrapper(user)::update, saveParam); + } + } +} diff --git a/src/com/engine/salary/web/SalaryFormulaController.java b/src/com/engine/salary/web/SalaryFormulaController.java new file mode 100644 index 000000000..d4ae5f8e7 --- /dev/null +++ b/src/com/engine/salary/web/SalaryFormulaController.java @@ -0,0 +1,104 @@ +package com.engine.salary.web; + +import com.engine.common.util.ServiceUtil; +import com.engine.salary.entity.salaryformula.dto.ExpressFormulaDTO; +import com.engine.salary.entity.salaryformula.param.SalaryFormulaDetailQueryParam; +import com.engine.salary.entity.salaryformula.param.SalaryFormulaFieldQueryParam; +import com.engine.salary.entity.salaryformula.param.SalaryFormulaMockParam; +import com.engine.salary.entity.salaryformula.param.SalaryFormulaSaveParam; +import com.engine.salary.entity.salaryformula.po.FormulaPO; +import com.engine.salary.entity.salaryformula.po.FormulaVar; +import com.engine.salary.formlua.constant.FormluaConstant; +import com.engine.salary.util.ResponseResult; +import com.engine.salary.wrapper.SalaryFormulaWrapper; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import lombok.extern.slf4j.Slf4j; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +@Slf4j +public class SalaryFormulaController { + + + private SalaryFormulaWrapper getSalaryFormulaWrapper(User user) { + return ServiceUtil.getService(SalaryFormulaWrapper.class, user); + } + + //变量项 + @POST + @Path("/search/group") + @Produces(MediaType.APPLICATION_JSON) + public String fieldGroupList(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Map param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult, List>>(user).run(getSalaryFormulaWrapper(user)::fieldGroupList, param); + } + + //变量字段列表 + @POST + @Path("/search/field") + @Produces(MediaType.APPLICATION_JSON) + public String fieldList(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryFormulaFieldQueryParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalaryFormulaWrapper(user)::fieldList, param); + } + + //获取公式详情 + @POST + @Path("/detail") + @Produces(MediaType.APPLICATION_JSON) + public String detail(@Context HttpServletRequest request, @Context HttpServletResponse response, SalaryFormulaDetailQueryParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryFormulaWrapper(user)::detail, queryParam); + } + + @POST + @Path("/save") + @Produces(MediaType.APPLICATION_JSON) + public String save(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryFormulaSaveParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryFormulaWrapper(user)::save, param); + } + + //数据源列表 + @GET + @Path("/datasource/list") + @Produces(MediaType.APPLICATION_JSON) + public String datasource(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryFormulaWrapper(user)::datasourceList); + } + + /** + * 测试公式 + * + * @param request + * @param response + * @param param + * @return + */ + @POST + @Path("/mock") + @Produces(MediaType.APPLICATION_JSON) + public String mock(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryFormulaMockParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryFormulaWrapper(user)::mock, param); + } + + + @GET + @Path("/des") + @Produces(MediaType.APPLICATION_JSON) + public String des(@Context HttpServletRequest request, @Context HttpServletResponse response) { + return FormluaConstant.DES; + } + +} diff --git a/src/com/engine/salary/web/SalaryItemController.java b/src/com/engine/salary/web/SalaryItemController.java new file mode 100644 index 000000000..115719b2c --- /dev/null +++ b/src/com/engine/salary/web/SalaryItemController.java @@ -0,0 +1,312 @@ +package com.engine.salary.web; + +import com.engine.common.util.ServiceUtil; +import com.engine.salary.component.WeaFormOption; +import com.engine.salary.entity.salaryitem.dto.SalaryItemFormDTO; +import com.engine.salary.entity.salaryitem.dto.SalaryItemListDTO; +import com.engine.salary.entity.salaryitem.dto.SysSalaryItemListDTO; +import com.engine.salary.entity.salaryitem.param.*; +import com.engine.salary.entity.salaryitem.po.SalaryItemPO; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.util.ResponseResult; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.excel.ImportExcelResponse; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.wrapper.SalaryItemWrapper; +import com.engine.salary.wrapper.SysSalaryItemWrapper; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.StreamingOutput; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.time.LocalDate; +import java.util.Collection; +import java.util.List; +import java.util.Map; + +/** + * 薪资项目 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Slf4j +public class SalaryItemController { + + private SalaryItemWrapper getSalaryItemWrapper(User user) { + return ServiceUtil.getService(SalaryItemWrapper.class, user); + } + + + private SysSalaryItemWrapper getSysSalaryItemWrapper(User user) { + return ServiceUtil.getService(SysSalaryItemWrapper.class, user); + } + + /**********************************自定义薪资项目 start*********************************/ + + /** + * 薪资项目列表 + */ + @POST + @Path("/list") + @Produces(MediaType.APPLICATION_JSON) + public String listSalaryItem(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryItemSearchParam searchParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(request, response, user).run(getSalaryItemWrapper(user)::listPage, searchParam); + } + + @POST + @Path("/listAuth") + @Produces(MediaType.APPLICATION_JSON) + public String listAuth(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryItemSearchParam searchParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(request, response, user).run(getSalaryItemWrapper(user)::listAuth, searchParam); + } + + + /** + * 可删除的薪资项目列表 + * + * @param request + * @param response + * @param searchParam + * @return + */ + @POST + @Path("/listCanDelete") + @Produces(MediaType.APPLICATION_JSON) + public String listCanDeleteSalaryItem(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryItemSearchParam searchParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalaryItemWrapper(user)::listPage4CanDelete, searchParam); + } + + /** + * 获取多个薪资项目的详情 + * + * @return + */ + @POST + @Path("/listSalaryItemDetail") + @Produces(MediaType.APPLICATION_JSON) + public String listSalaryItemDetail(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Collection ids) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult, List>(user).run(getSalaryItemWrapper(user)::listByIds, ids); + } + + +// @GetMapping("/getSearchCondition") +// @ApiOperation("薪资项目列表的高级搜索") +// @WeaPermission +// public WeaResult getSearchCondition() { +// return WeaResult.success(salaryItemWrapper.getSearchCondition()); +// } + + + /** + * 薪资项目的详情 + */ + @GET + @Path("/getSalaryForm") + @Produces(MediaType.APPLICATION_JSON) + public String getSalaryItemForm(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "id") Long id) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryItemWrapper(user)::getForm, id); + } + + /** + * 获取哪些账套中使用了该薪资项目 + */ + @GET + @Path("/getSalarySobBySalaryItem") + @Produces(MediaType.APPLICATION_JSON) + public String getSalarySobBySalaryItem(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "id") Long id) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>>(user).run(getSalaryItemWrapper(user)::getSalarySobBySalaryItem, id); + } + + /** + * 将薪资项目管理中的信息同步至账套 + */ + @POST + @Path("/syncSalaryItemToSalarySobItem") + @Produces(MediaType.APPLICATION_JSON) + public String syncSalaryItemToSalarySobItem(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SyncSalaryItemParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryItemWrapper(user)::syncSalaryItemToSalarySobItem, param); + } + + /** + * "获取薪资项目可选的类型(与属性有联动)" + * + * @return + */ + @GET + @Path("/listSalaryItemTypeOption") + @Produces(MediaType.APPLICATION_JSON) + public String listSalaryItemTypeOption(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>>(user).run(getSalaryItemWrapper(user)::listSalaryItemTypeOption); + } + + /** + * 删除 + */ + @POST + @Path("/delete") + @Produces(MediaType.APPLICATION_JSON) + public String deleteSalaryItem(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Collection ids) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult, String>(user).run(getSalaryItemWrapper(user)::delete, ids); + } + + /** + * 保存薪资项目 + */ + @POST + @Path("/save") + @Produces(MediaType.APPLICATION_JSON) + public String saveSalaryItem(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryItemSaveParam saveParam) { + User user = HrmUserVarify.getUser(request, response); + if (saveParam.getId() == null || saveParam.getId() <= 0) { + return new ResponseResult(request, response, user).run(getSalaryItemWrapper(user)::save, saveParam); + } else { + return new ResponseResult(request, response, user).run(getSalaryItemWrapper(user)::update, saveParam); + } + } + + /** + * 更新薪资项目 + */ + @POST + @Path("/update") + @Produces(MediaType.APPLICATION_JSON) + public String updateSalaryItem(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryItemSaveParam saveParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryItemWrapper(user)::update, saveParam); + } + + + @POST + @Path("/export") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response export(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryItemExportParam param) { + try { + User user = HrmUserVarify.getUser(request, response); + XSSFWorkbook workbook = getSalaryItemWrapper(user).export(param); + String time = LocalDate.now().toString(); + String fileName = "薪资项目" + time; + try { + fileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + StreamingOutput output = outputStream -> { + workbook.write(outputStream); + outputStream.flush(); + }; + response.setContentType("application/octet-stream"); + return Response.ok(output).header("Content-disposition", "attachment;filename=" + fileName).header("Cache-Control", "no-cache").build(); + } catch (Exception e) { + log.error("薪资项目下载失败", e); + throw e; + } + } + + @POST + @Path("/downloadTemplate") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response downloadTemplate(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryItemDownloadTemplateParam param) { + try { + User user = HrmUserVarify.getUser(request, response); + XSSFWorkbook workbook = getSalaryItemWrapper(user).downloadTemplate(param); + String time = LocalDate.now().toString(); + String fileName = "薪资项目导入模板" + time; + try { + fileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + StreamingOutput output = outputStream -> { + workbook.write(outputStream); + outputStream.flush(); + }; + response.setContentType("application/octet-stream"); + return Response.ok(output).header("Content-disposition", "attachment;filename=" + fileName).header("Cache-Control", "no-cache").build(); + } catch (Exception e) { + log.error("薪资项目导入模板", e); + throw e; + } + } + + @POST + @Path("/preview") + @Produces(MediaType.APPLICATION_JSON) + public String preview(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryItemImportParam importParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalaryItemWrapper(user)::preview, importParam); + } + + @POST + @Path("/import") + @Produces(MediaType.APPLICATION_JSON) + public String importSalaryItem(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryItemImportParam importParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryItemWrapper(user)::importSalaryItem, importParam); + } + + /**********************************自定义薪资项目 end*********************************/ + + + /**********************************系统薪资项目 start*********************************/ + + + /** + * 系统薪资项目列表 + */ + @POST + @Path("/sysList") + @Produces(MediaType.APPLICATION_JSON) + public String listSysSalaryItem(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SysSalaryItemSearchParam searchParam) { + User user = HrmUserVarify.getUser(request, response); + + return new ResponseResult>(user).run(getSysSalaryItemWrapper(user)::listPage, searchParam); + } + + +// @GetMapping("/getSysSearchCondition") +// @ApiOperation("系统薪资项目的高级搜索") +// @WeaPermission +// public WeaResult getSysSearchCondition() { +// return WeaResult.success(sysSalaryItemWrapper.getSearchCondition()); +// } + + + /** + * 添加系统薪资项目 + */ + @POST + @Path("/saveSys") + @Produces(MediaType.APPLICATION_JSON) + public String saveSysSalaryItem(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Collection sysSalaryItemIds) { + User user = HrmUserVarify.getUser(request, response); + if (CollectionUtils.isEmpty(sysSalaryItemIds)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(84026, "参数错误")); + } + return new ResponseResult, Map>(user).run(getSysSalaryItemWrapper(user)::add2SalaryItem, sysSalaryItemIds); + } + +// /**********************************系统薪资项目 end*********************************/ +} diff --git a/src/com/engine/salary/web/SalaryProgressController.java b/src/com/engine/salary/web/SalaryProgressController.java new file mode 100644 index 000000000..5219240a0 --- /dev/null +++ b/src/com/engine/salary/web/SalaryProgressController.java @@ -0,0 +1,52 @@ +package com.engine.salary.web; + +import com.engine.common.util.ServiceUtil; +import com.engine.salary.entity.progress.ProgressDTO; +import com.engine.salary.service.ProgressService; +import com.engine.salary.service.impl.ProgressServiceImpl; +import com.engine.salary.util.ResponseResult; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; + +/** + * 进度条 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SalaryProgressController { + + private ProgressService getSalaryAcctProgressService(User user) { + return (ProgressService) ServiceUtil.getService(ProgressServiceImpl.class, user); + } + + //获取进度条 + @GET + @Path("/getRate") + @Produces(MediaType.APPLICATION_JSON) + public String getRate(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "cacheKey") String cacheKey) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryAcctProgressService(user)::getProgress, cacheKey); + } + +// @ApiOperation("获取进度条") +// @GetMapping("/getWelfareAccountRate") +// @WeaPermission(publicPermission = true) +// public WeaResult getWelfareAccountRate(@RequestParam String billMonth) { +// Long employeeId = UserContext.getCurrentEmployeeId(); +// String tenantKey = TenantContext.getCurrentTenantKey(); +// SalaryAcctProgressDTO salaryAcctProgressDTO = salaryAcctProgressService.getProgress(tenantKey + billMonth, employeeId, tenantKey); +// return WeaResult.success(salaryAcctProgressDTO); +// } +} diff --git a/src/com/engine/salary/web/SalarySendRangeController.java b/src/com/engine/salary/web/SalarySendRangeController.java new file mode 100644 index 000000000..11a8730a0 --- /dev/null +++ b/src/com/engine/salary/web/SalarySendRangeController.java @@ -0,0 +1,58 @@ +package com.engine.salary.web; + +import com.engine.common.util.ServiceUtil; +import com.engine.salary.entity.salaryBill.dto.SalarySendRangeListDTO; +import com.engine.salary.entity.salaryBill.param.SalarySendRangeQueryParam; +import com.engine.salary.entity.salaryBill.param.SalarySendRangeSaveParam; +import com.engine.salary.util.ResponseResult; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.wrapper.SalarySendRangeWrapper; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import java.util.Collection; + +/** + * @Description: 工资单范围 + */ +public class SalarySendRangeController { + private SalarySendRangeWrapper getSalarySendRangeWrapper(User user) { + return ServiceUtil.getService(SalarySendRangeWrapper.class, user); + } + + @POST + @Path("/save") + @Produces(MediaType.APPLICATION_JSON) + public String save(@Context HttpServletRequest request, @Context HttpServletResponse response, + @RequestBody SalarySendRangeSaveParam saveParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalarySendRangeWrapper(user)::save, saveParam); + } + + @POST + @Path("/delete") + @Produces(MediaType.APPLICATION_JSON) + public String deleteByIds(@Context HttpServletRequest request, @Context HttpServletResponse response, + @RequestBody Collection ids) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult, Void>(user).run(getSalarySendRangeWrapper(user)::deleteByIds, ids); + } + + @POST + @Path("/list") + @Produces(MediaType.APPLICATION_JSON) + public String save(@Context HttpServletRequest request, @Context HttpServletResponse response, + @RequestBody SalarySendRangeQueryParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalarySendRangeWrapper(user)::listPage, queryParam); + } + +} diff --git a/src/com/engine/salary/web/SalarySobController.java b/src/com/engine/salary/web/SalarySobController.java new file mode 100644 index 000000000..5882004c9 --- /dev/null +++ b/src/com/engine/salary/web/SalarySobController.java @@ -0,0 +1,678 @@ +package com.engine.salary.web; + +import com.engine.common.util.ServiceUtil; +import com.engine.salary.entity.SalarySobExtRangePO; +import com.engine.salary.entity.salaryacct.param.SalaryAcctResultQueryParam; +import com.engine.salary.entity.salaryitem.dto.SalaryItemSobListDTO; +import com.engine.salary.entity.salaryitem.param.SalaryItemSearchParam; +import com.engine.salary.entity.salaryitem.po.SalaryItemPO; +import com.engine.salary.entity.salarysob.dto.*; +import com.engine.salary.entity.salarysob.param.*; +import com.engine.salary.entity.salarysob.po.SalarySobItemGroupPO; +import com.engine.salary.entity.salarysob.po.SalarySobItemPO; +import com.engine.salary.entity.salarysob.po.SalarySobPO; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.util.ResponseResult; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.wrapper.*; +import io.swagger.annotations.ApiOperation; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.StreamingOutput; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.time.LocalDate; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * 薪资账套 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Slf4j +public class SalarySobController { + + + private SalarySobWrapper getSalarySobWrapper(User user) { + return ServiceUtil.getService(SalarySobWrapper.class, user); + } + + private SalarySobRangeWrapper getSalarySobRangeWrapper(User user) { + return ServiceUtil.getService(SalarySobRangeWrapper.class, user); + } + + private SalarySobItemWrapper getSalarySobItemWrapper(User user) { + return ServiceUtil.getService(SalarySobItemWrapper.class, user); + } + + private SalarySobAdjustRuleWrapper getSalarySobAdjustRuleWrapper(User user) { + return ServiceUtil.getService(SalarySobAdjustRuleWrapper.class, user); + } + + private SalarySobCheckRuleWrapper getSalarySobCheckRuleWrapper(User user) { + return ServiceUtil.getService(SalarySobCheckRuleWrapper.class, user); + } + + private SalarySobBackItemWrapper getSalarySobBackItemWrapper(User user) { + return ServiceUtil.getService(SalarySobBackItemWrapper.class, user); + } + + private SalaryApprovalWrapper getSalaryApprovalWrapper(User user) { + return ServiceUtil.getService(SalaryApprovalWrapper.class, user); + } + + /**********************************薪资账套 start*********************************/ + + /** + * 薪资账套列表 + */ + @POST + @Path("/list") + @Produces(MediaType.APPLICATION_JSON) + public String listSalarySob(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalarySobListQueryParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalarySobWrapper(user)::listPage, queryParam); + } + + /** + * 根据扣缴义务人查询 + */ + @POST + @Path("/listByTaxAgent") + @Produces(MediaType.APPLICATION_JSON) + public String listSalarySob(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalarySobQueryParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalarySobWrapper(user)::listByTaxAgent, queryParam); + } + + /** + * 薪资账套列表 + */ + @POST + @Path("/listAll") + @Produces(MediaType.APPLICATION_JSON) + public String listAll(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalarySobWrapper(user)::listAll); + } + + + /** + * 薪资账套列表(分权) + */ + @POST + @Path("/listAuth") + @Produces(MediaType.APPLICATION_JSON) + public String listAllByAuth(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalarySobQueryParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalarySobWrapper(user)::listAuth,queryParam); + } + + + /** + * 薪资账套基本信息表单 + */ + @GET + @Path("/basic/getForm") + @Produces(MediaType.APPLICATION_JSON) + public String getSalarySobBasicForm(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "id") Long id) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalarySobWrapper(user)::getForm, id); + } + + /** + * 保存薪资账套基本信息 + */ + @POST + @Path("/basic/save") + @Produces(MediaType.APPLICATION_JSON) + public String getSalarySobBasicForm(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalarySobBasicSaveParam saveParam) { + User user = HrmUserVarify.getUser(request, response); + if (saveParam.getId() == null || saveParam.getId() <= 0) { + return new ResponseResult(user).run(getSalarySobWrapper(user)::save, saveParam); + } else { + return new ResponseResult(user).run(getSalarySobWrapper(user)::update, saveParam); + } + } + + /** + * 启用/禁用薪资账套 + */ + @POST + @Path("/disable") + @Produces(MediaType.APPLICATION_JSON) + public String updateSalarySobDisable(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalarySobDisableParam saveParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalarySobWrapper(user)::updateDisable, saveParam); + } + + /** + * 删除薪资账套 + */ + @POST + @Path("/delete") + @Produces(MediaType.APPLICATION_JSON) + public String deleteSalarySob(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Collection ids) { + User user = HrmUserVarify.getUser(request, response); + if (CollectionUtils.isEmpty(ids)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(84026, "参数错误")); + } + return new ResponseResult, Map>(user).run(getSalarySobWrapper(user)::delete, ids); + } + + /** + * 复制薪资账套 + */ + @POST + @Path("/duplicate") + @Produces(MediaType.APPLICATION_JSON) + public String duplicate(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalarySobDuplicateParam duplicateParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalarySobWrapper(user)::duplicate, duplicateParam); + } + + /**********************************薪资账套 end*********************************/ + + /**********************************薪资账套的人员范围 start*********************************/ + + + /** + * 薪资账套人员范围(包含)列表 + */ + @POST + @Path("/range/listInclude") + @Produces(MediaType.APPLICATION_JSON) + public String listPage4Include(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalarySobRangeQueryParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalarySobRangeWrapper(user)::listPage4Include, queryParam); + } + + + /** + * 薪资账套人员范围(排除)列表 + */ + @POST + @Path("/range/listExclude") + @Produces(MediaType.APPLICATION_JSON) + public String listPage4Exclude(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalarySobRangeQueryParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalarySobRangeWrapper(user)::listPage4Exclude, queryParam); + } + +// +// @GetMapping("/range/getForm") +// @ApiOperation("薪资账套人员范围表单") +// @WeaPermission +// public WeaResult getSalarySobRangeForm() { +// WeaForm weaForm = salarySobRangeWrapper.getForm(); +// return WeaResult.success(weaForm); +// } + + @POST + @Path("/ext/save") + @Produces(MediaType.APPLICATION_JSON) + public String saveSalarySobExtRange(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalarySobRangeExtSaveParam saveParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalarySobRangeWrapper(user)::saveExtRange, saveParam); + } + + @POST + @Path("/range/ext/list") + @Produces(MediaType.APPLICATION_JSON) + public String listPage4Ext(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalarySobRangeQueryParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalarySobRangeWrapper(user)::listPage4Ext, queryParam); + } + + /** + * 删除薪资账套人员范围 + */ + @POST + @Path("/range/ext/delete") + @Produces(MediaType.APPLICATION_JSON) + public String deleteSalarySobExtRange(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Collection ids) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult, String>(user).run(getSalarySobRangeWrapper(user)::deleteSalarySobExtRange, ids); + } + + /** + * 保存薪资账套人员范围 + */ + @POST + @Path("/range/save") + @Produces(MediaType.APPLICATION_JSON) + public String saveSalarySobRange(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalarySobRangeSaveParam saveParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalarySobRangeWrapper(user)::save, saveParam); + } + + /** + * 保存薪资账套人员范围 + */ + @POST + @Path("/range/edit") + @Produces(MediaType.APPLICATION_JSON) + public String editSalarySobRange(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalarySobRangeSaveParam saveParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalarySobRangeWrapper(user)::edit, saveParam); + } + + /** + * 删除薪资账套人员范围 + */ + @POST + @Path("/range/delete") + @Produces(MediaType.APPLICATION_JSON) + public String deleteSalarySobRange(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Collection ids) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult, String>(user).run(getSalarySobRangeWrapper(user)::delete, ids); + } + + /*** + * @description 下载薪资账套人员范围导入模板 + * @return Response + * @author Harryxzy + * @date 2023/1/9 11:10 + */ + @GET + @Path("/range/downloadTemplate") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response downloadSobRangeTemplate(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "salarySobId") Long salarySobId) { + User user = HrmUserVarify.getUser(request, response); + SalarySobPO salarySobPO = Objects.isNull(salarySobId) ? null : getSalarySobWrapper(user).getSalarySobService(user).getById(salarySobId); + if (Objects.isNull(salarySobPO)) { + throw new SalaryRunTimeException("薪资账套不存在或已被删除"); + } + try { + XSSFWorkbook workbook = getSalarySobRangeWrapper(user).exportImportTemplate(); + String time = LocalDate.now().toString(); + String fileName = salarySobPO.getName() + "人员范围导入模板" + time; + try { + fileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + StreamingOutput output = outputStream -> { + workbook.write(outputStream); + outputStream.flush(); + }; + response.setContentType("application/octet-stream"); + return Response.ok(output).header("Content-disposition", "attachment;filename=" + fileName).header("Cache-Control", "no-cache").build(); + } catch (Exception e) { + log.error("人员范围导入失败", e); + throw e; + } + } + + /** + * @return String + * @description 薪资账套人员范围导入预览 + * @author Harryxzy + * @date 2023/1/9 13:32 + */ + @POST + @Path("/range/preview") + @Produces(MediaType.APPLICATION_JSON) + public String preview(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalarySobRangeImportParam importParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalarySobRangeWrapper(user)::preview, importParam); + } + + /** + * @return String + * @description 薪资账套人员范围导入 + * @author Harryxzy + * @date 2023/1/9 13:32 + */ + @POST + @Path("/range/importData") + @Produces(MediaType.APPLICATION_JSON) + public String importData(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalarySobRangeImportParam importParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalarySobRangeWrapper(user)::importData, importParam); + } + + /**********************************薪资账套的人员范围 end*********************************/ + + /**********************************薪资账套的薪资项目 start*********************************/ + + /** + * 薪资账套可选薪资项目 + */ + @POST + @Path("/item/listSalaryItem") + @Produces(MediaType.APPLICATION_JSON) + public String listSalaryItem(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryItemSearchParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalarySobItemWrapper(user)::listPage4SalaryItem, queryParam); + } + + + /** + * 薪资账套可选薪资项目分类 + */ + @GET + @Path("/item/group/getForm") + @Produces(MediaType.APPLICATION_JSON) + public String getSalarySobItemGroupForm(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + String idStr = request.getParameter("id"); + Long id = null; + if (StringUtils.isNotBlank(idStr)) { + id = Long.valueOf(idStr); + } + return new ResponseResult(user).run(getSalarySobItemWrapper(user)::getGroupForm, id); + } + + /** + * 薪资账套薪资项目详情 + */ + @GET + @Path("/item/getForm") + @Produces(MediaType.APPLICATION_JSON) + public String getSalarySobItemForm(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + String salarySobIdStr = request.getParameter("salarySobId"); + Long salarySobId = null; + if (StringUtils.isNotBlank(salarySobIdStr)) { + salarySobId = Long.valueOf(salarySobIdStr); + } + return new ResponseResult(user).run(getSalarySobItemWrapper(user)::getForm, salarySobId); + } + + /** + * 人员信息字段列表 + */ + @GET + @Path("/empField/list") + @Produces(MediaType.APPLICATION_JSON) + public String empFieldList(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>>(user).run(getSalarySobItemWrapper(user)::empFieldList); + } + + /** + * 保存薪资账套薪资项目 + */ + @POST + @Path("/item/save") + @Produces(MediaType.APPLICATION_JSON) + public String saveSalarySobItem(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalarySobItemSaveParam saveParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalarySobItemWrapper(user)::save, saveParam); + } + + /** + * 薪资账套-薪资项目的详情 + */ + @POST + @Path("/item/getSalaryItemForm") + @Produces(MediaType.APPLICATION_JSON) + public String getSalaryItemForm(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalarySobItemPO param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalarySobItemWrapper(user)::getSalaryItemForm, param); + } + + + /**********************************薪资账套的薪资项目 end*********************************/ + + + /**********************************薪资账套的回算项目 start*********************************/ + + /** + * @return String + * @description 薪资账套回算项目列表 + * @author Harryxzy + * @date 2022/11/16 14:01 + */ + @GET + @Path("/backitem/getAggregate") + @Produces(MediaType.APPLICATION_JSON) + public String getSalarySobBackItemAggregate(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "salarySobId") Long salarySobId) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalarySobBackItemWrapper(user)::getAggregate, salarySobId); + } + + /** + * @return null + * @description 薪资账套回算项目详情(编辑前获取) + * @author Harryxzy + * @date 2022/11/16 14:02 + */ + @GET + @Path("/backitem/getForm") + @ApiOperation("薪资账套回算项目详情") + @Produces(MediaType.APPLICATION_JSON) + public String getSalarySobBackItemForm(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "id") Long id) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalarySobBackItemWrapper(user)::getForm, id); + } + + /** + * @return String + * @description 保存薪资账套回算项目 + * @author Harryxzy + * @date 2022/11/16 15:05 + */ + @POST + @Path("/backitem/save") + @Produces(MediaType.APPLICATION_JSON) + public String saveSalarySobBackItem(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalarySobBackItemSaveParam saveParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalarySobBackItemWrapper(user)::save, saveParam); + } + + /**********************************薪资账套的回算项目 end*********************************/ + + + /**********************************调薪计薪规则 start*********************************/ + + + /** + * 调薪计薪规则列表 + */ + @POST + @Path("/adjustmentrule/list") + @Produces(MediaType.APPLICATION_JSON) + public String listAdjustmentRule(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalarySobAdjustRuleQueryParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalarySobAdjustRuleWrapper(user)::list, queryParam); + } + + + /** + * 调薪计薪规则保存 + */ + @POST + @Path("/adjustmentrule/save") + @Produces(MediaType.APPLICATION_JSON) + public String saveAdjustmentRule(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalarySobAdjustRuleSaveParam saveParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalarySobAdjustRuleWrapper(user)::save, saveParam); + } + + /** + * 调薪计薪规则可选的薪资项目列表 + */ + @POST + @Path("/adjustmentrule/listSalarySobItem") + @Produces(MediaType.APPLICATION_JSON) + public String listSalarySobItem(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalarySobAdjustRuleItemQueryParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalarySobAdjustRuleWrapper(user)::list4SalarySobItem, queryParam); + } + + /**********************************调薪计薪规则 end*********************************/ + + /**********************************校验规则 start*********************************/ + + + /** + * 薪资账套校验规则列表 + */ + @POST + @Path("/checkrule/list") + @Produces(MediaType.APPLICATION_JSON) + public String listSalarySobCheckRule(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalarySobCheckRuleQueryParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalarySobCheckRuleWrapper(user)::listPage, queryParam); + } + + /** + * 薪资账套校验规则表单 + */ + @GET + @Path("/checkrule/getForm") + @Produces(MediaType.APPLICATION_JSON) + public String getForm(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + String idStr = request.getParameter("id"); + Long id = null; + if (StringUtils.isNotBlank(idStr)) { + id = Long.valueOf(idStr); + } + return new ResponseResult(user).run(getSalarySobCheckRuleWrapper(user)::getForm, id); + } + + /** + * 保存薪资账套校验规则 + */ + @POST + @Path("/checkrule/save") + @Produces(MediaType.APPLICATION_JSON) + public String saveSalarySobCheckRule(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalarySobCheckRuleSaveParam saveParam) { + User user = HrmUserVarify.getUser(request, response); + if (saveParam.getId() == null || saveParam.getId() <= 0) { + return new ResponseResult(user).run(getSalarySobCheckRuleWrapper(user)::save, saveParam); + } else { + return new ResponseResult(user).run(getSalarySobCheckRuleWrapper(user)::update, saveParam); + } + + } + + /** + * 编辑薪资账套校验规则公式 + */ + @POST + @Path("/checkrule/formula/update") + @Produces(MediaType.APPLICATION_JSON) + public String updateSalarySobCheckRuleFormula(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody UpdateCheckRuleFormulaParam updateParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalarySobCheckRuleWrapper(user)::updateFormulaId, updateParam); + } + + /** + * 删除薪资账套校验规则 + */ + @POST + @Path("/checkrule/delete") + @Produces(MediaType.APPLICATION_JSON) + public String deleteSalarySobCheckRule(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Collection ids) { + User user = HrmUserVarify.getUser(request, response); + if (CollectionUtils.isEmpty(ids)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(84026, "参数错误")); + } + return new ResponseResult, String>(user).run(getSalarySobCheckRuleWrapper(user)::delete, ids); + } + + + /**********************************校验规则 end*********************************/ + + /**********************************薪资审批规则 start*********************************/ + + /** + * 薪资审批规则表单 + */ + @POST + @Path("/salaryApproval/getForm") + @Produces(MediaType.APPLICATION_JSON) + public String salaryApprovalForm(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryApprovalQueryParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryApprovalWrapper(user)::salaryApprovalForm, queryParam); + } + + /** + * 保存薪资审批规则表单 + */ + @POST + @Path("/salaryApproval/saveForm") + @Produces(MediaType.APPLICATION_JSON) + public String saveSalaryApprovalForm(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryApprovalDTO saveParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryApprovalWrapper(user)::saveSalaryApprovalForm, saveParam); + } + + /** + * 薪资审批可选薪资项目 + */ + @POST + @Path("/salaryApproval/listSalaryItem") + @Produces(MediaType.APPLICATION_JSON) + public String listSalaryApprovalItem(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryItemSearchParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalaryApprovalWrapper(user)::listSalaryApprovalItem, queryParam); + } + + /** + * 根据核算记录id获取审批信息 + */ + @GET + @Path("/salaryApproval/getApprovalInfoByRecordId") + @Produces(MediaType.APPLICATION_JSON) + public String getApprovalInfo(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "salaryAcctRecordId")Long salaryAcctRecordId ) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryApprovalWrapper(user)::getApprovalInfoByRecordId, salaryAcctRecordId); + } + + /** + * 获取审批时薪资核算结果 + * @param request + * @param response + * @param param + * @return + */ + @POST + @Path("/salaryApproval/acctresult/list") + @Produces(MediaType.APPLICATION_JSON) + public String listSalaryApprovalAcctResult(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryAcctResultQueryParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalaryApprovalWrapper(user)::listSalaryApprovalAcctResult, param); + } + + /** + * 保存审批流程id + * @param request + * @param response + * @param param + * @return + */ + @POST + @Path("/salaryApproval/saveRequestId") + @Produces(MediaType.APPLICATION_JSON) + public String saveApprovalRequestId(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody ApprovalRequestSaveParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalaryApprovalWrapper(user)::saveApprovalRequestId, param); + } + + /**********************************薪资审批规则 start*********************************/ + +} diff --git a/src/com/engine/salary/web/SalarySystemConfigController.java b/src/com/engine/salary/web/SalarySystemConfigController.java new file mode 100644 index 000000000..4586af8e3 --- /dev/null +++ b/src/com/engine/salary/web/SalarySystemConfigController.java @@ -0,0 +1,376 @@ +package com.engine.salary.web; + +import com.engine.common.util.ServiceUtil; +import com.engine.salary.entity.config.SalaryConfig; +import com.engine.salary.sys.entity.param.*; +import com.engine.salary.sys.entity.po.SalarySysConfPO; +import com.engine.salary.sys.entity.vo.AppSettingVO; +import com.engine.salary.sys.entity.vo.OrderRuleVO; +import com.engine.salary.sys.entity.vo.UploadConfigResponse; +import com.engine.salary.sys.enums.TaxDeclarationFunctionEnum; +import com.engine.salary.util.ResponseResult; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.util.xml.XStreamUtil; +import com.engine.salary.wrapper.SalarySystemConfigWrapper; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import lombok.extern.slf4j.Slf4j; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.StreamingOutput; +import java.io.BufferedWriter; +import java.io.OutputStreamWriter; +import java.io.UnsupportedEncodingException; +import java.io.Writer; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.time.LocalDate; +import java.util.Map; + +@Slf4j +public class SalarySystemConfigController { + + private SalarySystemConfigWrapper getSalarySystemConfigWrapper(User user) { + return ServiceUtil.getService(SalarySystemConfigWrapper.class, user); + } + + /** + * 获取系统基础配置 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/info") + @Produces(MediaType.APPLICATION_JSON) + public String info(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult, Map>(user).run(getSalarySystemConfigWrapper(user)::info); + } + + /** + * 是否开启系统算税 + * + * @param request + * @param response + * @param param + * @return + */ + @POST + @Path("/operateTaxDeclarationFunction") + @Produces(MediaType.APPLICATION_JSON) + public String operateTaxDeclarationFunction(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody AppSettingSaveParam param) { + User user = HrmUserVarify.getUser(request, response); + + return new ResponseResult(user).run(getSalarySystemConfigWrapper(user)::operateTaxDeclarationFunction, TaxDeclarationFunctionEnum.parseByValue(param.getOperateTaxDeclaration())); + } + + + /** + * 获取系统配置 + * + * @param request + * @param response + * @param code + * @return + */ + @GET + @Path("/conf/code") + @Produces(MediaType.APPLICATION_JSON) + public String info(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "code") String code) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalarySystemConfigWrapper(user)::getOneByCode, code); + } + + /** + * 获取系统配置 + * + * @param request + * @param response + * @return + */ + @POST + @Path("/list") + @Produces(MediaType.APPLICATION_JSON) + public String info(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalarySysConfQueryParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalarySystemConfigWrapper(user)::list, param); + } + + /** + * 系统配置详情 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/detail") + @Produces(MediaType.APPLICATION_JSON) + public String detail(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "id") Long id) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalarySystemConfigWrapper(user)::detail, id); + } + + + /** + * 保存系统配置 + * + * @param request + * @param response + * @return + */ + @POST + @Path("/save") + @Produces(MediaType.APPLICATION_JSON) + public String save(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalarySysConfPO param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalarySystemConfigWrapper(user)::save, param); + } + + /** + * 更新系统配置 + * + * @param request + * @param response + * @return + */ + @POST + @Path("/update") + @Produces(MediaType.APPLICATION_JSON) + public String update(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalarySysConfPO param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalarySystemConfigWrapper(user)::update, param); + } + + /** + * 新增或更新系统配置 + * + * @param request + * @param response + * @return + */ + @POST + @Path("/operate") + @Produces(MediaType.APPLICATION_JSON) + public String operate(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalarySysConfPO param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalarySystemConfigWrapper(user)::operate, param); + } + + + /** + * 单个规则配置 + * + * @param request + * @param response + * @param param + * @return + */ + @POST + @Path("/updateByCode") + @Produces(MediaType.APPLICATION_JSON) + public String updateByCode(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalarySysConfPO param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalarySystemConfigWrapper(user)::updateByCode, param); + } + + @POST + @Path("/updateOrderRule") + @Produces(MediaType.APPLICATION_JSON) + public String updateOrderRule(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody OrderRuleParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalarySystemConfigWrapper(user)::updateOrderRule, param); + } + + @GET + @Path("/orderRule") + @Produces(MediaType.APPLICATION_JSON) + public String updateOrderRule(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalarySystemConfigWrapper(user)::orderRule); + } + + @POST + @Path("/saveMatchEmployeeModeRule") + @Produces(MediaType.APPLICATION_JSON) + public String saveMatchEmployeeModeRule(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody MatchEmployeeModeSaveParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalarySystemConfigWrapper(user)::saveMatchEmployeeModeRule, param); + } + + /** + * 薪资核算人员匹配规则 + * + * @param request + * @param response + * @param param + * @return + */ + @POST + @Path("/saveSalaryAcctEmployeeRule") + @Produces(MediaType.APPLICATION_JSON) + public String saveSalaryAcctEmployeeRule(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody MatchEmployeeModeSaveParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalarySystemConfigWrapper(user)::saveSalaryAcctEmployeeRule, param.getRule()); + } + + /** + * 工资单反馈 + * + * @param request + * @param response + * @param param + * @return + */ + @POST + @Path("/saveSalarySendFeedback") + @Produces(MediaType.APPLICATION_JSON) + public String saveSalarySendFeedback(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalarySysConfPO param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalarySystemConfigWrapper(user)::saveSalarySendFeedback, param); + } + + /** + * 撤回个税申报 + * + * @param request + * @param response + * @param param + * @return + */ + @POST + @Path("/saveWithDrawTaxDeclaration") + @Produces(MediaType.APPLICATION_JSON) + public String saveWithDrawTaxDeclaration(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalarySysConfPO param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalarySystemConfigWrapper(user)::saveWithDrawTaxDeclaration, param); + } + + /** + * 删除档案 + * + * @param request + * @param response + * @param param + * @return + */ + @POST + @Path("/saveArchiveDelete") + @Produces(MediaType.APPLICATION_JSON) + public String saveArchiveDelete(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalarySysConfPO param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalarySystemConfigWrapper(user)::saveArchiveDelete, param.getConfValue()); + } + + /** + * 应用设置 + * + * @param request + * @param response + * @param param + * @return + */ + @POST + @Path("/app/setting/save") + @Produces(MediaType.APPLICATION_JSON) + public String saveAppSetting(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody AppSettingSaveParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalarySystemConfigWrapper(user)::saveAppSetting, param); + } + + /** + * 应用设置 + * + * @param request + * @param response + * @param param + * @return + */ + @POST + @Path("/app/setting/saveEncryptSetting") + @Produces(MediaType.APPLICATION_JSON) + public String saveEncryptSetting(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody AppSettingSaveParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalarySystemConfigWrapper(user)::saveEncryptSetting, param); + } + + /** + * 应用设置 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/app/setting") + @Produces(MediaType.APPLICATION_JSON) + public String appSetting(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalarySystemConfigWrapper(user)::appSetting); + } + + /** + * 加密设置的进度 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/app/getEncryptProgress") + @Produces(MediaType.APPLICATION_JSON) + public String getEncryptProgress(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "progressId") String progressId) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalarySystemConfigWrapper(user)::getEncryptProgress, progressId); + } + + @POST + @Path("/downloadConfig") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response downloadConfig(@Context HttpServletRequest request, @Context HttpServletResponse response) { + try { + User user = HrmUserVarify.getUser(request, response); + SalaryConfig salaryConfig = getSalarySystemConfigWrapper(user).downloadConfig(); + + String xml = XStreamUtil.marshal(salaryConfig); + + String fileName = "薪酬配置" + LocalDate.now(); + try { + fileName = URLEncoder.encode(fileName + ".xml", "UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + + StreamingOutput output = outputStream -> { + Writer writer = new BufferedWriter(new OutputStreamWriter(outputStream, StandardCharsets.UTF_8)); + writer.write(xml); + writer.flush(); + }; + + + response.setContentType("application/octet-stream"); + return Response.ok(output).header("Content-disposition", "attachment;filename=" + fileName).header("Cache-Control", "no-cache").build(); + } catch (Exception e) { + log.error("下载薪酬配置", e); + throw new RuntimeException("下载薪酬配置", e); + } + } + + @POST + @Path("/uploadConfig") + @Produces(MediaType.APPLICATION_JSON) + public String initConfig(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody UploadConfigParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSalarySystemConfigWrapper(user)::uploadConfig, param); + + } + +} diff --git a/src/com/engine/salary/web/SpecialAddDeductionController.java b/src/com/engine/salary/web/SpecialAddDeductionController.java new file mode 100644 index 000000000..da67a4677 --- /dev/null +++ b/src/com/engine/salary/web/SpecialAddDeductionController.java @@ -0,0 +1,338 @@ +package com.engine.salary.web; + +import com.engine.common.util.ServiceUtil; +import com.engine.salary.entity.datacollection.dto.SpecialAddDeductionListDTO; +import com.engine.salary.entity.datacollection.dto.SpecialAddDeductionRecordDTO; +import com.engine.salary.entity.datacollection.param.SpecialAddDeductionImportParam; +import com.engine.salary.entity.datacollection.param.SpecialAddDeductionParam; +import com.engine.salary.entity.datacollection.param.SpecialAddDeductionQueryParam; +import com.engine.salary.entity.datacollection.param.SpecialAddDeductionRecordDeleteParam; +import com.engine.salary.util.ResponseResult; +import com.engine.salary.util.excel.ExcelPreviewDTO; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.wrapper.SpecialAddDeductionWrapper; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.jetbrains.annotations.Nullable; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.StreamingOutput; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.time.LocalDate; +import java.util.Arrays; +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * 数据采集-专项附加扣除 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author lfc + **/ +@Slf4j +public class SpecialAddDeductionController { + + private SpecialAddDeductionWrapper getSpecialAddDeductionWrapper(User user) { + return ServiceUtil.getService(SpecialAddDeductionWrapper.class, user); + } + + /** + * 数据采集-专项附加扣除列表的高级搜索 + * + * @return + */ + @GET + @Path("/getSearchCondition") + @Produces(MediaType.APPLICATION_JSON) + public String getSearchCondition(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult, Map>(user).run(getSpecialAddDeductionWrapper(user)::getSearchCondition); + } + + + @POST + @Path("/list") + @Produces(MediaType.APPLICATION_JSON) + public String list(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SpecialAddDeductionQueryParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSpecialAddDeductionWrapper(user)::list, queryParam); + } + + + @POST + @Path("/getSpecialAddDeduction") + @Produces(MediaType.APPLICATION_JSON) + public String getDetailList(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SpecialAddDeductionQueryParam param) { + User user = HrmUserVarify.getUser(request, response); + Long id = param.getId(); + return new ResponseResult(user).run(getSpecialAddDeductionWrapper(user)::getRecordById, id); + } + + @POST + @Path("/getDetailList") + @Produces(MediaType.APPLICATION_JSON) + public String getSpecialAddDeduction(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SpecialAddDeductionQueryParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSpecialAddDeductionWrapper(user)::getDetailList, queryParam); + } + + + @GET + @Path("/downloadTemplate") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response getAll(@Context HttpServletRequest request, @Context HttpServletResponse response) { + try { + User user = HrmUserVarify.getUser(request, response); + SpecialAddDeductionQueryParam param = buildParam(request); + + XSSFWorkbook workbook = getSpecialAddDeductionWrapper(user).downloadTemplate(param); + String fileName = "专项附加扣除导入模板" + LocalDate.now(); + try { + fileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + + StreamingOutput output = outputStream -> { + workbook.write(outputStream); + outputStream.flush(); + }; + response.setContentType("application/octet-stream"); + return Response.ok(output).header("Content-disposition", "attachment;filename=" + fileName).header("Cache-Control", "no-cache").build(); + + } catch (Exception e) { + log.error("专项附加扣除导入模板异常", e); + throw e; + } + } + + + /** + * 导出 + * + * @param + * @return + */ + @GET + @Path("/export") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response export(@Context HttpServletRequest request, @Context HttpServletResponse response) { + try { + User user = HrmUserVarify.getUser(request, response); + + SpecialAddDeductionQueryParam param = buildParam(request); + + XSSFWorkbook workbook = getSpecialAddDeductionWrapper(user).export(param); + + String fileName = null; + try { + fileName = URLEncoder.encode("专项附加扣除" + LocalDate.now() + ".xlsx", "UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + + StreamingOutput output = outputStream -> { + workbook.write(outputStream); + outputStream.flush(); + }; + + response.setContentType("application/octet-stream"); + return Response.ok(output) + .header("Content-disposition", "attachment;filename=" + fileName) + .header("Cache-Control", "no-cache").build(); + } catch (Exception e) { + log.error("专项附加扣除导出异常", e); + throw e; + } + } + + + @GET + @Path("/exportDetail") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response exportDetail(@Context HttpServletRequest request, @Context HttpServletResponse response) { + try { + User user = HrmUserVarify.getUser(request, response); + + SpecialAddDeductionQueryParam param = buildParam(request); + + XSSFWorkbook workbook = getSpecialAddDeductionWrapper(user).exportDetail(param); + + String fileName = "专项附加扣除明细" + LocalDate.now(); + try { + fileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + + StreamingOutput output = outputStream -> { + workbook.write(outputStream); + outputStream.flush(); + }; + + response.setContentType("application/octet-stream"); + return Response.ok(output) + .header("Content-disposition", "attachment;filename=" + fileName) + .header("Cache-Control", "no-cache").build(); + } catch (Exception e) { + log.error("专项附加扣除明细导出异常", e); + throw e; + } + + } + + @Nullable + private SpecialAddDeductionQueryParam buildParam(HttpServletRequest request) { + SpecialAddDeductionQueryParam param = new SpecialAddDeductionQueryParam(); + String ids = request.getParameter("ids"); + if (StringUtils.isNotBlank(ids)) { + param.setIds(Arrays.stream(ids.split(",")).map(Long::valueOf).collect(Collectors.toList())); + } + String keyword = request.getParameter("keyword"); + if (StringUtils.isNotBlank(keyword)) { + param.setKeyword(keyword); + } + String id = request.getParameter("id"); + if (StringUtils.isNotBlank(id)) { + param.setId(Long.valueOf(id)); + } + + String username = request.getParameter("username"); + if (StringUtils.isNotBlank(username)) { + param.setUsername(username); + } + String employeeId = request.getParameter("employeeId"); + if (StringUtils.isNotBlank(employeeId)) { + param.setEmployeeId(Long.valueOf(employeeId)); + } + String taxAgentId = request.getParameter("taxAgentId"); + if (StringUtils.isNotBlank(taxAgentId)) { + param.setTaxAgentId(Long.valueOf(taxAgentId)); + } + String departmentIds = request.getParameter("departmentIds"); + if (StringUtils.isNotBlank(departmentIds)) { + param.setDepartmentIds(Arrays.stream(departmentIds.split(",")).map(Long::valueOf).collect(Collectors.toList())); + } + String jobNum = request.getParameter("jobNum"); + if (StringUtils.isNotBlank(jobNum)) { + param.setJobNum(jobNum); + } + String idNo = request.getParameter("idNo"); + if (StringUtils.isNotBlank(idNo)) { + param.setIdNo(idNo); + } + String hiredate = request.getParameter("hiredate"); + if (StringUtils.isNotBlank(hiredate)) { + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + List dates = Arrays.stream(hiredate.split(",")).map(d -> { + try { + return format.parse(d); + } catch (ParseException e) { + e.printStackTrace(); + } + return null; + }).collect(Collectors.toList()); + param.setHiredate(dates); + } + String mobile = request.getParameter("mobile"); + if (StringUtils.isNotBlank(mobile)) { + param.setMobile(mobile); + } + String otherTaxExemptDeductionId = request.getParameter("otherTaxExemptDeductionId"); + if (StringUtils.isNotBlank(otherTaxExemptDeductionId)) { + param.setSpecialAddDeductionId(Long.valueOf(otherTaxExemptDeductionId)); + } + String hasData = request.getParameter("hasData"); + if (StringUtils.isNotBlank(hasData)) { + param.setHasData("true".equals(hasData)); + } + return param; + } + + @POST + @Path("/preview") + @Produces(MediaType.APPLICATION_JSON) + public String preview(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SpecialAddDeductionImportParam importParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getSpecialAddDeductionWrapper(user)::preview, importParam); + } + + @POST + @Path("/importData") + @Produces(MediaType.APPLICATION_JSON) + public String importAddUpDeduction(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SpecialAddDeductionImportParam importParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSpecialAddDeductionWrapper(user)::importData, importParam); + } + + /** + * @return String + * @description 编辑专项附加扣除 + * @author Harryxzy + * @date 2022/10/26 9:41 + */ + @POST + @Path("/editData") + @Produces(MediaType.APPLICATION_JSON) + public String editOtherDeduction(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SpecialAddDeductionParam otherDeductionParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSpecialAddDeductionWrapper(user)::editData, otherDeductionParam); + } + + /** + * @return String + * @description 新建专项附加扣除 + * @author lfc + */ + @POST + @Path("/createData") + @Produces(MediaType.APPLICATION_JSON) + public String createSpecialAddDeduction(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SpecialAddDeductionParam specialAddDeductionParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSpecialAddDeductionWrapper(user)::createData, specialAddDeductionParam); + } + + /** + * @return String + * @description 删除所选专项附加扣除 + * @author lfc + */ + @POST + @Path("/deleteSelectData") + @Produces(MediaType.APPLICATION_JSON) + public String deleteSelectOtherDeduction(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SpecialAddDeductionRecordDeleteParam deleteParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSpecialAddDeductionWrapper(user)::deleteSelectData, deleteParam); + } + + /** + * @return null + * @description 一键清空专项附加扣除 + * @author lfc + */ + @POST + @Path("/deleteAllData") + @Produces(MediaType.APPLICATION_JSON) + public String deleteAllOtherDeduction(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SpecialAddDeductionRecordDeleteParam deductionRecordDeleteParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSpecialAddDeductionWrapper(user)::deleteAllData, deductionRecordDeleteParam); + } +} diff --git a/src/com/engine/salary/web/TaxAgentController.java b/src/com/engine/salary/web/TaxAgentController.java new file mode 100644 index 000000000..5d06ab13f --- /dev/null +++ b/src/com/engine/salary/web/TaxAgentController.java @@ -0,0 +1,520 @@ +package com.engine.salary.web; + +import com.engine.common.util.ServiceUtil; +import com.engine.salary.entity.taxagent.dto.TaxAgentFormDTO; +import com.engine.salary.entity.taxagent.dto.TaxAgentManageRangeEmployeeDTO; +import com.engine.salary.entity.taxagent.dto.TaxAgentManageRangeFormDTO; +import com.engine.salary.entity.taxagent.dto.TaxAgentManageRangeListDTO; +import com.engine.salary.entity.taxagent.param.*; +import com.engine.salary.entity.taxagent.po.TaxAgentBasePO; +import com.engine.salary.entity.taxagent.po.TaxAgentExtRangePO; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import com.engine.salary.util.ResponseResult; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.wrapper.TaxAgentBaseWrapper; +import com.engine.salary.wrapper.TaxAgentSubAdminWrapper; +import com.engine.salary.wrapper.TaxAgentWrapper; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import org.apache.commons.lang3.StringUtils; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.StreamingOutput; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.time.LocalDate; +import java.util.*; + +public class TaxAgentController { + + private TaxAgentBaseWrapper getTaxAgentBaseWrapper(User user) { + return ServiceUtil.getService(TaxAgentBaseWrapper.class, user); + } + + private TaxAgentSubAdminWrapper getTaxAgentSubAdminWrapper(User user) { + return ServiceUtil.getService(TaxAgentSubAdminWrapper.class, user); + } + + private TaxAgentWrapper getTaxAgentWrapper(User user) { + return ServiceUtil.getService(TaxAgentWrapper.class, user); + } + + /** + * 是否是薪酬模块总管理员 + */ + @GET + @Path("/isChief") + @Produces(MediaType.APPLICATION_JSON) + public String isChief(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getTaxAgentWrapper(user)::isChief, (long) user.getUID()); + } + + /** + * 权限信息 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/permission") + @Produces(MediaType.APPLICATION_JSON) + public String permission(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getTaxAgentWrapper(user)::permission, (long) user.getUID()); + } + + /* ****** 基础信息 start ***********************************************************************************************/ + + /** + * 获取个税扣缴义务人基础信息表单 + * + * @return + */ + @GET + @Path("/base/getForm") + @Produces(MediaType.APPLICATION_JSON) + public String getBaseFrom(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getTaxAgentBaseWrapper(user)::getFrom); + } + + /** + * 保存个税扣缴义务人基础信息 + * + * @param saveBaseParam + * @return + */ + @POST + @Path("/base/save") + @Produces(MediaType.APPLICATION_JSON) + public String saveBase(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody TaxAgentSaveBaseParam saveBaseParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getTaxAgentBaseWrapper(user)::save, saveBaseParam); + } + /* ******* 基础信息 end ***********************************************************************************************/ + + /* ******* 个税扣缴义务人 start ***********************************************************************************************/ + + /** + * 个税扣缴义务人列表 + * + * @param queryParam + * @return + */ + @POST + @Path("/list") + @Produces(MediaType.APPLICATION_JSON) + public String list(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody TaxAgentQueryParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>>(user).run(getTaxAgentWrapper(user)::list, queryParam); + } + + @POST + @Path("/listAuth") + @Produces(MediaType.APPLICATION_JSON) + public String selectList(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody TaxAgentQueryParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getTaxAgentWrapper(user)::listAuth, queryParam); + } + + //查询个税扣缴义务人下面的代缴机构") + @GET + @Path("/paymentAgency/list") + @Produces(MediaType.APPLICATION_JSON) + public String paymentAgencyList(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "id") Long id) { + User user = HrmUserVarify.getUser(request, response); + TaxAgentQueryParam queryParam = new TaxAgentQueryParam(); + queryParam.setIds(Collections.singleton(id)); + return new ResponseResult>>(user).run(getTaxAgentWrapper(user)::paymentAgencyList, queryParam); + } + + //保存个税扣缴义务人下的代缴机构") + @POST + @Path("/paymentAgency/save") + @Produces(MediaType.APPLICATION_JSON) + public String paymentAgencySave(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody TaxAgentSaveParam saveParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getTaxAgentWrapper(user)::paymentAgencySave, saveParam); + } + + + /** + * 获取个税扣缴义务人表单 + * + * @param id 表单id + * @return 表单对象 + */ + @GET + @Path("/getForm") + @Produces(MediaType.APPLICATION_JSON) + public String getFrom(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "id") Long id) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getTaxAgentWrapper(user)::getFrom, id); + } + + /** + * 新建个税扣缴义务人 + * + * @param saveParam 个税扣缴义务人保存参数 + * @return 个税扣缴义务人id + */ + @POST + @Path("/save") + @Produces(MediaType.APPLICATION_JSON) + public String save(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody TaxAgentSaveParam saveParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getTaxAgentWrapper(user)::save, saveParam); + } + + /** + * 编辑个税扣缴义务人 + * + * @param saveParam + * @return + */ + @POST + @Path("/update") + @Produces(MediaType.APPLICATION_JSON) + public String update(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody TaxAgentSaveParam saveParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getTaxAgentWrapper(user)::update, saveParam); + } + + /** + * 更换管理员校验 + * + * @param checkParam + * @return + */ + @POST + @Path("/adminChangeCheck") + @Produces(MediaType.APPLICATION_JSON) + public String adminChangeCheck(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody TaxAgentAdminChangeCheckParam checkParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getTaxAgentWrapper(user)::adminChangeCheck, checkParam); + } + + /** + * 删除个税扣缴义务人 + * + * @param ids + * @return + */ + @POST + @Path("/delete") + @Produces(MediaType.APPLICATION_JSON) + public String delete(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody List ids) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult, String>(user).run(getTaxAgentWrapper(user)::delete, ids); + } + + /** + * 人员范围列表 + * + * @param queryParam + * @return + */ + @POST + @Path("/range/listInclude") + @Produces(MediaType.APPLICATION_JSON) + public String rangeListInclude(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody TaxAgentRangeQueryParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getTaxAgentWrapper(user)::listRangeInclude, queryParam); + } + + /** + * 人员范围排除列表 + * + * @param queryParam + * @return + */ + @POST + @Path("/range/listExclude") + @Produces(MediaType.APPLICATION_JSON) + public String rangeListExclude(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody TaxAgentRangeQueryParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getTaxAgentWrapper(user)::listRangeExclude, queryParam); + } + + //获取人员范围表单") + @POST + @Path("/range/getForm") + @Produces(MediaType.APPLICATION_JSON) + public String getRangeFrom(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getTaxAgentWrapper(user)::getRangeFrom); + } + + //保存人员范围 + @POST + @Path("/range/save") + @Produces(MediaType.APPLICATION_JSON) + public String saveRange(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody TaxAgentRangeSaveParam saveParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getTaxAgentWrapper(user)::saveRange, saveParam); + } + + //保存人员范围 + @POST + @Path("/range/edit") + @Produces(MediaType.APPLICATION_JSON) + public String editRange(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody TaxAgentRangeSaveParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getTaxAgentWrapper(user)::editRange, param); + } + + + //删除人员范围 + @POST + @Path("/range/delete") + @Produces(MediaType.APPLICATION_JSON) + public String deleteRange(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Collection ids) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult, String>(user).run(getTaxAgentWrapper(user)::deleteRange, ids); + } + + //外部人员 + @POST + @Path("/range/listExt") + @Produces(MediaType.APPLICATION_JSON) + public String listExt(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody TaxAgentRangeExtQueryParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getTaxAgentWrapper(user)::listExt, queryParam); + } + + + @POST + @Path("/range/ext/save") + @Produces(MediaType.APPLICATION_JSON) + public String saveExtRange(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody TaxAgentManageRangeExtSaveParam saveParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getTaxAgentWrapper(user)::saveExtRange, saveParam); + } + + //删除外部人员范围 + @POST + @Path("/range/ext/delete") + @Produces(MediaType.APPLICATION_JSON) + public String deleteExtRange(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Collection ids) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult, String>(user).run(getTaxAgentWrapper(user)::deleteExtRange, ids); + } + + /** + * 下载人员范围导入模板 + * + * @return + */ + @GET + @Path("/range/downloadTemplate") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response downloadTemplateRange(@Context HttpServletRequest request, @Context HttpServletResponse response ,@QueryParam(value = "taxAgentId") Long taxAgentId) { + try { + User user = HrmUserVarify.getUser(request, response); + TaxAgentPO taxAgent = taxAgentId == null ? null : getTaxAgentWrapper(user).getTaxAgentService(user).getById(taxAgentId); + TaxAgentRangeDownloadTemplateParam build = TaxAgentRangeDownloadTemplateParam.builder().taxAgentId(taxAgentId).build(); + XSSFWorkbook workbook = getTaxAgentWrapper(user).exportImportTemplate(build); + String time = LocalDate.now().toString(); + String fileName = Objects.isNull(taxAgent) ? "人员范围导入模板" + time : taxAgent.getName() + "人员范围导入模板" + time; + try { + fileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + StreamingOutput output = outputStream -> { + workbook.write(outputStream); + outputStream.flush(); + }; + response.setContentType("application/octet-stream"); + return Response.ok(output). + header("Content-disposition", "attachment;filename=" + fileName). + header("Cache-Control", "no-cache").build(); + } catch (Exception e) { + throw e; + } + } + + /** + * 预览人员范围导入模板 + * + * @return + */ + @POST + @Path("/range/preview") + @Produces(MediaType.APPLICATION_JSON) + public String preview(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody TaxAgentImportParam importParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getTaxAgentWrapper(user)::preview, importParam); + } + + /** + * 个税扣缴义务人人员范围导入 + * + * @return + */ + @POST + @Path("/range/importData") + @Produces(MediaType.APPLICATION_JSON) + public String importEmployeeRange(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody TaxAgentImportParam importParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getTaxAgentWrapper(user)::importData, importParam); + } + + /** + * 个税扣缴义务人下拉列表 + * + * @return + */ + @GET + @Path("/selectList") + @Produces(MediaType.APPLICATION_JSON) + public String selectList(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + boolean needAuth = !StringUtils.equals("true", request.getParameter("isShare")); + return new ResponseResult>>(user).run(getTaxAgentWrapper(user)::selectList, needAuth); + } + + @GET + @Path("/selectListAsAdmin") + @Produces(MediaType.APPLICATION_JSON) + public String selectListAsAdmin(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult, List>>(user).run(getTaxAgentWrapper(user)::selectListAsAdmin); + } + + + @GET + @Path("/getEmpListInTaxAgent") + @Produces(MediaType.APPLICATION_JSON) + public String getEmpListInTaxAgent(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "id") Long id) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getTaxAgentWrapper(user)::getEmpListInTaxAgent, id); + } + + + //同步人员范围 + @POST + @Path("/range/sync") + @Produces(MediaType.APPLICATION_JSON) + public String syncRange(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getTaxAgentWrapper(user)::syncRange); + } + + /* ******* 个税扣缴义务人 end ***********************************************************************************************/ + + /* ******* 分管理员 start ***********************************************************************************************/ + + /** + * 分管理员列表 + * + * @param queryParam + * @return + */ +// @POST +// @Path("/subAdmin/list") +// @Produces(MediaType.APPLICATION_JSON) +// public String subAdminList(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody TaxAgentSubAdminQueryParam queryParam) { +// User user = HrmUserVarify.getUser(request, response); +// return new ResponseResult>(user).run(getTaxAgentSubAdminWrapper(user)::list, queryParam); +// } + + /** + * 获取分管理员基础设置表单 + * + * @return + */ +// @POST +// @Path("/subAdmin/getBaseForm") +// @Produces(MediaType.APPLICATION_JSON) +// public String getSubAdminBaseFrom(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody TaxAgentSubAdminBaseFormParam baseFormParam) { +// User user = HrmUserVarify.getUser(request, response); +// return new ResponseResult(user).run(getTaxAgentSubAdminWrapper(user)::getBaseFrom, baseFormParam); +// } + + /** + * 分管理员基础设置保存 + * + * @param saveParam + * @return + */ +// @POST +// @Path("/subAdmin/saveBase") +// @Produces(MediaType.APPLICATION_JSON) +// public String saveSubAdminBase(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody TaxAgentSubAdminBaseSaveParam saveParam) { +// User user = HrmUserVarify.getUser(request, response); +// return new ResponseResult(user).run(getTaxAgentSubAdminWrapper(user)::saveBase, saveParam); +// } + + /** + * 删除个税扣缴义务人分管理员 + * + * @param ids + * @return + */ +// @POST +// @Path("/subAdmin/delete") +// @Produces(MediaType.APPLICATION_JSON) +// public String deleteSubAdmin(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Collection ids) { +// User user = HrmUserVarify.getUser(request, response); +// return new ResponseResult, String>(user).run(getTaxAgentSubAdminWrapper(user)::delete, ids); +// } + + //分管理员的管理范围列表 +// @POST +// @Path("/subAdmin/range/listInclude") +// @Produces(MediaType.APPLICATION_JSON) +// public String subAdminRangeListInclude(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody TaxAgentSubAdminRangeQueryParam queryParam) { +// User user = HrmUserVarify.getUser(request, response); +// return new ResponseResult>(user).run(getTaxAgentSubAdminWrapper(user)::listRangeInclude, queryParam); +// } + + //分管理员的管理范围排除列表 +// @POST +// @Path("/subAdmin/range/listExclude") +// @Produces(MediaType.APPLICATION_JSON) +// public String subAdminRangeListExclude(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody TaxAgentSubAdminRangeQueryParam queryParam) { +// User user = HrmUserVarify.getUser(request, response); +// return new ResponseResult>(user).run(getTaxAgentSubAdminWrapper(user)::listRangeExclude, queryParam); +// } + + //获取分管理员的管理范围表单 +// @POST +// @Path("/subAdmin/range/getForm") +// @Produces(MediaType.APPLICATION_JSON) +// public String getSubAdminRangeFrom(@Context HttpServletRequest request, @Context HttpServletResponse response) { +// User user = HrmUserVarify.getUser(request, response); +// return new ResponseResult(user).run(getTaxAgentSubAdminWrapper(user)::getRangeFrom); +// } + + //保存分管理员的管理范围 +// @POST +// @Path("/subAdmin/range/save") +// @Produces(MediaType.APPLICATION_JSON) +// public String saveSubAdminRange(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody TaxAgentSubAdminRangeSaveParam saveParam) { +// User user = HrmUserVarify.getUser(request, response); +// return new ResponseResult(user).run(getTaxAgentSubAdminWrapper(user)::saveRange, saveParam); +// } + + //删除分管理员的管理范围 +// @POST +// @Path("/subAdmin/range/delete") +// @Produces(MediaType.APPLICATION_JSON) +// public String deleteSubAdminRange(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Collection ids) { +// User user = HrmUserVarify.getUser(request, response); +// return new ResponseResult, String>(user).run(getTaxAgentSubAdminWrapper(user)::deleteRange, ids); +// } + + /******** 分管理员 end ***********************************************************************************************/ + + +} diff --git a/src/com/engine/salary/web/TaxDeclarationController.java b/src/com/engine/salary/web/TaxDeclarationController.java new file mode 100644 index 000000000..6d2332dd4 --- /dev/null +++ b/src/com/engine/salary/web/TaxDeclarationController.java @@ -0,0 +1,142 @@ +package com.engine.salary.web; + +import com.engine.common.util.ServiceUtil; +import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationFormDTO; +import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationInfoDTO; +import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationListDTO; +import com.engine.salary.entity.taxdeclaration.param.TaxDeclarationDetailListQueryParam; +import com.engine.salary.entity.taxdeclaration.param.TaxDeclarationListQueryParam; +import com.engine.salary.entity.taxdeclaration.param.TaxDeclarationSaveParam; +import com.engine.salary.service.TaxDeclarationExcelService; +import com.engine.salary.service.TaxDeclarationService; +import com.engine.salary.service.impl.TaxDeclarationExcelServiceImpl; +import com.engine.salary.service.impl.TaxDeclarationServiceImpl; +import com.engine.salary.util.ResponseResult; +import com.engine.salary.util.SalaryDateUtil; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.wrapper.TaxDeclarationDetailWrapper; +import com.engine.salary.wrapper.TaxDeclarationWrapper; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import lombok.extern.slf4j.Slf4j; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.StreamingOutput; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.text.ParseException; +import java.time.LocalDate; + + +@Slf4j +public class TaxDeclarationController { + + private TaxDeclarationService getService(User user) { + return ServiceUtil.getService(TaxDeclarationServiceImpl.class, user); + } + + private TaxDeclarationWrapper getTaxDeclarationWrapper(User user) { + return ServiceUtil.getService(TaxDeclarationWrapper.class, user); + } + + private TaxDeclarationExcelService getTaxDeclarationExcelService(User user) { + return ServiceUtil.getService(TaxDeclarationExcelServiceImpl.class, user); + } + + private TaxDeclarationDetailWrapper getTaxDeclarationDetailWrapper(User user) { + return ServiceUtil.getService(TaxDeclarationDetailWrapper.class, user); + } + + //个税申报表列表 + @POST + @Path("/list") + @Produces(MediaType.APPLICATION_JSON) + public String list(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody TaxDeclarationListQueryParam queryParam) throws ParseException { + User user = HrmUserVarify.getUser(request, response); + queryParam.setFromSalaryMonth(SalaryDateUtil.String2YearMonth(queryParam.getFromSalaryMonthStr() == null ? "" : queryParam.getFromSalaryMonthStr())); + queryParam.setEndSalaryMonth(SalaryDateUtil.String2YearMonth(queryParam.getEndSalaryMonthStr() == null ? "" : queryParam.getEndSalaryMonthStr())); + return new ResponseResult>(user).run(getTaxDeclarationWrapper(user)::listPage, queryParam); + } + + @POST + @Path("/withDrawTaxDeclaration") + @Produces(MediaType.APPLICATION_JSON) + public String deleteTaxDeclaration(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody TaxDeclarationSaveParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getTaxDeclarationWrapper(user)::withDrawTaxDeclaration, param.getTaxDeclarationId()); + } + + + //个税申报表表单 + @GET + @Path("/getForm") + @Produces(MediaType.APPLICATION_JSON) + public String getForm(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "id") Long id) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getTaxDeclarationWrapper(user)::getForm, id); + } + + //个税申报表相关信息 + @GET + @Path("/getTaxDeclarationInfo") + @Produces(MediaType.APPLICATION_JSON) + public String getTaxDeclarationInfo(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "taxDeclarationId") Long taxDeclarationId) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getTaxDeclarationWrapper(user)::getTaxDeclarationInfoById, taxDeclarationId); + } + + //个税申报表生成 + @POST + @Path("/save") + @Produces(MediaType.APPLICATION_JSON) + public String save(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody TaxDeclarationSaveParam param) { + User user = HrmUserVarify.getUser(request, response); + param.setSalaryMonth(SalaryDateUtil.String2YearMonth(param.getSalaryMonthStr())); + return new ResponseResult(user).run(getTaxDeclarationWrapper(user)::save, param); + } + + //个税申报表详情列表 + @POST + @Path("/detail/list") + @Produces(MediaType.APPLICATION_JSON) + public String listTaxDeclarationDetail(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody TaxDeclarationDetailListQueryParam param) { + User user = HrmUserVarify.getUser(request, response); + param.setTaxDeclarationId(Long.parseLong(param.getTaxDeclarationIdStr())); + return new ResponseResult(user).run(getTaxDeclarationDetailWrapper(user)::listPage, param); + } + + //个税申报表相关信息 + @GET + @Path("/export") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response exportTaxDeclaration(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "taxDeclarationId") Long taxDeclarationId) { + try { + User user = HrmUserVarify.getUser(request, response); + XSSFWorkbook workbook = getTaxDeclarationExcelService(user).exportTaxDeclaration(taxDeclarationId); + + String fileName = "个税申报表" + LocalDate.now(); + try { + fileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + + StreamingOutput output = outputStream -> { + workbook.write(outputStream); + outputStream.flush(); + }; + response.setContentType("application/octet-stream"); + return Response.ok(output).header("Content-disposition", "attachment;filename=" + fileName).header("Cache-Control", "no-cache").build(); + } catch (Exception e) { + log.error("个税申报表导出异常", e); + throw e; + } + } +} diff --git a/src/com/engine/salary/web/TaxRateController.java b/src/com/engine/salary/web/TaxRateController.java new file mode 100644 index 000000000..b452332b4 --- /dev/null +++ b/src/com/engine/salary/web/TaxRateController.java @@ -0,0 +1,92 @@ +package com.engine.salary.web; + +import com.engine.common.util.ParamUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.salary.entity.taxrate.param.TaxRateSaveParam; +import com.engine.salary.service.TaxRateBaseService; +import com.engine.salary.service.impl.TaxRateBaseServiceImpl; +import com.engine.salary.util.ResponseResult; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import weaver.general.BaseBean; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import java.util.Collection; +import java.util.Map; + +public class TaxRateController { + + private BaseBean logger = new BaseBean(); + + private TaxRateBaseService getService(User user) { + return (TaxRateBaseService) ServiceUtil.getService(TaxRateBaseServiceImpl.class, user); + } + + + //税率表列表 + @GET + @Path("/list") + @Produces(MediaType.APPLICATION_JSON) + public String list(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult< Map, Map>(user).run(getService(user)::listPage,ParamUtil.request2Map(request)); + } + + //税率表列表 + @GET + @Path("/getForm") + @Produces(MediaType.APPLICATION_JSON) + public String getForm(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult< Map, Map>(user).run(getService(user)::getForm,ParamUtil.request2Map(request)); + } + + + /** + * 新建税率表 + */ + @POST + @Path("/save") + @Produces(MediaType.APPLICATION_JSON) + public String save(@Context HttpServletRequest request, @Context HttpServletResponse response,@RequestBody TaxRateSaveParam taxRateSaveParam) { + User user = HrmUserVarify.getUser(request, response); + Map map = ParamUtil.request2Map(request); + map.put("taxRateSaveParam",taxRateSaveParam); + return new ResponseResult< Map, Map>(user).run(getService(user)::save,map); + } + + /** + * 编辑税率表 + */ + @POST + @Path("/update") + @Produces(MediaType.APPLICATION_JSON) + public String update(@Context HttpServletRequest request, @Context HttpServletResponse response,@RequestBody TaxRateSaveParam taxRateSaveParam) { + User user = HrmUserVarify.getUser(request, response); + Map map = ParamUtil.request2Map(request); + map.put("taxRateSaveParam",taxRateSaveParam); + return new ResponseResult< Map, Map>(user).run(getService(user)::update,map); + } + + /** + * 删除税率表 + */ + @POST + @Path("/delete") + @Produces(MediaType.APPLICATION_JSON) + public String deleteTaxRate(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Collection ids) { + User user = HrmUserVarify.getUser(request, response); + Map map = ParamUtil.request2Map(request); + map.put("ids",ids); + return new ResponseResult< Map, Map>(user).run(getService(user)::delete,map); + } + +} diff --git a/src/com/engine/salary/web/VariableArchiveController.java b/src/com/engine/salary/web/VariableArchiveController.java new file mode 100644 index 000000000..f179c9683 --- /dev/null +++ b/src/com/engine/salary/web/VariableArchiveController.java @@ -0,0 +1,259 @@ +package com.engine.salary.web; + +import com.engine.common.util.ServiceUtil; +import com.engine.salary.entity.datacollection.dto.VariableItemListDTO; +import com.engine.salary.entity.datacollection.param.VariableArchiveImportHandleParam; +import com.engine.salary.entity.datacollection.param.VariableArchiveQueryParam; +import com.engine.salary.entity.datacollection.param.VariableArchiveSaveParam; +import com.engine.salary.util.ResponseResult; +import com.engine.salary.util.SalaryDateUtil; +import com.engine.salary.util.excel.ExcelPreviewDTO; +import com.engine.salary.wrapper.VariableArchiveWrapper; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.math.NumberUtils; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.StreamingOutput; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.time.LocalDate; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * 数据采集-浮动薪酬 + *

Copyright: Copyright (c) 2024

+ *

Company: 泛微软件

+ * + * @author xzy + * @version 1.0 + **/ +@Slf4j +public class VariableArchiveController { + + private VariableArchiveWrapper getVariableArchiveWrapper(User user) { + return ServiceUtil.getService(VariableArchiveWrapper.class, user); + } + + /** + * 浮动薪酬列表 + * + * @param request + * @param response + * @param queryParam + * @return + */ + @POST + @Path("/list") + @Produces(MediaType.APPLICATION_JSON) + public String list(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody VariableArchiveQueryParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getVariableArchiveWrapper(user)::list, queryParam); + } + + /** + * 浮动薪酬明细 + * + * @param request + * @param response + * @param queryParam + * @return + */ + @POST + @Path("/getDetail") + @Produces(MediaType.APPLICATION_JSON) + public String getDetail(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody VariableArchiveQueryParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getVariableArchiveWrapper(user)::getDetail, queryParam); + } + + /** + * 获取创建浮动薪酬档案时项目信息 + * + * @param request + * @param response + * @return + */ + @POST + @Path("/getCreateForm") + @Produces(MediaType.APPLICATION_JSON) + public String getCreateForm(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getVariableArchiveWrapper(user)::getCreateForm); + } + + /** + * 创建浮动薪酬档案 + * + * @param request + * @param response + * @param saveParam + * @return + */ + @POST + @Path("/createData") + @Produces(MediaType.APPLICATION_JSON) + public String createData(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody VariableArchiveSaveParam saveParam) { + User user = HrmUserVarify.getUser(request, response); + if (saveParam.getId() == null) { + return new ResponseResult(user).run(getVariableArchiveWrapper(user)::createData, saveParam); + } else { + // 更新 + return new ResponseResult(user).run(getVariableArchiveWrapper(user)::updateData, saveParam); + } + } + + + @GET + @Path("/downloadTemplate") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response downloadTemplate(@Context HttpServletRequest request, @Context HttpServletResponse response) { + try { + User user = HrmUserVarify.getUser(request, response); + VariableArchiveQueryParam param = buildParam(request); + + XSSFWorkbook workbook = getVariableArchiveWrapper(user).downloadTemplate(param); + String fileName = "浮动薪酬导入模板" + LocalDate.now(); + try { + fileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + + StreamingOutput output = outputStream -> { + workbook.write(outputStream); + outputStream.flush(); + }; + response.setContentType("application/octet-stream"); + return Response.ok(output).header("Content-disposition", "attachment;filename=" + fileName).header("Cache-Control", "no-cache").build(); + + } catch (Exception e) { + log.error("浮动薪酬导入模板异常", e); + throw e; + } + } + + + /** + * 导出 + * + * @param + * @return + */ + @POST + @Path("/export") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response export(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody VariableArchiveQueryParam param) { + try { + User user = HrmUserVarify.getUser(request, response); + // VariableArchiveQueryParam param = buildParam(request); + // String columns = request.getParameter("columns"); + // if (StringUtils.isNotBlank(columns)) { + // param.setColumns(Arrays.stream(columns.split(",")).collect(Collectors.toList())); + // } + + XSSFWorkbook workbook = getVariableArchiveWrapper(user).export(param); + + String fileName = null; + try { + fileName = URLEncoder.encode("浮动薪酬" + LocalDate.now() + ".xlsx", "UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + + StreamingOutput output = outputStream -> { + workbook.write(outputStream); + outputStream.flush(); + }; + + response.setContentType("application/octet-stream"); + return Response.ok(output) + .header("Content-disposition", "attachment;filename=" + fileName) + .header("Cache-Control", "no-cache").build(); + } catch (Exception e) { + log.error("浮动薪酬导出异常", e); + throw e; + } + } + + + + private VariableArchiveQueryParam buildParam(HttpServletRequest request) { + VariableArchiveQueryParam param = new VariableArchiveQueryParam(); + + String salaryMonthStr = request.getParameter("salaryMonth"); + if (StringUtils.isNotBlank(salaryMonthStr)) { + param.setSalaryMonth(salaryMonthStr); + param.setSalaryMonthDate(SalaryDateUtil.dateStrToLocalYearMonth(salaryMonthStr)); + } + String username = request.getParameter("username"); + if (StringUtils.isNotBlank(username)) { + param.setUsername(username); + } + + String departmentIdStr = request.getParameter("departmentIds"); + if (StringUtils.isNotBlank(departmentIdStr)) { + List departmentIds = Arrays.stream(departmentIdStr.split(",")).filter(NumberUtils::isCreatable).map(Long::valueOf).collect(Collectors.toList()); + param.setDepartmentIds(departmentIds); + } + String workcode = request.getParameter("workcode"); + if (StringUtils.isNotBlank(workcode)) { + param.setWorkcode(workcode); + } + + String hasData = request.getParameter("hasData"); + if (StringUtils.isNotBlank(hasData)) { + param.setHasData(hasData.equals("true")); + } + + return param; + } + + @POST + @Path("/preview") + @Produces(MediaType.APPLICATION_JSON) + public String preview(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody VariableArchiveImportHandleParam importParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getVariableArchiveWrapper(user)::preview, importParam); + } + + @POST + @Path("/importData") + @Produces(MediaType.APPLICATION_JSON) + public String importAddUpDeduction(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody VariableArchiveImportHandleParam importParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getVariableArchiveWrapper(user)::importData, importParam); + } + + + /** + * @description 删除 + * @return String + * @author Harryxzy + * @date 2024/08/08 14:41 + */ + @POST + @Path("/deleteSelectData") + @Produces(MediaType.APPLICATION_JSON) + public String deleteSelectVariableArchive(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody VariableArchiveQueryParam variableArchiveQueryParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult, String>(user).run(getVariableArchiveWrapper(user)::deleteSelectVariableArchive, variableArchiveQueryParam.getIds()); + } + +} diff --git a/src/com/engine/salary/web/VariableItemController.java b/src/com/engine/salary/web/VariableItemController.java new file mode 100644 index 000000000..70146a585 --- /dev/null +++ b/src/com/engine/salary/web/VariableItemController.java @@ -0,0 +1,324 @@ +package com.engine.salary.web; + +import com.engine.common.util.ServiceUtil; +import com.engine.salary.entity.datacollection.dto.VariableItemListDTO; +import com.engine.salary.entity.datacollection.param.VariableItemQueryParam; +import com.engine.salary.entity.datacollection.param.VariableItemSaveParam; +import com.engine.salary.util.ResponseResult; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.wrapper.VariableItemWrapper; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import lombok.extern.slf4j.Slf4j; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import java.util.List; + +/** + * 数据采集-浮动薪酬项目 + *

Copyright: Copyright (c) 2024

+ *

Company: 泛微软件

+ * + * @author xzy + * @version 1.0 + **/ +@Slf4j +public class VariableItemController { + + private VariableItemWrapper getVariableItemWrapper(User user) { + return ServiceUtil.getService(VariableItemWrapper.class, user); + } + + /** + * 浮动薪酬项目列表 + * + * @return + */ + @POST + @Path("/listPage") + @Produces(MediaType.APPLICATION_JSON) + public String listPage(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody VariableItemQueryParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getVariableItemWrapper(user)::listPage, queryParam); + } + + + /** + * 浮动薪酬项目详细信息 + * + * @return + */ + @POST + @Path("/getDetail") + @Produces(MediaType.APPLICATION_JSON) + public String getDetail(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody VariableItemQueryParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getVariableItemWrapper(user)::getDetail, queryParam.getId()); + } + + + /** + * 保存浮动薪资项目 + * + * @param request + * @param response + * @param saveParam + * @return + */ + @POST + @Path("/save") + @Produces(MediaType.APPLICATION_JSON) + public String saveVariableItem(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody VariableItemSaveParam saveParam) { + User user = HrmUserVarify.getUser(request, response); + if (saveParam.getId() == null || saveParam.getId() <= 0) { + return new ResponseResult(request, response, user).run(getVariableItemWrapper(user)::save, saveParam); + } else { + return new ResponseResult(request, response, user).run(getVariableItemWrapper(user)::update, saveParam); + } + } + + + + /** + * 删除浮动薪资项目 + * + * @param request + * @param response + * @param param + * @return + */ + @POST + @Path("/delete") + @Produces(MediaType.APPLICATION_JSON) + public String deleteItem(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody VariableItemQueryParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult, String>(request, response, user).run(getVariableItemWrapper(user)::deleteItems, param.getItemIds()); + } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + // @GET + // @Path("/downloadTemplate") + // @Produces(MediaType.APPLICATION_OCTET_STREAM) + // public Response getAll(@Context HttpServletRequest request, @Context HttpServletResponse response) { + // try { + // User user = HrmUserVarify.getUser(request, response); + // OtherDeductionQueryParam param = buildParam(request); + // + // XSSFWorkbook workbook = getOtherDeductionWrapper(user).downloadTemplate(param); + // String fileName = "其他免税扣除导入模板" + LocalDate.now(); + // try { + // fileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8"); + // } catch (UnsupportedEncodingException e) { + // e.printStackTrace(); + // } + // + // StreamingOutput output = outputStream -> { + // workbook.write(outputStream); + // outputStream.flush(); + // }; + // response.setContentType("application/octet-stream"); + // return Response.ok(output).header("Content-disposition", "attachment;filename=" + fileName).header("Cache-Control", "no-cache").build(); + // + // } catch (Exception e) { + // log.error("其他免税扣除导入模板异常", e); + // throw e; + // } + // } + // + // + // /** + // * 导出 + // * + // * @param + // * @return + // */ + // @GET + // @Path("/export") + // @Produces(MediaType.APPLICATION_OCTET_STREAM) + // public Response export(@Context HttpServletRequest request, @Context HttpServletResponse response) { + // try { + // User user = HrmUserVarify.getUser(request, response); + // + // OtherDeductionQueryParam param = buildParam(request); + // + // XSSFWorkbook workbook = getOtherDeductionWrapper(user).export(param); + // + // String fileName = null; + // try { + // fileName = URLEncoder.encode("其他免税扣除" + LocalDate.now() + ".xlsx", "UTF-8"); + // } catch (UnsupportedEncodingException e) { + // e.printStackTrace(); + // } + // + // StreamingOutput output = outputStream -> { + // workbook.write(outputStream); + // outputStream.flush(); + // }; + // + // response.setContentType("application/octet-stream"); + // return Response.ok(output) + // .header("Content-disposition", "attachment;filename=" + fileName) + // .header("Cache-Control", "no-cache").build(); + // } catch (Exception e) { + // log.error("其他免税扣除导出异常", e); + // throw e; + // } + // } + // + // + // + // + // @Nullable + // private OtherDeductionQueryParam buildParam(HttpServletRequest request) { + // OtherDeductionQueryParam param = new OtherDeductionQueryParam(); + // String ids = request.getParameter("ids"); + // if (StringUtils.isNotBlank(ids)) { + // param.setIds(Arrays.stream(ids.split(",")).map(Long::valueOf).collect(Collectors.toList())); + // } + // String keyword = request.getParameter("keyword"); + // if (StringUtils.isNotBlank(keyword)) { + // param.setKeyword(keyword); + // } + // String id = request.getParameter("id"); + // if (StringUtils.isNotBlank(id)) { + // param.setId(Long.valueOf(id)); + // } + // String declareMonth = request.getParameter("declareMonth"); + // if (StringUtils.isNotBlank(declareMonth)) { + // param.setDeclareMonth(Arrays.stream(declareMonth.split(",")).map(e -> e + "-01 00:00:00").collect(Collectors.toList())); + // param.setDeclareMonthDate(Arrays.stream(declareMonth.split(",")).map(e -> e + "-01 00:00:00").map(SalaryDateUtil::dateStrToLocalTime).collect(Collectors.toList())); + // } + // + // String username = request.getParameter("username"); + // if (StringUtils.isNotBlank(username)) { + // param.setUsername(username); + // } + // String employeeId = request.getParameter("employeeId"); + // if (StringUtils.isNotBlank(employeeId)) { + // param.setEmployeeId(Long.valueOf(employeeId)); + // } + // String taxAgentId = request.getParameter("taxAgentId"); + // if (StringUtils.isNotBlank(taxAgentId)) { + // param.setTaxAgentId(Long.valueOf(taxAgentId)); + // } + // String departmentIds = request.getParameter("departmentIds"); + // if (StringUtils.isNotBlank(departmentIds)) { + // param.setDepartmentIds(Arrays.stream(departmentIds.split(",")).map(Long::valueOf).collect(Collectors.toList())); + // } + // String jobNum = request.getParameter("jobNum"); + // if (StringUtils.isNotBlank(jobNum)) { + // param.setJobNum(jobNum); + // } + // String idNo = request.getParameter("idNo"); + // if (StringUtils.isNotBlank(idNo)) { + // param.setIdNo(idNo); + // } + // String hiredate = request.getParameter("hiredate"); + // if (StringUtils.isNotBlank(hiredate)) { + // SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + // List dates = Arrays.stream(hiredate.split(",")).map(d -> { + // try { + // return format.parse(d); + // } catch (ParseException e) { + // e.printStackTrace(); + // } + // return null; + // }).collect(Collectors.toList()); + // param.setHiredate(dates); + // } + // String mobile = request.getParameter("mobile"); + // if (StringUtils.isNotBlank(mobile)) { + // param.setMobile(mobile); + // } + // String otherTaxExemptDeductionId = request.getParameter("otherTaxExemptDeductionId"); + // if (StringUtils.isNotBlank(otherTaxExemptDeductionId)) { + // param.setOtherTaxExemptDeductionId(Long.valueOf(otherTaxExemptDeductionId)); + // } + // + // String hasData = request.getParameter("hasData"); + // if (StringUtils.isNotBlank(hasData)) { + // param.setHasData("true".equals(hasData)); + // } + // return param; + // } + // + // @POST + // @Path("/preview") + // @Produces(MediaType.APPLICATION_JSON) + // public String preview(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody OtherDeductionImportParam importParam) { + // User user = HrmUserVarify.getUser(request, response); + // return new ResponseResult>(user).run(getOtherDeductionWrapper(user)::preview, importParam); + // } + // + // @POST + // @Path("/importData") + // @Produces(MediaType.APPLICATION_JSON) + // public String importAddUpDeduction(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody OtherDeductionImportParam importParam) { + // User user = HrmUserVarify.getUser(request, response); + // return new ResponseResult>(user).run(getOtherDeductionWrapper(user)::importData, importParam); + // } + // + // /** + // * @description 获取其他免税扣除数据 + // * @return String + // * @author Harryxzy + // * @date 2022/10/31 13:42 + // */ + // @POST + // @Path("/getData") + // @Produces(MediaType.APPLICATION_JSON) + // public String getOtherDeduction(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody OtherDeductionParam otherDeductionParam) { + // User user = HrmUserVarify.getUser(request, response); + // return new ResponseResult(user).run(getOtherDeductionWrapper(user)::getOtherDeduction, otherDeductionParam); + // } + // + // /** + // * @description 删除所选其他免税扣除 + // * @return String + // * @author Harryxzy + // * @date 2022/10/27 14:41 + // */ + // @POST + // @Path("/deleteSelectData") + // @Produces(MediaType.APPLICATION_JSON) + // public String deleteSelectOtherDeduction(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody AddUpDeductionRecordDeleteParam otherDeductionDeleteParam) { + // User user = HrmUserVarify.getUser(request, response); + // return new ResponseResult>(user).run(getOtherDeductionWrapper(user)::deleteSelectData, otherDeductionDeleteParam); + // } + +} diff --git a/src/com/engine/salary/wrapper/AddUpDeductionWrapper.java b/src/com/engine/salary/wrapper/AddUpDeductionWrapper.java new file mode 100644 index 000000000..7bceb9672 --- /dev/null +++ b/src/com/engine/salary/wrapper/AddUpDeductionWrapper.java @@ -0,0 +1,173 @@ +package com.engine.salary.wrapper; + +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.entity.datacollection.AddUpDeduction; +import com.engine.salary.entity.datacollection.dto.AddUpDeductionDTO; +import com.engine.salary.entity.datacollection.dto.AddUpDeductionRecordDTO; +import com.engine.salary.entity.datacollection.param.*; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.service.AddUpDeductionService; +import com.engine.salary.service.SalaryEmployeeService; +import com.engine.salary.service.TaxAgentService; +import com.engine.salary.service.impl.AddUpDeductionServiceImpl; +import com.engine.salary.service.impl.SalaryEmployeeServiceImpl; +import com.engine.salary.service.impl.TaxAgentServiceImpl; +import com.engine.salary.util.SalaryDateUtil; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.page.PageInfo; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import weaver.general.BaseBean; +import weaver.hrm.User; + +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * 累计专项附加扣除 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Slf4j +public class AddUpDeductionWrapper extends Service { + + private final BaseBean baseBean = new BaseBean(); + private final Boolean isLog = "true".equals(baseBean.getPropValue("hrmSalary", "log")); + + private AddUpDeductionService getAddUpDeductionService(User user) { + return ServiceUtil.getService(AddUpDeductionServiceImpl.class, user); + } + + private TaxAgentService getTaxAgentService(User user) { + return ServiceUtil.getService(TaxAgentServiceImpl.class, user); + } + + private SalaryEmployeeService getSalaryEmployeeService(User user) { + return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user); + } + + + /** + * 数据采集-累计专项附加扣除列表(分页) + * + * @param queryParam + * @return + */ + public PageInfo list(AddUpDeductionQueryParam queryParam) { + PageInfo pageInfo = getAddUpDeductionService(user).listPage(queryParam); + + return pageInfo; + } + + /** + * 数据采集-累计专项附加扣除详情列表(分页) + * + * @param queryParam + * @return + */ + public PageInfo getDetailList(AddUpDeductionQueryParam queryParam) { + Long id = queryParam.getAccumulatedSpecialAdditionalDeductionId(); + AddUpDeduction po = getAddUpDeductionService(user).getById(id); + if (po == null) { + throw new SalaryRunTimeException(String.format(SalaryI18nUtil.getI18nLabel(100338, "累计专项附加扣除不存在") + "[id:%s]", id)); + } + + //申报月份 + List declareMonth = queryParam.getDeclareMonth(); + if (CollectionUtils.isNotEmpty(declareMonth)) { + queryParam.setDeclareMonth(declareMonth.stream().map(e -> e + "-01 00:00:00").collect(Collectors.toList())); + queryParam.setDeclareMonthDate(declareMonth.stream().map(e -> e + "-01 00:00:00").map(SalaryDateUtil::dateStrToLocalTime).collect(Collectors.toList())); + } + queryParam.setEmployeeId(po.getEmployeeId()); + + PageInfo page = getAddUpDeductionService(user).recordListPage(queryParam); + + return page; + } + + + /** + * 导出-累计专项附加扣除列表 + * + * @param queryParam + * @return + */ + public XSSFWorkbook export(AddUpDeductionQueryParam queryParam) { + return getAddUpDeductionService(user).export( queryParam); + } + + /** + * 导出-累计专项附加扣除详情列表 + * + * @param queryParam + * @return + */ + public XSSFWorkbook exportDetail(AddUpDeductionQueryParam queryParam) { + Long id = queryParam.getAccumulatedSpecialAdditionalDeductionId(); + AddUpDeduction po = getAddUpDeductionService(user).getById(id); + if (po == null) { + throw new SalaryRunTimeException(String.format(SalaryI18nUtil.getI18nLabel(100338, "累计专项附加扣除不存在") + "[id:%s]", id)); + } + + return getAddUpDeductionService(user).exportDetail(po.getEmployeeId(), queryParam); + } + + /** + * 下载导入模板 + * + * @param queryParam + * @return + */ + public XSSFWorkbook downloadTemplate(AddUpDeductionQueryParam queryParam) { + return getAddUpDeductionService(user).downloadTemplate(queryParam); + } + + + public Map importAddUpDeduction(AddUpDeductionImportParam importParam) { + return getAddUpDeductionService(user).importAddUpDeduction(importParam); + } + + + public Map preview(AddUpDeductionImportParam importParam) { + return getAddUpDeductionService(user).preview(importParam); + } + + public Map getSearchCondition(Map params) { + return getAddUpDeductionService(user).getSearchCondition(params); + } + + public void editAddUpDeduction(AddUpDeductionRecordParam addUpDeduction) { + getAddUpDeductionService(user).editAddUpDeduction(addUpDeduction); + } + + public void createAddUpDeduction(AddUpDeductionRecordParam addUpDeductionRecordParam) { + getAddUpDeductionService(user).createAddUpDeduction(addUpDeductionRecordParam); + } + + public void deleteSelectAddUpDeduction(AddUpDeductionRecordDeleteParam deleteParam) { + getAddUpDeductionService(user).deleteSelectAddUpDeduction(deleteParam); + } + + public void deleteAllAddUpDeduction(AddUpDeductionRecordDeleteParam deleteParam) { + getAddUpDeductionService(user).deleteAllAddUpDeduction(deleteParam); + } + + public AddUpDeductionRecordDTO getAddUpDeduction(AddUpDeductionQueryParam param) { + return getAddUpDeductionService(user).getAddUpDeduction(param); + } + + public String autoAddAll(AddDeductionAutoAddParam param) { + Date yearMonth = param.getYearMonthDate(); + if (yearMonth == null) { + throw new SalaryRunTimeException("一键累计传入日期格式错误"); + } + return getAddUpDeductionService(user).autoAddAll(yearMonth, false, param.getTaxAgentIds()); + } +} diff --git a/src/com/engine/salary/wrapper/AddUpSituationWrapper.java b/src/com/engine/salary/wrapper/AddUpSituationWrapper.java new file mode 100644 index 000000000..9e76f49b2 --- /dev/null +++ b/src/com/engine/salary/wrapper/AddUpSituationWrapper.java @@ -0,0 +1,172 @@ +package com.engine.salary.wrapper; + +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.entity.datacollection.AddUpSituation; +import com.engine.salary.entity.datacollection.dto.AddUpSituationDTO; +import com.engine.salary.entity.datacollection.dto.AddUpSituationRecordDTO; +import com.engine.salary.entity.datacollection.param.AddUpSituationDeleteParam; +import com.engine.salary.entity.datacollection.param.AddUpSituationImportParam; +import com.engine.salary.entity.datacollection.param.AddUpSituationParam; +import com.engine.salary.entity.datacollection.param.AddUpSituationQueryParam; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.service.AddUpSituationService; +import com.engine.salary.service.impl.AddUpSituationServiceImpl; +import com.engine.salary.util.SalaryDateUtil; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.page.PageInfo; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import weaver.hrm.User; + +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * 往期累计情况 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class AddUpSituationWrapper extends Service { + + private AddUpSituationService getAddUpSituationService(User user) { + return ServiceUtil.getService(AddUpSituationServiceImpl.class, user); + } + + /** + * 数据采集-累计情况列表的高级搜索 + * + * @return + */ + public Map getSearchCondition() { + return getAddUpSituationService(user).getSearchCondition(); + } + + /** + * 数据采集-累计情况列表(分页) + * + * @param queryParam + * @return + */ + public PageInfo list(AddUpSituationQueryParam queryParam) { + return getAddUpSituationService(user).listPage(queryParam); + } + + /** + * 数据采集-往期累计情况详情列表(分页) + * + * @param queryParam + * @return + */ + public PageInfo getDetailList(AddUpSituationQueryParam queryParam) { + Long id = queryParam.getAccumulatedSituationId(); + AddUpSituation po = getAddUpSituationService(user).getById(id); + if (po == null) { + throw new SalaryRunTimeException(String.format(SalaryI18nUtil.getI18nLabel(100352, "累计情况不存在") + "[id:%s]", id)); + } + List taxYearMonths = queryParam.getTaxYearMonth(); + if (CollectionUtils.isNotEmpty(taxYearMonths)) { + queryParam.setTaxYearMonth(taxYearMonths.stream().map(e -> e + "-01 00:00:00").collect(Collectors.toList())); + queryParam.setTaxYearMonthDate(taxYearMonths.stream().map(e -> e + "-01 00:00:00").map(SalaryDateUtil::dateStrToLocalTime).collect(Collectors.toList())); + } + queryParam.setEmployeeId(po.getEmployeeId()); + return getAddUpSituationService(user).recordListPage(queryParam); + } + + /** + * 导出-往期累计情况列表 + * + * @param queryParam + * @return + */ + public XSSFWorkbook export(AddUpSituationQueryParam queryParam) { + return getAddUpSituationService(user).export(queryParam); + } + + /** + * 导出详情列表 + * + * @param queryParam + * @return + */ + public XSSFWorkbook exportDetail(AddUpSituationQueryParam queryParam) { + Long id = queryParam.getAccumulatedSituationId(); + AddUpSituation po = getAddUpSituationService(user).getById(id); + if (po == null) { + throw new SalaryRunTimeException(String.format(SalaryI18nUtil.getI18nLabel(100352, "累计情况不存在") + "[id:%s]", id)); + } + return getAddUpSituationService(user).exportDetail(queryParam); + } + + /** + * 下载导入模板 + * + * @param queryParam + * @return + */ + public XSSFWorkbook downloadTemplate(AddUpSituationQueryParam queryParam) { + return getAddUpSituationService(user).downloadTemplate(queryParam); + } + + public Map preview(AddUpSituationImportParam importParam){ + return getAddUpSituationService(user).preview(importParam); + } + + public Map importAddUpSituation(AddUpSituationImportParam importParam){ + return getAddUpSituationService(user).importAddUpSituation(importParam); + } + + /** + * @description 编辑数据 + * @return void + * @author Harryxzy + * @date 2022/10/27 21:30 + */ + public void editAddUpSituation(AddUpSituationParam addUpSituationParam) { + getAddUpSituationService(user).editAddUpSituation(addUpSituationParam); + } + + /** + * @description 新建数据 + * @return void + * @author Harryxzy + * @date 2022/10/27 22:00 + */ + public void createAddUpSituation(AddUpSituationParam addUpSituationParam) { + getAddUpSituationService(user).createAddUpSituation(addUpSituationParam); + } + + /** + * @description 删除所选数据 + * @return void + * @author Harryxzy + * @date 2022/10/27 22:34 + */ + public void deleteSelectAddUpSituation(AddUpSituationDeleteParam deleteParam) { + getAddUpSituationService(user).deleteSelectAddUpSituation(deleteParam); + } + + /** + * @description 一键清空数据 + * @return void + * @author Harryxzy + * @date 2022/10/27 22:34 + */ + public void deleteAllAddUpSituation(AddUpSituationDeleteParam addUpSituationDeleteParam) { + getAddUpSituationService(user).deleteAllAddUpSituation(addUpSituationDeleteParam); + } + + /** + * @description 获取往期累计情况 + * @return null + * @author Harryxzy + * @date 2022/10/31 14:00 + */ + public AddUpSituationRecordDTO getAddUpSituation(AddUpSituationParam addUpSituationParam) { + return getAddUpSituationService(user).getAddUpSituation(addUpSituationParam); + } +} diff --git a/src/com/engine/salary/wrapper/AttendQuoteDataWrapper.java b/src/com/engine/salary/wrapper/AttendQuoteDataWrapper.java new file mode 100644 index 000000000..2e5d4e579 --- /dev/null +++ b/src/com/engine/salary/wrapper/AttendQuoteDataWrapper.java @@ -0,0 +1,182 @@ +package com.engine.salary.wrapper; + +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.entity.datacollection.dto.AttendQuoteDataBaseDTO; +import com.engine.salary.entity.datacollection.param.*; +import com.engine.salary.entity.datacollection.po.AttendQuoteFieldPO; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.service.AttendQuoteDataService; +import com.engine.salary.service.AttendQuoteFieldService; +import com.engine.salary.service.impl.AttendQuoteDataServiceImpl; +import com.engine.salary.service.impl.AttendQuoteFieldServiceImpl; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.page.Column; +import com.engine.salary.util.page.PageInfo; +import org.apache.commons.collections.CollectionUtils; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import weaver.general.Util; +import weaver.hrm.User; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * 考勤数据 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class AttendQuoteDataWrapper extends Service { + + private AttendQuoteDataService getAttendQuoteDataService(User user) { + return ServiceUtil.getService(AttendQuoteDataServiceImpl.class, user); + } + + private AttendQuoteFieldService getAttendQuoteFieldService(User user) { + return ServiceUtil.getService(AttendQuoteFieldServiceImpl.class, user); + } + + /** + * 同步考勤引用数据 + * + * @param syncParam + * @return + */ + public String syncAttendQuoteData(AttendQuoteDataSyncParam syncParam) { + return getAttendQuoteDataService(user).syncAttendQuoteData(syncParam); + } + + /** + * 查看考勤引用数据 + * + * @param queryParam + * @return + */ + public Map view(AttendQuoteDataQueryParam queryParam) { + Long id = queryParam.getAttendQuoteId(); + if (id == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100253, "考勤引用id不能为空")); + } + // 考勤数据分页主数据 + PageInfo page = getAttendQuoteDataService(user).listPage(queryParam); + List attendQuoteDataBases = page.getList(); + // 所有考勤字段 + List attendQuoteFields = getAttendQuoteFieldService(user).getAllAttendQuoteFields(); + // 获取最终结果 + List> listMaps = getAttendQuoteDataService(user).getListMaps(attendQuoteDataBases); + + //当前引用的值 + List effectiveColumns = listMaps.stream() + .map(Map::keySet) + .max(Comparator.comparingInt(Set::size)) + .orElse(new HashSet<>()) + .stream() + .map(key -> key.split("_")[0]) + .collect(Collectors.toList()); + + + PageInfo> listPage = new PageInfo<>(listMaps); + listPage.setPageNum(page.getPageNum()); + listPage.setPageSize(page.getPageSize()); + listPage.setTotal(page.getTotal()); + List columns = new ArrayList<>(); + columns.add(Column.builder().title("姓名").dataIndex("username").key("username").display(Boolean.TRUE).build()); + columns.add(Column.builder().title("部门").dataIndex("departmentName").key("departmentName").display(Boolean.TRUE).build()); + columns.add(Column.builder().title("手机号").dataIndex("mobile").key("mobile").display(Boolean.TRUE).build()); + columns.add(Column.builder().title("工号").dataIndex("jobNum").key("jobNum").display(Boolean.TRUE).build()); + columns.add(Column.builder().title("证件号码").dataIndex("idNo").key("idNo").display(Boolean.TRUE).build()); + if (CollectionUtils.isNotEmpty(listMaps)) { + attendQuoteFields.stream() + .filter(attendQuoteField->effectiveColumns.contains(Util.null2String(attendQuoteField.getId()))) + .forEach(attendQuoteField -> { + columns.add(Column.builder().title(attendQuoteField.getFieldName()) + .dataIndex(attendQuoteField.getId() + "_attendQuoteData") + .key(attendQuoteField.getId() + "_attendQuoteData").display(Boolean.TRUE).build()); + } + ); + + } + listPage.setColumns(columns); + // 表格表头 +// List columns = new ArrayList<>(); +// columns.add(new WeaTableColumn("150", SalaryI18nUtil.getI18nLabel(85429, "姓名"), "username")); +// columns.add(new WeaTableColumn("150", SalaryI18nUtil.getI18nLabel(86185, "部门"), "departmentName")); +// columns.add(new WeaTableColumn("150", SalaryI18nUtil.getI18nLabel(86186, "手机号"), "mobile")); +// columns.add(new WeaTableColumn("150", SalaryI18nUtil.getI18nLabel(86317, "工号"), "jobNum")); + // 动态列 +// if (CollectionUtils.isNotEmpty(listMaps)) { +// for (AttendQuoteFieldPO attendQuoteField : attendQuoteFields) { +// columns.add(new WeaTableColumn("150", attendQuoteField.getFieldName(), attendQuoteField.getId() + "_attendQuoteData")); +// } +// } +// +// WeaTable weaTable = new WeaTable(); +// weaTable.setColumns(columns); + +// +// WeaResultMsg result = new WeaResultMsg(false); +// result.putAll(weaTable.makeDataResult()); +// result.success(); + + Map datas = new HashMap<>(); + datas.put("pageInfo", listPage); +// datas.put("dataKey", result.getResultMap()); + + return datas; + } + + /** + * 下载导入模板 + * + * @param templateParam + * @return + */ + public XSSFWorkbook downloadTemplate(AttendQuoteDataExportTemplateParam templateParam) { + return getAttendQuoteDataService(user).downloadTemplate(templateParam); + } + + /** + * 导出考勤引用数据 + * + * @param queryParam + * @return + */ + public XSSFWorkbook export(AttendQuoteDataQueryParam queryParam) { + return getAttendQuoteDataService(user).export(queryParam); + } + + /** + * 预览 + * + * @param param + * @return + */ + public Map preview(AttendQuoteDataImportParam param) { + return getAttendQuoteDataService(user).preview(param); + } + + + /** + * 导入 + * + * @param param + * @return + */ + public Map importAttendQuoteData(AttendQuoteDataImportParam param) { + return getAttendQuoteDataService(user).importAttendQuoteData(param); + } + + public void editData(AttendQuoteDataEditParam attendQuoteDataEditParam) { + getAttendQuoteDataService(user).editData(attendQuoteDataEditParam); + } + + /** + * 获取数据 + */ + public Map getData(AttendQuoteDataEditParam attendQuoteDataEditParam) { + return getAttendQuoteDataService(user).getData(attendQuoteDataEditParam); + } +} diff --git a/src/com/engine/salary/wrapper/AttendQuoteFieldSettingWrapper.java b/src/com/engine/salary/wrapper/AttendQuoteFieldSettingWrapper.java new file mode 100644 index 000000000..2c5a95e11 --- /dev/null +++ b/src/com/engine/salary/wrapper/AttendQuoteFieldSettingWrapper.java @@ -0,0 +1,68 @@ +package com.engine.salary.wrapper; + +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.entity.datacollection.dto.AttendQuoteFieldSettingListDTO; +import com.engine.salary.entity.datacollection.param.AttendQuoteFieldSettingQueryParam; +import com.engine.salary.entity.datacollection.param.AttendQuoteFieldSettingRecoverParam; +import com.engine.salary.entity.datacollection.param.AttendQuoteFieldSettingSaveParam; +import com.engine.salary.service.AttendQuoteFieldSettingService; +import com.engine.salary.service.impl.AttendQuoteFieldSettingServiceImpl; +import weaver.hrm.User; + +import java.util.List; + +/** + * 考勤引用字段设置 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class AttendQuoteFieldSettingWrapper extends Service { + + private AttendQuoteFieldSettingService getAttendQuoteFieldSettingService(User user) { + return ServiceUtil.getService(AttendQuoteFieldSettingServiceImpl.class, user); + } + + /** + * 考勤引用字段设置列表 + * + * @param queryParam + * @return + */ + public List list(AttendQuoteFieldSettingQueryParam queryParam) { + return getAttendQuoteFieldSettingService(user).list(queryParam); + } + + /** + * 考勤引用字段设置-保存 + * + * @param saveParam + * @return + */ + public String save(AttendQuoteFieldSettingSaveParam saveParam) { + return getAttendQuoteFieldSettingService(user).save(saveParam); + } + + /** + * 考勤引用字段设置-恢复默认设置 + * + * @param recoverParam + * @return + */ + public List recoverAsDefault(AttendQuoteFieldSettingRecoverParam recoverParam) { + return getAttendQuoteFieldSettingService(user).recoverAsDefault(recoverParam); + } + + /** + * 考勤引用字段设置-设为默认设置 + * + * @param saveParam + * @return + */ + public String saveAsDefault(AttendQuoteFieldSettingSaveParam saveParam) { + return getAttendQuoteFieldSettingService(user).saveAsDefault(saveParam); + } +} diff --git a/src/com/engine/salary/wrapper/AttendQuoteFieldWrapper.java b/src/com/engine/salary/wrapper/AttendQuoteFieldWrapper.java new file mode 100644 index 000000000..d1520efe0 --- /dev/null +++ b/src/com/engine/salary/wrapper/AttendQuoteFieldWrapper.java @@ -0,0 +1,147 @@ +package com.engine.salary.wrapper; + +import com.cloudstore.eccom.result.WeaResultMsg; +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.component.SalaryWeaTable; +import com.engine.salary.entity.datacollection.bo.AttendQuoteFieldBO; +import com.engine.salary.entity.datacollection.dto.AttendQuoteFieldFormDTO; +import com.engine.salary.entity.datacollection.dto.AttendQuoteFieldListDTO; +import com.engine.salary.entity.datacollection.param.AttendQuoteFieldQueryParam; +import com.engine.salary.entity.datacollection.param.AttendQuoteFieldSaveParam; +import com.engine.salary.entity.datacollection.po.AttendQuoteFieldPO; +import com.engine.salary.enums.datacollection.AttendQuoteFieldSourceTypeEnum; +import com.engine.salary.enums.datacollection.AttendQuoteFieldTypeEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.service.AttendQuoteFieldService; +import com.engine.salary.service.impl.AttendQuoteFieldServiceImpl; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.page.PageInfo; +import org.springframework.beans.BeanUtils; +import weaver.hrm.User; + +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 考勤引用字段 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class AttendQuoteFieldWrapper extends Service { + + private AttendQuoteFieldService getAttendQuoteFieldService(User user) { + return ServiceUtil.getService(AttendQuoteFieldServiceImpl.class, user); + } + + /** + * 考勤字段管理列表(分页) + * + * @param queryParam + * @return + */ + public Map list(AttendQuoteFieldQueryParam queryParam) { + // 同步字段 + syncAttendFields(); + + + PageInfo page = getAttendQuoteFieldService(user).listPage(queryParam); + + List list = page.getList(); + list.forEach(m->{ + Integer sourceType = Integer.valueOf(m.getSourceType()); + m.setSourceType(AttendQuoteFieldSourceTypeEnum.getDefaultLabelByValue(sourceType)); + m.setSourceTypeValue(AttendQuoteFieldSourceTypeEnum.getNameByValue(sourceType)); + m.setFieldType(AttendQuoteFieldTypeEnum.getDefaultLabelByValue(Integer.valueOf(m.getFieldType()))); + }); + page.setList(list); + + SalaryWeaTable table = new SalaryWeaTable<>(user, AttendQuoteFieldListDTO.class); + table.setColumns(AttendQuoteFieldBO.buildRecordTableColumns()); + + + WeaResultMsg result = new WeaResultMsg(false); + result.putAll(table.makeDataResult()); + result.success(); + + Map datas = new HashMap<>(); + datas.put("pageInfo", page); + datas.put("dataKey",result.getResultMap()); + + return datas; + } + + /** + * 同步考勤模块字段 + * + * @return + */ + public String syncAttendFields() { + return getAttendQuoteFieldService(user).syncAttendFields(); + } + + /** + * 获取考勤字段表单 + * + * @param id + * @return + */ + public AttendQuoteFieldFormDTO getFrom(Long id) { + AttendQuoteFieldFormDTO formDTO = new AttendQuoteFieldFormDTO(); + if (id != null) { + AttendQuoteFieldPO po = getAttendQuoteFieldService(user).getById(id); + if (po == null) { + throw new SalaryRunTimeException(String.format(SalaryI18nUtil.getI18nLabel( 100370, "字段不存在")+"[id:%s]", id)); + } + BeanUtils.copyProperties(po, formDTO); + } else { + formDTO.setEnableStatus(0); + } + + return formDTO; + } + + /** + * 新建考勤字段 + * + * @param saveParam + * @return + */ + public String save(AttendQuoteFieldSaveParam saveParam) { + return getAttendQuoteFieldService(user).save(saveParam); + } + + /** + * 启用/停用自定义字段 + * + * @return + */ + public String updateEnableStatus(AttendQuoteFieldSaveParam param) { + return getAttendQuoteFieldService(user).updateEnableStatus(param); + } + + /** + * 修改考勤字段 + * + * @param saveParam + * @return + */ + public String update(AttendQuoteFieldSaveParam saveParam) { + return getAttendQuoteFieldService(user).update(saveParam); + } + + /** + * 删除考勤字段 + * + * @param ids + * @return + */ + public String delete(Collection ids) { + return getAttendQuoteFieldService(user).delete(ids); + } +} diff --git a/src/com/engine/salary/wrapper/AttendQuoteWrapper.java b/src/com/engine/salary/wrapper/AttendQuoteWrapper.java new file mode 100644 index 000000000..d0baa414f --- /dev/null +++ b/src/com/engine/salary/wrapper/AttendQuoteWrapper.java @@ -0,0 +1,159 @@ +package com.engine.salary.wrapper; + +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.common.LocalDateRange; +import com.engine.salary.entity.datacollection.dto.AttendQuoteListDTO; +import com.engine.salary.entity.datacollection.param.AttendQuoteCheckOperationParam; +import com.engine.salary.entity.datacollection.param.AttendQuoteQueryParam; +import com.engine.salary.entity.datacollection.param.QuerySalaryCycleAndAttendCycleParam; +import com.engine.salary.entity.salarysob.dto.SalarySobCycleDTO; +import com.engine.salary.entity.salarysob.po.SalarySobPO; +import com.engine.salary.enums.datacollection.AttendQuoteSourceTypeEnum; +import com.engine.salary.service.AttendQuoteService; +import com.engine.salary.service.SalarySobService; +import com.engine.salary.service.impl.AttendQuoteServiceImpl; +import com.engine.salary.service.impl.SalarySobServiceImpl; +import com.engine.salary.util.SalaryDateUtil; +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.math.NumberUtils; +import weaver.hrm.User; + +import java.time.YearMonth; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * 考勤引用 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class AttendQuoteWrapper extends Service { + + private AttendQuoteService getAttendQuoteService(User user) { + return ServiceUtil.getService(AttendQuoteServiceImpl.class, user); + } + + private SalarySobService getSalarySobService(User user) { + return ServiceUtil.getService(SalarySobServiceImpl.class, user); + } + + + /** + * 考勤引用列表 + * + * @param queryParam + * @return + */ + public PageInfo list(AttendQuoteQueryParam queryParam) { + PageInfo page = getAttendQuoteService(user).listPage(queryParam); + + List list = page.getList(); + if (CollectionUtils.isNotEmpty(list)) { + list.forEach(m -> m.setSourceType(AttendQuoteSourceTypeEnum.getDefaultLabelByValue(Integer.valueOf(m.getSourceType())))); + page.setList(list); + } + + return page; + } + + /** + * 获取引用考勤表单 + * + * @param employeeId + * @return + */ +// public WeaForm getSyncForm(Long employeeId) { +// // 查询所有启用的薪资账套 +// List salarySobs = getSalarySobService(user).listByDisable(NumberUtils.INTEGER_ZERO); +// List salarySobOptions = salarySobs.stream() +// .map(salarySobPO -> new WeaFormOption("" + salarySobPO.getId(), salarySobPO.getName())) +// .collect(Collectors.toList()); +// // 构建表单 +// WeaForm weaForm = FormatManager.getInstance().genForm(AttendQuoteSyncDataFormDTO.class, AttendQuoteSyncDataFormDTO.builder().salarySobOptions(salarySobOptions).build()); +// +// WeaFormItem descriptionItem = weaForm.getItems().get("description"); +// Map otherParams = Maps.newHashMap(); +// otherParams.put("showCount", true); +// otherParams.put("placeholder", SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 85987, "请输入")); +// descriptionItem.setOtherParams(otherParams); +// weaForm.getItems().put("description", descriptionItem); +// +// WeaFormItem salaryYearMonthItem = weaForm.getItems().get("salaryYearMonth"); +// otherParams = Maps.newHashMap(); +// otherParams.put("type", "month"); +// salaryYearMonthItem.setOtherParams(otherParams); +// weaForm.getItems().put("salaryYearMonth", salaryYearMonthItem); +// +// return weaForm; +// } + + /** + * 检查是否可以操作 + * + * @return + */ + public Boolean checkOperation(AttendQuoteCheckOperationParam checkOperationParam) { + ValidUtil.doValidator(checkOperationParam); + + String salaryYearMonthStr = checkOperationParam.getSalaryYearMonthStr(); + YearMonth yearMonth = SalaryDateUtil.String2YearMonth(salaryYearMonthStr); + checkOperationParam.setSalaryYearMonth(yearMonth); + return getAttendQuoteService(user).checkOperation(checkOperationParam.getSalaryYearMonth(), checkOperationParam.getSalarySobIds()); + } + + /** + * 获取薪资周期和考勤周期 + * + * @return + */ + public Map getSalaryCycleAndAttendCycle(QuerySalaryCycleAndAttendCycleParam param) { + Long salarySobId = param.getSalarySobId(); + YearMonth salaryYearMonth = param.getSalaryYearMonth(); + SalarySobCycleDTO salarySobCycleDTO = getSalarySobService(user).getSalarySobCycle(salarySobId, salaryYearMonth); + + LocalDateRange salaryCycleRange = salarySobCycleDTO.getSalaryCycle(); + LocalDateRange attendCycleRange = salarySobCycleDTO.getAttendCycle(); + + Map salaryCycleAndAttendCycle = new HashMap<>(2); + salaryCycleAndAttendCycle.put("salaryCycle", SalaryDateUtil.getFormatLocalDate(salaryCycleRange.getFromDate()) + " ~ " + SalaryDateUtil.getFormatLocalDate(salaryCycleRange.getEndDate())); + salaryCycleAndAttendCycle.put("attendCycle", SalaryDateUtil.getFormatLocalDate(attendCycleRange.getFromDate()) + " ~ " + SalaryDateUtil.getFormatLocalDate(attendCycleRange.getEndDate())); + + return salaryCycleAndAttendCycle; + } + + /** + * 获取薪资账套下拉列表 + * + * @return + */ + public List> selectSalarySobList() { + // 查询所有启用的薪资账套 + List salarySobs = getSalarySobService(user).listByDisable(NumberUtils.INTEGER_ZERO); + + return salarySobs.stream().map(m -> { + Map map = new HashMap<>(2); + map.put("id", String.valueOf(m.getId())); + map.put("content", m.getName()); + return map; + }).collect(Collectors.toList()); + } + + /** + * 删除考勤引用 + * + * @param ids + * @return + */ + public String delete(Collection ids) { + return getAttendQuoteService(user).delete(ids); + } +} diff --git a/src/com/engine/salary/wrapper/AuthWrapper.java b/src/com/engine/salary/wrapper/AuthWrapper.java new file mode 100644 index 000000000..a05276a71 --- /dev/null +++ b/src/com/engine/salary/wrapper/AuthWrapper.java @@ -0,0 +1,187 @@ +package com.engine.salary.wrapper; + +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.entity.auth.dto.*; +import com.engine.salary.entity.auth.param.*; +import com.engine.salary.entity.auth.po.AuthDataPO; +import com.engine.salary.entity.auth.po.AuthMemberPO; +import com.engine.salary.entity.auth.po.AuthRolePO; +import com.engine.salary.entity.auth.vo.Permission; +import com.engine.salary.enums.auth.DataLinkEnum; +import com.engine.salary.enums.auth.DataTargetTypeEnum; +import com.engine.salary.enums.auth.MemberTargetTypeEnum; +import com.engine.salary.mapper.auth.AuthMapper; +import com.engine.salary.service.auth.*; +import com.engine.salary.util.db.MapperProxyFactory; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.util.page.SalaryPageUtil; +import com.engine.salary.util.valid.ValidUtil; +import lombok.extern.slf4j.Slf4j; +import weaver.hrm.User; + +import java.util.List; +import java.util.stream.Collectors; + + +@Slf4j +public class AuthWrapper extends Service { + + public AuthService getAuthService(User user) { + return ServiceUtil.getService(AuthServiceImpl.class, user); + } + private AuthRoleService getAuthRoleService(User user) { + return ServiceUtil.getService(AuthRoleServiceImpl.class, user); + } + + private AuthMemberService getAuthMemberService(User user) { + return ServiceUtil.getService(AuthMemberServiceImpl.class, user); + } + + private AuthOptService getAuthOptService(User user) { + return ServiceUtil.getService(AuthOptServiceImpl.class, user); + } + + private AuthDataService getAuthDataService(User user) { + return ServiceUtil.getService(AuthDataServiceImpl.class, user); + } + + public PageInfo roleList(AuthRoleListQueryParam param) { + ValidUtil.doValidator(param); + return getAuthRoleService(user).roleList(param); + } + + public AuthRoleDTO getRole(Long id) { + return getAuthRoleService(user).getRole(id); + } + + public Long saveRole(AuthRoleSaveParam param) { + ValidUtil.doValidator(param); + return getAuthRoleService(user).saveRole(param); + } + + + public void deleteRole(List ids) { + getAuthRoleService(user).deleteRole(ids); + } + + public PageInfo memberList(AuthMemberQueryParam param) { + List authMemberPOS = getAuthMemberService(user).list(param.getRoleId()); + int total = authMemberPOS.size(); + authMemberPOS = SalaryPageUtil.subList(param.getCurrent(), param.getPageSize(), authMemberPOS); + List dtos = authMemberPOS.stream() + .map(po -> AuthMemberDTO.builder() + .id(po.getId()) + .targetTypeName(MemberTargetTypeEnum.parseByValue(po.getTargetType()).getDefaultLabel()) + .targetType(MemberTargetTypeEnum.parseByValue(po.getTargetType())) + .targetName(po.getTargetName()) + .target(po.getTarget()) + .build()) + .collect(Collectors.toList()); + PageInfo authMemberDTOPageInfo = SalaryPageUtil.buildPage(param.getCurrent(), param.getPageSize(), AuthMemberDTO.class); + authMemberDTOPageInfo.setList(dtos); + authMemberDTOPageInfo.setTotal(total); + return authMemberDTOPageInfo; + } + + + public PageInfo memberDetail(AuthMemberQueryParam param) { + List list = getAuthMemberService(user).listRoleEmp(param); + return SalaryPageUtil.buildPage(param.getCurrent(), param.getPageSize(), list, AuthRoleEmpDTO.class); + } + + public void saveMember(List param) { + + param.forEach(ValidUtil::modify); + + getAuthMemberService(user).save(param); + } + + public void deleteMember(List ids) { + getAuthMemberService(user).delete(ids); + } + + public void syncMember(AuthSyncParam param) { + getAuthMemberService(user).sync(param); + } + + public AuthOptDTO optTree(Long roleId) { + return getAuthOptService(user).optTree(roleId); + } + + public void saveOpt(AuthOptSaveParam opt) { + getAuthOptService(user).save(opt); + } + + public PageInfo dataList(AuthDataQueryParam param) { + List list = getAuthDataService(user).list(param.getRoleId()); + int total = list.size(); + list = SalaryPageUtil.subList(param.getCurrent(), param.getPageSize(), list); + List dtos = list.stream().map(po -> AuthDataDTO.builder() + .id(po.getId()) + .link(DataLinkEnum.parseByValue(po.getLink())) + .linkName(DataLinkEnum.parseByValue(po.getLink()).getDefaultLabel()) + .targetTypeName(DataTargetTypeEnum.parseByValue(po.getTargetType()).getDefaultLabel()) + .targetType(DataTargetTypeEnum.parseByValue(po.getTargetType())) + .targetName(po.getTargetName()) + .target(po.getTarget()) + .sortedIndex(po.getSortedIndex()) + .build()) + .collect(Collectors.toList()); + + PageInfo page = SalaryPageUtil.buildPage(param.getCurrent(), param.getPageSize(), AuthDataDTO.class); + page.setList(dtos); + page.setTotal(total); + return page; + + } + + + public PageInfo dataDetail(AuthDataQueryParam param) { + List authRoleDataDTOS = getAuthDataService(user).listRoleData(param); + return SalaryPageUtil.buildPage(param.getCurrent(), param.getPageSize(), authRoleDataDTOS, AuthRoleDataDTO.class); + } + + public void saveData(List params) { + params.forEach(ValidUtil::modify); + + getAuthDataService(user).save(params); + } + + public void deleteData(List ids) { + getAuthDataService(user).delete(ids); + } + + public void syncData(AuthSyncParam param) { + getAuthDataService(user).sync(param); + } + + private AuthMapper getAuthMapper() { + return MapperProxyFactory.getProxy(AuthMapper.class); + } + + public Object auth(String page) { + return getAuthMapper().getTaxEmpOptAuth((long) user.getUID(), page); + } + + public Permission permission(String page) { + return getAuthService(user).permission(page); + } + + public AuthTreeDTO tree(AuthTreeQueryParam param) { + return getAuthService(user).tree(param); + } + + public String sync() { + List authRolePOS = getAuthRoleService(user).listAll(); + authRolePOS.forEach(po -> { + AuthSyncParam param = AuthSyncParam.builder() + .roleId(po.getId()) + .build(); + getAuthMemberService(user).sync(param); + getAuthDataService(user).sync(param); + }); + return ""; + } + +} diff --git a/src/com/engine/salary/wrapper/ExtEmpWrapper.java b/src/com/engine/salary/wrapper/ExtEmpWrapper.java new file mode 100644 index 000000000..9a60b3e30 --- /dev/null +++ b/src/com/engine/salary/wrapper/ExtEmpWrapper.java @@ -0,0 +1,66 @@ +package com.engine.salary.wrapper; + +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.entity.extemp.dto.ExtEmpDTO; +import com.engine.salary.entity.extemp.param.ExtEmpImportParam; +import com.engine.salary.entity.extemp.param.ExtEmpQueryParam; +import com.engine.salary.entity.extemp.param.ExtEmpSaveParam; +import com.engine.salary.entity.extemp.po.ExtEmpPO; +import com.engine.salary.service.ExtEmpService; +import com.engine.salary.service.impl.ExtEmpServiceImpl; +import com.engine.salary.util.page.PageInfo; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import weaver.hrm.User; + +import java.util.Collection; +import java.util.Map; + +/** + * 累计专项 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class ExtEmpWrapper extends Service { + + private ExtEmpService getExtEmpService(User user) { + return ServiceUtil.getService(ExtEmpServiceImpl.class, user); + } + + + public PageInfo listPage(ExtEmpQueryParam param) { + return getExtEmpService(user).listPage(param); + } + + public void save(ExtEmpSaveParam param) { + getExtEmpService(user).save(param); + } + + public void update(ExtEmpSaveParam param) { + getExtEmpService(user).update(param); + } + + public void delete(Collection ids) { + getExtEmpService(user).delete(ids); + } + + public ExtEmpPO detail(Long id) { + return getExtEmpService(user).getById(id); + } + + public XSSFWorkbook exportImportTemplate() { + return getExtEmpService(user).exportImportTemplate(); + } + + public Map previewImportExtEmp(ExtEmpImportParam param) { + return getExtEmpService(user).previewImportExtEmp(param); + } + + public Map importExtEmp(ExtEmpImportParam param) { + return getExtEmpService(user).importExtEmp(param); + } + +} diff --git a/src/com/engine/salary/wrapper/MySalaryShowSetWrapper.java b/src/com/engine/salary/wrapper/MySalaryShowSetWrapper.java new file mode 100644 index 000000000..4efbd70cb --- /dev/null +++ b/src/com/engine/salary/wrapper/MySalaryShowSetWrapper.java @@ -0,0 +1,32 @@ +package com.engine.salary.wrapper; + +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.entity.salaryBill.dto.MySalaryShowSetDTO; +import com.engine.salary.service.MySalaryShowSetService; +import com.engine.salary.service.impl.MySalaryShowSetServiceImpl; +import org.springframework.stereotype.Component; +import weaver.hrm.User; + +; + +/** + * @Description: 我的薪资福利显示设置 + * @Author: wangxiangzhong + * @Date: 2023/8/7 11:24 + */ +@Component +public class MySalaryShowSetWrapper extends Service { + private MySalaryShowSetService getMySalaryShowSetService(User user) { + return ServiceUtil.getService(MySalaryShowSetServiceImpl.class, user); + } + + /** + * 获取我的薪资福利显示设置 + * + * @return + */ + public MySalaryShowSetDTO mySalaryShowSet() { + return getMySalaryShowSetService(user).get(); + } +} diff --git a/src/com/engine/salary/wrapper/OtherDeductionWrapper.java b/src/com/engine/salary/wrapper/OtherDeductionWrapper.java new file mode 100644 index 000000000..3002e8cfd --- /dev/null +++ b/src/com/engine/salary/wrapper/OtherDeductionWrapper.java @@ -0,0 +1,270 @@ +package com.engine.salary.wrapper; + +import com.api.browser.bean.SearchConditionGroup; +import com.api.browser.bean.SearchConditionItem; +import com.api.browser.util.ConditionFactory; +import com.api.browser.util.ConditionType; +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.entity.datacollection.dto.OtherDeductionListDTO; +import com.engine.salary.entity.datacollection.dto.OtherDeductionRecordDTO; +import com.engine.salary.entity.datacollection.param.*; +import com.engine.salary.entity.datacollection.po.OtherDeductionPO; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.service.OtherDeductionService; +import com.engine.salary.service.SalaryEmployeeService; +import com.engine.salary.service.TaxAgentService; +import com.engine.salary.service.impl.OtherDeductionServiceImpl; +import com.engine.salary.service.impl.SalaryEmployeeServiceImpl; +import com.engine.salary.service.impl.TaxAgentServiceImpl; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.page.PageInfo; +import lombok.extern.slf4j.Slf4j; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import weaver.hrm.User; + +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.Month; +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @Description: 其他免税扣除 + * @Author: wangxiangzhong + * @Date: 2022/3/14 16:09 + */ +@Slf4j +public class OtherDeductionWrapper extends Service { + private OtherDeductionService getOtherDeductionService(User user) { + return ServiceUtil.getService(OtherDeductionServiceImpl.class, user); + } + + private TaxAgentService getTaxAgentV2Service(User user) { + return ServiceUtil.getService(TaxAgentServiceImpl.class, user); + } + + private SalaryEmployeeService getSalaryEmployeeService(User user) { + return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user); + } + + /** + * 数据采集-其他免税扣除列表的高级搜索 + * + * @return + */ + public Map getSearchCondition() { + Map apidatas = new HashMap(); + ConditionFactory conditionFactory = new ConditionFactory(user); + + //条件组 + List addGroups = new ArrayList(); + + List conditionItems = new ArrayList(); + + //文本输入框 + SearchConditionItem username = conditionFactory.createCondition(ConditionType.INPUT, 25034, "username"); + username.setInputType("input"); + username.setColSpan(2);//定义一行显示条件数,默认值为2,当值为1时标识该条件单独占一行 + username.setFieldcol(16); //条件输入框所占宽度,默认值18 + username.setLabelcol(8); + username.setViewAttr(2); // 编辑权限 1:只读,2:可编辑, 3:必填 默认2 + username.setLabel("姓名"); //设置文本值 这个将覆盖多语言标签的值 + conditionItems.add(username); + + + SearchConditionItem departmentName = conditionFactory.createCondition(ConditionType.BROWSER, 502227, "departmentIds", "57"); + departmentName.setInputType("browser"); + departmentName.setColSpan(2); + departmentName.setFieldcol(16); + departmentName.setLabelcol(8); + departmentName.setViewAttr(2); + departmentName.setIsQuickSearch(false); + departmentName.setLabel("部门"); + conditionItems.add(departmentName); + + + SearchConditionItem jobNum = conditionFactory.createCondition(ConditionType.INPUT, 25034, "jobNum"); + jobNum.setInputType("input"); + jobNum.setColSpan(2); + jobNum.setFieldcol(16); + jobNum.setLabelcol(8); + jobNum.setViewAttr(2); + jobNum.setLabel("工号"); + conditionItems.add(jobNum); + + +// SearchConditionItem idNo = conditionFactory.createCondition(ConditionType.INPUT, 25034, "idNo"); +// idNo.setInputType("input"); +// idNo.setColSpan(2); +// idNo.setFieldcol(16); +// idNo.setLabelcol(8); +// idNo.setViewAttr(2); +// idNo.setLabel("证件号码"); +// conditionItems.add(idNo); +// +// //日期范围选项 +// List dateOptions = new ArrayList(); +// dateOptions.add(new SearchConditionOption("6", SalaryI18nUtil.getI18nLabel(32530, user.getLanguage()), true));//指定日期范围(必须为6) +// SearchConditionItem hiredate = conditionFactory.createCondition(ConditionType.RANGEPICKER, 18648, new String[]{"hiredate", "hiredate"}); +// hiredate.setInputType("rangepicker"); +// hiredate.setFormat("yyyy-MM-dd"); +// hiredate.setFieldcol(16); +// hiredate.setLabelcol(8); +// hiredate.setViewAttr(2); +// hiredate.setLabel("入职日期"); +// hiredate.setOptions(dateOptions); +// conditionItems.add(hiredate); +// +// +// SearchConditionItem mobile = conditionFactory.createCondition(ConditionType.INPUT, 25034, "mobile"); +// mobile.setInputType("input"); +// mobile.setColSpan(2); +// mobile.setFieldcol(16); +// mobile.setLabelcol(8); +// mobile.setViewAttr(2); +// mobile.setLabel("手机号"); +// conditionItems.add(mobile); + + addGroups.add(new SearchConditionGroup("常用条件", true, conditionItems)); + + apidatas.put("condition", addGroups); + return apidatas; + } + + /** + * 数据采集-其他免税扣除列表(分页) + * + * @param queryParam + * @return + */ + public PageInfo list(OtherDeductionQueryParam queryParam) { + return getOtherDeductionService(user).listPage(queryParam); + + } + + /** + * 数据采集-其他免税扣除详情列表(分页) + * + * @param queryParam + * @return + */ + public PageInfo getDetailList(OtherDeductionQueryParam queryParam) { + Long id = queryParam.getOtherTaxExemptDeductionId(); + + OtherDeductionPO po = getOtherDeductionService(user).getById(id); + if (po == null) { + throw new SalaryRunTimeException(String.format(SalaryI18nUtil.getI18nLabel(100415, "其他免税扣除不存在") + "[id:%s]", id)); + } + queryParam.setEmployeeId(po.getEmployeeId()); + + return getOtherDeductionService(user).recordListPage(queryParam); + } + + /** + * 导出-其他免税扣除列表 + * + * @param queryParam + * @return + */ + public XSSFWorkbook export(OtherDeductionQueryParam queryParam) { + return getOtherDeductionService(user).export(queryParam); + } + + /** + * 导出-其他免税扣除详情列表 + * + * @param queryParam + * @return + */ + public XSSFWorkbook exportDetail(OtherDeductionQueryParam queryParam) { + Long id = queryParam.getOtherTaxExemptDeductionId(); + OtherDeductionPO po = getOtherDeductionService(user).getById(id); + if (po == null) { + throw new SalaryRunTimeException(String.format(SalaryI18nUtil.getI18nLabel(100415, "其他免税扣除不存在") + "[id:%s]", id)); + } + return getOtherDeductionService(user).exportDetail(queryParam); + } + + /** + * 下载导入模板 + * + * @param queryParam + * @return + */ + public XSSFWorkbook downloadTemplate(OtherDeductionQueryParam queryParam) { + return getOtherDeductionService(user).downloadTemplate(queryParam); + } + + /** + * 预览 + */ + public Map preview(OtherDeductionImportParam importParam) { + return getOtherDeductionService(user).preview(importParam); + } + + /** + * 导入数据 + */ + public Map importData(OtherDeductionImportParam importParam) { + return getOtherDeductionService(user).importData(importParam); + } + + /** + * 编辑数据 + */ + public void editData(OtherDeductionParam otherDeductionParam) { + getOtherDeductionService(user).editData(otherDeductionParam); + } + + + /** + * 新增数据 + */ + public void createData(OtherDeductionParam otherDeductionParam) { + getOtherDeductionService(user).createData(otherDeductionParam); + } + + /** + * 删除所选数据 + */ + public void deleteSelectData(AddUpDeductionRecordDeleteParam deleteParam) { + getOtherDeductionService(user).deleteSelectData(deleteParam); + } + + /** + * 一键清空所有数据 + */ + public void deleteAllData(AddUpDeductionRecordDeleteParam deleteParam) { + getOtherDeductionService(user).deleteAllData(deleteParam); + } + + /** + * 获取数据 + */ + public OtherDeductionRecordDTO getOtherDeduction(OtherDeductionParam otherDeductionParam) { + return getOtherDeductionService(user).getOtherDeduction(otherDeductionParam); + } + + public String extendToLastMonth(OtherDeductionExtendLastParam param) { + LocalDateTime localDate = null; + try { + localDate = LocalDate.parse(param.getDeclareMonth() + "-01", + DateTimeFormatter.ofPattern("yyyy-MM-dd")).atStartOfDay(); + param.setYearMonthTime(localDate); + } catch (Exception e) { + log.error("", e); + } + if (null == param.getDeclareMonth() || null == localDate || null == param.getYearMonthTime()) { + throw new SalaryRunTimeException("当前年月不合法"); + } + if (Month.JANUARY.equals(localDate.getMonth())) { + throw new SalaryRunTimeException("操作失败,每年度内首月无法沿用上月"); + } + param.setYearMonthTime(localDate); + return getOtherDeductionService(user).extendToLastMonth(param); + } +} diff --git a/src/com/engine/salary/wrapper/ProcessWrapper.java b/src/com/engine/salary/wrapper/ProcessWrapper.java new file mode 100644 index 000000000..d06f510df --- /dev/null +++ b/src/com/engine/salary/wrapper/ProcessWrapper.java @@ -0,0 +1,39 @@ +package com.engine.salary.wrapper; + +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.entity.process.dto.SalaryAdjustmentDTO; +import com.engine.salary.sys.entity.po.SalarySysConfPO; +import com.engine.salary.sys.service.SalarySysConfService; +import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl; +import weaver.hrm.User; + +/** + * 流程 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class ProcessWrapper extends Service { + + private SalarySysConfService getSalarySysConfService(User user) { + return ServiceUtil.getService(SalarySysConfServiceImpl.class, user); + } + + public SalaryAdjustmentDTO salaryAdjustment() { + + SalaryAdjustmentDTO build = SalaryAdjustmentDTO.builder().isShow("false").build(); + SalarySysConfPO needSalaryAdjustmentProcess = getSalarySysConfService(user).getOneByCode("needSalaryAdjustmentProcess"); + if (needSalaryAdjustmentProcess != null) { + build.setIsShow(needSalaryAdjustmentProcess.getConfValue()); + SalarySysConfPO salaryAdjustmentProcessUrl = getSalarySysConfService(user).getOneByCode("salaryAdjustmentProcessUrl"); + if (salaryAdjustmentProcessUrl != null) { + build.setUrl(salaryAdjustmentProcessUrl.getConfValue()); + } + return build; + } + return build; + } +} diff --git a/src/com/engine/salary/wrapper/PushWrapper.java b/src/com/engine/salary/wrapper/PushWrapper.java new file mode 100644 index 000000000..0950f19e3 --- /dev/null +++ b/src/com/engine/salary/wrapper/PushWrapper.java @@ -0,0 +1,100 @@ +package com.engine.salary.wrapper; + +import cn.hutool.core.collection.CollUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.entity.push.dto.PushRecordDTO; +import com.engine.salary.entity.push.dto.PushRecordDetailDTO; +import com.engine.salary.entity.push.dto.PushSettingDTO; +import com.engine.salary.entity.push.dto.PushSettingItemDTO; +import com.engine.salary.entity.push.param.*; +import com.engine.salary.entity.push.po.PushSettingItemPO; +import com.engine.salary.entity.push.po.PushSettingPO; +import com.engine.salary.remote.mode.cmd.GetModeList; +import com.engine.salary.service.PushService; +import com.engine.salary.service.impl.PushServiceImpl; +import com.engine.salary.util.page.PageInfo; +import weaver.hrm.User; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + + +public class PushWrapper extends Service { + + private PushService getPushService(User user) { + return ServiceUtil.getService(PushServiceImpl.class, user); + } + + + public Object modeList() { + Map map = new HashMap<>(); + map.put("appid", 1); + map.put("appidForAppname", 2); + map.put("aLLorCurrentKey", 1); + Map execute = commandExecutor.execute(new GetModeList(map, user)); + + return execute; + } + + public PageInfo settingList(PushSettingQueryParam param) { + return getPushService(user).settingList(param); + } + + public PushSettingPO save(PushSettingSaveParam param) { + return getPushService(user).save(param); + } + + + public void delete(Long id) { + getPushService(user).delete(id); + } + + public PageInfo itemList(PushSettingItemQueryParam param) { + return getPushService(user).itemList(param); + } + + public PushSettingItemPO saveItem(PushSettingItemSaveParam param) { + return getPushService(user).saveItem(param); + } + + public void deleteItem(Long id) { + getPushService(user).deleteItem(id); + } + + public void createPushRecord(CreatePushParam param) { + param.getSalaryAcctRecordIds().forEach(id -> { + getPushService(user).createPushRecord(id); + }); + } + + public void push(PushParam param) { + List ids = param.getIds(); + if (CollUtil.isEmpty(ids)) { + return; + } + ids.forEach(id -> { + getPushService(user).push(id); + }); + } + + public void withdraw(WithdrawParam param) { + List ids = param.getIds(); + if (CollUtil.isEmpty(ids)) { + return; + } + ids.forEach(id -> { + getPushService(user).withdraw(id); + }); + } + + + public PageInfo recordList(RecordListQueryParam param) { + return getPushService(user).recordList(param); + } + + public PageInfo recordDetailList(RecordDetailListQueryParam param) { + return getPushService(user).recordDetailList(param); + } +} diff --git a/src/com/engine/salary/wrapper/RoleWrapper.java b/src/com/engine/salary/wrapper/RoleWrapper.java new file mode 100644 index 000000000..38f06dce0 --- /dev/null +++ b/src/com/engine/salary/wrapper/RoleWrapper.java @@ -0,0 +1,24 @@ +package com.engine.salary.wrapper; + +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.service.OtherDeductionService; +import com.engine.salary.service.impl.OtherDeductionServiceImpl; +import lombok.extern.slf4j.Slf4j; +import weaver.hrm.User; + +/** + * 角色 + *

Copyright: Copyright (c) 2024

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Slf4j +public class RoleWrapper extends Service { + private OtherDeductionService getOtherDeductionService(User user) { + return ServiceUtil.getService(OtherDeductionServiceImpl.class, user); + } + +} diff --git a/src/com/engine/salary/wrapper/SIAComparisonResultWrapper.java b/src/com/engine/salary/wrapper/SIAComparisonResultWrapper.java new file mode 100644 index 000000000..2e4fc0d37 --- /dev/null +++ b/src/com/engine/salary/wrapper/SIAComparisonResultWrapper.java @@ -0,0 +1,55 @@ +package com.engine.salary.wrapper; + +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.entity.salaryacct.dto.SalaryComparisonResultListDTO; +import com.engine.salary.entity.salaryacct.param.SalaryComparisonResultQueryParam; +import com.engine.salary.entity.siaccount.dto.InsuranceComparisonResultListDTO; +import com.engine.salary.entity.siaccount.param.InsuranceComparisonResultQueryParam; +import com.engine.salary.service.SIAComparisonResultService; +import com.engine.salary.service.SalaryComparisonResultService; +import com.engine.salary.service.impl.SIAComparisonResultServiceImpl; +import com.engine.salary.service.impl.SalaryComparisonResultServiceImpl; +import com.engine.salary.util.page.PageInfo; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import weaver.hrm.User; + +import java.util.Map; + +/** + * @Author: sy + * @Description: 福利核算线下对比结果 + * @Date: 2022/9/28 + **/ +public class SIAComparisonResultWrapper extends Service { + + + private SIAComparisonResultService getSIAComparisonResultService(User user) { + return (SIAComparisonResultService) ServiceUtil.getService(SIAComparisonResultServiceImpl.class, user); + } + /** + * 福利核算线下对比列表 + * + * @param queryParam 列表查询条件 + * @return + */ + public PageInfo> listPage(InsuranceComparisonResultQueryParam queryParam) { + // 查询薪资核算线下对比列表 + InsuranceComparisonResultListDTO salaryComparisonResultListDTO = getSIAComparisonResultService(user).listPageByParam(queryParam); + + PageInfo> pageInfo = salaryComparisonResultListDTO.getData(); + pageInfo.setColumns(salaryComparisonResultListDTO.getWeaTableColumns()); + + return pageInfo; + } + + /** + * 导出福利核算线下对比结果 + * + * @param queryParam 列表查询条件 + * @return + */ + public XSSFWorkbook exportComparisonResult(InsuranceComparisonResultQueryParam queryParam) { + return getSIAComparisonResultService(user).exportComparisonResult( queryParam); + } +} diff --git a/src/com/engine/salary/wrapper/SIAccountWrapper.java b/src/com/engine/salary/wrapper/SIAccountWrapper.java new file mode 100644 index 000000000..9b9e754b6 --- /dev/null +++ b/src/com/engine/salary/wrapper/SIAccountWrapper.java @@ -0,0 +1,168 @@ +package com.engine.salary.wrapper; + +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; + +import com.engine.salary.entity.hrm.dto.HrmInfoDTO; +import com.engine.salary.entity.hrm.param.HrmQueryParam; +import com.engine.salary.entity.siaccount.dto.InsuranceCompensationDTO; +import com.engine.salary.entity.siaccount.param.*; +import com.engine.salary.service.SIBalanceService; +import com.engine.salary.service.SICompensationService; +import com.engine.salary.service.SIRecessionService; +import com.engine.salary.service.SIRepairService; +import com.engine.salary.service.impl.SIBalanceServiceImpl; +import com.engine.salary.service.impl.SICompensationServiceImpl; +import com.engine.salary.service.impl.SIRecessionServiceImpl; +import com.engine.salary.service.impl.SIRepairServiceImpl; +import com.engine.salary.util.page.PageInfo; +import weaver.hrm.User; + +import java.util.Collection; +import java.util.List; +import java.util.Map; + +/** + * @Author weaver_cl + * @Description: TODO + * @Date 2022/4/18 + * @Version V1.0 + **/ +public class SIAccountWrapper extends Service { + private SIRecessionService getSIRecessionService(User user) { + return (SIRecessionService) ServiceUtil.getService(SIRecessionServiceImpl.class, user); + } + + private SICompensationService getSICompensationService(User user) { + return (SICompensationService) ServiceUtil.getService(SICompensationServiceImpl.class, user); + } + + private SIBalanceService getSIBalanceService(User user) { + return (SIBalanceService) ServiceUtil.getService(SIBalanceServiceImpl.class, user); + } + + private SIRepairService getSIRepairService(User user) { + return (SIRepairService) ServiceUtil.getService(SIRepairServiceImpl.class, user); + } + + /** + * 新增退差数据 + * @param param 退差请求体 + */ + public void saveRecession(RecessionParam param) { + long currentEmployeeId = user.getUID(); + getSIRecessionService(user).save(param, currentEmployeeId); + } + + /** + * 删除退差数据 + * @param ids 表数据id集合 + */ + public void delRecession(Collection ids) { + long currentEmployeeId = user.getUID(); + getSIRecessionService(user).del(ids, currentEmployeeId); + } + + /** + * 可退差人员列表 + */ + public PageInfo getEmployeeListByTaxAgent(HrmQueryParam param) { + + return getSIRecessionService(user).getEmployeeListByTaxAgent(param); + } + + /** + * 可调差人员列表 + */ + public List getEmployeeListToCompensation(HrmQueryParam hrmQueryParam) { + + return getSICompensationService(user).getEmployeeListToCompensation(hrmQueryParam); + } + + /** + * 获取社保福利项 + */ + public List> compensationCategoryType(Long id) { + + return getSICompensationService(user).compensationCategoryType(id); + } + + /** + * 获取当前调差福利类型-公司方支出总计 + */ + public List> compensationComTotal(List paramList) { + + return getSICompensationService(user).compensationComTotal(paramList); + } + + /** + * 社保调差保存 + */ + public Map compensationSave(List param) { + + return getSICompensationService(user).compensationAccount(param); + } + + /** + * 社保调差默认配置保存 + */ + public String compensationConfigSave(List param) { + + return getSICompensationService(user).compensationConfigSave(param); + } + + /** + * 社保调差撤回 + */ + public String compensationBack(InsuranceCompensationDTO param) { + + return getSICompensationService(user).compensationRevert(param); + } + + /** + * 社保调差列表 + */ + public Map compensationList(InsuranceCompensationDTO param) { + return getSICompensationService(user).compensationList(param.getBillMonth(), param.getPaymentOrganization()); + } + + /** + * 删除补差数据 + * @param param 表数据id集合、账单月、个税扣缴义务人 + */ + public void delBalance(InspectAccountParam param) { + long currentEmployeeId = user.getUID(); + getSIBalanceService(user).del(param, currentEmployeeId); + } + + /** + * 取指定月份的福利缴纳基数作为补缴基数 + * @param param + * @return + */ + public List> getSupplementPaymentForm(SupplementAccountBaseParam param) { + return getSIRepairService(user).getSupplementPaymentForm(param); + } + + /** + * 获取待编辑的补缴费用相关福利项 + * @param param + * @return + */ + public List> getPaymentGroup(SupplementAccountBaseParam param) { + return getSIRepairService(user).getPaymentGroup(param); + } + + /** + * 获取待编辑的补差费用相关福利项 + * @param param + * @return + */ + public List> getBalancePaymentGroup(BalanceAccountBaseParam param) { + return getSIBalanceService(user).getPaymentGroup(param); + } + + public void addNewBalance(BalanceAccountBaseParam param) { + getSIBalanceService(user).addNewBalance(param); + } +} diff --git a/src/com/engine/salary/wrapper/SICategoryWrapper.java b/src/com/engine/salary/wrapper/SICategoryWrapper.java new file mode 100644 index 000000000..c4c6c0a6e --- /dev/null +++ b/src/com/engine/salary/wrapper/SICategoryWrapper.java @@ -0,0 +1,112 @@ +package com.engine.salary.wrapper; + +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.service.SICategoryService; +import com.engine.salary.service.impl.SICategoryServiceImpl; +import weaver.hrm.User; + +/** + * 福利类型service和controller转换层,用于组装前端数据 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SICategoryWrapper extends Service { + + + public SICategoryService getSICategoryService(User user) { + return ServiceUtil.getService(SICategoryServiceImpl.class, user); + } + +// /** +// * 新建福利类型 转view +// *

+// * 1、表中的五险一金和企业年金为系统预置数据 +// * 2、新建需要检查同类型福利下面是否存在同样的名称,重复不给新建 +// * +// * @param param 请求报文 +// * @param employeeId 操作员id +// * @param tenantKey 租户key +// */ +// public WeaResult insert(InsuranceCategoryFormDTO param, Long employeeId, String tenantKey) { +// siCategoryService.insert(param, employeeId, tenantKey); +// return WeaResult.success(""); +// } + +// /** +// * 查询自定义福利列表 +// * +// * @param welfareType 福利类型,用于页面右上角的筛选功能,不传则查询全部 +// * @return 分页列表 +// * @see WelfareTypeEnum +// */ +// public PageInfo listPage(WelfareTypeEnum welfareType) { +// PageInfo insuranceCategoryListDTOPage = getSICategoryService(user).listPage(welfareType); +// WeaTable insuranceCategoryListDTOWeaTable = FormatManager.getInstance() +// .genTable(InsuranceCategoryListDTO.class, insuranceCategoryListDTOPage); +// return WeaResult.success(insuranceCategoryListDTOWeaTable); +// } + +// /** +// * 自定义福利表单 +// * id == null ? 新建表单 : 查看已有数据内容表单 +// * +// * @param id 自定义福利主键 +// * @param employeeId 操作员id +// * @param tenantKey 租户key +// * @return 表单 +// */ +// public WeaResult getForm(Long id, Long employeeId, String tenantKey) { +// InsuranceCategoryFormDTO insuranceCategoryFormDTO = siCategoryService.getForm(id, employeeId, tenantKey); +// WeaForm weaForm = SalaryFormatUtil.getInstance().buildForm(InsuranceCategoryFormDTO.class, insuranceCategoryFormDTO); +// return WeaResult.success(weaForm); +// } + +// /** +// * 更新自定义福利 +// *

+// * 1、判断该条自定义福利是否存在 +// * 2、判断福利名称是否跟该类型的福利名称有重复 +// * 3、判断福利名称是否和系统名称重复 +// * +// * @param insuranceCategoryFormDTO 更新报文体 +// * @param employeeId 操作员信息 +// * @param tenantKey 租户key +// */ +// public WeaResult update(InsuranceCategoryFormDTO insuranceCategoryFormDTO, Long employeeId, String tenantKey) { +// siCategoryService.update(insuranceCategoryFormDTO, employeeId, tenantKey); +// return WeaResult.success(""); +// } +// +// /** +// * 该接口暂时没用,删除福利类型对档案和台账核算都有很大的影响,暂时还没考虑好怎么做 +// *

+// * 删除福利类型 +// * +// * @param id 要删除的福利类型主键id +// * @param employeeId 操作员id +// * @param tenantKey 租户key +// */ +// public WeaResult deleteSoftById(Long id, Long employeeId, String tenantKey) { +// siCategoryService.deleteSoftById(id, employeeId, tenantKey); +// return WeaResult.success(""); +// } +// +// /** +// * 更新福利类型状态 +// * +// * @param id 要更新的福利类型的主键id +// * @param isUse 启用停用状态 +// * @param employeeId 操作员id +// * @param tenantKey 租户key +// * @see com.weaver.hrm.salary.enums.sicategory.IsUseEnum +// */ +// public WeaResult updateStatusById(Long id, Integer isUse, Long employeeId, String tenantKey) { +// siCategoryService.updateStatusById(id, isUse, employeeId, tenantKey); +// return WeaResult.success(""); +// } + +} diff --git a/src/com/engine/salary/wrapper/SIExportWrapper.java b/src/com/engine/salary/wrapper/SIExportWrapper.java new file mode 100644 index 000000000..f37eb9bf9 --- /dev/null +++ b/src/com/engine/salary/wrapper/SIExportWrapper.java @@ -0,0 +1,44 @@ +package com.engine.salary.wrapper; + +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.entity.siarchives.param.InsuranceArchivesListParam; +import com.engine.salary.entity.siexport.param.InsuranceExportParam; +import com.engine.salary.service.SIArchivesService; +import com.engine.salary.service.SIExportService; +import com.engine.salary.service.impl.SIArchivesServiceImpl; +import com.engine.salary.service.impl.SIExportServiceImpl; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import weaver.hrm.User; + +/** + * @Author weaver_cl + * @Description: TODO + * @Date 2022/4/18 + * @Version V1.0 + **/ +public class SIExportWrapper extends Service { + + public SIExportService getSIExportService(User user) { + return ServiceUtil.getService(SIExportServiceImpl.class, user); + } + + public SIArchivesService getSIArchivesService(User user) { + return ServiceUtil.getService(SIArchivesServiceImpl.class, user); + } + + + public XSSFWorkbook exportOverView(InsuranceExportParam param) { + return getSIExportService(user).exportOverView(param); + } + + public XSSFWorkbook exportAccount(Integer paymentStatus, InsuranceExportParam param) { + return getSIExportService(user).exportAccount(paymentStatus,param); + } + + public XSSFWorkbook export(InsuranceArchivesListParam param) { + return getSIArchivesService(user).export(param); + } + + +} diff --git a/src/com/engine/salary/wrapper/SIImportWrapper.java b/src/com/engine/salary/wrapper/SIImportWrapper.java new file mode 100644 index 000000000..0543dddc0 --- /dev/null +++ b/src/com/engine/salary/wrapper/SIImportWrapper.java @@ -0,0 +1,28 @@ +package com.engine.salary.wrapper; + +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.entity.siarchives.param.InsuranceArchivesListParam; +import com.engine.salary.service.SIImportService; +import com.engine.salary.service.impl.SIImportServiceImpl; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import weaver.hrm.User; + + +/** + * @Author weaver_cl + * @Description: + * @Date 2022/4/20 + * @Version V1.0 + **/ +public class SIImportWrapper extends Service { + + public SIImportService getSIImportService(User user) { + return ServiceUtil.getService(SIImportServiceImpl.class,user); + } + + + public XSSFWorkbook exportTemplate(InsuranceArchivesListParam param) { + return getSIImportService(user).exportTemplate(param); + } +} diff --git a/src/com/engine/salary/wrapper/SIReportWrapper.java b/src/com/engine/salary/wrapper/SIReportWrapper.java new file mode 100644 index 000000000..9987e9995 --- /dev/null +++ b/src/com/engine/salary/wrapper/SIReportWrapper.java @@ -0,0 +1,69 @@ +package com.engine.salary.wrapper; + +import com.cloudstore.eccom.pc.table.WeaTable; +import com.cloudstore.eccom.pc.table.WeaTableColumn; +import com.cloudstore.eccom.result.WeaResultMsg; +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.entity.siaccount.param.QueryAccountDetailParam; +import com.engine.salary.entity.siaccount.po.InsuranceAccountDetailPO; +import com.engine.salary.service.ColumnBuildService; +import com.engine.salary.service.RecordsBuildService; +import com.engine.salary.service.SIReportService; +import com.engine.salary.service.impl.ColumnBuildServiceImpl; +import com.engine.salary.service.impl.RecordsBuildServiceImpl; +import com.engine.salary.service.impl.SIReportServiceImpl; +import com.engine.salary.util.page.PageInfo; +import weaver.hrm.User; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + + +public class SIReportWrapper extends Service { + + private SIReportService getSIReportService(User user) { + return (SIReportService) ServiceUtil.getService(SIReportServiceImpl.class, user); + } + + private RecordsBuildService getRecordsBuildService(User user) { + return (RecordsBuildService) ServiceUtil.getService(RecordsBuildServiceImpl.class, user); + } + + + private ColumnBuildService getColumnBuildService(User user) { + return (ColumnBuildService) ServiceUtil.getService(ColumnBuildServiceImpl.class, user); + } + + + public Map welfareList(QueryAccountDetailParam param) { + PageInfo page = getSIReportService(user).welfareList(param); + List list = page.getList(); + List> records = getRecordsBuildService(user).buildCommonRecordsWithStyle(list, param.getEmployeeId()); + + + PageInfo> pageInfo = new PageInfo<>(records); + pageInfo.setTotal(page.getTotal()); + pageInfo.setPageNum(page.getPageNum()); + pageInfo.setPageSize(page.getPageSize()); + + + List columns = getColumnBuildService(user).buildCommonColumns(list); + + WeaTable table = new WeaTable(); + table.setColumns(columns); + + + WeaResultMsg result = new WeaResultMsg(false); + result.putAll(table.makeDataResult()); + result.success(); + + Map datas = new HashMap<>(); + datas.put("pageInfo", pageInfo); + datas.put("dataKey",result.getResultMap()); + + + return datas; + } +} diff --git a/src/com/engine/salary/wrapper/SISchemeWrapper.java b/src/com/engine/salary/wrapper/SISchemeWrapper.java new file mode 100644 index 000000000..ecd60fea2 --- /dev/null +++ b/src/com/engine/salary/wrapper/SISchemeWrapper.java @@ -0,0 +1,28 @@ +package com.engine.salary.wrapper; + +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.entity.sischeme.dto.InsuranceSchemeListDTO; +import com.engine.salary.entity.sischeme.param.InsuranceSchemeParam; +import com.engine.salary.service.SISchemeService; +import com.engine.salary.service.impl.SISchemeServiceImpl; +import com.engine.salary.util.page.PageInfo; +import weaver.hrm.User; + +/** + * @Author weaver_cl + * @Description: + * @Date 2022/4/22 + * @Version V1.0 + **/ +public class SISchemeWrapper extends Service { + + private SISchemeService getSISchemeService(User user) { + return ServiceUtil.getService(SISchemeServiceImpl.class,user); + } + + + public PageInfo listPage(InsuranceSchemeParam param) { + return getSISchemeService(user).list(param); + } +} diff --git a/src/com/engine/salary/wrapper/SalaryAcctEmployeeWrapper.java b/src/com/engine/salary/wrapper/SalaryAcctEmployeeWrapper.java new file mode 100644 index 000000000..c0d207d45 --- /dev/null +++ b/src/com/engine/salary/wrapper/SalaryAcctEmployeeWrapper.java @@ -0,0 +1,198 @@ +package com.engine.salary.wrapper; + +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.salaryacct.bo.SalaryAcctEmployeeBO; +import com.engine.salary.entity.salaryacct.dto.SalaryAccEmployeeListDTO; +import com.engine.salary.entity.salaryacct.param.*; +import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.service.SalaryAcctEmployeeService; +import com.engine.salary.service.SalaryEmployeeService; +import com.engine.salary.service.TaxAgentService; +import com.engine.salary.service.impl.SalaryAcctEmployeeServiceImpl; +import com.engine.salary.service.impl.SalaryEmployeeServiceImpl; +import com.engine.salary.service.impl.TaxAgentServiceImpl; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.page.PageInfo; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.math.NumberUtils; +import weaver.hrm.User; + +import java.util.List; +import java.util.stream.Collectors; + +/** + * 薪资核算人员 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SalaryAcctEmployeeWrapper extends Service { + + private SalaryAcctEmployeeService getSalaryAcctEmployeeService(User user) { + return ServiceUtil.getService(SalaryAcctEmployeeServiceImpl.class, user); + } + private SalaryEmployeeService getSalaryEmployeeService(User user) { + return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user); + } + + + private TaxAgentService getTaxAgentService(User user) { + return ServiceUtil.getService(TaxAgentServiceImpl.class, user); + } + + /** + * 薪资核算人员列表 + * + * @param queryParam 列表查询参数 + * @return + */ + public PageInfo listPage(SalaryAcctEmployeeQueryParam queryParam) { + // 查询薪资核算人员(人员) + PageInfo page = getSalaryAcctEmployeeService(user).listPageByParam(queryParam); + // 转换成列表dto + PageInfo dtoPage = convert2ListDTO(page); + + return dtoPage; + } + + /** + * 同比减少的薪资核算人员列表 + * + * @param queryParam 列表查询参数 + * @return + */ + public PageInfo listPage4Reduce(SalaryAcctEmployeeQueryParam queryParam) { + // 查询同比减少的薪资核算人员(分页) + PageInfo page = getSalaryAcctEmployeeService(user).listPageByParam4Reduce(queryParam); + // 转换成列表dto + PageInfo dtoPage = convert2ListDTO(page); + + return dtoPage; + } + + /** + * 同比增加的薪资核算人员列表 + * + * @param queryParam 列表查询参数 + * @return + */ + public PageInfo listPage4Add(SalaryAcctEmployeeQueryParam queryParam) { + // 查询同比减少的薪资核算人员(分页) + PageInfo page = getSalaryAcctEmployeeService(user).listPageByParam4Add(queryParam); + // 转换成列表dto + PageInfo dtoPage = convert2ListDTO(page); + + return dtoPage; + } + + /** + * 转换成列表dto + * + * @param page 薪资核算人员po + * @return + */ + private PageInfo convert2ListDTO(PageInfo page) { + List list = page.getList(); + if (CollectionUtils.isEmpty(list)) { + return new PageInfo<>(SalaryAccEmployeeListDTO.class); + } + // 查询人员信息 + List employeeIds = list.stream().map(SalaryAcctEmployeePO::getEmployeeId).collect(Collectors.toList()); + List simpleEmployees = getSalaryEmployeeService(user).getEmployeeByIdsAll(employeeIds); + // 查询个税扣缴义务人 + List taxAgentIds = list.stream().map(SalaryAcctEmployeePO::getTaxAgentId).collect(Collectors.toList()); + List taxAgentPOS = getTaxAgentService(user).listByIds(taxAgentIds); + // 转换成列表dto + List salaryAccEmployeeListDTOS = SalaryAcctEmployeeBO.convert2EmployeeListDTO(list, taxAgentPOS, simpleEmployees); + PageInfo pageInfo = new PageInfo(salaryAccEmployeeListDTOS, SalaryAccEmployeeListDTO.class); + pageInfo.setTotal(page.getTotal()); + pageInfo.setPageSize(page.getPageSize()); + pageInfo.setPageNum(page.getPageNum()); + return pageInfo; + } + +// /** +// * 获取高级搜索表单 +// * +// * @return +// */ +// public WeaSearchCondition getCondition(String tenantKey) { +// SalaryAcctEmpSearchConditionDTO searchConditionDTO = new SalaryAcctEmpSearchConditionDTO(); +// WeaSearchCondition searchCondition = SalaryFormatUtil.getInstance().buildCondition(SalaryAcctEmpSearchConditionDTO.class, +// searchConditionDTO, "SalaryAcctEmpCondition"); +// // 查询个税扣缴义务人 +// List taxAgentPOS = getTaxAgentService(user).listAll(tenantKey); +// List weaSearchConditionOptions = taxAgentPOS.stream() +// .map(taxAgentPO -> new WeaSearchConditionOption(String.valueOf(taxAgentPO.getId()), taxAgentPO.getName())) +// .collect(Collectors.toList()); +// // 给查询条件中的个税扣缴义务人填充下拉项 +// searchCondition.getItems().forEach((k, v) -> { +// if (StringUtils.equals("taxAgentId", k)) { +// v.setOptions(weaSearchConditionOptions); +// } +// }); +// // 其他条件不要 +// searchCondition.getGroups().remove(1); +// return searchCondition; +// } + + /** + * 添加薪资核算人员 + * + * @param saveParam 保存参数 + */ + public void save(SalaryAcctEmployeeSaveParam saveParam) { + getSalaryAcctEmployeeService(user).save(saveParam); + } + + /** + * 从环比上月减少添加薪资核算人员 + * + * @param addParam + */ + public void addFromReduce(SalaryAcctEmployeeAddParam addParam) { + getSalaryAcctEmployeeService(user).addFromReduce(addParam); + } + + /** + * 删除薪资核算人员 + * + * @param deleteParam 删除参数 + */ + public void delete(SalaryAcctEmployeeDeleteParam deleteParam) { + getSalaryAcctEmployeeService(user).deleteByParam(deleteParam); + } + + /** + * 检查个税扣缴义务人 + * + * @param salaryAcctRecordId 薪资核算记录的id + */ + public void checkTaxAgent(Long salaryAcctRecordId) { + List salaryAcctEmployeePOS = getSalaryAcctEmployeeService(user) + .listBySalaryAcctRecordIdAndTaxAgentId(salaryAcctRecordId, NumberUtils.LONG_ZERO); + if (CollectionUtils.isNotEmpty(salaryAcctEmployeePOS)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98871, "有{0}个人无个税扣缴义务人,请先去薪资档案里维护员工档案,再点击当前页面的刷新按钮") + .replace("{0}", "" + salaryAcctEmployeePOS.size())); + } + } + + /** + * 刷新核算人员 + * + * @param salaryAcctRecordId 薪资核算记录的id + */ + public void refresh(Long salaryAcctRecordId) { + getSalaryAcctEmployeeService(user).refresh(salaryAcctRecordId); + } + + public void lockEmp(SalaryAcctResultUpdateLockStatusParam salaryAcctResultUpdateLockStatusParam) { + getSalaryAcctEmployeeService(user).lockEmp(salaryAcctResultUpdateLockStatusParam); + } +} diff --git a/src/com/engine/salary/wrapper/SalaryAcctExcelWrapper.java b/src/com/engine/salary/wrapper/SalaryAcctExcelWrapper.java new file mode 100644 index 000000000..6c2db9bd7 --- /dev/null +++ b/src/com/engine/salary/wrapper/SalaryAcctExcelWrapper.java @@ -0,0 +1,152 @@ +package com.engine.salary.wrapper; + +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.entity.salaryacct.param.*; +import com.engine.salary.service.SalaryAcctExcelService; +import com.engine.salary.service.impl.SalaryAcctExcelServiceImpl; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import weaver.hrm.User; + +/** + * 薪资核算导出导出 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SalaryAcctExcelWrapper extends Service { + + private SalaryAcctExcelService getSalaryAcctExcelService(User user) { + return (SalaryAcctExcelService) ServiceUtil.getService(SalaryAcctExcelServiceImpl.class, user); + } + /** + * 薪资核算人员导出 + * + * @param queryParam + */ + public XSSFWorkbook exportSalaryAcctEmployee(SalaryAcctEmployeeQueryParam queryParam) { + return getSalaryAcctExcelService(user).exportSalaryAcctEmployee(queryParam); + } + + /** + * 薪资核算环比减少人员导出 + * + * @param queryParam + * @return + */ + public XSSFWorkbook exportReducedEmployee(SalaryAcctEmployeeQueryParam queryParam) { + return getSalaryAcctExcelService(user).exportReducedEmployee(queryParam); + } + + + + /** + * 薪资核算环比增加人员导出 + * + * @param queryParam + * @return + */ + public XSSFWorkbook exportAddedEmployee(SalaryAcctEmployeeQueryParam queryParam) { + return getSalaryAcctExcelService(user).exportAddedEmployee(queryParam); + } + + /** + * 薪资核算结果导出 + * + * @param queryParam + * @return + */ + public XSSFWorkbook exportSalaryAcctResult(SalaryAcctResultQueryParam queryParam) { + return getSalaryAcctExcelService(user).exportSalaryAcctResult(queryParam); + } + + /** + * 下载薪资核算导入模板 + * + * @param param + * @return + */ + public XSSFWorkbook exportImportTemplate(SalaryAcctImportTemplateParam param) { + return getSalaryAcctExcelService(user).exportImportTemplate( param); + } + + /** + * 薪资核算线下对比结果导出 + * + * @param queryParam + * @return + */ + public XSSFWorkbook exportComparisonResult(SalaryComparisonResultQueryParam queryParam) { + return getSalaryAcctExcelService(user).exportComparisonResult( queryParam); + } + + /** + * 薪资核算线下对比结果导入模板导出 + * + * @param exportParam + * @return + */ + public XSSFWorkbook exportComparisonResultTemplate(SalaryComparisonResultExportParam exportParam) { + return getSalaryAcctExcelService(user).exportComparisonResultTemplate(exportParam); + } + +// /** +// * 薪资核算结果校验异常导出 +// * +// * @param exportParam +// * @param simpleEmployee +// * @param tenantKey +// * @param eteamsId +// * @return +// */ +// public Map exportCheckResult(SalaryCheckResultExportParam exportParam, +// DataCollectionEmployee simpleEmployee, String tenantKey, String eteamsId) { +// ExcelExportParam excelExportParam = new ExcelExportParam() +// .setModule(EntityType.hrsa.name()) +// .setFunction("salaryCheckResultHandler"); +// LocalRunnable localRunnable = new LocalRunnable() { +// @Override +// public void execute() { +// try { +// DSTenantKeyThreadVar.tenantKey.set(tenantKey); +// getSalaryAcctExcelService(user).exportCheckResult(excelExportParam, exportParam, simpleEmployee, tenantKey, eteamsId); +// } finally { +// DSTenantKeyThreadVar.tenantKey.remove(); +// } +// } +// }; +// ThreadPoolUtil.fixedPoolExecute(ModulePoolEnum.OTHER, "exportCheckResult", localRunnable); +// return JsonUtil.parseMap(excelExportParam, Object.class); +// } +// +// /** +// * 薪资核算结果校验异常明细导出 +// * +// * @param checkResultId +// * @param simpleEmployee +// * @param tenantKey +// * @param eteamsId +// * @return +// */ +// public Map exportCheckResultDetail(Long checkResultId, +// DataCollectionEmployee simpleEmployee, String tenantKey, String eteamsId) { +// ExcelExportParam excelExportParam = new ExcelExportParam() +// .setModule(EntityType.hrsa.name()) +// .setFunction("salaryCheckResultDetailHandler"); +// LocalRunnable localRunnable = new LocalRunnable() { +// @Override +// public void execute() { +// try { +// DSTenantKeyThreadVar.tenantKey.set(tenantKey); +// getSalaryAcctExcelService(user).exportCheckResultDetail(excelExportParam, checkResultId, simpleEmployee, tenantKey, eteamsId); +// } finally { +// DSTenantKeyThreadVar.tenantKey.remove(); +// } +// } +// }; +// ThreadPoolUtil.fixedPoolExecute(ModulePoolEnum.OTHER, "exportCheckResultDetail", localRunnable); +// return JsonUtil.parseMap(excelExportParam, Object.class); +// } +} diff --git a/src/com/engine/salary/wrapper/SalaryAcctRecordWrapper.java b/src/com/engine/salary/wrapper/SalaryAcctRecordWrapper.java new file mode 100644 index 000000000..a9f9e0556 --- /dev/null +++ b/src/com/engine/salary/wrapper/SalaryAcctRecordWrapper.java @@ -0,0 +1,383 @@ +package com.engine.salary.wrapper; + +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.cache.SalaryCacheKey; +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.salaryBill.dto.SalarySendCheckDTO; +import com.engine.salary.entity.salaryacct.bo.SalaryAcctConfig; +import com.engine.salary.entity.salaryacct.bo.SalaryAcctRecordBO; +import com.engine.salary.entity.salaryacct.dto.SalaryAcctEmployeeCountDTO; +import com.engine.salary.entity.salaryacct.dto.SalaryAcctRecordFormDTO; +import com.engine.salary.entity.salaryacct.dto.SalaryAcctRecordListDTO; +import com.engine.salary.entity.salaryacct.param.SalaryAcctRecordQueryParam; +import com.engine.salary.entity.salaryacct.param.SalaryAcctRecordSaveParam; +import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO; +import com.engine.salary.entity.salaryacct.po.SalaryAcctSobConfigPO; +import com.engine.salary.entity.salarysob.dto.SalarySobCycleDTO; +import com.engine.salary.entity.salarysob.po.SalaryApprovalRulePO; +import com.engine.salary.entity.salarysob.po.*; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import com.engine.salary.enums.salaryaccounting.SalaryAcctRecordStatusEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.service.*; +import com.engine.salary.service.impl.*; +import com.engine.salary.sys.constant.SalarySysConstant; +import com.engine.salary.sys.entity.po.SalarySysConfPO; +import com.engine.salary.sys.service.SalarySysConfService; +import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl; +import com.engine.salary.util.SalaryDateUtil; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.SalarySobUtil; +import com.engine.salary.util.page.Column; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.util.valid.ValidUtil; +import com.engine.salary.wrapper.proxy.SalaryAcctRecordWrapperProxy; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.math.NumberUtils; +import weaver.hrm.User; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * 薪资核算记录 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SalaryAcctRecordWrapper extends Service implements SalaryAcctRecordWrapperProxy { + + private SalaryAcctRecordService getSalaryAcctRecordService(User user) { + return ServiceUtil.getService(SalaryAcctRecordServiceImpl.class, user); + } + + private SalarySobService getSalarySobService(User user) { + return ServiceUtil.getService(SalarySobServiceImpl.class, user); + } + + private SalaryAcctEmployeeService getSalaryAcctEmployeeService(User user) { + return ServiceUtil.getService(SalaryAcctEmployeeServiceImpl.class, user); + } + + private SalarySendService getSalarySendService(User user) { + return ServiceUtil.getService(SalarySendServiceImpl.class, user); + } + + private SalaryEmployeeService getSalaryEmployeeService(User user) { + return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user); + } + + private SalaryItemService getSalaryItemService(User user) { + return ServiceUtil.getService(SalaryItemServiceImpl.class, user); + } + + private TaxAgentService getTaxAgentService(User user) { + return ServiceUtil.getService(TaxAgentServiceImpl.class, user); + } + + private SalaryAcctSobConfigService getSalaryAcctSobConfigService(User user) { + return ServiceUtil.getService(SalaryAcctSobConfigServiceImpl.class, user); + } + + private SalaryCacheService getSalaryCacheService(User user) { + return ServiceUtil.getService(SalaryCacheServiceImpl.class, user); + } + + + private SalaryApprovalRuleService getSalaryApprovalRuleService(User user) { + return ServiceUtil.getService(SalaryApprovalRuleServiceImpl.class, user); + } + + private SalarySysConfService getSalarySysConfService(User user) { + return ServiceUtil.getService(SalarySysConfServiceImpl.class, user); + } + +// private ComInfoCache comInfoCache; + + public PageInfo listPage(SalaryAcctRecordQueryParam queryParam) { + + // 处理历史数据将薪资账套中将关联人员状态转换为List + SalarySobUtil.handleEmployeeStatusHistory(); + getSalarySobService(user).handleHistory(); + + // 处理工资单发放历史数据 + getSalarySendService(user).handleHistory(); + // 查询薪资核算记录(分页) + PageInfo page = getSalaryAcctRecordService(user).listPageByParam(queryParam); + PageInfo dtoPage = new PageInfo(SalaryAcctRecordListDTO.class); + dtoPage.setPageNum(queryParam.getCurrent()); + dtoPage.setPageSize(queryParam.getPageSize()); + dtoPage.setTotal(page.getTotal()); + List list = page.getList(); + if (CollectionUtils.isNotEmpty(list)) { + // 查询薪资账套 + Set salarySobIds = SalaryEntityUtil.properties(list, SalaryAcctRecordPO::getSalarySobId); + List salarySobPOS = getSalarySobService(user).listByIds(salarySobIds); + // 规则设置中是否开启薪资审批按钮,默认关闭 + SalarySysConfPO salaryApprovalStatusConf = getSalarySysConfService(user).getOneByCode(SalarySysConstant.SALARY_APPROVAL_STATUS); + List needApprovalSalarySobIds = new ArrayList<>(); + // 默认可以重新核算、可以手动归档 + boolean approvalCanReCalc = true; + boolean approvalCanFile = true; + if (salaryApprovalStatusConf != null && salaryApprovalStatusConf.getConfValue().equals("1")) { + // 开启了薪资审批,获取这开启审批的账套id + List salaryApprovalRules = getSalaryApprovalRuleService(user).listBySalarySobIds(salarySobIds); + needApprovalSalarySobIds = salaryApprovalRules.stream().filter(po -> po.getOpenApproval().equals(1)).map(SalaryApprovalRulePO::getSalarySobId).collect(Collectors.toList()); + + // 获取 开启审批的核算记录允许重新核算设置,默认开启 + SalarySysConfPO approvalCanReCalcFileStatusPO = getSalarySysConfService(user).getOneByCode(SalarySysConstant.APPROVAL_CAN_RE_CALC_STATUS); + approvalCanReCalc = approvalCanReCalcFileStatusPO == null ? true : approvalCanReCalcFileStatusPO.getConfValue().equals("1"); + // 获取 开启审批的核算记录允许手动归档,默认开启 + SalarySysConfPO approvalCanManualFileStatusPO = getSalarySysConfService(user).getOneByCode(SalarySysConstant.APPROVAL_CAN_MANUAL_FILE_STATUS); + approvalCanFile = approvalCanManualFileStatusPO == null ? true : approvalCanManualFileStatusPO.getConfValue().equals("1"); + } + // 查询薪资核算记录的创建人员的人员信息 + List employeeIds = SalaryEntityUtil.properties(list, SalaryAcctRecordPO::getCreator, Collectors.toList()); + List employeeComInfos = getSalaryEmployeeService(user).getEmployeeByIdsAll(employeeIds); + // 查询薪资核算人数的数量 + Set salaryAcctRecordIds = SalaryEntityUtil.properties(list, SalaryAcctRecordPO::getId); + List salaryAcctEmployeeCountDTOS = getSalaryAcctEmployeeService(user).countBySalaryAcctRecordId(salaryAcctRecordIds); + // 查询工资单的查询情况 + List salarySendCheckResult = getSalarySendService(user).getSalarySendCheckResult(salaryAcctRecordIds); + + List taxAgentPOS = getTaxAgentService(user).listAll(); + + // 转换成列表dto + List salaryAcctRecordListDTOS = SalaryAcctRecordBO.convert2ListDTO(list, salarySobPOS, employeeComInfos, salaryAcctEmployeeCountDTOS, salarySendCheckResult, taxAgentPOS, needApprovalSalarySobIds, approvalCanFile, approvalCanReCalc); + dtoPage.setList(salaryAcctRecordListDTOS); + // 规则设置中是否开启审批功能,默认关闭 + if (CollectionUtils.isEmpty(needApprovalSalarySobIds)) { + // 没有开启审批的 + List columnList = dtoPage.getColumns().stream().filter(col -> !col.getKey().equals("approvalStatus")).collect(Collectors.toList()); + dtoPage.clearAndSetColumns(columnList); + } + } + return dtoPage; + } + + /** + * @description 处理历史数据给薪资项目都增加个默认排序 + * @return null + * @author Harryxzy + * @date 2023/5/29 14:37 + */ +// private void generateSalaryItemSortedIndex() { +// // 查询所有薪资项目 +// List salaryItemList = getSalaryItemService(user).listByParamOrderById(SalaryItemSearchParam.builder().build()); +// Optional needGenerate = salaryItemList.stream().filter(item -> item.getSortedIndex() == null).findFirst(); +// if(needGenerate.isPresent()){ +// Map> salaryItemMap = SalaryEntityUtil.group2Map(salaryItemList, SalaryItemPO::getUseInEmployeeSalary); +// for(Map.Entry> entry : salaryItemMap.entrySet()){ +// List values = entry.getValue(); +// if(CollectionUtils.isNotEmpty(values)){ +// // 将系统薪资项目放到最后 +// values = values.stream() +// .sorted(Comparator.comparing(SalaryItemPO::getSystemType)) +// .collect(Collectors.toList()); +// // 添加默认sortedIndex +// AtomicInteger index = new AtomicInteger(values.size()); +// values.stream().forEach(value -> value.setSortedIndex(index.getAndDecrement())); +// // 保存排序 +// getSalaryItemService(user).batchUpdateSortedIndex(values); +// } +// } +// } +// } + + /** + * 薪资核算记录详情 + * + * @param id 薪资核算记录id + * @return + */ + public Map getForm(Long id) { + SalaryAcctRecordFormDTO formDTO = new SalaryAcctRecordFormDTO(); + // 查询所有启用的薪资账套 + List salarySobPOS = getSalarySobService(user).listByDisable(NumberUtils.INTEGER_ZERO); + // 薪资核算详情表单中"薪资账套"的下拉选择项 + List> salarySobs = salarySobPOS.stream() + .map(salarySobPO -> { + Map map = new HashMap<>(); + map.put("id", salarySobPO.getId()); + map.put("name", salarySobPO.getName()); + return map; + }) + .collect(Collectors.toList()); + + if (Objects.nonNull(id)) { + // 查询薪资核算 + SalaryAcctRecordPO salaryAcctRecordPO = getSalaryAcctRecordService(user).getById(id); + if (Objects.isNull(salaryAcctRecordPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98747, "薪资核算记录不存在或已被删除")); + } + // 查询薪资账套 + SalarySobPO salarySobPO = getSalarySobService(user).getById(salaryAcctRecordPO.getSalarySobId()); + if (Objects.isNull(salarySobPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98769, "薪资账套不存在或已被删除")); + } + // 转换成薪资核算记录详情dto + formDTO.setId(salaryAcctRecordPO.getId()) + .setSalarySobId(salarySobPO.getId()) + .setSalarySobName(salarySobPO.getName()) + .setSalaryMonth(SalaryDateUtil.localDate2YearMonth(salaryAcctRecordPO.getSalaryMonth()).toString()) + .setDescription(salaryAcctRecordPO.getDescription()); + } + // 转换成前端所需的数据格式 + Map result = new HashMap<>(); + result.put("formDTO", formDTO); + result.put("salarySobs", salarySobs); + return result; + } + + /** + * 薪资核算记录所用的薪资账套薪资周期、考勤周期…… + * + * @param id 薪资核算记录的id + * @return + */ + public SalarySobCycleDTO getSalarySobCycleById(Long id) { + return getSalaryAcctRecordService(user).getSalarySobCycleById(id); + } + + /** + * 保存 + * + * @param saveParam 保存参数 + * @return + */ + public Long save(SalaryAcctRecordSaveParam saveParam) { + return getSalaryAcctRecordService(user).save(saveParam); + } + + /** + * 删除 + * + * @param ids 薪资核算记录的id + */ + public void delete(Collection ids) { + getSalaryAcctRecordService(user).deleteByIds(ids); + } + + /** + * 归档 + * + * @param id 薪资核算记录的id + */ + public void file(Long id) { + getSalaryAcctRecordService(user).file(id); + } + + /** + * 重新核算 + * + * @param id 薪资核算记录的id + */ + public void reCalculate(Long id) { + getSalaryAcctRecordService(user).reCalculate(id); + } + + + /** + * 判断是否存在合并计税 + * + * @param id 主键id + * @return + */ + public Integer hasConsolidatedTax(Long id) { + return getSalaryAcctRecordService(user).hasConsolidatedTax(id); + } + + /** + * @return void + * @description 回算 + * @author Harryxzy + * @date 2022/11/24 15:52 + */ + public void backCalculate(Long salaryAcctRecordId) { + getSalaryAcctRecordService(user).backCalculate(salaryAcctRecordId); + } + + + /** + * 薪资核算的账套配置是否已经发生变更 + * + * @param id + * @return true--发生了变更、false--没有发生变更 + */ + public boolean compareSobConfig(Long id) { + SalaryAcctRecordPO salaryAcctRecord = getSalaryAcctRecordService(user).getById(id); + if (salaryAcctRecord == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(156474, "参数错误,薪资核算记录不存在或已被删除")); + } + // 查询薪资核算记录已有的账套配置 + SalaryAcctSobConfigPO salaryAcctSobConfig = getSalaryAcctSobConfigService(user).getBySalaryAcctRecordId(false, id); + // 查询最新的账套配置 + SalaryAcctSobConfigPO newSalaryAcctSobConfig = getSalaryAcctSobConfigService(user).initBySalaryAcctRecord(salaryAcctRecord); + if (Objects.isNull(salaryAcctSobConfig)) { + // 为避免并发造成的事物问题,需要做一下并发处理 + String cacheIndex = id.toString(); + String acctSobConfigFlag = getSalaryCacheService(user).get(SalaryCacheKey.ACCT_SOB_CONFIG + cacheIndex); + if (acctSobConfigFlag != null && StringUtils.equals(acctSobConfigFlag, "TRUE")) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(160540, "其他人员正在操作此条薪资核算记录,请稍后再试")); + } + getSalaryCacheService(user).set(SalaryCacheKey.ACCT_SOB_CONFIG + cacheIndex, "TRUE"); + getSalaryAcctSobConfigService(user).save(newSalaryAcctSobConfig); + getSalaryCacheService(user).remove(SalaryCacheKey.ACCT_SOB_CONFIG + cacheIndex); + return false; + } + + // 如果薪资核算记录已经归档了,不再校验薪资核算的账套配置是否已经发生变更 + if (!Objects.equals(salaryAcctRecord.getStatus(), SalaryAcctRecordStatusEnum.NOT_ARCHIVED.getValue())) { + return false; + } + + SalaryAcctConfig config = SalaryAcctConfig.parse(salaryAcctSobConfig); + SalaryAcctConfig newConfig = SalaryAcctConfig.parse(newSalaryAcctSobConfig); + + // 判断账套配置是否已经变更了 + SalarySobPO salarySobPO = config.getSalarySob(); + SalarySobPO newSalarySobPO = newConfig.getSalarySob(); + if (!ValidUtil.compare(salarySobPO, newSalarySobPO)) { + return true; + } + + List salarySobEmpFields = config.getSalarySobEmpFields(); + List newSalarySobEmpFields = newConfig.getSalarySobEmpFields(); + if (SalarySobEmpFieldPO.toCompareString(salarySobEmpFields).compareTo(SalarySobEmpFieldPO.toCompareString(newSalarySobEmpFields)) != 0) { + return true; + } + + List salarySobItemGroups = config.getSalarySobItemGroups(); + List newSalarySobItemGroups = newConfig.getSalarySobItemGroups(); + if (SalarySobItemGroupPO.toCompareString(salarySobItemGroups).compareTo(SalarySobItemGroupPO.toCompareString(newSalarySobItemGroups)) != 0) { + return true; + } + + List salarySobItems = config.getSalarySobItems(); + List newSalarySobItems = newConfig.getSalarySobItems(); + if (SalarySobItemPO.toCompareString(salarySobItems).compareTo(SalarySobItemPO.toCompareString(newSalarySobItems)) != 0) { + return true; + } + + List salarySobBackItems = config.getSalarySobBackItems(); + List newSalarySobBackItems = newConfig.getSalarySobBackItems(); + if (SalarySobBackItemPO.toCompareString(salarySobBackItems).compareTo(SalarySobBackItemPO.toCompareString(newSalarySobBackItems)) != 0) { + return true; + } + return false; + } + + /** + * 更新薪资核算的账套配置 + * + * @param id + */ + public void updateSobConfig(Long id) { + getSalaryAcctSobConfigService(user).updateBySalaryAcctRecordId(id); + } +} diff --git a/src/com/engine/salary/wrapper/SalaryAcctResultWrapper.java b/src/com/engine/salary/wrapper/SalaryAcctResultWrapper.java new file mode 100644 index 000000000..097092b2e --- /dev/null +++ b/src/com/engine/salary/wrapper/SalaryAcctResultWrapper.java @@ -0,0 +1,314 @@ +package com.engine.salary.wrapper; + +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.cache.SalaryCacheKey; +import com.engine.salary.component.WeaTableColumnGroup; +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.progress.ProgressDTO; +import com.engine.salary.entity.salaryacct.dto.ConsolidatedTaxDetailDTO; +import com.engine.salary.entity.salaryacct.dto.SalaryAcctResultDetailDTO; +import com.engine.salary.entity.salaryacct.dto.SalaryAcctResultListColumnDTO; +import com.engine.salary.entity.salaryacct.param.*; +import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.service.*; +import com.engine.salary.service.impl.*; +import com.engine.salary.sys.service.SalarySysConfService; +import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.util.valid.ValidUtil; +import com.engine.salary.wrapper.proxy.SalaryAcctResultWrapperProxy; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang.math.NumberUtils; +import org.apache.commons.lang3.StringUtils; +import weaver.hrm.User; + +import java.math.BigDecimal; +import java.util.*; + +/** + * 薪资核算结果 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Slf4j +public class SalaryAcctResultWrapper extends Service implements SalaryAcctResultWrapperProxy { + + private SalaryAcctResultService getSalaryAcctResultService(User user) { + return ServiceUtil.getService(SalaryAcctResultServiceImpl.class, user); + } + + private SalaryAcctRecordService getSalaryAcctRecordService(User user) { + return ServiceUtil.getService(SalaryAcctRecordServiceImpl.class, user); + } + + private SalaryEmployeeService getSalaryEmployeeService(User user) { + return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user); + } + + private SalarySobItemService getSalarySobItemService(User user) { + return ServiceUtil.getService(SalarySobItemServiceImpl.class, user); + } + + private SalaryAcctEmployeeWrapper getSalaryAcctEmployeeWrapper(User user) { + return ServiceUtil.getService(SalaryAcctEmployeeWrapper.class, user); + } + + private ProgressService getSalaryAcctProgressService(User user) { + return ServiceUtil.getService(ProgressServiceImpl.class, user); + } + +// private SalaryCheckResultService salaryCheckResultService; + + + private SalaryAcctExcelService getSalaryAcctExcelService(User user) { + return ServiceUtil.getService(SalaryAcctExcelServiceImpl.class, user); + } + + private SalarySysConfService getSalarySysConfService(User user) { + return ServiceUtil.getService(SalarySysConfServiceImpl.class, user); + } + + private SalaryApprovalRuleService getSalaryApprovalRuleService(User user) { + return ServiceUtil.getService(SalaryApprovalRuleServiceImpl.class, user); + } + + /** + * 薪资核算列表 + * + * @param queryParam 列表查询条件 + * @return + */ + public Map listPage(SalaryAcctResultQueryParam queryParam) { + ValidUtil.doValidator(queryParam); + // 查询薪资核算记录 + SalaryAcctRecordPO salaryAcctRecordPO = getSalaryAcctRecordService(user).getById(queryParam.getSalaryAcctRecordId()); + if (Objects.isNull(salaryAcctRecordPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98747, "薪资核算记录不存在或已被删除")); + } + + // 查询薪资核算结果(分页) + PageInfo> page = getSalaryAcctResultService(user).listPageByParam(queryParam); + + // 构建薪资核算结果列表的表头 + List columns = getSalaryAcctExcelService(user).listWeaTableColumn(salaryAcctRecordPO); + + Map datas = new HashMap<>(); + datas.put("pageInfo", page); + datas.put("columns", columns); + + return datas; + } + + /** + * 合计行 + * + * @param queryParam 列表查询条件 + * @return + */ + public Map sumSalaryAcctResult(SalaryAcctResultQueryParam queryParam) { + ValidUtil.doValidator(queryParam); + + Map datas = new HashMap<>(); + + //合计 +// SalarySysConfPO openSum = getSalarySysConfService(user).getOneByCode(OPEN_ACCT_RESULT_SUM); + Map sumRow = getSalaryAcctResultService(user).sumRow(queryParam); + datas.put("sumRow", sumRow); + return datas; + } + + + /** + * 薪资核算列表-报表使用 + * + * @param queryParam 列表查询条件 + * @return + */ + @Deprecated + public Map list(SalaryAcctResultQueryParam queryParam) { + ValidUtil.doValidator(queryParam); + // 查询薪资核算记录 + SalaryAcctRecordPO salaryAcctRecordPO = getSalaryAcctRecordService(user).getById(queryParam.getSalaryAcctRecordId()); + if (Objects.isNull(salaryAcctRecordPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98747, "薪资核算记录不存在或已被删除")); + } + + // 查询薪资核算结果 + List> list = getSalaryAcctResultService(user).listByParam(queryParam); + + // 构建薪资核算结果列表的表头 + Map columns = getSalaryAcctExcelService(user).listColumn(salaryAcctRecordPO); + + Map datas = new HashMap<>(); + datas.put("list", list); + datas.put("columns", columns); + + return datas; + } + + /** + * 薪资核算结果详情 + * + * @param salaryAcctEmployeeId 薪资核算人员id + * @return + */ + public SalaryAcctResultDetailDTO getForm(Long salaryAcctEmployeeId) { + // 获取薪资核算结果详情 + return getSalaryAcctResultService(user).getBySalaryAcctEmployeeId(salaryAcctEmployeeId); + } + + /** + * 获取合并计税详情 + * + * @param salaryAcctEmployeeId 薪资核算人员id + * @return + */ + public ConsolidatedTaxDetailDTO getConsolidatedTaxDetail(Long salaryAcctEmployeeId) { + // 获取合并计税详情 + return getSalaryAcctResultService(user).getConsolidatedTaxDetail(salaryAcctEmployeeId); + } + + /** + * 根据薪资核算记录id获取表头数据 + * + * @param salaryAcctRecordId + * @return + */ + public Map getColumnBySalaryAcctRecordId(Long salaryAcctRecordId) { + return getSalaryAcctResultService(user).getColumnBySalaryAcctRecordId(salaryAcctRecordId); + } + + /** + * 保存薪资核算结果 + * + * @param saveParam 保存参数 + */ + public void save(SalaryAcctResultSaveParam saveParam) { + getSalaryAcctResultService(user).save(saveParam); + } + + + public void lock(SalaryAcctResultLockParam param) { + getSalaryAcctResultService(user).lock(param); + } + + /** + * 更新薪资核算结果的值的锁定状态 + * + * @param updateParam + */ + public void updateLockStatusByParam(SalaryAcctResultUpdateLockStatusParam updateParam) { + getSalaryAcctResultService(user).updateLockStatusByParam(updateParam); + } + + /** + * 薪资核算-核算 + * + * @param calculateParam 薪资核算的参数 + */ + public void calculate(SalaryAcctCalculateParam calculateParam) { + log.info("开始核算V1{}", calculateParam); + + + // 校验是否可以编辑 + SalaryAcctRecordPO salaryAcctRecordPO = getSalaryAcctRecordService(user).getById(calculateParam.getSalaryAcctRecordId()); + boolean recordIsCanEdit = getSalaryApprovalRuleService(user).getRecordIsCanEdit(salaryAcctRecordPO); + if (!recordIsCanEdit) { + throw new SalaryRunTimeException("该核算记录已经发起审批,无法编辑或核算,请先删除审批流程"); + } + //当前登陆人员 + DataCollectionEmployee simpleEmployee = new DataCollectionEmployee(); + simpleEmployee.setEmployeeId((long) user.getUID()); + // 检查薪资核算人员的个税扣缴义务人 + getSalaryAcctEmployeeWrapper(user).checkTaxAgent(calculateParam.getSalaryAcctRecordId()); + // 检查是否正在核算中 + ProgressDTO salaryAcctProgressDTO = getSalaryAcctProgressService(user).getProgress(SalaryCacheKey.ACCT_PROGRESS + calculateParam.getSalaryAcctRecordId()); + if (Objects.nonNull(salaryAcctProgressDTO) && salaryAcctProgressDTO.isStatus() && Optional.ofNullable(salaryAcctProgressDTO.getProgress()).orElse(BigDecimal.ZERO).compareTo(BigDecimal.ONE) < 0) { + log.warn("正在核算中,无法再次执行"+calculateParam.getSalaryAcctRecordId()); + return; + } + // 初始化进度 + ProgressDTO initProgress = new ProgressDTO() + .setTitle(SalaryI18nUtil.getI18nLabel(97515, "核算中")) + .setTitleLabelId(97515L) + .setTotalQuantity(NumberUtils.INTEGER_ONE) + .setCalculatedQuantity(NumberUtils.INTEGER_ZERO) + .setProgress(BigDecimal.ZERO) + .setStatus(true) + .setMessage(StringUtils.EMPTY); + getSalaryAcctProgressService(user).initProgress(SalaryCacheKey.ACCT_PROGRESS + calculateParam.getSalaryAcctRecordId(), initProgress); + // 异步执行薪资核算 +// LocalRunnable localRunnable = new LocalRunnable() { +// @Override +// public void execute() { +// getSalaryAcctResultService(user).calculate(calculateParam, simpleEmployee); +// } +// }; +// ThreadPoolUtil.fixedPoolExecute(ModulePoolEnum.HRM, "salaryAcctCalculateV1", localRunnable); + new Thread() { + public void run() { + getSalaryAcctResultService(user).calculate(calculateParam, simpleEmployee); + } + }.start(); + + } + + /** + * 检查是否有薪资核算结果的查看权限 + * @param salaryAcctRecordId + */ + public Boolean checkAuth(Long salaryAcctRecordId) { +// if(Objects.isNull(salaryAcctRecordId)){ +// return false; +// } +// return getSalaryAcctResultService(user).checkAuth(salaryAcctRecordId); + return true; + } + + /** + * 薪资核算结果批量更新 + * @param param + */ + public void batchUpdate(SalaryAcctResultBatchUpdateParam param) { + getSalaryAcctResultService(user).batchUpdate(param); + } + + /** + * 薪资核算-校验 + * + * @param checkParam 薪资核算的参数 + * @param simpleEmployee 当前登陆人员 + * @param tenantKey 租户key + */ +// public void check(SalaryAcctCheckParam checkParam, DataCollectionEmployee simpleEmployee, String tenantKey) { +// // 检查是否正在核算中 +// SalaryAcctProgressDTO salaryAcctProgressDTO = salaryAcctProgressService.getProgress("" + checkParam.getSalaryAcctRecordId(), simpleEmployee.getEmployeeId(), tenantKey); +// if (Objects.nonNull(salaryAcctProgressDTO) && salaryAcctProgressDTO.isStatus() && Optional.ofNullable(salaryAcctProgressDTO.getProgress()).orElse(BigDecimal.ZERO).compareTo(BigDecimal.ONE) < 0) { +// return; +// } +// // 初始化进度 +// SalaryAcctProgressDTO initProgress = new SalaryAcctProgressDTO() +// .setTitle(SalaryI18nUtil.getI18nLabel(99664, "正在运行校验规则")) +// .setTitleLabelId(99664L) +// .setTotalQuantity(NumberUtils.INTEGER_ONE) +// .setCalculatedQuantity(NumberUtils.INTEGER_ZERO) +// .setProgress(BigDecimal.ZERO) +// .setStatus(true) +// .setMessage(StringUtils.EMPTY); +// salaryAcctProgressService.initProgress("" + checkParam.getSalaryAcctRecordId(), initProgress, simpleEmployee.getEmployeeId(), tenantKey); +// // 异步执行校验 +// LocalRunnable localRunnable = new LocalRunnable() { +// @Override +// public void execute() { +// salaryCheckResultService.check(checkParam, false, simpleEmployee, tenantKey); +// } +// }; +// ThreadPoolUtil.fixedPoolExecute(ModulePoolEnum.OTHER, "salaryAcctCheck", localRunnable); +// } +} diff --git a/src/com/engine/salary/wrapper/SalaryApprovalWrapper.java b/src/com/engine/salary/wrapper/SalaryApprovalWrapper.java new file mode 100644 index 000000000..81c6b10ce --- /dev/null +++ b/src/com/engine/salary/wrapper/SalaryApprovalWrapper.java @@ -0,0 +1,168 @@ +package com.engine.salary.wrapper; + +import com.api.formmode.mybatis.util.SqlProxyHandle; +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.component.WeaTableColumnGroup; +import com.engine.salary.entity.salaryacct.param.SalaryAcctResultQueryParam; +import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO; +import com.engine.salary.entity.salaryitem.param.SalaryItemSearchParam; +import com.engine.salary.entity.salaryitem.po.SalaryItemPO; +import com.engine.salary.entity.salarysob.bo.SalarySobItemAggregateBO; +import com.engine.salary.entity.salarysob.dto.SalaryApprovalDTO; +import com.engine.salary.entity.salarysob.dto.SalarySobEmpFieldDTO; +import com.engine.salary.entity.salarysob.param.ApprovalRequestSaveParam; +import com.engine.salary.entity.salarysob.param.SalaryApprovalQueryParam; +import com.engine.salary.entity.salarysob.po.SalarySobEmpFieldPO; +import com.engine.salary.enums.salaryaccounting.LockStatusEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.mapper.sys.SalarySysConfMapper; +import com.engine.salary.service.*; +import com.engine.salary.service.impl.*; +import com.engine.salary.sys.entity.po.SalarySysConfPO; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.util.page.SalaryPageUtil; +import com.engine.salary.util.valid.ValidUtil; +import com.google.common.collect.Lists; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.math.NumberUtils; +import weaver.hrm.User; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +import static com.engine.salary.sys.constant.SalarySysConstant.SALARY_ACCT_FIXED_COLUMNS; + +/** + * 薪资账套的薪资审批 + *

Copyright: Copyright (c) 2024

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SalaryApprovalWrapper extends Service { + + private SalaryApprovalRuleService getSalaryApprovalRuleService(User user) { + return ServiceUtil.getService(SalaryApprovalRuleServiceImpl.class, user); + } + + private SalaryAcctRecordService getSalaryAcctRecordService(User user) { + return ServiceUtil.getService(SalaryAcctRecordServiceImpl.class, user); + } + + private SalaryAcctResultService getSalaryAcctResultService(User user) { + return ServiceUtil.getService(SalaryAcctResultServiceImpl.class, user); + } + + private SalarySobEmpFieldService getSalarySobEmpFieldService(User user) { + return ServiceUtil.getService(SalarySobEmpFieldServiceImpl.class, user); + } + + private SalaryItemService getSalaryItemService(User user) { + return ServiceUtil.getService(SalaryItemServiceImpl.class, user); + } + + private SalarySysConfMapper getSalarySysConfMapper() { + return SqlProxyHandle.getProxy(SalarySysConfMapper.class); + } + + /** + * 薪资账套的薪资审批规则 + * + * @param queryParam 查询参数 + * @return + */ + public SalaryApprovalDTO salaryApprovalForm(SalaryApprovalQueryParam queryParam) { + ValidUtil.doValidator(queryParam); + return getSalaryApprovalRuleService(user).salaryApprovalForm(queryParam); + } + + /** + * 保存薪资账套的薪资审批规则 + * + * @param salaryApprovalDTO + * + */ + public void saveSalaryApprovalForm(SalaryApprovalDTO salaryApprovalDTO) { + getSalaryApprovalRuleService(user).saveSalaryApprovalForm(salaryApprovalDTO); + } + + public List listSalaryApprovalItem(SalaryItemSearchParam queryParam) { + return getSalaryApprovalRuleService(user).listSalaryApprovalItem(queryParam); + } + + public SalaryApprovalDTO getApprovalInfoByRecordId(Long salaryAcctRecordId) { + return getSalaryApprovalRuleService(user).getApprovalInfoByRecordId(salaryAcctRecordId); + } + + public Map listSalaryApprovalAcctResult(SalaryAcctResultQueryParam queryParam) { + ValidUtil.doValidator(queryParam); + // 审批信息 + SalaryApprovalDTO approvalInfoByRecordId = getSalaryApprovalRuleService(user).getApprovalInfoByRecordId(queryParam.getSalaryAcctRecordId()); + + // 查询薪资核算记录 + SalaryAcctRecordPO salaryAcctRecordPO = getSalaryAcctRecordService(user).getById(queryParam.getSalaryAcctRecordId()); + if (Objects.isNull(salaryAcctRecordPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98747, "薪资核算记录不存在或已被删除")); + } + + // 查询薪资核算结果(分页) + PageInfo> page = getSalaryAcctResultService(user).listPageByParam(queryParam); + + // 构建薪资核算结果审批列表的表头 + List columns = Lists.newArrayList(); + // 查询薪资账套的员工信息字段 + List salarySobEmpFieldPOS = getSalarySobEmpFieldService(user).listBySalarySobId(salaryAcctRecordPO.getSalarySobId()); + List salarySobEmpFieldDTOS = new SalarySobItemAggregateBO().buildEmpField(salarySobEmpFieldPOS); + // 获取薪资项目信息 + List salaryItemPOS = getSalaryItemService(user).listAll(); + Map salaryItemWidthMap = SalaryEntityUtil.convert2Map(salaryItemPOS, SalaryItemPO::getId, SalaryItemPO::getWidth); + // 员工信息字段 + for (SalarySobEmpFieldDTO salarySobEmpFieldDTO : salarySobEmpFieldDTOS) { + columns.add(new WeaTableColumnGroup(SalaryPageUtil.selfAdaption(salarySobEmpFieldDTO.getFieldName(), 0), salarySobEmpFieldDTO.getFieldName(), salarySobEmpFieldDTO.getFieldId())); + } + // 薪资项目分组下的薪资项目 + for (SalaryApprovalDTO.approvalItemGroup groupDTO : approvalInfoByRecordId.getApprovalItemGroup()) { + if (CollectionUtils.isEmpty(groupDTO.getApprovalItems())) { + continue; + } + List childrenColumns = Lists.newArrayList(); + for (SalaryApprovalDTO.approvalItem approvalItemDTO : groupDTO.getApprovalItems()) { + childrenColumns.add(new WeaTableColumnGroup(SalaryPageUtil.selfAdaption(approvalItemDTO.getSalaryItemName(), salaryItemWidthMap.getOrDefault(approvalItemDTO.getSalaryItemId(), 0) == null ? 0 : salaryItemWidthMap.getOrDefault(approvalItemDTO.getSalaryItemId(), 0)), approvalItemDTO.getSalaryItemName(), "" + approvalItemDTO.getSalaryItemId(), LockStatusEnum.UNLOCK.getValue().toString())); + } + WeaTableColumnGroup weaTableColumnWapper = new WeaTableColumnGroup(SalaryPageUtil.selfAdaption(groupDTO.getGroupName(), 0), groupDTO.getGroupName(), groupDTO.getGroupName(), childrenColumns); + columns.add(weaTableColumnWapper); + } + + // 获取固定列头数 + SalarySysConfPO salaryAcctFixedColumns = getSalarySysConfMapper().getOneByCode(SALARY_ACCT_FIXED_COLUMNS); + if (salaryAcctFixedColumns != null) { + int fixedNum = NumberUtils.isCreatable(salaryAcctFixedColumns.getConfValue()) ? Integer.valueOf(salaryAcctFixedColumns.getConfValue()) : 3; + if (fixedNum == 0) { + fixedNum = 3; + } + for (int i = 0; i < fixedNum; i++) { + columns.get(i).setFixed("left"); + } + } + + Map datas = new HashMap<>(); + datas.put("pageInfo", page); + datas.put("columns", columns); + + return datas; + } + + /** + * 保存审批流程id + * @param saveParam + */ + public void saveApprovalRequestId(ApprovalRequestSaveParam saveParam) { + getSalaryApprovalRuleService(user).saveApprovalRequestId(saveParam); + } +} diff --git a/src/com/engine/salary/wrapper/SalaryArchiveItemWrapper.java b/src/com/engine/salary/wrapper/SalaryArchiveItemWrapper.java new file mode 100644 index 000000000..d53341ea3 --- /dev/null +++ b/src/com/engine/salary/wrapper/SalaryArchiveItemWrapper.java @@ -0,0 +1,486 @@ +package com.engine.salary.wrapper; + +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.hrmelog.entity.dto.LoggerContext; +import com.engine.salary.config.SalaryElogConfig; +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.salaryarchive.dto.SalaryArchiveItemFormDTO; +import com.engine.salary.entity.salaryarchive.dto.SalaryArchiveListDTO; +import com.engine.salary.entity.salaryarchive.dto.SalaryItemAdjustRecordListDTO; +import com.engine.salary.entity.salaryarchive.dto.SingleSalaryItemAdjustRecordListDTO; +import com.engine.salary.entity.salaryarchive.param.*; +import com.engine.salary.entity.salaryarchive.po.SalaryArchiveItemPO; +import com.engine.salary.entity.salaryitem.po.SalaryItemPO; +import com.engine.salary.enums.OperateTypeEnum; +import com.engine.salary.enums.UserStatusEnum; +import com.engine.salary.enums.auth.AuthFilterTypeEnum; +import com.engine.salary.enums.datacollection.UseEmployeeTypeEnum; +import com.engine.salary.enums.salaryarchive.SalaryArchiveItemAdjustReasonEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.service.*; +import com.engine.salary.service.impl.*; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.util.page.SalaryPageUtil; +import com.engine.salary.wrapper.proxy.SalaryArchiveItemWrapperProxy; +import com.google.common.collect.Lists; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.math.NumberUtils; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.springframework.beans.BeanUtils; +import weaver.hrm.User; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * 薪资项目 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ + +public class SalaryArchiveItemWrapper extends Service implements SalaryArchiveItemWrapperProxy { + + private SalaryArchiveItemService getSalaryArchiveItemService(User user) { + return (SalaryArchiveItemService) ServiceUtil.getService(SalaryArchiveItemServiceImpl.class, user); + } + + private SalaryItemService getSalaryItemService(User user) { + return (SalaryItemService) ServiceUtil.getService(SalaryItemServiceImpl.class, user); + } + + private TaxAgentService getTaxAgentService(User user) { + return (TaxAgentService) ServiceUtil.getService(TaxAgentServiceImpl.class, user); + } + + private SalaryArchiveService getSalaryArchiveService(User user) { + return ServiceUtil.getService(SalaryArchiveServiceImpl.class, user); + } + + private SalaryEmployeeService getSalaryEmployeeService(User user) { + return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user); + } + + + /** + * 构建薪资项目基础信息表单 + * + * @param effectiveTime + * @param adjustReason + * @param description + * @return + */ + private Map buildSalaryArchiveItemForm(Date effectiveTime, String adjustReason, String description) { + + // 控件数据 + Map data = new HashMap<>(); + data.put("effectiveTime", effectiveTime == null ? null : effectiveTime + ""); + data.put("adjustReason", adjustReason); + data.put("description", description); + data.put("adjustReasonList", SalaryArchiveItemAdjustReasonEnum.getList()); + return data; + } + + /** + * 构建薪资档案调整明细 + * + * @return + */ + private Map buildSalaryArchiveItemAdjustDetailTable(List> tableData) { + Map map = new HashMap<>(); + // 表头 + List columns = new ArrayList<>(); + columns.add(SalaryI18nUtil.getI18nLabel(84960, "薪资项目")); + columns.add(SalaryI18nUtil.getI18nLabel(85433, "调整前")); + columns.add(SalaryI18nUtil.getI18nLabel(85434, "调整后")); + // 获取所有可被引用的薪资项目 + List salaryItemList = getSalaryArchiveItemService(user).getCanAdjustSalaryItems(); + + List> salaryItems = salaryItemList.stream() + .map(m -> { + Map salaryItemMap = new LinkedHashMap<>(); + salaryItemMap.put("id", String.valueOf(m.getId())); + salaryItemMap.put("content", m.getName()); + salaryItemMap.put("dataType", m.getDataType()); + salaryItemMap.put("pattern", m.getPattern()); + return salaryItemMap; + }).collect(Collectors.toList()); + + map.put("columns", columns); + map.put("list", tableData); + map.put("salaryItemList", salaryItems); + + return map; + } + + /** + * 获取薪资项目调整前的值 + * + * @param adjustBeforeParam + * @return + */ + public String getSalaryItemAdjustBeforeValue(SalaryItemAdjustBeforeParam adjustBeforeParam) { + return getSalaryArchiveItemService(user).getSalaryItemAdjustBeforeValue(adjustBeforeParam); + } + + public SalaryArchiveItemFormDTO getSalaryItemForm(Long salaryArchiveId) { + + // 调整明细数据 + List> tableData = Lists.newArrayList(); + + return SalaryArchiveItemFormDTO.builder() + .salaryArchiveId(salaryArchiveId) + .salaryArchiveItemForm(buildSalaryArchiveItemForm(null, null, null)) + .salaryArchiveItemDetail(buildSalaryArchiveItemAdjustDetailTable(tableData)) + .build(); + } + + + /** + * 通过薪资档案的薪资项目id获取薪资项目调整表单 + * + * @param salaryArchiveItemId + * @return + */ + public SalaryArchiveItemFormDTO getSalaryItemFormBySalaryArchiveItemId(Long salaryArchiveItemId) { + if (salaryArchiveItemId == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100427, "薪资档案的薪资项目id不能为空")); + } + SalaryArchiveItemPO salaryArchiveItem = getSalaryArchiveItemService(user).getById(salaryArchiveItemId); + if (salaryArchiveItem == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100428, "该薪资档案的薪资项目的调整记录不存在")); + } + Long salaryArchiveId = salaryArchiveItem.getSalaryArchiveId(); + Date effectiveTime; + String adjustReason; + String description; + // 调整明细数据 + List> tableData = Lists.newArrayList(); + // 获取调整前 + String archiveItemBeforeValue = getSalaryArchiveItemService(user).getSalaryItemAdjustBeforeValue(SalaryItemAdjustBeforeParam.builder() + .salaryArchiveId(salaryArchiveItem.getSalaryArchiveId()) + .salaryArchiveItemId(salaryArchiveItem.getId()) + .salaryItemId(salaryArchiveItem.getSalaryItemId()) + .build()); + + effectiveTime = salaryArchiveItem.getEffectiveTime(); + adjustReason = salaryArchiveItem.getAdjustReason(); + description = salaryArchiveItem.getDescription(); + Map map = new HashMap<>(3); + map.put("salaryItem", String.valueOf(salaryArchiveItem.getSalaryItemId())); + map.put("salaryBefore", archiveItemBeforeValue); + map.put("adjustAfter", salaryArchiveItem.getItemValue()); + tableData.add(map); + + return SalaryArchiveItemFormDTO.builder() + .salaryArchiveId(salaryArchiveId) + .salaryArchiveItemForm(buildSalaryArchiveItemForm(effectiveTime, adjustReason, description)) + .salaryArchiveItemDetail(buildSalaryArchiveItemAdjustDetailTable(tableData)) + .build(); + } + + /** + * 调整前校验 + * + * @param saveParam + * @return + */ + public String checkSaveSalaryItem(SalaryArchiveItemSaveParam saveParam) { + return getSalaryArchiveItemService(user).checkSaveSalaryItem(saveParam); + } + + /** + * 保存薪资项目调整 + * + * @param saveParam + * @return + */ + public String saveSalaryItem(SalaryArchiveItemSaveParam saveParam) { + return getSalaryArchiveItemService(user).saveSalaryItem(saveParam); + } + + /** + * 删除薪资项目调整 + * + * @param salaryArchiveItemId + * @return + */ + public String deleteSalaryItem(Long salaryArchiveItemId) { + return getSalaryArchiveItemService(user).deleteSalaryItem(salaryArchiveItemId); + } + + + /** + * 薪资项目调整记录列表 + * + * @param queryParam + * @return + */ + public PageInfo adjustRecordList(SalaryItemAdjustRecordQueryParam queryParam) { + // 获取所有可被引用的薪资项目 + List salaryItemList = getSalaryArchiveItemService(user).getCanAdjustSalaryItems(); + List salaryItemIds = salaryItemList.stream().map(SalaryItemPO::getId).collect(Collectors.toList()); + + List employeeList = getSalaryEmployeeService(user).listAll(UseEmployeeTypeEnum.ALL); + Map employeeMap = SalaryEntityUtil.convert2Map(employeeList, DataCollectionEmployee::getEmployeeId); + + List listAll = getSalaryArchiveItemService(user).salaryItemAdjustRecordList(SalaryItemAdjustRecordQueryParam.builder().build(), salaryItemIds); + //分权 + SalaryArchiveQueryParam archiveQueryParam = new SalaryArchiveQueryParam(); + archiveQueryParam.setFilterType(AuthFilterTypeEnum.QUERY_DATA); + List salaryArchiveIds = getSalaryArchiveService(user).list(archiveQueryParam).stream().map(SalaryArchiveListDTO::getId).collect(Collectors.toList()); + queryParam.setSalaryArchiveIds(salaryArchiveIds); + + List listResult = getSalaryArchiveItemService(user).salaryItemAdjustRecordList(queryParam, salaryItemIds); + listResult = listResult.stream() + .filter(r -> { + DataCollectionEmployee employee = employeeMap.get(r.getEmployeeId()); + if (employee == null) { + return false; + } + String username = queryParam.getUsername(); + List departmentIds = queryParam.getDepartmentIds(); + List positionIds = queryParam.getPositionIds(); + String userstatus = queryParam.getUserstatus(); + r.setUsername(employee.getUsername()); + r.setDepartmentName(employee.getDepartmentName()); + r.setEmployeeStatus(StringUtils.isNotBlank(employee.getStatus())&& NumberUtils.isCreatable(employee.getStatus())? + UserStatusEnum.getDefaultLabelByValue(Integer.parseInt(employee.getStatus())):""); + r.setAdjustReason(SalaryArchiveItemAdjustReasonEnum.getDefaultLabelByValue(r.getAdjustReason())); + return (StringUtils.isBlank(username) || employee.getUsername().contains(username)) + && (CollectionUtils.isEmpty(departmentIds) || departmentIds.contains(employee.getDepartmentId())) + && (CollectionUtils.isEmpty(positionIds) || positionIds.contains(employee.getJobtitleId())) + && (StringUtils.isBlank(userstatus) || Objects.equals(employee.getStatus(), userstatus)) + && (CollectionUtils.isEmpty(positionIds) || positionIds.contains(employee.getJobtitleId())) + ; + }) + .collect(Collectors.toList()); + + PageInfo pageInfo = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), listResult, SalaryItemAdjustRecordListDTO.class); + + listResult = pageInfo.getList(); + //获取上次更改的记录 + listResult.forEach(m -> { + if (!CollectionUtils.isEmpty(listAll)) { + listAll.removeIf(a -> a.getId().equals(m.getId())); + } + Optional optional = listAll.stream().filter(f -> f.getSalaryArchiveId().equals(m.getSalaryArchiveId()) && f.getSalaryItemId().equals(m.getSalaryItemId())).findFirst(); + m.setAdjustBefore(optional.isPresent() ? optional.get().getAdjustAfter() : ""); + }); + return pageInfo; + } + + + /** + * 我的调薪记录 + * + * @param queryParam + * @return + */ + public PageInfo myAdjustRecordList(SalaryItemAdjustRecordQueryParam queryParam) { + // 获取所有可被引用的薪资项目 + List salaryItemList = getSalaryArchiveItemService(user).getCanAdjustSalaryItems(); + List salaryItemIds = salaryItemList.stream().map(SalaryItemPO::getId).collect(Collectors.toList()); + + DataCollectionEmployee employee = getSalaryEmployeeService(user).getEmployeeById(queryParam.getEmployeeId()); + + List listAll = getSalaryArchiveItemService(user).salaryItemAdjustRecordList(SalaryItemAdjustRecordQueryParam.builder().build(), salaryItemIds); + PageInfo list = getSalaryArchiveItemService(user).salaryItemAdjustRecordListPage(queryParam, salaryItemIds); + List listResult = list.getList(); + //获取上次更改的记录 + listResult.forEach(m -> { + if (!CollectionUtils.isEmpty(listAll)) { + listAll.removeIf(a -> a.getId().equals(m.getId())); + } + Optional optional = listAll.stream().filter(f -> f.getSalaryArchiveId().equals(m.getSalaryArchiveId()) && f.getSalaryItemId().equals(m.getSalaryItemId())).findFirst(); + m.setAdjustBefore(optional.isPresent() ? optional.get().getAdjustAfter() : ""); + + m.setUsername(employee.getUsername()); + m.setDepartmentName(employee.getDepartmentName()); + m.setEmployeeStatus(StringUtils.isNotBlank(employee.getStatus())&& NumberUtils.isCreatable(employee.getStatus())? + UserStatusEnum.getDefaultLabelByValue(Integer.parseInt(employee.getStatus())):""); + m.setAdjustReason(SalaryArchiveItemAdjustReasonEnum.getDefaultLabelByValue(m.getAdjustReason())); + }); + + // 记录查看日志 + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + // TODO 我的调薪记录setTargetId + // loggerContext.setTargetId(); + loggerContext.setTargetName("我的调薪记录"); + loggerContext.setOperateType(OperateTypeEnum.READ.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "查看调薪记录")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "查看调薪记录")); + SalaryElogConfig.myAdjustRecordLoggerTemplate.write(loggerContext); + return list; + } + + + /** + * 单个档案的薪资项目调整记录列表 + * + * @param queryParam + * @return + */ + public PageInfo singleSalaryItemAdjustRecordList(SingleSalaryItemAdjustRecordQueryParam queryParam) { + Long salaryArchiveId = queryParam.getSalaryArchiveId(); + + if (salaryArchiveId == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100425, "薪资档案id不能为空")); + } + // 获取所有可被引用的薪资项目 + List salaryItemList = getSalaryArchiveItemService(user).getCanAdjustSalaryItems(); + List salaryItemIds = salaryItemList.stream().map(SalaryItemPO::getId).collect(Collectors.toList()); + + SalaryItemAdjustRecordQueryParam adjustRecordQueryParam = new SalaryItemAdjustRecordQueryParam(); + BeanUtils.copyProperties(queryParam, adjustRecordQueryParam); + + //所有调整记录 + List listAll = getSalaryArchiveItemService(user).salaryItemAdjustRecordList(SalaryItemAdjustRecordQueryParam.builder().build(), salaryItemIds); + + //操作记录 + //根据条件分页查询调整记录 + PageInfo adjustlistByParamPage = getSalaryArchiveItemService(user).salaryItemAdjustRecordListPage(adjustRecordQueryParam, salaryItemIds); + List adjustPageList = adjustlistByParamPage.getList(); + List resultList = Lists.newArrayList(); + adjustPageList.forEach(m -> { + if (CollectionUtils.isNotEmpty(listAll)) { + listAll.removeIf(a -> a.getId().equals(m.getId())); + } + Optional optional = listAll.stream() + .filter(f -> f.getSalaryArchiveId().equals(m.getSalaryArchiveId())) + .filter(f -> f.getSalaryItemId().equals(m.getSalaryItemId())) + .filter(f -> f.getEffectiveTime().before(m.getEffectiveTime())) + .findFirst(); + m.setAdjustBefore(optional.isPresent() ? optional.get().getAdjustAfter() : ""); + + m.setAdjustReason(SalaryArchiveItemAdjustReasonEnum.getDefaultLabelByValue(m.getAdjustReason())); + + SingleSalaryItemAdjustRecordListDTO singleSalaryItemAdjustRecordList = new SingleSalaryItemAdjustRecordListDTO(); + BeanUtils.copyProperties(m, singleSalaryItemAdjustRecordList); + resultList.add(singleSalaryItemAdjustRecordList); + }); + + List salaryItemPageIds = resultList.stream().map(SingleSalaryItemAdjustRecordListDTO::getSalaryItemId).collect(Collectors.toList()); + List effectiveSalaryItems = getSalaryArchiveItemService(user).getEffectiveSalaryItems(salaryArchiveId, salaryItemPageIds); + // 行记录按钮权限控制 + for (int i = 0; i < resultList.size(); i++) { + SingleSalaryItemAdjustRecordListDTO singleSalaryItemAdjustRecord = resultList.get(i); + Optional optional = effectiveSalaryItems.stream().filter(f -> f.getSalaryItemId().equals(singleSalaryItemAdjustRecord.getSalaryItemId())).findFirst(); + Date effectiveDate = optional.map(SalaryArchiveItemPO::getEffectiveTime).orElse(null); + + if (effectiveDate != null && singleSalaryItemAdjustRecord.getEffectiveTime().before(effectiveDate)) { + singleSalaryItemAdjustRecord.setCanOperator(Boolean.FALSE); + } else { + singleSalaryItemAdjustRecord.setCanOperator(Boolean.TRUE); + } + } + + + PageInfo listPage = new PageInfo(resultList, SingleSalaryItemAdjustRecordListDTO.class); + listPage.setTotal(adjustlistByParamPage.getTotal()); + listPage.setPageNum(adjustlistByParamPage.getPageNum()); + listPage.setPageSize(adjustlistByParamPage.getPageSize()); + + + return listPage; + } + + /** + * @return void + * @description 单个档案的薪资项目调整的编辑 + * @author Harryxzy + * @date 2022/11/14 11:46 + */ + @Override + public String editSingleSalaryItem(SalaryArchiveItemSaveParam salaryArchiveItemSaveParam) { + return getSalaryArchiveItemService(user).editSingleSalaryItem(salaryArchiveItemSaveParam); + } + + /** + * 导出薪资项目调整记录列表 + * + * @param queryParam + * @return + */ + public XSSFWorkbook exportAdjustRecordList(SalaryItemAdjustRecordQueryParam queryParam) { + return getSalaryArchiveItemService(user).exportAdjustRecordList(queryParam); + } + + + /** + * @return void + * @description 获取单个档案的单个薪资项目调整信息 + * @author Harryxzy + * @date 2022/11/11 14:39 + */ + public SalaryArchiveItemFormDTO getSingleSalaryItemInfo(SingleSalaryItemAdjustRecordListDTO queryParam) { + SalaryArchiveItemPO byId = getSalaryArchiveItemService(user).getById(queryParam.getId()); + if (Objects.isNull(byId)) { + throw new SalaryRunTimeException("该薪资项目调整信息不存在"); + } + // 获取所有可被引用的薪资项目 + List salaryItemList = getSalaryArchiveItemService(user).getCanAdjustSalaryItems(); + List salaryItemIds = salaryItemList.stream().map(SalaryItemPO::getId).collect(Collectors.toList()); + //所有调整记录 + List listAll = getSalaryArchiveItemService(user).salaryItemAdjustRecordList(SalaryItemAdjustRecordQueryParam.builder().build(), salaryItemIds); + + //根据条件查询调整记录 + List adjustPageList = getSalaryArchiveItemService(user).salaryItemAdjustRecordList(SalaryItemAdjustRecordQueryParam.builder().salaryArchiveId(byId.getSalaryArchiveId()).build(), salaryItemIds); + + List resultList = Lists.newArrayList(); + adjustPageList.forEach(m -> { + if (CollectionUtils.isNotEmpty(listAll)) { + listAll.removeIf(a -> a.getId().equals(m.getId())); + } + Optional optional = listAll.stream().filter(f -> f.getSalaryArchiveId().equals(m.getSalaryArchiveId()) && f.getSalaryItemId().equals(m.getSalaryItemId())).findFirst(); + m.setAdjustBefore(optional.isPresent() ? optional.get().getAdjustAfter() : ""); + + m.setAdjustReason(SalaryArchiveItemAdjustReasonEnum.getDefaultLabelByValue(m.getAdjustReason())); + + SingleSalaryItemAdjustRecordListDTO singleSalaryItemAdjustRecordList = new SingleSalaryItemAdjustRecordListDTO(); + BeanUtils.copyProperties(m, singleSalaryItemAdjustRecordList); + resultList.add(singleSalaryItemAdjustRecordList); + }); + + List salaryItemPageIds = resultList.stream().map(SingleSalaryItemAdjustRecordListDTO::getSalaryItemId).collect(Collectors.toList()); + List effectiveSalaryItems = getSalaryArchiveItemService(user).getEffectiveSalaryItems(byId.getSalaryArchiveId(), salaryItemPageIds); + // 行记录按钮权限控制 + for (int i = 0; i < resultList.size(); i++) { + SingleSalaryItemAdjustRecordListDTO singleSalaryItemAdjustRecord = resultList.get(i); + if (singleSalaryItemAdjustRecord.getId().equals(queryParam.getId())) { +// Optional optional = effectiveSalaryItems.stream().filter(f -> f.getSalaryItemId().equals(singleSalaryItemAdjustRecord.getSalaryItemId())).findFirst(); +// Date effectiveDate = optional.map(SalaryArchiveItemPO::getEffectiveTime).orElse(null); +// if (effectiveDate != null && singleSalaryItemAdjustRecord.getEffectiveTime().before(effectiveDate)) { +// singleSalaryItemAdjustRecord.setCanOperator(Boolean.FALSE); +// } else { +// singleSalaryItemAdjustRecord.setCanOperator(Boolean.TRUE); +// } + singleSalaryItemAdjustRecord.setCanOperator(Boolean.TRUE); + Map map = new HashMap<>(3); + map.put("salaryItem", String.valueOf(singleSalaryItemAdjustRecord.getSalaryItemId())); + map.put("salaryBefore", singleSalaryItemAdjustRecord.getAdjustBefore()); + map.put("adjustAfter", singleSalaryItemAdjustRecord.getAdjustAfter()); + + // 调整明细数据 + List> tableData = Lists.newArrayList(); + tableData.add(map); + + return SalaryArchiveItemFormDTO.builder() + .canOperator(singleSalaryItemAdjustRecord.getCanOperator()) + .salaryArchiveId(byId.getSalaryArchiveId()) + .salaryArchiveItemForm(buildSalaryArchiveItemForm(byId.getEffectiveTime(), byId.getAdjustReason(), byId.getDescription())) + .salaryArchiveItemDetail(buildSalaryArchiveItemAdjustDetailTable(tableData)) + .build(); + + } + } + return null; + } +} diff --git a/src/com/engine/salary/wrapper/SalaryArchiveTaxAgentWrapper.java b/src/com/engine/salary/wrapper/SalaryArchiveTaxAgentWrapper.java new file mode 100644 index 000000000..a0c4f3200 --- /dev/null +++ b/src/com/engine/salary/wrapper/SalaryArchiveTaxAgentWrapper.java @@ -0,0 +1,267 @@ +package com.engine.salary.wrapper; + +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.entity.salaryarchive.dto.SalaryArchiveTaxAgentFormDTO; +import com.engine.salary.entity.salaryarchive.dto.SingleTaxAgentAdjustRecordListDTO; +import com.engine.salary.entity.salaryarchive.dto.TaxAgentAdjustRecordListDTO; +import com.engine.salary.entity.salaryarchive.param.SalaryArchiveTaxAgentSaveParam; +import com.engine.salary.entity.salaryarchive.param.SingleTaxAgentAdjustRecordQueryParam; +import com.engine.salary.entity.salaryarchive.param.TaxAgentAdjustRecordQueryParam; +import com.engine.salary.entity.salaryarchive.po.SalaryArchiveTaxAgentPO; +import com.engine.salary.entity.taxagent.dto.TaxAgentListDTO; +import com.engine.salary.entity.taxagent.param.TaxAgentQueryParam; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import com.engine.salary.enums.UserStatusEnum; +import com.engine.salary.enums.auth.AuthFilterTypeEnum; +import com.engine.salary.enums.salaryarchive.SalaryArchiveTaxAgentAdjustReasonEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.service.SalaryArchiveTaxAgentService; +import com.engine.salary.service.TaxAgentService; +import com.engine.salary.service.impl.SalaryArchiveTaxAgentServiceImpl; +import com.engine.salary.service.impl.TaxAgentServiceImpl; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.page.PageInfo; +import com.google.common.collect.Lists; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.springframework.beans.BeanUtils; +import weaver.hrm.User; + +import java.util.*; + +/** + * 薪资档案-个税扣缴义务人 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SalaryArchiveTaxAgentWrapper extends Service { + + private SalaryArchiveTaxAgentService getSalaryArchiveTaxAgentService(User user) { + return (SalaryArchiveTaxAgentService) ServiceUtil.getService(SalaryArchiveTaxAgentServiceImpl.class, user); + } + + private TaxAgentService getTaxAgentService(User user) { + return (TaxAgentService) ServiceUtil.getService(TaxAgentServiceImpl.class, user); + } + +// +// private SalaryBatchService salaryBatchService; +// +// private ExecutorService taskExecutor; + + /** + * 获取个税扣缴义务人调整表单 + * 获取调整原因和扣税义务人列表 + * + * @param salaryArchiveId + * @return + */ + public SalaryArchiveTaxAgentFormDTO getTaxAgentForm(Long salaryArchiveId) { + if (salaryArchiveId == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100425, "薪资档案id不能为空")); + } + + // 调整前 + String adjustBefore = ""; + String adjustReason = ""; + Date effectiveTime = null; + SalaryArchiveTaxAgentPO adjustBeforePo = getSalaryArchiveTaxAgentService(user).getAdjustBeforeTaxAgent(SalaryArchiveTaxAgentPO.builder().salaryArchiveId(salaryArchiveId).effectiveTime(new Date()).build()); + if (adjustBeforePo != null) { + TaxAgentPO taxAgent = getTaxAgentService(user).getById(adjustBeforePo.getTaxAgentId()); + if (taxAgent != null) { + adjustBefore = taxAgent.getName(); + } + adjustReason = adjustBeforePo.getAdjustReason(); + effectiveTime = adjustBeforePo.getEffectiveTime(); + } + + + // 构建表单 + Map form = buildTaxAgentForm(effectiveTime, adjustReason, adjustBefore, null); + + return SalaryArchiveTaxAgentFormDTO.builder() + .salaryArchiveId(salaryArchiveId) + .salaryArchiveTaxAgentForm(form) + .build(); + } + + private Map buildTaxAgentForm(Date effectiveTime, String adjustReason, String adjustBefore, Long adjustAfter) { + // 个税扣缴义务人下拉列表 + TaxAgentQueryParam param = TaxAgentQueryParam.builder().build(); + param.setFilterType(AuthFilterTypeEnum.ADMIN_DATA); + Collection taxAgentList = getTaxAgentService(user).listAuth(param); + + Map map = new HashMap<>(); + map.put("adjustReasonList", SalaryArchiveTaxAgentAdjustReasonEnum.getList()); + map.put("taxAgentList", taxAgentList); + map.put("effectiveTime", effectiveTime); + map.put("adjustBefore", adjustBefore); + map.put("adjustAfter", adjustAfter); + map.put("adjustReason", adjustReason); + return map; + } + + /** + * 通过薪资档案的个税扣缴义务人id获取个税扣缴义务人调整表单 + * + * @param salaryArchiveTaxAgentId + * @return + */ + public SalaryArchiveTaxAgentFormDTO getTaxAgentFormBySalaryArchiveTaxAgentId(Long salaryArchiveTaxAgentId) { + if (salaryArchiveTaxAgentId == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100489, "薪资档案的个税扣缴义务人id不能为空")); + } + SalaryArchiveTaxAgentPO salaryArchiveTaxAgent = getSalaryArchiveTaxAgentService(user).getById(salaryArchiveTaxAgentId); + if (salaryArchiveTaxAgent == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100484, "该薪资档案的个税扣缴义务人的调整记录不存在")); + } + // 个税扣缴义务人下拉列表 + Collection taxAgentList = getTaxAgentService(user).findAll(); + // 调整前 + String adjustBefore = ""; + SalaryArchiveTaxAgentPO adjustBeforePo = getSalaryArchiveTaxAgentService(user).getAdjustBeforeTaxAgent(salaryArchiveTaxAgent); + + if (adjustBeforePo != null) { + Optional optional = taxAgentList.stream().filter(f -> f.getId().equals(adjustBeforePo.getTaxAgentId())).findFirst(); + adjustBefore = optional.isPresent() ? optional.get().getName() : ""; + } + + Date effectiveTime = salaryArchiveTaxAgent.getEffectiveTime(); + String adjustReason = salaryArchiveTaxAgent.getAdjustReason(); + Long adjustAfter = salaryArchiveTaxAgent.getTaxAgentId(); + + // 构建表单 + Map taxAgentForm = buildTaxAgentForm(effectiveTime, adjustReason, adjustBefore, adjustAfter); + + return SalaryArchiveTaxAgentFormDTO.builder() + .salaryArchiveId(salaryArchiveTaxAgent.getSalaryArchiveId()) + .salaryArchiveTaxAgentForm(taxAgentForm) + .build(); + } + + /** + * 保存个税扣缴义务人调整 + * + * @param saveParam + * @return + */ + public String saveTaxAgent(SalaryArchiveTaxAgentSaveParam saveParam) { + return getSalaryArchiveTaxAgentService(user).saveTaxAgent(saveParam); + } + + /** + * 删除个税扣缴义务人调整 + * + * @param salaryArchiveTaxAgentId + * @return + */ + public String deleteTaxAgent(Long salaryArchiveTaxAgentId) { + return getSalaryArchiveTaxAgentService(user).deleteTaxAgent(salaryArchiveTaxAgentId); + } + + + /** + * 个税扣缴义务人调整记录列表 + * + * @param queryParam + * @return + */ + public PageInfo adjustRecordList(TaxAgentAdjustRecordQueryParam queryParam) { + + // 个税扣缴义务人 + Collection taxAgentList = getTaxAgentService(user).findAll(); + List listAll = getSalaryArchiveTaxAgentService(user).taxAgentAdjustRecordList(TaxAgentAdjustRecordQueryParam.builder().build()); + PageInfo page = getSalaryArchiveTaxAgentService(user).taxAgentAdjustRecordListPage(queryParam); + List list = page.getList(); + list.forEach(m -> { + if (!org.springframework.util.CollectionUtils.isEmpty(listAll)) { + listAll.removeIf(a -> a.getId().equals(m.getId())); + } + Optional optional = listAll.stream().filter(f -> f.getSalaryArchiveId().equals(m.getSalaryArchiveId())).findFirst(); + m.setAdjustBefore(optional.isPresent() ? optional.get().getAdjustAfter() : ""); + Optional optionalBefore = taxAgentList.stream().filter(t -> t.getId().toString().equals(m.getAdjustBefore())).findFirst(); + m.setAdjustBefore(optionalBefore.isPresent() ? optionalBefore.get().getName() : ""); + Optional optionalAfter = taxAgentList.stream().filter(t -> t.getId().toString().equals(m.getAdjustAfter())).findFirst(); + m.setAdjustAfter(optionalAfter.isPresent() ? optionalAfter.get().getName() : ""); + + m.setEmployeeStatus(UserStatusEnum.getDefaultLabelByValue(Integer.parseInt(m.getEmployeeStatus()))); + + m.setAdjustReason(SalaryArchiveTaxAgentAdjustReasonEnum.getDefaultLabelByValue(m.getAdjustReason())); + }); + + return page; + } + + /** + * 单个档案的个税扣缴义务人调整记录列表 + * + * @param queryParam + * @return + */ + public PageInfo singleTaxAgentAdjustRecordList(SingleTaxAgentAdjustRecordQueryParam queryParam) { + if (queryParam.getSalaryArchiveId() == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100425, "薪资档案id不能为空")); + } + + TaxAgentAdjustRecordQueryParam adjustRecordQueryParam = new TaxAgentAdjustRecordQueryParam(); + BeanUtils.copyProperties(queryParam, adjustRecordQueryParam); + PageInfo page = getSalaryArchiveTaxAgentService(user).taxAgentAdjustRecordListPage(adjustRecordQueryParam); + + // 个税扣缴义务人 + Collection taxAgentList = getTaxAgentService(user).findAll(); + List listAll = getSalaryArchiveTaxAgentService(user).taxAgentAdjustRecordList(TaxAgentAdjustRecordQueryParam.builder().build()); + List list = page.getList(); + List resultList = Lists.newArrayList(); + list.forEach(m -> { + if (!org.springframework.util.CollectionUtils.isEmpty(listAll)) { + listAll.removeIf(a -> a.getId().equals(m.getId())); + } + Optional optional = listAll.stream().filter(f -> f.getSalaryArchiveId().equals(m.getSalaryArchiveId())).findFirst(); + m.setAdjustBefore(optional.isPresent() ? optional.get().getAdjustAfter() : ""); + Optional optionalBefore = taxAgentList.stream().filter(t -> t.getId().toString().equals(m.getAdjustBefore())).findFirst(); + m.setAdjustBefore(optionalBefore.isPresent() ? optionalBefore.get().getName() : ""); + Optional optionalAfter = taxAgentList.stream().filter(t -> t.getId().toString().equals(m.getAdjustAfter())).findFirst(); + m.setAdjustAfter(optionalAfter.isPresent() ? optionalAfter.get().getName() : ""); + + m.setAdjustReason(SalaryArchiveTaxAgentAdjustReasonEnum.getDefaultLabelByValue(m.getAdjustReason())); + + SingleTaxAgentAdjustRecordListDTO singleTaxAgentAdjustRecordList = new SingleTaxAgentAdjustRecordListDTO(); + BeanUtils.copyProperties(m, singleTaxAgentAdjustRecordList); + resultList.add(singleTaxAgentAdjustRecordList); + }); + // 获取当前已生效 + SalaryArchiveTaxAgentPO salaryArchiveTaxAgent = getSalaryArchiveTaxAgentService(user).getEffectiveTaxAgent(queryParam.getSalaryArchiveId()); + Date effectiveDate = (salaryArchiveTaxAgent == null ? null : salaryArchiveTaxAgent.getEffectiveTime()); + + // 行记录按钮权限控制 + for (int i = 0; i < resultList.size(); i++) { + SingleTaxAgentAdjustRecordListDTO singleTaxAgentAdjustRecord = resultList.get(i); + if (effectiveDate != null && singleTaxAgentAdjustRecord.getEffectiveTime().before(effectiveDate)) { + singleTaxAgentAdjustRecord.setCanOperator(Boolean.FALSE); + } else { + singleTaxAgentAdjustRecord.setCanOperator(Boolean.TRUE); + } + } + PageInfo listPage = new PageInfo(resultList, SingleTaxAgentAdjustRecordListDTO.class); + listPage.setTotal(page.getTotal()); + listPage.setPageNum(page.getPageNum()); + listPage.setPageSize(page.getPageSize()); + + return listPage; + } + + /** + * 导出个税扣缴义务人调整记录列表 + * + * @param queryParam + * @return + */ + public XSSFWorkbook exportAdjustRecordList(TaxAgentAdjustRecordQueryParam queryParam) { + return getSalaryArchiveTaxAgentService(user).exportAdjustRecordList(queryParam); + } + + +} diff --git a/src/com/engine/salary/wrapper/SalaryArchiveWrapper.java b/src/com/engine/salary/wrapper/SalaryArchiveWrapper.java new file mode 100644 index 000000000..8a8b87e51 --- /dev/null +++ b/src/com/engine/salary/wrapper/SalaryArchiveWrapper.java @@ -0,0 +1,646 @@ +package com.engine.salary.wrapper; + +import com.cloudstore.eccom.pc.table.WeaTableColumn; +import com.cloudstore.eccom.result.WeaResultMsg; +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.hrmelog.entity.dto.LoggerContext; +import com.engine.salary.component.SalaryWeaTable; +import com.engine.salary.config.SalaryElogConfig; +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.salaryarchive.bo.SalaryArchiveBO; +import com.engine.salary.entity.salaryarchive.dto.SalaryArchiveBaseInfoFormDTO; +import com.engine.salary.entity.salaryarchive.dto.SalaryArchiveFormDTO; +import com.engine.salary.entity.salaryarchive.dto.SalaryArchiveListDTO; +import com.engine.salary.entity.salaryarchive.param.*; +import com.engine.salary.entity.salaryarchive.po.SalaryArchiveDimissionPO; +import com.engine.salary.entity.salaryarchive.po.SalaryArchiveItemPO; +import com.engine.salary.entity.salaryarchive.po.SalaryArchivePO; +import com.engine.salary.entity.salaryitem.po.SalaryItemPO; +import com.engine.salary.entity.taxagent.dto.TaxAgentListDTO; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import com.engine.salary.enums.OperateTypeEnum; +import com.engine.salary.enums.UserStatusEnum; +import com.engine.salary.enums.salaryarchive.*; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.process.salaryArchive.SalaryArchiveProcessQueryParam; +import com.engine.salary.service.*; +import com.engine.salary.service.impl.*; +import com.engine.salary.sys.service.SalarySysConfService; +import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.page.PageInfo; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import weaver.hrm.User; + +import java.util.*; +import java.util.stream.Collectors; + +import static com.engine.salary.sys.constant.SalarySysConstant.OPEN_SECONDARY_ACCOUNT; + +/** + * 薪资档案 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SalaryArchiveWrapper extends Service { + + private SalaryArchiveService getSalaryArchiveService(User user) { + return ServiceUtil.getService(SalaryArchiveServiceImpl.class, user); + } + + private SalaryArchiveItemService getSalaryArchiveItemService(User user) { + return ServiceUtil.getService(SalaryArchiveItemServiceImpl.class, user); + } + + + private TaxAgentService getTaxAgentService(User user) { + return ServiceUtil.getService(TaxAgentServiceImpl.class, user); + } + + private SalaryItemService getSalaryItemService(User user) { + return ServiceUtil.getService(SalaryItemServiceImpl.class, user); + } + + private SalaryArchiveExcelService getSalaryArchiveExcelService(User user) { + return ServiceUtil.getService(SalaryArchiveExcelServiceImpl.class, user); + } + + private SalaryEmployeeService getSalaryEmployeeService(User user) { + return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user); + } + + private SalarySysConfService getSalarySysConfService(User user) { + return ServiceUtil.getService(SalarySysConfServiceImpl.class, user); + } + + //主次账号是否开启 + boolean openSecondaryAccount = "1".equals(getSalarySysConfService(user).getValueByCode(OPEN_SECONDARY_ACCOUNT)); + + /** + * 薪资档案列表(分页) + * + * @param queryParam + * @return + */ + public Map list(SalaryArchiveQueryParam queryParam) { + //薪资档案列表 + PageInfo pageInfo = getSalaryArchiveService(user).listPage(queryParam); + Collection salaryArchives = pageInfo.getList(); + + //所有个税扣缴义务人 + Collection taxAgentLists = getTaxAgentService(user).listAll(); + + // 获取所有可被引用的薪资项目 + List salaryItems = getSalaryArchiveItemService(user).getCanAdjustSalaryItems(); + + //整合所有的显示列(固定列+薪资项目动态列) + List> listMaps = getSalaryArchiveService(user).buildSalaryArchiveData(salaryArchives, taxAgentLists, salaryItems, Boolean.TRUE); + + PageInfo> pageInfos = new PageInfo>(listMaps); + pageInfos.setTotal(pageInfo.getTotal()); + pageInfos.setPageNum(pageInfo.getPageNum()); + pageInfos.setPageSize(pageInfo.getPageSize()); + + + //动态列组装 + List columns = SalaryArchiveBO.buildSalaryArchiveTable(salaryItems, openSecondaryAccount); + + SalaryWeaTable table = new SalaryWeaTable(user, SalaryArchiveListDTO.class); + table.setColumns(columns); + + + WeaResultMsg result = new WeaResultMsg(false); + result.putAll(table.makeDataResult()); + result.success(); + + + Map datas = new HashMap<>(); + datas.put("pageInfo", pageInfos); + datas.put("dataKey", result.getResultMap()); + datas.put("salaryArchives", salaryArchives); + return datas; + } + + + /** + * 薪资档案列表(分页) + * + * @param queryParam + * @return + */ + public Map list(SalaryArchiveQueryParam queryParam, SalaryArchiveListTypeEnum listTypeEnum) { + //薪资档案列表 + PageInfo pageInfo = getSalaryArchiveService(user).listPage(queryParam); + Collection salaryArchives = pageInfo.getList(); + + //所有个税扣缴义务人 + Collection taxAgentLists = getTaxAgentService(user).listAll(); + + // 获取所有可被引用的薪资项目 + List salaryItems = getSalaryArchiveItemService(user).getCanAdjustSalaryItems(); + + //整合所有的显示列(固定列+薪资项目动态列) + List> listMaps = getSalaryArchiveService(user).buildSalaryArchiveData(salaryArchives, taxAgentLists, salaryItems, Boolean.TRUE); + + PageInfo> pageInfos = new PageInfo>(listMaps); + pageInfos.setTotal(pageInfo.getTotal()); + pageInfos.setPageNum(pageInfo.getPageNum()); + pageInfos.setPageSize(pageInfo.getPageSize()); + + + //动态列组装 + List columns = SalaryArchiveBO.buildSalaryArchiveTable(salaryItems, openSecondaryAccount); + + SalaryWeaTable table = new SalaryWeaTable(user, SalaryArchiveListDTO.class); + table.setColumns(columns); + + + WeaResultMsg result = new WeaResultMsg(false); + result.putAll(table.makeDataResult()); + result.success(); + + + Map datas = new HashMap<>(); + datas.put("pageInfo", pageInfos); + datas.put("dataKey", result.getResultMap()); + datas.put("salaryArchives", salaryArchives); + datas.put("listType", listTypeEnum.getValue()); + + //记录操作日志 + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetName(listTypeEnum.getDefaultLabel()); + loggerContext.setOperateType(OperateTypeEnum.READ.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "查看薪资档案列表")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "查看薪资档案列表")); + SalaryElogConfig.salaryArchiveLoggerTemplate.write(loggerContext); + return datas; + } + + + /** + * 获取各tab总人数 + * + * @return + */ + public Map queryTabTotal() { + return getSalaryArchiveService(user).queryTabTotal(); + } + + /** + * 待定薪列表 + * + * @param queryParam + * @return + */ + public Map listPage(SalaryArchiveQueryParam queryParam) { + return list(queryParam); + } + + + /** + * 待定薪列表 + * + * @param queryParam + * @return + */ + public Map pendingList(SalaryArchiveQueryParam queryParam) { + queryParam.setRunStatusList(Arrays.asList(SalaryArchiveStatusEnum.PENDING.getValue())); + return list(queryParam, SalaryArchiveListTypeEnum.PENDING); + } + + /** + * 删除待定薪待办 + * + * @param ids + * @return + */ + public String deletePendingTodo(Collection ids) { + return getSalaryArchiveService(user).deletePendingTodo(ids); + } + + /** + * 定薪列表 + * + * @param queryParam + * @return + */ + public Map fixedList(SalaryArchiveQueryParam queryParam) { + queryParam.setRunStatusList(Arrays.asList(SalaryArchiveStatusEnum.FIXED.getValue(), SalaryArchiveStatusEnum.SUSPEND.getValue())); + return list(queryParam, SalaryArchiveListTypeEnum.FIXED); + } + + /** + * 待停薪列表 + * + * @param queryParam + * @return + */ + public Map suspendList(SalaryArchiveQueryParam queryParam) { + queryParam.setRunStatusList(Arrays.asList(SalaryArchiveStatusEnum.SUSPEND.getValue())); + return list(queryParam, SalaryArchiveListTypeEnum.SUSPEND); + } + + /** + * 停薪列表 + * + * @param queryParam + * @return + */ + public Map stopList(SalaryArchiveQueryParam queryParam) { + queryParam.setRunStatusList(Arrays.asList(SalaryArchiveStatusEnum.STOP_FROM_PENDING.getValue(), SalaryArchiveStatusEnum.STOP_FROM_SUSPEND.getValue())); + return list(queryParam, SalaryArchiveListTypeEnum.STOP); + } + + /** + * 设为定薪员工 + * + * @param ids + * @return + */ + public Map gotoFixed(Collection ids) { + return getSalaryArchiveService(user).gotoFixed(ids); + } + + /** + * 一键全部定薪 + * + * @param queryParam + * @return + */ + public Map allGotoFixed(SalaryArchiveQueryParam queryParam) { + return getSalaryArchiveService(user).allGotoFixed(queryParam); + } + + + /** + * 停薪 + * + * @param ids + * @return + */ + public Map gotoStop(Collection ids) { + return getSalaryArchiveService(user).gotoStop(ids); + } + + /** + * 一键全部停薪 + * + * @param queryParam + * @return + */ + public Map allGotoStop(SalaryArchiveQueryParam queryParam) { + return getSalaryArchiveService(user).allGotoStop(queryParam); + } + + /** + * 删除待停薪待办 + * + * @param ids + * @return + */ + public String deleteSuspendTodo(Collection ids) { + return getSalaryArchiveService(user).deleteSuspendTodo(ids); + } + + /** + * 取消停薪 + * + * @param ids + * @return + */ + public String cancelStop(Collection ids) { + return getSalaryArchiveService(user).cancelStop(ids); + } + + + /** + * 外部人员 + * + * @param queryParam + * @return + */ + public Map extList(SalaryArchiveQueryParam queryParam) { + queryParam.setRunStatusList(Arrays.asList(SalaryArchiveStatusEnum.FIXED.getValue())); + queryParam.setExtSalaryArchiveList(true); + return list(queryParam, SalaryArchiveListTypeEnum.EXT); + } + + + /** + * 获取薪资档案详情表单 + * + * @param salaryArchiveId + * @return + */ + public SalaryArchiveFormDTO getFrom(Long salaryArchiveId) { + if (salaryArchiveId == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100425, "薪资档案id不能为空")); + } + SalaryArchivePO po = getSalaryArchiveService(user).getById(salaryArchiveId); + if (po == null) { + throw new SalaryRunTimeException(String.format(SalaryI18nUtil.getI18nLabel(100463, "薪资档案不存在") + "[id:%s]", salaryArchiveId)); + } + + List employeeList = getSalaryEmployeeService(user).getEmployeeByIdsAll(Collections.singletonList(po.getEmployeeId())); + if (CollectionUtils.isEmpty(employeeList)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100465, "薪资档案员工信息不存在")); + } + + Long taxAgentId = po.getTaxAgentId(); + TaxAgentPO taxAgent = getTaxAgentService(user).getById(taxAgentId); + + // 1.基本信息表单 + Map baseInfo = new HashMap<>(); + DataCollectionEmployee employee = employeeList.get(0); + SalaryArchiveBaseInfoFormDTO build = SalaryArchiveBaseInfoFormDTO.builder() + .username(employee.getUsername()) + .department(employee.getDepartmentName()) + .position(employee.getJobtitleName() == null ? "" : employee.getJobtitleName()) + .hiredate(employee.getCompanystartdate()) + .mobile(employee.getMobile()) + .taxAgent(taxAgent.getName()) + .build(); + baseInfo.put("employee", build); + + List> salaryItems = Lists.newArrayList(); + + // 2.发薪设置表单 + Map paySetForm = new HashMap<>(); + paySetForm.put("data", po); + + + // 获取所有可被引用的薪资项目 + List salaryItemList = getSalaryArchiveItemService(user).getCanAdjustSalaryItems() + .stream().filter(item -> getSalaryItemService(user).filterInRange(Collections.singleton(taxAgentId), item)) + .collect(Collectors.toList()); + Collection salaryItemIds = salaryItemList.stream().map(SalaryItemPO::getId).collect(Collectors.toList()); + List salaryArchiveItemList = getSalaryArchiveService(user).getCurrentEffectiveItemList(Collections.singletonList(salaryArchiveId), salaryItemIds); + salaryItemList.forEach(s -> { + Optional optionalItem = salaryArchiveItemList.stream().filter(f -> f.getSalaryItemId().equals(s.getId())).findFirst(); + Map salaryItemMap = new LinkedHashMap<>(); + salaryItemMap.put("id", s.getId()); + salaryItemMap.put("name", s.getName()); + salaryItemMap.put("value", optionalItem.isPresent() ? optionalItem.get().getItemValue() : ""); + salaryItemMap.put("dataType", s.getDataType()); + salaryItemMap.put("pattern", s.getPattern()); + salaryItems.add(salaryItemMap); + }); + + return SalaryArchiveFormDTO.builder() + .id(salaryArchiveId) + .employeeId(employee.getEmployeeId()) + .baseInfo(baseInfo) + .paySet(paySetForm) + .adjustSalaryItems(salaryItems) + .build(); + } + + + /** + * 保存发薪设置 + * + * @param saveParam + * @return + */ + public String savePaySet(SalaryArchiveSetPaySaveParam saveParam) { + return getSalaryArchiveService(user).savePaySet(saveParam); + } + + /** + * 获取离职时段设置表单 + * + * @return + */ + public Map getDimissionSetForm() { + List dimissionSets = getSalaryArchiveService(user).dimissionSets(); + Map data = new LinkedHashMap<>(); + if (CollectionUtils.isNotEmpty(dimissionSets)) { + data.put("dimissionTimeInterval", dimissionSets.get(0).getDimissionTimeInterval()); + } + return data; + } + + /** + * 保存离职时段设置 + * + * @param saveParam + * @return + */ + public String saveDimissionSet(SalaryArchiveDimissionSaveParam saveParam) { + return getSalaryArchiveService(user).saveDimissionSet(saveParam); + } + + public List> getImportTypes() { + List> importTypes = Arrays.stream(SalaryArchiveImportTypeEnum.values()).map(m -> { + Map map = new HashMap<>(2); + map.put("id", String.valueOf(m.getValue())); + map.put("content", SalaryI18nUtil.getI18nLabel(m.getLabelId(), m.getDefaultLabel())); + return map; + }).collect(Collectors.toList()); + return importTypes; + } + + + /** + * 下载导入模板 + * + * @param queryParam + * @return + */ + public XSSFWorkbook downloadTemplate(SalaryArchiveQueryParam queryParam) { + if (!queryParam.isExtSalaryArchiveList()) { + if (queryParam.getListType() == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(109712, "列表类型必传")); + } else { + // 定薪列表导入有调薪导入和初始化导入 + if (queryParam.getListType().equals(SalaryArchiveListTypeEnum.FIXED)) { + Optional optional = Arrays.stream(SalaryArchiveImportTypeEnum.values()) + .filter(e -> StringUtils.isNotEmpty(queryParam.getImportType()) && e.getValue().equals(queryParam.getImportType())).findFirst(); + if (!optional.isPresent()) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100593, "导入类型不正确")); + } + } + } + } + return getSalaryArchiveExcelService(user).downloadTemplate(queryParam); + } + + /** + * 预览 + * + * @param param + * @return + */ + public Map preview(SalaryArchiveImportHandleParam param) { + return getSalaryArchiveService(user).preview(param); + } + + /** + * 导入档案 + * + * @param param + * @return + */ + public Map importSalaryArchive(SalaryArchiveImportHandleParam param) { + return getSalaryArchiveExcelService(user).batchImportEbatch(param); + } + + /** + * 导出列表 + * + * @param queryParam + * @return + */ + public XSSFWorkbook exportList(SalaryArchiveQueryParam queryParam) { + return getSalaryArchiveService(user).exportList(queryParam); + } + + + /** + * 检查导入文件 + * + * @param param + * @return + */ + public Map checkImportSalaryArchiveParam(SalaryArchiveImportHandleParam param) { + param.setOnlyCheck(true); + return getSalaryArchiveExcelService(user).batchImportEbatch(param); + } + + /** + * 人员状态列表 + * + * @return + */ + public Map searchCondition() { + List> userStatus = UserStatusEnum.getList(); + List> itemAdjustReasons = SalaryArchiveItemAdjustReasonEnum.getList(); + List> TaxAgentAdjustReason = SalaryArchiveTaxAgentAdjustReasonEnum.getList(); + Collection taxAgentList = getTaxAgentService(user).findAll(); + HashMap map = Maps.newHashMap(); + map.put("userStatus", userStatus); + map.put("itemAdjustReasons", itemAdjustReasons); + map.put("TaxAgentAdjustReason", TaxAgentAdjustReason); + map.put("taxAgentList", taxAgentList); + return map; + } + + public Map selectSalaryArchiveColumns(String importType) { + return getSalaryArchiveService(user).selectSalaryArchiveColumns(SalaryArchiveImportTypeEnum.parseByValue(importType)); + } + + + public Map checkSalaryArchiveInit(SalaryArchiveImportActionParam importData) { + importData.setImportType("init"); + importData.setListType("FIXED"); + importData.setAddData(false); + return getSalaryArchiveExcelService(user).processInit(importData); + } + + public Map importSalaryArchiveInit(SalaryArchiveImportActionParam importData) { + importData.setImportType("init"); + importData.setListType("FIXED"); + importData.setAddData(true); + return getSalaryArchiveExcelService(user).processInit(importData); + } + + public Map checkAdjustmentSalaryArchive(SalaryArchiveImportActionParam importData) { + importData.setImportType("salaryItemAdjust"); + importData.setListType("FIXED"); + importData.setAddData(false); + return getSalaryArchiveExcelService(user).processInit(importData); + } + + public Map adjustmentSalaryArchive(SalaryArchiveImportActionParam importData) { + importData.setImportType("salaryItemAdjust"); + importData.setListType("FIXED"); + importData.setAddData(true); + return getSalaryArchiveExcelService(user).processInit(importData); + } + + /** + * 停薪 + * + * @param stopSalaryParam + * @return + */ + public void stopSalary(SalaryArchiveStopParam stopSalaryParam) { + getSalaryArchiveService(user).stopSalary(stopSalaryParam); + } + + + public Map handleRepeatData() { + return getSalaryArchiveService(user).handleRepeatData(); + } + + @Deprecated + public SalaryArchivePO getSalaryArchiveInfo(SalaryArchiveProcessQueryParam param) { + if (param.getEmployeeId() == null) { + throw new SalaryRunTimeException("人员id为空!"); + } + SalaryArchivePO po = SalaryArchivePO.builder().employeeId(param.getEmployeeId()).build(); + if (param.getTaxAgentId() != null) { + po.setTaxAgentId(param.getTaxAgentId()); + } + if (CollectionUtils.isNotEmpty(param.getRunStatusList())) { + po.setRunStatusList(param.getRunStatusList()); + } + + List list = getSalaryArchiveService(user).listSome(po); + if (CollectionUtils.isEmpty(list)) { + throw new SalaryRunTimeException("薪资档案不存在!"); + } + if (list.size() > 1) { + throw new SalaryRunTimeException("存在多个薪资档案!"); + } + return list.get(0); + } + + public List getSalaryArchiveInfoV2(SalaryArchiveProcessQueryParam param) { + if (param.getEmployeeId() == null) { + throw new SalaryRunTimeException("人员id为空!"); + } + SalaryArchivePO po = SalaryArchivePO.builder().employeeId(param.getEmployeeId()).build(); + if (param.getTaxAgentId() != null) { + po.setTaxAgentId(param.getTaxAgentId()); + } + if (CollectionUtils.isNotEmpty(param.getRunStatusList())) { + po.setRunStatusList(param.getRunStatusList()); + } + + List list = getSalaryArchiveService(user).listSome(po); + if (CollectionUtils.isEmpty(list)) { + throw new SalaryRunTimeException("薪资档案不存在!"); + } + + return list.stream().map(a -> getFrom(a.getId())).collect(Collectors.toList()); + } + + + /** + * 删除薪资档案 + * + * @param salaryArchiveIds + */ + public void deleteSalaryArchive(Collection salaryArchiveIds) { + getSalaryArchiveService(user).deleteSalaryArchive(salaryArchiveIds); + } + + /** + * 同步所有档案起始发薪日期变为入职日期 + * + * @return + */ + public String syncPayStartDate() { + return getSalaryArchiveService(user).syncPayStartDate(); + } +} diff --git a/src/com/engine/salary/wrapper/SalaryBillBaseSetWrapper.java b/src/com/engine/salary/wrapper/SalaryBillBaseSetWrapper.java new file mode 100644 index 000000000..505c19e0a --- /dev/null +++ b/src/com/engine/salary/wrapper/SalaryBillBaseSetWrapper.java @@ -0,0 +1,91 @@ +package com.engine.salary.wrapper; + +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.entity.salaryBill.dto.SalaryBaseSetFormDTO; +import com.engine.salary.entity.salaryBill.dto.SalaryBillAckFeedbackDTO; +import com.engine.salary.entity.salaryBill.dto.salaryBillViewingLimitSetting; +import com.engine.salary.entity.salaryBill.dto.SalaryBillWatermarkDTO; +import com.engine.salary.entity.salaryBill.param.SalaryBaseSetSaveParam; +import com.engine.salary.service.SalaryBillBaseSetService; +import com.engine.salary.service.impl.SalaryBillBaseSetServiceImpl; +import com.google.common.collect.Maps; +import weaver.hrm.User; + +import java.util.Map; +import java.util.Objects; + +/** + * @Description: 工资单水印 + * @Author: wangxiangzhong + * @Date: 2023/5/16 10:17 + */ + +public class SalaryBillBaseSetWrapper extends Service { + + private SalaryBillBaseSetService getSalaryBillBaseSetService(User user) { + return ServiceUtil.getService(SalaryBillBaseSetServiceImpl.class, user); + } + + + /** + * 是否具备工资单水印权限 + * + * @param currentEmployeeId + * @param currentTenantKey + * @return + */ +// public Boolean isBaseSetHasRight(Long currentEmployeeId, String currentTenantKey) { +// return taxAgentService.isHasPermission(SalaryBillWatermarkBO.PERMISSION_SET_CODE, currentEmployeeId, currentTenantKey); +// } + + /** + * 获取工资单水印设置表单 + * + * @return + */ + public SalaryBaseSetFormDTO getBaseSetForm() { + SalaryBaseSetFormDTO dto = new SalaryBaseSetFormDTO(); + SalaryBillWatermarkDTO salaryBillWatermark = getSalaryBillBaseSetService(user).getWatermarkSetting(); + SalaryBillAckFeedbackDTO salaryBillAckFeedback = getSalaryBillBaseSetService(user).getDefaultAckFeedbackSetting(); + salaryBillViewingLimitSetting salaryBillViewingLimitSetting = getSalaryBillBaseSetService(user).getSalaryBillViewingLimitSetting(); + Integer burningAfterReadingMin = getSalaryBillBaseSetService(user).getBurningAfterReadingMin(); + salaryBillViewingLimitSetting.setBurningAfterReadingMin(burningAfterReadingMin); + + if (Objects.isNull(salaryBillWatermark)) { + dto.setWatermarkStatus(false); + Map wmSetting = Maps.newHashMap(); + wmSetting.put("wmClassify", "text"); + dto.setWatermarkSetting(wmSetting); + } else { + dto.setWatermarkStatus(salaryBillWatermark.getWatermarkStatus()); + dto.setWatermarkSetting(salaryBillWatermark.getWmSetting()); + dto.setWatermark(salaryBillWatermark.getWatermarkType()); + } + if (Objects.nonNull(salaryBillAckFeedback)) { + // 工资单反馈默认设置 + dto.setAckFeedbackSetting(salaryBillAckFeedback); + } + dto.setSalaryBillViewingLimitSetting(salaryBillViewingLimitSetting); + + return dto; + } + + /** + * 保存工资单模板基础设置 + * + * @param saveParam + * @return + */ + public String saveBaseSet(SalaryBaseSetSaveParam saveParam) { + return getSalaryBillBaseSetService(user).saveBaseSet(saveParam); + } + + /** + * 获取水印预览内容 + * @param salaryBaseSetSaveParam + */ + public String previewWaterMark(SalaryBaseSetSaveParam salaryBaseSetSaveParam) { + return getSalaryBillBaseSetService(user).previewWaterMark(salaryBaseSetSaveParam.getWmSetting()); + } +} diff --git a/src/com/engine/salary/wrapper/SalaryCommonWrapper.java b/src/com/engine/salary/wrapper/SalaryCommonWrapper.java new file mode 100644 index 000000000..c91ac8913 --- /dev/null +++ b/src/com/engine/salary/wrapper/SalaryCommonWrapper.java @@ -0,0 +1,81 @@ +package com.engine.salary.wrapper; + +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.entity.setting.dto.PageListTemplateDTO; +import com.engine.salary.entity.setting.dto.PageListTemplateDetailDTO; +import com.engine.salary.entity.setting.param.*; +import com.engine.salary.entity.setting.po.PageListTemplatePO; +import com.engine.salary.service.SalaryCacheService; +import com.engine.salary.service.SettingService; +import com.engine.salary.service.impl.SalaryCacheServiceImpl; +import com.engine.salary.service.impl.SettingServiceImpl; +import com.engine.salary.util.page.PageInfo; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import weaver.hrm.User; + +import java.util.List; + + +public class SalaryCommonWrapper extends Service { + + private SalaryCacheService getSalaryCacheService(User user) { + return ServiceUtil.getService(SalaryCacheServiceImpl.class, user); + } + + private SettingService getSettingService(User user) { + return ServiceUtil.getService(SettingServiceImpl.class, user); + } + + public Object getCacheInfo(String key) { + return getSalaryCacheService(user).get(key); + } + + public void removeCache(String key) { + getSalaryCacheService(user).remove(key); + } + + public void savePageListSetting(PageListSettingSaveParam param) { + getSettingService(user).savePageListSetting(param); + } + + public void resetPageListSetting(PageListSettingResetParam param) { + getSettingService(user).resetPageListSetting(param); + } + + + public PageListTemplateDetailDTO getPageListSetting(PageListSettingQueryParam param) { + return getSettingService(user).getDefaultPageListSetting(param); + } + + + public PageListTemplateDetailDTO getPageListTemplate(PageListTemplateQueryParam param) { + return getSettingService(user).getPageListTemplate(param); + } + + public List getPageListTemplates(PageListTemplateQueryParam param) { + return getSettingService(user).getPageListTemplates(param); + } + + public PageInfo getTemplates(PageListTemplateQueryParam param) { + return getSettingService(user).getTemplates(param); + } + + public PageListTemplatePO savePageListTemplate(PageListTemplateSaveParam param) { + return getSettingService(user).savePageListTemplate(param); + } + + public XSSFWorkbook downloadPageExportTemplateFile(DownloadTemplateParam param) { + return getSettingService(user).downloadPageExportTemplateFile(param); + } + + public void deletePageListTemplate(PageListTemplateDeleteParam param) { + getSettingService(user).deletePageListTemplate(param); + } + + public void changePageListTemplate(PageListTemplateChangeParam param) { + getSettingService(user).changePageListTemplate(param); + } + + +} diff --git a/src/com/engine/salary/wrapper/SalaryComparisonResultWrapper.java b/src/com/engine/salary/wrapper/SalaryComparisonResultWrapper.java new file mode 100644 index 000000000..7ae995090 --- /dev/null +++ b/src/com/engine/salary/wrapper/SalaryComparisonResultWrapper.java @@ -0,0 +1,83 @@ +package com.engine.salary.wrapper; + +import com.api.formmode.mybatis.util.SqlProxyHandle; +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.component.WeaTableColumnGroup; +import com.engine.salary.entity.salaryacct.dto.SalaryComparisonResultListDTO; +import com.engine.salary.entity.salaryacct.param.SalaryComparisonResultQueryParam; +import com.engine.salary.mapper.sys.SalarySysConfMapper; +import com.engine.salary.service.SalaryAcctRecordService; +import com.engine.salary.service.SalaryComparisonResultService; +import com.engine.salary.service.SalarySobEmpFieldService; +import com.engine.salary.service.SalarySobItemService; +import com.engine.salary.service.impl.SalaryComparisonResultServiceImpl; +import com.engine.salary.sys.entity.po.SalarySysConfPO; +import com.engine.salary.util.page.PageInfo; + +import org.apache.commons.lang3.math.NumberUtils; +import weaver.hrm.User; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static com.engine.salary.sys.constant.SalarySysConstant.SALARY_ACCT_FIXED_COLUMNS; + +/** + * 薪资核算线下对比结果 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SalaryComparisonResultWrapper extends Service { + + + private SalaryComparisonResultService getSalaryComparisonResultService(User user) { + return (SalaryComparisonResultService) ServiceUtil.getService(SalaryComparisonResultServiceImpl.class, user); + } + + private SalarySysConfMapper getSalarySysConfMapper() { + return SqlProxyHandle.getProxy(SalarySysConfMapper.class); + } + + private SalaryAcctRecordService salaryAcctRecordService; + + private SalarySobEmpFieldService salarySobEmpFieldService; + + private SalarySobItemService salarySobItemService; + + /** + * 薪资核算线下对比列表 + * + * @param queryParam 列表查询条件 + * @return + */ + public Map listPage(SalaryComparisonResultQueryParam queryParam) { + // 查询薪资核算线下对比列表(不包含隐藏薪资项目) + SalaryComparisonResultListDTO salaryComparisonResultListDTO = getSalaryComparisonResultService(user).listPageByParam(queryParam); + + PageInfo> pageInfo = salaryComparisonResultListDTO.getData(); + + List weaTableColumns = salaryComparisonResultListDTO.getWeaTableColumns(); + // 获取固定列头数 + SalarySysConfPO salaryAcctFixedColumns = getSalarySysConfMapper().getOneByCode(SALARY_ACCT_FIXED_COLUMNS); + if (salaryAcctFixedColumns != null) { + int fixedNum = NumberUtils.isCreatable(salaryAcctFixedColumns.getConfValue()) ? Integer.valueOf(salaryAcctFixedColumns.getConfValue()) : 3; + if (fixedNum == 0) { + fixedNum = 3; + } + for (int i = 0; i < fixedNum && i < weaTableColumns.size(); i++) { + weaTableColumns.get(i).setFixed("left"); + } + } + + Map datas = new HashMap<>(); + datas.put("pageInfo", pageInfo); + datas.put("columns", weaTableColumns); + + return datas; + } +} diff --git a/src/com/engine/salary/wrapper/SalaryFieldWrapper.java b/src/com/engine/salary/wrapper/SalaryFieldWrapper.java new file mode 100644 index 000000000..462b015d3 --- /dev/null +++ b/src/com/engine/salary/wrapper/SalaryFieldWrapper.java @@ -0,0 +1,250 @@ +package com.engine.salary.wrapper; + +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.config.SalaryElogConfig; +import com.engine.hrmelog.entity.dto.LoggerContext; +import com.engine.salary.entity.salaryformula.ExpressFormula; +import com.engine.salary.entity.salaryitem.bo.SalaryItemBO; +import com.engine.salary.entity.salaryitem.dto.SalaryFieldListDTO; +import com.engine.salary.entity.salaryitem.dto.SalaryItemFormDTO; +import com.engine.salary.entity.salaryitem.dto.SalaryItemListDTO; +import com.engine.salary.entity.salaryitem.param.SalaryItemSaveParam; +import com.engine.salary.entity.salaryitem.param.SalaryItemSearchParam; +import com.engine.salary.entity.salaryitem.po.SalaryItemPO; +import com.engine.salary.entity.salaryitem.po.SysSalaryItemPO; +import com.engine.salary.enums.*; +import com.engine.salary.enums.salaryitem.SalaryDataTypeEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.service.SalaryFormulaService; +import com.engine.salary.service.SalaryItemService; +import com.engine.salary.service.SalarySobItemService; +import com.engine.salary.service.SysSalaryItemService; +import com.engine.salary.service.impl.SalaryFormulaServiceImpl; +import com.engine.salary.service.impl.SalaryItemServiceImpl; +import com.engine.salary.service.impl.SalarySobItemServiceImpl; +import com.engine.salary.service.impl.SysSalaryItemServiceImpl; +import com.engine.salary.sys.enums.TaxDeclarationFunctionEnum; +import com.engine.salary.sys.service.SalarySysConfService; +import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.page.Column; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.util.valid.RuntimeTypeEnum; +import com.engine.salary.util.valid.ValidUtil; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang.math.NumberUtils; +import org.apache.commons.lang3.StringUtils; +import weaver.hrm.User; + +import java.util.*; + +/** + * 字段管理 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SalaryFieldWrapper extends Service { + + private SalaryItemService getSalaryItemService(User user) { + return ServiceUtil.getService(SalaryItemServiceImpl.class, user); + } + + private SalaryFormulaService getSalaryFormulaService(User user) { + return ServiceUtil.getService(SalaryFormulaServiceImpl.class, user); + } + + + private SalarySobItemService getSalarySobItemService(User user) { + return ServiceUtil.getService(SalarySobItemServiceImpl.class, user); + } + + private SalaryItemWrapper getSalaryItemWrapper(User user) { + return ServiceUtil.getService(SalaryItemWrapper.class, user); + } + + private SysSalaryItemService getSysSalaryItemService(User user) { + return ServiceUtil.getService(SysSalaryItemServiceImpl.class, user); + } + + private SalarySysConfService getSalarySysConfService(User user) { + return ServiceUtil.getService(SalarySysConfServiceImpl.class, user); + } + + /** + * 薪资项目列表 + * + * @param searchParam 查询参数 + * @return + */ + public PageInfo listPage(SalaryItemSearchParam searchParam) { + + SalaryItemServiceImpl.UsingItem usingItem = getSalaryItemService(user).getUsingItem(); + List usingFormulaIds = usingItem.getUsingFormulaIds(); + List usingItemIds = usingItem.getUsingItemIds(); + List usingCodes = usingItem.getUsingCodes(); + + // 1、查询薪资项目 + //设置查询档案引用项目 + searchParam.setUseInEmployeeSalary(SalaryOnOffEnum.ON.getValue()); + + PageInfo page = getSalaryItemService(user).listPageByParam(searchParam); + List salaryItemList = page.getList(); + + //最终返回的分页对象 + PageInfo salaryItemListDTOPage = new PageInfo<>(SalaryItemListDTO.class); + salaryItemListDTOPage.setPageSize(page.getPageSize()); + salaryItemListDTOPage.setPageNum(page.getPageNum()); + salaryItemListDTOPage.setTotal(page.getTotal()); + //获取字段管理的字段列表 + PageInfo fieldColumnsPage = new PageInfo<>(SalaryFieldListDTO.class); + List fieldColumns = fieldColumnsPage.getColumns(); + salaryItemListDTOPage.getColumns().clear(); + salaryItemListDTOPage.setColumns(fieldColumns); + + //是否需要系统算税,不需要则去除系统项目 + TaxDeclarationFunctionEnum taxDeclarationFunctionEnum = getSalarySysConfService(user).getTaxDeclaration(); + + // 被薪资账套引用的薪资项目 + if (CollectionUtils.isNotEmpty(salaryItemList)) { + // 查询系统薪资项目 + Set sysSalaryItemIds = SalaryEntityUtil.properties(salaryItemList, SalaryItemPO::getSysSalaryItemId); + List sysSalaryItemPOS = getSysSalaryItemService(user).listByIds(sysSalaryItemIds); + // 转换成薪资项目列表dto + List salaryItemListDTOS = SalaryItemBO.convert2ListDTO(salaryItemList, Collections.emptyList(), sysSalaryItemPOS); + //系统项目不删除 + salaryItemListDTOS.forEach(dto -> { + if ((taxDeclarationFunctionEnum != TaxDeclarationFunctionEnum.CLOSURE && StringUtils.isNotBlank(dto.getSystemName())) + || usingItemIds.contains(dto.getId()) + || usingCodes.contains(dto.getCode())) { + dto.setCanDelete(false); + } + }); + salaryItemListDTOPage.setList(salaryItemListDTOS); + } + return salaryItemListDTOPage; + + } + + /** + * 薪资项目详情 + * + * @param id 主键id + * @return + */ + public SalaryItemFormDTO getForm(Long id) { + SalaryItemFormDTO salaryItemFormDTO = new SalaryItemFormDTO(); + // 默认可以编辑 + salaryItemFormDTO.setCanEdit(NumberUtils.INTEGER_ONE); + if (!Objects.isNull(id)) { + // 查询薪资项目 + SalaryItemPO salaryItemPO = getSalaryItemService(user).getById(id); + // 系统薪资项目 + if (Objects.isNull(salaryItemPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98299, "参数错误,薪资项目不存在或已被删除")); + } + ExpressFormula expressFormula; +// // 转换成薪资项目详情dto + + salaryItemFormDTO = SalaryItemBO.convert2FormDTO(salaryItemPO); + expressFormula = getSalaryFormulaService(user).getExpressFormula(salaryItemPO.getFormulaId()); + salaryItemFormDTO.setFormulaContent(Optional.ofNullable(expressFormula).map(ExpressFormula::getFormula).orElse("")); + } + return salaryItemFormDTO; + } + + /** + * 保存薪资项目 + * + * @param saveParam 保存参数 + */ + public void save(SalaryItemSaveParam saveParam) { + saveParam.setValueType(SalaryValueTypeEnum.INPUT.getValue()); + if (null == saveParam.getUseInEmployeeSalary()) { + saveParam.setUseInEmployeeSalary(NumberUtils.INTEGER_ONE); + } + saveParam.setSystemType(SalarySystemTypeEnum.CUSTOM.getValue()); + + ValidUtil.doValidator(saveParam); + validParam(saveParam); + + SalaryItemPO salaryItemPO = getSalaryItemService(user).save(saveParam); + // 记录日志 + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(salaryItemPO.getId())); + loggerContext.setTargetName(salaryItemPO.getName()); + loggerContext.setOperateType(OperateTypeEnum.ADD.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "新建字段")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "新建字段") + ": " + salaryItemPO.getName()); + loggerContext.setNewValues(salaryItemPO); + SalaryElogConfig.salaryArchiveFieldLoggerTemplate.write(loggerContext); + } + + private void validParam(SalaryItemSaveParam saveParam) { + if (SalarySystemTypeEnum.parseByValue(saveParam.getSystemType()) == null) { + throw new SalaryRunTimeException("系统内置的薪资项目异常"); + } + if (SalaryRoundingModeEnum.parseByValue(saveParam.getRoundingMode()) == null) { + throw new SalaryRunTimeException("舍入规则异常"); + } + if (SalaryValueTypeEnum.parseByValue(saveParam.getValueType()) == null) { + throw new SalaryRunTimeException("取值方式异常"); + } + if (SalaryDataTypeEnum.parseByValue(saveParam.getDataType()) == null) { + throw new SalaryRunTimeException("字段类型异常"); + } + } + + /** + * 编辑薪资项目 + * + * @param saveParam 更新参数 + */ + public void update(SalaryItemSaveParam saveParam) { + saveParam.setValueType(SalaryValueTypeEnum.INPUT.getValue()); + if (null == saveParam.getUseInEmployeeSalary()) { + saveParam.setUseInEmployeeSalary(NumberUtils.INTEGER_ONE); + } + saveParam.setSystemType(SalarySystemTypeEnum.CUSTOM.getValue()); + + ValidUtil.doValidator(saveParam, RuntimeTypeEnum.UPDATE); + validParam(saveParam); + SalaryItemPO salaryItemPO = getSalaryItemService(user).update(saveParam); + + // 记录日志 + SalaryItemPO newSalaryItemPO = getSalaryItemService(user).getById(salaryItemPO.getId()); + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(newSalaryItemPO.getId())); + loggerContext.setTargetName(newSalaryItemPO.getName()); + loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "编辑字段")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "编辑字段") + ": " + newSalaryItemPO.getName()); + loggerContext.setOldValues(salaryItemPO); + loggerContext.setNewValues(newSalaryItemPO); + SalaryElogConfig.salaryArchiveFieldLoggerTemplate.write(loggerContext); + } + + /** + * 删除薪资项目 + * + * @param ids 主键id + */ + public void delete(Collection ids) { + getSalaryItemService(user).deleteByIds(ids); + } + + /** + * 保存字段排序信息 + * + * @param salaryItemPOS + */ + public void saveSortedIndex(List salaryItemPOS) { + getSalaryItemService(user).batchUpdateSortedIndex(salaryItemPOS); + } +} diff --git a/src/com/engine/salary/wrapper/SalaryFormulaWrapper.java b/src/com/engine/salary/wrapper/SalaryFormulaWrapper.java new file mode 100644 index 000000000..1c62d921c --- /dev/null +++ b/src/com/engine/salary/wrapper/SalaryFormulaWrapper.java @@ -0,0 +1,175 @@ +package com.engine.salary.wrapper; + +import com.cloudstore.dev.api.util.Util_DataCache; +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.biz.SalaryItemBiz; +import com.engine.salary.constant.SalaryItemConstant; +import com.engine.salary.entity.salaryformula.ExpressFormula; +import com.engine.salary.entity.salaryformula.bo.SalaryFormulaBO; +import com.engine.salary.entity.salaryformula.dto.ExpressFormulaDTO; +import com.engine.salary.entity.salaryformula.param.SalaryFormulaDetailQueryParam; +import com.engine.salary.entity.salaryformula.param.SalaryFormulaFieldQueryParam; +import com.engine.salary.entity.salaryformula.param.SalaryFormulaMockParam; +import com.engine.salary.entity.salaryformula.param.SalaryFormulaSaveParam; +import com.engine.salary.entity.salaryformula.po.FormulaPO; +import com.engine.salary.entity.salaryformula.po.FormulaVar; +import com.engine.salary.entity.siaccount.dto.InsuranceAcctDetailImportFieldDTO; +import com.engine.salary.entity.sicategory.po.ICategoryPO; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.mapper.sicategory.ICategoryMapper; +import com.engine.salary.service.FormulaRunService; +import com.engine.salary.service.RemoteExcelService; +import com.engine.salary.service.SalaryFormulaService; +import com.engine.salary.service.impl.FormulaRunServiceImpl; +import com.engine.salary.service.impl.RemoteExcelServiceImpl; +import com.engine.salary.service.impl.SalaryFormulaServiceImpl; +import com.engine.salary.util.JsonUtil; +import com.engine.salary.util.db.MapperProxyFactory; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import weaver.hrm.User; +import weaver.servicefiles.DataSourceXML; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * 薪资项目 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Slf4j +public class SalaryFormulaWrapper extends Service { + + private RemoteExcelService getRemoteExcelService(User user) { + return ServiceUtil.getService(RemoteExcelServiceImpl.class, user); + } + + private SalaryFormulaService getSalaryFormulaService(User user) { + return ServiceUtil.getService(SalaryFormulaServiceImpl.class, user); + } + + private FormulaRunService getFormulaRunService(User user) { + return ServiceUtil.getService(FormulaRunServiceImpl.class, user); + } + + private SalaryItemBiz salaryItemBiz = new SalaryItemBiz(); + + private ICategoryMapper getICategoryMapper() { + return MapperProxyFactory.getProxy(ICategoryMapper.class); + } + + /** + * 公式字段列表 + * + * @param param 查询参数 + * @return + */ + public List fieldList(SalaryFormulaFieldQueryParam param) { + return getRemoteExcelService(user).fieldList(param.getSourceId(), param.getExtendParam()); + } + + + /** + * 公式字段分类 + * + * @param param 查询参数 + * @return + */ + public List> fieldGroupList(Map param) { + return getRemoteExcelService(user).fieldGroupList(param); + } + + public ExpressFormulaDTO detail(SalaryFormulaDetailQueryParam queryParam) { + List expressFormulas = getSalaryFormulaService(user).listExpressFormula(Collections.singleton(queryParam.getFormulaId())); + if (CollectionUtils.isEmpty(expressFormulas)) { + throw new SalaryRunTimeException("获取公式详情失败"); + } + Map returnTypeMap = new HashMap<>(); + returnTypeMap.put(queryParam.getFormulaId(),queryParam.getReturnType()); + return SalaryFormulaBO.convert2DTO(expressFormulas, returnTypeMap).get(0); + } + + public FormulaPO save(SalaryFormulaSaveParam salaryFormulaSaveParam) { + return getSalaryFormulaService(user).save(salaryFormulaSaveParam); + } + + public ArrayList datasourceList() { + DataSourceXML dataSourceXML = new DataSourceXML(); + ArrayList pointArrayList = dataSourceXML.getPointArrayList(); + return pointArrayList; + } + + /** + * 获取薪资项目中福利类项目 + */ + public List welfareList() { + + List welfareList = new ArrayList<>(); + SalaryFormulaFieldQueryParam param = new SalaryFormulaFieldQueryParam(); + param.setSourceId("welfare"); + //获取福利类薪资项目 + List list = getRemoteExcelService(user).fieldList(param.getSourceId(), param.getExtendParam()); + list = list.stream().filter(f -> !(f.getName().contains("正常缴纳") || f.getName().contains("补缴") || f.getName().contains("补差") || f.getName().contains("申报基数"))).collect(Collectors.toList()); + //提取出福利类项目名称 + for (FormulaVar formulaVar : list) { + InsuranceAcctDetailImportFieldDTO insuranceAcctDetailImportFieldDTO = new InsuranceAcctDetailImportFieldDTO(); + insuranceAcctDetailImportFieldDTO.setFieldId(formulaVar.getFieldId().contains("welfare_") ? formulaVar.getFieldId().substring(8) : formulaVar.getFieldId()); + insuranceAcctDetailImportFieldDTO.setSalaryItemName(formulaVar.getName()); + welfareList.add(insuranceAcctDetailImportFieldDTO); + + } + + welfareList.add(new InsuranceAcctDetailImportFieldDTO("socialSum","社保合计", false)); + welfareList.add(new InsuranceAcctDetailImportFieldDTO("fundSum","公积金合计",false)); + welfareList.add(new InsuranceAcctDetailImportFieldDTO("otherSum","其他福利合计", false)); + welfareList.add(new InsuranceAcctDetailImportFieldDTO("total","合计", false)); + + // 缓存勾选 + String cacheKey = user.getUID() + SalaryItemConstant.SI_ACCOUNT_IMPORT_FIELD_SIGN; + String cacheValue = (String) Util_DataCache.getObjVal(cacheKey); + List checkFields = JsonUtil.parseList(cacheValue, String.class) == null ? new ArrayList<>() : JsonUtil.parseList(cacheValue, String.class); + welfareList.stream().forEach(field -> { + if (checkFields.contains(field.getFieldId())) { + field.setChecked(true); + } + }); + return welfareList; + } + + /** + * 获取福利台账的补差-福利类项目 + */ + public List balanceWelfareList() { + + List welfareList = welfareList(); + welfareList = welfareList.stream().filter(f -> !f.getSalaryItemName().contains("合计")).collect(Collectors.toList()); + + List noUseICategoryList= getICategoryMapper().listAll().stream().filter(f -> f.getIsUse() == 0).collect(Collectors.toList()); + if (noUseICategoryList.size() > 0) { + List noUseNameList = noUseICategoryList.stream().map(ICategoryPO::getInsuranceName).collect(Collectors.toList()); + welfareList = welfareList.stream().filter(f -> !noUseNameList.contains(f.getSalaryItemName().substring(0, f.getSalaryItemName().length() - 2))).collect(Collectors.toList()); + + } + + // 缓存勾选 + String cacheKey = user.getUID() + SalaryItemConstant.SI_ACCOUNT_BALANCE_IMPORT_FIELD_SIGN; + String cacheValue = (String) Util_DataCache.getObjVal(cacheKey); + List checkFields = JsonUtil.parseList(cacheValue, String.class) == null ? new ArrayList<>() : JsonUtil.parseList(cacheValue, String.class); + welfareList.stream().forEach(field -> { + if (checkFields.contains(field.getFieldId())) { + field.setChecked(true); + } + }); + + return welfareList; + } + + public Object mock(SalaryFormulaMockParam param) { + return getSalaryFormulaService(user).mock(param); + } +} diff --git a/src/com/engine/salary/wrapper/SalaryItemWrapper.java b/src/com/engine/salary/wrapper/SalaryItemWrapper.java new file mode 100644 index 000000000..2a510d8db --- /dev/null +++ b/src/com/engine/salary/wrapper/SalaryItemWrapper.java @@ -0,0 +1,328 @@ +package com.engine.salary.wrapper; + +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.hrmelog.entity.dto.LoggerContext; +import com.engine.salary.component.WeaFormOption; +import com.engine.salary.config.SalaryElogConfig; +import com.engine.salary.entity.salaryformula.ExpressFormula; +import com.engine.salary.entity.salaryitem.bo.SalaryItemBO; +import com.engine.salary.entity.salaryitem.bo.SysSalaryItemBO; +import com.engine.salary.entity.salaryitem.dto.SalaryItemFormDTO; +import com.engine.salary.entity.salaryitem.dto.SalaryItemListDTO; +import com.engine.salary.entity.salaryitem.param.*; +import com.engine.salary.entity.salaryitem.po.SalaryItemPO; +import com.engine.salary.entity.salaryitem.po.SysSalaryItemPO; +import com.engine.salary.entity.salarysob.po.SalarySobItemPO; +import com.engine.salary.enums.*; +import com.engine.salary.enums.salaryitem.SalaryDataTypeEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.service.*; +import com.engine.salary.service.impl.*; +import com.engine.salary.sys.enums.TaxDeclarationFunctionEnum; +import com.engine.salary.sys.service.SalarySysConfService; +import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.excel.ImportExcelResponse; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.util.valid.RuntimeTypeEnum; +import com.engine.salary.util.valid.ValidUtil; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang.math.NumberUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import weaver.hrm.User; + +import java.util.*; + +/** + * 薪资项目 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SalaryItemWrapper extends Service { + + private SalaryItemService getSalaryItemService(User user) { + return ServiceUtil.getService(SalaryItemServiceImpl.class, user); + } + + private SysSalaryItemService getSysSalaryItemService(User user) { + return ServiceUtil.getService(SysSalaryItemServiceImpl.class, user); + } + + private SalaryFormulaService getSalaryFormulaService(User user) { + return ServiceUtil.getService(SalaryFormulaServiceImpl.class, user); + } + + + private SalarySobItemService getSalarySobItemService(User user) { + return ServiceUtil.getService(SalarySobItemServiceImpl.class, user); + } + + private SalarySobBackItemService getSalarySobBackItemService(User user) { + return ServiceUtil.getService(SalarySobBackItemServiceImpl.class, user); + } + + private SalarySysConfService getSalarySysConfService(User user) { + return ServiceUtil.getService(SalarySysConfServiceImpl.class, user); + } + + /** + * 薪资项目列表 + * + * @param searchParam 查询参数 + * @return + */ + public PageInfo listPage(SalaryItemSearchParam searchParam) { + SalaryItemServiceImpl.UsingItem usingItem = getSalaryItemService(user).getUsingItem(); + List usingFormulaIds = usingItem.getUsingFormulaIds(); + List usingItemIds = usingItem.getUsingItemIds(); + List usingCodes = usingItem.getUsingCodes(); + + //删除无用公式 +// getSalaryFormulaService(user).deleteNotIn(usingFormulaIds); + + //薪资档案引用的项目转移到字段管理功能项 + searchParam.setUseInEmployeeSalary(SalaryOnOffEnum.OFF.getValue()); + + // 1、查询薪资项目 + PageInfo page = getSalaryItemService(user).listPageByParam(searchParam); + List salaryItemList = page.getList(); + + //最终返回的分页对象 + PageInfo salaryItemListDTOPage = new PageInfo<>(SalaryItemListDTO.class); + salaryItemListDTOPage.setPageSize(page.getPageSize()); + salaryItemListDTOPage.setPageNum(page.getPageNum()); + salaryItemListDTOPage.setTotal(page.getTotal()); + + //是否需要系统算税,不需要则去除系统项目 + TaxDeclarationFunctionEnum taxDeclarationFunctionEnum = getSalarySysConfService(user).getTaxDeclaration(); + + + // 被薪资账套引用的薪资项目 + if (CollectionUtils.isNotEmpty(salaryItemList)) { + //2、填充公式内容 + Set formulaIds = SalaryEntityUtil.properties(salaryItemList, SalaryItemPO::getFormulaId); + List expressFormulas = getSalaryFormulaService(user).listExpressFormula(formulaIds); + // 查询系统薪资项目 + Set sysSalaryItemIds = SalaryEntityUtil.properties(salaryItemList, SalaryItemPO::getSysSalaryItemId); + List sysSalaryItemPOS = getSysSalaryItemService(user).listByIds(sysSalaryItemIds); + // 转换成薪资项目列表dto + List salaryItemListDTOS = SalaryItemBO.convert2ListDTO(salaryItemList, expressFormulas, sysSalaryItemPOS); + //系统项目不删除 + salaryItemListDTOS.forEach(dto -> { + if ((taxDeclarationFunctionEnum != TaxDeclarationFunctionEnum.CLOSURE && StringUtils.isNotBlank(dto.getSystemName())) + || usingItemIds.contains(dto.getId()) + || usingCodes.contains(dto.getCode())) { + dto.setCanDelete(false); + } + }); + salaryItemListDTOPage.setList(salaryItemListDTOS); + } + + return salaryItemListDTOPage; + + } + + + /** + * 可以删除的薪资项目列表 + * + * @param searchParam 查询人员 + * @return + */ + public PageInfo listPage4CanDelete(SalaryItemSearchParam searchParam) { + // 查询所有薪资账套中的薪资项目副本 + List salarySobItemPOS = getSalarySobItemService(user).list(); + // 被引用的薪资项目id + Set salaryItemIds = SalaryEntityUtil.properties(salarySobItemPOS, SalarySobItemPO::getSalaryItemId); + // 排除被引用的薪资项目(被引用的薪资项目不可以删除) + searchParam.setExcludeIds(salaryItemIds); + // 转换成前端所需的数据格式 + return listPage(searchParam); + + } + + /** + * 根据主键id获取薪资项目详情 + * + * @param ids 薪资项目的主键id + * @return + */ + public List listByIds(Collection ids) { + List salaryItemPOS = getSalaryItemService(user).listByIds(ids); + if (CollectionUtils.isEmpty(salaryItemPOS)) { + return Collections.emptyList(); + } + // 查询公式详情 + Set formulaIds = SalaryEntityUtil.properties(salaryItemPOS, SalaryItemPO::getFormulaId); + List expressFormulas = getSalaryFormulaService(user).listExpressFormula(formulaIds); + // 查询系统薪资项目 + Set sysSalaryItemIds = SalaryEntityUtil.properties(salaryItemPOS, SalaryItemPO::getSysSalaryItemId); + List sysSalaryItemPOS = getSysSalaryItemService(user).listByIds(sysSalaryItemIds); + // 转换成薪资项目列表dto + return SalaryItemBO.convert2ListDTO(salaryItemPOS, expressFormulas, sysSalaryItemPOS); + } + + /** + * 薪资项目详情 + * + * @param id 主键id + * @return + */ + public SalaryItemFormDTO getForm(Long id) { + SalaryItemFormDTO salaryItemFormDTO = new SalaryItemFormDTO(); + // 默认可以编辑 + salaryItemFormDTO.setCanEdit(NumberUtils.INTEGER_ONE); + if (!Objects.isNull(id)) { + // 查询薪资项目 + SalaryItemPO salaryItemPO = getSalaryItemService(user).getById(id); + // 系统薪资项目 + SysSalaryItemPO sysSalaryItemPO = getSysSalaryItemService(user).getById(id); + if (Objects.isNull(salaryItemPO) && Objects.isNull(sysSalaryItemPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98299, "参数错误,薪资项目不存在或已被删除")); + } + ExpressFormula expressFormula; +// // 转换成薪资项目详情dto + if (Objects.isNull(salaryItemPO)) { + salaryItemFormDTO = SysSalaryItemBO.convert2FormDTO(sysSalaryItemPO); + expressFormula = getSalaryFormulaService(user).getExpressFormula(sysSalaryItemPO.getFormulaId()); + } else { + salaryItemFormDTO = SalaryItemBO.convert2FormDTO(salaryItemPO); + expressFormula = getSalaryFormulaService(user).getExpressFormula(salaryItemPO.getFormulaId()); + } + String formulaContent = Optional.ofNullable(expressFormula).map(ExpressFormula::getFormula).orElse(""); + salaryItemFormDTO.setFormulaContent(formulaContent); + salaryItemFormDTO.setOriginFormulaContent(salaryItemFormDTO.getValueType().equals(SalaryValueTypeEnum.FORMULA.getValue()) ? formulaContent : ""); + salaryItemFormDTO.setOriginSqlContent(salaryItemFormDTO.getValueType().equals(SalaryValueTypeEnum.SQL.getValue()) ? formulaContent : ""); + } + return salaryItemFormDTO; + } + + /** + * 获取薪资项目可选的类型(与属性有联动) + * + * @return + */ + public Map> listSalaryItemTypeOption() { + return SalaryEntityUtil.group2ListMap(Arrays.asList(SalaryItemTypeEnum.values()), + e -> e.getCategory().name(), + e -> new WeaFormOption(e.name(), SalaryI18nUtil.getI18nLabel(e.getLabelId(), e.getDefaultLabel()))); + } + + /** + * 保存薪资项目 + * + * @param saveParam 保存参数 + */ + public void save(SalaryItemSaveParam saveParam) { + ValidUtil.doValidator(saveParam); + validParam(saveParam); + + SalaryItemPO salaryItemPO = getSalaryItemService(user).save(saveParam); + // 记录日志 + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(salaryItemPO.getId())); + loggerContext.setTargetName(salaryItemPO.getName()); + loggerContext.setOperateType(OperateTypeEnum.ADD.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "新建薪资项目")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "新建薪资项目") + ": " + salaryItemPO.getName()); + loggerContext.setNewValues(salaryItemPO); + SalaryElogConfig.salaryItemLoggerTemplate.write(loggerContext); + } + + private void validParam(SalaryItemSaveParam saveParam) { + if (SalarySystemTypeEnum.parseByValue(saveParam.getSystemType()) == null) { + throw new SalaryRunTimeException("系统内置的薪资项目异常"); + } + if (SalaryRoundingModeEnum.parseByValue(saveParam.getRoundingMode()) == null) { + throw new SalaryRunTimeException("舍入规则异常"); + } + if (SalaryValueTypeEnum.parseByValue(saveParam.getValueType()) == null) { + throw new SalaryRunTimeException("取值方式异常"); + } + if (SalaryDataTypeEnum.parseByValue(saveParam.getDataType()) == null) { + throw new SalaryRunTimeException("字段类型异常"); + } + if (saveParam.getName().contains("{") || saveParam.getName().contains("}") || saveParam.getName().contains(".")) { + throw new SalaryRunTimeException("薪资项目名称中不得包含大括号或点"); + } + } + + /** + * 编辑薪资项目 + * + * @param saveParam 更新参数 + */ + public void update(SalaryItemSaveParam saveParam) { + ValidUtil.doValidator(saveParam, RuntimeTypeEnum.UPDATE); + validParam(saveParam); + SalaryItemPO salaryItemPO = getSalaryItemService(user).update(saveParam); + + // 记录日志 + SalaryItemPO newSalaryItemPO = getSalaryItemService(user).getById(salaryItemPO.getId()); + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(newSalaryItemPO.getId())); + loggerContext.setTargetName(newSalaryItemPO.getName()); + loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "编辑字段")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "编辑字段") + ": " + newSalaryItemPO.getName()); + loggerContext.setOldValues(salaryItemPO); + loggerContext.setNewValues(newSalaryItemPO); + SalaryElogConfig.salaryItemLoggerTemplate.write(loggerContext); + } + + /** + * 删除薪资项目 + * + * @param ids 主键id + */ + public void delete(Collection ids) { + getSalaryItemService(user).deleteByIds(ids); + } + + + /** + * 获取薪资项目在哪些账套中使用 + * + * @param salaryItemId + */ + public List> getSalarySobBySalaryItem(Long salaryItemId) { + return getSalaryItemService(user).getSalarySobBySalaryItem(salaryItemId); + } + + /** + * 将薪资项目管理中的信息同步至账套 + * + * @param syncSalaryItemParam + */ + public void syncSalaryItemToSalarySobItem(SyncSalaryItemParam syncSalaryItemParam) { + getSalaryItemService(user).syncSalaryItemToSalarySobItem(syncSalaryItemParam); + } + + public XSSFWorkbook export(SalaryItemExportParam param) { + return getSalaryItemService(user).export(param); + } + + public Map preview(SalaryItemImportParam param) { + return getSalaryItemService(user).preview(param); + } + public ImportExcelResponse importSalaryItem(SalaryItemImportParam param) { + return getSalaryItemService(user).importSalaryItem(param); + } + + + public XSSFWorkbook downloadTemplate(SalaryItemDownloadTemplateParam param) { + return getSalaryItemService(user).downloadTemplate(param); + } + + public List listAuth(SalaryItemSearchParam param) { + return getSalaryItemService(user).listByName(param.getName()); + } +} diff --git a/src/com/engine/salary/wrapper/SalarySendRangeWrapper.java b/src/com/engine/salary/wrapper/SalarySendRangeWrapper.java new file mode 100644 index 000000000..a4edde955 --- /dev/null +++ b/src/com/engine/salary/wrapper/SalarySendRangeWrapper.java @@ -0,0 +1,36 @@ +package com.engine.salary.wrapper; + +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.entity.salaryBill.dto.SalarySendRangeListDTO; +import com.engine.salary.entity.salaryBill.param.SalarySendRangeQueryParam; +import com.engine.salary.entity.salaryBill.param.SalarySendRangeSaveParam; +import com.engine.salary.service.SalarySendRangeService; +import com.engine.salary.service.impl.SalarySendRangeServiceImpl; +import com.engine.salary.util.page.PageInfo; +import weaver.hrm.User; + +import java.util.ArrayList; +import java.util.Collection; + +public class SalarySendRangeWrapper extends Service { + private SalarySystemConfigWrapper getSalarySysConfService(User user) { + return ServiceUtil.getService(SalarySystemConfigWrapper.class, user); + } + + private SalarySendRangeService getSalarySendRangeService(User user) { + return ServiceUtil.getService(SalarySendRangeServiceImpl.class, user); + } + + public PageInfo listPage(SalarySendRangeQueryParam queryParam) { + return getSalarySendRangeService(user).listPage(queryParam); + } + + public void save(SalarySendRangeSaveParam saveParam) { + getSalarySendRangeService(user).save(saveParam); + } + + public void deleteByIds(Collection ids) { + getSalarySendRangeService(user).deleteByIds(new ArrayList<>(ids)); + } +} diff --git a/src/com/engine/salary/wrapper/SalarySendWrapper.java b/src/com/engine/salary/wrapper/SalarySendWrapper.java new file mode 100644 index 000000000..f97a798dc --- /dev/null +++ b/src/com/engine/salary/wrapper/SalarySendWrapper.java @@ -0,0 +1,741 @@ +package com.engine.salary.wrapper; + +import cn.hutool.core.util.ObjectUtil; +import com.api.browser.bean.SearchConditionGroup; +import com.api.browser.bean.SearchConditionItem; +import com.api.browser.bean.SearchConditionOption; +import com.api.browser.util.ConditionFactory; +import com.api.browser.util.ConditionType; +import com.cloudstore.eccom.constant.WeaBoolAttr; +import com.cloudstore.eccom.pc.table.WeaTable; +import com.cloudstore.eccom.pc.table.WeaTableCheckboxpopedom; +import com.cloudstore.eccom.pc.table.WeaTableColumn; +import com.cloudstore.eccom.result.WeaResultMsg; +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.constant.SalaryItemConstant; +import com.engine.salary.entity.salaryBill.dto.*; +import com.engine.salary.entity.salaryBill.param.*; +import com.engine.salary.entity.salaryBill.po.SalarySendPO; +import com.engine.salary.entity.salaryBill.po.SalaryTemplatePO; +import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO; +import com.engine.salary.entity.salarysob.po.SalarySobPO; +import com.engine.salary.entity.taxagent.dto.TaxAgentListDTO; +import com.engine.salary.enums.UserStatusEnum; +import com.engine.salary.enums.auth.AuthFilterTypeEnum; +import com.engine.salary.enums.salarybill.SalarySendStatusEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.service.*; +import com.engine.salary.service.impl.*; +import com.engine.salary.sys.constant.SalarySysConstant; +import com.engine.salary.sys.entity.po.SalarySysConfPO; +import com.engine.salary.sys.enums.PayrollCheckTypeEnum; +import com.engine.salary.sys.service.SalarySysConfService; +import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl; +import com.engine.salary.util.SalaryDateUtil; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.SalaryTokenUtil; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.util.page.SalaryPageUtil; +import com.engine.salary.wrapper.proxy.SalarySendWrapperProxy; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.math.NumberUtils; +import org.apache.ibatis.session.SqlSession; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import weaver.conn.mybatis.MyBatisFactory; +import weaver.hrm.User; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.stream.Collectors; + +/** + * 工资单发放 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SalarySendWrapper extends Service implements SalarySendWrapperProxy { + private TaxAgentService getTaxAgentService(User user) { + return ServiceUtil.getService(TaxAgentServiceImpl.class, user); + } + + private SalarySendService getSalarySendService(User user) { + return ServiceUtil.getService(SalarySendServiceImpl.class, user); + } + + private SalaryBillService getSalaryBillService(User user) { + return ServiceUtil.getService(SalaryBillServiceImpl.class, user); + } + + private SalaryTemplateService getSalaryTemplateService(User user) { + return ServiceUtil.getService(SalaryTemplateServiceImpl.class, user); + } + + private SalarySobService getSalarySobService(User user) { + return ServiceUtil.getService(SalarySobServiceImpl.class, user); + } + + private SalaryAcctRecordService getSalaryAcctRecordService(User user) { + return ServiceUtil.getService(SalaryAcctRecordServiceImpl.class, user); + } + + private ExtEmpService getExtEmpService(User user) { + return ServiceUtil.getService(ExtEmpServiceImpl.class, user); + } + + private SalarySysConfService getSalarySysConfService(User user) { + return ServiceUtil.getService(SalarySysConfServiceImpl.class, user); + } + + + /** + * 工资单发放列表 + * + * @param queryParam + * @return + */ + public Map list(SalarySendQueryParam queryParam) { + + // 处理工资单发放历史数据 + getSalarySendService(user).handleHistory(); + + long currentEmployeeId = user.getUID(); + + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + Map datas = new HashMap<>(16); + try { + queryParam.setSalaryMonth(queryParam.getSalaryYearMonth().stream().map(e -> e + "-01 00:00:00").collect(Collectors.toList())); + queryParam.setSalaryMonthDate(queryParam.getSalaryYearMonth().stream().map(e -> e + "-01 00:00:00").map(SalaryDateUtil::dateStrToLocalTime).collect(Collectors.toList())); + queryParam.setFilterType(AuthFilterTypeEnum.DATA_OPT); + + List list = getSalarySendService(user).list(queryParam); + + list.forEach(dto -> { + // 回算过,但是查看的是普通工资单(不能查看详情);回算过,但是查看的是回算工资单(可以发);记录没回算过(可以发) + if(Objects.equals(dto.getSalaryAcctRecordType(), NumberUtils.INTEGER_ONE) && Objects.equals(dto.getSalaryAcctType(),NumberUtils.INTEGER_ZERO)){ + dto.setCanSeeDetail(false); + }else{ + dto.setCanSeeDetail(true); + } + }); + + PageInfo pageInfo = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), + list, SalarySendListDTO.class); + List pageList = pageInfo.getList(); + List salarySobIds = pageList.stream().map(SalarySendListDTO::getSalarySobId).distinct().collect(Collectors.toList()); + // 获取默认模板 + if (salarySobIds.size() > 0) { + List salaryTemplates = getSalaryTemplateService(user).getDefaultTemplates(salarySobIds); + pageList.forEach(e -> { + // 已发放 + e.setSendSituation(e.getSendNum() + "/" + e.getSendTotal()); + // 工资单模板 + Optional optional = salaryTemplates.stream().filter(s -> s.getSalarySobId().equals(e.getSalarySobId())).findFirst(); + if (optional.isPresent()) { + // todo 目前就一个回算,那么没有冻结且是回算,就展示补发名称 + SalaryTemplatePO salaryTemplatePO = optional.get(); + e.setTemplate(NumberUtils.INTEGER_ONE.equals(e.getSalaryAcctType()) ? salaryTemplatePO.getReplenishName() : salaryTemplatePO.getName()); + e.setTemplateId(salaryTemplatePO.getId()); + if ((salaryTemplatePO.getAckFeedbackStatus() != null && salaryTemplatePO.getAckFeedbackStatus() == 1) || + (salaryTemplatePO.getFeedbackStatus() != null && salaryTemplatePO.getFeedbackStatus() == 1) ) { + e.setAckFeedbackStatus(1); + } else { + e.setAckFeedbackStatus(0); + } + } + }); + } + List columns = buildWeaTableColumns(); + WeaTable table = new WeaTable(); + table.setColumns(columns); + //设置check是否可用 + List checkboxpopedomList = new ArrayList<>(); + WeaTableCheckboxpopedom checkboxpopedom = new WeaTableCheckboxpopedom(); + checkboxpopedom.setPopedompara("column:system_type"); + checkboxpopedom.setShowmethod("com.engine.salary.transmethod.TaxRateTransMethod.getCheckBoxPopedom"); + checkboxpopedomList.add(checkboxpopedom); + table.setCheckboxList(checkboxpopedomList); + table.setCheckboxpopedom(null); + + WeaResultMsg result = new WeaResultMsg(false); + result.putAll(table.makeDataResult()); + result.success(); + + datas.put("pageInfo", pageInfo); + datas.put("datas", pageList); + datas.put("columns", columns); + datas.put("dataKey", result.getResultMap()); + return datas; + } catch (Exception e) { + throw new SalaryRunTimeException(e.getMessage()); + } finally { + sqlSession.close(); + } + } + + /** + * 创建表展示字段 + * + * @return + */ + private List buildWeaTableColumns() { + List list = new ArrayList<>(); + WeaTableColumn idColumn = new WeaTableColumn("0px", "id", "id"); + idColumn.setDisplay(WeaBoolAttr.FALSE); + list.add(new WeaTableColumn("10%", "薪资所属月", "salaryYearMonth")); + list.add(new WeaTableColumn("35%", "薪资账套", "salarySob")); + list.add(new WeaTableColumn("25%", "次数", "acctTimes")); + list.add(new WeaTableColumn("25%", "工资单模板", "template")); + list.add(new WeaTableColumn("15%", "已发放", "sendSituation")); + list.add(new WeaTableColumn("15%", "最后发送时间", "lastSendTime")); + return list; + } + + /** + * 工资单发放基本信息 + * + * @param id + * @return + */ + public SalarySendBaseInfoDTO getBaseInfo(Long id) { + return getSalarySendService(user).getBaseInfo(id); + } + + public Map preview(SalaryPreviewParam param) { + return getSalarySendService(user).preview(param); + } + + /** + * 工资单发放信息列表的高级搜索 + * + * @return + */ + public Map getInfoSearchCondition() { + Map apidatas = new HashMap(); + ConditionFactory conditionFactory = new ConditionFactory(user); + + //条件组 + List addGroups = new ArrayList(); + List conditionItems = new ArrayList(); + + //文本输入框 + SearchConditionItem username = conditionFactory.createCondition(ConditionType.INPUT, 25034, "username"); + username.setColSpan(2);//定义一行显示条件数,默认值为2,当值为1时标识该条件单独占一行 + username.setFieldcol(16); //条件输入框所占宽度,默认值18 + username.setLabelcol(8); + username.setViewAttr(2); // 编辑权限 1:只读,2:可编辑, 3:必填 默认2 + username.setLabel("姓名"); //设置文本值 这个将覆盖多语言标签的值 + username.setInputType(""); + conditionItems.add(username); + + // 个税扣缴义务人 + SearchConditionItem taxAgent = conditionFactory.createCondition(ConditionType.SELECT, 25034, "taxAgentId"); + taxAgent.setColSpan(2);//定义一行显示条件数,默认值为2,当值为1时标识该条件单独占一行 + taxAgent.setFieldcol(16); //条件输入框所占宽度,默认值18 + taxAgent.setLabelcol(8); + List searchConditionOptions = new ArrayList<>(); + Collection taxAgentLists = getTaxAgentService(user).findAll(); + taxAgentLists.forEach(e -> searchConditionOptions.add(new SearchConditionOption(e.getId().toString(), e.getName()))); + taxAgent.setOptions(searchConditionOptions); + taxAgent.setInputType(""); + taxAgent.setViewAttr(2); // 编辑权限 1:只读,2:可编辑, 3:必填 默认2 + taxAgent.setLabel("个税扣缴义务人"); //设置文本值 这个将覆盖多语言标签的值 + conditionItems.add(taxAgent); + + // 分部 + SearchConditionItem subCompany = conditionFactory.createCondition(ConditionType.BROWSER, 502227, "subCompanyIdStr", "194"); + subCompany.setColSpan(2); + subCompany.setFieldcol(16); + subCompany.setLabelcol(8); + subCompany.setViewAttr(2); + subCompany.setIsQuickSearch(false); + subCompany.setLabel("分部"); + subCompany.setInputType(""); + subCompany.getBrowserConditionParam().setIsSingle(false); + conditionItems.add(subCompany); + + // 部门 + SearchConditionItem departmentName = conditionFactory.createCondition(ConditionType.BROWSER, 502227, "departmentIdStr", "4"); + departmentName.setColSpan(2); + departmentName.setFieldcol(16); + departmentName.setLabelcol(8); + departmentName.setViewAttr(2); + departmentName.setIsQuickSearch(false); + departmentName.setLabel("部门"); + departmentName.setInputType(""); + departmentName.getBrowserConditionParam().setIsSingle(false); + conditionItems.add(departmentName); + + // 岗位 + SearchConditionItem position = conditionFactory.createCondition(ConditionType.BROWSER, 502227, "positionIds", "24"); + position.setColSpan(2); + position.setFieldcol(16); + position.setLabelcol(8); + position.setViewAttr(2); + position.setIsQuickSearch(false); + position.setLabel("岗位"); + position.setInputType(""); + conditionItems.add(position); + + //状态 + SearchConditionItem status = conditionFactory.createCondition(ConditionType.SELECT, 25034, "userstatus"); + status.setColSpan(2);//定义一行显示条件数,默认值为2,当值为1时标识该条件单独占一行 + status.setFieldcol(16); //条件输入框所占宽度,默认值18 + status.setLabelcol(8); + List userStatusOptions = new ArrayList<>(); + UserStatusEnum.getList().forEach(e -> userStatusOptions.add(new SearchConditionOption(e.get("id"), e.get("content")))); + status.setOptions(userStatusOptions); + status.setInputType(""); + status.setViewAttr(2); // 编辑权限 1:只读,2:可编辑, 3:必填 默认2 + status.setLabel("状态"); //设置文本值 这个将覆盖多语言标签的值 + conditionItems.add(status); + + //发送状态 + SearchConditionItem sendStatus = conditionFactory.createCondition(ConditionType.SELECT, 25034, "sendStatusVal"); + sendStatus.setColSpan(2);//定义一行显示条件数,默认值为2,当值为1时标识该条件单独占一行 + sendStatus.setFieldcol(16); //条件输入框所占宽度,默认值18 + sendStatus.setLabelcol(8); + List sendStatusOptions = new ArrayList<>(); + Arrays.asList(SalarySendStatusEnum.values()) + .forEach(e -> sendStatusOptions.add(new SearchConditionOption(e.getValue().toString(), e.getDefaultLabel()))); + sendStatus.setOptions(sendStatusOptions); + sendStatus.setInputType(""); + sendStatus.setViewAttr(2); // 编辑权限 1:只读,2:可编辑, 3:必填 默认2 + sendStatus.setLabel("发送状态"); //设置文本值 这个将覆盖多语言标签的值 + conditionItems.add(sendStatus); + + addGroups.add(new SearchConditionGroup("常用条件", true, conditionItems)); + + apidatas.put("condition", addGroups); + return apidatas; + } + + /** + * 工资单发放信息列表 + * + * @param queryParam + * @return + */ + public PageInfo infoList(SalarySendInfoQueryParam queryParam) { + + SalarySendInfoQueryParam.checkParam(queryParam); + // 发送状态 + if (queryParam.getSendStatus() != null) { + queryParam.setSendStatusVal(queryParam.getSendStatus().getValue()); + } + + PageInfo pageInfo = getSalarySendService(user).salarySendInfoListPage(queryParam); + + return pageInfo; + } + + /** + * 工资单信息列表 + * + * @return + */ + private List buildInfoListWeaTableColumns() { + List list = new ArrayList<>(); + WeaTableColumn idColumn = new WeaTableColumn("0px", "id", "id"); + idColumn.setDisplay(WeaBoolAttr.TRUE); + list.add(new WeaTableColumn("20%", "姓名", "username")); + list.add(new WeaTableColumn("20%", "个税扣缴义务人", "taxAgent")); + list.add(new WeaTableColumn("20%", "部门", "department")); + list.add(new WeaTableColumn("20%", "手机号", "mobile")); + list.add(new WeaTableColumn("20%", "工号", "jobNum")); + list.add(new WeaTableColumn("20%", "发送状态", "sendStatus")); + list.add(new WeaTableColumn("20%", "操作", "operation")); + return list; + } + + + /** + * 导出-工资单发放信息列表 + * + * @param queryParam + * @return + */ + public XSSFWorkbook exportInfoList(SalarySendInfoQueryParam queryParam) { + return getSalarySendService(user).exportInfoList(queryParam); + } + + /** + * 工资单发放 + * + * @param queryParam + * @return + */ + public Map grant(SalarySendGrantParam queryParam) { + return getSalaryBillService(user).grant(queryParam); + } + + /** + * 工资单撤回 + * + * @param queryParam + * @return + */ + public Map withdraw(SalarySendWithdrawParam queryParam) { + return getSalarySendService(user).withdraw(queryParam); + } + + /** + * 工资单发放详情列表的高级搜索 + * + * @return + */ + public Map getDetailSearchCondition() { + Map apidatas = new HashMap(); + ConditionFactory conditionFactory = new ConditionFactory(user); + + //条件组 + List addGroups = new ArrayList(); + List conditionItems = new ArrayList(); + + //文本输入框 + SearchConditionItem username = conditionFactory.createCondition(ConditionType.INPUT, 25034, "username"); + username.setColSpan(2);//定义一行显示条件数,默认值为2,当值为1时标识该条件单独占一行 + username.setFieldcol(16); //条件输入框所占宽度,默认值18 + username.setLabelcol(8); + username.setViewAttr(2); // 编辑权限 1:只读,2:可编辑, 3:必填 默认2 + username.setLabel("姓名"); //设置文本值 这个将覆盖多语言标签的值 + username.setInputType(""); + conditionItems.add(username); + + // 个税扣缴义务人 + SearchConditionItem taxAgent = conditionFactory.createCondition(ConditionType.SELECT, 25034, "taxAgent"); + taxAgent.setColSpan(2);//定义一行显示条件数,默认值为2,当值为1时标识该条件单独占一行 + taxAgent.setFieldcol(16); //条件输入框所占宽度,默认值18 + taxAgent.setLabelcol(8); + List searchConditionOptions = new ArrayList<>(); + Collection taxAgentLists = getTaxAgentService(user).findAll(); + taxAgentLists.forEach(e -> searchConditionOptions.add(new SearchConditionOption(e.getId().toString(), e.getName()))); + taxAgent.setOptions(searchConditionOptions); + taxAgent.setInputType(""); + taxAgent.setViewAttr(2); // 编辑权限 1:只读,2:可编辑, 3:必填 默认2 + taxAgent.setLabel("个税扣缴义务人"); //设置文本值 这个将覆盖多语言标签的值 + conditionItems.add(taxAgent); + + // 分部 + SearchConditionItem subCompany = conditionFactory.createCondition(ConditionType.BROWSER, 502227, "subCompanyIdStr", "194"); + subCompany.setColSpan(2); + subCompany.setFieldcol(16); + subCompany.setLabelcol(8); + subCompany.setViewAttr(2); + subCompany.setInputType(""); + subCompany.setIsQuickSearch(false); + subCompany.setLabel("分部"); + subCompany.getBrowserConditionParam().setIsSingle(false); + conditionItems.add(subCompany); + + + // 部门 + SearchConditionItem departmentName = conditionFactory.createCondition(ConditionType.BROWSER, 502227, "departmentIdStr", "4"); + departmentName.setColSpan(2); + departmentName.setFieldcol(16); + departmentName.setLabelcol(8); + departmentName.setViewAttr(2); + departmentName.setInputType(""); + departmentName.setIsQuickSearch(false); + departmentName.setLabel("部门"); + departmentName.getBrowserConditionParam().setIsSingle(false); + conditionItems.add(departmentName); + + // 岗位 + SearchConditionItem position = conditionFactory.createCondition(ConditionType.BROWSER, 502227, "position", "24"); + position.setColSpan(2); + position.setFieldcol(16); + position.setInputType(""); + position.setLabelcol(8); + position.setViewAttr(2); + position.setIsQuickSearch(false); + position.setLabel("岗位"); + conditionItems.add(position); + + //状态 + SearchConditionItem status = conditionFactory.createCondition(ConditionType.SELECT, 25034, "userstatus"); + status.setColSpan(2);//定义一行显示条件数,默认值为2,当值为1时标识该条件单独占一行 + status.setFieldcol(16); //条件输入框所占宽度,默认值18 + status.setLabelcol(8); + List userStatusOptions = new ArrayList<>(); + UserStatusEnum.getList().forEach(e -> userStatusOptions.add(new SearchConditionOption(e.get("id"), e.get("content")))); + status.setOptions(userStatusOptions); + status.setInputType(""); + status.setViewAttr(2); // 编辑权限 1:只读,2:可编辑, 3:必填 默认2 + status.setLabel("状态"); //设置文本值 这个将覆盖多语言标签的值 + conditionItems.add(status); + +// //入职日期 +// SearchConditionItem hiredate = conditionFactory.createCondition(ConditionType.RANGEPICKER, 25034, "hiredate"); +// hiredate.setColSpan(2);//定义一行显示条件数,默认值为2,当值为1时标识该条件单独占一行 +// hiredate.setFieldcol(16); //条件输入框所占宽度,默认值18 +// hiredate.setLabelcol(8); +// hiredate.setViewAttr(2); // 编辑权限 1:只读,2:可编辑, 3:必填 默认2 +// Map otherParams1 = new HashMap(); +// otherParams1.put("format", "yyyy-MM-dd"); +// hiredate.setOtherParams(otherParams1); +// hiredate.setInputType("day"); +// hiredate.setMode("day"); +// hiredate.setLabel("入职日期"); //设置文本值 这个将覆盖多语言标签的值 +// conditionItems.add(hiredate); + + //合并计税 + SearchConditionItem mergeCountTax = conditionFactory.createCondition(ConditionType.CHECKBOX, 25034, "mergeCountTax"); + mergeCountTax.setColSpan(2);//定义一行显示条件数,默认值为2,当值为1时标识该条件单独占一行 + mergeCountTax.setFieldcol(16); //条件输入框所占宽度,默认值18 + mergeCountTax.setLabelcol(8); + mergeCountTax.setInputType("switch"); + mergeCountTax.setViewAttr(2); // 编辑权限 1:只读,2:可编辑, 3:必填 默认2 + mergeCountTax.setLabel("合并计税"); //设置文本值 这个将覆盖多语言标签的值 + conditionItems.add(mergeCountTax); + + addGroups.add(new SearchConditionGroup("常用条件", true, conditionItems)); + + apidatas.put("condition", addGroups); + return apidatas; + } + + /** + * 工资单发放详情列表 + * + * @param queryParam + * @return + */ + public Map detailList(SalarySendDetailQueryParam queryParam) { + Map datas = new HashMap<>(); + SalarySendDetailQueryParam.checkParam(queryParam); + SalarySendPO salarySend = getSalarySendService(user).getById(queryParam.getSalarySendId()); + + if (salarySend == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100510, "工资发放不存在")); + } + + SalaryAcctRecordPO salaryAcctRecord = getSalaryAcctRecordService(user).getById(salarySend.getSalaryAccountingId()); + boolean isReplenish = salaryAcctRecord != null && Objects.equals(salaryAcctRecord.getBackCalcStatus(), (NumberUtils.INTEGER_ONE)); + + + // 1.根据模板获取薪资项目设置 + SalarySobPO salarySob = getSalarySobService(user).getById(salarySend.getSalarySobId()); + List salaryTemplates = getSalaryTemplateService(user) + .getDefaultTemplates(Arrays.asList(salarySend.getSalarySobId(), salarySob == null ? 0L : salarySob.getId())); + + List salaryItems = getSalarySendService(user) + .getSalaryItemsSetting(CollectionUtils.isNotEmpty(salaryTemplates) ? salaryTemplates.get(0) : null, isReplenish); + + // 2.获取基本数据 + PageInfo pageInfo = getSalarySendService(user).salarySendInfoDetailListPage(queryParam); + + List records = pageInfo.getList(); + // 3.组装详情数据 + List> listMaps = getSalarySendService(user).buildDetailList(salaryItems, records, salarySend.getSalaryAccountingId()); + + List columns = buildDetailListWeaTableColumns(); + + for (SalaryTemplateSalaryItemListDTO salaryItem : salaryItems) { + columns.add(new WeaTableColumn("100px", salaryItem.getName(), salaryItem.getId() + SalaryItemConstant.DYNAMIC_SUFFIX)); + } + + + WeaTable table = new WeaTable(); + table.setColumns(columns); + //设置check是否可用 + List checkboxpopedomList = new ArrayList<>(); + WeaTableCheckboxpopedom checkboxpopedom = new WeaTableCheckboxpopedom(); + checkboxpopedom.setPopedompara("column:system_type"); + checkboxpopedom.setShowmethod("com.engine.salary.transmethod.TaxRateTransMethod.getCheckBoxPopedom"); + checkboxpopedomList.add(checkboxpopedom); + table.setPageUID(queryParam.getSalarySendId().toString()); + table.setCheckboxList(checkboxpopedomList); + table.setCheckboxpopedom(null); + + WeaResultMsg result = new WeaResultMsg(false); + result.putAll(table.makeDataResult()); + result.success(); + + datas.put("pageInfo", pageInfo); + datas.put("datas", listMaps); + datas.put("columns", columns); + datas.put("dataKey", result.getResultMap()); + + return datas; + } + + private List buildDetailListWeaTableColumns() { + List list = new ArrayList<>(); + WeaTableColumn idColumn = new WeaTableColumn("0px", "id", "id"); + idColumn.setDisplay(WeaBoolAttr.TRUE); + list.add(new WeaTableColumn("100px", "姓名", "username")); + list.add(new WeaTableColumn("100px", "个税扣缴义务人", "taxAgent")); + list.add(new WeaTableColumn("100px", "部门", "department")); + list.add(new WeaTableColumn("100px", "手机号", "mobile")); + list.add(new WeaTableColumn("100px", "工号", "jobNum")); + return list; + } + + /** + * 导出-工资单发放详情列表 + * + * @param queryParam + * @return + */ + public XSSFWorkbook exportDetailList(SalarySendDetailQueryParam queryParam) { + // 获取发放详情 + SalarySendDetailQueryParam.checkParam(queryParam); + + SalarySendPO salarySend = getSalarySendService(user).getById(queryParam.getSalarySendId()); + if (salarySend == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100512, "工资单发放不存在")); + } + + return getSalarySendService(user).exportDetailList(salarySend, queryParam); + } + + /** + * 我的工资单列表 + * + * @param queryParam + * @return + */ + public Map mySalaryBillList(SalaryBillQueryParam queryParam) { + Map datas = new HashMap<>(); + queryParam.setEmployeeId((long) user.getUID()); + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); + queryParam.setSalaryMonth( + queryParam.getSalaryYearMonth().stream().map(e -> { + try { + return simpleDateFormat.parse(e + "-01"); + } catch (ParseException parseException) { + throw new SalaryRunTimeException("日期转换错误"); + } + }).collect(Collectors.toList())); + PageInfo pageInfo = getSalarySendService(user).mySalaryBillListPage(queryParam); + List records = pageInfo.getList(); + + records.forEach(e -> { + e.setTaxAgent(StringUtils.isEmpty(e.getTaxAgent()) ? "" : e.getTaxAgent()); + e.setAcctTimes(e.getAcctTimes()); + }); + List columns = buildMySalaryBillListColumns(); + WeaTable table = new WeaTable(); + table.setColumns(columns); + //设置check是否可用 + List checkboxpopedomList = new ArrayList<>(); + WeaTableCheckboxpopedom checkboxpopedom = new WeaTableCheckboxpopedom(); + checkboxpopedom.setPopedompara("column:system_type"); + checkboxpopedom.setShowmethod("com.engine.salary.transmethod.TaxRateTransMethod.getCheckBoxPopedom"); + checkboxpopedomList.add(checkboxpopedom); + table.setCheckboxList(checkboxpopedomList); + table.setCheckboxpopedom(null); + + WeaResultMsg result = new WeaResultMsg(false); + result.putAll(table.makeDataResult()); + result.success(); + + datas.put("pageInfo", pageInfo); + datas.put("datas", records); + datas.put("columns", columns); + datas.put("dataKey", result.getResultMap()); + + return datas; + } + + private List buildMySalaryBillListColumns() { + SalarySysConfPO taxAgentShowStatusPO = getSalarySysConfService(user).getOneByCode(SalarySysConstant.TAX_AGENT_SHOW_STATUS); + List list = new ArrayList<>(); + WeaTableColumn idColumn = new WeaTableColumn("0px", "id", "id"); + idColumn.setDisplay(WeaBoolAttr.TRUE); + list.add(new WeaTableColumn("20%", "薪资所属月", "salaryYearMonth")); + if (taxAgentShowStatusPO == null || taxAgentShowStatusPO.getConfValue().equals("1")) { + list.add(new WeaTableColumn("40%", "个税扣缴义务人", "taxAgent")); + } + list.add(new WeaTableColumn("40%", "发放时间", "sendTime")); + return list; + } + + + /** + * 我的工资单 + * + * @param salaryInfoId + * @return + */ + public Map mySalaryBill(Long salaryInfoId) { + if (user == null) { + throw new SalaryRunTimeException("获取人员信息失败!"); + } + return getSalarySendService(user).mySalaryBill(salaryInfoId, (long) user.getUID()); + } + + /** + * 工资单发放信息合计行 + * + * @param queryParam + * @return + */ + public Map sumSendResult(SalarySendInfoQueryParam queryParam) { + Map datas = new HashMap<>(); + //合计 + Map sumRow = getSalarySendService(user).sumRow(queryParam); + datas.put("sumRow", sumRow); + return datas; + + } + + /** + * 发送短信验证码 + * @param param 短信验证码发送参数 + */ + public void sendMobileCode(SMSCodeSendParam param) { + getSalarySendService(user).sendMobileCode(param); + } + + /** + * 校验短信验证码 + * @param param + * @return + */ + public Boolean checkMobileCode(SMSCodeCheckParam param) { + return getSalarySendService(user).checkMobileCode(param); + } + + public PayrollCheckTypeEnum payrollCheckType() { + SalarySysConfPO conf = getSalarySysConfService(user).getOneByCode(SalarySysConstant.SALARY_PAYROLL_CHECK_TYPE); + + if(conf == null){ + return PayrollCheckTypeEnum.PWD; + } + + return PayrollCheckTypeEnum.parseByValue(conf.getConfValue()); + } + + public void confirmSalaryBill(Long salaryInfoId) { + if(ObjectUtil.isNull(salaryInfoId)){ + throw new SalaryRunTimeException("工资单id不能为空!"); + } + getSalaryBillService(user).confirmSalaryBill(salaryInfoId); + } + + public void feedBackSalaryBill(Long salaryInfoId) { + if(ObjectUtil.isNull(salaryInfoId)){ + throw new SalaryRunTimeException("工资单id不能为空!"); + } + getSalaryBillService(user).feedBackSalaryBill(salaryInfoId); + } + + public String exportPdf(SalaryExportPdfParam param) { + return getSalaryBillService(user).exportPdf(param); + } + + public Map getToken(SalaryBillGetTokenParam param) { + return SalaryTokenUtil.GetToken(param); + } + + public String genPdfBeforeExport(SalaryExportPdfParam salaryExportPdfParam) { + return getSalaryBillService(user).genPdfBeforeExport(salaryExportPdfParam); + } +} diff --git a/src/com/engine/salary/wrapper/SalarySobAdjustRuleWrapper.java b/src/com/engine/salary/wrapper/SalarySobAdjustRuleWrapper.java new file mode 100644 index 000000000..33d7b350d --- /dev/null +++ b/src/com/engine/salary/wrapper/SalarySobAdjustRuleWrapper.java @@ -0,0 +1,96 @@ +package com.engine.salary.wrapper; + +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.entity.salaryitem.po.SalaryItemPO; +import com.engine.salary.entity.salarysob.bo.SalarySobAdjustRuleBO; +import com.engine.salary.entity.salarysob.dto.SalaryItemBaseDTO; +import com.engine.salary.entity.salarysob.dto.SalarySobAdjustRuleListDTO; +import com.engine.salary.entity.salarysob.param.SalarySobAdjustRuleItemQueryParam; +import com.engine.salary.entity.salarysob.param.SalarySobAdjustRuleQueryParam; +import com.engine.salary.entity.salarysob.param.SalarySobAdjustRuleSaveParam; +import com.engine.salary.entity.salarysob.po.SalarySobAdjustRulePO; +import com.engine.salary.entity.salarysob.po.SalarySobItemPO; +import com.engine.salary.service.SalaryItemService; +import com.engine.salary.service.SalarySobAdjustRuleService; +import com.engine.salary.service.SalarySobItemService; +import com.engine.salary.service.impl.SalaryItemServiceImpl; +import com.engine.salary.service.impl.SalarySobAdjustRuleServiceImpl; +import com.engine.salary.service.impl.SalarySobItemServiceImpl; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.valid.ValidUtil; +import weaver.hrm.User; + +import java.util.List; +import java.util.Set; + +/** + * 薪资账套的调薪计薪规则 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SalarySobAdjustRuleWrapper extends Service { + + private SalarySobAdjustRuleService getSalarySobAdjustRuleService(User user) { + return (SalarySobAdjustRuleService) ServiceUtil.getService(SalarySobAdjustRuleServiceImpl.class, user); + } + + private SalaryItemService getSalaryItemService(User user) { + return (SalaryItemService) ServiceUtil.getService(SalaryItemServiceImpl.class, user); + } + + private SalarySobItemService getSalarySobItemService(User user) { + return (SalarySobItemService) ServiceUtil.getService(SalarySobItemServiceImpl.class, user); + } + + + /** + * 薪资账套的调薪计薪规则列表 + * + * @param queryParam 查询参数 + * @return + */ + public List list(SalarySobAdjustRuleQueryParam queryParam) { + + ValidUtil.doValidator(queryParam); + + // 查询调薪计薪规则po + List salarySobAdjustRulePOS = getSalarySobAdjustRuleService(user).listBySalarySobId(queryParam.getSalarySobId()); + // 查询薪资项目 + Set salaryItemIds = SalaryEntityUtil.properties(salarySobAdjustRulePOS, SalarySobAdjustRulePO::getSalaryItemId); + List salaryItemPOS = getSalaryItemService(user).listByIds(salaryItemIds); + // 转换成dto + return SalarySobAdjustRuleBO.convert2ListDTO(salarySobAdjustRulePOS, salaryItemPOS); + } + + /** + * 查询调薪计薪规则可选的薪资项目 + * + * @param queryParam 查询条件 + * @return + */ + public List list4SalarySobItem(SalarySobAdjustRuleItemQueryParam queryParam) { + + ValidUtil.doValidator(queryParam); + + // 查询薪资账套的薪资项目副本 + List salarySobItemPOS = getSalarySobItemService(user).listBySalarySobIdAndSalaryItemIdNotIn(queryParam.getSalarySobId(), queryParam.getExcludeSalaryItemIds()); + // 查询薪资项目 + Set salaryItemIds = SalaryEntityUtil.properties(salarySobItemPOS, SalarySobItemPO::getSalaryItemId); + List salaryItemPOS = getSalaryItemService(user).listByIds(salaryItemIds); + // 转换成dto + return SalarySobAdjustRuleBO.convertItemBaseDTO(salaryItemPOS); + } + + /** + * 保存调薪计薪规则 + * + * @param saveParam 保存参数 + */ + public void save(SalarySobAdjustRuleSaveParam saveParam) { + getSalarySobAdjustRuleService(user).save(saveParam); + } +} diff --git a/src/com/engine/salary/wrapper/SalarySobBackItemWrapper.java b/src/com/engine/salary/wrapper/SalarySobBackItemWrapper.java new file mode 100644 index 000000000..66adefefa --- /dev/null +++ b/src/com/engine/salary/wrapper/SalarySobBackItemWrapper.java @@ -0,0 +1,135 @@ +package com.engine.salary.wrapper; + +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.entity.salaryformula.ExpressFormula; +import com.engine.salary.entity.salaryitem.bo.SalaryItemBO; +import com.engine.salary.entity.salaryitem.po.SalaryItemPO; +import com.engine.salary.entity.salarysob.dto.SalarySobBackItemAggregateDTO; +import com.engine.salary.entity.salarysob.dto.SalarySobBackItemDTO; +import com.engine.salary.entity.salarysob.dto.SalarySobBackItemFormDTO; +import com.engine.salary.entity.salarysob.param.SalarySobBackItemSaveParam; +import com.engine.salary.entity.salarysob.po.SalarySobBackItemPO; +import com.engine.salary.enums.SalaryRoundingModeEnum; +import com.engine.salary.enums.SalaryValueTypeEnum; +import com.engine.salary.enums.salaryitem.SalaryDataTypeEnum; +import com.engine.salary.service.SalaryFormulaService; +import com.engine.salary.service.SalaryItemService; +import com.engine.salary.service.SalarySobBackItemService; +import com.engine.salary.service.SysSalaryItemService; +import com.engine.salary.service.impl.SalaryFormulaServiceImpl; +import com.engine.salary.service.impl.SalaryItemServiceImpl; +import com.engine.salary.service.impl.SalarySobBackItemServiceImpl; +import com.engine.salary.service.impl.SysSalaryItemServiceImpl; +import com.engine.salary.util.SalaryEntityUtil; +import com.wbi.util.Util; +import weaver.hrm.User; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * @author Harryxzy + * @date 2022/11/15 15:56 + * @description 薪资账套的回算项目 + */ +public class SalarySobBackItemWrapper extends Service { + + private SalarySobBackItemService getSalarySobBackItemService(User user) { + return ServiceUtil.getService(SalarySobBackItemServiceImpl.class, user); + } + + private SalaryItemService getSalaryItemService(User user) { + return ServiceUtil.getService(SalaryItemServiceImpl.class, user); + } + + private SalaryFormulaService getSalaryFormulaService(User user) { + return ServiceUtil.getService(SalaryFormulaServiceImpl.class, user); + } + + private SysSalaryItemService getSysSalaryItemService(User user) { + return ServiceUtil.getService(SysSalaryItemServiceImpl.class, user); + } + + /** + * @description 查看详情 + * @return SalarySobBackItemAggregateDTO + * @author Harryxzy + * @date 2022/11/15 15:59 + */ + public SalarySobBackItemAggregateDTO getAggregate(Long salarySobId) { + List salarySobBackItemPOS = getSalarySobBackItemService(user).listBySalarySobId(salarySobId); + // 查询薪资项目 + Set salaryItemIds = SalaryEntityUtil.properties(salarySobBackItemPOS, SalarySobBackItemPO::getSalaryItemId); + List salaryItemPOS = getSalaryItemService(user).listByIds(salaryItemIds); + Map salaryItemMap = SalaryEntityUtil.convert2Map(salaryItemPOS, SalaryItemPO::getId); + // 查询公式详情 + Set formulaIds = salarySobBackItemPOS.stream() + .map(SalarySobBackItemPO::getFormulaId) + .filter(formulaId -> !Objects.equals(formulaId, 0L)) + .collect(Collectors.toSet()); + List expressFormulas = getSalaryFormulaService(user).listExpressFormula(formulaIds); + Map expressFormulaContentMap = SalaryEntityUtil.convert2Map(expressFormulas, ExpressFormula::getId, ExpressFormula::getFormula); + // 已发项目设置 + List issuedItems = convert2DTO(salarySobBackItemPOS, salaryItemMap, + expressFormulaContentMap, 0); + // 补发项目设置 + List reissueItems = convert2DTO(salarySobBackItemPOS, salaryItemMap, + expressFormulaContentMap, 1); + return SalarySobBackItemAggregateDTO.builder() + .salarySobId(salarySobId) + .issuedItems(issuedItems) + .reissueItems(reissueItems).build(); + } + + private List convert2DTO(List salarySobBackItemPOS, + Map salaryItemMap, + Map expressFormulaContentMap, Integer backCalcType) { + return salarySobBackItemPOS.stream() + .filter(salarySobBackItemPO -> Objects.equals(salarySobBackItemPO.getBackCalcType(), backCalcType)) + .map(salarySobBackItemPO -> { + SalaryItemPO salaryItemPO = salaryItemMap.get(salarySobBackItemPO.getSalaryItemId()); + return SalarySobBackItemAggregateDTO.SalarySobBackItemDTO.builder() + .id(salarySobBackItemPO.getId()) + .name(Optional.ofNullable(salaryItemPO).map(SalaryItemPO::getName).orElse("")) + .salaryItemId(salarySobBackItemPO.getSalaryItemId()) + .formulaId(salarySobBackItemPO.getFormulaId()) + .formulaContent(expressFormulaContentMap.getOrDefault(salarySobBackItemPO.getFormulaId(), "输入")) + .dataType(Optional.ofNullable(salaryItemPO).map(SalaryItemPO::getDataType).orElse("")) + .sortedIndex(0) + .canEdit(true) + .canDelete(false) + .backCalcType(Objects.equals(backCalcType,0) ? "issuedItems" :"reissueItems").build(); + }).collect(Collectors.toList()); + } + + + public SalarySobBackItemFormDTO getForm(Long salarySobBackItemId) { + // 查询薪资账套的薪资回算项目 + SalarySobBackItemPO salarySobBackItem = getSalarySobBackItemService(user).getById(salarySobBackItemId); + // 查询薪资项目 + SalaryItemPO salaryItem = getSalaryItemService(user).getById(salarySobBackItem.getSalaryItemId()); + // 查询公式 + ExpressFormula expressFormula = getSalaryFormulaService(user).getExpressFormula(salarySobBackItem.getFormulaId()); + // 转换为dto + + HashMap map = new HashMap<>(); + map.put("id",Util.null2String(salaryItem.getId())); + map.put("name",salaryItem.getName()); + SalarySobBackItemFormDTO salarySobBackItemFormDTO = SalarySobBackItemFormDTO.builder() + .id(salarySobBackItem.getId()) + .salaryItem( Collections.singletonList(map)) + .dataType(SalaryDataTypeEnum.parseByValue(salaryItem.getDataType())) + .roundingMode(SalaryRoundingModeEnum.parseByValue(salarySobBackItem.getRoundingMode())) + .pattern(Util.null2String(salarySobBackItem.getPattern())) + .valueType(SalaryValueTypeEnum.parseByValue(salarySobBackItem.getValueType())) + .formulaId(salarySobBackItem.getFormulaId()) + .formulaContent(expressFormula == null ? "" : expressFormula.getFormula()) + .taxDeclarationColumn(SalaryItemBO.buildTaxDeclarationColumn(salaryItem.getCode())).build(); + return salarySobBackItemFormDTO; + } + + public List save(SalarySobBackItemSaveParam saveParam) { + return getSalarySobBackItemService(user).save(saveParam); + } +} diff --git a/src/com/engine/salary/wrapper/SalarySobCheckRuleWrapper.java b/src/com/engine/salary/wrapper/SalarySobCheckRuleWrapper.java new file mode 100644 index 000000000..d607c8b37 --- /dev/null +++ b/src/com/engine/salary/wrapper/SalarySobCheckRuleWrapper.java @@ -0,0 +1,124 @@ +package com.engine.salary.wrapper; + +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.entity.salaryformula.ExpressFormula; +import com.engine.salary.entity.salarysob.bo.SalarySobCheckRuleBO; +import com.engine.salary.entity.salarysob.dto.SalarySobCheckRuleFormDTO; +import com.engine.salary.entity.salarysob.dto.SalarySobCheckRuleListDTO; +import com.engine.salary.entity.salarysob.param.SalarySobCheckRuleQueryParam; +import com.engine.salary.entity.salarysob.param.SalarySobCheckRuleSaveParam; +import com.engine.salary.entity.salarysob.param.UpdateCheckRuleFormulaParam; +import com.engine.salary.entity.salarysob.po.SalarySobCheckRulePO; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.service.SalaryFormulaService; +import com.engine.salary.service.SalarySobCheckRuleService; +import com.engine.salary.service.impl.SalarySobCheckRuleServiceImpl; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.page.PageInfo; +import weaver.hrm.User; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Objects; + +/** + * 薪资账套的校验规则 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SalarySobCheckRuleWrapper extends Service { + + + private SalarySobCheckRuleService getSalarySobCheckRuleService(User user) { + return (SalarySobCheckRuleService) ServiceUtil.getService(SalarySobCheckRuleServiceImpl.class, user); + } + + + private SalaryFormulaService salaryFormulaService; + + /** + * 薪资账套的校验规则列表 + * + * @param queryParam 列表查询条件 + * @return + */ + public PageInfo listPage(SalarySobCheckRuleQueryParam queryParam) { + // 分页查询薪资账套的校验规则 + PageInfo page = getSalarySobCheckRuleService(user).listPageByParam(queryParam); + // todo 查询公式详情 +// Set formulaIds = SalaryEntityUtil.properties(page.getList(), SalarySobCheckRulePO::getFormulaId); +// List expressFormulas = salaryFormulaService.listExpressFormula(formulaIds); + // 转换成dto + List salarySobCheckRuleListDTOS = SalarySobCheckRuleBO.convert2ListDTO(page.getList(), new ArrayList<>()); + // 转换成前端所需的数据格式 + PageInfo dtoPage = new PageInfo<>(salarySobCheckRuleListDTOS, SalarySobCheckRuleListDTO.class); + dtoPage.setPageSize(page.getPageSize()); + dtoPage.setPageNum(page.getPageNum()); + dtoPage.setTotal(page.getTotal()); + return dtoPage; + } + + /** + * 薪资账套的校验规则详情 + * + * @param id 校验规则的id + * @return + */ + public SalarySobCheckRuleFormDTO getForm(Long id) { + SalarySobCheckRuleFormDTO checkRuleFormDTO = new SalarySobCheckRuleFormDTO(); + if (!Objects.isNull(id)) { + // 查询校验规则 + SalarySobCheckRulePO salarySobCheckRulePO = getSalarySobCheckRuleService(user).getById(id); + if (Objects.isNull(salarySobCheckRulePO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98636, "校验规则不存在或者已被删除")); + } + // 查询公式详情 + ExpressFormula expressFormula = salaryFormulaService.getExpressFormula(salarySobCheckRulePO.getFormulaId()); + // 转换成详情dto + checkRuleFormDTO = SalarySobCheckRuleBO.convert2FormDTO(salarySobCheckRulePO, expressFormula); + } + // 转换成前端所需的数据格式 + return checkRuleFormDTO; + } + + /** + * 保存 + * + * @param saveParam 保存参数 + */ + public void save(SalarySobCheckRuleSaveParam saveParam) { + getSalarySobCheckRuleService(user).save(saveParam); + } + + /** + * 更新 + * + * @param updateParam 更新参数 + */ + public void update(SalarySobCheckRuleSaveParam updateParam) { + getSalarySobCheckRuleService(user).update(updateParam); + } + + /** + * 更新校验规则的公式 + * + * @param updateParam 更新参数 + */ + public void updateFormulaId(UpdateCheckRuleFormulaParam updateParam) { + getSalarySobCheckRuleService(user).updateFormulaId(updateParam); + } + + /** + * 删除 + * + * @param ids 校验规则的id + */ + public void delete(Collection ids) { + getSalarySobCheckRuleService(user).deleteByIds(ids); + } +} diff --git a/src/com/engine/salary/wrapper/SalarySobItemWrapper.java b/src/com/engine/salary/wrapper/SalarySobItemWrapper.java new file mode 100644 index 000000000..d8bece097 --- /dev/null +++ b/src/com/engine/salary/wrapper/SalarySobItemWrapper.java @@ -0,0 +1,180 @@ +package com.engine.salary.wrapper; + +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.annotation.SalaryFormulaVar; +import com.engine.salary.entity.salaryformula.ExpressFormula; +import com.engine.salary.entity.salaryformula.dto.SalaryFormulaEmployeeDTO; +import com.engine.salary.entity.salaryitem.bo.SalaryItemBO; +import com.engine.salary.entity.salaryitem.dto.SalaryItemSobListDTO; +import com.engine.salary.entity.salaryitem.param.SalaryItemSearchParam; +import com.engine.salary.entity.salaryitem.po.SalaryItemPO; +import com.engine.salary.entity.salaryitem.po.SysSalaryItemPO; +import com.engine.salary.entity.salarysob.dto.SalarySobItemAggregateDTO; +import com.engine.salary.entity.salarysob.dto.SalarySobItemFormDTO; +import com.engine.salary.entity.salarysob.param.SalarySobItemSaveParam; +import com.engine.salary.entity.salarysob.po.SalarySobItemGroupPO; +import com.engine.salary.entity.salarysob.po.SalarySobItemPO; +import com.engine.salary.entity.taxagent.param.TaxAgentQueryParam; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import com.engine.salary.enums.auth.AuthFilterTypeEnum; +import com.engine.salary.service.*; +import com.engine.salary.service.impl.*; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.util.page.SalaryPageUtil; +import com.google.common.collect.Maps; +import org.apache.commons.collections4.CollectionUtils; +import weaver.hrm.User; + +import java.lang.reflect.Field; +import java.util.*; +import java.util.stream.Collectors; + +/** + * 薪资账套的薪资项目 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SalarySobItemWrapper extends Service { + + private SalarySobItemService getSalarySobItemService(User user) { + return ServiceUtil.getService(SalarySobItemServiceImpl.class, user); + } + + private SalarySobItemGroupService getSalarySobItemGroupService(User user) { + return ServiceUtil.getService(SalarySobItemGroupServiceImpl.class, user); + } + + private TaxAgentService getTaxAgentService(User user) { + return ServiceUtil.getService(TaxAgentServiceImpl.class, user); + } + + private SalaryItemService getSalaryItemService(User user) { + return ServiceUtil.getService(SalaryItemServiceImpl.class, user); + } + + + private SalaryFormulaService getSalaryFormulaService(User user) { + return ServiceUtil.getService(SalaryFormulaServiceImpl.class, user); + } + + private SysSalaryItemService getSysSalaryItemService(User user) { + return ServiceUtil.getService(SysSalaryItemServiceImpl.class, user); + } + + /** + * 薪资账套可选薪资项目列表 + * + * @param queryParam 列表查询条件 + * @return + */ + public PageInfo listPage4SalaryItem(SalaryItemSearchParam queryParam) { + Integer searchPageSize = queryParam.getPageSize(); + Integer searchCurrent = queryParam.getCurrent(); + + List salaryItemList = getSalaryItemService(user).listByParam(queryParam); + + TaxAgentQueryParam param = TaxAgentQueryParam.builder().build(); + param.setFilterType(AuthFilterTypeEnum.QUERY_DATA); + Set taxAgentIds = getTaxAgentService(user).listAuth(param).stream().map(TaxAgentPO::getId).collect(Collectors.toSet()); + + salaryItemList = salaryItemList.stream() + .filter(po -> getSalaryItemService(user).filterInRange(taxAgentIds, po)) + .collect(Collectors.toList()); + + // 薪资项目排序:薪资项目放在前面(首先按照设置的排序,没有设置按照id倒序,系统薪资项目放在最后),档案字段放在后面 + salaryItemList = salaryItemList.stream() + .sorted(new Comparator() { + @Override + public int compare(SalaryItemPO o1, SalaryItemPO o2) { + return Integer.compare(o1.getUseInEmployeeSalary(),o2.getUseInEmployeeSalary()); + } + }) + .collect(Collectors.toList()); + + + //最终返回的分页对象 + PageInfo dtoPage = new PageInfo<>(SalaryItemSobListDTO.class); + dtoPage.setPageSize(searchPageSize); + dtoPage.setPageNum(searchCurrent); + dtoPage.setTotal(salaryItemList.size()); + List list = SalaryPageUtil.buildPage(searchCurrent, searchPageSize, salaryItemList).getList(); + if (CollectionUtils.isNotEmpty(list)) { + // 查询公式 + Set formulaIds = SalaryEntityUtil.properties(list, SalaryItemPO::getFormulaId); + List expressFormulas = getSalaryFormulaService(user).listExpressFormula(formulaIds); + // 查询系统薪资项目 + Set sysSalaryItemIds = SalaryEntityUtil.properties(list, SalaryItemPO::getSysSalaryItemId); + List sysSalaryItemPOS = getSysSalaryItemService(user).listByIds(sysSalaryItemIds); + // 转换成薪资项目列表dto + dtoPage.setList(SalaryItemBO.convert2itemSobListDTO(list, expressFormulas, sysSalaryItemPOS)); + } + return dtoPage; + + } + /** + * 获取薪资账套的薪资项目详情 + * + * @param salarySobItemGroupId 薪资账套的薪资项目的id + * @return + */ + public SalarySobItemGroupPO getGroupForm(Long salarySobItemGroupId) { + return getSalarySobItemGroupService(user).getById(salarySobItemGroupId); + } + + /** + * 获取薪资账套的薪资项目详情 + * + * @param salarySobId 薪资账套的id + * @return + */ + public SalarySobItemAggregateDTO getForm(Long salarySobId) { + return getSalarySobItemService(user).getAggregateBySalarySobId(salarySobId); + } + + /** + * 保存 + * + * @param saveParam 保存参数 + */ + public void save(SalarySobItemSaveParam saveParam) { + getSalarySobItemService(user).save(saveParam); + } + + + /** + * 基础信息浏览按钮(下拉框) + * + * @return + */ + public Collection> empFieldList() { + Field[] declaredFields = SalaryFormulaEmployeeDTO.class.getDeclaredFields(); + Map empFieldMap = Maps.newHashMapWithExpectedSize(declaredFields.length); + List> list = new ArrayList(); + for (Field declaredField : declaredFields) { + Map item = new HashMap<>(); + if (!declaredField.isAnnotationPresent(SalaryFormulaVar.class)) { + continue; + } + SalaryFormulaVar annotation = declaredField.getAnnotation(SalaryFormulaVar.class); + empFieldMap.put(declaredField.getName(), SalaryI18nUtil.getI18nLabel(annotation.labelId(), annotation.defaultLabel())); + item.put("name", SalaryI18nUtil.getI18nLabel(annotation.labelId(), annotation.defaultLabel())); + item.put("id", declaredField.getName()); + list.add(item); + } + return list; + } + + /** + * 薪资项目的详情 + */ + public SalarySobItemFormDTO getSalaryItemForm(SalarySobItemPO param) { + return getSalarySobItemService(user).getSalaryItemForm(param); + } + +} diff --git a/src/com/engine/salary/wrapper/SalarySobRangeWrapper.java b/src/com/engine/salary/wrapper/SalarySobRangeWrapper.java new file mode 100644 index 000000000..1ae272efc --- /dev/null +++ b/src/com/engine/salary/wrapper/SalarySobRangeWrapper.java @@ -0,0 +1,192 @@ +package com.engine.salary.wrapper; + +import cn.hutool.core.util.StrUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.entity.SalarySobExtRangePO; +import com.engine.salary.entity.salarysob.dto.SalarySobRangeListDTO; +import com.engine.salary.entity.salarysob.param.SalarySobRangeExtSaveParam; +import com.engine.salary.entity.salarysob.param.SalarySobRangeImportParam; +import com.engine.salary.entity.salarysob.param.SalarySobRangeQueryParam; +import com.engine.salary.entity.salarysob.param.SalarySobRangeSaveParam; +import com.engine.salary.service.SalarySobExtRangeService; +import com.engine.salary.service.SalarySobRangeService; +import com.engine.salary.service.impl.SalarySobExtRangeServiceImpl; +import com.engine.salary.service.impl.SalarySobRangeServiceImpl; +import com.engine.salary.util.page.PageInfo; +import org.apache.commons.lang.math.NumberUtils; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import weaver.hrm.User; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Map; +import java.util.Optional; + +/** + * 薪资账套的人员范围 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SalarySobRangeWrapper extends Service { + + private SalarySobRangeService getSalarySobRangeService(User user) { + return ServiceUtil.getService(SalarySobRangeServiceImpl.class, user); + } + + private SalarySobExtRangeService getSalarySobExtRangeService(User user) { + return ServiceUtil.getService(SalarySobExtRangeServiceImpl.class, user); + } + + /** + * 薪资账套的人员范围列表(关联人员范围) + * + * @param queryParam 列表查询条件 + * @return + */ + public PageInfo listPage4Include(SalarySobRangeQueryParam queryParam) { + return getSalarySobRangeService(user).listPageByParamAndIncludeType(queryParam, NumberUtils.INTEGER_ONE); + } + + /** + * 薪资账套的人员范围列表(从范围中排除) + * + * @param queryParam 列表查询条件 + * @return + */ + public PageInfo listPage4Exclude(SalarySobRangeQueryParam queryParam) { + return getSalarySobRangeService(user).listPageByParamAndIncludeType(queryParam, NumberUtils.INTEGER_ZERO); + } + + /** + * 获取薪资账套的人员范围列表添加人员的表单 + * + * @return + */ +// public WeaForm getForm() { +// return SalaryFormatUtil.getInstance().buildForm(SalarySobRangeFormDTO.class, new SalarySobRangeFormDTO()); +// } + + /** + * 保存 + * + * @param saveParam 保存参数 + */ + public void save(SalarySobRangeSaveParam saveParam) { + Optional.ofNullable(saveParam.getTargetParams()).orElse(new ArrayList<>()) + .forEach(targetParam -> { + if (StrUtil.isNotBlank(targetParam.getTarget())) { + targetParam.setTarget(targetParam.getTarget() + .replace("select", "select") + .replace("SELECT", "SELECT") + .replace("join", "join") + .replace("JOIN", "JOIN") + .replace("and", "and") + .replace("AND", "AND") + .replace("or", "or") + .replace("OR", "OR") + .replace("in", "in") + .replace("IN", "IN") + .replace("like", "like") + .replace("LIKE", "LIKE") + .replace("exists", "exists") + .replace("EXISTS", "EXISTS") + .replace("between", "between") + .replace("BETWEEN", "BETWEEN") + .replace("union", "union") + .replace("UNION", "UNION")); + } + }); + + getSalarySobRangeService(user).save(saveParam); + } + + + public void edit(SalarySobRangeSaveParam param) { + Optional.ofNullable(param.getTargetParams()).orElse(new ArrayList<>()) + .forEach(targetParam -> { + if (StrUtil.isNotBlank(targetParam.getTarget())) { + targetParam.setTarget(targetParam.getTarget() + .replace("select", "select") + .replace("SELECT", "SELECT") + .replace("join", "join") + .replace("JOIN", "JOIN") + .replace("and", "and") + .replace("AND", "AND") + .replace("or", "or") + .replace("OR", "OR") + .replace("in", "in") + .replace("IN", "IN") + .replace("like", "like") + .replace("LIKE", "LIKE") + .replace("exists", "exists") + .replace("EXISTS", "EXISTS") + .replace("between", "between") + .replace("BETWEEN", "BETWEEN") + .replace("union", "union") + .replace("UNION", "UNION")); + } + }); + + getSalarySobRangeService(user).edit(param); + } + + /** + * 保存 + * + * @param saveParam 保存参数 + */ + public void saveExtRange(SalarySobRangeExtSaveParam saveParam) { + getSalarySobExtRangeService(user).saveExtRange(saveParam); + } + + public PageInfo listPage4Ext(SalarySobRangeQueryParam param) { + return getSalarySobExtRangeService(user).listPage4Ext(param); + } + + /** + * 删除 + * + * @param ids 薪资账套的人员范围的主键id + */ + public void delete(Collection ids) { + getSalarySobRangeService(user).deleteByIds(ids); + } + + public void deleteSalarySobExtRange(Collection ids) { + getSalarySobExtRangeService(user).deleteSalarySobExtRange(ids); + } + + /*** + * @description 下载薪资账套人员范围导入模板 + * @return XSSFWorkbook + * @author Harryxzy + * @date 2023/1/9 11:32 + */ + public XSSFWorkbook exportImportTemplate() { + return getSalarySobRangeService(user).downloadTemplateRange(); + } + + /** + * @return void + * @description 薪资账套人员范围导入预览 + * @author Harryxzy + * @date 2023/1/9 13:37 + */ + public Map preview(SalarySobRangeImportParam importParam) { + return getSalarySobRangeService(user).preview(importParam); + } + + /** + * @return Map + * @description 导入薪资账套人员范围 + * @author Harryxzy + * @date 2023/1/9 14:10 + */ + public Map importData(SalarySobRangeImportParam importParam) { + return getSalarySobRangeService(user).importData(importParam); + } +} diff --git a/src/com/engine/salary/wrapper/SalarySobWrapper.java b/src/com/engine/salary/wrapper/SalarySobWrapper.java new file mode 100644 index 000000000..68722cffa --- /dev/null +++ b/src/com/engine/salary/wrapper/SalarySobWrapper.java @@ -0,0 +1,299 @@ +package com.engine.salary.wrapper; + +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.constant.SalaryDefaultTenantConstant; +import com.engine.salary.entity.salaryitem.bo.SysSalaryItemBO; +import com.engine.salary.entity.salaryitem.po.SalaryItemPO; +import com.engine.salary.entity.salaryitem.po.SysSalaryItemPO; +import com.engine.salary.entity.salarysob.bo.SalarySobBO; +import com.engine.salary.entity.salarysob.bo.SalarySobBackItemBO; +import com.engine.salary.entity.salarysob.dto.SalarySobBasicFormDTO; +import com.engine.salary.entity.salarysob.dto.SalarySobListDTO; +import com.engine.salary.entity.salarysob.param.*; +import com.engine.salary.entity.salarysob.po.SalarySobBackItemPO; +import com.engine.salary.entity.salarysob.po.SalarySobDefaultBackItemPO; +import com.engine.salary.entity.salarysob.po.SalarySobPO; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import com.engine.salary.enums.auth.AuthFilterTypeEnum; +import com.engine.salary.enums.salarysob.IncomeCategoryEnum; +import com.engine.salary.enums.sicategory.DeleteTypeEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.service.*; +import com.engine.salary.service.auth.AuthService; +import com.engine.salary.service.auth.AuthServiceImpl; +import com.engine.salary.service.impl.*; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.SalarySobUtil; +import com.engine.salary.util.db.IdGenerator; +import com.engine.salary.util.page.PageInfo; +import org.apache.commons.collections4.CollectionUtils; +import weaver.hrm.User; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * 薪资账套 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SalarySobWrapper extends Service { + + + public SalarySobService getSalarySobService(User user) { + return ServiceUtil.getService(SalarySobServiceImpl.class, user); + } + + + private TaxAgentService getTaxAgentService(User user) { + return ServiceUtil.getService(TaxAgentServiceImpl.class, user); + } + + private SalarySobBackItemService getSalarySobBackItemService(User user) { + return ServiceUtil.getService(SalarySobBackItemServiceImpl.class, user); + } + + private SalaryItemService getSalaryItemService(User user) { + return ServiceUtil.getService(SalaryItemServiceImpl.class, user); + } + + private SysSalaryItemService getSysSalaryItemService(User user) { + return ServiceUtil.getService(SysSalaryItemServiceImpl.class, user); + } + + private SalarySobItemService getSalarySobItemService(User user) { + return ServiceUtil.getService(SalarySobItemServiceImpl.class, user); + } + + public AuthService getAuthService(User user) { + return ServiceUtil.getService(AuthServiceImpl.class, user); + } + + /** + * 薪资账套列表 + * + * @param queryParam 列表查询参数 + * @return + */ + public PageInfo listPage(SalarySobListQueryParam queryParam) { + + // 处理历史数据,将薪资账套中将关联人员状态转换为List + SalarySobUtil.handleEmployeeStatusHistory(); + getSalarySobService(user).handleHistory(); + + + // 查询薪资账套 + PageInfo page = getSalarySobService(user).listPageByParam(queryParam); + // 薪资账套po转换成薪资账套列表dto + List taxAgentPOS = getTaxAgentService(user).listAll(); + + + List salarySobListDTOS = page.getList().stream() + .map(salarySobPO -> { + List taxAgentIds = salarySobPO.getTaxAgentIds(); + String taxAgentName = taxAgentPOS.stream().filter(po -> taxAgentIds.contains(po.getId())).map(TaxAgentPO::getName).collect(Collectors.joining(",")); + return SalarySobListDTO.builder() + .id(salarySobPO.getId()) + .name(salarySobPO.getName()) + .taxAgentName(taxAgentName) + .taxAgentIds(taxAgentIds) + .salaryCycle(SalarySobBO.buildSalaryCycle(salarySobPO)) + .disable(salarySobPO.getDisable()) + .description(salarySobPO.getDescription()) + .opts(salarySobPO.getOpts()) + .build(); + + }) + .collect(Collectors.toList()); + + + PageInfo dtoPage = new PageInfo<>(salarySobListDTOS, SalarySobListDTO.class); + dtoPage.setTotal(page.getTotal()); + dtoPage.setPageNum(page.getPageNum()); + dtoPage.setPageSize(page.getPageSize()); + // 处理历史数据,为薪资账套默认添加回算薪资项目 + handleSalarySobBackItemHistory(queryParam); + // 转换成前端所需的数据格式 + return dtoPage; + } + + + /** + * 薪资账套列表 + * + * @return + */ + public List listAll() { + return getSalarySobService(user).listAll(); + } + + /** + * 薪资账套列表(分权) + * + * @return + */ + public List listAuth(SalarySobQueryParam param) { + return getSalarySobService(user).listAuth(param); + } + + private void handleSalarySobBackItemHistory(SalarySobListQueryParam queryParam) { + queryParam.setPageSize(100000); + List list = getSalarySobService(user).listPageByParam(queryParam).getList(); + if (list != null && list.size() > 0) { + List salarySobIds = list.stream().map(SalarySobPO::getId).collect(Collectors.toList()); + Long count = getSalarySobBackItemService(user).getCountBySalarySobIdIn(salarySobIds); + if (count.equals(0L)) { + // 薪资账套的默认的回算薪资项目 + Set SalarySobBackItemIds = SalaryEntityUtil.properties(SalarySobBackItemBO.getDefault(), SalarySobDefaultBackItemPO::getSysSalaryItemId); + // 获取薪资项目中是否已经添加回算薪资项目 + List salaryItemPOS = getSalaryItemService(user).listBySysSalaryItemIds(SalarySobBackItemIds); + Set salaryBackItemSysIds = SalaryEntityUtil.properties(salaryItemPOS, SalaryItemPO::getSysSalaryItemId); + // 需要添加进薪资项目中的回算薪资项目 + List needAddSalaryBackItemIds = SalarySobBackItemIds.stream().filter(salarySobBackItemId -> !salaryBackItemSysIds.contains(salarySobBackItemId)).collect(Collectors.toList()); + List needAddSysSalaryBackItemPOS = getSysSalaryItemService(user).listByIds(needAddSalaryBackItemIds); + // 需要保存的回算薪资项目 + List needInsertSalaryItemPOS = SysSalaryItemBO.convert2SalaryItemPO(needAddSysSalaryBackItemPOS, (long) user.getUID()); + if (CollectionUtils.isNotEmpty(needInsertSalaryItemPOS)) { + getSalaryItemService(user).batchSave(needInsertSalaryItemPOS); + } + // 没有回算薪资项目数据,给所有薪资账套添加默认回算薪资项目 + List salarySobBackItems = new ArrayList<>(); + // 获取默认添加后的回算薪资项目 + List salaryBackItemPOS = getSalaryItemService(user).listBySysSalaryItemIds(SalarySobBackItemIds); + for (Long id : salarySobIds) { + for (SalarySobDefaultBackItemPO salarySobDefaultBackItemPO : SalarySobBackItemBO.getDefault()) { + Date now = new Date(); + Map sysSalaryItemMap = SalaryEntityUtil.convert2Map(salaryBackItemPOS, SalaryItemPO::getSysSalaryItemId); + SalaryItemPO salaryItemPO = sysSalaryItemMap.get(salarySobDefaultBackItemPO.getSysSalaryItemId()); + SalarySobBackItemPO salarySobBackItemPO = SalarySobBackItemPO.builder() + .id(IdGenerator.generate()) + .salarySobId(id) + .salaryItemId(salaryItemPO.getId()) + .salaryItemCode(salaryItemPO.getCode()) + .dataType(salaryItemPO.getDataType()) + .roundingMode(salaryItemPO.getRoundingMode()) + .pattern(salaryItemPO.getPattern()) + .valueType(salaryItemPO.getValueType()) + .formulaId(salarySobDefaultBackItemPO.getFormulaId()) + .backCalcType(salarySobDefaultBackItemPO.getBackCalcType()) + .creator((long) user.getUID()) + .createTime(now) + .updateTime(now) + .deleteType(DeleteTypeEnum.NOT_DELETED.getValue()) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY).build(); + salarySobBackItems.add(salarySobBackItemPO); + } + } + // 入库 + getSalarySobBackItemService(user).batchInsert(salarySobBackItems); + } + } + + } + + /** + * 薪资账套详情 + * + * @param id 薪资账套id + * @return + */ + public Map getForm(Long id) { + long employeeId = user.getUID(); + Map data = new HashMap<>(16); + + // 是否可以编辑(分权后,总管理员不可以编辑管理员新建的账套) + boolean canEdit = Objects.isNull(id) || canEdit(id, employeeId); + + // 薪资账套基础设置详情(目前核算人员范围的值固定为"1") + SalarySobBasicFormDTO basicForm = new SalarySobBasicFormDTO() + .setEmployeeRange("1") + .setTaxableItems(IncomeCategoryEnum.WAGES_AND_SALARIES.getValue()) + .setCanEdit(canEdit); + if (!Objects.isNull(id)) { + // 查询薪资账套 + SalarySobPO salarySobPO = getSalarySobService(user).getById(id); + if (Objects.isNull(salarySobPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98379, "参数错误,薪资账套不存在或者已被删除")); + } + // 薪资装套po转换成薪资账套详情dto + basicForm = SalarySobBO.convert2FormDTO(basicForm, salarySobPO); + } + // 转换成前端所需的数据格式 + data.put("basicForm", basicForm); + return data; + + } + + /** + * 保存 + * + * @param saveParam 保存参数 + * @return + */ + public Long save(SalarySobBasicSaveParam saveParam) { + return getSalarySobService(user).save(saveParam); + } + + /** + * 更新薪资账套的基础设置 + * + * @param saveParam 更新参数 + * @return + */ + public Long update(SalarySobBasicSaveParam saveParam) { + return getSalarySobService(user).update(saveParam); + } + + /** + * 启用/禁用薪资账套 + * + * @param disableParam 更新参数 + */ + public void updateDisable(SalarySobDisableParam disableParam) { + getSalarySobService(user).updateDisable(disableParam); + } + + /** + * 删除薪资账套 + * + * @param ids 薪资账套的id + */ + public void delete(Collection ids) { + getSalarySobService(user).deleteByIds(ids); + } + + /** + * 复制 + * + * @param duplicateParam 复制参数 + */ + public void duplicate(SalarySobDuplicateParam duplicateParam) { + getSalarySobService(user).duplicate(duplicateParam); + } + + /** + * 判断是否可以编辑薪资账套 + * + * @param id + * @param employeeId + * @return + */ + public boolean canEdit(Long id, Long employeeId) { + // 查询薪资账套 + SalarySobPO salarySobPO = getSalarySobService(user).getById(id); + if (Objects.isNull(salarySobPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98379, "参数错误,薪资账套不存在或者已被删除")); + } + + return getAuthService(user).auth(salarySobPO, AuthFilterTypeEnum.DATA_OPT, SalarySobPO.class); + } + + public List listByTaxAgent(SalarySobQueryParam param) { + return getSalarySobService(user).list(param); + } +} diff --git a/src/com/engine/salary/wrapper/SalarySystemConfigWrapper.java b/src/com/engine/salary/wrapper/SalarySystemConfigWrapper.java new file mode 100644 index 000000000..d6a2c3f3c --- /dev/null +++ b/src/com/engine/salary/wrapper/SalarySystemConfigWrapper.java @@ -0,0 +1,301 @@ +package com.engine.salary.wrapper; + +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.cache.SalaryCacheKey; +import com.engine.salary.entity.config.SalaryConfig; +import com.engine.salary.entity.salaryarchive.config.ArchiveFieldConfig; +import com.engine.salary.entity.salaryitem.config.SalaryItemAllConfig; +import com.engine.salary.entity.taxagent.config.TaxAgentConfig; +import com.engine.salary.entity.taxagent.po.TaxAgentBasePO; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.service.*; +import com.engine.salary.service.impl.*; +import com.engine.salary.sys.config.SysConfig; +import com.engine.salary.sys.entity.param.*; +import com.engine.salary.sys.entity.po.SalarySysConfPO; +import com.engine.salary.sys.entity.vo.AppSettingVO; +import com.engine.salary.sys.entity.vo.OrderRuleVO; +import com.engine.salary.sys.entity.vo.UploadConfigResponse; +import com.engine.salary.sys.enums.TaxDeclarationFunctionEnum; +import com.engine.salary.sys.service.SalarySysConfService; +import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.util.page.SalaryPageUtil; +import com.engine.salary.util.valid.RuntimeTypeEnum; +import com.engine.salary.util.valid.ValidUtil; +import com.engine.salary.util.xml.XStreamUtil; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.apache.poi.util.IOUtils; +import weaver.file.ImageFileManager; +import weaver.general.BaseBean; +import weaver.hrm.User; + +import java.io.BufferedReader; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.Reader; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 累计专项附加扣除 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Slf4j +public class SalarySystemConfigWrapper extends Service { + + private SalarySysConfService getSalarySysConfService(User user) { + return ServiceUtil.getService(SalarySysConfServiceImpl.class, user); + } + + private SalaryItemService getSalaryItemService(User user) { + return ServiceUtil.getService(SalaryItemServiceImpl.class, user); + } + + private SalaryArchiveItemService getSalaryArchiveItemService(User user) { + return ServiceUtil.getService(SalaryArchiveItemServiceImpl.class, user); + } + + private TaxAgentService getTaxAgentService(User user) { + return ServiceUtil.getService(TaxAgentServiceImpl.class, user); + } + + private SalaryFormulaService getSalaryFormulaService(User user) { + return ServiceUtil.getService(SalaryFormulaServiceImpl.class, user); + } + + private TaxAgentBaseService getTaxAgentBaseService(User user) { + return ServiceUtil.getService(TaxAgentBaseServiceImpl.class, user); + } + + private SalaryCacheService getSalaryCacheService(User user) { + return ServiceUtil.getService(SalaryCacheServiceImpl.class, user); + } + + public Map info() { + BaseBean baseBean = new BaseBean(); + String log = baseBean.getPropValue("hrmSalary", "log"); + String version = baseBean.getPropValue("hrmSalary", "version"); + String openFormulaForcedEditing = baseBean.getPropValue("hrmSalary", "openFormulaForcedEditing"); + String showEncryptOperationButton = baseBean.getPropValue("hrmSalary", "showEncryptOperationButton"); + + Map o = new HashMap<>(); + o.put("log", log); + o.put("version", version); + o.put("openFormulaForcedEditing", openFormulaForcedEditing); + o.put("showEncryptOperationButton", showEncryptOperationButton); + + + List confPOS = getSalarySysConfService(user).listSome(SalarySysConfPO.builder().build()); + Map map = SalaryEntityUtil.convert2Map(confPOS, SalarySysConfPO::getConfKey, SalarySysConfPO::getConfValue); + o.putAll(map); + return o; + } + + /** + * 操作是否需要申报功能 + * + * @param flag 开启 0/关闭 1/重新开启 2 + * @return 执行结果 + */ + public boolean operateTaxDeclarationFunction(TaxDeclarationFunctionEnum flag) { + return getSalarySysConfService(user).operateTaxDeclarationFunction(flag); + } + + /** + * 获取单一配置 + * + * @param code + * @return + */ + public String getOneByCode(String code) { + SalarySysConfPO one = getSalarySysConfService(user).getOneByCode(code); + if (one != null) { + return one.getConfValue(); + } else { + return StringUtils.EMPTY; + } + } + + + public PageInfo list(SalarySysConfQueryParam param) { + List salarySysConfPOS = getSalarySysConfService(user).listSome(SalarySysConfPO.builder().build()); + + List list = SalaryPageUtil.subList(param.getCurrent(), param.getPageSize(), salarySysConfPOS); + PageInfo page = new PageInfo<>(list, SalarySysConfPO.class); + + page.setTotal(salarySysConfPOS.size()); + page.setPageNum(param.getCurrent()); + page.setPageSize(param.getPageSize()); + return page; + } + + + public void save(SalarySysConfPO salarySysConfPO) { + ValidUtil.doValidator(salarySysConfPO); + getSalarySysConfService(user).save(salarySysConfPO); + } + + public void update(SalarySysConfPO salarySysConfPO) { + ValidUtil.doValidator(salarySysConfPO, RuntimeTypeEnum.UPDATE); + getSalarySysConfService(user).update(salarySysConfPO); + } + + public SalarySysConfPO detail(Long id) { + return getSalarySysConfService(user).getById(id); + } + + public void updateByCode(SalarySysConfPO salarySysConfPO) { + getSalarySysConfService(user).updateByCode(salarySysConfPO); + } + + public void updateOrderRule(OrderRuleParam param) { + getSalarySysConfService(user).updateOrderRule(param); + } + + public OrderRuleVO orderRule() { + return getSalarySysConfService(user).orderRule(); + } + + public void saveMatchEmployeeModeRule(MatchEmployeeModeSaveParam param) { + ValidUtil.doValidator(param); + getSalarySysConfService(user).saveMatchEmployeeModeRule(param.getRule()); + } + + public void saveAppSetting(AppSettingSaveParam param) { + ValidUtil.doValidator(param); + getSalarySysConfService(user).saveAppSetting(param); + } + + public AppSettingVO appSetting() { + + return getSalarySysConfService(user).appSetting(); + + } + + public Map saveEncryptSetting(AppSettingSaveParam param) { + return getSalarySysConfService(user).saveEncryptSetting(param); + } + + public Map getEncryptProgress(String progressId) { + return getSalarySysConfService(user).getEncryptProgress(progressId); + } + + public void saveSalaryAcctEmployeeRule(String rule) { + getSalarySysConfService(user).saveSalaryAcctEmployeeRule(rule); + } + + public void saveWithDrawTaxDeclaration(SalarySysConfPO param) { + getSalarySysConfService(user).saveWithDrawTaxDeclaration(param); + } + + public void saveArchiveDelete(String setting) { + getSalarySysConfService(user).saveArchiveDelete(setting); + } + + public void operate(SalarySysConfPO salarySysConfPO) { + getSalarySysConfService(user).operate(salarySysConfPO); + } + + public void saveSalarySendFeedback(SalarySysConfPO param) { + getSalarySysConfService(user).saveSalarySendFeedback(param); + } + + + public SalaryConfig downloadConfig() { + Boolean chief = getTaxAgentService(user).isChief((long) user.getUID()); + if (!chief) { + throw new SalaryRunTimeException("您不是薪酬总管理员,无法迁入出配置!"); + } + + + SalaryConfig salaryConfig = new SalaryConfig(); + SysConfig sysConfig = getSalarySysConfService(user).getConfig(); + salaryConfig.setSysConfig(sysConfig); + +// FormluaConfig formluaConfig = getSalaryFormulaService(user).getConfig(); +// salaryConfig.setFormluaConfig(formluaConfig); + + SalaryItemAllConfig salaryItemConfig = getSalaryItemService(user).getConfig(); + salaryConfig.setSalaryItemConfig(salaryItemConfig); + + ArchiveFieldConfig archiveFieldConfig = getSalaryArchiveItemService(user).getConfig(); + salaryConfig.setArchiveFieldConfig(archiveFieldConfig); + + TaxAgentBasePO taxAgentBaseConfig = getTaxAgentBaseService(user).getConfig(); + salaryConfig.setTaxAgentBaseConfig(taxAgentBaseConfig); + + List taxAgentConfigs = getTaxAgentService(user).getConfig(); + salaryConfig.setTaxAgentConfigs(taxAgentConfigs); + + return salaryConfig; + } + + public UploadConfigResponse uploadConfig(UploadConfigParam param) { + Boolean chief = getTaxAgentService(user).isChief((long) user.getUID()); + if (!chief) { + throw new SalaryRunTimeException("您不是薪酬总管理员,无法迁入配置!"); + } + + UploadConfigResponse lastResponse = getSalaryCacheService(user).get(SalaryCacheKey.UPLOAD_SALARY_CONFIG); + if (lastResponse != null && !lastResponse.isFinish()) { + throw new SalaryRunTimeException("迁入任务进行中,请等待上次任务完成!"); + } + +// LocalRunnable localRunnable = new LocalRunnable() { +// @Override +// public void execute() { + UploadConfigResponse response = UploadConfigResponse.builder().finish(false).results(new ArrayList<>()).build(); + getSalaryCacheService(user).set(SalaryCacheKey.UPLOAD_SALARY_CONFIG, response); + + InputStream fileInputStream = null; + try { + fileInputStream = ImageFileManager.getInputStreamById(Integer.parseInt(param.getImageId())); + Reader reader = new InputStreamReader(fileInputStream, StandardCharsets.UTF_8); + BufferedReader bufferedReader = new BufferedReader(reader); + String line; + StringBuilder xml = new StringBuilder(); + while ((line = bufferedReader.readLine()) != null) { + xml.append(line); + } + + SalaryConfig config = XStreamUtil.unmarshal(SalaryConfig.class, xml.toString()); + + UploadConfigResponse.Result sysConfigResult = getSalarySysConfService(user).parseConfig(config.getSysConfig()); + response.getResults().add(sysConfigResult); + + UploadConfigResponse.Result salaryItemResult = getSalaryItemService(user).parseConfig(config.getSalaryItemConfig()); + response.getResults().add(salaryItemResult); + + UploadConfigResponse.Result archiveFieldResult = getSalaryArchiveItemService(user).parseConfig(config.getArchiveFieldConfig()); + response.getResults().add(archiveFieldResult); + + UploadConfigResponse.Result taxAgentBaseResult = getTaxAgentBaseService(user).parseConfig(config.getTaxAgentBaseConfig()); + response.getResults().add(taxAgentBaseResult); + + List results = getTaxAgentService(user).parseConfig(config.getTaxAgentConfigs()); + response.getResults().addAll(results); + } catch (Exception e) { + log.error("加载失败", e); + } finally { + response.setFinish(true); + IOUtils.closeQuietly(fileInputStream); + } + getSalaryCacheService(user).set(SalaryCacheKey.UPLOAD_SALARY_CONFIG, response); +// } +// }; +// ThreadPoolUtil.fixedPoolExecute(ModulePoolEnum.HRM, "UPLOAD_SALARY_CONFIG", localRunnable); + + return response; + } +} diff --git a/src/com/engine/salary/wrapper/SalaryTemplateWrapper.java b/src/com/engine/salary/wrapper/SalaryTemplateWrapper.java new file mode 100644 index 000000000..b78eae261 --- /dev/null +++ b/src/com/engine/salary/wrapper/SalaryTemplateWrapper.java @@ -0,0 +1,468 @@ +package com.engine.salary.wrapper; + +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.entity.salaryBill.bo.SalaryBillItemNameBO; +import com.engine.salary.entity.salaryBill.dto.*; +import com.engine.salary.entity.salaryBill.param.*; +import com.engine.salary.entity.salaryBill.po.SalaryBillItemNamePO; +import com.engine.salary.entity.salaryBill.po.SalaryTemplatePO; +import com.engine.salary.entity.salaryitem.po.SalaryItemPO; +import com.engine.salary.entity.salarysob.po.SalarySobBackItemPO; +import com.engine.salary.entity.salarysob.po.SalarySobItemGroupPO; +import com.engine.salary.entity.salarysob.po.SalarySobPO; +import com.engine.salary.enums.salarybill.SalaryTemplateReplenishRuleEnum; +import com.engine.salary.enums.salarybill.SalaryTemplateVarEnum; +import com.engine.salary.enums.salarybill.SalaryTemplateWhetherEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.mapper.salarysob.SalarySobItemGroupMapper; +import com.engine.salary.service.*; +import com.engine.salary.service.impl.*; +import com.engine.salary.util.JsonUtil; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.db.MapperProxyFactory; +import com.engine.salary.util.page.PageInfo; +import com.mzlion.core.utils.BeanUtils; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.math.NumberUtils; +import weaver.hrm.User; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * @Description: 工资单模板 + * @Author: wangxiangzhong + * @Date: 2022/3/16 13:56 + */ +public class SalaryTemplateWrapper extends Service { + + private SalaryTemplateService getSalaryTemplateService(User user) { + return ServiceUtil.getService(SalaryTemplateServiceImpl.class, user); + } +// +// private MailBaseService mailBaseService; + + private SalarySobService getSalarySobService(User user) { + return ServiceUtil.getService(SalarySobServiceImpl.class, user); + } + + private SalarySobBackItemService getSalarySobBackItemService(User user) { + return ServiceUtil.getService(SalarySobBackItemServiceImpl.class, user); + } + + private SalaryItemService getSalaryItemService(User user) { + return ServiceUtil.getService(SalaryItemServiceImpl.class, user); + } + + private SalarySobItemGroupService getSalarySobItemGroupService(User user) { + return ServiceUtil.getService(SalarySobItemGroupServiceImpl.class, user); + } + + private TaxAgentService getTaxAgentService(User user) { + return ServiceUtil.getService(TaxAgentServiceImpl.class, user); + } + + private SalaryBillBaseSetService getSalaryBillBaseSetService(User user) { + return ServiceUtil.getService(SalaryBillBaseSetServiceImpl.class, user); + } + + private SalaryBillItemNameService getSalaryBillItemNameService(User user) { + return ServiceUtil.getService(SalaryBillItemNameServiceImpl.class, user); + } + + private SalarySobItemGroupMapper getSalarySobItemGroupMapper() { + return MapperProxyFactory.getProxy(SalarySobItemGroupMapper.class); + } + + /** + * 工资单模板列表 + * + * @param queryParam + * @return + */ + public PageInfo list(SalaryTemplateQueryParam queryParam) { + PageInfo listPage = getSalaryTemplateService(user).listPage(queryParam); + return listPage; + + } + + /** + * 获取工资单模板基础设置表单 + * + * @param id + * @return + */ + public SalaryTemplateBaseFormDTO getBaseForm(Long id) { + + SalaryTemplateBaseSetDTO salaryTemplateBaseSetDTO = new SalaryTemplateBaseSetDTO(); + + List> replenishRuleSetOptionList = Collections.emptyList(); + if (id != null) { + SalaryTemplatePO po = getSalaryTemplateService(user).getById(id); + if (po == null) { + throw new SalaryRunTimeException("工资单模板不存在"); + } + BeanUtils.copyProperties(po, salaryTemplateBaseSetDTO); + salaryTemplateBaseSetDTO.setSendEmail(po.getSendEmailId()); + salaryTemplateBaseSetDTO.setEmailStatus(po.getEmailStatus().equals(SalaryTemplateWhetherEnum.TRUE.getValue())); + salaryTemplateBaseSetDTO.setMsgStatus(po.getMsgStatus().equals(SalaryTemplateWhetherEnum.TRUE.getValue())); + salaryTemplateBaseSetDTO.setSalarySob(po.getSalarySobId()); + salaryTemplateBaseSetDTO.setSendEmail(po.getSendEmailId()); + salaryTemplateBaseSetDTO.setAutoSendStatus(po.getAutoSendStatus() != null && po.getAutoSendStatus().equals(SalaryTemplateWhetherEnum.TRUE.getValue())); + salaryTemplateBaseSetDTO.setAckFeedbackStatus(po.getAckFeedbackStatus() != null && NumberUtils.compare(po.getAckFeedbackStatus(), 1) == 0); + if (po.getFeedbackStatus() == null) { + salaryTemplateBaseSetDTO.setFeedbackStatus(salaryTemplateBaseSetDTO.getAckFeedbackStatus()); + } else { + salaryTemplateBaseSetDTO.setFeedbackStatus(NumberUtils.compare(po.getFeedbackStatus(), 1) == 0); + } + + salaryTemplateBaseSetDTO.setAutoAckDays(po.getAutoAckDays() == null ? 7 : po.getAutoAckDays()); + // 规则赋值 如果为ALL传“” 如果为byRule传薪资项目ID + salaryTemplateBaseSetDTO.setReplenishRule(SalaryTemplateReplenishRuleEnum.ALL.getValue().equals(po.getReplenishRule()) ? "" : po.getReplenishRule()); + // 规则设置赋值 +// salaryTemplateBaseSetDTO.setReplenishRuleSet(po.getReplenishRule()); + // 修改时获取补规则设置下拉列表 + replenishRuleSetOptionList = getReplenishRuleSetOptions(po.getSalarySobId()); + } + + + + // 查询所有启用的薪资账套 + List salarySobs = getSalarySobService(user).listByDisable(NumberUtils.INTEGER_ZERO); + List> salarySobOptions = salarySobs.stream().map(salarySobPO -> { + Map item = new HashMap<>(); + item.put("id", salarySobPO.getId()); + item.put("name", salarySobPO.getName()); + return item; + }).collect(Collectors.toList()); + + // 邮箱下拉 +// List sendEmailOptions = Lists.newArrayList(); +// MailPublicAccountListObj mailPublicAccountListObj = mailBaseService.getMailPublicAccountList(employeeId, tenantKey); +// List mailPublicAccountBos = mailPublicAccountListObj.getMailPublicAccountList(); +// mailPublicAccountBos.forEach(e->sendEmailOptions.add(new WeaFormOption(String.valueOf(e.getId()), e.getMailAddress()))); + +// WeaForm salaryTemplateBase = SalaryFormatUtil.getInstance().buildForm(SalaryTemplateBaseSetDTO.class, SalaryTemplateBaseSetDTO.builder().salarySobOptions(salarySobOptions).sendEmailOptions(sendEmailOptions).build()); + + if (id == null) { + // 新建,获取默认的确认反馈信息 + SalaryBillAckFeedbackDTO defaultAckFeedback = getSalaryBillBaseSetService(user).getDefaultAckFeedbackSetting(); + salaryTemplateBaseSetDTO.setAckFeedbackStatus(StringUtils.equals(defaultAckFeedback.getAckStatus(), "1")); + salaryTemplateBaseSetDTO.setAutoAckDays(defaultAckFeedback.getAutoAckDays()); + salaryTemplateBaseSetDTO.setFeedbackStatus(StringUtils.equals(defaultAckFeedback.getFeedbackStatus(), "1")); + salaryTemplateBaseSetDTO.setFeedbackUrl(defaultAckFeedback.getFeedBackUrl()); + salaryTemplateBaseSetDTO.setMobileFeedbackUrl(defaultAckFeedback.getMobileFeedbackUrl()); + } + + // 如果设置了pc端反馈流程地址,移动端没有设置,则移动端与pc端一致 + if (StringUtils.isNotBlank(salaryTemplateBaseSetDTO.getFeedbackUrl()) && StringUtils.isBlank(salaryTemplateBaseSetDTO.getMobileFeedbackUrl())) { + salaryTemplateBaseSetDTO.setMobileFeedbackUrl(salaryTemplateBaseSetDTO.getFeedbackUrl()); + } + + Map salaryTemplateBase = new HashMap<>(); + salaryTemplateBase.put("data", salaryTemplateBaseSetDTO); + salaryTemplateBase.put("salarySobOptions", salarySobOptions); + // 编辑时禁止修改薪资账套 前端实现 + // 分组 前端实现 + + return SalaryTemplateBaseFormDTO.builder().id(id).salaryTemplateBaseSet(salaryTemplateBase).replenishRuleSetOption(replenishRuleSetOptionList).build(); + + } + + /** + * 获取工资单模板显示设置表单 + * + * @param id + * @return + */ + public SalaryTemplateShowFormDTO getShowForm(Long id) { + SalaryTemplateShowSetDTO salaryTemplateShowSetDTO = new SalaryTemplateShowSetDTO(); + + SalaryTemplatePO po = new SalaryTemplatePO(); + if (id != null) { + po = getSalaryTemplateService(user).getById(id); + if (po == null) { + throw new SalaryRunTimeException("工资单模板不存在"); + } + BeanUtils.copyProperties(po, salaryTemplateShowSetDTO); + salaryTemplateShowSetDTO.setTextContentPosition(po.getTextContentPosition().toString()); + salaryTemplateShowSetDTO.setSalaryItemNullStatus(po.getSalaryItemNullStatus().equals(SalaryTemplateWhetherEnum.TRUE.getValue())); + salaryTemplateShowSetDTO.setSalaryItemZeroStatus(po.getSalaryItemZeroStatus().equals(SalaryTemplateWhetherEnum.TRUE.getValue())); + } + + Map salaryTemplateShowSet = new HashMap<>(); + salaryTemplateShowSet.put("data", salaryTemplateShowSetDTO); + + // 薪资项目设置 + List salaryTemplateShowSetData = new ArrayList<>(); + if (StringUtils.isNotEmpty(po.getSalaryItemSetting())) { + salaryTemplateShowSetData = JsonUtil.parseList(po.getSalaryItemSetting(), SalaryTemplateSalaryItemSetListDTO.class); + } + // 补发薪资项目设置,前端保存时需要使用 + List replenishSalaryTemplateSalaryItemSet = new ArrayList<>(); + if (StringUtils.isNotEmpty(po.getReplenishSalaryItemSetting())) { + replenishSalaryTemplateSalaryItemSet = JsonUtil.parseList(po.getReplenishSalaryItemSetting(), SalaryTemplateSalaryItemSetListDTO.class); + } + + //同步项目名称 + List itemPOS = getSalaryItemService(user).listAll(); + Map itemIdNameMap = SalaryEntityUtil.convert2Map(itemPOS, SalaryItemPO::getId, SalaryItemPO::getName); + +// List groupPOS = getSalarySobItemGroupService(user).listBySalarySobId(po.getSalarySobId()); +// Map groupIdNameMap = SalaryEntityUtil.convert2Map(groupPOS, SalarySobItemGroupPO::getId, SalarySobItemGroupPO::getName); + + // 获取工资单薪资项目展示名信息 + Map itemShowNameMap; + Map salaryBillItemNameDTOMap = Collections.emptyMap(); + if (id != null) { + List billItemNameList = getSalaryBillItemNameService(user).ListByTemplateAndType(SalaryBillItemNamePO.builder().salaryTemplateId(id).salaryBillType(0).build()); + itemShowNameMap = SalaryEntityUtil.convert2Map(billItemNameList, SalaryBillItemNamePO::getSalaryItemId, SalaryBillItemNamePO::getSalaryItemShowName); + // 获取薪资项目信息 + List salaryBillItemNameDTOS = SalaryBillItemNameBO.convert2ListDTO(billItemNameList); + salaryBillItemNameDTOMap = SalaryEntityUtil.convert2Map(salaryBillItemNameDTOS, SalaryBillItemNameDTO::getSalaryItemId); + } else { + itemShowNameMap = Collections.emptyMap(); + } + + if (CollectionUtils.isNotEmpty(salaryTemplateShowSetData)) { + salaryTemplateShowSetData.stream() + //排除人员消息 + .filter(data -> !StringUtils.equals(data.getGroupId(), "111111111111111111")).forEach(data -> { + data.getItems().forEach(item -> { + Long salaryItemId = Long.valueOf(item.getSalaryItemId()); + item.setOriginName(itemIdNameMap.getOrDefault(salaryItemId, item.getName())); + if (itemShowNameMap.containsKey(salaryItemId)) { + item.setSalaryItemShowName(itemShowNameMap.get(salaryItemId)); + item.setName(itemShowNameMap.get(salaryItemId) + "(" + itemIdNameMap.getOrDefault(salaryItemId, item.getName()) + ")"); + } else { + item.setSalaryItemShowName(itemIdNameMap.getOrDefault(salaryItemId, item.getName())); + item.setName(itemIdNameMap.getOrDefault(salaryItemId, item.getName())); + } + }); + }); + } + + + return SalaryTemplateShowFormDTO.builder().id(id).vars(Arrays.stream(SalaryTemplateVarEnum.values()).map(SalaryTemplateVarEnum::getValue).collect(Collectors.toList())).salaryTemplateShowSet(salaryTemplateShowSet).salaryTemplateSalaryItemSet(salaryTemplateShowSetData).replenishSalaryTemplateSalaryItemSet(replenishSalaryTemplateSalaryItemSet).salaryBillItemNameSet(salaryBillItemNameDTOMap).build(); + } + + /** + * 获取薪资项目设置 + * + * @param salarySobId + * @return + */ + public List getSalaryItemSet(Long salarySobId) { + return getSalaryTemplateService(user).getSalaryItemSet(salarySobId, false); + } + + + /** + * @param salarySobId + * @return + */ + public List getSmsSalaryItemSet(Long salarySobId) { + List salaryItemSet = getSalaryTemplateService(user).getSalaryItemSet(salarySobId, false); + + salaryItemSet.add(0, SalaryTemplateSalaryItemSetListDTO.builder().groupId("444444444444444444L").groupName("基本信息").items(Collections.singletonList(SalaryTemplateSalaryItemListDTO.builder().name("薪资所属月").build())).build()); + return salaryItemSet; + } + + public List getReplenishSalaryItemSet(Long salarySobId) { + return getSalaryTemplateService(user).getSalaryItemSet(salarySobId, true); + } + + /** + * 工资单模板默认使用 + * + * @param defaultUseParam + * @return + */ + public String defaultUse(SalaryTemplateDefaultUseParam defaultUseParam) { + return getSalaryTemplateService(user).defaultUse(defaultUseParam); + } + + /** + * 新建工资单模板 + * + * @param saveParam + * @return + */ + public String save(SalaryTemplateSaveParam saveParam) { + return getSalaryTemplateService(user).save(saveParam); + } + + /** + * 编辑工资单模板 + * + * @param saveParam + * @return + */ + public String update(SalaryTemplateSaveParam saveParam) { + return getSalaryTemplateService(user).update(saveParam); + } + + /** + * 复制工资单模板 + * + * @param copyParam + * @return + */ + public String copy(SalaryTemplateCopyParam copyParam) { + return getSalaryTemplateService(user).copy(copyParam); + } + + /** + * 删除工资单模板 + * + * @param ids + * @return + */ + public String delete(Collection ids) { + return getSalaryTemplateService(user).delete(ids); + } + + /** + * 获取薪资账套下拉列表 + * + * @return + */ + public List> selectSalarySobList() { + return getSalaryTemplateService(user).selectSalarySobList(); + } + + + /** + * 获取补发规则设置下拉列表 + * + * @param salarySobId + * @return + */ + public List> getReplenishRuleSetOptions(Long salarySobId) { + if (salarySobId == null) { + return Collections.emptyList(); + } + SalarySobPO salarySob = getSalarySobService(user).getById(salarySobId); + if (salarySob == null) { + return Collections.emptyList(); + } + // 查询薪资账套的回算薪资项目 + List salarySobBackItems = getSalarySobBackItemService(user).listBySalarySobId(salarySobId); + if (CollectionUtils.isEmpty(salarySobBackItems)) { + salarySobBackItems = getSalarySobBackItemService(user).listBySalarySobId(salarySob.getId()); + } + List salaryItemPOS = getSalaryItemService(user).listByIds(salarySobBackItems.stream().map(SalarySobBackItemPO::getSalaryItemId).collect(Collectors.toList())); + + String ruleTip = "(" + SalaryI18nUtil.getI18nLabel(140142, "不等于0") + ")"; + + List> result = salaryItemPOS.stream().map(m -> { + Map map = new HashMap<>(2); + map.put("id", String.valueOf(m.getId())); + map.put("content", m.getName() + ruleTip); + return map; + }).collect(Collectors.toList()); + + return result; +// if(result!= null && result.size()>0){ +// return result.get(0); +// } +// return Collections.emptyMap(); + } + + /** + * 获取工资单模板补发设置表单 + * + * @param replenishFormQueryParam + * @return + */ + public SalaryTemplateReplenishFormDTO getReplenishForm(ReplenishFormQueryParam replenishFormQueryParam) { + Long id = replenishFormQueryParam.getId(); + SalaryTemplateReplenishFormDTO salaryTemplateReplenishSetDTO = new SalaryTemplateReplenishFormDTO(); + + // 补发薪资项目设置 + List replenishSalaryItemSetting; + // 补发薪资项目显示名称 + Map salaryBillItemNameDTOMap = new HashMap<>(); + if (id != null) { + SalaryTemplatePO po = getSalaryTemplateService(user).getById(id); + if (po == null) { + throw new SalaryRunTimeException(String.format(SalaryI18nUtil.getI18nLabel(100533, "工资单模板不存在") + "[id:%s]", id)); + } + BeanUtils.copyProperties(po, salaryTemplateReplenishSetDTO); + if (StringUtils.isNotEmpty(po.getReplenishSalaryItemSetting())) { + replenishSalaryItemSetting = JsonUtil.parseList(po.getReplenishSalaryItemSetting(), SalaryTemplateSalaryItemSetListDTO.class); + // 同步补发薪资项目名称 + List itemPOS = getSalaryItemService(user).listAll(); + Map itemIdNameMap = SalaryEntityUtil.convert2Map(itemPOS, SalaryItemPO::getId, SalaryItemPO::getName); + // 获取工资单薪资项目展示名信息 + List billItemNameList = getSalaryBillItemNameService(user).ListByTemplateAndType(SalaryBillItemNamePO.builder().salaryTemplateId(id).salaryBillType(1).build()); + Map itemShowNameMap = SalaryEntityUtil.convert2Map(billItemNameList, SalaryBillItemNamePO::getSalaryItemId, SalaryBillItemNamePO::getSalaryItemShowName); + // 获取薪资项目信息 + List salaryBillItemNameDTOS = SalaryBillItemNameBO.convert2ListDTO(billItemNameList); + salaryBillItemNameDTOMap = SalaryEntityUtil.convert2Map(salaryBillItemNameDTOS, SalaryBillItemNameDTO::getSalaryItemId); + + if (CollectionUtils.isNotEmpty(replenishSalaryItemSetting)) { + replenishSalaryItemSetting.stream() + //排除人员消息 + .filter(data -> !StringUtils.equals(data.getGroupId(), "111111111111111111")).forEach(data -> { + data.getItems().forEach(item -> { + Long salaryItemId = Long.valueOf(item.getSalaryItemId()); + item.setOriginName(itemIdNameMap.getOrDefault(salaryItemId, item.getName())); + if (itemShowNameMap.containsKey(salaryItemId)) { + item.setSalaryItemShowName(itemShowNameMap.get(salaryItemId)); + item.setName(itemShowNameMap.get(salaryItemId) + "(" + itemIdNameMap.getOrDefault(salaryItemId, item.getName()) + ")"); + } else { + item.setSalaryItemShowName(itemIdNameMap.getOrDefault(salaryItemId, item.getName())); + item.setName(itemIdNameMap.getOrDefault(salaryItemId, item.getName())); + } + }); + }); + } + } else { + replenishSalaryItemSetting = getReplenishSalaryItemSet(replenishFormQueryParam.getSalarySobId()); + } + } else { + replenishSalaryItemSetting = getReplenishSalaryItemSet(replenishFormQueryParam.getSalarySobId()); + } + + return SalaryTemplateReplenishFormDTO.builder().id(id).replenishSalaryTemplateSalaryItemSet(replenishSalaryItemSetting).salaryBillItemNameSet(salaryBillItemNameDTOMap).build(); + } + + /** + * 获取单个分组下,没有被加入到模板的薪资项目 + * + * @param param 入参 + * @return 单个分组下剩余的薪资项目 + */ + public List getSalaryItemSetGrouped(SalaryBillSalaryItemQueryParam param) { + Boolean isReplenish = Optional.ofNullable(param.getIsReplenish()).orElse(false); + List salaryItemSet = getSalaryTemplateService(user).getSalaryItemSetContainHide(param.getSalarySobId(), param.getSalaryTemplateId(), isReplenish); + Long groupId = param.getGroupId(); + //工资单模板copy可能导致groupId不匹配 + List salarySobItemGroupPOS = getSalarySobItemGroupMapper().listSome(SalarySobItemGroupPO.builder().salarySobId(param.getSalarySobId()).name(param.getGroupName()).build()); + if (salarySobItemGroupPOS != null && salarySobItemGroupPOS.size() > 0) { + groupId = salarySobItemGroupPOS.get(0).getId(); + } + Long finalGroupId = groupId; + return salaryItemSet.stream().filter(s -> Objects.equals(s.getGroupId(), finalGroupId + "")).map(SalaryTemplateSalaryItemSetListDTO::getItems).findFirst().orElse(Collections.emptyList()).stream().filter(item -> !Optional.ofNullable(param.getExistSalaryItemIds()).orElse(Collections.emptyList()).contains(item.getId())).collect(Collectors.toList()); + } + + /** + * 获取账套下没有被加入的分组 + * + * @param param 入参 + * @return 分组与下属 + */ + public List getSalaryGroupSet(SalaryBillSalaryGroupQueryParam param) { + Boolean isReplenish = Optional.ofNullable(param.getIsReplenish()).orElse(false); + return getSalaryTemplateService(user).getSalaryItemSetContainHide(param.getSalarySobId(), param.getSalaryTemplateId(), isReplenish).stream().filter(group -> !Optional.ofNullable(param.getExistSalaryGroupIds()).orElse(Collections.emptyList()).contains(group.getGroupId())).collect(Collectors.toList()); + } + + public void saveItemShowName(List saveList) { + getSalaryBillItemNameService(user).saveItemShowName(saveList); + } + +} diff --git a/src/com/engine/salary/wrapper/SpecialAddDeductionWrapper.java b/src/com/engine/salary/wrapper/SpecialAddDeductionWrapper.java new file mode 100644 index 000000000..1e2586096 --- /dev/null +++ b/src/com/engine/salary/wrapper/SpecialAddDeductionWrapper.java @@ -0,0 +1,204 @@ +package com.engine.salary.wrapper; + +import com.api.browser.bean.SearchConditionGroup; +import com.api.browser.bean.SearchConditionItem; +import com.api.browser.util.ConditionFactory; +import com.api.browser.util.ConditionType; +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.entity.datacollection.dto.SpecialAddDeductionListDTO; +import com.engine.salary.entity.datacollection.dto.SpecialAddDeductionRecordDTO; +import com.engine.salary.entity.datacollection.param.*; +import com.engine.salary.entity.datacollection.po.SpecialAddDeductionPO; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.service.SalaryEmployeeService; +import com.engine.salary.service.SpecialAddDeductionService; +import com.engine.salary.service.TaxAgentService; +import com.engine.salary.service.impl.SalaryEmployeeServiceImpl; +import com.engine.salary.service.impl.SpecialAddDeductionServiceImpl; +import com.engine.salary.service.impl.TaxAgentServiceImpl; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.excel.ExcelPreviewDTO; +import com.engine.salary.util.page.PageInfo; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import weaver.hrm.User; + +import java.util.*; + +/** + * 专项附加扣除 + */ +public class SpecialAddDeductionWrapper extends Service { + private SpecialAddDeductionService getSpecialAddDeductionService(User user) { + return ServiceUtil.getService(SpecialAddDeductionServiceImpl.class, user); + } + private TaxAgentService getTaxAgentV2Service(User user) { + return ServiceUtil.getService(TaxAgentServiceImpl.class, user); + } + private SalaryEmployeeService getSalaryEmployeeService(User user) { + return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user); + } + /** + * 数据采集-专项附加扣除列表的高级搜索 + * + * @return + */ + public Map getSearchCondition() { + Map apidatas = new HashMap<>(); + ConditionFactory conditionFactory = new ConditionFactory(user); + + //条件组 + List addGroups = new ArrayList<>(); + + List conditionItems = new ArrayList<>(); + + //文本输入框 + SearchConditionItem username = conditionFactory.createCondition(ConditionType.INPUT, 25034, "username"); + username.setInputType("input"); + username.setColSpan(2);//定义一行显示条件数,默认值为2,当值为1时标识该条件单独占一行 + username.setFieldcol(16); //条件输入框所占宽度,默认值18 + username.setLabelcol(8); + username.setViewAttr(2); // 编辑权限 1:只读,2:可编辑, 3:必填 默认2 + username.setLabel("姓名"); //设置文本值 这个将覆盖多语言标签的值 + conditionItems.add(username); + + SearchConditionItem departmentName = conditionFactory.createCondition(ConditionType.BROWSER, 502227, "departmentIds", "57"); + departmentName.setInputType("browser"); + departmentName.setColSpan(2); + departmentName.setFieldcol(16); + departmentName.setLabelcol(8); + departmentName.setViewAttr(2); + departmentName.setIsQuickSearch(false); + departmentName.setLabel("部门"); + conditionItems.add(departmentName); + + + SearchConditionItem jobNum = conditionFactory.createCondition(ConditionType.INPUT, 25034, "jobNum"); + jobNum.setInputType("input"); + jobNum.setColSpan(2); + jobNum.setFieldcol(16); + jobNum.setLabelcol(8); + jobNum.setViewAttr(2); + jobNum.setLabel("工号"); + conditionItems.add(jobNum); + + addGroups.add(new SearchConditionGroup("常用条件", true, conditionItems)); + + apidatas.put("condition", addGroups); + return apidatas; + } + + /** + * 数据采集-专项附加扣除列表(分页) + * + * @param queryParam + * @return + */ + public PageInfo list(SpecialAddDeductionQueryParam queryParam) { + return getSpecialAddDeductionService(user).listPage(queryParam); + + } + + /** + * 数据采集-专项附加扣除详情列表(分页) + * + * @param queryParam + * @return + */ + public PageInfo getDetailList(SpecialAddDeductionQueryParam queryParam) { + Long id = queryParam.getSpecialAddDeductionId(); + + SpecialAddDeductionPO po = getSpecialAddDeductionService(user).getById(id); + if (po == null) { + throw new SalaryRunTimeException(String.format(SalaryI18nUtil.getI18nLabel(100415, "专项附加扣除不存在") + "[id:%s]", id)); + } + queryParam.setEmployeeId(po.getEmployeeId()); + + return getSpecialAddDeductionService(user).recordListPage(queryParam); + } + + /** + * 导出-专项附加扣除列表 + * + * @param queryParam + * @return + */ + public XSSFWorkbook export(SpecialAddDeductionQueryParam queryParam) { + return getSpecialAddDeductionService(user).export(queryParam, false); + } + + /** + * 导出-专项附加扣除详情列表 + * + * @param queryParam + * @return + */ + public XSSFWorkbook exportDetail(SpecialAddDeductionQueryParam queryParam) { + Long id = queryParam.getSpecialAddDeductionId(); + SpecialAddDeductionPO po = getSpecialAddDeductionService(user).getById(id); + if (po == null) { + throw new SalaryRunTimeException(String.format(SalaryI18nUtil.getI18nLabel( 100415, "专项附加扣除不存在") + "[id:%s]", id)); + } + return getSpecialAddDeductionService(user).exportDetail(queryParam); + } + + /** + * 下载导入模板 + * + * @param queryParam + * @return + */ + public XSSFWorkbook downloadTemplate(SpecialAddDeductionQueryParam queryParam) { + return getSpecialAddDeductionService(user).export(queryParam, true); + } + + /** + * 预览 + */ + public ExcelPreviewDTO preview(SpecialAddDeductionImportParam importParam){ + return getSpecialAddDeductionService(user).preview(importParam); + } + + /** + * 导入数据 + */ + public Map importData(SpecialAddDeductionImportParam importParam){ + return getSpecialAddDeductionService(user).importData(importParam); + } + + /** + * 编辑数据 + */ + public void editData(SpecialAddDeductionParam specialAddDeductionParam) { + getSpecialAddDeductionService(user).editData(specialAddDeductionParam); + } + + + /** + * 新增数据 + */ + public void createData(SpecialAddDeductionParam specialAddDeductionParam) { + getSpecialAddDeductionService(user).createData(specialAddDeductionParam); + } + + /** + * 删除所选数据 + */ + public void deleteSelectData(SpecialAddDeductionRecordDeleteParam deleteParam) { + getSpecialAddDeductionService(user).deleteSelectData(deleteParam); + } + + /** + * 一键清空所有数据 + */ + public void deleteAllData(SpecialAddDeductionRecordDeleteParam deleteParam) { + getSpecialAddDeductionService(user).deleteAllData(deleteParam); + } + + public SpecialAddDeductionRecordDTO getRecordById(Long id) { + if (id == null) { + throw new SalaryRunTimeException("专项附加扣除主键[id]必传"); + } + return getSpecialAddDeductionService(user).getRecordById(id); + } +} diff --git a/src/com/engine/salary/wrapper/SysSalaryItemWrapper.java b/src/com/engine/salary/wrapper/SysSalaryItemWrapper.java new file mode 100644 index 000000000..c7438edbb --- /dev/null +++ b/src/com/engine/salary/wrapper/SysSalaryItemWrapper.java @@ -0,0 +1,116 @@ +package com.engine.salary.wrapper; + +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.entity.salaryitem.bo.SysSalaryItemBO; +import com.engine.salary.entity.salaryitem.dto.SysSalaryItemListDTO; +import com.engine.salary.entity.salaryitem.param.SysSalaryItemSearchParam; +import com.engine.salary.entity.salaryitem.po.SalaryItemPO; +import com.engine.salary.entity.salaryitem.po.SysSalaryItemPO; +import com.engine.salary.enums.SalarySystemTypeEnum; +import com.engine.salary.service.SalaryItemService; +import com.engine.salary.service.SysSalaryItemService; +import com.engine.salary.service.impl.SalaryItemServiceImpl; +import com.engine.salary.service.impl.SysSalaryItemServiceImpl; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.util.page.SalaryPageUtil; +import weaver.hrm.User; + +import java.util.Collection; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; + +/** + * 系统薪资项目 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ + +public class SysSalaryItemWrapper extends Service { + + + private SalaryItemService getSalaryItemService(User user) { + return (SalaryItemService) ServiceUtil.getService(SalaryItemServiceImpl.class, user); + } + + private SysSalaryItemService getSysSalaryItemService(User user) { + return (SysSalaryItemService) ServiceUtil.getService(SysSalaryItemServiceImpl.class, user); + } + + + /** + * 系统薪资项目列表 + * + * @param searchParam 高级搜索的查询条件 + * @return + */ + public PageInfo listPage(SysSalaryItemSearchParam searchParam) { + // 查询已经添加过的系统薪资项目(已经添加过的系统薪资项目不能二次添加) + List salaryItemPOS = getSalaryItemService(user).listBySystemType(SalarySystemTypeEnum.SYSTEM); + Set sysSalaryItemIds = SalaryEntityUtil.properties(salaryItemPOS, SalaryItemPO::getSysSalaryItemId); + searchParam.setExcludeIds(sysSalaryItemIds); + + List sysSalaryItemPOS = getSysSalaryItemService(user).listLikeName(SysSalaryItemPO.builder().name(searchParam.getName()).build()); + List finalItems = sysSalaryItemPOS.stream().filter(item -> !sysSalaryItemIds.contains(item.getId())).collect(Collectors.toList()); + List sysSalaryItemListDTOS = SysSalaryItemBO.convert2ListDTO(finalItems); + // 分页参数 + PageInfo pageInfo = SalaryPageUtil.buildPage(searchParam.getCurrent(), searchParam.getPageSize(), sysSalaryItemListDTOS, SysSalaryItemListDTO.class); + return pageInfo; + } + +// private String makeSqlWhere(SysSalaryItemSearchParam searchParam) { +// DBType dbType = DBType.get(new RecordSet().getDBType()); +// String sqlWhere = " t.delete_type = 0 "; +// +// String name = searchParam.getName(); +// if (StringUtils.isNotBlank(name)) { +// sqlWhere += " AND t.name " + dbType.like(name); +// } +// +// String itemType = searchParam.getItemType(); +// if (StringUtils.isNotBlank(itemType)) { +// sqlWhere += " AND t.item_type = " + itemType; +// } +// +// String category = searchParam.getCategory(); +// if (StringUtils.isNotBlank(category)) { +// sqlWhere += " AND t.category = " + category; +// } +// +// Collection excludeIds = searchParam.getExcludeIds(); +// if (CollectionUtils.isNotEmpty(excludeIds)) { +// String idsStr = excludeIds.stream().map(String::valueOf).collect(Collectors.joining(",")); +// sqlWhere += " AND t.id NOT IN (" + idsStr + ")"; +// } +// +// +// return sqlWhere; +// } + +// /** +// * 获取高级搜索 +// * +// * @return +// */ +// public WeaSearchCondition getSearchCondition() { +// WeaSearchCondition searchCondition = SalaryFormatUtil.getInstance() +// .buildCondition(SysSalaryItemSearchConditionDTO.class, new SysSalaryItemSearchConditionDTO(), "sysSalaryItemCondition"); +// // 其他条件不要 +// searchCondition.getGroups().remove(1); +// return searchCondition; +// } + + /** + * 添加系统薪资项目到自定义薪资项目列表中 + * + * @param ids 主键id + */ + public void add2SalaryItem(Collection ids) { + getSysSalaryItemService(user).add2SalaryItem(ids); + } +} diff --git a/src/com/engine/salary/wrapper/TaxAgentBaseWrapper.java b/src/com/engine/salary/wrapper/TaxAgentBaseWrapper.java new file mode 100644 index 000000000..f1e8423fa --- /dev/null +++ b/src/com/engine/salary/wrapper/TaxAgentBaseWrapper.java @@ -0,0 +1,44 @@ +package com.engine.salary.wrapper; + +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.entity.taxagent.param.TaxAgentSaveBaseParam; +import com.engine.salary.entity.taxagent.po.TaxAgentBasePO; +import com.engine.salary.service.TaxAgentBaseService; +import com.engine.salary.service.impl.TaxAgentBaseServiceImpl; +import weaver.hrm.User; + +/** + * 个税扣缴义务人基础信息 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class TaxAgentBaseWrapper extends Service { + + private TaxAgentBaseService getTaxAgentBaseService(User user) { + return ServiceUtil.getService(TaxAgentBaseServiceImpl.class, user); + } + + /** + * 获取个税扣缴义务人基本信息表单 + * + * @return + */ + public TaxAgentBasePO getFrom() { + TaxAgentBasePO base = getTaxAgentBaseService(user).getBaseInfo(); + return base; + } + + /** + * 保存个税扣缴义务人基本信息 + * + * @param saveBaseParam + * @return + */ + public String save(TaxAgentSaveBaseParam saveBaseParam) { + return getTaxAgentBaseService(user).save(saveBaseParam); + } +} diff --git a/src/com/engine/salary/wrapper/TaxAgentSubAdminWrapper.java b/src/com/engine/salary/wrapper/TaxAgentSubAdminWrapper.java new file mode 100644 index 000000000..d9c4baa22 --- /dev/null +++ b/src/com/engine/salary/wrapper/TaxAgentSubAdminWrapper.java @@ -0,0 +1,178 @@ +package com.engine.salary.wrapper; + +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.taxagent.bo.TaxAgentBO; +import com.engine.salary.entity.taxagent.dto.*; +import com.engine.salary.entity.taxagent.param.TaxAgentSubAdminBaseFormParam; +import com.engine.salary.entity.taxagent.param.TaxAgentSubAdminBaseSaveParam; +import com.engine.salary.entity.taxagent.param.TaxAgentSubAdminQueryParam; +import com.engine.salary.entity.taxagent.param.TaxAgentSubAdminRangeQueryParam; +import com.engine.salary.entity.taxagent.po.TaxAgentSubAdminPO; +import com.engine.salary.enums.UserStatusEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.service.SalaryEmployeeService; +import com.engine.salary.service.TaxAgentManageRangeService; +import com.engine.salary.service.TaxAgentSubAdminService; +import com.engine.salary.service.impl.SalaryEmployeeServiceImpl; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.util.page.SalaryPageUtil; +import com.engine.salary.util.valid.ValidUtil; +import com.google.common.collect.Lists; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.math.NumberUtils; + +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; + +/** + * 个税义务人分管理员 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class TaxAgentSubAdminWrapper extends Service { + + private SalaryEmployeeService getSalaryEmployeeService() { + return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user); + } + + private TaxAgentSubAdminService taxAgentSubAdminService; + private TaxAgentManageRangeService taxAgentManageRangeService; +// private HrmCommonEmployeeService hrmCommonEmployeeService; + + /** + * 获取分管理员列表 + * + * @param queryParam + * @return + */ + public PageInfo list(TaxAgentSubAdminQueryParam queryParam) { + ValidUtil.doValidator(queryParam); + + List list = taxAgentSubAdminService.listByTaxAgentIds(Collections.singletonList(queryParam.getTaxAgentId())); + String range = SalaryI18nUtil.getI18nLabel(106290, "详情"); + List subAdminList = getSalaryEmployeeService().getEmployeeByIds(list.stream().map(TaxAgentSubAdminPO::getEmployeeId).distinct().collect(Collectors.toList())); + + List records = TaxAgentBO.convertToSubAdminListDTO(list, range, subAdminList); + PageInfo listPage = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), TaxAgentSubAdminListDTO.class); + // 填充总数和当页数据 + listPage.setTotal(records.size()); + listPage.setList(SalaryPageUtil.subList(listPage.getPageNum(), listPage.getPageSize(), records)); + + return listPage; + } + + /** + * 删除分管理员 + * + * @param ids + * @return + */ + public String delete(Collection ids) { + return taxAgentSubAdminService.deleteByIds(ids); + } + + /** + * 获取基础设置表单 + * + * @param baseFormParam + * @return + */ + public TaxAgentSubAdminBaseFormDTO getBaseFrom(TaxAgentSubAdminBaseFormParam baseFormParam) { + ValidUtil.doValidator(baseFormParam); + + TaxAgentSubAdminBaseFormDTO taxAgentSubAdminBaseFormDTO = new TaxAgentSubAdminBaseFormDTO(); + Long id = baseFormParam.getId(); + if (id != null) { + TaxAgentSubAdminPO taxAgentSubAdmin = taxAgentSubAdminService.getById(id); + if (taxAgentSubAdmin == null) { + throw new SalaryRunTimeException(String.format(SalaryI18nUtil.getI18nLabel(106466, "分管理员不存在") + "[id:%s]", id)); + } + if (!baseFormParam.getTaxAgentId().equals(taxAgentSubAdmin.getTaxAgentId())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(106685, "分管理员与所属个税扣缴义务人不匹配")); + } + taxAgentSubAdminBaseFormDTO.setId(taxAgentSubAdmin.getId()); + taxAgentSubAdminBaseFormDTO.setDescription(taxAgentSubAdmin.getRemark()); + TaxAgentEmployeeOptionDTO taxAgentEmployee = new TaxAgentEmployeeOptionDTO(); + taxAgentEmployee.setId(taxAgentSubAdmin.getEmployeeId()); + DataCollectionEmployee employee = getSalaryEmployeeService().getEmployeeById(taxAgentEmployee.getId()); + taxAgentEmployee.setContent(employee == null ? "" : employee.getUsername()); + + taxAgentSubAdminBaseFormDTO.setSubAdminUser(Collections.singletonList(taxAgentEmployee)); + } else { + taxAgentSubAdminBaseFormDTO.setSubAdminUser(Lists.newArrayList()); + } + + return taxAgentSubAdminBaseFormDTO; + } + + /** + * 保存分管理员基础设置 + * + * @param saveParam + * @return + */ + public String saveBase(TaxAgentSubAdminBaseSaveParam saveParam) { + return taxAgentSubAdminService.saveBase(saveParam); + } + + /** + * 范围列表 + * + * @param queryParam + * @return + */ + public PageInfo listRangeInclude(TaxAgentSubAdminRangeQueryParam queryParam) { + PageInfo listPage = taxAgentManageRangeService.listPageByParamAndIncludeType(queryParam, NumberUtils.INTEGER_ONE); + return listPage; + } + + /** + * 范围排除列表 + * + * @param queryParam + * @return + */ + public PageInfo listRangeExclude(TaxAgentSubAdminRangeQueryParam queryParam) { + PageInfo listPage = taxAgentManageRangeService.listPageByParamAndIncludeType(queryParam, NumberUtils.INTEGER_ZERO); + return listPage; + } + + /** + * 获取管理范围表单 + * + * @return + */ + public TaxAgentManageRangeFormDTO getRangeFrom() { + return TaxAgentManageRangeFormDTO.builder().employeeStatus(UserStatusEnum.getHrmStatusList()).build(); + } + + /** + * 保存管理范围 + * + * @param saveParam + * @return + */ +// public String saveRange(TaxAgentSubAdminRangeSaveParam saveParam) { +// taxAgentManageRangeService.save4SubAdmin(saveParam); +// return StringUtils.EMPTY; +// } + + /** + * 删除管理范围 + * + * @param ids + * @return + */ + public String deleteRange(Collection ids) { + taxAgentManageRangeService.deleteByIds(ids); + return StringUtils.EMPTY; + } +} diff --git a/src/com/engine/salary/wrapper/TaxAgentWrapper.java b/src/com/engine/salary/wrapper/TaxAgentWrapper.java new file mode 100644 index 000000000..2ea504ee9 --- /dev/null +++ b/src/com/engine/salary/wrapper/TaxAgentWrapper.java @@ -0,0 +1,508 @@ +package com.engine.salary.wrapper; + +import cn.hutool.core.util.StrUtil; +import com.cloudstore.dev.api.util.Util_DataCache; +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.cache.SalaryCacheKey; +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.hrm.HrmStatus; +import com.engine.salary.entity.taxagent.bo.TaxAgentBO; +import com.engine.salary.entity.taxagent.dto.*; +import com.engine.salary.entity.taxagent.param.*; +import com.engine.salary.entity.taxagent.po.TaxAgentAdminPO; +import com.engine.salary.entity.taxagent.po.TaxAgentExtRangePO; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import com.engine.salary.enums.UserStatusEnum; +import com.engine.salary.enums.auth.AuthFilterTypeEnum; +import com.engine.salary.enums.salarysob.TargetTypeEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.service.*; +import com.engine.salary.service.auth.AuthRoleService; +import com.engine.salary.service.auth.AuthRoleServiceImpl; +import com.engine.salary.service.impl.*; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.page.PageInfo; +import com.google.common.collect.Maps; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.math.NumberUtils; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.springframework.beans.BeanUtils; +import weaver.general.Util; +import weaver.hrm.User; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * 个税扣缴义务人 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class TaxAgentWrapper extends Service { + + public TaxAgentBaseService getTaxAgentBaseService(User user) { + return ServiceUtil.getService(TaxAgentBaseServiceImpl.class, user); + } + + public TaxAgentAdminService getTaxAgentAdminService(User user) { + return ServiceUtil.getService(TaxAgentAdminServiceImpl.class, user); + } + + public TaxAgentService getTaxAgentService(User user) { + return ServiceUtil.getService(TaxAgentServiceImpl.class, user); + } + + public SalaryEmployeeService getSalaryEmployeeService(User user) { + return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user); + } + + public TaxAgentManageRangeService getTaxAgentManageRangeService(User user) { + return ServiceUtil.getService(TaxAgentManageRangeServiceImpl.class, user); + } + + public TaxAgentExcelService getTaxAgentExcelService(User user) { + return ServiceUtil.getService(TaxAgentExcelServiceImpl.class, user); + } + + public AuthRoleService getAuthRoleService(User user) { + return ServiceUtil.getService(AuthRoleServiceImpl.class, user); + } + +// private PaymentAgencyService paymentAgencyService; +// +// private SIEmployeeStatusMapper siEmployeeStatusMapper; +// +// private HrmCommonHrmStatusService hrmCommonHrmStatusService; +// +// private HrmConfigSetCache hrmConfigSetCache; + + /** + * 是否是薪酬模块总管理员 + * + * @param currentEmployeeId + * @return + */ + public Boolean isChief(Long currentEmployeeId) { + return getTaxAgentService(user).isChief(currentEmployeeId); + } + + /** + * 权限信息 + * + * @param currentEmployeeId + * @return + */ + public Map permission(Long currentEmployeeId) { + Map resultMap = Maps.newHashMap(); + Boolean isChief = isChief(currentEmployeeId); + Boolean isDefaultOpen = getTaxAgentService(user).isDefaultOpen(currentEmployeeId); + Boolean isAdminEnable = getTaxAgentService(user).isAdminEnable(currentEmployeeId); + Boolean isOpenDevolution = getTaxAgentService(user).isOpenDevolution(); + resultMap.put("isChief", isChief); + resultMap.put("isDefaultOpen", isDefaultOpen); + resultMap.put("isAdminEnable", isAdminEnable); + resultMap.put("isOpenDevolution", isOpenDevolution); + return resultMap; + } + + /** + * 个税口角义务人列表 + * + * @param queryParam + * @return + */ + public PageInfo> list(TaxAgentQueryParam queryParam) { + // 是否开启分权 + boolean isOpenDevolution = getTaxAgentBaseService(user).isOpenDevolution(); + + PageInfo page = getTaxAgentService(user).listPage(queryParam); + List taxAgentPOS = page.getList(); + PageInfo> listPage = new PageInfo<>(); + + if (isOpenDevolution) { + List list = taxAgentPOS; + List taxAgentIds = list.stream().map(TaxAgentPO::getId).collect(Collectors.toList()); + List taxAgentAdmins = getTaxAgentAdminService(user).listByTaxAgentIds(taxAgentIds); + List adminList = getSalaryEmployeeService(user).getEmployeeByIdsAll(taxAgentAdmins.stream().map(TaxAgentAdminPO::getEmployeeId).distinct().collect(Collectors.toList())); + listPage.setList(TaxAgentBO.convertToTableListDTO(taxAgentPOS, null, taxAgentAdmins, adminList)); + } else { + listPage.setList(TaxAgentBO.convertToTableListDTO(taxAgentPOS, null)); + } + + listPage.setTotal(page.getTotal()); + listPage.setPageNum(page.getPageNum()); + listPage.setPageSize(page.getPageSize()); + + + + //构造表格 + TaxAgentBO.buildTaxAgentTable(listPage, isOpenDevolution); + + return listPage; + + } + + public List listAuth(TaxAgentQueryParam taxAgentQueryParam) { + return getTaxAgentService(user).listAuth(taxAgentQueryParam); + } + + public List> paymentAgencyList(TaxAgentQueryParam queryParam) { +// List taxAgentPOS = getTaxAgentService(user).listByIds(queryParam.getIds()); +// List paymentAgencyPOS = paymentAgencyService.listAll(currentTenantKey); +// SalaryAssert.notEmpty(taxAgentPOS, "taxagent data is not exist"); +// TaxAgentPO taxAgentPO = taxAgentPOS.get(0); +// return TaxAgentBO.buildPaymentAgency(taxAgentPO.getPaymentAgency(), paymentAgencyPOS); + return null; + } + + public String paymentAgencySave(TaxAgentSaveParam param) { +// List taxAgentPOS = getTaxAgentService(user).listByIds(Collections.singletonList(param.getId())); +// SalaryAssert.notEmpty(taxAgentPOS, "data is not exist"); +// TaxAgentPO taxAgentPO = taxAgentPOS.get(0); +// List errorList = new ArrayList<>(); +// List resultList = new ArrayList<>(); +// if (StringUtils.isNotBlank(taxAgentPO.getPaymentAgency())) { +// List originList = new ArrayList<>(Arrays.asList(taxAgentPO.getPaymentAgency().split(","))); +// List list = new ArrayList<>(Arrays.asList(param.getPaymentAgency().split(","))); +// originList.removeAll(list); +// if (CollectionUtils.isNotEmpty(originList)) { +// originList.stream().forEach(e -> { +// List employeeStatusPOS = new LambdaQueryChainWrapper<>(siEmployeeStatusMapper) +// .eq(InsuranceEmployeeStatusPO::getTenantKey) +// .eq(InsuranceEmployeeStatusPO::getPaymentAgency, Long.valueOf(e)) +// .eq(InsuranceEmployeeStatusPO::getPaymentOrganization, param.getId()) +// .list(); +// if (CollectionUtils.isNotEmpty(employeeStatusPOS)) { +// errorList.add(e); +// } +// }); +// } +// if (CollectionUtils.isNotEmpty(errorList)) { +// List paymentAgencyPOS = paymentAgencyService.listAll(currentTenantKey); +// errorList.forEach(e -> { +// Optional optionalPaymentAgencyPO = paymentAgencyPOS.stream().filter(po -> Objects.equals(e, String.valueOf(po.getId()))).findFirst(); +// optionalPaymentAgencyPO.ifPresent(paymentAgencyPO -> resultList.add(paymentAgencyPO.getAgencyName())); +// }); +// } +// } +// if (CollectionUtils.isNotEmpty(resultList)) { +// return SalaryI18nUtil.getI18nLabel(currentTenantKey, currentEmploueeId, 115128, "有员工在") + String.join(",", resultList) + SalaryI18nUtil.getI18nLabel(currentTenantKey, +// currentEmploueeId, 115129, "缴纳社保福利,不可取消关联"); +// } else { +// taxAgentPO.setPaymentAgency(param.getPaymentAgency()); +// getTaxAgentService(user).paymentAgencyUpdate(taxAgentPO, currentEmploueeId); +// } + return ""; + } + + /** + * 获取个税扣缴义务人表单 + * + * @param id + * @return + */ + public TaxAgentFormDTO getFrom(Long id) { + TaxAgentFormDTO taxAgentFromDTO = new TaxAgentFormDTO(); + if (id != null) { + TaxAgentPO taxAgent = getTaxAgentService(user).getById(id); + if (taxAgent == null) { + throw new SalaryRunTimeException(String.format(SalaryI18nUtil.getI18nLabel(100543, "个税扣缴人不存在") + "[id:%s]", id)); + } + BeanUtils.copyProperties(taxAgent, taxAgentFromDTO); + } + // 是否开启分权 + boolean isOpenDevolution = getTaxAgentBaseService(user).isOpenDevolution(); + List admins = getTaxAgentAdminService(user).listByTaxAgentIds(Collections.singletonList(id)); + List list = new ArrayList<>(); + if (CollectionUtils.isNotEmpty(admins)) { + list = admins.stream() + .map(admin -> { + Long employeeId = admin.getEmployeeId(); + DataCollectionEmployee employee = getSalaryEmployeeService(user).getEmployeeById(employeeId); + String content = employee == null ? "" : employee.getUsername(); + return TaxAgentEmployeeOptionDTO.builder().id(employeeId).content(content).build(); + + }) + .collect(Collectors.toList()); + } + + taxAgentFromDTO.setAdminUserIds(list); + + return taxAgentFromDTO; + } + + /** + * 保存个税扣缴义务人 + * + * @param saveParam + * @return + */ + public String save(TaxAgentSaveParam saveParam) { + return getTaxAgentService(user).save(saveParam); + } + + /** + * 编辑个税扣缴义务人 + * + * @param saveParam + * @return + */ + public String update(TaxAgentSaveParam saveParam) { + return getTaxAgentService(user).update(saveParam); + } + + /** + * 更换管理员校验 + * + * @param checkParam + * @return + */ + public Boolean adminChangeCheck(TaxAgentAdminChangeCheckParam checkParam) { + return getTaxAgentService(user).adminChangeCheck(checkParam); + } + + /** + * 删除个税扣缴义务人 + * + * @param ids + * @return + */ + public String delete(List ids) { + return getTaxAgentService(user).delete(ids); + } + + /** + * 个税扣缴义务人下拉列表 + * + * @return + */ + public List> selectList(boolean needAuth) { + return getTaxAgentService(user).selectList(needAuth); + } + + public List> selectListAsAdmin() { + return getTaxAgentService(user).selectListAsAdmin(false); + } + + /** + * 范围列表 + * + * @param queryParam + * @return + */ + public PageInfo listRangeInclude(TaxAgentRangeQueryParam queryParam) { + return getTaxAgentManageRangeService(user).listPageByParamAndIncludeType(queryParam, NumberUtils.INTEGER_ONE); + } + + /** + * 范围排除列表 + * + * @param queryParam + * @return + */ + public PageInfo listRangeExclude(TaxAgentRangeQueryParam queryParam) { + return getTaxAgentManageRangeService(user).listPageByParamAndIncludeType(queryParam, NumberUtils.INTEGER_ZERO); + } + + /** + * 获取管理范围表单 + * + * @return + */ + public TaxAgentManageRangeFormDTO getRangeFrom() { + // 查询人员状态 + List hrmStatusList = UserStatusEnum.getHrmStatusList(); + //人员类型下拉列表 + List> selectList = TargetTypeEnum.getSelectList(); + return TaxAgentManageRangeFormDTO.builder().employeeStatus(hrmStatusList).targetTypeList(selectList).build(); + } + + /** + * 保存管理范围 + * + * @param saveParam + * @return + */ + public String saveRange(TaxAgentRangeSaveParam saveParam) { + //将select因XSS过滤造成的异常字符转换回来 + + Optional.ofNullable(saveParam.getTargetParams()).orElse(new ArrayList<>()) + .forEach(targetParam -> { + if (StrUtil.isNotBlank(targetParam.getTarget())) { + targetParam.setTarget(targetParam.getTarget() + .replace("select", "select") + .replace("SELECT", "SELECT") + .replace("join", "join") + .replace("JOIN", "JOIN") + .replace("and", "and") + .replace("AND", "AND") + .replace("or", "or") + .replace("OR", "OR") + .replace("in", "in") + .replace("IN", "IN") + .replace("like", "like") + .replace("LIKE", "LIKE") + .replace("exists", "exists") + .replace("EXISTS", "EXISTS") + .replace("between", "between") + .replace("BETWEEN", "BETWEEN") + .replace("union", "union") + .replace("UNION", "UNION")); + } + }); + + + getTaxAgentManageRangeService(user).save(saveParam); + return StringUtils.EMPTY; + } + + + public String editRange(TaxAgentRangeSaveParam param) { + //将select因XSS过滤造成的异常字符转换回来 + + Optional.ofNullable(param.getTargetParams()).orElse(new ArrayList<>()) + .forEach(targetParam -> { + if (StrUtil.isNotBlank(targetParam.getTarget())) { + targetParam.setTarget(targetParam.getTarget() + .replace("select", "select") + .replace("SELECT", "SELECT") + .replace("join", "join") + .replace("JOIN", "JOIN") + .replace("and", "and") + .replace("AND", "AND") + .replace("or", "or") + .replace("OR", "OR") + .replace("in", "in") + .replace("IN", "IN") + .replace("like", "like") + .replace("LIKE", "LIKE") + .replace("exists", "exists") + .replace("EXISTS", "EXISTS") + .replace("between", "between") + .replace("BETWEEN", "BETWEEN") + .replace("union", "union") + .replace("UNION", "UNION")); + } + }); + + + getTaxAgentManageRangeService(user).edit(param); + return StringUtils.EMPTY; + } + + + /** + * 删除管理范围 + * + * @param ids + * @return + */ + public String deleteRange(Collection ids) { + getTaxAgentManageRangeService(user).deleteByIds(ids); + return StringUtils.EMPTY; + } + + + public PageInfo listExt(TaxAgentRangeExtQueryParam param) { + return getTaxAgentManageRangeService(user).listExt(param); + } + + /** + * 外部人员范围 + * + * @param saveParam + * @return + */ + public String saveExtRange(TaxAgentManageRangeExtSaveParam saveParam) { + getTaxAgentManageRangeService(user).saveExtRange(saveParam); + return StringUtils.EMPTY; + } + + public void deleteExtRange(Collection ids) { + + getTaxAgentManageRangeService(user).deleteExtRange(ids); + } + + + /** + * 获取个税管理的人员情况 + * + * @param id + * @return + */ + public List getEmpListInTaxAgent(Long id) { + return getTaxAgentService(user).listTaxAgentAndEmployeeTree((long) user.getUID()); + } + + + /** + * 同步当前人员管理的个税扣缴义务人人员范围 + * + * @return + */ + public String syncRange() { + long currentEmployeeId = (long) user.getUID(); + String index = SalaryCacheKey.TAX_AGENT_MANAGE_RANGE_SYNC + "-" + currentEmployeeId; + String syncRange = Util.null2String(Util_DataCache.getObjVal(index)); + if (StringUtils.isEmpty(syncRange)) { + TaxAgentQueryParam param = TaxAgentQueryParam.builder().build(); + param.setFilterType(AuthFilterTypeEnum.ADMIN_DATA); + List taxAgentIds = getTaxAgentService(user).listAuth(param).stream().map(TaxAgentPO::getId).collect(Collectors.toList()); + getTaxAgentManageRangeService(user).syncManageRange(taxAgentIds, index); + } else { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(135788, "人员范围同步过于频繁,请稍后再试")); + } + return SalaryI18nUtil.getI18nLabel(93945, "同步成功"); + } + + + /** + * 同步所有个税扣缴义务人的人员范围 + * + * @return + */ + public String syncAllRange() { + String syncRange = Util.null2String(Util_DataCache.getObjVal(SalaryCacheKey.TAX_AGENT_MANAGE_RANGE_SYNC)); + if (StringUtils.isEmpty(syncRange)) { + getTaxAgentManageRangeService(user).syncManageRange(null, SalaryCacheKey.TAX_AGENT_MANAGE_RANGE_SYNC); + } else { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(135788, "人员范围同步过于频繁,请稍后再试")); + } + return SalaryI18nUtil.getI18nLabel(93945, "同步成功"); + } + + /** + * 下载人员范围导入模板 + * + * @param downloadTemplateParam + * @return + */ + public XSSFWorkbook exportImportTemplate(TaxAgentRangeDownloadTemplateParam downloadTemplateParam) { + return getTaxAgentExcelService(user).downloadTemplateRange(downloadTemplateParam, user.getUID()); + } + + /** + * 预览人员范围 + * + * @param taxAgentImportParam + */ + public Map preview(TaxAgentImportParam taxAgentImportParam) { + return getTaxAgentExcelService(user).preview(taxAgentImportParam); + } + + /** + * 个税扣缴义务人-人员范围导入 + * + * @param taxAgentImportParam + */ + public Map importData(TaxAgentImportParam taxAgentImportParam) { + return getTaxAgentManageRangeService(user).importData(taxAgentImportParam); + } + + +} diff --git a/src/com/engine/salary/wrapper/TaxDeclarationDetailWrapper.java b/src/com/engine/salary/wrapper/TaxDeclarationDetailWrapper.java new file mode 100644 index 000000000..aae286e0f --- /dev/null +++ b/src/com/engine/salary/wrapper/TaxDeclarationDetailWrapper.java @@ -0,0 +1,65 @@ +package com.engine.salary.wrapper; + +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.entity.taxdeclaration.param.TaxDeclarationDetailListQueryParam; +import com.engine.salary.entity.taxdeclaration.po.TaxDeclarationPO; +import com.engine.salary.enums.salarysob.IncomeCategoryEnum; +import com.engine.salary.service.TaxDeclarationDetailService; +import com.engine.salary.service.TaxDeclarationService; +import com.engine.salary.service.impl.TaxDeclarationDetailServiceImpl; +import com.engine.salary.service.impl.TaxDeclarationServiceImpl; +import com.engine.salary.util.page.PageInfo; +import lombok.extern.slf4j.Slf4j; +import weaver.hrm.User; + +import java.util.Objects; + + +/** + * 个税申报表明细 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Slf4j +public class TaxDeclarationDetailWrapper extends Service { + + private TaxDeclarationDetailService getTaxDeclarationDetailService(User user) { + return ServiceUtil.getService(TaxDeclarationDetailServiceImpl.class, user); + } + + private TaxDeclarationService getTaxDeclarationService(User user) { + return ServiceUtil.getService(TaxDeclarationServiceImpl.class, user); + } + + /** + * 个税申报表明细列表 + * + * @param queryParam 列表查询条件 + * @return + */ + public PageInfo listPage(TaxDeclarationDetailListQueryParam queryParam) { + + TaxDeclarationPO taxDeclarationPO = getTaxDeclarationService(user).getById(queryParam.getTaxDeclarationId()); + + + // 正常工资薪金所得 + if (Objects.equals(taxDeclarationPO.getIncomeCategory(), IncomeCategoryEnum.WAGES_AND_SALARIES.getValue())) { + return getTaxDeclarationDetailService(user).listDtoPageByParam4Wage(queryParam); + } + // 劳务报酬所得 + if (Objects.equals(taxDeclarationPO.getIncomeCategory(), IncomeCategoryEnum.REMUNERATION_FOR_LABOR.getValue())) { + return getTaxDeclarationDetailService(user).listDtoPageByParam4Labor(queryParam); + } + + // 全年一次性奖金收入 + if (Objects.equals(taxDeclarationPO.getIncomeCategory(), IncomeCategoryEnum.ONETIME_ANNUAL_BONUS.getValue())) { + return getTaxDeclarationDetailService(user).listDtoPageByParam4Annual(queryParam); + } + + return new PageInfo(); + } +} diff --git a/src/com/engine/salary/wrapper/TaxDeclarationWrapper.java b/src/com/engine/salary/wrapper/TaxDeclarationWrapper.java new file mode 100644 index 000000000..38670737a --- /dev/null +++ b/src/com/engine/salary/wrapper/TaxDeclarationWrapper.java @@ -0,0 +1,161 @@ +package com.engine.salary.wrapper; + +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.component.WeaFormOption; +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import com.engine.salary.entity.taxdeclaration.bo.TaxDeclarationBO; +import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationFormDTO; +import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationInfoDTO; +import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationListDTO; +import com.engine.salary.entity.taxdeclaration.param.TaxDeclarationListQueryParam; +import com.engine.salary.entity.taxdeclaration.param.TaxDeclarationSaveParam; +import com.engine.salary.entity.taxdeclaration.po.TaxDeclarationPO; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.service.SalaryEmployeeService; +import com.engine.salary.service.TaxAgentService; +import com.engine.salary.service.TaxDeclarationService; +import com.engine.salary.service.impl.SalaryEmployeeServiceImpl; +import com.engine.salary.service.impl.TaxAgentServiceImpl; +import com.engine.salary.service.impl.TaxDeclarationServiceImpl; +import com.engine.salary.util.SalaryDateUtil; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.page.PageInfo; +import com.google.common.collect.Lists; +import org.apache.commons.collections4.CollectionUtils; +import weaver.hrm.User; + +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.stream.Collectors; + +/** + * 个税申报表 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class TaxDeclarationWrapper extends Service { + + private TaxDeclarationService getTaxDeclarationService(User user) { + return ServiceUtil.getService(TaxDeclarationServiceImpl.class, user); + } + + private TaxAgentService getTaxAgentService(User user) { + return ServiceUtil.getService(TaxAgentServiceImpl.class, user); + } + + private SalaryEmployeeService getSalaryEmployeeService(User user) { + return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user); + } + + /** + * 个税申报表列表 + * + * @param queryParam 列表查询条件 + * @param + * @return + */ + public PageInfo listPage(TaxDeclarationListQueryParam queryParam) { + // 询个税申报表(分页) + PageInfo page = getTaxDeclarationService(user).listPageByParam(queryParam); + PageInfo dtoPage = new PageInfo(TaxDeclarationListDTO.class); + dtoPage.setPageNum(queryParam.getCurrent()); + dtoPage.setPageSize(queryParam.getPageSize()); + dtoPage.setTotal(page.getTotal()); + List list = page.getList(); + if (CollectionUtils.isNotEmpty(list)) { + // 查询人员 + List employeeIds = SalaryEntityUtil.properties(list, TaxDeclarationPO::getCreator, Collectors.toList()); + List employeeComInfos = getSalaryEmployeeService(user).getEmployeeByIdsAll(employeeIds); + // 查询个税扣缴义务人 + Set taxAgentIds = SalaryEntityUtil.properties(list, TaxDeclarationPO::getTaxAgentId); + List taxAgentPOS = getTaxDeclarationService(user).countByTaxDeclarationId(taxAgentIds); + // 转换成列表dto + List taxDeclarationListDTOS = TaxDeclarationBO.convert2ListDTO(list, employeeComInfos, taxAgentPOS); + dtoPage.setList(taxDeclarationListDTOS); + } + return dtoPage; + } + + + public TaxDeclarationFormDTO getForm(Long id) { + TaxDeclarationFormDTO formDTO = new TaxDeclarationFormDTO(); + if (Objects.nonNull(id)) { + // 查询个税申报表 + TaxDeclarationPO taxDeclaration = getTaxDeclarationService(user).getById(id); + if (Objects.isNull(taxDeclaration)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98877, "个税申报表不存在或已删除")); + } + // 查询个税扣缴义务人 + TaxAgentPO taxAgent = getTaxAgentService(user).getById(id); + //日期转换 + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM"); + String transformDate = simpleDateFormat.format(taxDeclaration.getSalaryMonth()); + // 转换成个税申报表详情dto + formDTO = TaxDeclarationFormDTO.builder().salaryMonth(SalaryDateUtil.String2YearMonth(transformDate)).taxAgentId(taxDeclaration.getTaxAgentId()).taxAgentName(Optional.ofNullable(taxAgent).map(TaxAgentPO::getName).orElse("")).description(taxDeclaration.getDescription()).build(); + } + // 转换成前端所需的数据格式 + // WeaForm weaForm = SalaryFormatUtil.getInstance().buildForm(TaxDeclarationFormDTO.class, formDTO); + + // 查询租户所有的个税扣缴义务人 + Collection taxAgentListDTOS = getTaxAgentService(user).listAll(); + // 表单中个税扣缴义务人的可选项 + List weaFormOptions = Lists.newArrayListWithExpectedSize(taxAgentListDTOS.size()); + for (TaxAgentPO taxAgent : taxAgentListDTOS) { + weaFormOptions.add(new WeaFormOption("" + taxAgent.getId(), taxAgent.getName())); + } +// weaForm.getItems().forEach((k, v) -> { +// if (StringUtils.equals("taxAgentId", k)) { +// v.setOptions(weaFormOptions); +// } +// if (StringUtils.equals("salaryMonth", k)) { +// Map otherParams = new HashMap<>(); +// otherParams.put("type", "month"); +// v.setOtherParams(otherParams); +// } +// }); + return formDTO; + } + + /** + * 查询个税申报表的基本信息 + * + * @param id 个税申报表id + * @return + */ + public TaxDeclarationInfoDTO getTaxDeclarationInfoById(Long id) { + // 查询个税申报表 + TaxDeclarationPO taxDeclaration = getTaxDeclarationService(user).getById(id); + if (Objects.isNull(taxDeclaration)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98877, "个税申报表不存在或已删除")); + } + //日期转换 + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM"); + String transformDate = simpleDateFormat.format(taxDeclaration.getSalaryMonth()); + // 查询个税扣缴义务人 + TaxAgentPO taxAgentPO = getTaxAgentService(user).getById(taxDeclaration.getTaxAgentId()); + return TaxDeclarationInfoDTO.builder().salaryMonth(SalaryDateUtil.String2YearMonth(transformDate)).taxAgentId(taxDeclaration.getTaxAgentId()).taxAgentName(Optional.ofNullable(taxAgentPO).map(TaxAgentPO::getName).orElse("")).build(); + } + + /** + * 保存 + * + * @param saveParam 保存参数 + */ + public void save(TaxDeclarationSaveParam saveParam) { + getTaxDeclarationService(user).save(saveParam); + } + + /** + * 撤回个税申报 + * @param taxDeclarationId + */ + public void withDrawTaxDeclaration(Long taxDeclarationId) { + getTaxDeclarationService(user).withDrawTaxDeclaration(taxDeclarationId); + } +} diff --git a/src/com/engine/salary/wrapper/VariableArchiveWrapper.java b/src/com/engine/salary/wrapper/VariableArchiveWrapper.java new file mode 100644 index 000000000..927fa299a --- /dev/null +++ b/src/com/engine/salary/wrapper/VariableArchiveWrapper.java @@ -0,0 +1,130 @@ +package com.engine.salary.wrapper; + +import com.cloudstore.eccom.pc.table.WeaTableColumn; +import com.cloudstore.eccom.result.WeaResultMsg; +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.component.SalaryWeaTable; +import com.engine.salary.entity.datacollection.bo.VariableArchiveBO; +import com.engine.salary.entity.datacollection.dto.VariableArchiveListDTO; +import com.engine.salary.entity.datacollection.dto.VariableItemListDTO; +import com.engine.salary.entity.datacollection.param.VariableArchiveImportHandleParam; +import com.engine.salary.entity.datacollection.param.VariableArchiveQueryParam; +import com.engine.salary.entity.datacollection.param.VariableArchiveSaveParam; +import com.engine.salary.entity.datacollection.po.VariableItemPO; +import com.engine.salary.service.VariableArchiveService; +import com.engine.salary.service.VariableItemService; +import com.engine.salary.service.impl.VariableArchiveServiceImpl; +import com.engine.salary.service.impl.VariableItemServiceImpl; +import com.engine.salary.util.excel.ExcelPreviewDTO; +import com.engine.salary.util.page.PageInfo; +import lombok.extern.slf4j.Slf4j; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import weaver.hrm.User; + +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @Description: 浮动薪酬 + * @Author: xzy + * @Date: 2024/8/6 17:39 + */ +@Slf4j +public class VariableArchiveWrapper extends Service { + private VariableArchiveService getVariableArchiveService(User user) { + return ServiceUtil.getService(VariableArchiveServiceImpl.class, user); + } + + private VariableItemService getVariableItemService(User user) { + return ServiceUtil.getService(VariableItemServiceImpl.class, user); + } + + /** + * 数据采集-浮动薪酬列表(分页) + * + * @param queryParam + * @return + */ + public Map list(VariableArchiveQueryParam queryParam) { + + // 薪资档案列表 + PageInfo pageInfo = getVariableArchiveService(user).listPage(queryParam); + List salaryArchives = pageInfo.getList(); + + // 获取所有浮动薪酬项目 + List variableItems = getVariableItemService(user).listAll(); + + // 整合所有的显示列(固定列+薪资项目动态列) + List> listMaps = getVariableArchiveService(user).buildVariableArchiveData(salaryArchives); + + PageInfo> pageInfos = new PageInfo>(listMaps); + pageInfos.setTotal(pageInfo.getTotal()); + pageInfos.setPageNum(pageInfo.getPageNum()); + pageInfos.setPageSize(pageInfo.getPageSize()); + + //动态列组装 + List columns = VariableArchiveBO.buildVariableArchiveTable(variableItems); + + SalaryWeaTable table = new SalaryWeaTable(user, VariableArchiveListDTO.class); + table.setColumns(columns); + WeaResultMsg result = new WeaResultMsg(false); + result.putAll(table.makeDataResult()); + result.success(); + + Map datas = new HashMap<>(); + datas.put("pageInfo", pageInfos); + datas.put("dataKey", result.getResultMap()); + + return datas; + } + + /** + * 创建浮动薪酬档案 + * + * @param saveParam + */ + public void createData(VariableArchiveSaveParam saveParam) { + getVariableArchiveService(user).createData(saveParam); + } + + /** + * 浮动薪酬档案明细 + * + * @param queryParam + * @return + */ + public Map getDetail(VariableArchiveQueryParam queryParam) { + return getVariableArchiveService(user).getDetail(queryParam); + } + + public List getCreateForm() { + return getVariableArchiveService(user).getCreateForm(); + } + + public XSSFWorkbook downloadTemplate(VariableArchiveQueryParam param) { + return getVariableArchiveService(user).downloadTemplate(param); + } + + public ExcelPreviewDTO preview(VariableArchiveImportHandleParam importParam) { + return getVariableArchiveService(user).preview(importParam); + } + + public Map importData(VariableArchiveImportHandleParam importParam) { + return getVariableArchiveService(user).importData(importParam); + } + + public XSSFWorkbook export(VariableArchiveQueryParam param) { + return getVariableArchiveService(user).export(param); + } + + public void deleteSelectVariableArchive(Collection deleteIds) { + getVariableArchiveService(user).deleteSelectVariableArchive(deleteIds); + } + + public void updateData(VariableArchiveSaveParam updateParam) { + getVariableArchiveService(user).updateData(updateParam); + } +} diff --git a/src/com/engine/salary/wrapper/VariableItemWrapper.java b/src/com/engine/salary/wrapper/VariableItemWrapper.java new file mode 100644 index 000000000..92119e90f --- /dev/null +++ b/src/com/engine/salary/wrapper/VariableItemWrapper.java @@ -0,0 +1,75 @@ +package com.engine.salary.wrapper; + + +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.entity.datacollection.dto.VariableItemListDTO; +import com.engine.salary.entity.datacollection.param.VariableItemQueryParam; +import com.engine.salary.entity.datacollection.param.VariableItemSaveParam; +import com.engine.salary.service.VariableItemService; +import com.engine.salary.service.impl.VariableItemServiceImpl; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.util.valid.ValidUtil; +import lombok.extern.slf4j.Slf4j; +import weaver.hrm.User; + +import java.util.List; + +/** + * @Description: 浮动薪酬项目 + * @Author: xzy + * @Date: 2024/8/6 17:39 + */ +@Slf4j +public class VariableItemWrapper extends Service { + private VariableItemService getVariableItemService(User user) { + return ServiceUtil.getService(VariableItemServiceImpl.class, user); + } + + /** + * 获取所有的浮动薪酬项目 + * + * @param queryParam + */ + public PageInfo listPage(VariableItemQueryParam queryParam) { + return getVariableItemService(user).listPage(queryParam); + } + + /** + * 新建浮动薪酬项目 + * + * @param saveParam + */ + public void save(VariableItemSaveParam saveParam) { + ValidUtil.doValidator(saveParam); + getVariableItemService(user).save(saveParam); + } + + /** + * 更新浮动薪酬项目 + * + * @param saveParam + */ + public void update(VariableItemSaveParam saveParam) { + ValidUtil.doValidator(saveParam); + getVariableItemService(user).update(saveParam); + } + + /** + * 删除浮动薪资项目 + * + * @param itemIds + */ + public void deleteItems(List itemIds) { + getVariableItemService(user).deleteItems(itemIds); + } + + /** + * 浮动薪酬项目详细信息 + * + * @param id + */ + public VariableItemListDTO getDetail(Long id) { + return getVariableItemService(user).getDetail(id); + } +} diff --git a/src/com/engine/salary/wrapper/proxy/SalaryAcctRecordWrapperProxy.java b/src/com/engine/salary/wrapper/proxy/SalaryAcctRecordWrapperProxy.java new file mode 100644 index 000000000..0a0bfb86c --- /dev/null +++ b/src/com/engine/salary/wrapper/proxy/SalaryAcctRecordWrapperProxy.java @@ -0,0 +1,53 @@ +package com.engine.salary.wrapper.proxy; + +import com.engine.salary.entity.salaryacct.dto.SalaryAcctRecordListDTO; +import com.engine.salary.entity.salaryacct.param.SalaryAcctRecordQueryParam; +import com.engine.salary.entity.salaryacct.param.SalaryAcctRecordSaveParam; +import com.engine.salary.util.page.PageInfo; + +import java.util.Collection; +import java.util.Map; + +public interface SalaryAcctRecordWrapperProxy { + /** + * 分页列表 + */ + PageInfo listPage(SalaryAcctRecordQueryParam queryParam); + + /** + * 薪资核算记录详情 + * + * @param id 薪资核算记录id + */ + Map getForm(Long id); + + + /** + * 保存 + * + * @param saveParam 保存参数 + */ + Long save(SalaryAcctRecordSaveParam saveParam); + + /** + * 删除 + * + * @param ids 薪资核算记录的id + */ + void delete(Collection ids); + + /** + * 归档 + * + * @param id 薪资核算记录的id + */ + void file(Long id); + + /** + * 重新核算 + * + * @param id 薪资核算记录的id + */ + void reCalculate(Long id); + +} diff --git a/src/com/engine/salary/wrapper/proxy/SalaryAcctResultWrapperProxy.java b/src/com/engine/salary/wrapper/proxy/SalaryAcctResultWrapperProxy.java new file mode 100644 index 000000000..7a984d1c4 --- /dev/null +++ b/src/com/engine/salary/wrapper/proxy/SalaryAcctResultWrapperProxy.java @@ -0,0 +1,23 @@ +package com.engine.salary.wrapper.proxy; + +import com.engine.salary.entity.salaryacct.dto.SalaryAcctResultDetailDTO; +import com.engine.salary.entity.salaryacct.dto.SalaryAcctResultListColumnDTO; +import com.engine.salary.entity.salaryacct.param.*; + +import java.util.Map; + +public interface SalaryAcctResultWrapperProxy { + Map listPage(SalaryAcctResultQueryParam queryParam); + + SalaryAcctResultDetailDTO getForm(Long salaryAcctEmployeeId); + + Map getColumnBySalaryAcctRecordId(Long salaryAcctRecordId); + + void save(SalaryAcctResultSaveParam saveParam); + + void updateLockStatusByParam(SalaryAcctResultUpdateLockStatusParam updateParam); + + void calculate(SalaryAcctCalculateParam calculateParam); + + void batchUpdate(SalaryAcctResultBatchUpdateParam param); +} diff --git a/src/com/engine/salary/wrapper/proxy/SalaryArchiveItemWrapperProxy.java b/src/com/engine/salary/wrapper/proxy/SalaryArchiveItemWrapperProxy.java new file mode 100644 index 000000000..79ffa914a --- /dev/null +++ b/src/com/engine/salary/wrapper/proxy/SalaryArchiveItemWrapperProxy.java @@ -0,0 +1,67 @@ +package com.engine.salary.wrapper.proxy; + +import com.engine.salary.entity.salaryarchive.dto.SalaryArchiveItemFormDTO; +import com.engine.salary.entity.salaryarchive.dto.SalaryItemAdjustRecordListDTO; +import com.engine.salary.entity.salaryarchive.dto.SingleSalaryItemAdjustRecordListDTO; +import com.engine.salary.entity.salaryarchive.param.SalaryArchiveItemSaveParam; +import com.engine.salary.entity.salaryarchive.param.SalaryItemAdjustRecordQueryParam; +import com.engine.salary.entity.salaryarchive.param.SingleSalaryItemAdjustRecordQueryParam; +import com.engine.salary.util.page.PageInfo; + +public interface SalaryArchiveItemWrapperProxy { + + + SalaryArchiveItemFormDTO getSalaryItemForm(Long salaryArchiveId); + + + /** + * 通过薪资档案的薪资项目id获取薪资项目调整表单 + * + * @param salaryArchiveItemId + * @return + */ + SalaryArchiveItemFormDTO getSalaryItemFormBySalaryArchiveItemId(Long salaryArchiveItemId); + + /** + * 保存薪资项目调整 + * + * @param saveParam + * @return + */ + String saveSalaryItem(SalaryArchiveItemSaveParam saveParam); + + /** + * 删除薪资项目调整 + * + * @param salaryArchiveItemId + * @return + */ + String deleteSalaryItem(Long salaryArchiveItemId); + + /** + * 薪资项目调整记录列表 + * + * @param queryParam + * @return + */ + PageInfo adjustRecordList(SalaryItemAdjustRecordQueryParam queryParam); + + /** + * 单个档案的薪资项目调整记录列表 + * + * @param queryParam + * @return + */ + PageInfo singleSalaryItemAdjustRecordList(SingleSalaryItemAdjustRecordQueryParam queryParam); + + + SalaryArchiveItemFormDTO getSingleSalaryItemInfo(SingleSalaryItemAdjustRecordListDTO queryParam); + + /** + * @description 单个档案的薪资项目调整的编辑 + * @return void + * @author Harryxzy + * @date 2022/11/14 11:45 + */ + String editSingleSalaryItem(SalaryArchiveItemSaveParam salaryArchiveItemSaveParam); +} diff --git a/src/com/engine/salary/wrapper/proxy/SalarySendWrapperProxy.java b/src/com/engine/salary/wrapper/proxy/SalarySendWrapperProxy.java new file mode 100644 index 000000000..df063f4cd --- /dev/null +++ b/src/com/engine/salary/wrapper/proxy/SalarySendWrapperProxy.java @@ -0,0 +1,34 @@ +package com.engine.salary.wrapper.proxy; + +import com.engine.salary.entity.salaryBill.param.SalarySendGrantParam; +import com.engine.salary.entity.salaryBill.param.SalarySendWithdrawParam; + +import java.util.Map; + +/** + * 工资单发放代理 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public interface SalarySendWrapperProxy { + + /** + * 工资单发放 + * + * @param queryParam + * @return + */ + Map grant(SalarySendGrantParam queryParam); + + /** + * 工资单撤回 + * + * @param queryParam + * @return + */ + Map withdraw(SalarySendWithdrawParam queryParam); + +}